From 23ef17d4c79da51ea43b0dffc09647efc8f7184a Mon Sep 17 00:00:00 2001 From: Simone Margaritelli Date: Wed, 23 Oct 2019 15:14:55 +0200 Subject: [PATCH] fix: using normal status to signal unread messages in order to avoid BT overlap bug --- pwnagotchi/plugins/default/grid.py | 14 ++------------ pwnagotchi/ui/view.py | 5 +++++ pwnagotchi/voice.py | 4 ++++ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/pwnagotchi/plugins/default/grid.py b/pwnagotchi/plugins/default/grid.py index cfb5d8f..5b32635 100644 --- a/pwnagotchi/plugins/default/grid.py +++ b/pwnagotchi/plugins/default/grid.py @@ -66,18 +66,8 @@ def is_excluded(what): def on_ui_update(ui): - new_value = ' %d (%d)' % (UNREAD_MESSAGES, TOTAL_MESSAGES) - if not ui.has_element('mailbox') and UNREAD_MESSAGES > 0: - if ui.is_inky(): - pos = (80, 0) - else: - pos = (100, 0) - ui.add_element('mailbox', - LabeledValue(color=BLACK, label='MSG', value=new_value, - position=pos, - label_font=fonts.Bold, - text_font=fonts.Medium)) - ui.set('mailbox', new_value) + if UNREAD_MESSAGES > 0: + ui.on_unread_messages(UNREAD_MESSAGES, TOTAL_MESSAGES) def set_reported(reported, net_id): diff --git a/pwnagotchi/ui/view.py b/pwnagotchi/ui/view.py index a2f2d2c..dcb31a2 100644 --- a/pwnagotchi/ui/view.py +++ b/pwnagotchi/ui/view.py @@ -300,6 +300,11 @@ class View(object): self.set('status', self._voice.on_handshakes(new_shakes)) self.update() + def on_unread_messages(self, count, total): + self.set('face', faces.EXCITED) + self.set('status', self._voice.on_unread_messages(count, total)) + self.update() + def on_rebooting(self): self.set('face', faces.BROKEN) self.set('status', self._voice.on_rebooting()) diff --git a/pwnagotchi/voice.py b/pwnagotchi/voice.py index 61689cf..530c815 100644 --- a/pwnagotchi/voice.py +++ b/pwnagotchi/voice.py @@ -129,6 +129,10 @@ class Voice: s = 's' if new_shakes > 1 else '' return self._('Cool, we got {num} new handshake{plural}!').format(num=new_shakes, plural=s) + def on_unread_messages(self, count, total): + s = 's' if count > 1 else '' + return self._('You have {count} new message{plural}!').format(num=count, plural=s) + def on_rebooting(self): return self._("Ops, something went wrong ... Rebooting ...")