Example usage for android.text.style AbsoluteSizeSpan AbsoluteSizeSpan

List of usage examples for android.text.style AbsoluteSizeSpan AbsoluteSizeSpan

Introduction

In this page you can find the example usage for android.text.style AbsoluteSizeSpan AbsoluteSizeSpan.

Prototype

public AbsoluteSizeSpan(int size, boolean dip) 

Source Link

Document

Set the text size to size physical pixels, or to size device-independent pixels if dip is true.

Usage

From source file:Main.java

public static SpannableString formatTextSize(String txt, int size, int start, int end) {
    SpannableString spanString = new SpannableString(txt);
    AbsoluteSizeSpan span = new AbsoluteSizeSpan(size, true);
    spanString.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    return spanString;
}

From source file:Main.java

public static void setPartialSizeAndColor(TextView tv, int start, int end, int textSize, int textColor) {
    String s = tv.getText().toString();
    Spannable spannable = new SpannableString(s);
    spannable.setSpan(new AbsoluteSizeSpan(textSize, false), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    spannable.setSpan(new ForegroundColorSpan(textColor), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    tv.setText(spannable);//from w  w w  .j av a  2 s  .  c om
}

From source file:com.innoc.secureline.ui.UpgradeCallDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    final AlertDialog.Builder builder;
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
        builder = new AlertDialog.Builder(
                new ContextThemeWrapper(getActivity(), R.style.RedPhone_Light_Dialog));
    } else {/*from  w w  w.ja v a 2 s . c  o  m*/
        builder = new AlertDialog.Builder(getActivity(), R.style.RedPhone_Light_Dialog);
    }

    builder.setIcon(R.drawable.red_call);

    final String upgradeString = getActivity().getResources()
            .getString(R.string.RedPhoneChooser_upgrade_to_redphone);
    SpannableStringBuilder titleBuilder = new SpannableStringBuilder(upgradeString);
    titleBuilder.setSpan(new AbsoluteSizeSpan(20, true), 0, upgradeString.length(),
            Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    builder.setTitle(titleBuilder);

    //builder.setMessage(R.string.RedPhoneChooser_this_contact_also_uses_redphone_would_you_like_to_upgrade_to_a_secure_call);

    builder.setPositiveButton(R.string.RedPhoneChooser_secure_call, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(getActivity(), SecureLineService.class);
            intent.setAction(SecureLineService.ACTION_OUTGOING_CALL);
            intent.putExtra(Constants.REMOTE_NUMBER, number);
            getActivity().startService(intent);

            Intent activityIntent = new Intent();
            activityIntent.setClass(getActivity(), SecureLine.class);
            activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(activityIntent);

            getActivity().finish();
        }
    });

    builder.setNegativeButton(R.string.RedPhoneChooser_insecure_call, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            CallChooserCache.getInstance().addInsecureChoice(number);

            Intent intent = new Intent("android.intent.action.CALL",
                    Uri.fromParts("tel", number + CallListener.IGNORE_SUFFIX, null));
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            getActivity().finish();
        }
    });

    AlertDialog alert = builder.create();

    alert.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            ((AlertDialog) dialog).setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialogInterface) {
                    getActivity().finish();
                }
            });

            ((AlertDialog) dialog).setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialogInterface) {
                    getActivity().finish();
                }
            });
            Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);

            Button negativeButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE);
        }
    });

    return alert;
}

From source file:com.mindprotectionkit.freephone.ui.UpgradeCallDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    final AlertDialog.Builder builder;
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
        builder = new AlertDialog.Builder(
                new ContextThemeWrapper(getActivity(), R.style.RedPhone_Light_Dialog));
    } else {/*w  ww  .  j  ava  2  s .c o  m*/
        builder = new AlertDialog.Builder(getActivity(), R.style.RedPhone_Light_Dialog);
    }

    builder.setIcon(R.drawable.red_call);

    final String upgradeString = getActivity().getResources()
            .getString(R.string.RedPhoneChooser_upgrade_to_redphone);
    SpannableStringBuilder titleBuilder = new SpannableStringBuilder(upgradeString);
    titleBuilder.setSpan(new AbsoluteSizeSpan(20, true), 0, upgradeString.length(),
            Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    builder.setTitle(titleBuilder);

    //builder.setMessage(R.string.RedPhoneChooser_this_contact_also_uses_redphone_would_you_like_to_upgrade_to_a_secure_call);

    builder.setPositiveButton(R.string.RedPhoneChooser_secure_call, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(getActivity(), RedPhoneService.class);
            intent.setAction(RedPhoneService.ACTION_OUTGOING_CALL);
            intent.putExtra(Constants.REMOTE_NUMBER, number);
            getActivity().startService(intent);

            Intent activityIntent = new Intent();
            activityIntent.setClass(getActivity(), RedPhone.class);
            activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(activityIntent);

            getActivity().finish();
        }
    });

    builder.setNegativeButton(R.string.RedPhoneChooser_insecure_call, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            CallChooserCache.getInstance().addInsecureChoice(number);

            Intent intent = new Intent("android.intent.action.CALL",
                    Uri.fromParts("tel", number + CallListener.IGNORE_SUFFIX, null));
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            getActivity().finish();
        }
    });

    AlertDialog alert = builder.create();

    alert.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            ((AlertDialog) dialog).setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialogInterface) {
                    getActivity().finish();
                }
            });

            ((AlertDialog) dialog).setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialogInterface) {
                    getActivity().finish();
                }
            });
            Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);

            Button negativeButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE);
        }
    });

    return alert;
}

