kbd always show fix

This commit is contained in:
Yuriy Liskov
2020-03-21 23:39:45 +02:00
parent 28ba0fdadb
commit ac764617f2
2 changed files with 23 additions and 17 deletions

View File

@@ -19,6 +19,7 @@ import android.widget.RelativeLayout;
import androidx.annotation.NonNull;
import com.liskovsoft.leankeyboard.keyboard.android.leanback.ime.LeanbackKeyboardContainer.KeyFocus;
import com.liskovsoft.leankeyboard.keyboard.android.pano.util.TouchNavSpaceTracker;
import com.liskovsoft.leankeyboard.utils.LeanKeySettings;
import com.liskovsoft.leankeykeyboard.R;
import java.util.ArrayList;
@@ -56,29 +57,29 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
private int mLastEditorIdPhysicalKeyboardWasUsed;
private boolean mHideKeyboardWhenPhysicalKeyboardUsed = true;
public LeanbackKeyboardController(final InputMethodService context, final LeanbackKeyboardController.InputListener listener) {
public LeanbackKeyboardController(final InputMethodService context,
final InputListener listener) {
this(context, listener, new TouchNavSpaceTracker(), new LeanbackKeyboardContainer(context));
}
public LeanbackKeyboardController(final InputMethodService context, final LeanbackKeyboardController.InputListener listener, final TouchNavSpaceTracker tracker,
final LeanbackKeyboardContainer container) {
mDoubleClickDetector = new LeanbackKeyboardController.DoubleClickDetector();
mOnLayoutChangeListener = new OnLayoutChangeListener() {
@Override
public void onLayoutChange(View view, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
left = right - left;
top = bottom - top;
if (left > 0 && top > 0) {
if (LeanbackKeyboardController.this.mSpaceTracker != null) {
LeanbackKeyboardController.this.mSpaceTracker.setPixelSize((float) left, (float) top);
}
if (left != oldRight - oldLeft || top != oldBottom - oldTop) {
LeanbackKeyboardController.this.initInputView();
}
public LeanbackKeyboardController(final InputMethodService context,
final InputListener listener,
final TouchNavSpaceTracker tracker,
final LeanbackKeyboardContainer container) {
mDoubleClickDetector = new DoubleClickDetector();
mOnLayoutChangeListener = (view, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
left = right - left;
top = bottom - top;
if (left > 0 && top > 0) {
if (mSpaceTracker != null) {
mSpaceTracker.setPixelSize((float) left, (float) top);
}
if (left != oldRight - oldLeft || top != oldBottom - oldTop) {
initInputView();
}
}
};
mTouchEventListener = new TouchEventListener();
mDownFocus = new KeyFocus();
@@ -843,6 +844,10 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
}
public void setHideWhenPhysicalKeyboardUsed(boolean hide) {
mHideKeyboardWhenPhysicalKeyboardUsed = hide;
}
private class DoubleClickDetector {
final long DOUBLE_CLICK_TIMEOUT_MS;
boolean mFirstClickShiftLocked;

View File

@@ -255,6 +255,7 @@ public class LeanbackImeService extends InputMethodService {
@Override
public void onInitializeInterface() {
mKeyboardController = new LeanbackKeyboardController(this, mInputListener);
mKeyboardController.setHideWhenPhysicalKeyboardUsed(!mForceShowKbd);
mEnterSpaceBeforeCommitting = false;
mSuggestionsFactory = new LeanbackSuggestionsFactory(this, MAX_SUGGESTIONS);
}