From 2bc5c995f6d75faab7e4fd1b40cbe25e61209b1f Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Thu, 3 Aug 2017 13:59:12 -0700 Subject: [PATCH] Add new GradientView just for WidgetsBottomSheet Reusing the one behind all apps caused problems when opening widgets sheets from all apps. Bug: 64344341 Change-Id: Ia964d8456645c78614f94693f9538dbac4f566a0 --- res/layout-land/launcher.xml | 7 +----- res/layout-port/launcher.xml | 7 +----- res/layout-sw720dp/launcher.xml | 7 +----- res/layout/gradient_bg.xml | 24 +++++++++++++++++++ .../launcher3/widget/WidgetsBottomSheet.java | 22 ++++++++++------- 5 files changed, 41 insertions(+), 26 deletions(-) create mode 100644 res/layout/gradient_bg.xml diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml index dab074391d..ac440fc01e 100644 --- a/res/layout-land/launcher.xml +++ b/res/layout-land/launcher.xml @@ -42,12 +42,7 @@ android:layout_gravity="center" launcher:pageIndicator="@id/page_indicator" /> - + - + - + + + + \ No newline at end of file diff --git a/src/com/android/launcher3/widget/WidgetsBottomSheet.java b/src/com/android/launcher3/widget/WidgetsBottomSheet.java index b2fb09157a..717a61c1cb 100644 --- a/src/com/android/launcher3/widget/WidgetsBottomSheet.java +++ b/src/com/android/launcher3/widget/WidgetsBottomSheet.java @@ -89,7 +89,8 @@ public class WidgetsBottomSheet extends AbstractFloatingView implements Insettab mInsets = new Rect(); mVerticalPullDetector = new VerticalPullDetector(context); mVerticalPullDetector.setListener(this); - mGradientBackground = (GradientView) mLauncher.findViewById(R.id.gradient_bg); + mGradientBackground = (GradientView) mLauncher.getLayoutInflater().inflate( + R.layout.gradient_bg, mLauncher.getDragLayer(), false); } @Override @@ -107,6 +108,8 @@ public class WidgetsBottomSheet extends AbstractFloatingView implements Insettab onWidgetsBound(); + mLauncher.getDragLayer().addView(mGradientBackground); + mGradientBackground.setVisibility(VISIBLE); mLauncher.getDragLayer().addView(this); measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); setTranslationY(mTranslationYClosed); @@ -213,11 +216,8 @@ public class WidgetsBottomSheet extends AbstractFloatingView implements Insettab mOpenCloseAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { - mIsOpen = false; mVerticalPullDetector.finishedScrolling(); - ((ViewGroup) getParent()).removeView(WidgetsBottomSheet.this); - mLauncher.getSystemUiController().updateUiState( - SystemUiController.UI_STATE_WIDGET_BOTTOM_SHEET, 0); + onCloseComplete(); } }); mOpenCloseAnimator.setInterpolator(mVerticalPullDetector.isIdleState() @@ -225,12 +225,18 @@ public class WidgetsBottomSheet extends AbstractFloatingView implements Insettab mOpenCloseAnimator.start(); } else { setTranslationY(mTranslationYClosed); - mLauncher.getSystemUiController().updateUiState( - SystemUiController.UI_STATE_WIDGET_BOTTOM_SHEET, 0); - mIsOpen = false; + onCloseComplete(); } } + private void onCloseComplete() { + mIsOpen = false; + mLauncher.getDragLayer().removeView(mGradientBackground); + mLauncher.getDragLayer().removeView(WidgetsBottomSheet.this); + mLauncher.getSystemUiController().updateUiState( + SystemUiController.UI_STATE_WIDGET_BOTTOM_SHEET, 0); + } + @Override protected boolean isOfType(@FloatingViewType int type) { return (type & TYPE_WIDGETS_BOTTOM_SHEET) != 0;