am ae7c2570: Merge "Disable swipe-up gesture to invoke assist" into mnc-dev
* commit 'ae7c257031df915a10f20868f1bb1744335feffd': Disable swipe-up gesture to invoke assist
This commit is contained in:
@@ -116,7 +116,6 @@ public class AssistManager {
|
|||||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
|
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
|
||||||
WindowManager.LayoutParams lp = getLayoutParams();
|
WindowManager.LayoutParams lp = getLayoutParams();
|
||||||
mWindowManager.addView(mView, lp);
|
mWindowManager.addView(mView, lp);
|
||||||
mBar.getNavigationBarView().setDelegateView(mView);
|
|
||||||
if (visible) {
|
if (visible) {
|
||||||
mView.show(true /* show */, false /* animate */);
|
mView.show(true /* show */, false /* animate */);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -47,7 +47,6 @@ import android.widget.ImageView;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.statusbar.DelegateViewHelper;
|
|
||||||
import com.android.systemui.statusbar.policy.DeadZone;
|
import com.android.systemui.statusbar.policy.DeadZone;
|
||||||
import com.android.systemui.statusbar.policy.KeyButtonView;
|
import com.android.systemui.statusbar.policy.KeyButtonView;
|
||||||
|
|
||||||
@@ -79,7 +78,6 @@ public class NavigationBarView extends LinearLayout {
|
|||||||
private Drawable mRecentLandIcon;
|
private Drawable mRecentLandIcon;
|
||||||
|
|
||||||
private NavigationBarViewTaskSwitchHelper mTaskSwitchHelper;
|
private NavigationBarViewTaskSwitchHelper mTaskSwitchHelper;
|
||||||
private DelegateViewHelper mDelegateHelper;
|
|
||||||
private DeadZone mDeadZone;
|
private DeadZone mDeadZone;
|
||||||
private final NavigationBarTransitions mBarTransitions;
|
private final NavigationBarTransitions mBarTransitions;
|
||||||
|
|
||||||
@@ -92,7 +90,6 @@ public class NavigationBarView extends LinearLayout {
|
|||||||
|
|
||||||
private OnVerticalChangedListener mOnVerticalChangedListener;
|
private OnVerticalChangedListener mOnVerticalChangedListener;
|
||||||
private boolean mIsLayoutRtl;
|
private boolean mIsLayoutRtl;
|
||||||
private boolean mDelegateIntercepted;
|
|
||||||
|
|
||||||
private class NavTransitionListener implements TransitionListener {
|
private class NavTransitionListener implements TransitionListener {
|
||||||
private boolean mBackTransitioning;
|
private boolean mBackTransitioning;
|
||||||
@@ -180,7 +177,6 @@ public class NavigationBarView extends LinearLayout {
|
|||||||
mBarSize = res.getDimensionPixelSize(R.dimen.navigation_bar_size);
|
mBarSize = res.getDimensionPixelSize(R.dimen.navigation_bar_size);
|
||||||
mVertical = false;
|
mVertical = false;
|
||||||
mShowMenu = false;
|
mShowMenu = false;
|
||||||
mDelegateHelper = new DelegateViewHelper(this);
|
|
||||||
mTaskSwitchHelper = new NavigationBarViewTaskSwitchHelper(context);
|
mTaskSwitchHelper = new NavigationBarViewTaskSwitchHelper(context);
|
||||||
|
|
||||||
getIcons(res);
|
getIcons(res);
|
||||||
@@ -192,13 +188,8 @@ public class NavigationBarView extends LinearLayout {
|
|||||||
return mBarTransitions;
|
return mBarTransitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDelegateView(View view) {
|
|
||||||
mDelegateHelper.setDelegateView(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBar(PhoneStatusBar phoneStatusBar) {
|
public void setBar(PhoneStatusBar phoneStatusBar) {
|
||||||
mTaskSwitchHelper.setBar(phoneStatusBar);
|
mTaskSwitchHelper.setBar(phoneStatusBar);
|
||||||
mDelegateHelper.setBar(phoneStatusBar);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOnVerticalChangedListener(OnVerticalChangedListener onVerticalChangedListener) {
|
public void setOnVerticalChangedListener(OnVerticalChangedListener onVerticalChangedListener) {
|
||||||
@@ -208,44 +199,21 @@ public class NavigationBarView extends LinearLayout {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
initDownStates(event);
|
if (mTaskSwitchHelper.onTouchEvent(event)) {
|
||||||
if (!mDelegateIntercepted && mTaskSwitchHelper.onTouchEvent(event)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (mDeadZone != null && event.getAction() == MotionEvent.ACTION_OUTSIDE) {
|
if (mDeadZone != null && event.getAction() == MotionEvent.ACTION_OUTSIDE) {
|
||||||
mDeadZone.poke(event);
|
mDeadZone.poke(event);
|
||||||
}
|
}
|
||||||
if (mDelegateHelper != null && mDelegateIntercepted) {
|
|
||||||
boolean ret = mDelegateHelper.onInterceptTouchEvent(event);
|
|
||||||
if (ret) return true;
|
|
||||||
}
|
|
||||||
return super.onTouchEvent(event);
|
return super.onTouchEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initDownStates(MotionEvent ev) {
|
|
||||||
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
|
||||||
mDelegateIntercepted = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onInterceptTouchEvent(MotionEvent event) {
|
public boolean onInterceptTouchEvent(MotionEvent event) {
|
||||||
initDownStates(event);
|
return mTaskSwitchHelper.onInterceptTouchEvent(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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void abortCurrentGesture() {
|
public void abortCurrentGesture() {
|
||||||
mDelegateHelper.abortCurrentGesture();
|
|
||||||
getHomeButton().abortCurrentGesture();
|
getHomeButton().abortCurrentGesture();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,10 +429,6 @@ public class NavigationBarView extends LinearLayout {
|
|||||||
Log.d(TAG, "reorient(): rot=" + mDisplay.getRotation());
|
Log.d(TAG, "reorient(): rot=" + mDisplay.getRotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
// swap to x coordinate if orientation is not in vertical
|
|
||||||
if (mDelegateHelper != null) {
|
|
||||||
mDelegateHelper.setSwapXY(mVertical);
|
|
||||||
}
|
|
||||||
updateTaskSwitchHelper();
|
updateTaskSwitchHelper();
|
||||||
|
|
||||||
setNavigationIconHints(mNavigationIconHints, true);
|
setNavigationIconHints(mNavigationIconHints, true);
|
||||||
@@ -475,12 +439,6 @@ public class NavigationBarView extends LinearLayout {
|
|||||||
mTaskSwitchHelper.setBarState(mVertical, isRtl);
|
mTaskSwitchHelper.setBarState(mVertical, isRtl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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
|
@Override
|
||||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||||
if (DEBUG) Log.d(TAG, String.format(
|
if (DEBUG) Log.d(TAG, String.format(
|
||||||
|
|||||||
Reference in New Issue
Block a user