Search in sources :

Example 11 with Editable

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

the class RecipientSelectView method onTouchEvent.

@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
    int action = event.getActionMasked();
    Editable text = getText();
    if (text != null && action == MotionEvent.ACTION_UP) {
        int offset = getOffsetForPosition(event.getX(), event.getY());
        if (offset != -1) {
            TokenImageSpan[] links = text.getSpans(offset, offset, RecipientTokenSpan.class);
            if (links.length > 0) {
                showAlternates(links[0].getToken());
                return true;
            }
        }
    }
    return super.onTouchEvent(event);
}
Also used : Editable(android.text.Editable) SuppressLint(android.annotation.SuppressLint)

Example 12 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 13 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)

Example 14 with Editable

use of android.text.Editable in project FlexibleAdapter by davideas.

the class EditItemDialog method onCreateDialog.

@SuppressLint({ "InflateParams", "HandlerLeak" })
@Override
public AlertDialog onCreateDialog(Bundle savedInstanceState) {
    //Pick up bundle parameters
    Bundle bundle;
    if (savedInstanceState == null) {
        bundle = getArguments();
    } else {
        bundle = savedInstanceState;
    }
    mTitle = bundle.getString(ARG_TITLE);
    mPosition = bundle.getInt(ARG_ITEM_POSITION);
    //Inflate custom view
    View dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_edit_item, null);
    final EditText editText = (EditText) dialogView.findViewById(R.id.text_edit_title);
    //, R.style.AppTheme_AlertDialog);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.dialog_edit_title).setView(dialogView).setNegativeButton(R.string.CANCEL, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            Utils.hideSoftInputFrom(getActivity(), editText);
            dialog.dismiss();
        }
    }).setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            getListener().onTitleModified(mPosition, editText.getText().toString().trim());
            Utils.hideSoftInputFrom(getActivity(), editText);
            dialog.dismiss();
        }
    });
    final AlertDialog editDialog = builder.create();
    editDialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {
            updateOkButtonState(editDialog, null);
        }
    });
    if (mTitle != null) {
        editText.setText(mTitle);
        editText.selectAll();
    }
    editText.requestFocus();
    editText.addTextChangedListener(new SimpleTextWatcher() {

        private static final long DELAY = 400L;

        private static final int TRIGGER = 1;

        private Handler mHandler = new Handler() {

            @Override
            public void handleMessage(Message msg) {
                if (msg.what == TRIGGER) {
                    updateOkButtonState(editDialog, editText);
                }
            }
        };

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

        @Override
        public void afterTextChanged(Editable s) {
            mHandler.removeMessages(TRIGGER);
            mHandler.sendEmptyMessageDelayed(TRIGGER, DELAY);
        }
    });
    editDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return editDialog;
}
Also used : EditText(android.widget.EditText) AlertDialog(android.support.v7.app.AlertDialog) Message(android.os.Message) DialogInterface(android.content.DialogInterface) Bundle(android.os.Bundle) Handler(android.os.Handler) View(android.view.View) SuppressLint(android.annotation.SuppressLint) SimpleTextWatcher(eu.davidea.common.SimpleTextWatcher) Editable(android.text.Editable) SuppressLint(android.annotation.SuppressLint)

Example 15 with Editable

use of android.text.Editable in project philm by chrisbanes.

the class FloatLabelLayout method setEditText.

private void setEditText(EditText editText) {
    // If we already have an EditText, throw an exception
    if (mEditText != null) {
        throw new IllegalArgumentException("We already have an EditText, can only have one");
    }
    mEditText = editText;
    // Update the label visibility with no animation
    updateLabelVisibility(false);
    // Add a TextWatcher so that we know when the text input has changed
    mEditText.addTextChangedListener(new TextWatcher() {

        @Override
        public void afterTextChanged(Editable s) {
            updateLabelVisibility(true);
        }

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

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });
    // Add focus listener to the EditText so that we can notify the label that it is activated.
    // Allows the use of a ColorStateList for the text color on the label
    mEditText.setOnFocusChangeListener(new OnFocusChangeListener() {

        @Override
        public void onFocusChange(View view, boolean focused) {
            updateLabelVisibility(true);
        }
    });
    // If we do not have a valid hint, try and retrieve it from the EditText
    if (TextUtils.isEmpty(mHint)) {
        setHint(mEditText.getHint());
    }
}
Also used : TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) View(android.view.View)

Aggregations

Editable (android.text.Editable)881 TextWatcher (android.text.TextWatcher)414 View (android.view.View)293 TextView (android.widget.TextView)217 EditText (android.widget.EditText)144 Paint (android.graphics.Paint)102 ImageView (android.widget.ImageView)94 Intent (android.content.Intent)81 AdapterView (android.widget.AdapterView)81 KeyEvent (android.view.KeyEvent)74 TextPaint (android.text.TextPaint)69 InputMethodManager (android.view.inputmethod.InputMethodManager)64 ListView (android.widget.ListView)64 DialogInterface (android.content.DialogInterface)57 SuppressLint (android.annotation.SuppressLint)56 Spannable (android.text.Spannable)51 AlertDialog (android.app.AlertDialog)46 RecyclerView (android.support.v7.widget.RecyclerView)45 ArrayList (java.util.ArrayList)43 Button (android.widget.Button)41