summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2014-01-15 18:13:55 -0800
committerDanesh M <daneshm90@gmail.com>2014-06-06 22:54:26 -0700
commit6a2f47b814944d93d377b001ae6c1738dfe1d653 (patch)
tree9d48dad690614c7472ecd9c8de90178205c68617 /src
parent87d263e5a6c69122b91973ee62445f97e0466047 (diff)
downloadandroid_packages_apps_Trebuchet-6a2f47b814944d93d377b001ae6c1738dfe1d653.tar.gz
android_packages_apps_Trebuchet-6a2f47b814944d93d377b001ae6c1738dfe1d653.tar.bz2
android_packages_apps_Trebuchet-6a2f47b814944d93d377b001ae6c1738dfe1d653.zip
Migration update: ensuring all folders go first
-> Also, leave the last row empty on every screen -> Fix bug where shortcuts weren't getting moved (introduced in previous CL) -> Only dedupe items directly on the workspace Bug 12416411 Bug 12572727 Change-Id: Id95cc6081c57cc289c2a85b2a6872ee0bf3eb98a
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/LauncherProvider.java75
1 files changed, 50 insertions, 25 deletions
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index 2fe8b015f..eaaa960d1 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -1583,7 +1583,6 @@ public class LauncherProvider extends ContentProvider {
// Ignore
}
-
// We already have a favorites database in the old provider
if (c != null) {
try {
@@ -1629,7 +1628,8 @@ public class LauncherProvider extends ContentProvider {
final HashSet<String> seenIntents = new HashSet<String>(c.getCount());
- final ContentValues[] rows = new ContentValues[c.getCount()];
+ final ArrayList<ContentValues> shortcuts = new ArrayList<ContentValues>();
+ final ArrayList<ContentValues> folders = new ArrayList<ContentValues>();
while (c.moveToNext()) {
final int itemType = c.getInt(itemTypeIndex);
@@ -1661,17 +1661,20 @@ public class LauncherProvider extends ContentProvider {
}
cn = intent.getComponent();
-
if (TextUtils.isEmpty(intentStr)) {
// no intent? no icon
Launcher.addDumpLog(TAG, "skipping empty intent", true);
continue;
- } else if (!LauncherModel.isValidPackageComponent(pm, cn)) {
+ } else if (cn != null &&
+ !LauncherModel.isValidPackageComponent(pm, cn)) {
// component no longer exists.
- Launcher.addDumpLog(TAG, "skipping item whose component" +
+ Launcher.addDumpLog(TAG, "skipping item whose component " +
"no longer exists.", true);
continue;
- } else {
+ } else if (container ==
+ LauncherSettings.Favorites.CONTAINER_DESKTOP) {
+ // Dedupe icons directly on the workspace
+
// Canonicalize
// the Play Store sets the package parameter, but Launcher
// does not, so we clear that out to keep them the same
@@ -1704,7 +1707,8 @@ public class LauncherProvider extends ContentProvider {
c.getInt(displayModeIndex));
if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT
- && screen >= hotseatWidth) {
+ && (screen >= hotseatWidth ||
+ screen == grid.hotseatAllAppsRank)) {
// no room for you in the hotseat? it's off to the desktop with you
container = Favorites.CONTAINER_DESKTOP;
}
@@ -1715,32 +1719,53 @@ public class LauncherProvider extends ContentProvider {
values.put(LauncherSettings.Favorites.CELLX, cellX);
values.put(LauncherSettings.Favorites.CELLY, cellY);
} else {
- values.put(LauncherSettings.Favorites.SCREEN, curScreen);
- values.put(LauncherSettings.Favorites.CELLX, curX);
- values.put(LauncherSettings.Favorites.CELLY, curY);
- curX = (curX + 1) % width;
- if (curX == 0) {
- curY = (curY + 1);
- }
- // Leave the last row of icons blank on screen 0
- if (curScreen == 0 && curY == height - 1 || curY == height) {
- curScreen = (int) generateNewScreenId();
- curY = 0;
- }
+ // For items contained directly on one of the workspace screen,
+ // we'll determine their location (screen, x, y) in a second pass.
}
values.put(LauncherSettings.Favorites.CONTAINER, container);
- rows[i++] = values;
+ if (itemType != Favorites.ITEM_TYPE_FOLDER) {
+ shortcuts.add(values);
+ } else {
+ folders.add(values);
+ }
+ }
+
+ final ArrayList<ContentValues> allItems = new ArrayList<ContentValues>();
+ // Folders first
+ allItems.addAll(folders);
+ // Then shortcuts
+ allItems.addAll(shortcuts);
+
+ // Layout all the folders
+ for (ContentValues values: allItems) {
+ if (values.getAsInteger(LauncherSettings.Favorites.CONTAINER) !=
+ LauncherSettings.Favorites.CONTAINER_DESKTOP) {
+ // Hotseat items and folder items have already had their
+ // location information set. Nothing to be done here.
+ continue;
+ }
+ values.put(LauncherSettings.Favorites.SCREEN, curScreen);
+ values.put(LauncherSettings.Favorites.CELLX, curX);
+ values.put(LauncherSettings.Favorites.CELLY, curY);
+ curX = (curX + 1) % width;
+ if (curX == 0) {
+ curY = (curY + 1);
+ }
+ // Leave the last row of icons blank on every screen
+ if (curY == height - 1) {
+ curScreen = (int) generateNewScreenId();
+ curY = 0;
+ }
}
- if (i > 0) {
+ if (allItems.size() > 0) {
db.beginTransaction();
try {
- final int N = rows.length;
- for (i = 0; i < N; i++) {
- if (rows[i] == null) continue;
- if (dbInsertAndCheck(this, db, TABLE_FAVORITES, null, rows[i])
+ for (ContentValues row: allItems) {
+ if (row == null) continue;
+ if (dbInsertAndCheck(this, db, TABLE_FAVORITES, null, row)
< 0) {
return;
} else {