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

Commit 6e8e27bf authored by Mihai Popa's avatar Mihai Popa
Browse files

Fix monkey crash in smart selection animation

In Id65443e93d277c106ea955c867d39e94192cc55d we fixed a monkey crash
happening when the smart selected text had changed while the smart
selection animation was running. However, the change introduced a new
crash, happening when the smart selection result was null. This CL fixes
it, and lets startSelectionActionMode run even when the result is null,
as there seems to be some logic there which should happen in this case.

Bug: 80244201
Test: none
Change-Id: I7f0304446dec85578bdcd5011d2e9ea2737d3c36
(cherry picked from commit a9d27ea8)
Merged-in: I7f0304446dec85578bdcd5011d2e9ea2737d3c36
parent a7641864
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -285,10 +285,14 @@ public final class SelectionActionModeHelper {
        final Layout layout = mTextView.getLayout();
        final Layout layout = mTextView.getLayout();


        final Runnable onAnimationEndCallback = () -> {
        final Runnable onAnimationEndCallback = () -> {
            if (result.mStart >= 0 && result.mEnd <= getText(mTextView).length()
            final SelectionResult startSelectionResult;
            if (result != null && result.mStart >= 0 && result.mEnd <= getText(mTextView).length()
                    && result.mStart <= result.mEnd) {
                    && result.mStart <= result.mEnd) {
                startSelectionActionMode(result);
                startSelectionResult = result;
            } else {
                startSelectionResult = null;
            }
            }
            startSelectionActionMode(startSelectionResult);
        };
        };
        // TODO do not trigger the animation if the change included only non-printable characters
        // TODO do not trigger the animation if the change included only non-printable characters
        final boolean didSelectionChange =
        final boolean didSelectionChange =