android-notify
Advanced tools
| Metadata-Version: 2.4 | ||
| Name: android-notify | ||
| Version: 1.60.6.dev0 | ||
| Version: 1.60.6 | ||
| Summary: A Python package that simplifies creating Android notifications in Kivy and Flet apps. | ||
@@ -76,3 +76,5 @@ Author-email: Fabian <fector101@yahoo.com> | ||
| ### Kivy apps: | ||
| <details> | ||
| <summary><b>Kivy apps:</b></summary> | ||
| <br/> | ||
@@ -83,11 +85,22 @@ In your **`buildozer.spec`** file, ensure you include the following: | ||
| # Add pyjnius so ensure it's packaged with the build | ||
| requirements = python3, kivy, pyjnius, android-notify>=1.60.6.dev0 | ||
| requirements = python3, kivy, pyjnius, android-notify | ||
| # Add permission for notifications | ||
| android.permissions = POST_NOTIFICATIONS | ||
| # Required dependencies (write exactly as shown, no quotation marks) | ||
| android.gradle_dependencies = androidx.core:core:1.6.0, androidx.core:core-ktx:1.15.0 | ||
| android.enable_androidx = True | ||
| android.api = 35 | ||
| ``` | ||
| ### Flet apps: | ||
| </details> | ||
| In your `pyproject.toml` file, ensure you include the following: | ||
| <details> | ||
| <summary><b>Flet apps:</b></summary> | ||
| <br/> | ||
| In your `pyproject.toml` file, ensure you include the following: | ||
| ```toml | ||
@@ -102,11 +115,13 @@ [tool.flet.android] | ||
| ``` | ||
| - example of [complete flet pyproject.toml](https://github.com/Fector101/flet-app/blob/main/pyproject.toml) | ||
| ### Pydroid 3 | ||
| In the [pydroid 3](https://play.google.com/store/apps/details?id=ru.iiec.pydroid3) mobile app for running python code you can test some features. | ||
| - In pip section where you're asked to insert `Libary name` paste `android-notify>=1.60.6.dev0` | ||
| </details> | ||
| <details> | ||
| ### Testing | ||
| Can be installed via `pip` For testing purposes: | ||
| <summary><b>Desktop</b></summary> | ||
| <br/> | ||
| For IDE IntelliSense Can be installed via `pip install`: | ||
| ```bash | ||
@@ -117,5 +132,73 @@ pip install android_notify | ||
| </details> | ||
| ------ | ||
| ## Installing without Androidx | ||
| How to use without `gradle_dependencies` | ||
| Use `android-notify>=1.60.6.dev0` to install via `pip` | ||
| <details> | ||
| <summary><b>In Kivy</b></summary> | ||
| <br/> | ||
| ```ini | ||
| # buildozer.spec | ||
| requirements = python3, kivy, pyjnius, android-notify>=1.60.6.dev0 | ||
| ``` | ||
| </details> | ||
| <details> | ||
| <summary><b>On Pydroid 3</b></summary> | ||
| <br/> | ||
| On the [pydroid 3](https://play.google.com/store/apps/details?id=ru.iiec.pydroid3) mobile app for running python code you can test some features. | ||
| - In pip section where you're asked to insert `Libary name` paste `android-notify>=1.60.6.dev0` | ||
| - Minimal working example | ||
| ```py | ||
| # Testing with `android-notify>=1.60.6.dev0` on pydroid | ||
| from kivy.app import App | ||
| from kivy.uix.boxlayout import BoxLayout | ||
| from kivy.uix.button import Button | ||
| from android_notify import Notification | ||
| from android_notify.core import asks_permission_if_needed | ||
| class AndroidNotifyDemoApp(App): | ||
| def build(self): | ||
| layout = BoxLayout(orientation='vertical', spacing=10, padding=20) | ||
| layout.add_widget(Button( | ||
| text="Ask Notification Permission", | ||
| on_release=self.request_permission | ||
| )) | ||
| layout.add_widget(Button( | ||
| text="Send Notification", | ||
| on_release=self.send_notification | ||
| )) | ||
| return layout | ||
| def request_permission(self, *args): | ||
| asks_permission_if_needed(no_androidx=True) | ||
| def send_notification(self, *args): | ||
| Notification( | ||
| title="Hello from Android Notify", | ||
| message="This is a basic notification.", | ||
| channel_id="android_notify_demo", | ||
| channel_name="Android Notify Demo" | ||
| ).send() | ||
| if __name__ == "__main__": | ||
| AndroidNotifyDemoApp().run() | ||
| ``` | ||
| </details> | ||
| ## Documentation | ||
| For Dev Version use | ||
| ```requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_notify/archive/without-androidx.zip``` | ||
| ```requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_notify/archive/main.zip``` | ||
@@ -137,6 +220,5 @@ ### To talk to BroadCast Listener From Buttons | ||
| - Copy the [res](https://github.com/Fector101/android_notify/tree/main/android_notify/res) folder to your app path. | ||
| Lastly in your `buildozer.spec` file | ||
| - Add `source.include_exts = xml` and `android.add_resources = ./res` | ||
| - Lastly in your `buildozer.spec` file | ||
| Add `source.include_exts = xml` and `android.add_resources = # path you pasted` | ||
| ### To use Custom Sounds | ||
@@ -172,6 +254,3 @@ | ||
| If you find this project helpful, consider buying me a coffee! š Or Giving it a star on š [GitHub](https://github.com/Fector101/android_notify/) Your support helps maintain and improve the project. | ||
| <a href="https://www.buymeacoffee.com/fector101" target="_blank"> | ||
| <img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60"> | ||
| </a> | ||
| If you find this project helpful, any support would help me continue working on open-source projects. Iām currently saving for a laptop to keep developing. | ||
| [donate](https://www.buymeacoffee.com/fector101) |
@@ -18,4 +18,2 @@ README.md | ||
| android_notify.egg-info/top_level.txt | ||
| android_notify/fallback-icons/flet-appicon.png | ||
| android_notify/fallback-icons/pydroid3-appicon.png | ||
| docs/examples/flet-working/src/core.py | ||
@@ -22,0 +20,0 @@ docs/examples/flet-working/src/main.py |
@@ -111,6 +111,3 @@ """For autocomplete Storing Reference to Available Methods""" | ||
| class NotificationManagerClass: | ||
| pass | ||
| class NotificationChannel: | ||
@@ -176,8 +173,2 @@ def __init__(self, channel_id, channel_name, importance): | ||
| class AndroidNotification: | ||
| DEFAULT_ALL = 3 | ||
| PRIORITY_HIGH = 4 | ||
| PRIORITY_DEFAULT = '' | ||
| PRIORITY_LOW = '' | ||
| PRIORITY_MIN = '' | ||
@@ -201,16 +192,12 @@ class NotificationCompat: | ||
| self.mActions = MActions() | ||
| print(f"[MOCK] NotificationCompatBuilder initialized with context={context}, channel_id={channel_id}") | ||
| pass | ||
| def setProgress(self,max_value,current_value,endless): | ||
| pass | ||
| def setStyle(self,style): | ||
| pass | ||
| def setContentTitle(self,title): | ||
| pass | ||
| def setContentText(self,text): | ||
| pass | ||
| def setProgress(self, max_value, current_value, endless): | ||
| print(f"[MOCK] setProgress called with max={max_value}, current={current_value}, endless={endless}") | ||
| def setStyle(self, style): | ||
| print(f"[MOCK] setStyle called with style={style}") | ||
| def setContentTitle(self, title): | ||
| print(f"[MOCK] setContentTitle called with title={title}") | ||
| def setContentText(self, text): | ||
| print(f"[MOCK] setContentText called with text={text}") | ||
| def setSmallIcon(self, icon): | ||
@@ -217,0 +204,0 @@ print(f"[MOCK] setSmallIcon called with icon={icon}") |
@@ -7,8 +7,8 @@ """Collection of useful functions""" | ||
| from .config import ( | ||
| get_python_activity_context, app_storage_path, ON_ANDROID, | ||
| BitmapFactory, BuildVersion, Bundle, | ||
| NotificationManagerClass, AndroidNotification, Intent, Settings, Uri, String, Manifest | ||
| get_python_activity_context, app_storage_path,ON_ANDROID, | ||
| BitmapFactory, BuildVersion, Bundle, | ||
| NotificationManagerCompat,NotificationCompat, | ||
| Intent, Settings, Uri, String, Manifest | ||
| ) | ||
| ) | ||
| if ON_ANDROID: | ||
@@ -45,11 +45,11 @@ Color = autoclass('android.graphics.Color') | ||
| if importance == 'urgent': | ||
| value = AndroidNotification.PRIORITY_HIGH if BuildVersion.SDK_INT <= 25 else NotificationManagerClass.IMPORTANCE_HIGH | ||
| value = NotificationCompat.PRIORITY_HIGH if BuildVersion.SDK_INT <= 25 else NotificationManagerCompat.IMPORTANCE_HIGH | ||
| elif importance == 'high': | ||
| value = AndroidNotification.PRIORITY_DEFAULT if BuildVersion.SDK_INT <= 25 else NotificationManagerClass.IMPORTANCE_DEFAULT | ||
| value = NotificationCompat.PRIORITY_DEFAULT if BuildVersion.SDK_INT <= 25 else NotificationManagerCompat.IMPORTANCE_DEFAULT | ||
| elif importance == 'medium': | ||
| value = AndroidNotification.PRIORITY_LOW if BuildVersion.SDK_INT <= 25 else NotificationManagerClass.IMPORTANCE_LOW | ||
| value = NotificationCompat.PRIORITY_LOW if BuildVersion.SDK_INT <= 25 else NotificationManagerCompat.IMPORTANCE_LOW | ||
| elif importance == 'low': | ||
| value = AndroidNotification.PRIORITY_MIN if BuildVersion.SDK_INT <= 25 else NotificationManagerClass.IMPORTANCE_MIN | ||
| value = NotificationCompat.PRIORITY_MIN if BuildVersion.SDK_INT <= 25 else NotificationManagerCompat.IMPORTANCE_MIN | ||
| elif importance == 'none': | ||
| value = '' if BuildVersion.SDK_INT <= 25 else NotificationManagerClass.IMPORTANCE_NONE | ||
| value = '' if BuildVersion.SDK_INT <= 25 else NotificationManagerCompat.IMPORTANCE_NONE | ||
@@ -83,6 +83,6 @@ return value | ||
| if not os.path.exists(img_full_path): | ||
| print(f'\nImage: "{img_full_path}" Not Found, (Local images gotten from App Path)') | ||
| print(f'Image: "{img_full_path}" Not Found, (Local images gotten from App Path)') | ||
| try: | ||
| print("- These are the existing files in your app Folder:") | ||
| print('[' + ', '.join(os.listdir(app_folder)) + ']\n') | ||
| print('[' + ', '.join(os.listdir(app_folder)) + ']') | ||
| except Exception as could_not_get_files_in_path_error: | ||
@@ -89,0 +89,0 @@ print('Exception: ', could_not_get_files_in_path_error) |
+20
-12
| import os, traceback | ||
| ON_ANDROID = False | ||
| __version__ = "1.60.6.dev0" | ||
| __version__ = "1.60.6" | ||
| def is_platform_android(): | ||
@@ -54,6 +55,5 @@ if os.getenv("MAIN_ACTIVITY_HOST_CLASS_NAME"): | ||
| BuildVersion = autoclass('android.os.Build$VERSION') | ||
| NotificationManagerClass = autoclass('android.app.NotificationManager') | ||
| NotificationManager = autoclass('android.app.NotificationManager') | ||
| NotificationChannel = autoclass('android.app.NotificationChannel') | ||
| RemoteViews = autoclass('android.widget.RemoteViews') | ||
| AndroidNotification = autoclass("android.app.Notification") | ||
| Settings = autoclass("android.provider.Settings") | ||
@@ -75,13 +75,21 @@ Uri = autoclass("android.net.Uri") | ||
| try: | ||
| NotificationManagerCompat = autoclass('androidx.core.app.NotificationManagerCompat') | ||
| NotificationCompat = autoclass('androidx.core.app.NotificationCompat') | ||
| IconCompat = autoclass('androidx.core.graphics.drawable.IconCompat') | ||
| Color = autoclass('android.graphics.Color') | ||
| # Notification Design | ||
| NotificationCompatBuilder = autoclass('android.app.Notification$Builder') | ||
| NotificationCompatBigTextStyle = autoclass('android.app.Notification$BigTextStyle') | ||
| NotificationCompatBigPictureStyle = autoclass('android.app.Notification$BigPictureStyle') | ||
| NotificationCompatInboxStyle = autoclass('android.app.Notification$InboxStyle') | ||
| # NotificationCompatDecoratedCustomViewStyle = autoclass('androidx.core.app.NotificationCompat$DecoratedCustomViewStyle') | ||
| NotificationCompatBuilder = autoclass('androidx.core.app.NotificationCompat$Builder') | ||
| NotificationCompatBigTextStyle = autoclass('androidx.core.app.NotificationCompat$BigTextStyle') | ||
| NotificationCompatBigPictureStyle = autoclass('androidx.core.app.NotificationCompat$BigPictureStyle') | ||
| NotificationCompatInboxStyle = autoclass('androidx.core.app.NotificationCompat$InboxStyle') | ||
| NotificationCompatDecoratedCustomViewStyle = autoclass('androidx.core.app.NotificationCompat$DecoratedCustomViewStyle') | ||
| except Exception as styles_import_error: | ||
| print('styles_import_error: ', styles_import_error) | ||
| except Exception as dependencies_import_error: | ||
| print('dependencies_import_error: ', dependencies_import_error) | ||
| print(""" | ||
| Dependency Error: Add the following in buildozer.spec: | ||
| * android.gradle_dependencies = androidx.core:core-ktx:1.15.0, androidx.core:core:1.6.0 | ||
| * android.enable_androidx = True | ||
| """) | ||
@@ -154,3 +162,3 @@ from .an_types import * | ||
| notification_service = context.getSystemService(context.NOTIFICATION_SERVICE) | ||
| return cast(NotificationManagerClass, notification_service) | ||
| return cast(NotificationManager, notification_service) | ||
@@ -170,2 +178,2 @@ | ||
| def get_package_name(): | ||
| return context.getPackageName() # package.domain + "." + package.name | ||
| return context.getPackageName() # package.domain + "." + package.name |
+25
-20
@@ -24,3 +24,2 @@ """ Non-Advanced Stuff """ | ||
| BuildVersion = autoclass('android.os.Build$VERSION') | ||
| Notification = autoclass("android.app.Notification") | ||
| ON_ANDROID = True | ||
@@ -34,11 +33,16 @@ except Exception as e: | ||
| try: | ||
| NotificationManagerCompat = autoclass('android.app.NotificationManager') | ||
| NotificationManagerCompat = autoclass('androidx.core.app.NotificationManagerCompat') | ||
| NotificationCompat = autoclass('androidx.core.app.NotificationCompat') | ||
| # Notification Design | ||
| NotificationCompatBuilder = autoclass('android.app.Notification$Builder') | ||
| NotificationCompatBigTextStyle = autoclass('android.app.Notification$BigTextStyle') | ||
| NotificationCompatBigPictureStyle = autoclass('android.app.Notification$BigPictureStyle') | ||
| NotificationCompatInboxStyle = autoclass('android.app.Notification$InboxStyle') | ||
| NotificationCompatBuilder = autoclass('androidx.core.app.NotificationCompat$Builder') | ||
| NotificationCompatBigTextStyle = autoclass('androidx.core.app.NotificationCompat$BigTextStyle') | ||
| NotificationCompatBigPictureStyle = autoclass('androidx.core.app.NotificationCompat$BigPictureStyle') | ||
| NotificationCompatInboxStyle = autoclass('androidx.core.app.NotificationCompat$InboxStyle') | ||
| except Exception as e: | ||
| traceback.print_exc() | ||
| print("Error importing notification styles") | ||
| print("""\n | ||
| Dependency Error: Add the following in buildozer.spec: | ||
| * android.gradle_dependencies = androidx.core:core-ktx:1.15.0, androidx.core:core:1.6.0 | ||
| * android.enable_androidx = True\n | ||
| """) | ||
@@ -61,7 +65,5 @@ from .an_utils import can_show_permission_request_popup, open_settings_screen | ||
| def asks_permission_if_needed(legacy=False, no_androidx=False): | ||
| def asks_permission_if_needed(): | ||
| """ | ||
| Ask for permission to send notifications if needed. | ||
| legacy parameter will replace no_androidx parameter in Future Versions | ||
| """ | ||
@@ -84,10 +86,12 @@ if not ON_ANDROID: | ||
| if on_flet_app() or no_androidx or legacy: | ||
| Activity = autoclass("android.app.Activity") | ||
| PackageManager = autoclass("android.content.pm.PackageManager") | ||
| if on_flet_app(): | ||
| ContextCompat = autoclass('androidx.core.content.ContextCompat') | ||
| # if you get error `Failed to find class: androidx/core/app/ActivityCompat` | ||
| #in proguard-rules.pro add `-keep class androidx.core.app.ActivityCompat { *; }` | ||
| ActivityCompat = autoclass('androidx.core.app.ActivityCompat') | ||
| permission = Manifest.POST_NOTIFICATIONS | ||
| granted = context.checkSelfPermission(permission) | ||
| if granted != PackageManager.PERMISSION_GRANTED: | ||
| context.requestPermissions([permission], 101) | ||
| granted = ContextCompat.checkSelfPermission(context, permission) | ||
| if granted != 0: # PackageManager.PERMISSION_GRANTED == 0 | ||
| ActivityCompat.requestPermissions(context, [permission], 101) | ||
| else: # android package is from p4a which is for kivy | ||
@@ -170,3 +174,4 @@ try: | ||
| asks_permission_if_needed(legacy=True) | ||
| asks_permission_if_needed() | ||
| channel_id = channel_name.replace(' ', '_').lower().lower() if not channel_id else channel_id | ||
@@ -189,4 +194,4 @@ # Get notification manager | ||
| insert_app_icon(builder, custom_app_icon_path) | ||
| builder.setDefaults(Notification.DEFAULT_ALL) | ||
| builder.setPriority(Notification.PRIORITY_HIGH) | ||
| builder.setDefaults(NotificationCompat.DEFAULT_ALL) | ||
| builder.setPriority(NotificationCompat.PRIORITY_HIGH) | ||
@@ -193,0 +198,0 @@ if img_path: |
+20
-22
@@ -12,12 +12,13 @@ """This Module Contain Class for creating Notification With Java""" | ||
| from .config import from_service_file, get_python_activity, get_notification_manager, ON_ANDROID, on_flet_app, get_package_name | ||
| from .config import from_service_file, get_python_activity, get_notification_manager, ON_ANDROID, on_flet_app, \ | ||
| get_package_name | ||
| from .config import (Bundle, String, BuildVersion, | ||
| Intent, PendingIntent, | ||
| app_storage_path, | ||
| IconCompat, app_storage_path, | ||
| NotificationChannel, RemoteViews, | ||
| run_on_ui_thread, | ||
| ) | ||
| from .config import (AndroidNotification, NotificationCompatBuilder, | ||
| from .config import (NotificationCompat, NotificationCompatBuilder, | ||
| NotificationCompatBigTextStyle, NotificationCompatBigPictureStyle, | ||
| NotificationCompatInboxStyle, | ||
| NotificationCompatInboxStyle, NotificationCompatDecoratedCustomViewStyle, | ||
| Color, Manifest | ||
@@ -578,3 +579,3 @@ ) | ||
| context, self.__no_of_buttons or 1, action_intent__, | ||
| PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE | ||
| PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE | ||
| ) | ||
@@ -590,3 +591,3 @@ return pending_action_intent__ | ||
| context, self.__no_of_buttons or 1, action_intent, | ||
| PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE | ||
| PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE | ||
| ) | ||
@@ -601,3 +602,2 @@ | ||
| self.__builder.addAction(int(context.getApplicationInfo().icon), action_text, pending_action_intent) | ||
@@ -610,2 +610,3 @@ self.__builder.setContentIntent(pending_action_intent) # Set content intent for notification tap | ||
| if self.logs: | ||
@@ -741,3 +742,3 @@ print('Added Button: ', text) | ||
| self.__insert_app_icon() | ||
| self.__builder.setDefaults(AndroidNotification.DEFAULT_ALL) | ||
| self.__builder.setDefaults(NotificationCompat.DEFAULT_ALL) | ||
| self.__builder.setOnlyAlertOnce(True) | ||
@@ -827,4 +828,3 @@ self.__builder.setOngoing(persistent) | ||
| else: | ||
| bitmap = get_img_from_path( | ||
| img_path) # get_img_from_path is different from get_bitmap_from_path because it those some logging for user | ||
| bitmap = get_img_from_path(img_path) # get_img_from_path is different from get_bitmap_from_path because it those some logging for user | ||
| if bitmap: | ||
@@ -930,4 +930,2 @@ self.__set_builder_icon_with_bitmap(bitmap) | ||
| def __apply_basic_custom_style(self): | ||
| NotificationCompatDecoratedCustomViewStyle = autoclass( | ||
| 'androidx.core.app.NotificationCompat$DecoratedCustomViewStyle') | ||
@@ -1030,3 +1028,3 @@ # Load layout | ||
| if DEV: | ||
| print("notify_functions ", notifty_functions) | ||
| print("notifty_functions ", notifty_functions) | ||
| print("buttons_object", buttons_object) | ||
@@ -1108,13 +1106,12 @@ try: | ||
| if BuildVersion.SDK_INT < 33: # Android 12 below | ||
| print("android_notify- On android 12 or less don't need permission") | ||
| return True | ||
| if on_flet_app(): | ||
| ContextCompat = autoclass('androidx.core.content.ContextCompat') | ||
| Manifest = autoclass('android.Manifest$permission') | ||
| VERSION_CODES = autoclass('android.os.Build$VERSION_CODES') | ||
| PackageManager = autoclass("android.content.pm.PackageManager") | ||
| permission = Manifest.POST_NOTIFICATIONS | ||
| return PackageManager.PERMISSION_GRANTED == context.checkSelfPermission(permission) | ||
| return ContextCompat.checkSelfPermission(context, permission) | ||
| else: | ||
| from android.permissions import Permission, check_permission # type: ignore | ||
| from android.permissions import Permission, check_permission | ||
| return check_permission(Permission.POST_NOTIFICATIONS) | ||
@@ -1140,3 +1137,3 @@ | ||
| if not ON_ANDROID or BuildVersion.SDK_INT < 33: # Android 12 below: | ||
| if not ON_ANDROID or BuildVersion.SDK_INT < 33: # Android 12 below | ||
| try: | ||
@@ -1176,8 +1173,9 @@ if callback: | ||
| if on_flet_app(): | ||
| Manifest = autoclass('android.Manifest$permission') | ||
| ActivityCompat = autoclass('androidx.core.app.ActivityCompat') | ||
| permission = Manifest.POST_NOTIFICATIONS | ||
| context.requestPermissions([permission], 101) | ||
| ActivityCompat.requestPermissions(context, [permission], 101) | ||
| return None | ||
| # TODO Callback when user answers request question | ||
| else: | ||
| from android.permissions import request_permissions, Permission # type: ignore | ||
| from android.permissions import request_permissions, Permission | ||
| cls.__requesting_permission = True | ||
@@ -1184,0 +1182,0 @@ request_permissions([Permission.POST_NOTIFICATIONS], on_permissions_result) |
+98
-19
| Metadata-Version: 2.4 | ||
| Name: android-notify | ||
| Version: 1.60.6.dev0 | ||
| Version: 1.60.6 | ||
| Summary: A Python package that simplifies creating Android notifications in Kivy and Flet apps. | ||
@@ -76,3 +76,5 @@ Author-email: Fabian <fector101@yahoo.com> | ||
| ### Kivy apps: | ||
| <details> | ||
| <summary><b>Kivy apps:</b></summary> | ||
| <br/> | ||
@@ -83,11 +85,22 @@ In your **`buildozer.spec`** file, ensure you include the following: | ||
| # Add pyjnius so ensure it's packaged with the build | ||
| requirements = python3, kivy, pyjnius, android-notify>=1.60.6.dev0 | ||
| requirements = python3, kivy, pyjnius, android-notify | ||
| # Add permission for notifications | ||
| android.permissions = POST_NOTIFICATIONS | ||
| # Required dependencies (write exactly as shown, no quotation marks) | ||
| android.gradle_dependencies = androidx.core:core:1.6.0, androidx.core:core-ktx:1.15.0 | ||
| android.enable_androidx = True | ||
| android.api = 35 | ||
| ``` | ||
| ### Flet apps: | ||
| </details> | ||
| In your `pyproject.toml` file, ensure you include the following: | ||
| <details> | ||
| <summary><b>Flet apps:</b></summary> | ||
| <br/> | ||
| In your `pyproject.toml` file, ensure you include the following: | ||
| ```toml | ||
@@ -102,11 +115,13 @@ [tool.flet.android] | ||
| ``` | ||
| - example of [complete flet pyproject.toml](https://github.com/Fector101/flet-app/blob/main/pyproject.toml) | ||
| ### Pydroid 3 | ||
| In the [pydroid 3](https://play.google.com/store/apps/details?id=ru.iiec.pydroid3) mobile app for running python code you can test some features. | ||
| - In pip section where you're asked to insert `Libary name` paste `android-notify>=1.60.6.dev0` | ||
| </details> | ||
| <details> | ||
| ### Testing | ||
| Can be installed via `pip` For testing purposes: | ||
| <summary><b>Desktop</b></summary> | ||
| <br/> | ||
| For IDE IntelliSense Can be installed via `pip install`: | ||
| ```bash | ||
@@ -117,5 +132,73 @@ pip install android_notify | ||
| </details> | ||
| ------ | ||
| ## Installing without Androidx | ||
| How to use without `gradle_dependencies` | ||
| Use `android-notify>=1.60.6.dev0` to install via `pip` | ||
| <details> | ||
| <summary><b>In Kivy</b></summary> | ||
| <br/> | ||
| ```ini | ||
| # buildozer.spec | ||
| requirements = python3, kivy, pyjnius, android-notify>=1.60.6.dev0 | ||
| ``` | ||
| </details> | ||
| <details> | ||
| <summary><b>On Pydroid 3</b></summary> | ||
| <br/> | ||
| On the [pydroid 3](https://play.google.com/store/apps/details?id=ru.iiec.pydroid3) mobile app for running python code you can test some features. | ||
| - In pip section where you're asked to insert `Libary name` paste `android-notify>=1.60.6.dev0` | ||
| - Minimal working example | ||
| ```py | ||
| # Testing with `android-notify>=1.60.6.dev0` on pydroid | ||
| from kivy.app import App | ||
| from kivy.uix.boxlayout import BoxLayout | ||
| from kivy.uix.button import Button | ||
| from android_notify import Notification | ||
| from android_notify.core import asks_permission_if_needed | ||
| class AndroidNotifyDemoApp(App): | ||
| def build(self): | ||
| layout = BoxLayout(orientation='vertical', spacing=10, padding=20) | ||
| layout.add_widget(Button( | ||
| text="Ask Notification Permission", | ||
| on_release=self.request_permission | ||
| )) | ||
| layout.add_widget(Button( | ||
| text="Send Notification", | ||
| on_release=self.send_notification | ||
| )) | ||
| return layout | ||
| def request_permission(self, *args): | ||
| asks_permission_if_needed(no_androidx=True) | ||
| def send_notification(self, *args): | ||
| Notification( | ||
| title="Hello from Android Notify", | ||
| message="This is a basic notification.", | ||
| channel_id="android_notify_demo", | ||
| channel_name="Android Notify Demo" | ||
| ).send() | ||
| if __name__ == "__main__": | ||
| AndroidNotifyDemoApp().run() | ||
| ``` | ||
| </details> | ||
| ## Documentation | ||
| For Dev Version use | ||
| ```requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_notify/archive/without-androidx.zip``` | ||
| ```requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_notify/archive/main.zip``` | ||
@@ -137,6 +220,5 @@ ### To talk to BroadCast Listener From Buttons | ||
| - Copy the [res](https://github.com/Fector101/android_notify/tree/main/android_notify/res) folder to your app path. | ||
| Lastly in your `buildozer.spec` file | ||
| - Add `source.include_exts = xml` and `android.add_resources = ./res` | ||
| - Lastly in your `buildozer.spec` file | ||
| Add `source.include_exts = xml` and `android.add_resources = # path you pasted` | ||
| ### To use Custom Sounds | ||
@@ -172,6 +254,3 @@ | ||
| If you find this project helpful, consider buying me a coffee! š Or Giving it a star on š [GitHub](https://github.com/Fector101/android_notify/) Your support helps maintain and improve the project. | ||
| <a href="https://www.buymeacoffee.com/fector101" target="_blank"> | ||
| <img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60"> | ||
| </a> | ||
| If you find this project helpful, any support would help me continue working on open-source projects. Iām currently saving for a laptop to keep developing. | ||
| [donate](https://www.buymeacoffee.com/fector101) |
+1
-4
@@ -7,3 +7,3 @@ [build-system] | ||
| name = "android-notify" | ||
| version = "1.60.6.dev0" | ||
| version = "1.60.6" | ||
| description = "A Python package that simplifies creating Android notifications in Kivy and Flet apps." | ||
@@ -54,5 +54,2 @@ readme = { file = "README.md", content-type = "text/markdown" } | ||
| [tool.setuptools.package-data] | ||
| "android_notify" = ["fallback-icons/*.png"] | ||
| [project.scripts] | ||
@@ -59,0 +56,0 @@ android-notify = "android_notify.__main__:main" |
+97
-18
@@ -53,3 +53,5 @@ <div align="center"> | ||
| ### Kivy apps: | ||
| <details> | ||
| <summary><b>Kivy apps:</b></summary> | ||
| <br/> | ||
@@ -60,11 +62,22 @@ In your **`buildozer.spec`** file, ensure you include the following: | ||
| # Add pyjnius so ensure it's packaged with the build | ||
| requirements = python3, kivy, pyjnius, android-notify>=1.60.6.dev0 | ||
| requirements = python3, kivy, pyjnius, android-notify | ||
| # Add permission for notifications | ||
| android.permissions = POST_NOTIFICATIONS | ||
| # Required dependencies (write exactly as shown, no quotation marks) | ||
| android.gradle_dependencies = androidx.core:core:1.6.0, androidx.core:core-ktx:1.15.0 | ||
| android.enable_androidx = True | ||
| android.api = 35 | ||
| ``` | ||
| ### Flet apps: | ||
| </details> | ||
| In your `pyproject.toml` file, ensure you include the following: | ||
| <details> | ||
| <summary><b>Flet apps:</b></summary> | ||
| <br/> | ||
| In your `pyproject.toml` file, ensure you include the following: | ||
| ```toml | ||
@@ -79,11 +92,13 @@ [tool.flet.android] | ||
| ``` | ||
| - example of [complete flet pyproject.toml](https://github.com/Fector101/flet-app/blob/main/pyproject.toml) | ||
| ### Pydroid 3 | ||
| In the [pydroid 3](https://play.google.com/store/apps/details?id=ru.iiec.pydroid3) mobile app for running python code you can test some features. | ||
| - In pip section where you're asked to insert `Libary name` paste `android-notify>=1.60.6.dev0` | ||
| </details> | ||
| <details> | ||
| ### Testing | ||
| Can be installed via `pip` For testing purposes: | ||
| <summary><b>Desktop</b></summary> | ||
| <br/> | ||
| For IDE IntelliSense Can be installed via `pip install`: | ||
| ```bash | ||
@@ -94,5 +109,73 @@ pip install android_notify | ||
| </details> | ||
| ------ | ||
| ## Installing without Androidx | ||
| How to use without `gradle_dependencies` | ||
| Use `android-notify>=1.60.6.dev0` to install via `pip` | ||
| <details> | ||
| <summary><b>In Kivy</b></summary> | ||
| <br/> | ||
| ```ini | ||
| # buildozer.spec | ||
| requirements = python3, kivy, pyjnius, android-notify>=1.60.6.dev0 | ||
| ``` | ||
| </details> | ||
| <details> | ||
| <summary><b>On Pydroid 3</b></summary> | ||
| <br/> | ||
| On the [pydroid 3](https://play.google.com/store/apps/details?id=ru.iiec.pydroid3) mobile app for running python code you can test some features. | ||
| - In pip section where you're asked to insert `Libary name` paste `android-notify>=1.60.6.dev0` | ||
| - Minimal working example | ||
| ```py | ||
| # Testing with `android-notify>=1.60.6.dev0` on pydroid | ||
| from kivy.app import App | ||
| from kivy.uix.boxlayout import BoxLayout | ||
| from kivy.uix.button import Button | ||
| from android_notify import Notification | ||
| from android_notify.core import asks_permission_if_needed | ||
| class AndroidNotifyDemoApp(App): | ||
| def build(self): | ||
| layout = BoxLayout(orientation='vertical', spacing=10, padding=20) | ||
| layout.add_widget(Button( | ||
| text="Ask Notification Permission", | ||
| on_release=self.request_permission | ||
| )) | ||
| layout.add_widget(Button( | ||
| text="Send Notification", | ||
| on_release=self.send_notification | ||
| )) | ||
| return layout | ||
| def request_permission(self, *args): | ||
| asks_permission_if_needed(no_androidx=True) | ||
| def send_notification(self, *args): | ||
| Notification( | ||
| title="Hello from Android Notify", | ||
| message="This is a basic notification.", | ||
| channel_id="android_notify_demo", | ||
| channel_name="Android Notify Demo" | ||
| ).send() | ||
| if __name__ == "__main__": | ||
| AndroidNotifyDemoApp().run() | ||
| ``` | ||
| </details> | ||
| ## Documentation | ||
| For Dev Version use | ||
| ```requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_notify/archive/without-androidx.zip``` | ||
| ```requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_notify/archive/main.zip``` | ||
@@ -114,6 +197,5 @@ ### To talk to BroadCast Listener From Buttons | ||
| - Copy the [res](https://github.com/Fector101/android_notify/tree/main/android_notify/res) folder to your app path. | ||
| Lastly in your `buildozer.spec` file | ||
| - Add `source.include_exts = xml` and `android.add_resources = ./res` | ||
| - Lastly in your `buildozer.spec` file | ||
| Add `source.include_exts = xml` and `android.add_resources = # path you pasted` | ||
| ### To use Custom Sounds | ||
@@ -149,6 +231,3 @@ | ||
| If you find this project helpful, consider buying me a coffee! š Or Giving it a star on š [GitHub](https://github.com/Fector101/android_notify/) Your support helps maintain and improve the project. | ||
| <a href="https://www.buymeacoffee.com/fector101" target="_blank"> | ||
| <img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60"> | ||
| </a> | ||
| If you find this project helpful, any support would help me continue working on open-source projects. Iām currently saving for a laptop to keep developing. | ||
| [donate](https://www.buymeacoffee.com/fector101) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
2670
0.07%149937
-21.24%27
-6.9%