diff options
-rw-r--r-- | AndroidManifest.xml | 15 | ||||
-rw-r--r-- | res/values/strings.xml | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/AppWidgetsRestoredReceiver.java | 5 | ||||
-rw-r--r-- | src/com/android/launcher3/AppsContainerRecyclerView.java | 14 | ||||
-rw-r--r-- | src/com/android/launcher3/AutoInstallsLayout.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/Folder.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 11 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherAppState.java | 27 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherBackupAgentHelper.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherBackupHelper.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherCallbacks.java | 1 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherExtension.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherModel.java | 28 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherProvider.java | 26 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherSettings.java | 27 | ||||
-rw-r--r-- | src/com/android/launcher3/UninstallShortcutReceiver.java | 112 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 5 |
17 files changed, 72 insertions, 213 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 8c837cc1d..f43106f18 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -29,12 +29,6 @@ android:label="@string/permlab_install_shortcut" android:description="@string/permdesc_install_shortcut" /> <permission - android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" - android:permissionGroup="android.permission-group.SYSTEM_TOOLS" - android:protectionLevel="dangerous" - android:label="@string/permlab_uninstall_shortcut" - android:description="@string/permdesc_uninstall_shortcut"/> - <permission android:name="com.android.launcher3.permission.READ_SETTINGS" android:permissionGroup="android.permission-group.SYSTEM_TOOLS" android:protectionLevel="normal" @@ -191,15 +185,6 @@ </intent-filter> </receiver> - <!-- Intent received used to uninstall shortcuts from other applications --> - <receiver - android:name="com.android.launcher3.UninstallShortcutReceiver" - android:permission="com.android.launcher.permission.UNINSTALL_SHORTCUT"> - <intent-filter> - <action android:name="com.android.launcher.action.UNINSTALL_SHORTCUT" /> - </intent-filter> - </receiver> - <!-- Intent received used to initialize a restored widget --> <receiver android:name="com.android.launcher3.AppWidgetsRestoredReceiver" > <intent-filter> diff --git a/res/values/strings.xml b/res/values/strings.xml index 0b34d00a8..7f79b984c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -113,8 +113,6 @@ s --> <string name="invalid_hotseat_item">This widget is too large for the Favorites tray</string> <!-- Message displayed when a shortcut is created by an external application --> <string name="shortcut_installed">Shortcut \"<xliff:g id="name" example="Browser">%s</xliff:g>\" created.</string> - <!-- Message displayed when a shortcut is uninstalled by an external application --> - <string name="shortcut_uninstalled">Shortcut \"<xliff:g id="name" example="Browser">%s</xliff:g>\" was removed.</string> <!-- Message displayed when an external application attemps to create a shortcut that already exists --> <string name="shortcut_duplicate">Shortcut \"<xliff:g id="name" example="Browser">%s</xliff:g>\" already exists.</string> diff --git a/src/com/android/launcher3/AppWidgetsRestoredReceiver.java b/src/com/android/launcher3/AppWidgetsRestoredReceiver.java index 880aaf1ec..5e7a012d2 100644 --- a/src/com/android/launcher3/AppWidgetsRestoredReceiver.java +++ b/src/com/android/launcher3/AppWidgetsRestoredReceiver.java @@ -90,5 +90,10 @@ public class AppWidgetsRestoredReceiver extends BroadcastReceiver { } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null); } + + LauncherAppState app = LauncherAppState.getInstanceNoCreate(); + if (app != null) { + app.reloadWorkspace(); + } } } diff --git a/src/com/android/launcher3/AppsContainerRecyclerView.java b/src/com/android/launcher3/AppsContainerRecyclerView.java index 0cc651417..b942ea451 100644 --- a/src/com/android/launcher3/AppsContainerRecyclerView.java +++ b/src/com/android/launcher3/AppsContainerRecyclerView.java @@ -23,6 +23,7 @@ import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.drawable.Drawable; +import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.AttributeSet; import android.view.MotionEvent; @@ -290,14 +291,14 @@ public class AppsContainerRecyclerView extends RecyclerView // Get the total number of rows int rowCount = getNumRows(); - // Find the index of the first app in that row and scroll to that position + // Find the position of the first application in the section that contains the row at the + // current progress int rowAtProgress = (int) (progress * rowCount); int appIndex = 0; rowCount = 0; for (AlphabeticalAppsList.SectionInfo info : sections) { int numRowsInSection = (int) Math.ceil((float) info.numAppsInSection / mNumAppsPerRow); if (rowCount + numRowsInSection > rowAtProgress) { - appIndex += (rowAtProgress - rowCount) * mNumAppsPerRow; break; } rowCount += numRowsInSection; @@ -306,9 +307,14 @@ public class AppsContainerRecyclerView extends RecyclerView appIndex = Math.max(0, Math.min(mApps.getAppsWithoutSectionBreaks().size() - 1, appIndex)); AppInfo appInfo = mApps.getAppsWithoutSectionBreaks().get(appIndex); int sectionedAppIndex = mApps.getApps().indexOf(appInfo); - scrollToPosition(sectionedAppIndex); - // Returns the section name of the row + // Scroll the position into view, anchored at the top of the screen if possible. We call the + // scroll method on the LayoutManager directly since it is not exposed by RecyclerView. + LinearLayoutManager layoutManager = (LinearLayoutManager) getLayoutManager(); + stopScroll(); + layoutManager.scrollToPositionWithOffset(sectionedAppIndex, 0); + + // Return the section name of the row return mApps.getSectionNameForApp(appInfo); } diff --git a/src/com/android/launcher3/AutoInstallsLayout.java b/src/com/android/launcher3/AutoInstallsLayout.java index 9180dcf42..dac79a8ef 100644 --- a/src/com/android/launcher3/AutoInstallsLayout.java +++ b/src/com/android/launcher3/AutoInstallsLayout.java @@ -606,7 +606,7 @@ public class AutoInstallsLayout { // failed to add, and less than 2 were actually added if (folderItems.size() < 2) { // Delete the folder - Uri uri = Favorites.getContentUri(folderId, false); + Uri uri = Favorites.getContentUri(folderId); SqlArguments args = new SqlArguments(uri, null, null); mDb.delete(args.table, args.where, args.args); addedId = -1; diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java index 23582cec8..4529a9459 100644 --- a/src/com/android/launcher3/Folder.java +++ b/src/com/android/launcher3/Folder.java @@ -845,7 +845,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList View v = list.get(i); ItemInfo info = (ItemInfo) v.getTag(); LauncherModel.addItemToDatabase(mLauncher, info, mInfo.id, 0, - info.cellX, info.cellY, false); + info.cellX, info.cellY); } } diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 5be57f444..8a21d624c 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1554,7 +1554,7 @@ public class Launcher extends Activity return; } - LauncherModel.addItemToDatabase(this, info, container, screenId, cellXY[0], cellXY[1], false); + LauncherModel.addItemToDatabase(this, info, container, screenId, cellXY[0], cellXY[1]); if (!mRestoring) { mWorkspace.addInScreen(view, container, screenId, cellXY[0], cellXY[1], 1, 1, @@ -1616,7 +1616,7 @@ public class Launcher extends Activity launcherInfo.user = mAppWidgetManager.getUser(appWidgetInfo); LauncherModel.addItemToDatabase(this, launcherInfo, - container, screenId, info.cellX, info.cellY, false); + container, screenId, info.cellX, info.cellY); if (!mRestoring) { if (hostView == null) { @@ -2409,8 +2409,8 @@ public class Launcher extends Activity folderInfo.title = getText(R.string.folder_name); // Update the model - LauncherModel.addItemToDatabase(Launcher.this, folderInfo, container, screenId, cellX, cellY, - false); + LauncherModel.addItemToDatabase(Launcher.this, folderInfo, container, screenId, + cellX, cellY); sFolders.put(folderInfo.id, folderInfo); // Create the view @@ -3282,6 +3282,9 @@ public class Launcher extends Activity mAppsCustomizeTabHost.trimMemory(); } } + if (mLauncherCallbacks != null) { + mLauncherCallbacks.onTrimMemory(level); + } } @Override diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java index 555b1ccad..2a08b8176 100644 --- a/src/com/android/launcher3/LauncherAppState.java +++ b/src/com/android/launcher3/LauncherAppState.java @@ -19,16 +19,13 @@ package com.android.launcher3; import android.annotation.TargetApi; import android.app.SearchManager; import android.content.ComponentName; -import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.res.Configuration; import android.content.res.Resources; -import android.database.ContentObserver; import android.graphics.Point; import android.os.Build; -import android.os.Handler; import android.util.DisplayMetrics; import android.util.Log; import android.view.Display; @@ -116,11 +113,6 @@ public class LauncherAppState implements DeviceProfile.DeviceProfileCallbacks { filter.addAction(SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED); filter.addAction(SearchManager.INTENT_ACTION_SEARCHABLES_CHANGED); sContext.registerReceiver(mModel, filter); - - // Register for changes to the favorites - ContentResolver resolver = sContext.getContentResolver(); - resolver.registerContentObserver(LauncherSettings.Favorites.CONTENT_URI, true, - mFavoritesObserver); } /** @@ -131,23 +123,16 @@ public class LauncherAppState implements DeviceProfile.DeviceProfileCallbacks { final LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(sContext); launcherApps.removeOnAppsChangedCallback(mModel); PackageInstallerCompat.getInstance(sContext).onStop(); - - ContentResolver resolver = sContext.getContentResolver(); - resolver.unregisterContentObserver(mFavoritesObserver); } /** - * Receives notifications whenever the user favorites have changed. + * Reloads the workspace items from the DB and re-binds the workspace. This should generally + * not be called as DB updates are automatically followed by UI update */ - private final ContentObserver mFavoritesObserver = new ContentObserver(new Handler()) { - @Override - public void onChange(boolean selfChange) { - // If the database has ever changed, then we really need to force a reload of the - // workspace on the next load - mModel.resetLoadedState(false, true); - mModel.startLoaderFromBackground(); - } - }; + public void reloadWorkspace() { + mModel.resetLoadedState(false, true); + mModel.startLoaderFromBackground(); + } LauncherModel setLauncher(Launcher launcher) { mModel.initialize(launcher); diff --git a/src/com/android/launcher3/LauncherBackupAgentHelper.java b/src/com/android/launcher3/LauncherBackupAgentHelper.java index ddfd70d6b..5f7173fac 100644 --- a/src/com/android/launcher3/LauncherBackupAgentHelper.java +++ b/src/com/android/launcher3/LauncherBackupAgentHelper.java @@ -78,7 +78,7 @@ public class LauncherBackupAgentHelper extends BackupAgentHelper { super.onRestore(data, appVersionCode, newState); // If no favorite was migrated, clear the data and start fresh. final Cursor c = getContentResolver().query( - LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, null, null, null, null); + LauncherSettings.Favorites.CONTENT_URI, null, null, null, null); hasData = c.moveToNext(); c.close(); } catch (Exception e) { diff --git a/src/com/android/launcher3/LauncherBackupHelper.java b/src/com/android/launcher3/LauncherBackupHelper.java index c03480065..064f4363a 100644 --- a/src/com/android/launcher3/LauncherBackupHelper.java +++ b/src/com/android/launcher3/LauncherBackupHelper.java @@ -462,7 +462,7 @@ public class LauncherBackupHelper implements BackupHelper { ContentResolver cr = mContext.getContentResolver(); ContentValues values = unpackFavorite(buffer, dataSize); - cr.insert(Favorites.CONTENT_URI_NO_NOTIFICATION, values); + cr.insert(Favorites.CONTENT_URI, values); } /** diff --git a/src/com/android/launcher3/LauncherCallbacks.java b/src/com/android/launcher3/LauncherCallbacks.java index a1f4e0b90..d8128d6e5 100644 --- a/src/com/android/launcher3/LauncherCallbacks.java +++ b/src/com/android/launcher3/LauncherCallbacks.java @@ -42,6 +42,7 @@ public interface LauncherCallbacks { public void dump(String prefix, FileDescriptor fd, PrintWriter w, String[] args); public void onHomeIntent(); public boolean handleBackPressed(); + public void onTrimMemory(int level); /* * Extension points for providing custom behavior on certain user interactions. diff --git a/src/com/android/launcher3/LauncherExtension.java b/src/com/android/launcher3/LauncherExtension.java index b264042cf..fe9bd6c23 100644 --- a/src/com/android/launcher3/LauncherExtension.java +++ b/src/com/android/launcher3/LauncherExtension.java @@ -108,6 +108,10 @@ public class LauncherExtension extends Launcher { } @Override + public void onTrimMemory(int level) { + } + + @Override public void onLauncherProviderChange() { } diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index dcb375928..c6ed0da82 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -566,7 +566,7 @@ public class LauncherModel extends BroadcastReceiver // Add the shortcut to the db addItemToDatabase(context, shortcutInfo, LauncherSettings.Favorites.CONTAINER_DESKTOP, - screenId, cordinates[0], cordinates[1], false); + screenId, cordinates[0], cordinates[1]); // Save the ShortcutInfo for binding in the workspace addedShortcutsFinal.add(shortcutInfo); } @@ -652,7 +652,7 @@ public class LauncherModel extends BroadcastReceiver long screenId, int cellX, int cellY) { if (item.container == ItemInfo.NO_ID) { // From all apps - addItemToDatabase(context, item, container, screenId, cellX, cellY, false); + addItemToDatabase(context, item, container, screenId, cellX, cellY); } else { // From somewhere else moveItemInDatabase(context, item, container, screenId, cellX, cellY); @@ -718,7 +718,7 @@ public class LauncherModel extends BroadcastReceiver static void updateItemInDatabaseHelper(Context context, final ContentValues values, final ItemInfo item, final String callingFunction) { final long itemId = item.id; - final Uri uri = LauncherSettings.Favorites.getContentUri(itemId, false); + final Uri uri = LauncherSettings.Favorites.getContentUri(itemId); final ContentResolver cr = context.getContentResolver(); final StackTraceElement[] stackTrace = new Throwable().getStackTrace(); @@ -744,7 +744,7 @@ public class LauncherModel extends BroadcastReceiver for (int i = 0; i < count; i++) { ItemInfo item = items.get(i); final long itemId = item.id; - final Uri uri = LauncherSettings.Favorites.getContentUri(itemId, false); + final Uri uri = LauncherSettings.Favorites.getContentUri(itemId); ContentValues values = valuesList.get(i); ops.add(ContentProviderOperation.newUpdate(uri).withValues(values).build()); @@ -994,7 +994,7 @@ public class LauncherModel extends BroadcastReceiver * cellY fields of the item. Also assigns an ID to the item. */ static void addItemToDatabase(Context context, final ItemInfo item, final long container, - final long screenId, final int cellX, final int cellY, final boolean notify) { + final long screenId, final int cellX, final int cellY) { item.container = container; item.cellX = cellX; item.cellY = cellY; @@ -1017,8 +1017,7 @@ public class LauncherModel extends BroadcastReceiver final StackTraceElement[] stackTrace = new Throwable().getStackTrace(); Runnable r = new Runnable() { public void run() { - cr.insert(notify ? LauncherSettings.Favorites.CONTENT_URI : - LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, values); + cr.insert(LauncherSettings.Favorites.CONTENT_URI, values); // Lock on mBgLock *after* the db operation synchronized (sBgLock) { @@ -1102,7 +1101,7 @@ public class LauncherModel extends BroadcastReceiver Runnable r = new Runnable() { public void run() { for (ItemInfo item : items) { - final Uri uri = LauncherSettings.Favorites.getContentUri(item.id, false); + final Uri uri = LauncherSettings.Favorites.getContentUri(item.id); cr.delete(uri, null, null); // Lock on mBgLock *after* the db operation @@ -1197,7 +1196,7 @@ public class LauncherModel extends BroadcastReceiver Runnable r = new Runnable() { public void run() { - cr.delete(LauncherSettings.Favorites.getContentUri(info.id, false), null, null); + cr.delete(LauncherSettings.Favorites.getContentUri(info.id), null, null); // Lock on mBgLock *after* the db operation synchronized (sBgLock) { sBgItemsIdMap.remove(info.id); @@ -1205,7 +1204,7 @@ public class LauncherModel extends BroadcastReceiver sBgWorkspaceItems.remove(info); } - cr.delete(LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, + cr.delete(LauncherSettings.Favorites.CONTENT_URI, LauncherSettings.Favorites.CONTAINER + "=" + info.id, null); // Lock on mBgLock *after* the db operation synchronized (sBgLock) { @@ -1823,7 +1822,7 @@ public class LauncherModel extends BroadcastReceiver final ArrayList<Long> itemsToRemove = new ArrayList<Long>(); final ArrayList<Long> restoredRows = new ArrayList<Long>(); - final Uri contentUri = LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION; + final Uri contentUri = LauncherSettings.Favorites.CONTENT_URI; if (DEBUG_LOADERS) Log.d(TAG, "loading model from " + contentUri); final Cursor c = contentResolver.query(contentUri, null, null, null, null); @@ -2304,8 +2303,7 @@ public class LauncherModel extends BroadcastReceiver } // Don't notify content observers try { - client.delete(LauncherSettings.Favorites.getContentUri(id, false), - null, null); + client.delete(LauncherSettings.Favorites.getContentUri(id), null, null); } catch (RemoteException e) { Log.w(TAG, "Could not remove id = " + id); } @@ -2324,7 +2322,7 @@ public class LauncherModel extends BroadcastReceiver selectionBuilder.append(")"); ContentValues values = new ContentValues(); values.put(LauncherSettings.Favorites.RESTORED, 0); - updater.update(LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, + updater.update(LauncherSettings.Favorites.CONTENT_URI, values, selectionBuilder.toString(), null); } catch (RemoteException e) { Log.w(TAG, "Could not update restored rows"); @@ -2395,7 +2393,7 @@ public class LauncherModel extends BroadcastReceiver */ private void updateItem(long itemId, ContentValues update) { mContext.getContentResolver().update( - LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, + LauncherSettings.Favorites.CONTENT_URI, update, BaseColumns._ID + "= ?", new String[]{Long.toString(itemId)}); diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java index dfacfa3e4..a23553a04 100644 --- a/src/com/android/launcher3/LauncherProvider.java +++ b/src/com/android/launcher3/LauncherProvider.java @@ -70,7 +70,6 @@ public class LauncherProvider extends ContentProvider { static final String TABLE_FAVORITES = "favorites"; static final String TABLE_WORKSPACE_SCREENS = "workspaceScreens"; - static final String PARAMETER_NOTIFY = "notify"; static final String EMPTY_DATABASE_CREATED = "EMPTY_DATABASE_CREATED"; private static final String URI_PARAM_IS_EXTERNAL_ADD = "isExternalAdd"; @@ -150,7 +149,8 @@ public class LauncherProvider extends ContentProvider { // In very limited cases, we support system|signature permission apps to add to the db String externalAdd = uri.getQueryParameter(URI_PARAM_IS_EXTERNAL_ADD); - if (externalAdd != null && "true".equals(externalAdd)) { + final boolean isExternalAll = externalAdd != null && "true".equals(externalAdd); + if (isExternalAll) { if (!mOpenHelper.initializeExternalAdd(initialValues)) { return null; } @@ -162,7 +162,14 @@ public class LauncherProvider extends ContentProvider { if (rowId < 0) return null; uri = ContentUris.withAppendedId(uri, rowId); - sendNotify(uri); + notifyListeners(); + + if (isExternalAll) { + LauncherAppState app = LauncherAppState.getInstanceNoCreate(); + if (app != null) { + app.reloadWorkspace(); + } + } return uri; } @@ -187,7 +194,7 @@ public class LauncherProvider extends ContentProvider { db.endTransaction(); } - sendNotify(uri); + notifyListeners(); return values.length; } @@ -211,7 +218,7 @@ public class LauncherProvider extends ContentProvider { SQLiteDatabase db = mOpenHelper.getWritableDatabase(); int count = db.delete(args.table, args.where, args.args); - if (count > 0) sendNotify(uri); + if (count > 0) notifyListeners(); return count; } @@ -223,17 +230,12 @@ public class LauncherProvider extends ContentProvider { addModifiedTime(values); SQLiteDatabase db = mOpenHelper.getWritableDatabase(); int count = db.update(args.table, values, args.where, args.args); - if (count > 0) sendNotify(uri); + if (count > 0) notifyListeners(); return count; } - private void sendNotify(Uri uri) { - String notify = uri.getQueryParameter(PARAMETER_NOTIFY); - if (notify == null || "true".equals(notify)) { - getContext().getContentResolver().notifyChange(uri, null); - } - + private void notifyListeners() { // always notify the backup agent LauncherBackupAgentHelper.dataChanged(getContext()); if (mListener != null) { diff --git a/src/com/android/launcher3/LauncherSettings.java b/src/com/android/launcher3/LauncherSettings.java index d161fbb3d..d657cb50f 100644 --- a/src/com/android/launcher3/LauncherSettings.java +++ b/src/com/android/launcher3/LauncherSettings.java @@ -109,8 +109,7 @@ class LauncherSettings { * The content:// style URL for this table */ static final Uri CONTENT_URI = Uri.parse("content://" + - LauncherProvider.AUTHORITY + "/" + LauncherProvider.TABLE_WORKSPACE_SCREENS + - "?" + LauncherProvider.PARAMETER_NOTIFY + "=true"); + LauncherProvider.AUTHORITY + "/" + LauncherProvider.TABLE_WORKSPACE_SCREENS); /** * The rank of this screen -- ie. how it is ordered relative to the other screens. @@ -127,36 +126,18 @@ class LauncherSettings { * The content:// style URL for this table */ static final Uri CONTENT_URI = Uri.parse("content://" + - LauncherProvider.AUTHORITY + "/" + LauncherProvider.TABLE_FAVORITES + - "?" + LauncherProvider.PARAMETER_NOTIFY + "=true"); - - /** - * The content:// style URL for this table - */ - static final Uri OLD_CONTENT_URI = Uri.parse("content://" + - LauncherProvider.OLD_AUTHORITY + "/" + LauncherProvider.TABLE_FAVORITES + - "?" + LauncherProvider.PARAMETER_NOTIFY + "=true"); - - /** - * The content:// style URL for this table. When this Uri is used, no notification is - * sent if the content changes. - */ - static final Uri CONTENT_URI_NO_NOTIFICATION = Uri.parse("content://" + - LauncherProvider.AUTHORITY + "/" + LauncherProvider.TABLE_FAVORITES + - "?" + LauncherProvider.PARAMETER_NOTIFY + "=false"); + LauncherProvider.AUTHORITY + "/" + LauncherProvider.TABLE_FAVORITES); /** * The content:// style URL for a given row, identified by its id. * * @param id The row id. - * @param notify True to send a notification is the content changes. * * @return The unique content URL for the specified row. */ - static Uri getContentUri(long id, boolean notify) { + static Uri getContentUri(long id) { return Uri.parse("content://" + LauncherProvider.AUTHORITY + - "/" + LauncherProvider.TABLE_FAVORITES + "/" + id + "?" + - LauncherProvider.PARAMETER_NOTIFY + "=" + notify); + "/" + LauncherProvider.TABLE_FAVORITES + "/" + id); } /** diff --git a/src/com/android/launcher3/UninstallShortcutReceiver.java b/src/com/android/launcher3/UninstallShortcutReceiver.java index c9d0bb5f5..59e4cb591 100644 --- a/src/com/android/launcher3/UninstallShortcutReceiver.java +++ b/src/com/android/launcher3/UninstallShortcutReceiver.java @@ -17,117 +17,11 @@ package com.android.launcher3; import android.content.BroadcastReceiver; -import android.content.ContentResolver; import android.content.Context; import android.content.Intent; -import android.database.Cursor; -import android.net.Uri; -import android.widget.Toast; - -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Iterator; +//TODO: Remove this public class UninstallShortcutReceiver extends BroadcastReceiver { - private static final String ACTION_UNINSTALL_SHORTCUT = - "com.android.launcher.action.UNINSTALL_SHORTCUT"; - - // The set of shortcuts that are pending uninstall - private static ArrayList<PendingUninstallShortcutInfo> mUninstallQueue = - new ArrayList<PendingUninstallShortcutInfo>(); - - // Determines whether to defer uninstalling shortcuts immediately until - // disableAndFlushUninstallQueue() is called. - private static boolean mUseUninstallQueue = false; - - private static class PendingUninstallShortcutInfo { - Intent data; - - public PendingUninstallShortcutInfo(Intent rawData) { - data = rawData; - } - } - - public void onReceive(Context context, Intent data) { - if (!ACTION_UNINSTALL_SHORTCUT.equals(data.getAction())) { - return; - } - - PendingUninstallShortcutInfo info = new PendingUninstallShortcutInfo(data); - if (mUseUninstallQueue) { - mUninstallQueue.add(info); - } else { - processUninstallShortcut(context, info); - } - } - - static void enableUninstallQueue() { - mUseUninstallQueue = true; - } - - static void disableAndFlushUninstallQueue(Context context) { - mUseUninstallQueue = false; - Iterator<PendingUninstallShortcutInfo> iter = mUninstallQueue.iterator(); - while (iter.hasNext()) { - processUninstallShortcut(context, iter.next()); - iter.remove(); - } - } - - private static void processUninstallShortcut(Context context, - PendingUninstallShortcutInfo pendingInfo) { - final Intent data = pendingInfo.data; - - LauncherAppState.setApplicationContext(context.getApplicationContext()); - LauncherAppState app = LauncherAppState.getInstance(); - synchronized (app) { // TODO: make removeShortcut internally threadsafe - removeShortcut(context, data); - } - } - - private static void removeShortcut(Context context, Intent data) { - Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT); - String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); - boolean duplicate = data.getBooleanExtra(Launcher.EXTRA_SHORTCUT_DUPLICATE, true); - - if (intent != null && name != null) { - final ContentResolver cr = context.getContentResolver(); - Cursor c = cr.query(LauncherSettings.Favorites.CONTENT_URI, - new String[] { LauncherSettings.Favorites._ID, LauncherSettings.Favorites.INTENT }, - LauncherSettings.Favorites.TITLE + "=?", new String[] { name }, null); - - final int intentIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.INTENT); - final int idIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites._ID); - - boolean changed = false; - - try { - while (c.moveToNext()) { - try { - String intentStr = c.getString(intentIndex); - if (intentStr != null - && intent.filterEquals(Intent.parseUri(intentStr, 0))) { - final long id = c.getLong(idIndex); - final Uri uri = LauncherSettings.Favorites.getContentUri(id, false); - cr.delete(uri, null, null); - changed = true; - if (!duplicate) { - break; - } - } - } catch (URISyntaxException e) { - // Ignore - } - } - } finally { - c.close(); - } - - if (changed) { - cr.notifyChange(LauncherSettings.Favorites.CONTENT_URI, null); - Toast.makeText(context, context.getString(R.string.shortcut_uninstalled, name), - Toast.LENGTH_SHORT).show(); - } - } - } + @Override + public void onReceive(Context context, Intent data) { } } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 92e01324f..a79add05f 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -402,7 +402,6 @@ public class Workspace extends SmoothPagedView setChildrenBackgroundAlphaMultipliers(1f); // Prevent any Un/InstallShortcutReceivers from updating the db while we are dragging InstallShortcutReceiver.enableInstallQueue(); - UninstallShortcutReceiver.enableUninstallQueue(); post(new Runnable() { @Override public void run() { @@ -430,7 +429,6 @@ public class Workspace extends SmoothPagedView // Re-enable any Un/InstallShortcutReceiver and now process any queued items InstallShortcutReceiver.disableAndFlushInstallQueue(getContext()); - UninstallShortcutReceiver.disableAndFlushUninstallQueue(getContext()); mDragSourceInternal = null; mLauncher.onInteractionEnd(); @@ -4325,8 +4323,7 @@ public class Workspace extends SmoothPagedView cellX = hotseat.getCellXFromOrder((int) info.screenId); cellY = hotseat.getCellYFromOrder((int) info.screenId); } - LauncherModel.addItemToDatabase(mLauncher, info, container, screenId, cellX, - cellY, false); + LauncherModel.addItemToDatabase(mLauncher, info, container, screenId, cellX, cellY); } if (v instanceof FolderIcon) { FolderIcon fi = (FolderIcon) v; |