Search in sources :

Example 91 with Editable

use of android.text.Editable in project k-9 by k9mail.

the class RecipientSelectView method getTokenViewForRecipient.

/**
     * Find the token view tied to a given recipient. This method relies on spans to
     * be of the RecipientTokenSpan class, as created by the buildSpanForObject method.
     */
private View getTokenViewForRecipient(Recipient currentRecipient) {
    Editable text = getText();
    if (text == null) {
        return null;
    }
    RecipientTokenSpan[] recipientSpans = text.getSpans(0, text.length(), RecipientTokenSpan.class);
    for (RecipientTokenSpan recipientSpan : recipientSpans) {
        if (recipientSpan.getToken().equals(currentRecipient)) {
            return recipientSpan.view;
        }
    }
    return null;
}
Also used : Editable(android.text.Editable)

Example 92 with Editable

use of android.text.Editable in project Jota-Text-Editor-old by jiro-aqua.

the class Main method sendDirectIntent.

private void sendDirectIntent(Intent intent) {
    if (intent == null) {
        return;
    } else {
        String substr = null;
        Editable text = mEditor.getText();
        int startsel = mEditor.getSelectionStart();
        int endsel = mEditor.getSelectionEnd();
        if (startsel != endsel) {
            if (endsel < startsel) {
                int temp = startsel;
                startsel = endsel;
                endsel = temp;
            }
            if (endsel - startsel > jp.sblo.pandora.jota.text.TextView.MAX_PARCELABLE) {
                Toast.makeText(Main.this, R.string.toast_overflow_of_limit, Toast.LENGTH_LONG).show();
                return;
            }
            substr = text.subSequence(startsel, endsel).toString();
        }
        if (intent.getAction().equals(Intent.ACTION_SEND)) {
            if (substr != null) {
                intent.putExtra(Intent.EXTRA_TEXT, substr);
            } else {
                if (text.length() <= jp.sblo.pandora.jota.text.TextView.MAX_PARCELABLE) {
                    intent.putExtra(Intent.EXTRA_TEXT, text.toString());
                } else {
                    Toast.makeText(Main.this, R.string.toast_overflow_of_limit, Toast.LENGTH_LONG).show();
                    return;
                }
            }
            try {
                startActivity(intent);
            } catch (ActivityNotFoundException e) {
            }
        } else if (intent.getAction().equals(Intent.ACTION_SEARCH)) {
            if (substr != null) {
                intent.putExtra(SearchManager.QUERY, substr);
            } else {
                return;
            }
            try {
                startActivity(intent);
            } catch (ActivityNotFoundException e) {
            }
        } else if (intent.getAction().equals("com.adamrocker.android.simeji.ACTION_INTERCEPT")) {
            if (substr != null) {
                intent.putExtra("replace_key", substr);
            } else {
                intent.putExtra("replace_key", "");
            }
            startActivityForResult(intent, REQUESTCODE_MUSHROOM);
        } else if (intent.getAction().equals(Intent.ACTION_VIEW)) {
            if (mInstanceState.filename != null || mEditor.isChanged()) {
                mProcViewByIntent.setIntent(intent);
                confirmSave(mProcViewByIntent);
            }
        }
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) Editable(android.text.Editable)

Example 93 with Editable

use of android.text.Editable in project Jota-Text-Editor-old by jiro-aqua.

the class WordCounter method count.

public static Result count(TextView textview) {
    Result result = new Result();
    Editable text = (Editable) textview.getText();
    result.charactrers = text.length();
    result.lines = textview.getLineCount();
    result.logicallines = countPatterns("\n", text);
    result.words = countPatterns("\\w+", text);
    return result;
}
Also used : Editable(android.text.Editable)

Example 94 with Editable

use of android.text.Editable in project Klyph by jonathangerbaud.

the class FriendPickerActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    singleChoice = getIntent().getBooleanExtra(KlyphBundleExtras.SINGLE_CHOICE, false);
    setTitle(singleChoice ? R.string.friend_picker_single_choice_title : R.string.friend_picker_title);
    setListAdapter(new MultiObjectAdapter(getListView(), singleChoice ? SpecialLayout.FRIEND_PICKER_SINGLE : SpecialLayout.FRIEND_PICKER));
    getListView().setItemsCanFocus(false);
    getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    searchText = (EditText) findViewById(R.id.search_text);
    searchText.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            filter(s.toString());
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    setRequestType(Query.ALL_FRIENDS);
    if (getIntent().hasExtra(KlyphBundleExtras.FRIEND_PICKER_IDS)) {
        ArrayList<String> ids = getIntent().getStringArrayListExtra(KlyphBundleExtras.FRIEND_PICKER_IDS);
        if (ids != null && ids.size() > 0) {
            initialIds = ids;
        }
    }
    if (FRIEND_LIST == null) {
        load();
    } else {
        // reset previously selected objects
        for (GraphObject graphObject : FRIEND_LIST) {
            graphObject.setSelected(false);
        }
        populate(FRIEND_LIST);
    }
}
Also used : MultiObjectAdapter(com.abewy.android.apps.klyph.adapter.MultiObjectAdapter) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 95 with Editable

use of android.text.Editable in project UltimateAndroid by cymcsg.

the class CalligraphyUtils method applyFontToTextView.

/**
     * Applies a Typeface to a TextView, its recommend you don't call this multiple times, as this
     * adds a TextWatcher.
     *
     * @param textView Not null, TextView or child of.
     * @param typeface Not null, Typeface to apply to the TextView.
     * @return true if applied otherwise false.
     */
public static boolean applyFontToTextView(final TextView textView, final Typeface typeface) {
    if (textView == null || typeface == null)
        return false;
    textView.setPaintFlags(textView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
    textView.setText(applyTypefaceSpan(textView.getText(), typeface), TextView.BufferType.SPANNABLE);
    textView.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            applyTypefaceSpan(s, typeface);
        }
    });
    return true;
}
Also used : TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) Paint(android.graphics.Paint)

Aggregations

Editable (android.text.Editable)511 TextWatcher (android.text.TextWatcher)158 View (android.view.View)117 TextView (android.widget.TextView)77 Paint (android.graphics.Paint)73 Spannable (android.text.Spannable)45 TextPaint (android.text.TextPaint)44 EditText (android.widget.EditText)39 KeyEvent (android.view.KeyEvent)34 InputMethodManager (android.view.inputmethod.InputMethodManager)33 Intent (android.content.Intent)30 ImageView (android.widget.ImageView)30 SpellCheckSpan (android.text.style.SpellCheckSpan)26 SuppressLint (android.annotation.SuppressLint)24 AdapterView (android.widget.AdapterView)23 Spanned (android.text.Spanned)22 SuggestionSpan (android.text.style.SuggestionSpan)21 ListView (android.widget.ListView)19 SpannableStringBuilder (android.text.SpannableStringBuilder)18 DialogInterface (android.content.DialogInterface)16