Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Read-only Multi-line text input displays suggestions (Spell Checking) #2136

Closed
Aarontheissueguy opened this issue Sep 26, 2023 · 1 comment · Fixed by #2139
Closed
Labels
android The issue relates to Android mobile support. bug A crash or error in behavior.

Comments

@Aarontheissueguy
Copy link
Contributor

Describe the bug

When using the "MultilineTextInput" with the "readonly" parameter set to "True" on Android, it will suggest spelling improvements based on dictionary candidates. This behavior results in underlined text on android devices when using a language other than the keyboard language or with unknown words in general.

Steps to reproduce

  1. Use MultilineTextInput in readonly with a set text
  2. Compile for android and set the KeyBoard language to a different one than the text.
  3. The suggestions should appear, underlining the Text.

Expected behavior

Suggestions do not show up in MultilineTextInput if set to readonly.

Screenshots

No response

Environment

  • Operating System: Fedora 38 Workstation / Lineage OS 20.0
  • Python version: 3.11.5
  • Software versions:
    • Briefcase: 0.3.15
    • Toga: 0.3.1

[tool.briefcase.app.trinker.android]
requires = [
#"toga-android~=0.3.1"
'git+https://github.com/beeware/toga.git#subdirectory=core',
'git+https://github.com/beeware/toga.git#subdirectory=android',
]

Logs


Additional context

I did some research on the topic and while I'm not really an Android dev, I think I found the problem. In "android/src/toga_android/widgets/textinput.py" we need to set the flag TYPE_TEXT_FLAG_NO_SUGGESTIONS if "readonly" is true.

As said before, I'm not really an Android dev and am not sure how this would be implemented.

@Aarontheissueguy Aarontheissueguy added the bug A crash or error in behavior. label Sep 26, 2023
@freakboy3742 freakboy3742 added the android The issue relates to Android mobile support. label Sep 26, 2023
@freakboy3742
Copy link
Member

For anyone interested in tackling this: TYPE_TEXT_FLAG_NO_SUGGESTIONS is a constant on the same interface as TYPE_CLASS_TEXT, the InputType that the Android TextInput already uses (see the create() method). Add a call to add/remove the no-suggestions constant as part of the set_readonly() implementation, and add validation that the property has been set in the test backend probe, and you're done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android The issue relates to Android mobile support. bug A crash or error in behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants