|
|
@@ -6,26 +6,25 @@
|
|
|
* then copied into the TX buffer. The contents of the TX buffer are then
|
|
|
* transmitted. The sent message is appended to the text box and a MsgEntered
|
|
|
* event is sent to the scene manager to switch to the text box view. */
|
|
|
-static void chat_input_cb(void *context)
|
|
|
+static bool chat_input_validator(const char *text, FuriString *error,
|
|
|
+ void *context)
|
|
|
{
|
|
|
+ UNUSED(error);
|
|
|
+
|
|
|
furi_assert(context);
|
|
|
ESubGhzChatState* state = context;
|
|
|
|
|
|
/* no message, just switch to the text box view */
|
|
|
-#ifdef FW_ORIGIN_Official
|
|
|
- if (strcmp(state->text_input_store, " ") == 0) {
|
|
|
-#else /* FW_ORIGIN_Official */
|
|
|
- if (strlen(state->text_input_store) == 0) {
|
|
|
-#endif /* FW_ORIGIN_Official */
|
|
|
- scene_manager_handle_custom_event(state->scene_manager,
|
|
|
+ if (strlen(text) == 0) {
|
|
|
+ view_dispatcher_send_custom_event(state->view_dispatcher,
|
|
|
ESubGhzChatEvent_MsgEntered);
|
|
|
- return;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/* concatenate the name prefix and the actual message */
|
|
|
furi_string_set(state->msg_input, state->name_prefix);
|
|
|
furi_string_cat_str(state->msg_input, ": ");
|
|
|
- furi_string_cat_str(state->msg_input, state->text_input_store);
|
|
|
+ furi_string_cat_str(state->msg_input, text);
|
|
|
|
|
|
/* append the message to the chat box */
|
|
|
furi_string_cat_printf(state->chat_box_store, "\n%s",
|
|
|
@@ -38,8 +37,10 @@ static void chat_input_cb(void *context)
|
|
|
furi_string_set_char(state->msg_input, 0, 0);
|
|
|
|
|
|
/* switch to text box view */
|
|
|
- scene_manager_handle_custom_event(state->scene_manager,
|
|
|
+ view_dispatcher_send_custom_event(state->view_dispatcher,
|
|
|
ESubGhzChatEvent_MsgEntered);
|
|
|
+
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/* Prepares the message input scene. */
|
|
|
@@ -52,25 +53,22 @@ void scene_on_enter_chat_input(void* context)
|
|
|
|
|
|
state->text_input_store[0] = 0;
|
|
|
text_input_reset(state->text_input);
|
|
|
+ /* use validator for scene change to get around minimum length
|
|
|
+ * requirement */
|
|
|
text_input_set_result_callback(
|
|
|
state->text_input,
|
|
|
- chat_input_cb,
|
|
|
- state,
|
|
|
+ NULL,
|
|
|
+ NULL,
|
|
|
state->text_input_store,
|
|
|
sizeof(state->text_input_store),
|
|
|
true);
|
|
|
text_input_set_validator(
|
|
|
state->text_input,
|
|
|
- NULL,
|
|
|
- NULL);
|
|
|
+ chat_input_validator,
|
|
|
+ state);
|
|
|
text_input_set_header_text(
|
|
|
state->text_input,
|
|
|
-#ifdef FW_ORIGIN_Official
|
|
|
- "Message (space for none)");
|
|
|
-#else /* FW_ORIGIN_Official */
|
|
|
"Message");
|
|
|
- text_input_set_minimum_length(state->text_input, 0);
|
|
|
-#endif /* FW_ORIGIN_Official */
|
|
|
|
|
|
view_dispatcher_switch_to_view(state->view_dispatcher, ESubGhzChatView_Input);
|
|
|
}
|