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

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

Merge "Rename IME_SHOWN states to IME_VISIBLE" into main

parents ee622090 30f5e0c7
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -211,13 +211,13 @@ public class StatusBarManager {
     *
     * @hide
     */
    public static final int NAVIGATION_HINT_IME_SHOWN = 1 << 1;
    public static final int NAVIGATION_HINT_IME_VISIBLE = 1 << 1;
    /**
     * The IME Switcher button is visible. This only takes effect while the IME is visible.
     *
     * @hide
     */
    public static final int NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN = 1 << 2;
    public static final int NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE = 1 << 2;
    /**
     * Navigation bar flags related to the IME state.
     *
@@ -225,8 +225,8 @@ public class StatusBarManager {
     */
    @IntDef(flag = true, prefix = { "NAVIGATION_HINT_" }, value = {
            NAVIGATION_HINT_BACK_ALT,
            NAVIGATION_HINT_IME_SHOWN,
            NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN,
            NAVIGATION_HINT_IME_VISIBLE,
            NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface NavigationHint {}
@@ -1360,11 +1360,11 @@ public class StatusBarManager {
        if ((hints & NAVIGATION_HINT_BACK_ALT) != 0) {
            hintStrings.add("NAVIGATION_HINT_BACK_ALT");
        }
        if ((hints & NAVIGATION_HINT_IME_SHOWN) != 0) {
            hintStrings.add("NAVIGATION_HINT_IME_SHOWN");
        if ((hints & NAVIGATION_HINT_IME_VISIBLE) != 0) {
            hintStrings.add("NAVIGATION_HINT_IME_VISIBLE");
        }
        if ((hints & NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN) != 0) {
            hintStrings.add("NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN");
        if ((hints & NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE) != 0) {
            hintStrings.add("NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE");
        }
        return String.join(" | ", hintStrings);
    }
+8 −8
Original line number Diff line number Diff line
@@ -17,8 +17,8 @@
package android.inputmethodservice;

import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_ALT;
import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SHOWN;
import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN;
import static android.app.StatusBarManager.NAVIGATION_HINT_IME_VISIBLE;
import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE;
import static android.view.WindowInsets.Type.captionBar;
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;

@@ -242,10 +242,10 @@ final class NavigationBarController {
                        NavigationBarView.class::isInstance);
                if (navigationBarView != null) {
                    // TODO(b/213337792): Support InputMethodService#setBackDisposition().
                    // TODO(b/213337792): Set NAVIGATION_HINT_IME_SHOWN only when necessary.
                    final int hints = NAVIGATION_HINT_BACK_ALT | NAVIGATION_HINT_IME_SHOWN
                    // TODO(b/213337792): Set NAVIGATION_HINT_IME_VISIBLE only when necessary.
                    final int hints = NAVIGATION_HINT_BACK_ALT | NAVIGATION_HINT_IME_VISIBLE
                            | (mShouldShowImeSwitcherWhenImeIsShown
                                    ? NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN : 0);
                                    ? NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE : 0);
                    navigationBarView.setNavigationIconHints(hints);
                    navigationBarView.prepareNavButtons(this);
                }
@@ -515,10 +515,10 @@ final class NavigationBarController {
                        NavigationBarView.class::isInstance);
                if (navigationBarView != null) {
                    // TODO(b/213337792): Support InputMethodService#setBackDisposition().
                    // TODO(b/213337792): Set NAVIGATION_HINT_IME_SHOWN only when necessary.
                    final int hints = NAVIGATION_HINT_BACK_ALT | NAVIGATION_HINT_IME_SHOWN
                    // TODO(b/213337792): Set NAVIGATION_HINT_IME_VISIBLE only when necessary.
                    final int hints = NAVIGATION_HINT_BACK_ALT | NAVIGATION_HINT_IME_VISIBLE
                            | (mShouldShowImeSwitcherWhenImeIsShown
                                    ? NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN : 0);
                                    ? NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE : 0);
                    navigationBarView.setNavigationIconHints(hints);
                }
            } else {
+4 −3
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
package android.inputmethodservice.navigationbar;

import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_ALT;
import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN;
import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE;
import static android.inputmethodservice.navigationbar.NavigationBarConstants.DARK_MODE_ICON_COLOR_SINGLE_TONE;
import static android.inputmethodservice.navigationbar.NavigationBarConstants.LIGHT_MODE_ICON_COLOR_SINGLE_TONE;
import static android.inputmethodservice.navigationbar.NavigationBarConstants.NAVBAR_BACK_BUTTON_IME_OFFSET;
@@ -316,9 +316,10 @@ public final class NavigationBarView extends FrameLayout {

        getImeSwitchButton().setImageDrawable(mImeSwitcherIcon);

        // Update IME button visibility, a11y and rotate button always overrides the appearance
        // Update IME switcher button visibility, a11y and rotate button always overrides
        // the appearance.
        final boolean isImeSwitcherButtonVisible =
                (mNavigationIconHints & NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN) != 0;
                (mNavigationIconHints & NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE) != 0;
        getImeSwitchButton()
                .setVisibility(isImeSwitcherButtonVisible ? View.VISIBLE : View.INVISIBLE);

+26 −26
Original line number Diff line number Diff line
@@ -17,8 +17,8 @@
package com.android.systemui.navigationbar.views;

import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_ALT;
import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SHOWN;
import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN;
import static android.app.StatusBarManager.NAVIGATION_HINT_IME_VISIBLE;
import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE;
import static android.inputmethodservice.InputMethodService.BACK_DISPOSITION_ADJUST_NOTHING;
import static android.inputmethodservice.InputMethodService.BACK_DISPOSITION_DEFAULT;
import static android.inputmethodservice.InputMethodService.IME_VISIBLE;
@@ -31,8 +31,8 @@ import static com.android.systemui.assist.AssistManager.INVOCATION_TYPE_HOME_BUT
import static com.android.systemui.navigationbar.views.NavigationBar.NavBarActionEvent.NAVBAR_ASSIST_LONGPRESS;
import static com.android.systemui.navigationbar.views.buttons.KeyButtonView.NavBarButtonEvent.NAVBAR_IME_SWITCHER_BUTTON_LONGPRESS;
import static com.android.systemui.navigationbar.views.buttons.KeyButtonView.NavBarButtonEvent.NAVBAR_IME_SWITCHER_BUTTON_TAP;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_IME_SHOWING;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_IME_SWITCHER_BUTTON_SHOWING;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_IME_VISIBLE;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_IME_SWITCHER_BUTTON_VISIBLE;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING;

import static com.google.common.truth.Truth.assertThat;
@@ -500,8 +500,8 @@ public class NavigationBarTest extends SysuiTestCase {

        mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE,
                BACK_DISPOSITION_DEFAULT, true /* showImeSwitcher */);
        verify(mMockSysUiState).setFlag(eq(SYSUI_STATE_IME_SHOWING), eq(true));
        verify(mMockSysUiState).setFlag(eq(SYSUI_STATE_IME_SWITCHER_BUTTON_SHOWING), eq(true));
        verify(mMockSysUiState).setFlag(eq(SYSUI_STATE_IME_VISIBLE), eq(true));
        verify(mMockSysUiState).setFlag(eq(SYSUI_STATE_IME_SWITCHER_BUTTON_VISIBLE), eq(true));
    }

    /**
@@ -514,8 +514,8 @@ public class NavigationBarTest extends SysuiTestCase {

        mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE,
                BACK_DISPOSITION_DEFAULT, false /* showImeSwitcher */);
        verify(mMockSysUiState).setFlag(eq(SYSUI_STATE_IME_SHOWING), eq(true));
        verify(mMockSysUiState).setFlag(eq(SYSUI_STATE_IME_SWITCHER_BUTTON_SHOWING), eq(false));
        verify(mMockSysUiState).setFlag(eq(SYSUI_STATE_IME_VISIBLE), eq(true));
        verify(mMockSysUiState).setFlag(eq(SYSUI_STATE_IME_SWITCHER_BUTTON_VISIBLE), eq(false));
    }

    /**
@@ -531,8 +531,8 @@ public class NavigationBarTest extends SysuiTestCase {

        mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, 0 /* vis */,
                BACK_DISPOSITION_DEFAULT, true /* showImeSwitcher */);
        verify(mMockSysUiState).setFlag(eq(SYSUI_STATE_IME_SHOWING), eq(false));
        verify(mMockSysUiState).setFlag(eq(SYSUI_STATE_IME_SWITCHER_BUTTON_SHOWING), eq(false));
        verify(mMockSysUiState).setFlag(eq(SYSUI_STATE_IME_VISIBLE), eq(false));
        verify(mMockSysUiState).setFlag(eq(SYSUI_STATE_IME_SWITCHER_BUTTON_VISIBLE), eq(false));
    }

    /**
@@ -545,8 +545,8 @@ public class NavigationBarTest extends SysuiTestCase {

        mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE,
                BACK_DISPOSITION_ADJUST_NOTHING, true /* showImeSwitcher */);
        verify(mMockSysUiState).setFlag(eq(SYSUI_STATE_IME_SHOWING), eq(true));
        verify(mMockSysUiState).setFlag(eq(SYSUI_STATE_IME_SWITCHER_BUTTON_SHOWING), eq(true));
        verify(mMockSysUiState).setFlag(eq(SYSUI_STATE_IME_VISIBLE), eq(true));
        verify(mMockSysUiState).setFlag(eq(SYSUI_STATE_IME_SWITCHER_BUTTON_VISIBLE), eq(true));
    }

    @Test
@@ -567,26 +567,26 @@ public class NavigationBarTest extends SysuiTestCase {
                BACK_DISPOSITION_DEFAULT, true);

        // Verify IME window state will be updated in default NavBar & external NavBar state reset.
        assertEquals(NAVIGATION_HINT_BACK_ALT | NAVIGATION_HINT_IME_SHOWN
                        | NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN,
        assertEquals(NAVIGATION_HINT_BACK_ALT | NAVIGATION_HINT_IME_VISIBLE
                        | NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE,
                defaultNavBar.getNavigationIconHints());
        assertFalse((externalNavBar.getNavigationIconHints() & NAVIGATION_HINT_BACK_ALT) != 0);
        assertFalse((externalNavBar.getNavigationIconHints() & NAVIGATION_HINT_IME_SHOWN) != 0);
        assertFalse((externalNavBar.getNavigationIconHints() & NAVIGATION_HINT_IME_VISIBLE) != 0);
        assertFalse((externalNavBar.getNavigationIconHints()
                & NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN) != 0);
                & NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE) != 0);

        externalNavBar.setImeWindowStatus(EXTERNAL_DISPLAY_ID, IME_VISIBLE,
                BACK_DISPOSITION_DEFAULT, true);
        defaultNavBar.setImeWindowStatus(DEFAULT_DISPLAY, 0 /* vis */,
                BACK_DISPOSITION_DEFAULT, false);
        // Verify IME window state will be updated in external NavBar & default NavBar state reset.
        assertEquals(NAVIGATION_HINT_BACK_ALT | NAVIGATION_HINT_IME_SHOWN
                        | NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN,
        assertEquals(NAVIGATION_HINT_BACK_ALT | NAVIGATION_HINT_IME_VISIBLE
                        | NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE,
                externalNavBar.getNavigationIconHints());
        assertFalse((defaultNavBar.getNavigationIconHints() & NAVIGATION_HINT_BACK_ALT) != 0);
        assertFalse((defaultNavBar.getNavigationIconHints() & NAVIGATION_HINT_IME_SHOWN) != 0);
        assertFalse((defaultNavBar.getNavigationIconHints() & NAVIGATION_HINT_IME_VISIBLE) != 0);
        assertFalse((defaultNavBar.getNavigationIconHints()
                & NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN) != 0);
                & NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE) != 0);
    }

    @Test
