android, desktop: make audio call default type of call on desktop (#4954)

* android, desktop: make audio call default type of call on desktop

* change
This commit is contained in:
Stanislav Dmitrenko 2024-09-30 21:45:13 +07:00 committed by GitHub
parent 15ca662805
commit d9ad755474
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 19 additions and 40 deletions

View file

@ -17,7 +17,7 @@ data class Call(
val callUUID: String?,
val callState: CallState,
val initialCallType: CallMediaType,
val localMediaSources: CallMediaSources = CallMediaSources(mic = true, camera = initialCallType == CallMediaType.Video && appPlatform.isAndroid),
val localMediaSources: CallMediaSources = CallMediaSources(mic = true, camera = initialCallType == CallMediaType.Video),
val localCapabilities: CallCapabilities? = null,
val peerMediaSources: CallMediaSources = CallMediaSources(),
val sharedKey: String? = null,

View file

@ -779,30 +779,16 @@ fun ChatInfoToolbar(
if (chatInfo is ChatInfo.Direct && chatInfo.contact.mergedPreferences.calls.enabled.forUser) {
if (activeCall == null) {
barButtons.add {
if (appPlatform.isAndroid) {
IconButton({
showMenu.value = false
startCall(CallMediaType.Audio)
}, enabled = chatInfo.contact.ready && chatInfo.contact.active
) {
Icon(
painterResource(MR.images.ic_call_500),
stringResource(MR.strings.icon_descr_audio_call).capitalize(Locale.current),
tint = if (chatInfo.contact.ready && chatInfo.contact.active) MaterialTheme.colors.primary else MaterialTheme.colors.secondary
)
}
} else {
IconButton({
showMenu.value = false
startCall(CallMediaType.Video)
}, enabled = chatInfo.contact.ready && chatInfo.contact.active
) {
Icon(
painterResource(MR.images.ic_videocam),
stringResource(MR.strings.icon_descr_video_call).capitalize(Locale.current),
tint = if (chatInfo.contact.ready && chatInfo.contact.active) MaterialTheme.colors.primary else MaterialTheme.colors.secondary
)
}
IconButton({
showMenu.value = false
startCall(CallMediaType.Audio)
}, enabled = chatInfo.contact.ready && chatInfo.contact.active
) {
Icon(
painterResource(MR.images.ic_call_500),
stringResource(MR.strings.icon_descr_audio_call).capitalize(Locale.current),
tint = if (chatInfo.contact.ready && chatInfo.contact.active) MaterialTheme.colors.primary else MaterialTheme.colors.secondary
)
}
}
} else if (activeCall?.contact?.id == chatInfo.id && appPlatform.isDesktop) {
@ -836,17 +822,10 @@ fun ChatInfoToolbar(
}
if (chatInfo.contact.ready && chatInfo.contact.active && activeCall == null) {
menuItems.add {
if (appPlatform.isAndroid) {
ItemAction(stringResource(MR.strings.icon_descr_video_call).capitalize(Locale.current), painterResource(MR.images.ic_videocam), onClick = {
showMenu.value = false
startCall(CallMediaType.Video)
})
} else {
ItemAction(stringResource(MR.strings.icon_descr_audio_call).capitalize(Locale.current), painterResource(MR.images.ic_call_500), onClick = {
showMenu.value = false
startCall(CallMediaType.Audio)
})
}
ItemAction(stringResource(MR.strings.icon_descr_video_call).capitalize(Locale.current), painterResource(MR.images.ic_videocam), onClick = {
showMenu.value = false
startCall(CallMediaType.Video)
})
}
}
} else if (chatInfo is ChatInfo.Group && chatInfo.groupInfo.canAddMembers) {

View file

@ -296,7 +296,7 @@ const processCommand = (function () {
endCall();
let localStream = null;
try {
localStream = await getLocalMediaStream(true, command.media == CallMediaType.Video && !isDesktop, VideoCamera.User);
localStream = await getLocalMediaStream(true, command.media == CallMediaType.Video, VideoCamera.User);
const videos = getVideoElements();
if (videos) {
videos.local.srcObject = localStream;
@ -325,7 +325,7 @@ const processCommand = (function () {
if (activeCall)
endCall();
inactiveCallMediaSources.mic = true;
inactiveCallMediaSources.camera = command.media == CallMediaType.Video && !isDesktop;
inactiveCallMediaSources.camera = command.media == CallMediaType.Video;
inactiveCallMediaSourcesChanged(inactiveCallMediaSources);
const { media, iceServers, relay } = command;
const encryption = supportsInsertableStreams(useWorker);

View file

@ -560,7 +560,7 @@ const processCommand = (function () {
let localStream: MediaStream | null = null
try {
localStream = await getLocalMediaStream(true, command.media == CallMediaType.Video && !isDesktop, VideoCamera.User)
localStream = await getLocalMediaStream(true, command.media == CallMediaType.Video, VideoCamera.User)
const videos = getVideoElements()
if (videos) {
videos.local.srcObject = localStream
@ -588,7 +588,7 @@ const processCommand = (function () {
if (activeCall) endCall()
inactiveCallMediaSources.mic = true
inactiveCallMediaSources.camera = command.media == CallMediaType.Video && !isDesktop
inactiveCallMediaSources.camera = command.media == CallMediaType.Video
inactiveCallMediaSourcesChanged(inactiveCallMediaSources)
const {media, iceServers, relay} = command