From 084e045043b8aac1abd0e3b8bfb8a3e77a073f69 Mon Sep 17 00:00:00 2001 From: "sangwan.kwon" Date: Fri, 10 Jun 2016 18:09:17 +0900 Subject: [PATCH] Refine label layout for multi-line Change-Id: Id55fec0bb1c9d6d780f05a51aaa754955ea6acdd --- src/framework/ui/popup/logic.cpp | 103 ++++++++++++++++++++++----------------- src/framework/ui/popup/popup.cpp | 15 ++++-- test/popup/test-popup.cpp | 14 ++++-- 3 files changed, 78 insertions(+), 54 deletions(-) diff --git a/src/framework/ui/popup/logic.cpp b/src/framework/ui/popup/logic.cpp index 47d317c..a0cc90e 100755 --- a/src/framework/ui/popup/logic.cpp +++ b/src/framework/ui/popup/logic.cpp @@ -56,17 +56,23 @@ 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 << ")")); - 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(" If you really want to process anyway,
" + " tap ignore."); p.setText(p.m_buttons[0], "OK"); + p.setText(p.m_buttons[1], "Ignore"); p.m_types.emplace_back( static_cast(CSR_CS_USER_RESPONSE_PROCESSING_DISALLOWED)); + p.m_types.emplace_back( + static_cast(CSR_CS_USER_RESPONSE_PROCESSING_ALLOWED)); p.callbackRegister(p.m_buttons[0], &p.m_types[0]); + p.callbackRegister(p.m_buttons[1], &p.m_types[1]); p.callbackRegister(p.m_hypertext, d.detailedUrl); p.run(); @@ -82,16 +88,17 @@ 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 << ")")); + " - 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."); + " 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"); @@ -121,17 +128,19 @@ 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 : " << info.getLabel() << "
" << - " Version : " << info.getVersion() << "
" << - " Risk : " << risk << " (" << d.malwareName << ")")); + " App name : " << info.getLabel() << "
" << + " Version : " << info.getVersion() << "
" << + " Risk : " << risk << " (" << d.malwareName << ")")); p.setIcon(info.getIconPath()); p.setFooter( - " Tap Uninstall to uninstall infected
" - " application and protect your phone.
" - " If you really want to process anyway, tap Ignore."); + " 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"); @@ -158,10 +167,12 @@ 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 << ")")); - 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"); @@ -182,15 +193,16 @@ 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 << ")")); + " - File name : " << fileName << "
" << + " - Path : " << extraPath << "
" << + " - Risk : " << "High" << " (" << d.malwareName << ")")); p.setFooter( - " Tap Delete to delete infected files and
" - " protect your phone."); + " Tap Delete to delete infected files and
" + " protect your phone."); p.setText(p.m_buttons[0], "OK"); p.setText(p.m_buttons[1], "Delete"); @@ -215,16 +227,17 @@ 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.setIcon(info.getIconPath()); p.setBody(FORMAT( - " App name : " << info.getLabel() << "
" << - " Version : " << info.getVersion() << "
" << - " Risk : " << "High" << " (" << d.malwareName << ")")); + " App name : " << info.getLabel() << "
" << + " Version : " << info.getVersion() << "
" << + " Risk : " << "High" << " (" << d.malwareName << ")")); p.setFooter( - " Tap Uninstall to uninstall infected
" - " application and protect your phone."); + " Tap Uninstall to uninstall infected
" + " application and protect your phone."); p.setText(p.m_buttons[0], "OK"); p.setText(p.m_buttons[1], "Uninstall"); @@ -250,13 +263,13 @@ RawBuffer Logic::wpPrompt(const std::string &message, const UrlItem &item) const p.setMessage(message); p.setTitle("Block malicious URL"); - p.setHeader(" This website may harm your phone."); + p.setHeader(" This website may harm your phone."); p.setBody(FORMAT( - " - URL : " << item.url << "
" << - " - Risk : " << risk)); + " - URL : " << item.url << "
" << + " - Risk : " << risk)); p.setFooter( - " Accessing to this URL is prohibited to
" - " protect your phone."); + " Accessing to this URL is prohibited to
" + " protect your phone."); p.setText(p.m_buttons[0], "OK"); @@ -277,8 +290,8 @@ RawBuffer Logic::wpNotify(const std::string &message, const UrlItem &item) const p.setTitle("Block malicious URL"); p.setHeader(" This website may harm your phone."); p.setBody(FORMAT( - " - URL : " << item.url << "
" << - " - Risk : " << "High")); + " - URL : " << item.url << "
" << + " - Risk : " << "High")); p.setFooter( " If you really want to process anyway,
" " tap View"); diff --git a/src/framework/ui/popup/popup.cpp b/src/framework/ui/popup/popup.cpp index a4b3882..7f815cb 100644 --- a/src/framework/ui/popup/popup.cpp +++ b/src/framework/ui/popup/popup.cpp @@ -49,12 +49,16 @@ Popup::Popup(int buttonN) // Set popup properties. m_popup = elm_popup_add(m_win); + elm_popup_align_set(m_popup, ELM_NOTIFY_ALIGN_FILL, 1.0); evas_object_size_hint_weight_set(m_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); // Wrap objects with box. m_box = elm_box_add(m_popup); - m_header = elm_label_add(m_box); + evas_object_size_hint_weight_set(m_box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_box_padding_set(m_box, 10, 10); + m_header = elm_label_add(m_box); + evas_object_size_hint_weight_set(m_header, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 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); @@ -71,6 +75,7 @@ Popup::Popup(int buttonN) evas_object_show(m_icon); m_body = elm_label_add(m_subBox); + evas_object_size_hint_weight_set(m_body, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(m_body, EVAS_HINT_FILL, 0); elm_box_pack_end(m_subBox, m_body); evas_object_show(m_body); @@ -81,10 +86,12 @@ Popup::Popup(int buttonN) // This label is for linking to webview. m_hypertext = elm_button_add(m_box); elm_object_text_set(m_hypertext, "More information"); + evas_object_size_hint_weight_set(m_hypertext, EVAS_HINT_FILL, EVAS_HINT_FILL); 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); elm_object_style_set(m_hypertext, "anchor"); + elm_object_focus_set(m_hypertext, EINA_FALSE); m_footer = elm_label_add(m_box); evas_object_size_hint_align_set(m_footer, EVAS_HINT_FILL, 0); @@ -116,17 +123,17 @@ Popup::~Popup() void Popup::setHeader(const std::string &header) noexcept { - setText(m_header, header); + setText(m_header, "" + header + ""); } void Popup::setBody(const std::string &body) noexcept { - setText(m_body, body); + setText(m_body, "" + body + ""); } void Popup::setFooter(const std::string &footer) noexcept { - setText(m_footer, "
" + footer); + setText(m_footer, "
""" + footer + ""); } void Popup::setMessage(const std::string &msg) noexcept diff --git a/test/popup/test-popup.cpp b/test/popup/test-popup.cpp index a87669a..0fde317 100644 --- a/test/popup/test-popup.cpp +++ b/test/popup/test-popup.cpp @@ -110,7 +110,7 @@ BOOST_AUTO_TEST_CASE(prompt_data) CsDetected d; d.targetName.clear(); // data's target name should be empty - d.malwareName = "dummy malware in data"; + d.malwareName = "dummy malware"; d.detailedUrl = "http://detailedurl/cs_prompt_data"; d.severity = CSR_CS_SEVERITY_MEDIUM; @@ -126,9 +126,13 @@ BOOST_AUTO_TEST_CASE(prompt_app) EXCEPTION_GUARD_START CsDetected d; + + Test::uninstall_app(TEST_TPK_PKG_ID); + ASSERT_INSTALL_APP(TEST_TPK_PATH, TEST_TPK_TYPE); + // message pkg is for get icon temporary. - d.pkgId = "org.tizen.message"; - d.malwareName = "dummy malware in app"; + d.pkgId = TEST_TPK_PKG_ID; + d.malwareName = "dummy malware"; d.detailedUrl = "http://detailedurl/cs_prompt_app"; d.severity = CSR_CS_SEVERITY_MEDIUM; @@ -162,7 +166,7 @@ BOOST_AUTO_TEST_CASE(notify_data) CsDetected d; d.targetName.clear(); // data's target name should be empty - d.malwareName = "dummy malware in data"; + d.malwareName = "dummy malware"; d.detailedUrl = "http://detailedurl/cs_notify_data"; d.severity = CSR_CS_SEVERITY_HIGH; @@ -183,7 +187,7 @@ BOOST_AUTO_TEST_CASE(notify_app) ASSERT_INSTALL_APP(TEST_WGT_PATH, TEST_WGT_TYPE); d.pkgId = TEST_WGT_PKG_ID; - d.malwareName = "dummy malware in app"; + d.malwareName = "dummy malware"; d.detailedUrl = "http://detailedurl/cs_notify_app"; d.severity = CSR_CS_SEVERITY_HIGH; -- 2.7.4