Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remotecontrols/move into tools #950

Merged
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Attention: don't forget to add the flag for F-Droid before release
- [FIX] Share infrared remote after rename
- [FIX] Fix app bar colors on remote controls
- [FIX] Fix remote controls texts and favorite dropdown
- [FIX] Move remote controls into tools tab
- [FIX] Remove share from remote controls
- [CI] Fix merge-queue files diff
- [CI] Add https://github.com/LionZXY/detekt-decompose-rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.flipperdevices.archive.category.composable.ComposableCategory
import com.flipperdevices.archive.category.composable.ComposableDeleted
import com.flipperdevices.archive.category.model.CategoryNavigationConfig
import com.flipperdevices.archive.category.viewmodels.CategoryViewModel
import com.flipperdevices.archive.category.viewmodels.DebugSettingsViewModel
import com.flipperdevices.archive.category.viewmodels.DeleteViewModel
import com.flipperdevices.archive.model.CategoryType
import com.flipperdevices.bridge.dao.api.model.FlipperKeyPath
Expand All @@ -34,15 +33,11 @@ class CategoryScreenDecomposeComponentImpl @AssistedInject constructor(
private val deleteViewModelProvider: Provider<DeleteViewModel>,
private val categoryViewModelFactory: CategoryViewModel.Factory,
private val synchronizationUiApi: SynchronizationUiApi,
private val debugSettingsViewModelProvider: Provider<DebugSettingsViewModel>,
) : ScreenDecomposeComponent(componentContext) {

@Composable
@Suppress("NonSkippableComposable")
override fun Render() {
val debugSettingsViewModel = viewModelWithFactory(key = null) {
debugSettingsViewModelProvider.get()
}
val deleteViewModel = viewModelWithFactory(key = null) {
deleteViewModelProvider.get()
}
Expand All @@ -57,8 +52,6 @@ class CategoryScreenDecomposeComponentImpl @AssistedInject constructor(
val onOpenKeyScreen: (FlipperKeyPath) -> Unit = { flipperKeyPath ->
rootNavigation.push(RootScreenConfig.OpenKey(flipperKeyPath))
}
val showRemoteControls by debugSettingsViewModel.showRemoteControls.collectAsState()

when (categoryType) {
is CategoryType.ByFileType -> ComposableCategory(
categoryType = categoryType,
Expand All @@ -67,7 +60,6 @@ class CategoryScreenDecomposeComponentImpl @AssistedInject constructor(
onOpenKeyScreen = onOpenKeyScreen,
categoryState = categoryState,
synchronizationState = synchronizationState,
showRemoteControls = showRemoteControls
)

CategoryType.Deleted -> ComposableDeleted(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,21 @@ import com.flipperdevices.archive.model.CategoryType
import com.flipperdevices.archive.shared.composable.ComposableKeyCard
import com.flipperdevices.bridge.dao.api.model.FlipperKey
import com.flipperdevices.bridge.dao.api.model.FlipperKeyPath
import com.flipperdevices.bridge.dao.api.model.FlipperKeyType
import com.flipperdevices.bridge.dao.api.model.FlipperKeyType.Companion.colorByFlipperKeyType
import com.flipperdevices.bridge.synchronization.api.SynchronizationState
import com.flipperdevices.bridge.synchronization.api.SynchronizationUiApi
import com.flipperdevices.core.ui.ktx.OrangeAppBar
import com.flipperdevices.core.ui.ktx.clickableRipple
import com.flipperdevices.core.ui.theme.LocalPallet
import com.flipperdevices.core.ui.theme.LocalPalletV2
import com.flipperdevices.core.ui.theme.LocalTypography
import com.flipperdevices.deeplink.model.Deeplink
import com.flipperdevices.keyparser.api.model.FlipperKeyParsed
import com.flipperdevices.rootscreen.api.LocalDeeplinkHandler
import kotlinx.collections.immutable.ImmutableList

@Composable
fun AddRemoteEndBlock(modifier: Modifier = Modifier) {
val deeplinkHandler = LocalDeeplinkHandler.current
Text(
text = stringResource(R.string.add_remote),
style = LocalTypography.current.buttonB14,
color = LocalPalletV2.current.text.title.blackOnColor,
modifier = modifier
.padding(horizontal = 14.dp)
.clickableRipple {
deeplinkHandler.handleDeeplink(Deeplink.BottomBar.ArchiveTab.RemoteControls)
}
)
}

@Composable
fun ComposableCategory(
categoryType: CategoryType.ByFileType,
categoryState: CategoryState,
synchronizationState: SynchronizationState,
synchronizationUiApi: SynchronizationUiApi,
showRemoteControls: Boolean,
onBack: () -> Unit,
modifier: Modifier = Modifier,
onOpenKeyScreen: (FlipperKeyPath) -> Unit
Expand All @@ -64,11 +43,6 @@ fun ComposableCategory(
OrangeAppBar(
title = categoryType.fileType.humanReadableName,
onBack = onBack,
endBlock = {
if (categoryType.fileType == FlipperKeyType.INFRARED && showRemoteControls) {
AddRemoteEndBlock()
}
}
)
ComposableCategoryContent(
categoryType = categoryType,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import com.flipperdevices.archive.impl.model.toArchiveNavigationStack
import com.flipperdevices.bottombar.handlers.ResetTabDecomposeHandler
import com.flipperdevices.core.di.AppGraph
import com.flipperdevices.deeplink.model.Deeplink
import com.flipperdevices.remotecontrols.api.RemoteControlsScreenDecomposeComponent
import com.flipperdevices.ui.decompose.DecomposeComponent
import com.flipperdevices.ui.decompose.DecomposeOnBackParameter
import com.flipperdevices.ui.decompose.findComponentByConfig
Expand All @@ -32,7 +31,6 @@ class ArchiveDecomposeComponentImpl @AssistedInject constructor(
private val openCategoryFactory: CategoryDecomposeComponent.Factory,
private val searchFactory: SearchDecomposeComponent.Factory,
private val archiveScreenFactory: ArchiveScreenDecomposeComponentImpl.Factory,
private val remoteControlsComponentFactory: RemoteControlsScreenDecomposeComponent.Factory,
) : ArchiveDecomposeComponent<ArchiveNavigationConfig>(),
ComponentContext by componentContext,
ResetTabDecomposeHandler {
Expand Down Expand Up @@ -67,11 +65,6 @@ class ArchiveDecomposeComponentImpl @AssistedInject constructor(
onItemSelected = null,
onBack = { navigation.popOr(onBack::invoke) }
)

is ArchiveNavigationConfig.RemoteControls -> remoteControlsComponentFactory(
componentContext = componentContext,
onBack = { navigation.popOr(onBack::invoke) }
)
}

override fun handleDeeplink(deeplink: Deeplink.BottomBar.ArchiveTab) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ sealed class ArchiveNavigationConfig {

@Serializable
data object OpenSearch : ArchiveNavigationConfig()

@Serializable
data object RemoteControls : ArchiveNavigationConfig()
}

fun Deeplink.BottomBar.ArchiveTab?.toArchiveNavigationStack(): List<ArchiveNavigationConfig> {
Expand All @@ -39,10 +36,6 @@ fun Deeplink.BottomBar.ArchiveTab?.toArchiveNavigationStack(): List<ArchiveNavig

null -> {
}

Deeplink.BottomBar.ArchiveTab.RemoteControls -> {
stack.add(ArchiveNavigationConfig.RemoteControls)
}
}
return stack
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,4 @@ message Settings {
bool fatal_ble_security_exception_happens = 26;
bool notification_topic_update_enabled = 27;
bool notification_dialog_shown = 28;
bool show_remote_controls = 29;
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ sealed interface Deeplink {

@Serializable
sealed interface ArchiveTab : BottomBar {
@Serializable
data object RemoteControls : ArchiveTab

@Serializable
sealed interface ArchiveCategory : ArchiveTab {
val category: FlipperKeyType?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.flipperdevices.remotecontrols.impl.categories.composable.components

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
Expand All @@ -19,7 +20,9 @@ internal fun DeviceCategoriesLoadedContent(
) {
LazyVerticalGrid(
columns = GridCells.Fixed(2),
modifier = modifier.padding(horizontal = 16.dp, vertical = 14.dp),
modifier = modifier
.padding(horizontal = 16.dp, vertical = 14.dp)
.fillMaxHeight(),
horizontalArrangement = Arrangement.spacedBy(12.dp),
verticalArrangement = Arrangement.spacedBy(12.dp)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ private fun DebugCategoryItems(
onSwitchState = { onSwitch(DebugSettingSwitch.FapHubDev, it) }
)
GrayDivider()
SwitchableElement(
titleId = R.string.debug_application_show_remote_controls,
state = settings.show_remote_controls,
onSwitchState = { onSwitch(DebugSettingSwitch.ShowRemoteControls, it) }
)
GrayDivider()
SwitchableElement(
titleId = R.string.debug_selfupdater,
state = settings.self_updater_debug,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ sealed interface DebugSettingSwitch {
data object SkipAutoSync : DebugSettingSwitch
data object FapHubDev : DebugSettingSwitch
data object SelfUpdaterDebug : DebugSettingSwitch
data object ShowRemoteControls : DebugSettingSwitch
}

sealed interface DebugSettingAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class DebugViewModel @Inject constructor(
DebugSettingSwitch.SelfUpdaterDebug -> onSwitchSelfUpdaterDebug(flag)
DebugSettingSwitch.SkipAutoSync -> onSwitchSkipAutoSync(flag)
DebugSettingSwitch.SkipProvisioning -> onSwitchIgnoreSubGhzProvisioning(flag)
DebugSettingSwitch.ShowRemoteControls -> onShowRemoteControls(flag)
}
}

Expand Down Expand Up @@ -140,16 +139,6 @@ class DebugViewModel @Inject constructor(
}
}

private fun onShowRemoteControls(enabled: Boolean) {
viewModelScope.launch {
settingsDataStore.updateData {
it.copy(
show_remote_controls = enabled
)
}
}
}

private fun installAllApplication() {
viewModelScope.launch {
fapInstallationAllApi.installAll()
Expand Down
1 change: 1 addition & 0 deletions components/toolstab/impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies {
implementation(projects.components.bottombar.api)
implementation(projects.components.rootscreen.api)
implementation(projects.components.info.shared)
implementation(projects.components.remoteControls.main.api)

// Compose
implementation(libs.compose.ui)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.flipperdevices.bottombar.handlers.ResetTabDecomposeHandler
import com.flipperdevices.core.di.AppGraph
import com.flipperdevices.deeplink.model.Deeplink
import com.flipperdevices.nfc.mfkey32.api.MfKey32DecomposeComponent
import com.flipperdevices.remotecontrols.api.RemoteControlsScreenDecomposeComponent
import com.flipperdevices.toolstab.api.ToolsDecomposeComponent
import com.flipperdevices.toolstab.impl.model.ToolsNavigationConfig
import com.flipperdevices.toolstab.impl.model.toConfigStack
Expand All @@ -26,7 +27,8 @@ class ToolsDecomposeComponentImpl @AssistedInject constructor(
@Assisted deeplink: Deeplink.BottomBar.ToolsTab?,
@Assisted private val onBack: DecomposeOnBackParameter,
private val hubMainFactory: ToolsMainScreenDecomposeComponentImpl.Factory,
private val mfKey32Factory: MfKey32DecomposeComponent.Factory
private val mfKey32Factory: MfKey32DecomposeComponent.Factory,
private val remoteControlsComponentFactory: RemoteControlsScreenDecomposeComponent.Factory,
) : ToolsDecomposeComponent<ToolsNavigationConfig>(),
ComponentContext by componentContext,
ResetTabDecomposeHandler {
Expand All @@ -51,6 +53,11 @@ class ToolsDecomposeComponentImpl @AssistedInject constructor(
componentContext = componentContext,
onBack = { navigation.popOr(onBack::invoke) }
)

ToolsNavigationConfig.RemoteControls -> remoteControlsComponentFactory(
componentContext = componentContext,
onBack = { navigation.popOr(onBack::invoke) }
)
}

override fun handleDeeplink(deeplink: Deeplink.BottomBar.ToolsTab) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class ToolsMainScreenDecomposeComponentImpl @AssistedInject constructor(
hasNotification = hasNotification,
onOpenMfKey32 = {
navigation.pushToFront(ToolsNavigationConfig.MfKey32)
},
onOpenRemoteControls = {
navigation.pushToFront(ToolsNavigationConfig.RemoteControls)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import androidx.compose.ui.Modifier
import com.flipperdevices.core.ui.ktx.OrangeAppBar
import com.flipperdevices.toolstab.impl.R
import com.flipperdevices.toolstab.impl.composable.elements.MifareClassicComposable
import com.flipperdevices.toolstab.impl.composable.elements.RemoteControlsComposable

@Composable
fun ComposableHub(
hasNotification: Boolean,
onOpenMfKey32: () -> Unit,
onOpenRemoteControls: () -> Unit,
modifier: Modifier = Modifier
) {
Column(modifier) {
Expand All @@ -21,5 +23,8 @@ fun ComposableHub(
hasMfKey32Notification = hasNotification,
onOpenMfKey32 = onOpenMfKey32
)
RemoteControlsComposable(
onOpenRemoteControls = onOpenRemoteControls
)
}
}
Loading
Loading