Java 类android.telephony.PhoneNumberFormattingTextWatcher 实例源码

项目:Fitness-Buddy-Group-Project    文件:LoginActivity.java   
private void setupViews(){
    etName = (EditText) findViewById(R.id.etLoginName);
    etPhoneNumber = (EditText) findViewById(R.id.etLoginPhoneNumber);
    etPhoneNumber.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
    bLogin = (Button) findViewById(R.id.bLogin);
    bLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Create a new user and signup
            String verifyCode = Utils.generateRandomCode();

            // Send SMS with verify code starts here
            SmsManager smsManager = SmsManager.getDefault();
            String smsMessage = verifyCode + " " + Constants.VERIFICATION_SMS_TEXT;
            smsManager.sendTextMessage(etPhoneNumber.getText().toString(), null, smsMessage, null, null);
            // Send SMS with verify code ends here

            Intent intent = new Intent(LoginActivity.this, PhoneNoVerificationActivity.class);
            intent.putExtra("etName", etName.getText().toString());
            intent.putExtra("etPhoneNumber", etPhoneNumber.getText().toString());
            intent.putExtra("verifyCode", verifyCode);
            Log.v("verifyCode", "verifyCode-=============================== " + verifyCode);
            startActivityForResult(intent, 30);
        }
    });
}
项目:sms_DualCard    文件:PhoneNumberFormatter.java   
@Override
protected void onPostExecute(PhoneNumberFormattingTextWatcher watcher) {
    if (watcher == null || isCancelled()) {
        return; // May happen if we cancel the task.
    }
    // Setting a text changed listener is safe even after the view is detached.
    mTextView.addTextChangedListener(watcher);

    // Note changes the user made before onPostExecute() will not be formatted, but
    // once they type the next letter we format the entire text, so it's not a big deal.
    // (And loading PhoneNumberFormattingTextWatcher is usually fast enough.)
    // We could use watcher.afterTextChanged(mTextView.getEditableText()) to force format
    // the existing content here, but that could cause unwanted results.
    // (e.g. the contact editor thinks the user changed the content, and would save
    // when closed even when the user didn't make other changes.)
}
项目:silent-contacts-android    文件:PhoneNumberFormatter.java   
@Override
protected void onPostExecute(PhoneNumberFormattingTextWatcher watcher) {
    if (watcher == null || isCancelled()) {
        return; // May happen if we cancel the task.
    }
    // Setting a text changed listener is safe even after the view is detached.
    mTextView.addTextChangedListener(watcher);

    // Note changes the user made before onPostExecute() will not be formatted, but
    // once they type the next letter we format the entire text, so it's not a big deal.
    // (And loading PhoneNumberFormattingTextWatcher is usually fast enough.)
    // We could use watcher.afterTextChanged(mTextView.getEditableText()) to force format
    // the existing content here, but that could cause unwanted results.
    // (e.g. the contact editor thinks the user changed the content, and would save
    // when closed even when the user didn't make other changes.)
}
项目:android-aosp-mms    文件:PhoneNumberFormatter.java   
@Override
protected void onPostExecute(PhoneNumberFormattingTextWatcher watcher) {
    if (watcher == null || isCancelled()) {
        return; // May happen if we cancel the task.
    }
    // Setting a text changed listener is safe even after the view is detached.
    mTextView.addTextChangedListener(watcher);

    // Note changes the user made before onPostExecute() will not be formatted, but
    // once they type the next letter we format the entire text, so it's not a big deal.
    // (And loading PhoneNumberFormattingTextWatcher is usually fast enough.)
    // We could use watcher.afterTextChanged(mTextView.getEditableText()) to force format
    // the existing content here, but that could cause unwanted results.
    // (e.g. the contact editor thinks the user changed the content, and would save
    // when closed even when the user didn't make other changes.)
}
项目:CSipSimple    文件:DialerFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mDualPane = getResources().getBoolean(R.bool.use_dual_panes);
    digitFormater = new PhoneNumberFormattingTextWatcher();
    // Auto complete list in case of text
    autoCompleteAdapter = new ContactsSearchAdapter(getActivity());
    autoCompleteListItemListener = new OnAutoCompleteListItemClicked(autoCompleteAdapter);

    if(isDigit == null) {
        isDigit = !prefsWrapper.getPreferenceBooleanValue(SipConfigManager.START_WITH_TEXT_DIALER);
    }

    setHasOptionsMenu(true);
}
项目:Touch-Control    文件:AdditionalActionView.java   
private void init() {
    LayoutInflater.from(getContext()).inflate(R.layout.row_actiondata_view, this);
    mReadLayout = (ViewGroup) findViewById(R.id.read_layout);
    mHeader = (TextView) findViewById(android.R.id.text1);
    mSubtitle = (TextView) findViewById(android.R.id.text2);
    mIcon = (ImageView) findViewById(android.R.id.icon);

    mEditLayout = (EditText) findViewById(R.id.edit_layout);
    mEditLayout.addTextChangedListener(new PhoneNumberFormattingTextWatcher());


    mReadLayout.setVisibility(View.GONE);
    mEditLayout.setVisibility(View.GONE);

}
项目:android-card-form    文件:MobileNumberEditText.java   
private void init() {
    if (isInEditMode()) {
        return;
    }

    setInputType(InputType.TYPE_CLASS_PHONE);
    InputFilter[] filters = { new LengthFilter(14) };
    setFilters(filters);
    addTextChangedListener(new PhoneNumberFormattingTextWatcher());
}
项目:SUREwalk_android    文件:InfoFragment.java   
private void initializeTextAttributes() {

        et_name.setNextFocusDownId(R.id.et_eid);
        et_eid.setNextFocusDownId(R.id.et_phone);
        et_phone.setNextFocusDownId(R.id.et_email);

        et_name.setText(mPrefsHandler.getName());
        et_eid.setText(mPrefsHandler.getUTEID());
        et_phone.setText(mPrefsHandler.getPhoneNumber());
        et_email.setText(mPrefsHandler.getEmail());

        setUpTextListener(et_name);
        setUpTextListener(et_eid);
        et_phone.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
        setUpTextListener(et_phone);
        setUpTextListener(et_email);

        et_email.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_GO) {
                    getSherlockActivity().findViewById(R.id.next_button).performClick();
                    return true;
                }
                return false;
            }
        });
    }
项目:SUREwalk_android    文件:SettingsActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);

    mNamePattern = Pattern.compile("[\\p{L}- ]+");
    mEidPattern = Pattern.compile("^[A-Za-z]+[0-9]+$");
    mPhonePattern = Pattern.compile("(\\+[0-9]+[\\- \\.]*)?"
            + "(\\([0-9]+\\)[\\- \\.]*)?"
            + "([0-9][0-9\\- \\.][0-9\\- \\.]+[0-9])");
    mEmailPattern = Pattern.compile("[a-zA-Z0-9\\+\\._%\\-\\+]{1,256}" +
            "@" +
            "[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}" +
            "(" +
            "\\." +
            "[a-zA-Z0-9][a-zA-Z0-9\\-]{0,25}" +
            ")+");

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    EditTextPreference uteid = (EditTextPreference) findPreference("uteid");
    uteid.setSummary(((EditTextPreference) findPreference("uteid")).getText());
    uteid.setOnPreferenceChangeListener(this);

    EditTextPreference name = (EditTextPreference) findPreference("name");
    name.setSummary(((EditTextPreference) findPreference("name")).getText());
    name.setOnPreferenceChangeListener(this);

    EditTextPreference phone = (EditTextPreference) findPreference("phone");
    phone.getEditText().addTextChangedListener(new PhoneNumberFormattingTextWatcher());
    phone.setSummary(((EditTextPreference) findPreference("phone")).getText());
    phone.setOnPreferenceChangeListener(this);

    EditTextPreference email = (EditTextPreference) findPreference("email");
    email.setSummary(((EditTextPreference) findPreference("email")).getText());
    email.setOnPreferenceChangeListener(this);
}
项目:chromium-for-android-56-debug-video    文件:EditorView.java   
/**
 * Builds the editor view.
 *
 * @param activity        The activity on top of which the UI should be displayed.
 * @param observerForTest Optional event observer for testing.
 */
public EditorView(Activity activity, PaymentRequestObserverForTest observerForTest) {
    super(activity, R.style.FullscreenWhite);
    mContext = activity;
    mObserverForTest = observerForTest;
    mHandler = new Handler();
    mEditorActionListener = new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                mDoneButton.performClick();
                return true;
            } else if (actionId == EditorInfo.IME_ACTION_NEXT) {
                View next = v.focusSearch(View.FOCUS_FORWARD);
                if (next != null) {
                    next.requestFocus();
                    return true;
                }
            }
            return false;
        }
    };

    mHalfRowMargin = activity.getResources().getDimensionPixelSize(
            R.dimen.payments_section_large_spacing);
    mFieldViews = new ArrayList<>();
    mEditableTextFields = new ArrayList<>();
    mDropdownFields = new ArrayList<>();

    final Pattern cardNumberPattern = Pattern.compile("^[\\d- ]*$");
    mCardNumberInputFilter = new InputFilter() {
        @Override
        public CharSequence filter(
                CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
            // Accept deletions.
            if (start == end) return null;

            // Accept digits, "-", and spaces.
            if (cardNumberPattern.matcher(source.subSequence(start, end)).matches()) {
                return null;
            }

            // Reject everything else.
            return "";
        }
    };

    mCardNumberFormatter = new CreditCardNumberFormattingTextWatcher();
    new AsyncTask<Void, Void, PhoneNumberFormattingTextWatcher>() {
        @Override
        protected PhoneNumberFormattingTextWatcher doInBackground(Void... unused) {
            return new PhoneNumberFormattingTextWatcher();
        }

        @Override
        protected void onPostExecute(PhoneNumberFormattingTextWatcher result) {
            mPhoneFormatter = result;
            if (mPhoneInput != null) {
                mPhoneInput.addTextChangedListener(mPhoneFormatter);
            }
        }
    }.execute();
}
项目:AndroidChromium    文件:EditorView.java   
/**
 * Builds the editor view.
 *
 * @param activity        The activity on top of which the UI should be displayed.
 * @param observerForTest Optional event observer for testing.
 */
public EditorView(Activity activity, PaymentRequestObserverForTest observerForTest) {
    super(activity, R.style.FullscreenWhite);
    mContext = activity;
    mObserverForTest = observerForTest;
    mHandler = new Handler();
    mEditorActionListener = new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                mDoneButton.performClick();
                return true;
            } else if (actionId == EditorInfo.IME_ACTION_NEXT) {
                View next = v.focusSearch(View.FOCUS_FORWARD);
                if (next != null) {
                    next.requestFocus();
                    return true;
                }
            }
            return false;
        }
    };

    mHalfRowMargin = activity.getResources().getDimensionPixelSize(
            R.dimen.payments_section_large_spacing);
    mFieldViews = new ArrayList<>();
    mEditableTextFields = new ArrayList<>();
    mDropdownFields = new ArrayList<>();

    final Pattern cardNumberPattern = Pattern.compile("^[\\d- ]*$");
    mCardNumberInputFilter = new InputFilter() {
        @Override
        public CharSequence filter(
                CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
            // Accept deletions.
            if (start == end) return null;

            // Accept digits, "-", and spaces.
            if (cardNumberPattern.matcher(source.subSequence(start, end)).matches()) {
                return null;
            }

            // Reject everything else.
            return "";
        }
    };

    mCardNumberFormatter = new CreditCardNumberFormattingTextWatcher();
    new AsyncTask<Void, Void, PhoneNumberFormattingTextWatcher>() {
        @Override
        protected PhoneNumberFormattingTextWatcher doInBackground(Void... unused) {
            return new PhoneNumberFormattingTextWatcher();
        }

        @Override
        protected void onPostExecute(PhoneNumberFormattingTextWatcher result) {
            mPhoneFormatter = result;
            if (mPhoneInput != null) {
                mPhoneInput.addTextChangedListener(mPhoneFormatter);
            }
        }
    }.execute();
}
项目:sms_DualCard    文件:PhoneNumberFormatter.java   
@Override
protected PhoneNumberFormattingTextWatcher doInBackground(Void... params) {
    return new PhoneNumberFormattingTextWatcher(mCountryCode);
}
项目:silent-contacts-android    文件:PhoneNumberFormatter.java   
@Override
protected PhoneNumberFormattingTextWatcher doInBackground(Void... params) {
    return new PhoneNumberFormattingTextWatcher();
}
项目:android-aosp-mms    文件:PhoneNumberFormatter.java   
@Override
protected PhoneNumberFormattingTextWatcher doInBackground(Void... params) {
    return new PhoneNumberFormattingTextWatcher(mCountryCode);
}