diff --git a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/keyboard/android/leanback/ime/LeanbackKeyboardController.java b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/keyboard/android/leanback/ime/LeanbackKeyboardController.java index e8ae3fa..bc09d5d 100644 --- a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/keyboard/android/leanback/ime/LeanbackKeyboardController.java +++ b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/keyboard/android/leanback/ime/LeanbackKeyboardController.java @@ -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; diff --git a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/keyboard/leanback/ime/LeanbackImeService.java b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/keyboard/leanback/ime/LeanbackImeService.java index 68b1034..7c79e9b 100644 --- a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/keyboard/leanback/ime/LeanbackImeService.java +++ b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/keyboard/leanback/ime/LeanbackImeService.java @@ -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); }