将正在录音(slice)修改为录音视图的subview
authorluozheng <1732036298@qq.com>
Tue, 5 Mar 2024 01:40:28 +0000 (09:40 +0800)
committerluozheng <1732036298@qq.com>
Tue, 5 Mar 2024 01:40:28 +0000 (09:40 +0800)
12 files changed:
code/sdk/application/wearable/fd230app/CMakeLists.txt
code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h
code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h
code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp
code/sdk/application/wearable/fd230app/nativeui/record/include/RecordGoingPresenter.h [deleted file]
code/sdk/application/wearable/fd230app/nativeui/record/include/RecordGoingView.h
code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPresenter.h
code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingView.h
code/sdk/application/wearable/fd230app/nativeui/record/src/RecordGoingPresenter.cpp [deleted file]
code/sdk/application/wearable/fd230app/nativeui/record/src/RecordGoingView.cpp
code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingView.cpp

index 7c64f8a..97dc252 100644 (file)
@@ -310,7 +310,6 @@ set(SOURCES
     #录音
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordDeletePresenter.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordDeleteView.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordGoingPresenter.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordGoingView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordingPlayerPresenter.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordingPlayerView.cpp
index 96f08e4..1ae0601 100644 (file)
@@ -59,7 +59,6 @@ typedef enum : uint16_t
     VIEW_RECORD,
     VIEW_RECORD_PLAY,
     VIEW_RECORD_DELETE,
-    VIEW_RECORD_GOING,
     /* ---------------------------------- 界面 ---------------------------------- */
     VIEW_DIAL,     // 切换表盘
     VIEW_MESSAGE,  // 信息通知
index 067ac99..a19f849 100644 (file)
@@ -34,7 +34,6 @@ namespace OHOS
         void InitRecordingSlice(void);
         void InitRecordingPlaySlice(void);
         void InitRecordingDeleteSlice(void);
-        void InitRecordingGoingSlice(void);
         /* ----------------------------------- 天气 ----------------------------------- */
         void InitWeatherSlice(void);
         void InitWeatherReportSlice(void);
index 7fdca67..f02c367 100644 (file)
 #include "record/include/RecordingPlayerView.h"
 #include "record/include/RecordDeletePresenter.h"
 #include "record/include/RecordDeleteView.h"
-#include "record/include/RecordGoingPresenter.h"
-#include "record/include/RecordGoingView.h"
 
 #include "BluetoothHeadsetEvent.h"
 #include "graphic_hardware_config.h"
@@ -168,8 +166,6 @@ namespace OHOS
         {VIEW_RECORD, &NativeLauncher::InitRecordingSlice}, // 录音实例化地址
         {VIEW_RECORD_PLAY, &NativeLauncher::InitRecordingPlaySlice},
         {VIEW_RECORD_DELETE, &NativeLauncher::InitRecordingDeleteSlice},
-        {VIEW_RECORD_DELETE, &NativeLauncher::InitRecordingDeleteSlice},
-        {VIEW_RECORD_GOING, &NativeLauncher::InitRecordingGoingSlice},
 
         {VIEW_MESSAGE, &NativeLauncher::InitMessageSlice},
         {VIEW_ROTATE, &NativeLauncher::InitRotateSlice},
@@ -664,13 +660,5 @@ namespace OHOS
         NativeAbility::GetInstance().AddSliceProxy(VIEW_RECORD_DELETE, recorddelete);
     }
 
-    void NativeLauncher::InitRecordingGoingSlice(void) // 正在录音
-    {
-        SliceProxy *recordgoing = new AbilitySliceProxy<RecordGoingView, RecordGoingPresenter>;
-        if (recordgoing == nullptr)
-        {
-            return;
-        }
-        NativeAbility::GetInstance().AddSliceProxy(VIEW_RECORD_GOING, recordgoing);
-    }
+    
 }
diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordGoingPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordGoingPresenter.h
deleted file mode 100644 (file)
index dd4f941..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef RECORD_GOING_PRESENTER_H\r
-#define RECORD_GOING_PRESENTER_H\r
-\r
-#include "Presenter.h"\r
-\r
-#include "RecordGoingView.h"\r
-#include "animator/animator.h"\r
-namespace OHOS\r
-{\r
-    class RecordGoingView;\r
-\r
-    class RecordGoingPresenter : public Presenter<RecordGoingView>,\r
-                                 public UIView::OnClickListener,\r
-                                 public UIView::OnDragListener\r
-    {\r
-    public:\r
-        RecordGoingPresenter();\r
-        virtual ~RecordGoingPresenter();\r
-\r
-        void OnStart() override;\r
-        void OnPause() override;\r
-        void OnResume() override;\r
-        void OnStop() override;\r
-\r
-        static RecordGoingPresenter *GetInstance();\r
-    private:\r
-        // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
-        bool OnClick(UIView &view, const ClickEvent &event) override;\r
-        bool OnDrag(UIView &view, const DragEvent &event) override;\r
-    };\r
-} // namespace OHOS\r
-\r
-#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
index c88a190..abfc4a7 100644 (file)
@@ -4,60 +4,49 @@
 #include "BaseView.h"\r
 #include "View.h"\r
 \r
-#include "components/ui_view_group.h"\r
 #include "components/ui_label.h"\r
 #include "components/ui_image_view.h"\r
 #include "components/ui_button.h"\r
 #include "components/ui_scroll_view.h"\r
-#include "animator/animator.h"\r
-#include "sys/time.h"\r
 namespace OHOS\r
 {\r
-    static constexpr int16_t TIME_CONVERT = 60; // sec to min, and min to hor\r
-    static constexpr int16_t TEXT_BUFFER_SIEZ = 20;\r
-    class TimerAnimatorCallback : public AnimatorCallback\r
-    {\r
-    public:\r
-        explicit TimerAnimatorCallback(UILabel *label) : label_(label) {}\r
-        ~TimerAnimatorCallback() override {}\r
-        void Callback(UIView *view) override;\r
-\r
-    private:\r
-        UILabel *label_ = nullptr;\r
-    };\r
 \r
-    static const char *RECORD_GOING_BUTTON_VIEWID = "RECORD_GOING_BUTTON"; // 点击按钮后停止录音\r
-    class RecordGoingPresenter;\r
-    class RecordGoingView : public View<RecordGoingPresenter>\r
+    \r
+    class RecordGoingView\r
     {\r
-\r
     public:\r
+        struct LabelConfig\r
+        {\r
+            int16_t left;\r
+            int16_t top;\r
+            int16_t width;\r
+            int16_t height;\r
+            int16_t fontSize;      // 字体大小\r
+            int16_t lineHeigh;     // 行高\r
+            const char *text;      // 文本\r
+            uint8_t lineBreakMode; // 断行模式。\r
+        };\r
         RecordGoingView();\r
         virtual ~RecordGoingView();\r
         static RecordGoingView *GetInstance(void);\r
-\r
-        void OnStart() override;\r
-        void OnSetUpView() override;\r
-        void OnTearDownView() override;\r
-        void OnStop() override;\r
+        UIScrollView *RecordGoingViewInit(void);\r
+        void ClearAll(void);\r
 \r
     private:\r
-        UIView::OnClickListener *RECORD_GOING_BUTTON_CLICK{nullptr};\r
-\r
-        void InitView(void);\r
-        void DeInitView(void);\r
-\r
-        //有bug\r
-        TimerAnimatorCallback *callBack_ = nullptr;\r
-        Animator *animator_ = nullptr;\r
-\r
-        UIViewGroup *container_ = nullptr;\r
-        UIScrollView *scrollView = nullptr;\r
-        UILabel *RECORD_GOING_LABEL1 = nullptr;\r
-        UIImageView *RECORD_GOING_IMAGE = nullptr;\r
-        UIButton *RECORD_GOING_BUTTON = nullptr;\r
-        UILabel *RECORD_GOING_LABEL2 = nullptr;\r
-        UILabel *RECORD_GOING_LABEL3 = nullptr;\r
+        bool SetUpScrollView(void);\r
+        UILabel *SetUpLabel(LabelConfig &labelconfig); // 设置标签\r
+        bool SetRecordGoingViewLabel(void);\r
+        bool SetUpImageView(void);\r
+        bool SetUpButton(void);\r
+        UIScrollView *RecordGoingViewScrollView{nullptr};\r
+        UILabel *TitleLabel{nullptr};       // 标题\r
+        UILabel *RecordGoingLabel{nullptr}; // “录音中”\r
+        UILabel *Timer{nullptr};            // 显示录音时长\r
+        UIImageView *RECORD_GOING_IMAGE{nullptr};\r
+        UIButton *RECORD_GOING_BUTTON{nullptr};\r
+\r
+        \r
+        bool initViewStatus{false};\r
     };\r
 } // namespace OHOS\r
 #endif
