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;
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/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 @@
"Список приложений"
"Открыть список личных приложений"
"Открыть список приложений для работы"
- "Убрать"
+ "Удалить"
"Удалить"
"О приложении"
"Установить"
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..d2d00c8554 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -94,6 +94,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;
@@ -257,7 +259,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.
@@ -302,8 +305,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;
@@ -407,11 +412,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;
@@ -752,8 +763,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/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/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/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;
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/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/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/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.
*/
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
*/
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;
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(