فهرست منبع

Use single layout for grid badges

arkon 3 سال پیش
والد
کامیت
c95a269460

+ 3 - 3
app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceComfortableGridHolder.kt

@@ -39,11 +39,11 @@ class SourceComfortableGridHolder(private val view: View, private val adapter: F
         binding.thumbnail.alpha = if (manga.favorite) 0.3f else 1.0f
 
         // For rounded corners
-        binding.leftBadges.clipToOutline = true
-        binding.rightBadges.clipToOutline = true
+        binding.badges.leftBadges.clipToOutline = true
+        binding.badges.rightBadges.clipToOutline = true
 
         // Set favorite badge
-        binding.favoriteText.isVisible = manga.favorite
+        binding.badges.favoriteText.isVisible = manga.favorite
 
         setImage(manga)
     }

+ 7 - 7
app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceGridHolder.kt → app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceCompactGridHolder.kt

@@ -9,7 +9,7 @@ import coil.transition.CrossfadeTransition
 import eu.davidea.flexibleadapter.FlexibleAdapter
 import eu.kanade.tachiyomi.data.coil.MangaCoverFetcher
 import eu.kanade.tachiyomi.data.database.models.Manga
-import eu.kanade.tachiyomi.databinding.SourceComfortableGridItemBinding
+import eu.kanade.tachiyomi.databinding.SourceCompactGridItemBinding
 import eu.kanade.tachiyomi.widget.StateImageViewTarget
 
 /**
@@ -20,10 +20,10 @@ import eu.kanade.tachiyomi.widget.StateImageViewTarget
  * @param adapter the adapter handling this holder.
  * @constructor creates a new catalogue holder.
  */
