From 2e59b950241b460a19346146a881b0e07280e070 Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Tue, 9 Jun 2020 11:37:23 -0700 Subject: [PATCH] Work profile visual polish - Calculate work profile switch height and apply it as a padding to recyclerview instead of reading height from view. - Add solid background to work_apps paused overlay for improved crossfade animation on pause/unpause - Don't show work paused overlay text in landscape mode Bug 151672365 Bug 153763804 Bug 151595687 Test: Manual Change-Id: I6c14a8a1624455181d4998555bcc3ae2bb422efe --- res/layout/work_apps_paused.xml | 2 ++ res/layout/work_mode_switch.xml | 10 ++++---- res/values/dimens.xml | 4 ++- .../allapps/AllAppsContainerView.java | 25 ++++++++++++++++--- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/res/layout/work_apps_paused.xml b/res/layout/work_apps_paused.xml index 08e1c981ff..7f1107f68d 100644 --- a/res/layout/work_apps_paused.xml +++ b/res/layout/work_apps_paused.xml @@ -15,6 +15,7 @@ @@ -34,6 +35,7 @@ diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 31b12adbf1..947e635d73 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -96,7 +96,6 @@ 2dp - 20dp 3dp @@ -105,6 +104,9 @@ 8dp + 20dp + 16sp + 8dp 16dp diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index a45c96c44b..fe04e31e8e 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -19,6 +19,8 @@ import static com.android.launcher3.logging.LoggerUtils.newContainerTarget; import android.animation.ValueAnimator; import android.content.Context; +import android.content.res.Configuration; +import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Point; @@ -434,6 +436,15 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo mWorkModeSwitch.post(() -> mAH[AdapterHolder.WORK].applyPadding()); } + @Override + protected void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + View overlay = mAH[AdapterHolder.WORK].getOverlayView(); + int v = newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE ? GONE : VISIBLE; + overlay.findViewById(R.id.work_apps_paused_title).setVisibility(v); + overlay.findViewById(R.id.work_apps_paused_content).setVisibility(v); + } + private void replaceRVContainer(boolean showTabs) { for (int i = 0; i < mAH.length; i++) { if (mAH[i].recyclerView != null) { @@ -651,10 +662,12 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo recyclerView.setItemAnimator(new DefaultItemAnimator()); if (workDisabled) { overlayView.setAlpha(0); - appsList.updateItemFilter((info, cn) -> false); recyclerView.addAutoSizedOverlay(overlayView); overlayView.animate().alpha(1).withEndAction( - () -> recyclerView.setItemAnimator(null)).start(); + () -> { + appsList.updateItemFilter((info, cn) -> false); + recyclerView.setItemAnimator(null); + }).start(); } else if (mInfoMatcher != null) { appsList.updateItemFilter(mInfoMatcher); overlayView.animate().alpha(0).withEndAction(() -> { @@ -667,8 +680,12 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo void applyPadding() { if (recyclerView != null) { - int bottomOffset = - mWorkModeSwitch != null && mIsWork ? mWorkModeSwitch.getHeight() : 0; + Resources res = getResources(); + int switchH = res.getDimensionPixelSize(R.dimen.work_profile_footer_padding) * 2 + + mInsets.bottom + Utilities.calculateTextHeight( + res.getDimension(R.dimen.work_profile_footer_text_size)); + + int bottomOffset = mWorkModeSwitch != null && mIsWork ? switchH : 0; recyclerView.setPadding(padding.left, padding.top, padding.right, padding.bottom + bottomOffset); }