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

Commit cb5cdb72 authored by Cosmin Băieș's avatar Cosmin Băieș Committed by Android (Google) Code Review
Browse files

Merge changes Ica92b730,I16986c28 into main

* changes:
  Handle edge-to-edge for SimpleInputMethodService
  Enable multiple subtypes in InputMethodServiceTest
parents 79ddf80e 9622684b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -32,8 +32,8 @@
        <uses-library android:name="android.test.runner" />
    </application>

    <!-- The "targetPackage" reference the instruments APK package, which is the FakeImeApk, while
    the test package is "com.android.inputmethod.imetests" (FrameworksImeTests.apk).-->
    <!-- The "targetPackage" reference the instruments APK package, which is the SimpleTestIme.apk,
    while the test package is "com.android.inputmethod.imetests" (FrameworksImeTests.apk).-->
    <instrumentation
        android:name="androidx.test.runner.AndroidJUnitRunner"
        android:targetPackage="com.android.apps.inputmethod.simpleime"
+17 −10
Original line number Diff line number Diff line
@@ -92,6 +92,9 @@ public class InputMethodServiceTest {
    private static final String DISABLE_SHOW_IME_WITH_HARD_KEYBOARD_CMD =
            "settings put secure " + Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD + " 0";

    /** The ids of the subtypes of SimpleIme. */
    private static final int[] SUBTYPE_IDS = new int[]{1, 2};

    private final WindowManagerStateHelper mWmState =  new WindowManagerStateHelper();

    private final GestureNavSwitchHelper mGestureNavSwitchHelper = new GestureNavSwitchHelper();
@@ -833,8 +836,7 @@ public class InputMethodServiceTest {
    }

    /**
     * Verifies that clicking on the IME switch button either shows the Input Method Switcher Menu,
     * or switches the input method.
     * Verifies that clicking on the IME switch button switches the input method subtype.
     */
    @Test
    public void testImeSwitchButtonClick() throws Exception {
@@ -844,6 +846,12 @@ public class InputMethodServiceTest {

        setShowImeWithHardKeyboard(true /* enabled */);

        final var info = mImm.getCurrentInputMethodInfo();
        assertWithMessage("InputMethodInfo is not null").that(info).isNotNull();
        mImm.setExplicitlyEnabledInputMethodSubtypes(info.getId(), SUBTYPE_IDS);

        final var initialSubtype = mImm.getCurrentInputMethodSubtype();

        try (var ignored = mGestureNavSwitchHelper.withGestureNavigationMode()) {
            verifyInputViewStatusOnMainSync(
                    () -> {
@@ -852,23 +860,18 @@ public class InputMethodServiceTest {
                    },
                    EVENT_SHOW, true /* eventExpected */, true /* shown */, "IME is shown");

            final var initialInfo = mImm.getCurrentInputMethodInfo();

            final var imeSwitcherButton = getUiObject(By.res(INPUT_METHOD_NAV_IME_SWITCHER_ID));
            imeSwitcherButton.click();
            mInstrumentation.waitForIdleSync();

            final var newInfo = mImm.getCurrentInputMethodInfo();
            final var newSubtype = mImm.getCurrentInputMethodSubtype();

            assertWithMessage("Input Method Switcher Menu is shown or input method was switched")
                    .that(isInputMethodPickerShown(mImm) || !Objects.equals(initialInfo, newInfo))
            assertWithMessage("Input method subtype was switched")
                    .that(!Objects.equals(initialSubtype, newSubtype))
                    .isTrue();

            assertWithMessage("IME is still shown after IME Switcher button was clicked")
                    .that(mInputMethodService.isInputViewShown()).isTrue();

            // Hide the IME Switcher Menu before finishing.
            mUiDevice.pressBack();
        }
    }

@@ -883,6 +886,10 @@ public class InputMethodServiceTest {

        setShowImeWithHardKeyboard(true /* enabled */);

        final var info = mImm.getCurrentInputMethodInfo();
        assertWithMessage("InputMethodInfo is not null").that(info).isNotNull();
        mImm.setExplicitlyEnabledInputMethodSubtypes(info.getId(), SUBTYPE_IDS);

        try (var ignored = mGestureNavSwitchHelper.withGestureNavigationMode()) {
            verifyInputViewStatusOnMainSync(
                    () -> {
+9 −2
Original line number Diff line number Diff line
@@ -17,7 +17,14 @@

<input-method xmlns:android="http://schemas.android.com/apk/res/android">
    <subtype
        android:label="FakeIme"
        android:label="SimpleIme"
        android:imeSubtypeLocale="en_US"
        android:imeSubtypeMode="keyboard"/>
        android:imeSubtypeMode="keyboard"
        android:subtypeId="1" />

    <subtype
        android:label="SimpleIme French"
        android:imeSubtypeLocale="fr_FR"
        android:imeSubtypeMode="keyboard"
        android:subtypeId="2" />
</input-method>
 No newline at end of file
+10 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.util.Log;
import android.util.SparseArray;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.WindowInsets;
import android.widget.FrameLayout;
import android.widget.TextView;

@@ -107,6 +108,15 @@ final class SimpleKeyboardView extends FrameLayout {
        mapSoftKeys();
    }

    @Override
    public WindowInsets onApplyWindowInsets(WindowInsets insets) {
        // Handle edge to edge for navigationBars insets (system nav bar)
        // and captionBars insets (IME navigation bar).
        final int insetBottom = insets.getInsets(WindowInsets.Type.systemBars()).bottom;
        setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight(), insetBottom);
        return insets.inset(0, 0, 0, insetBottom);
    }

    /**
     * Sets the key press listener.
     *