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

Commit d0878262 authored by Cosmin Băieș's avatar Cosmin Băieș
Browse files

Clarify state names for IME Switcher button

We had a few instances of properties referencing the IME Switcher or its
visibility, when in fact this was related to the button, not the menu.

This clarifies the names for these states, as well as adding some
documentation around where these values are used/passed.

Flag: EXEMPT bugfix
Bug: 366129400
Test: n/a
Change-Id: Ia75cdbfcd0cf4642bc747a132c8500908c869885
parent 1d0b620c
Loading
Loading
Loading
Loading
+51 −6
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import com.android.internal.statusbar.NotificationVisibility;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -195,12 +196,40 @@ public class StatusBarManager {
     */
    private static final int DEFAULT_SIM_LOCKED_DISABLED_FLAGS = DISABLE_EXPAND;

    /** @hide */
    /**
     * The back button is visually adjusted to indicate that it will dismiss the IME when pressed.
     * This only takes effect while the IME is visible. By default, it is set while the IME is
     * visible, but may be overridden by the
     * {@link android.inputmethodservice.InputMethodService.BackDispositionMode backDispositionMode}
     * set by the IME.
     *
     * @hide
     */
    public static final int NAVIGATION_HINT_BACK_ALT = 1 << 0;
    /** @hide */
    /**
     * The IME is visible.
     *
     * @hide
     */
    public static final int NAVIGATION_HINT_IME_SHOWN = 1 << 1;
    /** @hide */
    public static final int NAVIGATION_HINT_IME_SWITCHER_SHOWN = 1 << 2;
    /**
     * 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;
    /**
     * Navigation bar flags related to the IME state.
     *
     * @hide
     */
    @IntDef(flag = true, prefix = { "NAVIGATION_HINT_" }, value = {
            NAVIGATION_HINT_BACK_ALT,
            NAVIGATION_HINT_IME_SHOWN,
            NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface NavigationHint {}

    /** @hide */
    public static final int WINDOW_STATUS_BAR = 1;
@@ -1324,6 +1353,22 @@ public class StatusBarManager {
                .canLaunchCaptureContentActivityForNote(taskId);
    }

    /** @hide */
    @NonNull
    public static String navigationHintsToString(@NavigationHint int hints) {
        final var hintStrings = new ArrayList<String>();
        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_SWITCHER_BUTTON_SHOWN) != 0) {
            hintStrings.add("NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN");
        }
        return String.join(" | ", hintStrings);
    }

    /** @hide */
    public static String windowStateToString(int state) {
        if (state == WINDOW_STATE_HIDING) return "WINDOW_STATE_HIDING";
+3 −3
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ 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.app.StatusBarManager.NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN;
import static android.view.WindowInsets.Type.captionBar;
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;

@@ -245,7 +245,7 @@ final class NavigationBarController {
                    // 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);
                                    ? NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN : 0);
                    navigationBarView.setNavigationIconHints(hints);
                    navigationBarView.prepareNavButtons(this);
                }
@@ -518,7 +518,7 @@ final class NavigationBarController {
                    // 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);
                                    ? NAVIGATION_HINT_IME_SWITCHER_BUTTON_SHOWN : 0);
                    navigationBarView.setNavigationIconHints(hints);
                }
            } else {
+14 −8
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

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.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;
@@ -28,6 +30,7 @@ import android.annotation.DrawableRes;
import android.annotation.FloatRange;
import android.annotation.NonNull;
import android.app.StatusBarManager;
import android.app.StatusBarManager.NavigationHint;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Canvas;
@@ -63,7 +66,8 @@ public final class NavigationBarView extends FrameLayout {
    private int mCurrentRotation = -1;

    int mDisabledFlags = 0;
    int mNavigationIconHints = StatusBarManager.NAVIGATION_HINT_BACK_ALT;
    @NavigationHint
    private int mNavigationIconHints = 0;
    private final int mNavBarMode = NAV_BAR_MODE_GESTURAL;

    private KeyButtonDrawable mBackIcon;
@@ -241,8 +245,7 @@ public final class NavigationBarView extends FrameLayout {
    }

    private void orientBackButton(KeyButtonDrawable drawable) {
        final boolean useAltBack =
                (mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0;
        final boolean useAltBack = (mNavigationIconHints & NAVIGATION_HINT_BACK_ALT) != 0;
        final boolean isRtl = mConfiguration.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
        float degrees = useAltBack ? (isRtl ? 90 : -90) : 0;
        if (drawable.getRotation() == degrees) {
@@ -284,8 +287,10 @@ public final class NavigationBarView extends FrameLayout {
     *
     * @param hints bit flags defined in {@link StatusBarManager}.
     */
    public void setNavigationIconHints(int hints) {
        if (hints == mNavigationIconHints) return;
    public void setNavigationIconHints(@NavigationHint int hints) {
        if (hints == mNavigationIconHints) {
            return;
        }
        final boolean newBackAlt = (hints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0;
        final boolean oldBackAlt =
                (mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0;
@@ -312,9 +317,10 @@ public final class NavigationBarView extends FrameLayout {
        getImeSwitchButton().setImageDrawable(mImeSwitcherIcon);

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

        getBackButton().setVisibility(View.VISIBLE);
        getHomeHandle().setVisibility(View.INVISIBLE);
+8 −0
Original line number Diff line number Diff line
@@ -51,6 +51,14 @@ oneway interface IStatusBar

    void showWirelessChargingAnimation(int batteryLevel);

    /**
     * Sets the new IME window status.
     *
     * @param displayId The id of the display to which the IME is bound.
     * @param vis The IME window visibility.
     * @param backDisposition The IME back disposition mode.
     * @param showImeSwitcher Whether the IME Switcher button should be shown.
     */
    void setImeWindowStatus(int displayId, int vis, int backDisposition, boolean showImeSwitcher);
    void setWindowState(int display, int window, int state);

+8 −0
Original line number Diff line number Diff line
@@ -61,6 +61,14 @@ interface IStatusBarService
    void setIconVisibility(String slot, boolean visible);
    @UnsupportedAppUsage
    void removeIcon(String slot);
    /**
     * Sets the new IME window status.
     *
     * @param displayId The id of the display to which the IME is bound.
     * @param vis The IME window visibility.
     * @param backDisposition The IME back disposition mode.
     * @param showImeSwitcher Whether the IME Switcher button should be shown.
     */
    void setImeWindowStatus(int displayId, int vis, int backDisposition, boolean showImeSwitcher);
    void expandSettingsPanel(String subPanel);

Loading