diff options
author | Romain Guy <romainguy@android.com> | 2009-11-06 11:44:55 -0800 |
---|---|---|
committer | Romain Guy <romainguy@android.com> | 2009-11-06 13:45:44 -0800 |
commit | 18042c82c5847d3caf9af65583c5590c17927c3d (patch) | |
tree | 8652d3ed62411281259612900ae08b8af22434c0 | |
parent | ad72e1705c32da463a552f2283ae467dc15a4a34 (diff) | |
download | android_packages_apps_Trebuchet-18042c82c5847d3caf9af65583c5590c17927c3d.tar.gz android_packages_apps_Trebuchet-18042c82c5847d3caf9af65583c5590c17927c3d.tar.bz2 android_packages_apps_Trebuchet-18042c82c5847d3caf9af65583c5590c17927c3d.zip |
[Launcher2] Delete app widgets when their configuration is cancelled or there's not enough room on Home.
Bugs #2234228 and #2244729.
Approved by mcleron
Change-Id: I15e4850d8c1a821497df5d32e5fb63b3400d1e44
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 6cccb77f2..9aa6cd304 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -376,8 +376,9 @@ public final class Launcher extends Activity // We just wanted the activity result here so we can clear mWaitingForResult break; } - } else if (requestCode == REQUEST_PICK_APPWIDGET && - resultCode == RESULT_CANCELED && data != null) { + } else if ((requestCode == REQUEST_PICK_APPWIDGET || + requestCode == REQUEST_CREATE_APPWIDGET) && resultCode == RESULT_CANCELED && + data != null) { // Clean up the appWidgetId if we canceled int appWidgetId = data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1); if (appWidgetId != -1) { @@ -680,7 +681,7 @@ public final class Launcher extends Activity Bundle extras = data.getExtras(); int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, -1); - d(LOG_TAG, "dumping extras content="+extras.toString()); + if (LOGD) d(LOG_TAG, "dumping extras content=" + extras.toString()); AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId); @@ -690,7 +691,10 @@ public final class Launcher extends Activity // Try finding open space on Launcher screen final int[] xy = mCellCoordinates; - if (!findSlot(cellInfo, xy, spans[0], spans[1])) return; + if (!findSlot(cellInfo, xy, spans[0], spans[1])) { + if (appWidgetId != -1) mAppWidgetHost.deleteAppWidgetId(appWidgetId); + return; + } // Build Launcher-specific widget info and save to database LauncherAppWidgetInfo launcherInfo = new LauncherAppWidgetInfo(appWidgetId); |