Merge "DO NOT MERGE Fix Autohide functionality" into qt-qpr1-dev
This commit is contained in:
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.systemui.statusbar.car;
|
package com.android.systemui.statusbar.car;
|
||||||
|
|
||||||
|
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_OPAQUE;
|
||||||
|
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_SEMI_TRANSPARENT;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
@@ -98,6 +101,8 @@ import com.android.systemui.statusbar.notification.NotificationEntryManager;
|
|||||||
import com.android.systemui.statusbar.notification.VisualStabilityManager;
|
import com.android.systemui.statusbar.notification.VisualStabilityManager;
|
||||||
import com.android.systemui.statusbar.notification.logging.NotificationLogger;
|
import com.android.systemui.statusbar.notification.logging.NotificationLogger;
|
||||||
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
|
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
|
||||||
|
import com.android.systemui.statusbar.phone.AutoHideElement;
|
||||||
|
import com.android.systemui.statusbar.phone.BarTransitions;
|
||||||
import com.android.systemui.statusbar.phone.CollapsedStatusBarFragment;
|
import com.android.systemui.statusbar.phone.CollapsedStatusBarFragment;
|
||||||
import com.android.systemui.statusbar.phone.LightBarController;
|
import com.android.systemui.statusbar.phone.LightBarController;
|
||||||
import com.android.systemui.statusbar.phone.NotificationGroupAlertTransferHelper;
|
import com.android.systemui.statusbar.phone.NotificationGroupAlertTransferHelper;
|
||||||
@@ -121,6 +126,7 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class CarStatusBar extends StatusBar implements CarBatteryController.BatteryViewHandler {
|
public class CarStatusBar extends StatusBar implements CarBatteryController.BatteryViewHandler {
|
||||||
private static final String TAG = "CarStatusBar";
|
private static final String TAG = "CarStatusBar";
|
||||||
|
private static final int MODE_INVALID = -1;
|
||||||
// used to calculate how fast to open or close the window
|
// used to calculate how fast to open or close the window
|
||||||
private static final float DEFAULT_FLING_VELOCITY = 0;
|
private static final float DEFAULT_FLING_VELOCITY = 0;
|
||||||
// max time a fling animation takes
|
// max time a fling animation takes
|
||||||
@@ -267,6 +273,9 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private int mNavigationBarMode;
|
||||||
|
private BarTransitions mNavBarTransitions;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start() {
|
public void start() {
|
||||||
// Non blocking call to connect to car service. Call this early so that we'll be connected
|
// Non blocking call to connect to car service. Call this early so that we'll be connected
|
||||||
@@ -381,6 +390,18 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
|
|||||||
Log.wtf(TAG, " mVolumeChangeCallback failed to connect to car ", e);
|
Log.wtf(TAG, " mVolumeChangeCallback failed to connect to car ", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mAutoHideController.setNavigationBar(new AutoHideElement() {
|
||||||
|
@Override
|
||||||
|
public void synchronizeState() {
|
||||||
|
checkNavBarModes();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSemiTransparent() {
|
||||||
|
return mNavigationBarMode == MODE_SEMI_TRANSPARENT;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -420,6 +441,65 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
|
|||||||
mUserSwitcherController = Dependency.get(UserSwitcherController.class);
|
mUserSwitcherController = Dependency.get(UserSwitcherController.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSystemUiVisibility(int displayId, int vis, int fullscreenStackVis,
|
||||||
|
int dockedStackVis, int mask, Rect fullscreenStackBounds, Rect dockedStackBounds,
|
||||||
|
boolean navbarColorManagedByIme) {
|
||||||
|
// Ensure we store the systemUiVisibility flags before the super call overwrites it.
|
||||||
|
int oldVal = getSystemUiVisibility();
|
||||||
|
|
||||||
|
super.setSystemUiVisibility(displayId, vis, fullscreenStackVis, dockedStackVis, mask,
|
||||||
|
fullscreenStackBounds, dockedStackBounds, navbarColorManagedByIme);
|
||||||
|
|
||||||
|
if (displayId != getDisplayId()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int newVal = (oldVal & ~mask) | (vis & mask);
|
||||||
|
|
||||||
|
// update navigation bar mode
|
||||||
|
int nbMode = mNavigationBarWindow == null ? MODE_INVALID : computeNavBarMode(oldVal,
|
||||||
|
newVal);
|
||||||
|
boolean nbModeChanged = nbMode != MODE_INVALID;
|
||||||
|
if (nbModeChanged) {
|
||||||
|
if (mNavigationBarMode != nbMode) {
|
||||||
|
mNavigationBarMode = nbMode;
|
||||||
|
checkNavBarModes();
|
||||||
|
}
|
||||||
|
mAutoHideController.touchAutoHide();
|
||||||
|
}
|
||||||
|
|
||||||
|
mLightBarController.onNavigationVisibilityChanged(
|
||||||
|
vis, mask, nbModeChanged, mNavigationBarMode, navbarColorManagedByIme);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BarTransitions.TransitionMode
|
||||||
|
private int computeNavBarMode(int oldVis, int newVis) {
|
||||||
|
int oldMode = navBarMode(oldVis);
|
||||||
|
int newMode = navBarMode(newVis);
|
||||||
|
if (oldMode == newMode) {
|
||||||
|
return -1; // no mode change
|
||||||
|
}
|
||||||
|
return newMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@BarTransitions.TransitionMode
|
||||||
|
private int navBarMode(int vis) {
|
||||||
|
if ((vis & View.NAVIGATION_BAR_TRANSIENT) != 0) {
|
||||||
|
return MODE_SEMI_TRANSPARENT;
|
||||||
|
} else {
|
||||||
|
return MODE_OPAQUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks current navigation bar mode and make transitions.
|
||||||
|
*/
|
||||||
|
private void checkNavBarModes() {
|
||||||
|
boolean anim = isDeviceInteractive() && mBottomNavBarVisible;
|
||||||
|
mNavBarTransitions.transitionTo(mNavigationBarMode, anim);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUpQuickSettingsTilePanel() {
|
protected void setUpQuickSettingsTilePanel() {
|
||||||
// ignore.
|
// ignore.
|
||||||
@@ -925,7 +1005,9 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
|
|||||||
mNotificationViewController.setIsInForeground(false);
|
mNotificationViewController.setIsInForeground(false);
|
||||||
// let the status bar know that the panel is closed
|
// let the status bar know that the panel is closed
|
||||||
setPanelExpanded(false);
|
setPanelExpanded(false);
|
||||||
|
mAutoHideController.userAutoHide();
|
||||||
} else {
|
} else {
|
||||||
|
mAutoHideController.cancelAutoHide();
|
||||||
mNotificationViewController.setIsInForeground(true);
|
mNotificationViewController.setIsInForeground(true);
|
||||||
// let the status bar know that the panel is open
|
// let the status bar know that the panel is open
|
||||||
mNotificationView.setVisibleNotificationsAsSeen();
|
mNotificationView.setVisibleNotificationsAsSeen();
|
||||||
@@ -1000,6 +1082,8 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
|
|||||||
if (mShowBottom) {
|
if (mShowBottom) {
|
||||||
mNavigationBarWindow = (ViewGroup) View.inflate(mContext,
|
mNavigationBarWindow = (ViewGroup) View.inflate(mContext,
|
||||||
R.layout.navigation_bar_window, null);
|
R.layout.navigation_bar_window, null);
|
||||||
|
mNavBarTransitions = new BarTransitions(mNavigationBarWindow,
|
||||||
|
R.drawable.nav_background);
|
||||||
}
|
}
|
||||||
if (mShowLeft) {
|
if (mShowLeft) {
|
||||||
mLeftNavigationBarWindow = (ViewGroup) View.inflate(mContext,
|
mLeftNavigationBarWindow = (ViewGroup) View.inflate(mContext,
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class AutoHideController implements CommandQueue.Callbacks {
|
|||||||
private final NotificationRemoteInputManager mRemoteInputManager;
|
private final NotificationRemoteInputManager mRemoteInputManager;
|
||||||
private final CommandQueue mCommandQueue;
|
private final CommandQueue mCommandQueue;
|
||||||
private StatusBar mStatusBar;
|
private StatusBar mStatusBar;
|
||||||
private NavigationBarFragment mNavigationBar;
|
private AutoHideElement mNavigationBar;
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
int mDisplayId;
|
int mDisplayId;
|
||||||
@@ -85,11 +85,11 @@ public class AutoHideController implements CommandQueue.Callbacks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setStatusBar(StatusBar statusBar) {
|
public void setStatusBar(StatusBar statusBar) {
|
||||||
mStatusBar = statusBar;
|
mStatusBar = statusBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setNavigationBar(NavigationBarFragment navigationBar) {
|
public void setNavigationBar(AutoHideElement navigationBar) {
|
||||||
mNavigationBar = navigationBar;
|
mNavigationBar = navigationBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +158,8 @@ public class AutoHideController implements CommandQueue.Callbacks {
|
|||||||
mAutoHideSuspended = (mSystemUiVisibility & getTransientMask()) != 0;
|
mAutoHideSuspended = (mSystemUiVisibility & getTransientMask()) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void touchAutoHide() {
|
/** Schedule auto hide if necessary otherwise cancel any pending runnables. */
|
||||||
|
public void touchAutoHide() {
|
||||||
// update transient bar auto hide
|
// update transient bar auto hide
|
||||||
if ((hasStatusBar() && mStatusBar.getStatusBarMode() == MODE_SEMI_TRANSPARENT)
|
if ((hasStatusBar() && mStatusBar.getStatusBarMode() == MODE_SEMI_TRANSPARENT)
|
||||||
|| hasNavigationBar() && mNavigationBar.isSemiTransparent()) {
|
|| hasNavigationBar() && mNavigationBar.isSemiTransparent()) {
|
||||||
@@ -172,13 +173,14 @@ public class AutoHideController implements CommandQueue.Callbacks {
|
|||||||
if (hasStatusBar()) {
|
if (hasStatusBar()) {
|
||||||
return () -> mStatusBar.checkBarModes();
|
return () -> mStatusBar.checkBarModes();
|
||||||
} else if (hasNavigationBar()) {
|
} else if (hasNavigationBar()) {
|
||||||
return () -> mNavigationBar.checkNavBarModes();
|
return () -> mNavigationBar.synchronizeState();
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cancelAutoHide() {
|
/** Remove any scheduled auto hide runnables. */
|
||||||
|
public void cancelAutoHide() {
|
||||||
mAutoHideSuspended = false;
|
mAutoHideSuspended = false;
|
||||||
mHandler.removeCallbacks(mAutoHide);
|
mHandler.removeCallbacks(mAutoHide);
|
||||||
}
|
}
|
||||||
@@ -202,7 +204,8 @@ public class AutoHideController implements CommandQueue.Callbacks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void userAutoHide() {
|
/** Schedule auto hide. */
|
||||||
|
public void userAutoHide() {
|
||||||
cancelAutoHide();
|
cancelAutoHide();
|
||||||
mHandler.postDelayed(mAutoHide, 350); // longer than app gesture -> flag clear
|
mHandler.postDelayed(mAutoHide, 350); // longer than app gesture -> flag clear
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* 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.phone;
|
||||||
|
|
||||||
|
/** An interface for a UI element controlled by the {@link AutoHideController}. */
|
||||||
|
public interface AutoHideElement {
|
||||||
|
/**
|
||||||
|
* Synchronizes the UI State of this {@link AutoHideElement}. This method is posted as a
|
||||||
|
* {@link Runnable} on the main thread.
|
||||||
|
*/
|
||||||
|
void synchronizeState();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns {@code true} if the {@link AutoHideElement} is in a
|
||||||
|
* {@link BarTransitions#MODE_SEMI_TRANSPARENT} state.
|
||||||
|
*/
|
||||||
|
boolean isSemiTransparent();
|
||||||
|
}
|
||||||
@@ -120,7 +120,7 @@ import javax.inject.Inject;
|
|||||||
* on clicks and view states of the nav bar.
|
* on clicks and view states of the nav bar.
|
||||||
*/
|
*/
|
||||||
public class NavigationBarFragment extends LifecycleFragment implements Callbacks,
|
public class NavigationBarFragment extends LifecycleFragment implements Callbacks,
|
||||||
NavigationModeController.ModeChangedListener {
|
NavigationModeController.ModeChangedListener, AutoHideElement {
|
||||||
|
|
||||||
public static final String TAG = "NavigationBar";
|
public static final String TAG = "NavigationBar";
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
@@ -970,10 +970,18 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
|||||||
mAutoHideController.setNavigationBar(this);
|
mAutoHideController.setNavigationBar(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AutoHideElement
|
||||||
|
@Override
|
||||||
public boolean isSemiTransparent() {
|
public boolean isSemiTransparent() {
|
||||||
return mNavigationBarMode == MODE_SEMI_TRANSPARENT;
|
return mNavigationBarMode == MODE_SEMI_TRANSPARENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AutoHideElement
|
||||||
|
@Override
|
||||||
|
public void synchronizeState() {
|
||||||
|
checkNavBarModes();
|
||||||
|
}
|
||||||
|
|
||||||
private void checkBarModes() {
|
private void checkBarModes() {
|
||||||
// We only have status bar on default display now.
|
// We only have status bar on default display now.
|
||||||
if (mIsOnDefaultDisplay) {
|
if (mIsOnDefaultDisplay) {
|
||||||
|
|||||||
@@ -2205,6 +2205,14 @@ public class StatusBar extends SystemUI implements DemoMode,
|
|||||||
navbarColorManagedByIme);
|
navbarColorManagedByIme);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected final int getSystemUiVisibility() {
|
||||||
|
return mSystemUiVisibility;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final int getDisplayId() {
|
||||||
|
return mDisplayId;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showWirelessChargingAnimation(int batteryLevel) {
|
public void showWirelessChargingAnimation(int batteryLevel) {
|
||||||
if (mDozing || mKeyguardManager.isKeyguardLocked()) {
|
if (mDozing || mKeyguardManager.isKeyguardLocked()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user