diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 7f78785a65..2629aa01d2 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -56,8 +56,11 @@ import btools.routingapp.BRouterServiceConnection; public class AppInitializer implements IProgress { public static final boolean TIPS_AND_TRICKS = false; - + private static final String FIRST_TIME_APP_RUN = "FIRST_TIME_APP_RUN"; //$NON-NLS-1$ + protected static final String NUMBER_OF_STARTS = "NUMBER_OF_STARTS"; //$NON-NLS-1$ + protected static final String FIRST_INSTALLED = "FIRST_INSTALLED"; //$NON-NLS-1$ private static final String VECTOR_INDEXES_CHECK = "VECTOR_INDEXES_CHECK"; //$NON-NLS-1$ + private static final String VERSION_INSTALLED = "VERSION_INSTALLED"; //$NON-NLS-1$ private static final String EXCEPTION_FILE_SIZE = "EXCEPTION_FS"; //$NON-NLS-1$ public static final String LATEST_CHANGES_URL = "changes-2.1.html"; @@ -110,18 +113,22 @@ public class AppInitializer implements IProgress { if(initSettings) { return; } - OsmandSettings settings = getSettings(activity); - firstTime = settings.FIRST_TIME_APP_RUN.get(); - if (firstTime) { - settings.FIRST_TIME_APP_RUN.set(false); - settings.VERSION_INSTALLED.set(Version.getFullVersion(app)); - } else if (!Version.getFullVersion(app).equals(settings.VERSION_INSTALLED.get())) { - settings.VERSION_INSTALLED.set(Version.getFullVersion(app)); - appVersionChanged = true; + SharedPreferences pref = activity.getPreferences(Context.MODE_WORLD_WRITEABLE); + if(!pref.contains(NUMBER_OF_STARTS)) { + pref.edit().putInt(NUMBER_OF_STARTS, 1).commit(); + } else { + pref.edit().putInt(NUMBER_OF_STARTS, pref.getInt(NUMBER_OF_STARTS, 0) + 1).commit(); } - settings.NUMBER_OF_APPLICATION_STARTS.set(settings.NUMBER_OF_APPLICATION_STARTS.get() + 1); - if (settings.FIRST_INSTALLED_DATE.get() == -1) { - settings.FIRST_INSTALLED_DATE.set(System.currentTimeMillis()); + if (!pref.contains(FIRST_INSTALLED)) { + pref.edit().putLong(FIRST_INSTALLED, System.currentTimeMillis()).commit(); + } + if (!pref.contains(FIRST_TIME_APP_RUN)) { + firstTime = true; + pref.edit().putBoolean(FIRST_TIME_APP_RUN, true).commit(); + pref.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit(); + } else if (!Version.getFullVersion(app).equals(pref.getString(VERSION_INSTALLED, ""))) { + pref.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit(); + appVersionChanged = true; } initSettings = true; } @@ -134,17 +141,7 @@ public class AppInitializer implements IProgress { public void setFirstTime(boolean firstTime) { this.firstTime = firstTime; } - - public void writeFirstTime(boolean firstTime, Activity activity) { - setFirstTime(firstTime); - OsmandSettings settings = getSettings(activity); - settings.FIRST_TIME_APP_RUN.set(firstTime); - } - - private OsmandSettings getSettings(Activity activity) { - return ((OsmandApplication) activity.getApplication()).getSettings(); - } - + public boolean checkAppVersionChanged(Activity activity) { initUiVars(activity); boolean showRecentChangesDialog = !firstTime && appVersionChanged; diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 832696cc4f..c8c0698306 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -1888,12 +1888,7 @@ public class OsmandSettings { public final OsmandPreference RATE_US_STATE = new EnumIntPreference<>("rate_us_state", DashRateUsFragment.RateUsState.INITIAL_STATE, DashRateUsFragment.RateUsState.values()) - .makeGlobal() - .cache(); - public final OsmandPreference FIRST_TIME_APP_RUN = - new BooleanPreference("first_time_app_run", true).makeGlobal().cache(); - public final OsmandPreference VERSION_INSTALLED = - new StringPreference("version_installed", null).makeGlobal().cache(); + .makeGlobal(); public enum DayNightMode { diff --git a/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java b/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java index 9662fb80df..c96c8f2f6f 100644 --- a/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java +++ b/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java @@ -182,21 +182,6 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity { cat.addPreference(createCheckBoxPreference(settings.SHOULD_SHOW_FREE_VERSION_BANNER, R.string.show_free_version_banner, R.string.show_free_version_banner_description)); - final Preference firstRunPreference = new Preference(this); - firstRunPreference.setTitle("Reset first run"); - firstRunPreference.setSummary("After reset app wold act like it is it's firs run"); - firstRunPreference.setSelectable(true); - firstRunPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { - @Override - public boolean onPreferenceClick(Preference preference) { - final SettingsDevelopmentActivity activity = SettingsDevelopmentActivity.this; - activity.getMyApplication().getAppInitializer() - .writeFirstTime(true, activity); - firstRunPreference.setSummary("First run flag has been reset"); - return true; - } - }); - cat.addPreference(firstRunPreference); } protected void availableProfileDialog() {