From 5c7b4cf719aa3f48916250f3ae904238df04f071 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Tue, 29 May 2018 12:46:07 +0300 Subject: [PATCH] The "later" button on travel cards hides the card until the application is restarted --- .../src/net/osmand/plus/AppInitializer.java | 2 ++ .../src/net/osmand/plus/OsmandSettings.java | 3 ++ .../explore/ExploreTabFragment.java | 29 +++++++++++++++++-- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 7ab054d9cd..aacab9a87a 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -177,6 +177,8 @@ public class AppInitializer implements IProgress { startPrefs.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit(); appVersionChanged = true; } + app.getSettings().SHOW_TRAVEL_UPDATE_CARD.set(true); + app.getSettings().SHOW_TRAVEL_NEEDED_MAPS_CARD.set(true); initSettings = true; } diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 33c424033a..242d543373 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -3006,6 +3006,9 @@ public class OsmandSettings { public final OsmandPreference SELECTED_TRAVEL_BOOK = new StringPreference("selected_travel_book", "").makeGlobal(); + public final OsmandPreference SHOW_TRAVEL_UPDATE_CARD = new BooleanPreference("show_travel_update_card", true).makeGlobal(); + public final OsmandPreference SHOW_TRAVEL_NEEDED_MAPS_CARD = new BooleanPreference("show_travel_needed_maps_card", true).makeGlobal(); + public final ListStringPreference TRANSPORT_DEFAULT_SETTINGS = (ListStringPreference) new ListStringPreference("transport_default_settings", "transportStops", ",").makeProfile(); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index 047a66fd16..2f05c8c578 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -16,6 +16,7 @@ import android.view.ViewGroup; import net.osmand.data.LatLon; import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.Version; import net.osmand.plus.base.BaseOsmAndFragment; @@ -206,6 +207,22 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv addNeededMapsCard(); } + private boolean showUpdateCard() { + OsmandSettings settings = getSettings(); + if (settings != null) { + return settings.SHOW_TRAVEL_UPDATE_CARD.get(); + } + return false; + } + + private boolean showNeededMapsCard() { + OsmandSettings settings = getSettings(); + if (settings != null) { + return settings.SHOW_TRAVEL_NEEDED_MAPS_CARD.get(); + } + return false; + } + private void addDownloadUpdateCard() { final OsmandApplication app = getMyApplication(); if (app != null && adapter != null) { @@ -214,7 +231,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv boolean outdated = mainIndexItem != null && mainIndexItem.isOutdated(); File selectedTravelBook = app.getTravelDbHelper().getSelectedTravelBook(); - if (selectedTravelBook == null || outdated) { + if (selectedTravelBook == null || (outdated && showUpdateCard())) { boolean showOtherMaps = false; if (selectedTravelBook == null) { List items = downloadThread.getIndexes().getWikivoyageItems(); @@ -238,6 +255,10 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv downloadThread.cancelDownload(mainIndexItem); adapter.updateDownloadUpdateCard(false); } else if (!downloadUpdateCard.isDownload()) { + OsmandSettings settings = getSettings(); + if (settings != null) { + settings.SHOW_TRAVEL_UPDATE_CARD.set(false); + } removeDownloadUpdateCard(); } else if (downloadUpdateCard.isShowOtherMapsBtn()) { Activity activity = getActivity(); @@ -258,7 +279,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv private void addNeededMapsCard() { final OsmandApplication app = getMyApplication(); - if (app != null && !neededIndexItems.isEmpty() && adapter != null) { + if (app != null && !neededIndexItems.isEmpty() && adapter != null && showNeededMapsCard()) { neededMapsCard = new TravelNeededMapsCard(app, nightMode, neededIndexItems); neededMapsCard.setListener(new TravelNeededMapsCard.CardListener() { @Override @@ -277,6 +298,10 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv adapter.updateNeededMapsCard(false); } } else { + OsmandSettings settings = getSettings(); + if (settings != null) { + settings.SHOW_TRAVEL_NEEDED_MAPS_CARD.set(false); + } removeNeededMapsCard(); } }