summaryrefslogtreecommitdiff
path: root/src/com/android/launcher3/MultipageCellLayout.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/MultipageCellLayout.java')
-rw-r--r--src/com/android/launcher3/MultipageCellLayout.java63
1 files changed, 48 insertions, 15 deletions
diff --git a/src/com/android/launcher3/MultipageCellLayout.java b/src/com/android/launcher3/MultipageCellLayout.java
index 44a1414d21..0ec9034cc7 100644
--- a/src/com/android/launcher3/MultipageCellLayout.java
+++ b/src/com/android/launcher3/MultipageCellLayout.java
@@ -23,9 +23,11 @@ import android.util.AttributeSet;
import android.view.View;
import com.android.launcher3.celllayout.CellLayoutLayoutParams;
+import com.android.launcher3.celllayout.ItemConfiguration;
import com.android.launcher3.celllayout.MulticellReorderAlgorithm;
import com.android.launcher3.util.CellAndSpan;
import com.android.launcher3.util.GridOccupancy;
+import com.android.launcher3.util.MultiTranslateDelegate;
/**
* CellLayout that simulates a split in the middle for use in foldable devices.
@@ -54,17 +56,6 @@ public class MultipageCellLayout extends CellLayout {
}
@Override
- public void getDirectionVectorForDrop(int dragViewCenterX, int dragViewCenterY, int spanX,
- int spanY, View dragView, int[] resultDirection) {
- createReorderAlgorithm().simulateSeam(
- () -> {
- super.getDirectionVectorForDrop(dragViewCenterX, dragViewCenterY, spanX, spanY,
- dragView, resultDirection);
- return 0;
- });
- }
-
- @Override
public boolean isNearestDropLocationOccupied(int pixelX, int pixelY, int spanX, int spanY,
View dragView, int[] result) {
return createReorderAlgorithm().simulateSeam(
@@ -118,7 +109,7 @@ public class MultipageCellLayout extends CellLayout {
}
@Override
- public void copyCurrentStateToSolution(ItemConfiguration solution, boolean temp) {
+ public void copyCurrentStateToSolution(ItemConfiguration solution) {
int childCount = mShortcutsAndWidgets.getChildCount();
for (int i = 0; i < childCount; i++) {
View child = mShortcutsAndWidgets.getChildAt(i);
@@ -139,18 +130,59 @@ public class MultipageCellLayout extends CellLayout {
@Override
protected void onDraw(Canvas canvas) {
+ float animatedWorkspaceMargin = mSpaceBetweenCellLayoutsPx * mSpringLoadedProgress;
if (mLeftBackground.getAlpha() > 0) {
+ canvas.save();
+ canvas.translate(-animatedWorkspaceMargin, 0);
mLeftBackground.setState(mBackground.getState());
mLeftBackground.draw(canvas);
+ canvas.restore();
}
if (mRightBackground.getAlpha() > 0) {
+ canvas.save();
+ canvas.translate(animatedWorkspaceMargin, 0);
mRightBackground.setState(mBackground.getState());
mRightBackground.draw(canvas);
+ canvas.restore();
}
-
super.onDraw(canvas);
}
+ private void updateMarginBetweenCellLayouts() {
+ for (int i = 0; i < mShortcutsAndWidgets.getChildCount(); i++) {
+ View workspaceItem = mShortcutsAndWidgets.getChildAt(i);
+ if (!(workspaceItem instanceof Reorderable)) {
+ continue;
+ }
+ CellLayoutLayoutParams params =
+ (CellLayoutLayoutParams) workspaceItem.getLayoutParams();
+ ((Reorderable) workspaceItem).getTranslateDelegate().setTranslation(
+ MultiTranslateDelegate.INDEX_CELLAYOUT_MULTIPAGE_SPACING,
+ getMarginForGivenCellParams(params),
+ 0
+ );
+
+ }
+ }
+
+ @Override
+ protected float getMarginForGivenCellParams(CellLayoutLayoutParams params) {
+ float margin = mSpaceBetweenCellLayoutsPx * mSpringLoadedProgress;
+ return params.getCellX() >= mCountX / 2 ? margin : -margin;
+ }
+
+ @Override
+ public void setSpringLoadedProgress(float progress) {
+ super.setSpringLoadedProgress(progress);
+ updateMarginBetweenCellLayouts();
+ }
+
+ @Override
+ public void setSpaceBetweenCellLayoutsPx(int spaceBetweenCellLayoutsPx) {
+ super.setSpaceBetweenCellLayoutsPx(spaceBetweenCellLayoutsPx);
+ updateMarginBetweenCellLayouts();
+ }
+
@Override
protected void updateBgAlpha() {
mLeftBackground.setAlpha((int) (mSpringLoadedProgress * 255));
@@ -161,8 +193,9 @@ public class MultipageCellLayout extends CellLayout {
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
Rect rect = mBackground.getBounds();
- mLeftBackground.setBounds(rect.left, rect.top, rect.right / 2 - 20, rect.bottom);
- mRightBackground.setBounds(rect.right / 2 + 20, rect.top, rect.right, rect.bottom);
+ int middlePointInPixels = rect.centerX();
+ mLeftBackground.setBounds(rect.left, rect.top, middlePointInPixels, rect.bottom);
+ mRightBackground.setBounds(middlePointInPixels, rect.top, rect.right, rect.bottom);
}
public void setCountX(int countX) {