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-02-14 18:17:34 +0000 |
commit | 25ad51382b769944069fb7274b5e1425dc2f8eca (patch) | |
tree | 8419ecbb8c2a284481abbafdfb5d3845baa7aae8 | |
parent | 6aba151873bfae198ef9eceb10f943e18b52d58c (diff) | |
download | base-25ad51382b769944069fb7274b5e1425dc2f8eca.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 dc5b50c35def901c810149d7095fc861019b5e69)
Merged-In: I52f475822cde1162575f6b09b0abe1c77ca132a4
(cherry picked from commit 42fac0d7833a619d16f44d010f9da32fc98ece9b)
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 0f81b0b8d6e0..3889030d5566 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/animation/DialogLaunchAnimator.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/DialogLaunchAnimator.kt @@ -298,10 +298,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 cac4a0e5432c..82af0f418ea4 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/animation/DialogLaunchAnimatorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/animation/DialogLaunchAnimatorTest.kt @@ -260,6 +260,12 @@ class DialogLaunchAnimatorTest : SysuiTestCase() { assertThat(touchSurface.visibility).isEqualTo(View.GONE) } + @Test + fun showFromDialogDoesNotCrashWhenShownFromRandomDialog() { + val dialog = createDialogAndShowFromDialog(animateFrom = TestDialog(context)) + dialog.dismiss() + } + private fun createAndShowDialog( animator: DialogLaunchAnimator = dialogLaunchAnimator, ): TestDialog { |