Commit e3bda33c authored by Amit Kumar's avatar Amit Kumar 💻
Browse files

Strip empty screens and fix crash related to wrong index

parent c26428d8
Pipeline #137169 passed with stage
in 3 minutes and 25 seconds
......@@ -294,6 +294,7 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
for (int i = 0; i < orderedScreenIds.size(); i++) {
int screenId = orderedScreenIds.get(i);
insertNewWorkspaceScreenBeforeEmptyScreen(screenId);
Log.d(TAG, "bindScreens() called with: orderedScreenIds = [" + orderedScreenIds + "]");
}
}
......@@ -666,7 +667,9 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
for (int i = 0; i < total; i++) {
int id = mWorkspaceScreens.keyAt(i);
GridLayout cl = mWorkspaceScreens.valueAt(i);
removeScreens.add(id);
if(id > FIRST_SCREEN_ID && cl.getChildCount() == 0) {
removeScreens.add(id);
}
}
// We enforce at least one page to add new items to. In the case that we remove the last
......@@ -782,6 +785,12 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
layout = getScreenWithId(screenId);
}
// It helps in recovering from situation when a layout is not saved correctly.
// TODO: Figure out when it can happen.
if(index > layout.getChildCount()) {
index = layout.getChildCount();
}
ViewGroup.LayoutParams genericLp = child.getLayoutParams();
GridLayout.Spec rowSpec = GridLayout.spec(GridLayout.UNDEFINED);
GridLayout.Spec colSpec = GridLayout.spec(GridLayout.UNDEFINED);
......@@ -821,6 +830,10 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
}
public void addInScreenFromBind(View child, LauncherItem info) {
Log.d(
TAG,
"addInScreenFromBind() called with: child = [" + child + "], info = [" + info + "]"
);
addInScreen(child, info.container, info.screenId, info.cell);
}
......@@ -1178,7 +1191,7 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
@Override
public void onDragEnd() {
if (!mDeferRemoveExtraEmptyScreen) {
//removeExtraEmptyScreen(true, mDragSourceInternal != null);
removeExtraEmptyScreen(true, mDragSourceInternal != null);
}
updateChildrenLayersEnabled();
......@@ -1508,8 +1521,10 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
launcherItem.cell = j;
launcherItem.screenId = screenId;
launcherItem.container = container;
Log.i(TAG, "updateDatabase: "+launcherItem);
if (launcherItem.itemType == Constants.ITEM_TYPE_FOLDER) {
FolderItem folderItem = (FolderItem) launcherItem;
Log.i(TAG, "updateDatabaseFolder: "+launcherItem);
items.add(folderItem);
for (int k = 0; k < folderItem.items.size(); k++) {
LauncherItem item = folderItem.items.get(k);
......
......@@ -598,6 +598,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
if (layoutChildren) {
final int childHeight = child.getMeasuredHeight();
final int childTop = verticalCenter - childHeight / 2;
Log.i(TAG, "getPageScrolls: "+childLeft+" "+childTop+" "+childRight+" "+ (childTop+childHeight));
child.layout(childLeft, childTop, childRight, childTop + childHeight);
}
......
......@@ -390,6 +390,10 @@ public class AppProvider {
}
}
for (LauncherItem mLauncherItem : mLauncherItems) {
Log.i(TAG, "prepareLauncherItems: "+mLauncherItem);
}
applicationItems.removeAll(mDatabaseItems);
List<ApplicationItem> mutableList = new ArrayList<>(applicationItems);
Collections.sort(mutableList, (app1, app2) -> {
......
......@@ -88,6 +88,7 @@ public class Hotseat extends CellLayout implements Insettable {
getLayout().setPadding(padding.left, padding.top, padding.right, padding.bottom);
setLayoutParams(lp);
InsettableFrameLayout.Companion.dispatchInsets(this, insets);
Log.i(TAG, "setInsets: called");
}
@Override
......
......@@ -15,6 +15,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import foundation.e.blisslauncher.core.Utilities;
import foundation.e.blisslauncher.core.customviews.AbstractFloatingView;
import foundation.e.blisslauncher.core.customviews.InsettableFrameLayout;
......@@ -438,11 +439,11 @@ public abstract class BaseDragLayer<T extends BaseDraggingActivity> extends Inse
int count = getChildCount();
for (int i = 0; i < count; i++) {
View child = getChildAt(i);
final LayoutParams flp = (LayoutParams) child.getLayoutParams();
final FrameLayout.LayoutParams flp = (FrameLayout.LayoutParams) child.getLayoutParams();
if (flp instanceof LayoutParams) {
final LayoutParams lp = flp;
final LayoutParams lp = (LayoutParams) flp;
if (lp.customPosition) {
child.layout(lp.x, lp.y, lp.x + lp.width, lp.y + lp.height+lp.height);
child.layout(lp.x, lp.y, lp.x + lp.width, lp.y + lp.height);
}
}
}
......
......@@ -209,6 +209,10 @@ open class CellLayout @JvmOverloads constructor(
requestLayout()
}
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
super.onLayout(changed, left, top, right, bottom)
}
fun measureChild(child: View) {
val lp = child.layoutParams as LayoutParams
lp.rowSpec = spec(UNDEFINED)
......
......@@ -1094,6 +1094,7 @@ class TestActivity : BaseDraggingActivity(), AutoCompleteAdapter.OnSuggestionCli
}
private fun showApps(launcherItems: List<LauncherItem>) {
Log.d(TAG, "showApps() called with: launcherItems = $launcherItems")
hotseat.resetLayout(false)
val populatedItems = populateItemPositions(launcherItems)
val orderedScreenIds = IntegerArray()
......
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