Cleanup and fix a few compiler warnings
This commit is contained in:
@@ -26,6 +26,7 @@ import exh.util.await
|
||||
import exh.util.cancellable
|
||||
import exh.util.jobScheduler
|
||||
import java.lang.RuntimeException
|
||||
import kotlinx.coroutines.FlowPreview
|
||||
import kotlinx.coroutines.flow.asFlow
|
||||
import kotlinx.coroutines.flow.mapNotNull
|
||||
import kotlinx.coroutines.flow.toList
|
||||
@@ -34,6 +35,7 @@ import timber.log.Timber
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import xyz.nulldev.ts.api.http.serializer.FilterSerializer
|
||||
|
||||
@OptIn(FlowPreview::class)
|
||||
object DebugFunctions {
|
||||
val app: Application by injectLazy()
|
||||
val db: DatabaseHelper by injectLazy()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package exh.debug
|
||||
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
enum class DebugToggles(val default: Boolean) {
|
||||
@@ -17,6 +18,7 @@ enum class DebugToggles(val default: Boolean) {
|
||||
|
||||
val prefKey = "eh_debug_toggle_${name.toLowerCase()}"
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
var enabled: Boolean
|
||||
get() = prefs.flowPrefs.getBoolean(prefKey, default).get()
|
||||
set(value) {
|
||||
|
||||
@@ -34,6 +34,8 @@ import kotlin.time.days
|
||||
import kotlin.time.hours
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.FlowPreview
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.cancelAndJoin
|
||||
import kotlinx.coroutines.flow.asFlow
|
||||
@@ -128,6 +130,7 @@ class EHentaiUpdateWorker : JobService(), CoroutineScope {
|
||||
return true
|
||||
}
|
||||
|
||||
@OptIn(FlowPreview::class)
|
||||
private suspend fun startUpdating() {
|
||||
logger.d("Update job started!")
|
||||
val startTime = System.currentTimeMillis()
|
||||
@@ -255,6 +258,7 @@ class EHentaiUpdateWorker : JobService(), CoroutineScope {
|
||||
}
|
||||
|
||||
// New, current
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
private suspend fun updateEntryAndGetChapters(manga: Manga): Pair<List<Chapter>, List<Chapter>> {
|
||||
val source = sourceManager.get(manga.source) as? EHentai
|
||||
?: throw GalleryNotUpdatedException(false, IllegalStateException("Missing EH-based source (${manga.source})!"))
|
||||
|
||||
@@ -117,7 +117,7 @@ class FavoritesSyncHelper(val context: Context) {
|
||||
ignore { wifiLock?.release() }
|
||||
wifiLock = ignore {
|
||||
context.wifiManager.createWifiLock(
|
||||
WifiManager.WIFI_MODE_FULL,
|
||||
WifiManager.WIFI_MODE_FULL_HIGH_PERF,
|
||||
"teh:ExhFavoritesSyncWifi"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ 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
|
||||
@@ -14,6 +15,7 @@ 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))
|
||||
|
||||
@@ -51,11 +51,6 @@ class NHentaiSearchMetadata : RaisedSearchMetadata() {
|
||||
if (it.isNotEmpty()) manga.artist = it.joinToString(transform = { it.name })
|
||||
}
|
||||
|
||||
var category: String? = null
|
||||
tags.filter { it.namespace == NHENTAI_CATEGORIES_NAMESPACE }.let {
|
||||
if (it.isNotEmpty()) category = it.joinToString(transform = { it.name })
|
||||
}
|
||||
|
||||
// Copy tags -> genres
|
||||
manga.genre = tagsToGenreString()
|
||||
|
||||
@@ -70,23 +65,7 @@ class NHentaiSearchMetadata : RaisedSearchMetadata() {
|
||||
}
|
||||
}
|
||||
|
||||
/*val titleDesc = StringBuilder()
|
||||
englishTitle?.let { titleDesc += "English Title: $it\n" }
|
||||
japaneseTitle?.let { titleDesc += "Japanese Title: $it\n" }
|
||||
shortTitle?.let { titleDesc += "Short Title: $it\n" }
|
||||
|
||||
val detailsDesc = StringBuilder()
|
||||
category?.let { detailsDesc += "Category: $it\n" }
|
||||
uploadDate?.let { detailsDesc += "Upload Date: ${EX_DATE_FORMAT.format(Date(it * 1000))}\n" }
|
||||
pageImageTypes.size.let { detailsDesc += "Length: $it pages\n" }
|
||||
favoritesCount?.let { detailsDesc += "Favorited: $it times\n" }
|
||||
scanlator?.nullIfBlank()?.let { detailsDesc += "Scanlator: $it\n" }
|
||||
|
||||
val tagsDesc = tagsToDescription()*/
|
||||
|
||||
manga.description = "meta" /*listOf(titleDesc.toString(), detailsDesc.toString(), tagsDesc.toString())
|
||||
.filter(String::isNotBlank)
|
||||
.joinToString(separator = "\n")*/
|
||||
manga.description = "meta"
|
||||
}
|
||||
|
||||
override fun getExtraInfoPairs(context: Context): List<Pair<String, String>> {
|
||||
|
||||
@@ -8,6 +8,7 @@ import eu.kanade.tachiyomi.source.model.SManga
|
||||
import exh.util.await
|
||||
import info.debatty.java.stringsimilarity.NormalizedLevenshtein
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.supervisorScope
|
||||
import rx.schedulers.Schedulers
|
||||
@@ -20,6 +21,7 @@ class SmartSearchEngine(
|
||||
|
||||
private val normalizedLevenshtein = NormalizedLevenshtein()
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
suspend fun smartSearch(source: CatalogueSource, title: String): SManga? {
|
||||
val cleanedTitle = cleanSmartSearchTitle(title)
|
||||
|
||||
@@ -49,6 +51,7 @@ class SmartSearchEngine(
|
||||
return eligibleManga.maxByOrNull { it.dist }?.manga
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
suspend fun normalSearch(source: CatalogueSource, title: String): SManga? {
|
||||
val eligibleManga = supervisorScope {
|
||||
val searchQuery = if (extraSearchParams != null) {
|
||||
|
||||
@@ -70,12 +70,14 @@ class BrowserActionActivity : AppCompatActivity() {
|
||||
}
|
||||
} else null
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val headers = (
|
||||
(source as? HttpSource)?.headers?.toMultimap()?.mapValues {
|
||||
it.value.joinToString(",")
|
||||
} ?: emptyMap()
|
||||
) + (intent.getSerializableExtra(HEADERS_EXTRA) as? HashMap<String, String> ?: emptyMap())
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val cookies: HashMap<String, String>? =
|
||||
intent.getSerializableExtra(COOKIES_EXTRA) as? HashMap<String, String>
|
||||
val script: String? = intent.getStringExtra(SCRIPT_EXTRA)
|
||||
|
||||
@@ -44,12 +44,14 @@ class DeferredField<T> {
|
||||
*/
|
||||
suspend fun get(): T {
|
||||
// Check if field is initialized and return immediately if it is
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
if (initialized) return content as T
|
||||
|
||||
// Wait for field to initialize
|
||||
mutex.withLock {}
|
||||
|
||||
// Field is initialized, return value
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return content as T
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package exh.util
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.view.WindowInsets
|
||||
import androidx.annotation.Px
|
||||
import com.google.android.material.chip.Chip
|
||||
import com.google.android.material.chip.ChipGroup
|
||||
import exh.EH_SOURCE_ID
|
||||
@@ -12,23 +9,6 @@ import exh.metadata.metadata.EHentaiSearchMetadata.Companion.TAG_TYPE_LIGHT
|
||||
import exh.metadata.metadata.EHentaiSearchMetadata.Companion.TAG_TYPE_NORMAL
|
||||
import exh.metadata.metadata.EHentaiSearchMetadata.Companion.TAG_TYPE_WEAK
|
||||
|
||||
inline fun View.updatePaddingRelative(
|
||||
@Px start: Int = paddingStart,
|
||||
@Px top: Int = paddingTop,
|
||||
@Px end: Int = paddingEnd,
|
||||
@Px bottom: Int = paddingBottom
|
||||
) {
|
||||
setPaddingRelative(start, top, end, bottom)
|
||||
}
|
||||
|
||||
object RecyclerWindowInsetsListener : View.OnApplyWindowInsetsListener {
|
||||
override fun onApplyWindowInsets(v: View, insets: WindowInsets): WindowInsets {
|
||||
v.updatePaddingRelative(bottom = insets.systemWindowInsetBottom)
|
||||
// v.updatePaddingRelative(bottom = v.paddingBottom + insets.systemWindowInsetBottom)
|
||||
return insets
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces chips in a ChipGroup.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package exh.widget.preference
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
@@ -32,7 +31,7 @@ class MangadexLoginDialog(bundle: Bundle? = null) : LoginDialogPreference(bundle
|
||||
|
||||
val scope = CoroutineScope(Job() + Dispatchers.Main)
|
||||
|
||||
constructor(source: MangaDex, activity: Activity? = null) : this(
|
||||
constructor(source: MangaDex) : this(
|
||||
Bundle().apply {
|
||||
putLong(
|
||||
"key",
|
||||
|
||||
Reference in New Issue
Block a user