diff --git a/.gitignore b/.gitignore
index 2968239c3..a8c7b78f4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
/local.properties
/.idea/caches
/.idea/libraries
+/.idea/dictionaries
/.idea/modules.xml
/.idea/misc.xml
/.idea/workspace.xml
diff --git a/.idea/dictionaries/admin.xml b/.idea/dictionaries/admin.xml
deleted file mode 100644
index 64cf6888c..000000000
--- a/.idea/dictionaries/admin.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
- amoled
- chucker
- desu
- failsafe
- koin
- kotatsu
- manga
- snackbar
- upsert
- webtoon
-
-
-
\ No newline at end of file
diff --git a/app/src/main/java/org/koitharu/kotatsu/details/ui/DetailsViewModel.kt b/app/src/main/java/org/koitharu/kotatsu/details/ui/DetailsViewModel.kt
index ebd377a50..570172cd4 100644
--- a/app/src/main/java/org/koitharu/kotatsu/details/ui/DetailsViewModel.kt
+++ b/app/src/main/java/org/koitharu/kotatsu/details/ui/DetailsViewModel.kt
@@ -171,6 +171,7 @@ class DetailsViewModel(
branch: String?,
): List {
val result = ArrayList(chapters.size)
+ val dateFormat = settings.dateFormat()
val currentIndex = chapters.indexOfFirst { it.id == currentId }
val firstNewIndex = chapters.size - newCount
for (i in chapters.indices) {
@@ -185,7 +186,8 @@ class DetailsViewModel(
i < currentIndex -> ChapterExtra.READ
else -> ChapterExtra.UNREAD
},
- isMissing = false
+ isMissing = false,
+ dateFormat = dateFormat,
)
}
return result
@@ -202,6 +204,7 @@ class DetailsViewModel(
val result = ArrayList(sourceChapters.size)
val currentIndex = sourceChapters.indexOfFirst { it.id == currentId }
val firstNewIndex = sourceChapters.size - newCount
+ val dateFormat = settings.dateFormat()
for (i in sourceChapters.indices) {
val chapter = sourceChapters[i]
if (chapter.branch != branch) {
@@ -215,7 +218,8 @@ class DetailsViewModel(
i < currentIndex -> ChapterExtra.READ
else -> ChapterExtra.UNREAD
},
- isMissing = false
+ isMissing = false,
+ dateFormat = dateFormat,
) ?: chapter.toListItem(
extra = when {
i >= firstNewIndex -> ChapterExtra.NEW
@@ -223,13 +227,14 @@ class DetailsViewModel(
i < currentIndex -> ChapterExtra.READ
else -> ChapterExtra.UNREAD
},
- isMissing = true
+ isMissing = true,
+ dateFormat = dateFormat,
)
}
if (chaptersMap.isNotEmpty()) { // some chapters on device but not online source
result.ensureCapacity(result.size + chaptersMap.size)
chaptersMap.values.mapTo(result) {
- it.toListItem(ChapterExtra.UNREAD, false)
+ it.toListItem(ChapterExtra.UNREAD, false, dateFormat)
}
result.sortBy { it.chapter.number }
}
diff --git a/app/src/main/java/org/koitharu/kotatsu/details/ui/adapter/ChapterListItemAD.kt b/app/src/main/java/org/koitharu/kotatsu/details/ui/adapter/ChapterListItemAD.kt
index 9db3208e8..8a6d9b3e4 100644
--- a/app/src/main/java/org/koitharu/kotatsu/details/ui/adapter/ChapterListItemAD.kt
+++ b/app/src/main/java/org/koitharu/kotatsu/details/ui/adapter/ChapterListItemAD.kt
@@ -1,16 +1,13 @@
package org.koitharu.kotatsu.details.ui.adapter
-import android.text.SpannableStringBuilder
import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding
-import org.koin.core.context.GlobalContext
import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.base.ui.list.OnListItemClickListener
-import org.koitharu.kotatsu.core.prefs.AppSettings
import org.koitharu.kotatsu.databinding.ItemChapterBinding
import org.koitharu.kotatsu.details.ui.model.ChapterListItem
import org.koitharu.kotatsu.history.domain.ChapterExtra
import org.koitharu.kotatsu.utils.ext.getThemeColor
-import java.util.*
+import org.koitharu.kotatsu.utils.ext.textAndVisible
fun chapterListItemAD(
clickListener: OnListItemClickListener,
@@ -25,23 +22,10 @@ fun chapterListItemAD(
clickListener.onItemLongClick(item, it)
}
- bind { payload ->
+ bind {
binding.textViewTitle.text = item.chapter.name
binding.textViewNumber.text = item.chapter.number.toString()
- val settings = GlobalContext.get().get()
- val descriptions = mutableListOf()
- val dateFormat = settings.dateFormat()
- if (item.chapter.uploadDate > 0) {
- descriptions.add(dateFormat.format(Date(item.chapter.uploadDate)))
- }
- if (!item.chapter.scanlator.isNullOrBlank()) {
- descriptions.add(item.chapter.scanlator!!)
- }
- if (descriptions.isNotEmpty()) {
- binding.textViewDescription.text = descriptions.joinTo(SpannableStringBuilder(), " • ")
- } else {
- binding.textViewDescription.text = ""
- }
+ binding.textViewDescription.textAndVisible = item.description()
when (item.extra) {
ChapterExtra.UNREAD -> {
binding.textViewNumber.setBackgroundResource(R.drawable.bg_badge_default)
diff --git a/app/src/main/java/org/koitharu/kotatsu/details/ui/model/ChapterListItem.kt b/app/src/main/java/org/koitharu/kotatsu/details/ui/model/ChapterListItem.kt
index 82f00decf..f45228688 100644
--- a/app/src/main/java/org/koitharu/kotatsu/details/ui/model/ChapterListItem.kt
+++ b/app/src/main/java/org/koitharu/kotatsu/details/ui/model/ChapterListItem.kt
@@ -7,4 +7,15 @@ data class ChapterListItem(
val chapter: MangaChapter,
val extra: ChapterExtra,
val isMissing: Boolean,
-)
+ val uploadDate: String?,
+) {
+
+ fun description(): CharSequence? {
+ val scanlator = chapter.scanlator?.takeUnless { it.isBlank() }
+ return when {
+ uploadDate != null && scanlator != null -> "$uploadDate • $scanlator"
+ scanlator != null -> scanlator
+ else -> uploadDate
+ }
+ }
+}
diff --git a/app/src/main/java/org/koitharu/kotatsu/details/ui/model/ListModelConversionExt.kt b/app/src/main/java/org/koitharu/kotatsu/details/ui/model/ListModelConversionExt.kt
index 0a1609989..a5de76fd1 100644
--- a/app/src/main/java/org/koitharu/kotatsu/details/ui/model/ListModelConversionExt.kt
+++ b/app/src/main/java/org/koitharu/kotatsu/details/ui/model/ListModelConversionExt.kt
@@ -2,12 +2,15 @@ package org.koitharu.kotatsu.details.ui.model
import org.koitharu.kotatsu.core.model.MangaChapter
import org.koitharu.kotatsu.history.domain.ChapterExtra
+import java.text.DateFormat
fun MangaChapter.toListItem(
extra: ChapterExtra,
isMissing: Boolean,
+ dateFormat: DateFormat,
) = ChapterListItem(
chapter = this,
extra = extra,
isMissing = isMissing,
+ uploadDate = if (uploadDate != 0L) dateFormat.format(uploadDate) else null
)
\ No newline at end of file
diff --git a/app/src/main/java/org/koitharu/kotatsu/reader/ui/ChaptersDialog.kt b/app/src/main/java/org/koitharu/kotatsu/reader/ui/ChaptersDialog.kt
index 78d713fff..37fb8f8fd 100644
--- a/app/src/main/java/org/koitharu/kotatsu/reader/ui/ChaptersDialog.kt
+++ b/app/src/main/java/org/koitharu/kotatsu/reader/ui/ChaptersDialog.kt
@@ -9,10 +9,12 @@ import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
+import org.koin.android.ext.android.get
import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.base.ui.AlertDialogFragment
import org.koitharu.kotatsu.base.ui.list.OnListItemClickListener
import org.koitharu.kotatsu.core.model.MangaChapter
+import org.koitharu.kotatsu.core.prefs.AppSettings
import org.koitharu.kotatsu.databinding.DialogChaptersBinding
import org.koitharu.kotatsu.details.ui.adapter.ChaptersAdapter
import org.koitharu.kotatsu.details.ui.model.ChapterListItem
@@ -45,6 +47,7 @@ class ChaptersDialog : AlertDialogFragment(),
}
val currentId = arguments?.getLong(ARG_CURRENT_ID, 0L) ?: 0L
val currentPosition = chapters.indexOfFirst { it.id == currentId }
+ val dateFormat = get().dateFormat()
binding.recyclerViewChapters.adapter = ChaptersAdapter(this).apply {
setItems(chapters.mapIndexed { index, chapter ->
chapter.toListItem(
@@ -53,7 +56,8 @@ class ChaptersDialog : AlertDialogFragment(),
index == currentPosition -> ChapterExtra.CURRENT
else -> ChapterExtra.UNREAD
},
- isMissing = false
+ isMissing = false,
+ dateFormat = dateFormat,
)
}) {
if (currentPosition >= 0) {
diff --git a/app/src/main/res/layout/item_chapter.xml b/app/src/main/res/layout/item_chapter.xml
index 873ac5830..d0da1ba31 100644
--- a/app/src/main/res/layout/item_chapter.xml
+++ b/app/src/main/res/layout/item_chapter.xml
@@ -40,6 +40,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView_number"
app:layout_constraintTop_toTopOf="parent"
+ app:layout_goneMarginBottom="8dp"
tools:text="@tools:sample/lorem[15]" />