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

Commit c6519410 authored by nergi's avatar nergi
Browse files

[CD Settings] Use ViewOutlineProvider to draw curved border

The existing solution apply box border to the displayBlock in order to
ensure Surface not leaking out behind the rounded corner.

While the box border itself fade into the background due to the gap in
displayBlocks in connected displays mode, the sharp box border will be
visible when displayBlocks are stacked in mirroring mode.

Applying stacked mirrored displays will be done in the next CL, but
here's the sample demo
Before: http://shortn/_vds67h67lV
After: http://shortn/_Y3gEbRbczV

Current CD pane with the change: http://shortn/_zqtwYJgKtA

Bug: 401059862
Test: atest DisplayBlockTest
Flag: com.android.settings.flags.display_topology_pane_in_display_list
Change-Id: Ibd58d0387dc3cc78e7e4e929b00559c086e1650c
parent b1a547a8
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -17,16 +17,6 @@

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

    <!-- A non-rounded rectangle is needed to prevent the enclosed image from
         leaking out behind the rounded corners. -->
    <item>
        <shape android:shape="rectangle">
            <stroke
                android:color="@color/display_topology_background_color"
                android:width="@dimen/display_block_padding" />
        </shape>
    </item>

    <item>
        <shape android:shape="rectangle">
            <stroke
+12 −6
Original line number Diff line number Diff line
@@ -16,26 +16,25 @@

package com.android.settings.connecteddevice.display

import com.android.settings.R

import android.content.Context
import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.Outline
import android.graphics.PointF
import android.util.Log
import android.view.SurfaceControl
import android.view.SurfaceHolder
import android.view.SurfaceView
import android.view.View
import android.view.ViewOutlineProvider
import android.widget.FrameLayout

import androidx.annotation.VisibleForTesting
import com.android.settings.R

/** Represents a draggable block in the topology pane. */
class DisplayBlock(val injector: ConnectedDisplayInjector) : FrameLayout(injector.context!!) {
    @VisibleForTesting
    val mHighlightPx = context.resources.getDimensionPixelSize(
            R.dimen.display_block_highlight_width)
    val cornerRadiusPx = context.resources.getDimensionPixelSize(
        R.dimen.display_block_corner_radius)

    private var mDisplayId: Int? = null

@@ -183,6 +182,13 @@ class DisplayBlock(val injector: ConnectedDisplayInjector) : FrameLayout(injecto
            mWallpaperView.layoutParams = it
        }

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

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