Merge "Fix some bugs in widget pickers." into sc-dev am: b42513fbc5

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/14339826

Change-Id: Ib4c85146f522217d69466bce40852bb574745149
diff --git a/res/color/arrow_tip_view_bg.xml b/res/color/arrow_tip_view_bg.xml
new file mode 100644
index 0000000..91eed50
--- /dev/null
+++ b/res/color/arrow_tip_view_bg.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2021, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+<selector
+    xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:color="?android:attr/colorAccent" />
+</selector>
diff --git a/res/color/arrow_tip_view_content.xml b/res/color/arrow_tip_view_content.xml
new file mode 100644
index 0000000..87c733e
--- /dev/null
+++ b/res/color/arrow_tip_view_content.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2021, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+<selector
+    xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:color="@android:color/white" />
+</selector>
diff --git a/res/drawable/arrow_toast_rounded_background.xml b/res/drawable/arrow_toast_rounded_background.xml
index 52cc6fc..f3f2158 100644
--- a/res/drawable/arrow_toast_rounded_background.xml
+++ b/res/drawable/arrow_toast_rounded_background.xml
@@ -14,6 +14,6 @@
     limitations under the License.
 -->
 <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
-    <solid android:color="?android:attr/colorAccent" />
+    <solid android:color="@color/arrow_tip_view_bg" />
     <corners android:radius="8dp" />
 </shape>
diff --git a/res/drawable/bg_widgets_searchbox.xml b/res/drawable/bg_widgets_searchbox.xml
index 2a50a51..3230ac8 100644
--- a/res/drawable/bg_widgets_searchbox.xml
+++ b/res/drawable/bg_widgets_searchbox.xml
@@ -14,6 +14,6 @@
      limitations under the License.
 -->
 <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
-    <solid android:color="?android:attr/textColorPrimaryInverse" />
+    <solid android:color="@color/widgets_picker_surface" />
     <corners android:radius="24dp" />
 </shape>
\ No newline at end of file
diff --git a/res/layout/add_item_confirmation_activity.xml b/res/layout/add_item_confirmation_activity.xml
index d5e7333..3f45746 100644
--- a/res/layout/add_item_confirmation_activity.xml
+++ b/res/layout/add_item_confirmation_activity.xml
@@ -53,6 +53,7 @@
             style="@style/Widget.DeviceDefault.Button.Rounded.Colored"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
+            android:paddingHorizontal="16dp"
             android:onClick="onCancelClick"
             android:text="@android:string/cancel" />
 
@@ -64,7 +65,8 @@
             style="@style/Widget.DeviceDefault.Button.Rounded.Colored"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
+            android:paddingHorizontal="16dp"
             android:onClick="onPlaceAutomaticallyClick"
-            android:text="@string/place_automatically" />
+            android:text="@string/add_to_home_screen" />
     </LinearLayout>
 </LinearLayout>
diff --git a/res/layout/arrow_toast.xml b/res/layout/arrow_toast.xml
index 0ec9981..ae60e1b 100644
--- a/res/layout/arrow_toast.xml
+++ b/res/layout/arrow_toast.xml
@@ -16,6 +16,7 @@
 
 <merge
     xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_height="wrap_content"
     android:layout_width="wrap_content">
 
@@ -38,7 +39,7 @@
             android:paddingBottom="5dp"
             android:gravity="center"
             android:layout_gravity="center_vertical"
-            android:textColor="@android:color/white"
+            android:textColor="@color/arrow_tip_view_content"
             android:textSize="16sp"/>
         <ImageView
             android:id="@+id/dismiss"
@@ -50,7 +51,7 @@
             android:layout_marginEnd="2dp"
             android:alpha="0.7"
             android:src="@drawable/ic_remove_no_shadow"
-            android:tint="@android:color/white"
+            android:tint="@color/arrow_tip_view_content"
             android:background="?android:attr/selectableItemBackgroundBorderless"
             android:contentDescription="@string/accessibility_close"/>
     </LinearLayout>
diff --git a/res/layout/widgets_search_bar.xml b/res/layout/widgets_search_bar.xml
index c3dd19e..103f296 100644
--- a/res/layout/widgets_search_bar.xml
+++ b/res/layout/widgets_search_bar.xml
@@ -24,7 +24,7 @@
         android:layout_weight="1"
         android:inputType="text"
         android:imeOptions="actionSearch"
-        android:textColor="?android:attr/textColorSecondary"
+        android:textColor="?android:attr/textColorPrimary"
         android:textColorHint="?android:attr/textColorTertiary"/>
 
     <ImageButton
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 0f937fa..680e51a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -57,8 +57,8 @@
     <string name="widget_accessible_dims_format">%1$d wide by %2$d high</string>
     <!-- Message to tell the user to press and hold a widget/icon to add it  -->
     <string name="add_item_request_drag_hint">Touch &amp; hold to place manually</string>
-    <!-- Button label to automatically add icon on home screen [CHAR_LIMIT=50] -->
-    <string name="place_automatically">Add automatically</string>
+    <!-- Button label to automatically add a widget to home screen [CHAR_LIMIT=50] -->
+    <string name="add_to_home_screen">Add to Home screen</string>
     <!-- Label for showing the number of widgets an app has in the full widgets picker.
          [CHAR_LIMIT=25] -->
     <plurals name="widgets_count">
diff --git a/src/com/android/launcher3/views/ArrowTipView.java b/src/com/android/launcher3/views/ArrowTipView.java
index 97c43ef..a6f2b42 100644
--- a/src/com/android/launcher3/views/ArrowTipView.java
+++ b/src/com/android/launcher3/views/ArrowTipView.java
@@ -22,7 +22,6 @@
 import android.graphics.drawable.ShapeDrawable;
 import android.os.Handler;
 import android.util.Log;
-import android.util.TypedValue;
 import android.view.Gravity;
 import android.view.MotionEvent;
 import android.view.View;
@@ -108,10 +107,7 @@
         ShapeDrawable arrowDrawable = new ShapeDrawable(TriangleShape.create(
                 arrowLp.width, arrowLp.height, false));
         Paint arrowPaint = arrowDrawable.getPaint();
-        TypedValue typedValue = new TypedValue();
-        context.getTheme()
-                .resolveAttribute(android.R.attr.colorAccent, typedValue, true);
-        arrowPaint.setColor(ContextCompat.getColor(getContext(), typedValue.resourceId));
+        arrowPaint.setColor(ContextCompat.getColor(getContext(),  R.color.arrow_tip_view_bg));
         // The corner path effect won't be reflected in the shadow, but shouldn't be noticeable.
         arrowPaint.setPathEffect(new CornerPathEffect(
                 context.getResources().getDimension(R.dimen.arrow_toast_corner_radius)));
diff --git a/tests/tapl/com/android/launcher3/tapl/AddToHomeScreenPrompt.java b/tests/tapl/com/android/launcher3/tapl/AddToHomeScreenPrompt.java
index e1fde3b..0582bc9 100644
--- a/tests/tapl/com/android/launcher3/tapl/AddToHomeScreenPrompt.java
+++ b/tests/tapl/com/android/launcher3/tapl/AddToHomeScreenPrompt.java
@@ -28,7 +28,7 @@
 
 public class AddToHomeScreenPrompt {
     private static final Pattern ADD_AUTOMATICALLY =
-            Pattern.compile("^Add automatically$", CASE_INSENSITIVE);
+            Pattern.compile("^Add to Home screen$", CASE_INSENSITIVE);
     private final LauncherInstrumentation mLauncher;
     private final UiObject2 mWidgetCell;