changeset 103:c601e3d40342

chat: display delivery receipt (with a green check mark)
author Goffi <goffi@goffi.org>
date Mon, 09 Jan 2017 00:46:59 +0100
parents 20251d926cc2
children 663e44f30092
files src/cagou/plugins/plugin_wid_chat.kv src/cagou/plugins/plugin_wid_chat.py
diffstat 2 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/cagou/plugins/plugin_wid_chat.kv	Thu Jan 05 20:36:41 2017 +0100
+++ b/src/cagou/plugins/plugin_wid_chat.kv	Mon Jan 09 00:46:59 2017 +0100
@@ -48,6 +48,7 @@
     height: self.minimum_height
     on_width: self.widthAdjust()
     avatar: avatar
+    delivery: delivery
     BoxLayout:
         id: header_box
         size_hint: 1, None
@@ -62,6 +63,18 @@
             size: self.texture_size
             padding: dp(5), 0
             text: u"{}, {}".format(root.mess_data.nick, root.mess_data.time_text)
+        Label:
+            id: delivery
+            text_size: None, None
+            size_hint: None, None
+            size: self.texture_size
+            padding: dp(5), 0
+            # XXX: DejaVuSans font is needed as check mark is not in Roboto
+            # this can be removed when Kivy will be able to handle fallback mechanism
+            # which will allow us to use fonts with more unicode characters
+            font_name: "DejaVuSans"
+            text: u''
+            color: 0, 1, 0, 1
     BoxLayout:
         # BoxLayout is needed here, else GridLayout won't let the Label choose its width
         size_hint: 1, None
--- a/src/cagou/plugins/plugin_wid_chat.py	Thu Jan 05 20:36:41 2017 +0100
+++ b/src/cagou/plugins/plugin_wid_chat.py	Mon Jan 09 00:46:59 2017 +0100
@@ -526,6 +526,7 @@
     mess_xhtml = properties.ObjectProperty()
     mess_padding = (dp(5), dp(5))
     avatar = properties.ObjectProperty()
+    delivery = properties.ObjectProperty()
 
     def __init__(self, **kwargs):
         super(MessageWidget, self).__init__(**kwargs)
@@ -564,6 +565,9 @@
     def update(self, update_dict):
         if 'avatar' in update_dict:
             self.avatar.source = update_dict['avatar']
+        if 'status' in update_dict:
+            status = update_dict['status']
+            self.delivery.text =  u'\u2714' if status == 'delivered' else u''
 
 
 class MessageInputBox(BoxLayout):