use of android.text.style.ClickableSpan in project zype-android by zype.
the class ConsumerActivity method bindViews.
// //////////
// UI
//
private void bindViews() {
if (consumer != null) {
layoutEmail.getEditText().setText(consumer.email);
layoutPassword.getEditText().setText(consumer.password);
}
// Set link to Terms screen
String terms = getString(R.string.consumer_create_terms);
String termsLink = getString(R.string.consumer_create_terms_link);
SpannableString spannableTerms = new SpannableString(terms);
ClickableSpan spanTerms = new ClickableSpan() {
@Override
public void onClick(View widget) {
switchToTermsScreen();
}
};
int index = terms.indexOf(termsLink);
spannableTerms.setSpan(spanTerms, index, index + termsLink.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
textTerms.setText(spannableTerms);
textTerms.setMovementMethod(LinkMovementMethod.getInstance());
// Set link to Sign in
String signIn = getString(R.string.consumer_create_sign_in);
String signInLink = getString(R.string.consumer_create_sign_in_link);
SpannableString spannableSignIn = new SpannableString(signIn);
ClickableSpan spanSignIn = new ClickableSpan() {
@Override
public void onClick(View widget) {
switchToLoginScreen();
}
};
int indexSignIn = signIn.indexOf(signInLink);
spannableSignIn.setSpan(spanSignIn, indexSignIn, indexSignIn + signInLink.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
textSignIn.setText(spannableSignIn);
textSignIn.setMovementMethod(LinkMovementMethod.getInstance());
}
use of android.text.style.ClickableSpan in project Klyph by jonathangerbaud.
the class TextViewUtil method setTextClickableForTags.
/**
* Make a clickable for the tags in parameters
* If callback is null, TextViewUtil.onTagClick is called
*/
public static void setTextClickableForTags(final Context context, TextView textView, Map<String, List<Tag>> tags, final TagCallback callback, boolean clickable) {
SpannableStringBuilder strBuilder = new SpannableStringBuilder(textView.getText());
for (final List<Tag> tagList : tags.values()) {
if (tagList.size() > 0) {
CharacterStyle span;
if (clickable) {
span = new ClickableSpan() {
@Override
public void onClick(View widget) {
if (callback != null)
callback.onTagClick(tagList);
else
onTagClick(context, tagList);
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(false);
ds.setFakeBoldText(true);
}
};
} else {
span = new StyleSpan(Typeface.BOLD);
}
Tag tag = tagList.get(0);
strBuilder.setSpan(span, tag.getOffset(), tag.getOffset() + tag.getLength(), 0);
}
}
textView.setText(strBuilder);
textView.setMovementMethod(LinkMovementMethod.getInstance());
}
use of android.text.style.ClickableSpan in project TextJustify-Android by bluejamesbond.
the class ClickableSpanTest method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final DocumentView documentView = addDocumentView(new ArticleBuilder().append("Healthcare workers returning to New York or New Jersey after treating Ebola patients in West Africa will be placed under a mandatory quarantine, officials announced Friday, one day after a Doctors Without Borders doctor was diagnosed with the virus in New York City. Illinois announced a similar policy Saturday, meaning it will be enforced in states with three of the five airports through which passengers traveling from the Ebola-stricken West African countries must enter the United States.", true, new RelativeSizeSpan(1f), new JustifiedSpan()).append("N.J. Gov. Chris Christie and N.Y. Gov. Andrew Cuomo made the announcement as part of a broader procedural plan to help protect the densely packed, highly populated area from any further spread of the disease. ", true, new RelativeSizeSpan(0.8f), new JustifiedSpan(), new MyQuoteSpan(0xFFFFC801)).append("“Since taking office, I have erred on the side of caution when it comes to the safety and protection of New Yorkers, and the current situation regarding Ebola will be no different,” Gov. Cuomo said. “The steps New York and New Jersey are taking today will strengthen our safeguards to protect our residents against this disease and help ensure those that may be infected by Ebola are treated with the highest precautions.”", true, new RelativeSizeSpan(1f), new JustifiedSpan(), new ClickableSpan() {
@Override
public void onClick(View widget) {
Toast.makeText(ClickableSpanTest.this, "Clicked", Toast.LENGTH_SHORT).show();
}
@Override
public void updateDrawState(TextPaint ds) {
ds.setColor(Color.parseColor("#ff05c5cf"));
ds.setUnderlineText(true);
}
}).append("New York and New Jersey state health department staff will be present on the ground at John F. Kennedy International Airport in New York and Newark Liberty Airport in New Jersey. In addition to implementing the mandatory quarantine of health care workers and others who had direct contact with Ebola patients, health department officials in each state will determine whether others should travelers should be hospitalized or quarantined.", true, new RelativeSizeSpan(1f), new JustifiedSpan()).append("“The announcements mark a dramatic escalation in measures designed to prevent the spread of Ebola in the United States. Previously, only individuals with symptoms of Ebola would be quarantined upon entry to the U.S. under a federal rule from the Centers for Diseases Control and the Department of Homeland Security.”", true, new RelativeSizeSpan(1f), new JustifiedSpan()), DocumentView.FORMATTED_TEXT);
documentView.getDocumentLayoutParams().setHyphenator(SqueezeHyphenator.getInstance());
documentView.getDocumentLayoutParams().setHyphenated(true);
}
use of android.text.style.ClickableSpan in project actor-platform by actorapp.
the class BaseAuthFragment method findAndHilightTos.
private void findAndHilightTos(SpannableStringBuilder builder, String text, boolean urlAvailable) {
String tosIndex = getString(R.string.auth_tos_index);
int index = text.indexOf(tosIndex);
ClickableSpan span;
if (urlAvailable) {
span = new BaseUrlSpan(ActorSDK.sharedActor().getTosUrl(), false);
} else {
span = new CustomClicableSpan(new CustomClicableSpan.SpanClickListener() {
@Override
public void onClick() {
new AlertDialog.Builder(getContext()).setTitle(R.string.auth_tos_index).setMessage(ActorSDK.sharedActor().getTosText()).setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).show();
}
});
}
builder.setSpan(span, index, index + tosIndex.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}
use of android.text.style.ClickableSpan in project actor-platform by actorapp.
the class BaseAuthFragment method findAndHilightPrivacy.
private void findAndHilightPrivacy(SpannableStringBuilder builder, String text, boolean urlAvailable) {
String ppIndex = getString(R.string.auth_privacy_index);
int index = text.indexOf(ppIndex);
ClickableSpan span;
if (urlAvailable) {
span = new BaseUrlSpan(ActorSDK.sharedActor().getPrivacyUrl(), false);
} else {
span = new CustomClicableSpan(new CustomClicableSpan.SpanClickListener() {
@Override
public void onClick() {
new AlertDialog.Builder(getContext()).setTitle(R.string.auth_privacy_index).setMessage(ActorSDK.sharedActor().getPrivacyText()).setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).show();
}
});
}
builder.setSpan(span, index, index + ppIndex.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}
Aggregations