aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-06-22 17:10:58 +0200
committerChristian Schneppe <christian@pix-art.de>2019-06-22 17:10:58 +0200
commit0d9f3ae619724ad75d2b42f4e30eb3955aa5379d (patch)
tree3f03e013eb3368dcb2a6d81ad42426a378d1d451
parent9e3a701cb0d84f1314c51dd52b8cd2c311d8b873 (diff)
change behavior of unencrypted chats warning
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java3
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java46
-rw-r--r--src/main/res/values/strings.xml3
3 files changed, 39 insertions, 13 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index c0c6c91d9..39a18c9a3 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -860,11 +860,10 @@ public class XmppConnectionService extends Service {
}
private void storeNumberOfAccounts(int accounts) {
- //write No of accounts to file
final SharedPreferences.Editor editor = getPreferences().edit();
Log.d(Config.LOGTAG, "Number of accounts is " + accounts);
editor.putInt(SettingsActivity.NUMBER_OF_ACCOUNTS, accounts);
- editor.commit();
+ editor.apply();
}
public void reinitializeMuclumbusService() {
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index 2379afad2..bd127d443 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -121,6 +121,7 @@ import de.pixart.messenger.xmpp.chatstate.ChatState;
import de.pixart.messenger.xmpp.jingle.JingleConnection;
import rocks.xmpp.addr.Jid;
+import static de.pixart.messenger.ui.SettingsActivity.WARN_UNENCRYPTED_CHAT;
import static de.pixart.messenger.ui.XmppActivity.EXTRA_ACCOUNT;
import static de.pixart.messenger.ui.XmppActivity.REQUEST_INVITE_TO_CONVERSATION;
import static de.pixart.messenger.ui.util.SoftKeyboardUtils.hideSoftKeyboard;
@@ -376,17 +377,17 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
return true;
};
- private OnClickListener mHideUnencryptionHint = new OnClickListener() {
- @Override
- public void onClick(View v) {
- if (Config.supportOmemo() && Conversation.suitableForOmemoByDefault(conversation) && conversation.isSingleOrPrivateAndNonAnonymous()) {
- conversation.setNextEncryption(Message.ENCRYPTION_AXOLOTL);
- activity.xmppConnectionService.updateConversation(conversation);
- activity.refreshUi();
- }
- hideSnackbar();
+ private OnClickListener mHideUnencryptionHint = v -> enableMessageEncryption();
+
+ private void enableMessageEncryption() {
+ if (Config.supportOmemo() && Conversation.suitableForOmemoByDefault(conversation) && conversation.isSingleOrPrivateAndNonAnonymous()) {
+ conversation.setNextEncryption(Message.ENCRYPTION_AXOLOTL);
+ activity.xmppConnectionService.updateConversation(conversation);
+ activity.refreshUi();
}
- };
+ hideSnackbar();
+ }
+
private OnClickListener mAllowPresenceSubscription = new OnClickListener() {
@Override
public void onClick(View v) {
@@ -2439,7 +2440,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
if (ENCRYPTION_EXCEPTIONS.contains(conversation.getJid().toString()) || conversation.getJid().toString().equals(account.getJid().getDomain())) {
hideSnackbar();
} else {
- showSnackbar(R.string.conversation_unencrypted_hint, R.string.ok, mHideUnencryptionHint, null);
+ showSnackbar(R.string.conversation_unencrypted_hint, R.string.ok, showUnencryptionHintDialog);
}
} else {
hideSnackbar();
@@ -2449,6 +2450,29 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
}
}
+ private OnClickListener showUnencryptionHintDialog = new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ activity.runOnUiThread(() -> {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+ builder.setTitle(getString(R.string.message_encryption));
+ builder.setMessage(getString(R.string.enable_message_encryption));
+ builder.setNegativeButton(getString(R.string.cancel), null);
+ builder.setPositiveButton(getString(R.string.enable),
+ (dialog, which) -> {
+ enableMessageEncryption();
+ });
+ builder.setNeutralButton(getString(R.string.hide_warning),
+ (dialog, which) -> {
+ SharedPreferences preferences = activity.getPreferences();
+ preferences.edit().putBoolean(WARN_UNENCRYPTED_CHAT, false).apply();
+ hideSnackbar();
+ });
+ builder.create().show();
+ });
+ }
+ };
+
@Override
public void refresh() {
if (this.binding == null) {
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 496c84d0d..5e91fe3d9 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -916,4 +916,7 @@
<string name="no_backup_available">No backup available</string>
<string name="pref_show_own_accounts_summary">Show own accounts in chats and contacts if you have multiple accounts.</string>
<string name="pref_show_own_accounts">Show own accounts</string>
+ <string name="message_encryption">Message encryption</string>
+ <string name="enable_message_encryption">This chat is unencrypted. For security reasons you should enable message encryption, prefareable OMEMO. If anything isn\'t working for you, you could disbale message encryption by pressing the key lock icon.</string>
+ <string name="hide_warning">Hide warning</string>
</resources>