Skip to content

Commit

Permalink
Merge branch 'nzoba-pages-left-chapter-j2k'
Browse files Browse the repository at this point in the history
  • Loading branch information
Saud-97 committed Jan 29, 2024
2 parents 6084154 + 9d8731b commit 1513682
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,12 @@ class ChapterHolder(

val showPagesLeft = !chapter.read && chapter.last_page_read > 0 && !isLocked

if (showPagesLeft && chapter.pages_left > 0) {
statuses.add(
itemView.resources.getQuantityString(
R.plurals.pages_left,
chapter.pages_left,
chapter.pages_left,
),
)
} else if (showPagesLeft) {
if (showPagesLeft) {
statuses.add(
itemView.context.getString(
R.string.page_,
R.string.page_x_of_y,
chapter.last_page_read + 1,
chapter.pages_left + chapter.last_page_read,
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,17 +477,17 @@ class ReaderViewModel(
val currentChapters = state.value.viewerChapters ?: return

val selectedChapter = page.chapter
val pages = selectedChapter.pages ?: return

// Save last page read and mark as read if needed
selectedChapter.chapter.last_page_read = page.index
selectedChapter.chapter.pages_left =
(selectedChapter.pages?.size ?: page.index) - page.index
selectedChapter.chapter.pages_left = pages.size - page.index
val shouldTrack = !preferences.incognitoMode().get() || hasTrackers
if (shouldTrack &&
// For double pages, check if the second to last page is doubled up
(
(selectedChapter.pages?.lastIndex == page.index && page.firstHalf != true) ||
(hasExtraPage && selectedChapter.pages?.lastIndex?.minus(1) == page.index)
(pages.lastIndex == page.index && page.firstHalf != true) ||
(hasExtraPage && pages.lastIndex.minus(1) == page.index)
)
) {
selectedChapter.chapter.read = true
Expand All @@ -501,7 +501,6 @@ class ReaderViewModel(
setReadStartTime()
scope.launch { loadNewChapter(selectedChapter) }
}
val pages = page.chapter.pages ?: return
val inDownloadRange = page.number.toDouble() / pages.size > 0.2
if (inDownloadRange) {
downloadNextChapters()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ class RecentMangaHolder(
}
item.chapter.id != item.mch.chapter.id -> readLastText(!moreVisible)
item.chapter.pages_left > 0 && !item.chapter.read -> context.timeSpanFromNow(R.string.read_, item.mch.history.last_read) +
"\n" + itemView.resources.getQuantityString(
R.plurals.pages_left,
item.chapter.pages_left,
item.chapter.pages_left,
"\n" + itemView.context.getString(
R.string.page_x_of_y,
item.last_page_read + 1,
item.pages_left + item.last_page_read,
)
else -> context.timeSpanFromNow(R.string.read_, item.mch.history.last_read)
}
Expand Down
5 changes: 1 addition & 4 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<string name="last_read_chapter_">Last read Chapter %1$s</string>
<string name="chapter_">Chapter %1$s</string>
<string name="chapter_x_of_y">Chapter %1$d of %2$d</string>
<string name="page_x_of_y">Page %1$d of %2$d</string>
<string name="all_chapters_read">All chapters read</string>
<string name="bookmarked">Bookmarked</string>
<string name="not_bookmarked">Not bookmarked</string>
Expand Down Expand Up @@ -79,10 +80,6 @@
<item quantity="one">%1$s chapter</item>
<item quantity="other">%1$s chapters</item>
</plurals>
<plurals name="pages_left">
<item quantity="one">%1$d page left</item>
<item quantity="other">%1$d pages left</item>
</plurals>

<!-- Category -->
<string name="category">Category</string>
Expand Down

0 comments on commit 1513682

Please sign in to comment.