mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-03 21:55:13 +00:00
Compose focus improvements
This commit is contained in:
parent
62cc21464b
commit
19938e764d
1 changed files with 37 additions and 33 deletions
|
@ -5157,10 +5157,7 @@ public class FragmentCompose extends FragmentBase {
|
||||||
showDraft(draft);
|
showDraft(draft);
|
||||||
|
|
||||||
} else if (action == R.id.action_save) {
|
} else if (action == R.id.action_save) {
|
||||||
etBody.requestFocus();
|
focus();
|
||||||
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
||||||
if (imm != null)
|
|
||||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
|
||||||
|
|
||||||
} else if (action == R.id.action_check) {
|
} else if (action == R.id.action_check) {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
|
@ -5461,35 +5458,7 @@ public class FragmentCompose extends FragmentBase {
|
||||||
return;
|
return;
|
||||||
state = State.LOADED;
|
state = State.LOADED;
|
||||||
|
|
||||||
final Context context = getContext();
|
focus();
|
||||||
|
|
||||||
final View target;
|
|
||||||
if (TextUtils.isEmpty(etTo.getText().toString().trim()))
|
|
||||||
target = etTo;
|
|
||||||
else if (TextUtils.isEmpty(etSubject.getText().toString()))
|
|
||||||
target = etSubject;
|
|
||||||
else
|
|
||||||
target = etBody;
|
|
||||||
|
|
||||||
getMainHandler().post(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
target.requestFocus();
|
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
||||||
boolean keyboard = prefs.getBoolean("keyboard", true);
|
|
||||||
if (keyboard) {
|
|
||||||
InputMethodManager imm =
|
|
||||||
(InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
||||||
if (imm != null)
|
|
||||||
imm.showSoftInput(target, InputMethodManager.SHOW_IMPLICIT);
|
|
||||||
}
|
|
||||||
} catch (Throwable ex) {
|
|
||||||
Log.e(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -5499,6 +5468,41 @@ public class FragmentCompose extends FragmentBase {
|
||||||
}.execute(this, args, "compose:show");
|
}.execute(this, args, "compose:show");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void focus() {
|
||||||
|
final View target;
|
||||||
|
if (TextUtils.isEmpty(etTo.getText().toString().trim()))
|
||||||
|
target = etTo;
|
||||||
|
else if (TextUtils.isEmpty(etSubject.getText().toString()))
|
||||||
|
target = etSubject;
|
||||||
|
else
|
||||||
|
target = etBody;
|
||||||
|
|
||||||
|
getMainHandler().post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
target.requestFocus();
|
||||||
|
|
||||||
|
Context context = target.getContext();
|
||||||
|
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
boolean keyboard = prefs.getBoolean("keyboard", true);
|
||||||
|
if (!keyboard)
|
||||||
|
return;
|
||||||
|
|
||||||
|
InputMethodManager imm =
|
||||||
|
(InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
if (imm == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
imm.showSoftInput(target, InputMethodManager.SHOW_IMPLICIT);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
Log.e(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void setBodyPadding() {
|
private void setBodyPadding() {
|
||||||
// Keep room for the style toolbar
|
// Keep room for the style toolbar
|
||||||
boolean pad =
|
boolean pad =
|
||||||
|
|
Loading…
Reference in a new issue