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

Commit 7851faac authored by Jorge Gil's avatar Jorge Gil
Browse files

Update App Header buttons background/ripple to spec

Changes the background drawable of the app chip and the maximize and
close buttons in the app header to meet these requirements:
1. The clickable/hoverable bounds of the buttons must be as large as
   possible (40dp height - equal to the header height, 44dp width for
   the maximize/close buttons).
2. The visible background ripple drawable should be 32x32dp, which means
   the ripple must be inset since the view bounds are larger than that.
3. The ripple drawable color & opacity is updated to spec, for both
   hover and pressed states.
4. The maximize button ripple & progress bar are now the same size
   (32dp) and have updated colors / opacity.

Bug: 342266301
Test: hover/press on app chip, maximize, close buttons, check ripple
bounds are rounded and have a 2dp margin between itself and the header
edges and other buttons. Also check maximize button's progress bar is
exactly at the edge of the ripple.

Change-Id: I8340761541cdc9f0bdbf424579d5db7b256ed261
parent f727200c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@
            android:toDegrees="275">
            <shape
                android:shape="ring"
                android:thickness="3dp"
                android:thickness="2dp"
                android:innerRadius="14dp"
                android:useLevel="true">
            </shape>
+2 −7
Original line number Diff line number Diff line
@@ -28,13 +28,11 @@
    <LinearLayout
        android:id="@+id/open_menu_button"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:tint="?androidprv:attr/materialColorOnSurface"
        android:background="?android:selectableItemBackground"
        android:layout_height="40dp"
        android:orientation="horizontal"
        android:clickable="true"
        android:focusable="true"
        android:paddingStart="12dp">
        android:layout_marginStart="12dp">
        <ImageView
            android:id="@+id/application_icon"
            android:layout_width="@dimen/desktop_mode_caption_icon_radius"
@@ -85,8 +83,6 @@
        android:layout_height="40dp"
        android:layout_gravity="end"
        android:layout_marginHorizontal="8dp"
        android:paddingHorizontal="5dp"
        android:paddingVertical="3dp"
        android:clickable="true"
        android:focusable="true"/>

@@ -97,7 +93,6 @@
        android:paddingHorizontal="10dp"
        android:paddingVertical="8dp"
        android:layout_marginEnd="8dp"
        android:background="?android:selectableItemBackgroundBorderless"
        android:contentDescription="@string/close_button_text"
        android:src="@drawable/desktop_mode_header_ic_close"
        android:scaleType="centerCrop"
+19 −11
Original line number Diff line number Diff line
@@ -16,20 +16,28 @@

<merge xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">

    <FrameLayout
        android:layout_width="44dp"
        android:layout_height="40dp">
        <ProgressBar
            android:id="@+id/progress_bar"
            style="?android:attr/progressBarStyleHorizontal"
            android:progressDrawable="@drawable/circular_progress"
        android:layout_width="34dp"
        android:layout_height="34dp"
            android:layout_width="32dp"
            android:layout_height="32dp"
            android:indeterminate="false"
            android:layout_marginHorizontal="6dp"
            android:layout_marginVertical="4dp"
            android:visibility="invisible"/>
    </FrameLayout>

    <ImageButton
        android:id="@+id/maximize_window"
        android:layout_width="34dp"
        android:layout_height="34dp"
        android:padding="5dp"
        android:layout_width="44dp"
        android:layout_height="40dp"
        android:paddingHorizontal="10dp"
        android:paddingVertical="8dp"
        android:contentDescription="@string/maximize_button_text"
        android:src="@drawable/decor_desktop_mode_maximize_button_dark"
        android:scaleType="fitCenter" />
