mirror of
https://github.com/yuliskov/LeanKeyboard.git
synced 2026-06-11 09:04:17 -04:00
add kbd picker
This commit is contained in:
@@ -815,8 +815,8 @@ public class LeanbackKeyboardContainer {
|
||||
setTouchState(LeanbackKeyboardContainer.TOUCH_STATE_NO_TOUCH);
|
||||
return true;
|
||||
} else if (keyCode == LeanbackKeyboardView.ASCII_SPACE) {
|
||||
onLangKeyPress();
|
||||
setTouchState(LeanbackKeyboardContainer.TOUCH_STATE_NO_TOUCH);
|
||||
LeanbackUtils.showKeyboardPicker(mContext);
|
||||
//setTouchState(LeanbackKeyboardContainer.TOUCH_STATE_NO_TOUCH);
|
||||
return true;
|
||||
} else if (keyCode == LeanbackKeyboardView.KEYCODE_LANG_TOGGLE) {
|
||||
Helpers.startActivity(mContext, KbSettingsActivity.class);
|
||||
@@ -1072,11 +1072,7 @@ public class LeanbackKeyboardContainer {
|
||||
* Switch to next keyboard (looped).
|
||||
* {@link KeyboardManager KeyboardManager} is the source behind all keyboard implementations
|
||||
*/
|
||||
public void onLangKeyPress() {
|
||||
switchToNextKeyboard();
|
||||
}
|
||||
|
||||
private void switchToNextKeyboard() {
|
||||
public void switchToNextKeyboard() {
|
||||
LeanbackKeyboardView keyboardView = mMainKeyboardView;
|
||||
Keyboard keyboard = mKeyboardManager.getNextKeyboard();
|
||||
|
||||
@@ -1140,8 +1136,7 @@ public class LeanbackKeyboardContainer {
|
||||
}
|
||||
|
||||
public void onLangKeyClick() {
|
||||
onLangKeyPress();
|
||||
// setTouchState(LeanbackKeyboardContainer.TOUCH_STATE_NO_TOUCH);
|
||||
switchToNextKeyboard();
|
||||
}
|
||||
|
||||
public void onClipboardClick(InputListener listener) {
|
||||
|
||||
@@ -111,16 +111,16 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
|
||||
private boolean applyLETVFixesUp(int keyCode) {
|
||||
switch (keyCode) {
|
||||
case KeyEvent.KEYCODE_MENU:
|
||||
this.mContainer.onLangKeyPress();
|
||||
mContainer.switchToNextKeyboard();
|
||||
break;
|
||||
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
|
||||
this.fakeKeyIndex(0, 2);
|
||||
fakeKeyIndex(0, 2);
|
||||
break;
|
||||
case KeyEvent.KEYCODE_MEDIA_REWIND:
|
||||
this.fakeKeyCode(-5);
|
||||
fakeKeyCode(-5);
|
||||
break;
|
||||
case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
|
||||
this.fakeKeyCode(32);
|
||||
fakeKeyCode(32);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.liskovsoft.leankeyboard.keyboard.android.leanback.ime;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.inputmethodservice.InputMethodService;
|
||||
import android.os.Handler;
|
||||
import android.text.InputType;
|
||||
import android.util.DisplayMetrics;
|
||||
@@ -12,6 +13,7 @@ import android.view.WindowManager;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputConnection;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import com.liskovsoft.leankeyboard.keyboard.leanback.ime.LeanbackImeService;
|
||||
|
||||
@@ -135,4 +137,16 @@ public class LeanbackUtils {
|
||||
|
||||
return metrics;
|
||||
}
|
||||
|
||||
public static void showKeyboardPicker(InputMethodService context) {
|
||||
if (context != null) {
|
||||
InputMethodManager imeManager = (InputMethodManager) context.getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (imeManager != null) {
|
||||
imeManager.showInputMethodPicker();
|
||||
|
||||
Log.d(TAG, "Keyboard may stuck on screen. Fixing it...");
|
||||
context.stopSelf();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.liskovsoft.leankeyboard.keyboard.leanback.ime;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.inputmethodservice.InputMethodService;
|
||||
import android.os.Build.VERSION;
|
||||
@@ -14,7 +13,6 @@ import android.view.InputDevice;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.CompletionInfo;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputConnection;
|
||||
@@ -297,6 +295,8 @@ public class LeanbackImeService extends InputMethodService {
|
||||
@Override
|
||||
public int onStartCommand(final Intent intent, final int flags, final int startId) {
|
||||
if (intent != null) {
|
||||
Log.d(TAG, "onStartCommand: " + intent.toUri(0));
|
||||
|
||||
if (intent.getBooleanExtra(COMMAND_RESTART, false)) {
|
||||
Log.d(TAG, "onStartCommand: trying to restart service");
|
||||
|
||||
|
||||
35
leankeykeyboard/src/main/res/values-hdpi/dimens.xml
Normal file
35
leankeykeyboard/src/main/res/values-hdpi/dimens.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Values for devices with 160 dpi e.g. Red Box TV -->
|
||||
<resources>
|
||||
<!-- Main values -->
|
||||
<dimen name="key_height">37.0dip</dimen>
|
||||
<dimen name="key_width">37.0dip</dimen>
|
||||
<!--
|
||||
NOTE: Don't change space size unless you've set this constants:
|
||||
LeanbackKeyboardView.ASCII_PERIOD, LeanbackKeyboardView.ASCII_PERIOD_LEN
|
||||
Old space width: 230.0dip
|
||||
-->
|
||||
<dimen name="space_key_width">245.0dip</dimen>
|
||||
<dimen name="keyboard_horizontal_gap">16.0dip</dimen>
|
||||
<dimen name="keyboard_vertical_gap">11.0dip</dimen>
|
||||
<dimen name="selector_size">32.0dip</dimen>
|
||||
<dimen name="key_font_size">24.0sp</dimen>
|
||||
<dimen name="function_key_mode_change_font_size">21.0sp</dimen>
|
||||
<dimen name="resize_move_distance">16.0dip</dimen>
|
||||
<!-- Enter key values -->
|
||||
<dimen name="enter_key_height">42.0dip</dimen>
|
||||
<dimen name="enter_key_font_size">24.0sp</dimen>
|
||||
<dimen name="enter_key_padding_horizontal">21.0dip</dimen>
|
||||
<!-- Keyboard other -->
|
||||
<dimen name="keyboard_top_spacing">8.0dip</dimen>
|
||||
<dimen name="keyboard_bottom_spacing">37.0dip</dimen>
|
||||
<!-- Voice input -->
|
||||
<dimen name="action_button_size">84.0dip</dimen>
|
||||
<dimen name="recognizer_size">125.0dip</dimen>
|
||||
<!-- Suggestions -->
|
||||
<dimen name="candidate_height">37.0dip</dimen>
|
||||
<dimen name="candidate_scroll_view_horz_spacing">73.0dip</dimen>
|
||||
<dimen name="candidate_font_size">24.0sp</dimen>
|
||||
<dimen name="candidate_padding_horizontal">21.0dip</dimen>
|
||||
<dimen name="candidate_margin_horizontal">6.0dip</dimen>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user