android-notify 1.57__py3-none-any.whl → 1.58__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.

android_notify/sword.py CHANGED
@@ -1,9 +1,8 @@
1
1
  """This Module Contain Class for creating Notification With Java"""
2
- import difflib
3
2
  import traceback
4
- import os
3
+ import os,re
5
4
  import threading
6
- import re
5
+ # ,time
7
6
  from .styles import NotificationStyles
8
7
  from .base import BaseNotification
9
8
  DEV=0
@@ -98,7 +97,13 @@ class Notification(BaseNotification):
98
97
  super().__init__(**kwargs)
99
98
 
100
99
  self.__id = self.__getUniqueID()
101
- self.__update_timer = None # To Track progressbar last update (According to Android Docs Don't update bar to often, I also faced so issues when doing that)
100
+
101
+ # To Track progressbar last update (According to Android Docs Don't update bar to often, I also faced so issues when doing that)
102
+ self.__update_timer = None
103
+ self.__progress_bar_msg = ''
104
+ self.__progress_bar_title = ''
105
+ self.__cooldown = 0
106
+
102
107
  self.__formatChannel(kwargs)
103
108
  if not ON_ANDROID:
104
109
  return
@@ -112,7 +117,7 @@ class Notification(BaseNotification):
112
117
  """
113
118
  self.__builder.setProgress(0,0, True)
114
119
  self.__dispatchNotification()
115
-
120
+
116
121
  def updateTitle(self,new_title):
117
122
  """Changes Old Title
118
123
 
@@ -139,78 +144,106 @@ class Notification(BaseNotification):
139
144
  self.__builder.setContentText(String(self.message))
140
145
  self.__dispatchNotification()
141
146
 
142
- def updateProgressBar(self,current_value:int,message:str='',title:str='',buffer=0.5):
147
+ def updateProgressBar(self,current_value:int,message:str='',title:str='',cooldown=0.5):
143
148
  """Updates progress bar current value
144
-
149
+
145
150
  Args:
146
151
  current_value (int): the value from progressbar current progress
147
152
  message (str): defaults to last message
148
153
  title (str): defaults to last title
149
- buffer (float, optional): Avoid Updating progressbar value too frequently Defaults to 0.5secs
150
- NOTE: There is a 0.5sec delay for value change, if updating title,msg with progressbar frequenlty pass them in too to avoid update issues
154
+ cooldown (float, optional): Avoid Updating progressbar value too frequently Defaults to 0.5secs
155
+
156
+ NOTE: There is a 0.5sec delay for value change, if updating title,msg with progressbar frequently pass them in too to avoid update issues
151
157
  """
152
- # replacing new value for when timer is called
153
- self.progress_current_value = current_value
154
158
 
155
- if self.__update_timer:
156
- if self.logs:
157
- print('Progressbar update too soon Doing bounce 0.5sec')
159
+ # replacing new values for when timer is called
160
+ self.progress_current_value = current_value
161
+ self.__progress_bar_msg = message
162
+ self.__progress_bar_title = title
163
+
164
+ if self.__update_timer and self.__update_timer.is_alive():
165
+ # Make Logs too Dirty
166
+ # if self.logs:
167
+ # remaining = self.__cooldown - (time.time() - self.__timer_start_time)
168
+ # print(f'Progressbar update too soon, waiting for cooldown ({max(0, remaining):.2f}s)')
158
169
  return
159
170
 
160
171
  def delayed_update():
161
- if self.__update_timer is None:
162
- # Ensure we are not executing an old timer
172
+ if self.__update_timer is None: # Ensure we are not executing an old timer
173
+ if self.logs:
174
+ print('ProgressBar update skipped: bar has been removed.')
163
175
  return
164
176
  if self.logs:
165
177
  print(f'Progress Bar Update value: {self.progress_current_value}')
166
178
 
167
179
  if not ON_ANDROID:
180
+ self.__update_timer = None
168
181
  return
182
+
169
183
  self.__builder.setProgress(self.progress_max_value, self.progress_current_value, False)
170
- if message:
171
- self.updateMessage(message)
172
- if title:
173
- self.updateTitle(title)
184
+
185
+ if self.__progress_bar_msg:
186
+ self.updateMessage(self.__progress_bar_msg)
187
+ if self.__progress_bar_title:
188
+ self.updateTitle(self.__progress_bar_title)
189
+
174
190
  self.__dispatchNotification()
175
191
  self.__update_timer = None
176
192
 
177
193
 
178
194
  # Start a new timer that runs after 0.5 seconds
179
- self.__update_timer = threading.Timer(0.5, delayed_update)
195
+ # self.__timer_start_time = time.time() # for logs
196
+ self.__cooldown = cooldown
197
+ self.__update_timer = threading.Timer(cooldown, delayed_update)
180
198
  self.__update_timer.start()
181
199
 
