mirror of https://github.com/M66B/FairEmail.git
Use media bar for style actions
This commit is contained in:
parent
aa1b7bd12d
commit
a0cc3c32bc
|
@ -466,9 +466,25 @@ public class FragmentCompose extends FragmentBase {
|
||||||
});
|
});
|
||||||
|
|
||||||
etBody.setSelectionListener(new EditTextCompose.ISelection() {
|
etBody.setSelectionListener(new EditTextCompose.ISelection() {
|
||||||
|
private boolean style = false;
|
||||||
|
private boolean styling = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSelected(boolean selection) {
|
public void onSelected(boolean selection) {
|
||||||
style_bar.setVisibility(selection ? View.VISIBLE : View.GONE);
|
if (media) {
|
||||||
|
style = selection;
|
||||||
|
getMainHandler().postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (style != styling) {
|
||||||
|
styling = style;
|
||||||
|
media_bar.getMenu().clear();
|
||||||
|
media_bar.inflateMenu(styling ? R.menu.action_compose_style : R.menu.action_compose_media);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 20);
|
||||||
|
} else
|
||||||
|
style_bar.setVisibility(selection ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -726,7 +742,8 @@ public class FragmentCompose extends FragmentBase {
|
||||||
style_bar.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
|
style_bar.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||||
return onActionStyle(item.getItemId());
|
int action = item.getItemId();
|
||||||
|
return onActionStyle(action, style_bar.findViewById(action));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -751,7 +768,7 @@ public class FragmentCompose extends FragmentBase {
|
||||||
onActionLink();
|
onActionLink();
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return onActionStyle(action, media_bar.findViewById(action));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1513,6 +1530,8 @@ public class FragmentCompose extends FragmentBase {
|
||||||
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);
|
media_bar.setVisibility(media ? View.VISIBLE : View.GONE);
|
||||||
|
media_bar.getMenu().clear();
|
||||||
|
media_bar.inflateMenu(media && etBody.hasSelection() ? R.menu.action_compose_style : R.menu.action_compose_media);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onMenuCompact() {
|
private void onMenuCompact() {
|
||||||
|
@ -1674,9 +1693,9 @@ public class FragmentCompose extends FragmentBase {
|
||||||
}.execute(getContext(), getViewLifecycleOwner(), new Bundle(), "compose:answer");
|
}.execute(getContext(), getViewLifecycleOwner(), new Bundle(), "compose:answer");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean onActionStyle(int action) {
|
private boolean onActionStyle(int action, View anchor) {
|
||||||
Log.i("Style action=" + action);
|
Log.i("Style action=" + action);
|
||||||
return StyleHelper.apply(action, view.findViewById(action), etBody);
|
return StyleHelper.apply(action, anchor, etBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onActionRecordAudio() {
|
private void onActionRecordAudio() {
|
||||||
|
|
|
@ -477,7 +477,6 @@
|
||||||
android:id="@+id/style_bar"
|
android:id="@+id/style_bar"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="36dp"
|
android:layout_height="36dp"
|
||||||
android:layout_marginBottom="1dp"
|
|
||||||
android:background="?attr/colorActionBackground"
|
android:background="?attr/colorActionBackground"
|
||||||
app:itemIconTint="@color/action_foreground"
|
app:itemIconTint="@color/action_foreground"
|
||||||
app:itemTextColor="@color/action_foreground"
|
app:itemTextColor="@color/action_foreground"
|
||||||
|
|
Loading…
Reference in New Issue