termux-dialog response inconsistencies
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.3k
- Forks
- 920
- PR merge metrics
- No merged PRs in 30d
Description
Hello, I'm currently working on a personal project involving Termux:API and have noticed inconsistencies in the response when calling termux-dialog.
The Dialog API returns a JSON object that may have these keys: code, text, index, values, and error. This depends on what widget is used. I have detailed below the inconsistencies I have noticed.
The code
There are 3 codes that I'm aware of (-2, -1, 0) and these correspond to, I believe, the "exit code" of the widget -- whether you tapped "OK", "Cancel", or dismissed it by tapping outside the widget. It seems the code is inconsistent across widgets. For example, if you tapped "OK" one returns 0 (confirm), and others return -1 (checkbox, counter, date, radio, spinner, text, time). For widgets without an "OK" button, sheet returns 0 if one of the values is selected, and speech returns 0 if speech is recognized and if it did not recognize anything (but error is also returned). What's more confusing is the code -2 seem to either mean "dismissed" or "Cancel" was tapped.
Request and possible fixes:
Make the code consistent. Make 0 the return code of "OK button tapped" regardless of whether a value is selected or not, -1 for "Cancel button tapped" and "None selected" for widgets without a "Cancel" button, and -2 when a widget is dismissed.
The index
It seems the value of index from the previous call that's expected to have an index value (spinner, radio, etc.) is returned in other widgets that index should have no value (text, checkbox indices in values and text). Example: call termux-dialog using spinner widget with values, note the index in the response, then call using text widget and note the index. It should have the same index as the previous call which is unexpected.
Request and possible fixes:
Do not return index if it's not expected or update index value to null or an empty string in widgets that index should have no value before returning response.
Others
When on dark theme or use-black-ui is set true in termux.properties, the sheet widget is all white and you can't see the values.
Request and possible fixes:
Make sheet widget color consistent with other widgets.
That's what I have noticed so far. I tried to read the code in DialogActivity.java so I could provide more information or try possible fixes but alas my Java skills is very poor.
Thank you :)
Problem description
Steps to reproduce
Expected behavior
Additional information
- Termux application version: 0.108, API: 0.47
- Android OS version: 9
- Device model:
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported responses across the termux-dialog widgets, then read DialogActivity.java to trace how code and index values are retained and returned. Check the sheet widget under dark theme or use-black-ui. Done means the reported widget cases produce consistent response fields and the sheet colors remain readable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- cli, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100