Commit 692f504b authored by Amit Kumar's avatar Amit Kumar 💻
Browse files

Fix animation issue

parent 5c94abd9
Pipeline #110670 failed with stage
in 2 minutes and 49 seconds
package foundation.e.blisslauncher.core.customviews;
import static foundation.e.blisslauncher.features.test.anim.LauncherAnimUtils.SPRING_LOADED_TRANSITION_MS;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.LayoutTransition;
......@@ -24,6 +22,13 @@ import android.view.View;
import android.view.WindowInsets;
import android.widget.GridLayout;
import android.widget.Toast;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import foundation.e.blisslauncher.BuildConfig;
import foundation.e.blisslauncher.R;
import foundation.e.blisslauncher.core.customviews.pageindicators.PageIndicatorDots;
......@@ -47,10 +52,8 @@ import foundation.e.blisslauncher.features.test.dragndrop.DragView;
import foundation.e.blisslauncher.features.test.dragndrop.DropTarget;
import foundation.e.blisslauncher.features.test.dragndrop.SpringLoadedDragController;
import foundation.e.blisslauncher.features.test.graphics.DragPreviewProvider;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.jetbrains.annotations.NotNull;
import static foundation.e.blisslauncher.features.test.anim.LauncherAnimUtils.SPRING_LOADED_TRANSITION_MS;
public class LauncherPagedView extends PagedView<PageIndicatorDots> implements View.OnTouchListener,
Insettable, DropTarget, DragSource, DragController.DragListener {
......@@ -664,6 +667,10 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
* @param y The Y position of the child in the screen's grid.
*/
private void addInScreen(View child, long container, long screenId, int x, int y) {
Log.d(
TAG,
"addInScreen() called with: child = [" + child + "], container = [" + container + "], screenId = [" + screenId + "], x = [" + x + "], y = [" + y + "]"
);
addInScreen(child, container, screenId, y * mLauncher.getDeviceProfile().getInv().getNumColumns() + x);
}
......@@ -724,7 +731,7 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
child,
index,
childId,
((CellLayout.LayoutParams) genericLp),
genericLp,
markCellsAsOccupied
)) {
// TODO: This branch occurs when the workspace is adding views
......@@ -732,6 +739,7 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
// maybe we should be deleting these items from the LauncherModel?
}
child.setHapticFeedbackEnabled(false);
child.setOnLongClickListener(ItemLongClickListener.INSTANCE_WORKSPACE);
if (child instanceof DropTarget) {
......@@ -1187,6 +1195,7 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
} else if (BuildConfig.DEBUG) {
throw new NullPointerException("mDragInfo.cell has null parent");
}
addInScreen(cell, container, screenId, mTargetCell[0], mTargetCell[1]);
}
......@@ -1220,9 +1229,11 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
}
final LauncherItem info = (LauncherItem) cell.getTag();
int duration = snapScreen < 0 ? -1 : ADJACENT_SCREEN_DROP_DURATION;
mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, cell, duration,
this
);
Log.i(TAG, "onDrop: Here it comes too");
} else {
d.deferDragViewCleanupPostAnimation = false;
cell.setVisibility(VISIBLE);
......
......@@ -500,6 +500,10 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
@SuppressLint("DrawAllocation")
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
Log.d(
TAG,
"onLayout() called with: changed = [" + changed + "], left = [" + left + "], top = [" + top + "], right = [" + right + "], bottom = [" + bottom + "]"
);
mIsLayoutValid = true;
final int childCount = getChildCount();
boolean pageScrollChanged = false;
......
......@@ -166,9 +166,14 @@ public abstract class BaseDragLayer<T extends BaseDraggingActivity> extends Inse
int x = loc[0];
int y = loc[1];
int[] temp = new int[2];
getLocationOnScreen(temp);
Log.i("BaseDragLayer", "getViewRectRelativeToSelf iNWindow: "+x+" "+y);
v.getLocationInWindow(loc);
int vX = loc[0];
int vY = loc[1];
Log.i("BaseDragLayer", "getViewRectRelativeToSelf ofView: "+vX+" "+vY);
int left = vX - x;
int top = vY - y;
......@@ -289,7 +294,6 @@ public abstract class BaseDragLayer<T extends BaseDraggingActivity> extends Inse
final FrameLayout.LayoutParams flp = (FrameLayout.LayoutParams) child.getLayoutParams();
if (flp instanceof LayoutParams) {
final LayoutParams lp = (LayoutParams) flp;
Log.i("BaseDragLayer","called");
if (lp.customPosition) {
child.layout(lp.x, lp.y, lp.x + lp.width, lp.y + lp.height+lp.height);
}
......
......@@ -180,10 +180,6 @@ open class CellLayout @JvmOverloads constructor(
override fun onMeasure(widthSpec: Int, heightSpec: Int) {
super.onMeasure(widthSpec, heightSpec)
Log.d(
TAG,
"$this onMeasure() called with: widthSpec = $widthSpec, heightSpec = $heightSpec"
)
val widthSpecMode = MeasureSpec.getMode(widthSpec)
val heightSpecMode = MeasureSpec.getMode(heightSpec)
val widthSize = MeasureSpec.getSize(widthSpec)
......@@ -192,7 +188,6 @@ open class CellLayout @JvmOverloads constructor(
val childHeightSize = heightSize - (paddingTop + paddingBottom)
cellWidth = VariantDeviceProfile.calculateCellWidth(childWidthSize, mCountX)
cellHeight = VariantDeviceProfile.calculateCellHeight(childHeightSize, mCountY)
Log.d(TAG, "cellWidth: $cellWidth")
setMeasuredDimension(widthSize, heightSize)
for (i in 0 until childCount) {
val child = getChildAt(i)
......@@ -222,7 +217,6 @@ open class CellLayout @JvmOverloads constructor(
}
fun measureChild(child: View) {
Log.d(TAG, "measureChild() called with: child = $child")
val lp = child.layoutParams as LayoutParams
lp.rowSpec = spec(UNDEFINED)
lp.columnSpec = spec(UNDEFINED)
......@@ -238,7 +232,6 @@ open class CellLayout @JvmOverloads constructor(
} else {
cellPaddingX = (dp.edgeMarginPx / 2f).toInt()
}
Log.d(TAG, "Hotseat cellPaddingY: $cellPaddingY ${lp.height} $cHeight")
child.setPadding(cellPaddingX, cellPaddingY, cellPaddingX, 0)
val childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY)
val childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(lp.height, MeasureSpec.EXACTLY)
......@@ -277,6 +270,15 @@ open class CellLayout @JvmOverloads constructor(
Log.d(TAG, "onViewAdded() called with: child = $child")
}
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
super.onLayout(changed, left, top, right, bottom)
Log.d(
TAG,
"onLayout() called with: changed = $changed, left = $left, top = $top, right = $right, bottom = $bottom"
)
}
fun addViewToCellLayout(
child: View,
index: Int,
......@@ -296,13 +298,12 @@ open class CellLayout @JvmOverloads constructor(
child.scaleX = 1f
child.scaleY = 1f
Log.d(TAG, "Adding view at index: $mContainerType")
// Generate an id for each view, this assumes we have at most 256x256 cells
// per workspace screen
if (index >= 0 && index <= mCountX * mCountY - 1) {
child.id = childId
child.layoutParams = lp
addView(child, index, lp)
if (markCells) markCellsAsOccupiedForView(child)
......@@ -333,31 +334,6 @@ open class CellLayout @JvmOverloads constructor(
super.removeViews(start, count)
}
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
super.onLayout(changed, left, top, right, bottom)
/*val count = childCount
for (i in 0 until count) {
val child = getChildAt(i)
if (child.visibility != GONE) {
val lp = child.layoutParams as LayoutParams
val childLeft = lp.x
val childTop = lp.y
child.layout(childLeft, childTop, childLeft + lp.width, childTop + lp.height)
if (lp.dropped) {
lp.dropped = false
val cellXY: IntArray = mTmpCellXY
getLocationOnScreen(cellXY)
*//*mWallpaperManager.sendWallpaperCommand(
windowToken,
WallpaperManager.COMMAND_DROP,
cellXY[0] + childLeft + lp.width / 2,
cellXY[1] + childTop + lp.height / 2, 0, null
)*//*
}
}
}*/
}
open fun setDropPending(pending: Boolean) {
mDropPending = pending
}
......@@ -844,14 +820,12 @@ open class CellLayout @JvmOverloads constructor(
return intArrayOf(-1, -1)
}
var index = result[1] * mCountX + result[0]
Log.d(
"REORDER",
"Index: $index $rowCount == $mCountX $columnCount == $mCountY ${result[0]} ${result[1]}"
)
// Handles the case when the icon is being dragged after the last item on the grid.
if (index > childCount) {
index = childCount
result[0] = index % mCountX;
result[1] = index / mCountX;
}
//appView.findViewById(R.id.app_label).setVisibility(GONE);
......@@ -889,7 +863,7 @@ open class CellLayout @JvmOverloads constructor(
/*if ((mode == MODE_ON_DROP || !foundSolution)) {
setUseTempCoords(false)
}*/
requestLayout()
//requestLayout()
return result
}
......
/*
* Copyright (C) 2008 The Android Open Source Project
*
......@@ -33,13 +32,10 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.WindowInsets;
import android.view.animation.Interpolator;
import android.widget.GridLayout;
import android.widget.TextView;
import foundation.e.blisslauncher.R;
import foundation.e.blisslauncher.core.customviews.LauncherPagedView;
import foundation.e.blisslauncher.features.test.BaseDragLayer;
import foundation.e.blisslauncher.features.test.CellLayout;
import foundation.e.blisslauncher.features.test.TestActivity;
import foundation.e.blisslauncher.features.test.TouchController;
import foundation.e.blisslauncher.features.test.anim.Interpolators;
......@@ -208,21 +204,28 @@ public class DragLayer extends BaseDragLayer<TestActivity> {
DragView dragView, final View child, int duration,
View anchorView
) {
CellLayout cellLayout = (CellLayout) child.getParent();
//TODO: Fix animation once the drag and drop is completed.
/*CellLayout cellLayout = (CellLayout) child.getParent();
GridLayout.LayoutParams lp = (GridLayout.LayoutParams) child.getLayoutParams();
cellLayout.measureChild(child);
Log.i("DragLayer", "Child index: "+cellLayout.indexOfChild(child)+" "+child.getX()+" "+child.getY());
Rect r = new Rect();
getViewRectRelativeToSelf(dragView, r);
int coord[] = new int[2];
float childScale = child.getScaleX();
coord[0] = (int) (child.getX() + (int) (child.getMeasuredWidth() * (1 - childScale) / 2));
coord[0] = (int) (lp.x + (int) (child.getMeasuredWidth() * (1 - childScale) / 2));
coord[1] = (int) (child.getY() + (int) (child.getMeasuredHeight() * (1 - childScale) / 2));
Log.i("DragLayer", "animateViewIntoPosition before relative: "+coord[0]+" "+coord[1]);
// Since the child hasn't necessarily been laid out, we force the lp to be updated with
// the correct coordinates (above) and use these to determine the final location
float scale = getDescendantCoordRelativeToSelf((View) child.getParent(), coord);
Log.i("DragLayer", "animateViewIntoPosition: "+coord[0]+" "+coord[1]+" "+scale);
// We need to account for the scale of the child itself, as the above only accounts for
// for the scale in parents.
scale *= childScale;
......@@ -245,26 +248,35 @@ public class DragLayer extends BaseDragLayer<TestActivity> {
}
toX -= (dragView.getMeasuredWidth() - Math.round(scale * child.getMeasuredWidth())) / 2;
} /*else if (child instanceof FolderIcon) {
} *//*else if (child instanceof FolderIcon) {
// Account for holographic blur padding on the drag view
toY += Math.round(scale * (child.getPaddingTop() - dragView.getDragRegionTop()));
toY -= scale * dragView.getBlurSizeOutline() / 2;
toY -= (1 - scale) * dragView.getMeasuredHeight() / 2;
// Center in the x coordinate about the target's drawable
toX -= (dragView.getMeasuredWidth() - Math.round(scale * child.getMeasuredWidth())) / 2;
} */else {
} *//*else {
toY -= (Math.round(scale * (dragView.getHeight() - child.getMeasuredHeight()))) / 2;
toX -= (Math.round(scale * (dragView.getMeasuredWidth()
- child.getMeasuredWidth()))) / 2;
}
final int fromX = r.left;
final int fromY = r.top;
final int fromY = r.top;*/
child.setVisibility(INVISIBLE);
Runnable onCompleteRunnable = () -> child.setVisibility(VISIBLE);
animateViewIntoPosition(dragView, fromX, fromY, toX, toY, 1, 1, 1, toScale, toScale,
/*animateViewIntoPosition(dragView, fromX, fromY, toX, toY, 1, 1, 1, toScale, toScale,
onCompleteRunnable, ANIMATION_END_DISAPPEAR, duration, anchorView
);
);*/
// Show the drop view if it was previously hidden
mDropView = dragView;
mDropView.requestLayout();
child.setVisibility(VISIBLE);
if (mDropView != null) {
mDragController.onDeferredEndDrag(mDropView);
}
mDropView = null;
invalidate();
}
public void animateViewIntoPosition(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment