Modify edit UI in keyboard input 74/129574/1
authorsungwook79.park <sungwook79.park@samsung.com>
Wed, 17 May 2017 04:51:54 +0000 (13:51 +0900)
committersungwook79.park <sungwook79.park@samsung.com>
Wed, 17 May 2017 04:51:54 +0000 (13:51 +0900)
Change-Id: I0e570a081fcc1f34f1ae45b47c45c98ef057cb0e
Signed-off-by: sungwook79.park <sungwook79.park@samsung.com>
inc/w-input-keyboard.h
src/w-input-keyboard.cpp

index a04fccd..b127fdf 100755 (executable)
@@ -21,7 +21,7 @@
 #include <app_control.h>
 #include <Evas.h>
 
-const int KEYBOARD_EDITOR_CHAR_COUNT_MAX = 50;
+const int KEYBOARD_EDITOR_CHAR_COUNT_MAX = 300;
 bool input_keyboard_init(app_control_h app_control);
 void input_keyboard_deinit(void);
 bool input_keyboard_launch(Evas_Object *window, void * data);
index 52051a6..d7e2bf2 100755 (executable)
@@ -141,12 +141,97 @@ void create_fullscreen_editor(void *data)
        elm_naviframe_item_pop_cb_set(nf_item, custom_back_cb, NULL);
 }
 
+static void editfield_focused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       Evas_Object *editfield = (Evas_Object *)data;
+       elm_object_signal_emit(editfield, "elm,state,focused", "");
+
+       if (!elm_entry_is_empty(obj))
+               elm_object_signal_emit(editfield, "elm,action,show,button", "");
+}
+
+static void editfield_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       Evas_Object *editfield = (Evas_Object *)data;
+       elm_object_signal_emit(editfield, "elm,state,unfocused", "");
+       elm_object_signal_emit(editfield, "elm,action,hide,button", "");
+}
+
+static Evas_Object *create_multiline_editfield_layout(Evas_Object *parent, void *data)
+{
+       Evas_Object *editfield;
+
+       editfield = elm_layout_add(parent);
+       elm_layout_theme_set(editfield, "layout", "editfield", "multiline");
+       evas_object_size_hint_align_set(editfield, EVAS_HINT_FILL, 0.0);
+       evas_object_size_hint_weight_set(editfield, EVAS_HINT_EXPAND, 0.0);
+
+       entry = elm_entry_add(editfield);
+       static Elm_Entry_Filter_Limit_Size limit_filter_data;
+       limit_filter_data.max_char_count = KEYBOARD_EDITOR_CHAR_COUNT_MAX;
+       elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_filter_data);
+       evas_object_smart_callback_add(entry, "maxlength,reached", maxlength_cb, data);
+
+       elm_object_part_text_set(entry, "elm.guide", g_input_keyboard_data.guide_text);
+       evas_object_smart_callback_add(entry, "focused", editfield_focused_cb, editfield);
+       evas_object_smart_callback_add(entry, "unfocused", editfield_unfocused_cb, editfield);
+       elm_object_part_content_set(editfield, "elm.swallow.content", entry);
+
+       return editfield;
+}
+
+static Evas_Object *create_editfield_view(void *data)
+{
+       App_Data *ad = (App_Data *)data;
+
+       Evas_Object *main_scroller, *main_box, *editfield;
+
+       main_scroller = elm_scroller_add(ad->naviframe);
+       elm_scroller_bounce_set(main_scroller, EINA_FALSE, EINA_TRUE);
+       evas_object_size_hint_weight_set(main_scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(main_scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       evas_object_show(main_scroller);
+
+       main_box = elm_box_add(main_scroller);
+       evas_object_size_hint_align_set(main_box, EVAS_HINT_FILL, 0.0);
+       evas_object_size_hint_weight_set(main_box, EVAS_HINT_EXPAND, 0.0);
+       evas_object_show(main_box);
+
+       editfield = create_multiline_editfield_layout(main_box, data);
+       elm_box_pack_end(main_box, editfield);
+       evas_object_show(editfield);
+
+       Evas_Object *btn = elm_button_add(main_box);
+       elm_object_text_set(btn, "OK");
+       evas_object_size_hint_weight_set(btn, 0.5, 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);
+       evas_object_show(btn);
+       elm_box_pack_end(main_box, btn);
+
+       elm_object_content_set(main_scroller, main_box);
+
+       evas_object_show(ad->naviframe);
+       const char *item_style = NULL;
+       if (_WEARABLE)
+               item_style = "empty";
+       Elm_Object_Item *nf_item = elm_naviframe_item_push(ad->naviframe, NULL, NULL, NULL, main_scroller, item_style);
+       elm_naviframe_item_pop_cb_set(nf_item, custom_back_cb, NULL);
+
+       return main_scroller;
+}
+
 bool input_keyboard_launch(Evas_Object *window, void *data) {
        if (window == NULL) {
                PRINTFUNC(DLOG_ERROR, "Can not get window");
                return false;
        }
-       create_fullscreen_editor(data);
+
+       if (_WEARABLE)
+               create_fullscreen_editor(data);
+       else
+               create_editfield_view(data);
+
        return true;
 }