Show current input values in OnScreenEditActivity

This was made primarily for debugging on-screen controls, but it might be useful to users too.
This commit is contained in:
lynxnb 2023-04-03 03:00:02 +02:00 committed by Billy Laws
parent 69fb15ffc9
commit 78252fbcbd
2 changed files with 21 additions and 1 deletions

View File

@ -76,7 +76,7 @@ class OnScreenEditActivity : AppCompatActivity() {
.show()
}
@SuppressLint("ClickableViewAccessibility")
@SuppressLint("ClickableViewAccessibility", "SetTextI18n")
override fun onCreate(savedInstanceState : Bundle?) {
super.onCreate(savedInstanceState)
window.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
@ -137,6 +137,15 @@ class OnScreenEditActivity : AppCompatActivity() {
binding.dragHandle.setOnTouchListener(dragPanelListener)
binding.closeButton.setOnClickListener { togglePanelVisibility() }
binding.onScreenControllerView.setOnButtonStateChangedListener { buttonId, state ->
binding.lastInputEvent.text = "Timestamp: ${System.currentTimeMillis()}\nButton: ${buttonId.short}\n$state"
}
binding.onScreenControllerView.setOnStickStateChangedListener { stickId, position ->
val x = "%9.6f".format(position.x)
val y = "%9.6f".format(position.y)
binding.lastInputEvent.text = "Timestamp: ${System.currentTimeMillis()}\nStick: ${stickId.button.short}\nX: $x\nY: $y"
}
binding.onScreenControllerView.setEditMode(true)
}
@ -205,6 +214,7 @@ class OnScreenEditActivity : AppCompatActivity() {
private fun togglePanelVisibility() {
isPanelVisible = !isPanelVisible
binding.lastInputEvent.text = null
binding.content.isGone = !isPanelVisible
binding.dragHandle.isGone = !isPanelVisible

View File

@ -17,6 +17,16 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@+id/last_input_event"
style="?attr/textAppearanceTitleMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAlignment="center"
android:textColor="#E6E1E5"
tools:text="Timestamp: 16000000000\nButton: A\nReleased" />
<LinearLayout
android:id="@+id/control_panel"
android:layout_width="wrap_content"