Support API for set/get cursor position 44/147144/2
authorsungwook79.park <sungwook79.park@samsung.com>
Fri, 1 Sep 2017 06:57:54 +0000 (15:57 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Fri, 1 Sep 2017 07:27:07 +0000 (07:27 +0000)
Change-Id: Ie28b7e1215d0309ec3ef2ec53a5a54f4da871713
Signed-off-by: sungwook79.park <sungwook79.park@samsung.com>
inc/w-input-selector.h
src/w-input-emoticon.cpp
src/w-input-keyboard.cpp
src/w-input-selector.cpp
src/w-input-stt-voice.cpp

index e79cbf5..7ff2ed2 100755 (executable)
@@ -118,6 +118,7 @@ struct _InputKeyboardData
        char *default_text;
        char *return_key_type;
        int max_text_length;
+       int cursor_position_set;
 };
 typedef struct _InputKeyboardData InputKeyboardData;
 
@@ -130,7 +131,7 @@ typedef struct _InputTypeData InputTypeData;
 
 void _app_terminate(void* user_data);
 void reply_to_sender_by_callback_for_back();
-void reply_to_sender_by_callback(const char *value, const char *type, const char *path[]);
+void reply_to_sender_by_callback(const char *value, const char *type, const char *path[], const char *cursor_pos);
 char* get_resource_path();
 char* get_shared_resource_path();
 void show_gl_focus(Eina_Bool bVisible);
index a2ab3c9..d94c553 100755 (executable)
@@ -379,7 +379,7 @@ static void _drawing_app_control_reply_cb(app_control_h request, app_control_h r
     if(path){
         PRINTFUNC(DLOG_DEBUG, "path=%s", path);
         char *pathes[] = {path, };
-        reply_to_sender_by_callback(NULL, "image", (const char **)pathes);
+        reply_to_sender_by_callback(NULL, "image", (const char **)pathes, NULL);
         free(path);
     }
     ui_app_exit();
@@ -421,7 +421,7 @@ static void _emoticon_item_clicked_cb(void *data, Evas_Object * obj, void *event
     const Eina_Unicode unicode_event[2] = { (Eina_Unicode)emoticon_info[index].code, 0 };
     char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length);
 
-    reply_to_sender_by_callback((const char*)utf_8, "emoticon", NULL);
+    reply_to_sender_by_callback((const char*)utf_8, "emoticon", NULL, NULL);
 
     PRINTFUNC(SECURE_DEBUG, "[%d]%s", index, utf_8);
     if (utf_8)
index cd6356f..ba9a217 100755 (executable)
@@ -36,6 +36,7 @@ bool input_keyboard_init(app_control_h app_control)
        char *guide_text = NULL;
        char *return_key_type = "SEND";
        char *max_text_length = NULL;
+       char *cursor_position_set = "0";
 
        input_keyboard_deinit();
 
@@ -55,6 +56,10 @@ bool input_keyboard_init(app_control_h app_control)
        if (ret == APP_CONTROL_ERROR_NONE) {
                g_input_keyboard_data.max_text_length = atoi(max_text_length);
        }
+       ret = app_control_get_extra_data(app_control, "cursor_position_set", &cursor_position_set);
+       if (ret == APP_CONTROL_ERROR_NONE) {
+               g_input_keyboard_data.cursor_position_set = atoi(cursor_position_set);
+       }
 
        return true;
 }
@@ -74,6 +79,7 @@ void input_keyboard_deinit(void)
        g_input_keyboard_data.guide_text = NULL;
        g_input_keyboard_data.return_key_type = "SEND";
        g_input_keyboard_data.max_text_length = KEYBOARD_EDITOR_CHAR_COUNT_MAX;
+       g_input_keyboard_data.cursor_position_set = 0;
 
        return;
 }
@@ -90,6 +96,9 @@ void exit_keyboard()
        const char *getText = elm_entry_entry_get(entry);
        LOGD("button key clicked!! : getText = %s", getText);
 
+       char cursorPosition[512];
+       snprintf(cursorPosition, sizeof(cursorPosition), "%d", elm_entry_cursor_pos_get(entry));
+
        char *app_id = NULL;
        app_control_get_caller(app_data->source_app_control, &app_id);
        if (app_id != NULL)
