From 781971ee813b9c3a71558c268365e9495dbc41c2 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 22 Nov 2020 11:43:16 -0500 Subject: [PATCH] Set preview/experimental compiler flags instead of using annotations --- app/build.gradle | 9 ++++++++- .../kanade/tachiyomi/data/backup/full/models/Backup.kt | 5 ----- .../tachiyomi/data/backup/full/models/BackupCategory.kt | 2 -- .../tachiyomi/data/backup/full/models/BackupChapter.kt | 2 -- .../tachiyomi/data/backup/full/models/BackupHistory.kt | 2 -- .../tachiyomi/data/backup/full/models/BackupManga.kt | 2 -- .../data/backup/full/models/BackupSerializer.kt | 2 -- .../tachiyomi/data/backup/full/models/BackupSource.kt | 2 -- .../tachiyomi/data/backup/full/models/BackupTracking.kt | 2 -- .../ui/manga/chapter/MangaChaptersHeaderAdapter.kt | 2 -- .../tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt | 2 -- .../kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt | 2 -- .../java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt | 4 ---- .../eu/kanade/tachiyomi/util/lang/RxCoroutineBridge.kt | 4 ---- .../eu/kanade/tachiyomi/util/lang/StringExtensions.kt | 1 - 15 files changed, 8 insertions(+), 35 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 3985fb1a3..7969df264 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -309,7 +309,14 @@ repositories { // See https://kotlinlang.org/docs/reference/experimental.html#experimental-status-of-experimental-api-markers tasks.withType(AbstractKotlinCompile).all { - kotlinOptions.freeCompilerArgs += ["-Xopt-in=kotlin.Experimental"] + kotlinOptions.freeCompilerArgs += [ + "-Xopt-in=kotlin.Experimental", + "-Xopt-in=kotlin.RequiresOptIn", + "-Xuse-experimental=kotlin.ExperimentalStdlibApi", + "-Xuse-experimental=kotlinx.coroutines.FlowPreview", + "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi", + "-Xuse-experimental=kotlinx.serialization.ExperimentalSerializationApi", + ] } // Duplicating Hebrew string assets due to some locale code issues on different devices diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/Backup.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/Backup.kt index 705fd02a6..b938639e7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/Backup.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/Backup.kt @@ -1,13 +1,8 @@ package eu.kanade.tachiyomi.data.backup.full.models -import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.Serializable import kotlinx.serialization.protobuf.ProtoNumber -/** - * Backup json model - */ -@ExperimentalSerializationApi @Serializable data class Backup( @ProtoNumber(1) val backupManga: List, diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupCategory.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupCategory.kt index 1fec2dd4c..e1d543eda 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupCategory.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupCategory.kt @@ -2,11 +2,9 @@ package eu.kanade.tachiyomi.data.backup.full.models import eu.kanade.tachiyomi.data.database.models.Category import eu.kanade.tachiyomi.data.database.models.CategoryImpl -import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.Serializable import kotlinx.serialization.protobuf.ProtoNumber -@ExperimentalSerializationApi @Serializable class BackupCategory( @ProtoNumber(1) var name: String, diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupChapter.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupChapter.kt index c9cdc0ccd..05111123b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupChapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupChapter.kt @@ -2,11 +2,9 @@ package eu.kanade.tachiyomi.data.backup.full.models import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.data.database.models.ChapterImpl -import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.Serializable import kotlinx.serialization.protobuf.ProtoNumber -@ExperimentalSerializationApi @Serializable data class BackupChapter( // in 1.x some of these values have different names diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupHistory.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupHistory.kt index cd43c4eda..3cbfbc622 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupHistory.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupHistory.kt @@ -1,10 +1,8 @@ package eu.kanade.tachiyomi.data.backup.full.models -import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.Serializable import kotlinx.serialization.protobuf.ProtoNumber -@ExperimentalSerializationApi @Serializable data class BackupHistory( @ProtoNumber(0) var url: String, diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupManga.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupManga.kt index 9812a7882..8e863ad74 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupManga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupManga.kt @@ -4,11 +4,9 @@ import eu.kanade.tachiyomi.data.database.models.ChapterImpl import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.MangaImpl import eu.kanade.tachiyomi.data.database.models.TrackImpl -import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.Serializable import kotlinx.serialization.protobuf.ProtoNumber -@ExperimentalSerializationApi @Serializable data class BackupManga( // in 1.x some of these values have different names diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupSerializer.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupSerializer.kt index 5e3730588..55b1c6afc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupSerializer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupSerializer.kt @@ -1,8 +1,6 @@ package eu.kanade.tachiyomi.data.backup.full.models -import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.Serializer -@ExperimentalSerializationApi @Serializer(forClass = Backup::class) object BackupSerializer diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupSource.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupSource.kt index a4e9e4d23..78b993373 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupSource.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupSource.kt @@ -1,11 +1,9 @@ package eu.kanade.tachiyomi.data.backup.full.models import eu.kanade.tachiyomi.source.Source -import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.Serializable import kotlinx.serialization.protobuf.ProtoNumber -@ExperimentalSerializationApi @Serializable data class BackupSource( @ProtoNumber(0) var name: String = "", diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupTracking.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupTracking.kt index 982ec3ecc..270adf2bf 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupTracking.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupTracking.kt @@ -2,11 +2,9 @@ package eu.kanade.tachiyomi.data.backup.full.models import eu.kanade.tachiyomi.data.database.models.Track import eu.kanade.tachiyomi.data.database.models.TrackImpl -import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.Serializable import kotlinx.serialization.protobuf.ProtoNumber -@ExperimentalSerializationApi @Serializable data class BackupTracking( // in 1.x some of these values have different types or names diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaChaptersHeaderAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaChaptersHeaderAdapter.kt index 55eadf678..ff2039b6f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaChaptersHeaderAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaChaptersHeaderAdapter.kt @@ -11,7 +11,6 @@ import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.util.system.getResourceColor import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.Job import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.merge @@ -53,7 +52,6 @@ class MangaChaptersHeaderAdapter( } inner class HeaderViewHolder(private val view: View) : RecyclerView.ViewHolder(view) { - @ExperimentalCoroutinesApi fun bind() { binding.chaptersLabel.text = if (numChapters == null) { view.context.getString(R.string.chapters) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt index f6e0ba45a..4a5108d00 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt @@ -25,7 +25,6 @@ import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.view.setChips import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.Job import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.merge @@ -204,7 +203,6 @@ class MangaInfoHeaderAdapter( * @param manga manga object containing information about manga. * @param source the source of the manga. */ - @ExperimentalCoroutinesApi private fun setMangaInfo(manga: Manga, source: Source?) { // Update full title TextView. binding.mangaFullTitle.text = if (manga.title.isBlank()) { 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 e0631e5a3..0c3b76864 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 @@ -17,7 +17,6 @@ import eu.kanade.tachiyomi.ui.base.controller.DialogController 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 -import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.launchIn @@ -95,7 +94,6 @@ class TrackSearchDialog : DialogController { adapter = null } - @FlowPreview override fun onAttach(view: View) { super.onAttach(view) dialogView!!.track_search.textChanges() 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 1c291f3b0..9e102b853 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,7 +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 kotlinx.coroutines.FlowPreview import kotlinx.coroutines.delay import kotlinx.coroutines.flow.drop import kotlinx.coroutines.flow.launchIn @@ -653,7 +652,6 @@ class ReaderActivity : BaseRxActivity() /** * Class that handles the user preferences of the reader. */ - @FlowPreview private inner class ReaderConfig { /** @@ -774,7 +772,6 @@ class ReaderActivity : BaseRxActivity() /** * Sets the custom brightness overlay according to [enabled]. */ - @FlowPreview private fun setCustomBrightness(enabled: Boolean) { if (enabled) { preferences.customBrightnessValue().asFlow() @@ -789,7 +786,6 @@ class ReaderActivity : BaseRxActivity() /** * Sets the color filter overlay according to [enabled]. */ - @FlowPreview private fun setColorFilter(enabled: Boolean) { if (enabled) { preferences.colorFilterValue().asFlow() diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/lang/RxCoroutineBridge.kt b/app/src/main/java/eu/kanade/tachiyomi/util/lang/RxCoroutineBridge.kt index 6e1be8681..8ec5ccfa2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/lang/RxCoroutineBridge.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/lang/RxCoroutineBridge.kt @@ -32,7 +32,6 @@ import kotlin.coroutines.resumeWithException * Util functions for bridging RxJava and coroutines. Taken from TachiyomiEH/SY. */ -@ExperimentalCoroutinesApi suspend fun Single.await(subscribeOn: Scheduler? = null): T { return suspendCancellableCoroutine { continuation -> val self = if (subscribeOn != null) subscribeOn(subscribeOn) else this @@ -59,7 +58,6 @@ suspend fun Single.await(subscribeOn: Scheduler? = null): T { suspend fun PreparedOperation.await(): T = asRxSingle().await() suspend fun PreparedGetObject.await(): T? = asRxSingle().await() -@ExperimentalCoroutinesApi suspend fun Completable.awaitSuspending(subscribeOn: Scheduler? = null) { return suspendCancellableCoroutine { continuation -> val self = if (subscribeOn != null) subscribeOn(subscribeOn) else this @@ -183,7 +181,6 @@ private suspend fun Observable.awaitOne(): T = suspendCancellableCoroutin internal fun CancellableContinuation.unsubscribeOnCancellation(sub: Subscription) = invokeOnCancellation { sub.unsubscribe() } -@ExperimentalCoroutinesApi fun Observable.asFlow(): Flow = callbackFlow { val observer = object : Observer { override fun onNext(t: T) { @@ -202,7 +199,6 @@ fun Observable.asFlow(): Flow = callbackFlow { awaitClose { subscription.unsubscribe() } } -@ExperimentalCoroutinesApi fun Flow.asObservable(backpressureMode: Emitter.BackpressureMode = Emitter.BackpressureMode.NONE): Observable { return Observable.create( { emitter -> 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 74d98276c..728615942 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 @@ -48,7 +48,6 @@ fun String.byteSize(): Int { * Returns a string containing the first [n] bytes from this string, or the entire string if this * string is shorter. */ -@OptIn(ExperimentalStdlibApi::class) fun String.takeBytes(n: Int): String { val bytes = toByteArray(Charsets.UTF_8) return if (bytes.size <= n) {