mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Running ktlint (trailing commas added everywhere)
This commit is contained in:
parent
fd1f5a4212
commit
d77d18a1c5
331 changed files with 1526 additions and 1492 deletions
5
.editorconfig
Normal file
5
.editorconfig
Normal file
|
@ -0,0 +1,5 @@
|
|||
[*.{kt,kts}]
|
||||
indent_size=4
|
||||
insert_final_newline=true
|
||||
ij_kotlin_allow_trailing_comma=true
|
||||
ij_kotlin_allow_trailing_comma_on_call_site=true
|
|
@ -101,7 +101,7 @@ open class App : Application(), DefaultLifecycleObserver {
|
|||
this@App,
|
||||
0,
|
||||
Intent(ACTION_DISABLE_INCOGNITO_MODE),
|
||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE,
|
||||
)
|
||||
setContentIntent(pendingIntent)
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ abstract class AbstractBackupRestore<T : AbstractBackupManager>(protected val co
|
|||
internal fun showRestoreProgress(
|
||||
progress: Int,
|
||||
amount: Int,
|
||||
title: String
|
||||
title: String,
|
||||
) {
|
||||
notifier.showRestoreProgress(title, progress, amount)
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ class BackupNotifier(private val context: Context) {
|
|||
addAction(
|
||||
R.drawable.ic_share_24dp,
|
||||
context.getString(R.string.share),
|
||||
NotificationReceiver.shareBackupPendingBroadcast(context, unifile.uri, Notifications.ID_BACKUP_COMPLETE)
|
||||
NotificationReceiver.shareBackupPendingBroadcast(context, unifile.uri, Notifications.ID_BACKUP_COMPLETE),
|
||||
)
|
||||
|
||||
show(Notifications.ID_BACKUP_COMPLETE)
|
||||
|
@ -97,7 +97,7 @@ class BackupNotifier(private val context: Context) {
|
|||
addAction(
|
||||
R.drawable.ic_close_24dp,
|
||||
context.getString(R.string.stop),
|
||||
NotificationReceiver.cancelRestorePendingBroadcast(context, Notifications.ID_RESTORE_PROGRESS)
|
||||
NotificationReceiver.cancelRestorePendingBroadcast(context, Notifications.ID_RESTORE_PROGRESS),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -124,8 +124,8 @@ class BackupNotifier(private val context: Context) {
|
|||
R.string.restore_duration,
|
||||
TimeUnit.MILLISECONDS.toMinutes(time),
|
||||
TimeUnit.MILLISECONDS.toSeconds(time) - TimeUnit.MINUTES.toSeconds(
|
||||
TimeUnit.MILLISECONDS.toMinutes(time)
|
||||
)
|
||||
TimeUnit.MILLISECONDS.toMinutes(time),
|
||||
),
|
||||
)
|
||||
|
||||
with(completeNotificationBuilder) {
|
||||
|
@ -142,7 +142,7 @@ class BackupNotifier(private val context: Context) {
|
|||
addAction(
|
||||
R.drawable.ic_eye_24dp,
|
||||
context.getString(R.string.open_log),
|
||||
NotificationReceiver.openErrorOrSkippedLogPendingActivity(context, uri)
|
||||
NotificationReceiver.openErrorOrSkippedLogPendingActivity(context, uri),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ class FullBackupRestore(context: Context, notifier: BackupNotifier) : AbstractBa
|
|||
history: List<BackupHistory>,
|
||||
tracks: List<Track>,
|
||||
backupCategories: List<BackupCategory>,
|
||||
customManga: CustomMangaManager.MangaJson?
|
||||
customManga: CustomMangaManager.MangaJson?,
|
||||
) {
|
||||
db.inTransaction {
|
||||
val dbManga = backupManager.getMangaFromDatabase(manga)
|
||||
|
@ -129,7 +129,7 @@ class FullBackupRestore(context: Context, notifier: BackupNotifier) : AbstractBa
|
|||
history: List<BackupHistory>,
|
||||
tracks: List<Track>,
|
||||
backupCategories: List<BackupCategory>,
|
||||
customManga: CustomMangaManager.MangaJson?
|
||||
customManga: CustomMangaManager.MangaJson?,
|
||||
) {
|
||||
try {
|
||||
val fetchedManga = backupManager.restoreManga(manga)
|
||||
|
@ -149,7 +149,7 @@ class FullBackupRestore(context: Context, notifier: BackupNotifier) : AbstractBa
|
|||
history: List<BackupHistory>,
|
||||
tracks: List<Track>,
|
||||
backupCategories: List<BackupCategory>,
|
||||
customManga: CustomMangaManager.MangaJson?
|
||||
customManga: CustomMangaManager.MangaJson?,
|
||||
) {
|
||||
backupManager.restoreChaptersForManga(backupManga, chapters)
|
||||
|
||||
|
@ -162,7 +162,7 @@ class FullBackupRestore(context: Context, notifier: BackupNotifier) : AbstractBa
|
|||
history: List<BackupHistory>,
|
||||
tracks: List<Track>,
|
||||
backupCategories: List<BackupCategory>,
|
||||
customManga: CustomMangaManager.MangaJson?
|
||||
customManga: CustomMangaManager.MangaJson?,
|
||||
) {
|
||||
// Restore categories
|
||||
backupManager.restoreCategoriesForManga(manga, categories, backupCategories)
|
||||
|
|
|
@ -9,5 +9,5 @@ data class Backup(
|
|||
@ProtoNumber(2) var backupCategories: List<BackupCategory> = emptyList(),
|
||||
// Bump by 100 to specify this is a 0.x value
|
||||
@ProtoNumber(100) var backupBrokenSources: List<BrokenBackupSource> = emptyList(),
|
||||
@ProtoNumber(101) var backupSources: List<BackupSource> = emptyList()
|
||||
@ProtoNumber(101) var backupSources: List<BackupSource> = emptyList(),
|
||||
)
|
||||
|
|
|
@ -31,7 +31,7 @@ class BackupCategory(
|
|||
name = category.name,
|
||||
order = category.order,
|
||||
flags = category.flags,
|
||||
mangaSort = category.mangaSort
|
||||
mangaSort = category.mangaSort,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ data class BackupChapter(
|
|||
dateFetch = chapter.date_fetch,
|
||||
dateUpload = chapter.date_upload,
|
||||
sourceOrder = chapter.source_order,
|
||||
pagesLeft = chapter.pages_left
|
||||
pagesLeft = chapter.pages_left,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,11 @@ import kotlinx.serialization.protobuf.ProtoNumber
|
|||
@Serializable
|
||||
data class BrokenBackupHistory(
|
||||
@ProtoNumber(0) var url: String,
|
||||
@ProtoNumber(1) var lastRead: Long
|
||||
@ProtoNumber(1) var lastRead: Long,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class BackupHistory(
|
||||
@ProtoNumber(1) var url: String,
|
||||
@ProtoNumber(2) var lastRead: Long
|
||||
@ProtoNumber(2) var lastRead: Long,
|
||||
)
|
||||
|
|
|
@ -47,7 +47,7 @@ data class BackupManga(
|
|||
@ProtoNumber(802) var customAuthor: String? = null,
|
||||
// skipping 803 due to using duplicate value in previous builds
|
||||
@ProtoNumber(804) var customDescription: String? = null,
|
||||
@ProtoNumber(805) var customGenre: List<String>? = null
|
||||
@ProtoNumber(805) var customGenre: List<String>? = null,
|
||||
) {
|
||||
fun getMangaImpl(): MangaImpl {
|
||||
return MangaImpl().apply {
|
||||
|
@ -92,7 +92,7 @@ data class BackupManga(
|
|||
artist = customArtist,
|
||||
description = customDescription,
|
||||
genre = customGenre?.toTypedArray(),
|
||||
status = customStatus.takeUnless { it == 0 }
|
||||
status = customStatus.takeUnless { it == 0 },
|
||||
)
|
||||
}
|
||||
return null
|
||||
|
@ -120,7 +120,7 @@ data class BackupManga(
|
|||
dateAdded = manga.date_added,
|
||||
viewer = manga.readingModeType,
|
||||
viewer_flags = manga.viewer_flags.takeIf { it != -1 } ?: 0,
|
||||
chapterFlags = manga.chapter_flags
|
||||
chapterFlags = manga.chapter_flags,
|
||||
).also { backupManga ->
|
||||
customMangaManager?.getManga(manga)?.let {
|
||||
backupManga.customTitle = it.title
|
||||
|
|
|
@ -7,19 +7,19 @@ import kotlinx.serialization.protobuf.ProtoNumber
|
|||
@Serializable
|
||||
data class BrokenBackupSource(
|
||||
@ProtoNumber(0) var name: String = "",
|
||||
@ProtoNumber(1) var sourceId: Long
|
||||
@ProtoNumber(1) var sourceId: Long,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class BackupSource(
|
||||
@ProtoNumber(1) var name: String = "",
|
||||
@ProtoNumber(2) var sourceId: Long
|
||||
@ProtoNumber(2) var sourceId: Long,
|
||||
) {
|
||||
companion object {
|
||||
fun copyFrom(source: Source): BackupSource {
|
||||
return BackupSource(
|
||||
name = source.name,
|
||||
sourceId = source.id
|
||||
sourceId = source.id,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ data class BackupTracking(
|
|||
status = track.status,
|
||||
startedReadingDate = track.started_reading_date,
|
||||
finishedReadingDate = track.finished_reading_date,
|
||||
trackingUrl = track.tracking_url
|
||||
trackingUrl = track.tracking_url,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ class ChapterCache(private val context: Context) {
|
|||
PARAMETER_APP_VERSION,
|
||||
PARAMETER_VALUE_COUNT,
|
||||
// 4 pages = 115MB, 6 = ~150MB, 10 = ~200MB, 20 = ~300MB
|
||||
(PARAMETER_CACHE_SIZE * cacheSize.toFloat().pow(0.6f)).roundToLong()
|
||||
(PARAMETER_CACHE_SIZE * cacheSize.toFloat().pow(0.6f)).roundToLong(),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -85,8 +85,8 @@ class CoverCache(val context: Context) {
|
|||
context.toast(
|
||||
context.getString(
|
||||
R.string.deleted_,
|
||||
Formatter.formatFileSize(context, deletedSize)
|
||||
)
|
||||
Formatter.formatFileSize(context, deletedSize),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -108,8 +108,8 @@ class CoverCache(val context: Context) {
|
|||
context.toast(
|
||||
context.getString(
|
||||
R.string.deleted_,
|
||||
Formatter.formatFileSize(context, deletedSize)
|
||||
)
|
||||
Formatter.formatFileSize(context, deletedSize),
|
||||
),
|
||||
)
|
||||
}
|
||||
context.imageLoader.memoryCache.clear()
|
||||
|
@ -217,7 +217,7 @@ class CoverCache(val context: Context) {
|
|||
*/
|
||||
fun deleteFromCache(
|
||||
manga: Manga,
|
||||
deleteCustom: Boolean = true
|
||||
deleteCustom: Boolean = true,
|
||||
) {
|
||||
// Check if url is empty.
|
||||
if (manga.thumbnail_url.isNullOrEmpty()) return
|
||||
|
|
|
@ -46,7 +46,7 @@ class DbOpenCallback : SupportSQLiteOpenHelper.Callback(DATABASE_VERSION) {
|
|||
// Fix kissmanga covers after supporting cloudflare
|
||||
db.execSQL(
|
||||
"""UPDATE mangas SET thumbnail_url =
|
||||
REPLACE(thumbnail_url, '93.174.95.110', 'kissmanga.com') WHERE source = 4"""
|
||||
REPLACE(thumbnail_url, '93.174.95.110', 'kissmanga.com') WHERE source = 4""",
|
||||
)
|
||||
}
|
||||
if (oldVersion < 3) {
|
||||
|
|
|
@ -21,7 +21,7 @@ import eu.kanade.tachiyomi.data.database.tables.CategoryTable.TABLE
|
|||
class CategoryTypeMapping : SQLiteTypeMapping<Category>(
|
||||
CategoryPutResolver(),
|
||||
CategoryGetResolver(),
|
||||
CategoryDeleteResolver()
|
||||
CategoryDeleteResolver(),
|
||||
)
|
||||
|
||||
class CategoryPutResolver : DefaultPutResolver<Category>() {
|
||||
|
|
|
@ -29,7 +29,7 @@ import eu.kanade.tachiyomi.data.database.tables.ChapterTable.TABLE
|
|||
class ChapterTypeMapping : SQLiteTypeMapping<Chapter>(
|
||||
ChapterPutResolver(),
|
||||
ChapterGetResolver(),
|
||||
ChapterDeleteResolver()
|
||||
ChapterDeleteResolver(),
|
||||
)
|
||||
|
||||
class ChapterPutResolver : DefaultPutResolver<Chapter>() {
|
||||
|
|
|
@ -20,7 +20,7 @@ import eu.kanade.tachiyomi.data.database.tables.HistoryTable.TABLE
|
|||
class HistoryTypeMapping : SQLiteTypeMapping<History>(
|
||||
HistoryPutResolver(),
|
||||
HistoryGetResolver(),
|
||||
HistoryDeleteResolver()
|
||||
HistoryDeleteResolver(),
|
||||
)
|
||||
|
||||
open class HistoryPutResolver : DefaultPutResolver<History>() {
|
||||
|
|
|
@ -18,7 +18,7 @@ import eu.kanade.tachiyomi.data.database.tables.MangaCategoryTable.TABLE
|
|||
class MangaCategoryTypeMapping : SQLiteTypeMapping<MangaCategory>(
|
||||
MangaCategoryPutResolver(),
|
||||
MangaCategoryGetResolver(),
|
||||
MangaCategoryDeleteResolver()
|
||||
MangaCategoryDeleteResolver(),
|
||||
)
|
||||
|
||||
class MangaCategoryPutResolver : DefaultPutResolver<MangaCategory>() {
|
||||
|
|
|
@ -34,7 +34,7 @@ import eu.kanade.tachiyomi.data.database.tables.MangaTable.TABLE
|
|||
class MangaTypeMapping : SQLiteTypeMapping<Manga>(
|
||||
MangaPutResolver(),
|
||||
MangaGetResolver(),
|
||||
MangaDeleteResolver()
|
||||
MangaDeleteResolver(),
|
||||
)
|
||||
|
||||
class MangaPutResolver : DefaultPutResolver<Manga>() {
|
||||
|
|
|
@ -20,7 +20,7 @@ import eu.kanade.tachiyomi.data.database.tables.SearchMetadataTable.TABLE
|
|||
class SearchMetadataTypeMapping : SQLiteTypeMapping<SearchMetadata>(
|
||||
SearchMetadataPutResolver(),
|
||||
SearchMetadataGetResolver(),
|
||||
SearchMetadataDeleteResolver()
|
||||
SearchMetadataDeleteResolver(),
|
||||
)
|
||||
|
||||
class SearchMetadataPutResolver : DefaultPutResolver<SearchMetadata>() {
|
||||
|
@ -51,7 +51,7 @@ class SearchMetadataGetResolver : DefaultGetResolver<SearchMetadata>() {
|
|||
uploader = cursor.getString(cursor.getColumnIndex(COL_UPLOADER)),
|
||||
extra = cursor.getString(cursor.getColumnIndex(COL_EXTRA)),
|
||||
indexedExtra = cursor.getString(cursor.getColumnIndex(COL_INDEXED_EXTRA)),
|
||||
extraVersion = cursor.getInt(cursor.getColumnIndex(COL_EXTRA_VERSION))
|
||||
extraVersion = cursor.getInt(cursor.getColumnIndex(COL_EXTRA_VERSION)),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import eu.kanade.tachiyomi.data.database.tables.TrackTable.TABLE
|
|||
class TrackTypeMapping : SQLiteTypeMapping<Track>(
|
||||
TrackPutResolver(),
|
||||
TrackGetResolver(),
|
||||
TrackDeleteResolver()
|
||||
TrackDeleteResolver(),
|
||||
)
|
||||
|
||||
class TrackPutResolver : DefaultPutResolver<Track>() {
|
||||
|
|
|
@ -96,7 +96,7 @@ interface Manga : SManga {
|
|||
TYPE_MANHUA -> R.string.manhua
|
||||
TYPE_COMIC -> R.string.comic
|
||||
else -> R.string.manga
|
||||
}
|
||||
},
|
||||
).lowercase(Locale.getDefault())
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ interface Manga : SManga {
|
|||
TYPE_WEBTOON
|
||||
} else if (currentTags.any { tag -> isManhuaTag(tag) } || sourceName.contains(
|
||||
"manhua",
|
||||
true
|
||||
true,
|
||||
)
|
||||
) {
|
||||
TYPE_MANHUA
|
||||
|
@ -348,6 +348,6 @@ fun Manga.toMangaInfo(): MangaInfo {
|
|||
genres = this.getGenres() ?: emptyList(),
|
||||
key = this.url,
|
||||
status = this.status,
|
||||
title = this.title
|
||||
title = this.title,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ data class SearchMetadata(
|
|||
val indexedExtra: String?,
|
||||
|
||||
// The version of this metadata's extra. Used to track changes to the 'extra' field's schema
|
||||
val extraVersion: Int
|
||||
val extraVersion: Int,
|
||||
) {
|
||||
// Transient information attached to this piece of metadata, useful for caching
|
||||
var transientCache: Map<String, Any>? = null
|
||||
|
|
|
@ -15,7 +15,7 @@ interface CategoryQueries : DbProvider {
|
|||
Query.builder()
|
||||
.table(CategoryTable.TABLE)
|
||||
.orderBy(CategoryTable.COL_ORDER)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
@ -25,7 +25,7 @@ interface CategoryQueries : DbProvider {
|
|||
RawQuery.builder()
|
||||
.query(getCategoriesForMangaQuery())
|
||||
.args(manga.id)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ interface ChapterQueries : DbProvider {
|
|||
.table(ChapterTable.TABLE)
|
||||
.where("${ChapterTable.COL_MANGA_ID} = ?")
|
||||
.whereArgs(mangaId)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
@ -36,7 +36,7 @@ interface ChapterQueries : DbProvider {
|
|||
.query(getRecentsQuery(search.sqLite, offset, isResuming))
|
||||
// .args(date.time, startDate.time)
|
||||
.observesTables(ChapterTable.TABLE)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.withGetResolver(MangaChapterGetResolver.INSTANCE)
|
||||
.prepare()
|
||||
|
@ -53,7 +53,7 @@ interface ChapterQueries : DbProvider {
|
|||
.query(getRecentsQueryDistinct(search.sqLite, offset, isResuming))
|
||||
// .args(date.time, startDate.time)
|
||||
.observesTables(ChapterTable.TABLE)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.withGetResolver(MangaChapterGetResolver.INSTANCE)
|
||||
.prepare()
|
||||
|
@ -65,7 +65,7 @@ interface ChapterQueries : DbProvider {
|
|||
.table(ChapterTable.TABLE)
|
||||
.where("${ChapterTable.COL_ID} = ?")
|
||||
.whereArgs(id)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
@ -76,7 +76,7 @@ interface ChapterQueries : DbProvider {
|
|||
.table(ChapterTable.TABLE)
|
||||
.where("${ChapterTable.COL_URL} = ?")
|
||||
.whereArgs(url)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
@ -87,7 +87,7 @@ interface ChapterQueries : DbProvider {
|
|||
.table(ChapterTable.TABLE)
|
||||
.where("${ChapterTable.COL_URL} = ?")
|
||||
.whereArgs(url)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
@ -98,7 +98,7 @@ interface ChapterQueries : DbProvider {
|
|||
.table(ChapterTable.TABLE)
|
||||
.where("${ChapterTable.COL_URL} = ? AND ${ChapterTable.COL_MANGA_ID} = ?")
|
||||
.whereArgs(url, mangaId)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ interface HistoryQueries : DbProvider {
|
|||
.query(getRecentMangasLimitQuery(search.sqLite, offset, isResuming))
|
||||
// .args(date.time, startDate.time)
|
||||
.observesTables(HistoryTable.TABLE)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.withGetResolver(MangaChapterHistoryGetResolver.INSTANCE)
|
||||
.prepare()
|
||||
|
@ -65,7 +65,7 @@ interface HistoryQueries : DbProvider {
|
|||
.query(getRecentHistoryUngrouped(search.sqLite, offset, isResuming))
|
||||
// .args(date.time, startDate.time)
|
||||
.observesTables(HistoryTable.TABLE)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.withGetResolver(MangaChapterHistoryGetResolver.INSTANCE)
|
||||
.prepare()
|
||||
|
@ -85,12 +85,12 @@ interface HistoryQueries : DbProvider {
|
|||
includeRead,
|
||||
endless,
|
||||
offset,
|
||||
isResuming
|
||||
)
|
||||
isResuming,
|
||||
),
|
||||
)
|
||||
// .args(date.time, startDate.time)
|
||||
.observesTables(HistoryTable.TABLE)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.withGetResolver(MangaChapterHistoryGetResolver.INSTANCE)
|
||||
.prepare()
|
||||
|
@ -102,7 +102,7 @@ interface HistoryQueries : DbProvider {
|
|||
.query(getHistoryByMangaId())
|
||||
.args(mangaId)
|
||||
.observesTables(HistoryTable.TABLE)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
@ -113,7 +113,7 @@ interface HistoryQueries : DbProvider {
|
|||
.query(getHistoryByChapterUrl())
|
||||
.args(chapterUrl)
|
||||
.observesTables(HistoryTable.TABLE)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
@ -151,7 +151,7 @@ interface HistoryQueries : DbProvider {
|
|||
.byQuery(
|
||||
DeleteQuery.builder()
|
||||
.table(HistoryTable.TABLE)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
@ -161,7 +161,7 @@ interface HistoryQueries : DbProvider {
|
|||
.table(HistoryTable.TABLE)
|
||||
.where("${HistoryTable.COL_LAST_READ} = ?")
|
||||
.whereArgs(0)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ interface MangaCategoryQueries : DbProvider {
|
|||
.table(MangaCategoryTable.TABLE)
|
||||
.where("${MangaCategoryTable.COL_MANGA_ID} IN (${Queries.placeholders(mangas.size)})")
|
||||
.whereArgs(*mangas.map { it.id }.toTypedArray())
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ interface MangaQueries : DbProvider {
|
|||
.withQuery(
|
||||
Query.builder()
|
||||
.table(MangaTable.TABLE)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
@ -39,7 +39,7 @@ interface MangaQueries : DbProvider {
|
|||
RawQuery.builder()
|
||||
.query(libraryQuery)
|
||||
.observesTables(MangaTable.TABLE, ChapterTable.TABLE, MangaCategoryTable.TABLE, CategoryTable.TABLE)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.withGetResolver(LibraryMangaGetResolver.INSTANCE)
|
||||
.prepare()
|
||||
|
@ -67,7 +67,7 @@ interface MangaQueries : DbProvider {
|
|||
.where("${MangaTable.COL_FAVORITE} = ?")
|
||||
.whereArgs(1)
|
||||
.orderBy(MangaTable.COL_TITLE)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
@ -78,7 +78,7 @@ interface MangaQueries : DbProvider {
|
|||
.table(MangaTable.TABLE)
|
||||
.where("${MangaTable.COL_URL} = ? AND ${MangaTable.COL_SOURCE} = ?")
|
||||
.whereArgs(url, sourceId)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
@ -89,7 +89,7 @@ interface MangaQueries : DbProvider {
|
|||
.table(MangaTable.TABLE)
|
||||
.where("${MangaTable.COL_ID} = ?")
|
||||
.whereArgs(id)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
@ -99,7 +99,7 @@ interface MangaQueries : DbProvider {
|
|||
RawQuery.builder()
|
||||
.query(getSourceIdsWithNonLibraryMangaQuery())
|
||||
.observesTables(MangaTable.TABLE)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.withGetResolver(SourceIdMangaCountGetResolver.INSTANCE)
|
||||
.prepare()
|
||||
|
@ -163,7 +163,7 @@ interface MangaQueries : DbProvider {
|
|||
.table(MangaTable.TABLE)
|
||||
.where("${MangaTable.COL_FAVORITE} = ? AND ${MangaTable.COL_SOURCE} IN (${Queries.placeholders(sourceIds.size)})")
|
||||
.whereArgs(0, *sourceIds.toTypedArray())
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
@ -171,7 +171,7 @@ interface MangaQueries : DbProvider {
|
|||
.byQuery(
|
||||
DeleteQuery.builder()
|
||||
.table(MangaTable.TABLE)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
@ -181,7 +181,7 @@ interface MangaQueries : DbProvider {
|
|||
RawQuery.builder()
|
||||
.query(getLastReadMangaQuery())
|
||||
.observesTables(MangaTable.TABLE)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
@ -191,7 +191,7 @@ interface MangaQueries : DbProvider {
|
|||
RawQuery.builder()
|
||||
.query(getLastFetchedMangaQuery())
|
||||
.observesTables(MangaTable.TABLE)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ fun getRecentsQueryDistinct(search: String, offset: Int = 0, isResuming: Boolean
|
|||
fun getRecentMangasLimitQuery(
|
||||
search: String = "",
|
||||
offset: Int = 0,
|
||||
isResuming: Boolean
|
||||
isResuming: Boolean,
|
||||
) =
|
||||
"""
|
||||
SELECT ${Manga.TABLE}.${Manga.COL_URL} as mangaUrl, ${Manga.TABLE}.*, ${Chapter.TABLE}.*, ${History.TABLE}.*
|
||||
|
@ -137,7 +137,7 @@ fun getRecentMangasLimitQuery(
|
|||
fun getRecentHistoryUngrouped(
|
||||
search: String = "",
|
||||
offset: Int = 0,
|
||||
isResuming: Boolean
|
||||
isResuming: Boolean,
|
||||
) =
|
||||
"""
|
||||
SELECT ${Manga.TABLE}.${Manga.COL_URL} as mangaUrl, ${Manga.TABLE}.*, ${Chapter.TABLE}.*, ${History.TABLE}.*
|
||||
|
@ -166,7 +166,7 @@ fun getAllRecentsType(
|
|||
includeRead: Boolean,
|
||||
endless: Boolean,
|
||||
offset: Int = 0,
|
||||
isResuming: Boolean
|
||||
isResuming: Boolean,
|
||||
) = """
|
||||
SELECT * FROM
|
||||
(SELECT mangas.url as mangaUrl, mangas.*, chapters.*, history.*
|
||||
|
|
|
@ -15,7 +15,7 @@ interface SearchMetadataQueries : DbProvider {
|
|||
.table(SearchMetadataTable.TABLE)
|
||||
.where("${SearchMetadataTable.COL_MANGA_ID} = ?")
|
||||
.whereArgs(mangaId)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
@ -24,7 +24,7 @@ interface SearchMetadataQueries : DbProvider {
|
|||
.withQuery(
|
||||
Query.builder()
|
||||
.table(SearchMetadataTable.TABLE)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
@ -35,7 +35,7 @@ interface SearchMetadataQueries : DbProvider {
|
|||
.table(SearchMetadataTable.TABLE)
|
||||
.where("${SearchMetadataTable.COL_INDEXED_EXTRA} = ?")
|
||||
.whereArgs(extra)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
@ -46,7 +46,7 @@ interface SearchMetadataQueries : DbProvider {
|
|||
fun deleteAllSearchMetadata() = db.delete().byQuery(
|
||||
DeleteQuery.builder()
|
||||
.table(SearchMetadataTable.TABLE)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ interface TrackQueries : DbProvider {
|
|||
.table(TrackTable.TABLE)
|
||||
.where("${TrackTable.COL_MANGA_ID} = ?")
|
||||
.whereArgs(mangaId)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
|
||||
|
@ -33,7 +33,7 @@ interface TrackQueries : DbProvider {
|
|||
.table(TrackTable.TABLE)
|
||||
.where("${TrackTable.COL_MANGA_ID} = ? AND ${TrackTable.COL_SYNC_ID} = ?")
|
||||
.whereArgs(manga.id, sync.id)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.prepare()
|
||||
}
|
||||
|
|
|
@ -29,6 +29,6 @@ class ChapterKnownBackupPutResolver : PutResolver<Chapter>() {
|
|||
contentValuesOf(
|
||||
ChapterTable.COL_READ to chapter.read,
|
||||
ChapterTable.COL_BOOKMARK to chapter.bookmark,
|
||||
ChapterTable.COL_LAST_PAGE_READ to chapter.last_page_read
|
||||
ChapterTable.COL_LAST_PAGE_READ to chapter.last_page_read,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class HistoryLastReadPutResolver : HistoryPutResolver() {
|
|||
.table(updateQuery.table())
|
||||
.where(updateQuery.where())
|
||||
.whereArgs(updateQuery.whereArgs())
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
|
||||
val putResult = cursor.use { putCursor ->
|
||||
|
@ -57,6 +57,6 @@ class HistoryLastReadPutResolver : HistoryPutResolver() {
|
|||
*/
|
||||
private fun mapToUpdateContentValues(history: History) =
|
||||
contentValuesOf(
|
||||
HistoryTable.COL_LAST_READ to history.last_read
|
||||
HistoryTable.COL_LAST_READ to history.last_read,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -26,6 +26,6 @@ class MangaFilteredScanlatorsPutResolver : PutResolver<Manga>() {
|
|||
.build()
|
||||
|
||||
fun mapToContentValues(manga: Manga) = contentValuesOf(
|
||||
MangaTable.COL_FILTERED_SCANLATORS to manga.filtered_scanlators
|
||||
MangaTable.COL_FILTERED_SCANLATORS to manga.filtered_scanlators,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -38,6 +38,6 @@ class MangaFlagsPutResolver(private val colName: String, private val fieldGetter
|
|||
|
||||
fun mapToContentValues(manga: Manga) =
|
||||
contentValuesOf(
|
||||
colName to fieldGetter.get(manga)
|
||||
colName to fieldGetter.get(manga),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class DownloadCache(
|
|||
private val context: Context,
|
||||
private val provider: DownloadProvider,
|
||||
private val sourceManager: SourceManager,
|
||||
private val preferences: PreferencesHelper = Injekt.get()
|
||||
private val preferences: PreferencesHelper = Injekt.get(),
|
||||
) {
|
||||
|
||||
/**
|
||||
|
@ -250,7 +250,7 @@ class DownloadCache(
|
|||
*/
|
||||
private class RootDirectory(
|
||||
val dir: UniFile,
|
||||
var files: Map<Long, SourceDirectory> = hashMapOf()
|
||||
var files: Map<Long, SourceDirectory> = hashMapOf(),
|
||||
)
|
||||
|
||||
/**
|
||||
|
@ -258,7 +258,7 @@ class DownloadCache(
|
|||
*/
|
||||
private class SourceDirectory(
|
||||
val dir: UniFile,
|
||||
var files: Map<Long, MutableSet<String>> = hashMapOf()
|
||||
var files: Map<Long, MutableSet<String>> = hashMapOf(),
|
||||
)
|
||||
|
||||
/**
|
||||
|
@ -266,7 +266,7 @@ class DownloadCache(
|
|||
*/
|
||||
private class MangaDirectory(
|
||||
val dir: UniFile,
|
||||
var files: MutableSet<String> = hashSetOf()
|
||||
var files: MutableSet<String> = hashSetOf(),
|
||||
)
|
||||
|
||||
/**
|
||||
|
|
|
@ -259,7 +259,7 @@ class DownloadManager(val context: Context) {
|
|||
provider.findChapterDirs(chapters, manga, source) + provider.findTempChapterDirs(
|
||||
chapters,
|
||||
manga,
|
||||
source
|
||||
source,
|
||||
)
|
||||
chapterDirs.forEach { it.delete() }
|
||||
cache.removeChapters(chapters, manga)
|
||||
|
|
|
@ -83,7 +83,7 @@ internal class DownloadNotifier(private val context: Context) {
|
|||
addAction(
|
||||
R.drawable.ic_pause_24dp,
|
||||
context.getString(R.string.pause),
|
||||
NotificationReceiver.pauseDownloadsPendingBroadcast(context)
|
||||
NotificationReceiver.pauseDownloadsPendingBroadcast(context),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -93,17 +93,17 @@ internal class DownloadNotifier(private val context: Context) {
|
|||
val chapter = download.chapter.name.replaceFirst(
|
||||
"$quotedTitle[\\s]*[-]*[\\s]*"
|
||||
.toRegex(RegexOption.IGNORE_CASE),
|
||||
""
|
||||
"",
|
||||
)
|
||||
setContentTitle("$title - $chapter".chop(30))
|
||||
setContentText(
|
||||
context.getString(R.string.downloading)
|
||||
context.getString(R.string.downloading),
|
||||
)
|
||||
} else {
|
||||
setContentTitle(
|
||||
context.getString(
|
||||
R.string.downloading
|
||||
)
|
||||
R.string.downloading,
|
||||
),
|
||||
)
|
||||
setContentText(null)
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ internal class DownloadNotifier(private val context: Context) {
|
|||
addAction(
|
||||
R.drawable.ic_pause_24dp,
|
||||
context.getString(R.string.pause),
|
||||
NotificationReceiver.pauseDownloadsPendingBroadcast(context)
|
||||
NotificationReceiver.pauseDownloadsPendingBroadcast(context),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ internal class DownloadNotifier(private val context: Context) {
|
|||
val quotedTitle = Pattern.quote(title)
|
||||
val chapter = download.chapter.name.replaceFirst(
|
||||
"$quotedTitle[\\s]*[-]*[\\s]*".toRegex(RegexOption.IGNORE_CASE),
|
||||
""
|
||||
"",
|
||||
)
|
||||
setContentTitle("$title - $chapter".chop(30))
|
||||
setContentText(downloadingProgressText)
|
||||
|
@ -180,13 +180,13 @@ internal class DownloadNotifier(private val context: Context) {
|
|||
addAction(
|
||||
R.drawable.ic_play_arrow_24dp,
|
||||
context.getString(R.string.resume),
|
||||
NotificationReceiver.resumeDownloadsPendingBroadcast(context)
|
||||
NotificationReceiver.resumeDownloadsPendingBroadcast(context),
|
||||
)
|
||||
// Clear action
|
||||
addAction(
|
||||
R.drawable.ic_close_24dp,
|
||||
context.getString(R.string.cancel_all),
|
||||
NotificationReceiver.clearDownloadsPendingBroadcast(context)
|
||||
NotificationReceiver.clearDownloadsPendingBroadcast(context),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -228,13 +228,13 @@ internal class DownloadNotifier(private val context: Context) {
|
|||
setSmallIcon(R.drawable.ic_warning_white_24dp)
|
||||
setStyle(
|
||||
NotificationCompat.BigTextStyle()
|
||||
.bigText(context.getString(R.string.download_queue_size_warning))
|
||||
.bigText(context.getString(R.string.download_queue_size_warning)),
|
||||
)
|
||||
setContentIntent(
|
||||
NotificationHandler.openUrl(
|
||||
context,
|
||||
LibraryUpdateNotifier.HELP_WARNING_URL
|
||||
)
|
||||
LibraryUpdateNotifier.HELP_WARNING_URL,
|
||||
),
|
||||
)
|
||||
setTimeoutAfter(30000)
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ internal class DownloadNotifier(private val context: Context) {
|
|||
fun onError(
|
||||
error: String? = null,
|
||||
chapter: String? = null,
|
||||
customIntent: Intent? = null
|
||||
customIntent: Intent? = null,
|
||||
) {
|
||||
// Create notification
|
||||
with(notification) {
|
||||
|
@ -264,8 +264,8 @@ internal class DownloadNotifier(private val context: Context) {
|
|||
setContentText(error ?: context.getString(R.string.could_not_download_unexpected_error))
|
||||
setStyle(
|
||||
NotificationCompat.BigTextStyle().bigText(
|
||||
error ?: context.getString(R.string.could_not_download_unexpected_error)
|
||||
)
|
||||
error ?: context.getString(R.string.could_not_download_unexpected_error),
|
||||
),
|
||||
)
|
||||
setSmallIcon(android.R.drawable.stat_sys_warning)
|
||||
setCategory(NotificationCompat.CATEGORY_ERROR)
|
||||
|
@ -277,8 +277,8 @@ internal class DownloadNotifier(private val context: Context) {
|
|||
context,
|
||||
0,
|
||||
customIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
setContentIntent(NotificationHandler.openDownloadManagerPendingActivity(context))
|
||||
|
|
|
@ -164,7 +164,7 @@ class DownloadProvider(private val context: Context) {
|
|||
fun findUnmatchedChapterDirs(
|
||||
chapters: List<Chapter>,
|
||||
manga: Manga,
|
||||
source: Source
|
||||
source: Source,
|
||||
): List<UniFile> {
|
||||
val mangaDir = findMangaDir(manga, source) ?: return emptyList()
|
||||
val chapterNameHashSet = chapters.map { it.name }.toHashSet()
|
||||
|
@ -231,7 +231,7 @@ class DownloadProvider(private val context: Context) {
|
|||
fun getChapterDirName(chapter: Chapter): String {
|
||||
return DiskUtil.buildValidFilename(
|
||||
if (chapter.scanlator != null) "${chapter.scanlator}_${chapter.name}"
|
||||
else chapter.name
|
||||
else chapter.name,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,7 @@ class DownloadProvider(private val context: Context) {
|
|||
return listOf(
|
||||
getChapterDirName(chapter),
|
||||
// Legacy chapter directory name used in v0.8.4 and before
|
||||
DiskUtil.buildValidFilename(chapter.name)
|
||||
DiskUtil.buildValidFilename(chapter.name),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ class DownloadService : Service() {
|
|||
|
||||
override fun onCapabilitiesChanged(
|
||||
network: Network,
|
||||
networkCapabilities: NetworkCapabilities
|
||||
networkCapabilities: NetworkCapabilities,
|
||||
) {
|
||||
onNetworkStateChanged()
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ class Downloader(
|
|||
private val context: Context,
|
||||
private val provider: DownloadProvider,
|
||||
private val cache: DownloadCache,
|
||||
private val sourceManager: SourceManager
|
||||
private val sourceManager: SourceManager,
|
||||
) {
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
private val chapterCache: ChapterCache by injectLazy()
|
||||
|
@ -227,7 +227,7 @@ class Downloader(
|
|||
downloadChapter(download).subscribeOn(Schedulers.io())
|
||||
}
|
||||
},
|
||||
5
|
||||
5,
|
||||
)
|
||||
.onBackpressureLatest()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
@ -239,7 +239,7 @@ class Downloader(
|
|||
DownloadService.stop(context)
|
||||
Timber.e(error)
|
||||
notifier.onError(error.message)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -323,13 +323,13 @@ class Downloader(
|
|||
) {
|
||||
val intent = Intent(
|
||||
Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION,
|
||||
"package:${context.packageName}".toUri()
|
||||
"package:${context.packageName}".toUri(),
|
||||
)
|
||||
|
||||
notifier.onError(
|
||||
context.getString(R.string.external_storage_download_notice),
|
||||
download.chapter.name,
|
||||
intent
|
||||
intent,
|
||||
)
|
||||
return@defer Observable.just(download)
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ class Downloader(
|
|||
private fun getOrDownloadImage(
|
||||
page: Page,
|
||||
download: Download,
|
||||
tmpDir: UniFile
|
||||
tmpDir: UniFile,
|
||||
): Observable<Page> {
|
||||
// If the image URL is empty, do nothing
|
||||
if (page.imageUrl == null) {
|
||||
|
@ -439,7 +439,7 @@ class Downloader(
|
|||
private fun moveImageFromCache(
|
||||
cacheFile: File,
|
||||
tmpDir: UniFile,
|
||||
filename: String
|
||||
filename: String,
|
||||
): Observable<UniFile> {
|
||||
return Observable.just(cacheFile).map {
|
||||
val tmpFile = tmpDir.createFile("$filename.tmp")
|
||||
|
@ -467,7 +467,7 @@ class Downloader(
|
|||
page: Page,
|
||||
source: HttpSource,
|
||||
tmpDir: UniFile,
|
||||
filename: String
|
||||
filename: String,
|
||||
): Observable<UniFile> {
|
||||
page.status = Page.DOWNLOAD_IMAGE
|
||||
page.progress = 0
|
||||
|
@ -519,7 +519,7 @@ class Downloader(
|
|||
download: Download,
|
||||
mangaDir: UniFile,
|
||||
tmpDir: UniFile,
|
||||
dirname: String
|
||||
dirname: String,
|
||||
) {
|
||||
// Ensure that the chapter folder has all the images.
|
||||
val downloadedImages = tmpDir.listFiles().orEmpty().filterNot { it.name!!.endsWith(".tmp") }
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.concurrent.CopyOnWriteArrayList
|
|||
|
||||
class DownloadQueue(
|
||||
private val store: DownloadStore,
|
||||
private val queue: MutableList<Download> = CopyOnWriteArrayList<Download>()
|
||||
private val queue: MutableList<Download> = CopyOnWriteArrayList<Download>(),
|
||||
) :
|
||||
List<Download> by queue {
|
||||
|
||||
|
|
|
@ -19,12 +19,12 @@ class ByteArrayFetcher : Fetcher<ByteArray> {
|
|||
pool: BitmapPool,
|
||||
data: ByteArray,
|
||||
size: Size,
|
||||
options: Options
|
||||
options: Options,
|
||||
): FetchResult {
|
||||
return SourceResult(
|
||||
source = ByteArrayInputStream(data).source().buffer(),
|
||||
mimeType = "image/gif",
|
||||
dataSource = DataSource.MEMORY
|
||||
dataSource = DataSource.MEMORY,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import eu.kanade.tachiyomi.util.system.getResourceColor
|
|||
class CoverViewTarget(
|
||||
view: ImageView,
|
||||
val progress: View? = null,
|
||||
val scaleType: ImageView.ScaleType = ImageView.ScaleType.CENTER_CROP
|
||||
val scaleType: ImageView.ScaleType = ImageView.ScaleType.CENTER_CROP,
|
||||
) : ImageViewTarget(view) {
|
||||
|
||||
override fun onError(error: Drawable?) {
|
||||
|
@ -21,7 +21,7 @@ class CoverViewTarget(
|
|||
val vector = VectorDrawableCompat.create(
|
||||
view.context.resources,
|
||||
R.drawable.ic_broken_image_24dp,
|
||||
null
|
||||
null,
|
||||
)
|
||||
vector?.setTint(view.context.getResourceColor(android.R.attr.textColorSecondary))
|
||||
view.setImageDrawable(vector)
|
||||
|
|
|
@ -17,7 +17,7 @@ import uy.kohesive.injekt.injectLazy
|
|||
|
||||
class LibraryMangaImageTarget(
|
||||
override val view: ImageView,
|
||||
val manga: Manga
|
||||
val manga: Manga,
|
||||
) : ImageViewTarget(view) {
|
||||
|
||||
private val coverCache: CoverCache by injectLazy()
|
||||
|
@ -46,7 +46,7 @@ class LibraryMangaImageTarget(
|
|||
inline fun ImageView.loadManga(
|
||||
manga: Manga,
|
||||
imageLoader: ImageLoader = context.imageLoader,
|
||||
builder: ImageRequest.Builder.() -> Unit = {}
|
||||
builder: ImageRequest.Builder.() -> Unit = {},
|
||||
): Disposable {
|
||||
val request = ImageRequest.Builder(context)
|
||||
.data(manga)
|
||||
|
|
|
@ -92,7 +92,7 @@ class MangaFetcher : Fetcher<Manga> {
|
|||
} else {
|
||||
false
|
||||
},
|
||||
shouldFetchRemotely
|
||||
shouldFetchRemotely,
|
||||
)
|
||||
|
||||
if (options.diskCachePolicy.writeEnabled) {
|
||||
|
@ -159,7 +159,7 @@ class MangaFetcher : Fetcher<Manga> {
|
|||
}
|
||||
|
||||
private suspend fun awaitGetCall(manga: Manga, onlyCache: Boolean = false, forceNetwork: Boolean): Pair<Response,
|
||||
ResponseBody> {
|
||||
ResponseBody,> {
|
||||
val call = getCall(manga, onlyCache, forceNetwork)
|
||||
val response = call.await()
|
||||
return response to checkNotNull(response.body) { "Null response source" }
|
||||
|
@ -221,7 +221,7 @@ class MangaFetcher : Fetcher<Manga> {
|
|||
return SourceResult(
|
||||
source = file.source().buffer(),
|
||||
mimeType = "image/*",
|
||||
dataSource = DataSource.DISK
|
||||
dataSource = DataSource.DISK,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ class CustomMangaManager(val context: Context) {
|
|||
artist,
|
||||
description,
|
||||
genre?.split(", ")?.toTypedArray(),
|
||||
status.takeUnless { it == -1 }
|
||||
status.takeUnless { it == -1 },
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ class CustomMangaManager(val context: Context) {
|
|||
val artist: String? = null,
|
||||
val description: String? = null,
|
||||
val genre: Array<String>? = null,
|
||||
val status: Int? = null
|
||||
val status: Int? = null,
|
||||
) {
|
||||
|
||||
fun toManga() = MangaImpl().apply {
|
||||
|
|
|
@ -52,7 +52,7 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
|||
interval.toLong(),
|
||||
TimeUnit.HOURS,
|
||||
10,
|
||||
TimeUnit.MINUTES
|
||||
TimeUnit.MINUTES,
|
||||
)
|
||||
.addTag(TAG)
|
||||
.setConstraints(constraints)
|
||||
|
|
|
@ -82,7 +82,7 @@ class LibraryUpdateNotifier(private val context: Context) {
|
|||
.setContentTitle("${context.getString(R.string.updating_library)} (${current + 1}/$total)")
|
||||
.setContentText(if (preferences.hideNotificationContent()) null else manga.title)
|
||||
.setProgress(total, current, false)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -106,18 +106,18 @@ class LibraryUpdateNotifier(private val context: Context) {
|
|||
NotificationCompat.BigTextStyle().bigText(
|
||||
errors.joinToString("\n") {
|
||||
it.chop(TITLE_MAX_LEN)
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
setContentIntent(pendingIntent)
|
||||
setSmallIcon(R.drawable.ic_tachij2k_notification)
|
||||
addAction(
|
||||
R.drawable.nnf_ic_file_folder,
|
||||
context.getString(R.string.open_log),
|
||||
pendingIntent
|
||||
pendingIntent,
|
||||
)
|
||||
}
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -141,18 +141,18 @@ class LibraryUpdateNotifier(private val context: Context) {
|
|||
NotificationCompat.BigTextStyle().bigText(
|
||||
skips.joinToString("\n") {
|
||||
it.chop(TITLE_MAX_LEN)
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
setContentIntent(NotificationHandler.openUrl(context, HELP_SKIPPED_URL))
|
||||
setSmallIcon(R.drawable.ic_tachij2k_notification)
|
||||
addAction(
|
||||
R.drawable.nnf_ic_file_folder,
|
||||
context.getString(R.string.open_log),
|
||||
NotificationReceiver.openErrorOrSkippedLogPendingActivity(context, uri)
|
||||
NotificationReceiver.openErrorOrSkippedLogPendingActivity(context, uri),
|
||||
)
|
||||
}
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ class LibraryUpdateNotifier(private val context: Context) {
|
|||
val request = ImageRequest.Builder(context).data(manga)
|
||||
.parameters(
|
||||
Parameters.Builder().set(MangaFetcher.onlyCache, true)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.networkCachePolicy(CachePolicy.READ_ONLY)
|
||||
.transformations(CircleCropTransformation())
|
||||
|
@ -199,7 +199,7 @@ class LibraryUpdateNotifier(private val context: Context) {
|
|||
context.resources.getQuantityString(
|
||||
R.plurals.notification_and_n_more,
|
||||
(chapterNames.size - (MAX_CHAPTERS - 1)),
|
||||
(chapterNames.size - (MAX_CHAPTERS - 1))
|
||||
(chapterNames.size - (MAX_CHAPTERS - 1)),
|
||||
)
|
||||
} else chapterNames.joinToString(", ")
|
||||
setContentText(chaptersNames)
|
||||
|
@ -210,8 +210,8 @@ class LibraryUpdateNotifier(private val context: Context) {
|
|||
NotificationReceiver.openChapterPendingActivity(
|
||||
context,
|
||||
manga,
|
||||
chapters.first()
|
||||
)
|
||||
chapters.first(),
|
||||
),
|
||||
)
|
||||
addAction(
|
||||
R.drawable.ic_eye_24dp,
|
||||
|
@ -220,8 +220,8 @@ class LibraryUpdateNotifier(private val context: Context) {
|
|||
context,
|
||||
manga,
|
||||
chapters,
|
||||
Notifications.ID_NEW_CHAPTERS
|
||||
)
|
||||
Notifications.ID_NEW_CHAPTERS,
|
||||
),
|
||||
)
|
||||
addAction(
|
||||
R.drawable.ic_book_24dp,
|
||||
|
@ -229,13 +229,13 @@ class LibraryUpdateNotifier(private val context: Context) {
|
|||
NotificationReceiver.openChapterPendingActivity(
|
||||
context,
|
||||
manga,
|
||||
Notifications.ID_NEW_CHAPTERS
|
||||
)
|
||||
Notifications.ID_NEW_CHAPTERS,
|
||||
),
|
||||
)
|
||||
setAutoCancel(true)
|
||||
},
|
||||
manga.id.hashCode()
|
||||
)
|
||||
manga.id.hashCode(),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -253,8 +253,8 @@ class LibraryUpdateNotifier(private val context: Context) {
|
|||
context.resources.getQuantityString(
|
||||
R.plurals.for_n_titles,
|
||||
updates.size,
|
||||
updates.size
|
||||
)
|
||||
updates.size,
|
||||
),
|
||||
)
|
||||
if (!preferences.hideNotificationContent()) {
|
||||
setStyle(
|
||||
|
@ -262,8 +262,8 @@ class LibraryUpdateNotifier(private val context: Context) {
|
|||
.bigText(
|
||||
updates.keys.joinToString("\n") {
|
||||
it.title.chop(45)
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
} else if (!preferences.hideNotificationContent()) {
|
||||
|
@ -275,7 +275,7 @@ class LibraryUpdateNotifier(private val context: Context) {
|
|||
setGroupSummary(true)
|
||||
setContentIntent(getNotificationIntent())
|
||||
setAutoCancel(true)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
notifications.forEach {
|
||||
|
|
|
@ -78,7 +78,7 @@ class LibraryUpdateService(
|
|||
val preferences: PreferencesHelper = Injekt.get(),
|
||||
val downloadManager: DownloadManager = Injekt.get(),
|
||||
val trackManager: TrackManager = Injekt.get(),
|
||||
private val mangaShortcutManager: MangaShortcutManager = Injekt.get()
|
||||
private val mangaShortcutManager: MangaShortcutManager = Injekt.get(),
|
||||
) : Service() {
|
||||
|
||||
/**
|
||||
|
@ -374,7 +374,7 @@ class LibraryUpdateService(
|
|||
val skippedFile = writeErrorFile(
|
||||
skippedUpdates,
|
||||
"skipped",
|
||||
getString(R.string.learn_more_at_, LibraryUpdateNotifier.HELP_SKIPPED_URL)
|
||||
getString(R.string.learn_more_at_, LibraryUpdateNotifier.HELP_SKIPPED_URL),
|
||||
).getUriCompat(this)
|
||||
notifier.showUpdateSkippedNotification(skippedUpdates.map { it.key.title }, skippedFile)
|
||||
}
|
||||
|
@ -410,7 +410,7 @@ class LibraryUpdateService(
|
|||
private suspend fun updateMangaChapters(
|
||||
manga: LibraryManga,
|
||||
progress: Int,
|
||||
shouldDownload: Boolean
|
||||
shouldDownload: Boolean,
|
||||
):
|
||||
Boolean {
|
||||
try {
|
||||
|
@ -442,7 +442,7 @@ class LibraryUpdateService(
|
|||
}
|
||||
}
|
||||
if (newChapters.first.size + newChapters.second.size > 0) listener?.onUpdateManga(
|
||||
manga
|
||||
manga,
|
||||
)
|
||||
}
|
||||
return hasDownloads
|
||||
|
@ -481,7 +481,7 @@ class LibraryUpdateService(
|
|||
notifier.showProgressNotification(
|
||||
manga,
|
||||
count.andIncrement,
|
||||
mangaToUpdate.size
|
||||
mangaToUpdate.size,
|
||||
)
|
||||
|
||||
val networkManga = try {
|
||||
|
@ -628,7 +628,7 @@ class LibraryUpdateService(
|
|||
context: Context,
|
||||
category: Category? = null,
|
||||
target: Target = Target.CHAPTERS,
|
||||
mangaToUse: List<LibraryManga>? = null
|
||||
mangaToUse: List<LibraryManga>? = null,
|
||||
): Boolean {
|
||||
return if (!isRunning()) {
|
||||
val intent = Intent(context, LibraryUpdateService::class.java).apply {
|
||||
|
@ -637,7 +637,7 @@ class LibraryUpdateService(
|
|||
putExtra(KEY_CATEGORY, id)
|
||||
if (mangaToUse != null) putExtra(
|
||||
KEY_MANGAS,
|
||||
mangaToUse.mapNotNull { it.id }.toLongArray()
|
||||
mangaToUse.mapNotNull { it.id }.toLongArray(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||
ACTION_DELETE_IMAGE -> deleteImage(
|
||||
context,
|
||||
intent.getStringExtra(EXTRA_FILE_LOCATION)!!,
|
||||
intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1)
|
||||
intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1),
|
||||
)
|
||||
// Cancel library update and dismiss notification
|
||||
ACTION_CANCEL_LIBRARY_UPDATE -> cancelLibraryUpdate(context)
|
||||
|
@ -73,14 +73,14 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||
shareBackup(
|
||||
context,
|
||||
intent.getParcelableExtra(EXTRA_URI)!!,
|
||||
intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1)
|
||||
intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1),
|
||||
)
|
||||
ACTION_MARK_AS_READ -> {
|
||||
val notificationId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1)
|
||||
if (notificationId > -1) dismissNotification(
|
||||
context,
|
||||
notificationId,
|
||||
intent.getIntExtra(EXTRA_GROUP_ID, 0)
|
||||
intent.getIntExtra(EXTRA_GROUP_ID, 0),
|
||||
)
|
||||
val urls = intent.getStringArrayExtra(EXTRA_CHAPTER_URL) ?: return
|
||||
val mangaId = intent.getLongExtra(EXTRA_MANGA_ID, -1)
|
||||
|
@ -93,7 +93,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||
context,
|
||||
intent.getParcelableExtra(EXTRA_URI)!!,
|
||||
"text/plain",
|
||||
intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1)
|
||||
intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||
context: Context,
|
||||
notificationId: Int,
|
||||
groupId: Int? =
|
||||
null
|
||||
null,
|
||||
) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
val groupKey = context.notificationManager.activeNotifications.find {
|
||||
|
@ -385,7 +385,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||
context,
|
||||
0,
|
||||
shareIntent,
|
||||
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -417,14 +417,14 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||
context: Context,
|
||||
manga: Manga,
|
||||
chapter:
|
||||
Chapter
|
||||
Chapter,
|
||||
): PendingIntent {
|
||||
val newIntent = ReaderActivity.newIntent(context, manga, chapter)
|
||||
return PendingIntent.getActivity(
|
||||
context,
|
||||
manga.id.hashCode(),
|
||||
newIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -446,7 +446,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||
context,
|
||||
downloadLink.hashCode(),
|
||||
newIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -468,7 +468,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||
context,
|
||||
manga.id.hashCode(),
|
||||
newIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -502,7 +502,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||
context,
|
||||
0,
|
||||
newIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -517,7 +517,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||
manga: Manga,
|
||||
chapters:
|
||||
Array<Chapter>,
|
||||
groupId: Int
|
||||
groupId: Int,
|
||||
):
|
||||
PendingIntent {
|
||||
val newIntent = Intent(context, NotificationReceiver::class.java).apply {
|
||||
|
|
|
@ -85,7 +85,7 @@ object Notifications {
|
|||
|
||||
private val deprecatedChannels = listOf(
|
||||
"backup_restore_channel",
|
||||
"library_channel"
|
||||
"library_channel",
|
||||
)
|
||||
|
||||
/**
|
||||
|
@ -102,11 +102,11 @@ object Notifications {
|
|||
listOf(
|
||||
NotificationChannelGroup(
|
||||
GROUP_BACKUP_RESTORE,
|
||||
context.getString(R.string.backup_and_restore)
|
||||
context.getString(R.string.backup_and_restore),
|
||||
),
|
||||
NotificationChannelGroup(
|
||||
GROUP_EXTENSION_UPDATES,
|
||||
context.getString(R.string.extension_updates)
|
||||
context.getString(R.string.extension_updates),
|
||||
),
|
||||
NotificationChannelGroup(GROUP_LIBRARY, context.getString(R.string.library)),
|
||||
).forEach(context.notificationManager::createNotificationChannelGroup)
|
||||
|
@ -115,12 +115,12 @@ object Notifications {
|
|||
NotificationChannel(
|
||||
CHANNEL_COMMON,
|
||||
context.getString(R.string.common),
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
NotificationManager.IMPORTANCE_LOW,
|
||||
),
|
||||
NotificationChannel(
|
||||
CHANNEL_LIBRARY_PROGRESS,
|
||||
context.getString(R.string.updating_library),
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
NotificationManager.IMPORTANCE_LOW,
|
||||
).apply {
|
||||
group = GROUP_LIBRARY
|
||||
setShowBadge(false)
|
||||
|
@ -128,7 +128,7 @@ object Notifications {
|
|||
NotificationChannel(
|
||||
CHANNEL_LIBRARY_ERROR,
|
||||
context.getString(R.string.channel_errors),
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
NotificationManager.IMPORTANCE_LOW,
|
||||
).apply {
|
||||
group = GROUP_LIBRARY
|
||||
setShowBadge(false)
|
||||
|
@ -136,7 +136,7 @@ object Notifications {
|
|||
NotificationChannel(
|
||||
CHANNEL_LIBRARY_SKIPPED,
|
||||
context.getString(R.string.channel_skipped),
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
NotificationManager.IMPORTANCE_LOW,
|
||||
).apply {
|
||||
group = GROUP_LIBRARY
|
||||
setShowBadge(false)
|
||||
|
@ -144,28 +144,28 @@ object Notifications {
|
|||
NotificationChannel(
|
||||
CHANNEL_DOWNLOADER,
|
||||
context.getString(R.string.downloads),
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
NotificationManager.IMPORTANCE_LOW,
|
||||
).apply {
|
||||
setShowBadge(false)
|
||||
},
|
||||
NotificationChannel(
|
||||
CHANNEL_UPDATES_TO_EXTS,
|
||||
context.getString(R.string.extension_updates_pending),
|
||||
NotificationManager.IMPORTANCE_DEFAULT
|
||||
NotificationManager.IMPORTANCE_DEFAULT,
|
||||
).apply {
|
||||
group = GROUP_EXTENSION_UPDATES
|
||||
},
|
||||
NotificationChannel(
|
||||
CHANNEL_NEW_CHAPTERS,
|
||||
context.getString(R.string.new_chapters),
|
||||
NotificationManager.IMPORTANCE_DEFAULT
|
||||
NotificationManager.IMPORTANCE_DEFAULT,
|
||||
).apply {
|
||||
group = GROUP_LIBRARY
|
||||
},
|
||||
NotificationChannel(
|
||||
CHANNEL_BACKUP_RESTORE_PROGRESS,
|
||||
context.getString(R.string.progress),
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
NotificationManager.IMPORTANCE_LOW,
|
||||
).apply {
|
||||
group = GROUP_BACKUP_RESTORE
|
||||
setShowBadge(false)
|
||||
|
@ -173,7 +173,7 @@ object Notifications {
|
|||
NotificationChannel(
|
||||
CHANNEL_BACKUP_RESTORE_COMPLETE,
|
||||
context.getString(R.string.complete),
|
||||
NotificationManager.IMPORTANCE_HIGH
|
||||
NotificationManager.IMPORTANCE_HIGH,
|
||||
).apply {
|
||||
group = GROUP_BACKUP_RESTORE
|
||||
setShowBadge(false)
|
||||
|
@ -182,17 +182,17 @@ object Notifications {
|
|||
NotificationChannel(
|
||||
CHANNEL_CRASH_LOGS,
|
||||
context.getString(R.string.crash_logs),
|
||||
NotificationManager.IMPORTANCE_HIGH
|
||||
NotificationManager.IMPORTANCE_HIGH,
|
||||
),
|
||||
NotificationChannel(
|
||||
CHANNEL_INCOGNITO_MODE,
|
||||
context.getString(R.string.incognito_mode),
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
NotificationManager.IMPORTANCE_LOW,
|
||||
),
|
||||
NotificationChannel(
|
||||
CHANNEL_EXT_PROGRESS,
|
||||
context.getString(R.string.updating_extensions),
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
NotificationManager.IMPORTANCE_LOW,
|
||||
).apply {
|
||||
group = GROUP_EXTENSION_UPDATES
|
||||
setShowBadge(false)
|
||||
|
@ -201,17 +201,17 @@ object Notifications {
|
|||
NotificationChannel(
|
||||
CHANNEL_EXT_UPDATED,
|
||||
context.getString(R.string.extensions_updated),
|
||||
NotificationManager.IMPORTANCE_DEFAULT
|
||||
NotificationManager.IMPORTANCE_DEFAULT,
|
||||
).apply {
|
||||
group = GROUP_EXTENSION_UPDATES
|
||||
},
|
||||
NotificationChannel(
|
||||
CHANNEL_UPDATED,
|
||||
context.getString(R.string.update_completed),
|
||||
NotificationManager.IMPORTANCE_DEFAULT
|
||||
NotificationManager.IMPORTANCE_DEFAULT,
|
||||
).apply {
|
||||
setShowBadge(false)
|
||||
}
|
||||
},
|
||||
)
|
||||
context.notificationManager.createNotificationChannels(channels)
|
||||
}
|
||||
|
|
|
@ -73,16 +73,16 @@ class PreferencesHelper(val context: Context) {
|
|||
File(
|
||||
Environment.getExternalStorageDirectory().absolutePath + File.separator +
|
||||
context.getString(R.string.app_name),
|
||||
"downloads"
|
||||
)
|
||||
"downloads",
|
||||
),
|
||||
)
|
||||
|
||||
private val defaultBackupDir = Uri.fromFile(
|
||||
File(
|
||||
Environment.getExternalStorageDirectory().absolutePath + File.separator +
|
||||
context.getString(R.string.app_name),
|
||||
"backup"
|
||||
)
|
||||
"backup",
|
||||
),
|
||||
)
|
||||
|
||||
fun getInt(key: String, default: Int) = flowPrefs.getInt(key, default)
|
||||
|
@ -182,7 +182,7 @@ class PreferencesHelper(val context: Context) {
|
|||
|
||||
fun readerBottomButtons() = flowPrefs.getStringSet(
|
||||
Keys.readerBottomButtons,
|
||||
ReaderBottomButton.BUTTONS_DEFAULTS
|
||||
ReaderBottomButton.BUTTONS_DEFAULTS,
|
||||
)
|
||||
|
||||
fun showNavigationOverlayNewUser() = flowPrefs.getBoolean(Keys.showNavigationOverlayNewUser, true)
|
||||
|
|
|
@ -267,7 +267,8 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
|
|||
| status
|
||||
|}
|
||||
|}
|
||||
|""".trimMargin()
|
||||
|
|
||||
""".trimMargin()
|
||||
|
||||
fun deleteFromLibraryQuery() =
|
||||
"""
|
||||
|
@ -276,7 +277,8 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
|
|||
|deleted
|
||||
|
||||
|}
|
||||
|}""".trimMargin()
|
||||
|}
|
||||
""".trimMargin()
|
||||
|
||||
fun updateInLibraryQuery() =
|
||||
"""
|
||||
|
@ -297,7 +299,8 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
|
|||
|}
|
||||
|}
|
||||
|}
|
||||
|""".trimMargin()
|
||||
|
|
||||
""".trimMargin()
|
||||
|
||||
fun searchQuery() =
|
||||
"""
|
||||
|
@ -323,7 +326,8 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
|
|||
|}
|
||||
|}
|
||||
|}
|
||||
|""".trimMargin()
|
||||
|
|
||||
""".trimMargin()
|
||||
|
||||
fun findLibraryMangaQuery() =
|
||||
"""
|
||||
|
@ -365,7 +369,8 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
|
|||
|}
|
||||
|}
|
||||
|}
|
||||
|""".trimMargin()
|
||||
|
|
||||
""".trimMargin()
|
||||
|
||||
fun currentUserQuery() =
|
||||
"""
|
||||
|
@ -377,6 +382,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
|
|||
|}
|
||||
|}
|
||||
|}
|
||||
|""".trimMargin()
|
||||
|
|
||||
""".trimMargin()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,10 +62,10 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor)
|
|||
"${baseUrl}library-entries",
|
||||
headers = headersOf(
|
||||
"Content-Type",
|
||||
"application/vnd.api+json"
|
||||
"application/vnd.api+json",
|
||||
),
|
||||
body = data.toString().toRequestBody("application/vnd.api+json".toMediaType()),
|
||||
),
|
||||
body = data.toString().toRequestBody("application/vnd.api+json".toMediaType())
|
||||
)
|
||||
)
|
||||
.await()
|
||||
.parseAs<JsonObject>()
|
||||
|
@ -98,11 +98,11 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor)
|
|||
.headers(
|
||||
headersOf(
|
||||
"Content-Type",
|
||||
"application/vnd.api+json"
|
||||
)
|
||||
"application/vnd.api+json",
|
||||
),
|
||||
)
|
||||
.patch(data.toString().toRequestBody("application/vnd.api+json".toMediaType()))
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.await()
|
||||
.parseAs<JsonObject>()
|
||||
|
@ -140,11 +140,11 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor)
|
|||
.headers(
|
||||
headersOf(
|
||||
"Content-Type",
|
||||
"application/vnd.api+json"
|
||||
)
|
||||
"application/vnd.api+json",
|
||||
),
|
||||
)
|
||||
.delete(data.toString().toRequestBody("application/vnd.api+json".toMediaType()))
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.await()
|
||||
.let {
|
||||
|
@ -180,8 +180,8 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor)
|
|||
"X-Algolia-API-Key",
|
||||
key,
|
||||
),
|
||||
body = jsonObject.toString().toRequestBody(jsonMime)
|
||||
)
|
||||
body = jsonObject.toString().toRequestBody(jsonMime),
|
||||
),
|
||||
)
|
||||
.await()
|
||||
.parseAs<JsonObject>()
|
||||
|
@ -293,7 +293,7 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor)
|
|||
.add("refresh_token", token)
|
||||
.add("client_id", clientId)
|
||||
.add("client_secret", clientSecret)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ data class OAuth(
|
|||
val token_type: String,
|
||||
val created_at: Long,
|
||||
val expires_in: Long,
|
||||
val refresh_token: String?
|
||||
val refresh_token: String?,
|
||||
) {
|
||||
|
||||
fun isExpired() = (System.currentTimeMillis() / 1000) > (created_at + expires_in - 3600)
|
||||
|
|
|
@ -165,7 +165,7 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI
|
|||
.filter {
|
||||
it.jsonObject["node"]!!.jsonObject["title"]!!.jsonPrimitive.content.contains(
|
||||
query,
|
||||
ignoreCase = true
|
||||
ignoreCase = true,
|
||||
)
|
||||
}
|
||||
.map {
|
||||
|
|
|
@ -7,7 +7,7 @@ data class OAuth(
|
|||
val refresh_token: String,
|
||||
val access_token: String,
|
||||
val token_type: String,
|
||||
val expires_in: Long
|
||||
val expires_in: Long,
|
||||
) {
|
||||
|
||||
fun isExpired() = System.currentTimeMillis() > expires_in
|
||||
|
|
|
@ -45,7 +45,7 @@ class AppUpdateJob(private val context: Context, workerParams: WorkerParameters)
|
|||
2,
|
||||
TimeUnit.DAYS,
|
||||
3,
|
||||
TimeUnit.HOURS
|
||||
TimeUnit.HOURS,
|
||||
)
|
||||
.addTag(TAG)
|
||||
.setConstraints(constraints)
|
||||
|
|
|
@ -64,8 +64,8 @@ internal class AppUpdateNotifier(private val context: Context) {
|
|||
R.string.new_beta_version_available
|
||||
} else {
|
||||
R.string.new_version_available
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
setContentIntent(pendingIntent)
|
||||
setAutoCancel(true)
|
||||
|
@ -81,8 +81,8 @@ internal class AppUpdateNotifier(private val context: Context) {
|
|||
context,
|
||||
0,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
|
||||
),
|
||||
)
|
||||
addReleasePageAction()
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ internal class AppUpdateNotifier(private val context: Context) {
|
|||
addAction(
|
||||
R.drawable.ic_new_releases_24dp,
|
||||
context.getString(R.string.release_page),
|
||||
PendingIntent.getActivity(context, releaseUrl.hashCode(), releaseIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
|
||||
PendingIntent.getActivity(context, releaseUrl.hashCode(), releaseIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ internal class AppUpdateNotifier(private val context: Context) {
|
|||
addAction(
|
||||
R.drawable.ic_close_24dp,
|
||||
context.getString(R.string.cancel),
|
||||
NotificationReceiver.cancelUpdateDownloadPendingBroadcast(context)
|
||||
NotificationReceiver.cancelUpdateDownloadPendingBroadcast(context),
|
||||
)
|
||||
addReleasePageAction()
|
||||
}
|
||||
|
@ -159,13 +159,13 @@ internal class AppUpdateNotifier(private val context: Context) {
|
|||
addAction(
|
||||
R.drawable.ic_system_update_24dp,
|
||||
context.getString(R.string.install),
|
||||
NotificationHandler.installApkPendingActivity(context, uri)
|
||||
NotificationHandler.installApkPendingActivity(context, uri),
|
||||
)
|
||||
// Cancel action
|
||||
addAction(
|
||||
R.drawable.ic_close_24dp,
|
||||
context.getString(R.string.cancel),
|
||||
NotificationReceiver.dismissNotificationPendingBroadcast(context, Notifications.ID_INSTALL)
|
||||
NotificationReceiver.dismissNotificationPendingBroadcast(context, Notifications.ID_INSTALL),
|
||||
)
|
||||
addReleasePageAction()
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ internal class AppUpdateNotifier(private val context: Context) {
|
|||
context,
|
||||
0,
|
||||
context.packageManager.getLaunchIntentForPackage(BuildConfig.APPLICATION_ID),
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
|
||||
)
|
||||
setContentIntent(pendingIntent)
|
||||
clearActions()
|
||||
|
@ -215,13 +215,13 @@ internal class AppUpdateNotifier(private val context: Context) {
|
|||
addAction(
|
||||
R.drawable.ic_refresh_24dp,
|
||||
context.getString(R.string.retry),
|
||||
AppUpdateService.downloadApkPendingService(context, url)
|
||||
AppUpdateService.downloadApkPendingService(context, url),
|
||||
)
|
||||
// Cancel action
|
||||
addAction(
|
||||
R.drawable.ic_close_24dp,
|
||||
context.getString(R.string.cancel),
|
||||
NotificationReceiver.dismissNotificationPendingBroadcast(context, Notifications.ID_UPDATER)
|
||||
NotificationReceiver.dismissNotificationPendingBroadcast(context, Notifications.ID_UPDATER),
|
||||
)
|
||||
addReleasePageAction()
|
||||
}
|
||||
|
@ -241,13 +241,13 @@ internal class AppUpdateNotifier(private val context: Context) {
|
|||
addAction(
|
||||
R.drawable.ic_refresh_24dp,
|
||||
context.getString(R.string.retry),
|
||||
NotificationHandler.installApkPendingActivity(context, uri)
|
||||
NotificationHandler.installApkPendingActivity(context, uri),
|
||||
)
|
||||
// Cancel action
|
||||
addAction(
|
||||
R.drawable.ic_close_24dp,
|
||||
context.getString(R.string.cancel),
|
||||
NotificationReceiver.dismissNotificationPendingBroadcast(context, Notifications.ID_UPDATER)
|
||||
NotificationReceiver.dismissNotificationPendingBroadcast(context, Notifications.ID_UPDATER),
|
||||
)
|
||||
addReleasePageAction()
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ class AppUpdateService : Service() {
|
|||
val data = file.inputStream()
|
||||
|
||||
val params = PackageInstaller.SessionParams(
|
||||
PackageInstaller.SessionParams.MODE_FULL_INSTALL
|
||||
PackageInstaller.SessionParams.MODE_FULL_INSTALL,
|
||||
)
|
||||
params.setRequireUserAction(PackageInstaller.SessionParams.USER_ACTION_NOT_REQUIRED)
|
||||
val sessionId = packageInstaller.createSession(params)
|
||||
|
|
|
@ -18,7 +18,7 @@ data class GithubRelease(
|
|||
@SerialName("body") val info: String,
|
||||
@SerialName("html_url") val releaseLink: String,
|
||||
@SerialName("prerelease") val preRelease: Boolean?,
|
||||
@SerialName("assets") private val assets: List<Assets>
|
||||
@SerialName("assets") private val assets: List<Assets>,
|
||||
) {
|
||||
|
||||
/**
|
||||
|
|
|
@ -57,7 +57,7 @@ class ExtensionInstallNotifier(private val context: Context) {
|
|||
.setChannelId(Notifications.CHANNEL_EXT_PROGRESS)
|
||||
.setContentTitle(context.getString(R.string.updating_extensions))
|
||||
.setProgress(max, progress, progress == 0)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -70,8 +70,8 @@ class ExtensionInstallNotifier(private val context: Context) {
|
|||
context.resources.getQuantityString(
|
||||
R.plurals.extensions_updated_plural,
|
||||
extensions.size,
|
||||
extensions.size
|
||||
)
|
||||
extensions.size,
|
||||
),
|
||||
)
|
||||
.setSmallIcon(R.drawable.ic_extension_updated_24dp)
|
||||
.setOngoing(false)
|
||||
|
@ -82,7 +82,7 @@ class ExtensionInstallNotifier(private val context: Context) {
|
|||
setContentText(extensions.joinToString(", ") { it.name })
|
||||
}
|
||||
}
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ import uy.kohesive.injekt.api.get
|
|||
*/
|
||||
class ExtensionManager(
|
||||
private val context: Context,
|
||||
private val preferences: PreferencesHelper = Injekt.get()
|
||||
private val preferences: PreferencesHelper = Injekt.get(),
|
||||
) {
|
||||
|
||||
/**
|
||||
|
@ -467,7 +467,7 @@ class ExtensionManager(
|
|||
apkName = extension.apkName,
|
||||
pkgName = extension.pkgName,
|
||||
name = extension.name,
|
||||
versionCode = extension.versionCode
|
||||
versionCode = extension.versionCode,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ class ExtensionUpdateJob(private val context: Context, workerParams: WorkerParam
|
|||
1
|
||||
} else {
|
||||
2
|
||||
}
|
||||
},
|
||||
)
|
||||
ContextCompat.startForegroundService(context, intent)
|
||||
if (extensionsInstalledByApp.size == extensions.size) {
|
||||
|
@ -114,8 +114,8 @@ class ExtensionUpdateJob(private val context: Context, workerParams: WorkerParam
|
|||
context.resources.getQuantityString(
|
||||
R.plurals.extension_updates_available,
|
||||
extensions.size,
|
||||
extensions.size
|
||||
)
|
||||
extensions.size,
|
||||
),
|
||||
)
|
||||
val extNames = extensions.joinToString(", ") { it.name }
|
||||
setContentText(extNames)
|
||||
|
@ -124,8 +124,8 @@ class ExtensionUpdateJob(private val context: Context, workerParams: WorkerParam
|
|||
color = ContextCompat.getColor(context, R.color.secondaryTachiyomi)
|
||||
setContentIntent(
|
||||
NotificationReceiver.openExtensionsPendingActivity(
|
||||
context
|
||||
)
|
||||
context,
|
||||
),
|
||||
)
|
||||
if (ExtensionManager.canAutoInstallUpdates(context, true) &&
|
||||
extensions.size == extensionsList.size
|
||||
|
@ -137,24 +137,24 @@ class ExtensionUpdateJob(private val context: Context, workerParams: WorkerParam
|
|||
context,
|
||||
0,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
|
||||
)
|
||||
} else {
|
||||
PendingIntent.getService(
|
||||
context,
|
||||
0,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
|
||||
)
|
||||
}
|
||||
addAction(
|
||||
R.drawable.ic_file_download_24dp,
|
||||
context.getString(R.string.update_all),
|
||||
pendingIntent
|
||||
pendingIntent,
|
||||
)
|
||||
}
|
||||
setAutoCancel(true)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ class ExtensionUpdateJob(private val context: Context, workerParams: WorkerParam
|
|||
12,
|
||||
TimeUnit.HOURS,
|
||||
1,
|
||||
TimeUnit.HOURS
|
||||
TimeUnit.HOURS,
|
||||
)
|
||||
.addTag(TAG)
|
||||
.setConstraints(constraints)
|
||||
|
|
|
@ -22,7 +22,7 @@ sealed class Extension {
|
|||
val sources: List<Source>,
|
||||
val hasUpdate: Boolean = false,
|
||||
val isObsolete: Boolean = false,
|
||||
val isUnofficial: Boolean = false
|
||||
val isUnofficial: Boolean = false,
|
||||
) : Extension()
|
||||
|
||||
data class Available(
|
||||
|
@ -34,14 +34,14 @@ sealed class Extension {
|
|||
override val isNsfw: Boolean,
|
||||
val apkName: String,
|
||||
val iconUrl: String,
|
||||
val sources: List<AvailableSource>? = null
|
||||
val sources: List<AvailableSource>? = null,
|
||||
) : Extension()
|
||||
|
||||
data class AvailableSource(
|
||||
val name: String,
|
||||
val id: String,
|
||||
val lang: String,
|
||||
val baseUrl: String
|
||||
val baseUrl: String,
|
||||
)
|
||||
|
||||
data class Untrusted(
|
||||
|
@ -51,6 +51,6 @@ sealed class Extension {
|
|||
override val versionCode: Long,
|
||||
val signatureHash: String,
|
||||
override val lang: String? = null,
|
||||
override val isNsfw: Boolean = false
|
||||
override val isNsfw: Boolean = false,
|
||||
) : Extension()
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ class ExtensionInstallBroadcast : BroadcastReceiver() {
|
|||
val data = UniFile.fromUri(context, intent.data).openInputStream()
|
||||
|
||||
val params = SessionParams(
|
||||
SessionParams.MODE_FULL_INSTALL
|
||||
SessionParams.MODE_FULL_INSTALL,
|
||||
)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
params.setRequireUserAction(USER_ACTION_NOT_REQUIRED)
|
||||
|
@ -137,7 +137,7 @@ class ExtensionInstallActivity : Activity() {
|
|||
val data = UniFile.fromUri(this, intent.data).openInputStream()
|
||||
|
||||
val params = SessionParams(
|
||||
SessionParams.MODE_FULL_INSTALL
|
||||
SessionParams.MODE_FULL_INSTALL,
|
||||
)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
params.setRequireUserAction(USER_ACTION_NOT_REQUIRED)
|
||||
|
|
|
@ -130,7 +130,7 @@ internal class ExtensionInstaller(private val context: Context) {
|
|||
.setDestinationInExternalFilesDir(
|
||||
context,
|
||||
Environment.DIRECTORY_DOWNLOADS,
|
||||
downloadUri.lastPathSegment
|
||||
downloadUri.lastPathSegment,
|
||||
)
|
||||
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
||||
|
||||
|
@ -140,7 +140,7 @@ internal class ExtensionInstaller(private val context: Context) {
|
|||
scope.launch {
|
||||
flowOf(
|
||||
pollStatus(id),
|
||||
pollInstallStatus(pkgName)
|
||||
pollInstallStatus(pkgName),
|
||||
).flattenMerge()
|
||||
.transformWhile {
|
||||
emit(it)
|
||||
|
@ -405,7 +405,7 @@ internal class ExtensionInstaller(private val context: Context) {
|
|||
downloadManager.query(query).use { cursor ->
|
||||
if (cursor.moveToFirst()) {
|
||||
val localUri = cursor.getString(
|
||||
cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI)
|
||||
cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI),
|
||||
).removePrefix(FILE_SCHEME)
|
||||
|
||||
installApk(id, File(localUri).getUriCompat(context))
|
||||
|
|
|
@ -130,7 +130,7 @@ internal object ExtensionLoader {
|
|||
if (libVersion < LIB_VERSION_MIN || libVersion > LIB_VERSION_MAX) {
|
||||
val exception = Exception(
|
||||
"Lib version is $libVersion, while only versions " +
|
||||
"$LIB_VERSION_MIN to $LIB_VERSION_MAX are allowed"
|
||||
"$LIB_VERSION_MIN to $LIB_VERSION_MAX are allowed",
|
||||
)
|
||||
Timber.w(exception)
|
||||
return LoadResult.Error(exception)
|
||||
|
@ -195,7 +195,7 @@ internal object ExtensionLoader {
|
|||
isNsfw,
|
||||
sources = sources,
|
||||
pkgFactory = appInfo.metaData.getString(METADATA_SOURCE_FACTORY),
|
||||
isUnofficial = signatureHash != officialSignature
|
||||
isUnofficial = signatureHash != officialSignature,
|
||||
)
|
||||
return LoadResult.Success(extension)
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ suspend fun Call.await(): Response {
|
|||
if (continuation.isCancelled) return
|
||||
continuation.resumeWithException(e)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
continuation.invokeOnCancellation {
|
||||
|
|
|
@ -135,7 +135,7 @@ class CloudflareInterceptor(private val context: Context) : Interceptor {
|
|||
errorCode: Int,
|
||||
description: String?,
|
||||
failingUrl: String,
|
||||
isMainFrame: Boolean
|
||||
isMainFrame: Boolean,
|
||||
) {
|
||||
if (isMainFrame) {
|
||||
if (errorCode in ERROR_CODES) {
|
||||
|
|
|
@ -17,7 +17,7 @@ import kotlin.coroutines.CoroutineContext
|
|||
|
||||
class SmartSearchEngine(
|
||||
parentContext: CoroutineContext,
|
||||
val extraSearchParams: String? = null
|
||||
val extraSearchParams: String? = null,
|
||||
) : CoroutineScope {
|
||||
override val coroutineContext: CoroutineContext = parentContext + Job() + Dispatchers.Default
|
||||
|
||||
|
@ -83,7 +83,7 @@ class SmartSearchEngine(
|
|||
'(' to ')',
|
||||
'[' to ']',
|
||||
'<' to '>',
|
||||
'{' to '}'
|
||||
'{' to '}',
|
||||
)
|
||||
var openingBracketPairs = bracketPairs.mapIndexed { index, (opening, _) ->
|
||||
opening to index
|
||||
|
|
|
@ -99,7 +99,7 @@ class LocalSource(private val context: Context) : CatalogueSource, UnmeteredSour
|
|||
override fun fetchSearchManga(
|
||||
page: Int,
|
||||
query: String,
|
||||
filters: FilterList
|
||||
filters: FilterList,
|
||||
): Observable<MangasPage> {
|
||||
val baseDirs = getBaseDirectories(context)
|
||||
|
||||
|
|
|
@ -27,23 +27,23 @@ open class SourceManager(private val context: Context) {
|
|||
DelegatedSource(
|
||||
"reader.kireicake.com",
|
||||
5509224355268673176,
|
||||
KireiCake()
|
||||
KireiCake(),
|
||||
),
|
||||
DelegatedSource(
|
||||
"mangadex.org",
|
||||
2499283573021220255,
|
||||
MangaDex()
|
||||
MangaDex(),
|
||||
),
|
||||
DelegatedSource(
|
||||
"mangaplus.shueisha.co.jp",
|
||||
1998944621602463790,
|
||||
MangaPlus()
|
||||
MangaPlus(),
|
||||
),
|
||||
DelegatedSource(
|
||||
"cubari.moe",
|
||||
6338219619148105941,
|
||||
Cubari()
|
||||
)
|
||||
Cubari(),
|
||||
),
|
||||
).associateBy { it.sourceId }
|
||||
|
||||
init {
|
||||
|
@ -84,7 +84,7 @@ open class SourceManager(private val context: Context) {
|
|||
}
|
||||
|
||||
private fun createInternalSources(): List<Source> = listOf(
|
||||
LocalSource(context)
|
||||
LocalSource(context),
|
||||
)
|
||||
|
||||
inner class StubSource(override val id: Long) : Source {
|
||||
|
@ -112,9 +112,9 @@ open class SourceManager(private val context: Context) {
|
|||
return SourceNotFoundException(
|
||||
context.getString(
|
||||
R.string.source_not_installed_,
|
||||
extensionManager.getStubSource(id)?.name ?: id.toString()
|
||||
extensionManager.getStubSource(id)?.name ?: id.toString(),
|
||||
),
|
||||
id
|
||||
id,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ open class SourceManager(private val context: Context) {
|
|||
private data class DelegatedSource(
|
||||
val urlName: String,
|
||||
val sourceId: Long,
|
||||
val delegatedHttpSource: DelegatedHttpSource
|
||||
val delegatedHttpSource: DelegatedHttpSource,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ open class Page(
|
|||
val index: Int,
|
||||
val url: String = "",
|
||||
var imageUrl: String? = null,
|
||||
@Transient var uri: Uri? = null // Deprecated but can't be deleted due to extensions
|
||||
@Transient var uri: Uri? = null, // Deprecated but can't be deleted due to extensions
|
||||
) : ProgressListener {
|
||||
|
||||
val number: Int
|
||||
|
@ -61,13 +61,13 @@ open class Page(
|
|||
|
||||
fun Page.toPageUrl(): PageUrl {
|
||||
return PageUrl(
|
||||
url = this.imageUrl ?: this.url
|
||||
url = this.imageUrl ?: this.url,
|
||||
)
|
||||
}
|
||||
|
||||
fun PageUrl.toPage(index: Int): Page {
|
||||
return Page(
|
||||
index = index,
|
||||
imageUrl = this.url
|
||||
imageUrl = this.url,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ fun SChapter.toChapterInfo(): ChapterInfo {
|
|||
key = this.url,
|
||||
name = this.name,
|
||||
number = this.chapter_number,
|
||||
scanlator = this.scanlator ?: ""
|
||||
scanlator = this.scanlator ?: "",
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ fun SManga.toMangaInfo(): MangaInfo {
|
|||
description = this.description ?: "",
|
||||
genres = this.genre?.split(", ") ?: emptyList(),
|
||||
status = this.status,
|
||||
cover = this.thumbnail_url ?: ""
|
||||
cover = this.thumbnail_url ?: "",
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class Cubari : DelegatedHttpSource() {
|
|||
val context = Injekt.get<PreferencesHelper>().context
|
||||
val trueChapter = findChapter(chapters, cubariType, chapterNumber)?.toChapter()
|
||||
?: error(
|
||||
context.getString(R.string.chapter_not_found)
|
||||
context.getString(R.string.chapter_not_found),
|
||||
)
|
||||
if (manga != null) {
|
||||
Triple(trueChapter, manga, chapters.orEmpty())
|
||||
|
|
|
@ -70,7 +70,7 @@ class MangaDex : DelegatedHttpSource() {
|
|||
val chapters = deferredChapters.await()
|
||||
val context = Injekt.get<PreferencesHelper>().context
|
||||
val trueChapter = chapters?.find { it.url == "/api$url" }?.toChapter() ?: error(
|
||||
context.getString(R.string.chapter_not_found)
|
||||
context.getString(R.string.chapter_not_found),
|
||||
)
|
||||
if (manga != null) {
|
||||
Triple(trueChapter, manga, chapters.orEmpty())
|
||||
|
|
|
@ -38,7 +38,7 @@ open class FoolSlide(override val domainName: String, private val urlModifier: S
|
|||
lang,
|
||||
volume,
|
||||
chapterNumber,
|
||||
subChapterNumber
|
||||
subChapterNumber,
|
||||
).joinToString("/") + "/"
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ open class FoolSlide(override val domainName: String, private val urlModifier: S
|
|||
val chapters = deferredChapters.await()
|
||||
val context = Injekt.get<PreferencesHelper>().context
|
||||
val trueChapter = chapters?.find { it.url == chapterUrl }?.toChapter() ?: error(
|
||||
context.getString(R.string.chapter_not_found)
|
||||
context.getString(R.string.chapter_not_found),
|
||||
)
|
||||
if (manga != null) Triple(trueChapter, manga, chapters) else null
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ open class FoolSlide(override val domainName: String, private val urlModifier: S
|
|||
url,
|
||||
body = FormBody.Builder()
|
||||
.add("adult", "true")
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class MangaPlus : DelegatedHttpSource() {
|
|||
val request = GET(
|
||||
chapterUrlTemplate.replace("##", uri.pathSegments[1]),
|
||||
delegate!!.headers,
|
||||
CacheControl.FORCE_NETWORK
|
||||
CacheControl.FORCE_NETWORK,
|
||||
)
|
||||
return withContext(Dispatchers.IO) {
|
||||
val response = network.client.newCall(request).await()
|
||||
|
@ -58,7 +58,7 @@ class MangaPlus : DelegatedHttpSource() {
|
|||
val chapters = deferredChapters.await()
|
||||
val context = Injekt.get<PreferencesHelper>().context
|
||||
val trueChapter = chapters?.find { it.url == url }?.toChapter() ?: error(
|
||||
context.getString(R.string.chapter_not_found)
|
||||
context.getString(R.string.chapter_not_found),
|
||||
)
|
||||
if (manga != null) {
|
||||
Triple(
|
||||
|
@ -66,7 +66,7 @@ class MangaPlus : DelegatedHttpSource() {
|
|||
manga.apply {
|
||||
this.title = trimmedTitle
|
||||
},
|
||||
chapters.orEmpty()
|
||||
chapters.orEmpty(),
|
||||
)
|
||||
} else null
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ open class BaseToolbar @JvmOverloads constructor(context: Context, attrs: Attrib
|
|||
attrs,
|
||||
R.styleable.Toolbar,
|
||||
0,
|
||||
defStyleRes
|
||||
defStyleRes,
|
||||
)
|
||||
titleTextAppearance = a.getResourceId(R.styleable.Toolbar_titleTextAppearance, 0)
|
||||
a.recycle()
|
||||
|
@ -70,7 +70,7 @@ open class BaseToolbar @JvmOverloads constructor(context: Context, attrs: Attrib
|
|||
getIncogRes(),
|
||||
0,
|
||||
getDropdownRes(),
|
||||
0
|
||||
0,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ class ExpandedAppBarLayout@JvmOverloads constructor(context: Context, attrs: Att
|
|||
get() = getEstimatedLayout(
|
||||
cardFrame?.isVisible == true && toolbarMode == ToolbarState.EXPANDED,
|
||||
useTabsInPreLayout,
|
||||
toolbarMode == ToolbarState.EXPANDED
|
||||
toolbarMode == ToolbarState.EXPANDED,
|
||||
)
|
||||
|
||||
private val preLayoutHeightWhileSearching: Int
|
||||
|
@ -112,7 +112,7 @@ class ExpandedAppBarLayout@JvmOverloads constructor(context: Context, attrs: Att
|
|||
cardFrame?.isVisible == true && toolbarMode == ToolbarState.EXPANDED,
|
||||
useTabsInPreLayout,
|
||||
toolbarMode == ToolbarState.EXPANDED,
|
||||
true
|
||||
true,
|
||||
)
|
||||
|
||||
private var dontFullyHideToolbar = false
|
||||
|
@ -206,7 +206,7 @@ class ExpandedAppBarLayout@JvmOverloads constructor(context: Context, attrs: Att
|
|||
MathUtils.clamp(
|
||||
translationY,
|
||||
-realHeight + (if (context.isTablet()) minTabletHeight else 0),
|
||||
if (compactSearchMode && toolbarMode == ToolbarState.EXPANDED) -realHeight + top + minTabletHeight else 0f
|
||||
if (compactSearchMode && toolbarMode == ToolbarState.EXPANDED) -realHeight + top + minTabletHeight else 0f,
|
||||
)
|
||||
}
|
||||
super.setTranslationY(newY)
|
||||
|
@ -288,7 +288,7 @@ class ExpandedAppBarLayout@JvmOverloads constructor(context: Context, attrs: Att
|
|||
MathUtils.clamp(
|
||||
translationY,
|
||||
-realHeight.toFloat() + top + if (context.isTablet()) minTabletHeight else 0,
|
||||
-realHeight.toFloat() + top + minTabletHeight
|
||||
-realHeight.toFloat() + top + minTabletHeight,
|
||||
)
|
||||
}
|
||||
// for regular compact modes, no need to clamp, setTranslationY will take care of it
|
||||
|
@ -307,9 +307,9 @@ class ExpandedAppBarLayout@JvmOverloads constructor(context: Context, attrs: Att
|
|||
smallHeight,
|
||||
if (offset > realHeight - shortH - tabHeight) smallHeight else min(
|
||||
-offset.toFloat(),
|
||||
0f
|
||||
)
|
||||
) + top.toFloat()
|
||||
0f,
|
||||
),
|
||||
) + top.toFloat(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -341,15 +341,15 @@ class ExpandedAppBarLayout@JvmOverloads constructor(context: Context, attrs: Att
|
|||
toolbarTextView.setTextColorAlpha(
|
||||
(
|
||||
MathUtils.clamp(
|
||||
(1 - ((if (alpha.isNaN()) 1f else alpha) + 0.95f)) * 2, 0f, 1f
|
||||
(1 - ((if (alpha.isNaN()) 1f else alpha) + 0.95f)) * 2, 0f, 1f,
|
||||
) * 255
|
||||
).roundToInt()
|
||||
).roundToInt(),
|
||||
)
|
||||
val mainToolbar = mainToolbar ?: return
|
||||
mainToolbar.alpha = MathUtils.clamp(
|
||||
(mainToolbar.bottom + mainToolbar.translationY + y - paddingTop) / mainToolbar.height,
|
||||
0f,
|
||||
1f
|
||||
1f,
|
||||
)
|
||||
val mainActivity = mainActivity ?: return
|
||||
val useSearchToolbar = mainToolbar.alpha <= 0.025f
|
||||
|
@ -373,7 +373,7 @@ class ExpandedAppBarLayout@JvmOverloads constructor(context: Context, attrs: Att
|
|||
val halfWay = compactAppBarHeight / 2
|
||||
val shortAnimationDuration = resources?.getInteger(
|
||||
if (toolbarMode != ToolbarState.EXPANDED) android.R.integer.config_shortAnimTime
|
||||
else android.R.integer.config_longAnimTime
|
||||
else android.R.integer.config_longAnimTime,
|
||||
) ?: 0
|
||||
val realHeight = preLayoutHeightWhileSearching + paddingTop
|
||||
val closerToTop = abs(y) > realHeight - halfWay
|
||||
|
|
|
@ -66,7 +66,7 @@ class FloatingToolbar @JvmOverloads constructor(context: Context, attrs: Attribu
|
|||
attrs,
|
||||
R.styleable.Toolbar,
|
||||
0,
|
||||
defStyleRes
|
||||
defStyleRes,
|
||||
)
|
||||
subtitleTextAppearance = a.getResourceId(R.styleable.Toolbar_subtitleTextAppearance, 0)
|
||||
a.recycle()
|
||||
|
|
|
@ -26,7 +26,7 @@ class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: Attr
|
|||
setViewsToUse(
|
||||
R.layout.material_fastscroll,
|
||||
R.id.fast_scroller_bubble,
|
||||
R.id.fast_scroller_handle
|
||||
R.id.fast_scroller_handle,
|
||||
)
|
||||
autoHideEnabled = true
|
||||
ignoreTouchesOutsideHandle = false
|
||||
|
@ -121,12 +121,12 @@ class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: Attr
|
|||
if (layoutManager is StaggeredGridLayoutManager) {
|
||||
(layoutManager as StaggeredGridLayoutManager).scrollToPositionWithOffset(
|
||||
targetPos,
|
||||
scrollOffset
|
||||
scrollOffset,
|
||||
)
|
||||
} else {
|
||||
(layoutManager as LinearLayoutManager).scrollToPositionWithOffset(
|
||||
targetPos,
|
||||
scrollOffset
|
||||
scrollOffset,
|
||||
)
|
||||
}
|
||||
updateBubbleText(targetPos)
|
||||
|
|
|
@ -33,7 +33,7 @@ class MaterialMenuSheet(
|
|||
selectedId: Int? = null,
|
||||
maxHeight: Int? = null,
|
||||
showDivider: Boolean = false,
|
||||
onMenuItemClicked: (MaterialMenuSheet, Int) -> Boolean
|
||||
onMenuItemClicked: (MaterialMenuSheet, Int) -> Boolean,
|
||||
) : E2EBottomSheetDialog<BottomMenuSheetBinding>(activity) {
|
||||
|
||||
override fun createBinding(inflater: LayoutInflater) = BottomMenuSheetBinding.inflate(inflater)
|
||||
|
@ -50,7 +50,7 @@ class MaterialMenuSheet(
|
|||
matchConstraintMaxHeight =
|
||||
min(
|
||||
(maxHeight ?: fullHeight) + (insets?.bottom ?: 0),
|
||||
fullHeight - (insets?.top ?: 0) - binding.titleLayout.height - 26.dpToPx
|
||||
fullHeight - (insets?.top ?: 0) - binding.titleLayout.height - 26.dpToPx,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ class MaterialMenuSheet(
|
|||
binding.root.post {
|
||||
binding.menuSheetRecycler.scrollBy(
|
||||
0,
|
||||
pos * 48.dpToPx - binding.menuSheetRecycler.height / 2
|
||||
pos * 48.dpToPx - binding.menuSheetRecycler.height / 2,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ class MaterialMenuSheet(
|
|||
|
||||
elevationAnimator = ValueAnimator.ofArgb(
|
||||
if (elevate) nonElevateColor else elevateColor,
|
||||
if (elevate) elevateColor else nonElevateColor
|
||||
if (elevate) elevateColor else nonElevateColor,
|
||||
)
|
||||
|
||||
elevationAnimator?.addUpdateListener {
|
||||
|
@ -121,7 +121,8 @@ class MaterialMenuSheet(
|
|||
elevate(notAtTop)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -145,6 +146,6 @@ class MaterialMenuSheet(
|
|||
@DrawableRes val drawable: Int = 0,
|
||||
@StringRes val textRes: Int = 0,
|
||||
val text: String? = null,
|
||||
var endDrawableRes: Int = 0
|
||||
var endDrawableRes: Int = 0,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ abstract class BaseController<VB : ViewBinding>(bundle: Bundle? = null) :
|
|||
viewScope.cancel()
|
||||
Timber.d("Destroy view for ${controller.instance()}")
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ abstract class BaseController<VB : ViewBinding>(bundle: Bundle? = null) :
|
|||
|
||||
return onCollapse?.invoke(item) ?: true
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
if (expandActionViewFromInteraction) {
|
||||
|
|
|
@ -91,7 +91,7 @@ abstract class DialogController : Controller {
|
|||
RouterTransaction.with(this)
|
||||
.pushChangeHandler(SimpleSwapChangeHandler(false))
|
||||
.popChangeHandler(SimpleSwapChangeHandler(false))
|
||||
.tag(tag)
|
||||
.tag(tag),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class OneWayFadeChangeHandler : FadeChangeHandler {
|
|||
constructor(duration: Long) : super(duration)
|
||||
constructor(duration: Long, removesFromViewOnPush: Boolean) : super(
|
||||
duration,
|
||||
removesFromViewOnPush
|
||||
removesFromViewOnPush,
|
||||
)
|
||||
|
||||
var fadeOut = true
|
||||
|
@ -26,7 +26,7 @@ class OneWayFadeChangeHandler : FadeChangeHandler {
|
|||
from: View?,
|
||||
to: View?,
|
||||
isPush: Boolean,
|
||||
toAddedToContainer: Boolean
|
||||
toAddedToContainer: Boolean,
|
||||
): Animator {
|
||||
val animator = AnimatorSet()
|
||||
if (to != null) {
|
||||
|
|
|
@ -53,7 +53,7 @@ abstract class RxController<VB : ViewBinding>(bundle: Bundle? = null) : BaseCont
|
|||
|
||||
fun <T> Observable<T>.subscribeUntilDetach(
|
||||
onNext: (T) -> Unit,
|
||||
onError: (Throwable) -> Unit
|
||||
onError: (Throwable) -> Unit,
|
||||
): Subscription {
|
||||
return subscribe(onNext, onError).also { untilDetachSubscriptions.add(it) }
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ abstract class RxController<VB : ViewBinding>(bundle: Bundle? = null) : BaseCont
|
|||
fun <T> Observable<T>.subscribeUntilDetach(
|
||||
onNext: (T) -> Unit,
|
||||
onError: (Throwable) -> Unit,
|
||||
onCompleted: () -> Unit
|
||||
onCompleted: () -> Unit,
|
||||
): Subscription {
|
||||
return subscribe(onNext, onError, onCompleted).also { untilDetachSubscriptions.add(it) }
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ abstract class RxController<VB : ViewBinding>(bundle: Bundle? = null) : BaseCont
|
|||
|
||||
fun <T> Observable<T>.subscribeUntilDestroy(
|
||||
onNext: (T) -> Unit,
|
||||
onError: (Throwable) -> Unit
|
||||
onError: (Throwable) -> Unit,
|
||||
): Subscription {
|
||||
return subscribe(onNext, onError).also { untilDestroySubscriptions.add(it) }
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ abstract class RxController<VB : ViewBinding>(bundle: Bundle? = null) : BaseCont
|
|||
fun <T> Observable<T>.subscribeUntilDestroy(
|
||||
onNext: (T) -> Unit,
|
||||
onError: (Throwable) -> Unit,
|
||||
onCompleted: () -> Unit
|
||||
onCompleted: () -> Unit,
|
||||
): Subscription {
|
||||
return subscribe(onNext, onError, onCompleted).also { untilDestroySubscriptions.add(it) }
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import eu.kanade.tachiyomi.util.system.isLTR
|
|||
abstract class BaseFlexibleViewHolder(
|
||||
view: View,
|
||||
adapter: FlexibleAdapter<*>,
|
||||
stickyHeader: Boolean = false
|
||||
stickyHeader: Boolean = false,
|
||||
) :
|
||||
FlexibleViewHolder(view, adapter, stickyHeader) {
|
||||
override fun getRearRightView(): View? {
|
||||
|
|
|
@ -152,7 +152,7 @@ class CategoryController(bundle: Bundle? = null) :
|
|||
super.onDismissed(transientBottomBar, event)
|
||||
if (!undoing) confirmDelete()
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
(activity as? MainActivity)?.setUndoSnackBar(snack)
|
||||
|
|
|
@ -56,7 +56,7 @@ class CategoryHolder(view: View, val adapter: CategoryAdapter) : BaseFlexibleVie
|
|||
regularDrawable = ContextCompat.getDrawable(
|
||||
itemView.context,
|
||||
R.drawable
|
||||
.ic_add_24dp
|
||||
.ic_add_24dp,
|
||||
)
|
||||
binding.image.isVisible = false
|
||||
binding.editButton.setImageDrawable(null)
|
||||
|
@ -67,7 +67,7 @@ class CategoryHolder(view: View, val adapter: CategoryAdapter) : BaseFlexibleVie
|
|||
regularDrawable = ContextCompat.getDrawable(
|
||||
itemView.context,
|
||||
R.drawable
|
||||
.ic_drag_handle_24dp
|
||||
.ic_drag_handle_24dp,
|
||||
)
|
||||
binding.image.isVisible = true
|
||||
binding.editText.setText(binding.title.text)
|
||||
|
@ -89,8 +89,8 @@ class CategoryHolder(view: View, val adapter: CategoryAdapter) : BaseFlexibleVie
|
|||
binding.reorder.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
itemView.context,
|
||||
R.drawable.ic_delete_24dp
|
||||
)
|
||||
R.drawable.ic_delete_24dp,
|
||||
),
|
||||
)
|
||||
binding.reorder.setOnClickListener {
|
||||
adapter.categoryItemListener.onItemDelete(flexibleAdapterPosition)
|
||||
|
@ -109,8 +109,8 @@ class CategoryHolder(view: View, val adapter: CategoryAdapter) : BaseFlexibleVie
|
|||
ContextCompat.getColor(
|
||||
itemView.context,
|
||||
R
|
||||
.color.gray_button
|
||||
)
|
||||
.color.gray_button,
|
||||
),
|
||||
)
|
||||
binding.reorder.setImageDrawable(regularDrawable)
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ class CategoryHolder(view: View, val adapter: CategoryAdapter) : BaseFlexibleVie
|
|||
inputMethodManager.showSoftInput(
|
||||
binding.editText,
|
||||
WindowManager.LayoutParams
|
||||
.SOFT_INPUT_ADJUST_PAN
|
||||
.SOFT_INPUT_ADJUST_PAN,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import uy.kohesive.injekt.api.get
|
|||
class CategoryPresenter(
|
||||
private val controller: CategoryController,
|
||||
private val db: DatabaseHelper = Injekt.get(),
|
||||
preferences: PreferencesHelper = Injekt.get()
|
||||
preferences: PreferencesHelper = Injekt.get(),
|
||||
) {
|
||||
|
||||
private val context = preferences.context
|
||||
|
|
|
@ -105,7 +105,7 @@ class ManageCategoryDialog(bundle: Bundle? = null) :
|
|||
updatePref(
|
||||
preferences.downloadNewChaptersInCategories(),
|
||||
preferences.excludeCategoriesInDownloadNew(),
|
||||
binding.downloadNew
|
||||
binding.downloadNew,
|
||||
)
|
||||
) {
|
||||
true -> preferences.downloadNewChapters().set(true)
|
||||
|
@ -116,7 +116,7 @@ class ManageCategoryDialog(bundle: Bundle? = null) :
|
|||
updatePref(
|
||||
preferences.libraryUpdateCategories(),
|
||||
preferences.libraryUpdateCategoriesExclude(),
|
||||
binding.includeGlobal
|
||||
binding.includeGlobal,
|
||||
) == false
|
||||
) {
|
||||
preferences.libraryUpdateInterval().set(0)
|
||||
|
@ -155,7 +155,7 @@ class ManageCategoryDialog(bundle: Bundle? = null) :
|
|||
binding.downloadNew,
|
||||
preferences.downloadNewChaptersInCategories(),
|
||||
preferences.excludeCategoriesInDownloadNew(),
|
||||
true
|
||||
true,
|
||||
)
|
||||
if (downloadNew && preferences.downloadNewChaptersInCategories().get().isEmpty()) {
|
||||
binding.downloadNew.isVisible = false
|
||||
|
@ -169,7 +169,7 @@ class ManageCategoryDialog(bundle: Bundle? = null) :
|
|||
binding.includeGlobal,
|
||||
preferences.libraryUpdateCategories(),
|
||||
preferences.libraryUpdateCategoriesExclude(),
|
||||
preferences.libraryUpdateInterval().get() > 0
|
||||
preferences.libraryUpdateInterval().get() > 0,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ class ManageCategoryDialog(bundle: Bundle? = null) :
|
|||
private fun updatePref(
|
||||
categories: Preference<Set<String>>,
|
||||
excludeCategories: Preference<Set<String>>,
|
||||
box: TriStateCheckBox
|
||||
box: TriStateCheckBox,
|
||||
): Boolean? {
|
||||
val categoryId = category?.id ?: return null
|
||||
if (!box.isVisible) return null
|
||||
|
@ -206,7 +206,7 @@ class ManageCategoryDialog(bundle: Bundle? = null) :
|
|||
box: TriStateCheckBox,
|
||||
categories: Preference<Set<String>>,
|
||||
excludeCategories: Preference<Set<String>>,
|
||||
shouldShow: Boolean
|
||||
shouldShow: Boolean,
|
||||
) {
|
||||
val updateCategories = categories.get()
|
||||
val excludeUpdateCategories = excludeCategories.get()
|
||||
|
|
|
@ -38,7 +38,7 @@ class SetCategoriesSheet(
|
|||
var categories: MutableList<Category>,
|
||||
var preselected: Array<TriStateCheckBox.State>,
|
||||
private val addingToLibrary: Boolean,
|
||||
val onMangaAdded: (() -> Unit) = { }
|
||||
val onMangaAdded: (() -> Unit) = { },
|
||||
) : E2EBottomSheetDialog<SetCategoriesSheetBinding>(activity) {
|
||||
|
||||
constructor(
|
||||
|
@ -47,7 +47,7 @@ class SetCategoriesSheet(
|
|||
categories: MutableList<Category>,
|
||||
preselected: Array<Int>,
|
||||
addingToLibrary: Boolean,
|
||||
onMangaAdded: () -> Unit
|
||||
onMangaAdded: () -> Unit,
|
||||
) : this(
|
||||
activity, listOf(manga), categories,
|
||||
categories.map {
|
||||
|
@ -57,7 +57,7 @@ class SetCategoriesSheet(
|
|||
TriStateCheckBox.State.UNCHECKED
|
||||
}
|
||||
}.toTypedArray(),
|
||||
addingToLibrary, onMangaAdded
|
||||
addingToLibrary, onMangaAdded,
|
||||
)
|
||||
|
||||
private val fastAdapter: FastAdapter<AddCategoryItem>
|
||||
|
@ -96,7 +96,7 @@ class SetCategoriesSheet(
|
|||
listManga.first().seriesType(context)
|
||||
} else {
|
||||
context.getString(R.string.selection).lowercase(Locale.ROOT)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
setOnShowListener {
|
||||
|
@ -112,7 +112,7 @@ class SetCategoriesSheet(
|
|||
override fun onStateChanged(bottomSheet: View, newState: Int) {
|
||||
updateBottomButtons()
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
binding.titleLayout.checkHeightThen {
|
||||
|
@ -135,7 +135,7 @@ class SetCategoriesSheet(
|
|||
skipInversed = preselected[index] != TriStateCheckBox.State.IGNORE
|
||||
state = preselected[index]
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
setCategoriesButtons()
|
||||
fastAdapter.onClickListener = onClickListener@{ view, _, item, _ ->
|
||||
|
@ -192,9 +192,9 @@ class SetCategoriesSheet(
|
|||
else -> context.resources.getQuantityString(
|
||||
R.plurals.category_plural,
|
||||
items.size,
|
||||
items.size
|
||||
items.size,
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ class SetCategoriesSheet(
|
|||
updateBottomButtons()
|
||||
binding.root.post {
|
||||
binding.categoryRecyclerView.scrollToPosition(
|
||||
max(0, itemAdapter.adapterItems.indexOf(selectedItems.firstOrNull()))
|
||||
max(0, itemAdapter.adapterItems.indexOf(selectedItems.firstOrNull())),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ class SetCategoriesSheet(
|
|||
val headerHeight = (activity as? MainActivity)?.toolbarHeight ?: 0
|
||||
binding.buttonLayout.updatePaddingRelative(
|
||||
bottom = activity.window.decorView.rootWindowInsetsCompat
|
||||
?.getInsets(systemBars())?.bottom ?: 0
|
||||
?.getInsets(systemBars())?.bottom ?: 0,
|
||||
)
|
||||
|
||||
binding.buttonLayout.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
|
@ -241,7 +241,7 @@ class SetCategoriesSheet(
|
|||
preselected.getOrElse(index) { TriStateCheckBox.State.UNCHECKED } != TriStateCheckBox.State.IGNORE
|
||||
state = map[category.id] ?: TriStateCheckBox.State.CHECKED
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
setCategoriesButtons()
|
||||
}.show(activity)
|
||||
|
|
|
@ -12,7 +12,7 @@ import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
|||
class DownloadAdapter(controller: DownloadItemListener) : FlexibleAdapter<AbstractFlexibleItem<*>>(
|
||||
null,
|
||||
controller,
|
||||
true
|
||||
true,
|
||||
) {
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,7 +33,7 @@ import uy.kohesive.injekt.injectLazy
|
|||
class DownloadBottomSheet @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? =
|
||||
null
|
||||
null,
|
||||
) : LinearLayout(context, attrs),
|
||||
DownloadAdapter.DownloadItemListener,
|
||||
FlexibleAdapter.OnActionStateListener {
|
||||
|
@ -123,7 +123,7 @@ class DownloadBottomSheet @JvmOverloads constructor(
|
|||
val extCount = presenter.downloadQueue.firstOrNull()
|
||||
binding.titleText.text = if (extCount != null) resources.getString(
|
||||
R.string.downloading_,
|
||||
extCount.chapter.name
|
||||
extCount.chapter.name,
|
||||
)
|
||||
else ""
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ class DownloadBottomSheet @JvmOverloads constructor(
|
|||
if (presenter.downloadQueue.isEmpty()) {
|
||||
binding.emptyView.show(
|
||||
R.drawable.ic_download_off_24dp,
|
||||
R.string.nothing_is_downloading
|
||||
R.string.nothing_is_downloading,
|
||||
)
|
||||
} else {
|
||||
binding.emptyView.hide()
|
||||
|
|
|
@ -25,60 +25,60 @@ class DownloadButton @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
activeColor = ColorUtils.blendARGB(
|
||||
colorSecondary,
|
||||
context.getResourceColor(R.attr.background),
|
||||
0.05f
|
||||
0.05f,
|
||||
)
|
||||
downloadedColor = ColorUtils.blendARGB(
|
||||
colorSecondary,
|
||||
context.getResourceColor(R.attr.colorOnBackground),
|
||||
0.3f
|
||||
0.3f,
|
||||
)
|
||||
}
|
||||
private var activeColor = ColorUtils.blendARGB(
|
||||
colorSecondary,
|
||||
context.getResourceColor(R.attr.background),
|
||||
0.05f
|
||||
0.05f,
|
||||
)
|
||||
private val progressBGColor = ContextCompat.getColor(
|
||||
context,
|
||||
R.color.divider
|
||||
R.color.divider,
|
||||
)
|
||||
private val disabledColor = ContextCompat.getColor(
|
||||
context,
|
||||
R.color.material_on_surface_disabled
|
||||
R.color.material_on_surface_disabled,
|
||||
)
|
||||
private var downloadedColor = ColorUtils.blendARGB(
|
||||
colorSecondary,
|
||||
context.getResourceColor(R.attr.colorOnBackground),
|
||||
0.3f
|
||||
0.3f,
|
||||
)
|
||||
private val downloadedTextColor = context.getResourceColor(R.attr.background)
|
||||
private val errorColor = ContextCompat.getColor(
|
||||
context,
|
||||
R.color.material_red_500
|
||||
R.color.material_red_500,
|
||||
)
|
||||
private val filledCircle = ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.filled_circle
|
||||
R.drawable.filled_circle,
|
||||
)?.mutate()
|
||||
private val borderCircle = ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.border_circle
|
||||
R.drawable.border_circle,
|
||||
)?.mutate()
|
||||
private val downloadDrawable = ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.ic_arrow_downward_24dp
|
||||
R.drawable.ic_arrow_downward_24dp,
|
||||
)?.mutate()
|
||||
private val checkDrawable = ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.ic_check_24dp
|
||||
R.drawable.ic_check_24dp,
|
||||
)?.mutate()
|
||||
private val filledAnim = AnimatedVectorDrawableCompat.create(
|
||||
context,
|
||||
R.drawable.anim_outline_to_filled
|
||||
R.drawable.anim_outline_to_filled,
|
||||
)
|
||||
private val checkAnim = AnimatedVectorDrawableCompat.create(
|
||||
context,
|
||||
R.drawable.anim_dl_to_check_to_dl
|
||||
R.drawable.anim_dl_to_check_to_dl,
|
||||
)
|
||||
private var isAnimating = false
|
||||
private var iconAnimation: ObjectAnimator? = null
|
||||
|
@ -99,7 +99,7 @@ class DownloadButton @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
binding.downloadIcon.setImageDrawable(
|
||||
if (state == Download.State.CHECKED) {
|
||||
checkDrawable
|
||||
} else downloadDrawable
|
||||
} else downloadDrawable,
|
||||
)
|
||||
when (state) {
|
||||
Download.State.CHECKED -> {
|
||||
|
@ -162,7 +162,7 @@ class DownloadButton @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
EndAnimatorListener {
|
||||
binding.downloadIcon.drawable.setTint(downloadedTextColor)
|
||||
checkAnim?.start()
|
||||
}
|
||||
},
|
||||
)
|
||||
alphaAnimation.duration = 150
|
||||
alphaAnimation.start()
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue