android-notify 1.57.1__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 +73 -39
- {android_notify-1.57.1.dist-info → android_notify-1.58.dist-info}/METADATA +1 -1
- {android_notify-1.57.1.dist-info → android_notify-1.58.dist-info}/RECORD +5 -5
- {android_notify-1.57.1.dist-info → android_notify-1.58.dist-info}/WHEEL +0 -0
- {android_notify-1.57.1.dist-info → android_notify-1.58.dist-info}/top_level.txt +0 -0
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
|
-
|
|
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
|
-
|
|
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='',
|
|
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
|
-
|
|
150
|
-
|
|
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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
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
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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.
|
|
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='')
|
|
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
|
|
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
|
-
|
|
203
|
-
|
|
204
|
-
self.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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)
|
|
@@ -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=
|
|
6
|
+
android_notify/sword.py,sha256=RJ8FME5Ob4F3Ln9mNdzW4xSw-mlMgh9GwBLiD0W7-a8,29791
|
|
7
7
|
android_notify/types_idea.py,sha256=6LC8JQT6rve4AtrppdKRmXeSC07L8ljlO1aQEOpuDV4,1776
|
|
8
|
-
android_notify-1.
|
|
9
|
-
android_notify-1.
|
|
10
|
-
android_notify-1.
|
|
11
|
-
android_notify-1.
|
|
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,,
|
|
File without changes
|
|
File without changes
|