Commit 7895dc5c authored by Amit Kumar's avatar Amit Kumar 💻
Browse files

Fix icon drop on empty page

parent 692f504b
Pipeline #111592 passed with stage
in 6 minutes and 16 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;
......@@ -19,16 +21,10 @@ import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
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;
......@@ -52,8 +48,10 @@ 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 static foundation.e.blisslauncher.features.test.anim.LauncherAnimUtils.SPRING_LOADED_TRANSITION_MS;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.jetbrains.annotations.NotNull;
public class LauncherPagedView extends PagedView<PageIndicatorDots> implements View.OnTouchListener,
Insettable, DropTarget, DragSource, DragController.DragListener {
......@@ -714,12 +712,18 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
layout = getScreenWithId(screenId);
}
CellLayout.LayoutParams genericLp = (CellLayout.LayoutParams) child.getLayoutParams();
ViewGroup.LayoutParams genericLp = child.getLayoutParams();
GridLayout.Spec rowSpec = GridLayout.spec(GridLayout.UNDEFINED);
GridLayout.Spec colSpec = GridLayout.spec(GridLayout.UNDEFINED);
if (genericLp == null || !(genericLp instanceof CellLayout.LayoutParams)) {
genericLp = new GridLayout.LayoutParams(rowSpec, colSpec);
CellLayout.LayoutParams lp;
if (!(genericLp instanceof CellLayout.LayoutParams)) {
lp = new GridLayout.LayoutParams(rowSpec, colSpec);
} else {
lp = (CellLayout.LayoutParams) genericLp;
lp.rowSpec = GridLayout.spec(GridLayout.UNDEFINED);
lp.columnSpec = GridLayout.spec(GridLayout.UNDEFINED);
}
lp.setGravity(Gravity.CENTER);
// Get the canonical child id to uniquely represent this view in this screen
LauncherItem info = (LauncherItem) child.getTag();
......@@ -731,7 +735,7 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
child,
index,
childId,
genericLp,
lp,
markCellsAsOccupied
)) {
// TODO: This branch occurs when the workspace is adding views
......@@ -1233,7 +1237,6 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, cell, duration,
this
);
Log.i(TAG, "onDrop: Here it comes too");
} else {
d.deferDragViewCleanupPostAnimation = false;
cell.setVisibility(VISIBLE);
......
......@@ -270,15 +270,6 @@ 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,
......@@ -303,7 +294,12 @@ open class CellLayout @JvmOverloads constructor(
if (index >= 0 && index <= mCountX * mCountY - 1) {
child.id = childId
child.layoutParams = lp
/* val rowSpec = spec(UNDEFINED)
val colSpec = spec(UNDEFINED)
val iconLayoutParams = LayoutParams(rowSpec, colSpec)
iconLayoutParams.height = launcher.deviceProfile.cellHeightPx
iconLayoutParams.width = launcher.deviceProfile.cellWidthPx
iconLayoutParams.setGravity(Gravity.CENTER)*/
addView(child, index, lp)
if (markCells) markCellsAsOccupiedForView(child)
......@@ -824,8 +820,8 @@ open class CellLayout @JvmOverloads constructor(
// 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;
result[0] = index % mCountX
result[1] = index / mCountX
}
//appView.findViewById(R.id.app_label).setVisibility(GONE);
......
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