Address PR review comments.

- use util startNotificationSettingsIntent.
- add documentation.
- use remember with userPushStoreFactory for recomposition.
This commit is contained in:
David Langley 2023-09-13 21:03:52 +01:00
parent 5e8cb958f8
commit 004abd16dc
7 changed files with 22 additions and 11 deletions

View file

@ -122,7 +122,7 @@ fun Context.copyToClipboard(
* Shows notification settings for the current app.
* In android O will directly opens the notification settings, in lower version it will show the App settings
*/
fun Context.startNotificationSettingsIntent(activityResultLauncher: ActivityResultLauncher<Intent>) {
fun Context.startNotificationSettingsIntent(activityResultLauncher: ActivityResultLauncher<Intent>? = null) {
val intent = Intent()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
intent.action = Settings.ACTION_APP_NOTIFICATION_SETTINGS
@ -132,7 +132,12 @@ fun Context.startNotificationSettingsIntent(activityResultLauncher: ActivityResu
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.data = Uri.fromParts("package", packageName, null)
}
activityResultLauncher.launch(intent)
if (activityResultLauncher != null) {
activityResultLauncher.launch(intent)
} else {
startActivity(intent)
}
}
fun Context.openAppSettingsPage(