mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Fix theme selector
This commit is contained in:
parent
08c1b03d84
commit
bcc95f2ef0
4 changed files with 8 additions and 4 deletions
|
|
@ -23,7 +23,7 @@ public class App extends Application {
|
|||
CrashReporter.initialize(this);
|
||||
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
String themePref = sharedPreferences.getString("themePref", ThemeHelper.DEFAULT_MODE);
|
||||
String themePref = sharedPreferences.getString("theme", ThemeHelper.DEFAULT_MODE);
|
||||
ThemeHelper.applyTheme(themePref);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.cappielloantonio.play.helper;
|
||||
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
|
|
@ -13,6 +14,8 @@ public class ThemeHelper {
|
|||
public static final String DEFAULT_MODE = "default";
|
||||
|
||||
public static void applyTheme(@NonNull String themePref) {
|
||||
Log.i(TAG, "+++ applyTheme: " + themePref);
|
||||
|
||||
switch (themePref) {
|
||||
case LIGHT_MODE: {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.cappielloantonio.play.ui.fragment;
|
|||
import android.content.Intent;
|
||||
import android.media.audiofx.AudioEffect;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
@ -115,8 +116,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
setPreferencesFromResource(R.xml.global_preferences, rootKey);
|
||||
|
||||
ListPreference themePreference = findPreference("themePref");
|
||||
ListPreference themePreference = findPreference("theme");
|
||||
if (themePreference != null) {
|
||||
themePreference.setOnPreferenceChangeListener(
|
||||
(preference, newValue) -> {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ public class PreferenceUtil {
|
|||
private static final String TAG = "PreferenceUtil";
|
||||
|
||||
public static final String SERVER = "server";
|
||||
public static final String THEME = "theme";
|
||||
public static final String USER = "user";
|
||||
public static final String PASSWORD = "password";
|
||||
public static final String TOKEN = "token";
|
||||
|
|
@ -45,7 +46,7 @@ public class PreferenceUtil {
|
|||
}
|
||||
|
||||
public String getTheme() {
|
||||
return mPreferences.getString("themePref", ThemeHelper.DEFAULT_MODE);
|
||||
return mPreferences.getString(THEME, ThemeHelper.DEFAULT_MODE);
|
||||
}
|
||||
|
||||
public String getServer() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue