Example usage for android.graphics Typeface ITALIC

List of usage examples for android.graphics Typeface ITALIC

Introduction

In this page you can find the example usage for android.graphics Typeface ITALIC.

Prototype

int ITALIC

To view the source code for android.graphics Typeface ITALIC.

Click Source Link

Usage

From source file:com.zulip.android.util.CustomHtmlToSpannedConverter.java

private void handleEndTag(String tag) {
    if (tag.equalsIgnoreCase("br")) {
        handleBr(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("p")) {
        handleP(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("div")) {
        handleP(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("strong")) {
        end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } else if (tag.equalsIgnoreCase("b")) {
        end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } else if (tag.equalsIgnoreCase("em")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("cite")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("dfn")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("i")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("big")) {
        end(mSpannableStringBuilder, Big.class, new RelativeSizeSpan(1.25f));
    } else if (tag.equalsIgnoreCase("small")) {
        end(mSpannableStringBuilder, Small.class, new RelativeSizeSpan(0.8f));
    } else if (tag.equalsIgnoreCase("font")) {
        endFont(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("blockquote")) {
        handleP(mSpannableStringBuilder);
        end(mSpannableStringBuilder, Blockquote.class, new CustomQuoteSpan());
    } else if (tag.equalsIgnoreCase("tt")) {
        end(mSpannableStringBuilder, Monospace.class, new TypefaceSpan(MONOSPACE));
    } else if (tag.equalsIgnoreCase("a")) {
        endA(mSpannableStringBuilder);//from   www .  ja  v  a  2 s .  co m
    } else if (tag.equalsIgnoreCase("span")) {
        endSpan(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("u")) {
        end(mSpannableStringBuilder, Underline.class, new UnderlineSpan());
    } else if (tag.equalsIgnoreCase("sup")) {
        end(mSpannableStringBuilder, Super.class, new SuperscriptSpan());
    } else if (tag.equalsIgnoreCase("sub")) {
        end(mSpannableStringBuilder, Sub.class, new SubscriptSpan());
    } else if (tag.equalsIgnoreCase("code")) {
        endMultiple(mSpannableStringBuilder, InlineCode.class,
                new Object[] { new TypefaceSpan(MONOSPACE), new ForegroundColorSpan(0xffdd1144) // pink
                });
    } else if (tag.equalsIgnoreCase("pre")) {
        end(mSpannableStringBuilder, CodeBlock.class, new TypefaceSpan(MONOSPACE));
    } else if (tag.length() == 2 && Character.toLowerCase(tag.charAt(0)) == 'h' && tag.charAt(1) >= '1'
            && tag.charAt(1) <= '6') {
        handleP(mSpannableStringBuilder);
        endHeader(mSpannableStringBuilder);
    } else if (mTagHandler != null) {
        mTagHandler.handleTag(false, tag, mSpannableStringBuilder, mReader);
    }
}

From source file:mobisocial.musubi.objects.PictureObj.java

@Override
public void getSummaryText(Context context, TextView view, FeedSummary summary) {
    view.setTypeface(null, Typeface.ITALIC);

    JSONObject json = summary.getJson();
    if (json != null && json.optString(PictureObj.TEXT).length() > 0) {
        StringBuilder summaryText = new StringBuilder(50).append(summary.getSender())
                .append(" shared a picture with the caption \"" + json.optString(StatusObj.TEXT) + "\"");
        view.setText(summaryText.toString());
    } else {//from www .j  a va 2  s  . c  o  m
        StringBuilder summaryText = new StringBuilder(50).append(summary.getSender())
                .append(" shared a picture.");
        view.setText(summaryText.toString());
    }
}

From source file:org.odk.collect.android.widgets.QuestionWidget.java

private TextView createHelpText(FormEntryPrompt prompt) {
    TextView helpText = new TextView(getContext());
    String s = prompt.getHelpText();

    if (s != null && !s.equals("")) {
        helpText.setId(ViewIds.generateViewId());
        helpText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, questionFontsize - 3);
        //noinspection ResourceType
        helpText.setPadding(0, -5, 0, 7);
        // wrap to the widget of view
        helpText.setHorizontallyScrolling(false);
        helpText.setTypeface(null, Typeface.ITALIC);
        helpText.setText(TextUtils.textToHtml(s));
        helpText.setTextColor(ContextCompat.getColor(getContext(), R.color.primaryTextColor));
        helpText.setMovementMethod(LinkMovementMethod.getInstance());
        return helpText;
    } else {/*from   ww  w .  ja  va  2s.  c o m*/
        helpText.setVisibility(View.GONE);
        return helpText;
    }
}

From source file:org.rm3l.ddwrt.tiles.status.router.StatusRouterStateTile.java

/**
 * Called when a previously created loader has finished its load.  Note
 * that normally an application is <em>not</em> allowed to commit fragment
 * transactions while in this call, since it can happen after an
 * activity's state is saved.  See {@link android.support.v4.app.FragmentManager#beginTransaction()
 * FragmentManager.openTransaction()} for further discussion on this.
 * <p/>//from   w ww .  ja  va2  s  .co  m
 * <p>This function is guaranteed to be called prior to the release of
 * the last data that was supplied for this Loader.  At this point
 * you should remove all use of the old data (since it will be released
 * soon), but should not do your own release of the data since its Loader
 * owns it and will take care of that.  The Loader will take care of
 * management of its data so you don't have to.  In particular:
 * <p/>
 * <ul>
 * <li> <p>The Loader will monitor for changes to the data, and report
 * them to you through new calls here.  You should not monitor the
 * data yourself.  For example, if the data is a {@link android.database.Cursor}
 * and you place it in a {@link android.widget.CursorAdapter}, use
 * the {@link android.widget.CursorAdapter#CursorAdapter(android.content.Context,
 * android.database.Cursor, int)} constructor <em>without</em> passing
 * in either {@link android.widget.CursorAdapter#FLAG_AUTO_REQUERY}
 * or {@link android.widget.CursorAdapter#FLAG_REGISTER_CONTENT_OBSERVER}
 * (that is, use 0 for the flags argument).  This prevents the CursorAdapter
 * from doing its own observing of the Cursor, which is not needed since
 * when a change happens you will get a new Cursor throw another call
 * here.
 * <li> The Loader will release the data once it knows the application
 * is no longer using it.  For example, if the data is
 * a {@link android.database.Cursor} from a {@link android.content.CursorLoader},
 * you should not call close() on it yourself.  If the Cursor is being placed in a
 * {@link android.widget.CursorAdapter}, you should use the
 * {@link android.widget.CursorAdapter#swapCursor(android.database.Cursor)}
 * method so that the old Cursor is not closed.
 * </ul>
 *
 * @param loader The Loader that has finished.
 * @param data   The data generated by the Loader.
 */
@Override
public void onLoadFinished(@NotNull final Loader<NVRAMInfo> loader, @Nullable NVRAMInfo data) {
    //Set tiles
    Log.d(LOG_TAG, "onLoadFinished: loader=" + loader + " / data=" + data);

    layout.findViewById(R.id.tile_status_router_router_state_loading_view).setVisibility(View.GONE);
    layout.findViewById(R.id.tile_status_router_router_state_header_loading_view).setVisibility(View.GONE);
    layout.findViewById(R.id.tile_status_router_router_state_gridLayout).setVisibility(View.VISIBLE);
    layout.findViewById(R.id.tile_status_router_router_state_header_layout).setVisibility(View.VISIBLE);

    if (data == null) {
        data = new NVRAMInfo().setException(new DDWRTNoDataException("No Data!"));
    }

    @NotNull
    final TextView errorPlaceHolderView = (TextView) this.layout
            .findViewById(R.id.tile_status_router_router_state_error);

    @Nullable
    final Exception exception = data.getException();

    if (!(exception instanceof DDWRTTileAutoRefreshNotAllowedException)) {

        if (exception == null) {
            errorPlaceHolderView.setVisibility(View.GONE);
        }

        //Router Name
        @NotNull
        final TextView routerNameView = (TextView) this.layout
                .findViewById(R.id.tile_status_router_router_state_title);
        final String routerName = data.getProperty(NVRAMInfo.ROUTER_NAME);
        final boolean routerNameNull = (routerName == null);
        String routerNameToSet = routerName;
        if (routerNameNull) {
            routerNameToSet = "(empty)";
        }
        routerNameView.setTypeface(null, routerNameNull ? Typeface.ITALIC : Typeface.NORMAL);

        routerNameView.setText(routerNameToSet);

        //We can change the action bar title
        //        this.layout.getSupportActionBar().setTitle((String) data);

        //WAN IP
        @NotNull
        final TextView wanIpView = (TextView) this.layout
                .findViewById(R.id.tile_status_router_router_state_wan_ip);
        wanIpView.setText(data.getProperty(NVRAMInfo.WAN_IPADDR));

        @NotNull
        final TextView routerModelView = (TextView) this.layout
                .findViewById(R.id.tile_status_router_router_state_model);
        routerModelView.setText(data.getProperty(NVRAMInfo.MODEL, "-"));

        @NotNull
        final TextView lanIpView = (TextView) this.layout
                .findViewById(R.id.tile_status_router_router_state_lan_ip);
        lanIpView.setText(data.getProperty(NVRAMInfo.LAN_IPADDR, "-"));

        @NotNull
        final TextView fwView = (TextView) this.layout
                .findViewById(R.id.tile_status_router_router_state_firmware);
        fwView.setText(data.getProperty(NVRAMInfo.FIRMWARE, "-"));

        @NotNull
        final TextView kernelView = (TextView) this.layout
                .findViewById(R.id.tile_status_router_router_state_kernel);
        kernelView.setText(data.getProperty(NVRAMInfo.KERNEL, "-"));

        @NotNull
        final TextView uptimeView = (TextView) this.layout
                .findViewById(R.id.tile_status_router_router_state_uptime);
        uptimeView.setText(data.getProperty(NVRAMInfo.UPTIME, "-"));

    }

    if (exception != null && !(exception instanceof DDWRTTileAutoRefreshNotAllowedException)) {
        //noinspection ThrowableResultOfMethodCallIgnored
        final Throwable rootCause = Throwables.getRootCause(exception);
        errorPlaceHolderView.setText("Error: " + (rootCause != null ? rootCause.getMessage() : "null"));
        final Context parentContext = this.mParentFragmentActivity;
        errorPlaceHolderView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                //noinspection ThrowableResultOfMethodCallIgnored
                if (rootCause != null) {
                    Toast.makeText(parentContext, rootCause.getMessage(), Toast.LENGTH_LONG).show();
                }
            }
        });
        errorPlaceHolderView.setVisibility(View.VISIBLE);
    }

    doneWithLoaderInstance(this, loader, R.id.tile_status_router_router_state_togglebutton_title,
            R.id.tile_status_router_router_state_togglebutton_separator);

    Log.d(LOG_TAG, "onLoadFinished(): done loading!");

}

From source file:com.achep.acdisplay.ui.widgets.notification.NotificationActions.java

/**
 * Sets new actions.// w  w  w  . j a va  2s. co  m
 *
 * @param notification the host notification
 * @param actions      the actions to set
 */
public void setActions(@Nullable OpenNotification notification, @Nullable Action[] actions) {
    Check.getInstance().isInMainThread();

    mRemoteInputsMap.clear();
    mActionsMap.clear();
    hideRii();

    if (actions == null) {
        // Free actions' container.
        removeAllViews();
        return;
    } else {
        assert notification != null;
    }

    int count = actions.length;
    View[] views = new View[count];

    // Find available views.
    int childCount = getChildCount();
    int a = Math.min(childCount, count);
    for (int i = 0; i < a; i++) {
        views[i] = getChildAt(i);
    }

    // Remove redundant views.
    for (int i = childCount - 1; i >= count; i--) {
        removeViewAt(i);
    }

    LayoutInflater inflater = null;
    for (int i = 0; i < count; i++) {
        final Action action = actions[i];
        View root = views[i];

        if (root == null) {
            // Initialize layout inflater only when we really need it.
            if (inflater == null) {
                inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                assert inflater != null;
            }

            root = inflater.inflate(getActionLayoutResource(), this, false);
            root = onCreateActionView(root);
            // We need to keep all IDs unique to make
            // TransitionManager.beginDelayedTransition(viewGroup, null)
            // work correctly!
            root.setId(getChildCount() + 1);
            addView(root);
        }

        mActionsMap.put(root, action);

        int style = Typeface.NORMAL;
        root.setOnLongClickListener(null);
        if (action.intent != null) {
            root.setEnabled(true);
            root.setOnClickListener(mActionsOnClick);

            RemoteInput remoteInput = getRemoteInput(action);
            if (remoteInput != null) {
                mRemoteInputsMap.put(action, remoteInput);
                root.setOnLongClickListener(mActionsOnLongClick);

                // Highlight the action
                style = Typeface.ITALIC;
            }
        } else {
            root.setEnabled(false);
            root.setOnClickListener(null);
        }

        // Get message view and apply the content.
        TextView textView = root instanceof TextView ? (TextView) root
                : (TextView) root.findViewById(android.R.id.title);
        textView.setText(action.title);
        if (mTypeface == null)
            mTypeface = textView.getTypeface();
        textView.setTypeface(mTypeface, style);

        Drawable icon = NotificationUtils.getDrawable(getContext(), notification, action.icon);
        if (icon != null)
            icon = onCreateActionIcon(icon);

        if (Device.hasJellyBeanMR1Api()) {
            textView.setCompoundDrawablesRelative(icon, null, null, null);
        } else {
            textView.setCompoundDrawables(icon, null, null, null);
        }
    }
}

From source file:org.mozilla.gecko.home.HistoryPanel.java

/**
 * Make Span that is clickable, italicized, and underlined
 * between the string markers <code>FORMAT_S1</code> and
 * <code>FORMAT_S2</code>./*from  w  ww. ja v  a  2  s .  co  m*/
 *
 * @param text String to format
 * @return formatted SpannableStringBuilder, or null if there
 * is not any text to format.
 */
private SpannableStringBuilder formatHintText(String text) {
    // Set formatting as marked by string placeholders.
    final int underlineStart = text.indexOf(FORMAT_S1);
    final int underlineEnd = text.indexOf(FORMAT_S2);

    // Check that there is text to be formatted.
    if (underlineStart >= underlineEnd) {
        return null;
    }

    final SpannableStringBuilder ssb = new SpannableStringBuilder(text);

    // Set italicization.
    ssb.setSpan(new StyleSpan(Typeface.ITALIC), 0, ssb.length(), 0);

    // Set clickable text.
    final ClickableSpan clickableSpan = new ClickableSpan() {
        @Override
        public void onClick(View widget) {
            Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.HOMESCREEN,
                    "hint-private-browsing");
            try {
                final JSONObject json = new JSONObject();
                json.put("type", "Menu:Open");
                EventDispatcher.getInstance().dispatchEvent(json, null);
            } catch (JSONException e) {
                Log.e(LOGTAG, "Error forming JSON for Private Browsing contextual hint", e);
            }
        }
    };

    ssb.setSpan(clickableSpan, 0, text.length(), 0);

    // Remove underlining set by ClickableSpan.
    final UnderlineSpan noUnderlineSpan = new UnderlineSpan() {
        @Override
        public void updateDrawState(TextPaint textPaint) {
            textPaint.setUnderlineText(false);
        }
    };

    ssb.setSpan(noUnderlineSpan, 0, text.length(), 0);

    // Add underlining for "Private Browsing".
    ssb.setSpan(new UnderlineSpan(), underlineStart, underlineEnd, 0);

    ssb.delete(underlineEnd, underlineEnd + FORMAT_S2.length());
    ssb.delete(underlineStart, underlineStart + FORMAT_S1.length());

    return ssb;
}

