This commit is contained in:
Jobobby04 2020-11-11 17:30:38 -05:00
parent a35e7871e8
commit 0594efb1c8
11 changed files with 28 additions and 31 deletions

View File

@ -13,6 +13,7 @@ import eu.kanade.tachiyomi.data.track.TrackManager
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.network.POST
import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.network.asObservableSuccess
import eu.kanade.tachiyomi.network.await
import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.MangasPage import eu.kanade.tachiyomi.source.model.MangasPage
@ -190,7 +191,7 @@ class MangaDex(delegate: HttpSource, val context: Context) :
headers, headers,
formBody.build() formBody.build()
) )
).execute() ).await()
response.body!!.string().let { response.body!!.string().let {
if (it.isEmpty()) { if (it.isEmpty()) {

View File

@ -3,6 +3,7 @@ package exh.debug
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.ExperimentalCoroutinesApi
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.util.Locale
enum class DebugToggles(val default: Boolean) { 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 // 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 // Pretend that all galleries only have a single version
INCLUDE_ONLY_ROOT_WHEN_LOADING_EXH_VERSIONS(false); 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) @OptIn(ExperimentalCoroutinesApi::class)
var enabled: Boolean var enabled: Boolean

View File

@ -15,6 +15,7 @@ import eu.kanade.tachiyomi.util.preference.onClick
import eu.kanade.tachiyomi.util.preference.preference import eu.kanade.tachiyomi.util.preference.preference
import eu.kanade.tachiyomi.util.preference.preferenceCategory import eu.kanade.tachiyomi.util.preference.preferenceCategory
import eu.kanade.tachiyomi.util.preference.switchPreference import eu.kanade.tachiyomi.util.preference.switchPreference
import java.util.Locale
import kotlin.reflect.KVisibility import kotlin.reflect.KVisibility
import kotlin.reflect.full.declaredFunctions import kotlin.reflect.full.declaredFunctions
@ -30,7 +31,7 @@ class SettingsDebugController : SettingsController() {
it.visibility == KVisibility.PUBLIC it.visibility == KVisibility.PUBLIC
}.forEach { }.forEach {
preference { 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 isPersistent = false
onClick { onClick {
@ -61,7 +62,7 @@ class SettingsDebugController : SettingsController() {
DebugToggles.values().forEach { DebugToggles.values().forEach {
switchPreference { switchPreference {
title = it.name.replace('_', ' ').toLowerCase().capitalize() title = it.name.replace('_', ' ').toLowerCase(Locale.getDefault()).capitalize(Locale.getDefault())
key = it.prefKey key = it.prefKey
defaultValue = it.default defaultValue = it.default
summaryOn = if (it.default) "" else MODIFIED_TEXT summaryOn = if (it.default) "" else MODIFIED_TEXT

View File

@ -13,6 +13,7 @@ import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.dpToPx
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.util.Locale
class EHDebugModeOverlay(private val context: Context) : OverlayModule<String>(null, null) { class EHDebugModeOverlay(private val context: Context) : OverlayModule<String>(null, null) {
private var textView: TextView? = 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>Debug mode:</b> ${BuildConfig.DEBUG.asEnabledString()}<br>
<b>Version code:</b> ${BuildConfig.VERSION_CODE}<br> <b>Version code:</b> ${BuildConfig.VERSION_CODE}<br>
<b>Commit SHA:</b> ${BuildConfig.COMMIT_SHA}<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()} <b>Source blacklist:</b> ${prefs.eh_enableSourceBlacklist().get().asEnabledString()}
""".trimIndent() """.trimIndent()

View File

@ -3,6 +3,7 @@ package exh.search
import exh.metadata.sql.tables.SearchMetadataTable import exh.metadata.sql.tables.SearchMetadataTable
import exh.metadata.sql.tables.SearchTagTable import exh.metadata.sql.tables.SearchTagTable
import exh.metadata.sql.tables.SearchTitleTable import exh.metadata.sql.tables.SearchTitleTable
import java.util.Locale
class SearchEngine { class SearchEngine {
private val queryCache = mutableMapOf<String, List<QueryComponent>>() 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 == '"') { if (char == '"') {
inQuotes = !inQuotes inQuotes = !inQuotes
} else if (enableWildcard && (char == '?' || char == '_')) { } else if (enableWildcard && (char == '?' || char == '_')) {

View File

@ -6,13 +6,13 @@ import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.util.lang.await import eu.kanade.tachiyomi.util.lang.await
import eu.kanade.tachiyomi.util.lang.awaitSingle
import info.debatty.java.stringsimilarity.NormalizedLevenshtein import info.debatty.java.stringsimilarity.NormalizedLevenshtein
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.async import kotlinx.coroutines.async
import kotlinx.coroutines.supervisorScope import kotlinx.coroutines.supervisorScope
import rx.schedulers.Schedulers
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.util.Locale
class SmartSearchEngine( class SmartSearchEngine(
private val extraSearchParams: String? = null private val extraSearchParams: String? = null
@ -21,7 +21,6 @@ class SmartSearchEngine(
private val normalizedLevenshtein = NormalizedLevenshtein() private val normalizedLevenshtein = NormalizedLevenshtein()
@OptIn(ExperimentalCoroutinesApi::class)
suspend fun smartSearch(source: CatalogueSource, title: String): SManga? { suspend fun smartSearch(source: CatalogueSource, title: String): SManga? {
val cleanedTitle = cleanSmartSearchTitle(title) val cleanedTitle = cleanSmartSearchTitle(title)
@ -34,8 +33,7 @@ class SmartSearchEngine(
"$query ${extraSearchParams.trim()}" "$query ${extraSearchParams.trim()}"
} else query } else query
val searchResults = source.fetchSearchManga(1, builtQuery, FilterList()) val searchResults = source.fetchSearchManga(1, builtQuery, FilterList()).awaitSingle()
.toSingle().await(Schedulers.io())
searchResults.mangas.map { searchResults.mangas.map {
val cleanedMangaTitle = cleanSmartSearchTitle(it.originalTitle) val cleanedMangaTitle = cleanSmartSearchTitle(it.originalTitle)
@ -51,13 +49,12 @@ class SmartSearchEngine(
return eligibleManga.maxByOrNull { it.dist }?.manga return eligibleManga.maxByOrNull { it.dist }?.manga
} }
@OptIn(ExperimentalCoroutinesApi::class)
suspend fun normalSearch(source: CatalogueSource, title: String): SManga? { suspend fun normalSearch(source: CatalogueSource, title: String): SManga? {
val eligibleManga = supervisorScope { val eligibleManga = supervisorScope {
val searchQuery = if (extraSearchParams != null) { val searchQuery = if (extraSearchParams != null) {
"$title ${extraSearchParams.trim()}" "$title ${extraSearchParams.trim()}"
} else title } 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) { if (searchResults.mangas.size == 1) {
return@supervisorScope listOf(SearchEntry(searchResults.mangas.first(), 0.0)) return@supervisorScope listOf(SearchEntry(searchResults.mangas.first(), 0.0))
@ -102,7 +99,7 @@ class SmartSearchEngine(
} }
private fun cleanSmartSearchTitle(title: String): String { private fun cleanSmartSearchTitle(title: String): String {
val preTitle = title.toLowerCase() val preTitle = title.toLowerCase(Locale.getDefault())
// Remove text in brackets // Remove text in brackets
var cleanedTitle = removeTextInBrackets(preTitle, true) var cleanedTitle = removeTextInBrackets(preTitle, true)
@ -152,6 +149,7 @@ class SmartSearchEngine(
if (closingBracketDepthIndex != null) { if (closingBracketDepthIndex != null) {
depthPairs[closingBracketDepthIndex]-- depthPairs[closingBracketDepthIndex]--
} else { } else {
@Suppress("ControlFlowWithEmptyBody")
if (depthPairs.all { it <= 0 }) { if (depthPairs.all { it <= 0 }) {
result.append(c) result.append(c)
} else { } else {

View File

@ -15,6 +15,7 @@ import okhttp3.FormBody
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.util.Locale
class EHConfigurator(val context: Context) { class EHConfigurator(val context: Context) {
private val prefs: PreferencesHelper by injectLazy() private val prefs: PreferencesHelper by injectLazy()
@ -64,7 +65,7 @@ class EHConfigurator(val context: Context) {
val hathPerks = EHHathPerksResponse() val hathPerks = EHHathPerksResponse()
perksPage.select(".stuffbox tr").forEach { 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() val purchased = it.child(2).getElementsByTag("form").isEmpty()
when (name) { when (name) {

View File

@ -3,6 +3,7 @@ package exh.uconfig
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import okhttp3.FormBody import okhttp3.FormBody
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.util.Locale
class EhUConfigBuilder { class EhUConfigBuilder {
private val preferences: PreferencesHelper by injectLazy() private val preferences: PreferencesHelper by injectLazy()
@ -13,7 +14,7 @@ class EhUConfigBuilder {
configItems += when ( configItems += when (
preferences.imageQuality() preferences.imageQuality()
.get() .get()
.toLowerCase() .toLowerCase(Locale.getDefault())
) { ) {
"ovrs_2400" -> Entry.ImageSize.`2400` "ovrs_2400" -> Entry.ImageSize.`2400`
"ovrs_1600" -> Entry.ImageSize.`1600` "ovrs_1600" -> Entry.ImageSize.`1600`

View File

@ -6,7 +6,6 @@ import android.webkit.WebView
import eu.kanade.tachiyomi.util.asJsoup import eu.kanade.tachiyomi.util.asJsoup
import org.jsoup.nodes.DataNode import org.jsoup.nodes.DataNode
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import java.nio.charset.Charset
class AutoSolvingWebViewClient( class AutoSolvingWebViewClient(
activity: BrowserActionActivity, activity: BrowserActionActivity,
@ -27,7 +26,7 @@ class AutoSolvingWebViewClient(
return WebResourceResponse( return WebResourceResponse(
"text/html", "text/html",
"UTF-8", "UTF-8",
doc.toString().byteInputStream(Charset.forName("UTF-8")).buffered() doc.toString().byteInputStream().buffered()
) )
} }
return super.shouldInterceptRequest(view, request) return super.shouldInterceptRequest(view, request)

View File

@ -18,6 +18,7 @@ import eu.kanade.tachiyomi.util.system.setDefaultSettings
import exh.uconfig.WarnConfigureDialogController import exh.uconfig.WarnConfigureDialogController
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.net.HttpCookie import java.net.HttpCookie
import java.util.Locale
/** /**
* LoginController * LoginController
@ -147,7 +148,7 @@ class LoginController : NucleusController<EhActivityLoginBinding, LoginPresenter
var igneous: String? = null var igneous: String? = null
parsed.forEach { parsed.forEach {
when (it.name.toLowerCase()) { when (it.name.toLowerCase(Locale.getDefault())) {
MEMBER_ID_COOKIE -> memberId = it.value MEMBER_ID_COOKIE -> memberId = it.value
PASS_HASH_COOKIE -> passHash = it.value PASS_HASH_COOKIE -> passHash = it.value
IGNEOUS_COOKIE -> igneous = it.value IGNEOUS_COOKIE -> igneous = it.value

View File

@ -9,18 +9,10 @@ import com.pushtorefresh.storio.sqlite.operations.put.PutResults
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
suspend fun <T> PreparedGetListOfObjects<T>.executeOnIO(): List<T> { suspend fun <T> PreparedGetListOfObjects<T>.executeOnIO(): List<T> = withContext(Dispatchers.IO) { executeAsBlocking() }
return withContext(Dispatchers.IO) { executeAsBlocking() }
}
suspend fun <T> PreparedGetObject<T>.executeOnIO(): T? { suspend fun <T> PreparedGetObject<T>.executeOnIO(): T? = withContext(Dispatchers.IO) { executeAsBlocking() }
return withContext(Dispatchers.IO) { executeAsBlocking() }
}
suspend fun <T> PreparedPutObject<T>.executeOnIO(): PutResult { suspend fun <T> PreparedPutObject<T>.executeOnIO(): PutResult = withContext(Dispatchers.IO) { executeAsBlocking() }
return withContext(Dispatchers.IO) { executeAsBlocking() }
}
suspend fun <T> PreparedPutCollectionOfObjects<T>.executeOnIO(): PutResults<T> { suspend fun <T> PreparedPutCollectionOfObjects<T>.executeOnIO(): PutResults<T> = withContext(Dispatchers.IO) { executeAsBlocking() }
return withContext(Dispatchers.IO) { executeAsBlocking() }
}