Merge "Avoids vibration over deadzone in navigationbar" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
47721fa59d
@@ -41,16 +41,4 @@
|
|||||||
|
|
||||||
</FrameLayout>
|
</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>
|
</FrameLayout>
|
||||||
|
|||||||
@@ -46,16 +46,4 @@
|
|||||||
|
|
||||||
</com.android.systemui.statusbar.phone.NearestTouchFrame>
|
</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>
|
</FrameLayout>
|
||||||
|
|||||||
@@ -46,16 +46,4 @@
|
|||||||
|
|
||||||
</com.android.systemui.statusbar.phone.NearestTouchFrame>
|
</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>
|
</FrameLayout>
|
||||||
|
|||||||
@@ -28,4 +28,7 @@
|
|||||||
|
|
||||||
<!-- We have only space for one notification on phone landscape layouts. -->
|
<!-- We have only space for one notification on phone landscape layouts. -->
|
||||||
<integer name="keyguard_max_notification_count">1</integer>
|
<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>
|
</resources>
|
||||||
|
|||||||
@@ -35,4 +35,7 @@
|
|||||||
<!-- Animation duration when using long press on recents to dock -->
|
<!-- Animation duration when using long press on recents to dock -->
|
||||||
<integer name="long_press_dock_anim_duration">290</integer>
|
<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>
|
</resources>
|
||||||
|
|||||||
@@ -93,6 +93,9 @@
|
|||||||
<integer name="navigation_bar_deadzone_hold">333</integer>
|
<integer name="navigation_bar_deadzone_hold">333</integer>
|
||||||
<integer name="navigation_bar_deadzone_decay">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>
|
<bool name="config_dead_zone_flash">false</bool>
|
||||||
|
|
||||||
<!-- Whether to enable dimming navigation buttons when wallpaper is not visible, should be
|
<!-- Whether to enable dimming navigation buttons when wallpaper is not visible, should be
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
|||||||
private TintedKeyButtonDrawable mRotateSuggestionIcon;
|
private TintedKeyButtonDrawable mRotateSuggestionIcon;
|
||||||
|
|
||||||
private GestureHelper mGestureHelper;
|
private GestureHelper mGestureHelper;
|
||||||
private DeadZone mDeadZone;
|
private final DeadZone mDeadZone;
|
||||||
private final NavigationBarTransitions mBarTransitions;
|
private final NavigationBarTransitions mBarTransitions;
|
||||||
private final OverviewProxyService mOverviewProxyService;
|
private final OverviewProxyService mOverviewProxyService;
|
||||||
|
|
||||||
@@ -263,6 +263,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
|||||||
new ButtonDispatcher(R.id.accessibility_button));
|
new ButtonDispatcher(R.id.accessibility_button));
|
||||||
mButtonDispatchers.put(R.id.rotate_suggestion,
|
mButtonDispatchers.put(R.id.rotate_suggestion,
|
||||||
new ButtonDispatcher(R.id.rotate_suggestion));
|
new ButtonDispatcher(R.id.rotate_suggestion));
|
||||||
|
mDeadZone = new DeadZone(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BarTransitions getBarTransitions() {
|
public BarTransitions getBarTransitions() {
|
||||||
@@ -297,6 +298,10 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onInterceptTouchEvent(MotionEvent event) {
|
public boolean onInterceptTouchEvent(MotionEvent event) {
|
||||||
|
if (mDeadZone.onTouchEvent(event)) {
|
||||||
|
// Consumed the touch event
|
||||||
|
return true;
|
||||||
|
}
|
||||||
switch (event.getActionMasked()) {
|
switch (event.getActionMasked()) {
|
||||||
case ACTION_DOWN:
|
case ACTION_DOWN:
|
||||||
int x = (int) event.getX();
|
int x = (int) event.getX();
|
||||||
@@ -319,6 +324,10 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
|
if (mDeadZone.onTouchEvent(event)) {
|
||||||
|
// Consumed the touch event
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (mGestureHelper.onTouchEvent(event)) {
|
if (mGestureHelper.onTouchEvent(event)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -818,6 +827,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
|||||||
@Override
|
@Override
|
||||||
protected void onDraw(Canvas canvas) {
|
protected void onDraw(Canvas canvas) {
|
||||||
mGestureHelper.onDraw(canvas);
|
mGestureHelper.onDraw(canvas);
|
||||||
|
mDeadZone.onDraw(canvas);
|
||||||
super.onDraw(canvas);
|
super.onDraw(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -889,10 +899,8 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
|||||||
public void reorient() {
|
public void reorient() {
|
||||||
updateCurrentView();
|
updateCurrentView();
|
||||||
|
|
||||||
mDeadZone = (DeadZone) mCurrentView.findViewById(R.id.deadzone);
|
|
||||||
|
|
||||||
((NavigationBarFrame) getRootView()).setDeadZone(mDeadZone);
|
((NavigationBarFrame) getRootView()).setDeadZone(mDeadZone);
|
||||||
mDeadZone.setDisplayRotation(mCurrentRotation);
|
mDeadZone.onConfigurationChanged(mCurrentRotation);
|
||||||
|
|
||||||
// force the low profile & disabled states into compliance
|
// force the low profile & disabled states into compliance
|
||||||
mBarTransitions.init();
|
mBarTransitions.init();
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ public class QuickStepController implements GestureHelper {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MotionEvent.ACTION_MOVE: {
|
case MotionEvent.ACTION_MOVE: {
|
||||||
if (mQuickStepStarted || !mAllowGestureDetection){
|
if (mQuickStepStarted || !mAllowGestureDetection || mHomeButtonView == null){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int x = (int) event.getX();
|
int x = (int) event.getX();
|
||||||
|
|||||||
@@ -17,18 +17,16 @@
|
|||||||
package com.android.systemui.statusbar.policy;
|
package com.android.systemui.statusbar.policy;
|
||||||
|
|
||||||
import android.animation.ObjectAnimator;
|
import android.animation.ObjectAnimator;
|
||||||
import android.content.Context;
|
import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.SysUiServiceProvider;
|
import com.android.systemui.SysUiServiceProvider;
|
||||||
|
import com.android.systemui.statusbar.phone.NavigationBarView;
|
||||||
import com.android.systemui.statusbar.phone.StatusBar;
|
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
|
* 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).
|
* 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 String TAG = "DeadZone";
|
||||||
|
|
||||||
public static final boolean DEBUG = false;
|
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 static final boolean CHATTY = true; // print to logcat when we eat a click
|
||||||
private final StatusBar mStatusBar;
|
private final StatusBar mStatusBar;
|
||||||
|
private final NavigationBarView mNavigationBarView;
|
||||||
|
|
||||||
private boolean mShouldFlash;
|
private boolean mShouldFlash;
|
||||||
private float mFlashFrac = 0f;
|
private float mFlashFrac = 0f;
|
||||||
@@ -67,31 +66,11 @@ public class DeadZone extends View {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public DeadZone(Context context, AttributeSet attrs) {
|
public DeadZone(NavigationBarView view) {
|
||||||
this(context, attrs, 0);
|
mNavigationBarView = view;
|
||||||
}
|
mStatusBar = SysUiServiceProvider.getComponent(mNavigationBarView.getContext(),
|
||||||
|
StatusBar.class);
|
||||||
public DeadZone(Context context, AttributeSet attrs, int defStyle) {
|
onConfigurationChanged(HORIZONTAL);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static float lerp(float a, float b, float f) {
|
static float lerp(float a, float b, float f) {
|
||||||
@@ -112,11 +91,29 @@ public class DeadZone extends View {
|
|||||||
public void setFlashOnTouchCapture(boolean dbg) {
|
public void setFlashOnTouchCapture(boolean dbg) {
|
||||||
mShouldFlash = dbg;
|
mShouldFlash = dbg;
|
||||||
mFlashFrac = 0f;
|
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...
|
// I made you a touch event...
|
||||||
@Override
|
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Slog.v(TAG, this + " onTouch: " + MotionEvent.actionToString(event.getAction()));
|
Slog.v(TAG, this + " onTouch: " + MotionEvent.actionToString(event.getAction()));
|
||||||
@@ -143,7 +140,7 @@ public class DeadZone extends View {
|
|||||||
final boolean consumeEvent;
|
final boolean consumeEvent;
|
||||||
if (mVertical) {
|
if (mVertical) {
|
||||||
if (mDisplayRotation == Surface.ROTATION_270) {
|
if (mDisplayRotation == Surface.ROTATION_270) {
|
||||||
consumeEvent = event.getX() > getWidth() - size;
|
consumeEvent = event.getX() > mNavigationBarView.getWidth() - size;
|
||||||
} else {
|
} else {
|
||||||
consumeEvent = event.getX() < size;
|
consumeEvent = event.getX() < size;
|
||||||
}
|
}
|
||||||
@@ -155,8 +152,8 @@ public class DeadZone extends View {
|
|||||||
Slog.v(TAG, "consuming errant click: (" + event.getX() + "," + event.getY() + ")");
|
Slog.v(TAG, "consuming errant click: (" + event.getX() + "," + event.getY() + ")");
|
||||||
}
|
}
|
||||||
if (mShouldFlash) {
|
if (mShouldFlash) {
|
||||||
post(mDebugFlash);
|
mNavigationBarView.post(mDebugFlash);
|
||||||
postInvalidate();
|
mNavigationBarView.postInvalidate();
|
||||||
}
|
}
|
||||||
return true; // ...but I eated it
|
return true; // ...but I eated it
|
||||||
}
|
}
|
||||||
@@ -168,19 +165,18 @@ public class DeadZone extends View {
|
|||||||
mLastPokeTime = event.getEventTime();
|
mLastPokeTime = event.getEventTime();
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
Slog.v(TAG, "poked! size=" + getSize(mLastPokeTime));
|
Slog.v(TAG, "poked! size=" + getSize(mLastPokeTime));
|
||||||
if (mShouldFlash) postInvalidate();
|
if (mShouldFlash) mNavigationBarView.postInvalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlash(float f) {
|
public void setFlash(float f) {
|
||||||
mFlashFrac = f;
|
mFlashFrac = f;
|
||||||
postInvalidate();
|
mNavigationBarView.postInvalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getFlash() {
|
public float getFlash() {
|
||||||
return mFlashFrac;
|
return mFlashFrac;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDraw(Canvas can) {
|
public void onDraw(Canvas can) {
|
||||||
if (!mShouldFlash || mFlashFrac <= 0f) {
|
if (!mShouldFlash || mFlashFrac <= 0f) {
|
||||||
return;
|
return;
|
||||||
@@ -202,10 +198,6 @@ public class DeadZone extends View {
|
|||||||
|
|
||||||
if (DEBUG && size > mSizeMin)
|
if (DEBUG && size > mSizeMin)
|
||||||
// crazy aggressive redrawing here, for debugging only
|
// crazy aggressive redrawing here, for debugging only
|
||||||
postInvalidateDelayed(100);
|
mNavigationBarView.postInvalidateDelayed(100);
|
||||||
}
|
|
||||||
|
|
||||||
public void setDisplayRotation(int rotation) {
|
|
||||||
mDisplayRotation = rotation;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user