Disable Axolotl option if not usable
In MUCs or if contact is not axolotl capable, disable axolotl menu option
This commit is contained in:
parent
9e8d9a6401
commit
6c38e53128
|
@ -37,6 +37,7 @@ import java.util.List;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
|
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
import eu.siacs.conversations.entities.Blockable;
|
import eu.siacs.conversations.entities.Blockable;
|
||||||
import eu.siacs.conversations.entities.Contact;
|
import eu.siacs.conversations.entities.Contact;
|
||||||
|
@ -752,15 +753,10 @@ public class ConversationActivity extends XmppActivity
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.encryption_choice_axolotl:
|
case R.id.encryption_choice_axolotl:
|
||||||
Log.d(Config.LOGTAG, "Trying to enable axolotl...");
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(conversation.getAccount())
|
||||||
if(conversation.getAccount().getAxolotlService().isContactAxolotlCapable(conversation.getContact())) {
|
+ "Enabled axolotl for Contact " + conversation.getContact().getJid());
|
||||||
Log.d(Config.LOGTAG, "Enabled axolotl for Contact " + conversation.getContact().getJid() );
|
|
||||||
conversation.setNextEncryption(Message.ENCRYPTION_AXOLOTL);
|
conversation.setNextEncryption(Message.ENCRYPTION_AXOLOTL);
|
||||||
item.setChecked(true);
|
item.setChecked(true);
|
||||||
} else {
|
|
||||||
Log.d(Config.LOGTAG, "Contact " + conversation.getContact().getJid() + " not axolotl capable!");
|
|
||||||
showAxolotlNoSessionsDialog();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
conversation.setNextEncryption(Message.ENCRYPTION_NONE);
|
conversation.setNextEncryption(Message.ENCRYPTION_NONE);
|
||||||
|
@ -776,13 +772,18 @@ public class ConversationActivity extends XmppActivity
|
||||||
MenuItem otr = popup.getMenu().findItem(R.id.encryption_choice_otr);
|
MenuItem otr = popup.getMenu().findItem(R.id.encryption_choice_otr);
|
||||||
MenuItem none = popup.getMenu().findItem(R.id.encryption_choice_none);
|
MenuItem none = popup.getMenu().findItem(R.id.encryption_choice_none);
|
||||||
MenuItem pgp = popup.getMenu().findItem(R.id.encryption_choice_pgp);
|
MenuItem pgp = popup.getMenu().findItem(R.id.encryption_choice_pgp);
|
||||||
|
MenuItem axolotl = popup.getMenu().findItem(R.id.encryption_choice_axolotl);
|
||||||
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
||||||
otr.setEnabled(false);
|
otr.setEnabled(false);
|
||||||
|
axolotl.setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
if (forceEncryption()) {
|
if (forceEncryption()) {
|
||||||
none.setVisible(false);
|
none.setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!conversation.getAccount().getAxolotlService().isContactAxolotlCapable(conversation.getContact())) {
|
||||||
|
axolotl.setEnabled(false);
|
||||||
|
}
|
||||||
switch (conversation.getNextEncryption(forceEncryption())) {
|
switch (conversation.getNextEncryption(forceEncryption())) {
|
||||||
case Message.ENCRYPTION_NONE:
|
case Message.ENCRYPTION_NONE:
|
||||||
none.setChecked(true);
|
none.setChecked(true);
|
||||||
|
@ -794,7 +795,6 @@ public class ConversationActivity extends XmppActivity
|
||||||
pgp.setChecked(true);
|
pgp.setChecked(true);
|
||||||
break;
|
break;
|
||||||
case Message.ENCRYPTION_AXOLOTL:
|
case Message.ENCRYPTION_AXOLOTL:
|
||||||
Log.d(Config.LOGTAG, "Axolotl confirmed. Setting menu item checked!");
|
|
||||||
popup.getMenu().findItem(R.id.encryption_choice_axolotl)
|
popup.getMenu().findItem(R.id.encryption_choice_axolotl)
|
||||||
.setChecked(true);
|
.setChecked(true);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -266,29 +266,6 @@ public abstract class XmppActivity extends Activity {
|
||||||
builder.create().show();
|
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();
|
abstract void onBackendConnected();
|
||||||
|
|
||||||
protected void registerListeners() {
|
protected void registerListeners() {
|
||||||
|
|
Loading…
Reference in New Issue