mirror of
https://github.com/yuliskov/LeanKeyboard.git
synced 2026-05-03 05:12:36 -04:00
refactoring + license
This commit is contained in:
@@ -14,6 +14,7 @@ import android.inputmethodservice.Keyboard;
|
||||
import android.inputmethodservice.Keyboard.Key;
|
||||
import android.os.Bundle;
|
||||
import android.speech.RecognitionListener;
|
||||
import android.speech.RecognizerIntent;
|
||||
import android.speech.SpeechRecognizer;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -101,7 +102,7 @@ public class LeanbackKeyboardContainer {
|
||||
private LeanbackKeyboardContainer.KeyFocus mTempKeyInfo = new LeanbackKeyboardContainer.KeyFocus();
|
||||
private PointF mTempPoint = new PointF();
|
||||
private boolean mTouchDown = false;
|
||||
private int mTouchState = 0;
|
||||
private int mTouchState = TOUCH_STATE_NO_TOUCH;
|
||||
private final int mVoiceAnimDur;
|
||||
private final LeanbackKeyboardContainer.VoiceIntroAnimator mVoiceAnimator;
|
||||
private RecognizerView mVoiceButtonView;
|
||||
@@ -225,8 +226,8 @@ public class LeanbackKeyboardContainer {
|
||||
final float width = (float) (this.mRootView.getWidth() - this.mRootView.getPaddingRight() - this.mRootView.getPaddingLeft());
|
||||
final float height = (float) (this.mRootView.getHeight() - this.mRootView.getPaddingTop() - this.mRootView.getPaddingBottom());
|
||||
final float size = this.mContext.getResources().getDimension(R.dimen.selector_size);
|
||||
result.x = posXCm / 12.0F * (width - size) + (float) this.mRootView.getPaddingLeft();
|
||||
result.y = posYCm / 5.0F * (height - size) + (float) this.mRootView.getPaddingTop();
|
||||
result.x = posXCm / PHYSICAL_WIDTH_CM * (width - size) + (float) this.mRootView.getPaddingLeft();
|
||||
result.y = posYCm / PHYSICAL_HEIGHT_CM * (height - size) + (float) this.mRootView.getPaddingTop();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -236,8 +237,8 @@ public class LeanbackKeyboardContainer {
|
||||
float posXCm = (float) (this.mRootView.getWidth() - this.mRootView.getPaddingRight() - this.mRootView.getPaddingLeft());
|
||||
float posYCm = (float) (this.mRootView.getHeight() - this.mRootView.getPaddingTop() - this.mRootView.getPaddingBottom());
|
||||
float size = this.mContext.getResources().getDimension(R.dimen.selector_size);
|
||||
result.x = (x - width - (float) this.mRootView.getPaddingLeft()) * 12.0F / (posXCm - size);
|
||||
result.y = (y - height - (float) this.mRootView.getPaddingTop()) * 5.0F / (posYCm - size);
|
||||
result.x = (x - width - (float) this.mRootView.getPaddingLeft()) * PHYSICAL_WIDTH_CM / (posXCm - size);
|
||||
result.y = (y - height - (float) this.mRootView.getPaddingTop()) * PHYSICAL_HEIGHT_CM / (posYCm - size);
|
||||
}
|
||||
|
||||
private PointF getTouchSnapPosition() {
|
||||
@@ -359,11 +360,11 @@ public class LeanbackKeyboardContainer {
|
||||
|
||||
this.mCapCharacters = false;
|
||||
if (var2.privateImeOptions != null) {
|
||||
if (var2.privateImeOptions.contains("EscapeNorth=1")) {
|
||||
if (var2.privateImeOptions.contains(IME_PRIVATE_OPTIONS_ESCAPE_NORTH)) {
|
||||
this.mEscapeNorthEnabled = false;
|
||||
}
|
||||
|
||||
if (var2.privateImeOptions.contains("VoiceDismiss=1")) {
|
||||
if (var2.privateImeOptions.contains(IME_PRIVATE_OPTIONS_VOICE_DISMISS)) {
|
||||
this.mVoiceKeyDismissesEnabled = false;
|
||||
}
|
||||
}
|
||||
@@ -442,37 +443,41 @@ public class LeanbackKeyboardContainer {
|
||||
}
|
||||
}
|
||||
|
||||
private void setShiftState(int var1) {
|
||||
this.mMainKeyboardView.setShiftState(var1);
|
||||
private void setShiftState(int state) {
|
||||
this.mMainKeyboardView.setShiftState(state);
|
||||
}
|
||||
|
||||
private void setTouchStateInternal(int var1) {
|
||||
this.mTouchState = var1;
|
||||
private void setTouchStateInternal(int state) {
|
||||
this.mTouchState = state;
|
||||
}
|
||||
|
||||
private void startRecognition(Context var1) {
|
||||
this.mRecognizerIntent = new Intent("android.speech.action.RECOGNIZE_SPEECH");
|
||||
this.mRecognizerIntent.putExtra("android.speech.extra.LANGUAGE_MODEL", "free_form");
|
||||
this.mRecognizerIntent.putExtra("android.speech.extra.PARTIAL_RESULTS", true);
|
||||
private void startRecognition(Context context) {
|
||||
this.mRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
|
||||
this.mRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "free_form");
|
||||
this.mRecognizerIntent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
|
||||
this.mSpeechRecognizer.setRecognitionListener(new RecognitionListener() {
|
||||
float peakRmsLevel = 0.0F;
|
||||
int rmsCounter = 0;
|
||||
|
||||
@Override
|
||||
public void onBeginningOfSpeech() {
|
||||
LeanbackKeyboardContainer.this.mVoiceButtonView.showRecording();
|
||||
}
|
||||
|
||||
public void onBufferReceived(byte[] var1) {
|
||||
@Override
|
||||
public void onBufferReceived(byte[] bytes) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEndOfSpeech() {
|
||||
LeanbackKeyboardContainer.this.mVoiceButtonView.showRecognizing();
|
||||
LeanbackKeyboardContainer.this.mVoiceOn = false;
|
||||
}
|
||||
|
||||
public void onError(int var1) {
|
||||
@Override
|
||||
public void onError(int i) {
|
||||
LeanbackKeyboardContainer.this.cancelVoiceRecording();
|
||||
switch (var1) {
|
||||
switch (i) {
|
||||
case 4:
|
||||
Log.d("LbKbContainer", "recognizer error server error");
|
||||
return;
|
||||
@@ -486,24 +491,28 @@ public class LeanbackKeyboardContainer {
|
||||
Log.d("LbKbContainer", "recognizer error no match");
|
||||
return;
|
||||
default:
|
||||
Log.d("LbKbContainer", "recognizer other error " + var1);
|
||||
Log.d("LbKbContainer", "recognizer other error " + i);
|
||||
}
|
||||
}
|
||||
|
||||
public void onEvent(int var1, Bundle var2) {
|
||||
@Override
|
||||
public void onEvent(int i, Bundle bundle) {
|
||||
}
|
||||
|
||||
public void onPartialResults(Bundle var1) {
|
||||
@Override
|
||||
public void onPartialResults(Bundle bundle) {
|
||||
synchronized (this) {
|
||||
}
|
||||
}
|
||||
|
||||
public void onReadyForSpeech(Bundle var1) {
|
||||
@Override
|
||||
public void onReadyForSpeech(Bundle bundle) {
|
||||
LeanbackKeyboardContainer.this.mVoiceButtonView.showListening();
|
||||
}
|
||||
|
||||
public void onResults(Bundle var1) {
|
||||
ArrayList var2 = var1.getStringArrayList("results_recognition");
|
||||
@Override
|
||||
public void onResults(Bundle bundle) {
|
||||
ArrayList var2 = bundle.getStringArrayList("results_recognition");
|
||||
if (var2 != null && LeanbackKeyboardContainer.this.mVoiceListener != null) {
|
||||
LeanbackKeyboardContainer.this.mVoiceListener.onVoiceResult((String) var2.get(0));
|
||||
}
|
||||
@@ -511,7 +520,8 @@ public class LeanbackKeyboardContainer {
|
||||
LeanbackKeyboardContainer.this.cancelVoiceRecording();
|
||||
}
|
||||
|
||||
public void onRmsChanged(float param1) {
|
||||
@Override
|
||||
public void onRmsChanged(float v) {
|
||||
// $FF: Couldn't be decompiled
|
||||
throw new IllegalStateException("method not implemented");
|
||||
}
|
||||
@@ -519,14 +529,14 @@ public class LeanbackKeyboardContainer {
|
||||
this.mSpeechRecognizer.startListening(this.mRecognizerIntent);
|
||||
}
|
||||
|
||||
public void alignSelector(float var1, float var2, boolean var3) {
|
||||
var1 -= (float) (this.mSelector.getWidth() / 2);
|
||||
var2 -= (float) (this.mSelector.getHeight() / 2);
|
||||
if (!var3) {
|
||||
this.mSelector.setX(var1);
|
||||
this.mSelector.setY(var2);
|
||||
public void alignSelector(final float x, final float y, final boolean playAnimation) {
|
||||
final float translatedX = x - (float) (this.mSelector.getWidth() / 2);
|
||||
final float translatedY = y - (float) (this.mSelector.getHeight() / 2);
|
||||
if (!playAnimation) {
|
||||
this.mSelector.setX(translatedX);
|
||||
this.mSelector.setY(translatedY);
|
||||
} else {
|
||||
this.mSelector.animate().x(var1).y(var2).setInterpolator(sMovementInterpolator).setDuration(150L).start();
|
||||
this.mSelector.animate().x(translatedX).y(translatedY).setInterpolator(sMovementInterpolator).setDuration(MOVEMENT_ANIMATION_DURATION).start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -621,8 +631,8 @@ public class LeanbackKeyboardContainer {
|
||||
return this.mActionButtonView;
|
||||
}
|
||||
|
||||
public Key getKey(int var1, int var2) {
|
||||
return var1 == 0 ? this.mMainKeyboardView.getKey(var2) : null;
|
||||
public Key getKey(int type, int index) {
|
||||
return type == KeyFocus.TYPE_MAIN ? this.mMainKeyboardView.getKey(index) : null;
|
||||
}
|
||||
|
||||
public boolean getNextFocusInDirection(int direction, LeanbackKeyboardContainer.KeyFocus startFocus, LeanbackKeyboardContainer.KeyFocus nextFocus) {
|
||||
@@ -846,15 +856,16 @@ public class LeanbackKeyboardContainer {
|
||||
this.setShiftState(var1);
|
||||
}
|
||||
|
||||
public void onShiftDoubleClick(boolean var1) {
|
||||
byte var2;
|
||||
if (var1) {
|
||||
var2 = 0;
|
||||
// TODO: state constants
|
||||
public void onShiftDoubleClick(boolean wasCapsLockOn) {
|
||||
byte state;
|
||||
if (wasCapsLockOn) {
|
||||
state = 0;
|
||||
} else {
|
||||
var2 = 2;
|
||||
state = 2;
|
||||
}
|
||||
|
||||
this.setShiftState(var2);
|
||||
this.setShiftState(state);
|
||||
}
|
||||
|
||||
public void onSpaceEntry() {
|
||||
@@ -869,8 +880,8 @@ public class LeanbackKeyboardContainer {
|
||||
|
||||
}
|
||||
|
||||
public void onStartInput(EditorInfo var1) {
|
||||
this.setImeOptions(this.mContext.getResources(), var1);
|
||||
public void onStartInput(EditorInfo info) {
|
||||
this.setImeOptions(this.mContext.getResources(), info);
|
||||
this.mVoiceOn = false;
|
||||
}
|
||||
|
||||
@@ -994,33 +1005,33 @@ public class LeanbackKeyboardContainer {
|
||||
}
|
||||
}
|
||||
|
||||
public void setTouchState(int var1) {
|
||||
switch (var1) {
|
||||
case 0:
|
||||
if (this.mTouchState == 2 || this.mTouchState == 3) {
|
||||
this.mSelectorAnimator.reverse();
|
||||
public void setTouchState(final int state) {
|
||||
switch (state) {
|
||||
case TOUCH_STATE_NO_TOUCH:
|
||||
if (mTouchState == TOUCH_STATE_TOUCH_MOVE || mTouchState == TOUCH_STATE_CLICK) {
|
||||
mSelectorAnimator.reverse();
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (this.mTouchState == 3) {
|
||||
this.mSelectorAnimator.reverse();
|
||||
} else if (this.mTouchState == 2) {
|
||||
this.mSelectorAnimator.reverse();
|
||||
case TOUCH_STATE_TOUCH_SNAP:
|
||||
if (mTouchState == TOUCH_STATE_CLICK) {
|
||||
mSelectorAnimator.reverse();
|
||||
} else if (mTouchState == TOUCH_STATE_TOUCH_MOVE) {
|
||||
mSelectorAnimator.reverse();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (this.mTouchState == 0 || this.mTouchState == 1) {
|
||||
this.mSelectorAnimator.start();
|
||||
case TOUCH_STATE_TOUCH_MOVE:
|
||||
if (mTouchState == TOUCH_STATE_NO_TOUCH || mTouchState == TOUCH_STATE_TOUCH_SNAP) {
|
||||
mSelectorAnimator.start();
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (this.mTouchState == 0 || this.mTouchState == 1) {
|
||||
this.mSelectorAnimator.start();
|
||||
case TOUCH_STATE_CLICK:
|
||||
if (mTouchState == TOUCH_STATE_NO_TOUCH || mTouchState == TOUCH_STATE_TOUCH_SNAP) {
|
||||
mSelectorAnimator.start();
|
||||
}
|
||||
}
|
||||
|
||||
this.setTouchStateInternal(var1);
|
||||
this.setKbFocus(this.mCurrKeyInfo, true, true);
|
||||
setTouchStateInternal(state);
|
||||
setKbFocus(mCurrKeyInfo, true, true);
|
||||
}
|
||||
|
||||
public void setVoiceListener(LeanbackKeyboardContainer.VoiceListener var1) {
|
||||
@@ -1093,39 +1104,41 @@ public class LeanbackKeyboardContainer {
|
||||
final Rect rect = new Rect();
|
||||
int type = -1;
|
||||
|
||||
public boolean equals(Object var1) {
|
||||
if (this != var1) {
|
||||
if (var1 == null || this.getClass() != var1.getClass()) {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this != obj) {
|
||||
if (obj == null || this.getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LeanbackKeyboardContainer.KeyFocus var2 = (LeanbackKeyboardContainer.KeyFocus) var1;
|
||||
if (this.code != var2.code) {
|
||||
LeanbackKeyboardContainer.KeyFocus focus = (LeanbackKeyboardContainer.KeyFocus) obj;
|
||||
if (this.code != focus.code) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.index != var2.index) {
|
||||
if (this.index != focus.index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.type != var2.type) {
|
||||
if (this.type != focus.type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: label
|
||||
label31:
|
||||
{
|
||||
if (this.label != null) {
|
||||
if (this.label.equals(var2.label)) {
|
||||
if (this.label.equals(focus.label)) {
|
||||
break label31;
|
||||
}
|
||||
} else if (var2.label == null) {
|
||||
} else if (focus.label == null) {
|
||||
break label31;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.rect.equals(var2.rect)) {
|
||||
if (!this.rect.equals(focus.rect)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1134,33 +1147,33 @@ public class LeanbackKeyboardContainer {
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int var2 = this.rect.hashCode();
|
||||
int var3 = this.index;
|
||||
int var4 = this.type;
|
||||
int var5 = this.code;
|
||||
int var1;
|
||||
int hash = this.rect.hashCode();
|
||||
int index = this.index;
|
||||
int type = this.type;
|
||||
int code = this.code;
|
||||
int salt;
|
||||
if (this.label != null) {
|
||||
var1 = this.label.hashCode();
|
||||
salt = this.label.hashCode();
|
||||
} else {
|
||||
var1 = 0;
|
||||
salt = 0;
|
||||
}
|
||||
|
||||
return (((var2 * 31 + var3) * 31 + var4) * 31 + var5) * 31 + var1;
|
||||
return (((hash * 31 + index) * 31 + type) * 31 + code) * 31 + salt;
|
||||
}
|
||||
|
||||
public void set(LeanbackKeyboardContainer.KeyFocus var1) {
|
||||
this.index = var1.index;
|
||||
this.type = var1.type;
|
||||
this.code = var1.code;
|
||||
this.label = var1.label;
|
||||
this.rect.set(var1.rect);
|
||||
public void set(LeanbackKeyboardContainer.KeyFocus focus) {
|
||||
this.index = focus.index;
|
||||
this.type = focus.type;
|
||||
this.code = focus.code;
|
||||
this.label = focus.label;
|
||||
this.rect.set(focus.rect);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder var1 = new StringBuilder();
|
||||
var1.append("[type: ").append(this.type).append(", index: ").append(this.index).append(", code: ").append(this.code).append(", label: " +
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("[type: ").append(this.type).append(", index: ").append(this.index).append(", code: ").append(this.code).append(", label: " +
|
||||
"").append(this.label).append(", rect: ").append(this.rect).append("]");
|
||||
return var1.toString();
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1179,7 +1192,7 @@ public class LeanbackKeyboardContainer {
|
||||
public ScaleAnimation(FrameLayout var2) {
|
||||
this.mView = var2;
|
||||
this.mParams = var2.getLayoutParams();
|
||||
this.setDuration(150L);
|
||||
this.setDuration(MOVEMENT_ANIMATION_DURATION);
|
||||
this.setInterpolator(LeanbackKeyboardContainer.sMovementInterpolator);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -258,8 +258,8 @@ public class LeanbackKeyboardView extends FrameLayout {
|
||||
return this.mKeyboard;
|
||||
}
|
||||
|
||||
public int getNearestIndex(float x, float y) {
|
||||
int var7;
|
||||
public int getNearestIndex(final float x, final float y) {
|
||||
int result;
|
||||
if (this.mKeys != null && this.mKeys.length != 0) {
|
||||
float var3 = (float) this.getPaddingLeft();
|
||||
float var4 = (float) this.getPaddingTop();
|
||||
@@ -269,11 +269,11 @@ public class LeanbackKeyboardView extends FrameLayout {
|
||||
int var10 = this.getColCount();
|
||||
int var8 = (int) ((y - var4) / var5 * (float) var9);
|
||||
if (var8 < 0) {
|
||||
var7 = 0;
|
||||
result = 0;
|
||||
} else {
|
||||
var7 = var8;
|
||||
result = var8;
|
||||
if (var8 >= var9) {
|
||||
var7 = var9 - 1;
|
||||
result = var9 - 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,33 +287,33 @@ public class LeanbackKeyboardView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
|
||||
var8 += this.mColCount * var7;
|
||||
var7 = var8;
|
||||
if (var8 > 46) {
|
||||
var7 = var8;
|
||||
var8 += this.mColCount * result;
|
||||
result = var8;
|
||||
if (var8 > ASCII_PERIOD) {
|
||||
result = var8;
|
||||
if (var8 < 53) {
|
||||
var7 = 46;
|
||||
result = ASCII_PERIOD;
|
||||
}
|
||||
}
|
||||
|
||||
var8 = var7;
|
||||
if (var7 >= 53) {
|
||||
var8 = var7 - 6;
|
||||
var8 = result;
|
||||
if (result >= 53) {
|
||||
var8 = result - 6;
|
||||
}
|
||||
|
||||
if (var8 < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var7 = var8;
|
||||
result = var8;
|
||||
if (var8 >= this.mKeys.length) {
|
||||
return this.mKeys.length - 1;
|
||||
}
|
||||
} else {
|
||||
var7 = 0;
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return var7;
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getRowCount() {
|
||||
|
||||
@@ -20,9 +20,9 @@ public class LeanbackSuggestionsFactory {
|
||||
private int mNumSuggestions;
|
||||
private final ArrayList<String> mSuggestions = new ArrayList();
|
||||
|
||||
public LeanbackSuggestionsFactory(InputMethodService var1, int var2) {
|
||||
this.mContext = var1;
|
||||
this.mNumSuggestions = var2;
|
||||
public LeanbackSuggestionsFactory(InputMethodService context, int numSuggestions) {
|
||||
this.mContext = context;
|
||||
this.mNumSuggestions = numSuggestions;
|
||||
}
|
||||
|
||||
public void clearSuggestions() {
|
||||
|
||||
@@ -127,13 +127,13 @@ public class TouchNavSpaceTracker {
|
||||
return var3;
|
||||
}
|
||||
|
||||
private void checkForLongClick(int var1, KeyEvent var2) {
|
||||
private void checkForLongClick(int var1, KeyEvent event) {
|
||||
if (var1 == 23) {
|
||||
Message var3 = this.mHandler.obtainMessage(0);
|
||||
var3.arg1 = var1;
|
||||
var3.obj = var2;
|
||||
Message msg = this.mHandler.obtainMessage(0);
|
||||
msg.arg1 = var1;
|
||||
msg.obj = event;
|
||||
if (!this.mHandler.hasMessages(0)) {
|
||||
this.mHandler.sendMessageDelayed(var3, (long)ViewConfiguration.getLongPressTimeout());
|
||||
this.mHandler.sendMessageDelayed(msg, (long)ViewConfiguration.getLongPressTimeout());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -253,16 +253,16 @@ public class TouchNavSpaceTracker {
|
||||
return new PointF(this.getPixelX(this.mPhysicalPosition.x), this.getPixelY(this.mPhysicalPosition.y));
|
||||
}
|
||||
|
||||
public boolean onGenericMotionEvent(MotionEvent var1) {
|
||||
if (var1 != null && (var1.getSource() & 2097152) == 2097152) {
|
||||
InputDevice var13 = var1.getDevice();
|
||||
public boolean onGenericMotionEvent(MotionEvent event) {
|
||||
if (event != null && (event.getSource() & InputDevice.SOURCE_TOUCH_NAVIGATION) == InputDevice.SOURCE_TOUCH_NAVIGATION) {
|
||||
InputDevice var13 = event.getDevice();
|
||||
if (var13 == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TouchNavMotionTracker var19 = this.getTrackerForDevice(var13);
|
||||
int var10 = var1.getActionMasked();
|
||||
var19.addMovement(var1);
|
||||
int var10 = event.getActionMasked();
|
||||
var19.addMovement(event);
|
||||
boolean var6;
|
||||
if ((var10 & 255) == 6) {
|
||||
var6 = true;
|
||||
@@ -272,19 +272,19 @@ public class TouchNavSpaceTracker {
|
||||
|
||||
int var7;
|
||||
if (var6) {
|
||||
var7 = var1.getActionIndex();
|
||||
var7 = event.getActionIndex();
|
||||
} else {
|
||||
var7 = -1;
|
||||
}
|
||||
|
||||
float var3 = 0.0F;
|
||||
float var2 = 0.0F;
|
||||
int var9 = var1.getPointerCount();
|
||||
int var9 = event.getPointerCount();
|
||||
|
||||
for(int var8 = 0; var8 < var9; ++var8) {
|
||||
if (var7 != var8) {
|
||||
var3 += var1.getX(var8);
|
||||
var2 += var1.getY(var8);
|
||||
var3 += event.getX(var8);
|
||||
var2 += event.getY(var8);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ public class TouchNavSpaceTracker {
|
||||
|
||||
float var4 = var3 / (float)var17;
|
||||
float var5 = var2 / (float)var17;
|
||||
TouchNavSpaceTracker.PhysicalMotionEvent var14 = new TouchNavSpaceTracker.PhysicalMotionEvent(var1.getDeviceId(), var19.getPhysicalX(var4), var19.getPhysicalX(var5), var1.getEventTime());
|
||||
TouchNavSpaceTracker.PhysicalMotionEvent var14 = new TouchNavSpaceTracker.PhysicalMotionEvent(event.getDeviceId(), var19.getPhysicalX(var4), var19.getPhysicalX(var5), event.getEventTime());
|
||||
boolean var18 = false;
|
||||
boolean var12 = false;
|
||||
boolean var11;
|
||||
@@ -312,7 +312,7 @@ public class TouchNavSpaceTracker {
|
||||
|
||||
var19.setNewValues(var4, var5);
|
||||
var19.updatePrevValues();
|
||||
var19.setDownEvent(MotionEvent.obtain(var1));
|
||||
var19.setDownEvent(MotionEvent.obtain(event));
|
||||
if (this.mPixelListener != null) {
|
||||
return false | this.mPixelListener.onDown(var14);
|
||||
}
|
||||
@@ -324,7 +324,7 @@ public class TouchNavSpaceTracker {
|
||||
return false | this.mPixelListener.onUp(var14, this.getPixelX(this.mPhysicalPosition.x), this.getPixelY(this.mPhysicalPosition.y));
|
||||
}
|
||||
|
||||
var16 = new TouchNavSpaceTracker.PhysicalMotionEvent(var1.getDeviceId(), var19.getPhysicalX(var15.getX()), var19.getPhysicalY(var15.getY()), var15.getEventTime());
|
||||
var16 = new TouchNavSpaceTracker.PhysicalMotionEvent(event.getDeviceId(), var19.getPhysicalX(var15.getX()), var19.getPhysicalY(var15.getY()), var15.getEventTime());
|
||||
var6 = var18;
|
||||
if (var19.computeVelocity()) {
|
||||
var6 = var18;
|
||||
@@ -356,7 +356,7 @@ public class TouchNavSpaceTracker {
|
||||
return var6 | var11;
|
||||
case 2:
|
||||
if (var19.getDownEvent() == null) {
|
||||
var19.setDownEvent(MotionEvent.obtain(var1));
|
||||
var19.setDownEvent(MotionEvent.obtain(event));
|
||||
if (this.mLPFEnabled) {
|
||||
this.mLPFCurrX = var4;
|
||||
this.mLPFCurrY = var5;
|
||||
@@ -375,7 +375,7 @@ public class TouchNavSpaceTracker {
|
||||
if (var19.setNewValues(var3, var2)) {
|
||||
var2 = var19.getPhysicalX(var19.getScrollX());
|
||||
var3 = var19.getPhysicalY(var19.getScrollY());
|
||||
var4 = this.calculateSensitivity(var1, var19.getDownEvent());
|
||||
var4 = this.calculateSensitivity(event, var19.getDownEvent());
|
||||
this.mPhysicalPosition.x = this.mPrevPhysPosition.x + this.getScaledValue(var2, var4);
|
||||
this.mPhysicalPosition.y = this.mPrevPhysPosition.y + this.getScaledValue(var3, var4);
|
||||
this.clampPosition();
|
||||
@@ -387,7 +387,7 @@ public class TouchNavSpaceTracker {
|
||||
var11 = var12;
|
||||
if (this.mPixelWidth > 0.0F) {
|
||||
var15 = var19.getDownEvent();
|
||||
var16 = new TouchNavSpaceTracker.PhysicalMotionEvent(var1.getDeviceId(), var19.getPhysicalX(var15.getX()), var19.getPhysicalY(var15.getY()), var15.getEventTime());
|
||||
var16 = new TouchNavSpaceTracker.PhysicalMotionEvent(event.getDeviceId(), var19.getPhysicalX(var15.getX()), var19.getPhysicalY(var15.getY()), var15.getEventTime());
|
||||
var2 = this.getPixelX(this.mPhysicalPosition.x);
|
||||
var3 = this.getPixelY(this.mPhysicalPosition.y);
|
||||
var11 = false | this.mPixelListener.onMove(var16, var14, var2, var3);
|
||||
@@ -416,28 +416,28 @@ public class TouchNavSpaceTracker {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onKeyDown(int var1, KeyEvent var2) {
|
||||
if (var2 != null && var2.getDevice() != null && (var2.getDevice().getSources() & 2097152) == 2097152) {
|
||||
if (var2.getRepeatCount() == 0) {
|
||||
this.checkForLongClick(var1, var2);
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (event != null && event.getDevice() != null && (event.getDevice().getSources() & InputDevice.SOURCE_TOUCH_NAVIGATION) == InputDevice.SOURCE_TOUCH_NAVIGATION) {
|
||||
if (event.getRepeatCount() == 0) {
|
||||
checkForLongClick(keyCode, event);
|
||||
}
|
||||
|
||||
if (this.mKeyEventListener != null) {
|
||||
return this.mKeyEventListener.onKeyDown(var1, var2);
|
||||
if (mKeyEventListener != null) {
|
||||
return mKeyEventListener.onKeyDown(keyCode, event);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onKeyUp(int var1, KeyEvent var2) {
|
||||
if (var2 != null && var2.getDevice() != null && (var2.getDevice().getSources() & 2097152) == 2097152) {
|
||||
if (var1 == 23) {
|
||||
this.mHandler.removeMessages(0);
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
if (event != null && event.getDevice() != null && (event.getDevice().getSources() & InputDevice.SOURCE_TOUCH_NAVIGATION) == InputDevice.SOURCE_TOUCH_NAVIGATION) {
|
||||
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
|
||||
mHandler.removeMessages(0);
|
||||
}
|
||||
|
||||
if (this.mKeyEventListener != null) {
|
||||
return this.mKeyEventListener.onKeyUp(var1, var2);
|
||||
if (mKeyEventListener != null) {
|
||||
return mKeyEventListener.onKeyUp(keyCode, event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,56 +445,56 @@ public class TouchNavSpaceTracker {
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
this.mHandler.removeMessages(0);
|
||||
mHandler.removeMessages(0);
|
||||
}
|
||||
|
||||
public void setKeyEventListener(TouchNavSpaceTracker.KeyEventListener var1) {
|
||||
this.mKeyEventListener = var1;
|
||||
public void setKeyEventListener(TouchNavSpaceTracker.KeyEventListener listener) {
|
||||
mKeyEventListener = listener;
|
||||
}
|
||||
|
||||
public void setLPFEnabled(boolean var1) {
|
||||
this.mLPFEnabled = var1;
|
||||
public void setLPFEnabled(boolean enabled) {
|
||||
mLPFEnabled = enabled;
|
||||
}
|
||||
|
||||
public void setPhysicalDensity(float var1) {
|
||||
this.mPixelsPerMm = var1;
|
||||
if (var1 > 0.0F) {
|
||||
this.updatePhysicalSize();
|
||||
public void setPhysicalDensity(float density) {
|
||||
mPixelsPerMm = density;
|
||||
if (density > 0.0F) {
|
||||
updatePhysicalSize();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setPhysicalPosition(float var1, float var2) {
|
||||
this.mPhysicalPosition.x = var1;
|
||||
this.mPhysicalPosition.y = var2;
|
||||
this.mPrevPhysPosition.x = var1;
|
||||
this.mPrevPhysPosition.y = var2;
|
||||
this.clampPosition();
|
||||
public void setPhysicalPosition(float x, float y) {
|
||||
mPhysicalPosition.x = x;
|
||||
mPhysicalPosition.y = y;
|
||||
mPrevPhysPosition.x = x;
|
||||
mPrevPhysPosition.y = y;
|
||||
clampPosition();
|
||||
}
|
||||
|
||||
public void setPhysicalSize(float var1, float var2) {
|
||||
if (this.mPixelsPerMm <= 0.0F) {
|
||||
this.setPhysicalSizeInternal(var1, var2);
|
||||
public void setPhysicalSize(float widthMm, float heightMm) {
|
||||
if (mPixelsPerMm <= 0.0F) {
|
||||
setPhysicalSizeInternal(widthMm, heightMm);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPixelPosition(float var1, float var2) {
|
||||
this.setPhysicalPosition(this.getPhysicalX(var1), this.getPhysicalY(var2));
|
||||
public void setPixelPosition(float x, float y) {
|
||||
setPhysicalPosition(getPhysicalX(x), getPhysicalY(y));
|
||||
}
|
||||
|
||||
public void setPixelSize(float var1, float var2) {
|
||||
this.mPixelHeight = var2;
|
||||
this.mPixelWidth = var1;
|
||||
this.updatePhysicalSize();
|
||||
public void setPixelSize(float width, float height) {
|
||||
mPixelHeight = height;
|
||||
mPixelWidth = width;
|
||||
updatePhysicalSize();
|
||||
}
|
||||
|
||||
public void setSensitivity(float var1) {
|
||||
this.mSensitivity = var1;
|
||||
this.configureFlicks(this.mUnscaledFlickMinDistance, this.mUnscaledFlickMaxDistance, this.mFlickMaxDuration);
|
||||
public void setSensitivity(float sensitivity) {
|
||||
mSensitivity = sensitivity;
|
||||
configureFlicks(mUnscaledFlickMinDistance, mUnscaledFlickMaxDistance, mFlickMaxDuration);
|
||||
}
|
||||
|
||||
public void setTouchEventListener(TouchNavSpaceTracker.TouchEventListener var1) {
|
||||
this.mPixelListener = var1;
|
||||
public void setTouchEventListener(TouchNavSpaceTracker.TouchEventListener listener) {
|
||||
mPixelListener = listener;
|
||||
}
|
||||
|
||||
public void unblockMovement() {
|
||||
@@ -502,11 +502,11 @@ public class TouchNavSpaceTracker {
|
||||
}
|
||||
|
||||
public interface KeyEventListener {
|
||||
boolean onKeyDown(int var1, KeyEvent var2);
|
||||
boolean onKeyDown(int keyCode, KeyEvent event);
|
||||
|
||||
boolean onKeyLongPress(int var1, KeyEvent var2);
|
||||
boolean onKeyLongPress(int keyCode, KeyEvent event);
|
||||
|
||||
boolean onKeyUp(int var1, KeyEvent var2);
|
||||
boolean onKeyUp(int keyCode, KeyEvent event);
|
||||
}
|
||||
|
||||
public static class PhysicalMotionEvent {
|
||||
@@ -558,15 +558,15 @@ public class TouchNavSpaceTracker {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onKeyDown(int var1, KeyEvent var2) {
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onKeyLongPress(int var1, KeyEvent var2) {
|
||||
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onKeyUp(int var1, KeyEvent var2) {
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.inputmethodservice.InputMethodService;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
import android.view.InputDevice;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
@@ -13,6 +14,8 @@ import android.view.inputmethod.CompletionInfo;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputConnection;
|
||||
import com.google.android.leanback.ime.LeanbackKeyboardController;
|
||||
import com.google.android.leanback.ime.LeanbackKeyboardController.InputListener;
|
||||
import com.google.android.leanback.ime.LeanbackKeyboardView;
|
||||
import com.google.android.leanback.ime.LeanbackSuggestionsFactory;
|
||||
import com.google.android.leanback.ime.LeanbackUtils;
|
||||
|
||||
@@ -38,8 +41,9 @@ public class LeanbackImeService extends InputMethodService {
|
||||
}
|
||||
};
|
||||
private LeanbackKeyboardController.InputListener mInputListener = new LeanbackKeyboardController.InputListener() {
|
||||
public void onEntry(int var1, int var2, CharSequence var3) {
|
||||
LeanbackImeService.this.handleTextEntry(var1, var2, var3);
|
||||
@Override
|
||||
public void onEntry(int type, int keyCode, CharSequence text) {
|
||||
LeanbackImeService.this.handleTextEntry(type, keyCode, text);
|
||||
}
|
||||
};
|
||||
private View mInputView;
|
||||
@@ -56,160 +60,156 @@ public class LeanbackImeService extends InputMethodService {
|
||||
}
|
||||
|
||||
private void clearSuggestionsDelayed() {
|
||||
if (!this.mSuggestionsFactory.shouldSuggestionsAmend()) {
|
||||
this.mHandler.removeMessages(123);
|
||||
this.mShouldClearSuggestions = true;
|
||||
this.mHandler.sendEmptyMessageDelayed(123, 1000L);
|
||||
if (!mSuggestionsFactory.shouldSuggestionsAmend()) {
|
||||
mHandler.removeMessages(MSG_SUGGESTIONS_CLEAR);
|
||||
mShouldClearSuggestions = true;
|
||||
mHandler.sendEmptyMessageDelayed(MSG_SUGGESTIONS_CLEAR, SUGGESTIONS_CLEAR_DELAY);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private int getAmpersandLocation(InputConnection var1) {
|
||||
String var4 = this.getEditorText(var1);
|
||||
int var3 = var4.indexOf(64);
|
||||
int var2 = var3;
|
||||
if (var3 < 0) {
|
||||
var2 = var4.length();
|
||||
private int getAmpersandLocation(InputConnection connection) {
|
||||
String text = getEditorText(connection);
|
||||
int pos = text.indexOf(64);
|
||||
if (pos < 0) { // not found
|
||||
pos = text.length();
|
||||
}
|
||||
|
||||
return var2;
|
||||
return pos;
|
||||
}
|
||||
|
||||
private int getCharLengthAfterCursor(InputConnection var1) {
|
||||
int var2 = 0;
|
||||
CharSequence var3 = var1.getTextAfterCursor(1000, 0);
|
||||
if (var3 != null) {
|
||||
var2 = var3.length();
|
||||
private int getCharLengthAfterCursor(InputConnection connection) {
|
||||
int len = 0;
|
||||
CharSequence after = connection.getTextAfterCursor(1000, 0);
|
||||
if (after != null) {
|
||||
len = after.length();
|
||||
}
|
||||
|
||||
return var2;
|
||||
return len;
|
||||
}
|
||||
|
||||
private int getCharLengthBeforeCursor(InputConnection var1) {
|
||||
int var2 = 0;
|
||||
CharSequence var3 = var1.getTextBeforeCursor(1000, 0);
|
||||
if (var3 != null) {
|
||||
var2 = var3.length();
|
||||
private int getCharLengthBeforeCursor(InputConnection connection) {
|
||||
int len = 0;
|
||||
CharSequence before = connection.getTextBeforeCursor(1000, 0);
|
||||
if (before != null) {
|
||||
len = before.length();
|
||||
}
|
||||
|
||||
return var2;
|
||||
return len;
|
||||
}
|
||||
|
||||
private String getEditorText(InputConnection var1) {
|
||||
StringBuilder var2 = new StringBuilder();
|
||||
CharSequence var3 = var1.getTextBeforeCursor(1000, 0);
|
||||
CharSequence var4 = var1.getTextAfterCursor(1000, 0);
|
||||
if (var3 != null) {
|
||||
var2.append(var3);
|
||||
private String getEditorText(InputConnection connection) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
CharSequence before = connection.getTextBeforeCursor(1000, 0);
|
||||
CharSequence after = connection.getTextAfterCursor(1000, 0);
|
||||
if (before != null) {
|
||||
result.append(before);
|
||||
}
|
||||
|
||||
if (var4 != null) {
|
||||
var2.append(var4);
|
||||
if (after != null) {
|
||||
result.append(after);
|
||||
}
|
||||
|
||||
return var2.toString();
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private void handleTextEntry(int var1, int var2, CharSequence var3) {
|
||||
InputConnection var5 = this.getCurrentInputConnection();
|
||||
boolean var4 = true;
|
||||
if (var5 != null) {
|
||||
boolean var6;
|
||||
switch (var1) {
|
||||
case 0:
|
||||
this.clearSuggestionsDelayed();
|
||||
if (this.mEnterSpaceBeforeCommitting && this.mKeyboardController.enableAutoEnterSpace()) {
|
||||
if (LeanbackUtils.isAlphabet(var2)) {
|
||||
var5.commitText(" ", 1);
|
||||
private void handleTextEntry(final int type, final int keyCode, final CharSequence text) {
|
||||
final InputConnection connection = getCurrentInputConnection();
|
||||
if (connection != null) {
|
||||
boolean updateSuggestions;
|
||||
switch (type) {
|
||||
case InputListener.ENTRY_TYPE_STRING:
|
||||
clearSuggestionsDelayed();
|
||||
if (mEnterSpaceBeforeCommitting && mKeyboardController.enableAutoEnterSpace()) {
|
||||
if (LeanbackUtils.isAlphabet(keyCode)) {
|
||||
connection.commitText(" ", 1);
|
||||
}
|
||||
|
||||
this.mEnterSpaceBeforeCommitting = false;
|
||||
mEnterSpaceBeforeCommitting = false;
|
||||
}
|
||||
|
||||
var5.commitText(var3, 1);
|
||||
var6 = var4;
|
||||
if (var2 == 46) {
|
||||
this.mEnterSpaceBeforeCommitting = true;
|
||||
var6 = var4;
|
||||
connection.commitText(text, 1);
|
||||
updateSuggestions = true;
|
||||
if (keyCode == LeanbackKeyboardView.ASCII_PERIOD) {
|
||||
mEnterSpaceBeforeCommitting = true;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
this.clearSuggestionsDelayed();
|
||||
var5.deleteSurroundingText(1, 0);
|
||||
this.mEnterSpaceBeforeCommitting = false;
|
||||
var6 = var4;
|
||||
case InputListener.ENTRY_TYPE_BACKSPACE:
|
||||
clearSuggestionsDelayed();
|
||||
connection.deleteSurroundingText(1, 0);
|
||||
mEnterSpaceBeforeCommitting = false;
|
||||
updateSuggestions = true;
|
||||
break;
|
||||
case 2:
|
||||
case 6:
|
||||
this.clearSuggestionsDelayed();
|
||||
if (!this.mSuggestionsFactory.shouldSuggestionsAmend()) {
|
||||
var5.deleteSurroundingText(this.getCharLengthBeforeCursor(var5), this.getCharLengthAfterCursor(var5));
|
||||
case InputListener.ENTRY_TYPE_SUGGESTION:
|
||||
case InputListener.ENTRY_TYPE_VOICE:
|
||||
clearSuggestionsDelayed();
|
||||
if (!mSuggestionsFactory.shouldSuggestionsAmend()) {
|
||||
connection.deleteSurroundingText(this.getCharLengthBeforeCursor(connection), this.getCharLengthAfterCursor(connection));
|
||||
} else {
|
||||
var1 = this.getAmpersandLocation(var5);
|
||||
var5.setSelection(var1, var1);
|
||||
var5.deleteSurroundingText(0, this.getCharLengthAfterCursor(var5));
|
||||
int location = this.getAmpersandLocation(connection);
|
||||
connection.setSelection(location, location);
|
||||
connection.deleteSurroundingText(0, this.getCharLengthAfterCursor(connection));
|
||||
}
|
||||
|
||||
var5.commitText(var3, 1);
|
||||
this.mEnterSpaceBeforeCommitting = true;
|
||||
case 5:
|
||||
this.sendDefaultEditorAction(false);
|
||||
var6 = false;
|
||||
connection.commitText(text, 1);
|
||||
mEnterSpaceBeforeCommitting = true;
|
||||
case InputListener.ENTRY_TYPE_ACTION:
|
||||
sendDefaultEditorAction(false);
|
||||
updateSuggestions = false;
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
var3 = var5.getTextBeforeCursor(1000, 0);
|
||||
if (var3 == null) {
|
||||
var2 = 0;
|
||||
case InputListener.ENTRY_TYPE_LEFT:
|
||||
case InputListener.ENTRY_TYPE_RIGHT:
|
||||
CharSequence textBeforeCursor = connection.getTextBeforeCursor(1000, 0);
|
||||
int len;
|
||||
if (textBeforeCursor == null) {
|
||||
len = 0;
|
||||
} else {
|
||||
var2 = var3.length();
|
||||
len = textBeforeCursor.length();
|
||||
}
|
||||
|
||||
if (var1 == 3) {
|
||||
var1 = var2;
|
||||
if (var2 > 0) {
|
||||
var1 = var2 - 1;
|
||||
int index;
|
||||
if (type == InputListener.ENTRY_TYPE_LEFT) {
|
||||
index = len;
|
||||
if (len > 0) {
|
||||
index = len - 1;
|
||||
}
|
||||
} else {
|
||||
var3 = var5.getTextAfterCursor(1000, 0);
|
||||
var1 = var2;
|
||||
if (var3 != null) {
|
||||
var1 = var2;
|
||||
if (var3.length() > 0) {
|
||||
var1 = var2 + 1;
|
||||
}
|
||||
textBeforeCursor = connection.getTextAfterCursor(1000, 0);
|
||||
index = len;
|
||||
if (textBeforeCursor != null && textBeforeCursor.length() > 0) {
|
||||
index = len + 1;
|
||||
}
|
||||
}
|
||||
|
||||
var5.setSelection(var1, var1);
|
||||
var6 = var4;
|
||||
connection.setSelection(index, index);
|
||||
updateSuggestions = true;
|
||||
break;
|
||||
case 7:
|
||||
var5.performEditorAction(1);
|
||||
var6 = false;
|
||||
case InputListener.ENTRY_TYPE_DISMISS:
|
||||
connection.performEditorAction(EditorInfo.IME_ACTION_NONE);
|
||||
updateSuggestions = false;
|
||||
break;
|
||||
case 8:
|
||||
var5.performEditorAction(2);
|
||||
var6 = false;
|
||||
case InputListener.ENTRY_TYPE_VOICE_DISMISS:
|
||||
connection.performEditorAction(EditorInfo.IME_ACTION_GO);
|
||||
updateSuggestions = false;
|
||||
break;
|
||||
default:
|
||||
var6 = var4;
|
||||
updateSuggestions = true;
|
||||
}
|
||||
|
||||
if (this.mKeyboardController.areSuggestionsEnabled() && var6) {
|
||||
this.mKeyboardController.updateSuggestions(this.mSuggestionsFactory.getSuggestions());
|
||||
return;
|
||||
if (mKeyboardController.areSuggestionsEnabled() && updateSuggestions) {
|
||||
mKeyboardController.updateSuggestions(mSuggestionsFactory.getSuggestions());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateInputView() {
|
||||
this.mInputView = this.mKeyboardController.getView();
|
||||
this.mInputView.requestFocus();
|
||||
return this.mInputView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisplayCompletions(CompletionInfo[] var1) {
|
||||
if (this.mKeyboardController.areSuggestionsEnabled()) {
|
||||
this.mShouldClearSuggestions = false;
|
||||
@@ -231,47 +231,56 @@ public class LeanbackImeService extends InputMethodService {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinishInputView(boolean var1) {
|
||||
super.onFinishInputView(var1);
|
||||
this.sendBroadcast(new Intent("com.google.android.athome.action.IME_CLOSE"));
|
||||
this.sendBroadcast(new Intent(IME_CLOSE));
|
||||
this.mSuggestionsFactory.clearSuggestions();
|
||||
}
|
||||
|
||||
public boolean onGenericMotionEvent(MotionEvent var1) {
|
||||
return this.isInputViewShown() && (var1.getSource() & 2097152) == 2097152 && this.mKeyboardController.onGenericMotionEvent(var1) ? true :
|
||||
super.onGenericMotionEvent(var1);
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public boolean onGenericMotionEvent(MotionEvent event) {
|
||||
return isInputViewShown() &&
|
||||
(event.getSource() & InputDevice.SOURCE_TOUCH_NAVIGATION) == InputDevice.SOURCE_TOUCH_NAVIGATION &&
|
||||
mKeyboardController.onGenericMotionEvent(event) || super.onGenericMotionEvent(event);
|
||||
}
|
||||
|
||||
public void onHideIme() {
|
||||
this.requestHideSelf(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitializeInterface() {
|
||||
this.mKeyboardController = new LeanbackKeyboardController(this, this.mInputListener);
|
||||
this.mEnterSpaceBeforeCommitting = false;
|
||||
this.mSuggestionsFactory = new LeanbackSuggestionsFactory(this, 10);
|
||||
mKeyboardController = new LeanbackKeyboardController(this, mInputListener);
|
||||
mEnterSpaceBeforeCommitting = false;
|
||||
mSuggestionsFactory = new LeanbackSuggestionsFactory(this, MAX_SUGGESTIONS);
|
||||
}
|
||||
|
||||
public boolean onKeyDown(int var1, KeyEvent var2) {
|
||||
return this.isInputViewShown() && this.mKeyboardController.onKeyDown(var1, var2) ? true : super.onKeyDown(var1, var2);
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
return isInputViewShown() && mKeyboardController.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
public boolean onKeyUp(int var1, KeyEvent var2) {
|
||||
return this.isInputViewShown() && this.mKeyboardController.onKeyUp(var1, var2) ? true : super.onKeyUp(var1, var2);
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
return isInputViewShown() && mKeyboardController.onKeyUp(keyCode, event) || super.onKeyUp(keyCode, event);
|
||||
}
|
||||
|
||||
public boolean onShowInputRequested(int var1, boolean var2) {
|
||||
@Override
|
||||
public boolean onShowInputRequested(int flags, boolean configChange) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int onStartCommand(Intent var1, int var2, int var3) {
|
||||
if (var1 != null) {
|
||||
super.onStartCommand(var1, var2, var3);
|
||||
if (var1.getBooleanExtra("restart", false)) {
|
||||
@Override
|
||||
public int onStartCommand(final Intent intent, final int flags, final int startId) {
|
||||
if (intent != null) {
|
||||
super.onStartCommand(intent, flags, startId);
|
||||
if (intent.getBooleanExtra("restart", false)) {
|
||||
Log.e("LeanbackImeService", "Service->onStartCommand: trying to restart service");
|
||||
LeanbackKeyboardController var4 = this.mKeyboardController;
|
||||
if (var4 != null) {
|
||||
var4.updateAddonKeyboard();
|
||||
LeanbackKeyboardController controller = mKeyboardController;
|
||||
if (controller != null) {
|
||||
controller.updateAddonKeyboard();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -279,25 +288,27 @@ public class LeanbackImeService extends InputMethodService {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void onStartInput(EditorInfo var1, boolean var2) {
|
||||
super.onStartInput(var1, var2);
|
||||
this.mEnterSpaceBeforeCommitting = false;
|
||||
this.mSuggestionsFactory.onStartInput(var1);
|
||||
this.mKeyboardController.onStartInput(var1);
|
||||
@Override
|
||||
public void onStartInput(EditorInfo info, boolean restarting) {
|
||||
super.onStartInput(info, restarting);
|
||||
mEnterSpaceBeforeCommitting = false;
|
||||
mSuggestionsFactory.onStartInput(info);
|
||||
mKeyboardController.onStartInput(info);
|
||||
}
|
||||
|
||||
public void onStartInputView(EditorInfo var1, boolean var2) {
|
||||
super.onStartInputView(var1, var2);
|
||||
this.mKeyboardController.onStartInputView();
|
||||
this.sendBroadcast(new Intent("com.google.android.athome.action.IME_OPEN"));
|
||||
if (this.mKeyboardController.areSuggestionsEnabled()) {
|
||||
this.mSuggestionsFactory.createSuggestions();
|
||||
this.mKeyboardController.updateSuggestions(this.mSuggestionsFactory.getSuggestions());
|
||||
InputConnection var4 = this.getCurrentInputConnection();
|
||||
if (var4 != null) {
|
||||
String var3 = this.getEditorText(var4);
|
||||
var4.deleteSurroundingText(this.getCharLengthBeforeCursor(var4), this.getCharLengthAfterCursor(var4));
|
||||
var4.commitText(var3, 1);
|
||||
@Override
|
||||
public void onStartInputView(EditorInfo info, boolean restarting) {
|
||||
super.onStartInputView(info, restarting);
|
||||
mKeyboardController.onStartInputView();
|
||||
sendBroadcast(new Intent(IME_OPEN));
|
||||
if (mKeyboardController.areSuggestionsEnabled()) {
|
||||
mSuggestionsFactory.createSuggestions();
|
||||
mKeyboardController.updateSuggestions(mSuggestionsFactory.getSuggestions());
|
||||
InputConnection connection = getCurrentInputConnection();
|
||||
if (connection != null) {
|
||||
String text = getEditorText(connection);
|
||||
connection.deleteSurroundingText(getCharLengthBeforeCursor(connection), getCharLengthAfterCursor(connection));
|
||||
connection.commitText(text, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user