Merge branch 'dev' of https://github.com/rebelonion/Dantotsu into dev
This commit is contained in:
commit
05fc97a933
6 changed files with 113 additions and 8 deletions
|
@ -13,6 +13,7 @@ data class MangaChapter(
|
||||||
var description: String? = null,
|
var description: String? = null,
|
||||||
var sChapter: SChapter,
|
var sChapter: SChapter,
|
||||||
val scanlator: String? = null,
|
val scanlator: String? = null,
|
||||||
|
val date: Long? = null,
|
||||||
var progress: String? = ""
|
var progress: String? = ""
|
||||||
) : Serializable {
|
) : Serializable {
|
||||||
constructor(chapter: MangaChapter) : this(
|
constructor(chapter: MangaChapter) : this(
|
||||||
|
@ -21,7 +22,8 @@ data class MangaChapter(
|
||||||
chapter.title,
|
chapter.title,
|
||||||
chapter.description,
|
chapter.description,
|
||||||
chapter.sChapter,
|
chapter.sChapter,
|
||||||
chapter.scanlator
|
chapter.scanlator,
|
||||||
|
chapter.date
|
||||||
)
|
)
|
||||||
|
|
||||||
private val images = mutableListOf<MangaImage>()
|
private val images = mutableListOf<MangaImage>()
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package ani.dantotsu.media.manga
|
package ani.dantotsu.media.manga
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
@ -16,6 +17,9 @@ import ani.dantotsu.databinding.ItemChapterListBinding
|
||||||
import ani.dantotsu.databinding.ItemEpisodeCompactBinding
|
import ani.dantotsu.databinding.ItemEpisodeCompactBinding
|
||||||
import ani.dantotsu.media.Media
|
import ani.dantotsu.media.Media
|
||||||
import ani.dantotsu.setAnimation
|
import ani.dantotsu.setAnimation
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Date
|
||||||
|
import java.util.Locale
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
@ -258,6 +262,7 @@ class MangaChapterAdapter(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||||
when (holder) {
|
when (holder) {
|
||||||
is ChapterCompactViewHolder -> {
|
is ChapterCompactViewHolder -> {
|
||||||
|
@ -290,6 +295,23 @@ class MangaChapterAdapter(
|
||||||
holder.bind(ep.number, ep.progress)
|
holder.bind(ep.number, ep.progress)
|
||||||
setAnimation(fragment.requireContext(), holder.binding.root)
|
setAnimation(fragment.requireContext(), holder.binding.root)
|
||||||
binding.itemChapterNumber.text = ep.number
|
binding.itemChapterNumber.text = ep.number
|
||||||
|
|
||||||
|
if (ep.date != null) {
|
||||||
|
binding.itemChapterDateLayout.visibility = View.VISIBLE
|
||||||
|
binding.itemChapterDate.text = formatDate(ep.date)
|
||||||
|
}
|
||||||
|
if (ep.scanlator != null) {
|
||||||
|
binding.itemChapterDateLayout.visibility = View.VISIBLE
|
||||||
|
binding.itemChapterScan.text = ep.scanlator.replaceFirstChar {
|
||||||
|
if (it.isLowerCase()) it.titlecase(
|
||||||
|
Locale.ROOT
|
||||||
|
) else it.toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (formatDate(ep.date) == "" || ep.scanlator == null) {
|
||||||
|
binding.itemChapterDateDivider.visibility = View.GONE
|
||||||
|
} else binding.itemChapterDateDivider.visibility = View.VISIBLE
|
||||||
|
|
||||||
if (ep.progress.isNullOrEmpty()) {
|
if (ep.progress.isNullOrEmpty()) {
|
||||||
binding.itemChapterTitle.visibility = View.GONE
|
binding.itemChapterTitle.visibility = View.GONE
|
||||||
} else binding.itemChapterTitle.visibility = View.VISIBLE
|
} else binding.itemChapterTitle.visibility = View.VISIBLE
|
||||||
|
@ -322,6 +344,33 @@ class MangaChapterAdapter(
|
||||||
fun updateType(t: Int) {
|
fun updateType(t: Int) {
|
||||||
type = t
|
type = t
|
||||||
}
|
}
|
||||||
|
private fun formatDate(timestamp: Long?): String {
|
||||||
|
timestamp ?: return "" // Return empty string if timestamp is null
|
||||||
|
|
||||||
|
val targetDate = Date(timestamp)
|
||||||
|
|
||||||
|
if (targetDate < Date(946684800000L)) { // January 1, 2000 (who want dates before that?)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
val currentDate = Date()
|
||||||
|
val difference = currentDate.time - targetDate.time
|
||||||
|
|
||||||
|
return when (val daysDifference = difference / (1000 * 60 * 60 * 24)) {
|
||||||
|
0L -> {
|
||||||
|
val hoursDifference = difference / (1000 * 60 * 60)
|
||||||
|
val minutesDifference = (difference / (1000 * 60)) % 60
|
||||||
|
|
||||||
|
when {
|
||||||
|
hoursDifference > 0 -> "$hoursDifference hour${if (hoursDifference > 1) "s" else ""} ago"
|
||||||
|
minutesDifference > 0 -> "$minutesDifference minute${if (minutesDifference > 1) "s" else ""} ago"
|
||||||
|
else -> "Just now"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
1L -> "1 day ago"
|
||||||
|
in 2..6 -> "$daysDifference days ago"
|
||||||
|
else -> SimpleDateFormat("dd MMM yyyy", Locale.ENGLISH).format(targetDate)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -633,7 +633,8 @@ class DynamicMangaParser(extension: MangaExtension.Installed) : MangaParser() {
|
||||||
sChapter.name,
|
sChapter.name,
|
||||||
null,
|
null,
|
||||||
sChapter.scanlator,
|
sChapter.scanlator,
|
||||||
sChapter
|
sChapter,
|
||||||
|
sChapter.date_upload
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,7 @@ data class MangaChapter(
|
||||||
val description: String? = null,
|
val description: String? = null,
|
||||||
val scanlator: String? = null,
|
val scanlator: String? = null,
|
||||||
val sChapter: SChapter,
|
val sChapter: SChapter,
|
||||||
|
val date: Long? = null,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class MangaImage(
|
data class MangaImage(
|
||||||
|
|
|
@ -36,18 +36,20 @@ class UserInterfaceSettingsActivity : AppCompatActivity() {
|
||||||
onBackPressedDispatcher.onBackPressed()
|
onBackPressedDispatcher.onBackPressed()
|
||||||
}
|
}
|
||||||
|
|
||||||
val views = resources.getStringArray(R.array.home_layouts)
|
|
||||||
binding.uiSettingsHomeLayout.setOnClickListener {
|
binding.uiSettingsHomeLayout.setOnClickListener {
|
||||||
|
val set = PrefManager.getVal<List<Boolean>>(PrefName.HomeLayoutShow).toMutableList()
|
||||||
|
val views = resources.getStringArray(R.array.home_layouts)
|
||||||
val dialog = AlertDialog.Builder(this, R.style.MyPopup)
|
val dialog = AlertDialog.Builder(this, R.style.MyPopup)
|
||||||
.setTitle(getString(R.string.home_layout_show)).apply {
|
.setTitle(getString(R.string.home_layout_show)).apply {
|
||||||
setMultiChoiceItems(
|
setMultiChoiceItems(
|
||||||
views,
|
views,
|
||||||
PrefManager.getVal<List<Boolean>>(PrefName.HomeLayoutShow).toBooleanArray()
|
PrefManager.getVal<List<Boolean>>(PrefName.HomeLayoutShow).toBooleanArray()
|
||||||
) { _, i, value ->
|
) { _, i, value ->
|
||||||
val set = PrefManager.getVal<List<Boolean>>(PrefName.HomeLayoutShow)
|
|
||||||
.toMutableList()
|
|
||||||
set[i] = value
|
set[i] = value
|
||||||
|
}
|
||||||
|
setPositiveButton("Done") { _, _ ->
|
||||||
PrefManager.setVal(PrefName.HomeLayoutShow, set)
|
PrefManager.setVal(PrefName.HomeLayoutShow, set)
|
||||||
|
restartApp()
|
||||||
}
|
}
|
||||||
}.show()
|
}.show()
|
||||||
dialog.window?.setDimAmount(0.8f)
|
dialog.window?.setDimAmount(0.8f)
|
||||||
|
@ -116,4 +118,4 @@ class UserInterfaceSettingsActivity : AppCompatActivity() {
|
||||||
show()
|
show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
android:textAppearance="@style/TextAppearance.Widget.AppCompat.Toolbar.Title"
|
android:textAppearance="@style/TextAppearance.Widget.AppCompat.Toolbar.Title"
|
||||||
android:textColor="?attr/colorOnBackground"
|
android:textColor="?attr/colorOnBackground"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
tools:text="1" />
|
tools:text="Chapter: 1" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/itemEpisodeViewed"
|
android:id="@+id/itemEpisodeViewed"
|
||||||
|
@ -53,10 +53,60 @@
|
||||||
app:tint="?attr/colorOnBackground" />
|
app:tint="?attr/colorOnBackground" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/itemChapterDateLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_marginTop="-20dp"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:layout_marginEnd="100dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/itemChapterDate"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="3dp"
|
||||||
|
android:alpha="0.6"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:fontFamily="@font/poppins_bold"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textSize="12dp"
|
||||||
|
tools:text="Aug/12/1969"
|
||||||
|
tools:visibility="visible"
|
||||||
|
tools:ignore="SpUsage" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/itemChapterDateDivider"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="3dp"
|
||||||
|
android:alpha="0.6"
|
||||||
|
android:fontFamily="@font/poppins_bold"
|
||||||
|
android:text="•"
|
||||||
|
android:textSize="16sp"
|
||||||
|
tools:ignore="HardcodedText,RtlSymmetry" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/itemChapterScan"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:alpha="0.6"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:fontFamily="@font/poppins_bold"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textSize="12dp"
|
||||||
|
tools:text="Manga"
|
||||||
|
tools:visibility="visible"
|
||||||
|
tools:ignore="SpUsage" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/itemChapterTitle"
|
android:id="@+id/itemChapterTitle"
|
||||||
android:layout_width="312dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="10dp"
|
android:layout_marginStart="10dp"
|
||||||
android:layout_marginTop="-10dp"
|
android:layout_marginTop="-10dp"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue