Add external encryption progress-notification 37/138937/2
authors414kim <s414.kim@samsung.com>
Fri, 14 Jul 2017 09:02:41 +0000 (18:02 +0900)
committerSungbae Yoo <sungbae.yoo@samsung.com>
Mon, 31 Jul 2017 05:31:12 +0000 (05:31 +0000)
Change-Id: I5863d8e56d0c778e4236adac201c29eee15f22d1
Signed-off-by: s414kim <s414.kim@samsung.com>
tools/apps/ode/rework/interface/external/insert-sdcard.cpp
tools/apps/ode/rework/interface/external/password-sdcard.cpp
tools/apps/ode/rework/interface/external/retry-sdcard.cpp
tools/apps/ode/rework/interface/progress.cpp
tools/apps/ode/rework/interface/progress.h
tools/apps/ode/rework/widgets/notification.cpp
tools/apps/ode/rework/widgets/notification.h

index 76b34f9..6ba4223 100644 (file)
@@ -19,7 +19,7 @@
 #include "insert-sdcard.h"
 
 InsertSDCardInterface::InsertSDCardInterface()
-       : popup(nullptr), appControl("org.tizen.ode")
+       : popup(nullptr), appControl("org.tizen.ode"), notification(NOTIFICATION_TYPE_NOTI)
 {
        window->setConfig(Window::Config::SetAlpha);
 }
@@ -60,7 +60,7 @@ void InsertSDCardInterface::create()
        /* SD Card Encrypted Notification */
        appControl.setData("viewtype", "SD_CARD_PASSWORD");
        notification.setTitle(dgetText("IDS_ST_MBODY_SD_CARD_ENCRYPTED"));
-       notification.setContent(dgetText("IDS_ST_SBODY_TAP_HERE_TO_ENTER_PW_FOR_SD_CARD_ABB"));
+       notification.setContentText(dgetText("IDS_ST_SBODY_TAP_HERE_TO_ENTER_PW_FOR_SD_CARD_ABB"));
        notification.setAppControl(appControl);
        notification.post();
 }
index 77a262e..2057432 100644 (file)
@@ -20,6 +20,7 @@
 PasswordSDCard::PasswordSDCard()
        : baseLayout(new Layout(window)),
          passwordConfirm(baseLayout),
+         notification(NOTIFICATION_TYPE_NOTI),
          progress(nullptr)
 {
        window->setContent(baseLayout);
@@ -81,13 +82,13 @@ void PasswordSDCard::onResultCallback(int result, const std::string &data)
                        encryption.mount(data);
                        appControl.setData("viewtype", "DECRYPT_SD_CARD");
                        notification.setTitle(dgetText("IDS_ST_MBODY_DECRYPT_SD_CARD"));
-                       notification.setContent(dgetText("IDS_ST_SBODY_SD_CARD_ENCRYPTED_M_STATUS"));
+                       notification.setContentText(dgetText("IDS_ST_SBODY_SD_CARD_ENCRYPTED_M_STATUS"));
                        notification.setAppControl(appControl);
                        notification.post();
                } else {
                        appControl.setData("viewtype", "ENCRYPT_SD_CARD");
                        notification.setTitle(dgetText("IDS_ST_MBODY_ENCRYPT_SD_CARD_ABB"));
-                       notification.setContent(dgetText("IDS_ST_SBODY_TAP_HERE_TO_ENTER_PW_FOR_SD_CARD_ABB"));
+                       notification.setContentText(dgetText("IDS_ST_SBODY_TAP_HERE_TO_ENTER_PW_FOR_SD_CARD_ABB"));
                        notification.setAppControl(appControl);
                        notification.post();
                }
index dfab39f..df0faa6 100644 (file)
@@ -20,7 +20,8 @@
 
 RetryPopup::RetryPopup(Widget *parent)
        : MobileDefaultPopup(parent),
