summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/Workspace.java
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2015-07-17 10:06:20 -0700
committerGerrit Code Review <gerrit@cyanogenmod.org>2015-07-22 11:58:04 -0700
commit53b6e9dd1a97ea59a84e4c8b7172e1773d990ee5 (patch)
treed8c46c3d286fe94c593fb5c1542aee0505dd1094 /src/com/android/launcher3/Workspace.java
parentc7b06ddeaed7dbaf25fd87dedbd4f6921e72cfca (diff)
downloadandroid_packages_apps_Trebuchet-53b6e9dd1a97ea59a84e4c8b7172e1773d990ee5.tar.gz
android_packages_apps_Trebuchet-53b6e9dd1a97ea59a84e4c8b7172e1773d990ee5.tar.bz2
android_packages_apps_Trebuchet-53b6e9dd1a97ea59a84e4c8b7172e1773d990ee5.zip
Show apps as unavailable when on unmounted storage
This patch allows shortcuts to apps that are currently unavailable due to being on unmounted external storage to remain on the workspace and in folders. The icons will be disabled and grayed out until the external storage is mounted. Change-Id: I971483806b27e3a75ef0d5bb89d8dfb86f97511e
Diffstat (limited to 'src/com/android/launcher3/Workspace.java')
-rw-r--r--src/com/android/launcher3/Workspace.java84
1 files changed, 84 insertions, 0 deletions
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index bfe555a63..8f5d9f0a2 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -4954,6 +4954,90 @@ public class Workspace extends SmoothPagedView
stripEmptyScreens();
}
+ void updateUnvailableItemsInCellLayout(CellLayout parent, ArrayList<String> packages) {
+ final HashSet<String> packageNames = new HashSet<String>();
+ packageNames.addAll(packages);
+
+ ViewGroup layout = parent.getShortcutsAndWidgets();
+ int childCount = layout.getChildCount();
+ for (int i = 0; i < childCount; ++i) {
+ View view = layout.getChildAt(i);
+ if (view instanceof BubbleTextView) {
+ ItemInfo info = (ItemInfo) view.getTag();
+ if (info instanceof ShortcutInfo) {
+ Intent intent = info.getIntent();
+ ComponentName cn = intent != null ? intent.getComponent() : null;
+ if (cn != null && packageNames.contains(cn.getPackageName())) {
+ ShortcutInfo shortcut = (ShortcutInfo) info;
+ if (!shortcut.isDisabled) {
+ shortcut.isDisabled = true;
+ ((BubbleTextView) view)
+ .applyFromShortcutInfo(shortcut, mIconCache, true);
+ }
+ }
+ }
+ } else if (view instanceof FolderIcon) {
+ final Folder folder = ((FolderIcon)view).getFolder();
+ updateUnvailableItemsInCellLayout(folder.getContent(), packages);
+ folder.invalidate();
+ }
+ }
+ }
+
+ void updateUnavailableItemsByPackageName(final ArrayList<String> packages) {
+ ArrayList<CellLayout> cellLayouts = getWorkspaceAndHotseatCellLayouts();
+ for (CellLayout layoutParent : cellLayouts) {
+ updateUnvailableItemsInCellLayout(layoutParent, packages);
+ }
+ }
+
+ /**
+ * Updates shortcuts to an app that was previously unavailable in the given cell layout
+ * @param parent CellLayout to check childen for shortcuts to the available app
+ * @param appInfos List of item infos. Items are assumed to be of type AppInfo
+ */
+ void updateAvailabeItemsInCellLayout(CellLayout parent, final ArrayList<ItemInfo> appInfos) {
+ ViewGroup layout = parent.getShortcutsAndWidgets();
+ int childCount = layout.getChildCount();
+ for (int i = 0; i < childCount; ++i) {
+ View view = layout.getChildAt(i);
+ if (view instanceof BubbleTextView) {
+ ItemInfo info = (ItemInfo) view.getTag();
+ if (info instanceof ShortcutInfo) {
+ Intent intent = info.getIntent();
+ ComponentName cn = intent != null ? intent.getComponent() : null;
+ for (ItemInfo itemInfo : appInfos) {
+ AppInfo appInfo = (AppInfo) itemInfo;
+ if (cn != null && cn.getPackageName().equals(
+ appInfo.componentName.getPackageName())) {
+ ShortcutInfo shortcut = (ShortcutInfo) info;
+ if (shortcut.isDisabled) {
+ shortcut.isDisabled = false;
+ ((BubbleTextView) view)
+ .applyFromShortcutInfo(shortcut, mIconCache, true);
+ }
+ }
+ }
+ }
+ } else if (view instanceof FolderIcon) {
+ final Folder folder = ((FolderIcon)view).getFolder();
+ updateAvailabeItemsInCellLayout(folder.getContent(), appInfos);
+ folder.invalidate();
+ }
+ }
+ }
+
+ /**
+ * Updates shortcuts to an app that was previously unavailable
+ * @param appInfos List of item infos. Items are assumed to be of type AppInfo
+ */
+ void updateAvailableItems(final ArrayList<ItemInfo> appInfos) {
+ ArrayList<CellLayout> cellLayouts = getWorkspaceAndHotseatCellLayouts();
+ for (CellLayout layoutParent : cellLayouts) {
+ updateAvailabeItemsInCellLayout(layoutParent, appInfos);
+ }
+ }
+
interface ItemOperator {
/**
* Process the next itemInfo, possibly with side-effect on {@link ItemOperator#value}.