From 8ff9e1d6790d64eb5f8ad9e9721e607978b50583 Mon Sep 17 00:00:00 2001 From: Mario Bertschler Date: Tue, 8 Aug 2017 16:26:18 -0700 Subject: Integrating suggested app by handling new status flags for shortcut items. Guarded via feature flag SUGGESTED_APP. Bug: 62483883 Change-Id: I7e0c8a9875bc37c435aa4316b44322a628cd4826 --- .../launcher3/allapps/AllAppsContainerView.java | 3 +- .../launcher3/allapps/AlphabeticalAppsList.java | 33 +++++++++++----------- 2 files changed, 19 insertions(+), 17 deletions(-) (limited to 'src/com/android/launcher3/allapps') diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index 97a87c16c..5cd072223 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 apps) { + public void setPredictedApps(List> 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 mFastScrollerSections = new ArrayList<>(); // The set of predicted app component names - private final List mPredictedAppComponents = new ArrayList<>(); + private final List> mPredictedAppComponents = new ArrayList<>(); // The set of predicted apps resolved from the component names and the current set of apps private final List mPredictedApps = new ArrayList<>(); private final List mDiscoveredApps = new ArrayList<>(); @@ -298,20 +299,20 @@ public class AlphabeticalAppsList { updateAdapterItems(); } - private List processPredictedAppComponents(List components) { + private List processPredictedAppComponents(List> components) { if (mComponentToAppMap.isEmpty()) { // Apps have not been bound yet. return Collections.emptyList(); } List predictedApps = new ArrayList<>(); - for (ComponentKey ck : components) { - AppInfo info = mComponentToAppMap.get(ck); + for (ComponentKeyMapper 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 apps) { + public void setPredictedApps(List> 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(new ComponentKey(mApps.get(0).componentName, + Process.myUserHandle()))); + mPredictedAppComponents.add(new ComponentKeyMapper(new ComponentKey(mApps.get(0).componentName, + Process.myUserHandle()))); + mPredictedAppComponents.add(new ComponentKeyMapper(new ComponentKey(mApps.get(0).componentName, + Process.myUserHandle()))); + mPredictedAppComponents.add(new ComponentKeyMapper(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 mapper) { + return mapper.getItem(mComponentToAppMap); } /** -- cgit v1.2.3