@@ -603,9 +603,9 @@ public class NavigationBarTest extends SysuiTestCase {
        mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE,
                BACK_DISPOSITION_DEFAULT, true);
        assertTrue((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_BACK_ALT) != 0);
        assertTrue((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_IME_SHOWN) != 0);
        assertTrue((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_IME_VISIBLE) != 0);
        assertTrue((mNavigationBar.getNavigationIconHints()
                & NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN) != 0);
                & NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE) != 0);

        // Verify navbar didn't alter and showing back icon when the keyguard is showing without
        // requesting IME insets visible.
@@ -613,9 +613,9 @@ public class NavigationBarTest extends SysuiTestCase {
        mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE,
                BACK_DISPOSITION_DEFAULT, true);
        assertFalse((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_BACK_ALT) != 0);
        assertFalse((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_IME_SHOWN) != 0);
        assertFalse((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_IME_VISIBLE) != 0);
        assertFalse((mNavigationBar.getNavigationIconHints()
                & NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN) != 0);
                & NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE) != 0);

        // Verify navbar altered and showing back icon when the keyguard is showing and
        // requesting IME insets visible.
@@ -624,9 +624,9 @@ public class NavigationBarTest extends SysuiTestCase {
        mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE,
                BACK_DISPOSITION_DEFAULT, true);
        assertTrue((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_BACK_ALT) != 0);
        assertTrue((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_IME_SHOWN) != 0);
        assertTrue((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_IME_VISIBLE) != 0);
        assertTrue((mNavigationBar.getNavigationIconHints()
                & NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN) != 0);
                & NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE) != 0);
    }

    @Test
