Make bottom-left pixel of navbar clickable with mouse

The DeadZone is eating all clicks in the bottem-left pixel of the screen.
* Ignore mouse clicks for DeadZone, because it exists to compensate for
  low-precision finger input.
* Fix bug where "vertical" orientation consumes events along both the top
  and the left edge.
* Fix orientation for tablets so it correctly consumes events along the
  top edge.

Bug: 20091403
Change-Id: I8e97d894e380ece251f7920e5194c0dee4de0b43
This commit is contained in:
James Cook
2015-04-09 10:38:05 -07:00
parent 0449ac457c
commit f8da20875b
2 changed files with 22 additions and 4 deletions

View File

@@ -305,6 +305,8 @@
/>
</LinearLayout>
<!-- On tablets in landscape the navbar is on the bottom, so use a
horizontal dead zone. -->
<com.android.systemui.statusbar.policy.DeadZone
android:id="@+id/deadzone"
android:layout_height="match_parent"
@@ -313,7 +315,7 @@
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"
systemui:orientation="horizontal"
android:layout_gravity="top"
/>
</FrameLayout>

View File

@@ -28,12 +28,19 @@ import android.view.View;
import com.android.systemui.R;
/**
* The "dead zone" consumes unintentional taps along the top edge of the navigation bar.
* When users are typing quickly on an IME they may attempt to hit the space bar, overshoot, and
* accidentally hit the home button. The DeadZone expands temporarily after each tap in the UI
* 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 static final String TAG = "DeadZone";
public static final boolean DEBUG = false;
public static final int HORIZONTAL = 0;
public static final int VERTICAL = 1;
public static final int HORIZONTAL = 0; // Consume taps along the top edge.
public static final int VERTICAL = 1; // Consume taps along the left edge.
private static final boolean CHATTY = true; // print to logcat when we eat a click
@@ -109,6 +116,12 @@ public class DeadZone extends View {
Slog.v(TAG, this + " onTouch: " + MotionEvent.actionToString(event.getAction()));
}
// Don't consume events for high precision pointing devices. For this purpose a stylus is
// considered low precision (like a finger), so its events may be consumed.
if (event.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE) {
return false;
}
final int action = event.getAction();
if (action == MotionEvent.ACTION_OUTSIDE) {
poke(event);
@@ -117,7 +130,10 @@ public class DeadZone extends View {
Slog.v(TAG, this + " ACTION_DOWN: " + event.getX() + "," + event.getY());
}
int size = (int) getSize(event.getEventTime());
if ((mVertical && event.getX() < size) || event.getY() < size) {
// In the vertical orientation consume taps along the left edge.
// In horizontal orientation consume taps along the top edge.
final boolean consumeEvent = mVertical ? event.getX() < size : event.getY() < size;
if (consumeEvent) {
if (CHATTY) {
Slog.v(TAG, "consuming errant click: (" + event.getX() + "," + event.getY() + ")");
}