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

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

Merge changes I092fa5a7,Ica72829a into main

* changes:
  Fixes the hover color of app handle menu buttons
  Fix formatting of HandleMenu.kt
parents 92c974c6 f2debc90
Loading
Loading
Loading
Loading
+14 −15
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ import android.widget.ImageButton
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.Space
import android.widget.TextView
import android.window.DesktopModeFlags
import android.window.SurfaceSyncGroup
import androidx.annotation.StringRes
@@ -59,10 +58,10 @@ import com.android.wm.shell.splitscreen.SplitScreenController
import com.android.wm.shell.windowdecor.additionalviewcontainer.AdditionalSystemViewContainer
import com.android.wm.shell.windowdecor.additionalviewcontainer.AdditionalViewContainer
import com.android.wm.shell.windowdecor.common.DecorThemeUtil
import com.android.wm.shell.windowdecor.common.DrawableInsets
import com.android.wm.shell.windowdecor.common.WindowDecorTaskResourceLoader
import com.android.wm.shell.windowdecor.common.calculateMenuPosition
import com.android.wm.shell.windowdecor.common.DrawableInsets
import com.android.wm.shell.windowdecor.common.createRippleDrawable
import com.android.wm.shell.windowdecor.common.createBackgroundDrawable
import com.android.wm.shell.windowdecor.extension.isFullscreen
import com.android.wm.shell.windowdecor.extension.isMultiWindow
import com.android.wm.shell.windowdecor.extension.isPinned
@@ -702,7 +701,7 @@ class HandleMenu(
                imageTintList = ColorStateList.valueOf(style.textColor)
                this.taskInfo = this@HandleMenuView.taskInfo

                background = createRippleDrawable(
                background = createBackgroundDrawable(
                    color = style.textColor,
                    cornerRadius = iconButtonRippleRadius,
                    drawableInsets = iconButtonDrawableInsetsBase
@@ -740,7 +739,7 @@ class HandleMenu(
                else iconButtonDrawableInsetsRight

            fullscreenBtn.apply {
                background = createRippleDrawable(
                background = createBackgroundDrawable(
                    color = style.textColor,
                    cornerRadius = iconButtonRippleRadius,
                    drawableInsets = startInsets
@@ -748,7 +747,7 @@ class HandleMenu(
            }

            splitscreenBtn.apply {
                background = createRippleDrawable(
                background = createBackgroundDrawable(
                    color = style.textColor,
                    cornerRadius = iconButtonRippleRadius,
                    drawableInsets = iconButtonDrawableInsetsBase
@@ -756,7 +755,7 @@ class HandleMenu(
            }

            floatingBtn.apply {
                background = createRippleDrawable(
                background = createBackgroundDrawable(
                    color = style.textColor,
                    cornerRadius = iconButtonRippleRadius,
                    drawableInsets = iconButtonDrawableInsetsBase
@@ -764,7 +763,7 @@ class HandleMenu(
            }

            desktopBtn.apply {
                background = createRippleDrawable(
                background = createBackgroundDrawable(
                    color = style.textColor,
                    cornerRadius = iconButtonRippleRadius,
                    drawableInsets = endInsets
+0 −40
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.content.res.ColorStateList
import android.graphics.Color
import android.graphics.drawable.Drawable
import android.graphics.drawable.LayerDrawable
import android.graphics.drawable.RippleDrawable
import android.graphics.drawable.ShapeDrawable
import android.graphics.drawable.shapes.RoundRectShape

@@ -47,45 +46,6 @@ fun replaceColorAlpha(@ColorInt color: Int, alpha: Int): Int {
    )
}

/**
 * Creates a RippleDrawable with specified color, corner radius, and insets.
 */
fun createRippleDrawable(
    @ColorInt color: Int,
    cornerRadius: Int,
    drawableInsets: DrawableInsets,
): RippleDrawable {
    return RippleDrawable(
        ColorStateList(
            arrayOf(
                intArrayOf(android.R.attr.state_hovered),
                intArrayOf(android.R.attr.state_pressed),
                intArrayOf(),
            ),
            intArrayOf(
                replaceColorAlpha(color, OPACITY_11),
                replaceColorAlpha(color, OPACITY_15),
                Color.TRANSPARENT,
            )
        ),
        null /* content */,
        LayerDrawable(arrayOf(
            ShapeDrawable().apply {
                shape = RoundRectShape(
                    FloatArray(8) { cornerRadius.toFloat() },
                    null /* inset */,
                    null /* innerRadii */
                )
                paint.color = Color.WHITE
            }
        )).apply {
            require(numberOfLayers == 1) { "Must only contain one layer" }
            setLayerInset(0 /* index */,
                drawableInsets.l, drawableInsets.t, drawableInsets.r, drawableInsets.b)
        }
    )
}

/**
 * Creates a background drawable with specified color, corner radius, and insets.
 */