Compare commits

..

1 Commits

Author SHA1 Message Date
Yuriy Liskov
4a821a4413 hide kbd on esc key; voice recognition fix 2025-02-10 21:50:41 +02:00
5 changed files with 22 additions and 14 deletions

View File

@@ -22,8 +22,8 @@ android {
applicationId "org.liskovsoft.leankeykeyboard.pro"
minSdkVersion project.properties.minSdkVersion
targetSdkVersion project.properties.targetSdkVersion
versionCode 196
versionName "6.1.26"
versionCode 199
versionName "6.1.29"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

View File

@@ -25,7 +25,7 @@ public class MiscFragment extends BaseSettingsFragment {
addCheckedAction(R.string.increase_kbd_size, R.string.increase_kbd_size_desc, mPrefs::getEnlargeKeyboard, mPrefs::setEnlargeKeyboard);
addCheckedAction(R.string.enable_suggestions, R.string.enable_suggestions_desc, mPrefs::getSuggestionsEnabled, mPrefs::setSuggestionsEnabled);
addCheckedAction(R.string.show_launcher_icon, R.string.show_launcher_icon_desc, this::getLauncherIconShown, this::setLauncherIconShown);
addCheckedAction(R.string.enable_cyclic_navigation, R.string.enable_cyclic_navigation_desc, mPrefs::getCyclicNavigationEnabled, mPrefs::setCyclicNavigationEnabled);
addCheckedAction(R.string.enable_cyclic_navigation, R.string.enable_cyclic_navigation_desc, mPrefs::isCyclicNavigationEnabled, mPrefs::setCyclicNavigationEnabled);
}
@NonNull

View File

@@ -307,18 +307,26 @@ public class LeanbackImeService extends KeyMapperImeService {
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
//// DOESN'T WORK!!!
//// Hide keyboard on ESC key: https://github.com/yuliskov/SmartYouTubeTV/issues/142
//event = mapEscToBack(event);
//keyCode = mapEscToBack(keyCode);
// Hide keyboard on ESC key: https://github.com/yuliskov/SmartYouTubeTV/issues/142
event = mapEscToBack(event);
keyCode = mapEscToBack(keyCode);
if (keyCode == KeyEvent.KEYCODE_ESCAPE) {
hideIme();
return true;
}
return isInputViewShown() && mKeyboardController.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event);
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
// Hide keyboard on ESC key: https://github.com/yuliskov/SmartYouTubeTV/issues/142
event = mapEscToBack(event);
keyCode = mapEscToBack(keyCode);
//// DOESN'T WORK!!!
//// Hide keyboard on ESC key: https://github.com/yuliskov/SmartYouTubeTV/issues/142
//event = mapEscToBack(event);
//keyCode = mapEscToBack(keyCode);
return isInputViewShown() && mKeyboardController.onKeyUp(keyCode, event) || super.onKeyUp(keyCode, event);
}

View File

@@ -14,6 +14,7 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.inputmethodservice.Keyboard;
import android.inputmethodservice.Keyboard.Key;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.speech.RecognitionListener;
import android.speech.RecognizerIntent;
@@ -532,7 +533,8 @@ public class LeanbackKeyboardContainer {
* @param context context
*/
private void startRecognition(Context context) {
if (PermissionHelpers.hasStoragePermissions(context) &&
// MANAGE_EXTERNAL_STORAGE does not work on Android 14
if ((PermissionHelpers.hasStoragePermissions(context) || VERSION.SDK_INT >= 34) &&
PermissionHelpers.hasMicPermissions(context)) {
if (SpeechRecognizer.isRecognitionAvailable(context)) {
mRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
@@ -680,7 +682,7 @@ public class LeanbackKeyboardContainer {
public void updateCyclicFocus(int dir, KeyFocus oldFocus, KeyFocus newFocus) {
if (oldFocus.equals(newFocus) || LeanbackUtils.isSubmitButton(newFocus)) {
if (LeanKeyPreferences.instance(mContext).getCyclicNavigationEnabled()) {
if (LeanKeyPreferences.instance(mContext).isCyclicNavigationEnabled()) {
if (dir == DIRECTION_RIGHT || dir == DIRECTION_LEFT) {
Rect actionRect = new Rect();
offsetRect(actionRect, mActionButtonView);
@@ -707,9 +709,7 @@ public class LeanbackKeyboardContainer {
configureFocus(newFocus, mRect, keyIdx, key, 0);
}
}
}
if (dir == DIRECTION_UP) {
} else if (dir == DIRECTION_UP) {
// Hide the keyboard when moving focus out of the keyboard
mContext.hideIme();
}

View File

@@ -109,7 +109,7 @@ public final class LeanKeyPreferences {
.apply();
}
public boolean getCyclicNavigationEnabled() {
public boolean isCyclicNavigationEnabled() {
return mPrefs.getBoolean(CYCLIC_NAVIGATION_ENABLED, false);
}