\ No newline at end of file
index 15d07eb..05a6154 100644 (file)
@@ -12,10 +12,10 @@ namespace OHOS
     {\r
         RECORDINGVIEW = 0, // 录音视图(slice)\r
         RECORDINGLISTVIEW, // 录音列表视图(subView)\r
-\r
+        RECORDGOINGVIEW,   // 正在录音视图\r
         MAX_RECORDINGVIEWID,\r
     } RECORDINGVIEWID;\r
-\r
+    static const char *RECORD_GOING_BUTTON_VIEWID = "RECORD_GOING_BUTTON"; // 点击按钮后停止录音\r
     class RecordListViewOnClickListener : public UIView::OnClickListener\r
     {\r
     public:\r
@@ -43,6 +43,7 @@ namespace OHOS
 \r
         static RecordingPresenter *GetInstance();\r
         int convertNumericDateTime(const char *numericDateTime, char *formattedDateTime);\r
+\r
     private:\r
         // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
         bool OnClick(UIView &view, const ClickEvent &event) override;\r
index 025a2e0..eb7fb84 100644 (file)
@@ -36,6 +36,7 @@ namespace OHOS
 \r
         bool ChangeRecordingView(int16_t thisView); // 切换到“录音”视图\r
         bool ChangeRecordListView(int16_t thisView);//切换到"录音列表"视图\r
+        bool ChangeRecordGoingView(int16_t thisView);//切换到“正在录音”视图\r
         bool ClickFunc(int16_t interface);\r
         void ChangeView(int16_t hideView, int16_t showView);\r
         UIScrollView *GetRecordingViewScrollView(int i);\r
@@ -55,7 +56,7 @@ namespace OHOS
         bool SetUpScrollView(void);\r
         bool SetTheTitle(void);\r
         UIButton *SetTheButton(ButtonConfig &buttonconfig, UIView::OnClickListener *clickListener);\r
-        UIScrollView *RecordingViewScrollView[2]{nullptr};\r
+        UIScrollView *RecordingViewScrollView[3]{nullptr};\r
         UILabel *RecordingViewTitleLabel{nullptr};\r
         UIButton *RecordingViewButton{nullptr};\r
         UILabel *AttentionLabel{nullptr};\r
diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordGoingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordGoingPresenter.cpp
deleted file mode 100644 (file)
index 3c198c3..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-#include "AppViewIDs.h"\r
-#include "NativeAbility.h"\r
-#include "string.h"\r
-#include "record/include/RecordGoingPresenter.h"\r
-#include "custom_utils.h"\r
-namespace OHOS\r
-{\r
-\r
-    // 当前Presenter属性实例化的内存指针\r
-    static RecordGoingPresenter *g_pRecordGoingPresenter = nullptr;\r
-\r
-    RecordGoingPresenter::RecordGoingPresenter()\r
-    {\r
-\r
-        g_pRecordGoingPresenter = this;\r
-    }\r
-\r
-    RecordGoingPresenter::~RecordGoingPresenter()\r
-    {\r
-\r
-        g_pRecordGoingPresenter = nullptr;\r
-    }\r
-\r
-    RecordGoingPresenter *RecordGoingPresenter::GetInstance()\r
-    {\r
-\r
-        return g_pRecordGoingPresenter;\r
-    }\r
-\r
-    void RecordGoingPresenter::OnStart()\r
-    {\r
-        Presenter<RecordGoingView>::OnStart();\r
-    }\r
-\r
-    void RecordGoingPresenter::OnPause(void)\r
-    {\r
-\r
-        Presenter<RecordGoingView>::OnPause();\r
-    }\r
-\r
-    void RecordGoingPresenter::OnResume(void)\r
-    {\r
-\r
-        Presenter<RecordGoingView>::OnResume();\r
-    }\r
-\r
-    void RecordGoingPresenter::OnStop(void)\r
-    {\r
-\r
-        Presenter<RecordGoingView>::OnStop();\r
-    }\r
-\r
-    bool RecordGoingPresenter::OnDrag(UIView &view, const DragEvent &event)\r
-    {\r
-        UNUSED(view);\r
-        UNUSED(event);\r
-    }\r
-\r
-#ifdef __cplusplus\r
-    extern "C"\r
-    {\r
-#endif\r
-        int32_t AudioCaptureSample(int32_t argc, const char *argv[]);\r
-\r
-#ifdef __cplusplus\r
-    };\r
-#endif\r
-\r
-    bool RecordGoingPresenter::OnClick(UIView &view, const ClickEvent &event)\r
-    {\r
-\r
-        // 根据控件id查找是哪个控件触发了点击回调\r
-        if (strcmp(view.GetViewId(), RECORD_GOING_BUTTON_VIEWID) == 0)\r
-        {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "End of recording....");\r
-            int32_t argc = 1;\r
-            uint8_t *argv = (uint8_t *)"stop";\r
-            AudioCaptureSample(argc, (const char **)&argv);\r
-            NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD);\r
-            return true;\r
-        }\r
-        return false;\r
-    }\r
-}
\ No newline at end of file
index f5c4375..33b40d8 100644 (file)
@@ -1,7 +1,7 @@
 #include "record/include/RecordGoingView.h"\r
