TizenRefApp-7613 Implement update of Done button state when add/remove record field 10/97110/2
authorNataliia Kamyshna <n.kamyshna@samsung.com>
Fri, 11 Nov 2016 07:09:06 +0000 (09:09 +0200)
committerAleksandr Sapozhnik <a.sapozhnik@samsung.com>
Mon, 14 Nov 2016 09:20:09 +0000 (01:20 -0800)
Change-Id: I8a5e2ea1f79da9b1f096b16509c8d8916d288e34
Signed-off-by: Nataliia Kamyshna <n.kamyshna@samsung.com>
lib-common/inc/Common/FileUtils.h
lib-common/inc/Common/Model/SoundRecord.h
lib-common/src/Common/FileUtils.cpp
lib-common/src/Common/Model/Memo.cpp
lib-common/src/Common/Model/SoundRecord.cpp
memo-app/inc/Input/RecordField.h
memo-app/src/Input/InputView.cpp
memo-app/src/Input/RecordField.cpp

index 4a97d65964a3dc6e8341464c59706ab918f25635..36514baedee476722bb48b0f8fa3d62305242072 100644 (file)
@@ -36,6 +36,13 @@ namespace Common
         */
        EXPORT_API bool removeFile(const char *filePath);
 
+       /**
+        * @brief Get file state.
+        * @param[in]   filePath   File path.
+        * @return true if exist, otherwise false.
+        */
+       EXPORT_API bool isFileExist(const char *filePath);
+
        /**
         * @brief Create folder.
         * @param[in]   dirPath   Destination path.
index a70841422d599f4cd5d09335709300deef6f5c42..7eb8ca4f21895bfff2bf8746ac98bf47b0c30892 100644 (file)
@@ -43,6 +43,12 @@ namespace Common
                         */
                        const std::string &getPath() const;
 
+                       /**
+                        * @brief Get record file state.
+                        * @return true if record file exist, otherwise false.
+                        */
+                       bool isExist() const;
+
                private:
                        std::string m_Path;
                };
index e0e08b1e9ad18268b7d9705c25135fc53fa50232..8aed7c0116ca8ba93c443ac49384fb356b257120 100644 (file)
@@ -42,18 +42,22 @@ bool Common::copyFile(const char *srcPath, const char *destPath)
 bool Common::removeFile(const char *filePath)
 {
        int res = 0;
-       struct stat st = {0};
-       if (filePath != NULL && stat(filePath, &st) == 0) {
+       if (isFileExist(filePath)) {
                res = std::remove(filePath);
        }
        return (res == 0);
 }
 
+bool Common::isFileExist(const char *filePath)
+{
+       struct stat st = {0};
+       return (filePath != nullptr && stat(filePath, &st) == 0);
+}
+
 bool Common::createFolder(const char *dirPath)
 {
        int res = 0;
-       struct stat st = {0};
-       if (stat(dirPath, &st) == -1) {
+       if (!isFileExist(dirPath)) {
                res = mkdir(dirPath, ACCESSPERMS);
        }
        return (res == 0);
index 240b97879c36d9dac4bf417ab1a39d808f1ebf06..ba38e3edbf3fabbf167f80e769e0b79ca12429e0 100644 (file)
@@ -213,7 +213,7 @@ bool Memo::isNew() const
 bool Memo::isEmpty() const
 {
        return (m_Title.empty() && m_Content.empty()
-                       && m_Images.empty() && !m_SoundRecord);
+                       && m_Images.empty() && (!m_SoundRecord || !m_SoundRecord->isExist()));
 }
 
 int Memo::onUpdate(void *data)
index e803e93a344356ac61e9cb53098865c7db056034..5060407bfd261a2259919b593245dff65676f160 100644 (file)
  */
 
 #include "Common/Model/SoundRecord.h"
+#include "Common/FileUtils.h"
+
 #include "App/Path.h"
 
 using namespace App;
+using namespace Common;
 using namespace Common::Model;
 
 namespace
@@ -35,3 +38,8 @@ const std::string &SoundRecord::getPath() const
 {
        return m_Path;
 }
+
+bool SoundRecord::isExist() const
+{
+       return isFileExist(m_Path.c_str());
+}
index 3fe31f15ff8b5eeff544aa78a4cbd04b8c3b25f8..0dd74f47cf1a1697ebfbbfafd5c7fad8f678b990 100644 (file)
@@ -44,6 +44,11 @@ namespace Input
                        ModePlayer
                };
 
+               /**
+                * @brief Recording start callback
+                */
+               typedef std::function<void()> RecordingStartCallback;
+
                /**
                 * @brief Delete callback
                 */
@@ -57,6 +62,12 @@ namespace Input
                explicit RecordField(std::string path, Mode mode = ModeRecorder);
                ~RecordField();
 
+               /**
+                * @brief Set recording start callback.
+                * @param[in]   callback   Recording start callback.
+                */
+               void setRecordingStartCallback(RecordingStartCallback callback);
+
                /**
                 * @brief Set delete callback.
                 * @param[in]   callback   Delete callback.
@@ -129,6 +140,7 @@ namespace Input
                Common::Recorder *m_Recorder;
                Common::Player *m_Player;
                Ecore_Timer *m_PlayTimer;
+               RecordingStartCallback m_OnRecordingStarted;
                DeleteCallback m_OnDelete;
        };
 }
index 75d0505c1ee73ae94d6c8b5f0004ed29e2caefd7..2b748061370ff0fb3b4847e9ba589f8ec0269648 100644 (file)
@@ -233,6 +233,7 @@ Evas_Object *InputView::createRecordField(Evas_Object *parent, RecordField::Mode
        m_RecordField = new RecordField(m_Memo.getSoundRecord()->getPath(), mode);
        m_RecordField->create(parent);
        m_RecordField->setRotation(getRotation());
+       m_RecordField->setRecordingStartCallback(std::bind(&InputView::onMemoChanged, this));
        m_RecordField->setDeleteCallback(std::bind(&InputView::onRecordFieldDelete, this));
 
        return m_RecordField->getEvasObject();
@@ -377,6 +378,7 @@ void InputView::onContentChanged(bool isEmpty)
 void InputView::onRecordFieldDelete()
 {
        m_Memo.removeSoundRecord();
+       onMemoChanged();
 }
 
 void InputView::onMemoChanged()
index d5ea98322a062bbfccd8729d251fbc69349468a6..68a9c5843cad48ccf29e85eb303f2983f198bbd6 100644 (file)
@@ -64,6 +64,11 @@ RecordField::~RecordField()
        delete m_Player;
 }
 
+void  RecordField::setRecordingStartCallback(RecordingStartCallback callback)
+{
+       m_OnRecordingStarted = std::move(callback);
+}
+
 void RecordField::setDeleteCallback(DeleteCallback callback)
 {
        m_OnDelete = std::move(callback);
@@ -257,6 +262,9 @@ void RecordField::onRecordPressed()
        elm_object_signal_emit(getEvasObject(), SIGNAL_ICON_REC, "*");
        elm_object_signal_emit(getEvasObject(), SIGNAL_BTN_STOP_SHOW, "*");
        elm_object_signal_emit(m_RecordBtn, SIGNAL_BTN_PAUSE, "*");
+       if (m_OnRecordingStarted) {
+               m_OnRecordingStarted();
+       }
 }
 
 void RecordField::onRecordPausePressed()