summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/LauncherProvider.java
diff options
context:
space:
mode:
authorDan Sandler <dsandler@android.com>2014-03-07 13:09:03 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2014-03-07 13:09:03 -0800
commitbfbd52a5e618a86dc7a13bb5e4866759e181a7cb (patch)
tree949100b22660e561ed4d24d2f1fc6f5215136a5a /src/com/android/launcher3/LauncherProvider.java
parent3a8a8f7c2355863006208fced945f63c9bdb40b4 (diff)
parenteac828e0fec7085d0d6b670d578eaaf36ae2e3ca (diff)
downloadandroid_packages_apps_Trebuchet-bfbd52a5e618a86dc7a13bb5e4866759e181a7cb.tar.gz
android_packages_apps_Trebuchet-bfbd52a5e618a86dc7a13bb5e4866759e181a7cb.tar.bz2
android_packages_apps_Trebuchet-bfbd52a5e618a86dc7a13bb5e4866759e181a7cb.zip
am eac828e0: Merge "Don\'t lose icons when migrating from different-sized hotseats." into ub-now-lunchbox
* commit 'eac828e0fec7085d0d6b670d578eaaf36ae2e3ca': Don't lose icons when migrating from different-sized hotseats.
Diffstat (limited to 'src/com/android/launcher3/LauncherProvider.java')
-rw-r--r--src/com/android/launcher3/LauncherProvider.java40
1 files changed, 34 insertions, 6 deletions
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index b952729bd..a080dd8ca 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -50,6 +50,7 @@ import android.provider.Settings;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
+import android.util.SparseArray;
import android.util.Xml;
import com.android.launcher3.LauncherSettings.Favorites;
@@ -1578,6 +1579,7 @@ public class LauncherProvider extends ContentProvider {
final ArrayList<ContentValues> shortcuts = new ArrayList<ContentValues>();
final ArrayList<ContentValues> folders = new ArrayList<ContentValues>();
+ final SparseArray<ContentValues> hotseat = new SparseArray<ContentValues>();
while (c.moveToNext()) {
final int itemType = c.getInt(itemTypeIndex);
@@ -1593,7 +1595,11 @@ public class LauncherProvider extends ContentProvider {
int container = c.getInt(containerIndex);
final String intentStr = c.getString(intentIndex);
Launcher.addDumpLog(TAG, "migrating \""
- + c.getString(titleIndex) + "\": " + intentStr, true);
+ + c.getString(titleIndex) + "\" ("
+ + cellX + "," + cellY + "@"
+ + LauncherSettings.Favorites.containerToString(container)
+ + "/" + screen
+ + "): " + intentStr, true);
if (itemType != Favorites.ITEM_TYPE_FOLDER) {
@@ -1654,11 +1660,8 @@ public class LauncherProvider extends ContentProvider {
values.put(LauncherSettings.Favorites.DISPLAY_MODE,
c.getInt(displayModeIndex));
- if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT
- && (screen >= hotseatWidth ||
- screen == grid.hotseatAllAppsRank)) {
- // no room for you in the hotseat? it's off to the desktop with you
- container = Favorites.CONTAINER_DESKTOP;
+ if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
+ hotseat.put(screen, values);
}
if (container != LauncherSettings.Favorites.CONTAINER_DESKTOP) {
@@ -1680,6 +1683,31 @@ public class LauncherProvider extends ContentProvider {
}
}
+ // Now that we have all the hotseat icons, let's go through them left-right
+ // and assign valid locations for them in the new hotseat
+ final int N = hotseat.size();
+ for (int idx=0; idx<N; idx++) {
+ int hotseatX = hotseat.keyAt(idx);
+ ContentValues values = hotseat.valueAt(idx);
+
+ if (hotseatX == grid.hotseatAllAppsRank) {
+ // let's drop this in the next available hole in the hotseat
+ while (++hotseatX < hotseatWidth) {
+ if (hotseat.get(hotseatX) == null) {
+ // found a spot! move it here
+ values.put(LauncherSettings.Favorites.SCREEN,
+ hotseatX);
+ break;
+ }
+ }
+ }
+ if (hotseatX >= hotseatWidth) {
+ // no room for you in the hotseat? it's off to the desktop with you
+ values.put(LauncherSettings.Favorites.CONTAINER,
+ Favorites.CONTAINER_DESKTOP);
+ }
+ }
+
final ArrayList<ContentValues> allItems = new ArrayList<ContentValues>();
// Folders first
allItems.addAll(folders);