Ignore touch down events near the edge of the screen for the purposes of pulling down the

windowshade.

This makes it happen less often when you pick up the device or push open the keyboard.
This commit is contained in:
Joe Onorato
2010-02-22 10:52:11 -08:00
parent 7edf7388b8
commit 679dd12fa1
2 changed files with 24 additions and 4 deletions

View File

@@ -38,4 +38,6 @@
<dimen name="password_keyboard_key_height">56dip</dimen>
<!-- Default correction for the space key in the password keyboard -->
<dimen name="password_keyboard_spacebar_vertical_correction">4dip</dimen>
<!-- Margin at the edge of the screen to ignore touch events for in the windowshade. -->
<dimen name="status_bar_edge_ignore">5dp</dimen>
</resources>

View File

@@ -206,6 +206,7 @@ public class StatusBarService extends IStatusBar.Stub
private boolean mTicking;
// Tracking finger for opening/closing.
int mEdgeBorder; // corresponds to R.dimen.status_bar_edge_ignore
boolean mTracking;
VelocityTracker mVelocityTracker;
@@ -299,6 +300,8 @@ public class StatusBarService extends IStatusBar.Stub
mCloseView = (CloseDragHandle)mTrackingView.findViewById(R.id.close);
mCloseView.mService = this;
mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore);
// add the more icon for the notifications
IconData moreData = IconData.makeIcon(null, context.getPackageName(),
R.drawable.stat_notify_more, 0, 42);
@@ -1204,8 +1207,10 @@ public class StatusBarService extends IStatusBar.Stub
}
boolean interceptTouchEvent(MotionEvent event) {
if (SPEW) Log.d(TAG, "Touch: rawY=" + event.getRawY() + " event=" + event + " mDisabled="
if (SPEW) {
Log.d(TAG, "Touch: rawY=" + event.getRawY() + " event=" + event + " mDisabled="
+ mDisabled);
}
if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) {
return false;
@@ -1214,7 +1219,7 @@ public class StatusBarService extends IStatusBar.Stub
final int statusBarSize = mStatusBarView.getHeight();
final int hitSize = statusBarSize*2;
if (event.getAction() == MotionEvent.ACTION_DOWN) {
int y = (int)event.getRawY();
final int y = (int)event.getRawY();
if (!mExpanded) {
mViewDelta = statusBarSize - y;
@@ -1224,8 +1229,16 @@ public class StatusBarService extends IStatusBar.Stub
}
if ((!mExpanded && y < hitSize) ||
(mExpanded && y > (mDisplay.getHeight()-hitSize))) {
prepareTracking(y, !mExpanded); // opening if we're not already fully visible
mVelocityTracker.addMovement(event);
// We drop events at the edge of the screen to make the windowshade come
// down by accident less, especially when pushing open a device with a keyboard
// that rotates (like g1 and droid)
int x = (int)event.getRawX();
final int edgeBorder = mEdgeBorder;
if (x >= edgeBorder && x < mDisplay.getWidth() - edgeBorder) {
prepareTracking(y, !mExpanded);// opening if we're not already fully visible
mVelocityTracker.addMovement(event);
}
}
} else if (mTracking) {
mVelocityTracker.addMovement(event);
@@ -1771,10 +1784,15 @@ public class StatusBarService extends IStatusBar.Stub
* meantime, just update the things that we know change.
*/
void updateResources() {
Resources res = mContext.getResources();
mClearButton.setText(mContext.getText(R.string.status_bar_clear_all_button));
mOngoingTitle.setText(mContext.getText(R.string.status_bar_ongoing_events_title));
mLatestTitle.setText(mContext.getText(R.string.status_bar_latest_events_title));
mNoNotificationsTitle.setText(mContext.getText(R.string.status_bar_no_notifications_title));
mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore);
if (false) Log.v(TAG, "updateResources");
}