From c2538d748ac954a435ca71bb12862bff30803e68 Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Sun, 10 Apr 2022 00:13:01 -0700 Subject: [PATCH 1/4] Add originalView of the menu to SystemShortcut Split from home animation needs to originate from the app icon instead of the menu item icon. This can be useful for other animations in the future. Bug: 226395821 Test: N/A Change-Id: If45d80e347ba275bd550b6acd6ad81b319e753a3 --- .../src/com/android/launcher3/AppSharing.java | 15 +++-- .../HotseatPredictionController.java | 8 +-- .../launcher3/model/WellbeingModel.java | 11 ++-- .../popup/QuickstepSystemShortcut.java | 9 +-- .../taskbar/TaskbarPopupController.java | 9 +-- .../android/quickstep/TaskOverlayFactory.java | 26 ++++---- .../quickstep/TaskShortcutFactory.java | 25 ++++---- .../popup/LauncherPopupLiveUpdateHandler.java | 5 +- .../popup/PopupContainerWithArrow.java | 2 +- .../launcher3/popup/RemoteActionShortcut.java | 4 +- .../launcher3/popup/SystemShortcut.java | 59 +++++++++++-------- .../secondarydisplay/PinnedAppsAdapter.java | 9 +-- .../secondarydisplay/SecondaryDragLayer.java | 4 +- 13 files changed, 105 insertions(+), 81 deletions(-) diff --git a/go/quickstep/src/com/android/launcher3/AppSharing.java b/go/quickstep/src/com/android/launcher3/AppSharing.java index c252fba728..c287446744 100644 --- a/go/quickstep/src/com/android/launcher3/AppSharing.java +++ b/go/quickstep/src/com/android/launcher3/AppSharing.java @@ -77,11 +77,12 @@ public final class AppSharing { return FileProvider.getUriForFile(context, authority, pathFile, displayName); } - private SystemShortcut getShortcut(Launcher launcher, ItemInfo info) { + private SystemShortcut getShortcut(Launcher launcher, ItemInfo info, + View originalView) { if (TextUtils.isEmpty(mSharingComponent)) { return null; } - return new Share(launcher, info); + return new Share(launcher, info, originalView); } /** @@ -104,8 +105,9 @@ public final class AppSharing { private final PopupDataProvider mPopupDataProvider; private final boolean mSharingEnabledForUser; - public Share(Launcher target, ItemInfo itemInfo) { - super(R.drawable.ic_share, R.string.app_share_drop_target_label, target, itemInfo); + public Share(Launcher target, ItemInfo itemInfo, View originalView) { + super(R.drawable.ic_share, R.string.app_share_drop_target_label, target, itemInfo, + originalView); mPopupDataProvider = target.getPopupDataProvider(); mSharingEnabledForUser = bluetoothSharingEnabled(target); @@ -200,6 +202,7 @@ public final class AppSharing { /** * Shortcut factory for generating the Share App button */ - public static final SystemShortcut.Factory SHORTCUT_FACTORY = (launcher, itemInfo) -> - (new AppSharing(launcher)).getShortcut(launcher, itemInfo); + public static final SystemShortcut.Factory SHORTCUT_FACTORY = + (launcher, itemInfo, originalView) -> + (new AppSharing(launcher)).getShortcut(launcher, itemInfo, originalView); } diff --git a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java index 85d9f01735..62a8da787d 100644 --- a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java +++ b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java @@ -409,11 +409,11 @@ public class HotseatPredictionController implements DragController.DragListener, @Nullable @Override public SystemShortcut getShortcut(QuickstepLauncher activity, - ItemInfo itemInfo) { + ItemInfo itemInfo, View originalView) { if (itemInfo.container != LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION) { return null; } - return new PinPrediction(activity, itemInfo); + return new PinPrediction(activity, itemInfo, originalView); } private void preparePredictionInfo(WorkspaceItemInfo itemInfo, int rank) { @@ -498,9 +498,9 @@ public class HotseatPredictionController implements DragController.DragListener, private class PinPrediction extends SystemShortcut { - private PinPrediction(QuickstepLauncher target, ItemInfo itemInfo) { + private PinPrediction(QuickstepLauncher target, ItemInfo itemInfo, View originalView) { super(R.drawable.ic_pin, R.string.pin_prediction, target, - itemInfo); + itemInfo, originalView); } @Override diff --git a/quickstep/src/com/android/launcher3/model/WellbeingModel.java b/quickstep/src/com/android/launcher3/model/WellbeingModel.java index e489cb3a71..68ed682792 100644 --- a/quickstep/src/com/android/launcher3/model/WellbeingModel.java +++ b/quickstep/src/com/android/launcher3/model/WellbeingModel.java @@ -40,6 +40,7 @@ import android.os.UserHandle; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Log; +import android.view.View; import androidx.annotation.MainThread; import androidx.annotation.Nullable; @@ -193,7 +194,7 @@ public final class WellbeingModel extends BgObjectWithLooper { @MainThread private SystemShortcut getShortcutForApp(String packageName, int userId, - BaseDraggingActivity activity, ItemInfo info) { + BaseDraggingActivity activity, ItemInfo info, View originalView) { Preconditions.assertUIThread(); // Work profile apps are not recognized by digital wellbeing. if (userId != UserHandle.myUserId()) { @@ -217,7 +218,7 @@ public final class WellbeingModel extends BgObjectWithLooper { "getShortcutForApp [" + packageName + "]: action: '" + action.getTitle() + "'"); } - return new RemoteActionShortcut(action, activity, info); + return new RemoteActionShortcut(action, activity, info, originalView); } } @@ -378,8 +379,8 @@ public final class WellbeingModel extends BgObjectWithLooper { * Shortcut factory for generating wellbeing action */ public static final SystemShortcut.Factory SHORTCUT_FACTORY = - (activity, info) -> (info.getTargetComponent() == null) ? null : INSTANCE.get(activity) - .getShortcutForApp( + (activity, info, originalView) -> (info.getTargetComponent() == null) ? null + : INSTANCE.get(activity).getShortcutForApp( info.getTargetComponent().getPackageName(), info.user.getIdentifier(), - activity, info); + activity, info, originalView); } diff --git a/quickstep/src/com/android/launcher3/popup/QuickstepSystemShortcut.java b/quickstep/src/com/android/launcher3/popup/QuickstepSystemShortcut.java index cc0072ebce..86310fa14f 100644 --- a/quickstep/src/com/android/launcher3/popup/QuickstepSystemShortcut.java +++ b/quickstep/src/com/android/launcher3/popup/QuickstepSystemShortcut.java @@ -34,8 +34,9 @@ public interface QuickstepSystemShortcut { static SystemShortcut.Factory getSplitSelectShortcutByPosition( SplitPositionOption position) { - return (activity, itemInfo) -> new QuickstepSystemShortcut.SplitSelectSystemShortcut( - activity, itemInfo, position); + return (activity, itemInfo, originalView) -> + new QuickstepSystemShortcut.SplitSelectSystemShortcut(activity, itemInfo, + originalView, position); } class SplitSelectSystemShortcut extends SystemShortcut { @@ -43,8 +44,8 @@ public interface QuickstepSystemShortcut { private final SplitPositionOption mPosition; public SplitSelectSystemShortcut(BaseQuickstepLauncher launcher, ItemInfo itemInfo, - SplitPositionOption position) { - super(position.iconResId, position.textResId, launcher, itemInfo); + View originalView, SplitPositionOption position) { + super(position.iconResId, position.textResId, launcher, itemInfo, originalView); mPosition = position; } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java index 1ccad78411..c6dbc877fb 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java @@ -159,7 +159,7 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba mPopupDataProvider.getNotificationKeysForItem(item), // TODO (b/198438631): add support for INSTALL shortcut factory getSystemShortcuts() - .map(s -> s.getShortcut(context, item)) + .map(s -> s.getShortcut(context, item, icon)) .filter(Objects::nonNull) .collect(Collectors.toList())); container.requestFocus(); @@ -242,7 +242,8 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba */ private SystemShortcut.Factory createSplitShortcutFactory( SplitPositionOption position) { - return (context, itemInfo) -> new TaskbarSplitShortcut(context, itemInfo, position); + return (context, itemInfo, originalView) -> new TaskbarSplitShortcut(context, itemInfo, + originalView, position); } /** @@ -253,9 +254,9 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba private static class TaskbarSplitShortcut extends SystemShortcut { private final SplitPositionOption mPosition; - TaskbarSplitShortcut(BaseTaskbarContext context, ItemInfo itemInfo, + TaskbarSplitShortcut(BaseTaskbarContext context, ItemInfo itemInfo, View originalView, SplitPositionOption position) { - super(position.iconResId, position.textResId, context, itemInfo); + super(position.iconResId, position.textResId, context, itemInfo, originalView); mPosition = position; } diff --git a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java index 2d1f17c924..d94e5f1772 100644 --- a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java +++ b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java @@ -118,8 +118,8 @@ public class TaskOverlayFactory implements ResourceBasedOverride { * * There aren't at least 2 tasks in overview to show split options for * * Device is in "Lock task mode" * * The taskView to show split options for is the focused task AND we haven't started - * scrolling in overview (if we haven't scrolled, there's a split overview action button so - * we don't need this menu option) + * scrolling in overview (if we haven't scrolled, there's a split overview action button so + * we don't need this menu option) */ private static void addSplitOptions(List outShortcuts, BaseDraggingActivity activity, TaskView taskView, DeviceProfile deviceProfile) { @@ -156,13 +156,15 @@ public class TaskOverlayFactory implements ResourceBasedOverride { * Subclasses can attach any system listeners in this method, must be paired with * {@link #removeListeners()} */ - public void initListeners() { } + public void initListeners() { + } /** * Subclasses should remove any system listeners in this method, must be paired with * {@link #initListeners()} */ - public void removeListeners() { } + public void removeListeners() { + } /** Note that these will be shown in order from top to bottom, if available for the task. */ private static final TaskShortcutFactory[] MENU_OPTIONS = new TaskShortcutFactory[]{ @@ -189,7 +191,7 @@ public class TaskOverlayFactory implements ResourceBasedOverride { mApplicationContext = taskThumbnailView.getContext().getApplicationContext(); mThumbnailView = taskThumbnailView; mImageApi = new ImageActionsApi( - mApplicationContext, mThumbnailView::getThumbnail); + mApplicationContext, mThumbnailView::getThumbnail); } protected T getActionsView() { @@ -263,7 +265,8 @@ public class TaskOverlayFactory implements ResourceBasedOverride { /** * Gets the modal state system shortcut. */ - public SystemShortcut getModalStateSystemShortcut(WorkspaceItemInfo itemInfo) { + public SystemShortcut getModalStateSystemShortcut(WorkspaceItemInfo itemInfo, + View original) { return null; } @@ -277,9 +280,10 @@ public class TaskOverlayFactory implements ResourceBasedOverride { * Gets the system shortcut for the screenshot that will be added to the task menu. */ public SystemShortcut getScreenshotShortcut(BaseDraggingActivity activity, - ItemInfo iteminfo) { - return new ScreenshotSystemShortcut(activity, iteminfo); + ItemInfo iteminfo, View originalView) { + return new ScreenshotSystemShortcut(activity, iteminfo, originalView); } + /** * Gets the task snapshot as it is displayed on the screen. * @@ -320,8 +324,10 @@ public class TaskOverlayFactory implements ResourceBasedOverride { private final BaseDraggingActivity mActivity; - ScreenshotSystemShortcut(BaseDraggingActivity activity, ItemInfo itemInfo) { - super(R.drawable.ic_screenshot, R.string.action_screenshot, activity, itemInfo); + ScreenshotSystemShortcut(BaseDraggingActivity activity, ItemInfo itemInfo, + View originalView) { + super(R.drawable.ic_screenshot, R.string.action_screenshot, activity, itemInfo, + originalView); mActivity = activity; } diff --git a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java index e731b79a80..e807e26b08 100644 --- a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java +++ b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java @@ -49,7 +49,6 @@ import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.recents.view.AppTransitionAnimationSpecCompat; import com.android.systemui.shared.recents.view.AppTransitionAnimationSpecsFuture; import com.android.systemui.shared.recents.view.RecentsTransition; -import com.android.systemui.shared.system.ActivityCompat; import com.android.systemui.shared.system.ActivityManagerWrapper; import com.android.systemui.shared.system.ActivityOptionsCompat; import com.android.systemui.shared.system.WindowManagerWrapper; @@ -78,7 +77,7 @@ public interface TaskShortcutFactory { TaskUtils.getTitle(taskView.getContext(), taskContainer.getTask()), taskContainer.getA11yNodeId() ); - return new AppInfo(activity, taskContainer.getItemInfo(), accessibilityInfo); + return new AppInfo(activity, taskContainer.getItemInfo(), taskView, accessibilityInfo); } @Override @@ -123,7 +122,7 @@ public interface TaskShortcutFactory { private final SplitPositionOption mSplitPositionOption; public SplitSelectSystemShortcut(BaseDraggingActivity target, TaskView taskView, SplitPositionOption option) { - super(option.iconResId, option.textResId, target, taskView.getItemInfo()); + super(option.iconResId, option.textResId, target, taskView.getItemInfo(), taskView); mTaskView = taskView; mSplitPositionOption = option; } @@ -147,7 +146,8 @@ public interface TaskShortcutFactory { public MultiWindowSystemShortcut(int iconRes, int textRes, BaseDraggingActivity activity, TaskIdAttributeContainer taskContainer, MultiWindowFactory factory, LauncherEvent launcherEvent) { - super(iconRes, textRes, activity, taskContainer.getItemInfo()); + super(iconRes, textRes, activity, taskContainer.getItemInfo(), + taskContainer.getTaskView()); mLauncherEvent = launcherEvent; mHandler = new Handler(Looper.getMainLooper()); mTaskView = taskContainer.getTaskView(); @@ -320,7 +320,7 @@ public interface TaskShortcutFactory { public PinSystemShortcut(BaseDraggingActivity target, TaskIdAttributeContainer taskContainer) { super(R.drawable.ic_pin, R.string.recent_task_option_pin, target, - taskContainer.getItemInfo()); + taskContainer.getItemInfo(), taskContainer.getTaskView()); mTaskView = taskContainer.getTaskView(); } @@ -337,20 +337,23 @@ public interface TaskShortcutFactory { TaskShortcutFactory INSTALL = (activity, taskContainer) -> InstantAppResolver.newInstance(activity).isInstantApp(activity, - taskContainer.getTask().getTopComponent().getPackageName()) - ? new SystemShortcut.Install(activity, taskContainer.getItemInfo()) : null; + taskContainer.getTask().getTopComponent().getPackageName()) + ? new SystemShortcut.Install(activity, taskContainer.getItemInfo(), + taskContainer.getTaskView()) : null; TaskShortcutFactory WELLBEING = (activity, taskContainer) -> - WellbeingModel.SHORTCUT_FACTORY.getShortcut(activity, taskContainer.getItemInfo()); + WellbeingModel.SHORTCUT_FACTORY.getShortcut(activity, taskContainer.getItemInfo(), + taskContainer.getTaskView()); TaskShortcutFactory SCREENSHOT = (activity, taskContainer) -> taskContainer.getThumbnailView().getTaskOverlay() - .getScreenshotShortcut(activity, taskContainer.getItemInfo()); + .getScreenshotShortcut(activity, taskContainer.getItemInfo(), + taskContainer.getTaskView()); TaskShortcutFactory MODAL = (activity, taskContainer) -> { if (ENABLE_OVERVIEW_SELECTIONS.get()) { - return taskContainer.getThumbnailView() - .getTaskOverlay().getModalStateSystemShortcut(taskContainer.getItemInfo()); + return taskContainer.getThumbnailView().getTaskOverlay().getModalStateSystemShortcut( + taskContainer.getItemInfo(), taskContainer.getTaskView()); } return null; }; diff --git a/src/com/android/launcher3/popup/LauncherPopupLiveUpdateHandler.java b/src/com/android/launcher3/popup/LauncherPopupLiveUpdateHandler.java index 72956b01c8..c0a04b1302 100644 --- a/src/com/android/launcher3/popup/LauncherPopupLiveUpdateHandler.java +++ b/src/com/android/launcher3/popup/LauncherPopupLiveUpdateHandler.java @@ -45,8 +45,9 @@ public class LauncherPopupLiveUpdateHandler extends PopupLiveUpdateHandler popupDataProvider.getShortcutCountForItem(item), popupDataProvider.getNotificationKeysForItem(item), launcher.getSupportedShortcuts() - .map(s -> s.getShortcut(launcher, item)) + .map(s -> s.getShortcut(launcher, item, icon)) .filter(Objects::nonNull) .collect(Collectors.toList())); launcher.refreshAndBindWidgetsForPackageUser(PackageUserKey.fromItemInfo(item)); diff --git a/src/com/android/launcher3/popup/RemoteActionShortcut.java b/src/com/android/launcher3/popup/RemoteActionShortcut.java index 7c393ad1e2..e5e2c350b4 100644 --- a/src/com/android/launcher3/popup/RemoteActionShortcut.java +++ b/src/com/android/launcher3/popup/RemoteActionShortcut.java @@ -46,8 +46,8 @@ public class RemoteActionShortcut extends SystemShortcut { private final RemoteAction mAction; public RemoteActionShortcut(RemoteAction action, - BaseDraggingActivity activity, ItemInfo itemInfo) { - super(0, R.id.action_remote_action_shortcut, activity, itemInfo); + BaseDraggingActivity activity, ItemInfo itemInfo, View originalView) { + super(0, R.id.action_remote_action_shortcut, activity, itemInfo, originalView); mAction = action; } diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java index 08d3779ab6..0e25984c1b 100644 --- a/src/com/android/launcher3/popup/SystemShortcut.java +++ b/src/com/android/launcher3/popup/SystemShortcut.java @@ -46,18 +46,21 @@ public abstract class SystemShortcut extend protected final T mTarget; protected final ItemInfo mItemInfo; + protected final View mOriginalView; /** * Indicates if it's invokable or not through some disabled UI */ private boolean isEnabled = true; - public SystemShortcut(int iconResId, int labelResId, T target, ItemInfo itemInfo) { + public SystemShortcut(int iconResId, int labelResId, T target, ItemInfo itemInfo, + View originalView) { mIconResId = iconResId; mLabelResId = labelResId; mAccessibilityActionId = labelResId; mTarget = target; mItemInfo = itemInfo; + mOriginalView = originalView; } public SystemShortcut(SystemShortcut other) { @@ -66,6 +69,7 @@ public abstract class SystemShortcut extend mAccessibilityActionId = other.mAccessibilityActionId; mTarget = other.mTarget; mItemInfo = other.mItemInfo; + mOriginalView = other.mOriginalView; } /** @@ -107,10 +111,10 @@ public abstract class SystemShortcut extend public interface Factory { - @Nullable SystemShortcut getShortcut(T activity, ItemInfo itemInfo); + @Nullable SystemShortcut getShortcut(T activity, ItemInfo itemInfo, View originalView); } - public static final Factory WIDGETS = (launcher, itemInfo) -> { + public static final Factory WIDGETS = (launcher, itemInfo, originalView) -> { if (itemInfo.getTargetComponent() == null) return null; final List widgets = launcher.getPopupDataProvider().getWidgetsForPackageUser(new PackageUserKey( @@ -118,12 +122,13 @@ public abstract class SystemShortcut extend if (widgets.isEmpty()) { return null; } - return new Widgets(launcher, itemInfo); + return new Widgets(launcher, itemInfo, originalView); }; public static class Widgets extends SystemShortcut { - public Widgets(Launcher target, ItemInfo itemInfo) { - super(R.drawable.ic_widget, R.string.widget_button_text, target, itemInfo); + public Widgets(Launcher target, ItemInfo itemInfo, View originalView) { + super(R.drawable.ic_widget, R.string.widget_button_text, target, itemInfo, + originalView); } @Override @@ -145,9 +150,9 @@ public abstract class SystemShortcut extend @Nullable private SplitAccessibilityInfo mSplitA11yInfo; - public AppInfo(T target, ItemInfo itemInfo) { + public AppInfo(T target, ItemInfo itemInfo, View originalView) { super(R.drawable.ic_info_no_shadow, R.string.app_info_drop_target_label, target, - itemInfo); + itemInfo, originalView); } /** @@ -160,8 +165,9 @@ public abstract class SystemShortcut extend * That way it could directly create the correct node info for any shortcut that supports * split, but then we'll need custom resIDs for each pair of shortcuts. */ - public AppInfo(T target, ItemInfo itemInfo, SplitAccessibilityInfo accessibilityInfo) { - this(target, itemInfo); + public AppInfo(T target, ItemInfo itemInfo, View originalView, + SplitAccessibilityInfo accessibilityInfo) { + this(target, itemInfo, originalView); mSplitA11yInfo = accessibilityInfo; mAccessibilityActionId = accessibilityInfo.nodeId; } @@ -203,28 +209,29 @@ public abstract class SystemShortcut extend } } - public static final Factory INSTALL = (activity, itemInfo) -> { - boolean supportsWebUI = (itemInfo instanceof WorkspaceItemInfo) - && ((WorkspaceItemInfo) itemInfo).hasStatusFlag( + public static final Factory INSTALL = + (activity, itemInfo, originalView) -> { + boolean supportsWebUI = (itemInfo instanceof WorkspaceItemInfo) + && ((WorkspaceItemInfo) itemInfo).hasStatusFlag( WorkspaceItemInfo.FLAG_SUPPORTS_WEB_UI); - boolean isInstantApp = false; - if (itemInfo instanceof com.android.launcher3.model.data.AppInfo) { - com.android.launcher3.model.data.AppInfo - appInfo = (com.android.launcher3.model.data.AppInfo) itemInfo; - isInstantApp = InstantAppResolver.newInstance(activity).isInstantApp(appInfo); - } - boolean enabled = supportsWebUI || isInstantApp; - if (!enabled) { - return null; - } - return new Install(activity, itemInfo); + boolean isInstantApp = false; + if (itemInfo instanceof com.android.launcher3.model.data.AppInfo) { + com.android.launcher3.model.data.AppInfo + appInfo = (com.android.launcher3.model.data.AppInfo) itemInfo; + isInstantApp = InstantAppResolver.newInstance(activity).isInstantApp(appInfo); + } + boolean enabled = supportsWebUI || isInstantApp; + if (!enabled) { + return null; + } + return new Install(activity, itemInfo, originalView); }; public static class Install extends SystemShortcut { - public Install(BaseDraggingActivity target, ItemInfo itemInfo) { + public Install(BaseDraggingActivity target, ItemInfo itemInfo, View originalView) { super(R.drawable.ic_install_no_shadow, R.string.install_drop_target_label, - target, itemInfo); + target, itemInfo, originalView); } @Override diff --git a/src/com/android/launcher3/secondarydisplay/PinnedAppsAdapter.java b/src/com/android/launcher3/secondarydisplay/PinnedAppsAdapter.java index e9058c343d..a0ed77e38f 100644 --- a/src/com/android/launcher3/secondarydisplay/PinnedAppsAdapter.java +++ b/src/com/android/launcher3/secondarydisplay/PinnedAppsAdapter.java @@ -205,8 +205,8 @@ public class PinnedAppsAdapter extends BaseAdapter implements OnSharedPreference /** * Returns a system shortcut to pin/unpin a shortcut */ - public SystemShortcut getSystemShortcut(ItemInfo info) { - return new PinUnPinShortcut(mLauncher, info, + public SystemShortcut getSystemShortcut(ItemInfo info, View originalView) { + return new PinUnPinShortcut(mLauncher, info, originalView, mPinnedApps.contains(new ComponentKey(info.getTargetComponent(), info.user))); } @@ -214,10 +214,11 @@ public class PinnedAppsAdapter extends BaseAdapter implements OnSharedPreference private final boolean mIsPinned; - PinUnPinShortcut(SecondaryDisplayLauncher target, ItemInfo info, boolean isPinned) { + PinUnPinShortcut(SecondaryDisplayLauncher target, ItemInfo info, View originalView, + boolean isPinned) { super(isPinned ? R.drawable.ic_remove_no_shadow : R.drawable.ic_pin, isPinned ? R.string.remove_drop_target_label : R.string.action_add_to_workspace, - target, info); + target, info, originalView); mIsPinned = isPinned; } diff --git a/src/com/android/launcher3/secondarydisplay/SecondaryDragLayer.java b/src/com/android/launcher3/secondarydisplay/SecondaryDragLayer.java index 9201006cd7..e906c951db 100644 --- a/src/com/android/launcher3/secondarydisplay/SecondaryDragLayer.java +++ b/src/com/android/launcher3/secondarydisplay/SecondaryDragLayer.java @@ -193,8 +193,8 @@ public class SecondaryDragLayer extends BaseDragLayer container.populateAndShow((BubbleTextView) v, popupDataProvider.getShortcutCountForItem(item), Collections.emptyList(), - Arrays.asList(mPinnedAppsAdapter.getSystemShortcut(item), - APP_INFO.getShortcut(mActivity, item))); + Arrays.asList(mPinnedAppsAdapter.getSystemShortcut(item, v), + APP_INFO.getShortcut(mActivity, item, v))); v.getParent().requestDisallowInterceptTouchEvent(true); return true; } From a9e9c667b4f603240c99f66b342682e6de931f0a Mon Sep 17 00:00:00 2001 From: Pablo Gamito Date: Wed, 20 Apr 2022 23:35:03 +0000 Subject: [PATCH 2/4] Use shared background color animation for settings activity Test: check that the launcher home settings activity transitions use the clear color activity animation with the correct background color Bug: 229898866 Change-Id: Ic96ceb0fdbd6c4f10b411492dc5be18e979796c8 --- .../shared_x_axis_activity_close_enter.xml | 42 +++++++++++++++++++ .../shared_x_axis_activity_close_exit.xml | 41 ++++++++++++++++++ .../shared_x_axis_activity_open_enter.xml | 42 +++++++++++++++++++ .../shared_x_axis_activity_open_exit.xml | 41 ++++++++++++++++++ res/interpolator/fast_out_extra_slow_in.xml | 19 +++++++++ res/interpolator/standard_accelerate.xml | 22 ++++++++++ res/interpolator/standard_decelerate.xml | 22 ++++++++++ res/values-v33/style.xml | 40 ++++++++++++++++++ 8 files changed, 269 insertions(+) create mode 100644 res/anim-v33/shared_x_axis_activity_close_enter.xml create mode 100644 res/anim-v33/shared_x_axis_activity_close_exit.xml create mode 100644 res/anim-v33/shared_x_axis_activity_open_enter.xml create mode 100644 res/anim-v33/shared_x_axis_activity_open_exit.xml create mode 100644 res/interpolator/fast_out_extra_slow_in.xml create mode 100644 res/interpolator/standard_accelerate.xml create mode 100644 res/interpolator/standard_decelerate.xml create mode 100644 res/values-v33/style.xml diff --git a/res/anim-v33/shared_x_axis_activity_close_enter.xml b/res/anim-v33/shared_x_axis_activity_close_enter.xml new file mode 100644 index 0000000000..94ef06c604 --- /dev/null +++ b/res/anim-v33/shared_x_axis_activity_close_enter.xml @@ -0,0 +1,42 @@ + + + + + + + + + + \ No newline at end of file diff --git a/res/anim-v33/shared_x_axis_activity_close_exit.xml b/res/anim-v33/shared_x_axis_activity_close_exit.xml new file mode 100644 index 0000000000..19eb09e4d3 --- /dev/null +++ b/res/anim-v33/shared_x_axis_activity_close_exit.xml @@ -0,0 +1,41 @@ + + + + + + + + + + \ No newline at end of file diff --git a/res/anim-v33/shared_x_axis_activity_open_enter.xml b/res/anim-v33/shared_x_axis_activity_open_enter.xml new file mode 100644 index 0000000000..f699ceca70 --- /dev/null +++ b/res/anim-v33/shared_x_axis_activity_open_enter.xml @@ -0,0 +1,42 @@ + + + + + + + + + + \ No newline at end of file diff --git a/res/anim-v33/shared_x_axis_activity_open_exit.xml b/res/anim-v33/shared_x_axis_activity_open_exit.xml new file mode 100644 index 0000000000..85988ecfd2 --- /dev/null +++ b/res/anim-v33/shared_x_axis_activity_open_exit.xml @@ -0,0 +1,41 @@ + + + + + + + + + + \ No newline at end of file diff --git a/res/interpolator/fast_out_extra_slow_in.xml b/res/interpolator/fast_out_extra_slow_in.xml new file mode 100644 index 0000000000..f296a8224f --- /dev/null +++ b/res/interpolator/fast_out_extra_slow_in.xml @@ -0,0 +1,19 @@ + + + + \ No newline at end of file diff --git a/res/interpolator/standard_accelerate.xml b/res/interpolator/standard_accelerate.xml new file mode 100644 index 0000000000..394393dc36 --- /dev/null +++ b/res/interpolator/standard_accelerate.xml @@ -0,0 +1,22 @@ + + + + \ No newline at end of file diff --git a/res/interpolator/standard_decelerate.xml b/res/interpolator/standard_decelerate.xml new file mode 100644 index 0000000000..579f4f5644 --- /dev/null +++ b/res/interpolator/standard_decelerate.xml @@ -0,0 +1,22 @@ + + + + \ No newline at end of file diff --git a/res/values-v33/style.xml b/res/values-v33/style.xml new file mode 100644 index 0000000000..bd484683d0 --- /dev/null +++ b/res/values-v33/style.xml @@ -0,0 +1,40 @@ + + + + + + + + \ No newline at end of file From 6729f0b95001bbebe32721e471b5dd9173977410 Mon Sep 17 00:00:00 2001 From: Andy Wickham Date: Mon, 11 Apr 2022 16:17:50 -0700 Subject: [PATCH 3/4] Refactors Search results into separate RV for Toast. This will help enable transitions between A-Z apps lists and search results because both can be seen simultaneously and manipulated independently. Some high level items of the refactor: - SearchRecyclerView is added; logic that populated the main (personal) tab with search results was simply redirected to this RV instead. - BaseAllAppsContainerView added isSearching() method. Returns false, and ActivityAllAppsContainerView overrides (as search is handled there). - Renamed BaseRecyclerView to FastScrollRecyclerView to better describe what it does. SearchRecyclerView extends this, but returns false for supportsFastScrolling(). - AlphabeticalAppsList#mAllAppsStore is now optional, so the Search RV doesn't need to store/listen to apps. Note this doesn't affect the predicted app row which is still updated if one of the predicted apps is uninstalled (I tested this). Future work: - Determine why dispatchRestoreInstanceState is not called for BaseAllAppsContainerView. Save is called, e.g. on rotation. Effect of restore not called: rotating while searching goes back to A-Z list. - Keep suggested apps in Header while searching. Currently they are rendered in the SearchRV above search results, as before. - Potentially extract Personal/Work tabs to move independently of header. - AlphabeticalAppsList is a misleading name because it can also contains search results. However, things are pretty intertwined between that and BaseAllAppsAdapter (effectively a circular dependency), so I figured cleaning all that up was out of the immediate scope of this refactor, which is mainly meant to unblock transition work. Bug: 206905515 Test: Manually checked for regressions, ran tests. Change-Id: I4d3757c8a8f9b774956ca6be541dd4fcdad1de13 --- quickstep/res/layout/taskbar_all_apps.xml | 4 + .../allapps/TaskbarAllAppsContainerView.java | 5 +- res/layout/all_apps.xml | 4 + res/layout/search_results_rv_layout.xml | 24 +++ res/layout/secondary_launcher.xml | 4 + ...rView.java => FastScrollRecyclerView.java} | 10 +- src/com/android/launcher3/Launcher.java | 2 +- .../allapps/ActivityAllAppsContainerView.java | 29 ++-- .../allapps/AllAppsRecyclerView.java | 32 ++-- .../allapps/AllAppsTransitionController.java | 9 +- .../allapps/AlphabeticalAppsList.java | 53 +++--- .../allapps/BaseAllAppsContainerView.java | 152 ++++++++++++------ .../launcher3/allapps/FloatingHeaderView.java | 29 ++-- .../launcher3/allapps/SearchRecyclerView.java | 53 ++++++ .../launcher3/allapps/WorkEduCard.java | 2 +- .../search/AppsSearchContainerLayout.java | 14 +- .../testing/TestInformationHandler.java | 2 +- .../views/RecyclerViewFastScroller.java | 6 +- .../widget/picker/WidgetsRecyclerView.java | 4 +- .../launcher3/ui/AbstractLauncherUiTest.java | 2 +- .../android/launcher3/ui/WorkProfileTest.java | 6 +- 21 files changed, 300 insertions(+), 146 deletions(-) create mode 100644 res/layout/search_results_rv_layout.xml rename src/com/android/launcher3/{BaseRecyclerView.java => FastScrollRecyclerView.java} (95%) create mode 100644 src/com/android/launcher3/allapps/SearchRecyclerView.java diff --git a/quickstep/res/layout/taskbar_all_apps.xml b/quickstep/res/layout/taskbar_all_apps.xml index d402469833..34d4b231b1 100644 --- a/quickstep/res/layout/taskbar_all_apps.xml +++ b/quickstep/res/layout/taskbar_all_apps.xml @@ -33,6 +33,10 @@ layout="@layout/all_apps_bottom_sheet_background" android:visibility="gone" /> + + diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java index 0ea2aa0647..51fa4d9f3a 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java @@ -44,9 +44,10 @@ public class TaskbarAllAppsContainerView extends } @Override - protected BaseAllAppsAdapter getAdapter(AlphabeticalAppsList mAppsList, + protected BaseAllAppsAdapter createAdapter( + AlphabeticalAppsList appsList, BaseAdapterProvider[] adapterProviders) { - return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), mAppsList, + return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), appsList, adapterProviders); } } diff --git a/res/layout/all_apps.xml b/res/layout/all_apps.xml index 2ac7e63a15..d0d82d48bd 100644 --- a/res/layout/all_apps.xml +++ b/res/layout/all_apps.xml @@ -29,6 +29,10 @@ layout="@layout/all_apps_bottom_sheet_background" android:visibility="gone" /> + + diff --git a/res/layout/search_results_rv_layout.xml b/res/layout/search_results_rv_layout.xml new file mode 100644 index 0000000000..567cb5f4fc --- /dev/null +++ b/res/layout/search_results_rv_layout.xml @@ -0,0 +1,24 @@ + + + diff --git a/res/layout/secondary_launcher.xml b/res/layout/secondary_launcher.xml index 0fe05ee721..635db141dd 100644 --- a/res/layout/secondary_launcher.xml +++ b/res/layout/secondary_launcher.xml @@ -59,6 +59,10 @@ layout="@layout/all_apps_bottom_sheet_background" android:visibility="gone" /> + + diff --git a/src/com/android/launcher3/BaseRecyclerView.java b/src/com/android/launcher3/FastScrollRecyclerView.java similarity index 95% rename from src/com/android/launcher3/BaseRecyclerView.java rename to src/com/android/launcher3/FastScrollRecyclerView.java index 9369bdc2fd..a60d143c6e 100644 --- a/src/com/android/launcher3/BaseRecyclerView.java +++ b/src/com/android/launcher3/FastScrollRecyclerView.java @@ -37,19 +37,19 @@ import com.android.launcher3.views.RecyclerViewFastScroller; *
  • Enable fast scroller. * */ -public abstract class BaseRecyclerView extends RecyclerView { +public abstract class FastScrollRecyclerView extends RecyclerView { protected RecyclerViewFastScroller mScrollbar; - public BaseRecyclerView(Context context) { + public FastScrollRecyclerView(Context context) { this(context, null); } - public BaseRecyclerView(Context context, AttributeSet attrs) { + public FastScrollRecyclerView(Context context, AttributeSet attrs) { this(context, attrs, 0); } - public BaseRecyclerView(Context context, AttributeSet attrs, int defStyleAttr) { + public FastScrollRecyclerView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @@ -206,4 +206,4 @@ public abstract class BaseRecyclerView extends RecyclerView { } scrollToPosition(0); } -} \ No newline at end of file +} diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 4b42ecbae0..463280b958 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -2750,7 +2750,7 @@ public class Launcher extends StatefulActivity packageName); if (supportsAllAppsState && isInState(LauncherState.ALL_APPS)) { - return getFirstMatch(Collections.singletonList(mAppsView.getActiveRecyclerView()), + return getFirstMatch(Collections.singletonList(mAppsView.getActiveAppsRecyclerView()), preferredItem, packageAndUserAndApp); } else { List containers = new ArrayList<>(mWorkspace.getPanelCount() + 1); diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java index e279f59aaf..16a2823c4e 100644 --- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java @@ -80,7 +80,7 @@ public class ActivityAllAppsContainerView mActivityContext.startActivitySafely(v, marketSearchIntent, null); for (int i = 0; i < mAH.size(); i++) { - mAH.get(i).adapter.setLastSearchQuery(query, marketSearchClickListener); + mAH.get(i).mAdapter.setLastSearchQuery(query, marketSearchClickListener); } mIsSearching = true; rebindAdapters(); @@ -142,7 +142,7 @@ public class ActivityAllAppsContainerView mHeaderThreshold) { bgVisible = false; @@ -242,7 +251,7 @@ public class ActivityAllAppsContainerView mAppsList, + protected BaseAllAppsAdapter createAdapter(AlphabeticalAppsList appsList, BaseAdapterProvider[] adapterProviders) { - return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), mAppsList, + return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), appsList, adapterProviders); } } diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java index 7dbe711716..18c6788397 100644 --- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java +++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java @@ -37,8 +37,8 @@ import android.view.View; import androidx.recyclerview.widget.RecyclerView; -import com.android.launcher3.BaseRecyclerView; import com.android.launcher3.DeviceProfile; +import com.android.launcher3.FastScrollRecyclerView; import com.android.launcher3.LauncherAppState; import com.android.launcher3.R; import com.android.launcher3.Utilities; @@ -53,13 +53,13 @@ import java.util.List; /** * A RecyclerView with custom fast scroll support for the all apps view. */ -public class AllAppsRecyclerView extends BaseRecyclerView { - private static final String TAG = "AllAppsContainerView"; +public class AllAppsRecyclerView extends FastScrollRecyclerView { + protected static final String TAG = "AllAppsRecyclerView"; private static final boolean DEBUG = false; private static final boolean DEBUG_LATENCY = Utilities.isPropertyEnabled(SEARCH_LOGGING); - private AlphabeticalAppsList mApps; - private final int mNumAppsPerRow; + protected AlphabeticalAppsList mApps; + protected final int mNumAppsPerRow; // The specific view heights that we use to calculate scroll private final SparseIntArray mViewHeights = new SparseIntArray(); @@ -74,8 +74,8 @@ public class AllAppsRecyclerView extends BaseRecyclerView { }; // The empty-search result background - private AllAppsBackgroundDrawable mEmptySearchBackground; - private int mEmptySearchBackgroundTopOffset; + protected AllAppsBackgroundDrawable mEmptySearchBackground; + protected int mEmptySearchBackgroundTopOffset; private ArrayList mAutoSizedOverlays = new ArrayList<>(); @@ -112,7 +112,7 @@ public class AllAppsRecyclerView extends BaseRecyclerView { return mApps; } - private void updatePoolSize() { + protected void updatePoolSize() { DeviceProfile grid = ActivityContext.lookupContext(getContext()).getDeviceProfile(); RecyclerView.RecycledViewPool pool = getRecycledViewPool(); int approxRows = (int) Math.ceil(grid.availableHeightPx / grid.allAppsIconSizePx); @@ -137,8 +137,8 @@ public class AllAppsRecyclerView extends BaseRecyclerView { Log.d(TAG, "onDraw at = " + System.currentTimeMillis()); } if (DEBUG_LATENCY) { - Log.d(SEARCH_LOGGING, - "-- Recycle view onDraw, time stamp = " + System.currentTimeMillis()); + Log.d(SEARCH_LOGGING, getClass().getSimpleName() + " onDraw; time stamp = " + + System.currentTimeMillis()); } super.onDraw(c); } @@ -223,8 +223,7 @@ public class AllAppsRecyclerView extends BaseRecyclerView { && mEmptySearchBackground != null && mEmptySearchBackground.getAlpha() > 0) { mEmptySearchBackground.setHotspot(e.getX(), e.getY()); } - hideKeyboardAsync(ActivityContext.lookupContext(getContext()), - getApplicationWindowToken()); + hideKeyboardAsync(ActivityContext.lookupContext(getContext()), getApplicationWindowToken()); return result; } @@ -359,13 +358,6 @@ public class AllAppsRecyclerView extends BaseRecyclerView { } } - @Override - public boolean supportsFastScrolling() { - // Only allow fast scrolling when the user is not searching, since the results are not - // grouped in a meaningful order - return !mApps.hasFilter(); - } - @Override public int getCurrentScrollY() { // Return early if there are no items or we haven't been measured @@ -376,7 +368,7 @@ public class AllAppsRecyclerView extends BaseRecyclerView { // Calculate the y and offset for the item View child = getChildAt(0); - int position = getChildPosition(child); + int position = getChildAdapterPosition(child); if (position == NO_POSITION) { return -1; } diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index 637a4189b8..723bc65978 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -84,7 +84,8 @@ public class AllAppsTransitionController @Override public Float get(AllAppsTransitionController controller) { if (controller.mIsTablet) { - return controller.mAppsView.getRecyclerViewContainer().getTranslationY(); + return controller.mAppsView.getAppsRecyclerViewContainer() + .getTranslationY(); } else { return controller.getAppsViewPullbackTranslationY().get( controller.mAppsView); @@ -94,7 +95,7 @@ public class AllAppsTransitionController @Override public void setValue(AllAppsTransitionController controller, float translation) { if (controller.mIsTablet) { - controller.mAppsView.getRecyclerViewContainer().setTranslationY( + controller.mAppsView.getAppsRecyclerViewContainer().setTranslationY( translation); } else { controller.getAppsViewPullbackTranslationY().set(controller.mAppsView, @@ -109,7 +110,7 @@ public class AllAppsTransitionController @Override public Float get(AllAppsTransitionController controller) { if (controller.mIsTablet) { - return controller.mAppsView.getRecyclerViewContainer().getAlpha(); + return controller.mAppsView.getAppsRecyclerViewContainer().getAlpha(); } else { return controller.getAppsViewPullbackAlpha().getValue(); } @@ -118,7 +119,7 @@ public class AllAppsTransitionController @Override public void setValue(AllAppsTransitionController controller, float alpha) { if (controller.mIsTablet) { - controller.mAppsView.getRecyclerViewContainer().setAlpha(alpha); + controller.mAppsView.getAppsRecyclerViewContainer().setAlpha(alpha); } else { controller.getAppsViewPullbackAlpha().setValue(alpha); } diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java index 7687fea85d..42374b894f 100644 --- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java +++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java @@ -18,6 +18,8 @@ package com.android.launcher3.allapps; import android.content.Context; +import androidx.annotation.Nullable; + import com.android.launcher3.allapps.BaseAllAppsAdapter.AdapterItem; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.model.data.AppInfo; @@ -71,6 +73,7 @@ public class AlphabeticalAppsList implement // The set of apps from the system private final List mApps = new ArrayList<>(); + @Nullable private final AllAppsStore mAllAppsStore; // The number of results in current adapter @@ -88,14 +91,16 @@ public class AlphabeticalAppsList implement private int mNumAppRowsInAdapter; private ItemInfoMatcher mItemFilter; - public AlphabeticalAppsList(Context context, AllAppsStore appsStore, + public AlphabeticalAppsList(Context context, @Nullable AllAppsStore appsStore, WorkAdapterProvider adapterProvider) { mAllAppsStore = appsStore; mActivityContext = ActivityContext.lookupContext(context); mAppNameComparator = new AppInfoComparator(context); mWorkAdapterProvider = adapterProvider; mNumAppsPerRowAllApps = mActivityContext.getDeviceProfile().inv.numAllAppsColumns; - mAllAppsStore.addUpdateListener(this); + if (mAllAppsStore != null) { + mAllAppsStore.addUpdateListener(this); + } } public void updateItemFilter(ItemInfoMatcher itemFilter) { @@ -168,9 +173,9 @@ public class AlphabeticalAppsList implement } /** - * Returns whether there are is a filter set. + * Returns whether there are search results which will hide the A-Z list. */ - public boolean hasFilter() { + public boolean hasSearchResults() { return !mSearchResults.isEmpty(); } @@ -178,7 +183,7 @@ public class AlphabeticalAppsList implement * Returns whether there are no filtered results. */ public boolean hasNoFilteredResults() { - return hasFilter() && mAccessibilityResultsCount == 0; + return hasSearchResults() && mAccessibilityResultsCount == 0; } /** @@ -196,13 +201,13 @@ public class AlphabeticalAppsList implement return true; } - public boolean appendSearchResults(ArrayList results) { - if (hasFilter() && results != null && results.size() > 0) { + /** Appends results to search. */ + public void appendSearchResults(ArrayList results) { + if (hasSearchResults() && results != null && results.size() > 0) { updateSearchAdapterItems(results, mSearchResults.size()); + mSearchResults.addAll(results); refreshRecyclerView(); - return true; } - return false; } void updateSearchAdapterItems(ArrayList list, int offset) { @@ -222,11 +227,14 @@ public class AlphabeticalAppsList implement */ @Override public void onAppsUpdated() { + if (mAllAppsStore == null) { + return; + } // Sort the list of apps mApps.clear(); for (AppInfo app : mAllAppsStore.getApps()) { - if (mItemFilter == null || mItemFilter.matches(app, null) || hasFilter()) { + if (mItemFilter == null || mItemFilter.matches(app, null) || hasSearchResults()) { mApps.add(app); } } @@ -296,7 +304,18 @@ public class AlphabeticalAppsList implement // Recreate the filtered and sectioned apps (for convenience for the grid layout) from the // ordered set of sections - if (!hasFilter()) { + if (hasSearchResults()) { + if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get()) { + // Append the search market item + if (hasNoFilteredResults()) { + mSearchResults.add(AdapterItem.asEmptySearch(position++)); + } else { + mSearchResults.add(AdapterItem.asAllAppsDivider(position++)); + } + mSearchResults.add(AdapterItem.asMarketSearch(position++)); + } + updateSearchAdapterItems(mSearchResults, 0); + } else { mAccessibilityResultsCount = mApps.size(); if (mWorkAdapterProvider != null) { position += mWorkAdapterProvider.addWorkItems(mAdapterItems); @@ -323,18 +342,6 @@ public class AlphabeticalAppsList implement mAdapterItems.add(appItem); } - } else { - updateSearchAdapterItems(mSearchResults, 0); - if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get()) { - // Append the search market item - if (hasNoFilteredResults()) { - mAdapterItems.add(AdapterItem.asEmptySearch(position++)); - } else { - mAdapterItems.add(AdapterItem.asAllAppsDivider(position++)); - } - mAdapterItems.add(AdapterItem.asMarketSearch(position++)); - - } } if (mNumAppsPerRowAllApps != 0) { // Update the number of rows in the adapter after we do all the merging (otherwise, we diff --git a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java index f913aa9093..6a4498917e 100644 --- a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java @@ -80,7 +80,7 @@ public abstract class BaseAllAppsContainerView