Browse Source

Allow themes to style more objects (#5197)

* Add Tertiary color and use it for Badges

* Define ripple color for Material Dialog

Although it doesn't do anything, but it should

* Add tertiary colors for Green Apple theme

* Use the correct theme accent in AlertDialog

* Declare a global colorControlHighlight

Fixes some of the ripples listed on #5154.

* Change md_ripple_color to primary ripple color
Soitora 3 years ago
parent
commit
11a232a2df

+ 2 - 2
app/src/main/res/layout-sw600dp/main_activity.xml

@@ -32,7 +32,7 @@
             android:id="@+id/downloaded_only"
             android:layout_width="0dp"
             android:layout_height="wrap_content"
-            android:background="@color/green"
+            android:background="?attr/colorTertiary"
             android:visibility="gone"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintStart_toStartOf="parent"
@@ -45,7 +45,7 @@
                 android:layout_gravity="center"
                 android:padding="4dp"
                 android:text="@string/label_downloaded_only"
-                android:textColor="@color/md_white_1000" />
+                android:textColor="?attr/colorOnTertiary" />
 
         </FrameLayout>
 

+ 2 - 2
app/src/main/res/layout/main_activity.xml

@@ -31,7 +31,7 @@
             android:id="@+id/downloaded_only"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:background="@color/green"
+            android:background="?attr/colorTertiary"
             android:visibility="gone"
             tools:visibility="visible">
 
@@ -41,7 +41,7 @@
                 android:layout_gravity="center"
                 android:padding="4dp"
                 android:text="@string/label_downloaded_only"
-                android:textColor="@color/md_white_1000" />
+                android:textColor="?attr/colorOnTertiary" />
 
         </FrameLayout>
 

+ 2 - 2
app/src/main/res/layout/main_activity_toolbar.xml

@@ -25,7 +25,7 @@
         android:id="@+id/downloaded_only"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:background="@color/green"
+        android:background="?attr/colorTertiary"
         android:visibility="gone"
         tools:visibility="visible">
 
@@ -35,7 +35,7 @@
             android:layout_gravity="center"
             android:padding="4dp"
             android:text="@string/label_downloaded_only"
-            android:textColor="@color/md_white_1000" />
+            android:textColor="?attr/colorOnTertiary" />
 
     </FrameLayout>
 

+ 6 - 6
app/src/main/res/layout/source_comfortable_grid_item.xml

@@ -42,13 +42,13 @@
                     style="@style/TextAppearance.Regular.Caption"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:background="@color/green"
+                    android:background="?attr/colorTertiary"
                     android:paddingStart="3dp"
                     android:paddingTop="1dp"
                     android:paddingEnd="3dp"
                     android:paddingBottom="1dp"
                     android:text="@string/local_source_badge"
-                    android:textColor="@color/md_white_1000"
+                    android:textColor="?attr/colorOnTertiary"
                     android:visibility="gone"
                     tools:visibility="visible" />
 
@@ -57,12 +57,12 @@
                     style="@style/TextAppearance.Regular.Caption"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:background="@color/green"
+                    android:background="?attr/colorTertiary"
                     android:paddingStart="3dp"
                     android:paddingTop="1dp"
                     android:paddingEnd="3dp"
                     android:paddingBottom="1dp"
-                    android:textColor="@color/md_white_1000"
+                    android:textColor="?attr/colorOnTertiary"
                     android:visibility="gone"
                     tools:text="120"
                     tools:visibility="visible" />
@@ -72,12 +72,12 @@
                     style="@style/TextAppearance.Regular.Caption"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:background="@color/colorAccentDark"
+                    android:background="?attr/colorSecondary"
                     android:paddingStart="3dp"
                     android:paddingTop="1dp"
                     android:paddingEnd="3dp"
                     android:paddingBottom="1dp"
-                    android:textColor="@color/md_white_1000"
+                    android:textColor="?attr/colorOnSecondary"
                     android:visibility="gone"
                     tools:text="120"
                     tools:visibility="visible" />

+ 6 - 6
app/src/main/res/layout/source_compact_grid_item.xml

@@ -41,13 +41,13 @@
                 style="@style/TextAppearance.Regular.Caption"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:background="@color/green"
+                android:background="?attr/colorTertiary"
                 android:paddingStart="3dp"
                 android:paddingTop="1dp"
                 android:paddingEnd="3dp"
                 android:paddingBottom="1dp"
                 android:text="@string/local_source_badge"
-                android:textColor="@color/md_white_1000"
+                android:textColor="?attr/colorOnTertiary"
                 android:visibility="gone"
                 tools:visibility="visible" />
 
@@ -56,12 +56,12 @@
                 style="@style/TextAppearance.Regular.Caption"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:background="@color/green"
+                android:background="?attr/colorTertiary"
                 android:paddingStart="3dp"
                 android:paddingTop="1dp"
                 android:paddingEnd="3dp"
                 android:paddingBottom="1dp"
-                android:textColor="@color/md_white_1000"
+                android:textColor="?attr/colorOnTertiary"
                 android:visibility="gone"
                 tools:text="120"
                 tools:visibility="visible" />
@@ -71,12 +71,12 @@
                 style="@style/TextAppearance.Regular.Caption"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:background="@color/colorAccentDark"
+                android:background="?attr/colorSecondary"
                 android:paddingStart="3dp"
                 android:paddingTop="1dp"
                 android:paddingEnd="3dp"
                 android:paddingBottom="1dp"
-                android:textColor="@color/md_white_1000"
+                android:textColor="?attr/colorOnSecondary"
                 android:visibility="gone"
                 tools:text="120"
                 tools:visibility="visible" />

+ 6 - 6
app/src/main/res/layout/source_list_item.xml

@@ -54,14 +54,14 @@
             style="@style/TextAppearance.Regular.Caption"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:background="@color/green"
+            android:background="?attr/colorTertiary"
             android:maxLines="1"
             android:paddingStart="3dp"
             android:paddingTop="1dp"
             android:paddingEnd="3dp"
             android:paddingBottom="1dp"
             android:text="@string/local_source_badge"
-            android:textColor="@color/md_white_1000"
+            android:textColor="?attr/colorOnTertiary"
             android:visibility="gone"
             tools:visibility="visible" />
 
@@ -70,13 +70,13 @@
             style="@style/TextAppearance.Regular.Caption"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:background="@color/green"
+            android:background="?attr/colorTertiary"
             android:maxLines="1"
             android:paddingStart="3dp"
             android:paddingTop="1dp"
             android:paddingEnd="3dp"
             android:paddingBottom="1dp"
-            android:textColor="@color/md_white_1000"
+            android:textColor="?attr/colorOnTertiary"
             android:visibility="gone"
             tools:text="122"
             tools:visibility="visible" />
@@ -86,13 +86,13 @@
             style="@style/TextAppearance.Regular.Caption"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:background="@color/colorAccentLight"
+            android:background="?attr/colorSecondary"
             android:maxLines="1"
             android:paddingStart="3dp"
             android:paddingTop="1dp"
             android:paddingEnd="3dp"
             android:paddingBottom="1dp"
-            android:textColor="@color/md_white_1000"
+            android:textColor="?attr/colorOnSecondary"
             android:visibility="gone"
             tools:text="130"
             tools:visibility="visible" />

+ 2 - 0
app/src/main/res/values/attrs.xml

@@ -22,6 +22,8 @@
     <attr name="colorFilterActive" format="reference|integer"/>
     <attr name="colorBackgroundSplash" format="reference|integer"/>
     <attr name="colorAccentOnPrimary" format="reference|integer"/>
+    <attr name="colorTertiary" format="reference|integer"/>
+    <attr name="colorOnTertiary" format="reference|integer"/>
     <attr name="rippleSecondaryColor" format="reference|integer"/>
     <attr name="rippleToolbarColor" format="reference|integer"/>
 

+ 16 - 0
app/src/main/res/values/styles.xml

@@ -68,14 +68,30 @@
         <item name="colorAccent">@color/colorAccentLight</item>
     </style>
 
+    <style name="Theme.AlertDialog.Light.StrawberryDaiquiri" parent="Theme.AlertDialog">
+        <item name="colorAccent">@color/colorAccentStrawberry</item>
+    </style>
+
     <style name="Theme.AlertDialog.Dark" parent="Theme.AlertDialog">
         <item name="colorAccent">@color/colorAccentDark</item>
     </style>
 
+    <style name="Theme.AlertDialog.Dark.GreenApple" parent="Theme.AlertDialog">
+        <item name="colorAccent">@color/colorAccentApple</item>
+    </style>
+
+    <style name="Theme.AlertDialog.Dark.MidnightDusk" parent="Theme.AlertDialog">
+        <item name="colorAccent">@color/colorAccentDusk</item>
+    </style>
+
     <style name="Theme.AlertDialog.Amoled" parent="Theme.AlertDialog">
         <item name="colorAccent">@color/colorAccentAmoled</item>
     </style>
 
+    <style name="Theme.AlertDialog.Amoled.HotPink" parent="Theme.AlertDialog">
+        <item name="colorAccent">@color/colorAccentPink</item>
+    </style>
+
 
     <!--===========-->
     <!--BottomSheet-->

+ 30 - 0
app/src/main/res/values/themes.xml

@@ -23,6 +23,8 @@
         <item name="colorPrimaryVariant">@color/md_white_1000</item>
         <item name="colorSecondary">@color/colorAccentLight</item>
         <item name="colorOnSecondary">@color/md_white_1000</item>
+        <item name="colorTertiary">@color/green</item>
+        <item name="colorOnTertiary">@color/md_white_1000</item>
         <item name="colorSurface">@color/dialogLight</item>
         <item name="colorOnSurface">@color/textColorPrimaryLight</item>
         <item name="colorOnBackground">@color/textColorPrimaryLight</item>
@@ -45,6 +47,7 @@
         <item name="rippleColor">@color/rippleColorLight</item>
         <item name="rippleSecondaryColor">@color/rippleSecondaryColorLight</item>
         <item name="rippleToolbarColor">@color/rippleToolbarColorLight</item>
+        <item name="android:colorControlHighlight">@color/rippleColorLight</item>
 
         <!-- Handles RTL text -->
         <item name="android:textAlignment">gravity</item>
@@ -84,6 +87,7 @@
         <item name="md_color_title">?attr/colorOnSurface</item>
         <item name="md_color_content">?attr/colorOnSurface</item>
         <item name="md_color_button_text">?attr/colorAccent</item>
+        <item name="md_ripple_color">?attr/rippleColor</item>
         <item name="md_button_casing">literal</item>
         <item name="md_corner_radius">@dimen/dialog_radius</item>
 
@@ -137,11 +141,16 @@
         <!-- Theme colors -->
         <item name="colorAccentOnPrimary">@color/colorAccentStrawberry</item>
         <item name="colorSecondary">@color/colorAccentStrawberry</item>
+        <item name="colorTertiary">@color/md_blue_A400</item>
+        <item name="colorOnTertiary">@color/md_white_1000</item>
         <item name="colorAccent">@color/colorAccentStrawberry</item>
 
         <!-- Ripples -->
         <item name="rippleSecondaryColor">@color/rippleSecondaryColorStrawberry</item>
 
+        <!-- Themes -->
+        <item name="materialAlertDialogTheme">@style/Theme.AlertDialog.Light.StrawberryDaiquiri</item>
+
         <!-- Custom Attributes-->
         <item name="colorLibrarySelectionActive">@color/selectorColorStrawberry</item>
     </style>
@@ -159,6 +168,8 @@
         <item name="colorPrimaryVariant">@color/colorDarkPrimary</item>
         <item name="colorSecondary">@color/colorAccentDark</item>
         <item name="colorOnSecondary">@color/textColorPrimaryDark</item>
+        <item name="colorTertiary">@color/green</item>
+        <item name="colorOnTertiary">@color/md_white_1000</item>
         <item name="colorSurface">@color/dialogDark</item>
         <item name="colorOnSurface">@color/textColorPrimaryDark</item>
         <item name="colorOnBackground">@color/textColorPrimaryDark</item>
@@ -186,6 +197,7 @@
         <item name="rippleColor">@color/rippleColorDark</item>
         <item name="rippleSecondaryColor">@color/rippleSecondaryColorDark</item>
         <item name="rippleToolbarColor">@color/rippleToolbarColorDark</item>
+        <item name="android:colorControlHighlight">@color/rippleColorDark</item>
 
         <!-- Themes -->
         <item name="android:statusBarColor">?attr/colorPrimary</item>
@@ -221,6 +233,7 @@
         <item name="md_color_title">?attr/colorOnSurface</item>
         <item name="md_color_content">?attr/colorOnSurface</item>
         <item name="md_color_button_text">?attr/colorAccent</item>
+        <item name="md_ripple_color">?attr/rippleColor</item>
         <item name="md_button_casing">literal</item>
         <item name="md_corner_radius">@dimen/dialog_radius</item>
 
@@ -254,11 +267,16 @@
         <item name="colorAccentOnPrimary">@color/colorAccentApple</item>
         <item name="colorSecondary">@color/colorAccentApple</item>
         <item name="colorOnSecondary">@color/colorOnSecondaryApple</item>
+        <item name="colorTertiary">@color/md_blue_A400</item>
+        <item name="colorOnTertiary">@color/md_white_1000</item>
         <item name="colorAccent">@color/colorAccentApple</item>
 
         <!-- Ripples -->
         <item name="rippleSecondaryColor">@color/rippleSecondaryColorApple</item>
 
+        <!-- Themes -->
+        <item name="materialAlertDialogTheme">@style/Theme.AlertDialog.Dark.GreenApple</item>
+
         <!-- Custom Attributes-->
         <item name="colorLibrarySelectionActive">@color/selectorColorApple</item>
     </style>
@@ -272,6 +290,8 @@
         <item name="colorPrimaryVariant">@color/dialogDusk</item>
         <item name="colorSecondary">@color/colorAccentDusk</item>
         <item name="colorOnSecondary">@color/textColorPrimaryDusk</item>
+        <item name="colorTertiary">@color/md_blue_A400</item>
+        <item name="colorOnTertiary">@color/md_white_1000</item>
         <item name="colorSurface">@color/dialogDusk</item>
         <item name="colorOnSurface">@color/textColorPrimaryDusk</item>
         <item name="colorOnBackground">@color/textColorPrimaryDusk</item>
@@ -284,6 +304,9 @@
         <!-- Ripples -->
         <item name="rippleSecondaryColor">@color/rippleSecondaryColorDusk</item>
 
+        <!-- Themes -->
+        <item name="materialAlertDialogTheme">@style/Theme.AlertDialog.Dark.MidnightDusk</item>
+
         <!-- Custom Attributes -->
         <item name="colorLibrarySelection">@color/selectorColorDark</item>
         <item name="colorLibrarySelectionActive">@color/selectorColorDark</item>
@@ -329,6 +352,7 @@
         <item name="rippleColor">@color/rippleColorAmoled</item>
         <item name="rippleSecondaryColor">@color/rippleSecondaryColorAmoled</item>
         <item name="rippleToolbarColor">@color/rippleToolbarColorAmoled</item>
+        <item name="android:colorControlHighlight">@color/rippleColorAmoled</item>
 
         <!-- Themes -->
         <item name="android:statusBarColor">?attr/colorPrimary</item>
@@ -363,6 +387,7 @@
         <item name="md_color_title">?attr/colorOnSurface</item>
         <item name="md_color_content">?attr/colorOnSurface</item>
         <item name="md_color_button_text">?attr/colorAccent</item>
+        <item name="md_ripple_color">?attr/rippleColor</item>
         <item name="md_button_casing">literal</item>
         <item name="md_corner_radius">@dimen/dialog_radius</item>
 
@@ -385,12 +410,17 @@
         <item name="colorAccentOnPrimary">@color/colorAccentPink</item>
         <item name="colorSecondary">@color/colorAccentPink</item>
         <item name="colorOnSecondary">@color/textColorPrimaryPink</item>
+        <item name="colorTertiary">@color/md_blue_A400</item>
+        <item name="colorOnTertiary">@color/md_white_1000</item>
         <item name="colorOnSurface">@color/textColorPrimaryPink</item>
         <item name="colorOnBackground">@color/textColorPrimaryPink</item>
         <item name="colorAccent">@color/colorAccentPink</item>
 
         <!-- Ripples -->
         <item name="rippleSecondaryColor">@color/rippleSecondaryColorPink</item>
+
+        <!-- Themes -->
+        <item name="materialAlertDialogTheme">@style/Theme.AlertDialog.Amoled.HotPink</item>
     </style>
 
     <!--===============-->