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

Commit e137a1ea authored by Daniel Sandler's avatar Daniel Sandler
Browse files

Low profile mode ("lights out") for phone status bar.

Also changes NAVIGATION_HIDDEN to remove the hide animation,
hopefully reducing the number of jarring transitions when
apps want to enable super-ultra-full-screen mode.

Bug: 5052456
Bug: 5146960
Change-Id: I5f5ebb23add81243dc8861b65d8f15ca4d9ce0d2
parent e644b647
Loading
Loading
Loading
Loading
+94 −7
Original line number Diff line number Diff line
@@ -23,12 +23,12 @@
    xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:background="#FF000000"
    >

    <FrameLayout android:id="@+id/rot0"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:background="#FF000000"
        >

        <LinearLayout
@@ -98,6 +98,51 @@
                />
        </LinearLayout>

        <!-- lights out layout to match exactly -->
        <LinearLayout
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:orientation="horizontal"
            android:id="@+id/lights_out"
            android:visibility="gone"
            >
            <ImageView
                android:layout_width="80dp"
                android:layout_height="match_parent"
                android:layout_marginLeft="40dp"
                android:src="@drawable/ic_sysbar_lights_out_dot_small"
                android:scaleType="center"
                android:layout_weight="0"
                />
            <View 
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:visibility="invisible"
                />
            <ImageView
                android:layout_width="80dp"
                android:layout_height="match_parent"
                android:src="@drawable/ic_sysbar_lights_out_dot_large"
                android:scaleType="center"
                android:layout_weight="0"
                />
            <View 
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:visibility="invisible"
                />
            <ImageView
                android:layout_width="80dp"
                android:layout_marginRight="40dp"
                android:layout_height="match_parent"
                android:src="@drawable/ic_sysbar_lights_out_dot_small"
                android:scaleType="center"
                android:layout_weight="0"
                />
        </LinearLayout>

        <View android:id="@+id/deadzone"
            android:layout_height="@dimen/navigation_bar_deadzone_size"
            android:layout_width="match_parent"
@@ -109,7 +154,6 @@
    <FrameLayout android:id="@+id/rot90"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:background="#FF000000"
        android:visibility="gone"
        android:paddingTop="24dp"
        >
@@ -131,6 +175,8 @@
                systemui:keyCode="82"
                android:layout_weight="0"
                android:visibility="invisible"
                android:contentDescription="@string/accessibility_menu"
                systemui:glowBackground="@drawable/ic_sysbar_highlight_land"
                />
            <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/recent_apps"
                android:layout_height="80dp"
@@ -171,15 +217,56 @@
                android:contentDescription="@string/accessibility_back"
                systemui:glowBackground="@drawable/ic_sysbar_highlight_land"
                />
            <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/menu"
            <View
                android:layout_height="40dp"
                android:layout_width="match_parent"
                android:src="@drawable/ic_sysbar_menu_land"
                systemui:keyCode="82"
                android:layout_weight="0"
                android:visibility="invisible"
                android:contentDescription="@string/accessibility_menu"
                systemui:glowBackground="@drawable/ic_sysbar_highlight_land"
                />
        </LinearLayout>

        <!-- lights out layout to match exactly -->
        <LinearLayout 
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:orientation="vertical"
            android:id="@+id/lights_out"
            android:visibility="gone"
            >
            <ImageView
                android:layout_height="80dp"
                android:layout_marginTop="40dp"
                android:layout_width="match_parent"
                android:src="@drawable/ic_sysbar_lights_out_dot_small"
                android:scaleType="center"
                android:layout_weight="0"
                />
            <View 
                android:layout_height="match_parent"
                android:layout_width="match_parent"
                android:layout_weight="1"
                android:visibility="invisible"
                />
            <ImageView
                android:layout_height="80dp"
                android:layout_width="match_parent"
                android:src="@drawable/ic_sysbar_lights_out_dot_large"
                android:scaleType="center"
                android:layout_weight="0"
                />
            <View 
                android:layout_height="match_parent"
                android:layout_width="match_parent"
                android:layout_weight="1"
                android:visibility="invisible"
                />
            <ImageView
                android:layout_height="80dp"
                android:layout_marginBottom="40dp"
                android:layout_width="match_parent"
                android:src="@drawable/ic_sysbar_lights_out_dot_small"
                android:scaleType="center"
                android:layout_weight="0"
                />
        </LinearLayout>

