Added axolotl activation code to UI
This commit is contained in:
parent
77619b55e4
commit
065519d3f3
|
@ -758,6 +758,15 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Message.ENCRYPTION_AXOLOTL:
|
||||||
|
try {
|
||||||
|
packet = mMessageGenerator.generateAxolotlChat(message);
|
||||||
|
Log.d(Config.LOGTAG, "Succeeded generating axolotl chat message!");
|
||||||
|
} catch (NoSessionsCreatedException e) {
|
||||||
|
message.setStatus(Message.STATUS_WAITING);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
if (account.getXmppConnection().getFeatures().sm() || conversation.getMode() == Conversation.MODE_MULTI) {
|
if (account.getXmppConnection().getFeatures().sm() || conversation.getMode() == Conversation.MODE_MULTI) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ import android.widget.QuickContactBadge;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||||
|
import org.whispersystems.libaxolotl.IdentityKey;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -376,6 +377,25 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
for(final IdentityKey identityKey:contact.getAxolotlIdentityKeys()) {
|
||||||
|
hasKeys = true;
|
||||||
|
View view = inflater.inflate(R.layout.contact_key, keys, false);
|
||||||
|
TextView key = (TextView) view.findViewById(R.id.key);
|
||||||
|
TextView keyType = (TextView) view.findViewById(R.id.key_type);
|
||||||
|
ImageButton remove = (ImageButton) view
|
||||||
|
.findViewById(R.id.button_remove);
|
||||||
|
remove.setVisibility(View.VISIBLE);
|
||||||
|
keyType.setText("Axolotl Fingerprint");
|
||||||
|
key.setText(identityKey.getFingerprint());
|
||||||
|
keys.addView(view);
|
||||||
|
remove.setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
//confirmToDeleteFingerprint(otrFingerprint);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
if (contact.getPgpKeyId() != 0) {
|
if (contact.getPgpKeyId() != 0) {
|
||||||
hasKeys = true;
|
hasKeys = true;
|
||||||
View view = inflater.inflate(R.layout.contact_key, keys, false);
|
View view = inflater.inflate(R.layout.contact_key, keys, false);
|
||||||
|
|
|
@ -16,6 +16,7 @@ import android.os.Bundle;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.support.v4.widget.SlidingPaneLayout;
|
import android.support.v4.widget.SlidingPaneLayout;
|
||||||
import android.support.v4.widget.SlidingPaneLayout.PanelSlideListener;
|
import android.support.v4.widget.SlidingPaneLayout.PanelSlideListener;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -34,6 +35,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
import eu.siacs.conversations.entities.Blockable;
|
import eu.siacs.conversations.entities.Blockable;
|
||||||
|
@ -749,6 +751,17 @@ public class ConversationActivity extends XmppActivity
|
||||||
showInstallPgpDialog();
|
showInstallPgpDialog();
|
||||||
}
|
}
|
||||||
break;
|
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();
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
conversation.setNextEncryption(Message.ENCRYPTION_NONE);
|
conversation.setNextEncryption(Message.ENCRYPTION_NONE);
|
||||||
break;
|
break;
|
||||||
|
@ -780,6 +793,11 @@ public class ConversationActivity extends XmppActivity
|
||||||
case Message.ENCRYPTION_PGP:
|
case Message.ENCRYPTION_PGP:
|
||||||
pgp.setChecked(true);
|
pgp.setChecked(true);
|
||||||
break;
|
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;
|
||||||
default:
|
default:
|
||||||
none.setChecked(true);
|
none.setChecked(true);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -303,6 +303,8 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
||||||
sendOtrMessage(message);
|
sendOtrMessage(message);
|
||||||
} else if (conversation.getNextEncryption(activity.forceEncryption()) == Message.ENCRYPTION_PGP) {
|
} else if (conversation.getNextEncryption(activity.forceEncryption()) == Message.ENCRYPTION_PGP) {
|
||||||
sendPgpMessage(message);
|
sendPgpMessage(message);
|
||||||
|
} else if (conversation.getNextEncryption(activity.forceEncryption()) == Message.ENCRYPTION_AXOLOTL) {
|
||||||
|
sendAxolotlMessage(message);
|
||||||
} else {
|
} else {
|
||||||
sendPlainTextMessage(message);
|
sendPlainTextMessage(message);
|
||||||
}
|
}
|
||||||
|
@ -1120,6 +1122,14 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void sendAxolotlMessage(final Message message) {
|
||||||
|
final ConversationActivity activity = (ConversationActivity) getActivity();
|
||||||
|
final XmppConnectionService xmppService = activity.xmppConnectionService;
|
||||||
|
//message.setCounterpart(conversation.getNextCounterpart());
|
||||||
|
xmppService.sendMessage(message);
|
||||||
|
messageSent();
|
||||||
|
}
|
||||||
|
|
||||||
protected void sendOtrMessage(final Message message) {
|
protected void sendOtrMessage(final Message message) {
|
||||||
final ConversationActivity activity = (ConversationActivity) getActivity();
|
final ConversationActivity activity = (ConversationActivity) getActivity();
|
||||||
final XmppConnectionService xmppService = activity.xmppConnectionService;
|
final XmppConnectionService xmppService = activity.xmppConnectionService;
|
||||||
|
|
|
@ -266,6 +266,29 @@ 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