Skip to content

Commit 25ad513

Browse files
jdemeulenaere-googleAndroid Build Coastguard Worker
authored andcommitted
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 dc5b50c) Merged-In: I52f475822cde1162575f6b09b0abe1c77ca132a4 (cherry picked from commit 42fac0d7833a619d16f44d010f9da32fc98ece9b) Merged-In: I52f475822cde1162575f6b09b0abe1c77ca132a4
1 parent 6aba151 commit 25ad513

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

packages/SystemUI/animation/src/com/android/systemui/animation/DialogLaunchAnimator.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,16 @@ constructor(
298298
) {
299299
val view =
300300
openedDialogs.firstOrNull { it.dialog == animateFrom }?.dialogContentWithBackground
301-
?: throw IllegalStateException(
302-
"The animateFrom dialog was not animated using " +
303-
"DialogLaunchAnimator.showFrom(View|Dialog)"
304-
)
301+
if (view == null) {
302+
Log.w(
303+
TAG,
304+
"Showing dialog $dialog normally as the dialog it is shown from was not shown " +
305+
"using DialogLaunchAnimator"
306+
)
307+
dialog.show()
308+
return
309+
}
310+
305311
showFromView(
306312
dialog,
307313
view,

packages/SystemUI/tests/src/com/android/systemui/animation/DialogLaunchAnimatorTest.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,12 @@ class DialogLaunchAnimatorTest : SysuiTestCase() {
260260
assertThat(touchSurface.visibility).isEqualTo(View.GONE)
261261
}
262262

263+
@Test
264+
fun showFromDialogDoesNotCrashWhenShownFromRandomDialog() {
265+
val dialog = createDialogAndShowFromDialog(animateFrom = TestDialog(context))
266+
dialog.dismiss()
267+
}
268+
263269
private fun createAndShowDialog(
264270
animator: DialogLaunchAnimator = dialogLaunchAnimator,
265271
): TestDialog {

0 commit comments

Comments
 (0)