mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-17 23:42:55 +00:00
attempt to fix issue in https://github.com/Helium314/openboard/issues/99#issuecomment-1722394199
and some formatting
This commit is contained in:
parent
67c328ec1f
commit
c4781e3da0
2 changed files with 23 additions and 28 deletions
|
@ -1009,8 +1009,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
// span, so we should reset our state unconditionally, even if restarting is true.
|
// span, so we should reset our state unconditionally, even if restarting is true.
|
||||||
// We also tell the input logic about the combining rules for the current subtype, so
|
// We also tell the input logic about the combining rules for the current subtype, so
|
||||||
// it can adjust its combiners if needed.
|
// it can adjust its combiners if needed.
|
||||||
mInputLogic.startInput(mRichImm.getCombiningRulesExtraValueOfCurrentSubtype(),
|
mInputLogic.startInput(mRichImm.getCombiningRulesExtraValueOfCurrentSubtype(), currentSettingsValues);
|
||||||
currentSettingsValues);
|
|
||||||
|
|
||||||
resetDictionaryFacilitatorIfNecessary();
|
resetDictionaryFacilitatorIfNecessary();
|
||||||
|
|
||||||
|
@ -1048,11 +1047,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
currentSettingsValues = mSettings.getCurrent();
|
currentSettingsValues = mSettings.getCurrent();
|
||||||
|
|
||||||
if (currentSettingsValues.mAutoCorrectionEnabledPerUserSettings) {
|
if (currentSettingsValues.mAutoCorrectionEnabledPerUserSettings) {
|
||||||
suggest.setAutoCorrectionThreshold(
|
suggest.setAutoCorrectionThreshold(currentSettingsValues.mAutoCorrectionThreshold);
|
||||||
currentSettingsValues.mAutoCorrectionThreshold);
|
|
||||||
}
|
}
|
||||||
switcher.loadKeyboard(editorInfo, currentSettingsValues, getCurrentAutoCapsState(),
|
switcher.loadKeyboard(editorInfo, currentSettingsValues, getCurrentAutoCapsState(), getCurrentRecapitalizeState());
|
||||||
getCurrentRecapitalizeState());
|
|
||||||
if (needToCallLoadKeyboardLater) {
|
if (needToCallLoadKeyboardLater) {
|
||||||
// If we need to call loadKeyboard again later, we need to save its state now. The
|
// If we need to call loadKeyboard again later, we need to save its state now. The
|
||||||
// later call will be done in #retryResetCaches.
|
// later call will be done in #retryResetCaches.
|
||||||
|
@ -1061,14 +1058,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
} else if (restarting) {
|
} else if (restarting) {
|
||||||
// TODO: Come up with a more comprehensive way to reset the keyboard layout when
|
// TODO: Come up with a more comprehensive way to reset the keyboard layout when
|
||||||
// a keyboard layout set doesn't get reloaded in this method.
|
// a keyboard layout set doesn't get reloaded in this method.
|
||||||
switcher.resetKeyboardStateToAlphabet(getCurrentAutoCapsState(),
|
switcher.resetKeyboardStateToAlphabet(getCurrentAutoCapsState(), getCurrentRecapitalizeState());
|
||||||
getCurrentRecapitalizeState());
|
|
||||||
// In apps like Talk, we come here when the text is sent and the field gets emptied and
|
// In apps like Talk, we come here when the text is sent and the field gets emptied and
|
||||||
// we need to re-evaluate the shift state, but not the whole layout which would be
|
// we need to re-evaluate the shift state, but not the whole layout which would be
|
||||||
// disruptive.
|
// disruptive.
|
||||||
// Space state must be updated before calling updateShiftState
|
// Space state must be updated before calling updateShiftState
|
||||||
switcher.requestUpdatingShiftState(getCurrentAutoCapsState(),
|
switcher.requestUpdatingShiftState(getCurrentAutoCapsState(), getCurrentRecapitalizeState());
|
||||||
getCurrentRecapitalizeState());
|
|
||||||
}
|
}
|
||||||
// This will set the punctuation suggestions if next word suggestion is off;
|
// This will set the punctuation suggestions if next word suggestion is off;
|
||||||
// otherwise it will clear the suggestion strip.
|
// otherwise it will clear the suggestion strip.
|
||||||
|
@ -1076,11 +1071,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
|
|
||||||
mHandler.cancelUpdateSuggestionStrip();
|
mHandler.cancelUpdateSuggestionStrip();
|
||||||
|
|
||||||
mainKeyboardView.setMainDictionaryAvailability(
|
mainKeyboardView.setMainDictionaryAvailability(mDictionaryFacilitator.hasAtLeastOneInitializedMainDictionary());
|
||||||
mDictionaryFacilitator.hasAtLeastOneInitializedMainDictionary());
|
|
||||||
mainKeyboardView.setKeyPreviewPopupEnabled(currentSettingsValues.mKeyPreviewPopupOn);
|
mainKeyboardView.setKeyPreviewPopupEnabled(currentSettingsValues.mKeyPreviewPopupOn);
|
||||||
mainKeyboardView.setSlidingKeyInputPreviewEnabled(
|
mainKeyboardView.setSlidingKeyInputPreviewEnabled(currentSettingsValues.mSlidingKeyInputPreviewEnabled);
|
||||||
currentSettingsValues.mSlidingKeyInputPreviewEnabled);
|
|
||||||
mainKeyboardView.setGestureHandlingEnabledByUser(
|
mainKeyboardView.setGestureHandlingEnabledByUser(
|
||||||
currentSettingsValues.mGestureInputEnabled,
|
currentSettingsValues.mGestureInputEnabled,
|
||||||
currentSettingsValues.mGestureTrailEnabled,
|
currentSettingsValues.mGestureTrailEnabled,
|
||||||
|
|
|
@ -148,8 +148,7 @@ public final class InputLogic {
|
||||||
// For messaging apps that offer send button, the IME does not get the opportunity
|
// For messaging apps that offer send button, the IME does not get the opportunity
|
||||||
// to capture the last word. This block should capture those uncommitted words.
|
// to capture the last word. This block should capture those uncommitted words.
|
||||||
// The timestamp at which it is captured is not accurate but close enough.
|
// The timestamp at which it is captured is not accurate but close enough.
|
||||||
StatsUtils.onWordCommitUserTyped(
|
StatsUtils.onWordCommitUserTyped(mWordComposer.getTypedWord(), mWordComposer.isBatchMode());
|
||||||
mWordComposer.getTypedWord(), mWordComposer.isBatchMode());
|
|
||||||
}
|
}
|
||||||
mWordComposer.restartCombining(combiningSpec);
|
mWordComposer.restartCombining(combiningSpec);
|
||||||
resetComposingState(true /* alsoResetLastComposedWord */);
|
resetComposingState(true /* alsoResetLastComposedWord */);
|
||||||
|
@ -169,8 +168,7 @@ public final class InputLogic {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settingsValues.mShouldShowLxxSuggestionUi) {
|
if (settingsValues.mShouldShowLxxSuggestionUi) {
|
||||||
mConnection.requestCursorUpdates(true /* enableMonitor */,
|
mConnection.requestCursorUpdates(true, true);
|
||||||
true /* requestImmediateCallback */);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1579,11 +1577,12 @@ public final class InputLogic {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final int expectedCursorPosition = mConnection.getExpectedSelectionStart();
|
final int expectedCursorPosition = mConnection.getExpectedSelectionStart();
|
||||||
if (!mConnection.isCursorTouchingWord(settingsValues.mSpacingAndPunctuations,
|
if (!mConnection.isCursorTouchingWord(settingsValues.mSpacingAndPunctuations, true /* checkTextAfter */)) {
|
||||||
true /* checkTextAfter */)) {
|
|
||||||
// Show predictions.
|
// Show predictions.
|
||||||
mWordComposer.setCapitalizedModeAtStartComposingTime(WordComposer.CAPS_MODE_OFF);
|
mWordComposer.setCapitalizedModeAtStartComposingTime(WordComposer.CAPS_MODE_OFF);
|
||||||
mLatinIME.mHandler.postUpdateSuggestionStrip(SuggestedWords.INPUT_STYLE_RECORRECTION);
|
mLatinIME.mHandler.postUpdateSuggestionStrip(SuggestedWords.INPUT_STYLE_RECORRECTION);
|
||||||
|
// "unselect" the previous text
|
||||||
|
mConnection.finishComposingText();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final TextRange range = mConnection.getWordRangeAtCursor(
|
final TextRange range = mConnection.getWordRangeAtCursor(
|
||||||
|
@ -1596,10 +1595,17 @@ public final class InputLogic {
|
||||||
}
|
}
|
||||||
// If for some strange reason (editor bug or so) we measure the text before the cursor as
|
// If for some strange reason (editor bug or so) we measure the text before the cursor as
|
||||||
// longer than what the entire text is supposed to be, the safe thing to do is bail out.
|
// longer than what the entire text is supposed to be, the safe thing to do is bail out.
|
||||||
if (range.mHasUrlSpans) return; // If there are links, we don't resume suggestions. Making
|
if (range.mHasUrlSpans) return;
|
||||||
|
// If there are links, we don't resume suggestions. Making
|
||||||
// edits to a linkified text through batch commands would ruin the URL spans, and unless
|
// edits to a linkified text through batch commands would ruin the URL spans, and unless
|
||||||
// we take very complicated steps to preserve the whole link, we can't do things right so
|
// we take very complicated steps to preserve the whole link, we can't do things right so
|
||||||
// we just do not resume because it's safer.
|
// we just do not resume because it's safer.
|
||||||
|
if (!isResumableWord(settingsValues, range.mWord.toString())) {
|
||||||
|
mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
|
||||||
|
// "unselect" the previous text
|
||||||
|
mConnection.finishComposingText();
|
||||||
|
return;
|
||||||
|
}
|
||||||
final int numberOfCharsInWordBeforeCursor = range.getNumberOfCharsInWordBeforeCursor();
|
final int numberOfCharsInWordBeforeCursor = range.getNumberOfCharsInWordBeforeCursor();
|
||||||
if (numberOfCharsInWordBeforeCursor > expectedCursorPosition) return;
|
if (numberOfCharsInWordBeforeCursor > expectedCursorPosition) return;
|
||||||
final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<>();
|
final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<>();
|
||||||
|
@ -1610,10 +1616,6 @@ public final class InputLogic {
|
||||||
SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */,
|
SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */,
|
||||||
SuggestedWordInfo.NOT_A_CONFIDENCE /* autoCommitFirstWordConfidence */);
|
SuggestedWordInfo.NOT_A_CONFIDENCE /* autoCommitFirstWordConfidence */);
|
||||||
suggestions.add(typedWordInfo);
|
suggestions.add(typedWordInfo);
|
||||||
if (!isResumableWord(settingsValues, typedWordString)) {
|
|
||||||
mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (final SuggestionSpan span : range.getSuggestionSpansAtWord()) {
|
for (final SuggestionSpan span : range.getSuggestionSpansAtWord()) {
|
||||||
for (final String s : span.getSuggestions()) {
|
for (final String s : span.getSuggestions()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue