mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
[SD3] Forward the script ID to where it will be used
Bug: 15840116 Change-Id: If2073e76fed74ae6e1cdd7670013e0e985b0e630
This commit is contained in:
parent
aca2ef85e1
commit
35c37dbef8
@ -211,6 +211,10 @@ public final class KeyboardLayoutSet {
|
||||
return keyboard;
|
||||
}
|
||||
|
||||
public int getScriptId() {
|
||||
return mParams.mScriptId;
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
private final Context mContext;
|
||||
private final String mPackageName;
|
||||
|
@ -370,4 +370,8 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||
return WordComposer.CAPS_MODE_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
public int getCurrentKeyboardScriptId() {
|
||||
return mKeyboardLayoutSet.getScriptId();
|
||||
}
|
||||
}
|
||||
|
@ -227,7 +227,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||
case MSG_RESUME_SUGGESTIONS:
|
||||
latinIme.mInputLogic.restartSuggestionsOnWordTouchedByCursor(
|
||||
latinIme.mSettings.getCurrent(),
|
||||
msg.arg1 == ARG1_TRUE /* shouldIncludeResumedWordInSuggestions */);
|
||||
msg.arg1 == ARG1_TRUE /* shouldIncludeResumedWordInSuggestions */,
|
||||
latinIme.mKeyboardSwitcher.getCurrentKeyboardScriptId());
|
||||
break;
|
||||
case MSG_REOPEN_DICTIONARIES:
|
||||
latinIme.resetSuggest();
|
||||
@ -1239,7 +1240,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||
final Event event = createSoftwareKeypressEvent(codeToSend, keyX, keyY, isKeyRepeat);
|
||||
final InputTransaction completeInputTransaction =
|
||||
mInputLogic.onCodeInput(mSettings.getCurrent(), event,
|
||||
mKeyboardSwitcher.getKeyboardShiftMode(), mHandler);
|
||||
mKeyboardSwitcher.getKeyboardShiftMode(),
|
||||
mKeyboardSwitcher.getCurrentKeyboardScriptId(), mHandler);
|
||||
updateStateAfterInputTransaction(completeInputTransaction);
|
||||
mKeyboardSwitcher.onCodeInput(codePoint, getCurrentAutoCapsState(),
|
||||
getCurrentRecapitalizeState());
|
||||
@ -1423,10 +1425,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||
// Called from {@link SuggestionStripView} through the {@link SuggestionStripView#Listener}
|
||||
// interface
|
||||
@Override
|
||||
public void pickSuggestionManually(final int index, final SuggestedWordInfo suggestionInfo) {
|
||||
public void pickSuggestionManually(final SuggestedWordInfo suggestionInfo) {
|
||||
final InputTransaction completeInputTransaction = mInputLogic.onPickSuggestionManually(
|
||||
mSettings.getCurrent(), index, suggestionInfo,
|
||||
mKeyboardSwitcher.getKeyboardShiftMode(), mHandler);
|
||||
mSettings.getCurrent(), suggestionInfo,
|
||||
mKeyboardSwitcher.getKeyboardShiftMode(),
|
||||
mKeyboardSwitcher.getCurrentKeyboardScriptId(),
|
||||
mHandler);
|
||||
updateStateAfterInputTransaction(completeInputTransaction);
|
||||
}
|
||||
|
||||
@ -1553,7 +1557,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||
// If it's handled, we return true because we did handle it.
|
||||
if (event.isHandled()) {
|
||||
mInputLogic.onCodeInput(mSettings.getCurrent(), event,
|
||||
mKeyboardSwitcher.getKeyboardShiftMode(), mHandler);
|
||||
mKeyboardSwitcher.getKeyboardShiftMode(),
|
||||
// TODO: this is not necessarily correct for a hardware keyboard right now
|
||||
mKeyboardSwitcher.getCurrentKeyboardScriptId(),
|
||||
mHandler);
|
||||
return true;
|
||||
}
|
||||
return super.onKeyDown(keyCode, keyEvent);
|
||||
|
@ -213,7 +213,6 @@ public final class InputLogic {
|
||||
/**
|
||||
* A suggestion was picked from the suggestion strip.
|
||||
* @param settingsValues the current values of the settings.
|
||||
* @param index the index of the suggestion.
|
||||
* @param suggestionInfo the suggestion info.
|
||||
* @param keyboardShiftState the shift state of the keyboard, as returned by
|
||||
* {@link com.android.inputmethod.keyboard.KeyboardSwitcher#getKeyboardShiftMode()}
|
||||
@ -222,9 +221,9 @@ public final class InputLogic {
|
||||
// Called from {@link SuggestionStripView} through the {@link SuggestionStripView#Listener}
|
||||
// interface
|
||||
public InputTransaction onPickSuggestionManually(final SettingsValues settingsValues,
|
||||
final int index, final SuggestedWordInfo suggestionInfo, final int keyboardShiftState,
|
||||
// TODO: remove this argument
|
||||
final LatinIME.UIHandler handler) {
|
||||
final SuggestedWordInfo suggestionInfo, final int keyboardShiftState,
|
||||
// TODO: remove these arguments
|
||||
final int currentKeyboardScriptId, final LatinIME.UIHandler handler) {
|
||||
final SuggestedWords suggestedWords = mSuggestedWords;
|
||||
final String suggestion = suggestionInfo.mWord;
|
||||
// If this is a punctuation picked from the suggestion strip, pass it to onCodeInput
|
||||
@ -232,7 +231,8 @@ public final class InputLogic {
|
||||
// Word separators are suggested before the user inputs something.
|
||||
// Rely on onCodeInput to do the complicated swapping/stripping logic consistently.
|
||||
final Event event = Event.createPunctuationSuggestionPickedEvent(suggestionInfo);
|
||||
return onCodeInput(settingsValues, event, keyboardShiftState, handler);
|
||||
return onCodeInput(settingsValues, event, keyboardShiftState,
|
||||
currentKeyboardScriptId, handler);
|
||||
}
|
||||
|
||||
final Event event = Event.createSuggestionPickedEvent(suggestionInfo);
|
||||
@ -378,8 +378,8 @@ public final class InputLogic {
|
||||
*/
|
||||
public InputTransaction onCodeInput(final SettingsValues settingsValues, final Event event,
|
||||
final int keyboardShiftMode,
|
||||
// TODO: remove this argument
|
||||
final LatinIME.UIHandler handler) {
|
||||
// TODO: remove these arguments
|
||||
final int currentKeyboardScriptId, final LatinIME.UIHandler handler) {
|
||||
final InputTransaction inputTransaction = new InputTransaction(settingsValues, event,
|
||||
SystemClock.uptimeMillis(), mSpaceState,
|
||||
getActualCapsMode(settingsValues, keyboardShiftMode));
|
||||
@ -403,7 +403,7 @@ public final class InputLogic {
|
||||
// A special key, like delete, shift, emoji, or the settings key.
|
||||
switch (event.mKeyCode) {
|
||||
case Constants.CODE_DELETE:
|
||||
handleBackspace(inputTransaction);
|
||||
handleBackspace(inputTransaction, currentKeyboardScriptId);
|
||||
break;
|
||||
case Constants.CODE_SHIFT:
|
||||
performRecapitalization(inputTransaction.mSettingsValues);
|
||||
@ -857,7 +857,9 @@ public final class InputLogic {
|
||||
* Handle a press on the backspace key.
|
||||
* @param inputTransaction The transaction in progress.
|
||||
*/
|
||||
private void handleBackspace(final InputTransaction inputTransaction) {
|
||||
private void handleBackspace(final InputTransaction inputTransaction,
|
||||
// TODO: remove this argument, put it into settingsValues
|
||||
final int currentKeyboardScriptId) {
|
||||
mSpaceState = SpaceState.NONE;
|
||||
mDeleteCount++;
|
||||
|
||||
@ -991,7 +993,7 @@ public final class InputLogic {
|
||||
&& !mConnection.isCursorFollowedByWordCharacter(
|
||||
inputTransaction.mSettingsValues.mSpacingAndPunctuations)) {
|
||||
restartSuggestionsOnWordTouchedByCursor(inputTransaction.mSettingsValues,
|
||||
true /* shouldIncludeResumedWordInSuggestions */);
|
||||
true /* shouldIncludeResumedWordInSuggestions */, currentKeyboardScriptId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1244,7 +1246,9 @@ public final class InputLogic {
|
||||
*/
|
||||
// TODO: make this private.
|
||||
public void restartSuggestionsOnWordTouchedByCursor(final SettingsValues settingsValues,
|
||||
final boolean shouldIncludeResumedWordInSuggestions) {
|
||||
final boolean shouldIncludeResumedWordInSuggestions,
|
||||
// TODO: remove this argument, put it into settingsValues
|
||||
final int currentKeyboardScriptId) {
|
||||
// HACK: We may want to special-case some apps that exhibit bad behavior in case of
|
||||
// recorrection. This is a temporary, stopgap measure that will be removed later.
|
||||
// TODO: remove this.
|
||||
|
@ -37,7 +37,7 @@ public final class MoreSuggestionsView extends MoreKeysKeyboardView {
|
||||
private static final String TAG = MoreSuggestionsView.class.getSimpleName();
|
||||
|
||||
public static abstract class MoreSuggestionsListener extends KeyboardActionListener.Adapter {
|
||||
public abstract void onSuggestionSelected(final int index, final SuggestedWordInfo info);
|
||||
public abstract void onSuggestionSelected(final SuggestedWordInfo info);
|
||||
}
|
||||
|
||||
public MoreSuggestionsView(final Context context, final AttributeSet attrs) {
|
||||
@ -104,7 +104,6 @@ public final class MoreSuggestionsView extends MoreKeysKeyboardView {
|
||||
+ mListener.getClass().getName());
|
||||
return;
|
||||
}
|
||||
((MoreSuggestionsListener)mListener).onSuggestionSelected(
|
||||
index, suggestedWords.getInfo(index));
|
||||
((MoreSuggestionsListener)mListener).onSuggestionSelected(suggestedWords.getInfo(index));
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||
public interface Listener {
|
||||
public void addWordToUserDictionary(String word);
|
||||
public void showImportantNoticeContents();
|
||||
public void pickSuggestionManually(int index, SuggestedWordInfo word);
|
||||
public void pickSuggestionManually(SuggestedWordInfo word);
|
||||
public void onCodeInput(int primaryCode, int x, int y, boolean isKeyRepeat);
|
||||
}
|
||||
|
||||
@ -286,8 +286,8 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||
|
||||
private final MoreSuggestionsListener mMoreSuggestionsListener = new MoreSuggestionsListener() {
|
||||
@Override
|
||||
public void onSuggestionSelected(final int index, final SuggestedWordInfo wordInfo) {
|
||||
mListener.pickSuggestionManually(index, wordInfo);
|
||||
public void onSuggestionSelected(final SuggestedWordInfo wordInfo) {
|
||||
mListener.pickSuggestionManually(wordInfo);
|
||||
dismissMoreSuggestionsPanel();
|
||||
}
|
||||
|
||||
@ -465,7 +465,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||
return;
|
||||
}
|
||||
final SuggestedWordInfo wordInfo = mSuggestedWords.getInfo(index);
|
||||
mListener.pickSuggestionManually(index, wordInfo);
|
||||
mListener.pickSuggestionManually(wordInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user