Move 'dismiss prediction' to droptarget
This is done to avoid shortcuts being crowded when a predicted app is
long pressed.
Bug: 148707493
Test: Manual
Change-Id: I356a2cebfcc329478d96ee815fd641179359a572
diff --git a/src/com/android/launcher3/SecondaryDropTarget.java b/src/com/android/launcher3/SecondaryDropTarget.java
index 3c2ed72..1dbe195 100644
--- a/src/com/android/launcher3/SecondaryDropTarget.java
+++ b/src/com/android/launcher3/SecondaryDropTarget.java
@@ -6,6 +6,7 @@
import static com.android.launcher3.ItemInfoWithIcon.FLAG_SYSTEM_MASK;
import static com.android.launcher3.ItemInfoWithIcon.FLAG_SYSTEM_NO;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP;
+import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.DISMISS_PREDICTION;
import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.RECONFIGURE;
import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.UNINSTALL;
@@ -29,9 +30,11 @@
import android.widget.Toast;
import com.android.launcher3.Launcher.OnResumeCallback;
+import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.logging.LoggerUtils;
+import com.android.launcher3.model.AppLaunchTracker;
import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import com.android.launcher3.util.PackageManagerHelper;
@@ -43,6 +46,7 @@
* Drop target which provides a secondary option for an item.
* For app targets: shows as uninstall
* For configurable widgets: shows as setup
+ * For predicted app icons: don't suggest app
*/
public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmListener {
@@ -81,7 +85,11 @@
mHoverColor = getResources().getColor(R.color.uninstall_target_hover_tint);
setDrawable(R.drawable.ic_uninstall_shadow);
updateText(R.string.uninstall_drop_target_label);
- } else {
+ } else if (action == DISMISS_PREDICTION) {
+ mHoverColor = Themes.getColorAccent(getContext());
+ setDrawable(R.drawable.ic_block);
+ updateText(R.string.dismiss_prediction_label);
+ } else if (action == RECONFIGURE) {
mHoverColor = Themes.getColorAccent(getContext());
setDrawable(R.drawable.ic_setup_shadow);
updateText(R.string.gadget_setup_text);
@@ -101,8 +109,13 @@
@Override
public Target getDropTargetForLogging() {
Target t = LoggerUtils.newTarget(Target.Type.CONTROL);
- t.controlType = mCurrentAccessibilityAction == UNINSTALL ? ControlType.UNINSTALL_TARGET
- : ControlType.SETTINGS_BUTTON;
+ if (mCurrentAccessibilityAction == UNINSTALL) {
+ t.controlType = ControlType.UNINSTALL_TARGET;
+ } else if (mCurrentAccessibilityAction == DISMISS_PREDICTION) {
+ t.controlType = ControlType.DISMISS_PREDICTION;
+ } else {
+ t.controlType = ControlType.SETTINGS_BUTTON;
+ }
return t;
}
@@ -119,6 +132,9 @@
return true;
}
return false;
+ } else if (FeatureFlags.ENABLE_PREDICTION_DISMISS.get() && info.isPredictedItem()) {
+ setupUi(DISMISS_PREDICTION);
+ return true;
}
setupUi(UNINSTALL);
@@ -229,6 +245,11 @@
}
return null;
}
+ if (mCurrentAccessibilityAction == DISMISS_PREDICTION) {
+ AppLaunchTracker.INSTANCE.get(getContext()).onDismissApp(info.getTargetComponent(),
+ info.user, AppLaunchTracker.CONTAINER_PREDICTIONS);
+ return null;
+ }
// else: mCurrentAccessibilityAction == UNINSTALL
ComponentName cn = getUninstallTarget(info);