Skip to content
Snippets Groups Projects
Commit bfeff9f9 authored by cyberta's avatar cyberta
Browse files

take extra care for wrongly formatted strings when using spannables in TetheringDialog

parent 51e2e18f
No related branches found
No related tags found
No related merge requests found
...@@ -209,10 +209,18 @@ public class TetheringDialog extends AppCompatDialogFragment implements Observer ...@@ -209,10 +209,18 @@ public class TetheringDialog extends AppCompatDialogFragment implements Observer
int endIndex = 0; int endIndex = 0;
if (matcher.matches()) { if (matcher.matches()) {
startIndex = matcher.start(2); startIndex = matcher.start(2);
try {
endIndex = startIndex + matcher.group(3).length(); endIndex = startIndex + matcher.group(3).length();
} catch (NullPointerException npe) {
endIndex = -1;
}
} }
systemSettingsMessage = systemSettingsMessage.replace("<b>", "").replace("</b>", ""); systemSettingsMessage = systemSettingsMessage.replace("<b>", "").replace("</b>", "");
String wholeMessage = systemSettingsMessage + "\n\n" + tetheringMessage; String wholeMessage = systemSettingsMessage + "\n\n" + tetheringMessage;
if (startIndex == -1 || endIndex == -1) {
Log.e(TAG, "Tethering string has wrong formatting!");
return wholeMessage;
}
Spannable spannable = new SpannableString(wholeMessage); Spannable spannable = new SpannableString(wholeMessage);
spannable.setSpan(new ClickableSpan() { spannable.setSpan(new ClickableSpan() {
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment