android-notify 1.51.1__tar.gz → 1.51.3__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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: android-notify
3
- Version: 1.51.1
3
+ Version: 1.51.3
4
4
  Summary: A Python package that simpilfies creating Android notifications in Kivy apps.
5
5
  Home-page: https://github.com/fector101/android-notify
6
6
  Author: Fabian
@@ -48,6 +48,7 @@ Dynamic: summary
48
48
  - Also Compatible with Android 8.0+.
49
49
  - Supports including images in notifications.
50
50
  - All Notifications can take Functions (version 1.50+) [functions section](#functions).
51
+ - Advanced Notification Handling [section](advanced-features).
51
52
  - Support for multiple notification styles:
52
53
  - [Simple](#basic-usage)
53
54
  - [Progress](#progress-bar-notification)
@@ -55,7 +56,7 @@ Dynamic: summary
55
56
  - [Inbox](#inbox-notification-style)
56
57
  - [Large Icon](#notification-with-an-image-large-icon-style)
57
58
  - [Buttons](#notification-with-buttons)
58
- - [Big Text](#big-text-notification-will-display-as-simple-text-if-device-dosent-support)
59
+ - [Big Text](#big-text-notification)
59
60
 
60
61
  This module automatically handles:
61
62
 
@@ -278,6 +279,24 @@ notification = Notification(
278
279
  )
279
280
  ```
280
281
 
282
+ ### Changing Style When Already Sent
283
+
284
+ ```python
285
+ from android_notify import NotificationStyles
286
+
287
+ notification = Notification(
288
+ title="Download..",
289
+ style="progress"
290
+ )
291
+ notification.send()
292
+
293
+ notification.updateTitle("Download Completed")
294
+ notification.removeProgressBar()
295
+ notification.large_icon_path="users/imgs/profile1234.png"
296
+ notification.addNotificationStyle(NotificationStyles.LARGE_ICON,already_sent=True)
297
+
298
+ ```
299
+
281
300
  **Sample Image:**
282
301
  ![channels img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/channel_name.jpg)
283
302
 
@@ -12,6 +12,7 @@
12
12
  - Also Compatible with Android 8.0+.
13
13
  - Supports including images in notifications.
14
14
  - All Notifications can take Functions (version 1.50+) [functions section](#functions).
15
+ - Advanced Notification Handling [section](advanced-features).
15
16
  - Support for multiple notification styles:
16
17
  - [Simple](#basic-usage)
17
18
  - [Progress](#progress-bar-notification)
@@ -19,7 +20,7 @@
19
20
  - [Inbox](#inbox-notification-style)
20
21
  - [Large Icon](#notification-with-an-image-large-icon-style)
21
22
  - [Buttons](#notification-with-buttons)
22
- - [Big Text](#big-text-notification-will-display-as-simple-text-if-device-dosent-support)
23
+ - [Big Text](#big-text-notification)
23
24
 
24
25
  This module automatically handles:
25
26
 
@@ -242,6 +243,24 @@ notification = Notification(
242
243
  )
243
244
  ```
244
245
 
246
+ ### Changing Style When Already Sent
247
+
248
+ ```python
249
+ from android_notify import NotificationStyles
250
+
251
+ notification = Notification(
252
+ title="Download..",
253
+ style="progress"
254
+ )
255
+ notification.send()
256
+
257
+ notification.updateTitle("Download Completed")
258
+ notification.removeProgressBar()
259
+ notification.large_icon_path="users/imgs/profile1234.png"
260
+ notification.addNotificationStyle(NotificationStyles.LARGE_ICON,already_sent=True)
261
+
262
+ ```
263
+
245
264
  **Sample Image:**
246
265
  ![channels img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/channel_name.jpg)
247
266
 
@@ -172,6 +172,7 @@ class Notification:
172
172
  self.message=new_message
173
173
  if ON_ANDROID:
174
174
  self.__builder.setContentText(new_message)
175
+
175
176
  return True
176
177
  return 'Updated'
177
178
  def updateProgressBar(self,current_value,message:str=''):
@@ -271,11 +272,11 @@ class Notification:
271
272
  def __startNotificationBuild(self):
272
273
  self.__createBasicNotification()
273
274
  if self.style not in ['simple','']:
274
- self.__addNotificationStyle()
275
+ self.addNotificationStyle(self.style)
275
276
 
276
277
  def __createBasicNotification(self):
277
278
  # Notification Channel (Required for Android 8.0+)
278
- # print("THis is cchannel is ",self.channel_id) #"BLAH"
279
+ # print("THis is cchannel is ",self.channel_id) #"
279
280
  if BuildVersion.SDK_INT >= 26 and self.notification_manager.getNotificationChannel(self.channel_id) is None:
280
281
  importance=NotificationManagerCompat.IMPORTANCE_DEFAULT if self.silent else NotificationManagerCompat.IMPORTANCE_HIGH # pylint: disable=possibly-used-before-assignment
281
282
  # importance = 3 or 4
@@ -299,37 +300,51 @@ class Notification:
299
300
  self.__builder.setPriority(NotificationCompat.PRIORITY_DEFAULT if self.silent else NotificationCompat.PRIORITY_HIGH)
300
301
  self.__builder.setOnlyAlertOnce(True)
301
302
  self.__addIntentToOpenApp()
303
+ @run_on_ui_thread
304
+ def addNotificationStyle(self,style:str,already_sent=False):
305
+ """Adds Style to Notification
306
+ Version 1.51.2+ Exposing to Users (Note): Always Call On UI Thread
302
307
 
303
- def __addNotificationStyle(self):
304
- if self.style == NotificationStyles.BIG_TEXT:
308
+ Args:
309
+ style (str): required style
310
+ """
311
+
312
+ if not ON_ANDROID:
313
+ # TODO for logs when not on android and style related to imgs etraxct app path from buildozer.spec and print
314
+ return
315
+
316
+ if style == NotificationStyles.BIG_TEXT:
305
317
  big_text_style = NotificationCompatBigTextStyle() # pylint: disable=E0606
306
318
  big_text_style.bigText(self.message)
307
319
  self.__builder.setStyle(big_text_style)
308
320
 
309
- elif self.style == NotificationStyles.INBOX:
321
+ elif style == NotificationStyles.INBOX:
310
322
  inbox_style = NotificationCompatInboxStyle() # pylint: disable=E0606
311
323
  for line in self.message.split("\n"):
312
324
  inbox_style.addLine(line)
313
325
  self.__builder.setStyle(inbox_style)
314
326
 
315
- elif self.style == NotificationStyles.BIG_PICTURE and self.big_picture_path:
316
- self.__buildImg(self.big_picture_path, self.style)
327
+ elif style == NotificationStyles.BIG_PICTURE and self.big_picture_path:
328
+ self.__buildImg(self.big_picture_path, style)
317
329
 
318
- elif self.style == NotificationStyles.LARGE_ICON and self.large_icon_path:
319
- self.__buildImg(self.large_icon_path, self.style)
330
+ elif style == NotificationStyles.LARGE_ICON and self.large_icon_path:
331
+ self.__buildImg(self.large_icon_path, style)
320
332
 
321
- elif self.style == NotificationStyles.BOTH_IMGS and (self.big_picture_path or self.large_icon_path):
333
+ elif style == NotificationStyles.BOTH_IMGS and (self.big_picture_path or self.large_icon_path):
322
334
  if self.big_picture_path:
323
335
  self.__buildImg(self.big_picture_path, NotificationStyles.BIG_PICTURE)
324
336
  if self.large_icon_path:
325
337
  self.__buildImg(self.large_icon_path, NotificationStyles.LARGE_ICON)
326
338
 
327
- elif self.style == 'progress':
339
+ elif style == 'progress':
328
340
  self.__builder.setContentTitle(String(self.title))
329
341
  self.__builder.setContentText(String(self.message))
330
342
  self.__builder.setProgress(self.progress_max_value, self.progress_current_value, False)
331
343
 
332
- # elif self.style == 'custom':
344
+ if already_sent:
345
+ self.notification_manager.notify(self.__id, self.__builder.build())
346
+
347
+ # elif style == 'custom':
333
348
  # self.__builder = self.__doCustomStyle()
334
349
 
335
350
  # def __doCustomStyle(self):
@@ -344,15 +359,10 @@ class Notification:
344
359
  )
345
360
  thread.start()
346
361
  else:
347
- if NotificationStyles.BIG_PICTURE:
348
- bitmap = self.__getImgFromPath(user_img)
349
- if bitmap:
350
- big_picture_style = NotificationCompatBigPictureStyle().bigPicture(bitmap) # pylint: disable=E0606
351
- self.__builder.setStyle(big_picture_style)
352
- elif NotificationStyles.LARGE_ICON:
353
- bitmap = self.__getImgFromPath(user_img)
354
- if bitmap:
355
- self.__builder.setLargeIcon(bitmap)
362
+ bitmap = self.__getImgFromPath(user_img)
363
+ if bitmap:
364
+ self.__applyNotificationImage(bitmap,img_style)
365
+
356
366
 
357
367
  def __getImgFromPath(self, relative_path):
358
368
  app_folder=os.path.join(app_storage_path(),'app') # pylint: disable=possibly-used-before-assignment
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: android-notify
3
- Version: 1.51.1
3
+ Version: 1.51.3
4
4
  Summary: A Python package that simpilfies creating Android notifications in Kivy apps.
5
5
  Home-page: https://github.com/fector101/android-notify
6
6
  Author: Fabian
@@ -48,6 +48,7 @@ Dynamic: summary
48
48
  - Also Compatible with Android 8.0+.
49
49
  - Supports including images in notifications.
50
50
  - All Notifications can take Functions (version 1.50+) [functions section](#functions).
51
+ - Advanced Notification Handling [section](advanced-features).
51
52
  - Support for multiple notification styles:
52
53
  - [Simple](#basic-usage)
53
54
  - [Progress](#progress-bar-notification)
@@ -55,7 +56,7 @@ Dynamic: summary
55
56
  - [Inbox](#inbox-notification-style)
56
57
  - [Large Icon](#notification-with-an-image-large-icon-style)
57
58
  - [Buttons](#notification-with-buttons)
58
- - [Big Text](#big-text-notification-will-display-as-simple-text-if-device-dosent-support)
59
+ - [Big Text](#big-text-notification)
59
60
 
60
61
  This module automatically handles:
61
62
 
@@ -278,6 +279,24 @@ notification = Notification(
278
279
  )
279
280
  ```
280
281
 
282
+ ### Changing Style When Already Sent
283
+
284
+ ```python
285
+ from android_notify import NotificationStyles
286
+
287
+ notification = Notification(
288
+ title="Download..",
289
+ style="progress"
290
+ )
291
+ notification.send()
292
+
293
+ notification.updateTitle("Download Completed")
294
+ notification.removeProgressBar()
295
+ notification.large_icon_path="users/imgs/profile1234.png"
296
+ notification.addNotificationStyle(NotificationStyles.LARGE_ICON,already_sent=True)
297
+
298
+ ```
299
+
281
300
  **Sample Image:**
282
301
  ![channels img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/channel_name.jpg)
283
302
 
@@ -6,7 +6,7 @@ with open("README.md", "r", encoding="utf-8") as readme_data:
6
6
 
7
7
  setup(
8
8
  name="android-notify",
9
- version="1.51.1",
9
+ version="1.51.3",
10
10
  author="Fabian",
11
11
  author_email='fector101@yahoo.com',
12
12
  description="A Python package that simpilfies creating Android notifications in Kivy apps.",