diff options
| author | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-07-19 19:50:33 (GMT) |
|---|---|---|
| committer | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-07-19 19:50:33 (GMT) |
| commit | a01fb7df573e13a6f6b9fbf2e7688d4e9713df6d (patch) | |
| tree | 5118831a0fa174681ade9aaf850b7613309a2803 /wasp/apps/pager.py | |
| parent | 6686f17e724b9a22318ff2248ce126a97dd19db4 (diff) | |
Introduction basic notification support
This requires a modified version of Gadgetbridge and currently works by
implementing the BangleJS protocol.
In Gadgetbridge ensure "Sync time" is *not* set and choose "Don't pair"
when adding the PineTime device.
Diffstat (limited to 'wasp/apps/pager.py')
| -rw-r--r-- | wasp/apps/pager.py | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/wasp/apps/pager.py b/wasp/apps/pager.py index 18322d2..edb5418 100644 --- a/wasp/apps/pager.py +++ b/wasp/apps/pager.py @@ -26,16 +26,13 @@ class PagerApp(): def foreground(self): """Activate the application.""" - self._page = 0 - self._chunks = wasp.watch.drawable.wrap(self._msg, 240) - self._numpages = (len(self._chunks) - 2) // 9 wasp.system.request_event(wasp.EventMask.SWIPE_UPDOWN) - self._draw() + self._redraw() def background(self): """De-activate the application.""" - del self._chunks - del self._numpages + self._chunks = None + self._numpages = None def swipe(self, event): """Swipe to page up/down.""" @@ -55,8 +52,15 @@ class PagerApp(): self._draw() mute(False) + def _redraw(self): + """Redraw from scratch (jump to the first page)""" + self._page = 0 + self._chunks = wasp.watch.drawable.wrap(self._msg, 240) + self._numpages = (len(self._chunks) - 2) // 9 + self._draw() + def _draw(self): - """Draw the display from scratch.""" + """Draw a page from scratch.""" draw = wasp.watch.drawable draw.fill() @@ -73,6 +77,22 @@ class PagerApp(): scroll.down = page < self._numpages scroll.draw() +class NotificationApp(PagerApp): + NAME = 'Notifications' + + def __init__(self): + super().__init__('') + + def foreground(self): + notes = wasp.system.notifications + + id = next(iter(notes)) + note = notes[id] + del notes[id] + self._msg = '{}\n\n{}'.format(note['title'], note['body']) + + super().foreground() + class CrashApp(): """Crash handler application. |
