Skip to content

Commit c865d0e

Browse files
committed
Do not offer dynamic theme for widgets below API 31
1 parent 4ee8529 commit c865d0e

File tree

9 files changed

+31
-12
lines changed

9 files changed

+31
-12
lines changed

app/src/main/java/com/orgzly/android/widgets/WidgetColors.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ object WidgetColors {
9494
)
9595
)
9696

97-
// TODO:
98-
val colorDayNight = mapOf(
97+
val dataDependentColors = mapOf(
9998
"dynamic-day" to mapOf(
10099
"todo" to R.color.widget_light_state_todo_color,
101100
"done" to R.color.widget_light_state_done_color,

app/src/main/java/com/orgzly/android/widgets/WidgetStyle.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ object WidgetStyle {
4141

4242
@ColorInt
4343
private fun getColor(context: Context, scheme: String, name: String): Int {
44-
val s = WidgetColors.colorDayNight[scheme]?.get(name).let { value ->
44+
val s = WidgetColors.dataDependentColors[scheme]?.get(name).let { value ->
4545
if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, "$scheme/$name: $value")
4646
value ?: throw Exception("Not defined: $scheme/$name")
4747
}

app/src/main/res/layout/item_list_widget.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:android="http://schemas.android.com/apk/res/android"
55
xmlns:tools="http://schemas.android.com/tools"
66
android:id="@+id/item_list_widget_layout"
7-
android:theme="@style/Theme.Material3.DynamicColors.DayNight"
7+
android:theme="@style/ListWidgetTheme"
88
android:layout_width="match_parent"
99
android:layout_height="wrap_content"
1010
android:orientation="horizontal"

app/src/main/res/layout/item_list_widget_divider.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:android="http://schemas.android.com/apk/res/android"
55
xmlns:tools="http://schemas.android.com/tools"
66
android:id="@+id/widget_list_item_divider_value"
7-
android:theme="@style/Theme.Material3.DynamicColors.DayNight"
7+
android:theme="@style/ListWidgetTheme"
88
android:layout_width="match_parent"
99
android:layout_height="wrap_content"
1010
android:layout_gravity="center_vertical"

app/src/main/res/layout/list_widget.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<LinearLayout
44
xmlns:android="http://schemas.android.com/apk/res/android"
5-
android:theme="@style/Theme.Material3.DynamicColors.DayNight"
5+
android:theme="@style/ListWidgetTheme"
66
android:layout_width="match_parent"
77
android:layout_height="match_parent"
88
android:orientation="vertical">
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<resources xmlns:tools="http://schemas.android.com/tools">
4+
<string-array name="widget_color_scheme" tools:ignore="InconsistentArrays">
5+
<item>@string/color_scheme_dynamic</item>
6+
<item>@string/color_scheme_light</item>
7+
<item>@string/color_scheme_dark</item>
8+
<item>@string/color_scheme_black</item>
9+
</string-array>
10+
<string-array name="widget_color_scheme_values" tools:ignore="InconsistentArrays">
11+
<item>dynamic</item>
12+
<item>light</item>
13+
<item>dark</item>
14+
<item>black</item>
15+
</string-array>
16+
</resources>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<resources>
4+
<style name="ListWidgetTheme" parent="Theme.Material3.DynamicColors.DayNight" />
5+
</resources>

app/src/main/res/values/prefs_keys.xml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22

3-
<resources>
3+
<resources xmlns:tools="http://schemas.android.com/tools">
44
<!-- Overwrite system Locale -->
55
<string name="pref_key_ignore_system_locale" translatable="false">pref_key_ignore_system_locale</string>
66
<bool name="pref_default_ignore_system_locale" translatable="false">false</bool>
@@ -510,14 +510,12 @@
510510

511511
<string name="pref_key_widget_color_scheme" translatable="false">pref_key_widget_color_scheme</string>
512512
<string name="pref_default_widget_color_scheme" translatable="false">light</string>
513-
<string-array name="widget_color_scheme">
514-
<item>@string/color_scheme_dynamic</item>
513+
<string-array name="widget_color_scheme" tools:ignore="InconsistentArrays">
515514
<item>@string/color_scheme_light</item>
516515
<item>@string/color_scheme_dark</item>
517516
<item>@string/color_scheme_black</item>
518517
</string-array>
519-
<string-array name="widget_color_scheme_values">
520-
<item>dynamic</item>
518+
<string-array name="widget_color_scheme_values" tools:ignore="InconsistentArrays">
521519
<item>light</item>
522520
<item>dark</item>
523521
<item>black</item>

app/src/main/res/values/styles.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@
144144
<item name="colorTertiaryContainer">@color/grey_800</item>
145145
<item name="colorOnTertiaryContainer">@color/grey_400</item>
146146
<item name="colorError">@color/red_200</item>
147-
148147
</style>
149148

150149
<!-- Color scheme -->
@@ -225,6 +224,8 @@
225224
<!--<item name="android:textAppearanceMedium">@style/TextAppearance.AppCompat.Large</item>-->
226225
</style>
227226

227+
<style name="ListWidgetTheme" parent="Theme.Material3.DynamicColors.DayNight" />
228+
228229
<style name="OverFlow" parent="Widget.AppCompat.ActionButton.Overflow">
229230
<item name="tint">?android:textColorPrimary</item>
230231
</style>

0 commit comments

Comments
 (0)