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:de.gadc.moneybeam.MoneyBeamActivity.java

/**
 * This method presents the user the dialog that enables him to enter his
 * email address.//from www.  j a v a2 s  .  c om
 */
private void showEmailDialog() {
    final EditText editText = new EditText(this);
    AlertDialog.Builder emailDialogBuilder = new Builder(this);
    emailDialogBuilder.setTitle(R.string.hint_email);
    editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    editText.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
    emailDialogBuilder.setView(editText);
    emailDialogBuilder.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            String mail = editText.getText().toString();
            prefs.edit().putString(Configuration.PREF_MAIL, mail).commit();
        }
    });
    emailDialogBuilder.setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    emailDialogBuilder.show();
}

From source file:com.projectgoth.mywebrtcdemo.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  www. j a va  2s.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:au.org.ala.fielddata.mobile.SurveyBuilder.java

/**
 * The purpose of this method is to configure EditText widgets so that:
 * 1) If the next widget is an EditText, the keyboard has a "next" key.
 * 2) If the next widget is not an EditText, the keyboard has a "done" key.
 * This is to prevent the input sequence from jumping from a text field
 * to the next text field, skipping other widgets (such as spinners) in the
 * process. // w  w w  .j  a  v a  2 s .  c o m
 * @param previousView the previously created widget.
 * @param inputView the widget created for the current field.
 */
private void configureKeyboardBindings(View previousView, View inputView) {
    if ((previousView instanceof EditText) && !(inputView instanceof EditText)) {
        int imeOptions = ((EditText) previousView).getImeOptions();
        ((EditText) previousView).setImeOptions(imeOptions | EditorInfo.IME_ACTION_DONE);
    }
}

From source file:com.lillicoder.newsblurry.login.LoginFragment.java

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

    this._passwordInput.setOnEditorActionListener(new OnEditorActionListener() {
        @Override// ww  w . j av a  2s  .c  o  m
        public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
            // When the 'done' key is pressed, attempt login via
            // submit button.
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                LoginFragment.this._signInButton.performClick();
                return true;
            }

            return false;
        }
    });

    this._signInButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            // Gather user credentials and attempt login.
            String userName = LoginFragment.this._userNameInput.getText().toString();
            String password = LoginFragment.this._passwordInput.getText().toString();

            // If the password is null (which it shouldn't be), replace it with
            // an empty string for the login task.
            if (password == null)
                password = "";

            if (!TextUtils.isEmpty(userName)) {
                LoginTask login = new LoginTask(view.getContext(), LoginFragment.this._loginTaskListener);
                login.execute(userName, password);
            } else {
                // The user provided no user name, show user name requirement error.
                LoginFragment.this.showUserNameRequiredError();
            }
        }
    });
}

From source file:com.unipiazza.material2stepslogin.fragments.FirstStepFragment.java

@Nullable
@Override//from  ww w  .j a v a2  s. c o m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View view = inflater.inflate(R.layout.first_login_view, null);

    email = (AutoCompleteTextView) view.findViewById(R.id.email);
    next = (Button) view.findViewById(R.id.buttonNext);
    progressBarFirst = (ProgressBar) view.findViewById(R.id.progressBarFirst);
    layoutFirst = (LinearLayout) view.findViewById(R.id.layoutFirst);
    logo = (ImageView) view.findViewById(R.id.logo);
    descriptionText = (TextView) view.findViewById(R.id.descriptionText);
    registerText = (TextView) view.findViewById(R.id.registerText);
    buttonRegistra = (Button) view.findViewById(R.id.buttonRegistra);

    progressBarFirst.setVisibility(View.GONE);

    if (mtsl != null) {
        view.setBackgroundColor(mtsl.getFirst_step_background_color());
        logo.setImageResource(mtsl.getLogo());
        descriptionText.setText(mtsl.getDescription());

        if (mtsl.getRegister_description() != 0)
            registerText.setText(mtsl.getRegister_description());
        if (mtsl.getRegister_description_text_color() != 0)
            registerText.setTextColor(mtsl.getRegister_description_text_color());

        if (mtsl.getRegister_text() != 0)
            buttonRegistra.setText(mtsl.getRegister_text());
        if (mtsl.getRegister_background() != 0)
            buttonRegistra.setBackgroundResource(mtsl.getRegister_background());
        if (mtsl.getButton_register_text_color() != 0)
            buttonRegistra.setTextColor(mtsl.getButton_register_text_color());

        if (mtsl.getEditText_email_text_color() != 0)
            email.setTextColor(mtsl.getEditText_email_text_color());
        if (mtsl.getEdittext_email_background() != 0)
            email.setBackgroundResource(mtsl.getEdittext_email_background());

        if (mtsl.getButton_next_background() != 0)
            next.setBackgroundResource(mtsl.getButton_next_background());
        if (mtsl.getButton_next_text_color() != 0)
            next.setTextColor(mtsl.getButton_next_text_color());

        if (mtsl.getDescription_text_color() != 0)
            descriptionText.setTextColor(mtsl.getDescription_text_color());

    }

    email.setOnEditorActionListener(new TextView.OnEditorActionListener() {

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

    checkAccountPermissions();

    next.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            progressBarFirst.setVisibility(View.VISIBLE);
            layoutFirst.setVisibility(View.GONE);
            mListener.onNextClicked(email.getText().toString());
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
        }
    });

    buttonRegistra.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mListener.onRegisterClicked();
        }
    });

    return view;
}

From source file:com.waz.zclient.pages.main.profile.preferences.dialogs.AddPhoneNumberPreferenceDialogFragment.java

@SuppressLint("InflateParams")
@Override//from  w  w  w  .  j  av a 2  s.c  o  m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final LayoutInflater inflater = LayoutInflater.from(getContext());
    final View view = inflater.inflate(R.layout.preference_dialog_add_phone, null);

    containerView = ViewUtils.getView(view, R.id.ll__preferences__container);
    errorView = ViewUtils.getView(view, R.id.tv__preferences__error);
    errorView.setVisibility(View.GONE);
    countryController = new CountryController(getActivity());

    countryEditText = ViewUtils.getView(view, R.id.acet__preferences__country);
    phoneEditText = ViewUtils.getView(view, R.id.acet__preferences__phone);
    phoneEditText.requestFocus();
    phoneEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                handleInput();
                return true;
            } else {
                return false;
            }
        }
    });

    final String phoneNumber = getArguments().getString(ARG_PHONE, "");
    final String number = countryController.getPhoneNumberWithoutCountryCode(phoneNumber);
    final String countryCode = phoneNumber.substring(0, phoneNumber.length() - number.length()).replace("+",
            "");
    phoneEditText.setText(number);
    phoneEditText.setSelection(number.length());
    countryEditText.setText(String.format("+%s", countryCode));

    if (isEditMode) {
        phoneEditText.requestFocus();
    } else {
        countryEditText.requestFocus();
    }

    final AlertDialog alertDialog = new AlertDialog.Builder(getActivity())
            .setTitle(isEditMode ? R.string.pref__account_action__dialog__edit_phone__title
                    : R.string.pref__account_action__dialog__add_phone__title)
            .setView(view).setPositiveButton(android.R.string.ok, null)
            .setNegativeButton(android.R.string.cancel, null).create();
    alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return alertDialog;
}

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);
    FabDialogMorphSetup.setupSharedEelementTransitions(this, container,
            getResources().getDimensionPixelSize(R.dimen.dialog_corners));
    if (getWindow().getSharedElementEnterTransition() != null) {
        getWindow().getSharedElementEnterTransition().addListener(new AnimUtils.TransitionListenerAdapter() {
            @Override/*  w  ww  . j  a  v a2s .  com*/
            public void onTransitionEnd(Transition transition) {
                finishSetup();
            }
        });
    } else {
        finishSetup();
    }

    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.github.vase4kin.teamcityapp.login.view.LoginViewImpl.java

/**
 * Setup views regarding user type/*w  w w .j ava2s  .  c  o  m*/
 *
 * @param isGuestUser - Is guest user enabled
 * @param listener    - listener
 */
private void setupViewsRegardingUserType(boolean isGuestUser, final OnLoginButtonClickListener listener) {
    if (isGuestUser) {
        // guest user
        mServerUrl.setImeOptions(EditorInfo.IME_ACTION_DONE);
        mServerUrl.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_DONE) {
                    listener.onGuestUserLoginButtonClick(v.getText().toString().trim());
                    return true;
                }
                return false;
            }
        });
        mLoginButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.onGuestUserLoginButtonClick(mServerUrl.getText().toString().trim());
            }
        });
    } else {
        // not guest user
        mServerUrl.setImeOptions(EditorInfo.IME_ACTION_NEXT);
        mServerUrl.setOnEditorActionListener(null);
        mLoginButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.onUserLoginButtonClick(mServerUrl.getText().toString().trim(),
                        mUserName.getText().toString().trim(), mPassword.getText().toString().trim());
            }
        });
    }
}

From source file:org.telegram.ui.ChangeNameActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("EditName", R.string.EditName));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override//from w ww.j av a2  s.c o  m
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == done_button) {
                if (firstNameField.getText().length() != 0) {
                    saveName();
                    finishFragment();
                }
            }
        }
    });

    ActionBarMenu menu = actionBar.createMenu();
    doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));

    TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId());
    if (user == null) {
        user = UserConfig.getCurrentUser();
    }

    LinearLayout linearLayout = new LinearLayout(context);
    fragmentView = linearLayout;
    fragmentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    ((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL);
    fragmentView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    firstNameField = new EditText(context);
    firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    //firstNameField.setHintTextColor(0xff979797);
    firstNameField.setTextColor(ContextCompat.getColor(context, R.color.primary_text));
    firstNameField.setMaxLines(1);
    firstNameField.setLines(1);
    firstNameField.setSingleLine(true);
    firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    firstNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    firstNameField.setImeOptions(EditorInfo.IME_ACTION_NEXT);
    firstNameField.setHint(LocaleController.getString("FirstName", R.string.FirstName));
    AndroidUtilities.clearCursorDrawable(firstNameField);
    linearLayout.addView(firstNameField,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 24, 24, 24, 0));
    firstNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_NEXT) {
                lastNameField.requestFocus();
                lastNameField.setSelection(lastNameField.length());
                return true;
            }
            return false;
        }
    });

    lastNameField = new EditText(context);
    lastNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    //lastNameField.setHintTextColor(0xff979797);
    lastNameField.setTextColor(ContextCompat.getColor(context, R.color.primary_text));
    lastNameField.setMaxLines(1);
    lastNameField.setLines(1);
    lastNameField.setSingleLine(true);
    lastNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    lastNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    lastNameField.setImeOptions(EditorInfo.IME_ACTION_DONE);
    lastNameField.setHint(LocaleController.getString("LastName", R.string.LastName));
    AndroidUtilities.clearCursorDrawable(lastNameField);
    linearLayout.addView(lastNameField,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 24, 16, 24, 0));
    lastNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_DONE) {
                doneButton.performClick();
                return true;
            }
            return false;
        }
    });

    if (user != null) {
        firstNameField.setText(user.first_name);
        firstNameField.setSelection(firstNameField.length());
        lastNameField.setText(user.last_name);
    }

    return fragmentView;
}

From source file:com.craftingmobile.alertdialogusage.LoginDialogFragment.java

/**
 * Perform the login if the user presses the Done key from the
 * password field//from   w  w w.jav  a2  s  . c om
 */
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_DONE) {
        doLogin();
        return true;
    }
    return false;
}