Add ODE progress interface for rework 96/137796/5
authors414kim <s414.kim@samsung.com>
Sat, 8 Jul 2017 11:49:59 +0000 (20:49 +0900)
committerSungbae Yoo <sungbae.yoo@samsung.com>
Mon, 31 Jul 2017 05:28:40 +0000 (05:28 +0000)
Change-Id: I200fa17116476724be72f014236f67164d3e6595
Signed-off-by: s414kim <s414.kim@samsung.com>
tools/apps/ode/CMakeLists.txt
tools/apps/ode/res/edc_resource/progress.edc [new file with mode: 0644]
tools/apps/ode/res/org.tizen.ode.edc
tools/apps/ode/rework/interface/external/decrypt-sdcard.cpp
tools/apps/ode/rework/interface/external/decrypt-sdcard.h
tools/apps/ode/rework/interface/external/encrypt-sdcard.cpp
tools/apps/ode/rework/interface/external/encrypt-sdcard.h
tools/apps/ode/rework/interface/progress.cpp [new file with mode: 0644]
tools/apps/ode/rework/interface/progress.h [new file with mode: 0644]
tools/apps/ode/rework/ode.cpp
tools/apps/ode/rework/ode.h

index 76e5a51..95533c3 100755 (executable)
@@ -45,6 +45,7 @@ SET(REWORK_SRC
                        ./rework/application.cpp
                        ./rework/interface/interface.cpp
                        ./rework/interface/page.cpp
+                       ./rework/interface/progress.cpp
                        ./rework/interface/internal/encrypt-device.cpp
                        ./rework/interface/internal/decrypt-device.cpp
                        ./rework/interface/external/encrypt-sdcard.cpp
diff --git a/tools/apps/ode/res/edc_resource/progress.edc b/tools/apps/ode/res/edc_resource/progress.edc
new file mode 100644 (file)
index 0000000..329cb47
--- /dev/null
@@ -0,0 +1,132 @@
+group { name : "progress,layout";
+       styles {
+               style { name: "progress,title";
+                       base: "font=Tizen:style=Regular font_size=28 color=#ffffff wrap=mixed align=center text_class=tizen";
+                       tag: "br" "\n";
+               }
+               style { name: "progress,content";
+                       base: "font=Tizen:style=Regular font_size=24 color=#ffffff wrap=mixed align=center text_class=tizen";
+                       tag: "br" "\n";
+               }
+       }
+       images {
+               image: "../images/icon_security.png" COMP;
+               image: "../images/icon_security_off.png" COMP;
+               image: "../images/icon_security_sdcard.png" COMP;
+               image: "../images/icon_security_off_sdcard.png" COMP;
+       }
+       parts {
+               rect { name: "base";
+                       desc { "default";
+                               rel1 { relative: 0.0 0.0;}
+                               rel2 { relative: 1.0 1.0;}
+                               color: 55 166 184 255;
+                       }
+               }
+               spacer { "icon,top,padding";
+                       desc { "default";
+                               rel1 { relative: 0.0 0.0;}
+                               rel2 { relative: 1.0 0.0; offset: 0 254; to: "base";}
+                       }
+               }
+               image { "iconbase";
+                       desc { "default";
+                               min: 242 242;
+                               max: 242 242;
+                               rel1 { relative: 0.0 1.0; to: "icon,top,padding";}
+                               rel2 { relative: 1.0 1.0; offset: 0 242; to: "icon,top,padding";}
+                               align: 0.5 0.5;
+                       }
+               }
+               swallow { "message_title";
+                       desc { "default";
+                               align: 0.5 0.5;
+                               rel1 { relative: 0.0 1.0; offset: 32 46; to_x: "base"; to_y: "iconbase";}
+                               rel2 { relative: 1.0 1.0; offset: -32 100; to_x: "base"; to_y: "iconbase";}
+                       }
+               }
+               swallow { "progressbar";
+                       desc { "default";
+                               rel1 { relative: 0.0 1.0; offset: 0 0; to: "message_title";}
+                               rel2 { relative: 1.0 1.0; offset: 0 54; to: "message_title";}
+                               align: 0.5 0.5;
+                               fixed: 1 1;
+                       }
+               }
+               textblock { "progress_percentage";
+                       desc { "default";
+                               text { style: "progress,content";
+                                       min: 0 1;
+                                       align: 0.5 0.5;
+                               }
+                               rel1 { relative: 0.0 1.0; offset: 0 0; to: "progressbar";}
+                               rel2 { relative: 1.0 1.0; offset: 0 54; to: "progressbar";}
+                       }
+               }
+               spacer { "message,top,padding";
+                       desc { "default";
+                               rel1 { relative: 0.0 1.0; offset: 0 0; to: "progress_percentage";}
+                               rel2 { relative: 1.0 1.0; offset: 0 157; to: "progress_percentage";}
+                       }
+               }
+               swallow { "message_content";
+                       desc { "default";
+                               align: 0.5 0.0;
+                               rel1 { relative: 0.0 1.0; offset: 0 0; to: "message,top,padding";}
+                               rel2 { relative: 1.0 1.0; offset: -32 0;}
+                       }
+               }
+       }
+}
+
+group { name: "external,encryption,progress";
+       inherit: "progress,layout";
+       parts {
+               image { name: "icon";
+                       inherit: "iconbase";
+                       desc { "default";
+                               align: 0.5 0.5;
+                               image.normal: "../images/icon_security_sdcard.png";
+                       }
+               }
+       }
+}
+
+group { name: "external,decryption,progress";
+       inherit: "progress,layout";
+       parts {
+               image { name: "icon";
+                       inherit: "iconbase";
+                       desc { "default";
+                               align: 0.5 0.5;
+                               image.normal: "../images/icon_security_off_sdcard.png";
+                       }
+               }
+       }
+}
+
+group { name: "internal,encryption,progress";
+       inherit: "progress,layout";
+       parts {
+               image { name: "icon";
+                       inherit: "iconbase";
+                       desc { "default";
+                               align: 0.5 0.5;
+                               image.normal: "../images/icon_security.png";
+                       }
+               }
+       }
+}
+
+group { name: "internal,decryption,progress";
+       inherit: "progress,layout";
+       parts {
+               image { name: "icon";
+                       inherit: "iconbase";
+                       desc { "default";
+                               align: 0.5 0.5;
+                               image.normal: "../images/icon_security_off.png";
+                       }
+               }
+       }
+}
index c9421d1..eb5235c 100644 (file)
@@ -28,5 +28,6 @@ collections {
        #include "./edc_resource/check-item.edc"
        #include "./edc_resource/internal.edc"
        #include "./edc_resource/external.edc"
+       #include "./edc_resource/progress.edc"
        #include "./edc_resource/entry-popup.edc"
 }
index 1b27709..2fdcfa3 100644 (file)
@@ -67,7 +67,7 @@ void DecryptSDCardConfirm::setPartContent()
 }
 
 DecryptSDCardInterface::DecryptSDCardInterface()
