From a13b43a9b936feea232ce5e06bd2f242387ebec2 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Wed, 29 May 2024 16:12:33 +0800 Subject: [PATCH] =?utf8?q?=E9=83=A8=E5=88=86=E4=BB=A3=E7=A0=81=E6=9B=B4?= =?utf8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/alarm/src/AlarmMaxClock.cpp | 6 +- .../bluetooth/src/BluetoothEarPhoneView.cpp | 4 +- .../src/BluetoothServiceOptionsPresenter.cpp | 2 +- .../nativeui/language/LanguageInit.cpp | 2 +- .../nativeui/main/include/DialBinParser.h | 61 +++++++++++++++++++ .../nativeui/main/include/DialBinTypes.h | 1 + .../main/include/VolumeSettingPresenter.h | 4 +- .../nativeui/main/include/VolumeSettingView.h | 6 +- .../main/src/VolumeSettingPresenter.cpp | 36 +++-------- .../nativeui/main/src/VolumeSettingView.cpp | 33 ++++------ .../offlinevoice/src/VocassistPresenter.cpp | 2 +- .../offlinevoice/src/VocassistView.cpp | 2 +- .../player/include/PlayersPresenter.h | 3 +- .../nativeui/player/src/PlayersPresenter.cpp | 23 ++++--- .../src/SoundAndVibrationModel.cpp | 2 +- .../takephotos/src/TakephotosModel.cpp | 1 + .../nativeui/traing/src/TraingModel.cpp | 7 ++- 17 files changed, 114 insertions(+), 81 deletions(-) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/main/include/DialBinParser.h diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmMaxClock.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmMaxClock.cpp index 823ff674f..e2bbd4f42 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmMaxClock.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmMaxClock.cpp @@ -19,8 +19,6 @@ namespace OHOS { osTimerId_t g_stopAlarmMaxHandle = nullptr; static AlarmMaxClock *g_AlarmMaxClock = nullptr; static constexpr uint64_t MS_THREE_SECONDS = 3000; -void ScanTimerCallback(int data); -void EndScanHandle(void); static AlarmMaxClock *g_JudgeView = nullptr; constexpr int16_t CONTAINER_X = 0; @@ -104,7 +102,7 @@ void CancelScanHandle(void) } } -void EndScanHandle(void) +static void EndScanHandle(void) { OHOS::MainAlarmView::GetInstance()->ChangeView(CHANGE_INTERFACE_MAXCLOCK, MAIN_INTERFACE); } @@ -117,7 +115,7 @@ static void ScanTimerCallbackProc(int data) EndScanHandle(); } -void ScanTimerCallback(int data) +static void ScanTimerCallback(int data) { GraphicService::GetInstance()->PostGraphicEvent(std::bind(ScanTimerCallbackProc, data)); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothEarPhoneView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothEarPhoneView.cpp index e7f807cf5..2cfca9cab 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothEarPhoneView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothEarPhoneView.cpp @@ -155,7 +155,7 @@ void CancelBrScanHandle(void) WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CancelBtDiscovery results %d", results); } -void EndScanHandle(void) +static void EndScanHandle(void) { if (BluetoothModel::GetInstance()->GetCase().size() == 0) { BluetoothEarPhoneView *bluetoothEarPhoneView = BluetoothEarPhoneView::GetInstance(); @@ -210,7 +210,7 @@ static void ScanTimerCallbackProc(int data) EndScanHandle(); } -void ScanTimerCallback(int data) +static void ScanTimerCallback(int data) { GraphicService::GetInstance()->PostGraphicEvent(std::bind(ScanTimerCallbackProc, data)); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/BluetoothServiceOptionsPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/BluetoothServiceOptionsPresenter.cpp index e1d2e64c6..3f8852387 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/BluetoothServiceOptionsPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/BluetoothServiceOptionsPresenter.cpp @@ -106,8 +106,8 @@ namespace OHOS } } - return true; } + return true; } bool BluetoothServiceOptionsPresenter::OnDrag(UIView &view, const DragEvent &event) diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/LanguageInit.cpp b/code/sdk/application/wearable/fd230app/nativeui/language/LanguageInit.cpp index ef8fb9c01..6337536ea 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/LanguageInit.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/language/LanguageInit.cpp @@ -15,7 +15,7 @@ #include "language/LanguageInit.h" #include "ConfigModel.h" #include - +#include "AppViewIDs.h" namespace OHOS { // 初始化 languages 数组 diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/DialBinParser.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/DialBinParser.h new file mode 100644 index 000000000..dc737236f --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/DialBinParser.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2023 CompanyNameMagicTag. + * 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 GRAPHIC_LITE_DIAL_BIN_PARSER_H +#define GRAPHIC_LITE_DIAL_BIN_PARSER_H +#include +#include +#include "graphic_types.h" +#include "DialViewGroup.h" +#include "DialBinTypes.h" +#include "components/ui_abstract_progress.h" + +namespace OHOS { +class DialBinParser { +public: + static DialBinParser* GetInstance(void); + bool UpdateDial(const std::string& file, FILE* fp, DialViewGroup* group); + bool GetDialPreviewInfo(FILE* fp, DialPreviewInfo* info); + +protected: + int32_t ParseDialHeader(FILE* file); + int32_t ParserDialStaticImg(FILE* fp); + int32_t ParserDialSequenceImg(FILE* fp); + int32_t ParserDialRotateImg(FILE* fp); + int32_t ParserDialOptionImg(FILE* fp); + int32_t ParserDialDigitalImg(FILE* fp); + int32_t ParserDialLabel(FILE* fp); + int32_t ParserDialArcLabel(FILE* fp); + int32_t ParserDialBoxProgress(FILE* fp); + int32_t ParserDialArcProgress(FILE* fp); + int32_t ParserDialVideo(FILE* fp); + int32_t ParserDialClick(FILE* fp); + int32_t ParserDialKaleidoscope(FILE* fp); + +private: + DialBinParser(); + virtual ~DialBinParser(); + void* MallocAndReadBuf(FILE* file, uint32_t readSize); + bool SetProgressType(FILE* fp, UIAbstractProgress* view, DialProgressType data); + + static constexpr uint8_t DIAL_BIN_PARSER_FUNC_NUM = 12; // 12: func max value + int32_t (DialBinParser::*funcArray_[DIAL_BIN_PARSER_FUNC_NUM])(FILE*); + + DialViewGroup* dialGroup_ = nullptr; + std::string file_; + uint32_t dirId_ = 0xfef << 20; // 20: offset + uint32_t imageOffset_ = 0; +}; +} +#endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/DialBinTypes.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/DialBinTypes.h index 1f8f49375..366c1bec6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/DialBinTypes.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/DialBinTypes.h @@ -155,6 +155,7 @@ struct DialVideo { DialRect rect; uint32_t offset; Color32 colorKey; + uint32_t imgId; }; struct DialClick { diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/VolumeSettingPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/VolumeSettingPresenter.h index f18dac441..07a41562c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/VolumeSettingPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/VolumeSettingPresenter.h @@ -33,11 +33,12 @@ typedef enum : uint8_t { VOLUMEDRAG = 2, } VolumeChangeStatus; +class VolumeSettingView; class VolumeSliderEventListener : public UISlider::UISliderEventListener, public UIView::OnClickListener, public UIView::OnDragListener { public: - VolumeSliderEventListener(); + VolumeSliderEventListener(VolumeSettingView *volumeSetting); ~VolumeSliderEventListener(); static VolumeSliderEventListener *GetInstance(); void OnChange(int32_t progress) override; @@ -50,6 +51,7 @@ public: private: int16_t preSound{0}; int16_t playerCoefficients{0}; + VolumeSettingView *volumeSettingView{nullptr}; }; } // namespace OHOS #endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/VolumeSettingView.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/VolumeSettingView.h index efdb0d883..55740c234 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/VolumeSettingView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/VolumeSettingView.h @@ -24,17 +24,13 @@ class VolumeSettingView : public UIViewGroup { public: VolumeSettingView(); ~VolumeSettingView(); - static VolumeSettingView *GetInstance(void); int16_t sounding{0}; UISlider *GetProgress(void); bool SetUpVolume(void); UIButton *GetIncreaseButton(void); UIButton *GetDecreaseButton(void); - int get_progress_vlaue() - { - return progress->GetValue(); - } + VolumeSliderEventListener *GetVolumeEventListener(void); private: VolumeSliderEventListener *listener{nullptr}; UISlider *progress{nullptr}; diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingPresenter.cpp index 88a3091bf..d823c7484 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingPresenter.cpp @@ -25,26 +25,16 @@ namespace OHOS { extern "C" { #endif -static VolumeSliderEventListener *g_pVolumeSliderEventListener = nullptr; - constexpr int16_t SOUND_CHANGE = 10; -VolumeSliderEventListener::VolumeSliderEventListener() +VolumeSliderEventListener::VolumeSliderEventListener(VolumeSettingView *volumeSetting) : volumeSettingView(volumeSetting) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VolumeSliderEventListener new"); - g_pVolumeSliderEventListener = this; } VolumeSliderEventListener::~VolumeSliderEventListener() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VolumeSliderEventListener::~VolumeSliderEventListener"); - g_pVolumeSliderEventListener = nullptr; -} - -VolumeSliderEventListener *VolumeSliderEventListener::GetInstance() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VolumeSliderEventListener GetInstance"); - return g_pVolumeSliderEventListener; } bool VolumeSliderEventListener::OnClick(UIView& view, const ClickEvent& event) @@ -67,11 +57,6 @@ bool VolumeSliderEventListener::OnClick(UIView& view, const ClickEvent& event) void VolumeSliderEventListener::ChangeVolume(VolumeChangeStatus status) { ImageInfo *image; - VolumeSettingView *volumeSettingView = VolumeSettingView::GetInstance(); - if (volumeSettingView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick:volumeSettingView new fail"); - return; - } UISlider *progress = volumeSettingView->GetProgress(); if (progress == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick:progress new fail"); @@ -85,7 +70,7 @@ void VolumeSliderEventListener::ChangeVolume(VolumeChangeStatus status) preSound = volumeSettingView->sounding; if (status == VOLUMEUP) { - volumeSettingView->sounding = progress->GetValue() + SOUND_CHANGE; + volumeSettingView->sounding = progress->GetValue() + SOUND_CHANGE; if (volumeSettingView->sounding > VOLUME_MAX) { volumeSettingView->sounding = VOLUME_MAX; } @@ -136,8 +121,7 @@ void VolumeSliderEventListener::ChangeVolume(VolumeChangeStatus status) BtAndLocalVolumeSet(volumeSettingView->sounding); } if (playerCoefficients == VOLUMEPHONE || playerCoefficients == VOLUMEPHONENOTIFY) { - unsigned char volumeValue; - volumeValue = (unsigned char) ((double) (volumeSettingView->sounding * CALL_VOLUME_MAX) / (VOLUME_MAX - VOLUME_MIN)); // 音量转换 + unsigned char volumeValue = (unsigned char) ((double) (volumeSettingView->sounding * CALL_VOLUME_MAX) / (VOLUME_MAX - VOLUME_MIN)); // 音量转换 SetSpeakerVolume(volumeValue); } } @@ -145,14 +129,13 @@ void VolumeSliderEventListener::ChangeVolume(VolumeChangeStatus status) extern BtAvrcpTgInf g_avrcp_srv_inf; void VolumeSliderEventListener::BtAndLocalVolumeSet(int16_t sounding) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BtAndLocalVolumeSet %d", sounding); if (g_avrcp_srv_inf.avrcp_srv_conn_stat == PROFILE_STATE_CONNECTED) { uint8_t volume = sounding * AVRCP_ABSOLUTE_VOLUME_PERCENTAGE_100 / 100; // 100:本地音量最大值 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "volume 0x%x", volume); + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "avrcp volume = %d", volume); (void)avrcp_ct_set_absolute_volume(&(g_avrcp_srv_inf.bd_addr), volume); // 手表音量设置同步远端BT音量 - } else { - AudioManager::GetInstance().SetVolume(AUDIO_STREAM_MUSIC, sounding); // 本地音量设置 } + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "audio volume = %d", sounding); + AudioManager::GetInstance().SetVolume(AUDIO_STREAM_MUSIC, sounding); // 本地音量设置 } void VolumeSliderEventListener::OnRelease(int32_t value) @@ -174,11 +157,6 @@ void VolumeSliderEventListener::OnChange(int32_t value) bool VolumeSliderEventListener::OnDrag(UIView& view, const DragEvent& event) { - VolumeSettingView *volumeSettingView = VolumeSettingView::GetInstance(); - if (volumeSettingView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnDrag::volumeSettingView new fail"); - return false; - } if (strcmp(view.GetViewId(), VOLUME_VIEW) == 0) { if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VolumeSliderEventListener::OnDrag"); @@ -215,4 +193,4 @@ bool VolumeSliderEventListener::OnDrag(UIView& view, const DragEvent& event) #ifdef __cplusplus } #endif -} +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingView.cpp index 4276373a0..89e2da827 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingView.cpp @@ -10,7 +10,6 @@ #include "ui_resource_image.h" namespace OHOS { -static VolumeSettingView *g_pVolumeSettingView{nullptr}; static constexpr uint16_t BUTTON_X = 182; static constexpr uint16_t BUTTON_Y = 0; static constexpr uint16_t BUTTON_Y2 = 363; @@ -27,18 +26,15 @@ constexpr int16_t VOLUME_ERROR = (-1); VolumeSettingView::VolumeSettingView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VolumeSettingView::VolumeSettingView"); - g_pVolumeSettingView = this; } VolumeSettingView::~VolumeSettingView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VolumeSettingView::~VolumeSettingView"); RemoveAll(); - - UIView::OnClickListener *click = increaseButton->GetOnClickListener(); - if (click != nullptr) { - delete click; - click = nullptr; + if (listener != nullptr) { + delete listener; + listener = nullptr; } delete increaseButton; increaseButton = nullptr; @@ -48,13 +44,6 @@ VolumeSettingView::~VolumeSettingView() delete progress; progress = nullptr; - - g_pVolumeSettingView = nullptr; -} - -VolumeSettingView *VolumeSettingView::GetInstance(void) -{ - return g_pVolumeSettingView; } bool VolumeSettingView::SetUpVolume(void) @@ -78,7 +67,7 @@ bool VolumeSettingView::SetUpVolume(void) progress->SetRange(VOLUME_MAX, VOLUME_MIN); if (listener == nullptr) { - listener = new VolumeSliderEventListener(); + listener = new VolumeSliderEventListener(this); if (listener == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "listener new fail"); return false; @@ -88,9 +77,8 @@ bool VolumeSettingView::SetUpVolume(void) progress->SetOnClickListener(listener); progress->SetOnDragListener(listener); progress->SetKnobStyle(StyleDefault::GetSliderKnobStyle()); - UIView::OnDragListener *volDragListener = (UIView::OnDragListener *)OHOS::VolumeSliderEventListener::GetInstance(); SetViewId(VOLUME_VIEW); - SetOnDragListener(volDragListener); + SetOnDragListener(listener); SetDraggable(true); SetTouchable(true); Add(progress); @@ -117,7 +105,6 @@ UIButton *VolumeSettingView::GetDecreaseButton(void) int VolumeSettingView::ShowVolume(void) { ImageInfo *image; - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::VolumeSliderEventListener::GetInstance(); if (increaseButton == nullptr) { increaseButton = new UIButton(); if (increaseButton == nullptr) { @@ -129,7 +116,7 @@ int VolumeSettingView::ShowVolume(void) increaseButton->SetViewId(INCREASE_BUTTON); image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_INCREASE_BUTTON, PLAYER_IAMGES); increaseButton->SetImageSrc(image, image); - increaseButton->SetOnClickListener(clickListener); + increaseButton->SetOnClickListener(listener); Add(increaseButton); if (decreaseButton == nullptr) { @@ -143,9 +130,15 @@ int VolumeSettingView::ShowVolume(void) decreaseButton->SetViewId(DECREASE_BUTTON); image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_DECREASE_BUTTON, PLAYER_IAMGES); decreaseButton->SetImageSrc(image, image); - decreaseButton->SetOnClickListener(clickListener); + decreaseButton->SetOnClickListener(listener); Add(decreaseButton); return VOLUME_OK; } + +VolumeSliderEventListener *VolumeSettingView::GetVolumeEventListener(void) +{ + return listener; +} + } diff --git a/code/sdk/application/wearable/fd230app/nativeui/offlinevoice/src/VocassistPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/offlinevoice/src/VocassistPresenter.cpp index 5cd75bf95..005f6542f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/offlinevoice/src/VocassistPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/offlinevoice/src/VocassistPresenter.cpp @@ -114,7 +114,7 @@ bool VocassistPresenter::OnDrag(UIView& view, const DragEvent& event) strcmp(view.GetViewId(), VOC_ID) == 0) { // 语音助手右滑退出 int phoneStatus = VocassistModel::GetInstance()->GetPhoneDetailStatus(); // 扫描设置此时通话的状态和个数 if (phoneStatus == ONE_ROAD_AND_INCOMING) { - NativeAbility::GetInstance().ChangeSlice(VIEW_MAEKPHONE_SAMPLE); + NativeAbility::GetInstance().ChangeSlice(VIEW_INCOMING_CALL); } else { NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/offlinevoice/src/VocassistView.cpp b/code/sdk/application/wearable/fd230app/nativeui/offlinevoice/src/VocassistView.cpp index 777adfe73..9f7378770 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/offlinevoice/src/VocassistView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/offlinevoice/src/VocassistView.cpp @@ -632,7 +632,7 @@ void VoiceAssistance::ExitProgress() if (quitStatus == CONTINUTE_EXIT_MODE1) { int phoneStatus = VocassistModel::GetInstance()->GetPhoneDetailStatus(); // 扫描设置此时通话的状态和个数 if (phoneStatus == ONE_ROAD_AND_INCOMING) { - NativeAbility::GetInstance().ChangeSlice(VIEW_MAEKPHONE_SAMPLE); // 返回来电界面 + NativeAbility::GetInstance().ChangeSlice(VIEW_INCOMING_CALL); // 返回来电界面 return; } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Too long no operate, now exit vocassist"); diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersPresenter.h index 9a6b473f3..02d263b41 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersPresenter.h @@ -109,8 +109,7 @@ private: void PlayerModelButtonOnClick(); void OptionsButtonOnClick(); PlayersCaseListAdapter *m_PlayersCaseListAdapter{nullptr}; - VolumeSettingView *volumeSetting{nullptr}; - UIViewGroup *volumeSettingView{nullptr}; + VolumeSettingView *volumeSettingView{nullptr}; }; // 播放器回调 diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp index 113719006..f1ef2012f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp @@ -545,30 +545,32 @@ void ButtonOnClickListener::PlayerButtonOnClick() void ButtonOnClickListener::SoundButtonOnClick() { + PlayersView *playersView = PlayersView::GetInstance(); if (playersView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundButtonOnClick playersView nullptr err"); return; } if (volumeSettingView == nullptr) { - volumeSetting = new VolumeSettingView(); - if (volumeSetting == nullptr) { + volumeSettingView = new VolumeSettingView(); + if (volumeSettingView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "volumeSetting nullptr err"); return; } - if (volumeSetting->SetUpVolume() == false) { + if (!volumeSettingView->SetUpVolume()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "volumeSetting SetUpVolume fail"); return; } - volumeSetting->GetProgress()->SetValue(AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC)); - if (AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC) == 0) { - ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_MUTE_BUTTON, PLAYER_IAMGES); - volumeSetting->GetDecreaseButton()->SetImageSrc(image, image); - } - volumeSettingView = volumeSetting; RootView::GetInstance()->Add(volumeSettingView); } - VolumeSliderEventListener *volumeSliderEventListener = VolumeSliderEventListener::GetInstance(); + int32_t volume = AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC); + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "current volume = %d", volume); + volumeSettingView->GetProgress()->SetValue(volume); + if (volume == 0) { + ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_MUTE_BUTTON, PLAYER_IAMGES); + volumeSettingView->GetDecreaseButton()->SetImageSrc(image, image); + } + VolumeSliderEventListener *volumeSliderEventListener = volumeSettingView->GetVolumeEventListener(); if (volumeSliderEventListener == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundButtonOnClick volumeSliderEventListener nullptr err"); return; @@ -578,6 +580,7 @@ void ButtonOnClickListener::SoundButtonOnClick() volumeSettingView->SetVisible(true); // 刷新UI RootView::GetInstance()->Invalidate(); + } void ButtonOnClickListener::OptionsButtonOnClick() diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationModel.cpp index 30746d38d..3d0cbb2bd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationModel.cpp @@ -32,7 +32,7 @@ namespace OHOS //获取震动强度 int SoundAndVibrationModel::GetVibrationReminderToggleButtonStaus() { - ConfigModel::GetInstance()->GetVibrationReminder(); + return ConfigModel::GetInstance()->GetVibrationReminder(); } /// @brief 设置“静音模式”是否开启 diff --git a/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosModel.cpp index 041bb3c7f..43ea0c10f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosModel.cpp @@ -17,6 +17,7 @@ #include "takephotos/include/TakephotosView.h" #include "takephotos/include/TakephotosModel.h" #include "NativeAbility.h" +#include "AppViewIDs.h" #include "bleEvent.h" extern "C" errcode_t uapi_get_timestampe_ms(uint32_t *tm); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp index 9414602fb..053e2e5f7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp @@ -575,6 +575,7 @@ namespace OHOS return UIResourceTextId::STR_ULTRA_HIGH_STRENGTH; break; default: + return UIResourceTextId::STR_LOWER_STRENGTH; break; } } @@ -1022,7 +1023,7 @@ namespace OHOS char file_path[MAX_FILE_PATH_LENGTH] = {0}; char timeday[12] = {0}; uapi_get_YYMMDD_Time(timeday, '_'); - sprintf_s(file_path, sizeof(file_path), "%s%s.bin", TRAINING_PATH, timeday); //防止越界 + sprintf_s(file_path, sizeof(file_path), "%s%s.bin", TRAINING_PATH, timeday); // 防止越界 // Check if the directory exists, if not, create it struct stat st = {0}; @@ -1059,7 +1060,7 @@ namespace OHOS Trainingdata *read_Trainingdata_data(char *timedata, uint16_t offset) { char file_path[128] = {0}; - sprintf_s(file_path, sizeof(file_path), "%s%s.bin", TRAINING_PATH, timedata); //防止越界 + sprintf_s(file_path, sizeof(file_path), "%s%s.bin", TRAINING_PATH, timedata); // 防止越界 FILE *fp = fopen(file_path, "rb+"); Trainingdata *data = (Trainingdata *)malloc(sizeof(Trainingdata)); @@ -1205,7 +1206,7 @@ namespace OHOS cJSON *root = cJSON_Parse(jsonData.c_str()); cJSON *dataArray = cJSON_GetObjectItem(root, "data"); - int dataCount = cJSON_GetArraySize(dataArray); //获取数组大小 + int dataCount = cJSON_GetArraySize(dataArray); // 获取数组大小 SportData *sportDataArray = new SportData[dataCount]; for (int i = 0; i < dataCount; i++) -- 2.17.1