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

Commit 06e6630a authored by Daniel Sandler's avatar Daniel Sandler
Browse files

Restore user-accessible lights-out control.

Current system area gestures:

       tap - no-op (bug 3114340)
  swipe up - open system panel
swipe down - lights out
long press - lights out (bug 3134973)

The enter/exit animations have been tweaked to reinforce
this, particularly the swipe down for lights out. (Swiping
up to exit lights out will work, as will any kind of tap in
the lights-out "curtain".)

Change-Id: Ie027d7a0e86a402d06a8a368a5a43050a6bb9e58
parent 91460d7f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -16,11 +16,11 @@

<set xmlns:android="http://schemas.android.com/apk/res/android"
    >
    <translate android:fromYDelta="100%p" android:toYDelta="0"
    <translate android:fromYDelta="-100%p" android:toYDelta="0"
        android:duration="@android:integer/config_mediumAnimTime" 
        android:interpolator="@anim/hydraulic_brake_interpolator"
        />
    <alpha android:fromAlpha="0.0" android:toAlpha="1.0"
    <alpha android:fromAlpha="0.5" android:toAlpha="1.0"
        android:duration="@android:integer/config_longAnimTime" 
        />
</set>
+2 −2
Original line number Diff line number Diff line
@@ -16,11 +16,11 @@

<set xmlns:android="http://schemas.android.com/apk/res/android"
    >
    <translate android:toYDelta="100%p" android:fromYDelta="0" 
    <translate android:toYDelta="-100%p" android:fromYDelta="0" 
        android:duration="@android:integer/config_mediumAnimTime" 
        android:interpolator="@anim/hydraulic_brake_interpolator"
        />
    <alpha android:toAlpha="0.0" android:fromAlpha="1.0"
    <alpha android:toAlpha="0.5" android:fromAlpha="1.0"
        android:duration="@android:integer/config_longAnimTime" 
        />
</set>
+2 −2
Original line number Diff line number Diff line
@@ -16,11 +16,11 @@

<set xmlns:android="http://schemas.android.com/apk/res/android"
    >
    <translate android:fromYDelta="-100%p" android:toYDelta="0"
    <translate android:fromYDelta="100%p" android:toYDelta="0"
        android:duration="@android:integer/config_longAnimTime" 
        android:interpolator="@anim/hydraulic_brake_interpolator"
        />
    <alpha android:fromAlpha="0.0" android:toAlpha="1.0"
    <alpha android:fromAlpha="0.5" android:toAlpha="1.0"
        android:duration="@android:integer/config_longAnimTime" 
        />
</set>
+2 −2
Original line number Diff line number Diff line
@@ -16,11 +16,11 @@

<set xmlns:android="http://schemas.android.com/apk/res/android"
    >
    <translate android:toYDelta="-100%p" android:fromYDelta="0"
    <translate android:toYDelta="100%p" android:fromYDelta="0"
        android:duration="@android:integer/config_longAnimTime" 
        android:interpolator="@anim/hydraulic_brake_interpolator"
        />
    <alpha android:toAlpha="0.0" android:fromAlpha="1.0"
    <alpha android:toAlpha="0.5" android:fromAlpha="1.0"
        android:duration="@android:integer/config_longAnimTime" 
        />
</set>
+35 −24
Original line number Diff line number Diff line
@@ -75,6 +75,8 @@ public class TabletStatusBarService extends StatusBarService {
    public static final int MSG_CLOSE_SYSTEM_PANEL = 1011;
    public static final int MSG_OPEN_RECENTS_PANEL = 1020;
    public static final int MSG_CLOSE_RECENTS_PANEL = 1021;
    public static final int MSG_LIGHTS_ON = 1030;
    public static final int MSG_LIGHTS_OUT = 1031;

    private static final int MAX_IMAGE_LEVEL = 10000;
    private static final boolean USE_2D_RECENTS = true;
@@ -263,8 +265,6 @@ public class TabletStatusBarService extends StatusBarService {
        mSystemInfo = sb.findViewById(R.id.systemInfo);
        mRecentButton = sb.findViewById(R.id.recent_apps);

//        mSystemInfo.setOnClickListener(mOnClickListener);
        mSystemInfo.setOnLongClickListener(new SetLightsOnListener(false));
        mSystemInfo.setOnTouchListener(new ClockTouchListener());

        mRecentButton = sb.findViewById(R.id.recent_apps);
@@ -422,6 +422,15 @@ public class TabletStatusBarService extends StatusBarService {
                    if (DEBUG) Slog.d(TAG, "closing recents panel");
                    if (mRecentsPanel != null) mRecentsPanel.setVisibility(View.GONE);
                    break;
                case MSG_LIGHTS_ON:
                    setViewVisibility(mCurtains, View.GONE, R.anim.lights_out_out);
                    setViewVisibility(mBarContents, View.VISIBLE, R.anim.status_bar_in);
                    break;
                case MSG_LIGHTS_OUT:
                    animateCollapse();
                    setViewVisibility(mCurtains, View.VISIBLE, R.anim.lights_out_in);
                    setViewVisibility(mBarContents, View.GONE, R.anim.status_bar_out);
                    break;
            }
        }
    }
