# HG changeset patch # User Goffi # Date 1582468746 -3600 # Node ID c466678c57b2f36d821815fd3e5f9317adbf7aa2 # Parent 7c6149c249c18d8a3a9b532edb9948d9d679beef chat: control send button visibility in core.platform_, and show it when there are attachments diff -r 7c6149c249c1 -r c466678c57b2 cagou/core/platform_/android.py --- a/cagou/core/platform_/android.py Sun Feb 23 15:39:03 2020 +0100 +++ b/cagou/core/platform_/android.py Sun Feb 23 15:39:06 2020 +0100 @@ -71,6 +71,7 @@ class Platform(BasePlatform): + send_button_visible = True def __init__(self): super().__init__() diff -r 7c6149c249c1 -r c466678c57b2 cagou/core/platform_/base.py --- a/cagou/core/platform_/base.py Sun Feb 23 15:39:03 2020 +0100 +++ b/cagou/core/platform_/base.py Sun Feb 23 15:39:06 2020 +0100 @@ -34,6 +34,8 @@ class Platform: """Base class to handle platform specific behaviours""" + # set to True to always show the send button in chat + send_button_visible = False def init_platform(self): # we don't want multi-touch emulation with mouse diff -r 7c6149c249c1 -r c466678c57b2 cagou/plugins/plugin_wid_chat.kv --- a/cagou/plugins/plugin_wid_chat.kv Sun Feb 23 15:39:03 2020 +0100 +++ b/cagou/plugins/plugin_wid_chat.kv Sun Feb 23 15:39:06 2020 +0100 @@ -171,6 +171,7 @@ message_input: message_input messages_widget: messages_widget history_scroll: history_scroll + send_button_visible: G.local_platform.send_button_visible or bool(attachments_to_send.attachments.children) ScrollView: id: history_scroll scroll_y: 0 @@ -201,15 +202,15 @@ multiline: True hint_text: _(u"Enter your message here") on_text_validate: root.onSend(args[0]) - + SymbolButton: + # "send" button, permanent visibility depends on platform + symbol: "forward" + size_hint: None, 1 + width: dp(30) if root.send_button_visible else 0 + opacity: 1 if root.send_button_visible else 0 + font_size: dp(25) + on_release: self.parent.send_text() -: - # SendButton is only shown on touch devices - symbol: "forward" - size_hint: None, 1 - width: dp(30) - font_size: dp(25) - on_release: self.message_input_box.send_text() # Buttons added in header diff -r 7c6149c249c1 -r c466678c57b2 cagou/plugins/plugin_wid_chat.py --- a/cagou/plugins/plugin_wid_chat.py Sun Feb 23 15:39:03 2020 +0100 +++ b/cagou/plugins/plugin_wid_chat.py Sun Feb 23 15:39:06 2020 +0100 @@ -210,21 +210,9 @@ layout.add_widget(item) -class SendButton(SymbolButton): - message_input_box = properties.ObjectProperty() - - class MessageInputBox(BoxLayout): message_input = properties.ObjectProperty() - def __init__(self, *args, **kwargs): - super(MessageInputBox, self).__init__(*args, **kwargs) - Clock.schedule_once(self.post_init, 0) - - def post_init(self, *args): - if sys.platform == 'android': - self.add_widget(SendButton(message_input_box=self), 0) - def send_text(self): self.message_input.send_text() @@ -459,6 +447,7 @@ messages_widget = properties.ObjectProperty() history_scroll = properties.ObjectProperty() attachments_to_send = properties.ObjectProperty() + send_button_visible = properties.BooleanProperty() use_header_input = True global_screen_manager = True collection_carousel = True