Fix big icon when dragging Toast by isolating the previous QL fix display to SEARCH_RESULT_APP_ROW
- Create another icon, "all_apps_predicted_row_icon" that will be the mDisplay for the predicted app row
in AllAppsList
Bug:299171695
Test: video
Before: https://drive.google.com/file/d/1HxNW0015nQHCc7eQiySf-gwsHrLs_JjR/view?usp=sharing
after: https://drive.google.com/file/d/1HyEwKI-yumILTCjglKcqovhTlRVjNGxg/view?usp=sharing - making sure that QL is fine and dragging regular Toast results are normal
Flag: N/a
Change-Id: Ie002cacb168396dbea39f79679bd6a04b80e374b
diff --git a/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java b/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java
index 4f889c0..f82474a 100644
--- a/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java
+++ b/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java
@@ -16,8 +16,6 @@
package com.android.launcher3.appprediction;
-import static com.android.launcher3.BubbleTextView.DISPLAY_PREDICTION_ROW;
-
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
@@ -189,7 +187,7 @@
LayoutInflater inflater = mActivityContext.getAppsView().getLayoutInflater();
while (getChildCount() < mNumPredictedAppsPerRow) {
BubbleTextView icon = (BubbleTextView) inflater.inflate(
- R.layout.all_apps_icon, this, false);
+ R.layout.all_apps_prediction_row_icon, this, false);
icon.setOnClickListener(mActivityContext.getItemOnClickListener());
icon.setOnLongClickListener(mActivityContext.getAllAppsItemLongClickListener());
icon.setLongPressTimeoutFactor(1f);
@@ -211,7 +209,6 @@
icon.reset();
if (predictionCount > i) {
icon.setVisibility(View.VISIBLE);
- icon.setDisplay(DISPLAY_PREDICTION_ROW);
icon.applyFromWorkspaceItem(mPredictedApps.get(i));
} else {
icon.setVisibility(predictionCount == 0 ? GONE : INVISIBLE);
diff --git a/res/layout/all_apps_prediction_row_icon.xml b/res/layout/all_apps_prediction_row_icon.xml
new file mode 100644
index 0000000..c9b3275
--- /dev/null
+++ b/res/layout/all_apps_prediction_row_icon.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2023 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.
+-->
+<com.android.launcher3.BubbleTextView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:launcher="http://schemas.android.com/apk/res-auto"
+ style="@style/BaseIcon.AllApps"
+ android:id="@+id/icon"
+ launcher:iconDisplay="prediction_row"
+ launcher:centerVertically="true" />
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 05eaf88..f046eca 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -86,6 +86,7 @@
<enum name="search_result_tall" value="6" />
<enum name="search_result_small" value="7" />
<enum name="prediction_row" value="8" />
+ <enum name="search_result_app_row" value="9" />
</attr>
<attr name="centerVertically" format="boolean" />
</declare-styleable>
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index abf84dd..a539148 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -99,8 +99,9 @@
private static final int DISPLAY_FOLDER = 2;
protected static final int DISPLAY_TASKBAR = 5;
public static final int DISPLAY_SEARCH_RESULT = 6;
- private static final int DISPLAY_SEARCH_RESULT_SMALL = 7;
+ public static final int DISPLAY_SEARCH_RESULT_SMALL = 7;
public static final int DISPLAY_PREDICTION_ROW = 8;
+ public static final int DISPLAY_SEARCH_RESULT_APP_ROW = 9;
private static final float MIN_LETTER_SPACING = -0.05f;
private static final int MAX_SEARCH_LOOP_COUNT = 20;
@@ -214,7 +215,8 @@
setCompoundDrawablePadding(grid.iconDrawablePaddingPx);
defaultIconSize = grid.iconSizePx;
setCenterVertically(grid.iconCenterVertically);
- } else if (mDisplay == DISPLAY_ALL_APPS || mDisplay == DISPLAY_PREDICTION_ROW) {
+ } else if (mDisplay == DISPLAY_ALL_APPS || mDisplay == DISPLAY_PREDICTION_ROW
+ || mDisplay == DISPLAY_SEARCH_RESULT_APP_ROW) {
setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.allAppsIconTextSizePx);
setCompoundDrawablePadding(grid.allAppsIconDrawablePaddingPx);
defaultIconSize = grid.allAppsIconSizePx;
@@ -1104,8 +1106,13 @@
}
public boolean isDisplaySearchResult() {
- return mDisplay == DISPLAY_SEARCH_RESULT ||
- mDisplay == DISPLAY_SEARCH_RESULT_SMALL;
+ return mDisplay == DISPLAY_SEARCH_RESULT
+ || mDisplay == DISPLAY_SEARCH_RESULT_SMALL
+ || mDisplay == DISPLAY_SEARCH_RESULT_APP_ROW;
+ }
+
+ public int getIconDisplay() {
+ return mDisplay;
}
@Override
diff --git a/src/com/android/launcher3/graphics/DragPreviewProvider.java b/src/com/android/launcher3/graphics/DragPreviewProvider.java
index b51373c..4208343 100644
--- a/src/com/android/launcher3/graphics/DragPreviewProvider.java
+++ b/src/com/android/launcher3/graphics/DragPreviewProvider.java
@@ -16,6 +16,8 @@
package com.android.launcher3.graphics;
+import static com.android.launcher3.BubbleTextView.DISPLAY_SEARCH_RESULT_APP_ROW;
+
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@@ -100,7 +102,8 @@
height = mView.getHeight();
}
- if (mView instanceof BubbleTextView) {
+ if (mView instanceof BubbleTextView btv
+ && btv.getIconDisplay() == DISPLAY_SEARCH_RESULT_APP_ROW) {
FastBitmapDrawable icon = ((BubbleTextView) mView).getIcon();
Drawable drawable = icon.getConstantState().newDrawable();
float xInset = (float) blurSizeOutline / (float) (width + blurSizeOutline);