Bug 965038 - Styling for links. r=nalexander

This commit is contained in:
Richard Newman 2014-01-28 15:49:39 -08:00
parent fbbe589163
commit cbb7b8036b
5 changed files with 20 additions and 6 deletions

View File

@ -118,7 +118,7 @@ public abstract class FxAccountAbstractActivity extends Activity {
continue;
}
ActivityUtils.linkifyTextView(textView);
ActivityUtils.linkifyTextView(textView, false);
}
}

View File

@ -61,7 +61,8 @@ public class FxAccountCreateAccountActivity extends FxAccountAbstractSetupActivi
final String linkedTOS = "<a href=\"" + linkTerms + "\">" + getString(R.string.fxaccount_policy_linktos) + "</a>";
final String linkedPN = "<a href=\"" + linkPrivacy + "\">" + getString(R.string.fxaccount_policy_linkprivacy) + "</a>";
policyView.setText(getString(R.string.fxaccount_policy_text, linkedTOS, linkedPN));
ActivityUtils.linkifyTextView(policyView);
final boolean underlineLinks = true;
ActivityUtils.linkifyTextView(policyView, underlineLinks);
emailEdit = (EditText) ensureFindViewById(null, R.id.email, "email edit");
passwordEdit = (EditText) ensureFindViewById(null, R.id.password, "password edit");

View File

@ -74,6 +74,7 @@
<TextView
android:id="@+id/policy"
style="@style/FxAccountLinkifiedItem"
android:textColorLink="@color/fxaccount_linkified_textColorLinkSubdued"
android:text="@string/fxaccount_policy_text" />
<LinearLayout style="@style/FxAccountSpacer" />

View File

@ -11,6 +11,7 @@
<color name="fxaccount_linkified_textColor">#c0c9d0</color>
<color name="fxaccount_linkified_textColorLink">#0096dd</color>
<color name="fxaccount_linkified_textColorLinkSubdued">#c0c9d0</color>
<color name="fxaccount_error">#d63920</color>
<color name="fxaccount_button_textColor">#ffffff</color>

View File

@ -17,6 +17,7 @@ import android.net.Uri;
import android.text.Html;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.text.style.URLSpan;
@ -60,9 +61,19 @@ public class ActivityUtils {
*/
public static class FennecClickableSpan extends ClickableSpan {
private final String url;
private final boolean underlining;
public FennecClickableSpan(final String url) {
public FennecClickableSpan(final String url, boolean underlining) {
this.url = url;
this.underlining = underlining;
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
if (!this.underlining) {
ds.setUnderlineText(false);
}
}
@Override
@ -79,10 +90,10 @@ public class ActivityUtils {
final Context context = view.getContext();
final String url = context.getString(link);
view.setText("<a href=\"" + url + "\">" + context.getString(text) + "</a>");
ActivityUtils.linkifyTextView(view);
linkifyTextView(view, false);
}
public static void linkifyTextView(TextView textView) {
public static void linkifyTextView(TextView textView, boolean underlining) {
if (textView == null) {
Logger.warn(LOG_TAG, "Could not process links for view.");
return;
@ -102,7 +113,7 @@ public class ActivityUtils {
final int flags = replaced.getSpanFlags(span);
replaced.removeSpan(span);
replaced.setSpan(new FennecClickableSpan(span.getURL()), start, end, flags);
replaced.setSpan(new FennecClickableSpan(span.getURL(), underlining), start, end, flags);
}
textView.setText(replaced);