summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/launcher3/BubbleTextView.java4
-rw-r--r--src/com/android/launcher3/IconCache.java6
-rw-r--r--src/com/android/launcher3/InfoDropTarget.java2
-rw-r--r--src/com/android/launcher3/ItemInfo.java12
-rw-r--r--src/com/android/launcher3/Launcher.java6
-rw-r--r--src/com/android/launcher3/LauncherCallbacks.java4
-rw-r--r--src/com/android/launcher3/ShortcutInfo.java24
-rw-r--r--src/com/android/launcher3/allapps/AllAppsContainerView.java3
-rw-r--r--src/com/android/launcher3/allapps/AlphabeticalAppsList.java33
-rw-r--r--src/com/android/launcher3/graphics/LauncherIcons.java12
-rw-r--r--src/com/android/launcher3/model/LoaderTask.java4
-rw-r--r--src/com/android/launcher3/model/PackageInstallStateChangedTask.java2
-rw-r--r--src/com/android/launcher3/model/PackageUpdatedTask.java15
-rw-r--r--src/com/android/launcher3/shortcuts/DeepShortcutManager.java2
-rw-r--r--src/com/android/launcher3/testing/LauncherExtension.java3
-rw-r--r--src/com/android/launcher3/util/ComponentKeyMapper.java50
16 files changed, 137 insertions, 45 deletions
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index a63767c5d..ac842f92e 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -184,7 +184,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver {
public void applyFromShortcutInfo(ShortcutInfo info, boolean promiseStateChanged) {
applyIconAndLabel(info.iconBitmap, info);
setTag(info);
- if (promiseStateChanged || info.isPromise()) {
+ if (promiseStateChanged || (info.hasPromiseIconUi())) {
applyPromiseState(promiseStateChanged);
}
@@ -481,7 +481,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver {
public void applyPromiseState(boolean promiseStateChanged) {
if (getTag() instanceof ShortcutInfo) {
ShortcutInfo info = (ShortcutInfo) getTag();
- final boolean isPromise = info.isPromise();
+ final boolean isPromise = info.hasPromiseIconUi();
final int progressLevel = isPromise ?
((info.hasStatusFlag(ShortcutInfo.FLAG_INSTALL_SESSION_ACTIVE) ?
info.getInstallProgress() : 0)) : 100;
diff --git a/src/com/android/launcher3/IconCache.java b/src/com/android/launcher3/IconCache.java
index 3bcd7afb4..ecadb18ef 100644
--- a/src/com/android/launcher3/IconCache.java
+++ b/src/com/android/launcher3/IconCache.java
@@ -478,6 +478,12 @@ public class IconCache {
}
private void applyCacheEntry(CacheEntry entry, ItemInfoWithIcon info) {
+ if (info instanceof ShortcutInfo
+ && ((ShortcutInfo) info).hasStatusFlag(ShortcutInfo.FLAG_SUPPORTS_WEB_UI)
+ && (entry.icon == null || isDefaultIcon(entry.icon, info.user))) {
+ // skip updating shortcut info if no icon and supports web ui
+ return;
+ }
info.title = Utilities.trim(entry.title);
info.contentDescription = entry.contentDescription;
info.iconBitmap = entry.icon == null ? getDefaultIcon(info.user) : entry.icon;
diff --git a/src/com/android/launcher3/InfoDropTarget.java b/src/com/android/launcher3/InfoDropTarget.java
index f088d1176..f919dd052 100644
--- a/src/com/android/launcher3/InfoDropTarget.java
+++ b/src/com/android/launcher3/InfoDropTarget.java
@@ -75,7 +75,7 @@ public class InfoDropTarget extends UninstallDropTarget {
if (info instanceof AppInfo) {
componentName = ((AppInfo) info).componentName;
} else if (info instanceof ShortcutInfo) {
- componentName = ((ShortcutInfo) info).intent.getComponent();
+ componentName = info.getTargetComponent();
} else if (info instanceof PendingAddItemInfo) {
componentName = ((PendingAddItemInfo) info).componentName;
} else if (info instanceof LauncherAppWidgetInfo) {
diff --git a/src/com/android/launcher3/ItemInfo.java b/src/com/android/launcher3/ItemInfo.java
index c5be096a2..fa3253c67 100644
--- a/src/com/android/launcher3/ItemInfo.java
+++ b/src/com/android/launcher3/ItemInfo.java
@@ -138,17 +138,11 @@ public class ItemInfo {
public ComponentName getTargetComponent() {
Intent intent = getIntent();
- if (intent == null) {
+ if (intent != null) {
+ return intent.getComponent();
+ } else {
return null;
}
- ComponentName cn = intent.getComponent();
- if (itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT && cn == null) {
- // Legacy shortcuts may not have a componentName but just a packageName. In that case
- // create a dummy componentName instead of adding additional check everywhere.
- String pkg = intent.getPackage();
- return pkg == null ? null : new ComponentName(pkg, IconCache.EMPTY_CLASS_NAME);
- }
- return cn;
}
public void writeToValues(ContentWriter writer) {
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 8492a7985..614d08669 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -113,7 +113,6 @@ import com.android.launcher3.pageindicators.PageIndicator;
import com.android.launcher3.popup.PopupContainerWithArrow;
import com.android.launcher3.popup.PopupDataProvider;
import com.android.launcher3.shortcuts.DeepShortcutManager;
-import com.android.launcher3.shortcuts.ShortcutKey;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
@@ -121,6 +120,7 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
import com.android.launcher3.util.ActivityResultInfo;
import com.android.launcher3.util.RunnableWithId;
import com.android.launcher3.util.ComponentKey;
+import com.android.launcher3.util.ComponentKeyMapper;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.MultiHashMap;
import com.android.launcher3.util.PackageManagerHelper;
@@ -2424,7 +2424,7 @@ public class Launcher extends BaseActivity
}
// Check for abandoned promise
- if ((v instanceof BubbleTextView) && shortcut.isPromise()) {
+ if ((v instanceof BubbleTextView) && shortcut.hasPromiseIconUi()) {
String packageName = shortcut.intent.getComponent() != null ?
shortcut.intent.getComponent().getPackageName() : shortcut.intent.getPackage();
if (!TextUtils.isEmpty(packageName)) {
@@ -3068,7 +3068,7 @@ public class Launcher extends BaseActivity
*/
public void tryAndUpdatePredictedApps() {
if (mLauncherCallbacks != null) {
- List<ComponentKey> apps = mLauncherCallbacks.getPredictedApps();
+ List<ComponentKeyMapper<AppInfo>> apps = mLauncherCallbacks.getPredictedApps();
if (apps != null) {
mAppsView.setPredictedApps(apps);
}
diff --git a/src/com/android/launcher3/LauncherCallbacks.java b/src/com/android/launcher3/LauncherCallbacks.java
index d66b14c7d..c900e533b 100644
--- a/src/com/android/launcher3/LauncherCallbacks.java
+++ b/src/com/android/launcher3/LauncherCallbacks.java
@@ -21,7 +21,7 @@ import android.os.Bundle;
import android.view.Menu;
import android.view.View;
-import com.android.launcher3.util.ComponentKey;
+import com.android.launcher3.util.ComponentKeyMapper;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -91,7 +91,7 @@ public interface LauncherCallbacks {
*/
boolean shouldMoveToDefaultScreenOnHomeIntent();
boolean hasSettings();
- List<ComponentKey> getPredictedApps();
+ List<ComponentKeyMapper<AppInfo>> getPredictedApps();
int SEARCH_BAR_HEIGHT_NORMAL = 0, SEARCH_BAR_HEIGHT_TALL = 1;
/** Must return one of {@link #SEARCH_BAR_HEIGHT_NORMAL} or {@link #SEARCH_BAR_HEIGHT_TALL} */
int getSearchBarHeight();
diff --git a/src/com/android/launcher3/ShortcutInfo.java b/src/com/android/launcher3/ShortcutInfo.java
index f0d9367af..adf008bf4 100644
--- a/src/com/android/launcher3/ShortcutInfo.java
+++ b/src/com/android/launcher3/ShortcutInfo.java
@@ -17,6 +17,7 @@
package com.android.launcher3;
import android.annotation.TargetApi;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
@@ -59,6 +60,11 @@ public class ShortcutInfo extends ItemInfoWithIcon {
public static final int FLAG_RESTORE_STARTED = 8; //0B1000;
/**
+ * Web UI supported.
+ */
+ public static final int FLAG_SUPPORTS_WEB_UI = 16; //0B10000;
+
+ /**
* Indicates if it represents a common type mentioned in {@link CommonAppTypeParser}.
* Upto 15 different types supported.
*/
@@ -188,6 +194,10 @@ public class ShortcutInfo extends ItemInfoWithIcon {
return hasStatusFlag(FLAG_RESTORED_ICON | FLAG_AUTOINSTALL_ICON);
}
+ public boolean hasPromiseIconUi() {
+ return isPromise() && !hasStatusFlag(FLAG_SUPPORTS_WEB_UI);
+ }
+
public int getInstallProgress() {
return mInstallProgress;
}
@@ -226,4 +236,18 @@ public class ShortcutInfo extends ItemInfoWithIcon {
public boolean isDisabled() {
return isDisabled != 0;
}
+
+ @Override
+ public ComponentName getTargetComponent() {
+ ComponentName cn = super.getTargetComponent();
+ if (cn == null && (itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT
+ || hasStatusFlag(FLAG_SUPPORTS_WEB_UI))) {
+ // Legacy shortcuts and promise icons with web UI may not have a componentName but just
+ // a packageName. In that case create a dummy componentName instead of adding additional
+ // check everywhere.
+ String pkg = intent.getPackage();
+ return pkg == null ? null : new ComponentName(pkg, IconCache.EMPTY_CLASS_NAME);
+ }
+ return cn;
+ }
}
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index dd88be6b7..4eba5c6df 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -50,6 +50,7 @@ import com.android.launcher3.folder.Folder;
import com.android.launcher3.keyboard.FocusedItemDecorator;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import com.android.launcher3.util.ComponentKey;
+import com.android.launcher3.util.ComponentKeyMapper;
import com.android.launcher3.util.PackageUserKey;
import java.util.List;
@@ -116,7 +117,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
/**
* Sets the current set of predicted apps.
*/
- public void setPredictedApps(List<ComponentKey> apps) {
+ public void setPredictedApps(List<ComponentKeyMapper<AppInfo>> apps) {
mApps.setPredictedApps(apps);
}
diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
index 5e7a5cac5..6bbe3ea55 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -29,6 +29,7 @@ import com.android.launcher3.discovery.AppDiscoveryAppInfo;
import com.android.launcher3.discovery.AppDiscoveryItem;
import com.android.launcher3.discovery.AppDiscoveryUpdateState;
import com.android.launcher3.util.ComponentKey;
+import com.android.launcher3.util.ComponentKeyMapper;
import com.android.launcher3.util.LabelComparator;
import java.util.ArrayList;
@@ -173,7 +174,7 @@ public class AlphabeticalAppsList {
// The set of sections that we allow fast-scrolling to (includes non-merged sections)
private final List<FastScrollSectionInfo> mFastScrollerSections = new ArrayList<>();
// The set of predicted app component names
- private final List<ComponentKey> mPredictedAppComponents = new ArrayList<>();
+ private final List<ComponentKeyMapper<AppInfo>> mPredictedAppComponents = new ArrayList<>();
// The set of predicted apps resolved from the component names and the current set of apps
private final List<AppInfo> mPredictedApps = new ArrayList<>();
private final List<AppDiscoveryAppInfo> mDiscoveredApps = new ArrayList<>();
@@ -298,20 +299,20 @@ public class AlphabeticalAppsList {
updateAdapterItems();
}
- private List<AppInfo> processPredictedAppComponents(List<ComponentKey> components) {
+ private List<AppInfo> processPredictedAppComponents(List<ComponentKeyMapper<AppInfo>> components) {
if (mComponentToAppMap.isEmpty()) {
// Apps have not been bound yet.
return Collections.emptyList();
}
List<AppInfo> predictedApps = new ArrayList<>();
- for (ComponentKey ck : components) {
- AppInfo info = mComponentToAppMap.get(ck);
+ for (ComponentKeyMapper<AppInfo> mapper : components) {
+ AppInfo info = mapper.getItem(mComponentToAppMap);
if (info != null) {
predictedApps.add(info);
} else {
if (FeatureFlags.IS_DOGFOOD_BUILD) {
- Log.e(TAG, "Predicted app not found: " + ck);
+ Log.e(TAG, "Predicted app not found: " + mapper);
}
}
// Stop at the number of predicted apps
@@ -331,7 +332,7 @@ public class AlphabeticalAppsList {
* If the number of predicted apps is the same as the previous list of predicted apps,
* we can optimize by swapping them in place.
*/
- public void setPredictedApps(List<ComponentKey> apps) {
+ public void setPredictedApps(List<ComponentKeyMapper<AppInfo>> apps) {
mPredictedAppComponents.clear();
mPredictedAppComponents.addAll(apps);
@@ -472,14 +473,14 @@ public class AlphabeticalAppsList {
if (DEBUG_PREDICTIONS) {
if (mPredictedAppComponents.isEmpty() && !mApps.isEmpty()) {
- mPredictedAppComponents.add(new ComponentKey(mApps.get(0).componentName,
- Process.myUserHandle()));
- mPredictedAppComponents.add(new ComponentKey(mApps.get(0).componentName,
- Process.myUserHandle()));
- mPredictedAppComponents.add(new ComponentKey(mApps.get(0).componentName,
- Process.myUserHandle()));
- mPredictedAppComponents.add(new ComponentKey(mApps.get(0).componentName,
- Process.myUserHandle()));
+ mPredictedAppComponents.add(new ComponentKeyMapper<AppInfo>(new ComponentKey(mApps.get(0).componentName,
+ Process.myUserHandle())));
+ mPredictedAppComponents.add(new ComponentKeyMapper<AppInfo>(new ComponentKey(mApps.get(0).componentName,
+ Process.myUserHandle())));
+ mPredictedAppComponents.add(new ComponentKeyMapper<AppInfo>(new ComponentKey(mApps.get(0).componentName,
+ Process.myUserHandle())));
+ mPredictedAppComponents.add(new ComponentKeyMapper<AppInfo>(new ComponentKey(mApps.get(0).componentName,
+ Process.myUserHandle())));
}
}
@@ -644,8 +645,8 @@ public class AlphabeticalAppsList {
return result;
}
- public AppInfo findApp(ComponentKey key) {
- return mComponentToAppMap.get(key);
+ public AppInfo findApp(ComponentKeyMapper<AppInfo> mapper) {
+ return mapper.getItem(mComponentToAppMap);
}
/**
diff --git a/src/com/android/launcher3/graphics/LauncherIcons.java b/src/com/android/launcher3/graphics/LauncherIcons.java
index d95567492..7c80c3098 100644
--- a/src/com/android/launcher3/graphics/LauncherIcons.java
+++ b/src/com/android/launcher3/graphics/LauncherIcons.java
@@ -38,6 +38,7 @@ import android.os.UserHandle;
import android.support.annotation.Nullable;
import com.android.launcher3.AppInfo;
+import com.android.launcher3.FastBitmapDrawable;
import com.android.launcher3.IconCache;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.R;
@@ -192,13 +193,16 @@ public class LauncherIcons {
* Adds the {@param badge} on top of {@param srcTgt} using the badge dimensions.
*/
public static Bitmap badgeWithBitmap(Bitmap srcTgt, Bitmap badge, Context context) {
+ return badgeWithDrawable(srcTgt, new FastBitmapDrawable(badge), context);
+ }
+
+ public static Bitmap badgeWithDrawable(Bitmap srcTgt, Drawable badge, Context context) {
int badgeSize = context.getResources().getDimensionPixelSize(R.dimen.profile_badge_size);
synchronized (sCanvas) {
sCanvas.setBitmap(srcTgt);
- sCanvas.drawBitmap(badge, new Rect(0, 0, badge.getWidth(), badge.getHeight()),
- new Rect(srcTgt.getWidth() - badgeSize,
- srcTgt.getHeight() - badgeSize, srcTgt.getWidth(), srcTgt.getHeight()),
- new Paint(Paint.FILTER_BITMAP_FLAG));
+ int iconSize = srcTgt.getWidth();
+ badge.setBounds(iconSize - badgeSize, iconSize - badgeSize, iconSize, iconSize);
+ badge.draw(sCanvas);
sCanvas.setBitmap(null);
}
return srcTgt;
diff --git a/src/com/android/launcher3/model/LoaderTask.java b/src/com/android/launcher3/model/LoaderTask.java
index c56325ad5..4756edcc0 100644
--- a/src/com/android/launcher3/model/LoaderTask.java
+++ b/src/com/android/launcher3/model/LoaderTask.java
@@ -431,6 +431,10 @@ public class LoaderTask implements Runnable {
}
}
+ if ((c.restoreFlag & ShortcutInfo.FLAG_SUPPORTS_WEB_UI) != 0) {
+ validTarget = false;
+ }
+
if (validTarget) {
// The shortcut points to a valid target (either no target
// or something which is ready to be used)
diff --git a/src/com/android/launcher3/model/PackageInstallStateChangedTask.java b/src/com/android/launcher3/model/PackageInstallStateChangedTask.java
index 1e0af6881..ebc6f2379 100644
--- a/src/com/android/launcher3/model/PackageInstallStateChangedTask.java
+++ b/src/com/android/launcher3/model/PackageInstallStateChangedTask.java
@@ -94,7 +94,7 @@ public class PackageInstallStateChangedTask extends BaseModelUpdateTask {
if (info instanceof ShortcutInfo) {
ShortcutInfo si = (ShortcutInfo) info;
ComponentName cn = si.getTargetComponent();
- if (si.isPromise() && (cn != null)
+ if (si.hasPromiseIconUi() && (cn != null)
&& mInstallInfo.packageName.equals(cn.getPackageName())) {
si.setInstallProgress(mInstallInfo.progress);
if (mInstallInfo.state == PackageInstallerCompat.STATUS_FAILED) {
diff --git a/src/com/android/launcher3/model/PackageUpdatedTask.java b/src/com/android/launcher3/model/PackageUpdatedTask.java
index 6c78d5bfc..98bffe1fb 100644
--- a/src/com/android/launcher3/model/PackageUpdatedTask.java
+++ b/src/com/android/launcher3/model/PackageUpdatedTask.java
@@ -104,6 +104,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
SessionCommitReceiver.queueAppIconAddition(context, packages[i], mUser);
}
}
+ flagOp = FlagOp.removeFlag(ShortcutInfo.FLAG_DISABLED_NOT_AVAILABLE);
break;
}
case OP_UPDATE:
@@ -170,12 +171,12 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
}
}
+ final LongArrayMap<Boolean> removedShortcuts = new LongArrayMap<>();
+
// Update shortcut infos
if (mOp == OP_ADD || flagOp != FlagOp.NO_OP) {
final ArrayList<ShortcutInfo> updatedShortcuts = new ArrayList<>();
- final LongArrayMap<Boolean> removedShortcuts = new LongArrayMap<>();
final ArrayList<LauncherAppWidgetInfo> widgets = new ArrayList<>();
-
synchronized (dataModel) {
for (ItemInfo info : dataModel.itemsIdMap) {
if (info instanceof ShortcutInfo && mUser.equals(info.user)) {
@@ -197,6 +198,12 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
if (cn != null && matcher.matches(si, cn)) {
AppInfo appInfo = addedOrUpdatedApps.get(cn);
+ if (mOp == OP_REMOVE
+ && si.hasStatusFlag(ShortcutInfo.FLAG_SUPPORTS_WEB_UI)) {
+ removedShortcuts.put(si.id, false);
+ continue;
+ }
+
// For system apps, package manager send OP_UPDATE when an
// app is enabled.
if (si.isPromise() && (mOp == OP_ADD || mOp == OP_UPDATE)) {
@@ -220,7 +227,6 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
si.intent = intent;
}
}
-
si.status = ShortcutInfo.DEFAULT;
infoUpdated = true;
if (si.itemType == Favorites.ITEM_TYPE_APPLICATION) {
@@ -308,7 +314,8 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
if (!removedPackages.isEmpty() || !removedComponents.isEmpty()) {
ItemInfoMatcher removeMatch = ItemInfoMatcher.ofPackages(removedPackages, mUser)
- .or(ItemInfoMatcher.ofComponents(removedComponents, mUser));
+ .or(ItemInfoMatcher.ofComponents(removedComponents, mUser))
+ .and(ItemInfoMatcher.ofItemIds(removedShortcuts, true));
deleteAndBindComponentsRemoved(removeMatch);
// Remove any queued items from the install queue
diff --git a/src/com/android/launcher3/shortcuts/DeepShortcutManager.java b/src/com/android/launcher3/shortcuts/DeepShortcutManager.java
index 5ce78dc3a..f44f5c8d9 100644
--- a/src/com/android/launcher3/shortcuts/DeepShortcutManager.java
+++ b/src/com/android/launcher3/shortcuts/DeepShortcutManager.java
@@ -66,7 +66,7 @@ public class DeepShortcutManager {
public static boolean supportsShortcuts(ItemInfo info) {
boolean isItemPromise = info instanceof com.android.launcher3.ShortcutInfo
- && ((com.android.launcher3.ShortcutInfo) info).isPromise();
+ && ((com.android.launcher3.ShortcutInfo) info).hasPromiseIconUi();
return info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION
&& !info.isDisabled() && !isItemPromise;
}
diff --git a/src/com/android/launcher3/testing/LauncherExtension.java b/src/com/android/launcher3/testing/LauncherExtension.java
index 8d4351884..e5842fa0a 100644
--- a/src/com/android/launcher3/testing/LauncherExtension.java
+++ b/src/com/android/launcher3/testing/LauncherExtension.java
@@ -11,6 +11,7 @@ import com.android.launcher3.AppInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherCallbacks;
import com.android.launcher3.util.ComponentKey;
+import com.android.launcher3.util.ComponentKeyMapper;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -197,7 +198,7 @@ public class LauncherExtension extends Launcher {
}
@Override
- public List<ComponentKey> getPredictedApps() {
+ public List<ComponentKeyMapper<AppInfo>> getPredictedApps() {
// To debug app predictions, enable AlphabeticalAppsList#DEBUG_PREDICTIONS
return new ArrayList<>();
}
diff --git a/src/com/android/launcher3/util/ComponentKeyMapper.java b/src/com/android/launcher3/util/ComponentKeyMapper.java
new file mode 100644
index 000000000..916176ac4
--- /dev/null
+++ b/src/com/android/launcher3/util/ComponentKeyMapper.java
@@ -0,0 +1,50 @@
+package com.android.launcher3.util;
+
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import android.support.annotation.Nullable;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class ComponentKeyMapper<T> {
+
+ protected final ComponentKey mComponentKey;
+
+ public ComponentKeyMapper(ComponentKey key) {
+ this.mComponentKey = key;
+ }
+
+ public @Nullable T getItem(Map<ComponentKey, T> map) {
+ return map.get(mComponentKey);
+ }
+
+ public String getPackage() {
+ return mComponentKey.componentName.getPackageName();
+ }
+
+ public String getComponentClass() {
+ return mComponentKey.componentName.getClassName();
+ }
+
+ @Override
+ public String toString() {
+ return mComponentKey.toString();
+ }
+
+}