Skip to content
An Android music picker library for picking alarm, notification or ringtones sound using an Activity or a dialog.
Kotlin
Branch: master
Clone or download
Latest commit 7adda54 Oct 10, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app Add build tools version and set root project name Oct 1, 2019
art New icons Oct 1, 2019
gradle/wrapper Grale 5.6.2 and stable androidx libries Sep 7, 2019
library Remove a redundant requireNotNull Oct 10, 2019
.gitignore Update .gitignore Jun 30, 2019
.travis.yml Trying to fix travis Sep 7, 2019
LICENSE Upgrade version and LICENSE Jan 10, 2019
README.md Fix broken image links Oct 10, 2019
README_OLD.md Fix broken image links Oct 10, 2019
build.gradle Refactoring, lots of changes. Aug 27, 2019
dependencies.gradle
gradle.properties Migrate to androidx Sep 23, 2018
gradlew Add execute permission to gradlew Aug 27, 2019
gradlew.bat Create empty project Sep 15, 2018
settings.gradle Add build tools version and set root project name Oct 1, 2019

README.md

UltimateRingtonePicker

Pick ringtone, notification, alarm sound and ringtone files from external storage with an activity or a dialog


3.0 API has been changed completely. Currently it's in the alpha. Everything may be changed.

Click here to use the deprecated 2.X.

Features

  • Respects Scoped Storage(MediaStore is used)
  • Available as an Activity and a Dialog
  • Provides options to pick alarm sound, notification sound, ringtone sound and external ringtones.
  • Ringtone preview
  • Provides interface to set a default entry
  • Provides interface to add custom ringtone entries
  • Sorts external ringtones with artists, albums and folders
  • Automatically remembers which external ringtones users picked
  • Multi Select
  • Dark theme support out of box
  • Permission are handled internally
  • Storage Access Framework support

This library targets Android 29 and uses appcompat 1.1.0.

Screenshot

Activity Dialog Dark

Gradle Dependency

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Step 2. Add the dependency

The Newest Version

dependencies {
    implementation "com.github.DeweyReed:UltimateRingtonePicker:${version}"
}

Usage

Here're some examples:

System ringtones dialog(no permission required)

RingtonePickerDialog.createInstance(
    UltimateRingtonePicker.Settings(
        showCustomRingtone = false,
        systemRingtoneTypes = UltimateRingtonePicker.Settings.allSystemRingtoneTypes
    ),
    "Dialog Picker"
).show(supportFragmentManager, null)

To receive the pick result, implement RingtonePickerListener in your activity or fragment.

System and device ringtones activity(Permission is handled internally)

Add RingtonePickerActivity to your AndroidManifest.xml:

<activity
    android:name="xyz.aprildown.ultimateringtonepicker.RingtonePickerActivity" />
startActivityForResult(
    RingtonePickerActivity.putInfoToLaunchIntent(
        Intent(this, RingtonePickerActivity::class.java),
            UltimateRingtonePicker.Settings(
            showDefault = true,
            defaultUri = UltimateRingtonePicker.Settings.createRawUri(this, R.raw.default_ringtone),
            defaultTitle = "Default Ringtone",
            additionalRingtones = listOf(
                RingtonePickerEntry(
                    UltimateRingtonePicker.Settings.createAssetUri("asset1.wav"),
                    "Assets/asset1.mp3"
                )
            ),
            systemRingtoneTypes = UltimateRingtonePicker.Settings.allSystemRingtoneTypes,
            deviceRingtoneTypes = UltimateRingtonePicker.Settings.allDeviceRingtoneTypes
        ),
        "Activity Picker"
    ),
    // Request Code
    200
)

Receive the pick result in your onActivityResult:

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    // You must check requestCode here because RingtonePickerFragment may
    // startActivityForResult internally and require super.onActivityResult here to be called.
    if (requestCode == 200 && resultCode == Activity.RESULT_OK && data != null) {
        val ringtones: List<RingtonePickerEntry> = RingtonePickerActivity.getPickerResult(data)

    } else {
        super.onActivityResult(requestCode, resultCode, data)
    }
}

More examples

You can find many examples in MainActivity. Also make sure check UltimateRingtonePicker to see all parameters.

BTW

UltimateRingtonePicker supports activity pick RingtonePickerActivity and dialog pick RingtonePickerDialog out of 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

You can’t perform that action at this time.