linked openkeychain install dialog from decrypt messages box

This commit is contained in:
iNPUTmice 2014-06-01 19:29:57 +02:00
parent c17db8e34e
commit 1982151630

View file

@ -91,7 +91,7 @@ public class ConversationFragment extends Fragment {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (askForPassphraseIntent != null) { if (activity.hasPgp() && askForPassphraseIntent != null) {
try { try {
getActivity().startIntentSenderForResult( getActivity().startIntentSenderForResult(
askForPassphraseIntent, askForPassphraseIntent,
@ -230,8 +230,8 @@ public class ConversationFragment extends Fragment {
viewHolder.indicator.setVisibility(View.VISIBLE); viewHolder.indicator.setVisibility(View.VISIBLE);
} }
String formatedTime = UIHelper.readableTimeDifference(getContext(), message String formatedTime = UIHelper.readableTimeDifference(
.getTimeSent()); getContext(), message.getTimeSent());
if (message.getStatus() <= Message.STATUS_RECIEVED) { if (message.getStatus() <= Message.STATUS_RECIEVED) {
if ((filesize != null) && (info != null)) { if ((filesize != null) && (info != null)) {
viewHolder.time.setText(filesize + " \u00B7 " + info); viewHolder.time.setText(filesize + " \u00B7 " + info);
@ -397,7 +397,8 @@ public class ConversationFragment extends Fragment {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
highlightInConference(item.getCounterpart()); highlightInConference(item
.getCounterpart());
} }
}); });
} }
@ -678,11 +679,13 @@ public class ConversationFragment extends Fragment {
if (activity.hasPgp()) { if (activity.hasPgp()) {
if (conversation.getMode() == Conversation.MODE_SINGLE) { if (conversation.getMode() == Conversation.MODE_SINGLE) {
if (contact.getPgpKeyId() != 0) { if (contact.getPgpKeyId() != 0) {
xmppService.getPgpEngine().hasKey(contact, new UiCallback() { xmppService.getPgpEngine().hasKey(contact,
new UiCallback() {
@Override @Override
public void userInputRequried(PendingIntent pi) { public void userInputRequried(PendingIntent pi) {
activity.runIntent(pi, activity.runIntent(
pi,
ConversationActivity.REQUEST_ENCRYPT_MESSAGE); ConversationActivity.REQUEST_ENCRYPT_MESSAGE);
} }
@ -698,11 +701,14 @@ public class ConversationFragment extends Fragment {
}); });
} else { } else {
showNoPGPKeyDialog(false,new DialogInterface.OnClickListener() { showNoPGPKeyDialog(false,
new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog,
conversation.setNextEncryption(Message.ENCRYPTION_NONE); int which) {
conversation
.setNextEncryption(Message.ENCRYPTION_NONE);
message.setEncryption(Message.ENCRYPTION_NONE); message.setEncryption(Message.ENCRYPTION_NONE);
xmppService.sendMessage(message, null); xmppService.sendMessage(message, null);
chatMsg.setText(""); chatMsg.setText("");
@ -712,17 +718,23 @@ public class ConversationFragment extends Fragment {
} else { } else {
if (conversation.getMucOptions().pgpKeysInUse()) { if (conversation.getMucOptions().pgpKeysInUse()) {
if (!conversation.getMucOptions().everybodyHasKeys()) { if (!conversation.getMucOptions().everybodyHasKeys()) {
Toast warning = Toast.makeText(getActivity(), R.string.missing_public_keys, Toast.LENGTH_LONG); Toast warning = Toast
.makeText(getActivity(),
R.string.missing_public_keys,
Toast.LENGTH_LONG);
warning.setGravity(Gravity.CENTER_VERTICAL, 0, 0); warning.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
warning.show(); warning.show();
} }
activity.encryptTextMessage(); activity.encryptTextMessage();
} else { } else {
showNoPGPKeyDialog(true,new DialogInterface.OnClickListener() { showNoPGPKeyDialog(true,
new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog,
conversation.setNextEncryption(Message.ENCRYPTION_NONE); int which) {
conversation
.setNextEncryption(Message.ENCRYPTION_NONE);
message.setEncryption(Message.ENCRYPTION_NONE); message.setEncryption(Message.ENCRYPTION_NONE);
xmppService.sendMessage(message, null); xmppService.sendMessage(message, null);
chatMsg.setText(""); chatMsg.setText("");
@ -733,7 +745,8 @@ public class ConversationFragment extends Fragment {
} }
} }
public void showNoPGPKeyDialog(boolean plural, 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.setIconAttribute(android.R.attr.alertDialogIcon); builder.setIconAttribute(android.R.attr.alertDialogIcon);
if (plural) { if (plural) {