From d8144a63043edf7308f11a1055e5dc35dd2f43cf Mon Sep 17 00:00:00 2001 From: Kevin Date: Mon, 29 Apr 2019 17:38:04 -0700 Subject: [PATCH] Overlap insets with item margins The system insets already create visual space for us, so there is no need to add additional margin if we already have the insets acting as a buffer. So we can just overlap them, preventing scenarios where we have too much scrollable white space. As a bonus, we get a more robust way of determining the clear all button's bottom margins as we now base it directly off whether the insets cover the space as opposed to using the orientation (which is an indirect way of knowing the insets). Bug: 131636735 Test: Test on 320x569 mdpi. Matches UX spec. Change-Id: I6a3a3a5475ed303ed21bca3ed3cc363276c6e745 --- go/quickstep/res/values-sw480dp/dimens.xml | 2 +- go/quickstep/res/values/dimens.xml | 2 +- .../quickstep/views/IconRecentsView.java | 30 ++++++++++++------- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/go/quickstep/res/values-sw480dp/dimens.xml b/go/quickstep/res/values-sw480dp/dimens.xml index be27d4bbd9..b48dafbafb 100644 --- a/go/quickstep/res/values-sw480dp/dimens.xml +++ b/go/quickstep/res/values-sw480dp/dimens.xml @@ -25,6 +25,6 @@ 48dp 28dp - 28dp + 28dp 140dp \ No newline at end of file diff --git a/go/quickstep/res/values/dimens.xml b/go/quickstep/res/values/dimens.xml index 60e997a84e..91040f205f 100644 --- a/go/quickstep/res/values/dimens.xml +++ b/go/quickstep/res/values/dimens.xml @@ -25,6 +25,6 @@ 36dp 20dp - 20dp + 20dp 106dp \ No newline at end of file diff --git a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java index ce22489316..f951304f59 100644 --- a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java +++ b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java @@ -16,7 +16,6 @@ package com.android.quickstep.views; import static android.content.res.Configuration.ORIENTATION_LANDSCAPE; -import static android.content.res.Configuration.ORIENTATION_PORTRAIT; import static androidx.recyclerview.widget.LinearLayoutManager.VERTICAL; @@ -32,7 +31,6 @@ import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.animation.ValueAnimator; import android.content.Context; -import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Rect; import android.util.ArraySet; @@ -125,6 +123,7 @@ public final class IconRecentsView extends FrameLayout implements Insettable { private boolean mTransitionedFromApp; private AnimatorSet mLayoutAnimation; private final ArraySet mLayingOutViews = new ArraySet<>(); + private Rect mInsets; private final RecentsModel.TaskThumbnailChangeListener listener = (taskId, thumbnailData) -> { ArrayList itemViews = getTaskViews(); for (int i = 0, size = itemViews.size(); i < size; i++) { @@ -194,13 +193,25 @@ public final class IconRecentsView extends FrameLayout implements Insettable { case ITEM_TYPE_CLEAR_ALL: outRect.top = (int) res.getDimension( R.dimen.clear_all_item_view_top_margin); - if (res.getConfiguration().orientation == ORIENTATION_LANDSCAPE) { - outRect.bottom = (int) res.getDimension( - R.dimen.clear_all_item_view_landscape_bottom_margin); + int desiredBottomMargin = (int) res.getDimension( + R.dimen.clear_all_item_view_bottom_margin); + // Only add bottom margin if insets aren't enough. + if (mInsets.bottom < desiredBottomMargin) { + outRect.bottom = desiredBottomMargin - mInsets.bottom; } break; case ITEM_TYPE_TASK: - outRect.top = (int) res.getDimension(R.dimen.task_item_top_margin); + int desiredTopMargin = (int) res.getDimension( + R.dimen.task_item_top_margin); + if (mTaskRecyclerView.getChildAdapterPosition(view) == + state.getItemCount() - 1) { + // Only add top margin to top task view if insets aren't enough. + if (mInsets.top < desiredTopMargin) { + outRect.top = desiredTopMargin - mInsets.bottom; + } + return; + } + outRect.top = desiredTopMargin; break; default: } @@ -233,11 +244,6 @@ public final class IconRecentsView extends FrameLayout implements Insettable { } } - @Override - protected void onConfigurationChanged(Configuration newConfig) { - mTaskRecyclerView.invalidateItemDecorations(); - } - /** * Set activity helper for the view to callback to. * @@ -522,6 +528,8 @@ public final class IconRecentsView extends FrameLayout implements Insettable { @Override public void setInsets(Rect insets) { + mInsets = insets; mTaskRecyclerView.setPadding(insets.left, insets.top, insets.right, insets.bottom); + mTaskRecyclerView.invalidateItemDecorations(); } }