Small behavior improvement

pull/187/head
M66B 4 years ago
parent f894c81390
commit fdcb62fb95

@ -470,20 +470,20 @@ public class FragmentCompose extends FragmentBase {
}); });
etBody.setSelectionListener(new EditTextCompose.ISelection() { etBody.setSelectionListener(new EditTextCompose.ISelection() {
private boolean style = false;
private boolean styling = false; private boolean styling = false;
@Override @Override
public void onSelected(boolean selection) { public void onSelected(final boolean selection) {
if (media) { if (media) {
style = selection;
getMainHandler().postDelayed(new Runnable() { getMainHandler().postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
if (style != styling) { if (styling != selection) {
styling = style; styling = selection;
media_bar.getMenu().clear(); media_bar.getMenu().clear();
media_bar.inflateMenu(styling ? R.menu.action_compose_style_alt : R.menu.action_compose_media); media_bar.inflateMenu(styling
? R.menu.action_compose_style_alt
: R.menu.action_compose_media);
} }
} }
}, 20); }, 20);
@ -1550,9 +1550,11 @@ public class FragmentCompose extends FragmentBase {
media = !media; media = !media;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
prefs.edit().putBoolean("compose_media", media).apply(); prefs.edit().putBoolean("compose_media", media).apply();
media_bar.setVisibility(media ? View.VISIBLE : View.GONE); etBody.setSelection(etBody.getSelectionStart());
media_bar.getMenu().clear(); media_bar.getMenu().clear();
media_bar.inflateMenu(media && etBody.hasSelection() ? R.menu.action_compose_style_alt : R.menu.action_compose_media); media_bar.inflateMenu(R.menu.action_compose_media);
media_bar.setVisibility(media ? View.VISIBLE : View.GONE);
style_bar.setVisibility(View.GONE);
} }
private void onMenuCompact() { private void onMenuCompact() {

Loading…
Cancel
Save