Example usage for android.view.inputmethod EditorInfo IME_ACTION_DONE

List of usage examples for android.view.inputmethod EditorInfo IME_ACTION_DONE

Introduction

In this page you can find the example usage for android.view.inputmethod EditorInfo IME_ACTION_DONE.

Prototype

int IME_ACTION_DONE

To view the source code for android.view.inputmethod EditorInfo IME_ACTION_DONE.

Click Source Link

Document

Bits of #IME_MASK_ACTION : the action key performs a "done" operation, typically meaning there is nothing more to input and the IME will be closed.

Usage

From source file:radoslav.yordanov.quizgames.controller.QuizChoiceFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View rootView = inflater.inflate(R.layout.fragment_quiz_choice, container, false);

    ImageView questionImg = (ImageView) rootView.findViewById(R.id.questionImg);
    imageLoader.displayImage(quizImage, questionImg, defaultOptions);

    Button selection1 = (Button) rootView.findViewById(R.id.selection1);
    Button selection2 = (Button) rootView.findViewById(R.id.selection2);
    Button selection3 = (Button) rootView.findViewById(R.id.selection3);
    Button selection4 = (Button) rootView.findViewById(R.id.selection4);
    Button[] selections = { selection1, selection2, selection3, selection4 };
    final EditText answer = (EditText) rootView.findViewById(R.id.answer);

    if (quizChoices.size() == 4) {
        for (int i = 0; i < 4; i++) {
            selections[i].setText(quizChoices.get(i).getChoice());
            selections[i].setTag(quizChoices.get(i).getIsRightChoice());
        }//from w w w. j ava 2  s  .c om
    } else {
        selection1.setVisibility(View.GONE);
        selection2.setVisibility(View.GONE);
        selection3.setVisibility(View.GONE);
        selection4.setVisibility(View.GONE);
        answer.setVisibility(View.VISIBLE);
        answer.setOnEditorActionListener(new EditText.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_DONE) {
                    ((QuizActivity) getActivity()).onSingleAnswerClick(quizChoices.get(0).getChoice(),
                            answer.getText().toString());
                    InputMethodManager imm = (InputMethodManager) getActivity()
                            .getSystemService(Context.INPUT_METHOD_SERVICE);
                    imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
                    return true;
                }
                return false;
            }
        });
    }

    return rootView;
}

From source file:org.appspot.apprtc.ConnectActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Get setting keys.
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    keyprefVideoCallEnabled = getString(R.string.pref_videocall_key);
    keyprefResolution = getString(R.string.pref_resolution_key);
    keyprefFps = getString(R.string.pref_fps_key);
    keyprefCaptureQualitySlider = getString(R.string.pref_capturequalityslider_key);
    keyprefVideoBitrateType = getString(R.string.pref_startvideobitrate_key);
    keyprefVideoBitrateValue = getString(R.string.pref_startvideobitratevalue_key);
    keyprefVideoCodec = getString(R.string.pref_videocodec_key);
    keyprefHwCodecAcceleration = getString(R.string.pref_hwcodec_key);
    keyprefAudioBitrateType = getString(R.string.pref_startaudiobitrate_key);
    keyprefAudioBitrateValue = getString(R.string.pref_startaudiobitratevalue_key);
    keyprefAudioCodec = getString(R.string.pref_audiocodec_key);
    keyprefNoAudioProcessingPipeline = getString(R.string.pref_noaudioprocessing_key);
    keyprefCpuUsageDetection = getString(R.string.pref_cpu_usage_detection_key);
    keyprefDisplayHud = getString(R.string.pref_displayhud_key);
    keyprefRoomServerUrl = getString(R.string.pref_room_server_url_key);
    keyprefRoom = getString(R.string.pref_room_key);
    keyprefRoomList = getString(R.string.pref_room_list_key);

    setContentView(R.layout.activity_connect);

    roomEditText = (EditText) findViewById(R.id.room_edittext);
    roomEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override//ww w  . j a v a  2  s  .co  m
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_DONE) {
                addRoomButton.performClick();
                return true;
            }
            return false;
        }
    });
    roomEditText.requestFocus();

    roomListView = (ListView) findViewById(R.id.room_listview);
    roomListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    addRoomButton = (ImageButton) findViewById(R.id.add_room_button);
    addRoomButton.setOnClickListener(addRoomListener);
    removeRoomButton = (ImageButton) findViewById(R.id.remove_room_button);
    removeRoomButton.setOnClickListener(removeRoomListener);
    connectButton = (ImageButton) findViewById(R.id.connect_button);
    connectButton.setOnClickListener(connectListener);
    connectLoopbackButton = (ImageButton) findViewById(R.id.connect_loopback_button);
    connectLoopbackButton.setOnClickListener(connectListener);

    // If an implicit VIEW intent is launching the app, go directly to that URL.
    final Intent intent = getIntent();
    if ("android.intent.action.VIEW".equals(intent.getAction()) && !commandLineRun) {
        commandLineRun = true;
        boolean loopback = intent.getBooleanExtra(CallActivity.EXTRA_LOOPBACK, false);
        int runTimeMs = intent.getIntExtra(CallActivity.EXTRA_RUNTIME, 0);
        String room = sharedPref.getString(keyprefRoom, "");
        roomEditText.setText(room);
        connectToRoom(loopback, runTimeMs);
        return;
    }
}

From source file:com.waz.zclient.newreg.fragments.OTREmailSignInFragment.java

@Override
public void onResume() {
    super.onResume();
    resetPasswordTextView.setOnClickListener(this);
    signInButton.setOnClickListener(this);
    guidedEditTextPassword.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override/*from w ww. j  a  va  2 s .c om*/
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                signIn();
                return true;
            } else {
                return false;
            }
        }
    });
    guidedEditTextEmail.getEditText().addTextChangedListener(this);
    guidedEditTextPassword.getEditText().addTextChangedListener(this);

    getControllerFactory().getGlobalLayoutController().setSoftInputModeForPage(Page.PHONE_REGISTRATION);
    KeyboardUtils.showKeyboard(getActivity());
}

From source file:kiv.janecekz.ma.ToneFragment.java

@Override
public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) {
    if (arg0.equals(input) && (arg1 == EditorInfo.IME_ACTION_DONE)) {
        boolean b = pl.setFreq(Float.parseFloat(((SpannableStringBuilder) arg0.getText()).toString()));
        if (!b) {
            arg0.setText(Float.toString(pl.getFreq()));
        } else {/*from  w  w  w  .  j a  va  2 s  . c om*/
            pl.togglePlay();
            // FIXME: What if only push the enter?
            if (actualFreqView != null) {
                actualFreqView.setTextColor(getView().getResources().getColor(R.color.blue));
                actualFreqView = null;
            }
        }
    }
    return true;
}

From source file:org.sufficientlysecure.keychain.ui.dialog.AddEmailDialogFragment.java

/**
 * Creates dialog/*from  w w w.ja v  a 2  s . co m*/
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Activity activity = getActivity();
    mMessenger = getArguments().getParcelable(ARG_MESSENGER);

    CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity);

    alert.setTitle(R.string.create_key_add_email);

    LayoutInflater inflater = activity.getLayoutInflater();
    View view = inflater.inflate(R.layout.add_email_dialog, null);
    alert.setView(view);

    mEmail = (EmailEditText) view.findViewById(R.id.add_email_address);

    alert.setPositiveButton(android.R.string.ok, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dismiss();

            // return new user id back to activity
            Bundle data = new Bundle();
            String email = mEmail.getText().toString();
            data.putString(MESSAGE_DATA_EMAIL, email);
            sendMessageToHandler(MESSAGE_OKAY, data);
        }
    });

    alert.setNegativeButton(android.R.string.cancel, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });

    // Hack to open keyboard.
    // This is the only method that I found to work across all Android versions
    // http://turbomanage.wordpress.com/2012/05/02/show-soft-keyboard-automatically-when-edittext-receives-focus/
    // Notes: * onCreateView can't be used because we want to add buttons to the dialog
    //        * opening in onActivityCreated does not work on Android 4.4
    mEmail.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            mEmail.post(new Runnable() {
                @Override
                public void run() {
                    if (getActivity() != null) {
                        InputMethodManager imm = (InputMethodManager) getActivity()
                                .getSystemService(Context.INPUT_METHOD_SERVICE);
                        imm.showSoftInput(mEmail, InputMethodManager.SHOW_IMPLICIT);
                    }
                }
            });
        }
    });
    mEmail.requestFocus();

    mEmail.setImeActionLabel(getString(android.R.string.ok), EditorInfo.IME_ACTION_DONE);
    mEmail.setOnEditorActionListener(this);

    return alert.show();
}

From source file:sean.dataexchange.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    test = new SurveyPointHandler("TestFile.txt", this.getApplicationContext());
    test.loadSurveyPoints();/*from   w ww.j a va 2s. c o  m*/

    if (savedInstanceState == null) {
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        BluetoothChatFragment fragment = new BluetoothChatFragment();
        transaction.replace(R.id.sample_content_fragment, fragment);
        transaction.commit();
    }

    flagnumber_before = 0;

    // -------------------------------------- Start Lat Long------------------------------------------------//
    // TURN OFF ONCE SURVEY BUTTON WORKS
    // Latitude and Longitude are stored to TextView files to be used in SurveyFileHandler
    // Use textLatitude and textLongitude
    initComponents();
    //---------------------------------------End Lat Long --------------------------------------------------//

    //---------------------------------------- Start Time/Day ----------------------------------------------//

    Calendar c = Calendar.getInstance();
    //int millisec = c.get(Calendar.MILLISECOND);
    //int seconds = c.get(Calendar.SECOND);
    //int minutes = c.get(Calendar.MINUTE);
    //int hours = c.get(Calendar.HOUR);
    //int day = c.get(Calendar.DAY_OF_MONTH);
    //int month = c.get(Calendar.MONTH);
    //int year = c.get(Calendar.YEAR);

    // Integer to String
    // Integer.toString(millisec)

    //----------------------------------------- End Time/Day -----------------------------------------------//

    //----------------------------------------- Start User Input-------------------------------------------//

    // The Name, Surveytype and Flagnumber are stored to TextView Files for use in the SurveyFileHandler
    // Use: textName, textSurveyType, and textFlagNumber

    EditText editTextName = (EditText) findViewById(R.id.editName);
    EditText editFlagNumber = (EditText) findViewById(R.id.editFlagNumber);
    final TextView textName = (TextView) findViewById(R.id.textName);
    final TextView textFlagNumber = (TextView) findViewById(R.id.textFlagNumber);

    editTextName.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {

            boolean handled = false;
            if (i == EditorInfo.IME_ACTION_DONE)

            {
                String inputText = textView.getText().toString();
                Toast.makeText(MainActivity.this, "Name: " + inputText, Toast.LENGTH_SHORT).show();
                InputMethodManager inputManager = (InputMethodManager) getSystemService(
                        Context.INPUT_METHOD_SERVICE);
                inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                        InputMethodManager.HIDE_NOT_ALWAYS);
                textName.setText(inputText);

                handled = true;
            }

            return handled;
        }
    });

    editFlagNumber.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {

            boolean handled = false;
            if (i == EditorInfo.IME_ACTION_DONE)

            {
                String inputText = textView.getText().toString();
                Toast.makeText(MainActivity.this, "Flag Number: " + inputText, Toast.LENGTH_SHORT).show();
                InputMethodManager inputManager = (InputMethodManager) getSystemService(
                        Context.INPUT_METHOD_SERVICE);
                inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                        InputMethodManager.HIDE_NOT_ALWAYS);

                textFlagNumber.setText(inputText);

                handled = true;
            }

            return handled;
        }
    });

    // -----------------------------------End User Input Work---------------------------------------------------------------//

    //------------------------------------Select Survey Type------------------------------------------------------------//

    method_spinner = (Spinner) findViewById(R.id.method_spinner);

    //------------------------------------Select Survey Type------------------------------------------------------------//

    //---------------------------------------Start Survey Data Point--------------------------------------------------//

    btnCollectSurveyPt = (Button) findViewById(R.id.btnGetSurveyPoint);

    btnCollectSurveyPt.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View arg0) {

            // Make Sure User Input Fields are completed
            if (!textFlagNumber.getText().toString().matches("\\d+") || textName.getText().toString() == "") {

                if (!textFlagNumber.getText().toString().matches("\\d+")) {
                    Toast.makeText(MainActivity.this, "Enter Numeric Flag", Toast.LENGTH_SHORT).show();
                } else if (textName.getText().toString() == "") {
                    Toast.makeText(MainActivity.this, "Enter Missing User Name", Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(MainActivity.this, "Enter Missing Survey Type", Toast.LENGTH_SHORT).show();
                }

            } else {

                // Collect User Input
                int flagnumber = Integer.parseInt(textFlagNumber.getText().toString());
                String user = textName.getText().toString();
                String method = String.valueOf(method_spinner.getSelectedItem());
                double latitude = 0.0;
                double longitude = 0.0;

                // Collect Lat/Long
                gps = new GPSTracker(MainActivity.this);
                if (gps.canGetLocation()) {
                    latitude = gps.getLatitude();
                    longitude = gps.getLongitude();
                    textLatitude.setText("\nLatitude: " + "" + latitude);
                    textLongitude.setText("\nLongitude: " + "" + longitude);
                } else {
                    gps.showSettingsAlert();
                }

                // Tell the User We have done something
                Toast.makeText(MainActivity.this,
                        method + " Point collected at Flag Number: " + textFlagNumber.getText().toString(),
                        Toast.LENGTH_SHORT).show();

                // USE SURVEY POINT HANDLER HERE
                test.recordSurveyPoint(latitude, longitude, flagnumber, user, method);

                // Set Flag Number to zero to make people enter next flag
                flagnumber_after = flagnumber;

                increment = flagnumber_after - flagnumber_before;
                textFlagNumber.setText(Integer.toString(flagnumber + increment));
                flagnumber_before = flagnumber_after;

            }
        }
    });

    //---------------------------------------Start Survey Data Point----------------------------------------//

    if (savedInstanceState == null) {
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        BluetoothChatFragment fragment = new BluetoothChatFragment();
        transaction.replace(R.id.sample_content_fragment, fragment);
        transaction.commit();
    }
}

From source file:de.da_sense.moses.client.LoginActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mContext = this;

    getActionBar().hide();//from  www.  j  av  a 2s . co m

    setContentView(R.layout.login);

    lg = this;
    editTextEmail = (EditText) findViewById(R.id.login_email);
    editTextPassword = (EditText) findViewById(R.id.login_password);
    checkBoxRemember = (CheckBox) findViewById(R.id.checkbox_login_remember_me);
    buttonLogin = (Button) findViewById(R.id.login_button);

    // set the previously persisted credentials if any
    try {
        String[] credentials = readCredentials();
        if (credentials != null) {
            editTextEmail.setText(credentials[0]);
            editTextPassword.setText(credentials[1]);
        }
    } catch (IOException e) {
        Log.e(LOG_TAG, "onCreate: file containing users credentials could not be read");
        e.printStackTrace();
    }

    // set the focus and cursor on an empty field (email or password)
    if (editTextEmail.getText().toString().isEmpty())
        editTextEmail.requestFocus();
    else if (editTextPassword.getText().toString().isEmpty())
        editTextPassword.requestFocus();

    /*
     * When user clicks the "Go" button on keyboard and the cursor is set on the password fields,
     * it should be equivalent to pressing the login button
     */
    editTextPassword.setOnEditorActionListener(new OnEditorActionListener() {

        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER))
                    || (actionId == EditorInfo.IME_ACTION_DONE)) {
                lg.handleClick(buttonLogin);
            }
            return false;
        }
    });
}

From source file:io.plaidapp.ui.DesignerNewsLogin.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_designer_news_login);
    ButterKnife.bind(this);
    if (!FabTransform.setup(this, container)) {
        MorphTransform.setup(this, container, ContextCompat.getColor(this, R.color.background_light),
                getResources().getDimensionPixelSize(R.dimen.dialog_corners));
    }//from  ww w  . jav  a 2 s. co m

    loading.setVisibility(View.GONE);
    setupAccountAutocomplete();
    username.addTextChangedListener(loginFieldWatcher);
    // the primer checkbox messes with focus order so force it
    username.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_NEXT) {
                password.requestFocus();
                return true;
            }
            return false;
        }
    });
    password.addTextChangedListener(loginFieldWatcher);
    password.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE && isLoginValid()) {
                login.performClick();
                return true;
            }
            return false;
        }
    });
    designerNewsPrefs = DesignerNewsPrefs.get(this);
}

From source file:com.ardnezar.lookapp.ConnectActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Get setting keys.
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    keyprefVideoCallEnabled = getString(R.string.pref_videocall_key);
    keyprefResolution = getString(R.string.pref_resolution_key);
    keyprefFps = getString(R.string.pref_fps_key);
    keyprefCaptureQualitySlider = getString(R.string.pref_capturequalityslider_key);
    keyprefVideoBitrateType = getString(R.string.pref_startvideobitrate_key);
    keyprefVideoBitrateValue = getString(R.string.pref_startvideobitratevalue_key);
    keyprefVideoCodec = getString(R.string.pref_videocodec_key);
    keyprefHwCodecAcceleration = getString(R.string.pref_hwcodec_key);
    keyprefCaptureToTexture = getString(R.string.pref_capturetotexture_key);
    keyprefAudioBitrateType = getString(R.string.pref_startaudiobitrate_key);
    keyprefAudioBitrateValue = getString(R.string.pref_startaudiobitratevalue_key);
    keyprefAudioCodec = getString(R.string.pref_audiocodec_key);
    keyprefNoAudioProcessingPipeline = getString(R.string.pref_noaudioprocessing_key);
    keyprefAecDump = getString(R.string.pref_aecdump_key);
    keyprefOpenSLES = getString(R.string.pref_opensles_key);
    keyprefDisplayHud = getString(R.string.pref_displayhud_key);
    keyprefTracing = getString(R.string.pref_tracing_key);
    keyprefRoomServerUrl = getString(R.string.pref_room_server_url_key);
    keyprefRoom = getString(R.string.pref_room_key);
    keyprefRoomList = getString(R.string.pref_room_list_key);

    setContentView(R.layout.activity_connect);

    roomEditText = (EditText) findViewById(R.id.room_edittext);
    roomEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override//from   ww  w  .j  a v  a2s  .c  o  m
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_DONE) {
                addRoomButton.performClick();
                return true;
            }
            return false;
        }
    });
    roomEditText.requestFocus();

    roomListView = (ListView) findViewById(R.id.room_listview);
    roomListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    addRoomButton = (ImageButton) findViewById(R.id.add_room_button);
    addRoomButton.setOnClickListener(addRoomListener);
    removeRoomButton = (ImageButton) findViewById(R.id.remove_room_button);
    removeRoomButton.setOnClickListener(removeRoomListener);
    connectButton = (ImageButton) findViewById(R.id.connect_button);
    connectButton.setOnClickListener(connectListener);
    connectLoopbackButton = (ImageButton) findViewById(R.id.connect_loopback_button);
    connectLoopbackButton.setOnClickListener(connectListener);

    // If an implicit VIEW intent is launching the app, go directly to that URL.
    //      final Intent intent = getIntent();
    //      if ("android.intent.action.VIEW".equals(intent.getAction())
    //            && !commandLineRun) {
    //         commandLineRun = true;
    //         boolean loopback = intent.getBooleanExtra(
    //               CallActivity.EXTRA_LOOPBACK, false);
    //         int runTimeMs = intent.getIntExtra(
    //               CallActivity.EXTRA_RUNTIME, 0);
    //         String room = sharedPref.getString(keyprefRoom, "");
    //         roomEditText.setText(room);
    //         connectToRoom(loopback, runTimeMs);
    //         return;
    //      }
}

From source file:org.chromium.chrome.browser.payments.ui.EditorView.java

/**
 * Builds the editor view./*from   w w  w .ja  v  a2  s .  co m*/
 *
 * @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();
}