Search in sources :

Example 1 with BaseUrlSpan

use of im.actor.sdk.view.BaseUrlSpan 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);
}
Also used : DialogInterface(android.content.DialogInterface) CustomClicableSpan(im.actor.sdk.view.CustomClicableSpan) SpannableStringBuilder(android.text.SpannableStringBuilder) BaseUrlSpan(im.actor.sdk.view.BaseUrlSpan) ClickableSpan(android.text.style.ClickableSpan)

Example 2 with BaseUrlSpan

use of im.actor.sdk.view.BaseUrlSpan 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);
}
Also used : DialogInterface(android.content.DialogInterface) CustomClicableSpan(im.actor.sdk.view.CustomClicableSpan) SpannableStringBuilder(android.text.SpannableStringBuilder) BaseUrlSpan(im.actor.sdk.view.BaseUrlSpan) ClickableSpan(android.text.style.ClickableSpan)

Example 3 with BaseUrlSpan

use of im.actor.sdk.view.BaseUrlSpan in project actor-platform by actorapp.

the class ChatListProcessor method fixLinkifyCustomLinks.

private boolean fixLinkifyCustomLinks(Spannable spannable, Pattern p, boolean isMention) {
    Matcher m = p.matcher(spannable.toString());
    boolean res = false;
    while (m.find()) {
        boolean found = false;
        String nick = "";
        UserVM user;
        int userId = 0;
        if (isGroup) {
            for (GroupMember member : group.getMembers().get()) {
                user = users().get(member.getUid());
                nick = user.getNick().get();
                if (nick != null && !nick.isEmpty() && nick.equals(m.group().substring(1, m.group().length()))) {
                    userId = user.getId();
                    found = true;
                    break;
                }
            }
        }
        if (isMention && !found) {
            return false;
        }
        URLSpan span = (isMention && isGroup && found) ? new MentionSpan(nick, userId, false) : new BaseUrlSpan(m.group(), false);
        spannable.setSpan(span, m.start(), m.end(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        res = true;
    }
    return res;
}
Also used : GroupMember(im.actor.core.entity.GroupMember) UserVM(im.actor.core.viewmodel.UserVM) Matcher(java.util.regex.Matcher) MentionSpan(im.actor.sdk.controllers.conversation.view.MentionSpan) BaseUrlSpan(im.actor.sdk.view.BaseUrlSpan) SpannableString(android.text.SpannableString) URLSpan(android.text.style.URLSpan)

Aggregations

BaseUrlSpan (im.actor.sdk.view.BaseUrlSpan)3 DialogInterface (android.content.DialogInterface)2 SpannableStringBuilder (android.text.SpannableStringBuilder)2 ClickableSpan (android.text.style.ClickableSpan)2 CustomClicableSpan (im.actor.sdk.view.CustomClicableSpan)2 SpannableString (android.text.SpannableString)1 URLSpan (android.text.style.URLSpan)1 GroupMember (im.actor.core.entity.GroupMember)1 UserVM (im.actor.core.viewmodel.UserVM)1 MentionSpan (im.actor.sdk.controllers.conversation.view.MentionSpan)1 Matcher (java.util.regex.Matcher)1