mirror of
https://github.com/yuliskov/LeanKeyboard.git
synced 2026-05-19 13:56:07 -04:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48e12a21d1 | ||
|
|
6a8b9c63e5 | ||
|
|
95ab858296 | ||
|
|
37243e4d11 | ||
|
|
0c7052be55 |
@@ -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 69
|
versionCode 74
|
||||||
versionName "4.3.19"
|
versionName "4.3.24"
|
||||||
|
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,9 @@
|
|||||||
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
|
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<service android:label="@string/ime_service_name" android:name="com.google.leanback.ime.LeanbackImeService" android:permission="android.permission.BIND_INPUT_METHOD">
|
<service android:label="@string/ime_service_name"
|
||||||
|
android:name="com.google.leanback.ime.LeanbackImeService"
|
||||||
|
android:permission="android.permission.BIND_INPUT_METHOD">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.view.InputMethod"/>
|
<action android:name="android.view.InputMethod"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import android.graphics.Rect;
|
|||||||
import android.inputmethodservice.InputMethodService;
|
import android.inputmethodservice.InputMethodService;
|
||||||
import android.inputmethodservice.Keyboard.Key;
|
import android.inputmethodservice.Keyboard.Key;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@@ -30,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;
|
||||||
@@ -51,6 +53,8 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
|
|||||||
private LeanbackKeyboardController.TouchEventListener mTouchEventListener;
|
private LeanbackKeyboardController.TouchEventListener mTouchEventListener;
|
||||||
private long prevTime;
|
private long prevTime;
|
||||||
private boolean mShowInput;
|
private boolean mShowInput;
|
||||||
|
private int mLastEditorIdPhysicalKeyboardWasUsed;
|
||||||
|
private boolean mHideKeyboardWhenPhysicalKeyboardUsed = true;
|
||||||
|
|
||||||
public LeanbackKeyboardController(final InputMethodService context, final LeanbackKeyboardController.InputListener listener) {
|
public LeanbackKeyboardController(final InputMethodService context, final LeanbackKeyboardController.InputListener listener) {
|
||||||
this(context, listener, new TouchNavSpaceTracker(), new LeanbackKeyboardContainer(context));
|
this(context, listener, new TouchNavSpaceTracker(), new LeanbackKeyboardContainer(context));
|
||||||
@@ -157,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));
|
||||||
@@ -434,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;
|
||||||
@@ -604,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;
|
||||||
@@ -647,7 +653,12 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
|
|||||||
* @param event {@link KeyEvent KeyEvent}
|
* @param event {@link KeyEvent KeyEvent}
|
||||||
* @return is event handled
|
* @return is event handled
|
||||||
*/
|
*/
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {
|
||||||
|
//greater than zero means it is a physical keyboard.
|
||||||
|
//we also want to hide the view if it's a glyph (for example, not physical volume-up key)
|
||||||
|
//if (event.getDeviceId() > 0 && event.isPrintingKey()) onPhysicalKeyboardKeyPressed();
|
||||||
|
if (event.isPrintingKey()) onPhysicalKeyboardKeyPressed();
|
||||||
|
|
||||||
mDownFocus.set(mContainer.getCurrFocus());
|
mDownFocus.set(mContainer.getCurrFocus());
|
||||||
if (mSpaceTracker != null && mSpaceTracker.onKeyDown(keyCode, event)) {
|
if (mSpaceTracker != null && mSpaceTracker.onKeyDown(keyCode, event)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -663,6 +674,24 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onPhysicalKeyboardKeyPressed() {
|
||||||
|
EditorInfo editorInfo = mContext.getCurrentInputEditorInfo();
|
||||||
|
mLastEditorIdPhysicalKeyboardWasUsed = editorInfo == null ? 0 : editorInfo.fieldId;
|
||||||
|
if (mHideKeyboardWhenPhysicalKeyboardUsed) {
|
||||||
|
mContext.hideWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
// For all other keys, if we want to do transformations on
|
||||||
|
// text being entered with a hard keyboard, we need to process
|
||||||
|
// it and do the appropriate action.
|
||||||
|
// using physical keyboard is more annoying with candidate view in
|
||||||
|
// the way
|
||||||
|
// so we disable it.
|
||||||
|
|
||||||
|
// stopping any soft-keyboard prediction
|
||||||
|
//abortCorrectionAndResetPredictionState(false);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean onKeyUp(int keyCode, KeyEvent keyEvent) {
|
public boolean onKeyUp(int keyCode, KeyEvent keyEvent) {
|
||||||
if (mSpaceTracker != null && mSpaceTracker.onKeyUp(keyCode, keyEvent)) {
|
if (mSpaceTracker != null && mSpaceTracker.onKeyUp(keyCode, keyEvent)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -718,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
|
||||||
|
|||||||
@@ -11,10 +11,10 @@
|
|||||||
<string name="title_movement_sensitivity">Rörelsekänslighet</string>
|
<string name="title_movement_sensitivity">Rörelsekänslighet</string>
|
||||||
<string name="btn_on">På</string>
|
<string name="btn_on">På</string>
|
||||||
<string name="btn_off">Av</string>
|
<string name="btn_off">Av</string>
|
||||||
<string name="keyboardview_keycode_space">Space</string>
|
<string name="keyboardview_keycode_space">Blanksteg</string>
|
||||||
<string name="keyboardview_keycode_delete">Delete</string>
|
<string name="keyboardview_keycode_delete">Ta bort</string>
|
||||||
<string name="keyboardview_keycode_mode_change">Funktionsändring</string>
|
<string name="keyboardview_keycode_mode_change">Funktionsändring</string>
|
||||||
<string name="keyboardview_keycode_shift">Shift</string>
|
<string name="keyboardview_keycode_shift">Skift</string>
|
||||||
<string name="keyboardview_keycode_caps">Caps Lock</string>
|
<string name="keyboardview_keycode_caps">Caps Lock</string>
|
||||||
<string name="keyboardview_keycode_left">Vänster</string>
|
<string name="keyboardview_keycode_left">Vänster</string>
|
||||||
<string name="keyboardview_keycode_right">Höger</string>
|
<string name="keyboardview_keycode_right">Höger</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user