List of usage examples for android.telephony PhoneNumberFormattingTextWatcher PhoneNumberFormattingTextWatcher
public PhoneNumberFormattingTextWatcher()
From source file:com.example.android.oauthTesting_slidingTabBasic.SlidingTabsBasicFragment.java
/** * This is called after the {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)} has finished. * Here we can pick out the {@link View}s we need to configure from the content view. * * We set the {@link ViewPager}'s adapter to be an instance of {@link SamplePagerAdapter}. The * {@link SlidingTabLayout} is then given the {@link ViewPager} so that it can populate itself. * * @param view View created in {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)} */// ww w.j a v a2 s . c o m @Override public void onViewCreated(View view, Bundle savedInstanceState) { // BEGIN_INCLUDE (setup_viewpager) // Get the ViewPager and set it's PagerAdapter so that it can display items mViewPager = (ViewPager) view.findViewById(R.id.viewpager); //mViewPager.setAdapter(new SimpleViewPagerAdapter(this.getChildFragmentManager())); mViewPager.setAdapter(new SimpleViewPagerAdapter(this.getChildFragmentManager())); // END_INCLUDE (setup_viewpager) // BEGIN_INCLUDE (setup_slidingtablayout) // Give the SlidingTabLayout the ViewPager, this must be done AFTER the ViewPager has had // it's PagerAdapter set. mSlidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tabs); mSlidingTabLayout.setViewPager(mViewPager); final EditText recipient_phone = (EditText) view.findViewById(R.id.recipient_phone); recipient_phone.addTextChangedListener(new PhoneNumberFormattingTextWatcher()); final Button send_sms = (Button) view.findViewById(R.id.send_sms); send_sms.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String number = recipient_phone.getText().toString(); String s = PhoneNumberUtils.stripSeparators(recipient_phone.getText().toString()); String q = PhoneNumberUtils.formatNumber(s, "US"); String r = q; } // END_INCLUDE (setup_slidingtablayout) }); //----FACEBOOK OAUTH TRIAL STUFF----// callbackManager = CallbackManager.Factory.create(); loginButton = (LoginButton) view.findViewById(R.id.login_button); loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { int a = 5; int b = a; } @Override public void onCancel() { } @Override public void onError(FacebookException e) { } }); // END_INCLUDE (fragment_onviewcreated) GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail().build(); mGoogleApiClient = new GoogleApiClient.Builder(getActivity()) .enableAutoManage(getActivity() /* FragmentActivity */, this /* OnConnectionFailedListener */) .addApi(Auth.GOOGLE_SIGN_IN_API, gso).build(); SignInButton signInButton = (SignInButton) view.findViewById(R.id.sign_in_button); signInButton.setOnClickListener(this); }
From source file:com.abcvoipsip.ui.dialpad.DialerFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDualPane = getResources().getBoolean(R.bool.use_dual_panes); digitFormater = new PhoneNumberFormattingTextWatcher(); setHasOptionsMenu(true);/*w w w . ja v a 2 s. co m*/ }
From source file:com.fututel.ui.dialpad.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); }/*from w w w. j a va 2 s. co m*/ setHasOptionsMenu(true); prefs = getActivity().getSharedPreferences("global", Context.MODE_PRIVATE); }
From source file:org.chromium.chrome.browser.payments.ui.EditorView.java
/** * Builds the editor view.//from ww w .j a va 2 s . com * * @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); // Sets transparent background for animating content view. getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); 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(); }
From source file:com.csipsimple.ui.dialpad.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); }/*from w ww . j av a 2 s .c o m*/ setHasOptionsMenu(true); }
From source file:com.sonetel.ui.dialpad.ContactFragment.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); // This implies isDigit = false;//prefsWrapper.startIsDigit(); setHasOptionsMenu(true);/*from w ww .ja v a 2 s . com*/ // updateRegistrations(); }
From source file:com.sonetel.ui.dialpad.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 = true;//!prefsWrapper.getPreferenceBooleanValue(SipConfigManager.START_WITH_TEXT_DIALER); // }// w ww. ja v a 2s . c o m setHasOptionsMenu(true); // updateRegistrations(); }
From source file:edu.cens.loci.ui.widget.GenericEditorView.java
/** * Prepare this editor using the given {@link DataKind} for defining * structure and {@link ValuesDelta} describing the content to edit. *///from w ww.j a va 2 s .c o m public void setValues(DataKind kind, ValuesDelta entry, EntityDelta state, boolean readOnly, ViewIdGenerator vig) { mKind = kind; mEntry = entry; mState = state; mReadOnly = readOnly; mViewIdGenerator = vig; setId(vig.getId(state, kind, entry, ViewIdGenerator.NO_VIEW_INDEX)); final boolean enabled = !readOnly; //Log.d(TAG, "setValues: kind=" + mKind.mimeType); if (!entry.isVisible()) { // Hide ourselves entirely if deleted setVisibility(View.GONE); return; } else { setVisibility(View.VISIBLE); } // Display label selector if multiple types available final boolean hasTypes = EntityModifier.hasEditTypes(kind); mLabel.setVisibility(hasTypes ? View.VISIBLE : View.GONE); mLabel.setEnabled(enabled); if (hasTypes) { mType = EntityModifier.getCurrentType(entry, kind); rebuildLabel(); } // Build out set of fields mFields.removeAllViews(); boolean hidePossible = false; int n = 0; if (mKind.mimeType.equals(WifiFingerprint.CONTENT_ITEM_TYPE)) { //Log.d(TAG, "setValues: Wifi"); for (EditField field : kind.fieldList) { Button fieldView = (Button) mInflater.inflate(RES_WIFI_FIELD, mFields, false); mWifiFieldButtonId = vig.getId(state, kind, entry, n++); fieldView.setId(mWifiFieldButtonId); final String column = field.column; final String value = entry.getAsString(column); fieldView.setText("Fingerprint on " + MyDateUtils.getAbrv_MMM_d_h_m(new Long(value))); final String extra1column = field.extra1; final String extra1value = entry.getAsString(extra1column); try { mWifiFingerprint = new LociWifiFingerprint(extra1value); mWifiFingerprintTimeStamp = MyDateUtils.getDateFormatLong(new Long(value)); } catch (JSONException e) { MyLog.e(LociConfig.D.JSON, TAG, "LociWifiFingerprint parsing failed"); e.printStackTrace(); } // Hide field when empty and optional value final boolean couldHide = (field.optional); final boolean willHide = (mHideOptional && couldHide); fieldView.setVisibility(willHide ? View.GONE : View.VISIBLE); fieldView.setEnabled(enabled); hidePossible = hidePossible || couldHide; fieldView.setOnClickListener(this); mFields.addView(fieldView); } } else if (mKind.mimeType.equals(Keyword.CONTENT_ITEM_TYPE)) { //Log.d(TAG, "setValues: Keywords"); for (EditField field : kind.fieldList) { AutoCompleteTextView fieldView = (AutoCompleteTextView) mInflater.inflate(RES_AUTOCOMPLETE_FIELD, mFields, false); fieldView.setId(vig.getId(state, kind, entry, n++)); if (field.titleRes > 0) { fieldView.setHint(field.titleRes); } int inputType = field.inputType; fieldView.setInputType(inputType); fieldView.setMinLines(field.minLines); // Read current value from state final String column = field.column; final String value = entry.getAsString(column); fieldView.setText(value); // Prepare listener for writing changes fieldView.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { // Trigger event for newly changed value onFieldChanged(column, s.toString()); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); // Hide field when empty and optional value final boolean couldHide = (field.optional); final boolean willHide = (mHideOptional && couldHide); fieldView.setVisibility(willHide ? View.GONE : View.VISIBLE); fieldView.setEnabled(enabled); hidePossible = hidePossible || couldHide; String[] usedKeywords = getResources().getStringArray(R.array.keyword_default); LociDbUtils myDb = new LociDbUtils(getContext()); ArrayList<String> suggestedKeywords = myDb.getSavedKeywords(); HashSet<String> suggestedKeywordsSet = new HashSet<String>(); for (String keyword : suggestedKeywords) { suggestedKeywordsSet.add(keyword); } //Log.d(TAG, "size of usedKeywords : " + usedKeywords.length); //Log.d(TAG, "size of suggestedKeywords : " + suggestedKeywords.size()); for (String usedKeyword : usedKeywords) { if (!suggestedKeywordsSet.contains(usedKeyword)) suggestedKeywords.add(usedKeyword); } //Log.d(TAG, "size of suggestedKeywords : " + suggestedKeywords.size()); Collections.sort(suggestedKeywords); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this.getContext(), R.layout.item_suggestion_list, suggestedKeywords); fieldView.setAdapter(adapter); fieldView.setThreshold(0); mFields.addView(fieldView); } } else { //Log.d(TAG, "General Types..."); for (EditField field : kind.fieldList) { // Inflate field from definition EditText fieldView = (EditText) mInflater.inflate(RES_FIELD, mFields, false); fieldView.setId(vig.getId(state, kind, entry, n++)); if (field.titleRes > 0) { fieldView.setHint(field.titleRes); } int inputType = field.inputType; fieldView.setInputType(inputType); if (inputType == InputType.TYPE_CLASS_PHONE) { fieldView.addTextChangedListener(new PhoneNumberFormattingTextWatcher()); } fieldView.setMinLines(field.minLines); // Read current value from state final String column = field.column; final String value = entry.getAsString(column); fieldView.setText(value); //Log.d(TAG, "setValues: column=" + column); //Log.d(TAG, "setValues: value=" + value); // Prepare listener for writing changes fieldView.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { // Trigger event for newly changed value onFieldChanged(column, s.toString()); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); // Hide field when empty and optional value final boolean couldHide = (field.optional); final boolean willHide = (mHideOptional && couldHide); fieldView.setVisibility(willHide ? View.GONE : View.VISIBLE); fieldView.setEnabled(enabled); hidePossible = hidePossible || couldHide; mFields.addView(fieldView); } } // When hiding fields, place expandable if (hidePossible) { mMore.setVisibility(mHideOptional ? View.VISIBLE : View.GONE); mLess.setVisibility(mHideOptional ? View.GONE : View.VISIBLE); } else { mMore.setVisibility(View.GONE); mLess.setVisibility(View.GONE); } mMore.setEnabled(enabled); mLess.setEnabled(enabled); }