Set preview/experimental compiler flags instead of using annotations

This commit is contained in:
arkon 2020-11-22 11:43:16 -05:00
parent 1140316d1b
commit 781971ee81
15 changed files with 8 additions and 35 deletions

View File

@ -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

View File

@ -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<BackupManga>,

View File

@ -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,

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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

View File

@ -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 = "",

View File

@ -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

View File

@ -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)

View File

@ -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()) {

View File

@ -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()

View File

@ -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<ReaderActivityBinding, ReaderPresenter>()
/**
* Class that handles the user preferences of the reader.
*/
@FlowPreview
private inner class ReaderConfig {
/**
@ -774,7 +772,6 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
/**
* 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<ReaderActivityBinding, ReaderPresenter>()
/**
* Sets the color filter overlay according to [enabled].
*/
@FlowPreview
private fun setColorFilter(enabled: Boolean) {
if (enabled) {
preferences.colorFilterValue().asFlow()

View File

@ -32,7 +32,6 @@ import kotlin.coroutines.resumeWithException
* Util functions for bridging RxJava and coroutines. Taken from TachiyomiEH/SY.
*/
@ExperimentalCoroutinesApi
suspend fun <T> Single<T>.await(subscribeOn: Scheduler? = null): T {
return suspendCancellableCoroutine { continuation ->
val self = if (subscribeOn != null) subscribeOn(subscribeOn) else this
@ -59,7 +58,6 @@ suspend fun <T> Single<T>.await(subscribeOn: Scheduler? = null): T {
suspend fun <T> PreparedOperation<T>.await(): T = asRxSingle().await()
suspend fun <T> PreparedGetObject<T>.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 <T> Observable<T>.awaitOne(): T = suspendCancellableCoroutin
internal fun <T> CancellableContinuation<T>.unsubscribeOnCancellation(sub: Subscription) =
invokeOnCancellation { sub.unsubscribe() }
@ExperimentalCoroutinesApi
fun <T : Any> Observable<T>.asFlow(): Flow<T> = callbackFlow {
val observer = object : Observer<T> {
override fun onNext(t: T) {
@ -202,7 +199,6 @@ fun <T : Any> Observable<T>.asFlow(): Flow<T> = callbackFlow {
awaitClose { subscription.unsubscribe() }
}
@ExperimentalCoroutinesApi
fun <T : Any> Flow<T>.asObservable(backpressureMode: Emitter.BackpressureMode = Emitter.BackpressureMode.NONE): Observable<T> {
return Observable.create(
{ emitter ->

View File

@ -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) {