Merge "Don't force nav bar shown if configured" into tm-dev

This commit is contained in:
Alex Stetson
2022-05-13 20:59:38 +00:00
committed by Android (Google) Code Review
4 changed files with 21 additions and 15 deletions

View File

@@ -592,7 +592,7 @@ public class InputMethodService extends AbstractInputMethodService {
private InlineSuggestionSessionController mInlineSuggestionSessionController; private InlineSuggestionSessionController mInlineSuggestionSessionController;
private boolean mAutomotiveHideNavBarForKeyboard; private boolean mHideNavBarForKeyboard;
private boolean mIsAutomotive; private boolean mIsAutomotive;
private @NonNull OptionalInt mHandwritingRequestId = OptionalInt.empty(); private @NonNull OptionalInt mHandwritingRequestId = OptionalInt.empty();
private InputEventReceiver mHandwritingEventReceiver; private InputEventReceiver mHandwritingEventReceiver;
@@ -1498,9 +1498,8 @@ public class InputMethodService extends AbstractInputMethodService {
// shown the first time (cold start). // shown the first time (cold start).
mSettingsObserver.shouldShowImeWithHardKeyboard(); mSettingsObserver.shouldShowImeWithHardKeyboard();
mIsAutomotive = isAutomotive(); mHideNavBarForKeyboard = getApplicationContext().getResources().getBoolean(
mAutomotiveHideNavBarForKeyboard = getApplicationContext().getResources().getBoolean( com.android.internal.R.bool.config_hideNavBarForKeyboard);
com.android.internal.R.bool.config_automotiveHideNavBarForKeyboard);
// TODO(b/111364446) Need to address context lifecycle issue if need to re-create // TODO(b/111364446) Need to address context lifecycle issue if need to re-create
// for update resources & configuration correctly when show soft input // for update resources & configuration correctly when show soft input
@@ -1539,11 +1538,11 @@ public class InputMethodService extends AbstractInputMethodService {
window.setFlags(windowFlags, windowFlagsMask); window.setFlags(windowFlags, windowFlagsMask);
// Automotive devices may request the navigation bar to be hidden when the IME shows up // Automotive devices may request the navigation bar to be hidden when the IME shows up
// (controlled via config_automotiveHideNavBarForKeyboard) in order to maximize the // (controlled via config_hideNavBarForKeyboard) in order to maximize the visible
// visible screen real estate. When this happens, the IME window should animate from the // screen real estate. When this happens, the IME window should animate from the
// bottom of the screen to reduce the jank that happens from the lack of synchronization // bottom of the screen to reduce the jank that happens from the lack of synchronization
// between the bottom system window and the IME window. // between the bottom system window and the IME window.
if (mIsAutomotive && mAutomotiveHideNavBarForKeyboard) { if (mHideNavBarForKeyboard) {
window.setDecorFitsSystemWindows(false); window.setDecorFitsSystemWindows(false);
} }
} }

View File

@@ -4894,7 +4894,7 @@
<!-- Whether or not to hide the navigation bar when the soft keyboard is visible in order to <!-- Whether or not to hide the navigation bar when the soft keyboard is visible in order to
create additional screen real estate outside beyond the keyboard. Note that the user needs create additional screen real estate outside beyond the keyboard. Note that the user needs
to have a confirmed way to dismiss the keyboard when desired. --> to have a confirmed way to dismiss the keyboard when desired. -->
<bool name="config_automotiveHideNavBarForKeyboard">false</bool> <bool name="config_hideNavBarForKeyboard">false</bool>
<!-- Whether or not to show the built-in charging animation when the device begins charging <!-- Whether or not to show the built-in charging animation when the device begins charging
wirelessly. --> wirelessly. -->

View File

@@ -4154,7 +4154,7 @@
<java-symbol type="bool" name="config_disable_all_cb_messages" /> <java-symbol type="bool" name="config_disable_all_cb_messages" />
<java-symbol type="drawable" name="ic_close" /> <java-symbol type="drawable" name="ic_close" />
<java-symbol type="bool" name="config_automotiveHideNavBarForKeyboard" /> <java-symbol type="bool" name="config_hideNavBarForKeyboard" />
<java-symbol type="bool" name="config_showBuiltinWirelessChargingAnim" /> <java-symbol type="bool" name="config_showBuiltinWirelessChargingAnim" />

View File

@@ -46,6 +46,7 @@ import android.annotation.Nullable;
import android.app.ActivityTaskManager; import android.app.ActivityTaskManager;
import android.app.StatusBarManager; import android.app.StatusBarManager;
import android.app.WindowConfiguration; import android.app.WindowConfiguration;
import android.content.res.Resources;
import android.graphics.Rect; import android.graphics.Rect;
import android.util.ArrayMap; import android.util.ArrayMap;
import android.util.IntArray; import android.util.IntArray;
@@ -123,14 +124,17 @@ class InsetsPolicy {
* Let remote insets controller control system bars regardless of other settings. * Let remote insets controller control system bars regardless of other settings.
*/ */
private boolean mRemoteInsetsControllerControlsSystemBars; private boolean mRemoteInsetsControllerControlsSystemBars;
private final boolean mHideNavBarForKeyboard;
private final float[] mTmpFloat9 = new float[9]; private final float[] mTmpFloat9 = new float[9];
InsetsPolicy(InsetsStateController stateController, DisplayContent displayContent) { InsetsPolicy(InsetsStateController stateController, DisplayContent displayContent) {
mStateController = stateController; mStateController = stateController;
mDisplayContent = displayContent; mDisplayContent = displayContent;
mPolicy = displayContent.getDisplayPolicy(); mPolicy = displayContent.getDisplayPolicy();
mRemoteInsetsControllerControlsSystemBars = mPolicy.getContext().getResources().getBoolean( final Resources r = mPolicy.getContext().getResources();
mRemoteInsetsControllerControlsSystemBars = r.getBoolean(
R.bool.config_remoteInsetsControllerControlsSystemBars); R.bool.config_remoteInsetsControllerControlsSystemBars);
mHideNavBarForKeyboard = r.getBoolean(R.bool.config_hideNavBarForKeyboard);
} }
boolean getRemoteInsetsControllerControlsSystemBars() { boolean getRemoteInsetsControllerControlsSystemBars() {
@@ -428,13 +432,15 @@ class InsetsPolicy {
private InsetsState adjustVisibilityForIme(WindowState w, InsetsState originalState, private InsetsState adjustVisibilityForIme(WindowState w, InsetsState originalState,
boolean copyState) { boolean copyState) {
if (w.mIsImWindow) { if (w.mIsImWindow) {
// Navigation bar insets is always visible to IME. // If navigation bar is not hidden by IME, IME should always receive visible
// navigation bar insets.
final boolean navVisible = !mHideNavBarForKeyboard;
final InsetsSource originalNavSource = originalState.peekSource(ITYPE_NAVIGATION_BAR); final InsetsSource originalNavSource = originalState.peekSource(ITYPE_NAVIGATION_BAR);
if (originalNavSource != null && !originalNavSource.isVisible()) { if (originalNavSource != null && originalNavSource.isVisible() != navVisible) {
final InsetsState state = copyState ? new InsetsState(originalState) final InsetsState state = copyState ? new InsetsState(originalState)
: originalState; : originalState;
final InsetsSource navSource = new InsetsSource(originalNavSource); final InsetsSource navSource = new InsetsSource(originalNavSource);
navSource.setVisible(true); navSource.setVisible(navVisible);
state.addSource(navSource); state.addSource(navSource);
return state; return state;
} }
@@ -573,8 +579,9 @@ class InsetsPolicy {
private @Nullable InsetsControlTarget getNavControlTarget(@Nullable WindowState focusedWin, private @Nullable InsetsControlTarget getNavControlTarget(@Nullable WindowState focusedWin,
boolean fake) { boolean fake) {
final WindowState imeWin = mDisplayContent.mInputMethodWindow; final WindowState imeWin = mDisplayContent.mInputMethodWindow;
if (imeWin != null && imeWin.isVisible()) { if (imeWin != null && imeWin.isVisible() && !mHideNavBarForKeyboard) {
// Force showing navigation bar while IME is visible. // Force showing navigation bar while IME is visible and if navigation bar is not
// configured to be hidden by the IME.
return null; return null;
} }
if (!fake && isShowingTransientTypes(Type.navigationBars())) { if (!fake && isShowingTransientTypes(Type.navigationBars())) {