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

Commit 08b9790c authored by Austin Tankiang's avatar Austin Tankiang Committed by Android (Google) Code Review
Browse files

Merge "Add failure badge to the job progress toolbar icon" into main

parents cc59aa16 71a5bda6
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (C) 2025 The Android Open Source Project

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <solid android:color="?attr/colorError" />
    <stroke
        android:color="?attr/colorSurfaceBright"
        android:width="@dimen/job_progress_toolbar_badge_outline_width" />
</shape>
+24 −6
Original line number Diff line number Diff line
@@ -15,10 +15,28 @@
    limitations under the License.
-->

<com.google.android.material.progressindicator.CircularProgressIndicator
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="48dp"
    android:layout_height="48dp">
    <com.google.android.material.progressindicator.CircularProgressIndicator
        android:id="@+id/job_progress_toolbar_indicator"
        style="@style/JobProgressToolbarIndicatorStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:clickable="true"
    android:focusable="true" />
        android:focusable="true"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent" />
    <ImageView
        android:id="@+id/job_progress_toolbar_badge"
        android:layout_width="@dimen/job_progress_toolbar_badge_diameter"
        android:layout_height="@dimen/job_progress_toolbar_badge_diameter"
        android:src="@drawable/job_progress_badge"
        android:visible="false"
        app:layout_constraintEnd_toEndOf="@id/job_progress_toolbar_indicator"
        app:layout_constraintTop_toTopOf="@id/job_progress_toolbar_indicator" />
</androidx.constraintlayout.widget.ConstraintLayout>
+3 −0
Original line number Diff line number Diff line
@@ -258,6 +258,9 @@
    the space between the button the text/title. -->
    <dimen name="search_bar_text_margin_start_m3">@dimen/space_extra_small_6</dimen>
    <dimen name="job_progress_toolbar_indicator_size">24dp</dimen>
    <dimen name="job_progress_toolbar_badge_outline_width">1dp</dimen>
    <!-- Includes outline. -->
    <dimen name="job_progress_toolbar_badge_diameter">10dp</dimen>
    <!-- The main margin is controlled above on paddingStart, zeroing toolbar_content_insets to
         avoid pushing the title or button further. -->
    <dimen name="toolbar_content_inset_start">0dp</dimen>
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@
    <style name="JobProgressToolbarIndicatorStyle" parent="@style/Widget.Material3.CircularProgressIndicator.ExtraSmall">
        <item name="android:background">?attr/actionBarItemBackground</item>
        <item name="indicatorSize">@dimen/job_progress_toolbar_indicator_size</item>
        <item name="indicatorInset">@dimen/space_extra_small_6</item>
        <item name="indicatorInset">0dp</item>
    </style>

    <style name="ToolbarStyles" parent="@style/Widget.Material3.Toolbar">
+7 −2
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.ImageView
import android.widget.PopupWindow
import android.widget.ProgressBar
import android.widget.TextView
@@ -308,7 +309,8 @@ class JobPanelController(

        menuItem?.let {
            Menus.setEnabledAndVisible(it, menuIconState !is MenuIconState.INVISIBLE)
            val icon = it.actionView as ProgressBar
            val icon = it.actionView!!
                .findViewById<ProgressBar>(R.id.job_progress_toolbar_indicator)
            when (menuIconState) {
                is MenuIconState.INDETERMINATE -> icon.isIndeterminate = true
                is MenuIconState.VISIBLE -> icon.apply {
@@ -317,6 +319,8 @@ class JobPanelController(
                }
                is MenuIconState.INVISIBLE -> {}
            }
            val badge = it.actionView!!.findViewById<ImageView>(R.id.job_progress_toolbar_badge)
            badge.isVisible = menuIconState.hasFailures
        }
    }

@@ -325,7 +329,8 @@ class JobPanelController(
     */
    @Suppress("ktlint:standard:comment-wrapping")
    fun setMenuItem(newMenuItem: MenuItem) {
        val progressIcon = newMenuItem.actionView as ProgressBar
        val progressIcon = newMenuItem.actionView!!
            .findViewById<ProgressBar>(R.id.job_progress_toolbar_indicator)
        progressIcon.max = MAX_PROGRESS
        progressIcon.setOnClickListener { view ->
            val panel = LayoutInflater.from(activityContext).inflate(
Loading