Merge "Fix privacy chip overlapped by status bar icons" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
4dac733fa4
@@ -59,7 +59,7 @@ import com.android.systemui.statusbar.notification.PropertyAnimator;
|
|||||||
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
|
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
|
||||||
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
|
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
|
||||||
import com.android.systemui.statusbar.phone.fragment.StatusBarIconBlocklistKt;
|
import com.android.systemui.statusbar.phone.fragment.StatusBarIconBlocklistKt;
|
||||||
import com.android.systemui.statusbar.phone.fragment.StatusBarSystemEventAnimator;
|
import com.android.systemui.statusbar.phone.fragment.StatusBarSystemEventDefaultAnimator;
|
||||||
import com.android.systemui.statusbar.policy.BatteryController;
|
import com.android.systemui.statusbar.policy.BatteryController;
|
||||||
import com.android.systemui.statusbar.policy.ConfigurationController;
|
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||||
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
||||||
@@ -75,6 +75,8 @@ import java.util.concurrent.Executor;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import kotlin.Unit;
|
||||||
|
|
||||||
/** View Controller for {@link com.android.systemui.statusbar.phone.KeyguardStatusBarView}. */
|
/** View Controller for {@link com.android.systemui.statusbar.phone.KeyguardStatusBarView}. */
|
||||||
public class KeyguardStatusBarViewController extends ViewController<KeyguardStatusBarView> {
|
public class KeyguardStatusBarViewController extends ViewController<KeyguardStatusBarView> {
|
||||||
private static final String TAG = "KeyguardStatusBarViewController";
|
private static final String TAG = "KeyguardStatusBarViewController";
|
||||||
@@ -123,7 +125,8 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
|
|||||||
public void onDensityOrFontScaleChanged() {
|
public void onDensityOrFontScaleChanged() {
|
||||||
mView.loadDimens();
|
mView.loadDimens();
|
||||||
// The animator is dependent on resources for offsets
|
// The animator is dependent on resources for offsets
|
||||||
mSystemEventAnimator = new StatusBarSystemEventAnimator(mView, getResources());
|
mSystemEventAnimator =
|
||||||
|
getSystemEventAnimator(mSystemEventAnimator.isAnimationRunning());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -248,7 +251,8 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
|
|||||||
private int mStatusBarState;
|
private int mStatusBarState;
|
||||||
private boolean mDozing;
|
private boolean mDozing;
|
||||||
private boolean mShowingKeyguardHeadsUp;
|
private boolean mShowingKeyguardHeadsUp;
|
||||||
private StatusBarSystemEventAnimator mSystemEventAnimator;
|
private StatusBarSystemEventDefaultAnimator mSystemEventAnimator;
|
||||||
|
private float mSystemEventAnimatorAlpha = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The alpha value to be set on the View. If -1, this value is to be ignored.
|
* The alpha value to be set on the View. If -1, this value is to be ignored.
|
||||||
@@ -324,7 +328,7 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
|
|||||||
|
|
||||||
mView.setKeyguardUserAvatarEnabled(
|
mView.setKeyguardUserAvatarEnabled(
|
||||||
!mStatusBarUserChipViewModel.getChipEnabled());
|
!mStatusBarUserChipViewModel.getChipEnabled());
|
||||||
mSystemEventAnimator = new StatusBarSystemEventAnimator(mView, r);
|
mSystemEventAnimator = getSystemEventAnimator(/* isAnimationRunning */ false);
|
||||||
|
|
||||||
mDisableStateTracker = new DisableStateTracker(
|
mDisableStateTracker = new DisableStateTracker(
|
||||||
/* mask1= */ DISABLE_SYSTEM_INFO,
|
/* mask1= */ DISABLE_SYSTEM_INFO,
|
||||||
@@ -480,6 +484,10 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
|
|||||||
* (1.0f - mKeyguardHeadsUpShowingAmount);
|
* (1.0f - mKeyguardHeadsUpShowingAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mSystemEventAnimator.isAnimationRunning()) {
|
||||||
|
newAlpha = Math.min(newAlpha, mSystemEventAnimatorAlpha);
|
||||||
|
}
|
||||||
|
|
||||||
boolean hideForBypass =
|
boolean hideForBypass =
|
||||||
mFirstBypassAttempt && mKeyguardUpdateMonitor.shouldListenForFace()
|
mFirstBypassAttempt && mKeyguardUpdateMonitor.shouldListenForFace()
|
||||||
|| mDelayShowingKeyguardStatusBar;
|
|| mDelayShowingKeyguardStatusBar;
|
||||||
@@ -488,7 +496,7 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
|
|||||||
&& !mDozing
|
&& !mDozing
|
||||||
&& !hideForBypass
|
&& !hideForBypass
|
||||||
&& !mDisableStateTracker.isDisabled()
|
&& !mDisableStateTracker.isDisabled()
|
||||||
? View.VISIBLE : View.INVISIBLE;
|
? View.VISIBLE : View.INVISIBLE;
|
||||||
|
|
||||||
updateViewState(newAlpha, newVisibility);
|
updateViewState(newAlpha, newVisibility);
|
||||||
}
|
}
|
||||||
@@ -614,4 +622,15 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
|
|||||||
updateBlockedIcons();
|
updateBlockedIcons();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private StatusBarSystemEventDefaultAnimator getSystemEventAnimator(boolean isAnimationRunning) {
|
||||||
|
return new StatusBarSystemEventDefaultAnimator(getResources(), (alpha) -> {
|
||||||
|
mSystemEventAnimatorAlpha = alpha;
|
||||||
|
updateViewState();
|
||||||
|
return Unit.INSTANCE;
|
||||||
|
}, (translationX) -> {
|
||||||
|
mView.setTranslationX(translationX);
|
||||||
|
return Unit.INSTANCE;
|
||||||
|
}, isAnimationRunning);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,19 +26,39 @@ import com.android.systemui.statusbar.events.STATUS_BAR_X_MOVE_IN
|
|||||||
import com.android.systemui.statusbar.events.STATUS_BAR_X_MOVE_OUT
|
import com.android.systemui.statusbar.events.STATUS_BAR_X_MOVE_OUT
|
||||||
import com.android.systemui.statusbar.events.SystemStatusAnimationCallback
|
import com.android.systemui.statusbar.events.SystemStatusAnimationCallback
|
||||||
import com.android.systemui.util.animation.AnimationUtil.Companion.frames
|
import com.android.systemui.util.animation.AnimationUtil.Companion.frames
|
||||||
|
import com.android.systemui.util.doOnCancel
|
||||||
|
import com.android.systemui.util.doOnEnd
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An implementation of [StatusBarSystemEventDefaultAnimator], applying the onAlphaChanged and
|
||||||
|
* onTranslationXChanged callbacks directly to the provided animatedView.
|
||||||
|
*/
|
||||||
|
class StatusBarSystemEventAnimator @JvmOverloads constructor(
|
||||||
|
val animatedView: View,
|
||||||
|
resources: Resources,
|
||||||
|
isAnimationRunning: Boolean = false
|
||||||
|
) : StatusBarSystemEventDefaultAnimator(
|
||||||
|
resources = resources,
|
||||||
|
onAlphaChanged = animatedView::setAlpha,
|
||||||
|
onTranslationXChanged = animatedView::setTranslationX,
|
||||||
|
isAnimationRunning = isAnimationRunning
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tied directly to [SystemStatusAnimationScheduler]. Any StatusBar-like thing (keyguard, collapsed
|
* Tied directly to [SystemStatusAnimationScheduler]. Any StatusBar-like thing (keyguard, collapsed
|
||||||
* status bar fragment), can just feed this an animatable view to get the default system status
|
* status bar fragment), can use this Animator to get the default system status animation. It simply
|
||||||
* animation.
|
* needs to implement the onAlphaChanged and onTranslationXChanged callbacks.
|
||||||
*
|
*
|
||||||
* This animator relies on resources, and should be recreated whenever resources are updated. While
|
* This animator relies on resources, and should be recreated whenever resources are updated. While
|
||||||
* this class could be used directly as the animation callback, it's probably best to forward calls
|
* this class could be used directly as the animation callback, it's probably best to forward calls
|
||||||
* to it so that it can be recreated at any moment without needing to remove/add callback.
|
* to it so that it can be recreated at any moment without needing to remove/add callback.
|
||||||
*/
|
*/
|
||||||
class StatusBarSystemEventAnimator(
|
|
||||||
val animatedView: View,
|
open class StatusBarSystemEventDefaultAnimator @JvmOverloads constructor(
|
||||||
resources: Resources
|
resources: Resources,
|
||||||
|
private val onAlphaChanged: (Float) -> Unit,
|
||||||
|
private val onTranslationXChanged: (Float) -> Unit,
|
||||||
|
var isAnimationRunning: Boolean = false
|
||||||
) : SystemStatusAnimationCallback {
|
) : SystemStatusAnimationCallback {
|
||||||
private val translationXIn: Int = resources.getDimensionPixelSize(
|
private val translationXIn: Int = resources.getDimensionPixelSize(
|
||||||
R.dimen.ongoing_appops_chip_animation_in_status_bar_translation_x)
|
R.dimen.ongoing_appops_chip_animation_in_status_bar_translation_x)
|
||||||
@@ -46,18 +66,19 @@ class StatusBarSystemEventAnimator(
|
|||||||
R.dimen.ongoing_appops_chip_animation_out_status_bar_translation_x)
|
R.dimen.ongoing_appops_chip_animation_out_status_bar_translation_x)
|
||||||
|
|
||||||
override fun onSystemEventAnimationBegin(): Animator {
|
override fun onSystemEventAnimationBegin(): Animator {
|
||||||
|
isAnimationRunning = true
|
||||||
val moveOut = ValueAnimator.ofFloat(0f, 1f).apply {
|
val moveOut = ValueAnimator.ofFloat(0f, 1f).apply {
|
||||||
duration = 23.frames
|
duration = 23.frames
|
||||||
interpolator = STATUS_BAR_X_MOVE_OUT
|
interpolator = STATUS_BAR_X_MOVE_OUT
|
||||||
addUpdateListener {
|
addUpdateListener {
|
||||||
animatedView.translationX = -(translationXIn * animatedValue as Float)
|
onTranslationXChanged(-(translationXIn * animatedValue as Float))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val alphaOut = ValueAnimator.ofFloat(1f, 0f).apply {
|
val alphaOut = ValueAnimator.ofFloat(1f, 0f).apply {
|
||||||
duration = 8.frames
|
duration = 8.frames
|
||||||
interpolator = null
|
interpolator = null
|
||||||
addUpdateListener {
|
addUpdateListener {
|
||||||
animatedView.alpha = animatedValue as Float
|
onAlphaChanged(animatedValue as Float)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,13 +88,13 @@ class StatusBarSystemEventAnimator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onSystemEventAnimationFinish(hasPersistentDot: Boolean): Animator {
|
override fun onSystemEventAnimationFinish(hasPersistentDot: Boolean): Animator {
|
||||||
animatedView.translationX = translationXOut.toFloat()
|
onTranslationXChanged(translationXOut.toFloat())
|
||||||
val moveIn = ValueAnimator.ofFloat(1f, 0f).apply {
|
val moveIn = ValueAnimator.ofFloat(1f, 0f).apply {
|
||||||
duration = 23.frames
|
duration = 23.frames
|
||||||
startDelay = 7.frames
|
startDelay = 7.frames
|
||||||
interpolator = STATUS_BAR_X_MOVE_IN
|
interpolator = STATUS_BAR_X_MOVE_IN
|
||||||
addUpdateListener {
|
addUpdateListener {
|
||||||
animatedView.translationX = translationXOut * animatedValue as Float
|
onTranslationXChanged(translationXOut * animatedValue as Float)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val alphaIn = ValueAnimator.ofFloat(0f, 1f).apply {
|
val alphaIn = ValueAnimator.ofFloat(0f, 1f).apply {
|
||||||
@@ -81,13 +102,14 @@ class StatusBarSystemEventAnimator(
|
|||||||
startDelay = 11.frames
|
startDelay = 11.frames
|
||||||
interpolator = null
|
interpolator = null
|
||||||
addUpdateListener {
|
addUpdateListener {
|
||||||
animatedView.alpha = animatedValue as Float
|
onAlphaChanged(animatedValue as Float)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val animatorSet = AnimatorSet()
|
val animatorSet = AnimatorSet()
|
||||||
animatorSet.playTogether(moveIn, alphaIn)
|
animatorSet.playTogether(moveIn, alphaIn)
|
||||||
|
animatorSet.doOnEnd { isAnimationRunning = false }
|
||||||
|
animatorSet.doOnCancel { isAnimationRunning = false }
|
||||||
return animatorSet
|
return animatorSet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user