Refactor theme preference values into constants
Also explicitly set a theme via preference updating to the default.
This commit is contained in:
@@ -104,6 +104,11 @@ public final class Constants {
|
||||
public static final String PROXY_PORT = "proxyPort";
|
||||
public static final String PROXY_TYPE = "proxyType";
|
||||
public static final String THEME = "theme";
|
||||
|
||||
public static final class Theme {
|
||||
public static final String LIGHT = "light";
|
||||
public static final String DARK = "dark";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,7 +122,7 @@ public final class Constants {
|
||||
|
||||
public static final class Defaults {
|
||||
public static final String KEY_SERVERS = "hkps://hkps.pool.sks-keyservers.net, hkps://pgp.mit.edu";
|
||||
public static final int PREF_VERSION = 4;
|
||||
public static final int PREF_VERSION = 5;
|
||||
}
|
||||
|
||||
public static final class key {
|
||||
|
||||
@@ -136,7 +136,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||
}
|
||||
|
||||
int themeId = R.style.LightTheme;
|
||||
if ("dark".equals(newTheme)) {
|
||||
if (Constants.Pref.Theme.DARK.equals(newTheme)) {
|
||||
themeId = R.style.DarkTheme;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.util.Preferences;
|
||||
|
||||
@@ -76,7 +77,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
int themeId = R.style.LightTheme;
|
||||
if ("dark".equals(newTheme)) {
|
||||
if (Constants.Pref.Theme.DARK.equals(newTheme)) {
|
||||
themeId = R.style.DarkTheme;
|
||||
}
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ public class Preferences {
|
||||
}
|
||||
|
||||
public String getTheme() {
|
||||
return mSharedPreferences.getString(Pref.THEME, "light");
|
||||
return mSharedPreferences.getString(Pref.THEME, Pref.Theme.LIGHT);
|
||||
}
|
||||
|
||||
public void setTheme(String value) {
|
||||
@@ -390,6 +390,10 @@ public class Preferences {
|
||||
}
|
||||
// fall through
|
||||
case 4: {
|
||||
// fall through
|
||||
}
|
||||
case 5: {
|
||||
setTheme(Constants.Pref.Theme.LIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user