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

Commit 48476ec6 authored by Daichi Hirono's avatar Daichi Hirono
Browse files

Correct hover effect for HandleMenuActionButton

Replaces the ripple background with a solid color drawable, addressing
color and shape discrepancies. Sets the drawable radius to match the
parent container if they are top or bottom menu items, and uses 0dp
insets to ensure the solid color fills the entire parent area.

Video: http://recall/-/dvR0xNyCWFr2PAfPfPhsQ6/coI4AeYo04Ig64JZ6yTwvq
Bug: 380873050
Bug: 403072612
Flag: com.android.window.flags.enable_desktop_windowing_mode
Test: manually check the hover
Change-Id: I731158610966b4161bc603c707ca8afdcdea458c
parent d244a4f5
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -51,7 +51,6 @@
        <item name="android:clickable">true</item>
        <item name="android:focusable">true</item>
        <item name="android:orientation">horizontal</item>
        <item name="android:background">?android:attr/selectableItemBackground</item>
    </style>

    <style name="DesktopModeHandleMenuActionButtonImage">
+24 −3
Original line number Diff line number Diff line
@@ -508,6 +508,9 @@ class HandleMenu(
        private val iconButtonRippleRadius = context.resources.getDimensionPixelSize(
            R.dimen.desktop_mode_handle_menu_icon_button_ripple_radius
        )
        private val handleMenuCornerRadius = context.resources.getDimensionPixelSize(
            R.dimen.desktop_mode_handle_menu_corner_radius
        )
        private val iconButtonDrawableInsetsBase = DrawableInsets(
            t = iconButtondrawableBaseInset,
            b = iconButtondrawableBaseInset, l = iconButtondrawableBaseInset,
@@ -866,14 +869,21 @@ class HandleMenu(

        private fun bindMoreActionsPill(style: MenuStyle) {
            moreActionsPill.background.setTint(style.backgroundColor)

            arrayOf(
            val buttons = arrayOf(
                screenshotBtn to SHOULD_SHOW_SCREENSHOT_BUTTON,
                newWindowBtn to shouldShowNewWindowButton,
                manageWindowBtn to shouldShowManageWindowsButton,
                changeAspectRatioBtn to shouldShowChangeAspectRatioButton,
                restartBtn to shouldShowRestartButton,
            ).forEach { (button, shouldShow) ->
            )
            val firstVisible = buttons.find { it.second }?.first
            val lastVisible = buttons.findLast { it.second }?.first

            buttons.forEach { (button, shouldShow) ->
                val topRadius =
                    if (button == firstVisible) handleMenuCornerRadius.toFloat() else 0f
                val bottomRadius =
                    if (button == lastVisible) handleMenuCornerRadius.toFloat() else 0f
                button.apply {
                    isGone = !shouldShow
                    textView.apply {
@@ -881,6 +891,13 @@ class HandleMenu(
                        startMarquee()
                    }
                    iconView.imageTintList = ColorStateList.valueOf(style.textColor)
                    background = createBackgroundDrawable(
                        color = style.textColor,
                        cornerRadius = floatArrayOf(
                            topRadius, topRadius, topRadius, topRadius,
                            bottomRadius, bottomRadius, bottomRadius, bottomRadius
                        ),
                        drawableInsets = DrawableInsets())
                }
            }
        }
@@ -899,6 +916,10 @@ class HandleMenu(

            openInAppOrBrowserBtn.apply {
                contentDescription = btnText
                background = createBackgroundDrawable(
                    color = style.textColor,
                    cornerRadius = handleMenuCornerRadius,
                    drawableInsets = DrawableInsets())
                textView.apply {
                    text = btnText
                    setTextColor(style.textColor)
+11 −1
Original line number Diff line number Diff line
@@ -51,10 +51,20 @@ fun replaceColorAlpha(@ColorInt color: Int, alpha: Int): Int {
 */
fun createBackgroundDrawable(
    @ColorInt color: Int, cornerRadius: Int, drawableInsets: DrawableInsets
): Drawable = createBackgroundDrawable(
    color,
    FloatArray(8) { cornerRadius.toFloat() },
    drawableInsets)

/**
 * Creates a background drawable with specified color, corner radius, and insets.
 */
fun createBackgroundDrawable(
    @ColorInt color: Int, cornerRadius: FloatArray, drawableInsets: DrawableInsets
): Drawable = LayerDrawable(arrayOf(
    ShapeDrawable().apply {
        shape = RoundRectShape(
            FloatArray(8) { cornerRadius.toFloat() },
            cornerRadius,
            /* inset= */ null,
            /* innerRadii= */ null
        )