show dialog when no contact in a muc has pgp support
This commit is contained in:
parent
5d0e1374b2
commit
1a4b1f8a2f
|
@ -115,6 +115,8 @@
|
||||||
<string name="offering">offering…</string>
|
<string name="offering">offering…</string>
|
||||||
<string name="no_pgp_key">No OpenPGP Key found</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>
|
<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>
|
||||||
|
<string name="no_pgp_keys">No OpenPGP Keys found</string>
|
||||||
|
<string name="contacts_have_no_pgp_keys">Conversations is unable to encrypt your messages because your contacts are not announcing their public key.\n\n<small>Please ask your contacts to setup OpenPGP.</small></string>
|
||||||
<string name="encrypted_message_received"><i>Encrypted message received. Touch to view and decrypt.</i></string>
|
<string name="encrypted_message_received"><i>Encrypted message received. Touch to view and decrypt.</i></string>
|
||||||
<string name="encrypted_image_received"><i>Encrypted image received. Touch to view and decrypt.</i></string>
|
<string name="encrypted_image_received"><i>Encrypted image received. Touch to view and decrypt.</i></string>
|
||||||
<string name="image_file"><i>Image received. Touch to view</i></string>
|
<string name="image_file"><i>Image received. Touch to view</i></string>
|
||||||
|
|
|
@ -250,4 +250,22 @@ public class MucOptions {
|
||||||
}
|
}
|
||||||
return primitivLongArray;
|
return primitivLongArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean pgpKeysInUse() {
|
||||||
|
for(User user : getUsers()) {
|
||||||
|
if (user.getPgpKeyId()!=0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean everybodyHasKeys() {
|
||||||
|
for(User user : getUsers()) {
|
||||||
|
if (user.getPgpKeyId()==0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -396,7 +396,7 @@ public class ConversationActivity extends XmppActivity {
|
||||||
final ConversationFragment fragment = (ConversationFragment) getFragmentManager()
|
final ConversationFragment fragment = (ConversationFragment) getFragmentManager()
|
||||||
.findFragmentByTag("conversation");
|
.findFragmentByTag("conversation");
|
||||||
if (fragment != null) {
|
if (fragment != null) {
|
||||||
fragment.showNoPGPKeyDialog(new OnClickListener() {
|
fragment.showNoPGPKeyDialog(false,new OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
|
|
@ -701,7 +701,7 @@ public class ConversationFragment extends Fragment {
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
showNoPGPKeyDialog(new DialogInterface.OnClickListener() {
|
showNoPGPKeyDialog(false,new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
@ -713,16 +713,34 @@ public class ConversationFragment extends Fragment {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (conversation.getMucOptions().pgpKeysInUse()) {
|
||||||
activity.encryptTextMessage();
|
activity.encryptTextMessage();
|
||||||
|
} else {
|
||||||
|
showNoPGPKeyDialog(true,new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
conversation.setNextEncryption(Message.ENCRYPTION_NONE);
|
||||||
|
message.setEncryption(Message.ENCRYPTION_NONE);
|
||||||
|
xmppService.sendMessage(message, null);
|
||||||
|
chatMsg.setText("");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showNoPGPKeyDialog(DialogInterface.OnClickListener listener) {
|
public void showNoPGPKeyDialog(boolean plural, DialogInterface.OnClickListener listener) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
builder.setTitle(getString(R.string.no_pgp_key));
|
|
||||||
builder.setIconAttribute(android.R.attr.alertDialogIcon);
|
builder.setIconAttribute(android.R.attr.alertDialogIcon);
|
||||||
|
if (plural) {
|
||||||
|
builder.setTitle(getString(R.string.no_pgp_keys));
|
||||||
|
builder.setMessage(getText(R.string.contacts_have_no_pgp_keys));
|
||||||
|
} else {
|
||||||
|
builder.setTitle(getString(R.string.no_pgp_key));
|
||||||
builder.setMessage(getText(R.string.contact_has_no_pgp_key));
|
builder.setMessage(getText(R.string.contact_has_no_pgp_key));
|
||||||
|
}
|
||||||
builder.setNegativeButton(getString(R.string.cancel), null);
|
builder.setNegativeButton(getString(R.string.cancel), null);
|
||||||
builder.setPositiveButton(getString(R.string.send_unencrypted),
|
builder.setPositiveButton(getString(R.string.send_unencrypted),
|
||||||
listener);
|
listener);
|
||||||
|
|
Loading…
Reference in a new issue