Update linter

This commit is contained in:
arkon
2022-04-08 15:30:30 -04:00
parent 37100f0937
commit f0eb42e72d
192 changed files with 318 additions and 437 deletions
@@ -112,7 +112,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)
}
@@ -144,7 +144,7 @@ class BackupNotifier(private val context: Context) {
addAction(
R.drawable.ic_folder_24dp,
context.getString(R.string.action_show_errors),
errorLogIntent,
errorLogIntent
)
}
@@ -93,7 +93,7 @@ class FullBackupRestore(context: Context, notifier: BackupNotifier) : AbstractBa
categories: List<Int>,
history: List<BackupHistory>,
tracks: List<Track>,
backupCategories: List<BackupCategory>
backupCategories: List<BackupCategory>,
) {
db.inTransaction {
val dbManga = backupManager.getMangaFromDatabase(manga)
@@ -123,7 +123,7 @@ class FullBackupRestore(context: Context, notifier: BackupNotifier) : AbstractBa
categories: List<Int>,
history: List<BackupHistory>,
tracks: List<Track>,
backupCategories: List<BackupCategory>
backupCategories: List<BackupCategory>,
) {
try {
val fetchedManga = backupManager.restoreManga(manga)
@@ -143,7 +143,7 @@ class FullBackupRestore(context: Context, notifier: BackupNotifier) : AbstractBa
categories: List<Int>,
history: List<BackupHistory>,
tracks: List<Track>,
backupCategories: List<BackupCategory>
backupCategories: List<BackupCategory>,
) {
backupManager.restoreChaptersForManga(backupManga, chapters)
@@ -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(),
)
@@ -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,
)
@@ -35,7 +35,7 @@ data class BackupManga(
@ProtoNumber(101) var chapterFlags: Int = 0,
@ProtoNumber(102) var brokenHistory: List<BrokenBackupHistory> = emptyList(),
@ProtoNumber(103) var viewer_flags: Int? = null,
@ProtoNumber(104) var history: List<BackupHistory> = emptyList()
@ProtoNumber(104) var history: List<BackupHistory> = emptyList(),
) {
fun getMangaImpl(): MangaImpl {
return MangaImpl().apply {
@@ -7,13 +7,13 @@ 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 {
@@ -109,7 +109,7 @@ class LegacyBackupRestore(context: Context, notifier: BackupNotifier) : Abstract
chapters: List<Chapter>,
categories: List<String>,
history: List<DHistory>,
tracks: List<Track>
tracks: List<Track>,
) {
val dbManga = backupManager.getMangaFromDatabase(manga)
@@ -139,7 +139,7 @@ class LegacyBackupRestore(context: Context, notifier: BackupNotifier) : Abstract
chapters: List<Chapter>,
categories: List<String>,
history: List<DHistory>,
tracks: List<Track>
tracks: List<Track>,
) {
try {
val fetchedManga = backupManager.fetchManga(source, manga)
@@ -161,7 +161,7 @@ class LegacyBackupRestore(context: Context, notifier: BackupNotifier) : Abstract
chapters: List<Chapter>,
categories: List<String>,
history: List<DHistory>,
tracks: List<Track>
tracks: List<Track>,
) {
if (!backupManager.restoreChaptersForManga(backupManga, chapters)) {
updateChapters(source, backupManga, chapters)
@@ -15,7 +15,7 @@ data class Backup(
val version: Int? = null,
var mangas: MutableList<MangaObject> = mutableListOf(),
var categories: List<@Contextual Category>? = null,
var extensions: List<String>? = null
var extensions: List<String>? = null,
) {
companion object {
const val CURRENT_VERSION = 2
@@ -33,5 +33,5 @@ data class MangaObject(
var chapters: List<@Contextual Chapter>? = null,
var categories: List<String>? = null,
var track: List<@Contextual Track>? = null,
var history: List<@Contextual DHistory>? = null
var history: List<@Contextual DHistory>? = null,
)
@@ -47,7 +47,7 @@ class MangaCoverFetcher(
private val options: Options,
private val coverCache: CoverCache,
private val callFactoryLazy: Lazy<Call.Factory>,
private val diskCacheLazy: Lazy<DiskCache>
private val diskCacheLazy: Lazy<DiskCache>,
) : Fetcher {
// For non-custom cover
@@ -273,7 +273,7 @@ class MangaCoverFetcher(
class Factory(
private val callFactoryLazy: Lazy<Call.Factory>,
private val diskCacheLazy: Lazy<DiskCache>
private val diskCacheLazy: Lazy<DiskCache>,
) : Fetcher.Factory<Manga> {
private val coverCache: CoverCache by injectLazy()
@@ -42,7 +42,7 @@ interface MangaQueries : DbProvider {
.where("${MangaTable.COL_FAVORITE} = 1 AND LOWER(${MangaTable.COL_TITLE}) = ? AND ${MangaTable.COL_SOURCE} != ?")
.whereArgs(
manga.title.lowercase(),
manga.source,
manga.source
)
.limit(1)
.build()
@@ -73,7 +73,7 @@ object TrackTable {
|INSERT INTO $TABLE($COL_ID,$COL_MANGA_ID,$COL_SYNC_ID,$COL_MEDIA_ID,$COL_LIBRARY_ID,$COL_TITLE,$COL_LAST_CHAPTER_READ,$COL_TOTAL_CHAPTERS,$COL_STATUS,$COL_SCORE,$COL_TRACKING_URL,$COL_START_DATE,$COL_FINISH_DATE)
|SELECT $COL_ID,$COL_MANGA_ID,$COL_SYNC_ID,$COL_MEDIA_ID,$COL_LIBRARY_ID,$COL_TITLE,$COL_LAST_CHAPTER_READ,$COL_TOTAL_CHAPTERS,$COL_STATUS,$COL_SCORE,$COL_TRACKING_URL,$COL_START_DATE,$COL_FINISH_DATE
|FROM ${TABLE}_tmp
""".trimMargin()
""".trimMargin()
val dropTempTable: String
get() = "DROP TABLE ${TABLE}_tmp"
@@ -27,7 +27,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(),
) {
/**
@@ -236,7 +236,7 @@ class DownloadCache(
*/
private class RootDirectory(
val dir: UniFile,
var files: Map<Long, SourceDirectory> = hashMapOf()
var files: Map<Long, SourceDirectory> = hashMapOf(),
)
/**
@@ -244,7 +244,7 @@ class DownloadCache(
*/
private class SourceDirectory(
val dir: UniFile,
var files: Map<String, MangaDirectory> = hashMapOf()
var files: Map<String, MangaDirectory> = hashMapOf(),
)
/**
@@ -252,7 +252,7 @@ class DownloadCache(
*/
private class MangaDirectory(
val dir: UniFile,
var files: Set<String> = hashSetOf()
var files: Set<String> = hashSetOf(),
)
/**
@@ -30,7 +30,7 @@ import uy.kohesive.injekt.injectLazy
*/
class DownloadManager(
private val context: Context,
private val db: DatabaseHelper = Injekt.get()
private val db: DatabaseHelper = Injekt.get(),
) {
private val sourceManager: SourceManager by injectLazy()
@@ -126,7 +126,7 @@ class DownloadPendingDeleter(context: Context) {
@Serializable
private data class Entry(
val chapters: List<ChapterEntry>,
val manga: MangaEntry
val manga: MangaEntry,
)
/**
@@ -137,7 +137,7 @@ class DownloadPendingDeleter(context: Context) {
val id: Long,
val url: String,
val name: String,
val scanlator: String? = null
val scanlator: String? = null,
)
/**
@@ -148,7 +148,7 @@ class DownloadPendingDeleter(context: Context) {
val id: Long,
val url: String,
val title: String,
val source: Long
val source: Long,
)
/**
@@ -177,7 +177,9 @@ class DownloadService : Service() {
*/
private fun listenDownloaderState() {
subscriptions += downloadManager.runningRelay
.doOnError { /* Swallow wakelock error */ }
.doOnError {
/* Swallow wakelock error */
}
.subscribe { running ->
if (running) {
wakeLock.acquireIfNeeded()
@@ -20,7 +20,7 @@ import uy.kohesive.injekt.injectLazy
*/
class DownloadStore(
context: Context,
private val sourceManager: SourceManager
private val sourceManager: SourceManager,
) {
/**
@@ -60,7 +60,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 chapterCache: ChapterCache by injectLazy()
@@ -478,7 +478,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") }
@@ -11,7 +11,7 @@ import java.util.concurrent.CopyOnWriteArrayList
class DownloadQueue(
private val store: DownloadStore,
private val queue: MutableList<Download> = CopyOnWriteArrayList()
private val queue: MutableList<Download> = CopyOnWriteArrayList(),
) : List<Download> by queue {
private val statusSubject = PublishSubject.create<Download>()
@@ -77,7 +77,7 @@ class LibraryUpdateService(
val preferences: PreferencesHelper = Injekt.get(),
val downloadManager: DownloadManager = Injekt.get(),
val trackManager: TrackManager = Injekt.get(),
val coverCache: CoverCache = Injekt.get()
val coverCache: CoverCache = Injekt.get(),
) : Service() {
private lateinit var wakeLock: PowerManager.WakeLock
@@ -310,7 +310,7 @@ class LibraryUpdateService(
withUpdateNotification(
currentlyUpdatingManga,
progressCount,
manga,
manga
) { manga ->
try {
when {
@@ -383,7 +383,7 @@ class LibraryUpdateService(
val errorFile = writeErrorFile(failedUpdates)
notifier.showUpdateErrorNotification(
failedUpdates.size,
errorFile.getUriCompat(this),
errorFile.getUriCompat(this)
)
}
if (skippedUpdates.isNotEmpty()) {
@@ -446,7 +446,7 @@ class LibraryUpdateService(
withUpdateNotification(
currentlyUpdatingManga,
progressCount,
manga,
manga
) { manga ->
sourceManager.get(manga.source)?.let { source ->
try {
@@ -461,7 +461,7 @@ class NotificationReceiver : BroadcastReceiver() {
context: Context,
manga: Manga,
chapters: Array<Chapter>,
groupId: Int
groupId: Int,
): PendingIntent {
val newIntent = Intent(context, NotificationReceiver::class.java).apply {
action = ACTION_MARK_AS_READ
@@ -483,7 +483,7 @@ class NotificationReceiver : BroadcastReceiver() {
context: Context,
manga: Manga,
chapters: Array<Chapter>,
groupId: Int
groupId: Int,
): PendingIntent {
val newIntent = Intent(context, NotificationReceiver::class.java).apply {
action = ACTION_DOWNLOAD_CHAPTER
@@ -87,7 +87,7 @@ object Notifications {
"backup_restore_complete_channel",
"library_channel",
"library_progress_channel",
"updates_ext_channel",
"updates_ext_channel"
)
/**
@@ -115,7 +115,7 @@ object Notifications {
},
buildNotificationChannelGroup(GROUP_APK_UPDATES) {
setName(context.getString(R.string.label_recent_updates))
},
}
)
)
@@ -181,7 +181,7 @@ object Notifications {
buildNotificationChannel(CHANNEL_EXTENSIONS_UPDATE, IMPORTANCE_DEFAULT) {
setGroup(GROUP_APK_UPDATES)
setName(context.getString(R.string.channel_ext_updates))
},
}
)
)
}
@@ -20,7 +20,7 @@ import java.io.File
import java.io.InputStream
class ImageSaver(
val context: Context
val context: Context,
) {
@SuppressLint("InlinedApi")
@@ -83,18 +83,18 @@ class ImageSaver(
sealed class Image(
open val name: String,
open val location: Location
open val location: Location,
) {
data class Cover(
val bitmap: Bitmap,
override val name: String,
override val location: Location
override val location: Location,
) : Image(name, location)
data class Page(
val inputStream: () -> InputStream,
override val name: String,
override val location: Location
override val location: Location,
) : Image(name, location)
val data: () -> InputStream
@@ -43,7 +43,8 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
| status
|}
|}
|""".trimMargin()
|
""".trimMargin()
val payload = buildJsonObject {
put("query", query)
putJsonObject("variables") {
@@ -84,7 +85,8 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
|progress
|}
|}
|""".trimMargin()
|
""".trimMargin()
val payload = buildJsonObject {
put("query", query)
putJsonObject("variables") {
@@ -127,7 +129,8 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
|}
|}
|}
|""".trimMargin()
|
""".trimMargin()
val payload = buildJsonObject {
put("query", query)
putJsonObject("variables") {
@@ -193,7 +196,8 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
|}
|}
|}
|""".trimMargin()
|
""".trimMargin()
val payload = buildJsonObject {
put("query", query)
putJsonObject("variables") {
@@ -238,7 +242,8 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
|}
|}
|}
|""".trimMargin()
|
""".trimMargin()
val payload = buildJsonObject {
put("query", query)
}
@@ -16,7 +16,7 @@ data class ALManga(
val format: String,
val publishing_status: String,
val start_date_fuzzy: Long,
val total_chapters: Int
val total_chapters: Int,
) {
fun toTrack() = TrackSearch.create(TrackManager.ANILIST).apply {
@@ -46,7 +46,7 @@ data class ALUserManga(
val chapters_read: Int,
val start_date_fuzzy: Long,
val completed_date_fuzzy: Long,
val manga: ALManga
val manga: ALManga,
) {
fun toTrack() = Track.create(TrackManager.ANILIST).apply {
@@ -7,7 +7,7 @@ data class OAuth(
val access_token: String,
val token_type: String,
val expires: Long,
val expires_in: Long
val expires_in: Long,
) {
fun isExpired() = System.currentTimeMillis() > expires
@@ -6,5 +6,5 @@ import kotlinx.serialization.Serializable
data class Avatar(
val large: String? = "",
val medium: String? = "",
val small: String? = ""
val small: String? = "",
)
@@ -12,5 +12,5 @@ data class Collection(
val status: Status? = Status(),
val tag: List<String?>? = listOf(),
val user: User? = User(),
val vol_status: Int? = 0
val vol_status: Int? = 0,
)
@@ -9,7 +9,7 @@ data class OAuth(
val created_at: Long = System.currentTimeMillis() / 1000,
val expires_in: Long,
val refresh_token: String?,
val user_id: Long?
val user_id: Long?,
) {
// Access token refresh before expired
@@ -6,5 +6,5 @@ import kotlinx.serialization.Serializable
data class Status(
val id: Int? = 0,
val name: String? = "",
val type: String? = ""
val type: String? = "",
)
@@ -10,5 +10,5 @@ data class User(
val sign: String? = "",
val url: String? = "",
val usergroup: Int? = 0,
val username: String? = ""
val username: String? = "",
)
@@ -39,7 +39,7 @@ class DelayedTrackingStore(context: Context) {
DelayedTrackingItem(
trackId = it.key.toLong(),
mangaId = mangaId.toLong(),
lastChapterRead = lastChapterRead.toFloat(),
lastChapterRead = lastChapterRead.toFloat()
)
}
}
@@ -137,7 +137,7 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor)
"X-Algolia-Application-Id",
algoliaAppId,
"X-Algolia-API-Key",
key,
key
),
body = jsonObject.toString().toRequestBody(jsonMime)
)
@@ -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)
@@ -15,7 +15,7 @@ data class SeriesDto(
val booksUnreadCount: Int,
val booksInProgressCount: Int,
val metadata: SeriesMetadataDto,
val booksMetadata: BookMetadataAggregationDto
val booksMetadata: BookMetadataAggregationDto,
)
@Serializable
@@ -38,7 +38,7 @@ data class SeriesMetadataDto(
val genres: Set<String>,
val genresLock: Boolean,
val tags: Set<String>,
val tagsLock: Boolean
val tagsLock: Boolean,
)
@Serializable
@@ -49,13 +49,13 @@ data class BookMetadataAggregationDto(
val summaryNumber: String,
val created: String,
val lastModified: String
val lastModified: String,
)
@Serializable
data class AuthorDto(
val name: String,
val role: String
val role: String,
)
@Serializable
@@ -75,7 +75,7 @@ data class ReadListDto(
val bookIds: List<String>,
val createdDate: String,
val lastModifiedDate: String,
val filtered: Boolean
val filtered: Boolean,
)
@Serializable
@@ -92,7 +92,7 @@ data class ReadProgressDto(
booksUnreadCount,
booksInProgressCount,
lastReadContinuousIndex.toFloat(),
booksCount.toFloat(),
booksCount.toFloat()
)
}
@@ -8,7 +8,7 @@ data class OAuth(
val access_token: String,
val token_type: String,
val created_at: Long = System.currentTimeMillis(),
val expires_in: Long
val expires_in: Long,
) {
fun isExpired() = System.currentTimeMillis() > created_at + (expires_in * 1000)
@@ -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?,
) {
// Access token lives 1 day
@@ -47,12 +47,12 @@ internal class AppUpdateNotifier(private val context: Context) {
addAction(
android.R.drawable.stat_sys_download_done,
context.getString(R.string.action_download),
updateIntent,
updateIntent
)
addAction(
R.drawable.ic_info_24dp,
context.getString(R.string.whats_new),
releaseInfoIntent,
releaseInfoIntent
)
}
notificationBuilder.show()
@@ -12,7 +12,7 @@ data class GithubRelease(
@SerialName("tag_name") val version: String,
@SerialName("body") val info: String,
@SerialName("html_url") val releaseLink: String,
@SerialName("assets") private val assets: List<Assets>
@SerialName("assets") private val assets: List<Assets>,
) {
/**