-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: set custom ringtones for contacts (closes #305)
- Loading branch information
1 parent
bbc969a
commit 59aaad5
Showing
6 changed files
with
134 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
app/src/main/java/com/bnyro/contacts/util/RingtonePickContract.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.bnyro.contacts.util | ||
|
||
import android.app.Activity | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.media.RingtoneManager | ||
import android.net.Uri | ||
import androidx.activity.result.contract.ActivityResultContract | ||
import com.bnyro.contacts.R | ||
|
||
class RingtonePickContract : ActivityResultContract<Void?, Uri?>() { | ||
override fun createIntent(context: Context, input: Void?): Intent { | ||
return Intent(RingtoneManager.ACTION_RINGTONE_PICKER).apply { | ||
putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_RINGTONE) | ||
putExtra( | ||
RingtoneManager.EXTRA_RINGTONE_TITLE, | ||
context.getString(R.string.select_custom_ringtone) | ||
) | ||
} | ||
} | ||
|
||
override fun parseResult(resultCode: Int, intent: Intent?): Uri? { | ||
return intent.takeIf { resultCode == Activity.RESULT_OK } | ||
?.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters