Skip to content

Commit

Permalink
add input button (#14)
Browse files Browse the repository at this point in the history
* add input button

* up version 0.6.0
  • Loading branch information
makeevrserg authored Sep 17, 2024
1 parent 29660a6 commit 0180598
Show file tree
Hide file tree
Showing 15 changed files with 169 additions and 79 deletions.
2 changes: 1 addition & 1 deletion IRDB
Submodule IRDB updated 796 files
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.parallel=true
makeevrserg.project.name=IRDBBackend
makeevrserg.project.url=https://github.com/flipperdevices/IRDB-Backend
makeevrserg.project.group=com.flipperdevices.ifrmvp.backend
makeevrserg.project.version.string=0.5.1
makeevrserg.project.version.string=0.6.0
makeevrserg.project.description=Api for IfrSample
makeevrserg.project.developers=makeevrserg|Makeev Roman|[email protected]
# Java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ object SignalTable : LongIdTable("SIGNAL_TABLE") {

init {
uniqueIndex(
name,
brandId,
type,
frequency,
dutyCycle,
data
)
uniqueIndex(
name,
brandId,
type,
protocol,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@ object DeviceKeyExt {
DeviceKey.FAVORITE -> listOf(
CategoryType.BOX
)

DeviceKey.INPUT -> listOf(
CategoryType.BOX,
CategoryType.DVD,
CategoryType.TVS,

)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.flipperdevices.ifrmvp.generator.config.device.api.any

import com.flipperdevices.ifrmvp.backend.model.DeviceConfiguration
import com.flipperdevices.ifrmvp.backend.model.DeviceKey
import com.flipperdevices.ifrmvp.generator.config.device.api.DeviceKeyNamesProvider
import java.io.File
import kotlinx.serialization.json.Json

object AnyDeviceKeyNamesProvider : DeviceKeyNamesProvider {
@Suppress("LongMethod", "CyclomaticComplexMethod")
Expand Down Expand Up @@ -406,6 +409,28 @@ object AnyDeviceKeyNamesProvider : DeviceKeyNamesProvider {
DeviceKey.LIGHT -> listOf(
"light"
)

DeviceKey.INPUT -> listOf(
"input",
"input_r",
"input method",
"next_input",
"pipinput_r",
"pipinput",
"input_next",
"input_source"
)
}
}
}

// For docs
fun main() {
DeviceKey.entries.forEach { deviceKey ->
println("#### ${deviceKey.name}")
AnyDeviceKeyNamesProvider.getKeyNames(deviceKey).forEach { alias ->
println("- $alias")
}
println()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,7 @@ internal class FillerController(private val database: Database) : CoroutineScope
this[SignalKeyTable.type] = IfrKeyIdentifier.Empty.TYPE
}

is IfrKeyIdentifier.Name -> {
this[SignalKeyTable.remoteKeyName] = keyIdentifier.name
this[SignalKeyTable.type] = IfrKeyIdentifier.Name.TYPE
}
is IfrKeyIdentifier.Name -> error("Identifying by name is not possible!")

is IfrKeyIdentifier.Sha256 -> {
this[SignalKeyTable.remoteKeyName] = keyIdentifier.name
Expand All @@ -194,9 +191,7 @@ internal class FillerController(private val database: Database) : CoroutineScope
andWhere { SignalTable.hash eq keyIdentifier.hash }
}

is IfrKeyIdentifier.Name -> {
andWhere { SignalTable.name eq keyIdentifier.name }
}
is IfrKeyIdentifier.Name -> error("Identifying by name is not possible!")
}
}
.map { it[SignalTable.id] }
Expand Down
1 change: 1 addition & 0 deletions modules/kenerator/ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ dependencies {
implementation(projects.modules.infrared)
implementation(projects.modules.kenerator.configuration)
implementation(projects.modules.kenerator.paths)
implementation(projects.modules.resources)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import com.flipperdevices.ifrmvp.kenerator.ui.button.ChannelButton
import com.flipperdevices.ifrmvp.kenerator.ui.button.NavigationButton
import com.flipperdevices.ifrmvp.kenerator.ui.button.OkNavigationButton
import com.flipperdevices.ifrmvp.kenerator.ui.button.VolButton
import com.flipperdevices.ifrmvp.model.buttondata.Base64ImageButtonData
import com.flipperdevices.ifrmvp.model.buttondata.ButtonData
import com.flipperdevices.ifrmvp.model.buttondata.IconButtonData
import com.flipperdevices.ifrmvp.model.buttondata.IconButtonData.IconType
import com.flipperdevices.ifrmvp.model.buttondata.PowerButtonData
import com.flipperdevices.ifrmvp.model.buttondata.ShutterButtonData
import com.flipperdevices.ifrmvp.model.buttondata.TextButtonData
import com.flipperdevices.ifrmvp.resources.CoreR
import com.flipperdevices.infrared.editor.encoding.InfraredRemoteEncoder.identifier
import com.flipperdevices.infrared.editor.model.InfraredRemote

Expand Down Expand Up @@ -286,6 +287,10 @@ internal object RemotesListExt {
IconButtonData(keyIdentifier = remote.identifier, iconId = IconType.FAVORITE)
}

DeviceKey.INPUT -> remotes.findByKey(deviceKey)?.let { remote ->
Base64ImageButtonData(keyIdentifier = remote.identifier, pngBase64 = CoreR.inputImage.toBase64())
}

DeviceKey.RECORD -> remotes.findByKey(deviceKey)?.let { remote ->
IconButtonData(keyIdentifier = remote.identifier, iconId = IconType.RECORD)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,71 +5,79 @@ package com.flipperdevices.ifrmvp.backend.model
*
* The keys have comments in which devices they are present
*/
enum class DeviceKey {
PWR,
SHUTTER,
VOL_UP,
VOL_DOWN,
CH_UP,
CH_DOWN,
FOCUS_MORE,
FOCUS_LESS,
ZOOM_UP,
ZOOM_DOWN,
RESET,
DOWN,
UP,
RIGHT,
LEFT,
NEXT,
PREVIOUS,
TV,
AUX,
HOME,
BACK,
MENU,
PLAY,
MUTE,
EJECT,
FAN_SPEED,
NEAR,
FAR,
PAUSE,
RECORD,
WIND_SPEED,
MODE,
LIGHT,
FAN_MEDIUM,
FAN_HIGH,
FAN_LOW,
STOP,
EXIT,
INFO,
TIMER,
OSCILLATE,
TIMER_ADD,
TIMER_REDUCE,
FAN_SPEED_UP,
FAN_SPEED_DOWN,
SLEEP,
SHAKE_WIND,
SWING,
OFF,
BRIGHTNESS_UP,
BRIGHTNESS_DOWN,
COLD_WIND,
COOL,
WIND_TYPE,
TEMPERATURE_UP,
TEMPERATURE_DOWN,
HEAT_ADD,
HEAT_REDUCE,
ENERGY_SAVE,
OK,
REW,
SET,
DELETE,
VOD,
LIVE_TV,
FAVORITE
enum class DeviceKey(val desc: String) {
PWR("Power enable button"),
SHUTTER("Take a photo with camera"),
VOL_UP("Increase volume"),
VOL_DOWN("Decrease volume"),
CH_UP("Next channel"),
CH_DOWN("Previous channel"),
FOCUS_MORE("Add focus"),
FOCUS_LESS("Decrease focus"),
ZOOM_UP("Zoom up"),
ZOOM_DOWN("Zoom down"),
RESET("Reset"),
DOWN("Navigation button(for TV menu, for example) - down"),
UP("Navigation button(for TV menu, for example) - up"),
RIGHT("Navigation button(for TV menu, for example) - right"),
LEFT("Navigation button(for TV menu, for example) - left"),
NEXT("Next button for TV box"),
PREVIOUS("Previous button for TV box"),
TV("TV button fot TVs"),
AUX("Change AUX mode"),
HOME("Home button"),
BACK("Back button"),
MENU("Show/Open menu"),
PLAY("Play/Resume playback"),
MUTE("Mute sound"),
EJECT("Eject disk"),
FAN_SPEED("Change fan speed recursively"),
NEAR("Near camera clipping plane"),
FAR("Far camera clipping plane"),
PAUSE("Pause playback"),
RECORD("Start recording"),
WIND_SPEED("Change wind speed recursively"),
MODE("Change mode (TV Box, DVD)"),
LIGHT("Increase/Decrease light recursively"),
FAN_MEDIUM("Set fan speed to medium"),
FAN_HIGH("Set fan mode to high"),
FAN_LOW("Change fan speed to low"),
STOP("Stop button (mostly for TV Box)"),
EXIT("Exit(from menu, etc)"),
INFO("Show info"),
TIMER("Start timer, show timer menu"),
OSCILLATE("Start oscillating (mostly for fans)"),
TIMER_ADD("Increase timer value"),
TIMER_REDUCE("Decrease timer value"),
FAN_SPEED_UP("Increase fan speed"),
FAN_SPEED_DOWN("Decrease fan speed"),
SLEEP("Start sleep mode"),
SHAKE_WIND("Same as oscillate, start shaking"),
SWING("Same as oscillate, start swing"),
OFF("Turn off the device"),
BRIGHTNESS_UP("Increase brightness"),
BRIGHTNESS_DOWN("Decrease brightness"),
COLD_WIND("Set wind cold"),
COOL("Set/increase cool"),
WIND_TYPE("Change wind type"),
TEMPERATURE_UP("Increase temperature"),
TEMPERATURE_DOWN("Decrease temperature"),
HEAT_ADD("Add heat"),
HEAT_REDUCE("Reduce heat"),
ENERGY_SAVE("Enter energy save mode"),
OK("Ok button(mostly where up/left/right/down buttons located"),
REW("Rewind button(mostly for playback)"),
SET("Set button(mostly for TV box)"),
DELETE("Delete button(mostly for TV Box)"),
VOD("Enable VODs"),
LIVE_TV("Set TV mode"),
FAVORITE("Add to favorite"),
INPUT("Input button to change input source(hdmi, tv, etc)")
}

// Generate docs text
fun main() {
DeviceKey.entries.forEach {
println("- `${it.name}` -> ${it.desc}")
}
}
8 changes: 8 additions & 0 deletions modules/resources/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import ru.astrainteractive.gradleplugin.property.extension.ModelPropertyValueExt.requireProjectInfo

plugins {
id("org.jetbrains.kotlin.jvm")
}
dependencies {
testImplementation(kotlin("test"))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.flipperdevices.ifrmvp.resources

object CoreR {
val inputImage = ServerResource.Image("/images/input.png")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.flipperdevices.ifrmvp.resources

import java.io.InputStream
import kotlin.io.encoding.Base64
import kotlin.io.encoding.ExperimentalEncodingApi

sealed interface ServerResource {
fun openStream(): InputStream

class Image(val path: String) : ServerResource {
override fun openStream(): InputStream {
val resource = object {}.javaClass.getResource(path)
return resource?.openStream() ?: error("Could not load file $path")
}

@OptIn(ExperimentalEncodingApi::class)
fun toBase64(): String {
return openStream().use {
PNG_BASE64_HEADER + Base64.encode(it.readAllBytes())
}
}

companion object {
private const val PNG_BASE64_HEADER = "data:image/png;base64,"
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.flipperdevices.ifrmvp.resources

import kotlin.test.Test

class ServerResourceTest {
@Test
fun testResource() {
println(CoreR.inputImage.toBase64())
}
}
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ include(":modules:build-konfig")
include(":modules:core")
include(":modules:model")
include(":modules:infrared")
include(":modules:resources")
// generators
include(":modules:kenerator:configuration")
include(":modules:kenerator:sql")
Expand Down

0 comments on commit 0180598

Please sign in to comment.