Skip to content

Commit 6ba043c

Browse files
committed
Analysis: Resolve kotlin stdlib's to lower case deprecated warnings
Warning Message: "'toLowerCase(Locale): String' is deprecated. Use lowercase() instead." Replacing 'toLowerCase(...)' with 'lowercase(...)' is the recommended action to resolve this kind of deprecated warnings.
1 parent 96fb186 commit 6ba043c

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/AztecTagHandler.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import org.wordpress.aztec.spans.createTaskListSpan
5353
import org.wordpress.aztec.spans.createUnorderedListSpan
5454
import org.wordpress.aztec.util.getLast
5555
import org.xml.sax.Attributes
56+
import java.util.Locale
5657

5758
class AztecTagHandler(val context: Context, val plugins: List<IAztecPlugin> = ArrayList(), private val alignmentRendering: AlignmentRendering
5859
) : Html.TagHandler {
@@ -75,7 +76,7 @@ class AztecTagHandler(val context: Context, val plugins: List<IAztecPlugin> = Ar
7576
return true
7677
}
7778

78-
when (tag.toLowerCase()) {
79+
when (tag.lowercase(Locale.getDefault())) {
7980
LIST_LI -> {
8081
val span = createListItemSpan(nestingLevel, alignmentRendering, AztecAttributes(attributes))
8182
handleElement(output, opening, span)

aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ import java.security.MessageDigest
132132
import java.security.NoSuchAlgorithmException
133133
import java.util.Arrays
134134
import java.util.LinkedList
135+
import java.util.Locale
135136

136137
@Suppress("UNUSED_PARAMETER")
137138
open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknownHtmlTappedListener, IEventInjector {
@@ -1818,7 +1819,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
18181819
// Android 8 Ref: https://github.com/wordpress-mobile/WordPress-Android/issues/8827
18191820
clipboardIdentifier -> {
18201821
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && Build.VERSION.SDK_INT < Build.VERSION_CODES.P
1821-
&& Build.MANUFACTURER.toLowerCase().equals("samsung")) {
1822+
&& Build.MANUFACTURER.lowercase(Locale.getDefault()).equals("samsung")) {
18221823
// Nope return true
18231824
Toast.makeText(context, context.getString(R.string.samsung_disabled_custom_clipboard, Build.VERSION.RELEASE), Toast.LENGTH_LONG).show()
18241825
} else {

aztec/src/main/kotlin/org/wordpress/aztec/spans/AztecHeadingSpan.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fun createHeadingSpan(nestingLevel: Int,
2020
alignmentRendering: AlignmentRendering,
2121
headerStyle: BlockFormatter.HeaderStyles = BlockFormatter.HeaderStyles(0, emptyMap())
2222
): AztecHeadingSpan {
23-
val textFormat = when (tag.toLowerCase(Locale.getDefault())) {
23+
val textFormat = when (tag.lowercase(Locale.getDefault())) {
2424
"h1" -> AztecTextFormat.FORMAT_HEADING_1
2525
"h2" -> AztecTextFormat.FORMAT_HEADING_2
2626
"h3" -> AztecTextFormat.FORMAT_HEADING_3

wordpress-comments/src/main/java/org/wordpress/aztec/plugins/wpcomments/WordPressCommentsPlugin.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import org.wordpress.aztec.Constants
99
import org.wordpress.aztec.plugins.html2visual.IHtmlCommentHandler
1010
import org.wordpress.aztec.plugins.visual2html.IInlineSpanHandler
1111
import org.wordpress.aztec.plugins.wpcomments.spans.WordPressCommentSpan
12+
import java.util.Locale
1213

1314
class WordPressCommentsPlugin(private val visualEditor: AztecText) : IInlineSpanHandler, IHtmlCommentHandler {
1415

@@ -33,7 +34,8 @@ class WordPressCommentsPlugin(private val visualEditor: AztecText) : IInlineSpan
3334

3435
val spanStart = output.length
3536

36-
if (text.toLowerCase() == WordPressCommentSpan.Comment.MORE.html.toLowerCase()) {
37+
if (text.lowercase(Locale.getDefault()) ==
38+
WordPressCommentSpan.Comment.MORE.html.lowercase(Locale.getDefault())) {
3739

3840
output.append(Constants.MAGIC_CHAR)
3941

@@ -49,7 +51,8 @@ class WordPressCommentsPlugin(private val visualEditor: AztecText) : IInlineSpan
4951
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
5052
)
5153
return true
52-
} else if (text.toLowerCase() == WordPressCommentSpan.Comment.PAGE.html.toLowerCase()) {
54+
} else if (text.lowercase(Locale.getDefault()) ==
55+
WordPressCommentSpan.Comment.PAGE.html.lowercase(Locale.getDefault())) {
5356

5457
output.append(Constants.MAGIC_CHAR)
5558

0 commit comments

Comments
 (0)