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,15 +459,15 @@ 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();
Selection.setSelection(etext, position); Selection.setSelection(etext, position);
} }
protected Bitmap findSelfPicture() { protected Bitmap findSelfPicture() {
SharedPreferences sharedPref = PreferenceManager SharedPreferences sharedPref = PreferenceManager
.getDefaultSharedPreferences(getActivity() .getDefaultSharedPreferences(getActivity()
@ -507,7 +508,7 @@ public class ConversationFragment extends Fragment {
if (this.pastedText == null) { if (this.pastedText == null) {
this.chatMsg.setText(oldString); this.chatMsg.setText(oldString);
} else { } else {
if (oldString.isEmpty()) { if (oldString.isEmpty()) {
chatMsg.setText(pastedText); chatMsg.setText(pastedText);
} else { } else {
@ -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
public void userInputRequried(PendingIntent pi) { @Override
activity.runIntent(pi, public void userInputRequried(PendingIntent pi) {
ConversationActivity.REQUEST_ENCRYPT_MESSAGE); activity.runIntent(
} pi,
ConversationActivity.REQUEST_ENCRYPT_MESSAGE);
@Override }
public void success() {
activity.encryptTextMessage(); @Override
} public void success() {
activity.encryptTextMessage();
@Override }
public void error(int error) {
@Override
} public void error(int error) {
});
}
});
} else { } else {
showNoPGPKeyDialog(false,new DialogInterface.OnClickListener() { showNoPGPKeyDialog(false,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) { @Override
conversation.setNextEncryption(Message.ENCRYPTION_NONE); public void onClick(DialogInterface dialog,
message.setEncryption(Message.ENCRYPTION_NONE); int which) {
xmppService.sendMessage(message, null); conversation
chatMsg.setText(""); .setNextEncryption(Message.ENCRYPTION_NONE);
} 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
public void onClick(DialogInterface dialog, int which) { @Override
conversation.setNextEncryption(Message.ENCRYPTION_NONE); public void onClick(DialogInterface dialog,
message.setEncryption(Message.ENCRYPTION_NONE); int which) {
xmppService.sendMessage(message, null); conversation
chatMsg.setText(""); .setNextEncryption(Message.ENCRYPTION_NONE);
} 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) {