diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index a53f08a015..e268d1b0e8 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -40,6 +40,9 @@ import static com.android.launcher3.config.FeatureFlags.RECEIVE_UNFOLD_EVENTS_FR import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_TAP; 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.INSTALL; +import static com.android.launcher3.popup.SystemShortcut.WIDGETS; import static com.android.launcher3.taskbar.LauncherTaskbarUIController.ALL_APPS_PAGE_PROGRESS_INDEX; import static com.android.launcher3.taskbar.LauncherTaskbarUIController.MINUS_ONE_PAGE_PROGRESS_INDEX; import static com.android.launcher3.taskbar.LauncherTaskbarUIController.WIDGETS_PAGE_PROGRESS_INDEX; @@ -186,6 +189,8 @@ import com.android.systemui.unfold.updates.RotationChangeProvider; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.function.Predicate; @@ -385,22 +390,30 @@ public class QuickstepLauncher extends Launcher { @Override public Stream getSupportedShortcuts() { - Stream base = Stream.of(WellbeingModel.SHORTCUT_FACTORY); - if (ENABLE_SPLIT_FROM_WORKSPACE.get() && mDeviceProfile.isTablet) { - RecentsView recentsView = getOverviewPanel(); - // TODO(b/266482558): Pull it out of PagedOrentationHandler for split from workspace. - List positions = - recentsView.getPagedOrientationHandler().getSplitPositionOptions( - mDeviceProfile); - List> splitShortcuts = new ArrayList<>(); - for (SplitPositionOption position : positions) { - splitShortcuts.add(getSplitSelectShortcutByPosition(position)); - } - base = Stream.concat(base, splitShortcuts.stream()); + // Order matters as it affects order of appearance in popup container + List shortcuts = new ArrayList(Arrays.asList( + APP_INFO, WellbeingModel.SHORTCUT_FACTORY, mHotseatPredictionController)); + shortcuts.addAll(getSplitShortcuts()); + shortcuts.add(WIDGETS); + shortcuts.add(INSTALL); + return shortcuts.stream(); + } + + private List> getSplitShortcuts() { + + if (!ENABLE_SPLIT_FROM_WORKSPACE.get() || !mDeviceProfile.isTablet) { + return Collections.emptyList(); } - return Stream.concat( - Stream.of(mHotseatPredictionController), - Stream.concat(base, super.getSupportedShortcuts())); + RecentsView recentsView = getOverviewPanel(); + // TODO(b/266482558): Pull it out of PagedOrentationHandler for split from workspace. + List positions = + recentsView.getPagedOrientationHandler().getSplitPositionOptions( + mDeviceProfile); + List> splitShortcuts = new ArrayList<>(); + for (SplitPositionOption position : positions) { + splitShortcuts.add(getSplitSelectShortcutByPosition(position)); + } + return splitShortcuts; } /** diff --git a/res/drawable/ic_split_horizontal.xml b/res/drawable/ic_split_horizontal.xml index ee710d0797..2efd2b9bc2 100644 --- a/res/drawable/ic_split_horizontal.xml +++ b/res/drawable/ic_split_horizontal.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> diff --git a/res/layout/system_shortcut_icons_container.xml b/res/layout/system_shortcut_icons_container.xml index ee104d9b32..dc4fdb3832 100644 --- a/res/layout/system_shortcut_icons_container.xml +++ b/res/layout/system_shortcut_icons_container.xml @@ -22,11 +22,4 @@ android:orientation="horizontal" android:gravity="end|center_vertical" android:background="@drawable/single_item_primary" - android:elevation="@dimen/deep_shortcuts_elevation" - android:clipToPadding="true"> - - - + android:elevation="@dimen/deep_shortcuts_elevation"/> diff --git a/res/layout/system_shortcut_icons_container_material_u.xml b/res/layout/system_shortcut_icons_container_material_u.xml index afd11e6bf9..70950ba2d6 100644 --- a/res/layout/system_shortcut_icons_container_material_u.xml +++ b/res/layout/system_shortcut_icons_container_material_u.xml @@ -23,10 +23,4 @@ android:orientation="horizontal" android:gravity="end|center_vertical" android:background="@drawable/popup_background_material_u" - android:elevation="@dimen/deep_shortcuts_elevation"> - - - + android:elevation="@dimen/deep_shortcuts_elevation"/> diff --git a/res/layout/system_shortcut_rows_container_material_u.xml b/res/layout/system_shortcut_rows_container.xml similarity index 100% rename from res/layout/system_shortcut_rows_container_material_u.xml rename to res/layout/system_shortcut_rows_container.xml diff --git a/res/layout/system_shortcut_spacer.xml b/res/layout/system_shortcut_spacer.xml new file mode 100644 index 0000000000..60ea9ecb85 --- /dev/null +++ b/res/layout/system_shortcut_spacer.xml @@ -0,0 +1,8 @@ + + + \ No newline at end of file diff --git a/src/com/android/launcher3/popup/ArrowPopup.java b/src/com/android/launcher3/popup/ArrowPopup.java index a0f21dc297..be3a09b673 100644 --- a/src/com/android/launcher3/popup/ArrowPopup.java +++ b/src/com/android/launcher3/popup/ArrowPopup.java @@ -60,9 +60,7 @@ import com.android.launcher3.util.Themes; import com.android.launcher3.views.ActivityContext; import com.android.launcher3.views.BaseDragLayer; -import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; /** * A container for shortcuts to deep links and notifications associated with an app. @@ -336,23 +334,6 @@ public abstract class ArrowPopup } } - /** - * Shows the popup at the desired location, optionally reversing the children. - * @param viewsToFlip number of views from the top to to flip in case of reverse order - */ - protected void reorderAndShow(int viewsToFlip) { - setupForDisplay(); - boolean reverseOrder = !ENABLE_MATERIAL_U_POPUP.get() && mIsAboveIcon; - if (reverseOrder) { - reverseOrder(viewsToFlip); - } - assignMarginsAndBackgrounds(this); - if (shouldAddArrow()) { - addArrow(); - } - animateOpen(); - } - /** * Shows the popup at the desired location. */ @@ -372,22 +353,6 @@ public abstract class ArrowPopup orientAboutObject(); } - private void reverseOrder(int viewsToFlip) { - int count = getChildCount(); - ArrayList allViews = new ArrayList<>(count); - for (int i = 0; i < count; i++) { - if (i == viewsToFlip) { - Collections.reverse(allViews); - } - allViews.add(getChildAt(i)); - } - Collections.reverse(allViews); - removeAllViews(); - for (int i = 0; i < count; i++) { - addView(allViews.get(i)); - } - } - private int getArrowLeft() { if (mIsLeftAligned) { return mArrowOffsetHorizontal; diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java index 8fef5c6bef..670fcc7dcb 100644 --- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java +++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java @@ -257,14 +257,19 @@ public class PopupContainerWithArrow } // If there is only 1 shortcut, add it to its own container so it can show text and icon if (shortcuts.size() == 1) { - initializeSystemShortcut(R.layout.system_shortcut, this, shortcuts.get(0)); + mSystemShortcutContainer = inflateAndAdd(R.layout.system_shortcut_rows_container, + this, 0); + initializeSystemShortcut(R.layout.system_shortcut, mSystemShortcutContainer, + shortcuts.get(0), false); return; } - mSystemShortcutContainer = inflateAndAdd(R.layout.system_shortcut_icons_container, this); - for (SystemShortcut shortcut : shortcuts) { + mSystemShortcutContainer = inflateAndAdd(R.layout.system_shortcut_icons_container, this, 0); + for (int i = 0; i < shortcuts.size(); i++) { initializeSystemShortcut( - R.layout.system_shortcut_icon_only, mSystemShortcutContainer, - shortcut); + R.layout.system_shortcut_icon_only, + mSystemShortcutContainer, + shortcuts.get(i), + i < shortcuts.size() - 1); } } @@ -289,7 +294,6 @@ public class PopupContainerWithArrow } updateNotificationHeader(); } - int viewsToFlip = getChildCount(); mSystemShortcutContainer = this; if (mDeepShortcutContainer == null) { mDeepShortcutContainer = findViewById(R.id.deep_shortcuts_container); @@ -314,8 +318,7 @@ public class PopupContainerWithArrow Optional widgetShortcutOpt = getWidgetShortcut(shortcuts); if (widgetShortcutOpt.isPresent()) { if (mWidgetContainer == null) { - mWidgetContainer = inflateAndAdd(R.layout.widget_shortcut_container, - this); + mWidgetContainer = inflateAndAdd(R.layout.widget_shortcut_container, this, 0); } initializeWidgetShortcut(mWidgetContainer, widgetShortcutOpt.get()); } @@ -324,14 +327,17 @@ public class PopupContainerWithArrow } else { mDeepShortcutContainer.setVisibility(View.GONE); if (!shortcuts.isEmpty()) { - for (SystemShortcut shortcut : shortcuts) { - initializeSystemShortcut(R.layout.system_shortcut, this, shortcut); + for (int i = 0; i < shortcuts.size(); i++) { + initializeSystemShortcut( + R.layout.system_shortcut, + this, + shortcuts.get(i), + i < shortcuts.size() - 1); } } } - - reorderAndShow(viewsToFlip); - showPopupContainer((ItemInfo) originalIcon.getTag(), notificationKeys); + show(); + loadAppShortcuts((ItemInfo) originalIcon.getTag(), notificationKeys); } /** @@ -351,19 +357,17 @@ public class PopupContainerWithArrow addAllShortcutsMaterialU(deepShortcutCount, systemShortcuts); } else if (!systemShortcuts.isEmpty()) { addSystemShortcutsMaterialU(systemShortcuts, - R.layout.system_shortcut_rows_container_material_u, + R.layout.system_shortcut_rows_container, R.layout.system_shortcut); } - - // no reversing needed for U design - reorderAndShow(0); - showPopupContainer((ItemInfo) originalIcon.getTag(), /* notificationKeys= */ emptyList()); + show(); + loadAppShortcuts((ItemInfo) originalIcon.getTag(), /* notificationKeys= */ emptyList()); } /** * Animates and loads shortcuts on background thread for this popup container */ - private void showPopupContainer(ItemInfo originalItemInfo, + private void loadAppShortcuts(ItemInfo originalItemInfo, List notificationKeys) { if (ATLEAST_P) { @@ -390,7 +394,7 @@ public class PopupContainerWithArrow if (deepShortcutCount + systemShortcuts.size() <= SHORTCUT_COLLAPSE_THRESHOLD) { // add all system shortcuts including widgets shortcut to same container addSystemShortcutsMaterialU(systemShortcuts, - R.layout.system_shortcut_rows_container_material_u, + R.layout.system_shortcut_rows_container, R.layout.system_shortcut); addDeepShortcutsMaterialU(deepShortcutCount); return; @@ -458,8 +462,12 @@ public class PopupContainerWithArrow return; } mSystemShortcutContainer = inflateAndAdd(systemShortcutContainerLayout, this); - for (SystemShortcut shortcut : systemShortcuts) { - initializeSystemShortcut(systemShortcutLayout, mSystemShortcutContainer, shortcut); + for (int i = 0; i < systemShortcuts.size(); i++) { + initializeSystemShortcut( + systemShortcutLayout, + mSystemShortcutContainer, + systemShortcuts.get(i), + i < systemShortcuts.size() - 1); } } @@ -533,20 +541,31 @@ public class PopupContainerWithArrow } protected void initializeWidgetShortcut(ViewGroup container, SystemShortcut info) { - View view = initializeSystemShortcut(R.layout.system_shortcut, container, info); + View view = initializeSystemShortcut(R.layout.system_shortcut, container, info, false); view.getLayoutParams().width = mContainerWidth; } - protected View initializeSystemShortcut(int resId, ViewGroup container, SystemShortcut info) { - View view = inflateAndAdd( - resId, container, getInsertIndexForSystemShortcut(container, info)); + /** + * Initializes and adds View for given SystemShortcut to a container. + * @param resId Resource id to use for SystemShortcut View. + * @param container ViewGroup to add the shortcut View to as a parent + * @param info The SystemShortcut instance to create a View for. + * @param shouldAddSpacer If True, will add a spacer after the shortcut, when showing the + * SystemShortcut as an icon only. Used to space the shortcut icons + * evenly. + * @return The view inflated for the SystemShortcut + */ + protected View initializeSystemShortcut(int resId, ViewGroup container, SystemShortcut info, + boolean shouldAddSpacer) { + View view = inflateAndAdd(resId, container); if (view instanceof DeepShortcutView) { - // Expanded system shortcut, with both icon and text shown on white background. + // System shortcut takes entire row with icon and text final DeepShortcutView shortcutView = (DeepShortcutView) view; info.setIconAndLabelFor(shortcutView.getIconView(), shortcutView.getBubbleText()); } else if (view instanceof ImageView) { - // Only the system shortcut icon shows on a gray background header. + // System shortcut is just an icon info.setIconAndContentDescriptionFor((ImageView) view); + if (shouldAddSpacer) inflateAndAdd(R.layout.system_shortcut_spacer, container); view.setTooltipText(view.getContentDescription()); } view.setTag(info); @@ -554,17 +573,6 @@ public class PopupContainerWithArrow return view; } - /** - * Returns an index for inserting a shortcut into a container. - */ - private int getInsertIndexForSystemShortcut(ViewGroup container, SystemShortcut shortcut) { - final View separator = container.findViewById(R.id.separator); - - return separator != null && shortcut.isLeftGroup() ? - container.indexOfChild(separator) : - container.getChildCount(); - } - /** * Determines when the deferred drag should be started. *