android-notify 1.59__py3-none-any.whl → 1.59.1__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.

@@ -0,0 +1,10 @@
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
android_notify/styles.py CHANGED
@@ -6,8 +6,14 @@ class NotificationStyles:
6
6
 
7
7
  PROGRESS = "progress"
8
8
  INBOX = "inbox"
9
+
10
+ # v1.59+
11
+ # Deprecated
12
+ # setBigText == Notification(...,big_picture_path="...",style=NotificationStyles.BIG_TEXT)
13
+ # setLargeIcon == Notification(...,large_icon_path="...",style=NotificationStyles.LARGE_ICON)
14
+ # setBigPicture == Notification(...,body="...",style=NotificationStyles.BIG_PICTURE)
15
+ # Use .refresh to apply any new changes after .send
9
16
  BIG_TEXT = "big_text"
10
-
11
17
  LARGE_ICON = "large_icon"
12
18
  BIG_PICTURE = "big_picture"
13
19
  BOTH_IMGS = "both_imgs"
android_notify/sword.py CHANGED
@@ -3,6 +3,7 @@ import traceback
3
3
  import os,re
4
4
  import threading
5
5
  from .an_types import Importance
6
+ from .an_utils import can_accept_arguments
6
7
  from .styles import NotificationStyles
7
8
  from .base import BaseNotification
8
9
  DEV=0
@@ -218,7 +219,7 @@ class Notification(BaseNotification):
218
219
 
219
220
  def setSmallIcon(self,path):
220
221
  """
221
- sets small icon to the top right
222
+ sets small icon to the top left
222
223
  :param path: can be `Relative Path` or `URL`
223
224
  :return:
224
225
  """
@@ -241,6 +242,10 @@ class Notification(BaseNotification):
241
242
  print('Done setting large icon')
242
243
 
243
244
  def setBigText(self,body):
245
+ """Sets a big text for when drop down button is pressed
246
+
247
+ :param body: The big text that will be displayed
248
+ """
244
249
  if ON_ANDROID:
245
250
  big_text_style = NotificationCompatBigTextStyle()
246
251
  big_text_style.bigText(str(body))
@@ -526,7 +531,12 @@ class Notification(BaseNotification):
526
531
  return True
527
532
 
528
533
  def __dispatch_notification(self):
529
- self.notification_manager.notify(self.__id, self.__builder.build())
534
+ if NotificationHandler.has_permission():
535
+ self.notification_manager.notify(self.__id, self.__builder.build())
536
+ else:
537
+ print('Permission not granted to send notifications')
538
+ # Not asking for permission too frequently, This makes dialog popup to stop showing
539
+ # NotificationHandler.asks_permission()
530
540
 
531
541
  def __start_notification_build(self, persistent, close_on_click):
532
542
  self.__create_basic_notification(persistent, close_on_click)
@@ -768,7 +778,7 @@ class NotificationHandler:
768
778
  """For Notification Operations """
769
779
  __name = None
770
780
  __bound = False
771
-
781
+ __requesting_permission=False
772
782
  @classmethod
773
783
  def get_name(cls):
774
784
  """Returns name or id str for Clicked Notification."""
@@ -876,22 +886,38 @@ class NotificationHandler:
876
886
  return check_permission(Permission.POST_NOTIFICATIONS)
877
887
 
878
888
  @classmethod
889
+ @run_on_ui_thread
879
890
  def asks_permission(cls,callback=None):
880
891
  """
881
892
  Ask for permission to send notifications if needed.
893
+ Passes True to callback if access granted
882
894
  """
883
- if not ON_ANDROID:
884
- return
885
- def on_permissions_result(permissions, grant):
886
- print("Permission Grant State: ",grant)
895
+ if cls.__requesting_permission or not ON_ANDROID:
896
+ return True
897
+
898
+ def on_permissions_result(permissions, grants):
887
899
  try:
888
900
  if callback:
889
- callback()
901
+ if can_accept_arguments(callback, True):
902
+ callback(grants[0])
903
+ else:
904
+ callback()
890
905
  except Exception as request_permission_error:
891
906
  print('Exception: ',request_permission_error)
892
- print('Permission request callback error: ',traceback.format_exc())
907
+ print('Permission response callback error: ',traceback.format_exc())
908
+ finally:
909
+ cls.__requesting_permission = False
910
+
893
911
  if not cls.has_permission():
