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
This commit is contained in:
Tony Wickham
2017-08-03 13:59:12 -07:00
parent 7f522a25c3
commit 2bc5c995f6
5 changed files with 41 additions and 26 deletions
+1 -6
View File
@@ -42,12 +42,7 @@
android:layout_gravity="center"
launcher:pageIndicator="@id/page_indicator" />
<com.android.launcher3.graphics.GradientView
android:id="@+id/gradient_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
launcher:layout_ignoreInsets="true"/>
<include layout="@layout/gradient_bg" />
<!-- DO NOT CHANGE THE ID -->
<include layout="@layout/hotseat"
+1 -6
View File
@@ -44,12 +44,7 @@
launcher:pageIndicator="@+id/page_indicator">
</com.android.launcher3.Workspace>
<com.android.launcher3.graphics.GradientView
android:id="@+id/gradient_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
launcher:layout_ignoreInsets="true"/>
<include layout="@layout/gradient_bg" />
<!-- DO NOT CHANGE THE ID -->
<include layout="@layout/hotseat"
+1 -6
View File
@@ -43,12 +43,7 @@
launcher:pageIndicator="@id/page_indicator">
</com.android.launcher3.Workspace>
<com.android.launcher3.graphics.GradientView
android:id="@+id/gradient_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
launcher:layout_ignoreInsets="true"/>
<include layout="@layout/gradient_bg" />
<!-- DO NOT CHANGE THE ID -->
<include layout="@layout/hotseat"
+24
View File
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2017 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<com.android.launcher3.graphics.GradientView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res-auto"
android:id="@+id/gradient_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
launcher:layout_ignoreInsets="true" />
@@ -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;