From ca1d0617d07b424ba85be12564bac57f70878258 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 12 Dec 2024 08:55:10 -0500 Subject: [PATCH] Removed locale --- .../java/org/wordpress/android/fluxc/model/list/ListOrder.kt | 4 +--- .../wordpress/android/fluxc/model/list/PostListDescriptor.kt | 3 +-- .../android/fluxc/model/notification/NotificationModel.kt | 5 ++--- .../fluxc/network/rest/wpcom/site/BooleanTypeAdapter.kt | 5 +---- .../org/wordpress/android/fluxc/store/NotificationStore.kt | 5 ++--- .../main/java/org/wordpress/android/fluxc/store/PageStore.kt | 4 +--- .../main/java/org/wordpress/android/fluxc/store/SiteStore.kt | 2 +- 7 files changed, 9 insertions(+), 19 deletions(-) diff --git a/libs/fluxc/src/main/java/org/wordpress/android/fluxc/model/list/ListOrder.kt b/libs/fluxc/src/main/java/org/wordpress/android/fluxc/model/list/ListOrder.kt index 77b70276d50d..5650cb8bdcf3 100644 --- a/libs/fluxc/src/main/java/org/wordpress/android/fluxc/model/list/ListOrder.kt +++ b/libs/fluxc/src/main/java/org/wordpress/android/fluxc/model/list/ListOrder.kt @@ -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() } } } } diff --git a/libs/fluxc/src/main/java/org/wordpress/android/fluxc/model/list/PostListDescriptor.kt b/libs/fluxc/src/main/java/org/wordpress/android/fluxc/model/list/PostListDescriptor.kt index 03ab6dd36f46..10ee78ed7731 100644 --- a/libs/fluxc/src/main/java/org/wordpress/android/fluxc/model/list/PostListDescriptor.kt +++ b/libs/fluxc/src/main/java/org/wordpress/android/fluxc/model/list/PostListDescriptor.kt @@ -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, @@ -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() } } } } diff --git a/libs/fluxc/src/main/java/org/wordpress/android/fluxc/model/notification/NotificationModel.kt b/libs/fluxc/src/main/java/org/wordpress/android/fluxc/model/notification/NotificationModel.kt index 610c7c8480c5..62cf385ed56e 100644 --- a/libs/fluxc/src/main/java/org/wordpress/android/fluxc/model/notification/NotificationModel.kt +++ b/libs/fluxc/src/main/java/org/wordpress/android/fluxc/model/notification/NotificationModel.kt @@ -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, @@ -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 } } @@ -62,7 +61,7 @@ data class NotificationModel( return if (type.isEmpty()) { NONE } else { - reverseMap[type.uppercase(Locale.US)] ?: UNKNOWN + reverseMap[type.uppercase()] ?: UNKNOWN } } } diff --git a/libs/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/site/BooleanTypeAdapter.kt b/libs/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/site/BooleanTypeAdapter.kt index 4adce128166e..160675dbf0c0 100644 --- a/libs/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/site/BooleanTypeAdapter.kt +++ b/libs/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/site/BooleanTypeAdapter.kt @@ -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 { @Suppress("VariableNaming") private val TRUE_STRINGS: Set = HashSet(listOf("true", "1", "yes")) @@ -17,9 +16,7 @@ internal class BooleanTypeAdapter : JsonDeserializer { 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 } diff --git a/libs/fluxc/src/main/java/org/wordpress/android/fluxc/store/NotificationStore.kt b/libs/fluxc/src/main/java/org/wordpress/android/fluxc/store/NotificationStore.kt index cbbcab67c155..3898a33dcfcb 100644 --- a/libs/fluxc/src/main/java/org/wordpress/android/fluxc/store/NotificationStore.kt +++ b/libs/fluxc/src/main/java/org/wordpress/android/fluxc/store/NotificationStore.kt @@ -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 @@ -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 } } @@ -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 } } diff --git a/libs/fluxc/src/main/java/org/wordpress/android/fluxc/store/PageStore.kt b/libs/fluxc/src/main/java/org/wordpress/android/fluxc/store/PageStore.kt index 4242074a3062..cd63552066f2 100644 --- a/libs/fluxc/src/main/java/org/wordpress/android/fluxc/store/PageStore.kt +++ b/libs/fluxc/src/main/java/org/wordpress/android/fluxc/store/PageStore.kt @@ -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 @@ -83,8 +82,7 @@ class PageStore @Inject constructor( suspend fun search(site: SiteModel, searchQuery: String): List = 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()) } } diff --git a/libs/fluxc/src/main/java/org/wordpress/android/fluxc/store/SiteStore.kt b/libs/fluxc/src/main/java/org/wordpress/android/fluxc/store/SiteStore.kt index 0f18dad7f163..2ca8be053e9d 100644 --- a/libs/fluxc/src/main/java/org/wordpress/android/fluxc/store/SiteStore.kt +++ b/libs/fluxc/src/main/java/org/wordpress/android/fluxc/store/SiteStore.kt @@ -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