优化通话声音逻辑
authorCaisking <3449750381@qq.com>
Tue, 28 Nov 2023 10:13:37 +0000 (18:13 +0800)
committerCaisking <3449750381@qq.com>
Tue, 28 Nov 2023 10:13:37 +0000 (18:13 +0800)
16 files changed:
.vscode/settings.json
code/sdk/application/wearable/nativeapp/nativeui/clock/src/DialUserView.cpp
code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallPresenter.h
code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallView.h
code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallupPresenter.h
code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallupView.h
code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallPresenter.cpp
code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallView.cpp
code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallupPresenter.cpp
code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallupView.cpp
code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneDirPresenter.cpp
code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhonePresenter.cpp
code/sdk/application/wearable/nativeapp/nativeui/saveele/src/SaveElePresenter.cpp
code/sdk/application/wearable/nativeapp/nativeui/soundandvibration/src/SystemVolumePresenter.cpp
code/sdk/application/wearable/ohos_deps/wearable_log.h
code/sdk/tools/pkg/fwpkg/brandy/tempFiles/application.bin

index 54fe105..d7c6654 100644 (file)
@@ -7,6 +7,8 @@
     ],
     "debug.onTaskErrors": "debugAnyway",
     "files.associations": {
-        "pinctrl_porting.h": "c"
+        "pinctrl_porting.h": "c",
+        "complex": "cpp",
+        "*.inc": "cpp"
     }
 }
\ No newline at end of file
index 65a3081..100c55b 100644 (file)
@@ -106,7 +106,7 @@ namespace OHOS
 
         // Add to rootView
         container_->Add(image1_);
-        //image1_->SetVisible(true);
+        // image1_->SetVisible(true);
 
         InitDateTime();
 
@@ -129,7 +129,7 @@ namespace OHOS
 
         // Add to rootView
         container_->Add(label2_);
-        //label2_->SetVisible(true);
+        // label2_->SetVisible(true);
 
         SetCoverable(true);
     }
@@ -142,7 +142,7 @@ namespace OHOS
             viewiInitStatus = true;
         }
     }
-
+ 
     void DialUserView::InitDateTime(void)
     {
         // Add Label to App
@@ -174,7 +174,7 @@ namespace OHOS
 
         // Add to rootView
         container_->Add(label1_);
-        //label1_->SetVisible(true);
+        // label1_->SetVisible(true);
     }
 
 }
\ No newline at end of file
index 3d9f791..f3ccb97 100644 (file)
@@ -12,6 +12,7 @@ namespace OHOS
     class PhoneCallPresenter : public Presenter<PhoneCallView>,
                                public UIView::OnClickListener,
                                public UIView::OnDragListener
+
     {
     public:
         PhoneCallPresenter();
index 4080c5b..8e608c5 100644 (file)
@@ -67,6 +67,7 @@ namespace OHOS
         void OnTearDownView() override;
         void OnStop() override;
         void Invalidate();
+        void ReLabel();
         void Init();
         void DeInit();
 
index 6d5e960..ddd8572 100644 (file)
@@ -13,7 +13,8 @@ namespace OHOS
 
     class PhoneCallupPresenter : public Presenter<PhoneCallupView>,
                                  public UIView::OnClickListener,
-                                 public UIView::OnDragListener
+                                 public UIView::OnDragListener,
+                                 public UIView::OnLongPressListener
     {
     public:
         PhoneCallupPresenter();
@@ -30,6 +31,7 @@ namespace OHOS
         // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;
         bool OnClick(UIView &view, const ClickEvent &event) override;
         bool OnDrag(UIView &view, const DragEvent &event) override;
+        bool OnLongPress(UIView &view, const LongPressEvent &event);
     };
 } // namespace OHOS
 
index 952f306..df53292 100644 (file)
@@ -53,6 +53,7 @@ namespace OHOS
         UIImageView *image1_ = nullptr;
         UIToggleButton *toggleButton2_ = nullptr;
         UIButton *button1_ = nullptr;
+        UIButton *button2_ = nullptr;
         PhoneAnimatorCallback *callBack_ = nullptr;
         Animator *animator_ = nullptr;
     };
index 372769a..42eee33 100644 (file)
@@ -52,13 +52,13 @@ namespace OHOS
 
     bool PhoneCallPresenter::OnDrag(UIView &view, const DragEvent &event)
     {
-
-        if (event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT)
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&
+            (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))
         {
-            printf("draglistene is ok!\n");
             NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE);
         }
-        if (event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP)
+        if ((event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) &&
+            (event.GetStartPoint().y > 300))
         {
             NativeAbility::GetInstance().ChangeSlice(VIEW_PHONECALLING);
         }
