-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from remotv/develop
Allow for external apps to receive controls from this app
- Loading branch information
Showing
5 changed files
with
89 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
76 changes: 76 additions & 0 deletions
76
sdk/src/main/java/tv/remo/android/controller/sdk/components/RemoBroadcaster.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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?) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |