fix link style
This commit is contained in:
parent
89339321b9
commit
17cf543fc0
1 changed files with 9 additions and 3 deletions
|
@ -46,6 +46,8 @@ import net.osmand.plus.download.DownloadIndexesThread;
|
||||||
import net.osmand.plus.download.DownloadResources;
|
import net.osmand.plus.download.DownloadResources;
|
||||||
import net.osmand.plus.download.DownloadValidationManager;
|
import net.osmand.plus.download.DownloadValidationManager;
|
||||||
import net.osmand.plus.download.IndexItem;
|
import net.osmand.plus.download.IndexItem;
|
||||||
|
import net.osmand.plus.helpers.FontCache;
|
||||||
|
import net.osmand.plus.widgets.style.CustomTypefaceSpan;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
@ -339,25 +341,29 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
|
||||||
String text,
|
String text,
|
||||||
String clickableText,
|
String clickableText,
|
||||||
final String url,
|
final String url,
|
||||||
final boolean fakeBold) {
|
final boolean medium) {
|
||||||
SpannableString spannableString = new SpannableString(text);
|
SpannableString spannableString = new SpannableString(text);
|
||||||
ClickableSpan clickableSpan = new ClickableSpan() {
|
ClickableSpan clickableSpan = new ClickableSpan() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(@NonNull View view) {
|
public void onClick(@NonNull View view) {
|
||||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||||
i.setData(Uri.parse(url));
|
i.setData(Uri.parse(url));
|
||||||
startActivity(i);
|
if (AndroidUtils.isIntentSafe(app, i)) {
|
||||||
|
startActivity(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateDrawState(@NonNull TextPaint ds) {
|
public void updateDrawState(@NonNull TextPaint ds) {
|
||||||
super.updateDrawState(ds);
|
super.updateDrawState(ds);
|
||||||
ds.setFakeBoldText(fakeBold);
|
|
||||||
ds.setUnderlineText(false);
|
ds.setUnderlineText(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
int startIndex = text.indexOf(clickableText);
|
int startIndex = text.indexOf(clickableText);
|
||||||
|
if (medium) {
|
||||||
|
spannableString.setSpan(new CustomTypefaceSpan(FontCache.getRobotoMedium(app)), startIndex, startIndex + clickableText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
|
}
|
||||||
spannableString.setSpan(clickableSpan, startIndex, startIndex + clickableText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
spannableString.setSpan(clickableSpan, startIndex, startIndex + clickableText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
textView.setText(spannableString);
|
textView.setText(spannableString);
|
||||||
textView.setMovementMethod(LinkMovementMethod.getInstance());
|
textView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
|
Loading…
Reference in a new issue