+75 −3
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.content.res.Resources;
import android.os.ServiceManager;
import android.util.AttributeSet;
import android.util.Slog;
import android.view.animation.AccelerateInterpolator;
import android.view.Display;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -47,6 +48,8 @@ public class NavigationBarView extends LinearLayout {

    final static boolean NAVBAR_ALWAYS_AT_RIGHT = true;

    final static boolean ANIMATE_HIDE_TRANSITION = false; // turned off because it introduces unsightly delay when videos goes to full screen

    protected IStatusBarService mBarService;
    final Display mDisplay;
    View mCurrentView = null;
@@ -56,7 +59,7 @@ public class NavigationBarView extends LinearLayout {
    int mBarSize;
    boolean mVertical;

    boolean mHidden;
    boolean mHidden, mLowProfile;
    boolean mEnabled = true;

    public View getRecentsButton() {
@@ -87,6 +90,65 @@ public class NavigationBarView extends LinearLayout {
        mCurrentView.setVisibility(enable ? View.VISIBLE : View.INVISIBLE);
    }

    View.OnTouchListener mLightsOutListener = new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent ev) {
            if (ev.getAction() == MotionEvent.ACTION_DOWN) {
                // even though setting the systemUI visibility below will turn these views
                // on, we need them to come up faster so that they can catch this motion
                // event
                setLowProfile(false, false);

                try {
                    mBarService.setSystemUiVisibility(0);
                } catch (android.os.RemoteException ex) {
                }
            }
            return false;
        }
    };

    public void setLowProfile(final boolean lightsOut) {
        setLowProfile(lightsOut, true);
    }

    public void setLowProfile(final boolean lightsOut, final boolean animate) {
        if (lightsOut == mLowProfile) return;

        mLowProfile = lightsOut;

        if (DEBUG) Slog.d(TAG, "setting lights " + (lightsOut?"out":"on"));

        final View navButtons = mCurrentView.findViewById(R.id.nav_buttons);
        final View lowLights = mCurrentView.findViewById(R.id.lights_out);

        if (!animate) {
            lowLights.setVisibility(View.GONE);
            navButtons.setAlpha(1f);
        } else {
            navButtons.animate()
                .alpha(lightsOut ? 0f : 1f)
                .setDuration(lightsOut ? 600 : 200)
                .start();

            lowLights.setOnTouchListener(mLightsOutListener);
            lowLights.setAlpha(0f);
            lowLights.setVisibility(View.VISIBLE);
            lowLights.animate()
                .alpha(lightsOut ? 1f : 0f)
                .setStartDelay(lightsOut ? 500 : 0)
                .setDuration(lightsOut ? 1000 : 300)
                .setInterpolator(new AccelerateInterpolator(2.0f))
                .setListener(lightsOut ? null : new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator _a) {
                        lowLights.setVisibility(View.GONE);
                    }
                })
                .start();
        }
    }

    public void setHidden(final boolean hide) {
        if (hide == mHidden) return;

@@ -94,6 +156,14 @@ public class NavigationBarView extends LinearLayout {
        Slog.d(TAG,
            (hide ? "HIDING" : "SHOWING") + " navigation bar");

        // bring up the lights no matter what
        setLowProfile(false);

        if (!ANIMATE_HIDE_TRANSITION) {
            setVisibility(hide ? View.GONE : View.VISIBLE);
            return;
        }

        float oldAlpha = mCurrentView.getAlpha();
        if (DEBUG) {
            Slog.d(TAG, "animating alpha: " + oldAlpha + " -> "
@@ -147,8 +217,10 @@ public class NavigationBarView extends LinearLayout {

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        // immediately bring up the lights
        setHidden(false);
        try {
            mBarService.setSystemUiVisibility(0);
        } catch (android.os.RemoteException ex) {
        }
        return false; // pass it on
    }

+10 −3
Original line number Diff line number Diff line
@@ -1494,12 +1494,19 @@ public class PhoneStatusBar extends StatusBar {

    @Override // CommandQueue
    public void setSystemUiVisibility(int vis) {
        if (vis != mSystemUiVisibility) {
        final int old = mSystemUiVisibility;
        final int diff = vis ^ old;

        if (diff != 0) {
            mSystemUiVisibility = vis;

            if (0 != (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE)) {
            if (0 != (diff & View.SYSTEM_UI_FLAG_LOW_PROFILE)) {
                final boolean lightsOut = (0 != (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE));
                if (lightsOut) {
                    animateCollapse();
                }
                mNavigationBarView.setLowProfile(lightsOut);
            }

            notifyUiVisibilityChanged();
        }