Remove LatinKeyboardBaseView.isShifted() and setShifted() for refactoring
Change-Id: I9a1106b679a9ffb3ae959d90377eef096e5af842main
parent
55952c9868
commit
29ff343f77
|
@ -392,7 +392,10 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
|
|
||||||
public void setShifted(boolean shifted) {
|
public void setShifted(boolean shifted) {
|
||||||
if (mInputView != null) {
|
if (mInputView != null) {
|
||||||
mInputView.setShifted(shifted);
|
LatinKeyboard latinKeyboard = mInputView.getLatinKeyboard();
|
||||||
|
if (latinKeyboard != null && latinKeyboard.setShifted(shifted)) {
|
||||||
|
mInputView.invalidateAllKeys();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -993,7 +993,8 @@ public class LatinIME extends InputMethodService
|
||||||
LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
|
LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
|
||||||
// Enable shift key and DPAD to do selections
|
// Enable shift key and DPAD to do selections
|
||||||
if (inputView != null && inputView.isShown()
|
if (inputView != null && inputView.isShown()
|
||||||
&& inputView.isShifted()) {
|
&& inputView.getLatinKeyboard() != null
|
||||||
|
&& inputView.getLatinKeyboard().isShifted()) {
|
||||||
event = new KeyEvent(event.getDownTime(), event.getEventTime(),
|
event = new KeyEvent(event.getDownTime(), event.getEventTime(),
|
||||||
event.getAction(), event.getKeyCode(), event.getRepeatCount(),
|
event.getAction(), event.getKeyCode(), event.getRepeatCount(),
|
||||||
event.getDeviceId(), event.getScanCode(),
|
event.getDeviceId(), event.getScanCode(),
|
||||||
|
@ -1372,7 +1373,10 @@ public class LatinIME extends InputMethodService
|
||||||
mCapsLock = false;
|
mCapsLock = false;
|
||||||
switcher.setShifted(false);
|
switcher.setShifted(false);
|
||||||
} else if (inputView != null) {
|
} else if (inputView != null) {
|
||||||
switcher.setShifted(!inputView.isShifted());
|
LatinKeyboard latinKeyboard = inputView.getLatinKeyboard();
|
||||||
|
if (latinKeyboard != null) {
|
||||||
|
switcher.setShifted(!latinKeyboard.isShifted());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switcher.toggleShift();
|
switcher.toggleShift();
|
||||||
|
@ -1425,7 +1429,8 @@ public class LatinIME extends InputMethodService
|
||||||
mWord.reset();
|
mWord.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mKeyboardSwitcher.getInputView().isShifted()) {
|
LatinKeyboard latinKeyboard = mKeyboardSwitcher.getInputView().getLatinKeyboard();
|
||||||
|
if (latinKeyboard != null && latinKeyboard.isShifted()) {
|
||||||
if (keyCodes == null || keyCodes[0] < Character.MIN_CODE_POINT
|
if (keyCodes == null || keyCodes[0] < Character.MIN_CODE_POINT
|
||||||
|| keyCodes[0] > Character.MAX_CODE_POINT) {
|
|| keyCodes[0] > Character.MAX_CODE_POINT) {
|
||||||
return;
|
return;
|
||||||
|
@ -1444,7 +1449,7 @@ public class LatinIME extends InputMethodService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mPredicting) {
|
if (mPredicting) {
|
||||||
if (mKeyboardSwitcher.getInputView().isShifted()
|
if (latinKeyboard != null && latinKeyboard.isShifted()
|
||||||
&& mKeyboardSwitcher.isAlphabetMode()
|
&& mKeyboardSwitcher.isAlphabetMode()
|
||||||
&& mComposing.length() == 0) {
|
&& mComposing.length() == 0) {
|
||||||
mWord.setFirstCharCapitalized(true);
|
mWord.setFirstCharCapitalized(true);
|
||||||
|
@ -1739,7 +1744,8 @@ public class LatinIME extends InputMethodService
|
||||||
final List<CharSequence> nBest = new ArrayList<CharSequence>();
|
final List<CharSequence> nBest = new ArrayList<CharSequence>();
|
||||||
boolean capitalizeFirstWord = preferCapitalization()
|
boolean capitalizeFirstWord = preferCapitalization()
|
||||||
|| (mKeyboardSwitcher.isAlphabetMode()
|
|| (mKeyboardSwitcher.isAlphabetMode()
|
||||||
&& mKeyboardSwitcher.getInputView().isShifted());
|
&& mKeyboardSwitcher.getInputView().getLatinKeyboard() != null
|
||||||
|
&& mKeyboardSwitcher.getInputView().getLatinKeyboard().isShifted());
|
||||||
for (String c : mVoiceResults.candidates) {
|
for (String c : mVoiceResults.candidates) {
|
||||||
if (capitalizeFirstWord) {
|
if (capitalizeFirstWord) {
|
||||||
c = Character.toUpperCase(c.charAt(0)) + c.substring(1, c.length());
|
c = Character.toUpperCase(c.charAt(0)) + c.substring(1, c.length());
|
||||||
|
@ -1791,7 +1797,10 @@ public class LatinIME extends InputMethodService
|
||||||
|
|
||||||
private void updateSuggestions() {
|
private void updateSuggestions() {
|
||||||
LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
|
LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
|
||||||
inputView.getLatinKeyboard().setPreferredLetters(null);
|
LatinKeyboard latinKeyboard = inputView.getLatinKeyboard();
|
||||||
|
if (latinKeyboard != null) {
|
||||||
|
latinKeyboard.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 +1822,10 @@ 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();
|
||||||
mKeyboardSwitcher.getInputView().getLatinKeyboard().setPreferredLetters(null);
|
LatinKeyboard latinKeyboard = mKeyboardSwitcher.getInputView().getLatinKeyboard();
|
||||||
|
if (latinKeyboard != null) {
|
||||||
|
latinKeyboard.setPreferredLetters(null);
|
||||||
|
}
|
||||||
showSuggestions(stringList, alternatives.getOriginalWord(), false, false);
|
showSuggestions(stringList, alternatives.getOriginalWord(), false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1829,8 +1841,10 @@ public class LatinIME extends InputMethodService
|
||||||
|
|
||||||
int[] nextLettersFrequencies = mSuggest.getNextLettersFrequencies();
|
int[] nextLettersFrequencies = mSuggest.getNextLettersFrequencies();
|
||||||
|
|
||||||
mKeyboardSwitcher.getInputView().getLatinKeyboard().setPreferredLetters(
|
LatinKeyboard latinKeyboard = mKeyboardSwitcher.getInputView().getLatinKeyboard();
|
||||||
nextLettersFrequencies);
|
if (latinKeyboard != null) {
|
||||||
|
latinKeyboard.setPreferredLetters(nextLettersFrequencies);
|
||||||
|
}
|
||||||
|
|
||||||
boolean correctionAvailable = !mInputTypeNoAutoCorrect && mSuggest.hasMinimalCorrection();
|
boolean correctionAvailable = !mInputTypeNoAutoCorrect && mSuggest.hasMinimalCorrection();
|
||||||
//|| mCorrectionMode == mSuggest.CORRECTION_FULL;
|
//|| mCorrectionMode == mSuggest.CORRECTION_FULL;
|
||||||
|
@ -2002,11 +2016,12 @@ public class LatinIME extends InputMethodService
|
||||||
*/
|
*/
|
||||||
private void pickSuggestion(CharSequence suggestion, boolean correcting) {
|
private void pickSuggestion(CharSequence suggestion, boolean correcting) {
|
||||||
LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
|
LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
|
||||||
|
LatinKeyboard latinKeyboard = inputView.getLatinKeyboard();
|
||||||
if (mCapsLock) {
|
if (mCapsLock) {
|
||||||
suggestion = suggestion.toString().toUpperCase();
|
suggestion = suggestion.toString().toUpperCase();
|
||||||
} else if (preferCapitalization()
|
} else if (preferCapitalization()
|
||||||
|| (mKeyboardSwitcher.isAlphabetMode()
|
|| (mKeyboardSwitcher.isAlphabetMode()
|
||||||
&& inputView.isShifted())) {
|
&& latinKeyboard != null && latinKeyboard.isShifted())) {
|
||||||
suggestion = suggestion.toString().toUpperCase().charAt(0)
|
suggestion = suggestion.toString().toUpperCase().charAt(0)
|
||||||
+ suggestion.subSequence(1, suggestion.length()).toString();
|
+ suggestion.subSequence(1, suggestion.length()).toString();
|
||||||
}
|
}
|
||||||
|
@ -2018,7 +2033,9 @@ public class LatinIME extends InputMethodService
|
||||||
saveWordInHistory(suggestion);
|
saveWordInHistory(suggestion);
|
||||||
mPredicting = false;
|
mPredicting = false;
|
||||||
mCommittedLength = suggestion.length();
|
mCommittedLength = suggestion.length();
|
||||||
inputView.getLatinKeyboard().setPreferredLetters(null);
|
if (latinKeyboard != null) {
|
||||||
|
latinKeyboard.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 +2338,10 @@ 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
|
||||||
mKeyboardSwitcher.getInputView().getLatinKeyboard().keyReleased();
|
LatinKeyboard latinKeyboard = mKeyboardSwitcher.getInputView().getLatinKeyboard();
|
||||||
|
if (latinKeyboard != null) {
|
||||||
|
latinKeyboard.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) {
|
||||||
|
|
|
@ -638,34 +638,6 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
|
||||||
return mHasDistinctMultitouch;
|
return mHasDistinctMultitouch;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the state of the shift key of the keyboard, if any.
|
|
||||||
* @param shifted whether or not to enable the state of the shift key
|
|
||||||
* @return true if the shift key state changed, false if there was no change
|
|
||||||
*/
|
|
||||||
public boolean setShifted(boolean shifted) {
|
|
||||||
if (mKeyboard != null) {
|
|
||||||
if (mKeyboard.setShifted(shifted)) {
|
|
||||||
// The whole keyboard probably needs to be redrawn
|
|
||||||
invalidateAllKeys();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the state of the shift key of the keyboard, if any.
|
|
||||||
* @return true if the shift is in a pressed state, false otherwise. If there is
|
|
||||||
* no shift key on the keyboard or there is no keyboard attached, it returns false.
|
|
||||||
*/
|
|
||||||
public boolean isShifted() {
|
|
||||||
if (mKeyboard != null) {
|
|
||||||
return mKeyboard.isShifted();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables or disables the key feedback popup. This is a popup that shows a magnified
|
* Enables or disables the key feedback popup. This is a popup that shows a magnified
|
||||||
* version of the depressed key. By default the preview is enabled.
|
* version of the depressed key. By default the preview is enabled.
|
||||||
|
@ -1247,7 +1219,12 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
|
||||||
mMiniKeyboardOriginX = adjustedX + container.getPaddingLeft() - mWindowOffset[0];
|
mMiniKeyboardOriginX = adjustedX + container.getPaddingLeft() - mWindowOffset[0];
|
||||||
mMiniKeyboardOriginY = y + container.getPaddingTop() - mWindowOffset[1];
|
mMiniKeyboardOriginY = y + container.getPaddingTop() - mWindowOffset[1];
|
||||||
mMiniKeyboard.setPopupOffset(adjustedX, y);
|
mMiniKeyboard.setPopupOffset(adjustedX, y);
|
||||||
mMiniKeyboard.setShifted(isShifted());
|
// TODO: change the below line to use getLatinKeyboard() instead of getKeyboard()
|
||||||
|
BaseKeyboard baseMiniKeyboard = mMiniKeyboard.getKeyboard();
|
||||||
|
if (baseMiniKeyboard != null && baseMiniKeyboard.setShifted(mKeyboard == null
|
||||||
|
? false : mKeyboard.isShifted())) {
|
||||||
|
mMiniKeyboard.invalidateAllKeys();
|
||||||
|
}
|
||||||
// Mini keyboard needs no pop-up key preview displayed.
|
// Mini keyboard needs no pop-up key preview displayed.
|
||||||
mMiniKeyboard.setPreviewEnabled(false);
|
mMiniKeyboard.setPreviewEnabled(false);
|
||||||
mMiniKeyboardPopup.setContentView(container);
|
mMiniKeyboardPopup.setContentView(container);
|
||||||
|
|
Loading…
Reference in New Issue