Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ private fun Throwable.toDomainThrowable(): Throwable =
when (this) {
is CancellationException -> this

is AppException -> this

is ApiException ->
AppException(
error = errorCode.toDomainError(),
Expand Down Expand Up @@ -74,7 +76,9 @@ private fun ServerErrorCode.toDomainError(): AppError =
ServerErrorCode.INVALID_ID_TOKEN,
-> AppError.UNAUTHORIZED

ServerErrorCode.VOICE_RECOGNITION_FAILED -> AppError.VOICE_RECOGNITION_FAILED
ServerErrorCode.VOICE_RECOGNITION_FAILED,
ServerErrorCode.VOICE_RECORDING_EMPTY_OR_SILENT,
-> AppError.VOICE_RECOGNITION_FAILED

ServerErrorCode.UNKNOWN -> AppError.UNKNOWN
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ enum class ServerErrorCode(
SENTENCE_NOT_FOUND("S001"),
VOICE_RECOGNITION_FAILED("V001"),
VOICE_ANALYSIS_FAILED("V002"),
VOICE_RECORDING_EMPTY_OR_SILENT("V003"),
UNKNOWN("UNKNOWN"),
;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.team.prezel.feature.practice.impl.analysis.component

import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
Expand All @@ -27,8 +28,8 @@ internal fun PracticeAnalysisFailurePage(
modifier: Modifier = Modifier,
) {
StatusView(
title = stringResource(R.string.feature_practice_impl_practice_recording_analysis_error_title),
description = stringResource(R.string.feature_practice_impl_practice_recording_analysis_error_description),
title = stringResource(errorType.titleResId),
description = stringResource(errorType.descriptionResId),
modifier = modifier,
visual = {
Image(
Expand Down Expand Up @@ -58,6 +59,21 @@ private val PracticeAnalysisErrorType.drawableResId: Int
PracticeAnalysisErrorType.VOICE_RECOGNITION_FAILED -> CoreUiR.drawable.core_ui_error_voice
}

private val PracticeAnalysisErrorType.titleResId: Int
@StringRes
get() = when (this) {
PracticeAnalysisErrorType.ANALYSIS_FAILED -> R.string.feature_practice_impl_practice_recording_analysis_failed_title
PracticeAnalysisErrorType.VOICE_RECOGNITION_FAILED ->
R.string.feature_practice_impl_practice_recording_voice_recognition_failed_title
}

private val PracticeAnalysisErrorType.descriptionResId: Int
@StringRes
get() = when (this) {
PracticeAnalysisErrorType.ANALYSIS_FAILED -> R.string.feature_practice_impl_practice_recording_analysis_failed_description
PracticeAnalysisErrorType.VOICE_RECOGNITION_FAILED -> R.string.feature_practice_impl_practice_recording_voice_recognition_failed_description
}

@BasicPreview
@Composable
private fun PracticeAnalysisAnalyzeFailurePagePreview() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.team.prezel.core.designsystem.component.actions.area.PrezelButtonArea
import com.team.prezel.core.designsystem.component.actions.button.PrezelButton
import com.team.prezel.core.designsystem.component.chip.chip.ChipHierarchy
import com.team.prezel.core.designsystem.component.chip.chip.PrezelChip
import com.team.prezel.core.designsystem.preview.BasicPreview
import com.team.prezel.core.designsystem.theme.PrezelTheme
Expand Down Expand Up @@ -151,7 +152,10 @@ private fun PracticeAnalysisMetricRow(
horizontalArrangement = Arrangement.SpaceBetween,
) {
PracticeAnalysisMetricLabel(text = stringResource(R.string.feature_practice_impl_practice_recording_analysis_speed))
PrezelChip(text = stringResource(speed.labelResId))
PrezelChip(
text = stringResource(speed.labelResId),
hierarchy = ChipHierarchy.SECONDARY,
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.team.prezel.feature.practice.impl.analysis.model

internal enum class PracticeAnalysisErrorType {
VOICE_RECOGNITION_FAILED,
ANALYSIS_FAILED,
VOICE_RECOGNITION_FAILED,
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.team.prezel.feature.practice.impl.navigation

import androidx.compose.runtime.Composable
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
import androidx.navigation3.runtime.EntryProviderScope
import androidx.navigation3.runtime.NavKey
Expand All @@ -14,30 +15,30 @@ import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityRetainedComponent
import dagger.multibindings.IntoSet
import kotlinx.serialization.Serializable

internal fun EntryProviderScope<NavKey>.featurePracticeEntryBuilder() {
entry<PracticeNavKey> { key ->
val navigator = LocalNavigator.current
PracticeRecordingRoute(presentationId = key.presentationId)
}

PracticeRecordingScreen(
onBack = navigator::goBack,
navigateToAnalysis = { recordingFilePath, referenceText ->
navigator.navigate(
PracticeAnalysisNavKey(
presentationId = key.presentationId,
recordingFilePath = recordingFilePath,
referenceText = referenceText,
),
)
},
)
entry<PracticeRecordingRetryNavKey> { key ->
PracticeRecordingRoute(presentationId = key.presentationId)
}

entry<PracticeAnalysisNavKey> { key ->
val navigator = LocalNavigator.current

PracticeAnalysisScreen(
onRetry = navigator::goBack,
onRetry = {
navigator.navigate(
key = PracticeRecordingRetryNavKey(
presentationId = key.presentationId,
recordingFilePath = key.recordingFilePath,
),
clearStack = true,
)
},
onComplete = { navigator.replaceRoot(HomeNavKey) },
viewModel = hiltViewModel<PracticeAnalysisViewModel, PracticeAnalysisViewModel.Factory> { factory ->
factory.create(
Expand All @@ -50,6 +51,30 @@ internal fun EntryProviderScope<NavKey>.featurePracticeEntryBuilder() {
}
}

@Composable
private fun PracticeRecordingRoute(presentationId: Long) {
val navigator = LocalNavigator.current

PracticeRecordingScreen(
onBack = navigator::goBack,
navigateToAnalysis = { recordingFilePath, referenceText ->
navigator.navigate(
PracticeAnalysisNavKey(
presentationId = presentationId,
recordingFilePath = recordingFilePath,
referenceText = referenceText,
),
)
},
)
}

@Serializable
private data class PracticeRecordingRetryNavKey(
val presentationId: Long,
val recordingFilePath: String,
) : NavKey

@Module
@InstallIn(ActivityRetainedComponent::class)
object FeaturePracticeModule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<string name="feature_practice_impl_practice_recording_playback_failed">녹음을 재생하지 못했습니다.</string>
<string name="feature_practice_impl_practice_recording_analysis_loading_title">분석중</string>
<string name="feature_practice_impl_practice_recording_analysis_loading_description">잠시만 기다려주세요</string>
<string name="feature_practice_impl_practice_recording_analysis_error_title">분석에 실패했어요</string>
<string name="feature_practice_impl_practice_recording_analysis_error_description">음성이 작거나 주변 소음이 많았을 수 있어요.\n조용한 환경에서 다시 시도해 주세요.</string>
<string name="feature_practice_impl_practice_recording_analysis_failed_title">분석 중 문제가 발생했어요.</string>
<string name="feature_practice_impl_practice_recording_analysis_failed_description">일시적인 오류로 분석을 완료하지 못했어요.\n잠시 후 다시 시도해 주세요.</string>
<string name="feature_practice_impl_practice_recording_analysis_retry">다시 시도하기</string>
<string name="feature_practice_impl_practice_recording_analysis_complete">완료</string>
<string name="feature_practice_impl_practice_recording_analysis_pronunciation">발화</string>
Expand All @@ -24,4 +24,6 @@
<string name="feature_practice_impl_practice_recording_analysis_card_perfect">perfect</string>
<string name="feature_practice_impl_practice_recording_analysis_card_good">good</string>
<string name="feature_practice_impl_practice_recording_analysis_card_try">try</string>
<string name="feature_practice_impl_practice_recording_voice_recognition_failed_title">분석할 음성을 인식하지 못했어요.</string>
<string name="feature_practice_impl_practice_recording_voice_recognition_failed_description">음성이 작거나 주변 소음이 많았을 수 있어요.\n조용한 환경에서 다시 녹음해 주세요.</string>
</resources>