android-notify 1.59.1__py3-none-any.whl → 1.59.3__py3-none-any.whl

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.

@@ -7,4 +7,12 @@ def can_accept_arguments(func, *args, **kwargs):
7
7
  sig.bind(*args, **kwargs)
8
8
  return True
9
9
  except TypeError:
10
- return False
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
android_notify/base.py CHANGED
@@ -18,6 +18,7 @@ class BaseNotification:
18
18
  progress_max_value: int = 100
19
19
  progress_current_value: float = 0.0 # Also Takes in Ints
20
20
  body: str = ''
21
+ lines_txt: str = ''
21
22
 
22
23
  # Notification Functions
23
24
  name: str = ''
android_notify/sword.py CHANGED
@@ -2,6 +2,8 @@
2
2
  import traceback
3
3
  import os,re
4
4
  import threading
5
+
6
+
5
7
  from .an_types import Importance
6
8
  from .an_utils import can_accept_arguments
7
9
  from .styles import NotificationStyles
@@ -17,9 +19,16 @@ try:
17
19
  from android.config import ACTIVITY_CLASS_NAME
18
20
  from android.runnable import run_on_ui_thread
19
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
+
20
29
  # Get the required Java classes needs to on android to import
21
30
  Bundle = autoclass('android.os.Bundle')
22
- PythonActivity = autoclass('org.kivy.android.PythonActivity')
31
+ PythonActivity = autoclass(ns+'.PythonActivity')
23
32
  String = autoclass('java.lang.String')
24
33
  Intent = autoclass('android.content.Intent')
25
34
  PendingIntent = autoclass('android.app.PendingIntent')
@@ -32,7 +41,7 @@ try:
32
41
  IconCompat = autoclass('androidx.core.graphics.drawable.IconCompat')
33
42
  ON_ANDROID = True
34
43
  except Exception as e:
35
- if e.name != 'android':
44
+ if hasattr(e,'name') and e.name != 'android':
36
45
  print('Exception: ',e)
37
46
  print(traceback.format_exc())
38
47
 
@@ -41,12 +50,7 @@ except Exception as e:
41
50
  # print(MESSAGE) Already Printing in core.py
42
51
 
43
52
  # This is so no crashes when developing on PC
44
- def run_on_ui_thread(func):
45
- """Fallback for Developing on PC"""
46
- def wrapper(*args, **kwargs):
47
- # print("Simulating run on UI thread")
48
- return func(*args, **kwargs)
49
- return wrapper
53
+ from .an_utils import run_on_ui_thread
50
54
 
51
55
  if ON_ANDROID:
52
56
  try:
@@ -61,6 +65,7 @@ if ON_ANDROID:
61
65
  NotificationCompatBigTextStyle = autoclass('androidx.core.app.NotificationCompat$BigTextStyle')
62
66
  NotificationCompatBigPictureStyle = autoclass('androidx.core.app.NotificationCompat$BigPictureStyle')
63
67
  NotificationCompatInboxStyle = autoclass('androidx.core.app.NotificationCompat$InboxStyle')
68
+ # NotificationCompatDecoratedCustomViewStyle = autoclass('androidx.core.app.NotificationCompat$DecoratedCustomViewStyle')
64
69
  except Exception as e:
65
70
  print(e)
66
71
  print("""
@@ -84,6 +89,7 @@ class Notification(BaseNotification):
84
89
  :param progress_current_value: integer To set progress bar current value.
85
90
  :param progress_max_value: integer To set Max range for progress bar.
86
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`
87
93
  ---
88
94
  (Advance Options)
89
95
  :param id: Pass in Old 'id' to use old instance
@@ -117,6 +123,9 @@ class Notification(BaseNotification):
117
123
  self.__built_parameter_filled=False
118
124
  self.__using_set_priority_method=False
119
125
 
126
+ # For components
127
+ self.__lines = []
128
+
120
129
  self.__format_channel(self.channel_name, self.channel_id)
121
130
  if not ON_ANDROID:
122
131
  return
@@ -126,6 +135,9 @@ class Notification(BaseNotification):
126
135
  self.notification_manager = cast(NotificationManager, notification_service)
127
136
  self.__builder = NotificationCompatBuilder(context, self.channel_id)
128
137
 
138
+ def addLine(self,text:str):
139
+ self.__lines.append(text)
140
+
129
141
  def cancel(self,_id=0):
130
142
  """
131
143
  Removes a Notification instance from tray
@@ -203,6 +215,7 @@ class Notification(BaseNotification):
203
215
  if self.__built_parameter_filled:
204
216
  # Don't dispatch before filling required values `self.__create_basic_notification`
205
217
  # We generally shouldn't dispatch till user call .send()
218
+ self.__applyNewLinesIfAny()
206
219
  self.__dispatch_notification()
207
220
 
208
221
  def setBigPicture(self,path):
@@ -506,11 +519,9 @@ class Notification(BaseNotification):
506
519
  if style == NotificationStyles.BIG_TEXT:
507
520
  self.setBigText(self.body)
508
521
 
509
- elif style == NotificationStyles.INBOX:
510
- inbox_style = NotificationCompatInboxStyle()
511
- for line in self.message.split("\n"):
512
- inbox_style.addLine(str(line))
513
- 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)
514
525
 
515
526
  elif (style == NotificationStyles.LARGE_ICON and self.large_icon_path) or (style == NotificationStyles.BIG_PICTURE and self.big_picture_path):
516
527
  img = self.large_icon_path if style == NotificationStyles.LARGE_ICON else self.big_picture_path
@@ -530,6 +541,20 @@ class Notification(BaseNotification):
530
541
 
531
542
  return True
532
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
+
533
558
  def __dispatch_notification(self):
534
559
  if NotificationHandler.has_permission():
535
560
  self.notification_manager.notify(self.__id, self.__builder.build())
@@ -542,6 +567,12 @@ class Notification(BaseNotification):
542
567
  self.__create_basic_notification(persistent, close_on_click)
543
568
  if self.style not in ['simple','']:
544
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
545
576
 
546
577
  def __create_basic_notification(self, persistent, close_on_click):
547
578
  if BuildVersion.SDK_INT >= 26 and self.notification_manager.getNotificationChannel(self.channel_id) is None:
@@ -562,7 +593,8 @@ class Notification(BaseNotification):
562
593
  self.__built_parameter_filled = True
563
594
 
564
595
  def __insert_app_icon(self,path=''):
565
- if path or self.app_icon not in ['','Defaults to package app icon']:
596
+ if BuildVersion.SDK_INT >= 23 and (path or self.app_icon not in ['','Defaults to package app icon']):
597
+ # Bitmap Insert as Icon Not available below Android 6
566
598
  if self.logs:
567
599
  print('getting custom icon...')
568
600
  self.__set_icon_from_bitmap(path or self.app_icon)
@@ -607,7 +639,9 @@ class Notification(BaseNotification):
607
639
  self.__builder.setSmallIcon(icon)
608
640
  else:
609
641
  if self.logs:
610
- print('Failed getting img for custom notification icon defaulting to app icon')
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}')
611
645
  self.__builder.setSmallIcon(context.getApplicationInfo().icon)
612
646
 
613
647
  @staticmethod
@@ -615,9 +649,13 @@ class Notification(BaseNotification):
615
649
  app_folder=os.path.join(app_storage_path(),'app')
616
650
  output_path = os.path.join(app_folder, relative_path)
617
651
  if not os.path.exists(output_path):
618
- print(f"\nImage not found at path: {output_path}, (Local images gotten from App Path)")
619
- print("These are the existing files in your app Folder:")
620
- print('['+', '.join(os.listdir(app_folder)) + ']')
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")
621
659
  return None
622
660
  # TODO test with a badly written Image and catch error
623
661
  Uri = autoclass('android.net.Uri')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: android-notify
3
- Version: 1.59.1
3
+ Version: 1.59.3
4
4
  Summary: A Python package that simplifies creating Android notifications in Kivy apps.
5
5
  Home-page: https://android-notify.vercel.app
6
6
  Author: Fabian
@@ -0,0 +1,12 @@
1
+ android_notify/__init__.py,sha256=lcLjyfegXgU7cyGhfSphAOBipXwemrVkdYy3mcF6X5Y,172
2
+ android_notify/__main__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ android_notify/an_types.py,sha256=LlE0zzPskVG2topZx3mVETGu5MqnpThs58Ph392ocy4,2390
4
+ android_notify/an_utils.py,sha256=ZEP_67Til9WdX0nyFpVQ9lSJnUG6uyHMWzUn7Q6s1OI,452
5
+ android_notify/base.py,sha256=PAF8-Jw60395O32ZGJ8xSJXIQbUglpYgngfJycCYCeY,3501
6
+ android_notify/core.py,sha256=Per4HFwYwP-mxHJqnwcLlWXsbZsSeeAYN49MmFU2qVk,6113
7
+ android_notify/styles.py,sha256=jLxeXB41HXe0fn3l07JZsHi-d0u-dESvsV_OqQow_Xc,726
8
+ android_notify/sword.py,sha256=0bDNXUqZqa7OXP4mISmJjf6W8jUe-26Txfmsk-s3yKI,39810
9
+ android_notify-1.59.3.dist-info/METADATA,sha256=NejpmdEysbWtDi2quXTlYZr23NoTbBFf-FKjwTIc3WE,4375
10
+ android_notify-1.59.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
+ android_notify-1.59.3.dist-info/top_level.txt,sha256=IR1ONMrRSRINZpWn2X0dL5gbWwWINsK7PW8Jy2p4fU8,15
12
+ android_notify-1.59.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.0.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,12 +0,0 @@
1
- android_notify/__init__.py,sha256=lcLjyfegXgU7cyGhfSphAOBipXwemrVkdYy3mcF6X5Y,172
2
- android_notify/__main__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- android_notify/an_types.py,sha256=LlE0zzPskVG2topZx3mVETGu5MqnpThs58Ph392ocy4,2390
4
- android_notify/an_utils.py,sha256=Io34r5JTorH3EbeR0bIfQ-8-bF3xO1wiVnvqafA2qyw,245
5
- android_notify/base.py,sha256=Fgv3hf-vwu-GvivDsKxseOyeOrLmw1moNAv_mZKvA5M,3477
6
- android_notify/core.py,sha256=Per4HFwYwP-mxHJqnwcLlWXsbZsSeeAYN49MmFU2qVk,6113
7
- android_notify/styles.py,sha256=jLxeXB41HXe0fn3l07JZsHi-d0u-dESvsV_OqQow_Xc,726
8
- android_notify/sword.py,sha256=Zut_Yr2rYsgW4PcjI6bpfHA37Lj9bpvG_ni6DGAIQgE,38327
9
- android_notify-1.59.1.dist-info/METADATA,sha256=D62WBGubg7FG5Pr8AY-rVTkGF-BpmmKDkqBA2R6QuTI,4375
10
- android_notify-1.59.1.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
11
- android_notify-1.59.1.dist-info/top_level.txt,sha256=IR1ONMrRSRINZpWn2X0dL5gbWwWINsK7PW8Jy2p4fU8,15
12
- android_notify-1.59.1.dist-info/RECORD,,