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

Commit 74ace355 authored by Austin Tankiang's avatar Austin Tankiang
Browse files

Add scrollbars to the job progress panel

This also reverts the first/last item rounded corner change as that
affects scrollbar drawing.

Bug: 407673809
Test: manual inspection
Flag: com.android.documentsui.flags.visual_signals_ro
Change-Id: I456cff332d5c3ae021083c9c70b098723a2dfcd1
parent 584a72b6
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -19,7 +19,8 @@
    xmlns:app="http://schemas.android.com/apk/res-auto"
    style="@style/JobProgressItemCardStyle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    android:layout_height="wrap_content"
    android:layout_marginHorizontal="@dimen/job_progress_list_margin">
    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
+1 −1
Original line number Diff line number Diff line
@@ -43,9 +43,9 @@
                android:id="@+id/job_progress_list"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginHorizontal="@dimen/job_progress_list_margin"
                android:paddingBottom="@dimen/job_progress_list_margin"
                android:clipToPadding="false"
                android:scrollbars="vertical"
                app:layout_constraintHeight_max="@dimen/job_progress_list_max_height"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
+0 −30
Original line number Diff line number Diff line
@@ -19,10 +19,7 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.graphics.Canvas
import android.graphics.Path
import android.graphics.Rect
import android.graphics.RectF
import android.text.format.Formatter
import android.util.Log
import android.view.LayoutInflater
@@ -33,7 +30,6 @@ import android.widget.Button
import android.widget.PopupWindow
import android.widget.ProgressBar
import android.widget.TextView
import androidx.core.view.isEmpty
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.ListAdapter
@@ -64,29 +60,6 @@ private class VerticalMarginItemDecoration(
    }
}

/**
 * Adds rounded corners to the extremes (i.e. the first and last items in a list) of the Recycler
 * View. It does this by getting the bounding box of all items and clipping the canvas to a rounded
 * rectangle of the same size.
 */
private class RoundedCornerExtremitiesItemDecoration(
    private val mCornerRadius: Float
) : RecyclerView.ItemDecoration() {
    override fun onDraw(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
        if (parent.isEmpty()) return

        val firstRect = Rect()
        val lastRect = Rect()
        parent.getDecoratedBoundsWithMargins(parent.getChildAt(0), firstRect)
        parent.getDecoratedBoundsWithMargins(parent.getChildAt(parent.childCount - 1), lastRect)
        firstRect.union(lastRect)

        val path = Path()
        path.addRoundRect(RectF(firstRect), mCornerRadius, mCornerRadius, Path.Direction.CW)
        c.clipPath(path)
    }
}

/**
 * JobPanelController is responsible for receiving broadcast updates from the [FileOperationService]
 * and updating a given menu item to reflect the current progress.
@@ -246,9 +219,6 @@ class JobPanelController(private val mContext: Context) : BroadcastReceiver() {
                addItemDecoration(VerticalMarginItemDecoration(
                    mContext.resources.getDimensionPixelSize(R.dimen.job_progress_list_gap)
                ))
                addItemDecoration(RoundedCornerExtremitiesItemDecoration(
                    mContext.resources.getDimension(R.dimen.job_progress_list_corner_radius)
                ))
                itemAnimator = null
                adapter = listAdapter
            }