Retry decryption from message menu

This commit is contained in:
fiaxh 2016-02-23 15:30:41 +01:00
parent 689ded1607
commit 894b5892a9
5 changed files with 21 additions and 2 deletions

View file

@ -449,6 +449,7 @@ public class Message extends AbstractEntity {
this.getTransferable() == null && this.getTransferable() == null &&
message.getTransferable() == null && message.getTransferable() == null &&
message.getEncryption() != Message.ENCRYPTION_PGP && message.getEncryption() != Message.ENCRYPTION_PGP &&
message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED &&
this.getType() == message.getType() && this.getType() == message.getType() &&
//this.getStatus() == message.getStatus() && //this.getStatus() == message.getStatus() &&
isStatusMergeable(this.getStatus(), message.getStatus()) && isStatusMergeable(this.getStatus(), message.getStatus()) &&

View file

@ -523,6 +523,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
activity.getMenuInflater().inflate(R.menu.message_context, menu); activity.getMenuInflater().inflate(R.menu.message_context, menu);
menu.setHeaderTitle(R.string.message_options); menu.setHeaderTitle(R.string.message_options);
MenuItem copyText = menu.findItem(R.id.copy_text); MenuItem copyText = menu.findItem(R.id.copy_text);
MenuItem retryDecryption = menu.findItem(R.id.retry_decryption);
MenuItem correctMessage = menu.findItem(R.id.correct_message); MenuItem correctMessage = menu.findItem(R.id.correct_message);
MenuItem shareWith = menu.findItem(R.id.share_with); MenuItem shareWith = menu.findItem(R.id.share_with);
MenuItem sendAgain = menu.findItem(R.id.send_again); MenuItem sendAgain = menu.findItem(R.id.send_again);
@ -535,6 +536,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
&& m.treatAsDownloadable() != Message.Decision.MUST) { && m.treatAsDownloadable() != Message.Decision.MUST) {
copyText.setVisible(true); copyText.setVisible(true);
} }
if (m.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
retryDecryption.setVisible(true);
}
if (relevantForCorrection.getType() == Message.TYPE_TEXT if (relevantForCorrection.getType() == Message.TYPE_TEXT
&& relevantForCorrection.isLastCorrectableMessage()) { && relevantForCorrection.isLastCorrectableMessage()) {
correctMessage.setVisible(true); correctMessage.setVisible(true);
@ -590,6 +594,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
case R.id.cancel_transmission: case R.id.cancel_transmission:
cancelTransmission(selectedMessage); cancelTransmission(selectedMessage);
return true; return true;
case R.id.retry_decryption:
retryDecryption(selectedMessage);
return true;
default: default:
return super.onContextItemSelected(item); return super.onContextItemSelected(item);
} }
@ -673,6 +680,12 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
} }
} }
private void retryDecryption(Message message) {
message.setEncryption(Message.ENCRYPTION_PGP);
activity.xmppConnectionService.updateConversationUi();
conversation.getAccount().getPgpDecryptionService().add(message);
}
protected void privateMessageWith(final Jid counterpart) { protected void privateMessageWith(final Jid counterpart) {
this.mEditMessage.setText(""); this.mEditMessage.setText("");
this.conversation.setNextCounterpart(counterpart); this.conversation.setNextCounterpart(counterpart);

View file

@ -171,7 +171,9 @@ public class UIHelper {
return new Pair<>("",false); return new Pair<>("",false);
} }
} else if (message.getEncryption() == Message.ENCRYPTION_PGP) { } else if (message.getEncryption() == Message.ENCRYPTION_PGP) {
return new Pair<>(context.getString(R.string.encrypted_message_received),true); return new Pair<>(context.getString(R.string.pgp_message),true);
} else if (message.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
return new Pair<>(context.getString(R.string.decryption_failed), true);
} else if (message.getType() == Message.TYPE_FILE || message.getType() == Message.TYPE_IMAGE) { } else if (message.getType() == Message.TYPE_FILE || message.getType() == Message.TYPE_IMAGE) {
if (message.getStatus() == Message.STATUS_RECEIVED) { if (message.getStatus() == Message.STATUS_RECEIVED) {
return new Pair<>(context.getString(R.string.received_x_file, return new Pair<>(context.getString(R.string.received_x_file,

View file

@ -5,6 +5,10 @@
android:id="@+id/copy_text" android:id="@+id/copy_text"
android:title="@string/copy_text" android:title="@string/copy_text"
android:visible="false"/> android:visible="false"/>
<item
android:id="@+id/retry_decryption"
android:title="Retry decryption"
android:visible="false"/>
<item <item
android:id="@+id/correct_message" android:id="@+id/correct_message"
android:title="@string/correct_message" android:title="@string/correct_message"

View file

@ -97,7 +97,6 @@
<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="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="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 decrypt.</i></string>
<string name="pref_general">General</string> <string name="pref_general">General</string>
<string name="pref_xmpp_resource">XMPP resource</string> <string name="pref_xmpp_resource">XMPP resource</string>
<string name="pref_xmpp_resource_summary">The name this client identifies itself with</string> <string name="pref_xmpp_resource_summary">The name this client identifies itself with</string>