Can now choose to automatically remove chapter after reading (or previous). Fix #42
This commit is contained in:
parent
499c2213ee
commit
a78f89d4eb
7 changed files with 70 additions and 17 deletions
|
@ -190,6 +190,14 @@ class PreferencesHelper(private val context: Context) {
|
||||||
return prefs.getBoolean(getKey(R.string.pref_download_only_over_wifi_key), true)
|
return prefs.getBoolean(getKey(R.string.pref_download_only_over_wifi_key), true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun removeAfterRead(): Boolean {
|
||||||
|
return prefs.getBoolean(getKey(R.string.pref_remove_after_read_key), false)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun removeAfterReadPrevious(): Boolean {
|
||||||
|
return prefs.getBoolean(getKey(R.string.pref_remove_after_read_previous_key), false)
|
||||||
|
}
|
||||||
|
|
||||||
fun removeAfterMarkedAsRead(): Boolean {
|
fun removeAfterMarkedAsRead(): Boolean {
|
||||||
return prefs.getBoolean(getKey(R.string.pref_remove_after_marked_as_read_key), false)
|
return prefs.getBoolean(getKey(R.string.pref_remove_after_marked_as_read_key), false)
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,6 +252,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||||
nextChapterBtn?.isVisible = presenter.hasNextChapter()
|
nextChapterBtn?.isVisible = presenter.hasNextChapter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun getOrCreateViewer(manga: Manga): BaseReader {
|
private fun getOrCreateViewer(manga: Manga): BaseReader {
|
||||||
val mangaViewer = if (manga.viewer == 0) preferences.defaultViewer else manga.viewer
|
val mangaViewer = if (manga.viewer == 0) preferences.defaultViewer else manga.viewer
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
|
||||||
{ view, pair -> view.onAdjacentChapters(pair.first, pair.second) })
|
{ view, pair -> view.onAdjacentChapters(pair.first, pair.second) })
|
||||||
|
|
||||||
startable(PRELOAD_NEXT_CHAPTER, { getPreloadNextChapterObservable() },
|
startable(PRELOAD_NEXT_CHAPTER, { getPreloadNextChapterObservable() },
|
||||||
{ },
|
{ },
|
||||||
{ error -> Timber.e("Error preloading chapter") })
|
{ error -> Timber.e("Error preloading chapter") })
|
||||||
|
|
||||||
|
|
||||||
|
@ -335,10 +335,32 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
|
||||||
// Save current progress of the chapter. Mark as read if the chapter is finished
|
// Save current progress of the chapter. Mark as read if the chapter is finished
|
||||||
if (activePage.isLastPage) {
|
if (activePage.isLastPage) {
|
||||||
chapter.read = true
|
chapter.read = true
|
||||||
|
|
||||||
|
// Check if remove after read is selected by user
|
||||||
|
if (prefs.removeAfterRead()) {
|
||||||
|
if (prefs.removeAfterReadPrevious() ) {
|
||||||
|
if (previousChapter != null) {
|
||||||
|
deleteChapter(previousChapter!!, manga)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
deleteChapter(chapter, manga)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
db.insertChapter(chapter).asRxObservable().subscribe()
|
db.insertChapter(chapter).asRxObservable().subscribe()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete selected chapter
|
||||||
|
* @param chapter chapter that is selected
|
||||||
|
* *
|
||||||
|
* @param manga manga that belongs to chapter
|
||||||
|
*/
|
||||||
|
fun deleteChapter(chapter: Chapter, manga: Manga) {
|
||||||
|
val source = sourceManager.get(manga.source)!!
|
||||||
|
downloadManager.deleteChapter(source, manga, chapter)
|
||||||
|
}
|
||||||
|
|
||||||
// If the current chapter has been read, we check with this one
|
// If the current chapter has been read, we check with this one
|
||||||
// If not, we check if the previous chapter has been read
|
// If not, we check if the previous chapter has been read
|
||||||
// We know the chapter we have to check, but we don't know yet if an update is required.
|
// We know the chapter we have to check, but we don't know yet if an update is required.
|
||||||
|
@ -417,5 +439,4 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
|
||||||
manga.viewer = viewer
|
manga.viewer = viewer
|
||||||
db.insertManga(manga).executeAsBlocking()
|
db.insertManga(manga).executeAsBlocking()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ import java.io.File
|
||||||
class SettingsDownloadsFragment : SettingsNestedFragment() {
|
class SettingsDownloadsFragment : SettingsNestedFragment() {
|
||||||
|
|
||||||
val downloadDirPref by lazy { findPreference(getString(R.string.pref_download_directory_key)) }
|
val downloadDirPref by lazy { findPreference(getString(R.string.pref_download_directory_key)) }
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
val DOWNLOAD_DIR_CODE = 103
|
val DOWNLOAD_DIR_CODE = 103
|
||||||
|
|
|
@ -37,6 +37,10 @@
|
||||||
<string name="pref_download_slots_key">pref_download_slots_key</string>
|
<string name="pref_download_slots_key">pref_download_slots_key</string>
|
||||||
<string name="pref_download_only_over_wifi_key">pref_download_only_over_wifi_key</string>
|
<string name="pref_download_only_over_wifi_key">pref_download_only_over_wifi_key</string>
|
||||||
<string name="pref_remove_after_marked_as_read_key">pref_remove_after_marked_as_read_key</string>
|
<string name="pref_remove_after_marked_as_read_key">pref_remove_after_marked_as_read_key</string>
|
||||||
|
<string name="pref_category_remove_after_read_key">pref_category_remove_after_read_key</string>
|
||||||
|
|
||||||
|
<string name="pref_remove_after_read_key">pref_remove_after_read_key</string>
|
||||||
|
<string name="pref_remove_after_read_previous_key">pref_remove_after_read_previous_key</string>
|
||||||
|
|
||||||
|
|
||||||
<string name="pref_source_languages">pref_source_languages</string>
|
<string name="pref_source_languages">pref_source_languages</string>
|
||||||
|
|
|
@ -135,8 +135,13 @@
|
||||||
<string name="pref_download_slots">Simultaneous downloads</string>
|
<string name="pref_download_slots">Simultaneous downloads</string>
|
||||||
<string name="pref_download_only_over_wifi">Only download over Wi-Fi</string>
|
<string name="pref_download_only_over_wifi">Only download over Wi-Fi</string>
|
||||||
<string name="pref_remove_after_marked_as_read">Remove when marked as read</string>
|
<string name="pref_remove_after_marked_as_read">Remove when marked as read</string>
|
||||||
|
<string name="pref_remove_after_read">Remove after read</string>
|
||||||
|
<string name="cat_remove_after_read">Remove after read</string>
|
||||||
|
<string name="current_chapter">Current chapter</string>
|
||||||
|
<string name="previous_chapter">Previous chapter</string>
|
||||||
<string name="custom_dir">Custom directory</string>
|
<string name="custom_dir">Custom directory</string>
|
||||||
|
|
||||||
|
|
||||||
<!-- Sources section -->
|
<!-- Sources section -->
|
||||||
<string name="languages">Languages</string>
|
<string name="languages">Languages</string>
|
||||||
<string name="languages_summary">Select the languages to show sources from</string>
|
<string name="languages_summary">Select the languages to show sources from</string>
|
||||||
|
|
|
@ -3,26 +3,41 @@
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:title="@string/pref_download_directory"
|
android:key="@string/pref_download_directory_key"
|
||||||
android:key="@string/pref_download_directory_key"/>
|
android:title="@string/pref_download_directory"/>
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
android:title="@string/pref_download_only_over_wifi"
|
android:defaultValue="true"
|
||||||
android:key="@string/pref_download_only_over_wifi_key"
|
android:key="@string/pref_download_only_over_wifi_key"
|
||||||
android:defaultValue="true"/>
|
android:title="@string/pref_download_only_over_wifi"/>
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
|
||||||
android:title="@string/pref_remove_after_marked_as_read"
|
|
||||||
android:key="@string/pref_remove_after_marked_as_read_key"
|
|
||||||
android:defaultValue="false"/>
|
|
||||||
|
|
||||||
|
|
||||||
<eu.kanade.tachiyomi.widget.preference.IntListPreference
|
<eu.kanade.tachiyomi.widget.preference.IntListPreference
|
||||||
android:title="@string/pref_download_slots"
|
android:defaultValue="1"
|
||||||
android:key="@string/pref_download_slots_key"
|
|
||||||
android:entries="@array/download_slots"
|
android:entries="@array/download_slots"
|
||||||
android:entryValues="@array/download_slots"
|
android:entryValues="@array/download_slots"
|
||||||
android:defaultValue="1"
|
android:key="@string/pref_download_slots_key"
|
||||||
android:summary="%s"/>
|
android:summary="%s"
|
||||||
|
android:title="@string/pref_download_slots"/>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:persistent="false"
|
||||||
|
android:title="@string/cat_remove_after_read"/>
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="@string/pref_remove_after_marked_as_read_key"
|
||||||
|
android:title="@string/pref_remove_after_marked_as_read"/>
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="@string/pref_remove_after_read_key"
|
||||||
|
android:summary="@string/current_chapter"
|
||||||
|
android:title="@string/pref_remove_after_read"/>
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:dependency="@string/pref_remove_after_read_key"
|
||||||
|
android:key="@string/pref_remove_after_read_previous_key"
|
||||||
|
android:summary="@string/previous_chapter"
|
||||||
|
android:title="@string/pref_remove_after_read"/>
|
||||||
|
|
||||||
</android.support.v7.preference.PreferenceScreen>
|
</android.support.v7.preference.PreferenceScreen>
|
Reference in a new issue