summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-05-23 15:55:41 -0700
committerSunny Goyal <sunnygoyal@google.com>2016-05-23 16:00:09 -0700
commitded0fdba52d94f8c841598a14dbece36a2f1849c (patch)
tree98911b25737775e8ea128ee86f3e4606062e641b
parent33c2ed341e376bf8778cf10a98ace072e2ea3bbe (diff)
downloadandroid_packages_apps_Trebuchet-ded0fdba52d94f8c841598a14dbece36a2f1849c.tar.gz
android_packages_apps_Trebuchet-ded0fdba52d94f8c841598a14dbece36a2f1849c.tar.bz2
android_packages_apps_Trebuchet-ded0fdba52d94f8c841598a14dbece36a2f1849c.zip
Removing logic for workspace migration from Launcher2
Change-Id: I8a121d74862f665c58406f8d5c7eb1263e7ccff3
-rw-r--r--res/drawable-nodpi/ic_migration.pngbin73676 -> 0 bytes
-rw-r--r--res/drawable/bg_migration_cling.xml11
-rw-r--r--res/layout-land/migration_cling.xml106
-rw-r--r--res/layout-port/migration_cling.xml109
-rw-r--r--res/values/strings.xml3
-rw-r--r--src/com/android/launcher3/Launcher.java59
-rw-r--r--src/com/android/launcher3/LauncherClings.java111
-rw-r--r--src/com/android/launcher3/LauncherModel.java33
-rw-r--r--src/com/android/launcher3/LauncherProvider.java279
-rw-r--r--src/com/android/launcher3/LauncherSettings.java1
10 files changed, 28 insertions, 684 deletions
diff --git a/res/drawable-nodpi/ic_migration.png b/res/drawable-nodpi/ic_migration.png
deleted file mode 100644
index 14f8721d8..000000000
--- a/res/drawable-nodpi/ic_migration.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/bg_migration_cling.xml b/res/drawable/bg_migration_cling.xml
deleted file mode 100644
index bfff5a41a..000000000
--- a/res/drawable/bg_migration_cling.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval" >
-
- <gradient
- android:endColor="#00ffeb3a"
- android:gradientRadius="50%p"
- android:startColor="#80ffeb3a"
- android:type="radial" />
-
-</shape> \ No newline at end of file
diff --git a/res/layout-land/migration_cling.xml b/res/layout-land/migration_cling.xml
deleted file mode 100644
index 269c1aee6..000000000
--- a/res/layout-land/migration_cling.xml
+++ /dev/null
@@ -1,106 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2011 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:launcher="http://schemas.android.com/apk/res-auto"
- android:id="@+id/migration_cling"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- launcher:layout_ignoreInsets="true"
- android:background="#FF009688"
- android:baselineAligned="false"
- android:gravity="center_vertical" >
-
- <FrameLayout
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1" >
-
- <ImageView
- android:layout_width="@dimen/cling_migration_bg_size"
- android:layout_height="@dimen/cling_migration_bg_size"
- android:layout_gravity="center"
- android:background="@drawable/bg_migration_cling" />
-
- <ImageView
- android:layout_width="@dimen/cling_migration_logo_width"
- android:layout_height="@dimen/cling_migration_logo_height"
- android:layout_gravity="center"
- android:src="@drawable/ic_migration" />
- </FrameLayout>
-
- <LinearLayout
- android:layout_width="@dimen/cling_migration_content_width"
- android:layout_height="wrap_content"
- android:layout_marginEnd="@dimen/cling_migration_content_margin"
- android:layout_marginRight="@dimen/cling_migration_content_margin"
- android:orientation="vertical"
- android:paddingLeft="24dp"
- android:paddingRight="24dp" >
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingBottom="8dp"
- android:text="@string/first_run_cling_title"
- android:textColor="#E1000000"
- android:textSize="34sp" />
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:fontFamily="sans-serif-medium"
- android:text="@string/migration_cling_title"
- android:textColor="#E1000000"
- android:textSize="20sp" />
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingBottom="24dp"
- android:text="@string/migration_cling_description"
- android:textColor="#99000000"
- android:textSize="16sp" />
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <Button
- android:id="@+id/cling_dismiss_migration_copy_apps"
- style="?android:attr/buttonBarButtonStyle"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:fontFamily="sans-serif-medium"
- android:text="@string/migration_cling_copy_apps"
- android:textColor="#FFFFFFFF"
- android:textSize="14sp" />
-
- <Button
- android:id="@+id/cling_dismiss_migration_use_default"
- style="?android:attr/buttonBarButtonStyle"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:fontFamily="sans-serif-medium"
- android:text="@string/migration_cling_use_default"
- android:textColor="#deFFFFFF"
- android:textSize="14sp" />
- </LinearLayout>
- </LinearLayout>
-
-</LinearLayout> \ No newline at end of file
diff --git a/res/layout-port/migration_cling.xml b/res/layout-port/migration_cling.xml
deleted file mode 100644
index 3f696a216..000000000
--- a/res/layout-port/migration_cling.xml
+++ /dev/null
@@ -1,109 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2011 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:launcher="http://schemas.android.com/apk/res-auto"
- android:id="@+id/migration_cling"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- launcher:layout_ignoreInsets="true"
- android:background="#FF009688" >
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical" >
-
- <ImageView
- android:layout_width="@dimen/cling_migration_bg_size"
- android:layout_height="@dimen/cling_migration_bg_size"
- android:layout_below="@+id/ic_cling_migration"
- android:layout_centerHorizontal="true"
- android:layout_marginTop="@dimen/cling_migration_bg_shift"
- android:src="@drawable/bg_migration_cling" />
-
- <ImageView
- android:id="@+id/ic_cling_migration"
- android:layout_width="@dimen/cling_migration_logo_width"
- android:layout_height="@dimen/cling_migration_logo_height"
- android:layout_alignParentTop="true"
- android:layout_centerHorizontal="true"
- android:src="@drawable/ic_migration" />
-
- <LinearLayout
- android:layout_width="@dimen/cling_migration_content_width"
- android:layout_height="wrap_content"
- android:layout_below="@+id/ic_cling_migration"
- android:layout_marginStart="@dimen/cling_migration_content_margin"
- android:layout_marginLeft="@dimen/cling_migration_content_margin"
- android:orientation="vertical"
- android:paddingLeft="24dp"
- android:paddingRight="24dp" >
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingBottom="8dp"
- android:text="@string/first_run_cling_title"
- android:textColor="#E1000000"
- android:textSize="34sp" />
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:fontFamily="sans-serif-medium"
- android:text="@string/migration_cling_title"
- android:textColor="#E1000000"
- android:textSize="20sp" />
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingBottom="24dp"
- android:text="@string/migration_cling_description"
- android:textColor="#99000000"
- android:textSize="16sp" />
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <Button
- android:id="@+id/cling_dismiss_migration_copy_apps"
- style="?android:attr/buttonBarButtonStyle"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:fontFamily="sans-serif-medium"
- android:text="@string/migration_cling_copy_apps"
- android:textColor="#FFFFFFFF"
- android:textSize="14sp" />
-
- <Button
- android:id="@+id/cling_dismiss_migration_use_default"
- style="?android:attr/buttonBarButtonStyle"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:fontFamily="sans-serif-medium"
- android:text="@string/migration_cling_use_default"
- android:textColor="#deFFFFFF"
- android:textSize="14sp" />
- </LinearLayout>
- </LinearLayout>
- </RelativeLayout>
-
-</FrameLayout> \ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4c9d0b5fa..e675a92c5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -21,9 +21,6 @@
<!-- General -->
<skip />
- <!-- URI used to import old favorites. [DO NOT TRANSLATE] -->
- <string name="old_launcher_provider_uri" translatable="false">content://com.android.launcher2.settings/favorites?notify=true</string>
-
<!-- Application name -->
<string name="app_name">Launcher3</string>
<!-- Default folder name -->
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index f487b12f6..ec09cf149 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -152,8 +152,6 @@ public class Launcher extends Activity
static final boolean DEBUG_RESUME_TIME = false;
static final boolean DEBUG_LOGGING = false;
- static final boolean ENABLE_DEBUG_INTENTS = false; // allow DebugIntents to run
-
private static final int REQUEST_CREATE_SHORTCUT = 1;
private static final int REQUEST_CREATE_APPWIDGET = 5;
private static final int REQUEST_PICK_APPWIDGET = 9;
@@ -201,9 +199,6 @@ public class Launcher extends Activity
private static final String QSB_WIDGET_ID = "qsb_widget_id";
private static final String QSB_WIDGET_PROVIDER = "qsb_widget_provider";
- public static final String USER_HAS_MIGRATED = "launcher.user_migrated_from_old_data";
- private static final String MIGRATE_AUTHORITY = "com.android.launcher2.settings";
-
/** The different states that Launcher can be in. */
enum State { NONE, WORKSPACE, WORKSPACE_SPRING_LOADED, APPS, APPS_SPRING_LOADED,
WIDGETS, WIDGETS_SPRING_LOADED }
@@ -1621,15 +1616,6 @@ public class Launcher extends Activity
} else if (Intent.ACTION_USER_PRESENT.equals(action)) {
mUserPresent = true;
updateAutoAdvanceState();
- } else if (ENABLE_DEBUG_INTENTS && DebugIntents.DELETE_DATABASE.equals(action)) {
- mModel.resetLoadedState(false, true);
- mModel.startLoader(PagedView.INVALID_RESTORE_PAGE,
- LauncherModel.LOADER_FLAG_CLEAR_WORKSPACE);
- } else if (ENABLE_DEBUG_INTENTS && DebugIntents.MIGRATE_DATABASE.equals(action)) {
- mModel.resetLoadedState(false, true);
- mModel.startLoader(PagedView.INVALID_RESTORE_PAGE,
- LauncherModel.LOADER_FLAG_CLEAR_WORKSPACE
- | LauncherModel.LOADER_FLAG_MIGRATE_SHORTCUTS);
}
}
};
@@ -1642,11 +1628,6 @@ public class Launcher extends Activity
final IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_USER_PRESENT);
- // For handling managed profiles
- if (ENABLE_DEBUG_INTENTS) {
- filter.addAction(DebugIntents.DELETE_DATABASE);
- filter.addAction(DebugIntents.MIGRATE_DATABASE);
- }
registerReceiver(mReceiver, filter);
FirstFrameAnimatorHelper.initializeDrawListener(getWindow().getDecorView());
mAttached = true;
@@ -4516,43 +4497,10 @@ public class Launcher extends Activity
LauncherClings launcherClings = new LauncherClings(this);
if (launcherClings.shouldShowFirstRunOrMigrationClings()) {
mClings = launcherClings;
- if (canMigrateFromOldLauncherDb()) {
- launcherClings.showMigrationCling();
- } else {
- launcherClings.showLongPressCling(true);
- }
+ launcherClings.showLongPressCling(true);
}
}
- private boolean canMigrateFromOldLauncherDb() {
- // Return true if launcher was not preinstalled and and old content provider exists.
- return ((getApplicationInfo().flags & ApplicationInfo.FLAG_SYSTEM) == 0) &&
- providerExists(MIGRATE_AUTHORITY) &&
- providerExists(Uri.parse(getString(R.string.old_launcher_provider_uri)).getAuthority());
-
- }
-
- private boolean providerExists(String authority) {
- return getPackageManager().resolveContentProvider(authority, 0) != null;
- }
-
-
- void showWorkspaceSearchAndHotseat() {
- if (mWorkspace != null) mWorkspace.setAlpha(1f);
- if (mHotseat != null) mHotseat.setAlpha(1f);
- if (mPageIndicator != null) mPageIndicator.setAlpha(1f);
- if (mSearchDropTargetBar != null) mSearchDropTargetBar.animateToState(
- SearchDropTargetBar.State.SEARCH_BAR, 0);
- }
-
- void hideWorkspaceSearchAndHotseat() {
- if (mWorkspace != null) mWorkspace.setAlpha(0f);
- if (mHotseat != null) mHotseat.setAlpha(0f);
- if (mPageIndicator != null) mPageIndicator.setAlpha(0f);
- if (mSearchDropTargetBar != null) mSearchDropTargetBar.animateToState(
- SearchDropTargetBar.State.INVISIBLE, 0);
- }
-
// TODO: These method should be a part of LauncherSearchCallback
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public ItemInfo createAppDragInfo(Intent appLaunchIntent) {
@@ -4706,8 +4654,3 @@ public class Launcher extends Activity
}
}
}
-
-interface DebugIntents {
- static final String DELETE_DATABASE = "com.android.launcher3.action.DELETE_DATABASE";
- static final String MIGRATE_DATABASE = "com.android.launcher3.action.MIGRATE_DATABASE";
-}
diff --git a/src/com/android/launcher3/LauncherClings.java b/src/com/android/launcher3/LauncherClings.java
index 1cfa3f7b3..c44969f8d 100644
--- a/src/com/android/launcher3/LauncherClings.java
+++ b/src/com/android/launcher3/LauncherClings.java
@@ -21,10 +21,7 @@ import android.animation.PropertyValuesHolder;
import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.pm.ApplicationInfo;
import android.graphics.drawable.Drawable;
-import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.UserManager;
@@ -42,7 +39,6 @@ import android.view.accessibility.AccessibilityManager;
import com.android.launcher3.util.Thunk;
class LauncherClings implements OnClickListener, OnKeyListener {
- private static final String MIGRATION_CLING_DISMISSED_KEY = "cling_gel.migration.dismissed";
private static final String WORKSPACE_CLING_DISMISSED_KEY = "cling_gel.workspace.dismissed";
private static final String TAG_CROP_TOP_AND_SIDES = "crop_bg_top_and_sides";
@@ -62,24 +58,7 @@ class LauncherClings implements OnClickListener, OnKeyListener {
@Override
public void onClick(View v) {
- int id = v.getId();
- if (id == R.id.cling_dismiss_migration_use_default) {
- // Disable the migration cling
- dismissMigrationCling();
- } else if (id == R.id.cling_dismiss_migration_copy_apps) {
- // Copy the shortcuts from the old database
- LauncherModel model = mLauncher.getModel();
- model.resetLoadedState(false, true);
- model.startLoader(PagedView.INVALID_RESTORE_PAGE,
- LauncherModel.LOADER_FLAG_CLEAR_WORKSPACE
- | LauncherModel.LOADER_FLAG_MIGRATE_SHORTCUTS);
- // Set the flag to skip the folder cling
- SharedPreferences.Editor editor = Utilities.getPrefs(mLauncher).edit();
- editor.putBoolean(Launcher.USER_HAS_MIGRATED, true);
- editor.apply();
- // Disable the migration cling
- dismissMigrationCling();
- } else if (id == R.id.cling_dismiss_longpress_info) {
+ if (v.getId() == R.id.cling_dismiss_longpress_info) {
dismissLongPressCling();
}
}
@@ -98,40 +77,6 @@ class LauncherClings implements OnClickListener, OnKeyListener {
return false;
}
- /**
- * Shows the migration cling.
- *
- * This flow is mutually exclusive with showFirstRunCling, and only runs if this Launcher
- * package was not preinstalled and there exists a db to migrate from.
- */
- public void showMigrationCling() {
- mLauncher.onLauncherClingShown();
- mIsVisible = true;
- mLauncher.hideWorkspaceSearchAndHotseat();
-
- ViewGroup root = (ViewGroup) mLauncher.findViewById(R.id.launcher);
- View inflated = mInflater.inflate(R.layout.migration_cling, root);
- inflated.findViewById(R.id.cling_dismiss_migration_copy_apps).setOnClickListener(this);
- inflated.findViewById(R.id.cling_dismiss_migration_use_default).setOnClickListener(this);
- }
-
- private void dismissMigrationCling() {
- mLauncher.showWorkspaceSearchAndHotseat();
- Runnable dismissCb = new Runnable() {
- public void run() {
- Runnable cb = new Runnable() {
- public void run() {
- // Show the longpress cling next
- showLongPressCling(false);
- }
- };
- dismissCling(mLauncher.findViewById(R.id.migration_cling), cb,
- MIGRATION_CLING_DISMISSED_KEY, DISMISS_CLING_DURATION);
- }
- };
- mLauncher.getWorkspace().post(dismissCb);
- }
-
public void showLongPressCling(boolean showWelcome) {
mIsVisible = true;
ViewGroup root = (ViewGroup) mLauncher.findViewById(R.id.launcher);
@@ -197,44 +142,28 @@ class LauncherClings implements OnClickListener, OnKeyListener {
@Thunk void dismissLongPressCling() {
Runnable dismissCb = new Runnable() {
public void run() {
- Runnable cb = new Runnable() {
- public void run() {
- mLauncher.onLauncherClingDismissed();
- }
- };
- dismissCling(mLauncher.findViewById(R.id.longpress_cling), cb,
- WORKSPACE_CLING_DISMISSED_KEY, DISMISS_CLING_DURATION);
+ final View cling = mLauncher.findViewById(R.id.longpress_cling);
+ // To catch cases where siblings of top-level views are made invisible, just check whether
+ // the cling is directly set to GONE before dismissing it.
+ if (cling != null && cling.getVisibility() != View.GONE) {
+ final Runnable cleanUpClingCb = new Runnable() {
+ public void run() {
+ cling.setVisibility(View.GONE);
+ mLauncher.getSharedPrefs().edit()
+ .putBoolean(WORKSPACE_CLING_DISMISSED_KEY, true)
+ .apply();
+ mIsVisible = false;
+ mLauncher.onLauncherClingDismissed();
+ }
+ };
+ cling.animate().alpha(0).setDuration(DISMISS_CLING_DURATION)
+ .withEndAction(cleanUpClingCb);
+ }
}
};
mLauncher.getWorkspace().post(dismissCb);
}
- /** Hides the specified Cling */
- @Thunk void dismissCling(final View cling, final Runnable postAnimationCb,
- final String flag, int duration) {
- // To catch cases where siblings of top-level views are made invisible, just check whether
- // the cling is directly set to GONE before dismissing it.
- if (cling != null && cling.getVisibility() != View.GONE) {
- final Runnable cleanUpClingCb = new Runnable() {
- public void run() {
- cling.setVisibility(View.GONE);
- mLauncher.getSharedPrefs().edit()
- .putBoolean(flag, true)
- .apply();
- mIsVisible = false;
- if (postAnimationCb != null) {
- postAnimationCb.run();
- }
- }
- };
- if (duration <= 0) {
- cleanUpClingCb.run();
- } else {
- cling.animate().alpha(0).setDuration(duration).withEndAction(cleanUpClingCb);
- }
- }
- }
-
public boolean isVisible() {
return mIsVisible;
}
@@ -269,10 +198,8 @@ class LauncherClings implements OnClickListener, OnKeyListener {
}
public boolean shouldShowFirstRunOrMigrationClings() {
- SharedPreferences sharedPrefs = mLauncher.getSharedPrefs();
return areClingsEnabled() &&
- !sharedPrefs.getBoolean(WORKSPACE_CLING_DISMISSED_KEY, false) &&
- !sharedPrefs.getBoolean(MIGRATION_CLING_DISMISSED_KEY, false);
+ !mLauncher.getSharedPrefs().getBoolean(WORKSPACE_CLING_DISMISSED_KEY, false);
}
public static void markFirstRunClingDismissed(Context ctx) {
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index fec96ca2e..f9cb9edea 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -97,10 +97,6 @@ public class LauncherModel extends BroadcastReceiver
static final String TAG = "Launcher.Model";
- 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;
@@ -1221,10 +1217,6 @@ public class LauncherModel extends BroadcastReceiver
}
public void startLoader(int synchronousBindPage) {
- startLoader(synchronousBindPage, LOADER_FLAG_NONE);
- }
-
- public void startLoader(int synchronousBindPage, int loadFlags) {
// Enable queue before starting loader. It will get disabled in Launcher#finishBindingItems
InstallShortcutReceiver.enableInstallQueue();
synchronized (mLock) {
@@ -1240,7 +1232,7 @@ public class LauncherModel extends BroadcastReceiver
// If there is already one running, tell it to stop.
stopLoaderLocked();
- mLoaderTask = new LoaderTask(mApp.getContext(), loadFlags, synchronousBindPage);
+ mLoaderTask = new LoaderTask(mApp.getContext(), synchronousBindPage);
if (synchronousBindPage != PagedView.INVALID_RESTORE_PAGE
&& mAllAppsLoaded && mWorkspaceLoaded && !mIsLoaderTaskRunning) {
mLoaderTask.runBindSynchronousPage(synchronousBindPage);
@@ -1299,11 +1291,9 @@ public class LauncherModel extends BroadcastReceiver
@Thunk boolean mIsLoadingAndBindingWorkspace;
private boolean mStopped;
@Thunk boolean mLoadAndBindStepFinished;
- private int mFlags;
- LoaderTask(Context context, int flags, int pageToBindFirst) {
+ LoaderTask(Context context, int pageToBindFirst) {
mContext = context;
- mFlags = flags;
mPageToBindFirst = pageToBindFirst;
}
@@ -1599,29 +1589,22 @@ public class LauncherModel extends BroadcastReceiver
int countX = profile.numColumns;
int countY = profile.numRows;
+ boolean clearDb = false;
if (GridSizeMigrationTask.ENABLED &&
!GridSizeMigrationTask.migrateGridIfNeeded(mContext)) {
// Migration failed. Clear workspace.
- mFlags = mFlags | LOADER_FLAG_CLEAR_WORKSPACE;
+ clearDb = true;
}
- if ((mFlags & LOADER_FLAG_CLEAR_WORKSPACE) != 0) {
+ if (clearDb) {
Log.d(TAG, "loadWorkspace: resetting launcher database");
LauncherSettings.Settings.call(contentResolver,
LauncherSettings.Settings.METHOD_DELETE_DB);
}
- if ((mFlags & LOADER_FLAG_MIGRATE_SHORTCUTS) != 0) {
- // append the user's Launcher2 shortcuts
- Log.d(TAG, "loadWorkspace: migrating from launcher2");
- LauncherSettings.Settings.call(contentResolver,
- LauncherSettings.Settings.METHOD_MIGRATE_LAUNCHER2_SHORTCUTS);
- } else {
- // Make sure the default workspace is loaded
- Log.d(TAG, "loadWorkspace: loading default favorites");
- LauncherSettings.Settings.call(contentResolver,
- LauncherSettings.Settings.METHOD_LOAD_DEFAULT_FAVORITES);
- }
+ Log.d(TAG, "loadWorkspace: loading default favorites");
+ LauncherSettings.Settings.call(contentResolver,
+ LauncherSettings.Settings.METHOD_LOAD_DEFAULT_FAVORITES);
synchronized (sBgLock) {
clearSBgDataStructures();
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index 7ebee31e4..11d61d02f 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -363,13 +363,6 @@ public class LauncherProvider extends ContentProvider {
loadDefaultFavoritesIfNecessary();
return null;
}
- case LauncherSettings.Settings.METHOD_MIGRATE_LAUNCHER2_SHORTCUTS: {
- mOpenHelper.migrateLauncher2Shortcuts(mOpenHelper.getWritableDatabase(),
- Uri.parse(getContext().getString(R.string.old_launcher_provider_uri)));
- Utilities.getPrefs(getContext()).edit().putBoolean(EMPTY_DATABASE_CREATED, false)
- .commit();
- return null;
- }
case LauncherSettings.Settings.METHOD_UPDATE_FOLDER_ITEMS_RANK: {
mOpenHelper.updateFolderItemsRank(mOpenHelper.getWritableDatabase(), false);
return null;
@@ -1033,278 +1026,6 @@ public class LauncherProvider extends ContentProvider {
return count;
}
-
- @Thunk void migrateLauncher2Shortcuts(SQLiteDatabase db, Uri uri) {
- final ContentResolver resolver = mContext.getContentResolver();
- Cursor c = null;
- int count = 0;
- int curScreen = 0;
-
- try {
- c = resolver.query(uri, null, null, null, "title ASC");
- } catch (Exception e) {
- // Ignore
- }
-
- // We already have a favorites database in the old provider
- if (c != null) {
- try {
- if (c.getCount() > 0) {
- final int idIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites._ID);
- final int intentIndex
- = c.getColumnIndexOrThrow(LauncherSettings.Favorites.INTENT);
- final int titleIndex
- = c.getColumnIndexOrThrow(LauncherSettings.Favorites.TITLE);
- final int iconIndex
- = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ICON);
- final int iconPackageIndex
- = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ICON_PACKAGE);
- final int iconResourceIndex
- = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ICON_RESOURCE);
- final int containerIndex
- = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CONTAINER);
- final int itemTypeIndex
- = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ITEM_TYPE);
- final int screenIndex
- = c.getColumnIndexOrThrow(LauncherSettings.Favorites.SCREEN);
- final int cellXIndex
- = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLX);
- final int cellYIndex
- = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLY);
- final int profileIndex
- = c.getColumnIndex(LauncherSettings.Favorites.PROFILE_ID);
-
- int i = 0;
- int curX = 0;
- int curY = 0;
-
- final LauncherAppState app = LauncherAppState.getInstance();
- final InvariantDeviceProfile profile = app.getInvariantDeviceProfile();
- final int width = (int) profile.numColumns;
- final int height = (int) profile.numRows;
- final int hotseatWidth = (int) profile.numHotseatIcons;
-
- final HashSet<String> seenIntents = new HashSet<String>(c.getCount());
-
- 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);
- if (itemType != Favorites.ITEM_TYPE_APPLICATION
- && itemType != Favorites.ITEM_TYPE_SHORTCUT
- && itemType != Favorites.ITEM_TYPE_FOLDER) {
- continue;
- }
-
- final int cellX = c.getInt(cellXIndex);
- final int cellY = c.getInt(cellYIndex);
- final int screen = c.getInt(screenIndex);
- int container = c.getInt(containerIndex);
- final String intentStr = c.getString(intentIndex);
-
- UserManagerCompat userManager = UserManagerCompat.getInstance(mContext);
- UserHandleCompat userHandle;
- final long userSerialNumber;
- if (profileIndex != -1 && !c.isNull(profileIndex)) {
- userSerialNumber = c.getInt(profileIndex);
- userHandle = userManager.getUserForSerialNumber(userSerialNumber);
- } else {
- // Default to the serial number of this user, for older
- // shortcuts.
- userHandle = UserHandleCompat.myUserHandle();
- userSerialNumber = userManager.getSerialNumberForUser(userHandle);
- }
-
- if (userHandle == null) {
- Log.d(TAG, "skipping deleted user");
- continue;
- }
-
- if (itemType != Favorites.ITEM_TYPE_FOLDER) {
-
- final Intent intent;
- final ComponentName cn;
- try {
- intent = Intent.parseUri(intentStr, 0);
- } catch (URISyntaxException e) {
- // bogus intent?
- Log.d(TAG, "skipping invalid intent uri");
- continue;
- }
-
- cn = intent.getComponent();
- if (TextUtils.isEmpty(intentStr)) {
- // no intent? no icon
- Log.d(TAG, "skipping empty intent");
- continue;
- } else if (cn != null &&
- !LauncherModel.isValidPackageActivity(mContext, cn,
- userHandle)) {
- // component no longer exists.
- Log.d(TAG, "skipping item whose component no longer exists.");
- continue;
- } 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.
- // Also ignore intent flags for the purposes of deduping.
- intent.setPackage(null);
- int flags = intent.getFlags();
- intent.setFlags(0);
- final String key = intent.toUri(0);
- intent.setFlags(flags);
- if (seenIntents.contains(key)) {
- Log.d(TAG, "skipping duplicate");
- continue;
- } else {
- seenIntents.add(key);
- }
- }
- }
-
- ContentValues values = new ContentValues(c.getColumnCount());
- values.put(LauncherSettings.Favorites._ID, c.getInt(idIndex));
- values.put(LauncherSettings.Favorites.INTENT, intentStr);
- values.put(LauncherSettings.Favorites.TITLE, c.getString(titleIndex));
- values.put(LauncherSettings.Favorites.ICON, c.getBlob(iconIndex));
- values.put(LauncherSettings.Favorites.ICON_PACKAGE,
- c.getString(iconPackageIndex));
- values.put(LauncherSettings.Favorites.ICON_RESOURCE,
- c.getString(iconResourceIndex));
- values.put(LauncherSettings.Favorites.ITEM_TYPE, itemType);
- values.put(LauncherSettings.Favorites.APPWIDGET_ID, -1);
- values.put(LauncherSettings.Favorites.PROFILE_ID, userSerialNumber);
-
- if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
- hotseat.put(screen, values);
- }
-
- if (container != LauncherSettings.Favorites.CONTAINER_DESKTOP) {
- // In a folder or in the hotseat, preserve position
- values.put(LauncherSettings.Favorites.SCREEN, screen);
- values.put(LauncherSettings.Favorites.CELLX, cellX);
- values.put(LauncherSettings.Favorites.CELLY, cellY);
- } else {
- // 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);
-
- if (itemType != Favorites.ITEM_TYPE_FOLDER) {
- shortcuts.add(values);
- } else {
- folders.add(values);
- }
- }
-
- // 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 == profile.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);
- // 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 (allItems.size() > 0) {
- db.beginTransaction();
- try {
- for (ContentValues row: allItems) {
- if (row == null) continue;
- if (dbInsertAndCheck(this, db, Favorites.TABLE_NAME, null, row)
- < 0) {
- return;
- } else {
- count++;
- }
- }
- db.setTransactionSuccessful();
- } finally {
- db.endTransaction();
- }
- }
-
- db.beginTransaction();
- try {
- for (i=0; i<=curScreen; i++) {
- final ContentValues values = new ContentValues();
- values.put(LauncherSettings.WorkspaceScreens._ID, i);
- values.put(LauncherSettings.WorkspaceScreens.SCREEN_RANK, i);
- if (dbInsertAndCheck(this, db, WorkspaceScreens.TABLE_NAME, null, values)
- < 0) {
- return;
- }
- }
- db.setTransactionSuccessful();
- } finally {
- db.endTransaction();
- }
-
- updateFolderItemsRank(db, false);
- }
- } finally {
- c.close();
- }
- }
-
- Log.d(TAG, "migrated " + count + " icons from Launcher2 into "
- + (curScreen+1) + " screens");
-
- // Update max IDs; very important since we just grabbed IDs from another database
- mMaxItemId = initializeMaxItemId(db);
- mMaxScreenId = initializeMaxScreenId(db);
- if (LOGD) Log.d(TAG, "mMaxItemId: " + mMaxItemId + " mMaxScreenId: " + mMaxScreenId);
- }
}
/**
diff --git a/src/com/android/launcher3/LauncherSettings.java b/src/com/android/launcher3/LauncherSettings.java
index 45a87cc02..52668d721 100644
--- a/src/com/android/launcher3/LauncherSettings.java
+++ b/src/com/android/launcher3/LauncherSettings.java
@@ -291,7 +291,6 @@ public class LauncherSettings {
public static final String METHOD_DELETE_DB = "delete_db";
public static final String METHOD_LOAD_DEFAULT_FAVORITES = "load_default_favorites";
- public static final String METHOD_MIGRATE_LAUNCHER2_SHORTCUTS = "migrate_l2_shortcuts";
public static final String METHOD_SET_EXTRACTED_COLORS_AND_WALLPAPER_ID =
"set_extracted_colors_and_wallpaper_id_setting";