-open class SourceGridHolder(private val view: View, private val adapter: FlexibleAdapter<*>) :
-    SourceHolder<SourceComfortableGridItemBinding>(view, adapter) {
+open class SourceCompactGridHolder(private val view: View, private val adapter: FlexibleAdapter<*>) :
+    SourceHolder<SourceCompactGridItemBinding>(view, adapter) {
 
-    override val binding = SourceComfortableGridItemBinding.bind(view)
+    override val binding = SourceCompactGridItemBinding.bind(view)
 
     /**
      * Method called from [CatalogueAdapter.onBindViewHolder]. It updates the data for this
@@ -39,11 +39,11 @@ open class SourceGridHolder(private val view: View, private val adapter: Flexibl
         binding.thumbnail.alpha = if (manga.favorite) 0.3f else 1.0f
 
         // For rounded corners
-        binding.leftBadges.clipToOutline = true
-        binding.rightBadges.clipToOutline = true
+        binding.badges.leftBadges.clipToOutline = true
+        binding.badges.rightBadges.clipToOutline = true
 
         // Set favorite badge
-        binding.favoriteText.isVisible = manga.favorite
+        binding.badges.favoriteText.isVisible = manga.favorite
 
         setImage(manga)
     }

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

@@ -48,7 +48,7 @@ class SourceItem(val manga: Manga, private val displayMode: Preference<DisplayMo
                         Gravity.BOTTOM
                     )
                 }
-                SourceGridHolder(view, adapter)
+                SourceCompactGridHolder(view, adapter)
             }
             DisplayModeSetting.COMFORTABLE_GRID -> {
                 val binding = SourceComfortableGridItemBinding.bind(view)

+ 6 - 6
app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryComfortableGridHolder.kt

@@ -36,26 +36,26 @@ class LibraryComfortableGridHolder(
         binding.title.text = item.manga.title
 
         // For rounded corners
-        binding.leftBadges.clipToOutline = true
-        binding.rightBadges.clipToOutline = true
+        binding.badges.leftBadges.clipToOutline = true
+        binding.badges.rightBadges.clipToOutline = true
 
         // Update the unread count and its visibility.
-        with(binding.unreadText) {
+        with(binding.badges.unreadText) {
             isVisible = item.unreadCount > 0
             text = item.unreadCount.toString()
         }
         // Update the download count and its visibility.
-        with(binding.downloadText) {
+        with(binding.badges.downloadText) {
             isVisible = item.downloadCount > 0
             text = item.downloadCount.toString()
         }
         // Update the source language and its visibility
-        with(binding.languageText) {
+        with(binding.badges.languageText) {
             isVisible = item.sourceLanguage.isNotEmpty()
             text = item.sourceLanguage
         }
         // set local visibility if its local manga
-        binding.localText.isVisible = item.isLocal
+        binding.badges.localText.isVisible = item.isLocal
 
         // For rounded corners
         binding.card.clipToOutline = true

+ 6 - 6
app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCompactGridHolder.kt

@@ -34,26 +34,26 @@ open class LibraryCompactGridHolder(
         binding.title.text = item.manga.title
 
         // For rounded corners
-        binding.leftBadges.clipToOutline = true
-        binding.rightBadges.clipToOutline = true
+        binding.badges.leftBadges.clipToOutline = true
+        binding.badges.rightBadges.clipToOutline = true
 
         // Update the unread count and its visibility.
-        with(binding.unreadText) {
+        with(binding.badges.unreadText) {
             isVisible = item.unreadCount > 0
             text = item.unreadCount.toString()
         }
         // Update the download count and its visibility.
-        with(binding.downloadText) {
+        with(binding.badges.downloadText) {
             isVisible = item.downloadCount > 0
             text = item.downloadCount.toString()
         }
         // Update the source language and its visibility
-        with(binding.languageText) {
+        with(binding.badges.languageText) {
             isVisible = item.sourceLanguage.isNotEmpty()
             text = item.sourceLanguage
         }
         // set local visibility if its local manga
-        binding.localText.isVisible = item.isLocal
+        binding.badges.localText.isVisible = item.isLocal
 
         // For rounded corners
         binding.card.clipToOutline = true

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

@@ -31,114 +31,9 @@
                 tools:ignore="ContentDescription"
                 tools:src="@mipmap/ic_launcher" />
 
-            <LinearLayout
+            <include
                 android:id="@+id/badges"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginStart="4dp"
-                android:layout_marginTop="4dp"
-                android:layout_marginEnd="4dp">
-
-                <LinearLayout
-                    android:id="@+id/left_badges"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:background="@drawable/rounded_rectangle">
-
-                    <TextView
-                        android:id="@+id/local_text"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:background="?attr/colorTertiary"
-                        android:paddingStart="3dp"
-                        android:paddingTop="1dp"
-                        android:maxLines="1"
-                        android:paddingEnd="3dp"
-                        android:paddingBottom="1dp"
-                        android:text="@string/local_source_badge"
-                        android:textAppearance="?attr/textAppearanceCaption"
-                        android:textColor="?attr/colorOnTertiary"
-                        android:visibility="gone"
-                        tools:visibility="visible" />
-
-                    <TextView
-                        android:id="@+id/download_text"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:background="?attr/colorTertiary"
-                        android:paddingStart="3dp"
-                        android:paddingTop="1dp"
-                        android:maxLines="1"
-                        android:paddingEnd="3dp"
-                        android:paddingBottom="1dp"
-                        android:textAppearance="?attr/textAppearanceCaption"
-                        android:textColor="?attr/colorOnTertiary"
-                        android:visibility="gone"
-                        tools:text="120"
-                        tools:visibility="visible" />
-
-                    <TextView
-                        android:id="@+id/unread_text"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:background="?attr/colorSecondary"
-                        android:paddingStart="3dp"
-                        android:paddingTop="1dp"
-                        android:paddingEnd="3dp"
-                        android:maxLines="1"
-                        android:paddingBottom="1dp"
-                        android:textAppearance="?attr/textAppearanceCaption"
-                        android:textColor="?attr/colorOnSecondary"
-                        android:visibility="gone"
-                        tools:text="120"
-                        tools:visibility="visible" />
-
-                    <TextView
-                        android:id="@+id/favorite_text"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:background="?attr/colorSecondary"
-                        android:maxLines="1"
-                        android:paddingStart="3dp"
-                        android:paddingTop="1dp"
-                        android:paddingEnd="3dp"
-                        android:paddingBottom="1dp"
-                        android:text="@string/in_library"
-                        android:textAppearance="?attr/textAppearanceCaption"
-                        android:textColor="?attr/colorOnSecondary"
-                        android:visibility="gone"
-                        tools:visibility="visible" />
-                </LinearLayout>
-
-                <View
-                    android:layout_width="0dp"
-                    android:layout_height="0dp"
-                    android:layout_weight="1" />
-
-                <LinearLayout
-                    android:id="@+id/right_badges"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:background="@drawable/rounded_rectangle">
-
-                    <TextView
-                        android:id="@+id/language_text"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:background="?attr/colorTertiary"
-                        android:maxLines="1"
-                        android:paddingStart="3dp"
-                        android:paddingTop="1dp"
-                        android:paddingEnd="3dp"
-                        android:paddingBottom="1dp"
-                        tools:text="EN"
-                        android:textAppearance="?attr/textAppearanceCaption"
-                        android:textColor="?attr/colorOnTertiary"
-                        android:visibility="gone"
-                        tools:visibility="visible" />
-                </LinearLayout>
-            </LinearLayout>
-
+                layout="@layout/source_grid_item_badges" />
 
             <com.google.android.material.progressindicator.CircularProgressIndicator
                 android:id="@+id/progress"

+ 2 - 106
app/src/main/res/layout/source_compact_grid_item.xml

@@ -30,113 +30,9 @@
             android:layout_gravity="bottom"
             android:background="@drawable/gradient_shape" />
 
-        <LinearLayout
+        <include
             android:id="@+id/badges"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginStart="4dp"
-            android:layout_marginTop="4dp"
-            android:layout_marginEnd="4dp">
-
-            <LinearLayout
-                android:id="@+id/left_badges"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:background="@drawable/rounded_rectangle">
-
-                <TextView
-                    android:id="@+id/local_text"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:background="?attr/colorTertiary"
-                    android:paddingStart="3dp"
-                    android:paddingTop="1dp"
-                    android:paddingEnd="3dp"
-                    android:paddingBottom="1dp"
-                    android:maxLines="1"
-                    android:text="@string/local_source_badge"
-                    android:textAppearance="?attr/textAppearanceCaption"
-                    android:textColor="?attr/colorOnTertiary"
-                    android:visibility="gone"
-                    tools:visibility="visible" />
-
-                <TextView
-                    android:id="@+id/download_text"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:background="?attr/colorTertiary"
-                    android:paddingStart="3dp"
-                    android:paddingTop="1dp"
-                    android:maxLines="1"
-                    android:paddingEnd="3dp"
-                    android:paddingBottom="1dp"
-                    android:textAppearance="?attr/textAppearanceCaption"
-                    android:textColor="?attr/colorOnTertiary"
-                    android:visibility="gone"
-                    tools:text="120"
-                    tools:visibility="visible" />
-
-                <TextView
-                    android:id="@+id/unread_text"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:background="?attr/colorSecondary"
-                    android:paddingStart="3dp"
-                    android:paddingTop="1dp"
-                    android:paddingEnd="3dp"
-                    android:paddingBottom="1dp"
-                    android:maxLines="1"
-                    android:textAppearance="?attr/textAppearanceCaption"
-                    android:textColor="?attr/colorOnSecondary"
-                    android:visibility="gone"
-                    tools:text="120"
-                    tools:visibility="visible" />
-
-                <TextView
-                    android:id="@+id/favorite_text"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:background="?attr/colorSecondary"
-                    android:maxLines="1"
-                    android:paddingStart="3dp"
-                    android:paddingTop="1dp"
-                    android:paddingEnd="3dp"
-                    android:paddingBottom="1dp"
-                    android:text="@string/in_library"
-                    android:textAppearance="?attr/textAppearanceCaption"
-                    android:textColor="?attr/colorOnSecondary"
-                    android:visibility="gone"
-                    tools:visibility="visible" />
-            </LinearLayout>
-
-            <View
-                android:layout_width="0dp"
-                android:layout_height="0dp"
-                android:layout_weight="1" />
-
-            <LinearLayout
-                android:id="@+id/right_badges"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:background="@drawable/rounded_rectangle">
-
-                <TextView
-                    android:id="@+id/language_text"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:background="?attr/colorTertiary"
-                    android:maxLines="1"
-                    android:paddingStart="3dp"
-                    android:paddingTop="1dp"
-                    android:paddingEnd="3dp"
-                    android:paddingBottom="1dp"
-                    tools:text="EN"
-                    android:textAppearance="?attr/textAppearanceCaption"
-                    android:textColor="?attr/colorOnTertiary"
-                    android:visibility="gone"
-                    tools:visibility="visible" />
-            </LinearLayout>
-        </LinearLayout>
+            layout="@layout/source_grid_item_badges" />
 
         <TextView
             android:id="@+id/title"

+ 111 - 0
app/src/main/res/layout/source_grid_item_badges.xml

@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:layout_marginStart="4dp"
+    android:layout_marginTop="4dp"
+    android:layout_marginEnd="4dp">
+
+    <LinearLayout
+        android:id="@+id/left_badges"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:background="@drawable/rounded_rectangle">
+
+        <TextView
+            android:id="@+id/local_text"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:background="?attr/colorTertiary"
+            android:maxLines="1"
+            android:paddingStart="3dp"
+            android:paddingTop="1dp"
+            android:paddingEnd="3dp"
+            android:paddingBottom="1dp"
+            android:text="@string/local_source_badge"
+            android:textAppearance="?attr/textAppearanceCaption"
+            android:textColor="?attr/colorOnTertiary"
+            android:visibility="gone"
+            tools:visibility="visible" />
+
+        <TextView
+            android:id="@+id/download_text"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:background="?attr/colorTertiary"
+            android:maxLines="1"
+            android:paddingStart="3dp"
+            android:paddingTop="1dp"
+            android:paddingEnd="3dp"
+            android:paddingBottom="1dp"
+            android:textAppearance="?attr/textAppearanceCaption"
+            android:textColor="?attr/colorOnTertiary"
+            android:visibility="gone"
+            tools:text="120"
+            tools:visibility="visible" />
+
+        <TextView
+            android:id="@+id/unread_text"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:background="?attr/colorSecondary"
+            android:maxLines="1"
+            android:paddingStart="3dp"
+            android:paddingTop="1dp"
+            android:paddingEnd="3dp"
+            android:paddingBottom="1dp"
+            android:textAppearance="?attr/textAppearanceCaption"
+            android:textColor="?attr/colorOnSecondary"
+            android:visibility="gone"
+            tools:text="120"
+            tools:visibility="visible" />
+
+        <TextView
+            android:id="@+id/favorite_text"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:background="?attr/colorSecondary"
+            android:maxLines="1"
+            android:paddingStart="3dp"
+            android:paddingTop="1dp"
+            android:paddingEnd="3dp"
+            android:paddingBottom="1dp"
+            android:text="@string/in_library"
+            android:textAppearance="?attr/textAppearanceCaption"
+            android:textColor="?attr/colorOnSecondary"
+            android:visibility="gone"
+            tools:visibility="visible" />
+
+    </LinearLayout>
+
+    <View
+        android:layout_width="0dp"
+        android:layout_height="0dp"
+        android:layout_weight="1" />
+
+    <LinearLayout
+        android:id="@+id/right_badges"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:background="@drawable/rounded_rectangle">
+
+        <TextView
+            android:id="@+id/language_text"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:background="?attr/colorTertiary"
+            android:maxLines="1"
+            android:paddingStart="3dp"
+            android:paddingTop="1dp"
+            android:paddingEnd="3dp"
+            android:paddingBottom="1dp"
+            android:textAppearance="?attr/textAppearanceCaption"
+            android:textColor="?attr/colorOnTertiary"
+            android:visibility="gone"
+            tools:text="EN"
+            tools:visibility="visible" />
+
+    </LinearLayout>
+
+</LinearLayout>