From 071d81e6230f1bda59a89ae4d34b8357e1fd6615 Mon Sep 17 00:00:00 2001 From: Lan Wei Date: Thu, 1 Apr 2021 12:42:12 +0800 Subject: [PATCH] Add the IntRange and IntDef annotations for initial text API Add the IntRange and IntDef annotations on the getInitialText{Before,After}Cursor API. BUG: 184017538 Test: atest FrameworksCoreTests:EditorInfoTest Test: atest CtsInputMethodTestCases:EditorInfoTest Change-Id: Ifebeeac6863600363ebcf6c73263874604ea3428 --- core/api/current.txt | 4 ++-- core/java/android/view/inputmethod/EditorInfo.java | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index 89cf257d894cb..9144333766dd2 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -51677,8 +51677,8 @@ package android.view.inputmethod { method public void dump(android.util.Printer, String); method @Nullable public CharSequence getInitialSelectedText(int); method @Nullable public android.view.inputmethod.SurroundingText getInitialSurroundingText(@IntRange(from=0) int, @IntRange(from=0) int, int); - method @Nullable public CharSequence getInitialTextAfterCursor(int, int); - method @Nullable public CharSequence getInitialTextBeforeCursor(int, int); + method @Nullable public CharSequence getInitialTextAfterCursor(@IntRange(from=0) int, int); + method @Nullable public CharSequence getInitialTextBeforeCursor(@IntRange(from=0) int, int); method public final void makeCompatible(int); method public void setInitialSurroundingSubText(@NonNull CharSequence, int); method public void setInitialSurroundingText(@NonNull CharSequence); diff --git a/core/java/android/view/inputmethod/EditorInfo.java b/core/java/android/view/inputmethod/EditorInfo.java index bde4cb7c4fc3d..4a52b1f01b46e 100644 --- a/core/java/android/view/inputmethod/EditorInfo.java +++ b/core/java/android/view/inputmethod/EditorInfo.java @@ -725,7 +725,8 @@ public class EditorInfo implements InputType, Parcelable { * protocol. */ @Nullable - public CharSequence getInitialTextBeforeCursor(int length, int flags) { + public CharSequence getInitialTextBeforeCursor( + @IntRange(from = 0) int length, @InputConnection.GetTextType int flags) { if (mInitialSurroundingText == null) { return null; } @@ -750,7 +751,7 @@ public class EditorInfo implements InputType, Parcelable { * this protocol is not supported. */ @Nullable - public CharSequence getInitialSelectedText(int flags) { + public CharSequence getInitialSelectedText(@InputConnection.GetTextType int flags) { if (mInitialSurroundingText == null) { return null; } @@ -792,7 +793,8 @@ public class EditorInfo implements InputType, Parcelable { * protocol. */ @Nullable - public CharSequence getInitialTextAfterCursor(int length, int flags) { + public CharSequence getInitialTextAfterCursor( + @IntRange(from = 0) int length, @InputConnection.GetTextType int flags) { if (mInitialSurroundingText == null) { return null; }