correct the item where progress spinner happens on
This commit is contained in:
+3
-2
@@ -39,11 +39,12 @@ import com.vitorpamplona.amethyst.ui.stringRes
|
|||||||
@Composable
|
@Composable
|
||||||
fun VoicePresetSelector(
|
fun VoicePresetSelector(
|
||||||
selectedPreset: VoicePreset,
|
selectedPreset: VoicePreset,
|
||||||
isProcessing: Boolean,
|
processingPreset: VoicePreset?,
|
||||||
onPresetSelected: (VoicePreset) -> Unit,
|
onPresetSelected: (VoicePreset) -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
val isProcessing = processingPreset != null
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = modifier.fillMaxWidth(),
|
modifier = modifier.fillMaxWidth(),
|
||||||
@@ -51,7 +52,7 @@ fun VoicePresetSelector(
|
|||||||
) {
|
) {
|
||||||
VoicePreset.entries.forEach { preset ->
|
VoicePreset.entries.forEach { preset ->
|
||||||
val isSelected = preset == selectedPreset
|
val isSelected = preset == selectedPreset
|
||||||
val isThisProcessing = isProcessing && preset == selectedPreset
|
val isThisProcessing = preset == processingPreset
|
||||||
val isEnabled = !isProcessing || preset == VoicePreset.NONE
|
val isEnabled = !isProcessing || preset == VoicePreset.NONE
|
||||||
|
|
||||||
FilterChip(
|
FilterChip(
|
||||||
|
|||||||
+1
-1
@@ -409,7 +409,7 @@ private fun NewPostScreenBody(
|
|||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
VoicePresetSelector(
|
VoicePresetSelector(
|
||||||
selectedPreset = postViewModel.selectedPreset,
|
selectedPreset = postViewModel.selectedPreset,
|
||||||
isProcessing = postViewModel.isProcessingPreset,
|
processingPreset = postViewModel.processingPreset,
|
||||||
onPresetSelected = { postViewModel.selectPreset(it) },
|
onPresetSelected = { postViewModel.selectPreset(it) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-8
@@ -200,7 +200,7 @@ open class ShortNotePostViewModel :
|
|||||||
|
|
||||||
// Voice Anonymization
|
// Voice Anonymization
|
||||||
var selectedPreset: VoicePreset by mutableStateOf(VoicePreset.NONE)
|
var selectedPreset: VoicePreset by mutableStateOf(VoicePreset.NONE)
|
||||||
var isProcessingPreset: Boolean by mutableStateOf(false)
|
var processingPreset: VoicePreset? by mutableStateOf(null)
|
||||||
var distortedFiles: Map<VoicePreset, AnonymizedResult> by mutableStateOf(emptyMap())
|
var distortedFiles: Map<VoicePreset, AnonymizedResult> by mutableStateOf(emptyMap())
|
||||||
private var processingJob: Job? = null
|
private var processingJob: Job? = null
|
||||||
|
|
||||||
@@ -829,7 +829,7 @@ open class ShortNotePostViewModel :
|
|||||||
voiceSelectedServer = null
|
voiceSelectedServer = null
|
||||||
voiceOrchestrator = null
|
voiceOrchestrator = null
|
||||||
selectedPreset = VoicePreset.NONE
|
selectedPreset = VoicePreset.NONE
|
||||||
isProcessingPreset = false
|
processingPreset = null
|
||||||
pTags = null
|
pTags = null
|
||||||
|
|
||||||
wantsPoll = false
|
wantsPoll = false
|
||||||
@@ -951,7 +951,7 @@ open class ShortNotePostViewModel :
|
|||||||
fun canPost(): Boolean {
|
fun canPost(): Boolean {
|
||||||
// Voice messages can be posted without text (with either uploaded or pending recording)
|
// Voice messages can be posted without text (with either uploaded or pending recording)
|
||||||
if (voiceMetadata != null || voiceRecording != null) {
|
if (voiceMetadata != null || voiceRecording != null) {
|
||||||
return !isUploadingVoice && !isUploadingImage && !isProcessingPreset
|
return !isUploadingVoice && !isUploadingImage && processingPreset == null
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regular text/media posts require text
|
// Regular text/media posts require text
|
||||||
@@ -987,7 +987,7 @@ open class ShortNotePostViewModel :
|
|||||||
voiceLocalFile = recording.file
|
voiceLocalFile = recording.file
|
||||||
voiceMetadata = null
|
voiceMetadata = null
|
||||||
selectedPreset = VoicePreset.NONE
|
selectedPreset = VoicePreset.NONE
|
||||||
isProcessingPreset = false
|
processingPreset = null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getVoicePreviewMetadata(): AudioMeta? =
|
fun getVoicePreviewMetadata(): AudioMeta? =
|
||||||
@@ -1001,7 +1001,7 @@ open class ShortNotePostViewModel :
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun selectPreset(preset: VoicePreset) {
|
fun selectPreset(preset: VoicePreset) {
|
||||||
if (isProcessingPreset || preset == selectedPreset) return
|
if (processingPreset != null || preset == selectedPreset) return
|
||||||
|
|
||||||
if (preset == VoicePreset.NONE) {
|
if (preset == VoicePreset.NONE) {
|
||||||
selectedPreset = preset
|
selectedPreset = preset
|
||||||
@@ -1018,7 +1018,7 @@ open class ShortNotePostViewModel :
|
|||||||
processingJob?.cancel()
|
processingJob?.cancel()
|
||||||
processingJob =
|
processingJob =
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
isProcessingPreset = true
|
processingPreset = preset
|
||||||
try {
|
try {
|
||||||
val anonymizer = VoiceAnonymizer()
|
val anonymizer = VoiceAnonymizer()
|
||||||
val result = anonymizer.anonymize(originalFile, preset)
|
val result = anonymizer.anonymize(originalFile, preset)
|
||||||
@@ -1035,7 +1035,7 @@ open class ShortNotePostViewModel :
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
isProcessingPreset = false
|
processingPreset = null
|
||||||
processingJob = null
|
processingJob = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1051,7 +1051,7 @@ open class ShortNotePostViewModel :
|
|||||||
isUploadingVoice = false
|
isUploadingVoice = false
|
||||||
voiceOrchestrator = null
|
voiceOrchestrator = null
|
||||||
selectedPreset = VoicePreset.NONE
|
selectedPreset = VoicePreset.NONE
|
||||||
isProcessingPreset = false
|
processingPreset = null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun deleteVoiceLocalFile() {
|
private fun deleteVoiceLocalFile() {
|
||||||
|
|||||||
+1
-1
@@ -198,7 +198,7 @@ private fun VoiceReplyScreenBody(
|
|||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
VoicePresetSelector(
|
VoicePresetSelector(
|
||||||
selectedPreset = viewModel.selectedPreset,
|
selectedPreset = viewModel.selectedPreset,
|
||||||
isProcessing = viewModel.isProcessingPreset,
|
processingPreset = viewModel.processingPreset,
|
||||||
onPresetSelected = { viewModel.selectPreset(it) },
|
onPresetSelected = { viewModel.selectPreset(it) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-6
@@ -71,7 +71,7 @@ class VoiceReplyViewModel : ViewModel() {
|
|||||||
var isUploading: Boolean by mutableStateOf(false)
|
var isUploading: Boolean by mutableStateOf(false)
|
||||||
|
|
||||||
var selectedPreset: VoicePreset by mutableStateOf(VoicePreset.NONE)
|
var selectedPreset: VoicePreset by mutableStateOf(VoicePreset.NONE)
|
||||||
var isProcessingPreset: Boolean by mutableStateOf(false)
|
var processingPreset: VoicePreset? by mutableStateOf(null)
|
||||||
var distortedFiles: Map<VoicePreset, AnonymizedResult> by mutableStateOf(emptyMap())
|
var distortedFiles: Map<VoicePreset, AnonymizedResult> by mutableStateOf(emptyMap())
|
||||||
private var processingJob: Job? = null
|
private var processingJob: Job? = null
|
||||||
|
|
||||||
@@ -138,6 +138,7 @@ class VoiceReplyViewModel : ViewModel() {
|
|||||||
fun selectRecording(recording: RecordingResult) {
|
fun selectRecording(recording: RecordingResult) {
|
||||||
cancelUpload()
|
cancelUpload()
|
||||||
processingJob?.cancel()
|
processingJob?.cancel()
|
||||||
|
processingPreset = null
|
||||||
deleteVoiceLocalFile()
|
deleteVoiceLocalFile()
|
||||||
voiceRecording = recording
|
voiceRecording = recording
|
||||||
voiceLocalFile = recording.file
|
voiceLocalFile = recording.file
|
||||||
@@ -175,10 +176,10 @@ class VoiceReplyViewModel : ViewModel() {
|
|||||||
distortedFiles = emptyMap()
|
distortedFiles = emptyMap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun canSend(): Boolean = voiceRecording != null && !isUploading && !isProcessingPreset
|
fun canSend(): Boolean = voiceRecording != null && !isUploading && processingPreset == null
|
||||||
|
|
||||||
fun selectPreset(preset: VoicePreset) {
|
fun selectPreset(preset: VoicePreset) {
|
||||||
if (isProcessingPreset || preset == selectedPreset) return
|
if (processingPreset != null || preset == selectedPreset) return
|
||||||
|
|
||||||
if (preset == VoicePreset.NONE) {
|
if (preset == VoicePreset.NONE) {
|
||||||
selectedPreset = preset
|
selectedPreset = preset
|
||||||
@@ -195,7 +196,7 @@ class VoiceReplyViewModel : ViewModel() {
|
|||||||
processingJob?.cancel()
|
processingJob?.cancel()
|
||||||
processingJob =
|
processingJob =
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
isProcessingPreset = true
|
processingPreset = preset
|
||||||
try {
|
try {
|
||||||
val anonymizer = VoiceAnonymizer()
|
val anonymizer = VoiceAnonymizer()
|
||||||
val result = anonymizer.anonymize(originalFile, preset)
|
val result = anonymizer.anonymize(originalFile, preset)
|
||||||
@@ -212,7 +213,7 @@ class VoiceReplyViewModel : ViewModel() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
isProcessingPreset = false
|
processingPreset = null
|
||||||
processingJob = null
|
processingJob = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -356,7 +357,7 @@ class VoiceReplyViewModel : ViewModel() {
|
|||||||
isUploading = false
|
isUploading = false
|
||||||
voiceOrchestrator = null
|
voiceOrchestrator = null
|
||||||
selectedPreset = VoicePreset.NONE
|
selectedPreset = VoicePreset.NONE
|
||||||
isProcessingPreset = false
|
processingPreset = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCleared() {
|
override fun onCleared() {
|
||||||
|
|||||||
Reference in New Issue
Block a user