Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 91ad4fb6 authored by Gitsaibot's avatar Gitsaibot Committed by GitHub
Browse files

Added possibility to choose black theme for night mode (#787)

* Added possibility to choose black theme for night mode
parent b8fd01da
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -464,6 +464,7 @@
    <!-- This is the title of a section in the Settings screen for settings
         related to viewing calendar events in Month view for landscape orientation -->
    <string name="preferences_month_view_landscape">Month view layout (Landscape)</string>

    <!-- This is the title of a section in the Settings screen for settings
         related to app theme -->
    <string name="preferences_theme">Theme</string>
@@ -471,6 +472,7 @@
    <string name="preferences_light_theme">Light</string>
    <string name="preferences_dark_theme">Dark</string>
    <string name="preferences_black_theme">Black</string>

    <string name="preferences_color">Primary color</string>
    <string name="preferences_color_teal" translatable="false">Teal</string>
    <string name="preferences_color_blue" translatable="false">Blue</string>
@@ -479,6 +481,9 @@
    <string name="preferences_color_red" translatable="false">Red</string>
    <string name="preferences_color_purple" translatable="false">Purple</string>
    <string name="preferences_color_pick">Primary color</string>

    <string name="preferences_pure_black_night_mode">Pure black night mode</string>

    <!-- This is the title of a section in the Settings screen for settings
         related to reminders for calendar events -->
    <string name="preferences_reminder_title">Notifications \u0026 reminders</string>
+7 −4
Original line number Diff line number Diff line
@@ -23,6 +23,10 @@
            app:entries="@array/pref_theme_entries"
            app:entryValues="@array/pref_theme_values"
            app:defaultValue="light" />
        <SwitchPreference
            app:defaultValue="false"
            app:key="pref_pure_black_night_mode"
            app:title="@string/preferences_pure_black_night_mode" />
        <Preference
            app:key="pref_color"
            app:title="@string/preferences_color"
@@ -66,8 +70,7 @@
            app:defaultValue="60"
            app:title="@string/preferences_default_event_duration_title"
            app:entries="@array/preferences_default_duration_labels"
            app:entryValues="@array/preferences_default_duration_values"
            />
            app:entryValues="@array/preferences_default_duration_values" />
        <CheckBoxPreference
            app:key="preferences_home_tz_enabled"
            app:defaultValue="false"
+7 −4
Original line number Diff line number Diff line
@@ -23,6 +23,10 @@ xmlns:app="http://schemas.android.com/apk/res-auto">
        app:entries="@array/pref_theme_entries"
        app:entryValues="@array/pref_theme_values"
        app:defaultValue="system" />
    <SwitchPreference
        app:defaultValue="false"
        app:key="pref_pure_black_night_mode"
        app:title="@string/preferences_pure_black_night_mode" />
    <Preference
        app:key="pref_color"
        app:title="@string/preferences_color"
@@ -66,8 +70,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto">
        app:defaultValue="60"
        app:title="@string/preferences_default_event_duration_title"
        app:entries="@array/preferences_default_duration_labels"
        app:entryValues="@array/preferences_default_duration_values"
        />
        app:entryValues="@array/preferences_default_duration_values" />
    <CheckBoxPreference
        app:key="preferences_home_tz_enabled"
        app:defaultValue="false"
+7 −4
Original line number Diff line number Diff line
@@ -23,6 +23,10 @@
            app:entries="@array/pref_theme_entries"
            app:entryValues="@array/pref_theme_values"
            app:defaultValue="light" />
        <SwitchPreference
            app:key="pref_pure_black_night_mode"
            app:defaultValue="false"
            app:title="@string/preferences_pure_black_night_mode" />
        <Preference
            app:key="pref_color"
            app:title="@string/preferences_color"
@@ -66,8 +70,7 @@
            app:defaultValue="60"
            app:title="@string/preferences_default_event_duration_title"
            app:entries="@array/preferences_default_duration_labels"
            app:entryValues="@array/preferences_default_duration_values"
            />
            app:entryValues="@array/preferences_default_duration_values" />
        <CheckBoxPreference
            app:key="preferences_home_tz_enabled"
            app:defaultValue="false"
+33 −7
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ public class DynamicTheme {

    private static final String THEME_PREF = "pref_theme";
    private static final String COLOR_PREF = "pref_color";
    private static final String PURE_BLACK_NIGHT_MODE = "pref_pure_black_night_mode";
    private static final String SYSTEM = "system";
    private static final String LIGHT = "light";
    private static final String DARK  = "dark";
@@ -51,10 +52,15 @@ public class DynamicTheme {

    private static int getSelectedTheme(Activity activity) {
        String theme = getTheme(activity) + getPrimaryColor(activity);
        boolean pureBlack = Utils.getSharedPreference(activity, PURE_BLACK_NIGHT_MODE, false);
        switch (theme) {
            case SYSTEM+TEAL:
                if (isSystemInDarkTheme(activity)) {
                    if (pureBlack) {
                        return R.style.CalendarAppThemeBlackTeal;
                    } else {
                        return R.style.CalendarAppThemeDarkTeal;
                    }
                } else {
                    return R.style.CalendarAppThemeLightTeal;
                }
@@ -66,7 +72,11 @@ public class DynamicTheme {
                return R.style.CalendarAppThemeBlackTeal;
            case SYSTEM+ORANGE:
                if (isSystemInDarkTheme(activity)) {
                    if (pureBlack) {
                        return R.style.CalendarAppThemeBlackOrange;
                    } else {
                        return R.style.CalendarAppThemeDarkOrange;
                    }
                } else {
                    return R.style.CalendarAppThemeLightOrange;
                }
@@ -78,7 +88,11 @@ public class DynamicTheme {
                return R.style.CalendarAppThemeBlackOrange;
            case SYSTEM+BLUE:
                if (isSystemInDarkTheme(activity)) {
                    if (pureBlack) {
                        return R.style.CalendarAppThemeBlackBlue;
                    } else {
                        return R.style.CalendarAppThemeDarkBlue;
                    }
                } else {
                    return R.style.CalendarAppThemeLightBlue;
                }
@@ -90,7 +104,11 @@ public class DynamicTheme {
                return R.style.CalendarAppThemeBlackBlue;
            case SYSTEM+GREEN:
                if (isSystemInDarkTheme(activity)) {
                    if (pureBlack) {
                        return R.style.CalendarAppThemeBlackGreen;
                    } else {
                        return R.style.CalendarAppThemeDarkGreen;
                    }
                } else {
                    return R.style.CalendarAppThemeLightGreen;
                }
@@ -102,7 +120,11 @@ public class DynamicTheme {
                return R.style.CalendarAppThemeBlackGreen;
            case SYSTEM+RED:
                if (isSystemInDarkTheme(activity)) {
                    if (pureBlack) {
                        return R.style.CalendarAppThemeBlackRed;
                    } else {
                        return R.style.CalendarAppThemeDarkRed;
                    }
                } else {
                    return R.style.CalendarAppThemeLightRed;
                }
@@ -114,7 +136,11 @@ public class DynamicTheme {
                return R.style.CalendarAppThemeBlackRed;
            case SYSTEM+PURPLE:
                if (isSystemInDarkTheme(activity)) {
                    if (pureBlack) {
                        return R.style.CalendarAppThemeBlackPurple;
                    } else {
                        return R.style.CalendarAppThemeDarkPurple;
                    }
                } else {
                    return R.style.CalendarAppThemeLightPurple;
                }
@@ -232,7 +258,7 @@ public class DynamicTheme {
        return Build.VERSION.SDK_INT >= 29;
    }

    private static boolean isSystemInDarkTheme(@NonNull Activity activity) {
    public static boolean isSystemInDarkTheme(@NonNull Activity activity) {
        return (activity.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
    }

Loading