Fix first start screen after permission

This commit is contained in:
Alexey Kulish 2016-03-24 15:33:31 +03:00
parent b5fbd3d131
commit 0fde34eecb
2 changed files with 27 additions and 1 deletions

View file

@ -83,6 +83,7 @@ public class AppInitializer implements IProgress {
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 FIRST_USAGE_FRAGMENT_DONE = "FIRST_USAGE_FRAGMENT_DONE"; //$NON-NLS-1$
public static final String LATEST_CHANGES_URL = "http://osmand.net/blog?id=osmand-2-3-released";
// public static final String LATEST_CHANGES_URL = null; // not enough to read
@ -93,6 +94,7 @@ public class AppInitializer implements IProgress {
private boolean initSettings = false;
private boolean firstTime;
private boolean firstUsageFragmentDone;
private boolean activityChangesShowed = false;
private boolean appVersionChanged;
private int prevAppVersion;
@ -168,6 +170,7 @@ public class AppInitializer implements IProgress {
startPrefs.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
appVersionChanged = true;
}
firstUsageFragmentDone = startPrefs.contains(FIRST_USAGE_FRAGMENT_DONE);
initSettings = true;
}
@ -188,9 +191,28 @@ public class AppInitializer implements IProgress {
public void resetFirstTimeRun() {
if(startPrefs != null) {
startPrefs.edit().remove(FIRST_TIME_APP_RUN).commit();
resetFirstUsageFragmentDone();
}
}
public void setFirstUsageFragmentDone() {
if(startPrefs != null) {
startPrefs.edit().putBoolean(FIRST_USAGE_FRAGMENT_DONE, true).commit();
firstUsageFragmentDone = true;
}
}
public void resetFirstUsageFragmentDone() {
if(startPrefs != null) {
startPrefs.edit().remove(FIRST_USAGE_FRAGMENT_DONE).commit();
firstUsageFragmentDone = false;
}
}
public boolean isFirstUsageFragmentDone() {
return firstUsageFragmentDone;
}
public boolean isFirstTime() {
initVariables();
return firstTime;

View file

@ -289,11 +289,12 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
}
mapView.refreshMap(true);
if (getMyApplication().getAppInitializer().isFirstTime() && FirstUsageFragment.SHOW) {
if (!getMyApplication().getAppInitializer().isFirstUsageFragmentDone() && FirstUsageFragment.SHOW) {
FirstUsageFragment.SHOW = false;
getSupportFragmentManager().beginTransaction()
.add(R.id.fragmentContainer, new FirstUsageFragment(),
FirstUsageFragment.TAG).commit();
app.getAppInitializer().setFirstUsageFragmentDone();
}
mapActions.updateDrawerMenu();
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
@ -616,6 +617,9 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
}
} else {
if (permissionGranted) {
if (app.getAppInitializer().isFirstTime()) {
app.getAppInitializer().resetFirstUsageFragmentDone();
}
restartApp();
} else if (getSupportFragmentManager().findFragmentByTag(DataStoragePlaceDialogFragment.TAG) == null) {
DataStoragePlaceDialogFragment.showInstance(getSupportFragmentManager(), true);