Skip to content

Commit

Permalink
Merge branch 'dev' into remotecontrols/add-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
makeevrserg committed Sep 10, 2024
2 parents 3f5ad70 + eb5e3e0 commit d8359e6
Show file tree
Hide file tree
Showing 86 changed files with 1,560 additions and 133 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Attention: don't forget to add the flag for F-Droid before release
- [Feature] Better user-ux when configuring remote control
- [Feature] Add flipper action dialogs into remote control and move it into bottombar
- [Feature] Add error display into remote controls screens
- [Feature] Add new icons for remote-controls
- [Refactor] Load RemoteControls from flipper, emulating animation
- [Refactor] Update to Kotlin 2.0
- [Refactor] Replace Ktorfit with Ktor requests in remote-controls
Expand All @@ -38,6 +39,7 @@ Attention: don't forget to add the flag for F-Droid before release
- [FIX] Fix flaky test
- [FIX] Infinite dispatch after screen close on remote-control screens
- [FIX] Bad bottom sheet animation on infrared setup screen
- [FIX] Share infrared remote after rename
- [CI] Fix merge-queue files diff
- [CI] Add https://github.com/LionZXY/detekt-decompose-rule
- [CI] Enabling detekt module for android and kmp modules
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class InfraredViewDecomposeComponentImpl @AssistedInject constructor(
}

shareBottomUiApi.ComposableShareBottomSheet(
viewModel.keyPath,
provideFlipperKeyPath = viewModel::getKeyPath,
onSheetStateVisible = { isShown, onClose ->
val isBackPressHandled by isBackPressHandledFlow.collectAsState()
backCallback.isEnabled = isShown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.flipperdevices.core.ui.lifecycle.DecomposeViewModel
import com.flipperdevices.infrared.api.InfraredConnectionApi
import com.flipperdevices.infrared.api.InfraredConnectionApi.InfraredEmulateState
import com.flipperdevices.keyscreen.api.KeyStateHelperApi
import com.flipperdevices.keyscreen.model.KeyScreenState
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
Expand All @@ -19,16 +20,23 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach

class InfraredViewModel @AssistedInject constructor(
@Assisted val keyPath: FlipperKeyPath, // For get value to bottom sheet
@Assisted private val paramKeyPath: FlipperKeyPath, // For get value to bottom sheet
keyStateHelperApi: KeyStateHelperApi.Builder,
serviceProvider: FlipperServiceProvider,
private val infraredConnectionApi: InfraredConnectionApi
) : DecomposeViewModel(), FlipperBleServiceConsumer, LogTagProvider {
override val TAG: String = "InfraredViewModel"

private val keyStateHelper = keyStateHelperApi.build(keyPath, viewModelScope)
private val keyStateHelper = keyStateHelperApi.build(paramKeyPath, viewModelScope)
fun getState() = keyStateHelper.getKeyScreenState()

fun getKeyPath(): FlipperKeyPath {
return (keyStateHelper.getKeyScreenState().value as? KeyScreenState.Ready)
?.flipperKey
?.getKeyPath()
?: paramKeyPath
}

private val emulateStateFlow = MutableStateFlow<InfraredEmulateState?>(null)
fun getEmulateState() = emulateStateFlow.asStateFlow()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class KeyScreenViewDecomposeComponentImpl @AssistedInject constructor(
keyScreenViewModelFactory(keyPath)
}
shareBottomApi.ComposableShareBottomSheet(
flipperKeyPath = viewModel.keyPath,
provideFlipperKeyPath = viewModel::getKeyPath,
onSheetStateVisible = { isShown, onClose ->
val isBackPressHandled by isBackPressHandledFlow.collectAsState()
backCallback.isEnabled = isShown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@ import kotlinx.coroutines.flow.StateFlow

@Suppress("LongParameterList")
class KeyScreenViewModel @AssistedInject constructor(
@Assisted val keyPath: FlipperKeyPath, // For get value to bottom sheet
@Assisted val paramKeyPath: FlipperKeyPath, // For get value to bottom sheet
keyStateHelperApi: KeyStateHelperApi.Builder,
private val metricApi: MetricApi
) : DecomposeViewModel(), LogTagProvider {
override val TAG = "KeyScreenViewModel"

private val keyStateHelper = keyStateHelperApi.build(keyPath, viewModelScope)
private val keyStateHelper = keyStateHelperApi.build(paramKeyPath, viewModelScope)

fun getKeyPath(): FlipperKeyPath {
return (keyStateHelper.getKeyScreenState().value as? KeyScreenState.Ready)
?.flipperKey
?.getKeyPath()
?: paramKeyPath
}

fun getKeyScreenState(): StateFlow<KeyScreenState> = keyStateHelper.getKeyScreenState()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,76 @@ data class IconButtonData(
override val type: ButtonData.ButtonType = ButtonData.ButtonType.ICON

enum class IconType {
BACK, HOME, INFO, MORE, MUTE,
POWER, COOL, HEAT, FAN, CAMERA,
BRIGHT_MORE, BRIGHT_LESS,
PAUSE, PLAY, STOP, EXIT,
MENU, ZOOM_IN, ZOOM_OUT,
RESET, NEXT, PREVIOUS,
EJECT, RECORD, WIND_SPEED,
MODE, LIGHT, TIMER, OFF,
DELETE, LIVE_TV, FAVORITE,
ENERGY_SAVE, VOL_UP, VOL_DOWN
ADD_PLUS_MORE,
AUX,
BACK,
BRIGHT_LESS,
BRIGHT_MORE,
CH_DOWN,
CH_UP,
COLD_WIND,
COOL,
DELETE,
DOWN,
EJECT,
ENERGY_SAVE,
EXIT,
FAN_HIGH,
FAN_MEDIUM,
FAN_LOW,
FAN_OFF,
FAN_SPEED,
FAN_SPEED_DOWN,
FAN_SPEED_UP,
FAR,
FAVORITE,
FOCUS_LESS,
FOCUS_MORE,
FORWARD,
HEAT_ADD,
HEAT_REDUCE,
HOME,
INFO,
LEFT,
LIGHT,
LIVE_TV,
MENU,
MODE,
MUTE,
NEAR,
NEXT,
OK,
OSCILLATE,
PAUSE,
PREVIOUS,
POWER,
RECORD,
REMOVE_MINUS_LESS,
RESET,
REWIND,
RIGHT,
SETTINGS,
SHAKE_WIND,
CAMERA,
SLEEP,
STOP,
SWING,
TEMPERATURE_DOWN,
TEMPERATURE_UP,
TIMER,
TIMER_ADD,
TIMER_REDUCE,
TV,
UP,
VOD,
VOL_DOWN,
VOL_UP,
WIND_SPEED,
WIND_TYPE,
ZOOM_OUT,
ZOOM_IN,
PLAY,
MORE,
HEAT,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,21 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowLeft
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
import androidx.compose.material.icons.filled.KeyboardArrowDown
import androidx.compose.material.icons.filled.KeyboardArrowUp
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import com.flipperdevices.core.ui.theme.FlipperThemeInternal
import com.flipperdevices.core.ui.theme.LocalPalletV2
import com.flipperdevices.ifrmvp.core.ui.button.core.EmulatingBox
import com.flipperdevices.ifrmvp.core.ui.button.core.NoConnectionBox
import com.flipperdevices.ifrmvp.core.ui.button.core.SyncingBox
import com.flipperdevices.ifrmvp.core.ui.layout.core.sf
import com.flipperdevices.ifrmvp.core.ui.layout.core.sfp
import com.flipperdevices.ifrmvp.core.ui.util.GridConstants
import com.flipperdevices.remotecontrols.core.ui.R as RemoteControlsR

@Suppress("LongMethod")
@Composable
Expand All @@ -44,7 +38,6 @@ fun NavigationButton(
modifier: Modifier = Modifier,
background: Color = LocalPalletV2.current.surface.menu.body.dufault,
iconTint: Color = MaterialTheme.colors.onPrimary,
textColor: Color = MaterialTheme.colors.onPrimary,
) {
Box(
modifier = modifier
Expand All @@ -55,7 +48,7 @@ fun NavigationButton(
contentAlignment = Alignment.Center
) {
Icon(
painter = rememberVectorPainter(Icons.Filled.KeyboardArrowUp),
painter = painterResource(RemoteControlsR.drawable.ic_rc_up),
tint = iconTint,
contentDescription = null,
modifier = Modifier
Expand All @@ -65,7 +58,7 @@ fun NavigationButton(
.align(Alignment.TopCenter)
)
Icon(
painter = rememberVectorPainter(Icons.AutoMirrored.Filled.KeyboardArrowLeft),
painter = painterResource(RemoteControlsR.drawable.ic_rc_left),
tint = iconTint,
contentDescription = null,
modifier = Modifier
Expand All @@ -88,19 +81,18 @@ fun NavigationButton(
.align(Alignment.Center),
contentAlignment = Alignment.Center,
content = {
Text(
text = "OK",
style = MaterialTheme.typography.caption,
color = textColor,
fontSize = 16.sfp,
lineHeight = 2.sfp
Icon(
painter = painterResource(RemoteControlsR.drawable.ic_rc_ok),
tint = MaterialTheme.colors.onPrimary,
contentDescription = null,
modifier = Modifier.size(48.sf)
)
}
)
}

Icon(
painter = rememberVectorPainter(Icons.AutoMirrored.Filled.KeyboardArrowRight),
painter = painterResource(RemoteControlsR.drawable.ic_rc_right),
tint = iconTint,
contentDescription = null,
modifier = Modifier
Expand All @@ -111,7 +103,7 @@ fun NavigationButton(
)

Icon(
painter = rememberVectorPainter(Icons.Filled.KeyboardArrowDown),
painter = painterResource(RemoteControlsR.drawable.ic_rc_down),
tint = iconTint,
contentDescription = null,
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,19 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.CameraAlt
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import com.flipperdevices.core.ui.ktx.clickableRipple
import com.flipperdevices.core.ui.theme.FlipperThemeInternal
import com.flipperdevices.core.ui.theme.LocalPalletV2
import com.flipperdevices.ifrmvp.core.ui.button.core.EmulatingBox
import com.flipperdevices.ifrmvp.core.ui.button.core.SyncingBox
import com.flipperdevices.ifrmvp.core.ui.layout.core.sf
import com.flipperdevices.remotecontrols.core.ui.R as RemoteControlsR

@Composable
fun ShutterButtonComposable(
Expand All @@ -49,7 +48,7 @@ fun ShutterButtonComposable(
contentAlignment = Alignment.Center
) {
Icon(
painter = rememberVectorPainter(Icons.Default.CameraAlt),
painter = painterResource(RemoteControlsR.drawable.ic_rc_shutter),
tint = MaterialTheme.colors.onPrimary,
contentDescription = null,
modifier = Modifier.size(48.sf)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fun SquareIconButton(
tint = iconTint,
modifier = Modifier
.fillMaxSize()
.padding(12.sf)
.padding(8.sf)
)
}
}
Expand Down
Loading

0 comments on commit d8359e6

Please sign in to comment.