Merge "Get rid of references to BaseKeyboard in Latin-specific classes"

main
Ken Wakasa 2010-10-25 02:08:31 -07:00 committed by Android (Google) Code Review
commit 55952c9868
3 changed files with 30 additions and 26 deletions

View File

@ -1791,7 +1791,7 @@ public class LatinIME extends InputMethodService
private void updateSuggestions() { private void updateSuggestions() {
LatinKeyboardView inputView = mKeyboardSwitcher.getInputView(); LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
((LatinKeyboard) inputView.getKeyboard()).setPreferredLetters(null); inputView.getLatinKeyboard().setPreferredLetters(null);
// Check if we have a suggestion engine attached. // Check if we have a suggestion engine attached.
if ((mSuggest == null || !isPredictionOn()) && !mVoiceInputHighlighted) { if ((mSuggest == null || !isPredictionOn()) && !mVoiceInputHighlighted) {
@ -1813,7 +1813,7 @@ public class LatinIME extends InputMethodService
private void showCorrections(WordAlternatives alternatives) { private void showCorrections(WordAlternatives alternatives) {
List<CharSequence> stringList = alternatives.getAlternatives(); List<CharSequence> stringList = alternatives.getAlternatives();
((LatinKeyboard) mKeyboardSwitcher.getInputView().getKeyboard()).setPreferredLetters(null); mKeyboardSwitcher.getInputView().getLatinKeyboard().setPreferredLetters(null);
showSuggestions(stringList, alternatives.getOriginalWord(), false, false); showSuggestions(stringList, alternatives.getOriginalWord(), false, false);
} }
@ -1829,7 +1829,7 @@ public class LatinIME extends InputMethodService
int[] nextLettersFrequencies = mSuggest.getNextLettersFrequencies(); int[] nextLettersFrequencies = mSuggest.getNextLettersFrequencies();
((LatinKeyboard) mKeyboardSwitcher.getInputView().getKeyboard()).setPreferredLetters( mKeyboardSwitcher.getInputView().getLatinKeyboard().setPreferredLetters(
nextLettersFrequencies); nextLettersFrequencies);
boolean correctionAvailable = !mInputTypeNoAutoCorrect && mSuggest.hasMinimalCorrection(); boolean correctionAvailable = !mInputTypeNoAutoCorrect && mSuggest.hasMinimalCorrection();
@ -2018,7 +2018,7 @@ public class LatinIME extends InputMethodService
saveWordInHistory(suggestion); saveWordInHistory(suggestion);
mPredicting = false; mPredicting = false;
mCommittedLength = suggestion.length(); mCommittedLength = suggestion.length();
((LatinKeyboard) inputView.getKeyboard()).setPreferredLetters(null); inputView.getLatinKeyboard().setPreferredLetters(null);
// If we just corrected a word, then don't show punctuations // If we just corrected a word, then don't show punctuations
if (!correcting) { if (!correcting) {
setNextSuggestions(); setNextSuggestions();
@ -2321,7 +2321,7 @@ public class LatinIME extends InputMethodService
public void onRelease(int primaryCode) { public void onRelease(int primaryCode) {
// Reset any drag flags in the keyboard // Reset any drag flags in the keyboard
((LatinKeyboard) mKeyboardSwitcher.getInputView().getKeyboard()).keyReleased(); mKeyboardSwitcher.getInputView().getLatinKeyboard().keyReleased();
//vibrate(); //vibrate();
final boolean distinctMultiTouch = mKeyboardSwitcher.hasDistinctMultitouch(); final boolean distinctMultiTouch = mKeyboardSwitcher.hasDistinctMultitouch();
if (distinctMultiTouch && primaryCode == BaseKeyboard.KEYCODE_SHIFT) { if (distinctMultiTouch && primaryCode == BaseKeyboard.KEYCODE_SHIFT) {

View File

@ -598,7 +598,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
* @see #getKeyboard() * @see #getKeyboard()
* @param keyboard the keyboard to display in this view * @param keyboard the keyboard to display in this view
*/ */
public void setKeyboard(BaseKeyboard keyboard) { protected void setKeyboard(BaseKeyboard keyboard) {
if (mKeyboard != null) { if (mKeyboard != null) {
dismissKeyPreview(); dismissKeyPreview();
} }
@ -626,7 +626,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
* @return the currently attached keyboard * @return the currently attached keyboard
* @see #setKeyboard(BaseKeyboard) * @see #setKeyboard(BaseKeyboard)
*/ */
public BaseKeyboard getKeyboard() { protected BaseKeyboard getKeyboard() {
return mKeyboard; return mKeyboard;
} }

View File

@ -40,7 +40,7 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
public static final int KEYCODE_PREV_LANGUAGE = -105; public static final int KEYCODE_PREV_LANGUAGE = -105;
public static final int KEYCODE_CAPSLOCK = -106; public static final int KEYCODE_CAPSLOCK = -106;
private BaseKeyboard mPhoneKeyboard; private LatinKeyboard mPhoneKeyboard;
/** Whether we've started dropping move events because we found a big jump */ /** Whether we've started dropping move events because we found a big jump */
private boolean mDroppingEvents; private boolean mDroppingEvents;
@ -62,13 +62,13 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
super(context, attrs, defStyle); super(context, attrs, defStyle);
} }
public void setPhoneKeyboard(BaseKeyboard phoneKeyboard) { public void setPhoneKeyboard(LatinKeyboard phoneKeyboard) {
mPhoneKeyboard = phoneKeyboard; mPhoneKeyboard = phoneKeyboard;
} }
@Override @Override
public void setPreviewEnabled(boolean previewEnabled) { public void setPreviewEnabled(boolean previewEnabled) {
if (getKeyboard() == mPhoneKeyboard) { if (getLatinKeyboard() == mPhoneKeyboard) {
// Phone keyboard never shows popup preview (except language switch). // Phone keyboard never shows popup preview (except language switch).
super.setPreviewEnabled(false); super.setPreviewEnabled(false);
} else { } else {
@ -76,8 +76,7 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
} }
} }
@Override public void setLatinKeyboard(LatinKeyboard k) {
public void setKeyboard(BaseKeyboard k) {
super.setKeyboard(k); super.setKeyboard(k);
// One-seventh of the keyboard width seems like a reasonable threshold // One-seventh of the keyboard width seems like a reasonable threshold
mJumpThresholdSquare = k.getMinWidth() / 7; mJumpThresholdSquare = k.getMinWidth() / 7;
@ -87,12 +86,21 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
setKeyboardLocal(k); setKeyboardLocal(k);
} }
public LatinKeyboard getLatinKeyboard() {
BaseKeyboard keyboard = getKeyboard();
if (keyboard instanceof LatinKeyboard) {
return (LatinKeyboard)keyboard;
} else {
return null;
}
}
@Override @Override
protected boolean onLongPress(Key key) { protected boolean onLongPress(Key key) {
int primaryCode = key.codes[0]; int primaryCode = key.codes[0];
if (primaryCode == KEYCODE_OPTIONS) { if (primaryCode == KEYCODE_OPTIONS) {
return invokeOnKey(KEYCODE_OPTIONS_LONGPRESS); return invokeOnKey(KEYCODE_OPTIONS_LONGPRESS);
} else if (primaryCode == '0' && getKeyboard() == mPhoneKeyboard) { } else if (primaryCode == '0' && getLatinKeyboard() == mPhoneKeyboard) {
// Long pressing on 0 in phone number keypad gives you a '+'. // Long pressing on 0 in phone number keypad gives you a '+'.
return invokeOnKey('+'); return invokeOnKey('+');
} else { } else {
@ -109,9 +117,8 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
@Override @Override
protected CharSequence adjustCase(CharSequence label) { protected CharSequence adjustCase(CharSequence label) {
BaseKeyboard keyboard = getKeyboard(); LatinKeyboard keyboard = getLatinKeyboard();
if (keyboard instanceof LatinKeyboard if (keyboard.isAlphaKeyboard()
&& ((LatinKeyboard) keyboard).isAlphaKeyboard()
&& keyboard.isShifted() && keyboard.isShifted()
&& !TextUtils.isEmpty(label) && label.length() < 3 && !TextUtils.isEmpty(label) && label.length() < 3
&& Character.isLowerCase(label.charAt(0))) { && Character.isLowerCase(label.charAt(0))) {
@ -121,13 +128,10 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
} }
public boolean setShiftLocked(boolean shiftLocked) { public boolean setShiftLocked(boolean shiftLocked) {
BaseKeyboard keyboard = getKeyboard(); LatinKeyboard keyboard = getLatinKeyboard();
if (keyboard instanceof LatinKeyboard) { keyboard.setShiftLocked(shiftLocked);
((LatinKeyboard)keyboard).setShiftLocked(shiftLocked); invalidateAllKeys();
invalidateAllKeys(); return true;
return true;
}
return false;
} }
/** /**
@ -209,7 +213,7 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
@Override @Override
public boolean onTouchEvent(MotionEvent me) { public boolean onTouchEvent(MotionEvent me) {
LatinKeyboard keyboard = (LatinKeyboard) getKeyboard(); LatinKeyboard keyboard = getLatinKeyboard();
if (DEBUG_LINE) { if (DEBUG_LINE) {
mLastX = (int) me.getX(); mLastX = (int) me.getX();
mLastY = (int) me.getY(); mLastY = (int) me.getY();
@ -258,7 +262,7 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
private int mLastY; private int mLastY;
private Paint mPaint; private Paint mPaint;
private void setKeyboardLocal(BaseKeyboard k) { private void setKeyboardLocal(LatinKeyboard k) {
if (DEBUG_AUTO_PLAY) { if (DEBUG_AUTO_PLAY) {
findKeys(); findKeys();
if (mHandler2 == null) { if (mHandler2 == null) {
@ -319,7 +323,7 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
} }
private void findKeys() { private void findKeys() {
List<Key> keys = getKeyboard().getKeys(); List<Key> keys = getLatinKeyboard().getKeys();
// Get the keys on this keyboard // Get the keys on this keyboard
for (int i = 0; i < keys.size(); i++) { for (int i = 0; i < keys.size(); i++) {
int code = keys.get(i).codes[0]; int code = keys.get(i).codes[0];