mirror of https://github.com/M66B/FairEmail.git
Edit name: handle editor done
This commit is contained in:
parent
fbe1edde16
commit
2668f19acd
|
@ -25,10 +25,14 @@ import android.app.Dialog;
|
|||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
@ -48,6 +52,22 @@ public class FragmentDialogEditName extends FragmentDialogBase {
|
|||
cbPrimary.setChecked(args.getBoolean("primary"));
|
||||
cbPrimary.setVisibility(args.containsKey("primary") ? View.VISIBLE : View.GONE);
|
||||
|
||||
etName.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
if (actionId != EditorInfo.IME_ACTION_DONE)
|
||||
return false;
|
||||
AlertDialog dialog = (AlertDialog) getDialog();
|
||||
if (dialog == null)
|
||||
return false;
|
||||
Button btnOk = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||
if (btnOk == null)
|
||||
return false;
|
||||
btnOk.performClick();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
return new AlertDialog.Builder(context)
|
||||
.setView(view)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
|
|
Loading…
Reference in New Issue