mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 14:27:57 +01:00 
			
		
		
		
	Allow preserving reading position even when manga is read
This commit is contained in:
		| @@ -176,4 +176,6 @@ object PreferenceKeys { | ||||
|     const val eh_utilAutoscrollInterval = "eh_util_autoscroll_interval" | ||||
|  | ||||
|     const val eh_cacheSize = "eh_cache_size" | ||||
|  | ||||
|     const val eh_preserveReadingPosition = "eh_preserve_reading_position" | ||||
| } | ||||
|   | ||||
| @@ -247,4 +247,6 @@ class PreferencesHelper(val context: Context) { | ||||
|     fun eh_utilAutoscrollInterval() = rxPrefs.getFloat(Keys.eh_utilAutoscrollInterval, 3f) | ||||
|  | ||||
|     fun eh_cacheSize() = rxPrefs.getString(Keys.eh_cacheSize, "75") | ||||
|  | ||||
|     fun eh_preserveReadingPosition() = rxPrefs.getBoolean(Keys.eh_preserveReadingPosition, false) | ||||
| } | ||||
|   | ||||
| @@ -5,17 +5,21 @@ import android.widget.PopupMenu | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.data.database.models.Manga | ||||
| import eu.kanade.tachiyomi.data.download.model.Download | ||||
| import eu.kanade.tachiyomi.data.preference.PreferencesHelper | ||||
| import eu.kanade.tachiyomi.data.preference.getOrDefault | ||||
| import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder | ||||
| import eu.kanade.tachiyomi.util.getResourceColor | ||||
| import eu.kanade.tachiyomi.util.gone | ||||
| import eu.kanade.tachiyomi.util.setVectorCompat | ||||
| import kotlinx.android.synthetic.main.chapters_item.* | ||||
| import uy.kohesive.injekt.injectLazy | ||||
| import java.util.* | ||||
|  | ||||
| class ChapterHolder( | ||||
|         private val view: View, | ||||
|         private val adapter: ChaptersAdapter | ||||
| ) : BaseFlexibleViewHolder(view, adapter) { | ||||
|     private val prefs: PreferencesHelper by injectLazy() | ||||
|  | ||||
|     init { | ||||
|         // We need to post a Runnable to show the popup to make sure that the PopupMenu is | ||||
| @@ -59,7 +63,8 @@ class ChapterHolder( | ||||
|             chapter_title.maxLines = 1 | ||||
|         } | ||||
|  | ||||
|         chapter_pages.text = if (!chapter.read && chapter.last_page_read > 0) { | ||||
|         chapter_pages.text = if ((!chapter.read /* --> EH */ || prefs.eh_preserveReadingPosition() | ||||
|                         .getOrDefault()) /* <-- EH */ && chapter.last_page_read > 0) { | ||||
|             itemView.context.getString(R.string.chapter_progress, chapter.last_page_read + 1) | ||||
|         } else { | ||||
|             "" | ||||
| @@ -100,7 +105,8 @@ class ChapterHolder( | ||||
|         popup.menu.findItem(R.id.action_remove_bookmark).isVisible = chapter.bookmark | ||||
|  | ||||
|         // Hide mark as unread when the chapter is unread | ||||
|         if (!chapter.read && chapter.last_page_read == 0) { | ||||
|         if (!chapter.read && (chapter.last_page_read == 0 /* --> EH */ || prefs.eh_preserveReadingPosition() | ||||
|                         .getOrDefault()) /* <-- EH */) { | ||||
|             popup.menu.findItem(R.id.action_mark_as_unread).isVisible = false | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -9,6 +9,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga | ||||
| import eu.kanade.tachiyomi.data.download.DownloadManager | ||||
| import eu.kanade.tachiyomi.data.download.model.Download | ||||
| import eu.kanade.tachiyomi.data.preference.PreferencesHelper | ||||
| import eu.kanade.tachiyomi.data.preference.getOrDefault | ||||
| import eu.kanade.tachiyomi.source.Source | ||||
| import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter | ||||
| import eu.kanade.tachiyomi.util.isNullOrUnsubscribed | ||||
| @@ -233,7 +234,9 @@ class ChaptersPresenter( | ||||
|         Observable.from(selectedChapters) | ||||
|                 .doOnNext { chapter -> | ||||
|                     chapter.read = read | ||||
|                     if (!read) { | ||||
|                     if (!read /* --> EH */ && !preferences | ||||
|                                     .eh_preserveReadingPosition() | ||||
|                                     .getOrDefault() /* <-- EH */) { | ||||
|                         chapter.last_page_read = 0 | ||||
|                     } | ||||
|                 } | ||||
|   | ||||
| @@ -13,6 +13,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga | ||||
| import eu.kanade.tachiyomi.data.database.models.Track | ||||
| import eu.kanade.tachiyomi.data.download.DownloadManager | ||||
| import eu.kanade.tachiyomi.data.preference.PreferencesHelper | ||||
| import eu.kanade.tachiyomi.data.preference.getOrDefault | ||||
| import eu.kanade.tachiyomi.data.track.TrackManager | ||||
| import eu.kanade.tachiyomi.source.LocalSource | ||||
| import eu.kanade.tachiyomi.source.SourceManager | ||||
| @@ -276,7 +277,9 @@ class ReaderPresenter( | ||||
|  | ||||
|         // If the chapter is partially read, set the starting page to the last the user read | ||||
|         // otherwise use the requested page. | ||||
|         chapter.requestedPage = if (!chapter.read) chapter.last_page_read else requestedPage | ||||
|         chapter.requestedPage = if (!chapter.read /* --> EH */ || prefs | ||||
|                         .eh_preserveReadingPosition() | ||||
|                         .getOrDefault() /* <-- EH */) chapter.last_page_read else requestedPage | ||||
|  | ||||
|         // Reset next and previous chapter. They have to be fetched again | ||||
|         nextChapter = null | ||||
|   | ||||
| @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.setting | ||||
|  | ||||
| import android.support.v7.preference.PreferenceScreen | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.util.SharedData.map | ||||
| import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys | ||||
|  | ||||
| class SettingsReaderController : SettingsController() { | ||||
| @@ -141,6 +142,11 @@ class SettingsReaderController : SettingsController() { | ||||
|             defaultValue = "75" | ||||
|             summary = "The amount of images to save on device while reading. Higher values will result in a smoother reading experience, at the cost of higher disk space usage" | ||||
|         } | ||||
|         switchPreference { | ||||
|             key = Keys.eh_preserveReadingPosition | ||||
|             title = "Preserve reading position on read manga" | ||||
|             defaultValue = false | ||||
|         } | ||||
|         preferenceCategory { | ||||
|             titleRes = R.string.pager_viewer | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user