android-notify 1.40.1__tar.gz → 1.50__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
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: android-notify
3
- Version: 1.40.1
3
+ Version: 1.50
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
@@ -21,6 +21,18 @@ Requires-Python: >=3.6
21
21
  Description-Content-Type: text/markdown
22
22
  Requires-Dist: kivy>=2.0.0
23
23
  Requires-Dist: pyjnius>=1.4.2
24
+ Dynamic: author
25
+ Dynamic: author-email
26
+ Dynamic: classifier
27
+ Dynamic: description
28
+ Dynamic: description-content-type
29
+ Dynamic: home-page
30
+ Dynamic: keywords
31
+ Dynamic: license
32
+ Dynamic: project-url
33
+ Dynamic: requires-dist
34
+ Dynamic: requires-python
35
+ Dynamic: summary
24
36
 
25
37
  <div align="center">
26
38
  <br>
@@ -35,6 +47,7 @@ Requires-Dist: pyjnius>=1.4.2
35
47
 
36
48
  - Also Compatible with Android 8.0+.
37
49
  - Supports including images in notifications.
50
+ - All Notifications can take Functions (version 1.50+) [functions docs](#functions).
38
51
  - Support for multiple notification styles:
39
52
  - [Simple](#basic-usage)
40
53
  - [Progress](#progress-bar-notification)
@@ -266,6 +279,60 @@ notification = Notification(title="Silent Update")
266
279
  notification.send(silent=True)
267
280
  ```
268
281
 
282
+ ## Functions
283
+
284
+ ### NotificationHandler - To Attach Listener
285
+
286
+ Add this to your main.py App Class so it runs Once, In later Versions It'll be Attached Automatical
287
+
288
+ ```python
289
+ from kivymd.app import MDApp
290
+ from android_notify import Notification, NotificationHandler
291
+
292
+ class Myapp(MDApp):
293
+
294
+ def on_start(self):
295
+ # Is called Once when app is Starts up
296
+ NotificationHandler.bindNotifyListener() # if successfull returns True
297
+ Notification(title="Hello", message="This is a basic notification.",callback=self.doSomething).send()
298
+
299
+ def doSomething(self):
300
+ print("print in Debug Console")
301
+ ```
302
+
303
+ ### Get Which Notification was used to Open App - identifer (str)
304
+
305
+ If you just want to get the Exact Notification Clicked to Open App, you can use NotificationHandler to get unique identifer
306
+
307
+ ```python
308
+ from kivymd.app import MDApp
309
+ from android_notify import Notification, NotificationHandler
310
+
311
+ class Myapp(MDApp):
312
+
313
+ def on_start(self):
314
+
315
+ notify = Notification(title="Change Page", message="Click to change App page.", identifer='change_app_page')
316
+ notify.send()
317
+
318
+ notify1 = Notification(title="Change Colour", message="Click to change App Colour", identifer='change_app_color')
319
+ notify1.send()
320
+
321
+ NotificationHandler.bindNotifyListener()
322
+
323
+ def on_resume(self):
324
+ # Is called everytime app is reopened
325
+ notify_identifer = NotificationHandler.getIdentifer()
326
+ if notify_identifer == 'change_app_page':
327
+ # Code to change Screen
328
+ pass
329
+ elif notify_identifer == 'change_app_color':
330
+ # Code to change Screen Color
331
+ pass
332
+ ```
333
+
334
+
335
+
269
336
  ### Assist
270
337
 
271
338
  - How to Copy image to app folder
@@ -1,27 +1,3 @@
1
- Metadata-Version: 2.1
2
- Name: android-notify
3
- Version: 1.40.1
4
- Summary: A Python package that simpilfies creating Android notifications 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
1
  <div align="center">
26
2
  <br>
27
3
  <h1> Android-Notifiy </h1>
@@ -35,6 +11,7 @@ Requires-Dist: pyjnius>=1.4.2
35
11
 
36
12
  - Also Compatible with Android 8.0+.
37
13
  - Supports including images in notifications.
14
+ - All Notifications can take Functions (version 1.50+) [functions docs](#functions).
38
15
  - Support for multiple notification styles:
39
16
  - [Simple](#basic-usage)
40
17
  - [Progress](#progress-bar-notification)
@@ -266,6 +243,60 @@ notification = Notification(title="Silent Update")
266
243
  notification.send(silent=True)
267
244
  ```
268
245
 
246
+ ## Functions
247
+
248
+ ### NotificationHandler - To Attach Listener
249
+
250
+ Add this to your main.py App Class so it runs Once, In later Versions It'll be Attached Automatical
251
+
252
+ ```python
253
+ from kivymd.app import MDApp
254
+ from android_notify import Notification, NotificationHandler
255
+
256
+ class Myapp(MDApp):
257
+
258
+ def on_start(self):
259
+ # Is called Once when app is Starts up
260
+ NotificationHandler.bindNotifyListener() # if successfull returns True
261
+ Notification(title="Hello", message="This is a basic notification.",callback=self.doSomething).send()
262
+
263
+ def doSomething(self):
264
+ print("print in Debug Console")
265
+ ```
266
+
267
+ ### Get Which Notification was used to Open App - identifer (str)
268
+
269
+ If you just want to get the Exact Notification Clicked to Open App, you can use NotificationHandler to get unique identifer
270
+
271
+ ```python
272
+ from kivymd.app import MDApp
273
+ from android_notify import Notification, NotificationHandler
274
+
275
+ class Myapp(MDApp):
276
+
277
+ def on_start(self):
278
+
279
+ notify = Notification(title="Change Page", message="Click to change App page.", identifer='change_app_page')
280
+ notify.send()
281
+
282
+ notify1 = Notification(title="Change Colour", message="Click to change App Colour", identifer='change_app_color')
283
+ notify1.send()
284
+
285
+ NotificationHandler.bindNotifyListener()
286
+
287
+ def on_resume(self):
288
+ # Is called everytime app is reopened
289
+ notify_identifer = NotificationHandler.getIdentifer()
290
+ if notify_identifer == 'change_app_page':
291
+ # Code to change Screen
292
+ pass
293
+ elif notify_identifer == 'change_app_color':
294
+ # Code to change Screen Color
295
+ pass
296
+ ```
297
+
298
+
299
+
269
300
  ### Assist
270
301
 
271
302
  - How to Copy image to app folder
@@ -0,0 +1,4 @@
1
+ """"For Easier Imports For Public Classes"""
2
+ from .core import send_notification
3
+ from .styles import NotificationStyles
4
+ from .sword import Notification,NotificationHandler
@@ -1,10 +1,10 @@
1
1
  """ Non-Advanced Stuff """
2
2
  import random
3
3
  import os
4
- from jnius import autoclass,cast
5
4
 
6
5
  ON_ANDROID = False
7
6
  try:
7
+ from jnius import autoclass,cast # Needs Java to be installed
8
8
  # Get the required Java classes
9
9
  PythonActivity = autoclass('org.kivy.android.PythonActivity')
10
10
  NotificationChannel = autoclass('android.app.NotificationChannel')
@@ -1,15 +1,19 @@
1
1
  """This Module Contain Class for creating Notification With Java"""
2
2
  import difflib
3
- import random
3
+ import traceback
4
4
  import os
5
5
  import re
6
- from jnius import autoclass,cast # pylint: disable=W0611, C0114
7
6
 
8
7
  DEV=0
9
8
  ON_ANDROID = False
10
9
 
11
10
  try:
11
+ from jnius import autoclass,cast # Needs Java to be installed pylint: disable=W0611, C0114
12
+ from android import activity # pylint: disable=import-error
13
+ from android.config import ACTIVITY_CLASS_NAME # pylint: disable=import-error
14
+
12
15
  # Get the required Java classes
16
+ Bundle = autoclass('android.os.Bundle')
13
17
  PythonActivity = autoclass('org.kivy.android.PythonActivity')
14
18
  String = autoclass('java.lang.String')
15
19
  Intent = autoclass('android.content.Intent')
@@ -56,18 +60,21 @@ class Notification:
56
60
  :param style: Style of the notification
57
61
  ('simple', 'progress', 'big_text', 'inbox', 'big_picture', 'large_icon', 'both_imgs').
58
62
  both_imgs == using lager icon and big picture
59
- :param big_picture_path: Path to the image resource.
60
- :param large_icon_path: Path to the image resource.
63
+ :param big_picture_path: Relative Path to the image resource.
64
+ :param large_icon_path: Relative Path to the image resource.
65
+ :param callback: Function for notification Click.
61
66
  ---
62
67
  (Advance Options)
63
- :param channel_name: Defaults to "Default Channel"
64
- :param channel_id: Defaults to "default_channel"
68
+ :param channel_name: - str Defaults to "Default Channel"
69
+ :param channel_id: - str Defaults to "default_channel"
65
70
  ---
66
71
  (Options during Dev On PC)
67
- :param logs: Defaults to True
72
+ :param logs: - Bool Defaults to True
68
73
  """
69
- notification_ids=[]
70
- button_ids=[]
74
+ notification_ids=[0]
75
+ button_ids=[0]
76
+ btns_box={}
77
+ main_functions={}
71
78
  style_values=[
72
79
  '','simple',
73
80
  'progress','big_text',
@@ -86,6 +93,8 @@ class Notification:
86
93
  'channel_name':'Default Channel',
87
94
  'channel_id':'default_channel',
88
95
  'logs':True,
96
+ "identifer": '',
97
+ 'callback': None
89
98
  }
90
99
  # During Development (When running on PC)
91
100
  logs=not ON_ANDROID
@@ -99,15 +108,23 @@ class Notification:
99
108
  self.big_picture_path=''
100
109
  self.progress_current_value=0
101
110
  self.progress_max_value=0
111
+
112
+ # For Nofitication Functions
113
+ self.identifer=''
114
+ self.callback = None
115
+
102
116
  # Advance Options
103
117
  self.channel_name='Default Channel'
104
118
  self.channel_id='default_channel'
105
119
  self.silent=False
120
+
106
121
  # During Dev on PC
107
122
  self.logs=self.logs
123
+
108
124
  # Private (Don't Touch)
109
125
  self.__id = self.__getUniqueID()
110
126
  self.__setArgs(kwargs)
127
+
111
128
  if not ON_ANDROID:
112
129
  return
113
130
  # TODO make send method wait for __asks_permission_if_needed method
@@ -139,7 +156,7 @@ class Notification:
139
156
  """message defaults to last message"""
140
157
  if not ON_ANDROID:
141
158
  return
142
-
159
+
143
160
  if self.logs:
144
161
  print(f'Progress Bar Update value: {current_value}')
145
162
  self.__builder.setProgress(self.progress_max_value, current_value, False)
@@ -234,8 +251,8 @@ class Notification:
234
251
 
235
252
  # Build the notification
236
253
  # self.__builder = NotificationCompatBuilder(context, self.channel_id)# pylint: disable=E0606
237
- self.__builder.setContentTitle(self.title)
238
- self.__builder.setContentText(self.message)
254
+ self.__builder.setContentTitle(str(self.title))
255
+ self.__builder.setContentText(str(self.message))
239
256
  self.__builder.setSmallIcon(context.getApplicationInfo().icon)
240
257
  self.__builder.setDefaults(NotificationCompat.DEFAULT_ALL) # pylint: disable=E0606
241
258
  self.__builder.setPriority(NotificationCompat.PRIORITY_DEFAULT if self.silent else NotificationCompat.PRIORITY_HIGH)
@@ -283,7 +300,7 @@ class Notification:
283
300
  big_pic_bitmap = self.__getBitmap(big_pic_javapath)
284
301
  big_picture_style = NotificationCompatBigPictureStyle().bigPicture(big_pic_bitmap)
285
302
  self.__builder.setStyle(big_picture_style)
286
- elif large_icon_javapath:
303
+ if large_icon_javapath:
287
304
  large_icon_bitmap = self.__getBitmap(large_icon_javapath)
288
305
  self.__builder.setLargeIcon(large_icon_bitmap)
289
306
  elif self.style == 'progress':
@@ -298,10 +315,7 @@ class Notification:
298
315
  # return self.__builder
299
316
 
300
317
  def __getUniqueID(self):
301
- reasonable_amount_of_notifications=101
302
- notification_id = random.randint(1, reasonable_amount_of_notifications)
303
- while notification_id in self.notification_ids:
304
- notification_id = random.randint(1, reasonable_amount_of_notifications)
318
+ notification_id = self.notification_ids[-1] + 1
305
319
  self.notification_ids.append(notification_id)
306
320
  return notification_id
307
321
 
@@ -352,9 +366,15 @@ class Notification:
352
366
  # Remove leading/trailing underscores
353
367
  channel_id = channel_id.strip('_')
354
368
  return channel_id[:50]
369
+
355
370
  def __addIntentToOpenApp(self):
356
371
  intent = Intent(context, PythonActivity)
357
- intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP)
372
+ action = str(self.identifer) or f"ACTION_{self.__id}"
373
+ intent.setAction(action)
374
+ self.__addDataToIntent(intent)
375
+ self.main_functions[action]=self.callback
376
+ intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
377
+
358
378
  pending_intent = PendingIntent.getActivity(
359
379
  context, 0,
360
380
  intent, PendingIntent.FLAG_IMMUTABLE if BuildVersion.SDK_INT >= 31 else PendingIntent.FLAG_UPDATE_CURRENT
@@ -362,13 +382,17 @@ class Notification:
362
382
  self.__builder.setContentIntent(pending_intent)
363
383
  self.__builder.setAutoCancel(True)
364
384
 
385
+ def __addDataToIntent(self,intent):
386
+ """Persit Some data to notification object for later use"""
387
+ bundle = Bundle()
388
+ bundle.putString("title", self.title or 'Title Placeholder')
389
+ bundle.putInt("notify_id", self.__id)
390
+ intent.putExtras(bundle)
391
+
365
392
  def __getIDForButton(self):
366
- reasonable_amount_of_notifications=101
367
- btn_id = random.randint(1, reasonable_amount_of_notifications)
368
- while btn_id in self.button_ids:
369
- btn_id = random.randint(1, reasonable_amount_of_notifications)
393
+ btn_id = self.button_ids[-1] + 1
370
394
  self.button_ids.append(btn_id)
371
- return str(btn_id)
395
+ return btn_id
372
396
 
373
397
  def addButton(self, text:str,on_release):
374
398
  """For adding action buttons
@@ -376,21 +400,40 @@ class Notification:
376
400
  Args:
377
401
  text (str): Text For Button
378
402
  """
403
+ if self.logs:
404
+ print('Added Button: ', text)
405
+
379
406
  if not ON_ANDROID:
380
407
  return
381
408
 
382
- if self.logs:
383
- print('Added Button: '+text)
409
+ btn_id= self.__getIDForButton()
410
+ action = f"BTN_ACTION_{btn_id}"
411
+
384
412
  action_intent = Intent(context, PythonActivity)
385
- action_intent.setAction("ACTION "+ self.__getIDForButton())
413
+ action_intent.setAction(action)
414
+ action_intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
415
+ bundle = Bundle()
416
+ bundle.putString("title", self.title or 'Title Placeholder')
417
+ bundle.putInt("key_int", 123)
418
+ action_intent.putExtras(bundle)
419
+ action_intent.putExtra("button_id", btn_id)
420
+
421
+ self.btns_box[action] = on_release
422
+ # action_intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP)
423
+
424
+ if self.logs:
425
+ print('Button id: ',btn_id)
386
426
  pending_action_intent = PendingIntent.getActivity(
387
427
  context,
388
428
  0,
389
429
  action_intent,
390
- PendingIntent.FLAG_IMMUTABLE
430
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE
391
431
  )
392
432
  # Convert text to CharSequence
393
433
  action_text = cast('java.lang.CharSequence', String(text))
434
+
435
+
436
+
394
437
  # Add action with proper types
395
438
  self.__builder.addAction(
396
439
  int(context.getApplicationInfo().icon), # Cast icon to int
@@ -399,38 +442,106 @@ class Notification:
399
442
  )
400
443
  # Set content intent for notification tap
401
444
  self.__builder.setContentIntent(pending_action_intent)
402
- # on_release()
403
-
404
- # def buttonsListener():
405
- # """Handle notification button clicks"""
406
- # try:
407
- # intent = context.getIntent()
408
- # action = context.getAction()
409
- # print("The Action --> ",action)
410
- # intent.setAction("")
411
- # context.setIntent(intent)
412
- # except Exception as e:
413
- # print("Catching Intents Error ",e)
414
-
415
- # notify=Notification(titl='My Title',channel_name='Go')#,logs=False)
416
- # # notify.channel_name='Downloads'
417
- # notify.message="Blah"
418
- # notify.send()
419
- # notify.updateTitle('New Title')
420
- # notify.updateMessage('New Message')
421
- # notify.send(True)
422
- # except Exception as e:
423
- # print(e)
424
-
425
- # notify=Notification(title='My Title1')
426
- # # notify.updateTitle('New Title1')
427
- # notify.send()
428
-
429
-
430
- # Notification.logs=False # Add in Readme
431
- # notify=Notification(style='large_icon',title='My Title',channel_name='Some thing about a thing ')#,logs=False)
432
- # # notify.channel_name='Downloads'
433
- # notify.message="Blah"
434
- # notify.send()
435
- # notify.updateTitle('New Title')
436
- # notify.updateMessage('New Message')
445
+
446
+
447
+ class NotificationHandler:
448
+ """For Notification Operations """
449
+ __identifer = None
450
+
451
+ @classmethod
452
+ def getIdentifer(cls):
453
+ """Returns identifer for Clicked Notification."""
454
+ if not cls.is_on_android():
455
+ return "Not on Android"
456
+
457
+ saved_intent = cls.__identifer
458
+ if not saved_intent or (isinstance(saved_intent, str) and saved_intent.startswith("android.intent")):
459
+ # All other notifications are not None after First notification opens app
460
+ # NOTE these notifications are also from Last time app was opened and they Still Give Value after first one opens App
461
+ # TODO Find a way to get intent when App if Swiped From recents
462
+ __PythonActivity = autoclass(ACTIVITY_CLASS_NAME)
463
+ __mactivity = __PythonActivity.mActivity
464
+ __context = cast('android.content.Context', __mactivity)
465
+ __Intent = autoclass('android.content.Intent')
466
+ __intent = __Intent(__context, __PythonActivity)
467
+ action = __intent.getAction()
468
+ print('Start up Intent ----', action)
469
+ print('start Up Title --->',__intent.getStringExtra("title"))
470
+
471
+ return saved_intent
472
+
473
+ @classmethod
474
+ def __notificationHandler(cls,intent):
475
+ """Calls Function Attached to notification on click.
476
+ Don't Call this function manual, it's Already Attach to Notification.
477
+
478
+ Returns:
479
+ str: The Identiter of Nofication that was clicked.
480
+ """
481
+ if not cls.is_on_android():
482
+ return "Not on Android"
483
+ buttons_object=Notification.btns_box
484
+ notifty_functions=Notification.main_functions
485
+ if DEV:
486
+ print("notifty_functions ",notifty_functions)
487
+ print("buttons_object", buttons_object)
488
+ action = None
489
+ try:
490
+ action = intent.getAction()
491
+ cls.__identifer = action
492
+
493
+ print("The Action --> ",action)
494
+ if action == "android.intent.action.MAIN": # Not Open From Notification
495
+ return 'Not notification'
496
+
497
+ print(intent.getStringExtra("title"))
498
+ try:
499
+ if action in notifty_functions and notifty_functions[action]:
500
+ notifty_functions[action]()
501
+ elif action in buttons_object:
502
+ buttons_object[action]()
503
+ except Exception as e: # pylint: disable=broad-exception-caught
504
+ print('Failed to run function: ', traceback.format_exc())
505
+ print("Error Type ",e)
506
+ except Exception as e: # pylint: disable=broad-exception-caught
507
+ print('Notify Hanlder Failed ',e)
508
+ return action
509
+
510
+ @classmethod
511
+ def bindNotifyListener(cls):
512
+ """Binds the notification listener.\n\n
513
+ ```
514
+ from kivy.app import App
515
+ from android_notify import bindNotifyListener
516
+ class Myapp(App):
517
+ def on_start(self):
518
+ bindNotifyListener() # if successfull returns True
519
+ ```
520
+ """
521
+ if not cls.is_on_android():
522
+ return "Not on Android"
523
+ #Beta TODO Automatic bind when Notification object is called the first time use keep trying BroadcastReceiver
524
+ try:
525
+ activity.bind(on_new_intent=cls.__notificationHandler)
526
+ return True
527
+ except Exception as e: # pylint: disable=broad-exception-caught
528
+ print('Failed to bin notitfications listener',e)
529
+ return False
530
+ @classmethod
531
+ def unbindNotifyListener(cls):
532
+ """Removes Listener for Notifications Click"""
533
+ if not cls.is_on_android():
534
+ return "Not on Android"
535
+
536
+ #Beta TODO use BroadcastReceiver
537
+ try:
538
+ activity.unbind(on_new_intent=cls.__notificationHandler)
539
+ return True
540
+ except Exception as e: # pylint: disable=broad-exception-caught
541
+ print("Failed to unbind notifications listener: ",e)
542
+ return False
543
+
544
+ @staticmethod
545
+ def is_on_android():
546
+ """Utility to check if the app is running on Android."""
547
+ return ON_ANDROID
@@ -1,3 +1,39 @@
1
+ Metadata-Version: 2.2
2
+ Name: android-notify
3
+ Version: 1.50
4
+ Summary: A Python package that simpilfies creating Android notifications 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
+ Dynamic: author
25
+ Dynamic: author-email
26
+ Dynamic: classifier
27
+ Dynamic: description
28
+ Dynamic: description-content-type
29
+ Dynamic: home-page
30
+ Dynamic: keywords
31
+ Dynamic: license
32
+ Dynamic: project-url
33
+ Dynamic: requires-dist
34
+ Dynamic: requires-python
35
+ Dynamic: summary
36
+
1
37
  <div align="center">
2
38
  <br>
3
39
  <h1> Android-Notifiy </h1>
@@ -11,6 +47,7 @@
11
47
 
12
48
  - Also Compatible with Android 8.0+.
13
49
  - Supports including images in notifications.
50
+ - All Notifications can take Functions (version 1.50+) [functions docs](#functions).
14
51
  - Support for multiple notification styles:
15
52
  - [Simple](#basic-usage)
16
53
  - [Progress](#progress-bar-notification)
@@ -242,6 +279,60 @@ notification = Notification(title="Silent Update")
242
279
  notification.send(silent=True)
243
280
  ```
244
281
 
282
+ ## Functions
283
+
284
+ ### NotificationHandler - To Attach Listener
285
+
286
+ Add this to your main.py App Class so it runs Once, In later Versions It'll be Attached Automatical
287
+
288
+ ```python
289
+ from kivymd.app import MDApp
290
+ from android_notify import Notification, NotificationHandler
291
+
292
+ class Myapp(MDApp):
293
+
294
+ def on_start(self):
295
+ # Is called Once when app is Starts up
296
+ NotificationHandler.bindNotifyListener() # if successfull returns True
297
+ Notification(title="Hello", message="This is a basic notification.",callback=self.doSomething).send()
298
+
299
+ def doSomething(self):
300
+ print("print in Debug Console")
301
+ ```
302
+
303
+ ### Get Which Notification was used to Open App - identifer (str)
304
+
305
+ If you just want to get the Exact Notification Clicked to Open App, you can use NotificationHandler to get unique identifer
306
+
307
+ ```python
308
+ from kivymd.app import MDApp
309
+ from android_notify import Notification, NotificationHandler
310
+
311
+ class Myapp(MDApp):
312
+
313
+ def on_start(self):
314
+
315
+ notify = Notification(title="Change Page", message="Click to change App page.", identifer='change_app_page')
316
+ notify.send()
317
+
318
+ notify1 = Notification(title="Change Colour", message="Click to change App Colour", identifer='change_app_color')
319
+ notify1.send()
320
+
321
+ NotificationHandler.bindNotifyListener()
322
+
323
+ def on_resume(self):
324
+ # Is called everytime app is reopened
325
+ notify_identifer = NotificationHandler.getIdentifer()
326
+ if notify_identifer == 'change_app_page':
327
+ # Code to change Screen
328
+ pass
329
+ elif notify_identifer == 'change_app_color':
330
+ # Code to change Screen Color
331
+ pass
332
+ ```
333
+
334
+
335
+
245
336
  ### Assist
246
337
 
247
338
  - How to Copy image to app folder
@@ -1,4 +1,4 @@
1
- """ For Packing"""
1
+ """ For Packing """
2
2
  from setuptools import setup, find_packages
3
3
 
4
4
  with open("README.md", "r", encoding="utf-8") as readme_data:
@@ -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.40.1",
9
+ version="1.50",
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.",
@@ -1,3 +0,0 @@
1
- from .core import send_notification
2
- from .styles import NotificationStyles
3
- from .sword import Notification
File without changes