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

Commit cb2c7940 authored by Tiger Huang's avatar Tiger Huang
Browse files

Remove action_mode_edge_to_edge flag and references

This CL removes the flag and the stale logic.

Fix: 444180253
Flag: EXEMPT clean up
Test: atest ActionBarContextViewTest
Change-Id: I10b9b0b7180a1337e8efc06e1916863c419d3029
parent ccfa6c76
Loading
Loading
Loading
Loading
+0 −8
Original line number Original line Diff line number Diff line
@@ -51,14 +51,6 @@ flag {
  is_fixed_read_only: true
  is_fixed_read_only: true
}
}


flag {
  name: "action_mode_edge_to_edge"
  namespace: "windowing_frontend"
  description: "Make contextual action bar edge-to-edge"
  bug: "379783298"
  is_fixed_read_only: true
}

flag {
flag {
  name: "copy_compat_fields_of_window_insets"
  name: "copy_compat_fields_of_window_insets"
  namespace: "windowing_frontend"
  namespace: "windowing_frontend"
+21 −103
Original line number Original line Diff line number Diff line
@@ -121,7 +121,6 @@ import com.android.internal.view.menu.MenuHelper;
import com.android.internal.widget.ActionBarContextView;
import com.android.internal.widget.ActionBarContextView;
import com.android.internal.widget.BackgroundFallback;
import com.android.internal.widget.BackgroundFallback;
import com.android.internal.widget.floatingtoolbar.FloatingToolbar;
import com.android.internal.widget.floatingtoolbar.FloatingToolbar;
import com.android.window.flags.Flags;


import java.util.List;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.Executor;
@@ -217,9 +216,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
    private FloatingToolbar mFloatingToolbar;
    private FloatingToolbar mFloatingToolbar;
    private ObjectAnimator mFadeAnim;
    private ObjectAnimator mFadeAnim;


    // View added at runtime to draw under the status bar area
    private View mStatusGuard;

    private final ColorViewState mStatusColorViewState =
    private final ColorViewState mStatusColorViewState =
            new ColorViewState(STATUS_BAR_COLOR_VIEW_ATTRIBUTES);
            new ColorViewState(STATUS_BAR_COLOR_VIEW_ATTRIBUTES);
    private final ColorViewState mNavigationColorViewState =
    private final ColorViewState mNavigationColorViewState =
@@ -1028,11 +1024,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
    @Override
    @Override
    public void onWindowSystemUiVisibilityChanged(int visible) {
    public void onWindowSystemUiVisibilityChanged(int visible) {
        updateColorViews(null /* insets */, true /* animate */);
        updateColorViews(null /* insets */, true /* animate */);

        if (!Flags.actionModeEdgeToEdge()
                && mStatusGuard != null && mStatusGuard.getVisibility() == VISIBLE) {
            updateStatusGuardColor();
        }
    }
    }


    @Override
    @Override
@@ -1625,8 +1616,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
    }
    }


    private WindowInsets updateActionModeInsets(WindowInsets insets) {
    private WindowInsets updateActionModeInsets(WindowInsets insets) {
        boolean showStatusGuard = false;
        // Show the status guard when the non-overlay contextual action bar is showing
        if (mPrimaryActionModeView != null) {
        if (mPrimaryActionModeView != null) {
            if (mPrimaryActionModeView.getLayoutParams() instanceof MarginLayoutParams) {
            if (mPrimaryActionModeView.getLayoutParams() instanceof MarginLayoutParams) {
                // Insets are magic!
                // Insets are magic!
@@ -1643,7 +1632,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
                    final WindowInsets innerInsets =
                    final WindowInsets innerInsets =
                            mWindow.mContentParent.computeSystemWindowInsets(insets, rect);
                            mWindow.mContentParent.computeSystemWindowInsets(insets, rect);
                    final boolean consumesSystemWindowInsetsTop;
                    final boolean consumesSystemWindowInsetsTop;
                    if (Flags.actionModeEdgeToEdge()) {
                    final Insets systemWindowInsets = innerInsets.getSystemWindowInsets();
                    final Insets systemWindowInsets = innerInsets.getSystemWindowInsets();
                    final Insets newMargin = innerInsets.getInsets(
                    final Insets newMargin = innerInsets.getInsets(
                            WindowInsets.Type.navigationBars());
                            WindowInsets.Type.navigationBars());
@@ -1665,56 +1653,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
                                    - newMargin.right,
                                    - newMargin.right,
                            mActionModeViewInternalPaddingBottom);
                            mActionModeViewInternalPaddingBottom);
                    consumesSystemWindowInsetsTop = systemWindowInsets.top > 0;
                    consumesSystemWindowInsetsTop = systemWindowInsets.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;
                        }

                        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;
                                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;

                        if (showStatusGuard && mStatusGuard.getVisibility() != VISIBLE) {
                            // If it wasn't previously shown, the color may be stale
                            updateStatusGuardColor();
                        }
                        consumesSystemWindowInsetsTop = showStatusGuard;
                    }


                    // We only need to consume the insets if the action
                    // We only need to consume the insets if the action
                    // mode is overlaid on the app content (e.g. it's
                    // mode is overlaid on the app content (e.g. it's
@@ -1725,34 +1663,15 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
                    if (nonOverlay && consumesSystemWindowInsetsTop) {
                    if (nonOverlay && consumesSystemWindowInsetsTop) {
                        insets = insets.inset(0, insets.getSystemWindowInsetTop(), 0, 0);
                        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;
                        }
                    }
                }
                }
                if (mlpChanged) {
                if (mlpChanged) {
                    mPrimaryActionModeView.setLayoutParams(mlp);
                    mPrimaryActionModeView.setLayoutParams(mlp);
                }
                }
            }
            }
        }
        }
        if (!Flags.actionModeEdgeToEdge() && mStatusGuard != null) {
            mStatusGuard.setVisibility(showStatusGuard ? VISIBLE : GONE);
        }
        return insets;
        return insets;
    }
    }


    private void updateStatusGuardColor() {
        boolean lightStatusBar =
                (getWindowSystemUiVisibility() & SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) != 0;
        mStatusGuard.setBackgroundColor(lightStatusBar
                ? mContext.getColor(R.color.decor_view_status_guard_light)
                : mContext.getColor(R.color.decor_view_status_guard));
    }

    /**
    /**
     * Overrides the view outline when the activity enters picture-in-picture to ensure that it has
     * Overrides the view outline when the activity enters picture-in-picture to ensure that it has
     * an opaque shadow even if the window background is completely transparent. This only applies
     * an opaque shadow even if the window background is completely transparent. This only applies
@@ -2251,8 +2170,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
    void clearContentView() {
    void clearContentView() {
        for (int i = getChildCount() - 1; i >= 0; i--) {
        for (int i = getChildCount() - 1; i >= 0; i--) {
            View v = getChildAt(i);
            View v = getChildAt(i);
            if (v != mStatusColorViewState.view && v != mNavigationColorViewState.view
            if (v != mStatusColorViewState.view && v != mNavigationColorViewState.view) {
                    && (Flags.actionModeEdgeToEdge() || v != mStatusGuard)) {
                removeViewAt(i);
                removeViewAt(i);
            }
            }
        }
        }
+1 −4
Original line number Original line Diff line number Diff line
@@ -36,7 +36,6 @@ import android.widget.TextView;


import com.android.internal.R;
import com.android.internal.R;
import com.android.internal.view.menu.MenuBuilder;
import com.android.internal.view.menu.MenuBuilder;
import com.android.window.flags.Flags;


/**
/**
 * @hide
 * @hide
@@ -338,9 +337,7 @@ public class ActionBarContextView extends AbsActionBarView {
        final int verticalPadding = getPaddingTop() + getPaddingBottom();
        final int verticalPadding = getPaddingTop() + getPaddingBottom();
        final int externalVerticalPadding = Math.max(0, verticalPadding - mInternalVerticalPadding);
        final int externalVerticalPadding = Math.max(0, verticalPadding - mInternalVerticalPadding);
        final int maxHeight = mContentHeight > 0
        final int maxHeight = mContentHeight > 0
                ? Flags.actionModeEdgeToEdge()
                ? mContentHeight + externalVerticalPadding
                ? mContentHeight + externalVerticalPadding
                        : mContentHeight
                : MeasureSpec.getSize(heightMeasureSpec);
                : MeasureSpec.getSize(heightMeasureSpec);
        final int height = maxHeight - verticalPadding;
        final int height = maxHeight - verticalPadding;
        final int childSpecHeight = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST);
        final int childSpecHeight = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST);
+1 −6
Original line number Original line Diff line number Diff line
@@ -24,8 +24,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import androidx.test.filters.SmallTest;
import androidx.test.rule.ActivityTestRule;
import androidx.test.rule.ActivityTestRule;


import com.android.window.flags.Flags;

import org.junit.Rule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runner.RunWith;
@@ -70,10 +68,7 @@ public class ActionBarContextViewTest {
                View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY),
                View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY),
                View.MeasureSpec.makeMeasureSpec(2000, View.MeasureSpec.AT_MOST));
                View.MeasureSpec.makeMeasureSpec(2000, View.MeasureSpec.AT_MOST));


        // Flags.actionModeEdgeToEdge() enabled:
        // 210 = 200 (content height) + 5 (external top padding) + 5 (external bottom padding)
        // 210 = 200 (content height) + 5 (external top padding) + 5 (external bottom padding)
        // Flags.actionModeEdgeToEdge() disabled:
        assertEquals(210, view.getMeasuredHeight());
        // If content height is greater than 0, the measured height should be content height (200).
        assertEquals(Flags.actionModeEdgeToEdge() ? 210 : 200, view.getMeasuredHeight());
    }
    }
}
}