FireTV fix (possible)

This commit is contained in:
Yuriy Liskov
2018-03-25 16:46:58 +03:00
parent 4262862a1b
commit e9cc575c31
3 changed files with 41 additions and 14 deletions

View File

@@ -49,6 +49,7 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
private PointF mTempPoint;
private LeanbackKeyboardController.TouchEventListener mTouchEventListener;
private long prevTime;
private boolean mShowInput;
public LeanbackKeyboardController(final InputMethodService context, final LeanbackKeyboardController.InputListener listener) {
this(context, listener, new TouchNavSpaceTracker(), new LeanbackKeyboardContainer(context));
@@ -681,23 +682,37 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
}
}
public void onStartInput(EditorInfo var1) {
if (this.mContainer != null) {
this.mContainer.onStartInput(var1);
this.initInputView();
public void onStartInput(EditorInfo info) {
if (mContainer != null) {
mContainer.onStartInput(info);
initInputView();
}
// prevent accidental kbd pop-up on FireTV devices
// more info: https://forum.xda-developers.com/fire-tv/general/guide-change-screen-keyboard-to-leankey-t3527675/page2
int maskAction = info.imeOptions & EditorInfo.IME_MASK_ACTION;
mShowInput = maskAction != 0;
}
public boolean showInputView() {
return mShowInput;
}
private void onHideIme() {
mContext.requestHideSelf(InputMethodService.BACK_DISPOSITION_DEFAULT);
}
public void onStartInputView() {
this.mKeyDownReceived = false;
if (this.mContainer != null) {
this.mContainer.onStartInputView();
mKeyDownReceived = false;
if (mContainer != null) {
mContainer.onStartInputView();
}
this.mDoubleClickDetector.reset();
mDoubleClickDetector.reset();
}
@Override
public boolean onTouch(View view, MotionEvent event) {
Object tag = view.getTag();
if (tag != null && "Go".equals(tag)) {

View File

@@ -224,15 +224,19 @@ public class LeanbackImeService extends InputMethodService {
return false;
}
/**
* At this point, decision whether to show kbd taking place
* @return whether to show kbd
*/
@SuppressLint("MissingSuperCall")
@Override
public boolean onEvaluateInputViewShown() {
return true;
return mKeyboardController.showInputView();
}
@Override
public void onFinishInputView(boolean var1) {
super.onFinishInputView(var1);
public void onFinishInputView(boolean finishingInput) {
super.onFinishInputView(finishingInput);
this.sendBroadcast(new Intent(IME_CLOSE));
this.mSuggestionsFactory.clearSuggestions();
}
@@ -246,7 +250,7 @@ public class LeanbackImeService extends InputMethodService {
}
public void onHideIme() {
this.requestHideSelf(0);
requestHideSelf(InputMethodService.BACK_DISPOSITION_DEFAULT);
}
@Override
@@ -298,6 +302,14 @@ public class LeanbackImeService extends InputMethodService {
@Override
public void onStartInputView(EditorInfo info, boolean restarting) {
super.onStartInputView(info, restarting);
// FireTV: fix accidental kbd pop-ups
// more info: https://forum.xda-developers.com/fire-tv/general/guide-change-screen-keyboard-to-leankey-t3527675/page2
//if (!mKeyboardController.showInputView()) {
// onHideIme();
// return;
//}
mKeyboardController.onStartInputView();
sendBroadcast(new Intent(IME_OPEN));
if (mKeyboardController.areSuggestionsEnabled()) {