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

Commit 9e3307d2 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Revert "DisplayBlock: replace layout with wider margin"" into main

parents 6b490c46 f07e88a7
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright (C) 2025 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  ~
  -->

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item>
        <shape android:shape="rectangle">
            <stroke
                android:color="@color/display_topology_background_color"
                android:width="@dimen/display_block_padding" />
            <corners android:radius="@dimen/display_block_corner_radius" />
        </shape>
    </item>

</layer-list>
+1 −1
Original line number Diff line number Diff line
@@ -562,7 +562,7 @@
    <!-- Connected displays -->
    <dimen name="display_topology_pane_margin">24dp</dimen>
    <dimen name="display_topology_pane_vertical_margin">24dp</dimen>
    <dimen name="display_block_padding">3dp</dimen>
    <dimen name="display_block_padding">5dp</dimen>
    <dimen name="display_block_highlight_width">2dp</dimen>
    <dimen name="display_block_corner_radius">10dp</dimen>

+18 −23
Original line number Diff line number Diff line
@@ -32,11 +32,8 @@ import com.android.settings.R
class DisplayBlock(val injector: ConnectedDisplayInjector) : FrameLayout(injector.context!!) {
    @VisibleForTesting
    val highlightPx = context.resources.getDimensionPixelSize(R.dimen.display_block_highlight_width)
    private val cornerRadiusPx =
    val cornerRadiusPx =
        context.resources.getDimensionPixelSize(R.dimen.display_block_corner_radius)
    private val displayBlockPaddingPx =
        context.resources.getDimensionPixelSize(R.dimen.display_block_padding)
    private val paneBgColor = context.resources.getColor(R.color.display_topology_background_color)

    // This doesn't necessarily refer to the actual display this block represents. In case of
    // mirroring, it will be the id of the mirrored display
@@ -94,19 +91,16 @@ class DisplayBlock(val injector: ConnectedDisplayInjector) : FrameLayout(injecto
        }

    val wallpaperView = SurfaceView(context)
    private val backgroundView =
        View(context).apply {
            background = context.getDrawable(R.drawable.display_block_background)
        }
    @VisibleForTesting
    val selectionMarkerView =
        View(context).apply {
            background = context.getDrawable(R.drawable.display_block_selection_marker_background)
        }

    val roundedCornerOutline =
        object : ViewOutlineProvider() {
            override fun getOutline(view: View, outline: Outline) {
                outline.setRoundRect(0, 0, view.width, view.height, cornerRadiusPx.toFloat())
            }
        }

    init {
        isScrollContainer = false
        isVerticalScrollBarEnabled = false
@@ -116,13 +110,10 @@ class DisplayBlock(val injector: ConnectedDisplayInjector) : FrameLayout(injecto
        stateListAnimator = null

        addView(wallpaperView)
        addView(backgroundView)
        addView(selectionMarkerView)

        wallpaperView.holder.addCallback(holderCallback)

        setBackgroundColor(paneBgColor)
        outlineProvider = roundedCornerOutline
        clipToOutline = true
    }

    /**
@@ -192,19 +183,23 @@ class DisplayBlock(val injector: ConnectedDisplayInjector) : FrameLayout(injecto
        // The highlight is the outermost border. The highlight is shown outside of the parent
        // FrameLayout so that it consumes the padding between the blocks.
        wallpaperView.layoutParams.let {
            it.width = newWidth - 2 * displayBlockPaddingPx
            it.height = newHeight - 2 * displayBlockPaddingPx
            it.width = newWidth
            it.height = newHeight
            if (it is MarginLayoutParams) {
                val totalPaddingPx = highlightPx + displayBlockPaddingPx
                it.leftMargin = totalPaddingPx
                it.topMargin = totalPaddingPx
                it.bottomMargin = totalPaddingPx
                it.topMargin = totalPaddingPx
                it.leftMargin = highlightPx
                it.topMargin = highlightPx
                it.bottomMargin = highlightPx
                it.topMargin = highlightPx
            }
            wallpaperView.layoutParams = it
        }

        wallpaperView.outlineProvider = roundedCornerOutline
        wallpaperView.outlineProvider =
            object : ViewOutlineProvider() {
                override fun getOutline(view: View, outline: Outline) {
                    outline.setRoundRect(0, 0, view.width, view.height, cornerRadiusPx.toFloat())
                }
            }
        wallpaperView.clipToOutline = true

        // The other two child views are MATCH_PARENT by default so will resize to fill up the