Skip to content

Commit

Permalink
feat(manga): Date and Scanlator in description
Browse files Browse the repository at this point in the history
  • Loading branch information
aayush2622 committed Feb 29, 2024
1 parent 89aaef8 commit 1316d5a
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 4 deletions.
4 changes: 3 additions & 1 deletion app/src/main/java/ani/dantotsu/media/manga/MangaChapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ data class MangaChapter(
var description: String? = null,
var sChapter: SChapter,
val scanlator: String? = null,
val date: Long? = null,
var progress: String? = ""
) : Serializable {
constructor(chapter: MangaChapter) : this(
Expand All @@ -21,7 +22,8 @@ data class MangaChapter(
chapter.title,
chapter.description,
chapter.sChapter,
chapter.scanlator
chapter.scanlator,
chapter.date
)

private val images = mutableListOf<MangaImage>()
Expand Down
22 changes: 22 additions & 0 deletions app/src/main/java/ani/dantotsu/media/manga/MangaChapterAdapter.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ani.dantotsu.media.manga

import android.annotation.SuppressLint
import android.app.AlertDialog
import android.util.TypedValue
import android.view.LayoutInflater
Expand All @@ -16,6 +17,9 @@ import ani.dantotsu.databinding.ItemChapterListBinding
import ani.dantotsu.databinding.ItemEpisodeCompactBinding
import ani.dantotsu.media.Media
import ani.dantotsu.setAnimation
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

Expand Down Expand Up @@ -258,6 +262,7 @@ class MangaChapterAdapter(
}
}

@SuppressLint("SetTextI18n")
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
when (holder) {
is ChapterCompactViewHolder -> {
Expand Down Expand Up @@ -290,6 +295,23 @@ class MangaChapterAdapter(
holder.bind(ep.number, ep.progress)
setAnimation(fragment.requireContext(), holder.binding.root)
binding.itemChapterNumber.text = ep.number

if (ep.date != null) {
binding.itemChapterDateLayout.visibility = View.VISIBLE
val time = Date(ep.date)
val dateFormat = SimpleDateFormat("MMM/dd/yyyy", Locale.ENGLISH).format(time)
binding.itemChapterDate.text =
if (dateFormat != "Jan/01/1970") "$dateFormat" else ""
}
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 (ep.progress.isNullOrEmpty()) {
binding.itemChapterTitle.visibility = View.GONE
} else binding.itemChapterTitle.visibility = View.VISIBLE
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/ani/dantotsu/parsers/AniyomiAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,8 @@ class DynamicMangaParser(extension: MangaExtension.Installed) : MangaParser() {
sChapter.name,
null,
sChapter.scanlator,
sChapter
sChapter,
sChapter.date_upload
)
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/ani/dantotsu/parsers/MangaParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ data class MangaChapter(
val description: String? = null,
val scanlator: String? = null,
val sChapter: SChapter,
val date: Long? = null,
)

data class MangaImage(
Expand Down
41 changes: 39 additions & 2 deletions app/src/main/res/layout/item_chapter_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
android:textAppearance="@style/TextAppearance.Widget.AppCompat.Toolbar.Title"
android:textColor="?attr/colorOnBackground"
android:textSize="16sp"
tools:text="1" />
tools:text="Chapter: 1" />

<ImageButton
android:id="@+id/itemEpisodeViewed"
Expand All @@ -53,10 +53,47 @@
app:tint="?attr/colorOnBackground" />

</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">

<TextView
android:id="@+id/itemChapterDate"
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="Aug/12/1969"
tools:visibility="visible"
tools:ignore="SpUsage" />

<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
android:id="@+id/itemChapterTitle"
android:layout_width="312dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="-10dp"
Expand Down

0 comments on commit 1316d5a

Please sign in to comment.