Compose focus improvements

pull/198/head
M66B 4 years ago
parent 62cc21464b
commit 19938e764d

@ -5157,10 +5157,7 @@ public class FragmentCompose extends FragmentBase {
showDraft(draft);
} else if (action == R.id.action_save) {
etBody.requestFocus();
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null)
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
focus();
} else if (action == R.id.action_check) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
@ -5461,8 +5458,17 @@ public class FragmentCompose extends FragmentBase {
return;
state = State.LOADED;
final Context context = getContext();
focus();
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getParentFragmentManager(), ex);
}
}.execute(this, args, "compose:show");
}
private void focus() {
final View target;
if (TextUtils.isEmpty(etTo.getText().toString().trim()))
target = etTo;
@ -5477,14 +5483,19 @@ public class FragmentCompose extends FragmentBase {
try {
target.requestFocus();
Context context = target.getContext();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean keyboard = prefs.getBoolean("keyboard", true);
if (keyboard) {
if (!keyboard)
return;
InputMethodManager imm =
(InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null)
if (imm == null)
return;
imm.showSoftInput(target, InputMethodManager.SHOW_IMPLICIT);
}
} catch (Throwable ex) {
Log.e(ex);
}
@ -5492,13 +5503,6 @@ public class FragmentCompose extends FragmentBase {
});
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getParentFragmentManager(), ex);
}
}.execute(this, args, "compose:show");
}
private void setBodyPadding() {
// Keep room for the style toolbar
boolean pad =

Loading…
Cancel
Save