mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-19 07:15:25 +02:00
feat: Add permission check
This commit is contained in:
parent
096cf56436
commit
459a0b18ba
@ -170,6 +170,13 @@ fun VideoRecorderPreparationSheet(
|
|||||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
) {
|
) {
|
||||||
|
PermissionRequester(
|
||||||
|
permission = Manifest.permission.CAMERA,
|
||||||
|
icon = Icons.Default.CameraAlt,
|
||||||
|
onPermissionAvailable = {
|
||||||
|
onStartRecording()
|
||||||
|
}
|
||||||
|
) { trigger ->
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
@ -186,7 +193,7 @@ fun VideoRecorderPreparationSheet(
|
|||||||
onPreviewVisible()
|
onPreviewVisible()
|
||||||
},
|
},
|
||||||
onTap = {
|
onTap = {
|
||||||
onStartRecording()
|
trigger()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@ -199,6 +206,7 @@ fun VideoRecorderPreparationSheet(
|
|||||||
color = MaterialTheme.colorScheme.onPrimary,
|
color = MaterialTheme.colorScheme.onPrimary,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Text(
|
Text(
|
||||||
stringResource(
|
stringResource(
|
||||||
R.string.ui_videoRecorder_action_preview_label
|
R.string.ui_videoRecorder_action_preview_label
|
||||||
|
@ -46,6 +46,7 @@ import app.myzel394.alibi.db.AppSettings
|
|||||||
import app.myzel394.alibi.ui.BIG_PRIMARY_BUTTON_SIZE
|
import app.myzel394.alibi.ui.BIG_PRIMARY_BUTTON_SIZE
|
||||||
import app.myzel394.alibi.ui.components.atoms.PermissionRequester
|
import app.myzel394.alibi.ui.components.atoms.PermissionRequester
|
||||||
import app.myzel394.alibi.ui.models.VideoRecorderModel
|
import app.myzel394.alibi.ui.models.VideoRecorderModel
|
||||||
|
import app.myzel394.alibi.ui.utils.PermissionHelper
|
||||||
|
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
@ -97,7 +98,18 @@ fun VideoRecordingStart(
|
|||||||
interactionSource = remember { MutableInteractionSource() },
|
interactionSource = remember { MutableInteractionSource() },
|
||||||
indication = rememberRipple(color = MaterialTheme.colorScheme.primary),
|
indication = rememberRipple(color = MaterialTheme.colorScheme.primary),
|
||||||
onClick = {
|
onClick = {
|
||||||
|
if (PermissionHelper.hasGranted(
|
||||||
|
context,
|
||||||
|
Manifest.permission.CAMERA
|
||||||
|
) && PermissionHelper.hasGranted(
|
||||||
|
context,
|
||||||
|
Manifest.permission.RECORD_AUDIO
|
||||||
|
)
|
||||||
|
) {
|
||||||
videoRecorder.startRecording(context, appSettings)
|
videoRecorder.startRecording(context, appSettings)
|
||||||
|
} else {
|
||||||
|
showSheet = true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onLongClick = {
|
onLongClick = {
|
||||||
showSheet = true
|
showSheet = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user