-       : exitButton(naviframe), infoPage(nullptr), confirmPage(nullptr), passwordConfirm(nullptr)
+       : exitButton(naviframe), infoPage(nullptr), confirmPage(nullptr), passwordConfirm(nullptr), progress(window)
 {
        setNaviframe();
 }
@@ -81,7 +81,9 @@ void DecryptSDCardInterface::onConfirmed(int result, const std::string &data)
        /* TBD : result == -1 In case of reset SD card */
        if (result == 1) {
                encryption.decrypt(data);
-               dispose();
+               naviframe->dispose();
+               setFullContent(&progress);
+               progress.start();
        }
 }
 
@@ -108,7 +110,7 @@ void DecryptSDCardInterface::create()
                naviframe->popItem();
        };
 
-       infoPage.reset(new DecryptSDCardInfo {naviframe});
+       infoPage.reset(new DecryptSDCardInfo{naviframe});
        infoPage->nextButton->onClickSignal.connect(this, &DecryptSDCardInterface::createConfirmPage);
        item = naviframe->pushPage(dgetText("IDS_ST_HEADER_DECRYPT_SD_CARD"), infoPage.get(), &exitButton);
        item->pagePopEvent.connect(this, &DecryptSDCardInterface::dispose);
index 705c3ee..122dfae 100644 (file)
@@ -20,6 +20,7 @@
 #define __ODE_DECRYPT_SD_CARD_H__
 
 #include "../interface.h"
+#include "../progress.h"
 #include "../../widgets/button.h"
 #include "../tools/encryption.h"
 #include "../external-locktype/password.h"
@@ -62,6 +63,7 @@ private:
        std::unique_ptr<DecryptSDCardConfirm> confirmPage;
        std::unique_ptr<PasswordConfirm> passwordConfirm;
        ExternalEncryption encryption;
+       ExternalDecryptProgress progress;
 };
 
 #endif
index 4e40678..d8f2f28 100644 (file)
@@ -255,7 +255,7 @@ void EncryptSDCardConfirm::setPartContent()
 }
 
 EncryptSDCardInterface::EncryptSDCardInterface()
-       : exitButton(nullptr), infoPage(nullptr), checkPage(nullptr), confirmPage(nullptr), passwordConfirm(nullptr)
+       : exitButton(nullptr), infoPage(nullptr), checkPage(nullptr), confirmPage(nullptr), passwordConfirm(nullptr), progress(window)
 {
        setNaviframe();
 }
