summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Neha Jain <jainne@google.com> 2025-03-23 17:17:29 -0700
committer Android Build Coastguard Worker <android-build-coastguard-worker@google.com> 2025-03-23 17:56:11 -0700
commitb46cab41cdcd7415a2aad2929ea3d2645fa9d93b (patch)
treee279b71a39691d2b13760235da28eaabc43de807
parent3b850d7e975167bc0107e70cdc1ac0afcbe5efb3 (diff)
Revert "Make action mode view extend into system insets area"
Revert submission 31806223 Reason for revert: b/403404572 Reverted changes: /q/submissionid:31806223 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:29918fbcdc22e4cb87d146196baf9e2d0a5945fc) Merged-In: I4499a0e5e8d00a400f7ea471ea54ec1d828a75a7 Change-Id: I4499a0e5e8d00a400f7ea471ea54ec1d828a75a7
-rw-r--r--core/java/com/android/internal/policy/DecorView.java130
-rw-r--r--core/java/com/android/internal/widget/ActionBarContextView.java12
-rw-r--r--core/java/com/android/internal/widget/ActionBarOverlayLayout.java85
3 files changed, 101 insertions, 126 deletions
diff --git a/core/java/com/android/internal/policy/DecorView.java b/core/java/com/android/internal/policy/DecorView.java
index 3d81e4fc7acd..e20a52b24485 100644
--- a/core/java/com/android/internal/policy/DecorView.java
+++ b/core/java/com/android/internal/policy/DecorView.java
@@ -120,7 +120,6 @@ import com.android.internal.view.menu.MenuHelper;
import com.android.internal.widget.ActionBarContextView;
import com.android.internal.widget.BackgroundFallback;
import com.android.internal.widget.floatingtoolbar.FloatingToolbar;
-import com.android.window.flags.Flags;
import java.util.List;
import java.util.concurrent.Executor;
@@ -1004,8 +1003,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
public void onWindowSystemUiVisibilityChanged(int visible) {
updateColorViews(null /* insets */, true /* animate */);
- if (!Flags.actionModeEdgeToEdge()
- && mStatusGuard != null && mStatusGuard.getVisibility() == VISIBLE) {
+ if (mStatusGuard != null && mStatusGuard.getVisibility() == VISIBLE) {
updateStatusGuardColor();
}
}
@@ -1042,7 +1040,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
}
mFrameOffsets.set(insets.getSystemWindowInsetsAsRect());
insets = updateColorViews(insets, true /* animate */);
- insets = updateActionModeInsets(insets);
+ insets = updateStatusGuard(insets);
if (getForeground() != null) {
drawableChanged();
}
@@ -1594,7 +1592,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
}
}
- private WindowInsets updateActionModeInsets(WindowInsets insets) {
+ private WindowInsets updateStatusGuard(WindowInsets insets) {
boolean showStatusGuard = false;
// Show the status guard when the non-overlay contextual action bar is showing
if (mPrimaryActionModeView != null) {
@@ -1610,78 +1608,54 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
final Rect rect = mTempRect;
// Apply the insets that have not been applied by the contentParent yet.
- final WindowInsets innerInsets =
+ WindowInsets innerInsets =
mWindow.mContentParent.computeSystemWindowInsets(insets, rect);
- final boolean consumesSystemWindowInsetsTop;
- if (Flags.actionModeEdgeToEdge()) {
- final Insets newPadding = innerInsets.getSystemWindowInsets();
- final Insets newMargin = innerInsets.getInsets(
- WindowInsets.Type.navigationBars());
-
- // Don't extend into navigation bar area so the width can align with status
- // bar color view.
- if (mlp.leftMargin != newMargin.left
- || mlp.rightMargin != newMargin.right) {
- mlpChanged = true;
- mlp.leftMargin = newMargin.left;
- mlp.rightMargin = newMargin.right;
- }
-
- mPrimaryActionModeView.setPadding(
- newPadding.left - newMargin.left,
- newPadding.top,
- newPadding.right - newMargin.right,
- 0);
- consumesSystemWindowInsetsTop = newPadding.top > 0;
- } else {
- int newTopMargin = innerInsets.getSystemWindowInsetTop();
- int newLeftMargin = innerInsets.getSystemWindowInsetLeft();
- int newRightMargin = innerInsets.getSystemWindowInsetRight();
-
- // Must use root window insets for the guard, because the color views
- // consume the navigation bar inset if the window does not request
- // LAYOUT_HIDE_NAV - but the status guard is attached at the root.
- WindowInsets rootInsets = getRootWindowInsets();
- int newGuardLeftMargin = rootInsets.getSystemWindowInsetLeft();
- int newGuardRightMargin = rootInsets.getSystemWindowInsetRight();
-
- if (mlp.topMargin != newTopMargin || mlp.leftMargin != newLeftMargin
- || mlp.rightMargin != newRightMargin) {
- mlpChanged = true;
- mlp.topMargin = newTopMargin;
- mlp.leftMargin = newLeftMargin;
- mlp.rightMargin = newRightMargin;
- }
+ int newTopMargin = innerInsets.getSystemWindowInsetTop();
+ int newLeftMargin = innerInsets.getSystemWindowInsetLeft();
+ int newRightMargin = innerInsets.getSystemWindowInsetRight();
+
+ // Must use root window insets for the guard, because the color views consume
+ // the navigation bar inset if the window does not request LAYOUT_HIDE_NAV - but
+ // the status guard is attached at the root.
+ WindowInsets rootInsets = getRootWindowInsets();
+ int newGuardLeftMargin = rootInsets.getSystemWindowInsetLeft();
+ int newGuardRightMargin = rootInsets.getSystemWindowInsetRight();
+
+ if (mlp.topMargin != newTopMargin || mlp.leftMargin != newLeftMargin
+ || mlp.rightMargin != newRightMargin) {
+ mlpChanged = true;
+ mlp.topMargin = newTopMargin;
+ mlp.leftMargin = newLeftMargin;
+ mlp.rightMargin = newRightMargin;
+ }
- if (newTopMargin > 0 && mStatusGuard == null) {
- mStatusGuard = new View(mContext);
- mStatusGuard.setVisibility(GONE);
- final LayoutParams lp = new LayoutParams(MATCH_PARENT,
- mlp.topMargin, Gravity.LEFT | Gravity.TOP);
+ if (newTopMargin > 0 && mStatusGuard == null) {
+ mStatusGuard = new View(mContext);
+ mStatusGuard.setVisibility(GONE);
+ final LayoutParams lp = new LayoutParams(MATCH_PARENT,
+ mlp.topMargin, Gravity.LEFT | Gravity.TOP);
+ lp.leftMargin = newGuardLeftMargin;
+ lp.rightMargin = newGuardRightMargin;
+ addView(mStatusGuard, indexOfChild(mStatusColorViewState.view), lp);
+ } else if (mStatusGuard != null) {
+ final LayoutParams lp = (LayoutParams)
+ mStatusGuard.getLayoutParams();
+ if (lp.height != mlp.topMargin || lp.leftMargin != newGuardLeftMargin
+ || lp.rightMargin != newGuardRightMargin) {
+ lp.height = mlp.topMargin;
lp.leftMargin = newGuardLeftMargin;
lp.rightMargin = newGuardRightMargin;
- addView(mStatusGuard, indexOfChild(mStatusColorViewState.view), lp);
- } else if (mStatusGuard != null) {
- final LayoutParams lp = (LayoutParams)
- mStatusGuard.getLayoutParams();
- if (lp.height != mlp.topMargin || lp.leftMargin != newGuardLeftMargin
- || lp.rightMargin != newGuardRightMargin) {
- lp.height = mlp.topMargin;
- lp.leftMargin = newGuardLeftMargin;
- lp.rightMargin = newGuardRightMargin;
- mStatusGuard.setLayoutParams(lp);
- }
+ mStatusGuard.setLayoutParams(lp);
}
+ }
- // The action mode's theme may differ from the app, so
- // always show the status guard above it if we have one.
- showStatusGuard = mStatusGuard != null;
+ // The action mode's theme may differ from the app, so
+ // always show the status guard above it if we have one.
+ showStatusGuard = mStatusGuard != null;
- if (showStatusGuard && mStatusGuard.getVisibility() != VISIBLE) {
- // If it wasn't previously shown, the color may be stale
- updateStatusGuardColor();
- }
- consumesSystemWindowInsetsTop = showStatusGuard;
+ if (showStatusGuard && mStatusGuard.getVisibility() != VISIBLE) {
+ // If it wasn't previously shown, the color may be stale
+ updateStatusGuardColor();
}
// We only need to consume the insets if the action
@@ -1690,16 +1664,14 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
// screen_simple_overlay_action_mode.xml).
final boolean nonOverlay = (mWindow.getLocalFeaturesPrivate()
& (1 << Window.FEATURE_ACTION_MODE_OVERLAY)) == 0;
- if (nonOverlay && consumesSystemWindowInsetsTop) {
+ if (nonOverlay && showStatusGuard) {
insets = insets.inset(0, insets.getSystemWindowInsetTop(), 0, 0);
}
} else {
- if (!Flags.actionModeEdgeToEdge()) {
- // reset top margin
- if (mlp.topMargin != 0 || mlp.leftMargin != 0 || mlp.rightMargin != 0) {
- mlpChanged = true;
- mlp.topMargin = 0;
- }
+ // reset top margin
+ if (mlp.topMargin != 0 || mlp.leftMargin != 0 || mlp.rightMargin != 0) {
+ mlpChanged = true;
+ mlp.topMargin = 0;
}
}
if (mlpChanged) {
@@ -1707,7 +1679,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
}
}
}
- if (!Flags.actionModeEdgeToEdge() && mStatusGuard != null) {
+ if (mStatusGuard != null) {
mStatusGuard.setVisibility(showStatusGuard ? VISIBLE : GONE);
}
return insets;
@@ -2211,7 +2183,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
for (int i = getChildCount() - 1; i >= 0; i--) {
View v = getChildAt(i);
if (v != mStatusColorViewState.view && v != mNavigationColorViewState.view
- && (Flags.actionModeEdgeToEdge() || v != mStatusGuard)) {
+ && v != mStatusGuard) {
removeViewAt(i);
}
}
diff --git a/core/java/com/android/internal/widget/ActionBarContextView.java b/core/java/com/android/internal/widget/ActionBarContextView.java
index d5bb51187ba4..80fc218839d5 100644
--- a/core/java/com/android/internal/widget/ActionBarContextView.java
+++ b/core/java/com/android/internal/widget/ActionBarContextView.java
@@ -34,7 +34,6 @@ import android.widget.TextView;
import com.android.internal.R;
import com.android.internal.view.menu.MenuBuilder;
-import com.android.window.flags.Flags;
/**
* @hide
@@ -316,14 +315,12 @@ public class ActionBarContextView extends AbsActionBarView {
final int contentWidth = MeasureSpec.getSize(widthMeasureSpec);
- final int maxHeight = !Flags.actionModeEdgeToEdge() && mContentHeight > 0
- ? mContentHeight : MeasureSpec.getSize(heightMeasureSpec);
+ int maxHeight = mContentHeight > 0 ?
+ mContentHeight : MeasureSpec.getSize(heightMeasureSpec);
final int verticalPadding = getPaddingTop() + getPaddingBottom();
int availableWidth = contentWidth - getPaddingLeft() - getPaddingRight();
- final int height = Flags.actionModeEdgeToEdge()
- ? mContentHeight > 0 ? mContentHeight : maxHeight
- : maxHeight - verticalPadding;
+ final int height = maxHeight - verticalPadding;
final int childSpecHeight = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST);
if (mClose != null) {
@@ -379,8 +376,7 @@ public class ActionBarContextView extends AbsActionBarView {
}
setMeasuredDimension(contentWidth, measuredHeight);
} else {
- setMeasuredDimension(contentWidth, Flags.actionModeEdgeToEdge()
- ? mContentHeight + verticalPadding : maxHeight);
+ setMeasuredDimension(contentWidth, maxHeight);
}
}
diff --git a/core/java/com/android/internal/widget/ActionBarOverlayLayout.java b/core/java/com/android/internal/widget/ActionBarOverlayLayout.java
index 362b79db4003..ff57fd4fe2ce 100644
--- a/core/java/com/android/internal/widget/ActionBarOverlayLayout.java
+++ b/core/java/com/android/internal/widget/ActionBarOverlayLayout.java
@@ -294,24 +294,54 @@ public class ActionBarOverlayLayout extends ViewGroup implements DecorContentPar
}
}
- private boolean setMargin(View view, int left, int top, int right, int bottom) {
+ private boolean applyInsets(View view, Rect insets, boolean toPadding,
+ boolean left, boolean top, boolean right, boolean bottom) {
+ boolean changed;
+ if (toPadding) {
+ changed = setMargin(view, EMPTY_RECT, left, top, right, bottom);
+ changed |= setPadding(view, insets, left, top, right, bottom);
+ } else {
+ changed = setPadding(view, EMPTY_RECT, left, top, right, bottom);
+ changed |= setMargin(view, insets, left, top, right, bottom);
+ }
+ return changed;
+ }
+
+ private boolean setPadding(View view, Rect insets,
+ boolean left, boolean top, boolean right, boolean bottom) {
+ if ((left && view.getPaddingLeft() != insets.left)
+ || (top && view.getPaddingTop() != insets.top)
+ || (right && view.getPaddingRight() != insets.right)
+ || (bottom && view.getPaddingBottom() != insets.bottom)) {
+ view.setPadding(
+ left ? insets.left : view.getPaddingLeft(),
+ top ? insets.top : view.getPaddingTop(),
+ right ? insets.right : view.getPaddingRight(),
+ bottom ? insets.bottom : view.getPaddingBottom());
+ return true;
+ }
+ return false;
+ }
+
+ private boolean setMargin(View view, Rect insets,
+ boolean left, boolean top, boolean right, boolean bottom) {
final LayoutParams lp = (LayoutParams) view.getLayoutParams();
boolean changed = false;
- if (lp.leftMargin != left) {
+ if (left && lp.leftMargin != insets.left) {
changed = true;
- lp.leftMargin = left;
+ lp.leftMargin = insets.left;
}
- if (lp.topMargin != top) {
+ if (top && lp.topMargin != insets.top) {
changed = true;
- lp.topMargin = top;
+ lp.topMargin = insets.top;
}
- if (lp.rightMargin != right) {
+ if (right && lp.rightMargin != insets.right) {
changed = true;
- lp.rightMargin = right;
+ lp.rightMargin = insets.right;
}
- if (lp.bottomMargin != bottom) {
+ if (bottom && lp.bottomMargin != insets.bottom) {
changed = true;
- lp.bottomMargin = bottom;
+ lp.bottomMargin = insets.bottom;
}
return changed;
}
@@ -337,30 +367,12 @@ public class ActionBarOverlayLayout extends ViewGroup implements DecorContentPar
final Insets sysInsets = insets.getSystemWindowInsets();
mSystemInsets.set(sysInsets.left, sysInsets.top, sysInsets.right, sysInsets.bottom);
- boolean changed = false;
- if (mActionBarExtendsIntoSystemInsets) {
- // Don't extend into navigation bar area so the width can align with status bar
- // color view.
- final Insets navBarInsets = insets.getInsets(WindowInsets.Type.navigationBars());
- final int paddingLeft = sysInsets.left - navBarInsets.left;
- final int paddingRight = sysInsets.right - navBarInsets.right;
- mActionBarTop.setPadding(paddingLeft, sysInsets.top, paddingRight, 0);
- changed |= setMargin(
- mActionBarTop, navBarInsets.left, 0, navBarInsets.right, 0);
- if (mActionBarBottom != null) {
- mActionBarBottom.setPadding(paddingLeft, 0, paddingRight, sysInsets.bottom);
- changed |= setMargin(
- mActionBarBottom, navBarInsets.left, 0, navBarInsets.right, 0);
- }
- } else {
- mActionBarTop.setPadding(0, 0, 0, 0);
- changed |= setMargin(
- mActionBarTop, sysInsets.left, sysInsets.top, sysInsets.right, 0);
- if (mActionBarBottom != null) {
- mActionBarBottom.setPadding(0, 0, 0, 0);
- changed |= setMargin(
- mActionBarTop, sysInsets.left, 0, sysInsets.right, sysInsets.bottom);
- }
+ // The top and bottom action bars are always within the content area.
+ boolean changed = applyInsets(mActionBarTop, mSystemInsets,
+ mActionBarExtendsIntoSystemInsets, true, true, true, false);
+ if (mActionBarBottom != null) {
+ changed |= applyInsets(mActionBarBottom, mSystemInsets,
+ mActionBarExtendsIntoSystemInsets, true, false, true, true);
}
// Cannot use the result of computeSystemWindowInsets, because that consumes the
@@ -509,12 +521,7 @@ public class ActionBarOverlayLayout extends ViewGroup implements DecorContentPar
);
}
}
- setMargin(
- mContent,
- mContentInsets.left,
- mContentInsets.top,
- mContentInsets.right,
- mContentInsets.bottom);
+ setMargin(mContent, mContentInsets, true, true, true, true);
if (!mLastInnerInsets.equals(mInnerInsets)) {
// If the inner insets have changed, we need to dispatch this down to