[go: nahoru, domu]

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: add support for TextInputType.none #26585

Merged
merged 8 commits into from
Jun 29, 2021

Conversation

jpnurmi
Copy link
Member
@jpnurmi jpnurmi commented Jun 4, 2021

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

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • 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 Hixie said 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 ///).
  • I signed the CLA.
  • All existing and new tests are passing.
  • The reviewer has submitted any presubmit flakes in this PR using the engine presubmit flakes form before re-triggering the failure.

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
@flutter-dashboard
Copy link

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.

@google-cla google-cla bot added the cla: yes label Jun 4, 2021
@jpnurmi jpnurmi mentioned this pull request Jun 4, 2021
14 tasks
@jpnurmi
Copy link
Member Author
jpnurmi commented Jun 4, 2021

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

@jpnurmi
Copy link
Member Author
jpnurmi commented Jun 4, 2021

Is there any reasonable way to test this?

Copy link
Contributor
@LongCatIsLooong LongCatIsLooong left a 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.

@chinmaygarde
Copy link
Member

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?

@LongCatIsLooong LongCatIsLooong added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Jun 29, 2021
@fluttergithubbot fluttergithubbot merged commit 9928f4f into flutter:master Jun 29, 2021
@jpnurmi jpnurmi deleted the android-text-input-type branch June 29, 2021 16:54
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 29, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 29, 2021
zanderso pushed a commit to flutter/flutter that referenced this pull request Jun 29, 2021
* 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)
moffatman pushed a commit to moffatman/engine that referenced this pull request Aug 5, 2021
naudzghebre pushed a commit to naudzghebre/engine that referenced this pull request Sep 2, 2021
johnmccutchan pushed a commit that referenced this pull request Feb 2, 2024
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes platform-android waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.
Projects
None yet
4 participants