Search in sources :

Example 31 with TextWatcher

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

the class AccountSetupNames method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.account_setup_names);
    mDescription = (EditText) findViewById(R.id.account_description);
    mName = (EditText) findViewById(R.id.account_name);
    mDoneButton = (Button) findViewById(R.id.done);
    mDoneButton.setOnClickListener(this);
    TextWatcher validationTextWatcher = new TextWatcher() {

        public void afterTextChanged(Editable s) {
            validateFields();
        }

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

        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    };
    mName.addTextChangedListener(validationTextWatcher);
    mName.setKeyListener(TextKeyListener.getInstance(false, Capitalize.WORDS));
    String accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT);
    mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
    // mDescription.setText(mAccount.getDescription());
    if (mAccount.getName() != null) {
        mName.setText(mAccount.getName());
    }
    if (!Utility.requiredFieldValid(mName)) {
        mDoneButton.setEnabled(false);
    }
}
Also used : TextWatcher(android.text.TextWatcher) Editable(android.text.Editable)

Example 32 with TextWatcher

use of android.text.TextWatcher in project LuaViewSDK by alibaba.

the class UDEditText method setCallback.

/**
     * 设置EditText代理
     * BeginEditing --开始编辑
     * EndEditing -- 结束编辑
     * Clear -- 删除
     * Return --返回
     *
     * @return
     */
public UDEditText setCallback(final LuaValue callback) {
    this.mCallback = callback;
    final EditText view = getView();
    if (view != null) {
        if (this.mCallback != null && this.mCallback.istable()) {
            view.addTextChangedListener(new TextWatcher() {

                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                    if (mCallback != null && mCallback.istable()) {
                        LuaUtil.callFunction(LuaUtil.getFunction(mCallback, "BeginEditing", "beginEditing"));
                    }
                }

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

                @Override
                public void afterTextChanged(Editable s) {
                    if (mCallback != null && mCallback.istable()) {
                        LuaUtil.callFunction(LuaUtil.getFunction(mCallback, "EndEditing", "endEditing"));
                    }
                }
            });
        }
    }
    return this;
}
Also used : EditText(android.widget.EditText) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable)

Example 33 with TextWatcher

use of android.text.TextWatcher in project Notes by MiCode.

the class NotesListActivity method showCreateOrModifyFolderDialog.

private void showCreateOrModifyFolderDialog(final boolean create) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null);
    final EditText etName = (EditText) view.findViewById(R.id.et_foler_name);
    showSoftInput();
    if (!create) {
        if (mFocusNoteDataItem != null) {
            etName.setText(mFocusNoteDataItem.getSnippet());
            builder.setTitle(getString(R.string.menu_folder_change_name));
        } else {
            Log.e(TAG, "The long click data item is null");
            return;
        }
    } else {
        etName.setText("");
        builder.setTitle(this.getString(R.string.menu_create_folder));
    }
    builder.setPositiveButton(android.R.string.ok, null);
    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            hideSoftInput(etName);
        }
    });
    final Dialog dialog = builder.setView(view).show();
    final Button positive = (Button) dialog.findViewById(android.R.id.button1);
    positive.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            hideSoftInput(etName);
            String name = etName.getText().toString();
            if (DataUtils.checkVisibleFolderName(mContentResolver, name)) {
                Toast.makeText(NotesListActivity.this, getString(R.string.folder_exist, name), Toast.LENGTH_LONG).show();
                etName.setSelection(0, etName.length());
                return;
            }
            if (!create) {
                if (!TextUtils.isEmpty(name)) {
                    ContentValues values = new ContentValues();
                    values.put(NoteColumns.SNIPPET, name);
                    values.put(NoteColumns.TYPE, Notes.TYPE_FOLDER);
                    values.put(NoteColumns.LOCAL_MODIFIED, 1);
                    mContentResolver.update(Notes.CONTENT_NOTE_URI, values, NoteColumns.ID + "=?", new String[] { String.valueOf(mFocusNoteDataItem.getId()) });
                }
            } else if (!TextUtils.isEmpty(name)) {
                ContentValues values = new ContentValues();
                values.put(NoteColumns.SNIPPET, name);
                values.put(NoteColumns.TYPE, Notes.TYPE_FOLDER);
                mContentResolver.insert(Notes.CONTENT_NOTE_URI, values);
            }
            dialog.dismiss();
        }
    });
    if (TextUtils.isEmpty(etName.getText())) {
        positive.setEnabled(false);
    }
    /**
         * When the name edit text is null, disable the positive button
         */
    etName.addTextChangedListener(new TextWatcher() {

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        // TODO Auto-generated method stub
        }

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (TextUtils.isEmpty(etName.getText())) {
                positive.setEnabled(false);
            } else {
                positive.setEnabled(true);
            }
        }

        public void afterTextChanged(Editable s) {
        // TODO Auto-generated method stub
        }
    });
}
Also used : AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText) ContentValues(android.content.ContentValues) DialogInterface(android.content.DialogInterface) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) Button(android.widget.Button) AlertDialog(android.app.AlertDialog) Dialog(android.app.Dialog) OnClickListener(android.view.View.OnClickListener) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable)

Example 34 with TextWatcher

use of android.text.TextWatcher in project MaterialSearchView by MiguelCatalan.

the class MaterialSearchView method initSearchView.

private void initSearchView() {
    mSearchSrcTextView.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            onSubmitQuery();
            return true;
        }
    });
    mSearchSrcTextView.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) {
            mUserQuery = s;
            startFilter(s);
            MaterialSearchView.this.onTextChanged(s);
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    mSearchSrcTextView.setOnFocusChangeListener(new OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                showKeyboard(mSearchSrcTextView);
                showSuggestions();
            }
        }
    });
}
Also used : KeyEvent(android.view.KeyEvent) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 35 with TextWatcher

use of android.text.TextWatcher in project actor-platform by actorapp.

the class InputBarFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View res = inflater.inflate(R.layout.fragment_inputbar, container, false);
    res.setBackgroundColor(style.getMainBackgroundColor());
    //
    // Message Body
    //
    messageEditText = (BarEditText) res.findViewById(R.id.et_message);
    messageEditText.setTextColor(style.getTextPrimaryColor());
    messageEditText.setHintTextColor(style.getTextHintColor());
    // Hardware keyboard events
    messageEditText.setOnKeyListener((view, keycode, keyEvent) -> {
        if (messenger().isSendByEnterEnabled()) {
            if (keyEvent.getAction() == KeyEvent.ACTION_DOWN && keycode == KeyEvent.KEYCODE_ENTER) {
                onSendButtonPressed();
                return true;
            }
        }
        return false;
    });
    // Software keyboard events
    messageEditText.setOnEditorActionListener((textView, i, keyEvent) -> {
        if (i == EditorInfo.IME_ACTION_SEND) {
            onSendButtonPressed();
            return true;
        }
        if (i == EditorInfo.IME_ACTION_DONE) {
            onSendButtonPressed();
            return true;
        }
        if (messenger().isSendByEnterEnabled()) {
            if (keyEvent != null && i == EditorInfo.IME_NULL && keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
                onSendButtonPressed();
                return true;
            }
        }
        return false;
    });
    messageEditText.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            onBeforeTextChanged(charSequence, i, i1, i2);
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            InputBarFragment.this.onTextChanged(charSequence, i, i1, i2);
        }

        @Override
        public void afterTextChanged(Editable editable) {
            onAfterTextChanged(editable);
        }
    });
    messageEditText.addSelectionListener((start, length) -> {
        InputBarFragment.this.onSelectionChanged(start, length);
    });
    messageEditText.setOnFocusChangeListener((v, hasFocus) -> {
        Fragment parent = getParentFragment();
        if (parent instanceof InputBarCallback) {
            ((InputBarCallback) parent).onTextFocusChanged(hasFocus);
        }
    });
    //
    // Send Button
    //
    sendButton = (TintImageView) res.findViewById(R.id.ib_send);
    sendButton.setResource(R.drawable.conv_send);
    sendButton.setOnClickListener(v -> {
        onSendButtonPressed();
    });
    //
    // Attach Button
    //
    attachButton = (ImageButton) res.findViewById(R.id.ib_attach);
    attachButton.setOnClickListener(v -> {
        onAttachButtonClicked();
    });
    //
    // Emoji keyboard
    //
    emojiButton = (ImageView) res.findViewById(R.id.ib_emoji);
    emojiButton.setOnClickListener(v -> emojiKeyboard.toggle());
    emojiKeyboard = getEmojiKeyboard();
    emojiKeyboard.setOnStickerClickListener(sticker -> {
        Fragment parent = getParentFragment();
        if (parent instanceof InputBarCallback) {
            ((InputBarCallback) parent).onStickerSent(sticker);
        }
    });
    emojiKeyboard.setKeyboardStatusListener(new KeyboardStatusListener() {

        @Override
        public void onDismiss() {
            emojiButton.setImageResource(R.drawable.ic_emoji);
        }

        @Override
        public void onShow() {
            emojiButton.setImageResource(R.drawable.ic_keyboard);
        }
    });
    //
    // Audio
    //
    audioContainer = res.findViewById(R.id.audioContainer);
    audioTimer = (TextView) res.findViewById(R.id.audioTimer);
    audioSlide = res.findViewById(R.id.audioSlide);
    recordPoint = res.findViewById(R.id.record_point);
    audioButton = (ImageView) res.findViewById(R.id.record_btn);
    audioButton.setVisibility(View.VISIBLE);
    audioButton.setOnTouchListener((v, event) -> {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            if (!isAudioVisible) {
                showAudio();
                slideStart = (int) event.getX();
            }
        } else if (event.getAction() == MotionEvent.ACTION_UP) {
            if (isAudioVisible) {
                hideAudio(false);
            }
        } else if (event.getAction() == MotionEvent.ACTION_MOVE) {
            if (isAudioVisible) {
                int slide = slideStart - (int) event.getX();
                if (slide < 0) {
                    slide = 0;
                }
                if (slide > SLIDE_LIMIT) {
                    hideAudio(true);
                } else {
                    slideAudio(slide);
                }
            }
        }
        return true;
    });
    return res;
}
Also used : TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) KeyboardStatusListener(im.actor.sdk.view.emoji.keyboard.KeyboardStatusListener) TintImageView(im.actor.sdk.view.TintImageView) ImageView(android.widget.ImageView) ViewUtils.zoomInView(im.actor.sdk.util.ViewUtils.zoomInView) View(android.view.View) ViewUtils.zoomOutView(im.actor.sdk.util.ViewUtils.zoomOutView) TextView(android.widget.TextView) BaseFragment(im.actor.sdk.controllers.BaseFragment) Fragment(android.support.v4.app.Fragment) MessagesDefaultFragment(im.actor.sdk.controllers.conversation.messages.MessagesDefaultFragment) MessagesFragment(im.actor.sdk.controllers.conversation.messages.MessagesFragment) Nullable(android.support.annotation.Nullable)

Aggregations

TextWatcher (android.text.TextWatcher)192 Editable (android.text.Editable)158 View (android.view.View)96 TextView (android.widget.TextView)75 Paint (android.graphics.Paint)37 ImageView (android.widget.ImageView)30 TextPaint (android.text.TextPaint)28 EditText (android.widget.EditText)28 Intent (android.content.Intent)25 KeyEvent (android.view.KeyEvent)24 AdapterView (android.widget.AdapterView)21 ListView (android.widget.ListView)17 RecyclerView (android.support.v7.widget.RecyclerView)15 DialogInterface (android.content.DialogInterface)13 SuppressLint (android.annotation.SuppressLint)12 OnClickListener (android.view.View.OnClickListener)12 Button (android.widget.Button)12 InputMethodManager (android.view.inputmethod.InputMethodManager)11 AlertDialog (android.app.AlertDialog)10 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)9