diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 58bf361..18e3671 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -6,9 +6,9 @@ device.powerOnUrl - TriggerAction.POWER_OFF -> device.powerOffUrl - TriggerAction.REBOOT -> device.rebootUrl + return when (action) { + TriggerAction.POWER_ON -> { + Request.Builder() + .url(device.powerOnUrl) + .get() + .build() + } + TriggerAction.POWER_OFF -> { + val jsonPayload = """{"node":"${device.node}"}""" + val body = jsonPayload.toRequestBody(jsonMediaType) + Request.Builder() + .url(device.powerOffUrl) + .addHeader("Content-Type", "application/json") + .addHeader("X-Secret-Key", device.secretKey) + .post(body) + .build() + } + TriggerAction.REBOOT -> { + val jsonPayload = """{"node":"${device.node}"}""" + val body = jsonPayload.toRequestBody(jsonMediaType) + Request.Builder() + .url(device.rebootUrl) + .addHeader("Content-Type", "application/json") + .addHeader("X-Secret-Key", device.secretKey) + .post(body) + .build() + } } - - val jsonPayload = """{"node":"${device.node}"}""" - val body = jsonPayload.toRequestBody(jsonMediaType) - - return Request.Builder() - .url(targetUrl) - .addHeader("Content-Type", "application/json") - .addHeader("X-Secret-Key", device.secretKey) - .post(body) - .build() } fun sendTrigger( diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..8a7cfa6 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..4df52ae Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..71fde80 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..6819087 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..fefeeb6 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..fefeeb6 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..9de7883 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..9de7883 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..4be5510 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..4be5510 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/app/src/test/java/com/expapp/trigger/network/TriggerClientTest.kt b/app/src/test/java/com/expapp/trigger/network/TriggerClientTest.kt index 9316171..b93a3da 100644 --- a/app/src/test/java/com/expapp/trigger/network/TriggerClientTest.kt +++ b/app/src/test/java/com/expapp/trigger/network/TriggerClientTest.kt @@ -64,12 +64,13 @@ class TriggerClientTest { } @Test - fun buildRequest_powerOn_usesPowerOnUrl() { + fun buildRequest_powerOn_usesGetMethodWithoutSecretKey() { val request = client.buildRequest(sampleDevice, TriggerAction.POWER_ON) - assertEquals("POST", request.method) + assertEquals("GET", request.method) assertEquals("https://cosmos.linuxguy.space/poweron", request.url.toString()) - assertEquals("Carbon@12", request.header("X-Secret-Key")) + org.junit.Assert.assertNull(request.header("X-Secret-Key")) + org.junit.Assert.assertNull(request.body) } @Test