浏览代码

Replace circular ProgressBars with Material component

arkon 4 年之前
父节点
当前提交
eaccfdde59

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt

@@ -247,7 +247,7 @@ open class BrowseSourceController(bundle: Bundle) :
         recycler.setHasFixedSize(true)
         recycler.adapter = adapter
 
-        binding.catalogueView.addView(recycler, 1)
+        binding.catalogueView.addView(recycler)
 
         if (oldPosition != RecyclerView.NO_POSITION) {
             recycler.layoutManager?.scrollToPosition(oldPosition)

+ 3 - 3
app/src/main/res/layout/global_search_controller.xml

@@ -34,11 +34,11 @@
             android:alpha="0.75"
             android:background="?attr/colorSurface" />
 
-        <ProgressBar
-            style="?android:attr/progressBarStyleLarge"
+        <com.google.android.material.progressindicator.CircularProgressIndicator
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
-            android:layout_gravity="center" />
+            android:layout_gravity="center"
+            android:indeterminate="true" />
 
     </FrameLayout>
 

+ 4 - 3
app/src/main/res/layout/global_search_controller_card.xml

@@ -65,12 +65,13 @@
         android:text="@string/no_results_found"
         android:visibility="gone" />
 
-    <ProgressBar
+    <com.google.android.material.progressindicator.CircularProgressIndicator
         android:id="@+id/progress"
-        style="?android:attr/progressBarStyleSmall"
+        style="@style/Theme.Widget.CircularProgressIndicator.Small"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_gravity="center" />
+        android:layout_gravity="center"
+        android:indeterminate="true" />
 
     <androidx.recyclerview.widget.RecyclerView
         android:id="@+id/recycler"

+ 3 - 2
app/src/main/res/layout/global_search_controller_card_item.xml

@@ -20,12 +20,13 @@
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toTopOf="parent">
 
-        <ProgressBar
+        <com.google.android.material.progressindicator.CircularProgressIndicator
             android:id="@+id/progress"
-            style="?android:attr/progressBarStyleSmall"
+            style="@style/Theme.Widget.CircularProgressIndicator.Small"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_gravity="center"
+            android:indeterminate="true"
             android:visibility="gone" />
 
         <ImageView

+ 5 - 3
app/src/main/res/layout/reader_activity.xml

@@ -15,12 +15,14 @@
             android:layout_width="match_parent"
             android:layout_height="match_parent" />
 
-        <ProgressBar
+        <com.google.android.material.progressindicator.CircularProgressIndicator
             android:id="@+id/please_wait"
-            android:layout_width="56dp"
-            android:layout_height="56dp"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
             android:layout_gravity="center"
+            android:indeterminate="true"
             android:visibility="gone"
+            app:indicatorSize="56dp"
             tools:visibility="visible" />
 
         <eu.kanade.tachiyomi.ui.reader.PageIndicatorTextView

+ 3 - 3
app/src/main/res/layout/settings_search_controller.xml

@@ -25,11 +25,11 @@
             android:alpha="0.75"
             android:background="?attr/colorSurface" />
 
-        <ProgressBar
-            style="?android:attr/progressBarStyleLarge"
+        <com.google.android.material.progressindicator.CircularProgressIndicator
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
-            android:layout_gravity="center" />
+            android:layout_gravity="center"
+            android:indeterminate="true" />
 
     </FrameLayout>
 

+ 0 - 1
app/src/main/res/layout/settings_search_controller_card.xml

@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:id="@+id/title_wrapper"
     android:layout_width="match_parent"

+ 3 - 2
app/src/main/res/layout/source_comfortable_grid_item.xml

@@ -83,12 +83,13 @@
 
             </LinearLayout>
 
-            <ProgressBar
+            <com.google.android.material.progressindicator.CircularProgressIndicator
                 android:id="@+id/progress"
-                style="?android:attr/progressBarStyleSmall"
+                style="@style/Theme.Widget.CircularProgressIndicator.Small"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_gravity="center"
+                android:indeterminate="true"
                 android:visibility="gone" />
 
         </FrameLayout>

+ 3 - 3
app/src/main/res/layout/source_compact_grid_item.xml

@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
@@ -101,12 +100,13 @@
             android:textColor="@color/md_white_1000"
             tools:text="Sample name" />
 
-        <ProgressBar
+        <com.google.android.material.progressindicator.CircularProgressIndicator
             android:id="@+id/progress"
-            style="?android:attr/progressBarStyleSmall"
+            style="@style/Theme.Widget.CircularProgressIndicator.Small"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_gravity="center"
+            android:indeterminate="true"
             android:visibility="gone" />
 
     </FrameLayout>

+ 9 - 10
app/src/main/res/layout/source_controller.xml

@@ -9,17 +9,16 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:orientation="vertical"
-        tools:context=".ui.browse.source.browse.BrowseSourceController">
+        tools:context=".ui.browse.source.browse.BrowseSourceController" />
 
-        <ProgressBar
-            android:id="@+id/progress"
-            style="?android:attr/progressBarStyleLarge"
-            android:layout_width="wrap_content"
-            android:layout_height="match_parent"
-            android:layout_gravity="center"
-            android:visibility="gone" />
-
-    </LinearLayout>
+    <com.google.android.material.progressindicator.CircularProgressIndicator
+        android:id="@+id/progress"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:indeterminate="true"
+        android:visibility="gone"
+        tools:visibility="visible" />
 
     <eu.kanade.tachiyomi.widget.EmptyView
         android:id="@+id/empty_view"

+ 8 - 5
app/src/main/res/layout/source_progress_item.xml

@@ -3,14 +3,17 @@
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:padding="8dp">
 
-    <ProgressBar
+    <com.google.android.material.progressindicator.CircularProgressIndicator
         android:id="@+id/progress_bar"
-        style="@style/Widget.AppCompat.ProgressBar"
-        android:layout_width="24dp"
-        android:layout_height="24dp"
-        android:layout_gravity="center" />
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:indeterminate="true"
+        app:indicatorSize="24dp"
+        app:trackThickness="3dp" />
 
     <TextView
         android:id="@+id/progress_message"

+ 2 - 2
app/src/main/res/layout/track_search_dialog.xml

@@ -29,14 +29,14 @@
         android:layout_height="0dp"
         android:layout_weight="1">
 
-        <ProgressBar
+        <com.google.android.material.progressindicator.CircularProgressIndicator
             android:id="@+id/progress"
-            style="?android:attr/progressBarStyle"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_gravity="center"
             android:layout_marginTop="32dp"
             android:layout_marginBottom="32dp"
+            android:indeterminate="true"
             android:visibility="invisible"
             tools:visibility="visible" />
 

+ 8 - 0
app/src/main/res/values/styles.xml

@@ -225,6 +225,14 @@
     </style>
 
 
+    <style name="Theme.Widget.CircularProgressIndicator" parent="Widget.MaterialComponents.CircularProgressIndicator">
+        <item name="indicatorColor">?attr/colorAccent</item>
+    </style>
+    <style name="Theme.Widget.CircularProgressIndicator.Small" parent="Theme.Widget.CircularProgressIndicator">
+        <item name="indicatorSize">16dp</item>
+        <item name="trackThickness">2dp</item>
+    </style>
+
     <style name="Theme.Widget.LinearProgressIndicator" parent="Widget.MaterialComponents.LinearProgressIndicator">
         <item name="indicatorColor">?attr/colorAccent</item>
     </style>

+ 2 - 0
app/src/main/res/values/themes.xml

@@ -67,6 +67,7 @@
         <item name="textInputStyle">@style/Theme.Widget.TextInputLayout.OutlinedBox</item>
         <item name="android:itemTextAppearance">@style/TextAppearance.Widget.Menu</item>
         <item name="swipeRefreshLayoutProgressSpinnerBackgroundColor">?attr/colorAccent</item>
+        <item name="circularProgressIndicatorStyle">@style/Theme.Widget.CircularProgressIndicator</item>
         <item name="linearProgressIndicatorStyle">@style/Theme.Widget.LinearProgressIndicator</item>
 
         <!-- Material Dialogs -->
@@ -160,6 +161,7 @@
         <item name="textInputStyle">@style/Theme.Widget.TextInputLayout.OutlinedBox</item>
         <item name="android:itemTextAppearance">@style/TextAppearance.Widget.Menu</item>
         <item name="swipeRefreshLayoutProgressSpinnerBackgroundColor">?attr/colorAccent</item>
+        <item name="circularProgressIndicatorStyle">@style/Theme.Widget.CircularProgressIndicator</item>
         <item name="linearProgressIndicatorStyle">@style/Theme.Widget.LinearProgressIndicator</item>
 
         <!-- Material Dialogs -->