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

Commit 11d78614 authored by Tiger Huang's avatar Tiger Huang Committed by android-build-team Robot
Browse files

DO NOT MERGE: Revert "Don't let IME window fit status bar"

This reverts commit 3cd31141.

Reason for revert: The CL causes the regression b/170474494
And it also makes status bar color incorrect while
FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS is cleared
Fix: 170474494

Change-Id: I26bed08456197721d07f2fab563be0c54e43efd2
(cherry picked from commit 427bdc1c)
parent 47b8faf7
Loading
Loading
Loading
Loading
+15 −11
Original line number Diff line number Diff line
@@ -16,11 +16,11 @@

package android.inputmethodservice;

import static android.graphics.Color.TRANSPARENT;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE;
import static android.view.WindowInsets.Type.navigationBars;
import static android.view.WindowInsets.Type.statusBars;
import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;

import static java.lang.annotation.RetentionPolicy.SOURCE;
@@ -69,6 +69,7 @@ import android.view.ViewGroup;
import android.view.ViewRootImpl;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowInsets;
import android.view.WindowInsets.Side;
import android.view.WindowManager;
import android.view.animation.AnimationUtils;
@@ -1202,22 +1203,25 @@ public class InputMethodService extends AbstractInputMethodService {
                Context.LAYOUT_INFLATER_SERVICE);
        mWindow = new SoftInputWindow(this, "InputMethod", mTheme, null, null, mDispatcherState,
                WindowManager.LayoutParams.TYPE_INPUT_METHOD, Gravity.BOTTOM, false);
        mWindow.getWindow().getAttributes().setFitInsetsTypes(navigationBars());
        mWindow.getWindow().getAttributes().setFitInsetsTypes(statusBars() | navigationBars());
        mWindow.getWindow().getAttributes().setFitInsetsSides(Side.all() & ~Side.BOTTOM);
        mWindow.getWindow().getAttributes().setFitInsetsIgnoringVisibility(true);

        // Our window will extend into the status bar area no matter the bar is visible or not.
        // We don't want the ColorView to be visible when status bar is shown.
        mWindow.getWindow().setStatusBarColor(TRANSPARENT);

        // Automotive devices may request the navigation bar to be hidden when the IME shows up
        // (controlled via config_automotiveHideNavBarForKeyboard) in order to maximize the visible
        // 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 between the
        // bottom system window and the IME window.
        // IME layout should always be inset by navigation bar, no matter its current visibility,
        // unless automotive requests it. Automotive devices may request the navigation bar to be
        // hidden when the IME shows up (controlled via config_automotiveHideNavBarForKeyboard)
        // in order to maximize the visible 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 between the bottom system window and the IME window.
        if (mIsAutomotive && mAutomotiveHideNavBarForKeyboard) {
            mWindow.getWindow().setDecorFitsSystemWindows(false);
        }
        mWindow.getWindow().getDecorView().setOnApplyWindowInsetsListener(
                (v, insets) -> v.onApplyWindowInsets(
                        new WindowInsets.Builder(insets).setInsets(
                                navigationBars(),
                                insets.getInsetsIgnoringVisibility(navigationBars()))
                                .build()));

        // For ColorView in DecorView to work, FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS needs to be set
        // by default (but IME developers can opt this out later if they want a new behavior).