Refine label layout for multi-line 97/73997/2
authorsangwan.kwon <sangwan.kwon@samsung.com>
Fri, 10 Jun 2016 09:09:17 +0000 (18:09 +0900)
committersangwan kwon <sangwan.kwon@samsung.com>
Fri, 10 Jun 2016 09:11:49 +0000 (02:11 -0700)
Change-Id: Id55fec0bb1c9d6d780f05a51aaa754955ea6acdd

src/framework/ui/popup/logic.cpp
src/framework/ui/popup/popup.cpp
test/popup/test-popup.cpp

index 47d317c..a0cc90e 100755 (executable)
@@ -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<br>"
+                               "  detected.");
+       p.setBody(FORMAT("  - Risk : " << risk << " (" << d.malwareName << ")"));
+       p.setFooter("  If you really want to process anyway,<br>"
+                               "  tap ignore.");
 
        p.setText(p.m_buttons[0], "OK");
+       p.setText(p.m_buttons[1], "Ignore");
 
        p.m_types.emplace_back(
                static_cast<int>(CSR_CS_USER_RESPONSE_PROCESSING_DISALLOWED));
+       p.m_types.emplace_back(
+               static_cast<int>(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<br>"
+                               "  detected.");
        p.setBody(FORMAT(
-               "    - File name : " << fileName << "<br>" <<
-               "    - Path : " << extraPath << "<br>" <<
-               "    - Risk : " << risk << " (" << d.malwareName << ")"));
+               "  - File name : " << fileName << "<br>" <<
+               "  - Path : " << extraPath << "<br>" <<
+               "  - Risk : " << risk << " (" << d.malwareName << ")"));
        p.setFooter(
-               "    Tap Delete to delete infected files and<br>"
-               "    protect your phone. If you really want to<br>"
-               "    process anyway, tap Ignore.");
+               "  Tap Delete to delete infected files and<br>"
+               "  protect your phone. If you really want to<br>"
+               "  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<br>"
+                               "  is detected.");
        p.setBody(FORMAT(
-               "    App name : " << info.getLabel() << "<br>" <<
-               "    Version : " << info.getVersion() << "<br>" <<
-               "    Risk : " << risk << " (" << d.malwareName << ")"));
+               "  App name : " << info.getLabel() << "<br>" <<
+               "  Version : " << info.getVersion() << "<br>" <<
+               "  Risk : " << risk << " (" << d.malwareName << ")"));
        p.setIcon(info.getIconPath());
        p.setFooter(
-               "    Tap Uninstall to uninstall infected<br>"
-               "    application and protect your phone.<br>"
-               "    If you really want to process anyway, tap Ignore.");
+               "  Tap Uninstall to uninstall infected<br>"
+               "  application and protect your phone. If<br>"
+               "  you really want to process anyway, tap<br>"
+               "  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<br>"
+                               "  detected.");
+       p.setBody(FORMAT("  - Risk : " << "High" << " (" << d.malwareName << ")"));
+       p.setFooter("  Processing is prohibited to protect<br>"
+                               "  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<br>"
+                               "  detected.");
        p.setBody(FORMAT(
-               "    - File name : " << fileName << "<br>" <<
-               "    - Path : " << extraPath << "<br>" <<
-               "    - Risk : " << "High" << " (" << d.malwareName << ")"));
+               "  - File name : " << fileName << "<br>" <<
+               "  - Path : " << extraPath << "<br>" <<
+               "  - Risk : " << "High" << " (" << d.malwareName << ")"));
        p.setFooter(
-               "    Tap Delete to delete infected files and<br>"
-               "    protect your phone.");
+               "  Tap Delete to delete infected files and<br>"
+               "  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<br>"
+                               "  detected.");
        p.setIcon(info.getIconPath());
        p.setBody(FORMAT(
-               "    App name : " << info.getLabel() << "<br>" <<
-               "    Version : " << info.getVersion() << "<br>" <<
-               "    Risk : " << "High" << " (" << d.malwareName << ")"));
+               "  App name : " << info.getLabel() << "<br>" <<
+               "  Version : " << info.getVersion() << "<br>" <<
+               "  Risk : " << "High" << " (" << d.malwareName << ")"));
        p.setFooter(
-               "    Tap Uninstall to uninstall infected<br>"
-               "    application and protect your phone.");
+               "  Tap Uninstall to uninstall infected<br>"
+               "  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 << "<br>" <<
-               "    - Risk : " << risk));
+               "  - URL : " << item.url << "<br>" <<
+               "  - Risk : " << risk));
        p.setFooter(
-               "    Accessing to this URL is prohibited to<br>"
-               "    protect your phone.");
+               "  Accessing to this URL is prohibited to<br>"
+               "  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 << "<br>" <<
-               "    - Risk : " << "High"));
+               "  - URL : " << item.url << "<br>" <<
+               "  - Risk : " << "High"));
        p.setFooter(
                "   If you really want to process anyway,<br>"
                "   tap View");
index a4b3882..7f815cb 100644 (file)
@@ -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, "<wrap = word>" + header + "</wrap>");
 }
 
 void Popup::setBody(const std::string &body) noexcept
 {
-       setText(m_body, body);
+       setText(m_body, "<wrap = word>" + body + "</wrap>");
 }
 
 void Popup::setFooter(const std::string &footer) noexcept
 {
-       setText(m_footer, "<br>" + footer);
+       setText(m_footer, "<br>""<wrap = word>" + footer + "</wrap>");
 }
 
 void Popup::setMessage(const std::string &msg) noexcept
index a87669a..0fde317 100644 (file)
@@ -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;