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
This commit is contained in:
Sunny Goyal
2016-10-10 10:41:41 -07:00
parent 5fe414f9a4
commit 8e0e1d7609
8 changed files with 81 additions and 113 deletions

View File

@@ -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;
/**
@@ -72,6 +78,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
*/
@@ -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());
}
}
}
}