[OAPSAN-4721] Force close and uninstall buttons updated 35/233835/1
authorMichal Skorupinski <m.skorupinsk@samsung.com>
Tue, 19 May 2020 12:11:55 +0000 (14:11 +0200)
committerMichal Skorupinski <m.skorupinsk@samsung.com>
Tue, 19 May 2020 12:11:55 +0000 (14:11 +0200)
Change-Id: Icbbf3c380a89951819e93cbb7422b5c40de332ae
Signed-off-by: Michal Skorupinski <m.skorupinsk@samsung.com>
setting-appmgr/src/setting-appmgr-main.c
setting-appmgr/src/setting-appmgr-pkginfo.c

index f08032785efeff5aab1c72e175893fdc30359503..8ec7edd86de1d02a51827dca05fdfca7f7c52660 100644 (file)
@@ -658,7 +658,7 @@ static void _bottom_tabbar_layout_add(SettingAppMgr *ad)
                return;
        }
 
-       char *path = setting_get_resource_path("edje/setting-theme.edj");
+       const char *path = setting_get_resource_path("edje/setting-theme.edj");
        if (!path) {
                SETTING_TRACE_ERROR("Failed to load file: setting-theme.edj");
                return;
index 163aac3d875cbed3b37024c4bd6650719960ff4f..60779eca3e0c4ec7bf14bf4d1558217d0712003b 100755 (executable)
@@ -28,6 +28,9 @@
 #include "setting-appmgr-pkginfo-utils.h"
 #include "setting-appmgr-pkginfo.h"
 
+#define CLOSE_UNINSTALL_BUTTON_FORMAT_ENABLED  "<underline=single underline_color=#0A0E4AFF color=#0A0E4A>%s</underline>"
+#define CLOSE_UNINSTALL_BUTTON_FORMAT_DISABLED "<underline=single underline_color=#C3CAD2FF color=#C3CAD2>%s</underline>"
+
 setting_view setting_view_appmgr_pkginfo;
 
 typedef struct {
@@ -940,6 +943,43 @@ static int __package_move_finished2(uid_t target_uid, int req_id,
 
 /* Genlist item classes: */
 
+static Evas_Object *_add_no_bg_button(Evas_Object *parent_box, char *txt, SettingAppMgr_PkgInfo *pkg, Evas_Smart_Cb btn_click_cb)
+{
+       /* Force close button */
+       char buf[1024];
+       snprintf(buf, 1024, CLOSE_UNINSTALL_BUTTON_FORMAT_DISABLED,  txt);
+       Evas_Object *button = setting_create_button(parent_box, buf, "textbutton", btn_click_cb, pkg);
+       evas_object_size_hint_min_set(button, 179, 50);
+       evas_object_size_hint_max_set(button, 179, 50);
+       elm_object_text_set(button, buf);
+       elm_box_pack_end(parent_box, button);
+       return button;
+}
+
+static void _add_spacer(Evas_Object *parent_box)
+{
+       Evas_Object *spacer = evas_object_rectangle_add(evas_object_evas_get(parent_box));
+       evas_object_color_set(spacer, 255, 0, 0, 255);
+       evas_object_size_hint_min_set(spacer, 1280 - 40 * 2 - 29 - 179 * 2, 50); // screen width - margins - distance between buttons - button width
+       elm_box_pack_end(parent_box, spacer);
+}
+
+static void _no_bg_button_set_disabled(Evas_Object *button, char *text, Eina_Bool disabled)
+{
+       elm_object_disabled_set(button, disabled);
+       SETTING_TRACE_WARNING("TEXT: %s", text);
+
+       char buf[1024];
+       if (disabled) {
+               snprintf(buf, 1024, CLOSE_UNINSTALL_BUTTON_FORMAT_DISABLED,  text);
+       } else {
+               snprintf(buf, 1024, CLOSE_UNINSTALL_BUTTON_FORMAT_ENABLED,  text);
+       }
+
+       SETTING_TRACE_WARNING("BUTTON: %s", buf);
+       elm_object_text_set(button, buf);
+}
+
 Evas_Object *pkginfo_force_close_dis_uninst_content_get(
                void *data, Evas_Object *genlist, const char *part)
 {
@@ -947,6 +987,7 @@ Evas_Object *pkginfo_force_close_dis_uninst_content_get(
        SettingAppMgr_PkgInfo *pkg = NULL;
        int h = 0;
        Evas_Object *box = NULL;
+       char buf[1024] = {0,};
 
        setting_retvm_if(ad == NULL, NULL, "Data parameter is NULL");
        pkg = &ad->selected_pkg;
@@ -955,22 +996,17 @@ Evas_Object *pkginfo_force_close_dis_uninst_content_get(
 
        box = elm_box_add(genlist);
        elm_box_horizontal_set(box, EINA_TRUE);
-       elm_box_align_set(box, 0.0, 0.5);
-
-       /* Force close button */
-       ad->force_close_button = setting_create_button(box, _("Force close"),
-                                                                                               NULL, _force_close_cb, pkg);
+       elm_box_padding_set(box, 0, 0);
 
-       /* Disable/Enable button */
-       ad->uninstall_button = setting_create_button(box,
-                                                       _("IDS_ST_BUTTON_DISABLE_ABB"), NULL, NULL, pkg);
+       _add_spacer(box);
+       ad->force_close_button = _add_no_bg_button(box, _("Force close"), pkg, _force_close_cb);
+       ad->uninstall_button   = _add_no_bg_button(box, _("IDS_ST_BUTTON_DISABLE_ABB"), pkg, NULL);
 
        _setup_force_close_uninstall_buttons(ad);
 
-       elm_box_pack_end(box, ad->force_close_button);
-       elm_box_pack_end(box, ad->uninstall_button);
        evas_object_size_hint_min_get(ad->force_close_button, NULL, &h);
-       evas_object_size_hint_min_set(box, 0, h);
+       evas_object_size_hint_min_set(box, 1280, 72);
+       evas_object_size_hint_max_set(box, 1280, 72);
 
        return box;
 }
@@ -1024,10 +1060,8 @@ static void _setup_force_close_uninstall_buttons(SettingAppMgr *ad)
        Eina_List *cur = NULL;
        const char *appid = NULL;
 
-
        pkg = &ad->selected_pkg;
 
-
        /* Check if have running app */
        EINA_LIST_FOREACH(pkg->apps_in_package, cur, appid) {
                if (!appid)
@@ -1037,34 +1071,28 @@ static void _setup_force_close_uninstall_buttons(SettingAppMgr *ad)
                        continue;
                if (running_flag) {
                        SETTING_TRACE_DEBUG(
-                               "Found running app :%s in package %s", appid,
-                               pkg->id);
+                               "Found running app :%s in package %s", appid, pkg->id);
                        break;
                }
        }
 
-       elm_object_disabled_set(ad->force_close_button, !running_flag);
-
-       /* Disable/Enable button */
-       elm_object_disabled_set(ad->uninstall_button, EINA_TRUE);
+       _no_bg_button_set_disabled(ad->force_close_button,  _("Force close"), !running_flag);
 
        if (pkg->is_disable_supported) {
                if (pkg->is_disabled) {
-                       evas_object_smart_callback_add(ad->uninstall_button, "clicked",
-                                                                               _enable_cb, pkg);
-                       elm_object_text_set(ad->uninstall_button,
-                                                               _("IDS_ST_BUTTON_ENABLE_ABB3"));
+                       evas_object_smart_callback_add(ad->uninstall_button, "clicked", _enable_cb, pkg);
+                       _no_bg_button_set_disabled(ad->uninstall_button,  _("IDS_ST_BUTTON_ENABLE_ABB3"), EINA_FALSE);
                } else {
-                       evas_object_smart_callback_add(ad->uninstall_button, "clicked",
-                                                                                       _disable_cb, pkg);
+                       evas_object_smart_callback_add(ad->uninstall_button, "clicked", _disable_cb, pkg);
+                       _no_bg_button_set_disabled(ad->uninstall_button,  _("IDS_ST_BUTTON_DISABLE_ABB"), EINA_FALSE);
                }
-               elm_object_disabled_set(ad->uninstall_button, EINA_FALSE);
 
        } else if (pkg->is_removable) {
-               elm_object_text_set(ad->uninstall_button, _("IDS_ST_BUTTON_UNINSTALL"));
-               evas_object_smart_callback_add(ad->uninstall_button, "clicked",
-                                                                               _uninstall_cb, ad);
-               elm_object_disabled_set(ad->uninstall_button, EINA_FALSE);
+               evas_object_smart_callback_add(ad->uninstall_button, "clicked", _uninstall_cb, ad);
+               _no_bg_button_set_disabled(ad->uninstall_button, _("IDS_ST_BUTTON_UNINSTALL"), EINA_FALSE);
+
+       } else {
+               _no_bg_button_set_disabled(ad->uninstall_button, _("IDS_ST_BUTTON_DISABLE_ABB"), EINA_TRUE);
        }
 }