Compare commits

..

2 Commits

Author SHA1 Message Date
Yuriy Liskov
37243e4d11 hide soft kbd on physical key 2018-08-03 19:00:34 +03:00
Yuriy Liskov
0c7052be55 Swedish translate fix 2018-07-19 00:02:24 +03:00
4 changed files with 34 additions and 7 deletions

View File

@@ -8,8 +8,8 @@ android {
applicationId "org.liskovsoft.leankeykeyboard.pro"
minSdkVersion project.properties.minSdkVersion
targetSdkVersion project.properties.targetSdkVersion
versionCode 69
versionName "4.3.19"
versionCode 71
versionName "4.3.21"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

View File

@@ -14,7 +14,9 @@
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
</intent-filter>
</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>
<action android:name="android.view.InputMethod"/>
</intent-filter>

View File

@@ -5,6 +5,7 @@ import android.graphics.Rect;
import android.inputmethodservice.InputMethodService;
import android.inputmethodservice.Keyboard.Key;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.text.InputType;
import android.util.Log;
import android.view.KeyEvent;
@@ -51,6 +52,8 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
private LeanbackKeyboardController.TouchEventListener mTouchEventListener;
private long prevTime;
private boolean mShowInput;
private int mLastEditorIdPhysicalKeyboardWasUsed;
private boolean mHideKeyboardWhenPhysicalKeyboardUsed = true;
public LeanbackKeyboardController(final InputMethodService context, final LeanbackKeyboardController.InputListener listener) {
this(context, listener, new TouchNavSpaceTracker(), new LeanbackKeyboardContainer(context));
@@ -647,7 +650,11 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
* @param event {@link KeyEvent KeyEvent}
* @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();
mDownFocus.set(mContainer.getCurrFocus());
if (mSpaceTracker != null && mSpaceTracker.onKeyDown(keyCode, event)) {
return true;
@@ -663,6 +670,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) {
if (mSpaceTracker != null && mSpaceTracker.onKeyUp(keyCode, keyEvent)) {
return true;

View File

@@ -11,10 +11,10 @@
<string name="title_movement_sensitivity">Rörelsekänslighet</string>
<string name="btn_on"></string>
<string name="btn_off">Av</string>
<string name="keyboardview_keycode_space">Space</string>
<string name="keyboardview_keycode_delete">Delete</string>
<string name="keyboardview_keycode_space">Blanksteg</string>
<string name="keyboardview_keycode_delete">Ta bort</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_left">Vänster</string>
<string name="keyboardview_keycode_right">Höger</string>