From source file:com.securecomcode.voice.ui.UpgradeCallDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    final AlertDialog.Builder builder;
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
        builder = new AlertDialog.Builder(
                new ContextThemeWrapper(getActivity(), R.style.RedPhone_Light_Dialog));
    } else {//from ww  w .j a  v  a2  s  .  com
        builder = new AlertDialog.Builder(getActivity(), R.style.RedPhone_Light_Dialog);
    }

    builder.setIcon(R.drawable.red_call);

    final String upgradeString = getActivity().getResources()
            .getString(R.string.RedPhoneChooser_upgrade_to_redphone);
    SpannableStringBuilder titleBuilder = new SpannableStringBuilder(upgradeString);
    titleBuilder.setSpan(new AbsoluteSizeSpan(20, true), 0, upgradeString.length(),
            Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    builder.setTitle(titleBuilder);

    builder.setMessage(
            R.string.RedPhoneChooser_this_contact_also_uses_redphone_would_you_like_to_upgrade_to_a_secure_call);

    builder.setPositiveButton(R.string.RedPhoneChooser_secure_call, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(getActivity(), RedPhoneService.class);
            intent.setAction(RedPhoneService.ACTION_OUTGOING_CALL);
            intent.putExtra(Constants.REMOTE_NUMBER, number);
            getActivity().startService(intent);

            Intent activityIntent = new Intent();
            activityIntent.setClass(getActivity(), RedPhone.class);
            activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(activityIntent);

            getActivity().finish();
        }
    });

    builder.setNegativeButton(R.string.RedPhoneChooser_insecure_call, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            CallChooserCache.getInstance().addInsecureChoice(number);

            Intent intent = new Intent("android.intent.action.CALL",
                    Uri.fromParts("tel", number + CallListener.IGNORE_SUFFIX, null));
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            getActivity().finish();
        }
    });

    AlertDialog alert = builder.create();

    alert.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            ((AlertDialog) dialog).setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialogInterface) {
                    getActivity().finish();
                }
            });

            ((AlertDialog) dialog).setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialogInterface) {
                    getActivity().finish();
                }
            });
            Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);

            Button negativeButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE);
        }
    });

    return alert;
}

From source file:com.pax.pay.trans.action.activity.InputTransData2Activity.java

private void setEditText_date(EditText editText) {
    SpannableString ss = new SpannableString(getString(R.string.prompt_date_default2));
    AbsoluteSizeSpan ass = new AbsoluteSizeSpan(getResources().getDimensionPixelOffset(R.dimen.font_size_large),
            false);//  ww w  .  j a v  a 2 s  .c  o m
    ss.setSpan(ass, 0, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    editText.setHint(new SpannedString(ss)); // ??,?
    editText.setHintTextColor(getResources().getColor(R.color.textEdit_hint));
    editText.setInputType(InputType.TYPE_CLASS_NUMBER);
    editText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(4) });
}

From source file:com.heath_bar.tvdb.SeriesOverview.java

/** Populate the GUI with the episode information */
private void PopulateStuffPartTwo() {

    // Populate the next/last episodes
    TvEpisode last = episodeList.getLastAired();
    TvEpisode next = episodeList.getNextAired();

    SpannableString text = null;// w ww.  ja  va  2  s  .co m

    TextView richTextView = (TextView) findViewById(R.id.last_episode);

    if (last == null) {
        text = new SpannableString("Last Episode: unknown");
    } else {

        text = new SpannableString(
                "Last Episode: " + last.getName() + " (" + DateUtil.toString(last.getAirDate()) + ")");

        NonUnderlinedClickableSpan clickableSpan = new NonUnderlinedClickableSpan() {
            @Override
            public void onClick(View view) {
                episodeListener.onClick(view);
            }
        };
        int start = 14;
        int end = start + last.getName().length();
        text.setSpan(clickableSpan, start, end, 0);
        text.setSpan(new TextAppearanceSpan(this, R.style.episode_link), start, end, 0);
        text.setSpan(new AbsoluteSizeSpan((int) textSize, true), 0, text.length(), 0);
        richTextView.setId(last.getId());
        richTextView.setMovementMethod(LinkMovementMethod.getInstance());
    }
    richTextView.setText(text, BufferType.SPANNABLE);

    text = null;
    richTextView = (TextView) findViewById(R.id.next_episode);

    if (seriesInfo != null && seriesInfo.getStatus() != null && !seriesInfo.getStatus().equals("Ended")) {
        if (next == null) {
            text = new SpannableString("Next Episode: unknown");
        } else {

            text = new SpannableString(
                    "Next Episode: " + next.getName() + " (" + DateUtil.toString(next.getAirDate()) + ")");

            NonUnderlinedClickableSpan clickableSpan = new NonUnderlinedClickableSpan() {
                @Override
                public void onClick(View view) {
                    episodeListener.onClick(view);
                }
            };
            int start = 14;
            int end = start + next.getName().length();
            text.setSpan(clickableSpan, start, end, 0);
            text.setSpan(new TextAppearanceSpan(this, R.style.episode_link), start, end, 0);
            text.setSpan(new AbsoluteSizeSpan((int) textSize, true), 0, text.length(), 0);
            richTextView.setId(next.getId());
            richTextView.setMovementMethod(LinkMovementMethod.getInstance());
        }
        richTextView.setText(text, BufferType.SPANNABLE);
    }
}