From d668c9552fa477feab7258dfbef0f54348eab861 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 23 Oct 2022 08:53:03 +0200 Subject: [PATCH] Added import/export next/done actions --- .../java/eu/faircode/email/ActivitySetup.java | 31 +++++++++++++++++++ app/src/main/res/layout/dialog_import.xml | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/ActivitySetup.java b/app/src/main/java/eu/faircode/email/ActivitySetup.java index d94de00d6b..f8255415ef 100644 --- a/app/src/main/java/eu/faircode/email/ActivitySetup.java +++ b/app/src/main/java/eu/faircode/email/ActivitySetup.java @@ -48,10 +48,12 @@ import android.text.TextWatcher; import android.text.style.ForegroundColorSpan; import android.text.style.StyleSpan; import android.util.Pair; +import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.view.WindowManager; +import android.view.inputmethod.EditorInfo; import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; @@ -1999,6 +2001,17 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac tilPassword1.getEditText().addTextChangedListener(w); tilPassword2.getEditText().addTextChangedListener(w); w.afterTextChanged(null); + + tilPassword2.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + if (actionId == EditorInfo.IME_ACTION_DONE) { + btnOk.performClick(); + return true; + } else + return false; + } + }); } } @@ -2068,6 +2081,24 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac return dialog; } + + @Override + public void onStart() { + super.onStart(); + + Button btnOk = ((AlertDialog) getDialog()).getButton(AlertDialog.BUTTON_POSITIVE); + + tilPassword1.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + if (actionId == EditorInfo.IME_ACTION_DONE) { + btnOk.performClick(); + return true; + } else + return false; + } + }); + } } private BroadcastReceiver receiver = new BroadcastReceiver() { diff --git a/app/src/main/res/layout/dialog_import.xml b/app/src/main/res/layout/dialog_import.xml index 0cccc2ebf3..d570c9916c 100644 --- a/app/src/main/res/layout/dialog_import.xml +++ b/app/src/main/res/layout/dialog_import.xml @@ -38,7 +38,7 @@ android:layout_height="wrap_content" android:autofillHints="password" android:hint="@string/title_setup_password" - android:imeOptions="actionNext" + android:imeOptions="actionDone" android:inputType="textPassword" android:textAppearance="@style/TextAppearance.AppCompat.Medium">