mirror of
https://github.com/yuliskov/LeanKeyboard.git
synced 2026-05-19 05:47:07 -04:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48e12a21d1 | ||
|
|
6a8b9c63e5 |
@@ -8,8 +8,8 @@ android {
|
|||||||
applicationId "org.liskovsoft.leankeykeyboard.pro"
|
applicationId "org.liskovsoft.leankeykeyboard.pro"
|
||||||
minSdkVersion project.properties.minSdkVersion
|
minSdkVersion project.properties.minSdkVersion
|
||||||
targetSdkVersion project.properties.targetSdkVersion
|
targetSdkVersion project.properties.targetSdkVersion
|
||||||
versionCode 72
|
versionCode 74
|
||||||
versionName "4.3.22"
|
versionName "4.3.24"
|
||||||
|
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
|
|||||||
@@ -320,10 +320,10 @@ public class LeanbackKeyboardContainer {
|
|||||||
* Init currently displayed keyboard<br/>
|
* Init currently displayed keyboard<br/>
|
||||||
* Note: all keyboard settings applied here<br/>
|
* Note: all keyboard settings applied here<br/>
|
||||||
* Note: this method is called constantly on new field
|
* Note: this method is called constantly on new field
|
||||||
* @param resources resources (not used)
|
* @param res resources (not used)
|
||||||
* @param info current ime attributes
|
* @param info current ime attributes
|
||||||
*/
|
*/
|
||||||
private void setImeOptions(Resources resources, EditorInfo info) {
|
private void setImeOptions(Resources res, EditorInfo info) {
|
||||||
// do not erase last keyboard
|
// do not erase last keyboard
|
||||||
if (mInitialMainKeyboard == null) {
|
if (mInitialMainKeyboard == null) {
|
||||||
mInitialMainKeyboard = mAbcKeyboard;
|
mInitialMainKeyboard = mAbcKeyboard;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
|
|||||||
private static final int KEY_CHANGE_HISTORY_SIZE = 10;
|
private static final int KEY_CHANGE_HISTORY_SIZE = 10;
|
||||||
private static final long KEY_CHANGE_REVERT_TIME_MS = 100L;
|
private static final long KEY_CHANGE_REVERT_TIME_MS = 100L;
|
||||||
private static final String TAG = "LbKbController";
|
private static final String TAG = "LbKbController";
|
||||||
|
public static final String TAG_GO = "Go";
|
||||||
private boolean clickConsumed;
|
private boolean clickConsumed;
|
||||||
private long lastClickTime;
|
private long lastClickTime;
|
||||||
private LeanbackKeyboardContainer mContainer;
|
private LeanbackKeyboardContainer mContainer;
|
||||||
@@ -160,8 +161,9 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
|
|||||||
case KeyFocus.TYPE_VOICE:
|
case KeyFocus.TYPE_VOICE:
|
||||||
mContainer.onVoiceClick();
|
mContainer.onVoiceClick();
|
||||||
return;
|
return;
|
||||||
case KeyFocus.TYPE_ACTION:
|
case KeyFocus.TYPE_ACTION: // NOTE: user presses Go, Send, Search etc
|
||||||
mInputListener.onEntry(InputListener.ENTRY_TYPE_ACTION, 0, null);
|
mInputListener.onEntry(InputListener.ENTRY_TYPE_ACTION, 0, null);
|
||||||
|
mContext.hideWindow(); // SmartYouTubeTV fix: force hide keyboard
|
||||||
return;
|
return;
|
||||||
case KeyFocus.TYPE_SUGGESTION:
|
case KeyFocus.TYPE_SUGGESTION:
|
||||||
mInputListener.onEntry(InputListener.ENTRY_TYPE_SUGGESTION, 0, mContainer.getSuggestionText(focus.index));
|
mInputListener.onEntry(InputListener.ENTRY_TYPE_SUGGESTION, 0, mContainer.getSuggestionText(focus.index));
|
||||||
@@ -437,7 +439,8 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
|
|||||||
private boolean handleKeyUpEvent(int keyCode, long currTime) {
|
private boolean handleKeyUpEvent(int keyCode, long currTime) {
|
||||||
keyCode = getSimplifiedKey(keyCode);
|
keyCode = getSimplifiedKey(keyCode);
|
||||||
boolean handled;
|
boolean handled;
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE) {
|
||||||
handled = false;
|
handled = false;
|
||||||
} else if (mContainer.isVoiceVisible()) {
|
} else if (mContainer.isVoiceVisible()) {
|
||||||
handled = true;
|
handled = true;
|
||||||
@@ -607,7 +610,7 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
|
|||||||
Button button = mContainer.getGoButton();
|
Button button = mContainer.getGoButton();
|
||||||
button.setOnTouchListener(this);
|
button.setOnTouchListener(this);
|
||||||
button.setOnHoverListener(this);
|
button.setOnHoverListener(this);
|
||||||
button.setTag("Go");
|
button.setTag(TAG_GO);
|
||||||
return view;
|
return view;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@@ -744,7 +747,7 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
|
|||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View view, MotionEvent event) {
|
public boolean onTouch(View view, MotionEvent event) {
|
||||||
Object tag = view.getTag();
|
Object tag = view.getTag();
|
||||||
if (tag != null && "Go".equals(tag)) {
|
if (TAG_GO.equals(tag)) {
|
||||||
fakeKeyIndex(0, KeyFocus.TYPE_ACTION);
|
fakeKeyIndex(0, KeyFocus.TYPE_ACTION);
|
||||||
} else {
|
} else {
|
||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.google.leanback.ime;
|
package com.google.leanback.ime;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.Service;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.inputmethodservice.InputMethodService;
|
import android.inputmethodservice.InputMethodService;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@@ -161,7 +162,7 @@ public class LeanbackImeService extends InputMethodService {
|
|||||||
|
|
||||||
connection.commitText(text, 1);
|
connection.commitText(text, 1);
|
||||||
mEnterSpaceBeforeCommitting = true;
|
mEnterSpaceBeforeCommitting = true;
|
||||||
case InputListener.ENTRY_TYPE_ACTION:
|
case InputListener.ENTRY_TYPE_ACTION: // NOTE: user presses Go, Send, Search etc
|
||||||
sendDefaultEditorAction(false);
|
sendDefaultEditorAction(false);
|
||||||
updateSuggestions = false;
|
updateSuggestions = false;
|
||||||
break;
|
break;
|
||||||
@@ -271,14 +272,39 @@ public class LeanbackImeService extends InputMethodService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
|
// NOTE: hide keyboard on ESC key
|
||||||
|
// https://github.com/yuliskov/SmartYouTubeTV/issues/142
|
||||||
|
event = mapEscToBack(event);
|
||||||
|
keyCode = mapEscToBack(keyCode);
|
||||||
|
|
||||||
return isInputViewShown() && mKeyboardController.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event);
|
return isInputViewShown() && mKeyboardController.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||||
|
// NOTE: 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);
|
return isInputViewShown() && mKeyboardController.onKeyUp(keyCode, event) || super.onKeyUp(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private KeyEvent mapEscToBack(KeyEvent event) {
|
||||||
|
if (event.getKeyCode() == KeyEvent.KEYCODE_ESCAPE) {
|
||||||
|
// pay attention, you must pass the same action
|
||||||
|
event = new KeyEvent(event.getAction(), KeyEvent.KEYCODE_BACK);
|
||||||
|
}
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int mapEscToBack(int keyCode) {
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_ESCAPE) {
|
||||||
|
keyCode = KeyEvent.KEYCODE_BACK;
|
||||||
|
}
|
||||||
|
return keyCode;
|
||||||
|
}
|
||||||
|
|
||||||
// FireTV fix
|
// FireTV fix
|
||||||
//@Override
|
//@Override
|
||||||
//public boolean onShowInputRequested(int flags, boolean configChange) {
|
//public boolean onShowInputRequested(int flags, boolean configChange) {
|
||||||
@@ -298,7 +324,7 @@ public class LeanbackImeService extends InputMethodService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return Service.START_STICKY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user