diff options
author | Jordan Demeulenaere <jdemeulenaere@google.com> | 2023-02-06 11:19:45 +0100 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-03-23 01:57:03 +0000 |
commit | e7f76d1e81093fec3bf6a1e8093c3ca958bbb19e (patch) | |
tree | aca8a44cfff9421fcab06289ad9b1e37c3ac0302 | |
parent | 9a3cd6fe0fc839e2fb4e60789b8ad84c72cff088 (diff) | |
download | base-e7f76d1e81093fec3bf6a1e8093c3ca958bbb19e.tar.gz |
Make DialogLaunchAnimator.showFromDialog more lenient
Before this CL, calling DialogLaunchAnimator.showFromDialog from a
Dialog that was not shown using DialogLaunchAnimator (i.e. it was shown
using Dialog.show()) would crash. This CL changes that so that we show
the dialog normally instead.
Bug: 267387248
Test: DialogLaunchAnimatorTest
Change-Id: I52f475822cde1162575f6b09b0abe1c77ca132a4
(cherry picked from commit on googleplex-android-review.googlesource.com host: dc5b50c35def901c810149d7095fc861019b5e69)
Merged-In: I52f475822cde1162575f6b09b0abe1c77ca132a4
-rw-r--r-- | packages/SystemUI/animation/src/com/android/systemui/animation/DialogLaunchAnimator.kt | 14 | ||||
-rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/animation/DialogLaunchAnimatorTest.kt | 6 |
2 files changed, 16 insertions, 4 deletions
diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/DialogLaunchAnimator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/DialogLaunchAnimator.kt index b8d78fb208f4..5aa7769d5ace 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/animation/DialogLaunchAnimator.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/DialogLaunchAnimator.kt @@ -304,10 +304,16 @@ constructor( ) { val view = openedDialogs.firstOrNull { it.dialog == animateFrom }?.dialogContentWithBackground - ?: throw IllegalStateException( - "The animateFrom dialog was not animated using " + - "DialogLaunchAnimator.showFrom(View|Dialog)" - ) + if (view == null) { + Log.w( + TAG, + "Showing dialog $dialog normally as the dialog it is shown from was not shown " + + "using DialogLaunchAnimator" + ) + dialog.show() + return + } + showFromView( dialog, view, diff --git a/packages/SystemUI/tests/src/com/android/systemui/animation/DialogLaunchAnimatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/animation/DialogLaunchAnimatorTest.kt index 1e62fd2332c3..316de59692f9 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/animation/DialogLaunchAnimatorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/animation/DialogLaunchAnimatorTest.kt @@ -268,6 +268,12 @@ class DialogLaunchAnimatorTest : SysuiTestCase() { } } + @Test + fun showFromDialogDoesNotCrashWhenShownFromRandomDialog() { + val dialog = createDialogAndShowFromDialog(animateFrom = TestDialog(context)) + dialog.dismiss() + } + private fun createAndShowDialog( animator: DialogLaunchAnimator = dialogLaunchAnimator, ): TestDialog { |