#include "w-input-keyboard.h"
#include "w-input-selector.h"
-#include "w-input-smartreply.h"
extern InputKeyboardData g_input_keyboard_data;
extern App_Data* app_data;
Evas_Object *entry;
-static void input_keyboard_app_control_send_reply_cb(app_control_h request, app_control_h reply,
- app_control_result_e result, void *user_data);
-
-static void input_keyboard_app_control_send_reply_cb(app_control_h request, app_control_h reply,
- app_control_result_e result, void *user_data)
-{
- char *feedback = NULL;
- if (result == APP_CONTROL_RESULT_SUCCEEDED) {
- if (reply) {
- int ret;
- ret = app_control_get_extra_data(reply,
- "template_feedback", &feedback);
-
- if (ret == APP_CONTROL_ERROR_NONE) {
- if (feedback) {
- input_smartreply_send_feedback(feedback);
- }
- }
- }
- reply_to_sender_by_callback(feedback, "keyboard");
- free(feedback);
- elm_exit();
- }
-}
-
-
bool input_keyboard_init(app_control_h app_control)
{
int ret = -1;
-
- char *app_id = NULL;
- char **data_array = NULL;
- int data_array_len = -1;
- char *default_text = NULL;
- char *guide_text = NULL;
+ char *default_text = NULL;
+ char *guide_text = NULL;
input_keyboard_deinit();
- ret = app_control_get_extra_data(app_control, APP_CONTROL_DATA_INPUT_DEFAULT_TEXT, &default_text);
- if (ret == APP_CONTROL_ERROR_NONE) {
- g_input_keyboard_data.default_text = default_text;
- }
- ret = app_control_get_extra_data(app_control, APP_CONTROL_DATA_INPUT_GUIDE_TEXT, &guide_text);
- if (ret == APP_CONTROL_ERROR_NONE) {
- g_input_keyboard_data.guide_text = guide_text;
- }
-
- ret = app_control_get_extra_data(app_control,
- "selector_keyboard_app_id",
- &app_id);
-
- if (ret != APP_CONTROL_ERROR_NONE) {
- PRINTFUNC(DLOG_WARN, "can not get selector_keyboard_app_id: %d", ret);
- return false;
+ ret = app_control_get_extra_data(app_control, APP_CONTROL_DATA_INPUT_DEFAULT_TEXT, &default_text);
+ if (ret == APP_CONTROL_ERROR_NONE) {
+ g_input_keyboard_data.default_text = default_text;
}
-
- ret = app_control_get_extra_data_array(app_control,
- "selector_keyboard_data_array",
- &data_array, &data_array_len);
-
-
- if (ret != APP_CONTROL_ERROR_NONE) {
- if (app_id)
- free(app_id);
-
- PRINTFUNC(DLOG_WARN, "can not get selector_keyboard_data_array : %d", ret);
- return false;
+ ret = app_control_get_extra_data(app_control, APP_CONTROL_DATA_INPUT_GUIDE_TEXT, &guide_text);
+ if (ret == APP_CONTROL_ERROR_NONE) {
+ g_input_keyboard_data.guide_text = guide_text;
}
- if (app_id)
- g_input_keyboard_data.app_id = app_id;
-
- if (data_array)
- g_input_keyboard_data.data_array = data_array;
-
- g_input_keyboard_data.data_array_len = data_array_len;
-
- PRINTFUNC(DLOG_WARN, "app_id = %s", app_id);
- PRINTFUNC(DLOG_WARN, "data_array = %s", data_array);
-
return true;
}
void input_keyboard_deinit(void)
{
- int i = 0;
- char **data_array = NULL;
-
if (g_input_keyboard_data.guide_text)
free(g_input_keyboard_data.guide_text);
if (g_input_keyboard_data.default_text)
free(g_input_keyboard_data.default_text);
- if (g_input_keyboard_data.app_id)
- free(g_input_keyboard_data.app_id);
-
- data_array = g_input_keyboard_data.data_array;
- if (data_array) {
- for (i = 0; i < g_input_keyboard_data.data_array_len; i++) {
- if (*(data_array + i))
- free(*(data_array + i));
- }
-
- free(data_array);
- }
-
- g_input_keyboard_data.app_id = NULL;
- g_input_keyboard_data.data_array = NULL;
- g_input_keyboard_data.data_array_len = 0;
+ g_input_keyboard_data.default_text = NULL;
+ g_input_keyboard_data.guide_text = NULL;
return;
}
-bool input_keyboard_launch(Evas_Object *window)
+void btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
{
- int ret;
-
- char *app_id;
-
app_control_h app_control;
-
- if (window == NULL) {
- PRINTFUNC(DLOG_ERROR, "Can not get window");
- return false;
- }
-
- ret = app_control_create(&app_control);
+ int ret = app_control_create(&app_control);
if (ret != APP_CONTROL_ERROR_NONE) {
PRINTFUNC(DLOG_ERROR, "Can not create app_control : %d", ret);
- return false;
+ return;
}
- app_id = g_input_keyboard_data.app_id;
- if (app_id == NULL) {
- PRINTFUNC(DLOG_INFO, "app id is undefined, use defualt");
- app_id = "com.samsung.message.appcontrol.compose";
- }
+ const char *getText = elm_entry_entry_get(entry);
+ LOGD("button key clicked!! : getText = %s", getText);
- app_control_set_app_id(app_control, app_id);
+ char *app_id = NULL;
+ app_control_get_caller(app_data->source_app_control, &app_id);
+ if (app_id != NULL)
+ app_control_set_app_id(app_control, app_id);
app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
-/*
- ret = app_control_set_window(app_control,
- elm_win_xwindow_get(window));
- if (ret != APP_CONTROL_ERROR_NONE) {
- PRINTFUNC(DLOG_ERROR, "Can not app control set window : %d", ret);
- app_control_destroy(app_control);
- return false;
- }
-*/
- if (g_input_keyboard_data.data_array && g_input_keyboard_data.data_array_len > 0) {
- app_control_add_extra_data_array(app_control,
- "selector_keyboard_data_array",
- (const char**)(g_input_keyboard_data.data_array),
- g_input_keyboard_data.data_array_len);
- }
-
set_source_caller_app_id(app_control);
-
- ret = app_control_send_launch_request(app_control,
- input_keyboard_app_control_send_reply_cb,
- NULL);
- if (ret != APP_CONTROL_ERROR_NONE)
- PRINTFUNC(DLOG_ERROR, "Can not launch app_control: %d", ret);
-
- app_control_destroy(app_control);
-
- return true;
+ free(app_id);
+ reply_to_sender_by_callback(getText, "keyboard");
+ ui_app_exit();
}
-void btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+static Eina_Bool custom_back_cb(void *data, Elm_Object_Item *it)
{
- app_control_h app_control;
- int ret = app_control_create(&app_control);
- if (ret != APP_CONTROL_ERROR_NONE) {
- PRINTFUNC(DLOG_ERROR, "Can not create app_control : %d", ret);
- return;
- }
-
- const char *getText = elm_entry_entry_get(entry);
- LOGD("button key clicked!! : getText = %s", getText);
-
- if(getText)
- input_smartreply_send_feedback(getText);
-
- char *app_id = NULL;
- app_control_get_caller(app_data->source_app_control, &app_id);
- if(app_id != NULL)
- app_control_set_app_id(app_control, app_id);
- 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");
- elm_exit();
+ _back_to_genlist_for_selector();
+ return EINA_TRUE;
}
-static Eina_Bool custom_back_cb(void *data, Elm_Object_Item *it)
+static void maxlength_cb(void *data, Evas_Object *obj, void *event_info)
{
- _back_to_genlist_for_selector();
- return EINA_TRUE;
+ LOGD("maxlength_cb : size = %d", KEYBOARD_EDITOR_CHAR_COUNT_MAX);
}
void create_fullscreen_editor(void *data)
{
App_Data *ad = (App_Data *)data;
- Evas_Object *box = elm_box_add(ad->naviframe);
- evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_show(box);
- elm_win_resize_object_add(ad->naviframe, box);
+ Evas_Object *box = elm_box_add(ad->naviframe);
+ evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(box);
+ elm_win_resize_object_add(ad->naviframe, box);
+
+ entry = elm_entry_add(box);
+
+ 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);
- entry = elm_entry_add(box);
elm_entry_single_line_set(entry, EINA_TRUE);
elm_entry_scrollable_set(entry, EINA_TRUE);
elm_scroller_policy_set(entry, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
elm_object_part_text_set(entry, "elm.guide", g_input_keyboard_data.guide_text);
- elm_entry_entry_set(entry, g_input_keyboard_data.default_text);
+ elm_entry_entry_set(entry, g_input_keyboard_data.default_text);
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);
evas_object_resize(ad->naviframe, 360, 360);
evas_object_show(ad->naviframe);
- Elm_Object_Item *nf_item = elm_naviframe_item_push(ad->naviframe, NULL, NULL, NULL, box, "empty");
- elm_naviframe_item_pop_cb_set(nf_item, custom_back_cb, NULL);
+ const char *item_style = NULL;
+ if (_WEARABLE)
+ item_style = "empty";
+ Elm_Object_Item *nf_item = elm_naviframe_item_push(ad->naviframe, NULL, NULL, NULL, box, item_style);
+ 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", "");
}
-bool input_keyboard_launch_with_ui(Evas_Object *window, void *data) {
+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);
- return true;
+
+ if (_WEARABLE)
+ create_fullscreen_editor(data);
+ else
+ create_editfield_view(data);
+
+ return true;
}