@@ -97,9 +106,8 @@ void exit_keyboard()
        app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
        set_source_caller_app_id(app_control);
        free(app_id);
-       reply_to_sender_by_callback(getText, "keyboard", NULL);
+       reply_to_sender_by_callback(getText, "keyboard", NULL, cursorPosition);
        ui_app_exit();
-
 }
 
 void btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
@@ -166,6 +174,9 @@ void create_fullscreen_editor(void *data)
                elm_entry_input_panel_return_key_type_set(entry, 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) {
+               elm_entry_cursor_pos_set(entry, g_input_keyboard_data.cursor_position_set);
+       }
        evas_object_show(entry);
        elm_box_pack_end(box, entry);
 
@@ -229,6 +240,9 @@ static Evas_Object *create_multiline_editfield_layout(Evas_Object *parent, void
                elm_entry_input_panel_return_key_type_set(entry, 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) {
+               elm_entry_cursor_pos_set(entry, g_input_keyboard_data.cursor_position_set);
+       }
 
        evas_object_show(entry);
        elm_object_part_content_set(editfield, "elm.swallow.content", entry);
index d72a097..57320ec 100755 (executable)
@@ -221,7 +221,7 @@ static void __ise_smartreply_gl_sel(void *data, Evas_Object *obj, void *event_in
                char *reply = input_smartreply_get_nth_item(index, &type);
                if (reply) {
                        input_smartreply_send_feedback(reply);
-                       reply_to_sender_by_callback(reply, "smartreply", NULL);
+                       reply_to_sender_by_callback(reply, "smartreply", NULL, NULL);
                        free(reply);
                        elm_exit();
                }
@@ -240,7 +240,7 @@ static void __ise_template_gl_sel(void *data, Evas_Object *obj, void *event_info
                const std::vector<TemplateData>  template_list = input_template_get_list();
 
                if (index < (int)template_list.size()) {
-                       reply_to_sender_by_callback(gettext(template_list[index].text.c_str()), "template", NULL);
+                       reply_to_sender_by_callback(gettext(template_list[index].text.c_str()), "template", NULL, NULL);
                        ui_app_exit();
                }
        }
@@ -479,7 +479,7 @@ void set_source_caller_app_id(app_control_h app_control)
        }
 }
 
-void reply_to_sender_by_callback(const char *value, const char *type, const char *path[])
+void reply_to_sender_by_callback(const char *value, const char *type, const char *path[], const char *cursor_position)
 {
        PRINTFUNC(DLOG_DEBUG, "");
 
@@ -498,6 +498,9 @@ void reply_to_sender_by_callback(const char *value, const char *type, const char
                        app_control_add_extra_data_array(app_control, APP_CONTROL_DATA_PATH, path, 1);
                }
 
+               if (cursor_position != NULL)
+                       app_control_add_extra_data(app_control, "cursor_position_get", cursor_position);
+
                set_source_caller_app_id(app_control);
 
                ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
@@ -627,7 +630,7 @@ void _back_to_genlist_for_selector()
        }
        if (app_data->app_type == APP_TYPE_STT || app_data->app_type == APP_TYPE_EMOTICON || app_data->app_type == APP_TYPE_KEYBOARD){
                PRINTFUNC(DLOG_DEBUG, "launched as STT/EMOTICON/KEYBOARD mode, So exit here.");
-               reply_to_sender_by_callback(NULL, NULL, NULL);
+               reply_to_sender_by_callback(NULL, NULL, NULL, NULL);
                ui_app_exit();
        }
 }
index fb0c086..1795cc8 100755 (executable)
@@ -479,7 +479,7 @@ static void on_confirm_button_clicked_cb(void *data, Evas_Object *obj, void *eve
        if (!vr)
                filePath = vr->file_path;
        char *path[] = {filePath, };
-       reply_to_sender_by_callback(result_text.c_str(), "voice", (const char **)path);
+       reply_to_sender_by_callback(result_text.c_str(), "voice", (const char **)path, NULL);
        destroy_voice();
        powerUnlock();
        ui_app_exit();