From: Somin Kim Date: Thu, 1 Oct 2015 10:25:30 +0000 (+0900) Subject: [SAMPLE APP][Context Trigger] genlist UI changed X-Git-Tag: tizen_3.0/TD_SYNC/20161201~421^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=da63c207fb44dfd8e358934e02eb4199d7226817;p=sdk%2Fonline-doc.git [SAMPLE APP][Context Trigger] genlist UI changed Change-Id: I7fd29b03a57f2893092d8fc5a4bddd00e9ce85ed Signed-off-by: Somin Kim --- diff --git a/org.tizen.sampledescriptions/html/images/context_trigger_sd.png b/org.tizen.sampledescriptions/html/images/context_trigger_sd.png index 89f1c4b..93f7cde 100644 Binary files a/org.tizen.sampledescriptions/html/images/context_trigger_sd.png and b/org.tizen.sampledescriptions/html/images/context_trigger_sd.png differ diff --git a/org.tizen.sampledescriptions/html/mobile_n/context_trigger_sd_mn.htm b/org.tizen.sampledescriptions/html/mobile_n/context_trigger_sd_mn.htm index 5e2f262..33c21da 100644 --- a/org.tizen.sampledescriptions/html/mobile_n/context_trigger_sd_mn.htm +++ b/org.tizen.sampledescriptions/html/mobile_n/context_trigger_sd_mn.htm @@ -145,77 +145,47 @@ void remove_rules(void)

