diff cagou/core/menu.py @ 417:5b50b7ef2617

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
author Goffi <goffi@goffi.org>
date Sun, 23 Feb 2020 17:16:27 +0100
parents 5761b5f03c0c
children cebf657d78ef
line wrap: on
line diff
--- 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]