From: Michal Skorupinski Date: Tue, 19 May 2020 12:11:55 +0000 (+0200) Subject: [OAPSAN-4721] Force close and uninstall buttons updated X-Git-Tag: submit/tizen/20200525.022829~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f607ba3ed39e91bf7e0fc0c9fa07669b46a33538;p=profile%2Fcommon%2Fapps%2Fnative%2Fsettings.git [OAPSAN-4721] Force close and uninstall buttons updated Change-Id: Icbbf3c380a89951819e93cbb7422b5c40de332ae Signed-off-by: Michal Skorupinski --- diff --git a/setting-appmgr/src/setting-appmgr-main.c b/setting-appmgr/src/setting-appmgr-main.c index f080327..8ec7edd 100644 --- a/setting-appmgr/src/setting-appmgr-main.c +++ b/setting-appmgr/src/setting-appmgr-main.c @@ -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; diff --git a/setting-appmgr/src/setting-appmgr-pkginfo.c b/setting-appmgr/src/setting-appmgr-pkginfo.c index 163aac3..60779ec 100755 --- a/setting-appmgr/src/setting-appmgr-pkginfo.c +++ b/setting-appmgr/src/setting-appmgr-pkginfo.c @@ -28,6 +28,9 @@ #include "setting-appmgr-pkginfo-utils.h" #include "setting-appmgr-pkginfo.h" +#define CLOSE_UNINSTALL_BUTTON_FORMAT_ENABLED "%s" +#define CLOSE_UNINSTALL_BUTTON_FORMAT_DISABLED "%s" + 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); } }