Set preview/experimental compiler flags instead of using annotations
(cherry picked from commit 781971ee81)
# Conflicts:
# app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt
This commit is contained in:
@@ -20,7 +20,6 @@ import exh.metadata.metadata.base.insertFlatMetadata
|
||||
import exh.savedsearches.JsonSavedSearch
|
||||
import exh.util.cancellable
|
||||
import exh.util.jobScheduler
|
||||
import kotlinx.coroutines.FlowPreview
|
||||
import kotlinx.coroutines.flow.asFlow
|
||||
import kotlinx.coroutines.flow.mapNotNull
|
||||
import kotlinx.coroutines.flow.toList
|
||||
@@ -31,7 +30,6 @@ import kotlinx.serialization.json.Json
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.lang.RuntimeException
|
||||
|
||||
@OptIn(FlowPreview::class)
|
||||
object DebugFunctions {
|
||||
val app: Application by injectLazy()
|
||||
val db: DatabaseHelper by injectLazy()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package exh.debug
|
||||
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.util.Locale
|
||||
|
||||
@@ -19,7 +18,6 @@ enum class DebugToggles(val default: Boolean) {
|
||||
|
||||
val prefKey = "eh_debug_toggle_${name.toLowerCase(Locale.getDefault())}"
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
var enabled: Boolean
|
||||
get() = prefs.flowPrefs.getBoolean(prefKey, default).get()
|
||||
set(value) {
|
||||
|
||||
@@ -29,7 +29,6 @@ import exh.util.cancellable
|
||||
import exh.util.jobScheduler
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.FlowPreview
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.cancelAndJoin
|
||||
import kotlinx.coroutines.flow.asFlow
|
||||
@@ -130,7 +129,6 @@ class EHentaiUpdateWorker : JobService(), CoroutineScope {
|
||||
return true
|
||||
}
|
||||
|
||||
@OptIn(FlowPreview::class)
|
||||
private suspend fun startUpdating() {
|
||||
logger.d("Update job started!")
|
||||
val startTime = System.currentTimeMillis()
|
||||
|
||||
@@ -3,7 +3,6 @@ package exh.md.handlers
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import exh.md.handlers.serializers.MangaPlusSerializer
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.protobuf.ProtoBuf
|
||||
import okhttp3.Headers
|
||||
import okhttp3.Interceptor
|
||||
@@ -26,7 +25,6 @@ class MangaPlusHandler(currentClient: OkHttpClient) {
|
||||
.addInterceptor { imageIntercept(it) }
|
||||
.build()
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
fun fetchPageList(chapterId: String): List<Page> {
|
||||
val response = client.newCall(pageListRequest(chapterId)).execute()
|
||||
return pageListParse(response)
|
||||
@@ -39,7 +37,6 @@ class MangaPlusHandler(currentClient: OkHttpClient) {
|
||||
)
|
||||
}
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
private fun pageListParse(response: Response): List<Page> {
|
||||
val result = ProtoBuf.decodeFromByteArray(MangaPlusSerializer, response.body!!.bytes())
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import exh.md.utils.MdUtil
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import okhttp3.CacheControl
|
||||
import okhttp3.Headers
|
||||
import okhttp3.OkHttpClient
|
||||
@@ -15,7 +14,6 @@ import rx.Observable
|
||||
// Unused, kept for reference todo
|
||||
class PageHandler(val client: OkHttpClient, val headers: Headers, private val imageServer: String, val dataSaver: String?) {
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
fun fetchPageList(chapter: SChapter): Observable<List<Page>> {
|
||||
if (chapter.scanlator.equals("MangaPlus")) {
|
||||
return client.newCall(pageListRequest(chapter))
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
package exh.md.handlers.serializers
|
||||
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.Serializer
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
@Serializer(forClass = MangaPlusResponse::class)
|
||||
object MangaPlusSerializer
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
@Serializable
|
||||
data class MangaPlusResponse(
|
||||
@ProtoNumber(1) val success: SuccessResult? = null,
|
||||
@ProtoNumber(2) val error: ErrorResult? = null
|
||||
)
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
@Serializable
|
||||
data class ErrorResult(
|
||||
@ProtoNumber(1) val action: Action,
|
||||
@@ -26,14 +22,12 @@ data class ErrorResult(
|
||||
|
||||
enum class Action { DEFAULT, UNAUTHORIZED, MAINTAINENCE, GEOIP_BLOCKING }
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
@Serializable
|
||||
data class Popup(
|
||||
@ProtoNumber(1) val subject: String,
|
||||
@ProtoNumber(2) val body: String
|
||||
)
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
@Serializable
|
||||
data class SuccessResult(
|
||||
@ProtoNumber(1) val isFeaturedUpdated: Boolean? = false,
|
||||
@@ -44,19 +38,15 @@ data class SuccessResult(
|
||||
@ProtoNumber(11) val webHomeView: WebHomeView? = null
|
||||
)
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
@Serializable
|
||||
data class TitleRankingView(@ProtoNumber(1) val titles: List<Title> = emptyList())
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
@Serializable
|
||||
data class AllTitlesView(@ProtoNumber(1) val titles: List<Title> = emptyList())
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
@Serializable
|
||||
data class WebHomeView(@ProtoNumber(2) val groups: List<UpdatedTitleGroup> = emptyList())
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
@Serializable
|
||||
data class TitleDetailView(
|
||||
@ProtoNumber(1) val title: Title,
|
||||
@@ -75,11 +65,9 @@ data class TitleDetailView(
|
||||
|
||||
enum class UpdateTiming { NOT_REGULARLY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY, DAY }
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
@Serializable
|
||||
data class MangaViewer(@ProtoNumber(1) val pages: List<MangaPlusPage> = emptyList())
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
@Serializable
|
||||
data class Title(
|
||||
@ProtoNumber(1) val titleId: Int,
|
||||
@@ -91,7 +79,6 @@ data class Title(
|
||||
@ProtoNumber(7) val language: Language? = Language.ENGLISH
|
||||
)
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
@Serializable
|
||||
enum class Language(val id: Int) {
|
||||
@ProtoNumber(0)
|
||||
@@ -101,20 +88,17 @@ enum class Language(val id: Int) {
|
||||
SPANISH(1)
|
||||
}
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
@Serializable
|
||||
data class UpdatedTitleGroup(
|
||||
@ProtoNumber(1) val groupName: String,
|
||||
@ProtoNumber(2) val titles: List<UpdatedTitle> = emptyList()
|
||||
)
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
@Serializable
|
||||
data class UpdatedTitle(
|
||||
@ProtoNumber(1) val title: Title? = null
|
||||
)
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
@Serializable
|
||||
data class Chapter(
|
||||
@ProtoNumber(1) val titleId: Int,
|
||||
@@ -125,11 +109,9 @@ data class Chapter(
|
||||
@ProtoNumber(7) val endTimeStamp: Int
|
||||
)
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
@Serializable
|
||||
data class MangaPlusPage(@ProtoNumber(1) val page: MangaPage? = null)
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
@Serializable
|
||||
data class MangaPage(
|
||||
@ProtoNumber(1) val imageUrl: String,
|
||||
|
||||
@@ -2,7 +2,6 @@ package exh.md.similar
|
||||
|
||||
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
|
||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.MediaType.Companion.toMediaType
|
||||
import okhttp3.ResponseBody
|
||||
@@ -28,7 +27,6 @@ interface SimilarHttpService {
|
||||
.build()
|
||||
}
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
fun create(): SimilarHttpService {
|
||||
// actual builder, which will parse the underlying json file
|
||||
val adapter = Retrofit.Builder()
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package exh.util
|
||||
|
||||
import kotlinx.coroutines.FlowPreview
|
||||
import kotlinx.coroutines.ensureActive
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlin.coroutines.coroutineContext
|
||||
|
||||
@FlowPreview
|
||||
fun <T> Flow<T>.cancellable() = onEach {
|
||||
coroutineContext.ensureActive()
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import kotlinx.coroutines.CancellableContinuation
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.CoroutineStart
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.InternalCoroutinesApi
|
||||
import kotlinx.coroutines.channels.awaitClose
|
||||
@@ -51,7 +50,6 @@ fun <T> Observable<T>.melt(): Observable<T> {
|
||||
return rs
|
||||
}
|
||||
|
||||
@ExperimentalCoroutinesApi
|
||||
suspend fun <T> Single<T>.await(subscribeOn: Scheduler? = null): T {
|
||||
return suspendCancellableCoroutine { continuation ->
|
||||
val self = if (subscribeOn != null) subscribeOn(subscribeOn) else this
|
||||
@@ -78,7 +76,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
|
||||
@@ -136,33 +133,33 @@ suspend fun <T> Single<T>.await(): T = suspendCancellableCoroutine { cont ->
|
||||
)
|
||||
}
|
||||
|
||||
@OptIn(InternalCoroutinesApi::class, ExperimentalCoroutinesApi::class)
|
||||
@OptIn(InternalCoroutinesApi::class)
|
||||
suspend fun <T> Observable<T>.awaitFirst(): T = first().awaitOne()
|
||||
|
||||
@OptIn(InternalCoroutinesApi::class, ExperimentalCoroutinesApi::class)
|
||||
@OptIn(InternalCoroutinesApi::class)
|
||||
suspend fun <T> Observable<T>.awaitFirstOrDefault(default: T): T = firstOrDefault(default).awaitOne()
|
||||
|
||||
@OptIn(InternalCoroutinesApi::class, ExperimentalCoroutinesApi::class)
|
||||
@OptIn(InternalCoroutinesApi::class)
|
||||
suspend fun <T> Observable<T>.awaitFirstOrNull(): T? = firstOrDefault(null).awaitOne()
|
||||
|
||||
@OptIn(InternalCoroutinesApi::class, ExperimentalCoroutinesApi::class)
|
||||
@OptIn(InternalCoroutinesApi::class)
|
||||
suspend fun <T> Observable<T>.awaitFirstOrElse(defaultValue: () -> T): T = switchIfEmpty(
|
||||
Observable.fromCallable(
|
||||
defaultValue
|
||||
)
|
||||
).first().awaitOne()
|
||||
|
||||
@OptIn(InternalCoroutinesApi::class, ExperimentalCoroutinesApi::class)
|
||||
@OptIn(InternalCoroutinesApi::class)
|
||||
suspend fun <T> Observable<T>.awaitLast(): T = last().awaitOne()
|
||||
|
||||
@OptIn(InternalCoroutinesApi::class, ExperimentalCoroutinesApi::class)
|
||||
@OptIn(InternalCoroutinesApi::class)
|
||||
suspend fun <T> Observable<T>.awaitSingle(): T = single().awaitOne()
|
||||
|
||||
suspend fun <T> Observable<T>.awaitSingleOrDefault(default: T): T = singleOrDefault(default).awaitOne()
|
||||
|
||||
suspend fun <T> Observable<T>.awaitSingleOrNull(): T? = singleOrDefault(null).awaitOne()
|
||||
|
||||
@OptIn(InternalCoroutinesApi::class, ExperimentalCoroutinesApi::class)
|
||||
@OptIn(InternalCoroutinesApi::class)
|
||||
private suspend fun <T> Observable<T>.awaitOne(): T = suspendCancellableCoroutine { cont ->
|
||||
cont.unsubscribeOnCancellation(
|
||||
subscribe(
|
||||
@@ -202,7 +199,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) {
|
||||
@@ -221,7 +217,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 ->
|
||||
|
||||
Reference in New Issue
Block a user