Merge "Add "Don't suggest app" shortcut to suggested apps." into main

This commit is contained in:
Anushree Ganjam
2024-01-17 22:25:17 +00:00
committed by Android (Google) Code Review
7 changed files with 50 additions and 3 deletions
@@ -155,6 +155,9 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList
}
return INVALID;
} else if (info.isPredictedItem()) {
if (Flags.enableShortcutDontSuggestApp()) {
return INVALID;
}
return DISMISS_PREDICTION;
}
@@ -211,6 +211,9 @@ public class StatsLogManager implements ResourceBasedOverride {
@UiEvent(doc = "User tapped on pin system shortcut.")
LAUNCHER_SYSTEM_SHORTCUT_PIN_TAP(522),
@UiEvent(doc = "User tapped on don't suggest app system shortcut.")
LAUNCHER_SYSTEM_SHORTCUT_DONT_SUGGEST_APP_TAP(1603),
@UiEvent(doc = "User is shown All Apps education view.")
LAUNCHER_ALL_APPS_EDU_SHOWN(523),
@@ -2,6 +2,7 @@ package com.android.launcher3.popup;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_PRIVATE_SPACE_INSTALL_SYSTEM_SHORTCUT_TAP;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_APP_INFO_TAP;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_DONT_SUGGEST_APP_TAP;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_WIDGETS_TAP;
import android.app.ActivityOptions;
@@ -324,6 +325,34 @@ public abstract class SystemShortcut<T extends Context & ActivityContext> extend
}
}
public static final Factory<Launcher> DONT_SUGGEST_APP = new Factory<Launcher>() {
@Nullable
@Override
public SystemShortcut<Launcher> getShortcut(Launcher activity, ItemInfo itemInfo,
View originalView) {
if (!itemInfo.isPredictedItem()) {
return null;
}
return new DontSuggestApp(activity, itemInfo, originalView);
}
};
private static class DontSuggestApp extends SystemShortcut<Launcher> {
DontSuggestApp(Launcher target, ItemInfo itemInfo,
View originalView) {
super(R.drawable.ic_block_no_shadow, R.string.dismiss_prediction_label, target,
itemInfo, originalView);
}
@Override
public void onClick(View view) {
dismissTaskMenuView(mTarget);
mTarget.getStatsLogManager().logger()
.withItemInfo(mItemInfo)
.log(LAUNCHER_SYSTEM_SHORTCUT_DONT_SUGGEST_APP_TAP);
}
}
public static <T extends Context & ActivityContext> void dismissTaskMenuView(T activity) {
AbstractFloatingView.closeOpenViews(activity, true,
AbstractFloatingView.TYPE_ALL & ~AbstractFloatingView.TYPE_REBIND_SAFE);