[Bug] Fix N_SE-13781 : if the text already reach max length, then press enter key...
authoryigang.jing <yigang.jing@samsung.com>
Wed, 14 Nov 2012 03:53:12 +0000 (11:53 +0800)
committeryigang.jing <yigang.jing@samsung.com>
Tue, 20 Nov 2012 04:22:04 +0000 (12:22 +0800)
Change-Id: I78ef3afc6633ff91750d85f4b3e6511cf0efd3da

setting-about/src/setting-about-main.c
setting-common/include/setting-common-data-type.h
setting-common/include/setting-common-resource.h
setting-common/src/setting-common-draw-genlist.c

index e6490b7..1194cd2 100755 (executable)
@@ -93,6 +93,19 @@ static void __about_popup_rsp_cb(void *data, Evas_Object *obj, void *event_info)
        }
        ad->popup = NULL;
 }
+
+static void __error_popup_response_cb(void *data, Evas_Object *obj,
+                                    void *event_info)
+{
+       SETTING_TRACE_BEGIN;
+       retm_if(data == NULL, "Data parameter is NULL");
+       Setting_GenGroupItem_Data *list_item = data;
+       if (list_item->notify) {
+               evas_object_del(list_item->notify);
+               list_item->notify = NULL;
+       }
+}
+
 static void __device_name_changed_cb(void *data, Evas_Object *obj)
 {
        retm_if(!data || !obj, "Data parameter is NULL");
@@ -107,6 +120,23 @@ static void __device_name_changed_cb(void *data, Evas_Object *obj)
        int entry_len = safeStrLen(entry_str);
        SETTING_TRACE("entry_str:[%s], lenght:%d", entry_str, entry_len);
 
+       SETTING_TRACE("maxLengthReachFlag:[%d], enterKeyPressFlag:%d", list_item->maxLengthReachFlag, list_item->enterKeyPressFlag);
+       /* show the popup if the text already reaches max length and the input character is not the enter key */
+       if (list_item->maxLengthReachFlag && list_item->enterKeyPressFlag == false) {
+               if (!list_item->notify) {
+                       list_item->notify = setting_create_popup_without_btn(list_item, list_item->win_main,
+                                                                NULL, _(EXCEED_LIMITATION_STR),
+                                                                __error_popup_response_cb,
+                                                                POPUP_INTERVAL, FALSE, FALSE);
+                       elm_object_focus_set(list_item->eo_check, EINA_FALSE);
+               } else {
+                       //postpone 2 seconds again
+                       elm_popup_timeout_set(list_item->notify, POPUP_INTERVAL);
+               }
+       }
+       list_item->maxLengthReachFlag = false;
+       list_item->enterKeyPressFlag = false;
+
 #if DEVNAME_BLOCK_SPACE
        //block 'Space' key
        if (entry_len > 0 && NULL != strstr(entry_str, " ")) {//cancel the effect of input 'space character'
@@ -557,6 +587,16 @@ static void __entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *eve
        }
 }
 
