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

Commit e5c7a894 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Hide back button on keyguard and make it work for bouncer.

Bug: 13635952
Change-Id: Ie9824dd9926c9deb0a38c8e0a6161f605a489622
parent d4a57440
Loading
Loading
Loading
Loading
+1 −15
Original line number Diff line number Diff line
@@ -107,7 +107,6 @@ public abstract class KeyguardViewBase extends FrameLayout implements SecurityCa
        mSecurityContainer.setSecurityCallback(this);
        mSecurityContainer.showPrimarySecurityScreen(false);
        // mSecurityContainer.updateSecurityViews(false /* not bouncing */);
        setBackButtonEnabled(false);
    }

    /**
@@ -127,12 +126,6 @@ public abstract class KeyguardViewBase extends FrameLayout implements SecurityCa
        return dismiss(false);
    }

    private void setBackButtonEnabled(boolean enabled) {
        setSystemUiVisibility(enabled ?
                getSystemUiVisibility() & ~View.STATUS_BAR_DISABLE_BACK :
                getSystemUiVisibility() | View.STATUS_BAR_DISABLE_BACK);
    }

    protected void showBouncer(boolean show) {
        CharSequence what = getContext().getResources().getText(
                show ? R.string.keyguard_accessibility_show_bouncer
@@ -143,8 +136,7 @@ public abstract class KeyguardViewBase extends FrameLayout implements SecurityCa

    public boolean handleBackKey() {
        if (mSecurityContainer.getCurrentSecuritySelection() == SecurityMode.Account) {
            // go back to primary screen and re-disable back
            setBackButtonEnabled(false);
            // go back to primary screen
            mSecurityContainer.showPrimarySecurityScreen(false /*turningOff*/);
            return true;
        }
@@ -207,12 +199,6 @@ public abstract class KeyguardViewBase extends FrameLayout implements SecurityCa

    @Override
    public void onSecurityModeChanged(SecurityMode securityMode, boolean needsInput) {
        // Enable or disable the back button based on security mode
        if (securityMode == SecurityMode.Account && !mLockPatternUtils.isPermanentlyLocked()) {
            // we're showing account as a backup, provide a way to get back to primary
            setBackButtonEnabled(true);
        }

        if (mViewMediatorCallback != null) {
            mViewMediatorCallback.setNeedsInput(needsInput);
        }
+8 −0
Original line number Diff line number Diff line
@@ -105,6 +105,10 @@ public class KeyguardBouncer {
        return KeyguardViewMediator.AWAKE_INTERVAL_DEFAULT_MS;
    }

    public boolean isShowing() {
        return mRoot != null && mRoot.getVisibility() == View.VISIBLE;
    }

    private void ensureView() {
        if (mRoot == null) {
            inflateView();
@@ -128,4 +132,8 @@ public class KeyguardBouncer {
            mRoot = null;
        }
    }

    public boolean onBackPressed() {
        return mKeyguardView != null && mKeyguardView.handleBackKey();
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -2857,6 +2857,15 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
        }
    }

    public boolean onBackPressed() {
        if (mOnKeyguard) {
            return mStatusBarKeyguardViewManager.onBackPressed();
        } else {
            animateCollapsePanels();
            return true;
        }
    }

    private void showBouncer() {
        if (mOnKeyguard) {
            mStatusBarKeyguardViewManager.dismiss();
+27 −1
Original line number Diff line number Diff line
@@ -62,7 +62,6 @@ public class StatusBarKeyguardViewManager {
        mContext = context;
        mViewMediatorCallback = callback;
        mLockPatternUtils = lockPatternUtils;

    }

    public void registerStatusBar(PhoneStatusBar phoneStatusBar,
@@ -83,10 +82,12 @@ public class StatusBarKeyguardViewManager {
        mStatusBarWindowManager.setKeyguardShowing(true);
        mPhoneStatusBar.showKeyguard();
        mBouncer.prepare();
        updateBackButtonState();
    }

    public void showBouncer() {
        mBouncer.show();
        updateBackButtonState();
    }

    /**
@@ -95,6 +96,7 @@ public class StatusBarKeyguardViewManager {
    public void reset() {
        mBouncer.reset();
        mPhoneStatusBar.showKeyguard();
        updateBackButtonState();
    }

    public void onScreenTurnedOff() {
@@ -165,4 +167,28 @@ public class StatusBarKeyguardViewManager {
    public boolean isShowing() {
        return mShowing;
    }

    /**
     * Notifies this manager that the back button has been pressed.
     *
     * @return whether the back press has been handled
     */
    public boolean onBackPressed() {
        if (mBouncer.isShowing()) {
            mBouncer.hide();
            mPhoneStatusBar.showKeyguard();
            updateBackButtonState();
            return true;
        }
        return false;
    }

    private void updateBackButtonState() {
        int vis = mContainer.getSystemUiVisibility();
        if (mBouncer.isShowing()) {
            mContainer.setSystemUiVisibility(vis & ~View.STATUS_BAR_DISABLE_BACK);
        } else {
            mContainer.setSystemUiVisibility(vis | View.STATUS_BAR_DISABLE_BACK);
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ public class StatusBarWindowView extends FrameLayout
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_BACK:
            if (!down) {
                mService.animateCollapsePanels();
                mService.onBackPressed();
            }
            return true;
        }