androidx.core.text.HtmlCompat Java Examples

The following examples show how to use androidx.core.text.HtmlCompat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SupportUsDialog.java    From EnhancedScreenshotNotification with GNU General Public License v3.0 7 votes vote down vote up
public static void start(@NonNull Context context) {
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "BuildConfig.SHOW_ALIPAY_ALWAYS: " + BuildConfig.SHOW_ALIPAY_ALWAYS);
        Log.i(TAG, "hasInstalledAlipayClient: " + hasInstalledAlipayClient(context));
    }
    final boolean shouldShowAlipay = BuildConfig.SHOW_ALIPAY_ALWAYS || hasInstalledAlipayClient(context);
    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(R.string.support_us_dialog_title);
    builder.setMessage(HtmlCompat.fromHtml(context.getString(shouldShowAlipay ?
            R.string.support_us_dialog_message : R.string.support_us_dialog_message_play_store), 0));
    builder.setPositiveButton(R.string.rate_us, (dialog, which) -> {
        context.startActivity(IntentUtils.createViewIntent(
                Uri.parse("https://play.google.com/store/apps/details?id=moe.feng.nevo.decorators.enscreenshot")
        ).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
    });
    builder.setNegativeButton(android.R.string.cancel, null);
    if (shouldShowAlipay) {
        builder.setNeutralButton(R.string.donate, (dialog, which) -> startAlipayDonateDialog(context));
    }
    builder.show();
}
 
Example #2
Source File: MessageRequestsBottomView.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
public void setRecipient(@NonNull Recipient recipient) {
  if (recipient.isBlocked()) {
    if (recipient.isGroup()) {
      question.setText(R.string.MessageRequestBottomView_unblock_to_allow_group_members_to_add_you_to_this_group_again);
    } else {
      question.setText(HtmlCompat.fromHtml(getContext().getString(R.string.MessageRequestBottomView_unblock_s_to_message_and_call_each_other, HtmlUtil.bold(recipient.getDisplayName(getContext()))), 0));
    }
    normalButtons.setVisibility(GONE);
    blockedButtons.setVisibility(VISIBLE);
  } else {
    if (recipient.isGroup()) {
      if (recipient.isPushV2Group()) {
        question.setText(HtmlCompat.fromHtml(getContext().getString(R.string.MessageRequestBottomView_you_were_invited_to_join_the_group_s, HtmlUtil.bold(recipient.getDisplayName(getContext()))), 0));
      } else {
        question.setText(HtmlCompat.fromHtml(getContext().getString(R.string.MessageRequestBottomView_do_you_want_to_join_the_group_s_they_wont_know_youve_seen_their_messages_until_you_accept, HtmlUtil.bold(recipient.getDisplayName(getContext()))), 0));
      }
    } else {
      question.setText(HtmlCompat.fromHtml(getContext().getString(R.string.MessageRequestBottomView_do_you_want_to_let_s_message_you_they_wont_know_youve_seen_their_messages_until_you_accept, HtmlUtil.bold(recipient.getDisplayName(getContext()))), 0));
    }
    normalButtons.setVisibility(VISIBLE);
    blockedButtons.setVisibility(GONE);
  }
}
 
Example #3
Source File: ApkVersionHelper.java    From XposedSmsCode with GNU General Public License v3.0 6 votes vote down vote up
static ApkVersion parseFromCoolApk(String html) {
    Document document = Jsoup.parse(html);
    String versionName = "-1";
    String versionInfo = null;
    if (document != null) {
        Element element = document.selectFirst("title");
        if (element != null) {
            String text = element.text();
            Pattern p = Pattern.compile("\\d(\\.\\d)+");
            Matcher m = p.matcher(text);
            if (m.find()) {
                versionName = m.group();
            }
        }

        Element rootInfoEle = document.selectFirst(".apk_left_title:contains(新版特性)");
        if (rootInfoEle != null) {
            Element infoEle = rootInfoEle.selectFirst(".apk_left_title_info");
            if (infoEle != null) {
                versionInfo = HtmlCompat.fromHtml(infoEle.toString(), HtmlCompat.FROM_HTML_MODE_COMPACT)
                        .toString().trim();
            }
        }
    }
    return new ApkVersion(versionName, versionInfo);
}
 
Example #4
Source File: CreateSupportDialogFragment.java    From lbry-android with MIT License 6 votes vote down vote up
private void updateInfoText() {
    View view = getView();
    if (view != null && switchTip != null) {
        TextView infoText = view.findViewById(R.id.create_support_info);
        boolean isTip = switchTip.isChecked();

        infoText.setMovementMethod(LinkMovementMethod.getInstance());
        if (!isTip) {
            infoText.setText(HtmlCompat.fromHtml(getString(R.string.support_info), HtmlCompat.FROM_HTML_MODE_LEGACY));
        } else if (claim != null) {
            infoText.setText(HtmlCompat.fromHtml(
                    Claim.TYPE_CHANNEL.equalsIgnoreCase(claim.getValueType()) ?
                            getString(R.string.send_tip_info_channel, claim.getTitleOrName()) :
                            getString(R.string.send_tip_info_content, claim.getTitleOrName()),
                    HtmlCompat.FROM_HTML_MODE_LEGACY));
        }
    }
}
 
Example #5
Source File: ViewUtils.java    From FirefoxReality with Mozilla Public License 2.0 5 votes vote down vote up
public static void setTextViewHTML(@NonNull TextView text, @NonNull String html, LinkClickableSpan listener)
{
    CharSequence sequence = HtmlCompat.fromHtml(html, HtmlCompat.FROM_HTML_MODE_LEGACY);
    SpannableStringBuilder strBuilder = new SpannableStringBuilder(sequence);
    URLSpan[] urls = strBuilder.getSpans(0, sequence.length(), URLSpan.class);
    for(URLSpan span : urls) {
        makeLinkClickable(strBuilder, span, listener);
    }
    text.setText(strBuilder);
    text.setMovementMethod(LinkMovementMethod.getInstance());
}
 
Example #6
Source File: FirstRunActivity.java    From lbry-android with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_first_run);

    TextView welcomeTos = findViewById(R.id.welcome_text_view_tos);
    welcomeTos.setMovementMethod(LinkMovementMethod.getInstance());
    welcomeTos.setText(HtmlCompat.fromHtml(getString(R.string.welcome_tos), HtmlCompat.FROM_HTML_MODE_LEGACY));

    findViewById(R.id.welcome_link_use_lbry).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finishFirstRun();
        }
    });

    registerAuthReceiver();
    if (!Lbry.SDK_READY) {
        findViewById(R.id.welcome_wait_container).setVisibility(View.VISIBLE);
    } else {
        authenticate();
    }

    IntentFilter filter = new IntentFilter();
    filter.addAction(MainActivity.ACTION_SDK_READY);
    filter.addAction(LbrynetService.ACTION_STOP_SERVICE);
    sdkReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (MainActivity.ACTION_SDK_READY.equals(action)) {
                // authenticate after we receive the sdk ready event
                authenticate();
            } else if (LbrynetService.ACTION_STOP_SERVICE.equals(action)) {
                finish();
            }
        }
    };
    registerReceiver(sdkReceiver, filter);
}
 
Example #7
Source File: ChannelAboutFragment.java    From lbry-android with MIT License 5 votes vote down vote up
public View onCreateView(@NonNull LayoutInflater inflater,
                         ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_channel_about, container, false);

    layoutInfoArea = root.findViewById(R.id.channel_about_info_area);
    layoutNoAboutInfo = root.findViewById(R.id.channel_about_no_info_container);
    layoutWebsite = root.findViewById(R.id.channel_about_website_container);
    layoutEmail = root.findViewById(R.id.channel_about_email_container);
    textWebsite = root.findViewById(R.id.channel_about_website);
    textEmail = root.findViewById(R.id.channel_about_email);
    textDescription = root.findViewById(R.id.channel_about_description);

    boolean noInfo = (Helper.isNullOrEmpty(website) && Helper.isNullOrEmpty(email) && Helper.isNullOrEmpty(description));
    layoutNoAboutInfo.setVisibility(noInfo ? View.VISIBLE : View.GONE);
    layoutInfoArea.setVisibility(noInfo ? View.GONE : View.VISIBLE);
    layoutWebsite.setVisibility(!Helper.isNullOrEmpty(website) ? View.VISIBLE : View.GONE);
    layoutEmail.setVisibility(!Helper.isNullOrEmpty(email) ? View.VISIBLE : View.GONE);
    textDescription.setVisibility(!Helper.isNullOrEmpty(description) ? View.VISIBLE : View.GONE);

    textWebsite.setLinksClickable(true);
    textWebsite.setMovementMethod(LinkMovementMethod.getInstance());
    textWebsite.setText(!Helper.isNullOrEmpty(website) ?
            HtmlCompat.fromHtml(String.format("<a href=\"%s\">%s</a>", website, website), HtmlCompat.FROM_HTML_MODE_LEGACY) : null);

    textEmail.setText(email);
    textDescription.setText(description);

    return root;
}
 
Example #8
Source File: ChannelAboutFragment.java    From lbry-android with MIT License 5 votes vote down vote up
public void refresh() {
    textWebsite.setText(!Helper.isNullOrEmpty(website) ?
            HtmlCompat.fromHtml(String.format("<a href=\"%s\">%s</a>", website, website), HtmlCompat.FROM_HTML_MODE_LEGACY) : null);

    textEmail.setText(email);
    textDescription.setText(description);
}
 
Example #9
Source File: MainActivity.java    From quickstart-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onFilter(Filters filters) {
    // Construct query basic query
    Query query = mFirestore.collection("restaurants");

    // Category (equality filter)
    if (filters.hasCategory()) {
        query = query.whereEqualTo(Restaurant.FIELD_CATEGORY, filters.getCategory());
    }

    // City (equality filter)
    if (filters.hasCity()) {
        query = query.whereEqualTo(Restaurant.FIELD_CITY, filters.getCity());
    }

    // Price (equality filter)
    if (filters.hasPrice()) {
        query = query.whereEqualTo(Restaurant.FIELD_PRICE, filters.getPrice());
    }

    // Sort by (orderBy with direction)
    if (filters.hasSortBy()) {
        query = query.orderBy(filters.getSortBy(), filters.getSortDirection());
    }

    // Limit items
    query = query.limit(LIMIT);

    // Update the query
    mAdapter.setQuery(query);

    // Set header
    mBinding.textCurrentSearch.setText(HtmlCompat.fromHtml(filters.getSearchDescription(this),
            HtmlCompat.FROM_HTML_MODE_LEGACY));
    mBinding.textCurrentSortBy.setText(filters.getOrderDescription(this));

    // Save filters
    mViewModel.setFilters(filters);
}
 
Example #10
Source File: ConversationFragment.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
private static void presentMessageRequestProfileView(@NonNull Context context, @NonNull MessageRequestViewModel.RecipientInfo recipientInfo, @Nullable ConversationBannerView conversationBanner) {

    if (conversationBanner == null) {
      return;
    }

    Recipient    recipient          = recipientInfo.getRecipient();
    boolean      isSelf             = Recipient.self().equals(recipient);
    int          memberCount        = recipientInfo.getGroupMemberCount();
    int          pendingMemberCount = recipientInfo.getGroupPendingMemberCount();
    List<String> groups             = recipientInfo.getSharedGroups();

    if (recipient != null) {
      conversationBanner.setAvatar(GlideApp.with(context), recipient);

      String title = isSelf ? context.getString(R.string.note_to_self) : recipient.getDisplayName(context);
      conversationBanner.setTitle(title);

      if (recipient.isGroup()) {
        if (pendingMemberCount > 0) {
          conversationBanner.setSubtitle(context.getResources()
                                                .getQuantityString(R.plurals.MessageRequestProfileView_members_and_invited, memberCount,
                                                                   memberCount, pendingMemberCount));
        } else {
          conversationBanner.setSubtitle(context.getResources().getQuantityString(R.plurals.MessageRequestProfileView_members, memberCount,
                                                                                  memberCount));
        }
      } else if (isSelf) {
        conversationBanner.setSubtitle(context.getString(R.string.ConversationFragment__you_can_add_notes_for_yourself_in_this_conversation));
      } else {
        String subtitle = recipient.getUsername().or(recipient.getE164()).orNull();

        if (subtitle == null || subtitle.equals(title)) {
          conversationBanner.hideSubtitle();
        } else {
          conversationBanner.setSubtitle(subtitle);
        }
      }
    }

    if (groups.isEmpty() || isSelf) {
      conversationBanner.hideDescription();
    } else {
      final String description;

      switch (groups.size()) {
        case 1:
          description = context.getString(R.string.MessageRequestProfileView_member_of_one_group, HtmlUtil.bold(groups.get(0)));
          break;
        case 2:
          description = context.getString(R.string.MessageRequestProfileView_member_of_two_groups, HtmlUtil.bold(groups.get(0)), HtmlUtil.bold(groups.get(1)));
          break;
        case 3:
          description = context.getString(R.string.MessageRequestProfileView_member_of_many_groups, HtmlUtil.bold(groups.get(0)), HtmlUtil.bold(groups.get(1)), HtmlUtil.bold(groups.get(2)));
          break;
        default:
          int others = groups.size() - 2;
          description = context.getString(R.string.MessageRequestProfileView_member_of_many_groups,
                                          HtmlUtil.bold(groups.get(0)),
                                          HtmlUtil.bold(groups.get(1)),
                                          context.getResources().getQuantityString(R.plurals.MessageRequestProfileView_member_of_others, others, others));
      }

      conversationBanner.setDescription(HtmlCompat.fromHtml(description, 0));
      conversationBanner.showDescription();
    }
  }
 
Example #11
Source File: Helper.java    From lbry-android with MIT License 4 votes vote down vote up
public static void applyHtmlForTextView(TextView textView) {
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    textView.setText(HtmlCompat.fromHtml(textView.getText().toString(), HtmlCompat.FROM_HTML_MODE_LEGACY));
}