Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ad3e6cb4 authored by John Spurlock's avatar John Spurlock
Browse files

Navigation hideybar via new system ui opt-in flag.

Apps using SYSTEM_UI_FLAG_HIDE_NAVIGATION to hide the nav bar
or SYSTEM_UI_FLAG_FULLSCREEN to hide the status bar can now
opt into hideybars by also using a new public sysui flag:
  View.SYSTEM_UI_FLAG_ALLOW_OVERLAY

When opting in, apps accept the fact that bars can be overlayed
over their content, but gain the ability to use the entire gesture
space - something that was not possible before, particularly when
hiding the nav bar.

Swiping from the nav bar edge of the screen will reveal the new hidey
version of the nav bar, if applicable.

Bug: 8682181
Change-Id: I6405bee50e6516667ba6b9a62d4f1e43490b5562
parent 3b9831f6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -26447,6 +26447,7 @@ package android.view {
    field public static final int SOUND_EFFECTS_ENABLED = 134217728; // 0x8000000
    field public static final deprecated int STATUS_BAR_HIDDEN = 1; // 0x1
    field public static final deprecated int STATUS_BAR_VISIBLE = 0; // 0x0
    field public static final int SYSTEM_UI_FLAG_ALLOW_OVERLAY = 2048; // 0x800
    field public static final int SYSTEM_UI_FLAG_FULLSCREEN = 4; // 0x4
    field public static final int SYSTEM_UI_FLAG_HIDE_NAVIGATION = 2; // 0x2
    field public static final int SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN = 1024; // 0x400
+22 −1
Original line number Diff line number Diff line
@@ -2361,6 +2361,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    public static final int SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN = 0x00000400;
    /**
     * Flag for {@link #setSystemUiVisibility(int)}: View would like to receive touch events
     * when hiding the status bar with {@link #SYSTEM_UI_FLAG_FULLSCREEN} and/or hiding the
     * navigation bar with {@link #SYSTEM_UI_FLAG_HIDE_NAVIGATION} instead of having the system
     * clear these flags upon interaction.  The system may compensate by temporarily overlaying
     * transparent system ui while also delivering the event.
     */
    public static final int SYSTEM_UI_FLAG_ALLOW_OVERLAY = 0x00000800;
    /**
     * @deprecated Use {@link #SYSTEM_UI_FLAG_LOW_PROFILE} instead.
     */
@@ -2487,11 +2496,23 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * out of the public fields to keep the undefined bits out of the developer's way.
     *
     * Flag to specify that the status bar should temporarily overlay underlying content
     * that is otherwise assuming the status bar is hidden.  The status bar will typically
     * that is otherwise assuming the status bar is hidden.  The status bar may
     * have some degree of transparency while in this temporary overlay mode.
     */
    public static final int STATUS_BAR_OVERLAY = 0x04000000;
    /**
     * @hide
     *
     * NOTE: This flag may only be used in subtreeSystemUiVisibility. It is masked
     * out of the public fields to keep the undefined bits out of the developer's way.
     *
     * Flag to specify that the navigation bar should temporarily overlay underlying content
     * that is otherwise assuming the navigation bar is hidden.  The navigation bar mayu
     * have some degree of transparency while in this temporary overlay mode.
     */
    public static final int NAVIGATION_BAR_OVERLAY = 0x08000000;
    /**
     * @hide
     */
+8 −0
Original line number Diff line number Diff line
@@ -1172,4 +1172,12 @@ public abstract class BaseStatusBar extends SystemUI implements
        KeyguardManager km = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
        return km.inKeyguardRestrictedInputMode();
    }

    public void suspendAutohide() {
        // hook for subclasses
    }

    public void resumeAutohide() {
        // hook for subclasses
    }
}
+9 −3
Original line number Diff line number Diff line
@@ -57,8 +57,8 @@ public class DelegateViewHelper {
        final float sourceX = mTempPoint[0];
        final float sourceY = mTempPoint[1];


        switch (event.getAction()) {
        final int action = event.getAction();
        switch (action) {
            case MotionEvent.ACTION_DOWN:
                mPanelShowing = mDelegateView.getVisibility() == View.VISIBLE;
                mDownPoint[0] = event.getX();
@@ -71,7 +71,7 @@ public class DelegateViewHelper {
            return false;
        }

        if (!mPanelShowing && event.getAction() == MotionEvent.ACTION_MOVE) {
        if (!mPanelShowing && action == MotionEvent.ACTION_MOVE) {
            final int historySize = event.getHistorySize();
            for (int k = 0; k < historySize + 1; k++) {
                float x = k < historySize ? event.getHistoricalX(k) : event.getX();
@@ -85,6 +85,12 @@ public class DelegateViewHelper {
            }
        }

        if (action == MotionEvent.ACTION_DOWN) {
            mBar.suspendAutohide();
        } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
            mBar.resumeAutohide();
        }

        mDelegateView.getLocationOnScreen(mTempPoint);
        final float delegateX = mTempPoint[0];
        final float delegateY = mTempPoint[1];
+31 −15
Original line number Diff line number Diff line
@@ -132,6 +132,8 @@ public class PhoneStatusBar extends BaseStatusBar {
    private static final int NOTIFICATION_PRIORITY_MULTIPLIER = 10; // see NotificationManagerService
    private static final int HIDE_ICONS_BELOW_SCORE = Notification.PRIORITY_LOW * NOTIFICATION_PRIORITY_MULTIPLIER;

    private static final int STATUS_OR_NAV_OVERLAY =
            View.STATUS_BAR_OVERLAY | View.NAVIGATION_BAR_OVERLAY;
    private static final long AUTOHIDE_TIMEOUT_MS = 3000;
    private static final float TRANSPARENT_ALPHA = 0.7f;

@@ -312,7 +314,7 @@ public class PhoneStatusBar extends BaseStatusBar {
    private final Runnable mAutohide = new Runnable() {
        @Override
        public void run() {
            int requested = mSystemUiVisibility & ~View.STATUS_BAR_OVERLAY;
            int requested = mSystemUiVisibility & ~STATUS_OR_NAV_OVERLAY;
            notifyUiVisibilityChanged(requested);
        }};

@@ -806,7 +808,7 @@ public class PhoneStatusBar extends BaseStatusBar {
                    | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                    | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
                    | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
                PixelFormat.OPAQUE);
                PixelFormat.TRANSLUCENT);
        // this will allow the navbar to run in an overlay on devices that support this
        if (ActivityManager.isHighEndGfx()) {
            lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
@@ -1682,9 +1684,7 @@ public class PhoneStatusBar extends BaseStatusBar {
        }

        // Reschedule suspended auto-hide if necessary
        if (mAutohideSuspended) {
            scheduleAutohide();
        }
        resumeAutohide();
    }

    /**
@@ -1875,13 +1875,20 @@ public class PhoneStatusBar extends BaseStatusBar {
                setStatusBarLowProfile(lightsOut);
            }

            if (0 != (diff & View.STATUS_BAR_OVERLAY)) {
                boolean overlay = 0 != (vis & View.STATUS_BAR_OVERLAY);
                if (overlay) {
                    setTransparent(true);
            boolean sbOverlayChanged = 0 != (diff & View.STATUS_BAR_OVERLAY);
            boolean nbOverlayChanged = 0 != (diff & View.NAVIGATION_BAR_OVERLAY);
            if (sbOverlayChanged || nbOverlayChanged) {
                boolean sbOverlay = 0 != (vis & View.STATUS_BAR_OVERLAY);
                boolean nbOverlay = 0 != (vis & View.NAVIGATION_BAR_OVERLAY);
                if (sbOverlayChanged) {
                    setTransparent(mStatusBarView, sbOverlay);
                }
                if (nbOverlayChanged) {
                    setTransparent(mNavigationBarView, nbOverlay);
                }
                if (sbOverlayChanged && sbOverlay || nbOverlayChanged && nbOverlay) {
                    scheduleAutohide();
                } else {
                    setTransparent(false);
                    cancelAutohide();
                }
            }
@@ -1889,9 +1896,17 @@ public class PhoneStatusBar extends BaseStatusBar {
        }
    }

    private void suspendAutohide() {
    @Override
    public void resumeAutohide() {
        if (mAutohideSuspended) {
            scheduleAutohide();
        }
    }

    @Override
    public void suspendAutohide() {
        mHandler.removeCallbacks(mAutohide);
        mAutohideSuspended = (0 != (mSystemUiVisibility & View.STATUS_BAR_OVERLAY));
        mAutohideSuspended = 0 != (mSystemUiVisibility & STATUS_OR_NAV_OVERLAY);
    }

    private void cancelAutohide() {
@@ -1904,10 +1919,11 @@ public class PhoneStatusBar extends BaseStatusBar {
        mHandler.postDelayed(mAutohide, AUTOHIDE_TIMEOUT_MS);
    }

    private void setTransparent(boolean transparent) {
    private void setTransparent(View view, boolean transparent) {
        float alpha = transparent ? TRANSPARENT_ALPHA : 1;
        if (DEBUG) Slog.d(TAG, "Setting alpha to " + alpha);
        mStatusBarView.setAlpha(alpha);
        if (DEBUG) Slog.d(TAG, "Setting " + (view == mStatusBarView ? "status bar" :
                view == mNavigationBarView ? "navigation bar" : "view") +  " alpha to " + alpha);
        view.setAlpha(alpha);
    }

    private void setStatusBarLowProfile(boolean lightsOut) {
Loading