Add options for unlimited and forced widget resize (#4170)

* Add option to make all widgets resizable.

* Split setting for unlimited size and forcing.

* Update labels and add description to settings.

* Fix build error.

---------

Co-authored-by: SuperDragonXD <70206496+SuperDragonXD@users.noreply.github.com>
This commit is contained in:
Daniel Hauck
2024-04-03 13:32:54 +02:00
committed by GitHub
parent 2288f29b5a
commit 0390df7bfe
6 changed files with 65 additions and 14 deletions
+6 -5
View File
@@ -2131,6 +2131,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
boolean snappedToNewPage = false;
boolean resizeOnDrop = false;
Runnable onCompleteRunnable = null;
boolean forceWidgetResize = PreferenceExtensionsKt.firstBlocking(mPreferenceManager2.getForceWidgetResize());
if (d.dragSource != this || mDragInfo == null) {
final int[] touchXY = new int[] { (int) mDragViewVisualCenter[0],
(int) mDragViewVisualCenter[1] };
@@ -2252,7 +2253,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
// We post this call so that the widget has a chance to be placed
// in its final location
onCompleteRunnable = getWidgetResizeFrameRunnable(options,
(LauncherAppWidgetHostView) cell, dropTargetLayout);
(LauncherAppWidgetHostView) cell, dropTargetLayout, forceWidgetResize);
}
mLauncher.getModelWriter().modifyItemInDatabase(info, container, screenId,
lp.getCellX(), lp.getCellY(), item.spanX, item.spanY);
@@ -2281,7 +2282,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
if (pageIsVisible) {
onCompleteRunnable = getWidgetResizeFrameRunnable(options,
(LauncherAppWidgetHostView) cell, cellLayout);
(LauncherAppWidgetHostView) cell, cellLayout, forceWidgetResize);
}
}
}
@@ -2346,10 +2347,10 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
@Nullable
private Runnable getWidgetResizeFrameRunnable(DragOptions options,
LauncherAppWidgetHostView hostView, CellLayout cellLayout) {
LauncherAppWidgetHostView hostView, CellLayout cellLayout, boolean force) {
AppWidgetProviderInfo pInfo = hostView.getAppWidgetInfo();
if (pInfo != null && pInfo.resizeMode != AppWidgetProviderInfo.RESIZE_NONE
&& !options.isAccessibleDrag) {
boolean shouldResize = (pInfo.resizeMode != AppWidgetProviderInfo.RESIZE_NONE) || force;
if (pInfo != null && shouldResize && !options.isAccessibleDrag) {
return () -> {
if (!isPageInTransition()) {
AppWidgetResizeFrame.showForWidget(hostView, cellLayout);