android-notify 1.54.1__tar.gz → 1.55__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.54.1
3
+ Version: 1.55
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
@@ -466,10 +466,16 @@ args
466
466
 
467
467
  ### Instance.updateProgressBar
468
468
 
469
+ if updating title,msg with progressbar frequenlty pass them in too to avoid update issues.
470
+ According to android docs updates shouldn't be too frequent.
471
+
472
+ `updateProgressBar` has a built-in delay of 0.5 secs
473
+
469
474
  args
470
475
 
471
476
  - current_value (str): the value from progressbar current progress
472
477
  - message (str,optional): defaults to last message
478
+ - title (str,optional): defaults to last title
473
479
 
474
480
  ### Instance.removeProgressBar
475
481
 
@@ -479,6 +485,7 @@ args
479
485
 
480
486
  - message (str, optional): notification message, Defaults to 'last message'.
481
487
  - show_on_update (bool, optional): To show notification brifely when progressbar removed. Defaults to True.
488
+ - title (str, optional): notification title, Defaults to 'last title'.
482
489
 
483
490
  ### Instance.addNotificationStyle
484
491
 
@@ -430,10 +430,16 @@ args
430
430
 
431
431
  ### Instance.updateProgressBar
432
432
 
433
+ if updating title,msg with progressbar frequenlty pass them in too to avoid update issues.
434
+ According to android docs updates shouldn't be too frequent.
435
+
436
+ `updateProgressBar` has a built-in delay of 0.5 secs
437
+
433
438
  args
434
439
 
435
440
  - current_value (str): the value from progressbar current progress
436
441
  - message (str,optional): defaults to last message
442
+ - title (str,optional): defaults to last title
437
443
 
438
444
  ### Instance.removeProgressBar
439
445
 
@@ -443,6 +449,7 @@ args
443
449
 
444
450
  - message (str, optional): notification message, Defaults to 'last message'.
445
451
  - show_on_update (bool, optional): To show notification brifely when progressbar removed. Defaults to True.
452
+ - title (str, optional): notification title, Defaults to 'last title'.
446
453
 
447
454
  ### Instance.addNotificationStyle
448
455
 
@@ -1,7 +1,6 @@
1
1
  """ Non-Advanced Stuff """
2
2
  import random
3
3
  import os
4
- print("This function has deprecated use Notification() class")
5
4
  ON_ANDROID = False
6
5
  try:
7
6
  from jnius import autoclass,cast # Needs Java to be installed
@@ -31,7 +31,7 @@ try:
31
31
  ON_ANDROID = True
32
32
  except Exception as e:# pylint: disable=W0718
33
33
  MESSAGE='This Package Only Runs on Android !!! ---> Check "https://github.com/Fector101/android_notify/" to see design patterns and more info.' # pylint: disable=C0301
34
- print(MESSAGE if DEV else '')
34
+ print(MESSAGE)
35
35
 
36
36
  # This is so no crashes when developing on PC
37
37
  def run_on_ui_thread(func):
@@ -55,7 +55,7 @@ if ON_ANDROID:
55
55
  NotificationCompatBigPictureStyle = autoclass('androidx.core.app.NotificationCompat$BigPictureStyle') # pylint: disable=C0301
56
56
  NotificationCompatInboxStyle = autoclass('androidx.core.app.NotificationCompat$InboxStyle')
57
57
  except Exception as e:# pylint: disable=W0718
58
- print(e if DEV else '','Import Fector101')
58
+ print(e)# if DEV else '','Import Fector101')
59
59
  # print(e if DEV else '')
