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

This works for suggested apps in both Home and AA+. When enable_shortcut_dont_suggest_app is true, the secondary drop target "Don't Suggest app" is removed instead "Don't suggest app" is added to shortcuts.

Video: https://b.corp.google.com/issues/319250810#comment5

Home: https://screenshot.googleplex.com/d7Wts48X6EmFAYg.png
Private space app suggested: https://screenshot.googleplex.com/BukzCRTvkzbpwQ3.png

AA+: https://screenshot.googleplex.com/ADMCHnQ378jvJEE.png
Private space app suggested : https://screenshot.googleplex.com/AYga8Km3646AqMt.png

Bug: 319250810
Flag: aconfig com.android.launcher.enable_shortcut_dont_suggest_app DEVELOPMENT
Test: Manual.

Change-Id: Ia7df749a1c7d806bd9d74124be138384c3050119
This commit is contained in:
Anushree Ganjam committed 2024-01-12 10:33:24 -08:00
1 parent eb1966c278
commit 5e9b71e055
7 files changed
+50 -3

No files matched your search

+7
View File
@@ -91,6 +91,13 @@ flag {
bug: "315055849"
}
flag {
name: "enable_shortcut_dont_suggest_app"
namespace: "launcher"
description: "Enables don't suggest app shortcut for suggested apps"
bug: "319250810"
}
flag {
name: "enable_support_for_archiving"
namespace: "launcher"
@@ -38,6 +38,7 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ONRESUME;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_QUICKSWITCH_LEFT;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_QUICKSWITCH_RIGHT;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_DONT_SUGGEST_APP_TAP;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_LAUNCH_SWIPE_DOWN;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_LAUNCH_TAP;
import static com.android.launcher3.model.PredictionHelper.isTrackedForHotseatPrediction;
@@ -137,7 +138,8 @@ public class AppEventProducer implements StatsLogConsumer {
|| event == LAUNCHER_QUICKSWITCH_LEFT
|| event == LAUNCHER_APP_LAUNCH_DRAGDROP) {
sendEvent(atomInfo, ACTION_LAUNCH, CONTAINER_PREDICTION);
} else if (event == LAUNCHER_ITEM_DROPPED_ON_DONT_SUGGEST) {
} else if (event == LAUNCHER_ITEM_DROPPED_ON_DONT_SUGGEST
|| event == LAUNCHER_SYSTEM_SHORTCUT_DONT_SUGGEST_APP_TAP) {
sendEvent(atomInfo, ACTION_DISMISS, CONTAINER_PREDICTION);
} else if (event == LAUNCHER_ITEM_DRAG_STARTED) {
mLastDragItem = atomInfo;
@@ -39,6 +39,7 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH
import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID;
import static com.android.launcher3.popup.QuickstepSystemShortcut.getSplitSelectShortcutByPosition;
import static com.android.launcher3.popup.SystemShortcut.APP_INFO;
import static com.android.launcher3.popup.SystemShortcut.DONT_SUGGEST_APP;
import static com.android.launcher3.popup.SystemShortcut.INSTALL;
import static com.android.launcher3.popup.SystemShortcut.PRIVATE_PROFILE_INSTALL;
import static com.android.launcher3.popup.SystemShortcut.WIDGETS;
@@ -417,10 +418,12 @@ public class QuickstepLauncher extends Launcher {
shortcuts.addAll(getSplitShortcuts());
shortcuts.add(WIDGETS);
shortcuts.add(INSTALL);
if (Flags.enablePrivateSpaceInstallShortcut()) {
shortcuts.add(PRIVATE_PROFILE_INSTALL);
}
if (Flags.enableShortcutDontSuggestApp()) {
shortcuts.add(DONT_SUGGEST_APP);
}
return shortcuts.stream();
}
+1 -1
View File
@@ -175,7 +175,7 @@
<string name="install_private_system_shortcut_label">Install in private</string>
<!-- Label for install drop target. [CHAR_LIMIT=20] -->
<string name="install_drop_target_label">Install</string>
<!-- Label for install dismiss prediction. -->
<!-- Label for dismiss prediction. -->
<string name="dismiss_prediction_label">Don\'t suggest app</string>
<!-- Label for pinning predicted app. -->
<string name="pin_prediction">Pin Prediction</string>
@@ -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;
@@ -314,6 +315,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);