Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1497df60 authored by Bonian Chen's avatar Bonian Chen Committed by Automerger Merge Worker
Browse files

Merge "[Settings] Learn more link should be removed when not supported." am: ec42c98e

Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/1385020

Change-Id: I51ec6ca9199a44c4107b9308036fbc309c4af446
parents 4ee1d085 ec42c98e
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -11337,11 +11337,11 @@
    <string name="rtt_settings_always_visible"></string>
    <!-- Footer to show current limitation of 5G on DSDS mode. [CHAR LIMIT=NONE] -->
    <string name="no_5g_in_dsds_text" product="default">When using 2 SIMs, this phone will be limited to 4G. <annotation id="url">Learn more</annotation>.</string>
    <string name="no_5g_in_dsds_text" product="default">When using 2 SIMs, this phone will be limited to 4G. <annotation id="url">Learn more</annotation></string>
    <!-- Footer to show current limitation of 5G on DSDS mode for tablets. [CHAR LIMIT=NONE] -->
    <string name="no_5g_in_dsds_text" product="tablet">When using 2 SIMs, this tablet will be limited to 4G. <annotation id="url">Learn more</annotation>.</string>
    <string name="no_5g_in_dsds_text" product="tablet">When using 2 SIMs, this tablet will be limited to 4G. <annotation id="url">Learn more</annotation></string>
    <!-- Footer to show current limitation of 5G on DSDS mode for general devices. [CHAR LIMIT=NONE] -->
    <string name="no_5g_in_dsds_text" product="device">When using 2 SIMs, this device will be limited to 4G. <annotation id="url">Learn more</annotation>.</string>
    <string name="no_5g_in_dsds_text" product="device">When using 2 SIMs, this device will be limited to 4G. <annotation id="url">Learn more</annotation></string>
    <!-- Help URI, 5G limitation in DSDS condition. [DO NOT TRANSLATE] -->
    <string name="help_uri_5g_dsds" translatable="false"></string>
</resources>
+1 −1
Original line number Diff line number Diff line
@@ -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));
        }
    }

+20 −0
Original line number Diff line number Diff line
@@ -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
     */