-         appControl("org.tizen.ode")
+         appControl("org.tizen.ode"),
+         notification(NOTIFICATION_TYPE_NOTI)
 {
 }
 
@@ -65,7 +66,7 @@ void ExternalRetryEncrypt::createNotification()
 {
        appControl.setData("viewtype", "SD_CARD_PASSWORD");
        notification.setTitle(dgetText("IDS_ST_MBODY_SD_CARD_ENCRYPTION_ERROR"));
-       notification.setContent(dgetText("IDS_ST_SBODY_TAP_HERE_TO_TRY_AGAIN"));
+       notification.setContentText(dgetText("IDS_ST_SBODY_TAP_HERE_TO_TRY_AGAIN"));
        notification.setAppControl(appControl);
        notification.post();
 }
@@ -97,7 +98,7 @@ void ExternalRetryEncryptStorageFull::createNotification()
 {
        appControl.setData("viewtype", "ENCRYPT_SD_CARD");
        notification.setTitle(dgetText("IDS_ST_MBODY_SD_CARD_ENCRYPTION_ERROR"));
-       notification.setContent(dgetText("IDS_ST_SBODY_DELETE_SOME_FILES_THEN_TRY_AGAIN"));
+       notification.setContentText(dgetText("IDS_ST_SBODY_DELETE_SOME_FILES_THEN_TRY_AGAIN"));
        notification.setAppControl(appControl);
        notification.post();
 }
@@ -125,7 +126,8 @@ void ExternalRetryDecrypt::createNotification()
 {
        appControl.setData("viewtype", "SD_CARD_PASSWORD");
        notification.setTitle(dgetText("IDS_ST_MBODY_SD_CARD_DECRYPTION_ERROR"));
-       notification.setContent(dgetText("IDS_ST_SBODY_TAP_HERE_TO_TRY_AGAIN"));
+       notification.setContentText(dgetText("IDS_ST_SBODY_TAP_HERE_TO_TRY_AGAIN"));
+
        notification.setAppControl(appControl);
        notification.post();
 }
@@ -157,7 +159,7 @@ void ExternalRetryDecryptStorageFull::createNotification()
 {
        appControl.setData("viewtype", "DECRYPT_SD_CARD");
        notification.setTitle(dgetText("IDS_ST_MBODY_SD_CARD_DECRYPTION_ERROR"));
-       notification.setContent(dgetText("IDS_ST_SBODY_DELETE_SOME_FILES_THEN_TRY_AGAIN"));
+       notification.setContentText(dgetText("IDS_ST_SBODY_DELETE_SOME_FILES_THEN_TRY_AGAIN"));
        notification.setAppControl(appControl);
        notification.post();
 }
