mirror of https://github.com/M66B/FairEmail.git
Show encryption type in action bar
This commit is contained in:
parent
c7f1ba9665
commit
b939f43b8a
|
@ -1193,8 +1193,8 @@ public class FragmentCompose extends FragmentBase {
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
inflater.inflate(R.menu.menu_compose, menu);
|
inflater.inflate(R.menu.menu_compose, menu);
|
||||||
|
|
||||||
menu.findItem(R.id.menu_encrypt).setActionView(R.layout.action_button);
|
menu.findItem(R.id.menu_encrypt).setActionView(R.layout.action_button_text);
|
||||||
ImageButton ib = (ImageButton) menu.findItem(R.id.menu_encrypt).getActionView();
|
ImageButton ib = menu.findItem(R.id.menu_encrypt).getActionView().findViewById(R.id.button);
|
||||||
ib.setOnClickListener(new View.OnClickListener() {
|
ib.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -1219,17 +1219,22 @@ public class FragmentCompose extends FragmentBase {
|
||||||
menu.findItem(R.id.menu_clear).setEnabled(state == State.LOADED);
|
menu.findItem(R.id.menu_clear).setEnabled(state == State.LOADED);
|
||||||
|
|
||||||
int colorEncrypt = Helper.resolveColor(getContext(), R.attr.colorEncrypt);
|
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);
|
ib.setEnabled(state == State.LOADED);
|
||||||
if (EntityMessage.PGP_SIGNONLY.equals(encrypt) || EntityMessage.SMIME_SIGNONLY.equals(encrypt)) {
|
if (EntityMessage.PGP_SIGNONLY.equals(encrypt) || EntityMessage.SMIME_SIGNONLY.equals(encrypt)) {
|
||||||
ib.setImageResource(R.drawable.baseline_gesture_24);
|
ib.setImageResource(R.drawable.baseline_gesture_24);
|
||||||
ib.setImageTintList(null);
|
ib.setImageTintList(null);
|
||||||
|
tv.setText(EntityMessage.PGP_SIGNONLY.equals(encrypt) ? "P" : "S");
|
||||||
} else if (EntityMessage.PGP_SIGNENCRYPT.equals(encrypt) || EntityMessage.SMIME_SIGNENCRYPT.equals(encrypt)) {
|
} else if (EntityMessage.PGP_SIGNENCRYPT.equals(encrypt) || EntityMessage.SMIME_SIGNENCRYPT.equals(encrypt)) {
|
||||||
ib.setImageResource(R.drawable.baseline_lock_24);
|
ib.setImageResource(R.drawable.baseline_lock_24);
|
||||||
ib.setImageTintList(ColorStateList.valueOf(colorEncrypt));
|
ib.setImageTintList(ColorStateList.valueOf(colorEncrypt));
|
||||||
|
tv.setText(EntityMessage.PGP_SIGNENCRYPT.equals(encrypt) ? "P" : "S");
|
||||||
} else {
|
} else {
|
||||||
ib.setImageResource(R.drawable.baseline_lock_open_24);
|
ib.setImageResource(R.drawable.baseline_lock_open_24);
|
||||||
ib.setImageTintList(null);
|
ib.setImageTintList(null);
|
||||||
|
tv.setText(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/button"
|
||||||
|
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:srcCompat="@drawable/baseline_lock_24" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="3dp"
|
||||||
|
android:clickable="false"
|
||||||
|
android:text="P"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
android:textColor="?attr/colorControlNormal"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/button"
|
||||||
|
app:layout_constraintEnd_toEndOf="@id/button"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/button" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue