From 7883d09573ef91011432936ab78724fc56e87637 Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Fri, 3 Aug 2012 17:34:09 -0700 Subject: [PATCH] Fix success/failure status on conversation item. --- .../ic_list_alert_sms_failed.png | Bin 0 -> 2200 bytes .../ic_list_alert_sms_failed.png | Bin 0 -> 824 bytes .../ic_list_alert_sms_failed.png | Bin 0 -> 2187 bytes res/layout/conversation_item_received.xml | 2 +- res/layout/conversation_item_sent.xml | 2 +- .../securesms/ConversationActivity.java | 9 ++++++++- .../securesms/ConversationFragment.java | 19 +++++++++++++++--- .../securesms/ConversationItem.java | 13 ++++++------ 8 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 res/drawable-hdpi/ic_list_alert_sms_failed.png create mode 100644 res/drawable-mdpi/ic_list_alert_sms_failed.png create mode 100644 res/drawable-xhdpi/ic_list_alert_sms_failed.png 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 0000000000000000000000000000000000000000..e47de9a6a0d208036ce0b27afe539ef54305c5dc GIT binary patch literal 2200 zcmV;J2xs?+P)Px#32;bRa{vGf6951U69E94oEQKA00(qQO+^RX2m=%l1l?^Vgdr2_`s1G|tDZ$HjT8>U7=P-M6PZMk~4L+jY;W^L{?> z^S%Z9yqwb9@7rB%UGHiAZkITKtF3FK{3ta|C){zv-GBw}s%btdg|K16+CPE+(Ckf_6eU|GRpRfq!$f86r70goW}Ac;5zmPNIwQ%1FiuM5Bf$CX-^(- zUE>1B0YwZ?knRW8vF`*bXX{tCE1)$jA$`HH0h|RUY8q4+u}z6~kD;_b6ml0i92R^B zIImtaWe-WRjbg3fVc>b-@Ii!w_7XBhk;0&=Y3!7iZEpx(2`}^*56Jn32ar+=TmoJK z-c-|EZ&S*-R6KuCbXpij%ZHbW8%_e>MEX()Jk{V?mmV=p4NKT3B_-hRz&kk;B&THT zJwa=ABZ=!?b^y*x`nKUvXlCpwS=gy_B2TfW8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`WNYZYfy3lK}+!wUV%Ajw+4Ddx4rx+mX2_EW8inV251Aa-YHLU@= zglE50$vZkDl0pyx-f7^PcBwokfE}_Xf^P+I9hg-ii-y9M#N7dp1XM2I@0vXCnmq3U z-3Vw~zynpRq77{j2y61w72uMx!X?%V@4Y!$8(v7s0;AIIFAFLbE+;Ztx>-dp5Foz* zZVHkI-oAvq7iI+y(X=!J(yk4B01gD_-inSOy(8xh;Hx}cz>lQkjHKtLw6p`N-V$&y zKz>L)<>uayI#U3Lf%_34VvkBon1ANrA!A3@@CsI&i zAT>(iD)2+rs+`5DtC!J~KCx+RvypB#7wLBYN?!iF=-7~NEB14z+&Km8ku{~lG3;L} zI>x-Wth(I-a7xwtGFlU*9oeU(WnXkGcrSS6lcUabBZR_;u1TQq?p_3rl%!oqO#xm* z4In8qXd${50cTv6O#^R$y%p!gPVnAH{LiQ5ci?;-SPpu CBWyVU literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..a1e9f229054805d0085a5a6bbd265991283cf498 GIT binary patch literal 2187 zcmV;62z2*}P)Px#32;bRa{vGf6951U69E94oEQKA00(qQO+^RX2m=%kD$LeO~jQm2j2*ePb72pM3`w;jI@VMgM zMn~Snjz>G@0Po7u`=W5#^;dv5^`{5^46OU2co+Cw_der@#QcXp0?dMs0oQuWGIR)G_yMIjA7jBe{DMiTZqRGbTI&TpB*0AS9d#}kE;d>YTeG0e^ zYyf`*KCyHCudqO7Xm13V1TF$gz}NLmA34D0f<+lV?~CFCF+y7u>VWp4$pIa(7_1t7{i?`ux_1e90Q^d|!QR}d=MUnfykMltVp=>a zTD;_o;x6#9E6b-SU@89y&)SPF9$ z#*7)<26(iUPsS3z@uqWh40s8+3fxym`O_+g_Yx6<)B)a1I4MlNp_W!0`c*|w%hV1n zpk?ZaR;src&3#hOycO7H&~iBMSM5bj&KFdmT#ab2Q`9Q4l@t|rk z?-Tps0b^2YS4Dm26Kc;VLb@MaQ8nk7D$ONe$rr^MaL<+HQyH7}nhWx76<=aZ%J^kt zyrsP+j<%eMpb-;+%Zh}@Vu!x$=_v_T$lYf!$N`<@RWwd+Nh<#ZSXYVc0jEEEcR&wk zdzmtS$igp2v`2%^@D&ai2fiUTc*z&Vzl>U>7q!?E3z#2FsL6TVl&vEsduIo*`0H z6J}jh@dXc`t!RPwvvaKhze`1m<@@Kf#+y-vm|R=l0ryoMnPqklEe6H8?^2+&hnUxy zj?|_!!lqqo6$|8D)LsxTUo$T8aIHS`J(s-`>)(os>Qqu=Z>o@dzIY- z&RFgBJB|Y@T1;-$pgKY}!un+fs}?V6&G&%615Z+Fv0Et|`tolYwMUf?|R(9 ze*^#Q0RmG!%vJULSS^MFl?TAvz@~+Q%>nT-(=+GuHI=vT13v(M*C7dhN6xQ9Er$0K zwt>GITHJG3ZrWVlWapmV&=>#;o50(yEZ<3#;NC29&;%IM;w$PH&FgG&$Ew9FDt|-Q zH8eS=*?*vlD>JmWDkXI;Q54k?1-=J0=xg46Yr{F&xEcz(zyha5K{t5zb+$So zFasa9%YuAvNV&`qC7I;{Zu)K_)i}KGf z)u)A2#_lQf7Vrz;`@lOn`)_bxGzp^Jp|Tss5z|s>{dR%tD8$;@*i*7~5%??z3Snb5 z@><;;-hTQAbv9L9)N632!E+{8lXE)4p6h_4Iug?$_#HMExF{FB2F&I1M8^KPe2n@3 zRt?~4p3Ba6RC%uz62lH(y|Dv4&4Hhb9|M-dz7v8dL@_%R_#t}L~{{hR*8A-G)Jfr{s N002ovPDHLkV1mmn60`sS literal 0 HcmV?d00001 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) {