From 917bac68253bfa8f395ebcc53622e421cd7e5897 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 15 Jun 2019 08:49:46 +0200 Subject: [PATCH] Added option to show keyboard by default (enabled) --- .../eu/faircode/email/FragmentCompose.java | 18 +++++++++++++++--- .../eu/faircode/email/FragmentOptionsSend.java | 12 +++++++++++- .../main/res/layout/fragment_options_send.xml | 13 ++++++++++++- app/src/main/res/values/strings.xml | 1 + 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index cc45813fdc..902a5da918 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -76,6 +76,7 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; +import android.view.inputmethod.InputMethodManager; import android.webkit.MimeTypeMap; import android.widget.AdapterView; import android.widget.ArrayAdapter; @@ -2944,12 +2945,23 @@ public class FragmentCompose extends FragmentBase { new Handler().post(new Runnable() { @Override public void run() { + View target; if (TextUtils.isEmpty(etTo.getText().toString().trim())) - etTo.requestFocus(); + target = etTo; else if (TextUtils.isEmpty(etSubject.getText().toString())) - etSubject.requestFocus(); + target = etSubject; else - etBody.requestFocus(); + target = etBody; + + target.requestFocus(); + + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + boolean keyboard = prefs.getBoolean("keyboard", true); + if (keyboard) { + InputMethodManager imm = + (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + imm.showSoftInput(target, InputMethodManager.SHOW_IMPLICIT); + } } }); } diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java index d222841b01..e8c3b0b474 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java @@ -38,6 +38,7 @@ import androidx.appcompat.widget.SwitchCompat; import androidx.preference.PreferenceManager; public class FragmentOptionsSend extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener { + private SwitchCompat swKeyboard; private SwitchCompat swPrefixOnce; private SwitchCompat swPlainOnly; private SwitchCompat swAutoResize; @@ -47,7 +48,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc private Spinner spSendDelayed; private final static String[] RESET_OPTIONS = new String[]{ - "prefix_once", "plain_only", "autoresize", "resize", "autosend", "send_delayed" + "keyboard", "prefix_once", "plain_only", "autoresize", "resize", "autosend", "send_delayed" }; @Override @@ -60,6 +61,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc // Get controls + swKeyboard = view.findViewById(R.id.swKeyboard); swPrefixOnce = view.findViewById(R.id.swPrefixOnce); swPlainOnly = view.findViewById(R.id.swPlainOnly); swAutoResize = view.findViewById(R.id.swAutoResize); @@ -74,6 +76,13 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + swKeyboard.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("keyboard", checked).apply(); + } + }); + swPrefixOnce.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -174,6 +183,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc private void setOptions() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + swKeyboard.setChecked(prefs.getBoolean("keyboard", true)); swPrefixOnce.setChecked(prefs.getBoolean("prefix_once", false)); swPlainOnly.setChecked(prefs.getBoolean("plain_only", false)); diff --git a/app/src/main/res/layout/fragment_options_send.xml b/app/src/main/res/layout/fragment_options_send.xml index c573501401..2730ff5eba 100644 --- a/app/src/main/res/layout/fragment_options_send.xml +++ b/app/src/main/res/layout/fragment_options_send.xml @@ -18,6 +18,17 @@ android:layout_height="wrap_content" android:padding="12dp"> + + Check if old messages were removed from the server Synchronize folder list + Show keyboard by default Prefix subject only once on replying or forwarding Send plain text only by default Automatically resize attached and embedded images