android-notify 1.60.5__tar.gz → 1.60.5.dev0__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.
Files changed (29) hide show
  1. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/PKG-INFO +16 -86
  2. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/README.md +15 -85
  3. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/android_notify/an_types.py +22 -9
  4. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/android_notify/an_utils.py +12 -12
  5. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/android_notify/config.py +12 -20
  6. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/android_notify/core.py +20 -25
  7. android_notify-1.60.5.dev0/android_notify/fallback-icons/flet-appicon.png +0 -0
  8. android_notify-1.60.5.dev0/android_notify/fallback-icons/pydroid3-appicon.png +0 -0
  9. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/android_notify/sword.py +16 -13
  10. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/android_notify.egg-info/PKG-INFO +16 -86
  11. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/android_notify.egg-info/SOURCES.txt +2 -0
  12. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/pyproject.toml +4 -1
  13. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/android_notify/__init__.py +0 -0
  14. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/android_notify/__main__.py +0 -0
  15. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/android_notify/base.py +0 -0
  16. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/android_notify/styles.py +0 -0
  17. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/android_notify.egg-info/dependency_links.txt +0 -0
  18. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/android_notify.egg-info/entry_points.txt +0 -0
  19. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/android_notify.egg-info/requires.txt +0 -0
  20. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/android_notify.egg-info/top_level.txt +0 -0
  21. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/docs/examples/flet-working/src/core.py +0 -0
  22. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/docs/examples/flet-working/src/main.py +0 -0
  23. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/docs/tests/flet/adv/main.py +0 -0
  24. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/docs/tests/flet/adv/tests/__init__.py +0 -0
  25. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/docs/tests/flet/adv/tests/test_android_notify_full.py +0 -0
  26. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/docs/tests/flet/basic/src/core.py +0 -0
  27. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/docs/tests/flet/basic/src/main.py +0 -0
  28. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/docs/website/src/pages/data/laner_Sent.py +0 -0
  29. {android_notify-1.60.5 → android_notify-1.60.5.dev0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: android-notify
3
- Version: 1.60.5
3
+ Version: 1.60.5.dev0
4
4
  Summary: A Python package that simplifies creating Android notifications in Kivy and Flet apps.
5
5
  Author-email: Fabian <fector101@yahoo.com>
6
6
  License-Expression: MIT
@@ -79,18 +79,15 @@ In your **`buildozer.spec`** file, ensure you include the following:
79
79
 
80
80
  ```ini
81
81
  # Add pyjnius so ensure it's packaged with the build
82
- requirements = python3, kivy, pyjnius, android-notify
82
+ requirements = python3, kivy, pyjnius, android-notify==1.60.5.dev0
83
83
  # Add permission for notifications
84
84
  android.permissions = POST_NOTIFICATIONS
85
-
86
- # Required dependencies (write exactly as shown, no quotation marks)
87
- android.gradle_dependencies = androidx.core:core:1.6.0, androidx.core:core-ktx:1.15.0
88
- android.enable_androidx = True
89
- android.api = 35
90
85
  ```
91
86
 
92
87
  ### Flet apps:
93
- In your `pyproject.toml` file, ensure you include the following:
88
+
89
+ In your `pyproject.toml` file, ensure you include the following:
90
+
94
91
  ```toml
95
92
  [tool.flet.android]
96
93
  dependencies = [
@@ -100,60 +97,14 @@ dependencies = [
100
97
  [tool.flet.android.permission]
101
98
  "android.permission.POST_NOTIFICATIONS" = true
102
99
  ```
103
- - example of [complete flet pyproject.toml](https://github.com/Fector101/flet-app/blob/main/pyproject.toml)
104
- ------
105
- ## Installing without Androidx
106
- How to use without `gradle_dependencies`
107
- Use `android-notify==1.60.5.dev0` to install via `pip`
108
- ### In Kivy
109
- ```ini
110
- # buildozer.spec
111
- requirements = python3, kivy, pyjnius, android-notify==1.60.5.dev0
112
- ```
113
100
 
114
- ### On Pydroid 3
115
- On the [pydroid 3](https://play.google.com/store/apps/details?id=ru.iiec.pydroid3) mobile app for running python code you can test some features.
101
+ ### Pydroid 3
102
+ In the [pydroid 3](https://play.google.com/store/apps/details?id=ru.iiec.pydroid3) mobile app for running python code you can test some features.
116
103
  - In pip section where you're asked to insert `Libary name` paste `android-notify==1.60.5.dev0`
117
- - Minimal working example
118
- ```py
119
- # Testing with `android-notify==1.60.5.dev0` on pydroid
120
- from kivy.app import App
121
- from kivy.uix.boxlayout import BoxLayout
122
- from kivy.uix.button import Button
123
- from android_notify import Notification
124
- from android_notify.core import asks_permission_if_needed
125
-
126
-
127
- class AndroidNotifyDemoApp(App):
128
- def build(self):
129
- layout = BoxLayout(orientation='vertical', spacing=10, padding=20)
130
- layout.add_widget(Button(
131
- text="Ask Notification Permission",
132
- on_release=self.request_permission
133
- ))
134
- layout.add_widget(Button(
135
- text="Send Notification",
136
- on_release=self.send_notification
137
- ))
138
- return layout
139
-
140
- def request_permission(self, *args):
141
- asks_permission_if_needed(no_androidx=True)
142
-
143
- def send_notification(self, *args):
144
- Notification(
145
- title="Hello from Android Notify",
146
- message="This is a basic notification.",
147
- channel_id="android_notify_demo",
148
- channel_name="Android Notify Demo"
149
- ).send()
150
-
151
-
152
- if __name__ == "__main__":
153
- AndroidNotifyDemoApp().run()
154
- ```
155
104
 
156
- For IDE IntelliSense Can be installed via `pip install`:
105
+
106
+ ### Testing
107
+ Can be installed via `pip` For testing purposes:
157
108
 
158
109
  ```bash
159
110
  pip install android_notify
@@ -162,7 +113,7 @@ android-notify -v
162
113
 
163
114
  ## Documentation
164
115
  For Dev Version use
165
- ```requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_notify/archive/main.zip```
116
+ ```requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_notify/archive/without-androidx.zip```
166
117
 
167
118
 
168
119
  To use colored text in your notifications:
@@ -170,34 +121,13 @@ To use colored text in your notifications:
170
121
  Lastly in your `buildozer.spec` file
171
122
  - Add `source.include_exts = xml` and `android.add_resources = ./res`
172
123
 
173
- To use Custom Sounds
174
- - Put audio files in `res/raw` folder,
175
- - Then from `buildozer.spec` point to res folder `android.add_resources = res`
176
- - and includes it's format `source.include_exts = wav`.
177
-
178
- Lastly From the code
179
- ```py
180
- # Create a custom notification channel with a unique sound resource for android 8+
181
- Notification.createChannel(
182
- id="weird_sound_tester",
183
- name="Weird Sound Tester",
184
- description="A test channel used to verify custom notification sounds from the res/raw folder.",
185
- res_sound_name="sneeze" # file name without .wav or .mp3
186
- )
187
-
188
- # Send a notification through the created channel
189
- n=Notification(
190
- title="Custom Sound Notification",
191
- message="This tests playback of a custom sound (sneeze.wav) stored in res/raw.",
192
- channel_id="weird_sound_tester" # important tells notification to use right channel
193
- )
194
- n.setSound("sneeze")# for android 7 below
195
- n.send()
196
- ```
197
124
  For full documentation, examples, and advanced usage, API reference visit the
198
125
  [documentation](https://android-notify.vercel.app)
199
126
 
200
127
  ## ☕ Support the Project
201
128
 
202
- If you find this project helpful, any support would help me continue working on open-source projects. I’m currently saving for a laptop to keep developing.
203
- [donate](https://www.buymeacoffee.com/fector101)
129
+ If you find this project helpful, consider buying me a coffee! 😊 Or Giving it a star on 🌟 [GitHub](https://github.com/Fector101/android_notify/) Your support helps maintain and improve the project.
130
+
131
+ <a href="https://www.buymeacoffee.com/fector101" target="_blank">
132
+ <img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60">
133
+ </a>
@@ -56,18 +56,15 @@ In your **`buildozer.spec`** file, ensure you include the following:
56
56
 
57
57
  ```ini
58
58
  # Add pyjnius so ensure it's packaged with the build
59
- requirements = python3, kivy, pyjnius, android-notify
59
+ requirements = python3, kivy, pyjnius, android-notify==1.60.5.dev0
60
60
  # Add permission for notifications
61
61
  android.permissions = POST_NOTIFICATIONS
62
-
63
- # Required dependencies (write exactly as shown, no quotation marks)
64
- android.gradle_dependencies = androidx.core:core:1.6.0, androidx.core:core-ktx:1.15.0
65
- android.enable_androidx = True
66
- android.api = 35
67
62
  ```
68
63
 
69
64
  ### Flet apps:
70
- In your `pyproject.toml` file, ensure you include the following:
65
+
66
+ In your `pyproject.toml` file, ensure you include the following:
67
+
71
68
  ```toml
72
69
  [tool.flet.android]
73
70
  dependencies = [
@@ -77,60 +74,14 @@ dependencies = [
77
74
  [tool.flet.android.permission]
78
75
  "android.permission.POST_NOTIFICATIONS" = true
79
76
  ```
80
- - example of [complete flet pyproject.toml](https://github.com/Fector101/flet-app/blob/main/pyproject.toml)
81
- ------
82
- ## Installing without Androidx
83
- How to use without `gradle_dependencies`
84
- Use `android-notify==1.60.5.dev0` to install via `pip`
85
- ### In Kivy
86
- ```ini
87
- # buildozer.spec
88
- requirements = python3, kivy, pyjnius, android-notify==1.60.5.dev0
89
- ```
90
77
 
91
- ### On Pydroid 3
92
- On the [pydroid 3](https://play.google.com/store/apps/details?id=ru.iiec.pydroid3) mobile app for running python code you can test some features.
78
+ ### Pydroid 3
79
+ In the [pydroid 3](https://play.google.com/store/apps/details?id=ru.iiec.pydroid3) mobile app for running python code you can test some features.
93
80
  - In pip section where you're asked to insert `Libary name` paste `android-notify==1.60.5.dev0`
94
- - Minimal working example
95
- ```py
96
- # Testing with `android-notify==1.60.5.dev0` on pydroid
97
- from kivy.app import App
98
- from kivy.uix.boxlayout import BoxLayout
99
- from kivy.uix.button import Button
100
- from android_notify import Notification
101
- from android_notify.core import asks_permission_if_needed
102
-
103
-
104
- class AndroidNotifyDemoApp(App):
105
- def build(self):
106
- layout = BoxLayout(orientation='vertical', spacing=10, padding=20)
107
- layout.add_widget(Button(
108
- text="Ask Notification Permission",
109
- on_release=self.request_permission
110
- ))
111
- layout.add_widget(Button(
112
- text="Send Notification",
113
- on_release=self.send_notification
114
- ))
115
- return layout
116
-
117
- def request_permission(self, *args):
118
- asks_permission_if_needed(no_androidx=True)
119
-
120
- def send_notification(self, *args):
121
- Notification(
122
- title="Hello from Android Notify",
123
- message="This is a basic notification.",
124
- channel_id="android_notify_demo",
125
- channel_name="Android Notify Demo"
126
- ).send()
127
-
128
-
129
- if __name__ == "__main__":
130
- AndroidNotifyDemoApp().run()
131
- ```
132
81
 
133
- For IDE IntelliSense Can be installed via `pip install`:
82
+
83
+ ### Testing
84
+ Can be installed via `pip` For testing purposes:
134
85
 
135
86
  ```bash
136
87
  pip install android_notify
@@ -139,7 +90,7 @@ android-notify -v
139
90
 
140
91
  ## Documentation
141
92
  For Dev Version use
142
- ```requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_notify/archive/main.zip```
93
+ ```requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_notify/archive/without-androidx.zip```
143
94
 
144
95
 
145
96
  To use colored text in your notifications:
@@ -147,34 +98,13 @@ To use colored text in your notifications:
147
98
  Lastly in your `buildozer.spec` file
148
99
  - Add `source.include_exts = xml` and `android.add_resources = ./res`
149
100
 
150
- To use Custom Sounds
151
- - Put audio files in `res/raw` folder,
152
- - Then from `buildozer.spec` point to res folder `android.add_resources = res`
153
- - and includes it's format `source.include_exts = wav`.
154
-
155
- Lastly From the code
156
- ```py
157
- # Create a custom notification channel with a unique sound resource for android 8+
158
- Notification.createChannel(
159
- id="weird_sound_tester",
160
- name="Weird Sound Tester",
161
- description="A test channel used to verify custom notification sounds from the res/raw folder.",
162
- res_sound_name="sneeze" # file name without .wav or .mp3
163
- )
164
-
165
- # Send a notification through the created channel
166
- n=Notification(
167
- title="Custom Sound Notification",
168
- message="This tests playback of a custom sound (sneeze.wav) stored in res/raw.",
169
- channel_id="weird_sound_tester" # important tells notification to use right channel
170
- )
171
- n.setSound("sneeze")# for android 7 below
172
- n.send()
173
- ```
174
101
  For full documentation, examples, and advanced usage, API reference visit the
175
102
  [documentation](https://android-notify.vercel.app)
176
103
 
177
104
  ## ☕ Support the Project
178
105
 
179
- If you find this project helpful, any support would help me continue working on open-source projects. I’m currently saving for a laptop to keep developing.
180
- [donate](https://www.buymeacoffee.com/fector101)
106
+ If you find this project helpful, consider buying me a coffee! 😊 Or Giving it a star on 🌟 [GitHub](https://github.com/Fector101/android_notify/) Your support helps maintain and improve the project.
107
+
108
+ <a href="https://www.buymeacoffee.com/fector101" target="_blank">
109
+ <img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60">
110
+ </a>
@@ -108,6 +108,9 @@ class Uri:
108
108
  class NotificationManager:
109
109
  pass
110
110
 
111
+ class NotificationManagerClass:
112
+ pass
113
+
111
114
 
112
115
  class NotificationChannel:
113
116
  def __init__(self, channel_id, channel_name, importance):
@@ -169,6 +172,12 @@ class NotificationManagerCompat:
169
172
  IMPORTANCE_MIN = ''
170
173
  IMPORTANCE_NONE = ''
171
174
 
175
+ class AndroidNotification:
176
+ DEFAULT_ALL = 3
177
+ PRIORITY_HIGH = 4
178
+ PRIORITY_DEFAULT = ''
179
+ PRIORITY_LOW = ''
180
+ PRIORITY_MIN = ''
172
181
 
173
182
  class NotificationCompat:
174
183
  DEFAULT_ALL = 3
@@ -187,15 +196,19 @@ class MActions:
187
196
  class NotificationCompatBuilder:
188
197
  def __init__(self, context, channel_id):
189
198
  self.mActions = MActions()
190
- pass
191
- def setProgress(self,max_value,current_value,endless):
192
- pass
193
- def setStyle(self,style):
194
- pass
195
- def setContentTitle(self,title):
196
- pass
197
- def setContentText(self,text):
198
- pass
199
+ print(f"[MOCK] NotificationCompatBuilder initialized with context={context}, channel_id={channel_id}")
200
+
201
+ def setProgress(self, max_value, current_value, endless):
202
+ print(f"[MOCK] setProgress called with max={max_value}, current={current_value}, endless={endless}")
203
+
204
+ def setStyle(self, style):
205
+ print(f"[MOCK] setStyle called with style={style}")
206
+
207
+ def setContentTitle(self, title):
208
+ print(f"[MOCK] setContentTitle called with title={title}")
209
+
210
+ def setContentText(self, text):
211
+ print(f"[MOCK] setContentText called with text={text}")
199
212
 
200
213
  def setSmallIcon(self, icon):
201
214
  print(f"[MOCK] setSmallIcon called with icon={icon}")
@@ -4,11 +4,11 @@ import inspect, os, re, traceback
4
4
  from .config import autoclass
5
5
  from .an_types import Importance
6
6
  from .config import (
7
- get_python_activity_context, app_storage_path,ON_ANDROID,
8
- BitmapFactory, BuildVersion, Bundle,
9
- NotificationManagerCompat,NotificationCompat,
10
- Intent, Settings, Uri, String, Manifest
11
- )
7
+ get_python_activity_context, app_storage_path, ON_ANDROID,
8
+ BitmapFactory, BuildVersion, Bundle,
9
+ NotificationManagerClass, AndroidNotification, Intent, Settings, Uri, String, Manifest
10
+
11
+ )
12
12
 
13
13
  if ON_ANDROID:
14
14
  Color = autoclass('android.graphics.Color')
@@ -41,15 +41,15 @@ def get_android_importance(importance: Importance):
41
41
  return None
42
42
  value = ''
43
43
  if importance == 'urgent':
44
- value = NotificationCompat.PRIORITY_HIGH if BuildVersion.SDK_INT <= 25 else NotificationManagerCompat.IMPORTANCE_HIGH
44
+ value = AndroidNotification.PRIORITY_HIGH if BuildVersion.SDK_INT <= 25 else NotificationManagerClass.IMPORTANCE_HIGH
45
45
  elif importance == 'high':
46
- value = NotificationCompat.PRIORITY_DEFAULT if BuildVersion.SDK_INT <= 25 else NotificationManagerCompat.IMPORTANCE_DEFAULT
46
+ value = AndroidNotification.PRIORITY_DEFAULT if BuildVersion.SDK_INT <= 25 else NotificationManagerClass.IMPORTANCE_DEFAULT
47
47
  elif importance == 'medium':
48
- value = NotificationCompat.PRIORITY_LOW if BuildVersion.SDK_INT <= 25 else NotificationManagerCompat.IMPORTANCE_LOW
48
+ value = AndroidNotification.PRIORITY_LOW if BuildVersion.SDK_INT <= 25 else NotificationManagerClass.IMPORTANCE_LOW
49
49
  elif importance == 'low':
50
- value = NotificationCompat.PRIORITY_MIN if BuildVersion.SDK_INT <= 25 else NotificationManagerCompat.IMPORTANCE_MIN
50
+ value = AndroidNotification.PRIORITY_MIN if BuildVersion.SDK_INT <= 25 else NotificationManagerClass.IMPORTANCE_MIN
51
51
  elif importance == 'none':
52
- value = '' if BuildVersion.SDK_INT <= 25 else NotificationManagerCompat.IMPORTANCE_NONE
52
+ value = '' if BuildVersion.SDK_INT <= 25 else NotificationManagerClass.IMPORTANCE_NONE
53
53
 
54
54
  return value
55
55
  # side-note 'medium' = NotificationCompat.PRIORITY_LOW and 'low' = NotificationCompat.PRIORITY_MIN # weird but from docs
@@ -78,10 +78,10 @@ def get_img_from_path(relative_path):
78
78
  app_folder = os.path.join(app_storage_path(), 'app')
79
79
  img_full_path = os.path.join(app_folder, relative_path)
80
80
  if not os.path.exists(img_full_path):
81
- print(f'Image: "{img_full_path}" Not Found, (Local images gotten from App Path)')
81
+ print(f'\nImage: "{img_full_path}" Not Found, (Local images gotten from App Path)')
82
82
  try:
83
83
  print("- These are the existing files in your app Folder:")
84
- print('[' + ', '.join(os.listdir(app_folder)) + ']')
84
+ print('[' + ', '.join(os.listdir(app_folder)) + ']\n')
85
85
  except Exception as could_not_get_files_in_path_error:
86
86
  print('Exception: ', could_not_get_files_in_path_error)
87
87
  print("Couldn't get Files in App Folder")
@@ -1,8 +1,7 @@
1
1
  import os, traceback
2
2
 
3
3
  ON_ANDROID = False
4
- __version__ = "1.60.5"
5
-
4
+ __version__ = "1.60.5.dev0"
6
5
 
7
6
  def is_platform_android():
8
7
  if os.getenv("MAIN_ACTIVITY_HOST_CLASS_NAME"):
@@ -52,9 +51,10 @@ if is_platform_android():
52
51
  PendingIntent = autoclass('android.app.PendingIntent')
53
52
  BitmapFactory = autoclass('android.graphics.BitmapFactory')
54
53
  BuildVersion = autoclass('android.os.Build$VERSION')
55
- NotificationManager = autoclass('android.app.NotificationManager')
54
+ NotificationManagerClass = autoclass('android.app.NotificationManager')
56
55
  NotificationChannel = autoclass('android.app.NotificationChannel')
57
56
  RemoteViews = autoclass('android.widget.RemoteViews')
57
+ AndroidNotification = autoclass("android.app.Notification")
58
58
  Settings = autoclass("android.provider.Settings")
59
59
  Uri = autoclass("android.net.Uri")
60
60
  Manifest = autoclass('android.Manifest$permission')
@@ -71,25 +71,17 @@ else:
71
71
 
72
72
  if ON_ANDROID:
73
73
  try:
74
- NotificationManagerCompat = autoclass('androidx.core.app.NotificationManagerCompat')
75
- NotificationCompat = autoclass('androidx.core.app.NotificationCompat')
76
- IconCompat = autoclass('androidx.core.graphics.drawable.IconCompat')
77
74
  Color = autoclass('android.graphics.Color')
78
75
 
79
76
  # Notification Design
80
- NotificationCompatBuilder = autoclass('androidx.core.app.NotificationCompat$Builder')
81
- NotificationCompatBigTextStyle = autoclass('androidx.core.app.NotificationCompat$BigTextStyle')
82
- NotificationCompatBigPictureStyle = autoclass('androidx.core.app.NotificationCompat$BigPictureStyle')
83
- NotificationCompatInboxStyle = autoclass('androidx.core.app.NotificationCompat$InboxStyle')
84
- NotificationCompatDecoratedCustomViewStyle = autoclass('androidx.core.app.NotificationCompat$DecoratedCustomViewStyle')
85
-
86
- except Exception as dependencies_import_error:
87
- print('dependencies_import_error: ', dependencies_import_error)
88
- print("""
89
- Dependency Error: Add the following in buildozer.spec:
90
- * android.gradle_dependencies = androidx.core:core-ktx:1.15.0, androidx.core:core:1.6.0
91
- * android.enable_androidx = True
92
- """)
77
+ NotificationCompatBuilder = autoclass('android.app.Notification$Builder')
78
+ NotificationCompatBigTextStyle = autoclass('android.app.Notification$BigTextStyle')
79
+ NotificationCompatBigPictureStyle = autoclass('android.app.Notification$BigPictureStyle')
80
+ NotificationCompatInboxStyle = autoclass('android.app.Notification$InboxStyle')
81
+ # NotificationCompatDecoratedCustomViewStyle = autoclass('androidx.core.app.NotificationCompat$DecoratedCustomViewStyle')
82
+
83
+ except Exception as styles_import_error:
84
+ print('styles_import_error: ', styles_import_error)
93
85
 
94
86
  from .an_types import *
95
87
  else:
@@ -157,7 +149,7 @@ def get_notification_manager():
157
149
  if not ON_ANDROID:
158
150
  return None
159
151
  notification_service = context.getSystemService(context.NOTIFICATION_SERVICE)
160
- return cast(NotificationManager, notification_service)
152
+ return cast(NotificationManagerClass, notification_service)
161
153
 
162
154
 
163
155
  def app_storage_path():
@@ -21,6 +21,7 @@ if is_platform_android():
21
21
  PendingIntent = autoclass('android.app.PendingIntent')
22
22
  BitmapFactory = autoclass('android.graphics.BitmapFactory')
23
23
  BuildVersion = autoclass('android.os.Build$VERSION')
24
+ Notification = autoclass("android.app.Notification")
24
25
  ON_ANDROID = True
25
26
  except Exception as e:
26
27
  print("android-notify: Error importing Java Classes-",e)
@@ -29,20 +30,15 @@ if is_platform_android():
29
30
 
30
31
  if ON_ANDROID:
31
32
  try:
32
- NotificationManagerCompat = autoclass('androidx.core.app.NotificationManagerCompat')
33
- NotificationCompat = autoclass('androidx.core.app.NotificationCompat')
34
-
33
+ NotificationManagerCompat = autoclass('android.app.NotificationManager')
35
34
  # Notification Design
36
- NotificationCompatBuilder = autoclass('androidx.core.app.NotificationCompat$Builder')
37
- NotificationCompatBigTextStyle = autoclass('androidx.core.app.NotificationCompat$BigTextStyle')
38
- NotificationCompatBigPictureStyle = autoclass('androidx.core.app.NotificationCompat$BigPictureStyle')
39
- NotificationCompatInboxStyle = autoclass('androidx.core.app.NotificationCompat$InboxStyle')
35
+ NotificationCompatBuilder = autoclass('android.app.Notification$Builder')
36
+ NotificationCompatBigTextStyle = autoclass('android.app.Notification$BigTextStyle')
37
+ NotificationCompatBigPictureStyle = autoclass('android.app.Notification$BigPictureStyle')
38
+ NotificationCompatInboxStyle = autoclass('android.app.Notification$InboxStyle')
40
39
  except Exception as e:
41
- print("""\n
42
- Dependency Error: Add the following in buildozer.spec:
43
- * android.gradle_dependencies = androidx.core:core-ktx:1.15.0, androidx.core:core:1.6.0
44
- * android.enable_androidx = True\n
45
- """)
40
+ traceback.print_exc()
41
+ print("Error importing notification styles")
46
42
 
47
43
  from .an_utils import can_show_permission_request_popup, open_settings_screen
48
44
 
@@ -60,9 +56,11 @@ def get_app_root_path():
60
56
  return './'
61
57
  return os.path.join(path, 'app')
62
58
 
63
- def asks_permission_if_needed():
59
+
60
+ def asks_permission_if_needed(legacy=False, no_androidx=False):
64
61
  """
65
62
  Ask for permission to send notifications if needed.
63
+ legacy parameter will replace no_androidx parameter in Future Versions
66
64
  """
67
65
  if not ON_ANDROID:
68
66
  print("android_notify- Can't ask permission when not on android")
@@ -80,16 +78,14 @@ Opening notification settings...
80
78
  open_settings_screen()
81
79
  return None
82
80
 
83
- if on_flet_app():
84
- ContextCompat = autoclass('androidx.core.content.ContextCompat')
85
- # if you get error `Failed to find class: androidx/core/app/ActivityCompat`
86
- #in proguard-rules.pro add `-keep class androidx.core.app.ActivityCompat { *; }`
87
- ActivityCompat = autoclass('androidx.core.app.ActivityCompat')
81
+ if on_flet_app() or no_androidx or legacy:
82
+ Activity = autoclass("android.app.Activity")
83
+ PackageManager = autoclass("android.content.pm.PackageManager")
88
84
 
89
85
  permission = Manifest.POST_NOTIFICATIONS
90
- granted = ContextCompat.checkSelfPermission(context, permission)
91
- if granted != 0: # PackageManager.PERMISSION_GRANTED == 0
92
- ActivityCompat.requestPermissions(context, [permission], 101)
86
+ granted = context.checkSelfPermission(permission)
87
+ if granted != PackageManager.PERMISSION_GRANTED:
88
+ context.requestPermissions([permission], 101)
93
89
  else: # android package is from p4a which is for kivy
94
90
  try:
95
91
  from android.permissions import request_permissions, Permission, check_permission # type: ignore
@@ -167,8 +163,7 @@ def send_notification(
167
163
  'This Package Only Runs on Android !!! ---> Check "https://github.com/Fector101/android_notify/" for Documentation.')
168
164
  return None
169
165
 
170
- asks_permission_if_needed()
171
-
166
+ asks_permission_if_needed(legacy=True)
172
167
  channel_id = channel_name.replace(' ', '_').lower().lower() if not channel_id else channel_id
173
168
  # Get notification manager
174
169
  notification_manager = context.getSystemService(context.NOTIFICATION_SERVICE)
@@ -186,8 +181,8 @@ def send_notification(
186
181
  builder.setContentTitle(title)
187
182
  builder.setContentText(message)
188
183
  insert_app_icon(builder, custom_app_icon_path)
189
- builder.setDefaults(NotificationCompat.DEFAULT_ALL)
190
- builder.setPriority(NotificationCompat.PRIORITY_HIGH)
184
+ builder.setDefaults(Notification.DEFAULT_ALL)
185
+ builder.setPriority(Notification.PRIORITY_HIGH)
191
186
 
192
187
  if img_path:
193
188
  print(
@@ -12,13 +12,13 @@ from .an_utils import can_accept_arguments, get_python_activity_context, \
12
12
  from .config import from_service_file, get_python_activity, get_notification_manager, ON_ANDROID, on_flet_app
13
13
  from .config import (Bundle, String, BuildVersion,
14
14
  Intent, PendingIntent,
15
- IconCompat, app_storage_path,
15
+ app_storage_path,
16
16
  NotificationChannel, RemoteViews,
17
17
  run_on_ui_thread,
18
18
  )
19
- from .config import (NotificationCompat, NotificationCompatBuilder,
19
+ from .config import (AndroidNotification, NotificationCompatBuilder,
20
20
  NotificationCompatBigTextStyle, NotificationCompatBigPictureStyle,
21
- NotificationCompatInboxStyle, NotificationCompatDecoratedCustomViewStyle,
21
+ NotificationCompatInboxStyle,
22
22
  Color, Manifest
23
23
  )
24
24
  from .styles import NotificationStyles
@@ -562,7 +562,7 @@ class Notification(BaseNotification):
562
562
  action_intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
563
563
  bundle = Bundle()
564
564
  bundle.putString("title", self.title or 'Title Placeholder')
565
- bundle.putInt("key_int", 123)
565
+ bundle.putInt("key_int", 68)
566
566
  action_intent.putExtras(bundle)
567
567
  action_intent.putExtra("button_id", action)
568
568
 
@@ -715,7 +715,7 @@ class Notification(BaseNotification):
715
715
  self.__builder.setContentTitle(str(self.title))
716
716
  self.__builder.setContentText(str(self.message))
717
717
  self.__insert_app_icon()
718
- self.__builder.setDefaults(NotificationCompat.DEFAULT_ALL)
718
+ self.__builder.setDefaults(AndroidNotification.DEFAULT_ALL)
719
719
  self.__builder.setOnlyAlertOnce(True)
720
720
  self.__builder.setOngoing(persistent)
721
721
  self.__builder.setAutoCancel(close_on_click)
@@ -800,7 +800,8 @@ class Notification(BaseNotification):
800
800
  args=[img_path, callback, self.logs]
801
801
  ).start()
802
802
  else:
803
- bitmap = get_img_from_path(img_path) # get_img_from_path is different from get_bitmap_from_path because it those some logging for user
803
+ bitmap = get_img_from_path(
804
+ img_path) # get_img_from_path is different from get_bitmap_from_path because it those some logging for user
804
805
  if bitmap:
805
806
  self.__set_builder_icon_with_bitmap(bitmap)
806
807
  else:
@@ -901,6 +902,8 @@ class Notification(BaseNotification):
901
902
  return get_notification_manager().getNotificationChannels()
902
903
 
903
904
  def __apply_basic_custom_style(self):
905
+ NotificationCompatDecoratedCustomViewStyle = autoclass(
906
+ 'androidx.core.app.NotificationCompat$DecoratedCustomViewStyle')
904
907
 
905
908
  # Load layout
906
909
  resources = context.getResources()
@@ -1072,14 +1075,15 @@ class NotificationHandler:
1072
1075
  return True
1073
1076
 
1074
1077
  if BuildVersion.SDK_INT < 33: # Android 12 below
1078
+ print("android_notify- On android 12 or less don't need permission")
1075
1079
  return True
1076
1080
 
1077
1081
  if on_flet_app():
1078
- ContextCompat = autoclass('androidx.core.content.ContextCompat')
1079
1082
  Manifest = autoclass('android.Manifest$permission')
1080
-
1083
+ VERSION_CODES = autoclass('android.os.Build$VERSION_CODES')
1084
+ PackageManager = autoclass("android.content.pm.PackageManager")
1081
1085
  permission = Manifest.POST_NOTIFICATIONS
1082
- return ContextCompat.checkSelfPermission(context, permission)
1086
+ return PackageManager.PERMISSION_GRANTED == context.checkSelfPermission(permission)
1083
1087
  else:
1084
1088
  from android.permissions import Permission, check_permission
1085
1089
  return check_permission(Permission.POST_NOTIFICATIONS)
@@ -1102,7 +1106,7 @@ class NotificationHandler:
1102
1106
  if BuildVersion.SDK_INT < 33: # Android 12 below
1103
1107
  print("android_notify- On android 12 or less don't need permission")
1104
1108
 
1105
- if not ON_ANDROID or BuildVersion.SDK_INT < 33: # Android 12 below
1109
+ if not ON_ANDROID or BuildVersion.SDK_INT < 33: # Android 12 below:
1106
1110
  try:
1107
1111
  if callback:
1108
1112
  if can_accept_arguments(callback, True):
@@ -1137,10 +1141,9 @@ Opening notification settings...""")
1137
1141
 
1138
1142
  if not cls.has_permission():
1139
1143
  if on_flet_app():
1140
- ActivityCompat = autoclass('androidx.core.app.ActivityCompat')
1144
+ Manifest = autoclass('android.Manifest$permission')
1141
1145
  permission = Manifest.POST_NOTIFICATIONS
1142
- ActivityCompat.requestPermissions(context, [permission], 101)
1143
- return None
1146
+ context.requestPermissions([permission], 101)
1144
1147
  # TODO Callback when user answers request question
1145
1148
  else:
1146
1149
  from android.permissions import request_permissions, Permission
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: android-notify
3
- Version: 1.60.5
3
+ Version: 1.60.5.dev0
4
4
  Summary: A Python package that simplifies creating Android notifications in Kivy and Flet apps.
5
5
  Author-email: Fabian <fector101@yahoo.com>
6
6
  License-Expression: MIT
@@ -79,18 +79,15 @@ In your **`buildozer.spec`** file, ensure you include the following:
79
79
 
80
80
  ```ini
81
81
  # Add pyjnius so ensure it's packaged with the build
82
- requirements = python3, kivy, pyjnius, android-notify
82
+ requirements = python3, kivy, pyjnius, android-notify==1.60.5.dev0
83
83
  # Add permission for notifications
84
84
  android.permissions = POST_NOTIFICATIONS
85
-
86
- # Required dependencies (write exactly as shown, no quotation marks)
87
- android.gradle_dependencies = androidx.core:core:1.6.0, androidx.core:core-ktx:1.15.0
88
- android.enable_androidx = True
89
- android.api = 35
90
85
  ```
91
86
 
92
87
  ### Flet apps:
93
- In your `pyproject.toml` file, ensure you include the following:
88
+
89
+ In your `pyproject.toml` file, ensure you include the following:
90
+
94
91
  ```toml
95
92
  [tool.flet.android]
96
93
  dependencies = [
@@ -100,60 +97,14 @@ dependencies = [
100
97
  [tool.flet.android.permission]
101
98
  "android.permission.POST_NOTIFICATIONS" = true
102
99
  ```
103
- - example of [complete flet pyproject.toml](https://github.com/Fector101/flet-app/blob/main/pyproject.toml)
104
- ------
105
- ## Installing without Androidx
106
- How to use without `gradle_dependencies`
107
- Use `android-notify==1.60.5.dev0` to install via `pip`
108
- ### In Kivy
109
- ```ini
110
- # buildozer.spec
111
- requirements = python3, kivy, pyjnius, android-notify==1.60.5.dev0
112
- ```
113
100
 
114
- ### On Pydroid 3
115
- On the [pydroid 3](https://play.google.com/store/apps/details?id=ru.iiec.pydroid3) mobile app for running python code you can test some features.
101
+ ### Pydroid 3
102
+ In the [pydroid 3](https://play.google.com/store/apps/details?id=ru.iiec.pydroid3) mobile app for running python code you can test some features.
116
103
  - In pip section where you're asked to insert `Libary name` paste `android-notify==1.60.5.dev0`
117
- - Minimal working example
118
- ```py
119
- # Testing with `android-notify==1.60.5.dev0` on pydroid
120
- from kivy.app import App
121
- from kivy.uix.boxlayout import BoxLayout
122
- from kivy.uix.button import Button
123
- from android_notify import Notification
124
- from android_notify.core import asks_permission_if_needed
125
-
126
-
127
- class AndroidNotifyDemoApp(App):
128
- def build(self):
129
- layout = BoxLayout(orientation='vertical', spacing=10, padding=20)
130
- layout.add_widget(Button(
131
- text="Ask Notification Permission",
132
- on_release=self.request_permission
133
- ))
134
- layout.add_widget(Button(
135
- text="Send Notification",
136
- on_release=self.send_notification
137
- ))
138
- return layout
139
-
140
- def request_permission(self, *args):
141
- asks_permission_if_needed(no_androidx=True)
142
-
143
- def send_notification(self, *args):
144
- Notification(
145
- title="Hello from Android Notify",
146
- message="This is a basic notification.",
147
- channel_id="android_notify_demo",
148
- channel_name="Android Notify Demo"
149
- ).send()
150
-
151
-
152
- if __name__ == "__main__":
153
- AndroidNotifyDemoApp().run()
154
- ```
155
104
 
156
- For IDE IntelliSense Can be installed via `pip install`:
105
+
106
+ ### Testing
107
+ Can be installed via `pip` For testing purposes:
157
108
 
158
109
  ```bash
159
110
  pip install android_notify
@@ -162,7 +113,7 @@ android-notify -v
162
113
 
163
114
  ## Documentation
164
115
  For Dev Version use
165
- ```requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_notify/archive/main.zip```
116
+ ```requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_notify/archive/without-androidx.zip```
166
117
 
167
118
 
168
119
  To use colored text in your notifications:
@@ -170,34 +121,13 @@ To use colored text in your notifications:
170
121
  Lastly in your `buildozer.spec` file
171
122
  - Add `source.include_exts = xml` and `android.add_resources = ./res`
172
123
 
173
- To use Custom Sounds
174
- - Put audio files in `res/raw` folder,
175
- - Then from `buildozer.spec` point to res folder `android.add_resources = res`
176
- - and includes it's format `source.include_exts = wav`.
177
-
178
- Lastly From the code
179
- ```py
180
- # Create a custom notification channel with a unique sound resource for android 8+
181
- Notification.createChannel(
182
- id="weird_sound_tester",
183
- name="Weird Sound Tester",
184
- description="A test channel used to verify custom notification sounds from the res/raw folder.",
185
- res_sound_name="sneeze" # file name without .wav or .mp3
186
- )
187
-
188
- # Send a notification through the created channel
189
- n=Notification(
190
- title="Custom Sound Notification",
191
- message="This tests playback of a custom sound (sneeze.wav) stored in res/raw.",
192
- channel_id="weird_sound_tester" # important tells notification to use right channel
193
- )
194
- n.setSound("sneeze")# for android 7 below
195
- n.send()
196
- ```
197
124
  For full documentation, examples, and advanced usage, API reference visit the
198
125
  [documentation](https://android-notify.vercel.app)
199
126
 
200
127
  ## ☕ Support the Project
201
128
 
202
- If you find this project helpful, any support would help me continue working on open-source projects. I’m currently saving for a laptop to keep developing.
203
- [donate](https://www.buymeacoffee.com/fector101)
129
+ If you find this project helpful, consider buying me a coffee! 😊 Or Giving it a star on 🌟 [GitHub](https://github.com/Fector101/android_notify/) Your support helps maintain and improve the project.
130
+
131
+ <a href="https://www.buymeacoffee.com/fector101" target="_blank">
132
+ <img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60">
133
+ </a>
@@ -15,6 +15,8 @@ android_notify.egg-info/dependency_links.txt
15
15
  android_notify.egg-info/entry_points.txt
16
16
  android_notify.egg-info/requires.txt
17
17
  android_notify.egg-info/top_level.txt
18
+ android_notify/fallback-icons/flet-appicon.png
19
+ android_notify/fallback-icons/pydroid3-appicon.png
18
20
  docs/examples/flet-working/src/core.py
19
21
  docs/examples/flet-working/src/main.py
20
22
  docs/tests/flet/adv/main.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "android-notify"
7
- version = "1.60.5"
7
+ version = "1.60.5.dev0"
8
8
  description = "A Python package that simplifies creating Android notifications in Kivy and Flet apps."
9
9
  readme = { file = "README.md", content-type = "text/markdown" }
10
10
  authors = [
@@ -50,6 +50,9 @@ dev = [
50
50
  "kivy>=2.0.0"
51
51
  ]
52
52
 
53
+ [tool.setuptools.package-data]
54
+ "android_notify" = ["fallback-icons/*.png"]
55
+
53
56
  [project.scripts]
54
57
  android-notify = "android_notify.__main__:main"
55
58