Fix favorites default icon and background
This commit is contained in:
parent
a8db838530
commit
6479a86840
2 changed files with 21 additions and 24 deletions
|
@ -117,6 +117,7 @@ public class AppInitializer implements IProgress {
|
|||
private List<String> warnings = new ArrayList<>();
|
||||
private String taskName;
|
||||
private List<AppInitializeListener> listeners = new ArrayList<>();
|
||||
private SharedPreferences startPrefs;
|
||||
|
||||
public enum InitEvents {
|
||||
FAVORITES_INITIALIZED, NATIVE_INITIALIZED,
|
||||
|
@ -158,21 +159,23 @@ public class AppInitializer implements IProgress {
|
|||
return;
|
||||
}
|
||||
ApplicationMode.onApplicationStart(app);
|
||||
|
||||
appVersionUpgrade.upgradeVersion(LAST_APP_VERSION);
|
||||
startPrefs = app.getSharedPreferences(
|
||||
getLocalClassName(app.getAppCustomization().getMapActivity().getName()),
|
||||
Context.MODE_PRIVATE);
|
||||
appVersionUpgrade.upgradeVersion(startPrefs, LAST_APP_VERSION);
|
||||
initSettings = true;
|
||||
}
|
||||
|
||||
public int getNumberOfStarts() {
|
||||
return appVersionUpgrade.getNumberOfStarts();
|
||||
return appVersionUpgrade.getNumberOfStarts(startPrefs);
|
||||
}
|
||||
|
||||
public long getFirstInstalledDays() {
|
||||
return appVersionUpgrade.getFirstInstalledDays();
|
||||
return appVersionUpgrade.getFirstInstalledDays(startPrefs);
|
||||
}
|
||||
|
||||
public void resetFirstTimeRun() {
|
||||
appVersionUpgrade.resetFirstTimeRun();
|
||||
appVersionUpgrade.resetFirstTimeRun(startPrefs);
|
||||
}
|
||||
|
||||
public boolean isFirstTime() {
|
||||
|
@ -927,4 +930,13 @@ public class AppInitializer implements IProgress {
|
|||
this.listeners.remove(listener);
|
||||
}
|
||||
|
||||
private String getLocalClassName(String cls) {
|
||||
final String pkg = app.getPackageName();
|
||||
int packageLen = pkg.length();
|
||||
if (!cls.startsWith(pkg) || cls.length() <= packageLen
|
||||
|| cls.charAt(packageLen) != '.') {
|
||||
return cls;
|
||||
}
|
||||
return cls.substring(packageLen + 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
class AppVersionUpgradeOnInit {
|
||||
|
@ -33,20 +32,16 @@ class AppVersionUpgradeOnInit {
|
|||
static final String VERSION_INSTALLED = "VERSION_INSTALLED";
|
||||
|
||||
private OsmandApplication app;
|
||||
private SharedPreferences startPrefs;
|
||||
private int prevAppVersion;
|
||||
private boolean appVersionChanged;
|
||||
private boolean firstTime;
|
||||
|
||||
AppVersionUpgradeOnInit(OsmandApplication app) {
|
||||
this.app = app;
|
||||
startPrefs = app.getSharedPreferences(
|
||||
getLocalClassName(app.getAppCustomization().getMapActivity().getName()),
|
||||
Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
void upgradeVersion(int lastVersion) {
|
||||
void upgradeVersion(SharedPreferences startPrefs, int lastVersion) {
|
||||
if(!startPrefs.contains(NUMBER_OF_STARTS)) {
|
||||
startPrefs.edit().putInt(NUMBER_OF_STARTS, 1).commit();
|
||||
} else {
|
||||
|
@ -134,20 +129,20 @@ class AppVersionUpgradeOnInit {
|
|||
return prevAppVersion;
|
||||
}
|
||||
|
||||
public void resetFirstTimeRun() {
|
||||
public void resetFirstTimeRun(SharedPreferences startPrefs) {
|
||||
if(startPrefs != null) {
|
||||
startPrefs.edit().remove(FIRST_TIME_APP_RUN).commit();
|
||||
}
|
||||
}
|
||||
|
||||
public int getNumberOfStarts() {
|
||||
public int getNumberOfStarts(SharedPreferences startPrefs) {
|
||||
if(startPrefs == null) {
|
||||
return 0;
|
||||
}
|
||||
return startPrefs.getInt(NUMBER_OF_STARTS, 1);
|
||||
}
|
||||
|
||||
public long getFirstInstalledDays() {
|
||||
public long getFirstInstalledDays(SharedPreferences startPrefs) {
|
||||
if(startPrefs == null) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -159,14 +154,4 @@ class AppVersionUpgradeOnInit {
|
|||
public boolean isFirstTime() {
|
||||
return firstTime;
|
||||
}
|
||||
|
||||
private String getLocalClassName(String cls) {
|
||||
final String pkg = app.getPackageName();
|
||||
int packageLen = pkg.length();
|
||||
if (!cls.startsWith(pkg) || cls.length() <= packageLen
|
||||
|| cls.charAt(packageLen) != '.') {
|
||||
return cls;
|
||||
}
|
||||
return cls.substring(packageLen + 1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue