android-notify 1.2__tar.gz → 1.5__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.

@@ -0,0 +1,452 @@
1
+ Metadata-Version: 2.2
2
+ Name: android-notify
3
+ Version: 1.5
4
+ Summary: A Python package that simpilfies creating Android notifications in Kivy apps.
5
+ Home-page: https://github.com/fector101/android-notify
6
+ Author: Fabian
7
+ Author-email: fector101@yahoo.com
8
+ License: MIT
9
+ Project-URL: Documentation, https://github.com/fector101/android-notify/
10
+ Project-URL: Source, https://github.com/fector101/android-notify
11
+ Project-URL: Tracker, https://github.com/fector101/android-notify/issues
12
+ Project-URL: Funding, https://www.buymeacoffee.com/fector101
13
+ Keywords: android,notifications,kivy,mobile,post-notifications,pyjnius,android-notifications,kivy-notifications,python-android,mobile-development,push-notifications,mobile-app,kivy-application
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: Android
17
+ Classifier: Development Status :: 5 - Production/Stable
18
+ Classifier: Intended Audience :: Developers
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Requires-Python: >=3.6
21
+ Description-Content-Type: text/markdown
22
+ Requires-Dist: kivy>=2.0.0
23
+ Requires-Dist: pyjnius>=1.4.2
24
+ Dynamic: author
25
+ Dynamic: author-email
26
+ Dynamic: classifier
27
+ Dynamic: description
28
+ Dynamic: description-content-type
29
+ Dynamic: home-page
30
+ Dynamic: keywords
31
+ Dynamic: license
32
+ Dynamic: project-url
33
+ Dynamic: requires-dist
34
+ Dynamic: requires-python
35
+ Dynamic: summary
36
+
37
+ <div align="center">
38
+ <br>
39
+ <h1> Android-Notifiy </h1>
40
+ <p> A Python library for effortlessly creating and managing Android notifications in Kivy android apps.</p>
41
+ <p>Supports various styles and ensures seamless integration and customization.</p>
42
+ <!-- <br> -->
43
+ <!-- <img src="https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/democollage.jpg"> -->
44
+ </div>
45
+
46
+ ## Features
47
+
48
+ - Also Compatible with Android 8.0+.
49
+ - Supports including images in notifications.
50
+ - All Notifications can take Functions (version 1.5+) [functions docs](#functions).
51
+ - Support for multiple notification styles:
52
+ - [Simple](#basic-usage)
53
+ - [Progress](#progress-bar-notification)
54
+ - [Big Picture](#notification-with-an-image-big-picture-style)
55
+ - [Inbox](#inbox-notification-style)
56
+ - [Large Icon](#notification-with-an-image-large-icon-style)
57
+ - [Buttons](#notification-with-buttons)
58
+ - [Big Text](#big-text-notification-will-display-as-simple-text-if-device-dosent-support)
59
+
60
+ This module automatically handles:
61
+
62
+ - Permission requests for notifications
63
+ - Customizable notification channels.
64
+
65
+ ## Installation
66
+
67
+ This package is available on PyPI and can be installed via pip:
68
+
69
+ ```bash
70
+ pip install android-notify
71
+ ```
72
+
73
+ ## **Dependencies**
74
+
75
+ **Prerequisites:**
76
+
77
+ - Kivy
78
+
79
+ In your **`buildozer.spec`** file, ensure you include the following:
80
+
81
+ ```ini
82
+ # Add pyjnius so ensure it's packaged with the build
83
+ requirements = python3, kivy, pyjnius, android-notify
84
+
85
+ # Add permission for notifications
86
+ 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
+ ```
92
+
93
+ ---
94
+
95
+ ## Basic Usage
96
+
97
+ ```python
98
+ from android_notify import Notification
99
+
100
+ # Create a simple notification
101
+ notification = Notification(
102
+ title="Hello",
103
+ message="This is a basic notification."
104
+ )
105
+ notification.send()
106
+ ```
107
+
108
+ **Sample Image:**
109
+ ![basic notification img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/basicnoti.jpg)
110
+
111
+ ## Notification Styles
112
+
113
+ The library supports multiple notification styles:
114
+
115
+ 1. `simple` - Basic notification with title and message
116
+ 2. `progress` - Shows a progress bar
117
+ 3. `big_text` - Expandable notification with long text
118
+ 4. `inbox` - List-style notification
119
+ 5. `big_picture` - Notification with a large image
120
+ 6. `large_icon` - Notification with a custom icon
121
+ 7. `both_imgs` - Combines big picture and large icon
122
+ 8. `custom` - For custom notification styles
123
+
124
+ ### Style Examples
125
+
126
+ #### Progress Bar notification
127
+
128
+ ```python
129
+ from kivy.clock import Clock
130
+
131
+ notification = Notification(
132
+ title="Downloading...",
133
+ message="0% downloaded",
134
+ style="progress",
135
+ progress_max_value=100,
136
+ progress_current_value=0
137
+ )
138
+ notification.send()
139
+ Clock.schedule_once(lambda dt: notification.updateProgressBar(30, "30% downloaded"), 350)
140
+ ```
141
+
142
+ **Sample Image:**
143
+ ![progress img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/progress.jpg)
144
+
145
+ #### Notification with an Image (Big Picture Style)
146
+
147
+ ```python
148
+ # Image notification
149
+ notification = Notification(
150
+ title='Picture Alert!',
151
+ message='This notification includes an image.',
152
+ style="big_picture",
153
+ big_picture_path="assets/imgs/photo.png"
154
+ )
155
+ notification.send()
156
+
157
+ ```
158
+
159
+ **Sample Image:**
160
+ ![big_picture img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/bigpicturenoti.jpg)
161
+
162
+ #### Inbox Notification Style
163
+
164
+ ```python
165
+ # Send a notification with inbox style
166
+ notification = Notification(
167
+ title='Inbox Notification',
168
+ message='Line 1\nLine 2\nLine 3',
169
+ style='inbox'
170
+ )
171
+ notification.send()
172
+
173
+ ```
174
+
175
+ **Sample Image:**
176
+ ![Inbox Notification sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/inboxnoti.jpg)
177
+
178
+ #### Notification with an Image (Large Icon Style)
179
+
180
+ ```python
181
+ notification = Notification(
182
+ title="FabianDev_",
183
+ message="A twitter about some programming stuff",
184
+ style="large_icon",
185
+ large_icon_path="assets/imgs/profile.png"
186
+ )
187
+
188
+ ```
189
+
190
+ **Sample Image:**
191
+ ![large_icon img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/large_icon.jpg)
192
+
193
+ #### Notification with Buttons
194
+
195
+ ```python
196
+ notification = Notification(title="Jane Dough", message="How to use android-notify #coding #purepython")
197
+ def playVideo():
198
+ print('Playing Video')
199
+
200
+ def turnOffNoti():
201
+ print('Please Turn OFf Noti')
202
+
203
+ def watchLater():
204
+ print('Add to Watch Later')
205
+
206
+ notification.addButton(text="Play",on_release=playVideo)
207
+ notification.addButton(text="Turn Off",on_release=turnOffNoti)
208
+ notification.addButton(text="Watch Later",on_release=watchLater)
209
+ notification.send()
210
+ ```
211
+
212
+ **Sample Image:**
213
+ ![btns img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/btns.jpg)
214
+
215
+ #### Big text notification (Will Display as normal text if Device dosen't support)
216
+
217
+ ```python
218
+ notification = Notification(
219
+ title="Article",
220
+ message="Long article content...",
221
+ style="big_text"
222
+ )
223
+ ```
224
+
225
+ ## Advanced Features
226
+
227
+ ### Updating Notifications
228
+
229
+ ```python
230
+ notification = Notification(title="Initial Title")
231
+ notification.send()
232
+
233
+ # Update title
234
+ notification.updateTitle("New Title")
235
+
236
+ # Update message
237
+ notification.updateMessage("New Message")
238
+ ```
239
+
240
+ ### Progress Bar Management
241
+
242
+ ```python
243
+ notification = Notification(
244
+ title="Download..",
245
+ style="progress"
246
+ )
247
+
248
+ # Update progress
249
+ notification.updateProgressBar(30, "30% downloaded")
250
+
251
+ # Remove progress bar
252
+ notification.removeProgressBar("Download Complete")
253
+ ```
254
+
255
+ ### Channel Management
256
+
257
+ Notifications are organized into channels. You can customize the channel name and ID:
258
+
259
+ - Custom Channel Name's Gives User ability to turn on/off specific
260
+
261
+ ```python
262
+ notification = Notification(
263
+ title="Download finished",
264
+ message="How to Catch a Fish.mp4",
265
+ channel_name="Download Notifications", # Will create User-visible name "Download Notifications"
266
+ channel_id="downloads_notifications" # Optional: specify custom channel ID
267
+ )
268
+ ```
269
+
270
+ **Sample Image:**
271
+ ![channels img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/channel_name.jpg)
272
+
273
+ ### Silent Notifications
274
+
275
+ To send a notification without sound or heads-up display:
276
+
277
+ ```python
278
+ notification = Notification(title="Silent Update")
279
+ notification.send(silent=True)
280
+ ```
281
+
282
+ ## Functions
283
+
284
+ ### NotificationHandler - To Attach Listener
285
+
286
+ Add this to your main.py App Class so it runs Once, In later Versions It'll be Attached Automatical
287
+
288
+ ```python
289
+ from kivymd.app import MDApp
290
+ from android_notify import Notification, NotificationHandler
291
+
292
+ class Myapp(MDApp):
293
+
294
+ def on_start(self):
295
+ # Is called Once when app is Starts up
296
+ NotificationHandler.bindNotifyListener() # if successfull returns True
297
+ Notification(title="Hello", message="This is a basic notification.",callback=self.doSomething).send()
298
+
299
+ def doSomething(self):
300
+ print("print in Debug Console")
301
+ ```
302
+
303
+ ### Get Which Notification was used to Open App - identifer (str)
304
+
305
+ If you just want to get the Exact Notification Clicked to Open App, you can use NotificationHandler to get unique identifer
306
+
307
+ ```python
308
+ from kivymd.app import MDApp
309
+ from android_notify import Notification, NotificationHandler
310
+
311
+ class Myapp(MDApp):
312
+
313
+ def on_start(self):
314
+
315
+ notify = Notification(title="Change Page", message="Click to change App page.", identifer='change_app_page')
316
+ notify.send()
317
+
318
+ notify1 = Notification(title="Change Colour", message="Click to change App Colour", identifer='change_app_color')
319
+ notify1.send()
320
+
321
+ NotificationHandler.bindNotifyListener()
322
+
323
+ def on_resume(self):
324
+ # Is called everytime app is reopened
325
+ notify_identifer = NotificationHandler.getIdentifer()
326
+ if notify_identifer == 'change_app_page':
327
+ # Code to change Screen
328
+ pass
329
+ elif notify_identifer == 'change_app_color':
330
+ # Code to change Screen Color
331
+ pass
332
+ ```
333
+
334
+
335
+
336
+ ### Assist
337
+
338
+ - How to Copy image to app folder
339
+
340
+ ```python
341
+ import shutil,os # These modules come packaged with python
342
+ from android.storage import app_storage_path # type: ignore -- This works only on android
343
+
344
+ app_path = os.path.join(app_storage_path(),'app')
345
+ image_path= "/storage/emulated/0/Download/profile.png"
346
+
347
+ shutil.copy(image_path, os.path.join(app_path, "profile.png"))
348
+ ```
349
+
350
+ - Avoiding Human Error when using different notification styles
351
+
352
+ ```python
353
+ from android_notify import Notification, NotificationStyles
354
+ Notification(
355
+ title="New Photo",
356
+ message="Check out this image",
357
+ style=NotificationStyles.BIG_PICTURE,
358
+ big_picture_path="assets/imgs/photo.png"
359
+ ).send()
360
+ ```
361
+
362
+ ## Development Mode
363
+
364
+ When developing on non-Android platforms, the library provides debugging output:
365
+
366
+ ```python
367
+ # Enable logs (default is True when not on Android)
368
+ Notification.logs = True
369
+
370
+ # Create notification for testing
371
+ notification = Notification(title="Test")
372
+ notification.send()
373
+ # Will print notification properties instead of sending
374
+ ```
375
+
376
+ ## Image Requirements
377
+
378
+ - Images must be located within your app's folder
379
+ - Supported paths are relative to your app's storage path
380
+ - Example: `assets/imgs/icon.png`
381
+
382
+ ## Error Handling
383
+
384
+ The library validates arguments and provides helpful error messages:
385
+
386
+ - Invalid style names will suggest the closest matching style
387
+ - Invalid arguments will list all valid options
388
+ - Missing image files will raise FileNotFoundError with the attempted path
389
+
390
+ ## Limitations
391
+
392
+ 1. Only works on Android devices
393
+ 2. Images must be within the app's storage path
394
+ 3. Channel names are limited to 40 characters
395
+ 4. Channel IDs are limited to 50 characters
396
+
397
+ ## Best Practices
398
+
399
+ 1. Always handle permissions appropriately
400
+ 2. Use meaningful channel names for organization
401
+ 3. Keep progress bar updates reasonable (don't update too frequently)
402
+ 4. Test notifications on different Android versions
403
+ 5. Consider using silent notifications for frequent updates
404
+
405
+ ## Debugging Tips
406
+
407
+ 1. Enable logs during development: `Notification.logs = True`
408
+ 2. Check channel creation with Android's notification settings
409
+ 3. Verify image paths before sending notifications
410
+ 4. Test different styles to ensure proper display
411
+
412
+ Remember to check Android's notification documentation for best practices and guidelines regarding notification frequency and content.
413
+
414
+ ## Contribution
415
+
416
+ Feel free to open issues or submit pull requests for improvements!
417
+
418
+ ## Reporting Issues
419
+
420
+ Found a bug? Please open an issue on our [GitHub Issues](https://github.com/Fector101/android_notify/issues) page.
421
+
422
+ ## Author
423
+
424
+ - Fabian - <fector101@yahoo.com>
425
+ - GitHub: [Android Notify Repo](https://github.com/Fector101/android_notify)
426
+ - Twitter: [FabianDev_](https://twitter.com/intent/user?user_id=1246911115319263233)
427
+
428
+ For feedback or contributions, feel free to reach out!
429
+
430
+ ---
431
+
432
+ ## ☕ Support the Project
433
+
434
+ 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.
435
+
436
+ <a href="https://www.buymeacoffee.com/fector101" target="_blank">
437
+ <img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60">
438
+ </a>
439
+
440
+ ---
441
+
442
+ ## Acknowledgments
443
+
444
+ - This Project was thoroughly Tested by the [Laner Project](https://github.com/Fector101/Laner/) - A application for Securely Transfering Files Wirelessly between your PC and Phone.
445
+ - Thanks to the Kivy and Pyjnius communities.
446
+
447
+ ---
448
+
449
+ ## 🌐 **Links**
450
+
451
+ - **PyPI:** [android-notify on PyPI](https://pypi.org/project/android-notify/)
452
+ - **GitHub:** [Source Code Repository](https://github.com/Fector101/android_notify/)