summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaj Yengisetty <rajesh@cyngn.com>2015-03-26 16:28:56 (GMT)
committerRajesh Yengisetty <rajesh@cyngn.com>2015-03-26 16:30:01 (GMT)
commitf963b11485ceef70bbce7a9a4b98415ac2672b5b (patch)
tree8ccaec82258ceae40d8ffe6ea3b5762515ebac0f
parent4b60765caa363af235fd83de7c4747eeedc19087 (diff)
downloadandroid_packages_apps_Trebuchet-f963b11485ceef70bbce7a9a4b98415ac2672b5b.zip
android_packages_apps_Trebuchet-f963b11485ceef70bbce7a9a4b98415ac2672b5b.tar.gz
android_packages_apps_Trebuchet-f963b11485ceef70bbce7a9a4b98415ac2672b5b.tar.bz2
ProtectedApps: map items without componentNames by position
Repro: - Add a contact widget to a folder - Open the hidden apps fragment - Attempt to remove an entry from the fragment - Observe: Force close Change-Id: I3ca2c62283af5232534b766d7579413c060a5403
-rw-r--r--src/com/android/launcher3/Folder.java12
-rw-r--r--src/com/android/launcher3/HiddenFolderFragment.java21
2 files changed, 28 insertions, 5 deletions
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index 988c43e..8bc38c5 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -1434,6 +1434,18 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
return null;
}
+ public ShortcutInfo getShortcutForPosition(int position) {
+ if (position < 0 || position >= mItemsInReadingOrder.size()) {
+ return null;
+ }
+ View v = mItemsInReadingOrder.get(position);
+ Object tag = v.getTag();
+ if (tag instanceof ShortcutInfo) {
+ return (ShortcutInfo) tag;
+ }
+ return null;
+ }
+
public void getLocationInDragLayer(int[] loc) {
mLauncher.getDragLayer().getLocationInDragLayer(this, loc);
}
diff --git a/src/com/android/launcher3/HiddenFolderFragment.java b/src/com/android/launcher3/HiddenFolderFragment.java
index 4b5314d..96c0860 100644
--- a/src/com/android/launcher3/HiddenFolderFragment.java
+++ b/src/com/android/launcher3/HiddenFolderFragment.java
@@ -138,16 +138,25 @@ public class HiddenFolderFragment extends Fragment {
private ArrayList<AppEntry> loadApps(List<Pair<ComponentName, CharSequence>> items) {
ArrayList<AppEntry> apps = new ArrayList<AppEntry>();
+ int pos = 0;
for (Pair<ComponentName, CharSequence> item : items) {
- apps.add(new AppEntry(item.first, item.second));
+ apps.add(new AppEntry(item.first, item.second, pos));
+ pos++;
}
return apps;
}
private void removeComponentFromFolder(AppEntry app) {
- mLauncher.mHiddenFolderIcon.getFolderInfo().remove(
- mLauncher.mHiddenFolderIcon.getFolder()
- .getShortcutForComponent(app.componentName));
+ ShortcutInfo info;
+ if (app.componentName != null) {
+ info = mLauncher.mHiddenFolderIcon.getFolder()
+ .getShortcutForComponent(app.componentName);
+ } else {
+ // Shortcut does not have componentName, use position since it maps to
+ // reading order position in the folder
+ info = mLauncher.mHiddenFolderIcon.getFolder().getShortcutForPosition(app.position);
+ }
+ mLauncher.mHiddenFolderIcon.getFolderInfo().remove(info);
mAppEntries.remove(app);
mAppsAdapter.remove(app);
@@ -325,10 +334,12 @@ public class HiddenFolderFragment extends Fragment {
private final class AppEntry {
public final ComponentName componentName;
public final CharSequence title;
+ public final int position;
- public AppEntry(ComponentName component, CharSequence title) {
+ public AppEntry(ComponentName component, CharSequence title, int position) {
this.componentName = component;
this.title = title;
+ this.position = position;
}
}