From ffc909b9488dcef1a5662c725e9c959175737593 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 16 Nov 2015 09:31:54 +0100 Subject: [PATCH] add pre 2.2 settings --- OsmAnd/src/net/osmand/plus/AppInitializer.java | 12 ++++++++++-- OsmAnd/src/net/osmand/plus/OsmandSettings.java | 4 ++++ .../src/net/osmand/plus/activities/MapActivity.java | 6 +----- .../net/osmand/plus/dashboard/DashboardOnMap.java | 6 ------ .../tools/DashboardSettingsDialogFragment.java | 9 ++++----- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 33022387c7..262e182941 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -52,13 +52,15 @@ import java.util.Random; import btools.routingapp.BRouterServiceConnection; /** - * Created by Denis - * on 03.03.15. */ public class AppInitializer implements IProgress { + // 22 - 2.2 + private static final int CURRENT_VERSION_FOR_UGPRADE = 22; + public static final boolean TIPS_AND_TRICKS = false; private static final String FIRST_TIME_APP_RUN = "FIRST_TIME_APP_RUN"; //$NON-NLS-1$ + private static final String VERSION_INSTALLED_NUMBER = "VERSION_INSTALLED_NUMBER"; //$NON-NLS-1$ public static final String NUMBER_OF_STARTS = "NUMBER_OF_STARTS"; //$NON-NLS-1$ public static final String FIRST_INSTALLED = "FIRST_INSTALLED"; //$NON-NLS-1$ private static final String VECTOR_INDEXES_CHECK = "VECTOR_INDEXES_CHECK"; //$NON-NLS-1$ @@ -130,7 +132,13 @@ public class AppInitializer implements IProgress { firstTime = true; startPrefs.edit().putBoolean(FIRST_TIME_APP_RUN, true).commit(); startPrefs.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit(); + startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, CURRENT_VERSION_FOR_UGPRADE).commit(); } else if (!Version.getFullVersion(app).equals(startPrefs.getString(VERSION_INSTALLED, ""))) { + if(startPrefs.getInt(VERSION_INSTALLED_NUMBER, 0) < 22) { + app.getSettings().SHOW_DASHBOARD_ON_START.set(true); + app.getSettings().SHOW_DASHBOARD_ON_MAP_SCREEN.set(true); + app.getSettings().SHOW_CARD_TO_CHOOSE_DRAWER.set(true); + } startPrefs.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit(); appVersionChanged = true; } diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 1756d3b47c..b6db90d37b 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -633,6 +633,10 @@ public class OsmandSettings { } public final CommonPreference USE_FAST_RECALCULATION = new BooleanPreference("use_fast_recalculation", true).makeGlobal().cache(); + public final CommonPreference SHOW_CARD_TO_CHOOSE_DRAWER = new BooleanPreference("show_card_to_choose_drawer", false).makeGlobal(); + public final CommonPreference SHOW_DASHBOARD_ON_START = new BooleanPreference("should_show_dashboard_on_start", false).makeGlobal(); + public final CommonPreference SHOW_DASHBOARD_ON_MAP_SCREEN = new BooleanPreference("show_dashboard_on_map_screen", false).makeGlobal(); + // this value string is synchronized with settings_pref.xml preference name public final CommonPreference USE_INTERNET_TO_DOWNLOAD_TILES = new BooleanPreference("use_internet_to_download_tiles", true).makeGlobal().cache(); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 1907276871..c45c3e8493 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -140,8 +140,6 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents { private IMapDownloaderCallback downloaderCallback; private DrawerLayout drawerLayout; - public static final String SHOULD_SHOW_DASHBOARD_ON_START = "should_show_dashboard_on_start"; - private Notification getNotification() { Intent notificationIndent = new Intent(this, getMyApplication().getAppCustomization().getMapActivity()); notificationIndent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); @@ -393,9 +391,7 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents { long tm = System.currentTimeMillis(); if (app.isApplicationInitializing() || DashboardOnMap.staticVisible) { if (!dashboardOnMap.isVisible()) { - final OsmandSettings.CommonPreference shouldShowDashboardOnStart = - settings.registerBooleanPreference(MapActivity.SHOULD_SHOW_DASHBOARD_ON_START, true); - if (shouldShowDashboardOnStart.get() || dashboardOnMap.hasCriticalMessages()) { + if (settings.SHOW_DASHBOARD_ON_START.get()) { dashboardOnMap.setDashboardVisibility(true, DashboardOnMap.staticVisibleType); } else { if (ErrorBottomSheetDialog.shouldShow(settings, this)) { diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index 6d9b6d5111..5d88c0c422 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -904,12 +904,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks { transaction.show(frag).commit(); } - // TODO: 11/13/15 Remove - public boolean hasCriticalMessages() { - final OsmandSettings settings = getMyApplication().getSettings(); - return rateUsShouldShow.shouldShow(settings, mapActivity, DashRateUsFragment.TAG); - } - View getParentView() { return dashboardView; } diff --git a/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java index 8ee361023e..dc09227fea 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java @@ -71,11 +71,10 @@ public class DashboardSettingsDialogFragment extends DialogFragment R.layout.show_dashboard_on_start_dialog_item, null, false); final TextView textView = (TextView) view.findViewById(R.id.text); textView.setText(R.string.show_on_start); - final OsmandSettings.CommonPreference shouldShowDashboardOnStart = - settings.registerBooleanPreference(MapActivity.SHOULD_SHOW_DASHBOARD_ON_START, true); final CompoundButton compoundButton = (CompoundButton) view.findViewById(R.id.check_item); - compoundButton.setChecked(shouldShowDashboardOnStart.get()); - textView.setTextColor(shouldShowDashboardOnStart.get() ? textColorPrimary + // FIXME Yura add settings.SHOW_DASHBOARD_ON_MAP_SCREEN + compoundButton.setChecked(settings.SHOW_DASHBOARD_ON_MAP_SCREEN.get()); + textView.setTextColor(settings.SHOW_DASHBOARD_ON_MAP_SCREEN.get() ? textColorPrimary : textColorSecondary); compoundButton.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @@ -111,7 +110,7 @@ public class DashboardSettingsDialogFragment extends DialogFragment } } mapActivity.getDashboard().refreshDashboardFragments(); - shouldShowDashboardOnStart.set(compoundButton.isChecked()); + settings.SHOW_DASHBOARD_ON_MAP_SCREEN.set(compoundButton.isChecked()); } }) .setNegativeButton(R.string.shared_string_cancel, null);