Loading aconfig/launcher.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -398,3 +398,10 @@ flag { purpose: PURPOSE_BUGFIX } } flag { name: "enable_dismiss_prediction_undo" namespace: "launcher" description: "Show an 'Undo' snackbar when users dismiss a predicted hotseat item" bug: "270394476" } src/com/android/launcher3/DropTargetHandler.kt +3 −13 Original line number Diff line number Diff line Loading @@ -35,8 +35,7 @@ class DropTargetHandler(launcher: Launcher) { target?.let { deferred.mPackageName = it.packageName mLauncher.addEventCallback(EVENT_RESUMED) { deferred.onLauncherResume() } } ?: deferred.sendFailure() } ?: deferred.sendFailure() } } } Loading @@ -47,19 +46,10 @@ class DropTargetHandler(launcher: Launcher) { mLauncher.appWidgetHolder.startConfigActivity( mLauncher, widgetId, ActivityCodes.REQUEST_RECONFIGURE_APPWIDGET ActivityCodes.REQUEST_RECONFIGURE_APPWIDGET, ) } fun dismissPrediction( announcement: CharSequence, onActionClicked: Runnable, onDismiss: Runnable? ) { mLauncher.dragLayer.announceForAccessibility(announcement) Snackbar.show(mLauncher, R.string.item_removed, R.string.undo, onDismiss, onActionClicked) } fun getViewUnderDrag(info: ItemInfo): View? { return if ( info is LauncherAppWidgetInfo && Loading Loading @@ -95,7 +85,7 @@ class DropTargetHandler(launcher: Launcher) { R.string.item_removed, R.string.undo, mLauncher.modelWriter::commitDelete, onUndoClicked onUndoClicked, ) } Loading src/com/android/launcher3/SecondaryDropTarget.java +4 −23 Original line number Diff line number Diff line Loading @@ -7,7 +7,6 @@ import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate. import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.INVALID; import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.RECONFIGURE; import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.UNINSTALL; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_DISMISS_PREDICTION_UNDO; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ITEM_DROPPED_ON_DONT_SUGGEST; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ITEM_DROPPED_ON_UNINSTALL; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ITEM_UNINSTALL_CANCELLED; Loading Loading @@ -36,7 +35,6 @@ import android.widget.Toast; import androidx.annotation.Nullable; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.dragndrop.DragOptions; import com.android.launcher3.logging.FileLog; import com.android.launcher3.logging.InstanceId; Loading Loading @@ -242,8 +240,7 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList @Override public void completeDrop(final DragObject d) { ComponentName target = performDropAction(getViewUnderDrag(d.dragInfo), d.dragInfo, d.logInstanceId); ComponentName target = performDropAction(getViewUnderDrag(d.dragInfo), d.dragInfo); mDropTargetHandler.onSecondaryTargetCompleteDrop(target, d); } Loading Loading @@ -275,7 +272,7 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList * Performs the drop action and returns the target component for the dragObject or null if * the action was not performed. */ protected ComponentName performDropAction(View view, ItemInfo info, InstanceId instanceId) { protected ComponentName performDropAction(View view, ItemInfo info) { if (mCurrentAccessibilityAction == RECONFIGURE) { int widgetId = getReconfigurableWidgetId(view); if (widgetId != INVALID_APPWIDGET_ID) { Loading @@ -283,21 +280,6 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList } return null; } if (mCurrentAccessibilityAction == DISMISS_PREDICTION) { if (FeatureFlags.ENABLE_DISMISS_PREDICTION_UNDO.get()) { CharSequence announcement = getContext().getString(R.string.item_removed); mDropTargetHandler .dismissPrediction(announcement, () -> { }, () -> { mStatsLogManager.logger() .withInstanceId(instanceId) .withItemInfo(info) .log(LAUNCHER_DISMISS_PREDICTION_UNDO); }); } return null; } return performUninstall(getContext(), getUninstallTarget(getContext(), info), info); } Loading Loading @@ -332,9 +314,8 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList @Override public void onAccessibilityDrop(View view, ItemInfo item) { InstanceId instanceId = new InstanceIdSequence().newInstanceId(); doLog(instanceId, item); performDropAction(view, item, instanceId); doLog(new InstanceIdSequence().newInstanceId(), item); performDropAction(view, item); } /** Loading src/com/android/launcher3/config/FeatureFlags.java +0 −4 Original line number Diff line number Diff line Loading @@ -63,10 +63,6 @@ public final class FeatureFlags { * <p> */ // TODO(Block 3): Clean up flags public static final BooleanFlag ENABLE_DISMISS_PREDICTION_UNDO = getDebugFlag(270394476, "ENABLE_DISMISS_PREDICTION_UNDO", DISABLED, "Show an 'Undo' snackbar when users dismiss a predicted hotseat item"); public static final BooleanFlag ENABLE_WORKSPACE_LOADING_OPTIMIZATION = getDebugFlag(251502424, "ENABLE_WORKSPACE_LOADING_OPTIMIZATION", DISABLED, "load the current workspace screen visible to the user before the rest rather than " Loading src/com/android/launcher3/popup/SystemShortcut.java +10 −0 Original line number Diff line number Diff line package com.android.launcher3.popup; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_DISMISS_PREDICTION_UNDO; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_PRIVATE_SPACE_INSTALL_SYSTEM_SHORTCUT_TAP; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_PRIVATE_SPACE_UNINSTALL_SYSTEM_SHORTCUT_TAP; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_APP_INFO_TAP; Loading Loading @@ -41,6 +42,7 @@ import com.android.launcher3.util.InstantAppResolver; import com.android.launcher3.util.PackageManagerHelper; import com.android.launcher3.util.PackageUserKey; import com.android.launcher3.views.ActivityContext; import com.android.launcher3.views.Snackbar; import com.android.launcher3.widget.WidgetsBottomSheet; import com.android.launcher3.widget.picker.model.data.WidgetPickerData; Loading Loading @@ -336,6 +338,14 @@ public abstract class SystemShortcut<T extends ActivityContext> extends ItemInfo mTarget.getStatsLogManager().logger() .withItemInfo(mItemInfo) .log(LAUNCHER_SYSTEM_SHORTCUT_DONT_SUGGEST_APP_TAP); if (Flags.enableDismissPredictionUndo()) { Snackbar.show(mTarget, view.getContext().getString(R.string.item_removed), R.string.undo, () -> { }, () -> mTarget.getStatsLogManager().logger() .withItemInfo(mItemInfo) .log(LAUNCHER_DISMISS_PREDICTION_UNDO)); } } } Loading Loading
aconfig/launcher.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -398,3 +398,10 @@ flag { purpose: PURPOSE_BUGFIX } } flag { name: "enable_dismiss_prediction_undo" namespace: "launcher" description: "Show an 'Undo' snackbar when users dismiss a predicted hotseat item" bug: "270394476" }
src/com/android/launcher3/DropTargetHandler.kt +3 −13 Original line number Diff line number Diff line Loading @@ -35,8 +35,7 @@ class DropTargetHandler(launcher: Launcher) { target?.let { deferred.mPackageName = it.packageName mLauncher.addEventCallback(EVENT_RESUMED) { deferred.onLauncherResume() } } ?: deferred.sendFailure() } ?: deferred.sendFailure() } } } Loading @@ -47,19 +46,10 @@ class DropTargetHandler(launcher: Launcher) { mLauncher.appWidgetHolder.startConfigActivity( mLauncher, widgetId, ActivityCodes.REQUEST_RECONFIGURE_APPWIDGET ActivityCodes.REQUEST_RECONFIGURE_APPWIDGET, ) } fun dismissPrediction( announcement: CharSequence, onActionClicked: Runnable, onDismiss: Runnable? ) { mLauncher.dragLayer.announceForAccessibility(announcement) Snackbar.show(mLauncher, R.string.item_removed, R.string.undo, onDismiss, onActionClicked) } fun getViewUnderDrag(info: ItemInfo): View? { return if ( info is LauncherAppWidgetInfo && Loading Loading @@ -95,7 +85,7 @@ class DropTargetHandler(launcher: Launcher) { R.string.item_removed, R.string.undo, mLauncher.modelWriter::commitDelete, onUndoClicked onUndoClicked, ) } Loading
src/com/android/launcher3/SecondaryDropTarget.java +4 −23 Original line number Diff line number Diff line Loading @@ -7,7 +7,6 @@ import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate. import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.INVALID; import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.RECONFIGURE; import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.UNINSTALL; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_DISMISS_PREDICTION_UNDO; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ITEM_DROPPED_ON_DONT_SUGGEST; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ITEM_DROPPED_ON_UNINSTALL; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ITEM_UNINSTALL_CANCELLED; Loading Loading @@ -36,7 +35,6 @@ import android.widget.Toast; import androidx.annotation.Nullable; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.dragndrop.DragOptions; import com.android.launcher3.logging.FileLog; import com.android.launcher3.logging.InstanceId; Loading Loading @@ -242,8 +240,7 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList @Override public void completeDrop(final DragObject d) { ComponentName target = performDropAction(getViewUnderDrag(d.dragInfo), d.dragInfo, d.logInstanceId); ComponentName target = performDropAction(getViewUnderDrag(d.dragInfo), d.dragInfo); mDropTargetHandler.onSecondaryTargetCompleteDrop(target, d); } Loading Loading @@ -275,7 +272,7 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList * Performs the drop action and returns the target component for the dragObject or null if * the action was not performed. */ protected ComponentName performDropAction(View view, ItemInfo info, InstanceId instanceId) { protected ComponentName performDropAction(View view, ItemInfo info) { if (mCurrentAccessibilityAction == RECONFIGURE) { int widgetId = getReconfigurableWidgetId(view); if (widgetId != INVALID_APPWIDGET_ID) { Loading @@ -283,21 +280,6 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList } return null; } if (mCurrentAccessibilityAction == DISMISS_PREDICTION) { if (FeatureFlags.ENABLE_DISMISS_PREDICTION_UNDO.get()) { CharSequence announcement = getContext().getString(R.string.item_removed); mDropTargetHandler .dismissPrediction(announcement, () -> { }, () -> { mStatsLogManager.logger() .withInstanceId(instanceId) .withItemInfo(info) .log(LAUNCHER_DISMISS_PREDICTION_UNDO); }); } return null; } return performUninstall(getContext(), getUninstallTarget(getContext(), info), info); } Loading Loading @@ -332,9 +314,8 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList @Override public void onAccessibilityDrop(View view, ItemInfo item) { InstanceId instanceId = new InstanceIdSequence().newInstanceId(); doLog(instanceId, item); performDropAction(view, item, instanceId); doLog(new InstanceIdSequence().newInstanceId(), item); performDropAction(view, item); } /** Loading
src/com/android/launcher3/config/FeatureFlags.java +0 −4 Original line number Diff line number Diff line Loading @@ -63,10 +63,6 @@ public final class FeatureFlags { * <p> */ // TODO(Block 3): Clean up flags public static final BooleanFlag ENABLE_DISMISS_PREDICTION_UNDO = getDebugFlag(270394476, "ENABLE_DISMISS_PREDICTION_UNDO", DISABLED, "Show an 'Undo' snackbar when users dismiss a predicted hotseat item"); public static final BooleanFlag ENABLE_WORKSPACE_LOADING_OPTIMIZATION = getDebugFlag(251502424, "ENABLE_WORKSPACE_LOADING_OPTIMIZATION", DISABLED, "load the current workspace screen visible to the user before the rest rather than " Loading
src/com/android/launcher3/popup/SystemShortcut.java +10 −0 Original line number Diff line number Diff line package com.android.launcher3.popup; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_DISMISS_PREDICTION_UNDO; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_PRIVATE_SPACE_INSTALL_SYSTEM_SHORTCUT_TAP; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_PRIVATE_SPACE_UNINSTALL_SYSTEM_SHORTCUT_TAP; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_APP_INFO_TAP; Loading Loading @@ -41,6 +42,7 @@ import com.android.launcher3.util.InstantAppResolver; import com.android.launcher3.util.PackageManagerHelper; import com.android.launcher3.util.PackageUserKey; import com.android.launcher3.views.ActivityContext; import com.android.launcher3.views.Snackbar; import com.android.launcher3.widget.WidgetsBottomSheet; import com.android.launcher3.widget.picker.model.data.WidgetPickerData; Loading Loading @@ -336,6 +338,14 @@ public abstract class SystemShortcut<T extends ActivityContext> extends ItemInfo mTarget.getStatsLogManager().logger() .withItemInfo(mItemInfo) .log(LAUNCHER_SYSTEM_SHORTCUT_DONT_SUGGEST_APP_TAP); if (Flags.enableDismissPredictionUndo()) { Snackbar.show(mTarget, view.getContext().getString(R.string.item_removed), R.string.undo, () -> { }, () -> mTarget.getStatsLogManager().logger() .withItemInfo(mItemInfo) .log(LAUNCHER_DISMISS_PREDICTION_UNDO)); } } } Loading