Skip to content

Commit

Permalink
Merge pull request #421 from Cypherock/fix/incorrect-input-text-len-r…
Browse files Browse the repository at this point in the history
…eturn/PRF-6254

Fix/incorrect input text len return/prf 6254
  • Loading branch information
amanCypherock authored Oct 20, 2023
2 parents dccaa58 + 94f40b9 commit b28a044
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
11 changes: 8 additions & 3 deletions common/interfaces/user_interface/ui_input_text.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ int get_entered_text_px_width() {

void ui_input_text(const char *input_list,
char *input_text_ptr,
uint8_t input_text_buffer_size,
const char *initial_heading,
const uint8_t min_input_size,
const INPUT_DATA_TYPE data_type,
Expand All @@ -125,8 +126,10 @@ void ui_input_text(const char *input_list,
* we shall remove below check once refactor is complete */
if (input_text_ptr == NULL) {
data->input_text_ptr = flow_level.screen_input.input_text;
data->input_text_buffer_size = sizeof(flow_level.screen_input.input_text);
} else {
data->input_text_ptr = input_text_ptr;
data->input_text_buffer_size = input_text_buffer_size;
}

data->input_list_size = strnlen(input_list, MAX_CHARACTER_INPUT_LIST);
Expand Down Expand Up @@ -156,9 +159,10 @@ void input_text_init(const char *input_list,
const INPUT_DATA_TYPE data_type,
const uint8_t max_input_size) {
/* In order to support current calls to input_text_init, set the argument
* `input_text_ptr` as NULL*/
* `input_text_ptr` as NULL and `input_text_buffer_size` as 0*/
ui_input_text(input_list,
NULL,
0,
initial_heading,
min_input_size,
data_type,
Expand Down Expand Up @@ -548,8 +552,9 @@ static void next_btn_event_handler(lv_obj_t *next_btn, const lv_event_t event) {
/* As of now, all text is stored in the buffer data->entered_text,
* therefore we must copy data from here into the buffer which the
* application can access */
ui_fill_text(
data->entered_text, data->input_text_ptr, data->max_input_size);
ui_fill_text(data->entered_text,
data->input_text_ptr,
data->input_text_buffer_size);
ui_set_text_input_event(data->input_text_ptr);
input_text_destructor();
break;
Expand Down
8 changes: 6 additions & 2 deletions common/interfaces/user_interface/ui_input_text.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ typedef enum {
struct Input_Text_Data {
const char *input_list;
char *input_text_ptr;
uint8_t input_text_buffer_size;
uint8_t input_list_size;
char *initial_heading;
int current_index;
Expand Down Expand Up @@ -81,10 +82,12 @@ struct Input_Text_Object {
* @param initial_heading Input heading text
* @param min_input_size Mininum input text size
* @param data_type data type PASSWORD, PASSPHRASE or TEXT
* @param max_input_size Maximum input text size
* @param max_input_size Maximum input text size(this is text limit not buffer
* size, buffer size should be greater than this to accomodate max text)
*/
void ui_input_text(const char *input_list,
char *input_text_ptr,
uint8_t input_text_buffer_size,
const char *initial_heading,
const uint8_t min_input_size,
const INPUT_DATA_TYPE data_type,
Expand All @@ -101,7 +104,8 @@ void ui_input_text(const char *input_list,
* @param initial_heading Input heading text
* @param min_input_size Mininum input text size
* @param data_type data type PASSWORD, PASSPHRASE or TEXT
* @param max_input_size Maximum input text size
* @param max_input_size Maximum input text size(this is text limit not buffer
* size, buffer size should be greater than this to accomodate max text)
*
* @return
* @retval
Expand Down

0 comments on commit b28a044

Please sign in to comment.