Skip to content
Snippets Groups Projects
Commit dfd00321 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Prevent a crash in the DuplicationWarningDialog

parent 61aa4149
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ import android.text.SpannableString
import android.text.Spanned
import android.text.style.ForegroundColorSpan
import android.text.style.StyleSpan
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
......@@ -92,8 +93,12 @@ class DuplicationWarningDialog : VLCBottomSheetDialogFragment(), View.OnClickLis
val styledText = SpannableString.valueOf(secondaryMessage)
val startIndex = styledText.indexOf(searchTitle)
val endIndex = startIndex + searchTitle.length
styledText.setSpan(StyleSpan(Typeface.BOLD), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
styledText.setSpan(ForegroundColorSpan(MaterialColors.getColor(requireContext(), R.attr.font_default, Color.BLACK)), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
try {
styledText.setSpan(StyleSpan(Typeface.BOLD), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
styledText.setSpan(ForegroundColorSpan(MaterialColors.getColor(requireContext(), R.attr.font_default, Color.BLACK)), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
} catch (e: Exception) {
Log.e("DupWarningDialog", "setupSecondaryText: $e")
}
finalMessage = SpannableString.valueOf(finalMessage.toString() + styledText.toString()+"\n")
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment