android-notify 1.59.2__tar.gz → 1.59.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of android-notify might be problematic. Click here for more details.
- {android_notify-1.59.2 → android_notify-1.59.3}/PKG-INFO +1 -1
- android_notify-1.59.3/android_notify/an_utils.py +18 -0
- {android_notify-1.59.2 → android_notify-1.59.3}/android_notify/base.py +1 -0
- {android_notify-1.59.2 → android_notify-1.59.3}/android_notify/sword.py +51 -16
- {android_notify-1.59.2 → android_notify-1.59.3}/android_notify.egg-info/PKG-INFO +1 -1
- {android_notify-1.59.2 → android_notify-1.59.3}/setup.py +1 -1
- android_notify-1.59.2/android_notify/an_utils.py +0 -10
- {android_notify-1.59.2 → android_notify-1.59.3}/README.md +0 -0
- {android_notify-1.59.2 → android_notify-1.59.3}/android_notify/__init__.py +0 -0
- {android_notify-1.59.2 → android_notify-1.59.3}/android_notify/__main__.py +0 -0
- {android_notify-1.59.2 → android_notify-1.59.3}/android_notify/an_types.py +0 -0
- {android_notify-1.59.2 → android_notify-1.59.3}/android_notify/core.py +0 -0
- {android_notify-1.59.2 → android_notify-1.59.3}/android_notify/styles.py +0 -0
- {android_notify-1.59.2 → android_notify-1.59.3}/android_notify.egg-info/SOURCES.txt +0 -0
- {android_notify-1.59.2 → android_notify-1.59.3}/android_notify.egg-info/dependency_links.txt +0 -0
- {android_notify-1.59.2 → android_notify-1.59.3}/android_notify.egg-info/requires.txt +0 -0
- {android_notify-1.59.2 → android_notify-1.59.3}/android_notify.egg-info/top_level.txt +0 -0
- {android_notify-1.59.2 → android_notify-1.59.3}/setup.cfg +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Collection of useful functions"""
|
|
2
|
+
|
|
3
|
+
import inspect
|
|
4
|
+
def can_accept_arguments(func, *args, **kwargs):
|
|
5
|
+
try:
|
|
6
|
+
sig = inspect.signature(func)
|
|
7
|
+
sig.bind(*args, **kwargs)
|
|
8
|
+
return True
|
|
9
|
+
except TypeError:
|
|
10
|
+
return False
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def run_on_ui_thread(func):
|
|
14
|
+
"""Fallback for Developing on PC"""
|
|
15
|
+
def wrapper(*args, **kwargs):
|
|
16
|
+
# print("Simulating run on UI thread")
|
|
17
|
+
return func(*args, **kwargs)
|
|
18
|
+
return wrapper
|
|
@@ -19,9 +19,16 @@ try:
|
|
|
19
19
|
from android.config import ACTIVITY_CLASS_NAME
|
|
20
20
|
from android.runnable import run_on_ui_thread
|
|
21
21
|
|
|
22
|
+
try:
|
|
23
|
+
from android import config
|
|
24
|
+
ns = config.JAVA_NAMESPACE
|
|
25
|
+
# print('This is Java name space:',ns)
|
|
26
|
+
except (ImportError,AttributeError):
|
|
27
|
+
ns='org.kivy.android'
|
|
28
|
+
|
|
22
29
|
# Get the required Java classes needs to on android to import
|
|
23
30
|
Bundle = autoclass('android.os.Bundle')
|
|
24
|
-
PythonActivity = autoclass('
|
|
31
|
+
PythonActivity = autoclass(ns+'.PythonActivity')
|
|
25
32
|
String = autoclass('java.lang.String')
|
|
26
33
|
Intent = autoclass('android.content.Intent')
|
|
27
34
|
PendingIntent = autoclass('android.app.PendingIntent')
|
|
@@ -43,12 +50,7 @@ except Exception as e:
|
|
|
43
50
|
# print(MESSAGE) Already Printing in core.py
|
|
44
51
|
|
|
45
52
|
# This is so no crashes when developing on PC
|
|
46
|
-
|
|
47
|
-
"""Fallback for Developing on PC"""
|
|
48
|
-
def wrapper(*args, **kwargs):
|
|
49
|
-
# print("Simulating run on UI thread")
|
|
50
|
-
return func(*args, **kwargs)
|
|
51
|
-
return wrapper
|
|
53
|
+
from .an_utils import run_on_ui_thread
|
|
52
54
|
|
|
53
55
|
if ON_ANDROID:
|
|
54
56
|
try:
|
|
@@ -63,6 +65,7 @@ if ON_ANDROID:
|
|
|
63
65
|
NotificationCompatBigTextStyle = autoclass('androidx.core.app.NotificationCompat$BigTextStyle')
|
|
64
66
|
NotificationCompatBigPictureStyle = autoclass('androidx.core.app.NotificationCompat$BigPictureStyle')
|
|
65
67
|
NotificationCompatInboxStyle = autoclass('androidx.core.app.NotificationCompat$InboxStyle')
|
|
68
|
+
# NotificationCompatDecoratedCustomViewStyle = autoclass('androidx.core.app.NotificationCompat$DecoratedCustomViewStyle')
|
|
66
69
|
except Exception as e:
|
|
67
70
|
print(e)
|
|
68
71
|
print("""
|
|
@@ -86,6 +89,7 @@ class Notification(BaseNotification):
|
|
|
86
89
|
:param progress_current_value: integer To set progress bar current value.
|
|
87
90
|
:param progress_max_value: integer To set Max range for progress bar.
|
|
88
91
|
:param body: large text For `big_Text` style, while `message` acts as subtitle.
|
|
92
|
+
:param lines_txt: text separated by newLine symbol For `inbox` style `use addLine method instead`
|
|
89
93
|
---
|
|
90
94
|
(Advance Options)
|
|
91
95
|
:param id: Pass in Old 'id' to use old instance
|
|
@@ -119,6 +123,9 @@ class Notification(BaseNotification):
|
|
|
119
123
|
self.__built_parameter_filled=False
|
|
120
124
|
self.__using_set_priority_method=False
|
|
121
125
|
|
|
126
|
+
# For components
|
|
127
|
+
self.__lines = []
|
|
128
|
+
|
|
122
129
|
self.__format_channel(self.channel_name, self.channel_id)
|
|
123
130
|
if not ON_ANDROID:
|
|
124
131
|
return
|
|
@@ -128,6 +135,9 @@ class Notification(BaseNotification):
|
|
|
128
135
|
self.notification_manager = cast(NotificationManager, notification_service)
|
|
129
136
|
self.__builder = NotificationCompatBuilder(context, self.channel_id)
|
|
130
137
|
|
|
138
|
+
def addLine(self,text:str):
|
|
139
|
+
self.__lines.append(text)
|
|
140
|
+
|
|
131
141
|
def cancel(self,_id=0):
|
|
132
142
|
"""
|
|
133
143
|
Removes a Notification instance from tray
|
|
@@ -205,6 +215,7 @@ class Notification(BaseNotification):
|
|
|
205
215
|
if self.__built_parameter_filled:
|
|
206
216
|
# Don't dispatch before filling required values `self.__create_basic_notification`
|
|
207
217
|
# We generally shouldn't dispatch till user call .send()
|
|
218
|
+
self.__applyNewLinesIfAny()
|
|
208
219
|
self.__dispatch_notification()
|
|
209
220
|
|
|
210
221
|
def setBigPicture(self,path):
|
|
@@ -508,11 +519,9 @@ class Notification(BaseNotification):
|
|
|
508
519
|
if style == NotificationStyles.BIG_TEXT:
|
|
509
520
|
self.setBigText(self.body)
|
|
510
521
|
|
|
511
|
-
elif style == NotificationStyles.INBOX:
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
inbox_style.addLine(str(line))
|
|
515
|
-
self.__builder.setStyle(inbox_style)
|
|
522
|
+
elif style == NotificationStyles.INBOX and self.lines_txt:
|
|
523
|
+
lines = self.lines_txt.split("\n")
|
|
524
|
+
self.setLines(lines)
|
|
516
525
|
|
|
517
526
|
elif (style == NotificationStyles.LARGE_ICON and self.large_icon_path) or (style == NotificationStyles.BIG_PICTURE and self.big_picture_path):
|
|
518
527
|
img = self.large_icon_path if style == NotificationStyles.LARGE_ICON else self.big_picture_path
|
|
@@ -532,6 +541,20 @@ class Notification(BaseNotification):
|
|
|
532
541
|
|
|
533
542
|
return True
|
|
534
543
|
|
|
544
|
+
def setLines(self, lines: list):
|
|
545
|
+
"""Pass in a list of strings to be used for lines"""
|
|
546
|
+
if not lines:
|
|
547
|
+
return
|
|
548
|
+
if ON_ANDROID:
|
|
549
|
+
inbox_style = NotificationCompatInboxStyle()
|
|
550
|
+
for line in lines:
|
|
551
|
+
inbox_style.addLine(str(line))
|
|
552
|
+
self.__builder.setStyle(inbox_style)
|
|
553
|
+
print('Set Lines: ', lines)
|
|
554
|
+
|
|
555
|
+
if self.logs:
|
|
556
|
+
print('Added Lines: ', lines)
|
|
557
|
+
|
|
535
558
|
def __dispatch_notification(self):
|
|
536
559
|
if NotificationHandler.has_permission():
|
|
537
560
|
self.notification_manager.notify(self.__id, self.__builder.build())
|
|
@@ -544,6 +567,12 @@ class Notification(BaseNotification):
|
|
|
544
567
|
self.__create_basic_notification(persistent, close_on_click)
|
|
545
568
|
if self.style not in ['simple','']:
|
|
546
569
|
self.addNotificationStyle(self.style)
|
|
570
|
+
self.__applyNewLinesIfAny()
|
|
571
|
+
|
|
572
|
+
def __applyNewLinesIfAny(self):
|
|
573
|
+
if self.__lines:
|
|
574
|
+
self.setLines(self.__lines)
|
|
575
|
+
self.__lines=[] # for refresh method to known when new lines added
|
|
547
576
|
|
|
548
577
|
def __create_basic_notification(self, persistent, close_on_click):
|
|
549
578
|
if BuildVersion.SDK_INT >= 26 and self.notification_manager.getNotificationChannel(self.channel_id) is None:
|
|
@@ -610,7 +639,9 @@ class Notification(BaseNotification):
|
|
|
610
639
|
self.__builder.setSmallIcon(icon)
|
|
611
640
|
else:
|
|
612
641
|
if self.logs:
|
|
613
|
-
|
|
642
|
+
app_folder=os.path.join(app_storage_path(),'app')
|
|
643
|
+
img_absolute_path = os.path.join(app_folder, img_path)
|
|
644
|
+
print(f'Failed getting img for custom notification icon defaulting to app icon\n absolute path {img_absolute_path}')
|
|
614
645
|
self.__builder.setSmallIcon(context.getApplicationInfo().icon)
|
|
615
646
|
|
|
616
647
|
@staticmethod
|
|
@@ -618,9 +649,13 @@ class Notification(BaseNotification):
|
|
|
618
649
|
app_folder=os.path.join(app_storage_path(),'app')
|
|
619
650
|
output_path = os.path.join(app_folder, relative_path)
|
|
620
651
|
if not os.path.exists(output_path):
|
|
621
|
-
print(f"\nImage not found at path: {
|
|
622
|
-
|
|
623
|
-
|
|
652
|
+
print(f"\nImage not found at path: {app_folder}, (Local images gotten from App Path)")
|
|
653
|
+
try:
|
|
654
|
+
print("- These are the existing files in your app Folder:")
|
|
655
|
+
print('['+', '.join(os.listdir(app_folder)) + ']')
|
|
656
|
+
except Exception as could_not_get_files_in_path_error:
|
|
657
|
+
print('Exception: ', could_not_get_files_in_path_error)
|
|
658
|
+
print("Couldn't get Files in App Folder")
|
|
624
659
|
return None
|
|
625
660
|
# TODO test with a badly written Image and catch error
|
|
626
661
|
Uri = autoclass('android.net.Uri')
|
|
@@ -6,7 +6,7 @@ with open("README.md", "r", encoding="utf-8") as readme_data:
|
|
|
6
6
|
|
|
7
7
|
setup(
|
|
8
8
|
name="android-notify",
|
|
9
|
-
version="1.59.
|
|
9
|
+
version="1.59.3",
|
|
10
10
|
author="Fabian",
|
|
11
11
|
author_email='fector101@yahoo.com',
|
|
12
12
|
description="A Python package that simplifies creating Android notifications in Kivy apps.",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{android_notify-1.59.2 → android_notify-1.59.3}/android_notify.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|