To create the genlist:

  1. -

    The genlist is created using the elm_genlist_add() function. For the genlist to be displayed properly, genlist item classes have to be created and defined with the elm_genlist_item_class_new() function. The following code snippet demonstrates how to set the item class properties. A text_get and a content_get callback function are defined to create item text and layout creation.

    +

    The genlist is created using the elm_genlist_add() function. For the genlist to be displayed properly, a genlist item class has to be created and defined with the elm_genlist_item_class_new() function. The following code snippet demonstrates how to set the item class properties. A text_get and a content_get callback function are defined to create item text and layout creation.

     Evas_Object *genlist;
    -Elm_Genlist_Item_Class *itc_name, *itc_description;
    +Elm_Genlist_Item_Class *itc;
     int index;
     
     /* Create item class */
    -itc_name = elm_genlist_item_class_new();
    -itc_name->item_style = "default";
    -itc_name->func.text_get = gl_text_name_get_cb;
    -itc_name->func.content_get = gl_content_get_cb;
    -
    -itc_description = elm_genlist_item_class_new();
    -itc_description->item_style = "multiline";
    -itc_description->func.text_get = gl_text_description_get_cb;
    +itc = elm_genlist_item_class_new();
    +itc->item_style = "multiline";
    +itc->func.text_get = gl_text_get_cb;
    +itc->func.content_get = gl_content_get_cb;
     
     /* Genlist */
    -genlist = elm_genlist_add(ad->nf);
    -Evas_Object *genlist = elm_genlist_add(viewdata.win);
    -
    -// Error handling
    -
    -viewdata.item_class = elm_genlist_item_class_new();
    -
    -// Error handling
    -
    -viewdata.item_class->item_style = "full";
    -viewdata.item_class->func.text_get = NULL;
    -viewdata.item_class->func.content_get = __get_item_content;
    -viewdata.item_class->func.state_get = NULL;
    -viewdata.item_class->func.del = NULL;
    +genlist = elm_genlist_add(ad->nf);
    +elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
    +evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    +evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
     
  2. -

    The genlist is filled with rule items and its descriptions. To append items to the genlist, the elm_genlist_item_append() function is invoked for each Eina_List item.

    +

    The genlist is filled with rule items. To append items to the genlist, the elm_genlist_item_append() function is invoked for each Eina_List item.

     // For each rule
     for (index = RULE_FIRST; index < RULE_LAST; index++) {
    -   /* Rule name item */
    -   if (ruleinfo_arr[index].result == CONTEXT_TRIGGER_ERROR_NONE) {
    -      elm_genlist_item_append(genlist, itc_name, (void *) &ruleinfo_arr[index], NULL, ELM_GENLIST_ITEM_NONE, gl_selected_cb, NULL);
    -   } else {
    -      elm_genlist_item_append(genlist, itc_name, (void *) &ruleinfo_arr[index], NULL, ELM_GENLIST_ITEM_NONE, gl_disabled_selected_cb, ad);
    -   }
    -
    -   /* Rule description item */
    -   Elm_Object_Item *item = elm_genlist_item_append(genlist, itc_description, (void *) &ruleinfo_arr[index], NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
    -   elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
    +   /* Rule item */
    +   elm_genlist_item_append(genlist, itc, (void *)&ruleinfo_arr[index], NULL, ELM_GENLIST_ITEM_NONE, gl_selected_cb, ad);
     }
     
  3. -

    The application's rule_info structure containing its rule information such as name, description, and so on. It is later passed on to the previously defined callback function. The following example shows the gl_text_name_get_cb, the gl_text_description_get_cb, the gl_content_get_cb callback function. Rule information is retrieved from the parameter and used to create the item layout.

    +

    The application's rule_info structure containing its rule information such as name, description, and so on. It is later passed on to the previously defined callback function. The following example shows the gl_text_get_cb, and the gl_content_get_cb callback function. Rule information is retrieved from the parameter and used to create the item layout.

    -static char *gl_text_name_get_cb(void *data, Evas_Object * obj, const char *part)
    +static char *gl_text_get_cb(void *data, Evas_Object * obj, const char *part)
     {
        rule_info_s *info = (rule_info_s *) data;
     
        if (!strcmp(part, "elm.text"))
           return strdup(info->name);
    -
    -   return NULL;
    -}
    -
    -static char *gl_text_description_get_cb(void *data, Evas_Object * obj, const char *part)
    -{
    -   rule_info_s *info = (rule_info_s *) data;
    -
    -   if (!strcmp(part, "elm.text.multiline"))
    +   else if (!strcmp(part, "elm.text.multiline"))
           return strdup(info->description);
     
        return NULL;
    @@ -247,26 +217,30 @@ static Evas_Object *gl_content_get_cb(void *data, Evas_Object * obj, const char
     
-

When a genlist item or a check button is clicked, corresponding rule will be enabled or disabled.

+

When a genlist item or a check button is clicked, corresponding rule will be enabled or disabled. If the user taps an rule item which fails to be added for some reasons, an error popup will be shown to indicate the reasons.

-static void gl_selected_cb(void *data EINA_UNUSED, Evas_Object * obj EINA_UNUSED, void *event_info)
+static void gl_selected_cb(void *data, Evas_Object * obj EINA_UNUSED, void *event_info)
 {
    Elm_Object_Item *it = (Elm_Object_Item *) event_info;
-   int error = CONTEXT_TRIGGER_ERROR_NONE;
-
-   rule_info_s *info = elm_object_item_data_get(it);
    elm_genlist_item_selected_set(it, false);
 
-   Evas_Object *check = elm_object_item_part_content_get(it, "elm.swallow.end");
+   rule_info_s *info = elm_object_item_data_get(it);
 
-   if (elm_check_state_get(check)) {
-      error = disable_rule(info->id);
-      if (error == CONTEXT_TRIGGER_ERROR_NONE)
-         elm_check_state_set(check, !info->enabled);
+   if (info->result == CONTEXT_TRIGGER_ERROR_NONE) {
+      int error = CONTEXT_TRIGGER_ERROR_NONE;
+      Evas_Object *check = elm_object_item_part_content_get(it, "elm.swallow.end");
+
+      if (elm_check_state_get(check)) {
+         error = disable_rule(info->id);
+         if (error == CONTEXT_TRIGGER_ERROR_NONE)
+            elm_check_state_set(check, !info->enabled);
+      } else {
+         error = enable_rule(info->id);
+         if (error == CONTEXT_TRIGGER_ERROR_NONE)
+            elm_check_state_set(check, !info->enabled);
+      }
    } else {
-      error = enable_rule(info->id);
-      if (error == CONTEXT_TRIGGER_ERROR_NONE)
-         elm_check_state_set(check, !info->enabled);
+      create_error_popup(data, info);
    }
 }
 
@@ -285,6 +259,42 @@ static void check_changed_cb(void *data, Evas_Object * obj, void *event_info EIN
          elm_check_state_set(obj, !info->enabled);
    }
 }
+
+static void create_error_popup(appdata_s * ad, void *data)
+{
+   rule_info_s *info = (rule_info_s *) data;
+
+   char *err_msg = NULL;
+
+   switch (info->result) {
+   case CONTEXT_TRIGGER_ERROR_PERMISSION_DENIED:
+      err_msg = ERR_MSG_PERMISSION_DENIED;
+      break;
+   case CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED:
+      err_msg = ERR_MSG_NOT_SUPPORTED;
+      break;
+   case CONTEXT_TRIGGER_ERROR_INVALID_RULE:
+      err_msg = ERR_MSG_INVALID_RULE;
+      break;
+   default:
+      err_msg = ERR_MSG_DEFAULT;
+      break;
+   }
+
+   Evas_Object *popup = elm_popup_add(ad->win);
+   elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
+   eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
+   elm_object_part_text_set(popup, "title,text", info->name);
+
+   elm_object_text_set(popup, err_msg);
+
+   Evas_Object *btn = elm_button_add(popup);
+   elm_object_style_set(btn, "popup");
+   elm_object_text_set(btn, "OK");
+   elm_object_part_content_set(popup, "button1", btn);
+   evas_object_smart_callback_add(btn, "clicked", popup_btn_clicked_cb, popup);
+   evas_object_show(popup);
+}