diff options
author | 2024-12-12 12:26:46 +0000 | |
---|---|---|
committer | 2025-01-10 15:53:06 +0000 | |
commit | 5546c92dc3d1bd8f5433a8f8d52dc9aa8da4dd0f (patch) | |
tree | 939313e39656da2dde59a7afd7faa4fb78f1acb0 /packages/PrintSpooler/src | |
parent | 40d62a22b537154c969bd21803acb98756d08c83 (diff) |
PrintSpooler edge to edge support
PrintContentView now fits system windows. Handle the insets in
PrintContentView to accomodate the padding introduced by this.
Reverts ag/26955039 and ag/27354397.
Bug: 378652618
Test: Manual verification that all the elements are visible,
interactable and in the expected position
Flag: com.android.printspooler.flags.print_edge2edge
Change-Id: Ib6c533fedbbc45e0340a389fba71f81be17fedf4
Diffstat (limited to 'packages/PrintSpooler/src')
-rw-r--r-- | packages/PrintSpooler/src/com/android/printspooler/ui/SelectPrinterActivity.java | 4 | ||||
-rw-r--r-- | packages/PrintSpooler/src/com/android/printspooler/widget/PrintContentView.java | 47 |
2 files changed, 38 insertions, 13 deletions
diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/SelectPrinterActivity.java b/packages/PrintSpooler/src/com/android/printspooler/ui/SelectPrinterActivity.java index 74acf677918e..559d3ea2e830 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/ui/SelectPrinterActivity.java +++ b/packages/PrintSpooler/src/com/android/printspooler/ui/SelectPrinterActivity.java @@ -66,10 +66,10 @@ import android.widget.Toast; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.printspooler.R; +import com.android.printspooler.flags.Flags; import java.util.ArrayList; import java.util.List; - /** * This is an activity for selecting a printer. */ @@ -134,6 +134,8 @@ public final class SelectPrinterActivity extends Activity implements mPrinterRegistry = new PrinterRegistry(this, null, LOADER_ID_PRINT_REGISTRY, LOADER_ID_PRINT_REGISTRY_INT); + findViewById(R.id.select_printer).setFitsSystemWindows(Flags.printEdge2edge()); + // Hook up the list view. mListView = findViewById(android.R.id.list); final DestinationAdapter adapter = new DestinationAdapter(); diff --git a/packages/PrintSpooler/src/com/android/printspooler/widget/PrintContentView.java b/packages/PrintSpooler/src/com/android/printspooler/widget/PrintContentView.java index 6ecffa4752cf..720d5b1f4e35 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/widget/PrintContentView.java +++ b/packages/PrintSpooler/src/com/android/printspooler/widget/PrintContentView.java @@ -25,6 +25,7 @@ import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; import com.android.printspooler.R; +import com.android.printspooler.flags.Flags; /** * This class is a layout manager for the print screen. It has a sliding @@ -93,6 +94,7 @@ public final class PrintContentView extends ViewGroup implements View.OnClickLis // The options view is sliding under the static header but appears // after it in the layout, so we will draw in opposite order. setChildrenDrawingOrderEnabled(true); + setFitsSystemWindows(Flags.printEdge2edge()); } public void setOptionsStateChangeListener(OptionsStateChangeListener listener) { @@ -148,6 +150,7 @@ public final class PrintContentView extends ViewGroup implements View.OnClickLis mExpandCollapseHandle = findViewById(R.id.expand_collapse_handle); mExpandCollapseIcon = findViewById(R.id.expand_collapse_icon); + mOptionsContainer.setFitsSystemWindows(Flags.printEdge2edge()); mExpandCollapseHandle.setOnClickListener(this); mSummaryContent.setOnClickListener(this); @@ -262,7 +265,7 @@ public final class PrintContentView extends ViewGroup implements View.OnClickLis } // The content host can grow vertically as much as needed - we will be covering it. - final int hostHeightMeasureSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.UNSPECIFIED, 0); + final int hostHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); measureChild(mEmbeddedContentContainer, widthMeasureSpec, hostHeightMeasureSpec); setMeasuredDimension(resolveSize(MeasureSpec.getSize(widthMeasureSpec), widthMeasureSpec), @@ -271,25 +274,43 @@ public final class PrintContentView extends ViewGroup implements View.OnClickLis @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - mStaticContent.layout(left, top, right, mStaticContent.getMeasuredHeight()); + final int childLeft; + final int childRight; + final int childTop; + if (Flags.printEdge2edge()) { + childLeft = left + mPaddingLeft; + childRight = right - mPaddingRight; + childTop = top + mPaddingTop; + } else { + childLeft = left; + childRight = right; + childTop = top; + } + mStaticContent.layout(childLeft, childTop, childRight, + mStaticContent.getMeasuredHeight() + (Flags.printEdge2edge() ? mPaddingTop : 0)); if (mSummaryContent.getVisibility() != View.GONE) { - mSummaryContent.layout(left, mStaticContent.getMeasuredHeight(), right, - mStaticContent.getMeasuredHeight() + mSummaryContent.getMeasuredHeight()); + mSummaryContent.layout(childLeft, + (Flags.printEdge2edge() ? mStaticContent.getBottom() + : mStaticContent.getMeasuredHeight()), childRight, + (Flags.printEdge2edge() ? mStaticContent.getBottom() + : mStaticContent.getMeasuredHeight()) + + mSummaryContent.getMeasuredHeight()); } - final int dynContentTop = mStaticContent.getMeasuredHeight() + mCurrentOptionsOffsetY; + final int dynContentTop = mStaticContent.getBottom() + mCurrentOptionsOffsetY; final int dynContentBottom = dynContentTop + mDynamicContent.getMeasuredHeight(); - mDynamicContent.layout(left, dynContentTop, right, dynContentBottom); + mDynamicContent.layout(childLeft, dynContentTop, childRight, dynContentBottom); MarginLayoutParams params = (MarginLayoutParams) mPrintButton.getLayoutParams(); final int printButtonLeft; if (getLayoutDirection() == View.LAYOUT_DIRECTION_LTR) { - printButtonLeft = right - mPrintButton.getMeasuredWidth() - params.getMarginStart(); + printButtonLeft = childRight - mPrintButton.getMeasuredWidth() + - params.getMarginStart(); } else { - printButtonLeft = left + params.getMarginStart(); + printButtonLeft = childLeft + params.getMarginStart(); } final int printButtonTop = dynContentBottom - mPrintButton.getMeasuredHeight() / 2; final int printButtonRight = printButtonLeft + mPrintButton.getMeasuredWidth(); @@ -297,11 +318,13 @@ public final class PrintContentView extends ViewGroup implements View.OnClickLis mPrintButton.layout(printButtonLeft, printButtonTop, printButtonRight, printButtonBottom); - final int embContentTop = mStaticContent.getMeasuredHeight() + mClosedOptionsOffsetY - + mDynamicContent.getMeasuredHeight(); - final int embContentBottom = embContentTop + mEmbeddedContentContainer.getMeasuredHeight(); + final int embContentTop = (Flags.printEdge2edge() ? mPaddingTop : 0) + + mStaticContent.getMeasuredHeight() + + mClosedOptionsOffsetY + mDynamicContent.getMeasuredHeight(); + final int embContentBottom = embContentTop + mEmbeddedContentContainer.getMeasuredHeight() + - (Flags.printEdge2edge() ? mPaddingBottom : 0); - mEmbeddedContentContainer.layout(left, embContentTop, right, embContentBottom); + mEmbeddedContentContainer.layout(childLeft, embContentTop, childRight, embContentBottom); } @Override |