Skip to content

Commit

Permalink
replace deprecated toLowerCase / toUpperCase
Browse files Browse the repository at this point in the history
  • Loading branch information
westnordost committed Jul 4, 2021
1 parent c9367d3 commit dbfe44e
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class StringWithCursor(private val string: String) {
return true
}

/** Advances the cursor if str or str.toUpperCase() is the next thing at the cursor
/** Advances the cursor if str or str.uppercase() is the next thing at the cursor
*
* Returns whether the next string was the str or str.toUpperCase
* Returns whether the next string was the str or str.uppercase
*/
fun nextIsAndAdvanceIgnoreCase(str: String): Boolean {
if (!nextIsIgnoreCase(str)) return false
Expand Down Expand Up @@ -72,7 +72,7 @@ class StringWithCursor(private val string: String) {
fun nextIs(c: Char): Boolean = c == char
fun nextIs(str: String): Boolean = string.startsWith(str, cursorPos)
fun nextIsIgnoreCase(str: String): Boolean =
nextIs(str.toLowerCase()) || nextIs(str.toUpperCase())
nextIs(str.lowercase()) || nextIs(str.uppercase())

fun nextMatches(regex: Regex): MatchResult? {
val match = regex.find(string, cursorPos) ?: return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import de.westnordost.streetcomplete.data.osmnotes.notequests.OsmNoteQuestContro
import de.westnordost.streetcomplete.quests.note_discussion.NoteAnswer
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.util.Locale
import javax.inject.Inject
import javax.inject.Singleton
import kotlin.collections.ArrayList
Expand Down Expand Up @@ -47,7 +46,7 @@ import kotlin.collections.ArrayList

var fullText = "Unable to answer \"$questTitle\""
if (q is OsmQuest && q.elementId > 0) {
val lowercaseTypeName = q.elementType.name.toLowerCase(Locale.US)
val lowercaseTypeName = q.elementType.name.lowercase()
val elementId = q.elementId
fullText += " for https://osm.org/$lowercaseTypeName/$elementId"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ class KtMapController(private val c: MapController, contentResolver: ContentReso
class LoadSceneException(message: String, val sceneUpdate: SceneUpdate) : RuntimeException(message)

private fun SceneError.toException() =
LoadSceneException(error.name.toLowerCase(Locale.US).replace("_", " "), sceneUpdate)
LoadSceneException(error.name.lowercase().replace("_", " "), sceneUpdate)


suspend fun MapView.initMap(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import android.view.View
import android.view.ViewOutlineProvider
import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.ktx.getYamlObject
import java.util.Locale
import kotlin.math.min

/** Show a flag of a country in a circle */
Expand Down Expand Up @@ -131,7 +130,7 @@ class CircularFlagView @JvmOverloads constructor(
}

private fun getFlagResId(countryCode: String): Int {
val lowerCaseCountryCode = countryCode.toLowerCase(Locale.US).replace('-', '_')
val lowerCaseCountryCode = countryCode.lowercase().replace('-', '_')
return resources.getIdentifier("ic_flag_$lowerCaseCountryCode", "drawable", context.packageName)
}

Expand All @@ -152,7 +151,7 @@ class CircularFlagView @JvmOverloads constructor(

private fun readFlagAlignments(resources: Resources): Map<String, FlagAlignment> =
resources.getYamlObject<HashMap<String, String>>(R.raw.flag_alignments).map {
it.key to FlagAlignment.valueOf(it.value.replace("-","_").toUpperCase(Locale.US))
it.key to FlagAlignment.valueOf(it.value.replace("-","_").uppercase())
}.toMap()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class CountryInfoFragment : AbstractInfoFakeDialogFragment(R.layout.fragment_cou
}

private fun getFlagResId(countryCode: String): Int {
val lowerCaseCountryCode = countryCode.toLowerCase(Locale.US).replace('-', '_')
val lowerCaseCountryCode = countryCode.lowercase().replace('-', '_')
return resources.getIdentifier("ic_flag_$lowerCaseCountryCode", "drawable", requireContext().packageName)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class AutoCorrectAbbreviationsEditText @JvmOverloads constructor(
fixedReplace(s, wordStart, wordStart + lastWordBeforeCursor.length, replacement)
} else if (lastWordBeforeCursor.length > 3) {
val locale = abbrs.locale
val capital = lastWordBeforeCursor.substring(0, 1).toUpperCase(locale)
val capital = lastWordBeforeCursor.substring(0, 1).uppercase(locale)
s.replace(wordStart, wordStart + 1, capital)
}
}
Expand Down

0 comments on commit dbfe44e

Please sign in to comment.