summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorim Jaggi <jjaggi@google.com>2015-06-11 00:22:46 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-06-11 00:22:49 +0000
commitae7c257031df915a10f20868f1bb1744335feffd (patch)
tree1d4625588ef564935c6eb3fce57f9cd0f825b5ee
parent1f86c1ae83557d7e03c7bd3e5222137b03216bd4 (diff)
parentfb6b19c84cf818e070489fc68affd62ca4b713ed (diff)
downloadframeworks_base-ae7c257031df915a10f20868f1bb1744335feffd.zip
frameworks_base-ae7c257031df915a10f20868f1bb1744335feffd.tar.gz
frameworks_base-ae7c257031df915a10f20868f1bb1744335feffd.tar.bz2
Merge "Disable swipe-up gesture to invoke assist" into mnc-dev
-rw-r--r--packages/SystemUI/src/com/android/systemui/assist/AssistManager.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/DelegateViewHelper.java157
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java46
3 files changed, 2 insertions, 202 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
index 3e122da..1e7ee98 100644
--- a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
+++ b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
@@ -116,7 +116,6 @@ public class AssistManager {
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
WindowManager.LayoutParams lp = getLayoutParams();
mWindowManager.addView(mView, lp);
- mBar.getNavigationBarView().setDelegateView(mView);
if (visible) {
mView.show(true /* show */, false /* animate */);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/DelegateViewHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/DelegateViewHelper.java
deleted file mode 100644
index 2dc521e..0000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/DelegateViewHelper.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.statusbar;
-
-import android.app.StatusBarManager;
-import android.content.res.Resources;
-import android.graphics.RectF;
-import android.view.MotionEvent;
-import android.view.View;
-import com.android.systemui.R;
-import com.android.systemui.statusbar.phone.PhoneStatusBar;
-
-public class DelegateViewHelper {
- private View mDelegateView;
- private View mSourceView;
- private PhoneStatusBar mBar;
- private int[] mTempPoint = new int[2];
- private float[] mDownPoint = new float[2];
- private float mTriggerThreshhold;
- private boolean mPanelShowing;
-
- RectF mInitialTouch = new RectF();
- private boolean mStarted;
- private boolean mSwapXY = false;
- private boolean mDisabled;
-
- public DelegateViewHelper(View sourceView) {
- setSourceView(sourceView);
- }
-
- public void setDelegateView(View view) {
- mDelegateView = view;
- }
-
- public void setBar(PhoneStatusBar phoneStatusBar) {
- mBar = phoneStatusBar;
- }
-
- public boolean onInterceptTouchEvent(MotionEvent event) {
- if (mSourceView == null || mDelegateView == null || mBar.shouldDisableNavbarGestures()) {
- return false;
- }
-
- mSourceView.getLocationOnScreen(mTempPoint);
- final float sourceX = mTempPoint[0];
- final float sourceY = mTempPoint[1];
-
- final int action = event.getAction();
- switch (action) {
- case MotionEvent.ACTION_DOWN:
- mPanelShowing = mDelegateView.getVisibility() == View.VISIBLE;
- mDownPoint[0] = event.getX();
- mDownPoint[1] = event.getY();
- mStarted = mInitialTouch.contains(mDownPoint[0] + sourceX, mDownPoint[1] + sourceY);
- break;
- }
-
- if (!mStarted) {
- return false;
- }
-
- if (!mDisabled && !mPanelShowing && action == MotionEvent.ACTION_MOVE) {
- final int historySize = event.getHistorySize();
- for (int k = 0; k < historySize + 1; k++) {
- float x = k < historySize ? event.getHistoricalX(k) : event.getX();
- float y = k < historySize ? event.getHistoricalY(k) : event.getY();
- final float distance = mSwapXY ? (mDownPoint[0] - x) : (mDownPoint[1] - y);
- if (distance > mTriggerThreshhold) {
- mBar.invokeAssistGesture(false /* vibrate */);
- mPanelShowing = true;
- break;
- }
- }
- }
-
- if (action == MotionEvent.ACTION_DOWN) {
- mBar.setInteracting(StatusBarManager.WINDOW_NAVIGATION_BAR, true);
- } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
- mBar.setInteracting(StatusBarManager.WINDOW_NAVIGATION_BAR, false);
- }
-
- mDelegateView.getLocationOnScreen(mTempPoint);
- final float delegateX = mTempPoint[0];
- final float delegateY = mTempPoint[1];
-
- float deltaX = sourceX - delegateX;
- float deltaY = sourceY - delegateY;
- event.offsetLocation(deltaX, deltaY);
- mDelegateView.dispatchTouchEvent(event);
- event.offsetLocation(-deltaX, -deltaY);
- return mPanelShowing;
- }
-
- public void abortCurrentGesture() {
- if (mStarted) {
- mStarted = false;
- mBar.setInteracting(StatusBarManager.WINDOW_NAVIGATION_BAR, false);
- }
- }
-
- public void setSourceView(View view) {
- mSourceView = view;
- if (mSourceView != null) {
- Resources r = mSourceView.getContext().getResources();
- mTriggerThreshhold = r.getDimensionPixelSize(R.dimen.navigation_bar_min_swipe_distance);
- }
- }
-
- /**
- * Selects the initial touch region based on a list of views. This is meant to be called by
- * a container widget on children over which the initial touch should be detected. Note this
- * will compute a minimum bound that contains all specified views.
- *
- * @param views
- */
- public void setInitialTouchRegion(View ... views) {
- RectF bounds = new RectF();
- int p[] = new int[2];
- for (int i = 0; i < views.length; i++) {
- View view = views[i];
- if (view == null) continue;
- view.getLocationOnScreen(p);
- if (i == 0) {
- bounds.set(p[0], p[1], p[0] + view.getWidth(), p[1] + view.getHeight());
- } else {
- bounds.union(p[0], p[1], p[0] + view.getWidth(), p[1] + view.getHeight());
- }
- }
- mInitialTouch.set(bounds);
- }
-
- /**
- * When rotation is set to NO_SENSOR, then this allows swapping x/y for gesture detection
- * @param swap
- */
- public void setSwapXY(boolean swap) {
- mSwapXY = swap;
- }
-
- public void setDisabled(boolean disabled) {
- mDisabled = disabled;
- }
-} \ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index 636c511..f40f501 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -47,7 +47,6 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import com.android.systemui.R;
-import com.android.systemui.statusbar.DelegateViewHelper;
import com.android.systemui.statusbar.policy.DeadZone;
import com.android.systemui.statusbar.policy.KeyButtonView;
@@ -79,7 +78,6 @@ public class NavigationBarView extends LinearLayout {
private Drawable mRecentLandIcon;
private NavigationBarViewTaskSwitchHelper mTaskSwitchHelper;
- private DelegateViewHelper mDelegateHelper;
private DeadZone mDeadZone;
private final NavigationBarTransitions mBarTransitions;
@@ -92,7 +90,6 @@ public class NavigationBarView extends LinearLayout {
private OnVerticalChangedListener mOnVerticalChangedListener;
private boolean mIsLayoutRtl;
- private boolean mDelegateIntercepted;
private class NavTransitionListener implements TransitionListener {
private boolean mBackTransitioning;
@@ -180,7 +177,6 @@ public class NavigationBarView extends LinearLayout {
mBarSize = res.getDimensionPixelSize(R.dimen.navigation_bar_size);
mVertical = false;
mShowMenu = false;
- mDelegateHelper = new DelegateViewHelper(this);
mTaskSwitchHelper = new NavigationBarViewTaskSwitchHelper(context);
getIcons(res);
@@ -192,13 +188,8 @@ public class NavigationBarView extends LinearLayout {
return mBarTransitions;
}
- public void setDelegateView(View view) {
- mDelegateHelper.setDelegateView(view);
- }
-
public void setBar(PhoneStatusBar phoneStatusBar) {
mTaskSwitchHelper.setBar(phoneStatusBar);
- mDelegateHelper.setBar(phoneStatusBar);
}
public void setOnVerticalChangedListener(OnVerticalChangedListener onVerticalChangedListener) {
@@ -208,44 +199,21 @@ public class NavigationBarView extends LinearLayout {
@Override
public boolean onTouchEvent(MotionEvent event) {
- initDownStates(event);
- if (!mDelegateIntercepted && mTaskSwitchHelper.onTouchEvent(event)) {
+ if (mTaskSwitchHelper.onTouchEvent(event)) {
return true;
}
if (mDeadZone != null && event.getAction() == MotionEvent.ACTION_OUTSIDE) {
mDeadZone.poke(event);
}
- if (mDelegateHelper != null && mDelegateIntercepted) {
- boolean ret = mDelegateHelper.onInterceptTouchEvent(event);
- if (ret) return true;
- }
return super.onTouchEvent(event);
}
- private void initDownStates(MotionEvent ev) {
- if (ev.getAction() == MotionEvent.ACTION_DOWN) {
- mDelegateIntercepted = false;
- }
- }
-
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
- initDownStates(event);
- boolean intercept = mTaskSwitchHelper.onInterceptTouchEvent(event);
- if (!intercept) {
- mDelegateIntercepted = mDelegateHelper.onInterceptTouchEvent(event);
- intercept = mDelegateIntercepted;
- } else {
- MotionEvent cancelEvent = MotionEvent.obtain(event);
- cancelEvent.setAction(MotionEvent.ACTION_CANCEL);
- mDelegateHelper.onInterceptTouchEvent(cancelEvent);
- cancelEvent.recycle();
- }
- return intercept;
+ return mTaskSwitchHelper.onInterceptTouchEvent(event);
}
public void abortCurrentGesture() {
- mDelegateHelper.abortCurrentGesture();
getHomeButton().abortCurrentGesture();
}
@@ -461,10 +429,6 @@ public class NavigationBarView extends LinearLayout {
Log.d(TAG, "reorient(): rot=" + mDisplay.getRotation());
}
- // swap to x coordinate if orientation is not in vertical
- if (mDelegateHelper != null) {
- mDelegateHelper.setSwapXY(mVertical);
- }
updateTaskSwitchHelper();
setNavigationIconHints(mNavigationIconHints, true);
@@ -476,12 +440,6 @@ public class NavigationBarView extends LinearLayout {
}
@Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {
- super.onLayout(changed, l, t, r, b);
- mDelegateHelper.setInitialTouchRegion(getHomeButton(), getBackButton(), getRecentsButton());
- }
-
- @Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
if (DEBUG) Log.d(TAG, String.format(
"onSizeChanged: (%dx%d) old: (%dx%d)", w, h, oldw, oldh));