@@ -143,11 +143,10 @@ namespace OHOS
         printf("**************************\n");
         printf("per phoneNumber: %s\n", phoneNumber.c_str());
 
-     
-        PhoneCallView::GetInstance()->Init();
+        PhoneCallView::GetInstance()->ReLabel();
 
-        //view.Invalidate();
-        // RootView::GetInstance()->Invalidate();
+        // view.Invalidate();
+        //  RootView::GetInstance()->Invalidate();
 
         printf("now phoneNumber: %s\n", phoneNumber.c_str());
         printf("**************************\n");
index d80c640..773c897 100644 (file)
@@ -90,7 +90,7 @@ namespace OHOS
         label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
         label_->SetRollSpeed(0);
         label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40);
-       
+
         // Add to rootView
         container_->Add(label_);
         label_->SetVisible(true);
@@ -114,14 +114,16 @@ namespace OHOS
             initButton(params);
         }
     }
+    void PhoneCallView::ReLabel()
+    {
+        label_->SetText(PhoneCallPresenter::GetInstance()->phoneNumber.c_str());
+    }
     void PhoneCallView::DeInit()
     {
         printf("DeInit is ok !\n");
         if (container_ != nullptr)
         {
             container_->RemoveAll();
-            delete container_;
-            container_ = nullptr;
         }
         if (button1_ != nullptr)
         {
@@ -183,6 +185,8 @@ namespace OHOS
             delete buttondel_;
             buttondel_ = nullptr;
         }
+        delete container_;
+        container_ = nullptr;
     }
     UIView *PhoneCallView::GetView()
     {
index d0a7179..636a17a 100644 (file)
@@ -70,6 +70,22 @@ namespace OHOS
         {
             NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE);
         }
+        if (strcmp(view.GetViewId(), "button2") == 0)
+        {
+            NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME);
+        }
+
+        return true;
+    }
+    bool PhoneCallupPresenter::OnLongPress(UIView &view, const LongPressEvent &event)
+    {
+        // 1.长按button1
+        // 2.退出 button1NativeAbility::GetInstance().ChangeSlice(VIEW_SAVEELE);
+        // 3.返回 true 以消耗点击事件
+        if (strcmp(view.GetViewId(), "toggleButton2") == 0)
+        {
+            NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME);
+        }
         return true;
     }
 }
\ No newline at end of file
index f114925..a766321 100644 (file)
@@ -157,32 +157,34 @@ namespace OHOS
         container_->Add(image1_);
         image1_->SetVisible(true);
 
-        // Add ToggleButton to App
-        if (toggleButton2_ == nullptr)
+        // Add Button to App
+        if (button2_ == nullptr)
         {
-            toggleButton2_ = new UIToggleButton();
+            button2_ = new UIButton();
         }
-        toggleButton2_->SetPosition(369, 207);      // widget's left position and top position
-        toggleButton2_->Resize(52, 52);             // widget's width and height
-        toggleButton2_->SetViewId("toggleButton2"); // Set style
-        toggleButton2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+        button2_->SetPosition(369, 207); // widget's left position and top position
+        button2_->Resize(52, 52);        // widget's width and height
+        button2_->SetViewId("button2");  // Set style
+        button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+        button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
 
         // Set additional property
 #ifdef _WIN32
-        char *toggleButton2selectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/voice.bin";
-#else
-        char *toggleButton2selectedImg = "/user/res/Phone/voice.bin";
-#endif
-#ifdef _WIN32
-        char *toggleButton2unSelectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/voice-no.bin";
+        char *button2defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Phone/voice.bin";
 #else
-        char *toggleButton2unSelectedImg = "/user/res/Phone/voice-no.bin";
+        char *button2defaultImgSrc = "/user/res/Phone/voice.bin";
 #endif
-        toggleButton2_->SetImages(toggleButton2selectedImg, toggleButton2unSelectedImg);
+        char *button2triggeredImgSrc = nullptr;
+        button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc);
+        button2_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);
+        button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
 
+        // Add the CallBack about events
+        UIView::OnClickListener *button2Click = static_cast<UIView::OnClickListener *>(PhoneCallupPresenter::GetInstance());
+        button2_->SetOnClickListener(button2Click);
         // Add to rootView
-        container_->Add(toggleButton2_);
-        toggleButton2_->SetVisible(true);
+        container_->Add(button2_);
+        button2_->SetVisible(true);
 
         // Add Button to App
         if (button1_ == nullptr)
