From 9deaa286d8db51cd53118b3c14a418c512cf55db Mon Sep 17 00:00:00 2001 From: John Spurlock Date: Thu, 25 Jul 2013 13:03:47 -0400 Subject: Dismiss hideybars on touch outside. When the system bars are revealed in auto-hiding mode, the user should be able to dismiss them before the timeout by interacting with the underlying activity. Bug:8682187 Change-Id: I79169005baafda27fb5ad9c29ab1ec67600b2eb6 --- .../systemui/statusbar/phone/PhoneStatusBar.java | 28 ++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 04df2c285272..a8cb955f677e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -341,7 +341,9 @@ public class PhoneStatusBar extends BaseStatusBar { @Override public void run() { int requested = mSystemUiVisibility & ~STATUS_OR_NAV_OVERLAY; - notifyUiVisibilityChanged(requested); + if (mSystemUiVisibility != requested) { + notifyUiVisibilityChanged(requested); + } }}; @Override @@ -379,6 +381,7 @@ public class PhoneStatusBar extends BaseStatusBar { mStatusBarWindow.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { + checkUserAutohide(v, event); if (event.getAction() == MotionEvent.ACTION_DOWN) { if (mExpandedVisible) { animateCollapsePanels(); @@ -435,6 +438,12 @@ public class PhoneStatusBar extends BaseStatusBar { mNavigationBarView.setDisabledFlags(mDisabled); mNavigationBarView.setBar(this); + mNavigationBarView.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + checkUserAutohide(v, event); + return false; + }}); } } catch (RemoteException ex) { // no window manager? good luck with that @@ -1948,6 +1957,20 @@ public class PhoneStatusBar extends BaseStatusBar { mHandler.postDelayed(mAutohide, AUTOHIDE_TIMEOUT_MS); } + private void checkUserAutohide(View v, MotionEvent event) { + if ((mSystemUiVisibility & STATUS_OR_NAV_OVERLAY) != 0 // an overlay bar is revealed + && event.getAction() == MotionEvent.ACTION_OUTSIDE // touch outside the source bar + && event.getX() == 0 && event.getY() == 0 // a touch outside both bars + ) { + userAutohide(); + } + } + + private void userAutohide() { + cancelAutohide(); + mHandler.postDelayed(mAutohide, 25); + } + private void setTransparent(View view, boolean transparent) { float alpha = transparent ? TRANSPARENT_ALPHA : 1; if (DEBUG) Log.d(TAG, "Setting " + (view == mStatusBarView ? "status bar" : @@ -2216,7 +2239,8 @@ public class PhoneStatusBar extends BaseStatusBar { WindowManager.LayoutParams.TYPE_STATUS_BAR, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING - | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, + | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH + | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, PixelFormat.TRANSLUCENT); lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; -- cgit v1.2.3-59-g8ed1b