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

Commit 0394f4f6 authored by Tiger Huang's avatar Tiger Huang Committed by Automerger Merge Worker
Browse files

Merge "Fix InsetsState#calculateVisibleInsets" into tm-dev am: d8a7e13a am: 0ee28eb1

parents beeed19f 0ee28eb1
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -833,10 +833,12 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
    }

    /**
     * @see InsetsState#calculateVisibleInsets(Rect, int)
     * @see InsetsState#calculateVisibleInsets(Rect, int, int, int, int)
     */
    public Insets calculateVisibleInsets(@SoftInputModeFlags int softInputMode) {
        return mState.calculateVisibleInsets(mFrame, softInputMode);
    public Insets calculateVisibleInsets(int windowType, int windowingMode,
            @SoftInputModeFlags int softInputMode, int windowFlags) {
        return mState.calculateVisibleInsets(mFrame, windowType, windowingMode, softInputMode,
                windowFlags);
    }

    /**
+14 −8
Original line number Diff line number Diff line
@@ -23,11 +23,11 @@ import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
import static android.view.WindowInsets.Type.displayCutout;
import static android.view.WindowInsets.Type.ime;
import static android.view.WindowInsets.Type.indexOf;
import static android.view.WindowInsets.Type.isVisibleInsetsType;
import static android.view.WindowInsets.Type.statusBars;
import static android.view.WindowInsets.Type.systemBars;
import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST;
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
@@ -257,7 +257,7 @@ public class InsetsState implements Parcelable {
        if ((legacyWindowFlags & FLAG_FULLSCREEN) != 0) {
            compatInsetsTypes &= ~statusBars();
        }
        if (clearCompatInsets(windowType, legacyWindowFlags, windowingMode)) {
        if (clearsCompatInsets(windowType, legacyWindowFlags, windowingMode)) {
            compatInsetsTypes = 0;
        }

@@ -358,17 +358,23 @@ public class InsetsState implements Parcelable {
        return insets;
    }

    public Insets calculateVisibleInsets(Rect frame, @SoftInputModeFlags int softInputMode) {
    public Insets calculateVisibleInsets(Rect frame, int windowType, int windowingMode,
            @SoftInputModeFlags int softInputMode, int windowFlags) {
        if (clearsCompatInsets(windowType, windowFlags, windowingMode)) {
            return Insets.NONE;
        }
        final int softInputAdjustMode = softInputMode & SOFT_INPUT_MASK_ADJUST;
        final int visibleInsetsTypes = softInputAdjustMode != SOFT_INPUT_ADJUST_NOTHING
                ? systemBars() | ime()
                : systemBars();
        Insets insets = Insets.NONE;
        for (int type = FIRST_TYPE; type <= LAST_TYPE; type++) {
            InsetsSource source = mSources[type];
            if (source == null) {
                continue;
            }

            // Ignore everything that's not a system bar or IME.
            int publicType = InsetsState.toPublicType(type);
            if (!isVisibleInsetsType(publicType, softInputMode)) {
            final int publicType = InsetsState.toPublicType(type);
            if ((publicType & visibleInsetsTypes) == 0) {
                continue;
            }
            insets = Insets.max(source.calculateVisibleInsets(frame), insets);
@@ -676,7 +682,7 @@ public class InsetsState implements Parcelable {
        mSources[source.getType()] = source;
    }

    public static boolean clearCompatInsets(int windowType, int windowFlags, int windowingMode) {
    public static boolean clearsCompatInsets(int windowType, int windowFlags, int windowingMode) {
        return (windowFlags & FLAG_LAYOUT_NO_LIMITS) != 0
                && windowType != TYPE_WALLPAPER && windowType != TYPE_SYSTEM_ERROR
                && !WindowConfiguration.inMultiWindowMode(windowingMode);
+2 −1
Original line number Diff line number Diff line
@@ -2570,7 +2570,8 @@ public final class ViewRootImpl implements ViewParent,
            mAttachInfo.mContentInsets.set(mLastWindowInsets.getSystemWindowInsets().toRect());
            mAttachInfo.mStableInsets.set(mLastWindowInsets.getStableInsets().toRect());
            mAttachInfo.mVisibleInsets.set(mInsetsController.calculateVisibleInsets(
                    mWindowAttributes.softInputMode).toRect());
                    mWindowAttributes.type, config.windowConfiguration.getWindowingMode(),
                    mWindowAttributes.softInputMode, mWindowAttributes.flags).toRect());
        }
        return mLastWindowInsets;
    }
+0 −14
Original line number Diff line number Diff line
@@ -32,8 +32,6 @@ import static android.view.WindowInsets.Type.all;
import static android.view.WindowInsets.Type.ime;
import static android.view.WindowInsets.Type.indexOf;
import static android.view.WindowInsets.Type.systemBars;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST;

import android.annotation.IntDef;
import android.annotation.IntRange;
@@ -46,7 +44,6 @@ import android.graphics.Rect;
import android.util.SparseArray;
import android.view.View.OnApplyWindowInsetsListener;
import android.view.WindowInsets.Type.InsetsType;
import android.view.WindowManager.LayoutParams.SoftInputModeFlags;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethod;

@@ -1600,17 +1597,6 @@ public final class WindowInsets {
        public static @InsetsType int all() {
            return 0xFFFFFFFF;
        }

        /**
         * Checks whether the specified type is considered to be part of visible insets.
         * @hide
         */
        public static boolean isVisibleInsetsType(int type,
                @SoftInputModeFlags int softInputModeFlags) {
            int softInputMode = softInputModeFlags & SOFT_INPUT_MASK_ADJUST;
            return (type & Type.systemBars()) != 0
                    || (softInputMode != SOFT_INPUT_ADJUST_NOTHING && (type & Type.ime()) != 0);
        }
    }

    /**
+3 −3
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import static android.os.Build.VERSION_CODES.M;
import static android.os.Build.VERSION_CODES.N;
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
import static android.view.InsetsState.ITYPE_STATUS_BAR;
import static android.view.InsetsState.clearCompatInsets;
import static android.view.InsetsState.clearsCompatInsets;
import static android.view.View.MeasureSpec.AT_MOST;
import static android.view.View.MeasureSpec.EXACTLY;
import static android.view.View.MeasureSpec.getMode;
@@ -1120,11 +1120,11 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
                    : controller.getSystemBarsAppearance();

            if (insets != null) {
                final boolean clearCompatInsets = clearCompatInsets(attrs.type, attrs.flags,
                final boolean clearsCompatInsets = clearsCompatInsets(attrs.type, attrs.flags,
                        getResources().getConfiguration().windowConfiguration.getWindowingMode());
                final Insets stableBarInsets = insets.getInsetsIgnoringVisibility(
                        WindowInsets.Type.systemBars());
                final Insets systemInsets = clearCompatInsets
                final Insets systemInsets = clearsCompatInsets
                        ? Insets.NONE
                        : Insets.min(insets.getInsets(WindowInsets.Type.systemBars()
                                | WindowInsets.Type.displayCutout()), stableBarInsets);
Loading