From 80dda30f49672f18140fe421b2fcbd1d36a6f558 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Wed, 28 Jul 2021 14:14:59 -0700 Subject: [PATCH 01/12] Add more restrictions on whether we increase the hotseat size for tall devices. Bug: 194688362 Test: test devices that should not be affected, ensure they are not affected Change-Id: I0e027354dbafcce30cf616998d2a7bfab516b5de --- src/com/android/launcher3/DeviceProfile.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 9ca753dd92..59962dd795 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -91,6 +91,8 @@ public class DeviceProfile { private static final float TALL_DEVICE_ASPECT_RATIO_THRESHOLD = 2.0f; private static final float TALLER_DEVICE_ASPECT_RATIO_THRESHOLD = 2.15f; + private static final float TALL_DEVICE_EXTRA_SPACE_THRESHOLD_DP = 252; + private static final float TALL_DEVICE_MORE_EXTRA_SPACE_THRESHOLD_DP = 268; // To evenly space the icons, increase the left/right margins for tablets in portrait mode. private static final int PORTRAIT_TABLET_LEFT_RIGHT_PADDING_MULTIPLIER = 4; @@ -377,11 +379,17 @@ public class DeviceProfile { } else if (!isVerticalBarLayout() && isPhone && isTallDevice) { // We increase the hotseat size when there is extra space. - if (Float.compare(aspectRatio, TALLER_DEVICE_ASPECT_RATIO_THRESHOLD) >= 0) { - // For taller devices, we will take a third of the extra space from each row, + if (Float.compare(aspectRatio, TALLER_DEVICE_ASPECT_RATIO_THRESHOLD) >= 0 + && extraSpace >= Utilities.dpToPx(TALL_DEVICE_EXTRA_SPACE_THRESHOLD_DP)) { + // For taller devices, we will take a piece of the extra space from each row, // and add it to the space above and below the hotseat. + + // For devices with more extra space, we take a larger piece from each cell. + int piece = extraSpace < Utilities.dpToPx(TALL_DEVICE_MORE_EXTRA_SPACE_THRESHOLD_DP) + ? 5 : 3; + int extraSpace = ((getCellSize().y - iconSizePx - iconDrawablePaddingPx * 2) - * inv.numRows) / 3; + * inv.numRows) / piece; int halfExtraSpace = extraSpace / 2; hotseatBarTopPaddingPx += halfExtraSpace; From 455718e8422707c021445205da3b194094fae411 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Wed, 28 Jul 2021 17:23:20 +0100 Subject: [PATCH 02/12] Always treat FallbackRecentsView as visible if isInLiveTileMode is true - activity.hasBeenResumed is no longer an accurate indicator after live tile has been introduced, indeed it's always false - Return recentsView regardless if there is a runningTask as well Bug: 194286330 Test: In fallback Recents with 3 button, tap overview button from home screen, then tap overview button again. Try combination with back and home button Change-Id: Ib2775a11f5466abc433763f24192e7bfdcf191a2 --- .../com/android/quickstep/FallbackActivityInterface.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/quickstep/FallbackActivityInterface.java b/quickstep/src/com/android/quickstep/FallbackActivityInterface.java index f29d68a72a..7fb8e16063 100644 --- a/quickstep/src/com/android/quickstep/FallbackActivityInterface.java +++ b/quickstep/src/com/android/quickstep/FallbackActivityInterface.java @@ -107,10 +107,9 @@ public final class FallbackActivityInterface extends public RecentsView getVisibleRecentsView() { RecentsActivity activity = getCreatedActivity(); if (activity != null) { - RecentsView recentsView = activity.getOverviewPanel(); - if (activity.hasBeenResumed() || (ENABLE_QUICKSTEP_LIVE_TILE.get() && isInLiveTileMode() - && recentsView.getRunningTaskId() == -1)) { - return recentsView; + if (activity.hasBeenResumed() + || (ENABLE_QUICKSTEP_LIVE_TILE.get() && isInLiveTileMode())) { + return activity.getOverviewPanel(); } } return null; From 684231560565d8477abc259e5fe222fe92c72592 Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Wed, 28 Jul 2021 22:02:18 -0700 Subject: [PATCH 03/12] Clear command queue of OverviewCommandHelper on home tap Fixes: 194934483 Test: manual Change-Id: Id83b341245793c38c305e6ada5581ac4e49527a7 Merged-In: Id83b341245793c38c305e6ada5581ac4e49527a7 --- .../android/launcher3/BaseQuickstepLauncher.java | 13 +++++++++++++ .../android/quickstep/OverviewCommandHelper.java | 5 +++++ .../android/quickstep/TouchInteractionService.java | 4 ++++ 3 files changed, 22 insertions(+) diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java index 32e2f1ad10..a44de793a3 100644 --- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java @@ -58,6 +58,7 @@ import com.android.launcher3.uioverrides.RecentsViewStateController; import com.android.launcher3.util.ActivityOptionsWrapper; import com.android.launcher3.util.ObjectWrapper; import com.android.launcher3.util.UiThreadHelper; +import com.android.quickstep.OverviewCommandHelper; import com.android.quickstep.RecentsModel; import com.android.quickstep.SysUINavigationMode; import com.android.quickstep.SysUINavigationMode.Mode; @@ -98,12 +99,15 @@ public abstract class BaseQuickstepLauncher extends Launcher private OverviewActionsView mActionsView; private @Nullable TaskbarManager mTaskbarManager; + private @Nullable OverviewCommandHelper mOverviewCommandHelper; private @Nullable LauncherTaskbarUIController mTaskbarUIController; private final ServiceConnection mTisBinderConnection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName componentName, IBinder iBinder) { mTaskbarManager = ((TISBinder) iBinder).getTaskbarManager(); mTaskbarManager.setLauncher(BaseQuickstepLauncher.this); + + mOverviewCommandHelper = ((TISBinder) iBinder).getOverviewCommandHelper(); } @Override @@ -136,6 +140,15 @@ public abstract class BaseQuickstepLauncher extends Launcher super.onDestroy(); } + @Override + protected void onNewIntent(Intent intent) { + super.onNewIntent(intent); + + if (mOverviewCommandHelper != null) { + mOverviewCommandHelper.clearPendingCommands(); + } + } + public QuickstepTransitionManager getAppTransitionManager() { return mAppTransitionManager; } diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java index 89c2ed8ed1..5d1f90885a 100644 --- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java +++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java @@ -109,6 +109,11 @@ public class OverviewCommandHelper { MAIN_EXECUTOR.execute(() -> addCommand(cmd)); } + @UiThread + public void clearPendingCommands() { + mPendingCommands.clear(); + } + private TaskView getNextTask(RecentsView view) { final TaskView runningTaskView = view.getRunningTaskView(); diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index b6dc833967..db5c93c503 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -277,6 +277,10 @@ public class TouchInteractionService extends Service implements PluginListener Date: Thu, 29 Jul 2021 12:59:27 -0700 Subject: [PATCH 04/12] Fixing hotseat hidden in 3P Launcher Bug: 193539246 Test: Manual Change-Id: I3e756457710f2a3909623c7eeec457319eb6c3b8 --- src/com/android/launcher3/DeviceProfile.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index b591dcd67e..9b9c77ece9 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -254,7 +254,8 @@ public class DeviceProfile { final Resources res = context.getResources(); hotseatQsbHeight = res.getDimensionPixelSize(R.dimen.qsb_widget_height); - isTaskbarPresent = isTablet && FeatureFlags.ENABLE_TASKBAR.get(); + isTaskbarPresent = isTablet && ApiWrapper.TASKBAR_DRAWN_IN_PROCESS + && FeatureFlags.ENABLE_TASKBAR.get(); if (isTaskbarPresent) { // Taskbar will be added later, but provides bottom insets that we should subtract // from availableHeightPx. From 7e91244a1ba0c8e914074d61a46b6fb92799f5ae Mon Sep 17 00:00:00 2001 From: Andras Kloczl Date: Thu, 6 May 2021 12:50:28 +0200 Subject: [PATCH 05/12] Fix controller navigation on two panel launcher home Test: manual test with a game controller, check on both normal and two panel home Bug: 187205980 Change-Id: I2515e476556098acf407c0bdcd634e3dd1cb308c --- src/com/android/launcher3/PagedView.java | 135 +++++++++++++-------- src/com/android/launcher3/util/IntSet.java | 9 ++ 2 files changed, 91 insertions(+), 53 deletions(-) diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index 3f7a3ad852..242e3e3743 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -238,10 +238,6 @@ public abstract class PagedView extends ViewGrou return getChildAt(index); } - protected int indexToPage(int index) { - return index; - } - /** * Updates the scroll of the current page immediately to its final scroll position. We use this * in CustomizePagedView to allow tabs to share the same PagedView while resetting the scroll of @@ -322,18 +318,56 @@ public abstract class PagedView extends ViewGrou */ @VisibleForTesting(otherwise = PACKAGE_PRIVATE) public IntSet getVisiblePageIndices() { - IntSet visiblePageIndices = new IntSet(); + return getPageIndices(mCurrentPage); + } + + /** + * In case the panelCount is 1 this just returns the same page index in an IntSet. + * But in cases where the panelCount > 1 this will return all the page indices that belong + * together, i.e. on the Workspace they are next to each other and shown at the same time. + */ + private IntSet getPageIndices(int pageIndex) { + // we want to make sure the pageIndex is the leftmost page + pageIndex = getLeftmostVisiblePageForIndex(pageIndex); + + IntSet pageIndices = new IntSet(); int panelCount = getPanelCount(); int pageCount = getPageCount(); - - // If a device goes from one panel to two panel (i.e. unfolding a foldable device) while - // an odd indexed page is the current page, then the new leftmost visible page will be - // different from the old mCurrentPage. - int currentPage = getLeftmostVisiblePageForIndex(mCurrentPage); - for (int page = currentPage; page < currentPage + panelCount && page < pageCount; page++) { - visiblePageIndices.add(page); + for (int page = pageIndex; page < pageIndex + panelCount && page < pageCount; page++) { + pageIndices.add(page); } - return visiblePageIndices; + return pageIndices; + } + + /** + * Returns an IntSet with the indices of the neighbour pages that are in the focus direction. + */ + private IntSet getNeighbourPageIndices(int focus) { + int panelCount = getPanelCount(); + // getNextPage is more reliable than getCurrentPage + int currentPage = getNextPage(); + + int nextPage; + if (focus == View.FOCUS_LEFT) { + nextPage = currentPage - panelCount; + } else if (focus == View.FOCUS_RIGHT) { + nextPage = currentPage + panelCount; + } else { + // no neighbours to those direction + return new IntSet(); + } + nextPage = validateNewPage(nextPage); + if (nextPage == currentPage) { + // We reached the end of the pages + return new IntSet(); + } + + int pageCount = getPageCount(); + IntSet neighbourIndices = new IntSet(); + for (int page = nextPage; page < nextPage + panelCount && page < pageCount; page++) { + neighbourIndices.add(page); + } + return neighbourIndices; } /** @@ -352,7 +386,14 @@ public abstract class PagedView extends ViewGrou * Returns true if the view is on one of the current pages, false otherwise. */ public boolean isVisible(View child) { - return getLeftmostVisiblePageForIndex(indexOfChild(child)) == mCurrentPage; + return isVisible(indexOfChild(child)); + } + + /** + * Returns true if the page with the given index is currently visible, false otherwise. + */ + private boolean isVisible(int pageIndex) { + return getLeftmostVisiblePageForIndex(pageIndex) == mCurrentPage; } /** @@ -817,8 +858,8 @@ public abstract class PagedView extends ViewGrou @Override public boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate) { - int page = indexToPage(indexOfChild(child)); - if (page != mCurrentPage || !mScroller.isFinished()) { + int page = indexOfChild(child); + if (!isVisible(page) || !mScroller.isFinished()) { if (immediate) { setCurrentPage(page); } else { @@ -857,21 +898,25 @@ public abstract class PagedView extends ViewGrou direction = View.FOCUS_LEFT; } } - if (direction == View.FOCUS_LEFT) { - if (getCurrentPage() > 0) { - int nextPage = validateNewPage(getCurrentPage() - 1); - snapToPage(nextPage); - getChildAt(nextPage).requestFocus(direction); - return true; - } - } else if (direction == View.FOCUS_RIGHT) { - if (getCurrentPage() < getPageCount() - 1) { - int nextPage = validateNewPage(getCurrentPage() + 1); - snapToPage(nextPage); - getChildAt(nextPage).requestFocus(direction); - return true; + + int currentPage = getNextPage(); + int closestNeighbourIndex = -1; + int closestNeighbourDistance = Integer.MAX_VALUE; + // Find the closest neighbour page + for (int neighbourPageIndex : getNeighbourPageIndices(direction)) { + int distance = Math.abs(neighbourPageIndex - currentPage); + if (closestNeighbourDistance > distance) { + closestNeighbourDistance = distance; + closestNeighbourIndex = neighbourPageIndex; } } + if (closestNeighbourIndex != -1) { + View page = getPageAt(closestNeighbourIndex); + snapToPage(closestNeighbourIndex); + page.requestFocus(direction); + return true; + } + return false; } @@ -881,28 +926,12 @@ public abstract class PagedView extends ViewGrou return; } - // Add the current page's views as focusable and the next possible page's too. If the - // last focus change action was left then the left neighbour's views will be added, and - // if it was right then the right neighbour's views will be added. - // Unfortunately mCurrentPage can be outdated if there were multiple control actions in a - // short period of time, but mNextPage is up to date because it is always updated by - // method snapToPage. - int nextPage = getNextPage(); - // XXX-RTL: This will be fixed in a future CL - if (nextPage >= 0 && nextPage < getPageCount()) { - getPageAt(nextPage).addFocusables(views, direction, focusableMode); - } - if (direction == View.FOCUS_LEFT) { - if (nextPage > 0) { - nextPage = validateNewPage(nextPage - 1); - getPageAt(nextPage).addFocusables(views, direction, focusableMode); - } - } else if (direction == View.FOCUS_RIGHT) { - if (nextPage < getPageCount() - 1) { - nextPage = validateNewPage(nextPage + 1); - getPageAt(nextPage).addFocusables(views, direction, focusableMode); - } - } + // nextPage is more reliable when multiple control movements have been done in a short + // period of time + getPageIndices(getNextPage()) + .addAll(getNeighbourPageIndices(direction)) + .forEach(pageIndex -> + getPageAt(pageIndex).addFocusables(views, direction, focusableMode)); } /** @@ -1482,8 +1511,8 @@ public abstract class PagedView extends ViewGrou setCurrentPage(nextPage); } - int page = indexToPage(indexOfChild(child)); - if (page >= 0 && page != getCurrentPage() && !isInTouchMode()) { + int page = indexOfChild(child); + if (page >= 0 && !isVisible(page) && !isInTouchMode()) { snapToPage(page); } } diff --git a/src/com/android/launcher3/util/IntSet.java b/src/com/android/launcher3/util/IntSet.java index e5b4f59cf7..4fd06fe24f 100644 --- a/src/com/android/launcher3/util/IntSet.java +++ b/src/com/android/launcher3/util/IntSet.java @@ -36,6 +36,15 @@ public class IntSet implements Iterable { } } + /** + * Appends the specified IntSet's values to the set if they does not exist, then returns the + * original set that now also contains the new values. + */ + public IntSet addAll(IntSet other) { + other.forEach(this::add); + return this; + } + /** * Removes the specified value from the set if it exist. */ From da8bf1142f5646ef3bc14cc9f1613129b3f4cec6 Mon Sep 17 00:00:00 2001 From: Bill Yi Date: Fri, 30 Jul 2021 04:59:15 +0000 Subject: [PATCH 06/12] Import translations. DO NOT MERGE ANYWHERE Auto-generated-cl: translation import Change-Id: I13dab850677f614cab804cae0b3125c93c55eeed --- res/values-ar/strings.xml | 2 +- res/values-in/strings.xml | 2 +- res/values-ru/strings.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml index b5b8b62450..2b8b9fa454 100644 --- a/res/values-ar/strings.xml +++ b/res/values-ar/strings.xml @@ -122,7 +122,7 @@ "السماح بتدوير الشاشة الرئيسية" "عند تدوير الهاتف" "نقاط الإشعارات" - "مفعّل" + "مفعّلة" "غير مفعّل" "يلزم تمكين الوصول إلى الإشعارات" "لعرض نقاط الإشعارات، يجب تفعيل إشعارات التطبيق في %1$s" diff --git a/res/values-in/strings.xml b/res/values-in/strings.xml index d3558ec2a0..673a4460bf 100644 --- a/res/values-in/strings.xml +++ b/res/values-in/strings.xml @@ -105,7 +105,7 @@ "Folder: %1$s, %2$d item atau lebih" "Wallpaper" "Wallpaper & gaya" - "Setelan layar utama" + "Setelan Layar utama" "Dinonaktifkan oleh admin" "Izinkan Layar utama diputar" "Saat ponsel diputar" diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index 85d7db62d4..241554261d 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -75,7 +75,7 @@ "Список приложений" "Открыть список личных приложений" "Открыть список приложений для работы" - "Убрать" + "Удалить" "Удалить" "О приложении" "Установить" From 942331fd182d74df222b1843a367d6357bf97749 Mon Sep 17 00:00:00 2001 From: Bill Yi Date: Fri, 30 Jul 2021 04:59:54 +0000 Subject: [PATCH 07/12] Import translations. DO NOT MERGE ANYWHERE Auto-generated-cl: translation import Change-Id: Idf735446d5b173d6c9b2718e8225ee1aa86c1579 --- res/values-ar/strings.xml | 2 +- res/values-in/strings.xml | 2 +- res/values-ru/strings.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml index b5b8b62450..2b8b9fa454 100644 --- a/res/values-ar/strings.xml +++ b/res/values-ar/strings.xml @@ -122,7 +122,7 @@ "السماح بتدوير الشاشة الرئيسية" "عند تدوير الهاتف" "نقاط الإشعارات" - "مفعّل" + "مفعّلة" "غير مفعّل" "يلزم تمكين الوصول إلى الإشعارات" "لعرض نقاط الإشعارات، يجب تفعيل إشعارات التطبيق في %1$s" diff --git a/res/values-in/strings.xml b/res/values-in/strings.xml index d3558ec2a0..673a4460bf 100644 --- a/res/values-in/strings.xml +++ b/res/values-in/strings.xml @@ -105,7 +105,7 @@ "Folder: %1$s, %2$d item atau lebih" "Wallpaper" "Wallpaper & gaya" - "Setelan layar utama" + "Setelan Layar utama" "Dinonaktifkan oleh admin" "Izinkan Layar utama diputar" "Saat ponsel diputar" diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index 85d7db62d4..241554261d 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -75,7 +75,7 @@ "Список приложений" "Открыть список личных приложений" "Открыть список приложений для работы" - "Убрать" + "Удалить" "Удалить" "О приложении" "Установить" From fb5ae9060dcb2bc562f915c0f3271aaf1cabc960 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Wed, 28 Jul 2021 17:23:20 +0100 Subject: [PATCH 08/12] Always treat FallbackRecentsView as visible if isInLiveTileMode is true - activity.hasBeenResumed is no longer an accurate indicator after live tile has been introduced, indeed it's always false - Return recentsView regardless if there is a runningTask as well Bug: 194286330 Test: In fallback Recents with 3 button, tap overview button from home screen, then tap overview button again. Try combination with back and home button Change-Id: Ib2775a11f5466abc433763f24192e7bfdcf191a2 (cherry picked from commit 455718e8422707c021445205da3b194094fae411) --- .../com/android/quickstep/FallbackActivityInterface.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/quickstep/FallbackActivityInterface.java b/quickstep/src/com/android/quickstep/FallbackActivityInterface.java index f29d68a72a..7fb8e16063 100644 --- a/quickstep/src/com/android/quickstep/FallbackActivityInterface.java +++ b/quickstep/src/com/android/quickstep/FallbackActivityInterface.java @@ -107,10 +107,9 @@ public final class FallbackActivityInterface extends public RecentsView getVisibleRecentsView() { RecentsActivity activity = getCreatedActivity(); if (activity != null) { - RecentsView recentsView = activity.getOverviewPanel(); - if (activity.hasBeenResumed() || (ENABLE_QUICKSTEP_LIVE_TILE.get() && isInLiveTileMode() - && recentsView.getRunningTaskId() == -1)) { - return recentsView; + if (activity.hasBeenResumed() + || (ENABLE_QUICKSTEP_LIVE_TILE.get() && isInLiveTileMode())) { + return activity.getOverviewPanel(); } } return null; From 2a5c5948552a70bdd60ed5e603a7d249b5d8fc44 Mon Sep 17 00:00:00 2001 From: Steven Ng Date: Thu, 29 Jul 2021 17:27:00 +0100 Subject: [PATCH 09/12] Fix cell size calculation in large screen devices Test: Digital clock widget is no longer cropped. Bug: 184966000, 194784402 Change-Id: I26c406da1e10232019f34620a4d2bc0dbafcbb31 --- res/values/dimens.xml | 3 ++- src/com/android/launcher3/DeviceProfile.java | 16 ++++++++++++---- src/com/android/launcher3/Workspace.java | 8 ++------ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 010d15b92d..838d0ec84f 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -29,7 +29,8 @@ 5.5dp 8dp - 18dp + 36dp + 9dp 8dp diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 740bf5aed8..a2487e4ade 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -302,8 +302,10 @@ public class DeviceProfile { : res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_layout_padding); if (isTwoPanels) { - cellLayoutPaddingLeftRightPx = - res.getDimensionPixelSize(R.dimen.two_panel_home_side_padding); + cellLayoutPaddingLeftRightPx = res.getDimensionPixelSize( + isLandscape + ? R.dimen.two_panels_home_side_padding_landscape + : R.dimen.two_panels_home_side_padding_portrait); cellLayoutBottomPaddingPx = 0; } else if (isLandscape) { cellLayoutPaddingLeftRightPx = 0; @@ -752,8 +754,14 @@ public class DeviceProfile { // Since we are only concerned with the overall padding, layout direction does // not matter. Point padding = getTotalWorkspacePadding(); - result.x = calculateCellWidth(availableWidthPx - padding.x - - cellLayoutPaddingLeftRightPx * 2, cellLayoutBorderSpacingPx, inv.numColumns); + // availableWidthPx is the screen width of the device. In 2 panels mode, each panel should + // only have half of the screen width. In addition, there is only cellLayoutPadding in the + // left side of the left panel and the right side of the right panel. There is no + // cellLayoutPadding in the middle. + int screenWidthPx = isTwoPanels + ? availableWidthPx / 2 - padding.x - cellLayoutPaddingLeftRightPx + : availableWidthPx - padding.x - cellLayoutPaddingLeftRightPx * 2; + result.x = calculateCellWidth(screenWidthPx, cellLayoutBorderSpacingPx, inv.numColumns); result.y = calculateCellHeight(availableHeightPx - padding.y - cellLayoutBottomPaddingPx, cellLayoutBorderSpacingPx, inv.numRows); return result; diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 5200456875..9a8b80d4c5 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -327,8 +327,6 @@ public class Workspace extends PagedView int paddingLeftRight = grid.cellLayoutPaddingLeftRightPx; int paddingBottom = grid.cellLayoutBottomPaddingPx; - int twoPanelLandscapeSidePadding = paddingLeftRight * 2; - int twoPanelPortraitSidePadding = paddingLeftRight / 2; int panelCount = getPanelCount(); for (int i = mWorkspaceScreens.size() - 1; i >= 0; i--) { @@ -336,13 +334,11 @@ public class Workspace extends PagedView int paddingRight = paddingLeftRight; if (panelCount > 1) { if (i % panelCount == 0) { // left side panel - paddingLeft = grid.isLandscape ? twoPanelLandscapeSidePadding - : twoPanelPortraitSidePadding; + paddingLeft = paddingLeftRight; paddingRight = 0; } else if (i % panelCount == panelCount - 1) { // right side panel paddingLeft = 0; - paddingRight = grid.isLandscape ? twoPanelLandscapeSidePadding - : twoPanelPortraitSidePadding; + paddingRight = paddingLeftRight; } else { // middle panel paddingLeft = 0; paddingRight = 0; From 3edfa98ba7be61e17ab896ad53ecaf4204efd873 Mon Sep 17 00:00:00 2001 From: Steven Ng Date: Fri, 30 Jul 2021 13:15:26 +0100 Subject: [PATCH 10/12] Use the right content to estimate the span in WidgetsFullSheet Test: Manual Fix: 194784402 Change-Id: I150f4c7b5a0344caa2bea3f1502894cb0f32e208 --- .../android/launcher3/widget/picker/WidgetsFullSheet.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java index e36ea905bc..be83f9ac13 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java +++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java @@ -402,7 +402,10 @@ public class WidgetsFullSheet extends BaseWidgetSheet private boolean updateMaxSpansPerRow() { if (getMeasuredWidth() == 0) return false; - int maxHorizontalSpans = computeMaxHorizontalSpans(mContent, + View content = mHasWorkProfile + ? mViewPager + : mAdapters.get(AdapterHolder.PRIMARY).mWidgetsRecyclerView; + int maxHorizontalSpans = computeMaxHorizontalSpans(content, mWidgetSheetContentHorizontalPadding); if (mMaxSpansPerRow != maxHorizontalSpans) { mMaxSpansPerRow = maxHorizontalSpans; From 6951aef06038135a9ad26838c2a77f79ddbcb8de Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Fri, 30 Jul 2021 16:24:58 +0100 Subject: [PATCH 11/12] Fix Launcher3 tests for tablets - Consider taskbar size for bottom gesture size, by using TargetInsets - TargetInsets should substract overlapping taskbar size when it's present - For pressHome, use the same gesture scope when context menu is present as well. - For pressHome, GestureScope.INSIDE_TO_OUTSIDE should only be used when it's already at home screen on launcher3 tablet. Bug: 193539246 Test: NexusLauncherTest and Launcher3Test Change-Id: I4a20522f3b38ef326acae4b189df11a125990411 --- .../testing/TestInformationHandler.java | 7 +++++-- .../tapl/LauncherInstrumentation.java | 19 +++++++++++-------- .../com/android/launcher3/tapl/Workspace.java | 4 +--- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java index 944a41f8d2..5106992dc7 100644 --- a/src/com/android/launcher3/testing/TestInformationHandler.java +++ b/src/com/android/launcher3/testing/TestInformationHandler.java @@ -102,8 +102,11 @@ public class TestInformationHandler implements ResourceBasedOverride { return getUIProperty(Bundle::putParcelable, a -> { WindowInsets insets = a.getWindow() .getDecorView().getRootWindowInsets(); - return Insets.max( - insets.getSystemGestureInsets(), insets.getSystemWindowInsets()); + return Insets.subtract( + Insets.max( + insets.getSystemGestureInsets(), + insets.getSystemWindowInsets()), + Insets.of(0, 0, 0, mDeviceProfile.nonOverlappingTaskbarInset)); }, this::getCurrentActivity); } diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 93c921ef08..49934f7e46 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -728,18 +728,23 @@ public final class LauncherInstrumentation { // otherwise waitForIdle may return immediately in case when there was a big enough // pause in accessibility events prior to pressing Home. final String action; - final boolean launcherWasVisible = isLauncherVisible(); if (getNavigationModel() == NavigationModel.ZERO_BUTTON) { checkForAnomaly(); final Point displaySize = getRealDisplaySize(); + boolean gestureStartFromLauncher = isTablet() + ? !isLauncher3() || hasLauncherObject(WORKSPACE_RES_ID) + : isLauncherVisible(); + GestureScope gestureScope = gestureStartFromLauncher + ? GestureScope.INSIDE_TO_OUTSIDE + : GestureScope.OUTSIDE_WITH_PILFER; if (hasLauncherObject(CONTEXT_MENU_RES_ID)) { linearGesture( displaySize.x / 2, displaySize.y - 1, displaySize.x / 2, 0, ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME, - false, GestureScope.INSIDE_TO_OUTSIDE); + false, gestureScope); try (LauncherInstrumentation.Closable c1 = addContextLayer( "Swiped up from context menu to home")) { waitUntilLauncherObjectGone(CONTEXT_MENU_RES_ID); @@ -760,9 +765,7 @@ public final class LauncherInstrumentation { displaySize.x / 2, displaySize.y - 1, displaySize.x / 2, 0, ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME, NORMAL_STATE_ORDINAL, - launcherWasVisible || isTablet() - ? GestureScope.INSIDE_TO_OUTSIDE - : GestureScope.OUTSIDE_WITH_PILFER); + gestureScope); } } else { log("Hierarchy before clicking home:"); @@ -1115,9 +1118,9 @@ public final class LauncherInstrumentation { "swiping"); } - private int getBottomGestureSize() { - return ResourceUtils.getNavbarSize( - ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, getResources()) + 1; + int getBottomGestureSize() { + return Math.max(getTargetInsets().bottom, ResourceUtils.getNavbarSize( + ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, getResources())) + 1; } int getBottomGestureMarginInContainer(UiObject2 container) { diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java index 2acf7b44b9..db2e250bd3 100644 --- a/tests/tapl/com/android/launcher3/tapl/Workspace.java +++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java @@ -34,7 +34,6 @@ import androidx.test.uiautomator.By; import androidx.test.uiautomator.Direction; import androidx.test.uiautomator.UiObject2; -import com.android.launcher3.ResourceUtils; import com.android.launcher3.testing.TestProtocol; import java.util.regex.Pattern; @@ -72,8 +71,7 @@ public final class Workspace extends Home { mLauncher.addContextLayer("want to switch from workspace to all apps")) { verifyActiveContainer(); final int deviceHeight = mLauncher.getDevice().getDisplayHeight(); - final int bottomGestureMargin = ResourceUtils.getNavbarSize( - ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, mLauncher.getResources()); + final int bottomGestureMargin = mLauncher.getBottomGestureSize(); final int windowCornerRadius = (int) Math.ceil(mLauncher.getWindowCornerRadius()); final int startY = deviceHeight - Math.max(bottomGestureMargin, windowCornerRadius) - 1; final int swipeHeight = mLauncher.getTestInfo( From 831212ec9265ce8db0fe348e0bd3c00fcc390670 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Fri, 14 May 2021 14:24:09 -0700 Subject: [PATCH 12/12] Adding support for overriding long-press menu in Launcher Bug: 188222480 Test: Manual Change-Id: Ic0b425fafde8beedc15a5aa42a8897b9143a3309 --- res/layout/system_shortcut.xml | 26 +---------- res/layout/system_shortcut_content.xml | 44 +++++++++++++++++++ src/com/android/launcher3/Launcher.java | 16 ++++++- .../launcher3/config/FeatureFlags.java | 4 ++ .../touch/WorkspaceTouchListener.java | 3 +- .../launcher3/views/OptionsPopupView.java | 10 ----- 6 files changed, 65 insertions(+), 38 deletions(-) create mode 100644 res/layout/system_shortcut_content.xml diff --git a/res/layout/system_shortcut.xml b/res/layout/system_shortcut.xml index de091c51c7..89895e54e4 100644 --- a/res/layout/system_shortcut.xml +++ b/res/layout/system_shortcut.xml @@ -16,36 +16,12 @@ - - - + diff --git a/res/layout/system_shortcut_content.xml b/res/layout/system_shortcut_content.xml new file mode 100644 index 0000000000..8b39202f31 --- /dev/null +++ b/res/layout/system_shortcut_content.xml @@ -0,0 +1,44 @@ + + + + + + + + \ No newline at end of file diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 07c211353f..8249887d9c 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -80,6 +80,7 @@ import android.content.res.Configuration; import android.database.sqlite.SQLiteDatabase; import android.graphics.Bitmap; import android.graphics.Rect; +import android.graphics.RectF; import android.os.Build; import android.os.Bundle; import android.os.CancellationSignal; @@ -2870,13 +2871,26 @@ public class Launcher extends StatefulActivity implements Launche if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { Log.d(TestProtocol.PERMANENT_DIAG_TAG, "Opening options popup on key up"); } - OptionsPopupView.showDefaultOptions(this, -1, -1); + showDefaultOptions(-1, -1); } return true; } return super.onKeyUp(keyCode, event); } + /** + * Shows the default options popup + */ + public void showDefaultOptions(float x, float y) { + float halfSize = getResources().getDimension(R.dimen.options_menu_thumb_size) / 2; + if (x < 0 || y < 0) { + x = mDragLayer.getWidth() / 2; + y = mDragLayer.getHeight() / 2; + } + RectF target = new RectF(x - halfSize, y - halfSize, x + halfSize, y + halfSize); + OptionsPopupView.show(this, target, OptionsPopupView.getOptions(this), false); + } + @Override protected void collectStateHandlers(List out) { out.add(getAllAppsController()); diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 33ee95162a..da701a8cb1 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -255,6 +255,10 @@ public final class FeatureFlags { "WIDGETS_IN_LAUNCHER_PREVIEW", true, "Enables widgets in Launcher preview for the Wallpaper app."); + public static final BooleanFlag QUICK_WALLPAPER_PICKER = getDebugFlag( + "QUICK_WALLPAPER_PICKER", false, + "Shows quick wallpaper picker in long-press menu"); + public static void initialize(Context context) { synchronized (sDebugFlags) { for (DebugFlag flag : sDebugFlags) { diff --git a/src/com/android/launcher3/touch/WorkspaceTouchListener.java b/src/com/android/launcher3/touch/WorkspaceTouchListener.java index 4fa658e7d5..20d2ad36a5 100644 --- a/src/com/android/launcher3/touch/WorkspaceTouchListener.java +++ b/src/com/android/launcher3/touch/WorkspaceTouchListener.java @@ -41,7 +41,6 @@ import com.android.launcher3.Workspace; import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.testing.TestLogging; import com.android.launcher3.testing.TestProtocol; -import com.android.launcher3.views.OptionsPopupView; /** * Helper class to handle touch on empty space in workspace and show options popup on long press @@ -175,7 +174,7 @@ public class WorkspaceTouchListener extends GestureDetector.SimpleOnGestureListe mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); mLauncher.getStatsLogManager().logger().log(LAUNCHER_WORKSPACE_LONGPRESS); - OptionsPopupView.showDefaultOptions(mLauncher, mTouchDownPoint.x, mTouchDownPoint.y); + mLauncher.showDefaultOptions(mTouchDownPoint.x, mTouchDownPoint.y); } else { cancelLongPress(); } diff --git a/src/com/android/launcher3/views/OptionsPopupView.java b/src/com/android/launcher3/views/OptionsPopupView.java index ecdd206224..257b18fcfb 100644 --- a/src/com/android/launcher3/views/OptionsPopupView.java +++ b/src/com/android/launcher3/views/OptionsPopupView.java @@ -176,16 +176,6 @@ public class OptionsPopupView extends ArrowPopup return launcher.findViewById(R.id.popup_container); } - public static void showDefaultOptions(Launcher launcher, float x, float y) { - float halfSize = launcher.getResources().getDimension(R.dimen.options_menu_thumb_size) / 2; - if (x < 0 || y < 0) { - x = launcher.getDragLayer().getWidth() / 2; - y = launcher.getDragLayer().getHeight() / 2; - } - RectF target = new RectF(x - halfSize, y - halfSize, x + halfSize, y + halfSize); - show(launcher, target, getOptions(launcher), false); - } - /** * Returns the list of supported actions */