From b939f43b8a6727862ef8f51c3e1b07bdb7f95b67 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 5 Jul 2020 18:28:55 +0200 Subject: [PATCH] Show encryption type in action bar --- .../eu/faircode/email/FragmentCompose.java | 11 +++++-- .../main/res/layout/action_button_text.xml | 29 +++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/layout/action_button_text.xml diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index a949e5f146..872d1aaf81 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -1193,8 +1193,8 @@ public class FragmentCompose extends FragmentBase { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.menu_compose, menu); - menu.findItem(R.id.menu_encrypt).setActionView(R.layout.action_button); - ImageButton ib = (ImageButton) menu.findItem(R.id.menu_encrypt).getActionView(); + menu.findItem(R.id.menu_encrypt).setActionView(R.layout.action_button_text); + ImageButton ib = menu.findItem(R.id.menu_encrypt).getActionView().findViewById(R.id.button); ib.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -1219,17 +1219,22 @@ public class FragmentCompose extends FragmentBase { menu.findItem(R.id.menu_clear).setEnabled(state == State.LOADED); int colorEncrypt = Helper.resolveColor(getContext(), R.attr.colorEncrypt); - ImageButton ib = (ImageButton) menu.findItem(R.id.menu_encrypt).getActionView(); + View v = menu.findItem(R.id.menu_encrypt).getActionView(); + ImageButton ib = v.findViewById(R.id.button); + TextView tv = v.findViewById(R.id.text); ib.setEnabled(state == State.LOADED); if (EntityMessage.PGP_SIGNONLY.equals(encrypt) || EntityMessage.SMIME_SIGNONLY.equals(encrypt)) { ib.setImageResource(R.drawable.baseline_gesture_24); ib.setImageTintList(null); + tv.setText(EntityMessage.PGP_SIGNONLY.equals(encrypt) ? "P" : "S"); } else if (EntityMessage.PGP_SIGNENCRYPT.equals(encrypt) || EntityMessage.SMIME_SIGNENCRYPT.equals(encrypt)) { ib.setImageResource(R.drawable.baseline_lock_24); ib.setImageTintList(ColorStateList.valueOf(colorEncrypt)); + tv.setText(EntityMessage.PGP_SIGNENCRYPT.equals(encrypt) ? "P" : "S"); } else { ib.setImageResource(R.drawable.baseline_lock_open_24); ib.setImageTintList(null); + tv.setText(null); } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); diff --git a/app/src/main/res/layout/action_button_text.xml b/app/src/main/res/layout/action_button_text.xml new file mode 100644 index 0000000000..c9b7bbd829 --- /dev/null +++ b/app/src/main/res/layout/action_button_text.xml @@ -0,0 +1,29 @@ + + + + + + + \ No newline at end of file