-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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: add support for TextInputType.none #26585
Android: add support for TextInputType.none #26585
Conversation
TextInputType.none makes it possible to disable the virtual keyboard for certain TextFields, and lays the foundations for custom in-app virtual keyboards (flutter/flutter#76072). Ref: flutter/flutter#83567
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
Minimal example: https://github.com/jpnurmi/text_input_type_none_example (requires flutter/flutter#83974 for the enum value) 21-06-04-09-03-26.mp4 |
Is there any reasonable way to test this? |
shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java
Outdated
Show resolved
Hide resolved
cbae154
to
876274d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add tests to verify this works? E.g., when the type is "none" the flutter view returns null for createInputConnection
.
8918312
to
9afec70
Compare
This needs to be rebased on ToT so that presubmits will pass after an infra failure. @LongCatIsLooong you comments looks like they have been addressed. Another review pass please? |
* b035192 Roll Dart SDK from e6e47f919791 to 59f9594aed9a (1 revision) (flutter/engine#27032) * 9e69740 [refactor] Migrate to View.focus.*. (flutter/engine#27005) * 9928f4f Android: add support for TextInputType.none (flutter/engine#26585) * c03f144 [iOS TextInput] Disables system keyboard for TextInputType.none (flutter/engine#26979) * 2384128 Roll Skia from 1df8756419ee to 4716a7681e4a (7 revisions) (flutter/engine#27035)
…49980) ## Description This PR fixes an issue where keystrokes aren't received on Android devices with physical keyboards (e.g. rugged Zebra devices) when `keyboardType` is set to `TextInputType.none` on a `TextField`. The logic in `setTextInputClient` and `canShowTextInput` created an `inputTarget` with `InputTarget.Type.NO_TARGET` which caused the [input connection to short circuit](https://github.com/flutter/engine/blob/main/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java#L296) and not be established. Bug introduction PR: #26585 ## Related Issue flutter/flutter#89983 ## Unit Test Notes - The existing `showTextInput_textInputTypeNone()` stays green after update. - `inputConnection_textInputTypeNone()` updated to `assertNotNull`. I would make this more specific, but this is my first venture into the Flutter engine and don't know enough about those connection attributes. ## Demo Video below with Zebra MC9300 device. This issue can also be reproduced in a standard android emulator. Simply add a `TextField`, configure `keyboardType` to be `TextInputType.none` and attempt to enter text after running and giving focus to textfield. Before https://github.com/flutter/engine/assets/1988098/348ca061-b8b9-4483-956e-0732c1238207 After https://github.com/flutter/engine/assets/1988098/b65c7251-59b4-4c73-9b85-7ac03f47a7e4 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [x] I listed at least one issue that this PR fixes in the description above. - [ ] I added new tests to check the change I am making or feature I am adding, or the PR is [test-exempt]. See [testing the engine] for instructions on writing and running engine tests. - [ ] I updated/added relevant documentation (doc comments with `///`). - [x] I signed the [CLA]. - [x] All existing and new tests are passing.
TextInputType.none
makes it possible to disable the virtual keyboard for certain TextFields, and lays the foundations for custom in-app virtual keyboards (flutter/flutter#76072).Ref: flutter/flutter#83567
Pre-launch Checklist
writing and running engine tests.
///
).