Merge "Change long press timeout to use a factor of ViewConfiguration.getLongPressTimeout()" into ub-launcher3-master

This commit is contained in:
Tony Wickham
2018-09-26 00:01:12 +00:00
committed by Android (Google) Code Review
3 changed files with 10 additions and 9 deletions

View File

@@ -272,8 +272,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
/**
* Overrides the default long press timeout.
*/
public void setLongPressTimeout(int longPressTimeout) {
mLongPressHelper.setLongPressTimeout(longPressTimeout);
public void setLongPressTimeoutFactor(float longPressTimeoutFactor) {
mLongPressHelper.setLongPressTimeoutFactor(longPressTimeoutFactor);
}
@Override

View File

@@ -17,17 +17,18 @@
package com.android.launcher3;
import android.view.View;
import android.view.ViewConfiguration;
import com.android.launcher3.util.Thunk;
public class CheckLongPressHelper {
public static final int DEFAULT_LONG_PRESS_TIMEOUT = 300;
public static final float DEFAULT_LONG_PRESS_TIMEOUT_FACTOR = 0.75f;
@Thunk View mView;
@Thunk View.OnLongClickListener mListener;
@Thunk boolean mHasPerformedLongPress;
private int mLongPressTimeout = DEFAULT_LONG_PRESS_TIMEOUT;
private float mLongPressTimeoutFactor = DEFAULT_LONG_PRESS_TIMEOUT_FACTOR;
private CheckForLongPress mPendingCheckForLongPress;
class CheckForLongPress implements Runnable {
@@ -60,8 +61,8 @@ public class CheckLongPressHelper {
/**
* Overrides the default long press timeout.
*/
public void setLongPressTimeout(int longPressTimeout) {
mLongPressTimeout = longPressTimeout;
public void setLongPressTimeoutFactor(float longPressTimeoutFactor) {
mLongPressTimeoutFactor = longPressTimeoutFactor;
}
public void postCheckForLongPress() {
@@ -70,7 +71,8 @@ public class CheckLongPressHelper {
if (mPendingCheckForLongPress == null) {
mPendingCheckForLongPress = new CheckForLongPress();
}
mView.postDelayed(mPendingCheckForLongPress, mLongPressTimeout);
mView.postDelayed(mPendingCheckForLongPress,
(long) (ViewConfiguration.getLongPressTimeout() * mLongPressTimeoutFactor));
}
public void cancelLongPress() {

View File

@@ -22,7 +22,6 @@ import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnFocusChangeListener;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.widget.TextView;
@@ -252,7 +251,7 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
R.layout.all_apps_icon, parent, false);
icon.setOnClickListener(ItemClickHandler.INSTANCE);
icon.setOnLongClickListener(ItemLongClickListener.INSTANCE_ALL_APPS);
icon.setLongPressTimeout(ViewConfiguration.getLongPressTimeout());
icon.setLongPressTimeoutFactor(1f);
icon.setOnFocusChangeListener(mIconFocusListener);
// Ensure the all apps icon height matches the workspace icons in portrait mode.