@@ -675,15 +684,12 @@ public class TabletStatusBarService extends StatusBarService {
        mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL);
    }

    // called by StatusBarService
    @Override
    public void setLightsOn(boolean on) {
        if (on) {
            setViewVisibility(mCurtains, View.GONE, R.anim.lights_out_out);
            setViewVisibility(mBarContents, View.VISIBLE, R.anim.status_bar_in);
        } else {
            animateCollapse();
            setViewVisibility(mCurtains, View.VISIBLE, R.anim.lights_out_in);
            setViewVisibility(mBarContents, View.GONE, R.anim.status_bar_out);
        }
        mHandler.removeMessages(MSG_LIGHTS_OUT);
        mHandler.removeMessages(MSG_LIGHTS_ON);
        mHandler.sendEmptyMessage(on ? MSG_LIGHTS_ON : MSG_LIGHTS_OUT);
    }

    public void setMenuKeyVisible(boolean visible) {
@@ -750,26 +756,41 @@ public class TabletStatusBarService extends StatusBarService {
    }

    private class ClockTouchListener implements View.OnTouchListener {
        VelocityTracker mVT;
        VelocityTracker mVT = null;
        int mInitX, mInitY;
        public boolean onTouch (View v, MotionEvent event) {
            final int x = (int) event.getX();
            final int y = (int) event.getY();
            switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    mVT = VelocityTracker.obtain();
                    // fall through
                    mInitX = x;
                    mInitY = y;
                    mHandler.sendEmptyMessageDelayed(MSG_LIGHTS_OUT,
                            ViewConfiguration.getLongPressTimeout());
                    break;
                case MotionEvent.ACTION_OUTSIDE:
                case MotionEvent.ACTION_MOVE:
                    final Rect r = new Rect();
                    final float radius = mSystemInfo.getHeight() / 2;
                    if (Math.abs(x - mInitX) > radius || Math.abs(y - mInitY) > radius) {
                        mHandler.removeMessages(MSG_LIGHTS_OUT);
                    }
                    if (mVT == null) break;
                    mVT.addMovement(event);
                    mVT.computeCurrentVelocity(1000);
                    if (mVT.getYVelocity() < -200 && mSystemPanel.getVisibility() == View.GONE) {
                        mHandler.removeMessages(MSG_OPEN_SYSTEM_PANEL);
                        mHandler.sendEmptyMessage(MSG_OPEN_SYSTEM_PANEL);
                    } else if (mVT.getYVelocity() > 200) {
                        mHandler.sendEmptyMessage(MSG_LIGHTS_OUT);
                    }
                    return true;
                case MotionEvent.ACTION_UP:
                case MotionEvent.ACTION_CANCEL:
                    mVT.recycle();
                    mVT = null;
                    mHandler.removeMessages(MSG_LIGHTS_OUT);
                    return true;
            }
            return false;
@@ -784,8 +805,6 @@ public class TabletStatusBarService extends StatusBarService {
                onClickDoNotDisturb();
            } else if (v == mNotificationTrigger) {
                onClickNotificationTrigger();
            } else if (v == mSystemInfo) {
                onClickSystemInfo();
            } else if (v == mRecentButton) {
                onClickRecentButton();
            }
@@ -1172,19 +1191,11 @@ public class TabletStatusBarService extends StatusBarService {
        }

        public void onClick(View v) {
            try {
                mBarService.setLightsOn(mOn);
            } catch (RemoteException ex) {
                // system process
            }
            setLightsOn(mOn);
        }

        public boolean onLongClick(View v) {
            try {
                mBarService.setLightsOn(mOn);
            } catch (RemoteException ex) {
                // system process
            }
            setLightsOn(mOn);
            return true;
        }