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

Commit d162e52a authored by Massimo Carli's avatar Massimo Carli Committed by Android (Google) Code Review
Browse files

Merge "[73/n] Rename RoundedCorners letterbox classes" into main

parents b44b6107 cf9a9313
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ import com.android.wm.shell.common.ShellExecutor
/**
 * Rounded corner [Drawable] implementation
 */
class RoundedCornersDrawable(
class LetterboxRoundedCornersDrawable(
    private var cornerColor: Color,
    private var radius: Float = 0f
) : Drawable() {
@@ -181,7 +181,7 @@ class RoundedCornersDrawable(
    private fun RectF.toRect() =
        Rect(this.top.toInt(), this.left.toInt(), this.right.toInt(), this.bottom.toInt())

    fun flip(flipType: FlipType): RoundedCornersDrawable {
    fun flip(flipType: FlipType): LetterboxRoundedCornersDrawable {
        when (flipType) {
            FlipType.FLIP_VERTICAL -> verticalFlipped = !verticalFlipped
            FlipType.FLIP_HORIZONTAL -> horizontalFlipped = !horizontalFlipped
+8 −8
Original line number Diff line number Diff line
@@ -18,25 +18,25 @@ package com.android.wm.shell.compatui.letterbox.roundedcorners

import android.graphics.Color
import android.graphics.drawable.Drawable
import com.android.wm.shell.compatui.letterbox.roundedcorners.RoundedCornersDrawable.FlipType.FLIP_HORIZONTAL
import com.android.wm.shell.compatui.letterbox.roundedcorners.RoundedCornersDrawable.FlipType.FLIP_VERTICAL
import com.android.wm.shell.compatui.letterbox.roundedcorners.RoundedCornersFactory.Position
import com.android.wm.shell.compatui.letterbox.roundedcorners.LetterboxRoundedCornersDrawable.FlipType.FLIP_HORIZONTAL
import com.android.wm.shell.compatui.letterbox.roundedcorners.LetterboxRoundedCornersDrawable.FlipType.FLIP_VERTICAL
import com.android.wm.shell.compatui.letterbox.roundedcorners.RoundedCornersDrawableFactory.Position
import com.android.wm.shell.dagger.WMSingleton
import javax.inject.Inject

/**
 * [RoundedCornersFactory] implementation returning rounded corners [Drawable]s using
 * [LetterboxRoundedCornersFactory] implementation returning rounded corners [Drawable]s using
 * SVG format.
 */
@WMSingleton
class LetterboxRoundedCornersFactory @Inject constructor(
) : RoundedCornersFactory<RoundedCornersDrawable> {
class LetterboxRoundedCornersDrawableFactory @Inject constructor(
) : RoundedCornersDrawableFactory<LetterboxRoundedCornersDrawable> {
    override fun getRoundedCornerDrawable(
        color: Color,
        position: Position,
        radius: Float
    ): RoundedCornersDrawable {
        val corners = RoundedCornersDrawable(color, radius)
    ): LetterboxRoundedCornersDrawable {
        val corners = LetterboxRoundedCornersDrawable(color, radius)
        return when (position) {
            Position.TOP_LEFT -> corners
            Position.TOP_RIGHT -> corners.flip(FLIP_HORIZONTAL)
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import android.graphics.drawable.Drawable
/**
 * Abstraction for the object responsible of the creation of the rounded corners Drawables.
 */
interface RoundedCornersFactory<T : Drawable> {
interface RoundedCornersDrawableFactory<T : Drawable> {

    enum class Position { TOP_LEFT, TOP_RIGHT, BOTTOM_RIGHT, BOTTOM_LEFT }

+13 −10
Original line number Diff line number Diff line
@@ -36,25 +36,28 @@ import android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
import android.view.WindowlessWindowManager
import android.widget.FrameLayout
import android.window.TaskConstants
import android.window.TaskConstants.TASK_CHILD_SHELL_LAYER_LETTERBOX_ROUNDED_CORNERS
import com.android.wm.shell.R
import com.android.wm.shell.common.ShellExecutor
import com.android.wm.shell.common.SyncTransactionQueue
import com.android.wm.shell.common.suppliers.SurfaceBuilderSupplier
import com.android.wm.shell.compatui.letterbox.LetterboxConfiguration
import com.android.wm.shell.compatui.letterbox.roundedcorners.RoundedCornersFactory.Position.BOTTOM_LEFT
import com.android.wm.shell.compatui.letterbox.roundedcorners.RoundedCornersFactory.Position.BOTTOM_RIGHT
import com.android.wm.shell.compatui.letterbox.roundedcorners.RoundedCornersFactory.Position.TOP_LEFT
import com.android.wm.shell.compatui.letterbox.roundedcorners.RoundedCornersFactory.Position.TOP_RIGHT
import com.android.wm.shell.compatui.letterbox.roundedcorners.RoundedCornersDrawableFactory.Position.BOTTOM_LEFT
import com.android.wm.shell.compatui.letterbox.roundedcorners.RoundedCornersDrawableFactory.Position.BOTTOM_RIGHT
import com.android.wm.shell.compatui.letterbox.roundedcorners.RoundedCornersDrawableFactory.Position.TOP_LEFT
import com.android.wm.shell.compatui.letterbox.roundedcorners.RoundedCornersDrawableFactory.Position.TOP_RIGHT

/**
 * Overlay responsible for handling letterbox rounded corners in Shell.
 */
class AppCompatRoundedCornersSurface(
class RoundedCornersSurface(
    private val context: Context,
    config: Configuration?,
    private val syncQueue: SyncTransactionQueue,
    private val parentSurface: SurfaceControl,
    private val cornersFactory: LetterboxRoundedCornersFactory,
    private val letterboxConfiguration: LetterboxConfiguration
    private val cornersFactory: LetterboxRoundedCornersDrawableFactory,
    private val letterboxConfiguration: LetterboxConfiguration,
    private val surfaceBuilderSupplier: SurfaceBuilderSupplier
) : WindowlessWindowManager(config, parentSurface, /* hostInputToken */ null) {

    private var viewHost: SurfaceControlViewHost? = null
@@ -90,7 +93,7 @@ class AppCompatRoundedCornersSurface(
        attrs: WindowManager.LayoutParams
    ): SurfaceControl {
        val className = javaClass.simpleName
        val builder = SurfaceControl.Builder()
        val builder = surfaceBuilderSupplier.get()
            .setContainerLayer()
            .setName(className + "Leash")
            .setHidden(false)
@@ -169,7 +172,7 @@ class AppCompatRoundedCornersSurface(
        visible: Boolean,
        immediate: Boolean = false
    ) {
        val drawable = background as? RoundedCornersDrawable
        val drawable = background as? LetterboxRoundedCornersDrawable
        drawable?.let {
            if (visible) it.show(executor, immediate) else it.hide(executor, immediate)
        }
@@ -238,7 +241,7 @@ class AppCompatRoundedCornersSurface(
    }

    private fun View.applyCornerAttrs(
        position: RoundedCornersFactory.Position,
        position: RoundedCornersDrawableFactory.Position,
        radius: Float,
        cornerGravity: Int,
        color: Color