Merge "Adding support for LauncherAppWidgetHostView in CellLayout" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
50b4ddc3f0
@@ -65,6 +65,7 @@ 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.model.data.LauncherAppWidgetInfo;
|
||||
import com.android.launcher3.util.CellAndSpan;
|
||||
import com.android.launcher3.util.GridOccupancy;
|
||||
import com.android.launcher3.util.ParcelableSparseArray;
|
||||
@@ -290,7 +291,7 @@ public class CellLayout extends ViewGroup {
|
||||
|
||||
for (int i = 0; i < mDragOutlineAnims.length; i++) {
|
||||
final InterruptibleInOutAnimator anim =
|
||||
new InterruptibleInOutAnimator(duration, fromAlphaValue, toAlphaValue);
|
||||
new InterruptibleInOutAnimator(duration, fromAlphaValue, toAlphaValue);
|
||||
anim.getAnimator().setInterpolator(mEaseOutInterpolator);
|
||||
final int thisIndex = i;
|
||||
anim.getAnimator().addUpdateListener(new AnimatorUpdateListener() {
|
||||
@@ -2440,7 +2441,7 @@ public class CellLayout extends ViewGroup {
|
||||
|
||||
// First we determine if things have moved enough to cause a different layout
|
||||
ItemConfiguration swapSolution = findReorderSolution(pixelXY[0], pixelXY[1], spanX, spanY,
|
||||
spanX, spanY, direction, dragView, true, new ItemConfiguration());
|
||||
spanX, spanY, direction, dragView, true, new ItemConfiguration());
|
||||
|
||||
setUseTempCoords(true);
|
||||
if (swapSolution != null && swapSolution.isSolution) {
|
||||
@@ -2477,7 +2478,7 @@ public class CellLayout extends ViewGroup {
|
||||
// direction vector, since we want the solution to match the preview, and it's possible
|
||||
// that the exact position of the item has changed to result in a new reordering outcome.
|
||||
if ((mode == MODE_ON_DROP || mode == MODE_ON_DROP_EXTERNAL || mode == MODE_ACCEPT_DROP)
|
||||
&& mPreviousReorderDirection[0] != INVALID_DIRECTION) {
|
||||
&& mPreviousReorderDirection[0] != INVALID_DIRECTION) {
|
||||
mDirectionVector[0] = mPreviousReorderDirection[0];
|
||||
mDirectionVector[1] = mPreviousReorderDirection[1];
|
||||
// We reset this vector after drop
|
||||
@@ -2493,7 +2494,7 @@ public class CellLayout extends ViewGroup {
|
||||
|
||||
// Find a solution involving pushing / displacing any items in the way
|
||||
ItemConfiguration swapSolution = findReorderSolution(pixelX, pixelY, minSpanX, minSpanY,
|
||||
spanX, spanY, mDirectionVector, dragView, true, new ItemConfiguration());
|
||||
spanX, spanY, mDirectionVector, dragView, true, new ItemConfiguration());
|
||||
|
||||
// We attempt the approach which doesn't shuffle views at all
|
||||
ItemConfiguration noShuffleSolution = findConfigurationNoShuffle(pixelX, pixelY, minSpanX,
|
||||
@@ -2733,12 +2734,24 @@ public class CellLayout extends ViewGroup {
|
||||
}
|
||||
|
||||
public void markCellsAsOccupiedForView(View view) {
|
||||
if (view instanceof LauncherAppWidgetHostView
|
||||
&& view.getTag() instanceof LauncherAppWidgetInfo) {
|
||||
LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) view.getTag();
|
||||
mOccupied.markCells(info.cellX, info.cellY, info.spanX, info.spanY, true);
|
||||
return;
|
||||
}
|
||||
if (view == null || view.getParent() != mShortcutsAndWidgets) return;
|
||||
LayoutParams lp = (LayoutParams) view.getLayoutParams();
|
||||
mOccupied.markCells(lp.cellX, lp.cellY, lp.cellHSpan, lp.cellVSpan, true);
|
||||
}
|
||||
|
||||
public void markCellsAsUnoccupiedForView(View view) {
|
||||
if (view instanceof LauncherAppWidgetHostView
|
||||
&& view.getTag() instanceof LauncherAppWidgetInfo) {
|
||||
LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) view.getTag();
|
||||
mOccupied.markCells(info.cellX, info.cellY, info.spanX, info.spanY, false);
|
||||
return;
|
||||
}
|
||||
if (view == null || view.getParent() != mShortcutsAndWidgets) return;
|
||||
LayoutParams lp = (LayoutParams) view.getLayoutParams();
|
||||
mOccupied.markCells(lp.cellX, lp.cellY, lp.cellHSpan, lp.cellVSpan, false);
|
||||
|
||||
Reference in New Issue
Block a user