annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 # Cagou: desktop/mobile frontend for Salut à Toi XMPP client
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # Copyright (C) 2016 Jérôme Poisson (goffi@goffi.org)
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
3
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # This program is free software: you can redistribute it and/or modify
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
5 # it under the terms of the GNU Affero General Public License as published by
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # the Free Software Foundation, either version 3 of the License, or
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # (at your option) any later version.
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
8
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # This program is distributed in the hope that it will be useful,
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # GNU Affero General Public License for more details.
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
13
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # You should have received a copy of the GNU Affero General Public License
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
16
78
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
17 #:import expanduser os.path.expanduser
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
18 #:import platform kivy.utils.platform
44
7819e9efa250 chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents: 31
diff changeset
19
58
7aa2ffff9067 chat: <img/> tag handling first draft:
Goffi <goffi@goffi.org>
parents: 57
diff changeset
20 <SimpleXHTMLWidgetEscapedText>:
7aa2ffff9067 chat: <img/> tag handling first draft:
Goffi <goffi@goffi.org>
parents: 57
diff changeset
21 size_hint: None, None
7aa2ffff9067 chat: <img/> tag handling first draft:
Goffi <goffi@goffi.org>
parents: 57
diff changeset
22 size: self.texture_size
7aa2ffff9067 chat: <img/> tag handling first draft:
Goffi <goffi@goffi.org>
parents: 57
diff changeset
23
7aa2ffff9067 chat: <img/> tag handling first draft:
Goffi <goffi@goffi.org>
parents: 57
diff changeset
24 <SimpleXHTMLWidgetText>:
7aa2ffff9067 chat: <img/> tag handling first draft:
Goffi <goffi@goffi.org>
parents: 57
diff changeset
25 size_hint: None, None
7aa2ffff9067 chat: <img/> tag handling first draft:
Goffi <goffi@goffi.org>
parents: 57
diff changeset
26 size: self.texture_size
7aa2ffff9067 chat: <img/> tag handling first draft:
Goffi <goffi@goffi.org>
parents: 57
diff changeset
27
7aa2ffff9067 chat: <img/> tag handling first draft:
Goffi <goffi@goffi.org>
parents: 57
diff changeset
28 <SimpleXHTMLWidgetImage>:
59
2aa44a82d0e7 chat: XHTML image size handling:
Goffi <goffi@goffi.org>
parents: 58
diff changeset
29 size_hint: None, None
58
7aa2ffff9067 chat: <img/> tag handling first draft:
Goffi <goffi@goffi.org>
parents: 57
diff changeset
30
44
7819e9efa250 chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents: 31
diff changeset
31 <MessAvatar>:
7819e9efa250 chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents: 31
diff changeset
32 size_hint: None, None
7819e9efa250 chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents: 31
diff changeset
33 size: dp(30), dp(30)
7819e9efa250 chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents: 31
diff changeset
34
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 <MessagesWidget>:
45
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
36 cols: 1
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
37 padding: dp(10)
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
38 spacing: dp(5)
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
39 size_hint: 1, None
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
40 height: self.minimum_height
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
41
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 <MessageWidget>:
45
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
43 cols: 1
57
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 47
diff changeset
44 mess_xhtml: mess_xhtml
45
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
45 padding: dp(10)
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
46 spacing: dp(5)
24
bc15b55a4114 chat: better bubble and time resizing
Goffi <goffi@goffi.org>
parents: 23
diff changeset
47 size_hint: 1, None
45
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
48 height: self.minimum_height
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
49 on_width: self.widthAdjust()
47
abb81efef3bb chat: update avatar following quick frontend improvments
Goffi <goffi@goffi.org>
parents: 45
diff changeset
50 avatar: avatar
45
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
51 BoxLayout:
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
52 id: header_box
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
53 size_hint: 1, None
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
54 height: avatar.height
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
55 MessAvatar:
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
56 id: avatar
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
57 source: root.mess_data.avatar
44
7819e9efa250 chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents: 31
diff changeset
58 Label:
7819e9efa250 chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents: 31
diff changeset
59 id: time_label
7819e9efa250 chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents: 31
diff changeset
60 text_size: None, None
45
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
61 size_hint: None, None
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
62 size: self.texture_size
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
63 padding: dp(5), 0
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
64 text: u"{}, {}".format(root.mess_data.nick, root.mess_data.time_text)
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
65 BoxLayout:
45
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
66 # BoxLayout is needed here, else GridLayout won't let the Label choose its width
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
67 size_hint: 1, None
57
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 47
diff changeset
68 height: mess_xhtml.height
45
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
69 on_size: root.widthAdjust()
57
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 47
diff changeset
70 SimpleXHTMLWidget:
24
bc15b55a4114 chat: better bubble and time resizing
Goffi <goffi@goffi.org>
parents: 23
diff changeset
71 canvas.before:
bc15b55a4114 chat: better bubble and time resizing
Goffi <goffi@goffi.org>
parents: 23
diff changeset
72 Color:
bc15b55a4114 chat: better bubble and time resizing
Goffi <goffi@goffi.org>
parents: 23
diff changeset
73 rgba: 1, 1, 1, 1
bc15b55a4114 chat: better bubble and time resizing
Goffi <goffi@goffi.org>
parents: 23
diff changeset
74 BorderImage:
45
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
75 source: app.expand("{media}/misc/black.png") if root.mess_data.type == "info" else app.expand("{media}/misc/borders/{}.jpg", "blue" if root.mess_data.own_mess else "gray")
24
bc15b55a4114 chat: better bubble and time resizing
Goffi <goffi@goffi.org>
parents: 23
diff changeset
76 pos: self.pos
58
7aa2ffff9067 chat: <img/> tag handling first draft:
Goffi <goffi@goffi.org>
parents: 57
diff changeset
77 size: self.content_width, self.height
57
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 47
diff changeset
78 id: mess_xhtml
58
7aa2ffff9067 chat: <img/> tag handling first draft:
Goffi <goffi@goffi.org>
parents: 57
diff changeset
79 size_hint: 0.8, None
7aa2ffff9067 chat: <img/> tag handling first draft:
Goffi <goffi@goffi.org>
parents: 57
diff changeset
80 height: self.minimum_height
57
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 47
diff changeset
81 xhtml: root.message_xhtml or self.escape(root.message or u' ')
45
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
82 color: (0.74,0.74,0.24,1) if root.mess_data.type == "info" else (0, 0, 0, 1)
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
83 padding: root.mess_padding
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
84 bold: True if root.mess_data.type == "info" else False
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
85
78
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
86 <MessageInputBox>:
45
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
87 size_hint: 1, None
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
88 height: dp(40)
78
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
89 message_input: message_input
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
90 MessageInputWidget:
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
91 id: message_input
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
92 size_hint: 1, 1
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
93 hint_text: "Enter your message here"
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
94 on_text_validate: root.parent.onSend(args[0])
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
95 IconButton
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
96 # upload button
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
97 source: app.expand("{media}/icons/tango/actions/32/list-add.png")
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
98 allow_stretch: True
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
99 size_hint: None, 1
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
100 width: max(self.texture_size[0], dp(40))
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
101 on_release: root.parent.onUploadButton()
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
102
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
103 <FileUploader>:
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
104 FileChooserListView:
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
105 id: filechooser
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
106 rootpath: "/" if platform == 'android' else expanduser('~')
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
107 Button:
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
108 text: "upload"
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
109 size_hint: 1, None
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
110 height: dp(50)
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
111 on_release: root.parent_chat.onUploadOK(filechooser)
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
112 Button:
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
113 text: "cancel"
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
114 size_hint: 1, None
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
115 height: dp(50)
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 59
diff changeset
116 on_release: root.parent_chat.onUploadCancel(filechooser)