Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/DeweyReed/UltimateRingtonePicker
An Android music picker library for picking alarm, notification or ringtones sound using an Activity or a dialog.
https://github.com/DeweyReed/UltimateRingtonePicker
android android-library android-pickerdialog android-pickers music-library picker ringtone-picker
Last synced: 14 days ago
JSON representation
An Android music picker library for picking alarm, notification or ringtones sound using an Activity or a dialog.
- Host: GitHub
- URL: https://github.com/DeweyReed/UltimateRingtonePicker
- Owner: DeweyReed
- License: mit
- Created: 2018-09-15T03:44:11.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-04-13T23:45:10.000Z (7 months ago)
- Last Synced: 2024-08-01T16:51:08.557Z (3 months ago)
- Topics: android, android-library, android-pickerdialog, android-pickers, music-library, picker, ringtone-picker
- Language: Kotlin
- Homepage:
- Size: 1000 KB
- Stars: 63
- Watchers: 4
- Forks: 10
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
UltimateRingtonePicker
Pick ringtone, notification, alarm sound and ringtone files from external storage with an activity or a dialog
## Features
- Respects Scoped Storage(MediaStore is used)
- Available as an Activity and a Dialog
- Options to pick alarm sound, notification sound, ringtone sound, and external ringtones.
- Ringtone preview
- An interface to set a default entry
- An interface to add custom ringtone entries
- Sorted external ringtones with artists, albums and folders
- Automatically remembers which external ringtones users have picked
- Multi-select
- Dark theme support out of box
- Permissions are handled internally
- Storage Access Framework supportThe library is inspired by [AOSP DeskClock RingtonePickerActivity](https://android.googlesource.com/platform/packages/apps/DeskClock/+/refs/heads/master/src/com/android/deskclock/ringtone/RingtonePickerActivity.kt).
## Screenshot
||||
|:-:|:-:|:-:|
|![Activity](./art/activity.webp)|![Dialog](./art/dialog.webp)|![Dark](./art/dark.webp)|## Gradle Dependency
Step 1. Add the JitPack repository to your build file
Add it in your root build.gradle at the end of repositories:
```Groovy
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
```Step 2. Add the dependency
[![The Newest Version](https://jitpack.io/v/com.github.DeweyReed/UltimateRingtonePicker.svg)](https://jitpack.io/#com.github.DeweyReed/UltimateRingtonePicker)
```Groovy
dependencies {
implementation 'com.github.DeweyReed:UltimateRingtonePicker:3.2.0'
}
```## Usage
[Demo APK](https://github.com/deweyreed/ultimateringtonepicker/releases) and [examples in the MainActivity](./app/src/main/java/xyz/aprildown/ultimateringtonepicker/app/MainActivity.kt).
### 0. Add Permission
Add ``
or `` when targeting Android
13 to your Manifest if you are not going to use Storage Access Framework.### 1. Create an `UltimateRingtonePicker.Settings`
```Kotlin
val settings = UltimateRingtonePicker.Settings(
systemRingtonePicker = UltimateRingtonePicker.SystemRingtonePicker(
customSection = UltimateRingtonePicker.SystemRingtonePicker.CustomSection(),
defaultSection = UltimateRingtonePicker.SystemRingtonePicker.DefaultSection(),
ringtoneTypes = listOf(
RingtoneManager.TYPE_RINGTONE,
RingtoneManager.TYPE_NOTIFICATION,
RingtoneManager.TYPE_ALARM
)
),
deviceRingtonePicker = UltimateRingtonePicker.DeviceRingtonePicker(
deviceRingtoneTypes = listOf(
UltimateRingtonePicker.RingtoneCategoryType.All,
UltimateRingtonePicker.RingtoneCategoryType.Artist,
UltimateRingtonePicker.RingtoneCategoryType.Album,
UltimateRingtonePicker.RingtoneCategoryType.Folder
)
)
)
```### 2. Launch the picker
- Launch the Activity picker
1. Add the Activity to the manifest.
``
1. Register Activity Result callback
```Kotlin
rivate val ringtoneLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
if (it.resultCode == Activity.RESULT_OK && it.data != null) {
val ringtones = RingtonePickerActivity.getPickerResult(data)
}
}
```1. Start Activity
```Kotlin
ringtoneLauncher.launch(
RingtonePickerActivity.getIntent(
context = this,
settings = settings,
windowTitle = "Activity Picker"
)
)
```- Launch the dialog picker
1. Show the dialog
```Kotlin
RingtonePickerDialog.createInstance(
settings = settings,
dialogTitle = "Dialog!"
).show(supportFragmentManager, null)
```1. Get the result
Implement `UltimateRingtonePicker.RingtonePickerListener` in your activity or fragment.
```Kotlin
override fun onRingtonePicked(ringtones: List) {}
```Alternatively, you can launch the dialog and get the result without implementing the interface, but the dialog will be dismissed in `onPause`:
```Kotlin
RingtonePickerDialog.createEphemeralInstance(
settings = settings,
dialogTitle = "Dialog",
listener = object : UltimateRingtonePicker.RingtonePickerListener {
override fun onRingtonePicked(ringtones: List) {}
}
).show(supportFragmentManager, null)
```## BTW
`UltimateRingtonePicker` supports activity pick `RingtonePickerActivity` and dialog pick `RingtonePickerDialog` out of the box. Both of them are just wrappers of `RingtonePickerFragment`. Therefore, you can directly wrap `RingtonePickerFragment` into your activity/fragment to provide more customization!
## License
[MIT License](./LICENSE)