[go: nahoru, domu]

Use a single set of text selection handle bitmaps

Same as in framework, where a single set of bitmaps is tinted with
`android:tint` on the `<bitmap>` wrapper, we already have tinting
performed in AppCompatDrawableManager. No need to carry two sets
of bitmaps if these are tinted at runtime in any case.

Binary size of minified obfuscated v7 demo:
 - before the change 2,409,701 bytes
 -  after the change 2,398,886 bytes
for the total reduction of about 10KB

Bug: 126209808
Bug: 126204182
Test: ./gradlew appcompat:appcompat:connectedCheck --info --daemon -Pandroid.testInstrumentationRunnerArguments.package=androidx.appcompat.widget
Test: manual inspection of text selection handles visuals in the demo app
Change-Id: Ic291c5e426b29de6a53dc971aa81e524634b647d
diff --git a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatDrawableManager.java b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatDrawableManager.java
index 9777298..37caa03 100644
--- a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatDrawableManager.java
+++ b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatDrawableManager.java
@@ -90,12 +90,9 @@
                         R.drawable.abc_textfield_search_activated_mtrl_alpha,
                         R.drawable.abc_cab_background_top_mtrl_alpha,
                         R.drawable.abc_text_cursor_material,
-                        R.drawable.abc_text_select_handle_left_mtrl_dark,
-                        R.drawable.abc_text_select_handle_middle_mtrl_dark,
-                        R.drawable.abc_text_select_handle_right_mtrl_dark,
-                        R.drawable.abc_text_select_handle_left_mtrl_light,
-                        R.drawable.abc_text_select_handle_middle_mtrl_light,
-                        R.drawable.abc_text_select_handle_right_mtrl_light
+                        R.drawable.abc_text_select_handle_left_mtrl,
+                        R.drawable.abc_text_select_handle_middle_mtrl,
+                        R.drawable.abc_text_select_handle_right_mtrl
                 };
 
                 /**
diff --git a/appcompat/appcompat/src/main/res/drawable-hdpi/abc_text_select_handle_left_mtrl_light.png b/appcompat/appcompat/src/main/res/drawable-hdpi/abc_text_select_handle_left_mtrl.png
similarity index 100%
rename from appcompat/appcompat/src/main/res/drawable-hdpi/abc_text_select_handle_left_mtrl_light.png
rename to appcompat/appcompat/src/main/res/drawable-hdpi/abc_text_select_handle_left_mtrl.png
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-hdpi/abc_text_select_handle_left_mtrl_dark.png b/appcompat/appcompat/src/main/res/drawable-hdpi/abc_text_select_handle_left_mtrl_dark.png
deleted file mode 100644
index ebf3f6c..0000000
--- a/appcompat/appcompat/src/main/res/drawable-hdpi/abc_text_select_handle_left_mtrl_dark.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-hdpi/abc_text_select_handle_middle_mtrl_light.png b/appcompat/appcompat/src/main/res/drawable-hdpi/abc_text_select_handle_middle_mtrl.png
similarity index 100%
rename from appcompat/appcompat/src/main/res/drawable-hdpi/abc_text_select_handle_middle_mtrl_light.png
rename to appcompat/appcompat/src/main/res/drawable-hdpi/abc_text_select_handle_middle_mtrl.png
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-hdpi/abc_text_select_handle_middle_mtrl_dark.png b/appcompat/appcompat/src/main/res/drawable-hdpi/abc_text_select_handle_middle_mtrl_dark.png
deleted file mode 100644
index 428bfab..0000000
--- a/appcompat/appcompat/src/main/res/drawable-hdpi/abc_text_select_handle_middle_mtrl_dark.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-hdpi/abc_text_select_handle_right_mtrl_light.png b/appcompat/appcompat/src/main/res/drawable-hdpi/abc_text_select_handle_right_mtrl.png
similarity index 100%
rename from appcompat/appcompat/src/main/res/drawable-hdpi/abc_text_select_handle_right_mtrl_light.png
rename to appcompat/appcompat/src/main/res/drawable-hdpi/abc_text_select_handle_right_mtrl.png
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-hdpi/abc_text_select_handle_right_mtrl_dark.png b/appcompat/appcompat/src/main/res/drawable-hdpi/abc_text_select_handle_right_mtrl_dark.png
deleted file mode 100644
index 829d5b2..0000000
--- a/appcompat/appcompat/src/main/res/drawable-hdpi/abc_text_select_handle_right_mtrl_dark.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-mdpi/abc_text_select_handle_left_mtrl_light.png b/appcompat/appcompat/src/main/res/drawable-mdpi/abc_text_select_handle_left_mtrl.png
similarity index 100%
rename from appcompat/appcompat/src/main/res/drawable-mdpi/abc_text_select_handle_left_mtrl_light.png
rename to appcompat/appcompat/src/main/res/drawable-mdpi/abc_text_select_handle_left_mtrl.png
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-mdpi/abc_text_select_handle_left_mtrl_dark.png b/appcompat/appcompat/src/main/res/drawable-mdpi/abc_text_select_handle_left_mtrl_dark.png
deleted file mode 100644
index 87e48ec..0000000
--- a/appcompat/appcompat/src/main/res/drawable-mdpi/abc_text_select_handle_left_mtrl_dark.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-mdpi/abc_text_select_handle_middle_mtrl_light.png b/appcompat/appcompat/src/main/res/drawable-mdpi/abc_text_select_handle_middle_mtrl.png
similarity index 100%
rename from appcompat/appcompat/src/main/res/drawable-mdpi/abc_text_select_handle_middle_mtrl_light.png
rename to appcompat/appcompat/src/main/res/drawable-mdpi/abc_text_select_handle_middle_mtrl.png
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-mdpi/abc_text_select_handle_middle_mtrl_dark.png b/appcompat/appcompat/src/main/res/drawable-mdpi/abc_text_select_handle_middle_mtrl_dark.png
deleted file mode 100644
index d001cea..0000000
--- a/appcompat/appcompat/src/main/res/drawable-mdpi/abc_text_select_handle_middle_mtrl_dark.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-mdpi/abc_text_select_handle_right_mtrl_light.png b/appcompat/appcompat/src/main/res/drawable-mdpi/abc_text_select_handle_right_mtrl.png
similarity index 100%
rename from appcompat/appcompat/src/main/res/drawable-mdpi/abc_text_select_handle_right_mtrl_light.png
rename to appcompat/appcompat/src/main/res/drawable-mdpi/abc_text_select_handle_right_mtrl.png
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-mdpi/abc_text_select_handle_right_mtrl_dark.png b/appcompat/appcompat/src/main/res/drawable-mdpi/abc_text_select_handle_right_mtrl_dark.png
deleted file mode 100644
index f415390..0000000
--- a/appcompat/appcompat/src/main/res/drawable-mdpi/abc_text_select_handle_right_mtrl_dark.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_text_select_handle_left_mtrl_light.png b/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_text_select_handle_left_mtrl.png
similarity index 100%
rename from appcompat/appcompat/src/main/res/drawable-xhdpi/abc_text_select_handle_left_mtrl_light.png
rename to appcompat/appcompat/src/main/res/drawable-xhdpi/abc_text_select_handle_left_mtrl.png
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_text_select_handle_left_mtrl_dark.png b/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_text_select_handle_left_mtrl_dark.png
deleted file mode 100644
index 76ed4f3..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_text_select_handle_left_mtrl_dark.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_text_select_handle_middle_mtrl_light.png b/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_text_select_handle_middle_mtrl.png
similarity index 100%
rename from appcompat/appcompat/src/main/res/drawable-xhdpi/abc_text_select_handle_middle_mtrl_light.png
rename to appcompat/appcompat/src/main/res/drawable-xhdpi/abc_text_select_handle_middle_mtrl.png
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_text_select_handle_middle_mtrl_dark.png b/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_text_select_handle_middle_mtrl_dark.png
deleted file mode 100644
index 3dcebcf..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_text_select_handle_middle_mtrl_dark.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_text_select_handle_right_mtrl_light.png b/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_text_select_handle_right_mtrl.png
similarity index 100%
rename from appcompat/appcompat/src/main/res/drawable-xhdpi/abc_text_select_handle_right_mtrl_light.png
rename to appcompat/appcompat/src/main/res/drawable-xhdpi/abc_text_select_handle_right_mtrl.png
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_text_select_handle_right_mtrl_dark.png b/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_text_select_handle_right_mtrl_dark.png
deleted file mode 100644
index 8df3718..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_text_select_handle_right_mtrl_dark.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_text_select_handle_left_mtrl_light.png b/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_text_select_handle_left_mtrl.png
similarity index 100%
rename from appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_text_select_handle_left_mtrl_light.png
rename to appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_text_select_handle_left_mtrl.png
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_text_select_handle_left_mtrl_dark.png b/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_text_select_handle_left_mtrl_dark.png
deleted file mode 100644
index 278cb23..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_text_select_handle_left_mtrl_dark.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_text_select_handle_middle_mtrl_light.png b/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_text_select_handle_middle_mtrl.png
similarity index 100%
rename from appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_text_select_handle_middle_mtrl_light.png
rename to appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_text_select_handle_middle_mtrl.png
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_text_select_handle_middle_mtrl_dark.png b/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_text_select_handle_middle_mtrl_dark.png
deleted file mode 100644
index d71dbd1..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_text_select_handle_middle_mtrl_dark.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_text_select_handle_right_mtrl_light.png b/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_text_select_handle_right_mtrl.png
similarity index 100%
rename from appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_text_select_handle_right_mtrl_light.png
rename to appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_text_select_handle_right_mtrl.png
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_text_select_handle_right_mtrl_dark.png b/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_text_select_handle_right_mtrl_dark.png
deleted file mode 100644
index 56d677d..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_text_select_handle_right_mtrl_dark.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_text_select_handle_left_mtrl_light.png b/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_text_select_handle_left_mtrl.png
similarity index 100%
rename from appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_text_select_handle_left_mtrl_light.png
rename to appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_text_select_handle_left_mtrl.png
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_text_select_handle_left_mtrl_dark.png b/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_text_select_handle_left_mtrl_dark.png
deleted file mode 100644
index 2c6d0da..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_text_select_handle_left_mtrl_dark.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_text_select_handle_right_mtrl_light.png b/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_text_select_handle_right_mtrl.png
similarity index 100%
rename from appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_text_select_handle_right_mtrl_light.png
rename to appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_text_select_handle_right_mtrl.png
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_text_select_handle_right_mtrl_dark.png b/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_text_select_handle_right_mtrl_dark.png
deleted file mode 100644
index 714b641..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_text_select_handle_right_mtrl_dark.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/values/themes_base.xml b/appcompat/appcompat/src/main/res/values/themes_base.xml
index c31ad88..bed6f98 100644
--- a/appcompat/appcompat/src/main/res/values/themes_base.xml
+++ b/appcompat/appcompat/src/main/res/values/themes_base.xml
@@ -87,9 +87,9 @@
         <item name="android:actionModePasteDrawable">?actionModePasteDrawable</item>
         <item name="android:actionModeSelectAllDrawable">?actionModeSelectAllDrawable</item>
 
-        <item name="android:textSelectHandle">@drawable/abc_text_select_handle_middle_mtrl_dark</item>
-        <item name="android:textSelectHandleLeft">@drawable/abc_text_select_handle_left_mtrl_dark</item>
-        <item name="android:textSelectHandleRight">@drawable/abc_text_select_handle_right_mtrl_dark</item>
+        <item name="android:textSelectHandle">@drawable/abc_text_select_handle_middle_mtrl</item>
+        <item name="android:textSelectHandleLeft">@drawable/abc_text_select_handle_left_mtrl</item>
+        <item name="android:textSelectHandleRight">@drawable/abc_text_select_handle_right_mtrl</item>
     </style>
 
     <style name="Platform.AppCompat.Light" parent="android:Theme.Holo.Light">
@@ -158,9 +158,9 @@
         <item name="android:actionModePasteDrawable">?actionModePasteDrawable</item>
         <item name="android:actionModeSelectAllDrawable">?actionModeSelectAllDrawable</item>
 
-        <item name="android:textSelectHandle">@drawable/abc_text_select_handle_middle_mtrl_light</item>
-        <item name="android:textSelectHandleLeft">@drawable/abc_text_select_handle_left_mtrl_light</item>
-        <item name="android:textSelectHandleRight">@drawable/abc_text_select_handle_right_mtrl_light</item>
+        <item name="android:textSelectHandle">@drawable/abc_text_select_handle_middle_mtrl</item>
+        <item name="android:textSelectHandleLeft">@drawable/abc_text_select_handle_left_mtrl</item>
+        <item name="android:textSelectHandleRight">@drawable/abc_text_select_handle_right_mtrl</item>
     </style>
 
     <!-- Themes in the "Base.Theme" family vary based on the current platform
diff --git a/samples/Support7Demos/src/main/res/layout/appcompat_night_mode.xml b/samples/Support7Demos/src/main/res/layout/appcompat_night_mode.xml
index 974ff3f..05e50f8 100644
--- a/samples/Support7Demos/src/main/res/layout/appcompat_night_mode.xml
+++ b/samples/Support7Demos/src/main/res/layout/appcompat_night_mode.xml
@@ -81,6 +81,17 @@
             android:layout_width="match_parent"
             android:layout_height="100dp" />
 
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="16dp"
+            android:text="@string/editbox" />
+
+        <EditText
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="@string/editbox" />
+
     </LinearLayout>
 
 </ScrollView>
\ No newline at end of file
diff --git a/samples/Support7Demos/src/main/res/values/strings.xml b/samples/Support7Demos/src/main/res/values/strings.xml
index 4411d75..ea8ee1f 100644
--- a/samples/Support7Demos/src/main/res/values/strings.xml
+++ b/samples/Support7Demos/src/main/res/values/strings.xml
@@ -285,6 +285,7 @@
     <string name="popup_group_dividers">Display group dividers</string>
 
     <string name="webview">WebView</string>
+    <string name="editbox">EditText</string>
     <string name="launch_activity">Launch Activity</string>
 
     <string name="custom_drawable">Drawable/Custom drawable</string>