Merge "Cleanup code related to ag/11035582" into ub-launcher3-rvc-dev am: 8f3c7c23d6
Change-Id: I371d4a7549df0391e50b5423899a1cdc8aae3d3d
diff --git a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialEngagedController.java b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialEngagedController.java
index c9ee1e2..297c287 100644
--- a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialEngagedController.java
+++ b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialEngagedController.java
@@ -35,7 +35,7 @@
@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 d03811d..d7c10b0 100644
--- a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialHandAnimation.java
+++ b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialHandAnimation.java
@@ -38,8 +38,6 @@
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 @@
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 @@
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();
}
}
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 4e1e586..0cc9a2c 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -271,7 +271,7 @@
// 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.
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index b9b33fe..4fe1d1a 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -331,7 +331,7 @@
.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;
@@ -457,24 +457,12 @@
});
}
- /**
- * 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;
}
@@ -494,9 +482,6 @@
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 680c3ba..e29971e 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 @@
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) {