android-notify 1.24.4__py3-none-any.whl → 1.30__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of android-notify might be problematic. Click here for more details.

@@ -0,0 +1,360 @@
1
+ Metadata-Version: 2.1
2
+ Name: android-notify
3
+ Version: 1.30
4
+ Summary: A Python package that simpilfies creating Android Post notifications using PyJNIus 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
+
25
+ <div align="center">
26
+ <br>
27
+ <h1> Android-Notifiy </h1>
28
+ <p> A Python library for effortlessly creating and managing Android notifications in Kivy android apps.</p>
29
+ <p>
30
+ Supports various styles and ensures seamless integration and customization.
31
+ </p>
32
+ <br>
33
+ <!-- <img src="https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/democollage.jpg"> -->
34
+ </div>
35
+
36
+
37
+ ## Features
38
+
39
+ - Compatible with Android 8.0+.
40
+ - Supports including images in notifications.
41
+ - Support for multiple notification styles:
42
+ - Progress
43
+ - Big Picture
44
+ - Inbox
45
+ - Big Text
46
+ - Large Icon
47
+
48
+ This module automatically handles:
49
+
50
+ - Permission requests for notifications
51
+ - Customizable notification channels.
52
+
53
+ ## Installation
54
+
55
+ This package is available on PyPI and can be installed via pip:
56
+
57
+ ```bash
58
+ pip install android-notify
59
+ ```
60
+
61
+ ## **Dependencies**
62
+
63
+ **Prerequisites:**
64
+
65
+ - Kivy
66
+
67
+ In your **`buildozer.spec`** file, ensure you include the following:
68
+
69
+ ```ini
70
+ # Add pyjnius so it's packaged with the build
71
+ requirements = python3, kivy, pyjnius, android-notify
72
+
73
+ # Add permission for notifications
74
+ android.permissions = POST_NOTIFICATIONS
75
+
76
+ # Required dependencies (write exactly as shown, no quotation marks)
77
+ android.gradle_dependencies = androidx.core:core:1.6.0, androidx.core:core-ktx:1.15.0
78
+ android.enable_androidx = True
79
+ ```
80
+
81
+ ---
82
+
83
+ ## Basic Usage
84
+
85
+ ```python
86
+ from android_notify import Notification
87
+
88
+ # Create a simple notification
89
+ notification = Notification(
90
+ title="Hello",
91
+ message="This is a basic notification"
92
+ )
93
+ notification.send()
94
+ ```
95
+
96
+ **Sample Image:**
97
+ ![basic notification img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/basicnoti.jpg)
98
+
99
+ ## Notification Styles
100
+
101
+ The library supports multiple notification styles:
102
+
103
+ 1. `simple` - Basic notification with title and message
104
+ 2. `progress` - Shows a progress bar
105
+ 3. `big_text` - Expandable notification with long text
106
+ 4. `inbox` - List-style notification
107
+ 5. `big_picture` - Notification with a large image
108
+ 6. `large_icon` - Notification with a custom icon
109
+ 7. `both_imgs` - Combines big picture and large icon
110
+ 8. `custom` - For custom notification styles
111
+
112
+ ### Style Examples
113
+
114
+ #### Notification with an Image (Big Picture Style)
115
+
116
+ ```python
117
+ # Image notification
118
+ notification = Notification(
119
+ title='Picture Alert!',
120
+ message='This notification includes an image.',
121
+ style="big_picture",
122
+ big_picture_path="assets/imgs/photo.png"
123
+ )
124
+ ```
125
+
126
+ **Sample Image:**
127
+ ![big_picture img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/bigpicturenoti.jpg)
128
+
129
+ #### Inbox Notification Style
130
+
131
+ ```python
132
+ # Send a notification with inbox style
133
+ notification = Notification(
134
+ title='Inbox Notification',
135
+ message='Line 1\nLine 2\nLine 3',
136
+ style='inbox'
137
+ )
138
+ ```
139
+
140
+ **Sample Image:**
141
+ ![Inbox Notification sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/inboxnoti.jpg)
142
+
143
+ #### Big text notification (Will Display as simple text if Device dosen't support)
144
+
145
+ ```python
146
+ notification = Notification(
147
+ title="Article",
148
+ message="Long article content...",
149
+ style="big_text"
150
+ )
151
+ ```
152
+
153
+ #### Progress bar notification
154
+
155
+ ```python
156
+ notification = Notification(
157
+ title="Download",
158
+ message="Downloading file...",
159
+ style="progress",
160
+ progress_max_value=100,
161
+ progress_current_value=0
162
+ )
163
+
164
+ ```
165
+
166
+ **Sample Image:**
167
+ ![progress img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/progress.jpg)
168
+
169
+ #### Notification with an Image (Large Icon Style)
170
+
171
+ ```python
172
+ notification = Notification(
173
+ title="Completed download",
174
+ message="profile.jpg",
175
+ style="large_icon",
176
+ large_icon_path="assets/imgs/profile.png"
177
+ )
178
+
179
+ ```
180
+
181
+ **Sample Image:**
182
+ ![large_icon img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/large_icon.jpg)
183
+
184
+ ## Advanced Features
185
+
186
+ ### Updating Notifications
187
+
188
+ ```python
189
+ notification = Notification(title="Initial Title")
190
+ notification.send()
191
+
192
+ # Update title
193
+ notification.updateTitle("New Title")
194
+
195
+ # Update message
196
+ notification.updateMessage("New Message")
197
+ ```
198
+
199
+ ### Progress Bar Management
200
+
201
+ ```python
202
+ notification = Notification(
203
+ title="Download..",
204
+ style="progress"
205
+ )
206
+
207
+ # Update progress
208
+ notification.updateProgressBar(30, "30% Complete")
209
+
210
+ # Remove progress bar
211
+ notification.removeProgressBar("Download Complete")
212
+ ```
213
+
214
+ **Sample Image:**
215
+ ![progressbar img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/progress.jpg)
216
+
217
+ ### Channel Management
218
+
219
+ Notifications are organized into channels. You can customize the channel name and ID:
220
+
221
+ - Custom Channel Name's Gives User ability to turn on/off specific
222
+
223
+ ```python
224
+ notification = Notification(
225
+ title="Download finished",
226
+ message="How to Catch a Fish.mp4",
227
+ channel_name="Download Notifications", # Will create User-visible name "downloads"
228
+ channel_id="custom_downloads" # Optional: specify custom channel ID
229
+ )
230
+ ```
231
+
232
+ **Sample Image:**
233
+ ![channels img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/channel_name.jpg)
234
+
235
+ ### Silent Notifications
236
+
237
+ To send a notification without sound or heads-up display:
238
+
239
+ ```python
240
+ notification = Notification(title="Silent Update")
241
+ notification.send(silent=True)
242
+ ```
243
+
244
+ ### Assist
245
+
246
+ - How to Copy image to app folder
247
+
248
+ ```python
249
+ import shutil,os # These modules come packaged with python
250
+ from android.storage import app_storage_path # type: ignore -- This works only on android
251
+
252
+ app_path = os.path.join(app_storage_path(),'app')
253
+ image_path= "/storage/emulated/0/Download/profile.png"
254
+
255
+ shutil.copy(image_path, os.path.join(app_path, "profile.png"))
256
+ ```
257
+
258
+ - Avoiding Human Error when using different notification styles
259
+
260
+ ```python
261
+ from android_notify import Notification, NotificationStyles
262
+ notification = Notification(
263
+ title="New Photo",
264
+ message="Check out this image",
265
+ style=NotificationStyles.BIG_PICTURE,
266
+ big_picture_path="assets/imgs/photo.png"
267
+ ).send()
268
+ ```
269
+
270
+ ## Development Mode
271
+
272
+ When developing on non-Android platforms, the library provides debugging output:
273
+
274
+ ```python
275
+ # Enable logs (default is True when not on Android)
276
+ Notification.logs = True
277
+
278
+ # Create notification for testing
279
+ notification = Notification(title="Test")
280
+ notification.send()
281
+ # Will print notification properties instead of sending
282
+ ```
283
+
284
+ ## Image Requirements
285
+
286
+ - Images must be located within your app's asset folder
287
+ - Supported paths are relative to your app's storage path
288
+ - Example: `assets/imgs/icon.png`
289
+
290
+ ## Error Handling
291
+
292
+ The library validates arguments and provides helpful error messages:
293
+
294
+ - Invalid style names will suggest the closest matching style
295
+ - Invalid arguments will list all valid options
296
+ - Missing image files will raise FileNotFoundError with the attempted path
297
+
298
+ ## Limitations
299
+
300
+ 1. Only works on Android devices
301
+ 2. Images must be within the app's storage path
302
+ 3. Channel names are limited to 40 characters
303
+ 4. Channel IDs are limited to 50 characters
304
+
305
+ ## Best Practices
306
+
307
+ 1. Always handle permissions appropriately
308
+ 2. Use meaningful channel names for organization
309
+ 3. Keep progress bar updates reasonable (don't update too frequently)
310
+ 4. Test notifications on different Android versions
311
+ 5. Consider using silent notifications for frequent updates
312
+
313
+ ## Debugging Tips
314
+
315
+ 1. Enable logs during development: `Notification.logs = True`
316
+ 2. Check channel creation with Android's notification settings
317
+ 3. Verify image paths before sending notifications
318
+ 4. Test different styles to ensure proper display
319
+
320
+ Remember to check Android's notification documentation for best practices and guidelines regarding notification frequency and content.
321
+
322
+ ## Contribution
323
+
324
+ Feel free to open issues or submit pull requests for improvements!
325
+
326
+ ## Reporting Issues
327
+
328
+ Found a bug? Please open an issue on our [GitHub Issues](https://github.com/Fector101/android_notify/issues) page.
329
+
330
+ ## Author
331
+
332
+ - Fabian - <fector101@yahoo.com>
333
+ - GitHub: [Android Notify Repo](https://github.com/Fector101/android_notify)
334
+ - Twitter: [FabianDev_](https://twitter.com/intent/user?user_id=1246911115319263233)
335
+
336
+ For feedback or contributions, feel free to reach out!
337
+
338
+ ---
339
+
340
+ ## ☕ Support the Project
341
+
342
+ 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.
343
+
344
+ <a href="https://www.buymeacoffee.com/fector101" target="_blank">
345
+ <img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60">
346
+ </a>
347
+
348
+ ---
349
+
350
+ ## Acknowledgments
351
+
352
+ - 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.
353
+ - Thanks to the Kivy and Pyjnius communities.
354
+
355
+ ---
356
+
357
+ ## 🌐 **Links**
358
+
359
+ - **PyPI:** [android-notify on PyPI](https://pypi.org/project/android-notify/)
360
+ - **GitHub:** [Source Code Repository](https://github.com/Fector101/android_notify/)
@@ -0,0 +1,9 @@
1
+ android_notify/__init__.py,sha256=dAcsj7M_KHBOira9AVk4LtFFXRHTYsn6tza4Oz7T1MM,107
2
+ android_notify/__main__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ android_notify/core.py,sha256=hHzBnVw25x_WpMHp_HPKCuHEL2mQ7IHC_I3EqQZylas,6081
4
+ android_notify/styles.py,sha256=I2p31qStg9DaML9U4nXRvdpGzpppK6RS-qlDKuOv_Tk,328
5
+ android_notify/sword.py,sha256=8v28Q9x3CRRa3xDbHUd8629S5KvLy7xnjSygbqT-coQ,16271
6
+ android_notify-1.30.dist-info/METADATA,sha256=c-VGUh2_DaHzHc1NgpZOliOGwlUPmqwzx6kCj9J_OcQ,10166
7
+ android_notify-1.30.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
8
+ android_notify-1.30.dist-info/top_level.txt,sha256=IR1ONMrRSRINZpWn2X0dL5gbWwWINsK7PW8Jy2p4fU8,15
9
+ android_notify-1.30.dist-info/RECORD,,
android_notify/_dev.py DELETED
@@ -1,112 +0,0 @@
1
-
2
- class NotificationManager:
3
- notification_ids=[]
4
- def __init__(self, channel_id='',channel_name="Default Channel",importance_level=NotificationManagerCompat.IMPORTANCE_HIGH):
5
- if not ON_ANDROID:
6
- raise RuntimeError("This package only runs on Android!")
7
- self.channel_name = channel_name
8
- self.channel_id=channel_name.replace(' ','_').lower().lower() if not channel_id else channel_id
9
- self.notification_manager = context.getSystemService(context.NOTIFICATION_SERVICE)
10
- self.builder = NotificationCompatBuilder(context, self.channel_id)
11
- self.notification_id = self.__getUniqueID()
12
-
13
- # Setup Channel (For Android 8.0+)
14
- if BuildVersion.SDK_INT >= 26:
15
- channel = NotificationChannel(self.channel_id, channel_name, importance_level)
16
- self.notification_manager.createNotificationChannel(channel)
17
-
18
- def set_title(self, title: str):
19
- """Set the title of the notification."""
20
- self.builder.setContentTitle(title)
21
- def set_message(self, message: str):
22
- """Set the message of the notification."""
23
- self.builder.setContentText(message)
24
- def set_style(self, style: str, img_path=None):
25
- """Set the style of the notification."""
26
- try:
27
- if style == "big_text":
28
- big_text_style = NotificationCompatBigTextStyle()
29
- big_text_style.bigText(self.builder.mContentText)
30
- self.builder.setStyle(big_text_style)
31
- elif style == "big_picture" and img_path:
32
- img = get_image_uri(img_path)
33
- big_picture_style = NotificationCompatBigPictureStyle().bigPicture(img)
34
- self.builder.setStyle(big_picture_style)
35
- elif style == "inbox":
36
- inbox_style = NotificationCompatInboxStyle()
37
- for line in self.builder.mContentText.split("\n"):
38
- inbox_style.addLine(line)
39
- self.builder.setStyle(inbox_style)
40
- except Exception as e:
41
- print('Failed Adding Style:', e)
42
-
43
- def add_button(self, action_name: str, action_intent: str):
44
- """Add a button to the notification."""
45
- try:
46
- intent = Intent(context, PythonActivity)
47
- intent.setAction(action_intent)
48
- pending_intent = PendingIntent.getActivity(
49
- context,
50
- 0,
51
- intent,
52
- PendingIntent.FLAG_IMMUTABLE
53
- )
54
- action_text = cast('java.lang.CharSequence', String(action_name))
55
- self.builder.addAction(
56
- int(context.getApplicationInfo().icon),
57
- action_text,
58
- pending_intent
59
- )
60
- except Exception as e:
61
- print('Failed adding button:', e)
62
- def set_icon(self, img_path: str):
63
- """Set the icon of the notification."""
64
- try:
65
- img = get_image_uri(img_path)
66
- self.builder.setLargeIcon(BitmapFactory.decodeStream(context.getContentResolver().openInputStream(img)))
67
- except Exception as e:
68
- print('Failed Adding Bitmap:', e)
69
-
70
- def send(self):
71
- """Send the notification."""
72
- self.builder.setSmallIcon(context.getApplicationInfo().icon)
73
- self.builder.setDefaults(NotificationCompat.DEFAULT_ALL)
74
- self.builder.setPriority(NotificationCompat.PRIORITY_HIGH)
75
- self.notification_manager.notify(self.notification_id, self.builder.build())
76
- return self.notification_id
77
-
78
- def update(self, title=None, message=None):
79
- """Update the notification."""
80
- if title:
81
- self.builder.setContentTitle(title)
82
- if message:
83
- self.builder.setContentText(message)
84
- self.notification_manager.notify(self.notification_id, self.builder.build())
85
- def __get_image(self, img_path):
86
- """Get the image from the app Relative path."""
87
- from android.storage import app_storage_path
88
- output_path = os.path.join(app_storage_path(), 'app', img_path)
89
- if not os.path.exists(output_path):
90
- raise FileNotFoundError(f"Image not found at path: {output_path}")
91
- Uri = autoclass('android.net.Uri')
92
- return BitmapFactory.decodeStream(context.getContentResolver().openInputStream(Uri.parse(f"file://{output_path}")))
93
- # return BitmapFactory.decodeStream(context.getContentResolver().openInputStream(get_image_uri(img_path)))
94
- def cancel(self):
95
- """Cancel the notification."""
96
- self.notification_manager.cancel(self.notification_id)
97
- self.__del__()
98
- def cancel_all(self):
99
- """Cancel all notifications."""
100
- self.notification_manager.cancelAll()
101
- def __del__(self):
102
- """Delete the notification id."""
103
- self.notification_ids.remove(self.notification_id)
104
- def __getUniqueID(self):
105
- notification_id = random.randint(1, 100)
106
- while notification_id in self.notification_ids:
107
- notification_id = random.randint(1, 100)
108
- self.notification_ids.append(notification_id)
109
- return notification_id
110
-
111
- # notification_manager=NotificationManager()
112
- # notification_manager.s