Search in sources :

Example 81 with ClickableSpan

use of android.text.style.ClickableSpan in project RxTools by vondear.

the class ActivityTextTool method initView.

private void initView() {
    mRxTitle.setLeftFinish(mContext);
    ClickableSpan clickableSpan = new ClickableSpan() {

        @Override
        public void onClick(View widget) {
            RxToast.showToast(mContext, "事件触发了", 500);
        }

        @Override
        public void updateDrawState(TextPaint ds) {
            ds.setColor(Color.BLUE);
            ds.setUnderlineText(false);
        }
    };
    // 响应点击事件的话必须设置以下属性
    mTvAboutSpannable.setMovementMethod(LinkMovementMethod.getInstance());
    RxTextTool.getBuilder("").setBold().setAlign(Layout.Alignment.ALIGN_CENTER).append("测试").append("Url\n").setUrl(URL_VONTOOLS).append("列表项\n").setBullet(60, getResources().getColor(R.color.baby_blue)).append("  测试引用\n").setQuoteColor(getResources().getColor(R.color.baby_blue)).append("首行缩进\n").setLeadingMargin(30, 50).append("测试").append("上标").setSuperscript().append("下标\n").setSubscript().append("测试").append("点击事件\n").setClickSpan(clickableSpan).append("测试").append("serif 字体\n").setFontFamily("serif").append("测试").append("图片\n").setResourceId(R.drawable.logo).append("测试").append("前景色").setForegroundColor(Color.GREEN).append("背景色\n").setBackgroundColor(getResources().getColor(R.color.baby_blue)).append("测试").append("删除线").setStrikethrough().append("下划线\n").setUnderline().append("测试").append("sans-serif 字体\n").setFontFamily("sans-serif").append("测试").append("2倍字体\n").setProportion(2).append("测试").append("monospace字体\n").setFontFamily("monospace").append("测试").append("普通模糊效果字体\n").setBlur(3, BlurMaskFilter.Blur.NORMAL).append("测试").append(" 粗体 ").setBold().append(" 斜体 ").setItalic().append(" 粗斜体 \n").setBoldItalic().append("测试").append("横向2倍字体\n").setXProportion(2).append("\n测试正常对齐\n").setAlign(Layout.Alignment.ALIGN_NORMAL).append("测试居中对齐\n").setAlign(Layout.Alignment.ALIGN_CENTER).append("测试相反对齐\n").setAlign(Layout.Alignment.ALIGN_OPPOSITE).into(mTvAboutSpannable);
}
Also used : ClickableSpan(android.text.style.ClickableSpan) BindView(butterknife.BindView) TextView(android.widget.TextView) View(android.view.View) TextPaint(android.text.TextPaint)

Example 82 with ClickableSpan

use of android.text.style.ClickableSpan in project twicalico by moko256.

the class TwitterStringUtils method getProfileLinkedSequence.

