diff options
author | Mario Bertschler <bmario@google.com> | 2017-01-04 16:31:57 -0800 |
---|---|---|
committer | Mario Bertschler <bmario@google.com> | 2017-01-09 14:42:52 -0800 |
commit | cd0f67903015a9dcea098e5fdcf65040ffdbf66f (patch) | |
tree | b799a18c8a9a9109521e4a87e62abcbeadd569fb /src/com | |
parent | 2c3194e87977c06a72e54e63745f790d619e77ed (diff) | |
download | android_packages_apps_Trebuchet-cd0f67903015a9dcea098e5fdcf65040ffdbf66f.tar.gz android_packages_apps_Trebuchet-cd0f67903015a9dcea098e5fdcf65040ffdbf66f.tar.bz2 android_packages_apps_Trebuchet-cd0f67903015a9dcea098e5fdcf65040ffdbf66f.zip |
This enables to slide up All Apps from anywhere in the workspace,
not only over the hotseat.
The tricky part handling with scrollable widgets is solved by
setting requestDisallowInterceptTouchEvent from within the
widget view host (and resetting it upon performing long click).
Change-Id: I8b60e7ea2c1e8ae830b4737e94ed2d796265fa24
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/launcher3/LauncherAppWidgetHostView.java | 53 | ||||
-rw-r--r-- | src/com/android/launcher3/allapps/AllAppsTransitionController.java | 28 |
2 files changed, 47 insertions, 34 deletions
diff --git a/src/com/android/launcher3/LauncherAppWidgetHostView.java b/src/com/android/launcher3/LauncherAppWidgetHostView.java index 49bbfd097..1429df5d3 100644 --- a/src/com/android/launcher3/LauncherAppWidgetHostView.java +++ b/src/com/android/launcher3/LauncherAppWidgetHostView.java @@ -33,9 +33,11 @@ import android.view.ViewConfiguration; import android.view.ViewDebug; import android.view.ViewGroup; import android.view.accessibility.AccessibilityNodeInfo; +import android.widget.AdapterView; import android.widget.Advanceable; import android.widget.RemoteViews; +import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.dragndrop.DragLayer.TouchCompleteListener; import java.lang.reflect.Method; @@ -45,7 +47,8 @@ import java.util.concurrent.Executor; /** * {@inheritDoc} */ -public class LauncherAppWidgetHostView extends AppWidgetHostView implements TouchCompleteListener { +public class LauncherAppWidgetHostView extends AppWidgetHostView + implements TouchCompleteListener, View.OnLongClickListener { private static final String TAG = "LauncherWidgetHostView"; @@ -56,11 +59,12 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView implements Touc // Maintains a list of widget ids which are supposed to be auto advanced. private static final SparseBooleanArray sAutoAdvanceWidgetIds = new SparseBooleanArray(); - LayoutInflater mInflater; + protected final LayoutInflater mInflater; + + private final CheckLongPressHelper mLongPressHelper; + private final StylusEventHelper mStylusEventHelper; + private final Context mContext; - private CheckLongPressHelper mLongPressHelper; - private StylusEventHelper mStylusEventHelper; - private Context mContext; @ViewDebug.ExportedProperty(category = "launcher") private int mPreviousOrientation; @@ -69,6 +73,7 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView implements Touc @ViewDebug.ExportedProperty(category = "launcher") private boolean mChildrenFocused; + private boolean mIsScrollable; private boolean mIsAttachedToWindow; private boolean mIsAutoAdvanceRegistered; private Runnable mAutoAdvanceRunnable; @@ -86,7 +91,7 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView implements Touc public LauncherAppWidgetHostView(Context context) { super(context); mContext = context; - mLongPressHelper = new CheckLongPressHelper(this); + mLongPressHelper = new CheckLongPressHelper(this, this); mStylusEventHelper = new StylusEventHelper(new SimpleOnStylusPressListener(this), this); mInflater = LayoutInflater.from(context); setAccessibilityDelegate(Launcher.getLauncher(context).getAccessibilityDelegate()); @@ -104,6 +109,16 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView implements Touc } @Override + public boolean onLongClick(View view) { + if (mIsScrollable) { + DragLayer dragLayer = Launcher.getLauncher(getContext()).getDragLayer(); + dragLayer.requestDisallowInterceptTouchEvent(false); + } + view.performLongClick(); + return true; + } + + @Override protected View getErrorView() { return mInflater.inflate(R.layout.appwidget_error, this, false); } @@ -120,6 +135,24 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView implements Touc // The provider info or the views might have changed. checkIfAutoAdvance(); + + mIsScrollable = checkScrollableRecursively(this); + } + + private boolean checkScrollableRecursively(ViewGroup viewGroup) { + if (viewGroup instanceof AdapterView) { + return true; + } else { + for (int i=0; i < viewGroup.getChildCount(); i++) { + View child = viewGroup.getChildAt(i); + if (child instanceof ViewGroup) { + if (checkScrollableRecursively((ViewGroup) child)) { + return true; + } + } + } + } + return false; } public boolean isReinflateRequired() { @@ -150,12 +183,18 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView implements Touc mLongPressHelper.cancelLongPress(); return true; } + switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: { + DragLayer dragLayer = Launcher.getLauncher(getContext()).getDragLayer(); + + if (mIsScrollable) { + dragLayer.requestDisallowInterceptTouchEvent(true); + } if (!mStylusEventHelper.inStylusButtonPressed()) { mLongPressHelper.postCheckForLongPress(); } - Launcher.getLauncher(getContext()).getDragLayer().setTouchCompleteListener(this); + dragLayer.setTouchCompleteListener(this); break; } diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index c199fef09..547ab2b34 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -18,15 +18,12 @@ import android.view.animation.DecelerateInterpolator; import android.view.animation.Interpolator; import com.android.launcher3.AbstractFloatingView; -import com.android.launcher3.DeviceProfile; import com.android.launcher3.Hotseat; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAnimUtils; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.Workspace; -import com.android.launcher3.shortcuts.DeepShortcutsContainer; -import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto.Action; import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.util.TouchController; @@ -88,7 +85,6 @@ public class AllAppsTransitionController implements TouchController, VerticalPul private static final float RECATCH_REJECTION_FRACTION = .0875f; - private int mBezelSwipeUpHeight; private long mAnimationDuration; private AnimatorSet mCurrentAnimation; @@ -104,8 +100,6 @@ public class AllAppsTransitionController implements TouchController, VerticalPul mDetector.setListener(this); mShiftRange = DEFAULT_SHIFT_RANGE; mProgress = 1f; - mBezelSwipeUpHeight = l.getResources().getDimensionPixelSize( - R.dimen.all_apps_bezel_swipe_height); mEvaluator = new ArgbEvaluator(); mAllAppsBackgroundColor = ContextCompat.getColor(l, R.color.all_apps_container_color); @@ -120,8 +114,6 @@ public class AllAppsTransitionController implements TouchController, VerticalPul } else if (mLauncher.isAllAppsVisible() && !mAppsView.shouldContainerScroll(ev)) { mNoIntercept = true; - } else if (!mLauncher.isAllAppsVisible() && !shouldPossiblyIntercept(ev)) { - mNoIntercept = true; } else if (AbstractFloatingView.getTopOpenView(mLauncher) != null) { mNoIntercept = true; } else { @@ -150,6 +142,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul ignoreSlopWhenSettling); } } + if (mNoIntercept) { return false; } @@ -160,25 +153,6 @@ public class AllAppsTransitionController implements TouchController, VerticalPul return mDetector.isDraggingOrSettling(); } - private boolean shouldPossiblyIntercept(MotionEvent ev) { - DeviceProfile grid = mLauncher.getDeviceProfile(); - if (mDetector.isIdleState()) { - if (grid.isVerticalBarLayout()) { - if (ev.getY() > mLauncher.getDeviceProfile().heightPx - mBezelSwipeUpHeight) { - return true; - } - } else { - if (mLauncher.getDragLayer().isEventOverHotseat(ev) || - mLauncher.getDragLayer().isEventOverPageIndicator(ev)) { - return true; - } - } - return false; - } else { - return true; - } - } - @Override public boolean onControllerTouchEvent(MotionEvent ev) { return mDetector.onTouchEvent(ev); |