diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryBadge.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryBadge.kt
index 0e45d9b006..9e38a57ea9 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryBadge.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryBadge.kt
@@ -1,15 +1,17 @@
package eu.kanade.tachiyomi.ui.library
import android.content.Context
-import android.graphics.Color
import android.util.AttributeSet
import android.view.View
-import androidx.core.content.ContextCompat
import com.google.android.material.card.MaterialCardView
import eu.kanade.tachiyomi.R
+import eu.kanade.tachiyomi.util.system.contextCompatColor
import eu.kanade.tachiyomi.util.system.dpToPx
-import eu.kanade.tachiyomi.util.system.getResourceColor
+import eu.kanade.tachiyomi.util.view.gone
+import eu.kanade.tachiyomi.util.view.isNotGone
+import eu.kanade.tachiyomi.util.view.isVisible
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
+import eu.kanade.tachiyomi.util.view.visibleIf
import kotlinx.android.synthetic.main.unread_download_badge.view.*
class LibraryBadge @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
@@ -17,39 +19,43 @@ class LibraryBadge @JvmOverloads constructor(context: Context, attrs: AttributeS
fun setUnreadDownload(unread: Int, downloads: Int, showTotalChapters: Boolean) {
// Update the unread count and its visibility.
+
+ val unreadBadgeBackground = when (showTotalChapters) {
+ true -> context.contextCompatColor(R.color.total_badge)
+ false -> context.contextCompatColor(R.color.unread_badge)
+ }
+
with(unread_text) {
+ visibleIf(unread > 0 || unread == -1 || showTotalChapters)
+
text = if (unread == -1) "0" else unread.toString()
- setTextColor(if (unread == -1 && !showTotalChapters)
- context.getResourceColor(android.R.attr.colorAccent)
- else Color.WHITE)
- setBackgroundColor(
- if (showTotalChapters) ContextCompat.getColor(context, R.color.material_deep_purple_500)
- else context.getResourceColor(android.R.attr.colorAccent))
- visibility = when {
- unread > 0 || unread == -1 || showTotalChapters -> View.VISIBLE
- else -> View.GONE
- }
+ setTextColor(
+ when (unread == -1 && !showTotalChapters) {
+ true -> context.contextCompatColor(R.color.unread_badge) // hide the 0 in the badge
+ false -> context.contextCompatColor(R.color.unread_badge_text)
+ }
+ )
+ setBackgroundColor(unreadBadgeBackground)
}
// Update the download count or local status and its visibility.
with(download_text) {
- visibility = if (downloads == -2 || downloads > 0) View.VISIBLE else View.GONE
- text = if (downloads == -2)
+ visibleIf(downloads == -2 || downloads > 0)
+ text = if (downloads == -2) {
resources.getString(R.string.local)
- else downloads.toString()
+ } else {
+ downloads.toString()
+ }
}
- // Show the bade card if unread or downloads exists
- visibility = if (download_text.visibility == View.VISIBLE || unread_text
- .visibility != View.GONE) View.VISIBLE else View.GONE
+ // Show the badge card if unread or downloads exists
+ this.visibleIf(download_text.isVisible() || unread_text.isNotGone())
// Show the angles divider if both unread and downloads exists
- unread_angle.visibility = if (download_text.visibility == View.VISIBLE && unread_text
- .visibility != View.GONE) View.VISIBLE else View.GONE
- unread_angle.setColorFilter(
- if (showTotalChapters) ContextCompat.getColor(context, R.color.material_deep_purple_500)
- else context.getResourceColor(android.R.attr.colorAccent))
- if (unread_angle.visibility == View.VISIBLE) {
+ unread_angle.visibleIf(download_text.isVisible() && unread_text.isNotGone())
+
+ unread_angle.setColorFilter(unreadBadgeBackground)
+ if (unread_angle.isVisible()) {
download_text.updatePaddingRelative(end = 8.dpToPx)
unread_text.updatePaddingRelative(start = 2.dpToPx)
} else {
@@ -63,10 +69,10 @@ class LibraryBadge @JvmOverloads constructor(context: Context, attrs: AttributeS
}
fun setInLibrary(inLibrary: Boolean) {
- visibility = if (inLibrary) View.VISIBLE else View.GONE
- unread_angle.visibility = View.GONE
+ this.visibleIf(inLibrary)
+ unread_angle.gone()
unread_text.updatePaddingRelative(start = 5.dpToPx)
- unread_text.visibility = if (inLibrary) View.VISIBLE else View.GONE
+ unread_text.visibleIf(inLibrary)
unread_text.text = resources.getText(R.string.in_library)
}
}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt
index b28d065b8e..f418f48625 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt
@@ -61,7 +61,6 @@ class TrackSearchDialog : DialogController {
val dialog = MaterialDialog(activity!!).apply {
customView(viewRes = R.layout.track_search_dialog, scrollable = false)
negativeButton(android.R.string.cancel)
- positiveButton(R.string.clear) { onPositiveButtonClick() }
if (wasPreviouslyTracked) {
positiveButton(R.string.clear) { onPositiveButtonClick() }
}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt
index cb5402972a..1e442d8725 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt
@@ -97,6 +97,14 @@ inline fun View.gone() {
visibility = View.GONE
}
+inline fun View.isVisible(): Boolean {
+ return visibility == View.VISIBLE
+}
+
+inline fun View.isNotGone(): Boolean {
+ return visibility != View.GONE
+}
+
inline fun View.visibleIf(show: Boolean) {
visibility = if (show) View.VISIBLE else View.GONE
}
diff --git a/app/src/main/res/drawable/unread_angled_badge.xml b/app/src/main/res/drawable/unread_angled_badge.xml
index b634e73025..4d5987186d 100644
--- a/app/src/main/res/drawable/unread_angled_badge.xml
+++ b/app/src/main/res/drawable/unread_angled_badge.xml
@@ -8,8 +8,8 @@
tools:background="@color/red_error">
+ android:strokeColor="@color/unread_badge" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/unread_download_badge.xml b/app/src/main/res/layout/unread_download_badge.xml
index 0c25d5dd03..1821957584 100644
--- a/app/src/main/res/layout/unread_download_badge.xml
+++ b/app/src/main/res/layout/unread_download_badge.xml
@@ -21,12 +21,12 @@
style="@style/TextAppearance.Regular.Caption.Light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:background="@color/pale_green"
+ android:background="@color/download_badge"
android:gravity="center"
android:maxLines="1"
android:paddingStart="5dp"
android:paddingEnd="5dp"
- android:textColor="@color/md_black_1000"
+ android:textColor="@color/download_badge_text"
android:textSize="13sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
@@ -44,19 +44,20 @@
android:src="@drawable/unread_angled_badge"
app:layout_constraintBottom_toBottomOf="@+id/unread_text"
app:layout_constraintEnd_toStartOf="@id/unread_text"
- app:layout_constraintTop_toTopOf="@+id/unread_text" />
+ app:layout_constraintTop_toTopOf="@+id/unread_text"
+ tools:ignore="ContentDescription" />
@color/md_black_1000_38
#404040
+ @color/colorAccent
+ @color/md_white_1000
+ @color/pale_green
+ @color/md_black_1000
+ @color/material_deep_purple_500
+ @color/md_white_1000
+
+
@color/md_black_1000
@color/md_black_1000_87