+14 −13
Original line number Diff line number Diff line
@@ -17,8 +17,8 @@
package com.android.systemui.shared.recents.utilities;

import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_ALT;
import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SHOWN;
import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN;
import static android.app.StatusBarManager.NAVIGATION_HINT_IME_VISIBLE;
import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE;

import android.annotation.TargetApi;
import android.app.StatusBarManager.NavigationHint;
@@ -108,20 +108,21 @@ public class Utilities {
     *
     * @param oldHints        current navigation icon hints.
     * @param backDisposition the IME back disposition mode. Only takes effect if
     *                        {@code imeShown} is {@code true}.
     * @param imeShown        whether the IME is currently visible.
     *                        {@code isImeVisible} is {@code true}.
     * @param isImeVisible    whether the IME is currently visible.
     * @param showImeSwitcher whether the IME Switcher button should be shown. Only takes effect if
     *                        {@code imeShown} is {@code true}.
     *                        {@code isImeVisible} is {@code true}.
     */
    @NavigationHint
    public static int calculateNavigationIconHints(@NavigationHint int oldHints,
            @BackDispositionMode int backDisposition, boolean imeShown, boolean showImeSwitcher) {
            @BackDispositionMode int backDisposition, boolean isImeVisible,
            boolean showImeSwitcher) {
        int hints = oldHints;
        switch (backDisposition) {
            case InputMethodService.BACK_DISPOSITION_DEFAULT:
            case InputMethodService.BACK_DISPOSITION_WILL_NOT_DISMISS:
            case InputMethodService.BACK_DISPOSITION_WILL_DISMISS:
                if (imeShown) {
                if (isImeVisible) {
                    hints |= NAVIGATION_HINT_BACK_ALT;
                } else {
                    hints &= ~NAVIGATION_HINT_BACK_ALT;
@@ -131,15 +132,15 @@ public class Utilities {
                hints &= ~NAVIGATION_HINT_BACK_ALT;
                break;
        }
        if (imeShown) {
            hints |= NAVIGATION_HINT_IME_SHOWN;
        if (isImeVisible) {
            hints |= NAVIGATION_HINT_IME_VISIBLE;
        } else {
            hints &= ~NAVIGATION_HINT_IME_SHOWN;
            hints &= ~NAVIGATION_HINT_IME_VISIBLE;
        }
        if (showImeSwitcher && imeShown) {
            hints |= NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN;
        if (showImeSwitcher && isImeVisible) {
            hints |= NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE;
        } else {
            hints &= ~NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN;
            hints &= ~NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE;
        }

        return hints;
Loading