summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/model
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-10-10 10:41:41 -0700
committerSunny Goyal <sunnygoyal@google.com>2016-10-10 20:58:56 +0000
commit8e0e1d76095badc58a3178917c43642065ace37c (patch)
tree86ca5bfe89825614f3cc42674679fd317cacc6fb /src/com/android/launcher3/model
parent5fe414f9a425d9d7c2d5010fa476bc9faf440aed (diff)
downloadandroid_packages_apps_Trebuchet-8e0e1d76095badc58a3178917c43642065ace37c.tar.gz
android_packages_apps_Trebuchet-8e0e1d76095badc58a3178917c43642065ace37c.tar.bz2
android_packages_apps_Trebuchet-8e0e1d76095badc58a3178917c43642065ace37c.zip
Moving come helper methods to corresponding classes
> Moving isPackageEnabled to InstallShortcutReceiver > Moving the deep shortcut map to the data model > Removing appInfo.flags. Instead fetching the flags when needed Change-Id: I654dd8acefa7b7d183b0419afbe112bef001d536
Diffstat (limited to 'src/com/android/launcher3/model')
-rw-r--r--src/com/android/launcher3/model/BgDataModel.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/com/android/launcher3/model/BgDataModel.java b/src/com/android/launcher3/model/BgDataModel.java
index 2b7039928..c18eeef3d 100644
--- a/src/com/android/launcher3/model/BgDataModel.java
+++ b/src/com/android/launcher3/model/BgDataModel.java
@@ -24,13 +24,19 @@ import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherAppWidgetInfo;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.ShortcutInfo;
+import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.config.ProviderConfig;
+import com.android.launcher3.shortcuts.ShortcutInfoCompat;
import com.android.launcher3.shortcuts.ShortcutKey;
+import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.LongArrayMap;
+import com.android.launcher3.util.MultiHashMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
/**
@@ -73,6 +79,11 @@ public class BgDataModel {
public final Map<ShortcutKey, MutableInt> pinnedShortcutCounts = new HashMap<>();
/**
+ * Maps all launcher activities to the id's of their shortcuts (if they have any).
+ */
+ public final MultiHashMap<ComponentKey, String> deepShortcutMap = new MultiHashMap<>();
+
+ /**
* Clears all the data
*/
public synchronized void clear() {
@@ -82,6 +93,7 @@ public class BgDataModel {
itemsIdMap.clear();
workspaceScreens.clear();
pinnedShortcutCounts.clear();
+ deepShortcutMap.clear();
}
public synchronized void removeItem(ItemInfo... items) {
@@ -194,4 +206,32 @@ public class BgDataModel {
}
return folderInfo;
}
+
+ /**
+ * Clear all the deep shortcuts for the given package, and re-add the new shortcuts.
+ */
+ public synchronized void updateDeepShortcutMap(
+ String packageName, UserHandleCompat user, List<ShortcutInfoCompat> shortcuts) {
+ if (packageName != null) {
+ Iterator<ComponentKey> keysIter = deepShortcutMap.keySet().iterator();
+ while (keysIter.hasNext()) {
+ ComponentKey next = keysIter.next();
+ if (next.componentName.getPackageName().equals(packageName)
+ && next.user.equals(user)) {
+ keysIter.remove();
+ }
+ }
+ }
+
+ // Now add the new shortcuts to the map.
+ for (ShortcutInfoCompat shortcut : shortcuts) {
+ boolean shouldShowInContainer = shortcut.isEnabled()
+ && (shortcut.isDeclaredInManifest() || shortcut.isDynamic());
+ if (shouldShowInContainer) {
+ ComponentKey targetComponent
+ = new ComponentKey(shortcut.getActivity(), shortcut.getUserHandle());
+ deepShortcutMap.addToList(targetComponent, shortcut.getId());
+ }
+ }
+ }
}