From 21970ccd290c6d95ba87c8b7c213adc4fdde6ffc Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Wed, 15 Sep 2021 15:44:05 -0700 Subject: [PATCH 1/9] Remove nonOverlappingTaskarInsets - Override our insets in LauncherRootView to explicitly only care about nav bar size, ignoring any insets due to taskbar. - Previously we used nonOverlappingTaskbarInsets to belatedly subtract from measurements in e.g. DeviceProfile, but now we can revert most of those calculations since we effectively subtract taskbar insets at the root. Test: visual in different orientations and navigation modes, and testPressHomeOnAllAppsContextMenu to ensure REQUEST_WINDOW_INSETS still works for automated tests Fixes: 200607741 Change-Id: I8de5a268c686a1354b4beaa30e101bab6bed5af9 --- src/com/android/launcher3/DeviceProfile.java | 27 +++++-------------- .../android/launcher3/LauncherRootView.java | 19 +++---------- src/com/android/launcher3/Workspace.java | 2 -- .../WorkspacePageIndicator.java | 4 +-- .../launcher3/states/SpringLoadedState.java | 3 +-- .../testing/TestInformationHandler.java | 4 +-- 6 files changed, 13 insertions(+), 46 deletions(-) diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 3121bfc9ee..ce8cf3c218 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -33,7 +33,6 @@ import android.graphics.Point; import android.graphics.PointF; import android.graphics.Rect; import android.util.DisplayMetrics; -import android.util.Pair; import android.view.Surface; import com.android.launcher3.CellLayout.ContainerType; @@ -215,8 +214,6 @@ public class DeviceProfile { // Whether Taskbar will inset the bottom of apps by taskbarSize. public boolean isTaskbarPresentInApps; public int taskbarSize; - // How much of the bottom inset is due to Taskbar rather than other system elements. - public int nonOverlappingTaskbarInset; // DragController public int flingToDeleteThresholdVelocity; @@ -239,7 +236,7 @@ public class DeviceProfile { widthPx = windowBounds.bounds.width(); heightPx = windowBounds.bounds.height(); availableWidthPx = windowBounds.availableSize.x; - int nonFinalAvailableHeightPx = windowBounds.availableSize.y; + availableHeightPx = windowBounds.availableSize.y; mInfo = info; // If the device's pixel density was scaled (usually via settings for A11y), use the @@ -266,15 +263,8 @@ public class DeviceProfile { 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. taskbarSize = res.getDimensionPixelSize(R.dimen.taskbar_size); - nonOverlappingTaskbarInset = taskbarSize - windowBounds.insets.bottom; - if (nonOverlappingTaskbarInset > 0) { - nonFinalAvailableHeightPx -= nonOverlappingTaskbarInset; - } } - availableHeightPx = nonFinalAvailableHeightPx; edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin); @@ -842,7 +832,7 @@ public class DeviceProfile { padding.right = hotseatBarSizePx; } } else { - int hotseatTop = isTaskbarPresent ? taskbarSize : hotseatBarSizePx; + int hotseatTop = hotseatBarSizePx; int paddingBottom = hotseatTop + workspacePageIndicatorHeight + workspaceBottomPadding - mWorkspacePageIndicatorOverlapWorkspace; if (isTablet) { @@ -853,8 +843,7 @@ public class DeviceProfile { ((inv.numColumns - 1) * cellWidthPx))); availablePaddingX = (int) Math.min(availablePaddingX, widthPx * MAX_HORIZONTAL_PADDING_PERCENT); - int hotseatVerticalPadding = isTaskbarPresent ? 0 - : hotseatBarTopPaddingPx + hotseatBarBottomPaddingPx; + int hotseatVerticalPadding = hotseatBarTopPaddingPx + hotseatBarBottomPaddingPx; int availablePaddingY = Math.max(0, heightPx - edgeMarginPx - paddingBottom - (2 * inv.numRows * cellHeightPx) - hotseatVerticalPadding); padding.set(availablePaddingX / 2, edgeMarginPx + availablePaddingY / 2, @@ -886,9 +875,9 @@ public class DeviceProfile { mInsets.right + hotseatBarSidePaddingStartPx, mInsets.bottom); } } else if (isTaskbarPresent) { - int hotseatHeight = workspacePadding.bottom + taskbarSize; + int hotseatHeight = workspacePadding.bottom; int taskbarOffset = getTaskbarOffsetY(); - int hotseatTopDiff = hotseatHeight - taskbarSize - taskbarOffset; + int hotseatTopDiff = hotseatHeight - taskbarOffset; int endOffset = ApiWrapper.getHotseatEndOffset(context); int requiredWidth = iconSizePx * numShownHotseatIcons; @@ -938,7 +927,8 @@ public class DeviceProfile { : hotseatBarSizePx - hotseatCellHeightPx - hotseatQsbHeight; if (isScalableGrid && qsbBottomMarginPx > mInsets.bottom) { - return Math.min(qsbBottomMarginPx, freeSpace); + // Note that taskbarSize = 0 unless isTaskbarPresent. + return Math.min(qsbBottomMarginPx + taskbarSize, freeSpace); } else { return (int) (freeSpace * QSB_CENTER_FACTOR) + (isTaskbarPresent ? taskbarSize : mInsets.bottom); @@ -1116,10 +1106,7 @@ public class DeviceProfile { writer.println(prefix + "\tisTaskbarPresent:" + isTaskbarPresent); writer.println(prefix + "\tisTaskbarPresentInApps:" + isTaskbarPresentInApps); - writer.println(prefix + pxToDpStr("taskbarSize", taskbarSize)); - writer.println(prefix + pxToDpStr("nonOverlappingTaskbarInset", - nonOverlappingTaskbarInset)); writer.println(prefix + pxToDpStr("workspacePadding.left", workspacePadding.left)); writer.println(prefix + pxToDpStr("workspacePadding.top", workspacePadding.top)); diff --git a/src/com/android/launcher3/LauncherRootView.java b/src/com/android/launcher3/LauncherRootView.java index 28afc5768b..7de2ee4eed 100644 --- a/src/com/android/launcher3/LauncherRootView.java +++ b/src/com/android/launcher3/LauncherRootView.java @@ -47,15 +47,8 @@ public class LauncherRootView extends InsettableFrameLayout { } private void handleSystemWindowInsets(Rect insets) { - DeviceProfile dp = mActivity.getDeviceProfile(); - - // Taskbar provides insets, but we don't want that for most Launcher elements so remove it. - mTempRect.set(insets); - insets = mTempRect; - insets.bottom = Math.max(0, insets.bottom - dp.nonOverlappingTaskbarInset); - // Update device profile before notifying the children. - dp.updateInsets(insets); + mActivity.getDeviceProfile().updateInsets(insets); boolean resetState = !insets.equals(mInsets); setInsets(insets); @@ -86,10 +79,6 @@ public class LauncherRootView extends InsettableFrameLayout { * get its insets, we calculate them ourselves so they are stable regardless of whether taskbar * is currently attached. * - * TODO(b/198798034): Currently we always calculate nav insets as taskbarSize, but then we - * subtract nonOverlappingTaskbarInset in handleSystemWindowInsets(). Instead, we should just - * calculate the normal nav bar height here, and remove nonOverlappingTaskbarInset altogether. - * * @param oldInsets The system-provided insets, which we are modifying. * @return The updated insets. */ @@ -108,10 +97,8 @@ public class LauncherRootView extends InsettableFrameLayout { Insets oldNavInsets = oldInsets.getInsets(WindowInsets.Type.navigationBars()); Rect newNavInsets = new Rect(oldNavInsets.left, oldNavInsets.top, oldNavInsets.right, oldNavInsets.bottom); - if (dp.isTaskbarPresent) { - // TODO (see javadoc): Remove this block and fall into the next one instead. - newNavInsets.bottom = dp.taskbarSize; - } else if (dp.isLandscape) { + + if (dp.isLandscape) { if (dp.isTablet) { newNavInsets.bottom = ResourceUtils.getNavbarSize( "navigation_bar_height_landscape", resources); diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index bd2a14fd2d..1d62480cd3 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -314,8 +314,6 @@ public class Workspace extends PagedView Rect padding = grid.workspacePadding; setPadding(padding.left, padding.top, padding.right, padding.bottom); mInsets.set(insets); - // Increase our bottom insets so we don't overlap with the taskbar. - mInsets.bottom += grid.nonOverlappingTaskbarInset; if (mWorkspaceFadeInAdjacentScreens) { // In landscape mode the page spacing is set to the default. diff --git a/src/com/android/launcher3/pageindicators/WorkspacePageIndicator.java b/src/com/android/launcher3/pageindicators/WorkspacePageIndicator.java index f73d782685..c685891dac 100644 --- a/src/com/android/launcher3/pageindicators/WorkspacePageIndicator.java +++ b/src/com/android/launcher3/pageindicators/WorkspacePageIndicator.java @@ -268,9 +268,7 @@ public class WorkspacePageIndicator extends View implements Insettable, PageIndi } else { lp.leftMargin = lp.rightMargin = 0; lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM; - lp.bottomMargin = grid.isTaskbarPresent - ? grid.workspacePadding.bottom + grid.taskbarSize - : grid.hotseatBarSizePx + insets.bottom; + lp.bottomMargin = grid.hotseatBarSizePx + insets.bottom; } setLayoutParams(lp); } diff --git a/src/com/android/launcher3/states/SpringLoadedState.java b/src/com/android/launcher3/states/SpringLoadedState.java index 8db1dbe69d..5fe5450a12 100644 --- a/src/com/android/launcher3/states/SpringLoadedState.java +++ b/src/com/android/launcher3/states/SpringLoadedState.java @@ -59,11 +59,10 @@ public class SpringLoadedState extends LauncherState { float scale = grid.workspaceSpringLoadShrinkFactor; Rect insets = launcher.getDragLayer().getInsets(); - int insetsBottom = grid.isTaskbarPresent ? grid.taskbarSize : insets.bottom; float scaledHeight = scale * ws.getNormalChildHeight(); float shrunkTop = insets.top + grid.dropTargetBarSizePx; - float shrunkBottom = ws.getMeasuredHeight() - insetsBottom + float shrunkBottom = ws.getMeasuredHeight() - insets.bottom - grid.workspacePadding.bottom - grid.workspaceSpringLoadedBottomSpace; float totalShrunkSpace = shrunkBottom - shrunkTop; diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java index 86acff718f..5a9c074f96 100644 --- a/src/com/android/launcher3/testing/TestInformationHandler.java +++ b/src/com/android/launcher3/testing/TestInformationHandler.java @@ -116,9 +116,7 @@ public class TestInformationHandler implements ResourceBasedOverride { return getUIProperty(Bundle::putParcelable, activity -> { WindowInsets insets = activity.getWindow() .getDecorView().getRootWindowInsets(); - return Insets.subtract( - insets.getSystemWindowInsets(), - Insets.of(0, 0, 0, mDeviceProfile.nonOverlappingTaskbarInset)); + return insets.getSystemWindowInsets(); }, this::getCurrentActivity); } From 827335f2097d3efc1550d4821733085149fcbd10 Mon Sep 17 00:00:00 2001 From: Vadim Tryshev Date: Wed, 22 Sep 2021 02:57:25 +0000 Subject: [PATCH 2/9] Revert "Removing unused tracing" This reverts commit 1cb868e2f7f30619593a968afe61fc770b6b31b6. Reason for revert: The problem still happens Bug: 195319692 Test: presubmit Change-Id: I468c84af743f04f440b719a561e4e5dd6adbf3b4 --- tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index cd0c7f2240..1a6ce8ccae 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -153,6 +153,8 @@ public abstract class AbstractLauncherUiTest { public static String dumpHprofData() { String result; if (sDumpWasGenerated) { + Log.d("b/195319692", "dump has already been generated by another test", + new Exception()); result = "dump has already been generated by another test"; } else { try { @@ -167,6 +169,7 @@ public abstract class AbstractLauncherUiTest { "am dumpheap " + device.getLauncherPackageName() + " " + fileName); } sDumpWasGenerated = true; + Log.d("b/195319692", "sDumpWasGenerated := true", new Exception()); result = "memory dump filename: " + fileName; } catch (Throwable e) { Log.e(TAG, "dumpHprofData failed", e); From 0e8a2ce0a9024a52f1a0593a884de86e1f5fcd23 Mon Sep 17 00:00:00 2001 From: Steven Ng Date: Mon, 20 Sep 2021 18:23:13 +0100 Subject: [PATCH 3/9] Fix RecyclerViewFastScroller scrolling in widgets full sheet See b/200132426 regarding to the bugs. Test: manually tested full widgets picker scrolling on phone and 2 panels UI. Fix: 200132426 Change-Id: I13c7a7262e9357cf0acac1c2c7c069b2118bd527 --- res/layout/widgets_full_sheet.xml | 2 +- res/layout/widgets_full_sheet_paged_view.xml | 3 ++- res/layout/widgets_full_sheet_recyclerview.xml | 2 +- .../views/RecyclerViewFastScroller.java | 9 +-------- .../widget/picker/WidgetsFullSheet.java | 17 +++++++++++++---- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/res/layout/widgets_full_sheet.xml b/res/layout/widgets_full_sheet.xml index 8afd40bbac..0fc0ff8737 100644 --- a/res/layout/widgets_full_sheet.xml +++ b/res/layout/widgets_full_sheet.xml @@ -67,7 +67,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/collapse_handle" - android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin" + android:paddingHorizontal="@dimen/widget_list_horizontal_margin" android:visibility="gone" android:clipToPadding="false" /> diff --git a/res/layout/widgets_full_sheet_paged_view.xml b/res/layout/widgets_full_sheet_paged_view.xml index 85f14cda4f..dfe226a8bd 100644 --- a/res/layout/widgets_full_sheet_paged_view.xml +++ b/res/layout/widgets_full_sheet_paged_view.xml @@ -20,7 +20,6 @@ android:id="@+id/widgets_view_pager" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin" android:clipToPadding="false" android:layout_below="@id/collapse_handle" android:descendantFocusability="afterDescendants" @@ -30,12 +29,14 @@ android:id="@+id/primary_widgets_list_view" android:layout_width="match_parent" android:layout_height="match_parent" + android:paddingHorizontal="@dimen/widget_list_horizontal_margin" android:clipToPadding="false" /> diff --git a/res/layout/widgets_full_sheet_recyclerview.xml b/res/layout/widgets_full_sheet_recyclerview.xml index dde82eab5f..6a5d6cb416 100644 --- a/res/layout/widgets_full_sheet_recyclerview.xml +++ b/res/layout/widgets_full_sheet_recyclerview.xml @@ -19,7 +19,7 @@ android:layout_below="@id/collapse_handle" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin" + android:paddingHorizontal="@dimen/widget_list_horizontal_margin" android:clipToPadding="false" /> diff --git a/src/com/android/launcher3/views/RecyclerViewFastScroller.java b/src/com/android/launcher3/views/RecyclerViewFastScroller.java index 2b0f707276..a982786972 100644 --- a/src/com/android/launcher3/views/RecyclerViewFastScroller.java +++ b/src/com/android/launcher3/views/RecyclerViewFastScroller.java @@ -113,7 +113,6 @@ public class RecyclerViewFastScroller extends View { private boolean mIsThumbDetached; private final boolean mCanThumbDetach; private boolean mIgnoreDragGesture; - private boolean mIsRecyclerViewFirstChildInParent = true; private long mDownTimeStampMillis; // This is the offset from the top of the scrollbar when the user first starts touching. To @@ -438,9 +437,7 @@ public class RecyclerViewFastScroller extends View { return false; } getHitRect(sTempRect); - if (mIsRecyclerViewFirstChildInParent) { - sTempRect.top += mRv.getScrollBarTop(); - } + sTempRect.top += mRv.getScrollBarTop(); if (outOffset != null) { outOffset.set(sTempRect.left, sTempRect.top); } @@ -453,8 +450,4 @@ public class RecyclerViewFastScroller extends View { // alpha is so low, it does not matter. return false; } - - public void setIsRecyclerViewFirstChildInParent(boolean isRecyclerViewFirstChildInParent) { - mIsRecyclerViewFirstChildInParent = isRecyclerViewFirstChildInParent; - } } diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java index 09f02997c2..9e12f6f541 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java +++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java @@ -198,7 +198,6 @@ public class WidgetsFullSheet extends BaseWidgetSheet .setOnClickListener((View view) -> mViewPager.snapToPage(0)); findViewById(R.id.tab_work) .setOnClickListener((View view) -> mViewPager.snapToPage(1)); - fastScroller.setIsRecyclerViewFirstChildInParent(false); mAdapters.get(AdapterHolder.WORK).setup(findViewById(R.id.work_widgets_list_view)); } else { mViewPager = null; @@ -334,13 +333,18 @@ public class WidgetsFullSheet extends BaseWidgetSheet setContentViewChildHorizontalMargin(mSearchScrollController.mContainer, contentHorizontalMarginInPx); if (mViewPager == null) { - setContentViewChildHorizontalMargin( + setContentViewChildHorizontalPadding( mAdapters.get(AdapterHolder.PRIMARY).mWidgetsRecyclerView, contentHorizontalMarginInPx); } else { - setContentViewChildHorizontalMargin(mViewPager, contentHorizontalMarginInPx); + setContentViewChildHorizontalPadding( + mAdapters.get(AdapterHolder.PRIMARY).mWidgetsRecyclerView, + contentHorizontalMarginInPx); + setContentViewChildHorizontalPadding( + mAdapters.get(AdapterHolder.WORK).mWidgetsRecyclerView, + contentHorizontalMarginInPx); } - setContentViewChildHorizontalMargin( + setContentViewChildHorizontalPadding( mAdapters.get(AdapterHolder.SEARCH).mWidgetsRecyclerView, contentHorizontalMarginInPx); } @@ -352,6 +356,11 @@ public class WidgetsFullSheet extends BaseWidgetSheet layoutParams.setMarginEnd(horizontalMarginInPx); } + private static void setContentViewChildHorizontalPadding(View view, int horizontalPaddingInPx) { + view.setPadding(horizontalPaddingInPx, view.getPaddingTop(), horizontalPaddingInPx, + view.getPaddingBottom()); + } + @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { doMeasure(widthMeasureSpec, heightMeasureSpec); From 51ad3bfdb8700b4ea92c689216ea64cfd786325c Mon Sep 17 00:00:00 2001 From: Peter Kalauskas Date: Mon, 30 Aug 2021 12:00:49 -0700 Subject: [PATCH 4/9] Fix crash in Go Launcher Bug: 198141465 Bug: 200747950 Test: Check that wembley is usable after unlocking Change-Id: I37620be4f24a2f0f8f08483991fad7760415b67c Merged-In: I37620be4f24a2f0f8f08483991fad7760415b67c (cherry picked from commit 1beab2a3d7b39176a792037399b08a0104ea20de) --- .../res/layout/overview_actions_container.xml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/go/quickstep/res/layout/overview_actions_container.xml b/go/quickstep/res/layout/overview_actions_container.xml index cc65cbf9a5..710e2e0959 100644 --- a/go/quickstep/res/layout/overview_actions_container.xml +++ b/go/quickstep/res/layout/overview_actions_container.xml @@ -104,6 +104,23 @@ +