Loading core/java/android/app/StatusBarManager.java +18 −18 Original line number Original line Diff line number Diff line Loading @@ -205,31 +205,31 @@ public class StatusBarManager { * * * @hide * @hide */ */ public static final int NAVIGATION_HINT_BACK_DISMISS_IME = 1 << 0; public static final int NAVBAR_BACK_DISMISS_IME = 1 << 0; /** /** * The IME is visible. * The IME is visible. * * * @hide * @hide */ */ public static final int NAVIGATION_HINT_IME_VISIBLE = 1 << 1; public static final int NAVBAR_IME_VISIBLE = 1 << 1; /** /** * The IME Switcher button is visible. This only takes effect while the IME is visible. * The IME Switcher button is visible. This only takes effect while the IME is visible. * * * @hide * @hide */ */ public static final int NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE = 1 << 2; public static final int NAVBAR_IME_SWITCHER_BUTTON_VISIBLE = 1 << 2; /** /** * Navigation bar flags related to the IME state. * Navigation bar state flags. * * * @hide * @hide */ */ @IntDef(flag = true, prefix = { "NAVIGATION_HINT_" }, value = { @IntDef(flag = true, prefix = { "NAVBAR_" }, value = { NAVIGATION_HINT_BACK_DISMISS_IME, NAVBAR_BACK_DISMISS_IME, NAVIGATION_HINT_IME_VISIBLE, NAVBAR_IME_VISIBLE, NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE, NAVBAR_IME_SWITCHER_BUTTON_VISIBLE, }) }) @Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE) public @interface NavigationHint {} public @interface NavbarFlags {} /** @hide */ /** @hide */ public static final int WINDOW_STATUS_BAR = 1; public static final int WINDOW_STATUS_BAR = 1; Loading Loading @@ -1355,18 +1355,18 @@ public class StatusBarManager { /** @hide */ /** @hide */ @NonNull @NonNull public static String navigationHintsToString(@NavigationHint int hints) { public static String navbarFlagsToString(@NavbarFlags int flags) { final var hintStrings = new ArrayList<String>(); final var flagStrings = new ArrayList<String>(); if ((hints & NAVIGATION_HINT_BACK_DISMISS_IME) != 0) { if ((flags & NAVBAR_BACK_DISMISS_IME) != 0) { hintStrings.add("NAVIGATION_HINT_BACK_DISMISS_IME"); flagStrings.add("NAVBAR_BACK_DISMISS_IME"); } } if ((hints & NAVIGATION_HINT_IME_VISIBLE) != 0) { if ((flags & NAVBAR_IME_VISIBLE) != 0) { hintStrings.add("NAVIGATION_HINT_IME_VISIBLE"); flagStrings.add("NAVBAR_IME_VISIBLE"); } } if ((hints & NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE) != 0) { if ((flags & NAVBAR_IME_SWITCHER_BUTTON_VISIBLE) != 0) { hintStrings.add("NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE"); flagStrings.add("NAVBAR_IME_SWITCHER_BUTTON_VISIBLE"); } } return String.join(" | ", hintStrings); return String.join(" | ", flagStrings); } } /** @hide */ /** @hide */ Loading core/java/android/inputmethodservice/NavigationBarController.java +11 −11 Original line number Original line Diff line number Diff line Loading @@ -16,9 +16,9 @@ package android.inputmethodservice; package android.inputmethodservice; import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_DISMISS_IME; import static android.app.StatusBarManager.NAVBAR_BACK_DISMISS_IME; import static android.app.StatusBarManager.NAVIGATION_HINT_IME_VISIBLE; import static android.app.StatusBarManager.NAVBAR_IME_SWITCHER_BUTTON_VISIBLE; import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE; import static android.app.StatusBarManager.NAVBAR_IME_VISIBLE; import static android.view.WindowInsets.Type.captionBar; import static android.view.WindowInsets.Type.captionBar; import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS; import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS; Loading Loading @@ -242,11 +242,11 @@ final class NavigationBarController { NavigationBarView.class::isInstance); NavigationBarView.class::isInstance); if (navigationBarView != null) { if (navigationBarView != null) { // TODO(b/213337792): Support InputMethodService#setBackDisposition(). // TODO(b/213337792): Support InputMethodService#setBackDisposition(). // TODO(b/213337792): Set NAVIGATION_HINT_IME_VISIBLE only when necessary. // TODO(b/213337792): Set NAVBAR_IME_VISIBLE only when necessary. final int hints = NAVIGATION_HINT_BACK_DISMISS_IME | NAVIGATION_HINT_IME_VISIBLE final int flags = NAVBAR_BACK_DISMISS_IME | NAVBAR_IME_VISIBLE | (mShouldShowImeSwitcherWhenImeIsShown | (mShouldShowImeSwitcherWhenImeIsShown ? NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE : 0); ? NAVBAR_IME_SWITCHER_BUTTON_VISIBLE : 0); navigationBarView.setNavigationIconHints(hints); navigationBarView.setNavbarFlags(flags); navigationBarView.prepareNavButtons(this); navigationBarView.prepareNavButtons(this); } } } else { } else { Loading Loading @@ -515,11 +515,11 @@ final class NavigationBarController { NavigationBarView.class::isInstance); NavigationBarView.class::isInstance); if (navigationBarView != null) { if (navigationBarView != null) { // TODO(b/213337792): Support InputMethodService#setBackDisposition(). // TODO(b/213337792): Support InputMethodService#setBackDisposition(). // TODO(b/213337792): Set NAVIGATION_HINT_IME_VISIBLE only when necessary. // TODO(b/213337792): Set NAVBAR_IME_VISIBLE only when necessary. final int hints = NAVIGATION_HINT_BACK_DISMISS_IME | NAVIGATION_HINT_IME_VISIBLE final int flags = NAVBAR_BACK_DISMISS_IME | NAVBAR_IME_VISIBLE | (mShouldShowImeSwitcherWhenImeIsShown | (mShouldShowImeSwitcherWhenImeIsShown ? NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE : 0); ? NAVBAR_IME_SWITCHER_BUTTON_VISIBLE : 0); navigationBarView.setNavigationIconHints(hints); navigationBarView.setNavbarFlags(flags); } } } else { } else { uninstallNavigationBarFrameIfNecessary(); uninstallNavigationBarFrameIfNecessary(); Loading core/java/android/inputmethodservice/navigationbar/NavigationBarView.java +15 −17 Original line number Original line Diff line number Diff line Loading @@ -16,8 +16,8 @@ package android.inputmethodservice.navigationbar; package android.inputmethodservice.navigationbar; import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_DISMISS_IME; import static android.app.StatusBarManager.NAVBAR_BACK_DISMISS_IME; import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE; import static android.app.StatusBarManager.NAVBAR_IME_SWITCHER_BUTTON_VISIBLE; import static android.inputmethodservice.navigationbar.NavigationBarConstants.DARK_MODE_ICON_COLOR_SINGLE_TONE; 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.LIGHT_MODE_ICON_COLOR_SINGLE_TONE; import static android.inputmethodservice.navigationbar.NavigationBarConstants.NAVBAR_BACK_BUTTON_IME_OFFSET; import static android.inputmethodservice.navigationbar.NavigationBarConstants.NAVBAR_BACK_BUTTON_IME_OFFSET; Loading @@ -30,7 +30,7 @@ import android.annotation.DrawableRes; import android.annotation.FloatRange; import android.annotation.FloatRange; import android.annotation.NonNull; import android.annotation.NonNull; import android.app.StatusBarManager; import android.app.StatusBarManager; import android.app.StatusBarManager.NavigationHint; import android.app.StatusBarManager.NavbarFlags; import android.content.Context; import android.content.Context; import android.content.res.Configuration; import android.content.res.Configuration; import android.graphics.Canvas; import android.graphics.Canvas; Loading Loading @@ -66,8 +66,8 @@ public final class NavigationBarView extends FrameLayout { private int mCurrentRotation = -1; private int mCurrentRotation = -1; int mDisabledFlags = 0; int mDisabledFlags = 0; @NavigationHint @NavbarFlags private int mNavigationIconHints = 0; private int mNavbarFlags; private final int mNavBarMode = NAV_BAR_MODE_GESTURAL; private final int mNavBarMode = NAV_BAR_MODE_GESTURAL; private KeyButtonDrawable mBackIcon; private KeyButtonDrawable mBackIcon; Loading Loading @@ -245,8 +245,7 @@ public final class NavigationBarView extends FrameLayout { } } private void orientBackButton(KeyButtonDrawable drawable) { private void orientBackButton(KeyButtonDrawable drawable) { final boolean isBackDismissIme = final boolean isBackDismissIme = (mNavbarFlags & NAVBAR_BACK_DISMISS_IME) != 0; (mNavigationIconHints & NAVIGATION_HINT_BACK_DISMISS_IME) != 0; final boolean isRtl = mConfiguration.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; final boolean isRtl = mConfiguration.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; float degrees = isBackDismissIme ? (isRtl ? 90 : -90) : 0; float degrees = isBackDismissIme ? (isRtl ? 90 : -90) : 0; if (drawable.getRotation() == degrees) { if (drawable.getRotation() == degrees) { Loading Loading @@ -284,27 +283,26 @@ public final class NavigationBarView extends FrameLayout { } } /** /** * Updates the navigation icons based on {@code hints}. * Sets the navigation bar state flags. * * * @param hints bit flags defined in {@link StatusBarManager}. * @param flags the navigation bar state flags. */ */ public void setNavigationIconHints(@NavigationHint int hints) { public void setNavbarFlags(@NavbarFlags int flags) { if (hints == mNavigationIconHints) { if (flags == mNavbarFlags) { return; return; } } final boolean backDismissIme = final boolean backDismissIme = (flags & StatusBarManager.NAVBAR_BACK_DISMISS_IME) != 0; (hints & StatusBarManager.NAVIGATION_HINT_BACK_DISMISS_IME) != 0; final boolean oldBackDismissIme = final boolean oldBackDismissIme = (mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_DISMISS_IME) != 0; (mNavbarFlags & StatusBarManager.NAVBAR_BACK_DISMISS_IME) != 0; if (backDismissIme != oldBackDismissIme) { if (backDismissIme != oldBackDismissIme) { //onBackDismissImeChanged(backDismissIme); //onBackDismissImeChanged(backDismissIme); } } if (DEBUG) { if (DEBUG) { android.widget.Toast.makeText(getContext(), "Navigation icon hints = " + hints, 500) android.widget.Toast.makeText(getContext(), "Navbar flags = " + flags, 500) .show(); .show(); } } mNavigationIconHints = hints; mNavbarFlags = flags; updateNavButtonIcons(); updateNavButtonIcons(); } } Loading @@ -321,7 +319,7 @@ public final class NavigationBarView extends FrameLayout { // Update IME switcher button visibility, a11y and rotate button always overrides // Update IME switcher button visibility, a11y and rotate button always overrides // the appearance. // the appearance. final boolean isImeSwitcherButtonVisible = final boolean isImeSwitcherButtonVisible = (mNavigationIconHints & NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE) != 0; (mNavbarFlags & NAVBAR_IME_SWITCHER_BUTTON_VISIBLE) != 0; getImeSwitchButton() getImeSwitchButton() .setVisibility(isImeSwitcherButtonVisible ? View.VISIBLE : View.INVISIBLE); .setVisibility(isImeSwitcherButtonVisible ? View.VISIBLE : View.INVISIBLE); Loading packages/SystemUI/multivalentTests/src/com/android/systemui/navigationbar/views/NavigationBarTest.java +31 −41 Original line number Original line Diff line number Diff line Loading @@ -16,9 +16,9 @@ package com.android.systemui.navigationbar.views; package com.android.systemui.navigationbar.views; import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_DISMISS_IME; import static android.app.StatusBarManager.NAVBAR_BACK_DISMISS_IME; import static android.app.StatusBarManager.NAVIGATION_HINT_IME_VISIBLE; import static android.app.StatusBarManager.NAVBAR_IME_SWITCHER_BUTTON_VISIBLE; import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE; import static android.app.StatusBarManager.NAVBAR_IME_VISIBLE; import static android.inputmethodservice.InputMethodService.BACK_DISPOSITION_ADJUST_NOTHING; import static android.inputmethodservice.InputMethodService.BACK_DISPOSITION_ADJUST_NOTHING; import static android.inputmethodservice.InputMethodService.BACK_DISPOSITION_DEFAULT; import static android.inputmethodservice.InputMethodService.BACK_DISPOSITION_DEFAULT; import static android.inputmethodservice.InputMethodService.IME_VISIBLE; import static android.inputmethodservice.InputMethodService.IME_VISIBLE; Loading @@ -32,8 +32,8 @@ import static com.android.systemui.navigationbar.views.NavigationBar.NavBarActio 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_LONGPRESS; import static com.android.systemui.navigationbar.views.buttons.KeyButtonView.NavBarButtonEvent.NAVBAR_IME_SWITCHER_BUTTON_TAP; 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_BACK_DISMISS_IME; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BACK_DISMISS_IME; 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_IME_SWITCHER_BUTTON_VISIBLE; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_IME_VISIBLE; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat; Loading Loading @@ -569,31 +569,27 @@ public class NavigationBarTest extends SysuiTestCase { externalNavBar.init(); externalNavBar.init(); defaultNavBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE, defaultNavBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE, BACK_DISPOSITION_DEFAULT, true); BACK_DISPOSITION_DEFAULT, true /* showImeSwitcher */); // Verify IME window state will be updated in default NavBar & external NavBar state reset. // Verify IME window state will be updated in default NavBar & external NavBar state reset. assertEquals(NAVIGATION_HINT_BACK_DISMISS_IME | NAVIGATION_HINT_IME_VISIBLE assertEquals(NAVBAR_BACK_DISMISS_IME | NAVBAR_IME_VISIBLE | NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE, | NAVBAR_IME_SWITCHER_BUTTON_VISIBLE, defaultNavBar.getNavigationIconHints()); defaultNavBar.getNavbarFlags()); assertFalse((externalNavBar.getNavigationIconHints() assertFalse((externalNavBar.getNavbarFlags() & NAVBAR_BACK_DISMISS_IME) != 0); & NAVIGATION_HINT_BACK_DISMISS_IME) != 0); assertFalse((externalNavBar.getNavbarFlags() & NAVBAR_IME_VISIBLE) != 0); assertFalse((externalNavBar.getNavigationIconHints() & NAVIGATION_HINT_IME_VISIBLE) != 0); assertFalse((externalNavBar.getNavbarFlags() & NAVBAR_IME_SWITCHER_BUTTON_VISIBLE) != 0); assertFalse((externalNavBar.getNavigationIconHints() & NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE) != 0); externalNavBar.setImeWindowStatus(EXTERNAL_DISPLAY_ID, IME_VISIBLE, externalNavBar.setImeWindowStatus(EXTERNAL_DISPLAY_ID, IME_VISIBLE, BACK_DISPOSITION_DEFAULT, true); BACK_DISPOSITION_DEFAULT, true /* showImeSwitcher */); defaultNavBar.setImeWindowStatus(DEFAULT_DISPLAY, 0 /* vis */, defaultNavBar.setImeWindowStatus(DEFAULT_DISPLAY, 0 /* vis */, BACK_DISPOSITION_DEFAULT, false); BACK_DISPOSITION_DEFAULT, false /* showImeSwitcher */); // Verify IME window state will be updated in external NavBar & default NavBar state reset. // Verify IME window state will be updated in external NavBar & default NavBar state reset. assertEquals(NAVIGATION_HINT_BACK_DISMISS_IME | NAVIGATION_HINT_IME_VISIBLE assertEquals(NAVBAR_BACK_DISMISS_IME | NAVBAR_IME_VISIBLE | NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE, | NAVBAR_IME_SWITCHER_BUTTON_VISIBLE, externalNavBar.getNavigationIconHints()); externalNavBar.getNavbarFlags()); assertFalse((defaultNavBar.getNavigationIconHints() assertFalse((defaultNavBar.getNavbarFlags() & NAVBAR_BACK_DISMISS_IME) != 0); & NAVIGATION_HINT_BACK_DISMISS_IME) != 0); assertFalse((defaultNavBar.getNavbarFlags() & NAVBAR_IME_VISIBLE) != 0); assertFalse((defaultNavBar.getNavigationIconHints() & NAVIGATION_HINT_IME_VISIBLE) != 0); assertFalse((defaultNavBar.getNavbarFlags() & NAVBAR_IME_SWITCHER_BUTTON_VISIBLE) != 0); assertFalse((defaultNavBar.getNavigationIconHints() & NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE) != 0); } } @Test @Test Loading @@ -608,35 +604,29 @@ public class NavigationBarTest extends SysuiTestCase { // Verify navbar altered back icon when an app is showing IME // Verify navbar altered back icon when an app is showing IME mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE, mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE, BACK_DISPOSITION_DEFAULT, true); BACK_DISPOSITION_DEFAULT, true /* showImeSwitcher */); assertTrue((mNavigationBar.getNavigationIconHints() assertTrue((mNavigationBar.getNavbarFlags() & NAVBAR_BACK_DISMISS_IME) != 0); & NAVIGATION_HINT_BACK_DISMISS_IME) != 0); assertTrue((mNavigationBar.getNavbarFlags() & NAVBAR_IME_VISIBLE) != 0); assertTrue((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_IME_VISIBLE) != 0); assertTrue((mNavigationBar.getNavbarFlags() & NAVBAR_IME_SWITCHER_BUTTON_VISIBLE) != 0); assertTrue((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE) != 0); // Verify navbar didn't alter and showing back icon when the keyguard is showing without // Verify navbar didn't alter and showing back icon when the keyguard is showing without // requesting IME insets visible. // requesting IME insets visible. doReturn(true).when(mKeyguardStateController).isShowing(); doReturn(true).when(mKeyguardStateController).isShowing(); mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE, mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE, BACK_DISPOSITION_DEFAULT, true); BACK_DISPOSITION_DEFAULT, true /* showImeSwitcher */); assertFalse((mNavigationBar.getNavigationIconHints() assertFalse((mNavigationBar.getNavbarFlags() & NAVBAR_BACK_DISMISS_IME) != 0); & NAVIGATION_HINT_BACK_DISMISS_IME) != 0); assertFalse((mNavigationBar.getNavbarFlags() & NAVBAR_IME_VISIBLE) != 0); assertFalse((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_IME_VISIBLE) != 0); assertFalse((mNavigationBar.getNavbarFlags() & NAVBAR_IME_SWITCHER_BUTTON_VISIBLE) != 0); assertFalse((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE) != 0); // Verify navbar altered and showing back icon when the keyguard is showing and // Verify navbar altered and showing back icon when the keyguard is showing and // requesting IME insets visible. // requesting IME insets visible. windowInsets = new WindowInsets.Builder().setVisible(ime(), true).build(); windowInsets = new WindowInsets.Builder().setVisible(ime(), true).build(); doReturn(windowInsets).when(mockShadeWindowView).getRootWindowInsets(); doReturn(windowInsets).when(mockShadeWindowView).getRootWindowInsets(); mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE, mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE, BACK_DISPOSITION_DEFAULT, true); BACK_DISPOSITION_DEFAULT, true /* showImeSwitcher */); assertTrue((mNavigationBar.getNavigationIconHints() assertTrue((mNavigationBar.getNavbarFlags() & NAVBAR_BACK_DISMISS_IME) != 0); & NAVIGATION_HINT_BACK_DISMISS_IME) != 0); assertTrue((mNavigationBar.getNavbarFlags() & NAVBAR_IME_VISIBLE) != 0); assertTrue((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_IME_VISIBLE) != 0); assertTrue((mNavigationBar.getNavbarFlags() & NAVBAR_IME_SWITCHER_BUTTON_VISIBLE) != 0); assertTrue((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE) != 0); } } @Test @Test Loading packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/Utilities.java +17 −17 Original line number Original line Diff line number Diff line Loading @@ -16,12 +16,12 @@ package com.android.systemui.shared.recents.utilities; package com.android.systemui.shared.recents.utilities; import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_DISMISS_IME; import static android.app.StatusBarManager.NAVBAR_BACK_DISMISS_IME; import static android.app.StatusBarManager.NAVIGATION_HINT_IME_VISIBLE; import static android.app.StatusBarManager.NAVBAR_IME_SWITCHER_BUTTON_VISIBLE; import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE; import static android.app.StatusBarManager.NAVBAR_IME_VISIBLE; import android.annotation.TargetApi; import android.annotation.TargetApi; import android.app.StatusBarManager.NavigationHint; import android.app.StatusBarManager.NavbarFlags; import android.content.Context; import android.content.Context; import android.content.res.Resources; import android.content.res.Resources; import android.graphics.Color; import android.graphics.Color; Loading Loading @@ -104,46 +104,46 @@ public class Utilities { } } /** /** * Gets the updated navigation icon hints, based on the current ones and the given IME state. * Updates the navigation bar state flags with the given IME state. * * * @param oldHints current navigation icon hints. * @param oldFlags current navigation bar state flags. * @param backDisposition the IME back disposition mode. Only takes effect if * @param backDisposition the IME back disposition mode. Only takes effect if * {@code isImeVisible} is {@code true}. * {@code isImeVisible} is {@code true}. * @param isImeVisible whether the IME is currently visible. * @param isImeVisible whether the IME is currently visible. * @param showImeSwitcher whether the IME Switcher button should be shown. Only takes effect if * @param showImeSwitcher whether the IME Switcher button should be shown. Only takes effect if * {@code isImeVisible} is {@code true}. * {@code isImeVisible} is {@code true}. */ */ @NavigationHint @NavbarFlags public static int calculateNavigationIconHints(@NavigationHint int oldHints, public static int updateNavbarFlagsFromIme(@NavbarFlags int oldFlags, @BackDispositionMode int backDisposition, boolean isImeVisible, @BackDispositionMode int backDisposition, boolean isImeVisible, boolean showImeSwitcher) { boolean showImeSwitcher) { int hints = oldHints; int flags = oldFlags; switch (backDisposition) { switch (backDisposition) { case InputMethodService.BACK_DISPOSITION_DEFAULT: case InputMethodService.BACK_DISPOSITION_DEFAULT: case InputMethodService.BACK_DISPOSITION_WILL_NOT_DISMISS: case InputMethodService.BACK_DISPOSITION_WILL_NOT_DISMISS: case InputMethodService.BACK_DISPOSITION_WILL_DISMISS: case InputMethodService.BACK_DISPOSITION_WILL_DISMISS: if (isImeVisible) { if (isImeVisible) { hints |= NAVIGATION_HINT_BACK_DISMISS_IME; flags |= NAVBAR_BACK_DISMISS_IME; } else { } else { hints &= ~NAVIGATION_HINT_BACK_DISMISS_IME; flags &= ~NAVBAR_BACK_DISMISS_IME; } } break; break; case InputMethodService.BACK_DISPOSITION_ADJUST_NOTHING: case InputMethodService.BACK_DISPOSITION_ADJUST_NOTHING: hints &= ~NAVIGATION_HINT_BACK_DISMISS_IME; flags &= ~NAVBAR_BACK_DISMISS_IME; break; break; } } if (isImeVisible) { if (isImeVisible) { hints |= NAVIGATION_HINT_IME_VISIBLE; flags |= NAVBAR_IME_VISIBLE; } else { } else { hints &= ~NAVIGATION_HINT_IME_VISIBLE; flags &= ~NAVBAR_IME_VISIBLE; } } if (showImeSwitcher && isImeVisible) { if (showImeSwitcher && isImeVisible) { hints |= NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE; flags |= NAVBAR_IME_SWITCHER_BUTTON_VISIBLE; } else { } else { hints &= ~NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE; flags &= ~NAVBAR_IME_SWITCHER_BUTTON_VISIBLE; } } return hints; return flags; } } /** @return whether or not {@param context} represents that of a large screen device or not */ /** @return whether or not {@param context} represents that of a large screen device or not */ Loading Loading
core/java/android/app/StatusBarManager.java +18 −18 Original line number Original line Diff line number Diff line Loading @@ -205,31 +205,31 @@ public class StatusBarManager { * * * @hide * @hide */ */ public static final int NAVIGATION_HINT_BACK_DISMISS_IME = 1 << 0; public static final int NAVBAR_BACK_DISMISS_IME = 1 << 0; /** /** * The IME is visible. * The IME is visible. * * * @hide * @hide */ */ public static final int NAVIGATION_HINT_IME_VISIBLE = 1 << 1; public static final int NAVBAR_IME_VISIBLE = 1 << 1; /** /** * The IME Switcher button is visible. This only takes effect while the IME is visible. * The IME Switcher button is visible. This only takes effect while the IME is visible. * * * @hide * @hide */ */ public static final int NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE = 1 << 2; public static final int NAVBAR_IME_SWITCHER_BUTTON_VISIBLE = 1 << 2; /** /** * Navigation bar flags related to the IME state. * Navigation bar state flags. * * * @hide * @hide */ */ @IntDef(flag = true, prefix = { "NAVIGATION_HINT_" }, value = { @IntDef(flag = true, prefix = { "NAVBAR_" }, value = { NAVIGATION_HINT_BACK_DISMISS_IME, NAVBAR_BACK_DISMISS_IME, NAVIGATION_HINT_IME_VISIBLE, NAVBAR_IME_VISIBLE, NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE, NAVBAR_IME_SWITCHER_BUTTON_VISIBLE, }) }) @Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE) public @interface NavigationHint {} public @interface NavbarFlags {} /** @hide */ /** @hide */ public static final int WINDOW_STATUS_BAR = 1; public static final int WINDOW_STATUS_BAR = 1; Loading Loading @@ -1355,18 +1355,18 @@ public class StatusBarManager { /** @hide */ /** @hide */ @NonNull @NonNull public static String navigationHintsToString(@NavigationHint int hints) { public static String navbarFlagsToString(@NavbarFlags int flags) { final var hintStrings = new ArrayList<String>(); final var flagStrings = new ArrayList<String>(); if ((hints & NAVIGATION_HINT_BACK_DISMISS_IME) != 0) { if ((flags & NAVBAR_BACK_DISMISS_IME) != 0) { hintStrings.add("NAVIGATION_HINT_BACK_DISMISS_IME"); flagStrings.add("NAVBAR_BACK_DISMISS_IME"); } } if ((hints & NAVIGATION_HINT_IME_VISIBLE) != 0) { if ((flags & NAVBAR_IME_VISIBLE) != 0) { hintStrings.add("NAVIGATION_HINT_IME_VISIBLE"); flagStrings.add("NAVBAR_IME_VISIBLE"); } } if ((hints & NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE) != 0) { if ((flags & NAVBAR_IME_SWITCHER_BUTTON_VISIBLE) != 0) { hintStrings.add("NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE"); flagStrings.add("NAVBAR_IME_SWITCHER_BUTTON_VISIBLE"); } } return String.join(" | ", hintStrings); return String.join(" | ", flagStrings); } } /** @hide */ /** @hide */ Loading
core/java/android/inputmethodservice/NavigationBarController.java +11 −11 Original line number Original line Diff line number Diff line Loading @@ -16,9 +16,9 @@ package android.inputmethodservice; package android.inputmethodservice; import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_DISMISS_IME; import static android.app.StatusBarManager.NAVBAR_BACK_DISMISS_IME; import static android.app.StatusBarManager.NAVIGATION_HINT_IME_VISIBLE; import static android.app.StatusBarManager.NAVBAR_IME_SWITCHER_BUTTON_VISIBLE; import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE; import static android.app.StatusBarManager.NAVBAR_IME_VISIBLE; import static android.view.WindowInsets.Type.captionBar; import static android.view.WindowInsets.Type.captionBar; import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS; import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS; Loading Loading @@ -242,11 +242,11 @@ final class NavigationBarController { NavigationBarView.class::isInstance); NavigationBarView.class::isInstance); if (navigationBarView != null) { if (navigationBarView != null) { // TODO(b/213337792): Support InputMethodService#setBackDisposition(). // TODO(b/213337792): Support InputMethodService#setBackDisposition(). // TODO(b/213337792): Set NAVIGATION_HINT_IME_VISIBLE only when necessary. // TODO(b/213337792): Set NAVBAR_IME_VISIBLE only when necessary. final int hints = NAVIGATION_HINT_BACK_DISMISS_IME | NAVIGATION_HINT_IME_VISIBLE final int flags = NAVBAR_BACK_DISMISS_IME | NAVBAR_IME_VISIBLE | (mShouldShowImeSwitcherWhenImeIsShown | (mShouldShowImeSwitcherWhenImeIsShown ? NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE : 0); ? NAVBAR_IME_SWITCHER_BUTTON_VISIBLE : 0); navigationBarView.setNavigationIconHints(hints); navigationBarView.setNavbarFlags(flags); navigationBarView.prepareNavButtons(this); navigationBarView.prepareNavButtons(this); } } } else { } else { Loading Loading @@ -515,11 +515,11 @@ final class NavigationBarController { NavigationBarView.class::isInstance); NavigationBarView.class::isInstance); if (navigationBarView != null) { if (navigationBarView != null) { // TODO(b/213337792): Support InputMethodService#setBackDisposition(). // TODO(b/213337792): Support InputMethodService#setBackDisposition(). // TODO(b/213337792): Set NAVIGATION_HINT_IME_VISIBLE only when necessary. // TODO(b/213337792): Set NAVBAR_IME_VISIBLE only when necessary. final int hints = NAVIGATION_HINT_BACK_DISMISS_IME | NAVIGATION_HINT_IME_VISIBLE final int flags = NAVBAR_BACK_DISMISS_IME | NAVBAR_IME_VISIBLE | (mShouldShowImeSwitcherWhenImeIsShown | (mShouldShowImeSwitcherWhenImeIsShown ? NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE : 0); ? NAVBAR_IME_SWITCHER_BUTTON_VISIBLE : 0); navigationBarView.setNavigationIconHints(hints); navigationBarView.setNavbarFlags(flags); } } } else { } else { uninstallNavigationBarFrameIfNecessary(); uninstallNavigationBarFrameIfNecessary(); Loading
core/java/android/inputmethodservice/navigationbar/NavigationBarView.java +15 −17 Original line number Original line Diff line number Diff line Loading @@ -16,8 +16,8 @@ package android.inputmethodservice.navigationbar; package android.inputmethodservice.navigationbar; import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_DISMISS_IME; import static android.app.StatusBarManager.NAVBAR_BACK_DISMISS_IME; import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE; import static android.app.StatusBarManager.NAVBAR_IME_SWITCHER_BUTTON_VISIBLE; import static android.inputmethodservice.navigationbar.NavigationBarConstants.DARK_MODE_ICON_COLOR_SINGLE_TONE; 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.LIGHT_MODE_ICON_COLOR_SINGLE_TONE; import static android.inputmethodservice.navigationbar.NavigationBarConstants.NAVBAR_BACK_BUTTON_IME_OFFSET; import static android.inputmethodservice.navigationbar.NavigationBarConstants.NAVBAR_BACK_BUTTON_IME_OFFSET; Loading @@ -30,7 +30,7 @@ import android.annotation.DrawableRes; import android.annotation.FloatRange; import android.annotation.FloatRange; import android.annotation.NonNull; import android.annotation.NonNull; import android.app.StatusBarManager; import android.app.StatusBarManager; import android.app.StatusBarManager.NavigationHint; import android.app.StatusBarManager.NavbarFlags; import android.content.Context; import android.content.Context; import android.content.res.Configuration; import android.content.res.Configuration; import android.graphics.Canvas; import android.graphics.Canvas; Loading Loading @@ -66,8 +66,8 @@ public final class NavigationBarView extends FrameLayout { private int mCurrentRotation = -1; private int mCurrentRotation = -1; int mDisabledFlags = 0; int mDisabledFlags = 0; @NavigationHint @NavbarFlags private int mNavigationIconHints = 0; private int mNavbarFlags; private final int mNavBarMode = NAV_BAR_MODE_GESTURAL; private final int mNavBarMode = NAV_BAR_MODE_GESTURAL; private KeyButtonDrawable mBackIcon; private KeyButtonDrawable mBackIcon; Loading Loading @@ -245,8 +245,7 @@ public final class NavigationBarView extends FrameLayout { } } private void orientBackButton(KeyButtonDrawable drawable) { private void orientBackButton(KeyButtonDrawable drawable) { final boolean isBackDismissIme = final boolean isBackDismissIme = (mNavbarFlags & NAVBAR_BACK_DISMISS_IME) != 0; (mNavigationIconHints & NAVIGATION_HINT_BACK_DISMISS_IME) != 0; final boolean isRtl = mConfiguration.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; final boolean isRtl = mConfiguration.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; float degrees = isBackDismissIme ? (isRtl ? 90 : -90) : 0; float degrees = isBackDismissIme ? (isRtl ? 90 : -90) : 0; if (drawable.getRotation() == degrees) { if (drawable.getRotation() == degrees) { Loading Loading @@ -284,27 +283,26 @@ public final class NavigationBarView extends FrameLayout { } } /** /** * Updates the navigation icons based on {@code hints}. * Sets the navigation bar state flags. * * * @param hints bit flags defined in {@link StatusBarManager}. * @param flags the navigation bar state flags. */ */ public void setNavigationIconHints(@NavigationHint int hints) { public void setNavbarFlags(@NavbarFlags int flags) { if (hints == mNavigationIconHints) { if (flags == mNavbarFlags) { return; return; } } final boolean backDismissIme = final boolean backDismissIme = (flags & StatusBarManager.NAVBAR_BACK_DISMISS_IME) != 0; (hints & StatusBarManager.NAVIGATION_HINT_BACK_DISMISS_IME) != 0; final boolean oldBackDismissIme = final boolean oldBackDismissIme = (mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_DISMISS_IME) != 0; (mNavbarFlags & StatusBarManager.NAVBAR_BACK_DISMISS_IME) != 0; if (backDismissIme != oldBackDismissIme) { if (backDismissIme != oldBackDismissIme) { //onBackDismissImeChanged(backDismissIme); //onBackDismissImeChanged(backDismissIme); } } if (DEBUG) { if (DEBUG) { android.widget.Toast.makeText(getContext(), "Navigation icon hints = " + hints, 500) android.widget.Toast.makeText(getContext(), "Navbar flags = " + flags, 500) .show(); .show(); } } mNavigationIconHints = hints; mNavbarFlags = flags; updateNavButtonIcons(); updateNavButtonIcons(); } } Loading @@ -321,7 +319,7 @@ public final class NavigationBarView extends FrameLayout { // Update IME switcher button visibility, a11y and rotate button always overrides // Update IME switcher button visibility, a11y and rotate button always overrides // the appearance. // the appearance. final boolean isImeSwitcherButtonVisible = final boolean isImeSwitcherButtonVisible = (mNavigationIconHints & NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE) != 0; (mNavbarFlags & NAVBAR_IME_SWITCHER_BUTTON_VISIBLE) != 0; getImeSwitchButton() getImeSwitchButton() .setVisibility(isImeSwitcherButtonVisible ? View.VISIBLE : View.INVISIBLE); .setVisibility(isImeSwitcherButtonVisible ? View.VISIBLE : View.INVISIBLE); Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/navigationbar/views/NavigationBarTest.java +31 −41 Original line number Original line Diff line number Diff line Loading @@ -16,9 +16,9 @@ package com.android.systemui.navigationbar.views; package com.android.systemui.navigationbar.views; import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_DISMISS_IME; import static android.app.StatusBarManager.NAVBAR_BACK_DISMISS_IME; import static android.app.StatusBarManager.NAVIGATION_HINT_IME_VISIBLE; import static android.app.StatusBarManager.NAVBAR_IME_SWITCHER_BUTTON_VISIBLE; import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE; import static android.app.StatusBarManager.NAVBAR_IME_VISIBLE; import static android.inputmethodservice.InputMethodService.BACK_DISPOSITION_ADJUST_NOTHING; import static android.inputmethodservice.InputMethodService.BACK_DISPOSITION_ADJUST_NOTHING; import static android.inputmethodservice.InputMethodService.BACK_DISPOSITION_DEFAULT; import static android.inputmethodservice.InputMethodService.BACK_DISPOSITION_DEFAULT; import static android.inputmethodservice.InputMethodService.IME_VISIBLE; import static android.inputmethodservice.InputMethodService.IME_VISIBLE; Loading @@ -32,8 +32,8 @@ import static com.android.systemui.navigationbar.views.NavigationBar.NavBarActio 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_LONGPRESS; import static com.android.systemui.navigationbar.views.buttons.KeyButtonView.NavBarButtonEvent.NAVBAR_IME_SWITCHER_BUTTON_TAP; 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_BACK_DISMISS_IME; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BACK_DISMISS_IME; 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_IME_SWITCHER_BUTTON_VISIBLE; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_IME_VISIBLE; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat; Loading Loading @@ -569,31 +569,27 @@ public class NavigationBarTest extends SysuiTestCase { externalNavBar.init(); externalNavBar.init(); defaultNavBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE, defaultNavBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE, BACK_DISPOSITION_DEFAULT, true); BACK_DISPOSITION_DEFAULT, true /* showImeSwitcher */); // Verify IME window state will be updated in default NavBar & external NavBar state reset. // Verify IME window state will be updated in default NavBar & external NavBar state reset. assertEquals(NAVIGATION_HINT_BACK_DISMISS_IME | NAVIGATION_HINT_IME_VISIBLE assertEquals(NAVBAR_BACK_DISMISS_IME | NAVBAR_IME_VISIBLE | NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE, | NAVBAR_IME_SWITCHER_BUTTON_VISIBLE, defaultNavBar.getNavigationIconHints()); defaultNavBar.getNavbarFlags()); assertFalse((externalNavBar.getNavigationIconHints() assertFalse((externalNavBar.getNavbarFlags() & NAVBAR_BACK_DISMISS_IME) != 0); & NAVIGATION_HINT_BACK_DISMISS_IME) != 0); assertFalse((externalNavBar.getNavbarFlags() & NAVBAR_IME_VISIBLE) != 0); assertFalse((externalNavBar.getNavigationIconHints() & NAVIGATION_HINT_IME_VISIBLE) != 0); assertFalse((externalNavBar.getNavbarFlags() & NAVBAR_IME_SWITCHER_BUTTON_VISIBLE) != 0); assertFalse((externalNavBar.getNavigationIconHints() & NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE) != 0); externalNavBar.setImeWindowStatus(EXTERNAL_DISPLAY_ID, IME_VISIBLE, externalNavBar.setImeWindowStatus(EXTERNAL_DISPLAY_ID, IME_VISIBLE, BACK_DISPOSITION_DEFAULT, true); BACK_DISPOSITION_DEFAULT, true /* showImeSwitcher */); defaultNavBar.setImeWindowStatus(DEFAULT_DISPLAY, 0 /* vis */, defaultNavBar.setImeWindowStatus(DEFAULT_DISPLAY, 0 /* vis */, BACK_DISPOSITION_DEFAULT, false); BACK_DISPOSITION_DEFAULT, false /* showImeSwitcher */); // Verify IME window state will be updated in external NavBar & default NavBar state reset. // Verify IME window state will be updated in external NavBar & default NavBar state reset. assertEquals(NAVIGATION_HINT_BACK_DISMISS_IME | NAVIGATION_HINT_IME_VISIBLE assertEquals(NAVBAR_BACK_DISMISS_IME | NAVBAR_IME_VISIBLE | NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE, | NAVBAR_IME_SWITCHER_BUTTON_VISIBLE, externalNavBar.getNavigationIconHints()); externalNavBar.getNavbarFlags()); assertFalse((defaultNavBar.getNavigationIconHints() assertFalse((defaultNavBar.getNavbarFlags() & NAVBAR_BACK_DISMISS_IME) != 0); & NAVIGATION_HINT_BACK_DISMISS_IME) != 0); assertFalse((defaultNavBar.getNavbarFlags() & NAVBAR_IME_VISIBLE) != 0); assertFalse((defaultNavBar.getNavigationIconHints() & NAVIGATION_HINT_IME_VISIBLE) != 0); assertFalse((defaultNavBar.getNavbarFlags() & NAVBAR_IME_SWITCHER_BUTTON_VISIBLE) != 0); assertFalse((defaultNavBar.getNavigationIconHints() & NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE) != 0); } } @Test @Test Loading @@ -608,35 +604,29 @@ public class NavigationBarTest extends SysuiTestCase { // Verify navbar altered back icon when an app is showing IME // Verify navbar altered back icon when an app is showing IME mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE, mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE, BACK_DISPOSITION_DEFAULT, true); BACK_DISPOSITION_DEFAULT, true /* showImeSwitcher */); assertTrue((mNavigationBar.getNavigationIconHints() assertTrue((mNavigationBar.getNavbarFlags() & NAVBAR_BACK_DISMISS_IME) != 0); & NAVIGATION_HINT_BACK_DISMISS_IME) != 0); assertTrue((mNavigationBar.getNavbarFlags() & NAVBAR_IME_VISIBLE) != 0); assertTrue((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_IME_VISIBLE) != 0); assertTrue((mNavigationBar.getNavbarFlags() & NAVBAR_IME_SWITCHER_BUTTON_VISIBLE) != 0); assertTrue((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE) != 0); // Verify navbar didn't alter and showing back icon when the keyguard is showing without // Verify navbar didn't alter and showing back icon when the keyguard is showing without // requesting IME insets visible. // requesting IME insets visible. doReturn(true).when(mKeyguardStateController).isShowing(); doReturn(true).when(mKeyguardStateController).isShowing(); mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE, mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE, BACK_DISPOSITION_DEFAULT, true); BACK_DISPOSITION_DEFAULT, true /* showImeSwitcher */); assertFalse((mNavigationBar.getNavigationIconHints() assertFalse((mNavigationBar.getNavbarFlags() & NAVBAR_BACK_DISMISS_IME) != 0); & NAVIGATION_HINT_BACK_DISMISS_IME) != 0); assertFalse((mNavigationBar.getNavbarFlags() & NAVBAR_IME_VISIBLE) != 0); assertFalse((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_IME_VISIBLE) != 0); assertFalse((mNavigationBar.getNavbarFlags() & NAVBAR_IME_SWITCHER_BUTTON_VISIBLE) != 0); assertFalse((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE) != 0); // Verify navbar altered and showing back icon when the keyguard is showing and // Verify navbar altered and showing back icon when the keyguard is showing and // requesting IME insets visible. // requesting IME insets visible. windowInsets = new WindowInsets.Builder().setVisible(ime(), true).build(); windowInsets = new WindowInsets.Builder().setVisible(ime(), true).build(); doReturn(windowInsets).when(mockShadeWindowView).getRootWindowInsets(); doReturn(windowInsets).when(mockShadeWindowView).getRootWindowInsets(); mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE, mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, IME_VISIBLE, BACK_DISPOSITION_DEFAULT, true); BACK_DISPOSITION_DEFAULT, true /* showImeSwitcher */); assertTrue((mNavigationBar.getNavigationIconHints() assertTrue((mNavigationBar.getNavbarFlags() & NAVBAR_BACK_DISMISS_IME) != 0); & NAVIGATION_HINT_BACK_DISMISS_IME) != 0); assertTrue((mNavigationBar.getNavbarFlags() & NAVBAR_IME_VISIBLE) != 0); assertTrue((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_IME_VISIBLE) != 0); assertTrue((mNavigationBar.getNavbarFlags() & NAVBAR_IME_SWITCHER_BUTTON_VISIBLE) != 0); assertTrue((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE) != 0); } } @Test @Test Loading
packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/Utilities.java +17 −17 Original line number Original line Diff line number Diff line Loading @@ -16,12 +16,12 @@ package com.android.systemui.shared.recents.utilities; package com.android.systemui.shared.recents.utilities; import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_DISMISS_IME; import static android.app.StatusBarManager.NAVBAR_BACK_DISMISS_IME; import static android.app.StatusBarManager.NAVIGATION_HINT_IME_VISIBLE; import static android.app.StatusBarManager.NAVBAR_IME_SWITCHER_BUTTON_VISIBLE; import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE; import static android.app.StatusBarManager.NAVBAR_IME_VISIBLE; import android.annotation.TargetApi; import android.annotation.TargetApi; import android.app.StatusBarManager.NavigationHint; import android.app.StatusBarManager.NavbarFlags; import android.content.Context; import android.content.Context; import android.content.res.Resources; import android.content.res.Resources; import android.graphics.Color; import android.graphics.Color; Loading Loading @@ -104,46 +104,46 @@ public class Utilities { } } /** /** * Gets the updated navigation icon hints, based on the current ones and the given IME state. * Updates the navigation bar state flags with the given IME state. * * * @param oldHints current navigation icon hints. * @param oldFlags current navigation bar state flags. * @param backDisposition the IME back disposition mode. Only takes effect if * @param backDisposition the IME back disposition mode. Only takes effect if * {@code isImeVisible} is {@code true}. * {@code isImeVisible} is {@code true}. * @param isImeVisible whether the IME is currently visible. * @param isImeVisible whether the IME is currently visible. * @param showImeSwitcher whether the IME Switcher button should be shown. Only takes effect if * @param showImeSwitcher whether the IME Switcher button should be shown. Only takes effect if * {@code isImeVisible} is {@code true}. * {@code isImeVisible} is {@code true}. */ */ @NavigationHint @NavbarFlags public static int calculateNavigationIconHints(@NavigationHint int oldHints, public static int updateNavbarFlagsFromIme(@NavbarFlags int oldFlags, @BackDispositionMode int backDisposition, boolean isImeVisible, @BackDispositionMode int backDisposition, boolean isImeVisible, boolean showImeSwitcher) { boolean showImeSwitcher) { int hints = oldHints; int flags = oldFlags; switch (backDisposition) { switch (backDisposition) { case InputMethodService.BACK_DISPOSITION_DEFAULT: case InputMethodService.BACK_DISPOSITION_DEFAULT: case InputMethodService.BACK_DISPOSITION_WILL_NOT_DISMISS: case InputMethodService.BACK_DISPOSITION_WILL_NOT_DISMISS: case InputMethodService.BACK_DISPOSITION_WILL_DISMISS: case InputMethodService.BACK_DISPOSITION_WILL_DISMISS: if (isImeVisible) { if (isImeVisible) { hints |= NAVIGATION_HINT_BACK_DISMISS_IME; flags |= NAVBAR_BACK_DISMISS_IME; } else { } else { hints &= ~NAVIGATION_HINT_BACK_DISMISS_IME; flags &= ~NAVBAR_BACK_DISMISS_IME; } } break; break; case InputMethodService.BACK_DISPOSITION_ADJUST_NOTHING: case InputMethodService.BACK_DISPOSITION_ADJUST_NOTHING: hints &= ~NAVIGATION_HINT_BACK_DISMISS_IME; flags &= ~NAVBAR_BACK_DISMISS_IME; break; break; } } if (isImeVisible) { if (isImeVisible) { hints |= NAVIGATION_HINT_IME_VISIBLE; flags |= NAVBAR_IME_VISIBLE; } else { } else { hints &= ~NAVIGATION_HINT_IME_VISIBLE; flags &= ~NAVBAR_IME_VISIBLE; } } if (showImeSwitcher && isImeVisible) { if (showImeSwitcher && isImeVisible) { hints |= NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE; flags |= NAVBAR_IME_SWITCHER_BUTTON_VISIBLE; } else { } else { hints &= ~NAVIGATION_HINT_IME_SWITCHER_BUTTON_VISIBLE; flags &= ~NAVBAR_IME_SWITCHER_BUTTON_VISIBLE; } } return hints; return flags; } } /** @return whether or not {@param context} represents that of a large screen device or not */ /** @return whether or not {@param context} represents that of a large screen device or not */ Loading