Kaskit: Add to unistall the package 82/74182/3
authorSungbae Yoo <sungbae.yoo@samsung.com>
Mon, 13 Jun 2016 02:20:45 +0000 (11:20 +0900)
committerSungbae Yoo <sungbae.yoo@samsung.com>
Mon, 13 Jun 2016 07:30:17 +0000 (16:30 +0900)
Change-Id: I4726d5bc15de7f687fc6f45df90f399a444a9eed
Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
zone/kaskit/CMakeLists.txt
zone/kaskit/include/conf.h
zone/kaskit/include/kaskit.h
zone/kaskit/res/edje/app_icon.edc [moved from zone/kaskit/res/edc_resource/app_icon.edc with 64% similarity]
zone/kaskit/res/edje/launcher.edc [moved from zone/kaskit/res/edc_resource/launcher.edc with 100% similarity]
zone/kaskit/res/edje/org.tizen.kaskit.edc [moved from zone/kaskit/res/org.tizen.kaskit.edc with 89% similarity]
zone/kaskit/src/main.c
zone/kaskit/src/ui.c
zone/kaskit/src/widget.c

index 328fee2..38189e3 100644 (file)
@@ -33,9 +33,9 @@ TARGET_LINK_LIBRARIES(${PKG_NAME} ${launcher_pkgs_LIBRARIES} zone)
 #Create edj file
 ADD_CUSTOM_TARGET(org.tizen.kaskit.edj
        COMMAND edje_cc -no-save -id ${CMAKE_CURRENT_SOURCE_DIR}/res/images
-       ${CMAKE_CURRENT_SOURCE_DIR}/res/org.tizen.kaskit.edc
+       ${CMAKE_CURRENT_SOURCE_DIR}/res/edje/org.tizen.kaskit.edc
        ${CMAKE_BINARY_DIR}/org.tizen.kaskit.edj
-       DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/res/org.tizen.kaskit.edc)
+       DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/res/edje/org.tizen.kaskit.edc)
 
 ADD_DEPENDENCIES(${PROJECT_NAME} org.tizen.kaskit.edj)
 INSTALL(FILES ${CMAKE_BINARY_DIR}/org.tizen.kaskit.edj DESTINATION ${APP_INSTALL_PREFIX}/${PKG_NAME}/res)
index b7acbb6..4783f48 100644 (file)
@@ -32,5 +32,6 @@
 #define ICON_SIZE_H            ((1060) * (RESOLUTION_SCALE_H) / 5)
 
 #define ALLOWED_ICON_DRAG_DISTANCE     100
+#define LONG_PRESS_TIME                0.75
 
 #endif /* CONF_H_ */
index 9311889..be33218 100644 (file)
@@ -51,9 +51,10 @@ typedef struct {
 } uidata_s;
 
 void _create_kaskit_window(const char* krate_name);
-void _create_app_icon(const char* pkg_id, const char* app_id, const char* label, const char* icon);
+void _create_app_icon(const char* pkg_id, const char* app_id, const char* label, const char* icon, bool removable);
 void _destroy_app_icon(const char* pkg_id);
 
 void _icon_clicked_cb(const char *app_id);
+void _icon_uninstalled_cb(const char *app_id);
 
 #endif /* __KASKIT_H__ */
similarity index 64%
rename from zone/kaskit/res/edc_resource/app_icon.edc
rename to zone/kaskit/res/edje/app_icon.edc
index 81ce600..07c2489 100755 (executable)
@@ -212,104 +212,64 @@ group { name: "icon";
                        target: "icon_touch";
                        transition: LINEAR 0.1;
                }
