mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-25 09:06:22 +00:00
fix urls field being detected when it shouldn't
This commit is contained in:
parent
0c8cd42a03
commit
2be6eaa10d
2 changed files with 12 additions and 1 deletions
|
@ -2119,7 +2119,9 @@ public final class InputLogic {
|
|||
private boolean textBeforeCursorMayBeUrlOrSimilar(final SettingsValues settingsValues) {
|
||||
final EditorInfo ei = getCurrentInputEditorInfo();
|
||||
// URL field and no space -> may be URL
|
||||
if (ei != null && (ei.inputType & InputType.TYPE_TEXT_VARIATION_URI) != 0 && !mConnection.spaceBeforeCursor())
|
||||
// for whatever absurd reason long message, postal address and email subject have type values that return true when filtering for URI, see https://developer.android.com/reference/android/text/InputType
|
||||
// so we really need to specifically require URI as only type variation
|
||||
if (ei != null && (ei.inputType & 0x000000f0) == 0x00000010 && !mConnection.spaceBeforeCursor())
|
||||
return true;
|
||||
// already contains a SometimesWordConnector -> may be URL (not so sure, only do with detection enabled
|
||||
if (settingsValues.mUrlDetectionEnabled && settingsValues.mSpacingAndPunctuations.containsSometimesWordConnector(mWordComposer.getTypedWord()))
|
||||
|
|
|
@ -416,6 +416,15 @@ class InputLogicTest {
|
|||
assertEquals("bla.com/img.jpg", composingText)
|
||||
}
|
||||
|
||||
@Test fun `don't accidentally detect some other text fields as URI`() {
|
||||
// see comment in InputLogic.textBeforeCursorMayBeUrlOrSimilar
|
||||
reset()
|
||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
||||
setInputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE)
|
||||
chainInput("Hey,why")
|
||||
assertEquals("Hey, why", text)
|
||||
}
|
||||
|
||||
// ------- helper functions ---------
|
||||
|
||||
// should be called before every test, so the same state is guaranteed
|
||||
|
|
Loading…
Add table
Reference in a new issue