Merge "Removing support for app prediction from Launcher3" into ub-launcher3-master

This commit is contained in:
TreeHugger Robot
2018-02-06 00:55:56 +00:00
committed by Android (Google) Code Review
11 changed files with 29 additions and 399 deletions

View File

@@ -58,7 +58,6 @@ import com.android.launcher3.dragndrop.DragController;
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;
@@ -87,11 +86,7 @@ public class AllAppsContainerView extends RelativeLayout implements DragSource,
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) {
@@ -252,21 +247,6 @@ public class AllAppsContainerView extends RelativeLayout implements DragSource,
return mSearchUiManager;
}
@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);
@@ -378,17 +358,12 @@ public class AllAppsContainerView extends RelativeLayout implements DragSource,
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);
@@ -465,46 +440,21 @@ public class AllAppsContainerView extends RelativeLayout implements DragSource,
.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();
}
}
@@ -534,13 +484,6 @@ public class AllAppsContainerView extends RelativeLayout implements DragSource,
}
}
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);
@@ -572,7 +515,6 @@ public class AllAppsContainerView extends RelativeLayout implements DragSource,
final SpringAnimationHandler animationHandler;
final AlphabeticalAppsList appsList;
final Rect padding = new Rect();
int paddingTopForTabs;
AllAppsRecyclerView recyclerView;
boolean verticalFadingEdge;
@@ -603,24 +545,11 @@ public class AllAppsContainerView extends RelativeLayout implements DragSource,
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);
}
}