mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-26 17:47:27 +00:00
Reduce amount of unwanted automatic space insertions
This commit is contained in:
parent
cfa27dbb7f
commit
7b743db65a
4 changed files with 28 additions and 2 deletions
|
@ -13,7 +13,7 @@ Plan / to do:
|
||||||
* ~make additional dictionaries available for download (from OpenBoard PRs)~
|
* ~make additional dictionaries available for download (from OpenBoard PRs)~
|
||||||
* multi-lingual typing, https://github.com/openboard-team/openboard/pull/593
|
* multi-lingual typing, https://github.com/openboard-team/openboard/pull/593
|
||||||
* ~suggestion fixes, https://github.com/openboard-team/openboard/pull/694, https://github.com/openboard-team/openboard/issues/795, https://github.com/openboard-team/openboard/issues/660~
|
* ~suggestion fixes, https://github.com/openboard-team/openboard/pull/694, https://github.com/openboard-team/openboard/issues/795, https://github.com/openboard-team/openboard/issues/660~
|
||||||
* improve auto-space insertion, https://github.com/openboard-team/openboard/pull/576
|
* ~improve auto-space insertion, https://github.com/openboard-team/openboard/pull/576~
|
||||||
* emoji prediction/search, either https://github.com/openboard-team/openboard/pull/749 or use dictionaries
|
* emoji prediction/search, either https://github.com/openboard-team/openboard/pull/749 or use dictionaries
|
||||||
* theming, https://github.com/openboard-team/openboard/issues/124
|
* theming, https://github.com/openboard-team/openboard/issues/124
|
||||||
* delete suggestions, https://github.com/openboard-team/openboard/issues/106
|
* delete suggestions, https://github.com/openboard-team/openboard/issues/106
|
||||||
|
@ -32,6 +32,7 @@ Changes:
|
||||||
* add Galician dictionary for download, from https://github.com/chavaone/openboard/blob/master/dictionaries/es_GL_wordlist.combined.gz / https://github.com/openboard-team/openboard/pull/291
|
* add Galician dictionary for download, from https://github.com/chavaone/openboard/blob/master/dictionaries/es_GL_wordlist.combined.gz / https://github.com/openboard-team/openboard/pull/291
|
||||||
* fix suggestions after some characters, https://github.com/openboard-team/openboard/pull/694, https://github.com/openboard-team/openboard/issues/795
|
* fix suggestions after some characters, https://github.com/openboard-team/openboard/pull/694, https://github.com/openboard-team/openboard/issues/795
|
||||||
* fix suggestions sometimes not being shown, https://github.com/openboard-team/openboard/pull/709
|
* fix suggestions sometimes not being shown, https://github.com/openboard-team/openboard/pull/709
|
||||||
|
* Reduce amount of unwanted automatic space insertions, https://github.com/openboard-team/openboard/pull/576
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|
|
@ -896,6 +896,14 @@ public final class RichInputConnection implements PrivateCommandPerformer {
|
||||||
return StringUtils.lastPartLooksLikeURL(mCommittedTextBeforeComposingText);
|
return StringUtils.lastPartLooksLikeURL(mCommittedTextBeforeComposingText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean spaceBeforeCursor() {
|
||||||
|
return mCommittedTextBeforeComposingText.indexOf(" ") != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean wordBeforeCursorMayBeEmail() {
|
||||||
|
return mCommittedTextBeforeComposingText.lastIndexOf(" ") < mCommittedTextBeforeComposingText.lastIndexOf("@");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks at the text just before the cursor to find out if we are inside a double quote.
|
* Looks at the text just before the cursor to find out if we are inside a double quote.
|
||||||
*
|
*
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.dslul.openboard.inputmethod.latin.inputlogic;
|
||||||
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
import android.text.InputType;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
@ -2045,11 +2046,26 @@ public final class InputLogic {
|
||||||
private void insertAutomaticSpaceIfOptionsAndTextAllow(final SettingsValues settingsValues) {
|
private void insertAutomaticSpaceIfOptionsAndTextAllow(final SettingsValues settingsValues) {
|
||||||
if (settingsValues.shouldInsertSpacesAutomatically()
|
if (settingsValues.shouldInsertSpacesAutomatically()
|
||||||
&& settingsValues.mSpacingAndPunctuations.mCurrentLanguageHasSpaces
|
&& settingsValues.mSpacingAndPunctuations.mCurrentLanguageHasSpaces
|
||||||
&& !mConnection.textBeforeCursorLooksLikeURL()) {
|
&& !textBeforeCursorMayBeURL()
|
||||||
|
&& !(mConnection.getCodePointBeforeCursor() == Constants.CODE_PERIOD && mConnection.wordBeforeCursorMayBeEmail())) {
|
||||||
sendKeyCodePoint(settingsValues, Constants.CODE_SPACE);
|
sendKeyCodePoint(settingsValues, Constants.CODE_SPACE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean textBeforeCursorMayBeURL() {
|
||||||
|
if (mConnection.textBeforeCursorLooksLikeURL()) return true;
|
||||||
|
// doesn't look like URL, but we may be in URL field and user may want to enter example.com
|
||||||
|
if (mConnection.getCodePointBeforeCursor() != Constants.CODE_PERIOD && mConnection.getCodePointBeforeCursor() != ':')
|
||||||
|
return false;
|
||||||
|
final EditorInfo ei = getCurrentInputEditorInfo();
|
||||||
|
if (ei == null) return false;
|
||||||
|
int inputType = ei.inputType;
|
||||||
|
if ((inputType & InputType.TYPE_TEXT_VARIATION_URI) != 0)
|
||||||
|
return !mConnection.spaceBeforeCursor();
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do the final processing after a batch input has ended. This commits the word to the editor.
|
* Do the final processing after a batch input has ended. This commits the word to the editor.
|
||||||
* @param settingsValues the current values of the settings.
|
* @param settingsValues the current values of the settings.
|
||||||
|
|
|
@ -31,6 +31,7 @@ public final class InputTypeUtils implements InputType {
|
||||||
private static final int TEXT_VISIBLE_PASSWORD_INPUT_TYPE =
|
private static final int TEXT_VISIBLE_PASSWORD_INPUT_TYPE =
|
||||||
TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
|
TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
|
||||||
private static final int[] SUPPRESSING_AUTO_SPACES_FIELD_VARIATION = {
|
private static final int[] SUPPRESSING_AUTO_SPACES_FIELD_VARIATION = {
|
||||||
|
InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS,
|
||||||
InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS,
|
InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS,
|
||||||
InputType.TYPE_TEXT_VARIATION_PASSWORD,
|
InputType.TYPE_TEXT_VARIATION_PASSWORD,
|
||||||
InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD,
|
InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD,
|
||||||
|
|
Loading…
Add table
Reference in a new issue