Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dc5b50c3 authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

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
parent 02cdf72a
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -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,
+6 −0
Original line number Diff line number Diff line
@@ -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 {