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

Commit 1ada6e0b authored by Matt Casey's avatar Matt Casey Committed by Android (Google) Code Review
Browse files

Merge "Increase size and bottom padding for shelf UI" into 24D1-dev

parents 478a2360 8141f178
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@
        android:layout_width="0dp"
        android:elevation="4dp"
        android:background="@drawable/shelf_action_chip_container_background"
        android:layout_marginStart="@dimen/overlay_action_container_margin_horizontal"
        android:layout_marginStart="@dimen/overlay_action_container_minimum_edge_spacing"
        android:layout_marginBottom="@dimen/overlay_action_container_margin_bottom"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/actions_container"
+3 −4
Original line number Diff line number Diff line
@@ -33,8 +33,7 @@
            android:layout_width="wrap_content"
            android:elevation="4dp"
            android:background="@drawable/shelf_action_chip_container_background"
            android:layout_marginHorizontal="@dimen/overlay_action_container_margin_horizontal"
            android:layout_marginBottom="@dimen/screenshot_shelf_vertical_margin"
            android:layout_marginHorizontal="@dimen/overlay_action_container_minimum_edge_spacing"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintBottom_toTopOf="@id/guideline"
            >
@@ -61,7 +60,7 @@
            android:id="@+id/screenshot_preview_border"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginStart="@dimen/overlay_action_container_margin_horizontal"
            android:layout_marginStart="@dimen/overlay_action_container_minimum_edge_spacing"
            android:layout_marginTop="@dimen/overlay_border_width_neg"
            android:layout_marginEnd="@dimen/overlay_border_width_neg"
            android:layout_marginBottom="@dimen/screenshot_shelf_vertical_margin"
@@ -153,7 +152,7 @@
            android:id="@+id/screenshot_message_container"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginHorizontal="@dimen/overlay_action_container_margin_horizontal"
            android:layout_marginHorizontal="@dimen/overlay_action_container_minimum_edge_spacing"
            android:layout_marginTop="4dp"
            android:layout_marginBottom="@dimen/overlay_action_container_margin_bottom"
            android:paddingHorizontal="@dimen/overlay_action_container_padding_end"
+2 −0
Original line number Diff line number Diff line
@@ -442,6 +442,8 @@
    <dimen name="overlay_preview_container_margin">8dp</dimen>
    <dimen name="overlay_action_container_margin_horizontal">8dp</dimen>
    <dimen name="overlay_action_container_margin_bottom">6dp</dimen>
    <!-- minimum distance to the left, right or bottom edges. -->
    <dimen name="overlay_action_container_minimum_edge_spacing">12dp</dimen>
    <dimen name="overlay_bg_protection_height">242dp</dimen>
    <dimen name="overlay_action_container_corner_radius">20dp</dimen>
    <dimen name="overlay_action_container_padding_vertical">8dp</dimen>
+36 −9
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import android.widget.FrameLayout
import android.widget.ImageView
import com.android.systemui.res.R
import com.android.systemui.screenshot.FloatingWindowUtil
import kotlin.math.max

class ScreenshotShelfView(context: Context, attrs: AttributeSet? = null) :
    FrameLayout(context, attrs) {
@@ -88,6 +87,18 @@ class ScreenshotShelfView(context: Context, attrs: AttributeSet? = null) :
        val inPortrait = orientation == Configuration.ORIENTATION_PORTRAIT
        val cutout = insets.displayCutout
        val navBarInsets = insets.getInsets(WindowInsets.Type.navigationBars())

        // When honoring the navbar or other obstacle offsets, include some extra padding above
        // the inset itself.
        val verticalPadding =
            mContext.resources.getDimensionPixelOffset(R.dimen.screenshot_shelf_vertical_margin)

        // Minimum bottom padding to always enforce (e.g. if there's no nav bar)
        val minimumBottomPadding =
            context.resources.getDimensionPixelOffset(
                R.dimen.overlay_action_container_minimum_edge_spacing
            )

        if (cutout == null) {
            screenshotStatic.setPadding(0, 0, 0, navBarInsets.bottom)
        } else {
@@ -95,23 +106,39 @@ class ScreenshotShelfView(context: Context, attrs: AttributeSet? = null) :
            if (inPortrait) {
                screenshotStatic.setPadding(
                    waterfall.left,
                    max(cutout.safeInsetTop.toDouble(), waterfall.top.toDouble()).toInt(),
                    max(cutout.safeInsetTop, waterfall.top),
                    waterfall.right,
                    max(
                            cutout.safeInsetBottom.toDouble(),
                            max(navBarInsets.bottom.toDouble(), waterfall.bottom.toDouble())
                        navBarInsets.bottom + verticalPadding,
                        cutout.safeInsetBottom + verticalPadding,
                        waterfall.bottom + verticalPadding,
                        minimumBottomPadding,
                    )
                        .toInt()
                )
            } else {
                screenshotStatic.setPadding(
                    max(cutout.safeInsetLeft.toDouble(), waterfall.left.toDouble()).toInt(),
                    max(cutout.safeInsetLeft, waterfall.left),
                    waterfall.top,
                    max(cutout.safeInsetRight.toDouble(), waterfall.right.toDouble()).toInt(),
                    max(navBarInsets.bottom.toDouble(), waterfall.bottom.toDouble()).toInt()
                    max(cutout.safeInsetRight, waterfall.right),
                    max(
                        navBarInsets.bottom + verticalPadding,
                        waterfall.bottom + verticalPadding,
                        minimumBottomPadding,
                    )
                )
            }
        }
    }

    // Max function for two or more params.
    private fun max(first: Int, second: Int, vararg items: Int): Int {
        var largest = if (first > second) first else second
        for (item in items) {
            if (item > largest) {
                largest = item
            }
        }
        return largest
    }

    private fun getSwipeRegion(): Region {