Merge "Don't keep a list of AutoHideUiElements" into rvc-dev am: 5be3a74263 am: 71bc36d6a7
Change-Id: I3f6d735866fcecadc3f022768b92b10bfbcb8bbc
This commit is contained in:
@@ -150,7 +150,7 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
ex.rethrowFromSystemServer();
|
||||
}
|
||||
|
||||
mAutoHideController.addAutoHideUiElement(new AutoHideUiElement() {
|
||||
mAutoHideController.setNavigationBar(new AutoHideUiElement() {
|
||||
@Override
|
||||
public void synchronizeState() {
|
||||
// No op.
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.systemui.statusbar.phone;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.RemoteException;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Log;
|
||||
import android.view.IWindowManager;
|
||||
import android.view.MotionEvent;
|
||||
@@ -27,8 +26,6 @@ import android.view.MotionEvent;
|
||||
import com.android.systemui.dagger.qualifiers.Main;
|
||||
import com.android.systemui.statusbar.AutoHideUiElement;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/** A controller to control all auto-hide things. Also see {@link AutoHideUiElement}. */
|
||||
@@ -38,8 +35,9 @@ public class AutoHideController {
|
||||
|
||||
private final IWindowManager mWindowManagerService;
|
||||
private final Handler mHandler;
|
||||
private final Set<AutoHideUiElement> mElements;
|
||||
|
||||
private AutoHideUiElement mStatusBar;
|
||||
private AutoHideUiElement mNavigationBar;
|
||||
private int mDisplayId;
|
||||
|
||||
private boolean mAutoHideSuspended;
|
||||
@@ -55,28 +53,24 @@ public class AutoHideController {
|
||||
IWindowManager iWindowManager) {
|
||||
mHandler = handler;
|
||||
mWindowManagerService = iWindowManager;
|
||||
mElements = new ArraySet<>();
|
||||
|
||||
mDisplayId = context.getDisplayId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an {@link AutoHideUiElement} whose behavior should be controlled by the
|
||||
* Sets a {@link AutoHideUiElement} status bar that should be controlled by the
|
||||
* {@link AutoHideController}.
|
||||
*/
|
||||
public void addAutoHideUiElement(AutoHideUiElement element) {
|
||||
if (element != null) {
|
||||
mElements.add(element);
|
||||
}
|
||||
public void setStatusBar(AutoHideUiElement element) {
|
||||
mStatusBar = element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an {@link AutoHideUiElement} that was previously added.
|
||||
* Sets a {@link AutoHideUiElement} navigation bar that should be controlled by the
|
||||
* {@link AutoHideController}.
|
||||
*/
|
||||
public void removeAutoHideUiElement(AutoHideUiElement element) {
|
||||
if (element != null) {
|
||||
mElements.remove(element);
|
||||
}
|
||||
public void setNavigationBar(AutoHideUiElement element) {
|
||||
mNavigationBar = element;
|
||||
}
|
||||
|
||||
private void hideTransientBars() {
|
||||
@@ -86,8 +80,12 @@ public class AutoHideController {
|
||||
Log.w(TAG, "Cannot get WindowManager");
|
||||
}
|
||||
|
||||
for (AutoHideUiElement element : mElements) {
|
||||
element.hide();
|
||||
if (mStatusBar != null) {
|
||||
mStatusBar.hide();
|
||||
}
|
||||
|
||||
if (mNavigationBar != null) {
|
||||
mNavigationBar.hide();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,15 +119,13 @@ public class AutoHideController {
|
||||
}
|
||||
|
||||
private Runnable getCheckBarModesRunnable() {
|
||||
if (mElements.isEmpty()) {
|
||||
if (mStatusBar != null) {
|
||||
return () -> mStatusBar.synchronizeState();
|
||||
} else if (mNavigationBar != null) {
|
||||
return () -> mNavigationBar.synchronizeState();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return () -> {
|
||||
for (AutoHideUiElement element : mElements) {
|
||||
element.synchronizeState();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void cancelAutoHide() {
|
||||
@@ -147,8 +143,11 @@ public class AutoHideController {
|
||||
&& event.getAction() == MotionEvent.ACTION_OUTSIDE // touch outside the source bar.
|
||||
&& event.getX() == 0 && event.getY() == 0;
|
||||
|
||||
for (AutoHideUiElement element : mElements) {
|
||||
shouldHide &= element.shouldHideOnTouch();
|
||||
if (mStatusBar != null) {
|
||||
shouldHide &= mStatusBar.shouldHideOnTouch();
|
||||
}
|
||||
if (mNavigationBar != null) {
|
||||
shouldHide &= mNavigationBar.shouldHideOnTouch();
|
||||
}
|
||||
|
||||
if (shouldHide) {
|
||||
@@ -162,11 +161,14 @@ public class AutoHideController {
|
||||
}
|
||||
|
||||
private boolean isAnyTransientBarShown() {
|
||||
for (AutoHideUiElement element : mElements) {
|
||||
if (element.isVisible()) {
|
||||
return true;
|
||||
}
|
||||
if (mStatusBar != null && mStatusBar.isVisible()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mNavigationBar != null && mNavigationBar.isVisible()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1075,12 +1075,9 @@ 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;
|
||||
if (mAutoHideController != null) {
|
||||
mAutoHideController.addAutoHideUiElement(mAutoHideUiElement);
|
||||
mAutoHideController.setNavigationBar(mAutoHideUiElement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1073,7 +1073,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
}
|
||||
});
|
||||
|
||||
mAutoHideController.addAutoHideUiElement(new AutoHideUiElement() {
|
||||
mAutoHideController.setStatusBar(new AutoHideUiElement() {
|
||||
@Override
|
||||
public void synchronizeState() {
|
||||
checkBarModes();
|
||||
|
||||
Reference in New Issue
Block a user