public static CharSequence getProfileLinkedSequence(Context context, User user) {
    String description = user.getDescription();
    if (GlobalApplication.clientType == Type.MASTODON) {
        return convertUrlSpanToCustomTabs(Html.fromHtml(description), context);
    }
    URLEntity[] urlEntities = user.getDescriptionURLEntities();
    if (urlEntities == null || urlEntities.length <= 0 || TextUtils.isEmpty(urlEntities[0].getURL()))
        return description;
    SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(description);
    int tweetLength = description.codePointCount(0, description.length());
    int sp = 0;
    for (URLEntity entity : urlEntities) {
        String url = entity.getURL();
        String expandedUrl = entity.getDisplayURL();
        int urlLength = url.codePointCount(0, url.length());
        int displayUrlLength = expandedUrl.codePointCount(0, expandedUrl.length());
        if (entity.getStart() <= tweetLength && entity.getEnd() <= tweetLength) {
            int dusp = displayUrlLength - urlLength;
            spannableStringBuilder.replace(description.offsetByCodePoints(0, entity.getStart()) + sp, description.offsetByCodePoints(0, entity.getEnd()) + sp, expandedUrl);
            spannableStringBuilder.setSpan(new ClickableSpan() {

                @Override
                public void onClick(View view) {
                    AppCustomTabsKt.launchChromeCustomTabs(context, entity.getExpandedURL());
                }
            }, description.offsetByCodePoints(0, entity.getStart()) + sp, description.offsetByCodePoints(0, entity.getEnd()) + sp + dusp, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
            sp += dusp;
        }
    }
    return spannableStringBuilder;
}
Also used : URLEntity(twitter4j.URLEntity) ClickableSpan(android.text.style.ClickableSpan) View(android.view.View) TextView(android.widget.TextView) SpannableStringBuilder(android.text.SpannableStringBuilder) SuppressLint(android.annotation.SuppressLint)

Example 83 with ClickableSpan

use of android.text.style.ClickableSpan in project twicalico by moko256.

the class TwitterStringUtils method convertUrlSpanToCustomTabs.

public static SpannableStringBuilder convertUrlSpanToCustomTabs(Spanned spanned, Context context) {
    SpannableStringBuilder builder = SpannableStringBuilder.valueOf(spanned);
    URLSpan[] spans = builder.getSpans(0, builder.length(), URLSpan.class);
    for (URLSpan span : spans) {
        int spanStart = builder.getSpanStart(span);
        int spanEnd = builder.getSpanEnd(span);
        ClickableSpan span1;
        String firstChar = String.valueOf(builder.subSequence(spanStart, spanStart + 1));
        switch(firstChar) {
            case "#":
                span1 = new ClickableSpan() {

                    @Override
                    public void onClick(View widget) {
                        context.startActivity(SearchResultActivity.getIntent(context, String.valueOf(builder.subSequence(spanStart + 1, spanEnd))));
                    }
                };
                break;
            case "@":
                span1 = new ClickableSpan() {

                    @Override
                    public void onClick(View widget) {
                        context.startActivity(ShowUserActivity.getIntent(context, String.valueOf(builder.subSequence(spanStart + 1, spanEnd))));
                    }
                };
                break;
            default:
                span1 = new ClickableSpan() {

                    @Override
                    public void onClick(View view) {
                        AppCustomTabsKt.launchChromeCustomTabs(context, span.getURL());
                    }
                };
                break;
        }
        builder.removeSpan(span);
        builder.setSpan(span1, spanStart, spanEnd, builder.getSpanFlags(span));
    }
    return builder;
}
Also used : URLSpan(android.text.style.URLSpan) ClickableSpan(android.text.style.ClickableSpan) View(android.view.View) TextView(android.widget.TextView) SpannableStringBuilder(android.text.SpannableStringBuilder) SuppressLint(android.annotation.SuppressLint)

Example 84 with ClickableSpan

use of android.text.style.ClickableSpan in project twicalico by moko256.

the class TwitterStringUtils method setLinkedSequenceTo.

@SuppressLint("StaticFieldLeak")
public static void setLinkedSequenceTo(Status item, TextView textView) {
    Context context = textView.getContext();
    String tweet = item.getText();
    if (GlobalApplication.clientType == Type.MASTODON) {
        Spanned html = Html.fromHtml(tweet);
        int length = html.length();
        // Trim unless \n\n made by fromHtml() after post
        if (length == 3 && item.getMediaEntities().length > 0 && html.charAt(0) == ".".charAt(0)) {
            // If post has media only, context of post from Mastodon is "."
            textView.setText("");
            return;
        } else if (length >= 2) {
            html = (Spanned) html.subSequence(0, length - 2);
        }
        SpannableStringBuilder builder = convertUrlSpanToCustomTabs(html, context);
        textView.setText(builder);
        List<Emoji> list = ((StatusCacheMap.CachedStatus) item).getEmojis();
        if (list != null) {
            Matcher matcher = containsEmoji.matcher(builder);
            boolean matches = matcher.matches();
            int imageSize;
            if (matches) {
                imageSize = (int) Math.floor((textView.getTextSize() * 1.15) * 2.0);
            } else {
                imageSize = (int) Math.floor(textView.getTextSize() * 1.15);
            }
            new AsyncTask<Void, Void, Map<String, Drawable>>() {

                @Override
                protected Map<String, Drawable> doInBackground(Void... params) {
                    Map<String, Drawable> map = new ArrayMap<>();
                    GlideRequests glideRequests = GlideApp.with(context);
                    for (Emoji emoji : list) {
                        try {
                            Drawable value = glideRequests.load(emoji.getUrl()).submit().get();
                            value.setBounds(0, 0, imageSize, imageSize);
                            map.put(emoji.getShortCode(), value);
                        } catch (InterruptedException | ExecutionException e) {
                            e.printStackTrace();
                        }
                    }
                    return map;
                }

                @Override
                protected void onPostExecute(Map<String, Drawable> map) {
                    if (TextUtils.equals(builder, textView.getText())) {
                        boolean found = matches || matcher.find();
                        while (found) {
                            String shortCode = matcher.group(1);
                            Drawable drawable = map.get(shortCode);
                            if (drawable != null) {
                                builder.setSpan(new ImageSpan(drawable), matcher.start(), matcher.end(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                            }
                            found = matcher.find();
                        }
                        textView.setText(builder);
                    }
                }
            }.execute();
        }
        return;
    }
    SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(tweet);
    for (SymbolEntity symbolEntity : item.getSymbolEntities()) {
        spannableStringBuilder.setSpan(new ClickableSpan() {

            @Override
            public void onClick(View view) {
                context.startActivity(SearchResultActivity.getIntent(context, symbolEntity.getText()));
            }
        }, tweet.offsetByCodePoints(0, symbolEntity.getStart()), tweet.offsetByCodePoints(0, symbolEntity.getEnd()), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    }
    for (HashtagEntity hashtagEntity : item.getHashtagEntities()) {
        spannableStringBuilder.setSpan(new ClickableSpan() {

            @Override
            public void onClick(View view) {
                context.startActivity(SearchResultActivity.getIntent(context, "#" + hashtagEntity.getText()));
            }
        }, tweet.offsetByCodePoints(0, hashtagEntity.getStart()), tweet.offsetByCodePoints(0, hashtagEntity.getEnd()), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    }
    for (UserMentionEntity userMentionEntity : item.getUserMentionEntities()) {
        spannableStringBuilder.setSpan(new ClickableSpan() {

            @Override
            public void onClick(View view) {
                context.startActivity(ShowUserActivity.getIntent(context, userMentionEntity.getScreenName()));
            }
        }, tweet.offsetByCodePoints(0, userMentionEntity.getStart()), tweet.offsetByCodePoints(0, userMentionEntity.getEnd()), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    }
    boolean hasMedia = item.getMediaEntities().length > 0;
    List<URLEntity> urlEntities = new ArrayList<>(item.getURLEntities().length + (hasMedia ? 1 : 0));
    urlEntities.addAll(Arrays.asList(item.getURLEntities()));
    if (hasMedia) {
        urlEntities.add(item.getMediaEntities()[0]);
    }
    int tweetLength = tweet.codePointCount(0, tweet.length());
    int sp = 0;
    for (URLEntity entity : urlEntities) {
        String url = entity.getURL();
        String displayUrl = entity.getDisplayURL();
        int urlLength = url.codePointCount(0, url.length());
        int displayUrlLength = displayUrl.codePointCount(0, displayUrl.length());
        if (entity.getStart() <= tweetLength && entity.getEnd() <= tweetLength) {
            int dusp = displayUrlLength - urlLength;
            spannableStringBuilder.replace(tweet.offsetByCodePoints(0, entity.getStart()) + sp, tweet.offsetByCodePoints(0, entity.getEnd()) + sp, displayUrl);
            spannableStringBuilder.setSpan(new ClickableSpan() {

                @Override
                public void onClick(View view) {
                    AppCustomTabsKt.launchChromeCustomTabs(context, entity.getExpandedURL());
                }
            }, tweet.offsetByCodePoints(0, entity.getStart()) + sp, tweet.offsetByCodePoints(0, entity.getEnd()) + sp + dusp, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
            sp += dusp;
        }
    }
    textView.setText(spannableStringBuilder);
}
Also used : Matcher(java.util.regex.Matcher) GlideRequests(com.github.moko256.twicalico.GlideRequests) ArrayList(java.util.ArrayList) SymbolEntity(twitter4j.SymbolEntity) Emoji(com.github.moko256.twicalico.entity.Emoji) HashtagEntity(twitter4j.HashtagEntity) Context(android.content.Context) URLEntity(twitter4j.URLEntity) Drawable(android.graphics.drawable.Drawable) Spanned(android.text.Spanned) ClickableSpan(android.text.style.ClickableSpan) View(android.view.View) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) UserMentionEntity(twitter4j.UserMentionEntity) ArrayMap(android.support.v4.util.ArrayMap) Map(java.util.Map) StatusCacheMap(com.github.moko256.twicalico.cacheMap.StatusCacheMap) SpannableStringBuilder(android.text.SpannableStringBuilder) ImageSpan(android.text.style.ImageSpan) SuppressLint(android.annotation.SuppressLint)

Example 85 with ClickableSpan

use of android.text.style.ClickableSpan in project PhoneProfilesPlus by henrichg.

the class AboutApplicationActivity method onCreate.

@SuppressLint({ "InlinedApi", "SetTextI18n" })
@Override
protected void onCreate(Bundle savedInstanceState) {
    // must by called before super.onCreate() for PreferenceActivity
    // must by called before super.onCreate()
    GlobalGUIRoutines.setTheme(this, false, false, false);
    GlobalGUIRoutines.setLanguage(getBaseContext());
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about_application);
    if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) && (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)) {
        // in Activity's onCreate() for instance
        Window w = getWindow();
        // w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        // create our manager instance after the content view is set
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        // enable status bar tint
        tintManager.setStatusBarTintEnabled(true);
        // set a custom tint color for status bar
        if (ApplicationPreferences.applicationTheme(getApplicationContext()).equals("material"))
            tintManager.setStatusBarTintColor(Color.parseColor("#ff237e9f"));
        else
            tintManager.setStatusBarTintColor(Color.parseColor("#ff202020"));
    }
    if (getSupportActionBar() != null) {
        getSupportActionBar().setHomeButtonEnabled(true);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle(R.string.about_application_title);
    }
    TextView text = findViewById(R.id.about_application_application_version);
    try {
        PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        text.setText(getString(R.string.about_application_version) + " " + pInfo.versionName + " (" + pInfo.versionCode + ")");
    } catch (Exception e) {
        text.setText("");
    }
    text = findViewById(R.id.about_application_author);
    CharSequence str1 = getString(R.string.about_application_author);
    CharSequence str2 = str1 + " Henrich Gron";
    Spannable sbt = new SpannableString(str2);
    sbt.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, str1.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    text.setText(sbt);
    text = findViewById(R.id.about_application_email);
    str1 = getString(R.string.about_application_email);
    str2 = str1 + " henrich.gron@gmail.com";
    sbt = new SpannableString(str2);
    sbt.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, str1.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    ClickableSpan clickableSpan = new ClickableSpan() {

        @Override
        public void onClick(View textView) {
            Intent intent = new Intent(Intent.ACTION_SENDTO);
            // only email apps should handle this
            intent.setData(Uri.parse("mailto:"));
            String[] email = { "henrich.gron@gmail.com" };
            intent.putExtra(Intent.EXTRA_EMAIL, email);
            String packageVersion = "";
            try {
                PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
                packageVersion = " - v" + pInfo.versionName + " (" + pInfo.versionCode + ")";
            } catch (Exception ignored) {
            }
            intent.putExtra(Intent.EXTRA_SUBJECT, "PhoneProfilesPlus" + packageVersion);
            try {
                startActivity(Intent.createChooser(intent, getString(R.string.email_chooser)));
            } catch (Exception ignored) {
            }
        }
    };
    sbt.setSpan(clickableSpan, str1.length() + 1, str2.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    sbt.setSpan(new UnderlineSpan(), str1.length() + 1, str2.length(), 0);
    text.setText(sbt);
    text.setMovementMethod(LinkMovementMethod.getInstance());
    text = findViewById(R.id.about_application_privacy_policy);
    str1 = getString(R.string.about_application_privacy_policy);
    str2 = str1 + " https://sites.google.com/site/phoneprofilesplus/home/privacy-policy";
    sbt = new SpannableString(str2);
    sbt.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, str1.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    clickableSpan = new ClickableSpan() {

        @Override
        public void onClick(View textView) {
            String url = "https://sites.google.com/site/phoneprofilesplus/home/privacy-policy";
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            try {
                startActivity(Intent.createChooser(i, getString(R.string.web_browser_chooser)));
            } catch (Exception ignored) {
            }
        }
    };
    sbt.setSpan(clickableSpan, str1.length() + 1, str2.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    sbt.setSpan(new UnderlineSpan(), str1.length() + 1, str2.length(), 0);
    text.setText(sbt);
    text.setMovementMethod(LinkMovementMethod.getInstance());
    text = findViewById(R.id.about_application_releases);
    str1 = getString(R.string.about_application_releases);
    str2 = str1 + " https://github.com/henrichg/PhoneProfilesPlus/releases";
    sbt = new SpannableString(str2);
    sbt.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, str1.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    clickableSpan = new ClickableSpan() {

        @Override
        public void onClick(View textView) {
            String url = "https://github.com/henrichg/PhoneProfilesPlus/releases";
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            try {
                startActivity(Intent.createChooser(i, getString(R.string.web_browser_chooser)));
            } catch (Exception ignored) {
            }
        }
    };
    sbt.setSpan(clickableSpan, str1.length() + 1, str2.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    sbt.setSpan(new UnderlineSpan(), str1.length() + 1, str2.length(), 0);
    text.setText(sbt);
    text.setMovementMethod(LinkMovementMethod.getInstance());
    text = findViewById(R.id.about_application_source_code);
    str1 = getString(R.string.about_application_source_code);
    str2 = str1 + " https://github.com/henrichg/PhoneProfilesPlus";
    sbt = new SpannableString(str2);
    sbt.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, str1.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    clickableSpan = new ClickableSpan() {

        @Override
        public void onClick(View textView) {
            String url = "https://github.com/henrichg/PhoneProfilesPlus";
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            try {
                startActivity(Intent.createChooser(i, getString(R.string.web_browser_chooser)));
            } catch (Exception ignored) {
            }
        }
    };
    sbt.setSpan(clickableSpan, str1.length() + 1, str2.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    sbt.setSpan(new UnderlineSpan(), str1.length() + 1, str2.length(), 0);
    text.setText(sbt);
    text.setMovementMethod(LinkMovementMethod.getInstance());
    text = findViewById(R.id.about_application_extender_source_code);
    str1 = getString(R.string.about_application_extender_source_code);
    str2 = str1 + " https://github.com/henrichg/PhoneProfilesPlusExtender";
    sbt = new SpannableString(str2);
    sbt.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, str1.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    clickableSpan = new ClickableSpan() {

        @Override
        public void onClick(View textView) {
            String url = "https://github.com/henrichg/PhoneProfilesPlusExtender";
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            try {
                startActivity(Intent.createChooser(i, getString(R.string.web_browser_chooser)));
            } catch (Exception ignored) {
            }
        }
    };
    sbt.setSpan(clickableSpan, str1.length() + 1, str2.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    sbt.setSpan(new UnderlineSpan(), str1.length() + 1, str2.length(), 0);
    text.setText(sbt);
    text.setMovementMethod(LinkMovementMethod.getInstance());
    text = findViewById(R.id.about_application_translations);
    str1 = getString(R.string.about_application_transaltions);
    str2 = str1 + " https://crowdin.com/project/phoneprofilesplus";
    sbt = new SpannableString(str2);
    sbt.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, str1.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    clickableSpan = new ClickableSpan() {

        @Override
        public void onClick(View textView) {
            String url = "https://crowdin.com/project/phoneprofilesplus";
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            try {
                startActivity(Intent.createChooser(i, getString(R.string.web_browser_chooser)));
            } catch (Exception ignored) {
            }
        }
    };
    sbt.setSpan(clickableSpan, str1.length() + 1, str2.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    sbt.setSpan(new UnderlineSpan(), str1.length() + 1, str2.length(), 0);
    text.setText(sbt);
    text.setMovementMethod(LinkMovementMethod.getInstance());
    text = findViewById(R.id.about_application_rate_application);
    str1 = getString(R.string.about_application_rate_in_gplay);
    sbt = new SpannableString(str1);
    clickableSpan = new ClickableSpan() {

        @Override
        public void onClick(View textView) {
            Uri uri = Uri.parse("market://details?id=" + getPackageName());
            Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
            // to taken back to our application, we need to add following flags to intent.
            if (android.os.Build.VERSION.SDK_INT >= 21)
                goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
            else
                goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
            try {
                startActivity(goToMarket);
            } catch (ActivityNotFoundException e) {
                try {
                    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + getPackageName()));
                    startActivity(Intent.createChooser(i, getString(R.string.google_play_chooser)));
                } catch (Exception ignored) {
                }
            }
        }
    };
    sbt.setSpan(clickableSpan, 0, str1.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    sbt.setSpan(new UnderlineSpan(), 0, str1.length(), 0);
    text.setText(sbt);
    text.setMovementMethod(LinkMovementMethod.getInstance());
    Button donateButton = findViewById(R.id.about_application_donate_button);
    donateButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(getBaseContext(), DonationActivity.class);
            startActivity(intent);
        }
    });
}
Also used : Window(android.view.Window) PackageInfo(android.content.pm.PackageInfo) Intent(android.content.Intent) SystemBarTintManager(com.readystatesoftware.systembartint.SystemBarTintManager) SpannableString(android.text.SpannableString) ClickableSpan(android.text.style.ClickableSpan) TextView(android.widget.TextView) View(android.view.View) Uri(android.net.Uri) ActivityNotFoundException(android.content.ActivityNotFoundException) UnderlineSpan(android.text.style.UnderlineSpan) SpannableString(android.text.SpannableString) ActivityNotFoundException(android.content.ActivityNotFoundException) Button(android.widget.Button) StyleSpan(android.text.style.StyleSpan) TextView(android.widget.TextView) Spannable(android.text.Spannable) SuppressLint(android.annotation.SuppressLint)

Aggregations

ClickableSpan (android.text.style.ClickableSpan)133 View (android.view.View)76 TextView (android.widget.TextView)55 TextPaint (android.text.TextPaint)50 SpannableString (android.text.SpannableString)46 Layout (android.text.Layout)37 Spannable (android.text.Spannable)28 SpannableStringBuilder (android.text.SpannableStringBuilder)24 Intent (android.content.Intent)17 NonNull (androidx.annotation.NonNull)15 Paint (android.graphics.Paint)14 Context (android.content.Context)12 Spanned (android.text.Spanned)12 URLSpan (android.text.style.URLSpan)12 ImageView (android.widget.ImageView)12 StyleSpan (android.text.style.StyleSpan)9 Uri (android.net.Uri)8 SuppressLint (android.annotation.SuppressLint)7 InputMethodManager (android.view.inputmethod.InputMethodManager)7 DialogInterface (android.content.DialogInterface)6