android-notify 1.60.5.dev0__tar.gz → 1.60.6__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.
- android_notify-1.60.6/PKG-INFO +250 -0
- android_notify-1.60.6/README.md +227 -0
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/android_notify/an_types.py +9 -22
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/android_notify/an_utils.py +12 -12
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/android_notify/config.py +24 -12
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/android_notify/core.py +25 -20
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/android_notify/sword.py +69 -50
- android_notify-1.60.6/android_notify.egg-info/PKG-INFO +250 -0
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/android_notify.egg-info/SOURCES.txt +0 -2
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/pyproject.toml +1 -4
- android_notify-1.60.5.dev0/PKG-INFO +0 -133
- android_notify-1.60.5.dev0/README.md +0 -110
- android_notify-1.60.5.dev0/android_notify/fallback-icons/flet-appicon.png +0 -0
- android_notify-1.60.5.dev0/android_notify/fallback-icons/pydroid3-appicon.png +0 -0
- android_notify-1.60.5.dev0/android_notify.egg-info/PKG-INFO +0 -133
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/android_notify/__init__.py +0 -0
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/android_notify/__main__.py +0 -0
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/android_notify/base.py +0 -0
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/android_notify/styles.py +0 -0
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/android_notify.egg-info/dependency_links.txt +0 -0
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/android_notify.egg-info/entry_points.txt +0 -0
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/android_notify.egg-info/requires.txt +0 -0
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/android_notify.egg-info/top_level.txt +0 -0
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/docs/examples/flet-working/src/core.py +0 -0
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/docs/examples/flet-working/src/main.py +0 -0
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/docs/tests/flet/adv/main.py +0 -0
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/docs/tests/flet/adv/tests/__init__.py +0 -0
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/docs/tests/flet/adv/tests/test_android_notify_full.py +0 -0
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/docs/tests/flet/basic/src/core.py +0 -0
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/docs/tests/flet/basic/src/main.py +0 -0
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/docs/website/src/pages/data/laner_Sent.py +0 -0
- {android_notify-1.60.5.dev0 → android_notify-1.60.6}/setup.cfg +0 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: android-notify
|
|
3
|
+
Version: 1.60.6
|
|
4
|
+
Summary: A Python package that simplifies creating Android notifications in Kivy and Flet apps.
|
|
5
|
+
Author-email: Fabian <fector101@yahoo.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://android-notify.vercel.app
|
|
8
|
+
Project-URL: Documentation, https://android-notify.vercel.app/
|
|
9
|
+
Project-URL: Source, https://github.com/fector101/android_notify
|
|
10
|
+
Project-URL: Tracker, https://github.com/fector101/android_notify/issues
|
|
11
|
+
Project-URL: Funding, https://www.buymeacoffee.com/fector101
|
|
12
|
+
Keywords: android,notifications,kivy,mobile,post-notifications,pyjnius,android-notifications,kivy-notifications,python-android,mobile-development,push-notifications,mobile-app,kivy-application
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Operating System :: Android
|
|
15
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Requires-Python: >=3.6
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
Requires-Dist: pyjnius>=1.4.2
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: kivy>=2.0.0; extra == "dev"
|
|
23
|
+
|
|
24
|
+
<div align="center">
|
|
25
|
+
<br>
|
|
26
|
+
<h1> Android-Notify </h1>
|
|
27
|
+
<p><a href='https://android-notify.vercel.app'>Android Notify</a> is a Python library for effortlessly creating and managing Android notifications in Kivy and Flet apps.</p>
|
|
28
|
+
<p>Supports various styles and ensures seamless integration, customization and Pythonic APIs.</p>
|
|
29
|
+
<!-- <br> -->
|
|
30
|
+
<!-- <img src="https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/democollage.jpg"> -->
|
|
31
|
+
</div>
|
|
32
|
+
<!-- Channel [CRUD]
|
|
33
|
+
The Android Notify package provides a simple yet comprehensive way to create and manage rich notifications on Android devices directly from your Python code. This library bridges the gap between Python and Android's notification system, giving you full control over notifications with a clean, Pythonic API. -->
|
|
34
|
+
|
|
35
|
+
## Features
|
|
36
|
+
|
|
37
|
+
- **Multiple Notification Styles**: Support for various notification styles including:
|
|
38
|
+
- Simple text notifications
|
|
39
|
+
- [Progress bar notifications](https://android-notify.vercel.app/components#progress-bars) (determinate and indeterminate)
|
|
40
|
+
- Large icon notifications
|
|
41
|
+
- Big picture notifications
|
|
42
|
+
- Combined image styles
|
|
43
|
+
- Custom notification Icon - [images section](https://android-notify.vercel.app/components#images)
|
|
44
|
+
- Big text notifications
|
|
45
|
+
- Inbox-style notifications
|
|
46
|
+
- Colored texts and Icons
|
|
47
|
+
|
|
48
|
+
- **Rich Functionality**:
|
|
49
|
+
- Add action buttons with custom callbacks
|
|
50
|
+
- [Update notification](https://android-notify.vercel.app/advanced-methods#updating-notification) content dynamically
|
|
51
|
+
- Manage progress bars with fine-grained control
|
|
52
|
+
- [Custom notification channels](https://android-notify.vercel.app/advanced-methods#channel-management) for Android 8.0+ (Creating and Deleting)
|
|
53
|
+
- Silent notifications
|
|
54
|
+
- Persistent notifications
|
|
55
|
+
- Click handlers and callbacks
|
|
56
|
+
- Cancel Notifications
|
|
57
|
+
|
|
58
|
+
## Quick Start
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from android_notify import Notification
|
|
62
|
+
|
|
63
|
+
# Simple notification
|
|
64
|
+
Notification(
|
|
65
|
+
title="Hello",
|
|
66
|
+
message="This is a basic notification."
|
|
67
|
+
).send()
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Sample Image:**
|
|
72
|
+

|
|
73
|
+
|
|
74
|
+
## Installation
|
|
75
|
+
|
|
76
|
+
<details>
|
|
77
|
+
<summary><b>Kivy apps:</b></summary>
|
|
78
|
+
<br/>
|
|
79
|
+
|
|
80
|
+
In your **`buildozer.spec`** file, ensure you include the following:
|
|
81
|
+
|
|
82
|
+
```ini
|
|
83
|
+
# Add pyjnius so ensure it's packaged with the build
|
|
84
|
+
requirements = python3, kivy, pyjnius, android-notify
|
|
85
|
+
# Add permission for notifications
|
|
86
|
+
android.permissions = POST_NOTIFICATIONS
|
|
87
|
+
|
|
88
|
+
# Required dependencies (write exactly as shown, no quotation marks)
|
|
89
|
+
android.gradle_dependencies = androidx.core:core:1.6.0, androidx.core:core-ktx:1.15.0
|
|
90
|
+
android.enable_androidx = True
|
|
91
|
+
android.api = 35
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
</details>
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
<details>
|
|
98
|
+
<summary><b>Flet apps:</b></summary>
|
|
99
|
+
<br/>
|
|
100
|
+
|
|
101
|
+
In your `pyproject.toml` file, ensure you include the following:
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
```toml
|
|
105
|
+
[tool.flet.android]
|
|
106
|
+
dependencies = [
|
|
107
|
+
"pyjnius","android-notify>=1.60.6.dev0"
|
|
108
|
+
]
|
|
109
|
+
|
|
110
|
+
[tool.flet.android.permission]
|
|
111
|
+
"android.permission.POST_NOTIFICATIONS" = true
|
|
112
|
+
```
|
|
113
|
+
- example of [complete flet pyproject.toml](https://github.com/Fector101/flet-app/blob/main/pyproject.toml)
|
|
114
|
+
|
|
115
|
+
</details>
|
|
116
|
+
|
|
117
|
+
<details>
|
|
118
|
+
|
|
119
|
+
<summary><b>Desktop</b></summary>
|
|
120
|
+
<br/>
|
|
121
|
+
|
|
122
|
+
For IDE IntelliSense Can be installed via `pip install`:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
pip install android_notify
|
|
126
|
+
android-notify -v
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
</details>
|
|
130
|
+
|
|
131
|
+
------
|
|
132
|
+
## Installing without Androidx
|
|
133
|
+
How to use without `gradle_dependencies`
|
|
134
|
+
Use `android-notify>=1.60.6.dev0` to install via `pip`
|
|
135
|
+
|
|
136
|
+
<details>
|
|
137
|
+
<summary><b>In Kivy</b></summary>
|
|
138
|
+
<br/>
|
|
139
|
+
|
|
140
|
+
```ini
|
|
141
|
+
# buildozer.spec
|
|
142
|
+
requirements = python3, kivy, pyjnius, android-notify>=1.60.6.dev0
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
</details>
|
|
146
|
+
|
|
147
|
+
<details>
|
|
148
|
+
|
|
149
|
+
<summary><b>On Pydroid 3</b></summary>
|
|
150
|
+
<br/>
|
|
151
|
+
|
|
152
|
+
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.
|
|
153
|
+
- In pip section where you're asked to insert `Libary name` paste `android-notify>=1.60.6.dev0`
|
|
154
|
+
- Minimal working example
|
|
155
|
+
```py
|
|
156
|
+
# Testing with `android-notify>=1.60.6.dev0` on pydroid
|
|
157
|
+
from kivy.app import App
|
|
158
|
+
from kivy.uix.boxlayout import BoxLayout
|
|
159
|
+
from kivy.uix.button import Button
|
|
160
|
+
from android_notify import Notification
|
|
161
|
+
from android_notify.core import asks_permission_if_needed
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
class AndroidNotifyDemoApp(App):
|
|
165
|
+
def build(self):
|
|
166
|
+
layout = BoxLayout(orientation='vertical', spacing=10, padding=20)
|
|
167
|
+
layout.add_widget(Button(
|
|
168
|
+
text="Ask Notification Permission",
|
|
169
|
+
on_release=self.request_permission
|
|
170
|
+
))
|
|
171
|
+
layout.add_widget(Button(
|
|
172
|
+
text="Send Notification",
|
|
173
|
+
on_release=self.send_notification
|
|
174
|
+
))
|
|
175
|
+
return layout
|
|
176
|
+
|
|
177
|
+
def request_permission(self, *args):
|
|
178
|
+
asks_permission_if_needed(no_androidx=True)
|
|
179
|
+
|
|
180
|
+
def send_notification(self, *args):
|
|
181
|
+
Notification(
|
|
182
|
+
title="Hello from Android Notify",
|
|
183
|
+
message="This is a basic notification.",
|
|
184
|
+
channel_id="android_notify_demo",
|
|
185
|
+
channel_name="Android Notify Demo"
|
|
186
|
+
).send()
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
if __name__ == "__main__":
|
|
190
|
+
AndroidNotifyDemoApp().run()
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
</details>
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
## Documentation
|
|
198
|
+
For Dev Version use
|
|
199
|
+
```requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_notify/archive/main.zip```
|
|
200
|
+
|
|
201
|
+
### To talk to BroadCast Listener From Buttons
|
|
202
|
+
|
|
203
|
+
- Make things happen without being in your app
|
|
204
|
+
```python
|
|
205
|
+
|
|
206
|
+
from android_notify import Notification
|
|
207
|
+
notification = Notification(title="Reciver Notification")
|
|
208
|
+
notification.addButton(text="Stop", receiver_name="CarouselReceiver", action="ACTION_STOP")
|
|
209
|
+
notification.addButton(text="Skip", receiver_name="CarouselReceiver", action="ACTION_SKIP")
|
|
210
|
+
```
|
|
211
|
+
You can use this [wiki](https://github.com/Fector101/android_notify/wiki/How-to#use-with-broadcast-listener-in-kivy) as a guide create a broadcast listener
|
|
212
|
+
|
|
213
|
+
### To use colored text in your notifications
|
|
214
|
+
|
|
215
|
+
- Copy the [res](https://github.com/Fector101/android_notify/tree/main/android_notify/res) folder to your app path.
|
|
216
|
+
- Lastly in your `buildozer.spec` file
|
|
217
|
+
Add `source.include_exts = xml` and `android.add_resources = # path you pasted`
|
|
218
|
+
|
|
219
|
+
### To use Custom Sounds
|
|
220
|
+
|
|
221
|
+
- Put audio files in `res/raw` folder,
|
|
222
|
+
- Then from `buildozer.spec` point to res folder `android.add_resources = res`
|
|
223
|
+
- and includes it's format `source.include_exts = wav`.
|
|
224
|
+
|
|
225
|
+
Lastly From the code
|
|
226
|
+
```py
|
|
227
|
+
# Create a custom notification channel with a unique sound resource for android 8+
|
|
228
|
+
Notification.createChannel(
|
|
229
|
+
id="weird_sound_tester",
|
|
230
|
+
name="Weird Sound Tester",
|
|
231
|
+
description="A test channel used to verify custom notification sounds from the res/raw folder.",
|
|
232
|
+
res_sound_name="sneeze" # file name without .wav or .mp3
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
# Send a notification through the created channel
|
|
236
|
+
n=Notification(
|
|
237
|
+
title="Custom Sound Notification",
|
|
238
|
+
message="This tests playback of a custom sound (sneeze.wav) stored in res/raw.",
|
|
239
|
+
channel_id="weird_sound_tester" # important tells notification to use right channel
|
|
240
|
+
)
|
|
241
|
+
n.setSound("sneeze")# for android 7 below
|
|
242
|
+
n.send()
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### For full documentation, examples, and advanced usage, API reference visit the [documentation](https://android-notify.vercel.app)
|
|
246
|
+
|
|
247
|
+
## ☕ Support the Project
|
|
248
|
+
|
|
249
|
+
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.
|
|
250
|
+
[donate](https://www.buymeacoffee.com/fector101)
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<br>
|
|
3
|
+
<h1> Android-Notify </h1>
|
|
4
|
+
<p><a href='https://android-notify.vercel.app'>Android Notify</a> is a Python library for effortlessly creating and managing Android notifications in Kivy and Flet apps.</p>
|
|
5
|
+
<p>Supports various styles and ensures seamless integration, customization and Pythonic APIs.</p>
|
|
6
|
+
<!-- <br> -->
|
|
7
|
+
<!-- <img src="https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/democollage.jpg"> -->
|
|
8
|
+
</div>
|
|
9
|
+
<!-- Channel [CRUD]
|
|
10
|
+
The Android Notify package provides a simple yet comprehensive way to create and manage rich notifications on Android devices directly from your Python code. This library bridges the gap between Python and Android's notification system, giving you full control over notifications with a clean, Pythonic API. -->
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- **Multiple Notification Styles**: Support for various notification styles including:
|
|
15
|
+
- Simple text notifications
|
|
16
|
+
- [Progress bar notifications](https://android-notify.vercel.app/components#progress-bars) (determinate and indeterminate)
|
|
17
|
+
- Large icon notifications
|
|
18
|
+
- Big picture notifications
|
|
19
|
+
- Combined image styles
|
|
20
|
+
- Custom notification Icon - [images section](https://android-notify.vercel.app/components#images)
|
|
21
|
+
- Big text notifications
|
|
22
|
+
- Inbox-style notifications
|
|
23
|
+
- Colored texts and Icons
|
|
24
|
+
|
|
25
|
+
- **Rich Functionality**:
|
|
26
|
+
- Add action buttons with custom callbacks
|
|
27
|
+
- [Update notification](https://android-notify.vercel.app/advanced-methods#updating-notification) content dynamically
|
|
28
|
+
- Manage progress bars with fine-grained control
|
|
29
|
+
- [Custom notification channels](https://android-notify.vercel.app/advanced-methods#channel-management) for Android 8.0+ (Creating and Deleting)
|
|
30
|
+
- Silent notifications
|
|
31
|
+
- Persistent notifications
|
|
32
|
+
- Click handlers and callbacks
|
|
33
|
+
- Cancel Notifications
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from android_notify import Notification
|
|
39
|
+
|
|
40
|
+
# Simple notification
|
|
41
|
+
Notification(
|
|
42
|
+
title="Hello",
|
|
43
|
+
message="This is a basic notification."
|
|
44
|
+
).send()
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Sample Image:**
|
|
49
|
+

|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
<details>
|
|
54
|
+
<summary><b>Kivy apps:</b></summary>
|
|
55
|
+
<br/>
|
|
56
|
+
|
|
57
|
+
In your **`buildozer.spec`** file, ensure you include the following:
|
|
58
|
+
|
|
59
|
+
```ini
|
|
60
|
+
# Add pyjnius so ensure it's packaged with the build
|
|
61
|
+
requirements = python3, kivy, pyjnius, android-notify
|
|
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
|
+
android.api = 35
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
</details>
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
<details>
|
|
75
|
+
<summary><b>Flet apps:</b></summary>
|
|
76
|
+
<br/>
|
|
77
|
+
|
|
78
|
+
In your `pyproject.toml` file, ensure you include the following:
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
```toml
|
|
82
|
+
[tool.flet.android]
|
|
83
|
+
dependencies = [
|
|
84
|
+
"pyjnius","android-notify>=1.60.6.dev0"
|
|
85
|
+
]
|
|
86
|
+
|
|
87
|
+
[tool.flet.android.permission]
|
|
88
|
+
"android.permission.POST_NOTIFICATIONS" = true
|
|
89
|
+
```
|
|
90
|
+
- example of [complete flet pyproject.toml](https://github.com/Fector101/flet-app/blob/main/pyproject.toml)
|
|
91
|
+
|
|
92
|
+
</details>
|
|
93
|
+
|
|
94
|
+
<details>
|
|
95
|
+
|
|
96
|
+
<summary><b>Desktop</b></summary>
|
|
97
|
+
<br/>
|
|
98
|
+
|
|
99
|
+
For IDE IntelliSense Can be installed via `pip install`:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
pip install android_notify
|
|
103
|
+
android-notify -v
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
</details>
|
|
107
|
+
|
|
108
|
+
------
|
|
109
|
+
## Installing without Androidx
|
|
110
|
+
How to use without `gradle_dependencies`
|
|
111
|
+
Use `android-notify>=1.60.6.dev0` to install via `pip`
|
|
112
|
+
|
|
113
|
+
<details>
|
|
114
|
+
<summary><b>In Kivy</b></summary>
|
|
115
|
+
<br/>
|
|
116
|
+
|
|
117
|
+
```ini
|
|
118
|
+
# buildozer.spec
|
|
119
|
+
requirements = python3, kivy, pyjnius, android-notify>=1.60.6.dev0
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
</details>
|
|
123
|
+
|
|
124
|
+
<details>
|
|
125
|
+
|
|
126
|
+
<summary><b>On Pydroid 3</b></summary>
|
|
127
|
+
<br/>
|
|
128
|
+
|
|
129
|
+
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.
|
|
130
|
+
- In pip section where you're asked to insert `Libary name` paste `android-notify>=1.60.6.dev0`
|
|
131
|
+
- Minimal working example
|
|
132
|
+
```py
|
|
133
|
+
# Testing with `android-notify>=1.60.6.dev0` on pydroid
|
|
134
|
+
from kivy.app import App
|
|
135
|
+
from kivy.uix.boxlayout import BoxLayout
|
|
136
|
+
from kivy.uix.button import Button
|
|
137
|
+
from android_notify import Notification
|
|
138
|
+
from android_notify.core import asks_permission_if_needed
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
class AndroidNotifyDemoApp(App):
|
|
142
|
+
def build(self):
|
|
143
|
+
layout = BoxLayout(orientation='vertical', spacing=10, padding=20)
|
|
144
|
+
layout.add_widget(Button(
|
|
145
|
+
text="Ask Notification Permission",
|
|
146
|
+
on_release=self.request_permission
|
|
147
|
+
))
|
|
148
|
+
layout.add_widget(Button(
|
|
149
|
+
text="Send Notification",
|
|
150
|
+
on_release=self.send_notification
|
|
151
|
+
))
|
|
152
|
+
return layout
|
|
153
|
+
|
|
154
|
+
def request_permission(self, *args):
|
|
155
|
+
asks_permission_if_needed(no_androidx=True)
|
|
156
|
+
|
|
157
|
+
def send_notification(self, *args):
|
|
158
|
+
Notification(
|
|
159
|
+
title="Hello from Android Notify",
|
|
160
|
+
message="This is a basic notification.",
|
|
161
|
+
channel_id="android_notify_demo",
|
|
162
|
+
channel_name="Android Notify Demo"
|
|
163
|
+
).send()
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
if __name__ == "__main__":
|
|
167
|
+
AndroidNotifyDemoApp().run()
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
</details>
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
## Documentation
|
|
175
|
+
For Dev Version use
|
|
176
|
+
```requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_notify/archive/main.zip```
|
|
177
|
+
|
|
178
|
+
### To talk to BroadCast Listener From Buttons
|
|
179
|
+
|
|
180
|
+
- Make things happen without being in your app
|
|
181
|
+
```python
|
|
182
|
+
|
|
183
|
+
from android_notify import Notification
|
|
184
|
+
notification = Notification(title="Reciver Notification")
|
|
185
|
+
notification.addButton(text="Stop", receiver_name="CarouselReceiver", action="ACTION_STOP")
|
|
186
|
+
notification.addButton(text="Skip", receiver_name="CarouselReceiver", action="ACTION_SKIP")
|
|
187
|
+
```
|
|
188
|
+
You can use this [wiki](https://github.com/Fector101/android_notify/wiki/How-to#use-with-broadcast-listener-in-kivy) as a guide create a broadcast listener
|
|
189
|
+
|
|
190
|
+
### To use colored text in your notifications
|
|
191
|
+
|
|
192
|
+
- Copy the [res](https://github.com/Fector101/android_notify/tree/main/android_notify/res) folder to your app path.
|
|
193
|
+
- Lastly in your `buildozer.spec` file
|
|
194
|
+
Add `source.include_exts = xml` and `android.add_resources = # path you pasted`
|
|
195
|
+
|
|
196
|
+
### To use Custom Sounds
|
|
197
|
+
|
|
198
|
+
- Put audio files in `res/raw` folder,
|
|
199
|
+
- Then from `buildozer.spec` point to res folder `android.add_resources = res`
|
|
200
|
+
- and includes it's format `source.include_exts = wav`.
|
|
201
|
+
|
|
202
|
+
Lastly From the code
|
|
203
|
+
```py
|
|
204
|
+
# Create a custom notification channel with a unique sound resource for android 8+
|
|
205
|
+
Notification.createChannel(
|
|
206
|
+
id="weird_sound_tester",
|
|
207
|
+
name="Weird Sound Tester",
|
|
208
|
+
description="A test channel used to verify custom notification sounds from the res/raw folder.",
|
|
209
|
+
res_sound_name="sneeze" # file name without .wav or .mp3
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
# Send a notification through the created channel
|
|
213
|
+
n=Notification(
|
|
214
|
+
title="Custom Sound Notification",
|
|
215
|
+
message="This tests playback of a custom sound (sneeze.wav) stored in res/raw.",
|
|
216
|
+
channel_id="weird_sound_tester" # important tells notification to use right channel
|
|
217
|
+
)
|
|
218
|
+
n.setSound("sneeze")# for android 7 below
|
|
219
|
+
n.send()
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### For full documentation, examples, and advanced usage, API reference visit the [documentation](https://android-notify.vercel.app)
|
|
223
|
+
|
|
224
|
+
## ☕ Support the Project
|
|
225
|
+
|
|
226
|
+
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.
|
|
227
|
+
[donate](https://www.buymeacoffee.com/fector101)
|
|
@@ -108,9 +108,6 @@ class Uri:
|
|
|
108
108
|
class NotificationManager:
|
|
109
109
|
pass
|
|
110
110
|
|
|
111
|
-
class NotificationManagerClass:
|
|
112
|
-
pass
|
|
113
|
-
|
|
114
111
|
|
|
115
112
|
class NotificationChannel:
|
|
116
113
|
def __init__(self, channel_id, channel_name, importance):
|
|
@@ -172,12 +169,6 @@ class NotificationManagerCompat:
|
|
|
172
169
|
IMPORTANCE_MIN = ''
|
|
173
170
|
IMPORTANCE_NONE = ''
|
|
174
171
|
|
|
175
|
-
class AndroidNotification:
|
|
176
|
-
DEFAULT_ALL = 3
|
|
177
|
-
PRIORITY_HIGH = 4
|
|
178
|
-
PRIORITY_DEFAULT = ''
|
|
179
|
-
PRIORITY_LOW = ''
|
|
180
|
-
PRIORITY_MIN = ''
|
|
181
172
|
|
|
182
173
|
class NotificationCompat:
|
|
183
174
|
DEFAULT_ALL = 3
|
|
@@ -196,19 +187,15 @@ class MActions:
|
|
|
196
187
|
class NotificationCompatBuilder:
|
|
197
188
|
def __init__(self, context, channel_id):
|
|
198
189
|
self.mActions = MActions()
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
def
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
print(f"[MOCK] setContentTitle called with title={title}")
|
|
209
|
-
|
|
210
|
-
def setContentText(self, text):
|
|
211
|
-
print(f"[MOCK] setContentText called with text={text}")
|
|
190
|
+
pass
|
|
191
|
+
def setProgress(self,max_value,current_value,endless):
|
|
192
|
+
pass
|
|
193
|
+
def setStyle(self,style):
|
|
194
|
+
pass
|
|
195
|
+
def setContentTitle(self,title):
|
|
196
|
+
pass
|
|
197
|
+
def setContentText(self,text):
|
|
198
|
+
pass
|
|
212
199
|
|
|
213
200
|
def setSmallIcon(self, icon):
|
|
214
201
|
print(f"[MOCK] setSmallIcon called with icon={icon}")
|
|
@@ -4,11 +4,11 @@ import inspect, os, re, traceback
|
|
|
4
4
|
from .config import autoclass
|
|
5
5
|
from .an_types import Importance
|
|
6
6
|
from .config import (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
)
|
|
7
|
+
get_python_activity_context, app_storage_path,ON_ANDROID,
|
|
8
|
+
BitmapFactory, BuildVersion, Bundle,
|
|
9
|
+
NotificationManagerCompat,NotificationCompat,
|
|
10
|
+
Intent, Settings, Uri, String, Manifest
|
|
11
|
+
)
|
|
12
12
|
|
|
13
13
|
if ON_ANDROID:
|
|
14
14
|
Color = autoclass('android.graphics.Color')
|
|
@@ -41,15 +41,15 @@ def get_android_importance(importance: Importance):
|
|
|
41
41
|
return None
|
|
42
42
|
value = ''
|
|
43
43
|
if importance == 'urgent':
|
|
44
|
-
value =
|
|
44
|
+
value = NotificationCompat.PRIORITY_HIGH if BuildVersion.SDK_INT <= 25 else NotificationManagerCompat.IMPORTANCE_HIGH
|
|
45
45
|
elif importance == 'high':
|
|
46
|
-
value =
|
|
46
|
+
value = NotificationCompat.PRIORITY_DEFAULT if BuildVersion.SDK_INT <= 25 else NotificationManagerCompat.IMPORTANCE_DEFAULT
|
|
47
47
|
elif importance == 'medium':
|
|
48
|
-
value =
|
|
48
|
+
value = NotificationCompat.PRIORITY_LOW if BuildVersion.SDK_INT <= 25 else NotificationManagerCompat.IMPORTANCE_LOW
|
|
49
49
|
elif importance == 'low':
|
|
50
|
-
value =
|
|
50
|
+
value = NotificationCompat.PRIORITY_MIN if BuildVersion.SDK_INT <= 25 else NotificationManagerCompat.IMPORTANCE_MIN
|
|
51
51
|
elif importance == 'none':
|
|
52
|
-
value = '' if BuildVersion.SDK_INT <= 25 else
|
|
52
|
+
value = '' if BuildVersion.SDK_INT <= 25 else NotificationManagerCompat.IMPORTANCE_NONE
|
|
53
53
|
|
|
54
54
|
return value
|
|
55
55
|
# side-note 'medium' = NotificationCompat.PRIORITY_LOW and 'low' = NotificationCompat.PRIORITY_MIN # weird but from docs
|
|
@@ -78,10 +78,10 @@ def get_img_from_path(relative_path):
|
|
|
78
78
|
app_folder = os.path.join(app_storage_path(), 'app')
|
|
79
79
|
img_full_path = os.path.join(app_folder, relative_path)
|
|
80
80
|
if not os.path.exists(img_full_path):
|
|
81
|
-
print(f'
|
|
81
|
+
print(f'Image: "{img_full_path}" Not Found, (Local images gotten from App Path)')
|
|
82
82
|
try:
|
|
83
83
|
print("- These are the existing files in your app Folder:")
|
|
84
|
-
print('[' + ', '.join(os.listdir(app_folder)) + ']
|
|
84
|
+
print('[' + ', '.join(os.listdir(app_folder)) + ']')
|
|
85
85
|
except Exception as could_not_get_files_in_path_error:
|
|
86
86
|
print('Exception: ', could_not_get_files_in_path_error)
|
|
87
87
|
print("Couldn't get Files in App Folder")
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import os, traceback
|
|
2
2
|
|
|
3
3
|
ON_ANDROID = False
|
|
4
|
-
__version__ = "1.60.
|
|
4
|
+
__version__ = "1.60.6"
|
|
5
|
+
|
|
5
6
|
|
|
6
7
|
def is_platform_android():
|
|
7
8
|
if os.getenv("MAIN_ACTIVITY_HOST_CLASS_NAME"):
|
|
@@ -51,10 +52,9 @@ if is_platform_android():
|
|
|
51
52
|
PendingIntent = autoclass('android.app.PendingIntent')
|
|
52
53
|
BitmapFactory = autoclass('android.graphics.BitmapFactory')
|
|
53
54
|
BuildVersion = autoclass('android.os.Build$VERSION')
|
|
54
|
-
|
|
55
|
+
NotificationManager = autoclass('android.app.NotificationManager')
|
|
55
56
|
NotificationChannel = autoclass('android.app.NotificationChannel')
|
|
56
57
|
RemoteViews = autoclass('android.widget.RemoteViews')
|
|
57
|
-
AndroidNotification = autoclass("android.app.Notification")
|
|
58
58
|
Settings = autoclass("android.provider.Settings")
|
|
59
59
|
Uri = autoclass("android.net.Uri")
|
|
60
60
|
Manifest = autoclass('android.Manifest$permission')
|
|
@@ -71,17 +71,25 @@ else:
|
|
|
71
71
|
|
|
72
72
|
if ON_ANDROID:
|
|
73
73
|
try:
|
|
74
|
+
NotificationManagerCompat = autoclass('androidx.core.app.NotificationManagerCompat')
|
|
75
|
+
NotificationCompat = autoclass('androidx.core.app.NotificationCompat')
|
|
76
|
+
IconCompat = autoclass('androidx.core.graphics.drawable.IconCompat')
|
|
74
77
|
Color = autoclass('android.graphics.Color')
|
|
75
78
|
|
|
76
79
|
# Notification Design
|
|
77
|
-
NotificationCompatBuilder = autoclass('
|
|
78
|
-
NotificationCompatBigTextStyle = autoclass('
|
|
79
|
-
NotificationCompatBigPictureStyle = autoclass('
|
|
80
|
-
NotificationCompatInboxStyle = autoclass('
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
except Exception as
|
|
84
|
-
print('
|
|
80
|
+
NotificationCompatBuilder = autoclass('androidx.core.app.NotificationCompat$Builder')
|
|
81
|
+
NotificationCompatBigTextStyle = autoclass('androidx.core.app.NotificationCompat$BigTextStyle')
|
|
82
|
+
NotificationCompatBigPictureStyle = autoclass('androidx.core.app.NotificationCompat$BigPictureStyle')
|
|
83
|
+
NotificationCompatInboxStyle = autoclass('androidx.core.app.NotificationCompat$InboxStyle')
|
|
84
|
+
NotificationCompatDecoratedCustomViewStyle = autoclass('androidx.core.app.NotificationCompat$DecoratedCustomViewStyle')
|
|
85
|
+
|
|
86
|
+
except Exception as dependencies_import_error:
|
|
87
|
+
print('dependencies_import_error: ', dependencies_import_error)
|
|
88
|
+
print("""
|
|
89
|
+
Dependency Error: Add the following in buildozer.spec:
|
|
90
|
+
* android.gradle_dependencies = androidx.core:core-ktx:1.15.0, androidx.core:core:1.6.0
|
|
91
|
+
* android.enable_androidx = True
|
|
92
|
+
""")
|
|
85
93
|
|
|
86
94
|
from .an_types import *
|
|
87
95
|
else:
|
|
@@ -149,7 +157,7 @@ def get_notification_manager():
|
|
|
149
157
|
if not ON_ANDROID:
|
|
150
158
|
return None
|
|
151
159
|
notification_service = context.getSystemService(context.NOTIFICATION_SERVICE)
|
|
152
|
-
return cast(
|
|
160
|
+
return cast(NotificationManager, notification_service)
|
|
153
161
|
|
|
154
162
|
|
|
155
163
|
def app_storage_path():
|
|
@@ -161,3 +169,7 @@ def app_storage_path():
|
|
|
161
169
|
return kivy_app_storage_path()
|
|
162
170
|
except Exception as e:
|
|
163
171
|
return './' # TODO return file main.py path (not android)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def get_package_name():
|
|
175
|
+
return context.getPackageName() # package.domain + "." + package.name
|