diff --git a/CHANGELOG.md b/CHANGELOG.md index 332953ad9b..3ed9d2a778 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Attention: don't forget to add the flag for F-Droid before release - [Feature] Add onetap widget - [Feature] Save, edit, share remote control - [Feature] More UI elements for remote-controls +- [Feature] Skip infrared signals on setup screen - [Refactor] Load RemoteControls from flipper, emulating animation - [Refactor] Update to Kotlin 2.0 - [Refactor] Replace Ktorfit with Ktor requests in remote-controls diff --git a/components/remote-controls/api-backend/src/commonMain/kotlin/com/flipperdevices/ifrmvp/backend/model/SignalRequestModel.kt b/components/remote-controls/api-backend/src/commonMain/kotlin/com/flipperdevices/ifrmvp/backend/model/SignalRequestModel.kt index f41c5cee8f..63c9c7696f 100644 --- a/components/remote-controls/api-backend/src/commonMain/kotlin/com/flipperdevices/ifrmvp/backend/model/SignalRequestModel.kt +++ b/components/remote-controls/api-backend/src/commonMain/kotlin/com/flipperdevices/ifrmvp/backend/model/SignalRequestModel.kt @@ -9,6 +9,8 @@ data class SignalRequestModel( val successResults: List = emptyList(), @SerialName("failed_results") val failedResults: List = emptyList(), + @SerialName("skipped_results") + val skippedResults: List = emptyList(), @SerialName("brand_id") val brandId: Long ) { diff --git a/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/composable/SetupScreen.kt b/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/composable/SetupScreen.kt index 911a7d363a..a76fe9771b 100644 --- a/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/composable/SetupScreen.kt +++ b/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/composable/SetupScreen.kt @@ -109,6 +109,7 @@ fun SetupScreen( .padding(scaffoldPaddings), onNegativeClick = setupComponent::onFailedClick, onSuccessClick = setupComponent::onSuccessClick, + onSkipClick = setupComponent::onSkipClicked ) } } diff --git a/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/composable/components/ConfirmContent.kt b/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/composable/components/ConfirmContent.kt index 5011e8e8c4..c4a9a12328 100644 --- a/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/composable/components/ConfirmContent.kt +++ b/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/composable/components/ConfirmContent.kt @@ -38,11 +38,13 @@ import com.flipperdevices.core.ui.theme.LocalTypography import com.flipperdevices.ifrmvp.backend.model.SignalResponse import com.flipperdevices.remotecontrols.setup.impl.R as SetupR +@Suppress("LongMethod") @Composable fun ConfirmContent( text: String, onPositiveClick: () -> Unit, onNegativeClick: () -> Unit, + onSkipClick: () -> Unit, modifier: Modifier = Modifier, ) { Box( @@ -76,7 +78,8 @@ fun ConfirmContent( horizontalArrangement = Arrangement.SpaceBetween, modifier = Modifier .fillMaxWidth() - .padding(vertical = 42.dp, horizontal = 38.dp) + .padding(horizontal = 38.dp) + .padding(top = 42.dp) ) { Text( text = stringResource(SetupR.string.no), @@ -93,6 +96,17 @@ fun ConfirmContent( onClick = onPositiveClick ) } + Text( + text = stringResource(SetupR.string.skip), + style = LocalTypography.current.buttonB16, + color = LocalPalletV2.current.action.blue.text.default, + textAlign = TextAlign.Center, + modifier = Modifier + .clip(RoundedCornerShape(30.dp)) + .clickableRipple(onClick = onSkipClick) + .padding(vertical = 18.dp, horizontal = 36.dp) + .padding(bottom = 22.dp), + ) } } ) @@ -103,6 +117,7 @@ fun AnimatedConfirmContent( lastEmulatedSignal: SignalResponse?, onNegativeClick: () -> Unit, onSuccessClick: () -> Unit, + onSkipClick: () -> Unit, modifier: Modifier = Modifier, ) { Box( @@ -135,6 +150,7 @@ fun AnimatedConfirmContent( }, onNegativeClick = onNegativeClick, onPositiveClick = onSuccessClick, + onSkipClick = onSkipClick, modifier = Modifier.align(Alignment.BottomCenter) ) } @@ -152,7 +168,8 @@ private fun ComposableConfirmContentLightPreview() { ConfirmContent( text = "Super mega text of preview confirm element", onPositiveClick = {}, - onNegativeClick = {} + onNegativeClick = {}, + onSkipClick = {} ) } } @@ -168,7 +185,8 @@ private fun ComposableConfirmContentDarkPreview() { ConfirmContent( text = "Super mega text of preview confirm element", onPositiveClick = {}, - onNegativeClick = {} + onNegativeClick = {}, + onSkipClick = {} ) } } diff --git a/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/presentation/decompose/SetupComponent.kt b/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/presentation/decompose/SetupComponent.kt index d0863a19cf..01b0503fda 100644 --- a/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/presentation/decompose/SetupComponent.kt +++ b/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/presentation/decompose/SetupComponent.kt @@ -23,6 +23,7 @@ interface SetupComponent { fun onSuccessClick() fun onFailedClick() + fun onSkipClicked() fun dispatchSignal() fun dismissBusyDialog() diff --git a/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/presentation/decompose/internal/SetupComponentImpl.kt b/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/presentation/decompose/internal/SetupComponentImpl.kt index 8d9c77fe70..fa375b59dc 100644 --- a/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/presentation/decompose/internal/SetupComponentImpl.kt +++ b/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/presentation/decompose/internal/SetupComponentImpl.kt @@ -138,7 +138,8 @@ class SetupComponentImpl @AssistedInject constructor( dispatchSignalApi.reset() createCurrentSignalViewModel.load( successResults = historyViewModel.state.value.successfulSignals, - failedResults = historyViewModel.state.value.failedSignals + failedResults = historyViewModel.state.value.failedSignals, + skippedResults = historyViewModel.state.value.skippedSignals ) _lastEmulatedSignal.value = null } @@ -163,6 +164,14 @@ class SetupComponentImpl @AssistedInject constructor( tryLoad() } + override fun onSkipClicked() { + val state = createCurrentSignalViewModel.state.value as? CurrentSignalViewModel.State.Loaded + ?: return + val signalModel = state.response.signalResponse?.signalModel ?: return + historyViewModel.rememberSkipped(signalModel) + tryLoad() + } + override fun dispatchSignal() { val state = createCurrentSignalViewModel.state.value val loadedState = state as? CurrentSignalViewModel.State.Loaded ?: run { diff --git a/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/presentation/viewmodel/CurrentSignalViewModel.kt b/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/presentation/viewmodel/CurrentSignalViewModel.kt index 29cfa8a3c7..8349db1d87 100644 --- a/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/presentation/viewmodel/CurrentSignalViewModel.kt +++ b/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/presentation/viewmodel/CurrentSignalViewModel.kt @@ -26,13 +26,15 @@ class CurrentSignalViewModel @AssistedInject constructor( fun load( successResults: List, - failedResults: List + failedResults: List, + skippedResults: List ) = viewModelScope.launch { _state.emit(State.Loading) val result = runCatching { val request = SignalRequestModel( successResults = successResults, failedResults = failedResults, + skippedResults = skippedResults, brandId = param.brandId, ) infraredBackendApi.getSignal(request) @@ -45,7 +47,7 @@ class CurrentSignalViewModel @AssistedInject constructor( } init { - load(emptyList(), emptyList()) + load(emptyList(), emptyList(), emptyList()) } sealed interface State { diff --git a/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/presentation/viewmodel/HistoryViewModel.kt b/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/presentation/viewmodel/HistoryViewModel.kt index 2ed0870e38..fb2798ea54 100644 --- a/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/presentation/viewmodel/HistoryViewModel.kt +++ b/components/remote-controls/setup/impl/src/main/kotlin/com/flipperdevices/remotecontrols/impl/setup/presentation/viewmodel/HistoryViewModel.kt @@ -26,8 +26,16 @@ class HistoryViewModel @Inject constructor() : DecomposeViewModel() { _state.update { it.copy(failedSignals = it.failedSignals + signalResultData) } } + fun rememberSkipped(signalModel: SignalModel) { + val signalResultData = SignalResultData( + signalId = signalModel.id, + ) + _state.update { it.copy(skippedSignals = it.skippedSignals + signalResultData) } + } + data class State( val successfulSignals: List = emptyList(), - val failedSignals: List = emptyList() + val failedSignals: List = emptyList(), + val skippedSignals: List = emptyList() ) } diff --git a/components/remote-controls/setup/impl/src/main/res/values/strings.xml b/components/remote-controls/setup/impl/src/main/res/values/strings.xml index 03c947c047..3d8c825873 100644 --- a/components/remote-controls/setup/impl/src/main/res/values/strings.xml +++ b/components/remote-controls/setup/impl/src/main/res/values/strings.xml @@ -3,6 +3,7 @@ Yes No + Skip Not found signal for your preferences Point Flipper Zero at the %s and tap the button Set Up Remote