android-notify 1.60.6__tar.gz → 1.60.6.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.6 → android_notify-1.60.6.dev0}/PKG-INFO +19 -98
  2. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/README.md +18 -97
  3. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/android_notify/an_types.py +22 -9
  4. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/android_notify/an_utils.py +12 -12
  5. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/android_notify/config.py +13 -21
  6. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/android_notify/core.py +20 -25
  7. android_notify-1.60.6.dev0/android_notify/fallback-icons/flet-appicon.png +0 -0
  8. android_notify-1.60.6.dev0/android_notify/fallback-icons/pydroid3-appicon.png +0 -0
  9. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/android_notify/sword.py +22 -20
  10. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/android_notify.egg-info/PKG-INFO +19 -98
  11. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/android_notify.egg-info/SOURCES.txt +2 -0
  12. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/pyproject.toml +4 -1
  13. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/android_notify/__init__.py +0 -0
  14. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/android_notify/__main__.py +0 -0
  15. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/android_notify/base.py +0 -0
  16. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/android_notify/styles.py +0 -0
  17. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/android_notify.egg-info/dependency_links.txt +0 -0
  18. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/android_notify.egg-info/entry_points.txt +0 -0
  19. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/android_notify.egg-info/requires.txt +0 -0
  20. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/android_notify.egg-info/top_level.txt +0 -0
  21. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/docs/examples/flet-working/src/core.py +0 -0
  22. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/docs/examples/flet-working/src/main.py +0 -0
  23. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/docs/tests/flet/adv/main.py +0 -0
  24. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/docs/tests/flet/adv/tests/__init__.py +0 -0
  25. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/docs/tests/flet/adv/tests/test_android_notify_full.py +0 -0
  26. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/docs/tests/flet/basic/src/core.py +0 -0
  27. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/docs/tests/flet/basic/src/main.py +0 -0
  28. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/docs/website/src/pages/data/laner_Sent.py +0 -0
  29. {android_notify-1.60.6 → android_notify-1.60.6.dev0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: android-notify
3
- Version: 1.60.6
3
+ Version: 1.60.6.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
@@ -73,33 +73,20 @@ Notification(
73
73
 
74
74
  ## Installation
75
75
 
76
- <details>
77
- <summary><b>Kivy apps:</b></summary>
78
- <br/>
76
+ ### Kivy apps:
79
77
 
80
78
  In your **`buildozer.spec`** file, ensure you include the following:
81
79
 
82
80
  ```ini
83
81
  # Add pyjnius so ensure it's packaged with the build
84
- requirements = python3, kivy, pyjnius, android-notify
82
+ requirements = python3, kivy, pyjnius, android-notify>=1.60.6.dev0
85
83
  # Add permission for notifications
86
84
  android.permissions = POST_NOTIFICATIONS
87
-
88
- # Required dependencies (write exactly as shown, no quotation marks)
89
- android.gradle_dependencies = androidx.core:core:1.6.0, androidx.core:core-ktx:1.15.0
90
- android.enable_androidx = True
91
- android.api = 35
92
85
  ```
93
86
 
94
- </details>
95
-
96
-
97
- <details>
98
- <summary><b>Flet apps:</b></summary>
99
- <br/>
100
-
101
- In your `pyproject.toml` file, ensure you include the following:
87
+ ### Flet apps:
102
88
 
89
+ In your `pyproject.toml` file, ensure you include the following:
103
90
 
104
91
  ```toml
105
92
  [tool.flet.android]
@@ -110,93 +97,23 @@ dependencies = [
110
97
  [tool.flet.android.permission]
111
98
  "android.permission.POST_NOTIFICATIONS" = true
112
99
  ```
113
- - example of [complete flet pyproject.toml](https://github.com/Fector101/flet-app/blob/main/pyproject.toml)
114
-
115
- </details>
116
100
 
117
- <details>
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.
103
+ - In pip section where you're asked to insert `Libary name` paste `android-notify>=1.60.6.dev0`
118
104
 
119
- <summary><b>Desktop</b></summary>
120
- <br/>
121
105
 
122
- For IDE IntelliSense Can be installed via `pip install`:
106
+ ### Testing
107
+ Can be installed via `pip` For testing purposes:
123
108
 
124
109
  ```bash
125
110
  pip install android_notify
126
111
  android-notify -v
127
112
  ```
128
113
 
129
- </details>
130
-
131
- ------
132
- ## Installing without Androidx
133
- How to use without `gradle_dependencies`
134
- Use `android-notify>=1.60.6.dev0` to install via `pip`
135
-
136
- <details>
137
- <summary><b>In Kivy</b></summary>
138
- <br/>
139
-
140
- ```ini
141
- # buildozer.spec
142
- requirements = python3, kivy, pyjnius, android-notify>=1.60.6.dev0
143
- ```
144
-
145
- </details>
146
-
147
- <details>
148
-
149
- <summary><b>On Pydroid 3</b></summary>
150
- <br/>
151
-
152
- 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.
153
- - In pip section where you're asked to insert `Libary name` paste `android-notify>=1.60.6.dev0`
154
- - Minimal working example
155
- ```py
156
- # Testing with `android-notify>=1.60.6.dev0` on pydroid
157
- from kivy.app import App
158
- from kivy.uix.boxlayout import BoxLayout
159
- from kivy.uix.button import Button
160
- from android_notify import Notification
161
- from android_notify.core import asks_permission_if_needed
162
-
163
-
164
- class AndroidNotifyDemoApp(App):
165
- def build(self):
166
- layout = BoxLayout(orientation='vertical', spacing=10, padding=20)
167
- layout.add_widget(Button(
168
- text="Ask Notification Permission",
169
- on_release=self.request_permission
170
- ))
171
- layout.add_widget(Button(
172
- text="Send Notification",
173
- on_release=self.send_notification
174
- ))
175
- return layout
176
-
177
- def request_permission(self, *args):
178
- asks_permission_if_needed(no_androidx=True)
179
-
180
- def send_notification(self, *args):
181
- Notification(
182
- title="Hello from Android Notify",
183
- message="This is a basic notification.",
184
- channel_id="android_notify_demo",
185
- channel_name="Android Notify Demo"
186
- ).send()
187
-
188
-
189
- if __name__ == "__main__":
190
- AndroidNotifyDemoApp().run()
191
- ```
192
-
193
- </details>
194
-
195
-
196
-
197
114
  ## Documentation
198
115
  For Dev Version use
199
- ```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```
200
117
 
201
118
  ### To talk to BroadCast Listener From Buttons
202
119
 
@@ -213,8 +130,9 @@ You can use this [wiki](https://github.com/Fector101/android_notify/wiki/How-to#
213
130
  ### To use colored text in your notifications
214
131
 
215
132
  - Copy the [res](https://github.com/Fector101/android_notify/tree/main/android_notify/res) folder to your app path.
216
- - Lastly in your `buildozer.spec` file
217
- Add `source.include_exts = xml` and `android.add_resources = # path you pasted`
133
+ Lastly in your `buildozer.spec` file
134
+ - Add `source.include_exts = xml` and `android.add_resources = ./res`
135
+
218
136
 
219
137
  ### To use Custom Sounds
220
138
 
@@ -246,5 +164,8 @@ n.send()
246
164
 
247
165
  ## ☕ Support the Project
248
166
 
249
- 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.
250
- [donate](https://www.buymeacoffee.com/fector101)
167
+ 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.
168
+
169
+ <a href="https://www.buymeacoffee.com/fector101" target="_blank">
170
+ <img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60">
171
+ </a>
@@ -50,33 +50,20 @@ Notification(
50
50
 
51
51
  ## Installation
52
52
 
53
- <details>
54
- <summary><b>Kivy apps:</b></summary>
55
- <br/>
53
+ ### Kivy apps:
56
54
 
57
55
  In your **`buildozer.spec`** file, ensure you include the following:
58
56
 
59
57
  ```ini
60
58
  # Add pyjnius so ensure it's packaged with the build
61
- requirements = python3, kivy, pyjnius, android-notify
59
+ requirements = python3, kivy, pyjnius, android-notify>=1.60.6.dev0
62
60
  # Add permission for notifications
63
61
  android.permissions = POST_NOTIFICATIONS
64
-
65
- # Required dependencies (write exactly as shown, no quotation marks)
66
- android.gradle_dependencies = androidx.core:core:1.6.0, androidx.core:core-ktx:1.15.0
67
- android.enable_androidx = True
68
- android.api = 35
69
62
  ```
70
63
 
71
- </details>
72
-
73
-
74
- <details>
75
- <summary><b>Flet apps:</b></summary>
76
- <br/>
77
-
78
- In your `pyproject.toml` file, ensure you include the following:
64
+ ### Flet apps:
79
65
 
66
+ In your `pyproject.toml` file, ensure you include the following:
80
67
 
81
68
  ```toml
82
69
  [tool.flet.android]
@@ -87,93 +74,23 @@ dependencies = [
87
74
  [tool.flet.android.permission]
88
75
  "android.permission.POST_NOTIFICATIONS" = true
89
76
  ```
90
- - example of [complete flet pyproject.toml](https://github.com/Fector101/flet-app/blob/main/pyproject.toml)
91
-
92
- </details>
93
77
 
94
- <details>
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.
80
+ - In pip section where you're asked to insert `Libary name` paste `android-notify>=1.60.6.dev0`
95
81
 
96
- <summary><b>Desktop</b></summary>
97
- <br/>
98
82
 
99
- For IDE IntelliSense Can be installed via `pip install`:
83
+ ### Testing
84
+ Can be installed via `pip` For testing purposes:
100
85
 
101
86
  ```bash
102
87
  pip install android_notify
103
88
  android-notify -v
104
89
  ```
105
90
 
106
- </details>
107
-
108
- ------
109
- ## Installing without Androidx
110
- How to use without `gradle_dependencies`
111
- Use `android-notify>=1.60.6.dev0` to install via `pip`
112
-
113
- <details>
114
- <summary><b>In Kivy</b></summary>
115
- <br/>
116
-
117
- ```ini
118
- # buildozer.spec
119
- requirements = python3, kivy, pyjnius, android-notify>=1.60.6.dev0
120
- ```
121
-
122
- </details>
123
-
124
- <details>
125
-
126
- <summary><b>On Pydroid 3</b></summary>
127
- <br/>
128
-
129
- 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.
130
- - In pip section where you're asked to insert `Libary name` paste `android-notify>=1.60.6.dev0`
131
- - Minimal working example
132
- ```py
133
- # Testing with `android-notify>=1.60.6.dev0` on pydroid
134
- from kivy.app import App
135
- from kivy.uix.boxlayout import BoxLayout
136
- from kivy.uix.button import Button
137
- from android_notify import Notification
138
- from android_notify.core import asks_permission_if_needed
139
-
140
-
141
- class AndroidNotifyDemoApp(App):
142
- def build(self):
143
- layout = BoxLayout(orientation='vertical', spacing=10, padding=20)
144
- layout.add_widget(Button(
145
- text="Ask Notification Permission",
146
- on_release=self.request_permission
147
- ))
148
- layout.add_widget(Button(
149
- text="Send Notification",
150
- on_release=self.send_notification
151
- ))
152
- return layout
153
-
154
- def request_permission(self, *args):
155
- asks_permission_if_needed(no_androidx=True)
156
-
157
- def send_notification(self, *args):
158
- Notification(
159
- title="Hello from Android Notify",
160
- message="This is a basic notification.",
161
- channel_id="android_notify_demo",
162
- channel_name="Android Notify Demo"
163
- ).send()
164
-
165
-
166
- if __name__ == "__main__":
167
- AndroidNotifyDemoApp().run()
168
- ```
169
-
170
- </details>
171
-
172
-
173
-
174
91
  ## Documentation
175
92
  For Dev Version use
176
- ```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```
177
94
 
178
95
  ### To talk to BroadCast Listener From Buttons
179
96
 
@@ -190,8 +107,9 @@ You can use this [wiki](https://github.com/Fector101/android_notify/wiki/How-to#
190
107
  ### To use colored text in your notifications
191
108
 
192
109
  - Copy the [res](https://github.com/Fector101/android_notify/tree/main/android_notify/res) folder to your app path.
193
- - Lastly in your `buildozer.spec` file
194
- Add `source.include_exts = xml` and `android.add_resources = # path you pasted`
110
+ Lastly in your `buildozer.spec` file
111
+ - Add `source.include_exts = xml` and `android.add_resources = ./res`
112
+
195
113
 
196
114
  ### To use Custom Sounds
197
115
 
@@ -223,5 +141,8 @@ n.send()
223
141
 
224
142
  ## ☕ Support the Project
225
143
 
226
- 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.
227
- [donate](https://www.buymeacoffee.com/fector101)
144
+ 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.
145
+
146
+ <a href="https://www.buymeacoffee.com/fector101" target="_blank">
147
+ <img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60">
148
+ </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.6"
5
-
4
+ __version__ = "1.60.6.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():
@@ -172,4 +164,4 @@ def app_storage_path():
172
164
 
173
165
 
174
166
  def get_package_name():
175
- return context.getPackageName() # package.domain + "." + package.name
167
+ return context.getPackageName() # package.domain + "." + package.name
@@ -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(
@@ -9,17 +9,16 @@ from .an_utils import can_accept_arguments, get_python_activity_context, \
9
9
  get_bitmap_from_url, add_data_to_intent, get_sound_uri, icon_finder, get_bitmap_from_path, \
10
10
  can_show_permission_request_popup, open_settings_screen
11
11
 
12
- from .config import from_service_file, get_python_activity, get_notification_manager, ON_ANDROID, on_flet_app, \
13
- get_package_name
12
+ from .config import from_service_file, get_python_activity, get_notification_manager, ON_ANDROID, on_flet_app, get_package_name
14
13
  from .config import (Bundle, String, BuildVersion,
15
14
  Intent, PendingIntent,
16
- IconCompat, app_storage_path,
15
+ app_storage_path,
17
16
  NotificationChannel, RemoteViews,
18
17
  run_on_ui_thread,
19
18
  )
20
- from .config import (NotificationCompat, NotificationCompatBuilder,
19
+ from .config import (AndroidNotification, NotificationCompatBuilder,
21
20
  NotificationCompatBigTextStyle, NotificationCompatBigPictureStyle,
22
- NotificationCompatInboxStyle, NotificationCompatDecoratedCustomViewStyle,
21
+ NotificationCompatInboxStyle,
23
22
  Color, Manifest
24
23
  )
25
24
  from .styles import NotificationStyles
@@ -575,7 +574,7 @@ class Notification(BaseNotification):
575
574
  set_action(action_intent__)
576
575
  pending_action_intent__ = PendingIntent.getActivity(
577
576
  context, self.__no_of_buttons or 1, action_intent__,
578
- PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE
577
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE
579
578
  )
580
579
  return pending_action_intent__
581
580
 
@@ -586,7 +585,7 @@ class Notification(BaseNotification):
586
585
  set_action(action_intent)
587
586
  pending_action_intent = PendingIntent.getBroadcast(
588
587
  context, self.__no_of_buttons or 1, action_intent,
589
- PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE
588
+ PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE
590
589
  )
591
590
 
592
591
  except Exception as error_getting_broadcast_receiver:
@@ -596,6 +595,7 @@ class Notification(BaseNotification):
596
595
  else:
597
596
  pending_action_intent = set_default_action_intent()
598
597
 
598
+
599
599
  self.__builder.addAction(int(context.getApplicationInfo().icon), action_text, pending_action_intent)
600
600
  self.__builder.setContentIntent(pending_action_intent) # Set content intent for notification tap
601
601
 
@@ -603,7 +603,6 @@ class Notification(BaseNotification):
603
603
  self.__no_of_buttons += 1
604
604
  # action_intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP)
605
605
 
606
-
607
606
  if self.logs:
608
607
  print('Added Button: ', text)
609
608
  print('Button action: ', action)
@@ -734,7 +733,7 @@ class Notification(BaseNotification):
734
733
  self.__builder.setContentTitle(str(self.title))
735
734
  self.__builder.setContentText(str(self.message))
736
735
  self.__insert_app_icon()
737
- self.__builder.setDefaults(NotificationCompat.DEFAULT_ALL)
736
+ self.__builder.setDefaults(AndroidNotification.DEFAULT_ALL)
738
737
  self.__builder.setOnlyAlertOnce(True)
739
738
  self.__builder.setOngoing(persistent)
740
739
  self.__builder.setAutoCancel(close_on_click)
@@ -819,7 +818,8 @@ class Notification(BaseNotification):
819
818
  args=[img_path, callback, self.logs]
820
819
  ).start()
821
820
  else:
822
- 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
821
+ bitmap = get_img_from_path(
822
+ img_path) # get_img_from_path is different from get_bitmap_from_path because it those some logging for user
823
823
  if bitmap:
824
824
  self.__set_builder_icon_with_bitmap(bitmap)
825
825
  else:
@@ -920,6 +920,8 @@ class Notification(BaseNotification):
920
920
  return get_notification_manager().getNotificationChannels()
921
921
 
922
922
  def __apply_basic_custom_style(self):
923
+ NotificationCompatDecoratedCustomViewStyle = autoclass(
924
+ 'androidx.core.app.NotificationCompat$DecoratedCustomViewStyle')
923
925
 
924
926
  # Load layout
925
927
  resources = context.getResources()
@@ -1017,7 +1019,7 @@ class NotificationHandler:
1017
1019
  buttons_object = Notification.btns_box
1018
1020
  notifty_functions = Notification.main_functions
1019
1021
  if DEV:
1020
- print("notifty_functions ", notifty_functions)
1022
+ print("notify_functions ", notifty_functions)
1021
1023
  print("buttons_object", buttons_object)
1022
1024
  try:
1023
1025
  action = intent.getAction()
@@ -1094,16 +1096,17 @@ class NotificationHandler:
1094
1096
  return True
1095
1097
 
1096
1098
  if BuildVersion.SDK_INT < 33: # Android 12 below
1099
+ print("android_notify- On android 12 or less don't need permission")
1097
1100
  return True
1098
1101
 
1099
1102
  if on_flet_app():
1100
- ContextCompat = autoclass('androidx.core.content.ContextCompat')
1101
1103
  Manifest = autoclass('android.Manifest$permission')
1102
-
1104
+ VERSION_CODES = autoclass('android.os.Build$VERSION_CODES')
1105
+ PackageManager = autoclass("android.content.pm.PackageManager")
1103
1106
  permission = Manifest.POST_NOTIFICATIONS
1104
- return ContextCompat.checkSelfPermission(context, permission)
1107
+ return PackageManager.PERMISSION_GRANTED == context.checkSelfPermission(permission)
1105
1108
  else:
1106
- from android.permissions import Permission, check_permission
1109
+ from android.permissions import Permission, check_permission # type: ignore
1107
1110
  return check_permission(Permission.POST_NOTIFICATIONS)
1108
1111
 
1109
1112
  @classmethod
@@ -1124,7 +1127,7 @@ class NotificationHandler:
1124
1127
  if BuildVersion.SDK_INT < 33: # Android 12 below
1125
1128
  print("android_notify- On android 12 or less don't need permission")
1126
1129
 
1127
- if not ON_ANDROID or BuildVersion.SDK_INT < 33: # Android 12 below
1130
+ if not ON_ANDROID or BuildVersion.SDK_INT < 33: # Android 12 below:
1128
1131
  try:
1129
1132
  if callback:
1130
1133
  if can_accept_arguments(callback, True):
@@ -1159,13 +1162,12 @@ Opening notification settings...""")
1159
1162
 
1160
1163
  if not cls.has_permission():
1161
1164
  if on_flet_app():
1162
- ActivityCompat = autoclass('androidx.core.app.ActivityCompat')
1165
+ Manifest = autoclass('android.Manifest$permission')
1163
1166
  permission = Manifest.POST_NOTIFICATIONS
1164
- ActivityCompat.requestPermissions(context, [permission], 101)
1165
- return None
1167
+ context.requestPermissions([permission], 101)
1166
1168
  # TODO Callback when user answers request question
1167
1169
  else:
1168
- from android.permissions import request_permissions, Permission
1170
+ from android.permissions import request_permissions, Permission # type: ignore
1169
1171
  cls.__requesting_permission = True
1170
1172
  request_permissions([Permission.POST_NOTIFICATIONS], on_permissions_result)
1171
1173
  return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: android-notify
3
- Version: 1.60.6
3
+ Version: 1.60.6.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
@@ -73,33 +73,20 @@ Notification(
73
73
 
74
74
  ## Installation
75
75
 
76
- <details>
77
- <summary><b>Kivy apps:</b></summary>
78
- <br/>
76
+ ### Kivy apps:
79
77
 
80
78
  In your **`buildozer.spec`** file, ensure you include the following:
81
79
 
82
80
  ```ini
83
81
  # Add pyjnius so ensure it's packaged with the build
84
- requirements = python3, kivy, pyjnius, android-notify
82
+ requirements = python3, kivy, pyjnius, android-notify>=1.60.6.dev0
85
83
  # Add permission for notifications
86
84
  android.permissions = POST_NOTIFICATIONS
87
-
88
- # Required dependencies (write exactly as shown, no quotation marks)
89
- android.gradle_dependencies = androidx.core:core:1.6.0, androidx.core:core-ktx:1.15.0
90
- android.enable_androidx = True
91
- android.api = 35
92
85
  ```
93
86
 
94
- </details>
95
-
96
-
97
- <details>
98
- <summary><b>Flet apps:</b></summary>
99
- <br/>
100
-
101
- In your `pyproject.toml` file, ensure you include the following:
87
+ ### Flet apps:
102
88
 
89
+ In your `pyproject.toml` file, ensure you include the following:
103
90
 
104
91
  ```toml
105
92
  [tool.flet.android]
@@ -110,93 +97,23 @@ dependencies = [
110
97
  [tool.flet.android.permission]
111
98
  "android.permission.POST_NOTIFICATIONS" = true
112
99
  ```
113
- - example of [complete flet pyproject.toml](https://github.com/Fector101/flet-app/blob/main/pyproject.toml)
114
-
115
- </details>
116
100
 
117
- <details>
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.
103
+ - In pip section where you're asked to insert `Libary name` paste `android-notify>=1.60.6.dev0`
118
104
 
119
- <summary><b>Desktop</b></summary>
120
- <br/>
121
105
 
122
- For IDE IntelliSense Can be installed via `pip install`:
106
+ ### Testing
107
+ Can be installed via `pip` For testing purposes:
123
108
 
124
109
  ```bash
125
110
  pip install android_notify
126
111
  android-notify -v
127
112
  ```
128
113
 
129
- </details>
130
-
131
- ------
132
- ## Installing without Androidx
133
- How to use without `gradle_dependencies`
134
- Use `android-notify>=1.60.6.dev0` to install via `pip`
135
-
136
- <details>
137
- <summary><b>In Kivy</b></summary>
138
- <br/>
139
-
140
- ```ini
141
- # buildozer.spec
142
- requirements = python3, kivy, pyjnius, android-notify>=1.60.6.dev0
143
- ```
144
-
145
- </details>
146
-
147
- <details>
148
-
149
- <summary><b>On Pydroid 3</b></summary>
150
- <br/>
151
-
152
- 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.
153
- - In pip section where you're asked to insert `Libary name` paste `android-notify>=1.60.6.dev0`
154
- - Minimal working example
155
- ```py
156
- # Testing with `android-notify>=1.60.6.dev0` on pydroid
157
- from kivy.app import App
158
- from kivy.uix.boxlayout import BoxLayout
159
- from kivy.uix.button import Button
160
- from android_notify import Notification
161
- from android_notify.core import asks_permission_if_needed
162
-
163
-
164
- class AndroidNotifyDemoApp(App):
165
- def build(self):
166
- layout = BoxLayout(orientation='vertical', spacing=10, padding=20)
167
- layout.add_widget(Button(
168
- text="Ask Notification Permission",
169
- on_release=self.request_permission
170
- ))
171
- layout.add_widget(Button(
172
- text="Send Notification",
173
- on_release=self.send_notification
174
- ))
175
- return layout
176
-
177
- def request_permission(self, *args):
178
- asks_permission_if_needed(no_androidx=True)
179
-
180
- def send_notification(self, *args):
181
- Notification(
182
- title="Hello from Android Notify",
183
- message="This is a basic notification.",
184
- channel_id="android_notify_demo",
185
- channel_name="Android Notify Demo"
186
- ).send()
187
-
188
-
189
- if __name__ == "__main__":
190
- AndroidNotifyDemoApp().run()
191
- ```
192
-
193
- </details>
194
-
195
-
196
-
197
114
  ## Documentation
198
115
  For Dev Version use
199
- ```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```
200
117
 
201
118
  ### To talk to BroadCast Listener From Buttons
202
119
 
@@ -213,8 +130,9 @@ You can use this [wiki](https://github.com/Fector101/android_notify/wiki/How-to#
213
130
  ### To use colored text in your notifications
214
131
 
215
132
  - Copy the [res](https://github.com/Fector101/android_notify/tree/main/android_notify/res) folder to your app path.
216
- - Lastly in your `buildozer.spec` file
217
- Add `source.include_exts = xml` and `android.add_resources = # path you pasted`
133
+ Lastly in your `buildozer.spec` file
134
+ - Add `source.include_exts = xml` and `android.add_resources = ./res`
135
+
218
136
 
219
137
  ### To use Custom Sounds
220
138
 
@@ -246,5 +164,8 @@ n.send()
246
164
 
247
165
  ## ☕ Support the Project
248
166
 
249
- 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.
250
- [donate](https://www.buymeacoffee.com/fector101)
167
+ 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.
168
+
169
+ <a href="https://www.buymeacoffee.com/fector101" target="_blank">
170
+ <img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60">
171
+ </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.6"
7
+ version = "1.60.6.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