Fix issue with search in ActionBar

This pull request fixes an issue where searching for the "from:" keyword in the ActionBar would cause the app to crash. The issue was caused by attempting to access a line in the layout that did not exist. The solution is to add a check to ensure that the line offset is within the bounds of the layout before attempting to access it. This fix will prevent the app from crashing when searching for "from:" in the ActionBar.
This commit is contained in:
Laky64 2022-12-29 13:57:29 +01:00 committed by GitHub
parent 2c71f6c92b
commit 711f26cb11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -147,6 +147,7 @@ public class EditTextEffects extends EditText {
Layout layout = getLayout();
if (text instanceof Spannable && layout != null) {
if (start > layout.getLineCount()) return;
int line = layout.getLineForOffset(start);
int x = (int) layout.getPrimaryHorizontal(start);
int y = (int) ((layout.getLineTop(line) + layout.getLineBottom(line)) / 2f);