android-notify 1.1__py3-none-any.whl → 1.21__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/__init__.py +2 -0
- android_notify/core.py +70 -106
- android_notify-1.21.dist-info/METADATA +251 -0
- android_notify-1.21.dist-info/RECORD +8 -0
- {android_notify-1.1.dist-info → android_notify-1.21.dist-info}/WHEEL +1 -1
- android_notify-1.1.dist-info/METADATA +0 -140
- android_notify-1.1.dist-info/RECORD +0 -8
- {android_notify-1.1.dist-info → android_notify-1.21.dist-info}/top_level.txt +0 -0
android_notify/__init__.py
CHANGED
android_notify/core.py
CHANGED
|
@@ -3,22 +3,48 @@ from jnius import autoclass,cast
|
|
|
3
3
|
import random
|
|
4
4
|
import os
|
|
5
5
|
|
|
6
|
+
ON_ANDROID = False
|
|
7
|
+
try:
|
|
8
|
+
# Get the required Java classes
|
|
9
|
+
PythonActivity = autoclass('org.kivy.android.PythonActivity')
|
|
10
|
+
NotificationChannel = autoclass('android.app.NotificationChannel')
|
|
11
|
+
String = autoclass('java.lang.String')
|
|
12
|
+
Intent = autoclass('android.content.Intent')
|
|
13
|
+
PendingIntent = autoclass('android.app.PendingIntent')
|
|
14
|
+
context = PythonActivity.mActivity # Get the app's context
|
|
15
|
+
BitmapFactory = autoclass('android.graphics.BitmapFactory')
|
|
16
|
+
BuildVersion = autoclass('android.os.Build$VERSION')
|
|
17
|
+
ON_ANDROID=True
|
|
18
|
+
except Exception as e:
|
|
19
|
+
print('This Package Only Runs on Android !!! ---> Check "https://github.com/Fector101/android_notify/" to see design patterns and more info.')
|
|
20
|
+
|
|
21
|
+
if ON_ANDROID:
|
|
22
|
+
try:
|
|
23
|
+
NotificationManagerCompat = autoclass('androidx.core.app.NotificationManagerCompat')
|
|
24
|
+
NotificationCompat = autoclass('androidx.core.app.NotificationCompat')
|
|
25
|
+
|
|
26
|
+
# Notification Design
|
|
27
|
+
NotificationCompatBuilder = autoclass('androidx.core.app.NotificationCompat$Builder')
|
|
28
|
+
NotificationCompatBigTextStyle = autoclass('androidx.core.app.NotificationCompat$BigTextStyle')
|
|
29
|
+
# NotificationCompatBigTextStyle = autoclass('android.app.Notification$BigTextStyle')
|
|
30
|
+
NotificationCompatBigPictureStyle = autoclass('androidx.core.app.NotificationCompat$BigPictureStyle')
|
|
31
|
+
NotificationCompatInboxStyle = autoclass('androidx.core.app.NotificationCompat$InboxStyle')
|
|
32
|
+
except Exception as e:
|
|
33
|
+
print("""
|
|
34
|
+
Dependency Error: Add the following in buildozer.spec:
|
|
35
|
+
* android.gradle_dependencies = androidx.core:core-ktx:1.15.0, androidx.core:core:1.6.0
|
|
36
|
+
* android.enable_androidx = True
|
|
37
|
+
* android.permissions = POST_NOTIFICATIONS
|
|
38
|
+
""")
|
|
6
39
|
|
|
7
40
|
def asks_permission_if_needed():
|
|
8
41
|
"""
|
|
9
42
|
Ask for permission to send notifications if needed.
|
|
10
43
|
"""
|
|
11
|
-
# Get the required Java classes
|
|
12
44
|
from android.permissions import request_permissions, Permission,check_permission # type: ignore
|
|
13
|
-
|
|
14
|
-
def check_permissions(permissions):
|
|
15
|
-
for permission in permissions:
|
|
16
|
-
if check_permission(permission) != True:
|
|
17
|
-
return False
|
|
18
|
-
return True
|
|
19
45
|
|
|
20
46
|
permissions=[Permission.POST_NOTIFICATIONS]
|
|
21
|
-
if
|
|
47
|
+
if not all(check_permission(p) for p in permissions):
|
|
22
48
|
request_permissions(permissions)
|
|
23
49
|
|
|
24
50
|
def get_image_uri(relative_path):
|
|
@@ -28,62 +54,40 @@ def get_image_uri(relative_path):
|
|
|
28
54
|
:return: Absolute URI java Object (e.g., 'file:///path/to/file.png').
|
|
29
55
|
"""
|
|
30
56
|
from android.storage import app_storage_path # type: ignore
|
|
31
|
-
# print("app_storage_path()",app_storage_path())
|
|
32
57
|
|
|
33
58
|
output_path = os.path.join(app_storage_path(),'app', relative_path)
|
|
34
59
|
# print(output_path,'output_path') # /data/user/0/org.laner.lan_ft/files/app/assets/imgs/icon.png
|
|
35
|
-
|
|
60
|
+
|
|
61
|
+
if not os.path.exists(output_path):
|
|
62
|
+
raise FileNotFoundError(f"Image not found at path: {output_path}")
|
|
63
|
+
|
|
36
64
|
Uri = autoclass('android.net.Uri')
|
|
37
65
|
return Uri.parse(f"file://{output_path}")
|
|
38
66
|
|
|
39
|
-
|
|
67
|
+
|
|
68
|
+
def send_notification(title:str, message:str, style=None, img_path=None, channel_id:str="default_channel"):
|
|
40
69
|
"""
|
|
41
70
|
Send a notification on Android.
|
|
42
71
|
|
|
43
72
|
:param title: Title of the notification.
|
|
44
73
|
:param message: Message body.
|
|
45
|
-
:param style: Style of the notification ('big_text', 'big_picture', 'inbox').
|
|
46
|
-
:param
|
|
74
|
+
:param style: Style of the notification ('big_text', 'big_picture', 'inbox', 'large_icon').
|
|
75
|
+
:param img_path: Path to the image resource.
|
|
47
76
|
:param channel_id: Notification channel ID.
|
|
48
77
|
"""
|
|
49
|
-
|
|
78
|
+
if not ON_ANDROID:
|
|
79
|
+
print('This Package Only Runs on Android !!! ---> Check "https://github.com/Fector101/android_notify/" for Documentation.')
|
|
80
|
+
return
|
|
50
81
|
|
|
51
|
-
# Get
|
|
52
|
-
# Notification Base
|
|
53
|
-
PythonActivity = autoclass('org.kivy.android.PythonActivity')
|
|
54
|
-
NotificationChannel = autoclass('android.app.NotificationChannel')
|
|
55
|
-
String = autoclass('java.lang.String')
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
NotificationManagerCompat = autoclass('androidx.core.app.NotificationManagerCompat')
|
|
59
|
-
NotificationCompat = autoclass('androidx.core.app.NotificationCompat')
|
|
60
|
-
|
|
61
|
-
# Notification Design
|
|
62
|
-
NotificationCompatBuilder = autoclass('androidx.core.app.NotificationCompat$Builder')
|
|
63
|
-
NotificationCompatBigTextStyle = autoclass('androidx.core.app.NotificationCompat$BigTextStyle')
|
|
64
|
-
# NotificationCompatBigTextStyle = autoclass('android.app.Notification$BigTextStyle')
|
|
65
|
-
|
|
66
|
-
NotificationCompatBigPictureStyle = autoclass('androidx.core.app.NotificationCompat$BigPictureStyle')
|
|
67
|
-
NotificationCompatInboxStyle = autoclass('androidx.core.app.NotificationCompat$InboxStyle')
|
|
68
|
-
BitmapFactory = autoclass('android.graphics.BitmapFactory')
|
|
69
|
-
BuildVersion = autoclass('android.os.Build$VERSION')
|
|
70
|
-
PendingIntent = autoclass('android.app.PendingIntent')
|
|
71
|
-
Intent = autoclass('android.content.Intent')
|
|
72
|
-
|
|
73
|
-
# Get the app's context and notification manager
|
|
74
|
-
context = PythonActivity.mActivity
|
|
82
|
+
# Get notification manager
|
|
75
83
|
notification_manager = context.getSystemService(context.NOTIFICATION_SERVICE)
|
|
76
84
|
|
|
85
|
+
# importance= autoclass('android.app.NotificationManager').IMPORTANCE_HIGH # also works #NotificationManager.IMPORTANCE_DEFAULT
|
|
77
86
|
importance= NotificationManagerCompat.IMPORTANCE_HIGH #autoclass('android.app.NotificationManager').IMPORTANCE_HIGH also works #NotificationManager.IMPORTANCE_DEFAULT
|
|
78
87
|
|
|
79
88
|
# Notification Channel (Required for Android 8.0+)
|
|
80
89
|
if BuildVersion.SDK_INT >= 26:
|
|
81
|
-
|
|
82
|
-
channel = NotificationChannel(
|
|
83
|
-
channel_id,
|
|
84
|
-
"Default Channel",
|
|
85
|
-
importance
|
|
86
|
-
)
|
|
90
|
+
channel = NotificationChannel(channel_id, "Default Channel",importance)
|
|
87
91
|
notification_manager.createNotificationChannel(channel)
|
|
88
92
|
|
|
89
93
|
# Build the notification
|
|
@@ -94,75 +98,35 @@ def send_notification(title, message, style=None, img_path=None, channel_id="def
|
|
|
94
98
|
builder.setDefaults(NotificationCompat.DEFAULT_ALL)
|
|
95
99
|
builder.setPriority(NotificationCompat.PRIORITY_HIGH)
|
|
96
100
|
|
|
97
|
-
|
|
98
|
-
img=img_path
|
|
101
|
+
img=None
|
|
99
102
|
if img_path:
|
|
100
103
|
try:
|
|
101
104
|
img = get_image_uri(img_path)
|
|
102
|
-
except
|
|
103
|
-
print('Failed
|
|
104
|
-
|
|
105
|
-
# Add Actions (Buttons)
|
|
106
|
-
|
|
107
|
-
# add Action 1 Button
|
|
108
|
-
# try:
|
|
109
|
-
# # Create Action 1
|
|
110
|
-
# action_intent = Intent(context, PythonActivity)
|
|
111
|
-
# action_intent.setAction("ACTION_ONE")
|
|
112
|
-
# pending_action_intent = PendingIntent.getActivity(
|
|
113
|
-
# context,
|
|
114
|
-
# 0,
|
|
115
|
-
# action_intent,
|
|
116
|
-
# PendingIntent.FLAG_IMMUTABLE
|
|
117
|
-
# )
|
|
118
|
-
|
|
119
|
-
# # Convert text to CharSequence
|
|
120
|
-
# action_text = cast('java.lang.CharSequence', String("Action 1"))
|
|
121
|
-
|
|
122
|
-
# # Add action with proper types
|
|
123
|
-
# builder.addAction(
|
|
124
|
-
# int(context.getApplicationInfo().icon), # Cast icon to int
|
|
125
|
-
# action_text, # CharSequence text
|
|
126
|
-
# pending_action_intent # PendingIntent
|
|
127
|
-
# )
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
# # Set content intent for notification tap
|
|
131
|
-
# builder.setContentIntent(pending_action_intent)
|
|
132
|
-
# except Exception as e:
|
|
133
|
-
# print('Failed adding Action 1',e)
|
|
134
|
-
|
|
105
|
+
except FileNotFoundError as e:
|
|
106
|
+
print('Failed Adding Bitmap: ',e)
|
|
135
107
|
|
|
136
|
-
# Apply styles
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
elif style == "big_picture" and img_path:
|
|
144
|
-
try:
|
|
108
|
+
# Apply notification styles
|
|
109
|
+
try:
|
|
110
|
+
if style == "big_text":
|
|
111
|
+
big_text_style = NotificationCompatBigTextStyle()
|
|
112
|
+
big_text_style.bigText(message)
|
|
113
|
+
builder.setStyle(big_text_style)
|
|
114
|
+
elif style == "big_picture" and img_path:
|
|
145
115
|
bitmap = BitmapFactory.decodeStream(context.getContentResolver().openInputStream(img))
|
|
146
|
-
# bitmap = BitmapFactory.decodeFile(img_path)
|
|
147
116
|
builder.setLargeIcon(bitmap)
|
|
148
117
|
big_picture_style = NotificationCompatBigPictureStyle().bigPicture(bitmap)
|
|
149
|
-
# big_picture_style.bigPicture(bitmap).bigLargeIcon(None)
|
|
150
|
-
# big_picture_style.bigLargeIcon(bitmap) # This just changes dropdown app icon
|
|
151
|
-
|
|
152
118
|
builder.setStyle(big_picture_style)
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
builder.setStyle(inbox_style)
|
|
160
|
-
elif style == "large_icon" and img_path:
|
|
161
|
-
try:
|
|
119
|
+
elif style == "inbox":
|
|
120
|
+
inbox_style = NotificationCompatInboxStyle()
|
|
121
|
+
for line in message.split("\n"):
|
|
122
|
+
inbox_style.addLine(line)
|
|
123
|
+
builder.setStyle(inbox_style)
|
|
124
|
+
elif style == "large_icon" and img_path:
|
|
162
125
|
bitmap = BitmapFactory.decodeStream(context.getContentResolver().openInputStream(img))
|
|
163
126
|
builder.setLargeIcon(bitmap)
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
notification_manager.notify(
|
|
127
|
+
except Exception as e:
|
|
128
|
+
print('Failed Adding Style: ',e)
|
|
129
|
+
# Display the notification
|
|
130
|
+
notification_id = random.randint(0, 100)
|
|
131
|
+
notification_manager.notify(notification_id, builder.build())
|
|
132
|
+
return notification_id
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: android_notify
|
|
3
|
+
Version: 1.21
|
|
4
|
+
Summary: A Python package for sending Android notifications.
|
|
5
|
+
Home-page: https://github.com/Fector101/android_notify/
|
|
6
|
+
Author: Fabian
|
|
7
|
+
Author-email: fabianjoseph063@gmail.com
|
|
8
|
+
Project-URL: Funding, https://buymeacoffee.com/fector101
|
|
9
|
+
Project-URL: Source, https://github.com/Fector101/android_notify/
|
|
10
|
+
Requires-Python: >=3.6
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: pyjnius
|
|
13
|
+
|
|
14
|
+
# Android Notify
|
|
15
|
+
|
|
16
|
+
`android_notify` is a Python module designed to simplify sending Android notifications using Kivy and Pyjnius. It supports multiple notification styles, including text, images, and inbox layouts.
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- Send Android notifications with custom titles and messages.
|
|
21
|
+
- Support for multiple notification styles:
|
|
22
|
+
- Big Text
|
|
23
|
+
- Big Picture
|
|
24
|
+
- Large Icon
|
|
25
|
+
- Inbox
|
|
26
|
+
- Supports including images in notifications.
|
|
27
|
+
- Compatible with Android 8.0+ (Notification Channels).
|
|
28
|
+
- Customizable notification channels.
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
This package is available on PyPI and can be installed via pip:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install android-notify
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## **Dependencies**
|
|
39
|
+
|
|
40
|
+
**Prerequisites:**
|
|
41
|
+
|
|
42
|
+
- Buildozer
|
|
43
|
+
- Kivy
|
|
44
|
+
|
|
45
|
+
In your **`buildozer.spec`** file, ensure you include the following:
|
|
46
|
+
|
|
47
|
+
```ini
|
|
48
|
+
# Add pyjnius so it's packaged with the build
|
|
49
|
+
requirements = python3,kivy,pyjnius
|
|
50
|
+
|
|
51
|
+
# Add permission for notifications
|
|
52
|
+
android.permissions = POST_NOTIFICATIONS
|
|
53
|
+
|
|
54
|
+
# Required dependencies (write exactly as shown, no quotation marks)
|
|
55
|
+
android.gradle_dependencies = androidx.core:core:1.6.0, androidx.core:core-ktx:1.15.0
|
|
56
|
+
android.enable_androidx = True
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
### Example Notification
|
|
62
|
+
|
|
63
|
+
#### Basic Notification
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from android_notify import send_notification
|
|
67
|
+
|
|
68
|
+
# Send a basic notification
|
|
69
|
+
send_notification("Hello", "This is a basic notification.")
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Example Image:**
|
|
73
|
+

|
|
74
|
+
|
|
75
|
+
#### Notification with an Image (Big Picture Style)
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
# Send a notification with an image
|
|
79
|
+
send_notification(
|
|
80
|
+
title='Picture Alert!',
|
|
81
|
+
message='This notification includes an image.',
|
|
82
|
+
style='big_picture',
|
|
83
|
+
img_path='assets/imgs/icon.png'
|
|
84
|
+
)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Example Image:**
|
|
88
|
+

|
|
89
|
+
|
|
90
|
+
#### Inbox Notification Style
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
# Send a notification with inbox style
|
|
94
|
+
send_notification(
|
|
95
|
+
title='Inbox Notification',
|
|
96
|
+
message='Line 1\nLine 2\nLine 3',
|
|
97
|
+
style='inbox'
|
|
98
|
+
)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Example Image:**
|
|
102
|
+

|
|
103
|
+
|
|
104
|
+
#### Big Text Notification
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
# Send a Big Text notification
|
|
108
|
+
send_notification(
|
|
109
|
+
title='Hello!',
|
|
110
|
+
message='This is a sample notification.',
|
|
111
|
+
style='big_text'
|
|
112
|
+
)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Example Image:**
|
|
116
|
+

|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
### **Assist**
|
|
121
|
+
|
|
122
|
+
- How to Copy image to app folder
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
import shutil,os # These module comes packaged with python
|
|
126
|
+
from android.storage import app_storage_path # type: ignore -- This works only on android
|
|
127
|
+
|
|
128
|
+
app_path = os.path.join(app_storage_path(),'app')
|
|
129
|
+
image_path= "/storage/emulated/0/Download/profile.png"
|
|
130
|
+
|
|
131
|
+
shutil.copy(image_path, os.path.join(app_path, "profile.png"))
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
- Avoiding Human Error when using different notification styles
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
from android_notify import NotificationStyles
|
|
138
|
+
send_notification(
|
|
139
|
+
title='Picture Alert!',
|
|
140
|
+
message='This notification includes an image.',
|
|
141
|
+
img_path='assets/imgs/icon.png'
|
|
142
|
+
style=NotificationStyles.BIG_PICTURE,
|
|
143
|
+
)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
### **Functions Reference**
|
|
149
|
+
|
|
150
|
+
### 1. `asks_permission_if_needed()`
|
|
151
|
+
|
|
152
|
+
**Description:**
|
|
153
|
+
|
|
154
|
+
- Checks if notification permissions are granted and requests them if missing.
|
|
155
|
+
|
|
156
|
+
**Usage:**
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
asks_permission_if_needed()
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
### 2. `get_image_uri(relative_path)`
|
|
165
|
+
|
|
166
|
+
**Description:**
|
|
167
|
+
|
|
168
|
+
- Resolves the absolute URI for an image in the app's storage.
|
|
169
|
+
|
|
170
|
+
**Parameters:**
|
|
171
|
+
|
|
172
|
+
- `relative_path` *(str)*: Path to the image (e.g., `assets/imgs/icon.png`).
|
|
173
|
+
|
|
174
|
+
**Returns:**
|
|
175
|
+
|
|
176
|
+
- `Uri`: Android URI object for the image.
|
|
177
|
+
|
|
178
|
+
**Usage:**
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
uri = get_image_uri('assets/imgs/icon.png')
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
### 3. `send_notification(title, message, style=None, img_path=None, channel_id='default_channel')`
|
|
187
|
+
|
|
188
|
+
**Description:**
|
|
189
|
+
|
|
190
|
+
- Sends an Android notification with optional styles and images.
|
|
191
|
+
|
|
192
|
+
**Parameters:**
|
|
193
|
+
|
|
194
|
+
- `title` *(str)*: Notification title.
|
|
195
|
+
- `message` *(str)*: Notification message.
|
|
196
|
+
- `style` *(str, optional)*: Notification style (`big_text`, `big_picture`, `inbox`, `large_icon`).
|
|
197
|
+
- `img_path` *(str, optional)*: Path to the image resource.(for `big_picture` or `large_icon` styles).
|
|
198
|
+
- `channel_id` *(str, optional)*: Notification channel ID.
|
|
199
|
+
|
|
200
|
+
Returns - notification id
|
|
201
|
+
|
|
202
|
+
### Advanced Usage
|
|
203
|
+
|
|
204
|
+
You can customize notification channels for different types of notifications.
|
|
205
|
+
|
|
206
|
+
```python
|
|
207
|
+
send_notification(
|
|
208
|
+
title='Custom Channel Notification',
|
|
209
|
+
message='This uses a custom notification channel.',
|
|
210
|
+
channel_id='custom_channel'
|
|
211
|
+
)
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Contribution
|
|
215
|
+
|
|
216
|
+
Feel free to open issues or submit pull requests for improvements!
|
|
217
|
+
|
|
218
|
+
## 🐛 Reporting Issues
|
|
219
|
+
|
|
220
|
+
Found a bug? Please open an issue on our [GitHub Issues](https://github.com/Fector101/android_notify/issues) page.
|
|
221
|
+
|
|
222
|
+
## Author
|
|
223
|
+
|
|
224
|
+
- Fabian - <fector101@yahoo.com>
|
|
225
|
+
- GitHub: <https://github.com/Fector101/android_notify>
|
|
226
|
+
- Twitter: <https://x.com/CodewithFabian> -- 😊 I'm sure to answer
|
|
227
|
+
|
|
228
|
+
For feedback or contributions, feel free to reach out!
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## ☕ Support the Project
|
|
233
|
+
|
|
234
|
+
If you find this project helpful, consider buying me a coffee! Your support helps maintain and improve the project.
|
|
235
|
+
|
|
236
|
+
<a href="https://www.buymeacoffee.com/fector101" target="_blank">
|
|
237
|
+
<img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60">
|
|
238
|
+
</a>
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Acknowledgments
|
|
243
|
+
|
|
244
|
+
- Thanks to the Kivy and Pyjnius communities for their support.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## 🌐 **Links**
|
|
249
|
+
|
|
250
|
+
- **PyPI:** [android-notify on PyPI](https://pypi.org/project/android-notify/)
|
|
251
|
+
- **GitHub:** [Source Code Repository](https://github.com/Fector101/android_notify/)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
android_notify/__init__.py,sha256=DOUMyhwcXFBbamkxf0fJCBtRemTGXTiJTrQpKV_XF_A,74
|
|
2
|
+
android_notify/__main__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
android_notify/core.py,sha256=JsfpijK-v4aDDQ0E2ECdzdlGUGlVM51UDCHgLRZFr9w,5916
|
|
4
|
+
android_notify/styles.py,sha256=P_8sAqb3Hbf_vbhqSoCVjKeqJ05Fr_CksO-HX5pj8pU,134
|
|
5
|
+
android_notify-1.21.dist-info/METADATA,sha256=D4DVpiTBOpuMpi0kELE0IGUEX-3-WddoBNJwjn3wsog,5949
|
|
6
|
+
android_notify-1.21.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
7
|
+
android_notify-1.21.dist-info/top_level.txt,sha256=IR1ONMrRSRINZpWn2X0dL5gbWwWINsK7PW8Jy2p4fU8,15
|
|
8
|
+
android_notify-1.21.dist-info/RECORD,,
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: android-notify
|
|
3
|
-
Version: 1.1
|
|
4
|
-
Summary: A Python package for sending Android notifications.
|
|
5
|
-
Home-page: https://github.com/Fector101/android_notify/
|
|
6
|
-
Author: Fabian
|
|
7
|
-
Author-email: fabianjoseph063@gmail.com
|
|
8
|
-
Project-URL: Funding, https://buymeacoffee.com/fector101
|
|
9
|
-
Project-URL: Source, https://github.com/Fector101/android_notify/
|
|
10
|
-
Requires-Python: >=3.6
|
|
11
|
-
Description-Content-Type: text/markdown
|
|
12
|
-
Requires-Dist: pyjnius
|
|
13
|
-
|
|
14
|
-
# Android Notify
|
|
15
|
-
|
|
16
|
-
`android_notify` is a Python module designed to simplify sending Android notifications using Kivy and Pyjnius. It supports multiple notification styles, including text, images, and inbox layouts.
|
|
17
|
-
|
|
18
|
-
## Features
|
|
19
|
-
|
|
20
|
-
- Send Android notifications with custom titles and messages.
|
|
21
|
-
- Support for multiple notification styles:
|
|
22
|
-
- Big Text
|
|
23
|
-
- Big Picture
|
|
24
|
-
- Inbox
|
|
25
|
-
- Ability to include images in notifications.
|
|
26
|
-
- Compatible with Android 8.0+ (Notification Channels).
|
|
27
|
-
- Customizable notification channels.
|
|
28
|
-
- Support for large icons in notifications.
|
|
29
|
-
|
|
30
|
-
## Installation
|
|
31
|
-
|
|
32
|
-
Make sure you have the required dependencies installed:
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
pip install android-notify
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Usage
|
|
39
|
-
|
|
40
|
-
**Prerequisites:**
|
|
41
|
-
|
|
42
|
-
- Buildozer
|
|
43
|
-
- Kivy
|
|
44
|
-
|
|
45
|
-
In your **`buildozer.spec`** file, ensure you include the following:
|
|
46
|
-
|
|
47
|
-
```ini
|
|
48
|
-
# Add pyjnius so it's packaged with the build
|
|
49
|
-
requirements = python3,kivy,pyjnius
|
|
50
|
-
|
|
51
|
-
# Add permission for notifications
|
|
52
|
-
android.permissions = POST_NOTIFICATIONS
|
|
53
|
-
|
|
54
|
-
# Required dependencies (write exactly as shown, no quotation marks)
|
|
55
|
-
android.gradle_dependencies = androidx.core:core:1.6.0
|
|
56
|
-
android.enable_androidx = True
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### Example Notification
|
|
60
|
-
|
|
61
|
-
```python
|
|
62
|
-
from android_notify.core import send_notification
|
|
63
|
-
|
|
64
|
-
# Send a basic notification
|
|
65
|
-
send_notification("Hello", "This is a basic notification.")
|
|
66
|
-
|
|
67
|
-
# Send a notification with an image
|
|
68
|
-
send_notification(
|
|
69
|
-
title='Picture Alert!',
|
|
70
|
-
message='This notification includes an image.',
|
|
71
|
-
style='big_picture',
|
|
72
|
-
img_path='assets/imgs/icon.png'
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
# Send a notification with inbox style
|
|
76
|
-
send_notification(
|
|
77
|
-
title='Inbox Notification',
|
|
78
|
-
message='Line 1\nLine 2\nLine 3',
|
|
79
|
-
style='inbox'
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
# Send a Big Text notification (Note this send as a normal notification if not supported on said device)
|
|
83
|
-
send_notification(
|
|
84
|
-
title='Hello!',
|
|
85
|
-
message='This is a sample notification.',
|
|
86
|
-
style='big_text'
|
|
87
|
-
)
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Function Reference
|
|
91
|
-
|
|
92
|
-
#### `send_notification`
|
|
93
|
-
|
|
94
|
-
- **title** (*str*): Notification title.
|
|
95
|
-
- **message** (*str*): Notification message body.
|
|
96
|
-
- **style** (*str*): Notification style (`big_text`, `big_picture`, `inbox`, `large_icon`).
|
|
97
|
-
- **img_path** (*str*): Path to the image (for `big_picture` or `large_icon` styles).
|
|
98
|
-
- **channel_id** (*str*): Notification channel ID.
|
|
99
|
-
|
|
100
|
-
#### `get_image_uri`
|
|
101
|
-
|
|
102
|
-
- Resolves the absolute URI of an image resource.
|
|
103
|
-
- **relative_path** (*str*): The relative path to the image.
|
|
104
|
-
|
|
105
|
-
### Advanced Usage
|
|
106
|
-
|
|
107
|
-
You can customize notification channels for different types of notifications.
|
|
108
|
-
|
|
109
|
-
```python
|
|
110
|
-
send_notification(
|
|
111
|
-
title='Custom Channel Notification',
|
|
112
|
-
message='This uses a custom notification channel.',
|
|
113
|
-
channel_id='custom_channel'
|
|
114
|
-
)
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
## Contribution
|
|
118
|
-
|
|
119
|
-
Feel free to open issues or submit pull requests for improvements!
|
|
120
|
-
|
|
121
|
-
## 🐛 Reporting Issues
|
|
122
|
-
|
|
123
|
-
Found a bug? Please open an issue on our [GitHub Issues](https://github.com/Fector101/android_notify/issues) page.
|
|
124
|
-
|
|
125
|
-
## ☕ Support the Project
|
|
126
|
-
|
|
127
|
-
If you find this project helpful, consider buying me a coffee! Your support helps maintain and improve the project.
|
|
128
|
-
|
|
129
|
-
<a href="https://www.buymeacoffee.com/fector101" target="_blank">
|
|
130
|
-
<img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60">
|
|
131
|
-
</a>
|
|
132
|
-
|
|
133
|
-
## Author
|
|
134
|
-
|
|
135
|
-
- Fabian - <fector101@yahoo.com>
|
|
136
|
-
- GitHub: <https://github.com/Fector101/android_notify>
|
|
137
|
-
|
|
138
|
-
## Acknowledgments
|
|
139
|
-
|
|
140
|
-
- Thanks to the Kivy and Pyjnius communities for their support.
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
android_notify/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
android_notify/__main__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
android_notify/core.py,sha256=0edRXIF6ltTboJtkGjnOhLJDrYCYa2fzrB7cy61Y1PM,6598
|
|
4
|
-
android_notify/styles.py,sha256=P_8sAqb3Hbf_vbhqSoCVjKeqJ05Fr_CksO-HX5pj8pU,134
|
|
5
|
-
android_notify-1.1.dist-info/METADATA,sha256=q2w4ak4jAcfJ9103bpKU-kPXdFdVgtpc4cbI7z5nd9I,3808
|
|
6
|
-
android_notify-1.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
7
|
-
android_notify-1.1.dist-info/top_level.txt,sha256=IR1ONMrRSRINZpWn2X0dL5gbWwWINsK7PW8Jy2p4fU8,15
|
|
8
|
-
android_notify-1.1.dist-info/RECORD,,
|
|
File without changes
|