move Theme handling to Preferences class
This is one of the last instances of direct SharedPreferences manipulation in the code. Moving it to Preferences like the rest.
This commit is contained in:
parent
230c06d536
commit
c4a1295095
@ -49,6 +49,7 @@ import org.acra.ReportingInteractionMode;
|
||||
import org.acra.annotation.ReportsCrashes;
|
||||
import org.apache.commons.net.util.SubnetUtils;
|
||||
import org.fdroid.fdroid.Preferences.ChangeListener;
|
||||
import org.fdroid.fdroid.Preferences.Theme;
|
||||
import org.fdroid.fdroid.compat.PRNGFixes;
|
||||
import org.fdroid.fdroid.data.AppProvider;
|
||||
import org.fdroid.fdroid.data.InstalledAppCacheUpdater;
|
||||
@ -96,19 +97,10 @@ public class FDroidApp extends Application {
|
||||
enableSpongyCastle();
|
||||
}
|
||||
|
||||
public enum Theme {
|
||||
light,
|
||||
dark,
|
||||
night,
|
||||
lightWithDarkActionBar, // Obsolete
|
||||
}
|
||||
|
||||
private static Theme curTheme = Theme.light;
|
||||
|
||||
public void reloadTheme() {
|
||||
curTheme = Theme.valueOf(PreferenceManager
|
||||
.getDefaultSharedPreferences(getBaseContext())
|
||||
.getString(Preferences.PREF_THEME, Preferences.DEFAULT_THEME));
|
||||
curTheme = Preferences.get().getTheme();
|
||||
}
|
||||
|
||||
public void applyTheme(Activity activity) {
|
||||
@ -194,6 +186,7 @@ public class FDroidApp extends Application {
|
||||
// Perhaps the constructor is a better place, but then again,
|
||||
// it is more deterministic as to when this gets called...
|
||||
Preferences.setup(this);
|
||||
curTheme = Preferences.get().getTheme();
|
||||
|
||||
// Apply the Google PRNG fixes to properly seed SecureRandom
|
||||
PRNGFixes.apply();
|
||||
@ -241,9 +234,6 @@ public class FDroidApp extends Application {
|
||||
// been installed, but this causes problems for proprietary gapps
|
||||
// users since the introduction of verification (on pre-4.2 Android),
|
||||
// because the install intent says it's finished when it hasn't.
|
||||
SharedPreferences prefs = PreferenceManager
|
||||
.getDefaultSharedPreferences(getBaseContext());
|
||||
curTheme = Theme.valueOf(prefs.getString(Preferences.PREF_THEME, Preferences.DEFAULT_THEME));
|
||||
Utils.deleteFiles(Utils.getApkDownloadDir(this), null, ".apk");
|
||||
if (!Preferences.get().shouldCacheApks()) {
|
||||
Utils.deleteFiles(Utils.getApkCacheDir(this), null, ".apk");
|
||||
|
@ -85,6 +85,13 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
private static final boolean DEFAULT_FIRST_TIME = true;
|
||||
private static final boolean DEFAULT_POST_PRIVILEGED_INSTALL = false;
|
||||
|
||||
public enum Theme {
|
||||
light,
|
||||
dark,
|
||||
night,
|
||||
lightWithDarkActionBar, // Obsolete
|
||||
}
|
||||
|
||||
private boolean filterAppsRequiringRoot = DEFAULT_ROOTED;
|
||||
|
||||
private final Map<String, Boolean> initialized = new HashMap<>();
|
||||
@ -155,6 +162,10 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
return preferences.getBoolean(PREF_EXPERT, DEFAULT_EXPERT);
|
||||
}
|
||||
|
||||
public Theme getTheme() {
|
||||
return Theme.valueOf(preferences.getString(Preferences.PREF_THEME, Preferences.DEFAULT_THEME));
|
||||
}
|
||||
|
||||
public boolean isLocalRepoHttpsEnabled() {
|
||||
return false; // disabled until it works well
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user