diff options
Diffstat (limited to '')
-rw-r--r-- | src/eu/siacs/conversations/ui/ConversationFragment.java | 104 |
1 files changed, 49 insertions, 55 deletions
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java index b0e9d79b..b551e6ad 100644 --- a/src/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/eu/siacs/conversations/ui/ConversationFragment.java @@ -263,7 +263,7 @@ public class ConversationFragment extends Fragment { } private void displayInfoMessage(ViewHolder viewHolder, int r) { - if (viewHolder.download_button!=null) { + if (viewHolder.download_button != null) { viewHolder.download_button.setVisibility(View.GONE); } viewHolder.image.setVisibility(View.GONE); @@ -329,7 +329,8 @@ public class ConversationFragment extends Fragment { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setDataAndType(ImageProvider.getContentUri(message), "image/*"); + intent.setDataAndType( + ImageProvider.getContentUri(message), "image/*"); startActivity(intent); } }); @@ -486,7 +487,7 @@ public class ConversationFragment extends Fragment { @Override public void onStop() { super.onStop(); - if (this.conversation!=null) { + if (this.conversation != null) { this.conversation.setNextMessage(chatMsg.getText().toString()); } } @@ -577,13 +578,15 @@ public class ConversationFragment extends Fragment { } public void updateMessages() { - if (getView()==null) { + if (getView() == null) { return; } ConversationActivity activity = (ConversationActivity) getActivity(); if (this.conversation != null) { for (Message message : this.conversation.getMessages()) { - if ((message.getEncryption() == Message.ENCRYPTION_PGP)&&((message.getStatus() == Message.STATUS_RECIEVED)||(message.getStatus() == Message.STATUS_SEND))) { + if ((message.getEncryption() == Message.ENCRYPTION_PGP) + && ((message.getStatus() == Message.STATUS_RECIEVED) || (message + .getStatus() == Message.STATUS_SEND))) { decryptMessage(message); break; } @@ -623,31 +626,26 @@ public class ConversationFragment extends Fragment { protected void makeFingerprintWarning(int latestEncryption) { final LinearLayout fingerprintWarning = (LinearLayout) getView() .findViewById(R.id.new_fingerprint); - if (conversation.getContact() != null) { - Set<String> knownFingerprints = conversation.getContact() - .getOtrFingerprints(); - if ((latestEncryption == Message.ENCRYPTION_OTR) - && (conversation.hasValidOtrSession() - && (conversation.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) && (!knownFingerprints - .contains(conversation.getOtrFingerprint())))) { - fingerprintWarning.setVisibility(View.VISIBLE); - TextView fingerprint = (TextView) getView().findViewById( - R.id.otr_fingerprint); - fingerprint.setText(conversation.getOtrFingerprint()); - fingerprintWarning.setOnClickListener(new OnClickListener() { + Set<String> knownFingerprints = conversation.getContact() + .getOtrFingerprints(); + if ((latestEncryption == Message.ENCRYPTION_OTR) + && (conversation.hasValidOtrSession() + && (conversation.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) && (!knownFingerprints + .contains(conversation.getOtrFingerprint())))) { + fingerprintWarning.setVisibility(View.VISIBLE); + TextView fingerprint = (TextView) getView().findViewById( + R.id.otr_fingerprint); + fingerprint.setText(conversation.getOtrFingerprint()); + fingerprintWarning.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - AlertDialog dialog = UIHelper - .getVerifyFingerprintDialog( - (ConversationActivity) getActivity(), - conversation, fingerprintWarning); - dialog.show(); - } - }); - } else { - fingerprintWarning.setVisibility(View.GONE); - } + @Override + public void onClick(View v) { + AlertDialog dialog = UIHelper.getVerifyFingerprintDialog( + (ConversationActivity) getActivity(), conversation, + fingerprintWarning); + dialog.show(); + } + }); } else { fingerprintWarning.setVisibility(View.GONE); } @@ -666,35 +664,31 @@ public class ConversationFragment extends Fragment { final Contact contact = message.getConversation().getContact(); if (activity.hasPgp()) { if (contact.getPgpKeyId() != 0) { - xmppService.getPgpEngine().hasKey(contact, - new UiCallback() { - - @Override - public void userInputRequried(PendingIntent pi) { - activity.runIntent( - pi, - ConversationActivity.REQUEST_ENCRYPT_MESSAGE); - } + xmppService.getPgpEngine().hasKey(contact, new UiCallback() { - @Override - public void success() { - activity.encryptTextMessage(); - } + @Override + public void userInputRequried(PendingIntent pi) { + activity.runIntent(pi, + ConversationActivity.REQUEST_ENCRYPT_MESSAGE); + } - @Override - public void error(int error) { - - } - }); + @Override + public void success() { + activity.encryptTextMessage(); + } + + @Override + public void error(int error) { + + } + }); } else { showNoPGPKeyDialog(new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, - int which) { - conversation - .setNextEncryption(Message.ENCRYPTION_NONE); + public void onClick(DialogInterface dialog, int which) { + conversation.setNextEncryption(Message.ENCRYPTION_NONE); message.setEncryption(Message.ENCRYPTION_NONE); xmppService.sendMessage(message, null); chatMsg.setText(""); @@ -703,15 +697,15 @@ public class ConversationFragment extends Fragment { } } } - + public void showNoPGPKeyDialog(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.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.setPositiveButton(getString(R.string.send_unencrypted), + listener); builder.create().show(); } |