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

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

Merge "Use correct navigation hint for IME visibility" into main

parents 46ff722e 1d0b620c
Loading
Loading
Loading
Loading
+12 −10
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

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_SHOWN;
import static android.view.WindowInsets.Type.captionBar;
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;

@@ -23,7 +26,6 @@ import android.animation.ValueAnimator;
import android.annotation.FloatRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.StatusBarManager;
import android.graphics.Color;
import android.graphics.Insets;
import android.graphics.Rect;
@@ -241,10 +243,9 @@ final class NavigationBarController {
                if (navigationBarView != null) {
                    // TODO(b/213337792): Support InputMethodService#setBackDisposition().
                    // TODO(b/213337792): Set NAVIGATION_HINT_IME_SHOWN only when necessary.
                    final int hints = StatusBarManager.NAVIGATION_HINT_BACK_ALT
                    final int hints = NAVIGATION_HINT_BACK_ALT | NAVIGATION_HINT_IME_SHOWN
                            | (mShouldShowImeSwitcherWhenImeIsShown
                                    ? StatusBarManager.NAVIGATION_HINT_IME_SWITCHER_SHOWN
                                    : 0);
                                    ? NAVIGATION_HINT_IME_SWITCHER_SHOWN : 0);
                    navigationBarView.setNavigationIconHints(hints);
                    navigationBarView.prepareNavButtons(this);
                }
@@ -512,13 +513,14 @@ final class NavigationBarController {
                }
                final NavigationBarView navigationBarView = mNavigationBarFrame.findViewByPredicate(
                        NavigationBarView.class::isInstance);
                if (navigationBarView == null) {
                    return;
                }
                final int hints = StatusBarManager.NAVIGATION_HINT_BACK_ALT
                        | (shouldShowImeSwitcherWhenImeIsShown
                                ? StatusBarManager.NAVIGATION_HINT_IME_SWITCHER_SHOWN : 0);
                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
                            | (mShouldShowImeSwitcherWhenImeIsShown
                                    ? NAVIGATION_HINT_IME_SWITCHER_SHOWN : 0);
                    navigationBarView.setNavigationIconHints(hints);
                }
            } else {
                uninstallNavigationBarFrameIfNecessary();
            }
+1 −1
Original line number Diff line number Diff line
@@ -290,7 +290,7 @@ public final class NavigationBarView extends FrameLayout {
        final boolean oldBackAlt =
                (mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0;
        if (newBackAlt != oldBackAlt) {
            //onImeVisibilityChanged(newBackAlt);
            //onBackAltChanged(newBackAlt);
        }

        if (DEBUG) {
+62 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ 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_SHOWN;
import static android.inputmethodservice.InputMethodService.BACK_DISPOSITION_ADJUST_NOTHING;
import static android.inputmethodservice.InputMethodService.BACK_DISPOSITION_DEFAULT;
import static android.inputmethodservice.InputMethodService.IME_VISIBLE;
import static android.view.Display.DEFAULT_DISPLAY;
@@ -30,6 +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_SHOWING;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING;

import static com.google.common.truth.Truth.assertThat;
@@ -487,6 +490,65 @@ public class NavigationBarTest extends SysuiTestCase {
        verify(mUserTracker).addCallback(any(UserTracker.Callback.class), any(Executor.class));
    }

    /**
     * Verifies that the SysUI state is updated correctly when given a new IME window status with
     * IME visible and IME Switcher button visible.
     */
    @Test
    public void testSetImeWindowStatusSysuiState_ImeVisibleImeSwitcherButtonVisible() {
        doNothing().when(mNavigationBar).checkNavBarModes();

        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_SHOWING), eq(true));
    }

    /**
     * Verifies that the SysUI state is updated correctly when given a new IME window status with
     * IME visible and IME Switcher button not visible.
     */
    @Test
    public void testSetImeWindowStatusSysuiState_ImeVisibleImeSwitcherButtonNotVisible() {
        doNothing().when(mNavigationBar).checkNavBarModes();

        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_SHOWING), eq(false));
    }

    /**
     * Verifies that the SysUI state is updated correctly when given a new IME window status with
     * IME not visible and IME Switcher button visible.
     */
    @Test
    public void testSetImeWindowStatusSysuiState_ImeNotVisibleImeSwitcherButtonVisible() {
        doNothing().when(mNavigationBar).checkNavBarModes();
        // Set initial state for later reset to be able to take place.
        mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE,
                BACK_DISPOSITION_DEFAULT, true /* showImeSwitcher */);

        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_SHOWING), eq(false));
    }

    /**
     * Verifies that the SysUI state is updated correctly when given a new IME window status with
     * IME visible and back disposition adjust nothing.
     */
    @Test
    public void testSetImeWindowStatusSysuiState_ImeVisibleBackDispositionAdjustNothing() {
        doNothing().when(mNavigationBar).checkNavBarModes();

        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_SHOWING), eq(true));
    }

    @Test
    public void testSetImeWindowStatusWhenImeSwitchOnDisplay() {
        // Create default & external NavBar fragment.
+2 −2
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
package com.android.systemui.navigationbar;

import static android.app.ActivityManager.LOCK_TASK_MODE_PINNED;
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_SHOWN;
import static android.app.StatusBarManager.WINDOW_STATE_SHOWING;
import static android.view.WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE;
@@ -361,7 +361,7 @@ public class TaskbarDelegate implements CommandQueue.Callbacks,
        mSysUiState.setFlag(SYSUI_STATE_A11Y_BUTTON_CLICKABLE, clickable)
                .setFlag(SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE, longClickable)
                .setFlag(SYSUI_STATE_IME_SHOWING,
                        (mNavigationIconHints & NAVIGATION_HINT_BACK_ALT) != 0)
                        (mNavigationIconHints & NAVIGATION_HINT_IME_SHOWN) != 0)
                .setFlag(SYSUI_STATE_IME_SWITCHER_SHOWING,
                        (mNavigationIconHints & NAVIGATION_HINT_IME_SWITCHER_SHOWN) != 0)
                .setFlag(SYSUI_STATE_OVERVIEW_DISABLED,
+4 −4
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
package com.android.systemui.navigationbar.views;

import static android.app.ActivityManager.LOCK_TASK_MODE_PINNED;
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_SHOWN;
import static android.app.StatusBarManager.WINDOW_STATE_HIDDEN;
import static android.app.StatusBarManager.WINDOW_STATE_SHOWING;
@@ -1681,7 +1681,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
                .setFlag(SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE, longClickable)
                .setFlag(SYSUI_STATE_NAV_BAR_HIDDEN, !isNavBarWindowVisible())
                .setFlag(SYSUI_STATE_IME_SHOWING,
                        (mNavigationIconHints & NAVIGATION_HINT_BACK_ALT) != 0)
                        (mNavigationIconHints & NAVIGATION_HINT_IME_SHOWN) != 0)
                .setFlag(SYSUI_STATE_IME_SWITCHER_SHOWING,
                        (mNavigationIconHints & NAVIGATION_HINT_IME_SWITCHER_SHOWN) != 0)
                .setFlag(SYSUI_STATE_ALLOW_GESTURE_IGNORING_BAR_VISIBILITY,
@@ -1938,9 +1938,9 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
            final boolean oldBackAlt =
                    (mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0;
            if (newBackAlt != oldBackAlt) {
                mView.onImeVisibilityChanged(newBackAlt);
                mImeVisible = newBackAlt;
                mView.onBackAltChanged(newBackAlt);
            }
            mImeVisible = (hints & NAVIGATION_HINT_IME_SHOWN) != 0;

            mView.setNavigationIconHints(hints);
        }
Loading