Skip to content

Commit

Permalink
Improve Layout
Browse files Browse the repository at this point in the history
Add more output and fix margins
  • Loading branch information
rustammendel committed Jul 15, 2024
1 parent 6f16e64 commit ea5fe34
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 10 deletions.
26 changes: 22 additions & 4 deletions app/src/main/java/com/rlabs/dakc/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package com.rlabs.dakc

import android.os.Bundle
import android.util.Log
import android.widget.Button
import android.widget.TextView
import androidx.activity.ComponentActivity
import androidx.activity.enableEdgeToEdge

class MainActivity : ComponentActivity() {
lateinit var dev1: TextView
lateinit var dev2: TextView
lateinit var dev3: TextView
lateinit var button1: Button
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
Expand All @@ -17,19 +21,33 @@ class MainActivity : ComponentActivity() {

dev2 = findViewById(R.id.dev2)
dev2.text = TinymixOut(device = "2")

dev3 = findViewById(R.id.dev3)
dev3.text = TinymixOut(device = "2", 7)


button1 = findViewById(R.id.button1)
button1.setOnClickListener {
dev1.text = TinymixOut(device = "1")
dev2.text = TinymixOut(device = "2")
dev3.text = TinymixOut(device = "2", 7)
}

}


}

fun TinymixOut(device: String): String {
fun TinymixOut(device: String, lineNum: Int = 0): 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]
val firstLine = if (errout.isNotEmpty()) errout.split("\n")[0] else out.split("\n")[lineNum]

// Log.d("tinymix", firstLine)
Log.d("tinymix", out)

return "tinymix -D $device out: ${firstLine}!"
return "tinymix -D $device out: \n$firstLine"

}
36 changes: 30 additions & 6 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<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"
Expand All @@ -12,10 +11,11 @@
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" />
android:layout_marginStart="16dp"
android:textSize="16sp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="48dp" />

<TextView
android:text="TextView"
Expand All @@ -24,6 +24,30 @@
android:id="@+id/dev2"
app:layout_constraintTop_toBottomOf="@+id/dev1"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="32dp" />
android:layout_marginTop="48dp"
android:layout_marginStart="16dp"
android:textSize="16sp" />

<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dev3"
app:layout_constraintTop_toBottomOf="@+id/dev2"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="48dp"
android:layout_marginStart="16dp"
android:textSize="16sp" />

<Button
android:text="Refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button1"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.526"
app:layout_constraintBottom_toBottomOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit ea5fe34

Please sign in to comment.