index 2fe8fed..7bfe6af 100644 (file)
@@ -54,13 +54,13 @@ namespace OHOS
     bool PhoneDirPresenter::OnDrag(UIView &view, const DragEvent &event)
     {
 
-        if (event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT)
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&
+            (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))
         {
-            printf("draglistene is ok!\n");
             NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE);
         }
-         UNUSED(view);
-         return true;
+        UNUSED(view);
+        return true;
     }
 
     bool PhoneDirPresenter::OnClick(UIView &view, const ClickEvent &event)
index bec5520..f202a3d 100644 (file)
@@ -54,7 +54,8 @@ namespace OHOS
     bool PhonePresenter::OnDrag(UIView &view, const DragEvent &event)
     {
 
-        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&
+            (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))
         {
             NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
         }
index a8237b1..0e2bf2c 100644 (file)
@@ -58,8 +58,8 @@ namespace OHOS
         // {
         //     NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
         // }
-         UNUSED(view);
-         return true;
+        UNUSED(view);
+        return true;
     }
 
     bool SaveElePresenter::OnClick(UIView &view, const ClickEvent &event)
@@ -68,7 +68,9 @@ namespace OHOS
         // if (strcmp(view.GetViewId(), 控件ID) == 0)
         if (strcmp(view.GetViewId(), "button1") == 0)
         {
-            NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE);
+            // NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE);
+            uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
+            NativeAbility::GetInstance().ChangeSlice(preSlice);
         }
         if (strcmp(view.GetViewId(), "button2") == 0)
         {
index f63f084..47949cc 100644 (file)
@@ -53,10 +53,6 @@ namespace OHOS{
             uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
             NativeAbility::GetInstance().ChangeSlice(preSlice);
         }
-        // if(strcmp(view.GetViewId(), BRIGHTNESS_CONTROL_SLIDER))
-        // {
-            
-        // }
         return true;
     }
  
index 5737633..b443fc0 100644 (file)
@@ -9,7 +9,8 @@
 #define WEARABLE_LOG_H
 #ifdef __cplusplus
 #if __cplusplus
-extern "C" {
+extern "C"
+{
 #endif
 #endif
 
@@ -21,32 +22,33 @@ extern "C" {
 #include "debug_print.h"
 #endif
 
-/**
- * @brief Enumerates logging module types.
- *
- * The module type must be globally unique. A maximum of 64 module types can be defined.
- *
- * @since 1.0
- * @version 1.0
- */
-typedef enum {
-    /** applications */
-    WEARABLE_LOG_MODULE_APP = 0,
-    /** Launcher Framework */
-    WEARABLE_LOG_MODULE_LAUNCHER_FWK,
-    /** Main Service */
-    WEARABLE_LOG_MODULE_MAIN_SERVICE,
-    /** Broadcast Service */
-    WEARABLE_LOG_MODULE_BROADCASE_SERVICE,
-    /** Atomic Ability Framework */
-    WEARABLE_LOG_MODULE_AAFWK,
-    /** smart voice */
-    WEARABLE_LOG_MODULE_SMART_VOICE,
-    /* UI SERVICE */
-    WEARABLE_LOG_MODULE_UI_SERVICE,
+    /**
+     * @brief Enumerates logging module types.
+     *
+     * The module type must be globally unique. A maximum of 64 module types can be defined.
+     *
+     * @since 1.0
+     * @version 1.0
+     */
+    typedef enum
+    {
+        /** applications */
+        WEARABLE_LOG_MODULE_APP = 0,
+        /** Launcher Framework */
+        WEARABLE_LOG_MODULE_LAUNCHER_FWK,
+        /** Main Service */
+        WEARABLE_LOG_MODULE_MAIN_SERVICE,
+        /** Broadcast Service */
+        WEARABLE_LOG_MODULE_BROADCASE_SERVICE,
+        /** Atomic Ability Framework */
+        WEARABLE_LOG_MODULE_AAFWK,
+        /** smart voice */
+        WEARABLE_LOG_MODULE_SMART_VOICE,
+        /* UI SERVICE */
+        WEARABLE_LOG_MODULE_UI_SERVICE,
 
-    WEARABLE_LOG_MODULE_MAX
-} WearableLogModuleType;
+        WEARABLE_LOG_MODULE_MAX
+    } WearableLogModuleType;
 
 #ifdef USE_DIAG_LOG
 #define WEARABLE_LOGE(mod, fmt, arg...) uapi_diag_error_log(0, fmt, ##arg)
index a8fda45..e46a4e1 100644 (file)
Binary files a/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/application.bin and b/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/application.bin differ