mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-27 02:07:12 +00:00
Added auto decrypt
This commit is contained in:
parent
5290f2138b
commit
5cb089098d
5 changed files with 37 additions and 13 deletions
|
@ -1409,7 +1409,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
// Check for inline encryption
|
||||
int begin = body.indexOf(Helper.PGP_BEGIN_MESSAGE);
|
||||
int end = body.indexOf(Helper.PGP_END_MESSAGE);
|
||||
args.putBoolean("iencrypted", begin >= 0 && begin < end);
|
||||
args.putBoolean("inline_encrypted", begin >= 0 && begin < end);
|
||||
|
||||
// Check for images
|
||||
boolean has_images = false;
|
||||
|
@ -1518,7 +1518,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
@Override
|
||||
protected void onExecuted(Bundle args, Object result) {
|
||||
TupleMessageEx message = (TupleMessageEx) args.getSerializable("message");
|
||||
properties.setValue("iencrypted", message.id, args.getBoolean("iencrypted"));
|
||||
properties.setValue("inline_encrypted", message.id, args.getBoolean("inline_encrypted"));
|
||||
|
||||
TupleMessageEx amessage = getMessage();
|
||||
if (amessage == null || !amessage.id.equals(message.id))
|
||||
|
@ -1567,9 +1567,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
|
||||
grpAttachments.setVisibility(attachments.size() > 0 ? View.VISIBLE : View.GONE);
|
||||
|
||||
boolean iencrypted = properties.getValue("iencrypted", message.id);
|
||||
boolean show_inline = properties.getValue("inline", message.id);
|
||||
Log.i("Show inline=" + show_inline);
|
||||
boolean inline_encrypted = properties.getValue("inline_encrypted", message.id);
|
||||
Log.i("Show inline=" + show_inline + " encrypted=" + inline_encrypted);
|
||||
|
||||
boolean has_inline = false;
|
||||
boolean is_encrypted = false;
|
||||
|
@ -1620,7 +1620,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
btnDownloadAttachments.setVisibility(download && suitable ? View.VISIBLE : View.GONE);
|
||||
tvNoInternetAttachments.setVisibility(downloading && !suitable ? View.VISIBLE : View.GONE);
|
||||
|
||||
ibDecrypt.setVisibility(iencrypted || is_encrypted ? View.VISIBLE : View.GONE);
|
||||
ibDecrypt.setVisibility(inline_encrypted || is_encrypted ? View.VISIBLE : View.GONE);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean auto_decrypt = prefs.getBoolean("auto_decrypt", false);
|
||||
if (auto_decrypt && is_encrypted)
|
||||
onActionDecrypt(message);
|
||||
|
||||
cbInline.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
|
|
|
@ -4030,19 +4030,16 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
String html = parts.getHtml(context);
|
||||
Helper.writeText(message.getFile(context), html);
|
||||
|
||||
// Remove previously decrypted attachments
|
||||
// Remove attachments
|
||||
for (EntityAttachment local : attachments)
|
||||
if (local.encryption == null)
|
||||
db.attachment().deleteAttachment(local.id);
|
||||
|
||||
int sequence = db.attachment().getAttachmentSequence(id);
|
||||
db.attachment().deleteAttachment(local.id);
|
||||
|
||||
// Add decrypted attachments
|
||||
List<EntityAttachment> remotes = parts.getAttachments();
|
||||
for (int index = 0; index < remotes.size(); index++) {
|
||||
EntityAttachment remote = remotes.get(index);
|
||||
remote.message = id;
|
||||
remote.sequence = ++sequence;
|
||||
remote.sequence = index + 1;
|
||||
remote.id = db.attachment().insertAttachment(remote);
|
||||
try {
|
||||
parts.downloadAttachment(context, index, remote);
|
||||
|
|
|
@ -48,12 +48,13 @@ import androidx.preference.PreferenceManager;
|
|||
public class FragmentOptionsPrivacy extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private SwitchCompat swDisableTracking;
|
||||
private SwitchCompat swDisplayHidden;
|
||||
private SwitchCompat swAutoDecrypt;
|
||||
private SwitchCompat swNoHistory;
|
||||
private Spinner spBiometricsTimeout;
|
||||
private Button btnPin;
|
||||
|
||||
private final static String[] RESET_OPTIONS = new String[]{
|
||||
"disable_tracking", "display_hidden", "no_history", "biometrics_timeout"
|
||||
"disable_tracking", "display_hidden", "auto_decrypt", "no_history", "biometrics_timeout"
|
||||
};
|
||||
|
||||
@Override
|
||||
|
@ -68,6 +69,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
|||
|
||||
swDisableTracking = view.findViewById(R.id.swDisableTracking);
|
||||
swDisplayHidden = view.findViewById(R.id.swDisplayHidden);
|
||||
swAutoDecrypt = view.findViewById(R.id.swAutoDecrypt);
|
||||
swNoHistory = view.findViewById(R.id.swNoHistory);
|
||||
spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout);
|
||||
btnPin = view.findViewById(R.id.btnPin);
|
||||
|
@ -92,6 +94,13 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
|||
}
|
||||
});
|
||||
|
||||
swAutoDecrypt.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("auto_decrypt", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
swNoHistory.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
|
@ -169,6 +178,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
|||
|
||||
swDisableTracking.setChecked(prefs.getBoolean("disable_tracking", true));
|
||||
swDisplayHidden.setChecked(prefs.getBoolean("display_hidden", false));
|
||||
swAutoDecrypt.setChecked(prefs.getBoolean("auto_decrypt", false));
|
||||
swNoHistory.setChecked(prefs.getBoolean("no_history", false));
|
||||
|
||||
int biometrics_timeout = prefs.getInt("biometrics_timeout", 2);
|
||||
|
|
|
@ -59,6 +59,17 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swDisplayHidden" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swAutoDecrypt"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_auto_decrypt"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvDisplayHiddenHint"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swNoHistory"
|
||||
android:layout_width="0dp"
|
||||
|
@ -67,7 +78,7 @@
|
|||
android:text="@string/title_advanced_recents"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvDisplayHiddenHint"
|
||||
app:layout_constraintTop_toBottomOf="@id/swAutoDecrypt"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<TextView
|
||||
|
|
|
@ -320,6 +320,7 @@
|
|||
|
||||
<string name="title_advanced_tracking">Automatically recognize and disable tracking images</string>
|
||||
<string name="title_advanced_display_hidden">Display hidden message texts</string>
|
||||
<string name="title_advanced_auto_decrypt">Automatically decrypt messages</string>
|
||||
<string name="title_advanced_recents">Hide FairEmail from screen with recent apps</string>
|
||||
<string name="title_advanced_biometrics_timeout">Biometric authentication timeout</string>
|
||||
<string name="title_advanced_pin">PIN</string>
|
||||
|
|
Loading…
Reference in a new issue