First time reset setting in Developement plugin
This commit is contained in:
parent
e5941c29e0
commit
38f73859d3
3 changed files with 37 additions and 10 deletions
|
@ -56,9 +56,7 @@ import btools.routingapp.BRouterServiceConnection;
|
||||||
public class AppInitializer implements IProgress {
|
public class AppInitializer implements IProgress {
|
||||||
|
|
||||||
public static final boolean TIPS_AND_TRICKS = false;
|
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 VECTOR_INDEXES_CHECK = "VECTOR_INDEXES_CHECK"; //$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$
|
private static final String EXCEPTION_FILE_SIZE = "EXCEPTION_FS"; //$NON-NLS-1$
|
||||||
|
|
||||||
public static final String LATEST_CHANGES_URL = "changes-2.1.html";
|
public static final String LATEST_CHANGES_URL = "changes-2.1.html";
|
||||||
|
@ -111,13 +109,13 @@ public class AppInitializer implements IProgress {
|
||||||
if(initSettings) {
|
if(initSettings) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SharedPreferences pref = activity.getPreferences(Context.MODE_WORLD_WRITEABLE);
|
OsmandSettings settings = getSettings(activity);
|
||||||
if (!pref.contains(FIRST_TIME_APP_RUN)) {
|
firstTime = settings.FIRST_TIME_APP_RUN.get();
|
||||||
firstTime = true;
|
if (firstTime) {
|
||||||
pref.edit().putBoolean(FIRST_TIME_APP_RUN, true).commit();
|
settings.FIRST_TIME_APP_RUN.set(false);
|
||||||
pref.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
|
settings.VERSION_INSTALLED.set(Version.getFullVersion(app));
|
||||||
} else if (!Version.getFullVersion(app).equals(pref.getString(VERSION_INSTALLED, ""))) {
|
} else if (!Version.getFullVersion(app).equals(settings.VERSION_INSTALLED.get())) {
|
||||||
pref.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
|
settings.VERSION_INSTALLED.set(Version.getFullVersion(app));
|
||||||
appVersionChanged = true;
|
appVersionChanged = true;
|
||||||
}
|
}
|
||||||
initSettings = true;
|
initSettings = true;
|
||||||
|
@ -132,6 +130,16 @@ public class AppInitializer implements IProgress {
|
||||||
this.firstTime = 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) {
|
public boolean checkAppVersionChanged(Activity activity) {
|
||||||
initUiVars(activity);
|
initUiVars(activity);
|
||||||
boolean showRecentChangesDialog = !firstTime && appVersionChanged;
|
boolean showRecentChangesDialog = !firstTime && appVersionChanged;
|
||||||
|
|
|
@ -1891,6 +1891,10 @@ public class OsmandSettings {
|
||||||
DashRateUsFragment.RateUsState.INITIAL_STATE, DashRateUsFragment.RateUsState.values())
|
DashRateUsFragment.RateUsState.INITIAL_STATE, DashRateUsFragment.RateUsState.values())
|
||||||
.makeGlobal()
|
.makeGlobal()
|
||||||
.cache();
|
.cache();
|
||||||
|
public final OsmandPreference<Boolean> FIRST_TIME_APP_RUN =
|
||||||
|
new BooleanPreference("first_time_app_run", true).makeGlobal().cache();
|
||||||
|
public final OsmandPreference<String> VERSION_INSTALLED =
|
||||||
|
new StringPreference("version_installed", null).makeGlobal().cache();
|
||||||
|
|
||||||
|
|
||||||
public enum DayNightMode {
|
public enum DayNightMode {
|
||||||
|
|
|
@ -182,6 +182,21 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
|
||||||
cat.addPreference(createCheckBoxPreference(settings.SHOULD_SHOW_FREE_VERSION_BANNER,
|
cat.addPreference(createCheckBoxPreference(settings.SHOULD_SHOW_FREE_VERSION_BANNER,
|
||||||
R.string.show_free_version_banner,
|
R.string.show_free_version_banner,
|
||||||
R.string.show_free_version_banner_description));
|
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() {
|
protected void availableProfileDialog() {
|
||||||
|
|
Loading…
Reference in a new issue