Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 43dbb549 authored by Ahaan Ugale's avatar Ahaan Ugale
Browse files

Add a showInInputMethodPicker attr.

An app that provided an IME and is deprecating that functionality may
want to still keep it's IME around temporarily, to prevent breaking
clients that hardcode the component name when switching to the IME.
Such an IME may want to not be presented as an option in the Input
Method picker. They can now set showInInputMethodPicker=false for
this.

Fix: 175480153
Test: manual - Test IME with showInInputMethodPicker=false isn't
 shown in the IME picker.
Test: [new tests]
 atest android.view.inputmethod.cts.InputMethodManagerTest
Test: atest CtsInputMethodTestCases
Change-Id: I18dda0525168f9195606840239507b9daba65be7
parent 68558761
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1296,6 +1296,7 @@ package android {
    field public static final int showDefault = 16843258; // 0x10101fa
    field public static final int showDividers = 16843561; // 0x1010329
    field public static final int showForAllUsers = 16844015; // 0x10104ef
    field public static final int showInInputMethodPicker = 16844361; // 0x1010649
    field public static final int showMetadataInPreview = 16844079; // 0x101052f
    field @Deprecated public static final int showOnLockScreen = 16843721; // 0x10103c9
    field public static final int showSilent = 16843259; // 0x10101fb
+23 −1
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ import java.util.List;
 * @attr ref android.R.styleable#InputMethod_supportsSwitchingToNextInputMethod
 * @attr ref android.R.styleable#InputMethod_supportsInlineSuggestions
 * @attr ref android.R.styleable#InputMethod_suppressesSpellChecker
 * @attr ref android.R.styleable#InputMethod_showInInputMethodPicker
 */
public final class InputMethodInfo implements Parcelable {
    static final String TAG = "InputMethodInfo";
@@ -123,6 +124,11 @@ public final class InputMethodInfo implements Parcelable {
     */
    private final boolean mSuppressesSpellChecker;

    /**
     * The flag whether this IME should be shown as an option in the IME picker.
     */
    private final boolean mShowInInputMethodPicker;

    /**
     * @param service the {@link ResolveInfo} corresponds in which the IME is implemented.
     * @return a unique ID to be returned by {@link #getId()}. We have used
@@ -167,6 +173,7 @@ public final class InputMethodInfo implements Parcelable {
        boolean supportsSwitchingToNextInputMethod = false; // false as default
        boolean inlineSuggestionsEnabled = false; // false as default
        boolean suppressesSpellChecker = false; // false as default
        boolean showInInputMethodPicker = true; // true as default
        mForceDefault = false;

        PackageManager pm = context.getPackageManager();
@@ -212,6 +219,8 @@ public final class InputMethodInfo implements Parcelable {
                    com.android.internal.R.styleable.InputMethod_supportsInlineSuggestions, false);
            suppressesSpellChecker = sa.getBoolean(
                    com.android.internal.R.styleable.InputMethod_suppressesSpellChecker, false);
            showInInputMethodPicker = sa.getBoolean(
                    com.android.internal.R.styleable.InputMethod_showInInputMethodPicker, true);
            sa.recycle();

            final int depth = parser.getDepth();
@@ -284,6 +293,7 @@ public final class InputMethodInfo implements Parcelable {
        mSupportsSwitchingToNextInputMethod = supportsSwitchingToNextInputMethod;
        mInlineSuggestionsEnabled = inlineSuggestionsEnabled;
        mSuppressesSpellChecker = suppressesSpellChecker;
        mShowInInputMethodPicker = showInInputMethodPicker;
        mIsVrOnly = isVrOnly;
    }

@@ -295,6 +305,7 @@ public final class InputMethodInfo implements Parcelable {
        mSupportsSwitchingToNextInputMethod = source.readInt() == 1;
        mInlineSuggestionsEnabled = source.readInt() == 1;
        mSuppressesSpellChecker = source.readBoolean();
        mShowInInputMethodPicker = source.readBoolean();
        mIsVrOnly = source.readBoolean();
        mService = ResolveInfo.CREATOR.createFromParcel(source);
        mSubtypes = new InputMethodSubtypeArray(source);
@@ -354,6 +365,7 @@ public final class InputMethodInfo implements Parcelable {
        mSupportsSwitchingToNextInputMethod = supportsSwitchingToNextInputMethod;
        mInlineSuggestionsEnabled = inlineSuggestionsEnabled;
        mSuppressesSpellChecker = false;
        mShowInInputMethodPicker = true;
        mIsVrOnly = isVrOnly;
    }

@@ -507,7 +519,8 @@ public final class InputMethodInfo implements Parcelable {
                + " mIsVrOnly=" + mIsVrOnly
                + " mSupportsSwitchingToNextInputMethod=" + mSupportsSwitchingToNextInputMethod
                + " mInlineSuggestionsEnabled=" + mInlineSuggestionsEnabled
                + " mSuppressesSpellChecker=" + mSuppressesSpellChecker);
                + " mSuppressesSpellChecker=" + mSuppressesSpellChecker
                + " mShowInInputMethodPicker=" + mShowInInputMethodPicker);
        pw.println(prefix + "mIsDefaultResId=0x"
                + Integer.toHexString(mIsDefaultResId));
        pw.println(prefix + "Service:");
@@ -582,6 +595,14 @@ public final class InputMethodInfo implements Parcelable {
        return mSuppressesSpellChecker;
    }

    /**
     * Return {@code true} if this input method should be shown in the IME picker.
     * @hide
     */
    public boolean showInInputMethodPicker() {
        return mShowInInputMethodPicker;
    }

    /**
     * Used to package this object into a {@link Parcel}.
     *
@@ -597,6 +618,7 @@ public final class InputMethodInfo implements Parcelable {
        dest.writeInt(mSupportsSwitchingToNextInputMethod ? 1 : 0);
        dest.writeInt(mInlineSuggestionsEnabled ? 1 : 0);
        dest.writeBoolean(mSuppressesSpellChecker);
        dest.writeBoolean(mShowInInputMethodPicker);
        dest.writeBoolean(mIsVrOnly);
        mService.writeToParcel(dest, flags);
        mSubtypes.writeToParcel(dest);
+6 −0
Original line number Diff line number Diff line
@@ -3579,6 +3579,12 @@
        <!-- Specifies whether the IME supports showing inline suggestions. -->
        <attr name="supportsInlineSuggestions" format="boolean" />
        <attr name="suppressesSpellChecker" format="boolean" />
        <!-- Specifies whether the IME wants to be shown in the Input Method picker. Defaults to
             true. Set this to false if the IME is intended to be accessed programmatically.
             <p>
             Note: This functions as a hint to the system, which may choose to ignore this
             preference in certain situations or in future releases.-->
        <attr name="showInInputMethodPicker" format="boolean" />
    </declare-styleable>
    <!-- This is the subtype of InputMethod. Subtype can describe locales (for example, en_US and
+1 −0
Original line number Diff line number Diff line
@@ -3098,6 +3098,7 @@
    <public name="lStar" />
    <!-- @hide @SystemApi -->
    <public name="throttleDurationMillis" />
    <public name="showInInputMethodPicker" />
  </public-group>

  <public-group type="drawable" first-id="0x010800b5">
+2 −1
Original line number Diff line number Diff line
@@ -100,7 +100,8 @@ public class InputMethodMenuController {

        synchronized (mMethodMap) {
            final List<ImeSubtypeListItem> imList = mSwitchingController
                    .getSortedInputMethodAndSubtypeListLocked(showAuxSubtypes, isScreenLocked);
                    .getSortedInputMethodAndSubtypeListForImeMenuLocked(
                            showAuxSubtypes, isScreenLocked);
            if (imList.isEmpty()) {
                return;
            }
Loading