Preview input value

This commit is contained in:
Johannes Frohnmeyer 2023-01-26 15:03:11 +01:00
parent b742a050c2
commit a09d307f7e
Signed by: Johannes
GPG Key ID: E76429612C2929F4
4 changed files with 27 additions and 6 deletions

1
.gitignore vendored
View File

@ -8,3 +8,4 @@
.externalNativeBuild
.cxx
local.properties
release

View File

@ -2,6 +2,7 @@ package io.gitlab.jfronny.hc05ac
import android.os.Bundle
import android.view.MotionEvent
import android.widget.TextView
import androidx.appcompat.widget.LinearLayoutCompat
import io.gitlab.jfronny.hc05ac.util.Action
import io.gitlab.jfronny.hc05ac.util.BaseActivity
@ -14,10 +15,14 @@ import io.gitlab.jfronny.hc05ac.util.jAction
*/
abstract class InputActivity : BaseActivity() {
private var root: LinearLayoutCompat? = null
private var leftView: TextView? = null
private var rightView: TextView? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
root = findViewById(R.id.root)
leftView = findViewById(R.id.left)
rightView = findViewById(R.id.right)
}
override fun onTouchEvent(event: MotionEvent?): Boolean {
@ -37,7 +42,7 @@ abstract class InputActivity : BaseActivity() {
Action.UP -> 0
Action.OTHER -> return false
}
send(left, right)
update()
return false
}
@ -47,9 +52,15 @@ abstract class InputActivity : BaseActivity() {
Action.UP -> 0
Action.OTHER -> return false
}
send(left, right)
update()
return false
}
private fun update() {
leftView!!.text = left.toString()
rightView!!.text = right.toString()
send(left, right)
}
protected abstract fun send(left: Byte, right: Byte)
}

View File

@ -10,14 +10,22 @@
app:divider="@drawable/divider"
app:showDividers="middle">
<View
android:layout_width="wrap_content"
<TextView
android:text="@string/zero"
android:id="@+id/left"
android:gravity="center"
android:textAlignment="gravity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:background="?attr/colorPrimary" />
<View
android:layout_width="wrap_content"
<TextView
android:text="@string/zero"
android:id="@+id/right"
android:gravity="center"
android:textAlignment="gravity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:background="?attr/colorSecondary" />

View File

@ -1,3 +1,4 @@
<resources>
<string name="app_name">HC05AC</string>
<string name="zero">0</string>
</resources>