aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Straub <andy@strb.org>2015-07-10 03:02:49 +0200
committerAndreas Straub <andy@strb.org>2015-07-10 03:02:49 +0200
commit8b08bdb3affa73360d955bd03ca0f074cb2670a1 (patch)
treee46915e0b714696e80b99239bc6824225ece3ac4
parent36e743159537c3d2a99cb45d48421cc905e83f32 (diff)
Disable Axolotl option if not usable
In MUCs or if contact is not axolotl capable, disable axolotl menu option
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java20
-rw-r--r--src/main/java/eu/siacs/conversations/ui/XmppActivity.java23
2 files changed, 10 insertions, 33 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index f7dca7a3..a946ec37 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -37,6 +37,7 @@ import java.util.List;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
+import eu.siacs.conversations.crypto.axolotl.AxolotlService;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Blockable;
import eu.siacs.conversations.entities.Contact;
@@ -755,15 +756,10 @@ public class ConversationActivity extends XmppActivity
}
break;
case R.id.encryption_choice_axolotl:
- Log.d(Config.LOGTAG, "Trying to enable axolotl...");
- if(conversation.getAccount().getAxolotlService().isContactAxolotlCapable(conversation.getContact())) {
- Log.d(Config.LOGTAG, "Enabled axolotl for Contact " + conversation.getContact().getJid() );
- conversation.setNextEncryption(Message.ENCRYPTION_AXOLOTL);
- item.setChecked(true);
- } else {
- Log.d(Config.LOGTAG, "Contact " + conversation.getContact().getJid() + " not axolotl capable!");
- showAxolotlNoSessionsDialog();
- }
+ Log.d(Config.LOGTAG, AxolotlService.getLogprefix(conversation.getAccount())
+ + "Enabled axolotl for Contact " + conversation.getContact().getJid());
+ conversation.setNextEncryption(Message.ENCRYPTION_AXOLOTL);
+ item.setChecked(true);
break;
default:
conversation.setNextEncryption(Message.ENCRYPTION_NONE);
@@ -777,15 +773,20 @@ public class ConversationActivity extends XmppActivity
});
popup.inflate(R.menu.encryption_choices);
MenuItem otr = popup.getMenu().findItem(R.id.encryption_choice_otr);
+ MenuItem axolotl = popup.getMenu().findItem(R.id.encryption_choice_axolotl);
MenuItem none = popup.getMenu().findItem(
R.id.encryption_choice_none);
if (conversation.getMode() == Conversation.MODE_MULTI) {
otr.setEnabled(false);
+ axolotl.setEnabled(false);
} else {
if (forceEncryption()) {
none.setVisible(false);
}
}
+ if (!conversation.getAccount().getAxolotlService().isContactAxolotlCapable(conversation.getContact())) {
+ axolotl.setEnabled(false);
+ }
switch (conversation.getNextEncryption(forceEncryption())) {
case Message.ENCRYPTION_NONE:
none.setChecked(true);
@@ -798,7 +799,6 @@ public class ConversationActivity extends XmppActivity
.setChecked(true);
break;
case Message.ENCRYPTION_AXOLOTL:
- Log.d(Config.LOGTAG, "Axolotl confirmed. Setting menu item checked!");
popup.getMenu().findItem(R.id.encryption_choice_axolotl)
.setChecked(true);
break;
diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
index e916598f..934c696f 100644
--- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
@@ -266,29 +266,6 @@ public abstract class XmppActivity extends Activity {
builder.create().show();
}
- public void showAxolotlNoSessionsDialog() {
- Builder builder = new AlertDialog.Builder(this);
- builder.setTitle("No Sessions");
- builder.setIconAttribute(android.R.attr.alertDialogIcon);
- builder.setMessage("Your contact is not Axolotl-capable!");
- builder.setNegativeButton(getString(R.string.cancel), null);
- builder.setNeutralButton("Foo",
- new OnClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
- }
- });
- builder.setPositiveButton("Bar",
- new OnClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
- }
- });
- builder.create().show();
- }
-
abstract void onBackendConnected();
protected void registerListeners() {