OSDN Git Service

Dismiss hideybars on touch outside.
authorJohn Spurlock <jspurlock@google.com>
Thu, 25 Jul 2013 17:03:47 +0000 (13:03 -0400)
committerJohn Spurlock <jspurlock@google.com>
Thu, 25 Jul 2013 18:42:48 +0000 (14:42 -0400)
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

packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java

index 04df2c2..a8cb955 100644 (file)
@@ -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;