Added option to show keyboard by default (enabled)

This commit is contained in:
M66B
2019-06-15 08:49:46 +02:00
parent d710ddfdaa
commit 917bac6825
4 changed files with 39 additions and 5 deletions

View File

@@ -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);
}
}
});
}

View File

@@ -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));