~singpolyma/cheogram-android

eca7f82005d5fc66fc688667abf5a13a0b893c84 — SavagePeanut 2 months ago db25cc4
follow system dark mode with custom theme
M src/main/java/eu/siacs/conversations/ui/SettingsActivity.java => src/main/java/eu/siacs/conversations/ui/SettingsActivity.java +1 -0
@@ 582,6 582,7 @@ public class SettingsActivity extends XmppActivity implements OnSharedPreference
        } else if (name.equals(AUTOMATIC_MESSAGE_DELETION)) {
            xmppConnectionService.expireOldMessages(true);
        } else if ( name.equals(THEME) ||
                    name.equals("custom_theme_automatic") ||
                    name.equals("custom_theme_primary") ||
                    name.equals("custom_theme_primary_dark") ||
                    name.equals("custom_theme_accent") ||

M src/main/java/eu/siacs/conversations/utils/ThemeHelper.java => src/main/java/eu/siacs/conversations/utils/ThemeHelper.java +3 -1
@@ 137,7 137,9 @@ public class ThemeHelper {

	private static boolean isDark(final SharedPreferences sharedPreferences, final Resources resources) {
		final String setting = sharedPreferences.getString(SettingsActivity.THEME, resources.getString(R.string.theme));
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && "automatic".equals(setting)) {
		if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && "automatic".equals(setting)) ||
			("custom".equals(setting) && sharedPreferences.getBoolean("custom_theme_automatic", false))
		) {
			return (resources.getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
		} else {
			if ("custom".equals(setting)) return sharedPreferences.getBoolean("custom_theme_dark", false);

M src/main/res/xml/preferences.xml => src/main/res/xml/preferences.xml +6 -0
@@ 209,6 209,12 @@

                <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?" />
                <com.rarepebble.colorpicker.ColorPreference