-#include "record/include/RecordGoingPresenter.h"\r
+#include "record/include/RecordingPresenter.h"\r
 #include "UiConfig.h"\r
-\r
+#include "wearable_log.h"\r
 namespace OHOS\r
 {\r
 \r
@@ -9,238 +9,197 @@ namespace OHOS
 \r
     RecordGoingView::RecordGoingView()\r
     {\r
-\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordGoingView::RecordGoingView");\r
         g_pRecordGoingView = this;\r
     }\r
 \r
     RecordGoingView::~RecordGoingView()\r
     {\r
-        DeInitView();\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordGoingView::~RecordGoingView");\r
+        ClearAll();\r
         g_pRecordGoingView = nullptr;\r
     }\r
 \r
     RecordGoingView *RecordGoingView::GetInstance()\r
     {\r
-\r
         return g_pRecordGoingView;\r
     }\r
-    static void GetTime(char *buf, int len)\r
+\r
+    void RecordGoingView::ClearAll()\r
     {\r
-        struct timeval tv;\r
-        gettimeofday(&tv, NULL);\r
-        uint32_t second = tv.tv_sec % TIME_CONVERT;\r
-        uint32_t minute = tv.tv_sec / TIME_CONVERT;\r
-        uint32_t hour = (minute / TIME_CONVERT) % 24; // 24: 24 hours per day\r
-        // uint32_t realMilliSecond = tv.tv_usec / USEC_TO_MILLI;\r
-        minute = minute % TIME_CONVERT;\r
-        snprintf(buf, len, "%02d : %02d : %02d", hour, minute, second);\r
-        // sprintf_s(buf, len, "%02d : %02d : %02d", hour, minute, second);\r
+        if (initViewStatus == true)\r
+        {\r
+            RecordGoingViewScrollView->RemoveAll();\r
+\r
+            delete TitleLabel;\r
+            TitleLabel = nullptr;\r
+\r
+            delete RECORD_GOING_IMAGE;\r
+            RECORD_GOING_IMAGE = nullptr;\r
+\r
+            delete RECORD_GOING_BUTTON;\r
+            RECORD_GOING_BUTTON = nullptr;\r
+\r
+            delete Timer;\r
+            Timer = nullptr;\r
+\r
+            delete RecordGoingLabel;\r
+            RecordGoingLabel = nullptr;\r
+\r
+            delete RecordGoingViewScrollView;\r
+            RecordGoingViewScrollView = nullptr;\r
+        }\r
     }\r
 \r
-    void TimerAnimatorCallback::Callback(UIView *view)\r
+    bool RecordGoingView::SetUpScrollView(void)\r
     {\r
-        (void)view;\r
-        char buf[TEXT_BUFFER_SIEZ] = {0};\r
-        GetTime(buf, TEXT_BUFFER_SIEZ);\r
-        label_->SetText(buf);\r
-        RootView::GetInstance()->Invalidate();\r
+        RecordGoingViewScrollView = new UIScrollView();\r
+        if (RecordGoingViewScrollView == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordGoingView::RecordGoingViewScrollView new fail!");\r
+            return false;\r
+        }\r
+        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(RecordingPresenter::GetInstance());\r
+        if (draglistener == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordGoingView::draglistener can not be nullptr!");\r
+            return false;\r
+        }\r
+        RecordGoingViewScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+        RecordGoingViewScrollView->SetTouchable(true);\r
+        RecordGoingViewScrollView->SetDraggable(true);\r
+        return true;\r
     }\r
 \r
-    void RecordGoingView::InitView()\r
+    UILabel *RecordGoingView::SetUpLabel(LabelConfig &labelconfig) // 设置标签\r
     {\r
-        if (container_ == nullptr)\r
+        UILabel *label = new UILabel();\r
+        if (label == nullptr)\r
         {\r
-            container_ = new UIViewGroup();\r
-            container_->SetPosition(0, 0, 466, 466);\r
-            container_->SetStyle(STYLE_BACKGROUND_OPA, 0);\r
-            container_->SetTouchable(true);\r
+            return nullptr;\r
         }\r
-        if (scrollView == nullptr)\r
+        label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height); // 位置大小\r
+        label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize);                                       // 字体大小\r
+        label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh);                                    // 字体行高\r
+        label->SetText(labelconfig.text);                                                             // 内容\r
+        label->SetLineBreakMode(labelconfig.lineBreakMode);                                           // 断行模式。\r
+        label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+        label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize);\r
+        return label;\r
+    }\r
+\r
+    bool RecordGoingView::SetRecordGoingViewLabel(void)\r
+    {\r
+        LabelConfig labelconfig = {\r
+            .left = 188,\r
+            .top = 52,\r
+            .width = 90,\r
+            .height = 35,\r
+            .fontSize = 30,\r
+            .lineHeigh = 35,\r
+            .text = "录音机",\r
+            .lineBreakMode = UILabel::LINE_BREAK_ADAPT,\r
+        };\r
+\r
+        TitleLabel = SetUpLabel(labelconfig);\r
+        if (nullptr == TitleLabel)\r
         {\r
-            scrollView = new UIScrollView();\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordGoingView::SetRecordGoingViewLabel is nullptr!");\r
+            return false;\r
+        }\r
+        labelconfig.top = 370;\r
+        labelconfig.text = "录音中";\r
+        RecordGoingLabel = SetUpLabel(labelconfig);\r
+        if (nullptr == RecordGoingLabel)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordGoingView::RecordGoingLabel is nullptr!");\r
+            return false;\r
         }\r
