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

Commit f2834842 authored by Miranda Kephart's avatar Miranda Kephart
Browse files

Limit the maxLines of the clipboard TextView to a minimum of 1

The TextView can crash if the maxLines is set to a negative value;
this shouldn't happen in general but is possible in edge cases/if
the view is measured at an unexpected time, due to how we're calculating
the max lines.

Bug: 317445600
Fix: 317445600
Test: tested no apparent behavior change; crash is not directly
reproducible but ensuring the maxLines is never less than 1 should
prevent the crash going forward.
Flag: NONE

Change-Id: I4da647b21d481e0baca9db991b4b6d39be56ffcb
parent a9d2c1f1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -143,7 +143,7 @@ public class ClipboardOverlayView extends DraggableConstraintLayout {
        mTextPreview.getViewTreeObserver().addOnPreDrawListener(() -> {
            int availableHeight = mTextPreview.getHeight()
                    - (mTextPreview.getPaddingTop() + mTextPreview.getPaddingBottom());
            mTextPreview.setMaxLines(availableHeight / mTextPreview.getLineHeight());
            mTextPreview.setMaxLines(Math.max(availableHeight / mTextPreview.getLineHeight(), 1));
            return true;
        });
        super.onFinishInflate();