diff options
2 files changed, 9 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessSliderController.java b/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessSliderController.java index 3a90d2b9df7b..503d0bfbc301 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessSliderController.java +++ b/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessSliderController.java @@ -235,8 +235,7 @@ public class BrightnessSliderController extends ViewController<BrightnessSliderV if (mBrightnessWarningToast.isToastActive()) { return; } - mBrightnessWarningToast.show(mView.getContext(), - R.string.quick_settings_brightness_unable_adjust_msg); + mBrightnessWarningToast.show(mView.getContext(), resId); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/settings/brightness/ui/BrightnessWarningToast.kt b/packages/SystemUI/src/com/android/systemui/settings/brightness/ui/BrightnessWarningToast.kt index dfbdaa62ec44..a57b8ddf5ab3 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/brightness/ui/BrightnessWarningToast.kt +++ b/packages/SystemUI/src/com/android/systemui/settings/brightness/ui/BrightnessWarningToast.kt @@ -37,6 +37,9 @@ constructor( private var toastView: View? = null fun show(viewContext: Context, @StringRes resId: Int) { + if (isToastActive()) { + return + } val res = viewContext.resources // Show the brightness warning toast with passing the toast inflation required context, // userId and resId from SystemUI package. @@ -79,13 +82,15 @@ constructor( val inAnimator = systemUIToast.inAnimation inAnimator?.start() - toastView!!.postDelayed({ + toastView?.postDelayed({ val outAnimator = systemUIToast.outAnimation if (outAnimator != null) { outAnimator.start() outAnimator.addListener(object : AnimatorListenerAdapter() { override fun onAnimationEnd(animator: Animator) { - windowManager.removeViewImmediate(toastView) + if (isToastActive()) { + windowManager.removeViewImmediate(toastView) + } toastView = null } }) @@ -94,7 +99,7 @@ constructor( } fun isToastActive(): Boolean { - return toastView != null && toastView!!.isAttachedToWindow + return toastView?.isAttachedToWindow == true } companion object { |