diff src/cagou/plugins/plugin_wid_chat.kv @ 78:46d962910801

chat: file upload first draft: - added a icon to upload files - only do a basic upload with list file browser for now - use the new progressFinished and progressError listeners
author Goffi <goffi@goffi.org>
date Thu, 22 Dec 2016 19:03:06 +0100
parents 2aa44a82d0e7
children c711be670ecd
line wrap: on
line diff
--- a/src/cagou/plugins/plugin_wid_chat.kv	Thu Dec 22 18:24:24 2016 +0100
+++ b/src/cagou/plugins/plugin_wid_chat.kv	Thu Dec 22 19:03:06 2016 +0100
@@ -14,6 +14,8 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+#:import expanduser os.path.expanduser
+#:import platform kivy.utils.platform
 
 <SimpleXHTMLWidgetEscapedText>:
     size_hint: None, None
@@ -81,7 +83,34 @@
             padding: root.mess_padding
             bold: True if root.mess_data.type == "info" else False
 
-<MessageInputWidget>:
+<MessageInputBox>:
     size_hint: 1, None
     height: dp(40)
-    hint_text: "Enter your message here"
+    message_input: message_input
+    MessageInputWidget:
+        id: message_input
+        size_hint: 1, 1
+        hint_text: "Enter your message here"
+        on_text_validate: root.parent.onSend(args[0])
+    IconButton
+        # upload button
+        source: app.expand("{media}/icons/tango/actions/32/list-add.png")
+        allow_stretch: True
+        size_hint: None, 1
+        width: max(self.texture_size[0], dp(40))
+        on_release: root.parent.onUploadButton()
+
+<FileUploader>:
+    FileChooserListView:
+        id: filechooser
+        rootpath: "/" if platform == 'android' else expanduser('~')
+    Button:
+        text: "upload"
+        size_hint: 1, None
+        height: dp(50)
+        on_release: root.parent_chat.onUploadOK(filechooser)
+    Button:
+        text: "cancel"
+        size_hint: 1, None
+        height: dp(50)
+        on_release: root.parent_chat.onUploadCancel(filechooser)