Search in sources :

Example 6 with BulletSpan

use of android.text.style.BulletSpan in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ClearDefaultsPreference method updateUI.

public boolean updateUI(PreferenceViewHolder view) {
    boolean hasBindAppWidgetPermission = mAppWidgetManager.hasBindAppWidgetPermission(mAppEntry.info.packageName);
    TextView autoLaunchView = (TextView) view.findViewById(R.id.auto_launch);
    boolean autoLaunchEnabled = AppUtils.hasPreferredActivities(mPm, mPackageName) || isDefaultBrowser(mPackageName) || AppUtils.hasUsbDefaults(mUsbManager, mPackageName);
    if (!autoLaunchEnabled && !hasBindAppWidgetPermission) {
        resetLaunchDefaultsUi(autoLaunchView);
    } else {
        boolean useBullets = hasBindAppWidgetPermission && autoLaunchEnabled;
        if (hasBindAppWidgetPermission) {
            autoLaunchView.setText(R.string.auto_launch_label_generic);
        } else {
            autoLaunchView.setText(R.string.auto_launch_label);
        }
        Context context = getContext();
        CharSequence text = null;
        int bulletIndent = context.getResources().getDimensionPixelSize(R.dimen.installed_app_details_bullet_offset);
        if (autoLaunchEnabled) {
            CharSequence autoLaunchEnableText = context.getText(R.string.auto_launch_enable_text);
            SpannableString s = new SpannableString(autoLaunchEnableText);
            if (useBullets) {
                s.setSpan(new BulletSpan(bulletIndent), 0, autoLaunchEnableText.length(), 0);
            }
            text = (text == null) ? TextUtils.concat(s, "\n") : TextUtils.concat(text, "\n", s, "\n");
        }
        if (hasBindAppWidgetPermission) {
            CharSequence alwaysAllowBindAppWidgetsText = context.getText(R.string.always_allow_bind_appwidgets_text);
            SpannableString s = new SpannableString(alwaysAllowBindAppWidgetsText);
            if (useBullets) {
                s.setSpan(new BulletSpan(bulletIndent), 0, alwaysAllowBindAppWidgetsText.length(), 0);
            }
            text = (text == null) ? TextUtils.concat(s, "\n") : TextUtils.concat(text, "\n", s, "\n");
        }
        autoLaunchView.setText(text);
        mActivitiesButton.setEnabled(true);
    }
    return true;
}
Also used : Context(android.content.Context) SpannableString(android.text.SpannableString) BulletSpan(android.text.style.BulletSpan) TextView(android.widget.TextView)

Example 7 with BulletSpan

use of android.text.style.BulletSpan in project android_frameworks_base by DirtyUnicorns.

the class HtmlToSpannedConverter method endLi.

private static void endLi(Editable text) {
    endCssStyle(text);
    endBlockElement(text);
    end(text, Bullet.class, new BulletSpan());
}
Also used : BulletSpan(android.text.style.BulletSpan)

Example 8 with BulletSpan

use of android.text.style.BulletSpan in project android_frameworks_base by crdroidandroid.

the class HtmlToSpannedConverter method endLi.

private static void endLi(Editable text) {
    endCssStyle(text);
    endBlockElement(text);
    end(text, Bullet.class, new BulletSpan());
}
Also used : BulletSpan(android.text.style.BulletSpan)

Example 9 with BulletSpan

use of android.text.style.BulletSpan in project BBS-Android by bdpqchen.

the class HtmlTagHandler method handleTag.

@Override
public void handleTag(final boolean opening, final String tag, Editable output, final XMLReader xmlReader) {
    if (opening) {
        // opening tag
        if (HtmlTextView.DEBUG) {
            Log.d(HtmlTextView.TAG, "opening, output: " + output.toString());
        }
        if (tag.equalsIgnoreCase(UNORDERED_LIST)) {
            lists.push(tag);
        } else if (tag.equalsIgnoreCase(ORDERED_LIST)) {
            lists.push(tag);
            olNextIndex.push(1);
        } else if (tag.equalsIgnoreCase(LIST_ITEM)) {
            if (output.length() > 0 && output.charAt(output.length() - 1) != '\n') {
                output.append("\n");
            }
            if (!lists.isEmpty()) {
                String parentList = lists.peek();
                if (parentList.equalsIgnoreCase(ORDERED_LIST)) {
                    start(output, new Ol());
                    olNextIndex.push(olNextIndex.pop() + 1);
                } else if (parentList.equalsIgnoreCase(UNORDERED_LIST)) {
                    start(output, new Ul());
                }
            }
        } else if (tag.equalsIgnoreCase("code")) {
            start(output, new Code());
        } else if (tag.equalsIgnoreCase("center")) {
            start(output, new Center());
        } else if (tag.equalsIgnoreCase("s") || tag.equalsIgnoreCase("strike")) {
            start(output, new Strike());
        } else if (tag.equalsIgnoreCase("table")) {
            start(output, new Table());
            if (tableTagLevel == 0) {
                tableHtmlBuilder = new StringBuilder();
                // We need some text for the table to be replaced by the span because
                // the other tags will remove their text when their text is extracted
                output.append("table placeholder");
            }
            tableTagLevel++;
        } else if (tag.equalsIgnoreCase("tr")) {
            start(output, new Tr());
        } else if (tag.equalsIgnoreCase("th")) {
            start(output, new Th());
        } else if (tag.equalsIgnoreCase("td")) {
            start(output, new Td());
        }
    } else {
        // closing tag
        if (HtmlTextView.DEBUG) {
            Log.d(HtmlTextView.TAG, "closing, output: " + output.toString());
        }
        if (tag.equalsIgnoreCase(UNORDERED_LIST)) {
            lists.pop();
        } else if (tag.equalsIgnoreCase(ORDERED_LIST)) {
            lists.pop();
            olNextIndex.pop();
        } else if (tag.equalsIgnoreCase(LIST_ITEM)) {
            if (!lists.isEmpty()) {
                if (lists.peek().equalsIgnoreCase(UNORDERED_LIST)) {
                    if (output.length() > 0 && output.charAt(output.length() - 1) != '\n') {
                        output.append("\n");
                    }
                    // Nested BulletSpans increases distance between bullet and text, so we must prevent it.
                    int bulletMargin = indent;
                    if (lists.size() > 1) {
                        bulletMargin = indent - bullet.getLeadingMargin(true);
                        if (lists.size() > 2) {
                            // This get's more complicated when we add a LeadingMarginSpan into the same line:
                            // we have also counter it's effect to BulletSpan
                            bulletMargin -= (lists.size() - 2) * listItemIndent;
                        }
                    }
                    BulletSpan newBullet = new BulletSpan(bulletMargin);
                    end(output, Ul.class, false, new LeadingMarginSpan.Standard(listItemIndent * (lists.size() - 1)), newBullet);
                } else if (lists.peek().equalsIgnoreCase(ORDERED_LIST)) {
                    if (output.length() > 0 && output.charAt(output.length() - 1) != '\n') {
                        output.append("\n");
                    }
                    int numberMargin = listItemIndent * (lists.size() - 1);
                    if (lists.size() > 2) {
                        // Same as in ordered lists: counter the effect of nested Spans
                        numberMargin -= (lists.size() - 2) * listItemIndent;
                    }
                    NumberSpan numberSpan = new NumberSpan(mTextPaint, olNextIndex.lastElement() - 1);
                    end(output, Ol.class, false, new LeadingMarginSpan.Standard(numberMargin), numberSpan);
                }
            }
        } else if (tag.equalsIgnoreCase("code")) {
            end(output, Code.class, false, new TypefaceSpan("monospace"));
        } else if (tag.equalsIgnoreCase("center")) {
            end(output, Center.class, true, new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER));
        } else if (tag.equalsIgnoreCase("s") || tag.equalsIgnoreCase("strike")) {
            end(output, Strike.class, false, new StrikethroughSpan());
        } else if (tag.equalsIgnoreCase("table")) {
            tableTagLevel--;
            // When we're back at the root-level table
            if (tableTagLevel == 0) {
                final String tableHtml = tableHtmlBuilder.toString();
                ClickableTableSpan myClickableTableSpan = null;
                if (clickableTableSpan != null) {
                    myClickableTableSpan = clickableTableSpan.newInstance();
                    myClickableTableSpan.setTableHtml(tableHtml);
                }
                DrawTableLinkSpan myDrawTableLinkSpan = null;
                if (drawTableLinkSpan != null) {
                    myDrawTableLinkSpan = drawTableLinkSpan.newInstance();
                }
                end(output, Table.class, false, myDrawTableLinkSpan, myClickableTableSpan);
            } else {
                end(output, Table.class, false);
            }
        } else if (tag.equalsIgnoreCase("tr")) {
            end(output, Tr.class, false);
        } else if (tag.equalsIgnoreCase("th")) {
            end(output, Th.class, false);
        } else if (tag.equalsIgnoreCase("td")) {
            end(output, Td.class, false);
        }
    }
    storeTableTags(opening, tag);
}
Also used : AlignmentSpan(android.text.style.AlignmentSpan) TextPaint(android.text.TextPaint) BulletSpan(android.text.style.BulletSpan) LeadingMarginSpan(android.text.style.LeadingMarginSpan) TypefaceSpan(android.text.style.TypefaceSpan) StrikethroughSpan(android.text.style.StrikethroughSpan)

Example 10 with BulletSpan

use of android.text.style.BulletSpan in project android_frameworks_base by AOSPA.

the class HtmlToSpannedConverter method endLi.

private static void endLi(Editable text) {
    endCssStyle(text);
    endBlockElement(text);
    end(text, Bullet.class, new BulletSpan());
}
Also used : BulletSpan(android.text.style.BulletSpan)

Aggregations

BulletSpan (android.text.style.BulletSpan)17 ParagraphStyle (android.text.style.ParagraphStyle)5 LeadingMarginSpan (android.text.style.LeadingMarginSpan)2 StrikethroughSpan (android.text.style.StrikethroughSpan)2 Context (android.content.Context)1 SpannableString (android.text.SpannableString)1 TextPaint (android.text.TextPaint)1 AlignmentSpan (android.text.style.AlignmentSpan)1 QuoteSpan (android.text.style.QuoteSpan)1 TypefaceSpan (android.text.style.TypefaceSpan)1 URLSpan (android.text.style.URLSpan)1 TextView (android.widget.TextView)1