2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <Elementary.h>
24 #include "w-input-keyboard.h"
25 #include "w-input-selector.h"
27 extern InputKeyboardData g_input_keyboard_data;
28 extern App_Data* app_data;
32 bool input_keyboard_init(app_control_h app_control)
35 char *default_text = NULL;
36 char *guide_text = NULL;
38 input_keyboard_deinit();
40 ret = app_control_get_extra_data(app_control, APP_CONTROL_DATA_INPUT_DEFAULT_TEXT, &default_text);
41 if (ret == APP_CONTROL_ERROR_NONE) {
42 g_input_keyboard_data.default_text = default_text;
44 ret = app_control_get_extra_data(app_control, APP_CONTROL_DATA_INPUT_GUIDE_TEXT, &guide_text);
45 if (ret == APP_CONTROL_ERROR_NONE) {
46 g_input_keyboard_data.guide_text = guide_text;
52 void input_keyboard_deinit(void)
54 if (g_input_keyboard_data.guide_text)
55 free(g_input_keyboard_data.guide_text);
57 if (g_input_keyboard_data.default_text)
58 free(g_input_keyboard_data.default_text);
60 g_input_keyboard_data.default_text = NULL;
61 g_input_keyboard_data.guide_text = NULL;
66 void btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
68 app_control_h app_control;
69 int ret = app_control_create(&app_control);
70 if (ret != APP_CONTROL_ERROR_NONE) {
71 PRINTFUNC(DLOG_ERROR, "Can not create app_control : %d", ret);
75 const char *getText = elm_entry_entry_get(entry);
76 LOGD("button key clicked!! : getText = %s", getText);
79 app_control_get_caller(app_data->source_app_control, &app_id);
81 app_control_set_app_id(app_control, app_id);
82 app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
83 set_source_caller_app_id(app_control);
85 reply_to_sender_by_callback(getText, "keyboard");
89 static Eina_Bool custom_back_cb(void *data, Elm_Object_Item *it)
91 _back_to_genlist_for_selector();
95 static void maxlength_cb(void *data, Evas_Object *obj, void *event_info)
97 LOGD("maxlength_cb : size = %d", KEYBOARD_EDITOR_CHAR_COUNT_MAX);
100 void create_fullscreen_editor(void *data)
102 App_Data *ad = (App_Data *)data;
104 Evas_Object *box = elm_box_add(ad->naviframe);
105 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
106 evas_object_show(box);
107 elm_win_resize_object_add(ad->naviframe, box);
109 entry = elm_entry_add(box);
111 static Elm_Entry_Filter_Limit_Size limit_filter_data;
112 limit_filter_data.max_char_count = KEYBOARD_EDITOR_CHAR_COUNT_MAX;
113 elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_filter_data);
114 evas_object_smart_callback_add(entry, "maxlength,reached", maxlength_cb, data);
116 elm_entry_single_line_set(entry, EINA_TRUE);
117 elm_entry_scrollable_set(entry, EINA_TRUE);
118 elm_scroller_policy_set(entry, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
119 elm_object_part_text_set(entry, "elm.guide", g_input_keyboard_data.guide_text);
120 elm_entry_entry_set(entry, g_input_keyboard_data.default_text);
121 elm_entry_cursor_end_set(entry);
122 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
123 evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
124 evas_object_show(entry);
125 elm_box_pack_end(box, entry);
127 Evas_Object *btn = elm_button_add(box);
128 elm_object_text_set(btn, "SEND");
129 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, 0.5);
130 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
131 evas_object_smart_callback_add(btn, "clicked", btn_clicked_cb, NULL);
132 evas_object_show(btn);
133 elm_box_pack_end(box, btn);
134 evas_object_resize(ad->naviframe, 360, 360);
135 evas_object_show(ad->naviframe);
137 Elm_Object_Item *nf_item = elm_naviframe_item_push(ad->naviframe, NULL, NULL, NULL, box, "empty");
138 elm_naviframe_item_pop_cb_set(nf_item, custom_back_cb, NULL);
141 bool input_keyboard_launch(Evas_Object *window, void *data) {
142 if (window == NULL) {
143 PRINTFUNC(DLOG_ERROR, "Can not get window");
146 create_fullscreen_editor(data);