android-notify 1.60.10.dev0__tar.gz → 1.61.0__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.10.dev0 → android_notify-1.61.0}/PKG-INFO +46 -31
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/README.md +45 -30
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/base.py +0 -15
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/config.py +1 -2
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/core.py +4 -3
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/internal/android.py +21 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/internal/java_classes.py +17 -10
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/internal/permissions.py +21 -8
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/sword.py +74 -64
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/widgets/images.py +1 -2
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/widgets/texts.py +1 -5
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify.egg-info/PKG-INFO +46 -31
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify.egg-info/SOURCES.txt +1 -4
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/pyproject.toml +1 -1
- android_notify-1.60.10.dev0/android_notify/tests/flet/basic/src/core.py +0 -221
- android_notify-1.60.10.dev0/android_notify/tests/flet/flet-working/src/core.py +0 -221
- android_notify-1.60.10.dev0/docs/website/src/pages/data/laner_Sent.py +0 -24
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/__init__.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/__main__.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/fallback-icons/flet-appicon.png +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/fallback-icons/pydroid3-appicon.png +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/internal/an_types.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/internal/channels.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/internal/facade.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/internal/helper.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/internal/intents.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/internal/logger.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/styles.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/tests/__init__.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/tests/android_notify_test.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/tests/base_test.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/tests/flet/adv/main.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/tests/flet/adv/tests/__init__.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/tests/flet/adv/tests/test_android_notify_full.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/tests/flet/basic/src/main.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/tests/flet/flet-working/src/main.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/tests/main.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/tests/p4a/hook.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/tests/serivces/wallpaper.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/tests/test_basic_notifications.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/tests/test_notification_actions.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/tests/test_notification_appearance.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/tests/test_notification_behavior.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/tests/test_notification_channels.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/tests/test_notification_clear.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/tests/test_notification_permission.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/tests/test_notification_progress.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/tests/test_notification_sound.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/tests/test_notification_styles.py +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify.egg-info/dependency_links.txt +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify.egg-info/entry_points.txt +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify.egg-info/requires.txt +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify.egg-info/top_level.txt +0 -0
- {android_notify-1.60.10.dev0 → android_notify-1.61.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: android-notify
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.61.0
|
|
4
4
|
Summary: A Python package that simplifies creating Android notifications in Kivy and Flet apps.
|
|
5
5
|
Author-email: Fabian <fector101@yahoo.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -81,9 +81,14 @@ In your **`buildozer.spec`** file, ensure you include the following:
|
|
|
81
81
|
|
|
82
82
|
```ini
|
|
83
83
|
# Add pyjnius so ensure it's packaged with the build
|
|
84
|
-
requirements = python3, kivy, pyjnius, android-notify
|
|
84
|
+
requirements = python3, kivy, pyjnius, android-notify
|
|
85
85
|
# Add permission for notifications
|
|
86
86
|
android.permissions = POST_NOTIFICATIONS
|
|
87
|
+
|
|
88
|
+
# Required dependency (write exactly as shown, no quotation marks)
|
|
89
|
+
android.gradle_dependencies = androidx.core:core-ktx:1.15.0
|
|
90
|
+
android.enable_androidx = True
|
|
91
|
+
android.api = 35
|
|
87
92
|
```
|
|
88
93
|
|
|
89
94
|
</details>
|
|
@@ -93,13 +98,13 @@ android.permissions = POST_NOTIFICATIONS
|
|
|
93
98
|
<summary><b>Flet apps:</b></summary>
|
|
94
99
|
<br/>
|
|
95
100
|
|
|
96
|
-
In your `pyproject.toml` file, ensure you include the following:
|
|
101
|
+
In your `pyproject.toml` file, ensure you include the following:
|
|
97
102
|
|
|
98
103
|
|
|
99
104
|
```toml
|
|
100
105
|
[tool.flet.android]
|
|
101
106
|
dependencies = [
|
|
102
|
-
"pyjnius","android-notify==1.
|
|
107
|
+
"pyjnius","android-notify==1.61.0.dev0"
|
|
103
108
|
]
|
|
104
109
|
|
|
105
110
|
[tool.flet.android.permission]
|
|
@@ -109,7 +114,35 @@ dependencies = [
|
|
|
109
114
|
|
|
110
115
|
</details>
|
|
111
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.61.0.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.61.0.dev0
|
|
143
|
+
```
|
|
112
144
|
|
|
145
|
+
</details>
|
|
113
146
|
|
|
114
147
|
<details>
|
|
115
148
|
|
|
@@ -117,10 +150,10 @@ dependencies = [
|
|
|
117
150
|
<br/>
|
|
118
151
|
|
|
119
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.
|
|
120
|
-
- In pip section where you're asked to insert `Libary name` paste `android-notify==1.
|
|
153
|
+
- In pip section where you're asked to insert `Libary name` paste `android-notify==1.61.0.dev0`
|
|
121
154
|
- Minimal working example
|
|
122
155
|
```py
|
|
123
|
-
# Testing with `android-notify==1.
|
|
156
|
+
# Testing with `android-notify==1.61.0.dev0` on pydroid
|
|
124
157
|
from kivy.app import App
|
|
125
158
|
from kivy.uix.boxlayout import BoxLayout
|
|
126
159
|
from kivy.uix.button import Button
|
|
@@ -147,9 +180,7 @@ class AndroidNotifyDemoApp(App):
|
|
|
147
180
|
def send_notification(self, *args):
|
|
148
181
|
Notification(
|
|
149
182
|
title="Hello from Android Notify",
|
|
150
|
-
message="This is a basic notification."
|
|
151
|
-
channel_id="android_notify_demo",
|
|
152
|
-
channel_name="Android Notify Demo"
|
|
183
|
+
message="This is a basic notification."
|
|
153
184
|
).send()
|
|
154
185
|
|
|
155
186
|
|
|
@@ -160,23 +191,11 @@ if __name__ == "__main__":
|
|
|
160
191
|
</details>
|
|
161
192
|
|
|
162
193
|
|
|
163
|
-
<details>
|
|
164
|
-
|
|
165
|
-
<summary><b>Desktop</b></summary>
|
|
166
|
-
<br/>
|
|
167
|
-
|
|
168
|
-
For IDE IntelliSense Can be installed via `pip install`:
|
|
169
|
-
|
|
170
|
-
```bash
|
|
171
|
-
pip install android_notify
|
|
172
|
-
android-notify -v
|
|
173
|
-
```
|
|
174
|
-
</details>
|
|
175
194
|
|
|
176
195
|
## Documentation
|
|
177
|
-
For Dev Version
|
|
196
|
+
For Dev Version usage
|
|
178
197
|
```ini
|
|
179
|
-
requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_notify/archive/
|
|
198
|
+
requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_notify/archive/main.zip
|
|
180
199
|
```
|
|
181
200
|
|
|
182
201
|
<details>
|
|
@@ -185,7 +204,7 @@ requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_noti
|
|
|
185
204
|
- Make things happen without being in your app
|
|
186
205
|
```python
|
|
187
206
|
from android_notify import Notification
|
|
188
|
-
notification = Notification(title="
|
|
207
|
+
notification = Notification(title="Reciver Notification")
|
|
189
208
|
notification.addButton(text="Stop", receiver_name="CarouselReceiver", action="ACTION_STOP")
|
|
190
209
|
notification.addButton(text="Skip", receiver_name="CarouselReceiver", action="ACTION_SKIP")
|
|
191
210
|
```
|
|
@@ -248,7 +267,7 @@ Notification.createChannel(id='shake', name="Shake Passage", vibrate=True)
|
|
|
248
267
|
|
|
249
268
|
n=Notification(title='Vibrate',channel_id='shake')
|
|
250
269
|
n.setVibrate() # for less than android 8
|
|
251
|
-
n.fVibrate() # To Force Vibrate
|
|
270
|
+
n.fVibrate() # To Force Vibrate
|
|
252
271
|
n.send()
|
|
253
272
|
```
|
|
254
273
|
|
|
@@ -286,9 +305,5 @@ from android_notify import Notification, NotificationHandler
|
|
|
286
305
|
|
|
287
306
|
## ☕ Support the Project
|
|
288
307
|
|
|
289
|
-
If you find this project helpful,
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
<a href="https://www.buymeacoffee.com/fector101" target="_blank">
|
|
293
|
-
<img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60">
|
|
294
|
-
</a>
|
|
308
|
+
If you find this project helpful, your support would help me continue working on open-source projects
|
|
309
|
+
[donate](https://www.buymeacoffee.com/fector101)
|
|
@@ -58,9 +58,14 @@ In your **`buildozer.spec`** file, ensure you include the following:
|
|
|
58
58
|
|
|
59
59
|
```ini
|
|
60
60
|
# Add pyjnius so ensure it's packaged with the build
|
|
61
|
-
requirements = python3, kivy, pyjnius, android-notify
|
|
61
|
+
requirements = python3, kivy, pyjnius, android-notify
|
|
62
62
|
# Add permission for notifications
|
|
63
63
|
android.permissions = POST_NOTIFICATIONS
|
|
64
|
+
|
|
65
|
+
# Required dependency (write exactly as shown, no quotation marks)
|
|
66
|
+
android.gradle_dependencies = androidx.core:core-ktx:1.15.0
|
|
67
|
+
android.enable_androidx = True
|
|
68
|
+
android.api = 35
|
|
64
69
|
```
|
|
65
70
|
|
|
66
71
|
</details>
|
|
@@ -70,13 +75,13 @@ android.permissions = POST_NOTIFICATIONS
|
|
|
70
75
|
<summary><b>Flet apps:</b></summary>
|
|
71
76
|
<br/>
|
|
72
77
|
|
|
73
|
-
In your `pyproject.toml` file, ensure you include the following:
|
|
78
|
+
In your `pyproject.toml` file, ensure you include the following:
|
|
74
79
|
|
|
75
80
|
|
|
76
81
|
```toml
|
|
77
82
|
[tool.flet.android]
|
|
78
83
|
dependencies = [
|
|
79
|
-
"pyjnius","android-notify==1.
|
|
84
|
+
"pyjnius","android-notify==1.61.0.dev0"
|
|
80
85
|
]
|
|
81
86
|
|
|
82
87
|
[tool.flet.android.permission]
|
|
@@ -86,7 +91,35 @@ dependencies = [
|
|
|
86
91
|
|
|
87
92
|
</details>
|
|
88
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.61.0.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.61.0.dev0
|
|
120
|
+
```
|
|
89
121
|
|
|
122
|
+
</details>
|
|
90
123
|
|
|
91
124
|
<details>
|
|
92
125
|
|
|
@@ -94,10 +127,10 @@ dependencies = [
|
|
|
94
127
|
<br/>
|
|
95
128
|
|
|
96
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.
|
|
97
|
-
- In pip section where you're asked to insert `Libary name` paste `android-notify==1.
|
|
130
|
+
- In pip section where you're asked to insert `Libary name` paste `android-notify==1.61.0.dev0`
|
|
98
131
|
- Minimal working example
|
|
99
132
|
```py
|
|
100
|
-
# Testing with `android-notify==1.
|
|
133
|
+
# Testing with `android-notify==1.61.0.dev0` on pydroid
|
|
101
134
|
from kivy.app import App
|
|
102
135
|
from kivy.uix.boxlayout import BoxLayout
|
|
103
136
|
from kivy.uix.button import Button
|
|
@@ -124,9 +157,7 @@ class AndroidNotifyDemoApp(App):
|
|
|
124
157
|
def send_notification(self, *args):
|
|
125
158
|
Notification(
|
|
126
159
|
title="Hello from Android Notify",
|
|
127
|
-
message="This is a basic notification."
|
|
128
|
-
channel_id="android_notify_demo",
|
|
129
|
-
channel_name="Android Notify Demo"
|
|
160
|
+
message="This is a basic notification."
|
|
130
161
|
).send()
|
|
131
162
|
|
|
132
163
|
|
|
@@ -137,23 +168,11 @@ if __name__ == "__main__":
|
|
|
137
168
|
</details>
|
|
138
169
|
|
|
139
170
|
|
|
140
|
-
<details>
|
|
141
|
-
|
|
142
|
-
<summary><b>Desktop</b></summary>
|
|
143
|
-
<br/>
|
|
144
|
-
|
|
145
|
-
For IDE IntelliSense Can be installed via `pip install`:
|
|
146
|
-
|
|
147
|
-
```bash
|
|
148
|
-
pip install android_notify
|
|
149
|
-
android-notify -v
|
|
150
|
-
```
|
|
151
|
-
</details>
|
|
152
171
|
|
|
153
172
|
## Documentation
|
|
154
|
-
For Dev Version
|
|
173
|
+
For Dev Version usage
|
|
155
174
|
```ini
|
|
156
|
-
requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_notify/archive/
|
|
175
|
+
requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_notify/archive/main.zip
|
|
157
176
|
```
|
|
158
177
|
|
|
159
178
|
<details>
|
|
@@ -162,7 +181,7 @@ requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_noti
|
|
|
162
181
|
- Make things happen without being in your app
|
|
163
182
|
```python
|
|
164
183
|
from android_notify import Notification
|
|
165
|
-
notification = Notification(title="
|
|
184
|
+
notification = Notification(title="Reciver Notification")
|
|
166
185
|
notification.addButton(text="Stop", receiver_name="CarouselReceiver", action="ACTION_STOP")
|
|
167
186
|
notification.addButton(text="Skip", receiver_name="CarouselReceiver", action="ACTION_SKIP")
|
|
168
187
|
```
|
|
@@ -225,7 +244,7 @@ Notification.createChannel(id='shake', name="Shake Passage", vibrate=True)
|
|
|
225
244
|
|
|
226
245
|
n=Notification(title='Vibrate',channel_id='shake')
|
|
227
246
|
n.setVibrate() # for less than android 8
|
|
228
|
-
n.fVibrate() # To Force Vibrate
|
|
247
|
+
n.fVibrate() # To Force Vibrate
|
|
229
248
|
n.send()
|
|
230
249
|
```
|
|
231
250
|
|
|
@@ -263,9 +282,5 @@ from android_notify import Notification, NotificationHandler
|
|
|
263
282
|
|
|
264
283
|
## ☕ Support the Project
|
|
265
284
|
|
|
266
|
-
If you find this project helpful,
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
<a href="https://www.buymeacoffee.com/fector101" target="_blank">
|
|
270
|
-
<img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60">
|
|
271
|
-
</a>
|
|
285
|
+
If you find this project helpful, your support would help me continue working on open-source projects
|
|
286
|
+
[donate](https://www.buymeacoffee.com/fector101)
|
|
@@ -11,15 +11,10 @@ class BaseNotification:
|
|
|
11
11
|
# Basic options
|
|
12
12
|
title: str = ''
|
|
13
13
|
message: str = ''
|
|
14
|
-
style: str = 'simple'
|
|
15
14
|
|
|
16
15
|
# Style-specific attributes
|
|
17
|
-
big_picture_path: str = ''
|
|
18
|
-
large_icon_path: str = ''
|
|
19
16
|
progress_max_value: int = 0
|
|
20
17
|
progress_current_value: float = 0.0 # Also Takes in Ints
|
|
21
|
-
body: str = ''
|
|
22
|
-
lines_txt: str = ''
|
|
23
18
|
|
|
24
19
|
# Notification Functions
|
|
25
20
|
name: str = ''
|
|
@@ -28,7 +23,6 @@ class BaseNotification:
|
|
|
28
23
|
# Advanced Options
|
|
29
24
|
id: int = 0
|
|
30
25
|
app_icon: str = 'Defaults to package app icon'
|
|
31
|
-
sub_text: str=''
|
|
32
26
|
|
|
33
27
|
# Channel related
|
|
34
28
|
channel_name: str = 'Default Channel'
|
|
@@ -86,12 +80,3 @@ class BaseNotification:
|
|
|
86
80
|
if not isinstance(actual_value, expected_type):
|
|
87
81
|
raise TypeError(f"Expected '{each_arg}' to be {expected_type}, got {type(actual_value)} instead.")
|
|
88
82
|
|
|
89
|
-
# Validate `style` values
|
|
90
|
-
style_values = [value for key, value in vars(NotificationStyles).items() if not key.startswith("__")]
|
|
91
|
-
if 'style' in inputted_kwargs and inputted_kwargs['style'] not in ['',*style_values]:
|
|
92
|
-
inputted_style=inputted_kwargs['style']
|
|
93
|
-
allowed_styles=', '.join(style_values)
|
|
94
|
-
raise ValueError(
|
|
95
|
-
f"Invalid style '{inputted_style}'. Allowed styles: {allowed_styles}"
|
|
96
|
-
)
|
|
97
|
-
|
|
@@ -6,7 +6,7 @@ from android_notify.internal.logger import logger
|
|
|
6
6
|
from android_notify.config import get_python_activity, on_android_platform, get_python_activity_context
|
|
7
7
|
from android_notify.internal.permissions import has_notification_permission, ask_notification_permission
|
|
8
8
|
from android_notify.internal.java_classes import autoclass, BuildVersion, BitmapFactory, NotificationChannel, NotificationManagerCompat, NotificationCompat, NotificationCompatBuilder, \
|
|
9
|
-
NotificationCompatBigTextStyle, NotificationCompatBigPictureStyle, NotificationCompatInboxStyle
|
|
9
|
+
NotificationCompatBigTextStyle, NotificationCompatBigPictureStyle, NotificationCompatInboxStyle, IconCompat
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
@@ -60,7 +60,6 @@ def get_image_uri(relative_path):
|
|
|
60
60
|
|
|
61
61
|
def get_icon_object(uri):
|
|
62
62
|
context = get_python_activity_context()
|
|
63
|
-
IconCompat = autoclass('android.graphics.drawable.Icon')
|
|
64
63
|
bitmap = BitmapFactory.decodeStream(context.getContentResolver().openInputStream(uri))
|
|
65
64
|
return IconCompat.createWithBitmap(bitmap)
|
|
66
65
|
|
|
@@ -115,7 +114,9 @@ def send_notification(
|
|
|
115
114
|
return None
|
|
116
115
|
context = get_python_activity_context()
|
|
117
116
|
|
|
118
|
-
|
|
117
|
+
|
|
118
|
+
asks_permission_if_needed()
|
|
119
|
+
|
|
119
120
|
channel_id = channel_name.replace(' ', '_').lower().lower() if not channel_id else channel_id
|
|
120
121
|
# Get notification manager
|
|
121
122
|
notification_manager = context.getSystemService(context.NOTIFICATION_SERVICE)
|
|
@@ -180,3 +180,24 @@ def force_vibrate(repeat=False):
|
|
|
180
180
|
else:
|
|
181
181
|
vibrator.vibrate(pattern, -1 if not repeat else 0)
|
|
182
182
|
return None
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def get_active_notification_ids(notification_manager=None) -> list:
|
|
186
|
+
"""
|
|
187
|
+
Returns the IDS of all currently active notifications for your app.
|
|
188
|
+
Android 6+
|
|
189
|
+
"""
|
|
190
|
+
active_notification_ids = []
|
|
191
|
+
if not on_android_platform():
|
|
192
|
+
return active_notification_ids
|
|
193
|
+
|
|
194
|
+
if BuildVersion.SDK_INT < 23:
|
|
195
|
+
return active_notification_ids
|
|
196
|
+
|
|
197
|
+
notification_manager = notification_manager or get_notification_manager()
|
|
198
|
+
activeNotifications = notification_manager.getActiveNotifications()
|
|
199
|
+
|
|
200
|
+
for status_bar_notification in activeNotifications:
|
|
201
|
+
active_notification_ids.append(status_bar_notification.getId())
|
|
202
|
+
|
|
203
|
+
return active_notification_ids
|
{android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/internal/java_classes.py
RENAMED
|
@@ -39,24 +39,31 @@ if on_android_platform():
|
|
|
39
39
|
Manifest = autoclass('android.Manifest$permission')
|
|
40
40
|
Color = autoclass('android.graphics.Color')
|
|
41
41
|
Context = autoclass('android.content.Context')
|
|
42
|
-
PackageManager = autoclass("android.content.pm.PackageManager")
|
|
43
42
|
except Exception as e:
|
|
44
43
|
from .facade import *
|
|
45
44
|
logger.exception("Didn't get Basic Java Classes")
|
|
46
45
|
|
|
47
46
|
# noinspection PyBroadException
|
|
48
47
|
try:
|
|
49
|
-
NotificationManagerCompat =
|
|
50
|
-
NotificationCompat = autoclass(
|
|
51
|
-
NotificationCompatBuilder = autoclass('
|
|
52
|
-
|
|
53
|
-
NotificationCompatBigPictureStyle = autoclass('android.app.Notification$BigPictureStyle')
|
|
54
|
-
NotificationCompatInboxStyle = autoclass('android.app.Notification$InboxStyle')
|
|
48
|
+
NotificationManagerCompat = autoclass('androidx.core.app.NotificationManagerCompat')
|
|
49
|
+
NotificationCompat = autoclass('androidx.core.app.NotificationCompat')
|
|
50
|
+
NotificationCompatBuilder = autoclass('androidx.core.app.NotificationCompat$Builder')
|
|
51
|
+
IconCompat = autoclass('androidx.core.graphics.drawable.IconCompat')
|
|
55
52
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
# Notification Design
|
|
54
|
+
NotificationCompatBigTextStyle = autoclass('androidx.core.app.NotificationCompat$BigTextStyle')
|
|
55
|
+
NotificationCompatBigPictureStyle = autoclass('androidx.core.app.NotificationCompat$BigPictureStyle')
|
|
56
|
+
NotificationCompatInboxStyle = autoclass('androidx.core.app.NotificationCompat$InboxStyle')
|
|
57
|
+
NotificationCompatDecoratedCustomViewStyle = autoclass('androidx.core.app.NotificationCompat$DecoratedCustomViewStyle')
|
|
58
|
+
|
|
59
|
+
except Exception as dependencies_import_error:
|
|
60
|
+
logger.exception("""
|
|
61
|
+
Dependency Error: Add the following in buildozer.spec:
|
|
62
|
+
* android.gradle_dependencies = androidx.core:core-ktx:1.15.0, androidx.core:core:1.6.0
|
|
63
|
+
* android.enable_androidx = True
|
|
64
|
+
""")
|
|
59
65
|
|
|
66
|
+
from .facade import *
|
|
60
67
|
else:
|
|
61
68
|
cast = lambda x, y: x
|
|
62
69
|
autoclass = lambda x: None
|
{android_notify-1.60.10.dev0 → android_notify-1.61.0}/android_notify/internal/permissions.py
RENAMED
|
@@ -5,7 +5,7 @@ import os.path
|
|
|
5
5
|
|
|
6
6
|
from .logger import logger
|
|
7
7
|
from android_notify.config import on_android_platform, on_flet_app, get_python_activity_context
|
|
8
|
-
from android_notify.internal.java_classes import autoclass, BuildVersion, Manifest, Intent, String, Settings, Uri,
|
|
8
|
+
from android_notify.internal.java_classes import autoclass, BuildVersion, Manifest, Intent, String, Settings, Uri, NotificationManagerCompat
|
|
9
9
|
from android_notify.internal.helper import execute_callback
|
|
10
10
|
|
|
11
11
|
|
|
@@ -19,10 +19,10 @@ def has_notification_permission():
|
|
|
19
19
|
|
|
20
20
|
if BuildVersion.SDK_INT < 33: # Android 12 and below
|
|
21
21
|
try:
|
|
22
|
-
# NotificationManagerCompat is actually NotificationManager from android_notify.internal.java_classes
|
|
23
22
|
context = get_python_activity_context()
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
func_from = getattr(NotificationManagerCompat, "from")
|
|
24
|
+
compat_manager = func_from(context)
|
|
25
|
+
return compat_manager.areNotificationsEnabled()
|
|
26
26
|
except Exception as error_checking_permission:
|
|
27
27
|
logger.exception(f"On Android 12 and below Error checking permission: {error_checking_permission}")
|
|
28
28
|
return None
|
|
@@ -30,8 +30,10 @@ def has_notification_permission():
|
|
|
30
30
|
if on_flet_app():
|
|
31
31
|
context = get_python_activity_context()
|
|
32
32
|
permission = Manifest.POST_NOTIFICATIONS
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
ContextCompat = autoclass('androidx.core.content.ContextCompat')
|
|
34
|
+
# if you get error `Failed to find class: androidx/core/app/ActivityCompat`
|
|
35
|
+
# in proguard-rules.pro add `-keep class androidx.core.app.ActivityCompat { *; }`
|
|
36
|
+
return ContextCompat.checkSelfPermission(context, permission)
|
|
35
37
|
else:
|
|
36
38
|
from android.permissions import Permission, check_permission # type: ignore
|
|
37
39
|
return check_permission(Permission.POST_NOTIFICATIONS)
|
|
@@ -80,10 +82,21 @@ def ask_notification_permission(callback=None, set_requesting_state=None, legacy
|
|
|
80
82
|
execute_callback(callback, grants[0])
|
|
81
83
|
execute_callback(set_requesting_state, False,from_who="package")
|
|
82
84
|
|
|
83
|
-
if legacy
|
|
85
|
+
if legacy:
|
|
84
86
|
# TODO Handle activity with request code
|
|
87
|
+
PackageManager = autoclass("android.content.pm.PackageManager")
|
|
88
|
+
permission = Manifest.POST_NOTIFICATIONS
|
|
89
|
+
|
|
90
|
+
granted = context.checkSelfPermission(permission)
|
|
91
|
+
if granted != PackageManager.PERMISSION_GRANTED:
|
|
92
|
+
context.requestPermissions([permission], 101)
|
|
93
|
+
return None
|
|
94
|
+
elif on_flet_app():
|
|
95
|
+
# TODO Callback when user answers request question
|
|
96
|
+
# Can't bind activity result method is from p4a which is only on kivy
|
|
97
|
+
ActivityCompat = autoclass('androidx.core.app.ActivityCompat')
|
|
85
98
|
permission = Manifest.POST_NOTIFICATIONS
|
|
86
|
-
|
|
99
|
+
ActivityCompat.requestPermissions(context, [permission], 101)
|
|
87
100
|
return None
|
|
88
101
|
else:
|
|
89
102
|
from android.permissions import request_permissions, Permission # type: ignore
|