From source file:uk.co.ashtonbrsc.intentexplode.Explode.java

/** textViewToIgnore is not updated so current selected char in that textview will not change */
private void showAllIntentData(TextView textViewToIgnore) {
    showTextViewIntentData(textViewToIgnore);

    categoriesLayout.removeAllViews();/*from  w  ww  .ja  va 2s  . c  o  m*/
    Set<String> categories = editableIntent.getCategories();
    StringBuilder stringBuilder = new StringBuilder();
    if (categories != null) {
        categoriesHeader.setVisibility(View.VISIBLE);
        stringBuilder.append(getResources().getString(R.string.categories));
        for (String category : categories) {
            stringBuilder.append(category).append(NEWLINE);
            TextView categoryTextView = new TextView(this);
            categoryTextView.setText(category);
            categoryTextView.setTextAppearance(this, R.style.TextFlags);
            categoriesLayout.addView(categoryTextView);
        }
    } else {
        categoriesHeader.setVisibility(View.GONE);
        // addTextToLayout("NONE", Typeface.NORMAL, categoriesLayout);
    }

    flagsLayout.removeAllViews();
    ArrayList<String> flagsStrings = getFlags();
    if (!flagsStrings.isEmpty()) {
        for (String thisFlagString : flagsStrings) {
            addTextToLayout(thisFlagString, Typeface.NORMAL, flagsLayout);
        }
    } else {
        addTextToLayout(getResources().getString(R.string.none), Typeface.NORMAL, flagsLayout);
    }

    extrasLayout.removeAllViews();
    try {
        Bundle intentBundle = editableIntent.getExtras();
        if (intentBundle != null) {
            Set<String> keySet = intentBundle.keySet();
            stringBuilder.append(getResources().getString(R.string.bundle_title_bold));
            int count = 0;

            for (String key : keySet) {
                count++;
                Object thisObject = intentBundle.get(key);
                addTextToLayout(getResources().getString(R.string.extra) + count, Typeface.BOLD, extrasLayout);
                String thisClass = thisObject.getClass().getName();
                if (thisClass != null) {
                    addTextToLayout(getResources().getString(R.string.class_text) + thisClass, Typeface.ITALIC,
                            STANDARD_INDENT_SIZE_IN_DIP, extrasLayout);
                }
                addTextToLayout(getResources().getString(R.string.key) + key, Typeface.ITALIC,
                        STANDARD_INDENT_SIZE_IN_DIP, extrasLayout);
                if (thisObject instanceof String || thisObject instanceof Long || thisObject instanceof Integer
                        || thisObject instanceof Boolean || thisObject instanceof Uri) {
                    addTextToLayout(getResources().getString(R.string.value) + thisObject.toString(),
                            Typeface.ITALIC, STANDARD_INDENT_SIZE_IN_DIP, extrasLayout);
                } else if (thisObject instanceof ArrayList) {
                    addTextToLayout(getResources().getString(R.string.values), Typeface.ITALIC, extrasLayout);
                    ArrayList thisArrayList = (ArrayList) thisObject;
                    for (Object thisArrayListObject : thisArrayList) {
                        addTextToLayout(thisArrayListObject.toString(), Typeface.ITALIC,
                                STANDARD_INDENT_SIZE_IN_DIP, extrasLayout);
                    }
                }
            }
        } else {
            addTextToLayout(getResources().getString(R.string.none), Typeface.NORMAL, extrasLayout);
        }
    } catch (Exception e) {
        // TODO Should make this red to highlight error
        addTextToLayout(getResources().getString(R.string.error_extracting_extras), Typeface.NORMAL,
                extrasLayout);
        e.printStackTrace();
    }

    // resolveInfo = pm.queryIntentServices(intent, 0);
    // stringBuilder.append("<br><b><u>" + resolveInfo.size()
    // + " services match this intent:</u></b><br>");
    // for (int i = 0; i < resolveInfo.size(); i++) {
    // ResolveInfo info = resolveInfo.get(i);
    // ActivityInfo activityinfo = info.activityInfo;
    // stringBuilder.append(activityinfo.packageName + "<br>");
    // }

    // intentDetailsHtml = stringBuilder.toString();
    // (((TextView) findViewById(R.id.text))).setText(intentDetailsHtml);
    refreshUI();
}

