android-notify 1.3__tar.gz → 1.23__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.
- android_notify-1.23/MANIFEST.in +1 -0
- android_notify-1.23/PKG-INFO +262 -0
- android_notify-1.23/README.md +238 -0
- android_notify-1.23/android_notify/__init__.py +2 -0
- {android_notify-1.3 → android_notify-1.23}/android_notify/core.py +8 -15
- android_notify-1.23/android_notify/styles.py +5 -0
- android_notify-1.23/android_notify.egg-info/PKG-INFO +262 -0
- {android_notify-1.3 → android_notify-1.23}/android_notify.egg-info/SOURCES.txt +1 -1
- {android_notify-1.3 → android_notify-1.23}/setup.py +10 -17
- android_notify-1.3/PKG-INFO +0 -350
- android_notify-1.3/README.md +0 -326
- android_notify-1.3/android_notify/__init__.py +0 -3
- android_notify-1.3/android_notify/styles.py +0 -15
- android_notify-1.3/android_notify/sword.py +0 -375
- android_notify-1.3/android_notify.egg-info/PKG-INFO +0 -350
- {android_notify-1.3 → android_notify-1.23}/android_notify/__main__.py +0 -0
- {android_notify-1.3 → android_notify-1.23}/android_notify.egg-info/dependency_links.txt +0 -0
- {android_notify-1.3 → android_notify-1.23}/android_notify.egg-info/requires.txt +0 -0
- {android_notify-1.3 → android_notify-1.23}/android_notify.egg-info/top_level.txt +0 -0
- {android_notify-1.3 → android_notify-1.23}/setup.cfg +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
global-exclude *.env
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: android-notify
|
|
3
|
+
Version: 1.23
|
|
4
|
+
Summary: A Python package for sending Android notifications using PyJNIus 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,push notifications,pyjnius,android notifications,kivy notifications,python android,mobile development
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: Android
|
|
17
|
+
Classifier: Development Status :: 4 - Beta
|
|
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
|
+
# Android Notify
|
|
26
|
+
|
|
27
|
+
`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.
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
- Send Android notifications with custom titles and messages.
|
|
32
|
+
- Support for multiple notification styles:
|
|
33
|
+
- Big Text
|
|
34
|
+
- Big Picture
|
|
35
|
+
- Large Icon
|
|
36
|
+
- Inbox
|
|
37
|
+
- Supports including images in notifications.
|
|
38
|
+
- Compatible with Android 8.0+ (Notification Channels).
|
|
39
|
+
- Customizable notification channels.
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
This package is available on PyPI and can be installed via pip:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install android-notify
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## **Dependencies**
|
|
50
|
+
|
|
51
|
+
**Prerequisites:**
|
|
52
|
+
|
|
53
|
+
- Buildozer
|
|
54
|
+
- Kivy
|
|
55
|
+
|
|
56
|
+
In your **`buildozer.spec`** file, ensure you include the following:
|
|
57
|
+
|
|
58
|
+
```ini
|
|
59
|
+
# Add pyjnius so it's packaged with the build
|
|
60
|
+
requirements = python3, kivy, pyjnius, android-notify
|
|
61
|
+
|
|
62
|
+
# Add permission for notifications
|
|
63
|
+
android.permissions = POST_NOTIFICATIONS
|
|
64
|
+
|
|
65
|
+
# Required dependencies (write exactly as shown, no quotation marks)
|
|
66
|
+
android.gradle_dependencies = androidx.core:core:1.6.0, androidx.core:core-ktx:1.15.0
|
|
67
|
+
android.enable_androidx = True
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
### Example Notification
|
|
73
|
+
|
|
74
|
+
#### Basic Notification
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
from android_notify import send_notification
|
|
78
|
+
|
|
79
|
+
# Send a basic notification
|
|
80
|
+
send_notification("Hello", "This is a basic notification.")
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Example Image:**
|
|
84
|
+

|
|
85
|
+
|
|
86
|
+
#### Notification with an Image (Big Picture Style)
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
# Send a notification with an image
|
|
90
|
+
send_notification(
|
|
91
|
+
title='Picture Alert!',
|
|
92
|
+
message='This notification includes an image.',
|
|
93
|
+
style='big_picture',
|
|
94
|
+
img_path='assets/imgs/icon.png'
|
|
95
|
+
)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Example Image:**
|
|
99
|
+

|
|
100
|
+
|
|
101
|
+
#### Inbox Notification Style
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
# Send a notification with inbox style
|
|
105
|
+
send_notification(
|
|
106
|
+
title='Inbox Notification',
|
|
107
|
+
message='Line 1\nLine 2\nLine 3',
|
|
108
|
+
style='inbox'
|
|
109
|
+
)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Example Image:**
|
|
113
|
+

|
|
114
|
+
|
|
115
|
+
#### Big Text Notification
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
# Send a Big Text notification
|
|
119
|
+
send_notification(
|
|
120
|
+
title='Hello!',
|
|
121
|
+
message='This is a sample notification.',
|
|
122
|
+
style='big_text'
|
|
123
|
+
)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Example Image:**
|
|
127
|
+

|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
### **Assist**
|
|
132
|
+
|
|
133
|
+
- How to Copy image to app folder
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
import shutil,os # These modules come packaged with python
|
|
137
|
+
from android.storage import app_storage_path # type: ignore -- This works only on android
|
|
138
|
+
|
|
139
|
+
app_path = os.path.join(app_storage_path(),'app')
|
|
140
|
+
image_path= "/storage/emulated/0/Download/profile.png"
|
|
141
|
+
|
|
142
|
+
shutil.copy(image_path, os.path.join(app_path, "profile.png"))
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
- Avoiding Human Error when using different notification styles
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
from android_notify import send_notification, NotificationStyles
|
|
149
|
+
send_notification(
|
|
150
|
+
title='Picture Alert!',
|
|
151
|
+
message='This notification includes an image.',
|
|
152
|
+
img_path='assets/imgs/icon.png'
|
|
153
|
+
style=NotificationStyles.BIG_PICTURE,
|
|
154
|
+
)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
### **Functions Reference**
|
|
160
|
+
|
|
161
|
+
### 1. `asks_permission_if_needed()`
|
|
162
|
+
|
|
163
|
+
**Description:**
|
|
164
|
+
|
|
165
|
+
- Checks if notification permissions are granted and requests them if missing.
|
|
166
|
+
|
|
167
|
+
**Usage:**
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
asks_permission_if_needed()
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
### 2. `get_image_uri(relative_path)`
|
|
176
|
+
|
|
177
|
+
**Description:**
|
|
178
|
+
|
|
179
|
+
- Resolves the absolute URI for an image in the app's storage.
|
|
180
|
+
|
|
181
|
+
**Parameters:**
|
|
182
|
+
|
|
183
|
+
- `relative_path` *(str)*: Path to the image (e.g., `assets/imgs/icon.png`).
|
|
184
|
+
|
|
185
|
+
**Returns:**
|
|
186
|
+
|
|
187
|
+
- `Uri`: Android URI object for the image.
|
|
188
|
+
|
|
189
|
+
**Usage:**
|
|
190
|
+
|
|
191
|
+
```python
|
|
192
|
+
uri = get_image_uri('assets/imgs/icon.png')
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
### 3. `send_notification(title, message, style=None, img_path=None, channel_id='default_channel')`
|
|
198
|
+
|
|
199
|
+
**Description:**
|
|
200
|
+
|
|
201
|
+
- Sends an Android notification with optional styles and images.
|
|
202
|
+
|
|
203
|
+
**Parameters:**
|
|
204
|
+
|
|
205
|
+
- `title` *(str)*: Notification title.
|
|
206
|
+
- `message` *(str)*: Notification message.
|
|
207
|
+
- `style` *(str, optional)*: Notification style (`big_text`, `big_picture`, `inbox`, `large_icon`).
|
|
208
|
+
- `img_path` *(str, optional)*: Path to the image resource.(for `big_picture` or `large_icon` styles).
|
|
209
|
+
- `channel_id` *(str, optional)*: Notification channel ID.
|
|
210
|
+
|
|
211
|
+
Returns - notification id
|
|
212
|
+
|
|
213
|
+
### Advanced Usage
|
|
214
|
+
|
|
215
|
+
You can customize notification channels for different types of notifications.
|
|
216
|
+
|
|
217
|
+
```python
|
|
218
|
+
send_notification(
|
|
219
|
+
title='Custom Channel Notification',
|
|
220
|
+
message='This uses a custom notification channel.',
|
|
221
|
+
channel_id='custom_channel'
|
|
222
|
+
)
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Contribution
|
|
226
|
+
|
|
227
|
+
Feel free to open issues or submit pull requests for improvements!
|
|
228
|
+
|
|
229
|
+
## 🐛 Reporting Issues
|
|
230
|
+
|
|
231
|
+
Found a bug? Please open an issue on our [GitHub Issues](https://github.com/Fector101/android_notify/issues) page.
|
|
232
|
+
|
|
233
|
+
## Author
|
|
234
|
+
|
|
235
|
+
- Fabian - <fector101@yahoo.com>
|
|
236
|
+
- GitHub: <https://github.com/Fector101/android_notify>
|
|
237
|
+
- Twitter: <https://x.com/CodewithFabian> -- 😊 I'm sure to answer
|
|
238
|
+
|
|
239
|
+
For feedback or contributions, feel free to reach out!
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## ☕ Support the Project
|
|
244
|
+
|
|
245
|
+
If you find this project helpful, consider buying me a coffee! Your support helps maintain and improve the project.
|
|
246
|
+
|
|
247
|
+
<a href="https://www.buymeacoffee.com/fector101" target="_blank">
|
|
248
|
+
<img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60">
|
|
249
|
+
</a>
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## Acknowledgments
|
|
254
|
+
|
|
255
|
+
- Thanks to the Kivy and Pyjnius communities for their support.
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## 🌐 **Links**
|
|
260
|
+
|
|
261
|
+
- **PyPI:** [android-notify on PyPI](https://pypi.org/project/android-notify/)
|
|
262
|
+
- **GitHub:** [Source Code Repository](https://github.com/Fector101/android_notify/)
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# Android Notify
|
|
2
|
+
|
|
3
|
+
`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.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Send Android notifications with custom titles and messages.
|
|
8
|
+
- Support for multiple notification styles:
|
|
9
|
+
- Big Text
|
|
10
|
+
- Big Picture
|
|
11
|
+
- Large Icon
|
|
12
|
+
- Inbox
|
|
13
|
+
- Supports including images in notifications.
|
|
14
|
+
- Compatible with Android 8.0+ (Notification Channels).
|
|
15
|
+
- Customizable notification channels.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
This package is available on PyPI and can be installed via pip:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install android-notify
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## **Dependencies**
|
|
26
|
+
|
|
27
|
+
**Prerequisites:**
|
|
28
|
+
|
|
29
|
+
- Buildozer
|
|
30
|
+
- Kivy
|
|
31
|
+
|
|
32
|
+
In your **`buildozer.spec`** file, ensure you include the following:
|
|
33
|
+
|
|
34
|
+
```ini
|
|
35
|
+
# Add pyjnius so it's packaged with the build
|
|
36
|
+
requirements = python3, kivy, pyjnius, android-notify
|
|
37
|
+
|
|
38
|
+
# Add permission for notifications
|
|
39
|
+
android.permissions = POST_NOTIFICATIONS
|
|
40
|
+
|
|
41
|
+
# Required dependencies (write exactly as shown, no quotation marks)
|
|
42
|
+
android.gradle_dependencies = androidx.core:core:1.6.0, androidx.core:core-ktx:1.15.0
|
|
43
|
+
android.enable_androidx = True
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
### Example Notification
|
|
49
|
+
|
|
50
|
+
#### Basic Notification
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from android_notify import send_notification
|
|
54
|
+
|
|
55
|
+
# Send a basic notification
|
|
56
|
+
send_notification("Hello", "This is a basic notification.")
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Example Image:**
|
|
60
|
+

|
|
61
|
+
|
|
62
|
+
#### Notification with an Image (Big Picture Style)
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
# Send a notification with an image
|
|
66
|
+
send_notification(
|
|
67
|
+
title='Picture Alert!',
|
|
68
|
+
message='This notification includes an image.',
|
|
69
|
+
style='big_picture',
|
|
70
|
+
img_path='assets/imgs/icon.png'
|
|
71
|
+
)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Example Image:**
|
|
75
|
+

|
|
76
|
+
|
|
77
|
+
#### Inbox Notification Style
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
# Send a notification with inbox style
|
|
81
|
+
send_notification(
|
|
82
|
+
title='Inbox Notification',
|
|
83
|
+
message='Line 1\nLine 2\nLine 3',
|
|
84
|
+
style='inbox'
|
|
85
|
+
)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Example Image:**
|
|
89
|
+

|
|
90
|
+
|
|
91
|
+
#### Big Text Notification
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
# Send a Big Text notification
|
|
95
|
+
send_notification(
|
|
96
|
+
title='Hello!',
|
|
97
|
+
message='This is a sample notification.',
|
|
98
|
+
style='big_text'
|
|
99
|
+
)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Example Image:**
|
|
103
|
+

|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
### **Assist**
|
|
108
|
+
|
|
109
|
+
- How to Copy image to app folder
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
import shutil,os # These modules come packaged with python
|
|
113
|
+
from android.storage import app_storage_path # type: ignore -- This works only on android
|
|
114
|
+
|
|
115
|
+
app_path = os.path.join(app_storage_path(),'app')
|
|
116
|
+
image_path= "/storage/emulated/0/Download/profile.png"
|
|
117
|
+
|
|
118
|
+
shutil.copy(image_path, os.path.join(app_path, "profile.png"))
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
- Avoiding Human Error when using different notification styles
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
from android_notify import send_notification, NotificationStyles
|
|
125
|
+
send_notification(
|
|
126
|
+
title='Picture Alert!',
|
|
127
|
+
message='This notification includes an image.',
|
|
128
|
+
img_path='assets/imgs/icon.png'
|
|
129
|
+
style=NotificationStyles.BIG_PICTURE,
|
|
130
|
+
)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
### **Functions Reference**
|
|
136
|
+
|
|
137
|
+
### 1. `asks_permission_if_needed()`
|
|
138
|
+
|
|
139
|
+
**Description:**
|
|
140
|
+
|
|
141
|
+
- Checks if notification permissions are granted and requests them if missing.
|
|
142
|
+
|
|
143
|
+
**Usage:**
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
asks_permission_if_needed()
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
### 2. `get_image_uri(relative_path)`
|
|
152
|
+
|
|
153
|
+
**Description:**
|
|
154
|
+
|
|
155
|
+
- Resolves the absolute URI for an image in the app's storage.
|
|
156
|
+
|
|
157
|
+
**Parameters:**
|
|
158
|
+
|
|
159
|
+
- `relative_path` *(str)*: Path to the image (e.g., `assets/imgs/icon.png`).
|
|
160
|
+
|
|
161
|
+
**Returns:**
|
|
162
|
+
|
|
163
|
+
- `Uri`: Android URI object for the image.
|
|
164
|
+
|
|
165
|
+
**Usage:**
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
uri = get_image_uri('assets/imgs/icon.png')
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
### 3. `send_notification(title, message, style=None, img_path=None, channel_id='default_channel')`
|
|
174
|
+
|
|
175
|
+
**Description:**
|
|
176
|
+
|
|
177
|
+
- Sends an Android notification with optional styles and images.
|
|
178
|
+
|
|
179
|
+
**Parameters:**
|
|
180
|
+
|
|
181
|
+
- `title` *(str)*: Notification title.
|
|
182
|
+
- `message` *(str)*: Notification message.
|
|
183
|
+
- `style` *(str, optional)*: Notification style (`big_text`, `big_picture`, `inbox`, `large_icon`).
|
|
184
|
+
- `img_path` *(str, optional)*: Path to the image resource.(for `big_picture` or `large_icon` styles).
|
|
185
|
+
- `channel_id` *(str, optional)*: Notification channel ID.
|
|
186
|
+
|
|
187
|
+
Returns - notification id
|
|
188
|
+
|
|
189
|
+
### Advanced Usage
|
|
190
|
+
|
|
191
|
+
You can customize notification channels for different types of notifications.
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
send_notification(
|
|
195
|
+
title='Custom Channel Notification',
|
|
196
|
+
message='This uses a custom notification channel.',
|
|
197
|
+
channel_id='custom_channel'
|
|
198
|
+
)
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Contribution
|
|
202
|
+
|
|
203
|
+
Feel free to open issues or submit pull requests for improvements!
|
|
204
|
+
|
|
205
|
+
## 🐛 Reporting Issues
|
|
206
|
+
|
|
207
|
+
Found a bug? Please open an issue on our [GitHub Issues](https://github.com/Fector101/android_notify/issues) page.
|
|
208
|
+
|
|
209
|
+
## Author
|
|
210
|
+
|
|
211
|
+
- Fabian - <fector101@yahoo.com>
|
|
212
|
+
- GitHub: <https://github.com/Fector101/android_notify>
|
|
213
|
+
- Twitter: <https://x.com/CodewithFabian> -- 😊 I'm sure to answer
|
|
214
|
+
|
|
215
|
+
For feedback or contributions, feel free to reach out!
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## ☕ Support the Project
|
|
220
|
+
|
|
221
|
+
If you find this project helpful, consider buying me a coffee! Your support helps maintain and improve the project.
|
|
222
|
+
|
|
223
|
+
<a href="https://www.buymeacoffee.com/fector101" target="_blank">
|
|
224
|
+
<img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60">
|
|
225
|
+
</a>
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Acknowledgments
|
|
230
|
+
|
|
231
|
+
- Thanks to the Kivy and Pyjnius communities for their support.
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## 🌐 **Links**
|
|
236
|
+
|
|
237
|
+
- **PyPI:** [android-notify on PyPI](https://pypi.org/project/android-notify/)
|
|
238
|
+
- **GitHub:** [Source Code Repository](https://github.com/Fector101/android_notify/)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
from jnius import autoclass,cast
|
|
2
3
|
import random
|
|
3
4
|
import os
|
|
4
|
-
from jnius import autoclass,cast
|
|
5
5
|
|
|
6
6
|
ON_ANDROID = False
|
|
7
7
|
try:
|
|
@@ -26,6 +26,7 @@ if ON_ANDROID:
|
|
|
26
26
|
# Notification Design
|
|
27
27
|
NotificationCompatBuilder = autoclass('androidx.core.app.NotificationCompat$Builder')
|
|
28
28
|
NotificationCompatBigTextStyle = autoclass('androidx.core.app.NotificationCompat$BigTextStyle')
|
|
29
|
+
# NotificationCompatBigTextStyle = autoclass('android.app.Notification$BigTextStyle')
|
|
29
30
|
NotificationCompatBigPictureStyle = autoclass('androidx.core.app.NotificationCompat$BigPictureStyle')
|
|
30
31
|
NotificationCompatInboxStyle = autoclass('androidx.core.app.NotificationCompat$InboxStyle')
|
|
31
32
|
except Exception as e:
|
|
@@ -64,14 +65,7 @@ def get_image_uri(relative_path):
|
|
|
64
65
|
return Uri.parse(f"file://{output_path}")
|
|
65
66
|
|
|
66
67
|
|
|
67
|
-
def send_notification(
|
|
68
|
-
title:str,
|
|
69
|
-
message:str,
|
|
70
|
-
style=None,
|
|
71
|
-
img_path=None,
|
|
72
|
-
channel_name="Default Channel",
|
|
73
|
-
channel_id:str="default_channel"
|
|
74
|
-
):
|
|
68
|
+
def send_notification(title:str, message:str, style=None, img_path=None, channel_id:str="default_channel"):
|
|
75
69
|
"""
|
|
76
70
|
Send a notification on Android.
|
|
77
71
|
|
|
@@ -79,13 +73,13 @@ def send_notification(
|
|
|
79
73
|
:param message: Message body.
|
|
80
74
|
:param style: Style of the notification ('big_text', 'big_picture', 'inbox', 'large_icon').
|
|
81
75
|
:param img_path: Path to the image resource.
|
|
82
|
-
:param channel_id: Notification channel ID.
|
|
76
|
+
:param channel_id: Notification channel ID.
|
|
83
77
|
"""
|
|
84
78
|
if not ON_ANDROID:
|
|
85
79
|
print('This Package Only Runs on Android !!! ---> Check "https://github.com/Fector101/android_notify/" for Documentation.')
|
|
86
80
|
return
|
|
87
81
|
asks_permission_if_needed()
|
|
88
|
-
|
|
82
|
+
|
|
89
83
|
# Get notification manager
|
|
90
84
|
notification_manager = context.getSystemService(context.NOTIFICATION_SERVICE)
|
|
91
85
|
|
|
@@ -94,7 +88,7 @@ def send_notification(
|
|
|
94
88
|
|
|
95
89
|
# Notification Channel (Required for Android 8.0+)
|
|
96
90
|
if BuildVersion.SDK_INT >= 26:
|
|
97
|
-
channel = NotificationChannel(channel_id,
|
|
91
|
+
channel = NotificationChannel(channel_id, "Default Channel",importance)
|
|
98
92
|
notification_manager.createNotificationChannel(channel)
|
|
99
93
|
|
|
100
94
|
# Build the notification
|
|
@@ -136,5 +130,4 @@ def send_notification(
|
|
|
136
130
|
# Display the notification
|
|
137
131
|
notification_id = random.randint(0, 100)
|
|
138
132
|
notification_manager.notify(notification_id, builder.build())
|
|
139
|
-
return notification_id
|
|
140
|
-
|
|
133
|
+
return notification_id
|