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

Commit 671681d8 authored by Austin Tankiang's avatar Austin Tankiang
Browse files

Implement base job progress item

This implements a skeleton item with progress and message. Also adds the
recycler list used to display these items.

The items are still incomplete, missing proper expand/collapse, status
messages and other behaviour.

Bug: 385841321
Test: atest -c 'DocumentsUIGoogleTests:com.android.documentsui.JobPanelUiTest'
Flag: com.android.documentsui.flags.visual_signals_ro

Change-Id: Ieee1d0b8bd947387c8e13aaf3df8acee73ba1b88
parent 8ef010c4
Loading
Loading
Loading
Loading
+124 −0
Original line number Original line 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.
-->
<com.google.android.material.card.MaterialCardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    style="@style/JobProgressItemCardStyle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <com.google.android.material.textview.MaterialTextView
            android:id="@+id/job_progress_item_title"
            style="@style/JobProgressItemTitleStyle"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/job_progress_item_padding"
            android:layout_marginStart="@dimen/job_progress_item_padding"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toStartOf="@id/job_progress_item_expand"
            app:layout_constraintTop_toTopOf="parent" />
        <com.google.android.material.button.MaterialButton
            android:id="@+id/job_progress_item_expand"
            style="@style/JobProgressItemExpandButtonStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/job_progress_item_expand_margin_start"
            android:layout_marginEnd="@dimen/job_progress_item_padding"
            app:layout_constraintStart_toEndOf="@id/job_progress_item_title"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="@id/job_progress_item_title" />
        <androidx.constraintlayout.widget.Barrier
            android:id="@+id/job_progress_item_header_barrier"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:barrierDirection="bottom"
            app:constraint_referenced_ids="job_progress_item_title,job_progress_item_expand" />

        <com.google.android.material.progressindicator.LinearProgressIndicator
            android:id="@+id/job_progress_item_progress"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/job_progress_item_progress_margin_top"
            app:layout_constraintStart_toStartOf="@id/job_progress_item_title"
            app:layout_constraintEnd_toEndOf="@id/job_progress_item_expand"
            app:layout_constraintTop_toBottomOf="@id/job_progress_item_header_barrier" />
        <com.google.android.material.textview.MaterialTextView
            android:id="@+id/job_progress_item_primary_status"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="@style/JobProgressItemStatusText"
            app:layout_constraintStart_toStartOf="@id/job_progress_item_progress"
            app:layout_constraintTop_toBottomOf="@id/job_progress_item_progress" />
        <com.google.android.material.textview.MaterialTextView
            android:id="@+id/job_progress_item_status_separator"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/job_progress_item_status_separator_margin"
            android:text="@string/bullet"
            android:textAppearance="?attr/textAppearanceBodySmall"
            app:layout_constraintStart_toEndOf="@id/job_progress_item_primary_status"
            app:layout_constraintTop_toBottomOf="@id/job_progress_item_progress" />
        <com.google.android.material.textview.MaterialTextView
            android:id="@+id/job_progress_item_secondary_status"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/job_progress_item_status_separator_margin"
            android:textAppearance="@style/JobProgressItemStatusText"
            app:layout_constraintStart_toEndOf="@+id/job_progress_item_status_separator"
            app:layout_constraintTop_toBottomOf="@+id/job_progress_item_progress" />

        <!-- Used to provide a bottom margin when all buttons are hidden. -->
        <Space
            android:layout_width="wrap_content"
            android:layout_height="@dimen/job_progress_item_padding"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/job_progress_item_secondary_status" />
        <!-- Used to provide a consistent margin regardless of which button is displayed. -->
        <Space
            android:id="@+id/job_progress_item_button_margin"
            android:layout_width="@dimen/job_progress_item_buttons_margin_start"
            android:layout_height="@dimen/job_progress_item_buttons_margin_top"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/job_progress_item_secondary_status" />
        <com.google.android.material.button.MaterialButton
            android:id="@+id/job_progress_item_cancel"
            style="@style/JobProgressItemActionButtonStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@android:string/cancel"
            app:layout_constraintStart_toEndOf="@id/job_progress_item_button_margin"
            app:layout_constraintTop_toBottomOf="@id/job_progress_item_button_margin" />
        <com.google.android.material.button.MaterialButton
            android:id="@+id/job_progress_item_show_in_folder"
            style="@style/JobProgressItemActionButtonStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/button_show_in_folder"
            app:layout_constraintStart_toEndOf="@id/job_progress_item_cancel"
            app:layout_constraintTop_toTopOf="@id/job_progress_item_cancel" />
        <com.google.android.material.button.MaterialButton
            android:id="@+id/job_progress_item_dismiss"
            style="@style/JobProgressItemActionButtonStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/button_dismiss"
            app:layout_constraintStart_toEndOf="@id/job_progress_item_show_in_folder"
            app:layout_constraintTop_toTopOf="@id/job_progress_item_show_in_folder" />
    </androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
+7 −0
Original line number Original line Diff line number Diff line
@@ -256,4 +256,11 @@
    <!-- 360dp - 2 * header margin (16dp) - header line height (24dp) -->
    <!-- 360dp - 2 * header margin (16dp) - header line height (24dp) -->
    <dimen name="job_progress_list_max_height">304dp</dimen>
    <dimen name="job_progress_list_max_height">304dp</dimen>
    <dimen name="job_progress_list_margin">@dimen/space_extra_small_6</dimen>
    <dimen name="job_progress_list_margin">@dimen/space_extra_small_6</dimen>

    <dimen name="job_progress_item_padding">@dimen/space_small_1</dimen>
    <dimen name="job_progress_item_expand_margin_start">@dimen/space_small_4</dimen>
    <dimen name="job_progress_item_progress_margin_top">@dimen/space_extra_small_4</dimen>
    <dimen name="job_progress_item_status_separator_margin">@dimen/space_extra_small_2</dimen>
    <dimen name="job_progress_item_buttons_margin_start">@dimen/space_extra_small_2</dimen>
    <dimen name="job_progress_item_buttons_margin_top">@dimen/space_extra_small_1</dimen>
</resources>
</resources>
+34 −0
Original line number Original line Diff line number Diff line
@@ -192,4 +192,38 @@
        <item name="cardElevation">1dp</item>
        <item name="cardElevation">1dp</item>
        <item name="cardBackgroundColor">?attr/colorSurfaceDim</item>
        <item name="cardBackgroundColor">?attr/colorSurfaceDim</item>
    </style>
    </style>

    <style name="JobProgressItemCardStyle" parent="@style/Widget.Material3.CardView.Filled">
        <item name="cardBackgroundColor">?attr/colorSurfaceContainer</item>
        <item name="shapeAppearance">@style/ShapeAppearance.Material3.Corner.ExtraSmall</item>
    </style>

    <style name="JobProgressItemTitleStyle" parent="">
        <item name="android:textAppearance">@style/JobProgressItemTitleText</item>
    </style>

    <style name="JobProgressItemTitleStyle.Collapsed">
        <item name="android:ellipsize">end</item>
        <item name="android:maxLines">1</item>
    </style>

    <style name="JobProgressItemExpandButtonStyle" parent="@style/Widget.Material3.Button.IconButton.Filled">
        <item name="android:insetBottom">0dp</item>
        <item name="android:insetLeft">0dp</item>
        <item name="android:insetRight">0dp</item>
        <item name="android:insetTop">0dp</item>
        <item name="android:minHeight">0dp</item>
        <item name="android:paddingHorizontal">6dp</item>
        <item name="android:paddingVertical">1dp</item>
        <item name="backgroundTint">?attr/colorSurfaceBright</item>
        <item name="iconSize">16dp</item>
        <item name="iconTint">?attr/colorOnSurface</item>
        <item name="shapeAppearance">@style/ShapeAppearance.Material3.Corner.Full</item>
    </style>

    <style name="JobProgressItemActionButtonStyle" parent="@style/Widget.Material3.Button.TextButton">
        <item name="android:minWidth">0dp</item>
        <item name="android:textAppearance">@style/JobProgressItemActionButtonText</item>
    </style>

</resources>
</resources>
+12 −0
Original line number Original line Diff line number Diff line
@@ -163,6 +163,18 @@
        <item name="fontFamily">@string/config_fontFamilyMedium</item>
        <item name="fontFamily">@string/config_fontFamilyMedium</item>
    </style>
    </style>


    <style name="JobProgressItemTitleText" parent="@style/TextAppearance.Material3.TitleSmall">
        <item name="fontFamily">@string/config_fontFamily</item>
    </style>

    <style name="JobProgressItemStatusText" parent="@style/TextAppearance.Material3.LabelMedium">
        <item name="fontFamily">@string/config_fontFamilyMedium</item>
    </style>

    <style name="JobProgressItemActionButtonText" parent="@style/TextAppearance.Material3.LabelLarge">
        <item name="fontFamily">@string/config_fontFamilyMedium</item>
    </style>

    <style name="MaterialAlertDialogTitleStyle" parent="@style/MaterialAlertDialog.Material3.Title.Text.CenterStacked">
    <style name="MaterialAlertDialogTitleStyle" parent="@style/MaterialAlertDialog.Material3.Title.Text.CenterStacked">
        <item name="fontFamily">@string/config_fontFamilyMedium</item>
        <item name="fontFamily">@string/config_fontFamilyMedium</item>
    </style>
    </style>
+7 −0
Original line number Original line Diff line number Diff line
@@ -133,6 +133,8 @@
    <string name="button_show_provider">Show in provider</string>
    <string name="button_show_provider">Show in provider</string>
    <!-- Button label that do back action [CHAR LIMIT=24] -->
    <!-- Button label that do back action [CHAR LIMIT=24] -->
    <string name="button_back">Back</string>
    <string name="button_back">Back</string>
    <!-- Button label that navigates to the destination folder of a copy/move. -->
    <string name="button_show_in_folder">Show in folder</string>


    <!-- A string used to show user that currently documents are not sorted in any given order. [CHAR_LIMIT=30] -->
    <!-- A string used to show user that currently documents are not sorted in any given order. [CHAR_LIMIT=30] -->
    <string name="not_sorted">Not sorted</string>
    <string name="not_sorted">Not sorted</string>
@@ -430,6 +432,11 @@
        other {Zipping # files}
        other {Zipping # files}
    }</string>
    }</string>
    <string name="job_progress_panel_title" translatable="false">File Progress</string>
    <string name="job_progress_panel_title" translatable="false">File Progress</string>
    <string name="job_progress_item_completed" translatable="false">Completed</string>
    <string name="job_progress_item_failed" translatable="false">Failed</string>
    <string name="job_progress_item_byte_progress" translatable="false">
        <xliff:g id="currentBytes" example="2.4 MB">%1$s</xliff:g> of <xliff:g id="totalBytes" example="50 MB">%2$s</xliff:g>
    </string>


    <!-- Text in an alert dialog asking user to grant app access to a given directory in an external storage volume -->
    <!-- Text in an alert dialog asking user to grant app access to a given directory in an external storage volume -->
    <string name="open_external_dialog_request">Grant <xliff:g id="appName" example="System Settings"><b>^1</b></xliff:g>
    <string name="open_external_dialog_request">Grant <xliff:g id="appName" example="System Settings"><b>^1</b></xliff:g>
Loading