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

Added a text input that only accepts full numbers (int) #3350

Open
wants to merge 31 commits into
base: dev
Choose a base branch
from

Conversation

leedave
Copy link

@leedave leedave commented Jan 9, 2024

What's new

  • I've added a new Keyboard input. It is similar to text_input and byte_input. The purpose of this one is to only allow users to input a number, nothing else. This can be very handy in app designs, as the user input is limited to expected characters.

Verification

  • #include <gui/modules/int_input.h> in a fap application the same way you would include text_input.h

Checklist (For Reviewer)

  • PR has description of feature/bug or link to Confluence/Jira task
  • Description contains actions to verify feature/bugfix
  • I've built this code, uploaded it to the device and verified feature/bugfix

@hedger hedger added UI Affects UI New Feature Contains an IMPLEMENTATION of a new feature labels Jan 9, 2024
Copy link
Member

@hedger hedger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also include the new header in "sdk_headers" for gui module. And update API CSV's for both f7 and f18 afterwards.

@leedave
Copy link
Author

leedave commented Jan 9, 2024

@hedger Thank you for the feedback.
Added the requested sdk_headers and CSV entries

@leedave leedave requested a review from hedger January 9, 2024 08:18
@leedave
Copy link
Author

leedave commented Jan 11, 2024

@hedger are these fail messages normal or am I expected to do something to fix this?

@leedave leedave requested a review from gsurkov as a code owner January 16, 2024 13:27
@skotopes
Copy link
Member

Sorry for delay with your PR.
Can you also provide example app and rename IntInput to NumberInput, int_input to number_input?

@leedave
Copy link
Author

leedave commented Feb 15, 2024

@skotopes
Ok, tried my best to keep it as expected. Let me know if something isn't right.

  • The keyboard is renamed
  • There is an example app in applications/examples/example_number_input

@leedave
Copy link
Author

leedave commented Feb 15, 2024

trim.7362EBC2-3BCF-48BD-AF7D-D92890EC4349.MOV

@skotopes
Copy link
Member

0x0801147c in __furi_crash_implementation () at furi/core/check.c:163
163	        RESTORE_REGISTERS_AND_HALT_MCU(debug);
(gdb) bt
#0  0x0801147c in __furi_crash_implementation () at furi/core/check.c:163
#1  0x0807a5cc in view_dispatcher_free (view_dispatcher=0x20014de8) at applications/services/gui/view_dispatcher.c:26
#2  0x200154a6 in example_number_input_free (app=app@entry=0x20015a00) at applications/examples/example_number_input/example_number_input.c:45
#3  0x2001551e in example_number_input (p=<optimized out>) at applications/examples/example_number_input/example_number_input.c:69
#4  0x080548a2 in flipper_application_thread (context=0x20014b20) at lib/flipper_application/flipper_application.c:224
#5  0x08013d6e in furi_thread_body (context=0x20014d78) at furi/core/thread.c:91
#6  0x08013d1a in furi_thread_catch () at furi/core/thread.c:62
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

crashing on exit because some view was not released from view dispatcher

model->selected_row = 0;
model->selected_column = 0;
model->clear_default_text = false;
model->text_buffer = "";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got feeling that this part was copied from another place. We are not proud with it )

General concept for view modules is that they should own their own buffer and then provide it in callback call.

static const uint8_t enter_symbol = '\r';
static const uint8_t backspace_symbol = '\b';

static const NumberInputKey keyboard_keys_row_1[] = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we talking about numbers(int) you may want to provide negative sign too.
Also it will be nice if limits(MIN/MAX) and maybe int size be adjustable

@skotopes skotopes marked this pull request as draft February 16, 2024 04:07
@skotopes
Copy link
Member

Un-draft when ready

@skotopes
Copy link
Member

also please fix build issues (API mismatch)

@skotopes
Copy link
Member

@leedave need help?

@leedave
Copy link
Author

leedave commented Apr 19, 2024

@skotopes
Can you give me some more hints on the
view modules should own their own buffer issue.
Tbh I learn how code for Flipper should look by studying the fw you provide, as there is no official developer documentation. I got the basic setup from the other two keyboards (text & hex). If you say you're not proud of what you guys did back then and ask for an update, I'm not sure where I can find something built in the way you want to see it.

@skotopes
Copy link
Member

@leedave change model->text_buffer type to FuriString and allocate it on your module allocation

@leedave
Copy link
Author

leedave commented Apr 19, 2024

@skotopes
How did you do the check, to see if some views were not removed from view_dispatcher. I added a code update, but lack a way of testing the result

David Lee and others added 8 commits May 15, 2024 16:17
* GUI: Fix array out of bounds in menu exit
* Gui: fix incorrect empty menu handling
* Gui: add missing item check in menu ok handling
* Gui: remove dead code from menu module

Co-authored-by: あく <alleteam@gmail.com>
@leedave leedave marked this pull request as ready for review May 17, 2024 21:28
@leedave
Copy link
Author

leedave commented May 17, 2024

So after a long wait, I finally managed to add your requests

  • model->text_buffer changed to FuriString
  • removed number digits length option
  • replaced with settings for min/max value allowed
  • added possibility to input negative numbers, added button if set to true when loading module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Feature Contains an IMPLEMENTATION of a new feature UI Affects UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants