Skip to content

Commit

Permalink
Analysis: Resolve kotlin stdlib's to lower case deprecated warnings
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ParaskP7 committed Nov 17, 2022
1 parent 96fb186 commit 6ba043c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion aztec/src/main/kotlin/org/wordpress/aztec/AztecTagHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import org.wordpress.aztec.spans.createTaskListSpan
import org.wordpress.aztec.spans.createUnorderedListSpan
import org.wordpress.aztec.util.getLast
import org.xml.sax.Attributes
import java.util.Locale

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

when (tag.toLowerCase()) {
when (tag.lowercase(Locale.getDefault())) {
LIST_LI -> {
val span = createListItemSpan(nestingLevel, alignmentRendering, AztecAttributes(attributes))
handleElement(output, opening, span)
Expand Down
3 changes: 2 additions & 1 deletion aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ import java.security.MessageDigest
import java.security.NoSuchAlgorithmException
import java.util.Arrays
import java.util.LinkedList
import java.util.Locale

@Suppress("UNUSED_PARAMETER")
open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknownHtmlTappedListener, IEventInjector {
Expand Down Expand Up @@ -1818,7 +1819,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
// Android 8 Ref: https://github.com/wordpress-mobile/WordPress-Android/issues/8827
clipboardIdentifier -> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && Build.VERSION.SDK_INT < Build.VERSION_CODES.P
&& Build.MANUFACTURER.toLowerCase().equals("samsung")) {
&& Build.MANUFACTURER.lowercase(Locale.getDefault()).equals("samsung")) {
// Nope return true
Toast.makeText(context, context.getString(R.string.samsung_disabled_custom_clipboard, Build.VERSION.RELEASE), Toast.LENGTH_LONG).show()
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fun createHeadingSpan(nestingLevel: Int,
alignmentRendering: AlignmentRendering,
headerStyle: BlockFormatter.HeaderStyles = BlockFormatter.HeaderStyles(0, emptyMap())
): AztecHeadingSpan {
val textFormat = when (tag.toLowerCase(Locale.getDefault())) {
val textFormat = when (tag.lowercase(Locale.getDefault())) {
"h1" -> AztecTextFormat.FORMAT_HEADING_1
"h2" -> AztecTextFormat.FORMAT_HEADING_2
"h3" -> AztecTextFormat.FORMAT_HEADING_3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.wordpress.aztec.Constants
import org.wordpress.aztec.plugins.html2visual.IHtmlCommentHandler
import org.wordpress.aztec.plugins.visual2html.IInlineSpanHandler
import org.wordpress.aztec.plugins.wpcomments.spans.WordPressCommentSpan
import java.util.Locale

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

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

val spanStart = output.length

if (text.toLowerCase() == WordPressCommentSpan.Comment.MORE.html.toLowerCase()) {
if (text.lowercase(Locale.getDefault()) ==
WordPressCommentSpan.Comment.MORE.html.lowercase(Locale.getDefault())) {

output.append(Constants.MAGIC_CHAR)

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

output.append(Constants.MAGIC_CHAR)

Expand Down

0 comments on commit 6ba043c

Please sign in to comment.