+19 −0
Original line number Diff line number Diff line
@@ -553,6 +553,25 @@
    <!-- The corner radius of a task that was dragged from fullscreen. -->
    <dimen name="desktop_mode_dragged_task_radius">28dp</dimen>

    <!-- The corner radius of the app chip, maximize and close button's ripple drawable -->
    <dimen name="desktop_mode_header_buttons_ripple_radius">16dp</dimen>
    <!-- The vertical inset to apply to the app chip's ripple drawable -->
    <dimen name="desktop_mode_header_app_chip_ripple_inset_vertical">4dp</dimen>

    <!-- The corner radius of the maximize button's ripple drawable -->
    <dimen name="desktop_mode_header_maximize_ripple_radius">18dp</dimen>
    <!-- The vertical inset to apply to the maximize button's ripple drawable -->
    <dimen name="desktop_mode_header_maximize_ripple_inset_vertical">4dp</dimen>
    <!-- The horizontal inset to apply to the maximize button's ripple drawable -->
    <dimen name="desktop_mode_header_maximize_ripple_inset_horizontal">6dp</dimen>

    <!-- The corner radius of the close button's ripple drawable -->
    <dimen name="desktop_mode_header_close_ripple_radius">18dp</dimen>
    <!-- The vertical inset to apply to the close button's ripple drawable -->
    <dimen name="desktop_mode_header_close_ripple_inset_vertical">4dp</dimen>
    <!-- The horizontal inset to apply to the close button's ripple drawable -->
    <dimen name="desktop_mode_header_close_ripple_inset_horizontal">6dp</dimen>

    <!-- The acceptable area ratio of fg icon area/bg icon area, i.e. (72 x 72) / (108 x 108) -->
    <item type="dimen" format="float" name="splash_icon_enlarge_foreground_threshold">0.44</item>
    <!-- Scaling factor applied to splash icons without provided background i.e. (192 / 160) -->
+6 −31
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.view.View
import android.widget.FrameLayout
import android.widget.ImageButton
import android.widget.ProgressBar
import androidx.annotation.ColorInt
import androidx.core.animation.doOnEnd
import androidx.core.animation.doOnStart
import androidx.core.content.ContextCompat
@@ -106,30 +105,17 @@ class MaximizeButtonView(
    fun setAnimationTints(
        darkMode: Boolean,
        iconForegroundColor: ColorStateList? = null,
        baseForegroundColor: Int? = null
        baseForegroundColor: Int? = null,
        rippleDrawable: RippleDrawable? = null
    ) {
        if (Flags.enableThemedAppHeaders()) {
            requireNotNull(iconForegroundColor) { "Icon foreground color must be non-null" }
            requireNotNull(baseForegroundColor) { "Base foreground color must be non-null" }
            requireNotNull(rippleDrawable) { "Ripple drawable must be non-null" }
            maximizeWindow.imageTintList = iconForegroundColor
            maximizeWindow.background = RippleDrawable(
                ColorStateList(
                    arrayOf(
                        intArrayOf(android.R.attr.state_hovered),
                        intArrayOf(android.R.attr.state_pressed),
                        intArrayOf(),
                    ),
                    intArrayOf(
                        replaceColorAlpha(baseForegroundColor, OPACITY_8),
                        replaceColorAlpha(baseForegroundColor, OPACITY_12),
                        Color.TRANSPARENT
                    )
                ),
                null,
                null
            )
            maximizeWindow.background = rippleDrawable
            progressBar.progressTintList = ColorStateList.valueOf(baseForegroundColor)
                .withAlpha(OPACITY_12)
                .withAlpha(OPACITY_15)
            progressBar.progressBackgroundTintList = ColorStateList.valueOf(Color.TRANSPARENT)
        } else {
            if (darkMode) {
@@ -146,18 +132,7 @@ class MaximizeButtonView(
        }
    }

    @ColorInt
    private fun replaceColorAlpha(@ColorInt color: Int, alpha: Int): Int {
        return Color.argb(
            alpha,
            Color.red(color),
            Color.green(color),
            Color.blue(color)
        )
    }

    companion object {
        private const val OPACITY_8 = 20
        private const val OPACITY_12 = 31
        private const val OPACITY_15 = 38
    }
}
Loading