Bug 725170 - Reset IME selection when Fennec resumes. r=dougt

This commit is contained in:
Chris Peterson 2012-02-28 18:40:39 -05:00
parent 544a50dece
commit 04d373eb1c
3 changed files with 22 additions and 0 deletions

View File

@ -2109,6 +2109,10 @@ abstract public class GeckoApp
mMainHandler.sendMessage(message);
}
// An Android framework bug can cause an IME crash when focus changes invalidate text
// selection offsets. A workaround is to reset selection when the activity resumes.
GeckoAppShell.resetIMESelection();
int newOrientation = getResources().getConfiguration().orientation;
if (mOrientation != newOrientation) {

View File

@ -579,6 +579,12 @@ public class GeckoAppShell
mInputConnection.returnIMEQueryResult(result, selectionStart, selectionLength);
}
public static void resetIMESelection() {
if (mInputConnection != null) {
mInputConnection.resetSelection();
}
}
static void onXreExit() {
// mLaunchState can only be Launched or GeckoRunning at this point
GeckoApp.setLaunchState(GeckoApp.LaunchState.GeckoExiting);

View File

@ -912,6 +912,18 @@ public class GeckoInputConnection
Selection.setSelection(mEditable, contents.length());
}
public void resetSelection() {
// An Android framework bug can cause a SpannableStringBuilder crash when focus changes
// invalidate text selection offsets. A workaround is to reset selection when the activity
// resumes. More info: https://code.google.com/p/android/issues/detail?id=5164
Editable content = getEditable();
if (content != null) {
Log.d(LOGTAG, "IME: resetSelection");
int length = content.length();
setSelection(length, length);
}
}
// Is a composition active?
private boolean mComposing;
private int mCompositionStart = -1;