Add ui for wearable 29/101629/2
authorZofia Abramowska <z.abramowska@samsung.com>
Thu, 1 Dec 2016 17:12:48 +0000 (18:12 +0100)
committerZofia Abramowska <z.abramowska@samsung.com>
Thu, 1 Dec 2016 19:32:39 +0000 (20:32 +0100)
* 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
packaging/askuser.spec
src/agent/notification-daemon/CMakeLists.txt
src/agent/notification-daemon/GuiRunner.cpp
src/agent/notification-daemon/GuiRunner.h
src/agent/notification-daemon/res/popup_custom.edc [new file with mode: 0644]
src/agent/notification-daemon/res/tw_ic_popup_btn_check.png [new file with mode: 0644]
src/agent/notification-daemon/res/tw_ic_popup_btn_delete.png [new file with mode: 0644]

index e0d174b..0845f5a 100644 (file)
@@ -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")
index e83a9b7..3048768 100644 (file)
@@ -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
index 06b1e6d..b75cd5c 100644 (file)
@@ -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)
index ad63014..e4d03d7 100644 (file)
@@ -26,6 +26,7 @@
 #include <exception/Exception.h>
 #include <translator/Translator.h>
 #include <libintl.h>
+#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)
index c826c54..cd20823 100644 (file)
@@ -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 (file)
index 0000000..041572d
--- /dev/null
@@ -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 (file)
index 0000000..f20f62e
Binary files /dev/null and b/src/agent/notification-daemon/res/tw_ic_popup_btn_check.png differ
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 (file)
index 0000000..5f346cb
Binary files /dev/null and b/src/agent/notification-daemon/res/tw_ic_popup_btn_delete.png differ