diff options
author | Charlie Anderson <charlander@google.com> | 2023-03-15 22:20:10 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-03-15 22:20:10 +0000 |
commit | 787cd87ec82634575f9c4f4add3cd28d06549198 (patch) | |
tree | a7a24209f10cdda5a28d26e95f9582c848f941e3 /src/com/android/launcher3/popup | |
parent | c0d8b2dc0bb51a849326594de34cad3eb9ede741 (diff) | |
parent | d52925f9c404b49abbb9e05a319a705941a74d73 (diff) | |
download | Launcher3-787cd87ec82634575f9c4f4add3cd28d06549198.tar.gz |
Merge "polish for the app shortcut popup, fixing padding on several elements." into tm-qpr-dev am: da4e07812a am: d52925f9c4
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/21791366
Change-Id: I615cd997eb02a7c6b3e43db556ed64ead68b402d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'src/com/android/launcher3/popup')
-rw-r--r-- | src/com/android/launcher3/popup/PopupContainerWithArrow.java | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java index 43ca2a6efb..a7265a7a60 100644 --- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java +++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java @@ -264,14 +264,7 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext> shortcuts.get(0), false); return; } - 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, - shortcuts.get(i), - i < shortcuts.size() - 1); - } + addSystemShortcutsIconsOnly(shortcuts); } @TargetApi(Build.VERSION_CODES.P) @@ -404,9 +397,7 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext> List<SystemShortcut> nonWidgetSystemShortcuts = getNonWidgetSystemShortcuts(systemShortcuts); // If total shortcuts over threshold, collapse system shortcuts to single row - addSystemShortcutsMaterialU(nonWidgetSystemShortcuts, - R.layout.system_shortcut_icons_container_material_u, - R.layout.system_shortcut_icon_only); + addSystemShortcutsIconsOnly(nonWidgetSystemShortcuts); // May need to recalculate row width mContainerWidth = Math.max(mContainerWidth, nonWidgetSystemShortcuts.size() * getResources() @@ -473,6 +464,33 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext> } } + private void addSystemShortcutsIconsOnly(List<SystemShortcut> systemShortcuts) { + if (systemShortcuts.size() == 0) { + return; + } + + mSystemShortcutContainer = ENABLE_MATERIAL_U_POPUP.get() + ? inflateAndAdd(R.layout.system_shortcut_icons_container_material_u, this) + : inflateAndAdd(R.layout.system_shortcut_icons_container, this, 0); + + for (int i = 0; i < systemShortcuts.size(); i++) { + @LayoutRes int shortcutIconLayout = R.layout.system_shortcut_icon_only; + boolean shouldAppendSpacer = true; + + if (i == 0) { + shortcutIconLayout = R.layout.system_shortcut_icon_only_start; + } else if (i == systemShortcuts.size() - 1) { + shortcutIconLayout = R.layout.system_shortcut_icon_only_end; + shouldAppendSpacer = false; + } + initializeSystemShortcut( + shortcutIconLayout, + mSystemShortcutContainer, + systemShortcuts.get(i), + shouldAppendSpacer); + } + } + /** * Inflates and adds [deepShortcutCount] number of DeepShortcutView for the to a new container * @param deepShortcutCount number of DeepShortcutView instances to add @@ -552,13 +570,13 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext> * @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 + * @param shouldAppendSpacer 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) { + boolean shouldAppendSpacer) { View view = inflateAndAdd(resId, container); if (view instanceof DeepShortcutView) { // System shortcut takes entire row with icon and text @@ -567,7 +585,7 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext> } else if (view instanceof ImageView) { // System shortcut is just an icon info.setIconAndContentDescriptionFor((ImageView) view); - if (shouldAddSpacer) inflateAndAdd(R.layout.system_shortcut_spacer, container); + if (shouldAppendSpacer) inflateAndAdd(R.layout.system_shortcut_spacer, container); view.setTooltipText(view.getContentDescription()); } view.setTag(info); |