mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Fix crashes related to setSpan(-1 ... -1) errors
Fixes b/7652661 In some circumstnaces, when hiding the window, the logger tries to capture the TextView contents and restore the cursor position based on the values stored in LatinIME. However, the IME may not know the cursor position. This fix does two things 1) doesn't try to reposition the cursor if the TextView contents are not to be captured, and 2) if the cursor position is unknown (i.e., == -1), doesn't try to move it back. Change-Id: I3976aaccf58c18f892c3a8530218ae52bcac9989
This commit is contained in:
parent
aa5a3e84ad
commit
b10ec5319b
@ -925,18 +925,20 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||
public static void latinIME_onWindowHidden(final int savedSelectionStart,
|
||||
final int savedSelectionEnd, final InputConnection ic) {
|
||||
if (ic != null) {
|
||||
// Capture the TextView contents. This will trigger onUpdateSelection(), so we
|
||||
// set sLatinIMEExpectingUpdateSelection so that when onUpdateSelection() is called,
|
||||
// it can tell that it was generated by the logging code, and not by the user, and
|
||||
// therefore keep user-visible state as is.
|
||||
ic.beginBatchEdit();
|
||||
ic.performContextMenuAction(android.R.id.selectAll);
|
||||
CharSequence charSequence = ic.getSelectedText(0);
|
||||
ic.setSelection(savedSelectionStart, savedSelectionEnd);
|
||||
ic.endBatchEdit();
|
||||
sLatinIMEExpectingUpdateSelection = true;
|
||||
final Object[] values = new Object[2];
|
||||
if (OUTPUT_ENTIRE_BUFFER) {
|
||||
// Capture the TextView contents. This will trigger onUpdateSelection(), so we
|
||||
// set sLatinIMEExpectingUpdateSelection so that when onUpdateSelection() is called,
|
||||
// it can tell that it was generated by the logging code, and not by the user, and
|
||||
// therefore keep user-visible state as is.
|
||||
ic.beginBatchEdit();
|
||||
ic.performContextMenuAction(android.R.id.selectAll);
|
||||
CharSequence charSequence = ic.getSelectedText(0);
|
||||
if (savedSelectionStart != -1 && savedSelectionEnd != -1) {
|
||||
ic.setSelection(savedSelectionStart, savedSelectionEnd);
|
||||
}
|
||||
ic.endBatchEdit();
|
||||
sLatinIMEExpectingUpdateSelection = true;
|
||||
if (TextUtils.isEmpty(charSequence)) {
|
||||
values[0] = false;
|
||||
values[1] = "";
|
||||
|
Loading…
Reference in New Issue
Block a user