912
+ cls.__requesting_permission = True
894
913
  request_permissions([Permission.POST_NOTIFICATIONS],on_permissions_result)
914
+ else:
915
+ cls.__requesting_permission = False
916
+ if callback:
917
+ if can_accept_arguments(callback,True):
918
+ callback(True)
919
+ else:
920
+ callback()
895
921
 
896
922
 
897
923
  NotificationHandler.bindNotifyListener()
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: android-notify
3
- Version: 1.59
3
+ Version: 1.59.1
4
4
  Summary: A Python package that simplifies creating Android notifications in Kivy apps.
5
- Home-page: https://github.com/fector101/android-notify
5
+ Home-page: https://android-notify.vercel.app
6
6
  Author: Fabian
7
7
  Author-email: fector101@yahoo.com
8
8
  License: MIT
9
- Project-URL: Documentation, https://android-notify.vercel.app/getting-started
9
+ Project-URL: Documentation, https://android-notify.vercel.app/
10
10
  Project-URL: Source, https://github.com/fector101/android-notify
11
11
  Project-URL: Tracker, https://github.com/fector101/android-notify/issues
12
12
  Project-URL: Funding, https://www.buymeacoffee.com/fector101
@@ -36,13 +36,13 @@ Dynamic: summary
36
36
 
37
37
  <div align="center">
38
38
  <br>
39
- <h1> Android-Notifiy </h1>
40
- <p><a href='https://android-notify.vercel.app/getting-started'>Android Notify</a> is a Python library for effortlessly creating and managing Android notifications in Kivy android apps.</p>
39
+ <h1> Android-Notify </h1>
40
+ <p><a href='https://android-notify.vercel.app'>Android Notify</a> is a Python library for effortlessly creating and managing Android notifications in Kivy apps.</p>
41
41
  <p>Supports various styles and ensures seamless integration, customization and Pythonic APIs.</p>
42
42
  <!-- <br> -->
43
43
  <!-- <img src="https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/democollage.jpg"> -->
44
44
  </div>
45
- <!--
45
+ <!-- Channel [CRUD]
46
46
  The Android Notify package provides a simple yet comprehensive way to create and manage rich notifications on Android devices directly from your Python code. This library bridges the gap between Python and Android's notification system, giving you full control over notifications with a clean, Pythonic API. -->
47
47
 
48
48
  ## Features
@@ -60,10 +60,12 @@ The Android Notify package provides a simple yet comprehensive way to create and
60
60
  - Add action buttons with custom callbacks
61
61
  - Update notification content dynamically
62
62
  - Manage progress bars with fine-grained control
63
- - Custom notification channels for Android 8.0+
63
+ - Custom notification Icon
64
+ - Custom notification channels for Android 8.0+ (Creating and Deleting)
64
65
  - Silent notifications
65
66
  - Persistent notifications
66
67
  - Click handlers and callbacks
68
+ - Cancel Notifications
67
69
 
68
70
  ## Quick Start
69
71
 
@@ -106,7 +108,7 @@ pip install android_notify
106
108
  ## Documentation
107
109
 
108
110
  For full documentation, examples, and advanced usage, API reference visit the
109
- [documentation](https://android-notify.vercel.app/getting-started)
111
+ [documentation](https://android-notify.vercel.app)
110
112
 
111
113
  ## ☕ Support the Project
112
114
 
@@ -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=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,,
@@ -1,11 +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/base.py,sha256=Fgv3hf-vwu-GvivDsKxseOyeOrLmw1moNAv_mZKvA5M,3477
5
- android_notify/core.py,sha256=Per4HFwYwP-mxHJqnwcLlWXsbZsSeeAYN49MmFU2qVk,6113
6
- android_notify/styles.py,sha256=QBkCY8ZO26FnS-jPtRLf9CKEEnnYylmH9enCa5CNDes,354
7
- android_notify/sword.py,sha256=hBNIJDDszEozbvkXHuWhmiRz-9q2Kz4WBEnV1LAe8vw,37291
8
- android_notify-1.59.dist-info/METADATA,sha256=U4RSxaMqEaWBoS82Kp5L66992cka8MixFGwYlqYQiHM,4347
9
- android_notify-1.59.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
10
- android_notify-1.59.dist-info/top_level.txt,sha256=IR1ONMrRSRINZpWn2X0dL5gbWwWINsK7PW8Jy2p4fU8,15
11
- android_notify-1.59.dist-info/RECORD,,