@@ -271,7 +271,9 @@ void EncryptSDCardInterface::onConfirmed(int result, const std::string &data)
                checkPage->passwordResultCallback(0, data);
        } else if (result == 1) {
                encryption.encrypt(data, confirmPage->getOption());
-               dispose();
+               naviframe->dispose();
+               setFullContent(&progress);
+               progress.start();
        }
 }
 
index 0288148..6652698 100644 (file)
@@ -20,6 +20,7 @@
 #define __ODE_ENCRYPT_SD_CARD_H__
 
 #include "../interface.h"
+#include "../progress.h"
 #include "../tools/vconf.h"
 #include "../tools/encryption.h"
 #include "../../widgets/genlist.h"
@@ -103,6 +104,7 @@ public:
        void createConfirmPage();
        void onConfirmed(int result, const std::string &data);
        void checkPassword();
+       void cryptoStateChangedCallback();
 
 private:
        std::unique_ptr<Button> exitButton;
@@ -111,6 +113,7 @@ private:
        std::unique_ptr<EncryptSDCardConfirm> confirmPage;
        std::unique_ptr<PasswordConfirm> passwordConfirm;
        ExternalEncryption encryption;
+       ExternalEncryptProgress progress;
 };
 
 #endif
diff --git a/tools/apps/ode/rework/interface/progress.cpp b/tools/apps/ode/rework/interface/progress.cpp
new file mode 100644 (file)
index 0000000..482d7b3
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ *
+ * Copyright (c) 2017 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.
+ *
+ */
+#include "progress.h"
+
+ProgressPage::ProgressPage(Widget *parent, const std::string &group, const std::string &key)
+       : Layout{parent, "/usr/apps/org.tizen.ode/res/org.tizen.ode.edj", group},
+         vconf(key),
+         progressbar(this, Progressbar::Config::SetPulse),
+         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'")
+{
+       progressbar.setValue(0.0);
+       setContent("progressbar", &progressbar);
+}
+
+ProgressPage::~ProgressPage()
+{
+       timer.dispose();
+}
+
+void ProgressPage::start()
+{
+       timer.add(0.1);
+       timer.onTimer = [this]() {
+               return setProgress();
+       };
+}
+
+bool ProgressPage::setProgress()
+{
+       std::string stringValue = vconf.getString();
+       int percentage = 0;
+
+       percentage = ::atoi(stringValue.c_str());
+       progressbar.setValue(percentage/100.0);
+       stringValue.append("%");
+       setText("progress_percentage", stringValue);
+
+       if (percentage == 100) {
+               timer.dispose();
+               ::ui_app_exit();
+               return ECORE_CALLBACK_DONE;
+       }
+       return ECORE_CALLBACK_PASS_ON;
+}
+
+ExternalEncryptProgress::ExternalEncryptProgress(Widget *parent)
+       : ProgressPage(parent, "external,encryption,progress", VCONFKEY_SDE_ENCRYPT_PROGRESS)
+{
+       std::string text;
+       titleText.reset(new TextBlock(this, titleStyle, dgetText("IDS_ST_BODY_ENCRYPTING_SD_CARD_ING")));
+       setContent("message_title", titleText.get());
+
+       text.append(dgetText("IDS_ST_BODY_PLEASE_WAIT"));
+       text.append("</br>");
+       text.append(dgetText("IDS_ST_BODY_ENCRYPT_ALL_NEW_FILES_SAVED_ON_THIS_SD_CARD_EXISTING_FILES_WILL_NOT_BE_ENCRYPTED"));
+       text.append("</br></br>");
+       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());
+}
+
+ExternalEncryptProgress::~ExternalEncryptProgress()
+{
+}
+
+ExternalDecryptProgress::ExternalDecryptProgress(Widget *parent)
+       : ProgressPage(parent, "external,decryption,progress", VCONFKEY_SDE_ENCRYPT_PROGRESS)
+{
+       std::string text;
+       titleText.reset(new TextBlock(this, titleStyle, dgetText("IDS_ST_BODY_DECRYPTING_SD_CARD_ING")));
+       setContent("message_title", titleText.get());
+
+       text.append(dgetText("IDS_ST_BODY_PLEASE_WAIT"));
+       text.append("</br></br>");
+       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());
+}
+
+ExternalDecryptProgress::~ExternalDecryptProgress()
+{
+}
+
+InternalEncryptProgress::InternalEncryptProgress(Widget *parent)
+       : ProgressPage(parent, "internal,encryption,progress", VCONFKEY_ODE_ENCRYPT_PROGRESS)
+{
+       std::string text;
+       titleText.reset(new TextBlock(this, titleStyle, dgetText("IDS_ST_NPBODY_ENCRYPTING_DEVICE_ING")));
+       setContent("message_title", titleText.get());
+
+       text.append(dgetText("IDS_ST_BODY_PLEASE_WAIT"));
+       text.append("</br>");
+       text.append(dgetText("IDS_ST_BODY_ONCE_THE_DEVICE_IS_ENCRYPTED_IT_WILL_RESTART"));
+       contentText.reset(new TextBlock(this, contentStyle, text));
+       setContent("message_content", contentText.get());
+}
+
+InternalEncryptProgress::~InternalEncryptProgress()
+{
+}
+
+InternalDecryptProgress::InternalDecryptProgress(Widget *parent)
+       : ProgressPage(parent, "internal,decryption,progress", VCONFKEY_ODE_ENCRYPT_PROGRESS)
+{
+       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()
+{
+}
diff --git a/tools/apps/ode/rework/interface/progress.h b/tools/apps/ode/rework/interface/progress.h
new file mode 100644 (file)
index 0000000..95a32e7
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ *
+ * Copyright (c) 2017 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.
+ *
+ */
+
+#ifndef __ODE_PROGRESS_H__
+#define __ODE_PROGRESS_H__
+
+#include "interface.h"
+#include "tools/vconf.h"
+#include "../language.h"
+#include "../widgets/layout.h"
+#include "../widgets/timer.h"
+#include "../widgets/progressbar.h"
+#include "../widgets/textblock.h"
+
+class ProgressPage : public Layout {
+public:
+       ProgressPage(Widget *parent, const std::string &group, const std::string &key);
+       ~ProgressPage();
+
+       void start();
+       bool setProgress();
+
+       Vconf vconf;
+       Progressbar progressbar;
+       Timer timer;
+
+       std::unique_ptr<TextBlock> titleText;
+       std::unique_ptr<TextBlock> contentText;
+       std::string titleStyle;
+       std::string contentStyle;
+};
+
+class ExternalEncryptProgress : public ProgressPage {
+public:
+       ExternalEncryptProgress(Widget *parent);
+       ~ExternalEncryptProgress();
+};
+
+class ExternalDecryptProgress : public ProgressPage {
+public:
+       ExternalDecryptProgress(Widget *parent);
+       ~ExternalDecryptProgress();
+};
+
+class InternalEncryptProgress : public ProgressPage {
+public:
+       InternalEncryptProgress(Widget *parent);
+       ~InternalEncryptProgress();
+};
+
+class InternalDecryptProgress : public ProgressPage {
+public:
+       InternalDecryptProgress(Widget *parent);
+       ~InternalDecryptProgress();
+};
+
+#endif
index 2362cd8..e23d70e 100644 (file)
@@ -15,7 +15,6 @@
  * limitations under the License.
  *
  */
-#include <dlog.h>
 #include "ode.h"
 
 ODELaunchPad::ODELaunchPad()
@@ -86,24 +85,38 @@ void ODELaunchPad::onTerminate()
 }
 
 ODEStandAlone::ODEStandAlone()
-       : Application("ode"), interface(nullptr)
+       : Application("ode"), interface(nullptr), progress(nullptr)
 {
 }
 
 ODEStandAlone::~ODEStandAlone()
 {
+       if (interface) {
+               delete interface;
+       }
 }
 
 void ODEStandAlone::createProgressInterface(const std::string &type, const std::string &target)
 {
+       if (interface == nullptr) {
+               interface = new ODEInterface{};
+       }
+       interface->setBaseLayout();
+
        if (!type.compare("Encrypting") && !target.compare("External")) {
-               /* TBD create interface */
+               progress.reset(new ExternalEncryptProgress(interface->getWindow()));
        } else if (!type.compare("Decrypting") && !target.compare("External")) {
-               /* TBD create interface */
+               progress.reset(new ExternalDecryptProgress(interface->getWindow()));
        } else if (!type.compare("Encrypting") && !target.compare("Internal")) {
-               /* TBD create interface */
+               progress.reset(new InternalEncryptProgress(interface->getWindow()));
+       } else if (!type.compare("Decrypting") && !target.compare("Internal")) {
+               progress.reset(new InternalDecryptProgress(interface->getWindow()));
        } else {
-               /* TBD create interface */
+               throw runtime::Exception("Do not supported viewtype");
+       }
+       if (progress) {
+               interface->setFullContent(progress.get());
+               progress->start();
        }
 }
 
index 93e8d94..9b21605 100644 (file)
 #ifndef __ODE_APPLICATION_H__
 #define __ODE_APPLICATION_H__
 
+#include <dlog.h>
 #include <vconf.h>
 
 #include "application.h"
+#include "interface/progress.h"
 #include "interface/interface.h"
 #include "interface/internal/encrypt-device.h"
 #include "interface/internal/decrypt-device.h"
@@ -61,7 +63,8 @@ public:
        int run(int argc, char *argv[]);
        void createProgressInterface(const std::string &type, const std::string &target);
 private:
-       std::unique_ptr<ODEInterface> interface;
+       ODEInterface *interface;
+       std::unique_ptr<ProgressPage> progress;
 };
 
 #endif