diff --git a/IRDB b/IRDB index 9fd968f..7f31653 160000 --- a/IRDB +++ b/IRDB @@ -1 +1 @@ -Subproject commit 9fd968fe529b5415dd17d505d9577864b215d7cb +Subproject commit 7f316534e15946485ea5cdd94d6b05f87e349e27 diff --git a/gradle.properties b/gradle.properties index f5d77bb..4e86d4c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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|makeevrserg@gmail.com # Java diff --git a/modules/database/src/main/kotlin/com/flipperdevices/ifrmvp/backend/db/signal/table/SignalTable.kt b/modules/database/src/main/kotlin/com/flipperdevices/ifrmvp/backend/db/signal/table/SignalTable.kt index 7baf1aa..f4f97df 100644 --- a/modules/database/src/main/kotlin/com/flipperdevices/ifrmvp/backend/db/signal/table/SignalTable.kt +++ b/modules/database/src/main/kotlin/com/flipperdevices/ifrmvp/backend/db/signal/table/SignalTable.kt @@ -24,7 +24,6 @@ object SignalTable : LongIdTable("SIGNAL_TABLE") { init { uniqueIndex( - name, brandId, type, frequency, @@ -32,7 +31,6 @@ object SignalTable : LongIdTable("SIGNAL_TABLE") { data ) uniqueIndex( - name, brandId, type, protocol, diff --git a/modules/kenerator/configuration/src/main/kotlin/com/flipperdevices/ifrmvp/generator/config/category/api/DeviceKeyExt.kt b/modules/kenerator/configuration/src/main/kotlin/com/flipperdevices/ifrmvp/generator/config/category/api/DeviceKeyExt.kt index 8bfef87..0adf56d 100644 --- a/modules/kenerator/configuration/src/main/kotlin/com/flipperdevices/ifrmvp/generator/config/category/api/DeviceKeyExt.kt +++ b/modules/kenerator/configuration/src/main/kotlin/com/flipperdevices/ifrmvp/generator/config/category/api/DeviceKeyExt.kt @@ -191,6 +191,13 @@ object DeviceKeyExt { DeviceKey.FAVORITE -> listOf( CategoryType.BOX ) + + DeviceKey.INPUT -> listOf( + CategoryType.BOX, + CategoryType.DVD, + CategoryType.TVS, + + ) } } } diff --git a/modules/kenerator/configuration/src/main/kotlin/com/flipperdevices/ifrmvp/generator/config/device/api/any/AnyDeviceKeyNamesProvider.kt b/modules/kenerator/configuration/src/main/kotlin/com/flipperdevices/ifrmvp/generator/config/device/api/any/AnyDeviceKeyNamesProvider.kt index 7169e14..b9a7ecf 100644 --- a/modules/kenerator/configuration/src/main/kotlin/com/flipperdevices/ifrmvp/generator/config/device/api/any/AnyDeviceKeyNamesProvider.kt +++ b/modules/kenerator/configuration/src/main/kotlin/com/flipperdevices/ifrmvp/generator/config/device/api/any/AnyDeviceKeyNamesProvider.kt @@ -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") @@ -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() + } +} \ No newline at end of file diff --git a/modules/kenerator/sql/src/main/kotlin/com/flipperdevices/ifrmvp/parser/presentation/FillerController.kt b/modules/kenerator/sql/src/main/kotlin/com/flipperdevices/ifrmvp/parser/presentation/FillerController.kt index 7fdfd65..5e367b2 100644 --- a/modules/kenerator/sql/src/main/kotlin/com/flipperdevices/ifrmvp/parser/presentation/FillerController.kt +++ b/modules/kenerator/sql/src/main/kotlin/com/flipperdevices/ifrmvp/parser/presentation/FillerController.kt @@ -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 @@ -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] } diff --git a/modules/kenerator/ui/build.gradle.kts b/modules/kenerator/ui/build.gradle.kts index 981256d..a45dd23 100644 --- a/modules/kenerator/ui/build.gradle.kts +++ b/modules/kenerator/ui/build.gradle.kts @@ -19,4 +19,5 @@ dependencies { implementation(projects.modules.infrared) implementation(projects.modules.kenerator.configuration) implementation(projects.modules.kenerator.paths) + implementation(projects.modules.resources) } diff --git a/modules/kenerator/ui/src/main/kotlin/com/flipperdevices/ifrmvp/kenerator/ui/util/RemotesListExt.kt b/modules/kenerator/ui/src/main/kotlin/com/flipperdevices/ifrmvp/kenerator/ui/util/RemotesListExt.kt index a8df8e1..966d5b4 100644 --- a/modules/kenerator/ui/src/main/kotlin/com/flipperdevices/ifrmvp/kenerator/ui/util/RemotesListExt.kt +++ b/modules/kenerator/ui/src/main/kotlin/com/flipperdevices/ifrmvp/kenerator/ui/util/RemotesListExt.kt @@ -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 @@ -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) } diff --git a/modules/model/src/commonMain/kotlin/com/flipperdevices/ifrmvp/backend/model/DeviceKey.kt b/modules/model/src/commonMain/kotlin/com/flipperdevices/ifrmvp/backend/model/DeviceKey.kt index 63a2802..403c0b9 100644 --- a/modules/model/src/commonMain/kotlin/com/flipperdevices/ifrmvp/backend/model/DeviceKey.kt +++ b/modules/model/src/commonMain/kotlin/com/flipperdevices/ifrmvp/backend/model/DeviceKey.kt @@ -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}") + } } diff --git a/modules/resources/build.gradle.kts b/modules/resources/build.gradle.kts new file mode 100644 index 0000000..4d0ab23 --- /dev/null +++ b/modules/resources/build.gradle.kts @@ -0,0 +1,8 @@ +import ru.astrainteractive.gradleplugin.property.extension.ModelPropertyValueExt.requireProjectInfo + +plugins { + id("org.jetbrains.kotlin.jvm") +} +dependencies { + testImplementation(kotlin("test")) +} \ No newline at end of file diff --git a/modules/resources/src/main/kotlin/com/flipperdevices/ifrmvp/resources/CoreR.kt b/modules/resources/src/main/kotlin/com/flipperdevices/ifrmvp/resources/CoreR.kt new file mode 100644 index 0000000..ef7355a --- /dev/null +++ b/modules/resources/src/main/kotlin/com/flipperdevices/ifrmvp/resources/CoreR.kt @@ -0,0 +1,5 @@ +package com.flipperdevices.ifrmvp.resources + +object CoreR { + val inputImage = ServerResource.Image("/images/input.png") +} \ No newline at end of file diff --git a/modules/resources/src/main/kotlin/com/flipperdevices/ifrmvp/resources/ServerResource.kt b/modules/resources/src/main/kotlin/com/flipperdevices/ifrmvp/resources/ServerResource.kt new file mode 100644 index 0000000..40dd39f --- /dev/null +++ b/modules/resources/src/main/kotlin/com/flipperdevices/ifrmvp/resources/ServerResource.kt @@ -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," + } + } +} \ No newline at end of file diff --git a/modules/resources/src/main/resources/images/input.png b/modules/resources/src/main/resources/images/input.png new file mode 100644 index 0000000..2e3c6d5 Binary files /dev/null and b/modules/resources/src/main/resources/images/input.png differ diff --git a/modules/resources/src/test/kotlin/com/flipperdevices/ifrmvp/resources/ServerResourceTest.kt b/modules/resources/src/test/kotlin/com/flipperdevices/ifrmvp/resources/ServerResourceTest.kt new file mode 100644 index 0000000..17b3ab5 --- /dev/null +++ b/modules/resources/src/test/kotlin/com/flipperdevices/ifrmvp/resources/ServerResourceTest.kt @@ -0,0 +1,10 @@ +package com.flipperdevices.ifrmvp.resources + +import kotlin.test.Test + +class ServerResourceTest { + @Test + fun testResource() { + println(CoreR.inputImage.toBase64()) + } +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 733bf5b..5a4e810 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -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")