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