more informative dialog if contact doesn't announce public key
This commit is contained in:
parent
dc73a25ae4
commit
0ed29c1c77
|
@ -84,4 +84,6 @@
|
||||||
<string name="restart">Restart</string>
|
<string name="restart">Restart</string>
|
||||||
<string name="install">Install</string>
|
<string name="install">Install</string>
|
||||||
<string name="offering">offering…</string>
|
<string name="offering">offering…</string>
|
||||||
|
<string name="no_pgp_key">No openPGP Key found</string>
|
||||||
|
<string name="contact_has_no_pgp_key">Conversations is unable to encrypt your messages because your contact is not announcing his or hers public key.\n\n<small>Please ask your contact to setup openPGP.</small></string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -341,9 +341,11 @@ public class ConversationActivity extends XmppActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void attachFile() {
|
private void attachFile() {
|
||||||
if (getSelectedConversation().getNextEncryption() == Message.ENCRYPTION_PGP) {
|
final Conversation conversation = getSelectedConversation();
|
||||||
|
if (conversation.getNextEncryption() == Message.ENCRYPTION_PGP) {
|
||||||
if (hasPgp()) {
|
if (hasPgp()) {
|
||||||
xmppConnectionService.getPgpEngine().hasKey(getSelectedConversation().getContact(), new OnPgpEngineResult() {
|
if (conversation.getContact().getPgpKeyId()!=0) {
|
||||||
|
xmppConnectionService.getPgpEngine().hasKey(conversation.getContact(), new OnPgpEngineResult() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void userInputRequried(PendingIntent pi) {
|
public void userInputRequried(PendingIntent pi) {
|
||||||
|
@ -361,6 +363,20 @@ public class ConversationActivity extends XmppActivity {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
final ConversationFragment fragment = (ConversationFragment) getFragmentManager()
|
||||||
|
.findFragmentByTag("conversation");
|
||||||
|
if (fragment != null) {
|
||||||
|
fragment.showNoPGPKeyDialog(new OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
conversation.setNextEncryption(Message.ENCRYPTION_NONE);
|
||||||
|
attachFileDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (getSelectedConversation().getNextEncryption() == Message.ENCRYPTION_NONE) {
|
} else if (getSelectedConversation().getNextEncryption() == Message.ENCRYPTION_NONE) {
|
||||||
attachFileDialog();
|
attachFileDialog();
|
||||||
|
|
|
@ -718,14 +718,7 @@ public class ConversationFragment extends Fragment {
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(
|
showNoPGPKeyDialog(new DialogInterface.OnClickListener() {
|
||||||
getActivity());
|
|
||||||
builder.setTitle("No openPGP key found");
|
|
||||||
builder.setIconAttribute(android.R.attr.alertDialogIcon);
|
|
||||||
builder.setMessage("There is no openPGP key associated with this contact");
|
|
||||||
builder.setNegativeButton("Cancel", null);
|
|
||||||
builder.setPositiveButton("Send plain text",
|
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog,
|
||||||
|
@ -737,10 +730,20 @@ public class ConversationFragment extends Fragment {
|
||||||
chatMsg.setText("");
|
chatMsg.setText("");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showNoPGPKeyDialog(DialogInterface.OnClickListener listener) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||||
|
getActivity());
|
||||||
|
builder.setTitle(getString(R.string.no_pgp_key));
|
||||||
|
builder.setIconAttribute(android.R.attr.alertDialogIcon);
|
||||||
|
builder.setMessage(getText(R.string.contact_has_no_pgp_key));
|
||||||
|
builder.setNegativeButton(getString(R.string.cancel), null);
|
||||||
|
builder.setPositiveButton(getString(R.string.send_unencrypted),listener);
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void sendOtrMessage(final Message message) {
|
protected void sendOtrMessage(final Message message) {
|
||||||
ConversationActivity activity = (ConversationActivity) getActivity();
|
ConversationActivity activity = (ConversationActivity) getActivity();
|
||||||
|
|
Loading…
Reference in a new issue