index 5e0d116..bcc7240 100644 (file)
@@ -21,10 +21,13 @@ ProgressPage::ProgressPage(Widget *parent, const std::string &group, const std::
        : Layout{parent, "/usr/apps/org.tizen.ode/res/org.tizen.ode.edj", group},
          vconf(key),
          progressbar(this, Progressbar::Config::SetPulse),
+         notification(nullptr),
+         doneNotification(nullptr),
          titleStyle("DEFAULT='font=Tizen:style=Regular font_size=40 color=#ffffff wrap=mixed align=center'"),
-         contentStyle("DEFAULT='font=Tizen:style=Regular font_size=32 color=#ffffff wrap=mixed align=center'")
+         contentStyle("DEFAULT='font=Tizen:style=Regular font_size=32 color=#ffffff wrap=mixed align=center'"),
+         current(0.0)
 {
-       progressbar.setValue(0.0);
+       progressbar.setValue(current);
        setContent("progressbar", &progressbar);
 }
 
@@ -35,6 +38,9 @@ ProgressPage::~ProgressPage()
 
 void ProgressPage::start()
 {
+       createPartContent();
+       createNotification();
+
        timer.add(0.1);
        timer.onTimer = [this]() {
                return setProgress();
@@ -47,12 +53,23 @@ bool ProgressPage::setProgress()
        int percentage = 0;
 
        percentage = ::atoi(stringValue.c_str());
-       progressbar.setValue(percentage/100.0);
+       current = percentage/100.0;
+
+       progressbar.setValue(current);
        stringValue.append("%");
        setText("progress_percentage", stringValue);
 
+       if (notification != nullptr && notification->getProgress() != current) {
+               notification->setProgress(percentage/100.0);
+               notification->update();
+       }
+
        if (percentage == 100) {
                timer.dispose();
+               if (notification)
+                       notification->dispose();
+               if (doneNotification)
+                       doneNotification->post();
                ::ui_app_exit();
                return ECORE_CALLBACK_DONE;
        }
@@ -66,7 +83,17 @@ ExternalEncryptProgress::ExternalEncryptProgress(Widget *parent)
 {
        Vconf cryptoType(VCONFKEY_SDE_CRYPTO_TYPE);
        cryptoType.setString("encrypt");
+       cryptoState.addChangedCallback();
+       cryptoState.onKeyChanged.connect(this, &ExternalEncryptProgress::cryptoStateChangedCallback);
+}
+
+ExternalEncryptProgress::~ExternalEncryptProgress()
+{
+       cryptoState.removeChangedCallback();
+}
 
+void ExternalEncryptProgress::createPartContent()
+{
        std::string text;
        titleText.reset(new TextBlock(this, titleStyle, dgetText("IDS_ST_BODY_ENCRYPTING_SD_CARD_ING")));
        setContent("message_title", titleText.get());
@@ -78,14 +105,19 @@ ExternalEncryptProgress::ExternalEncryptProgress(Widget *parent)
        text.append(dgetText("IDS_ST_BODY_THE_SD_CARD_CANT_BE_USED_UNTIL_IT_HAS_BEEN_ENCRYPTED"));
        contentText.reset(new TextBlock(this, contentStyle, text));
        setContent("message_content", contentText.get());
-
-       cryptoState.addChangedCallback();
-       cryptoState.onKeyChanged.connect(this, &ExternalEncryptProgress::cryptoStateChangedCallback);
 }
 
-ExternalEncryptProgress::~ExternalEncryptProgress()
+void ExternalEncryptProgress::createNotification()
 {
-       cryptoState.removeChangedCallback();
+       notification.reset(new Notification(NOTIFICATION_TYPE_ONGOING));
+       notification->setTitle(dgetText("IDS_ST_MBODY_ENCRYPTING_SD_CARD_ING"));
+       notification->setContentText(dgetText("IDS_ST_BODY_PDP_M_PERCENT"));
+       notification->setLayout(NOTIFICATION_LY_ONGOING_PROGRESS);
+       notification->post();
+
+       doneNotification.reset(new Notification(NOTIFICATION_TYPE_NOTI));
+       doneNotification->setTitle(dgetText("IDS_ST_MBODY_SD_CARD_ENCRYPTED"));
+       doneNotification->setLayout(NOTIFICATION_LY_NOTI_EVENT_SINGLE);
 }
 
 void ExternalEncryptProgress::cryptoStateChangedCallback()
@@ -104,7 +136,17 @@ ExternalDecryptProgress::ExternalDecryptProgress(Widget *parent)
 {
        Vconf cryptoType(VCONFKEY_SDE_CRYPTO_TYPE);
        cryptoType.setString("decrypt");
+       cryptoState.addChangedCallback();
+       cryptoState.onKeyChanged.connect(this, &ExternalDecryptProgress::cryptoStateChangedCallback);
+}
+
+ExternalDecryptProgress::~ExternalDecryptProgress()
+{
+       cryptoState.removeChangedCallback();
+}
 
+void ExternalDecryptProgress::createPartContent()
+{
        std::string text;
        titleText.reset(new TextBlock(this, titleStyle, dgetText("IDS_ST_BODY_DECRYPTING_SD_CARD_ING")));
        setContent("message_title", titleText.get());
@@ -114,14 +156,19 @@ ExternalDecryptProgress::ExternalDecryptProgress(Widget *parent)
        text.append(dgetText("IDS_ST_BODY_THE_SD_CARD_CANT_BE_USED_UNTIL_IT_HAS_BEEN_DECRYPTED"));
        contentText.reset(new TextBlock(this, contentStyle, text));
        setContent("message_content", contentText.get());
-
-       cryptoState.addChangedCallback();
-       cryptoState.onKeyChanged.connect(this, &ExternalDecryptProgress::cryptoStateChangedCallback);
 }
 
-ExternalDecryptProgress::~ExternalDecryptProgress()
+void ExternalDecryptProgress::createNotification()
 {
-       cryptoState.removeChangedCallback();
+       notification.reset(new Notification(NOTIFICATION_TYPE_ONGOING));
+       notification->setTitle(dgetText("IDS_ST_MBODY_DECRYPTING_SD_CARD_ING"));
+       notification->setContentText(dgetText("IDS_ST_BODY_PDP_M_PERCENT"));
+       notification->setLayout(NOTIFICATION_LY_ONGOING_PROGRESS);
+       notification->post();
+
+       doneNotification.reset(new Notification(NOTIFICATION_TYPE_NOTI));
+       doneNotification->setTitle(dgetText("IDS_ST_MBODY_SD_CARD_DECRYPTED"));
+       doneNotification->setLayout(NOTIFICATION_LY_NOTI_EVENT_SINGLE);
 }
 
 void ExternalDecryptProgress::cryptoStateChangedCallback()
@@ -136,6 +183,14 @@ void ExternalDecryptProgress::cryptoStateChangedCallback()
 InternalEncryptProgress::InternalEncryptProgress(Widget *parent)
        : ProgressPage(parent, "internal,encryption,progress", VCONFKEY_ODE_ENCRYPT_PROGRESS)
 {
+}
+
+InternalEncryptProgress::~InternalEncryptProgress()
+{
+}
+
+void InternalEncryptProgress::createPartContent()
+{
        std::string text;
        titleText.reset(new TextBlock(this, titleStyle, dgetText("IDS_ST_NPBODY_ENCRYPTING_DEVICE_ING")));
        setContent("message_title", titleText.get());
@@ -147,19 +202,27 @@ InternalEncryptProgress::InternalEncryptProgress(Widget *parent)
        setContent("message_content", contentText.get());
 }
 
-InternalEncryptProgress::~InternalEncryptProgress()
+void InternalEncryptProgress::createNotification()
 {
 }
 
 InternalDecryptProgress::InternalDecryptProgress(Widget *parent)
        : ProgressPage(parent, "internal,decryption,progress", VCONFKEY_ODE_ENCRYPT_PROGRESS)
 {
+}
+
+InternalDecryptProgress::~InternalDecryptProgress()
+{
+}
+
+void InternalDecryptProgress::createPartContent()
+{
        titleText.reset(new TextBlock(this, titleStyle, dgetText("IDS_ST_BODY_DECRYPTING_DEVICE_ING")));
        setContent("message_title", titleText.get());
        contentText.reset(new TextBlock(this, contentStyle, dgetText("IDS_ST_BODY_PLEASE_WAIT_NONCE_THE_DEVICE_IS_DECRYPTED_IT_WILL_RESTART")));
        setContent("message_content", contentText.get());
 }
 
-InternalDecryptProgress::~InternalDecryptProgress()
+void InternalDecryptProgress::createNotification()
 {
 }
index af9b684..2d61321 100644 (file)
 #include "../widgets/timer.h"
 #include "../widgets/progressbar.h"
 #include "../widgets/textblock.h"
+#include "../widgets/notification.h"
 
 class ProgressPage : public Layout {
 public:
        ProgressPage(Widget *parent, const std::string &group, const std::string &key);
-       ~ProgressPage();
+       virtual ~ProgressPage();
 
        void start();
        bool setProgress();
-
+protected:
+       virtual void createPartContent() = 0;
+       virtual void createNotification() = 0;
+protected:
        Vconf vconf;
        Progressbar progressbar;
        Timer timer;
-
+       std::unique_ptr<Notification> notification;
+       std::unique_ptr<Notification> doneNotification;
        std::unique_ptr<TextBlock> titleText;
        std::unique_ptr<TextBlock> contentText;
        std::string titleStyle;
        std::string contentStyle;
+       double current;
 };
 
 class ExternalEncryptProgress : public ProgressPage {
@@ -51,6 +57,8 @@ public:
        ExternalEncryptProgress(Widget *parent);
        ~ExternalEncryptProgress();
 
+       void createPartContent();
+       void createNotification();
        void cryptoStateChangedCallback();
 
        Vconf cryptoState;
@@ -62,6 +70,8 @@ public:
        ExternalDecryptProgress(Widget *parent);
        ~ExternalDecryptProgress();
 
+       void createPartContent();
+       void createNotification();
        void cryptoStateChangedCallback();
 
        Vconf cryptoState;
@@ -72,12 +82,18 @@ class InternalEncryptProgress : public ProgressPage {
 public:
        InternalEncryptProgress(Widget *parent);
        ~InternalEncryptProgress();
+
+       void createPartContent();
+       void createNotification();
 };
 
 class InternalDecryptProgress : public ProgressPage {
 public:
        InternalDecryptProgress(Widget *parent);
        ~InternalDecryptProgress();
+
+       void createPartContent();
+       void createNotification();
 };
 
 #endif
index f2e68f9..92da321 100644 (file)
@@ -18,9 +18,9 @@
 
 #include "notification.h"
 
-Notification::Notification()
+Notification::Notification(notification_type_e type)
 {
-       notification = ::notification_create(NOTIFICATION_TYPE_NOTI);
+       notification = ::notification_create(type);
 }
 
 Notification::~Notification()
@@ -35,12 +35,29 @@ void Notification::setTitle(const std::string &title)
                                                        title.c_str(), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
 }
 
-void Notification::setContent(const std::string &content)
+void Notification::setContentText(const std::string &content)
 {
        ::notification_set_text(notification, NOTIFICATION_TEXT_TYPE_CONTENT,
                                                        content.c_str(), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
 }
 
+void Notification::setProgress(double value)
+{
+       ::notification_set_progress(notification, value);
+}
+
+double Notification::getProgress()
+{
+       double value = 0.0;
+       ::notification_get_progress(notification, &value);
+       return value;
+}
+
+void Notification::setLayout(notification_ly_type_e type)
+{
+       ::notification_set_layout(notification, type);
+}
+
 void Notification::setImage(const std::string &path)
 {
        ::notification_set_image(notification, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, path.c_str());
@@ -51,6 +68,11 @@ void Notification::setAppControl(AppControl &appControl)
        ::notification_set_launch_option(notification, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, appControl);
 }
 
+void Notification::update()
+{
+       ::notification_update(notification);
+}
+
 void Notification::post()
 {
        ::notification_post(notification);
index 2a8b7a6..a8a4ddb 100644 (file)
 
 class Notification {
 public:
-       Notification();
+       Notification(notification_type_e type);
        ~Notification();
 
        void setTitle(const std::string &title);
-       void setContent(const std::string &content);
+       void setContentText(const std::string &content);
+       void setProgress(double value);
+       double getProgress();
+       void setLayout(notification_ly_type_e type);
        void setImage(const std::string &path);
        void setAppControl(AppControl &appcontrol);
+
+       void update();
        void post();
        void dispose();
 private: