~singpolyma/cheogram-android

d78bc969bcf7ca46036b91a7032ef430cf4280bb — SavagePeanut 6 months ago fde6d60
hide Custom Theme is Dark? when following system dark mode
M src/main/java/eu/siacs/conversations/ui/SettingsActivity.java => src/main/java/eu/siacs/conversations/ui/SettingsActivity.java +14 -8
@@ 429,16 429,22 @@ public class SettingsActivity extends XmppActivity implements OnSharedPreference
            if (customTheme != null) uiCategory.removePreference(customTheme);
        }

        final boolean customAutomatic = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("custom_theme_automatic", false);
        if (Build.VERSION.SDK_INT > 30 && theTheme.equals("custom") && !customAutomatic) {
        if (Build.VERSION.SDK_INT > 30 && theTheme.equals("custom")) {
            final boolean customAutomatic = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("custom_theme_automatic", false);
            final PreferenceScreen customTheme = (PreferenceScreen) mSettingsFragment.findPreference("custom_theme");
            final boolean isDark = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("custom_theme_dark", false);
            if (isDark) {
                final PreferenceCategory customThemeColors = (PreferenceCategory) mSettingsFragment.findPreference("custom_theme_colors");
                customTheme.removePreference(customThemeColors);
            final Preference customThemeIsDark = mSettingsFragment.findPreference("custom_theme_dark");

            if (customAutomatic) {
                customTheme.removePreference(customThemeIsDark);
            } else {
                final PreferenceCategory customThemeColorsDark = (PreferenceCategory) mSettingsFragment.findPreference("custom_theme_colors_dark");
                customTheme.removePreference(customThemeColorsDark);
                final boolean isDark = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("custom_theme_dark", false);
                if (isDark) {
                    final PreferenceCategory customThemeColors = (PreferenceCategory) mSettingsFragment.findPreference("custom_theme_colors");
                    customTheme.removePreference(customThemeColors);
                } else {
                    final PreferenceCategory customThemeColorsDark = (PreferenceCategory) mSettingsFragment.findPreference("custom_theme_colors_dark");
                    customTheme.removePreference(customThemeColorsDark);
                }
            }
        }
    }

M src/main/res/xml/preferences.xml => src/main/res/xml/preferences.xml +0 -2
@@ 204,12 204,10 @@
                android:summary="You may sometimes have to force quit the app to get changes applied."/>
            <CheckBoxPreference
                android:defaultValue="false"
                android:disableDependentsState="true"
                android:key="custom_theme_automatic"
                android:title="Follow System Dark Mode?" />
            <CheckBoxPreference
                android:defaultValue="false"
                android:dependency="custom_theme_automatic"
                android:key="custom_theme_dark"
                android:title="Custom Theme is Dark?" />