Merge "[Settings] Learn more link should be removed when not supported." into rvc-dev
This commit is contained in:
@@ -69,7 +69,7 @@ public class NrDisabledInDsdsFooterPreferenceController extends BasePreferenceCo
|
||||
if (linkInfo.isActionable()) {
|
||||
return AnnotationSpan.linkify(mContext.getText(R.string.no_5g_in_dsds_text), linkInfo);
|
||||
} else {
|
||||
return mContext.getText(R.string.no_5g_in_dsds_text);
|
||||
return AnnotationSpan.textWithoutLink(mContext.getText(R.string.no_5g_in_dsds_text));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,9 @@ import android.text.style.URLSpan;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* This class is used to add {@link View.OnClickListener} for the text been wrapped by
|
||||
* annotation.
|
||||
@@ -75,6 +78,23 @@ public class AnnotationSpan extends URLSpan {
|
||||
return builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the text part without having text for link part
|
||||
*/
|
||||
public static CharSequence textWithoutLink(CharSequence encodedText) {
|
||||
SpannableString msg = new SpannableString(encodedText);
|
||||
Annotation[] spans = msg.getSpans(0, msg.length(), Annotation.class);
|
||||
if (spans == null) {
|
||||
return encodedText;
|
||||
}
|
||||
Arrays.sort(spans, Comparator.comparingInt(span -> -msg.getSpanStart(span)));
|
||||
StringBuilder msgWithoutLink = new StringBuilder(msg.toString());
|
||||
for (Annotation span : spans) {
|
||||
msgWithoutLink.delete(msg.getSpanStart(span), msg.getSpanEnd(span));
|
||||
}
|
||||
return msgWithoutLink.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Data class to store the annotation and the click action
|
||||
*/
|
||||
|
Reference in New Issue
Block a user