diff options
| author | 2018-04-03 19:09:22 +0000 | |
|---|---|---|
| committer | 2018-04-03 19:09:22 +0000 | |
| commit | 47721fa59d798b8da4460a43e78d24eb8f091388 (patch) | |
| tree | 7403d4b9d456c4469be9c73fbd72f29ff519c06b | |
| parent | 7793bcd867e87e23f87b02e3dd8fc224150385fc (diff) | |
| parent | 603b3298ffa73714e2af955ce916b044f234d8b6 (diff) | |
Merge "Avoids vibration over deadzone in navigationbar" into pi-dev
9 files changed, 57 insertions, 84 deletions
diff --git a/packages/SystemUI/res/layout-sw600dp/navigation_layout_rot90.xml b/packages/SystemUI/res/layout-sw600dp/navigation_layout_rot90.xml index 6f153c1086a1..78304fd894dd 100644 --- a/packages/SystemUI/res/layout-sw600dp/navigation_layout_rot90.xml +++ b/packages/SystemUI/res/layout-sw600dp/navigation_layout_rot90.xml @@ -41,16 +41,4 @@ </FrameLayout> - <com.android.systemui.statusbar.policy.DeadZone - android:id="@+id/deadzone" - android:layout_height="match_parent" - android:layout_width="match_parent" - android:layout_gravity="top" - systemui:minSize="@dimen/navigation_bar_deadzone_size" - systemui:maxSize="@dimen/navigation_bar_deadzone_size_max" - systemui:holdTime="@integer/navigation_bar_deadzone_hold" - systemui:decayTime="@integer/navigation_bar_deadzone_decay" - systemui:orientation="horizontal" - /> - </FrameLayout> diff --git a/packages/SystemUI/res/layout/navigation_layout.xml b/packages/SystemUI/res/layout/navigation_layout.xml index 3e6079451c74..953abc7148a8 100644 --- a/packages/SystemUI/res/layout/navigation_layout.xml +++ b/packages/SystemUI/res/layout/navigation_layout.xml @@ -46,16 +46,4 @@ </com.android.systemui.statusbar.phone.NearestTouchFrame> - <com.android.systemui.statusbar.policy.DeadZone - android:id="@+id/deadzone" - android:layout_height="match_parent" - android:layout_width="match_parent" - android:layout_gravity="top" - systemui:minSize="@dimen/navigation_bar_deadzone_size" - systemui:maxSize="@dimen/navigation_bar_deadzone_size_max" - systemui:holdTime="@integer/navigation_bar_deadzone_hold" - systemui:decayTime="@integer/navigation_bar_deadzone_decay" - systemui:orientation="horizontal" - /> - </FrameLayout> diff --git a/packages/SystemUI/res/layout/navigation_layout_rot90.xml b/packages/SystemUI/res/layout/navigation_layout_rot90.xml index 39cdff47c5ac..0e17e5b57cae 100644 --- a/packages/SystemUI/res/layout/navigation_layout_rot90.xml +++ b/packages/SystemUI/res/layout/navigation_layout_rot90.xml @@ -46,16 +46,4 @@ </com.android.systemui.statusbar.phone.NearestTouchFrame> - <com.android.systemui.statusbar.policy.DeadZone - android:id="@+id/deadzone" - android:layout_height="match_parent" - android:layout_width="match_parent" - android:layout_gravity="top" - systemui:minSize="@dimen/navigation_bar_deadzone_size" - systemui:maxSize="@dimen/navigation_bar_deadzone_size_max" - systemui:holdTime="@integer/navigation_bar_deadzone_hold" - systemui:decayTime="@integer/navigation_bar_deadzone_decay" - systemui:orientation="vertical" - /> - </FrameLayout> diff --git a/packages/SystemUI/res/values-land/config.xml b/packages/SystemUI/res/values-land/config.xml index f7e23449fa0a..63bbe62a6520 100644 --- a/packages/SystemUI/res/values-land/config.xml +++ b/packages/SystemUI/res/values-land/config.xml @@ -28,4 +28,7 @@ <!-- We have only space for one notification on phone landscape layouts. --> <integer name="keyguard_max_notification_count">1</integer> + + <!-- orientation of the dead zone when touches have recently occurred elsewhere on screen --> + <integer name="navigation_bar_deadzone_orientation">1</integer> </resources> diff --git a/packages/SystemUI/res/values-sw600dp/config.xml b/packages/SystemUI/res/values-sw600dp/config.xml index 67dabdb7353d..f91af03f5889 100644 --- a/packages/SystemUI/res/values-sw600dp/config.xml +++ b/packages/SystemUI/res/values-sw600dp/config.xml @@ -35,4 +35,7 @@ <!-- Animation duration when using long press on recents to dock --> <integer name="long_press_dock_anim_duration">290</integer> + <!-- orientation of the dead zone when touches have recently occurred elsewhere on screen --> + <integer name="navigation_bar_deadzone_orientation">0</integer> + </resources> diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml index 711d550e89c6..f49d3de4a6a4 100644 --- a/packages/SystemUI/res/values/config.xml +++ b/packages/SystemUI/res/values/config.xml @@ -93,6 +93,9 @@ <integer name="navigation_bar_deadzone_hold">333</integer> <integer name="navigation_bar_deadzone_decay">333</integer> + <!-- orientation of the dead zone when touches have recently occurred elsewhere on screen --> + <integer name="navigation_bar_deadzone_orientation">0</integer> + <bool name="config_dead_zone_flash">false</bool> <!-- Whether to enable dimming navigation buttons when wallpaper is not visible, should be 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 54dec42aa48c..4c4eb60e4412 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java @@ -124,7 +124,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav private TintedKeyButtonDrawable mRotateSuggestionIcon; private GestureHelper mGestureHelper; - private DeadZone mDeadZone; + private final DeadZone mDeadZone; private final NavigationBarTransitions mBarTransitions; private final OverviewProxyService mOverviewProxyService; @@ -263,6 +263,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav new ButtonDispatcher(R.id.accessibility_button)); mButtonDispatchers.put(R.id.rotate_suggestion, new ButtonDispatcher(R.id.rotate_suggestion)); + mDeadZone = new DeadZone(this); } public BarTransitions getBarTransitions() { @@ -297,6 +298,10 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav @Override public boolean onInterceptTouchEvent(MotionEvent event) { + if (mDeadZone.onTouchEvent(event)) { + // Consumed the touch event + return true; + } switch (event.getActionMasked()) { case ACTION_DOWN: int x = (int) event.getX(); @@ -319,6 +324,10 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav @Override public boolean onTouchEvent(MotionEvent event) { + if (mDeadZone.onTouchEvent(event)) { + // Consumed the touch event + return true; + } if (mGestureHelper.onTouchEvent(event)) { return true; } @@ -818,6 +827,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav @Override protected void onDraw(Canvas canvas) { mGestureHelper.onDraw(canvas); + mDeadZone.onDraw(canvas); super.onDraw(canvas); } @@ -889,10 +899,8 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav public void reorient() { updateCurrentView(); - mDeadZone = (DeadZone) mCurrentView.findViewById(R.id.deadzone); - ((NavigationBarFrame) getRootView()).setDeadZone(mDeadZone); - mDeadZone.setDisplayRotation(mCurrentRotation); + mDeadZone.onConfigurationChanged(mCurrentRotation); // force the low profile & disabled states into compliance mBarTransitions.init(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStepController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStepController.java index 77a317f5aec4..af778045456b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStepController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStepController.java @@ -199,7 +199,7 @@ public class QuickStepController implements GestureHelper { break; } case MotionEvent.ACTION_MOVE: { - if (mQuickStepStarted || !mAllowGestureDetection){ + if (mQuickStepStarted || !mAllowGestureDetection || mHomeButtonView == null){ break; } int x = (int) event.getX(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeadZone.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeadZone.java index 06040e2b0bcc..4a1175489c5e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeadZone.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeadZone.java @@ -17,18 +17,16 @@ package com.android.systemui.statusbar.policy; import android.animation.ObjectAnimator; -import android.content.Context; -import android.content.res.TypedArray; +import android.content.res.Resources; import android.graphics.Canvas; import android.os.SystemClock; -import android.util.AttributeSet; import android.util.Slog; import android.view.MotionEvent; import android.view.Surface; -import android.view.View; import com.android.systemui.R; import com.android.systemui.SysUiServiceProvider; +import com.android.systemui.statusbar.phone.NavigationBarView; import com.android.systemui.statusbar.phone.StatusBar; /** @@ -38,7 +36,7 @@ import com.android.systemui.statusbar.phone.StatusBar; * outside the navigation bar (since this is when accidental taps are more likely), then contracts * back over time (since a later tap might be intended for the top of the bar). */ -public class DeadZone extends View { +public class DeadZone { public static final String TAG = "DeadZone"; public static final boolean DEBUG = false; @@ -47,6 +45,7 @@ public class DeadZone extends View { private static final boolean CHATTY = true; // print to logcat when we eat a click private final StatusBar mStatusBar; + private final NavigationBarView mNavigationBarView; private boolean mShouldFlash; private float mFlashFrac = 0f; @@ -67,31 +66,11 @@ public class DeadZone extends View { } }; - public DeadZone(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - public DeadZone(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs); - - TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DeadZone, - defStyle, 0); - - mHold = a.getInteger(R.styleable.DeadZone_holdTime, 0); - mDecay = a.getInteger(R.styleable.DeadZone_decayTime, 0); - - mSizeMin = a.getDimensionPixelSize(R.styleable.DeadZone_minSize, 0); - mSizeMax = a.getDimensionPixelSize(R.styleable.DeadZone_maxSize, 0); - - int index = a.getInt(R.styleable.DeadZone_orientation, -1); - mVertical = (index == VERTICAL); - - if (DEBUG) - Slog.v(TAG, this + " size=[" + mSizeMin + "-" + mSizeMax + "] hold=" + mHold - + (mVertical ? " vertical" : " horizontal")); - - setFlashOnTouchCapture(context.getResources().getBoolean(R.bool.config_dead_zone_flash)); - mStatusBar = SysUiServiceProvider.getComponent(context, StatusBar.class); + public DeadZone(NavigationBarView view) { + mNavigationBarView = view; + mStatusBar = SysUiServiceProvider.getComponent(mNavigationBarView.getContext(), + StatusBar.class); + onConfigurationChanged(HORIZONTAL); } static float lerp(float a, float b, float f) { @@ -112,11 +91,29 @@ public class DeadZone extends View { public void setFlashOnTouchCapture(boolean dbg) { mShouldFlash = dbg; mFlashFrac = 0f; - postInvalidate(); + mNavigationBarView.postInvalidate(); + } + + public void onConfigurationChanged(int rotation) { + mDisplayRotation = rotation; + + final Resources res = mNavigationBarView.getResources(); + mHold = res.getInteger(R.integer.navigation_bar_deadzone_hold); + mDecay = res.getInteger(R.integer.navigation_bar_deadzone_decay); + + mSizeMin = res.getDimensionPixelSize(R.dimen.navigation_bar_deadzone_size); + mSizeMax = res.getDimensionPixelSize(R.dimen.navigation_bar_deadzone_size_max); + int index = res.getInteger(R.integer.navigation_bar_deadzone_orientation); + mVertical = (index == VERTICAL); + + if (DEBUG) { + Slog.v(TAG, this + " size=[" + mSizeMin + "-" + mSizeMax + "] hold=" + mHold + + (mVertical ? " vertical" : " horizontal")); + } + setFlashOnTouchCapture(res.getBoolean(R.bool.config_dead_zone_flash)); } // I made you a touch event... - @Override public boolean onTouchEvent(MotionEvent event) { if (DEBUG) { Slog.v(TAG, this + " onTouch: " + MotionEvent.actionToString(event.getAction())); @@ -143,7 +140,7 @@ public class DeadZone extends View { final boolean consumeEvent; if (mVertical) { if (mDisplayRotation == Surface.ROTATION_270) { - consumeEvent = event.getX() > getWidth() - size; + consumeEvent = event.getX() > mNavigationBarView.getWidth() - size; } else { consumeEvent = event.getX() < size; } @@ -155,8 +152,8 @@ public class DeadZone extends View { Slog.v(TAG, "consuming errant click: (" + event.getX() + "," + event.getY() + ")"); } if (mShouldFlash) { - post(mDebugFlash); - postInvalidate(); + mNavigationBarView.post(mDebugFlash); + mNavigationBarView.postInvalidate(); } return true; // ...but I eated it } @@ -168,19 +165,18 @@ public class DeadZone extends View { mLastPokeTime = event.getEventTime(); if (DEBUG) Slog.v(TAG, "poked! size=" + getSize(mLastPokeTime)); - if (mShouldFlash) postInvalidate(); + if (mShouldFlash) mNavigationBarView.postInvalidate(); } public void setFlash(float f) { mFlashFrac = f; - postInvalidate(); + mNavigationBarView.postInvalidate(); } public float getFlash() { return mFlashFrac; } - @Override public void onDraw(Canvas can) { if (!mShouldFlash || mFlashFrac <= 0f) { return; @@ -202,10 +198,6 @@ public class DeadZone extends View { if (DEBUG && size > mSizeMin) // crazy aggressive redrawing here, for debugging only - postInvalidateDelayed(100); - } - - public void setDisplayRotation(int rotation) { - mDisplayRotation = rotation; + mNavigationBarView.postInvalidateDelayed(100); } } |