mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-18 23:05:26 +02:00
feat: Add permission check
This commit is contained in:
parent
096cf56436
commit
459a0b18ba
@ -170,34 +170,42 @@ fun VideoRecorderPreparationSheet(
|
|||||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
) {
|
) {
|
||||||
Row(
|
PermissionRequester(
|
||||||
modifier = Modifier
|
permission = Manifest.permission.CAMERA,
|
||||||
.fillMaxWidth()
|
icon = Icons.Default.CameraAlt,
|
||||||
.height(BIG_PRIMARY_BUTTON_SIZE)
|
onPermissionAvailable = {
|
||||||
.clip(CircleShape)
|
onStartRecording()
|
||||||
.background(MaterialTheme.colorScheme.primary)
|
}
|
||||||
.padding(16.dp)
|
) { trigger ->
|
||||||
.semantics {
|
Row(
|
||||||
contentDescription = label
|
modifier = Modifier
|
||||||
}
|
.fillMaxWidth()
|
||||||
.pointerInput(Unit) {
|
.height(BIG_PRIMARY_BUTTON_SIZE)
|
||||||
detectTapGestures(
|
.clip(CircleShape)
|
||||||
onLongPress = {
|
.background(MaterialTheme.colorScheme.primary)
|
||||||
onPreviewVisible()
|
.padding(16.dp)
|
||||||
},
|
.semantics {
|
||||||
onTap = {
|
contentDescription = label
|
||||||
onStartRecording()
|
}
|
||||||
}
|
.pointerInput(Unit) {
|
||||||
)
|
detectTapGestures(
|
||||||
},
|
onLongPress = {
|
||||||
horizontalArrangement = Arrangement.Center,
|
onPreviewVisible()
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
},
|
||||||
) {
|
onTap = {
|
||||||
Text(
|
trigger()
|
||||||
label,
|
}
|
||||||
style = MaterialTheme.typography.labelLarge,
|
)
|
||||||
color = MaterialTheme.colorScheme.onPrimary,
|
},
|
||||||
)
|
horizontalArrangement = Arrangement.Center,
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
label,
|
||||||
|
style = MaterialTheme.typography.labelLarge,
|
||||||
|
color = MaterialTheme.colorScheme.onPrimary,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
stringResource(
|
stringResource(
|
||||||
|
@ -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 = {
|
||||||
videoRecorder.startRecording(context, appSettings)
|
if (PermissionHelper.hasGranted(
|
||||||
|
context,
|
||||||
|
Manifest.permission.CAMERA
|
||||||
|
) && PermissionHelper.hasGranted(
|
||||||
|
context,
|
||||||
|
Manifest.permission.RECORD_AUDIO
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
videoRecorder.startRecording(context, appSettings)
|
||||||
|
} else {
|
||||||
|
showSheet = true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onLongClick = {
|
onLongClick = {
|
||||||
showSheet = true
|
showSheet = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user