Rounded library badges

This commit is contained in:
arkon 2020-06-13 17:00:32 -04:00
parent 395ca3630c
commit 6ad3fcb91d
10 changed files with 146 additions and 166 deletions

View File

@ -40,7 +40,7 @@ class SourceComfortableGridHolder(private val view: View, private val adapter: F
} }
override fun setImage(manga: Manga) { override fun setImage(manga: Manga) {
// Setting this via XML doesn't work // For rounded corners
card.clipToOutline = true card.clipToOutline = true
GlideApp.with(view.context).clear(thumbnail) GlideApp.with(view.context).clear(thumbnail)

View File

@ -40,7 +40,7 @@ open class SourceGridHolder(private val view: View, private val adapter: Flexibl
} }
override fun setImage(manga: Manga) { override fun setImage(manga: Manga) {
// Setting this via XML doesn't work // For rounded corners
card.clipToOutline = true card.clipToOutline = true
GlideApp.with(view.context).clear(thumbnail) GlideApp.with(view.context).clear(thumbnail)

View File

@ -9,6 +9,7 @@ import eu.kanade.tachiyomi.data.glide.GlideApp
import eu.kanade.tachiyomi.data.glide.toMangaThumbnail import eu.kanade.tachiyomi.data.glide.toMangaThumbnail
import eu.kanade.tachiyomi.util.isLocal import eu.kanade.tachiyomi.util.isLocal
import eu.kanade.tachiyomi.util.view.visibleIf import eu.kanade.tachiyomi.util.view.visibleIf
import kotlinx.android.synthetic.main.source_comfortable_grid_item.badges
import kotlinx.android.synthetic.main.source_comfortable_grid_item.card import kotlinx.android.synthetic.main.source_comfortable_grid_item.card
import kotlinx.android.synthetic.main.source_comfortable_grid_item.download_text import kotlinx.android.synthetic.main.source_comfortable_grid_item.download_text
import kotlinx.android.synthetic.main.source_comfortable_grid_item.local_text import kotlinx.android.synthetic.main.source_comfortable_grid_item.local_text
@ -28,7 +29,7 @@ import kotlinx.android.synthetic.main.source_comfortable_grid_item.unread_text
class LibraryComfortableGridHolder( class LibraryComfortableGridHolder(
private val view: View, private val view: View,
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>> adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>
) : LibraryGridHolder(view, adapter) { ) : LibraryCompactGridHolder(view, adapter) {
/** /**
* Method called from [LibraryCategoryAdapter.onBindViewHolder]. It updates the data for this * Method called from [LibraryCategoryAdapter.onBindViewHolder]. It updates the data for this
@ -40,6 +41,9 @@ class LibraryComfortableGridHolder(
// Update the title of the manga. // Update the title of the manga.
title.text = item.manga.title title.text = item.manga.title
// For rounded corners
badges.clipToOutline = true
// Update the unread count and its visibility. // Update the unread count and its visibility.
with(unread_text) { with(unread_text) {
visibleIf { item.unreadCount > 0 } visibleIf { item.unreadCount > 0 }
@ -53,7 +57,7 @@ class LibraryComfortableGridHolder(
// set local visibility if its local manga // set local visibility if its local manga
local_text.visibleIf { item.manga.isLocal() } local_text.visibleIf { item.manga.isLocal() }
// Setting this via XML doesn't work // For rounded corners
card.clipToOutline = true card.clipToOutline = true
// Update the cover. // Update the cover.

View File

@ -7,6 +7,7 @@ import eu.kanade.tachiyomi.data.glide.GlideApp
import eu.kanade.tachiyomi.data.glide.toMangaThumbnail import eu.kanade.tachiyomi.data.glide.toMangaThumbnail
import eu.kanade.tachiyomi.util.isLocal import eu.kanade.tachiyomi.util.isLocal
import eu.kanade.tachiyomi.util.view.visibleIf import eu.kanade.tachiyomi.util.view.visibleIf
import kotlinx.android.synthetic.main.source_compact_grid_item.badges
import kotlinx.android.synthetic.main.source_compact_grid_item.card import kotlinx.android.synthetic.main.source_compact_grid_item.card
import kotlinx.android.synthetic.main.source_compact_grid_item.download_text import kotlinx.android.synthetic.main.source_compact_grid_item.download_text
import kotlinx.android.synthetic.main.source_compact_grid_item.local_text import kotlinx.android.synthetic.main.source_compact_grid_item.local_text
@ -23,7 +24,7 @@ import kotlinx.android.synthetic.main.source_compact_grid_item.unread_text
* @param listener a listener to react to single tap and long tap events. * @param listener a listener to react to single tap and long tap events.
* @constructor creates a new library holder. * @constructor creates a new library holder.
*/ */
open class LibraryGridHolder( open class LibraryCompactGridHolder(
private val view: View, private val view: View,
private val adapter: FlexibleAdapter<*> private val adapter: FlexibleAdapter<*>
) : LibraryHolder(view, adapter) { ) : LibraryHolder(view, adapter) {
@ -38,6 +39,9 @@ open class LibraryGridHolder(
// Update the title of the manga. // Update the title of the manga.
title.text = item.manga.title title.text = item.manga.title
// For rounded corners
badges.clipToOutline = true
// Update the unread count and its visibility. // Update the unread count and its visibility.
with(unread_text) { with(unread_text) {
visibleIf { item.unreadCount > 0 } visibleIf { item.unreadCount > 0 }
@ -51,7 +55,7 @@ open class LibraryGridHolder(
// set local visibility if its local manga // set local visibility if its local manga
local_text.visibleIf { item.manga.isLocal() } local_text.visibleIf { item.manga.isLocal() }
// Setting this via XML doesn't work // For rounded corners
card.clipToOutline = true card.clipToOutline = true
// Update the cover. // Update the cover.

View File

@ -48,7 +48,7 @@ class LibraryItem(val manga: LibraryManga, private val libraryDisplayMode: Prefe
MATCH_PARENT, coverHeight / 2, Gravity.BOTTOM MATCH_PARENT, coverHeight / 2, Gravity.BOTTOM
) )
} }
LibraryGridHolder(view, adapter) LibraryCompactGridHolder(view, adapter)
} }
DisplayMode.COMFORTABLE_GRID -> { DisplayMode.COMFORTABLE_GRID -> {
val parent = adapter.recyclerView as AutofitRecyclerView val parent = adapter.recyclerView as AutofitRecyclerView

View File

@ -11,6 +11,7 @@ import eu.kanade.tachiyomi.data.glide.GlideApp
import eu.kanade.tachiyomi.data.glide.toMangaThumbnail import eu.kanade.tachiyomi.data.glide.toMangaThumbnail
import eu.kanade.tachiyomi.util.isLocal import eu.kanade.tachiyomi.util.isLocal
import eu.kanade.tachiyomi.util.view.visibleIf import eu.kanade.tachiyomi.util.view.visibleIf
import kotlinx.android.synthetic.main.source_list_item.badges
import kotlinx.android.synthetic.main.source_list_item.download_text import kotlinx.android.synthetic.main.source_list_item.download_text
import kotlinx.android.synthetic.main.source_list_item.local_text import kotlinx.android.synthetic.main.source_list_item.local_text
import kotlinx.android.synthetic.main.source_list_item.thumbnail import kotlinx.android.synthetic.main.source_list_item.thumbnail
@ -42,6 +43,9 @@ class LibraryListHolder(
// Update the title of the manga. // Update the title of the manga.
title.text = item.manga.title title.text = item.manga.title
// For rounded corners
badges.clipToOutline = true
// Update the unread count and its visibility. // Update the unread count and its visibility.
with(unread_text) { with(unread_text) {
visibleIf { item.unreadCount > 0 } visibleIf { item.unreadCount > 0 }

View File

@ -91,7 +91,7 @@ class MangaInfoController(private val fromSource: Boolean = false) :
override fun onViewCreated(view: View) { override fun onViewCreated(view: View) {
super.onViewCreated(view) super.onViewCreated(view)
// Setting this via XML doesn't work // For rounded corners
binding.mangaCover.clipToOutline = true binding.mangaCover.clipToOutline = true
binding.btnFavorite.clicks() binding.btnFavorite.clicks()

View File

@ -28,57 +28,19 @@
tools:ignore="ContentDescription" tools:ignore="ContentDescription"
tools:src="@mipmap/ic_launcher" /> tools:src="@mipmap/ic_launcher" />
<androidx.constraintlayout.widget.ConstraintLayout <LinearLayout
android:id="@+id/badges"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:layout_editor_absoluteX="7dp" android:layout_marginStart="4dp"
tools:layout_editor_absoluteY="7dp"> android:layout_marginTop="4dp"
android:background="@drawable/rounded_rectangle">
<TextView
android:id="@+id/unread_text"
style="@style/TextAppearance.Regular.Caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:background="@color/colorAccentDark"
android:paddingStart="3dp"
android:paddingTop="1dp"
android:paddingEnd="3dp"
android:paddingBottom="1dp"
android:textColor="@color/md_white_1000"
android:visibility="gone"
app:layout_constraintStart_toEndOf="@+id/download_text"
app:layout_constraintTop_toTopOf="parent"
tools:text="120"
tools:visibility="visible" />
<TextView
android:id="@+id/download_text"
style="@style/TextAppearance.Regular.Caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:background="@color/md_red_500"
android:paddingStart="3dp"
android:paddingTop="1dp"
android:paddingEnd="3dp"
android:paddingBottom="1dp"
android:textColor="@color/md_white_1000"
android:visibility="gone"
app:layout_constraintStart_toEndOf="@+id/local_text"
app:layout_constraintTop_toTopOf="parent"
tools:text="120"
tools:visibility="visible" />
<TextView <TextView
android:id="@+id/local_text" android:id="@+id/local_text"
style="@style/TextAppearance.Regular.Caption" style="@style/TextAppearance.Regular.Caption"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:background="@color/md_teal_500" android:background="@color/md_teal_500"
android:paddingStart="3dp" android:paddingStart="3dp"
android:paddingTop="1dp" android:paddingTop="1dp"
@ -87,11 +49,39 @@
android:text="@string/local_source_badge" android:text="@string/local_source_badge"
android:textColor="@color/md_white_1000" android:textColor="@color/md_white_1000"
android:visibility="gone" android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" /> tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout> <TextView
android:id="@+id/unread_text"
style="@style/TextAppearance.Regular.Caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/colorAccentDark"
android:paddingStart="3dp"
android:paddingTop="1dp"
android:paddingEnd="3dp"
android:paddingBottom="1dp"
android:textColor="@color/md_white_1000"
android:visibility="gone"
tools:text="120"
tools:visibility="visible" />
<TextView
android:id="@+id/download_text"
style="@style/TextAppearance.Regular.Caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/md_red_500"
android:paddingStart="3dp"
android:paddingTop="1dp"
android:paddingEnd="3dp"
android:paddingBottom="1dp"
android:textColor="@color/md_white_1000"
android:visibility="gone"
tools:text="120"
tools:visibility="visible" />
</LinearLayout>
<ProgressBar <ProgressBar
android:id="@+id/progress" android:id="@+id/progress"

View File

@ -28,57 +28,19 @@
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:background="@drawable/gradient_shape" /> android:background="@drawable/gradient_shape" />
<androidx.constraintlayout.widget.ConstraintLayout <LinearLayout
android:id="@+id/badges"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:layout_editor_absoluteX="7dp" android:layout_marginStart="4dp"
tools:layout_editor_absoluteY="7dp"> android:layout_marginTop="4dp"
android:background="@drawable/rounded_rectangle">
<TextView
android:id="@+id/unread_text"
style="@style/TextAppearance.Regular.Caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:background="@color/colorAccentDark"
android:paddingStart="3dp"
android:paddingTop="1dp"
android:paddingEnd="3dp"
android:paddingBottom="1dp"
android:textColor="@color/md_white_1000"
android:visibility="gone"
app:layout_constraintStart_toEndOf="@+id/download_text"
app:layout_constraintTop_toTopOf="parent"
tools:text="120"
tools:visibility="visible" />
<TextView
android:id="@+id/download_text"
style="@style/TextAppearance.Regular.Caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:background="@color/md_red_500"
android:paddingStart="3dp"
android:paddingTop="1dp"
android:paddingEnd="3dp"
android:paddingBottom="1dp"
android:textColor="@color/md_white_1000"
android:visibility="gone"
app:layout_constraintStart_toEndOf="@+id/local_text"
app:layout_constraintTop_toTopOf="parent"
tools:text="120"
tools:visibility="visible" />
<TextView <TextView
android:id="@+id/local_text" android:id="@+id/local_text"
style="@style/TextAppearance.Regular.Caption" style="@style/TextAppearance.Regular.Caption"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:background="@color/md_teal_500" android:background="@color/md_teal_500"
android:paddingStart="3dp" android:paddingStart="3dp"
android:paddingTop="1dp" android:paddingTop="1dp"
@ -87,11 +49,39 @@
android:text="@string/local_source_badge" android:text="@string/local_source_badge"
android:textColor="@color/md_white_1000" android:textColor="@color/md_white_1000"
android:visibility="gone" android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" /> tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout> <TextView
android:id="@+id/unread_text"
style="@style/TextAppearance.Regular.Caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/colorAccentDark"
android:paddingStart="3dp"
android:paddingTop="1dp"
android:paddingEnd="3dp"
android:paddingBottom="1dp"
android:textColor="@color/md_white_1000"
android:visibility="gone"
tools:text="120"
tools:visibility="visible" />
<TextView
android:id="@+id/download_text"
style="@style/TextAppearance.Regular.Caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/md_red_500"
android:paddingStart="3dp"
android:paddingTop="1dp"
android:paddingEnd="3dp"
android:paddingBottom="1dp"
android:textColor="@color/md_white_1000"
android:visibility="gone"
tools:text="120"
tools:visibility="visible" />
</LinearLayout>
<TextView <TextView
android:id="@+id/title" android:id="@+id/title"

View File

@ -30,83 +30,71 @@
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/local_text" app:layout_constraintEnd_toStartOf="@+id/badges"
app:layout_constraintHorizontal_bias="0.007" app:layout_constraintHorizontal_bias="0.007"
app:layout_constraintStart_toEndOf="@+id/thumbnail" app:layout_constraintStart_toEndOf="@+id/thumbnail"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.523" app:layout_constraintVertical_bias="0.523"
tools:text="Manga title" /> tools:text="Manga title" />
<TextView <LinearLayout
android:id="@+id/local_text" android:id="@+id/badges"
style="@style/TextAppearance.Regular.Caption"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp" android:background="@drawable/rounded_rectangle"
android:background="@color/md_teal_500"
android:maxLines="1"
android:paddingStart="3dp"
android:paddingTop="1dp"
android:paddingEnd="3dp"
android:paddingBottom="1dp"
android:text="@string/local_source_badge"
android:textColor="@color/md_white_1000"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/unread_text"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" />
<TextView
android:id="@+id/unread_text"
style="@style/TextAppearance.Regular.Caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="@color/colorAccentLight"
android:maxLines="1"
android:paddingStart="3dp"
android:paddingTop="1dp"
android:paddingEnd="3dp"
android:paddingBottom="1dp"
android:textColor="@color/md_white_1000"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@+id/download_text" app:layout_constraintTop_toTopOf="parent">
app:layout_constraintTop_toTopOf="parent"
tools:text="130"
tools:visibility="visible" />
<TextView <TextView
android:id="@+id/download_text" android:id="@+id/local_text"
style="@style/TextAppearance.Regular.Caption" style="@style/TextAppearance.Regular.Caption"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:background="@color/md_teal_500"
android:layout_marginTop="8dp" android:maxLines="1"
android:layout_marginEnd="8dp" android:paddingStart="3dp"
android:layout_marginBottom="8dp" android:paddingTop="1dp"
android:layout_toStartOf="@+id/unread_text" android:paddingEnd="3dp"
android:background="@color/md_red_500" android:paddingBottom="1dp"
android:maxLines="1" android:text="@string/local_source_badge"
android:paddingStart="3dp" android:textColor="@color/md_white_1000"
android:paddingTop="1dp" android:visibility="gone"
android:paddingEnd="3dp" tools:visibility="visible" />
android:paddingBottom="1dp"
android:textColor="@color/md_white_1000" <TextView
android:visibility="gone" android:id="@+id/unread_text"
app:layout_constraintBottom_toBottomOf="parent" style="@style/TextAppearance.Regular.Caption"
app:layout_constraintEnd_toEndOf="parent" android:layout_width="wrap_content"
app:layout_constraintTop_toTopOf="parent" android:layout_height="wrap_content"
tools:text="122" android:background="@color/colorAccentLight"
tools:visibility="visible" /> android:maxLines="1"
android:paddingStart="3dp"
android:paddingTop="1dp"
android:paddingEnd="3dp"
android:paddingBottom="1dp"
android:textColor="@color/md_white_1000"
android:visibility="gone"
tools:text="130"
tools:visibility="visible" />
<TextView
android:id="@+id/download_text"
style="@style/TextAppearance.Regular.Caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/md_red_500"
android:maxLines="1"
android:paddingStart="3dp"
android:paddingTop="1dp"
android:paddingEnd="3dp"
android:paddingBottom="1dp"
android:textColor="@color/md_white_1000"
android:visibility="gone"
tools:text="122"
tools:visibility="visible" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>