summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/LauncherModel.java
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/LauncherModel.java
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/LauncherModel.java')
-rw-r--r--src/com/android/launcher3/LauncherModel.java73
1 files changed, 9 insertions, 64 deletions
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 4afff1898..3f9c2a324 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -93,7 +93,6 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.Executor;
@@ -145,9 +144,6 @@ public class LauncherModel extends BroadcastReceiver
// Entire list of widgets.
private final WidgetsModel mBgWidgetsModel;
- // Maps all launcher activities to the id's of their shortcuts (if they have any).
- private final MultiHashMap<ComponentKey, String> mBgDeepShortcutMap = new MultiHashMap<>();
-
private boolean mHasShortcutHostPermission;
// Runnable to check if the shortcuts permission has changed.
private final Runnable mShortcutPermissionCheckRunnable = new Runnable() {
@@ -316,15 +312,7 @@ public class LauncherModel extends BroadcastReceiver
ComponentName cn = si.getTargetComponent();
if (si.isPromise() && (cn != null)
&& packageName.equals(cn.getPackageName())) {
- if (si.hasStatusFlag(ShortcutInfo.FLAG_AUTOINTALL_ICON)) {
- // For auto install apps update the icon as well as label.
- mIconCache.getTitleAndIcon(si,
- si.promisedIntent, user,
- si.shouldUseLowResIcon());
- } else {
- // Only update the icon for restored apps.
- si.updateIcon(mIconCache);
- }
+ si.updateIcon(mIconCache);
updates.add(si);
}
}
@@ -2647,14 +2635,14 @@ public class LauncherModel extends BroadcastReceiver
Log.d(TAG, "loadAndBindDeepShortcuts mDeepShortcutsLoaded=" + mDeepShortcutsLoaded);
}
if (!mDeepShortcutsLoaded) {
- mBgDeepShortcutMap.clear();
+ sBgDataModel.deepShortcutMap.clear();
mHasShortcutHostPermission = mDeepShortcutManager.hasHostPermission();
if (mHasShortcutHostPermission) {
for (UserHandleCompat user : mUserManager.getUserProfiles()) {
if (mUserManager.isUserUnlocked(user)) {
List<ShortcutInfoCompat> shortcuts = mDeepShortcutManager
.queryForAllShortcuts(user);
- updateDeepShortcutMap(null, user, shortcuts);
+ sBgDataModel.updateDeepShortcutMap(null, user, shortcuts);
}
}
}
@@ -2678,36 +2666,9 @@ public class LauncherModel extends BroadcastReceiver
}
}
- /**
- * Clear all the shortcuts for the given package, and re-add the new shortcuts.
- */
- private void updateDeepShortcutMap(
- String packageName, UserHandleCompat user, List<ShortcutInfoCompat> shortcuts) {
- if (packageName != null) {
- Iterator<ComponentKey> keysIter = mBgDeepShortcutMap.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());
- mBgDeepShortcutMap.addToList(targetComponent, shortcut.getId());
- }
- }
- }
-
public void bindDeepShortcuts() {
- final MultiHashMap<ComponentKey, String> shortcutMapCopy = mBgDeepShortcutMap.clone();
+ final MultiHashMap<ComponentKey, String> shortcutMapCopy =
+ sBgDataModel.deepShortcutMap.clone();
Runnable r = new Runnable() {
@Override
public void run() {
@@ -2989,11 +2950,6 @@ public class LauncherModel extends BroadcastReceiver
}
}
- // Restore the shortcut.
- if (appInfo != null) {
- si.flags = appInfo.flags;
- }
-
si.intent = si.promisedIntent;
si.promisedIntent = null;
si.status = ShortcutInfo.DEFAULT;
@@ -3221,7 +3177,7 @@ public class LauncherModel extends BroadcastReceiver
if (mUpdateIdMap) {
// Update the deep shortcut map if the list of ids has changed for an activity.
- updateDeepShortcutMap(mPackageName, mUser, mShortcuts);
+ sBgDataModel.updateDeepShortcutMap(mPackageName, mUser, mShortcuts);
bindDeepShortcuts();
}
}
@@ -3289,7 +3245,7 @@ public class LauncherModel extends BroadcastReceiver
}
// Remove shortcut id map for that user
- Iterator<ComponentKey> keysIter = mBgDeepShortcutMap.keySet().iterator();
+ Iterator<ComponentKey> keysIter = sBgDataModel.deepShortcutMap.keySet().iterator();
while (keysIter.hasNext()) {
if (keysIter.next().user.equals(mUser)) {
keysIter.remove();
@@ -3297,7 +3253,8 @@ public class LauncherModel extends BroadcastReceiver
}
if (isUserUnlocked) {
- updateDeepShortcutMap(null, mUser, mDeepShortcutManager.queryForAllShortcuts(mUser));
+ sBgDataModel.updateDeepShortcutMap(
+ null, mUser, mDeepShortcutManager.queryForAllShortcuts(mUser));
}
bindDeepShortcuts();
}
@@ -3338,15 +3295,6 @@ public class LauncherModel extends BroadcastReceiver
return !launcherApps.isPackageEnabledForProfile(packageName, user);
}
- public static boolean isValidPackage(Context context, String packageName,
- UserHandleCompat user) {
- if (packageName == null) {
- return false;
- }
- final LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(context);
- return launcherApps.isPackageEnabledForProfile(packageName, user);
- }
-
/**
* Make an ShortcutInfo object for a restored application or shortcut item that points
* to a package that is not yet installed on the system.
@@ -3454,9 +3402,6 @@ public class LauncherModel extends BroadcastReceiver
info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
info.user = user;
info.contentDescription = mUserManager.getBadgedLabelForUser(info.title, info.user);
- if (lai != null) {
- info.flags = AppInfo.initFlags(lai);
- }
return info;
}