182
- def removeProgressBar(self,message='',show_on_update=True, title:str='') -> bool:
200
+ def removeProgressBar(self,message='',show_on_update=True, title:str='',cooldown=0.5):
183
201
  """Removes Progress Bar from Notification
184
202
 
185
203
  Args:
186
204
  message (str, optional): notification message. Defaults to 'last message'.
187
- show_on_update (bool, optional): To show notification brifely when progressbar removed. Defaults to True.
205
+ show_on_update (bool, optional): To show notification briefly when progressbar removed. Defaults to True.
188
206
  title (str, optional): notification title. Defaults to 'last title'.
207
+ cooldown (float, optional): Avoid Updating progressbar value too frequently Defaults to 0.5secs
208
+
209
+ In-Built Delay of 0.5sec According to Android Docs Don't Update Progressbar too Frequently
189
210
  """
211
+
212
+ # To Cancel any queued timer from `updateProgressBar` method and to avoid race effect incase it somehow gets called while in this method
213
+ # Avoiding Running `updateProgressBar.delayed_update` at all
214
+ # so didn't just set `self.__progress_bar_title` and `self.progress_current_value` to 0
190
215
  if self.__update_timer:
216
+ # Make Logs too Dirty
217
+ # if self.logs:
218
+ # print('cancelled progressbar stream update because about to remove',self.progress_current_value)
191
219
  self.__update_timer.cancel()
192
220
  self.__update_timer = None
193
-
194
- if self.logs:
195
- msg = message or self.message
196
- title_=title or self.title
197
- print(f'removed progress bar with message: {msg} and title: {title_}')
198
221
 
199
- if not ON_ANDROID:
200
- return False
201
222
 
202
- self.__builder.setOnlyAlertOnce(not show_on_update)
203
- if message:
204
- self.updateMessage(message)
205
- if title:
206
- self.updateTitle(title)
207
- self.__builder.setProgress(0, 0, False)
208
- self.__dispatchNotification()
209
- return True
223
+
224
+ def delayed_update():
225
+ if self.logs:
226
+ msg = message or self.message
227
+ title_=title or self.title
228
+ print(f'removed progress bar with message: {msg} and title: {title_}')
229
+
230
+ if not ON_ANDROID:
231
+ return
232
+
233
+ if message:
234
+ self.updateMessage(message)
235
+ if title:
236
+ self.updateTitle(title)
237
+ self.__builder.setOnlyAlertOnce(not show_on_update)
238
+ self.__builder.setProgress(0, 0, False)
239
+ self.__dispatchNotification()
240
+
241
+ # Incase `self.updateProgressBar delayed_update` is called right before this method, so android doesn't bounce update
242
+ threading.Timer(cooldown, delayed_update).start()
210
243
 
211
244
  def send(self,silent:bool=False,persistent=False,close_on_click=True):
212
245
  """Sends notification
213
-
246
+
214
247
  Args:
215
248
  silent (bool): True if you don't want to show briefly on screen
216
249
  persistent (bool): True To not remove Notification When User hits clears All notifications button
@@ -242,6 +275,7 @@ class Notification(BaseNotification):
242
275
 
243
276
  Args:
244
277
  text (str): Text For Button
278
+ on_release: function to be called when button is clicked
245
279
  """
246
280
  if self.logs:
247
281
  print('Added Button: ', text)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: android-notify
3
- Version: 1.57
3
+ Version: 1.58
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
@@ -3,9 +3,9 @@ android_notify/__main__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  android_notify/base.py,sha256=QkNSNFX8KtNnRRm0r1wXsQa6TWMRKySn-3PT-XpY1mM,3377
4
4
  android_notify/core.py,sha256=Per4HFwYwP-mxHJqnwcLlWXsbZsSeeAYN49MmFU2qVk,6113
5
5
  android_notify/styles.py,sha256=QBkCY8ZO26FnS-jPtRLf9CKEEnnYylmH9enCa5CNDes,354
6
- android_notify/sword.py,sha256=wjLYAsQ1OAnK7UthF5VqhUYYN9EX8otbQ7gL0dHElAQ,28115
6
+ android_notify/sword.py,sha256=RJ8FME5Ob4F3Ln9mNdzW4xSw-mlMgh9GwBLiD0W7-a8,29791
7
7
  android_notify/types_idea.py,sha256=6LC8JQT6rve4AtrppdKRmXeSC07L8ljlO1aQEOpuDV4,1776
8
- android_notify-1.57.dist-info/METADATA,sha256=Fzrqbb5beNdPXQld1lCtbxu-UmnQ0bHndg07z5oD_JU,16568
9
- android_notify-1.57.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
10
- android_notify-1.57.dist-info/top_level.txt,sha256=IR1ONMrRSRINZpWn2X0dL5gbWwWINsK7PW8Jy2p4fU8,15
11
- android_notify-1.57.dist-info/RECORD,,
8
+ android_notify-1.58.dist-info/METADATA,sha256=9CDByWUNDh4kZcQGPxj_zwnwZYeDzatltON64PAw_vs,16568
9
+ android_notify-1.58.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
10
+ android_notify-1.58.dist-info/top_level.txt,sha256=IR1ONMrRSRINZpWn2X0dL5gbWwWINsK7PW8Jy2p4fU8,15
11
+ android_notify-1.58.dist-info/RECORD,,