powerkey popup : add power off image for wearable device 52/92552/2 accepted/tizen/3.0/mobile/20161028.143138 accepted/tizen/3.0/tv/20161028.143450 accepted/tizen/3.0/wearable/20161028.150818 accepted/tizen/common/20161017.170440 accepted/tizen/mobile/20161017.233939 accepted/tizen/tv/20161017.233947 accepted/tizen/wearable/20161017.234005 submit/tizen/20161017.110416 submit/tizen_3.0/20161028.062323 submit/tizen_3.0/20161028.092423 submit/tizen_3.0_common/20161104.104000
authorchangjoo.lee <changjoo.lee@samsung.com>
Mon, 17 Oct 2016 10:23:51 +0000 (19:23 +0900)
committerchangjoo.lee <changjoo.lee@samsung.com>
Mon, 17 Oct 2016 10:29:40 +0000 (19:29 +0900)
Change-Id: I304c7cdd33b4f7da46669a23760374ba26932ffd
Signed-off-by: changjoo.lee <changjoo.lee@samsung.com>
data/saving_device_options_power_off.png [new file with mode: 0755]
packaging/system-servant.spec
src/powerkey/CMakeLists.txt
src/powerkey/powerkey-wearable.c

diff --git a/data/saving_device_options_power_off.png b/data/saving_device_options_power_off.png
new file mode 100755 (executable)
index 0000000..4997109
Binary files /dev/null and b/data/saving_device_options_power_off.png differ
index 52f334f..67ac42a 100755 (executable)
@@ -366,6 +366,7 @@ rm -rf %{buildroot}
 %if "%{?profile}" == "wearable"
 %{TZ_SYS_RO_APP}/org.tizen.powerkey-syspopup/res/circle_btn_check.png
 %{TZ_SYS_RO_APP}/org.tizen.powerkey-syspopup/res/circle_btn_delete.png
+%{TZ_SYS_RO_APP}/org.tizen.powerkey-syspopup/res/saving_device_options_power_off.png
 %endif
 %endif
 
index 5199168..7b102ca 100755 (executable)
@@ -74,6 +74,7 @@ INSTALL(FILES ${CMAKE_SOURCE_DIR}/src/powerkey/${PKGNAME}.xml DESTINATION ${MANI
 IF(PROFILE STREQUAL wearable)
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/circle_btn_check.png DESTINATION ${RESDIR})
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/circle_btn_delete.png DESTINATION ${RESDIR})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/saving_device_options_power_off.png DESTINATION ${RESDIR})
 ENDIF()
 
 IF(PROFILE STREQUAL mobile)
index ee882a5..aea74a7 100755 (executable)
@@ -71,9 +71,6 @@ static char *menu_its[] = {
        "IDS_ST_BODY_FLIGHT_MODE"
 };
 
-static int MENU_SIZE =
-       sizeof(menu_its) / sizeof(menu_its[0]);
-
 static char *
 _gl_menu_title_text_get(void *data, Evas_Object *obj, const char *part)
 {
@@ -84,34 +81,44 @@ _gl_menu_title_text_get(void *data, Evas_Object *obj, const char *part)
 }
 
 static char *
-_gl_menu_text_get(void *data, Evas_Object *obj, const char *part)
+_gl_menu_text_get_poweroff(void *data, Evas_Object *obj, const char *part)
 {
-       Item_Data *id = (Item_Data *)data;
-       int index = id->index;
+       if (!strncmp(part, "elm.text", sizeof("elm.text")))
+               return strdup(_(menu_its[0]));
+
+       return NULL;
+}
 
+static char *
+_gl_menu_text_get_airplane(void *data, Evas_Object *obj, const char *part)
+{
        if (!strncmp(part, "elm.text", sizeof("elm.text")))
-               return strdup(_(menu_its[index]));
+               return strdup(_(menu_its[1]));
 
        return NULL;
 }
 
 static void
-_gl_sel_cb(void *data, Evas_Object *obj, void *event_info)
+_gl_sel_poweroff_cb(void *data, Evas_Object *obj, void *event_info)
 {
        const struct popup_ops *ops = data;
+
+       _D("poweroff is chosen");
+       elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
+       poweroff_clicked(ops);
+
+       return;
+}
+
+static void
+_gl_sel_airplane_cb(void *data, Evas_Object *obj, void *event_info)
+{
        bundle *b = NULL;
-       Elm_Object_Item *it = (Elm_Object_Item *)event_info;
-       Item_Data *id = (Item_Data *)elm_object_item_data_get(it);
        int is_flight_mode = 0;
        int ret = 0;
 
        elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
 
-       if (id->index == 0) {
-               _D("poweroff is chosen");
-               poweroff_clicked(ops);
-       }
-       else if (id->index == 1) {
                _D("flight mode is chosen");
                ret = vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &is_flight_mode);
                if (ret < 0) {
@@ -123,26 +130,22 @@ _gl_sel_cb(void *data, Evas_Object *obj, void *event_info)
                        load_simple_popup(b, &flightmode_ops);
                else
                        set_flight_icon(!is_flight_mode);
-       } else
-               _E("Wrong button is pressed");
 
        return;
 }
 
