android-notify 1.59__tar.gz → 1.59.2__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.

@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: android-notify
3
- Version: 1.59
3
+ Version: 1.59.2
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
 
@@ -1,12 +1,12 @@
1
1
  <div align="center">
2
2
  <br>
3
- <h1> Android-Notifiy </h1>
4
- <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>
3
+ <h1> Android-Notify </h1>
4
+ <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>
5
5
  <p>Supports various styles and ensures seamless integration, customization and Pythonic APIs.</p>
6
6
  <!-- <br> -->
7
7
  <!-- <img src="https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/democollage.jpg"> -->
8
8
  </div>
9
- <!--
9
+ <!-- Channel [CRUD]
10
10
  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. -->
11
11
 
12
12
  ## Features
@@ -24,10 +24,12 @@ The Android Notify package provides a simple yet comprehensive way to create and
24
24
  - Add action buttons with custom callbacks
25
25
  - Update notification content dynamically
26
26
  - Manage progress bars with fine-grained control
27
- - Custom notification channels for Android 8.0+
27
+ - Custom notification Icon
28
+ - Custom notification channels for Android 8.0+ (Creating and Deleting)
28
29
  - Silent notifications
29
30
  - Persistent notifications
30
31
  - Click handlers and callbacks
32
+ - Cancel Notifications
31
33
 
32
34
  ## Quick Start
33
35
 
@@ -70,7 +72,7 @@ pip install android_notify
70
72
  ## Documentation
71
73
 
72
74
  For full documentation, examples, and advanced usage, API reference visit the
