Address some deprecation warnings

This commit is contained in:
Jobobby04 2021-06-01 21:09:03 -04:00
parent 9697bffc5e
commit d30c9f7120
31 changed files with 56 additions and 56 deletions

View File

@ -9,7 +9,7 @@ interface UrlImportableSource : Source {
val matchingHosts: List<String>
fun matchesUri(uri: Uri): Boolean {
return uri.host.orEmpty().toLowerCase() in matchingHosts
return uri.host.orEmpty().lowercase() in matchingHosts
}
fun mapUrlToChapterUrl(uri: Uri): String? = null

View File

@ -193,7 +193,7 @@ class EHentai(
genre = getGenre(
genreString = parsedGenre?.text()
?.nullIfBlank()
?.toLowerCase()
?.lowercase()
?.replace(" ", "")
)
@ -306,7 +306,7 @@ class EHentai(
doc = client.newCall(exGet(baseUrl + url)).await().asJsoup()
val parentLink = doc.select("#gdd .gdt1").find { el ->
el.text().toLowerCase() == "parent:"
el.text().lowercase() == "parent:"
}!!.nextElementSibling().selectFirst("a")?.attr("href")
if (parentLink != null) {
@ -335,7 +335,7 @@ class EHentai(
number = 1f,
dateUpload = MetadataUtil.EX_DATE_FORMAT.parse(
doc.select("#gdd .gdt1").find { el ->
el.text().toLowerCase() == "posted:"
el.text().lowercase() == "posted:"
}!!.nextElementSibling().text()
)!!.time
)
@ -593,7 +593,7 @@ class EHentai(
val right = rightElement.text().trimOrNull()
if (left != null && right != null) {
ignore {
when (left.removeSuffix(":").toLowerCase()) {
when (left.removeSuffix(":").lowercase()) {
"posted" -> datePosted = MetadataUtil.EX_DATE_FORMAT.parse(right)!!.time
// Example gallery with parent: https://e-hentai.org/g/1390451/7f181c2426/
// Example JP gallery: https://exhentai.org/g/1375385/03519d541b/

View File

@ -58,7 +58,7 @@ class Hitomi(delegate: HttpSource, val context: Context) :
input.select(".gallery-info tr").forEach { galleryInfoElement ->
val content = galleryInfoElement.child(1)
when (galleryInfoElement.child(0).text().toLowerCase()) {
when (galleryInfoElement.child(0).text().lowercase()) {
"group" -> {
group = content.text()
tags += RaisedTag("group", group!!, RaisedSearchMetadata.TAG_TYPE_VIRTUAL)
@ -114,7 +114,7 @@ class Hitomi(delegate: HttpSource, val context: Context) :
}
}
override fun toString() = "$name (${lang.toUpperCase()})"
override fun toString() = "$name (${lang.uppercase()})"
override fun ensureDelegateCompatible() {
if (versionId != delegate.versionId) {
@ -127,7 +127,7 @@ class Hitomi(delegate: HttpSource, val context: Context) :
)
override suspend fun mapUrlToMangaUrl(uri: Uri): String? {
val lcFirstPathSegment = uri.pathSegments.firstOrNull()?.toLowerCase() ?: return null
val lcFirstPathSegment = uri.pathSegments.firstOrNull()?.lowercase() ?: return null
if (lcFirstPathSegment != "manga" && lcFirstPathSegment != "reader") {
return null

View File

@ -148,7 +148,7 @@ class NHentai(delegate: HttpSource, val context: Context) :
val count: Long? = null
)
override fun toString() = "$name (${lang.toUpperCase()})"
override fun toString() = "$name (${lang.uppercase()})"
override fun ensureDelegateCompatible() {
if (versionId != delegate.versionId) {
@ -161,7 +161,7 @@ class NHentai(delegate: HttpSource, val context: Context) :
)
override suspend fun mapUrlToMangaUrl(uri: Uri): String? {
if (uri.pathSegments.firstOrNull()?.toLowerCase() != "g") {
if (uri.pathSegments.firstOrNull()?.lowercase() != "g") {
return null
}

View File

@ -58,14 +58,14 @@ class PervEden(delegate: HttpSource, val context: Context) :
tags.clear()
var inStatus: String? = null
rightBoxElement.childNodes().forEach {
if (it is Element && it.tagName().toLowerCase() == "h4") {
if (it is Element && it.tagName().lowercase() == "h4") {
inStatus = it.text().trim()
} else {
when (inStatus) {
"Alternative name(s)" -> {
if (it is TextNode) {
val text = it.text().trim()
if (!text.isBlank()) {
if (text.isNotBlank()) {
newAltTitles += text
}
}
@ -75,7 +75,7 @@ class PervEden(delegate: HttpSource, val context: Context) :
artist = it.text()
tags += RaisedTag(
"artist",
it.text().toLowerCase(),
it.text().lowercase(),
RaisedSearchMetadata.TAG_TYPE_VIRTUAL
)
}
@ -84,7 +84,7 @@ class PervEden(delegate: HttpSource, val context: Context) :
if (it is Element && it.tagName() == "a") {
tags += RaisedTag(
null,
it.text().toLowerCase(),
it.text().lowercase(),
PervEdenSearchMetadata.TAG_TYPE_DEFAULT
)
}
@ -92,7 +92,7 @@ class PervEden(delegate: HttpSource, val context: Context) :
"Type" -> {
if (it is TextNode) {
val text = it.text().trim()
if (!text.isBlank()) {
if (text.isNotBlank()) {
genre = text
}
}
@ -100,7 +100,7 @@ class PervEden(delegate: HttpSource, val context: Context) :
"Status" -> {
if (it is TextNode) {
val text = it.text().trim()
if (!text.isBlank()) {
if (text.isNotBlank()) {
status = text
}
}
@ -118,7 +118,7 @@ class PervEden(delegate: HttpSource, val context: Context) :
override val matchingHosts = listOf("www.perveden.com")
override fun matchesUri(uri: Uri): Boolean {
return super.matchesUri(uri) && uri.pathSegments.firstOrNull()?.toLowerCase() == when (lang) {
return super.matchesUri(uri) && uri.pathSegments.firstOrNull()?.lowercase() == when (lang) {
"en" -> "en-manga"
"it" -> "it-manga"
else -> false

View File

@ -91,7 +91,7 @@ class EightMuses(delegate: HttpSource, val context: Context) :
override suspend fun mapUrlToMangaUrl(uri: Uri): String {
var path = uri.pathSegments.drop(2)
if (uri.pathSegments[1].toLowerCase() == "picture") {
if (uri.pathSegments[1].lowercase() == "picture") {
path = path.dropLast(1)
}
return "/comics/album/${path.joinToString("/")}"

View File

@ -48,7 +48,7 @@ class HBrowse(delegate: HttpSource, val context: Context) :
tags.clear()
((tables[""] ?: error("")) + (tables["categories"] ?: error(""))).forEach { (k, v) ->
when (val lowercaseNs = k.toLowerCase()) {
when (val lowercaseNs = k.lowercase()) {
"title" -> title = v.text()
"length" -> length = v.text().substringBefore(" ").toInt()
else -> {
@ -67,7 +67,7 @@ class HBrowse(delegate: HttpSource, val context: Context) :
private fun parseIntoTables(doc: Document): Map<String, Map<String, Element>> {
return doc.select("#main > .listTable").map { ele ->
val tableName = ele.previousElementSibling()?.text()?.toLowerCase().orEmpty()
val tableName = ele.previousElementSibling()?.text()?.lowercase().orEmpty()
tableName to ele.select("tr").map {
it.child(0).text() to it.child(1)
}.toMap()

View File

@ -73,7 +73,7 @@ class Pururin(delegate: HttpSource, val context: Context) :
tags.clear()
contentWrapper.select(".table-gallery-info > tbody > tr").forEach { ele ->
val key = ele.child(0).text().toLowerCase()
val key = ele.child(0).text().lowercase()
val value = ele.child(1)
when (key) {
"pages" -> {

View File

@ -42,7 +42,7 @@ class Tsumino(delegate: HttpSource, val context: Context) :
}
override suspend fun mapUrlToMangaUrl(uri: Uri): String? {
val lcFirstPathSegment = uri.pathSegments.firstOrNull()?.toLowerCase(Locale.ROOT) ?: return null
val lcFirstPathSegment = uri.pathSegments.firstOrNull()?.lowercase(Locale.ROOT) ?: return null
if (lcFirstPathSegment != "read" && lcFirstPathSegment != "book" && lcFirstPathSegment != "entry") {
return null
}

View File

@ -41,6 +41,6 @@ class MigrationMangaDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
(targetController as? MigrationListController)?.migrateMangas()
}
}
.negativeButton(android.R.string.no)
.negativeButton(android.R.string.cancel)
}
}

View File

@ -235,7 +235,7 @@ class SourceController(bundle: Bundle? = null) :
}
private fun addToCategories(source: Source) {
val categories = preferences.sourcesTabCategories().get().toList().sortedBy { it.toLowerCase() }
val categories = preferences.sourcesTabCategories().get().toList().sortedBy { it.lowercase() }
if (categories.isEmpty()) {
applicationContext?.toast(R.string.no_source_categories)

View File

@ -219,7 +219,7 @@ class SourceFilterController : SettingsController() {
}
private fun sortedSources(sources: List<HttpSource>?): List<HttpSource> {
val sourceAlpha = sources.orEmpty().sortedBy { it.name.toLowerCase() }
val sourceAlpha = sources.orEmpty().sortedBy { it.name.lowercase() }
return if (sorting == SourcesSort.Enabled) {
val disabledSourceIds = preferences.disabledSources().get()
sourceAlpha.filter { it.id.toString() !in disabledSourceIds } +

View File

@ -278,7 +278,7 @@ open class BrowseSourceController(bundle: Bundle) :
.title(R.string.save_search_delete)
.message(text = it.getString(R.string.save_search_delete_message, search.name))
.positiveButton(R.string.action_cancel)
.negativeButton(android.R.string.yes) {
.negativeButton(android.R.string.ok) {
val newSearches = savedSearches.filterIndexed { index, _ ->
index != indexToDelete
}

View File

@ -85,10 +85,10 @@ class SourceEnhancedEHentaiListHolder(private val view: View, adapter: FlexibleA
val pageCount = metadata.length
binding.language.text = if (locale != null && pageCount != null) {
view.resources.getQuantityString(R.plurals.browse_language_and_pages, pageCount, pageCount, locale.toLanguageTag().toUpperCase())
view.resources.getQuantityString(R.plurals.browse_language_and_pages, pageCount, pageCount, locale.toLanguageTag().uppercase())
} else if (pageCount != null) {
view.resources.getQuantityString(R.plurals.num_pages, pageCount, pageCount)
} else locale?.toLanguageTag()?.toUpperCase()
} else locale?.toLanguageTag()?.uppercase()
}
override fun setImage(manga: Manga) {

View File

@ -166,7 +166,7 @@ class SourceFilterSheet(
}
}
}
.sortedBy { it.text.toString().toLowerCase() }
.sortedBy { it.text.toString().lowercase() }
}
fun hideFilterButton() {

View File

@ -30,7 +30,7 @@ class RepoPresenter(
super.onCreate(savedState)
preferences.extensionRepos().asFlow().onEach { repos ->
this.repos = repos.toList().sortedBy { it.toLowerCase() }
this.repos = repos.toList().sortedBy { it.lowercase() }
Observable.just(this.repos)
.map { it.map(::RepoItem) }

View File

@ -34,7 +34,7 @@ class SourceCategoryPresenter(
super.onCreate(savedState)
preferences.sourcesTabCategories().asFlow().onEach { categories ->
this.categories = categories.toList().sortedBy { it.toLowerCase() }
this.categories = categories.toList().sortedBy { it.lowercase() }
Observable.just(this.categories)
.map { it.map(::SourceCategoryItem) }

View File

@ -809,7 +809,7 @@ class LibraryPresenter(
val categories = (
when (groupType) {
LibraryGroup.BY_SOURCE -> grouping.sortedBy { it.third.toLowerCase() }
LibraryGroup.BY_SOURCE -> grouping.sortedBy { it.third.lowercase() }
LibraryGroup.BY_TRACK_STATUS, LibraryGroup.BY_STATUS -> grouping.filter { it.second in map.keys }
else -> grouping
}

View File

@ -545,7 +545,7 @@ class SettingsEhController : SettingsController() {
MaterialDialog(activity)
.title(R.string.favorites_sync_reset)
.message(R.string.favorites_sync_reset_message)
.positiveButton(android.R.string.yes) {
.positiveButton(android.R.string.ok) {
LocalFavoritesStorage().apply {
getRealm().use {
it.trans {
@ -555,7 +555,7 @@ class SettingsEhController : SettingsController() {
}
activity.toast(context.getString(R.string.sync_state_reset), Toast.LENGTH_LONG)
}
.negativeButton(android.R.string.no)
.negativeButton(android.R.string.cancel)
.cancelable(false)
.show()
}

View File

@ -170,22 +170,22 @@ object DebugFunctions {
fun clearSavedSearches() = prefs.savedSearches().set(emptySet())
fun listAllSources() = sourceManager.getCatalogueSources().joinToString("\n") {
"${it.id}: ${it.name} (${it.lang.toUpperCase()})"
"${it.id}: ${it.name} (${it.lang.uppercase()})"
}
fun listAllSourcesClassName() = sourceManager.getCatalogueSources().joinToString("\n") {
"${it::class.qualifiedName}: ${it.name} (${it.lang.toUpperCase()})"
"${it::class.qualifiedName}: ${it.name} (${it.lang.uppercase()})"
}
fun listVisibleSources() = sourceManager.getVisibleCatalogueSources().joinToString("\n") {
"${it.id}: ${it.name} (${it.lang.toUpperCase()})"
"${it.id}: ${it.name} (${it.lang.uppercase()})"
}
fun listAllHttpSources() = sourceManager.getOnlineSources().joinToString("\n") {
"${it.id}: ${it.name} (${it.lang.toUpperCase()})"
"${it.id}: ${it.name} (${it.lang.uppercase()})"
}
fun listVisibleHttpSources() = sourceManager.getVisibleOnlineSources().joinToString("\n") {
"${it.id}: ${it.name} (${it.lang.toUpperCase()})"
"${it.id}: ${it.name} (${it.lang.uppercase()})"
}
fun convertAllEhentaiGalleriesToExhentai() = convertSources(EH_SOURCE_ID, EXH_SOURCE_ID)

View File

@ -31,7 +31,7 @@ class SettingsDebugController : SettingsController() {
it.visibility == KVisibility.PUBLIC
}.forEach {
preference {
title = it.name.replace("(.)(\\p{Upper})".toRegex(), "$1 $2").toLowerCase(Locale.getDefault()).capitalize(Locale.getDefault())
title = it.name.replace("(.)(\\p{Upper})".toRegex(), "$1 $2").lowercase(Locale.getDefault()).capitalize(Locale.getDefault())
isPersistent = false
onClick {
@ -62,7 +62,7 @@ class SettingsDebugController : SettingsController() {
DebugToggles.values().forEach {
switchPreference {
title = it.name.replace('_', ' ').toLowerCase(Locale.getDefault()).capitalize(Locale.getDefault())
title = it.name.replace('_', ' ').lowercase(Locale.getDefault()).capitalize(Locale.getDefault())
key = it.prefKey
defaultValue = it.default
summaryOn = if (it.default) "" else MODIFIED_TEXT

View File

@ -62,7 +62,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(Locale.getDefault())}<br>
<b>Log level:</b> ${EHLogLevel.currentLogLevel.name.lowercase(Locale.getDefault())}<br>
<b>Source blacklist:</b> ${preferences.enableSourceBlacklist().get().asEnabledString()}
""".trimIndent()

View File

@ -193,7 +193,7 @@ class FilterHandler(private val preferencesHelper: PreferencesHelper) {
if (rating.state) {
addQueryParameter(
"contentRating[]",
rating.name.toLowerCase(Locale.US)
rating.name.lowercase(Locale.US)
)
}
}
@ -203,7 +203,7 @@ class FilterHandler(private val preferencesHelper: PreferencesHelper) {
if (demographic.state) {
addQueryParameter(
"publicationDemographic[]",
demographic.name.toLowerCase(
demographic.name.lowercase(
Locale.US
)
)
@ -215,7 +215,7 @@ class FilterHandler(private val preferencesHelper: PreferencesHelper) {
if (status.state) {
addQueryParameter(
"status[]",
status.name.toLowerCase(
status.name.lowercase(
Locale.US
)
)
@ -246,13 +246,13 @@ class FilterHandler(private val preferencesHelper: PreferencesHelper) {
is TagInclusionMode -> {
addQueryParameter(
"includedTagsMode",
filter.values[filter.state].toUpperCase(Locale.US)
filter.values[filter.state].uppercase(Locale.US)
)
}
is TagExclusionMode -> {
addQueryParameter(
"excludedTagsMode",
filter.values[filter.state].toUpperCase(Locale.US)
filter.values[filter.state].uppercase(Locale.US)
)
}
}

View File

@ -135,7 +135,7 @@ class FollowsHandler(
return withIOContext {
val status = when (followStatus == FollowStatus.UNFOLLOWED) {
true -> null
false -> followStatus.name.toLowerCase(Locale.US)
false -> followStatus.name.lowercase(Locale.US)
}
val jsonString = MdUtil.jsonParser.encodeToString(UpdateReadingStatus(status))
@ -247,7 +247,7 @@ class FollowsHandler(
val mangaStatusUrl = MdUtil.mangaStatus.toHttpUrl().newBuilder()
if (status != null) {
mangaStatusUrl.addQueryParameter("status", status.name.toLowerCase(Locale.US))
mangaStatusUrl.addQueryParameter("status", status.name.lowercase(Locale.US))
}
return GET(mangaStatusUrl.build().toString(), MdUtil.getAuthHeaders(headers, preferences, mdList), CacheControl.FORCE_NETWORK)

View File

@ -12,7 +12,7 @@ enum class FollowStatus(val int: Int) {
RE_READING(6);
companion object {
fun fromDex(value: String?): FollowStatus = values().firstOrNull { it.name.toLowerCase(Locale.US) == value } ?: UNFOLLOWED
fun fromDex(value: String?): FollowStatus = values().firstOrNull { it.name.lowercase(Locale.US) == value } ?: UNFOLLOWED
fun fromInt(value: Int): FollowStatus = values().firstOrNull { it.int == value } ?: UNFOLLOWED
}
}

View File

@ -163,7 +163,7 @@ class SearchEngine {
}
}
query.toLowerCase(Locale.getDefault()).forEach { char ->
query.lowercase(Locale.getDefault()).forEach { char ->
if (char == '"') {
inQuotes = !inQuotes
} else if (enableWildcard && (char == '?' || char == '_')) {

View File

@ -99,7 +99,7 @@ class SmartSearchEngine(
}
private fun cleanSmartSearchTitle(title: String): String {
val preTitle = title.toLowerCase(Locale.getDefault())
val preTitle = title.lowercase(Locale.getDefault())
// Remove text in brackets
var cleanedTitle = removeTextInBrackets(preTitle, true)

View File

@ -65,7 +65,7 @@ class EHConfigurator(val context: Context) {
val hathPerks = EHHathPerksResponse()
perksPage.select(".stuffbox tr").forEach {
val name = it.child(0).text().toLowerCase(Locale.getDefault())
val name = it.child(0).text().lowercase(Locale.getDefault())
val purchased = it.child(2).getElementsByTag("form").isEmpty()
when (name) {

View File

@ -14,7 +14,7 @@ class EhUConfigBuilder {
configItems += when (
preferences.imageQuality()
.get()
.toLowerCase(Locale.getDefault())
.lowercase(Locale.getDefault())
) {
"ovrs_2400" -> Entry.ImageSize.`2400`
"ovrs_1600" -> Entry.ImageSize.`1600`

View File

@ -233,7 +233,7 @@ class EhLoginActivity : BaseViewBindingActivity<EhActivityLoginBinding>() {
var igneous: String? = null
parsed.forEach {
when (it.name.toLowerCase(Locale.getDefault())) {
when (it.name.lowercase(Locale.getDefault())) {
MEMBER_ID_COOKIE -> memberId = it.value
PASS_HASH_COOKIE -> passHash = it.value
IGNEOUS_COOKIE -> igneous = this.igneous ?: it.value

View File

@ -18,7 +18,7 @@ fun Manga.mangaType(context: Context): String {
MangaType.TYPE_COMIC -> R.string.comic
else -> R.string.manga
}
).toLowerCase(Locale.getDefault())
).lowercase(Locale.getDefault())
}
/**