-Evas_Object *_gl_menu_contents_get(void *data, Evas_Object *obj, const char *part)
+static Evas_Object *_gl_menu_contents_get_airplane(void *data, Evas_Object *obj, const char *part)
 {
-       Evas_Object *check = NULL;
+       Evas_Object *check;
        Powerkey_Item_Data *id = data;
-       int index = id->index;
        int is_value = 0;
        int ret = 0;
 
        if (!strncmp(part, "elm.icon", sizeof("elm.icon"))) {
-               switch (index) {
-               case POWERKEY_FLIGHT_MODE:
+               _D("index = AIRPLANE_MODE");
                        check = elm_check_add(obj);
-                       if (check == NULL) {
-                               _E("Error in adding check button");
+               if (!check) {
+                       _E("BAD check!");
                                return NULL;
                        }
                        flight_icon = check;
@@ -159,18 +162,29 @@ Evas_Object *_gl_menu_contents_get(void *data, Evas_Object *obj, const char *par
                        evas_object_propagate_events_set(check, EINA_TRUE);
 
                        id->check = check;
-                       break;
+               return check;
+       } else
+               return NULL;
+}
 
-               case POWERKEY_POWER_OFF:
-                       break;
+static Evas_Object *_gl_menu_contents_get_poweroff(void *data, Evas_Object *obj, const char *part)
+{
+       Evas_Object *img;
+       Evas_Coord w, h;
 
-               default:
-                       _E("Invalid index(%d)", index);
-                       break;
+       if (!strncmp(part, "elm.icon", sizeof("elm.icon"))) {
+               _D("index = POWEROFF_MODE");
+               img = elm_image_add(obj);
+               if (!img) {
+                       _E("BAD image!");
+                       return NULL;
                }
-       }
-
-       return check;
+               elm_image_file_set(img, RESDIR"/saving_device_options_power_off.png", NULL);
+               elm_image_object_size_get(img, &w, &h);
+               evas_object_size_hint_min_set(img, w, h);
+               return img;
+       } else
+               return NULL;
 }
 
 static void pm_state_changed(keynode_t *key, void *data)
@@ -319,9 +333,10 @@ create_list_view(appdata_s *application_info, const struct popup_ops *ops)
        Elm_Object_Item *nf_it;
        Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
        Elm_Genlist_Item_Class *ttc = elm_genlist_item_class_new();
+       Elm_Genlist_Item_Class *utc = elm_genlist_item_class_new();
        Elm_Genlist_Item_Class *ptc = elm_genlist_item_class_new();
        Item_Data *id;
-       int i = 0;
+       int i;
 
        ad = (appdata_s *)application_info;
        if (ad == NULL) return;
@@ -337,30 +352,41 @@ create_list_view(appdata_s *application_info, const struct popup_ops *ops)
        ttc->func.text_get = _gl_menu_title_text_get;
        ttc->func.del = NULL;
 
-       itc->item_style = "1text.1icon.1";
-       itc->func.text_get = _gl_menu_text_get;
-       itc->func.content_get = _gl_menu_contents_get;
+       itc->item_style = "1text.1icon";
+       itc->func.text_get = _gl_menu_text_get_poweroff;
+       itc->func.content_get = _gl_menu_contents_get_poweroff;
        itc->func.del = NULL;
 
        ptc->item_style = "padding";
        ptc->func.del = NULL;
 
+       utc->item_style = "1text.1icon.1";
+       utc->func.text_get = _gl_menu_text_get_airplane;
+       utc->func.content_get = _gl_menu_contents_get_airplane;
+       utc->func.del = NULL;
+
+       ptc->item_style = "padding";
+       ptc->func.del = NULL;
+
        /* back key */
        eext_object_event_callback_add(genlist, EEXT_CALLBACK_BACK, event_back_key_up, (void*)ops);
        elm_genlist_item_append(genlist, ttc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
 
-       _D("MENU_SIZE=%d", MENU_SIZE);
-       for (i = 0; i < MENU_SIZE; i++) {
-               _D("menu_its[%d] = %s", i, menu_its[i]);
-               id = calloc(sizeof(Item_Data), 1);
-               id->index = i;
-               id->item = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_cb, ops);
-       }
+       i = 0;
+       id = calloc(sizeof(Item_Data), 1);
+       id->index = i;
+       id->item = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_poweroff_cb, ops);
+
+       i++;
+       id = calloc(sizeof(Item_Data), 1);
+       id->index = i;
+       id->item = elm_genlist_item_append(genlist, utc, id, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_airplane_cb, ops);
 
        elm_genlist_item_append(genlist, ptc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
 
        elm_genlist_item_class_free(itc);
        elm_genlist_item_class_free(ttc);
+       elm_genlist_item_class_free(utc);
        elm_genlist_item_class_free(ptc);
 
        nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, "empty");