-        scrollView->SetPosition(0, 0);\r
-        scrollView->Resize(466, 466);\r
-        scrollView->SetViewId("scrollView");\r
-        scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-\r
-        // Add to rootView\r
-        container_->Add(scrollView);\r
-        scrollView->SetVisible(true);\r
 \r
-        // Add Label to App\r
-        if (RECORD_GOING_LABEL1 == nullptr)\r
+        labelconfig = {\r
+            .left = 83,\r
+            .top = 290,\r
+            .width = 300,\r
+            .height = 77,\r
+            .fontSize = 65,\r
+            .lineHeigh = 76,\r
+            .text = "00:00:12",\r
+            .lineBreakMode = UILabel::LINE_BREAK_WRAP,\r
+        };\r
+        Timer = SetUpLabel(labelconfig);\r
+        if (nullptr == Timer)\r
         {\r
-            RECORD_GOING_LABEL1 = new UILabel();\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordGoingView::Timer is nullptr!");\r
+            return false;\r
         }\r
-        RECORD_GOING_LABEL1->SetPosition(188, 52);\r
-        RECORD_GOING_LABEL1->Resize(90, 35);\r
-        RECORD_GOING_LABEL1->SetViewId("RECORD_GOING_LABEL1");\r
-        RECORD_GOING_LABEL1->SetStyle(STYLE_TEXT_FONT, 30);\r
-        RECORD_GOING_LABEL1->SetStyle(STYLE_LINE_HEIGHT, 35);\r
-\r
-        // Set additional property\r
-        RECORD_GOING_LABEL1->SetText("录音机");\r
-        RECORD_GOING_LABEL1->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
-        RECORD_GOING_LABEL1->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
-        RECORD_GOING_LABEL1->SetRollSpeed(0);\r
-        RECORD_GOING_LABEL1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
-\r
-        // Add to rootView\r
-        scrollView->Add(RECORD_GOING_LABEL1);\r
-        RECORD_GOING_LABEL1->SetVisible(true);\r
-\r
-        // Add ImageView to App\r
+\r
+        return true;\r
+    }\r
+\r
+    bool RecordGoingView::SetUpImageView(void)\r
+    {\r
+        RECORD_GOING_IMAGE = new UIImageView();\r
         if (RECORD_GOING_IMAGE == nullptr)\r
         {\r
-            RECORD_GOING_IMAGE = new UIImageView();\r
         }\r
-        RECORD_GOING_IMAGE->SetPosition(158, 129);\r
-        RECORD_GOING_IMAGE->Resize(150, 150);\r
-        RECORD_GOING_IMAGE->SetViewId("RECORD_GOING_IMAGE");\r
+        RECORD_GOING_IMAGE->SetPosition(158, 129, 150, 150);\r
         RECORD_GOING_IMAGE->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
         RECORD_GOING_IMAGE->SetStyle(STYLE_BORDER_RADIUS, 15);\r
         RECORD_GOING_IMAGE->SetSrc(PNG_RECORD3_IMAGE);\r
 \r
-        // Add to rootView\r
-        scrollView->Add(RECORD_GOING_IMAGE);\r
-        RECORD_GOING_IMAGE->SetVisible(true);\r
+        return true;\r
+    }\r
 \r
