Removing support for app prediction from Launcher3
Derivative projects can extend the FloatingHeader to add support
to custom content in all-apps screen.
Change-Id: I4e29221a72e5a077a756713a6774cda7ecde8f1b
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 7a43198..246fa74 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -65,12 +65,6 @@
public int numColumns;
/**
- * The minimum number of predicted apps in all apps.
- */
- @Deprecated
- int minAllAppsPredictionColumns;
-
- /**
* Number of icons per row and column in the folder.
*/
public int numFolderRows;
@@ -99,12 +93,12 @@
public InvariantDeviceProfile(InvariantDeviceProfile p) {
this(p.name, p.minWidthDps, p.minHeightDps, p.numRows, p.numColumns,
- p.numFolderRows, p.numFolderColumns, p.minAllAppsPredictionColumns,
+ p.numFolderRows, p.numFolderColumns,
p.iconSize, p.landscapeIconSize, p.iconTextSize, p.numHotseatIcons,
p.defaultLayoutId, p.demoModeLayoutId);
}
- InvariantDeviceProfile(String n, float w, float h, int r, int c, int fr, int fc, int maapc,
+ InvariantDeviceProfile(String n, float w, float h, int r, int c, int fr, int fc,
float is, float lis, float its, int hs, int dlId, int dmlId) {
name = n;
minWidthDps = w;
@@ -113,7 +107,6 @@
numColumns = c;
numFolderRows = fr;
numFolderColumns = fc;
- minAllAppsPredictionColumns = maapc;
iconSize = is;
landscapeIconSize = lis;
iconTextSize = its;
@@ -150,7 +143,6 @@
demoModeLayoutId = closestProfile.demoModeLayoutId;
numFolderRows = closestProfile.numFolderRows;
numFolderColumns = closestProfile.numFolderColumns;
- minAllAppsPredictionColumns = closestProfile.minAllAppsPredictionColumns;
iconSize = interpolatedDeviceProfileOut.iconSize;
landscapeIconSize = interpolatedDeviceProfileOut.landscapeIconSize;
@@ -207,7 +199,6 @@
numColumns,
a.getInt(R.styleable.InvariantDeviceProfile_numFolderRows, numRows),
a.getInt(R.styleable.InvariantDeviceProfile_numFolderColumns, numColumns),
- a.getInt(R.styleable.InvariantDeviceProfile_minAllAppsPredictionColumns, numColumns),
iconSize,
a.getFloat(R.styleable.InvariantDeviceProfile_landscapeIconSize, iconSize),
a.getFloat(R.styleable.InvariantDeviceProfile_iconTextSize, 0),
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index dc3de18..4b08bb2 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -55,7 +55,6 @@
import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.keyboard.FocusedItemDecorator;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
-import com.android.launcher3.util.ComponentKeyMapper;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.views.BottomUserEducationView;
@@ -84,11 +83,7 @@
private SpannableStringBuilder mSearchQueryBuilder = null;
- private int mNumAppsPerRow;
- private int mNumPredictedAppsPerRow;
-
private boolean mUsingTabs;
- private boolean mHasPredictions = false;
private boolean mSearchModeWhileUsingTabs = false;
public AllAppsContainerView(Context context) {
@@ -237,21 +232,6 @@
}
@Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- DeviceProfile grid = mLauncher.getDeviceProfile();
-
- if (mNumAppsPerRow != grid.inv.numColumns ||
- mNumPredictedAppsPerRow != grid.inv.numColumns) {
- mNumAppsPerRow = grid.inv.numColumns;
- mNumPredictedAppsPerRow = grid.inv.numColumns;
- for (int i = 0; i < mAH.length; i++) {
- mAH[i].applyNumsPerRow();
- }
- }
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- }
-
- @Override
public boolean dispatchKeyEvent(KeyEvent event) {
mSearchUiManager.preDispatchKeyEvent(event);
return super.dispatchKeyEvent(event);
@@ -357,17 +337,12 @@
mAH[AdapterHolder.MAIN].setup(mViewPager.getChildAt(0), mPersonalMatcher);
mAH[AdapterHolder.WORK].setup(mViewPager.getChildAt(1), mWorkMatcher);
setupWorkProfileTabs();
- setupHeader();
} else {
mTabsPagerAdapter = null;
mAH[AdapterHolder.MAIN].setup(findViewById(R.id.apps_list_view), null);
mAH[AdapterHolder.WORK].recyclerView = null;
- if (FeatureFlags.ALL_APPS_PREDICTION_ROW_VIEW) {
- setupHeader();
- } else {
- mHeader.setVisibility(View.GONE);
- }
}
+ setupHeader();
mAllAppsStore.registerIconContainer(mAH[AdapterHolder.MAIN].recyclerView);
mAllAppsStore.registerIconContainer(mAH[AdapterHolder.WORK].recyclerView);
@@ -444,46 +419,21 @@
.setOnClickListener((View view) -> mViewPager.setCurrentItem(1));
}
- public void setPredictedApps(List<ComponentKeyMapper<AppInfo>> apps) {
- mAH[AdapterHolder.MAIN].appsList.setPredictedApps(apps);
- boolean hasPredictions = !apps.isEmpty();
- if (mHasPredictions != hasPredictions) {
- mHasPredictions = hasPredictions;
- if (FeatureFlags.ALL_APPS_PREDICTION_ROW_VIEW) {
- setupHeader();
- }
- }
- }
-
- public AppInfo findApp(ComponentKeyMapper<AppInfo> mapper) {
- return mAllAppsStore.getApp(mapper);
- }
-
public AlphabeticalAppsList getApps() {
return mAH[AdapterHolder.MAIN].appsList;
}
- public boolean isUsingTabs() {
- return mUsingTabs;
- }
-
public FloatingHeaderView getFloatingHeaderView() {
return mHeader;
}
public void setupHeader() {
- if (mHeader == null) {
- return;
- }
mHeader.setVisibility(View.VISIBLE);
mHeader.setup(mAH, mAH[AllAppsContainerView.AdapterHolder.WORK].recyclerView == null);
int padding = mHeader.getMaxTranslation();
- if (mHasPredictions && !mUsingTabs) {
- padding += mHeader.getPaddingTop() + mHeader.getPaddingBottom();
- }
for (int i = 0; i < mAH.length; i++) {
- mAH[i].paddingTopForTabs = padding;
+ mAH[i].padding.top = padding;
mAH[i].applyPadding();
}
}
@@ -513,13 +463,6 @@
}
}
- public void setRecyclerViewPaddingTop(int top) {
- for (int i = 0; i < mAH.length; i++) {
- mAH[i].padding.top = top;
- mAH[i].applyPadding();
- }
- }
-
public void setRecyclerViewVerticalFadingEdgeEnabled(boolean enabled) {
for (int i = 0; i < mAH.length; i++) {
mAH[i].applyVerticalFadingEdgeEnabled(enabled);
@@ -551,7 +494,6 @@
final SpringAnimationHandler animationHandler;
final AlphabeticalAppsList appsList;
final Rect padding = new Rect();
- int paddingTopForTabs;
AllAppsRecyclerView recyclerView;
boolean verticalFadingEdge;
@@ -582,24 +524,11 @@
adapter.setIconFocusListener(focusedItemDecorator.getFocusListener());
applyVerticalFadingEdgeEnabled(verticalFadingEdge);
applyPadding();
- applyNumsPerRow();
}
void applyPadding() {
if (recyclerView != null) {
- int paddingTop = mUsingTabs || FeatureFlags.ALL_APPS_PREDICTION_ROW_VIEW
- ? paddingTopForTabs : padding.top;
- recyclerView.setPadding(padding.left, paddingTop, padding.right, padding.bottom);
- }
- }
-
- void applyNumsPerRow() {
- if (mNumAppsPerRow > 0) {
- if (recyclerView != null) {
- recyclerView.setNumAppsPerRow(mLauncher.getDeviceProfile(), mNumAppsPerRow);
- }
- adapter.setNumAppsPerRow(mNumAppsPerRow);
- appsList.setNumAppsPerRow(mNumAppsPerRow, mNumPredictedAppsPerRow);
+ recyclerView.setPadding(padding.left, padding.top, padding.right, padding.bottom);
}
}
diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
index 2103106..a61521c 100644
--- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
+++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
@@ -56,29 +56,22 @@
// A normal icon
public static final int VIEW_TYPE_ICON = 1 << 1;
- // A prediction icon
- public static final int VIEW_TYPE_PREDICTION_ICON = 1 << 2;
// The message shown when there are no filtered results
- public static final int VIEW_TYPE_EMPTY_SEARCH = 1 << 3;
+ public static final int VIEW_TYPE_EMPTY_SEARCH = 1 << 2;
// The message to continue to a market search when there are no filtered results
- public static final int VIEW_TYPE_SEARCH_MARKET = 1 << 4;
+ public static final int VIEW_TYPE_SEARCH_MARKET = 1 << 3;
// We use various dividers for various purposes. They share enough attributes to reuse layouts,
// but differ in enough attributes to require different view types
// A divider that separates the apps list and the search market button
- public static final int VIEW_TYPE_ALL_APPS_DIVIDER = 1 << 5;
- // The divider that separates prediction icons from the app list
- public static final int VIEW_TYPE_PREDICTION_DIVIDER = 1 << 6;
- public static final int VIEW_TYPE_WORK_TAB_FOOTER = 1 << 7;
+ public static final int VIEW_TYPE_ALL_APPS_DIVIDER = 1 << 4;
+ public static final int VIEW_TYPE_WORK_TAB_FOOTER = 1 << 5;
// Common view type masks
- public static final int VIEW_TYPE_MASK_DIVIDER = VIEW_TYPE_ALL_APPS_DIVIDER
- | VIEW_TYPE_PREDICTION_DIVIDER;
- public static final int VIEW_TYPE_MASK_ICON = VIEW_TYPE_ICON
- | VIEW_TYPE_PREDICTION_ICON;
- public static final int VIEW_TYPE_MASK_HAS_SPRINGS = VIEW_TYPE_MASK_ICON
- | VIEW_TYPE_PREDICTION_DIVIDER;
+ public static final int VIEW_TYPE_MASK_DIVIDER = VIEW_TYPE_ALL_APPS_DIVIDER;
+ public static final int VIEW_TYPE_MASK_ICON = VIEW_TYPE_ICON;
+ public static final int VIEW_TYPE_MASK_HAS_SPRINGS = VIEW_TYPE_MASK_ICON;
public interface BindViewCallback {
@@ -192,7 +185,7 @@
private final View.OnClickListener mIconClickListener;
private final View.OnLongClickListener mIconLongClickListener;
- private int mAppsPerRow;
+ private final int mAppsPerRow;
private BindViewCallback mBindViewCallback;
private OnFocusChangeListener mIconFocusListener;
@@ -222,6 +215,9 @@
} else {
mSpringAnimationHandler = null;
}
+
+ mAppsPerRow = mLauncher.getDeviceProfile().inv.numColumns;
+ mGridLayoutMgr.setSpanCount(mAppsPerRow);
}
public SpringAnimationHandler getSpringAnimationHandler() {
@@ -240,18 +236,6 @@
return (viewType & viewTypeMask) != 0;
}
- /**
- * Sets the number of apps per row.
- */
- public void setNumAppsPerRow(int appsPerRow) {
- mAppsPerRow = appsPerRow;
- mGridLayoutMgr.setSpanCount(appsPerRow);
- }
-
- public int getNumAppsPerRow() {
- return mAppsPerRow;
- }
-
public void setIconFocusListener(OnFocusChangeListener focusListener) {
mIconFocusListener = focusListener;
}
@@ -284,7 +268,6 @@
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
switch (viewType) {
case VIEW_TYPE_ICON:
- case VIEW_TYPE_PREDICTION_ICON:
BubbleTextView icon = (BubbleTextView) mLayoutInflater.inflate(
R.layout.all_apps_icon, parent, false);
icon.setOnClickListener(mIconClickListener);
@@ -308,7 +291,6 @@
}
});
return new ViewHolder(searchMarketView);
- case VIEW_TYPE_PREDICTION_DIVIDER:
case VIEW_TYPE_ALL_APPS_DIVIDER:
return new ViewHolder(mLayoutInflater.inflate(
R.layout.all_apps_divider, parent, false));
@@ -324,7 +306,6 @@
public void onBindViewHolder(ViewHolder holder, int position) {
switch (holder.getItemViewType()) {
case VIEW_TYPE_ICON:
- case VIEW_TYPE_PREDICTION_ICON:
AppInfo info = mApps.getAdapterItems().get(position).appInfo;
BubbleTextView icon = (BubbleTextView) holder.itemView;
icon.reset();
@@ -427,10 +408,7 @@
*/
@Override
public void update(SpringAnimation spring, ViewHolder vh) {
- int numPredictedApps = Math.min(mAppsPerRow, mApps.getPredictedApps().size());
- int appPosition = getAppPosition(vh.getAdapterPosition(), numPredictedApps,
- mAppsPerRow);
-
+ int appPosition = vh.getAdapterPosition();
int col = appPosition % mAppsPerRow;
int row = appPosition / mAppsPerRow;
@@ -473,31 +451,6 @@
}
/**
- * @return The app position is the position of the app in the Adapter if we ignored all
- * other view types.
- *
- * The first app is at position 0, and the first app each following row is at a
- * position that is a multiple of {@param appsPerRow}.
- *
- * ie. If there are 5 apps per row, and there are two rows of apps:
- * 0 1 2 3 4
- * 5 6 7 8 9
- */
- private int getAppPosition(int position, int numPredictedApps, int appsPerRow) {
- if (position < numPredictedApps) {
- // Predicted apps are first in the adapter.
- return position;
- }
-
- // There is at most 1 divider view between the predicted apps and the alphabetical apps.
- int numDividerViews = numPredictedApps == 0 ? 0 : 1;
-
- // This offset takes into consideration an incomplete row of predicted apps.
- int numPredictedAppsOffset = appsPerRow - numPredictedApps;
- return position + numPredictedAppsOffset - numDividerViews;
- }
-
- /**
* Increase the column factor as the distance increases between the column and the center
* column(s).
*/
diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
index 4792cc2..a16d00b 100644
--- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
@@ -28,9 +28,10 @@
import android.view.View;
import com.android.launcher3.BaseRecyclerView;
-import com.android.launcher3.BubbleTextView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.ItemInfo;
+import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherAppState;
import com.android.launcher3.R;
import com.android.launcher3.anim.SpringAnimationHandler;
import com.android.launcher3.config.FeatureFlags;
@@ -51,7 +52,7 @@
private AlphabeticalAppsList mApps;
private AllAppsFastScrollHelper mFastScrollHelper;
- private int mNumAppsPerRow;
+ private final int mNumAppsPerRow;
// The specific view heights that we use to calculate scroll
private SparseIntArray mViewHeights = new SparseIntArray();
@@ -101,6 +102,8 @@
mOverScrollHelper = new OverScrollHelper();
mPullDetector = new SwipeDetector(getContext(), mOverScrollHelper, SwipeDetector.VERTICAL);
mPullDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_BOTH, true);
+
+ mNumAppsPerRow = LauncherAppState.getIDP(context).numColumns;
}
public void setSpringAnimationHandler(SpringAnimationHandler springAnimationHandler) {
@@ -131,19 +134,14 @@
return mApps;
}
- /**
- * Sets the number of apps per row in this recycler view.
- */
- public void setNumAppsPerRow(DeviceProfile grid, int numAppsPerRow) {
- mNumAppsPerRow = numAppsPerRow;
+ private void updatePoolSize() {
+ DeviceProfile grid = Launcher.getLauncher(getContext()).getDeviceProfile();
RecyclerView.RecycledViewPool pool = getRecycledViewPool();
int approxRows = (int) Math.ceil(grid.availableHeightPx / grid.allAppsIconSizePx);
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_EMPTY_SEARCH, 1);
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_ALL_APPS_DIVIDER, 1);
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_SEARCH_MARKET, 1);
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_ICON, approxRows * mNumAppsPerRow);
- pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_PREDICTION_ICON, mNumAppsPerRow);
- pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_PREDICTION_DIVIDER, 1);
}
/**
@@ -154,7 +152,6 @@
View icon = adapter.onCreateViewHolder(this, AllAppsGridAdapter.VIEW_TYPE_ICON).itemView;
final int iconHeight = icon.getLayoutParams().height;
mViewHeights.put(AllAppsGridAdapter.VIEW_TYPE_ICON, iconHeight);
- mViewHeights.put(AllAppsGridAdapter.VIEW_TYPE_PREDICTION_ICON, iconHeight);
final int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(
getResources().getDisplayMetrics().widthPixels, View.MeasureSpec.AT_MOST);
@@ -162,7 +159,6 @@
getResources().getDisplayMetrics().heightPixels, View.MeasureSpec.AT_MOST);
putSameHeightFor(adapter, widthMeasureSpec, heightMeasureSpec,
- AllAppsGridAdapter.VIEW_TYPE_PREDICTION_DIVIDER,
AllAppsGridAdapter.VIEW_TYPE_ALL_APPS_DIVIDER);
putSameHeightFor(adapter, widthMeasureSpec, heightMeasureSpec,
AllAppsGridAdapter.VIEW_TYPE_SEARCH_MARKET);
@@ -229,6 +225,7 @@
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
updateEmptySearchBackgroundBounds();
+ updatePoolSize();
}
@Override
@@ -236,19 +233,6 @@
if (mApps.hasFilter()) {
targetParent.containerType = ContainerType.SEARCHRESULT;
} else {
- if (v instanceof BubbleTextView) {
- BubbleTextView icon = (BubbleTextView) v;
- int position = getChildPosition(icon);
- if (position != NO_POSITION) {
- List<AlphabeticalAppsList.AdapterItem> items = mApps.getAdapterItems();
- AlphabeticalAppsList.AdapterItem item = items.get(position);
- if (item.viewType == AllAppsGridAdapter.VIEW_TYPE_PREDICTION_ICON) {
- targetParent.containerType = ContainerType.PREDICTION;
- target.predictedRank = item.rowAppIndex;
- return;
- }
- }
- }
targetParent.containerType = ContainerType.ALLAPPS;
}
}
diff --git a/src/com/android/launcher3/allapps/AllAppsStore.java b/src/com/android/launcher3/allapps/AllAppsStore.java
index 17f1c89..846b6a9 100644
--- a/src/com/android/launcher3/allapps/AllAppsStore.java
+++ b/src/com/android/launcher3/allapps/AllAppsStore.java
@@ -21,7 +21,6 @@
import com.android.launcher3.AppInfo;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.util.ComponentKey;
-import com.android.launcher3.util.ComponentKeyMapper;
import java.util.ArrayList;
import java.util.Collection;
@@ -53,10 +52,6 @@
return mComponentToAppMap.get(key);
}
- public AppInfo getApp(ComponentKeyMapper<AppInfo> mapper) {
- return mapper.getItem(mComponentToAppMap);
- }
-
/**
* Adds or updates existing apps in the list
*/
diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
index 29b32b0..434918d 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -17,19 +17,13 @@
import android.content.Context;
import android.content.pm.PackageManager;
-import android.os.Process;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.util.Log;
import com.android.launcher3.AppInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.AlphabeticIndexCompat;
-import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.util.ComponentKey;
-import com.android.launcher3.util.ComponentKeyMapper;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.LabelComparator;
@@ -47,8 +41,6 @@
public class AlphabeticalAppsList implements AllAppsStore.OnUpdateListener {
public static final String TAG = "AlphabeticalAppsList";
- private static final boolean DEBUG = false;
- private static final boolean DEBUG_PREDICTIONS = false;
private static final int FAST_SCROLL_FRACTION_DISTRIBUTE_BY_ROWS_FRACTION = 0;
private static final int FAST_SCROLL_FRACTION_DISTRIBUTE_BY_NUM_SECTIONS = 1;
@@ -95,13 +87,6 @@
// The index of this app not including sections
public int appIndex = -1;
- public static AdapterItem asPredictedApp(int pos, String sectionName, AppInfo appInfo,
- int appIndex) {
- AdapterItem item = asApp(pos, sectionName, appInfo, appIndex);
- item.viewType = AllAppsGridAdapter.VIEW_TYPE_PREDICTION_ICON;
- return item;
- }
-
public static AdapterItem asApp(int pos, String sectionName, AppInfo appInfo,
int appIndex) {
AdapterItem item = new AdapterItem();
@@ -120,13 +105,6 @@
return item;
}
- public static AdapterItem asPredictionDivider(int pos) {
- AdapterItem item = new AdapterItem();
- item.viewType = AllAppsGridAdapter.VIEW_TYPE_PREDICTION_DIVIDER;
- item.position = pos;
- return item;
- }
-
public static AdapterItem asAllAppsDivider(int pos) {
AdapterItem item = new AdapterItem();
item.viewType = AllAppsGridAdapter.VIEW_TYPE_ALL_APPS_DIVIDER;
@@ -151,7 +129,7 @@
private final Launcher mLauncher;
- // The set of apps from the system not including predictions
+ // The set of apps from the system
private final List<AppInfo> mApps = new ArrayList<>();
private final AllAppsStore mAllAppsStore;
@@ -161,10 +139,6 @@
private final ArrayList<AdapterItem> mAdapterItems = new ArrayList<>();
// 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<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<>();
// Is it the work profile app list.
private final boolean mIsWork;
@@ -174,8 +148,7 @@
private AllAppsGridAdapter mAdapter;
private AlphabeticIndexCompat mIndexer;
private AppInfoComparator mAppNameComparator;
- private int mNumAppsPerRow;
- private int mNumPredictedAppsPerRow;
+ private final int mNumAppsPerRow;
private int mNumAppRowsInAdapter;
private ItemInfoMatcher mItemFilter;
@@ -185,6 +158,7 @@
mIndexer = new AlphabeticIndexCompat(context);
mAppNameComparator = new AppInfoComparator(context);
mIsWork = isWork;
+ mNumAppsPerRow = mLauncher.getDeviceProfile().inv.numColumns;
mAllAppsStore.addUpdateListener(this);
}
@@ -194,16 +168,6 @@
}
/**
- * Sets the number of apps per row.
- */
- public void setNumAppsPerRow(int numAppsPerRow, int numPredictedAppsPerRow) {
- mNumAppsPerRow = numAppsPerRow;
- mNumPredictedAppsPerRow = numPredictedAppsPerRow;
-
- updateAdapterItems();
- }
-
- /**
* Sets the adapter to notify when this dataset changes.
*/
public void setAdapter(AllAppsGridAdapter adapter) {
@@ -218,13 +182,6 @@
}
/**
- * Returns the predicted apps.
- */
- public List<AppInfo> getPredictedApps() {
- return mPredictedApps;
- }
-
- /**
* Returns fast scroller sections of all the current filtered applications.
*/
public List<FastScrollSectionInfo> getFastScrollerSections() {
@@ -239,7 +196,7 @@
}
/**
- * Returns the number of rows of applications (not including predictions)
+ * Returns the number of rows of applications
*/
public int getNumAppRows() {
return mNumAppRowsInAdapter;
@@ -279,80 +236,6 @@
return false;
}
- private List<AppInfo> processPredictedAppComponents(List<ComponentKeyMapper<AppInfo>> components) {
- if (mAllAppsStore.getApps().isEmpty()) {
- // Apps have not been bound yet.
- return Collections.emptyList();
- }
-
- List<AppInfo> predictedApps = new ArrayList<>();
- for (ComponentKeyMapper<AppInfo> mapper : components) {
- AppInfo info = mAllAppsStore.getApp(mapper);
- if (info != null) {
- predictedApps.add(info);
- } else {
- if (FeatureFlags.IS_DOGFOOD_BUILD) {
- Log.e(TAG, "Predicted app not found: " + mapper);
- }
- }
- // Stop at the number of predicted apps
- if (predictedApps.size() == mNumPredictedAppsPerRow) {
- break;
- }
- }
- return predictedApps;
- }
-
- /**
- * Sets the current set of predicted apps.
- *
- * This can be called before we get the full set of applications, we should merge the results
- * only in onAppsUpdated() which is idempotent.
- *
- * 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<ComponentKeyMapper<AppInfo>> apps) {
- mPredictedAppComponents.clear();
- mPredictedAppComponents.addAll(apps);
-
- List<AppInfo> newPredictedApps = processPredictedAppComponents(apps);
- // We only need to do work if any of the visible predicted apps have changed.
- if (!newPredictedApps.equals(mPredictedApps)) {
- if (newPredictedApps.size() == mPredictedApps.size()) {
- swapInNewPredictedApps(newPredictedApps);
- } else {
- // We need to update the appIndex of all the items.
- onAppsUpdated();
- }
- }
- }
-
- /**
- * Swaps out the old predicted apps with the new predicted apps, in place. This optimization
- * allows us to skip an entire relayout that would otherwise be called by notifyDataSetChanged.
- *
- * Note: This should only be called if the # of predicted apps is the same.
- * This method assumes that predicted apps are the first items in the adapter.
- */
- private void swapInNewPredictedApps(List<AppInfo> apps) {
- mPredictedApps.clear();
- mPredictedApps.addAll(apps);
-
- int size = apps.size();
- for (int i = 0; i < size; ++i) {
- AppInfo info = apps.get(i);
- AdapterItem orgItem = mAdapterItems.get(i);
- AdapterItem newItem = AdapterItem.asPredictedApp(orgItem.position, "", info,
- orgItem.appIndex);
- newItem.rowAppIndex = orgItem.rowAppIndex;
-
- mAdapterItems.set(i, newItem);
- mFilteredApps.set(i, info);
- mAdapter.notifyItemChanged(i);
- }
- }
-
/**
* Updates internals when the set of apps are updated.
*/
@@ -433,47 +316,6 @@
mFastScrollerSections.clear();
mAdapterItems.clear();
- if (!FeatureFlags.ALL_APPS_PREDICTION_ROW_VIEW) {
- if (DEBUG_PREDICTIONS) {
- if (mPredictedAppComponents.isEmpty() && !mApps.isEmpty()) {
- 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())));
- }
- }
-
- // Process the predicted app components
- mPredictedApps.clear();
- if (mPredictedAppComponents != null && !mPredictedAppComponents.isEmpty() && !hasFilter()) {
- mPredictedApps.addAll(processPredictedAppComponents(mPredictedAppComponents));
-
- if (!mPredictedApps.isEmpty()) {
- // Add a section for the predictions
- lastFastScrollerSectionInfo = new FastScrollSectionInfo("");
- mFastScrollerSections.add(lastFastScrollerSectionInfo);
-
- // Add the predicted app items
- for (AppInfo info : mPredictedApps) {
- AdapterItem appItem = AdapterItem.asPredictedApp(position++, "", info,
- appIndex++);
- if (lastFastScrollerSectionInfo.fastScrollToItem == null) {
- lastFastScrollerSectionInfo.fastScrollToItem = appItem;
- }
- mAdapterItems.add(appItem);
- mFilteredApps.add(info);
- }
-
- mAdapterItems.add(AdapterItem.asPredictionDivider(position++));
- }
- }
-
- }
-
// Recreate the filtered and sectioned apps (for convenience for the grid layout) from the
// ordered set of sections
for (AppInfo info : getFiltersAppInfos()) {
diff --git a/src/com/android/launcher3/config/BaseFlags.java b/src/com/android/launcher3/config/BaseFlags.java
index 059b04e..e494bea 100644
--- a/src/com/android/launcher3/config/BaseFlags.java
+++ b/src/com/android/launcher3/config/BaseFlags.java
@@ -53,8 +53,6 @@
// When enabled shows a work profile tab in all apps
public static final boolean ALL_APPS_TABS_ENABLED = true;
- // When enabled prediction row is rendered as it's own custom view
- public static final boolean ALL_APPS_PREDICTION_ROW_VIEW = true;
public static final boolean ENABLE_TWO_SWIPE_TARGETS = true;
}
diff --git a/src/com/android/launcher3/util/ComponentKeyMapper.java b/src/com/android/launcher3/util/ComponentKeyMapper.java
deleted file mode 100644
index a7f0d76..0000000
--- a/src/com/android/launcher3/util/ComponentKeyMapper.java
+++ /dev/null
@@ -1,48 +0,0 @@
-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.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();
- }
-
-}