Skip to content

Commit 654e4ea

Browse files
committed
safe sync
1 parent c8200a6 commit 654e4ea

7 files changed

Lines changed: 574 additions & 44 deletions

File tree

README.md

Lines changed: 82 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -63,45 +63,21 @@ In your **`buildozer.spec`** file, ensure you include the following:
6363
requirements = python3, kivy, pyjnius, android-notify
6464
# Add permission for notifications
6565
android.permissions = POST_NOTIFICATIONS
66-
67-
# Required dependency (write exactly as shown, no quotation marks)
68-
android.gradle_dependencies = androidx.core:core:1.12.0
69-
android.enable_androidx = True
70-
android.api = 35
71-
```
72-
73-
</details>
74-
75-
<details>
76-
<summary><b>Desktop</b></summary>
77-
<br/>
78-
79-
For IDE IntelliSense Can be installed via `pip install`:
80-
81-
```bash
82-
pip install android_notify
83-
android-notify -v
8466
```
8567

8668
</details>
8769

88-
------
89-
## Installing without Androidx
90-
How to use without `gradle_dependencies`
91-
Use `android-notify==1.61.3.dev0` to install via `pip`
92-
93-
9470
<details>
9571
<summary><b>Flet apps:</b></summary>
9672
<br/>
9773

98-
In your `pyproject.toml` file, ensure you include the following:
74+
In your `pyproject.toml` file, ensure you include the following:
9975

10076

10177
```toml
10278
[tool.flet.android]
10379
dependencies = [
104-
"pyjnius","android-notify==1.61.3.dev0"
80+
"pyjnius","android-notify"
10581
]
10682

10783
[tool.flet.android.permission]
@@ -111,27 +87,15 @@ dependencies = [
11187

11288
</details>
11389

114-
<details>
115-
<summary><b>In Kivy</b></summary>
116-
<br/>
117-
118-
```ini
119-
# buildozer.spec
120-
requirements = python3, kivy, pyjnius, android-notify==1.61.3.dev0
121-
```
122-
123-
</details>
124-
12590
<details>
12691

12792
<summary><b>On Pydroid 3</b></summary>
12893
<br/>
12994

13095
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.
131-
- In pip section where you're asked to insert `Libary name` paste `android-notify==1.61.3.dev0`
96+
- In pip section where you're asked to insert `Libary name` paste `android-notify`
13297
- Minimal working example
13398
```py
134-
# Testing with `android-notify==1.61.3.dev0` on pydroid
13599
from kivy.app import App
136100
from kivy.uix.boxlayout import BoxLayout
137101
from kivy.uix.button import Button
@@ -169,13 +133,87 @@ if __name__ == "__main__":
169133
</details>
170134

171135

136+
<details>
137+
138+
<summary><b>Desktop</b></summary>
139+
<br/>
140+
141+
For IDE IntelliSense Can be installed via `pip install`:
142+
143+
```bash
144+
pip install android_notify
145+
android-notify -v
146+
```
147+
</details>
172148

173149
## Documentation
174150
For Dev Version usage
175151
```ini
176152
requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_notify/archive/main.zip
177153
```
178154

155+
<details>
156+
<summary> <b>To use Custom Sounds </b> </summary>
157+
158+
**Option 1: Audio files bundled in `res/raw`**
159+
160+
- Put audio files in `res/raw` folder,
161+
- Then from `buildozer.spec` point to res folder `android.add_resources = res`
162+
- and includes it's format `source.include_exts = wav`.
163+
164+
Lastly From the code
165+
```py
166+
# Create a custom notification channel with a unique sound resource for android 8+
167+
Notification.createChannel(
168+
id="weird_sound_tester",
169+
name="Weird Sound Tester",
170+
description="A test channel for custom sounds from the res/raw folder.",
171+
res_sound_name="sneeze" # file name without .wav or .mp3
172+
)
173+
174+
# Send a notification through the created channel
175+
n=Notification(
176+
title="Custom Sound Notification",
177+
message="This tests playback of a custom sound (sneeze.wav) stored in res/raw.",
178+
channel_id="weird_sound_tester" # important tells notification to use right channel
179+
)
180+
n.setSound("sneeze")# for android 7 below
181+
n.send()
182+
```
183+
184+
**Option 2: Local file path or URI (`sound_path`)**
185+
186+
You can use a local audio file, a `content://`, `file://`, or `android.resource://` URI directly:
187+
188+
```py
189+
# Using a local file path
190+
Notification.createChannel(
191+
id="local_sound",
192+
name="Local Sound",
193+
sound_path="/storage/emulated/0/Download/alert.mp3"
194+
)
195+
196+
# Using a content URI (e.g., from media store)
197+
Notification.createChannel(
198+
id="uri_sound",
199+
name="URI Sound",
200+
sound_path="content://media/external/audio/media/123"
201+
)
202+
203+
# Send notification with custom sound path
204+
n = Notification(
205+
title="Custom Sound",
206+
message="Playing from local path",
207+
channel_id="local_sound"
208+
)
209+
n.setSound(sound_path="/storage/emulated/0/Download/alert.mp3")
210+
n.send()
211+
```
212+
213+
Private files (e.g., in app's `data/` directory) are automatically copied to external storage before playing.
214+
</details>
215+
216+
179217
<details>
180218
<summary> <b> Add Data to Notification</b> </summary>
181219

@@ -207,9 +245,12 @@ from android_notify import Notification, NotificationHandler
207245

208246
## ☕ Support the Project
209247

210-
If you find this project helpful, your support would help me continue working on open-source projects
211-
[donate](https://www.buymeacoffee.com/fector101)
248+
If you find this project helpful, consider buying me a coffee! 😊
249+
Or Giving it a star on 🌟 [GitHub](https://github.com/Fector101/android_notify/) Your support helps maintain and improve the project.
212250

251+
<a href="https://www.buymeacoffee.com/fector101" target="_blank">
252+
<img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60">
253+
</a>
213254

214255
## Bug Reports & Feature Requests
215256

android_notify/tests/buildozer.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ android.api = 35
2828
android.permissions = INTERNET, VIBRATE, USE_EXACT_ALARM, SCHEDULE_EXACT_ALARM, FOREGROUND_SERVICE, FOREGROUND_SERVICE_DATA_SYNC, POST_NOTIFICATIONS, SET_WALLPAPER, READ_MEDIA_IMAGES, (name=android.permission.READ_EXTERNAL_STORAGE;maxSdkVersion=32), (name=android.permission.WRITE_EXTERNAL_STORAGE;maxSdkVersion=28)
2929
android.add_src = %(source.dir)s/android/src
3030
android.add_resources = %(source.dir)s/android/res
31-
android.gradle_dependencies = androidx.core:core-ktx:1.15.0
31+
android.gradle_dependencies = androidx.core:core:1.12.0
3232
p4a.hook = %(source.dir)s/android/p4a/hook.py
3333

3434
android.archs = arm64-v8a

0 commit comments

Comments
 (0)