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());
} }
}); });
} }
@ -458,9 +459,9 @@ public class ConversationFragment extends Fragment {
protected void highlightInConference(String nick) { protected void highlightInConference(String nick) {
String oldString = chatMsg.getText().toString().trim(); String oldString = chatMsg.getText().toString().trim();
if (oldString.isEmpty()) { if (oldString.isEmpty()) {
chatMsg.setText(nick+": "); chatMsg.setText(nick + ": ");
} else { } else {
chatMsg.setText(oldString+" "+nick+" "); chatMsg.setText(oldString + " " + nick + " ");
} }
int position = chatMsg.length(); int position = chatMsg.length();
Editable etext = chatMsg.getText(); Editable etext = chatMsg.getText();
@ -678,62 +679,74 @@ 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(
ConversationActivity.REQUEST_ENCRYPT_MESSAGE); pi,
} ConversationActivity.REQUEST_ENCRYPT_MESSAGE);
}
@Override @Override
public void success() { public void success() {
activity.encryptTextMessage(); activity.encryptTextMessage();
} }
@Override @Override
public void error(int error) { public void error(int error) {
} }
}); });
} 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) {
message.setEncryption(Message.ENCRYPTION_NONE); conversation
xmppService.sendMessage(message, null); .setNextEncryption(Message.ENCRYPTION_NONE);
chatMsg.setText(""); message.setEncryption(Message.ENCRYPTION_NONE);
} xmppService.sendMessage(message, null);
}); chatMsg.setText("");
}
});
} }
} 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) {
message.setEncryption(Message.ENCRYPTION_NONE); conversation
xmppService.sendMessage(message, null); .setNextEncryption(Message.ENCRYPTION_NONE);
chatMsg.setText(""); message.setEncryption(Message.ENCRYPTION_NONE);
} xmppService.sendMessage(message, null);
}); chatMsg.setText("");
}
});
} }
} }
} }
} }
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) {