# HG changeset patch # User Goffi # Date 1582474587 -3600 # Node ID 5b50b7ef261770d56caeee4184693b45766d604b # Parent 3e2333a11f61adb71882d5ed7c58ba61f36cd82b menu (TransferMenu): UI improvments: - a white background is now used - ToggleButton have been replaced by SymbolButtonLabel - transfer info message now displays with emphasis if the file will be encrypted or not, and explain when the file goes to the server - various padding/spacing/color adjustments diff -r 3e2333a11f61 -r 5b50b7ef2617 cagou/core/menu.py --- a/cagou/core/menu.py Sun Feb 23 17:13:15 2020 +0100 +++ b/cagou/core/menu.py Sun Feb 23 17:16:27 2020 +0100 @@ -206,15 +206,13 @@ # callback will be called with path to file to transfer # profiles if set will be sent to transfer widget, may be used to get specific files profiles = properties.ObjectProperty() - transfer_txt = _("Beware! The file will be sent to your server and stay unencrypted " - "there\nServer admin(s) can see the file, and they choose how, " - "when and if it will be deleted") - send_txt = _("The file will be sent unencrypted directly to your contact " - "(without transiting by the server), except in some cases") + transfer_txt = properties.StringProperty() + transfer_info = properties.ObjectProperty() + upload_btn = properties.ObjectProperty() + encrypted = properties.BooleanProperty(False) items_layout = properties.ObjectProperty() size_hint_close = (1, 0) size_hint_open = (1, 0.5) - bg_color = properties.ListProperty([1, 1, 1, 1]) def __init__(self, **kwargs): super(TransferMenu, self).__init__(**kwargs) @@ -226,6 +224,45 @@ ) self.items_layout.add_widget(item) + def on_kv_post(self, __): + self.updateTransferInfo() + + def getTransferInfo(self): + if self.upload_btn.state == "down": + # upload + if self.encrypted: + return _( + "The file will be [color=00aa00][b]encrypted[/b][/color] and sent to " + "your server\nServer admin(s) can delete the file, but they won't be " + "able to see its content" + ) + else: + return _( + "Beware! The file will be sent to your server and stay " + "[color=ff0000][b]unencrypted[/b][/color] there\nServer admin(s) " + "can see the file, and they choose how, when and if it will be " + "deleted" + ) + else: + # P2P + if self.encrypted: + return _( + "The file will be sent [color=ff0000][b]unencrypted[/b][/color] " + "directly to your contact (it may be transiting by the " + "server if direct connection is not possible).\n[color=ff0000]" + "Please not that end-to-end encryption is not yet implemented for " + "P2P transfer." + ) + else: + return _( + "The file will be sent [color=ff0000][b]unencrypted[/b][/color] " + "directly to your contact (it [i]may be[/i] transiting by the " + "server if direct connection is not possible)." + ) + + def updateTransferInfo(self): + self.transfer_info.text = self.getTransferInfo() + def _onTransferCb(self, file_path, external, wid_cont, cleaning_cb=None): if not external: wid = wid_cont[0] diff -r 3e2333a11f61 -r 5b50b7ef2617 cagou/kv/menu.kv --- a/cagou/kv/menu.kv Sun Feb 23 17:13:15 2020 +0100 +++ b/cagou/kv/menu.kv Sun Feb 23 17:16:27 2020 +0100 @@ -42,31 +42,51 @@ : items_layout: items_layout orientation: "vertical" + bg_color: app.c_prim size_hint: 1, 0.5 - canvas.before: + padding: [app.MARGIN_LEFT, 3, app.MARGIN_RIGHT, 0] + spacing: dp(5) + transfer_info: transfer_info + upload_btn: upload_btn + on_encrypted: self.updateTransferInfo() + canvas.after: Color: - rgba: 0, 0, 0, 1 - Rectangle: - pos: self.pos - size: self.size + rgba: app.c_prim_dark + Line: + points: 0, self.y + self.height, self.width + self.x, self.y + self.height + width: 1 BoxLayout: size_hint: 1, None height: dp(50) - ToggleButton: + spacing: dp(10) + Widget: + SymbolToggleLabel id: upload_btn + symbol: "upload" text: _(u"upload") group: "transfer" state: "down" - ToggleButton: + on_state: root.updateTransferInfo() + SymbolToggleLabel id: send_btn + symbol: "loop-alt" text: _(u"send") group: "transfer" + Widget: Label: - size_hint: 1, 0.3 - text: root.transfer_txt if upload_btn.state == 'down' else root.send_txt - text_size: self.size + id: transfer_info + size_hint: 1, None + padding: 0, dp(5) + markup: True + text_size: root.width, None + size: self.texture_size halign: 'center' - valign: 'top' + canvas.before: + Color: + rgba: app.c_prim_dark + RoundedRectangle: + pos: self.pos + size: self.size ScrollView: do_scroll_x: False StackLayout: diff -r 3e2333a11f61 -r 5b50b7ef2617 cagou/plugins/plugin_wid_chat.py --- a/cagou/plugins/plugin_wid_chat.py Sun Feb 23 17:13:15 2020 +0100 +++ b/cagou/plugins/plugin_wid_chat.py Sun Feb 23 17:16:27 2020 +0100 @@ -239,7 +239,10 @@ chat = properties.ObjectProperty() def on_release(self, *args): - menu.TransferMenu(callback=self.chat.transferFile).show(self) + menu.TransferMenu( + encrypted=self.chat.encrypted, + callback=self.chat.transferFile, + ).show(self) class ExtraMenu(DropDown):