diff options
Diffstat (limited to 'src/com/android/launcher3/LauncherModel.java')
-rw-r--r-- | src/com/android/launcher3/LauncherModel.java | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index 498d91a38..d271976a7 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; @@ -1202,6 +1206,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); @@ -1216,7 +1224,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); @@ -1307,13 +1315,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() { @@ -1475,7 +1485,7 @@ public class LauncherModel extends BroadcastReceiver { sBgDbIconCache.clear(); } - if (AppsCustomizePagedView.DISABLE_ALL_APPS) { + if (LauncherAppState.isDisableAllApps()) { // Ensure that all the applications that are in the system are // represented on the home screen. if (!UPGRADE_USE_MORE_APPS_FOLDER || !isUpgrade) { @@ -1678,8 +1688,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) @@ -2573,7 +2595,7 @@ public class LauncherModel extends BroadcastReceiver { if (added != null) { // Ensure that we add all the workspace applications to the db Callbacks cb = mCallbacks != null ? mCallbacks.get() : null; - if (!AppsCustomizePagedView.DISABLE_ALL_APPS) { + if (!LauncherAppState.isDisableAllApps()) { addAndBindAddedApps(context, new ArrayList<ItemInfo>(), cb, added); } else { final ArrayList<ItemInfo> addedInfos = new ArrayList<ItemInfo>(added); |