android: update video item layout, add video behind experimental toggle (#2109)
* android: update video item layout, add video behind experimental toggle
* video duration / size design
* refactor, fix duration box size
* more readable
* reuse box modifier
* Revert "reuse box modifier"
This reverts commit d0d2d3e402.
This commit is contained in:
committed by
GitHub
parent
400a3707b2
commit
9b627534f5
@@ -134,6 +134,7 @@ fun ChatView(chatId: String, chatModel: ChatModel, onComposed: () -> Unit) {
|
|||||||
searchText,
|
searchText,
|
||||||
useLinkPreviews = useLinkPreviews,
|
useLinkPreviews = useLinkPreviews,
|
||||||
linkMode = chatModel.simplexLinkMode.value,
|
linkMode = chatModel.simplexLinkMode.value,
|
||||||
|
allowVideoAttachment = chatModel.controller.appPrefs.xftpSendEnabled.get(),
|
||||||
chatModelIncognito = chatModel.incognito.value,
|
chatModelIncognito = chatModel.incognito.value,
|
||||||
back = {
|
back = {
|
||||||
hideKeyboard(view)
|
hideKeyboard(view)
|
||||||
@@ -307,6 +308,7 @@ fun ChatLayout(
|
|||||||
searchValue: State<String>,
|
searchValue: State<String>,
|
||||||
useLinkPreviews: Boolean,
|
useLinkPreviews: Boolean,
|
||||||
linkMode: SimplexLinkMode,
|
linkMode: SimplexLinkMode,
|
||||||
|
allowVideoAttachment: Boolean,
|
||||||
chatModelIncognito: Boolean,
|
chatModelIncognito: Boolean,
|
||||||
back: () -> Unit,
|
back: () -> Unit,
|
||||||
info: () -> Unit,
|
info: () -> Unit,
|
||||||
@@ -338,6 +340,7 @@ fun ChatLayout(
|
|||||||
sheetContent = {
|
sheetContent = {
|
||||||
ChooseAttachmentView(
|
ChooseAttachmentView(
|
||||||
attachmentOption,
|
attachmentOption,
|
||||||
|
allowVideoAttachment,
|
||||||
hide = { scope.launch { attachmentBottomSheetState.hide() } }
|
hide = { scope.launch { attachmentBottomSheetState.hide() } }
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@@ -1078,6 +1081,7 @@ fun PreviewChatLayout() {
|
|||||||
searchValue,
|
searchValue,
|
||||||
useLinkPreviews = true,
|
useLinkPreviews = true,
|
||||||
linkMode = SimplexLinkMode.DESCRIPTION,
|
linkMode = SimplexLinkMode.DESCRIPTION,
|
||||||
|
allowVideoAttachment = true,
|
||||||
chatModelIncognito = false,
|
chatModelIncognito = false,
|
||||||
back = {},
|
back = {},
|
||||||
info = {},
|
info = {},
|
||||||
@@ -1138,6 +1142,7 @@ fun PreviewGroupChatLayout() {
|
|||||||
searchValue,
|
searchValue,
|
||||||
useLinkPreviews = true,
|
useLinkPreviews = true,
|
||||||
linkMode = SimplexLinkMode.DESCRIPTION,
|
linkMode = SimplexLinkMode.DESCRIPTION,
|
||||||
|
allowVideoAttachment = true,
|
||||||
chatModelIncognito = false,
|
chatModelIncognito = false,
|
||||||
back = {},
|
back = {},
|
||||||
info = {},
|
info = {},
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ private fun VideoView(uri: Uri, file: CIFile, defaultPreview: Bitmap, defaultDur
|
|||||||
private fun BoxScope.PlayButton(error: Boolean = false, onLongClick: () -> Unit, onClick: () -> Unit) {
|
private fun BoxScope.PlayButton(error: Boolean = false, onLongClick: () -> Unit, onClick: () -> Unit) {
|
||||||
Surface(
|
Surface(
|
||||||
Modifier.align(Alignment.Center),
|
Modifier.align(Alignment.Center),
|
||||||
color = Color.White.copy(alpha = 0.8f),
|
color = Color.Black.copy(alpha = 0.25f),
|
||||||
shape = RoundedCornerShape(percent = 50)
|
shape = RoundedCornerShape(percent = 50)
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
@@ -163,7 +163,7 @@ private fun BoxScope.PlayButton(error: Boolean = false, onLongClick: () -> Unit,
|
|||||||
imageVector = Icons.Filled.PlayArrow,
|
imageVector = Icons.Filled.PlayArrow,
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
Modifier.size(25.dp),
|
Modifier.size(25.dp),
|
||||||
tint = if (error) WarningOrange else MaterialTheme.colors.primary
|
tint = if (error) WarningOrange else Color.White
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -176,15 +176,15 @@ private fun DurationProgress(file: CIFile, playing: MutableState<Boolean>, durat
|
|||||||
Box(
|
Box(
|
||||||
Modifier
|
Modifier
|
||||||
.padding(DEFAULT_PADDING_HALF)
|
.padding(DEFAULT_PADDING_HALF)
|
||||||
.background(Color.Black.copy(alpha = 0.4f), MaterialTheme.shapes.small)
|
.background(Color.Black.copy(alpha = 0.35f), RoundedCornerShape(percent = 50))
|
||||||
.padding(vertical = 2.dp, horizontal = 4.dp)
|
.padding(vertical = 2.dp, horizontal = 4.dp)
|
||||||
) {
|
) {
|
||||||
val time = (if (progress.value > 0) durationText((progress.value / 1000).toInt()) else durationText((duration.value / 1000).toInt()))
|
val time = if (progress.value > 0) progress.value else duration.value
|
||||||
val sp30 = with(LocalDensity.current) { 30.sp.toDp() }
|
val timeStr = durationText((time / 1000).toInt())
|
||||||
val sp45 = with(LocalDensity.current) { 45.sp.toDp() }
|
val width = if (timeStr.length <= 5) 44 else 50
|
||||||
Text(
|
Text(
|
||||||
time,
|
timeStr,
|
||||||
Modifier.widthIn(min = if (time.length <= 5) sp30 else sp45),
|
Modifier.widthIn(min = with(LocalDensity.current) { width.sp.toDp() }).padding(horizontal = 4.dp),
|
||||||
fontSize = 13.sp,
|
fontSize = 13.sp,
|
||||||
color = Color.White
|
color = Color.White
|
||||||
)
|
)
|
||||||
@@ -199,11 +199,12 @@ private fun DurationProgress(file: CIFile, playing: MutableState<Boolean>, durat
|
|||||||
Box(
|
Box(
|
||||||
Modifier
|
Modifier
|
||||||
.padding(top = DEFAULT_PADDING_HALF)
|
.padding(top = DEFAULT_PADDING_HALF)
|
||||||
.background(Color.Black.copy(alpha = 0.4f), MaterialTheme.shapes.small)
|
.background(Color.Black.copy(alpha = 0.35f), RoundedCornerShape(percent = 50))
|
||||||
.padding(vertical = 2.dp, horizontal = 4.dp)
|
.padding(vertical = 2.dp, horizontal = 4.dp)
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
formatBytes(file.fileSize),
|
formatBytes(file.fileSize),
|
||||||
|
Modifier.padding(horizontal = 4.dp),
|
||||||
fontSize = 13.sp,
|
fontSize = 13.sp,
|
||||||
color = Color.White
|
color = Color.White
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ sealed class AttachmentOption {
|
|||||||
@Composable
|
@Composable
|
||||||
fun ChooseAttachmentView(
|
fun ChooseAttachmentView(
|
||||||
attachmentOption: MutableState<AttachmentOption?>,
|
attachmentOption: MutableState<AttachmentOption?>,
|
||||||
|
allowVideoAttachment: Boolean,
|
||||||
hide: () -> Unit
|
hide: () -> Unit
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
@@ -46,10 +47,12 @@ fun ChooseAttachmentView(
|
|||||||
attachmentOption.value = AttachmentOption.PickImage
|
attachmentOption.value = AttachmentOption.PickImage
|
||||||
hide()
|
hide()
|
||||||
}
|
}
|
||||||
|
if (allowVideoAttachment) {
|
||||||
ActionButton(null, stringResource(R.string.from_gallery_button), icon = Icons.Outlined.Videocam) {
|
ActionButton(null, stringResource(R.string.from_gallery_button), icon = Icons.Outlined.Videocam) {
|
||||||
attachmentOption.value = AttachmentOption.PickVideo
|
attachmentOption.value = AttachmentOption.PickVideo
|
||||||
hide()
|
hide()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ActionButton(null, stringResource(R.string.choose_file), icon = Icons.Outlined.InsertDriveFile) {
|
ActionButton(null, stringResource(R.string.choose_file), icon = Icons.Outlined.InsertDriveFile) {
|
||||||
attachmentOption.value = AttachmentOption.PickFile
|
attachmentOption.value = AttachmentOption.PickFile
|
||||||
hide()
|
hide()
|
||||||
|
|||||||
@@ -736,7 +736,7 @@
|
|||||||
<string name="settings_section_title_calls">CALLS</string>
|
<string name="settings_section_title_calls">CALLS</string>
|
||||||
<string name="settings_section_title_incognito">Incognito mode</string>
|
<string name="settings_section_title_incognito">Incognito mode</string>
|
||||||
<string name="settings_section_title_experimenta">EXPERIMENTAL</string>
|
<string name="settings_section_title_experimenta">EXPERIMENTAL</string>
|
||||||
<string name="settings_send_files_via_xftp">Send files via XFTP</string>
|
<string name="settings_send_files_via_xftp">Send videos and files via XFTP</string>
|
||||||
<string name="xftp_requires_v461">v4.6.1+ is required to receive via XFTP.</string>
|
<string name="xftp_requires_v461">v4.6.1+ is required to receive via XFTP.</string>
|
||||||
|
|
||||||
<!-- DatabaseView.kt -->
|
<!-- DatabaseView.kt -->
|
||||||
|
|||||||
Reference in New Issue
Block a user