Repository navigation
feat(mobile): type into Android's own text field from the Capture form - #3001
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
| env.call_method(activity, jni_str!("copyText"), jni_sig!((text: JString) -> void), &[JValue::Object(&text)])?.v() | ||
| }); | ||
| if let Err(e) = asked { | ||
| log::warn!("{e}"); |
There was a problem hiding this comment.
A refused JNI call here is only logged. The user asked for a copy, and it never reached Android's clipboard, yet no notice is shown. The doc comment above says "a refusal is logged: the window's own clipboard still has it", but the rule for this repo is that a lost or failed operation is said through Session::notify (log::warn! alone doesn't count). copyText already reports its own refusals as copy-failed, so the Rust side's JNI errors (for example new_string failing on a very large copy, or the VM being unavailable) are the gap.
Suggested direction: have Phone::copy_text return Result<(), String>, have shell::Phone::copy_text return it too, and on Err call self.app.session.notify(..., true) in shell.rs (or reuse Event::CopyFailed) so the user sees one notice for the failed copy. Add a test that a failing copy yields a notice.
Category: agents-md
There was a problem hiding this comment.
Fixed in a0b9736: copy_text returns the JNI error on every layer, and the shell says it with the same notice as a copy Android refused (copy_failed). Test: a_copy_that_cannot_reach_the_clipboard_is_said.
| entry.show(); | ||
| } catch (RuntimeException e) { | ||
| entry = null; | ||
| add("text-closed\t" + id + "\t" + oneField(e.getMessage() == null ? e.getClass().getSimpleName() : e.getMessage())); |
There was a problem hiding this comment.
Edge case: if the exception's message is an empty string (not null), oneField("") gives text-closed\t<id>\t. On the Rust side Event::parse only accepts text-closed with a reason whose concat() is non-empty, so this line falls through to the "something RustGIS doesn't know" failure. The result is a misleading notice that quotes the line, and entering stays set on the Rust side (the field keeps its open outline) because the Closed never arrives.
A small fix is to treat an empty message like a missing one:
| add("text-closed\t" + id + "\t" + oneField(e.getMessage() == null ? e.getClass().getSimpleName() : e.getMessage())); | |
| String why = e.getMessage(); | |
| add("text-closed\t" + id + "\t" + oneField(why == null || why.isEmpty() ? e.getClass().getSimpleName() : why)); |
Confidence is low: this needs a throwable with an empty message from EditText/Dialog, which is rare.
Category: bug
There was a problem hiding this comment.
Fixed in a0b9736 as suggested: an empty message names the exception class.
| @@ -1289,6 +1289,8 @@ fn services(inbox: Inbox, font_inbox: Inbox, notes: Notes, ctx: egui::Context, e | |||
| take_photo: None, | |||
| // A text field's Paste: the page reads the clipboard (Firefox and Safari show a Paste | |||
There was a problem hiding this comment.
The new enter_text: None line landed between the Paste comment and read_clipboard, so the two-line comment about Paste now sits above enter_text and no longer describes the field it documents. Moving the new comment and field above the Paste comment keeps each comment with its field:
| // A text field's Paste: the page reads the clipboard (Firefox and Safari show a Paste | |
| // The browser gives egui's own fields their typing: no text field of its own is needed. | |
| enter_text: None, | |
| // A text field's Paste: the page reads the clipboard (Firefox and Safari show a Paste | |
| // button to confirm, Chrome asks once); only over HTTPS, where the browser offers it. |
Category: quality
Code reviewReviewed the 10-file diff against Bugs
Security
Performance
Quality
AGENTS.md
Twins checked
Change sizeCompared: the whole PR against main (merge base 54d7854 to PR head 77510a9).
|
📖 Docs preview
GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the |
Code reviewI found no confirmed bugs, security issues, or AGENTS.md breaks in this PR. I posted no inline comments because nothing I found met the bar for one. The two earlier review concerns about the Android clipboard and the empty-message edge case are already fixed in Bugs: none found.
Security: none confirmed.
Performance:
Quality (for the release quality pass):
AGENTS.md: none found. Checked: no new command, so Twins and surfaces checked:
Earlier concerns: three threads on the PR. Two are fixed in the head and one is a quality point still open. I did not repost any of them. Change sizeCompared with
|
A NativeActivity hands its window's touches and keys to Rust, so egui's fields on Android get no paste, suggestions, glide typing or dictation. The Platform trait gains enter_text (a default that does nothing, so the desktop, the browser and iOS are unchanged): Android opens an EditText in a window of its own, docked above the soft keyboard, and sends its text back as an event on each change and again when it closes. The Capture form draws its text and number fields as boxes that open it. Text copied in RustGIS also goes on Android's clipboard.
… an empty error still closes the text box Review of opengeos#3001: a refused JNI call for a copy was only logged; it now gives the same notice as a copy Android refused. An exception with an empty message named no reason, so the text box's close was never read.
a0b9736 to
946df8c
Compare
| try { | ||
| android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService(CLIPBOARD_SERVICE); | ||
| if (clipboard == null) { | ||
| add("copy-failed\tthis device has no clipboard service"); |
There was a problem hiding this comment.
This English text reaches the user through copy_failed in a notice, and Java can't use tl!, so it stays English in every language. Existing Java messages (such as "This device has no file picker") already do this, so the PR follows a precedent rather than adding a new gap. A cleaner fix is to send a short code such as no-clipboard and map it to a translated string on the Rust side in shell.rs.
Category: quality
There was a problem hiding this comment.
Left for the release quality pass.
| // The Capture form takes it (`rustgis_ui_touch`). | ||
| Event::Typed(typed) => { | ||
| if let rustgis_engine::platform::Typed::Closed { failed: Some(error), .. } = &typed { | ||
| self.app.session.notify(i18n::fmt("The text box couldn't be opened: {error}", &[("error", error)]), true); |
There was a problem hiding this comment.
The notice for a text box that couldn't be opened has no test. The PR tests the take_typed notice and the copy_out notice, but not Event::Typed with failed: Some(..), nor the Err branch of Services::enter_text in capture_fields. AGENTS asks that each lossy path have a test that gives the notice. A test in this file's tests module that feeds Typed::Closed { failed: Some(..) } through the event loop and checks for exactly one notice would cover it.
Category: quality
There was a problem hiding this comment.
Left for the release quality pass.
Code reviewI found no confirmed bugs, security issues or performance problems. I raised two quality points inline. I did not build or run anything: this environment has no shell, and the PR says the emulator run is still pending. Bugs: None confirmed. I traced these paths and found them consistent:
Confidence: medium-high. Security: None. The Performance: None material. Each keystroke sends the full text over JNI, which is fine for form fields. Confidence: high. Quality:
AGENTS.md:
Prior reviews: Three threads exist, all outdated and answered as fixed. I confirmed each fix in the diff: Twins checked:
Change sizeCompared with the base branch (merge base e48daeb to PR head 946df8c), not the latest push.
|
|
@coderabbitai review |
| } | ||
| } catch (RuntimeException e) { | ||
| // Too large for Android to pass on, say: the Rust side's own clipboard still has it. | ||
| add("copy-failed\t" + oneField(e.getMessage() == null ? e.getClass().getSimpleName() : e.getMessage())); |
There was a problem hiding this comment.
Twin of the empty-message case fixed in enterText (a0b9736): here an exception whose message is "" (not null) passes through as an empty reason, so copy-failed\t reaches Rust. Event::parse accepts it, and the user gets the notice "...system's clipboard...: " with a blank reason. The notice still fires, so nothing is lost; this is the wording of the reason only. Treating an empty message like a missing one matches the enterText fix:
| add("copy-failed\t" + oneField(e.getMessage() == null ? e.getClass().getSimpleName() : e.getMessage())); | |
| add("copy-failed\t" + oneField(e.getMessage() == null || e.getMessage().isEmpty() ? e.getClass().getSimpleName() : e.getMessage())); |
Category: quality
There was a problem hiding this comment.
Left for the release quality pass.
Code reviewI read the full diff against BugsNone found. I checked the Java/Rust hand-off for ordering ( SecurityNone found. Copy from egui password fields is suppressed by egui, so sending copies to the Android clipboard doesn't expose masked values. PerformanceNone found. Quality
AGENTS.mdNo new violations. Twins checked:
Already raised, left alone (5 threads):
Change sizeCompared: the whole PR against main (merge base e48daeb to PR head 946df8c).
|
Action not completed
|
Summary
On Android, typing into the phone's text fields misses most of what the keyboard does. Paste does nothing, and suggestions, glide typing and dictation don't reach the field. The app is a
NativeActivity, which hands its window's touches and keys straight to Rust. winit maps Android'sKeyAction::Multiple(the event paste, glide typing and dictation send) to a key release with no text. egui-winit also has no system clipboard on Android, so text copied in RustGIS stays inside the app.This gives the touch interface Android's own text field:
Platformgetsenters_textandenter_text(&TextEntry)(id, current value, label, kind: plain, lines, secret, number). Both have defaults that do nothing, so the desktop, the browser and iOS are unchanged. The answers come back asEvent::Typed:Typed::Text { id, text }on each change, thenTyped::Closed { id, failed }.MainActivity.enterTextopens anEditTextin aDialogdocked above the soft keyboard. It is a window of its own becauseNativeActivitytakes its own window's input queue, so a view added there gets no touches or keys. It uses plain platform widgets: no Jetpack, no Gradle. Secret entries useTYPE_TEXT_VARIATION_PASSWORDwith the password autofill hint. Number entries get the number keyboard throughsetRawInputType, without Android's digit filter, which would turn a pasted1e3into13. The Capture parser checks the number as before.Services::enter_text), and opens the native box on a tap. Each opening has its own id, so a late close from an earlier opening can't end a later one. Text that arrives after Capture has moved to another layer, or after the layer lost the field, is reported in a notice and not stored.OutputCommand::CopyText) also goes on Android's clipboard. A refusal (Android won't pass on a very large copy) is reported in a notice. The app's own clipboard still has the text.Fields the desktop interface draws, the Assistant's settings among them, still use egui's own text field on Android. The Assistant's phone sheet (stage 1a of the phone plan) will use this entry, including the
secretkind.Surfaces. The phone's touch interface on Android. iOS keeps the trait default: its keyboard goes through winit's
UIKeyInputpath, and I can't run iOS on this machine. Desktop, browser, CLI and Python have no touch sheets and keep egui's fields; the browser's literal setsenter_text: None. No command, ribbon, shortcut, Assistant/MCP tool or plugin interface changes. The way back is unchanged: the value goes into the same form field and the feature is added with the same undoable command.Testing
crates/ui-touch:a_field_typed_into_with_the_systems_text_field_fills_the_featuretaps the drawn box and checks the entry asked for (value, label, kind). It sends changes back and checks that another field's answer and an earlier opening's late close change nothing, that the added feature holds the typed text (tab and all), and that text arriving after Capture moved to another layer is reported, not stored.crates/engineplatform::tests: the newtext,text-closedandcopy-failedlines, escapes included, and malformed ones read as failures quoting the line.apps/rustgis-mobile/build-apk.sh x86_64builds (javac, d8, the Rust library).WGPU_DEBUG=0: the emulator's Vulkan driver crashes on the object names wgpu gives in debug builds, which a release build doesn't set: tapping a Capture field opens Android's text box docked at the bottom, with the field's name and Done; typed text reaches the form field as it is typed; cut and paste through Android's clipboard work in the box; Done, Back (the first Back hides the keyboard, as Android does) and a tap outside close it, keeping the value; reopening shows it again; rotating with the box open keeps the box and its text.1e3, the typed value in a feature added from the form, and a copy from a RustGIS field reaching Android's clipboard; theui-touchtest above covers the typed value reaching the feature.UI evidence
Android emulator. The Capture field itself looks as before: a box showing its value.
Related issue
Part of #1902.
Summary by CodeRabbit