From f149ad805ab3bde821487cc03fcc0bd5cc76f774 Mon Sep 17 00:00:00 2001 From: Eoin Mcloughlin Date: Sun, 17 Apr 2022 11:59:28 +0100 Subject: [PATCH] Fix bug where bluetooth keyboards don't work in sounder. Fixes #6 --- app/build.gradle | 4 ++-- app/src/main/java/es/eoinrul/ecwt/SounderActivity.kt | 12 +++++++++++- fastlane/metadata/android/en-US/changelogs/42.txt | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 fastlane/metadata/android/en-US/changelogs/42.txt diff --git a/app/build.gradle b/app/build.gradle index 49f34bb..65d7065 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "es.eoinrul.ecwt" minSdkVersion 23 targetSdkVersion 29 - versionCode 41 - versionName "4.1" + versionCode 42 + versionName "4.2" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/es/eoinrul/ecwt/SounderActivity.kt b/app/src/main/java/es/eoinrul/ecwt/SounderActivity.kt index 4d8a358..fd37812 100644 --- a/app/src/main/java/es/eoinrul/ecwt/SounderActivity.kt +++ b/app/src/main/java/es/eoinrul/ecwt/SounderActivity.kt @@ -33,6 +33,15 @@ class SounderActivity : AppCompatActivity() { onTextEntered("E"); // Display and sound something - this is arbitrary } + // This will be called for connected USB/Bluetooth keyboards: + override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean { + val sequence = KeycodeToSoundSequence(keyCode) + mTextViewTest?.text = SequenceToString(sequence) + mSoundPlayer?.enqueue(sequence) + mKeyboardInput?.setText("") // Should be empty due to physical keyboard + return true; + } + override fun onResume() { super.onResume() initSoundPlayer() @@ -69,7 +78,8 @@ class SounderActivity : AppCompatActivity() { private var mSoundPlayer : DitDahSoundStream? = null; - // Utility to watch our EditText and handle any user input: + // Utility to watch our EditText and handle any user input + // This only seems to get triggered if we're using the software keyboard private val mInputHandler = object : TextWatcher { override fun afterTextChanged(s: Editable?) { if(s == null) { diff --git a/fastlane/metadata/android/en-US/changelogs/42.txt b/fastlane/metadata/android/en-US/changelogs/42.txt new file mode 100644 index 0000000..3ef08b0 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/42.txt @@ -0,0 +1 @@ +Fixed a bug where Bluetooth/USB keyboards wouldn't work in sounder mode.