Skip to content

Commit

Permalink
braille-systems#291 log all accessibility events to debug serial
Browse files Browse the repository at this point in the history
  • Loading branch information
zuevval committed Jan 26, 2021
1 parent 00a82c9 commit 4fad46c
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package com.github.braillesystems.learnbraille.ui.screens

import android.content.pm.ActivityInfo
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import android.view.accessibility.AccessibilityEvent
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.NavController
import androidx.navigation.findNavController
Expand All @@ -10,6 +13,17 @@ import com.github.braillesystems.learnbraille.R
import com.github.braillesystems.learnbraille.ui.brailletrainer.BrailleTrainer
import timber.log.Timber

class MyAccessibilityDelegate : View.AccessibilityDelegate() {
override fun onRequestSendAccessibilityEvent(
host: ViewGroup?,
child: View?,
event: AccessibilityEvent?
): Boolean {
Timber.i("Event: %s", event.toString())
return super.onRequestSendAccessibilityEvent(host, child, event)
}
}

class MainActivity : AppCompatActivity() {

private lateinit var navController: NavController
Expand All @@ -20,6 +34,9 @@ class MainActivity : AppCompatActivity() {
Timber.i("onCreate")
setContentView(R.layout.activity_main)

val contentView = findViewById<View>(android.R.id.content)
contentView.accessibilityDelegate = MyAccessibilityDelegate()

navController = findNavController(R.id.navHostFragment)
NavigationUI.setupActionBarWithNavController(this, navController)

Expand Down

0 comments on commit 4fad46c

Please sign in to comment.