summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaj Yengisetty <rajesh@cyngn.com>2015-03-26 16:28:56 (GMT)
committerStephen Bird <sbird@cyngn.com>2015-07-13 21:55:43 (GMT)
commit8055e99967a786545f55ea4b3f4351583ee7f7b1 (patch)
tree56c7ab0bca7571bc8fca8373d454380364bd2bca
parent99fb0c49cce8205dedaaba456a5ae144ae8eaebe (diff)
downloadandroid_packages_apps_Trebuchet-8055e99967a786545f55ea4b3f4351583ee7f7b1.zip
android_packages_apps_Trebuchet-8055e99967a786545f55ea4b3f4351583ee7f7b1.tar.gz
android_packages_apps_Trebuchet-8055e99967a786545f55ea4b3f4351583ee7f7b1.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 (cherry picked from commit f963b11485ceef70bbce7a9a4b98415ac2672b5b) (cherry picked from commit 660761014f5ab0d6ebada8a1579db4da910643fe)
-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 ff8f347..3319b74 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -1490,6 +1490,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 db5e51f..7d3835e 100644
--- a/src/com/android/launcher3/HiddenFolderFragment.java
+++ b/src/com/android/launcher3/HiddenFolderFragment.java
@@ -128,16 +128,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);
@@ -315,10 +324,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;
}
}