From 76f6fe46010b235ee59962c94c790428870fc23e Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 13 Sep 2020 18:48:20 -0400 Subject: [PATCH] Use Kolinter Gradle plugin for linting instead of ktlint directly --- app/build.gradle | 2 +- app/src/main/java/eu/kanade/tachiyomi/App.kt | 2 +- .../tachiyomi/data/backup/BackupCreatorJob.kt | 8 +- .../tachiyomi/data/backup/BackupManager.kt | 2 +- .../tachiyomi/data/backup/BackupNotifier.kt | 2 +- .../data/backup/BackupRestoreService.kt | 8 +- .../tachiyomi/data/cache/ChapterCache.kt | 4 +- .../tachiyomi/data/download/DownloadCache.kt | 2 +- .../data/download/DownloadNotifier.kt | 6 +- .../tachiyomi/data/download/Downloader.kt | 2 +- .../data/download/model/DownloadQueue.kt | 2 +- .../tachiyomi/data/glide/FileFetcher.kt | 2 +- .../data/glide/MangaThumbnailModelLoader.kt | 2 +- .../tachiyomi/data/glide/TachiGlideModule.kt | 2 +- .../data/library/LibraryUpdateJob.kt | 8 +- .../data/library/LibraryUpdateNotifier.kt | 15 ++- .../data/library/LibraryUpdateService.kt | 4 +- .../data/notification/NotificationReceiver.kt | 16 ++-- .../data/notification/Notifications.kt | 27 ++++-- .../data/preference/PreferencesHelper.kt | 10 +- .../data/track/anilist/AnilistApi.kt | 13 ++- .../data/track/anilist/AnilistModels.kt | 2 +- .../data/track/bangumi/BangumiApi.kt | 2 +- .../tachiyomi/data/track/kitsu/Kitsu.kt | 2 +- .../data/track/myanimelist/MyAnimeListApi.kt | 14 +-- .../tachiyomi/data/updater/UpdaterJob.kt | 8 +- .../tachiyomi/data/updater/UpdaterService.kt | 2 +- .../tachiyomi/extension/ExtensionUpdateJob.kt | 8 +- .../extension/api/ExtensionGithubApi.kt | 2 +- .../extension/util/ExtensionInstaller.kt | 4 +- .../extension/util/ExtensionLoader.kt | 8 +- .../network/CloudflareInterceptor.kt | 6 +- .../kanade/tachiyomi/network/NetworkHelper.kt | 6 +- .../tachiyomi/network/OkHttpExtensions.kt | 36 +++---- .../tachiyomi/network/ProgressResponseBody.kt | 2 +- .../eu/kanade/tachiyomi/network/Requests.kt | 2 +- .../eu/kanade/tachiyomi/source/LocalSource.kt | 8 +- .../tachiyomi/source/online/HttpSource.kt | 6 +- .../ui/base/activity/BaseActivity.kt | 2 +- .../ui/base/controller/BaseController.kt | 52 +++++----- .../ui/browse/extension/ExtensionPresenter.kt | 2 +- .../migration/search/SearchPresenter.kt | 2 +- .../browse/source/SourceFilterController.kt | 2 +- .../ui/browse/source/SourcePresenter.kt | 2 +- .../source/browse/BrowseSourcePresenter.kt | 2 +- .../ui/browse/source/browse/SourceItem.kt | 10 +- .../ui/browse/source/filter/SelectItem.kt | 3 +- .../ui/browse/source/filter/TriStateItem.kt | 2 +- .../globalsearch/GlobalSearchController.kt | 20 ++-- .../ui/category/CategoryController.kt | 7 +- .../ui/download/DownloadController.kt | 2 +- .../tachiyomi/ui/library/LibraryItem.kt | 7 +- .../tachiyomi/ui/library/LibraryPresenter.kt | 4 +- .../kanade/tachiyomi/ui/main/MainActivity.kt | 42 +++++---- .../tachiyomi/ui/manga/MangaController.kt | 10 +- .../tachiyomi/ui/manga/MangaPresenter.kt | 2 +- .../ui/manga/chapter/ChapterHolder.kt | 2 +- .../ui/manga/chapter/ChaptersAdapter.kt | 2 +- .../manga/track/SetTrackReadingDatesDialog.kt | 2 +- .../tachiyomi/ui/manga/track/TrackHolder.kt | 2 +- .../ui/manga/track/TrackSearchDialog.kt | 2 +- .../tachiyomi/ui/more/AboutController.kt | 6 +- .../tachiyomi/ui/more/MoreController.kt | 2 +- .../tachiyomi/ui/reader/ReaderActivity.kt | 38 ++++---- .../ui/reader/ReaderColorFilterSheet.kt | 60 +++++++----- .../tachiyomi/ui/reader/ReaderPresenter.kt | 6 +- .../ui/reader/loader/DirectoryPageLoader.kt | 2 +- .../ui/reader/loader/EpubPageLoader.kt | 2 +- .../ui/reader/loader/HttpPageLoader.kt | 6 +- .../ui/reader/loader/RarPageLoader.kt | 6 +- .../ui/reader/loader/ZipPageLoader.kt | 2 +- .../ui/reader/viewer/ReaderProgressBar.kt | 9 +- .../ui/reader/viewer/ReaderTransitionView.kt | 2 +- .../ui/reader/viewer/pager/PagerPageHolder.kt | 94 ++++++++++--------- .../ui/reader/viewer/pager/PagerViewer.kt | 16 ++-- .../viewer/webtoon/WebtoonPageHolder.kt | 68 +++++++------- .../ui/reader/viewer/webtoon/WebtoonViewer.kt | 40 ++++---- .../ui/recent/history/HistoryAdapter.kt | 2 +- .../ui/recent/history/HistoryHolder.kt | 2 +- .../ui/recent/history/HistoryPresenter.kt | 6 +- .../ui/recent/updates/UpdatesPresenter.kt | 6 +- .../ui/security/BiometricUnlockActivity.kt | 5 +- .../ui/security/SecureActivityDelegate.kt | 2 +- .../ui/setting/SettingsAdvancedController.kt | 2 +- .../ui/setting/SettingsBackupController.kt | 18 ++-- .../ui/setting/SettingsBrowseController.kt | 2 +- .../ui/setting/SettingsDownloadController.kt | 11 ++- .../ui/setting/SettingsGeneralController.kt | 6 +- .../ui/setting/SettingsLibraryController.kt | 13 ++- .../SettingsParentalControlsController.kt | 4 +- .../ui/setting/SettingsReaderController.kt | 30 ++++-- .../ui/setting/SettingsSecurityController.kt | 2 +- .../ui/setting/SettingsTrackingController.kt | 2 +- .../util/chapter/ChapterSourceSync.kt | 4 +- .../tachiyomi/util/lang/RetryWithDelay.kt | 2 +- .../tachiyomi/util/lang/StringExtensions.kt | 2 +- .../kanade/tachiyomi/util/storage/EpubFile.kt | 4 +- .../tachiyomi/util/storage/OkioExtensions.kt | 4 +- .../tachiyomi/util/system/LocaleHelper.kt | 2 +- .../util/system/WebViewClientCompat.kt | 11 ++- .../kanade/tachiyomi/widget/ActionToolbar.kt | 10 +- .../eu/kanade/tachiyomi/widget/EmptyView.kt | 2 +- .../tachiyomi/widget/MaterialFastScroll.kt | 4 +- .../tachiyomi/widget/NegativeSeekBar.kt | 26 ++--- .../tachiyomi/widget/RevealAnimationView.kt | 12 ++- .../tachiyomi/widget/SimpleNavigationView.kt | 14 ++- build.gradle.kts | 20 +--- buildSrc/src/main/kotlin/Dependencies.kt | 6 +- 108 files changed, 582 insertions(+), 453 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index df13d74101..1c910f78c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -306,7 +306,7 @@ task copyResources(type: Copy) { include '**/*' } -preBuild.dependsOn(ktlintFormat, copyResources) +preBuild.dependsOn(formatKotlin, copyResources) if (getGradle().getStartParameter().getTaskRequests().toString().contains("Standard")) { apply plugin: 'com.google.gms.google-services' diff --git a/app/src/main/java/eu/kanade/tachiyomi/App.kt b/app/src/main/java/eu/kanade/tachiyomi/App.kt index 91c49c1361..762b324f30 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/App.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/App.kt @@ -13,7 +13,6 @@ import eu.kanade.tachiyomi.data.notification.Notifications import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate import eu.kanade.tachiyomi.util.system.LocaleHelper -import java.security.Security import org.acra.ACRA import org.acra.annotation.AcraCore import org.acra.annotation.AcraHttpSender @@ -24,6 +23,7 @@ import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.InjektScope import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.registry.default.DefaultRegistrar +import java.security.Security @AcraCore( buildConfigClass = BuildConfig::class, diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreatorJob.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreatorJob.kt index 8c62e9476c..c78f87011a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreatorJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreatorJob.kt @@ -8,9 +8,9 @@ import androidx.work.WorkManager import androidx.work.Worker import androidx.work.WorkerParameters import eu.kanade.tachiyomi.data.preference.PreferencesHelper -import java.util.concurrent.TimeUnit import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import java.util.concurrent.TimeUnit class BackupCreatorJob(private val context: Context, workerParams: WorkerParameters) : Worker(context, workerParams) { @@ -36,8 +36,10 @@ class BackupCreatorJob(private val context: Context, workerParams: WorkerParamet val interval = prefInterval ?: preferences.backupInterval().get() if (interval > 0) { val request = PeriodicWorkRequestBuilder( - interval.toLong(), TimeUnit.HOURS, - 10, TimeUnit.MINUTES + interval.toLong(), + TimeUnit.HOURS, + 10, + TimeUnit.MINUTES ) .addTag(TAG) .build() 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 8761f0a7f9..66a7e55d39 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 @@ -50,10 +50,10 @@ import eu.kanade.tachiyomi.source.LocalSource import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource -import kotlin.math.max import rx.Observable import timber.log.Timber import uy.kohesive.injekt.injectLazy +import kotlin.math.max class BackupManager(val context: Context, version: Int = CURRENT_VERSION) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt index e48f2d334b..d7e24e6eb2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt @@ -11,9 +11,9 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.util.storage.getUriCompat import eu.kanade.tachiyomi.util.system.notificationBuilder import eu.kanade.tachiyomi.util.system.notificationManager +import uy.kohesive.injekt.injectLazy import java.io.File import java.util.concurrent.TimeUnit -import uy.kohesive.injekt.injectLazy internal class BackupNotifier(private val context: Context) { 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 b13b290495..df51b1a99e 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 @@ -35,10 +35,6 @@ import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.util.chapter.NoChaptersException import eu.kanade.tachiyomi.util.system.acquireWakeLock import eu.kanade.tachiyomi.util.system.isServiceRunning -import java.io.File -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale import kotlinx.coroutines.CoroutineExceptionHandler import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.Job @@ -46,6 +42,10 @@ import kotlinx.coroutines.launch import rx.Observable import timber.log.Timber import uy.kohesive.injekt.injectLazy +import java.io.File +import java.text.SimpleDateFormat +import java.util.Date +import java.util.Locale /** * Restores backup from a JSON file. 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 bb63a82256..fab8a2b31f 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 @@ -9,13 +9,13 @@ import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.util.storage.DiskUtil import eu.kanade.tachiyomi.util.storage.saveTo -import java.io.File -import java.io.IOException import okhttp3.Response import okio.buffer import okio.sink import rx.Observable import uy.kohesive.injekt.injectLazy +import java.io.File +import java.io.IOException /** * Class used to create chapter cache 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 f51578c43e..edf719e74a 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 @@ -7,10 +7,10 @@ import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.source.SourceManager -import java.util.concurrent.TimeUnit import kotlinx.coroutines.flow.onEach import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import java.util.concurrent.TimeUnit /** * Cache where we dump the downloads directory from the filesystem. This class is needed because diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadNotifier.kt index f2136e7c1f..16bcee8dec 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadNotifier.kt @@ -12,8 +12,8 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.util.lang.chop import eu.kanade.tachiyomi.util.system.notificationBuilder import eu.kanade.tachiyomi.util.system.notificationManager -import java.util.regex.Pattern import uy.kohesive.injekt.injectLazy +import java.util.regex.Pattern /** * DownloadNotifier is used to show notifications when downloading one or multiple chapters. @@ -107,7 +107,9 @@ internal class DownloadNotifier(private val context: Context) { } val downloadingProgressText = context.getString( - R.string.chapter_downloading_progress, download.downloadedImages, download.pages!!.size + R.string.chapter_downloading_progress, + download.downloadedImages, + download.pages!!.size ) if (preferences.hideNotificationContent()) { 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 4382333d83..d107f4cdea 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 @@ -22,7 +22,6 @@ import eu.kanade.tachiyomi.util.lang.plusAssign import eu.kanade.tachiyomi.util.storage.DiskUtil import eu.kanade.tachiyomi.util.storage.saveTo import eu.kanade.tachiyomi.util.system.ImageUtil -import java.io.File import kotlinx.coroutines.async import okhttp3.Response import rx.Observable @@ -31,6 +30,7 @@ import rx.schedulers.Schedulers import rx.subscriptions.CompositeSubscription import timber.log.Timber import uy.kohesive.injekt.injectLazy +import java.io.File /** * This class is the one in charge of downloading chapters. diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/model/DownloadQueue.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/model/DownloadQueue.kt index 79dde6a6ed..90207b9e1f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/model/DownloadQueue.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/model/DownloadQueue.kt @@ -5,9 +5,9 @@ import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.download.DownloadStore import eu.kanade.tachiyomi.source.model.Page -import java.util.concurrent.CopyOnWriteArrayList import rx.Observable import rx.subjects.PublishSubject +import java.util.concurrent.CopyOnWriteArrayList class DownloadQueue( private val store: DownloadStore, 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 91da7c558a..a54c3cedec 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,12 +5,12 @@ 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 import java.io.IOException import java.io.InputStream -import timber.log.Timber open class FileFetcher(private val filePath: String = "") : DataFetcher { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/glide/MangaThumbnailModelLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/glide/MangaThumbnailModelLoader.kt index ca478cc74f..b3cf79a151 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/glide/MangaThumbnailModelLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/glide/MangaThumbnailModelLoader.kt @@ -14,10 +14,10 @@ import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.util.isLocal -import java.io.InputStream import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy +import java.io.InputStream /** * A class for loading a cover associated with a [Manga] that can be present in our own cache. diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/glide/TachiGlideModule.kt b/app/src/main/java/eu/kanade/tachiyomi/data/glide/TachiGlideModule.kt index 2182fa8687..dca2e08797 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/glide/TachiGlideModule.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/glide/TachiGlideModule.kt @@ -14,9 +14,9 @@ import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions import com.bumptech.glide.module.AppGlideModule import com.bumptech.glide.request.RequestOptions import eu.kanade.tachiyomi.network.NetworkHelper -import java.io.InputStream import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import java.io.InputStream /** * Class used to update Glide module settings diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt index 9e97310301..f2055a6541 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt @@ -9,9 +9,9 @@ import androidx.work.WorkManager import androidx.work.Worker import androidx.work.WorkerParameters import eu.kanade.tachiyomi.data.preference.PreferencesHelper -import java.util.concurrent.TimeUnit import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import java.util.concurrent.TimeUnit class LibraryUpdateJob(private val context: Context, workerParams: WorkerParameters) : Worker(context, workerParams) { @@ -45,8 +45,10 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet .build() val request = PeriodicWorkRequestBuilder( - interval.toLong(), TimeUnit.HOURS, - 10, TimeUnit.MINUTES + interval.toLong(), + TimeUnit.HOURS, + 10, + TimeUnit.MINUTES ) .addTag(TAG) .setConstraints(constraints) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt index 8982730e07..697d76b3f7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt @@ -22,9 +22,9 @@ import eu.kanade.tachiyomi.util.lang.chop import eu.kanade.tachiyomi.util.system.notification import eu.kanade.tachiyomi.util.system.notificationBuilder import eu.kanade.tachiyomi.util.system.notificationManager +import uy.kohesive.injekt.injectLazy import java.text.DecimalFormat import java.text.DecimalFormatSymbols -import uy.kohesive.injekt.injectLazy class LibraryUpdateNotifier(private val context: Context) { @@ -198,18 +198,23 @@ class LibraryUpdateNotifier(private val context: Context) { // Mark chapters as read action addAction( - R.drawable.ic_glasses_black_24dp, context.getString(R.string.action_mark_as_read), + R.drawable.ic_glasses_black_24dp, + context.getString(R.string.action_mark_as_read), NotificationReceiver.markAsReadPendingBroadcast( context, - manga, chapters, Notifications.ID_NEW_CHAPTERS + manga, + chapters, + Notifications.ID_NEW_CHAPTERS ) ) // View chapters action addAction( - R.drawable.ic_book_24dp, context.getString(R.string.action_view_chapters), + R.drawable.ic_book_24dp, + context.getString(R.string.action_view_chapters), NotificationReceiver.openChapterPendingActivity( context, - manga, Notifications.ID_NEW_CHAPTERS + manga, + Notifications.ID_NEW_CHAPTERS ) ) } 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 faff75b9f2..49d64db7c3 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 @@ -29,14 +29,14 @@ import eu.kanade.tachiyomi.util.shouldDownloadNewChapters import eu.kanade.tachiyomi.util.storage.getUriCompat import eu.kanade.tachiyomi.util.system.acquireWakeLock import eu.kanade.tachiyomi.util.system.isServiceRunning -import java.io.File -import java.util.concurrent.atomic.AtomicInteger import rx.Observable import rx.Subscription import rx.schedulers.Schedulers import timber.log.Timber import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import java.io.File +import java.util.concurrent.atomic.AtomicInteger /** * This class will take care of updating the chapters of the manga from the library. It can be diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationReceiver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationReceiver.kt index 695b608bbd..4960327b91 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationReceiver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationReceiver.kt @@ -7,7 +7,6 @@ import android.content.Intent import android.net.Uri import android.os.Build import android.os.Handler -import eu.kanade.tachiyomi.BuildConfig.APPLICATION_ID as ID import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.backup.BackupRestoreService import eu.kanade.tachiyomi.data.database.DatabaseHelper @@ -26,10 +25,11 @@ import eu.kanade.tachiyomi.util.storage.DiskUtil import eu.kanade.tachiyomi.util.storage.getUriCompat import eu.kanade.tachiyomi.util.system.notificationManager import eu.kanade.tachiyomi.util.system.toast -import java.io.File import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy +import java.io.File +import eu.kanade.tachiyomi.BuildConfig.APPLICATION_ID as ID /** * Global [BroadcastReceiver] that runs on UI thread @@ -56,19 +56,22 @@ class NotificationReceiver : BroadcastReceiver() { // Launch share activity and dismiss notification ACTION_SHARE_IMAGE -> shareImage( - context, intent.getStringExtra(EXTRA_FILE_LOCATION), + context, + intent.getStringExtra(EXTRA_FILE_LOCATION), intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1) ) // Delete image from path and dismiss notification ACTION_DELETE_IMAGE -> deleteImage( - context, intent.getStringExtra(EXTRA_FILE_LOCATION), + context, + intent.getStringExtra(EXTRA_FILE_LOCATION), intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1) ) // Share backup file ACTION_SHARE_BACKUP -> shareBackup( - context, intent.getParcelableExtra(EXTRA_URI), + context, + intent.getParcelableExtra(EXTRA_URI), intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1) ) ACTION_CANCEL_RESTORE -> cancelRestore( @@ -80,7 +83,8 @@ class NotificationReceiver : BroadcastReceiver() { // Open reader activity ACTION_OPEN_CHAPTER -> { openChapter( - context, intent.getLongExtra(EXTRA_MANGA_ID, -1), + context, + intent.getLongExtra(EXTRA_MANGA_ID, -1), intent.getLongExtra(EXTRA_CHAPTER_ID, -1) ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt b/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt index 0bd84af86e..b55b53fedd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt @@ -82,53 +82,62 @@ object Notifications { listOf( NotificationChannel( - CHANNEL_COMMON, context.getString(R.string.channel_common), + CHANNEL_COMMON, + context.getString(R.string.channel_common), NotificationManager.IMPORTANCE_LOW ), NotificationChannel( - CHANNEL_LIBRARY, context.getString(R.string.channel_library), + CHANNEL_LIBRARY, + context.getString(R.string.channel_library), NotificationManager.IMPORTANCE_LOW ).apply { setShowBadge(false) }, NotificationChannel( - CHANNEL_DOWNLOADER_PROGRESS, context.getString(R.string.channel_progress), + CHANNEL_DOWNLOADER_PROGRESS, + context.getString(R.string.channel_progress), NotificationManager.IMPORTANCE_LOW ).apply { group = GROUP_DOWNLOADER setShowBadge(false) }, NotificationChannel( - CHANNEL_DOWNLOADER_COMPLETE, context.getString(R.string.channel_complete), + CHANNEL_DOWNLOADER_COMPLETE, + context.getString(R.string.channel_complete), NotificationManager.IMPORTANCE_LOW ).apply { group = GROUP_DOWNLOADER setShowBadge(false) }, NotificationChannel( - CHANNEL_DOWNLOADER_ERROR, context.getString(R.string.channel_errors), + CHANNEL_DOWNLOADER_ERROR, + context.getString(R.string.channel_errors), NotificationManager.IMPORTANCE_LOW ).apply { group = GROUP_DOWNLOADER setShowBadge(false) }, NotificationChannel( - CHANNEL_NEW_CHAPTERS, context.getString(R.string.channel_new_chapters), + CHANNEL_NEW_CHAPTERS, + context.getString(R.string.channel_new_chapters), NotificationManager.IMPORTANCE_DEFAULT ), NotificationChannel( - CHANNEL_UPDATES_TO_EXTS, context.getString(R.string.channel_ext_updates), + CHANNEL_UPDATES_TO_EXTS, + context.getString(R.string.channel_ext_updates), NotificationManager.IMPORTANCE_DEFAULT ), NotificationChannel( - CHANNEL_BACKUP_RESTORE_PROGRESS, context.getString(R.string.channel_progress), + CHANNEL_BACKUP_RESTORE_PROGRESS, + context.getString(R.string.channel_progress), NotificationManager.IMPORTANCE_LOW ).apply { group = GROUP_BACKUP_RESTORE setShowBadge(false) }, NotificationChannel( - CHANNEL_BACKUP_RESTORE_COMPLETE, context.getString(R.string.channel_complete), + CHANNEL_BACKUP_RESTORE_COMPLETE, + context.getString(R.string.channel_complete), NotificationManager.IMPORTANCE_HIGH ).apply { group = GROUP_BACKUP_RESTORE diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index 11bffb1863..f0f121583d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -7,19 +7,19 @@ import androidx.preference.PreferenceManager import com.tfcporciuncula.flow.FlowSharedPreferences import com.tfcporciuncula.flow.Preference import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys -import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values import eu.kanade.tachiyomi.data.preference.PreferenceValues.DisplayMode import eu.kanade.tachiyomi.data.preference.PreferenceValues.NsfwAllowance import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.data.track.anilist.Anilist +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.onEach import java.io.File import java.text.DateFormat import java.text.SimpleDateFormat import java.util.Locale -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.onEach +import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys +import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values @OptIn(ExperimentalCoroutinesApi::class) fun Preference.asImmediateFlow(block: (value: T) -> Unit): Flow { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt index 5f0afdf4e4..1258677501 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt @@ -13,12 +13,12 @@ import com.google.gson.JsonParser import eu.kanade.tachiyomi.data.database.models.Track import eu.kanade.tachiyomi.data.track.model.TrackSearch import eu.kanade.tachiyomi.network.asObservableSuccess -import java.util.Calendar import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.RequestBody.Companion.toRequestBody import rx.Observable +import java.util.Calendar class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { @@ -271,9 +271,14 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { } return ALManga( - struct["id"].asInt, struct["title"]["romaji"].asString, struct["coverImage"]["large"].asString, - struct["description"].nullString.orEmpty(), struct["type"].asString, struct["status"].nullString.orEmpty(), - date, struct["chapters"].nullInt ?: 0 + struct["id"].asInt, + struct["title"]["romaji"].asString, + struct["coverImage"]["large"].asString, + struct["description"].nullString.orEmpty(), + struct["type"].asString, + struct["status"].nullString.orEmpty(), + date, + struct["chapters"].nullInt ?: 0 ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistModels.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistModels.kt index 8c8cfd5763..f589e3b4d6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistModels.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistModels.kt @@ -4,9 +4,9 @@ import eu.kanade.tachiyomi.data.database.models.Track import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.data.track.model.TrackSearch +import uy.kohesive.injekt.injectLazy import java.text.SimpleDateFormat import java.util.Locale -import uy.kohesive.injekt.injectLazy data class ALManga( val media_id: Int, diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt index 24d95c78b1..fedb1a956d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt @@ -12,13 +12,13 @@ import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.data.track.model.TrackSearch import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.network.asObservableSuccess -import java.net.URLEncoder import okhttp3.CacheControl import okhttp3.FormBody import okhttp3.OkHttpClient import okhttp3.Request import rx.Observable import uy.kohesive.injekt.injectLazy +import java.net.URLEncoder class BangumiApi(private val client: OkHttpClient, interceptor: BangumiInterceptor) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt index 8b5ef74f1f..412f04b55f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt @@ -7,10 +7,10 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Track import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.data.track.model.TrackSearch -import java.text.DecimalFormat import rx.Completable import rx.Observable import uy.kohesive.injekt.injectLazy +import java.text.DecimalFormat class Kitsu(private val context: Context, id: Int) : TrackService(id) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListApi.kt index 0939726b2d..39ae211258 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListApi.kt @@ -11,13 +11,6 @@ import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.util.lang.toCalendar import eu.kanade.tachiyomi.util.selectInt import eu.kanade.tachiyomi.util.selectText -import java.io.BufferedReader -import java.io.InputStreamReader -import java.text.SimpleDateFormat -import java.util.Calendar -import java.util.GregorianCalendar -import java.util.Locale -import java.util.zip.GZIPInputStream import okhttp3.FormBody import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.OkHttpClient @@ -30,6 +23,13 @@ import org.jsoup.nodes.Document import org.jsoup.nodes.Element import org.jsoup.parser.Parser import rx.Observable +import java.io.BufferedReader +import java.io.InputStreamReader +import java.text.SimpleDateFormat +import java.util.Calendar +import java.util.GregorianCalendar +import java.util.Locale +import java.util.zip.GZIPInputStream class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListInterceptor) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterJob.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterJob.kt index 524060c329..fd8d965212 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterJob.kt @@ -15,8 +15,8 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.notification.Notifications import eu.kanade.tachiyomi.data.updater.github.GithubUpdateChecker import eu.kanade.tachiyomi.util.system.notificationManager -import java.util.concurrent.TimeUnit import kotlinx.coroutines.runBlocking +import java.util.concurrent.TimeUnit class UpdaterJob(private val context: Context, workerParams: WorkerParameters) : Worker(context, workerParams) { @@ -66,8 +66,10 @@ class UpdaterJob(private val context: Context, workerParams: WorkerParameters) : .build() val request = PeriodicWorkRequestBuilder( - 3, TimeUnit.DAYS, - 3, TimeUnit.HOURS + 3, + TimeUnit.DAYS, + 3, + TimeUnit.HOURS ) .addTag(TAG) .setConstraints(constraints) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterService.kt index 39596ea221..81103643e4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterService.kt @@ -20,9 +20,9 @@ import eu.kanade.tachiyomi.util.storage.getUriCompat import eu.kanade.tachiyomi.util.storage.saveTo import eu.kanade.tachiyomi.util.system.acquireWakeLock import eu.kanade.tachiyomi.util.system.isServiceRunning -import java.io.File import timber.log.Timber import uy.kohesive.injekt.injectLazy +import java.io.File class UpdaterService : Service() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionUpdateJob.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionUpdateJob.kt index d9d2ed398a..974b42827b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionUpdateJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionUpdateJob.kt @@ -16,10 +16,10 @@ import eu.kanade.tachiyomi.data.notification.Notifications import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.extension.api.ExtensionGithubApi import eu.kanade.tachiyomi.util.system.notification -import java.util.concurrent.TimeUnit import kotlinx.coroutines.coroutineScope import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import java.util.concurrent.TimeUnit class ExtensionUpdateJob(private val context: Context, workerParams: WorkerParameters) : CoroutineWorker(context, workerParams) { @@ -73,8 +73,10 @@ class ExtensionUpdateJob(private val context: Context, workerParams: WorkerParam .build() val request = PeriodicWorkRequestBuilder( - 12, TimeUnit.HOURS, - 1, TimeUnit.HOURS + 12, + TimeUnit.HOURS, + 1, + TimeUnit.HOURS ) .addTag(TAG) .setConstraints(constraints) diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt index 2b989efc0c..6b991f2b9b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt @@ -9,10 +9,10 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.extension.model.Extension import eu.kanade.tachiyomi.extension.model.LoadResult import eu.kanade.tachiyomi.extension.util.ExtensionLoader -import java.util.Date import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import uy.kohesive.injekt.injectLazy +import java.util.Date internal class ExtensionGithubApi { diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstaller.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstaller.kt index 7b698ee157..02ae9ae9f7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstaller.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstaller.kt @@ -13,11 +13,11 @@ import com.jakewharton.rxrelay.PublishRelay import eu.kanade.tachiyomi.extension.model.Extension import eu.kanade.tachiyomi.extension.model.InstallStep import eu.kanade.tachiyomi.util.storage.getUriCompat -import java.io.File -import java.util.concurrent.TimeUnit import rx.Observable import rx.android.schedulers.AndroidSchedulers import timber.log.Timber +import java.io.File +import java.util.concurrent.TimeUnit /** * The installer which installs, updates and uninstalls the extensions. diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt index a2f51c7314..f84a2337d4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt @@ -178,7 +178,13 @@ internal object ExtensionLoader { } val extension = Extension.Installed( - extName, pkgName, versionName, versionCode, lang, isNsfw, sources, + extName, + pkgName, + versionName, + versionCode, + lang, + isNsfw, + sources, isUnofficial = signatureHash != officialSignature ) return LoadResult.Success(extension) diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt b/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt index 5b2cccde2c..de143801b0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt @@ -16,15 +16,15 @@ import eu.kanade.tachiyomi.util.system.WebViewUtil import eu.kanade.tachiyomi.util.system.isOutdated import eu.kanade.tachiyomi.util.system.setDefaultSettings import eu.kanade.tachiyomi.util.system.toast -import java.io.IOException -import java.util.concurrent.CountDownLatch -import java.util.concurrent.TimeUnit import okhttp3.Cookie import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.Interceptor import okhttp3.Request import okhttp3.Response import uy.kohesive.injekt.injectLazy +import java.io.IOException +import java.util.concurrent.CountDownLatch +import java.util.concurrent.TimeUnit class CloudflareInterceptor(private val context: Context) : Interceptor { diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt index aeb7ce5cd2..0f31ee10b6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt @@ -3,15 +3,15 @@ package eu.kanade.tachiyomi.network import android.content.Context import eu.kanade.tachiyomi.BuildConfig import eu.kanade.tachiyomi.data.preference.PreferencesHelper -import java.io.File -import java.net.InetAddress -import java.util.concurrent.TimeUnit import okhttp3.Cache import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.OkHttpClient import okhttp3.dnsoverhttps.DnsOverHttps import okhttp3.logging.HttpLoggingInterceptor import uy.kohesive.injekt.injectLazy +import java.io.File +import java.net.InetAddress +import java.util.concurrent.TimeUnit class NetworkHelper(context: Context) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/OkHttpExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/network/OkHttpExtensions.kt index 8d86629cf5..5e8b660d34 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/OkHttpExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/OkHttpExtensions.kt @@ -1,9 +1,5 @@ package eu.kanade.tachiyomi.network -import java.io.IOException -import java.util.concurrent.atomic.AtomicBoolean -import kotlin.coroutines.resume -import kotlin.coroutines.resumeWithException import kotlinx.coroutines.suspendCancellableCoroutine import okhttp3.Call import okhttp3.Callback @@ -13,6 +9,10 @@ import okhttp3.Response import rx.Observable import rx.Producer import rx.Subscription +import java.io.IOException +import java.util.concurrent.atomic.AtomicBoolean +import kotlin.coroutines.resume +import kotlin.coroutines.resumeWithException fun Call.asObservable(): Observable { return Observable.unsafeCreate { subscriber -> @@ -54,22 +54,24 @@ fun Call.asObservable(): Observable { // Based on https://github.com/gildor/kotlin-coroutines-okhttp suspend fun Call.await(assertSuccess: Boolean = false): Response { return suspendCancellableCoroutine { continuation -> - enqueue(object : Callback { - override fun onResponse(call: Call, response: Response) { - if (assertSuccess && !response.isSuccessful) { - continuation.resumeWithException(Exception("HTTP error ${response.code}")) - return + enqueue( + object : Callback { + override fun onResponse(call: Call, response: Response) { + if (assertSuccess && !response.isSuccessful) { + continuation.resumeWithException(Exception("HTTP error ${response.code}")) + return + } + + continuation.resume(response) } - continuation.resume(response) + override fun onFailure(call: Call, e: IOException) { + // Don't bother with resuming the continuation if it is already cancelled. + if (continuation.isCancelled) return + continuation.resumeWithException(e) + } } - - override fun onFailure(call: Call, e: IOException) { - // Don't bother with resuming the continuation if it is already cancelled. - if (continuation.isCancelled) return - continuation.resumeWithException(e) - } - }) + ) continuation.invokeOnCancellation { try { diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/ProgressResponseBody.kt b/app/src/main/java/eu/kanade/tachiyomi/network/ProgressResponseBody.kt index 53799e9ca4..ff56520b55 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/ProgressResponseBody.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/ProgressResponseBody.kt @@ -1,6 +1,5 @@ package eu.kanade.tachiyomi.network -import java.io.IOException import okhttp3.MediaType import okhttp3.ResponseBody import okio.Buffer @@ -8,6 +7,7 @@ import okio.BufferedSource import okio.ForwardingSource import okio.Source import okio.buffer +import java.io.IOException class ProgressResponseBody(private val responseBody: ResponseBody, private val progressListener: ProgressListener) : ResponseBody() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/Requests.kt b/app/src/main/java/eu/kanade/tachiyomi/network/Requests.kt index 8fc2b9a6ff..3d3b88b548 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/Requests.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/Requests.kt @@ -1,11 +1,11 @@ package eu.kanade.tachiyomi.network -import java.util.concurrent.TimeUnit.MINUTES import okhttp3.CacheControl import okhttp3.FormBody import okhttp3.Headers import okhttp3.Request import okhttp3.RequestBody +import java.util.concurrent.TimeUnit.MINUTES private val DEFAULT_CACHE_CONTROL = CacheControl.Builder().maxAge(10, MINUTES).build() private val DEFAULT_HEADERS = Headers.Builder().build() diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt index 23d0f00b49..9ab3c2ae18 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt @@ -14,6 +14,10 @@ import eu.kanade.tachiyomi.util.lang.compareToCaseInsensitiveNaturalOrder import eu.kanade.tachiyomi.util.storage.DiskUtil import eu.kanade.tachiyomi.util.storage.EpubFile import eu.kanade.tachiyomi.util.system.ImageUtil +import junrar.Archive +import junrar.rarfile.FileHeader +import rx.Observable +import timber.log.Timber import java.io.File import java.io.FileInputStream import java.io.InputStream @@ -21,10 +25,6 @@ import java.util.Locale import java.util.concurrent.TimeUnit import java.util.zip.ZipEntry import java.util.zip.ZipFile -import junrar.Archive -import junrar.rarfile.FileHeader -import rx.Observable -import timber.log.Timber class LocalSource(private val context: Context) : CatalogueSource { companion object { diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt index 438662c6db..23b15ff479 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt @@ -10,15 +10,15 @@ import eu.kanade.tachiyomi.source.model.MangasPage import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga -import java.net.URI -import java.net.URISyntaxException -import java.security.MessageDigest import okhttp3.Headers import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.Response import rx.Observable import uy.kohesive.injekt.injectLazy +import java.net.URI +import java.net.URISyntaxException +import java.security.MessageDigest /** * A simple implementation for sources from a website. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt index 0ecde8b1d6..7635f07bb9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt @@ -7,11 +7,11 @@ import androidx.appcompat.app.AppCompatActivity import androidx.lifecycle.lifecycleScope import androidx.viewbinding.ViewBinding import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate import eu.kanade.tachiyomi.util.system.LocaleHelper import uy.kohesive.injekt.injectLazy +import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values abstract class BaseActivity : AppCompatActivity() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/BaseController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/BaseController.kt index f1e980a7de..8d4fea2151 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/BaseController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/BaseController.kt @@ -22,27 +22,29 @@ abstract class BaseController(bundle: Bundle? = null) : lateinit var binding: VB init { - addLifecycleListener(object : LifecycleListener() { - override fun postCreateView(controller: Controller, view: View) { - onViewCreated(view) - } + addLifecycleListener( + object : LifecycleListener() { + override fun postCreateView(controller: Controller, view: View) { + onViewCreated(view) + } - override fun preCreateView(controller: Controller) { - Timber.d("Create view for ${controller.instance()}") - } + override fun preCreateView(controller: Controller) { + Timber.d("Create view for ${controller.instance()}") + } - override fun preAttach(controller: Controller, view: View) { - Timber.d("Attach view for ${controller.instance()}") - } + override fun preAttach(controller: Controller, view: View) { + Timber.d("Attach view for ${controller.instance()}") + } - override fun preDetach(controller: Controller, view: View) { - Timber.d("Detach view for ${controller.instance()}") - } + override fun preDetach(controller: Controller, view: View) { + Timber.d("Detach view for ${controller.instance()}") + } - override fun preDestroyView(controller: Controller, view: View) { - Timber.d("Destroy view for ${controller.instance()}") + override fun preDestroyView(controller: Controller, view: View) { + Timber.d("Destroy view for ${controller.instance()}") + } } - }) + ) } override val containerView: View? @@ -98,17 +100,19 @@ abstract class BaseController(bundle: Bundle? = null) : var expandActionViewFromInteraction = false fun MenuItem.fixExpand(onExpand: ((MenuItem) -> Boolean)? = null, onCollapse: ((MenuItem) -> Boolean)? = null) { - setOnActionExpandListener(object : MenuItem.OnActionExpandListener { - override fun onMenuItemActionExpand(item: MenuItem): Boolean { - return onExpand?.invoke(item) ?: true - } + setOnActionExpandListener( + object : MenuItem.OnActionExpandListener { + override fun onMenuItemActionExpand(item: MenuItem): Boolean { + return onExpand?.invoke(item) ?: true + } - override fun onMenuItemActionCollapse(item: MenuItem): Boolean { - activity?.invalidateOptionsMenu() + override fun onMenuItemActionCollapse(item: MenuItem): Boolean { + activity?.invalidateOptionsMenu() - return onCollapse?.invoke(item) ?: true + return onCollapse?.invoke(item) ?: true + } } - }) + ) if (expandActionViewFromInteraction) { expandActionViewFromInteraction = false diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionPresenter.kt index f9ca2b3867..6c892ffe07 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionPresenter.kt @@ -10,12 +10,12 @@ import eu.kanade.tachiyomi.extension.model.Extension import eu.kanade.tachiyomi.extension.model.InstallStep import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter import eu.kanade.tachiyomi.util.system.LocaleHelper -import java.util.concurrent.TimeUnit import rx.Observable import rx.Subscription import rx.android.schedulers.AndroidSchedulers import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import java.util.concurrent.TimeUnit private typealias ExtensionTuple = Triple, List, List> diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SearchPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SearchPresenter.kt index 910cf148f7..277ec75294 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SearchPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SearchPresenter.kt @@ -13,10 +13,10 @@ import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchCardItem import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchItem import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchPresenter import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource -import java.util.Date import rx.Observable import rx.android.schedulers.AndroidSchedulers import rx.schedulers.Schedulers +import java.util.Date class SearchPresenter( initialQuery: String? = "", diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceFilterController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceFilterController.kt index 11d6fa6ecc..7d629be0b4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceFilterController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceFilterController.kt @@ -16,9 +16,9 @@ import eu.kanade.tachiyomi.util.preference.onChange import eu.kanade.tachiyomi.util.preference.switchPreferenceCategory import eu.kanade.tachiyomi.util.preference.titleRes import eu.kanade.tachiyomi.util.system.LocaleHelper -import java.util.TreeMap import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import java.util.TreeMap class SourceFilterController : SettingsController() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcePresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcePresenter.kt index b1fb9e7198..eeee195c5a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcePresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcePresenter.kt @@ -6,7 +6,6 @@ import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.source.LocalSource import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter -import java.util.TreeMap import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -21,6 +20,7 @@ import rx.Observable import rx.Subscription import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import java.util.TreeMap /** * Presenter of [SourceController] diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt index 7a75b0f5a4..d7fb3e5231 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt @@ -29,7 +29,6 @@ import eu.kanade.tachiyomi.ui.browse.source.filter.TextSectionItem import eu.kanade.tachiyomi.ui.browse.source.filter.TriStateItem import eu.kanade.tachiyomi.ui.browse.source.filter.TriStateSectionItem import eu.kanade.tachiyomi.util.removeCovers -import java.util.Date import kotlinx.coroutines.flow.subscribe import rx.Observable import rx.Subscription @@ -39,6 +38,7 @@ import rx.subjects.PublishSubject import timber.log.Timber import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import java.util.Date /** * Presenter of [BrowseSourceController]. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceItem.kt index 5ee0bb61ad..8fefce9e04 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceItem.kt @@ -38,10 +38,13 @@ class SourceItem(val manga: Manga, private val displayMode: Preference) : AbstractFlexibleItem( holder.itemView.context, - android.R.layout.simple_spinner_item, filter.values + android.R.layout.simple_spinner_item, + filter.values ).apply { setDropDownViewResource(R.layout.common_spinner_item) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/filter/TriStateItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/filter/TriStateItem.kt index 1c8feb830b..9bc93ee7fb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/filter/TriStateItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/filter/TriStateItem.kt @@ -9,10 +9,10 @@ import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.items.AbstractFlexibleItem import eu.davidea.flexibleadapter.items.IFlexible import eu.davidea.viewholders.FlexibleViewHolder -import eu.kanade.tachiyomi.R as TR import eu.kanade.tachiyomi.source.model.Filter import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.getResourceColor +import eu.kanade.tachiyomi.R as TR open class TriStateItem(val filter: Filter.TriState) : AbstractFlexibleItem() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchController.kt index 04ba78da04..64bbb04c8a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchController.kt @@ -108,17 +108,19 @@ open class GlobalSearchController( val searchView = searchItem.actionView as SearchView searchView.maxWidth = Int.MAX_VALUE - searchItem.setOnActionExpandListener(object : MenuItem.OnActionExpandListener { - override fun onMenuItemActionExpand(item: MenuItem?): Boolean { - searchView.onActionViewExpanded() // Required to show the query in the view - searchView.setQuery(presenter.query, false) - return true - } + searchItem.setOnActionExpandListener( + object : MenuItem.OnActionExpandListener { + override fun onMenuItemActionExpand(item: MenuItem?): Boolean { + searchView.onActionViewExpanded() // Required to show the query in the view + searchView.setQuery(presenter.query, false) + return true + } - override fun onMenuItemActionCollapse(item: MenuItem?): Boolean { - return true + override fun onMenuItemActionCollapse(item: MenuItem?): Boolean { + return true + } } - }) + ) searchView.queryTextEvents() .filterIsInstance() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryController.kt index 5a5c27928c..e1fac83deb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryController.kt @@ -198,8 +198,11 @@ class CategoryController : R.id.action_delete -> { undoHelper = UndoHelper(adapter, this) undoHelper?.start( - adapter.selectedPositions, activity!!.root_coordinator, - R.string.snack_categories_deleted, R.string.action_undo, 3000 + adapter.selectedPositions, + activity!!.root_coordinator, + R.string.snack_categories_deleted, + R.string.action_undo, + 3000 ) mode.finish() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt index eba0cba6b0..5fb2d934a3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt @@ -18,13 +18,13 @@ import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.ui.base.controller.FabController import eu.kanade.tachiyomi.ui.base.controller.NucleusController import eu.kanade.tachiyomi.util.view.shrinkOnScroll -import java.util.concurrent.TimeUnit import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import reactivecircus.flowbinding.android.view.clicks import rx.Observable import rx.Subscription import rx.android.schedulers.AndroidSchedulers +import java.util.concurrent.TimeUnit /** * Controller that shows the currently active downloads. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt index a246c2d6b2..8c4176f96b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt @@ -45,7 +45,9 @@ class LibraryItem(val manga: LibraryManga, private val libraryDisplayMode: Prefe view.apply { card.layoutParams = FrameLayout.LayoutParams(MATCH_PARENT, coverHeight) gradient.layoutParams = FrameLayout.LayoutParams( - MATCH_PARENT, coverHeight / 2, Gravity.BOTTOM + MATCH_PARENT, + coverHeight / 2, + Gravity.BOTTOM ) } LibraryCompactGridHolder(view, adapter) @@ -55,7 +57,8 @@ class LibraryItem(val manga: LibraryManga, private val libraryDisplayMode: Prefe val coverHeight = parent.itemWidth / 3 * 4 view.apply { card.layoutParams = ConstraintLayout.LayoutParams( - MATCH_PARENT, coverHeight + MATCH_PARENT, + coverHeight ) } LibraryComfortableGridHolder(view, adapter) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt index 578aece21a..75200a0a63 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt @@ -19,14 +19,14 @@ import eu.kanade.tachiyomi.util.lang.combineLatest import eu.kanade.tachiyomi.util.lang.isNullOrUnsubscribed import eu.kanade.tachiyomi.util.lang.launchIO import eu.kanade.tachiyomi.util.removeCovers -import java.util.Collections -import java.util.Comparator import rx.Observable import rx.Subscription import rx.android.schedulers.AndroidSchedulers import rx.schedulers.Schedulers import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import java.util.Collections +import java.util.Comparator /** * Class containing library information. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index a5829b6a7c..4c02134a98 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -44,13 +44,13 @@ import eu.kanade.tachiyomi.ui.recent.updates.UpdatesController import eu.kanade.tachiyomi.util.lang.launchIO import eu.kanade.tachiyomi.util.lang.launchUI import eu.kanade.tachiyomi.util.system.toast -import java.util.Date -import java.util.concurrent.TimeUnit import kotlinx.android.synthetic.main.main_activity.appbar import kotlinx.android.synthetic.main.main_activity.tabs import kotlinx.coroutines.delay import kotlinx.coroutines.flow.launchIn import timber.log.Timber +import java.util.Date +import java.util.concurrent.TimeUnit class MainActivity : BaseActivity() { @@ -126,26 +126,28 @@ class MainActivity : BaseActivity() { onBackPressed() } - router.addChangeListener(object : ControllerChangeHandler.ControllerChangeListener { - override fun onChangeStarted( - to: Controller?, - from: Controller?, - isPush: Boolean, - container: ViewGroup, - handler: ControllerChangeHandler - ) { - syncActivityViewWithController(to, from) - } + router.addChangeListener( + object : ControllerChangeHandler.ControllerChangeListener { + override fun onChangeStarted( + to: Controller?, + from: Controller?, + isPush: Boolean, + container: ViewGroup, + handler: ControllerChangeHandler + ) { + syncActivityViewWithController(to, from) + } - override fun onChangeCompleted( - to: Controller?, - from: Controller?, - isPush: Boolean, - container: ViewGroup, - handler: ControllerChangeHandler - ) { + override fun onChangeCompleted( + to: Controller?, + from: Controller?, + isPush: Boolean, + container: ViewGroup, + handler: ControllerChangeHandler + ) { + } } - }) + ) syncActivityViewWithController(router.backstack.lastOrNull()?.controller()) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt index e7c7e1fdd1..40a9174581 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt @@ -71,7 +71,6 @@ import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.view.getCoordinates import eu.kanade.tachiyomi.util.view.shrinkOnScroll import eu.kanade.tachiyomi.util.view.snack -import kotlin.math.min import kotlinx.android.synthetic.main.main_activity.root_coordinator import kotlinx.android.synthetic.main.main_activity.toolbar import kotlinx.coroutines.flow.launchIn @@ -83,6 +82,7 @@ import timber.log.Timber import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy +import kotlin.math.min class MangaController : NucleusController, @@ -291,10 +291,10 @@ class MangaController : // Get coordinates and start animation actionFab?.getCoordinates()?.let { coordinates -> if (!binding.revealView.showRevealEffect( - coordinates.x, - coordinates.y, - revealAnimationListener - ) + coordinates.x, + coordinates.y, + revealAnimationListener + ) ) { openChapter(item.chapter) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt index 95ee65ce35..4a8e021916 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt @@ -26,7 +26,6 @@ import eu.kanade.tachiyomi.util.prepUpdateCover import eu.kanade.tachiyomi.util.removeCovers import eu.kanade.tachiyomi.util.shouldDownloadNewChapters import eu.kanade.tachiyomi.util.updateCoverLastModified -import java.util.Date import rx.Observable import rx.Subscription import rx.android.schedulers.AndroidSchedulers @@ -34,6 +33,7 @@ import rx.schedulers.Schedulers import timber.log.Timber import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import java.util.Date class MangaPresenter( val manga: Manga, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt index d57ef6e0a5..7dd16b7fd3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt @@ -9,11 +9,11 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.download.model.Download import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder -import java.util.Date import kotlinx.android.synthetic.main.chapters_item.bookmark_icon import kotlinx.android.synthetic.main.chapters_item.chapter_description import kotlinx.android.synthetic.main.chapters_item.chapter_title import kotlinx.android.synthetic.main.chapters_item.download_text +import java.util.Date class ChapterHolder( view: View, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersAdapter.kt index 9ead9cde9e..f78047d021 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersAdapter.kt @@ -6,10 +6,10 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.util.system.getResourceColor +import uy.kohesive.injekt.injectLazy import java.text.DateFormat import java.text.DecimalFormat import java.text.DecimalFormatSymbols -import uy.kohesive.injekt.injectLazy class ChaptersAdapter( controller: MangaController, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackReadingDatesDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackReadingDatesDialog.kt index 00aed713b2..a5d60509a3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackReadingDatesDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackReadingDatesDialog.kt @@ -9,9 +9,9 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Track import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.ui.base.controller.DialogController -import java.util.Calendar import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import java.util.Calendar class SetTrackReadingDatesDialog : DialogController where T : Controller, T : SetTrackReadingDatesDialog.Listener { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackHolder.kt index a35353e040..1279335aa9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackHolder.kt @@ -5,8 +5,8 @@ import androidx.core.view.isVisible import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.databinding.TrackItemBinding import eu.kanade.tachiyomi.ui.base.holder.BaseViewHolder -import java.text.DateFormat import uy.kohesive.injekt.injectLazy +import java.text.DateFormat class TrackHolder(private val binding: TrackItemBinding, adapter: TrackAdapter) : BaseViewHolder(binding.root) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt index e949ab29e7..2671042b5e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt @@ -13,7 +13,6 @@ import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.data.track.model.TrackSearch import eu.kanade.tachiyomi.ui.base.controller.DialogController -import java.util.concurrent.TimeUnit import kotlinx.android.synthetic.main.track_search_dialog.view.progress import kotlinx.android.synthetic.main.track_search_dialog.view.track_search import kotlinx.android.synthetic.main.track_search_dialog.view.track_search_list @@ -26,6 +25,7 @@ import reactivecircus.flowbinding.android.widget.itemClicks import reactivecircus.flowbinding.android.widget.textChanges import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import java.util.concurrent.TimeUnit class TrackSearchDialog : DialogController { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt index 33e9c497c9..1100041df7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt @@ -23,12 +23,12 @@ import eu.kanade.tachiyomi.util.preference.preferenceCategory import eu.kanade.tachiyomi.util.preference.titleRes import eu.kanade.tachiyomi.util.system.copyToClipboard import eu.kanade.tachiyomi.util.system.toast +import timber.log.Timber import java.text.DateFormat import java.text.ParseException import java.text.SimpleDateFormat import java.util.Locale import java.util.TimeZone -import timber.log.Timber class AboutController : SettingsController() { @@ -224,7 +224,9 @@ class AboutController : SettingsController() { val buildTime = inputDf.parse(BuildConfig.BUILD_TIME) val outputDf = DateFormat.getDateTimeInstance( - DateFormat.MEDIUM, DateFormat.SHORT, Locale.getDefault() + DateFormat.MEDIUM, + DateFormat.SHORT, + Locale.getDefault() ) outputDf.timeZone = TimeZone.getDefault() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreController.kt index b49007f3ee..24062f3ecc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreController.kt @@ -7,7 +7,6 @@ import androidx.preference.PreferenceScreen import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.download.DownloadManager import eu.kanade.tachiyomi.data.download.DownloadService -import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys import eu.kanade.tachiyomi.ui.base.controller.NoToolbarElevationController import eu.kanade.tachiyomi.ui.base.controller.RootController import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction @@ -28,6 +27,7 @@ import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.openInBrowser import rx.android.schedulers.AndroidSchedulers import uy.kohesive.injekt.injectLazy +import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys class MoreController : SettingsController(), diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index b6ccb9b0f1..3d95a58565 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -57,8 +57,6 @@ import eu.kanade.tachiyomi.util.view.showBar import eu.kanade.tachiyomi.util.view.snack import eu.kanade.tachiyomi.widget.SimpleAnimationListener import eu.kanade.tachiyomi.widget.SimpleSeekBarListener -import java.io.File -import kotlin.math.abs import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.delay import kotlinx.coroutines.flow.drop @@ -68,6 +66,8 @@ import kotlinx.coroutines.flow.sample import nucleus.factory.RequiresPresenter import timber.log.Timber import uy.kohesive.injekt.injectLazy +import java.io.File +import kotlin.math.abs /** * Activity containing the reader of Tachiyomi. This activity is mostly a container of the @@ -303,13 +303,15 @@ class ReaderActivity : BaseRxActivity() } // Init listeners on bottom menu - binding.pageSeekbar.setOnSeekBarChangeListener(object : SimpleSeekBarListener() { - override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) { - if (viewer != null && fromUser) { - moveToPageIndex(value) + binding.pageSeekbar.setOnSeekBarChangeListener( + object : SimpleSeekBarListener() { + override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) { + if (viewer != null && fromUser) { + moveToPageIndex(value) + } } } - }) + ) binding.leftChapter.setOnClickListener { if (viewer != null) { if (viewer is R2LPagerViewer) { @@ -349,12 +351,14 @@ class ReaderActivity : BaseRxActivity() if (animate) { val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_top) - toolbarAnimation.setAnimationListener(object : SimpleAnimationListener() { - override fun onAnimationStart(animation: Animation) { - // Fix status bar being translucent the first time it's opened. - window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) + toolbarAnimation.setAnimationListener( + object : SimpleAnimationListener() { + override fun onAnimationStart(animation: Animation) { +// Fix status bar being translucent the first time it's opened. + window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) + } } - }) + ) binding.toolbar.startAnimation(toolbarAnimation) val bottomAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_bottom) @@ -373,11 +377,13 @@ class ReaderActivity : BaseRxActivity() if (animate) { val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.exit_to_top) - toolbarAnimation.setAnimationListener(object : SimpleAnimationListener() { - override fun onAnimationEnd(animation: Animation) { - binding.readerMenu.isVisible = false + toolbarAnimation.setAnimationListener( + object : SimpleAnimationListener() { + override fun onAnimationEnd(animation: Animation) { + binding.readerMenu.isVisible = false + } } - }) + ) binding.toolbar.startAnimation(toolbarAnimation) val bottomAnimation = AnimationUtils.loadAnimation(this, R.anim.exit_to_bottom) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderColorFilterSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderColorFilterSheet.kt index 7fe1a46094..8dee52cb56 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderColorFilterSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderColorFilterSheet.kt @@ -74,45 +74,55 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet } binding.colorFilterMode.setSelection(preferences.colorFilterMode().get(), false) - binding.seekbarColorFilterAlpha.setOnSeekBarChangeListener(object : SimpleSeekBarListener() { - override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) { - if (fromUser) { - setColorValue(value, ALPHA_MASK, 24) + binding.seekbarColorFilterAlpha.setOnSeekBarChangeListener( + object : SimpleSeekBarListener() { + override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) { + if (fromUser) { + setColorValue(value, ALPHA_MASK, 24) + } } } - }) + ) - binding.seekbarColorFilterRed.setOnSeekBarChangeListener(object : SimpleSeekBarListener() { - override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) { - if (fromUser) { - setColorValue(value, RED_MASK, 16) + binding.seekbarColorFilterRed.setOnSeekBarChangeListener( + object : SimpleSeekBarListener() { + override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) { + if (fromUser) { + setColorValue(value, RED_MASK, 16) + } } } - }) + ) - binding.seekbarColorFilterGreen.setOnSeekBarChangeListener(object : SimpleSeekBarListener() { - override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) { - if (fromUser) { - setColorValue(value, GREEN_MASK, 8) + binding.seekbarColorFilterGreen.setOnSeekBarChangeListener( + object : SimpleSeekBarListener() { + override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) { + if (fromUser) { + setColorValue(value, GREEN_MASK, 8) + } } } - }) + ) - binding.seekbarColorFilterBlue.setOnSeekBarChangeListener(object : SimpleSeekBarListener() { - override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) { - if (fromUser) { - setColorValue(value, BLUE_MASK, 0) + binding.seekbarColorFilterBlue.setOnSeekBarChangeListener( + object : SimpleSeekBarListener() { + override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) { + if (fromUser) { + setColorValue(value, BLUE_MASK, 0) + } } } - }) + ) - binding.brightnessSeekbar.setOnSeekBarChangeListener(object : SimpleSeekBarListener() { - override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) { - if (fromUser) { - preferences.customBrightnessValue().set(value) + binding.brightnessSeekbar.setOnSeekBarChangeListener( + object : SimpleSeekBarListener() { + override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) { + if (fromUser) { + preferences.customBrightnessValue().set(value) + } } } - }) + ) } override fun onStart() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt index 83aac83d61..e87bd67c8b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt @@ -27,9 +27,6 @@ import eu.kanade.tachiyomi.util.lang.takeBytes import eu.kanade.tachiyomi.util.storage.DiskUtil import eu.kanade.tachiyomi.util.system.ImageUtil import eu.kanade.tachiyomi.util.updateCoverLastModified -import java.io.File -import java.util.Date -import java.util.concurrent.TimeUnit import rx.Completable import rx.Observable import rx.Subscription @@ -38,6 +35,9 @@ import rx.schedulers.Schedulers import timber.log.Timber import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import java.io.File +import java.util.Date +import java.util.concurrent.TimeUnit /** * Presenter used by the activity to perform background operations. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/DirectoryPageLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/DirectoryPageLoader.kt index 95e7c6e5ea..71671b6fc2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/DirectoryPageLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/DirectoryPageLoader.kt @@ -4,9 +4,9 @@ import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.ui.reader.model.ReaderPage import eu.kanade.tachiyomi.util.lang.compareToCaseInsensitiveNaturalOrder import eu.kanade.tachiyomi.util.system.ImageUtil +import rx.Observable import java.io.File import java.io.FileInputStream -import rx.Observable /** * Loader used to load a chapter from a directory given on [file]. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/EpubPageLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/EpubPageLoader.kt index 00895e9012..99764ac7b1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/EpubPageLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/EpubPageLoader.kt @@ -3,8 +3,8 @@ package eu.kanade.tachiyomi.ui.reader.loader import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.ui.reader.model.ReaderPage import eu.kanade.tachiyomi.util.storage.EpubFile -import java.io.File import rx.Observable +import java.io.File /** * Loader used to load a chapter from a .epub file. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt index 1cc6df6ba5..81481a2668 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt @@ -6,9 +6,6 @@ import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter import eu.kanade.tachiyomi.ui.reader.model.ReaderPage import eu.kanade.tachiyomi.util.lang.plusAssign -import java.util.concurrent.PriorityBlockingQueue -import java.util.concurrent.atomic.AtomicInteger -import kotlin.math.min import rx.Completable import rx.Observable import rx.schedulers.Schedulers @@ -18,6 +15,9 @@ import rx.subscriptions.CompositeSubscription import timber.log.Timber import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import java.util.concurrent.PriorityBlockingQueue +import java.util.concurrent.atomic.AtomicInteger +import kotlin.math.min /** * Loader used to load chapters from an online source. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/RarPageLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/RarPageLoader.kt index 37b35a97cb..9a6a6b88c6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/RarPageLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/RarPageLoader.kt @@ -4,14 +4,14 @@ import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.ui.reader.model.ReaderPage import eu.kanade.tachiyomi.util.lang.compareToCaseInsensitiveNaturalOrder import eu.kanade.tachiyomi.util.system.ImageUtil +import junrar.Archive +import junrar.rarfile.FileHeader +import rx.Observable import java.io.File import java.io.InputStream import java.io.PipedInputStream import java.io.PipedOutputStream import java.util.concurrent.Executors -import junrar.Archive -import junrar.rarfile.FileHeader -import rx.Observable /** * Loader used to load a chapter from a .rar or .cbr file. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/ZipPageLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/ZipPageLoader.kt index f65ebc5946..a48c404a66 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/ZipPageLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/ZipPageLoader.kt @@ -5,11 +5,11 @@ import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.ui.reader.model.ReaderPage import eu.kanade.tachiyomi.util.lang.compareToCaseInsensitiveNaturalOrder import eu.kanade.tachiyomi.util.system.ImageUtil +import rx.Observable import java.io.File import java.nio.charset.StandardCharsets import java.util.zip.ZipEntry import java.util.zip.ZipFile -import rx.Observable /** * Loader used to load a chapter from a .zip or .cbz file. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderProgressBar.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderProgressBar.kt index 4161bf4f06..3afc4da31a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderProgressBar.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderProgressBar.kt @@ -63,9 +63,12 @@ class ReaderProgressBar @JvmOverloads constructor( */ private val rotationAnimation by lazy { RotateAnimation( - 0f, 360f, - Animation.RELATIVE_TO_SELF, 0.5f, - Animation.RELATIVE_TO_SELF, 0.5f + 0f, + 360f, + Animation.RELATIVE_TO_SELF, + 0.5f, + Animation.RELATIVE_TO_SELF, + 0.5f ).apply { interpolator = LinearInterpolator() repeatCount = Animation.INFINITE diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderTransitionView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderTransitionView.kt index 5d442dd223..13394c87b4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderTransitionView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderTransitionView.kt @@ -8,11 +8,11 @@ import androidx.core.text.buildSpannedString import androidx.core.view.isVisible import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition -import kotlin.math.floor import kotlinx.android.synthetic.main.reader_transition_view.view.lower_text import kotlinx.android.synthetic.main.reader_transition_view.view.upper_text import kotlinx.android.synthetic.main.reader_transition_view.view.warning import kotlinx.android.synthetic.main.reader_transition_view.view.warning_text +import kotlin.math.floor class ReaderTransitionView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : LinearLayout(context, attrs) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt index 1d4242a41d..1443ab19cb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt @@ -35,12 +35,12 @@ import eu.kanade.tachiyomi.ui.webview.WebViewActivity import eu.kanade.tachiyomi.util.system.ImageUtil import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.widget.ViewPagerAdapter -import java.io.InputStream -import java.util.concurrent.TimeUnit import rx.Observable import rx.Subscription import rx.android.schedulers.AndroidSchedulers import rx.schedulers.Schedulers +import java.io.InputStream +import java.util.concurrent.TimeUnit /** * View of the ViewPager that contains a page of a chapter. @@ -307,20 +307,22 @@ class PagerPageHolder( setMinimumDpi(90) setMinimumTileDpi(180) setCropBorders(config.imageCropBorders) - setOnImageEventListener(object : SubsamplingScaleImageView.DefaultOnImageEventListener() { - override fun onReady() { - when (config.imageZoomType) { - ZoomType.Left -> setScaleAndCenter(scale, PointF(0f, 0f)) - ZoomType.Right -> setScaleAndCenter(scale, PointF(sWidth.toFloat(), 0f)) - ZoomType.Center -> setScaleAndCenter(scale, center.also { it?.y = 0f }) + setOnImageEventListener( + object : SubsamplingScaleImageView.DefaultOnImageEventListener() { + override fun onReady() { + when (config.imageZoomType) { + ZoomType.Left -> setScaleAndCenter(scale, PointF(0f, 0f)) + ZoomType.Right -> setScaleAndCenter(scale, PointF(sWidth.toFloat(), 0f)) + ZoomType.Center -> setScaleAndCenter(scale, center.also { it?.y = 0f }) + } + onImageDecoded() } - onImageDecoded() - } - override fun onImageLoadError(e: Exception) { - onImageDecodeError() + override fun onImageLoadError(e: Exception) { + onImageDecodeError() + } } - }) + ) } addView(subsamplingImageView) return subsamplingImageView!! @@ -338,16 +340,18 @@ class PagerPageHolder( setZoomTransitionDuration(viewer.config.doubleTapAnimDuration) setScaleLevels(1f, 2f, 3f) // Force 2 scale levels on double tap - setOnDoubleTapListener(object : GestureDetector.SimpleOnGestureListener() { - override fun onDoubleTap(e: MotionEvent): Boolean { - if (scale > 1f) { - setScale(1f, e.x, e.y, true) - } else { - setScale(2f, e.x, e.y, true) + setOnDoubleTapListener( + object : GestureDetector.SimpleOnGestureListener() { + override fun onDoubleTap(e: MotionEvent): Boolean { + if (scale > 1f) { + setScale(1f, e.x, e.y, true) + } else { + setScale(2f, e.x, e.y, true) + } + return true } - return true } - }) + ) } addView(imageView) return imageView!! @@ -437,31 +441,33 @@ class PagerPageHolder( .skipMemoryCache(true) .diskCacheStrategy(DiskCacheStrategy.NONE) .transition(DrawableTransitionOptions.with(NoTransition.getFactory())) - .listener(object : RequestListener { - override fun onLoadFailed( - e: GlideException?, - model: Any?, - target: Target?, - isFirstResource: Boolean - ): Boolean { - onImageDecodeError() - return false - } - - override fun onResourceReady( - resource: Drawable?, - model: Any?, - target: Target?, - dataSource: DataSource?, - isFirstResource: Boolean - ): Boolean { - if (resource is GifDrawable) { - resource.setLoopCount(GifDrawable.LOOP_INTRINSIC) + .listener( + object : RequestListener { + override fun onLoadFailed( + e: GlideException?, + model: Any?, + target: Target?, + isFirstResource: Boolean + ): Boolean { + onImageDecodeError() + return false + } + + override fun onResourceReady( + resource: Drawable?, + model: Any?, + target: Target?, + dataSource: DataSource?, + isFirstResource: Boolean + ): Boolean { + if (resource is GifDrawable) { + resource.setLoopCount(GifDrawable.LOOP_INTRINSIC) + } + onImageDecoded() + return false } - onImageDecoded() - return false } - }) + ) .into(this) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt index a4f5a3e95f..373401ac05 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt @@ -71,15 +71,17 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer { pager.offscreenPageLimit = 1 pager.id = R.id.reader_pager pager.adapter = adapter - pager.addOnPageChangeListener(object : ViewPager.SimpleOnPageChangeListener() { - override fun onPageSelected(position: Int) { - onPageChange(position) - } + pager.addOnPageChangeListener( + object : ViewPager.SimpleOnPageChangeListener() { + override fun onPageSelected(position: Int) { + onPageChange(position) + } - override fun onPageScrollStateChanged(state: Int) { - isIdle = state == ViewPager.SCROLL_STATE_IDLE + override fun onPageScrollStateChanged(state: Int) { + isIdle = state == ViewPager.SCROLL_STATE_IDLE + } } - }) + ) pager.tapListener = f@{ event -> if (!config.tappingEnabled) { activity.toggleMenu() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt index ea84285886..5d8962339d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt @@ -32,12 +32,12 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ReaderProgressBar import eu.kanade.tachiyomi.ui.webview.WebViewActivity import eu.kanade.tachiyomi.util.system.ImageUtil import eu.kanade.tachiyomi.util.system.dpToPx -import java.io.InputStream -import java.util.concurrent.TimeUnit import rx.Observable import rx.Subscription import rx.android.schedulers.AndroidSchedulers import rx.schedulers.Schedulers +import java.io.InputStream +import java.util.concurrent.TimeUnit /** * Holder of the webtoon reader for a single page of a chapter. @@ -362,15 +362,17 @@ class WebtoonPageHolder( setMinimumDpi(90) setMinimumTileDpi(180) setCropBorders(config.imageCropBorders) - setOnImageEventListener(object : SubsamplingScaleImageView.DefaultOnImageEventListener() { - override fun onReady() { - onImageDecoded() - } + setOnImageEventListener( + object : SubsamplingScaleImageView.DefaultOnImageEventListener() { + override fun onReady() { + onImageDecoded() + } - override fun onImageLoadError(e: Exception) { - onImageDecodeError() + override fun onImageLoadError(e: Exception) { + onImageDecodeError() + } } - }) + ) } frame.addView(subsamplingImageView, MATCH_PARENT, MATCH_PARENT) return subsamplingImageView!! @@ -492,31 +494,33 @@ class WebtoonPageHolder( .skipMemoryCache(true) .diskCacheStrategy(DiskCacheStrategy.NONE) .transition(DrawableTransitionOptions.with(NoTransition.getFactory())) - .listener(object : RequestListener { - override fun onLoadFailed( - e: GlideException?, - model: Any?, - target: Target?, - isFirstResource: Boolean - ): Boolean { - onImageDecodeError() - return false - } - - override fun onResourceReady( - resource: Drawable?, - model: Any?, - target: Target?, - dataSource: DataSource?, - isFirstResource: Boolean - ): Boolean { - if (resource is GifDrawable) { - resource.setLoopCount(GifDrawable.LOOP_INTRINSIC) + .listener( + object : RequestListener { + override fun onLoadFailed( + e: GlideException?, + model: Any?, + target: Target?, + isFirstResource: Boolean + ): Boolean { + onImageDecodeError() + return false + } + + override fun onResourceReady( + resource: Drawable?, + model: Any?, + target: Target?, + dataSource: DataSource?, + isFirstResource: Boolean + ): Boolean { + if (resource is GifDrawable) { + resource.setLoopCount(GifDrawable.LOOP_INTRINSIC) + } + onImageDecoded() + return false } - onImageDecoded() - return false } - }) + ) .into(this) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt index bb927f923d..e2a4492369 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt @@ -15,10 +15,10 @@ import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition import eu.kanade.tachiyomi.ui.reader.model.ReaderPage import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer -import kotlin.math.max -import kotlin.math.min import rx.subscriptions.CompositeSubscription import timber.log.Timber +import kotlin.math.max +import kotlin.math.min /** * Implementation of a [BaseViewer] to display pages with a [RecyclerView]. @@ -71,28 +71,30 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr recycler.itemAnimator = null recycler.layoutManager = layoutManager recycler.adapter = adapter - recycler.addOnScrollListener(object : RecyclerView.OnScrollListener() { - override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { - val position = layoutManager.findLastEndVisibleItemPosition() - val item = adapter.items.getOrNull(position) - val allowPreload = checkAllowPreload(item as? ReaderPage) - if (item != null && currentPage != item) { - currentPage = item - when (item) { - is ReaderPage -> onPageSelected(item, allowPreload) - is ChapterTransition -> onTransitionSelected(item) + recycler.addOnScrollListener( + object : RecyclerView.OnScrollListener() { + override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { + val position = layoutManager.findLastEndVisibleItemPosition() + val item = adapter.items.getOrNull(position) + val allowPreload = checkAllowPreload(item as? ReaderPage) + if (item != null && currentPage != item) { + currentPage = item + when (item) { + is ReaderPage -> onPageSelected(item, allowPreload) + is ChapterTransition -> onTransitionSelected(item) + } } - } - if (dy < 0) { - val firstIndex = layoutManager.findFirstVisibleItemPosition() - val firstItem = adapter.items.getOrNull(firstIndex) - if (firstItem is ChapterTransition.Prev && firstItem.to != null) { - activity.requestPreloadChapter(firstItem.to) + if (dy < 0) { + val firstIndex = layoutManager.findFirstVisibleItemPosition() + val firstItem = adapter.items.getOrNull(firstIndex) + if (firstItem is ChapterTransition.Prev && firstItem.to != null) { + activity.requestPreloadChapter(firstItem.to) + } } } } - }) + ) recycler.tapListener = f@{ event -> if (!config.tappingEnabled) { activity.toggleMenu() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryAdapter.kt index 98f2f42454..d5c19f32d3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryAdapter.kt @@ -2,9 +2,9 @@ package eu.kanade.tachiyomi.ui.recent.history import eu.davidea.flexibleadapter.FlexibleAdapter import eu.kanade.tachiyomi.source.SourceManager +import uy.kohesive.injekt.injectLazy import java.text.DecimalFormat import java.text.DecimalFormatSymbols -import uy.kohesive.injekt.injectLazy /** * Adapter of HistoryHolder. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryHolder.kt index cd9a4799d3..595bf640ca 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryHolder.kt @@ -8,13 +8,13 @@ import eu.kanade.tachiyomi.data.glide.GlideApp import eu.kanade.tachiyomi.data.glide.toMangaThumbnail import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder import eu.kanade.tachiyomi.util.lang.toTimestampString -import java.util.Date import kotlinx.android.synthetic.main.history_item.cover import kotlinx.android.synthetic.main.history_item.holder import kotlinx.android.synthetic.main.history_item.manga_subtitle import kotlinx.android.synthetic.main.history_item.manga_title import kotlinx.android.synthetic.main.history_item.remove import kotlinx.android.synthetic.main.history_item.resume +import java.util.Date /** * Holder that contains recent manga item diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryPresenter.kt index b8b5506a1a..b75a1dafdc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryPresenter.kt @@ -9,13 +9,13 @@ import eu.kanade.tachiyomi.data.database.models.MangaChapterHistory import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter import eu.kanade.tachiyomi.ui.recent.DateSectionItem import eu.kanade.tachiyomi.util.lang.toDateKey +import rx.Observable +import rx.android.schedulers.AndroidSchedulers +import uy.kohesive.injekt.injectLazy import java.util.Calendar import java.util.Comparator import java.util.Date import java.util.TreeMap -import rx.Observable -import rx.android.schedulers.AndroidSchedulers -import uy.kohesive.injekt.injectLazy /** * Presenter of HistoryFragment. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt index 86a75cd2dc..84b1c87e15 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt @@ -10,15 +10,15 @@ import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter import eu.kanade.tachiyomi.ui.recent.DateSectionItem import eu.kanade.tachiyomi.util.lang.toDateKey -import java.util.Calendar -import java.util.Date -import java.util.TreeMap import rx.Observable import rx.android.schedulers.AndroidSchedulers import rx.schedulers.Schedulers import timber.log.Timber import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import java.util.Calendar +import java.util.Date +import java.util.TreeMap class UpdatesPresenter( val preferences: PreferencesHelper = Injekt.get(), diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/security/BiometricUnlockActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/security/BiometricUnlockActivity.kt index 9ab2cb2671..92a7d778a0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/security/BiometricUnlockActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/security/BiometricUnlockActivity.kt @@ -5,9 +5,9 @@ import androidx.appcompat.app.AppCompatActivity import androidx.biometric.BiometricPrompt import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferencesHelper +import uy.kohesive.injekt.injectLazy import java.util.Date import java.util.concurrent.Executors -import uy.kohesive.injekt.injectLazy /** * Blank activity with a BiometricPrompt. @@ -21,7 +21,8 @@ class BiometricUnlockActivity : AppCompatActivity() { super.onCreate(savedInstanceState) val biometricPrompt = BiometricPrompt( - this, executor, + this, + executor, object : BiometricPrompt.AuthenticationCallback() { override fun onAuthenticationError(errorCode: Int, errString: CharSequence) { super.onAuthenticationError(errorCode, errString) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt index a34a13819b..5549ae2fb9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt @@ -6,10 +6,10 @@ import androidx.biometric.BiometricManager import androidx.fragment.app.FragmentActivity import androidx.lifecycle.lifecycleScope import eu.kanade.tachiyomi.data.preference.PreferencesHelper -import java.util.Date import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import uy.kohesive.injekt.injectLazy +import java.util.Date class SecureActivityDelegate(private val activity: FragmentActivity) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt index 9be61ad9d5..5d532bee0b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt @@ -15,7 +15,6 @@ import eu.kanade.tachiyomi.data.cache.ChapterCache import eu.kanade.tachiyomi.data.database.DatabaseHelper import eu.kanade.tachiyomi.data.library.LibraryUpdateService import eu.kanade.tachiyomi.data.library.LibraryUpdateService.Target -import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.ui.base.controller.DialogController import eu.kanade.tachiyomi.util.preference.defaultValue @@ -31,6 +30,7 @@ import rx.Observable import rx.android.schedulers.AndroidSchedulers import rx.schedulers.Schedulers import uy.kohesive.injekt.injectLazy +import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys class SettingsAdvancedController : SettingsController() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt index f030d36803..dbcafbb2ab 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt @@ -19,7 +19,6 @@ import eu.kanade.tachiyomi.data.backup.BackupCreatorJob import eu.kanade.tachiyomi.data.backup.BackupRestoreService import eu.kanade.tachiyomi.data.backup.BackupRestoreValidator import eu.kanade.tachiyomi.data.backup.models.Backup -import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys import eu.kanade.tachiyomi.data.preference.asImmediateFlow import eu.kanade.tachiyomi.ui.base.controller.DialogController import eu.kanade.tachiyomi.ui.base.controller.requestPermissionsSafe @@ -36,6 +35,7 @@ import eu.kanade.tachiyomi.util.system.getFilePicker import eu.kanade.tachiyomi.util.system.toast import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach +import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys class SettingsBackupController : SettingsController() { @@ -90,9 +90,12 @@ class SettingsBackupController : SettingsController() { key = Keys.backupInterval titleRes = R.string.pref_backup_interval entriesRes = arrayOf( - R.string.update_never, R.string.update_6hour, - R.string.update_12hour, R.string.update_24hour, - R.string.update_48hour, R.string.update_weekly + R.string.update_never, + R.string.update_6hour, + R.string.update_12hour, + R.string.update_24hour, + R.string.update_48hour, + R.string.update_weekly ) entryValues = arrayOf("0", "6", "12", "24", "48", "168") defaultValue = "0" @@ -211,8 +214,11 @@ class SettingsBackupController : SettingsController() { override fun onCreateDialog(savedViewState: Bundle?): Dialog { val activity = activity!! val options = arrayOf( - R.string.manga, R.string.categories, R.string.chapters, - R.string.track, R.string.history + R.string.manga, + R.string.categories, + R.string.chapters, + R.string.track, + R.string.history ) .map { activity.getString(it) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBrowseController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBrowseController.kt index ab4d0bd7b4..0def71f54a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBrowseController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBrowseController.kt @@ -2,13 +2,13 @@ package eu.kanade.tachiyomi.ui.setting import androidx.preference.PreferenceScreen import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys import eu.kanade.tachiyomi.extension.ExtensionUpdateJob import eu.kanade.tachiyomi.util.preference.defaultValue import eu.kanade.tachiyomi.util.preference.onChange import eu.kanade.tachiyomi.util.preference.preferenceCategory import eu.kanade.tachiyomi.util.preference.switchPreference import eu.kanade.tachiyomi.util.preference.titleRes +import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys class SettingsBrowseController : SettingsController() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt index 82c055a0fc..ad9e7097c7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt @@ -15,7 +15,6 @@ import com.hippo.unifile.UniFile import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.DatabaseHelper import eu.kanade.tachiyomi.data.database.models.Category -import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.asImmediateFlow import eu.kanade.tachiyomi.ui.base.controller.DialogController @@ -29,12 +28,13 @@ import eu.kanade.tachiyomi.util.preference.preferenceCategory import eu.kanade.tachiyomi.util.preference.switchPreference import eu.kanade.tachiyomi.util.preference.titleRes import eu.kanade.tachiyomi.util.system.getFilePicker -import java.io.File import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy +import java.io.File +import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys class SettingsDownloadController : SettingsController() { @@ -76,8 +76,11 @@ class SettingsDownloadController : SettingsController() { key = Keys.removeAfterReadSlots titleRes = R.string.pref_remove_after_read entriesRes = arrayOf( - R.string.disabled, R.string.last_read_chapter, - R.string.second_to_last, R.string.third_to_last, R.string.fourth_to_last, + R.string.disabled, + R.string.last_read_chapter, + R.string.second_to_last, + R.string.third_to_last, + R.string.fourth_to_last, R.string.fifth_to_last ) entryValues = arrayOf("-1", "0", "1", "2", "3", "4") diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt index f3785bea66..6f12604b02 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt @@ -5,8 +5,6 @@ import android.os.Build import android.provider.Settings import androidx.preference.PreferenceScreen import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys -import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values import eu.kanade.tachiyomi.data.preference.asImmediateFlow import eu.kanade.tachiyomi.util.preference.defaultValue import eu.kanade.tachiyomi.util.preference.entriesRes @@ -19,8 +17,10 @@ import eu.kanade.tachiyomi.util.preference.preferenceCategory import eu.kanade.tachiyomi.util.preference.switchPreference import eu.kanade.tachiyomi.util.preference.titleRes import eu.kanade.tachiyomi.util.system.LocaleHelper -import java.util.Date import kotlinx.coroutines.flow.launchIn +import java.util.Date +import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys +import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values class SettingsGeneralController : SettingsController() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt index b42ed0b0a0..09d433af71 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt @@ -11,7 +11,6 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.DatabaseHelper import eu.kanade.tachiyomi.data.database.models.Category import eu.kanade.tachiyomi.data.library.LibraryUpdateJob -import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.asImmediateFlow import eu.kanade.tachiyomi.ui.base.controller.DialogController @@ -35,6 +34,7 @@ import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys class SettingsLibraryController : SettingsController() { @@ -121,9 +121,14 @@ class SettingsLibraryController : SettingsController() { key = Keys.libraryUpdateInterval titleRes = R.string.pref_library_update_interval entriesRes = arrayOf( - R.string.update_never, R.string.update_1hour, - R.string.update_2hour, R.string.update_3hour, R.string.update_6hour, - R.string.update_12hour, R.string.update_24hour, R.string.update_48hour + R.string.update_never, + R.string.update_1hour, + R.string.update_2hour, + R.string.update_3hour, + R.string.update_6hour, + R.string.update_12hour, + R.string.update_24hour, + R.string.update_48hour ) entryValues = arrayOf("0", "1", "2", "3", "6", "12", "24", "48") defaultValue = "24" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsParentalControlsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsParentalControlsController.kt index 016b626c59..60e92af7f5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsParentalControlsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsParentalControlsController.kt @@ -2,14 +2,14 @@ package eu.kanade.tachiyomi.ui.setting import androidx.preference.PreferenceScreen import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys -import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values import eu.kanade.tachiyomi.util.preference.defaultValue import eu.kanade.tachiyomi.util.preference.entriesRes import eu.kanade.tachiyomi.util.preference.infoPreference import eu.kanade.tachiyomi.util.preference.listPreference import eu.kanade.tachiyomi.util.preference.preferenceCategory import eu.kanade.tachiyomi.util.preference.titleRes +import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys +import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values class SettingsParentalControlsController : SettingsController() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt index e35f49666b..2a9d84843d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt @@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.ui.setting import android.os.Build import androidx.preference.PreferenceScreen import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode import eu.kanade.tachiyomi.data.preference.asImmediateFlow import eu.kanade.tachiyomi.util.preference.defaultValue @@ -16,6 +15,7 @@ import eu.kanade.tachiyomi.util.preference.switchPreference import eu.kanade.tachiyomi.util.preference.titleRes import eu.kanade.tachiyomi.util.system.hasDisplayCutout import kotlinx.coroutines.flow.launchIn +import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys class SettingsReaderController : SettingsController() { @@ -26,8 +26,11 @@ class SettingsReaderController : SettingsController() { key = Keys.defaultViewer titleRes = R.string.pref_viewer_type entriesRes = arrayOf( - R.string.left_to_right_viewer, R.string.right_to_left_viewer, - R.string.vertical_viewer, R.string.webtoon_viewer, R.string.vertical_plus_viewer + R.string.left_to_right_viewer, + R.string.right_to_left_viewer, + R.string.vertical_viewer, + R.string.webtoon_viewer, + R.string.vertical_plus_viewer ) entryValues = arrayOf("1", "2", "3", "4", "5") defaultValue = "2" @@ -68,8 +71,10 @@ class SettingsReaderController : SettingsController() { key = Keys.rotation titleRes = R.string.pref_rotation_type entriesRes = arrayOf( - R.string.rotation_free, R.string.rotation_lock, - R.string.rotation_force_portrait, R.string.rotation_force_landscape + R.string.rotation_free, + R.string.rotation_lock, + R.string.rotation_force_portrait, + R.string.rotation_force_landscape ) entryValues = arrayOf("1", "2", "3", "4") defaultValue = "1" @@ -136,9 +141,12 @@ class SettingsReaderController : SettingsController() { key = Keys.imageScaleType titleRes = R.string.pref_image_scale_type entriesRes = arrayOf( - R.string.scale_type_fit_screen, R.string.scale_type_stretch, - R.string.scale_type_fit_width, R.string.scale_type_fit_height, - R.string.scale_type_original_size, R.string.scale_type_smart_fit + R.string.scale_type_fit_screen, + R.string.scale_type_stretch, + R.string.scale_type_fit_width, + R.string.scale_type_fit_height, + R.string.scale_type_original_size, + R.string.scale_type_smart_fit ) entryValues = arrayOf("1", "2", "3", "4", "5", "6") defaultValue = "1" @@ -148,8 +156,10 @@ class SettingsReaderController : SettingsController() { key = Keys.zoomStart titleRes = R.string.pref_zoom_start entriesRes = arrayOf( - R.string.zoom_start_automatic, R.string.zoom_start_left, - R.string.zoom_start_right, R.string.zoom_start_center + R.string.zoom_start_automatic, + R.string.zoom_start_left, + R.string.zoom_start_right, + R.string.zoom_start_center ) entryValues = arrayOf("1", "2", "3", "4") defaultValue = "1" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSecurityController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSecurityController.kt index 6fb3a1e663..82483286c8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSecurityController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSecurityController.kt @@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.ui.setting import androidx.biometric.BiometricManager import androidx.preference.PreferenceScreen import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys import eu.kanade.tachiyomi.data.preference.asImmediateFlow import eu.kanade.tachiyomi.util.preference.defaultValue import eu.kanade.tachiyomi.util.preference.intListPreference @@ -11,6 +10,7 @@ import eu.kanade.tachiyomi.util.preference.summaryRes import eu.kanade.tachiyomi.util.preference.switchPreference import eu.kanade.tachiyomi.util.preference.titleRes import kotlinx.coroutines.flow.launchIn +import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys class SettingsSecurityController : SettingsController() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt index d61cce20ae..5099075a01 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt @@ -5,7 +5,6 @@ import android.content.Intent import androidx.browser.customtabs.CustomTabsIntent import androidx.preference.PreferenceScreen import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.data.track.anilist.AnilistApi @@ -23,6 +22,7 @@ import eu.kanade.tachiyomi.util.preference.titleRes import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.widget.preference.LoginPreference import uy.kohesive.injekt.injectLazy +import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys class SettingsTrackingController : SettingsController(), diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt b/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt index 3c665723d8..308ba27fa1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt @@ -7,10 +7,10 @@ import eu.kanade.tachiyomi.data.download.DownloadManager import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.online.HttpSource -import java.util.Date -import java.util.TreeSet import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import java.util.Date +import java.util.TreeSet /** * Helper method for syncing the list of chapters from the source with the ones from the database. diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/lang/RetryWithDelay.kt b/app/src/main/java/eu/kanade/tachiyomi/util/lang/RetryWithDelay.kt index a14825a4b5..bc1d9a801a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/lang/RetryWithDelay.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/lang/RetryWithDelay.kt @@ -1,10 +1,10 @@ package eu.kanade.tachiyomi.util.lang -import java.util.concurrent.TimeUnit.MILLISECONDS import rx.Observable import rx.Scheduler import rx.functions.Func1 import rx.schedulers.Schedulers +import java.util.concurrent.TimeUnit.MILLISECONDS class RetryWithDelay( private val maxRetries: Int = 1, diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/lang/StringExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/lang/StringExtensions.kt index 1ae62a62e9..74d98276c6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/lang/StringExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/lang/StringExtensions.kt @@ -1,7 +1,7 @@ package eu.kanade.tachiyomi.util.lang -import kotlin.math.floor import net.greypanther.natsort.CaseInsensitiveSimpleNaturalComparator +import kotlin.math.floor /** * Replaces the given string to have at most [count] characters using [replacement] at its end. diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/storage/EpubFile.kt b/app/src/main/java/eu/kanade/tachiyomi/util/storage/EpubFile.kt index 8d6c3a59b0..656467850f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/storage/EpubFile.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/storage/EpubFile.kt @@ -2,6 +2,8 @@ package eu.kanade.tachiyomi.util.storage import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga +import org.jsoup.Jsoup +import org.jsoup.nodes.Document import java.io.Closeable import java.io.File import java.io.InputStream @@ -10,8 +12,6 @@ import java.text.SimpleDateFormat import java.util.Locale import java.util.zip.ZipEntry import java.util.zip.ZipFile -import org.jsoup.Jsoup -import org.jsoup.nodes.Document /** * Wrapper over ZipFile to load files in epub format. diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/storage/OkioExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/storage/OkioExtensions.kt index 0eac12d482..c3f72c8662 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/storage/OkioExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/storage/OkioExtensions.kt @@ -1,10 +1,10 @@ package eu.kanade.tachiyomi.util.storage -import java.io.File -import java.io.OutputStream import okio.BufferedSource import okio.buffer import okio.sink +import java.io.File +import java.io.OutputStream /** * Saves the given source to a file and closes it. Directories will be created if needed. diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/LocaleHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/LocaleHelper.kt index 5ae9383fa9..059facb3a7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/LocaleHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/LocaleHelper.kt @@ -8,8 +8,8 @@ import android.view.ContextThemeWrapper import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.ui.browse.source.SourcePresenter -import java.util.Locale import uy.kohesive.injekt.injectLazy +import java.util.Locale /** * Utility class to change the application's language in runtime. diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/WebViewClientCompat.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/WebViewClientCompat.kt index d32cc11410..8d2eea7cf0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/WebViewClientCompat.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/WebViewClientCompat.kt @@ -61,8 +61,11 @@ abstract class WebViewClientCompat : WebViewClient() { error: WebResourceError ) { onReceivedErrorCompat( - view, error.errorCode, error.description?.toString(), - request.url.toString(), request.isForMainFrame + view, + error.errorCode, + error.description?.toString(), + request.url.toString(), + request.isForMainFrame ) } @@ -82,7 +85,9 @@ abstract class WebViewClientCompat : WebViewClient() { error: WebResourceResponse ) { onReceivedErrorCompat( - view, error.statusCode, error.reasonPhrase, + view, + error.statusCode, + error.reasonPhrase, request.url .toString(), request.isForMainFrame diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/ActionToolbar.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/ActionToolbar.kt index eb6f70c937..4b825cfd83 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/ActionToolbar.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/ActionToolbar.kt @@ -59,11 +59,13 @@ class ActionToolbar @JvmOverloads constructor(context: Context, attrs: Attribute */ fun hide() { val bottomAnimation = AnimationUtils.loadAnimation(context, R.anim.exit_to_bottom) - bottomAnimation.setAnimationListener(object : SimpleAnimationListener() { - override fun onAnimationEnd(animation: Animation) { - common_action_toolbar.isVisible = false + bottomAnimation.setAnimationListener( + object : SimpleAnimationListener() { + override fun onAnimationEnd(animation: Animation) { + common_action_toolbar.isVisible = false + } } - }) + ) common_action_toolbar.startAnimation(bottomAnimation) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/EmptyView.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/EmptyView.kt index 3d56b942e8..05bb89d6c0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/EmptyView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/EmptyView.kt @@ -8,10 +8,10 @@ import androidx.annotation.StringRes import androidx.appcompat.widget.AppCompatButton import androidx.core.view.isVisible import eu.kanade.tachiyomi.R -import kotlin.random.Random import kotlinx.android.synthetic.main.common_view_empty.view.actions_container import kotlinx.android.synthetic.main.common_view_empty.view.text_face import kotlinx.android.synthetic.main.common_view_empty.view.text_label +import kotlin.random.Random class EmptyView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : RelativeLayout(context, attrs) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialFastScroll.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialFastScroll.kt index 3f6778089c..60549d302f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialFastScroll.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialFastScroll.kt @@ -12,7 +12,9 @@ class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: Attr init { setViewsToUse( - R.layout.material_fastscroll, R.id.fast_scroller_bubble, R.id.fast_scroller_handle + R.layout.material_fastscroll, + R.id.fast_scroller_bubble, + R.id.fast_scroller_handle ) autoHideEnabled = true ignoreTouchesOutsideHandle = true diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/NegativeSeekBar.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/NegativeSeekBar.kt index 10f4f12967..36f5a7a6cd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/NegativeSeekBar.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/NegativeSeekBar.kt @@ -18,7 +18,9 @@ class NegativeSeekBar @JvmOverloads constructor(context: Context, attrs: Attribu init { val styledAttributes = context.obtainStyledAttributes( attrs, - R.styleable.NegativeSeekBar, 0, 0 + R.styleable.NegativeSeekBar, + 0, + 0 ) try { @@ -28,19 +30,21 @@ class NegativeSeekBar @JvmOverloads constructor(context: Context, attrs: Attribu styledAttributes.recycle() } - super.setOnSeekBarChangeListener(object : OnSeekBarChangeListener { - override fun onProgressChanged(seekBar: SeekBar?, value: Int, fromUser: Boolean) { - listener?.onProgressChanged(seekBar, minValue + value, fromUser) - } + super.setOnSeekBarChangeListener( + object : OnSeekBarChangeListener { + override fun onProgressChanged(seekBar: SeekBar?, value: Int, fromUser: Boolean) { + listener?.onProgressChanged(seekBar, minValue + value, fromUser) + } - override fun onStartTrackingTouch(p0: SeekBar?) { - listener?.onStartTrackingTouch(p0) - } + override fun onStartTrackingTouch(p0: SeekBar?) { + listener?.onStartTrackingTouch(p0) + } - override fun onStopTrackingTouch(p0: SeekBar?) { - listener?.onStopTrackingTouch(p0) + override fun onStopTrackingTouch(p0: SeekBar?) { + listener?.onStopTrackingTouch(p0) + } } - }) + ) } override fun setProgress(progress: Int) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/RevealAnimationView.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/RevealAnimationView.kt index 69dcde0916..8201d3b4ac 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/RevealAnimationView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/RevealAnimationView.kt @@ -25,7 +25,11 @@ class RevealAnimationView @JvmOverloads constructor(context: Context, attrs: Att // Create the animation (the final radius is zero). val anim = ViewAnimationUtils.createCircularReveal( - this, centerX, centerY, initialRadius.toFloat(), 0f + this, + centerX, + centerY, + initialRadius.toFloat(), + 0f ) // Set duration of animation. @@ -55,7 +59,11 @@ class RevealAnimationView @JvmOverloads constructor(context: Context, attrs: Att // Create animation val anim = ViewAnimationUtils.createCircularReveal( - this, centerX, centerY, 0f, height.toFloat() + this, + centerX, + centerY, + 0f, + height.toFloat() ) // Set duration of animation diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/SimpleNavigationView.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/SimpleNavigationView.kt index 1d91b7b76d..af0cdcfe47 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/SimpleNavigationView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/SimpleNavigationView.kt @@ -18,8 +18,8 @@ import androidx.recyclerview.widget.RecyclerView import com.google.android.material.R import com.google.android.material.internal.ScrimInsetsFrameLayout import com.google.android.material.textfield.TextInputLayout -import eu.kanade.tachiyomi.R as TR import eu.kanade.tachiyomi.util.view.inflate +import eu.kanade.tachiyomi.R as TR @Suppress("LeakingThis") @SuppressLint("PrivateResource", "RestrictedApi") @@ -37,20 +37,24 @@ open class SimpleNavigationView @JvmOverloads constructor( init { // Custom attributes val a = TintTypedArray.obtainStyledAttributes( - context, attrs, - R.styleable.NavigationView, defStyleAttr, + context, + attrs, + R.styleable.NavigationView, + defStyleAttr, R.style.Widget_Design_NavigationView ) ViewCompat.setBackground( - this, a.getDrawable(R.styleable.NavigationView_android_background) + this, + a.getDrawable(R.styleable.NavigationView_android_background) ) if (a.hasValue(R.styleable.NavigationView_elevation)) { ViewCompat.setElevation( this, a.getDimensionPixelSize( - R.styleable.NavigationView_elevation, 0 + R.styleable.NavigationView_elevation, + 0 ).toFloat() ) } diff --git a/build.gradle.kts b/build.gradle.kts index 26bec1e911..8c2aec6b15 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,7 +2,7 @@ plugins { id("com.android.application") version BuildPluginsVersion.AGP apply false id("com.android.library") version BuildPluginsVersion.AGP apply false kotlin("android") version BuildPluginsVersion.KOTLIN apply false - id("org.jlleitschuh.gradle.ktlint") version BuildPluginsVersion.KTLINT + id("org.jmailen.kotlinter") version BuildPluginsVersion.KOLINTER id("com.github.ben-manes.versions") version BuildPluginsVersion.VERSIONS_PLUGIN } @@ -16,22 +16,10 @@ allprojects { } subprojects { - apply { - plugin("org.jlleitschuh.gradle.ktlint") - } + apply(plugin = "org.jmailen.kotlinter") - ktlint { - debug.set(false) - version.set(Versions.KTLINT) - verbose.set(true) - android.set(false) - outputToConsole.set(true) - ignoreFailures.set(false) - enableExperimentalRules.set(true) - filter { - exclude("**/generated/**") - include("**/kotlin/**") - } + kotlinter { + experimentalRules = true } } diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index b2597d892b..0cbb167338 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -1,10 +1,6 @@ -object Versions { - const val KTLINT = "0.36.0" -} - object BuildPluginsVersion { const val AGP = "4.0.1" const val KOTLIN = "1.4.10" - const val KTLINT = "9.2.1" + const val KOLINTER = "3.0.2" const val VERSIONS_PLUGIN = "0.28.0" }