Merge "Fix crashes related to setSpan(-1 ... -1) errors"

main
Kurt Partridge 2012-12-03 19:32:40 -08:00 committed by Android (Google) Code Review
commit 8918cb46f6
1 changed files with 12 additions and 10 deletions

View File

@ -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] = "";