Ensure that we use the system long press duration when dragging from AllApps.
- Removing some old code out of LauncherAppState
Bug: 21559400
Change-Id: I3c586094efb7ad8a17d2169bc8aaccf6b0df40a2
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index f4e306a..6a13f3d 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -184,6 +184,12 @@
verifyHighRes();
}
+ /**
+ * Overrides the default long press timeout.
+ */
+ public void setLongPressTimeout(int longPressTimeout) {
+ mLongPressHelper.setLongPressTimeout(longPressTimeout);
+ }
@Override
protected boolean setFrame(int left, int top, int right, int bottom) {
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index 09a71b0..b7f89d0 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -51,7 +51,6 @@
protected Launcher mLauncher;
private int mBottomDragPadding;
- protected TextView mText;
protected SearchDropTargetBar mSearchDropTargetBar;
/** Whether this drop target is active for the current drag */
@@ -82,11 +81,9 @@
mOriginalTextColor = getTextColors();
// Remove the text in the Phone UI in landscape
- int orientation = getResources().getConfiguration().orientation;
- if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
- if (!LauncherAppState.getInstance().isScreenLarge()) {
- setText("");
- }
+ DeviceProfile grid = ((Launcher) getContext()).getDeviceProfile();
+ if (grid.isVerticalBarLayout()) {
+ setText("");
}
}
diff --git a/src/com/android/launcher3/CheckLongPressHelper.java b/src/com/android/launcher3/CheckLongPressHelper.java
index 381b678..483c622 100644
--- a/src/com/android/launcher3/CheckLongPressHelper.java
+++ b/src/com/android/launcher3/CheckLongPressHelper.java
@@ -21,9 +21,11 @@
import com.android.launcher3.util.Thunk;
public class CheckLongPressHelper {
+
@Thunk View mView;
@Thunk View.OnLongClickListener mListener;
@Thunk boolean mHasPerformedLongPress;
+ private int mLongPressTimeout = 300;
private CheckForLongPress mPendingCheckForLongPress;
class CheckForLongPress implements Runnable {
@@ -53,14 +55,20 @@
mListener = listener;
}
+ /**
+ * Overrides the default long press timeout.
+ */
+ public void setLongPressTimeout(int longPressTimeout) {
+ mLongPressTimeout = longPressTimeout;
+ }
+
public void postCheckForLongPress() {
mHasPerformedLongPress = false;
if (mPendingCheckForLongPress == null) {
mPendingCheckForLongPress = new CheckForLongPress();
}
- mView.postDelayed(mPendingCheckForLongPress,
- LauncherAppState.getInstance().getLongPressTimeout());
+ mView.postDelayed(mPendingCheckForLongPress, mLongPressTimeout);
}
public void cancelLongPress() {
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java
index afa09ec..81d595a 100644
--- a/src/com/android/launcher3/LauncherAppState.java
+++ b/src/com/android/launcher3/LauncherAppState.java
@@ -25,6 +25,7 @@
import android.content.res.Resources;
import android.util.Log;
+import android.view.ViewConfiguration;
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.PackageInstallerCompat;
@@ -40,9 +41,6 @@
private final IconCache mIconCache;
private final WidgetPreviewLoader mWidgetCache;
- private final boolean mIsScreenLarge;
- private final int mLongPressTimeout = 300;
-
private boolean mWallpaperChangedSinceLastCheck;
private static WeakReference<LauncherProvider> sLauncherProvider;
@@ -86,8 +84,6 @@
MemoryTracker.startTrackingMe(sContext, "L");
}
- // set sIsScreenXLarge and mScreenDensity *before* creating icon cache
- mIsScreenLarge = isScreenLarge(sContext.getResources());
mInvariantDeviceProfile = new InvariantDeviceProfile(sContext);
mIconCache = new IconCache(sContext, mInvariantDeviceProfile);
mWidgetCache = new WidgetPreviewLoader(sContext, mInvariantDeviceProfile, mIconCache);
@@ -149,6 +145,9 @@
return mModel;
}
+ /**
+ * TODO(winsonc, hyunyoungs): We need to respect this
+ */
boolean shouldShowAppOrWidgetProvider(ComponentName componentName) {
return mAppFilter == null || mAppFilter.shouldShowApp(componentName);
}
@@ -168,20 +167,7 @@
public WidgetPreviewLoader getWidgetCache() {
return mWidgetCache;
}
-
- public boolean isScreenLarge() {
- return mIsScreenLarge;
- }
-
- // Need a version that doesn't require an instance of LauncherAppState for the wallpaper picker
- public static boolean isScreenLarge(Resources res) {
- return res.getBoolean(R.bool.is_large_tablet);
- }
-
- public int getLongPressTimeout() {
- return mLongPressTimeout;
- }
-
+
public void onWallpaperChanged() {
mWallpaperChangedSinceLastCheck = true;
}
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 9386500..09f6a2c 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -432,6 +432,7 @@
icon = (BubbleTextView) mLayoutInflater.inflate(
R.layout.all_apps_prediction_bar_icon, mPredictionBarView, false);
icon.setFocusable(true);
+ icon.setLongPressTimeout(ViewConfiguration.get(getContext()).getLongPressTimeout());
mPredictionBarView.addView(icon);
}
diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
index 307d940..02a950f 100644
--- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
+++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
@@ -27,6 +27,7 @@
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.widget.TextView;
import com.android.launcher3.AppInfo;
@@ -418,6 +419,8 @@
icon.setOnTouchListener(mTouchListener);
icon.setOnClickListener(mIconClickListener);
icon.setOnLongClickListener(mIconLongClickListener);
+ icon.setLongPressTimeout(ViewConfiguration.get(parent.getContext())
+ .getLongPressTimeout());
icon.setFocusable(true);
return new ViewHolder(icon);
default: