From d80cec62b4f2433f975f949bedd017b248753157 Mon Sep 17 00:00:00 2001 From: Alina Zaidi Date: Thu, 13 May 2021 14:13:18 +0100 Subject: [PATCH] Modify pin widget dialog open-close animation. Pin widget sheet should open from bottom up and close on drag down. Behaviour with navigation bar is similar to that of widgets bottom sheet. Add a drag layer and reuse AbstractSlideInView for open-close animation. Test: Tested manually- opening, closing through dragging/ cancel button/ back button. Adding widget to screen by dragging/ add to home screen button. Bug: 186124244 Change-Id: I4b77d5bdd4ed1689b651847dfed69d19cafa7456 --- AndroidManifest-common.xml | 2 +- .../hybridhotseat/HotseatEduDialog.java | 20 +-- res/layout/add_item_confirmation_activity.xml | 130 ++++++++++-------- res/values-night/styles.xml | 10 +- res/values/styles.xml | 10 +- .../launcher3/AbstractFloatingView.java | 7 +- .../launcher3/dragndrop/AddItemActivity.java | 47 +++++-- .../launcher3/dragndrop/AddItemDragLayer.java | 42 ++++++ .../launcher3/views/AbstractSlideInView.java | 45 ++++-- .../android/launcher3/views/WorkEduView.java | 16 ++- .../widget/AddItemWidgetsBottomSheet.java | 98 +++++++++++++ .../launcher3/widget/BaseWidgetSheet.java | 12 +- .../launcher3/widget/WidgetsBottomSheet.java | 8 +- .../widget/picker/WidgetsFullSheet.java | 26 ++-- 14 files changed, 336 insertions(+), 137 deletions(-) create mode 100644 src/com/android/launcher3/dragndrop/AddItemDragLayer.java create mode 100644 src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java diff --git a/AndroidManifest-common.xml b/AndroidManifest-common.xml index 87a08afc24..d725a16f80 100644 --- a/AndroidManifest-common.xml +++ b/AndroidManifest-common.xml @@ -107,7 +107,7 @@ android:value="true" /> diff --git a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduDialog.java b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduDialog.java index a2ed21143c..14b0c5dd62 100644 --- a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduDialog.java +++ b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduDialog.java @@ -48,7 +48,7 @@ import java.util.List; * User education dialog for hybrid hotseat. Allows user to migrate hotseat items to a new page in * the workspace and shows predictions on the whole hotseat */ -public class HotseatEduDialog extends AbstractSlideInView implements Insettable { +public class HotseatEduDialog extends AbstractSlideInView implements Insettable { private static final int DEFAULT_CLOSE_DURATION = 200; protected static final int FINAL_SCRIM_BG_COLOR = 0x88000000; @@ -84,7 +84,7 @@ public class HotseatEduDialog extends AbstractSlideInView implements Insettable mHotseatWrapper = findViewById(R.id.hotseat_wrapper); mSampleHotseat = findViewById(R.id.sample_prediction); - DeviceProfile grid = mLauncher.getDeviceProfile(); + DeviceProfile grid = mActivityContext.getDeviceProfile(); Rect padding = grid.getHotseatLayoutPadding(); mSampleHotseat.getLayoutParams().height = grid.cellHeightPx; @@ -110,13 +110,13 @@ public class HotseatEduDialog extends AbstractSlideInView implements Insettable mHotseatEduController.moveHotseatItems(); mHotseatEduController.finishOnboarding(); - mLauncher.getStatsLogManager().logger().log(LAUNCHER_HOTSEAT_EDU_ACCEPT); + mActivityContext.getStatsLogManager().logger().log(LAUNCHER_HOTSEAT_EDU_ACCEPT); } private void onDismiss(View v) { mHotseatEduController.showDimissTip(); mHotseatEduController.finishOnboarding(); - mLauncher.getStatsLogManager().logger().log(LAUNCHER_HOTSEAT_EDU_DENY); + mActivityContext.getStatsLogManager().logger().log(LAUNCHER_HOTSEAT_EDU_DENY); handleClose(true); } @@ -131,12 +131,12 @@ public class HotseatEduDialog extends AbstractSlideInView implements Insettable int rightInset = insets.right - mInsets.right; int bottomInset = insets.bottom - mInsets.bottom; mInsets.set(insets); - if (mLauncher.getOrientation() == Configuration.ORIENTATION_PORTRAIT) { + if (mActivityContext.getOrientation() == Configuration.ORIENTATION_PORTRAIT) { setPadding(leftInset, getPaddingTop(), rightInset, 0); mHotseatWrapper.setPadding(mHotseatWrapper.getPaddingLeft(), getPaddingTop(), mHotseatWrapper.getPaddingRight(), bottomInset); mHotseatWrapper.getLayoutParams().height = - mLauncher.getDeviceProfile().hotseatBarSizePx + insets.bottom; + mActivityContext.getDeviceProfile().hotseatBarSizePx + insets.bottom; } else { setPadding(0, getPaddingTop(), 0, 0); @@ -178,7 +178,7 @@ public class HotseatEduDialog extends AbstractSlideInView implements Insettable } private void populatePreview(List predictions) { - for (int i = 0; i < mLauncher.getDeviceProfile().numShownHotseatIcons; i++) { + for (int i = 0; i < mActivityContext.getDeviceProfile().numShownHotseatIcons; i++) { WorkspaceItemInfo info = predictions.get(i); PredictedAppIcon icon = PredictedAppIcon.createIcon(mSampleHotseat, info); icon.setEnabled(false); @@ -194,13 +194,13 @@ public class HotseatEduDialog extends AbstractSlideInView implements Insettable */ public void show(List predictions) { if (getParent() != null - || predictions.size() < mLauncher.getDeviceProfile().numShownHotseatIcons + || predictions.size() < mActivityContext.getDeviceProfile().numShownHotseatIcons || mHotseatEduController == null) { return; } - AbstractFloatingView.closeAllOpenViews(mLauncher); + AbstractFloatingView.closeAllOpenViews(mActivityContext); attachToContainer(); - mLauncher.getStatsLogManager().logger().log(LAUNCHER_HOTSEAT_EDU_SEEN); + mActivityContext.getStatsLogManager().logger().log(LAUNCHER_HOTSEAT_EDU_SEEN); animateOpen(); populatePreview(predictions); } diff --git a/res/layout/add_item_confirmation_activity.xml b/res/layout/add_item_confirmation_activity.xml index 00d148f2dc..0a3fbbcd01 100644 --- a/res/layout/add_item_confirmation_activity.xml +++ b/res/layout/add_item_confirmation_activity.xml @@ -16,69 +16,85 @@ ** limitations under the License. */ --> - + android:clipChildren="false" + android:clipToPadding="false" + android:importantForAccessibility="no"> - + android:background="@drawable/add_item_dialog_background" + android:padding="24dp" + android:theme="?attr/widgetsTheme" + android:layout_gravity="bottom" + android:orientation="vertical"> - - - - - -