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); 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,8 +5458,17 @@ public class FragmentCompose extends FragmentBase {
return; return;
state = State.LOADED; 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; final View target;
if (TextUtils.isEmpty(etTo.getText().toString().trim())) if (TextUtils.isEmpty(etTo.getText().toString().trim()))
target = etTo; target = etTo;
@ -5477,14 +5483,19 @@ public class FragmentCompose extends FragmentBase {
try { try {
target.requestFocus(); target.requestFocus();
Context context = target.getContext();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean keyboard = prefs.getBoolean("keyboard", true); boolean keyboard = prefs.getBoolean("keyboard", true);
if (keyboard) { if (!keyboard)
return;
InputMethodManager imm = InputMethodManager imm =
(InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) if (imm == null)
return;
imm.showSoftInput(target, InputMethodManager.SHOW_IMPLICIT); imm.showSoftInput(target, InputMethodManager.SHOW_IMPLICIT);
}
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(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() { private void setBodyPadding() {
// Keep room for the style toolbar // Keep room for the style toolbar
boolean pad = boolean pad =

Loading…
Cancel
Save