Fix privacy chip overlapped by status bar icons
Bug: 262191003 Test: Manual, i.e. showing privacy chip on lockscreen by starting assistant. Change-Id: I0281f8a9bcf4195c5b8ac06369857cd67d2d6702
This commit is contained in:
@@ -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.StackStateAnimator;
|
||||
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.ConfigurationController;
|
||||
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
||||
@@ -75,6 +75,8 @@ import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import kotlin.Unit;
|
||||
|
||||
/** View Controller for {@link com.android.systemui.statusbar.phone.KeyguardStatusBarView}. */
|
||||
public class KeyguardStatusBarViewController extends ViewController<KeyguardStatusBarView> {
|
||||
private static final String TAG = "KeyguardStatusBarViewController";
|
||||
@@ -123,7 +125,8 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
|
||||
public void onDensityOrFontScaleChanged() {
|
||||
mView.loadDimens();
|
||||
// The animator is dependent on resources for offsets
|
||||
mSystemEventAnimator = new StatusBarSystemEventAnimator(mView, getResources());
|
||||
mSystemEventAnimator =
|
||||
getSystemEventAnimator(mSystemEventAnimator.isAnimationRunning());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -248,7 +251,8 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
|
||||
private int mStatusBarState;
|
||||
private boolean mDozing;
|
||||
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.
|
||||
@@ -324,7 +328,7 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
|
||||
|
||||
mView.setKeyguardUserAvatarEnabled(
|
||||
!mStatusBarUserChipViewModel.getChipEnabled());
|
||||
mSystemEventAnimator = new StatusBarSystemEventAnimator(mView, r);
|
||||
mSystemEventAnimator = getSystemEventAnimator(/* isAnimationRunning */ false);
|
||||
|
||||
mDisableStateTracker = new DisableStateTracker(
|
||||
/* mask1= */ DISABLE_SYSTEM_INFO,
|
||||
@@ -480,6 +484,10 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
|
||||
* (1.0f - mKeyguardHeadsUpShowingAmount);
|
||||
}
|
||||
|
||||
if (mSystemEventAnimator.isAnimationRunning()) {
|
||||
newAlpha = Math.min(newAlpha, mSystemEventAnimatorAlpha);
|
||||
}
|
||||
|
||||
boolean hideForBypass =
|
||||
mFirstBypassAttempt && mKeyguardUpdateMonitor.shouldListenForFace()
|
||||
|| mDelayShowingKeyguardStatusBar;
|
||||
@@ -488,7 +496,7 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
|
||||
&& !mDozing
|
||||
&& !hideForBypass
|
||||
&& !mDisableStateTracker.isDisabled()
|
||||
? View.VISIBLE : View.INVISIBLE;
|
||||
? View.VISIBLE : View.INVISIBLE;
|
||||
|
||||
updateViewState(newAlpha, newVisibility);
|
||||
}
|
||||
@@ -614,4 +622,15 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
|
||||
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.SystemStatusAnimationCallback
|
||||
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
|
||||
* status bar fragment), can just feed this an animatable view to get the default system status
|
||||
* animation.
|
||||
* status bar fragment), can use this Animator to get the default system status animation. It simply
|
||||
* needs to implement the onAlphaChanged and onTranslationXChanged callbacks.
|
||||
*
|
||||
* 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
|
||||
* to it so that it can be recreated at any moment without needing to remove/add callback.
|
||||
*/
|
||||
class StatusBarSystemEventAnimator(
|
||||
val animatedView: View,
|
||||
resources: Resources
|
||||
|
||||
open class StatusBarSystemEventDefaultAnimator @JvmOverloads constructor(
|
||||
resources: Resources,
|
||||
private val onAlphaChanged: (Float) -> Unit,
|
||||
private val onTranslationXChanged: (Float) -> Unit,
|
||||
var isAnimationRunning: Boolean = false
|
||||
) : SystemStatusAnimationCallback {
|
||||
private val translationXIn: Int = resources.getDimensionPixelSize(
|
||||
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)
|
||||
|
||||
override fun onSystemEventAnimationBegin(): Animator {
|
||||
isAnimationRunning = true
|
||||
val moveOut = ValueAnimator.ofFloat(0f, 1f).apply {
|
||||
duration = 23.frames
|
||||
interpolator = STATUS_BAR_X_MOVE_OUT
|
||||
addUpdateListener {
|
||||
animatedView.translationX = -(translationXIn * animatedValue as Float)
|
||||
onTranslationXChanged(-(translationXIn * animatedValue as Float))
|
||||
}
|
||||
}
|
||||
val alphaOut = ValueAnimator.ofFloat(1f, 0f).apply {
|
||||
duration = 8.frames
|
||||
interpolator = null
|
||||
addUpdateListener {
|
||||
animatedView.alpha = animatedValue as Float
|
||||
onAlphaChanged(animatedValue as Float)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,13 +88,13 @@ class StatusBarSystemEventAnimator(
|
||||
}
|
||||
|
||||
override fun onSystemEventAnimationFinish(hasPersistentDot: Boolean): Animator {
|
||||
animatedView.translationX = translationXOut.toFloat()
|
||||
onTranslationXChanged(translationXOut.toFloat())
|
||||
val moveIn = ValueAnimator.ofFloat(1f, 0f).apply {
|
||||
duration = 23.frames
|
||||
startDelay = 7.frames
|
||||
interpolator = STATUS_BAR_X_MOVE_IN
|
||||
addUpdateListener {
|
||||
animatedView.translationX = translationXOut * animatedValue as Float
|
||||
onTranslationXChanged(translationXOut * animatedValue as Float)
|
||||
}
|
||||
}
|
||||
val alphaIn = ValueAnimator.ofFloat(0f, 1f).apply {
|
||||
@@ -81,13 +102,14 @@ class StatusBarSystemEventAnimator(
|
||||
startDelay = 11.frames
|
||||
interpolator = null
|
||||
addUpdateListener {
|
||||
animatedView.alpha = animatedValue as Float
|
||||
onAlphaChanged(animatedValue as Float)
|
||||
}
|
||||
}
|
||||
|
||||
val animatorSet = AnimatorSet()
|
||||
animatorSet.playTogether(moveIn, alphaIn)
|
||||
|
||||
animatorSet.doOnEnd { isAnimationRunning = false }
|
||||
animatorSet.doOnCancel { isAnimationRunning = false }
|
||||
return animatorSet
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user