refactoring after power shutdown

This commit is contained in:
Yuriy Liskov
2018-01-22 10:55:15 +02:00
parent ca382ea3fd
commit 97da009cf3
6 changed files with 242 additions and 216 deletions

1
.gitignore vendored
View File

@@ -1,7 +1,6 @@
notes.txt
/files
/misc
/TODO.txt
tmp/
*_bak*
*_tmp

View File

@@ -6,11 +6,11 @@ public class EventLogTags {
public static final int TIME_LEANBACK_IME_INPUT = 270900;
public static final int TOTAL_LEANBACK_IME_BACKSPACE = 270902;
public static void writeTimeLeanbackImeInput(long var0, long var2) {
EventLog.writeEvent(270900, new Object[]{var0, var2});
public static void writeTimeLeanbackImeInput(long time, long duration) {
EventLog.writeEvent(TIME_LEANBACK_IME_INPUT, new Object[]{time, duration});
}
public static void writeTotalLeanbackImeBackspace(int var0) {
EventLog.writeEvent(270902, var0);
public static void writeTotalLeanbackImeBackspace(int count) {
EventLog.writeEvent(TOTAL_LEANBACK_IME_BACKSPACE, count);
}
}

View File

@@ -1,10 +1,10 @@
package com.google.android.leanback.ime;
import android.animation.Animator;
import android.animation.ValueAnimator;
import android.animation.Animator.AnimatorListener;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.annotation.TargetApi;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
@@ -16,6 +16,7 @@ import android.os.Bundle;
import android.speech.RecognitionListener;
import android.speech.RecognizerIntent;
import android.speech.SpeechRecognizer;
import android.text.InputType;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
@@ -108,32 +109,40 @@ public class LeanbackKeyboardContainer {
private RecognizerView mVoiceButtonView;
private boolean mVoiceEnabled;
private AnimatorListener mVoiceEnterListener = new AnimatorListener() {
public void onAnimationCancel(Animator var1) {
@Override
public void onAnimationCancel(Animator animation) {
}
public void onAnimationEnd(Animator var1) {
@Override
public void onAnimationEnd(Animator animation) {
}
public void onAnimationRepeat(Animator var1) {
@Override
public void onAnimationRepeat(Animator animation) {
}
public void onAnimationStart(Animator var1) {
@Override
public void onAnimationStart(Animator animation) {
LeanbackKeyboardContainer.this.mSelector.setVisibility(View.INVISIBLE);
LeanbackKeyboardContainer.this.startRecognition(LeanbackKeyboardContainer.this.mContext);
}
};
private AnimatorListener mVoiceExitListener = new AnimatorListener() {
public void onAnimationCancel(Animator var1) {
@Override
public void onAnimationCancel(Animator animation) {
}
public void onAnimationEnd(Animator var1) {
@Override
public void onAnimationEnd(Animator animation) {
LeanbackKeyboardContainer.this.mSelector.setVisibility(View.VISIBLE);
}
public void onAnimationRepeat(Animator var1) {
@Override
public void onAnimationRepeat(Animator animation) {
}
public void onAnimationStart(Animator var1) {
@Override
public void onAnimationStart(Animator animation) {
LeanbackKeyboardContainer.this.mVoiceButtonView.showNotListening();
LeanbackKeyboardContainer.this.mSpeechRecognizer.cancel();
LeanbackKeyboardContainer.this.mSpeechRecognizer.setRecognitionListener((RecognitionListener) null);
@@ -147,47 +156,50 @@ public class LeanbackKeyboardContainer {
private Float mY;
public LeanbackKeyboardContainer(Context context) {
this.mContext = (LeanbackImeService) context;
final Resources res = this.mContext.getResources();
this.mVoiceAnimDur = res.getInteger(R.integer.voice_anim_duration);
this.mAlphaIn = res.getFraction(R.fraction.alpha_in, 1, 1);
this.mAlphaOut = res.getFraction(R.fraction.alpha_out, 1, 1);
this.mVoiceAnimator = new LeanbackKeyboardContainer.VoiceIntroAnimator(this.mVoiceEnterListener, this.mVoiceExitListener);
this.initKeyboards();
this.mRootView = (RelativeLayout) this.mContext.getLayoutInflater().inflate(R.layout.root_leanback, null);
this.mKeyboardsContainer = this.mRootView.findViewById(R.id.keyboard);
this.mSuggestionsBg = this.mRootView.findViewById(R.id.candidate_background);
this.mSuggestionsContainer = (HorizontalScrollView) this.mRootView.findViewById(R.id.suggestions_container);
this.mSuggestions = (LinearLayout) this.mSuggestionsContainer.findViewById(R.id.suggestions);
this.mMainKeyboardView = (LeanbackKeyboardView) this.mRootView.findViewById(R.id.main_keyboard);
this.mVoiceButtonView = (RecognizerView) this.mRootView.findViewById(R.id.voice);
this.mActionButtonView = (Button) this.mRootView.findViewById(R.id.enter);
this.mSelector = this.mRootView.findViewById(R.id.selector);
this.mSelectorAnimation = new LeanbackKeyboardContainer.ScaleAnimation((FrameLayout) this.mSelector);
this.mOverestimate = this.mContext.getResources().getFraction(R.fraction.focused_scale, 1, 1);
mContext = (LeanbackImeService) context;
final Resources res = mContext.getResources();
mVoiceAnimDur = res.getInteger(R.integer.voice_anim_duration);
mAlphaIn = res.getFraction(R.fraction.alpha_in, 1, 1);
mAlphaOut = res.getFraction(R.fraction.alpha_out, 1, 1);
mVoiceAnimator = new LeanbackKeyboardContainer.VoiceIntroAnimator(mVoiceEnterListener, mVoiceExitListener);
initKeyboards();
mRootView = (RelativeLayout) mContext.getLayoutInflater().inflate(R.layout.root_leanback, null);
mKeyboardsContainer = mRootView.findViewById(R.id.keyboard);
mSuggestionsBg = mRootView.findViewById(R.id.candidate_background);
mSuggestionsContainer = (HorizontalScrollView) mRootView.findViewById(R.id.suggestions_container);
mSuggestions = (LinearLayout) mSuggestionsContainer.findViewById(R.id.suggestions);
mMainKeyboardView = (LeanbackKeyboardView) mRootView.findViewById(R.id.main_keyboard);
mVoiceButtonView = (RecognizerView) mRootView.findViewById(R.id.voice);
mActionButtonView = (Button) mRootView.findViewById(R.id.enter);
mSelector = mRootView.findViewById(R.id.selector);
mSelectorAnimation = new LeanbackKeyboardContainer.ScaleAnimation((FrameLayout) mSelector);
mOverestimate = mContext.getResources().getFraction(R.fraction.focused_scale, 1, 1);
final float scale = context.getResources().getFraction(R.fraction.clicked_scale, 1, 1);
this.mClickAnimDur = context.getResources().getInteger(R.integer.clicked_anim_duration);
this.mSelectorAnimator = ValueAnimator.ofFloat(new float[]{1.0F, scale});
this.mSelectorAnimator.setDuration((long) this.mClickAnimDur);
this.mSelectorAnimator.addUpdateListener(new AnimatorUpdateListener() {
mClickAnimDur = context.getResources().getInteger(R.integer.clicked_anim_duration);
mSelectorAnimator = ValueAnimator.ofFloat(new float[]{1.0F, scale});
mSelectorAnimator.setDuration((long) mClickAnimDur);
mSelectorAnimator.addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
final float value = (Float) animation.getAnimatedValue();
LeanbackKeyboardContainer.this.mSelector.setScaleX(value);
LeanbackKeyboardContainer.this.mSelector.setScaleY(value);
}
});
this.mSpeechLevelSource = new SpeechLevelSource();
this.mVoiceButtonView.setSpeechLevelSource(this.mSpeechLevelSource);
this.mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(this.mContext);
this.mVoiceButtonView.setCallback(new RecognizerView.Callback() {
mSpeechLevelSource = new SpeechLevelSource();
mVoiceButtonView.setSpeechLevelSource(mSpeechLevelSource);
mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(mContext);
mVoiceButtonView.setCallback(new RecognizerView.Callback() {
@Override
public void onCancelRecordingClicked() {
LeanbackKeyboardContainer.this.cancelVoiceRecording();
}
@Override
public void onStartRecordingClicked() {
LeanbackKeyboardContainer.this.startVoiceRecording();
}
@Override
public void onStopRecordingClicked() {
LeanbackKeyboardContainer.this.cancelVoiceRecording();
}
@@ -200,6 +212,14 @@ public class LeanbackKeyboardContainer {
focus.rect.set(rect);
}
/**
* Initialize {@link KeyFocus} with values
* @param focus {@link KeyFocus} to configure
* @param rect {@link Rect}
* @param index key index
* @param key {@link Key}
* @param type {@link KeyFocus#type} constant
*/
private void configureFocus(LeanbackKeyboardContainer.KeyFocus focus, Rect rect, int index, Key key, int type) {
focus.type = type;
if (key != null) {
@@ -268,120 +288,125 @@ public class LeanbackKeyboardContainer {
return false;
}
private void moveFocusToIndex(int var1, int var2) {
Key var3 = this.mMainKeyboardView.getKey(var1);
this.configureFocus(this.mTempKeyInfo, this.mRect, var1, var3, var2);
this.setTouchState(0);
this.setKbFocus(this.mTempKeyInfo, true, true);
/**
* Move focus to specified key
* @param index key index
* @param type {@link KeyFocus#type} constant
*/
private void moveFocusToIndex(int index, int type) {
Key key = this.mMainKeyboardView.getKey(index);
configureFocus(mTempKeyInfo, mRect, index, key, type);
setTouchState(TOUCH_STATE_NO_TOUCH);
setKbFocus(mTempKeyInfo, true, true);
}
private void offsetRect(Rect var1, View var2) {
var1.left = 0;
var1.top = 0;
var1.right = var2.getWidth();
var1.bottom = var2.getHeight();
this.mRootView.offsetDescendantRectToMyCoords(var2, var1);
private void offsetRect(Rect rect, View view) {
rect.left = 0;
rect.top = 0;
rect.right = view.getWidth();
rect.bottom = view.getHeight();
mRootView.offsetDescendantRectToMyCoords(view, rect);
}
private void onToggleCapsLock() {
this.onShiftDoubleClick(this.isCapsLockOn());
onShiftDoubleClick(isCapsLockOn());
}
private void setImeOptions(Resources var1, EditorInfo var2) {
if (this.mInitialMainKeyboard == null) {
this.mInitialMainKeyboard = this.mAbcKeyboard;
private void setImeOptions(Resources res, EditorInfo info) {
if (mInitialMainKeyboard == null) {
mInitialMainKeyboard = mAbcKeyboard;
}
this.mSuggestionsEnabled = false;
this.mAutoEnterSpaceEnabled = false;
this.mVoiceEnabled = false;
this.mEscapeNorthEnabled = false;
this.mVoiceKeyDismissesEnabled = false;
label67:
switch (LeanbackUtils.getInputTypeClass(var2)) {
case 1:
switch (LeanbackUtils.getInputTypeVariation(var2)) {
case 16:
case 32:
case 160:
case 208:
this.mSuggestionsEnabled = false;
this.mAutoEnterSpaceEnabled = false;
this.mVoiceEnabled = false;
this.mInitialMainKeyboard = this.mAbcKeyboard;
break label67;
case 96:
case 128:
case 144:
case 224:
this.mSuggestionsEnabled = false;
this.mVoiceEnabled = false;
this.mInitialMainKeyboard = this.mAbcKeyboard;
default:
break label67;
mSuggestionsEnabled = false;
mAutoEnterSpaceEnabled = false;
mVoiceEnabled = false;
mEscapeNorthEnabled = false;
mVoiceKeyDismissesEnabled = false;
switch (LeanbackUtils.getInputTypeClass(info)) {
case InputType.TYPE_CLASS_TEXT:
switch (LeanbackUtils.getInputTypeVariation(info)) {
case InputType.TYPE_DATETIME_VARIATION_DATE:
case InputType.TYPE_DATETIME_VARIATION_TIME:
case InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT:
case InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS:
mSuggestionsEnabled = false;
mAutoEnterSpaceEnabled = false;
mVoiceEnabled = false;
mInitialMainKeyboard = mAbcKeyboard;
break;
case InputType.TYPE_TEXT_VARIATION_PERSON_NAME:
case InputType.TYPE_TEXT_VARIATION_PASSWORD:
case InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD:
case InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD:
mSuggestionsEnabled = false;
mVoiceEnabled = false;
mInitialMainKeyboard = mAbcKeyboard;
}
case 2:
case 3:
case 4:
this.mSuggestionsEnabled = false;
this.mVoiceEnabled = false;
this.mInitialMainKeyboard = this.mAbcKeyboard;
break;
case InputType.TYPE_CLASS_NUMBER:
case InputType.TYPE_CLASS_PHONE:
case InputType.TYPE_CLASS_DATETIME:
mSuggestionsEnabled = false;
mVoiceEnabled = false;
mInitialMainKeyboard = this.mAbcKeyboard;
}
if (this.mSuggestionsEnabled) {
if ((var2.inputType & 524288) == 0) {
if (mSuggestionsEnabled) {
if ((info.inputType & InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) == 0) {
;
}
this.mSuggestionsEnabled = false;
mSuggestionsEnabled = false;
}
if (this.mAutoEnterSpaceEnabled) {
if (this.mSuggestionsEnabled && this.mAutoEnterSpaceEnabled) {
if (mAutoEnterSpaceEnabled) {
if (mSuggestionsEnabled && mAutoEnterSpaceEnabled) {
;
}
this.mAutoEnterSpaceEnabled = false;
mAutoEnterSpaceEnabled = false;
}
if ((var2.inputType & 16384) != 0) {
if ((info.inputType & InputType.TYPE_TEXT_FLAG_CAP_SENTENCES) != 0) {
;
}
this.mCapSentences = false;
if ((var2.inputType & 8192) == 0 && LeanbackUtils.getInputTypeVariation(var2) == 96) {
mCapSentences = false;
if ((info.inputType & InputType.TYPE_TEXT_FLAG_CAP_WORDS) == 0 &&
LeanbackUtils.getInputTypeVariation(info) == InputType.TYPE_TEXT_VARIATION_PERSON_NAME) {
;
}
this.mCapWords = false;
if ((var2.inputType & 4096) != 0) {
mCapWords = false;
if ((info.inputType & InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS) != 0) {
;
}
this.mCapCharacters = false;
if (var2.privateImeOptions != null) {
if (var2.privateImeOptions.contains(IME_PRIVATE_OPTIONS_ESCAPE_NORTH)) {
this.mEscapeNorthEnabled = false;
mCapCharacters = false;
if (info.privateImeOptions != null) {
if (info.privateImeOptions.contains(IME_PRIVATE_OPTIONS_ESCAPE_NORTH)) {
mEscapeNorthEnabled = false;
}
if (var2.privateImeOptions.contains(IME_PRIVATE_OPTIONS_VOICE_DISMISS)) {
this.mVoiceKeyDismissesEnabled = false;
if (info.privateImeOptions.contains(IME_PRIVATE_OPTIONS_VOICE_DISMISS)) {
mVoiceKeyDismissesEnabled = false;
}
}
this.mEnterKeyText = var2.actionLabel;
if (TextUtils.isEmpty(this.mEnterKeyText)) {
switch (LeanbackUtils.getImeAction(var2)) {
case 2:
mEnterKeyText = info.actionLabel;
if (TextUtils.isEmpty(mEnterKeyText)) {
switch (LeanbackUtils.getImeAction(info)) {
case EditorInfo.IME_ACTION_GO:
this.mEnterKeyTextResId = R.string.label_go_key;
return;
case 3:
case EditorInfo.IME_ACTION_SEARCH:
this.mEnterKeyTextResId = R.string.label_search_key;
return;
case 4:
case EditorInfo.IME_ACTION_SEND:
this.mEnterKeyTextResId = R.string.label_send_key;
return;
case 5:
case EditorInfo.IME_ACTION_NEXT:
this.mEnterKeyTextResId = R.string.label_next_key;
return;
default:
@@ -391,6 +416,12 @@ public class LeanbackKeyboardContainer {
}
/**
* Move focus to specified key
* @param focus key that will be focused
* @param forceFocusChange force focus
* @param animate animate transition
*/
private void setKbFocus(final LeanbackKeyboardContainer.KeyFocus focus, final boolean forceFocusChange, final boolean animate) {
boolean clicked = true;
if (!focus.equals(this.mCurrKeyInfo) || forceFocusChange) {
@@ -846,129 +877,126 @@ public class LeanbackKeyboardContainer {
}
public void onShiftClick() {
byte var1;
if (this.mMainKeyboardView.isShifted()) {
var1 = 0;
byte state;
if (mMainKeyboardView.isShifted()) {
state = LeanbackKeyboardView.SHIFT_OFF;
} else {
var1 = 1;
state = LeanbackKeyboardView.SHIFT_ON;
}
this.setShiftState(var1);
setShiftState(state);
}
// TODO: state constants
public void onShiftDoubleClick(boolean wasCapsLockOn) {
byte state;
if (wasCapsLockOn) {
state = 0;
state = LeanbackKeyboardView.SHIFT_OFF;
} else {
state = 2;
state = LeanbackKeyboardView.SHIFT_LOCKED;
}
this.setShiftState(state);
setShiftState(state);
}
public void onSpaceEntry() {
if (this.mMainKeyboardView.isShifted()) {
if (!this.isCapsLockOn() && !this.mCapCharacters && !this.mCapWords) {
this.setShiftState(0);
if (mMainKeyboardView.isShifted()) {
if (!isCapsLockOn() && !mCapCharacters && !mCapWords) {
setShiftState(LeanbackKeyboardView.SHIFT_OFF);
}
} else if (this.isCapsLockOn() || this.mCapCharacters || this.mCapWords) {
this.setShiftState(1);
return;
} else if (isCapsLockOn() || mCapCharacters || mCapWords) {
setShiftState(LeanbackKeyboardView.SHIFT_ON);
}
}
public void onStartInput(EditorInfo info) {
this.setImeOptions(this.mContext.getResources(), info);
this.mVoiceOn = false;
setImeOptions(mContext.getResources(), info);
mVoiceOn = false;
}
@TargetApi(17)
@SuppressLint("NewApi")
public void onStartInputView() {
this.clearSuggestions();
LayoutParams params = (LayoutParams) this.mKeyboardsContainer.getLayoutParams();
if (this.mSuggestionsEnabled) {
clearSuggestions();
LayoutParams params = (LayoutParams) mKeyboardsContainer.getLayoutParams();
if (mSuggestionsEnabled) {
params.removeRule(10);
this.mSuggestionsContainer.setVisibility(View.VISIBLE);
this.mSuggestionsBg.setVisibility(View.VISIBLE);
mSuggestionsContainer.setVisibility(View.VISIBLE);
mSuggestionsBg.setVisibility(View.VISIBLE);
} else {
params.addRule(10);
this.mSuggestionsContainer.setVisibility(View.GONE);
this.mSuggestionsBg.setVisibility(View.GONE);
mSuggestionsContainer.setVisibility(View.GONE);
mSuggestionsBg.setVisibility(View.GONE);
}
this.mKeyboardsContainer.setLayoutParams(params);
this.mMainKeyboardView.setKeyboard(this.mInitialMainKeyboard);
this.mVoiceButtonView.setMicEnabled(this.mVoiceEnabled);
this.resetVoice();
this.dismissMiniKeyboard();
if (!TextUtils.isEmpty(this.mEnterKeyText)) {
this.mActionButtonView.setText(this.mEnterKeyText);
this.mActionButtonView.setContentDescription(this.mEnterKeyText);
mKeyboardsContainer.setLayoutParams(params);
mMainKeyboardView.setKeyboard(mInitialMainKeyboard);
mVoiceButtonView.setMicEnabled(mVoiceEnabled);
resetVoice();
dismissMiniKeyboard();
if (!TextUtils.isEmpty(mEnterKeyText)) {
mActionButtonView.setText(mEnterKeyText);
mActionButtonView.setContentDescription(mEnterKeyText);
} else {
this.mActionButtonView.setText(this.mEnterKeyTextResId);
this.mActionButtonView.setContentDescription(this.mContext.getString(this.mEnterKeyTextResId));
mActionButtonView.setText(mEnterKeyTextResId);
mActionButtonView.setContentDescription(mContext.getString(mEnterKeyTextResId));
}
if (this.mCapCharacters) {
this.setShiftState(2);
} else if (!this.mCapSentences && !this.mCapWords) {
this.setShiftState(0);
if (mCapCharacters) {
setShiftState(LeanbackKeyboardView.SHIFT_LOCKED);
} else if (!mCapSentences && !mCapWords) {
setShiftState(LeanbackKeyboardView.SHIFT_OFF);
} else {
this.setShiftState(1);
setShiftState(LeanbackKeyboardView.SHIFT_ON);
}
}
public void onTextEntry() {
if (this.mMainKeyboardView.isShifted()) {
if (!this.isCapsLockOn() && !this.mCapCharacters) {
this.setShiftState(0);
if (mMainKeyboardView.isShifted()) {
if (!isCapsLockOn() && !mCapCharacters) {
setShiftState(LeanbackKeyboardView.SHIFT_OFF);
}
} else if (this.isCapsLockOn() || this.mCapCharacters) {
this.setShiftState(2);
} else if (isCapsLockOn() || mCapCharacters) {
setShiftState(LeanbackKeyboardView.SHIFT_LOCKED);
}
if (this.dismissMiniKeyboard()) {
this.moveFocusToIndex(this.mMiniKbKeyIndex, 0);
if (dismissMiniKeyboard()) {
moveFocusToIndex(mMiniKbKeyIndex, KeyFocus.TYPE_MAIN);
}
}
public void onVoiceClick() {
if (this.mVoiceButtonView != null) {
this.mVoiceButtonView.onClick();
if (mVoiceButtonView != null) {
mVoiceButtonView.onClick();
}
}
public void resetFocusCursor() {
this.offsetRect(this.mRect, this.mMainKeyboardView);
this.mX = (float) ((double) this.mRect.left + (double) this.mRect.width() * 0.45D);
this.mY = (float) ((double) this.mRect.top + (double) this.mRect.height() * 0.375D);
this.getBestFocus(this.mX, this.mY, this.mTempKeyInfo);
this.setKbFocus(this.mTempKeyInfo, true, false);
this.setTouchStateInternal(0);
this.mSelectorAnimator.reverse();
this.mSelectorAnimator.end();
offsetRect(mRect, mMainKeyboardView);
mX = (float) ((double) mRect.left + (double) mRect.width() * 0.45D);
mY = (float) ((double) mRect.top + (double) mRect.height() * 0.375D);
getBestFocus(mX, mY, mTempKeyInfo);
setKbFocus(mTempKeyInfo, true, false);
setTouchStateInternal(0);
mSelectorAnimator.reverse();
mSelectorAnimator.end();
}
public void resetVoice() {
this.mMainKeyboardView.setAlpha(this.mAlphaIn);
this.mActionButtonView.setAlpha(this.mAlphaIn);
this.mVoiceButtonView.setAlpha(this.mAlphaOut);
this.mMainKeyboardView.setVisibility(View.VISIBLE);
this.mActionButtonView.setVisibility(View.VISIBLE);
this.mVoiceButtonView.setVisibility(View.INVISIBLE);
mMainKeyboardView.setAlpha(mAlphaIn);
mActionButtonView.setAlpha(mAlphaIn);
mVoiceButtonView.setAlpha(mAlphaOut);
mMainKeyboardView.setVisibility(View.VISIBLE);
mActionButtonView.setVisibility(View.VISIBLE);
mVoiceButtonView.setVisibility(View.INVISIBLE);
}
public void setDismissListener(LeanbackKeyboardContainer.DismissListener listener) {
this.mDismissListener = listener;
mDismissListener = listener;
}
public void setFocus(LeanbackKeyboardContainer.KeyFocus focus) {
this.setKbFocus(focus, false, true);
setKbFocus(focus, false, true);
}
public void setSelectorToFocus(Rect rect, boolean overestimateWidth, boolean overestimateHeight, boolean animate) {
@@ -1124,17 +1152,12 @@ public class LeanbackKeyboardContainer {
return false;
}
// TODO: label
label31:
{
if (this.label != null) {
if (this.label.equals(focus.label)) {
break label31;
}
} else if (focus.label == null) {
break label31;
}
// equality must be commutative
if (this.label == null && focus.label != null) {
return false;
}
if (this.label != null && !this.label.equals(focus.label)) {
return false;
}

View File

@@ -1,38 +1,42 @@
package com.google.android.leanback.ime;
import android.annotation.SuppressLint;
import android.os.Handler;
import android.text.InputType;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import android.view.inputmethod.EditorInfo;
public class LeanbackUtils {
private static final int ACCESSIBILITY_DELAY_MS = 250;
private static final Handler sAccessibilityHandler = new Handler();
private static final int ACCESSIBILITY_DELAY_MS = 250;
private static final Handler sAccessibilityHandler = new Handler();
public static int getImeAction(EditorInfo var0) {
return var0.imeOptions & 1073742079;
}
public static int getImeAction(EditorInfo info) {
return info.imeOptions & (EditorInfo.IME_FLAG_NO_ENTER_ACTION | EditorInfo.IME_MASK_ACTION);
}
public static int getInputTypeClass(EditorInfo var0) {
return var0.inputType & 15;
}
public static int getInputTypeClass(EditorInfo info) {
return info.inputType & InputType.TYPE_MASK_CLASS;
}
public static int getInputTypeVariation(EditorInfo var0) {
return var0.inputType & 4080;
}
public static int getInputTypeVariation(EditorInfo info) {
return info.inputType & InputType.TYPE_MASK_VARIATION;
}
public static boolean isAlphabet(int var0) {
return Character.isLetter(var0);
}
public static boolean isAlphabet(int letter) {
return Character.isLetter(letter);
}
public static void sendAccessibilityEvent(final View var0, boolean var1) {
if (var0 != null && var1) {
sAccessibilityHandler.removeCallbacksAndMessages((Object)null);
sAccessibilityHandler.postDelayed(new Runnable() {
public void run() {
var0.sendAccessibilityEvent(16384);
}
}, 250L);
}
@SuppressLint("NewApi")
public static void sendAccessibilityEvent(final View view, boolean focusGained) {
if (view != null && focusGained) {
sAccessibilityHandler.removeCallbacksAndMessages(null);
sAccessibilityHandler.postDelayed(new Runnable() {
public void run() {
view.sendAccessibilityEvent(AccessibilityEvent.TYPE_ANNOUNCEMENT);
}
}, ACCESSIBILITY_DELAY_MS);
}
}
}
}

View File

@@ -31,8 +31,8 @@ public class LeanbackImeService extends InputMethodService {
private static final String TAG = "LbImeService";
private boolean mEnterSpaceBeforeCommitting;
private final Handler mHandler = new Handler() {
public void handleMessage(Message var1) {
if (var1.what == 123 && LeanbackImeService.this.mShouldClearSuggestions) {
public void handleMessage(Message msg) {
if (msg.what == MSG_SUGGESTIONS_CLEAR && LeanbackImeService.this.mShouldClearSuggestions) {
LeanbackImeService.this.mSuggestionsFactory.clearSuggestions();
LeanbackImeService.this.mKeyboardController.updateSuggestions(LeanbackImeService.this.mSuggestionsFactory.getSuggestions());
LeanbackImeService.this.mShouldClearSuggestions = false;

View File

@@ -11,7 +11,7 @@
<LinearLayout android:gravity="center" android:orientation="horizontal" android:id="@+id/suggestions" android:clipChildren="false"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:divider="@null" android:showDividers="middle"/>
</HorizontalScrollView>
<!-- TODO: original position - on top of the HorizontalScrollView -->
<!-- NOTE: moved below HorizontalScrollView because some ids not generated yet -->
<View android:id="@+id/candidate_background" android:background="@color/candidate_background" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignBottom="@id/suggestions_container" android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" android:layout_alignParentRight="true"/>