summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/LauncherModel.java
diff options
context:
space:
mode:
authorDan Sandler <dsandler@android.com>2014-01-09 15:01:33 -0500
committerDan Sandler <dsandler@android.com>2014-01-10 15:49:51 -0500
commitd502404a44fb7c4ea739622d7f8bdd2a764d97a1 (patch)
tree2d14d3da3c805d6dcb61b9573ffdbc8cb4e85dc9 /src/com/android/launcher3/LauncherModel.java
parent0bae5b220a24541dbc69fb2cb755f303776d0a59 (diff)
downloadandroid_packages_apps_Trebuchet-d502404a44fb7c4ea739622d7f8bdd2a764d97a1.tar.gz
android_packages_apps_Trebuchet-d502404a44fb7c4ea739622d7f8bdd2a764d97a1.tar.bz2
android_packages_apps_Trebuchet-d502404a44fb7c4ea739622d7f8bdd2a764d97a1.zip
New launcher2 icon migration algorithm.
The user will be able to request "icon migration", which is not a direct mapping of the old workspace, but rather follows this heuristic for bringing the user's favorite icons (by dint of their existence on the workspace) into Launcher3: Workspace shortcuts are placed in lexicographic order on the workspace starting at screen 0 (leaving the bottom row of screen 0 empty to make sure there's room to move things around). Folders are preserved and their contents sorted. Duplicate icons (that is, shortcuts with the same intent, pursuant to some cleanups) are removed. Hotseat icons are migrated in their original place, unless their new location is not accommodated by the hotseat (i.e. the L3 hotseat is too small on this device), in which case they're treated like any other shortcut and tossed into the workspace. To test, turn on Launcher.ENABLE_DEBUG_INTENTS and then: $ adb shell am broadcast -a com.android.launcher3.action.DELETE_DATABASE $ adb shell am broadcast -a com.android.launcher3.action.MIGRATE_DATABASE Bug: 12416411 Change-Id: Ia5c56f36c11455867ea20a39f70210f595020a87
Diffstat (limited to 'src/com/android/launcher3/LauncherModel.java')
-rw-r--r--src/com/android/launcher3/LauncherModel.java32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index b2cfb2456..460ab5db2 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -75,6 +75,10 @@ public class LauncherModel extends BroadcastReceiver {
// false = strew non-workspace apps across the workspace on upgrade
public static final boolean UPGRADE_USE_MORE_APPS_FOLDER = false;
+ public static final int LOADER_FLAG_NONE = 0;
+ public static final int LOADER_FLAG_CLEAR_WORKSPACE = 1 << 0;
+ public static final int LOADER_FLAG_MIGRATE_SHORTCUTS = 1 << 1;
+
private static final int ITEMS_CHUNK = 6; // batch size for the workspace icons
private static final long INVALID_SCREEN_ID = -1L;
private final boolean mAppsCanBeOnRemoveableStorage;
@@ -1193,6 +1197,10 @@ public class LauncherModel extends BroadcastReceiver {
}
public void startLoader(boolean isLaunching, int synchronousBindPage) {
+ startLoader(isLaunching, synchronousBindPage, LOADER_FLAG_NONE);
+ }
+
+ public void startLoader(boolean isLaunching, int synchronousBindPage, int loadFlags) {
synchronized (mLock) {
if (DEBUG_LOADERS) {
Log.d(TAG, "startLoader isLaunching=" + isLaunching);
@@ -1207,7 +1215,7 @@ public class LauncherModel extends BroadcastReceiver {
// If there is already one running, tell it to stop.
// also, don't downgrade isLaunching if we're already running
isLaunching = isLaunching || stopLoaderLocked();
- mLoaderTask = new LoaderTask(mApp.getContext(), isLaunching);
+ mLoaderTask = new LoaderTask(mApp.getContext(), isLaunching, loadFlags);
if (synchronousBindPage != PagedView.INVALID_RESTORE_PAGE
&& mAllAppsLoaded && mWorkspaceLoaded) {
mLoaderTask.runBindSynchronousPage(synchronousBindPage);
@@ -1298,13 +1306,15 @@ public class LauncherModel extends BroadcastReceiver {
private boolean mIsLoadingAndBindingWorkspace;
private boolean mStopped;
private boolean mLoadAndBindStepFinished;
+ private int mFlags;
private HashMap<Object, CharSequence> mLabelCache;
- LoaderTask(Context context, boolean isLaunching) {
+ LoaderTask(Context context, boolean isLaunching, int flags) {
mContext = context;
mIsLaunching = isLaunching;
mLabelCache = new HashMap<Object, CharSequence>();
+ mFlags = flags;
}
boolean isLaunching() {
@@ -1651,7 +1661,7 @@ public class LauncherModel extends BroadcastReceiver {
}
}
- /** Returns whether this is an upgradge path */
+ /** Returns whether this is an upgrade path */
private boolean loadWorkspace() {
// Log to disk
Launcher.addDumpLog(TAG, "11683562 - loadWorkspace()", true);
@@ -1669,8 +1679,20 @@ public class LauncherModel extends BroadcastReceiver {
int countX = (int) grid.numColumns;
int countY = (int) grid.numRows;
- // Make sure the default workspace is loaded, if needed
- LauncherAppState.getLauncherProvider().loadDefaultFavoritesIfNecessary(0);
+ if ((mFlags & LOADER_FLAG_CLEAR_WORKSPACE) != 0) {
+ Launcher.addDumpLog(TAG, "loadWorkspace: resetting launcher database", true);
+ LauncherAppState.getLauncherProvider().deleteDatabase();
+ }
+
+ if ((mFlags & LOADER_FLAG_MIGRATE_SHORTCUTS) != 0) {
+ // append the user's Launcher2 shortcuts
+ Launcher.addDumpLog(TAG, "loadWorkspace: migrating from launcher2", true);
+ LauncherAppState.getLauncherProvider().migrateLauncher2Shortcuts();
+ } else {
+ // Make sure the default workspace is loaded
+ Launcher.addDumpLog(TAG, "loadWorkspace: loading default favorites", false);
+ LauncherAppState.getLauncherProvider().loadDefaultFavoritesIfNecessary(0);
+ }
// Check if we need to do any upgrade-path logic
// (Includes having just imported default favorites)