Merge "Fixes several Visual issues with the app shortcut popup" into tm-qpr-dev am: 3b072b9a07 am: 04d2397c43 am: d6ada70040

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/21559561

Change-Id: I194529c8bcdce7c429f4c79f834b68ab8560a3f3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Charlie Anderson
2023-03-08 15:46:44 +00:00
committed by Automerger Merge Worker
8 changed files with 90 additions and 109 deletions
@@ -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.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_TAP;
import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID; 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.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.ALL_APPS_PAGE_PROGRESS_INDEX;
import static com.android.launcher3.taskbar.LauncherTaskbarUIController.MINUS_ONE_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; 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.FileDescriptor;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.function.Predicate; import java.util.function.Predicate;
@@ -385,22 +390,30 @@ public class QuickstepLauncher extends Launcher {
@Override @Override
public Stream<SystemShortcut.Factory> getSupportedShortcuts() { public Stream<SystemShortcut.Factory> getSupportedShortcuts() {
Stream<SystemShortcut.Factory> base = Stream.of(WellbeingModel.SHORTCUT_FACTORY); // Order matters as it affects order of appearance in popup container
if (ENABLE_SPLIT_FROM_WORKSPACE.get() && mDeviceProfile.isTablet) { List<SystemShortcut.Factory> shortcuts = new ArrayList(Arrays.asList(
RecentsView recentsView = getOverviewPanel(); APP_INFO, WellbeingModel.SHORTCUT_FACTORY, mHotseatPredictionController));
// TODO(b/266482558): Pull it out of PagedOrentationHandler for split from workspace. shortcuts.addAll(getSplitShortcuts());
List<SplitPositionOption> positions = shortcuts.add(WIDGETS);
recentsView.getPagedOrientationHandler().getSplitPositionOptions( shortcuts.add(INSTALL);
mDeviceProfile); return shortcuts.stream();
List<SystemShortcut.Factory<QuickstepLauncher>> splitShortcuts = new ArrayList<>(); }
for (SplitPositionOption position : positions) {
splitShortcuts.add(getSplitSelectShortcutByPosition(position)); private List<SystemShortcut.Factory<QuickstepLauncher>> getSplitShortcuts() {
}
base = Stream.concat(base, splitShortcuts.stream()); if (!ENABLE_SPLIT_FROM_WORKSPACE.get() || !mDeviceProfile.isTablet) {
return Collections.emptyList();
} }
return Stream.concat( RecentsView recentsView = getOverviewPanel();
Stream.of(mHotseatPredictionController), // TODO(b/266482558): Pull it out of PagedOrentationHandler for split from workspace.
Stream.concat(base, super.getSupportedShortcuts())); List<SplitPositionOption> positions =
recentsView.getPagedOrientationHandler().getSplitPositionOptions(
mDeviceProfile);
List<SystemShortcut.Factory<QuickstepLauncher>> splitShortcuts = new ArrayList<>();
for (SplitPositionOption position : positions) {
splitShortcuts.add(getSplitSelectShortcutByPosition(position));
}
return splitShortcuts;
} }
/** /**
+5 -5
View File
@@ -1,9 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp" android:width="24dp"
android:height="16dp" android:height="24dp"
android:viewportWidth="20" android:viewportWidth="24"
android:viewportHeight="16"> android:viewportHeight="24">
<path <path
android:pathData="M18,14L13,14L13,2L18,2L18,14ZM20,14L20,2C20,0.9 19.1,-0 18,-0L13,-0C11.9,-0 11,0.9 11,2L11,14C11,15.1 11.9,16 13,16L18,16C19.1,16 20,15.1 20,14ZM7,14L2,14L2,2L7,2L7,14ZM9,14L9,2C9,0.9 8.1,-0 7,-0L2,-0C0.9,-0 -0,0.9 -0,2L-0,14C-0,15.1 0.9,16 2,16L7,16C8.1,16 9,15.1 9,14Z" android:pathData="M4,6L9,6L9,18L4,18L4,6ZM2,6L2,18C2,19.1 2.9,20 4,20L9,20C10.1,20 11,19.1 11,18L11,6C11,4.9 10.1,4 9,4L4,4C2.9,4 2,4.9 2,6ZM15,6L20,6L20,18L15,18L15,6ZM13,6L13,18C13,19.1 13.9,20 15,20L20,20C21.1,20 22,19.1 22,18L22,6C22,4.9 21.1,4 20,4L15,4C13.9,4 13,4.9 13,6Z"
android:fillColor="#000000"/> android:fillColor="#000000"/>
</vector> </vector>
@@ -22,11 +22,4 @@
android:orientation="horizontal" android:orientation="horizontal"
android:gravity="end|center_vertical" android:gravity="end|center_vertical"
android:background="@drawable/single_item_primary" android:background="@drawable/single_item_primary"
android:elevation="@dimen/deep_shortcuts_elevation" android:elevation="@dimen/deep_shortcuts_elevation"/>
android:clipToPadding="true">
<Space android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/separator"/>
</LinearLayout>
@@ -23,10 +23,4 @@
android:orientation="horizontal" android:orientation="horizontal"
android:gravity="end|center_vertical" android:gravity="end|center_vertical"
android:background="@drawable/popup_background_material_u" android:background="@drawable/popup_background_material_u"
android:elevation="@dimen/deep_shortcuts_elevation"> android:elevation="@dimen/deep_shortcuts_elevation"/>
<Space android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/separator"/>
</LinearLayout>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Space
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/shortcut_spacer"/>
@@ -60,9 +60,7 @@ import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ActivityContext; import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.BaseDragLayer; import com.android.launcher3.views.BaseDragLayer;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
/** /**
* A container for shortcuts to deep links and notifications associated with an app. * A container for shortcuts to deep links and notifications associated with an app.
@@ -336,23 +334,6 @@ public abstract class ArrowPopup<T extends Context & ActivityContext>
} }
} }
/**
* 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. * Shows the popup at the desired location.
*/ */
@@ -372,22 +353,6 @@ public abstract class ArrowPopup<T extends Context & ActivityContext>
orientAboutObject(); orientAboutObject();
} }
private void reverseOrder(int viewsToFlip) {
int count = getChildCount();
ArrayList<View> 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() { private int getArrowLeft() {
if (mIsLeftAligned) { if (mIsLeftAligned) {
return mArrowOffsetHorizontal; return mArrowOffsetHorizontal;
@@ -257,14 +257,19 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext>
} }
// If there is only 1 shortcut, add it to its own container so it can show text and icon // If there is only 1 shortcut, add it to its own container so it can show text and icon
if (shortcuts.size() == 1) { 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; return;
} }
mSystemShortcutContainer = inflateAndAdd(R.layout.system_shortcut_icons_container, this); mSystemShortcutContainer = inflateAndAdd(R.layout.system_shortcut_icons_container, this, 0);
for (SystemShortcut shortcut : shortcuts) { for (int i = 0; i < shortcuts.size(); i++) {
initializeSystemShortcut( initializeSystemShortcut(
R.layout.system_shortcut_icon_only, mSystemShortcutContainer, R.layout.system_shortcut_icon_only,
shortcut); mSystemShortcutContainer,
shortcuts.get(i),
i < shortcuts.size() - 1);
} }
} }
@@ -289,7 +294,6 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext>
} }
updateNotificationHeader(); updateNotificationHeader();
} }
int viewsToFlip = getChildCount();
mSystemShortcutContainer = this; mSystemShortcutContainer = this;
if (mDeepShortcutContainer == null) { if (mDeepShortcutContainer == null) {
mDeepShortcutContainer = findViewById(R.id.deep_shortcuts_container); mDeepShortcutContainer = findViewById(R.id.deep_shortcuts_container);
@@ -314,8 +318,7 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext>
Optional<SystemShortcut.Widgets> widgetShortcutOpt = getWidgetShortcut(shortcuts); Optional<SystemShortcut.Widgets> widgetShortcutOpt = getWidgetShortcut(shortcuts);
if (widgetShortcutOpt.isPresent()) { if (widgetShortcutOpt.isPresent()) {
if (mWidgetContainer == null) { if (mWidgetContainer == null) {
mWidgetContainer = inflateAndAdd(R.layout.widget_shortcut_container, mWidgetContainer = inflateAndAdd(R.layout.widget_shortcut_container, this, 0);
this);
} }
initializeWidgetShortcut(mWidgetContainer, widgetShortcutOpt.get()); initializeWidgetShortcut(mWidgetContainer, widgetShortcutOpt.get());
} }
@@ -324,14 +327,17 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext>
} else { } else {
mDeepShortcutContainer.setVisibility(View.GONE); mDeepShortcutContainer.setVisibility(View.GONE);
if (!shortcuts.isEmpty()) { if (!shortcuts.isEmpty()) {
for (SystemShortcut shortcut : shortcuts) { for (int i = 0; i < shortcuts.size(); i++) {
initializeSystemShortcut(R.layout.system_shortcut, this, shortcut); initializeSystemShortcut(
R.layout.system_shortcut,
this,
shortcuts.get(i),
i < shortcuts.size() - 1);
} }
} }
} }
show();
reorderAndShow(viewsToFlip); loadAppShortcuts((ItemInfo) originalIcon.getTag(), notificationKeys);
showPopupContainer((ItemInfo) originalIcon.getTag(), notificationKeys);
} }
/** /**
@@ -351,19 +357,17 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext>
addAllShortcutsMaterialU(deepShortcutCount, systemShortcuts); addAllShortcutsMaterialU(deepShortcutCount, systemShortcuts);
} else if (!systemShortcuts.isEmpty()) { } else if (!systemShortcuts.isEmpty()) {
addSystemShortcutsMaterialU(systemShortcuts, addSystemShortcutsMaterialU(systemShortcuts,
R.layout.system_shortcut_rows_container_material_u, R.layout.system_shortcut_rows_container,
R.layout.system_shortcut); R.layout.system_shortcut);
} }
show();
// no reversing needed for U design loadAppShortcuts((ItemInfo) originalIcon.getTag(), /* notificationKeys= */ emptyList());
reorderAndShow(0);
showPopupContainer((ItemInfo) originalIcon.getTag(), /* notificationKeys= */ emptyList());
} }
/** /**
* Animates and loads shortcuts on background thread for this popup container * Animates and loads shortcuts on background thread for this popup container
*/ */
private void showPopupContainer(ItemInfo originalItemInfo, private void loadAppShortcuts(ItemInfo originalItemInfo,
List<NotificationKeyData> notificationKeys) { List<NotificationKeyData> notificationKeys) {
if (ATLEAST_P) { if (ATLEAST_P) {
@@ -390,7 +394,7 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext>
if (deepShortcutCount + systemShortcuts.size() <= SHORTCUT_COLLAPSE_THRESHOLD) { if (deepShortcutCount + systemShortcuts.size() <= SHORTCUT_COLLAPSE_THRESHOLD) {
// add all system shortcuts including widgets shortcut to same container // add all system shortcuts including widgets shortcut to same container
addSystemShortcutsMaterialU(systemShortcuts, addSystemShortcutsMaterialU(systemShortcuts,
R.layout.system_shortcut_rows_container_material_u, R.layout.system_shortcut_rows_container,
R.layout.system_shortcut); R.layout.system_shortcut);
addDeepShortcutsMaterialU(deepShortcutCount); addDeepShortcutsMaterialU(deepShortcutCount);
return; return;
@@ -458,8 +462,12 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext>
return; return;
} }
mSystemShortcutContainer = inflateAndAdd(systemShortcutContainerLayout, this); mSystemShortcutContainer = inflateAndAdd(systemShortcutContainerLayout, this);
for (SystemShortcut shortcut : systemShortcuts) { for (int i = 0; i < systemShortcuts.size(); i++) {
initializeSystemShortcut(systemShortcutLayout, mSystemShortcutContainer, shortcut); initializeSystemShortcut(
systemShortcutLayout,
mSystemShortcutContainer,
systemShortcuts.get(i),
i < systemShortcuts.size() - 1);
} }
} }
@@ -533,20 +541,31 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext>
} }
protected void initializeWidgetShortcut(ViewGroup container, SystemShortcut info) { 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; view.getLayoutParams().width = mContainerWidth;
} }
protected View initializeSystemShortcut(int resId, ViewGroup container, SystemShortcut info) { /**
View view = inflateAndAdd( * Initializes and adds View for given SystemShortcut to a container.
resId, container, getInsertIndexForSystemShortcut(container, info)); * @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) { 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; final DeepShortcutView shortcutView = (DeepShortcutView) view;
info.setIconAndLabelFor(shortcutView.getIconView(), shortcutView.getBubbleText()); info.setIconAndLabelFor(shortcutView.getIconView(), shortcutView.getBubbleText());
} else if (view instanceof ImageView) { } 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); info.setIconAndContentDescriptionFor((ImageView) view);
if (shouldAddSpacer) inflateAndAdd(R.layout.system_shortcut_spacer, container);
view.setTooltipText(view.getContentDescription()); view.setTooltipText(view.getContentDescription());
} }
view.setTag(info); view.setTag(info);
@@ -554,17 +573,6 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext>
return view; 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. * Determines when the deferred drag should be started.
* *