summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZekovski <>2023-08-15 13:00:26 +0200
committerZekovski <>2023-08-15 13:00:26 +0200
commited9563d380a235ed120ecbb11042eeb6b47e9c6f (patch)
treec01d140036a3baed0f7660f5ec95218573dfea88
parent49cd05ee35f0f7a27b765c23beeee9728ac79759 (diff)
Replaced SDK version check with isDynamicColorAvailable before showing DynamicColors options.
-rw-r--r--app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentThemingSettings.java27
1 files changed, 14 insertions, 13 deletions
diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentThemingSettings.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentThemingSettings.java
index d6403e64d..a38c15ac7 100644
--- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentThemingSettings.java
+++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentThemingSettings.java
@@ -31,6 +31,7 @@ import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.SwitchPreferenceCompat;
+import com.google.android.material.color.DynamicColors;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.jaredrummler.android.colorpicker.ColorPreferenceCompat;
@@ -118,31 +119,31 @@ public class FragmentThemingSettings extends PreferenceFragmentCompat implements
SwitchPreferenceCompat SET_CUSTOM_ACCENT = findPreference(getString(R.string.SET_CUSTOM_ACCENT));
ColorPreferenceCompat SET_CUSTOM_ACCENT_DARK_VALUE = findPreference(getString(R.string.SET_CUSTOM_ACCENT_DARK_VALUE));
ColorPreferenceCompat SET_CUSTOM_ACCENT_LIGHT_VALUE = findPreference(getString(R.string.SET_CUSTOM_ACCENT_LIGHT_VALUE));
- if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
- if (SET_DYNAMIC_COLOR != null) {
- getPreferenceScreen().removePreference(SET_DYNAMIC_COLOR);
- }
+ if (DynamicColors.isDynamicColorAvailable()) {
if (SET_CUSTOM_ACCENT != null) {
- getPreferenceScreen().removePreference(SET_CUSTOM_ACCENT);
+ boolean customAccentEnabled = sharedpreferences.getBoolean(getString(R.string.SET_CUSTOM_ACCENT) + currentUserID + currentInstance, false);
+ SET_CUSTOM_ACCENT.setChecked(customAccentEnabled);
}
if (SET_CUSTOM_ACCENT_DARK_VALUE != null) {
- getPreferenceScreen().removePreference(SET_CUSTOM_ACCENT_DARK_VALUE);
+ int darkValue = sharedpreferences.getInt(getString(R.string.SET_CUSTOM_ACCENT_DARK_VALUE) + currentUserID + currentInstance, -1);
+ SET_CUSTOM_ACCENT_DARK_VALUE.setColor(darkValue);
}
if (SET_CUSTOM_ACCENT_LIGHT_VALUE != null) {
- getPreferenceScreen().removePreference(SET_CUSTOM_ACCENT_LIGHT_VALUE);
+ int lightValue = sharedpreferences.getInt(getString(R.string.SET_CUSTOM_ACCENT_LIGHT_VALUE) + currentUserID + currentInstance, -1);
+ SET_CUSTOM_ACCENT_LIGHT_VALUE.setColor(lightValue);
}
} else {
+ if (SET_DYNAMIC_COLOR != null) {
+ getPreferenceScreen().removePreference(SET_DYNAMIC_COLOR);
+ }
if (SET_CUSTOM_ACCENT != null) {
- boolean customAccentEnabled = sharedpreferences.getBoolean(getString(R.string.SET_CUSTOM_ACCENT) + currentUserID + currentInstance, false);
- SET_CUSTOM_ACCENT.setChecked(customAccentEnabled);
+ getPreferenceScreen().removePreference(SET_CUSTOM_ACCENT);
}
if (SET_CUSTOM_ACCENT_DARK_VALUE != null) {
- int darkValue = sharedpreferences.getInt(getString(R.string.SET_CUSTOM_ACCENT_DARK_VALUE) + currentUserID + currentInstance, -1);
- SET_CUSTOM_ACCENT_DARK_VALUE.setColor(darkValue);
+ getPreferenceScreen().removePreference(SET_CUSTOM_ACCENT_DARK_VALUE);
}
if (SET_CUSTOM_ACCENT_LIGHT_VALUE != null) {
- int lightValue = sharedpreferences.getInt(getString(R.string.SET_CUSTOM_ACCENT_LIGHT_VALUE) + currentUserID + currentInstance, -1);
- SET_CUSTOM_ACCENT_LIGHT_VALUE.setColor(lightValue);
+ getPreferenceScreen().removePreference(SET_CUSTOM_ACCENT_LIGHT_VALUE);
}
}