Merge "Revert "Revert "Provide AllApps item OnLongClickListener through ActivityContext.""" into udc-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1a50287c08
@@ -43,7 +43,6 @@ import com.android.launcher3.keyboard.FocusIndicatorHelper.SimpleFocusIndicatorH
|
|||||||
import com.android.launcher3.model.data.ItemInfo;
|
import com.android.launcher3.model.data.ItemInfo;
|
||||||
import com.android.launcher3.model.data.ItemInfoWithIcon;
|
import com.android.launcher3.model.data.ItemInfoWithIcon;
|
||||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||||
import com.android.launcher3.touch.ItemLongClickListener;
|
|
||||||
import com.android.launcher3.views.ActivityContext;
|
import com.android.launcher3.views.ActivityContext;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -66,7 +65,6 @@ public class PredictionRowView<T extends Context & ActivityContext>
|
|||||||
private FloatingHeaderView mParent;
|
private FloatingHeaderView mParent;
|
||||||
|
|
||||||
private boolean mPredictionsEnabled = false;
|
private boolean mPredictionsEnabled = false;
|
||||||
private OnLongClickListener mOnIconLongClickListener = ItemLongClickListener.INSTANCE_ALL_APPS;
|
|
||||||
|
|
||||||
public PredictionRowView(@NonNull Context context) {
|
public PredictionRowView(@NonNull Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
@@ -176,15 +174,6 @@ public class PredictionRowView<T extends Context & ActivityContext>
|
|||||||
applyPredictionApps();
|
applyPredictionApps();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the long click listener for predictions for any future predictions.
|
|
||||||
*
|
|
||||||
* Existing predictions in the container are not updated with this new callback.
|
|
||||||
*/
|
|
||||||
public void setOnIconLongClickListener(OnLongClickListener onIconLongClickListener) {
|
|
||||||
mOnIconLongClickListener = onIconLongClickListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDeviceProfileChanged(DeviceProfile dp) {
|
public void onDeviceProfileChanged(DeviceProfile dp) {
|
||||||
mNumPredictedAppsPerRow = dp.numShownAllAppsColumns;
|
mNumPredictedAppsPerRow = dp.numShownAllAppsColumns;
|
||||||
@@ -202,7 +191,7 @@ public class PredictionRowView<T extends Context & ActivityContext>
|
|||||||
BubbleTextView icon = (BubbleTextView) inflater.inflate(
|
BubbleTextView icon = (BubbleTextView) inflater.inflate(
|
||||||
R.layout.all_apps_icon, this, false);
|
R.layout.all_apps_icon, this, false);
|
||||||
icon.setOnClickListener(mActivityContext.getItemOnClickListener());
|
icon.setOnClickListener(mActivityContext.getItemOnClickListener());
|
||||||
icon.setOnLongClickListener(mOnIconLongClickListener);
|
icon.setOnLongClickListener(mActivityContext.getAllAppsItemLongClickListener());
|
||||||
icon.setLongPressTimeoutFactor(1f);
|
icon.setLongPressTimeoutFactor(1f);
|
||||||
icon.setOnFocusChangeListener(mFocusHelper);
|
icon.setOnFocusChangeListener(mFocusHelper);
|
||||||
|
|
||||||
|
|||||||
-10
@@ -18,9 +18,7 @@ package com.android.launcher3.secondarydisplay;
|
|||||||
import static com.android.launcher3.util.OnboardingPrefs.ALL_APPS_VISITED_COUNT;
|
import static com.android.launcher3.util.OnboardingPrefs.ALL_APPS_VISITED_COUNT;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import com.android.launcher3.allapps.ActivityAllAppsContainerView;
|
|
||||||
import com.android.launcher3.appprediction.AppsDividerView;
|
import com.android.launcher3.appprediction.AppsDividerView;
|
||||||
import com.android.launcher3.appprediction.PredictionRowView;
|
import com.android.launcher3.appprediction.PredictionRowView;
|
||||||
import com.android.launcher3.model.BgDataModel;
|
import com.android.launcher3.model.BgDataModel;
|
||||||
@@ -56,12 +54,4 @@ public final class SecondaryDisplayPredictionsImpl extends SecondaryDisplayPredi
|
|||||||
.findFixedRowByType(PredictionRowView.class)
|
.findFixedRowByType(PredictionRowView.class)
|
||||||
.setPredictedApps(item.items);
|
.setPredictedApps(item.items);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLongClickListener(ActivityAllAppsContainerView<?> appsView,
|
|
||||||
View.OnLongClickListener onIconLongClickListener) {
|
|
||||||
appsView.getFloatingHeaderView()
|
|
||||||
.findFixedRowByType(PredictionRowView.class)
|
|
||||||
.setOnIconLongClickListener(onIconLongClickListener);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import static com.android.launcher3.util.OnboardingPrefs.ALL_APPS_VISITED_COUNT;
|
|||||||
|
|
||||||
import com.android.launcher3.AbstractFloatingView;
|
import com.android.launcher3.AbstractFloatingView;
|
||||||
import com.android.launcher3.appprediction.AppsDividerView;
|
import com.android.launcher3.appprediction.AppsDividerView;
|
||||||
import com.android.launcher3.appprediction.PredictionRowView;
|
|
||||||
import com.android.launcher3.taskbar.NavbarButtonsViewController;
|
import com.android.launcher3.taskbar.NavbarButtonsViewController;
|
||||||
import com.android.launcher3.taskbar.TaskbarControllers;
|
import com.android.launcher3.taskbar.TaskbarControllers;
|
||||||
import com.android.launcher3.taskbar.TaskbarStashController;
|
import com.android.launcher3.taskbar.TaskbarStashController;
|
||||||
@@ -54,7 +53,6 @@ final class TaskbarAllAppsViewController {
|
|||||||
mOverlayController = taskbarControllers.taskbarOverlayController;
|
mOverlayController = taskbarControllers.taskbarOverlayController;
|
||||||
|
|
||||||
mSlideInView.init(new TaskbarAllAppsCallbacks());
|
mSlideInView.init(new TaskbarAllAppsCallbacks());
|
||||||
setUpIconLongClick();
|
|
||||||
setUpAppDivider();
|
setUpAppDivider();
|
||||||
setUpTaskbarStashing();
|
setUpTaskbarStashing();
|
||||||
}
|
}
|
||||||
@@ -69,15 +67,6 @@ final class TaskbarAllAppsViewController {
|
|||||||
mSlideInView.close(animate);
|
mSlideInView.close(animate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpIconLongClick() {
|
|
||||||
mAppsView.setOnIconLongClickListener(
|
|
||||||
mContext.getDragController()::startDragOnLongClick);
|
|
||||||
mAppsView.getFloatingHeaderView()
|
|
||||||
.findFixedRowByType(PredictionRowView.class)
|
|
||||||
.setOnIconLongClickListener(
|
|
||||||
mContext.getDragController()::startDragOnLongClick);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpAppDivider() {
|
private void setUpAppDivider() {
|
||||||
mAppsView.getFloatingHeaderView()
|
mAppsView.getFloatingHeaderView()
|
||||||
.findFixedRowByType(AppsDividerView.class)
|
.findFixedRowByType(AppsDividerView.class)
|
||||||
|
|||||||
@@ -125,6 +125,11 @@ public class TaskbarOverlayContext extends BaseTaskbarContext {
|
|||||||
return mTaskbarContext.getItemOnClickListener();
|
return mTaskbarContext.getItemOnClickListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View.OnLongClickListener getAllAppsItemLongClickListener() {
|
||||||
|
return mDragController::startDragOnLongClick;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PopupDataProvider getPopupDataProvider() {
|
public PopupDataProvider getPopupDataProvider() {
|
||||||
return mTaskbarContext.getPopupDataProvider();
|
return mTaskbarContext.getPopupDataProvider();
|
||||||
|
|||||||
@@ -194,6 +194,7 @@ import com.android.launcher3.states.RotationHelper;
|
|||||||
import com.android.launcher3.testing.TestLogging;
|
import com.android.launcher3.testing.TestLogging;
|
||||||
import com.android.launcher3.testing.shared.TestProtocol;
|
import com.android.launcher3.testing.shared.TestProtocol;
|
||||||
import com.android.launcher3.touch.AllAppsSwipeController;
|
import com.android.launcher3.touch.AllAppsSwipeController;
|
||||||
|
import com.android.launcher3.touch.ItemLongClickListener;
|
||||||
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
|
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
|
||||||
import com.android.launcher3.util.ActivityResultInfo;
|
import com.android.launcher3.util.ActivityResultInfo;
|
||||||
import com.android.launcher3.util.ActivityTracker;
|
import com.android.launcher3.util.ActivityTracker;
|
||||||
@@ -3372,4 +3373,9 @@ public class Launcher extends StatefulActivity<LauncherState>
|
|||||||
public boolean areFreeformTasksVisible() {
|
public boolean areFreeformTasksVisible() {
|
||||||
return false; // Base launcher does not track freeform tasks
|
return false; // Base launcher does not track freeform tasks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View.OnLongClickListener getAllAppsItemLongClickListener() {
|
||||||
|
return ItemLongClickListener.INSTANCE_ALL_APPS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -892,15 +892,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
|||||||
container.put(R.id.work_tab_state_id, state);
|
container.put(R.id.work_tab_state_id, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the long click listener for icons
|
|
||||||
*/
|
|
||||||
public void setOnIconLongClickListener(OnLongClickListener listener) {
|
|
||||||
for (AdapterHolder holder : mAH) {
|
|
||||||
holder.mAdapter.setOnIconLongClickListener(listener);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public AllAppsStore getAppsStore() {
|
public AllAppsStore getAppsStore() {
|
||||||
return mAllAppsStore;
|
return mAllAppsStore;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.launcher3.allapps;
|
package com.android.launcher3.allapps;
|
||||||
|
|
||||||
import static com.android.launcher3.touch.ItemLongClickListener.INSTANCE_ALL_APPS;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
@@ -27,7 +24,6 @@ import android.view.View.OnLongClickListener;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.android.launcher3.BubbleTextView;
|
import com.android.launcher3.BubbleTextView;
|
||||||
@@ -139,31 +135,24 @@ public abstract class BaseAllAppsAdapter<T extends Context & ActivityContext> ex
|
|||||||
|
|
||||||
protected final LayoutInflater mLayoutInflater;
|
protected final LayoutInflater mLayoutInflater;
|
||||||
protected final OnClickListener mOnIconClickListener;
|
protected final OnClickListener mOnIconClickListener;
|
||||||
protected OnLongClickListener mOnIconLongClickListener = INSTANCE_ALL_APPS;
|
protected final OnLongClickListener mOnIconLongClickListener;
|
||||||
protected OnFocusChangeListener mIconFocusListener;
|
protected OnFocusChangeListener mIconFocusListener;
|
||||||
private final int mExtraTextHeight;
|
private final int mExtraTextHeight;
|
||||||
|
|
||||||
public BaseAllAppsAdapter(T activityContext, LayoutInflater inflater,
|
public BaseAllAppsAdapter(T activityContext, LayoutInflater inflater,
|
||||||
AlphabeticalAppsList<T> apps, SearchAdapterProvider<?> adapterProvider) {
|
AlphabeticalAppsList<T> apps, SearchAdapterProvider<?> adapterProvider) {
|
||||||
Resources res = activityContext.getResources();
|
|
||||||
mActivityContext = activityContext;
|
mActivityContext = activityContext;
|
||||||
mApps = apps;
|
mApps = apps;
|
||||||
mLayoutInflater = inflater;
|
mLayoutInflater = inflater;
|
||||||
|
|
||||||
mOnIconClickListener = mActivityContext.getItemOnClickListener();
|
mOnIconClickListener = mActivityContext.getItemOnClickListener();
|
||||||
|
mOnIconLongClickListener = mActivityContext.getAllAppsItemLongClickListener();
|
||||||
|
|
||||||
mAdapterProvider = adapterProvider;
|
mAdapterProvider = adapterProvider;
|
||||||
mExtraTextHeight = Utilities.calculateTextHeight(
|
mExtraTextHeight = Utilities.calculateTextHeight(
|
||||||
mActivityContext.getDeviceProfile().allAppsIconTextSizePx);
|
mActivityContext.getDeviceProfile().allAppsIconTextSizePx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the long click listener for icons
|
|
||||||
*/
|
|
||||||
public void setOnIconLongClickListener(@Nullable OnLongClickListener listener) {
|
|
||||||
mOnIconLongClickListener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Checks if the passed viewType represents all apps divider. */
|
/** Checks if the passed viewType represents all apps divider. */
|
||||||
public static boolean isDividerViewType(int viewType) {
|
public static boolean isDividerViewType(int viewType) {
|
||||||
return isViewType(viewType, VIEW_TYPE_MASK_DIVIDER);
|
return isViewType(viewType, VIEW_TYPE_MASK_DIVIDER);
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class SecondaryDisplayLauncher extends BaseDraggingActivity
|
|||||||
implements BgDataModel.Callbacks, DragController.DragListener {
|
implements BgDataModel.Callbacks, DragController.DragListener {
|
||||||
|
|
||||||
private LauncherModel mModel;
|
private LauncherModel mModel;
|
||||||
private BaseDragLayer mDragLayer;
|
private SecondaryDragLayer mDragLayer;
|
||||||
private SecondaryDragController mDragController;
|
private SecondaryDragController mDragController;
|
||||||
private ActivityAllAppsContainerView<SecondaryDisplayLauncher> mAppsView;
|
private ActivityAllAppsContainerView<SecondaryDisplayLauncher> mAppsView;
|
||||||
private View mAppsButton;
|
private View mAppsButton;
|
||||||
@@ -314,10 +314,6 @@ public class SecondaryDisplayLauncher extends BaseDraggingActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SecondaryDisplayPredictions getSecondaryDisplayPredictions() {
|
|
||||||
return mSecondaryDisplayPredictions;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StringCache getStringCache() {
|
public StringCache getStringCache() {
|
||||||
return mStringCache;
|
return mStringCache;
|
||||||
@@ -337,6 +333,11 @@ public class SecondaryDisplayLauncher extends BaseDraggingActivity
|
|||||||
return this::onIconClicked;
|
return this::onIconClicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View.OnLongClickListener getAllAppsItemLongClickListener() {
|
||||||
|
return v -> mDragLayer.onIconLongClicked(v);
|
||||||
|
}
|
||||||
|
|
||||||
private void onIconClicked(View v) {
|
private void onIconClicked(View v) {
|
||||||
// Make sure that rogue clicks don't get through while allapps is launching, or after the
|
// Make sure that rogue clicks don't get through while allapps is launching, or after the
|
||||||
// view has detached (it's possible for this to happen if the view is removed mid touch).
|
// view has detached (it's possible for this to happen if the view is removed mid touch).
|
||||||
|
|||||||
@@ -16,10 +16,8 @@
|
|||||||
package com.android.launcher3.secondarydisplay;
|
package com.android.launcher3.secondarydisplay;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.allapps.ActivityAllAppsContainerView;
|
|
||||||
import com.android.launcher3.model.BgDataModel;
|
import com.android.launcher3.model.BgDataModel;
|
||||||
import com.android.launcher3.util.ResourceBasedOverride;
|
import com.android.launcher3.util.ResourceBasedOverride;
|
||||||
|
|
||||||
@@ -47,12 +45,4 @@ public class SecondaryDisplayPredictions implements ResourceBasedOverride {
|
|||||||
*/
|
*/
|
||||||
public void setPredictedApps(BgDataModel.FixedContainerItems item) {
|
public void setPredictedApps(BgDataModel.FixedContainerItems item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set long click listener for predicted apps in top of app drawer.
|
|
||||||
*/
|
|
||||||
public void setLongClickListener(
|
|
||||||
ActivityAllAppsContainerView<?> appsView,
|
|
||||||
View.OnLongClickListener onIconLongClickListener) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,9 +79,6 @@ public class SecondaryDragLayer extends BaseDragLayer<SecondaryDisplayLauncher>
|
|||||||
mAllAppsButton = findViewById(R.id.all_apps_button);
|
mAllAppsButton = findViewById(R.id.all_apps_button);
|
||||||
|
|
||||||
mAppsView = findViewById(R.id.apps_view);
|
mAppsView = findViewById(R.id.apps_view);
|
||||||
mAppsView.setOnIconLongClickListener(this::onIconLongClicked);
|
|
||||||
mActivity.getSecondaryDisplayPredictions()
|
|
||||||
.setLongClickListener(mAppsView, this::onIconLongClicked);
|
|
||||||
// Setup workspace
|
// Setup workspace
|
||||||
mWorkspace = findViewById(R.id.workspace_grid);
|
mWorkspace = findViewById(R.id.workspace_grid);
|
||||||
mPinnedAppsAdapter = new PinnedAppsAdapter(mActivity, mAppsView.getAppsStore(),
|
mPinnedAppsAdapter = new PinnedAppsAdapter(mActivity, mAppsView.getAppsStore(),
|
||||||
@@ -179,7 +176,7 @@ public class SecondaryDragLayer extends BaseDragLayer<SecondaryDisplayLauncher>
|
|||||||
return mPinnedAppsAdapter;
|
return mPinnedAppsAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean onIconLongClicked(View v) {
|
boolean onIconLongClicked(View v) {
|
||||||
if (!(v instanceof BubbleTextView)) {
|
if (!(v instanceof BubbleTextView)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -239,6 +239,11 @@ public interface ActivityContext {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Long-click callback used for All Apps items. */
|
||||||
|
default View.OnLongClickListener getAllAppsItemLongClickListener() {
|
||||||
|
return v -> false;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
default PopupDataProvider getPopupDataProvider() {
|
default PopupDataProvider getPopupDataProvider() {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user