From e725b6fe56f4b4acb53188803564adea76757bfe Mon Sep 17 00:00:00 2001 From: Andy Wickham Date: Sat, 4 Apr 2020 00:25:49 +0000 Subject: [PATCH 01/63] Fixes issue where back tutorial animation didn't always appear. Specifically, when switching from right to left edge, the animation disappeared. This change forces the animation to restart whenever you switch to another tutorial. Bug: 148542211 Change-Id: Ie74c636a4afd1018c7c8e6998a1e7a176bf8099e --- .../BackGestureTutorialEngagedController.java | 2 +- .../BackGestureTutorialHandAnimation.java | 27 +++++-------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialEngagedController.java b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialEngagedController.java index c9ee1e2006..297c287615 100644 --- a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialEngagedController.java +++ b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialEngagedController.java @@ -35,7 +35,7 @@ final class BackGestureTutorialEngagedController extends BackGestureTutorialCont @Override void transitToController() { super.transitToController(); - mHandCoachingAnimation.maybeStartLoopedAnimation(mTutorialTypeInfo.get().getTutorialType()); + mHandCoachingAnimation.startLoopedAnimation(mTutorialTypeInfo.get().getTutorialType()); } @Override diff --git a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialHandAnimation.java b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialHandAnimation.java index d03811de55..d7c10b0b9c 100644 --- a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialHandAnimation.java +++ b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialHandAnimation.java @@ -38,8 +38,6 @@ final class BackGestureTutorialHandAnimation { private final ImageView mHandCoachingView; private final AnimatedVectorDrawable mGestureAnimation; - private boolean mIsAnimationPlayed = false; - BackGestureTutorialHandAnimation(Context context, View rootView) { mHandCoachingView = rootView.findViewById( R.id.back_gesture_tutorial_fragment_hand_coaching); @@ -47,20 +45,15 @@ final class BackGestureTutorialHandAnimation { R.drawable.back_gesture); } - boolean isRunning() { - return mGestureAnimation.isRunning(); - } - /** - * Starts animation if the playground is launched for the first time. + * [Re]starts animation for the given tutorial. */ - void maybeStartLoopedAnimation(TutorialType tutorialType) { - if (isRunning() || mIsAnimationPlayed) { - return; + void startLoopedAnimation(TutorialType tutorialType) { + if (mGestureAnimation.isRunning()) { + stop(); } - mIsAnimationPlayed = true; - clearAnimationCallbacks(); + mGestureAnimation.clearAnimationCallbacks(); mGestureAnimation.registerAnimationCallback( new Animatable2.AnimationCallback() { @Override @@ -78,17 +71,11 @@ final class BackGestureTutorialHandAnimation { float rotationY = tutorialType == TutorialType.LEFT_EDGE_BACK_NAVIGATION ? 180f : 0f; mHandCoachingView.setRotationY(rotationY); mHandCoachingView.setImageDrawable(mGestureAnimation); - mHandCoachingView.postDelayed(() -> mGestureAnimation.start(), - ANIMATION_START_DELAY.toMillis()); - } - - private void clearAnimationCallbacks() { - mGestureAnimation.clearAnimationCallbacks(); + mHandCoachingView.postDelayed(mGestureAnimation::start, ANIMATION_START_DELAY.toMillis()); } void stop() { - mIsAnimationPlayed = false; - clearAnimationCallbacks(); + mGestureAnimation.clearAnimationCallbacks(); mGestureAnimation.stop(); } } From 09066ffeb2262646f9cf6ff6aace97c264019419 Mon Sep 17 00:00:00 2001 From: jayaprakashs Date: Fri, 10 Apr 2020 20:52:23 -0700 Subject: [PATCH 02/63] Don't open the Folder and IME when Folder is created. Bug: 153751859 Change-Id: I8169d0890a43b614b293ca29f504e19c532b90ee --- src/com/android/launcher3/folder/Folder.java | 21 +++------------ .../android/launcher3/folder/FolderIcon.java | 26 ++++++++++++++++++- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java index 202836daa5..a59b01dd7d 100644 --- a/src/com/android/launcher3/folder/Folder.java +++ b/src/com/android/launcher3/folder/Folder.java @@ -329,7 +329,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo .map(info -> info.suggestedFolderNames) .map(folderNames -> (FolderNameInfo[]) folderNames .getParcelableArrayExtra(FolderInfo.EXTRA_FOLDER_SUGGESTIONS)) - .ifPresent(nameInfos -> showLabelSuggestion(nameInfos, false)); + .ifPresent(nameInfos -> showLabelSuggestions(nameInfos)); } mFolderName.setHint(""); mIsEditingName = true; @@ -455,24 +455,12 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo }); } - /** - * Show suggested folder title in FolderEditText, push InputMethodManager suggestions and save - * the suggestedFolderNames. - */ - public void showSuggestedTitle(FolderNameInfo[] nameInfos) { - if (FeatureFlags.FOLDER_NAME_SUGGEST.get()) { - if (isEmpty(mFolderName.getText().toString()) - && !mInfo.hasOption(FLAG_MANUAL_FOLDER_NAME)) { - showLabelSuggestion(nameInfos, true); - } - } - } /** * Show suggested folder title in FolderEditText if the first suggestion is non-empty, push - * InputMethodManager suggestions. + * rest of the suggestions to InputMethodManager. */ - private void showLabelSuggestion(FolderNameInfo[] nameInfos, boolean animate) { + private void showLabelSuggestions(FolderNameInfo[] nameInfos) { if (nameInfos == null) { return; } @@ -492,9 +480,6 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo mFolderName.setText(firstLabel); } } - if (animate) { - animateOpen(mInfo.contents, 0, true); - } mFolderName.showKeyboard(); mFolderName.displayCompletions( asList(nameInfos).subList(0, nameInfos.length).stream() diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java index eda9545b17..36351bd20d 100644 --- a/src/com/android/launcher3/folder/FolderIcon.java +++ b/src/com/android/launcher3/folder/FolderIcon.java @@ -16,6 +16,8 @@ package com.android.launcher3.folder; +import static android.text.TextUtils.isEmpty; + import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.MAX_NUM_ITEMS_IN_PREVIEW; import static com.android.launcher3.folder.PreviewItemManager.INITIAL_ITEM_ANIMATION_DURATION; @@ -418,11 +420,33 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel postDelayed(() -> { mPreviewItemManager.hidePreviewItem(finalIndex, false); mFolder.showItem(item); + setLabelSuggestion(nameInfos); invalidate(); - mFolder.showSuggestedTitle(nameInfos); }, DROP_IN_ANIMATION_DURATION); } + /** + * Set the suggested folder name. + */ + public void setLabelSuggestion(FolderNameInfo[] nameInfos) { + if (!FeatureFlags.FOLDER_NAME_SUGGEST.get()) { + return; + } + if (!isEmpty(mFolderName.getText().toString()) + || mInfo.hasOption(FolderInfo.FLAG_MANUAL_FOLDER_NAME)) { + return; + } + if (nameInfos == null || nameInfos[0] == null || isEmpty(nameInfos[0].getLabel())) { + return; + } + mInfo.title = nameInfos[0].getLabel(); + onTitleChanged(mInfo.title); + mFolder.mFolderName.setText(mInfo.title); + mFolder.mLauncher.getModelWriter().updateItemInDatabase(mInfo); + // TODO: Add logging while folder creation. + } + + public void onDrop(DragObject d, boolean itemReturnedOnFailedDrop) { WorkspaceItemInfo item; if (d.dragInfo instanceof AppInfo) { From 157e666058772056c2820f6eff7b7b52c5a8ecd4 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Tue, 14 Apr 2020 03:06:01 +0000 Subject: [PATCH 03/63] Revert "Show all apps app names in multi window landscape" This reverts commit 1c3c3b1d6fc1911740882c726e4e838d6502edd6. Reason for revert: Broke multi-window rotation and secondary display Change-Id: I907b21ca82cf2e25f8abe7a09eafd6dec817f81b --- src/com/android/launcher3/DeviceProfile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index c0490696c9..0d71da4814 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -271,7 +271,7 @@ public class DeviceProfile { // In multi-window mode, we can have widthPx = availableWidthPx // and heightPx = availableHeightPx because Launcher uses the InvariantDeviceProfiles' // widthPx and heightPx values where it's needed. - DeviceProfile profile = new DeviceProfile(context, inv, null, mwSize, mwSize, + DeviceProfile profile = new DeviceProfile(context, inv, originalIdp, mwSize, mwSize, mwSize.x, mwSize.y, isLandscape, true); // If there isn't enough vertical cell padding with the labels displayed, hide the labels. From 9c89358c7d49357082d8446fa752981eb64b2bd1 Mon Sep 17 00:00:00 2001 From: Andy Wickham Date: Tue, 14 Apr 2020 23:08:46 +0000 Subject: [PATCH 04/63] Refactors Sandbox to more easily add new tutorials. - Extracts abstract classes for common functionality - Renames some layouts, etc. to not be back-specific - Consolidates more logic in the controllers rather than classes like BackGestureTutorialTypeInfo - Removes redundant TutorialStep enum (combining it with TutorialType) Still considering removing additional layers of abstraction like the Fragment itself (instead keeping UI within the Activity, which would still be controlled by a TutorialController). Test: Built and went through the Back tutorial to confirm existing funcitonality was not disrupted. Bug: 148542211 Change-Id: I590af62f5fe3186a15deb5883e6ef6e6cb7e4665 Change-Id: Id893869cb59609141dcdbdca01744d0f5952b546 --- ...ure_tutorial_action_button_background.xml} | 2 +- ...ure_tutorial_action_button_background.xml} | 2 +- ....xml => gesture_tutorial_close_button.xml} | 0 ...vity.xml => gesture_tutorial_activity.xml} | 2 +- ...ment.xml => gesture_tutorial_fragment.xml} | 40 ++-- quickstep/res/values/dimens.xml | 6 +- quickstep/res/values/strings.xml | 6 +- quickstep/res/values/styles.xml | 8 +- .../BackGestureTutorialConfirmController.java | 64 ------ .../BackGestureTutorialController.java | 199 ++++++------------ .../BackGestureTutorialEngagedController.java | 64 ------ .../BackGestureTutorialFragment.java | 153 ++------------ .../BackGestureTutorialTypeInfo.java | 109 ---------- .../BackGestureTutorialTypeInfoProvider.java | 59 ------ .../interaction/EdgeBackGestureHandler.java | 8 +- .../interaction/GestureSandboxActivity.java | 21 +- .../interaction/TutorialController.java | 135 ++++++++++++ .../interaction/TutorialFragment.java | 153 ++++++++++++++ ...mation.java => TutorialHandAnimation.java} | 16 +- res/values/colors.xml | 10 +- 20 files changed, 429 insertions(+), 628 deletions(-) rename quickstep/res/drawable-v28/{back_gesture_tutorial_action_button_background.xml => gesture_tutorial_action_button_background.xml} (90%) rename quickstep/res/drawable/{back_gesture_tutorial_action_button_background.xml => gesture_tutorial_action_button_background.xml} (90%) rename quickstep/res/drawable/{back_gesture_tutorial_close_button.xml => gesture_tutorial_close_button.xml} (100%) rename quickstep/res/layout/{back_gesture_tutorial_activity.xml => gesture_tutorial_activity.xml} (87%) rename quickstep/res/layout/{back_gesture_tutorial_fragment.xml => gesture_tutorial_fragment.xml} (70%) delete mode 100644 quickstep/src/com/android/quickstep/interaction/BackGestureTutorialConfirmController.java delete mode 100644 quickstep/src/com/android/quickstep/interaction/BackGestureTutorialEngagedController.java delete mode 100644 quickstep/src/com/android/quickstep/interaction/BackGestureTutorialTypeInfo.java delete mode 100644 quickstep/src/com/android/quickstep/interaction/BackGestureTutorialTypeInfoProvider.java create mode 100644 quickstep/src/com/android/quickstep/interaction/TutorialController.java create mode 100644 quickstep/src/com/android/quickstep/interaction/TutorialFragment.java rename quickstep/src/com/android/quickstep/interaction/{BackGestureTutorialHandAnimation.java => TutorialHandAnimation.java} (85%) diff --git a/quickstep/res/drawable-v28/back_gesture_tutorial_action_button_background.xml b/quickstep/res/drawable-v28/gesture_tutorial_action_button_background.xml similarity index 90% rename from quickstep/res/drawable-v28/back_gesture_tutorial_action_button_background.xml rename to quickstep/res/drawable-v28/gesture_tutorial_action_button_background.xml index cd30ef7075..57423c2ffc 100644 --- a/quickstep/res/drawable-v28/back_gesture_tutorial_action_button_background.xml +++ b/quickstep/res/drawable-v28/gesture_tutorial_action_button_background.xml @@ -16,5 +16,5 @@ - + \ No newline at end of file diff --git a/quickstep/res/drawable/back_gesture_tutorial_action_button_background.xml b/quickstep/res/drawable/gesture_tutorial_action_button_background.xml similarity index 90% rename from quickstep/res/drawable/back_gesture_tutorial_action_button_background.xml rename to quickstep/res/drawable/gesture_tutorial_action_button_background.xml index d7b910273a..3f3b288e2d 100644 --- a/quickstep/res/drawable/back_gesture_tutorial_action_button_background.xml +++ b/quickstep/res/drawable/gesture_tutorial_action_button_background.xml @@ -16,5 +16,5 @@ - + \ No newline at end of file diff --git a/quickstep/res/drawable/back_gesture_tutorial_close_button.xml b/quickstep/res/drawable/gesture_tutorial_close_button.xml similarity index 100% rename from quickstep/res/drawable/back_gesture_tutorial_close_button.xml rename to quickstep/res/drawable/gesture_tutorial_close_button.xml diff --git a/quickstep/res/layout/back_gesture_tutorial_activity.xml b/quickstep/res/layout/gesture_tutorial_activity.xml similarity index 87% rename from quickstep/res/layout/back_gesture_tutorial_activity.xml rename to quickstep/res/layout/gesture_tutorial_activity.xml index e894e893c3..4dc8913ef5 100644 --- a/quickstep/res/layout/back_gesture_tutorial_activity.xml +++ b/quickstep/res/layout/gesture_tutorial_activity.xml @@ -14,6 +14,6 @@ limitations under the License. --> \ No newline at end of file diff --git a/quickstep/res/layout/back_gesture_tutorial_fragment.xml b/quickstep/res/layout/gesture_tutorial_fragment.xml similarity index 70% rename from quickstep/res/layout/back_gesture_tutorial_fragment.xml rename to quickstep/res/layout/gesture_tutorial_fragment.xml index d8c25bd4d0..0bc062af35 100644 --- a/quickstep/res/layout/back_gesture_tutorial_fragment.xml +++ b/quickstep/res/layout/gesture_tutorial_fragment.xml @@ -16,27 +16,27 @@ + android:background="@color/gesture_tutorial_background_color"> + android:accessibilityTraversalAfter="@id/gesture_tutorial_fragment_titles_container" + android:contentDescription="@string/gesture_tutorial_close_button_content_description" + android:src="@drawable/gesture_tutorial_close_button"/> @@ -91,21 +91,21 @@ android:layout_gravity="center_horizontal">