mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 16:26:47 +00:00
Remove widgets that no longer fit the workspace in their current spans.
This can happen when display size changes. We compare span sizes of widget in the db to the min sizes of the widget in the current display size. If the widget can no longer fit in its existing spans, we remove it. Bug: 168818961 Change-Id: I6b095d2eeaeda95bfa91baec89cb54660695b60b
This commit is contained in:
@@ -49,6 +49,7 @@ import android.util.LongSparseArray;
|
||||
import android.util.TimingLogger;
|
||||
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.LauncherAppWidgetProviderInfo;
|
||||
import com.android.launcher3.LauncherModel;
|
||||
import com.android.launcher3.LauncherSettings;
|
||||
import com.android.launcher3.Utilities;
|
||||
@@ -306,6 +307,7 @@ public class LoaderTask implements Runnable {
|
||||
final PackageManagerHelper pmHelper = new PackageManagerHelper(context);
|
||||
final boolean isSafeMode = pmHelper.isSafeMode();
|
||||
final boolean isSdCardReady = Utilities.isBootCompleted();
|
||||
final WidgetManagerHelper widgetHelper = new WidgetManagerHelper(context);
|
||||
|
||||
boolean clearDb = false;
|
||||
try {
|
||||
@@ -391,6 +393,7 @@ public class LoaderTask implements Runnable {
|
||||
|
||||
WorkspaceItemInfo info;
|
||||
LauncherAppWidgetInfo appWidgetInfo;
|
||||
LauncherAppWidgetProviderInfo widgetProviderInfo;
|
||||
Intent intent;
|
||||
String targetPkg;
|
||||
|
||||
@@ -720,6 +723,19 @@ public class LoaderTask implements Runnable {
|
||||
+ appWidgetInfo.spanX + "x" + appWidgetInfo.spanY);
|
||||
continue;
|
||||
}
|
||||
widgetProviderInfo =
|
||||
widgetHelper.getLauncherAppWidgetInfo(appWidgetId);
|
||||
if (widgetProviderInfo != null
|
||||
&& (appWidgetInfo.spanX < widgetProviderInfo.minSpanX
|
||||
|| appWidgetInfo.spanY < widgetProviderInfo.minSpanY)) {
|
||||
// This can happen when display size changes.
|
||||
c.markDeleted("Widget removed, min sizes not met: "
|
||||
+ "span=" + appWidgetInfo.spanX + "x"
|
||||
+ appWidgetInfo.spanY + " minSpan="
|
||||
+ widgetProviderInfo.minSpanX + "x"
|
||||
+ widgetProviderInfo.minSpanY);
|
||||
continue;
|
||||
}
|
||||
if (!c.isOnWorkspaceOrHotseat()) {
|
||||
c.markDeleted("Widget found where container != " +
|
||||
"CONTAINER_DESKTOP nor CONTAINER_HOTSEAT - ignoring!");
|
||||
|
||||
Reference in New Issue
Block a user