diff --git a/app/build.gradle.kts b/app/build.gradle.kts index ea66a51..7156aad 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -59,6 +59,7 @@ dependencies { implementation(libs.androidx.ui.graphics) implementation(libs.androidx.ui.tooling.preview) implementation(libs.androidx.material3) + implementation(libs.androidx.constraintlayout) testImplementation(libs.junit) androidTestImplementation(libs.androidx.junit) androidTestImplementation(libs.androidx.espresso.core) diff --git a/app/src/main/java/com/rlabs/dakc/DakcTileService.kt b/app/src/main/java/com/rlabs/dakc/DakcTileService.kt index 4995ebf..bbb3746 100644 --- a/app/src/main/java/com/rlabs/dakc/DakcTileService.kt +++ b/app/src/main/java/com/rlabs/dakc/DakcTileService.kt @@ -9,21 +9,6 @@ import java.io.InputStreamReader class DakcTileService : TileService() { - // Called when the user adds your tile. - override fun onTileAdded() { - super.onTileAdded() - } - - // Called when your app can update your tile. - override fun onStartListening() { - super.onStartListening() - } - - // Called when your app can no longer update your tile. - override fun onStopListening() { - super.onStopListening() - } - // Called when the user taps on your tile in an active or inactive state. override fun onClick() { super.onClick() @@ -31,13 +16,11 @@ class DakcTileService : TileService() { runAsRoot(arrayOf("tinymix -D 2 3 120")) } - // Called when the user removes your tile. - override fun onTileRemoved() { - super.onTileRemoved() - } } -fun runAsRoot(commands: Array) { +fun runAsRoot(commands: Array): Pair { + val output = StringBuilder() + val errorOutput = StringBuilder() try { for (command in commands) { @@ -47,8 +30,6 @@ fun runAsRoot(commands: Array) { // Read the output val reader = BufferedReader(InputStreamReader(process.inputStream)) val errorReader = BufferedReader(InputStreamReader(process.errorStream)) - val output = StringBuilder() - val errorOutput = StringBuilder() var line: String? while (reader.readLine().also { line = it } != null) { @@ -74,4 +55,5 @@ fun runAsRoot(commands: Array) { e.printStackTrace() } + return Pair(output, errorOutput) } \ No newline at end of file diff --git a/app/src/main/java/com/rlabs/dakc/MainActivity.kt b/app/src/main/java/com/rlabs/dakc/MainActivity.kt index 425b2b0..4b98f63 100644 --- a/app/src/main/java/com/rlabs/dakc/MainActivity.kt +++ b/app/src/main/java/com/rlabs/dakc/MainActivity.kt @@ -1,47 +1,35 @@ package com.rlabs.dakc import android.os.Bundle +import android.widget.TextView import androidx.activity.ComponentActivity -import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.padding -import androidx.compose.material3.Scaffold -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.tooling.preview.Preview -import com.rlabs.dakc.ui.theme.DAKCTheme class MainActivity : ComponentActivity() { + lateinit var dev1: TextView + lateinit var dev2: TextView override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) enableEdgeToEdge() - setContent { - DAKCTheme { - Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding -> - Greeting( - name = "DAkC", - modifier = Modifier.padding(innerPadding) - ) - } - } - } + setContentView(R.layout.activity_main) + dev1 = findViewById(R.id.dev1) + dev1.text = TinymixOut(device = "1") + + dev2 = findViewById(R.id.dev2) + dev2.text = TinymixOut(device = "2") } } -@Composable -fun Greeting(name: String, modifier: Modifier = Modifier) { - Text( - text = "Hello $name!", - modifier = modifier - ) -} +fun TinymixOut(device: String): String { + val outPair = runAsRoot(arrayOf("tinymix -D $device")) + + val out = outPair.first.toString() + val errout = outPair.second.toString() + + val firstLine = if (errout.isNotEmpty()) errout.split("\n")[0] else out.split("\n")[0] + +// Log.d("tinymix", firstLine) + + return "tinymix -D $device out: ${firstLine}!" -@Preview(showBackground = true) -@Composable -fun GreetingPreview() { - DAKCTheme { - Greeting("Android") - } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..11492fc --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,29 @@ + + + + + + + +