-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functionality in call menu options to start/stop transcriptions
- Loading branch information
1 parent
b53deeb
commit 4a05030
Showing
8 changed files
with
186 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 46 additions & 34 deletions
80
demo-app/src/main/kotlin/io/getstream/video/android/ui/menu/TranscriptionUiState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,52 @@ | ||
/* | ||
* Copyright (c) 2014-2024 Stream.io Inc. All rights reserved. | ||
* | ||
* Licensed under the Stream License; | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://github.com/GetStream/stream-video-android/blob/main/LICENSE | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.getstream.video.android.ui.menu | ||
|
||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Transcribe | ||
import androidx.compose.material.icons.filled.Description | ||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import io.getstream.video.android.core.TranscriptionState | ||
|
||
data class TranscriptionUiState(val text: String, | ||
val icon: ImageVector, // Assuming it's a drawable resource ID | ||
val isButtonEnabled: Boolean) | ||
sealed class TranscriptionUiState( | ||
val text: String, | ||
val icon: ImageVector, // Assuming it's a drawable resource ID | ||
val highlight: Boolean, | ||
) | ||
|
||
/** | ||
* Stop Transcription | ||
* Start Transcription | ||
* Transcription is disabled | ||
* Transcription failed | ||
*/ | ||
|
||
data object TranscriptionAvailableUiState : TranscriptionUiState( | ||
text = "Transcribe the call", | ||
icon = Icons.Default.Description, | ||
highlight = false, | ||
) | ||
|
||
data object TranscriptionStoppedUiState : TranscriptionUiState( | ||
text = "Stop Transcription", | ||
icon = Icons.Default.Description, | ||
highlight = true, | ||
) | ||
|
||
fun TranscriptionState.mapTouUiState(): TranscriptionUiState { | ||
return when(this){ | ||
is TranscriptionState.CallTranscriptionInitialState -> TranscriptionUiState( | ||
text = "Transcription Not Ready", | ||
icon = Icons.Default.Transcribe, | ||
isButtonEnabled = false | ||
) | ||
is TranscriptionState.CallTranscriptionReadyState -> TranscriptionUiState( | ||
text = "Transcription is ready", | ||
icon = Icons.Default.Transcribe, | ||
isButtonEnabled = true | ||
) | ||
is TranscriptionState.CallTranscriptionStartedState -> TranscriptionUiState( | ||
text = "Transcription in progress", | ||
icon = Icons.Default.Transcribe, | ||
isButtonEnabled = true | ||
) | ||
is TranscriptionState.CallTranscriptionStoppedState -> TranscriptionUiState( | ||
text = "Transcription stopped", | ||
icon = Icons.Default.Transcribe, | ||
isButtonEnabled = true | ||
) | ||
is TranscriptionState.CallTranscriptionFailedState -> TranscriptionUiState( | ||
text = "Transcription failed", | ||
icon = Icons.Default.Transcribe, | ||
isButtonEnabled = false | ||
) | ||
} | ||
} | ||
data object TranscriptionDisabledUiState : TranscriptionUiState( | ||
text = "Transcription not available", | ||
icon = Icons.Default.Description, | ||
highlight = false, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...n/kotlin/io/getstream/video/android/ui/menu/transcriptions/TranscriptionUiStateManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (c) 2014-2024 Stream.io Inc. All rights reserved. | ||
* | ||
* Licensed under the Stream License; | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://github.com/GetStream/stream-video-android/blob/main/LICENSE | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.getstream.video.android.ui.menu.transcriptions | ||
|
||
import io.getstream.video.android.ui.menu.TranscriptionAvailableUiState | ||
import io.getstream.video.android.ui.menu.TranscriptionDisabledUiState | ||
import io.getstream.video.android.ui.menu.TranscriptionStoppedUiState | ||
import io.getstream.video.android.ui.menu.TranscriptionUiState | ||
import org.openapitools.client.models.CallSettingsResponse | ||
import org.openapitools.client.models.TranscriptionSettingsResponse | ||
|
||
class TranscriptionUiStateManager( | ||
private val isTranscribing: Boolean, | ||
private val settings: CallSettingsResponse?, | ||
) { | ||
|
||
fun getUiState(): TranscriptionUiState { | ||
return if (settings != null) { | ||
val mode = settings.transcription.mode | ||
when (mode) { | ||
TranscriptionSettingsResponse.Mode.Available, TranscriptionSettingsResponse.Mode.AutoOn -> { | ||
if (isTranscribing) { | ||
TranscriptionStoppedUiState | ||
} else { | ||
TranscriptionAvailableUiState | ||
} | ||
} | ||
else -> { | ||
TranscriptionDisabledUiState | ||
} | ||
} | ||
} else { | ||
TranscriptionDisabledUiState | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.