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

Commit f3c0ef0e authored by c_mallik's avatar c_mallik
Browse files

Contacts: Fix IndexOutOfBoundException while setting the spannable text index.

This can occur in a scenerio during the process of building new views and editing
input entered text. Added check to prevent cursor index going beyond the entered
data text length and also for negative index.

CRs-Fixed: 186249
parent 335adff3
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -1728,6 +1728,14 @@ public final class EditContactActivity extends Activity implements View.OnClickL
        if (focusChild != null) {
            focusChild.requestFocus();
            if (focusChild instanceof EditText) {
                // Index ends beyond data length.
                if (entry.requestCursor > entry.data.length()) {
                    entry.requestCursor = entry.data.length();
                }
                // Index starts before 0. Set the cursor offset of the selection text.
                if (entry.requestCursor < 0) {
                    entry.requestCursor = ((EditText) focusChild).getSelectionStart();
                }
                ((EditText) focusChild).setSelection(entry.requestCursor);
            }
        }