Merge "Generalize AutoHideController to be shared" into rvc-dev
This commit is contained in:
@@ -16,6 +16,12 @@
|
|||||||
|
|
||||||
package com.android.systemui.navigationbar.car;
|
package com.android.systemui.navigationbar.car;
|
||||||
|
|
||||||
|
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
||||||
|
import static android.view.InsetsState.containsType;
|
||||||
|
|
||||||
|
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_SEMI_TRANSPARENT;
|
||||||
|
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARENT;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
import android.inputmethodservice.InputMethodService;
|
import android.inputmethodservice.InputMethodService;
|
||||||
@@ -37,9 +43,12 @@ import com.android.systemui.car.CarDeviceProvisionedController;
|
|||||||
import com.android.systemui.car.CarDeviceProvisionedListener;
|
import com.android.systemui.car.CarDeviceProvisionedListener;
|
||||||
import com.android.systemui.dagger.qualifiers.Main;
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
||||||
|
import com.android.systemui.statusbar.AutoHideUiElement;
|
||||||
import com.android.systemui.statusbar.CommandQueue;
|
import com.android.systemui.statusbar.CommandQueue;
|
||||||
import com.android.systemui.statusbar.NavigationBarController;
|
import com.android.systemui.statusbar.NavigationBarController;
|
||||||
import com.android.systemui.statusbar.SuperStatusBarViewFactory;
|
import com.android.systemui.statusbar.SuperStatusBarViewFactory;
|
||||||
|
import com.android.systemui.statusbar.phone.AutoHideController;
|
||||||
|
import com.android.systemui.statusbar.phone.BarTransitions;
|
||||||
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
|
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
|
||||||
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
||||||
|
|
||||||
@@ -57,6 +66,7 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
|||||||
private final WindowManager mWindowManager;
|
private final WindowManager mWindowManager;
|
||||||
private final CarDeviceProvisionedController mCarDeviceProvisionedController;
|
private final CarDeviceProvisionedController mCarDeviceProvisionedController;
|
||||||
private final CommandQueue mCommandQueue;
|
private final CommandQueue mCommandQueue;
|
||||||
|
private final AutoHideController mAutoHideController;
|
||||||
private final ButtonSelectionStateListener mButtonSelectionStateListener;
|
private final ButtonSelectionStateListener mButtonSelectionStateListener;
|
||||||
private final Handler mMainHandler;
|
private final Handler mMainHandler;
|
||||||
private final Lazy<KeyguardStateController> mKeyguardStateControllerLazy;
|
private final Lazy<KeyguardStateController> mKeyguardStateControllerLazy;
|
||||||
@@ -64,6 +74,8 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
|||||||
private final SuperStatusBarViewFactory mSuperStatusBarViewFactory;
|
private final SuperStatusBarViewFactory mSuperStatusBarViewFactory;
|
||||||
private final ButtonSelectionStateController mButtonSelectionStateController;
|
private final ButtonSelectionStateController mButtonSelectionStateController;
|
||||||
|
|
||||||
|
private final int mDisplayId;
|
||||||
|
|
||||||
private IStatusBarService mBarService;
|
private IStatusBarService mBarService;
|
||||||
private ActivityManagerWrapper mActivityManagerWrapper;
|
private ActivityManagerWrapper mActivityManagerWrapper;
|
||||||
|
|
||||||
@@ -86,12 +98,16 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
|||||||
private boolean mDeviceIsSetUpForUser = true;
|
private boolean mDeviceIsSetUpForUser = true;
|
||||||
private boolean mIsUserSetupInProgress = false;
|
private boolean mIsUserSetupInProgress = false;
|
||||||
|
|
||||||
|
private @BarTransitions.TransitionMode int mNavigationBarMode;
|
||||||
|
private boolean mTransientShown;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public CarNavigationBar(Context context,
|
public CarNavigationBar(Context context,
|
||||||
CarNavigationBarController carNavigationBarController,
|
CarNavigationBarController carNavigationBarController,
|
||||||
WindowManager windowManager,
|
WindowManager windowManager,
|
||||||
DeviceProvisionedController deviceProvisionedController,
|
DeviceProvisionedController deviceProvisionedController,
|
||||||
CommandQueue commandQueue,
|
CommandQueue commandQueue,
|
||||||
|
AutoHideController autoHideController,
|
||||||
ButtonSelectionStateListener buttonSelectionStateListener,
|
ButtonSelectionStateListener buttonSelectionStateListener,
|
||||||
@Main Handler mainHandler,
|
@Main Handler mainHandler,
|
||||||
Lazy<KeyguardStateController> keyguardStateControllerLazy,
|
Lazy<KeyguardStateController> keyguardStateControllerLazy,
|
||||||
@@ -104,12 +120,15 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
|||||||
mCarDeviceProvisionedController = (CarDeviceProvisionedController)
|
mCarDeviceProvisionedController = (CarDeviceProvisionedController)
|
||||||
deviceProvisionedController;
|
deviceProvisionedController;
|
||||||
mCommandQueue = commandQueue;
|
mCommandQueue = commandQueue;
|
||||||
|
mAutoHideController = autoHideController;
|
||||||
mButtonSelectionStateListener = buttonSelectionStateListener;
|
mButtonSelectionStateListener = buttonSelectionStateListener;
|
||||||
mMainHandler = mainHandler;
|
mMainHandler = mainHandler;
|
||||||
mKeyguardStateControllerLazy = keyguardStateControllerLazy;
|
mKeyguardStateControllerLazy = keyguardStateControllerLazy;
|
||||||
mNavigationBarControllerLazy = navigationBarControllerLazy;
|
mNavigationBarControllerLazy = navigationBarControllerLazy;
|
||||||
mSuperStatusBarViewFactory = superStatusBarViewFactory;
|
mSuperStatusBarViewFactory = superStatusBarViewFactory;
|
||||||
mButtonSelectionStateController = buttonSelectionStateController;
|
mButtonSelectionStateController = buttonSelectionStateController;
|
||||||
|
|
||||||
|
mDisplayId = mWindowManager.getDefaultDisplay().getDisplayId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -133,6 +152,23 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
|||||||
ex.rethrowFromSystemServer();
|
ex.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mAutoHideController.addAutoHideUiElement(new AutoHideUiElement() {
|
||||||
|
@Override
|
||||||
|
public void synchronizeState() {
|
||||||
|
// No op.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVisible() {
|
||||||
|
return mTransientShown;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() {
|
||||||
|
clearTransient();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
mDeviceIsSetUpForUser = mCarDeviceProvisionedController.isCurrentUserSetup();
|
mDeviceIsSetUpForUser = mCarDeviceProvisionedController.isCurrentUserSetup();
|
||||||
mIsUserSetupInProgress = mCarDeviceProvisionedController.isCurrentUserSetupInProgress();
|
mIsUserSetupInProgress = mCarDeviceProvisionedController.isCurrentUserSetupInProgress();
|
||||||
mCarDeviceProvisionedController.addCallback(
|
mCarDeviceProvisionedController.addCallback(
|
||||||
@@ -340,6 +376,39 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
|||||||
isKeyboardVisible ? View.GONE : View.VISIBLE);
|
isKeyboardVisible ? View.GONE : View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showTransient(int displayId, int[] types) {
|
||||||
|
if (displayId != mDisplayId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!containsType(types, ITYPE_NAVIGATION_BAR)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mTransientShown) {
|
||||||
|
mTransientShown = true;
|
||||||
|
handleTransientChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void abortTransient(int displayId, int[] types) {
|
||||||
|
if (displayId != mDisplayId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!containsType(types, ITYPE_NAVIGATION_BAR)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
clearTransient();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clearTransient() {
|
||||||
|
if (mTransientShown) {
|
||||||
|
mTransientShown = false;
|
||||||
|
handleTransientChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||||
pw.print(" mTaskStackListener=");
|
pw.print(" mTaskStackListener=");
|
||||||
@@ -347,4 +416,18 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
|||||||
pw.print(" mBottomNavigationBarView=");
|
pw.print(" mBottomNavigationBarView=");
|
||||||
pw.println(mBottomNavigationBarView);
|
pw.println(mBottomNavigationBarView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleTransientChanged() {
|
||||||
|
updateBarMode(mTransientShown ? MODE_SEMI_TRANSPARENT : MODE_TRANSPARENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true if the bar mode is changed.
|
||||||
|
private boolean updateBarMode(int barMode) {
|
||||||
|
if (mNavigationBarMode != barMode) {
|
||||||
|
mNavigationBarMode = barMode;
|
||||||
|
mAutoHideController.touchAutoHide();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import android.os.HandlerThread;
|
|||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.view.Choreographer;
|
import android.view.Choreographer;
|
||||||
|
import android.view.IWindowManager;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
@@ -47,6 +48,7 @@ import com.android.systemui.shared.system.ActivityManagerWrapper;
|
|||||||
import com.android.systemui.shared.system.DevicePolicyManagerWrapper;
|
import com.android.systemui.shared.system.DevicePolicyManagerWrapper;
|
||||||
import com.android.systemui.statusbar.CommandQueue;
|
import com.android.systemui.statusbar.CommandQueue;
|
||||||
import com.android.systemui.statusbar.NavigationBarController;
|
import com.android.systemui.statusbar.NavigationBarController;
|
||||||
|
import com.android.systemui.statusbar.phone.AutoHideController;
|
||||||
import com.android.systemui.statusbar.phone.ConfigurationControllerImpl;
|
import com.android.systemui.statusbar.phone.ConfigurationControllerImpl;
|
||||||
import com.android.systemui.statusbar.policy.ConfigurationController;
|
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||||
import com.android.systemui.statusbar.policy.DataSaverController;
|
import com.android.systemui.statusbar.policy.DataSaverController;
|
||||||
@@ -166,6 +168,14 @@ public class DependencyProvider {
|
|||||||
return new ConfigurationControllerImpl(context);
|
return new ConfigurationControllerImpl(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** */
|
||||||
|
@Singleton
|
||||||
|
@Provides
|
||||||
|
public AutoHideController provideAutoHideController(Context context,
|
||||||
|
@Main Handler mainHandler, IWindowManager iWindowManager) {
|
||||||
|
return new AutoHideController(context, mainHandler, iWindowManager);
|
||||||
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
public ActivityManagerWrapper provideActivityManagerWrapper() {
|
public ActivityManagerWrapper provideActivityManagerWrapper() {
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.systemui.statusbar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common interface for a UI element controlled by
|
||||||
|
* {@link com.android.systemui.statusbar.phone.AutoHideController}. These UI elements automatically
|
||||||
|
* hidden by {@link com.android.systemui.statusbar.phone.AutoHideController} when in some transient
|
||||||
|
* state.
|
||||||
|
*/
|
||||||
|
public interface AutoHideUiElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensures that the {@link AutoHideUiElement} reflects the current expected state. This
|
||||||
|
* method will be posted as a {@link Runnable} in the main thread.
|
||||||
|
*/
|
||||||
|
void synchronizeState();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link com.android.systemui.statusbar.phone.AutoHideController} is responsible for
|
||||||
|
* automatically hiding ui elements that are only shown transiently. This method determines
|
||||||
|
* whether a manual touch should also hide the ui elements that are temporarily visible.
|
||||||
|
*
|
||||||
|
* Note that all {@link AutoHideUiElement} instances should return true for a manual touch to
|
||||||
|
* trigger {@link #hide()} on the ui elements.
|
||||||
|
*/
|
||||||
|
default boolean shouldHideOnTouch() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns true if the {@link AutoHideUiElement} is visible. */
|
||||||
|
boolean isVisible();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to hide the {@link AutoHideUiElement} through the
|
||||||
|
* {@link com.android.systemui.statusbar.phone.AutoHideController}.
|
||||||
|
*/
|
||||||
|
void hide();
|
||||||
|
}
|
||||||
@@ -149,7 +149,6 @@ public class NavigationBarController implements Callbacks {
|
|||||||
AutoHideController autoHideController = isOnDefaultDisplay
|
AutoHideController autoHideController = isOnDefaultDisplay
|
||||||
? Dependency.get(AutoHideController.class)
|
? Dependency.get(AutoHideController.class)
|
||||||
: new AutoHideController(context, mHandler,
|
: new AutoHideController(context, mHandler,
|
||||||
Dependency.get(NotificationRemoteInputManager.class),
|
|
||||||
Dependency.get(IWindowManager.class));
|
Dependency.get(IWindowManager.class));
|
||||||
navBar.setAutoHideController(autoHideController);
|
navBar.setAutoHideController(autoHideController);
|
||||||
navBar.restoreAppearanceAndTransientState();
|
navBar.restoreAppearanceAndTransientState();
|
||||||
|
|||||||
@@ -19,56 +19,64 @@ 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;
|
||||||
|
|
||||||
import com.android.systemui.dagger.qualifiers.Main;
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
import com.android.systemui.statusbar.NotificationRemoteInputManager;
|
import com.android.systemui.statusbar.AutoHideUiElement;
|
||||||
import com.android.systemui.statusbar.phone.dagger.StatusBarPhoneModule;
|
|
||||||
|
|
||||||
/** A controller to control all auto-hide things. */
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
/** A controller to control all auto-hide things. Also see {@link AutoHideUiElement}. */
|
||||||
public class AutoHideController {
|
public class AutoHideController {
|
||||||
private static final String TAG = "AutoHideController";
|
private static final String TAG = "AutoHideController";
|
||||||
|
private static final long AUTO_HIDE_TIMEOUT_MS = 2250;
|
||||||
|
|
||||||
private final IWindowManager mWindowManagerService;
|
private final IWindowManager mWindowManagerService;
|
||||||
|
|
||||||
private final Handler mHandler;
|
private final Handler mHandler;
|
||||||
private final NotificationRemoteInputManager mRemoteInputManager;
|
private final Set<AutoHideUiElement> mElements;
|
||||||
private StatusBar mStatusBar;
|
|
||||||
private NavigationBarFragment mNavigationBar;
|
|
||||||
|
|
||||||
private int mDisplayId;
|
private int mDisplayId;
|
||||||
|
|
||||||
private boolean mAutoHideSuspended;
|
private boolean mAutoHideSuspended;
|
||||||
|
|
||||||
private static final long AUTO_HIDE_TIMEOUT_MS = 2250;
|
|
||||||
|
|
||||||
private final Runnable mAutoHide = () -> {
|
private final Runnable mAutoHide = () -> {
|
||||||
if (isAnyTransientBarShown()) {
|
if (isAnyTransientBarShown()) {
|
||||||
hideTransientBars();
|
hideTransientBars();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
@Inject
|
||||||
* Injected constructor. See {@link StatusBarPhoneModule}.
|
|
||||||
*/
|
|
||||||
public AutoHideController(Context context, @Main Handler handler,
|
public AutoHideController(Context context, @Main Handler handler,
|
||||||
NotificationRemoteInputManager notificationRemoteInputManager,
|
|
||||||
IWindowManager iWindowManager) {
|
IWindowManager iWindowManager) {
|
||||||
mHandler = handler;
|
mHandler = handler;
|
||||||
mRemoteInputManager = notificationRemoteInputManager;
|
|
||||||
mWindowManagerService = iWindowManager;
|
mWindowManagerService = iWindowManager;
|
||||||
|
mElements = new ArraySet<>();
|
||||||
|
|
||||||
mDisplayId = context.getDisplayId();
|
mDisplayId = context.getDisplayId();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setStatusBar(StatusBar statusBar) {
|
/**
|
||||||
mStatusBar = statusBar;
|
* Adds an {@link AutoHideUiElement} whose behavior should be controlled by the
|
||||||
|
* {@link AutoHideController}.
|
||||||
|
*/
|
||||||
|
public void addAutoHideUiElement(AutoHideUiElement element) {
|
||||||
|
if (element != null) {
|
||||||
|
mElements.add(element);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setNavigationBar(NavigationBarFragment navigationBar) {
|
/**
|
||||||
mNavigationBar = navigationBar;
|
* Remove an {@link AutoHideUiElement} that was previously added.
|
||||||
|
*/
|
||||||
|
public void removeAutoHideUiElement(AutoHideUiElement element) {
|
||||||
|
if (element != null) {
|
||||||
|
mElements.remove(element);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hideTransientBars() {
|
private void hideTransientBars() {
|
||||||
@@ -77,11 +85,9 @@ public class AutoHideController {
|
|||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
Log.w(TAG, "Cannot get WindowManager");
|
Log.w(TAG, "Cannot get WindowManager");
|
||||||
}
|
}
|
||||||
if (mStatusBar != null) {
|
|
||||||
mStatusBar.clearTransient();
|
for (AutoHideUiElement element : mElements) {
|
||||||
}
|
element.hide();
|
||||||
if (mNavigationBar != null) {
|
|
||||||
mNavigationBar.clearTransient();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +110,8 @@ public class AutoHideController {
|
|||||||
mAutoHideSuspended = isAnyTransientBarShown();
|
mAutoHideSuspended = isAnyTransientBarShown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void touchAutoHide() {
|
/** Schedules or cancels auto hide behavior based on current system bar state. */
|
||||||
|
public void touchAutoHide() {
|
||||||
// update transient bar auto hide
|
// update transient bar auto hide
|
||||||
if (isAnyTransientBarShown()) {
|
if (isAnyTransientBarShown()) {
|
||||||
scheduleAutoHide();
|
scheduleAutoHide();
|
||||||
@@ -114,13 +121,15 @@ public class AutoHideController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Runnable getCheckBarModesRunnable() {
|
private Runnable getCheckBarModesRunnable() {
|
||||||
if (mStatusBar != null) {
|
if (mElements.isEmpty()) {
|
||||||
return () -> mStatusBar.checkBarModes();
|
|
||||||
} else if (mNavigationBar != null) {
|
|
||||||
return () -> mNavigationBar.checkNavBarModes();
|
|
||||||
} else {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return () -> {
|
||||||
|
for (AutoHideUiElement element : mElements) {
|
||||||
|
element.synchronizeState();
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cancelAutoHide() {
|
private void cancelAutoHide() {
|
||||||
@@ -134,14 +143,15 @@ public class AutoHideController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void checkUserAutoHide(MotionEvent event) {
|
void checkUserAutoHide(MotionEvent event) {
|
||||||
boolean shouldAutoHide = isAnyTransientBarShown()
|
boolean shouldHide = isAnyTransientBarShown()
|
||||||
&& 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;
|
||||||
if (mStatusBar != null) {
|
|
||||||
// a touch outside both bars
|
for (AutoHideUiElement element : mElements) {
|
||||||
shouldAutoHide &= !mRemoteInputManager.getController().isRemoteInputActive();
|
shouldHide &= element.shouldHideOnTouch();
|
||||||
}
|
}
|
||||||
if (shouldAutoHide) {
|
|
||||||
|
if (shouldHide) {
|
||||||
userAutoHide();
|
userAutoHide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,7 +162,11 @@ public class AutoHideController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAnyTransientBarShown() {
|
private boolean isAnyTransientBarShown() {
|
||||||
return (mStatusBar != null && mStatusBar.isTransientShown())
|
for (AutoHideUiElement element : mElements) {
|
||||||
|| mNavigationBar != null && mNavigationBar.isTransientShown();
|
if (element.isVisible()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,8 +105,10 @@ import com.android.systemui.recents.Recents;
|
|||||||
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
||||||
import com.android.systemui.shared.system.QuickStepContract;
|
import com.android.systemui.shared.system.QuickStepContract;
|
||||||
import com.android.systemui.stackdivider.Divider;
|
import com.android.systemui.stackdivider.Divider;
|
||||||
|
import com.android.systemui.statusbar.AutoHideUiElement;
|
||||||
import com.android.systemui.statusbar.CommandQueue;
|
import com.android.systemui.statusbar.CommandQueue;
|
||||||
import com.android.systemui.statusbar.CommandQueue.Callbacks;
|
import com.android.systemui.statusbar.CommandQueue.Callbacks;
|
||||||
|
import com.android.systemui.statusbar.NotificationRemoteInputManager;
|
||||||
import com.android.systemui.statusbar.StatusBarState;
|
import com.android.systemui.statusbar.StatusBarState;
|
||||||
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
|
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
|
||||||
import com.android.systemui.statusbar.phone.ContextualButton.ContextButtonListener;
|
import com.android.systemui.statusbar.phone.ContextualButton.ContextButtonListener;
|
||||||
@@ -166,6 +168,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
|||||||
private int mDisabledFlags2;
|
private int mDisabledFlags2;
|
||||||
private final Lazy<StatusBar> mStatusBarLazy;
|
private final Lazy<StatusBar> mStatusBarLazy;
|
||||||
private final ShadeController mShadeController;
|
private final ShadeController mShadeController;
|
||||||
|
private final NotificationRemoteInputManager mNotificationRemoteInputManager;
|
||||||
private Recents mRecents;
|
private Recents mRecents;
|
||||||
private StatusBar mStatusBar;
|
private StatusBar mStatusBar;
|
||||||
private final Divider mDivider;
|
private final Divider mDivider;
|
||||||
@@ -291,6 +294,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
|||||||
CommandQueue commandQueue, Divider divider,
|
CommandQueue commandQueue, Divider divider,
|
||||||
Optional<Recents> recentsOptional, Lazy<StatusBar> statusBarLazy,
|
Optional<Recents> recentsOptional, Lazy<StatusBar> statusBarLazy,
|
||||||
ShadeController shadeController,
|
ShadeController shadeController,
|
||||||
|
NotificationRemoteInputManager notificationRemoteInputManager,
|
||||||
@Main Handler mainHandler) {
|
@Main Handler mainHandler) {
|
||||||
mAccessibilityManagerWrapper = accessibilityManagerWrapper;
|
mAccessibilityManagerWrapper = accessibilityManagerWrapper;
|
||||||
mDeviceProvisionedController = deviceProvisionedController;
|
mDeviceProvisionedController = deviceProvisionedController;
|
||||||
@@ -300,6 +304,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
|||||||
mSysUiFlagsContainer = sysUiFlagsContainer;
|
mSysUiFlagsContainer = sysUiFlagsContainer;
|
||||||
mStatusBarLazy = statusBarLazy;
|
mStatusBarLazy = statusBarLazy;
|
||||||
mShadeController = shadeController;
|
mShadeController = shadeController;
|
||||||
|
mNotificationRemoteInputManager = notificationRemoteInputManager;
|
||||||
mAssistantAvailable = mAssistManager.getAssistInfoForUser(UserHandle.USER_CURRENT) != null;
|
mAssistantAvailable = mAssistManager.getAssistInfoForUser(UserHandle.USER_CURRENT) != null;
|
||||||
mOverviewProxyService = overviewProxyService;
|
mOverviewProxyService = overviewProxyService;
|
||||||
mNavigationModeController = navigationModeController;
|
mNavigationModeController = navigationModeController;
|
||||||
@@ -614,7 +619,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
|||||||
clearTransient();
|
clearTransient();
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearTransient() {
|
private void clearTransient() {
|
||||||
if (mTransientShown) {
|
if (mTransientShown) {
|
||||||
mTransientShown = false;
|
mTransientShown = false;
|
||||||
handleTransientChanged();
|
handleTransientChanged();
|
||||||
@@ -1048,10 +1053,30 @@ 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) {
|
||||||
mAutoHideController = autoHideController;
|
mAutoHideController = autoHideController;
|
||||||
mAutoHideController.setNavigationBar(this);
|
mAutoHideController.addAutoHideUiElement(new AutoHideUiElement() {
|
||||||
|
@Override
|
||||||
|
public void synchronizeState() {
|
||||||
|
checkNavBarModes();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isTransientShown() {
|
@Override
|
||||||
|
public boolean shouldHideOnTouch() {
|
||||||
|
return !mNotificationRemoteInputManager.getController().isRemoteInputActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVisible() {
|
||||||
|
return isTransientShown();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() {
|
||||||
|
clearTransient();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isTransientShown() {
|
||||||
return mTransientShown;
|
return mTransientShown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -163,6 +163,7 @@ import com.android.systemui.recents.ScreenPinningRequest;
|
|||||||
import com.android.systemui.shared.plugins.PluginManager;
|
import com.android.systemui.shared.plugins.PluginManager;
|
||||||
import com.android.systemui.shared.system.WindowManagerWrapper;
|
import com.android.systemui.shared.system.WindowManagerWrapper;
|
||||||
import com.android.systemui.stackdivider.Divider;
|
import com.android.systemui.stackdivider.Divider;
|
||||||
|
import com.android.systemui.statusbar.AutoHideUiElement;
|
||||||
import com.android.systemui.statusbar.BackDropView;
|
import com.android.systemui.statusbar.BackDropView;
|
||||||
import com.android.systemui.statusbar.CommandQueue;
|
import com.android.systemui.statusbar.CommandQueue;
|
||||||
import com.android.systemui.statusbar.CrossFadeHelper;
|
import com.android.systemui.statusbar.CrossFadeHelper;
|
||||||
@@ -1074,7 +1075,27 @@ public class StatusBar extends SystemUI implements DemoMode,
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mAutoHideController.setStatusBar(this);
|
mAutoHideController.addAutoHideUiElement(new AutoHideUiElement() {
|
||||||
|
@Override
|
||||||
|
public void synchronizeState() {
|
||||||
|
checkBarModes();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldHideOnTouch() {
|
||||||
|
return !mRemoteInputManager.getController().isRemoteInputActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVisible() {
|
||||||
|
return isTransientShown();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() {
|
||||||
|
clearTransient();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
ScrimView scrimBehind = mNotificationShadeWindowView.findViewById(R.id.scrim_behind);
|
ScrimView scrimBehind = mNotificationShadeWindowView.findViewById(R.id.scrim_behind);
|
||||||
ScrimView scrimInFront = mNotificationShadeWindowView.findViewById(R.id.scrim_in_front);
|
ScrimView scrimInFront = mNotificationShadeWindowView.findViewById(R.id.scrim_in_front);
|
||||||
@@ -2228,7 +2249,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
|||||||
clearTransient();
|
clearTransient();
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearTransient() {
|
private void clearTransient() {
|
||||||
if (mTransientShown) {
|
if (mTransientShown) {
|
||||||
mTransientShown = false;
|
mTransientShown = false;
|
||||||
handleTransientChanged();
|
handleTransientChanged();
|
||||||
@@ -4262,7 +4283,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
|||||||
return mGutsManager;
|
return mGutsManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isTransientShown() {
|
private boolean isTransientShown() {
|
||||||
return mTransientShown;
|
return mTransientShown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,14 +16,7 @@
|
|||||||
|
|
||||||
package com.android.systemui.statusbar.phone.dagger;
|
package com.android.systemui.statusbar.phone.dagger;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.view.IWindowManager;
|
|
||||||
|
|
||||||
import com.android.systemui.dagger.qualifiers.Main;
|
|
||||||
import com.android.systemui.statusbar.NotificationRemoteInputManager;
|
|
||||||
import com.android.systemui.statusbar.notification.row.RowContentBindStage;
|
import com.android.systemui.statusbar.notification.row.RowContentBindStage;
|
||||||
import com.android.systemui.statusbar.phone.AutoHideController;
|
|
||||||
import com.android.systemui.statusbar.phone.NotificationGroupAlertTransferHelper;
|
import com.android.systemui.statusbar.phone.NotificationGroupAlertTransferHelper;
|
||||||
import com.android.systemui.statusbar.phone.StatusBar;
|
import com.android.systemui.statusbar.phone.StatusBar;
|
||||||
|
|
||||||
@@ -39,16 +32,6 @@ import dagger.Provides;
|
|||||||
*/
|
*/
|
||||||
@Module
|
@Module
|
||||||
public interface StatusBarPhoneDependenciesModule {
|
public interface StatusBarPhoneDependenciesModule {
|
||||||
/** */
|
|
||||||
@Singleton
|
|
||||||
@Provides
|
|
||||||
static AutoHideController newAutoHideController(Context context,
|
|
||||||
@Main Handler handler,
|
|
||||||
NotificationRemoteInputManager notificationRemoteInputManager,
|
|
||||||
IWindowManager iWindowManager) {
|
|
||||||
return new AutoHideController(context, handler, notificationRemoteInputManager,
|
|
||||||
iWindowManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
@Singleton
|
@Singleton
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ import com.android.systemui.recents.OverviewProxyService;
|
|||||||
import com.android.systemui.recents.Recents;
|
import com.android.systemui.recents.Recents;
|
||||||
import com.android.systemui.stackdivider.Divider;
|
import com.android.systemui.stackdivider.Divider;
|
||||||
import com.android.systemui.statusbar.CommandQueue;
|
import com.android.systemui.statusbar.CommandQueue;
|
||||||
|
import com.android.systemui.statusbar.NotificationRemoteInputManager;
|
||||||
import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper;
|
import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper;
|
||||||
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
|
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
|
||||||
|
|
||||||
@@ -255,6 +256,7 @@ public class NavigationBarFragmentTest extends SysuiBaseFragmentTest {
|
|||||||
Optional.of(mRecents),
|
Optional.of(mRecents),
|
||||||
() -> mock(StatusBar.class),
|
() -> mock(StatusBar.class),
|
||||||
mock(ShadeController.class),
|
mock(ShadeController.class),
|
||||||
|
mock(NotificationRemoteInputManager.class),
|
||||||
mHandler);
|
mHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user