diff options
author | 2024-12-12 12:26:46 +0000 | |
---|---|---|
committer | 2025-01-10 15:53:06 +0000 | |
commit | 5546c92dc3d1bd8f5433a8f8d52dc9aa8da4dd0f (patch) | |
tree | 939313e39656da2dde59a7afd7faa4fb78f1acb0 | |
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
7 files changed, 64 insertions, 24 deletions
diff --git a/packages/PrintSpooler/Android.bp b/packages/PrintSpooler/Android.bp index 000e20fb4280..5c5ec69a4140 100644 --- a/packages/PrintSpooler/Android.bp +++ b/packages/PrintSpooler/Android.bp @@ -47,20 +47,23 @@ android_library { resource_dirs: ["res"], srcs: [ "src/**/*.java", - "src/com/android/printspooler/renderer/IPdfRenderer.aidl", "src/com/android/printspooler/renderer/IPdfEditor.aidl", + "src/com/android/printspooler/renderer/IPdfRenderer.aidl", ], platform_apis: true, static_libs: [ - "android-support-v7-recyclerview", + "android-support-annotations", "android-support-compat", - "android-support-media-compat", - "android-support-core-utils", "android-support-core-ui", + "android-support-core-utils", "android-support-fragment", - "android-support-annotations", + "android-support-media-compat", + "android-support-v7-recyclerview", "printspooler_aconfig_flags_java_lib", ], + flags_packages: [ + "printspooler_aconfig_declarations", + ], manifest: "AndroidManifest.xml", } diff --git a/packages/PrintSpooler/flags/flags.aconfig b/packages/PrintSpooler/flags/flags.aconfig index 4a76dff405d0..5d45b3f0303d 100644 --- a/packages/PrintSpooler/flags/flags.aconfig +++ b/packages/PrintSpooler/flags/flags.aconfig @@ -7,3 +7,14 @@ flag { description: "Log print job creation and state transitions." bug: "385340868" } + +flag { + name: "print_edge2edge" + namespace: "printing" + description: "Enable edge to edge in print spooler" + bug: "378652618" + is_fixed_read_only: true + metadata { + purpose: PURPOSE_BUGFIX + } +}
\ No newline at end of file diff --git a/packages/PrintSpooler/res/layout/select_printer_activity.xml b/packages/PrintSpooler/res/layout/select_printer_activity.xml index 681924b334d0..c5f19b1df6fd 100644 --- a/packages/PrintSpooler/res/layout/select_printer_activity.xml +++ b/packages/PrintSpooler/res/layout/select_printer_activity.xml @@ -15,6 +15,7 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/select_printer" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> diff --git a/packages/PrintSpooler/res/values-night/themes.xml b/packages/PrintSpooler/res/values-night/themes.xml index 76fa7b921e77..495bbcac1fb7 100644 --- a/packages/PrintSpooler/res/values-night/themes.xml +++ b/packages/PrintSpooler/res/values-night/themes.xml @@ -15,7 +15,7 @@ limitations under the License. --> -<resources> +<resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="Theme.AddPrinterActivity" parent="@android:style/Theme.DeviceDefault.Dialog"> <item name="android:listSeparatorTextViewStyle">@style/ListSeparator</item> <item name="android:textAppearanceListItemSecondary">@style/ListItemSecondary</item> @@ -24,14 +24,14 @@ <style name="Theme.SelectPrinterActivity" parent="android:style/Theme.DeviceDefault"> <item name="android:textAppearanceListItemSecondary">@style/ListItemSecondary</item> - <item name="android:windowOptOutEdgeToEdgeEnforcement">true</item> + <item name="android:windowOptOutEdgeToEdgeEnforcement" android:featureFlag="!com.android.printspooler.flags.print_edge2edge">true</item> </style> <style name="Theme.PrintActivity" parent="@android:style/Theme.DeviceDefault"> <item name="android:windowIsTranslucent">true</item> <item name="android:windowActionBar">false</item> <item name="android:windowNoTitle">true</item> - <item name="android:windowOptOutEdgeToEdgeEnforcement">true</item> + <item name="android:windowOptOutEdgeToEdgeEnforcement" android:featureFlag="!com.android.printspooler.flags.print_edge2edge">true</item> </style> </resources> diff --git a/packages/PrintSpooler/res/values/themes.xml b/packages/PrintSpooler/res/values/themes.xml index 22842f724036..5fcbbf53a57d 100644 --- a/packages/PrintSpooler/res/values/themes.xml +++ b/packages/PrintSpooler/res/values/themes.xml @@ -14,7 +14,7 @@ limitations under the License. --> -<resources> +<resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="Theme.AddPrinterActivity" parent="@android:style/Theme.DeviceDefault.Light.Dialog"> <item name="android:listSeparatorTextViewStyle">@style/ListSeparator</item> <item name="android:textAppearanceListItemSecondary">@style/ListItemSecondary</item> @@ -24,7 +24,7 @@ parent="android:style/Theme.DeviceDefault.Light"> <item name="android:textAppearanceListItemSecondary">@style/ListItemSecondary</item> <item name="android:windowLightStatusBar">true</item> - <item name="android:windowOptOutEdgeToEdgeEnforcement">true</item> + <item name="android:windowOptOutEdgeToEdgeEnforcement" android:featureFlag="!com.android.printspooler.flags.print_edge2edge">true</item> </style> <style name="Theme.PrintActivity" parent="@android:style/Theme.DeviceDefault.Light"> @@ -32,7 +32,7 @@ <item name="android:windowActionBar">false</item> <item name="android:windowNoTitle">true</item> <item name="android:windowLightStatusBar">true</item> - <item name="android:windowOptOutEdgeToEdgeEnforcement">true</item> + <item name="android:windowOptOutEdgeToEdgeEnforcement" android:featureFlag="!com.android.printspooler.flags.print_edge2edge">true</item> </style> </resources> 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 |