Skip to content

Commit 3b7c984

Browse files
committed
Clean up theme resources
1 parent e43ec5a commit 3b7c984

19 files changed

+167
-175
lines changed

app/src/main/java/com/jkuester/unlauncher/Theme.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,14 @@ private fun setWallpaperBackgroundColor(activity: Activity) = { color: Int ->
4545
}
4646
}
4747

48-
private fun getThemeBackgroundColor(theme: Resources.Theme, themeRes: Int) = theme
49-
.obtainStyledAttributes(themeRes, intArrayOf(android.R.attr.colorBackground))
50-
.use { it.getColor(0, Int.MIN_VALUE) }
48+
private fun getThemeBackgroundColor(theme: Resources.Theme, themeRes: Int): Int {
49+
val typedArray = theme.obtainStyledAttributes(themeRes, intArrayOf(android.R.attr.colorBackground))
50+
return try {
51+
typedArray.getColor(0, Int.MIN_VALUE)
52+
} finally {
53+
typedArray.recycle()
54+
}
55+
}
5156

5257
fun setWallpaperAsync(
5358
activity: AppCompatActivity,
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+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item android:state_enabled="false" android:color="?attr/colorHintTextDisabled"/>
4+
<item android:color="?attr/colorHintTextEnabled"/>
5+
</selector>
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+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item android:state_enabled="false" android:color="?attr/colorPrimaryTextDisabled"/>
4+
<item android:color="?attr/colorPrimaryTextEnabled"/>
5+
</selector>

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
android:layout_height="wrap_content"
1212
android:layout_gravity="end"
1313
android:padding="@dimen/padding"
14-
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
15-
android:textSize="@dimen/font_size_customize_group_header"
14+
android:textAppearance="@style/TextAppearance.AppGroupHeader"
1615
tools:text="A" />
1716

1817
<View

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
android:layout_width="match_parent"
55
android:layout_height="wrap_content"
66
android:padding="@dimen/padding"
7-
android:textAppearance="@style/TextAppearance.AppCompat"
8-
android:textSize="@dimen/font_size_apps_list_item">
7+
android:textAppearance="@style/TextAppearance.Primary">
98
</TextView>

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
android:layout_width="0dp"
2828
android:layout_height="wrap_content"
2929
android:text="@string/options_fragment_customize_app_drawer"
30-
android:textAppearance="@style/TextAppearance.AppCompat"
31-
android:textColor="?headerTextColor"
32-
android:textSize="@dimen/font_size_options_title"
30+
android:textAppearance="@style/TextAppearance.Header"
3331
app:layout_constraintEnd_toEndOf="parent"
3432
app:layout_constraintStart_toEndOf="@+id/header_back"
3533
app:layout_constraintTop_toTopOf="parent" />
@@ -53,8 +51,7 @@
5351
android:layout_width="match_parent"
5452
android:layout_height="wrap_content"
5553
android:text="@string/customize_app_drawer_fragment_visible_apps"
56-
android:textAppearance="@style/TextAppearance.AppCompat"
57-
android:textSize="@dimen/font_size_customize_options"
54+
android:textAppearance="@style/TextAppearance.Primary.Large"
5855
app:layout_constraintStart_toStartOf="parent"
5956
app:layout_constraintTop_toTopOf="parent" />
6057

@@ -64,15 +61,15 @@
6461
android:layout_height="wrap_content"
6562
android:layout_marginTop="@dimen/margin_list_items"
6663
android:text="@string/customize_app_drawer_fragment_search_field_options"
67-
android:textAppearance="@style/TextAppearance.AppCompat.Large"
64+
android:textAppearance="@style/TextAppearance.Primary"
6865
app:layout_constraintStart_toStartOf="parent"
6966
app:layout_constraintTop_toBottomOf="@id/visible_apps" />
7067

7168
<TextView
7269
android:id="@+id/search_field_options_subtitle"
7370
android:layout_width="match_parent"
7471
android:layout_height="wrap_content"
75-
android:textAppearance="@style/TextAppearance.AppCompat.Small"
72+
android:textAppearance="@style/TextAppearance.Hint"
7673
app:layout_constraintStart_toStartOf="parent"
7774
app:layout_constraintTop_toBottomOf="@id/search_field_options_title" />
7875

@@ -82,7 +79,7 @@
8279
android:layout_height="wrap_content"
8380
android:layout_marginTop="@dimen/margin_list_items"
8481
android:text="@string/customize_app_drawer_fragment_show_headings"
85-
android:textAppearance="@style/TextAppearance.AppCompat.Large"
82+
android:textAppearance="@style/TextAppearance.Primary"
8683
app:layout_constrainedWidth="true"
8784
app:layout_constraintEnd_toStartOf="@+id/show_headings_switch_toggle"
8885
app:layout_constraintHorizontal_bias="0"
@@ -94,7 +91,7 @@
9491
android:layout_width="0dp"
9592
android:layout_height="wrap_content"
9693
android:text="@string/customize_app_drawer_fragment_show_headings_subtitle"
97-
android:textAppearance="@style/TextAppearance.AppCompat.Small"
94+
android:textAppearance="@style/TextAppearance.Hint"
9895
app:layout_constrainedWidth="true"
9996
app:layout_constraintEnd_toStartOf="@+id/show_headings_switch_toggle"
10097
app:layout_constraintHorizontal_bias="0"

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
android:layout_width="0dp"
2727
android:layout_height="wrap_content"
2828
android:text="@string/customize_app_drawer_fragment_search_field_options"
29-
android:textAppearance="@style/TextAppearance.AppCompat"
30-
android:textColor="?headerTextColor"
31-
android:textSize="@dimen/font_size_options_title"
29+
android:textAppearance="@style/TextAppearance.Header"
3230
app:layout_constraintEnd_toEndOf="parent"
3331
app:layout_constraintStart_toEndOf="@+id/header_back"
3432
app:layout_constraintTop_toTopOf="parent" />
@@ -52,9 +50,8 @@
5250
android:layout_width="match_parent"
5351
android:layout_height="wrap_content"
5452
android:text="@string/customize_app_drawer_fragment_show_search_bar"
55-
android:textAppearance="@style/TextAppearance.AppCompat"
56-
android:textColor="?switchTextColor"
57-
android:textSize="@dimen/font_size_customize_options"
53+
android:textAppearance="@style/TextAppearance.Primary.Large"
54+
android:textColor="@color/primary_text"
5855
app:layout_constraintStart_toStartOf="parent"
5956
app:layout_constraintTop_toTopOf="parent" />
6057

@@ -64,15 +61,15 @@
6461
android:layout_height="wrap_content"
6562
android:layout_marginTop="@dimen/margin_list_items"
6663
android:text="@string/customize_app_drawer_fragment_search_bar_position"
67-
android:textAppearance="@style/TextAppearance.AppCompat.Large"
64+
android:textAppearance="@style/TextAppearance.Primary"
6865
app:layout_constraintStart_toStartOf="parent"
6966
app:layout_constraintTop_toBottomOf="@id/show_search_field_switch" />
7067

7168
<TextView
7269
android:id="@+id/search_field_position_subtitle"
7370
android:layout_width="match_parent"
7471
android:layout_height="wrap_content"
75-
android:textAppearance="@style/TextAppearance.AppCompat.Small"
72+
android:textAppearance="@style/TextAppearance.Hint"
7673
app:layout_constraintStart_toStartOf="parent"
7774
app:layout_constraintTop_toBottomOf="@id/search_field_position_title" />
7875

@@ -82,7 +79,7 @@
8279
android:layout_height="wrap_content"
8380
android:layout_marginTop="@dimen/margin_list_items"
8481
android:text="@string/customize_app_drawer_fragment_open_keyboard"
85-
android:textAppearance="@style/TextAppearance.AppCompat.Large"
82+
android:textAppearance="@style/TextAppearance.Primary"
8683
app:layout_constrainedWidth="true"
8784
app:layout_constraintEnd_toStartOf="@+id/open_keyboard_switch_toggle"
8885
app:layout_constraintHorizontal_bias="0"
@@ -94,7 +91,7 @@
9491
android:layout_width="0dp"
9592
android:layout_height="wrap_content"
9693
android:text="@string/customize_app_drawer_fragment_open_keyboard_subtitle"
97-
android:textAppearance="@style/TextAppearance.AppCompat.Small"
94+
android:textAppearance="@style/TextAppearance.Hint"
9895
app:layout_constrainedWidth="true"
9996
app:layout_constraintEnd_toStartOf="@+id/open_keyboard_switch_toggle"
10097
app:layout_constraintHorizontal_bias="0"
@@ -115,7 +112,7 @@
115112
android:layout_height="wrap_content"
116113
android:layout_marginTop="@dimen/margin_list_items"
117114
android:text="@string/customize_app_drawer_fragment_search_all"
118-
android:textAppearance="@style/TextAppearance.AppCompat.Large"
115+
android:textAppearance="@style/TextAppearance.Primary"
119116
app:layout_constrainedWidth="true"
120117
app:layout_constraintEnd_toStartOf="@+id/open_keyboard_switch_toggle"
121118
app:layout_constraintHorizontal_bias="0"
@@ -127,7 +124,7 @@
127124
android:layout_width="0dp"
128125
android:layout_height="wrap_content"
129126
android:text="@string/customize_app_drawer_fragment_search_all_subtitle"
130-
android:textAppearance="@style/TextAppearance.AppCompat.Small"
127+
android:textAppearance="@style/TextAppearance.Hint"
131128
app:layout_constrainedWidth="true"
132129
app:layout_constraintEnd_toStartOf="@+id/open_keyboard_switch_toggle"
133130
app:layout_constraintHorizontal_bias="0"

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
android:layout_width="0dp"
2727
android:layout_height="wrap_content"
2828
android:text="@string/customize_app_drawer_fragment_visible_apps"
29-
android:textAppearance="@style/TextAppearance.AppCompat"
30-
android:textColor="?headerTextColor"
31-
android:textSize="@dimen/font_size_options_title"
29+
android:textAppearance="@style/TextAppearance.Header"
3230
app:layout_constraintEnd_toEndOf="parent"
3331
app:layout_constraintStart_toEndOf="@+id/header_back"
3432
app:layout_constraintTop_toTopOf="parent" />

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
android:layout_width="match_parent"
55
android:layout_height="wrap_content"
66
android:padding="@dimen/padding"
7-
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
7+
android:textAppearance="@style/TextAppearance.Primary" />

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
android:layout_width="0dp"
2727
android:layout_height="wrap_content"
2828
android:text="@string/customize_home"
29-
android:textAppearance="@style/TextAppearance.AppCompat"
30-
android:textColor="?headerTextColor"
31-
android:textSize="@dimen/font_size_options_title"
29+
android:textAppearance="@style/TextAppearance.Header"
3230
app:layout_constraintEnd_toEndOf="parent"
3331
app:layout_constraintStart_toEndOf="@id/header_back"
3432
app:layout_constraintTop_toTopOf="parent" />
@@ -59,17 +57,15 @@
5957
android:padding="@dimen/padding"
6058
android:paddingEnd="0dp"
6159
android:text="+"
62-
android:textAppearance="@style/TextAppearance.AppCompat"
63-
android:textSize="@dimen/font_size_home_app_list_item"
60+
android:textAppearance="@style/TextAppearance.Primary.XL"
6461
tools:ignore="HardcodedText,RtlSymmetry" />
6562

6663
<TextView
6764
android:layout_width="wrap_content"
6865
android:layout_height="wrap_content"
6966
android:padding="@dimen/padding"
7067
android:text="@string/customise_apps_fragment_add"
71-
android:textAppearance="@style/TextAppearance.AppCompat"
72-
android:textSize="@dimen/font_size_home_app_list_item" />
68+
android:textAppearance="@style/TextAppearance.Primary.XL" />
7369
</LinearLayout>
7470

7571
<ImageView

0 commit comments

Comments
 (0)