-       /*
-           program { name: "uninstall_button_show_ani";
-               signal: "uninstall_btn_show_ani";
-               source: SIGNAL_SOURCE;
-               action: STATE_SET "show" 0.0;
-               target: "uninstall_btn";
-               transition: DECELERATE ANIMATION_RESIZE_TIME;
-           }
-           program {
-               name: "uninstall_button_show";
-               signal: SIGNAL_UNINSTALL_BUTTON_SHOW;
-               source: SIGNAL_SOURCE;
-               action: STATE_SET "show" 0.0;
-               target: "uninstall_btn";
-           }
-           program {
-               name: "uninstall_button_hide_ani";
-               signal: SIGNAL_UNINSTALL_BUTTON_HIDE_ANI;
-               source: SIGNAL_SOURCE;
-               action: STATE_SET "default" 0.0;
-               target: "uninstall_btn";
-               transition: DECELERATE ANIMATION_RESIZE_TIME;
-           }
-           program {
-               name: "uninstall_button_hide";
-               signal: SIGNAL_UNINSTALL_BUTTON_HIDE;
-               source: SIGNAL_SOURCE;
-               action: STATE_SET "default" 0.0;
-               target: "uninstall_btn";
-           }
-           program {
-               name: "uninstall_button_clicked";
-               signal: "mouse,clicked,1";
-               source: "uninstall_btn";
-               action: SIGNAL_EMIT SIGNAL_UNINSTALL_BUTTON_CLICKED SIGNAL_SOURCE;
-           }
-           program {
-               name: "uninstall_button_mouse_down";
-               signal: "mouse,down,1";
-               source: "uninstall_btn";
-               action: STATE_SET "press" 0.0;
-               target: "uninstall_btn";
-               transition: DECELERATE ANIMATION_RESIZE_TIME;
-           }
-           program {
-               name: "uninstall_button_mouse_up";
-               signal: "mouse,up,1";
-               source: "uninstall_btn";
-               action: STATE_SET "show" 0.0;
-               target: "uninstall_btn";
-               transition: DECELERATE ANIMATION_RESIZE_TIME;
-           }
-           program {
-               name: "icon_badge_show";
-               signal: SIGNAL_BADGE_SHOW;
-               source: SIGNAL_SOURCE;
-               action: STATE_SET "show" 0.0;
-               target: "icon_badge";
-               target: "badge_text";
-           }
-           program {
-               name: "icon_badge_hide";
-               signal: SIGNAL_BADGE_HIDE;
-               source: SIGNAL_SOURCE;
-               action: STATE_SET "default" 0.0;
-               target: "icon_badge";
-               target: "badge_text";
-           }
-           program {
-               name: "icon_disable";
-               signal: SIGNAL_ICON_DISABLE;
-               source: SIGNAL_SOURCE;
-               action: STATE_SET "disable" 0.0;
-               target: "app_icon_disable";
-               target: "icon_name";
-           }
-           program {
-               name: "icon_enable";
-               signal: SIGNAL_ICON_ENABLE;
-               source: SIGNAL_SOURCE;
-               action: STATE_SET "default" 0.0;
-               target: "icon_name";
-               target: "app_icon_disable";
-           }
-           program {
-               name: "icon_picked";
-               signal: SIGNAL_ICON_NAME_HIDE;
-               source: SIGNAL_SOURCE;
-               action: STATE_SET "hide" 0.0;
-               target: "icon_name";
-           }
-           program {
-               name: "icon_drop";
-               signal: SIGNAL_ICON_NAME_SHOW;
-               source: SIGNAL_SOURCE;
-               action: STATE_SET "default" 0.0;
-               target: "icon_name";
-           }
-       */
+               program { name: "uninstall_button_show";
+                       signal: "uninstall_button_show";
+                       source: "source";
+                       action: STATE_SET "show" 0.0;
+                       target: "uninstall_btn";
+               }
+               program { name: "uninstall_button_hide";
+                       signal: "uninstall_button_hide";
+                       source: "source";
+                       action: STATE_SET "default" 0.0;
+                       target: "uninstall_btn";
+               }
+               program { name: "uninstall_button_clicked";
+                       signal: "mouse,clicked,1";
+                       source: "uninstall_btn";
+                       action: SIGNAL_EMIT "uninstall_button_clicked" "source";
+               }
+               program { name: "uninstall_button_mouse_down";
+                       signal: "mouse,down,1";
+                       source: "uninstall_btn";
+                       action: STATE_SET "press" 0.0;
+                       target: "uninstall_btn";
+                       transition: DECELERATE 0.4;
+               }
+               program { name: "uninstall_button_mouse_up";
+                       signal: "mouse,up,1";
+                       source: "uninstall_btn";
+                       action: STATE_SET "show" 0.0;
+                       target: "uninstall_btn";
+                       transition: DECELERATE 0.4;
+               }
+               program { name: "icon_badge_show";
+                       signal: "icon_badge_show";
+                       source: "source";
+                       action: STATE_SET "show" 0.0;
+                       target: "icon_badge";
+                       target: "badge_text";
+               }
+               program { name: "icon_badge_hide";
+                       signal: "icon_badge_hide";
+                       source: "source";
+                       action: STATE_SET "default" 0.0;
+                       target: "icon_badge";
+                       target: "badge_text";
+               }
+               program { name: "icon_disable";
+                       signal: "icon_disable";
+                       source: "source";
+                       action: STATE_SET "disable" 0.0;
+                       target: "app_icon_disable";
+                       target: "icon_name";
+               }
+               program { name: "icon_enable";
+                       signal: "icon_enable";
+                       source: "source";
+                       action: STATE_SET "default" 0.0;
+                       target: "icon_name";
+                       target: "app_icon_disable";
+               }
        }
