From 7d964726d5bbd93b720b095c46bee2e321aa4754 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Mon, 24 May 2021 19:10:42 +0100 Subject: [PATCH 01/11] Ensure RecentsOrientedState.mRecentsRotation is up to date on swipe up - Updates RecentsOrientedState.mRecentsRotation after launcher is started, as it's not updated when RecentsView is in foreground when device rotates e.g. inside another app - No longer calls updateOrientationHandler in onConfigurationChanged, as updateOrientationHandler is already called in setInsets, which get called on rotation Bug: 181550945 Test: Swipe up to enter overview, launch app, rotate, then swipe up again Test: Swipe up to enter overview from landscape only app, while holding device in portrait Change-Id: I268093617d51333678e510c910ed15275706f984 --- .../com/android/quickstep/AbsSwipeUpHandler.java | 3 +++ .../com/android/quickstep/views/RecentsView.java | 13 +++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 005e9b5a7d..2c41a5fdb1 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -393,6 +393,9 @@ public abstract class AbsSwipeUpHandler, if (mStateCallback.hasStates(STATE_HANDLER_INVALIDATED)) { return; } + // RecentsView never updates the display rotation until swipe-up, force update + // RecentsOrientedState before passing to TaskViewSimulator. + mRecentsView.updateRecentsRotation(); mTaskViewSimulator.setOrientationState(mRecentsView.getPagedViewOrientedState()); // If we've already ended the gesture and are going home, don't prepare recents UI, diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 376cb31a90..1e8e2b19d1 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -2618,19 +2618,20 @@ public abstract class RecentsView finishRecentsAnimation(true /* toRecents */, - this::onConfigurationChangedInternal)); + this::updateRecentsRotation)); mEnableDrawingLiveTile = false; } else { - onConfigurationChangedInternal(); + updateRecentsRotation(); } mOrientation = newConfig.orientation; } - private void onConfigurationChangedInternal() { + /** + * Updates {@link RecentsOrientedState}'s cached RecentsView rotation. + */ + public void updateRecentsRotation() { final int rotation = mActivity.getDisplay().getRotation(); - if (mOrientationState.setRecentsRotation(rotation)) { - updateOrientationHandler(); - } + mOrientationState.setRecentsRotation(rotation); } public void setLayoutRotation(int touchRotation, int displayRotation) { From 7a36ad396e87819459f3bf0d55b976be5b9ba5ba Mon Sep 17 00:00:00 2001 From: Steven Ng Date: Thu, 27 May 2021 18:41:51 +0100 Subject: [PATCH 02/11] Don't dismiss keyboard after clicking X button on the widgets search bar Test: Enter some queries in the widgets search bar. Click X button. The keyboard is still opened after the search queries has been erased. Bug: 189454318 Change-Id: Icb0501cf36cbf1517e2da24044da44101fa86ed9 --- .../picker/search/WidgetsSearchBarControllerTest.java | 9 ++------- .../widget/picker/search/WidgetsSearchBarController.java | 4 +--- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/robolectric_tests/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarControllerTest.java b/robolectric_tests/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarControllerTest.java index a057a84d06..7ac879aa44 100644 --- a/robolectric_tests/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarControllerTest.java +++ b/robolectric_tests/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarControllerTest.java @@ -19,7 +19,6 @@ package com.android.launcher3.widget.picker.search; import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; @@ -131,18 +130,14 @@ public class WidgetsSearchBarControllerTest { public void cancelSearch_shouldInformSearchModeListenerToClearResultsAndExitSearch() { mCancelButton.performClick(); - // 1 time explicitly from the cancel button on click listener. - // Another from the setText("") the cancel button on click listener causing afterTextChange. - verify(mSearchModeListener, times(2)).exitSearchMode(); + verify(mSearchModeListener).exitSearchMode(); } @Test public void cancelSearch_shouldCancelSearch() { mCancelButton.performClick(); - // 1 time explicitly from the cancel button on click listener. - // Another from the setText("") the cancel button on click listener causing afterTextChange. - verify(mSearchAlgorithm, times(2)).cancel(true); + verify(mSearchAlgorithm).cancel(true); verifyNoMoreInteractions(mSearchAlgorithm); } diff --git a/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarController.java b/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarController.java index a8294c0426..2751a52796 100644 --- a/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarController.java +++ b/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarController.java @@ -101,10 +101,8 @@ public class WidgetsSearchBarController implements TextWatcher, @Override public void clearSearchResult() { - mSearchAlgorithm.cancel(/* interruptActiveRequests= */ true); + // Any existing search session will be cancelled by setting text to empty. mInput.setText(""); - clearFocus(); - mSearchModeListener.exitSearchMode(); } /** From 62769f10d75a1bf11e17103857b179ab931282d7 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Thu, 27 May 2021 15:13:36 -0700 Subject: [PATCH 03/11] Turn off app close flag, Revert back to R implementation. Need more time to experiment with interpolated + springs based approach, will aim for QPR instead. Bug: 189120868 Bug: 173107751 Test: manual Change-Id: I5698bd61c92b4fa719d82f2553125fc7f65b5969 --- quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java | 4 ++-- src/com/android/launcher3/config/FeatureFlags.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 92e8268570..f484568068 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -103,10 +103,10 @@ import com.android.quickstep.util.MotionPauseDetector; import com.android.quickstep.util.ProtoTracer; import com.android.quickstep.util.RecentsOrientedState; import com.android.quickstep.util.RectFSpringAnim; +import com.android.quickstep.util.StaggeredWorkspaceAnim; import com.android.quickstep.util.SurfaceTransactionApplier; import com.android.quickstep.util.SwipePipToHomeAnimator; import com.android.quickstep.util.TransformParams; -import com.android.quickstep.util.WorkspaceRevealAnim; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskView; import com.android.systemui.shared.recents.model.ThumbnailData; @@ -202,7 +202,7 @@ public abstract class AbsSwipeUpHandler, STATE_LAUNCHER_PRESENT | STATE_LAUNCHER_DRAWN | STATE_LAUNCHER_STARTED; public static final long MAX_SWIPE_DURATION = 350; - public static final long HOME_DURATION = WorkspaceRevealAnim.DURATION_MS; + public static final long HOME_DURATION = StaggeredWorkspaceAnim.DURATION_MS; public static final float MIN_PROGRESS_FOR_OVERVIEW = 0.7f; private static final float SWIPE_DURATION_MULTIPLIER = diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 0c0c92ed04..7ef43ed4be 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -238,7 +238,7 @@ public final class FeatureFlags { "Sends a notification whenever launcher encounters an uncaught exception."); public static final BooleanFlag PROTOTYPE_APP_CLOSE = getDebugFlag( - "PROTOTYPE_APP_CLOSE", true, "Enables new app close"); + "PROTOTYPE_APP_CLOSE", false, "Enables new app close"); public static final BooleanFlag ENABLE_WALLPAPER_SCRIM = getDebugFlag( "ENABLE_WALLPAPER_SCRIM", false, From 1e1f85beffc59baeb30cd684445b85f9a33a91d6 Mon Sep 17 00:00:00 2001 From: Jon Spivack Date: Thu, 27 May 2021 14:19:34 -0700 Subject: [PATCH 04/11] NIU Actions: Support Dark Mode and Landscape This adds light and dark color variants for the UI elements on the Go Recents screen. Toggling Dark Mode will switch between the themes. Additionally, the button spacing definitions have been updated to better support Landscape orientation. Bug: 187866121 Bug: 183714277 Test: Manual (Pixel 3A) Change-Id: Ia2c0cbf372882aad87e4018d10d8f85bd92842e0 --- .../res/layout/overview_actions_container.xml | 18 ++------- go/quickstep/res/layout/overview_panel.xml | 39 +++++++++++++++++++ go/quickstep/res/values/attrs.xml | 23 +++++++++++ go/quickstep/res/values/colors.xml | 6 ++- go/quickstep/res/values/dimens.xml | 1 + go/quickstep/res/values/styles.xml | 22 +++++++++-- 6 files changed, 91 insertions(+), 18 deletions(-) create mode 100644 go/quickstep/res/layout/overview_panel.xml create mode 100644 go/quickstep/res/values/attrs.xml diff --git a/go/quickstep/res/layout/overview_actions_container.xml b/go/quickstep/res/layout/overview_actions_container.xml index b36214ba7d..e7da196fad 100644 --- a/go/quickstep/res/layout/overview_actions_container.xml +++ b/go/quickstep/res/layout/overview_actions_container.xml @@ -28,10 +28,6 @@ android:layout_gravity="top|center_horizontal" android:orientation="horizontal"> - - + android:layout_width="@dimen/go_overview_button_container_margin" + android:layout_height="1dp" /> @@ -68,9 +63,8 @@ + android:layout_width="@dimen/go_overview_button_container_margin" + android:layout_height="1dp" /> @@ -90,10 +84,6 @@ android:layout_height="1dp" android:layout_weight="1" /> - - + + + + + + + + + diff --git a/go/quickstep/res/values/attrs.xml b/go/quickstep/res/values/attrs.xml new file mode 100644 index 0000000000..3adf462d2c --- /dev/null +++ b/go/quickstep/res/values/attrs.xml @@ -0,0 +1,23 @@ + + + + + + + + + \ No newline at end of file diff --git a/go/quickstep/res/values/colors.xml b/go/quickstep/res/values/colors.xml index 9383770318..f815f54581 100644 --- a/go/quickstep/res/values/colors.xml +++ b/go/quickstep/res/values/colors.xml @@ -16,6 +16,10 @@ --> - #3C4043 + #DADADA + #000000 + #3C4043 + #F8F9FA #70FFFFFF + #303030 diff --git a/go/quickstep/res/values/dimens.xml b/go/quickstep/res/values/dimens.xml index da684fa23b..55cd138f12 100644 --- a/go/quickstep/res/values/dimens.xml +++ b/go/quickstep/res/values/dimens.xml @@ -22,6 +22,7 @@ 60dp 60dp 80dp + 16dp 8dp 96dp 0dp diff --git a/go/quickstep/res/values/styles.xml b/go/quickstep/res/values/styles.xml index 9b3fe67b98..59f7377d8e 100644 --- a/go/quickstep/res/values/styles.xml +++ b/go/quickstep/res/values/styles.xml @@ -15,9 +15,25 @@ limitations under the License. --> + + + + + + + + + + + + + + + diff --git a/src/com/android/launcher3/AbstractFloatingView.java b/src/com/android/launcher3/AbstractFloatingView.java index 910094769a..4979b40af5 100644 --- a/src/com/android/launcher3/AbstractFloatingView.java +++ b/src/com/android/launcher3/AbstractFloatingView.java @@ -63,7 +63,8 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch TYPE_TASK_MENU, TYPE_OPTIONS_POPUP, TYPE_ICON_SURFACE, - TYPE_PIN_WIDGET_FROM_EXTERNAL_POPUP + TYPE_PIN_WIDGET_FROM_EXTERNAL_POPUP, + TYPE_WIDGETS_EDUCATION_DIALOG }) @Retention(RetentionPolicy.SOURCE) public @interface FloatingViewType {} @@ -85,17 +86,19 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch public static final int TYPE_ICON_SURFACE = 1 << 13; public static final int TYPE_PIN_WIDGET_FROM_EXTERNAL_POPUP = 1 << 14; + public static final int TYPE_WIDGETS_EDUCATION_DIALOG = 1 << 15; public static final int TYPE_ALL = TYPE_FOLDER | TYPE_ACTION_POPUP | TYPE_WIDGETS_BOTTOM_SHEET | TYPE_WIDGET_RESIZE_FRAME | TYPE_WIDGETS_FULL_SHEET | TYPE_ON_BOARD_POPUP | TYPE_DISCOVERY_BOUNCE | TYPE_TASK_MENU | TYPE_OPTIONS_POPUP | TYPE_SNACKBAR | TYPE_LISTENER | TYPE_ALL_APPS_EDU - | TYPE_ICON_SURFACE | TYPE_DRAG_DROP_POPUP | TYPE_PIN_WIDGET_FROM_EXTERNAL_POPUP; + | TYPE_ICON_SURFACE | TYPE_DRAG_DROP_POPUP | TYPE_PIN_WIDGET_FROM_EXTERNAL_POPUP + | TYPE_WIDGETS_EDUCATION_DIALOG; // Type of popups which should be kept open during launcher rebind public static final int TYPE_REBIND_SAFE = TYPE_WIDGETS_FULL_SHEET | TYPE_WIDGETS_BOTTOM_SHEET | TYPE_ON_BOARD_POPUP | TYPE_DISCOVERY_BOUNCE - | TYPE_ALL_APPS_EDU | TYPE_ICON_SURFACE; + | TYPE_ALL_APPS_EDU | TYPE_ICON_SURFACE | TYPE_WIDGETS_EDUCATION_DIALOG; // Usually we show the back button when a floating view is open. Instead, hide for these types. public static final int TYPE_HIDE_BACK_BUTTON = TYPE_ON_BOARD_POPUP | TYPE_DISCOVERY_BOUNCE diff --git a/src/com/android/launcher3/views/ArrowTipView.java b/src/com/android/launcher3/views/ArrowTipView.java index ef3df5fa37..07d377615b 100644 --- a/src/com/android/launcher3/views/ArrowTipView.java +++ b/src/com/android/launcher3/views/ArrowTipView.java @@ -105,10 +105,6 @@ public class ArrowTipView extends AbstractFloatingView { private void init(Context context) { inflate(context, R.layout.arrow_toast, this); setOrientation(LinearLayout.VERTICAL); - View dismissButton = findViewById(R.id.dismiss); - dismissButton.setOnClickListener(view -> { - handleClose(true); - }); View arrowView = findViewById(R.id.arrow); ViewGroup.LayoutParams arrowLp = arrowView.getLayoutParams(); @@ -194,18 +190,18 @@ public class ArrowTipView extends AbstractFloatingView { public ArrowTipView showAtLocation(String text, int arrowXCoord, int yCoord) { ViewGroup parent = mActivity.getDragLayer(); @Px int parentViewWidth = parent.getWidth(); - @Px int textViewWidth = getContext().getResources() - .getDimensionPixelSize(R.dimen.widget_picker_education_tip_width); + @Px int maxTextViewWidth = getContext().getResources() + .getDimensionPixelSize(R.dimen.widget_picker_education_tip_max_width); @Px int minViewMargin = getContext().getResources() .getDimensionPixelSize(R.dimen.widget_picker_education_tip_min_margin); - if (parentViewWidth < textViewWidth + 2 * minViewMargin) { + if (parentViewWidth < maxTextViewWidth + 2 * minViewMargin) { Log.w(TAG, "Cannot display tip on a small screen of size: " + parentViewWidth); return null; } TextView textView = findViewById(R.id.text); textView.setText(text); - textView.setWidth(textViewWidth); + textView.setMaxWidth(maxTextViewWidth); parent.addView(this); requestLayout(); diff --git a/src/com/android/launcher3/views/WidgetsEduView.java b/src/com/android/launcher3/views/WidgetsEduView.java new file mode 100644 index 0000000000..e69cb5b04b --- /dev/null +++ b/src/com/android/launcher3/views/WidgetsEduView.java @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2021 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. + */ +package com.android.launcher3.views; + +import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN; + +import android.animation.PropertyValuesHolder; +import android.content.Context; +import android.graphics.Rect; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; + +import com.android.launcher3.Insettable; +import com.android.launcher3.Launcher; +import com.android.launcher3.R; + +/** + * Education view about widgets. + */ +public class WidgetsEduView extends AbstractSlideInView implements Insettable { + + private static final int DEFAULT_CLOSE_DURATION = 200; + + protected static final int FINAL_SCRIM_BG_COLOR = 0x88000000; + + private Rect mInsets = new Rect(); + private View mEduView; + + + public WidgetsEduView(Context context, AttributeSet attr) { + this(context, attr, 0); + } + + public WidgetsEduView(Context context, AttributeSet attrs, + int defStyleAttr) { + super(context, attrs, defStyleAttr); + mContent = this; + } + + @Override + protected void handleClose(boolean animate) { + handleClose(true, DEFAULT_CLOSE_DURATION); + } + + @Override + protected boolean isOfType(int type) { + return (type & TYPE_WIDGETS_EDUCATION_DIALOG) != 0; + } + + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + mEduView = findViewById(R.id.edu_view); + findViewById(R.id.edu_close_button) + .setOnClickListener(v -> close(/* animate= */ true)); + } + + @Override + public void setInsets(Rect insets) { + int leftInset = insets.left - mInsets.left; + int rightInset = insets.right - mInsets.right; + int bottomInset = insets.bottom - mInsets.bottom; + mInsets.set(insets); + setPadding(leftInset, getPaddingTop(), rightInset, 0); + mEduView.setPaddingRelative(mEduView.getPaddingStart(), + mEduView.getPaddingTop(), mEduView.getPaddingEnd(), bottomInset); + } + + private void show() { + attachToContainer(); + animateOpen(); + } + + @Override + protected int getScrimColor(Context context) { + return FINAL_SCRIM_BG_COLOR; + } + + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + super.onLayout(changed, l, t, r, b); + setTranslationShift(mTranslationShift); + } + + private void animateOpen() { + if (mIsOpen || mOpenCloseAnimator.isRunning()) { + return; + } + mIsOpen = true; + mOpenCloseAnimator.setValues( + PropertyValuesHolder.ofFloat(TRANSLATION_SHIFT, TRANSLATION_SHIFT_OPENED)); + mOpenCloseAnimator.setInterpolator(FAST_OUT_SLOW_IN); + mOpenCloseAnimator.start(); + } + + /** Shows widget education dialog. */ + public static WidgetsEduView showEducationDialog(Launcher launcher) { + LayoutInflater layoutInflater = LayoutInflater.from(launcher); + WidgetsEduView v = (WidgetsEduView) layoutInflater.inflate( + R.layout.widgets_edu, launcher.getDragLayer(), false); + v.show(); + return v; + } +} diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java index fb6ac0e090..6fd16e7b6c 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java +++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java @@ -49,11 +49,14 @@ import com.android.launcher3.Insettable; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; import com.android.launcher3.R; +import com.android.launcher3.Utilities; import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.compat.AccessibilityManagerCompat; import com.android.launcher3.model.WidgetItem; +import com.android.launcher3.views.ArrowTipView; import com.android.launcher3.views.RecyclerViewFastScroller; import com.android.launcher3.views.TopRoundedCornerView; +import com.android.launcher3.views.WidgetsEduView; import com.android.launcher3.widget.BaseWidgetSheet; import com.android.launcher3.widget.LauncherAppWidgetHost.ProviderChangedListener; import com.android.launcher3.widget.model.WidgetsListBaseEntry; @@ -79,12 +82,16 @@ public class WidgetsFullSheet extends BaseWidgetSheet private static final long DEFAULT_OPEN_DURATION = 267; private static final long FADE_IN_DURATION = 150; private static final long EDUCATION_TIP_DELAY_MS = 200; + private static final long EDUCATION_DIALOG_DELAY_MS = 500; private static final float VERTICAL_START_POSITION = 0.3f; // The widget recommendation table can easily take over the entire screen on devices with small // resolution or landscape on phone. This ratio defines the max percentage of content area that // the table can display. private static final float RECOMMENDATION_TABLE_HEIGHT_RATIO = 0.75f; + private static final String KEY_WIDGETS_EDUCATION_DIALOG_SEEN = + "launcher.widgets_education_dialog_seen"; + private final Rect mInsets = new Rect(); private final boolean mHasWorkProfile; private final SparseArray mAdapters = new SparseArray(); @@ -93,6 +100,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet entry -> mCurrentUser.equals(entry.mPkgItem.user); private final Predicate mWorkWidgetsFilter = mPrimaryWidgetsFilter.negate(); + @Nullable private ArrowTipView mLatestEducationalTip; private final OnLayoutChangeListener mLayoutChangeListenerToShowTips = new OnLayoutChangeListener() { @Override @@ -116,11 +124,12 @@ public class WidgetsFullSheet extends BaseWidgetSheet removeOnLayoutChangeListener(mLayoutChangeListenerToShowTips); return; } - View viewForTip = getViewToShowEducationTip(); - if (showEducationTipOnViewIfPossible(viewForTip) != null) { + mLatestEducationalTip = showEducationTipOnViewIfPossible(getViewToShowEducationTip()); + if (mLatestEducationalTip != null) { removeOnLayoutChangeListener(mLayoutChangeListenerToShowTips); } }; + private final int mTabsHeight; private final int mViewPagerTopPadding; private final int mWidgetCellHorizontalPadding; @@ -211,9 +220,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet mSearchAndRecommendationViewHolder.mSearchBar.initialize( mActivityContext.getPopupDataProvider(), /* searchModeListener= */ this); - if (!hasSeenEducationTip()) { - addOnLayoutChangeListener(mLayoutChangeListenerToShowTips); - } + setUpEducationViewsIfNeeded(); } @Override @@ -598,6 +605,10 @@ public class WidgetsFullSheet extends BaseWidgetSheet @Override protected void onCloseComplete() { super.onCloseComplete(); + removeCallbacks(mShowEducationTipTask); + if (mLatestEducationalTip != null) { + mLatestEducationalTip.close(false); + } AccessibilityManagerCompat.sendStateEventToTest(getContext(), NORMAL_STATE_ORDINAL); } @@ -670,6 +681,38 @@ public class WidgetsFullSheet extends BaseWidgetSheet return null; } + /** Shows education dialog for widgets. */ + private WidgetsEduView showEducationDialog() { + mActivityContext.getSharedPrefs().edit() + .putBoolean(KEY_WIDGETS_EDUCATION_DIALOG_SEEN, true).apply(); + return WidgetsEduView.showEducationDialog(mActivityContext); + } + + /** Returns {@code true} if education dialog has previously been shown. */ + protected boolean hasSeenEducationDialog() { + return mActivityContext.getSharedPrefs() + .getBoolean(KEY_WIDGETS_EDUCATION_DIALOG_SEEN, false) + || Utilities.IS_RUNNING_IN_TEST_HARNESS; + } + + private void setUpEducationViewsIfNeeded() { + if (!hasSeenEducationDialog()) { + postDelayed(() -> { + WidgetsEduView eduDialog = showEducationDialog(); + eduDialog.addOnCloseListener(() -> { + if (!hasSeenEducationTip()) { + addOnLayoutChangeListener(mLayoutChangeListenerToShowTips); + // Call #requestLayout() to trigger layout change listener in order to show + // arrow tip immediately if there is a widget to show it on. + requestLayout(); + } + }); + }, EDUCATION_DIALOG_DELAY_MS); + } else if (!hasSeenEducationTip()) { + addOnLayoutChangeListener(mLayoutChangeListenerToShowTips); + } + } + /** A holder class for holding adapters & their corresponding recycler view. */ private final class AdapterHolder { static final int PRIMARY = 0; From 8cabe52f81a6c651475962b82fbb2e3453486de9 Mon Sep 17 00:00:00 2001 From: Alina Zaidi Date: Fri, 21 May 2021 17:59:19 +0100 Subject: [PATCH 11/11] Update buttons in pin widget picker. Bug: 188504905 Test: Tested manually Change-Id: Ibce57d7f70700b5f36b588ad85f8a829d4d4c5c2 --- .../add_item_dialog_button_background.xml | 22 -------------- res/drawable/full_rounded_colored_ripple.xml | 28 ++++++++++++++++++ res/layout/add_item_confirmation_activity.xml | 29 +++++++++++-------- res/values/styles.xml | 9 +++--- 4 files changed, 50 insertions(+), 38 deletions(-) delete mode 100644 res/drawable/add_item_dialog_button_background.xml create mode 100644 res/drawable/full_rounded_colored_ripple.xml diff --git a/res/drawable/add_item_dialog_button_background.xml b/res/drawable/add_item_dialog_button_background.xml deleted file mode 100644 index 1b4591f8c1..0000000000 --- a/res/drawable/add_item_dialog_button_background.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/res/drawable/full_rounded_colored_ripple.xml b/res/drawable/full_rounded_colored_ripple.xml new file mode 100644 index 0000000000..d89537ca0e --- /dev/null +++ b/res/drawable/full_rounded_colored_ripple.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/add_item_confirmation_activity.xml b/res/layout/add_item_confirmation_activity.xml index 0a3fbbcd01..ddc98156e9 100644 --- a/res/layout/add_item_confirmation_activity.xml +++ b/res/layout/add_item_confirmation_activity.xml @@ -53,7 +53,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" - android:paddingVertical="8dp" + android:paddingTop="8dp" android:text="@string/add_item_request_drag_hint" android:textSize="14sp" android:textColor="?android:attr/textColorSecondary" @@ -70,28 +70,33 @@