diff --git a/app/build.gradle b/app/build.gradle
index 1b19165ab..8af52a047 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -254,7 +254,7 @@ dependencies {
testImplementation "org.robolectric:shadows-multidex:$robolectric_version"
testImplementation "org.robolectric:shadows-play-services:$robolectric_version"
- implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
final coroutines_version = '1.3.4'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 463a8453f..9acde10ed 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -18,15 +18,15 @@
android:name=".App"
android:allowBackup="true"
android:fullBackupContent="@xml/backup_rules"
- android:hasFragileUserData="true"
android:hardwareAccelerated="true"
- android:usesCleartextTraffic="true"
+ android:hasFragileUserData="true"
android:icon="@mipmap/ic_launcher"
- android:requestLegacyExternalStorage="true"
- android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:largeHeap="true"
- android:theme="@style/Theme.Tachiyomi.Light">
+ android:requestLegacyExternalStorage="true"
+ android:roundIcon="@mipmap/ic_launcher_round"
+ android:theme="@style/Theme.Tachiyomi.Light"
+ android:usesCleartextTraffic="true">
-
+
-
-
+
+
+
-
+
-
+
+
-
+
@@ -110,7 +115,7 @@
+ android:theme="@android:style/Theme.Translucent.NoTitleBar" />
+ android:exported="false" />
+ android:exported="false" />
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt
index 809a1344e..82238578e 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt
@@ -128,7 +128,7 @@ class BackupManager(val context: Context, version: Int = CURRENT_VERSION) {
val categoryEntries = JsonArray()
// Add value's to root
- root[Backup.VERSION] = Backup.CURRENT_VERSION
+ root[Backup.VERSION] = CURRENT_VERSION
root[Backup.MANGAS] = mangaEntries
root[CATEGORIES] = categoryEntries
@@ -303,8 +303,8 @@ class BackupManager(val context: Context, version: Int = CURRENT_VERSION) {
fun restoreChapterFetchObservable(source: Source, manga: Manga, chapters: List): Observable, List>> {
return source.fetchChapterList(manga)
.map { syncChaptersWithSource(databaseHelper, it, manga, source) }
- .doOnNext {
- if (it.first.isNotEmpty()) {
+ .doOnNext { pair ->
+ if (pair.first.isNotEmpty()) {
chapters.forEach { it.manga_id = manga.id }
insertChapters(chapters)
}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt
index 0cd976ede..a373adf79 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt
@@ -164,7 +164,7 @@ class BackupRestoreService : Service() {
* @return the start value of the command.
*/
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
- if (intent == null) return Service.START_NOT_STICKY
+ if (intent == null) return START_NOT_STICKY
val uri = intent.getParcelableExtra(BackupConst.EXTRA_URI)
@@ -179,7 +179,7 @@ class BackupRestoreService : Service() {
.subscribeOn(Schedulers.from(executor))
.subscribe()
- return Service.START_NOT_STICKY
+ return START_NOT_STICKY
}
/**
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/cache/ChapterCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/cache/ChapterCache.kt
index b5a684118..52b246f33 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/cache/ChapterCache.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/cache/ChapterCache.kt
@@ -80,13 +80,13 @@ class ChapterCache(private val context: Context) {
if (file == "journal" || file.startsWith("journal."))
return false
- try {
+ return try {
// Remove the extension from the file to get the key of the cache
val key = file.substringBeforeLast(".")
// Remove file from cache.
- return diskCache.remove(key)
+ diskCache.remove(key)
} catch (e: Exception) {
- return false
+ false
}
}
@@ -149,10 +149,10 @@ class ChapterCache(private val context: Context) {
* @return true if in cache otherwise false.
*/
fun isImageInCache(imageUrl: String): Boolean {
- try {
- return diskCache.get(DiskUtil.hashKeyForDisk(imageUrl)) != null
+ return try {
+ diskCache.get(DiskUtil.hashKeyForDisk(imageUrl)) != null
} catch (e: IOException) {
- return false
+ false
}
}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/HistoryLastReadPutResolver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/HistoryLastReadPutResolver.kt
index 98ec17cb4..3834b710b 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/HistoryLastReadPutResolver.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/HistoryLastReadPutResolver.kt
@@ -27,17 +27,15 @@ class HistoryLastReadPutResolver : HistoryPutResolver() {
val putResult: PutResult
- try {
- if (cursor.count == 0) {
+ putResult = cursor.use { putCursor ->
+ if (putCursor.count == 0) {
val insertQuery = mapToInsertQuery(history)
val insertedId = db.lowLevel().insert(insertQuery, mapToContentValues(history))
- putResult = PutResult.newInsertResult(insertedId, insertQuery.table())
+ PutResult.newInsertResult(insertedId, insertQuery.table())
} else {
val numberOfRowsUpdated = db.lowLevel().update(updateQuery, mapToUpdateContentValues(history))
- putResult = PutResult.newUpdateResult(numberOfRowsUpdated, updateQuery.table())
+ PutResult.newUpdateResult(numberOfRowsUpdated, updateQuery.table())
}
- } finally {
- cursor.close()
}
putResult
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt
index f257bbc16..aaa2d7c2b 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt
@@ -259,7 +259,7 @@ class DownloadCache(
*/
private inline fun Map.mapNotNullKeys(transform: (Map.Entry) -> R?): Map {
val destination = LinkedHashMap()
- forEach { element -> transform(element)?.let { destination.put(it, element.value) } }
+ forEach { element -> transform(element)?.let { destination[it] = element.value } }
return destination
}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadService.kt
index ba37783f1..58b1acb39 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadService.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadService.kt
@@ -106,7 +106,7 @@ class DownloadService : Service() {
* Not used.
*/
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
- return Service.START_NOT_STICKY
+ return START_NOT_STICKY
}
/**
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt
index d14407360..a8ed2cb82 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt
@@ -283,7 +283,7 @@ class Downloader(
// Do when page is downloaded.
.doOnNext { notifier.onProgressChange(download) }
.toList()
- .map { _ -> download }
+ .map { download }
// Do after download completes
.doOnNext { ensureSuccessfulDownload(download, mangaDir, tmpDir, chapterDirname) }
// If the page list threw, it will resume here
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/glide/FileFetcher.kt b/app/src/main/java/eu/kanade/tachiyomi/data/glide/FileFetcher.kt
index 6f88ec722..539703642 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/glide/FileFetcher.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/glide/FileFetcher.kt
@@ -5,6 +5,7 @@ import android.util.Log
import com.bumptech.glide.Priority
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.data.DataFetcher
+import timber.log.Timber
import java.io.File
import java.io.FileInputStream
import java.io.FileNotFoundException
@@ -24,7 +25,7 @@ open class FileFetcher(private val file: File) : DataFetcher {
data = FileInputStream(file)
} catch (e: FileNotFoundException) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Failed to open file", e)
+ Timber.d(e, "Failed to open file")
}
callback.onLoadFailed(e)
return
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt
index 8fb260d99..f7e4d3297 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt
@@ -246,7 +246,7 @@ class LibraryUpdateService(
stopSelf(startId)
})
- return Service.START_REDELIVER_INTENT
+ return START_REDELIVER_INTENT
}
/**
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt
index 224547c4a..2cc10f8f6 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt
@@ -97,13 +97,13 @@ class Anilist(private val context: Context, id: Int) : TrackService(id) {
// 100 point
POINT_100 -> index.toFloat()
// 5 stars
- POINT_5 -> when {
- index == 0 -> 0f
+ POINT_5 -> when (index) {
+ 0 -> 0f
else -> index * 20f - 10f
}
// Smiley
- POINT_3 -> when {
- index == 0 -> 0f
+ POINT_3 -> when (index) {
+ 0 -> 0f
else -> index * 25f + 10f
}
// 10 point decimal
@@ -116,8 +116,8 @@ class Anilist(private val context: Context, id: Int) : TrackService(id) {
val score = track.score
return when (scorePreference.getOrDefault()) {
- POINT_5 -> when {
- score == 0f -> "0 ★"
+ POINT_5 -> when (score) {
+ 0f -> "0 ★"
else -> "${((score + 10) / 20).toInt()} ★"
}
POINT_3 -> when {
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuApi.kt
index dcb759bcc..20ca7136c 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuApi.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuApi.kt
@@ -38,7 +38,7 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor)
.addConverterFactory(GsonConverterFactory.create(GsonBuilder().serializeNulls().create()))
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build()
- .create(KitsuApi.Rest::class.java)
+ .create(Rest::class.java)
private val searchRest = Retrofit.Builder()
.baseUrl(algoliaKeyUrl)
@@ -46,7 +46,7 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build()
- .create(KitsuApi.SearchKeyRest::class.java)
+ .create(SearchKeyRest::class.java)
private val algoliaRest = Retrofit.Builder()
.baseUrl(algoliaUrl)
@@ -54,7 +54,7 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build()
- .create(KitsuApi.AgoliaSearchRest::class.java)
+ .create(AgoliaSearchRest::class.java)
fun addLibManga(track: Track, userId: String): Observable