Search in sources :

Example 71 with Editable

use of android.text.Editable in project Talon-for-Twitter by klinker24.

the class UserAutoCompleteHelper method on.

private void on(final EditText textView) {
    userAutoComplete.setAnchorView(textView);
    textView.addTextChangedListener(new TextWatcher() {

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

        @Override
        public void afterTextChanged(Editable editable) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            String tvText = textView.getText().toString();
            try {
                int position = textView.getSelectionStart() - 1;
                if (tvText.charAt(position) == '@') {
                    userAutoComplete.show();
                } else if (!tvText.contains("@")) {
                    userAutoComplete.dismiss();
                } else if (userAutoComplete.isShowing()) {
                    String searchText = "";
                    do {
                        searchText = tvText.charAt(position--) + searchText;
                    } while (tvText.charAt(position) != '@');
                    searchText = searchText.replace("@", "");
                    search(searchText);
                }
            } catch (Exception e) {
                e.printStackTrace();
                userAutoComplete.dismiss();
            }
        }
    });
    userAutoComplete.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            userAutoComplete.dismiss();
            autoCompleter.completeTweet(textView, users.get(i).getScreenName(), '@');
            if (callback != null) {
                callback.onUserSelected(users.get(i));
            }
        }
    });
}
Also used : TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) AdapterView(android.widget.AdapterView) View(android.view.View) AdapterView(android.widget.AdapterView) Point(android.graphics.Point)

Example 72 with Editable

use of android.text.Editable in project KJFrameForAndroid by kymjs.

the class TweetRecordFragment method initWidget.

@Override
protected void initWidget(View view) {
    super.initWidget(view);
    RelativeLayout.LayoutParams params = (LayoutParams) mBtnRecort.getLayoutParams();
    params.width = DensityUtils.getScreenW(getActivity());
    params.height = (int) (DensityUtils.getScreenH(getActivity()) * 0.4);
    mBtnRecort.setLayoutParams(params);
    mBtnRecort.setOnFinishedRecordListener(new OnFinishedRecordListener() {

        @Override
        public void onFinishedRecord(String audioPath, int recordTime) {
            mLayout.setVisibility(View.VISIBLE);
            if (recordTime < 10) {
                mTvTime.setText("0" + recordTime + "\"");
            } else {
                mTvTime.setText(recordTime + "\"");
            }
            mImgAdd.setVisibility(View.GONE);
            filePath = null;
        }

        @Override
        public void onCancleRecord() {
            mLayout.setVisibility(View.GONE);
        }
    });
    drawable = (AnimationDrawable) mImgVolume.getBackground();
    mBtnRecort.getAudioUtil().setOnPlayListener(new OnPlayListener() {

        @Override
        public void stopPlay() {
            drawable.stop();
            mImgVolume.setBackgroundDrawable(drawable.getFrame(0));
        }

        @Override
        public void starPlay() {
            mImgVolume.setBackgroundDrawable(drawable);
            drawable.start();
        }
    });
    mEtSpeech.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (s.length() > MAX_LEN) {
                mTvInputLen.setText("已达到最大长度");
            } else {
                mTvInputLen.setText("你还可以输入" + (MAX_LEN - s.length()) + "个字");
            }
        }

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

        @Override
        public void afterTextChanged(Editable s) {
            if (s.length() > MAX_LEN) {
                mEtSpeech.setText(s.subSequence(0, MAX_LEN));
                CharSequence text = mEtSpeech.getText();
                if (text instanceof Spannable) {
                    Selection.setSelection((Spannable) text, MAX_LEN);
                }
            }
        }
    });
}
Also used : LayoutParams(android.widget.RelativeLayout.LayoutParams) OnFinishedRecordListener(org.kymjs.blog.ui.widget.RecordButton.OnFinishedRecordListener) OnPlayListener(org.kymjs.blog.ui.widget.RecordButtonUtil.OnPlayListener) RelativeLayout(android.widget.RelativeLayout) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) LayoutParams(android.widget.RelativeLayout.LayoutParams) Spannable(android.text.Spannable)

Example 73 with Editable

use of android.text.Editable 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 74 with Editable

use of android.text.Editable in project Signal-Android by WhisperSystems.

the class PassphraseChangeActivity method verifyAndSavePassphrases.

private void verifyAndSavePassphrases() {
    Editable originalText = this.originalPassphrase.getText();
    Editable newText = this.newPassphrase.getText();
    Editable repeatText = this.repeatPassphrase.getText();
    String original = (originalText == null ? "" : originalText.toString());
    String passphrase = (newText == null ? "" : newText.toString());
    String passphraseRepeat = (repeatText == null ? "" : repeatText.toString());
    if (TextSecurePreferences.isPasswordDisabled(this)) {
        original = MasterSecretUtil.UNENCRYPTED_PASSPHRASE;
    }
    if (!passphrase.equals(passphraseRepeat)) {
        this.newPassphrase.setText("");
        this.repeatPassphrase.setText("");
        this.newPassphrase.setError(getString(R.string.PassphraseChangeActivity_passphrases_dont_match_exclamation));
        this.newPassphrase.requestFocus();
    } else if (passphrase.equals("")) {
        this.newPassphrase.setError(getString(R.string.PassphraseChangeActivity_enter_new_passphrase_exclamation));
        this.newPassphrase.requestFocus();
    } else {
        new ChangePassphraseTask(this).execute(original, passphrase);
    }
}
Also used : Editable(android.text.Editable)

Example 75 with Editable

use of android.text.Editable in project Signal-Android by WhisperSystems.

the class PassphrasePromptActivity method handlePassphrase.

private void handlePassphrase() {
    try {
        Editable text = passphraseText.getText();
        String passphrase = (text == null ? "" : text.toString());
        MasterSecret masterSecret = MasterSecretUtil.getMasterSecret(this, passphrase);
        setMasterSecret(masterSecret);
    } catch (InvalidPassphraseException ipe) {
        passphraseText.setText("");
        passphraseText.setError(getString(R.string.PassphrasePromptActivity_invalid_passphrase_exclamation));
    }
}
Also used : MasterSecret(org.thoughtcrime.securesms.crypto.MasterSecret) InvalidPassphraseException(org.thoughtcrime.securesms.crypto.InvalidPassphraseException) Editable(android.text.Editable) SpannableString(android.text.SpannableString)

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