From a0cbbd2d21cf68d8d31273c71fcbd371c15abd9d Mon Sep 17 00:00:00 2001 From: Jake McGinty Date: Thu, 20 Feb 2014 11:42:15 -0800 Subject: [PATCH] confirm session abort handler in ConversationItem // FREEBIE --- .../securesms/ConversationItem.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/org/thoughtcrime/securesms/ConversationItem.java b/src/org/thoughtcrime/securesms/ConversationItem.java index 3173eb38d5..ff353e1ff1 100644 --- a/src/org/thoughtcrime/securesms/ConversationItem.java +++ b/src/org/thoughtcrime/securesms/ConversationItem.java @@ -53,6 +53,7 @@ import org.thoughtcrime.securesms.util.BitmapUtil; import org.thoughtcrime.securesms.util.DateUtils; import org.thoughtcrime.securesms.util.Emoji; import org.whispersystems.textsecure.crypto.MasterSecret; +import org.whispersystems.textsecure.storage.Session; import org.whispersystems.textsecure.util.FutureTaskListener; import org.whispersystems.textsecure.util.ListenableFutureTask; @@ -134,6 +135,8 @@ public class ConversationItem extends LinearLayout { public void set(MasterSecret masterSecret, MessageRecord messageRecord, Handler failedIconHandler, boolean groupThread) { + + this.messageRecord = messageRecord; this.masterSecret = masterSecret; this.failedIconHandler = failedIconHandler; @@ -549,4 +552,24 @@ public class ConversationItem extends LinearLayout { } } + private void handleAbortSecureSession() { + if (!messageRecord.isSecure()) return; + + AlertDialog.Builder builder = new AlertDialog.Builder(context); + builder.setTitle(R.string.ConversationActivity_abort_secure_session_confirmation); + builder.setIcon(android.R.drawable.ic_dialog_alert); + builder.setCancelable(true); + builder.setMessage(R.string.ConversationActivity_are_you_sure_that_you_want_to_abort_this_secure_session_question); + builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + if (messageRecord.getRecipients().isSingleRecipient()) { + Recipient recipient = messageRecord.getRecipients().getPrimaryRecipient(); + Session.abortSessionFor(context, recipient); + } + } + }); + builder.setNegativeButton(R.string.no, null); + builder.show(); + } }