diff --git a/embedding/android/GeckoInputConnection.java b/embedding/android/GeckoInputConnection.java index 7e02e8cb9d2..93016008ec2 100644 --- a/embedding/android/GeckoInputConnection.java +++ b/embedding/android/GeckoInputConnection.java @@ -488,7 +488,7 @@ public class GeckoInputConnection //Log.d("GeckoAppJava", "IME: notifyTextChange"); if (!text.contentEquals(GeckoApp.surfaceView.mEditable)) - GeckoApp.surfaceView.setupEditable(text); + GeckoApp.surfaceView.setEditable(text); if (mUpdateRequest == null) return; diff --git a/embedding/android/GeckoSurfaceView.java b/embedding/android/GeckoSurfaceView.java index acbb7e3a85d..80b6dbf7759 100644 --- a/embedding/android/GeckoSurfaceView.java +++ b/embedding/android/GeckoSurfaceView.java @@ -87,7 +87,7 @@ class GeckoSurfaceView mSurfaceLock = new ReentrantLock(); mEditableFactory = Editable.Factory.getInstance(); - setupEditable(""); + initEditable(""); mIMEState = IME_STATE_DISABLED; mIMETypeHint = ""; mIMEActionHint = ""; @@ -375,7 +375,15 @@ class GeckoSurfaceView return inputConnection; } - public void setupEditable(String contents) + public void setEditable(String contents) + { + mEditable.removeSpan(inputConnection); + mEditable.replace(0, mEditable.length(), contents); + mEditable.setSpan(inputConnection, 0, contents.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); + Selection.setSelection(mEditable, contents.length()); + } + + public void initEditable(String contents) { mEditable = mEditableFactory.newEditable(contents); mEditable.setSpan(inputConnection, 0, contents.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);