From bd116d02d0f12802a0c01f9d67dfb1a38e4a4402 Mon Sep 17 00:00:00 2001 From: Zofia Abramowska Date: Thu, 1 Dec 2016 18:12:48 +0100 Subject: [PATCH] Add ui for wearable * Switch between mobile and wearable profiles * Add icons and edc file * Create different popup for wearable profile * Display appId/main appId instead of smack label Change-Id: I4fa609959525fc77f75d2b6fb7d5f39413e19006 --- CMakeLists.txt | 12 ++ packaging/askuser.spec | 12 +- src/agent/notification-daemon/CMakeLists.txt | 8 ++ src/agent/notification-daemon/GuiRunner.cpp | 73 ++++++++++-- src/agent/notification-daemon/GuiRunner.h | 2 + src/agent/notification-daemon/res/popup_custom.edc | 124 +++++++++++++++++++++ .../res/tw_ic_popup_btn_check.png | Bin 0 -> 1392 bytes .../res/tw_ic_popup_btn_delete.png | Bin 0 -> 1184 bytes 8 files changed, 220 insertions(+), 11 deletions(-) create mode 100644 src/agent/notification-daemon/res/popup_custom.edc create mode 100644 src/agent/notification-daemon/res/tw_ic_popup_btn_check.png create mode 100644 src/agent/notification-daemon/res/tw_ic_popup_btn_delete.png diff --git a/CMakeLists.txt b/CMakeLists.txt index e0d174b..0845f5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,18 @@ IF (BUILD_WITH_SYSTEMD_DAEMON) ADD_DEFINITIONS("-DBUILD_WITH_SYSTEMD_DAEMON") ENDIF (BUILD_WITH_SYSTEMD_DAEMON) +IF (NOTIFICATION_UI STREQUAL MOBILE) + ADD_DEFINITIONS("-DMOBILE_UI") +ELSEIF (NOTIFICATION_UI STREQUAL CIRCLE) + ADD_DEFINITIONS("-DCIRCLE_UI") +ENDIF (NOTIFICATION_UI) + +IF (RES_DIR) + ADD_DEFINITIONS("-DRES_DIR=\"${RES_DIR}\"") +ELSE (RES_DIR) + ADD_DEFINITIONS("-DRES_DIR=\"/usr/share/askuser/res/\"") +ENDIF (RES_DIR) + SET(TARGET_ASKUSER "askuser") SET(TARGET_ASKUSER_COMMON "askuser-common") SET(TARGET_PLUGIN_SERVICE "askuser-plugin-service") diff --git a/packaging/askuser.spec b/packaging/askuser.spec index e83a9b7..3048768 100644 --- a/packaging/askuser.spec +++ b/packaging/askuser.spec @@ -27,11 +27,18 @@ BuildRequires: pkgconfig(security-privilege-manager) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: coregl +BuildRequires: edje-bin %if !%{defined build_type} %define build_type RELEASE %endif +%if %{?profile} == "wearable" +%define notification_ui CIRCLE +%else +%define notification_ui MOBILE +%endif + %description Daemon allowing user to grant or deny acces for given application and privilege @@ -85,7 +92,9 @@ export LDFLAGS+="-Wl,--rpath=%{_libdir}" %cmake . \ -DCMAKE_BUILD_TYPE=%{?build_type} \ -DBUILD_WITH_SYSTEMD_DAEMON=%{?with_systemd_daemon} \ - -DCMAKE_VERBOSE_MAKEFILE=ON + -DCMAKE_VERBOSE_MAKEFILE=ON \ + -DNOTIFICATION_UI=%{?notification_ui} \ + -DRES_DIR="/usr/share/askuser/res" make %{?jobs:-j%jobs} %install @@ -152,6 +161,7 @@ systemctl restart cynara.service %endif /usr/share/locale/en/LC_MESSAGES/askuser.mo /usr/share/locale/pl/LC_MESSAGES/askuser.mo +/usr/share/askuser/res/* %files -n libaskuser-common %manifest libaskuser-common.manifest diff --git a/src/agent/notification-daemon/CMakeLists.txt b/src/agent/notification-daemon/CMakeLists.txt index 06b1e6d..b75cd5c 100644 --- a/src/agent/notification-daemon/CMakeLists.txt +++ b/src/agent/notification-daemon/CMakeLists.txt @@ -40,6 +40,14 @@ TARGET_LINK_LIBRARIES(${TARGET_ASKUSER_NOTIFICATION} -pie ) +ADD_CUSTOM_TARGET(popup_custom.edj + COMMAND edje_cc -no-save res/popup_custom.edc res/popup_custom.edj + DEPENDS res/popup_custom.edc + ) +ADD_DEPENDENCIES(${PROJECT_NAME} popup_custom.edj) + INSTALL(TARGETS ${TARGET_ASKUSER_NOTIFICATION} DESTINATION ${BIN_INSTALL_DIR}) +INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res/ DESTINATION ${RES_DIR} FILES_MATCHING PATTERN "*.png") +INSTALL(FILES res/popup_custom.edj DESTINATION ${RES_DIR}) ADD_SUBDIRECTORY(po) diff --git a/src/agent/notification-daemon/GuiRunner.cpp b/src/agent/notification-daemon/GuiRunner.cpp index ad63014..e4d03d7 100644 --- a/src/agent/notification-daemon/GuiRunner.cpp +++ b/src/agent/notification-daemon/GuiRunner.cpp @@ -26,6 +26,7 @@ #include #include #include +#include "Policy.h" namespace AskUser { @@ -134,11 +135,12 @@ void GuiRunner::addDismissFd(int fd, DissmissCb cb, void *data) void GuiRunner::initialize() { + char *popupTitle = dgettext(PROJECT_NAME, "SID_PRIVILEGE_REQUEST_DIALOG_TITLE"); + char *checkBoxText = dgettext(PROJECT_NAME, "SID_PRIVILEGE_REQUEST_DIALOG_CHECKBOX_ALWAYS"); elm_init(0, NULL); //placeholder - m_win = elm_win_add(NULL, dgettext(PROJECT_NAME, "SID_PRIVILEGE_REQUEST_DIALOG_TITLE"), - ELM_WIN_DOCK); + m_win = elm_win_add(NULL, popupTitle, ELM_WIN_DOCK); if (!m_win) { ALOGE("EFL : Failed to add window"); throw Exception("Elementary failed"); @@ -147,14 +149,14 @@ void GuiRunner::initialize() elm_win_override_set(m_win, EINA_TRUE); elm_win_alpha_set(m_win, EINA_TRUE); +#ifdef MOBILE_UI // popup m_popup = elm_popup_add(m_win); if (!m_popup) { ALOGE("EFL : Failed to add popup"); throw Exception("Elementary failed"); } - elm_object_part_text_set(m_popup, "title,text", dgettext(PROJECT_NAME, - "SID_PRIVILEGE_REQUEST_DIALOG_TITLE")); + elm_object_part_text_set(m_popup, "title,text", popupTitle); // box m_box = elm_box_add(m_popup); @@ -185,9 +187,8 @@ void GuiRunner::initialize() ALOGE("EFL : Failed to add checkbox"); throw Exception("Enlightement failed"); } - elm_object_part_content_set(m_popup, "checkbox1", m_checkbox); - elm_object_text_set(m_checkbox, dgettext(PROJECT_NAME, - "SID_PRIVILEGE_REQUEST_DIALOG_CHECKBOX_ALWAYS")); + elm_object_content_set(m_popup, m_checkbox); + elm_object_text_set(m_checkbox, checkBoxText); elm_check_state_set(m_checkbox, EINA_FALSE); evas_object_size_hint_align_set(m_checkbox, EVAS_HINT_FILL, 0.0); evas_object_show(m_checkbox); @@ -210,10 +211,61 @@ void GuiRunner::initialize() ALOGE("EFL : Failed to add allow button"); throw Exception("Enlightement failed"); } - elm_object_part_content_set(m_popup, "button3", m_allowButton); + elm_object_part_content_set(m_popup, "button2", m_allowButton); elm_object_text_set(m_allowButton, dgettext(PROJECT_NAME, "SID_PRIVILEGE_REQUEST_DIALOG_BUTTON_ALLOW")); +#elif defined(CIRCLE_UI) + Evas_Object *icon; + m_popup = elm_popup_add(m_win); + elm_object_style_set(m_popup, "circle"); + + m_layout = elm_layout_add(m_popup); + elm_layout_theme_set(m_layout, "layout", "popup", "content/circle/buttons2"); + elm_object_part_text_set(m_layout, "elm.text.title", popupTitle); + elm_object_content_set(m_popup, m_layout); + + m_layoutInner = elm_layout_add(m_layout); + elm_layout_file_set(m_layoutInner, RES_DIR"/popup_custom.edj", "popup_checkview_internal"); + evas_object_size_hint_weight_set(m_layoutInner, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_part_content_set(m_layout, "elm.swallow.content", m_layoutInner); + + m_content = elm_label_add(m_layoutInner); + elm_object_style_set(m_content, "popup/default"); + elm_label_line_wrap_set(m_content, ELM_WRAP_MIXED); + evas_object_size_hint_weight_set(m_content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_content, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_part_content_set(m_layoutInner, "label", m_content); + + + m_checkbox = elm_check_add(m_popup); + elm_object_style_set(m_checkbox, "popup"); + elm_object_text_set(m_checkbox, checkBoxText); + evas_object_size_hint_align_set(m_checkbox, EVAS_HINT_FILL, 0.0); + elm_object_part_content_set(m_layoutInner, "elm.swallow.end", m_checkbox); + evas_object_show(m_checkbox); + + m_allowButton = elm_button_add(m_popup); + elm_object_style_set(m_allowButton, "popup/circle/right"); + elm_object_part_content_set(m_popup, "button2", m_allowButton); + + icon = elm_image_add(m_allowButton); + elm_image_file_set(icon, RES_DIR"/tw_ic_popup_btn_check.png", NULL); + evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_part_content_set(m_allowButton, "elm.swallow.content", icon); + evas_object_show(icon); + + m_denyButton = elm_button_add(m_popup); + elm_object_style_set(m_denyButton, "popup/circle/left"); + elm_object_part_content_set(m_popup, "button1", m_denyButton); + + icon = elm_image_add(m_denyButton); + elm_image_file_set(icon, RES_DIR"/tw_ic_popup_btn_delete.png", NULL); + elm_object_part_content_set(m_denyButton, "elm.swallow.content", icon); + evas_object_show(icon); + + evas_object_show(m_popup); +#endif // callbacks evas_object_smart_callback_add(m_win, "unfocused", &GuiRunner::unfocused, this); evas_object_smart_callback_add(m_allowButton, "clicked", &GuiRunner::allowAnswerCb, this); @@ -229,12 +281,13 @@ NResponseType GuiRunner::popupRun(const std::string &app, const std::string &per initialize(); } m_running = true; - + std::string appId; + identifyApp(app, appId); // create message char *messageFormat = dgettext(PROJECT_NAME, "SID_PRIVILEGE_REQUEST_DIALOG_MESSAGE"); char buf[BUFSIZ]; int ret = std::snprintf(buf, sizeof(buf), messageFormat, - app.c_str(), + appId.c_str(), perm.c_str()); if (ret < 0) diff --git a/src/agent/notification-daemon/GuiRunner.h b/src/agent/notification-daemon/GuiRunner.h index c826c54..cd20823 100644 --- a/src/agent/notification-daemon/GuiRunner.h +++ b/src/agent/notification-daemon/GuiRunner.h @@ -69,6 +69,8 @@ private: Evas_Object *m_win = nullptr; Evas_Object *m_popup = nullptr; + Evas_Object *m_layout = nullptr; + Evas_Object *m_layoutInner = nullptr; Evas_Object *m_box = nullptr; Evas_Object *m_content = nullptr; Evas_Object *m_checkbox = nullptr; diff --git a/src/agent/notification-daemon/res/popup_custom.edc b/src/agent/notification-daemon/res/popup_custom.edc new file mode 100644 index 0000000..041572d --- /dev/null +++ b/src/agent/notification-daemon/res/popup_custom.edc @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +collections { + base_scale: 1.3; +//Height = 480 - (2 + 83 + 68) +group { name: "popup_checkview_internal"; + parts { + part { name: "label"; + scale: 1; + type: SWALLOW; + description { state: "default" 0.0; + fixed: 1 0; + rel2 { + relative: 1.0 0.0; + to_y: "end_field"; + } + } + } + part { name: "bottom_pad"; + type: SPACER; + scale: 1; + description { state: "default" 0.0; + align: 0.0 1.0; + min: 0 4; + fixed: 0 1; + rel1.relative: 0.0 1.0; + } + } + part { name: "pad_b"; + type: SPACER; + scale: 1; + description { state: "default" 0.0; + align: 0.0 1.0; + min: 0 90; + fixed: 0 1; + rel1 { + relative: 0.0 0.0; + to: "bottom_pad"; + } + rel2 { + relative: 1.0 0.0; + to: "bottom_pad"; + } + } + } + part { name: "left_pad"; + type: SPACER; + scale: 1; + description { state: "default" 0.0; + fixed: 1 0; + min: 16 0; + rel1 { + relative: 0.0 0.0; + } + rel2 { + relative: 0.0 1.0; + } + } + } + part { name: "right_pad"; + type: SPACER; + scale: 1; + description { state: "default" 0.0; + fixed: 1 0; + min: 16 0; + rel1 { + relative: 1.0 0.0; + } + rel2 { + relative: 1.0 1.0; + } + } + } + part { name: "end_field"; + type: SPACER; + scale: 1; + description { state: "default" 0.0; + align: 0.0 1.0; + min: 0 90; + max: 244 -1; + fixed: 0 1; + rel1 { + relative: 1.0 1.0; + to_x: "left_pad"; + to_y: "pad_b"; + } + rel2 { + relative: 0.0 1.0; + to_x: "right_pad"; + to_y: "pad_b"; + } + } + } + part { name: "elm.swallow.end"; + type: SWALLOW; + scale: 1; + description { state: "default" 0.0; + rel1.to: "end_field"; + rel2.to: "end_field"; + rel1 { + relative: 0.0 0.0; + } + rel2 { + relative: 1.0 1.0; + } + } + } + } +} +} diff --git a/src/agent/notification-daemon/res/tw_ic_popup_btn_check.png b/src/agent/notification-daemon/res/tw_ic_popup_btn_check.png new file mode 100644 index 0000000000000000000000000000000000000000..f20f62e7f8872c282aa2bb8135b3393de9dff42f GIT binary patch literal 1392 zcmbVMZA=?=7(aoHm&u?Sw6bZ=gJp@*-b=49cT(WEYgr@ZrEMH8e&BjN=%rk*-W|47 zRE8#2Hg)oWWeI}Gf*NCR(?pCirpdBpya;A7OSX)ez@~F!#QK6{!+3?3`GM?%m%ID_ z|IauP*+$`S^xk*p=%%G(N-k&>K;vw^M`&-0Z4kR23!EozIqp5!Fa$fk6RF)^Z{0id!v7Gb#%uY!KQT?pHu z9@WLdNXSx?NJ+ zr^GM>uB)gaJG2p0i@OP=C7B1!M#R7&78JDLMifT~oTvaX1VvyJgAuC%MM$%iL{Kn& zL7F!?&_;R~XWEx`vO_^tjgT-LjYf@8lTnh}VU!>U7{Oo+GiVwHr7NtmF+*4>%UED| zg_DJdDo9~4Ws&tuovIzuBHc(qjJVyKhQmslD2*~W#ztV&h`^$l%4=O)Q9b;Wt1L)sT(KnRcyim^Bd z6vs_w+<~KLt%ETW6y~&=EDVKPv5bwau!zZILl84X*lZMvI&h-4*6F}4gsIj{5EjIi z!MehV%7!^U<5$r9rm@6*u_P_?tSZSqN$SXSKvPgsB_$|DK-z0IqM)1Qgm6ldD$qv0 z3@-~W@d2kSiQqcJq_9N_qpW*XZ5V1@X1lADu`AD0dAh}}M|uZ~aw9?&_$2XCLa>wFa}!}))X_kMCsSu3^`RQAZz zr}l1NJ@8Q1W#Ij9UpbtZXj|UZ;(kinb)xJK6UOWg{Wbpj*N3|My}^scXwJy7g?ArJ zhDMXFtc0CDGc%l^XHf5n+jNxxoRkt@0rr_oxxv5tqxs;@H?AD%zVOj_sOJXWe15EZ z>P{YVs`>b84qKX>$f_Uyz5Hs!v-9mezaDyL@fl(A&Q7pl-1~?6_N0c#kZNwP|r;n;w|WU0S;JTJg=)KhWi9U`A_Od;bN2{Oh;? literal 0 HcmV?d00001 diff --git a/src/agent/notification-daemon/res/tw_ic_popup_btn_delete.png b/src/agent/notification-daemon/res/tw_ic_popup_btn_delete.png new file mode 100644 index 0000000000000000000000000000000000000000..5f346cb1623ffc78d757ca3d0e4528043ca5e42a GIT binary patch literal 1184 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTC$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWuD@%qp275hW46K32*3xq68pHF_1f1wh>l3^w)^1&PVosU-?Y zsp*+{wo31J?^jaDOtDo8H}y5}EpSfF$n>ZxN)4{^3rViZPPR-@vbR&PsjvbXkegbP zs8ErclUHn2VXFi-*9yo63F|8hm3bwJ6}oxF$}kgLQj3#|G7CyF^YauyCMG83 zmzLNn0bL65LT&-v*t}wBFaZNhzap_f-%!s00+w{G(#^lGsVin%-qt%z{teX!qLRg(AC7!$;r*t#LUvz z$<)%)%)kPs*Cju>G&eP`1g19ysMpZa)X?0>&;qE}6sulPV#qB3+U$~Alv$RV;#QQO zs{r=2RVHq?7~yscL~jZfw?O@2j8m^Z&@uX;s6~oum=G}ifSB-v3*^9)erg^ty%zx! zHjl2}Yz78KAx{^_kcwMxW?tkyWWeJRe9CIg5t%fmO&)4Vaw1J4oi!p!le@LT(@)w@ zO}g(byJMU8Im?Q^-~u@o1qMbA2L`5yB;A=_r&x4@vez#Q&DUOdW^2l+`2vS;#d!sr zUyWO}b(-4R3YC_eE55hBP7|!kiP_EHH~EUxthmFBVXkcJbIMDY|D1o7y=j{QPUmrh$$_!6eKbLh* G2~7Z}D~yo< literal 0 HcmV?d00001 -- 2.7.4