From: Caisking <3449750381@qq.com> Date: Tue, 28 Nov 2023 10:13:37 +0000 (+0800) Subject: 优化通话声音逻辑 X-Git-Url: http://git.snicker.com.cn/css/html/static/gitweb.css?a=commitdiff_plain;h=e0e277bc2bc2d155b210d533830d5c7d48d03807;p=mirrors%2FFD230.git 优化通话声音逻辑 --- diff --git a/.vscode/settings.json b/.vscode/settings.json index 54fe105db..d7c6654e4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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 diff --git a/code/sdk/application/wearable/nativeapp/nativeui/clock/src/DialUserView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/clock/src/DialUserView.cpp index 65a3081d8..100c55b0d 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/clock/src/DialUserView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/clock/src/DialUserView.cpp @@ -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 diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallPresenter.h index 3d9f7919b..f3ccb9715 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallPresenter.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallPresenter.h @@ -12,6 +12,7 @@ namespace OHOS class PhoneCallPresenter : public Presenter, public UIView::OnClickListener, public UIView::OnDragListener + { public: PhoneCallPresenter(); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallView.h b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallView.h index 4080c5b5a..8e608c564 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallView.h @@ -67,6 +67,7 @@ namespace OHOS void OnTearDownView() override; void OnStop() override; void Invalidate(); + void ReLabel(); void Init(); void DeInit(); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallupPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallupPresenter.h index 6d5e96071..ddd8572dd 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallupPresenter.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallupPresenter.h @@ -13,7 +13,8 @@ namespace OHOS class PhoneCallupPresenter : public Presenter, 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 diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallupView.h b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallupView.h index 952f30626..df53292bf 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallupView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallupView.h @@ -53,6 +53,7 @@ namespace OHOS UIImageView *image1_ = nullptr; UIToggleButton *toggleButton2_ = nullptr; UIButton *button1_ = nullptr; + UIButton *button2_ = nullptr; PhoneAnimatorCallback *callBack_ = nullptr; Animator *animator_ = nullptr; }; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallPresenter.cpp index 372769aca..42eee33aa 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallPresenter.cpp @@ -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"); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallView.cpp index d80c640fd..773c897db 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallView.cpp @@ -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() { diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallupPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallupPresenter.cpp index d0a7179b6..636a17a61 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallupPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallupPresenter.cpp @@ -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 diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallupView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallupView.cpp index f1149256a..a76632137 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallupView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallupView.cpp @@ -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(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) diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneDirPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneDirPresenter.cpp index 2fe8fed3c..7bfe6af0d 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneDirPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneDirPresenter.cpp @@ -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) diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhonePresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhonePresenter.cpp index bec5520be..f202a3dea 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhonePresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhonePresenter.cpp @@ -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); } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/saveele/src/SaveElePresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/saveele/src/SaveElePresenter.cpp index a8237b11c..0e2bf2c08 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/saveele/src/SaveElePresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/saveele/src/SaveElePresenter.cpp @@ -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) { diff --git a/code/sdk/application/wearable/nativeapp/nativeui/soundandvibration/src/SystemVolumePresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/soundandvibration/src/SystemVolumePresenter.cpp index f63f0846c..47949cceb 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/soundandvibration/src/SystemVolumePresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/soundandvibration/src/SystemVolumePresenter.cpp @@ -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; } diff --git a/code/sdk/application/wearable/ohos_deps/wearable_log.h b/code/sdk/application/wearable/ohos_deps/wearable_log.h index 573763392..b443fc081 100644 --- a/code/sdk/application/wearable/ohos_deps/wearable_log.h +++ b/code/sdk/application/wearable/ohos_deps/wearable_log.h @@ -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) diff --git a/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/application.bin b/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/application.bin index a8fda45cc..e46a4e1ee 100644 Binary files a/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/application.bin and b/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/application.bin differ