Drop support for remove all dead promises.

Bug: 12764789
Change-Id: Id876b66cf8da4388cb3ed5670a0bbdcf73f2982d
This commit is contained in:
Chris Wren
2014-07-01 16:52:49 -04:00
parent 8d8d62249e
commit 803a4bec0f
3 changed files with 12 additions and 53 deletions
+3 -9
View File
@@ -288,13 +288,7 @@ s -->
<string name="abandoned_promises_title">This app is not installed</string>
<!-- Explanation for abandoned promise dialog. "The first 'it' refers to the shortcut icon.
The second "it" refers to the app. -->
<plurals name="abandoned_promises_explanation">
<item quantity="one">The app for this icon isn\'t installed.
You can remove it, or search for the app and install it manually.
</item>
<item quantity="other">The app for this icon isn\'t installed.
You can remove all such broken icons, remove only this one,
or search for the app and install it manually.
</item>
</plurals>
<string name="abandoned_promise_explanation">The app for this icon isn\'t installed.
You can remove it, or search for the app and install it manually.
</string>
</resources>
+1 -14
View File
@@ -2545,12 +2545,9 @@ public class Launcher extends Activity
// Check for abandoned promise
if (shortcut.isAbandoned() && v instanceof BubbleTextView) {
final ArrayList<BubbleTextView> abandoned =
mWorkspace.getAbandonedPromises(new ArrayList<BubbleTextView>());
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.abandoned_promises_title);
builder.setMessage(getResources().getQuantityString(
R.plurals.abandoned_promises_explanation, abandoned.size()));
builder.setMessage(R.string.abandoned_promise_explanation);
builder.setPositiveButton(R.string.abandoned_search,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
@@ -2558,16 +2555,6 @@ public class Launcher extends Activity
}
}
);
if (abandoned.size() > 1) {
builder.setNegativeButton(R.string.abandoned_clean_all,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
final UserHandleCompat user = UserHandleCompat.myUserHandle();
mWorkspace.removeAbandonedPromises(abandoned, user);
}
}
);
}
builder.setNeutralButton(R.string.abandoned_clean_this,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
+8 -30
View File
@@ -4857,38 +4857,16 @@ public class Workspace extends SmoothPagedView
});
}
ArrayList<BubbleTextView> getAbandonedPromises(final ArrayList<BubbleTextView> abandoned) {
mapOverShortcuts(Workspace.MAP_RECURSE, new Workspace.ShortcutOperator() {
@Override
public boolean evaluate(ItemInfo info, View view, View parent) {
if (info instanceof ShortcutInfo
&& ((ShortcutInfo) info).isAbandoned()
&& view instanceof BubbleTextView) {
abandoned.add((BubbleTextView) view);
}
return false;
}
});
return abandoned;
}
public void removeAbandonedPromise(BubbleTextView view, UserHandleCompat user) {
ArrayList<BubbleTextView> views = new ArrayList<BubbleTextView>(1);
views.add(view);
removeAbandonedPromises(views, user);
}
public void removeAbandonedPromises(ArrayList<BubbleTextView> views, UserHandleCompat user) {
HashSet<ComponentName> cns = new HashSet<ComponentName>(views.size());
for (final BubbleTextView bubble : views) {
if (bubble.getTag() != null && bubble.getTag() instanceof ShortcutInfo) {
final ShortcutInfo shortcut = (ShortcutInfo) bubble.getTag();
if (shortcut.isAbandoned()) {
cns.add(shortcut.getRestoredIntent().getComponent());
LauncherModel.deleteItemFromDatabase(mLauncher, shortcut);
}
public void removeAbandonedPromise(BubbleTextView abandonedIcon, UserHandleCompat user) {
if (abandonedIcon.getTag() != null && abandonedIcon.getTag() instanceof ShortcutInfo) {
final ShortcutInfo shortcut = (ShortcutInfo) abandonedIcon.getTag();
if (shortcut.isAbandoned()) {
HashSet<ComponentName> cns = new HashSet<ComponentName>(1);
cns.add(shortcut.getRestoredIntent().getComponent());
LauncherModel.deleteItemFromDatabase(mLauncher, shortcut);
removeItemsByComponentName(cns, user);
}
}
removeItemsByComponentName(cns, user);
}
public void updatePackageState(final String pkgName, final int state) {