Merge "Import translations. DO NOT MERGE ANYWHERE"
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index deeaaa6..99ad8c0 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -140,7 +140,8 @@
private final ArrayList<Runnable> mRecentsAnimationStartCallbacks = new ArrayList<>();
private final OnScrollChangedListener mOnRecentsScrollListener = this::onRecentsViewScroll;
- protected RecentsAnimationController mRecentsAnimationController;
+ // Null if the recents animation hasn't started yet or has been canceled or finished.
+ protected @Nullable RecentsAnimationController mRecentsAnimationController;
protected RecentsAnimationTargets mRecentsAnimationTargets;
protected T mActivity;
protected Q mRecentsView;
@@ -1354,8 +1355,10 @@
@UiThread
private void resumeLastTask() {
- mRecentsAnimationController.finish(false /* toRecents */, null);
- ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimation", false);
+ if (mRecentsAnimationController != null) {
+ mRecentsAnimationController.finish(false /* toRecents */, null);
+ ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimation", false);
+ }
doLogGesture(LAST_TASK, null);
reset();
}
@@ -1663,13 +1666,17 @@
}
} else {
mActivityInterface.onLaunchTaskFailed();
- mRecentsAnimationController.finish(true /* toRecents */, null);
+ if (mRecentsAnimationController != null) {
+ mRecentsAnimationController.finish(true /* toRecents */, null);
+ }
}
}, true /* freezeTaskList */);
} else {
mActivityInterface.onLaunchTaskFailed();
Toast.makeText(mContext, R.string.activity_not_available, LENGTH_SHORT).show();
- mRecentsAnimationController.finish(true /* toRecents */, null);
+ if (mRecentsAnimationController != null) {
+ mRecentsAnimationController.finish(true /* toRecents */, null);
+ }
}
}
mCanceled = false;
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index eec0a71..c7924e4 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -2438,12 +2438,15 @@
resetTaskVisuals();
int pageToSnapTo = mCurrentPage;
- if (finalNextFocusedTaskView != null) {
- pageToSnapTo = indexOfChild(finalNextFocusedTaskView);
- }
- if (dismissedIndex < pageToSnapTo || pageToSnapTo == (taskCount - 1)) {
+ if ((dismissedIndex < pageToSnapTo && !showAsGrid)
+ || pageToSnapTo == taskCount - 1) {
pageToSnapTo -= 1;
}
+ if (showAsGrid) {
+ int primaryScroll = mOrientationHandler.getPrimaryScroll(RecentsView.this);
+ int currentPageScroll = getScrollForPage(pageToSnapTo);
+ mCurrentPageScrollDiff = primaryScroll - currentPageScroll;
+ }
removeViewInLayout(dismissedTaskView);
mTopRowIdSet.remove(dismissedTaskId);
@@ -2456,12 +2459,11 @@
mFocusedTaskId = finalNextFocusedTaskView.getTaskId();
mTopRowIdSet.remove(mFocusedTaskId);
finalNextFocusedTaskView.animateIconScaleAndDimIntoView();
- setCurrentPage(pageToSnapTo);
}
updateTaskSize(true);
// Update scroll and snap to page.
updateScrollSynchronously();
- snapToPageImmediately(pageToSnapTo);
+ setCurrentPage(pageToSnapTo);
dispatchScrollChanged();
}
}
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index 0a674b5..1c3f329 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -20,15 +20,12 @@
import static com.android.launcher3.LauncherState.NORMAL;
-import android.animation.AnimatorSet;
import android.content.Context;
-import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
-import android.util.Property;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
@@ -40,6 +37,7 @@
import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.DragOptions;
+import com.android.launcher3.dragndrop.DragView;
import com.android.launcher3.model.data.ItemInfo;
/**
@@ -212,15 +210,21 @@
return;
}
final DragLayer dragLayer = mLauncher.getDragLayer();
+ final DragView dragView = d.dragView;
final Rect to = getIconRect(d);
final float scale = (float) to.width() / d.dragView.getMeasuredWidth();
- d.dragView.detachContentView(/* reattachToPreviousParent= */ true);
+ dragView.disableColorExtraction();
+ dragView.detachContentView(/* reattachToPreviousParent= */ true);
+
mDropTargetBar.deferOnDragEnd();
Runnable onAnimationEndRunnable = () -> {
completeDrop(d);
mDropTargetBar.onDragEnd();
mLauncher.getStateManager().goToState(NORMAL);
+ // Only re-enable updates once the workspace is back to normal, which will be after the
+ // current frame.
+ post(dragView::resumeColorExtraction);
};
dragLayer.animateView(d.dragView, to, scale, 0.1f, 0.1f,
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 204913a..1555e98 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -104,6 +104,10 @@
@ViewDebug.ExportedProperty(category = "launcher")
protected int mCurrentPage;
+ // Difference between current scroll position and mCurrentPage's page scroll. Used to maintain
+ // relative scroll position unchanged in updateCurrentPageScroll. Cleared when snapping to a
+ // page.
+ protected int mCurrentPageScrollDiff;
@ViewDebug.ExportedProperty(category = "launcher")
protected int mNextPage = INVALID_PAGE;
@@ -247,7 +251,7 @@
// If the current page is invalid, just reset the scroll position to zero
int newPosition = 0;
if (0 <= mCurrentPage && mCurrentPage < getPageCount()) {
- newPosition = getScrollForPage(mCurrentPage);
+ newPosition = getScrollForPage(mCurrentPage) + mCurrentPageScrollDiff;
}
mOrientationHandler.set(this, VIEW_SCROLL_TO, newPosition);
mScroller.startScroll(mScroller.getCurrX(), 0, newPosition - mScroller.getCurrX(), 0);
@@ -452,6 +456,7 @@
* to provide custom behavior during animation.
*/
protected void onPageEndTransition() {
+ mCurrentPageScrollDiff = 0;
AccessibilityManagerCompat.sendScrollFinishedEventToTest(getContext());
AccessibilityManagerCompat.sendCustomAccessibilityEvent(getPageAt(mCurrentPage),
AccessibilityEvent.TYPE_VIEW_FOCUSED, null);
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index f412f92..5689394 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -1833,8 +1833,11 @@
onDropExternal(touchXY, dropTargetLayout, d);
} else {
final View cell = mDragInfo.cell;
+ final DragView dragView = d.dragView;
boolean droppedOnOriginalCellDuringTransition = false;
- Runnable onCompleteRunnable = null;
+ Runnable onCompleteRunnable = dragView::resumeColorExtraction;
+
+ dragView.disableColorExtraction();
if (dropTargetLayout != null && !d.cancelled) {
// Move internally
@@ -1945,7 +1948,9 @@
AppWidgetProviderInfo pInfo = hostView.getAppWidgetInfo();
if (pInfo != null && pInfo.resizeMode != AppWidgetProviderInfo.RESIZE_NONE
&& !options.isAccessibleDrag) {
+ final Runnable previousRunnable = onCompleteRunnable;
onCompleteRunnable = () -> {
+ previousRunnable.run();
if (!isPageInTransition()) {
AppWidgetResizeFrame.showForWidget(hostView, cellLayout);
}
@@ -2014,7 +2019,7 @@
parent.onDropChild(cell);
mLauncher.getStateManager().goToState(NORMAL, SPRING_LOADED_EXIT_DELAY,
- onCompleteRunnable == null ? null : forSuccessCallback(onCompleteRunnable));
+ forSuccessCallback(onCompleteRunnable));
mStatsLogManager.logger().withItemInfo(d.dragInfo).withInstanceId(d.logInstanceId)
.log(LauncherEvent.LAUNCHER_ITEM_DROP_COMPLETED);
}
diff --git a/src/com/android/launcher3/dragndrop/DragView.java b/src/com/android/launcher3/dragndrop/DragView.java
index fb1a6be..3f941e1 100644
--- a/src/com/android/launcher3/dragndrop/DragView.java
+++ b/src/com/android/launcher3/dragndrop/DragView.java
@@ -63,6 +63,7 @@
import com.android.launcher3.util.RunnableList;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.BaseDragLayer;
+import com.android.launcher3.widget.LauncherAppWidgetHostView;
/** A custom view for rendering an icon, folder, shortcut or widget during drag-n-drop. */
public abstract class DragView<T extends Context & ActivityContext> extends FrameLayout {
@@ -467,6 +468,24 @@
}
/**
+ * If the drag view uses color extraction, block it.
+ */
+ public void disableColorExtraction() {
+ if (mContent instanceof LauncherAppWidgetHostView) {
+ ((LauncherAppWidgetHostView) mContent).disableColorExtraction();
+ }
+ }
+
+ /**
+ * If the drag view uses color extraction, restores it.
+ */
+ public void resumeColorExtraction() {
+ if (mContent instanceof LauncherAppWidgetHostView) {
+ ((LauncherAppWidgetHostView) mContent).enableColorExtraction(/* updateColors= */ false);
+ }
+ }
+
+ /**
* Removes this view from the {@link DragLayer}.
*
* <p>If the drag content is a {@link #mContent}, this call doesn't reattach the
diff --git a/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java b/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java
index fa50dfb..bee32ff 100644
--- a/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java
+++ b/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java
@@ -98,6 +98,7 @@
private final ViewGroupFocusHelper mDragLayerRelativeCoordinateHelper;
private long mDeferUpdatesUntilMillis = 0;
private RemoteViews mMostRecentRemoteViews;
+ private boolean mEnableColorExtraction = true;
public LauncherAppWidgetHostView(Context context) {
super(context);
@@ -282,12 +283,7 @@
super.onLayout(changed, left, top, right, bottom);
mIsScrollable = checkScrollableRecursively(this);
- if (!mIsInDragMode && getTag() instanceof LauncherAppWidgetInfo) {
- LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) getTag();
- mDragLayerRelativeCoordinateHelper.viewToRect(this, mCurrentWidgetSize);
- updateColorExtraction(mCurrentWidgetSize,
- mWorkspace.getPageIndexForScreenId(info.screenId));
- }
+ updateColorExtraction();
}
/** Starts the drag mode. */
@@ -314,6 +310,7 @@
* @param pageId The workspace page the widget is on.
*/
private void updateColorExtraction(Rect rectInDragLayer, int pageId) {
+ if (!mEnableColorExtraction) return;
mColorExtractor.getExtractedRectForViewRect(mLauncher, pageId, rectInDragLayer, mTempRectF);
if (mTempRectF.isEmpty()) {
@@ -328,6 +325,38 @@
}
}
+ /**
+ * Update the color extraction, using the current position of the app widget.
+ */
+ private void updateColorExtraction() {
+ if (!mIsInDragMode && getTag() instanceof LauncherAppWidgetInfo) {
+ LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) getTag();
+ mDragLayerRelativeCoordinateHelper.viewToRect(this, mCurrentWidgetSize);
+ updateColorExtraction(mCurrentWidgetSize,
+ mWorkspace.getPageIndexForScreenId(info.screenId));
+ }
+ }
+
+ /**
+ * Enables the local color extraction.
+ *
+ * @param updateColors If true, this will update the color extraction using the current location
+ * of the App Widget.
+ */
+ public void enableColorExtraction(boolean updateColors) {
+ mEnableColorExtraction = true;
+ if (updateColors) {
+ updateColorExtraction();
+ }
+ }
+
+ /**
+ * Disables the local color extraction.
+ */
+ public void disableColorExtraction() {
+ mEnableColorExtraction = false;
+ }
+
// Compare two location rectangles. Locations are always in the [0;1] range.
private static boolean isSameLocation(@NonNull RectF rect1, @Nullable RectF rect2,
float epsilon) {