summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/UninstallShortcutReceiver.java
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2012-04-03 14:22:34 -0700
committerWinson Chung <winsonc@google.com>2012-04-09 17:04:00 -0700
commita2413751e3a698aef9c87411a639637883856939 (patch)
treee71fc7aa7fef5408ca7956c5ad373504d763337c /src/com/android/launcher2/UninstallShortcutReceiver.java
parente9bafe991b5bbcd033e1f27c66ba254d55117b20 (diff)
downloadandroid_packages_apps_Trebuchet-a2413751e3a698aef9c87411a639637883856939.tar.gz
android_packages_apps_Trebuchet-a2413751e3a698aef9c87411a639637883856939.tar.bz2
android_packages_apps_Trebuchet-a2413751e3a698aef9c87411a639637883856939.zip
Adding delay upon user interaction to prevent the new-app animation from taking over your phone. (Bug 6248609)
- Fixing issue where we might have been reading the db items while handling previous broadcast and adding db items to invalid positions - Making items add alternating from the center page (as opposed to the current page) - Re-adding the strict-mode fix (really requires 1. to be true) - Adding flag for enabling strict mode exceptions - Removing items from the new apps add list on uninstall-shortcut broadcast Change-Id: I495e80bf5f8dbb4b87dd709460937d6f2a1e05e7
Diffstat (limited to 'src/com/android/launcher2/UninstallShortcutReceiver.java')
-rw-r--r--src/com/android/launcher2/UninstallShortcutReceiver.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/com/android/launcher2/UninstallShortcutReceiver.java b/src/com/android/launcher2/UninstallShortcutReceiver.java
index eb4ee4cf3..3f6de7c5a 100644
--- a/src/com/android/launcher2/UninstallShortcutReceiver.java
+++ b/src/com/android/launcher2/UninstallShortcutReceiver.java
@@ -20,11 +20,14 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.ContentResolver;
+import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.Uri;
import android.widget.Toast;
import java.net.URISyntaxException;
+import java.util.HashSet;
+import java.util.Set;
import com.android.launcher.R;
@@ -36,7 +39,16 @@ public class UninstallShortcutReceiver extends BroadcastReceiver {
if (!ACTION_UNINSTALL_SHORTCUT.equals(data.getAction())) {
return;
}
+ String spKey = LauncherApplication.getSharedPreferencesKey();
+ SharedPreferences sharedPrefs = context.getSharedPreferences(spKey, Context.MODE_PRIVATE);
+ LauncherApplication app = (LauncherApplication) context.getApplicationContext();
+ synchronized (app) {
+ removeShortcut(context, data, sharedPrefs);
+ }
+ }
+
+ private void removeShortcut(Context context, Intent data, final SharedPreferences sharedPrefs) {
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);
@@ -77,6 +89,29 @@ public class UninstallShortcutReceiver extends BroadcastReceiver {
Toast.makeText(context, context.getString(R.string.shortcut_uninstalled, name),
Toast.LENGTH_SHORT).show();
}
+
+ // Remove any items due to be animated
+ boolean appRemoved;
+ Set<String> newApps = new HashSet<String>();
+ newApps = sharedPrefs.getStringSet(InstallShortcutReceiver.NEW_APPS_LIST_KEY, newApps);
+ do {
+ appRemoved = newApps.remove(intent.toUri(0).toString());
+ } while (appRemoved);
+ if (appRemoved) {
+ final Set<String> savedNewApps = newApps;
+ new Thread("setNewAppsThread-remove") {
+ public void run() {
+ SharedPreferences.Editor editor = sharedPrefs.edit();
+ editor.putStringSet(InstallShortcutReceiver.NEW_APPS_LIST_KEY,
+ savedNewApps);
+ if (savedNewApps.isEmpty()) {
+ // Reset the page index if there are no more items
+ editor.putInt(InstallShortcutReceiver.NEW_APPS_PAGE_KEY, -1);
+ }
+ editor.commit();
+ }
+ }.start();
+ }
}
}
}