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

Commit 69da2690 authored by Satoshi Kataoka's avatar Satoshi Kataoka Committed by satok
Browse files

Add an API supportsSwitchingToNextInput

To let the system know an IME supports switching to a next input method

Bug: 8364845
Change-Id: Iabf4f106893ee6a262ad0cd44dbec0c661bf0ff2
parent 70e907f5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1015,6 +1015,7 @@ package android {
    field public static final int summaryOff = 16843248; // 0x10101f0
    field public static final int summaryOn = 16843247; // 0x10101ef
    field public static final int supportsRtl = 16843695; // 0x10103af
    field public static final int supportsSwitchingToNextInputMethod = 16843753; // 0x10103e9
    field public static final int supportsUploading = 16843419; // 0x101029b
    field public static final int switchMinWidth = 16843632; // 0x1010370
    field public static final int switchPadding = 16843633; // 0x1010371
+22 −1
Original line number Diff line number Diff line
@@ -82,10 +82,15 @@ public final class InputMethodInfo implements Parcelable {
    private final boolean mIsAuxIme;

    /**
     * Cavert: mForceDefault must be false for production. This flag is only for test.
     * Caveat: mForceDefault must be false for production. This flag is only for test.
     */
    private final boolean mForceDefault;

    /**
     * The flag whether this IME supports ways to switch to a next input method (e.g. globe key.)
     */
    private final boolean mSupportsSwitchingToNextInputMethod;

    /**
     * Constructor.
     *
@@ -114,6 +119,7 @@ public final class InputMethodInfo implements Parcelable {
        ServiceInfo si = service.serviceInfo;
        mId = new ComponentName(si.packageName, si.name).flattenToShortString();
        boolean isAuxIme = true;
        boolean supportsSwitchingToNextInputMethod = false; // false as default
        mForceDefault = false;

        PackageManager pm = context.getPackageManager();
@@ -149,6 +155,9 @@ public final class InputMethodInfo implements Parcelable {
                    com.android.internal.R.styleable.InputMethod_settingsActivity);
            isDefaultResId = sa.getResourceId(
                    com.android.internal.R.styleable.InputMethod_isDefault, 0);
            supportsSwitchingToNextInputMethod = sa.getBoolean(
                    com.android.internal.R.styleable.InputMethod_supportsSwitchingToNextInputMethod,
                    false);
            sa.recycle();

            final int depth = parser.getDepth();
@@ -216,6 +225,7 @@ public final class InputMethodInfo implements Parcelable {
        mSettingsActivityName = settingsActivityComponent;
        mIsDefaultResId = isDefaultResId;
        mIsAuxIme = isAuxIme;
        mSupportsSwitchingToNextInputMethod = supportsSwitchingToNextInputMethod;
    }

    InputMethodInfo(Parcel source) {
@@ -223,6 +233,7 @@ public final class InputMethodInfo implements Parcelable {
        mSettingsActivityName = source.readString();
        mIsDefaultResId = source.readInt();
        mIsAuxIme = source.readInt() == 1;
        mSupportsSwitchingToNextInputMethod = source.readInt() == 1;
        mService = ResolveInfo.CREATOR.createFromParcel(source);
        source.readTypedList(mSubtypes, InputMethodSubtype.CREATOR);
        mForceDefault = false;
@@ -254,6 +265,7 @@ public final class InputMethodInfo implements Parcelable {
            mSubtypes.addAll(subtypes);
        }
        mForceDefault = forceDefault;
        mSupportsSwitchingToNextInputMethod = true;
    }

    private static ResolveInfo buildDummyResolveInfo(String packageName, String className,
@@ -434,6 +446,14 @@ public final class InputMethodInfo implements Parcelable {
        return mIsAuxIme;
    }

    /**
     * @return true if this input method supports ways to switch to a next input method.
     * @hide
     */
    public boolean supportsSwitchingToNextInputMethod() {
        return mSupportsSwitchingToNextInputMethod;
    }

    /**
     * Used to package this object into a {@link Parcel}.
     * 
@@ -446,6 +466,7 @@ public final class InputMethodInfo implements Parcelable {
        dest.writeString(mSettingsActivityName);
        dest.writeInt(mIsDefaultResId);
        dest.writeInt(mIsAuxIme ? 1 : 0);
        dest.writeInt(mSupportsSwitchingToNextInputMethod ? 1 : 0);
        mService.writeToParcel(dest, flags);
        dest.writeTypedList(mSubtypes);
    }
+3 −0
Original line number Diff line number Diff line
@@ -2378,6 +2378,9 @@
        <!-- Set to true in all of the configurations for which this input
             method should be considered an option as the default. -->
        <attr name="isDefault" format="boolean" />
        <!-- Set to true if this input method supports ways to switch to
             a next input method (e.g. a globe key.). -->
        <attr name="supportsSwitchingToNextInputMethod" format="boolean" />
    </declare-styleable>

    <!-- This is the subtype of InputMethod. Subtype can describe locales (e.g. en_US, fr_FR...)
+1 −0
Original line number Diff line number Diff line
@@ -2072,5 +2072,6 @@
  <public type="attr" name="isAsciiCapable" />
  <public type="attr" name="customRoots" />
  <public type="attr" name="autoMirrored" />
  <public type="attr" name="supportsSwitchingToNextInputMethod" />

</resources>