From a86a09ab5b81f39c4d56c37af65e630539e85ffe Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 20 Sep 2014 15:49:25 +0200 Subject: [PATCH] indicates received messages with a tick. --- art/ic_received_indicator.svg | 76 ++++++++++++++++++ art/render.rb | 2 +- res/drawable-hdpi/ic_received_indicator.png | Bin 0 -> 686 bytes res/drawable-mdpi/ic_received_indicator.png | Bin 0 -> 447 bytes res/drawable-xhdpi/ic_received_indicator.png | Bin 0 -> 855 bytes res/drawable-xxhdpi/ic_received_indicator.png | Bin 0 -> 1236 bytes res/layout/message_sent.xml | 12 ++- res/values-de/strings.xml | 5 +- res/values/strings.xml | 3 + res/xml/preferences.xml | 9 ++- .../siacs/conversations/entities/Message.java | 12 +-- .../generator/MessageGenerator.java | 3 + .../conversations/parser/MessageParser.java | 7 ++ .../services/XmppConnectionService.java | 4 + .../ui/ConversationActivity.java | 4 + .../ui/adapter/MessageAdapter.java | 16 ++++ 16 files changed, 143 insertions(+), 10 deletions(-) create mode 100644 art/ic_received_indicator.svg create mode 100644 res/drawable-hdpi/ic_received_indicator.png create mode 100644 res/drawable-mdpi/ic_received_indicator.png create mode 100644 res/drawable-xhdpi/ic_received_indicator.png create mode 100644 res/drawable-xxhdpi/ic_received_indicator.png diff --git a/art/ic_received_indicator.svg b/art/ic_received_indicator.svg new file mode 100644 index 00000000..d9378c60 --- /dev/null +++ b/art/ic_received_indicator.svg @@ -0,0 +1,76 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/art/render.rb b/art/render.rb index ed306072..5464b9f5 100755 --- a/art/render.rb +++ b/art/render.rb @@ -1,6 +1,6 @@ #!/bin/env ruby resolutions={'mdpi'=> 1, 'hdpi' => 1.5, 'xhdpi' => 2, 'xxhdpi' => 3} -images = { 'conversations.svg' => ['ic_launcher',48], 'conversations_baloon.svg' => ['ic_activity', 32], 'conversations_mono.svg' => ['ic_notification',24] } +images = { 'conversations.svg' => ['ic_launcher',48], 'conversations_baloon.svg' => ['ic_activity', 32], 'conversations_mono.svg' => ['ic_notification',24], 'ic_received_indicator.svg' => ['ic_received_indicator',12] } images.each do |source, result| resolutions.each do |name, factor| size = factor * result[1] diff --git a/res/drawable-hdpi/ic_received_indicator.png b/res/drawable-hdpi/ic_received_indicator.png new file mode 100644 index 0000000000000000000000000000000000000000..b1e3f27486a20085b651510660b0a07a5cf751ea GIT binary patch literal 686 zcmV;f0#W^mP)8FWQhbW?9;ba!ELWdL_~cP?peYja~^ zaAhuUa%Y?FJQ@H10xL;GK~y-6tdah+q{2p_ba> z!5;j;lZRH6g5GLx0Z|VggenLgDu@RWX`$d3cu;H(6-7NL5wR3O)RaKdCe5bl?xxx7 zy5m7pYHaf%4!p~}H@}(p7(yw<|5)t593nl$79I#+X9Q+HEKE>a(56YVFY+AmgdF=E zlbqk$4*+^rkL#bxLrp>6L2tl*z!BrT+)e<{zLxGQ@0BxBOe!!9w?l}9-z(g%AjOaB zL~=ZNLW)TR0B9HroeN#&J6jF|fcCxgI5m+PqZ`_32x>nYJkIa1MFGIb=qjo$Y4btjLF3di*2)3zbBmFL04-x9$RfQc|0g9!jrkjev;#qQ`x( zZN}=i?x8x>mAD+$zG-pyv9@Ox!6MKf)XYDZdUKC*Z)-x7Qh1JfB4VF&hHYiT0AQ|} zWyZ!>0YFceUnDLi25KR|?_n=LS^lhikWZOKa}@w8$S+8rs)wvY0Fa%^&KBe9DAlP^ z*)vv*#nj8xbW;!jr0=Hh73b8bAsGo%HRW0beWxO!dg&2n4CPs_*$ UM9b_%mH+?%07*qoM6N<$g0yQUzW@LL literal 0 HcmV?d00001 diff --git a/res/drawable-mdpi/ic_received_indicator.png b/res/drawable-mdpi/ic_received_indicator.png new file mode 100644 index 0000000000000000000000000000000000000000..88ff1efb90664e193981d988003767bfd62b9772 GIT binary patch literal 447 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&kmSQK*5Dp-y;YjHK@;M7UB8wRq z7!QCj=-6~$u*PAB|qpZJhlS&=vB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/ic_received_indicator.png b/res/drawable-xxhdpi/ic_received_indicator.png new file mode 100644 index 0000000000000000000000000000000000000000..039a9ef9ba6d588442aec93dd251eef7345538c2 GIT binary patch literal 1236 zcmV;_1S|WAP)C8)X~^@ZWR2Uhl5G((M^Ms3_&2#B%VsENHwddyW&3_i>YX;)C z@b@qevje1$tjL%!04IkMuSY(Lyo$3toLCDCszENgiT=cb0RV9{bxJrb9L|PWGf?n} zvJ=h_^^iGNCgg9z?}cAnYOU>{(B4oxQ%mnN=W0wHnY}pMhA~$21`6&7Hqz^u6Uc$k z;#^M}VR=Y;CUG$lyHgF@Kn0r%3aRz3Zh|Fzi*rLU#N@B@JB2>s_vO^F4dlJwd(2tv zT%QpdfW^_&!Dv_X+vV1=1;n@WTV0iOn>kPaC7lsI5KgV6R?Z+_v(Hc0v&RvMGHPiF zZAKhQ9$IO=oI&mfxi_7KWVJb$uS&;e`)8-}3M$#bw=k7-yE#|F@=wBP;hojg%m5*T zC~uS3+N)$4zGk1_Q_plFXXd4eRji7m;!7A~eKjBw0HAbN>67%`%+boustO0|pi0_G zHpRMP-!HY0ZSou?15OKGnvl9;=VCvs1_N+whnOnnBy|_Hj`WdkL?NfU)^ie7A7&zvV3vqEO9o3T0&X>AqXMDUFUucIgzEg zldg$x%zQaBlM{#waiA;4gn5FhalKI5Uiz3h=Xdh^T;=pebFRkJsmOPck8{BQ01)$+ z=Hv26db^P_ZY-W~Fb>vpAJ-FjHqg9~c^~l>({;?jY=!i=){Fnda?T(C0HH^?oct}Z z8!MRw2{%#fZs5-Ht^8I10B?i$71E#i^#TAGX+sgm#7}d@0GK*Pet+nB?q2uXKtRTA zjdhIGxH?Yy$TEVmwxi0F{PpCK$rd|68Rt;s{pokpS4GQ#h8ze{0jfG11^_^wl+W6M z0m#x*BZP?ZL*;$03i_$#6i}kd^{JO9>sNaanuq1;z!)2;!PIkVRQ-851@s%*XLez- zf&c*G7vl5sW$9^cP90xru^|~!VmQ%l7v{Dg007~+vI8Gl94tv0069FERCmoq60#o y-Jlh{xpLK90M()zZA$xF92HmGeAy1l$M_c^7QnNP%a4!%0000 + + - \ No newline at end of file + diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 1dbfdf10..9b76c94b 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -232,6 +232,8 @@ Zusätzliche Informationen Überspringen Benutzeroberfläche + Anfrage für Nachrichten Empfang + Wenn Nachricht vom Empfänger empfangen wurde dann erscheint ein Häckchen als Bestätigung (muss vom Client des Empfängers unterstützt werden und funktioniert nicht in jedem Fall) Benachrichtigungen deaktivieren Benachrichtigungen für diese Unterhaltung deaktivieren Benachrichtigungen sind deaktiviert @@ -256,5 +258,6 @@ Überall in der App eine größere Schrift verwenden Absende-Knopf zeigt Online-Status an Absende-Knopf einfärben, um den Online-Status des Kontakts zu signalisieren + Anderes - nicht kategorisiert - \ No newline at end of file + diff --git a/res/values/strings.xml b/res/values/strings.xml index c3e465ac..22d617f8 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -255,6 +255,9 @@ Increase font size Use larger font sizes across the entire app Send button indicates status + Request message receipts + When message has been received by the receiver then a tick will appear as confirmation (must supported by the recipient client and does not work as any case) Colorize send button to indicate contact status + Other - not categorized diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index 7d0886bc..3dab0959 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -90,6 +90,13 @@ android:summary="@string/pref_dont_save_encrypted_summary" android:title="@string/pref_dont_save_encrypted" /> + + + - \ No newline at end of file + diff --git a/src/eu/siacs/conversations/entities/Message.java b/src/eu/siacs/conversations/entities/Message.java index ce496d27..63b6be92 100644 --- a/src/eu/siacs/conversations/entities/Message.java +++ b/src/eu/siacs/conversations/entities/Message.java @@ -326,12 +326,12 @@ public class Message extends AbstractEntity { && this.getType() == message.getType() && this.getEncryption() == message.getEncryption() && this.getCounterpart().equals(message.getCounterpart()) - && (message.getTimeSent() - this.getTimeSent()) <= (Config.MESSAGE_MERGE_WINDOW * 1000) && ((this - .getStatus() == message.getStatus()) || ((this.getStatus() == Message.STATUS_SEND || this - .getStatus() == Message.STATUS_SEND_RECEIVED) && (message - .getStatus() == Message.STATUS_UNSEND - || message.getStatus() == Message.STATUS_SEND || message - .getStatus() == Message.STATUS_SEND_DISPLAYED)))); + && (message.getTimeSent() - this.getTimeSent()) <= (Config.MESSAGE_MERGE_WINDOW * 1000) + && ((this.getStatus() == message.getStatus()) + || (this.getStatus() == Message.STATUS_SEND && (message.getStatus() == Message.STATUS_UNSEND + || message.getStatus() == Message.STATUS_SEND)) + || (this.getStatus() == Message.STATUS_SEND_RECEIVED + && message.getStatus() == Message.STATUS_SEND_DISPLAYED))); } public String getMergedBody() { diff --git a/src/eu/siacs/conversations/generator/MessageGenerator.java b/src/eu/siacs/conversations/generator/MessageGenerator.java index 8c0d4e23..acfa3db7 100644 --- a/src/eu/siacs/conversations/generator/MessageGenerator.java +++ b/src/eu/siacs/conversations/generator/MessageGenerator.java @@ -27,6 +27,9 @@ public class MessageGenerator extends AbstractGenerator { packet.setTo(message.getCounterpart()); packet.setType(MessagePacket.TYPE_CHAT); packet.addChild("markable", "urn:xmpp:chat-markers:0"); + if (this.mXmppConnectionService.indicateReceived()) { + packet.addChild("request", "urn:xmpp:receipts"); + } } else if (message.getType() == Message.TYPE_PRIVATE) { packet.setTo(message.getCounterpart()); packet.setType(MessagePacket.TYPE_CHAT); diff --git a/src/eu/siacs/conversations/parser/MessageParser.java b/src/eu/siacs/conversations/parser/MessageParser.java index b9fe3c15..d2274000 100644 --- a/src/eu/siacs/conversations/parser/MessageParser.java +++ b/src/eu/siacs/conversations/parser/MessageParser.java @@ -278,6 +278,13 @@ public class MessageParser extends AbstractParser implements updateLastseen(packet, account, false); mXmppConnectionService.markMessage(account, fromParts[0], id, Message.STATUS_SEND_RECEIVED); + } else if (packet.hasChild("received", "urn:xmpp:receipts")) { + String id = packet.findChild("received", "urn:xmpp:receipts") + .getAttribute("id"); + String[] fromParts = packet.getAttribute("from").split("/"); + updateLastseen(packet, account, false); + mXmppConnectionService.markMessage(account, fromParts[0], id, + Message.STATUS_SEND_RECEIVED); } else if (packet.hasChild("x", "http://jabber.org/protocol/muc#user")) { Element x = packet.findChild("x", "http://jabber.org/protocol/muc#user"); diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index 0012713a..5bc25552 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -1566,6 +1566,10 @@ public class XmppConnectionService extends Service { return !getPreferences().getBoolean("dont_save_encrypted", false); } + public boolean indicateReceived() { + return getPreferences().getBoolean("indicate_received", false); + } + public void notifyUi(Conversation conversation, boolean notify) { if (mOnConversationUpdate != null) { mOnConversationUpdate.onConversationUpdate(); diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java index f58b4ddd..03d034d9 100644 --- a/src/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/eu/siacs/conversations/ui/ConversationActivity.java @@ -790,6 +790,10 @@ public class ConversationActivity extends XmppActivity implements return getPreferences().getBoolean("send_button_status", false); } + public boolean indicateReceived() { + return getPreferences().getBoolean("indicate_received", false); + } + @Override public void onAccountUpdate() { final ConversationFragment fragment = (ConversationFragment) getFragmentManager() diff --git a/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java index 876fbfe7..87565b93 100644 --- a/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -96,6 +96,9 @@ public class MessageAdapter extends ArrayAdapter { String filesize = null; String info = null; boolean error = false; + if (viewHolder.indicatorReceived != null) { + viewHolder.indicatorReceived.setVisibility(View.GONE); + } boolean multiReceived = message.getConversation().getMode() == Conversation.MODE_MULTI && message.getMergedStatus() <= Message.STATUS_RECEIVED; if (message.getType() == Message.TYPE_IMAGE) { @@ -117,6 +120,16 @@ public class MessageAdapter extends ArrayAdapter { case Message.STATUS_OFFERED: info = getContext().getString(R.string.offering); break; + case Message.STATUS_SEND_RECEIVED: + if (activity.indicateReceived()) { + viewHolder.indicatorReceived.setVisibility(View.VISIBLE); + } + break; + case Message.STATUS_SEND_DISPLAYED: + if (activity.indicateReceived()) { + viewHolder.indicatorReceived.setVisibility(View.VISIBLE); + } + break; case Message.STATUS_SEND_FAILED: info = getContext().getString(R.string.send_failed); error = true; @@ -337,6 +350,8 @@ public class MessageAdapter extends ArrayAdapter { .findViewById(R.id.message_body); viewHolder.time = (TextView) view .findViewById(R.id.message_time); + viewHolder.indicatorReceived = (ImageView) view + .findViewById(R.id.indicator_received); view.setTag(viewHolder); break; case RECEIVED: @@ -512,6 +527,7 @@ public class MessageAdapter extends ArrayAdapter { protected Button download_button; protected ImageView image; protected ImageView indicator; + protected ImageView indicatorReceived; protected TextView time; protected TextView messageBody; protected ImageView contact_picture;