-}
\ No newline at end of file
+}
similarity index 89%
rename from zone/kaskit/res/org.tizen.kaskit.edc
rename to zone/kaskit/res/edje/org.tizen.kaskit.edc
index c295840..b666153 100755 (executable)
@@ -17,6 +17,6 @@
 
 collections {
        base_scale: 1.8;
-       #include "./edc_resource/launcher.edc"
-       #include "./edc_resource/app_icon.edc"
+       #include "launcher.edc"
+       #include "app_icon.edc"
 }
index 0c848d8..2ee20d1 100644 (file)
@@ -27,10 +27,22 @@ static zone_package_proxy_h __zone_pkg;
 static zone_app_proxy_h __zone_app;
 static zone_manager_h __zone_mgr;
 
+static bool __pkg_is_remvable(const char* pkg_id) {
+       bool removable = false;
+
+       package_info_h pkg_h;
+
+       zone_package_proxy_get_package_info(__zone_pkg, pkg_id, &pkg_h);
+       package_info_is_removable_package(pkg_h, &removable);
+       package_info_destroy(pkg_h);
+
+       return removable;
+}
+
 static bool __get_app_info_cb(app_info_h app_h, void* user_data)
 {
        char* pkg_id, *app_id, *app_label = NULL, *app_icon = NULL;
-       bool nodisplay = false;
+       bool nodisplay = true, removable = false;
 
        app_info_is_nodisplay(app_h, &nodisplay);
        if (nodisplay)
@@ -42,8 +54,9 @@ static bool __get_app_info_cb(app_info_h app_h, void* user_data)
                app_info_get_app_id(app_h, &app_id);
                app_info_get_label(app_h, &app_label);
                app_info_get_icon(app_h, &app_icon);
+               removable = __pkg_is_remvable(pkg_id);
 
-               _create_app_icon(pkg_id, app_id, app_label, app_icon);
+               _create_app_icon(pkg_id, app_id, app_label, app_icon, removable);
                free(app_id);
                if (app_label != NULL) {
                        free(app_label);
@@ -108,7 +121,11 @@ static void __toast_callback_cb(void *data, Evas_Object *obj)
 void _icon_clicked_cb(const char *app_id)
 {
        zone_app_proxy_launch(__zone_app, app_id);
-       ui_app_exit();
+}
+
+void _icon_uninstalled_cb(const char *pkg_id)
+{
+       zone_package_proxy_uninstall(__zone_pkg, pkg_id);
 }
 
 static bool __app_create(void *data)
index cb3c0bb..d80c456 100644 (file)
@@ -23,6 +23,8 @@
 static uidata_s ud = {0, };
 
 static int __num_of_apps = 0;
+static bool __is_edit_mode = false;
+static Ecore_Timer* __app_icon_long_press_timer = NULL;
 
 static void __block_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
 {
@@ -72,6 +74,22 @@ static char* __get_res_path(const char* file)
        return strdup(edj_path);
 }
 
+static void __back_key_cb(void *data , Evas_Object *obj , void *event_info)
+{
+        Evas_Object* icon;
+        Eina_List* i;
+
+       if (__is_edit_mode) {
+               __is_edit_mode = false;
+
+               EINA_LIST_FOREACH(ud.app_icon_list, i, icon) {
+                       elm_object_signal_emit(icon, "uninstall_button_hide", "source");
+               }
+       } else {
+               ui_app_exit();
+       }
+}
+
 void _create_kaskit_window(const char *krate_name)
 {
        ud.edj_path = __get_res_path(PACKAGE ".edj");
@@ -79,42 +97,89 @@ void _create_kaskit_window(const char *krate_name)
        ud.conform = _create_conformant(ud.win);
        ud.layout = _create_layout(ud.conform, ud.edj_path, "main_window");
        elm_object_content_set(ud.conform, ud.layout);
+       eext_object_event_callback_add(ud.win, EEXT_CALLBACK_BACK, __back_key_cb, NULL);
 
        elm_object_signal_callback_add(ud.layout, "bg_clicked", "layout", __block_clicked_cb, NULL);
 
        __set_kaskit_layout(krate_name);
 
        evas_object_show(ud.win);
+
        return;
 }
 
+static Eina_Bool __app_icon_long_press_cb(void *data)
+{
+       Evas_Object* icon;
+       Eina_List* i;
+
+       EINA_LIST_FOREACH(ud.app_icon_list, i, icon) {
+               if (evas_object_data_get(icon, "removable")) {
+                       elm_object_signal_emit(icon, "uninstall_button_show", "source");
+               }
+       }
+
+       __is_edit_mode = true;
+
+       return ECORE_CALLBACK_CANCEL;
+}
+
 int __icon_down_x, __icon_down_y;
 static void __app_icon_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) {
        Evas_Event_Mouse_Up* ev = event_info;
 
        __icon_down_x = ev->output.x;
        __icon_down_y = ev->output.y;
+
+       __app_icon_long_press_timer = ecore_timer_add(LONG_PRESS_TIME, __app_icon_long_press_cb, NULL);
+}
+
+static void __app_icon_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+       Evas_Event_Mouse_Up* ev = event_info;
+
+       int distance_x = (ev->output.x - __icon_down_x);
+       int distance_y = (ev->output.y - __icon_down_y);
+        int distance = distance_x * distance_x + distance_y * distance_y;
+
+       if (distance > ALLOWED_ICON_DRAG_DISTANCE) {
+               if (__app_icon_long_press_timer != NULL) {
+                       ecore_timer_del(__app_icon_long_press_timer);
+                       __app_icon_long_press_timer = NULL;
+               }
+       }
 }
 
 static void __app_icon_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
 {
        Evas_Event_Mouse_Up* ev = event_info;
+
        int distance_x = (ev->output.x - __icon_down_x);
        int distance_y = (ev->output.y - __icon_down_y);
         int distance = distance_x * distance_x + distance_y * distance_y;
 
-       if (distance <= ALLOWED_ICON_DRAG_DISTANCE) {
-               _icon_clicked_cb(data);
+       if (distance <= ALLOWED_ICON_DRAG_DISTANCE && !__is_edit_mode) {
+               _icon_clicked_cb(evas_object_data_get(obj, "id"));
+       }
+
+       if (__app_icon_long_press_timer != NULL) {
+               ecore_timer_del(__app_icon_long_press_timer);
+               __app_icon_long_press_timer = NULL;
        }
-       free(data);
 }
 
 static void __app_icon_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
 {
+       free(evas_object_data_get(obj, "id"));
        free(evas_object_data_get(obj, "package"));
 }
 
-void _create_app_icon(const char* pkg_id, const char* app_id, const char* label, const char* icon)
+static void __app_icon_uninstall_btn_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
+{
+       _icon_uninstalled_cb(evas_object_data_get(obj, "package"));
+}
+
+void _create_app_icon(const char* pkg_id, const char* app_id, const char* label, const char* icon, bool removable)
 {
        char string[1024] = {0, }, *default_icon;
        Evas_Object *icon_layout;
@@ -142,11 +207,16 @@ void _create_app_icon(const char* pkg_id, const char* app_id, const char* label,
 
        elm_object_part_content_set(icon_layout, "icon_content", icon_image);
 
+       evas_object_data_set(icon_layout, "id", strdup(app_id));
        evas_object_data_set(icon_layout, "package", strdup(pkg_id));
+       evas_object_data_set(icon_layout, "removable", (const void*)removable);
 
        evas_object_event_callback_add(icon_layout, EVAS_CALLBACK_DEL, __app_icon_del_cb, NULL);
        evas_object_event_callback_add(icon_layout, EVAS_CALLBACK_MOUSE_DOWN, __app_icon_down_cb, NULL);
-       evas_object_event_callback_add(icon_layout, EVAS_CALLBACK_MOUSE_UP, __app_icon_up_cb, strdup(app_id));
+       evas_object_event_callback_add(icon_layout, EVAS_CALLBACK_MOUSE_MOVE, __app_icon_move_cb, NULL);
+       evas_object_event_callback_add(icon_layout, EVAS_CALLBACK_MOUSE_UP, __app_icon_up_cb, NULL);
+
+       elm_object_signal_callback_add(icon_layout, "uninstall_button_clicked", "source", __app_icon_uninstall_btn_clicked_cb, NULL);
 
        elm_table_pack(ud.app_view, icon_layout, __num_of_apps % 3, __num_of_apps / 3, 1, 1);
        evas_object_size_hint_min_set(ud.app_view, 0, (__num_of_apps / 3 + 1) * ICON_SIZE_H);
@@ -158,6 +228,9 @@ void _create_app_icon(const char* pkg_id, const char* app_id, const char* label,
        evas_object_show(icon_image);
        evas_object_show(icon_layout);
 
+       if (__is_edit_mode && removable) {
+               elm_object_signal_emit(icon_layout, "uninstall_button_show", "source");
+       }
 }
 
 void _destroy_app_icon(const char* pkg_id)
index dbd9eb0..fee085b 100644 (file)
@@ -54,8 +54,6 @@ Evas_Object *_create_win(const char *package)
 
        evas_object_smart_callback_add(win, "delete,request", __win_delete_request_cb, NULL);
 
-       eext_object_event_callback_add(win, EEXT_CALLBACK_BACK, __win_delete_request_cb, NULL);
-
        return win;
 }