73
- [documentation](https://android-notify.vercel.app/getting-started)
75
+ [documentation](https://android-notify.vercel.app)
74
76
 
75
77
  ## ☕ Support the Project
76
78
 
@@ -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
@@ -0,0 +1,22 @@
1
+ """Contains Safe way to call Styles"""
2
+
3
+ class NotificationStyles:
4
+ """ Safely Adding Styles"""
5
+ DEFAULT = "simple"
6
+
7
+ PROGRESS = "progress"
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
16
+ BIG_TEXT = "big_text"
17
+ LARGE_ICON = "large_icon"
18
+ BIG_PICTURE = "big_picture"
19
+ BOTH_IMGS = "both_imgs"
20
+
21
+ # MESSAGING = "messaging" # TODO
22
+ # CUSTOM = "custom" # TODO
@@ -2,7 +2,10 @@
2
2
  import traceback
3
3
  import os,re
4
4
  import threading
5
+
6
+
5
7
  from .an_types import Importance
8
+ from .an_utils import can_accept_arguments
6
9
  from .styles import NotificationStyles
7
10
  from .base import BaseNotification
8
11
  DEV=0
@@ -31,7 +34,7 @@ try:
31
34
  IconCompat = autoclass('androidx.core.graphics.drawable.IconCompat')
32
35
  ON_ANDROID = True
33
36
  except Exception as e:
34
- if e.name != 'android':
37
+ if hasattr(e,'name') and e.name != 'android':
35
38
  print('Exception: ',e)
36
39
  print(traceback.format_exc())
37
40
 
@@ -218,7 +221,7 @@ class Notification(BaseNotification):
218
221
 
219
222
  def setSmallIcon(self,path):
220
223
  """
221
- sets small icon to the top right
224
+ sets small icon to the top left
222
225
  :param path: can be `Relative Path` or `URL`
223
226
  :return:
224
227
  """
@@ -241,6 +244,10 @@ class Notification(BaseNotification):
241
244
  print('Done setting large icon')
242
245
 
243
246
  def setBigText(self,body):
247
+ """Sets a big text for when drop down button is pressed
248
+
249
+ :param body: The big text that will be displayed
250
+ """
244
251
  if ON_ANDROID:
245
252
  big_text_style = NotificationCompatBigTextStyle()
246
253
  big_text_style.bigText(str(body))
@@ -526,7 +533,12 @@ class Notification(BaseNotification):
526
533
  return True
527
534
 
528
535
  def __dispatch_notification(self):
529
- self.notification_manager.notify(self.__id, self.__builder.build())
536
+ if NotificationHandler.has_permission():
537
+ self.notification_manager.notify(self.__id, self.__builder.build())
538
+ else:
539
+ print('Permission not granted to send notifications')
540
+ # Not asking for permission too frequently, This makes dialog popup to stop showing
541
+ # NotificationHandler.asks_permission()
530
542
 
531
543
  def __start_notification_build(self, persistent, close_on_click):
532
544
  self.__create_basic_notification(persistent, close_on_click)
@@ -552,7 +564,8 @@ class Notification(BaseNotification):
552
564
  self.__built_parameter_filled = True
553
565
 
554
566
  def __insert_app_icon(self,path=''):
555
- if path or self.app_icon not in ['','Defaults to package app icon']:
567
+ if BuildVersion.SDK_INT >= 23 and (path or self.app_icon not in ['','Defaults to package app icon']):
568
+ # Bitmap Insert as Icon Not available below Android 6
556
569
  if self.logs:
557
570
  print('getting custom icon...')
558
571
  self.__set_icon_from_bitmap(path or self.app_icon)
@@ -768,7 +781,7 @@ class NotificationHandler:
768
781
  """For Notification Operations """
769
782
  __name = None
770
783
  __bound = False
771
-
784
+ __requesting_permission=False
772
785
  @classmethod
773
786
  def get_name(cls):
774
787
  """Returns name or id str for Clicked Notification."""
@@ -876,22 +889,38 @@ class NotificationHandler:
876
889
  return check_permission(Permission.POST_NOTIFICATIONS)
877
890
 
878
891
  @classmethod
892
+ @run_on_ui_thread
879
893
  def asks_permission(cls,callback=None):
880
894
  """
881
895
  Ask for permission to send notifications if needed.
896
+ Passes True to callback if access granted
882
897
  """
883
- if not ON_ANDROID:
884
- return
885
- def on_permissions_result(permissions, grant):
886
- print("Permission Grant State: ",grant)
898
+ if cls.__requesting_permission or not ON_ANDROID:
899
+ return True
900
+
901
+ def on_permissions_result(permissions, grants):
887
902
  try:
888
903
  if callback:
889
- callback()
904
+ if can_accept_arguments(callback, True):
905
+ callback(grants[0])
906
+ else:
907
+ callback()
890
908
  except Exception as request_permission_error:
891
909
  print('Exception: ',request_permission_error)
892
- print('Permission request callback error: ',traceback.format_exc())
910
+ print('Permission response callback error: ',traceback.format_exc())
911
+ finally:
912
+ cls.__requesting_permission = False
913
+
893
914
  if not cls.has_permission():
915
+ cls.__requesting_permission = True
894
916
  request_permissions([Permission.POST_NOTIFICATIONS],on_permissions_result)
917
+ else:
918
+ cls.__requesting_permission = False
919
+ if callback:
920
+ if can_accept_arguments(callback,True):
921
+ callback(True)
922
+ else:
923
+ callback()
895
924
 
896
925
 
897
926
  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.2
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
 
@@ -3,6 +3,7 @@ setup.py
3
3
  android_notify/__init__.py
4
4
  android_notify/__main__.py
5
5
  android_notify/an_types.py
6
+ android_notify/an_utils.py
6
7
  android_notify/base.py
7
8
  android_notify/core.py
8
9
  android_notify/styles.py
@@ -6,13 +6,13 @@ 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.2",
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.",
13
13
  long_description=long_description,
14
14
  long_description_content_type="text/markdown",
15
- url="https://github.com/fector101/android-notify",
15
+ url="https://android-notify.vercel.app",
16
16
  packages=find_packages(),
17
17
  install_requires=[
18
18
  "kivy>=2.0.0",
@@ -44,7 +44,7 @@ setup(
44
44
  ],
45
45
  project_urls={
46
46
  # "Documentation": "https://github.com/fector101/android-notify/wiki",
47
- "Documentation": "https://android-notify.vercel.app/getting-started",
47
+ "Documentation": "https://android-notify.vercel.app/",
48
48
  "Source": "https://github.com/fector101/android-notify",
49
49
  "Tracker": "https://github.com/fector101/android-notify/issues",
50
50
  "Funding": "https://www.buymeacoffee.com/fector101"
@@ -1,16 +0,0 @@
1
- """Contains Safe way to call Styles"""
2
-
3
- class NotificationStyles:
4
- """ Safely Adding Styles"""
5
- DEFAULT = "simple"
6
-
7
- PROGRESS = "progress"
8
- INBOX = "inbox"
9
- BIG_TEXT = "big_text"
10
-
11
- LARGE_ICON = "large_icon"
12
- BIG_PICTURE = "big_picture"
13
- BOTH_IMGS = "both_imgs"
14
-
15
- # MESSAGING = "messaging" # TODO
16
- # CUSTOM = "custom" # TODO
File without changes