aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorChristian Schneppe <christian.schneppe@pix-art.de>2019-11-02 17:18:45 +0100
committerChristian Schneppe <christian.schneppe@pix-art.de>2019-11-02 17:18:45 +0100
commit06949b76490736783520d783f0ec889e58707062 (patch)
tree946b6a6d16ba1d03ee2e82dbba79e2a6b8c128e3 /src/main/java
parentf81d60f9a84ebe491b9343f4dfbdf0e893100cd3 (diff)
introduce setting to completely disable (OMEMO) encryption
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/de/pixart/messenger/crypto/OmemoSetting.java13
-rw-r--r--src/main/java/de/pixart/messenger/entities/Conversation.java3
-rw-r--r--src/main/java/de/pixart/messenger/ui/SettingsActivity.java3
-rw-r--r--src/main/java/de/pixart/messenger/ui/util/ConversationMenuConfigurator.java2
4 files changed, 20 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/crypto/OmemoSetting.java b/src/main/java/de/pixart/messenger/crypto/OmemoSetting.java
index 19fd6f9c0..973b44545 100644
--- a/src/main/java/de/pixart/messenger/crypto/OmemoSetting.java
+++ b/src/main/java/de/pixart/messenger/crypto/OmemoSetting.java
@@ -39,12 +39,17 @@ import de.pixart.messenger.ui.SettingsActivity;
public class OmemoSetting {
private static boolean always = false;
+ private static boolean never = false;
private static int encryption = Message.ENCRYPTION_AXOLOTL;
public static boolean isAlways() {
return always;
}
+ public static boolean isNever() {
+ return never;
+ }
+
public static int getEncryption() {
return encryption;
}
@@ -54,14 +59,22 @@ public class OmemoSetting {
switch (value) {
case "always":
always = true;
+ never = false;
encryption = Message.ENCRYPTION_AXOLOTL;
break;
case "default_on":
always = false;
+ never = false;
encryption = Message.ENCRYPTION_AXOLOTL;
break;
+ case "always_off":
+ always = false;
+ never = true;
+ encryption = Message.ENCRYPTION_NONE;
+ break;
default:
always = false;
+ never = false;
encryption = Message.ENCRYPTION_NONE;
break;
diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java
index b20976316..cc0d5525f 100644
--- a/src/main/java/de/pixart/messenger/entities/Conversation.java
+++ b/src/main/java/de/pixart/messenger/entities/Conversation.java
@@ -805,6 +805,9 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
if (OmemoSetting.isAlways()) {
return suitableForOmemoByDefault(this) ? Message.ENCRYPTION_AXOLOTL : Message.ENCRYPTION_NONE;
}
+ if (OmemoSetting.isNever()) {
+ return Message.ENCRYPTION_NONE;
+ }
final int defaultEncryption;
if (suitableForOmemoByDefault(this)) {
defaultEncryption = OmemoSetting.getEncryption();
diff --git a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java
index e57030a61..419785ecf 100644
--- a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java
@@ -370,6 +370,9 @@ public class SettingsActivity extends XmppActivity implements
case "default_off":
omemoPreference.setSummary(R.string.pref_omemo_setting_summary_default_off);
break;
+ case "always_off":
+ omemoPreference.setSummary(R.string.pref_omemo_setting_summary_always_off);
+ break;
}
} else {
Log.d(Config.LOGTAG, "unable to find preference named " + OMEMO_SETTING);
diff --git a/src/main/java/de/pixart/messenger/ui/util/ConversationMenuConfigurator.java b/src/main/java/de/pixart/messenger/ui/util/ConversationMenuConfigurator.java
index fd5a5c441..cb4211b1e 100644
--- a/src/main/java/de/pixart/messenger/ui/util/ConversationMenuConfigurator.java
+++ b/src/main/java/de/pixart/messenger/ui/util/ConversationMenuConfigurator.java
@@ -106,7 +106,7 @@ public class ConversationMenuConfigurator {
final int next = conversation.getNextEncryption();
boolean visible;
- if (OmemoSetting.isAlways()) {
+ if (OmemoSetting.isAlways() || OmemoSetting.isNever()) {
visible = false;
} else if (conversation.getMode() == Conversation.MODE_MULTI) {
if (next == Message.ENCRYPTION_NONE && !conversation.isPrivateAndNonAnonymous() && !conversation.getBooleanAttribute(Conversation.ATTRIBUTE_FORMERLY_PRIVATE_NON_ANONYMOUS, false)) {