mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-14 14:02:49 +00:00
Improve theme based texts
This commit is contained in:
parent
59c0ca947d
commit
f7c32bc28b
4 changed files with 26 additions and 12 deletions
|
@ -16,4 +16,24 @@ public enum Theme {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getThemeName(int x) {
|
||||
switch(x) {
|
||||
case 0:
|
||||
return "Light theme";
|
||||
case 1:
|
||||
return "Dark theme";
|
||||
case 2:
|
||||
return "Amoled theme";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String[] getThemeNames() {
|
||||
return new String[] {
|
||||
"Light theme",
|
||||
"Dark theme",
|
||||
"Amoled theme"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,24 +91,20 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
|
|||
// set the result intent in advance
|
||||
setResult(new Intent());
|
||||
|
||||
int currentTheme = app.getPreferences().getCurrentTheme();
|
||||
Preference darkModePreference = findPreference("pref_dark_mode");
|
||||
darkModePreference.setSummary("Selected: " + Theme.getThemeName(currentTheme));
|
||||
darkModePreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
String[] themeNames = {"Light theme", "Dark theme", "Amoled theme"};
|
||||
String[] themeNames = Theme.getThemeNames();
|
||||
int checkedTheme = app.getPreferences().getCurrentTheme();
|
||||
|
||||
Dialogs.showSecureDialog(new AlertDialog.Builder(getActivity())
|
||||
.setTitle(getString(R.string.choose_theme))
|
||||
.setSingleChoiceItems(themeNames, checkedTheme, (dialog, which) -> {
|
||||
int i = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
|
||||
Theme selectedTheme = Theme.fromInteger(i);
|
||||
app.getPreferences().setCurrentTheme(selectedTheme);
|
||||
|
||||
if (selectedTheme == Theme.AMOLED)
|
||||
{
|
||||
Toast.makeText(app, "Due to a bug in a third party library, the amoled theme is not visible here.", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
app.getPreferences().setCurrentTheme(Theme.fromInteger(i));
|
||||
|
||||
_result.putExtra("needsRecreate", true);
|
||||
getActivity().recreate();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue