Search in sources :

Example 31 with OnEditorActionListener

use of android.widget.TextView.OnEditorActionListener in project android_frameworks_base by AOSPA.

the class RenameDocumentFragment method onCreateDialog.

/**
     * Creates the dialog UI.
     * @param savedInstanceState
     * @return
     */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context context = getActivity();
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
    View view = dialogInflater.inflate(R.layout.dialog_file_name, null, false);
    mEditText = (EditText) view.findViewById(android.R.id.text1);
    builder.setTitle(R.string.menu_rename);
    builder.setView(view);
    builder.setPositiveButton(android.R.string.ok, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            renameDocuments(mEditText.getText().toString());
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);
    final AlertDialog dialog = builder.create();
    // Workaround for the problem - virtual keyboard doesn't show on the phone.
    Shared.ensureKeyboardPresent(context, dialog);
    mEditText.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView view, int actionId, @Nullable KeyEvent event) {
            if ((actionId == EditorInfo.IME_ACTION_DONE) || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.hasNoModifiers())) {
                renameDocuments(mEditText.getText().toString());
                dialog.dismiss();
                return true;
            }
            return false;
        }
    });
    return dialog;
}
Also used : Context(android.content.Context) AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) View(android.view.View) TextView(android.widget.TextView) KeyEvent(android.view.KeyEvent) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.content.DialogInterface.OnClickListener) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) TextView(android.widget.TextView)

Example 32 with OnEditorActionListener

use of android.widget.TextView.OnEditorActionListener in project android_frameworks_base by ResurrectionRemix.

the class RenameDocumentFragment method onCreateDialog.

/**
     * Creates the dialog UI.
     * @param savedInstanceState
     * @return
     */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context context = getActivity();
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
    View view = dialogInflater.inflate(R.layout.dialog_file_name, null, false);
    mEditText = (EditText) view.findViewById(android.R.id.text1);
    builder.setTitle(R.string.menu_rename);
    builder.setView(view);
    builder.setPositiveButton(android.R.string.ok, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            renameDocuments(mEditText.getText().toString());
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);
    final AlertDialog dialog = builder.create();
    // Workaround for the problem - virtual keyboard doesn't show on the phone.
    Shared.ensureKeyboardPresent(context, dialog);
    mEditText.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView view, int actionId, @Nullable KeyEvent event) {
            if ((actionId == EditorInfo.IME_ACTION_DONE) || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.hasNoModifiers())) {
                renameDocuments(mEditText.getText().toString());
                dialog.dismiss();
                return true;
            }
            return false;
        }
    });
    return dialog;
}
Also used : Context(android.content.Context) AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) View(android.view.View) TextView(android.widget.TextView) KeyEvent(android.view.KeyEvent) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.content.DialogInterface.OnClickListener) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) TextView(android.widget.TextView)

Example 33 with OnEditorActionListener

use of android.widget.TextView.OnEditorActionListener in project android_frameworks_base by ResurrectionRemix.

the class CreateDirectoryFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Context context = getActivity();
    final ContentResolver resolver = context.getContentResolver();
    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    final LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
    final View view = dialogInflater.inflate(R.layout.dialog_file_name, null, false);
    final EditText editText = (EditText) view.findViewById(android.R.id.text1);
    builder.setTitle(R.string.menu_create_dir);
    builder.setView(view);
    builder.setPositiveButton(android.R.string.ok, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            createDirectory(editText.getText().toString());
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);
    final AlertDialog dialog = builder.create();
    // Workaround for the problem - virtual keyboard doesn't show on the phone.
    Shared.ensureKeyboardPresent(context, dialog);
    editText.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView view, int actionId, @Nullable KeyEvent event) {
            if ((actionId == EditorInfo.IME_ACTION_DONE) || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.hasNoModifiers())) {
                createDirectory(editText.getText().toString());
                dialog.dismiss();
                return true;
            }
            return false;
        }
    });
    return dialog;
}
Also used : Context(android.content.Context) AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface) View(android.view.View) TextView(android.widget.TextView) ContentResolver(android.content.ContentResolver) KeyEvent(android.view.KeyEvent) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.content.DialogInterface.OnClickListener) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) TextView(android.widget.TextView)

Example 34 with OnEditorActionListener

use of android.widget.TextView.OnEditorActionListener in project android_frameworks_base by DirtyUnicorns.

the class RenameDocumentFragment method onCreateDialog.

/**
     * Creates the dialog UI.
     * @param savedInstanceState
     * @return
     */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context context = getActivity();
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
    View view = dialogInflater.inflate(R.layout.dialog_file_name, null, false);
    mEditText = (EditText) view.findViewById(android.R.id.text1);
    builder.setTitle(R.string.menu_rename);
    builder.setView(view);
    builder.setPositiveButton(android.R.string.ok, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            renameDocuments(mEditText.getText().toString());
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);
    final AlertDialog dialog = builder.create();
    // Workaround for the problem - virtual keyboard doesn't show on the phone.
    Shared.ensureKeyboardPresent(context, dialog);
    mEditText.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView view, int actionId, @Nullable KeyEvent event) {
            if ((actionId == EditorInfo.IME_ACTION_DONE) || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.hasNoModifiers())) {
                renameDocuments(mEditText.getText().toString());
                dialog.dismiss();
                return true;
            }
            return false;
        }
    });
    return dialog;
}
Also used : Context(android.content.Context) AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) View(android.view.View) TextView(android.widget.TextView) KeyEvent(android.view.KeyEvent) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.content.DialogInterface.OnClickListener) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) TextView(android.widget.TextView)

Example 35 with OnEditorActionListener

use of android.widget.TextView.OnEditorActionListener in project hubroid by EddieRingle.

the class GitHubAuthenticatorActivity method onCreate.

@Override
public void onCreate(Bundle bundle) {
    super.onCreate(bundle, R.layout.login_activity);
    mAccountAuthenticatorResponse = getIntent().getParcelableExtra(KEY_ACCOUNT_AUTHENTICATOR_RESPONSE);
    if (mAccountAuthenticatorResponse != null) {
        mAccountAuthenticatorResponse.onRequestContinued();
    }
    mAccountManager = AccountManager.get(this);
    final Intent intent = getIntent();
    mLogin = intent.getStringExtra(PARAM_LOGIN);
    mAuthTokenType = intent.getStringExtra(PARAM_AUTHTOKEN_TYPE);
    mRequestNewAccount = mLogin == null;
    mConfirmCredentials = intent.getBooleanExtra(PARAM_CONFIRMCREDENTIALS, false);
    mLoginText.setAdapter(new ArrayAdapter<String>(this, simple_dropdown_item_1line, userLoginAccounts()));
    mPasswordText.setOnKeyListener(new OnKeyListener() {

        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event != null && ACTION_DOWN == event.getAction() && keyCode == KEYCODE_ENTER && mSignInButton.isEnabled()) {
                handleLogin(mSignInButton);
                return true;
            }
            return false;
        }
    });
    mPasswordText.setOnEditorActionListener(new OnEditorActionListener() {

        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == IME_ACTION_DONE && mSignInButton.isEnabled()) {
                handleLogin(mSignInButton);
                return true;
            }
            return false;
        }
    });
    mSignInButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            handleLogin(mSignInButton);
        }
    });
    mLoginText.addTextChangedListener(mWatcher);
    mPasswordText.addTextChangedListener(mWatcher);
    TextView signupText = (TextView) findViewById(R.id.tv_auth_link_sign_up);
    signupText.setMovementMethod(LinkMovementMethod.getInstance());
    signupText.setText(Html.fromHtml(getString(R.string.auth_link_signup)));
}
Also used : KeyEvent(android.view.KeyEvent) OnKeyListener(android.view.View.OnKeyListener) Intent(android.content.Intent) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) AutoCompleteTextView(android.widget.AutoCompleteTextView) TextView(android.widget.TextView) View(android.view.View) InjectView(roboguice.inject.InjectView) AutoCompleteTextView(android.widget.AutoCompleteTextView) TextView(android.widget.TextView)

Aggregations

OnEditorActionListener (android.widget.TextView.OnEditorActionListener)37 KeyEvent (android.view.KeyEvent)32 TextView (android.widget.TextView)32 View (android.view.View)28 DialogInterface (android.content.DialogInterface)13 LayoutInflater (android.view.LayoutInflater)13 EditText (android.widget.EditText)13 OnClickListener (android.view.View.OnClickListener)12 AlertDialog (android.app.AlertDialog)11 Context (android.content.Context)11 OnClickListener (android.content.DialogInterface.OnClickListener)11 Intent (android.content.Intent)9 Test (org.junit.Test)6 ContentResolver (android.content.ContentResolver)5 Button (android.widget.Button)4 InjectView (roboguice.inject.InjectView)4 Handler (android.os.Handler)3 AlertDialog (android.support.v7.app.AlertDialog)3 InputMethodManager (android.view.inputmethod.InputMethodManager)3 AutoCompleteTextView (android.widget.AutoCompleteTextView)3