Cleanup
This commit is contained in:
parent
a35e7871e8
commit
0594efb1c8
@ -13,6 +13,7 @@ import eu.kanade.tachiyomi.data.track.TrackManager
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.POST
|
||||
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||
import eu.kanade.tachiyomi.network.await
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import eu.kanade.tachiyomi.source.model.MangasPage
|
||||
@ -190,7 +191,7 @@ class MangaDex(delegate: HttpSource, val context: Context) :
|
||||
headers,
|
||||
formBody.build()
|
||||
)
|
||||
).execute()
|
||||
).await()
|
||||
|
||||
response.body!!.string().let {
|
||||
if (it.isEmpty()) {
|
||||
|
@ -3,6 +3,7 @@ package exh.debug
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.util.Locale
|
||||
|
||||
enum class DebugToggles(val default: Boolean) {
|
||||
// Redirect to master version of gallery when encountering a gallery that has a parent/child that is already in the library
|
||||
@ -16,7 +17,7 @@ enum class DebugToggles(val default: Boolean) {
|
||||
// Pretend that all galleries only have a single version
|
||||
INCLUDE_ONLY_ROOT_WHEN_LOADING_EXH_VERSIONS(false);
|
||||
|
||||
val prefKey = "eh_debug_toggle_${name.toLowerCase()}"
|
||||
val prefKey = "eh_debug_toggle_${name.toLowerCase(Locale.getDefault())}"
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
var enabled: Boolean
|
||||
|
@ -15,6 +15,7 @@ import eu.kanade.tachiyomi.util.preference.onClick
|
||||
import eu.kanade.tachiyomi.util.preference.preference
|
||||
import eu.kanade.tachiyomi.util.preference.preferenceCategory
|
||||
import eu.kanade.tachiyomi.util.preference.switchPreference
|
||||
import java.util.Locale
|
||||
import kotlin.reflect.KVisibility
|
||||
import kotlin.reflect.full.declaredFunctions
|
||||
|
||||
@ -30,7 +31,7 @@ class SettingsDebugController : SettingsController() {
|
||||
it.visibility == KVisibility.PUBLIC
|
||||
}.forEach {
|
||||
preference {
|
||||
title = it.name.replace(Regex("(.)(\\p{Upper})"), "$1 $2").toLowerCase().capitalize()
|
||||
title = it.name.replace(Regex("(.)(\\p{Upper})"), "$1 $2").toLowerCase(Locale.getDefault()).capitalize(Locale.getDefault())
|
||||
isPersistent = false
|
||||
|
||||
onClick {
|
||||
@ -61,7 +62,7 @@ class SettingsDebugController : SettingsController() {
|
||||
|
||||
DebugToggles.values().forEach {
|
||||
switchPreference {
|
||||
title = it.name.replace('_', ' ').toLowerCase().capitalize()
|
||||
title = it.name.replace('_', ' ').toLowerCase(Locale.getDefault()).capitalize(Locale.getDefault())
|
||||
key = it.prefKey
|
||||
defaultValue = it.default
|
||||
summaryOn = if (it.default) "" else MODIFIED_TEXT
|
||||
|
@ -13,6 +13,7 @@ import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.util.Locale
|
||||
|
||||
class EHDebugModeOverlay(private val context: Context) : OverlayModule<String>(null, null) {
|
||||
private var textView: TextView? = null
|
||||
@ -57,7 +58,7 @@ class EHDebugModeOverlay(private val context: Context) : OverlayModule<String>(n
|
||||
<b>Debug mode:</b> ${BuildConfig.DEBUG.asEnabledString()}<br>
|
||||
<b>Version code:</b> ${BuildConfig.VERSION_CODE}<br>
|
||||
<b>Commit SHA:</b> ${BuildConfig.COMMIT_SHA}<br>
|
||||
<b>Log level:</b> ${EHLogLevel.currentLogLevel.name.toLowerCase()}<br>
|
||||
<b>Log level:</b> ${EHLogLevel.currentLogLevel.name.toLowerCase(Locale.getDefault())}<br>
|
||||
<b>Source blacklist:</b> ${prefs.eh_enableSourceBlacklist().get().asEnabledString()}
|
||||
""".trimIndent()
|
||||
|
||||
|
@ -3,6 +3,7 @@ package exh.search
|
||||
import exh.metadata.sql.tables.SearchMetadataTable
|
||||
import exh.metadata.sql.tables.SearchTagTable
|
||||
import exh.metadata.sql.tables.SearchTitleTable
|
||||
import java.util.Locale
|
||||
|
||||
class SearchEngine {
|
||||
private val queryCache = mutableMapOf<String, List<QueryComponent>>()
|
||||
@ -162,7 +163,7 @@ class SearchEngine {
|
||||
}
|
||||
}
|
||||
|
||||
query.toLowerCase().forEach { char ->
|
||||
query.toLowerCase(Locale.getDefault()).forEach { char ->
|
||||
if (char == '"') {
|
||||
inQuotes = !inQuotes
|
||||
} else if (enableWildcard && (char == '?' || char == '_')) {
|
||||
|
@ -6,13 +6,13 @@ import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.util.lang.await
|
||||
import eu.kanade.tachiyomi.util.lang.awaitSingle
|
||||
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
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.util.Locale
|
||||
|
||||
class SmartSearchEngine(
|
||||
private val extraSearchParams: String? = null
|
||||
@ -21,7 +21,6 @@ class SmartSearchEngine(
|
||||
|
||||
private val normalizedLevenshtein = NormalizedLevenshtein()
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
suspend fun smartSearch(source: CatalogueSource, title: String): SManga? {
|
||||
val cleanedTitle = cleanSmartSearchTitle(title)
|
||||
|
||||
@ -34,8 +33,7 @@ class SmartSearchEngine(
|
||||
"$query ${extraSearchParams.trim()}"
|
||||
} else query
|
||||
|
||||
val searchResults = source.fetchSearchManga(1, builtQuery, FilterList())
|
||||
.toSingle().await(Schedulers.io())
|
||||
val searchResults = source.fetchSearchManga(1, builtQuery, FilterList()).awaitSingle()
|
||||
|
||||
searchResults.mangas.map {
|
||||
val cleanedMangaTitle = cleanSmartSearchTitle(it.originalTitle)
|
||||
@ -51,13 +49,12 @@ 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) {
|
||||
"$title ${extraSearchParams.trim()}"
|
||||
} else title
|
||||
val searchResults = source.fetchSearchManga(1, searchQuery, FilterList()).toSingle().await(Schedulers.io())
|
||||
val searchResults = source.fetchSearchManga(1, searchQuery, FilterList()).awaitSingle()
|
||||
|
||||
if (searchResults.mangas.size == 1) {
|
||||
return@supervisorScope listOf(SearchEntry(searchResults.mangas.first(), 0.0))
|
||||
@ -102,7 +99,7 @@ class SmartSearchEngine(
|
||||
}
|
||||
|
||||
private fun cleanSmartSearchTitle(title: String): String {
|
||||
val preTitle = title.toLowerCase()
|
||||
val preTitle = title.toLowerCase(Locale.getDefault())
|
||||
|
||||
// Remove text in brackets
|
||||
var cleanedTitle = removeTextInBrackets(preTitle, true)
|
||||
@ -152,6 +149,7 @@ class SmartSearchEngine(
|
||||
if (closingBracketDepthIndex != null) {
|
||||
depthPairs[closingBracketDepthIndex]--
|
||||
} else {
|
||||
@Suppress("ControlFlowWithEmptyBody")
|
||||
if (depthPairs.all { it <= 0 }) {
|
||||
result.append(c)
|
||||
} else {
|
||||
|
@ -15,6 +15,7 @@ import okhttp3.FormBody
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.util.Locale
|
||||
|
||||
class EHConfigurator(val context: Context) {
|
||||
private val prefs: PreferencesHelper by injectLazy()
|
||||
@ -64,7 +65,7 @@ class EHConfigurator(val context: Context) {
|
||||
val hathPerks = EHHathPerksResponse()
|
||||
|
||||
perksPage.select(".stuffbox tr").forEach {
|
||||
val name = it.child(0).text().toLowerCase()
|
||||
val name = it.child(0).text().toLowerCase(Locale.getDefault())
|
||||
val purchased = it.child(2).getElementsByTag("form").isEmpty()
|
||||
|
||||
when (name) {
|
||||
|
@ -3,6 +3,7 @@ package exh.uconfig
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import okhttp3.FormBody
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.util.Locale
|
||||
|
||||
class EhUConfigBuilder {
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
@ -13,7 +14,7 @@ class EhUConfigBuilder {
|
||||
configItems += when (
|
||||
preferences.imageQuality()
|
||||
.get()
|
||||
.toLowerCase()
|
||||
.toLowerCase(Locale.getDefault())
|
||||
) {
|
||||
"ovrs_2400" -> Entry.ImageSize.`2400`
|
||||
"ovrs_1600" -> Entry.ImageSize.`1600`
|
||||
|
@ -6,7 +6,6 @@ import android.webkit.WebView
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import org.jsoup.nodes.DataNode
|
||||
import org.jsoup.nodes.Element
|
||||
import java.nio.charset.Charset
|
||||
|
||||
class AutoSolvingWebViewClient(
|
||||
activity: BrowserActionActivity,
|
||||
@ -27,7 +26,7 @@ class AutoSolvingWebViewClient(
|
||||
return WebResourceResponse(
|
||||
"text/html",
|
||||
"UTF-8",
|
||||
doc.toString().byteInputStream(Charset.forName("UTF-8")).buffered()
|
||||
doc.toString().byteInputStream().buffered()
|
||||
)
|
||||
}
|
||||
return super.shouldInterceptRequest(view, request)
|
||||
|
@ -18,6 +18,7 @@ import eu.kanade.tachiyomi.util.system.setDefaultSettings
|
||||
import exh.uconfig.WarnConfigureDialogController
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.net.HttpCookie
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* LoginController
|
||||
@ -147,7 +148,7 @@ class LoginController : NucleusController<EhActivityLoginBinding, LoginPresenter
|
||||
var igneous: String? = null
|
||||
|
||||
parsed.forEach {
|
||||
when (it.name.toLowerCase()) {
|
||||
when (it.name.toLowerCase(Locale.getDefault())) {
|
||||
MEMBER_ID_COOKIE -> memberId = it.value
|
||||
PASS_HASH_COOKIE -> passHash = it.value
|
||||
IGNEOUS_COOKIE -> igneous = it.value
|
||||
|
@ -9,18 +9,10 @@ import com.pushtorefresh.storio.sqlite.operations.put.PutResults
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
suspend fun <T> PreparedGetListOfObjects<T>.executeOnIO(): List<T> {
|
||||
return withContext(Dispatchers.IO) { executeAsBlocking() }
|
||||
}
|
||||
suspend fun <T> PreparedGetListOfObjects<T>.executeOnIO(): List<T> = withContext(Dispatchers.IO) { executeAsBlocking() }
|
||||
|
||||
suspend fun <T> PreparedGetObject<T>.executeOnIO(): T? {
|
||||
return withContext(Dispatchers.IO) { executeAsBlocking() }
|
||||
}
|
||||
suspend fun <T> PreparedGetObject<T>.executeOnIO(): T? = withContext(Dispatchers.IO) { executeAsBlocking() }
|
||||
|
||||
suspend fun <T> PreparedPutObject<T>.executeOnIO(): PutResult {
|
||||
return withContext(Dispatchers.IO) { executeAsBlocking() }
|
||||
}
|
||||
suspend fun <T> PreparedPutObject<T>.executeOnIO(): PutResult = withContext(Dispatchers.IO) { executeAsBlocking() }
|
||||
|
||||
suspend fun <T> PreparedPutCollectionOfObjects<T>.executeOnIO(): PutResults<T> {
|
||||
return withContext(Dispatchers.IO) { executeAsBlocking() }
|
||||
}
|
||||
suspend fun <T> PreparedPutCollectionOfObjects<T>.executeOnIO(): PutResults<T> = withContext(Dispatchers.IO) { executeAsBlocking() }
|
||||
|
Loading…
x
Reference in New Issue
Block a user