diff --git a/app/src/main/java/helium314/keyboard/accessibility/AccessibilityUtils.kt b/app/src/main/java/helium314/keyboard/accessibility/AccessibilityUtils.kt index 85acaf336..b5d7adb15 100644 --- a/app/src/main/java/helium314/keyboard/accessibility/AccessibilityUtils.kt +++ b/app/src/main/java/helium314/keyboard/accessibility/AccessibilityUtils.kt @@ -7,6 +7,8 @@ package helium314.keyboard.accessibility import android.content.Context +import android.media.AudioDeviceInfo +import android.media.AudioDeviceInfo.* import android.media.AudioManager import android.os.Build import android.os.SystemClock @@ -72,7 +74,19 @@ class AccessibilityUtils private constructor() { if (speakPassword) return false } // Always speak if the user is listening through headphones. - return if (mAudioManager.isWiredHeadsetOn || mAudioManager.isBluetoothA2dpOn) { + val listeningThroughHeadphones = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { + @Suppress("deprecation") // no replacement available + mAudioManager.isWiredHeadsetOn || mAudioManager.isBluetoothA2dpOn + } else { + // try the same as the deprecated thing above, for what we can assume to be headphones + mAudioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS).any { + when (it.type) { + TYPE_WIRED_HEADSET, TYPE_WIRED_HEADPHONES, TYPE_BLUETOOTH_SCO, TYPE_BLUETOOTH_A2DP, TYPE_USB_HEADSET, TYPE_HEARING_AID, TYPE_BLE_HEADSET -> true + else -> false + } + } + } + return if (listeningThroughHeadphones) { false } else InputTypeUtils.isPasswordInputType(editorInfo.inputType) // Don't speak if the IME is connected to a password field. diff --git a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/KeyboardParser.kt b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/KeyboardParser.kt index 99aefc4fe..1eb892212 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/KeyboardParser.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/KeyboardParser.kt @@ -795,7 +795,6 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co // currently always holo is applied in readAttributes private fun layoutInfos(params: KeyboardParams): LayoutInfos { val layout = params.mId.mSubtype.keyboardLayoutSetName - val language = params.mId.locale.language // only for alphabet, but some exceptions for shift layouts val enableProximityCharsCorrection = params.mId.isAlphabetKeyboard && when (layout) { "bengali_akkhor", "georgian", "hindi", "lao", "nepali_romanized", "nepali_traditional", "sinhala", "thai" -> diff --git a/app/src/main/java/helium314/keyboard/latin/utils/SubtypeSettings.kt b/app/src/main/java/helium314/keyboard/latin/utils/SubtypeSettings.kt index 2b6c7b786..7ed43ac0d 100644 --- a/app/src/main/java/helium314/keyboard/latin/utils/SubtypeSettings.kt +++ b/app/src/main/java/helium314/keyboard/latin/utils/SubtypeSettings.kt @@ -195,6 +195,7 @@ private fun getDefaultEnabledSubtypes(): List { /** string for for identifying a subtype, does not contain all necessary information to actually create it */ private fun InputMethodSubtype.prefString(): String { if (DebugFlags.DEBUG_ENABLED && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && locale().toLanguageTag() == "und") { + @Suppress("deprecation") // it's debug logging, better get all information Log.e(TAG, "unknown language, should not happen ${locale}, $languageTag, $extraValue, ${hashCode()}, $nameResId") } return locale().toLanguageTag() + LOCALE_LAYOUT_SEPARATOR + SubtypeLocaleUtils.getKeyboardLayoutSetName(this)