-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show tinymix outputs dor device 1 and 2 in main activity
- Loading branch information
1 parent
d86a954
commit 9a84b5f
Showing
4 changed files
with
54 additions
and
54 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,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") | ||
} | ||
} |
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,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".MainActivity"> | ||
|
||
<TextView | ||
android:text="TextView" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/dev1" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
android:layout_marginTop="48dp" | ||
android:layout_marginStart="32dp" /> | ||
|
||
<TextView | ||
android:text="TextView" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/dev2" | ||
app:layout_constraintTop_toBottomOf="@+id/dev1" | ||
app:layout_constraintStart_toStartOf="parent" | ||
android:layout_marginStart="32dp" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |