Browse Source

Improvements to the new library item selectors (#5379)

* Increase card selector radius

* Add themed overlay to library selector
Soitora 3 years ago
parent
commit
4dfb3cc972

+ 4 - 0
app/src/main/res/color/selector_overlay.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:alpha="0.2" android:color="?attr/colorAccent" />
+</selector>

+ 3 - 3
app/src/main/res/drawable/library_item_selector.xml

@@ -10,7 +10,7 @@
                 android:bottom="2dp"
                 android:left="2dp">
                 <shape android:shape="rectangle">
-                    <corners android:radius="@dimen/card_radius" />
+                    <corners android:radius="@dimen/card_selector_radius" />
                     <solid android:color="?attr/colorLibrarySelectionActive" />
                 </shape>
             </item>
@@ -22,7 +22,7 @@
                 android:bottom="2dp"
                 android:left="2dp">
                 <shape android:shape="rectangle">
-                    <corners android:radius="@dimen/card_radius" />
+                    <corners android:radius="@dimen/card_selector_radius" />
                     <solid android:color="?attr/colorLibrarySelectionActive" />
                 </shape>
             </item>
@@ -33,7 +33,7 @@
                 android:bottom="2dp"
                 android:left="2dp">
                 <shape android:shape="rectangle">
-                    <corners android:radius="@dimen/card_radius" />
+                    <corners android:radius="@dimen/card_selector_radius" />
                     <solid android:color="?android:attr/colorBackground" />
                 </shape>
             </item>

+ 21 - 0
app/src/main/res/drawable/library_item_selector_overlay.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+    android:color="?attr/colorLibrarySelection">
+    <item>
+        <selector xmlns:android="http://schemas.android.com/apk/res/android">
+            <item android:state_selected="true">
+                <shape android:shape="rectangle">
+                    <corners android:radius="@dimen/card_selector_radius" />
+                    <solid android:color="@color/selector_overlay" />
+                </shape>
+            </item>
+
+            <item android:state_activated="true">
+                <shape android:shape="rectangle">
+                    <corners android:radius="@dimen/card_selector_radius" />
+                    <solid android:color="@color/selector_overlay" />
+                </shape>
+            </item>
+        </selector>
+    </item>
+</ripple>

+ 1 - 0
app/src/main/res/layout/source_comfortable_grid_item.xml

@@ -6,6 +6,7 @@
     android:layout_height="wrap_content"
     android:layout_margin="2dp"
     android:background="@drawable/library_item_selector"
+    android:foreground="@drawable/library_item_selector_overlay"
     android:padding="4dp">
 
     <androidx.constraintlayout.widget.ConstraintLayout

+ 1 - 0
app/src/main/res/layout/source_compact_grid_item.xml

@@ -5,6 +5,7 @@
     android:layout_height="wrap_content"
     android:layout_margin="2dp"
     android:background="@drawable/library_item_selector"
+    android:foreground="@drawable/library_item_selector_overlay"
     android:padding="4dp">
 
     <FrameLayout

+ 1 - 0
app/src/main/res/values/dimens.xml

@@ -6,6 +6,7 @@
 
     <dimen name="space_between_cards">4dp</dimen>
     <dimen name="card_radius">4dp</dimen>
+    <dimen name="card_selector_radius">6dp</dimen>
     <dimen name="dialog_radius">8dp</dimen>
 
     <dimen name="fab_size">56dp</dimen>