From 6a8b9c63e5242f78afa22afc9f1b2afa013bc226 Mon Sep 17 00:00:00 2001 From: Yuriy Liskov Date: Tue, 7 Aug 2018 20:39:07 +0300 Subject: [PATCH] ESC and Go fixes (see github > issues) --- leankeykeyboard/build.gradle | 4 ++-- .../leanback/ime/LeanbackKeyboardContainer.java | 4 ++-- .../leanback/ime/LeanbackKeyboardController.java | 12 ++++++++---- .../com/google/leanback/ime/LeanbackImeService.java | 5 +++-- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/leankeykeyboard/build.gradle b/leankeykeyboard/build.gradle index 88b5b8f..c160a47 100644 --- a/leankeykeyboard/build.gradle +++ b/leankeykeyboard/build.gradle @@ -8,8 +8,8 @@ android { applicationId "org.liskovsoft.leankeykeyboard.pro" minSdkVersion project.properties.minSdkVersion targetSdkVersion project.properties.targetSdkVersion - versionCode 72 - versionName "4.3.22" + versionCode 73 + versionName "4.3.23" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" diff --git a/leankeykeyboard/src/main/java/com/google/android/leanback/ime/LeanbackKeyboardContainer.java b/leankeykeyboard/src/main/java/com/google/android/leanback/ime/LeanbackKeyboardContainer.java index 2f2dade..050b6ab 100644 --- a/leankeykeyboard/src/main/java/com/google/android/leanback/ime/LeanbackKeyboardContainer.java +++ b/leankeykeyboard/src/main/java/com/google/android/leanback/ime/LeanbackKeyboardContainer.java @@ -320,10 +320,10 @@ public class LeanbackKeyboardContainer { * Init currently displayed keyboard
* Note: all keyboard settings applied here
* Note: this method is called constantly on new field - * @param resources resources (not used) + * @param res resources (not used) * @param info current ime attributes */ - private void setImeOptions(Resources resources, EditorInfo info) { + private void setImeOptions(Resources res, EditorInfo info) { // do not erase last keyboard if (mInitialMainKeyboard == null) { mInitialMainKeyboard = mAbcKeyboard; diff --git a/leankeykeyboard/src/main/java/com/google/android/leanback/ime/LeanbackKeyboardController.java b/leankeykeyboard/src/main/java/com/google/android/leanback/ime/LeanbackKeyboardController.java index 931ee3b..ba93dc4 100644 --- a/leankeykeyboard/src/main/java/com/google/android/leanback/ime/LeanbackKeyboardController.java +++ b/leankeykeyboard/src/main/java/com/google/android/leanback/ime/LeanbackKeyboardController.java @@ -31,6 +31,7 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi private static final int KEY_CHANGE_HISTORY_SIZE = 10; private static final long KEY_CHANGE_REVERT_TIME_MS = 100L; private static final String TAG = "LbKbController"; + public static final String TAG_GO = "Go"; private boolean clickConsumed; private long lastClickTime; private LeanbackKeyboardContainer mContainer; @@ -160,8 +161,9 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi case KeyFocus.TYPE_VOICE: mContainer.onVoiceClick(); return; - case KeyFocus.TYPE_ACTION: + case KeyFocus.TYPE_ACTION: // NOTE: user presses Go, Send, Search etc mInputListener.onEntry(InputListener.ENTRY_TYPE_ACTION, 0, null); + mContext.hideWindow(); // SmartYouTubeTV fix: force hide keyboard return; case KeyFocus.TYPE_SUGGESTION: mInputListener.onEntry(InputListener.ENTRY_TYPE_SUGGESTION, 0, mContainer.getSuggestionText(focus.index)); @@ -437,7 +439,9 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi private boolean handleKeyUpEvent(int keyCode, long currTime) { keyCode = getSimplifiedKey(keyCode); boolean handled; - if (keyCode == KeyEvent.KEYCODE_BACK) { + // NOTE: hide keyboard on ESC key + // https://github.com/yuliskov/SmartYouTubeTV/issues/142 + if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE) { handled = false; } else if (mContainer.isVoiceVisible()) { handled = true; @@ -607,7 +611,7 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi Button button = mContainer.getGoButton(); button.setOnTouchListener(this); button.setOnHoverListener(this); - button.setTag("Go"); + button.setTag(TAG_GO); return view; } else { return null; @@ -744,7 +748,7 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi @Override public boolean onTouch(View view, MotionEvent event) { Object tag = view.getTag(); - if (tag != null && "Go".equals(tag)) { + if (TAG_GO.equals(tag)) { fakeKeyIndex(0, KeyFocus.TYPE_ACTION); } else { switch (event.getAction()) { diff --git a/leankeykeyboard/src/main/java/com/google/leanback/ime/LeanbackImeService.java b/leankeykeyboard/src/main/java/com/google/leanback/ime/LeanbackImeService.java index c32c545..dd17e54 100644 --- a/leankeykeyboard/src/main/java/com/google/leanback/ime/LeanbackImeService.java +++ b/leankeykeyboard/src/main/java/com/google/leanback/ime/LeanbackImeService.java @@ -1,6 +1,7 @@ package com.google.leanback.ime; import android.annotation.SuppressLint; +import android.app.Service; import android.content.Intent; import android.inputmethodservice.InputMethodService; import android.os.Handler; @@ -161,7 +162,7 @@ public class LeanbackImeService extends InputMethodService { connection.commitText(text, 1); mEnterSpaceBeforeCommitting = true; - case InputListener.ENTRY_TYPE_ACTION: + case InputListener.ENTRY_TYPE_ACTION: // NOTE: user presses Go, Send, Search etc sendDefaultEditorAction(false); updateSuggestions = false; break; @@ -298,7 +299,7 @@ public class LeanbackImeService extends InputMethodService { } } - return 1; + return Service.START_STICKY; } @Override