aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui/util/JidDialog.java
blob: 291bb873c174b4fc9ca57659312acb7a37c7242f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package de.pixart.messenger.ui.util;

import android.content.Context;
import android.support.annotation.StringRes;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.TypefaceSpan;

public class JidDialog {

    public static SpannableString style(Context context, @StringRes int res, String... args) {
        SpannableString spannable = new SpannableString(context.getString(res, (Object[]) args));
        if (args.length >= 1) {
            final String value = args[0];
            int start = spannable.toString().indexOf(value);
            if (start >= 0) {
                spannable.setSpan(new TypefaceSpan("monospace"), start, start + value.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
        }
        return spannable;
    }
}