Skip to content

Commit

Permalink
Removed locale
Browse files Browse the repository at this point in the history
  • Loading branch information
nbradbury committed Dec 12, 2024
1 parent 631549d commit ca1d061
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package org.wordpress.android.fluxc.model.list

import java.util.Locale

enum class ListOrder(val value: String) {
ASC("ASC"),
DESC("DESC");
companion object {
fun fromValue(value: String): ListOrder? {
return values().firstOrNull { it.value.lowercase(Locale.ROOT) == value.lowercase(Locale.ROOT) }
return values().firstOrNull { it.value.lowercase() == value.lowercase() }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import org.wordpress.android.fluxc.model.list.ListOrder.DESC
import org.wordpress.android.fluxc.model.list.PostListOrderBy.DATE
import org.wordpress.android.fluxc.model.post.PostStatus
import org.wordpress.android.fluxc.store.PostStore.DEFAULT_POST_STATUS_LIST
import java.util.Locale

sealed class PostListDescriptor(
val site: SiteModel,
Expand Down Expand Up @@ -105,7 +104,7 @@ enum class PostListOrderBy(val value: String) {

companion object {
fun fromValue(value: String): PostListOrderBy? {
return values().firstOrNull { it.value.lowercase(Locale.ROOT) == value.lowercase(Locale.ROOT) }
return values().firstOrNull { it.value.lowercase() == value.lowercase() }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.wordpress.android.fluxc.model.notification

import org.wordpress.android.fluxc.tools.FormattableContent
import org.wordpress.android.fluxc.tools.FormattableMeta
import java.util.Locale

data class NotificationModel(
val noteId: Int = 0,
Expand Down Expand Up @@ -45,7 +44,7 @@ data class NotificationModel(
companion object {
private val reverseMap = values().associateBy(
Kind::name)
fun fromString(type: String) = reverseMap[type.uppercase(Locale.US)] ?: UNKNOWN
fun fromString(type: String) = reverseMap[type.uppercase()] ?: UNKNOWN
}
}

Expand All @@ -62,7 +61,7 @@ data class NotificationModel(
return if (type.isEmpty()) {
NONE
} else {
reverseMap[type.uppercase(Locale.US)] ?: UNKNOWN
reverseMap[type.uppercase()] ?: UNKNOWN
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.google.gson.JsonDeserializer
import com.google.gson.JsonElement
import com.google.gson.JsonParseException
import java.lang.reflect.Type
import java.util.Locale

internal class BooleanTypeAdapter : JsonDeserializer<Boolean?> {
@Suppress("VariableNaming") private val TRUE_STRINGS: Set<String> = HashSet(listOf("true", "1", "yes"))
Expand All @@ -17,9 +16,7 @@ internal class BooleanTypeAdapter : JsonDeserializer<Boolean?> {
jsonPrimitive.isBoolean -> jsonPrimitive.asBoolean
jsonPrimitive.isNumber -> jsonPrimitive.asNumber.toInt() == 1
jsonPrimitive.isString -> TRUE_STRINGS.contains(
jsonPrimitive.asString.lowercase(
Locale.getDefault()
)
jsonPrimitive.asString.lowercase()
)
else -> false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import org.wordpress.android.fluxc.utils.PreferenceUtils
import org.wordpress.android.util.AppLog
import org.wordpress.android.util.AppLog.T
import java.util.Date
import java.util.Locale
import java.util.UUID
import javax.inject.Inject
import javax.inject.Singleton
Expand Down Expand Up @@ -74,7 +73,7 @@ class NotificationStore @Inject constructor(

companion object {
private val reverseMap = values().associateBy(DeviceRegistrationErrorType::name)
fun fromString(type: String) = reverseMap[type.uppercase(Locale.US)] ?: GENERIC_ERROR
fun fromString(type: String) = reverseMap[type.uppercase()] ?: GENERIC_ERROR
}
}

Expand Down Expand Up @@ -147,7 +146,7 @@ class NotificationStore @Inject constructor(

companion object {
private val reverseMap = values().associateBy(NotificationErrorType::name)
fun fromString(type: String) = reverseMap[type.uppercase(Locale.US)] ?: GENERIC_ERROR
fun fromString(type: String) = reverseMap[type.uppercase()] ?: GENERIC_ERROR
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import org.wordpress.android.fluxc.tools.CoroutineEngine
import org.wordpress.android.util.AppLog
import org.wordpress.android.util.DateTimeUtils
import java.util.Calendar
import java.util.Locale
import javax.inject.Inject
import javax.inject.Singleton
import kotlin.coroutines.Continuation
Expand Down Expand Up @@ -83,8 +82,7 @@ class PageStore @Inject constructor(
suspend fun search(site: SiteModel, searchQuery: String): List<PageModel> =
coroutineEngine.withDefaultContext(AppLog.T.POSTS, this, "search") {
getPagesFromDb(site).filter {
it.title.lowercase(Locale.ROOT)
.contains(searchQuery.lowercase(Locale.ROOT))
it.title.lowercase().contains(searchQuery.lowercase())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ open class SiteStore @Inject constructor(
private const val SITE = "SITE"
@JvmStatic fun fromString(string: String): NewSiteErrorType {
if (!TextUtils.isEmpty(string)) {
val siteString = string.uppercase(Locale.US).replace(BLOG, SITE)
val siteString = string.uppercase().replace(BLOG, SITE)
for (v in values()) {
if (siteString.equals(v.name, ignoreCase = true)) {
return v
Expand Down

0 comments on commit ca1d061

Please sign in to comment.