Skip to content

Commit

Permalink
Merge pull request #56 from remotv/develop
Browse files Browse the repository at this point in the history
Allow for external apps to receive controls from this app
  • Loading branch information
SkyeOfBreeze authored Oct 26, 2019
2 parents 67de072 + 76f66b4 commit 04859f4
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Currently under development. Not everything works at the moment, such as volume

The most stable code in the repo. Can be used for testing and is known to work

### devel
### develop

The latest code, mostly stable, but might have issues. Sometimes this code may not be buildable

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ android {
applicationId "tv.remo.android.controller"
minSdkVersion 16
targetSdkVersion 28
versionCode 3
versionName "0.9.3"
versionCode 4
versionName "0.10.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
8 changes: 7 additions & 1 deletion sdk/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tv.remo.android.controller.sdk"/>
package="tv.remo.android.controller.sdk">
<permission
android:name="tv.remo.android.controller.sdk.socket.controls"
android:label="@string/controlSocketLabel"
android:description="@string/controlSocketLabelPermissionDescription"
android:protectionLevel="dangerous" />
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package tv.remo.android.controller.sdk.components

import android.app.Activity
import android.content.Context
import android.content.Intent
import org.btelman.controlsdk.enums.ComponentStatus
import org.btelman.controlsdk.hardware.interfaces.DriverComponent
import org.btelman.controlsdk.hardware.interfaces.HardwareDriver
import java.nio.charset.Charset

/**
* Created by Brendon on 9/22/2019.
*/
@DriverComponent(
description = "Broadcasts controls to other apps that were given permission. Only supports ArduinoSendString",
requiresSetup = false
)
class RemoBroadcaster : HardwareDriver{
private lateinit var context: Context

override fun enable() {

}

override fun disable() {
sendToBroadcast("stop")
}

override fun getStatus(): ComponentStatus {
return ComponentStatus.STABLE
}

override fun initConnection(context: Context) {
this.context = context
}

override fun isConnected(): Boolean {
return true
}

override fun send(byteArray: ByteArray): Boolean {
sendToBroadcast(byteArray.toString(Charset.defaultCharset()))
return true
}

fun sendToBroadcast(data : String){
val intent = Intent("tv.remo.android.controller.sdk.socket.controls").apply {
putExtra("command", data)
}
context.sendBroadcast(intent)
}

override fun setupComponent(activity: Activity, force: Boolean): Int {
return -1
}

override fun usesCustomSetup(): Boolean {
return false
}

override fun clearSetup(context: Context) {

}

override fun getAutoReboot(): Boolean {
return false
}

override fun needsSetup(activity: Activity): Boolean {
return false
}

override fun receivedComponentSetupDetails(context: Context, intent: Intent?) {

}
}
3 changes: 3 additions & 0 deletions sdk/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<resources>
<string name="app_name">sdk</string>
<string name="controlSocketLabel">Remo.TV Control Socket Broadcast</string>
<string name="controlSocketLabelPermissionDescription">Once this app has access, it can listen for
controls from the app that will go to motors</string>
</resources>

0 comments on commit 04859f4

Please sign in to comment.