Skip to content

Commit

Permalink
Fixed broken widget overlap (#3792)
Browse files Browse the repository at this point in the history
- Due to the faulty merged of A13
  • Loading branch information
MrSluffy authored Nov 29, 2023
1 parent c58df33 commit d60bced
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/com/android/launcher3/CellLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
import com.android.launcher3.util.Thunk;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
import com.patrykmichalik.opto.core.PreferenceExtensionsKt;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand Down Expand Up @@ -2343,6 +2344,11 @@ public boolean rearrangementExists(int cellX, int cellY, int spanX, int spanY, i
if (cellX < 0 || cellY < 0) return false;

mIntersectingViews.clear();
if (PreferenceExtensionsKt.firstBlocking(mPreferenceManager2.getAllowWidgetOverlap())) {
// let's pretend no intersections exist
solution.intersectingViews = new ArrayList<>(mIntersectingViews);
return true;
}
mOccupiedRect.set(cellX, cellY, cellX + spanX, cellY + spanY);

// Mark the desired location of the view currently being dragged.
Expand Down Expand Up @@ -2739,7 +2745,7 @@ public int getDesiredHeight() {

public boolean isOccupied(int x, int y) {
if (x < mCountX && y < mCountY) {
return mOccupied.cells[x][y];
return mOccupied.cells[x][y] && !PreferenceExtensionsKt.firstBlocking(mPreferenceManager2.getAllowWidgetOverlap());
} else {
throw new RuntimeException("Position exceeds the bound of this CellLayout");
}
Expand Down Expand Up @@ -2857,6 +2863,6 @@ public GridOccupancy cloneGridOccupancy() {
}

public boolean isRegionVacant(int x, int y, int spanX, int spanY) {
return mOccupied.isRegionVacant(x, y, spanX, spanY);
return mOccupied.isRegionVacant(x, y, spanX, spanY) || PreferenceExtensionsKt.firstBlocking(mPreferenceManager2.getAllowWidgetOverlap());
}
}
15 changes: 15 additions & 0 deletions src/com/android/launcher3/ShortcutAndWidgetContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.widget.NavigableAppWidgetHostView;
import com.patrykmichalik.opto.core.PreferenceExtensionsKt;

import app.lawnchair.preferences2.PreferenceManager2;

public class ShortcutAndWidgetContainer extends ViewGroup implements FolderIcon.FolderIconParent {
static final String TAG = "ShortcutAndWidgetContainer";
Expand All @@ -62,11 +65,23 @@ public class ShortcutAndWidgetContainer extends ViewGroup implements FolderIcon.
private final ActivityContext mActivity;
private boolean mInvertIfRtl = false;

private final PreferenceManager2 mPreferenceManager2;

public ShortcutAndWidgetContainer(Context context, @ContainerType int containerType) {
super(context);
mActivity = ActivityContext.lookupContext(context);
mWallpaperManager = WallpaperManager.getInstance(context);
mContainerType = containerType;
mPreferenceManager2 = PreferenceManager2.getInstance(context);
}

@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
boolean mAllowWidgetOverlap = PreferenceExtensionsKt.firstBlocking(mPreferenceManager2.getAllowWidgetOverlap());
setClipChildren(!mAllowWidgetOverlap);
setClipToPadding(!mAllowWidgetOverlap);
setClipToOutline(!mAllowWidgetOverlap);
}

public void setCellDimensions(int cellWidth, int cellHeight, int countX, int countY,
Expand Down

0 comments on commit d60bced

Please sign in to comment.