mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-24 02:21:51 +01:00
Add manga-wised rotation mode settings
Co-Authored-By: Andreas <6576096+ghostbear@users.noreply.github.com>
This commit is contained in:
parent
2ac761729d
commit
5911ad2fd4
@ -13,6 +13,7 @@ import eu.kanade.tachiyomi.data.updater.UpdaterJob
|
|||||||
import eu.kanade.tachiyomi.extension.ExtensionUpdateJob
|
import eu.kanade.tachiyomi.extension.ExtensionUpdateJob
|
||||||
import eu.kanade.tachiyomi.network.PREF_DOH_CLOUDFLARE
|
import eu.kanade.tachiyomi.network.PREF_DOH_CLOUDFLARE
|
||||||
import eu.kanade.tachiyomi.ui.library.LibraryPresenter
|
import eu.kanade.tachiyomi.ui.library.LibraryPresenter
|
||||||
|
import eu.kanade.tachiyomi.ui.reader.settings.OrientationType
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
@ -113,7 +114,12 @@ object Migrations {
|
|||||||
}
|
}
|
||||||
if (oldVersion < 73) {
|
if (oldVersion < 73) {
|
||||||
// Reset rotation to Free after replacing Lock
|
// Reset rotation to Free after replacing Lock
|
||||||
preferences.rotation().set(1)
|
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
if (prefs.contains("pref_rotation_type_key")) {
|
||||||
|
prefs.edit {
|
||||||
|
putInt("pref_rotation_type_key", 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (oldVersion < 74) {
|
if (oldVersion < 74) {
|
||||||
// Turn on auto updates for all users
|
// Turn on auto updates for all users
|
||||||
@ -141,6 +147,28 @@ object Migrations {
|
|||||||
LibraryUpdateJob.setupTask(context, 3)
|
LibraryUpdateJob.setupTask(context, 3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (oldVersion < 77) {
|
||||||
|
// Migrate Rotation and Viewer values to default values for viewer_flags
|
||||||
|
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
val newOrientation = when (prefs.getInt("pref_rotation_type_key", 1)) {
|
||||||
|
1 -> OrientationType.FREE.flagValue
|
||||||
|
2 -> OrientationType.PORTRAIT.flagValue
|
||||||
|
3 -> OrientationType.LANDSCAPE.flagValue
|
||||||
|
4 -> OrientationType.LOCKED_PORTRAIT.flagValue
|
||||||
|
5 -> OrientationType.LOCKED_LANDSCAPE.flagValue
|
||||||
|
else -> OrientationType.FREE.flagValue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reading mode flag and prefValue is the same value
|
||||||
|
val newReadingMode = prefs.getInt("pref_default_viewer_key", 1)
|
||||||
|
|
||||||
|
prefs.edit {
|
||||||
|
putInt("pref_default_orientation_type_key", newOrientation)
|
||||||
|
remove("pref_rotation_type_key")
|
||||||
|
putInt("pref_default_reading_mode_key", newReadingMode)
|
||||||
|
remove("pref_default_viewer_key")
|
||||||
|
}
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -26,7 +26,7 @@ data class BackupManga(
|
|||||||
// @ProtoNumber(11) val lastUpdate: Long = 0, 1.x value, not used in 0.x
|
// @ProtoNumber(11) val lastUpdate: Long = 0, 1.x value, not used in 0.x
|
||||||
// @ProtoNumber(12) val lastInit: Long = 0, 1.x value, not used in 0.x
|
// @ProtoNumber(12) val lastInit: Long = 0, 1.x value, not used in 0.x
|
||||||
@ProtoNumber(13) var dateAdded: Long = 0,
|
@ProtoNumber(13) var dateAdded: Long = 0,
|
||||||
@ProtoNumber(14) var viewer: Int = 0,
|
@ProtoNumber(14) var viewer: Int = 0, // Replaced by viewer_flags
|
||||||
// @ProtoNumber(15) val flags: Int = 0, 1.x value, not used in 0.x
|
// @ProtoNumber(15) val flags: Int = 0, 1.x value, not used in 0.x
|
||||||
@ProtoNumber(16) var chapters: List<BackupChapter> = emptyList(),
|
@ProtoNumber(16) var chapters: List<BackupChapter> = emptyList(),
|
||||||
@ProtoNumber(17) var categories: List<Int> = emptyList(),
|
@ProtoNumber(17) var categories: List<Int> = emptyList(),
|
||||||
@ -35,6 +35,7 @@ data class BackupManga(
|
|||||||
@ProtoNumber(100) var favorite: Boolean = true,
|
@ProtoNumber(100) var favorite: Boolean = true,
|
||||||
@ProtoNumber(101) var chapterFlags: Int = 0,
|
@ProtoNumber(101) var chapterFlags: Int = 0,
|
||||||
@ProtoNumber(102) var history: List<BackupHistory> = emptyList(),
|
@ProtoNumber(102) var history: List<BackupHistory> = emptyList(),
|
||||||
|
@ProtoNumber(103) var viewer_flags: Int? = null,
|
||||||
|
|
||||||
// SY specific values
|
// SY specific values
|
||||||
@ProtoNumber(602) var customStatus: Int = 0,
|
@ProtoNumber(602) var customStatus: Int = 0,
|
||||||
@ -60,7 +61,11 @@ data class BackupManga(
|
|||||||
favorite = this@BackupManga.favorite
|
favorite = this@BackupManga.favorite
|
||||||
source = this@BackupManga.source
|
source = this@BackupManga.source
|
||||||
date_added = this@BackupManga.dateAdded
|
date_added = this@BackupManga.dateAdded
|
||||||
viewer = this@BackupManga.viewer
|
viewer_flags = (
|
||||||
|
this@BackupManga.viewer_flags
|
||||||
|
?: this@BackupManga.viewer
|
||||||
|
).takeIf { it != 0 }
|
||||||
|
?: -1
|
||||||
chapter_flags = this@BackupManga.chapterFlags
|
chapter_flags = this@BackupManga.chapterFlags
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,7 +117,8 @@ data class BackupManga(
|
|||||||
favorite = manga.favorite,
|
favorite = manga.favorite,
|
||||||
source = manga.source,
|
source = manga.source,
|
||||||
dateAdded = manga.date_added,
|
dateAdded = manga.date_added,
|
||||||
viewer = manga.viewer,
|
viewer = manga.readingModeType,
|
||||||
|
viewer_flags = manga.viewer_flags.takeIf { it != -1 } ?: 0,
|
||||||
chapterFlags = manga.chapter_flags
|
chapterFlags = manga.chapter_flags
|
||||||
).also { backupManga ->
|
).also { backupManga ->
|
||||||
customMangaManager?.getManga(manga)?.let {
|
customMangaManager?.getManga(manga)?.let {
|
||||||
|
@ -16,7 +16,7 @@ object MangaTypeAdapter {
|
|||||||
value(it.url)
|
value(it.url)
|
||||||
value(it.title)
|
value(it.title)
|
||||||
value(it.source)
|
value(it.source)
|
||||||
value(it.viewer)
|
value(it.viewer_flags)
|
||||||
value(it.chapter_flags)
|
value(it.chapter_flags)
|
||||||
endArray()
|
endArray()
|
||||||
}
|
}
|
||||||
@ -27,7 +27,7 @@ object MangaTypeAdapter {
|
|||||||
manga.url = nextString()
|
manga.url = nextString()
|
||||||
manga.title = nextString()
|
manga.title = nextString()
|
||||||
manga.source = nextLong()
|
manga.source = nextLong()
|
||||||
manga.viewer = nextInt()
|
manga.viewer_flags = nextInt()
|
||||||
manga.chapter_flags = nextInt()
|
manga.chapter_flags = nextInt()
|
||||||
endArray()
|
endArray()
|
||||||
manga
|
manga
|
||||||
|
@ -62,7 +62,7 @@ class MangaPutResolver : DefaultPutResolver<Manga>() {
|
|||||||
put(COL_FAVORITE, obj.favorite)
|
put(COL_FAVORITE, obj.favorite)
|
||||||
put(COL_LAST_UPDATE, obj.last_update)
|
put(COL_LAST_UPDATE, obj.last_update)
|
||||||
put(COL_INITIALIZED, obj.initialized)
|
put(COL_INITIALIZED, obj.initialized)
|
||||||
put(COL_VIEWER, obj.viewer)
|
put(COL_VIEWER, obj.viewer_flags)
|
||||||
put(COL_HIDE_TITLE, obj.hide_title)
|
put(COL_HIDE_TITLE, obj.hide_title)
|
||||||
put(COL_CHAPTER_FLAGS, obj.chapter_flags)
|
put(COL_CHAPTER_FLAGS, obj.chapter_flags)
|
||||||
put(COL_DATE_ADDED, obj.date_added)
|
put(COL_DATE_ADDED, obj.date_added)
|
||||||
@ -84,7 +84,7 @@ interface BaseMangaGetResolver {
|
|||||||
favorite = cursor.getInt(cursor.getColumnIndex(COL_FAVORITE)) == 1
|
favorite = cursor.getInt(cursor.getColumnIndex(COL_FAVORITE)) == 1
|
||||||
last_update = cursor.getLong(cursor.getColumnIndex(COL_LAST_UPDATE))
|
last_update = cursor.getLong(cursor.getColumnIndex(COL_LAST_UPDATE))
|
||||||
initialized = cursor.getInt(cursor.getColumnIndex(COL_INITIALIZED)) == 1
|
initialized = cursor.getInt(cursor.getColumnIndex(COL_INITIALIZED)) == 1
|
||||||
viewer = cursor.getInt(cursor.getColumnIndex(COL_VIEWER))
|
viewer_flags = cursor.getInt(cursor.getColumnIndex(COL_VIEWER))
|
||||||
chapter_flags = cursor.getInt(cursor.getColumnIndex(COL_CHAPTER_FLAGS))
|
chapter_flags = cursor.getInt(cursor.getColumnIndex(COL_CHAPTER_FLAGS))
|
||||||
hide_title = cursor.getInt(cursor.getColumnIndex(COL_HIDE_TITLE)) == 1
|
hide_title = cursor.getInt(cursor.getColumnIndex(COL_HIDE_TITLE)) == 1
|
||||||
date_added = cursor.getLong(cursor.getColumnIndex(COL_DATE_ADDED))
|
date_added = cursor.getLong(cursor.getColumnIndex(COL_DATE_ADDED))
|
||||||
|
@ -4,7 +4,8 @@ import android.content.Context
|
|||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
import eu.kanade.tachiyomi.ui.reader.settings.OrientationType
|
||||||
|
import eu.kanade.tachiyomi.ui.reader.settings.ReadingModeType
|
||||||
import tachiyomi.source.model.MangaInfo
|
import tachiyomi.source.model.MangaInfo
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
@ -22,7 +23,7 @@ interface Manga : SManga {
|
|||||||
|
|
||||||
var date_added: Long
|
var date_added: Long
|
||||||
|
|
||||||
var viewer: Int
|
var viewer_flags: Int
|
||||||
|
|
||||||
var chapter_flags: Int
|
var chapter_flags: Int
|
||||||
|
|
||||||
@ -32,26 +33,30 @@ interface Manga : SManga {
|
|||||||
fun isHidden() = status == -1
|
fun isHidden() = status == -1
|
||||||
|
|
||||||
fun setChapterOrder(order: Int) {
|
fun setChapterOrder(order: Int) {
|
||||||
setFlags(order, SORT_MASK)
|
setChapterFlags(order, CHAPTER_SORT_MASK)
|
||||||
setFlags(SORT_LOCAL, SORT_SELF_MASK)
|
setChapterFlags(CHAPTER_SORT_LOCAL, CHAPTER_SORT_SELF_MASK)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setSortToGlobal() = setFlags(SORT_GLOBAL, SORT_SELF_MASK)
|
fun setSortToGlobal() = setChapterFlags(CHAPTER_SORT_GLOBAL, CHAPTER_SORT_SELF_MASK)
|
||||||
|
|
||||||
private fun setFlags(flag: Int, mask: Int) {
|
private fun setChapterFlags(flag: Int, mask: Int) {
|
||||||
chapter_flags = chapter_flags and mask.inv() or (flag and mask)
|
chapter_flags = chapter_flags and mask.inv() or (flag and mask)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sortDescending(): Boolean = chapter_flags and SORT_MASK == SORT_DESC
|
private fun setViewerFlags(flag: Int, mask: Int) {
|
||||||
|
viewer_flags = viewer_flags and mask.inv() or (flag and mask)
|
||||||
|
}
|
||||||
|
|
||||||
fun usesLocalSort(): Boolean = chapter_flags and SORT_SELF_MASK == SORT_LOCAL
|
fun sortDescending(): Boolean = chapter_flags and CHAPTER_SORT_MASK == CHAPTER_SORT_DESC
|
||||||
|
|
||||||
|
fun usesLocalSort(): Boolean = chapter_flags and CHAPTER_SORT_SELF_MASK == CHAPTER_SORT_LOCAL
|
||||||
|
|
||||||
fun sortDescending(defaultDesc: Boolean): Boolean {
|
fun sortDescending(defaultDesc: Boolean): Boolean {
|
||||||
return if (chapter_flags and SORT_SELF_MASK == SORT_GLOBAL) defaultDesc
|
return if (chapter_flags and CHAPTER_SORT_SELF_MASK == CHAPTER_SORT_GLOBAL) defaultDesc
|
||||||
else sortDescending()
|
else sortDescending()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showChapterTitle(defaultShow: Boolean): Boolean = chapter_flags and DISPLAY_MASK == DISPLAY_NUMBER
|
fun showChapterTitle(defaultShow: Boolean): Boolean = chapter_flags and CHAPTER_DISPLAY_MASK == CHAPTER_DISPLAY_NUMBER
|
||||||
|
|
||||||
fun seriesType(context: Context, sourceManager: SourceManager? = null): String {
|
fun seriesType(context: Context, sourceManager: SourceManager? = null): String {
|
||||||
return context.getString(
|
return context.getString(
|
||||||
@ -125,7 +130,7 @@ interface Manga : SManga {
|
|||||||
currentTags.none { tag -> isComicTag(tag) }
|
currentTags.none { tag -> isComicTag(tag) }
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
ReaderActivity.WEBTOON
|
ReadingModeType.WEBTOON.flagValue
|
||||||
} else if (currentTags.any
|
} else if (currentTags.any
|
||||||
{ tag ->
|
{ tag ->
|
||||||
tag == "chinese" || tag == "manhua" ||
|
tag == "chinese" || tag == "manhua" ||
|
||||||
@ -136,7 +141,7 @@ interface Manga : SManga {
|
|||||||
) ||
|
) ||
|
||||||
(sourceName.contains("manhua", true) && currentTags.none { tag -> isMangaTag(tag) })
|
(sourceName.contains("manhua", true) && currentTags.none { tag -> isMangaTag(tag) })
|
||||||
) {
|
) {
|
||||||
ReaderActivity.LEFT_TO_RIGHT
|
ReadingModeType.LEFT_TO_RIGHT.flagValue
|
||||||
} else 0
|
} else 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,57 +199,65 @@ interface Manga : SManga {
|
|||||||
|
|
||||||
// Used to display the chapter's title one way or another
|
// Used to display the chapter's title one way or another
|
||||||
var displayMode: Int
|
var displayMode: Int
|
||||||
get() = chapter_flags and DISPLAY_MASK
|
get() = chapter_flags and CHAPTER_DISPLAY_MASK
|
||||||
set(mode) = setFlags(mode, DISPLAY_MASK)
|
set(mode) = setChapterFlags(mode, CHAPTER_DISPLAY_MASK)
|
||||||
|
|
||||||
var readFilter: Int
|
var readFilter: Int
|
||||||
get() = chapter_flags and READ_MASK
|
get() = chapter_flags and CHAPTER_READ_MASK
|
||||||
set(filter) = setFlags(filter, READ_MASK)
|
set(filter) = setChapterFlags(filter, CHAPTER_READ_MASK)
|
||||||
|
|
||||||
var downloadedFilter: Int
|
var downloadedFilter: Int
|
||||||
get() = chapter_flags and DOWNLOADED_MASK
|
get() = chapter_flags and CHAPTER_DOWNLOADED_MASK
|
||||||
set(filter) = setFlags(filter, DOWNLOADED_MASK)
|
set(filter) = setChapterFlags(filter, CHAPTER_DOWNLOADED_MASK)
|
||||||
|
|
||||||
var bookmarkedFilter: Int
|
var bookmarkedFilter: Int
|
||||||
get() = chapter_flags and BOOKMARKED_MASK
|
get() = chapter_flags and CHAPTER_BOOKMARKED_MASK
|
||||||
set(filter) = setFlags(filter, BOOKMARKED_MASK)
|
set(filter) = setChapterFlags(filter, CHAPTER_BOOKMARKED_MASK)
|
||||||
|
|
||||||
var sorting: Int
|
var sorting: Int
|
||||||
get() = chapter_flags and SORTING_MASK
|
get() = chapter_flags and CHAPTER_SORTING_MASK
|
||||||
set(sort) = setFlags(sort, SORTING_MASK)
|
set(sort) = setChapterFlags(sort, CHAPTER_SORTING_MASK)
|
||||||
|
|
||||||
|
var readingModeType: Int
|
||||||
|
get() = viewer_flags and ReadingModeType.MASK
|
||||||
|
set(readingMode) = setViewerFlags(readingMode, ReadingModeType.MASK)
|
||||||
|
|
||||||
|
var orientationType: Int
|
||||||
|
get() = viewer_flags and OrientationType.MASK
|
||||||
|
set(rotationType) = setViewerFlags(rotationType, OrientationType.MASK)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
const val SORT_DESC = 0x00000000
|
const val CHAPTER_SORT_DESC = 0x00000000
|
||||||
const val SORT_ASC = 0x00000001
|
const val CHAPTER_SORT_ASC = 0x00000001
|
||||||
const val SORT_MASK = 0x00000001
|
const val CHAPTER_SORT_MASK = 0x00000001
|
||||||
|
|
||||||
const val SORT_GLOBAL = 0x00000000
|
const val CHAPTER_SORT_GLOBAL = 0x00000000
|
||||||
const val SORT_LOCAL = 0x00001000
|
const val CHAPTER_SORT_LOCAL = 0x00001000
|
||||||
const val SORT_SELF_MASK = 0x00001000
|
const val CHAPTER_SORT_SELF_MASK = 0x00001000
|
||||||
|
|
||||||
// Generic filter that does not filter anything
|
// Generic filter that does not filter anything
|
||||||
const val SHOW_ALL = 0x00000000
|
const val SHOW_ALL = 0x00000000
|
||||||
|
|
||||||
const val SHOW_UNREAD = 0x00000002
|
const val CHAPTER_SHOW_UNREAD = 0x00000002
|
||||||
const val SHOW_READ = 0x00000004
|
const val CHAPTER_SHOW_READ = 0x00000004
|
||||||
const val READ_MASK = 0x00000006
|
const val CHAPTER_READ_MASK = 0x00000006
|
||||||
|
|
||||||
const val SHOW_DOWNLOADED = 0x00000008
|
const val CHAPTER_SHOW_DOWNLOADED = 0x00000008
|
||||||
const val SHOW_NOT_DOWNLOADED = 0x00000010
|
const val CHAPTER_SHOW_NOT_DOWNLOADED = 0x00000010
|
||||||
const val DOWNLOADED_MASK = 0x00000018
|
const val CHAPTER_DOWNLOADED_MASK = 0x00000018
|
||||||
|
|
||||||
const val SHOW_BOOKMARKED = 0x00000020
|
const val CHAPTER_SHOW_BOOKMARKED = 0x00000020
|
||||||
const val SHOW_NOT_BOOKMARKED = 0x00000040
|
const val CHAPTER_SHOW_NOT_BOOKMARKED = 0x00000040
|
||||||
const val BOOKMARKED_MASK = 0x00000060
|
const val CHAPTER_BOOKMARKED_MASK = 0x00000060
|
||||||
|
|
||||||
const val SORTING_SOURCE = 0x00000000
|
const val CHAPTER_SORTING_SOURCE = 0x00000000
|
||||||
const val SORTING_NUMBER = 0x00000100
|
const val CHAPTER_SORTING_NUMBER = 0x00000100
|
||||||
const val SORTING_MASK = 0x00000100
|
const val CHAPTER_SORTING_MASK = 0x00000100
|
||||||
|
|
||||||
const val DISPLAY_NAME = 0x00000000
|
const val CHAPTER_DISPLAY_NAME = 0x00000000
|
||||||
const val DISPLAY_NUMBER = 0x00100000
|
const val CHAPTER_DISPLAY_NUMBER = 0x00100000
|
||||||
const val DISPLAY_MASK = 0x00100000
|
const val CHAPTER_DISPLAY_MASK = 0x00100000
|
||||||
|
|
||||||
const val TYPE_MANGA = 1
|
const val TYPE_MANGA = 1
|
||||||
const val TYPE_MANHWA = 2
|
const val TYPE_MANHWA = 2
|
||||||
|
@ -56,7 +56,7 @@ open class MangaImpl : Manga {
|
|||||||
|
|
||||||
override var initialized: Boolean = false
|
override var initialized: Boolean = false
|
||||||
|
|
||||||
override var viewer: Int = -1
|
override var viewer_flags: Int = -1
|
||||||
|
|
||||||
override var chapter_flags: Int = 0
|
override var chapter_flags: Int = 0
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ import eu.kanade.tachiyomi.data.database.resolvers.MangaFlagsPutResolver
|
|||||||
import eu.kanade.tachiyomi.data.database.resolvers.MangaInfoPutResolver
|
import eu.kanade.tachiyomi.data.database.resolvers.MangaInfoPutResolver
|
||||||
import eu.kanade.tachiyomi.data.database.resolvers.MangaLastUpdatedPutResolver
|
import eu.kanade.tachiyomi.data.database.resolvers.MangaLastUpdatedPutResolver
|
||||||
import eu.kanade.tachiyomi.data.database.resolvers.MangaTitlePutResolver
|
import eu.kanade.tachiyomi.data.database.resolvers.MangaTitlePutResolver
|
||||||
import eu.kanade.tachiyomi.data.database.resolvers.MangaViewerPutResolver
|
|
||||||
import eu.kanade.tachiyomi.data.database.tables.CategoryTable
|
import eu.kanade.tachiyomi.data.database.tables.CategoryTable
|
||||||
import eu.kanade.tachiyomi.data.database.tables.ChapterTable
|
import eu.kanade.tachiyomi.data.database.tables.ChapterTable
|
||||||
import eu.kanade.tachiyomi.data.database.tables.MangaCategoryTable
|
import eu.kanade.tachiyomi.data.database.tables.MangaCategoryTable
|
||||||
@ -79,9 +78,24 @@ interface MangaQueries : DbProvider {
|
|||||||
|
|
||||||
fun insertMangas(mangas: List<Manga>) = db.put().objects(mangas).prepare()
|
fun insertMangas(mangas: List<Manga>) = db.put().objects(mangas).prepare()
|
||||||
|
|
||||||
fun updateFlags(manga: Manga) = db.put()
|
fun updateChapterFlags(manga: Manga) = db.put()
|
||||||
.`object`(manga)
|
.`object`(manga)
|
||||||
.withPutResolver(MangaFlagsPutResolver())
|
.withPutResolver(MangaFlagsPutResolver(MangaTable.COL_CHAPTER_FLAGS, Manga::chapter_flags))
|
||||||
|
.prepare()
|
||||||
|
|
||||||
|
fun updateChapterFlags(manga: List<Manga>) = db.put()
|
||||||
|
.objects(manga)
|
||||||
|
.withPutResolver(MangaFlagsPutResolver(MangaTable.COL_CHAPTER_FLAGS, Manga::chapter_flags, true))
|
||||||
|
.prepare()
|
||||||
|
|
||||||
|
fun updateViewerFlags(manga: Manga) = db.put()
|
||||||
|
.`object`(manga)
|
||||||
|
.withPutResolver(MangaFlagsPutResolver(MangaTable.COL_VIEWER, Manga::viewer_flags))
|
||||||
|
.prepare()
|
||||||
|
|
||||||
|
fun updateViewerFlags(manga: List<Manga>) = db.put()
|
||||||
|
.objects(manga)
|
||||||
|
.withPutResolver(MangaFlagsPutResolver(MangaTable.COL_VIEWER, Manga::viewer_flags, true))
|
||||||
.prepare()
|
.prepare()
|
||||||
|
|
||||||
fun updateLastUpdated(manga: Manga) = db.put()
|
fun updateLastUpdated(manga: Manga) = db.put()
|
||||||
@ -99,11 +113,6 @@ interface MangaQueries : DbProvider {
|
|||||||
.withPutResolver(MangaDateAddedPutResolver())
|
.withPutResolver(MangaDateAddedPutResolver())
|
||||||
.prepare()
|
.prepare()
|
||||||
|
|
||||||
fun updateMangaViewer(manga: Manga) = db.put()
|
|
||||||
.`object`(manga)
|
|
||||||
.withPutResolver(MangaViewerPutResolver())
|
|
||||||
.prepare()
|
|
||||||
|
|
||||||
fun updateMangaTitle(manga: Manga) = db.put()
|
fun updateMangaTitle(manga: Manga) = db.put()
|
||||||
.`object`(manga)
|
.`object`(manga)
|
||||||
.withPutResolver(MangaTitlePutResolver())
|
.withPutResolver(MangaTitlePutResolver())
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package eu.kanade.tachiyomi.data.database.resolvers
|
package eu.kanade.tachiyomi.data.database.resolvers
|
||||||
|
|
||||||
import android.content.ContentValues
|
import androidx.core.content.contentValuesOf
|
||||||
import com.pushtorefresh.storio.sqlite.StorIOSQLite
|
import com.pushtorefresh.storio.sqlite.StorIOSQLite
|
||||||
import com.pushtorefresh.storio.sqlite.operations.put.PutResolver
|
import com.pushtorefresh.storio.sqlite.operations.put.PutResolver
|
||||||
import com.pushtorefresh.storio.sqlite.operations.put.PutResult
|
import com.pushtorefresh.storio.sqlite.operations.put.PutResult
|
||||||
@ -8,8 +8,9 @@ import com.pushtorefresh.storio.sqlite.queries.UpdateQuery
|
|||||||
import eu.kanade.tachiyomi.data.database.inTransactionReturn
|
import eu.kanade.tachiyomi.data.database.inTransactionReturn
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.tables.MangaTable
|
import eu.kanade.tachiyomi.data.database.tables.MangaTable
|
||||||
|
import kotlin.reflect.KProperty1
|
||||||
|
|
||||||
class MangaFlagsPutResolver : PutResolver<Manga>() {
|
class MangaFlagsPutResolver(private val colName: String, private val fieldGetter: KProperty1<Manga, Int>, private val updateAll: Boolean = false) : PutResolver<Manga>() {
|
||||||
|
|
||||||
override fun performPut(db: StorIOSQLite, manga: Manga) = db.inTransactionReturn {
|
override fun performPut(db: StorIOSQLite, manga: Manga) = db.inTransactionReturn {
|
||||||
val updateQuery = mapToUpdateQuery(manga)
|
val updateQuery = mapToUpdateQuery(manga)
|
||||||
@ -19,13 +20,24 @@ class MangaFlagsPutResolver : PutResolver<Manga>() {
|
|||||||
PutResult.newUpdateResult(numberOfRowsUpdated, updateQuery.table())
|
PutResult.newUpdateResult(numberOfRowsUpdated, updateQuery.table())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun mapToUpdateQuery(manga: Manga) = UpdateQuery.builder()
|
fun mapToUpdateQuery(manga: Manga): UpdateQuery {
|
||||||
|
val builder = UpdateQuery.builder()
|
||||||
|
|
||||||
|
return if (updateAll) {
|
||||||
|
builder
|
||||||
|
.table(MangaTable.TABLE)
|
||||||
|
.build()
|
||||||
|
} else {
|
||||||
|
builder
|
||||||
.table(MangaTable.TABLE)
|
.table(MangaTable.TABLE)
|
||||||
.where("${MangaTable.COL_ID} = ?")
|
.where("${MangaTable.COL_ID} = ?")
|
||||||
.whereArgs(manga.id)
|
.whereArgs(manga.id)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
fun mapToContentValues(manga: Manga) = ContentValues(1).apply {
|
|
||||||
put(MangaTable.COL_CHAPTER_FLAGS, manga.chapter_flags)
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun mapToContentValues(manga: Manga) =
|
||||||
|
contentValuesOf(
|
||||||
|
colName to fieldGetter.get(manga)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
package eu.kanade.tachiyomi.data.database.resolvers
|
|
||||||
|
|
||||||
import android.content.ContentValues
|
|
||||||
import com.pushtorefresh.storio.sqlite.StorIOSQLite
|
|
||||||
import com.pushtorefresh.storio.sqlite.operations.put.PutResolver
|
|
||||||
import com.pushtorefresh.storio.sqlite.operations.put.PutResult
|
|
||||||
import com.pushtorefresh.storio.sqlite.queries.UpdateQuery
|
|
||||||
import eu.kanade.tachiyomi.data.database.inTransactionReturn
|
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
|
||||||
import eu.kanade.tachiyomi.data.database.tables.MangaTable
|
|
||||||
|
|
||||||
class MangaViewerPutResolver : PutResolver<Manga>() {
|
|
||||||
|
|
||||||
override fun performPut(db: StorIOSQLite, manga: Manga) = db.inTransactionReturn {
|
|
||||||
val updateQuery = mapToUpdateQuery(manga)
|
|
||||||
val contentValues = mapToContentValues(manga)
|
|
||||||
|
|
||||||
val numberOfRowsUpdated = db.lowLevel().update(updateQuery, contentValues)
|
|
||||||
PutResult.newUpdateResult(numberOfRowsUpdated, updateQuery.table())
|
|
||||||
}
|
|
||||||
|
|
||||||
fun mapToUpdateQuery(manga: Manga) = UpdateQuery.builder()
|
|
||||||
.table(MangaTable.TABLE)
|
|
||||||
.where("${MangaTable.COL_ID} = ?")
|
|
||||||
.whereArgs(manga.id)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
fun mapToContentValues(manga: Manga) = ContentValues(1).apply {
|
|
||||||
put(MangaTable.COL_VIEWER, manga.viewer)
|
|
||||||
}
|
|
||||||
}
|
|
@ -18,8 +18,6 @@ object PreferenceKeys {
|
|||||||
|
|
||||||
const val deniedA11FilePermission = "denied_a11_file_permission"
|
const val deniedA11FilePermission = "denied_a11_file_permission"
|
||||||
|
|
||||||
const val rotation = "pref_rotation_type_key"
|
|
||||||
|
|
||||||
const val enableTransitions = "pref_enable_transitions_key"
|
const val enableTransitions = "pref_enable_transitions_key"
|
||||||
|
|
||||||
const val pagerCutoutBehavior = "pager_cutout_behavior"
|
const val pagerCutoutBehavior = "pager_cutout_behavior"
|
||||||
@ -44,7 +42,9 @@ object PreferenceKeys {
|
|||||||
|
|
||||||
const val colorFilterMode = "color_filter_mode"
|
const val colorFilterMode = "color_filter_mode"
|
||||||
|
|
||||||
const val defaultViewer = "pref_default_viewer_key"
|
const val defaultReadingMode = "pref_default_reading_mode_key"
|
||||||
|
|
||||||
|
const val defaultOrientationType = "pref_default_orientation_type_key"
|
||||||
|
|
||||||
const val imageScaleType = "pref_image_scale_type_key"
|
const val imageScaleType = "pref_image_scale_type_key"
|
||||||
|
|
||||||
@ -229,6 +229,18 @@ object PreferenceKeys {
|
|||||||
|
|
||||||
const val incognitoMode = "incognito_mode"
|
const val incognitoMode = "incognito_mode"
|
||||||
|
|
||||||
|
const val defaultChapterFilterByRead = "default_chapter_filter_by_read"
|
||||||
|
|
||||||
|
const val defaultChapterFilterByDownloaded = "default_chapter_filter_by_downloaded"
|
||||||
|
|
||||||
|
const val defaultChapterFilterByBookmarked = "default_chapter_filter_by_bookmarked"
|
||||||
|
|
||||||
|
const val defaultChapterSortBySourceOrNumber = "default_chapter_sort_by_source_or_number" // and upload date
|
||||||
|
|
||||||
|
const val defaultChapterSortByAscendingOrDescending = "default_chapter_sort_by_ascending_or_descending"
|
||||||
|
|
||||||
|
const val defaultChapterDisplayByNameOrNumber = "default_chapter_display_by_name_or_number"
|
||||||
|
|
||||||
fun trackUsername(syncId: Int) = "pref_mangasync_username_$syncId"
|
fun trackUsername(syncId: Int) = "pref_mangasync_username_$syncId"
|
||||||
|
|
||||||
fun trackPassword(syncId: Int) = "pref_mangasync_password_$syncId"
|
fun trackPassword(syncId: Int) = "pref_mangasync_password_$syncId"
|
||||||
|
@ -5,15 +5,19 @@ import android.content.SharedPreferences
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
|
import androidx.core.content.edit
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import com.f2prateek.rx.preferences.Preference
|
import com.f2prateek.rx.preferences.Preference
|
||||||
import com.f2prateek.rx.preferences.RxSharedPreferences
|
import com.f2prateek.rx.preferences.RxSharedPreferences
|
||||||
import com.tfcporciuncula.flow.FlowSharedPreferences
|
import com.tfcporciuncula.flow.FlowSharedPreferences
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.track.TrackService
|
import eu.kanade.tachiyomi.data.track.TrackService
|
||||||
import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet
|
import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet
|
||||||
|
import eu.kanade.tachiyomi.ui.reader.settings.OrientationType
|
||||||
import eu.kanade.tachiyomi.ui.reader.settings.PageLayout
|
import eu.kanade.tachiyomi.ui.reader.settings.PageLayout
|
||||||
import eu.kanade.tachiyomi.ui.reader.settings.ReaderBottomButton
|
import eu.kanade.tachiyomi.ui.reader.settings.ReaderBottomButton
|
||||||
|
import eu.kanade.tachiyomi.ui.reader.settings.ReadingModeType
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||||
import eu.kanade.tachiyomi.ui.recents.RecentMangaAdapter
|
import eu.kanade.tachiyomi.ui.recents.RecentMangaAdapter
|
||||||
import eu.kanade.tachiyomi.util.system.Themes
|
import eu.kanade.tachiyomi.util.system.Themes
|
||||||
@ -119,8 +123,6 @@ class PreferencesHelper(val context: Context) {
|
|||||||
fun lightTheme() = flowPrefs.getEnum(Keys.lightTheme, Themes.PURE_WHITE)
|
fun lightTheme() = flowPrefs.getEnum(Keys.lightTheme, Themes.PURE_WHITE)
|
||||||
fun darkTheme() = flowPrefs.getEnum(Keys.darkTheme, Themes.DARK)
|
fun darkTheme() = flowPrefs.getEnum(Keys.darkTheme, Themes.DARK)
|
||||||
|
|
||||||
fun rotation() = flowPrefs.getInt(Keys.rotation, 1)
|
|
||||||
|
|
||||||
fun pageTransitions() = flowPrefs.getBoolean(Keys.enableTransitions, true)
|
fun pageTransitions() = flowPrefs.getBoolean(Keys.enableTransitions, true)
|
||||||
|
|
||||||
fun pagerCutoutBehavior() = flowPrefs.getInt(Keys.pagerCutoutBehavior, 0)
|
fun pagerCutoutBehavior() = flowPrefs.getInt(Keys.pagerCutoutBehavior, 0)
|
||||||
@ -145,7 +147,9 @@ class PreferencesHelper(val context: Context) {
|
|||||||
|
|
||||||
fun colorFilterMode() = flowPrefs.getInt(Keys.colorFilterMode, 0)
|
fun colorFilterMode() = flowPrefs.getInt(Keys.colorFilterMode, 0)
|
||||||
|
|
||||||
fun defaultViewer() = prefs.getInt(Keys.defaultViewer, 2)
|
fun defaultReadingMode() = prefs.getInt(Keys.defaultReadingMode, ReadingModeType.RIGHT_TO_LEFT.flagValue)
|
||||||
|
|
||||||
|
fun defaultOrientationType() = flowPrefs.getInt(Keys.defaultOrientationType, OrientationType.FREE.flagValue)
|
||||||
|
|
||||||
fun imageScaleType() = flowPrefs.getInt(Keys.imageScaleType, 1)
|
fun imageScaleType() = flowPrefs.getInt(Keys.imageScaleType, 1)
|
||||||
|
|
||||||
@ -421,4 +425,27 @@ class PreferencesHelper(val context: Context) {
|
|||||||
fun openChapterInShortcuts() = prefs.getBoolean(Keys.openChapterInShortcuts, true)
|
fun openChapterInShortcuts() = prefs.getBoolean(Keys.openChapterInShortcuts, true)
|
||||||
|
|
||||||
fun incognitoMode() = flowPrefs.getBoolean(Keys.incognitoMode, false)
|
fun incognitoMode() = flowPrefs.getBoolean(Keys.incognitoMode, false)
|
||||||
|
|
||||||
|
fun filterChapterByRead() = prefs.getInt(Keys.defaultChapterFilterByRead, Manga.SHOW_ALL)
|
||||||
|
|
||||||
|
fun filterChapterByDownloaded() = prefs.getInt(Keys.defaultChapterFilterByDownloaded, Manga.SHOW_ALL)
|
||||||
|
|
||||||
|
fun filterChapterByBookmarked() = prefs.getInt(Keys.defaultChapterFilterByBookmarked, Manga.SHOW_ALL)
|
||||||
|
|
||||||
|
fun sortChapterBySourceOrNumber() = prefs.getInt(Keys.defaultChapterSortBySourceOrNumber, Manga.CHAPTER_SORTING_SOURCE)
|
||||||
|
|
||||||
|
fun displayChapterByNameOrNumber() = prefs.getInt(Keys.defaultChapterDisplayByNameOrNumber, Manga.CHAPTER_DISPLAY_NAME)
|
||||||
|
|
||||||
|
fun sortChapterByAscendingOrDescending() = prefs.getInt(Keys.defaultChapterSortByAscendingOrDescending, Manga.CHAPTER_SORT_DESC)
|
||||||
|
|
||||||
|
fun setChapterSettingsDefault(manga: Manga) {
|
||||||
|
prefs.edit {
|
||||||
|
putInt(Keys.defaultChapterFilterByRead, manga.readFilter)
|
||||||
|
putInt(Keys.defaultChapterFilterByDownloaded, manga.downloadedFilter)
|
||||||
|
putInt(Keys.defaultChapterFilterByBookmarked, manga.bookmarkedFilter)
|
||||||
|
putInt(Keys.defaultChapterSortBySourceOrNumber, manga.sorting)
|
||||||
|
putInt(Keys.defaultChapterDisplayByNameOrNumber, manga.displayMode)
|
||||||
|
putInt(Keys.defaultChapterSortByAscendingOrDescending, if (manga.sortDescending()) Manga.CHAPTER_SORT_DESC else Manga.CHAPTER_SORT_ASC)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,6 @@ import eu.kanade.tachiyomi.util.storage.DiskUtil
|
|||||||
import eu.kanade.tachiyomi.util.system.ImageUtil
|
import eu.kanade.tachiyomi.util.system.ImageUtil
|
||||||
import eu.kanade.tachiyomi.util.manga.MangaShortcutManager
|
import eu.kanade.tachiyomi.util.manga.MangaShortcutManager
|
||||||
import eu.kanade.tachiyomi.util.system.executeOnIO
|
import eu.kanade.tachiyomi.util.system.executeOnIO
|
||||||
import eu.kanade.tachiyomi.util.system.isTablet
|
|
||||||
import eu.kanade.tachiyomi.util.system.launchIO
|
import eu.kanade.tachiyomi.util.system.launchIO
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@ -213,8 +212,8 @@ class MangaDetailsPresenter(
|
|||||||
* @param hide set title to hidden
|
* @param hide set title to hidden
|
||||||
*/
|
*/
|
||||||
fun hideTitle(hide: Boolean) {
|
fun hideTitle(hide: Boolean) {
|
||||||
manga.displayMode = if (hide) Manga.DISPLAY_NUMBER else Manga.DISPLAY_NAME
|
manga.displayMode = if (hide) Manga.CHAPTER_DISPLAY_NUMBER else Manga.CHAPTER_DISPLAY_NAME
|
||||||
db.updateFlags(manga).executeAsBlocking()
|
db.updateChapterFlags(manga).executeAsBlocking()
|
||||||
controller.refreshAdapter()
|
controller.refreshAdapter()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,11 +235,11 @@ class MangaDetailsPresenter(
|
|||||||
val chapters = chapterFilter.filterChapters(chapterList, manga)
|
val chapters = chapterFilter.filterChapters(chapterList, manga)
|
||||||
|
|
||||||
val sortFunction: (Chapter, Chapter) -> Int = when (manga.sorting) {
|
val sortFunction: (Chapter, Chapter) -> Int = when (manga.sorting) {
|
||||||
Manga.SORTING_SOURCE -> when (sortDescending()) {
|
Manga.CHAPTER_SORTING_SOURCE -> when (sortDescending()) {
|
||||||
true -> { c1, c2 -> c1.source_order.compareTo(c2.source_order) }
|
true -> { c1, c2 -> c1.source_order.compareTo(c2.source_order) }
|
||||||
false -> { c1, c2 -> c2.source_order.compareTo(c1.source_order) }
|
false -> { c1, c2 -> c2.source_order.compareTo(c1.source_order) }
|
||||||
}
|
}
|
||||||
Manga.SORTING_NUMBER -> when (sortDescending()) {
|
Manga.CHAPTER_SORTING_NUMBER -> when (sortDescending()) {
|
||||||
true -> { c1, c2 -> c2.chapter_number.compareTo(c1.chapter_number) }
|
true -> { c1, c2 -> c2.chapter_number.compareTo(c1.chapter_number) }
|
||||||
false -> { c1, c2 -> c1.chapter_number.compareTo(c2.chapter_number) }
|
false -> { c1, c2 -> c1.chapter_number.compareTo(c2.chapter_number) }
|
||||||
}
|
}
|
||||||
@ -509,7 +508,7 @@ class MangaDetailsPresenter(
|
|||||||
* Sets the sorting order and requests an UI update.
|
* Sets the sorting order and requests an UI update.
|
||||||
*/
|
*/
|
||||||
fun setSortOrder(descend: Boolean) {
|
fun setSortOrder(descend: Boolean) {
|
||||||
manga.setChapterOrder(if (descend) Manga.SORT_DESC else Manga.SORT_ASC)
|
manga.setChapterOrder(if (descend) Manga.CHAPTER_SORT_DESC else Manga.CHAPTER_SORT_ASC)
|
||||||
asyncUpdateMangaAndChapters()
|
asyncUpdateMangaAndChapters()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,7 +524,7 @@ class MangaDetailsPresenter(
|
|||||||
* Sets the sorting method and requests an UI update.
|
* Sets the sorting method and requests an UI update.
|
||||||
*/
|
*/
|
||||||
fun setSortMethod(bySource: Boolean) {
|
fun setSortMethod(bySource: Boolean) {
|
||||||
manga.sorting = if (bySource) Manga.SORTING_SOURCE else Manga.SORTING_NUMBER
|
manga.sorting = if (bySource) Manga.CHAPTER_SORTING_SOURCE else Manga.CHAPTER_SORTING_NUMBER
|
||||||
asyncUpdateMangaAndChapters()
|
asyncUpdateMangaAndChapters()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -534,18 +533,18 @@ class MangaDetailsPresenter(
|
|||||||
*/
|
*/
|
||||||
fun setFilters(read: Boolean, unread: Boolean, downloaded: Boolean, bookmarked: Boolean) {
|
fun setFilters(read: Boolean, unread: Boolean, downloaded: Boolean, bookmarked: Boolean) {
|
||||||
manga.readFilter = when {
|
manga.readFilter = when {
|
||||||
read -> Manga.SHOW_READ
|
read -> Manga.CHAPTER_SHOW_READ
|
||||||
unread -> Manga.SHOW_UNREAD
|
unread -> Manga.CHAPTER_SHOW_UNREAD
|
||||||
else -> Manga.SHOW_ALL
|
else -> Manga.SHOW_ALL
|
||||||
}
|
}
|
||||||
manga.downloadedFilter = if (downloaded) Manga.SHOW_DOWNLOADED else Manga.SHOW_ALL
|
manga.downloadedFilter = if (downloaded) Manga.CHAPTER_SHOW_DOWNLOADED else Manga.SHOW_ALL
|
||||||
manga.bookmarkedFilter = if (bookmarked) Manga.SHOW_BOOKMARKED else Manga.SHOW_ALL
|
manga.bookmarkedFilter = if (bookmarked) Manga.CHAPTER_SHOW_BOOKMARKED else Manga.SHOW_ALL
|
||||||
asyncUpdateMangaAndChapters()
|
asyncUpdateMangaAndChapters()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun asyncUpdateMangaAndChapters(justChapters: Boolean = false) {
|
private fun asyncUpdateMangaAndChapters(justChapters: Boolean = false) {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
if (!justChapters) db.updateFlags(manga).executeOnIO()
|
if (!justChapters) db.updateChapterFlags(manga).executeOnIO()
|
||||||
getChapters()
|
getChapters()
|
||||||
withContext(Dispatchers.Main) { controller.updateChapters(chapters) }
|
withContext(Dispatchers.Main) { controller.updateChapters(chapters) }
|
||||||
}
|
}
|
||||||
@ -553,10 +552,10 @@ class MangaDetailsPresenter(
|
|||||||
|
|
||||||
fun currentFilters(): String {
|
fun currentFilters(): String {
|
||||||
val filtersId = mutableListOf<Int?>()
|
val filtersId = mutableListOf<Int?>()
|
||||||
filtersId.add(if (manga.readFilter == Manga.SHOW_READ) R.string.read else null)
|
filtersId.add(if (manga.readFilter == Manga.CHAPTER_SHOW_READ) R.string.read else null)
|
||||||
filtersId.add(if (manga.readFilter == Manga.SHOW_UNREAD) R.string.unread else null)
|
filtersId.add(if (manga.readFilter == Manga.CHAPTER_SHOW_UNREAD) R.string.unread else null)
|
||||||
filtersId.add(if (manga.downloadedFilter == Manga.SHOW_DOWNLOADED) R.string.downloaded else null)
|
filtersId.add(if (manga.downloadedFilter == Manga.CHAPTER_SHOW_DOWNLOADED) R.string.downloaded else null)
|
||||||
filtersId.add(if (manga.bookmarkedFilter == Manga.SHOW_BOOKMARKED) R.string.bookmarked else null)
|
filtersId.add(if (manga.bookmarkedFilter == Manga.CHAPTER_SHOW_BOOKMARKED) R.string.bookmarked else null)
|
||||||
return filtersId.filterNotNull().joinToString(", ") { preferences.context.getString(it) }
|
return filtersId.filterNotNull().joinToString(", ") { preferences.context.getString(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -656,8 +655,8 @@ class MangaDetailsPresenter(
|
|||||||
manga.genre = if (tags.isNullOrEmpty()) null else tagsString?.trim()
|
manga.genre = if (tags.isNullOrEmpty()) null else tagsString?.trim()
|
||||||
if (seriesType != null) {
|
if (seriesType != null) {
|
||||||
manga.genre = setSeriesType(seriesType, manga.genre).joinToString(", ") { it.capitalize() }
|
manga.genre = setSeriesType(seriesType, manga.genre).joinToString(", ") { it.capitalize() }
|
||||||
manga.viewer = -1
|
manga.viewer_flags = -1
|
||||||
db.updateMangaViewer(manga).executeAsBlocking()
|
db.updateViewerFlags(manga).executeAsBlocking()
|
||||||
}
|
}
|
||||||
manga.status = status ?: SManga.UNKNOWN
|
manga.status = status ?: SManga.UNKNOWN
|
||||||
LocalSource(downloadManager.context).updateMangaInfo(manga)
|
LocalSource(downloadManager.context).updateMangaInfo(manga)
|
||||||
@ -670,8 +669,8 @@ class MangaDetailsPresenter(
|
|||||||
}
|
}
|
||||||
if (seriesType != null) {
|
if (seriesType != null) {
|
||||||
genre = setSeriesType(seriesType, genre?.joinToString(", "))
|
genre = setSeriesType(seriesType, genre?.joinToString(", "))
|
||||||
manga.viewer = -1
|
manga.viewer_flags = -1
|
||||||
db.updateMangaViewer(manga).executeAsBlocking()
|
db.updateViewerFlags(manga).executeAsBlocking()
|
||||||
}
|
}
|
||||||
val manga = CustomMangaManager.MangaJson(
|
val manga = CustomMangaManager.MangaJson(
|
||||||
manga.id!!,
|
manga.id!!,
|
||||||
|
@ -40,10 +40,10 @@ class ChapterFilterLayout @JvmOverloads constructor(context: Context, attrs: Att
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun setCheckboxes(manga: Manga) {
|
fun setCheckboxes(manga: Manga) {
|
||||||
binding.showRead.isChecked = manga.readFilter == Manga.SHOW_READ
|
binding.showRead.isChecked = manga.readFilter == Manga.CHAPTER_SHOW_READ
|
||||||
binding.showUnread.isChecked = manga.readFilter == Manga.SHOW_UNREAD
|
binding.showUnread.isChecked = manga.readFilter == Manga.CHAPTER_SHOW_UNREAD
|
||||||
binding.showDownload.isChecked = manga.downloadedFilter == Manga.SHOW_DOWNLOADED
|
binding.showDownload.isChecked = manga.downloadedFilter == Manga.CHAPTER_SHOW_DOWNLOADED
|
||||||
binding.showBookmark.isChecked = manga.bookmarkedFilter == Manga.SHOW_BOOKMARKED
|
binding.showBookmark.isChecked = manga.bookmarkedFilter == Manga.CHAPTER_SHOW_BOOKMARKED
|
||||||
|
|
||||||
binding.showAll.isChecked = !(
|
binding.showAll.isChecked = !(
|
||||||
binding.showRead.isChecked || binding.showUnread.isChecked ||
|
binding.showRead.isChecked || binding.showUnread.isChecked ||
|
||||||
|
@ -34,7 +34,7 @@ class ChapterHolder(
|
|||||||
val chapter = item.chapter
|
val chapter = item.chapter
|
||||||
val isLocked = item.isLocked
|
val isLocked = item.isLocked
|
||||||
binding.chapterTitle.text = when (manga.displayMode) {
|
binding.chapterTitle.text = when (manga.displayMode) {
|
||||||
Manga.DISPLAY_NUMBER -> {
|
Manga.CHAPTER_DISPLAY_NUMBER -> {
|
||||||
val number = adapter.decimalFormat.format(chapter.chapter_number.toDouble())
|
val number = adapter.decimalFormat.format(chapter.chapter_number.toDouble())
|
||||||
itemView.context.getString(R.string.chapter_, number)
|
itemView.context.getString(R.string.chapter_, number)
|
||||||
}
|
}
|
||||||
|
@ -88,9 +88,9 @@ class ChaptersSortBottomSheet(controller: MangaDetailsController) :
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
binding.hideTitles.isChecked = presenter.manga.displayMode != Manga.DISPLAY_NAME
|
binding.hideTitles.isChecked = presenter.manga.displayMode != Manga.CHAPTER_DISPLAY_NAME
|
||||||
binding.sortMethodGroup.check(
|
binding.sortMethodGroup.check(
|
||||||
if (presenter.manga.sorting == Manga.SORTING_SOURCE) R.id.sort_by_source else {
|
if (presenter.manga.sorting == Manga.CHAPTER_SORTING_SOURCE) R.id.sort_by_source else {
|
||||||
R.id.sort_by_number
|
R.id.sort_by_number
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -19,6 +19,7 @@ import rx.android.schedulers.AndroidSchedulers
|
|||||||
import rx.schedulers.Schedulers
|
import rx.schedulers.Schedulers
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
class MigrationPresenter(
|
class MigrationPresenter(
|
||||||
private val sourceManager: SourceManager = Injekt.get(),
|
private val sourceManager: SourceManager = Injekt.get(),
|
||||||
@ -143,6 +144,19 @@ class MigrationPresenter(
|
|||||||
manga.favorite = true
|
manga.favorite = true
|
||||||
db.updateMangaFavorite(manga).executeAsBlocking()
|
db.updateMangaFavorite(manga).executeAsBlocking()
|
||||||
|
|
||||||
|
manga.chapter_flags = prevManga.chapter_flags
|
||||||
|
db.updateChapterFlags(manga).executeAsBlocking()
|
||||||
|
manga.viewer_flags = prevManga.viewer_flags
|
||||||
|
db.updateViewerFlags(manga).executeAsBlocking()
|
||||||
|
|
||||||
|
// Update date added
|
||||||
|
if (replace) {
|
||||||
|
manga.date_added = prevManga.date_added
|
||||||
|
prevManga.date_added = 0
|
||||||
|
} else {
|
||||||
|
manga.date_added = Date().time
|
||||||
|
}
|
||||||
|
|
||||||
// SearchPresenter#networkToLocalManga may have updated the manga title, so ensure db gets updated title
|
// SearchPresenter#networkToLocalManga may have updated the manga title, so ensure db gets updated title
|
||||||
db.updateMangaTitle(manga).executeAsBlocking()
|
db.updateMangaTitle(manga).executeAsBlocking()
|
||||||
}
|
}
|
||||||
|
@ -186,12 +186,6 @@ class ReaderActivity :
|
|||||||
private var lastCropRes = 0
|
private var lastCropRes = 0
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@Suppress("unused")
|
|
||||||
const val LEFT_TO_RIGHT = 1
|
|
||||||
const val RIGHT_TO_LEFT = 2
|
|
||||||
const val VERTICAL = 3
|
|
||||||
const val WEBTOON = 4
|
|
||||||
const val VERTICAL_PLUS = 5
|
|
||||||
|
|
||||||
const val SHIFT_DOUBLE_PAGES = "shiftingDoublePages"
|
const val SHIFT_DOUBLE_PAGES = "shiftingDoublePages"
|
||||||
const val SHIFTED_PAGE_INDEX = "shiftedPageIndex"
|
const val SHIFTED_PAGE_INDEX = "shiftedPageIndex"
|
||||||
@ -366,7 +360,7 @@ class ReaderActivity :
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateRotationShortcut(preference: Int) {
|
private fun updateOrientationShortcut(preference: Int) {
|
||||||
val orientation = OrientationType.fromPreference(preference)
|
val orientation = OrientationType.fromPreference(preference)
|
||||||
binding.chaptersSheet.rotationSheetButton.setImageResource(orientation.iconRes)
|
binding.chaptersSheet.rotationSheetButton.setImageResource(orientation.iconRes)
|
||||||
}
|
}
|
||||||
@ -582,13 +576,15 @@ class ReaderActivity :
|
|||||||
|
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
popupMenu(
|
popupMenu(
|
||||||
items = OrientationType.values().map { it.prefValue to it.stringRes },
|
items = OrientationType.values().map { it.flagValue to it.stringRes },
|
||||||
selectedItemId = preferences.rotation().get(),
|
selectedItemId = presenter.manga?.orientationType
|
||||||
|
?: preferences.defaultOrientationType().get(),
|
||||||
) {
|
) {
|
||||||
val newOrientation = OrientationType.fromPreference(itemId)
|
val newOrientation = OrientationType.fromPreference(itemId)
|
||||||
|
|
||||||
preferences.rotation().set(newOrientation.prefValue)
|
presenter.setMangaOrientationType(newOrientation.flagValue)
|
||||||
setOrientation(newOrientation.flag)
|
|
||||||
|
updateOrientationShortcut(newOrientation.flagValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -608,10 +604,10 @@ class ReaderActivity :
|
|||||||
|
|
||||||
readingMode.setOnClickListener { readingMode ->
|
readingMode.setOnClickListener { readingMode ->
|
||||||
readingMode.popupMenu(
|
readingMode.popupMenu(
|
||||||
items = ReadingModeType.values().map { it.prefValue to it.stringRes },
|
items = ReadingModeType.values().map { it.flagValue to it.stringRes },
|
||||||
selectedItemId = presenter.manga?.viewer,
|
selectedItemId = presenter.manga?.readingModeType,
|
||||||
) {
|
) {
|
||||||
presenter.setMangaViewer(itemId)
|
presenter.setMangaReadingMode(itemId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -622,7 +618,6 @@ class ReaderActivity :
|
|||||||
.onEach { updateCropBordersShortcut() }
|
.onEach { updateCropBordersShortcut() }
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
preferences.rotation().asImmediateFlowIn(scope) { updateRotationShortcut(it) }
|
|
||||||
|
|
||||||
binding.chaptersSheet.shiftPageButton.setOnClickListener {
|
binding.chaptersSheet.shiftPageButton.setOnClickListener {
|
||||||
shiftDoublePages()
|
shiftDoublePages()
|
||||||
@ -829,25 +824,25 @@ class ReaderActivity :
|
|||||||
*/
|
*/
|
||||||
fun setManga(manga: Manga) {
|
fun setManga(manga: Manga) {
|
||||||
val prevViewer = viewer
|
val prevViewer = viewer
|
||||||
val noDefault = manga.viewer == -1
|
val noDefault = manga.viewer_flags == -1
|
||||||
val mangaViewer = presenter.getMangaViewer()
|
val mangaViewer = presenter.getMangaReadingMode()
|
||||||
val newViewer = when (mangaViewer) {
|
val newViewer = when (mangaViewer) {
|
||||||
LEFT_TO_RIGHT -> L2RPagerViewer(this)
|
ReadingModeType.LEFT_TO_RIGHT.flagValue -> L2RPagerViewer(this)
|
||||||
VERTICAL -> VerticalPagerViewer(this)
|
ReadingModeType.VERTICAL.flagValue -> VerticalPagerViewer(this)
|
||||||
WEBTOON -> WebtoonViewer(this)
|
ReadingModeType.WEBTOON.flagValue -> WebtoonViewer(this)
|
||||||
VERTICAL_PLUS -> WebtoonViewer(this, hasMargins = true)
|
ReadingModeType.CONTINUOUS_VERTICAL.flagValue -> WebtoonViewer(this, hasMargins = true)
|
||||||
else -> R2LPagerViewer(this)
|
else -> R2LPagerViewer(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noDefault && presenter.manga?.viewer!! > 0) {
|
if (noDefault && presenter.manga?.readingModeType!! > 0) {
|
||||||
snackbar = binding.readerLayout.snack(
|
snackbar = binding.readerLayout.snack(
|
||||||
getString(
|
getString(
|
||||||
R.string.reading_,
|
R.string.reading_,
|
||||||
getString(
|
getString(
|
||||||
when (mangaViewer) {
|
when (mangaViewer) {
|
||||||
RIGHT_TO_LEFT -> R.string.right_to_left_viewer
|
ReadingModeType.RIGHT_TO_LEFT.flagValue -> R.string.right_to_left_viewer
|
||||||
VERTICAL -> R.string.vertical_viewer
|
ReadingModeType.VERTICAL.flagValue -> R.string.vertical_viewer
|
||||||
WEBTOON -> R.string.webtoon_style
|
ReadingModeType.WEBTOON.flagValue -> R.string.webtoon_style
|
||||||
else -> R.string.left_to_right_viewer
|
else -> R.string.left_to_right_viewer
|
||||||
}
|
}
|
||||||
).toLowerCase(Locale.getDefault())
|
).toLowerCase(Locale.getDefault())
|
||||||
@ -855,11 +850,13 @@ class ReaderActivity :
|
|||||||
4000
|
4000
|
||||||
) {
|
) {
|
||||||
if (presenter.manga?.isLongStrip() != true) setAction(R.string.use_default) {
|
if (presenter.manga?.isLongStrip() != true) setAction(R.string.use_default) {
|
||||||
presenter.setMangaViewer(0)
|
presenter.setMangaReadingMode(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setOrientation(presenter.getMangaOrientationType())
|
||||||
|
|
||||||
// Destroy previous viewer if there was one
|
// Destroy previous viewer if there was one
|
||||||
if (prevViewer != null) {
|
if (prevViewer != null) {
|
||||||
prevViewer.destroy()
|
prevViewer.destroy()
|
||||||
@ -903,7 +900,7 @@ class ReaderActivity :
|
|||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
updateCropBordersShortcut()
|
updateCropBordersShortcut()
|
||||||
updateBottomShortcuts()
|
updateBottomShortcuts()
|
||||||
val viewerMode = ReadingModeType.fromPreference(presenter?.manga?.viewer ?: 0)
|
val viewerMode = ReadingModeType.fromPreference(presenter?.manga?.readingModeType ?: 0)
|
||||||
binding.chaptersSheet.readingMode.setImageResource(viewerMode.iconRes)
|
binding.chaptersSheet.readingMode.setImageResource(viewerMode.iconRes)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1371,7 +1368,7 @@ class ReaderActivity :
|
|||||||
/**
|
/**
|
||||||
* Forces the user preferred [orientation] on the activity.
|
* Forces the user preferred [orientation] on the activity.
|
||||||
*/
|
*/
|
||||||
private fun setOrientation(orientation: Int) {
|
fun setOrientation(orientation: Int) {
|
||||||
val newOrientation = OrientationType.fromPreference(orientation)
|
val newOrientation = OrientationType.fromPreference(orientation)
|
||||||
if (newOrientation.flag != requestedOrientation) {
|
if (newOrientation.flag != requestedOrientation) {
|
||||||
requestedOrientation = newOrientation.flag
|
requestedOrientation = newOrientation.flag
|
||||||
@ -1389,12 +1386,11 @@ class ReaderActivity :
|
|||||||
* Initializes the reader subscriptions.
|
* Initializes the reader subscriptions.
|
||||||
*/
|
*/
|
||||||
init {
|
init {
|
||||||
setOrientation(preferences.rotation().get())
|
preferences.defaultOrientationType().asFlow()
|
||||||
preferences.rotation().asFlow()
|
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.onEach {
|
.onEach {
|
||||||
delay(250)
|
delay(250)
|
||||||
setOrientation(it)
|
setOrientation(presenter.getMangaOrientationType())
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
|
|
||||||
|
@ -30,6 +30,8 @@ import eu.kanade.tachiyomi.ui.reader.loader.ChapterLoader
|
|||||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
||||||
|
import eu.kanade.tachiyomi.ui.reader.settings.OrientationType
|
||||||
|
import eu.kanade.tachiyomi.ui.reader.settings.ReadingModeType
|
||||||
import eu.kanade.tachiyomi.util.chapter.ChapterFilter
|
import eu.kanade.tachiyomi.util.chapter.ChapterFilter
|
||||||
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
||||||
import eu.kanade.tachiyomi.util.storage.DiskUtil
|
import eu.kanade.tachiyomi.util.storage.DiskUtil
|
||||||
@ -117,8 +119,8 @@ class ReaderPresenter(
|
|||||||
chapterFilter.filterChaptersForReader(dbChapters, manga, selectedChapter)
|
chapterFilter.filterChaptersForReader(dbChapters, manga, selectedChapter)
|
||||||
|
|
||||||
when (manga.sorting) {
|
when (manga.sorting) {
|
||||||
Manga.SORTING_SOURCE -> ChapterLoadBySource().get(chaptersForReader)
|
Manga.CHAPTER_SORTING_SOURCE -> ChapterLoadBySource().get(chaptersForReader)
|
||||||
Manga.SORTING_NUMBER -> ChapterLoadByNumber().get(chaptersForReader, selectedChapter)
|
Manga.CHAPTER_SORTING_NUMBER -> ChapterLoadByNumber().get(chaptersForReader, selectedChapter)
|
||||||
else -> error("Unknown sorting method")
|
else -> error("Unknown sorting method")
|
||||||
}.map(::ReaderChapter)
|
}.map(::ReaderChapter)
|
||||||
}
|
}
|
||||||
@ -215,7 +217,7 @@ class ReaderPresenter(
|
|||||||
chapterFilter.filterChaptersForReader(dbChapters, manga, getCurrentChapter()?.chapter)
|
chapterFilter.filterChaptersForReader(dbChapters, manga, getCurrentChapter()?.chapter)
|
||||||
.sortedBy {
|
.sortedBy {
|
||||||
when (manga.sorting) {
|
when (manga.sorting) {
|
||||||
Manga.SORTING_NUMBER -> it.chapter_number
|
Manga.CHAPTER_SORTING_NUMBER -> it.chapter_number
|
||||||
else -> it.source_order.toFloat()
|
else -> it.source_order.toFloat()
|
||||||
}
|
}
|
||||||
}.map {
|
}.map {
|
||||||
@ -235,21 +237,6 @@ class ReaderPresenter(
|
|||||||
return chapterItems
|
return chapterItems
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes all filters and requests an UI update.
|
|
||||||
*/
|
|
||||||
fun setFilters(read: Boolean, unread: Boolean, downloaded: Boolean, bookmarked: Boolean) {
|
|
||||||
val manga = manga ?: return
|
|
||||||
manga.readFilter = when {
|
|
||||||
read -> Manga.SHOW_READ
|
|
||||||
unread -> Manga.SHOW_UNREAD
|
|
||||||
else -> Manga.SHOW_ALL
|
|
||||||
}
|
|
||||||
manga.downloadedFilter = if (downloaded) Manga.SHOW_DOWNLOADED else Manga.SHOW_ALL
|
|
||||||
manga.bookmarkedFilter = if (bookmarked) Manga.SHOW_BOOKMARKED else Manga.SHOW_ALL
|
|
||||||
db.updateFlags(manga).executeAsBlocking()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes this presenter with the given [manga] and [initialChapterId]. This method will
|
* Initializes this presenter with the given [manga] and [initialChapterId]. This method will
|
||||||
* set the chapter loader, view subscriptions and trigger an initial load.
|
* set the chapter loader, view subscriptions and trigger an initial load.
|
||||||
@ -594,29 +581,32 @@ class ReaderPresenter(
|
|||||||
/**
|
/**
|
||||||
* Returns the viewer position used by this manga or the default one.
|
* Returns the viewer position used by this manga or the default one.
|
||||||
*/
|
*/
|
||||||
fun getMangaViewer(): Int {
|
fun getMangaReadingMode(): Int {
|
||||||
val default = preferences.defaultViewer()
|
val default = preferences.defaultReadingMode()
|
||||||
val manga = manga ?: return default
|
val manga = manga ?: return default
|
||||||
val readerType = manga.defaultReaderType()
|
val readerType = manga.defaultReaderType()
|
||||||
if (manga.viewer == -1 ||
|
if (manga.viewer_flags == -1 ||
|
||||||
// Force webtoon mode
|
// Force webtoon mode
|
||||||
(manga.isLongStrip() && readerType != manga.viewer)
|
(manga.isLongStrip() && readerType != manga.readingModeType)
|
||||||
) {
|
) {
|
||||||
val cantSwitchToLTR =
|
val cantSwitchToLTR =
|
||||||
(readerType == ReaderActivity.LEFT_TO_RIGHT && default != ReaderActivity.RIGHT_TO_LEFT)
|
(
|
||||||
manga.viewer = if (cantSwitchToLTR) 0 else readerType
|
readerType == ReadingModeType.LEFT_TO_RIGHT.flagValue &&
|
||||||
db.updateMangaViewer(manga).asRxObservable().subscribe()
|
default != ReadingModeType.RIGHT_TO_LEFT.flagValue
|
||||||
|
)
|
||||||
|
manga.readingModeType = if (cantSwitchToLTR) 0 else readerType
|
||||||
|
db.updateViewerFlags(manga).asRxObservable().subscribe()
|
||||||
}
|
}
|
||||||
return if (manga.viewer == 0) default else manga.viewer
|
return if (manga.readingModeType == 0) default else manga.readingModeType
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the viewer position for the open manga.
|
* Updates the viewer position for the open manga.
|
||||||
*/
|
*/
|
||||||
fun setMangaViewer(viewer: Int) {
|
fun setMangaReadingMode(readingModeType: Int) {
|
||||||
val manga = manga ?: return
|
val manga = manga ?: return
|
||||||
manga.viewer = viewer
|
manga.readingModeType = readingModeType
|
||||||
db.updateMangaViewer(manga).executeAsBlocking()
|
db.updateViewerFlags(manga).executeAsBlocking()
|
||||||
|
|
||||||
Observable.timer(250, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
|
Observable.timer(250, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
|
||||||
.subscribeFirst({ view, _ ->
|
.subscribeFirst({ view, _ ->
|
||||||
@ -633,6 +623,36 @@ class ReaderPresenter(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the orientation type used by this manga or the default one.
|
||||||
|
*/
|
||||||
|
fun getMangaOrientationType(): Int {
|
||||||
|
val default = preferences.defaultOrientationType().get()
|
||||||
|
return when (manga?.orientationType) {
|
||||||
|
OrientationType.DEFAULT.flagValue -> default
|
||||||
|
else -> manga?.orientationType ?: default
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the orientation type for the open manga.
|
||||||
|
*/
|
||||||
|
fun setMangaOrientationType(rotationType: Int) {
|
||||||
|
val manga = manga ?: return
|
||||||
|
manga.orientationType = rotationType
|
||||||
|
db.updateViewerFlags(manga).executeAsBlocking()
|
||||||
|
|
||||||
|
Timber.i("Manga orientation is ${manga.orientationType}")
|
||||||
|
|
||||||
|
Observable.timer(250, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
|
||||||
|
.subscribeFirst({ view, _ ->
|
||||||
|
val currChapters = viewerChaptersRelay.value
|
||||||
|
if (currChapters != null) {
|
||||||
|
view.setOrientation(getMangaOrientationType())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the image of this [page] in the given [directory] and returns the file location.
|
* Saves the image of this [page] in the given [directory] and returns the file location.
|
||||||
*/
|
*/
|
||||||
|
@ -41,7 +41,7 @@ class ReaderChapterItem(val chapter: Chapter, val manga: Manga, val isCurrent: B
|
|||||||
val chapterColor = ChapterUtil.chapterColor(itemView.context, item.chapter)
|
val chapterColor = ChapterUtil.chapterColor(itemView.context, item.chapter)
|
||||||
|
|
||||||
binding.chapterTitle.text = when (manga.displayMode) {
|
binding.chapterTitle.text = when (manga.displayMode) {
|
||||||
Manga.DISPLAY_NUMBER -> {
|
Manga.CHAPTER_DISPLAY_NUMBER -> {
|
||||||
val number = item.decimalFormat.format(item.chapter_number.toDouble())
|
val number = item.decimalFormat.format(item.chapter_number.toDouble())
|
||||||
itemView.context.getString(R.string.chapter_, number)
|
itemView.context.getString(R.string.chapter_, number)
|
||||||
}
|
}
|
||||||
|
@ -5,16 +5,21 @@ import androidx.annotation.DrawableRes
|
|||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
|
||||||
enum class OrientationType(val prefValue: Int, val flag: Int, @StringRes val stringRes: Int, @DrawableRes val iconRes: Int) {
|
enum class OrientationType(val prefValue: Int, val flag: Int, @StringRes val stringRes: Int, @DrawableRes val iconRes: Int, val flagValue: Int) {
|
||||||
FREE(1, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED, R.string.free, R.drawable.ic_screen_rotation_24dp),
|
DEFAULT(0, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED, R.string.default_value, R.drawable.ic_screen_rotation_24dp, 0x00000000),
|
||||||
PORTRAIT(2, ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT, R.string.portrait, R.drawable.ic_stay_current_portrait_24dp),
|
FREE(1, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED, R.string.free, R.drawable.ic_screen_rotation_24dp, 0x00000008),
|
||||||
LANDSCAPE(3, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, R.string.landscape, R.drawable.ic_stay_current_landscape_24dp),
|
PORTRAIT(2, ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT, R.string.portrait, R.drawable.ic_stay_current_portrait_24dp, 0x00000010),
|
||||||
LOCKED_PORTRAIT(4, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, R.string.locked_portrait, R.drawable.ic_screen_lock_portrait_24dp),
|
LANDSCAPE(3, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, R.string.landscape, R.drawable.ic_stay_current_landscape_24dp, 0x00000018),
|
||||||
LOCKED_LANDSCAPE(5, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, R.string.locked_landscape, R.drawable.ic_screen_lock_landscape_24dp),
|
LOCKED_PORTRAIT(4, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, R.string.locked_portrait, R.drawable.ic_screen_lock_portrait_24dp, 0x00000020),
|
||||||
|
LOCKED_LANDSCAPE(5, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, R.string.locked_landscape, R.drawable.ic_screen_lock_landscape_24dp, 0x00000028),
|
||||||
;
|
;
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
const val MASK = 0x00000038
|
||||||
|
|
||||||
fun fromPreference(preference: Int): OrientationType =
|
fun fromPreference(preference: Int): OrientationType =
|
||||||
values().find { it.prefValue == preference } ?: FREE
|
values().find { it.flagValue == preference } ?: FREE
|
||||||
|
|
||||||
|
fun fromSpinner(position: Int?) = values().find { value -> value.prefValue == position } ?: DEFAULT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,17 +15,31 @@ class ReaderGeneralView @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
override fun inflateBinding() = ReaderGeneralLayoutBinding.bind(this)
|
override fun inflateBinding() = ReaderGeneralLayoutBinding.bind(this)
|
||||||
override fun initGeneralPreferences() {
|
override fun initGeneralPreferences() {
|
||||||
binding.viewerSeries.onItemSelectedListener = { position ->
|
binding.viewerSeries.onItemSelectedListener = { position ->
|
||||||
activity.presenter.setMangaViewer(position)
|
val readingModeType = ReadingModeType.fromSpinner(position)
|
||||||
|
(context as ReaderActivity).presenter.setMangaReadingMode(readingModeType.flagValue)
|
||||||
|
|
||||||
val mangaViewer = activity.presenter.getMangaViewer()
|
val mangaViewer = activity.presenter.getMangaReadingMode()
|
||||||
if (mangaViewer == ReaderActivity.WEBTOON || mangaViewer == ReaderActivity.VERTICAL_PLUS) {
|
if (mangaViewer == ReadingModeType.WEBTOON.flagValue || mangaViewer == ReadingModeType.CONTINUOUS_VERTICAL.flagValue) {
|
||||||
initWebtoonPreferences()
|
initWebtoonPreferences()
|
||||||
} else {
|
} else {
|
||||||
initPagerPreferences()
|
initPagerPreferences()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
binding.viewerSeries.setSelection((context as? ReaderActivity)?.presenter?.manga?.viewer ?: 0)
|
binding.viewerSeries.setSelection(
|
||||||
binding.rotationMode.bindToPreference(preferences.rotation(), 1)
|
(context as? ReaderActivity)?.presenter?.manga?.readingModeType?.let {
|
||||||
|
ReadingModeType.fromPreference(it).prefValue
|
||||||
|
} ?: 0
|
||||||
|
)
|
||||||
|
binding.rotationMode.onItemSelectedListener = { position ->
|
||||||
|
val rotationType = OrientationType.fromSpinner(position)
|
||||||
|
(context as ReaderActivity).presenter.setMangaOrientationType(rotationType.flagValue)
|
||||||
|
}
|
||||||
|
binding.rotationMode.setSelection(
|
||||||
|
(context as ReaderActivity).presenter.manga?.orientationType?.let {
|
||||||
|
OrientationType.fromPreference(it).prefValue
|
||||||
|
} ?: 0
|
||||||
|
)
|
||||||
|
|
||||||
binding.backgroundColor.bindToPreference(preferences.readerTheme(), 0)
|
binding.backgroundColor.bindToPreference(preferences.readerTheme(), 0)
|
||||||
binding.showPageNumber.bindToPreference(preferences.showPageNumber())
|
binding.showPageNumber.bindToPreference(preferences.showPageNumber())
|
||||||
binding.fullscreen.bindToPreference(preferences.fullscreen())
|
binding.fullscreen.bindToPreference(preferences.fullscreen())
|
||||||
|
@ -19,9 +19,8 @@ class ReaderPagedView @JvmOverloads constructor(context: Context, attrs: Attribu
|
|||||||
override fun initGeneralPreferences() {
|
override fun initGeneralPreferences() {
|
||||||
with(binding) {
|
with(binding) {
|
||||||
scaleType.bindToPreference(preferences.imageScaleType(), 1) {
|
scaleType.bindToPreference(preferences.imageScaleType(), 1) {
|
||||||
val mangaViewer = (context as? ReaderActivity)?.presenter?.getMangaViewer() ?: 0
|
val mangaViewer = (context as? ReaderActivity)?.presenter?.getMangaReadingMode() ?: 0
|
||||||
val isWebtoonView =
|
val isWebtoonView = ReadingModeType.isWebtoonType(mangaViewer)
|
||||||
mangaViewer == ReaderActivity.WEBTOON || mangaViewer == ReaderActivity.VERTICAL_PLUS
|
|
||||||
updatePagedGroup(!isWebtoonView)
|
updatePagedGroup(!isWebtoonView)
|
||||||
}
|
}
|
||||||
zoomStart.bindToPreference(preferences.zoomStart(), 1)
|
zoomStart.bindToPreference(preferences.zoomStart(), 1)
|
||||||
@ -31,19 +30,17 @@ class ReaderPagedView @JvmOverloads constructor(context: Context, attrs: Attribu
|
|||||||
pagerInvert.bindToPreference(preferences.pagerNavInverted())
|
pagerInvert.bindToPreference(preferences.pagerNavInverted())
|
||||||
extendPastCutout.bindToPreference(preferences.pagerCutoutBehavior())
|
extendPastCutout.bindToPreference(preferences.pagerCutoutBehavior())
|
||||||
pageLayout.bindToPreference(preferences.pageLayout()) {
|
pageLayout.bindToPreference(preferences.pageLayout()) {
|
||||||
val mangaViewer = (context as? ReaderActivity)?.presenter?.getMangaViewer() ?: 0
|
val mangaViewer = (context as? ReaderActivity)?.presenter?.getMangaReadingMode() ?: 0
|
||||||
val isWebtoonView =
|
val isWebtoonView = ReadingModeType.isWebtoonType(mangaViewer)
|
||||||
mangaViewer == ReaderActivity.WEBTOON || mangaViewer == ReaderActivity.VERTICAL_PLUS
|
|
||||||
updatePagedGroup(!isWebtoonView)
|
updatePagedGroup(!isWebtoonView)
|
||||||
}
|
}
|
||||||
invertDoublePages.bindToPreference(preferences.invertDoublePages())
|
invertDoublePages.bindToPreference(preferences.invertDoublePages())
|
||||||
|
|
||||||
pageLayout.title = pageLayout.title.toString().addBetaTag(context)
|
pageLayout.title = pageLayout.title.toString().addBetaTag(context)
|
||||||
|
|
||||||
val mangaViewer = (context as? ReaderActivity)?.presenter?.getMangaViewer() ?: 0
|
val mangaViewer = (context as? ReaderActivity)?.presenter?.getMangaReadingMode() ?: 0
|
||||||
val isWebtoonView =
|
val isWebtoonView = ReadingModeType.isWebtoonType(mangaViewer)
|
||||||
mangaViewer == ReaderActivity.WEBTOON || mangaViewer == ReaderActivity.VERTICAL_PLUS
|
val hasMargins = mangaViewer == ReadingModeType.CONTINUOUS_VERTICAL.flagValue
|
||||||
val hasMargins = mangaViewer == ReaderActivity.VERTICAL_PLUS
|
|
||||||
cropBordersWebtoon.bindToPreference(if (hasMargins) preferences.cropBorders() else preferences.cropBordersWebtoon())
|
cropBordersWebtoon.bindToPreference(if (hasMargins) preferences.cropBorders() else preferences.cropBordersWebtoon())
|
||||||
webtoonSidePadding.bindToIntPreference(
|
webtoonSidePadding.bindToIntPreference(
|
||||||
preferences.webtoonSidePadding(),
|
preferences.webtoonSidePadding(),
|
||||||
@ -58,9 +55,9 @@ class ReaderPagedView @JvmOverloads constructor(context: Context, attrs: Attribu
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun updatePrefs() {
|
fun updatePrefs() {
|
||||||
val mangaViewer = activity.presenter.getMangaViewer()
|
val mangaViewer = activity.presenter.getMangaReadingMode()
|
||||||
val isWebtoonView = mangaViewer == ReaderActivity.WEBTOON || mangaViewer == ReaderActivity.VERTICAL_PLUS
|
val isWebtoonView = ReadingModeType.isWebtoonType(mangaViewer)
|
||||||
val hasMargins = mangaViewer == ReaderActivity.VERTICAL_PLUS
|
val hasMargins = mangaViewer == ReadingModeType.CONTINUOUS_VERTICAL.flagValue
|
||||||
binding.cropBordersWebtoon.bindToPreference(if (hasMargins) preferences.cropBorders() else preferences.cropBordersWebtoon())
|
binding.cropBordersWebtoon.bindToPreference(if (hasMargins) preferences.cropBorders() else preferences.cropBordersWebtoon())
|
||||||
updatePagedGroup(!isWebtoonView)
|
updatePagedGroup(!isWebtoonView)
|
||||||
}
|
}
|
||||||
|
@ -5,17 +5,18 @@ import androidx.annotation.StringRes
|
|||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.util.lang.next
|
import eu.kanade.tachiyomi.util.lang.next
|
||||||
|
|
||||||
enum class ReadingModeType(val prefValue: Int, @StringRes val stringRes: Int, @DrawableRes val iconRes: Int) {
|
enum class ReadingModeType(val prefValue: Int, @StringRes val stringRes: Int, @DrawableRes val iconRes: Int, val flagValue: Int) {
|
||||||
DEFAULT(0, R.string.default_value, R.drawable.ic_reader_default_24dp),
|
DEFAULT(0, R.string.default_value, R.drawable.ic_reader_default_24dp, 0x00000000),
|
||||||
LEFT_TO_RIGHT(1, R.string.left_to_right_viewer, R.drawable.ic_reader_ltr_24dp),
|
LEFT_TO_RIGHT(1, R.string.left_to_right_viewer, R.drawable.ic_reader_ltr_24dp, 0x00000001),
|
||||||
RIGHT_TO_LEFT(2, R.string.right_to_left_viewer, R.drawable.ic_reader_rtl_24dp),
|
RIGHT_TO_LEFT(2, R.string.right_to_left_viewer, R.drawable.ic_reader_rtl_24dp, 0x00000002),
|
||||||
VERTICAL(3, R.string.vertical_viewer, R.drawable.ic_reader_vertical_24dp),
|
VERTICAL(3, R.string.vertical_viewer, R.drawable.ic_reader_vertical_24dp, 0x00000003),
|
||||||
WEBTOON(4, R.string.webtoon, R.drawable.ic_reader_webtoon_24dp),
|
WEBTOON(4, R.string.webtoon, R.drawable.ic_reader_webtoon_24dp, 0x00000004),
|
||||||
CONTINUOUS_VERTICAL(5, R.string.continuous_vertical, R.drawable.ic_reader_continuous_vertical_24dp),
|
CONTINUOUS_VERTICAL(5, R.string.continuous_vertical, R.drawable.ic_reader_continuous_vertical_24dp, 0x00000005),
|
||||||
;
|
;
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun fromPreference(preference: Int): ReadingModeType = values().find { it.prefValue == preference } ?: DEFAULT
|
fun fromPreference(preference: Int): ReadingModeType = values().find { it.flagValue == preference } ?: DEFAULT
|
||||||
|
const val MASK = 0x00000007
|
||||||
|
|
||||||
fun getNextReadingMode(preference: Int): ReadingModeType {
|
fun getNextReadingMode(preference: Int): ReadingModeType {
|
||||||
val current = fromPreference(preference)
|
val current = fromPreference(preference)
|
||||||
@ -26,5 +27,12 @@ enum class ReadingModeType(val prefValue: Int, @StringRes val stringRes: Int, @D
|
|||||||
val mode = fromPreference(preference)
|
val mode = fromPreference(preference)
|
||||||
return mode == LEFT_TO_RIGHT || mode == RIGHT_TO_LEFT || mode == VERTICAL
|
return mode == LEFT_TO_RIGHT || mode == RIGHT_TO_LEFT || mode == VERTICAL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isWebtoonType(preference: Int): Boolean {
|
||||||
|
val mode = fromPreference(preference)
|
||||||
|
return mode == WEBTOON || mode == CONTINUOUS_VERTICAL
|
||||||
|
}
|
||||||
|
|
||||||
|
fun fromSpinner(position: Int?) = values().find { value -> value.prefValue == position } ?: DEFAULT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,10 +36,10 @@ class TabbedReaderSettingsSheet(
|
|||||||
null
|
null
|
||||||
) as ReaderFilterView
|
) as ReaderFilterView
|
||||||
|
|
||||||
var showWebview: Boolean = {
|
var showWebtoonView: Boolean = run {
|
||||||
val mangaViewer = readerActivity.presenter.getMangaViewer()
|
val mangaViewer = readerActivity.presenter.getMangaReadingMode()
|
||||||
mangaViewer == ReaderActivity.WEBTOON || mangaViewer == ReaderActivity.VERTICAL_PLUS
|
ReadingModeType.isWebtoonType(mangaViewer)
|
||||||
}()
|
}
|
||||||
|
|
||||||
override var offset = 0
|
override var offset = 0
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ class TabbedReaderSettingsSheet(
|
|||||||
|
|
||||||
override fun getTabTitles(): List<Int> = listOf(
|
override fun getTabTitles(): List<Int> = listOf(
|
||||||
R.string.general,
|
R.string.general,
|
||||||
if (showWebview) R.string.webtoon else R.string.paged,
|
if (showWebtoonView) R.string.webtoon else R.string.paged,
|
||||||
R.string.filter
|
R.string.filter
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ class TabbedReaderSettingsSheet(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun updateTabs(isWebtoon: Boolean) {
|
fun updateTabs(isWebtoon: Boolean) {
|
||||||
showWebview = isWebtoon
|
showWebtoonView = isWebtoon
|
||||||
binding.pager.adapter?.notifyDataSetChanged()
|
binding.pager.adapter?.notifyDataSetChanged()
|
||||||
pagedView.updatePrefs()
|
pagedView.updatePrefs()
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
|||||||
import eu.kanade.tachiyomi.ui.reader.settings.ReaderBottomButton
|
import eu.kanade.tachiyomi.ui.reader.settings.ReaderBottomButton
|
||||||
import eu.kanade.tachiyomi.ui.reader.settings.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.settings.OrientationType
|
||||||
import eu.kanade.tachiyomi.ui.reader.settings.PageLayout
|
import eu.kanade.tachiyomi.ui.reader.settings.PageLayout
|
||||||
|
import eu.kanade.tachiyomi.ui.reader.settings.ReadingModeType
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||||
import eu.kanade.tachiyomi.util.lang.addBetaTag
|
import eu.kanade.tachiyomi.util.lang.addBetaTag
|
||||||
import eu.kanade.tachiyomi.util.system.isTablet
|
import eu.kanade.tachiyomi.util.system.isTablet
|
||||||
@ -23,16 +24,12 @@ class SettingsReaderController : SettingsController() {
|
|||||||
preferenceCategory {
|
preferenceCategory {
|
||||||
titleRes = R.string.general
|
titleRes = R.string.general
|
||||||
intListPreference(activity) {
|
intListPreference(activity) {
|
||||||
key = Keys.defaultViewer
|
key = Keys.defaultReadingMode
|
||||||
titleRes = R.string.default_reading_mode
|
titleRes = R.string.default_reading_mode
|
||||||
entriesRes = arrayOf(
|
entriesRes = ReadingModeType.values().drop(1)
|
||||||
R.string.left_to_right_viewer,
|
.map { value -> value.stringRes }.toTypedArray()
|
||||||
R.string.right_to_left_viewer,
|
entryValues = ReadingModeType.values().drop(1)
|
||||||
R.string.vertical_viewer,
|
.map { value -> value.flagValue }
|
||||||
R.string.webtoon,
|
|
||||||
R.string.continuous_vertical
|
|
||||||
)
|
|
||||||
entryRange = 1..5
|
|
||||||
defaultValue = 2
|
defaultValue = 2
|
||||||
}
|
}
|
||||||
intListPreference(activity) {
|
intListPreference(activity) {
|
||||||
@ -92,12 +89,13 @@ class SettingsReaderController : SettingsController() {
|
|||||||
titleRes = R.string.display
|
titleRes = R.string.display
|
||||||
|
|
||||||
intListPreference(activity) {
|
intListPreference(activity) {
|
||||||
key = Keys.rotation
|
key = Keys.defaultOrientationType
|
||||||
titleRes = R.string.rotation
|
titleRes = R.string.default_orientation
|
||||||
val enumConstants = OrientationType.values()
|
val enumConstants = OrientationType.values().drop(1)
|
||||||
entriesRes = enumConstants.map { it.stringRes }.toTypedArray()
|
entriesRes = enumConstants.map { it.stringRes }.toTypedArray()
|
||||||
entryRange = 1..enumConstants.size
|
entryValues = OrientationType.values().drop(1)
|
||||||
defaultValue = 1
|
.map { value -> value.flagValue }
|
||||||
|
defaultValue = OrientationType.FREE.flagValue
|
||||||
}
|
}
|
||||||
intListPreference(activity) {
|
intListPreference(activity) {
|
||||||
key = Keys.readerTheme
|
key = Keys.readerTheme
|
||||||
|
@ -11,10 +11,10 @@ class ChapterFilter(val preferences: PreferencesHelper = Injekt.get(), val downl
|
|||||||
|
|
||||||
// filters chapters based on the manga values
|
// filters chapters based on the manga values
|
||||||
fun <T : Chapter> filterChapters(chapters: List<T>, manga: Manga): List<T> {
|
fun <T : Chapter> filterChapters(chapters: List<T>, manga: Manga): List<T> {
|
||||||
val readEnabled = manga.readFilter == Manga.SHOW_READ
|
val readEnabled = manga.readFilter == Manga.CHAPTER_SHOW_READ
|
||||||
val unreadEnabled = manga.readFilter == Manga.SHOW_UNREAD
|
val unreadEnabled = manga.readFilter == Manga.CHAPTER_SHOW_UNREAD
|
||||||
val downloadEnabled = manga.downloadedFilter == Manga.SHOW_DOWNLOADED
|
val downloadEnabled = manga.downloadedFilter == Manga.CHAPTER_SHOW_DOWNLOADED
|
||||||
val bookmarkEnabled = manga.bookmarkedFilter == Manga.SHOW_BOOKMARKED
|
val bookmarkEnabled = manga.bookmarkedFilter == Manga.CHAPTER_SHOW_BOOKMARKED
|
||||||
|
|
||||||
// if none of the filters are enabled skip the filtering of them
|
// if none of the filters are enabled skip the filtering of them
|
||||||
return if (readEnabled || unreadEnabled || downloadEnabled || bookmarkEnabled) {
|
return if (readEnabled || unreadEnabled || downloadEnabled || bookmarkEnabled) {
|
||||||
|
@ -38,6 +38,14 @@
|
|||||||
app:title="@string/reading_mode"
|
app:title="@string/reading_mode"
|
||||||
android:entries="@array/viewers_selector" />
|
android:entries="@array/viewers_selector" />
|
||||||
|
|
||||||
|
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
|
||||||
|
android:id="@+id/rotation_mode"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
app:title="@string/orientation"
|
||||||
|
android:entries="@array/rotation_type" />
|
||||||
|
|
||||||
<com.google.android.material.textview.MaterialTextView
|
<com.google.android.material.textview.MaterialTextView
|
||||||
style="@style/TextAppearance.MaterialComponents.Headline6"
|
style="@style/TextAppearance.MaterialComponents.Headline6"
|
||||||
android:textSize="15sp"
|
android:textSize="15sp"
|
||||||
@ -47,14 +55,6 @@
|
|||||||
android:layout_marginTop="12dp"
|
android:layout_marginTop="12dp"
|
||||||
android:text="@string/general" />
|
android:text="@string/general" />
|
||||||
|
|
||||||
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
|
|
||||||
android:id="@+id/rotation_mode"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="4dp"
|
|
||||||
app:title="@string/rotation"
|
|
||||||
android:entries="@array/rotation_type" />
|
|
||||||
|
|
||||||
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
|
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
|
||||||
android:id="@+id/background_color"
|
android:id="@+id/background_color"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -79,6 +79,7 @@
|
|||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="rotation_type">
|
<string-array name="rotation_type">
|
||||||
|
<item>@string/default_value</item>
|
||||||
<item>@string/free</item>
|
<item>@string/free</item>
|
||||||
<item>@string/portrait</item>
|
<item>@string/portrait</item>
|
||||||
<item>@string/landscape</item>
|
<item>@string/landscape</item>
|
||||||
|
@ -953,6 +953,8 @@
|
|||||||
<string name="retry">Retry</string>
|
<string name="retry">Retry</string>
|
||||||
<string name="right">Right</string>
|
<string name="right">Right</string>
|
||||||
<string name="rotation">Rotation</string>
|
<string name="rotation">Rotation</string>
|
||||||
|
<string name="default_orientation">Default orientation</string>
|
||||||
|
<string name="orientation">Orientation</string>
|
||||||
<string name="save">Save</string>
|
<string name="save">Save</string>
|
||||||
<string name="search">Search</string>
|
<string name="search">Search</string>
|
||||||
<string name="search_">Search %1$s</string>
|
<string name="search_">Search %1$s</string>
|
||||||
|
@ -89,7 +89,7 @@ class BackupTest {
|
|||||||
root.add(Backup.MANGAS, mangaEntries)
|
root.add(Backup.MANGAS, mangaEntries)
|
||||||
root.add(Backup.CATEGORIES, categoryEntries)
|
root.add(Backup.CATEGORIES, categoryEntries)
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
/**
|
/**
|
||||||
* Test that checks if no crashes when no categories in library.
|
* Test that checks if no crashes when no categories in library.
|
||||||
*/
|
*/
|
||||||
@ -105,6 +105,7 @@ class BackupTest {
|
|||||||
val dbCats = db.getCategories().executeAsBlocking()
|
val dbCats = db.getCategories().executeAsBlocking()
|
||||||
assertThat(dbCats).isEmpty()
|
assertThat(dbCats).isEmpty()
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test to check if single category gets restored
|
* Test to check if single category gets restored
|
||||||
@ -150,7 +151,7 @@ class BackupTest {
|
|||||||
assertThat(dbCats[3].name).isEqualTo(category4.name)
|
assertThat(dbCats[3].name).isEqualTo(category4.name)
|
||||||
assertThat(dbCats[4].name).isEqualTo(category5.name)
|
assertThat(dbCats[4].name).isEqualTo(category5.name)
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
/**
|
/**
|
||||||
* Test if restore of manga is successful
|
* Test if restore of manga is successful
|
||||||
*/
|
*/
|
||||||
@ -217,6 +218,7 @@ class BackupTest {
|
|||||||
assertThat(dbCats[0].viewer).isEqualTo(3)
|
assertThat(dbCats[0].viewer).isEqualTo(3)
|
||||||
assertThat(dbCats[0].description).isEqualTo("This is a description")
|
assertThat(dbCats[0].description).isEqualTo("This is a description")
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if chapter restore is successful
|
* Test if chapter restore is successful
|
||||||
|
Loading…
Reference in New Issue
Block a user