mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 03:08:19 +00:00
Updating consumed insets when dispatching to child views
Bug: 134963243 Change-Id: I4fa072128398cfd22b906037c6c444495781c9d0
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user