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

Commit 8cfe6c56 authored by Heemin Seog's avatar Heemin Seog
Browse files

Clean up navbar for autohide

AutoHideController's reference to the navbar should be removed when nav
bar is removed.

Bug: 150961453
Test: build
Change-Id: Id5e09f529f4898f9991b0bb97fad7ccf4e84b05c
parent 91b4f26c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -165,6 +165,7 @@ public class NavigationBarController implements Callbacks {
    private void removeNavigationBar(int displayId) {
        NavigationBarFragment navBar = mNavigationBars.get(displayId);
        if (navBar != null) {
            navBar.setAutoHideController(/* autoHideController */ null);
            View navigationWindow = navBar.getView().getRootView();
            WindowManagerGlobal.getInstance()
                    .removeView(navigationWindow, true /* immediate */);
+28 −21
Original line number Diff line number Diff line
@@ -205,6 +205,28 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback

    private final Handler mHandler;

    private final AutoHideUiElement mAutoHideUiElement = new AutoHideUiElement() {
        @Override
        public void synchronizeState() {
            checkNavBarModes();
        }

        @Override
        public boolean shouldHideOnTouch() {
            return !mNotificationRemoteInputManager.getController().isRemoteInputActive();
        }

        @Override
        public boolean isVisible() {
            return isTransientShown();
        }

        @Override
        public void hide() {
            clearTransient();
        }
    };

    private final OverviewProxyListener mOverviewProxyListener = new OverviewProxyListener() {
        @Override
        public void onConnectionChanged(boolean isConnected) {
@@ -1052,28 +1074,13 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback

    /** Sets {@link AutoHideController} to the navigation bar. */
    public void setAutoHideController(AutoHideController autoHideController) {
        mAutoHideController = autoHideController;
        mAutoHideController.addAutoHideUiElement(new AutoHideUiElement() {
            @Override
            public void synchronizeState() {
                checkNavBarModes();
            }

            @Override
            public boolean shouldHideOnTouch() {
                return !mNotificationRemoteInputManager.getController().isRemoteInputActive();
            }

            @Override
            public boolean isVisible() {
                return isTransientShown();
        if (mAutoHideController != null) {
            mAutoHideController.removeAutoHideUiElement(mAutoHideUiElement);
        }

            @Override
            public void hide() {
                clearTransient();
        mAutoHideController = autoHideController;
        if (mAutoHideController != null) {
            mAutoHideController.addAutoHideUiElement(mAutoHideUiElement);
        }
        });
    }

    private boolean isTransientShown() {