Support a variety of return key types 29/315929/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Fri, 6 Dec 2024 08:33:40 +0000 (17:33 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Fri, 6 Dec 2024 08:33:40 +0000 (17:33 +0900)
Change-Id: I662ebdc8d1fc509f81626be047faec4db141ca3b
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
inc/w-input-selector.h
src/w-input-keyboard.cpp

index 1c5e79e1b0106ff15b58a3c7dca4086b458dc942..346ccdce6f6907bbd1f854c13b6bfa6a7f6bcc41 100644 (file)
@@ -119,7 +119,7 @@ struct _InputKeyboardData
 {
        string guide_text;
        string default_text;
-       string return_key_type;
+       Elm_Input_Panel_Return_Key_Type return_key_type;
        int max_text_length;
        int cursor_position_set;
        Elm_Input_Panel_Layout input_panel_layout;
index d050cbc8854fa76a346e0f8b83adf8e49827559b..837b0a7e50b603aa10bdce6b9030a56348d059d1 100644 (file)
@@ -34,6 +34,11 @@ struct _input_panel_layout_item {
        Elm_Input_Panel_Layout input_panel_layout;
 };
 
+struct _returnkey_type_item {
+       const char *returnkey_string;
+       Elm_Input_Panel_Return_Key_Type return_key_type;
+};
+
 static struct _input_panel_layout_item _input_panel_layout_items[] = {
        { "Normal", ELM_INPUT_PANEL_LAYOUT_NORMAL },
        { "Number", ELM_INPUT_PANEL_LAYOUT_NUMBER },
@@ -48,6 +53,19 @@ static struct _input_panel_layout_item _input_panel_layout_items[] = {
        { NULL, ELM_INPUT_PANEL_LAYOUT_NORMAL }
 };
 
+static struct _returnkey_type_item _return_key_items[] = {
+       { "Default", ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT },
+       { "Done", ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE },
+       { "Go", ELM_INPUT_PANEL_RETURN_KEY_TYPE_GO },
+       { "Join", ELM_INPUT_PANEL_RETURN_KEY_TYPE_JOIN },
+       { "Login", ELM_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN },
+       { "Next", ELM_INPUT_PANEL_RETURN_KEY_TYPE_NEXT },
+       { "Search", ELM_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH },
+       { "Send", ELM_INPUT_PANEL_RETURN_KEY_TYPE_SEND },
+       { "Signin", ELM_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN },
+       { NULL, ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT }
+};
+
 static Elm_Input_Panel_Layout convert_string_to_input_panel_layout(const char *input_panel_layout)
 {
        Elm_Input_Panel_Layout layout = ELM_INPUT_PANEL_LAYOUT_NORMAL;
@@ -65,6 +83,24 @@ static Elm_Input_Panel_Layout convert_string_to_input_panel_layout(const char *i
     return layout;
 }
 
+static Elm_Input_Panel_Return_Key_Type convert_string_to_return_key_type(const char *returnkey)
+{
+       Elm_Input_Panel_Return_Key_Type return_key_type = ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
+
+       unsigned int idx = 0;
+
+       while (_return_key_items[idx].returnkey_string != NULL) {
+               if (strcasecmp(_return_key_items[idx].returnkey_string, returnkey) == 0) {
+                       return_key_type = _return_key_items[idx].return_key_type;
+                       break;
+               }
+               idx++;
+       }
+
+    return return_key_type;
+
+}
+
 bool input_keyboard_init(app_control_h app_control)
 {
        int ret = -1;
@@ -104,7 +140,7 @@ bool input_keyboard_init(app_control_h app_control)
        ret = app_control_get_extra_data(app_control, APP_CONTROL_DATA_INPUT_RETURNKEY_TYPE, &return_key_type);
        if (ret == APP_CONTROL_ERROR_NONE) {
                if (return_key_type) {
-                       g_input_keyboard_data.return_key_type = string(return_key_type);
+                       g_input_keyboard_data.return_key_type = convert_string_to_return_key_type(return_key_type);
                }
        }
 
@@ -149,7 +185,7 @@ bool input_keyboard_init(app_control_h app_control)
 
 void input_keyboard_deinit(void)
 {
-       g_input_keyboard_data.return_key_type = string(_("IDS_AMEMO_BUTTON_SEND"));
+       g_input_keyboard_data.return_key_type = ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
        g_input_keyboard_data.max_text_length = KEYBOARD_EDITOR_CHAR_COUNT_MAX;
        g_input_keyboard_data.cursor_position_set = 0;
 
@@ -244,8 +280,8 @@ void create_fullscreen_editor(void *data)
        elm_entry_cursor_end_set(entry);
        evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
-       if (g_input_keyboard_data.return_key_type == string("DONE")) {
-               elm_entry_input_panel_return_key_type_set(entry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
+       elm_entry_input_panel_return_key_type_set(entry, g_input_keyboard_data.return_key_type);
+       if (g_input_keyboard_data.return_key_type == ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE) {
                evas_object_smart_callback_add(entry, "activated", enter_keydown_cb, ad);
        }
        if (g_input_keyboard_data.cursor_position_set != 0) {
@@ -258,7 +294,6 @@ void create_fullscreen_editor(void *data)
        elm_box_pack_end(box, entry);
 
        Evas_Object *btn = elm_button_add(box);
-       elm_object_text_set(btn, g_input_keyboard_data.return_key_type.c_str());
        evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, 0.5);
        evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
        evas_object_smart_callback_add(btn, "clicked", btn_clicked_cb, NULL);
@@ -313,8 +348,9 @@ static Evas_Object *create_multiline_editfield_layout(Evas_Object *parent, void
        elm_entry_cursor_end_set(entry);
        evas_object_smart_callback_add(entry, "focused", editfield_focused_cb, editfield);
        evas_object_smart_callback_add(entry, "unfocused", editfield_unfocused_cb, editfield);
-       if (g_input_keyboard_data.return_key_type == string("DONE")) {
-               elm_entry_input_panel_return_key_type_set(entry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
+       elm_entry_input_panel_return_key_type_set(entry, g_input_keyboard_data.return_key_type);
+
+       if (g_input_keyboard_data.return_key_type == ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE) {
                evas_object_smart_callback_add(entry, "activated", enter_keydown_cb, ad);
        }
        if (g_input_keyboard_data.cursor_position_set != 0) {