mirror of https://github.com/M66B/FairEmail.git
Added encryption toggle to compose action bar
This commit is contained in:
parent
1f656a9022
commit
ebc40787ac
|
@ -193,6 +193,7 @@ public class FragmentCompose extends FragmentBase {
|
||||||
|
|
||||||
private boolean prefix_once = false;
|
private boolean prefix_once = false;
|
||||||
private boolean monospaced = false;
|
private boolean monospaced = false;
|
||||||
|
private boolean encrypt = false;
|
||||||
private boolean media = true;
|
private boolean media = true;
|
||||||
private boolean compact = false;
|
private boolean compact = false;
|
||||||
|
|
||||||
|
@ -910,6 +911,7 @@ public class FragmentCompose extends FragmentBase {
|
||||||
public void onPrepareOptionsMenu(Menu menu) {
|
public void onPrepareOptionsMenu(Menu menu) {
|
||||||
super.onPrepareOptionsMenu(menu);
|
super.onPrepareOptionsMenu(menu);
|
||||||
|
|
||||||
|
menu.findItem(R.id.menu_encrypt).setVisible(state == State.LOADED);
|
||||||
menu.findItem(R.id.menu_zoom).setVisible(state == State.LOADED);
|
menu.findItem(R.id.menu_zoom).setVisible(state == State.LOADED);
|
||||||
menu.findItem(R.id.menu_media).setVisible(state == State.LOADED);
|
menu.findItem(R.id.menu_media).setVisible(state == State.LOADED);
|
||||||
menu.findItem(R.id.menu_compact).setVisible(state == State.LOADED);
|
menu.findItem(R.id.menu_compact).setVisible(state == State.LOADED);
|
||||||
|
@ -918,6 +920,7 @@ public class FragmentCompose extends FragmentBase {
|
||||||
menu.findItem(R.id.menu_answer).setVisible(state == State.LOADED);
|
menu.findItem(R.id.menu_answer).setVisible(state == State.LOADED);
|
||||||
menu.findItem(R.id.menu_send).setVisible(state == State.LOADED);
|
menu.findItem(R.id.menu_send).setVisible(state == State.LOADED);
|
||||||
|
|
||||||
|
menu.findItem(R.id.menu_encrypt).setEnabled(!busy);
|
||||||
menu.findItem(R.id.menu_zoom).setEnabled(!busy);
|
menu.findItem(R.id.menu_zoom).setEnabled(!busy);
|
||||||
menu.findItem(R.id.menu_media).setEnabled(!busy);
|
menu.findItem(R.id.menu_media).setEnabled(!busy);
|
||||||
menu.findItem(R.id.menu_compact).setEnabled(!busy);
|
menu.findItem(R.id.menu_compact).setEnabled(!busy);
|
||||||
|
@ -926,6 +929,7 @@ public class FragmentCompose extends FragmentBase {
|
||||||
menu.findItem(R.id.menu_answer).setEnabled(!busy);
|
menu.findItem(R.id.menu_answer).setEnabled(!busy);
|
||||||
menu.findItem(R.id.menu_send).setEnabled(!busy);
|
menu.findItem(R.id.menu_send).setEnabled(!busy);
|
||||||
|
|
||||||
|
menu.findItem(R.id.menu_encrypt).setIcon(encrypt ? R.drawable.baseline_lock_24 : R.drawable.baseline_no_encryption_24);
|
||||||
menu.findItem(R.id.menu_media).setChecked(media);
|
menu.findItem(R.id.menu_media).setChecked(media);
|
||||||
menu.findItem(R.id.menu_compact).setChecked(compact);
|
menu.findItem(R.id.menu_compact).setChecked(compact);
|
||||||
}
|
}
|
||||||
|
@ -937,6 +941,9 @@ public class FragmentCompose extends FragmentBase {
|
||||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
|
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
|
||||||
onExit();
|
onExit();
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.menu_encrypt:
|
||||||
|
onMenuEncrypt();
|
||||||
|
return true;
|
||||||
case R.id.menu_zoom:
|
case R.id.menu_zoom:
|
||||||
onMenuZoom();
|
onMenuZoom();
|
||||||
return true;
|
return true;
|
||||||
|
@ -977,6 +984,33 @@ public class FragmentCompose extends FragmentBase {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onMenuEncrypt() {
|
||||||
|
encrypt = !encrypt;
|
||||||
|
getActivity().invalidateOptionsMenu();
|
||||||
|
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putLong("id", working);
|
||||||
|
args.putBoolean("encrypt", encrypt);
|
||||||
|
|
||||||
|
new SimpleTask<Void>() {
|
||||||
|
@Override
|
||||||
|
protected Void onExecute(Context context, Bundle args) {
|
||||||
|
long id = args.getLong("id");
|
||||||
|
boolean encrypt = args.getBoolean("encrypt");
|
||||||
|
|
||||||
|
DB db = DB.getInstance(context);
|
||||||
|
db.message().setMessageEncrypt(id, encrypt);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onException(Bundle args, Throwable ex) {
|
||||||
|
Helper.unexpectedError(getFragmentManager(), ex);
|
||||||
|
}
|
||||||
|
}.execute(this, args, "compose:encrypt");
|
||||||
|
}
|
||||||
|
|
||||||
private void onMenuZoom() {
|
private void onMenuZoom() {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
boolean compact = prefs.getBoolean("compact", false);
|
boolean compact = prefs.getBoolean("compact", false);
|
||||||
|
@ -2399,11 +2433,13 @@ public class FragmentCompose extends FragmentBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onExecuted(Bundle args, final DraftData data) {
|
protected void onExecuted(Bundle args, final DraftData data) {
|
||||||
working = data.draft.id;
|
|
||||||
|
|
||||||
final String action = getArguments().getString("action");
|
final String action = getArguments().getString("action");
|
||||||
Log.i("Loaded draft id=" + data.draft.id + " action=" + action);
|
Log.i("Loaded draft id=" + data.draft.id + " action=" + action);
|
||||||
|
|
||||||
|
working = data.draft.id;
|
||||||
|
encrypt = (data.draft.encrypt != null && data.draft.encrypt);
|
||||||
|
getActivity().invalidateOptionsMenu();
|
||||||
|
|
||||||
// Show identities
|
// Show identities
|
||||||
AdapterIdentitySelect iadapter = new AdapterIdentitySelect(getContext(), data.identities);
|
AdapterIdentitySelect iadapter = new AdapterIdentitySelect(getContext(), data.identities);
|
||||||
spIdentity.setAdapter(iadapter);
|
spIdentity.setAdapter(iadapter);
|
||||||
|
@ -2436,8 +2472,6 @@ public class FragmentCompose extends FragmentBase {
|
||||||
bottom_navigation.getMenu().findItem(R.id.action_redo).setVisible(
|
bottom_navigation.getMenu().findItem(R.id.action_redo).setVisible(
|
||||||
data.draft.revision != null && !data.draft.revision.equals(data.draft.revisions));
|
data.draft.revision != null && !data.draft.revision.equals(data.draft.revisions));
|
||||||
|
|
||||||
getActivity().invalidateOptionsMenu();
|
|
||||||
|
|
||||||
if (args.getBoolean("incomplete"))
|
if (args.getBoolean("incomplete"))
|
||||||
Snackbar.make(view, R.string.title_attachments_incomplete, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(view, R.string.title_attachments_incomplete, Snackbar.LENGTH_LONG).show();
|
||||||
|
|
||||||
|
@ -2485,6 +2519,9 @@ public class FragmentCompose extends FragmentBase {
|
||||||
if (draft == null || draft.ui_hide)
|
if (draft == null || draft.ui_hide)
|
||||||
finish();
|
finish();
|
||||||
else {
|
else {
|
||||||
|
encrypt = (draft.encrypt != null && draft.encrypt);
|
||||||
|
getActivity().invalidateOptionsMenu();
|
||||||
|
|
||||||
Log.i("Draft content=" + draft.content);
|
Log.i("Draft content=" + draft.content);
|
||||||
if (draft.content && state == State.NONE)
|
if (draft.content && state == State.NONE)
|
||||||
showDraft(draft);
|
showDraft(draft);
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_encrypt"
|
||||||
|
android:icon="@drawable/baseline_lock_24"
|
||||||
|
android:title="@string/title_encrypt"
|
||||||
|
app:showAsAction="always" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_zoom"
|
android:id="@+id/menu_zoom"
|
||||||
android:icon="@drawable/baseline_format_size_24"
|
android:icon="@drawable/baseline_format_size_24"
|
||||||
|
|
Loading…
Reference in New Issue