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);
|
CrashReporter.initialize(this);
|
||||||
|
|
||||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||||
String themePref = sharedPreferences.getString("themePref", ThemeHelper.DEFAULT_MODE);
|
String themePref = sharedPreferences.getString("theme", ThemeHelper.DEFAULT_MODE);
|
||||||
ThemeHelper.applyTheme(themePref);
|
ThemeHelper.applyTheme(themePref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.cappielloantonio.play.helper;
|
package com.cappielloantonio.play.helper;
|
||||||
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatDelegate;
|
import androidx.appcompat.app.AppCompatDelegate;
|
||||||
|
|
@ -13,6 +14,8 @@ public class ThemeHelper {
|
||||||
public static final String DEFAULT_MODE = "default";
|
public static final String DEFAULT_MODE = "default";
|
||||||
|
|
||||||
public static void applyTheme(@NonNull String themePref) {
|
public static void applyTheme(@NonNull String themePref) {
|
||||||
|
Log.i(TAG, "+++ applyTheme: " + themePref);
|
||||||
|
|
||||||
switch (themePref) {
|
switch (themePref) {
|
||||||
case LIGHT_MODE: {
|
case LIGHT_MODE: {
|
||||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.cappielloantonio.play.ui.fragment;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.media.audiofx.AudioEffect;
|
import android.media.audiofx.AudioEffect;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
@ -115,8 +116,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
||||||
@Override
|
@Override
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
setPreferencesFromResource(R.xml.global_preferences, rootKey);
|
setPreferencesFromResource(R.xml.global_preferences, rootKey);
|
||||||
|
ListPreference themePreference = findPreference("theme");
|
||||||
ListPreference themePreference = findPreference("themePref");
|
|
||||||
if (themePreference != null) {
|
if (themePreference != null) {
|
||||||
themePreference.setOnPreferenceChangeListener(
|
themePreference.setOnPreferenceChangeListener(
|
||||||
(preference, newValue) -> {
|
(preference, newValue) -> {
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ public class PreferenceUtil {
|
||||||
private static final String TAG = "PreferenceUtil";
|
private static final String TAG = "PreferenceUtil";
|
||||||
|
|
||||||
public static final String SERVER = "server";
|
public static final String SERVER = "server";
|
||||||
|
public static final String THEME = "theme";
|
||||||
public static final String USER = "user";
|
public static final String USER = "user";
|
||||||
public static final String PASSWORD = "password";
|
public static final String PASSWORD = "password";
|
||||||
public static final String TOKEN = "token";
|
public static final String TOKEN = "token";
|
||||||
|
|
@ -45,7 +46,7 @@ public class PreferenceUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTheme() {
|
public String getTheme() {
|
||||||
return mPreferences.getString("themePref", ThemeHelper.DEFAULT_MODE);
|
return mPreferences.getString(THEME, ThemeHelper.DEFAULT_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServer() {
|
public String getServer() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue