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
This commit is contained in:
Heemin Seog
2020-03-06 15:01:08 -08:00
parent 91b4f26c5b
commit 8cfe6c5639
2 changed files with 29 additions and 21 deletions

View File

@@ -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 */);

View File

@@ -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) {
if (mAutoHideController != null) {
mAutoHideController.removeAutoHideUiElement(mAutoHideUiElement);
}
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();
}
@Override
public void hide() {
clearTransient();
}
});
if (mAutoHideController != null) {
mAutoHideController.addAutoHideUiElement(mAutoHideUiElement);
}
}
private boolean isTransientShown() {