Merge "Use TOUCHABLE_INSETS_REGION when IME is visible" into sc-v2-dev
diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java
index ae3cc50..6addfe3 100644
--- a/quickstep/src/com/android/quickstep/TaskViewUtils.java
+++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java
@@ -32,7 +32,6 @@
import static com.android.launcher3.Utilities.getDescendantCoordRelativeToAncestor;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.TOUCH_RESPONSE_INTERPOLATOR;
-import static com.android.launcher3.anim.Interpolators.TOUCH_RESPONSE_INTERPOLATOR_ACCEL_DEACCEL;
import static com.android.launcher3.anim.Interpolators.clampToProgress;
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.launcher3.statehandlers.DepthController.DEPTH;
@@ -193,7 +192,6 @@
boolean showAsGrid = dp.overviewShowAsGrid;
boolean parallaxCenterAndAdjacentTask =
taskIndex != recentsView.getCurrentPage() && !showAsGrid;
- float gridTranslationSecondary = recentsView.getGridTranslationSecondary(taskIndex);
int startScroll = recentsView.getScrollOffset(taskIndex);
RemoteTargetHandle[] topMostSimulators = null;
@@ -211,11 +209,9 @@
tvsLocal.fullScreenProgress.value = 0;
tvsLocal.recentsViewScale.value = 1;
- if (showAsGrid) {
- tvsLocal.taskSecondaryTranslation.value = gridTranslationSecondary;
- }
tvsLocal.setScroll(startScroll);
tvsLocal.setIsGridTask(v.isGridTask());
+ tvsLocal.setGridTranslationY(v.getGridTranslationY());
// Fade in the task during the initial 20% of the animation
out.addFloat(targetHandle.getTransformParams(), TransformParams.TARGET_ALPHA, 0, 1,
@@ -230,10 +226,6 @@
out.setFloat(tvsLocal.recentsViewScale,
AnimatedFloat.VALUE, tvsLocal.getFullScreenScale(),
TOUCH_RESPONSE_INTERPOLATOR);
- if (showAsGrid) {
- out.setFloat(tvsLocal.taskSecondaryTranslation, AnimatedFloat.VALUE, 0,
- TOUCH_RESPONSE_INTERPOLATOR_ACCEL_DEACCEL);
- }
out.setFloat(tvsLocal.recentsViewScroll, AnimatedFloat.VALUE, 0,
TOUCH_RESPONSE_INTERPOLATOR);
diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
index eff59e2..95095fa 100644
--- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
+++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
@@ -16,6 +16,7 @@
package com.android.quickstep.fallback;
import static com.android.quickstep.GestureState.GestureEndTarget.RECENTS;
+import static com.android.quickstep.ViewUtils.postFrameDrawn;
import static com.android.quickstep.fallback.RecentsState.DEFAULT;
import static com.android.quickstep.fallback.RecentsState.HOME;
import static com.android.quickstep.fallback.RecentsState.MODAL_TASK;
@@ -218,8 +219,14 @@
@Override
public void onStateTransitionComplete(RecentsState finalState) {
- setOverlayEnabled(finalState == DEFAULT || finalState == MODAL_TASK);
+ boolean isOverlayEnabled = finalState == DEFAULT || finalState == MODAL_TASK;
+ setOverlayEnabled(isOverlayEnabled);
setFreezeViewVisibility(false);
+
+ if (isOverlayEnabled) {
+ postFrameDrawn(this, () -> runActionOnRemoteHandles(remoteTargetHandle ->
+ remoteTargetHandle.getTaskViewSimulator().setDrawsBelowRecents(true)));
+ }
}
@Override
diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java
index 146d235..7d396ba 100644
--- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java
+++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java
@@ -102,6 +102,7 @@
private StagedSplitBounds mStagedSplitBounds;
private boolean mDrawsBelowRecents;
private boolean mIsGridTask;
+ private float mGridTranslationY;
public TaskViewSimulator(Context context, BaseActivityInterface sizeStrategy) {
mContext = context;
@@ -156,9 +157,15 @@
fullTaskSize = new Rect(mTaskRect);
mOrientationState.getOrientationHandler()
.setSplitTaskSwipeRect(mDp, mTaskRect, mStagedSplitBounds, mStagePosition);
+ if (mIsGridTask) {
+ mTaskRect.offset(0, (int) mGridTranslationY);
+ }
} else {
fullTaskSize = mTaskRect;
}
+ if (mIsGridTask) {
+ fullTaskSize.offset(0, (int) mGridTranslationY);
+ }
return mOrientationState.getFullScreenScaleAndPivot(fullTaskSize, mDp, mPivot);
}
@@ -218,6 +225,13 @@
}
/**
+ * Sets the y-translation when overview is in grid.
+ */
+ public void setGridTranslationY(float gridTranslationY) {
+ mGridTranslationY = gridTranslationY;
+ }
+
+ /**
* Adds animation for all the components corresponding to transition from an app to overview.
*/
public void addAppToOverviewAnim(PendingAnimation pa, TimeInterpolator interpolator) {
@@ -320,14 +334,12 @@
mMatrix.postTranslate(insets.left, insets.top);
mMatrix.postScale(scale, scale);
- // Apply TaskView matrix: translate, scroll
+ // Apply TaskView matrix: taskRect, translate
mMatrix.postTranslate(mTaskRect.left, mTaskRect.top);
mOrientationState.getOrientationHandler().set(mMatrix, MATRIX_POST_TRANSLATE,
taskPrimaryTranslation.value);
mOrientationState.getOrientationHandler().setSecondary(mMatrix, MATRIX_POST_TRANSLATE,
taskSecondaryTranslation.value);
- mOrientationState.getOrientationHandler().set(
- mMatrix, MATRIX_POST_TRANSLATE, recentsViewScroll.value);
// Apply RecentsView matrix
mMatrix.postScale(recentsViewScale.value, recentsViewScale.value, mPivot.x, mPivot.y);
@@ -335,6 +347,8 @@
recentsViewSecondaryTranslation.value);
mOrientationState.getOrientationHandler().set(mMatrix, MATRIX_POST_TRANSLATE,
recentsViewPrimaryTranslation.value);
+ mOrientationState.getOrientationHandler().set(
+ mMatrix, MATRIX_POST_TRANSLATE, recentsViewScroll.value);
applyWindowToHomeRotation(mMatrix);
// Crop rect is the inverse of thumbnail matrix
diff --git a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java
index 30b55a8..df99d27 100644
--- a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java
+++ b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java
@@ -74,7 +74,7 @@
}
public void bind(Task primary, Task secondary, RecentsOrientedState orientedState,
- StagedSplitBounds splitBoundsConfig) {
+ @Nullable StagedSplitBounds splitBoundsConfig) {
super.bind(primary, orientedState);
mSecondaryTask = secondary;
mTaskIdContainer[1] = secondary.key.id;
diff --git a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
index 5d6b656..3cba392 100644
--- a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
@@ -21,6 +21,7 @@
import static com.android.launcher3.LauncherState.OVERVIEW_MODAL_TASK;
import static com.android.launcher3.LauncherState.OVERVIEW_SPLIT_SELECT;
import static com.android.launcher3.LauncherState.SPRING_LOADED;
+import static com.android.quickstep.ViewUtils.postFrameDrawn;
import android.annotation.TargetApi;
import android.content.Context;
@@ -104,8 +105,14 @@
@Override
public void onStateTransitionComplete(LauncherState finalState) {
- setOverlayEnabled(finalState == OVERVIEW || finalState == OVERVIEW_MODAL_TASK);
+ boolean isOverlayEnabled = finalState == OVERVIEW || finalState == OVERVIEW_MODAL_TASK;
+ setOverlayEnabled(isOverlayEnabled);
setFreezeViewVisibility(false);
+
+ if (isOverlayEnabled) {
+ postFrameDrawn(this, () -> runActionOnRemoteHandles(remoteTargetHandle ->
+ remoteTargetHandle.getTaskViewSimulator().setDrawsBelowRecents(true)));
+ }
}
@Override
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 0188962..7b5a6b9 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -838,6 +838,7 @@
* Update the thumbnail of the task.
* @param refreshNow Refresh immediately if it's true.
*/
+ @Nullable
public TaskView updateThumbnail(int taskId, ThumbnailData thumbnailData, boolean refreshNow) {
TaskView taskView = getTaskViewByTaskId(taskId);
if (taskView != null) {
@@ -1043,6 +1044,7 @@
return getLastGridTaskView(getTopRowIdArray(), getBottomRowIdArray());
}
+ @Nullable
private TaskView getLastGridTaskView(IntArray topRowIdArray, IntArray bottomRowIdArray) {
if (topRowIdArray.isEmpty() && bottomRowIdArray.isEmpty()) {
return null;
@@ -1506,17 +1508,6 @@
}
}
if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
- // Since we reuse the same mLiveTileTaskViewSimulator in the RecentsView, we need
- // to reset the params after it settles in Overview from swipe up so that we don't
- // render with obsolete param values.
- runActionOnRemoteHandles(remoteTargetHandle -> {
- TaskViewSimulator simulator = remoteTargetHandle.getTaskViewSimulator();
- simulator.taskPrimaryTranslation.value = 0;
- simulator.taskSecondaryTranslation.value = 0;
- simulator.fullScreenProgress.value = 0;
- simulator.recentsViewScale.value = 1;
- });
-
// Similar to setRunningTaskHidden below, reapply the state before runningTaskView is
// null.
if (!mRunningTaskShowScreenshot) {
@@ -1904,7 +1895,7 @@
setEnableDrawingLiveTile(false);
runActionOnRemoteHandles(remoteTargetHandle -> {
remoteTargetHandle.getTransformParams().setTargetSet(null);
- remoteTargetHandle.getTaskViewSimulator().setDrawsBelowRecents(true);
+ remoteTargetHandle.getTaskViewSimulator().setDrawsBelowRecents(false);
});
mSplitSelectStateController.resetState();
@@ -3014,6 +3005,10 @@
@SuppressWarnings("WrongCall")
private void onEnd(boolean success) {
+ // Reset task translations as they may have updated via animations in
+ // createTaskDismissAnimation
+ resetTaskVisuals();
+
if (success) {
if (shouldRemoveTask) {
if (dismissedTaskView.getTask() != null) {
@@ -3030,10 +3025,6 @@
}
}
- // Reset task translations as they may have updated via animations in
- // createTaskDismissAnimation
- resetTaskVisuals();
-
int pageToSnapTo = mCurrentPage;
mCurrentPageScrollDiff = 0;
int taskViewIdToSnapTo = -1;
@@ -4387,7 +4378,6 @@
TaskViewSimulator tvs = remoteTargetHandle.getTaskViewSimulator();
tvs.setOrientationState(mOrientationState);
tvs.setDp(mActivity.getDeviceProfile());
- tvs.setDrawsBelowRecents(true);
tvs.recentsViewScale.value = 1;
}
}
@@ -4689,20 +4679,6 @@
return position != -1 ? position : bottomRowIdArray.indexOf(taskView.getTaskViewId());
}
- /**
- * Returns how many pixels the task is offset on the currently laid out secondary axis
- * according to {@link #mGridProgress}.
- */
- public float getGridTranslationSecondary(int pageIndex) {
- TaskView taskView = getTaskViewAt(pageIndex);
- if (taskView == null) {
- return 0;
- }
-
- return mOrientationHandler.getSecondaryValue(taskView.getGridTranslationX(),
- taskView.getGridTranslationY());
- }
-
public Consumer<MotionEvent> getEventDispatcher(float navbarRotation) {
float degreesRotated;
if (navbarRotation == 0) {
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index 3da7893..e9a3779 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -648,21 +648,7 @@
recentsView.getDepthController());
anim.addListener(new AnimatorListenerAdapter() {
@Override
- public void onAnimationStart(Animator animator) {
- recentsView.runActionOnRemoteHandles(
- (Consumer<RemoteTargetHandle>) remoteTargetHandle ->
- remoteTargetHandle
- .getTaskViewSimulator()
- .setDrawsBelowRecents(false));
- }
-
- @Override
public void onAnimationEnd(Animator animator) {
- recentsView.runActionOnRemoteHandles(
- (Consumer<RemoteTargetHandle>) remoteTargetHandle ->
- remoteTargetHandle
- .getTaskViewSimulator()
- .setDrawsBelowRecents(true));
mIsClickableAsLiveTile = true;
}
});
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 02eb1de..adb1613 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -19,6 +19,8 @@
import static android.animation.ValueAnimator.areAnimatorsEnabled;
import static com.android.launcher3.anim.Interpolators.DEACCEL_1_5;
+import static com.android.launcher3.dragndrop.DraggableView.DRAGGABLE_ICON;
+import static com.android.launcher3.icons.IconNormalizer.ICON_VISIBLE_AREA_FACTOR;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -37,7 +39,6 @@
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
-import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Parcelable;
import android.util.ArrayMap;
@@ -61,6 +62,7 @@
import com.android.launcher3.accessibility.DragAndDropAccessibilityDelegate;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.config.FeatureFlags;
+import com.android.launcher3.dragndrop.DraggableView;
import com.android.launcher3.folder.PreviewBackground;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.util.CellAndSpan;
@@ -442,18 +444,43 @@
}
if (DEBUG_VISUALIZE_OCCUPIED) {
- int[] pt = new int[2];
- ColorDrawable cd = new ColorDrawable(Color.RED);
- cd.setBounds(0, 0, mCellWidth, mCellHeight);
- for (int i = 0; i < mCountX; i++) {
- for (int j = 0; j < mCountY; j++) {
- if (mOccupied.cells[i][j]) {
- cellToPoint(i, j, pt);
- canvas.save();
- canvas.translate(pt[0], pt[1]);
- cd.draw(canvas);
- canvas.restore();
+ Rect cellBounds = new Rect();
+ // Will contain the bounds of the cell including spacing between cells.
+ Rect cellBoundsWithSpacing = new Rect();
+ int[] targetCell = new int[2];
+ int[] cellCenter = new int[2];
+ Paint debugPaint = new Paint();
+ debugPaint.setStrokeWidth(Utilities.dpToPx(1));
+ for (int x = 0; x < mCountX; x++) {
+ for (int y = 0; y < mCountY; y++) {
+ if (!mOccupied.cells[x][y]) {
+ continue;
}
+ targetCell[0] = x;
+ targetCell[1] = y;
+
+ boolean canCreateFolder = canCreateFolder(getChildAt(x, y));
+ cellToRect(x, y, 1, 1, cellBounds);
+ cellBoundsWithSpacing.set(cellBounds);
+ cellBoundsWithSpacing.inset(-mBorderSpace.x / 2, -mBorderSpace.y / 2);
+ getWorkspaceCellVisualCenter(x, y, cellCenter);
+
+ canvas.save();
+ canvas.clipRect(cellBoundsWithSpacing);
+
+ // Draw reorder drag target.
+ debugPaint.setColor(Color.RED);
+ canvas.drawCircle(cellCenter[0], cellCenter[1], getReorderRadius(targetCell),
+ debugPaint);
+
+ // Draw folder creation drag target.
+ if (canCreateFolder) {
+ debugPaint.setColor(Color.GREEN);
+ canvas.drawCircle(cellCenter[0], cellCenter[1],
+ getFolderCreationRadius(targetCell), debugPaint);
+ }
+
+ canvas.restore();
}
}
}
@@ -482,6 +509,14 @@
}
/**
+ * Returns whether dropping an icon on the given View can create (or add to) a folder.
+ */
+ private boolean canCreateFolder(View child) {
+ return child instanceof DraggableView
+ && ((DraggableView) child).getViewType() == DRAGGABLE_ICON;
+ }
+
+ /**
* Indicates the progress of the Workspace entering the SpringLoaded state; allows the
* CellLayout to update various visuals for this state.
*
@@ -817,7 +852,7 @@
}
/**
- * Given a cell coordinate and span return the point that represents the center of the regio
+ * Given a cell coordinate and span return the point that represents the center of the region
*
* @param cellX X coordinate of the cell
* @param cellY Y coordinate of the cell
@@ -830,11 +865,65 @@
result[1] = mTempRect.centerY();
}
- public float getDistanceFromCell(float x, float y, int[] cell) {
- cellToCenterPoint(cell[0], cell[1], mTmpPoint);
+ /**
+ * Returns the distance between the given coordinate and the visual center of the given cell.
+ */
+ public float getDistanceFromWorkspaceCellVisualCenter(float x, float y, int[] cell) {
+ getWorkspaceCellVisualCenter(cell[0], cell[1], mTmpPoint);
return (float) Math.hypot(x - mTmpPoint[0], y - mTmpPoint[1]);
}
+ private void getWorkspaceCellVisualCenter(int cellX, int cellY, int[] outPoint) {
+ View child = getChildAt(cellX, cellY);
+ if (child instanceof DraggableView) {
+ DraggableView draggableChild = (DraggableView) child;
+ if (draggableChild.getViewType() == DRAGGABLE_ICON) {
+ cellToPoint(cellX, cellY, outPoint);
+ draggableChild.getWorkspaceVisualDragBounds(mTempRect);
+ mTempRect.offset(outPoint[0], outPoint[1]);
+ outPoint[0] = mTempRect.centerX();
+ outPoint[1] = mTempRect.centerY();
+ return;
+ }
+ }
+ cellToCenterPoint(cellX, cellY, outPoint);
+ }
+
+ /**
+ * Returns the max distance from the center of a cell that can accept a drop to create a folder.
+ */
+ public float getFolderCreationRadius(int[] targetCell) {
+ DeviceProfile grid = mActivity.getDeviceProfile();
+ float iconVisibleRadius = ICON_VISIBLE_AREA_FACTOR * grid.iconSizePx / 2;
+ // Halfway between reorder radius and icon.
+ return (getReorderRadius(targetCell) + iconVisibleRadius) / 2;
+ }
+
+ /**
+ * Returns the max distance from the center of a cell that will start to reorder on drag over.
+ */
+ public float getReorderRadius(int[] targetCell) {
+ int[] centerPoint = mTmpPoint;
+ getWorkspaceCellVisualCenter(targetCell[0], targetCell[1], centerPoint);
+
+ Rect cellBoundsWithSpacing = mTempRect;
+ cellToRect(targetCell[0], targetCell[1], 1, 1, cellBoundsWithSpacing);
+ cellBoundsWithSpacing.inset(-mBorderSpace.x / 2, -mBorderSpace.y / 2);
+
+ if (canCreateFolder(getChildAt(targetCell[0], targetCell[1]))) {
+ // Take only the circle in the smaller dimension, to ensure we don't start reordering
+ // too soon before accepting a folder drop.
+ int minRadius = centerPoint[0] - cellBoundsWithSpacing.left;
+ minRadius = Math.min(minRadius, centerPoint[1] - cellBoundsWithSpacing.top);
+ minRadius = Math.min(minRadius, cellBoundsWithSpacing.right - centerPoint[0]);
+ minRadius = Math.min(minRadius, cellBoundsWithSpacing.bottom - centerPoint[1]);
+ return minRadius;
+ }
+ // Take up the entire cell, including space between this cell and the adjacent ones.
+ return (float) Math.hypot(cellBoundsWithSpacing.width() / 2f,
+ cellBoundsWithSpacing.height() / 2f);
+ }
+
public int getCellWidth() {
return mCellWidth;
}
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 5c16b4c..e64ea90 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -251,8 +251,7 @@
// Tablet UI does not support emulated landscape.
isTablet = allowRotation && info.isTablet(windowBounds);
isPhone = !isTablet;
- isTwoPanels = isTablet && useTwoPanels
- && (isLandscape || FeatureFlags.ENABLE_TWO_PANEL_HOME_IN_PORTRAIT.get());
+ isTwoPanels = isTablet && useTwoPanels;
aspectRatio = ((float) Math.max(widthPx, heightPx)) / Math.min(widthPx, heightPx);
boolean isTallDevice = Float.compare(aspectRatio, TALL_DEVICE_ASPECT_RATIO_THRESHOLD) >= 0;
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 131fbfb..203df0a 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -220,7 +220,6 @@
private FolderIcon mDragOverFolderIcon = null;
private boolean mCreateUserFolderOnDrop = false;
private boolean mAddToExistingFolderOnDrop = false;
- private float mMaxDistanceForFolderCreation;
// Variables relating to touch disambiguation (scrolling workspace vs. scrolling a widget)
private float mXDown;
@@ -308,8 +307,6 @@
public void setInsets(Rect insets) {
DeviceProfile grid = mLauncher.getDeviceProfile();
- mMaxDistanceForFolderCreation = grid.isTablet
- ? 0.75f * grid.iconSizePx : 0.55f * grid.iconSizePx;
mWorkspaceFadeInAdjacentScreens = grid.shouldFadeAdjacentWorkspaceScreens();
Rect padding = grid.workspacePadding;
@@ -1774,8 +1771,8 @@
mTargetCell = findNearestArea((int) mDragViewVisualCenter[0],
(int) mDragViewVisualCenter[1], minSpanX, minSpanY, dropTargetLayout,
mTargetCell);
- float distance = dropTargetLayout.getDistanceFromCell(mDragViewVisualCenter[0],
- mDragViewVisualCenter[1], mTargetCell);
+ float distance = dropTargetLayout.getDistanceFromWorkspaceCellVisualCenter(
+ mDragViewVisualCenter[0], mDragViewVisualCenter[1], mTargetCell);
if (mCreateUserFolderOnDrop && willCreateUserFolder(d.dragInfo,
dropTargetLayout, mTargetCell, distance, true)) {
return true;
@@ -1809,7 +1806,7 @@
boolean willCreateUserFolder(ItemInfo info, CellLayout target, int[] targetCell,
float distance, boolean considerTimeout) {
- if (distance > mMaxDistanceForFolderCreation) return false;
+ if (distance > target.getFolderCreationRadius(targetCell)) return false;
View dropOverView = target.getChildAt(targetCell[0], targetCell[1]);
return willCreateUserFolder(info, dropOverView, considerTimeout);
}
@@ -1844,7 +1841,7 @@
boolean willAddToExistingUserFolder(ItemInfo dragInfo, CellLayout target, int[] targetCell,
float distance) {
- if (distance > mMaxDistanceForFolderCreation) return false;
+ if (distance > target.getFolderCreationRadius(targetCell)) return false;
View dropOverView = target.getChildAt(targetCell[0], targetCell[1]);
return willAddToExistingUserFolder(dragInfo, dropOverView);
@@ -1868,7 +1865,7 @@
boolean createUserFolderIfNecessary(View newView, int container, CellLayout target,
int[] targetCell, float distance, boolean external, DragObject d) {
- if (distance > mMaxDistanceForFolderCreation) return false;
+ if (distance > target.getFolderCreationRadius(targetCell)) return false;
View v = target.getChildAt(targetCell[0], targetCell[1]);
boolean hasntMoved = false;
@@ -1925,7 +1922,7 @@
boolean addToExistingFolderIfNecessary(View newView, CellLayout target, int[] targetCell,
float distance, DragObject d, boolean external) {
- if (distance > mMaxDistanceForFolderCreation) return false;
+ if (distance > target.getFolderCreationRadius(targetCell)) return false;
View dropOverView = target.getChildAt(targetCell[0], targetCell[1]);
if (!mAddToExistingFolderOnDrop) return false;
@@ -1989,8 +1986,8 @@
mTargetCell = findNearestArea((int) mDragViewVisualCenter[0], (int)
mDragViewVisualCenter[1], spanX, spanY, dropTargetLayout, mTargetCell);
- float distance = dropTargetLayout.getDistanceFromCell(mDragViewVisualCenter[0],
- mDragViewVisualCenter[1], mTargetCell);
+ float distance = dropTargetLayout.getDistanceFromWorkspaceCellVisualCenter(
+ mDragViewVisualCenter[0], mDragViewVisualCenter[1], mTargetCell);
// If the item being dropped is a shortcut and the nearest drop
// cell also contains a shortcut, then create a folder with the two shortcuts.
@@ -2418,7 +2415,7 @@
setCurrentDropOverCell(mTargetCell[0], mTargetCell[1]);
- float targetCellDistance = mDragTargetLayout.getDistanceFromCell(
+ float targetCellDistance = mDragTargetLayout.getDistanceFromWorkspaceCellVisualCenter(
mDragViewVisualCenter[0], mDragViewVisualCenter[1], mTargetCell);
manageFolderFeedback(targetCellDistance, d);
@@ -2431,8 +2428,9 @@
mDragTargetLayout.visualizeDropLocation(mTargetCell[0], mTargetCell[1],
item.spanX, item.spanY, d);
} else if ((mDragMode == DRAG_MODE_NONE || mDragMode == DRAG_MODE_REORDER)
- && !mReorderAlarm.alarmPending() && (mLastReorderX != reorderX ||
- mLastReorderY != reorderY)) {
+ && !mReorderAlarm.alarmPending()
+ && (mLastReorderX != reorderX || mLastReorderY != reorderY)
+ && targetCellDistance < mDragTargetLayout.getReorderRadius(mTargetCell)) {
int[] resultSpan = new int[2];
mDragTargetLayout.performReorder((int) mDragViewVisualCenter[0],
@@ -2529,7 +2527,7 @@
}
private void manageFolderFeedback(float distance, DragObject dragObject) {
- if (distance > mMaxDistanceForFolderCreation) {
+ if (distance > mDragTargetLayout.getFolderCreationRadius(mTargetCell)) {
if ((mDragMode == DRAG_MODE_ADD_TO_FOLDER
|| mDragMode == DRAG_MODE_CREATE_FOLDER)) {
setDragMode(DRAG_MODE_NONE);
@@ -2674,8 +2672,8 @@
if (pendingInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) {
mTargetCell = findNearestArea(touchXY[0], touchXY[1], spanX, spanY,
cellLayout, mTargetCell);
- float distance = cellLayout.getDistanceFromCell(mDragViewVisualCenter[0],
- mDragViewVisualCenter[1], mTargetCell);
+ float distance = cellLayout.getDistanceFromWorkspaceCellVisualCenter(
+ mDragViewVisualCenter[0], mDragViewVisualCenter[1], mTargetCell);
if (willCreateUserFolder(d.dragInfo, cellLayout, mTargetCell, distance, true)
|| willAddToExistingUserFolder(
d.dragInfo, cellLayout, mTargetCell, distance)) {
@@ -2774,8 +2772,8 @@
if (touchXY != null) {
mTargetCell = findNearestArea(touchXY[0], touchXY[1], spanX, spanY,
cellLayout, mTargetCell);
- float distance = cellLayout.getDistanceFromCell(mDragViewVisualCenter[0],
- mDragViewVisualCenter[1], mTargetCell);
+ float distance = cellLayout.getDistanceFromWorkspaceCellVisualCenter(
+ mDragViewVisualCenter[0], mDragViewVisualCenter[1], mTargetCell);
if (createUserFolderIfNecessary(view, container, cellLayout, mTargetCell, distance,
true, d)) {
return;
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index e253505..c4d8166 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -210,10 +210,6 @@
"ENABLE_TWO_PANEL_HOME", true,
"Uses two panel on home screen. Only applicable on large screen devices.");
- public static final BooleanFlag ENABLE_TWO_PANEL_HOME_IN_PORTRAIT = getDebugFlag(
- "ENABLE_TWO_PANEL_HOME_IN_PORTRAIT", true,
- "Uses two panel on home screen in portrait if ENABLE_TWO_PANEL_HOME is enabled.");
-
public static final BooleanFlag ENABLE_SCRIM_FOR_APP_LAUNCH = getDebugFlag(
"ENABLE_SCRIM_FOR_APP_LAUNCH", false,
"Enables scrim during app launch animation.");
diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
index 8caf886..ba9d09c 100644
--- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
+++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
@@ -451,24 +451,19 @@
public void setSplitTaskSwipeRect(DeviceProfile dp, Rect outRect,
StagedSplitBounds splitInfo, int desiredStagePosition) {
boolean isLandscape = dp.isLandscape;
- float verticalDividerDiff = splitInfo.visualDividerBounds.height() / 2f;
- float horizontalDividerDiff = splitInfo.visualDividerBounds.width() / 2f;
- float diff;
if (desiredStagePosition == SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT) {
if (isLandscape) {
- diff = outRect.width() * (1f - splitInfo.leftTaskPercent) + horizontalDividerDiff;
- outRect.right -= diff;
+ outRect.right = outRect.left + (int) (outRect.width() * splitInfo.leftTaskPercent);
} else {
- diff = outRect.height() * (1f - splitInfo.topTaskPercent) + verticalDividerDiff;
- outRect.bottom -= diff;
+ outRect.bottom = outRect.top + (int) (outRect.height() * splitInfo.topTaskPercent);
}
} else {
if (isLandscape) {
- diff = outRect.width() * splitInfo.leftTaskPercent + horizontalDividerDiff;
- outRect.left += diff;
+ outRect.left += (int) (outRect.width() *
+ (splitInfo.leftTaskPercent + splitInfo.dividerWidthPercent));
} else {
- diff = outRect.height() * splitInfo.topTaskPercent + verticalDividerDiff;
- outRect.top += diff;
+ outRect.top += (int) (outRect.height() *
+ (splitInfo.topTaskPercent + splitInfo.dividerHeightPercent));
}
}
}
@@ -479,9 +474,9 @@
StagedSplitBounds splitBoundsConfig, DeviceProfile dp) {
int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx;
int totalThumbnailHeight = parentHeight - spaceAboveSnapshot;
- int dividerBar = (splitBoundsConfig.appsStackedVertically ?
- splitBoundsConfig.visualDividerBounds.height() :
- splitBoundsConfig.visualDividerBounds.width());
+ int dividerBar = splitBoundsConfig.appsStackedVertically
+ ? (int) (splitBoundsConfig.dividerHeightPercent * parentHeight)
+ : (int) (splitBoundsConfig.dividerWidthPercent * parentWidth);
int primarySnapshotHeight;
int primarySnapshotWidth;
int secondarySnapshotHeight;
diff --git a/src/com/android/launcher3/util/SplitConfigurationOptions.java b/src/com/android/launcher3/util/SplitConfigurationOptions.java
index 6aef38f..53b1c3e 100644
--- a/src/com/android/launcher3/util/SplitConfigurationOptions.java
+++ b/src/com/android/launcher3/util/SplitConfigurationOptions.java
@@ -99,6 +99,8 @@
// This class is orientation-agnostic, so we compute both for later use
public final float topTaskPercent;
public final float leftTaskPercent;
+ public final float dividerWidthPercent;
+ public final float dividerHeightPercent;
/**
* If {@code true}, that means at the time of creation of this object, the
* split-screened apps were vertically stacked. This is useful in scenarios like
@@ -130,6 +132,8 @@
leftTaskPercent = this.leftTopBounds.width() / (float) rightBottomBounds.right;
topTaskPercent = this.leftTopBounds.height() / (float) rightBottomBounds.bottom;
+ dividerWidthPercent = visualDividerBounds.width() / (float) rightBottomBounds.right;
+ dividerHeightPercent = visualDividerBounds.height() / (float) rightBottomBounds.bottom;
}
}