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

Commit 022b1826 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Updating consumed insets when dispatching to child views

Bug: 134963243
Change-Id: I4fa072128398cfd22b906037c6c444495781c9d0
parent c9e6f236
Loading
Loading
Loading
Loading
+19 −6
Original line number Diff line number Diff line
@@ -8,18 +8,22 @@ import android.app.ActivityManager;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Insets;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewDebug;
import android.view.WindowInsets;

import java.util.Collections;
import java.util.List;

public class LauncherRootView extends InsettableFrameLayout {

    private final Rect mTempRect = new Rect();

    private final Launcher mLauncher;

    private final Paint mOpaquePaint;
@@ -56,9 +60,7 @@ public class LauncherRootView extends InsettableFrameLayout {
        super.onFinishInflate();
    }

    @TargetApi(23)
    @Override
    protected boolean fitSystemWindows(Rect insets) {
    private void handleSystemWindowInsets(Rect insets) {
        mConsumedInsets.setEmpty();
        boolean drawInsetBar = false;
        if (mLauncher.isInMultiWindowMode()
@@ -66,13 +68,13 @@ public class LauncherRootView extends InsettableFrameLayout {
            mConsumedInsets.left = insets.left;
            mConsumedInsets.right = insets.right;
            mConsumedInsets.bottom = insets.bottom;
            insets = new Rect(0, insets.top, 0, 0);
            insets.set(0, insets.top, 0, 0);
            drawInsetBar = true;
        } else  if ((insets.right > 0 || insets.left > 0) &&
                getContext().getSystemService(ActivityManager.class).isLowRamDevice()) {
            mConsumedInsets.left = insets.left;
            mConsumedInsets.right = insets.right;
            insets = new Rect(0, insets.top, 0, insets.bottom);
            insets.set(0, insets.top, 0, insets.bottom);
            drawInsetBar = true;
        }

@@ -99,8 +101,19 @@ public class LauncherRootView extends InsettableFrameLayout {
        if (resetState) {
            mLauncher.getStateManager().reapplyState(true /* cancelCurrentAnimation */);
        }
    }

        return false; // Let children get the full insets
    @Override
    public WindowInsets onApplyWindowInsets(WindowInsets insets) {
        mTempRect.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
                insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
        handleSystemWindowInsets(mTempRect);
        if (Utilities.ATLEAST_Q) {
            return insets.inset(mConsumedInsets.left, mConsumedInsets.top,
                    mConsumedInsets.right, mConsumedInsets.bottom);
        } else {
            return insets.replaceSystemWindowInsets(mTempRect);
        }
    }

    @Override