60
60
  print("""
61
61
  Dependency Error: Add the following in buildozer.spec:
@@ -157,59 +157,71 @@ class Notification(BaseNotification):
157
157
  self.__builder.setContentText(String(self.message))
158
158
  self.notification_manager.notify(self.__id, self.__builder.build())
159
159
 
160
- def updateProgressBar(self,current_value,message:str=''):
160
+ def updateProgressBar(self,current_value:int,message:str='',title:str=''):
161
161
  """Updates progress bar current value
162
162
 
163
163
  Args:
164
- current_value (str): the value from progressbar current progress
164
+ current_value (int): the value from progressbar current progress
165
165
  message (str): defaults to last message
166
+ title (str): defaults to last title
166
167
 
167
- NOTE: There is a 0.5sec delay
168
+ NOTE: There is a 0.5sec delay, if updating title,msg with progressbar frequenlty pass them in too to avoid update issues
168
169
  """
169
170
 
170
171
  # Cancel any existing timer before setting a new one
171
172
  if self.__update_timer:
172
- return False
173
-
174
- def delayed_update():
173
+ self.__update_timer.cancel()
175
174
  self.__update_timer = None
175
+
176
+ def delayed_update():
177
+ if self.__update_timer is None:
178
+ # Ensure we are not executing an old timer
179
+ return
176
180
  if self.logs:
177
181
  print(f'Progress Bar Update value: {current_value}')
178
182
 
179
183
  self.progress_current_value = current_value
180
184
 
181
185
  if not ON_ANDROID:
182
- return False
186
+ return
183
187
  self.__builder.setProgress(self.progress_max_value, current_value, False)
184
188
  if message:
185
189
  self.updateMessage(message)
190
+ if title:
191
+ self.updateTitle(title)
186
192
  self.notification_manager.notify(self.__id, self.__builder.build())
187
- return True
193
+ self.__update_timer = None
194
+
188
195
 
189
196
  # Start a new timer that runs after 0.5 seconds
190
197
  self.__update_timer = threading.Timer(0.5, delayed_update)
191
198
  self.__update_timer.start()
192
199
 
193
- def removeProgressBar(self,message='',show_on_update=True) -> None:
200
+ def removeProgressBar(self,message='',show_on_update=True, title:str='') -> None:
194
201
  """Removes Progress Bar from Notification
195
202
 
196
203
  Args:
197
204
  message (str, optional): notification message. Defaults to 'last message'.
198
205
  show_on_update (bool, optional): To show notification brifely when progressbar removed. Defaults to True.
206
+ title (str, optional): notification title. Defaults to 'last title'.
199
207
  """
200
208
  if self.__update_timer:
201
209
  self.__update_timer.cancel()
202
210
  self.__update_timer = None
203
211
 
204
212
  if self.logs:
205
- print(f'removed progress bar with message: {self.message}')
213
+ msg = message or self.message
214
+ title_=title or self.title
215
+ print(f'removed progress bar with message: {msg} and title: {title_}')
206
216
 
207
217
  if not ON_ANDROID:
208
218
  return False
209
219
 
210
220
  self.__builder.setOnlyAlertOnce(not show_on_update)
211
221
  if message:
212
- self.__builder.setContentText(String(message))
222
+ self.updateMessage(message)
223
+ if title:
224
+ self.updateTitle(title)
213
225
  self.__builder.setProgress(0, 0, False)
214
226
  self.notification_manager.notify(self.__id, self.__builder.build())
215
227
  return True
@@ -380,7 +392,7 @@ class Notification(BaseNotification):
380
392
  elif key == 'channel_id' and value.strip(): # If user input's a channel id (i format properly)
381
393
  setattr(self,key, self.__generate_channel_id(value))
382
394
  else:
383
- setattr(self,key, value if value else self.defaults[key])
395
+ setattr(self,key, value if value or isinstance(value, bool) else self.defaults[key])
384
396
 
385
397
  if "channel_id" not in options_dict and 'channel_name' in options_dict: # if User doesn't input channel id but inputs channel_name
386
398
  setattr(self,'channel_id', self.__generate_channel_id(options_dict['channel_name']))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: android-notify
3
- Version: 1.54.1
3
+ Version: 1.55
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
@@ -466,10 +466,16 @@ args
466
466
 
467
467
  ### Instance.updateProgressBar
468
468
 
469
+ if updating title,msg with progressbar frequenlty pass them in too to avoid update issues.
470
+ According to android docs updates shouldn't be too frequent.
471
+
472
+ `updateProgressBar` has a built-in delay of 0.5 secs
473
+
469
474
  args
470
475
 
471
476
  - current_value (str): the value from progressbar current progress
472
477
  - message (str,optional): defaults to last message
478
+ - title (str,optional): defaults to last title
473
479
 
474
480
  ### Instance.removeProgressBar
475
481
 
@@ -479,6 +485,7 @@ args
479
485
 
480
486
  - message (str, optional): notification message, Defaults to 'last message'.
481
487
  - show_on_update (bool, optional): To show notification brifely when progressbar removed. Defaults to True.
488
+ - title (str, optional): notification title, Defaults to 'last title'.
482
489
 
483
490
  ### Instance.addNotificationStyle
484
491
 
@@ -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.54.1",
9
+ version="1.55",
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.",
File without changes