Merge "Fixing potential crash when trying to create 0x0 bitmaps"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 509a670..f707c8c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -83,6 +83,8 @@
<string name="group_wallpapers">Wallpapers</string>
<!-- Error message when user has filled a home screen, possibly not used -->
<string name="out_of_space">No more room on your Home screens.</string>
+ <!-- Error message when user has filled the hotseat -->
+ <string name="hotseat_out_of_space">No more room on the hotseat.</string>
<!-- Error message when user tries to drop an invalid item on the hotseat -->
<string name="invalid_hotseat_item">This widget is too large for the hotseat.</string>
<!-- Message displayed when a shortcut is created by an external application -->
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index f0c7f34..840ec45 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -791,7 +791,7 @@
}
}
if (showOutOfSpaceMessage) {
- mLauncher.showOutOfSpaceMessage();
+ mLauncher.showOutOfSpaceMessage(false);
}
d.deferDragViewCleanupPostAnimation = false;
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 9494d27..6464a7d 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -881,7 +881,7 @@
cellXY[0] = cellX;
cellXY[1] = cellY;
} else if (!layout.findCellForSpan(cellXY, 1, 1)) {
- showOutOfSpaceMessage();
+ showOutOfSpaceMessage(isHotseatLayout(layout));
return;
}
@@ -944,7 +944,7 @@
}
if (!foundCellSpan) {
- showOutOfSpaceMessage();
+ showOutOfSpaceMessage(isHotseatLayout(layout));
return;
}
@@ -1039,7 +1039,7 @@
}
}.start();
}
- showOutOfSpaceMessage();
+ showOutOfSpaceMessage(isHotseatLayout(layout));
return;
}
@@ -1225,8 +1225,9 @@
launcherInfo.hostView = null;
}
- void showOutOfSpaceMessage() {
- Toast.makeText(this, getString(R.string.out_of_space), Toast.LENGTH_SHORT).show();
+ void showOutOfSpaceMessage(boolean isHotseatLayout) {
+ int strId = (isHotseatLayout ? R.string.hotseat_out_of_space : R.string.out_of_space);
+ Toast.makeText(this, getString(strId), Toast.LENGTH_SHORT).show();
}
public LauncherAppWidgetHost getAppWidgetHost() {
@@ -2751,7 +2752,7 @@
*/
void addExternalItemToScreen(ItemInfo itemInfo, final CellLayout layout) {
if (!mWorkspace.addExternalItemToScreen(itemInfo, layout)) {
- showOutOfSpaceMessage();
+ showOutOfSpaceMessage(isHotseatLayout(layout));
}
}
diff --git a/src/com/android/launcher2/WallpaperChooserDialogFragment.java b/src/com/android/launcher2/WallpaperChooserDialogFragment.java
index 030d33d..eec699e 100644
--- a/src/com/android/launcher2/WallpaperChooserDialogFragment.java
+++ b/src/com/android/launcher2/WallpaperChooserDialogFragment.java
@@ -82,10 +82,7 @@
outState.putBoolean(EMBEDDED_KEY, mEmbedded);
}
- @Override
- public void onDestroy() {
- super.onDestroy();
-
+ private void cancelLoader() {
if (mLoader != null && mLoader.getStatus() != WallpaperLoader.Status.FINISHED) {
mLoader.cancel(true);
mLoader = null;
@@ -93,6 +90,20 @@
}
@Override
+ public void onDetach() {
+ super.onDetach();
+
+ cancelLoader();
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+
+ cancelLoader();
+ }
+
+ @Override
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
/* On orientation changes, the dialog is effectively "dismissed" so this is called
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index f1941b3..5c8694d 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -2064,7 +2064,8 @@
if (!foundCell) {
// Don't show the message if we are dropping on the AllApps button and the hotseat
// is full
- if (mTargetCell != null && mLauncher.isHotseatLayout(mDragTargetLayout)) {
+ boolean isHotseat = mLauncher.isHotseatLayout(mDragTargetLayout);
+ if (mTargetCell != null && isHotseat) {
Hotseat hotseat = mLauncher.getHotseat();
if (hotseat.isAllAppsButtonRank(
hotseat.getOrderInHotseat(mTargetCell[0], mTargetCell[1]))) {
@@ -2072,7 +2073,7 @@
}
}
- mLauncher.showOutOfSpaceMessage();
+ mLauncher.showOutOfSpaceMessage(isHotseat);
return false;
}
}
@@ -2943,7 +2944,7 @@
onDropExternal(dragInfo.dropPos, (ItemInfo) dragInfo, (CellLayout) layout, false);
return true;
}
- mLauncher.showOutOfSpaceMessage();
+ mLauncher.showOutOfSpaceMessage(mLauncher.isHotseatLayout(layout));
return false;
}