-        // Add Button to App\r
+    bool RecordGoingView::SetUpButton(void)\r
+    {\r
+        RECORD_GOING_BUTTON = new UIButton();\r
         if (RECORD_GOING_BUTTON == nullptr)\r
         {\r
-            RECORD_GOING_BUTTON = new UIButton();\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordGoingView::RECORD_GOING_BUTTON new fail!");\r
         }\r
-        RECORD_GOING_BUTTON->SetPosition(210, 180);\r
-        RECORD_GOING_BUTTON->Resize(60, 60);\r
+        RECORD_GOING_BUTTON->SetPosition(210, 180, 60, 60);\r
         RECORD_GOING_BUTTON->SetViewId(RECORD_GOING_BUTTON_VIEWID);\r
         RECORD_GOING_BUTTON->SetStyle(STYLE_BACKGROUND_COLOR, 0xffff5a36);\r
         RECORD_GOING_BUTTON->SetStyle(STYLE_BORDER_RADIUS, 20);\r
 \r
-        // Set additional property\r
         RECORD_GOING_BUTTON->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
         RECORD_GOING_BUTTON->SetStyleForState(STYLE_BORDER_RADIUS, 20, UIButton::PRESSED);\r
-        // Add the CallBack about events\r
-        RECORD_GOING_BUTTON_CLICK = static_cast<UIView::OnClickListener *>(RecordGoingPresenter::GetInstance());\r
-        RECORD_GOING_BUTTON->SetOnClickListener(RECORD_GOING_BUTTON_CLICK);\r
-        // Add to rootView\r
-        scrollView->Add(RECORD_GOING_BUTTON);\r
-        RECORD_GOING_BUTTON->SetVisible(true);\r
-\r
-        // Add Label to App\r
-        if (RECORD_GOING_LABEL2 == nullptr)\r
-        {\r
-            RECORD_GOING_LABEL2 = new UILabel();\r
-        }\r
-        RECORD_GOING_LABEL2->SetPosition(107, 290);\r
-        RECORD_GOING_LABEL2->Resize(253, 77);\r
-        RECORD_GOING_LABEL2->SetViewId("RECORD_GOING_LABEL2");\r
-        RECORD_GOING_LABEL2->SetStyle(STYLE_TEXT_FONT, 65);\r
-        RECORD_GOING_LABEL2->SetStyle(STYLE_LINE_HEIGHT, 77);\r
-\r
-        // Set additional property\r
-        RECORD_GOING_LABEL2->SetText("00:00:00");\r
-        RECORD_GOING_LABEL2->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
-        RECORD_GOING_LABEL2->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
-        RECORD_GOING_LABEL2->SetRollSpeed(0);\r
-        RECORD_GOING_LABEL2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 65);\r
-\r
-        callBack_ = new TimerAnimatorCallback(RECORD_GOING_LABEL2);\r
-        animator_ = new Animator(callBack_, RECORD_GOING_LABEL2, 0, true);\r
-        animator_->Start();\r
-        // Add to rootView\r
-        container_->Add(RECORD_GOING_LABEL2);\r
-        RECORD_GOING_LABEL2->SetVisible(true);\r
-\r
-        // Add Label to App\r
-        if (RECORD_GOING_LABEL3 == nullptr)\r
-        {\r
-            RECORD_GOING_LABEL3 = new UILabel();\r
-        }\r
-        RECORD_GOING_LABEL3->SetPosition(188, 370);\r
-        RECORD_GOING_LABEL3->Resize(90, 95);\r
-        RECORD_GOING_LABEL3->SetViewId("RECORD_GOING_LABEL3");\r
-        RECORD_GOING_LABEL3->SetStyle(STYLE_TEXT_FONT, 30);\r
-        RECORD_GOING_LABEL3->SetStyle(STYLE_LINE_HEIGHT, 35);\r
-\r
-        // Set additional property\r
-        RECORD_GOING_LABEL3->SetText("录音中");\r
-        RECORD_GOING_LABEL3->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
-        RECORD_GOING_LABEL3->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
-        RECORD_GOING_LABEL3->SetRollSpeed(0);\r
-        RECORD_GOING_LABEL3->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
-\r
-        // Add to rootView\r
-        scrollView->Add(RECORD_GOING_LABEL3);\r
-        RECORD_GOING_LABEL3->SetVisible(true);\r
+\r
+        UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>(RecordingPresenter::GetInstance());\r
+        RECORD_GOING_BUTTON->SetOnClickListener(clickListener);\r
+        return true;\r
     }\r
 \r
