#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)
-{
- 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);
- if (ret != APP_CONTROL_ERROR_NONE) {
- PRINTFUNC(DLOG_ERROR, "Can not create app_control : %d", ret);
- return false;
- }
-
- 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";
- }
-
- 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;
-}
-
void btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
{
- app_control_h app_control;
- int ret = app_control_create(&app_control);
+ 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);
+ const char *getText = elm_entry_entry_get(entry);
+ LOGD("button key clicked!! : getText = %s", 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);
+ 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);
+ set_source_caller_app_id(app_control);
+ free(app_id);
reply_to_sender_by_callback(getText, "keyboard");
elm_exit();
}
static Eina_Bool custom_back_cb(void *data, Elm_Object_Item *it)
{
- _back_to_genlist_for_selector();
- return EINA_TRUE;
+ _back_to_genlist_for_selector();
+ return EINA_TRUE;
+}
+
+static void maxlength_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ 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);
+ 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);
}
-bool input_keyboard_launch_with_ui(Evas_Object *window, void *data) {
+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;
+ create_fullscreen_editor(data);
+ return true;
}