From 4fad46ca3b35eaf10a564b9b2e24c6432981744e Mon Sep 17 00:00:00 2001 From: zuevval Date: Tue, 26 Jan 2021 21:11:58 +0300 Subject: [PATCH] #291 log all accessibility events to debug serial --- .../learnbraille/ui/screens/MainActivity.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/MainActivity.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/MainActivity.kt index 7ba77c61..c4665a08 100644 --- a/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/MainActivity.kt +++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/MainActivity.kt @@ -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 @@ -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 @@ -20,6 +34,9 @@ class MainActivity : AppCompatActivity() { Timber.i("onCreate") setContentView(R.layout.activity_main) + val contentView = findViewById(android.R.id.content) + contentView.accessibilityDelegate = MyAccessibilityDelegate() + navController = findNavController(R.id.navHostFragment) NavigationUI.setupActionBarWithNavController(this, navController)