From c05aca19aeeb3456b4ba0676b5a38d1abd3a1fbb Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Sun, 8 Mar 2015 11:37:18 -0700 Subject: [PATCH] Minimal-diff change to fix NPE. Fixes #2623 // FREEBIE --- .../securesms/ConversationFragment.java | 9 ++++++--- .../thoughtcrime/securesms/ConversationItem.java | 7 +++++-- .../securesms/MessageDetailsActivity.java | 15 +++++++++++++-- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/org/thoughtcrime/securesms/ConversationFragment.java b/src/org/thoughtcrime/securesms/ConversationFragment.java index 14899030c2..4f61ff9bdc 100644 --- a/src/org/thoughtcrime/securesms/ConversationFragment.java +++ b/src/org/thoughtcrime/securesms/ConversationFragment.java @@ -52,7 +52,7 @@ public class ConversationFragment extends ListFragment private static final String TAG = ConversationFragment.class.getSimpleName(); private final ActionModeCallback actionModeCallback = new ActionModeCallback(); - private final SelectionClickListener selectionClickListener = new SelectionClickListener(); + private final SelectionClickListener selectionClickListener = new ConversationFragmentSelectionClickListener(); private ConversationFragmentListener listener; @@ -289,8 +289,11 @@ public class ConversationFragment extends ListFragment public void setComposeText(String text); } - public class SelectionClickListener - implements AdapterView.OnItemLongClickListener, AdapterView.OnItemClickListener + public interface SelectionClickListener extends + AdapterView.OnItemLongClickListener, AdapterView.OnItemClickListener {} + + private class ConversationFragmentSelectionClickListener + implements SelectionClickListener { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { diff --git a/src/org/thoughtcrime/securesms/ConversationItem.java b/src/org/thoughtcrime/securesms/ConversationItem.java index ca63bf5172..4ae459eb7e 100644 --- a/src/org/thoughtcrime/securesms/ConversationItem.java +++ b/src/org/thoughtcrime/securesms/ConversationItem.java @@ -29,6 +29,7 @@ import android.os.Handler; import android.os.Message; import android.provider.ContactsContract; import android.provider.ContactsContract.QuickContact; +import android.support.annotation.NonNull; import android.util.AttributeSet; import android.util.Log; import android.view.View; @@ -162,8 +163,10 @@ public class ConversationItem extends LinearLayout { if (mmsThumbnail != null) mmsThumbnail.setOnLongClickListener(new MultiSelectLongClickListener()); } - public void set(MasterSecret masterSecret, MessageRecord messageRecord, - Set batchSelected, SelectionClickListener selectionClickListener, + public void set(@NonNull MasterSecret masterSecret, + @NonNull MessageRecord messageRecord, + @NonNull Set batchSelected, + @NonNull SelectionClickListener selectionClickListener, boolean groupThread, boolean pushDestination) { this.masterSecret = masterSecret; diff --git a/src/org/thoughtcrime/securesms/MessageDetailsActivity.java b/src/org/thoughtcrime/securesms/MessageDetailsActivity.java index d6fafca5b7..19b1d5dd1c 100644 --- a/src/org/thoughtcrime/securesms/MessageDetailsActivity.java +++ b/src/org/thoughtcrime/securesms/MessageDetailsActivity.java @@ -18,7 +18,6 @@ package org.thoughtcrime.securesms; import android.content.Context; import android.database.Cursor; -import android.graphics.Paint; import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.app.LoaderManager.LoaderCallbacks; @@ -28,6 +27,7 @@ import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.widget.AdapterView; import android.widget.ListView; import android.widget.TextView; @@ -52,6 +52,9 @@ import java.text.SimpleDateFormat; import java.util.HashSet; import java.util.LinkedList; +/** + * @author Jake McGinty + */ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity implements LoaderCallbacks { private final static String TAG = MessageDetailsActivity.class.getSimpleName(); @@ -148,7 +151,7 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity toFromRes = R.string.message_details_header__from; } toFrom.setText(toFromRes); - conversationItem.set(masterSecret, messageRecord, new HashSet(), null, + conversationItem.set(masterSecret, messageRecord, new HashSet(), new NullSelectionListener(), recipients != messageRecord.getRecipients(), DirectoryHelper.isPushDestination(this, recipients)); recipientsList.setAdapter(new MessageDetailsRecipientAdapter(this, masterSecret, messageRecord, @@ -278,6 +281,14 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity metadataContainer.setVisibility(View.VISIBLE); } } + } + private static class NullSelectionListener implements ConversationFragment.SelectionClickListener { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) {} + @Override + public boolean onItemLongClick(AdapterView parent, View view, int position, long id) { + return false; + } } }