From source file:org.anoopam.main.anoopamaudio.AudioListActivity.java

@Override
public void manageAppBar(ActionBar actionBar, Toolbar toolbar, ActionBarDrawerToggle actionBarDrawerToggle) {

    actionBar.setDisplayHomeAsUpEnabled(true);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override/*w  ww  .  j a  v a2s . c  om*/
        public void onClick(View v) {

            handleBackPress();

        }
    });
    toolbar.setTitle(getString(R.string.nav_audio_title));
    SpannableString spannableString = new SpannableString(currentAlbumName);
    spannableString.setSpan(new StyleSpan(Typeface.ITALIC), 0, spannableString.length(), 0);
    toolbar.setSubtitle(spannableString);
}

From source file:org.appcelerator.titanium.util.TiUIHelper.java

public static int toTypefaceStyle(final String fontWeight, final String fontStyle) {
    int style = Typeface.NORMAL;

    if (fontWeight != null) {
        if (fontWeight.equals("bold")) {
            if (fontStyle != null && fontStyle.equals("italic")) {
                style = Typeface.BOLD_ITALIC;
            } else {
                style = Typeface.BOLD;//from  www  .  ja  v  a2  s .  c o  m
            }
        } else if (fontStyle != null && fontStyle.equals("italic")) {
            style = Typeface.ITALIC;
        }
    } else if (fontStyle != null && fontStyle.equals("italic")) {
        style = Typeface.ITALIC;
    }
    return style;
}

From source file:android.support.v7.widget.SwitchCompat.java

/**
 * Sets the typeface and style in which the text should be displayed on the
 * switch, and turns on the fake bold and italic bits in the Paint if the
 * Typeface that you provided does not have all the bits in the
 * style that you specified.// w  w  w  .  j a  va2  s .  c  om
 */
public void setSwitchTypeface(Typeface tf, int style) {
    if (style > 0) {
        if (tf == null) {
            tf = Typeface.defaultFromStyle(style);
        } else {
            tf = Typeface.create(tf, style);
        }

        setSwitchTypeface(tf);
        // now compute what (if any) algorithmic styling is needed
        int typefaceStyle = tf != null ? tf.getStyle() : 0;
        int need = style & ~typefaceStyle;
        mTextPaint.setFakeBoldText((need & Typeface.BOLD) != 0);
        mTextPaint.setTextSkewX((need & Typeface.ITALIC) != 0 ? -0.25f : 0);
    } else {
        mTextPaint.setFakeBoldText(false);
        mTextPaint.setTextSkewX(0);
        setSwitchTypeface(tf);
    }
}