android-notify 1.24.4__py3-none-any.whl → 1.31__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,361 @@
1
+ Metadata-Version: 2.1
2
+ Name: android-notify
3
+ Version: 1.31
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
+ ## Features
37
+
38
+ - Compatible with Android 8.0+.
39
+ - Supports including images in notifications.
40
+ - Support for multiple notification styles:
41
+ - Progress
42
+ - Big Picture
43
+ - Inbox
44
+ - Big Text
45
+ - Large Icon
46
+
47
+ This module automatically handles:
48
+
49
+ - Permission requests for notifications
50
+ - Customizable notification channels.
51
+
52
+ ## Installation
53
+
54
+ This package is available on PyPI and can be installed via pip:
55
+
56
+ ```bash
57
+ pip install android-notify
58
+ ```
59
+
60
+ ## **Dependencies**
61
+
62
+ **Prerequisites:**
63
+
64
+ - Kivy
65
+
66
+ In your **`buildozer.spec`** file, ensure you include the following:
67
+
68
+ ```ini
69
+ # Add pyjnius so it's packaged with the build
70
+ requirements = python3, kivy, pyjnius, android-notify
71
+
72
+ # Add permission for notifications
73
+ android.permissions = POST_NOTIFICATIONS
74
+
75
+ # Required dependencies (write exactly as shown, no quotation marks)
76
+ android.gradle_dependencies = androidx.core:core:1.6.0, androidx.core:core-ktx:1.15.0
77
+ android.enable_androidx = True
78
+ ```
79
+
80
+ ---
81
+
82
+ ## Basic Usage
83
+
84
+ ```python
85
+ from android_notify import Notification
86
+
87
+ # Create a simple notification
88
+ notification = Notification(
89
+ title="Hello",
90
+ message="This is a basic notification"
91
+ )
92
+ notification.send()
93
+ ```
94
+
95
+ **Sample Image:**
96
+ ![basic notification img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/basicnoti.jpg)
97
+
98
+ ## Notification Styles
99
+
100
+ The library supports multiple notification styles:
101
+
102
+ 1. `simple` - Basic notification with title and message
103
+ 2. `progress` - Shows a progress bar
104
+ 3. `big_text` - Expandable notification with long text
105
+ 4. `inbox` - List-style notification
106
+ 5. `big_picture` - Notification with a large image
107
+ 6. `large_icon` - Notification with a custom icon
108
+ 7. `both_imgs` - Combines big picture and large icon
109
+ 8. `custom` - For custom notification styles
110
+
111
+ ### Style Examples
112
+
113
+ #### Notification with an Image (Big Picture Style)
114
+
115
+ ```python
116
+ # Image notification
117
+ notification = Notification(
118
+ title='Picture Alert!',
119
+ message='This notification includes an image.',
120
+ style="big_picture",
121
+ big_picture_path="assets/imgs/photo.png"
122
+ )
123
+ ```
124
+
125
+ **Sample Image:**
126
+ ![big_picture img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/bigpicturenoti.jpg)
127
+
128
+ #### Inbox Notification Style
129
+
130
+ ```python
131
+ # Send a notification with inbox style
132
+ notification = Notification(
133
+ title='Inbox Notification',
134
+ message='Line 1\nLine 2\nLine 3',
135
+ style='inbox'
136
+ )
137
+ ```
138
+
139
+ **Sample Image:**
140
+ ![Inbox Notification sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/inboxnoti.jpg)
141
+
142
+ #### Big text notification (Will Display as simple text if Device dosen't support)
143
+
144
+ ```python
145
+ notification = Notification(
146
+ title="Article",
147
+ message="Long article content...",
148
+ style="big_text"
149
+ )
150
+ ```
151
+
152
+ #### Progress bar notification
153
+
154
+ ```python
155
+ import time
156
+ notification = Notification(
157
+ title="Downloading...",
158
+ message="0% downloaded",
159
+ style="progress",
160
+ progress_max_value=100,
161
+ progress_current_value=0
162
+ )
163
+ notification.send()
164
+ time.sleep(350)
165
+ notification.updateProgressBar(30, "30% downloaded")
166
+
167
+
168
+ ```
169
+
170
+ **Sample Image:**
171
+ ![progress img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/progress.jpg)
172
+
173
+ #### Notification with an Image (Large Icon Style)
174
+
175
+ ```python
176
+ notification = Notification(
177
+ title="Completed download",
178
+ message="profile.jpg",
179
+ style="large_icon",
180
+ large_icon_path="assets/imgs/profile.png"
181
+ )
182
+
183
+ ```
184
+
185
+ **Sample Image:**
186
+ ![large_icon img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/large_icon.jpg)
187
+
188
+ ## Advanced Features
189
+
190
+ ### Updating Notifications
191
+
192
+ ```python
193
+ notification = Notification(title="Initial Title")
194
+ notification.send()
195
+
196
+ # Update title
197
+ notification.updateTitle("New Title")
198
+
199
+ # Update message
200
+ notification.updateMessage("New Message")
201
+ ```
202
+
203
+ ### Progress Bar Management
204
+
205
+ ```python
206
+ notification = Notification(
207
+ title="Download..",
208
+ style="progress"
209
+ )
210
+
211
+ # Update progress
212
+ notification.updateProgressBar(30, "30% downloaded")
213
+
214
+ # Remove progress bar
215
+ notification.removeProgressBar("Download Complete")
216
+ ```
217
+
218
+ ### Channel Management
219
+
220
+ Notifications are organized into channels. You can customize the channel name and ID:
221
+
222
+ - Custom Channel Name's Gives User ability to turn on/off specific
223
+
224
+ ```python
225
+ notification = Notification(
226
+ title="Download finished",
227
+ message="How to Catch a Fish.mp4",
228
+ channel_name="Download Notifications", # Will create User-visible name "downloads"
229
+ channel_id="custom_downloads" # Optional: specify custom channel ID
230
+ )
231
+ ```
232
+
233
+ **Sample Image:**
234
+ ![channels img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/channel_name.jpg)
235
+
236
+ ### Silent Notifications
237
+
238
+ To send a notification without sound or heads-up display:
239
+
240
+ ```python
241
+ notification = Notification(title="Silent Update")
242
+ notification.send(silent=True)
243
+ ```
244
+
245
+ ### Assist
246
+
247
+ - How to Copy image to app folder
248
+
249
+ ```python
250
+ import shutil,os # These modules come packaged with python
251
+ from android.storage import app_storage_path # type: ignore -- This works only on android
252
+
253
+ app_path = os.path.join(app_storage_path(),'app')
254
+ image_path= "/storage/emulated/0/Download/profile.png"
255
+
256
+ shutil.copy(image_path, os.path.join(app_path, "profile.png"))
257
+ ```
258
+
259
+ - Avoiding Human Error when using different notification styles
260
+
261
+ ```python
262
+ from android_notify import Notification, NotificationStyles
263
+ notification = Notification(
264
+ title="New Photo",
265
+ message="Check out this image",
266
+ style=NotificationStyles.BIG_PICTURE,
267
+ big_picture_path="assets/imgs/photo.png"
268
+ ).send()
269
+ ```
270
+
271
+ ## Development Mode
272
+
273
+ When developing on non-Android platforms, the library provides debugging output:
274
+
275
+ ```python
276
+ # Enable logs (default is True when not on Android)
277
+ Notification.logs = True
278
+
279
+ # Create notification for testing
280
+ notification = Notification(title="Test")
281
+ notification.send()
282
+ # Will print notification properties instead of sending
283
+ ```
284
+
285
+ ## Image Requirements
286
+
287
+ - Images must be located within your app's asset folder
288
+ - Supported paths are relative to your app's storage path
289
+ - Example: `assets/imgs/icon.png`
290
+
291
+ ## Error Handling
292
+
293
+ The library validates arguments and provides helpful error messages:
294
+
295
+ - Invalid style names will suggest the closest matching style
296
+ - Invalid arguments will list all valid options
297
+ - Missing image files will raise FileNotFoundError with the attempted path
298
+
299
+ ## Limitations
300
+
301
+ 1. Only works on Android devices
302
+ 2. Images must be within the app's storage path
303
+ 3. Channel names are limited to 40 characters
304
+ 4. Channel IDs are limited to 50 characters
305
+
306
+ ## Best Practices
307
+
308
+ 1. Always handle permissions appropriately
309
+ 2. Use meaningful channel names for organization
310
+ 3. Keep progress bar updates reasonable (don't update too frequently)
311
+ 4. Test notifications on different Android versions
312
+ 5. Consider using silent notifications for frequent updates
313
+
314
+ ## Debugging Tips
315
+
316
+ 1. Enable logs during development: `Notification.logs = True`
317
+ 2. Check channel creation with Android's notification settings
318
+ 3. Verify image paths before sending notifications
319
+ 4. Test different styles to ensure proper display
320
+
321
+ Remember to check Android's notification documentation for best practices and guidelines regarding notification frequency and content.
322
+
323
+ ## Contribution
324
+
325
+ Feel free to open issues or submit pull requests for improvements!
326
+
327
+ ## Reporting Issues
328
+
329
+ Found a bug? Please open an issue on our [GitHub Issues](https://github.com/Fector101/android_notify/issues) page.
330
+
331
+ ## Author
332
+
333
+ - Fabian - <fector101@yahoo.com>
334
+ - GitHub: [Android Notify Repo](https://github.com/Fector101/android_notify)
335
+ - Twitter: [FabianDev_](https://twitter.com/intent/user?user_id=1246911115319263233)
336
+
337
+ For feedback or contributions, feel free to reach out!
338
+
339
+ ---
340
+
341
+ ## ☕ Support the Project
342
+
343
+ 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.
344
+
345
+ <a href="https://www.buymeacoffee.com/fector101" target="_blank">
346
+ <img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60">
347
+ </a>
348
+
349
+ ---
350
+
351
+ ## Acknowledgments
352
+
353
+ - 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.
354
+ - Thanks to the Kivy and Pyjnius communities.
355
+
356
+ ---
357
+
358
+ ## 🌐 **Links**
359
+
360
+ - **PyPI:** [android-notify on PyPI](https://pypi.org/project/android-notify/)
361
+ - **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.31.dist-info/METADATA,sha256=dBq0SFyS1HzdbADXhM7J_HU6GDXdzNMWqOrv8gLnLnE,10134
7
+ android_notify-1.31.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
8
+ android_notify-1.31.dist-info/top_level.txt,sha256=IR1ONMrRSRINZpWn2X0dL5gbWwWINsK7PW8Jy2p4fU8,15
9
+ android_notify-1.31.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