diff --git a/core/api/current.txt b/core/api/current.txt index f6d0d9dea096a..acdc5baa708c6 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -51517,6 +51517,10 @@ package android.view.textservice { } public final class TextServicesManager { + method @Nullable public android.view.textservice.SpellCheckerInfo getCurrentSpellChecker(); + method @Nullable public android.view.textservice.SpellCheckerSubtype getCurrentSpellCheckerSubtype(boolean); + method @Nullable public java.util.List getEnabledSpellCheckersList(); + method public boolean isSpellCheckerEnabled(); method public android.view.textservice.SpellCheckerSession newSpellCheckerSession(android.os.Bundle, java.util.Locale, android.view.textservice.SpellCheckerSession.SpellCheckerSessionListener, boolean); } diff --git a/core/api/test-current.txt b/core/api/test-current.txt index 5b86e8d93064e..a2c5d52f925d9 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -2341,10 +2341,6 @@ package android.view.textservice { field public static final int SUBTYPE_ID_NONE = 0; // 0x0 } - public final class TextServicesManager { - method public boolean isSpellCheckerEnabled(); - } - } package android.widget { diff --git a/core/java/android/view/textservice/TextServicesManager.java b/core/java/android/view/textservice/TextServicesManager.java index d34c8d58e7896..578ed8c948e29 100644 --- a/core/java/android/view/textservice/TextServicesManager.java +++ b/core/java/android/view/textservice/TextServicesManager.java @@ -17,8 +17,8 @@ package android.view.textservice; import android.annotation.NonNull; +import android.annotation.Nullable; import android.annotation.SystemService; -import android.annotation.TestApi; import android.annotation.UserIdInt; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; @@ -34,6 +34,8 @@ import android.view.textservice.SpellCheckerSession.SpellCheckerSessionListener; import com.android.internal.textservice.ISpellCheckerSessionListener; import com.android.internal.textservice.ITextServicesManager; +import java.util.Arrays; +import java.util.List; import java.util.Locale; /** @@ -232,9 +234,22 @@ public final class TextServicesManager { } /** - * @hide + * Retrieve the list of currently enabled spell checkers, or null if there is none. + * + * @return The list of currently enabled spell checkers. */ - @UnsupportedAppUsage + @Nullable + public List getEnabledSpellCheckersList() { + final SpellCheckerInfo[] enabledSpellCheckers = getEnabledSpellCheckers(); + return enabledSpellCheckers != null ? Arrays.asList(enabledSpellCheckers) : null; + } + + /** + * Retrieve the currently active spell checker, or null if there is none. + * + * @return The current active spell checker info. + */ + @Nullable public SpellCheckerInfo getCurrentSpellChecker() { try { // Passing null as a locale for ICS @@ -245,9 +260,13 @@ public final class TextServicesManager { } /** - * @hide + * Retrieve the selected subtype of the selected spell checker, or null if there is none. + * + * @param allowImplicitlySelectedSubtype {@code true} to return the default language matching + * system locale if there's no subtype selected explicitly, otherwise, returns null. + * @return The meta information of the selected subtype of the selected spell checker. */ - @UnsupportedAppUsage + @Nullable public SpellCheckerSubtype getCurrentSpellCheckerSubtype( boolean allowImplicitlySelectedSubtype) { try { @@ -258,10 +277,10 @@ public final class TextServicesManager { } /** - * @hide + * Return whether the spell checker is enabled or not. + * + * @return {@code true} if spell checker is enabled, {@code false} otherwise. */ - @UnsupportedAppUsage - @TestApi public boolean isSpellCheckerEnabled() { try { return mService.isSpellCheckerEnabled(mUserId);