Search in sources :

Example 41 with LinkMovementMethod

use of android.text.method.LinkMovementMethod in project android_packages_apps_Settings by SudaMod.

the class LinkablePreference method onBindViewHolder.

@Override
public void onBindViewHolder(PreferenceViewHolder view) {
    super.onBindViewHolder(view);
    TextView textView = (TextView) view.findViewById(android.R.id.title);
    if (textView == null) {
        return;
    }
    textView.setSingleLine(false);
    if (mContentTitle == null || mClickListener == null) {
        return;
    }
    StringBuilder contentBuilder = new StringBuilder().append(mContentTitle);
    if (mContentDescription != null) {
        contentBuilder.append("\n\n");
        contentBuilder.append(mContentDescription);
    }
    boolean linked = LinkifyUtils.linkify(textView, contentBuilder, mClickListener);
    if (linked && mContentTitle != null) {
        // Embolden and enlarge the title.
        Spannable boldSpan = (Spannable) textView.getText();
        boldSpan.setSpan(new TextAppearanceSpan(getContext(), android.R.style.TextAppearance_Medium), 0, mContentTitle.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
        textView.setText(boldSpan);
        textView.setMovementMethod(new LinkMovementMethod());
    }
}
Also used : TextAppearanceSpan(android.text.style.TextAppearanceSpan) LinkMovementMethod(android.text.method.LinkMovementMethod) TextView(android.widget.TextView) Spannable(android.text.Spannable)

Example 42 with LinkMovementMethod

use of android.text.method.LinkMovementMethod in project platform_packages_apps_Settings by BlissRoms.

the class LinkablePreference method onBindViewHolder.

@Override
public void onBindViewHolder(PreferenceViewHolder view) {
    super.onBindViewHolder(view);
    TextView textView = (TextView) view.findViewById(android.R.id.title);
    if (textView == null) {
        return;
    }
    textView.setSingleLine(false);
    if (mContentTitle == null || mClickListener == null) {
        return;
    }
    StringBuilder contentBuilder = new StringBuilder().append(mContentTitle);
    if (mContentDescription != null) {
        contentBuilder.append("\n\n");
        contentBuilder.append(mContentDescription);
    }
    boolean linked = LinkifyUtils.linkify(textView, contentBuilder, mClickListener);
    if (linked && mContentTitle != null) {
        // Embolden and enlarge the title.
        Spannable boldSpan = (Spannable) textView.getText();
        boldSpan.setSpan(new TextAppearanceSpan(getContext(), android.R.style.TextAppearance_Medium), 0, mContentTitle.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
        textView.setText(boldSpan);
        textView.setMovementMethod(new LinkMovementMethod());
    }
}
Also used : TextAppearanceSpan(android.text.style.TextAppearanceSpan) LinkMovementMethod(android.text.method.LinkMovementMethod) TextView(android.widget.TextView) Spannable(android.text.Spannable)

Example 43 with LinkMovementMethod

use of android.text.method.LinkMovementMethod in project ButterRemote-Android by se-bastiaan.

the class DonationFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Activity activity = getActivity();
    assert activity != null;
    View view = getActivity().getLayoutInflater().inflate(R.layout.donation_dialog, null, false);
    AlertDialog.Builder builder = new AlertDialog.Builder(activity).setTitle(R.string.donation_title).setView(view).setNegativeButton(android.R.string.cancel, null);
    TextView info = (TextView) view.findViewById(R.id.info);
    info.setText(Html.fromHtml(getString(R.string.donation_info)));
    info.setMovementMethod(new LinkMovementMethod());
    mError = (TextView) view.findViewById(R.id.error);
    mProgressBar = (ProgressBar) view.findViewById(android.R.id.progress);
    mGridView = (GridView) view.findViewById(R.id.grid);
    mGridView.setAdapter(new DonationAdapter(getActivity(), mDonationList, mInventorySet));
    mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            DonationAdapter adapter = (DonationAdapter) parent.getAdapter();
            Donation donation = adapter.getItem(position);
            if (!mInventorySet.contains(donation.sku)) {
                /**
                 * See {@link sharedcode.turboeditor.iab.DonationFragment#verifyDeveloperPayload(Purchase)}.
                 */
                String payload = "";
                try {
                    mHelper.launchPurchaseFlow(getActivity(), donation.sku, RC_REQUEST, mPurchaseFinishedListener, payload);
                } catch (Exception e) {
                    Toast.makeText(getActivity(), "Failed to launch a purchase flow.", Toast.LENGTH_SHORT).show();
                }
            } else {
                Toast.makeText(getActivity(), getString(R.string.donation_item_bought), Toast.LENGTH_LONG);
            }
        }
    });
    final AlertDialog alertDialog;
    alertDialog = builder.create();
    initBilling();
    return alertDialog;
}
Also used : AlertDialog(android.app.AlertDialog) Activity(android.app.Activity) LinkMovementMethod(android.text.method.LinkMovementMethod) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ActivityNotFoundException(android.content.ActivityNotFoundException) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView)

Example 44 with LinkMovementMethod

use of android.text.method.LinkMovementMethod in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NotificationFooterPreference method onBindViewHolder.

@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    TextView title = holder.itemView.findViewById(android.R.id.title);
    title.setMovementMethod(new LinkMovementMethod());
    title.setClickable(false);
    title.setLongClickable(false);
}
Also used : LinkMovementMethod(android.text.method.LinkMovementMethod) TextView(android.widget.TextView)

Example 45 with LinkMovementMethod

use of android.text.method.LinkMovementMethod in project Stringlate by LonamiWebs.

the class ActivityUtils method showDialogWithHtmlTextView.

public void showDialogWithHtmlTextView(@StringRes int resTitleId, String text, boolean isHtml, DialogInterface.OnDismissListener dismissedListener) {
    AppCompatTextView textView = new AppCompatTextView(_context);
    int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, _context.getResources().getDisplayMetrics());
    textView.setMovementMethod(new LinkMovementMethod());
    textView.setPadding(padding, 0, padding, 0);
    textView.setText(isHtml ? new SpannableString(Html.fromHtml(text)) : text);
    AlertDialog.Builder dialog = new AlertDialog.Builder(_context).setPositiveButton(android.R.string.ok, null).setOnDismissListener(dismissedListener).setTitle(resTitleId).setView(textView);
    dialog.show();
}
Also used : SpannableString(android.text.SpannableString) AlertDialog(android.support.v7.app.AlertDialog) AppCompatTextView(android.support.v7.widget.AppCompatTextView) LinkMovementMethod(android.text.method.LinkMovementMethod)

Aggregations

LinkMovementMethod (android.text.method.LinkMovementMethod)50 TextView (android.widget.TextView)40 SmallTest (android.test.suitebuilder.annotation.SmallTest)18 View (android.view.View)12 Spannable (android.text.Spannable)8 TextAppearanceSpan (android.text.style.TextAppearanceSpan)7 ImageView (android.widget.ImageView)7 SpannableStringBuilder (android.text.SpannableStringBuilder)6 SpannableString (android.text.SpannableString)4 ActivityNotFoundException (android.content.ActivityNotFoundException)3 Context (android.content.Context)3 ViewGroup (android.view.ViewGroup)3 SystemUIDialog (com.android.systemui.statusbar.phone.SystemUIDialog)3 Intent (android.content.Intent)2 PackageManager (android.content.pm.PackageManager)2 Resources (android.content.res.Resources)2 Paint (android.graphics.Paint)2 Bundle (android.os.Bundle)2 ActionBar (android.support.v7.app.ActionBar)2 AlertDialog (android.support.v7.app.AlertDialog)2