From ff0bd1f42ad95b6c0780111908b2e9db9506ba86 Mon Sep 17 00:00:00 2001 From: Jaewoong Eum Date: Fri, 5 Apr 2024 10:45:58 +0900 Subject: [PATCH] Implement onPermissionResult callback for launching camera & microphone permissions (#1057) --- .../api/stream-video-android-ui-compose.api | 4 ++-- .../compose/permission/SinglePermission.kt | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/stream-video-android-ui-compose/api/stream-video-android-ui-compose.api b/stream-video-android-ui-compose/api/stream-video-android-ui-compose.api index 8355d94274..90c04e66ce 100644 --- a/stream-video-android-ui-compose/api/stream-video-android-ui-compose.api +++ b/stream-video-android-ui-compose/api/stream-video-android-ui-compose.api @@ -29,8 +29,8 @@ public abstract interface class io/getstream/video/android/compose/permission/La } public final class io/getstream/video/android/compose/permission/SinglePermissionKt { - public static final fun LaunchCameraPermissions (Lio/getstream/video/android/core/Call;Landroidx/compose/runtime/Composer;I)V - public static final fun LaunchMicrophonePermissions (Lio/getstream/video/android/core/Call;Landroidx/compose/runtime/Composer;I)V + public static final fun LaunchCameraPermissions (Lio/getstream/video/android/core/Call;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;I)V + public static final fun LaunchMicrophonePermissions (Lio/getstream/video/android/core/Call;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;I)V public static final fun rememberBluetoothPermissionState (Lio/getstream/video/android/core/Call;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;I)Lio/getstream/video/android/compose/permission/VideoPermissionsState; public static final fun rememberCameraPermissionState (Lio/getstream/video/android/core/Call;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;II)Lio/getstream/video/android/compose/permission/VideoPermissionsState; public static final fun rememberMicrophonePermissionState (Lio/getstream/video/android/core/Call;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;II)Lio/getstream/video/android/compose/permission/VideoPermissionsState; diff --git a/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/permission/SinglePermission.kt b/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/permission/SinglePermission.kt index b663cdfa8f..e5b6a462f0 100644 --- a/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/permission/SinglePermission.kt +++ b/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/permission/SinglePermission.kt @@ -52,8 +52,12 @@ public fun rememberCameraPermissionState( * - android.Manifest.permission.CAMERA */ @Composable -public fun LaunchCameraPermissions(call: Call) { - val callPermissionsState = rememberCameraPermissionState(call = call) +public fun LaunchCameraPermissions( + call: Call, + onPermissionsResult: (Boolean) -> Unit, +) { + val callPermissionsState = + rememberCameraPermissionState(call = call, onPermissionsResult = onPermissionsResult) LaunchedEffect(key1 = call) { callPermissionsState.launchPermissionRequest() } } @@ -87,8 +91,12 @@ public fun rememberMicrophonePermissionState( * - android.Manifest.permission.RECORD_AUDIO */ @Composable -public fun LaunchMicrophonePermissions(call: Call) { - val callPermissionsState = rememberMicrophonePermissionState(call = call) +public fun LaunchMicrophonePermissions( + call: Call, + onPermissionsResult: (Boolean) -> Unit, +) { + val callPermissionsState = + rememberMicrophonePermissionState(call = call, onPermissionsResult = onPermissionsResult) LaunchedEffect(key1 = call) { callPermissionsState.launchPermissionRequest() } }