-    void RecordGoingView::DeInitView()\r
+    UIScrollView *RecordGoingView::RecordGoingViewInit()\r
     {\r
-        if (container_ != nullptr)\r
-        {\r
-            container_->RemoveAll();\r
-        }\r
-        if (scrollView != nullptr)\r
+        if (!SetUpScrollView())\r
         {\r
-            scrollView->RemoveAll();\r
-            delete scrollView;\r
-            scrollView = nullptr;\r
+            return nullptr;\r
         }\r
-        if (RECORD_GOING_LABEL1 != nullptr)\r
-        {\r
-            delete RECORD_GOING_LABEL1;\r
-            RECORD_GOING_LABEL1 = nullptr;\r
-        }\r
-        if (RECORD_GOING_IMAGE != nullptr)\r
-        {\r
-            delete RECORD_GOING_IMAGE;\r
-            RECORD_GOING_IMAGE = nullptr;\r
-        }\r
-        if (RECORD_GOING_BUTTON != nullptr)\r
+\r
+        if (!SetRecordGoingViewLabel())\r
         {\r
-            delete RECORD_GOING_BUTTON;\r
-            RECORD_GOING_BUTTON = nullptr;\r
+            return nullptr;\r
         }\r
-        if (RECORD_GOING_LABEL2 != nullptr)\r
+\r
+        if (!SetUpImageView())\r
         {\r
-            delete RECORD_GOING_LABEL2;\r
-            RECORD_GOING_LABEL2 = nullptr;\r
+            return nullptr;\r
         }\r
-        if (RECORD_GOING_LABEL3 != nullptr)\r
+\r
+        if (!SetUpButton())\r
         {\r
-            delete RECORD_GOING_LABEL3;\r
-            RECORD_GOING_LABEL3 = nullptr;\r
+            return nullptr;\r
         }\r
-        delete container_;\r
-        container_ = nullptr;\r
-    }\r
 \r
-    void RecordGoingView::OnStart()\r
-    {\r
-        View<RecordGoingPresenter>::OnStart();\r
-        InitView();\r
-        RootView::GetInstance()->Add(container_);\r
+        /* ----------------------------------- Add ---------------------------------- */\r
+        RecordGoingViewScrollView->Add(TitleLabel);\r
+        RecordGoingViewScrollView->Add(RECORD_GOING_IMAGE);\r
+        RecordGoingViewScrollView->Add(RECORD_GOING_BUTTON);\r
+        RecordGoingViewScrollView->Add(Timer);\r
+        RecordGoingViewScrollView->Add(RecordGoingLabel);\r
+        initViewStatus = true;\r
+        return RecordGoingViewScrollView;\r
     }\r
 \r
-    void RecordGoingView::OnSetUpView()\r
-    {\r
-        View<RecordGoingPresenter>::OnSetUpView();\r
-        Draw();\r
-    }\r
-\r
-    void RecordGoingView::OnTearDownView()\r
-    {\r
-\r
-        View<RecordGoingPresenter>::OnTearDownView();\r
-        return;\r
-    }\r
-\r
-    void RecordGoingView::OnStop()\r
-    {\r
-        animator_->Stop();\r
-        View<RecordGoingPresenter>::OnStop();\r
-        RootView::GetInstance()->RemoveAll();\r
-        return;\r
-    }\r
 }
\ No newline at end of file
index 98a0882..8b86d99 100644 (file)
@@ -116,7 +116,7 @@ namespace OHOS
 \r
         // 格式化输出为上午/下午几点几分几秒\r
         strftime(formattedDateTime, 80, "%p %I点%M分%S秒", &timeinfo);\r
-\r
+        //strftime(formattedDateTime, 80, "%p %H %M %S", &timeinfo);\r
         return 1; // 转换成功\r
     }\r
 \r
@@ -132,6 +132,13 @@ namespace OHOS
 \r
     bool RecordingPresenter::OnClick(UIView &view, const ClickEvent &event)\r
     {\r
+        RecordingView *p_RecordingView = RecordingView::GetInstance();\r
+        if (p_RecordingView == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingView GetInstance fail");\r
+            return false;\r
+        }\r
+\r
         if (strcmp(view.GetViewId(), RECORD_BUTTON) == 0)\r
         {\r
             char *args[6] = {0};\r
@@ -159,7 +166,7 @@ namespace OHOS
             /* ---------------------------------- 开始录音 ---------------------------------- */\r
             AudioCaptureSample(6, (const char **)args);\r
             /* --------------------------------- 跳转到录音界面 -------------------------------- */\r
-            NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD_GOING);\r
+            p_RecordingView->ChangeView(RECORDINGVIEW, RECORDGOINGVIEW);\r
             /* ---------------------------------- 释放内存 ---------------------------------- */\r
             for (int i = 0; i < 6; ++i)\r
             {\r
@@ -169,6 +176,14 @@ namespace OHOS
             /* -------------------------------------------------------------------------- */\r
             return true;\r
         }\r
+        else if (strcmp(view.GetViewId(), RECORD_GOING_BUTTON_VIEWID) == 0)\r
+        {\r
+            int32_t argc = 1;\r
+            uint8_t *argv = (uint8_t *)"stop";\r
+            AudioCaptureSample(argc, (const char **)&argv);\r
+            p_RecordingView->ChangeView(RECORDGOINGVIEW, RECORDINGVIEW);\r
+            return true;\r
+        }\r
         return true;\r
     }\r
 \r
index c819088..4a63230 100644 (file)
@@ -54,6 +54,9 @@ namespace OHOS
             delete p_RecordListView;\r
             p_RecordListView = nullptr;\r
 \r
+            delete p_RecordGoingView;\r
+            p_RecordGoingView = nullptr;\r
+\r
             delete RecordingViewScrollView[RECORDINGVIEW];\r
             RecordingViewScrollView[RECORDINGVIEW] = nullptr;\r
         }\r
@@ -220,6 +223,24 @@ namespace OHOS
         return true;\r
     }\r
 \r
+    // 切换到“正在录音”视图\r
+    bool RecordingView::ChangeRecordGoingView(int16_t thisView)\r
+    {\r
+        if (RecordingViewScrollView[thisView] == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingView::ChangeRecordGoingView");\r
+            p_RecordGoingView = new RecordGoingView();\r
+            if (p_RecordGoingView == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingView:: new scrollView[%d] fail", thisView);\r
+                return false;\r
+            }\r
+            RecordingViewScrollView[thisView] = p_RecordGoingView->RecordGoingViewInit();\r
+            RootView::GetInstance()->Add(RecordingViewScrollView[thisView]);\r
+        }\r
+        return true;\r
+    }\r
+\r
     /* -------------------------------------------------------------------------- */\r
     // 1.RecordingViewMapper:结构体定义了一个将视图ID映射到特定成员函数指针的映射表。\r
     struct RecordingViewMapper\r
@@ -232,6 +253,7 @@ namespace OHOS
     static const RecordingViewMapper ViewMapper[] = {\r
         {RECORDINGVIEW, &RecordingView::ChangeRecordingView},\r
         {RECORDINGLISTVIEW, &RecordingView::ChangeRecordListView},\r
+        {RECORDGOINGVIEW, &RecordingView::ChangeRecordGoingView},\r
     };\r
 \r
     // 3.根据传入的interface参数执行相应视图ID关联的成员函数。\r