Loading core/java/android/view/View.java +8 −1 Original line number Diff line number Diff line Loading @@ -8705,7 +8705,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * * <p>When implementing this, you probably also want to implement * {@link #onCheckIsTextEditor()} to indicate you will return a * non-null InputConnection. * non-null InputConnection.</p> * * <p>Also, take good care to fill in the {@link android.view.inputmethod.EditorInfo} * object correctly and in its entirety, so that the connected IME can rely * on its values. For example, {@link android.view.inputmethod.EditorInfo#initialSelStart} * and {@link android.view.inputmethod.EditorInfo#initialSelEnd} members * must be filled in with the correct cursor position for IMEs to work correctly * with your application.</p> * * @param outAttrs Fill in with attribute information about the connection. */ Loading core/java/android/view/inputmethod/EditorInfo.java +78 −61 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ import android.util.Printer; /** * An EditorInfo describes several attributes of a text editing object * that an input method is communicating with (typically an EditText), most * importantly the type of text content it contains. * importantly the type of text content it contains and the current cursor position. */ public class EditorInfo implements InputType, Parcelable { /** Loading Loading @@ -95,7 +95,7 @@ public class EditorInfo implements InputType, Parcelable { public static final int IME_ACTION_DONE = 0x00000006; /** * Bits of {@link #IME_MASK_ACTION}: Like {@link #IME_ACTION_NEXT}, but * Bits of {@link #IME_MASK_ACTION}: like {@link #IME_ACTION_NEXT}, but * for moving to the previous field. This will normally not be used to * specify an action (since it precludes {@link #IME_ACTION_NEXT}), but * can be returned to the app if it sets {@link #IME_FLAG_NAVIGATE_PREVIOUS}. Loading Loading @@ -244,17 +244,33 @@ public class EditorInfo implements InputType, Parcelable { /** * The text offset of the start of the selection at the time editing * began; -1 if not known. Keep in mind some IMEs may not be able * to give their full feature set without knowing the cursor position; * avoid passing -1 here if you can. * begins; -1 if not known. Keep in mind that, without knowing the cursor * position, many IMEs will not be able to offer their full feature set and * may even behave in unpredictable ways: pass the actual cursor position * here if possible at all. * * <p>Also, this needs to be the cursor position <strong>right now</strong>, * not at some point in the past, even if input is starting in the same text field * as before. When the app is filling this object, input is about to start by * definition, and this value will override any value the app may have passed to * {@link InputMethodManager#updateSelection(android.view.View, int, int, int, int)} * before.</p> */ public int initialSelStart = -1; /** * The text offset of the end of the selection at the time editing * began; -1 if not known. Keep in mind some IMEs may not be able * to give their full feature set without knowing the cursor position; * avoid passing -1 here if you can. * <p>The text offset of the end of the selection at the time editing * begins; -1 if not known. Keep in mind that, without knowing the cursor * position, many IMEs will not be able to offer their full feature set and * may behave in unpredictable ways: pass the actual cursor position * here if possible at all.</p> * * <p>Also, this needs to be the cursor position <strong>right now</strong>, * not at some point in the past, even if input is starting in the same text field * as before. When the app is filling this object, input is about to start by * definition, and this value will override any value the app may have passed to * {@link InputMethodManager#updateSelection(android.view.View, int, int, int, int)} * before.</p> */ public int initialSelEnd = -1; Loading @@ -264,8 +280,8 @@ public class EditorInfo implements InputType, Parcelable { * {@link TextUtils#CAP_MODE_CHARACTERS TextUtils.CAP_MODE_CHARACTERS}, * {@link TextUtils#CAP_MODE_WORDS TextUtils.CAP_MODE_WORDS}, and * {@link TextUtils#CAP_MODE_SENTENCES TextUtils.CAP_MODE_SENTENCES}, though * you should generally just take a non-zero value to mean start out in * caps mode. * you should generally just take a non-zero value to mean "start out in * caps mode". */ public int initialCapsMode = 0; Loading Loading @@ -392,7 +408,8 @@ public class EditorInfo implements InputType, Parcelable { /** * Used to make this class parcelable. */ public static final Parcelable.Creator<EditorInfo> CREATOR = new Parcelable.Creator<EditorInfo>() { public static final Parcelable.Creator<EditorInfo> CREATOR = new Parcelable.Creator<EditorInfo>() { public EditorInfo createFromParcel(Parcel source) { EditorInfo res = new EditorInfo(); res.inputType = source.readInt(); Loading core/java/android/view/inputmethod/InputMethodManager.java +8 −0 Original line number Diff line number Diff line Loading @@ -1394,6 +1394,14 @@ public final class InputMethodManager { /** * Report the current selection range. * * <p><strong>Editor authors</strong>, you need to call this method whenever * the cursor moves in your editor. Remember that in addition to doing this, your * editor needs to always supply current cursor values in * {@link EditorInfo#initialSelStart} and {@link EditorInfo#initialSelEnd} every * time {@link android.view.View#onCreateInputConnection(EditorInfo)} is * called, which happens whenever the keyboard shows up or the focus changes * to a text field, among other cases.</p> */ public void updateSelection(View view, int selStart, int selEnd, int candidatesStart, int candidatesEnd) { Loading Loading
core/java/android/view/View.java +8 −1 Original line number Diff line number Diff line Loading @@ -8705,7 +8705,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * * <p>When implementing this, you probably also want to implement * {@link #onCheckIsTextEditor()} to indicate you will return a * non-null InputConnection. * non-null InputConnection.</p> * * <p>Also, take good care to fill in the {@link android.view.inputmethod.EditorInfo} * object correctly and in its entirety, so that the connected IME can rely * on its values. For example, {@link android.view.inputmethod.EditorInfo#initialSelStart} * and {@link android.view.inputmethod.EditorInfo#initialSelEnd} members * must be filled in with the correct cursor position for IMEs to work correctly * with your application.</p> * * @param outAttrs Fill in with attribute information about the connection. */ Loading
core/java/android/view/inputmethod/EditorInfo.java +78 −61 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ import android.util.Printer; /** * An EditorInfo describes several attributes of a text editing object * that an input method is communicating with (typically an EditText), most * importantly the type of text content it contains. * importantly the type of text content it contains and the current cursor position. */ public class EditorInfo implements InputType, Parcelable { /** Loading Loading @@ -95,7 +95,7 @@ public class EditorInfo implements InputType, Parcelable { public static final int IME_ACTION_DONE = 0x00000006; /** * Bits of {@link #IME_MASK_ACTION}: Like {@link #IME_ACTION_NEXT}, but * Bits of {@link #IME_MASK_ACTION}: like {@link #IME_ACTION_NEXT}, but * for moving to the previous field. This will normally not be used to * specify an action (since it precludes {@link #IME_ACTION_NEXT}), but * can be returned to the app if it sets {@link #IME_FLAG_NAVIGATE_PREVIOUS}. Loading Loading @@ -244,17 +244,33 @@ public class EditorInfo implements InputType, Parcelable { /** * The text offset of the start of the selection at the time editing * began; -1 if not known. Keep in mind some IMEs may not be able * to give their full feature set without knowing the cursor position; * avoid passing -1 here if you can. * begins; -1 if not known. Keep in mind that, without knowing the cursor * position, many IMEs will not be able to offer their full feature set and * may even behave in unpredictable ways: pass the actual cursor position * here if possible at all. * * <p>Also, this needs to be the cursor position <strong>right now</strong>, * not at some point in the past, even if input is starting in the same text field * as before. When the app is filling this object, input is about to start by * definition, and this value will override any value the app may have passed to * {@link InputMethodManager#updateSelection(android.view.View, int, int, int, int)} * before.</p> */ public int initialSelStart = -1; /** * The text offset of the end of the selection at the time editing * began; -1 if not known. Keep in mind some IMEs may not be able * to give their full feature set without knowing the cursor position; * avoid passing -1 here if you can. * <p>The text offset of the end of the selection at the time editing * begins; -1 if not known. Keep in mind that, without knowing the cursor * position, many IMEs will not be able to offer their full feature set and * may behave in unpredictable ways: pass the actual cursor position * here if possible at all.</p> * * <p>Also, this needs to be the cursor position <strong>right now</strong>, * not at some point in the past, even if input is starting in the same text field * as before. When the app is filling this object, input is about to start by * definition, and this value will override any value the app may have passed to * {@link InputMethodManager#updateSelection(android.view.View, int, int, int, int)} * before.</p> */ public int initialSelEnd = -1; Loading @@ -264,8 +280,8 @@ public class EditorInfo implements InputType, Parcelable { * {@link TextUtils#CAP_MODE_CHARACTERS TextUtils.CAP_MODE_CHARACTERS}, * {@link TextUtils#CAP_MODE_WORDS TextUtils.CAP_MODE_WORDS}, and * {@link TextUtils#CAP_MODE_SENTENCES TextUtils.CAP_MODE_SENTENCES}, though * you should generally just take a non-zero value to mean start out in * caps mode. * you should generally just take a non-zero value to mean "start out in * caps mode". */ public int initialCapsMode = 0; Loading Loading @@ -392,7 +408,8 @@ public class EditorInfo implements InputType, Parcelable { /** * Used to make this class parcelable. */ public static final Parcelable.Creator<EditorInfo> CREATOR = new Parcelable.Creator<EditorInfo>() { public static final Parcelable.Creator<EditorInfo> CREATOR = new Parcelable.Creator<EditorInfo>() { public EditorInfo createFromParcel(Parcel source) { EditorInfo res = new EditorInfo(); res.inputType = source.readInt(); Loading
core/java/android/view/inputmethod/InputMethodManager.java +8 −0 Original line number Diff line number Diff line Loading @@ -1394,6 +1394,14 @@ public final class InputMethodManager { /** * Report the current selection range. * * <p><strong>Editor authors</strong>, you need to call this method whenever * the cursor moves in your editor. Remember that in addition to doing this, your * editor needs to always supply current cursor values in * {@link EditorInfo#initialSelStart} and {@link EditorInfo#initialSelEnd} every * time {@link android.view.View#onCreateInputConnection(EditorInfo)} is * called, which happens whenever the keyboard shows up or the focus changes * to a text field, among other cases.</p> */ public void updateSelection(View view, int selStart, int selEnd, int candidatesStart, int candidatesEnd) { Loading