summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorBonian Chen <bonianchen@google.com>2020-06-29 01:42:26 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-06-29 01:42:26 +0000
commit136cb73ae6015a397452aeb7e17c6aa42e27e5b3 (patch)
tree5b3ca65fb5835f6ae01d8d216399186c94fa6ec0 /src/com
parentaf5950790a9bf1e7d592bba04e20e84c6602198a (diff)
parent5faf7717225ce47221781c516b50668ea917b881 (diff)
downloadpackages_apps_Settings-136cb73ae6015a397452aeb7e17c6aa42e27e5b3.tar.gz
packages_apps_Settings-136cb73ae6015a397452aeb7e17c6aa42e27e5b3.tar.bz2
packages_apps_Settings-136cb73ae6015a397452aeb7e17c6aa42e27e5b3.zip
Merge "[Settings] Learn more link should be removed when not supported." into rvc-dev
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/settings/network/telephony/NrDisabledInDsdsFooterPreferenceController.java2
-rw-r--r--src/com/android/settings/utils/AnnotationSpan.java20
2 files changed, 21 insertions, 1 deletions
diff --git a/src/com/android/settings/network/telephony/NrDisabledInDsdsFooterPreferenceController.java b/src/com/android/settings/network/telephony/NrDisabledInDsdsFooterPreferenceController.java
index 4077e91ae8..3911fb8038 100644
--- a/src/com/android/settings/network/telephony/NrDisabledInDsdsFooterPreferenceController.java
+++ b/src/com/android/settings/network/telephony/NrDisabledInDsdsFooterPreferenceController.java
@@ -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));
}
}
diff --git a/src/com/android/settings/utils/AnnotationSpan.java b/src/com/android/settings/utils/AnnotationSpan.java
index 1b8179d759..98256a00cb 100644
--- a/src/com/android/settings/utils/AnnotationSpan.java
+++ b/src/com/android/settings/utils/AnnotationSpan.java
@@ -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.
@@ -76,6 +79,23 @@ public class AnnotationSpan extends URLSpan {
}
/**
+ * 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
*/
public static class LinkInfo {