diff --git a/res/drawable-hdpi/ic_list_alert_sms_failed.png b/res/drawable-hdpi/ic_list_alert_sms_failed.png new file mode 100644 index 0000000000..e47de9a6a0 Binary files /dev/null and b/res/drawable-hdpi/ic_list_alert_sms_failed.png differ diff --git a/res/drawable-mdpi/ic_list_alert_sms_failed.png b/res/drawable-mdpi/ic_list_alert_sms_failed.png new file mode 100644 index 0000000000..13131861af Binary files /dev/null and b/res/drawable-mdpi/ic_list_alert_sms_failed.png differ diff --git a/res/drawable-xhdpi/ic_list_alert_sms_failed.png b/res/drawable-xhdpi/ic_list_alert_sms_failed.png new file mode 100644 index 0000000000..a1e9f22905 Binary files /dev/null and b/res/drawable-xhdpi/ic_list_alert_sms_failed.png differ diff --git a/res/layout/conversation_item_received.xml b/res/layout/conversation_item_received.xml index 3ee5a705f7..1fec73280e 100644 --- a/res/layout/conversation_item_received.xml +++ b/res/layout/conversation_item_received.xml @@ -131,7 +131,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - android:src="@drawable/ic_sms_mms_not_delivered" + android:src="@drawable/ic_list_alert_sms_failed" android:visibility="gone" /> diff --git a/res/layout/conversation_item_sent.xml b/res/layout/conversation_item_sent.xml index 28bb7dee03..7a8b62474e 100644 --- a/res/layout/conversation_item_sent.xml +++ b/res/layout/conversation_item_sent.xml @@ -40,7 +40,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - android:src="@drawable/ic_sms_mms_not_delivered" + android:src="@drawable/ic_list_alert_sms_failed" android:visibility="gone" /> diff --git a/src/org/thoughtcrime/securesms/ConversationActivity.java b/src/org/thoughtcrime/securesms/ConversationActivity.java index d4feb1b139..276b1a419e 100644 --- a/src/org/thoughtcrime/securesms/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/ConversationActivity.java @@ -81,7 +81,9 @@ import java.io.IOException; * @author Moxie Marlinspike * */ -public class ConversationActivity extends SherlockFragmentActivity { +public class ConversationActivity extends SherlockFragmentActivity + implements ConversationFragment.ConversationFragmentListener + { private static final int PICK_CONTACT = 1; private static final int PICK_IMAGE = 2; @@ -678,4 +680,9 @@ public class ConversationActivity extends SherlockFragmentActivity { return false; } } + + @Override + public void setComposeText(String text) { + this.composeText.setText(text); + } } diff --git a/src/org/thoughtcrime/securesms/ConversationFragment.java b/src/org/thoughtcrime/securesms/ConversationFragment.java index 6f4673e17a..940f5d2b96 100644 --- a/src/org/thoughtcrime/securesms/ConversationFragment.java +++ b/src/org/thoughtcrime/securesms/ConversationFragment.java @@ -1,5 +1,6 @@ package org.thoughtcrime.securesms; +import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; @@ -31,6 +32,8 @@ public class ConversationFragment extends SherlockListFragment implements LoaderManager.LoaderCallbacks { + private ConversationFragmentListener listener; + private MasterSecret masterSecret; private Recipients recipients; private long threadId; @@ -73,6 +76,12 @@ public class ConversationFragment extends SherlockListFragment return false; } + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + this.listener = (ConversationFragmentListener)activity; + } + public void reload(Recipients recipients, long threadId) { this.recipients = recipients; this.threadId = threadId; @@ -170,10 +179,14 @@ public class ConversationFragment extends SherlockListFragment private class FailedIconClickHandler extends Handler { @Override public void handleMessage(android.os.Message message) { - assert(false); -// String failedMessageText = (String)message.obj; -// ConversationActivity.this.composeText.setText(failedMessageText); + if (listener != null) { + listener.setComposeText((String)message.obj); + } } } + public interface ConversationFragmentListener { + public void setComposeText(String text); + } + } \ No newline at end of file diff --git a/src/org/thoughtcrime/securesms/ConversationItem.java b/src/org/thoughtcrime/securesms/ConversationItem.java index 1197560117..392b77ba74 100644 --- a/src/org/thoughtcrime/securesms/ConversationItem.java +++ b/src/org/thoughtcrime/securesms/ConversationItem.java @@ -135,10 +135,7 @@ public class ConversationItem extends LinearLayout { public void setMessageRecord(MessageRecord messageRecord) { setBody(messageRecord); - setDate(messageRecord.getDate()); - setStatusIcons(messageRecord); - setEvents(messageRecord); } @@ -268,10 +265,6 @@ public class ConversationItem extends LinearLayout { return (number != null) && (number.trim().length() > 0); } - private void setDate(long date) { - dateText.setText(DateUtils.getRelativeTimeSpanString(getContext(), date, false)); - } - private void setStatusIcons(MessageRecord messageRecord) { failedImage.setVisibility(messageRecord.isFailed() ? View.VISIBLE : View.GONE); secureImage.setVisibility(messageRecord.isSecure() ? View.VISIBLE : View.GONE); @@ -280,6 +273,12 @@ public class ConversationItem extends LinearLayout { mmsThumbnail.setVisibility(View.GONE); mmsDownloadButton.setVisibility(View.GONE); mmsDownloadingLabel.setVisibility(View.GONE); + + if (messageRecord.isFailed()) dateText.setText("Error sending message"); + else if (messageRecord.isPending()) dateText.setText("Sending..."); + else dateText.setText(DateUtils.getRelativeTimeSpanString(getContext(), + messageRecord.getDate(), + false)); } private void setEvents(MessageRecord messageRecord) {