From ea97045364acfb60bf5c4e4c8d0ef4b67a787697 Mon Sep 17 00:00:00 2001 From: "sangwan.kwon" Date: Thu, 2 Jun 2016 16:30:28 +0900 Subject: [PATCH] Refine popup layout for linking to web page * "More information" pressed, popup should link to detailed web page * For this, seperate popup text to several label Change-Id: I7832e0594a268a169dd6ec0304933b4adc442397 --- src/framework/ui/popup/logic.cpp | 115 +++++++++++++++++++-------------------- src/framework/ui/popup/popup.cpp | 50 ++++++++++++++--- src/framework/ui/popup/popup.h | 11 ++-- 3 files changed, 105 insertions(+), 71 deletions(-) diff --git a/src/framework/ui/popup/logic.cpp b/src/framework/ui/popup/logic.cpp index 8832c5c..1b457bc 100755 --- a/src/framework/ui/popup/logic.cpp +++ b/src/framework/ui/popup/logic.cpp @@ -16,6 +16,7 @@ /* * @file logic.cpp * @author Kyungwook Tak (k.tak@samsung.com) + * @author Sangwan Kwon (sangwan.kwon@samsung.com) * @version 1.0 * @brief Logic for popup service */ @@ -55,12 +56,10 @@ RawBuffer Logic::csPromptData(const std::string &message, const CsDetected &d) c Popup p(1); p.setMessage(message); - p.setTitle("Malware detected"); - p.setHeader("Malware which is harm your phone is detected."); - p.setBody(FORMAT( - "- Risk : " << risk << " (" << d.malwareName << ")" << - "

" << "More information")); - p.setFooter("Processing is prohibited to protect your phone."); + p.setTitle(" Malware detected"); + p.setHeader(" Malware which is harm your phone is detected."); + p.setBody(FORMAT(" - Risk : " << risk << " (" << d.malwareName << ")")); + p.setFooter(" Processing is prohibited to protect your phone."); p.setText(p.m_buttons[0], "OK"); @@ -82,16 +81,16 @@ RawBuffer Logic::csPromptFile(const std::string &message, const CsDetected &d) c Popup p(3); p.setMessage(message); - p.setTitle("Malware detected"); - p.setHeader("Malware which is harm your phone is detected."); + p.setTitle(" Malware detected"); + p.setHeader(" Malware which is harm your phone is detected."); p.setBody(FORMAT( - "- File name : " << fileName << "
" << - "- Path : " << extraPath << "
" << - "- Risk : " << risk << " (" << d.malwareName << ")" << - "

" << "More information")); - p.setFooter("Tap Delete to delete infected files and" - "protect your phone. If you really want to" - "process anyway, tap Ignore."); + " - File name : " << fileName << "
" << + " - Path : " << extraPath << "
" << + " - Risk : " << risk << " (" << d.malwareName << ")")); + p.setFooter( + " Tap Delete to delete infected files and
" + " protect your phone. If you really want to
" + " process anyway, tap Ignore."); p.setText(p.m_buttons[0], "OK"); p.setText(p.m_buttons[1], "Ignore"); @@ -119,16 +118,16 @@ RawBuffer Logic::csPromptApp(const std::string &message, const CsDetected &d) co Popup p(3); p.setMessage(message); - p.setTitle("Malware detected"); - p.setHeader("Malware which is harm your phone is detected."); + p.setTitle(" Malware detected"); + p.setHeader(" Malware which is harm your phone is detected."); p.setBody(FORMAT( - "App name : " << d.targetName << "
" << - "Version : " << "1.0" << "
" << - "Risk : " << risk << " (" << d.malwareName << ")" << - "

" << "More information")); - p.setFooter("Tap Uninstall to uninstall infected" - "application and protect your phone." - "If you really want to process anyway, tap Ignore."); + " App name : " << d.targetName << "
" << + " Version : " << "1.0" << "
" << + " Risk : " << risk << " (" << d.malwareName << ")")); + p.setFooter( + " Tap Uninstall to uninstall infected
" + " application and protect your phone.
" + " If you really want to process anyway, tap Ignore."); p.setText(p.m_buttons[0], "OK"); p.setText(p.m_buttons[1], "Ignore"); @@ -154,12 +153,10 @@ RawBuffer Logic::csNotifyData(const std::string &message, const CsDetected &d) c Popup p(1); p.setMessage(message); - p.setTitle("Malware detected"); - p.setHeader("Malware which is harm your phone is detected."); - p.setBody(FORMAT( - "- Risk : " << "High" << " (" << d.malwareName << ")" << - "

" << "More information")); - p.setFooter("Processing is prohibited to protect your phone."); + p.setTitle(" Malware detected"); + p.setHeader(" Malware which is harm your phone is detected."); + p.setBody(FORMAT(" - Risk : " << "High" << " (" << d.malwareName << ")")); + p.setFooter(" Processing is prohibited to protect your phone."); p.setText(p.m_buttons[0], "OK"); @@ -179,15 +176,15 @@ RawBuffer Logic::csNotifyFile(const std::string &message, const CsDetected &d) c split(d.targetName, fileName, extraPath); p.setMessage(message); - p.setTitle("Malware detected"); - p.setHeader("Malware which is harm your phone is detected."); + p.setTitle(" Malware detected"); + p.setHeader(" Malware which is harm your phone is detected."); p.setBody(FORMAT( - "- File name : " << fileName << "
" << - "- Path : " << extraPath << "
" << - "- Risk : " << "High" << " (" << d.malwareName << ")" << - "

" << "More information")); - p.setFooter("Tap Delete to delete infected files and" - "protect your phone."); + " - File name : " << fileName << "
" << + " - Path : " << extraPath << "
" << + " - Risk : " << "High" << " (" << d.malwareName << ")")); + p.setFooter( + " Tap Delete to delete infected files and
" + " protect your phone."); p.setText(p.m_buttons[0], "OK"); p.setText(p.m_buttons[1], "Delete"); @@ -209,15 +206,15 @@ RawBuffer Logic::csNotifyApp(const std::string &message, const CsDetected &d) co Popup p(2); p.setMessage(message); - p.setTitle("Malware detected"); - p.setHeader("Malware which is harm your phone is detected."); + p.setTitle(" Malware detected"); + p.setHeader(" Malware which is harm your phone is detected."); p.setBody(FORMAT( - "App name : " << d.targetName << "
" << - "Version : " << "1.0" << "
" << - "Risk : " << "High" << " (" << d.malwareName << ")" << - "

" << "More information")); - p.setFooter("Tap Uninstall to uninstall infected" - "application and protect your phone."); + " App name : " << d.targetName << "
" << + " Version : " << "1.0" << "
" << + " Risk : " << "High" << " (" << d.malwareName << ")")); + p.setFooter( + " Tap Uninstall to uninstall infected
" + " application and protect your phone."); p.setText(p.m_buttons[0], "OK"); p.setText(p.m_buttons[1], "Uninstall"); @@ -241,13 +238,14 @@ RawBuffer Logic::wpPrompt(const std::string &message, const UrlItem &item) const Popup p(1); p.setMessage(message); - p.setTitle("Block malicious URL"); - p.setHeader("This website may harm your phone."); + p.setTitle(" Block malicious URL"); + p.setHeader(" This website may harm your phone."); p.setBody(FORMAT( - "- URL : " << item.url << "
" << - "- Risk : " << risk << "

" << - "More information")); - p.setFooter("Accessing to this URL is prohibited to protect your phone."); + " - URL : " << item.url << "
" << + " - Risk : " << risk)); + p.setFooter( + " Accessing to this URL is prohibited to
" + " protect your phone."); p.setText(p.m_buttons[0], "OK"); @@ -264,13 +262,14 @@ RawBuffer Logic::wpNotify(const std::string &message, const UrlItem &item) const Popup p(2); p.setMessage(message); - p.setTitle("Block malicious URL"); - p.setHeader("This website may harm your phone."); + p.setTitle(" Block malicious URL"); + p.setHeader(" This website may harm your phone."); p.setBody(FORMAT( - "- URL : " << item.url << "
" << - "- Risk : " << "High" << "

" << - "More information")); - p.setFooter("If you really want to process anyway, tap View"); + " - URL : " << item.url << "
" << + " - Risk : " << "High")); + p.setFooter( + " If you really want to process anyway,
" + " tap View"); p.setText(p.m_buttons[0], "OK"); p.setText(p.m_buttons[1], "View"); diff --git a/src/framework/ui/popup/popup.cpp b/src/framework/ui/popup/popup.cpp index 51f3f1c..9bb5517 100644 --- a/src/framework/ui/popup/popup.cpp +++ b/src/framework/ui/popup/popup.cpp @@ -35,15 +35,44 @@ Popup::Popup(int buttonN) m_popup = elm_popup_add(m_win); evas_object_size_hint_weight_set(m_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + m_box = elm_box_add(m_popup); + + m_header = elm_label_add(m_box); + evas_object_size_hint_align_set(m_header, EVAS_HINT_FILL, 0); + elm_box_pack_end(m_box, m_header); + evas_object_show(m_header); + + m_body = elm_label_add(m_box); + evas_object_size_hint_align_set(m_body, EVAS_HINT_FILL, 0); + elm_box_pack_end(m_box, m_body); + evas_object_show(m_body); + + m_hypertext = elm_label_add(m_box); + elm_object_text_set(m_hypertext,"" + " More information"); + evas_object_size_hint_align_set(m_hypertext, EVAS_HINT_FILL, 0); + elm_box_pack_end(m_box, m_hypertext); + evas_object_show(m_hypertext); + + m_footer = elm_label_add(m_box); + evas_object_size_hint_align_set(m_footer, EVAS_HINT_FILL, 0); + elm_box_pack_end(m_box, m_footer); + evas_object_show(m_footer); + + elm_object_content_set(m_popup, m_box); + for(int i=1 ; i <= buttonN; i++) { std::string id("button" + std::to_string(i)); Evas_Object *button = elm_button_add(m_popup); elm_object_style_set(button, "bottom"); elm_object_part_content_set(m_popup, id.c_str(), button); - elm_object_text_set(button, "default"); + evas_object_show(button); m_buttons.emplace_back(button); } + + evas_object_show(m_popup); + evas_object_show(m_win); } Popup::~Popup() @@ -54,17 +83,17 @@ Popup::~Popup() void Popup::setHeader(const std::string &header) noexcept { - m_header = header; + setText(m_header, header); } void Popup::setBody(const std::string &body) noexcept { - m_body = body; + setText(m_body, body); } void Popup::setFooter(const std::string &footer) noexcept { - m_footer = footer; + setText(m_footer, "
" + footer); } void Popup::setMessage(const std::string &msg) noexcept @@ -74,15 +103,18 @@ void Popup::setMessage(const std::string &msg) noexcept void Popup::run(void) { - setText(m_popup, (m_header + "
" + - m_body + "

" + m_footer).c_str()); + m_objects.emplace_back(m_header); + m_objects.emplace_back(m_body); + m_objects.emplace_back(m_hypertext); + m_objects.emplace_back(m_footer); + m_objects.emplace_back(m_box); + + for (auto &btn : m_buttons) + m_objects.emplace_back(btn); m_objects.emplace_back(m_popup); m_objects.emplace_back(m_win); - for (auto &obj : m_objects) - evas_object_show(obj); - elm_run(); } diff --git a/src/framework/ui/popup/popup.h b/src/framework/ui/popup/popup.h index 02f50bc..8e86720 100644 --- a/src/framework/ui/popup/popup.h +++ b/src/framework/ui/popup/popup.h @@ -78,11 +78,14 @@ public: private: Evas_Object *m_win; Evas_Object *m_popup; - std::string m_title; - std::string m_header; - std::string m_body; - std::string m_footer; + Evas_Object *m_box; + Evas_Object *m_header; + Evas_Object *m_body; + Evas_Object *m_hypertext; + Evas_Object *m_footer; + std::string m_message; + std::string m_hypertextUrl; static int response; }; -- 2.7.4