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

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

Merge "Correct hover effect for HandleMenuActionButton" into main

parents ab0fe97d 48476ec6
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
        )