+static void __max_len_reached(void *data, Evas_Object *obj, void *event_info)
+{
+       SETTING_TRACE_BEGIN;
+       retm_if(data == NULL, "Data parameter is NULL");
+       retm_if(!elm_object_focus_get(obj), "Entry is not focused");//notify only when entry is being focused on.
+
+       Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
+       list_item->maxLengthReachFlag = true;
+}
+
 int setting_about_generate_genlist(void *data)
 {
        SETTING_TRACE_BEGIN;
@@ -612,6 +652,7 @@ int setting_about_generate_genlist(void *data)
                        ad->item_dev_name->isSinglelineFlag = 0;
                        ad->item_dev_name->start_change_cb = (setting_call_back_func)__entry_key_down_cb;
                        ad->item_dev_name->stop_change_cb = __entry_unfocus_cb;
+                       ad->item_dev_name->maxlength_reached_cb = __max_len_reached;
                        ad->item_dev_name->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
 
                        if (ad->item_dev_name->limit_filter_data) {
index 8e70307..398bfd8 100755 (executable)
@@ -240,11 +240,7 @@ typedef enum _POPUP_BTN_RESPONSE_TYPE{
  * @todo isItemDisableFlag is required?
  * @todo isSinglelineFlag is requred?
  */
-
-
-typedef struct Setting_GenGroupItem_Data Setting_GenGroupItem_Data;
-
-typedef struct Setting_GenGroupItem_Data {
+typedef struct _Setting_GenGroupItem_Data {
 
        void **pBack;
 
@@ -277,6 +273,7 @@ typedef struct Setting_GenGroupItem_Data {
        double slider_max;                                              /**< to swallow a slider */
        setting_call_back_func start_change_cb;
        setting_call_back_func stop_change_cb;
+       setting_call_back_func maxlength_reached_cb;
 
        /* sound/vibration */
        int belongs_to;                                                 /**< 1: slider belongs to sound group. 0: slider belongs to vibration group */
@@ -291,6 +288,8 @@ typedef struct Setting_GenGroupItem_Data {
        bool isFocusFlag;
        bool isItemDisableFlag;                                 /**< date/time UG only */
        bool isSinglelineFlag;
+       bool maxLengthReachFlag;
+       bool enterKeyPressFlag;
 
        int int_slp_setting_binded;                     /**< its relative vconf value must increase from 0, and step is 1. eg, 0, 1, 2, 3.. */
 
@@ -302,7 +301,7 @@ typedef struct Setting_GenGroupItem_Data {
        Elm_Entry_Filter_Limit_Size *limit_filter_data;
 
        Eina_List* childs;              /**< child nodes if this node has child nodes for handling radio buttons */
-};
+} Setting_GenGroupItem_Data;
 
 typedef enum {
        SETTING_VCONF_INT_TYPE = 0,
index 2144a38..74520aa 100755 (executable)
@@ -21,6 +21,9 @@
 
 #ifndef __SETTING_COMMON_RESOURCE
 #define __SETTING_COMMON_RESOURCE
+
+#define EXCEED_LIMITATION_STR          "The content is too long."
+
 #define SETTING_ICON_PATH_CFG  "/usr/apps/org.tizen.setting/res/icons/"
 #define SETTING_IMAGE_PATH_CFG "/usr/apps/org.tizen.setting/res/images/"
 #define SETTING_OPEN_SOURCE_LICENSE_PATH "file:///opt/apps/org.tizen.setting/data/Open_Source_Announcement.html"
index cfecfb3..2bd29da 100755 (executable)
@@ -24,8 +24,6 @@
 #include <Ecore_X.h>
 #include <system_settings.h>
 
-#define EXCEED_LIMITATION_STR          "The content is too long."
-
 static Evas_Object *_gl_Gendial_content_get(void *data, Evas_Object *obj, const char *part);
 static char *_gl_Gendial_text_get(void *data, Evas_Object *obj, const char *part);
 static void _gl_Gendial_del(void *data, Evas_Object *obj);
@@ -213,14 +211,18 @@ static void __max_len_reached(void *data, Evas_Object *obj, void *event_info)
        }
 
 }
+
 static void __entry_keydown(void *data, Evas *e, Evas_Object *obj, void *event_info)
 {
-       ret_if(event_info == NULL);
+       retm_if(data == NULL, "Data parameter is NULL");
+       retm_if(event_info == NULL, "event_info is NULL");
+       Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
        Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
        if(safeStrCmp(ev->key, "KP_Enter") == 0 //it is for Japanese keyboard to fix N_SE-10719
           || safeStrCmp(ev->key, "Return") == 0) //to disable the 'Enter' orginal function
        {
                SETTING_TRACE("ENTER %s ev->key:%s", __FUNCTION__, ev->key);
+               list_item->enterKeyPressFlag = true;
                //hide the eraser button
                //format like:xx<br/>
                const char *entry_str = remove_first_substring(elm_entry_entry_get(obj), "<br/>");
@@ -229,6 +231,7 @@ static void __entry_keydown(void *data, Evas *e, Evas_Object *obj, void *event_i
                elm_entry_cursor_end_set(obj);
                setting_hide_input_pannel_cb(obj);
        } else {
+               list_item->enterKeyPressFlag = false;
                Evas_Object *entry_container = elm_object_parent_widget_get(obj);
                if(safeStrLen(elm_entry_entry_get(obj)) > 0) {
                        elm_object_signal_emit(entry_container, "elm,state,guidetext,hide", "elm");
@@ -508,11 +511,17 @@ static Evas_Object *__add_entry(Setting_GenGroupItem_Data *item_data, Evas_Objec
                     elm_entry_filter_limit_size,
                     item_data->limit_filter_data);
 
-               evas_object_smart_callback_add(entry,
-                                             "maxlength,reached",
-                                             __max_len_reached,
-                                             item_data);
-
+               if (item_data->maxlength_reached_cb) {
+                       evas_object_smart_callback_add(entry,
+                                                     "maxlength,reached",
+                                                     item_data->maxlength_reached_cb,
+                                                     item_data);
+               } else {
+                       evas_object_smart_callback_add(entry,
+                                                     "maxlength,reached",
+                                                     __max_len_reached,
+                                                     item_data);
+               }
        }
        if (item_data->stop_change_cb) {//invoked when stop focusing on
                evas_object_smart_callback_add(entry,