From 1f1c950b6706791900b2ce56d93826c369454ba9 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Fri, 17 Apr 2026 09:59:57 +0800 Subject: [PATCH] =?utf8?q?1201patch=E8=A6=81=E5=88=A0=E9=99=A4=E7=9A=84?= =?utf8?q?=E6=96=87=E4=BB=B6=E5=92=8C=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../include/ui_stopwatch_resource.h | 25 - .../nativeui/add_card/src/AddCardAdapter.cpp | 59 - .../nativeui/add_card/src/AddCardItem.cpp | 58 - .../nativeui/add_card/src/AddCardModel.cpp | 37 - .../add_card/src/AddCardPresenter.cpp | 95 - .../nativeui/add_card/src/AddCardView.cpp | 108 -- .../nativeui/blood/src/BloodView.cpp | 603 ------- .../bloodoxygen/src/BloodBandoffView.cpp | 146 -- .../bloodoxygen/src/BloodOxygenModel.cpp | 42 - .../bloodoxygen/src/BloodOxygenPresenter.cpp | 140 -- .../bloodoxygen/src/BloodOxygenView.cpp | 368 ---- .../src/BluetoothCaseListAdapter.cpp | 164 -- .../src/BluetoothDeviceCaseListAdapter.cpp | 140 -- .../bluetooth/src/BluetoothDeviceListView.cpp | 195 --- .../bluetooth/src/BluetoothEarListView.cpp | 185 -- .../bluetooth/src/BluetoothEarPhoneView.cpp | 273 --- .../bluetooth/src/BluetoothHeadsetEvent.cpp | 480 ------ .../bluetooth/src/BluetoothItemView.cpp | 164 -- .../nativeui/bluetooth/src/BluetoothModel.cpp | 1522 ----------------- .../bluetooth/src/BluetoothOptionsView.cpp | 227 --- .../bluetooth/src/BluetoothPresenter.cpp | 214 --- .../bluetooth/src/BluetoothReconnectView.cpp | 174 -- .../bluetooth/src/MainBluetoothView.cpp | 447 ----- .../bluetooth/src/TipsConnFailMessageView.cpp | 202 --- .../bluetooth/src/TipsFailMessageView.cpp | 127 -- .../bluetooth/src/TipsSuccMessageView.cpp | 162 -- .../nativeui/breath/src/BreathDurPage.cpp | 171 -- .../nativeui/breath/src/BreathExerPage.cpp | 323 ---- .../nativeui/breath/src/BreathMainPage.cpp | 253 --- .../nativeui/breath/src/BreathModel.cpp | 259 --- .../nativeui/breath/src/BreathPresenter.cpp | 13 - .../nativeui/breath/src/BreathResultPage.cpp | 353 ---- .../nativeui/breath/src/BreathRhyPage.cpp | 172 -- .../nativeui/breath/src/BreathStartPage.cpp | 197 --- .../nativeui/callerlog/src/CallerItemView.cpp | 114 -- .../nativeui/callerlog/src/CallerLogModel.cpp | 816 --------- .../callerlog/src/CallerLogPresenter.cpp | 146 -- .../nativeui/callerlog/src/CallerLogView.cpp | 271 --- .../connectnewphone/src/ConnectOpenView.cpp | 132 -- .../src/ConnectPhonePresenter.cpp | 79 - .../connectnewphone/src/ConnectPhoneView.cpp | 125 -- .../connectnewphone/src/ConnectSelectView.cpp | 121 -- .../nativeui/date/src/DateAdapter.cpp | 73 - .../nativeui/date/src/DateButtonAdapter.cpp | 73 - .../nativeui/date/src/DateItemView.cpp | 118 -- .../flashlight/src/FlashLightDefaultPage.cpp | 132 -- .../src/FlashLightSetItemAdapter.cpp | 57 - .../nativeui/heartrate/src/HeartRateView.cpp | 786 --------- .../include/add_card/AddCardAdapter.h | 46 - .../nativeui/include/add_card/AddCardItem.h | 42 - .../nativeui/include/add_card/AddCardModel.h | 34 - .../include/add_card/AddCardPresenter.h | 45 - .../nativeui/include/add_card/AddCardView.h | 47 - .../include/bloodoxygen/BloodBandoffView.h | 37 - .../include/bloodoxygen/BloodOxygenModel.h | 31 - .../bloodoxygen/BloodOxygenPresenter.h | 40 - .../include/bloodoxygen/BloodOxygenView.h | 57 - .../bluetooth/BluetoothCaseListAdapter.h | 31 - .../BluetoothDeviceCaseListAdapter.h | 30 - .../bluetooth/BluetoothDeviceListView.h | 39 - .../include/bluetooth/BluetoothEarListView.h | 43 - .../include/bluetooth/BluetoothEarPhoneView.h | 52 - .../include/bluetooth/BluetoothHeadsetEvent.h | 45 - .../include/bluetooth/BluetoothItemView.h | 44 - .../include/bluetooth/BluetoothModel.h | 140 -- .../include/bluetooth/BluetoothOptionsView.h | 42 - .../include/bluetooth/BluetoothPresenter.h | 56 - .../bluetooth/BluetoothReconnectView.h | 40 - .../include/bluetooth/MainBluetoothView.h | 70 - .../bluetooth/TipsConnFailMessageView.h | 37 - .../include/bluetooth/TipsFailMessageView.h | 30 - .../include/bluetooth/TipsSuccMessageView.h | 34 - .../nativeui/include/breath/BreathDurPage.h | 47 - .../nativeui/include/breath/BreathExerPage.h | 62 - .../nativeui/include/breath/BreathMainPage.h | 48 - .../nativeui/include/breath/BreathModel.h | 57 - .../nativeui/include/breath/BreathPresenter.h | 19 - .../include/breath/BreathResultPage.h | 55 - .../nativeui/include/breath/BreathRhyPage.h | 44 - .../nativeui/include/breath/BreathStartPage.h | 51 - .../nativeui/include/breath/BreathView.h | 24 - .../include/callerlog/CallerItemView.h | 44 - .../include/callerlog/CallerLogModel.h | 96 -- .../include/callerlog/CallerLogPresenter.h | 35 - .../include/callerlog/CallerLogView.h | 92 - .../include/connectnewphone/ConnectOpenView.h | 31 - .../connectnewphone/ConnectPhonePresenter.h | 43 - .../connectnewphone/ConnectPhoneView.h | 38 - .../connectnewphone/ConnectSelectView.h | 33 - .../nativeui/include/date/DateAdapter.h | 43 - .../nativeui/include/date/DateButtonAdapter.h | 44 - .../nativeui/include/date/DateItemView.h | 39 - .../flashlight/FlashLightDefaultPage.h | 39 - .../flashlight/FlashLightSetItemAdapter.h | 54 - .../flashlight/FlashlightUiResourceImage.h | 49 - .../nativeui/include/heartrate/HeartModel.h | 122 -- .../include/indoorwalk/CustomizationView.h | 77 - .../include/indoorwalk/IndoorWalkEndView.h | 34 - .../include/indoorwalk/IndoorWalkModel.h | 104 -- .../include/indoorwalk/IndoorWalkMotionView.h | 53 - .../indoorwalk/IndoorWalkPreparedView.h | 43 - .../include/indoorwalk/IndoorWalkPresenter.h | 134 -- .../include/indoorwalk/IndoorWalkView.h | 46 - .../include/indoorwalk/MotionPageFifth.h | 32 - .../include/indoorwalk/MotionPageFirst.h | 57 - .../include/indoorwalk/MotionPageFourth.h | 37 - .../include/indoorwalk/MotionPageSecond.h | 51 - .../include/indoorwalk/MotionPageThird.h | 45 - .../nativeui/include/main/MessageAdapter.h | 66 - .../nativeui/include/main/MessageMainView.h | 54 - .../include/makephone/CallerDisplayView.h | 38 - .../nativeui/include/makephone/CallingView.h | 45 - .../include/makephone/DialingScreenView.h | 36 - .../include/makephone/MainCallingPresenter.h | 36 - .../include/makephone/MainCallingView.h | 46 - .../include/makephone/WaitingHintsView.h | 36 - .../nativeui/include/player/BluetoothView.h | 50 - .../include/player/PlayersCaseListAdapter.h | 30 - .../include/qrcode_conn/QrcodeConnModel.h | 31 - .../include/qrcode_conn/QrcodeConnPresenter.h | 31 - .../include/qrcode_conn/QrcodeConnView.h | 45 - .../include/rebootdevice/RebootDeviceView.h | 29 - .../include/rebootdevice/RebootModel.h | 35 - .../include/rebootdevice/RebootPresenter.h | 45 - .../include/rebootdevice/RebootView.h | 48 - .../include/rebootdevice/ShutdownDeviceView.h | 29 - .../include/set_card/SetCardAdapter.h | 46 - .../include/set_card/SetCardDeleteView.h | 26 - .../nativeui/include/set_card/SetCardItem.h | 35 - .../nativeui/include/set_card/SetCardModel.h | 43 - .../include/set_card/SetCardNoCardView.h | 27 - .../include/set_card/SetCardPresenter.h | 55 - .../nativeui/include/set_card/SetCardView.h | 58 - .../nativeui/include/set_dial/SetDialInfo.h | 27 - .../nativeui/include/set_dial/SetDialModel.h | 38 - .../include/set_dial/SetDialPresenter.h | 54 - .../nativeui/include/set_dial/SetDialView.h | 53 - .../set_dial_style/SetDialStyleModel.h | 41 - .../set_dial_style/SetDialStylePresenter.h | 37 - .../include/set_dial_style/SetDialStyleView.h | 45 - .../nativeui/include/set_ota/OTACommon.h | 39 - .../nativeui/include/set_ota/OTAModel.h | 56 - .../nativeui/include/set_ota/OTAPresenter.h | 44 - .../nativeui/include/set_ota/OTAView.h | 45 - .../include/settings/SetDesktopModel.h | 35 - .../include/settings/SettingAdapter.h | 61 - .../include/settings/SettingDesktopPage.h | 53 - .../nativeui/include/settings/SettingItem.h | 22 - .../include/settings/SettingItemView.h | 39 - .../include/settings/SettingMainPage.h | 38 - .../nativeui/include/settings/SettingModel.h | 39 - .../include/sleep/SleepingDetailsPage.h | 75 - .../nativeui/include/sleep/SleepingMainPage.h | 83 - .../nativeui/include/sleep/SleepingModel.h | 82 - .../include/sleep/SleepingPresenter.h | 18 - .../nativeui/include/sleep/SleepingView.h | 22 - .../nativeui/include/sleep/TargetSleepTime.h | 50 - .../nativeui/include/sports/SportsModel.h | 44 - .../nativeui/include/sports/SportsPresenter.h | 25 - .../nativeui/include/sports/SportsView.h | 48 - .../include/stopwatch/StopwatchAdapter.h | 31 - .../include/temperature/TempClickMea.h | 31 - .../include/temperature/TempContinueWarn.h | 31 - .../include/temperature/TempExitInter.h | 31 - .../include/temperature/TempExitPrompt.h | 30 - .../include/temperature/TempInitInter.h | 34 - .../include/temperature/TempJoinStudy.h | 32 - .../include/temperature/TempLittleTip.h | 29 - .../include/temperature/TempMainView.h | 82 - .../include/temperature/TempMeaProcess.h | 38 - .../include/temperature/TempMeasure.h | 34 - .../nativeui/include/temperature/TempModel.h | 28 - .../include/temperature/TempPresenter.h | 104 -- .../include/temperature/TempPromptWear.h | 33 - .../include/temperature/TempRemindWear.h | 30 - .../nativeui/include/temperature/TempReport.h | 32 - .../include/temperature/TempStudyAbout.h | 29 - .../nativeui/include/temperature/TempWarn.h | 34 - .../nativeui/include/timers/TimerTimingPage.h | 81 - .../nativeui/include/training/DataView.h | 45 - .../nativeui/include/training/MenuView.h | 57 - .../nativeui/include/training/PauseView.h | 35 - .../nativeui/include/training/PrepareView.h | 47 - .../nativeui/include/training/PromptView.h | 34 - .../nativeui/include/training/TargetAdapter.h | 54 - .../include/training/TargetItemView.h | 38 - .../include/training/TargetSettingView.h | 36 - .../nativeui/include/training/TargetView.h | 48 - .../include/training/TrainingAdapter.h | 54 - .../include/training/TrainingItemView.h | 38 - .../nativeui/include/training/TrainingModel.h | 31 - .../include/training/TrainingPresenter.h | 45 - .../include/training/TrainingSettingAdapter.h | 54 - .../training/TrainingSettingItemView.h | 38 - .../include/training/TrainingSettingView.h | 58 - .../nativeui/include/training/TrainingView.h | 77 - .../nativeui/include/weather/WeatherAdapter.h | 60 - .../include/weather/WeatherPageSecond.h | 51 - .../include/weather/WeatherPageThird.h | 46 - .../indoorwalk/src/CustomizationView.cpp | 379 ---- .../indoorwalk/src/IndoorWalkEndView.cpp | 128 -- .../indoorwalk/src/IndoorWalkModel.cpp | 338 ---- .../indoorwalk/src/IndoorWalkMotionView.cpp | 173 -- .../indoorwalk/src/IndoorWalkPreparedView.cpp | 284 --- .../indoorwalk/src/IndoorWalkPresenter.cpp | 842 --------- .../indoorwalk/src/IndoorWalkView.cpp | 180 -- .../indoorwalk/src/MotionPageFifth.cpp | 96 -- .../indoorwalk/src/MotionPageFirst.cpp | 383 ----- .../indoorwalk/src/MotionPageFourth.cpp | 167 -- .../indoorwalk/src/MotionPageSecond.cpp | 314 ---- .../indoorwalk/src/MotionPageThird.cpp | 245 --- .../nativeui/main/src/MessageAdapter.cpp | 82 - .../nativeui/main/src/MessageMainView.cpp | 374 ---- .../makephone/src/CallerDisplayView.cpp | 159 -- .../nativeui/makephone/src/CallingView.cpp | 215 --- .../makephone/src/DialingScreenView.cpp | 152 -- .../makephone/src/MainCallingPresenter.cpp | 216 --- .../makephone/src/MainCallingView.cpp | 152 -- .../makephone/src/WaitingHintsView.cpp | 120 -- .../nativeui/player/src/BluetoothView.cpp | 356 ---- .../player/src/PlayersCaseListAdapter.cpp | 172 -- .../qrcode_conn/src/QrcodeConnModel.cpp | 20 - .../qrcode_conn/src/QrcodeConnPresenter.cpp | 39 - .../qrcode_conn/src/QrcodeConnView.cpp | 91 - .../rebootdevice/src/RebootDeviceView.cpp | 110 -- .../nativeui/rebootdevice/src/RebootModel.cpp | 51 - .../rebootdevice/src/RebootPresenter.cpp | 83 - .../nativeui/rebootdevice/src/RebootView.cpp | 273 --- .../rebootdevice/src/ShutdownDeviceView.cpp | 110 -- .../nativeui/set_card/src/SetCardAdapter.cpp | 59 - .../set_card/src/SetCardDeleteView.cpp | 53 - .../nativeui/set_card/src/SetCardItem.cpp | 39 - .../nativeui/set_card/src/SetCardModel.cpp | 72 - .../set_card/src/SetCardNoCardView.cpp | 43 - .../set_card/src/SetCardPresenter.cpp | 139 -- .../nativeui/set_card/src/SetCardView.cpp | 188 -- .../nativeui/set_dial/src/SetDialModel.cpp | 211 --- .../set_dial/src/SetDialPresenter.cpp | 110 -- .../nativeui/set_dial/src/SetDialView.cpp | 152 -- .../set_dial_style/src/SetDialStyleModel.cpp | 43 - .../src/SetDialStylePresenter.cpp | 45 - .../set_dial_style/src/SetDialStyleView.cpp | 95 - .../nativeui/set_ota/src/OTAModel.cpp | 150 -- .../nativeui/set_ota/src/OTAPresenter.cpp | 126 -- .../nativeui/set_ota/src/OTAView.cpp | 133 -- .../nativeui/settings/src/SetDesktopModel.cpp | 51 - .../nativeui/settings/src/SettingAdapter.cpp | 68 - .../settings/src/SettingDesktopPage.cpp | 195 --- .../nativeui/settings/src/SettingItemView.cpp | 79 - .../nativeui/settings/src/SettingMainPage.cpp | 174 -- .../nativeui/settings/src/SettingModel.cpp | 66 - .../sleep/src/SleepingDetailsPage.cpp | 635 ------- .../nativeui/sleep/src/SleepingMainPage.cpp | 705 -------- .../nativeui/sleep/src/SleepingModel.cpp | 283 --- .../nativeui/sleep/src/SleepingPresenter.cpp | 13 - .../nativeui/sleep/src/TargetSleepTime.cpp | 335 ---- .../nativeui/sports/src/SportsModel.cpp | 266 --- .../nativeui/sports/src/SportsPresenter.cpp | 48 - .../nativeui/sports/src/SportsView.cpp | 213 --- .../stopwatch/src/StopwatchAdapter.cpp | 63 - .../nativeui/temperature/src/TempClickMea.cpp | 143 -- .../temperature/src/TempContinueWarn.cpp | 158 -- .../temperature/src/TempExitInter.cpp | 164 -- .../temperature/src/TempExitPrompt.cpp | 127 -- .../temperature/src/TempInitInter.cpp | 235 --- .../temperature/src/TempJoinStudy.cpp | 186 -- .../temperature/src/TempLittleTip.cpp | 173 -- .../nativeui/temperature/src/TempMainView.cpp | 589 ------- .../temperature/src/TempMeaProcess.cpp | 177 -- .../nativeui/temperature/src/TempMeasure.cpp | 182 -- .../nativeui/temperature/src/TempModel.cpp | 38 - .../temperature/src/TempPresenter.cpp | 329 ---- .../temperature/src/TempPromptWear.cpp | 135 -- .../temperature/src/TempRemindWear.cpp | 121 -- .../nativeui/temperature/src/TempReport.cpp | 212 --- .../temperature/src/TempStudyAbout.cpp | 147 -- .../nativeui/temperature/src/TempWarn.cpp | 161 -- .../nativeui/timers/src/TimerTimingPage.cpp | 548 ------ .../nativeui/training/src/DataView.cpp | 363 ---- .../nativeui/training/src/MenuView.cpp | 133 -- .../nativeui/training/src/PauseView.cpp | 179 -- .../nativeui/training/src/PrepareView.cpp | 345 ---- .../nativeui/training/src/PromptView.cpp | 138 -- .../nativeui/training/src/TargetAdapter.cpp | 64 - .../nativeui/training/src/TargetItemView.cpp | 76 - .../training/src/TargetSettingView.cpp | 185 -- .../nativeui/training/src/TargetView.cpp | 134 -- .../nativeui/training/src/TrainingAdapter.cpp | 64 - .../training/src/TrainingItemView.cpp | 78 - .../nativeui/training/src/TrainingModel.cpp | 40 - .../training/src/TrainingPresenter.cpp | 213 --- .../training/src/TrainingSettingAdapter.cpp | 64 - .../training/src/TrainingSettingItemView.cpp | 75 - .../training/src/TrainingSettingView.cpp | 134 -- .../nativeui/training/src/TrainingView.cpp | 297 ---- .../nativeui/uisample/src/UISampleView.cpp | 78 - .../framework/src/test_case_list_adapter.cpp | 160 -- .../nativeui/weather/src/WeatherAdapter.cpp | 67 - .../weather/src/WeatherPageSecond.cpp | 264 --- .../nativeui/weather/src/WeatherPageThird.cpp | 206 --- .../service/device_msg/device_location.cpp | 174 -- .../evb/service/device_msg/device_location.h | 20 - .../include/notify/makephone_notification.h | 74 - .../src/notify/makephone_notification.cpp | 778 --------- .../connectnewphone/include/ConnectOpenView.h | 31 - .../include/ConnectPhonePresenter.h | 44 - .../include/ConnectPhoneView.h | 38 - .../include/ConnectSelectView.h | 33 - .../connectnewphone/src/ConnectOpenView.cpp | 132 -- .../src/ConnectPhonePresenter.cpp | 79 - .../connectnewphone/src/ConnectPhoneView.cpp | 125 -- .../connectnewphone/src/ConnectSelectView.cpp | 121 -- .../nativeui/heartrate/src/HeartModel.cpp | 1105 ------------ .../scale_item_adapter.cpp | 271 --- .../scale_item_adapter.h | 52 - .../ui_test_scale_list.cpp | 147 -- .../ui_test_scale_list.h | 39 - ...0\210\345\271\266\346\217\220\344\272\244" | 1 - .../peripheral/sensor/hal/CMakeLists.txt | 60 - .../sensor/hal/include/sensor_common.h | 40 - .../sensor/hal/include/sensor_controller.h | 27 - .../sensor/hal/include/sensor_manager.h | 43 - .../sensor/hal/include/sensor_thread.h | 67 - .../sensor/hal/src/sensor_controller.c | 446 ----- .../peripheral/sensor/hal/src/sensor_log.c | 97 -- .../sensor/hal/src/sensor_manager.c | 64 - .../peripheral/sensor/hal/src/sensor_thread.c | 157 -- .../ace_engine_lite/modules/net/http_module.h | 80 - .../websocket/include/net_websocket_debug.h | 39 - .../websocket/include/net_websocket_frame.h | 48 - .../websocket/include/net_websocket_list.h | 28 - .../websocket/include/net_websocket_opts.h | 23 - .../websocket/include/net_websocket_priv.h | 122 -- .../websocket/include/net_websocket_string.h | 19 - .../websocket/include/net_websocket_thread.h | 64 - .../modules/network_module.cpp | 149 -- .../ace_engine_lite/modules/network_module.h | 79 - .../modules/websocket/websocket_module.cpp | 293 ---- .../freertos/src/test/lwip_test.c | 63 - .../freertos/src/test/socket_test.c | 113 -- .../lwip_adapter/liteos/src/test/lwip_test.c | 63 - .../liteos/src/test/socket_test.c | 113 -- 342 files changed, 42027 deletions(-) delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativelauncher/include/ui_stopwatch_resource.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/add_card/src/AddCardAdapter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/add_card/src/AddCardItem.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/add_card/src/AddCardModel.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/add_card/src/AddCardPresenter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/add_card/src/AddCardView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/blood/src/BloodView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/bloodoxygen/src/BloodBandoffView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/bloodoxygen/src/BloodOxygenModel.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/bloodoxygen/src/BloodOxygenView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothCaseListAdapter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothDeviceListView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothEarListView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothEarPhoneView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothHeadsetEvent.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothItemView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothOptionsView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothPresenter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothReconnectView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/MainBluetoothView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/TipsConnFailMessageView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/TipsFailMessageView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/TipsSuccMessageView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathDurPage.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathExerPage.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathMainPage.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathModel.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathPresenter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathResultPage.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathRhyPage.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathStartPage.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/callerlog/src/CallerItemView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/callerlog/src/CallerLogPresenter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/callerlog/src/CallerLogView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/connectnewphone/src/ConnectOpenView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/connectnewphone/src/ConnectPhonePresenter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/connectnewphone/src/ConnectPhoneView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/connectnewphone/src/ConnectSelectView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/date/src/DateAdapter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/date/src/DateButtonAdapter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/date/src/DateItemView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/flashlight/src/FlashLightDefaultPage.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/flashlight/src/FlashLightSetItemAdapter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/heartrate/src/HeartRateView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/add_card/AddCardAdapter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/add_card/AddCardItem.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/add_card/AddCardModel.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/add_card/AddCardPresenter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/add_card/AddCardView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/bloodoxygen/BloodBandoffView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/bloodoxygen/BloodOxygenModel.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/bloodoxygen/BloodOxygenPresenter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/bloodoxygen/BloodOxygenView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothCaseListAdapter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothDeviceCaseListAdapter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothDeviceListView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothEarListView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothEarPhoneView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothHeadsetEvent.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothItemView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothModel.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothOptionsView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothPresenter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothReconnectView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/MainBluetoothView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/TipsConnFailMessageView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/TipsFailMessageView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/TipsSuccMessageView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathDurPage.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathExerPage.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathMainPage.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathModel.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathPresenter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathResultPage.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathRhyPage.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathStartPage.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/callerlog/CallerItemView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/callerlog/CallerLogModel.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/callerlog/CallerLogPresenter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/callerlog/CallerLogView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/connectnewphone/ConnectOpenView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/connectnewphone/ConnectPhonePresenter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/connectnewphone/ConnectPhoneView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/connectnewphone/ConnectSelectView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/date/DateAdapter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/date/DateButtonAdapter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/date/DateItemView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/flashlight/FlashLightDefaultPage.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/flashlight/FlashLightSetItemAdapter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/flashlight/FlashlightUiResourceImage.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/heartrate/HeartModel.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/CustomizationView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkEndView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkModel.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkMotionView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkPreparedView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkPresenter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/MotionPageFifth.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/MotionPageFirst.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/MotionPageFourth.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/MotionPageSecond.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/MotionPageThird.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/main/MessageAdapter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/main/MessageMainView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/CallerDisplayView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/CallingView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/DialingScreenView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/MainCallingPresenter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/MainCallingView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/WaitingHintsView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/player/BluetoothView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/player/PlayersCaseListAdapter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/qrcode_conn/QrcodeConnModel.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/qrcode_conn/QrcodeConnPresenter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/qrcode_conn/QrcodeConnView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/rebootdevice/RebootDeviceView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/rebootdevice/RebootModel.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/rebootdevice/RebootPresenter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/rebootdevice/RebootView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/rebootdevice/ShutdownDeviceView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardAdapter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardDeleteView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardItem.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardModel.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardNoCardView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardPresenter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial/SetDialInfo.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial/SetDialModel.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial/SetDialPresenter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial/SetDialView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial_style/SetDialStyleModel.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial_style/SetDialStylePresenter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial_style/SetDialStyleView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_ota/OTACommon.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_ota/OTAModel.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_ota/OTAPresenter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_ota/OTAView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SetDesktopModel.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingAdapter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingDesktopPage.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingItem.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingItemView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingMainPage.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingModel.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/SleepingDetailsPage.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/SleepingMainPage.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/SleepingModel.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/SleepingPresenter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/SleepingView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/TargetSleepTime.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/sports/SportsModel.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/sports/SportsPresenter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/sports/SportsView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/stopwatch/StopwatchAdapter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempClickMea.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempContinueWarn.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempExitInter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempExitPrompt.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempInitInter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempJoinStudy.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempLittleTip.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempMainView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempMeaProcess.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempMeasure.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempModel.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempPresenter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempPromptWear.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempRemindWear.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempReport.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempStudyAbout.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempWarn.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/timers/TimerTimingPage.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/DataView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/MenuView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/PauseView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/PrepareView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/PromptView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TargetAdapter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TargetItemView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TargetSettingView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TargetView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingAdapter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingItemView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingModel.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingPresenter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingSettingAdapter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingSettingItemView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingSettingView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingView.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/weather/WeatherAdapter.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/weather/WeatherPageSecond.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/include/weather/WeatherPageThird.h delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/CustomizationView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkEndView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkModel.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkMotionView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkPreparedView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkPresenter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/MotionPageFifth.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/MotionPageFirst.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/MotionPageFourth.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/MotionPageSecond.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/MotionPageThird.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/main/src/MessageAdapter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/main/src/MessageMainView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/CallerDisplayView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/CallingView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/DialingScreenView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/MainCallingView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/WaitingHintsView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/player/src/BluetoothView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/player/src/PlayersCaseListAdapter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/qrcode_conn/src/QrcodeConnModel.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/qrcode_conn/src/QrcodeConnPresenter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/qrcode_conn/src/QrcodeConnView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/rebootdevice/src/RebootDeviceView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/rebootdevice/src/RebootModel.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/rebootdevice/src/RebootPresenter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/rebootdevice/src/RebootView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/rebootdevice/src/ShutdownDeviceView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardAdapter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardDeleteView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardItem.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardModel.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardNoCardView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardPresenter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial/src/SetDialModel.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial/src/SetDialPresenter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial/src/SetDialView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial_style/src/SetDialStyleModel.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial_style/src/SetDialStylePresenter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial_style/src/SetDialStyleView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/set_ota/src/OTAModel.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/set_ota/src/OTAPresenter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/set_ota/src/OTAView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SetDesktopModel.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SettingAdapter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SettingDesktopPage.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SettingItemView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SettingMainPage.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SettingModel.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/sleep/src/SleepingDetailsPage.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/sleep/src/SleepingMainPage.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/sleep/src/SleepingModel.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/sleep/src/SleepingPresenter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/sleep/src/TargetSleepTime.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/sports/src/SportsModel.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/sports/src/SportsPresenter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/sports/src/SportsView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/stopwatch/src/StopwatchAdapter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempClickMea.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempContinueWarn.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempExitInter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempExitPrompt.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempInitInter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempJoinStudy.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempLittleTip.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempMainView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempMeaProcess.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempMeasure.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempModel.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempPresenter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempPromptWear.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempRemindWear.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempReport.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempStudyAbout.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempWarn.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/timers/src/TimerTimingPage.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/DataView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/MenuView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/PauseView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/PrepareView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/PromptView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TargetAdapter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TargetItemView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TargetSettingView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TargetView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingAdapter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingItemView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingModel.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingPresenter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingSettingAdapter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingSettingItemView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingSettingView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/uisample/src/UISampleView.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/uisample/uitest/framework/src/test_case_list_adapter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/weather/src/WeatherAdapter.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/weather/src/WeatherPageSecond.cpp delete mode 100644 code/sdk/application/wearable/evb/nativeapp/nativeui/weather/src/WeatherPageThird.cpp delete mode 100644 code/sdk/application/wearable/evb/service/device_msg/device_location.cpp delete mode 100644 code/sdk/application/wearable/evb/service/device_msg/device_location.h delete mode 100644 code/sdk/application/wearable/evb/service/msg_center/include/notify/makephone_notification.h delete mode 100644 code/sdk/application/wearable/evb/service/msg_center/src/notify/makephone_notification.cpp delete mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/include/ConnectOpenView.h delete mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/include/ConnectPhonePresenter.h delete mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/include/ConnectPhoneView.h delete mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/include/ConnectSelectView.h delete mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/src/ConnectOpenView.cpp delete mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/src/ConnectPhonePresenter.cpp delete mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/src/ConnectPhoneView.cpp delete mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/src/ConnectSelectView.cpp delete mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/src/HeartModel.cpp delete mode 100644 code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_transform_list/scale_item_adapter.cpp delete mode 100644 code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_transform_list/scale_item_adapter.h delete mode 100644 code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_transform_list/ui_test_scale_list.cpp delete mode 100644 code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_transform_list/ui_test_scale_list.h delete mode 100644 "code/sdk/open_source/openharmony/base/startup/syspara_lite/src/\346\226\207\344\273\266\345\244\2711201patch\345\220\210\345\271\266\346\217\220\344\272\244" delete mode 100644 code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/CMakeLists.txt delete mode 100644 code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/include/sensor_common.h delete mode 100644 code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/include/sensor_controller.h delete mode 100644 code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/include/sensor_manager.h delete mode 100644 code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/include/sensor_thread.h delete mode 100644 code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/src/sensor_controller.c delete mode 100644 code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/src/sensor_log.c delete mode 100644 code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/src/sensor_manager.c delete mode 100644 code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/src/sensor_thread.c delete mode 100644 code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/net/http_module.h delete mode 100644 code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_debug.h delete mode 100644 code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_frame.h delete mode 100644 code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_list.h delete mode 100644 code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_opts.h delete mode 100644 code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_priv.h delete mode 100644 code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_string.h delete mode 100644 code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_thread.h delete mode 100644 code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/network_module.cpp delete mode 100644 code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/network_module.h delete mode 100644 code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/websocket/websocket_module.cpp delete mode 100644 code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/freertos/src/test/lwip_test.c delete mode 100644 code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/freertos/src/test/socket_test.c delete mode 100644 code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/lwip_test.c delete mode 100644 code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/socket_test.c diff --git a/code/sdk/application/wearable/evb/nativeapp/nativelauncher/include/ui_stopwatch_resource.h b/code/sdk/application/wearable/evb/nativeapp/nativelauncher/include/ui_stopwatch_resource.h deleted file mode 100644 index 56019f1cd..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativelauncher/include/ui_stopwatch_resource.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2025-2025. All rights reserved. - * Description: UIStopWatchResource - * Create: 2025-06-05 - */ - -#ifndef UI_STOPWATCH_RESOURCE_H -#define UI_STOPWATCH_RESOURCE_H - -#include - -namespace OHOS { -static const int IMAGE_STOPWATCH_STOPWATCH01 = 0x100001; -static const int IMAGE_STOPWATCH_STOPWATCH02 = 0x100002; -static const int IMAGE_STOPWATCH_STOPWATCH04 = 0x100003; -static const int IMAGE_STOPWATCH_STOPWATCH06 = 0x100004; -static const int IMAGE_STOPWATCH_STOPWATCH08 = 0x100005; -static const int IMAGE_STOPWATCH_STOPWATCH10 = 0x100006; -static const int IMAGE_STOPWATCH_STOPWATCH12 = 0x100007; -static const int IMAGE_STOPWATCH_STOPWATCH14 = 0x100008; -static const int IMAGE_STOPWATCH_STOPWATCH16 = 0x100009; -static const int IMAGE_STOPWATCH_STOPWATCH19 = 0x10000a; -static const int IMAGE_STOPWATCH_STOPWATCH20 = 0x10000b; -} // OHOS -#endif // UI_STOPWATCH_RESOURCE_H diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/add_card/src/AddCardAdapter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/add_card/src/AddCardAdapter.cpp deleted file mode 100644 index b62235fec..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/add_card/src/AddCardAdapter.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: AddCardAdapter.cpp - * Author: - * Create: 2021-09-18 - */ - -#include "add_card/AddCardAdapter.h" - -namespace OHOS { -AddCardAdapter::AddCardAdapter() {} - -AddCardAdapter::~AddCardAdapter() -{ - listData_.clear(); -} - -uint16 AddCardAdapter::GetCount(void) -{ - return listData_.size(); -} - -void AddCardAdapter::ClearItem(void) -{ - listData_.clear(); -} - -UIView *AddCardAdapter::GetView(UIView *inView, int16 index) -{ - if (index >= (int16)listData_.size() || index < 0) { - return nullptr; - } - - std::list::iterator it = listData_.begin(); - for (int i = 0; i < index; i++) { - it++; - } - - AddCardItem *item = nullptr; - if (inView == nullptr) { - item = new AddCardItem(); - if (item == nullptr) { - return nullptr; - } - } else { - item = static_cast(inView); - } - - item->SetItemInfo(*it); - item->SetViewIndex(index); - item->SetOnClickListener(itemClickListener_); - return item; -} - -void AddCardAdapter::AddListItem(const AddCardInfo &item) -{ - listData_.push_back(item); -} -} // namespace OHOS diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/add_card/src/AddCardItem.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/add_card/src/AddCardItem.cpp deleted file mode 100644 index c6453a442..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/add_card/src/AddCardItem.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "add_card/AddCardItem.h" -#include "add_card/AddCardPresenter.h" -#include "wearable_log.h" - -namespace OHOS { - AddCardItem::AddCardItem() - { - SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - SetUpChild(); - Add(&cardImg_); - Add(&cardLabel_); - } - - AddCardItem::~AddCardItem() - { - Remove(&cardImg_); - Remove(&cardLabel_); - } - - void AddCardItem::SetUpChild() - { - cardImg_.SetPosition(87, 60); - cardImg_.Resize(280, 280); - cardImg_.SetResizeMode(UIImageView::FILL); - cardImg_.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); - - cardLabel_.SetPosition(175, 360); - cardLabel_.Resize(100, 50); - cardLabel_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); - } - - void AddCardItem::SetItemInfo(const AddCardInfo &cardInfo) - { - cardInfo_ = cardInfo; - cardImg_.SetSrc(cardInfo.cardImg); - if (cardInfo.addFlag) { - cardLabel_.SetText("已添加"); - } else { - cardLabel_.SetText("添加"); - } - } - - void AddCardItem::UpdateItemInfo(bool addFlag) - { - if (addFlag) { - cardLabel_.SetText("已添加"); - cardInfo_.addFlag = addFlag; - Invalidate(); - } - } - - void AddCardItem::SetOnClickListener(OnClickListener *onClickListener) - { - cardLabel_.SetOnClickListener(onClickListener); - } - -}; diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/add_card/src/AddCardModel.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/add_card/src/AddCardModel.cpp deleted file mode 100644 index 52a621627..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/add_card/src/AddCardModel.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: AddCardModel.cpp - * Author: - * Create: 2021-11-23 - */ - -#include "add_card/AddCardModel.h" -#include "kv_store.h" -#include "securec.h" - -namespace OHOS { - AddCardModel::AddCardModel() {} - - AddCardModel::~AddCardModel() {} - - AddCardModel &AddCardModel::GetInstance() - { - static AddCardModel instance; - return instance; - } - - void AddCardModel::SetSelectedCardIndex(uint8_t cardIndex) - { - selectedCardIndex = cardIndex; - } - - uint8_t AddCardModel::GetSelectedCardIndex(void) const - { - return selectedCardIndex; - } - - void AddCardModel::AddCardSetting(void) - { - MainModel::GetInstance().AddCardSetting(selectedCardIndex); - } -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/add_card/src/AddCardPresenter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/add_card/src/AddCardPresenter.cpp deleted file mode 100644 index 59474f5d9..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/add_card/src/AddCardPresenter.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: AddCardPresenter.cpp - * Author: - * Create: 2021-11-23 - */ - -#include "add_card/AddCardView.h" -#include "add_card/AddCardModel.h" -#include "add_card/AddCardPresenter.h" -#include "hal_tick.h" -#include "NativeRegisterManager.h" - - -namespace OHOS { - -REGIST_SLICE(VIEW_ADD_CARD, AddCardView, AddCardPresenter); - - AddCardPresenter::AddCardPresenter() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardPresenter::AddCardPresenter"); - model = &AddCardModel::GetInstance(); - } - - AddCardPresenter::~AddCardPresenter() { - } - - bool AddCardPresenter::OnDrag(UIView& view, const DragEvent& event) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardPresenter::OnDrag"); - UNUSED(view); - if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && - (event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardPresenter::OnDrag ChangeSlice"); - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE); - } - return false; - } - - bool AddCardPresenter::OnClick(UIView &view, const ClickEvent &event) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardPresenter::OnClick"); - if (MainModel::GetInstance().GetCardSettingCount() >= CARD_SETTING_COUNT_MAX) { - cardCountEvent = true; - view_->ExceedsCardCountEvent(true); - ResetTickTimer(); - } else { - model->AddCardSetting(); - view_->RefreshCardList(); - } - return true; - } - - void AddCardPresenter::OnScrollStart(int16_t index, UIView *view) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardPresenter::OnScrollStart index = %d", index); - return; - } - - void AddCardPresenter::OnScrollEnd(int16_t index, UIView *view) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardPresenter::OnScrollEnd index = %d", index); - if (view == nullptr) { - return; - } - model->SetSelectedCardIndex(index); - } - - void AddCardPresenter::OnItemSelected(int16_t index, UIView* view) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardPresenter::OnItemSelected index = %d", index); - if (view == nullptr) { - return; - } - } - - void AddCardPresenter::OnTickEvent() - { - if (cardCountEvent) { - uint64_t current_time = static_cast(HALTick::GetInstance().GetTime()); - if (current_time - startTime > TOAST_KEEP_TIME) { - view_->ExceedsCardCountEvent(false); - cardCountEvent = false; - } - } - return; - } - - void AddCardPresenter::ResetTickTimer(void) - { - startTime = static_cast(HALTick::GetInstance().GetTime()); - return; - } - -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/add_card/src/AddCardView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/add_card/src/AddCardView.cpp deleted file mode 100644 index 4828ac3fe..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/add_card/src/AddCardView.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: AddCardView.cpp - * Author: - * Create: 2021-11-23 - */ - -#include -#include "add_card/AddCardView.h" -#include "add_card/AddCardPresenter.h" - -namespace OHOS { -AddCardView::AddCardView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardView::AddCardView"); -} - -AddCardView::~AddCardView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardView::~AddCardView"); - if (addCardAdapter_ != nullptr) { - delete addCardAdapter_; - addCardAdapter_ = nullptr; - } -} - -void AddCardView::OnStart() -{ - addCardAdapter_ = new AddCardAdapter(); - addCardAdapter_->SetItemClickListener(presenter_); - SetUpListInfo(); - SetUpListView(); - SetUpToast(); -} - -void AddCardView::SetUpListInfo(void) -{ - MainModel::GetInstance().InitCardSettings(); - uint8_t cardCount = MainModel::GetInstance().GetCardSettingCount(); - CardId *cardSettings = MainModel::GetInstance().GetCardSettings(); - addCardAdapter_->ClearItem(); - for (uint8_t i = WATCH_FACE + 1; i < MAX_CARD; i++) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "All:cardId = %d", i); - const CardInfo *info = MainModel::GetInstance().GetCardInfo((CardId)i); - if (info != nullptr) { - AddCardInfo addInfo; - addInfo.id = info->id; - addInfo.cardImg = info->cardImg; - addInfo.addFlag = false; - for (uint8_t j = 0; j < cardCount; j++) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Settings:cardId = %d", cardSettings[j]); - if (cardSettings[j] == i) { - addInfo.addFlag = true; - break; - } - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetUpListInfo::%d %s %d", - addInfo.id, addInfo.cardImg, addInfo.addFlag); - addCardAdapter_->AddListItem(addInfo); - } - } -} - -void AddCardView::SetUpListView(void) -{ - contentList_.SetPosition(0, 0); - contentList_.Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - contentList_.SetScrollBlankSize(VERTICAL_RESOLUTION / 2); - contentList_.SetSelectPosition(VERTICAL_RESOLUTION / 2); - contentList_.SetDraggable(true); - contentList_.SetThrowDrag(true); - contentList_.EnableAutoAlign(true); - contentList_.SetScrollStateListener(presenter_); - contentList_.SetOnDragListener(presenter_); - contentList_.SetMaxScrollDistance(1000); - contentList_.SetAdapter(addCardAdapter_); - contentList_.SetVisible(true); - AddViewToRootContainer(&contentList_); -} - -void AddCardView::SetUpToast(void) -{ - toastLabel_.SetPosition(77, 220); - toastLabel_.Resize(454, 60); - toastLabel_.SetViewId("toast"); - toastLabel_.SetText("卡片数量已经到达上限"); - toastLabel_.SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full); - toastLabel_.SetStyle(STYLE_BACKGROUND_OPA, 255); - toastLabel_.SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - toastLabel_.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - toastLabel_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - toastLabel_.SetVisible(false); - AddViewToRootContainer(&toastLabel_); -} - -void AddCardView::RefreshCardList(void) -{ - SetUpListInfo(); - contentList_.RefreshList(); -} - -void AddCardView::ExceedsCardCountEvent(bool isVisible) -{ - toastLabel_.SetVisible(isVisible); - toastLabel_.Invalidate(); -} - -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/blood/src/BloodView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/blood/src/BloodView.cpp deleted file mode 100644 index 05a7801dc..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/blood/src/BloodView.cpp +++ /dev/null @@ -1,603 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: SettingView.cpp - * Author: - * Create: 2025-03-23 - */ - -#include - -#include "blood/BloodView.h" -#include "blood/BloodPresenter.h" -#include "ui_test_group.h" - -namespace OHOS { -static BloodView *g_pBloodView = nullptr; -static const char *BLOOD_LABEL_TWO = (char *)"本功能用于18岁以上健康人群测量运动过程,及之后腕部皮肤温度和体温的变化," - "请加入研究,以便及时观察运动前后身体的变化。"; -static const char *BLOOD_LABEL_THREE = (char *)"测量需佩戴10分钟以上,且容易受到环境因素影响。目前达不到水银体温计的精" - "度,测量结果仅供参考,不作为医疗诊断依据。"; -static constexpr uint16_t BLOOD_FIRST_LABEL_FONT = 35; -static constexpr uint16_t BLOOD_LABEL_FIRST_X = 45; -static constexpr uint16_t BLOOD_LABEL_FIRST_Y = 120; -static constexpr uint16_t BLOOD_LABEL_SECOND_Y = 350; -static constexpr uint16_t BLOOD_LABEL_THIRD_Y = 650; -static constexpr uint16_t BLOOD_LABEL_FIRST_WIDTH = 350; -static constexpr uint16_t BLOOD_LABEL_FIRST_HEIGHT = 400; -static constexpr uint16_t BLOOD_IMAGE_POSITION_X = 92; -static constexpr uint16_t BLOOD_IMAGE_POSITION_y = 127; -static constexpr uint16_t BLOOD_IMAGE_WIDTH = 276; -static constexpr uint16_t BLOOD_IMAGE_HEIGHT = 125; -static const char *BLOOD_LABEL_ONE = - (char *)"本功能通过内置温度传感器测量腕部皮肤温度,主要研究腕部皮肤温度和体温的关系。"; -static constexpr uint16_t WATCH_TIME_LABEL_CURTIME_XPOS = 188; -static constexpr uint16_t WATCH_TIME_LABEL_CURTIME_YPOS = 12; -static constexpr uint16_t WATCH_TIME_LABEL_CURTIME_WIDTH = 361; -static constexpr uint16_t WATCH_TIME_LABEL_CURTIME_HEIGHT = 80; -static constexpr uint16_t WATCH_TIME_LABEL_CURTIME_FONT_SIZE = 40; -static constexpr uint16_t BLOOD_LAYOUT_POSITION_X = 370; -static constexpr uint16_t BLOOD_LAYOUT_WIDTH = 320; -static constexpr uint16_t BLOOD_BUTTON_POSITION_X = 188; -static constexpr uint16_t BLOOD_BUTTON_POSITION_Y = 320; -static constexpr uint16_t BLOOD_BUTTON_WIDTH = 180; -static constexpr uint16_t BLOOD_BUTTON_HEIGHT = 80; -static constexpr uint16_t BLOOD_BUTTON_TWO_POSITION_Y = 330; -static constexpr uint16_t BLOOD_BUTTON_TWO_WIDTH = 120; -static constexpr uint16_t BLOOD_LABEL_FRONT = 25; -static constexpr uint16_t BLOOD_LABEL1_POSITION_X = 150; -static constexpr uint16_t BLOOD_LABEL1_POSITION_Y = 161; -static constexpr uint16_t BLOOD_LABEL1_WIDTH = 200; -static constexpr uint16_t BLOOD_LABEL1_HEIGHT = 60; -static constexpr uint16_t BLOOD_LABEL_FRONT1 = 60; -static constexpr uint16_t BLOOD_LABEL2_POSITION_X = 150; -static constexpr uint16_t BLOOD_LABEL2_POSITION_Y = 132; -static constexpr uint16_t BLOOD_LABEL2_WIDTH = 200; -static constexpr uint16_t BLOOD_LABEL2_HEIGHT = 60; -static constexpr uint16_t BLOOD_IMAGEANIMATOR_POSITION_X = 84; -static constexpr uint16_t BLOOD_IMAGEANIMATOR_POSITION_Y = 108; -static constexpr uint16_t BLOOD_IMAGEANIMATOR_WIDTH = 100; -static constexpr uint16_t BLOOD_IMAGEANIMATOR_HEIGHT = 100; - -static ImageAnimatorInfo g_imageAnimatorInfo[4] = { - {PNG_SETTTING_BUTTON_IMAGE, {84, 108}, 116, 116, IMG_SRC_FILE_PATH}, - {PNG_NEW_DEVICE, {84, 108}, 116, 116, IMG_SRC_FILE_PATH}, - {PNG_BT_LIST, {84, 108}, 116, 116, IMG_SRC_FILE_PATH}, - {PNG_GANTAN, {84, 108}, 116, 116, IMG_SRC_FILE_PATH}, -}; - -BloodView::BloodView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodView::BloodView"); - g_pBloodView = this; - findPhoneModel = &BloodModel::GetInstance(); -} - -BloodView::~BloodView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodView::~BloodView"); - g_pBloodView = nullptr; - if (currentTime_ != nullptr) { - delete currentTime_; - currentTime_ = nullptr; - } - if (button != nullptr) { - delete button; - button = nullptr; - } - if (buttonMore != nullptr) { - delete buttonMore; - buttonMore = nullptr; - } - if (label1_ != nullptr) { - delete label1_; - label1_ = nullptr; - } - if (label2_ != nullptr) { - delete label2_; - label2_ = nullptr; - } - if (layout_ != nullptr) { - delete layout_; - layout_ = nullptr; - } - if (currentTime_ != nullptr) { - delete currentTime_; - currentTime_ = nullptr; - } - if (group != nullptr) { - delete group; - group = nullptr; - } - if (groupTest != nullptr) { - delete groupTest; - groupTest = nullptr; - } - if (scrollGroup != nullptr) { - delete scrollGroup; - scrollGroup = nullptr; - } - for (int16_t numGroup = SET_ZERO; numGroup <= MAX_BLOOD_PAGE; numGroup++) { - if (container[numGroup] != nullptr) { - container[numGroup] = nullptr; - } - } -} - -BloodView *BloodView::GetInstance() -{ - return g_pBloodView; -} - -void BloodView::OnStart() -{ - SetupCurrentTime(); - InitStart(); -} - -void BloodView::OnStop() -{ - if (dragListener_ != nullptr) { - delete dragListener_; - dragListener_ = nullptr; - } - return; -} - -void BloodView::SetupCurrentTime() -{ - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::SetupCurrentTime new Label"); - currentTime_ = new UILabel(); - if (currentTime_ == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::SetupCurrentTime new Label currentTime_ fail"); - return; - } - currentTime_->SetPosition(WATCH_TIME_LABEL_CURTIME_XPOS, WATCH_TIME_LABEL_CURTIME_YPOS); - currentTime_->Resize(WATCH_TIME_LABEL_CURTIME_WIDTH, WATCH_TIME_LABEL_CURTIME_HEIGHT); - std::string curtime = BloodModel::GetInstance().GetCurrentTimeString(); - currentTime_->SetText(curtime.c_str()); - currentTime_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WATCH_TIME_LABEL_CURTIME_FONT_SIZE); - currentTime_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - currentTime_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - currentTime_->SetRollSpeed(0); - currentTime_->SetVisible(true); -} - -void BloodView::SetUpImageAnimator() -{ - imageAnimator_ = new UIImageAnimatorView(); - if (imageAnimator_ == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::UIImageAnimatorView new Label currentTime_ fail"); - return; - } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::SetUpImageAnimator "); - imageAnimator_ = new UIImageAnimatorView(); - imageAnimator_->SetPosition(BLOOD_IMAGE_POSITION_X, BLOOD_IMAGE_POSITION_y, BLOOD_IMAGE_WIDTH, - BLOOD_IMAGE_HEIGHT); // 50 : offset 50 : offset 200 : offset 200: offset - int imageNumber = 4; - int ImageUpdate = 300; - imageAnimator_->SetImageAnimatorSrc(g_imageAnimatorInfo, imageNumber, - ImageUpdate); // 4: the number of images, 100: updating time - imageAnimator_->Stop(); - imageAnimator_->LayoutCenterOfParent(); - imageAnimator_->SetDraggable(true); - UIView::OnDragListener *listener = static_cast(BloodPresenter::GetInstance()); - imageAnimator_->SetOnDragListener(listener); - container[BLOOD_START]->Add(imageAnimator_); - if (layout_ == nullptr) { - layout_ = new GridLayout(); - uint16_t height = Screen::GetInstance().GetHeight(); - - int heightOffset = 50; - layout_->SetPosition(BLOOD_LAYOUT_POSITION_X, 0, BLOOD_LAYOUT_WIDTH, - height - heightOffset); // 370: x , 320: width, 50: offset - container[BLOOD_START]->Add(layout_); - layout_->SetLayoutDirection(LAYOUT_VER); - layout_->SetRows(SET_NINE); // 9 : rows - layout_->SetCols(SET_TWO); // 2 : columns - } - InitImageInfo(); -} - -void BloodView::InitStart() -{ - if (group == nullptr) { - group = new UIViewGroup(); - } - group->SetPosition(0, 0); - group->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); - UIView::OnDragListener *dragListener = static_cast(BloodPresenter::GetInstance()); - if (dragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "start dragListener = nullptr"); - } - group->SetOnDragListener(dragListener); - group->SetViewId("startPage"); - group->SetDraggable(true); - group->SetTouchable(true); - - if (button == nullptr) { - button = new UILabelButton(); - } - button->SetPosition(BLOOD_BUTTON_POSITION_X, - BLOOD_BUTTON_TWO_POSITION_Y); // widget's left position and top position - button->Resize(BLOOD_BUTTON_TWO_WIDTH, BLOOD_BUTTON_HEIGHT); // widget's width and height - button->SetViewId("button1"); // Set style - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)(BloodPresenter::GetInstance()); - button->SetOnClickListener(clickListener); - button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - button->SetVisible(true); - button->SetText("开始"); - - group->Add(currentTime_); - group->Add(button); - container[BLOOD_START] = group; - - AddViewToRootContainer(container[BLOOD_START]); - GetRootContainer()->Invalidate(); -} - -void BloodView::InitTest() -{ - if (groupTest == nullptr) { - groupTest = new UIViewGroup(); - } - groupTest->SetPosition(0, 0); - groupTest->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); - - UIView::OnDragListener *dragListener = static_cast(BloodPresenter::GetInstance()); - if (dragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "init test dragListener = nullptr"); - } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "init test dragListener successful"); - - groupTest->SetOnDragListener(dragListener); - groupTest->SetViewId("testPage"); - groupTest->SetDraggable(true); - groupTest->SetTouchable(true); - - if (label1_ == nullptr) { - label1_ = new UILabel(); - } - - label1_->SetPosition(BLOOD_LABEL1_POSITION_X, BLOOD_LABEL1_POSITION_Y); // widget's left position and top position - label1_->Resize(BLOOD_LABEL1_WIDTH, BLOOD_LABEL1_HEIGHT); // widget's width and height - label1_->SetViewId("label1"); // Set style - label1_->SetStyle(STYLE_TEXT_FONT, BLOOD_LABEL_FRONT1); - - // Set additional property - label1_->SetText("99%"); - label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label1_->SetRollSpeed(0); - label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, BLOOD_LABEL_FRONT1); - - // Add to rootView - label1_->SetVisible(true); - - // Add Label to App - if (label2_ == nullptr) { - label2_ = new UILabel(); - } - - label2_->SetPosition(BLOOD_LABEL2_POSITION_X, BLOOD_LABEL2_POSITION_Y); // widget's left position and top position - label2_->Resize(BLOOD_LABEL2_WIDTH, BLOOD_LABEL2_HEIGHT); // widget's width and height - label2_->SetViewId("label1"); // Set style - label2_->SetStyle(STYLE_TEXT_FONT, BLOOD_LABEL_FRONT); - - // Set additional property - label2_->SetText("血氧"); - label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label2_->SetRollSpeed(0); - label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, BLOOD_LABEL_FRONT); - label2_->SetVisible(true); - - // Add to rootView - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "init test label successful"); - - if (buttonMore == nullptr) { - buttonMore = new UILabelButton(); - } - - buttonMore->SetPosition(BLOOD_BUTTON_POSITION_X, - BLOOD_BUTTON_POSITION_Y); // widget's left position and top position - buttonMore->Resize(BLOOD_BUTTON_WIDTH, BLOOD_BUTTON_HEIGHT); // widget's width and height - buttonMore->SetViewId("button2"); // Set style - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)(BloodPresenter::GetInstance()); - buttonMore->SetOnClickListener(clickListener); - buttonMore->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - buttonMore->SetVisible(true); - buttonMore->SetText("了解更多"); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "init test button successful"); - - groupTest->Add(label1_); - groupTest->Add(label2_); - groupTest->Add(currentTime_); - groupTest->Add(buttonMore); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "init test add button successful"); -} - -void BloodView::InitMore() -{ - if (scrollGroup == nullptr) { - scrollGroup = new UIScrollView(); - } - scrollGroup->Add(currentTime_); - - scrollGroup->SetViewId("moreGroup"); - scrollGroup->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - scrollGroup->SetThrowDrag(true); - scrollGroup->SetScrollBlankSize(50); // 50:font size - UIView::OnDragListener *listener = static_cast(BloodPresenter::GetInstance()); - scrollGroup->SetOnDragListener(listener); - scrollGroup->SetDraggable(true); - scrollGroup->SetTouchable(true); - if (!InitSimilarLabel(SET_ZERO, BLOOD_LABEL_FIRST_Y, BLOOD_LABEL_ONE)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempJoinStudy::TempInitLabel new tempLabel[SET_ZERO] error"); - } - if (!InitSimilarLabel(SET_ONE, BLOOD_LABEL_SECOND_Y, BLOOD_LABEL_TWO)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempJoinStudy::TempInitLabel new tempLabel[SET_ONE] error"); - } - if (!InitSimilarLabel(SET_TWO, BLOOD_LABEL_THIRD_Y, BLOOD_LABEL_THREE)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempJoinStudy::TempInitLabel new tempLabel[SET_ONE] error"); - } -} - -bool BloodView::InitSimilarLabel(int16 num, int16 labelY, const char *labelText) -{ - tempLabel[num] = new UILabel(); - if (tempLabel[num] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempJoinStudy::TempInitLabel new tempLabel[%d] error", num); - return false; - } - tempLabel[num]->SetPosition(BLOOD_LABEL_FIRST_X, labelY, BLOOD_LABEL_FIRST_WIDTH, BLOOD_LABEL_FIRST_HEIGHT); - tempLabel[num]->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - tempLabel[num]->SetText(labelText); - tempLabel[num]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, BLOOD_FIRST_LABEL_FONT); - scrollGroup->Add(tempLabel[num]); - - return true; -} - -bool BloodView::TempInitLabel(void) -{ - scrollGroup->Add(currentTime_); - UIView::OnDragListener *dragListener = static_cast(BloodPresenter::GetInstance()); - if (dragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "init more dragListener = nullptr"); - } - if (!InitSimilarLabel(SET_ZERO, BLOOD_LABEL_FIRST_Y, BLOOD_LABEL_ONE)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempJoinStudy::TempInitLabel new tempLabel[SET_ZERO] error"); - return false; - } - if (!InitSimilarLabel(SET_ONE, BLOOD_LABEL_SECOND_Y, BLOOD_LABEL_TWO)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempJoinStudy::TempInitLabel new tempLabel[SET_ONE] error"); - return false; - } - if (!InitSimilarLabel(SET_TWO, BLOOD_LABEL_THIRD_Y, BLOOD_LABEL_THREE)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempJoinStudy::TempInitLabel new tempLabel[SET_ONE] error"); - return false; - } - return true; -} - -void BloodView::InitImageInfo() -{ - const uint16_t pixelByteSize = 4; // 4: bytes per pixel - const uint16_t width = 100; // 100: image's width - const uint16_t height = 100; // 100: image's height - uint32_t dataSize = width * height * pixelByteSize; - uint8_t *srcData1 = static_cast(UIMalloc(dataSize)); - if (srcData1 == nullptr) { - return; - } - - for (uint32_t i = 0; i < dataSize; i += pixelByteSize) { - srcData1[i] = SET_INT_MAX; // 255: pixel value - srcData1[i + 1] = 0; // 1: set green channel - srcData1[i + 2] = 0; // 2: set red channel - srcData1[i + 3] = OPA_OPAQUE; // 3: set alpha channel - } - imageInfo1_ = static_cast(UIMalloc(sizeof(ImageInfo))); - if (imageInfo1_ == nullptr) { - UIFree(srcData1); - return; - } - - imageInfo1_->header.width = width; - imageInfo1_->header.height = height; - imageInfo1_->header.colorMode = ColorMode::ARGB8888; - imageInfo1_->dataSize = dataSize; - imageInfo1_->data = srcData1; - - uint8_t *srcData2 = static_cast(UIMalloc(dataSize)); - if (srcData2 == nullptr) { - UIFree(imageInfo1_); - UIFree(srcData1); - return; - } - for (uint32_t i = 0; i < dataSize; i += pixelByteSize) { - srcData2[i] = 0; // set blue channel - srcData2[i + 1] = SET_INT_MAX; // 1: set green channel 255: pixel value - srcData2[i + 2] = 0; // 2: set red channel - srcData2[i + 3] = OPA_OPAQUE; // 3: set alpha channel - } - - imageInfo2_ = static_cast(UIMalloc(sizeof(ImageInfo))); - if (imageInfo2_ == nullptr) { - UIFree(srcData2); - UIFree(imageInfo1_); - UIFree(srcData1); - return; - } - imageInfo2_->header.width = width; - imageInfo2_->header.height = height; - imageInfo2_->header.colorMode = ARGB8888; - imageInfo2_->dataSize = dataSize; - imageInfo2_->data = srcData2; - - uint8_t *srcData3 = static_cast(UIMalloc(dataSize)); - if (srcData3 == nullptr) { - UIFree(imageInfo2_); - UIFree(srcData2); - UIFree(imageInfo1_); - UIFree(srcData1); - return; - } - for (uint32_t i = 0; i < dataSize; i += pixelByteSize) { - srcData3[i] = 0; // set blue channel - srcData3[i + 1] = 0; // 1: set green channel - srcData3[i + 2] = SET_INT_MAX; // 2: set red channel 255: pixel value - srcData3[i + 3] = OPA_OPAQUE; // 3: set alpha channel - } - - imageInfo3_ = static_cast(UIMalloc(sizeof(ImageInfo))); - if (imageInfo3_ == nullptr) { - UIFree(srcData3); - UIFree(imageInfo2_); - UIFree(srcData2); - UIFree(imageInfo1_); - UIFree(srcData1); - return; - } - imageInfo3_->header.width = width; - imageInfo3_->header.height = height; - imageInfo3_->header.colorMode = ARGB8888; - imageInfo3_->dataSize = dataSize; - imageInfo3_->data = srcData3; - - imageAnimatorImageInfo_[0].imageInfo = imageInfo1_; - imageAnimatorImageInfo_[0].pos = {BLOOD_IMAGEANIMATOR_POSITION_X, BLOOD_IMAGEANIMATOR_POSITION_Y}; - imageAnimatorImageInfo_[0].width = BLOOD_IMAGEANIMATOR_WIDTH; // 100: width value - imageAnimatorImageInfo_[0].height = BLOOD_IMAGEANIMATOR_HEIGHT; // 100: height value - imageAnimatorImageInfo_[0].imageType = IMG_SRC_IMAGE_INFO; - - imageAnimatorImageInfo_[1].imageInfo = imageInfo2_; - imageAnimatorImageInfo_[1].pos = {BLOOD_IMAGEANIMATOR_POSITION_X, BLOOD_IMAGEANIMATOR_POSITION_Y}; - imageAnimatorImageInfo_[1].width = BLOOD_IMAGEANIMATOR_WIDTH; // 100: width value - imageAnimatorImageInfo_[1].height = BLOOD_IMAGEANIMATOR_HEIGHT; // 100: height value - imageAnimatorImageInfo_[1].imageType = IMG_SRC_IMAGE_INFO; - - imageAnimatorImageInfo_[2].imageInfo = imageInfo3_; // 2: image index - imageAnimatorImageInfo_[2].pos = {BLOOD_IMAGEANIMATOR_POSITION_X, BLOOD_IMAGEANIMATOR_POSITION_Y}; // 2: image index - imageAnimatorImageInfo_[2].width = BLOOD_IMAGEANIMATOR_WIDTH; // 2: image index, 100: width value - imageAnimatorImageInfo_[2].height = BLOOD_IMAGEANIMATOR_HEIGHT; // 2: image index, 100: height value - imageAnimatorImageInfo_[2].imageType = IMG_SRC_IMAGE_INFO; // 2: image index -} - -void BloodView::UpdateCurrentTimeLabel(const char *currentTime) -{ - currentTime_->SetText(currentTime); - currentTime_->Invalidate(); -} - -bool BloodView::IsCurrentTimeLabelValid() -{ - return currentTime_ != nullptr ? true : false; -} - -void BloodView::DropView(UIView &view, int type) -{ - if (type == 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::DropView::container[WEATHER_ondrop]-0"); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::DropView::container[WEATHER_ondrop] view name :%s", - view.GetViewId()); - if (&view == container[BLOOD_START]) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::DropView::container[CHANGE_INTERFACE_CONFIG]-0"); - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); - } else if (&view == container[BLOOD_TEST]) { - ChangeView(BLOOD_TEST, BLOOD_START); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::DropView::container[BLOOD_START]-0"); - } else if (&view == container[BLOOD_MORE]) { - ChangeView(BLOOD_MORE, BLOOD_TEST); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::DropView::container[WEATHER_SCROLL]-0"); - } - } else if (type == 1) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::DropView::container[WEATHER_ondrop] view name :%s", - view.GetViewId()); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::DropView::container[WEATHER_ondrop]-1"); - if (&view == button || view.GetViewId() == "button1") { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::DropView::container[WEATHER_SWIPE]-1"); - ChangeView(BLOOD_START, BLOOD_TEST); - } else if (&view == buttonMore || view.GetViewId() == "button1") { - ChangeView(BLOOD_TEST, BLOOD_MORE); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::DropView::container[WEATHER_SCROLL]-1"); - } else if (&view == container[BLOOD_MORE]) { - } - } -} - -bool BloodView::ChangeBloodStart(int16_t thisView) -{ - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodView::WeatherGroupView"); - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool BloodView::ChangeBloodTest(int16_t thisView) -{ - if (container[thisView] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::ChangeBloodTest"); - InitTest(); - container[thisView] = groupTest; - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool BloodView::ChangeBloodMore(int16_t thisView) -{ - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodView::WeatherScrollView"); - InitMore(); - container[thisView] = scrollGroup; - AddViewToRootContainer(container[thisView]); - } - return true; -} - -struct BloodViewMapper { - uint16_t viewId; - bool (BloodView::*func)(int16 thisView); -}; - -static const BloodViewMapper ViewMapper[] = { - {BLOOD_START, &BloodView::ChangeBloodStart}, - {BLOOD_TEST, &BloodView::ChangeBloodTest}, - {BLOOD_MORE, &BloodView::ChangeBloodMore}, -}; - -bool BloodView::ClickFunc(int16 interf) -{ - int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]); - for (int i = 0; i < funcSize; i++) { - if (interf == ViewMapper[i].viewId) { - bool jug = (this->*(ViewMapper[i].func))(interf); - if (!jug) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView:: ChangeInterFace[%d] false", interf); - return false; - } - return true; - } - } - return false; -} - -void BloodView::ChangeView(int16 hideView, int16 showView) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodView::ChangeView hideView = %d, showView = %d", hideView, showView); - if (hideView > MAX_BLOOD_PAGE) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::ChangeView Overstep ones bounds"); - return; - } - if (!ClickFunc(showView)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::ChangeView ClickFunc ercror"); - return; - } - container[hideView]->SetVisible(false); - container[showView]->SetVisible(true); - Draw(); - return; -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/bloodoxygen/src/BloodBandoffView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/bloodoxygen/src/BloodBandoffView.cpp deleted file mode 100644 index 894ffd66c..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/bloodoxygen/src/BloodBandoffView.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: bloodBandoff view - * Author: - * Create: 2021-08-01 - */ -#include "UiConfig.h" -#include "wearable_log.h" -#include "bloodoxygen/BloodBandoffView.h" -#include "bloodoxygen/BloodOxygenModel.h" - -namespace OHOS { -// 动态显示图片设置 -static constexpr uint16_t IMAGE_SIZE = 96; -static constexpr uint16_t IMAGE_POSITION_Y = 276; -static constexpr uint16_t IMAGE_POSITION_X = 179; -static constexpr uint16_t IMAGEANIMATOERVIEW_SIZE = 24; -static constexpr uint16_t IMAGEANIMATOERVIEW_SPEED = 40; - -// 标签设置 -static constexpr uint16_t LABEL_POSITION_X = 87; -static constexpr uint16_t LABEL_POSITION_Y = 200; -static constexpr uint16_t LABEL_POSITION_WIDTH = 288; -static constexpr uint16_t LABEL_POSITION_HEIGHT = 50; - -// 图片设置 -static constexpr uint16_t IMAGE_ENTER_POSITION_X = 131; -static constexpr uint16_t IMAGE_ENTER_POSITION_Y = 70; - -static constexpr uint16_t TITLE_LABEL_DEFAULT_HEIGHT = 30; -static constexpr uint16_t FONT_DEFAULT_SIZE = 25; -static constexpr uint16_t VIEW_DISTANCE_TO_LEFT_SIDE = 48; -static constexpr uint16_t TEXT_DISTANCE_TO_LEFT_SIDE = 50; -static constexpr uint16_t TEXT_DISTANCE_TO_TOP_SIDE = 11; - -static ImageAnimatorInfo g_imageAnimatorInfo_Time[IMAGEANIMATOERVIEW_SIZE] = { - {PNG_COUNTDOWN_TIME_IMAGE_0, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_1, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_2, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_3, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_4, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_5, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_6, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_7, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_8, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_9, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_10, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_11, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_12, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_13, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_14, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_15, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_16, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_17, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_18, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_19, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_20, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_21, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_22, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_COUNTDOWN_TIME_IMAGE_23, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, -}; -static BloodBandoffView *g_pMainView = nullptr; -BloodBandoffView::BloodBandoffView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodBandoffView::BloodBandoffView"); - label = nullptr; - imageView = nullptr; - group = nullptr; - imageAnimator = nullptr; - g_pMainView = this; -} - -BloodBandoffView::~BloodBandoffView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodBandoffView::~BloodBandoffView"); - group->RemoveAll(); - delete label; - delete imageView; - delete group; - delete imageAnimator; - label = nullptr; - imageView = nullptr; - group = nullptr; - imageAnimator = nullptr; - g_pMainView = nullptr; -} - -BloodBandoffView *BloodBandoffView::GetInstance(void) -{ - return g_pMainView; -} - -UIViewGroup *BloodBandoffView::GetBandoffViewGroup() -{ - return group; -} - -UIImageAnimatorView *BloodBandoffView::GetImageAnimator() -{ - return imageAnimator; -} - -UIViewGroup *BloodBandoffView::CreateUIViewGroup() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodBandoffView::CreateUIViewGroup"); - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodBandoffView::new group fail"); - return nullptr; - } - group->SetPosition(0, 0); - group->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); - - label = new UILabel(); - if (label == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodBandoffView::new Label fail"); - return nullptr; - } - group->Add(label); - label->SetPosition(LABEL_POSITION_X, LABEL_POSITION_Y, LABEL_POSITION_WIDTH, LABEL_POSITION_HEIGHT); - label->SetText("偏紧佩戴,保持静止"); - label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - - imageAnimator = new UIImageAnimatorView(); - if (imageAnimator == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodBandoffView::new UIImageAnimatorView fail"); - return nullptr; - } - imageAnimator->SetImageAnimatorSrc(g_imageAnimatorInfo_Time, IMAGEANIMATOERVIEW_SIZE, IMAGEANIMATOERVIEW_SPEED); - imageAnimator->Start(); - imageAnimator->SetRepeat(false); - group->Add(imageAnimator); - - imageView = new UIImageView(); - if (imageView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodBandoffView::new UIImageView fail"); - return nullptr; - } - imageView->SetPosition(IMAGE_ENTER_POSITION_X, IMAGE_ENTER_POSITION_Y); // 30 : offset - imageView->SetSrc(PNG_BLOOD_ICON_ENTER); - group->Add(imageView); - - return group; -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/bloodoxygen/src/BloodOxygenModel.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/bloodoxygen/src/BloodOxygenModel.cpp deleted file mode 100644 index edad7933b..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/bloodoxygen/src/BloodOxygenModel.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: bloodOxygen view - * Author: - * Create: 2021-08-01 - */ - -#include "bloodoxygen/BloodOxygenModel.h" - -namespace OHOS { -BloodOxygenModel::BloodOxygenModel() -{ - OxygenView = false; - BandoffView = false; -} - -bool BloodOxygenModel::GetBloodOxygenViewStatus(void) -{ - return OxygenView; -} - -bool BloodOxygenModel::GetBloodBandoffViewStatus(void) -{ - return BandoffView; -} - -void BloodOxygenModel::SetBloodBandoffViewStatus(bool bandoffViewStatus) -{ - BandoffView = bandoffViewStatus; -} - -void BloodOxygenModel::SetBloodOxygenViewStatus(bool oxygenViewStatus) -{ - OxygenView = oxygenViewStatus; -} - -BloodOxygenModel *BloodOxygenModel::GetInstance(void) -{ - static BloodOxygenModel instance; - return &instance; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp deleted file mode 100644 index 84d8e0897..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: bloodOxygen view - * Author: - * Create: 2021-08-01 - */ - -#include "bloodoxygen/BloodOxygenPresenter.h" -#include "common/task_manager.h" -#include "bloodoxygen/BloodOxygenView.h" -#include "bloodoxygen/BloodOxygenModel.h" -#include "components/ui_label.h" -#include "bloodoxygen/BloodBandoffView.h" -#include "ChangeSliceListener.h" -#include "uiservice/ui_service.h" -#include "NativeRegisterManager.h" - -namespace OHOS { - -REGIST_MENU(VIEW_BLOODOXY_SAMPLE, BloodOxygenView, BloodOxygenPresenter, PNG_APPLIST_SPO2_IMAGE, PNG_APPLIST_DEFAULT_IMG, "血氧饱和度"); - -static BloodOxygenPresenter *g_pMainView = nullptr; -static constexpr uint16_t PROGRESS_VALUE_MIN = 0; -static constexpr uint16_t PROGRESS_VALUE_MAX = 100; - -BloodOxygenPresenter::BloodOxygenPresenter() -{ - count = PROGRESS_VALUE_MAX; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::new BloodOxygenPresenter"); - g_pMainView = this; -} - -BloodOxygenPresenter::~BloodOxygenPresenter() -{ - g_pMainView = nullptr; -} - -BloodOxygenPresenter* BloodOxygenPresenter::GetInstance() -{ - return g_pMainView; -} - -void BloodOxygenPresenter::OnStart() -{ - SendMsgToUIService(UI_ADD_SLEEP_VETO, 0, nullptr, 0); -} - -void BloodOxygenPresenter::OnStop() -{ - SendMsgToUIService(UI_RM_SLEEP_VETO, 0, nullptr, 0); -} - -bool BloodOxygenPresenter::CheckPointersValue() -{ - if (BloodOxygenView::GetInstance() == nullptr) { - return false; - } - - if (BloodBandoffView::GetInstance() == nullptr) { - return false; - } - - if (BloodOxygenModel::GetInstance() == nullptr) { - return false; - } - return true; -} - - -bool BloodOxygenPresenter::OnDrag(UIView& view, const DragEvent& event) -{ - UNUSED(view); - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { - BloodOxygenModel::GetInstance()->SetBloodOxygenViewStatus(false); - BloodOxygenView::GetInstance()->GetTestButton()->SetTouchable(true); - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); - } - return false; -} - - -bool BloodOxygenPresenter::OnClick(UIView& view, const ClickEvent& event) -{ - UNUSED(view); - UNUSED(event); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::OnClick"); - if (!CheckPointersValue()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::Pointers is empty"); - return false; - } - BloodOxygenView::GetInstance()->GetPercent()->SetText(""); - BloodOxygenView::GetInstance()->GetBloodOxygenGroup()->SetVisible(false); - BloodBandoffView::GetInstance()->GetBandoffViewGroup()->SetVisible(true); - BloodBandoffView::GetInstance()->GetImageAnimator()->Stop(); - BloodBandoffView::GetInstance()->GetImageAnimator()->SetRepeat(false); - BloodBandoffView::GetInstance()->GetImageAnimator()->Start(); - BloodOxygenModel::GetInstance()->SetBloodBandoffViewStatus(true); - BloodOxygenView::GetInstance()->GetTestButton()->SetTouchable(false); - return true; -} - -void BloodOxygenPresenter::ProgressNotify(void) -{ - if (!CheckPointersValue()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::Pointers is empty"); - return; - } - - if (BloodOxygenModel::GetInstance()->GetBloodOxygenViewStatus()) { - count--; - BloodOxygenView::GetInstance()->GetCircleProgress()->SetValue(count); - if (count == PROGRESS_VALUE_MIN) { - BloodOxygenView::GetInstance()->GetPercent()->SetText("98%"); - BloodOxygenModel::GetInstance()->SetBloodOxygenViewStatus(false); - count = PROGRESS_VALUE_MAX; - BloodOxygenView::GetInstance()->GetCircleProgress()->SetValue(count); - BloodOxygenView::GetInstance()->GetTestButton()->SetTouchable(true); - } - } -} - -void BloodOxygenPresenter::ReturnInterface() -{ - if (BloodOxygenModel::GetInstance()->GetBloodBandoffViewStatus()) { - if (!BloodBandoffView::GetInstance()->GetImageAnimator()->GetState()) { - BloodOxygenModel::GetInstance()->SetBloodBandoffViewStatus(false); - BloodOxygenModel::GetInstance()->SetBloodOxygenViewStatus(true); - - BloodBandoffView::GetInstance()->GetBandoffViewGroup()->SetVisible(false); - BloodOxygenView::GetInstance()->GetBloodOxygenGroup()->SetVisible(true); - } - } -} - -void BloodOxygenPresenter::Notify(void) -{ - ProgressNotify(); - ReturnInterface(); -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/bloodoxygen/src/BloodOxygenView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/bloodoxygen/src/BloodOxygenView.cpp deleted file mode 100644 index 5b2ade831..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/bloodoxygen/src/BloodOxygenView.cpp +++ /dev/null @@ -1,368 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: bloodOxygen view - * Author: - * Create: 2021-08-01 - */ - -#include "bloodoxygen/BloodOxygenView.h" -#include "bloodoxygen/BloodOxygenModel.h" - -namespace OHOS { -// 按钮设置 -static constexpr uint16_t TESTBUTTON_ZERO = 0; -static constexpr uint16_t TESTBUTTON_X = 167; -static constexpr uint16_t TESTBUTTON_Y = 360; - -// 进度条参数设置 -static constexpr uint16_t CIRCLE_PROGRESS_VALUE = 100; -static constexpr uint16_t CIRCLE_PROGRESS_RADIUS = 43; -static constexpr uint16_t CIRCLE_PROGRESS_STARTANGLE = 360; -static constexpr uint16_t CIRCLE_PROGRESS_ENDANGLE = 0; -static constexpr uint16_t CIRCLE_PROGRESS_WIDTH = 10; -static constexpr uint16_t CIRCLE_PROGRESS_POSITION_X = 10; -static constexpr uint16_t CIRCLE_PROGRESS_POSITION_Y = 10; -static constexpr uint16_t CIRCLE_PROGRESS_CENTER_X = 195; -static constexpr uint16_t CIRCLE_PROGRESS_CENTER_Y = 37; -static constexpr uint16_t CIRCLE_PROGRESS_POSITION_WIDTH = 275; -static constexpr uint16_t CIRCLE_PROGRESS_POSITION_HEIGHT = 130; -static constexpr uint16_t CIRCLE_PROGRESS_LEFT = 10; -static constexpr uint16_t CIRCLE_PROGRESS_TOP = 5; - -// 动态刷新设置 -static constexpr uint16_t IMAGE_SIZE = 60; -static constexpr uint16_t IMAGE_POSITION_X = 186; -static constexpr uint16_t IMAGE_POSITION_Y = 23; -static constexpr uint16_t IMAGEANIMATORVIEW_SIZE = 31; -static constexpr uint16_t IMAGEANIMATORVIEW_SPEED = 40; - -// 血氧主图设置 -static constexpr uint16_t IMAGE_PROGRESS_POSITION_X = 176; -static constexpr uint16_t IMAGE_PROGRESS_POSITION_Y = 13; - -// 血氧%显示 -static constexpr uint16_t LABEL_PERCENT_POSITION_X = 258; -static constexpr uint16_t LABEL_PERCENT_POSITION_Y = 40; - -// 血氧柱状图 -static constexpr int16 VIEW_MAX_X = 415; -static constexpr int16 VIEW_MIN_X = 35; -static constexpr int16 VIEW_MAX_Y = 150; -static constexpr int16 VIEW_MIN_Y = 0; -static constexpr int16 VIEW_WIDTH = 7; -static constexpr int16 VIEW_HEIGHT = 300; -static constexpr uint16_t VIEW_BACKGROUND_OPA = 127; -static constexpr uint16_t VIEW_BORDER_RADIUS = 5; -static constexpr uint16_t BORDER_OPA = 127; -static constexpr uint16_t BORDER_WIDTH = 20; - -static constexpr uint16_t TITLE_LABEL_DEFAULT_HEIGHT = 30; -static constexpr uint16_t FONT_DEFAULT_SIZE = 20; -static constexpr uint16_t VIEW_DISTANCE_TO_LEFT_SIDE = 48; -static constexpr uint16_t TEXT_DISTANCE_TO_LEFT_SIDE = 50; -static constexpr uint16_t TEXT_DISTANCE_TO_TOP_SIDE = 11; -static constexpr uint16_t BUTTON_LABEL_SIZE = 40; -static constexpr uint8_t BUTTON_STYLE_BORDER_RADIUS_VALUE = 20; -static constexpr uint32 BUTTON_STYLE_BACKGROUND_COLOR_VALUE = 0xFFFFFF; -static constexpr uint16_t BUTTON_WIDHT2 = 120; -static constexpr uint16_t BUTTON_HEIGHT2 = 60; - -// 字体大小 -static constexpr uint16_t PERCENT_FONT_SIZE = 25; - -static constexpr uint16_t MATH_ZERO = 0; - -static BloodOxygenView *g_pMainView = nullptr; -static ImageAnimatorInfo g_imageAnimatorInfo_new[31] = { - {PNG_BLOOD_FLOW_IMAGE_0, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_1, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_2, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_3, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_4, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_5, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_6, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_7, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_8, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_9, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_10, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_11, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_12, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_13, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_14, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_15, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_16, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_17, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_18, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_19, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_20, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_21, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_22, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_23, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_24, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_25, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_26, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_27, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_28, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_29, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_BLOOD_FLOW_IMAGE_30, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, -}; - -BloodOxygenView::BloodOxygenView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::BloodOxygenView"); - imageViewMain = nullptr; - imageViewProgress = nullptr; - group = nullptr; - percent = nullptr; - testButton = nullptr; - circleProgress = nullptr; - imageAnimator = nullptr; - g_pMainView = this; - bloodbandoff = new BloodBandoffView(); - if (bloodbandoff == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new BloodBandoffView fail"); - } -} - -BloodOxygenView::~BloodOxygenView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::~BloodOxygenView"); - group->RemoveAll(); - delete imageViewMain; - delete imageViewProgress; - delete group; - delete testButton; - delete percent; - delete circleProgress; - delete imageAnimator; - delete bloodbandoff; - imageViewMain = nullptr; - imageViewProgress = nullptr; - group = nullptr; - percent = nullptr; - testButton = nullptr; - circleProgress = nullptr; - imageAnimator = nullptr; - g_pMainView = nullptr; - bloodbandoff = nullptr; -} - -BloodOxygenView *BloodOxygenView::GetInstance(void) -{ - return g_pMainView; -} - -UILabel *BloodOxygenView::GetPercent() -{ - return percent; -} - -UIViewGroup *BloodOxygenView::GetBloodOxygenGroup() -{ - return group; -} - -UILabelButton *BloodOxygenView::GetTestButton() -{ - return testButton; -} - -UICircleProgress *BloodOxygenView::GetCircleProgress() -{ - return circleProgress; -} - -UILabelButton *BloodOxygenView::CreateAndSetUIButton(const char *title) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::CreateAndSetUIButton"); - UILabelButton* btn = new UILabelButton(); - if (btn == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new UILabelButton fail"); - return nullptr; - } - btn->SetPosition(TESTBUTTON_X, TESTBUTTON_Y, BUTTON_WIDHT2, BUTTON_HEIGHT2); - btn->SetText(title); - btn->SetTextColor(Color::Red()); - btn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, BUTTON_LABEL_SIZE); - btn->SetAlign(TEXT_ALIGNMENT_CENTER); - btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::RELEASED); - btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::PRESSED); - btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::INACTIVE); - btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::RELEASED); - btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::PRESSED); - btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::INACTIVE); - UIView::OnClickListener* clickLeftListener = (UIView::OnClickListener*)OHOS::BloodOxygenPresenter::GetInstance(); - if (clickLeftListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new clickLeftListener fail"); - return nullptr; - } - btn->SetOnClickListener(clickLeftListener); - return btn; -} - - -bool BloodOxygenView::SetOnDragListener() -{ - UIView::OnDragListener *dragListener = (UIView::OnDragListener*)OHOS::BloodOxygenPresenter::GetInstance(); - if (dragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::OnDragListener fail"); - return false; - } - group->SetDraggable(true); - group->SetTouchable(true); - group->SetOnDragListener(dragListener); - return true; -} - -UIView *BloodOxygenView::CreateAndSetUIView(int16 x, int16 y) const -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::CreateAndSetUIView"); - UIView* view = new UIView(); - if (view == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new View fail"); - return nullptr; - } - if (x > VIEW_MAX_X || x < VIEW_MIN_X) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::X error"); - return nullptr; - } - if (y < VIEW_MIN_Y || y >VIEW_MAX_Y) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::Y error"); - return nullptr; - } - view->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green().full); - view->SetStyle(STYLE_BACKGROUND_OPA, VIEW_BACKGROUND_OPA); // 127 : background opacity - view->SetStyle(STYLE_BORDER_RADIUS, VIEW_BORDER_RADIUS); // 5 : radius value - view->SetStyle(STYLE_BORDER_COLOR, Color::Gray().full); - view->SetStyle(STYLE_BORDER_OPA, BORDER_OPA); // 127 : border opacity - view->SetStyle(STYLE_BORDER_WIDTH, BORDER_WIDTH); // 20 : border width - view->SetStyle(STYLE_PADDING_LEFT, MATH_ZERO); - view->SetStyle(STYLE_PADDING_RIGHT, MATH_ZERO); - view->SetStyle(STYLE_PADDING_TOP, MATH_ZERO); - view->SetStyle(STYLE_PADDING_BOTTOM, MATH_ZERO); - view->SetStyle(STYLE_MARGIN_LEFT, MATH_ZERO); - view->SetStyle(STYLE_MARGIN_RIGHT, MATH_ZERO); - view->SetStyle(STYLE_MARGIN_TOP, MATH_ZERO); - view->SetStyle(STYLE_MARGIN_BOTTOM, MATH_ZERO); - - view->SetPosition(x, VIEW_HEIGHT - y); - view->SetStyle(STYLE_BORDER_WIDTH, MATH_ZERO); - view->SetStyle(STYLE_BORDER_RADIUS, MATH_ZERO); // 2 : half width 10 : offset - view->Resize(VIEW_WIDTH, y); - return view; -} - -UICircleProgress *BloodOxygenView::CreateAndSetUICircleProgress() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::CreateAndSetUICircleProgress"); - UICircleProgress *circle = new UICircleProgress(); - circle->SetPosition(CIRCLE_PROGRESS_POSITION_X, CIRCLE_PROGRESS_POSITION_Y, - CIRCLE_PROGRESS_POSITION_WIDTH, CIRCLE_PROGRESS_POSITION_HEIGHT); - circle->SetCenterPosition(CIRCLE_PROGRESS_CENTER_X, CIRCLE_PROGRESS_CENTER_Y); - circle->SetRadius(CIRCLE_PROGRESS_RADIUS); - circle->SetValue(CIRCLE_PROGRESS_VALUE); - circle->SetBackgroundStyle(STYLE_LINE_WIDTH, - circle->GetBackgroundStyle(STYLE_LINE_WIDTH) + CIRCLE_PROGRESS_WIDTH); - circle->SetForegroundStyle(STYLE_LINE_WIDTH, - circle->GetForegroundStyle(STYLE_LINE_WIDTH) + CIRCLE_PROGRESS_WIDTH); - circle->SetStyle(STYLE_PADDING_LEFT, CIRCLE_PROGRESS_LEFT); - circle->SetStyle(STYLE_PADDING_TOP, CIRCLE_PROGRESS_TOP); - circle->SetStartAngle(CIRCLE_PROGRESS_STARTANGLE); - circle->SetEndAngle(CIRCLE_PROGRESS_ENDANGLE); - circle->SetImage(nullptr, PNG_PROGRESS_BAR_TMAGE); - circle->SetLineColor(Color::Black()); - - return circle; -} - -bool BloodOxygenView::InitImageDisplay() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::InitImageDisplay"); - imageViewMain = new UIImageView(); - if (imageViewMain == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new UIImageView fail"); - return false; - } - imageViewMain->SetPosition(MATH_ZERO, MATH_ZERO); // 30 : offset - imageViewMain->SetSrc(PNG_BLOODOXYGEN_IMAGE_PATH); - group->Add(imageViewMain); - - imageAnimator = new UIImageAnimatorView(); - if (imageAnimator == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new UIImageAnimatorView fail"); - return false; - } - imageAnimator->SetImageAnimatorSrc(g_imageAnimatorInfo_new, IMAGEANIMATORVIEW_SIZE, IMAGEANIMATORVIEW_SPEED); - imageAnimator->Start(); - imageAnimator->SetRepeat(true); - group->Add(imageAnimator); - - imageViewProgress = new UIImageView(); - if (imageViewProgress == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new UIImageView fail"); - return false; - } - imageViewProgress->SetPosition(IMAGE_PROGRESS_POSITION_X, IMAGE_PROGRESS_POSITION_Y); // 30 : offset - imageViewProgress->SetSrc(PNG_PROGRESS_BAR_TMAGE); - group->Add(imageViewProgress); - - return true; -} - -void BloodOxygenView::OnStart() -{ - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new group fail"); - return; - } - group->SetPosition(MATH_ZERO, MATH_ZERO); - group->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); - - if (!InitImageDisplay()) { - return; - } - - if (!SetOnDragListener()) { - return; - } - - circleProgress = CreateAndSetUICircleProgress(); - if (circleProgress == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new circleProgress fail"); - return; - } - group->Add(circleProgress); - - percent = new UILabel(); - if (percent == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new Label fail"); - return; - } - percent->SetPosition(LABEL_PERCENT_POSITION_X, LABEL_PERCENT_POSITION_Y, - VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); - percent->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - percent->SetText("%97"); - percent->SetFont(DEFAULT_VECTOR_FONT_FILENAME, PERCENT_FONT_SIZE); - percent->SetTextColor(Color::Red()); - group->Add(percent); - - testButton = CreateAndSetUIButton("测试"); - if (testButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new Button fail"); - return; - } - group->Add(testButton); - - if (OHOS::BloodOxygenModel::GetInstance()->GetBloodOxygenViewStatus()) { - testButton->SetTouchable(false); - percent->SetText(""); - } - - BloodBandoffView::GetInstance()->CreateUIViewGroup(); - - AddViewToRootContainer(group); - AddViewToRootContainer(BloodBandoffView::GetInstance()->GetBandoffViewGroup()); - BloodBandoffView::GetInstance()->GetBandoffViewGroup()->SetVisible(false); -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothCaseListAdapter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothCaseListAdapter.cpp deleted file mode 100644 index 06dc76ba1..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothCaseListAdapter.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: Bluetooth Case List Adapter - * Author: - * Create: 2021-07-26 - */ -#include -#include "bluetooth/BluetoothCaseListAdapter.h" -#include "bluetooth/BluetoothEarPhoneView.h" -#include "gfx_utils/list.h" -#include "player/PlayersPresenter.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "bluetooth/BluetoothModel.h" - -namespace OHOS { -BluetoothCaseListAdapter::~BluetoothCaseListAdapter() -{ - if (listener != nullptr) { - delete listener; - listener = nullptr; - } -} - -uint16_t BluetoothCaseListAdapter::GetCount() -{ - return BluetoothModel::GetInstance()->GetCase().size(); -} - -class BluetoothOnClickListListener; -static BluetoothOnClickListListener* g_btOnClickListListener = nullptr; -class BluetoothOnClickListListener : public UIView::OnClickListener { -public: - BluetoothOnClickListListener() - { - g_btOnClickListListener = this; - } - ~BluetoothOnClickListListener() - { - g_btOnClickListListener = nullptr; - } - bool OnClick(UIView& view, const ClickEvent& event) override - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothOnClickListListener"); - UNUSED(event); - BluetoothItemView *itemView = static_cast(&view); - // 二次点击不做响应 - bool ret = itemView->IsConnectAnimator(); - if (ret) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Block secondary clicks"); - return true; - } - BluetoothCaseInfo *bluetoothInfo_ = itemView->GetItemInfo(); - /* 点击事件 */ - BluetoothModel::GetInstance()->SetTempMacValue(bluetoothInfo_); - BluetoothModel::GetInstance()->SetTagReconnectJump(0); - BluetoothModel::GetInstance()->SetTagDisconnectView(true); - bd_addr_t addr; - (void)memcpy_s(addr.addr, BD_ADDR_LEN, bluetoothInfo_->addr, BD_ADDR_LEN); - BluetoothEarPhoneView *bluetoothEarPhoneView = BluetoothEarPhoneView::GetInstance(); - if (bluetoothEarPhoneView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView bluetoothEarPhoneView == nullptr"); - return false; - } - bluetoothEarPhoneView->BtAnimatorStop(); - bluetoothEarPhoneView->StopBtDiscovery(); - BluetoothModel::GetInstance()->SetTagScanDeviceClicked(true); - - // 刷新列表 - BluetoothEarListView *bluetoothEarListView = BluetoothEarListView::GetInstance(); - if (bluetoothEarListView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClickCancelConnedRequestButton bluetoothEarListView nullptr"); - return false; - } - if (bluetoothEarListView->GetScanUIList() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClickCancelConnedRequestButton GetScanUIList nullptr"); - return false; - } - bluetoothEarListView->GetScanUIList()->RefreshList(); - bluetoothEarListView->SetNewEquipmentButtonRemove(); - bluetoothEarListView->SetCancelConnedRequestButtonAdd(); - RootView::GetInstance()->Invalidate(); - - // 判断是否正在连接 - if (BluetoothModel::GetInstance()->GetBluetoothAclState()) { - bd_addr_t *lastAddr = BluetoothModel::GetInstance()->GetLastConnedAddr(); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "LastDevice addr: %02x%02x%02x%02x%02x%02x is connected", - lastAddr->addr[5], lastAddr->addr[4], lastAddr->addr[3], - lastAddr->addr[2], lastAddr->addr[1], lastAddr->addr[0]); - BluetoothModel::GetInstance()->SetTagConnectNew(true); - errcode_t retVal = gap_disconnect_remote_device(lastAddr); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Disconnect LastDevice retVal = %d", retVal); - } - errcode_t retVal = BluetoothModel::GetInstance()->ConnectRemoteDevice(&addr); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "ConnectRemoteDevice ret = %d", retVal); - // 跳转可选页 - return true; - } - - static BluetoothOnClickListListener *GetInstance() - { - return g_btOnClickListListener; - } -}; - -void BluetoothCaseListAdapter::ClickAnimation(BluetoothCaseInfo &itemData, BluetoothItemView *itemView) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothCaseListAdapter::ClickAnimation"); - bool ret = BluetoothModel::GetInstance()->IsTagScanDeviceClicked(); - if (ret) { - BluetoothCaseInfo *clickInfo = BluetoothModel::GetInstance()->GetTempMacValue(); - if ((clickInfo->addr[0] == itemData.addr[0]) && (clickInfo->addr[1] == itemData.addr[1]) && - (clickInfo->addr[2] == itemData.addr[2]) && (clickInfo->addr[3] == itemData.addr[3]) && - (clickInfo->addr[4] == itemData.addr[4]) && (clickInfo->addr[5] == itemData.addr[5])) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClickAnimation clickInfo->addr == itemData.addr"); - itemView->ConnectAnimatorStart(); - BluetoothModel::GetInstance()->SetConnectionView(itemView); - return; - } - } -} - -UIView *BluetoothCaseListAdapter::GetView(UIView *inView, int16_t index) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothCaseListAdapter GetView"); - std::list &bluetoothCaseList = BluetoothModel::GetInstance()->GetCase(); - if (bluetoothCaseList.empty()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothCaseList IsEmpty"); - return nullptr; - } - if ((static_cast(index) > bluetoothCaseList.size() - 1) || (index < 0)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothCaseListAdapter::GetView %d %d", index, bluetoothCaseList.size()); - return nullptr; - } - std::list::iterator node = bluetoothCaseList.begin(); - for (uint16_t i = 0; i < index; i++) { - ++node; - } - node->index = index; - BluetoothCaseInfo itemData = *node; - if (inView == nullptr) { - item = new BluetoothItemView(); - if (item == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetView item err"); - return nullptr; - } - } else { - item = static_cast(inView); - } - if (BluetoothOnClickListListener::GetInstance() == nullptr) { - listener =static_cast(new BluetoothOnClickListListener()); - } else { - listener = static_cast(BluetoothOnClickListListener::GetInstance()); - } - item->SetOnClickListener(listener); - (void)sprintf_s(addrTmp, sizeof(addrTmp), "%02x%02x%02x%02x%02x%02x", node->addr[0], node->addr[1], - node->addr[2], node->addr[3], node->addr[4], node->addr[5]); // 没有%s类型,不做返回判断 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "addrTmp %s", addrTmp); - ClickAnimation(itemData, item); - item->SetItemInfo(itemData, true); - item->SetViewIndex(index); - return item; -} -} // namespace OHOS \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp deleted file mode 100644 index ed234cca2..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: Bluetooth Case List Adapter - * Author: - * Create: 2021-07-26 - */ -#include -#include "bluetooth/BluetoothDeviceCaseListAdapter.h" -#include "bluetooth/BluetoothOptionsView.h" -#include "gfx_utils/list.h" -#include "bluetooth/BluetoothModel.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "bluetooth/BluetoothPresenter.h" - -namespace OHOS { -BluetoothDeviceCaseListAdapter::~BluetoothDeviceCaseListAdapter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceCaseListAdapter::~BluetoothDeviceCaseListAdapter"); - UIView::OnClickListener *click = item->GetOnClickListener(); - if (click != nullptr) { - delete click; - click = nullptr; - } -} - -uint16_t BluetoothDeviceCaseListAdapter::GetCount() -{ - return BluetoothModel::GetInstance()->GetConnedDevicesCase().Size(); -} - -class BluetoothDeviceOnClickListListener : public UIView::OnClickListener { -public: - BluetoothDeviceOnClickListListener(BluetoothCaseInfo *bluetoothInfo) - { - if (bluetoothInfo != nullptr) { - (void)memcpy_s(addr.addr, BD_ADDR_LEN, - bluetoothInfo->addr, BD_ADDR_LEN); // 源和目标内存长度一样,不做返回值判断 - (void)memcpy_s(bluetoothInfo_.addr, BD_ADDR_LEN, - bluetoothInfo->addr, BD_ADDR_LEN); // 源和目标内存长度一样,不做返回值判断 - (void)memcpy_s(bluetoothInfo_.deviceName, BD_NAME_LEN, - bluetoothInfo->deviceName, BD_NAME_LEN); // 源和目标内存长度一样,不做返回值判断 - bluetoothInfo_.index = bluetoothInfo->index; - bluetoothInfo_.connIndex = bluetoothInfo->connIndex; - } - } - ~BluetoothDeviceOnClickListListener() {} - bool OnClick(UIView& view, const ClickEvent& event) override - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceOnClickListListener"); - UNUSED(view); - UNUSED(event); - /* 点击事件 */ - // 跳转可选页 - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - JumpView *jumpView = JumpView::GetInstance(); - if (jumpView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceOnClick jumpView GetInstance fail"); - return false; - } - jumpView->ChangeView(JumpView::BluetoothJumpViewNum::BLUETOOTHDEVICELISTVIEW, - JumpView::BluetoothJumpViewNum::BLUETOOTHEOPTIONSVIEW); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - MainBluetoothView *mainBluetoothView = MainBluetoothView::GetInstance(); - if (mainBluetoothView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceOnClick mainBluetoothView GetInstance fail"); - return false; - } - mainBluetoothView->ChangeView(BLUETOOTHDEVICELISTVIEW, BLUETOOTHEOPTIONSVIEW); - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceOnClickListListener addr: %02x%02x%02x%02x%02x%02x", - bluetoothInfo_.addr[5], bluetoothInfo_.addr[4], bluetoothInfo_.addr[3], /* mac下标 0 1 2 3 4 5 */ - bluetoothInfo_.addr[2], bluetoothInfo_.addr[1], bluetoothInfo_.addr[0]); /* mac下标 0 1 2 3 4 5 */ - BluetoothModel::GetInstance()->SetTempMacValue(&bluetoothInfo_); - // 用于查询连接状态 - BluetoothOptionsView *bluetoothOptionsView = BluetoothOptionsView::GetInstance(); - if (bluetoothOptionsView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick bluetoothOptionsView new fail"); - return false; - } - bluetoothOptionsView->SetCurrentAddr(addr); - bluetoothOptionsView->RefreshText(); - return true; - } - -private: - BluetoothCaseInfo bluetoothInfo_{}; - bd_addr_t addr; -}; - - -UIView *BluetoothDeviceCaseListAdapter::GetView(UIView *inView, int16_t index) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceCaseListAdapter GetView"); - List &bluetoothCaseList = BluetoothModel::GetInstance()->GetConnedDevicesCase(); - if (bluetoothCaseList.IsEmpty()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothCaseList IsEmpty"); - return nullptr; - } - if ((index > bluetoothCaseList.Size() - 1) || (index < 0)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceCaseListAdapter::GetView err"); - return nullptr; - } - ListNode* node = bluetoothCaseList.Begin(); - for (uint16_t i = 0; i < index; i++) { - node = node->next_; - } - node->data_.index = index; - BluetoothCaseInfo itemData = node->data_; - if (inView == nullptr) { - item = new BluetoothItemView(); - if (item == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetView item err"); - return nullptr; - } - } else { - item = static_cast(inView); - } - item->SetItemInfo(itemData, false); - item->SetConnectionstatus(itemData); - - listener = item->GetOnClickListener(); - if (listener != nullptr) { - delete listener; - listener = nullptr; - } - listener = new BluetoothDeviceOnClickListListener(&node->data_); - if (listener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetView BluetoothDeviceOnClickListListener err"); - return nullptr; - } - sprintf_s(addrTmp, sizeof(addrTmp), "%02x%02x%02x%02x%02x%02x", node->data_.addr[0], node->data_.addr[1], - node->data_.addr[2], node->data_.addr[3], node->data_.addr[4], node->data_.addr[5]); // 没有%s类型,不做返回判断 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "addrTmp %s", addrTmp); - - item->SetViewIndex(index); - item->SetOnClickListener(listener); - return item; -} -} // namespace OHOS \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothDeviceListView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothDeviceListView.cpp deleted file mode 100644 index abcad4678..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothDeviceListView.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: BluetoothEarList view 蓝牙耳机设备列表界面 - * Author: - * Create: 2021-10-13 - */ -#include "bluetooth/BluetoothDeviceListView.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "player/PlayersPresenter.h" -#include "bluetooth/BluetoothPresenter.h" -#include "bluetooth/BluetoothModel.h" - -namespace OHOS { -static BluetoothDeviceListView *g_pBluetoothDeviceListView{nullptr}; - -BluetoothDeviceListView::BluetoothDeviceListView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView::BluetoothDeviceListView"); - g_pBluetoothDeviceListView = this; -} - -BluetoothDeviceListView::~BluetoothDeviceListView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView::~BluetoothDeviceListView"); - group->RemoveAll(); - delete titleLabel; - titleLabel = nullptr; - delete adapterText; - adapterText = nullptr; - delete emptyLabel; - emptyLabel = nullptr; - delete list; - list = nullptr; - delete newEquipmentButton; - newEquipmentButton = nullptr; - delete group; - group = nullptr; - g_pBluetoothDeviceListView = nullptr; -} - -BluetoothDeviceListView *BluetoothDeviceListView::GetInstance() -{ - return g_pBluetoothDeviceListView; -} - -void BluetoothDeviceListView::InitList() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView::InitList"); - // list type - if (adapterText == nullptr) { - adapterText = new BluetoothDeviceCaseListAdapter(); - if (adapterText == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView adapterText new fail"); - return; - } - } - if (list == nullptr) { - list = new UIList(UIList::VERTICAL); - if (list == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView list new fail"); - return; - } - list->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - list->SetPosition(36, 118, HORIZONTAL_RESOLUTION, 241); // 36:x 118:y 454:width 241:height - list->SetStartIndex(0); // 0 : list start index - list->SetAdapter(adapterText); - group->Add(list); - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView::InitList end"); -} - -void BluetoothDeviceListView::InItEmptyLabel() // 暂无已配对设备 -{ - if (emptyLabel == nullptr) { - emptyLabel = new UILabel(); - if (emptyLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView emptyLabel new fail"); - return; - } - } - emptyLabel->SetPosition(87, 205, 280, 45); // 87:x 205:y 280:width 45:height - emptyLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_FORTY_SIZE); - emptyLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - emptyLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - emptyLabel->SetText("暂无已配对设备"); -} - -UIViewGroup *BluetoothDeviceListView::GetGroup() -{ - return group; -} - -UIList *BluetoothDeviceListView::GetDeviceUIList() -{ - return list; -} - -void BluetoothDeviceListView::InitNewEquipmentButton() -{ - if (newEquipmentButton == nullptr) { - newEquipmentButton = new UILabelButton(); - if (newEquipmentButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView newEquipmentButton new fail"); - return; - } - } - newEquipmentButton->SetPosition(65, 359, 324, 101); // 65 : x, 359 : y, 324:width 101:height - newEquipmentButton->SetText("新设备"); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::PlayersPresenter::GetInstance(); - UIView::OnClickListener *clickListener2 = (UIView::OnClickListener *)OHOS::BluetoothPresenter::GetInstance(); - if ((clickListener == nullptr) && (clickListener2 == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance fail"); - return; - } - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - newEquipmentButton->SetOnClickListener(clickListener); - newEquipmentButton->SetTextColor(Color::Red()); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - newEquipmentButton->SetOnClickListener(clickListener2); - newEquipmentButton->SetTextColor(Color::Blue()); - } - newEquipmentButton->SetImageSrc(PNG_NEW_DEVICE, PNG_NEW_DEVICE); - newEquipmentButton->SetViewId(BLUETOOTH_NEWEQUIPMENT_BUTTON); - newEquipmentButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_FORTY_SIZE); -} - -UIViewGroup *BluetoothDeviceListView::InitShowUpView() -{ - // 获取currentBdAddr db值 待开发 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView init"); - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - } - group->SetPosition(0, 0); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - if (titleLabel == nullptr) { - titleLabel = new UILabel(); - if (titleLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView titleLabel new fail"); - return nullptr; - } - } - - titleLabel->SetPosition(135, 35, 183, 53); // 135:x 35:y 183:width 53:height - titleLabel->SetText("蓝牙耳机"); - titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_FORTY_SIZE); - titleLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - titleLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - InitNewEquipmentButton(); - InItEmptyLabel(); - // 加载列表 - InitList(); - group->Add(newEquipmentButton); - group->Add(titleLabel); - group->Add(emptyLabel); - - UIView::OnDragListener *earDragListener = (UIView::OnDragListener *)OHOS::PlayerOnDragListener::GetInstance(); - UIView::OnDragListener *earDragListener2 = (UIView::OnDragListener *)OHOS::BluetoothPresenter::GetInstance(); - if ((earDragListener == nullptr) && (earDragListener2 == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "earDragListener GetInstance fail"); - return nullptr; - } - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - group->SetOnDragListener(earDragListener); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - group->SetOnDragListener(earDragListener2); - } - group->SetViewId(BLUETOOTH_DEVICE_LIST_VIEW); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} - -void BluetoothDeviceListView::RefreshText(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView::RefreshText"); - List &bluetoothConnedList = BluetoothModel::GetInstance()->GetConnedDevicesCase(); - bool ret = bluetoothConnedList.IsEmpty(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView::RefreshText bluetoothConnedList.IsEmpty ret = %d", ret); - if (ret) { - emptyLabel->SetVisible(true); - } else { - emptyLabel->SetVisible(false); - } -} - -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothEarListView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothEarListView.cpp deleted file mode 100644 index 190747bde..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothEarListView.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: BluetoothEarList view - * Author: - * Create: 2021-10-13 - */ -#include "bluetooth/BluetoothModel.h" -#include "bluetooth/BluetoothEarListView.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "player/PlayersPresenter.h" -#include "bluetooth/BluetoothPresenter.h" -#include "settings/SettingModel.h" - -namespace OHOS { -static BluetoothEarListView *g_pBluetoothEarListView{nullptr}; - -BluetoothEarListView::BluetoothEarListView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView::BluetoothEarListView"); - g_pBluetoothEarListView = this; -} - -BluetoothEarListView::~BluetoothEarListView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView::~BluetoothEarListView"); - group->RemoveAll(); - delete titleLabel; - titleLabel = nullptr; - delete adapterText; - adapterText = nullptr; - delete list; - list = nullptr; - delete rescanButton; - rescanButton = nullptr; - delete group; - group = nullptr; - g_pBluetoothEarListView = nullptr; -} - -BluetoothEarListView *BluetoothEarListView::GetInstance() -{ - return g_pBluetoothEarListView; -} - -void BluetoothEarListView::InitList() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView::InitList"); - // list type - if (adapterText == nullptr) { - adapterText = new BluetoothCaseListAdapter(); - if (adapterText == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView adapterText new fail"); - return; - } - } - if (list == nullptr) { - list = new UIList(UIList::VERTICAL); - if (list == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView list new fail"); - return; - } - list->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - list->SetPosition(36, 118, HORIZONTAL_RESOLUTION, 241); // 36:x 118:y 454:width 241:height - list->SetStartIndex(0); // 0 : list start index - list->SetAdapter(adapterText); - group->Add(list); - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView::InitList end"); -} - -UIViewGroup *BluetoothEarListView::GetGroup() -{ - return group; -} - -UIList *BluetoothEarListView::GetScanUIList() -{ - return list; -} - -void BluetoothEarListView::SetTitleLabel(const char *text) -{ - titleLabel->SetText(text); -} - -void BluetoothEarListView::SetNewEquipmentButtonAdd(void) -{ - group->Add(rescanButton); -} - -void BluetoothEarListView::SetNewEquipmentButtonRemove(void) -{ - group->Remove(rescanButton); -} - -void BluetoothEarListView::SetCancelConnedRequestButtonAdd(void) -{ - group->Add(cancelConnedRequestButton); -} - -void BluetoothEarListView::SetCancelConnedRequestButtonRemove(void) -{ - group->Remove(cancelConnedRequestButton); -} - -void BluetoothEarListView::InitButten(UILabelButton **button, const char *text, const char* id) -{ - if (*button == nullptr) { - *button = new UILabelButton(); - if (*button == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView::InitButten new fail"); - return; - } - } - (*button)->SetPosition(65, 359, 324, 101); // 65 : x, 359 : y, 324:width 101:height - (*button)->SetText(text); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::PlayersPresenter::GetInstance(); - UIView::OnClickListener *clickListener2 = (UIView::OnClickListener *)OHOS::BluetoothPresenter::GetInstance(); - if ((clickListener == nullptr) && (clickListener2 == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView::InitButten button GetInstance fail"); - return; - } - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - (*button)->SetOnClickListener(clickListener); - (*button)->SetTextColor(Color::Red()); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - (*button)->SetOnClickListener(clickListener2); - (*button)->SetTextColor(Color::Blue()); - } - (*button)->SetImageSrc(PNG_NEW_DEVICE, PNG_NEW_DEVICE); - (*button)->SetViewId(id); - (*button)->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_FORTY_SIZE); -} - -UIViewGroup *BluetoothEarListView::InitShowUpView() -{ - // 获取currentBdAddr db值 待开发 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView init"); - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - } - group->SetPosition(0, 0); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - if (titleLabel == nullptr) { - titleLabel = new UILabel(); - if (titleLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView titleLabel new fail"); - return nullptr; - } - } - titleLabel->SetPosition(135, 35, 183, 53); // 135:x 35:y 183:width 53:height - titleLabel->SetText("正在扫描"); - titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_FORTY_SIZE); - titleLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - titleLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - // 加载列表 - InitList(); - InitButten(&rescanButton, "重新扫描", BLUETOOTH_RESCAN_BUTTON); - InitButten(&cancelConnedRequestButton, "取消", BLUETOOTH_CANCELCONNEDREQUEST_BUTTON); - group->Add(titleLabel); - - UIView::OnDragListener *earDragListener = (UIView::OnDragListener *)OHOS::PlayerOnDragListener::GetInstance(); - UIView::OnDragListener *earDragListener2 = (UIView::OnDragListener *)OHOS::BluetoothPresenter::GetInstance(); - if ((earDragListener == nullptr) && (earDragListener2 == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "earDragListener GetInstance fail"); - return nullptr; - } - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - group->SetOnDragListener(earDragListener); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - group->SetOnDragListener(earDragListener2); - } - group->SetViewId(BLUETOOTH_EARLIST_VIEW); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothEarPhoneView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothEarPhoneView.cpp deleted file mode 100644 index 5c85b6d00..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothEarPhoneView.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: BluetoothEarPhone view - * Author: - * Create: 2021-10-13 - */ -#include -#include "bluetooth/BluetoothEarPhoneView.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "bluetooth/BluetoothPresenter.h" -#include "player/PlayersPresenter.h" -#include "bluetooth/BluetoothItemView.h" -#include "settings/SettingModel.h" -#include "common/image_cache_manager.h" -#include "graphic_service.h" - -namespace OHOS { -static BluetoothEarPhoneView *g_pBluetoothEarPhoneView{nullptr}; -#define BLUETOOTH_IMAGE_X 175 -#define BLUETOOTH_IMAGE_Y 175 -#define BLUETOOTH_IMAGE_WIDTH 104 -#define BLUETOOTH_IMAGE_HEIGHT 104 -#define BLUETOOTH_DELAY 200 - -GraphicTimer* g_stopScanHandle = nullptr; -static constexpr uint64_t MS_SCAN_TIME = 25000; - -BluetoothEarPhoneView::BluetoothEarPhoneView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BluetoothEarPhoneView"); - g_pBluetoothEarPhoneView = this; -} - -BluetoothEarPhoneView::~BluetoothEarPhoneView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::~BluetoothEarPhoneView"); - group->RemoveAll(); - delete titleLabel; - titleLabel = nullptr; - delete imageAnimator; - imageAnimator = nullptr; - delete group; - group = nullptr; - g_pBluetoothEarPhoneView = nullptr; -} - -BluetoothEarPhoneView *BluetoothEarPhoneView::GetInstance() -{ - return g_pBluetoothEarPhoneView; -} - -void BluetoothEarPhoneView::BtScanImageAnimator() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BtScanImageAnimator init"); - const char *searchImagePath[BLUETOOTH_SEARCH_IMAGE_NUM] = { - PNG_A019_080_IMAGE_PATH, - PNG_A019_081_IMAGE_PATH, - PNG_A019_082_IMAGE_PATH, - PNG_A019_083_IMAGE_PATH, - PNG_A019_084_IMAGE_PATH, - PNG_A019_085_IMAGE_PATH, - PNG_A019_086_IMAGE_PATH, - PNG_A019_087_IMAGE_PATH, - }; - - if (imageAnimator == nullptr) { - imageAnimator = new UIImageAnimatorView(); - if (imageAnimator == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView new imageAnimator fail"); - return; - } - for (uint8_t i = 0; i < BLUETOOTH_SEARCH_IMAGE_NUM; i++) { - searchImageInfo[i].imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(searchImagePath[i]); - searchImageInfo[i].imageType = IMG_SRC_IMAGE_INFO; - searchImageInfo[i].pos.x = BLUETOOTH_IMAGE_X; - searchImageInfo[i].pos.y = BLUETOOTH_IMAGE_Y; - searchImageInfo[i].width = BLUETOOTH_IMAGE_WIDTH; - searchImageInfo[i].height = BLUETOOTH_IMAGE_HEIGHT; - } - imageAnimator->SetPosition(175, 175, 104, 104); // 175:x 175:y 104:width 104:height - imageAnimator->SetImageAnimatorSrc(searchImageInfo, BLUETOOTH_SEARCH_IMAGE_NUM, BLUETOOTH_DELAY); - imageAnimator->SetRepeat(true); - group->Add(imageAnimator); - } -} - -void BluetoothEarPhoneView::BtAnimatorStart(void) -{ - imageAnimator->Start(); -} - -void BluetoothEarPhoneView::BtAnimatorStop(void) -{ - imageAnimator->Stop(); -} - -UIViewGroup *BluetoothEarPhoneView::InitShowUpView() -{ - // 获取currentBdAddr db值 待开发 - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - } - group->SetPosition(0, 0); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - if (titleLabel == nullptr) { - titleLabel = new UILabel(); - if (titleLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView titleLabel new fail"); - return nullptr; - } - titleLabel->SetPosition(135, 35, 183, 53); // 135:x 35:y 183:width 53:height - titleLabel->SetText("正在搜索"); - titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_FORTY_SIZE); - titleLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - titleLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - group->Add(titleLabel); - } - UIView::OnDragListener *earDragListener = (UIView::OnDragListener *)OHOS::PlayerOnDragListener::GetInstance(); - UIView::OnDragListener *earDragListener2 = (UIView::OnDragListener *)OHOS::BluetoothPresenter::GetInstance(); - if ((earDragListener == nullptr) && (earDragListener2 == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "earDragListener GetInstance fail"); - return nullptr; - } - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - group->SetOnDragListener(earDragListener); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - group->SetOnDragListener(earDragListener2); - } - group->SetViewId(BLUETOOTH_EAR_PHONE_VIEW); - // 动画 - BtScanImageAnimator(); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} - -void CancelBrScanHandle(void) -{ - if (g_stopScanHandle != nullptr) { - delete g_stopScanHandle; - g_stopScanHandle = nullptr; - } - bool results = gap_br_cancel_discovery(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CancelBtDiscovery results %d", results); -} - -void EndScanHandle(void) -{ - if (BluetoothModel::GetInstance()->GetCase().size() == 0) { - BluetoothEarPhoneView *bluetoothEarPhoneView = BluetoothEarPhoneView::GetInstance(); - if (bluetoothEarPhoneView == nullptr) { // 暂停动画 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothEarPhoneView nullptr"); - return; - } - bluetoothEarPhoneView->BtAnimatorStop(); - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - JumpView *jumpView = JumpView::GetInstance(); - if (jumpView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "jumpView GetInstance fail"); - return; - } - jumpView->ChangeView(JumpView::BluetoothJumpViewNum::BLUETOOTHEARPHONEVIEW, - JumpView::BluetoothJumpViewNum::TIPSFAILMESSAGEVIEW); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - MainBluetoothView *mainBluetoothView = MainBluetoothView::GetInstance(); - if (mainBluetoothView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainBluetoothView GetInstance fail"); - return; - } - mainBluetoothView->ChangeView(BLUETOOTHEARPHONEVIEW, TIPSFAILMESSAGEVIEW); - } - } else { - // 按rssi信息重新排序 - BluetoothModel::GetInstance()->SortScansCaseRssi(); - // 刷新 - BluetoothEarListView *bluetoothEarListView = BluetoothEarListView::GetInstance(); - if (bluetoothEarListView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothEarListView nullptr"); - return; - } - if (bluetoothEarListView->GetScanUIList() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetScanUIList nullptr"); - return; - } - bluetoothEarListView->GetScanUIList()->RefreshList(); - // 扫描完成 - bluetoothEarListView->SetTitleLabel("扫描完成"); - bluetoothEarListView->SetNewEquipmentButtonAdd(); - RootView::GetInstance()->Invalidate(); - } -} - -// 定时器回调函数 -static void BluetoothScanTimerCallbackProc(void* data) -{ - (void)data; - CancelBrScanHandle(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Bt scan end jumpView"); - EndScanHandle(); -} - -void BluetoothScanTimerCallback(void* data) -{ - GraphicService::GetInstance()->PostGraphicEvent(std::bind(BluetoothScanTimerCallbackProc, data)); -} - -// 蓝牙start -void BluetoothEarPhoneView::BtEnable() -{ - bool ret; - bool results; - // 经典蓝牙扫描 - setScanStatus(true); // 开始扫描标记 - BluetoothModel::GetInstance()->SetCaseListClear(); // 扫描list清空 - ret = is_bt_discovering(BT_TRANSPORT_BR_EDR); - if (ret) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable Bt is Discovering"); - return; - } else { - results = gap_br_set_inquiry_paramters(DEVICE_MAJOR_CLASS_AUDIO_VIDEO, 0); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "gap_br_set_inquiry_paramters results %d", results); - results = gap_br_start_discovery(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "gap_br_start_discovery results %d", results); - } - if (g_stopScanHandle != nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable g_stopScanHandle != nullptr"); - return; - } - uint32 tick = GetOSTick(MS_SCAN_TIME); - g_stopScanHandle = new GraphicTimer(tick, BluetoothScanTimerCallback, nullptr, true); - if (g_stopScanHandle == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable new GraphicTimer failed!!"); - return; - } - bool retTimer = g_stopScanHandle->Start(); - if (!retTimer) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable Start failed"); - if (g_stopScanHandle != nullptr) { - delete g_stopScanHandle; - g_stopScanHandle = nullptr; - } - return; - } - return; -} - -void BluetoothEarPhoneView::StopBtDiscovery(void) -{ - bool ret = is_bt_discovering(BT_TRANSPORT_BR_EDR); - if (!ret) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Bt is not Discovering"); - return; - } - CancelBrScanHandle(); - return; -} - -void BluetoothEarPhoneView::setScanStatus(bool value) -{ - scanStart = value; -} -bool BluetoothEarPhoneView::getScanStatus(void) -{ - return scanStart; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothHeadsetEvent.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothHeadsetEvent.cpp deleted file mode 100644 index a036e7628..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothHeadsetEvent.cpp +++ /dev/null @@ -1,480 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: BluetoothHeadsetEvent - * Author: - * Create: 2022-3-22 - */ - -#include "bluetooth/BluetoothHeadsetEvent.h" -#include "bts_avrcp_target.h" -#include "bts_avrcp_controller.h" -#include "player/PlayersModel.h" -#include "graphic_service.h" - -using namespace OHOS; - -#ifdef __cplusplus -extern "C" { -#endif - -#define AVRCP_CT_AUTO_REG_TYPE 1 -uint8_t g_avrcp_tg_local_media_vol = AVRCP_ABSOLUTE_VOLUME_INVALID; -#define BT_A2DP_MEDIA_VOL_LEVEL 100 - -bt_avrcp_tg_bts_cbk g_avrcp_tg_audio_cb; -avrcp_ct_callbacks_t g_avrcp_ct_cb; -avrcp_tg_callbacks_t g_avrcp_tg_cb; -BtAvrcpTgInf g_avrcp_srv_inf; - -void BtAvrcpVolumeChangedSyncMedia(uint8_t a2dp_volume) -{ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "[BtAvrcpVolumeChangedSyncMedia]::a2dp_volume = 0x%x\r\n", a2dp_volume); - int32_t audio_volume = a2dp_volume * BT_A2DP_MEDIA_VOL_LEVEL / AVRCP_ABSOLUTE_VOLUME_PERCENTAGE_100; - AudioManager::GetInstance().SetVolume(AUDIO_STREAM_A2DP_MUSIC, audio_volume); /* 设置增益音量 */ - g_avrcp_tg_local_media_vol = a2dp_volume; - avrcp_tg_notify_volume_changed(a2dp_volume); -} - -/* tg通知媒体状态 */ -static void BtAvrcpTgNotifyMeidaStatus(bt_avrcp_tg_evt_status_param *notifyEventStatusParam) -{ - if (notifyEventStatusParam == nullptr || notifyEventStatusParam->event_id >= AVRCP_NOTIFY_EVENT_RESERVED) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[BtAvrcpTgNotifyMeidaStatus] param is error"); - return; - } - switch (notifyEventStatusParam->event_id) { - case AVRCP_NOTIFY_EVENT_PLAYBACK_STATUS_CHANGED: - avrcp_tg_notify_playback_status_changed(*(td_u8 *)notifyEventStatusParam->event_status); - break; - case AVRCP_NOTIFY_EVENT_TRACK_CHANGED: - avrcp_tg_notify_track_changed(*(unsigned long long *)notifyEventStatusParam->event_status); - break; - case AVRCP_NOTIFY_EVENT_TRACK_REACHED_END: - avrcp_tg_notify_track_reached_end(); - break; - case AVRCP_NOTIFY_EVENT_TRACK_REACHED_START: - avrcp_tg_notify_track_reached_start(); - break; - case AVRCP_NOTIFY_EVENT_PLAYBACK_POS_CHANGED: - avrcp_tg_notify_playback_pos_changed(*(td_u32 *)notifyEventStatusParam->event_status); - break; - case AVRCP_NOTIFY_EVENT_BATT_STATUS_CHANGED: - case AVRCP_NOTIFY_EVENT_SYSTEM_STATUS_CHANGED: - case AVRCP_NOTIFY_EVENT_PLAYER_APPLICATION_SETTING_CHANGED: - break; - case AVRCP_NOTIFY_EVENT_NOW_PLAYING_CONTENT_CHANGED: - avrcp_tg_notify_now_playing_content_changed(); - break; - case AVRCP_NOTIFY_EVENT_AVAILABLE_PLAYERS_CHANGED: - avrcp_tg_notify_available_players_changed(); - break; - case AVRCP_NOTIFY_EVENT_ADDRESSED_PLAYER_CHANGED: - avrcp_tg_notify_addressed_players_changed(*(td_u16 *)notifyEventStatusParam->event_status, - *(td_u16 *)(notifyEventStatusParam->event_status + sizeof(td_u16))); - break; - case AVRCP_NOTIFY_EVENT_UIDS_CHANGED: - avrcp_tg_notify_uid_changed(*(td_u16 *)notifyEventStatusParam->event_status); - break; - case AVRCP_NOTIFY_EVENT_VOLUME_CHANGED: - BtAvrcpVolumeChangedSyncMedia(notifyEventStatusParam->event_status[0]); - break; - case AVRCP_NOTIFY_EVENT_RESERVED: - break; - default: - break; - } -} - -void PressButtonStatusCallback(td_u32 keyOperation, td_u32 keyValue) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[PressButtonStatusCallback]::keyValue = 0x%x keyOperation = 0x%x", - keyValue, keyOperation); - GraphicService::GetInstance()->PostGraphicEvent(std::bind(UsingPressButtonStatusCallback, keyOperation, keyValue)); -} - -void BtAvrcpTgNotifyVolumeChangedProc(uint8_t a2dp_volume) -{ - int32_t audio_volume = a2dp_volume * BT_A2DP_MEDIA_VOL_LEVEL / AVRCP_ABSOLUTE_VOLUME_PERCENTAGE_100; - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "NotifyVolume = %d", audio_volume); - AudioManager::GetInstance().SetVolume(AUDIO_STREAM_MUSIC, audio_volume); // 耳机连接手表场景调节手表音量 -} - -void UsingPressButtonStatusCallback(td_u32 keyOperation, td_u32 keyValue) -{ - bt_avrcp_tg_evt_status_param event; - switch (keyOperation) { - case AVRCP_KEY_VOLUME_UP: // 耳机控制手表加减音量不走key_operation事件 - case AVRCP_KEY_VOLUME_DOWN: // 减小音量 - break; - case AVRCP_KEY_MUTE: // 静音 - event.event_status[0] = AVRCP_ABSOLUTE_VOLUME_PERCENTAGE_0; - event.event_id = AVRCP_NOTIFY_EVENT_VOLUME_CHANGED; - break; - case AVRCP_KEY_PLAY: // 播放 - (void)PlayersModel::GetInstance()->PlayerPlay(); - event.event_status[0] = AVRCP_PLAY_STATUS_PLAYING; - event.event_id = AVRCP_NOTIFY_EVENT_PLAYBACK_STATUS_CHANGED; - break; - case AVRCP_KEY_STOP: // 停止 - (void)PlayersModel::GetInstance()->PlayerStop(); - event.event_status[0] = AVRCP_PLAY_STATUS_STOPPED; - event.event_id = AVRCP_NOTIFY_EVENT_PLAYBACK_STATUS_CHANGED; - break; - case AVRCP_KEY_PAUSE: // 暂停 - (void)PlayersModel::GetInstance()->PlayerPause(); - event.event_status[0] = AVRCP_PLAY_STATUS_PAUSED; - event.event_id = AVRCP_NOTIFY_EVENT_PLAYBACK_STATUS_CHANGED; - break; - case AVRCP_KEY_FORWARD: // 下一曲 - PlayersModel::GetInstance()->LoopingPlayout(); - event.event_status[0] = AVRCP_PLAY_STATUS_FWD_SEEK; - event.event_id = AVRCP_NOTIFY_EVENT_PLAYBACK_STATUS_CHANGED; - break; - case AVRCP_KEY_BACKWARD: // 上一曲 - PlayersModel::GetInstance()->PreviousPlayout(); - event.event_status[0] = AVRCP_PLAY_STATUS_REV_SEEK; - event.event_id = AVRCP_NOTIFY_EVENT_PLAYBACK_STATUS_CHANGED; - break; - case AVRCP_NOTIFY_EVENT_VOLUME_CHANGED: - /* 手机连接手表场景,控制手表喇叭声音 */ - event.event_status[0] = keyValue; - event.event_id = AVRCP_NOTIFY_EVENT_VOLUME_CHANGED; - BtAvrcpTgNotifyVolumeChangedProc((uint8_t)keyValue); - default: - break; - } - - BtAvrcpTgNotifyMeidaStatus(&event); -} - -uint8_t BtAvrcpTgGetLocMediaVolume(void) -{ - if (g_avrcp_tg_local_media_vol == AVRCP_ABSOLUTE_VOLUME_INVALID) { - int32_t audio_volume = AudioManager::GetInstance().GetVolume(AUDIO_STREAM_A2DP_MUSIC); - uint8_t a2dp_volume = (uint8_t)(audio_volume * AVRCP_ABSOLUTE_VOLUME_PERCENTAGE_100 / BT_A2DP_MEDIA_VOL_LEVEL); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "audio_volume 0x%x, a2dp_volume 0x%x\n", audio_volume, a2dp_volume); - g_avrcp_tg_local_media_vol = a2dp_volume; - } - - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "get local media volume, a2dp_volume = 0x%x", g_avrcp_tg_local_media_vol); - return g_avrcp_tg_local_media_vol; -} - -void MediaStatusCallback(bt_avrcp_tg_evt_status_param *eventStatusParam) -{ - if (eventStatusParam == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "eventStatusParam is nullptr"); - return; - } - - int32_t playerStatus = PlayersModel::GetInstance()->GetPlayerstatus(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "playerStatus = %d", playerStatus); - - switch (eventStatusParam->event_id) { - case AVRCP_NOTIFY_EVENT_PLAYBACK_STATUS_CHANGED: - eventStatusParam->event_status[0] = playerStatus; - break; - case AVRCP_NOTIFY_EVENT_TRACK_CHANGED: - case AVRCP_NOTIFY_EVENT_TRACK_REACHED_END: - break; - case AVRCP_NOTIFY_EVENT_TRACK_REACHED_START: - break; - case AVRCP_NOTIFY_EVENT_PLAYBACK_POS_CHANGED: - eventStatusParam->event_status[0] = 0xFF; - break; - case AVRCP_NOTIFY_EVENT_BATT_STATUS_CHANGED: - case AVRCP_NOTIFY_EVENT_SYSTEM_STATUS_CHANGED: - case AVRCP_NOTIFY_EVENT_PLAYER_APPLICATION_SETTING_CHANGED: - break; - case AVRCP_NOTIFY_EVENT_NOW_PLAYING_CONTENT_CHANGED: - break; - case AVRCP_NOTIFY_EVENT_AVAILABLE_PLAYERS_CHANGED: - break; - case AVRCP_NOTIFY_EVENT_ADDRESSED_PLAYER_CHANGED: - break; - case AVRCP_NOTIFY_EVENT_UIDS_CHANGED: - break; - case AVRCP_NOTIFY_EVENT_VOLUME_CHANGED: - eventStatusParam->event_status[0] = BtAvrcpTgGetLocMediaVolume(); - break; - case AVRCP_NOTIFY_EVENT_RESERVED: - break; - default : - break; - } -} - -void ConnCtStateChangedCallback(const bd_addr_t *bdAddr, profile_connect_state_t state) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "avrcp ct update conn stat:%u", state); - if (bdAddr == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bdaddr nullptr"); - return; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnCtStateChangedCallback addr: %02x%02x%02x%02x%02x%02x ", - bdAddr->addr[5], bdAddr->addr[4], bdAddr->addr[3], /* 5 4 3 idx */ - bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0]); /* 2 1 0 idx */ - (void)memcpy_s(g_avrcp_srv_inf.bd_addr.addr, BD_ADDR_LEN, bdAddr->addr, BD_ADDR_LEN); - g_avrcp_srv_inf.avrcp_srv_conn_stat = state; -} - -static bd_addr_t *BtAvrcpSrvGetActiveAddr(void) -{ - return &g_avrcp_srv_inf.bd_addr; -} - -void ConnectTgStateChangedCallback(const bd_addr_t *bdAddr, profile_connect_state_t state) -{ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "avrcp tg update conn stat:%u", state); - if (bdAddr == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bdaddr nullptr"); - return; - } - - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnCtStateChangedCallback addr: %02x%02x%02x%02x%02x%02x ", - bdAddr->addr[5], bdAddr->addr[4], bdAddr->addr[3], /* 5 4 3 idx */ - bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0]); /* 2 1 0 idx */ - (void)memcpy_s(g_avrcp_srv_inf.bd_addr.addr, BD_ADDR_LEN, bdAddr->addr, BD_ADDR_LEN); - g_avrcp_srv_inf.avrcp_srv_conn_stat = state; - - /* 手表耳机链接场景时,耳机控制音量是一个事件而非key_operation,故需要在手表侧向耳机注册音量变更事件 */ - if (state == PROFILE_STATE_CONNECTED) { - (void)avrcp_ct_get_supported_events(BtAvrcpSrvGetActiveAddr()); - } -} - -static void BtAvrcpCtPressButtonRspCallback(const bd_addr_t *bd_addr, int32_t key_operation) -{ - if (bd_addr == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "null pointer\n"); - return; - } - if (g_avrcp_srv_inf.avrcp_button_flag == AVRCP_SRV_RELEASED_VALUE) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "avrcp ct press button button_flag change:%u->%u\n", - g_avrcp_srv_inf.avrcp_button_flag, AVRCP_SRV_PRESS_VALUE); - g_avrcp_srv_inf.avrcp_button_flag = AVRCP_SRV_PRESS_VALUE; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "avrcp ct press button cbk key:%d button_flag:%u\n", - key_operation, g_avrcp_srv_inf.avrcp_button_flag); -} - -static void BtAvrcpPressReleaseButtonLog(uint32_t key_operation) -{ - switch (key_operation) { - case AVRCP_KEY_VOLUME_UP: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AVRCP_KEY_VOLUME_UP\n"); - break; - case AVRCP_KEY_VOLUME_DOWN: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AVRCP_KEY_VOLUME_DOWN\n"); - break; - case AVRCP_KEY_MUTE: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AVRCP_KEY_VOLUME_MUTE\n"); - break; - case AVRCP_KEY_PLAY: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AVRCP_KEY_PLAY\n"); - break; - case AVRCP_KEY_STOP: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AVRCP_KEY_STOP\n"); - break; - case AVRCP_KEY_PAUSE: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AVRCP_KEY_PAUSE\n"); - break; - case AVRCP_KEY_FORWARD: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AVRCP_KEY_FORWARD\n"); - break; - case AVRCP_KEY_BACKWARD: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AVRCP_KEY_BACKWARD\n"); - break; - case AVRCP_NOTIFY_EVENT_VOLUME_CHANGED: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AVRCP_EVENT_VOLUME_CHANGED\n"); - break; - default: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "invalid\n"); - break; - } -} - -static void BtAvrcpCtReleaseButtonRspCallback(const bd_addr_t *bd_addr, int32_t key_operation) -{ - UNUSED(bd_addr); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "avrcp ct release button cbk key:%d\n", key_operation); - if (g_avrcp_srv_inf.avrcp_button_flag == AVRCP_SRV_PRESS_VALUE) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "avrcp ct released button button_flag change:%u->%u\n", - g_avrcp_srv_inf.avrcp_button_flag, AVRCP_SRV_RELEASED_VALUE); - g_avrcp_srv_inf.avrcp_button_flag = AVRCP_SRV_RELEASED_VALUE; - } - BtAvrcpPressReleaseButtonLog((uint32_t)key_operation); -} - -static void BtAvrcpCtSupportCompanyCallback(const bd_addr_t *bd_addr, avrcp_ct_support_company_para_t *company) -{ - if (bd_addr == nullptr || company == nullptr || company->company_id == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "null pointer\n"); - return; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "get company list:"); - for (uint8_t i = 0; i < company->company_num; i++) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " 0x%x ", *company->company_id); - } -} - -static void BtAvrcpCtSupportEventCallback(const bd_addr_t *bd_addr, avrcp_ct_support_event_para_t *event) -{ - if (bd_addr == nullptr || event == nullptr || event->event_id == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "null pointer\n"); - return; - } - - for (uint8_t i = 0; i < event->event_num; i++) { - if (event->event_id[i] == AVRCP_NOTIFY_EVENT_VOLUME_CHANGED) { - int ret = avrcp_ct_register_notification(bd_addr, event->event_id[i], 0); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "register event_id: 0x%x, ret = 0x%x", event->event_id[i], ret); - } - } - - for (uint8_t i = 0; i < event->event_num; i++) { - if (event->event_id[i] != AVRCP_NOTIFY_EVENT_VOLUME_CHANGED) { - int ret = avrcp_ct_register_notification(bd_addr, event->event_id[i], 0); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "register event_id: 0x%x, ret = 0x%x", event->event_id[i], ret); - } - } -} - -static void BtAvrcpCtGetElementAttriCallback(const bd_addr_t *bd_addr, avrcp_ct_element_attr_para_cb_t *attr_cb_para) -{ - if (bd_addr == nullptr || attr_cb_para == nullptr || attr_cb_para->attr_value == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "null pointer\n"); - return; - } - - for (uint8_t i = 0; i < attr_cb_para->attr_num; i++) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "attrId-charaId-valLen: 0x%x-0x%x-%u \n", - attr_cb_para->attr_value[i].attr_id, - attr_cb_para->attr_value[i].character_set_id, - attr_cb_para->attr_value[i].value_len); - switch (attr_cb_para->attr_value[i].attr_id) { - case AVRCP_CT_ELEMENT_ATTR_TITLE: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Attr Title:"); - break; - case AVRCP_CT_ELEMENT_ATTR_ARTIST_NAME: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Attr Name:"); - break; - case AVRCP_CT_ELEMENT_ATTR_ALBUM_NAME: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Attr Album:"); - break; - case AVRCP_CT_ELEMENT_ATTR_TRACK_NUMBER: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Attr Track Number:"); - break; - case AVRCP_CT_ELEMENT_ATTR_TOTAL_NUMBER_OF_TRACKS: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Attr Total Number Of Track:"); - break; - case AVRCP_CT_ELEMENT_ATTR_TRACK_GENRE: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Attr Track GENRE:"); - break; - case AVRCP_CT_ELEMENT_ATTR_TRACK_PLAYING_TIME: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Attr Track Playing Time_ms:"); - break; - default: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Other:"); - break; - } - - uint8_t *value = (uint8_t *)(void *)malloc(attr_cb_para->attr_value[i].value_len + 1); - if (attr_cb_para->attr_value[i].value_len > 0 && attr_cb_para->attr_value[i].value != nullptr) { - if (memcpy_s(value, attr_cb_para->attr_value[i].value_len, - attr_cb_para->attr_value[i].value, attr_cb_para->attr_value[i].value_len) != EOK) { - free(value); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "memcpy_s fail."); - return; - } - } - value[attr_cb_para->attr_value[i].value_len] = '\0'; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " %s \n", value); - free(value); - } -} - -static void BtAvrcpCtGetPlayStatusCallback(const bd_addr_t *bd_addr, avrcp_ct_play_status_cb_t *status) -{ - if (bd_addr == nullptr || status == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "null pointer\n"); - return; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "test get play status songlen:%u, songpos:%u, playstatus:%u:", - status->song_length, status->song_position, status->play_status); -} - -static void BtAvrcpCtHdlNotifyVolumeRspCbk(avrcp_ct_notification_value_cb_t *notification) -{ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Set local volume: 0x%x\n", notification->volume); /* 注册事件后通知的音量 */ - BtAvrcpTgNotifyVolumeChangedProc((uint8_t)notification->volume); -} - -static void BtAvrcpCtNotificationCallback( - const bd_addr_t *bd_addr, avrcp_notify_event_t event_id, avrcp_ct_notification_value_cb_t *notification) -{ - if (bd_addr == nullptr || notification == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "null pointer\n"); - return; - } - - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ct notification cbk event_id:0x%x\n", event_id); - bool notify_flag = true; - switch (event_id) { - case AVRCP_NOTIFY_EVENT_PLAYBACK_STATUS_CHANGED: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "tg notify ct playback status changed :%u\n", - notification->play_status); - break; - case AVRCP_NOTIFY_EVENT_VOLUME_CHANGED: - BtAvrcpCtHdlNotifyVolumeRspCbk(notification); - break; - case AVRCP_NOTIFY_EVENT_NOW_PLAYING_CONTENT_CHANGED: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "play conent changed event_id:0x%x\n", event_id); - break; - case AVRCP_NOTIFY_EVENT_TRACK_CHANGED: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "track changed event_id:0x%x\n", event_id); - break; - case AVRCP_NOTIFY_EVENT_TRACK_REACHED_END: - case AVRCP_NOTIFY_EVENT_TRACK_REACHED_START: - case AVRCP_NOTIFY_EVENT_PLAYBACK_POS_CHANGED: - case AVRCP_NOTIFY_EVENT_BATT_STATUS_CHANGED: - case AVRCP_NOTIFY_EVENT_SYSTEM_STATUS_CHANGED: - case AVRCP_NOTIFY_EVENT_PLAYER_APPLICATION_SETTING_CHANGED: - case AVRCP_NOTIFY_EVENT_AVAILABLE_PLAYERS_CHANGED: - case AVRCP_NOTIFY_EVENT_ADDRESSED_PLAYER_CHANGED: - case AVRCP_NOTIFY_EVENT_UIDS_CHANGED: - case AVRCP_NOTIFY_EVENT_RESERVED: - default: - notify_flag = false; - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "invalid event id event_id:0x%x\n", event_id); - break; - } - if (notify_flag) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "notify reg event_id: 0x%x\n", event_id); - avrcp_ct_register_notification(bd_addr, event_id, 0); /* TG通知变化后CT重新注册事件 */ - } -} - -void InitBtHeadsetEvent() -{ - g_avrcp_tg_audio_cb.notify_pass_through_status_cbk = PressButtonStatusCallback; - g_avrcp_tg_audio_cb.get_media_status_cbk = MediaStatusCallback; - - g_avrcp_tg_cb.conn_state_changed_cb = ConnectTgStateChangedCallback; - - g_avrcp_ct_cb.conn_state_changed_cb = ConnCtStateChangedCallback; - g_avrcp_ct_cb.press_button_cb = BtAvrcpCtPressButtonRspCallback; - g_avrcp_ct_cb.release_button_cb = BtAvrcpCtReleaseButtonRspCallback; - g_avrcp_ct_cb.supported_companies_cb = BtAvrcpCtSupportCompanyCallback; - g_avrcp_ct_cb.supported_event_cb = BtAvrcpCtSupportEventCallback; - g_avrcp_ct_cb.element_attr_cb = BtAvrcpCtGetElementAttriCallback; - g_avrcp_ct_cb.play_status_cb = BtAvrcpCtGetPlayStatusCallback; - g_avrcp_ct_cb.notification_cb = BtAvrcpCtNotificationCallback; - - avrcp_tg_register_callbacks(&g_avrcp_tg_cb); - avrcp_ct_register_callbacks(&g_avrcp_ct_cb); - bt_avrcp_tg_register_audio_cbk(&g_avrcp_tg_audio_cb); -} -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothItemView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothItemView.cpp deleted file mode 100644 index a05ca8591..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothItemView.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: BluetoothItem view - * Author: - * Create: 2021-10-13 - */ - -#include "bluetooth/BluetoothItemView.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "common/image_cache_manager.h" - -namespace OHOS { -constexpr uint16_t BUTTON_WIDTH = 351; -constexpr uint16_t BUTTON_HEIGHT = 81; -constexpr uint16_t IMAGE_WIDTH = 81; -constexpr uint16_t IMAGE_HEIGHT = 81; -constexpr uint16_t LABEL_HEIGHT = 81; -constexpr uint16_t LABEL_WIDTH = 189; -constexpr uint16_t BLELIST_BUTTON_HEIGHT = 81; - -#define BLUETOOTH_CONNECT_DELAY 200 -#define BLUETOOTH_CONNECT_X 294 -#define BLUETOOTH_CONNECT_Y 0 -#define BLUETOOTH_CONNECT_WIDTH 81 -#define BLUETOOTH_CONNECT_HEIGHT 81 - -BluetoothItemView::BluetoothItemView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::BluetoothItemView"); - SetPosition(53, 106, 375, 81); // 53:x 106:y 375:width 81:height - SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - SetUpChild(); - SetTouchable(true); - - Add(&button); - Add(&connectStateLabel); - Add(&namelabel); - Add(&image); - Add(&connectionAnimator); -} - -BluetoothItemView::~BluetoothItemView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::~BluetoothItemView"); - Remove(&connectStateLabel); - Remove(&button); - Remove(&namelabel); - Remove(&image); - Remove(&connectionAnimator); -} - -void BluetoothItemView::SetUpChild() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::SetUpChild"); - button.Resize(BUTTON_WIDTH, BUTTON_HEIGHT); // 351:Width - button.SetImageSrc(PNG_BT_LIST, PNG_BT_LIST); // 跳转图片 - button.SetImagePosition(24, 0); // 24: lable x-coordinate - - namelabel.SetPosition(105, 0); // 105:x 0:y - namelabel.Resize(LABEL_WIDTH, LABEL_HEIGHT); - namelabel.SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); - namelabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); // 30: means font size - namelabel.SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - namelabel.SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - - image.SetPosition(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT); // 0:x 0:y - image.SetSrc(PNG_BLUETOOTHEAR); - BtConnectImageAnimator(); -} - -void BluetoothItemView::SetItemInfo(const BluetoothCaseInfo& itemInfo, bool isCaseList) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::SetItemInfo"); - itemInfo_ = itemInfo; - namelabel.SetText(reinterpret_cast(itemInfo_.deviceName)); - if (isCaseList) { - bool ret = BluetoothModel::GetInstance()->IsTagScanDeviceClicked(); - if ((!IsConnectAnimator()) && (ret)) { - namelabel.SetStyle(STYLE_TEXT_COLOR, Color::Gray().full); - button.SetTouchable(false); - SetTouchable(false); - } else { - namelabel.SetStyle(STYLE_TEXT_COLOR, Color::White().full); - button.SetTouchable(true); - SetTouchable(true); - } - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "index = %d", GetViewIndex()); -} - -BluetoothCaseInfo *BluetoothItemView::GetItemInfo(void) -{ - return &itemInfo_; -} - -void BluetoothItemView::SetConnectionstatus(const BluetoothCaseInfo& infoData) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::SetConnectionstatus"); - connectStateLabel.SetPosition(105, 0); // 105:x 0:y - connectStateLabel.Resize(LABEL_WIDTH, LABEL_HEIGHT); - connectStateLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); // 30: means font size - connectStateLabel.SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - connectStateLabel.SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_BOTTOM); - bool aclConnected = bt_is_acl_connected((const bd_addr_t*)&infoData.addr); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::SetConnectionstatus aclConnected %d", aclConnected); - if (aclConnected) { - connectStateLabel.SetText("已连接"); - } else { - connectStateLabel.SetText("已断开"); - } - namelabel.SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_TOP); - namelabel.Invalidate(); -} - -void BluetoothItemView::ConnectAnimatorStart(void) -{ - connectionAnimator.SetVisible(true); - connectionAnimator.Start(); -} - -void BluetoothItemView::ConnectAnimatorStop(void) -{ - connectionAnimator.SetVisible(false); - connectionAnimator.Stop(); -} - -bool BluetoothItemView::IsConnectAnimator(void) -{ - return connectionAnimator.IsVisible(); -} - -void BluetoothItemView::BtConnectImageAnimator() -{ - const char *connectImagePath[BLUETOOTH_CONNECT_IMAGE_NUM] = { - PNG_A019_088_IMAGE_PATH, - PNG_A019_089_IMAGE_PATH, - PNG_A019_090_IMAGE_PATH, - PNG_A019_091_IMAGE_PATH, - PNG_A019_092_IMAGE_PATH, - PNG_A019_093_IMAGE_PATH, - PNG_A019_094_IMAGE_PATH, - PNG_A019_095_IMAGE_PATH, - }; - - for (uint8_t i = 0; i < BLUETOOTH_CONNECT_IMAGE_NUM; i++) { - connectImageInfo[i].imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(connectImagePath[i]); - connectImageInfo[i].imageType = IMG_SRC_IMAGE_INFO; - connectImageInfo[i].pos.x = BLUETOOTH_CONNECT_X; - connectImageInfo[i].pos.y = BLUETOOTH_CONNECT_Y; - connectImageInfo[i].width = BLUETOOTH_CONNECT_WIDTH; - connectImageInfo[i].height = BLUETOOTH_CONNECT_HEIGHT; - } - - connectionAnimator.SetImageAnimatorSrc(connectImageInfo, BLUETOOTH_CONNECT_IMAGE_NUM, BLUETOOTH_CONNECT_DELAY); - connectionAnimator.SetRepeat(true); - connectionAnimator.SetVisible(false); -} - -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp deleted file mode 100644 index cf54e84df..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp +++ /dev/null @@ -1,1522 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: BluetoothModel view - * Author: - * Create: 2021-10-13 - */ -#include -#include "bluetooth/BluetoothModel.h" -#include "bluetooth/BluetoothWrapper.h" -#include "bluetooth/BluetoothPresenter.h" -#include "connectnewphone/ConnectPhonePresenter.h" -#include "player/BluetoothView.h" -#include "bluetooth/BluetoothItemView.h" -#include "player/PlayersModel.h" -#include "phoneservice/PhoneAudio.h" -#include "graphic_service.h" -#include "msg_center.h" -#include "bts_def.h" -#include "bts_gatt_stru.h" -#include "bts_a2dp_source.h" -#include "bts_gatt_server.h" -#include "bts_le_gap.h" -#include "bts_spp.h" -#include "osal_task.h" -#ifdef SUPPORT_ALIPAY_SEC -#include "alipay_feature.h" -#endif -#include "bts_a2dp_sink.h" -#include "bts_feature.h" -#include "bt_audio_hal_interface.h" -#include "audio_manager_c_wrapper.h" -#include "bts_avrcp_target.h" -#include "msg_center_msg.h" -#include "client/msg_center_client.h" -#include "msg_center_protocol.h" -#include "dfx_channel.h" -#include "tcxo.h" -#include "uiservice/ui_service.h" -#include "network/network_listener.h" -#if defined(SUPPORT_LWIP) && defined(SUPPORT_BREDR) -#include "lwip_driver_adapter.h" -#endif -namespace OHOS { - -#define BT_SPP_TASK_STACK_SIZE 2048 -#define BT_SPP_TASK_PRI 20 -#define TEN 10 - -constexpr uint16_t BLUETOOTH_MAX_NUM = 20; - -#define MEDIA_A2DP_SNK_INTERFACE 1 -osal_timer g_a2dp_stream_accept_timer = {nullptr, nullptr, 0, 0}; -#define A2DP_STREAM_ACCEPT_TIMER_PERIOD 500 -AudioFormatConfig g_audio_format_config = {AUDIO_DEFAULT, 0, 0}; -static uint16_t g_sample_svr_handle = 0; -static uint16_t g_sample_characteristic_handle = 0; -static uint16_t g_diag_characteristic_handle = 0; -static uint16_t g_diag_desc_handle = 0; -constexpr uint16_t g_sample_adv_id = 2; -static bd_addr_t g_bd_addr = { 0 }; - -void BluetoothModel::SetBluetoothCalleridStatus(int16_t value) -{ - callerid = value; -} - -int BluetoothModel::GetBluetoothCalleridStatus(void) -{ - return callerid; -} - -BluetoothModel::BluetoothModel() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothModel::BluetoothModel"); -} - -BluetoothModel *BluetoothModel::GetInstance(void) -{ - static BluetoothModel instance; - return &instance; -} - -char* BluetoothModel::getWatchName(void) -{ - return watchName; -} - -void BluetoothModel::InitBluetoothInfo(void) -{ - errcode_t ret; - unsigned char nameLen = BD_NAME_LEN; - memset_s(watchName, sizeof(watchName), 0, sizeof(watchName)); - ret = bluetooth_get_local_name((unsigned char *)watchName, &nameLen); - // 为了实验室测试需要,客户需要自己修改 - if ((nameLen == strlen("WatchDemo") + 1) && (strcmp("WatchDemo", watchName) == 0)) { - uint32_t currentUs = uapi_tcxo_get_us(); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "currentUs 0x%x", currentUs); - // 设置蓝牙名称 - (void)sprintf_s(watchName, sizeof(watchName), "Watch%x", (currentUs & 0xFFFF)); - ret = bluetooth_set_local_name((unsigned char*)watchName, strlen((char*)watchName) + 1); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "bluetooth_set_local_name %s ret = %u", watchName, ret); - - // 设置蓝牙地址 - bd_addr_t addr = {{0x1C, 0x1D, 0x2B, 0x0, 0x0, 0x0} ,0}; - addr.addr[3] = currentUs & 0xFF; - addr.addr[4] = (currentUs & 0XFF00) >> 8; - addr.addr[5] = currentUs & 0xFF; - ret = bluetooth_set_local_addr(addr.addr, BD_ADDR_LEN); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "bluetooth_set_local_addr [0x%x:0x%x] ret = %u", addr.addr[0], addr.addr[1], ret); - } else { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "watchName: %s", watchName); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "nameLen: %u", nameLen); - } -} - -void BluetoothModel::Init() -{ -#ifndef SUPPORT_AUTO_OTA - errcode_t ret; - - // 设置自动回连,ios一键双连依赖此配置 - bts_feature_t bts_feature = { 0 }; - bts_feature.bt_auto_reconnect_closed = 0; - ret = bts_set_features(&bts_feature); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "bt bts_set_features ret = %u", ret); - - ret = enable_bt_stack(); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "bt enable_bt_stack ret = %u", ret); - - // 设置安全连接 - gap_ble_sec_params_t sec_param = { 1, GAP_BLE_IO_CAPABILITY_NOINPUTNOOUTPUT, 1, GAP_BLE_GAP_SECURITY_MODE1_LEVEL3 }; - ret = gap_ble_set_sec_param(&sec_param); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "bt gap_ble_set_sec_param ret = %u", ret); - - InitBluetoothInfo(); - BtInitCallBacks(); - wrapper_ble_register(); -#ifdef SUPPORT_ALIPAY_SEC - svr_alipay_bluetooth_init(); -#endif - BtInitCallBacksEx(); - BtInitGatts(); - BtInitSpp(); - - /* 实验室测试需要,开机开广播 */ - BleAdvStart(); - - SetUpListCase(); - SetUpConnedDevicesList(); -#endif -} - -void BluetoothModel::SetCaseListClear() -{ - btScansDevicesList_.clear(); -} - -bool BluetoothModel::CheckExistScanList(BluetoothCaseInfo caseInfo) -{ - std::list::iterator node = btScansDevicesList_.begin(); - if (btScansDevicesList_.empty()) { - return false; - } - while (node != btScansDevicesList_.end()) { - if ((caseInfo.addr[0] == node->addr[0]) && (caseInfo.addr[1] == node->addr[1]) - && (caseInfo.addr[2] == node->addr[2]) && (caseInfo.addr[3] == node->addr[3]) - && (caseInfo.addr[4] == node->addr[4]) && (caseInfo.addr[5] == node->addr[5])) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "true"); - return true; - } - node++; - } - return false; -} - -void BluetoothModel::SetUpListCase() -{ - SetCaseListClear(); -} - -std::list& BluetoothModel::GetCase() -{ - return btScansDevicesList_; -} - -void BluetoothModel::AddCase(BluetoothCaseInfo caseInfo) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCase::caseInfo addr: %02x%02x%02x%02x%02x%02x", - caseInfo.addr[5], caseInfo.addr[4], caseInfo.addr[3], /* mac下标 0 1 2 3 4 5 */ - caseInfo.addr[2], caseInfo.addr[1], caseInfo.addr[0]); - if (btScansDevicesList_.size() >= BLUETOOTH_MAX_NUM) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "btScansDevicesList_.size is BLUETOOTH_MAX_NUM"); - return; - } else { - btScansDevicesList_.push_back(caseInfo); - } -} - -void BluetoothModel::SetScansCaseRssi(const bd_addr_t *bdAddr, int rssi) -{ - for (auto it = btScansDevicesList_.begin(); it != btScansDevicesList_.end(); it++) { - if ((it->addr[0] == bdAddr->addr[0]) && (it->addr[1] == bdAddr->addr[1]) - && (it->addr[2] == bdAddr->addr[2]) && (it->addr[3] == bdAddr->addr[3]) - && (it->addr[4] == bdAddr->addr[4]) && (it->addr[5] == bdAddr->addr[5])) { - it->temp = rssi; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "btScansDevicesList_ rssi:%d deviceName:%s", it->temp, it->deviceName); - } - } -} - - -bool CompBuletoothInfo(const BluetoothCaseInfo& a, const BluetoothCaseInfo& b) -{ - if (a.temp > b.temp) { - return true; - } - return false; -} - -void BluetoothModel::SortScansCaseRssi() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothModel::SortScansCaseRssi"); - btScansDevicesList_.sort(CompBuletoothInfo); -} - -void BluetoothModel::ResetScanDevicesCase(const BluetoothCaseInfo& caseInfo) -{ - for (auto it = btScansDevicesList_.begin(); it != btScansDevicesList_.end(); it++) { - if ((it->addr[0] == caseInfo.addr[0]) && (it->addr[1] == caseInfo.addr[1]) - && (it->addr[2] == caseInfo.addr[2]) && (it->addr[3] == caseInfo.addr[3]) - && (it->addr[4] == caseInfo.addr[4]) && (it->addr[5] == caseInfo.addr[5])) { - (void)memcpy_s(it->deviceName, BD_NAME_LEN, - caseInfo.deviceName, BD_NAME_LEN); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ResetConnedDevicesCase deviceName:%s", it->deviceName); - } - } -} - -/* 已配对设备队列 */ -void BluetoothModel::SetConnedDevicesListClear() -{ - btConnedDevicesList_->Clear(); -} - -void BluetoothModel::SetUpConnedDevicesList() -{ - if (btConnedDevicesList_ == nullptr) { - btConnedDevicesList_ = new List(); - if (btConnedDevicesList_ == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothModel btConnedDevicesList_ new fail"); - return; - } - SetConnedDevicesListClear(); - unsigned int connedDevicesNum = 0; - bool ret = gap_get_paired_devices_num(&connedDevicesNum); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Setup GetPariedDevicesNum ret = %d, num = %d", ret, connedDevicesNum); - - gap_paired_device_info_t *devInfo = (gap_paired_device_info_t*)malloc(sizeof(gap_paired_device_info_t) *connedDevicesNum); - if (devInfo == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DevInfo malloc failed %u", sizeof(gap_paired_device_info_t) *connedDevicesNum); - return; - } - ret = gap_get_paired_devices_list(devInfo, (int *)&connedDevicesNum); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetUpConnedDevicesList gap_get_paired_devices_list ret = %d", ret); - - BluetoothCaseInfo caseInfo{}; - for (int i = 0; i < static_cast(connedDevicesNum); ++i) { - if ((gap_get_device_class((const bd_addr_t *)devInfo[i].addr.addr) & 0x200) != 0) { - continue; - } - (void)memcpy_s(caseInfo.addr, BD_ADDR_LEN, - devInfo[i].addr.addr, BD_ADDR_LEN); - (void)memcpy_s(caseInfo.deviceName, BD_NAME_LEN, - devInfo[i].device_name, BD_NAME_LEN); - AddConnedDevicesCase(caseInfo); - } - free(devInfo); - } -} - -void BluetoothModel::AddConnedDevicesCase(BluetoothCaseInfo caseInfo) -{ - if (btConnedDevicesList_ == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "btConnedDevicesList_ nullptr"); - return; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddConnedDevicesCase::caseInfo addr: %02x%02x%02x%02x%02x%02x", - caseInfo.addr[5], caseInfo.addr[4], caseInfo.addr[3], /* mac下标 0 1 2 3 4 5 */ - caseInfo.addr[2], caseInfo.addr[1], caseInfo.addr[0]); - if (btConnedDevicesList_->Size() >= BLUETOOTH_MAX_NUM) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "btConnedDevicesList_->Size is BLUETOOTH_MAX_NUM"); - return; - } else { - btConnedDevicesList_->PushBack(caseInfo); - } -} - -List& BluetoothModel::GetConnedDevicesCase() -{ - return *btConnedDevicesList_; -} - -void BluetoothModel::SetBtStatus(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetBtStatus tempMacValue: %02x%02x%02x%02x%02x%02x", - tempMacValue.addr[5], tempMacValue.addr[4], tempMacValue.addr[3], /* mac챐 0 1 2 3 4 5 */ - tempMacValue.addr[2], tempMacValue.addr[1], tempMacValue.addr[0]); /* mac챐 0 1 2 3 4 5 */ - aclConnected = bt_is_acl_connected((const bd_addr_t*)&tempMacValue.addr); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "aclConnected %d", aclConnected); -} - -bool BluetoothModel::GetAclConnected(void) -{ - return aclConnected; -} - -void BluetoothModel::SetTempMacValue(BluetoothCaseInfo *caseInfo) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetTempMacValue: %02x%02x%02x%02x%02x%02x", - caseInfo->addr[5], caseInfo->addr[4], caseInfo->addr[3], /* mac챐 0 1 2 3 4 5 */ - caseInfo->addr[2], caseInfo->addr[1], caseInfo->addr[0]); /* mac챐 0 1 2 3 4 5 */ - (void)memcpy_s(tempMacValue.addr, BD_ADDR_LEN, - caseInfo->addr, BD_ADDR_LEN); - (void)memcpy_s(tempMacValue.deviceName, BD_NAME_LEN, - caseInfo->deviceName, BD_NAME_LEN); -} - -BluetoothCaseInfo *BluetoothModel::GetTempMacValue(void) -{ - return &tempMacValue; -} - -void BluetoothModel::SetLastConnedAddr(const bd_addr_t *addr) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetLastConnedAddr: %02x%02x%02x%02x%02x%02x", - addr->addr[5], addr->addr[4], addr->addr[3], /* mac챐 0 1 2 3 4 5 */ - addr->addr[2], addr->addr[1], addr->addr[0]); /* mac챐 0 1 2 3 4 5 */ - (void)memcpy_s(lastConnedAddr.addr, BD_ADDR_LEN, addr->addr, BD_ADDR_LEN); -} - -bd_addr_t *BluetoothModel::GetLastConnedAddr(void) -{ - return &lastConnedAddr; -} - -void BluetoothModel::SetConnectionView(BluetoothItemView *item) -{ - selectItemView = item; -} - -BluetoothItemView *BluetoothModel::GetConnectionView() -{ - return selectItemView; -} - - -void BluetoothModel::SetTagReconnectJump(bool tag) -{ - tagReconnectJump = tag; -} - -bool BluetoothModel::GetTagReconnectJump(void) -{ - return tagReconnectJump; -} - -void BluetoothModel::SetCurView(int16_t viewNum) -{ - curView = viewNum; -} - -int BluetoothModel::GetCurView(void) -{ - return curView; -} - -void BluetoothModel::SetTagConnectView(bool tag) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothModel::SetTagConnectView:%d", tag); - tagConnectView = tag; -} - -// 判断是否需要跳转连接成功\失败界面(已退出蓝牙模块) -bool BluetoothModel::IsTagConnectView(void) -{ - return tagConnectView; -} - -void BluetoothModel::SetTagDisconnectView(bool tag) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothModel::SetTagDisconnectView:%d", tag); - tagDisconnectView = tag; -} - -// 判断是否需要跳转连接失败界面 -bool BluetoothModel::IsTagDisconnectView(void) -{ - return tagDisconnectView; -} - -void BluetoothModel::SetTagConnectNew(bool tag) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothModel::SetTagConnectNew:%d", tag); - tagConnectNew = tag; -} - -void BluetoothModel::SetTagReturnToDeviceListView(bool tag) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothModel::SetTagReturnToDeviceListView:%d", tag); - tagReturnToDeviceListView = tag; -} - -bool BluetoothModel::IsTagReturnToDeviceListView(void) -{ - return tagReturnToDeviceListView; -} - -// 判断断开连接时是否需要马上连接新设备 -bool BluetoothModel::IsTagConnectNew(void) -{ - return tagConnectNew; -} - -void BluetoothModel::SetTagScanDeviceClicked(bool tag) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothModel::SetTagScanDeviceClicked:%d", tag); - tagScanDeviceClicked = tag; -} - -// 判断是否已点击设备请求连接 -bool BluetoothModel::IsTagScanDeviceClicked(void) -{ - return tagScanDeviceClicked; -} - -bool BluetoothModel::CheckExistConnedList(BluetoothCaseInfo caseInfo) -{ - ListNode *node = btConnedDevicesList_ ->Begin(); - if (node == nullptr) { - return false; - } else if ((caseInfo.addr[0] == 0) && (caseInfo.addr[1] == 0) - && (caseInfo.addr[2] == 0) && (caseInfo.addr[3] == 0) - && (caseInfo.addr[4] == 0) && (caseInfo.addr[5] == 0)) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CheckExistConnedList false addr: 000000000000"); - return true; - } - while (node != btConnedDevicesList_ ->End()) { - if ((caseInfo.addr[0] == node->data_.addr[0]) && (caseInfo.addr[1] == node->data_.addr[1]) - && (caseInfo.addr[2] == node->data_.addr[2]) && (caseInfo.addr[3] == node->data_.addr[3]) - && (caseInfo.addr[4] == node->data_.addr[4]) && (caseInfo.addr[5] == node->data_.addr[5])) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CheckExistConnedList true"); - return true; - } - node = node->next_; - } - return false; -} - -bool BluetoothModel::FindNameByAddr(BluetoothCaseInfo &listInfo, BluetoothCaseInfo *caseInfo) -{ - if ((listInfo.addr[0] == caseInfo->addr[0]) && (listInfo.addr[1] == caseInfo->addr[1]) && - (listInfo.addr[2] == caseInfo->addr[2]) && (listInfo.addr[3] == caseInfo->addr[3]) && - (listInfo.addr[4] == caseInfo->addr[4]) && (listInfo.addr[5] == caseInfo->addr[5])) { - (void)memcpy_s(caseInfo->deviceName, BD_NAME_LEN, listInfo.deviceName, BD_NAME_LEN); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FindNameFromList success, deviceName:%s", listInfo.deviceName); - return true; - } else { - return false; - } -} - -bool BluetoothModel::FindNameFromList(BluetoothCaseInfo *caseInfo) -{ - ListNode *node = btConnedDevicesList_->Begin(); - if (!btScansDevicesList_.empty()) { - for (auto it = btScansDevicesList_.begin(); it != btScansDevicesList_.end(); it++) { - if (FindNameByAddr(*it, caseInfo)) { - return true; - } - } - } - if (node != nullptr) { - while (node != btConnedDevicesList_->End()) { - if (FindNameByAddr(node->data_, caseInfo)) { - return true; - } - node = node->next_; - } - } - return false; -} - -bool BluetoothModel::GetBluetoothAclState(void) -{ - if ((lastConnedAddr.addr[0] == 0) && (lastConnedAddr.addr[1] == 0) && - (lastConnedAddr.addr[2] == 0) && (lastConnedAddr.addr[3] == 0) && - (lastConnedAddr.addr[4] == 0) && (lastConnedAddr.addr[5] == 0)) { - return false; - } else { - return bt_is_acl_connected(&lastConnedAddr); - } -} - -bool BluetoothModel::GetAdvStartState(void) -{ - return advStartState; -} -void BluetoothModel::SetAdvStartState(bool state) -{ - advStartState = state; -} - -int BluetoothModel::ConnectRemoteDevice(const bd_addr_t *addr) -{ - /* 恢厂后耳机连接要开启BT广播否则会导致AVRCP无法音量控制 */ - bool ret = gap_br_set_bt_scan_mode(GAP_SCAN_MODE_CONNECTABLE, 60); - if (!ret) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectRemoteDevice gap_br_set_bt_scan_mode ret = 0x%x", ret); - } - errcode_t retVal = gap_connect_remote_device(addr); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "ConnectRemoteDevice gap_connect_remote_device ret = 0x%x", retVal); - (void)memcpy_s(&remoteConnectAddr, sizeof(bd_addr_t), addr, sizeof(bd_addr_t)); - return retVal; -} - -bool BluetoothModel::ConnectRemoteCheck(const bd_addr_t *addr) -{ - bool ret; - if ((remoteConnectAddr.addr[0] == addr->addr[0]) && (remoteConnectAddr.addr[1] == addr->addr[1]) && - (remoteConnectAddr.addr[2] == addr->addr[2]) && (remoteConnectAddr.addr[3] == addr->addr[3]) && - (remoteConnectAddr.addr[4] == addr->addr[4]) && (remoteConnectAddr.addr[5] == addr->addr[5])) { - ret = true; - (void)memset_s(&remoteConnectAddr, sizeof(bd_addr_t), 0, sizeof(bd_addr_t)); - } else { - ret = false; - } - return ret; -} - -#ifdef __cplusplus -extern "C" { -#endif - -// 回调: gap_read_remote_rssi_value 接口的数据上报 -void BtGapReadRemoteRssiEventCallback(const bd_addr_t *bdAddr, int rssi, int status) -{ - UNUSED(status); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BtGapReadRemoteRssiEventCallback addr: %02x%02x%02x%02x%02x%02x", - bdAddr->addr[5], bdAddr->addr[4], bdAddr->addr[3], /* mac下标 0 1 2 3 4 5 */ - bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0]); /* mac下标 0 1 2 3 4 5 */ - BluetoothModel::GetInstance()->SetScansCaseRssi(bdAddr, rssi); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "bt BtGapReadRemoteRssiEventCallback SetSortCaseRssi: %d status: %d", rssi, status); -} - -// 回调:发现状态变化上报/扫描结束 -void BtGapDiscoveryStateChangedCallback(int status) -{ - UNUSED(status); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "bt BtGapDiscoveryStateChangedCallback %d", status); -} - -static void ChangeScanView() -{ - BluetoothEarPhoneView *bluetoothEarPhoneView = BluetoothEarPhoneView::GetInstance(); - if (bluetoothEarPhoneView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothEarPhoneView nullptr"); - return; - } - bluetoothEarPhoneView->setScanStatus(false); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Bt scan one jumpView"); - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - JumpView *jumpView = JumpView::GetInstance(); - if (jumpView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "jumpView GetInstance fail"); - return; - } - jumpView->ChangeView(JumpView::BluetoothJumpViewNum::BLUETOOTHEARPHONEVIEW, - JumpView::BluetoothJumpViewNum::BLUETOOTHEARLISTVIEW); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - MainBluetoothView *mainBluetoothView = MainBluetoothView::GetInstance(); - if (mainBluetoothView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainBluetoothView GetInstance fail"); - return; - } - mainBluetoothView->ChangeView(BLUETOOTHEARPHONEVIEW, BLUETOOTHEARLISTVIEW); - } - // 暂停动画 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BtAnimatorStop bk"); - bluetoothEarPhoneView->BtAnimatorStop(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BtAnimatorStop"); -} - -void BluetoothModel::BtGapDiscoveryResultCallbakHandle(const bd_addr_t &bdAddr) -{ - BluetoothCaseInfo caseInfo{}; - (void)memcpy_s(caseInfo.addr, BD_ADDR_LEN, bdAddr.addr, BD_ADDR_LEN); - - unsigned char nameLen = BD_NAME_LEN; - bool getNameRet = gap_get_device_name(&bdAddr, caseInfo.deviceName, &nameLen); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "gap_discovery_result_callback getNameRet(bool): %d nameLen: %d name:%s", - getNameRet, nameLen, caseInfo.deviceName); - - if (nameLen == 0) { // 过滤未扫描到名字的设备 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "nameLen == 0 return"); - return; - } - // 去重操作 - bool tag = BluetoothModel::GetInstance()->CheckExistScanList(caseInfo); - if (!tag) { - BluetoothModel::GetInstance()->AddCase(caseInfo); // 增加扫描设备信息 - } - bool ret = gap_read_remote_rssi_value(&bdAddr); // 获取rssi - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "gap_read_remote_rssi_value ret = %d", ret); - BluetoothEarPhoneView *bluetoothEarPhoneView = BluetoothEarPhoneView::GetInstance(); - if (bluetoothEarPhoneView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothEarPhoneView nullptr"); - return; - } - tag = bluetoothEarPhoneView->getScanStatus(); - if (tag) { // 跳转 - ChangeScanView(); - } else { - BluetoothEarListView *bluetoothEarListView = BluetoothEarListView::GetInstance(); - if (bluetoothEarListView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothEarListView nullptr"); - return; - } - if (bluetoothEarListView->GetScanUIList() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetScanUIList nullptr"); - return; - } // 刷新 - bluetoothEarListView->GetScanUIList()->RefreshList(); - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "bt BtGapDiscoveryResultCallback end"); -} - -void BtGapPairStatusChangedCallback(const bd_addr_t *bdAddr, int status) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BtGapPairStatusChangedCallback addr: ****%02x%02x%02x%02x status: %d\n", - bdAddr->addr[3], bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0], status); /* addr下标 0 1 2 3 */ - if (status == GAP_PAIR_PAIRED) { - if (ConnectPhonePresenter::GetInstance() != nullptr) { - NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); - } - } -} - -void BtGapPairRequestedCallback(const bd_addr_t *bdAddr) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BtGapPairRequestedCallback addr: ****%02x%02x%02x%02x\n", - bdAddr->addr[3], bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0]); /* addr下标 0 1 2 3 */ -} - -void BtGapPairConfirmedCallback(const bd_addr_t *bdAddr, int req_type, int number) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BtGapPairConfirmedCallback addr: ****%02x%02x%02x%02x req_type: %d number: %d\n", - bdAddr->addr[3], bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0], /* addr下标 0 1 2 3 */ - req_type, number); -} - -// 回调:扫描结果处理/发现结果上报 -void BtGapDiscoveryResultCallback(const bd_addr_t *bdAddr) -{ - if ((gap_get_device_class(bdAddr) & DEVICE_MAJOR_CLASS_PHONE) != 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BtGapDiscoveryResultCallback: Mobile Phone Device"); - return; - } - - if (bdAddr == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "addr nullptr"); - return; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "gap_discovery_result_callback addr: %02x%02x%02x%02x%02x%02x", - bdAddr->addr[5], bdAddr->addr[4], bdAddr->addr[3], /* mac下标 0 1 2 3 4 5 */ - bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0]); /* mac下标 0 1 2 3 4 5 */ - GraphicService::GetInstance()->PostGraphicEvent(std::bind(&BluetoothModel::BtGapDiscoveryResultCallbakHandle, - BluetoothModel::GetInstance(), *bdAddr)); -} - -void HandleBeforeChangeView() -{ - int curView = BluetoothModel::GetInstance()->GetCurView(); - if (curView == BLUETOOTHEARPHONEVIEW) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandleBeforeChangeView curView == BLUETOOTHEARPHONEVIEW"); - BluetoothEarPhoneView *bluetoothEarPhoneView = BluetoothEarPhoneView::GetInstance(); - if (bluetoothEarPhoneView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleBeforeChangeView bluetoothEarPhoneView == nullptr"); - return; - } - bluetoothEarPhoneView->BtAnimatorStop(); - bluetoothEarPhoneView->StopBtDiscovery(); - } else if (curView == BLUETOOTHEARLISTVIEW) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandleBeforeChangeView curView == BLUETOOTHEARLISTVIEW"); - BluetoothEarPhoneView *bluetoothEarPhone = BluetoothEarPhoneView::GetInstance(); - if (bluetoothEarPhone == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleBeforeChangeView bluetoothEarPhoneView == nullptr"); - return; - } - bluetoothEarPhone->StopBtDiscovery(); - BluetoothItemView *pbItermView = BluetoothModel::GetInstance()->GetConnectionView(); - if (pbItermView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleBeforeChangeView The GetConnectionView get failed."); - return; - } - pbItermView->ConnectAnimatorStop(); - BluetoothModel::GetInstance()->SetConnectionView(nullptr); - } else if (curView == BLUETOOTHRECONNECTVIEW) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandleBeforeChangeView curView == BLUETOOTHRECONNECTVIEW"); - BluetoothReconnectView *bluetoothReconnectView = BluetoothReconnectView::GetInstance(); - if (bluetoothReconnectView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleBeforeChangeView bluetoothReconnectView == nullptr"); - return; - } - bluetoothReconnectView->BtReconnectStop(); - } -} - -static void ACLConnectionSuss(const bd_addr_t &bdAddr) -{ - // 判断是否已退出蓝牙模块(无需跳转) - bool tagConnectView = BluetoothModel::GetInstance()->IsTagConnectView(); - if (!tagConnectView) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GapAclStateChangedCallback tagConnectView fail"); - return; - } - // 成功提示 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GAP_ACL_STATE_CONNECTED"); - HandleBeforeChangeView(); - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - JumpView *jumpView = JumpView::GetInstance(); - if (jumpView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "jumpView GetInstance fail"); - return; - } - jumpView->ChangeView(BluetoothModel::GetInstance()->GetCurView(), - JumpView::BluetoothJumpViewNum::TIPSSUCCMESSAGEVIEW); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - MainBluetoothView *mainBluetoothView = MainBluetoothView::GetInstance(); - if (mainBluetoothView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainBluetoothView GetInstance fail"); - return; - } - mainBluetoothView->ChangeView(BluetoothModel::GetInstance()->GetCurView(), TIPSSUCCMESSAGEVIEW); - } - TipsSuccMessageView *tipsSuccMessageView = TipsSuccMessageView::GetInstance(); - if (tipsSuccMessageView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ACLConnectionSuss tipsSuccMessageView GetInstance fail"); - return; - } - tipsSuccMessageView->RefreshNameLabel(bdAddr); -} - -static void ACLConnectionFail(const bd_addr_t &bdAddr) -{ - // 判断是否已退出蓝牙模块(无需跳转) - bool tagConnectView = BluetoothModel::GetInstance()->IsTagConnectView(); - // 判断是否无需跳转到失败界面 - bool tagDisconnectView = BluetoothModel::GetInstance()->IsTagDisconnectView(); - if ((!tagConnectView) || (!tagDisconnectView)) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GapAclStateChangedCallback tagDisconnectView fail"); - return; - } - // 失败提示页 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "conn fail"); - HandleBeforeChangeView(); - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - JumpView *jumpView = JumpView::GetInstance(); - if (jumpView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "jumpView GetInstance fail"); - return; - } - jumpView->ChangeView(BluetoothModel::GetInstance()->GetCurView(), - JumpView::BluetoothJumpViewNum::TIPSCONNFAILMESSAGEVIEW); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - MainBluetoothView *mainBluetoothView = MainBluetoothView::GetInstance(); - if (mainBluetoothView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainBluetoothView GetInstance fail"); - return; - } - mainBluetoothView->ChangeView(BluetoothModel::GetInstance()->GetCurView(), TIPSCONNFAILMESSAGEVIEW); - } - TipsConnFailMessageView *tipsConnFailMessageView = TipsConnFailMessageView::GetInstance(); - if (tipsConnFailMessageView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ACLConnectionFail tipsConnFailMessageView GetInstance fail"); - return; - } - tipsConnFailMessageView->RefreshNameLabel(bdAddr); -} - -static void DisconnectedHandle() -{ - BluetoothModel::GetInstance()->SetTagDisconnectView(false); - BluetoothDeviceListView *bluetoothDeviceListView = BluetoothDeviceListView::GetInstance(); - if (bluetoothDeviceListView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AclStateChangedCallback bluetoothDeviceListView == nullptr"); - return; - } - UIList *deviceList = bluetoothDeviceListView->GetDeviceUIList(); - if (deviceList == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisconnectedHandle deviceList nullptr"); - return; - } - deviceList->RefreshList(); - BluetoothOptionsView *bluetoothOptionsView = BluetoothOptionsView::GetInstance(); - if (bluetoothOptionsView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AclStateChangedCallback bluetoothOptionsView == nullptr"); - return; - } - bluetoothOptionsView->RefreshText(); -} - -void BluetoothModel::BtGapAclStateChangedHandle(gap_acl_state_t state, unsigned int reason, const bd_addr_t &bdAddr) -{ - bool tag = BluetoothModel::GetInstance()->IsTagScanDeviceClicked(); - if ((reason == 0x13) || (reason == 0x14) || (reason == 0x15) || (reason == 0x3D) || (reason == 0x08 && (!tag))) { // 连接断开 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "The peer end is disconnected."); - DisconnectedHandle(); - } else if (reason == 0x16) { // 主动断开连接 - DisconnectedHandle(); - BluetoothCaseInfo *onClickBtCaseInfo = BluetoothModel::GetInstance()->GetTempMacValue(); - if (BluetoothModel::GetInstance()->IsTagConnectNew()) { - errcode_t retVal = ConnectRemoteDevice((const bd_addr_t *)&onClickBtCaseInfo->addr); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectRemoteDevice retVal = %d", retVal); - } - } else if ((reason == 0xb) || (reason > 0x45)) { // 0xb:重复点击连接按钮 0x45:acl状态最大参数 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "reason is false."); - SetTagDisconnectView(false); - } - - if ((state == GAP_ACL_STATE_CONNECTED) || (state == GAP_ACL_STATE_LE_CONNECTED)) { - SetLastConnedAddr(&bdAddr); - // 将数据存入设备列表 - BluetoothCaseInfo *info = GetTempMacValue(); - tag = CheckExistConnedList(*info); - if ((!tag) && (memcmp(info->addr, bdAddr.addr, BD_ADDR_LEN) == 0)) { - AddConnedDevicesCase(*info); - } - } else { - ACLConnectionFail(bdAddr); - } - - if ((state == GAP_ACL_STATE_CONNECTED) || (state == GAP_ACL_STATE_LE_CONNECTED)) { - if (BluetoothModel::GetInstance()->ConnectRemoteCheck(&bdAddr)) { - int32_t retA2dp = a2dp_src_connect(&bdAddr); - if (retA2dp) { - ACLConnectionFail(bdAddr); - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "a2dp_src_connect result 0x%x", retA2dp); - } else { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ingore a2dp_src_connect"); - } - } -} - -void ChangeBleConnectToMax() -{ - if (msg_center_get_trans_channel() == DIAG_FRAME_FID_BT) { - gap_conn_param_update_t conn_param = { 0 }; - conn_param.conn_handle = BLUETOOTH_CONN_HANDLE; - conn_param.interval_min = BLUETOOTH_INTERVAL_TOMAX_MIN; - conn_param.interval_max = BLUETOOTH_INTERVAL_TOMAX_MAX; - conn_param.slave_latency = BLUETOOTH_LATENCY; - conn_param.timeout_multiplier = BLUETOOTH_TIMEOUT_MUTIPLIER; - errcode_t ret = gap_ble_connect_param_update(&conn_param); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BleConnectCallback change to max interval ret:%d : latency-min:%u latency-max:%u\n", - ret, conn_param.interval_min, conn_param.interval_max); - } -} - -void ChangeBleConnectToDefault() -{ - if (msg_center_get_trans_channel() == DIAG_FRAME_FID_BT) { - gap_conn_param_update_t conn_param = { 0 }; - conn_param.conn_handle = BLUETOOTH_CONN_HANDLE; - conn_param.interval_min = BLUETOOTH_INTERVAL_TODEFAULT_MIN; - conn_param.interval_max = BLUETOOTH_INTERVAL_TODEFAULT_MAX; - conn_param.slave_latency = BLUETOOTH_LATENCY; - conn_param.timeout_multiplier = BLUETOOTH_TIMEOUT_MUTIPLIER; - errcode_t ret = gap_ble_connect_param_update(&conn_param); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BleConnectCallback change to default interval ret:%d : latency-min:%u latency-max:%u\n", - ret, conn_param.interval_min, conn_param.interval_max); - } -} - -// 回调:ACL连接状态上报 -void GapAclStateChangedCallback(const bd_addr_t *bdAddr, gap_acl_state_t state, unsigned int reason) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "bt GapAclStateChangedCallback state %d, reason %x succ or err", state, reason); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "addr: %02x%02x%02x%02x%02x%02x", - bdAddr->addr[5], bdAddr->addr[4], bdAddr->addr[3], /* mac下标 0 1 2 3 4 5 */ - bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0]); /* mac下标 0 1 2 3 4 5 */ - static bd_addr_t gapAclConnectAddr{0}; /* 连接后保存手机地址,手表清除手机配对后查询不到class比较手机地址 */ - if ((gap_get_device_class(bdAddr) & 0x200) != 0 || memcmp(gapAclConnectAddr.addr, bdAddr->addr, BD_ADDR_LEN) == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GapAclStateChangedCallback: Mobile Phone Device"); - if (state == GAP_ACL_STATE_DISCONNECTED) { - /* 通知msg_center,ble状态仍用bt状态,此处不区分 */ - MsgCenterSendMsg(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0); - SendMsgToUIService(BT_DISCONNECTED_TO_UI, 0, nullptr, 0); - // send to ace network - // SetAclConnected(false); - net_connect_status_change(NETWORK_TYPE_BLUETOOTH, CONNECTION_STATUS_DISCONNECTED); - } else if (state == GAP_ACL_STATE_CONNECTED) { - (void)memcpy_s(gapAclConnectAddr.addr, BD_ADDR_LEN, bdAddr->addr, BD_ADDR_LEN); - MsgCenterSendMsg(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0); - SendMsgToUIService(BT_CONNECTED_TO_UI, 0, nullptr, 0); - // send to ace network - // SetAclConnected(true); -#if defined(SUPPORT_LWIP) && defined(SUPPORT_BREDR) - bt_pan_open(); -#endif - net_connect_status_change(NETWORK_TYPE_BLUETOOTH, CONNECTION_STATUS_CONNECTED); - } - return; - } - - GraphicService::GetInstance()->PostGraphicEvent( - std::bind(&BluetoothModel::BtGapAclStateChangedHandle, BluetoothModel::GetInstance(), state, reason, *bdAddr)); -} - -// 回调:远端设备名称变化 -void BtRemoteNameChangedCallback(const bd_addr_t *bdAddr, const unsigned char *deviceName, unsigned char length) -{ - if ((gap_get_device_class(bdAddr) & 0x200) != 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BtRemoteNameChangedCallback: Mobile Phone Device"); - return; - } - BluetoothCaseInfo caseInfo{}; - if (bdAddr == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BtRemoteNameChangedCallback addr nullptr"); - return; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BtRemoteNameChangedCallback addr: %02x%02x%02x%02x%02x%02x", - bdAddr->addr[5], bdAddr->addr[4], bdAddr->addr[3], /* mac下标 0 1 2 3 4 5 */ - bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0]); /* mac下标 0 1 2 3 4 5 */ - - (void)memcpy_s(caseInfo.addr, BD_ADDR_LEN, bdAddr->addr, BD_ADDR_LEN); - int ret = memcpy_s(caseInfo.deviceName, BD_NAME_LEN, deviceName, length); - if (ret != EOK) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BtRemoteNameChangedCallback memcpy fail!"); - return; - } - BluetoothModel::GetInstance()->ResetScanDevicesCase(caseInfo); -} - -void BtIsAcceptConnOnSafeModeCallback(const bd_addr_t *bdAddr, bool *res) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BtIsAcceptConnOnSafeModeCallback addr: %02x%02x%02x%02x%02x%02x set *res true", - bdAddr->addr[5], bdAddr->addr[4], bdAddr->addr[3], /* addr下标 3 4 5 */ - bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0]); /* addr下标 0 1 2 */ - *res = true; -} - -static void A2dpSrcConnectstateChanged(bd_addr_t *bdAddr, int connState) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "a2dp_src_connectStateChangedCallback addr: %02x%02x%02x%02x%02x%02x connState: %x", - bdAddr->addr[5], bdAddr->addr[4], bdAddr->addr[3], /* 5 4 3 idx */ - bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0], connState); /* 2 1 0 idx */ - if ((gap_get_device_class(bdAddr) & 0x200) != 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "a2dp_src_connectstateChangedCb: Mobile Phone Device"); - return; - } - if (connState == PROFILE_STATE_CONNECTED) { - uint32_t ret = avrcp_ct_connect(bdAddr); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "avrcp_ct_connect ret = 0x%x", ret); - PhoneAudioManagerSetDeviceConnState(OUT_BLUETOOTH_A2DP, AUDIO_DEVICE_CONNECTED); - GraphicService::GetInstance()->PostGraphicEvent(std::bind(ACLConnectionSuss, *bdAddr)); - } - - if (connState == PROFILE_STATE_DISCONNECTED) { - PhoneAudioManagerSetDeviceConnState(OUT_BLUETOOTH_A2DP, AUDIO_DEVICE_DISCONNECTED); - GraphicService::GetInstance()->PostGraphicEvent(std::bind(ACLConnectionFail, *bdAddr)); - /* 实验室测试耳机回连场景,用户根据需要调整策略 */ - bool ret = gap_br_set_bt_scan_mode(GAP_SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE, 60); // start scan - if (!ret) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "a2dp disc: gap_br_set_bt_scan_mode ret = 0x%x", ret); - } - } -} - -static void A2dpSrcPlayingStateChanged(bd_addr_t *bdAddr, int playState) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "A2dpSrcPlayingStateChangedCallback addr: %02x%02x%02x%02x%02x%02x playState: %x", - bdAddr->addr[5], bdAddr->addr[4], bdAddr->addr[3], /* 5 4 3 idx */ - bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0], playState); /* 2 1 0 idx */ -} - -static void A2dpSrcConfigureChanged(bd_addr_t *bdAddr, a2dp_codec_info_t *info) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "A2dpSrcConfigurationChangedCallback addr: %02x%02x%02x%02x%02x%02x ", - bdAddr->addr[5], bdAddr->addr[4], bdAddr->addr[3], /* 5 4 3 idx */ - bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0]); /* 2 1 0 idx */ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "codec_priority: %04x codec_type: %04x sample_rate: %02x bits_per_sample: %02x channel_mode: %02x ", - info->codec_priority, info->codec_type, info->sample_rate, info->bits_per_sample, info->channel_mode); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "codec_specific1: %04x codec_specific2: %04x codec_specific3: %04x codec_specific4: %04x", - info->codec_specific1, info->codec_specific2, info->codec_specific3, info->codec_specific4); -} - -static void BleConnStateChangeCallback(unsigned short connId, bd_addr_t *addr, gap_ble_conn_state_t connState, - gap_ble_pair_state_t pairState, gap_ble_disc_reason_t discReason) -{ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BleConnStateChangeCallback connId 0x%x, connState 0x%x, pairState 0x%x", - connId, connState, pairState); - if (GAP_BLE_STATE_DISCONNECTED == connState) { // restart ble adv when disconnected - /* 通知msg_center,ble状态仍用bt状态,此处不区分 */ - MsgCenterSendMsg(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0); - msg_center_set_ble_conn_state(GAP_BLE_STATE_DISCONNECTED); - // send to ace network - net_connect_status_change(NETWORK_TYPE_BLUETOOTH_LE, CONNECTION_STATUS_DISCONNECTED); - } else { - MsgCenterSendMsg(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0); - msg_center_set_ble_conn_state(GAP_BLE_STATE_CONNECTED); - (void)memcpy_s(&g_bd_addr, sizeof(bd_addr_t), addr, sizeof(bd_addr_t)); - // send to ace network - net_connect_status_change(NETWORK_TYPE_BLUETOOTH_LE, CONNECTION_STATUS_CONNECTED); - } - // send to ace network -} - -static void BleAdvStartCallback(uint8_t advId, adv_status_t status) -{ - if (g_sample_adv_id == advId) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BleAdvStartCallback advId: %d, status:%d\n", advId, status); - BluetoothModel::GetInstance()->SetAdvStartState(true); - } -} - -static void BleAdvStopCallback(uint8_t advId, adv_status_t status) -{ - if (g_sample_adv_id == advId) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BleAdvStopCallback advId: %d, status:%d\n", advId, status); - BluetoothModel::GetInstance()->SetAdvStartState(false); - } -} - -static void BleAdvTerminateCallback(uint8_t advId, adv_status_t status) -{ - if (g_sample_adv_id == advId) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BleAdvTerminateCallback advId: %d, status:%d\n", advId, status); - BluetoothModel::GetInstance()->SetAdvStartState(false); - // 此处开广播是为了实验室测试需要,客户需要自己修改 - BleAdvStart(); - } -} - -static void BtGattsServiceAddCallback(uint8_t serverId, bt_uuid_t *uuid, uint16_t srvcHandle, errcode_t status) -{ - if ((uuid->uuid_len == sizeof(uint16_t)) && (*((uint16_t*)uuid->uuid) == 0xF01F)) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BtGattsServiceAddCallback 0x%x 0x%x 0x%x", - status, serverId, srvcHandle); - uint16_t sample_id = 0xF11F; - uint16_t diag_id = 0xF21F; - gatts_add_chara_info_t character; - uint16_t value = 0; - - memset_s(&character, sizeof(gatts_add_chara_info_t), 0, sizeof(gatts_add_chara_info_t)); - character.chara_uuid.uuid_len = sizeof(sample_id); - memcpy_s(character.chara_uuid.uuid, sizeof(character.chara_uuid.uuid), (char *)&sample_id, sizeof(sample_id)); - character.permissions = GATT_ATTRIBUTE_PERMISSION_WRITE; - character.properties = GATT_CHARACTER_PROPERTY_BIT_WRITE_NO_RSP; - character.value_len = (uint16_t)sizeof(value); - character.value = (uint8_t *)(&value); - int ret = gatts_add_characteristic(serverId, srvcHandle, &character); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gatts_add_characteristic sample ret 0x%x", ret); - - memset_s(&character, sizeof(gatts_add_chara_info_t), 0, sizeof(gatts_add_chara_info_t)); - character.chara_uuid.uuid_len = sizeof(diag_id); - memcpy_s(character.chara_uuid.uuid, sizeof(character.chara_uuid.uuid), (char *)&diag_id, sizeof(diag_id)); - character.permissions = GATT_ATTRIBUTE_PERMISSION_WRITE | GATT_ATTRIBUTE_PERMISSION_READ; - character.properties = GATT_CHARACTER_PROPERTY_BIT_WRITE_NO_RSP | GATT_CHARACTER_PROPERTY_BIT_READ | GATT_CHARACTER_PROPERTY_BIT_NOTIFY; - character.value_len = (uint16_t)sizeof(value); - character.value = (uint8_t *)(&value); - - ret = gatts_add_characteristic(serverId, srvcHandle, &character); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gatts_add_characteristic diag ret 0x%x", ret); - - g_sample_svr_handle = srvcHandle; - } -} - -static void BtGattsCharacteristicAddCallback(uint8_t serverId, bt_uuid_t *uuid, uint16_t srvcHandle, gatts_add_character_result_t *result, errcode_t status) -{ - if ((uuid->uuid_len == sizeof(uint16_t)) && (*((uint16_t*)uuid->uuid) == 0xF11F)) { - g_sample_characteristic_handle = result->value_handle; - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BtGattsCharacteristicAddCallback 0x%x 0x%x 0x%x 0x%x", - status, serverId, srvcHandle, g_sample_characteristic_handle); - } - if ((uuid->uuid_len == sizeof(uint16_t)) && (*((uint16_t*)uuid->uuid) == 0xF21F)) { - g_diag_characteristic_handle = result->value_handle; - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BtGattsCharacteristicAddCallback 0x%x 0x%x 0x%x 0x%x", - status, serverId, srvcHandle, g_diag_characteristic_handle); - - uint8_t ccc_val[] = { 0x01, 0x00 }; - uint16_t diag_desc = 0x0229; - gatts_add_desc_info_t descriptor; - memset_s(&descriptor, sizeof(gatts_add_desc_info_t), 0, sizeof(gatts_add_desc_info_t)); - descriptor.desc_uuid.uuid_len = sizeof(diag_desc); - memcpy_s(descriptor.desc_uuid.uuid, sizeof(descriptor.desc_uuid.uuid), (char *)&diag_desc, sizeof(diag_desc)); - descriptor.permissions = GATT_ATTRIBUTE_PERMISSION_READ | GATT_ATTRIBUTE_PERMISSION_WRITE; - descriptor.value_len = (uint16_t)sizeof(ccc_val); - descriptor.value = ccc_val; - int ret = gatts_add_descriptor(serverId, srvcHandle, &descriptor); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gatts_add_descriptor diag_desc ret 0x%x", ret); - } - - if (g_sample_characteristic_handle != 0 && g_diag_characteristic_handle !=0 && g_diag_desc_handle != 0) { - int ret = gatts_start_service(serverId, srvcHandle); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gatts_start_service ret 0x%x", ret); - } -} - -static void BtGattsDescriptorAddCallback(uint8_t serverId, bt_uuid_t *uuid, uint16_t srvcHandle, uint16_t descriptorHandle, errcode_t status) -{ - if (g_sample_svr_handle == srvcHandle) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BtGattsDescriptorAddCallback 0x%x 0x%x 0x%x 0x%x", - status, serverId, srvcHandle, descriptorHandle); - g_diag_desc_handle = descriptorHandle; - } - - if (g_sample_characteristic_handle != 0 && g_diag_characteristic_handle !=0 && g_diag_desc_handle != 0) { - int ret = gatts_start_service(serverId, srvcHandle); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gatts_start_service ret 0x%x", ret); - } -} - -static void BtGattsServiceStartCallback(uint8_t serverId, uint16_t srvcHandle, errcode_t status) -{ - if (g_sample_svr_handle == srvcHandle) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BtGattsServiceStartCallback 0x%x 0x%x 0x%x", status, serverId, srvcHandle); - } -} - -static void BtGattsServiceStopCallback(uint8_t serverId, uint16_t srvcHandle, errcode_t status) -{ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BtGattsServiceStopCallback 0x%x 0x%x 0x%x", status, serverId, srvcHandle); -} - -static void BtGattsServiceDeleteCallback(uint8_t serverId, errcode_t status) -{ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BtGattsServiceDeleteCallback 0x%x 0x%x", status, serverId); -} - -static void BtGattsRequestReadCallback(uint8_t serverId, uint16_t connId, gatts_req_read_cb_t *readCbPara, errcode_t status) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BtGattsRequestReadCallback handle = %u", readCbPara->handle); -} - -static void BtGattsRequestWriteCallback(uint8_t serverId, uint16_t connId, gatts_req_write_cb_t *writeCbPara, errcode_t status) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BtGattsRequestWriteCallback handle = %u", writeCbPara->handle); - if (g_sample_characteristic_handle == writeCbPara->handle) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BtGattsRequestWriteCallback handle = %u", writeCbPara->handle); - if (writeCbPara->length == 9) { - if (memcmp("open ctkd", writeCbPara->value, writeCbPara->length) == 0) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "enable ctkd"); - // 一键双连使能(依赖安全连接参数配置) - errcode_t ret = gap_ble_set_ctkd_enable(true); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gap_ble_set_ctkd_enable ret = %u", ret); - - // 发起ble配对 - ret = gap_ble_pair_remote_device(&g_bd_addr); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gap_ble_pair_remote_device ret = %u ", ret); - } - } else if (writeCbPara->length == 10) { - if (memcmp("close ctkd", writeCbPara->value, writeCbPara->length) == 0) { - // 一键双连去使能 - errcode_t ret = gap_ble_set_ctkd_enable(false); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gap_ble_set_ctkd_disable ret = %u", ret); - } - } - } else if (g_diag_characteristic_handle == writeCbPara->handle) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "diag_gatt_write_req_cbk handle = %u", writeCbPara->handle); - diag_gatt_write_req_cbk(serverId, connId, writeCbPara, status); - } else if (g_diag_desc_handle == writeCbPara->handle) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "diag_gatt_set_handle handle = %u", writeCbPara->handle); - if ((writeCbPara->length == 2) && (*(char*)(writeCbPara->value) == 1)) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "open gatt channel"); - diag_gatt_set_handle(serverId, connId, g_diag_characteristic_handle); - msg_center_set_trans_channel(DIAG_FRAME_FID_BT); - } else if ((writeCbPara->length == 2) && (*(char*)(writeCbPara->value) == 0)) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "close gatt channel"); - diag_gatt_set_handle(0, 0, 0); - msg_center_set_trans_channel(DIAG_FRAME_FID_PHONE); - } - } -} - -static void BtGattsMtuChangedCallback(uint8_t serverId, uint16_t connId, uint16_t mtuSize, errcode_t status) -{ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BtGattsMtuChangedCallback connId = %u mtuSize = %u", connId, mtuSize); -} - -static void BtA2dpSnkAcceptTimerStop(void) -{ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "stop timer\n"); - if (g_a2dp_stream_accept_timer.timer != nullptr) { - (void)osal_timer_stop(&g_a2dp_stream_accept_timer); - (void)osal_timer_destroy(&g_a2dp_stream_accept_timer); - g_a2dp_stream_accept_timer.timer = nullptr; - } - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "stop timer success!\n"); -} - -static void BtA2dpSnStartAcceptHandler(unsigned long data) -{ - UNUSED(data); - bd_addr_t active_bd_addr = a2dp_snk_get_active_device(); - a2dp_snk_start_accept(&active_bd_addr); - BtA2dpSnkAcceptTimerStop(); -} - -static errcode_t BtA2dpSnkStartAcceptTimer(void) -{ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "start timer\n"); - if (g_a2dp_stream_accept_timer.timer != nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "timer is running"); - return ERRCODE_SUCC; - } - - g_a2dp_stream_accept_timer.handler = BtA2dpSnStartAcceptHandler; - g_a2dp_stream_accept_timer.interval = A2DP_STREAM_ACCEPT_TIMER_PERIOD; - - int32_t timer_ret = osal_timer_init(&g_a2dp_stream_accept_timer); - if (timer_ret != EOK) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "create timer error! ret: %x\n", timer_ret); - BtA2dpSnkAcceptTimerStop(); - return ERRCODE_FAIL; - } - timer_ret = osal_timer_start(&g_a2dp_stream_accept_timer); - if (timer_ret != EOK) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "start timer error! ret: %x\n", timer_ret); - BtA2dpSnkAcceptTimerStop(); - return ERRCODE_FAIL; - } - return ERRCODE_SUCC; -} - -static int32_t BtA2dpSnkAudioCreate() -{ -#if MEDIA_A2DP_SNK_INTERFACE - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "audioFormat %d channelCount %d sampleRate %d \n", - g_audio_format_config.audioFormat, g_audio_format_config.channelCount, g_audio_format_config.sampleRate); - - int32_t ret = AudioManagerA2dpSinkSetParam(g_audio_format_config); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "AudioManagerA2dpSinkSetParam ret %x\n", ret); - ret = AudioManagerA2dpSinkCreate(); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "AudioManagerA2dpSinkCreate ret %x\n", ret); -#endif - /* 起定时器接受音乐开始请求 */ - (void)BtA2dpSnkStartAcceptTimer(); - return 0; -} - -static int32_t BtA2dpSnkAudioDestroy() -{ -#if MEDIA_A2DP_SNK_INTERFACE - int32_t ret = AudioManagerA2dpSinkDestroy(); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "AudioManagerA2dpSinkDestroy ret %x\n", ret); -#endif - return 0; -} - -static void BtA2dpSnkConnectStateChangedCb(bd_addr_t *bd_addr, int conn_state) -{ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "addr: ****%02x%02x%02x%02x conn_state: %x\n", - bd_addr->addr[3], bd_addr->addr[2], bd_addr->addr[1], bd_addr->addr[0], conn_state); /* 3 2 1 0 idx */ -} - -static void BtA2dpSnkStartStreamReqCb(bd_addr_t *bd_addr) -{ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "addr: ****%02x%02x%02x%02x \n", - bd_addr->addr[3], bd_addr->addr[2], bd_addr->addr[1], bd_addr->addr[0]); /* 3 2 1 0 idx */ - BtA2dpSnkAudioCreate(); -} - -static void BtA2dpSnkPlayingStateChangedCb(bd_addr_t *bd_addr, int playing_state) -{ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "addr: ****%02x%02x%02x%02x playing_state: %x\n", - bd_addr->addr[3], bd_addr->addr[2], bd_addr->addr[1], bd_addr->addr[0], playing_state); /* 3 2 1 0 idx */ - if (playing_state == A2DP_NOT_PLAYING) { - BtA2dpSnkAudioDestroy(); - } -} - -static void BtA2dpSnkConfigChangedCb(bd_addr_t *bd_addr, a2dp_snk_codec_info_t *info) -{ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "addr: ****%02x%02x%02x%02x ", - bd_addr->addr[3], bd_addr->addr[2], bd_addr->addr[1], bd_addr->addr[0]); /* 3 2 1 0 idx */ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, - "codec_priority: %04x codec_type: %04x sample_rate: %02x bits_per_sample: %02x channel_mode: %02x", - info->codec_priority, info->codec_type, info->sample_rate, info->bits_per_sample, info->channel_mode); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, - "codec_specific1: %04x codec_specific2: %04x codec_specific3: %04x codec_specific4: %04x\n", - (unsigned int)info->codec_specific1, - (unsigned int)info->codec_specific2, - (unsigned int)info->codec_specific3, - (unsigned int)info->codec_specific4); -#if MEDIA_A2DP_SNK_INTERFACE - if (info->codec_type == A2DP_SNK_CODEC_TYPE_AAC) { - g_audio_format_config.audioFormat = AAC_LC; - } else { - g_audio_format_config.audioFormat = SBC; - } - /* channel count 1 or 2 */ - g_audio_format_config.channelCount = (info->channel_mode == A2DP_SNK_CODEC_CHANNEL_MODE_NONE ? 1 : 2); - - switch (info->sample_rate) { - case A2DP_SNK_CODEC_SAMPLE_RATE_48000: - g_audio_format_config.sampleRate = BT_AUDIO_A2DP_SMAPLE_RATE48000; - break; - case A2DP_SNK_CODEC_SAMPLE_RATE_88200: - g_audio_format_config.sampleRate = BT_AUDIO_A2DP_SMAPLE_RATE88200; - break; - case A2DP_SNK_CODEC_SAMPLE_RATE_96000: - g_audio_format_config.sampleRate = BT_AUDIO_A2DP_SMAPLE_RATE96000; - break; - default: - g_audio_format_config.sampleRate = BT_AUDIO_A2DP_SMAPLE_RATE44100; - break; - } - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "audioFormat %d channelCount %d sampleRate %d \n", - g_audio_format_config.audioFormat, g_audio_format_config.channelCount, g_audio_format_config.sampleRate); -#endif -} - -// 注册回调函数 -static gap_call_backs_t g_btGapCallBacks{}; -static a2dp_src_callbacks_t g_a2dpSrcCallbacks{}; -static gap_ble_callbacks_t g_gapBleCallbacks{}; -static gatts_callbacks_t g_btGattsCallbacks{}; - -static a2dp_snk_callbacks_t g_a2dp_snk_callbacks = { - BtA2dpSnkConnectStateChangedCb, - BtA2dpSnkStartStreamReqCb, - BtA2dpSnkPlayingStateChangedCb, - BtA2dpSnkConfigChangedCb -}; - -static void BleConnectCallback(uint16_t conn_id, errcode_t status, const gap_ble_conn_param_update_t *param) -{ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BleConnectCallback conn_id:%u, interval-1:%u latency:%u timeout:%u\n",conn_id, param->interval, param->latency, param->timeout); -} - -void BtInitCallBacks() -{ - g_btGapCallBacks.discovery_result_callback = BtGapDiscoveryResultCallback; - g_btGapCallBacks.discovery_state_changed_callback = BtGapDiscoveryStateChangedCallback; - g_btGapCallBacks.acl_state_changed_callbak = GapAclStateChangedCallback; - g_btGapCallBacks.read_remote_rssi_event_callback = BtGapReadRemoteRssiEventCallback; - g_btGapCallBacks.remote_name_changed_callback = BtRemoteNameChangedCallback; - g_btGapCallBacks.is_accept_conn_on_safe_mode_callback = BtIsAcceptConnOnSafeModeCallback; - g_btGapCallBacks.pair_status_changed_callback = BtGapPairStatusChangedCallback; - g_btGapCallBacks.pair_requested_callback = BtGapPairRequestedCallback; - g_btGapCallBacks.pair_confiremed_callback = BtGapPairConfirmedCallback; - gap_register_callbacks(&g_btGapCallBacks); - - g_a2dpSrcCallbacks.connectstate_changed_cb = A2dpSrcConnectstateChanged; - g_a2dpSrcCallbacks.configuration_changed_cb = A2dpSrcConfigureChanged; - g_a2dpSrcCallbacks.playing_state_changed_cb = A2dpSrcPlayingStateChanged; - a2dp_src_register_callbacks(&g_a2dpSrcCallbacks); - - /* a2dp sink */ - a2dp_snk_register_callbacks(&g_a2dp_snk_callbacks); -} - -void BtInitCallBacksEx() -{ - g_gapBleCallbacks.conn_state_change_cb = BleConnStateChangeCallback; - g_gapBleCallbacks.start_adv_cb = BleAdvStartCallback; - g_gapBleCallbacks.stop_adv_cb = BleAdvStopCallback; - g_gapBleCallbacks.terminate_adv_cb = BleAdvTerminateCallback; - g_gapBleCallbacks.conn_param_update_cb = BleConnectCallback; - wrapper_gap_ble_register_callbacks(&g_gapBleCallbacks); - - g_btGattsCallbacks.add_service_cb = BtGattsServiceAddCallback; - g_btGattsCallbacks.add_characteristic_cb = BtGattsCharacteristicAddCallback; - g_btGattsCallbacks.add_descriptor_cb = BtGattsDescriptorAddCallback; - g_btGattsCallbacks.start_service_cb = BtGattsServiceStartCallback; - g_btGattsCallbacks.stop_service_cb = BtGattsServiceStopCallback; - g_btGattsCallbacks.delete_service_cb = BtGattsServiceDeleteCallback; - g_btGattsCallbacks.read_request_cb = BtGattsRequestReadCallback; - g_btGattsCallbacks.write_request_cb = BtGattsRequestWriteCallback; - g_btGattsCallbacks.mtu_changed_cb = BtGattsMtuChangedCallback; - wrapper_gatts_register_callbacks(&g_btGattsCallbacks); -} - -void BtInitGatts(void) -{ - uint16_t id = 0xF01F; - uint16_t ser_id = 0xFF1F; - uint8_t serverId = 0; - bt_uuid_t uuid; - int ret; - - uuid.uuid_len = sizeof(ser_id); - memcpy_s(uuid.uuid, sizeof(uuid.uuid), (char *)&ser_id, sizeof(ser_id)); - ret = wrapper_gatts_register_server(&uuid, &serverId); /* 注册gatt server */ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gatts_register_server ret: 0x%x serverId = 0x%x", ret, serverId); - - uuid.uuid_len = sizeof(id); - memcpy_s(uuid.uuid, sizeof(uuid.uuid), (char *)&id, sizeof(id)); - ret = wrapper_gatts_add_service(serverId, &uuid, true); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gatts_add_service ret: 0x%x", ret); - - wrapper_gatts_service_start(); -} - -static uint8_t Char2Num(int8_t c) -{ - if (c >= '0' && c <= '9') { - return (uint8_t)(c - '0'); - } else if (c >= 'A' && c <= 'F') { - return (uint8_t)(c - 'A' + TEN); - } else if (c >= 'a' && c <= 'f') { - return (uint8_t)(c - 'a' + TEN); - } else { - return 0xFF; - } -} - -static uint32_t GenerateUuidFromString(const char *str, uint8_t len, bt_uuid_t *uuid_out) -{ - int slen = (int)strnlen(str, len); - bool new_uuid = false; - if (uuid_out == nullptr) { - return ERRCODE_INVALID_PARAM; - } - - uuid_out->uuid_len = (uint8_t)slen / 2; /* 2: 2个字符组成一个字节,因此只取偶数个字符 */ - for (int i = 0; i + 1 < slen; i += 2) { /* 2: 同上 */ - uint8_t num1 = Char2Num(str[i]); - uint8_t num2 = Char2Num(str[i + 1]); - if (num1 == UINT8_MAX || num2 == UINT8_MAX) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "invalid input %c%c\n", str[i], str[i + 1]); - return ERRCODE_INVALID_PARAM; - } - - uuid_out->uuid[i / 2] = (uint8_t)((num1 << BIT4) | num2); /* 2: 同上 */ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "%02x ", (uint8_t)(uuid_out->uuid[i / 2])); /* 2: 同上 */ - } - - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "\n"); - return ERRCODE_SUCC; -} - -void BtSppServerCreate(const char *spp_uuid, const char *name, uint8_t name_len) -{ - spp_create_socket_para_t param; - if (GenerateUuidFromString((const char *)spp_uuid, (uint8_t)strlen(spp_uuid), ¶m.uuid) != ERRCODE_SUCC) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "get uuid fail\n"); - return; - } - - param.socket_type = SPP_SOCKET_RFCOMM; - param.is_encrypt = true; - - int ret = spp_server_create(¶m, name, name_len); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "spp_server_create ret: %x\n", ret); -} - -static int BtSppServerAcceptTaskBody(void *data) -{ - int server_id = (int)(intptr_t)data; - int ret = spp_server_accept(server_id); - - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "spp_server_accept ret: %x, server_id: %d\r\n", ret, server_id); - return OSAL_SUCCESS; -} - -/* 等待client连接 */ -void BtSppServerAccept(uint8_t server_id) -{ - osal_task *task = osal_kthread_create(BtSppServerAcceptTaskBody, (void *)(uintptr_t)server_id, - "spp_server_accept_task", BT_SPP_TASK_STACK_SIZE); - if (task == nullptr) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "create task fail\n"); - return; - } - - int ret = osal_kthread_set_priority(task, BT_SPP_TASK_PRI); - if (ret != OSAL_SUCCESS) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "set pri error: %08x\n", ret); - } -} - -void BtInitSpp(void) -{ - char uuid[] = "1101"; - char name[] = "COM1"; - uint8_t name_len = strlen(name) + 1; - uint8_t server_id = 0; - - /* 创建spp */ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "create spp server uuid=%s name=%s name_len=%d\n", uuid, name, name_len); - BtSppServerCreate(uuid, name, name_len); - BtSppServerAccept(server_id); -} - -void BleAdvStart(void) -{ - int advId = g_sample_adv_id; - if (BluetoothModel::GetInstance()->GetAdvStartState()) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BleAdvStart already started"); - gap_ble_stop_adv(advId); - osDelay(50); - } - gap_ble_adv_params_t adv_para; - memset_s(&adv_para, sizeof(gap_ble_adv_params_t), 0, sizeof(gap_ble_adv_params_t)); - adv_para.min_interval = 0x30; - adv_para.max_interval = 0x60; - adv_para.adv_type = GAP_BLE_ADV_CONN_SCAN_UNDIR; - adv_para.channel_map = 0x7; - adv_para.duration = 0; - gap_ble_set_adv_param(advId, &adv_para); - gap_ble_set_local_appearance(GAP_BLE_APPEARANCE_TYPE_GENERIC_WATCH); - errcode_t ret = gap_ble_start_adv(advId); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BleAdvStart bt gap_ble_start_adv ret = 0x%x", ret); -} - -#ifdef __cplusplus -} -#endif -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothOptionsView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothOptionsView.cpp deleted file mode 100644 index ae254eaa6..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothOptionsView.cpp +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: BluetoothOptions view - * Author: - * Create: 2021-10-13 - */ -#include "bluetooth/BluetoothOptionsView.h" -#include "bluetooth/BluetoothModel.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "player/PlayersPresenter.h" -#include "bluetooth/BluetoothPresenter.h" - -namespace OHOS { -static BluetoothOptionsView *g_pBluetoothOptionsView{nullptr}; - -BluetoothOptionsView::BluetoothOptionsView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothOptionsView::BluetoothOptionsView"); - g_pBluetoothOptionsView = this; -} - -BluetoothOptionsView::~BluetoothOptionsView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothOptionsView::~BluetoothOptionsView"); - group->RemoveAll(); - delete titleLabel; - titleLabel = nullptr; - delete connectStateLabel; - connectStateLabel = nullptr; - delete optionsOneButton; - optionsOneButton = nullptr; - delete unpairButton; - unpairButton = nullptr; - delete group; - group = nullptr; - g_pBluetoothOptionsView = nullptr; -} - -BluetoothOptionsView *BluetoothOptionsView::GetInstance() -{ - return g_pBluetoothOptionsView; -} - -void BluetoothOptionsView::RefreshText(void) -{ - // 刷新状态和文字 - BluetoothModel::GetInstance()->SetBtStatus(); - if (BluetoothModel::GetInstance()->GetAclConnected()) { - connectStateLabel->SetText("已连接"); - optionsOneButton->SetText("断开连接"); - } else { - connectStateLabel->SetText("已断开"); - optionsOneButton->SetText("重新连接"); - } - BluetoothCaseInfo *caseInfo = BluetoothModel::GetInstance()->GetTempMacValue(); - titleLabel->SetText(reinterpret_cast(caseInfo->deviceName)); - optionsOneButton->Invalidate(); -} - -void BluetoothOptionsView::InItTitleLabel() -{ - if (titleLabel == nullptr) { - titleLabel = new UILabel(); - if (titleLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothOptionsView titleLabel new fail"); - return; - } - titleLabel->SetPosition(60, 100, 333, 45); // 60:x 100:y 333:width 45:height - BluetoothCaseInfo *caseInfo = BluetoothModel::GetInstance()->GetTempMacValue(); - titleLabel->SetText(reinterpret_cast(caseInfo->deviceName)); - titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); - titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_FORTY_SIZE); - titleLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - titleLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - group->Add(titleLabel); - } - if (connectStateLabel == nullptr) { - connectStateLabel = new UILabel(); - if (connectStateLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothOptionsView connectStateLabel new fail"); - return; - } - connectStateLabel->SetPosition(60, 148, 333, 33); // 60:x 148:y 333:width 33:height - connectStateLabel->SetText("已连接"); - connectStateLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_THIRTY_SIZE); - connectStateLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - connectStateLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - group->Add(connectStateLabel); - } -} - -void BluetoothOptionsView::InItLabelButton() -{ - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::PlayersPresenter::GetInstance(); - UIView::OnClickListener *clickListener2 = (UIView::OnClickListener *)OHOS::BluetoothPresenter::GetInstance(); - if ((clickListener == nullptr) && (clickListener2 == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance fail"); - return; - } - if (optionsOneButton == nullptr) { - optionsOneButton = new UILabelButton(); - if (optionsOneButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothOptionsView optionsOneButton new fail"); - return; - } - optionsOneButton->SetPosition(157, 210, 139, 47); // 157:x, 210:y, 139:width 47:height - optionsOneButton->SetText("断开连接"); - optionsOneButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_THIRTY_SIZE); - optionsOneButton->SetViewId(BLUETOOTH_OPTIONONE_BUTTON); - optionsOneButton->SetImageSrc(PNG_SELECTION_BOX, PNG_SELECTION_BOX); - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - optionsOneButton->SetTextColor(Color::Red()); - optionsOneButton->SetOnClickListener(clickListener); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - optionsOneButton->SetTextColor(Color::Blue()); - optionsOneButton->SetOnClickListener(clickListener2); - } - group->Add(optionsOneButton); - } - if (unpairButton == nullptr) { - unpairButton = new UILabelButton(); - if (unpairButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothOptionsView unpairButton new fail"); - return; - } - unpairButton->SetPosition(157, 284, 139, 47); // 157:x, 284:y, 139:width 47:height - unpairButton->SetText("取消配对"); - unpairButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_THIRTY_SIZE); - unpairButton->SetViewId(BLUETOOTH_UNPAIR_BUTTON); - unpairButton->SetImageSrc(PNG_SELECTION_BOX, PNG_SELECTION_BOX); - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - unpairButton->SetTextColor(Color::Red()); - unpairButton->SetOnClickListener(clickListener); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - unpairButton->SetTextColor(Color::Blue()); - unpairButton->SetOnClickListener(clickListener2); - } - group->Add(unpairButton); - } -} - -UIViewGroup *BluetoothOptionsView::InitShowUpView() -{ - // 获取currentBdAddr db值 model待开发 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothOptionsView init"); - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - InItLabelButton(); - InItTitleLabel(); - UIView::OnDragListener *earDragListener = (UIView::OnDragListener *)OHOS::PlayerOnDragListener::GetInstance(); - UIView::OnDragListener *earDragListener2 = (UIView::OnDragListener *)OHOS::BluetoothPresenter::GetInstance(); - if ((earDragListener == nullptr) && (earDragListener2 == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "earDragListener GetInstance fail"); - return nullptr; - } - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - group->SetOnDragListener(earDragListener); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - group->SetOnDragListener(earDragListener2); - } - group->SetViewId(BLUETOOTH_OPTIONS_VIEW); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} - -UILabelButton *BluetoothOptionsView::GetOptionsOneButton(void) -{ - return optionsOneButton; -} - -UILabelButton *BluetoothOptionsView::GetUnpairButton(void) -{ - return unpairButton; -} - - -void BluetoothOptionsView::SetBtDisconnect(void) -{ - bd_addr_t *lastAddr = BluetoothModel::GetInstance()->GetLastConnedAddr(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetBtDisconnect Addr: %02x%02x%02x%02x%02x%02x", - lastAddr->addr[5], lastAddr->addr[4], lastAddr->addr[3], /* mac下标 0 1 2 3 4 5 */ - lastAddr->addr[2], lastAddr->addr[1], lastAddr->addr[0]); /* mac下标 0 1 2 3 4 5 */ - errcode_t retVal = gap_disconnect_remote_device(lastAddr); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "gap_disconnect_remote_device %d", retVal); -} - -void BluetoothOptionsView::SetBtconnect(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetBtconnect currentAddr: %02x%02x%02x%02x%02x%02x", - currentAddr.addr[5], currentAddr.addr[4], currentAddr.addr[3], /* mac下标 0 1 2 3 4 5 */ - currentAddr.addr[2], currentAddr.addr[1], currentAddr.addr[0]); /* mac下标 0 1 2 3 4 5 */ - errcode_t retVal = BluetoothModel::GetInstance()->ConnectRemoteDevice(¤tAddr); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetBtconnect ConnectRemoteDevice %d", retVal); -} - -void BluetoothOptionsView::SetUnpair(void) -{ - bool ret; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetUnpair currentAddr: %02x%02x%02x%02x%02x%02x", - currentAddr.addr[5], currentAddr.addr[4], currentAddr.addr[3], /* mac下标 0 1 2 3 4 5 */ - currentAddr.addr[2], currentAddr.addr[1], currentAddr.addr[0]); /* mac下标 0 1 2 3 4 5 */ - ret = gap_remove_pair(¤tAddr); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetUnpair gap_remove_pair %d", ret); -} - - -void BluetoothOptionsView::SetCurrentAddr(bd_addr_t addr) -{ - (void)memcpy_s(currentAddr.addr, BD_ADDR_LEN, - addr.addr, BD_ADDR_LEN); // 源和目标内存长度一样,不做返回值判断 -} - -bd_addr_t BluetoothOptionsView::GetCurrentAddr(void) -{ - return currentAddr; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothPresenter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothPresenter.cpp deleted file mode 100644 index e3e472450..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothPresenter.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: BluetoothPresenter view - * Author: - * Create: 2021-10-13 - */ - -#include "wearable_log.h" -#include "UiConfig.h" -#include "bluetooth/BluetoothPresenter.h" -#include "bluetooth/BluetoothReconnectView.h" -#include "bluetooth/MainBluetoothView.h" -#include "NativeRegisterManager.h" -#include "UiConfig.h" - -namespace OHOS { - -REGIST_SLICE(VIEW_BLUETOOTH_EARPHONE, MainBluetoothView, BluetoothPresenter); - -static BluetoothPresenter *g_pBluetoothPresenter = nullptr; - -BluetoothPresenter::BluetoothPresenter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothPresenter new"); - g_pBluetoothPresenter = this; - bluetoothMode_ = BluetoothModel::GetInstance(); -} - -BluetoothPresenter::~BluetoothPresenter() -{ - g_pBluetoothPresenter = nullptr; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothPresenter::~BluetoothPresenter"); -} - -void BluetoothPresenter::OnStop(void) -{ - BluetoothEarPhoneView *bluetoothEarPhoneView = BluetoothEarPhoneView::GetInstance(); - if (bluetoothEarPhoneView != nullptr) { - bluetoothEarPhoneView->StopBtDiscovery(); - return; - } -} - -BluetoothPresenter *BluetoothPresenter::GetInstance() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothPresenter GetInstance"); - return g_pBluetoothPresenter; -} - -void BluetoothPresenter::ClickRescanButton(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothPresenter::OnClick BLUETOOTH_RESCAN_BUTTON"); - // 跳转正在搜索界面 - view_->ChangeView(BLUETOOTHEARLISTVIEW, BLUETOOTHEARPHONEVIEW); -} - -void BluetoothPresenter::ClickNewEquipmentButton(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothPresenter::OnClick BLUETOOTH_NEWEQUIPMENT_BUTTON"); - bluetoothMode_->SetTagReturnToDeviceListView(true); - view_->ChangeView(BLUETOOTHDEVICELISTVIEW, BLUETOOTHEARPHONEVIEW); -} - -void BluetoothPresenter::ClickCancelConnedRequestButton(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothPresenter::OnClick BLUETOOTH_CANCELCONNEDREQUEST_BUTTON"); - BluetoothCaseInfo *caseInfo = bluetoothMode_->GetTempMacValue(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClickCancelConnedRequestButton Addr: %02x%02x%02x%02x%02x%02x", - caseInfo->addr[5], caseInfo->addr[4], caseInfo->addr[3], /* mac下标 0 1 2 3 4 5 */ - caseInfo->addr[2], caseInfo->addr[1], caseInfo->addr[0]); /* mac下标 0 1 2 3 4 5 */ - errcode_t retVal = gap_disconnect_remote_device((const bd_addr_t *)caseInfo->addr); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClickCancelConnedRequestButton gap_disconnect_remote_device retVal = %d", retVal); - - bluetoothMode_->SetTagScanDeviceClicked(false); - // 刷新列表 - BluetoothEarListView *bluetoothEarListView = BluetoothEarListView::GetInstance(); - if (bluetoothEarListView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClickCancelConnedRequestButton bluetoothEarListView nullptr"); - return; - } - if (bluetoothEarListView->GetScanUIList() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClickCancelConnedRequestButton GetScanUIList nullptr"); - return; - } - bluetoothEarListView->GetScanUIList()->RefreshList(); - bluetoothEarListView->SetCancelConnedRequestButtonRemove(); - bluetoothEarListView->SetTitleLabel("扫描完成"); - - BluetoothItemView *pbItermView = bluetoothMode_->GetConnectionView(); - if (pbItermView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleBeforeChangeView The GetConnectionView get failed."); - return; - } - pbItermView->ConnectAnimatorStop(); - bluetoothMode_->SetConnectionView(nullptr); - bluetoothEarListView->SetNewEquipmentButtonAdd(); - RootView::GetInstance()->Invalidate(); -} - -void BluetoothPresenter::ClickUnpairButton(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothPresenter::OnClick BLUETOOTH_UNPAIR_BUTTON"); - bluetoothMode_->SetTagConnectNew(false); - BluetoothOptionsView *bluetoothOptionsView = BluetoothOptionsView::GetInstance(); - if (bluetoothOptionsView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothOptionsView GetInstance fail"); - return; - } - bluetoothOptionsView->SetUnpair(); // 取消配对 - // 删除对应设备列表节点 - bd_addr_t bdAddr = bluetoothOptionsView->GetCurrentAddr(); - List &bluetoothCaseList = bluetoothMode_->GetConnedDevicesCase(); - ListNode *node = bluetoothCaseList.Begin(); - if (node == nullptr) { - return; - } - while (node != bluetoothCaseList.End()) { - if ((bdAddr.addr[0] == node->data_.addr[0]) && (bdAddr.addr[1] == node->data_.addr[1]) - && (bdAddr.addr[2] == node->data_.addr[2]) && (bdAddr.addr[3] == node->data_.addr[3]) - && (bdAddr.addr[4] == node->data_.addr[4]) && (bdAddr.addr[5] == node->data_.addr[5])) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "bdAddr true"); - bluetoothCaseList.Remove(node); - } - node = node->next_; - } - // 跳转并刷新列表 - view_->ChangeView(BLUETOOTHEOPTIONSVIEW, BLUETOOTHDEVICELISTVIEW); -} - -void BluetoothPresenter::ClickOptionsOneButton(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothPresenter::OnClick BLUETOOTH_OPTIONONE_BUTTON"); - BluetoothOptionsView *bluetoothOptionsView = BluetoothOptionsView::GetInstance(); - if (bluetoothOptionsView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothOptionsView GetInstance fail"); - return; - } - bluetoothMode_->SetBtStatus(); - if (bluetoothMode_->GetAclConnected()) { - bluetoothMode_->SetTagConnectNew(false); - bluetoothOptionsView->SetBtDisconnect(); - view_->ChangeView(BLUETOOTHEOPTIONSVIEW, BLUETOOTHDEVICELISTVIEW); - } else { - bluetoothMode_->SetTagReconnectJump(true); - // 重连动画 - view_->ChangeView(BLUETOOTHEOPTIONSVIEW, BLUETOOTHRECONNECTVIEW); - // 判断是否已有连接 - bd_addr_t *lastAddr = bluetoothMode_->GetLastConnedAddr(); - if (bt_is_acl_connected(lastAddr)) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "LastDevice addr: %02x%02x%02x%02x%02x%02x is connected", - lastAddr->addr[5], lastAddr->addr[4], lastAddr->addr[3], - lastAddr->addr[2], lastAddr->addr[1], lastAddr->addr[0]); - bluetoothMode_->SetTagConnectNew(true); - bluetoothOptionsView->SetBtDisconnect(); - } else { - BluetoothCaseInfo *caseInfo = bluetoothMode_->GetTempMacValue(); - errcode_t retVal = BluetoothModel::GetInstance()->ConnectRemoteDevice((const bd_addr_t *)&caseInfo->addr); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClickOptionsOneButton ConnectRemoteDevice retVal = %d", retVal); - } - } -} - -void BluetoothPresenter::ClickSuccBackButton(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothPresenter::OnClick BLUETOOTH_SUCC_BACK_BUTTON"); - view_->ChangeView(TIPSSUCCMESSAGEVIEW, BLUETOOTHDEVICELISTVIEW); -} - -void BluetoothPresenter::ClickFailBackButton(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothPresenter::OnClick BLUETOOTH_FAIL_BACK_BUTTON"); - view_->ChangeView(TIPSFAILMESSAGEVIEW, BLUETOOTHEARPHONEVIEW); -} - -void BluetoothPresenter::ClickConnfailBackButton(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothPresenter::OnClick BLUETOOTH_CONN_FAIL_BACK_BUTTON"); - view_->ChangeView(TIPSCONNFAILMESSAGEVIEW, BLUETOOTHRECONNECTVIEW); - BluetoothCaseInfo *caseInfo = bluetoothMode_->GetTempMacValue(); - errcode_t retVal = bluetoothMode_->ConnectRemoteDevice((const bd_addr_t *)&caseInfo->addr); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClickConnfailBackButton ConnectRemoteDevice retVal = %d", retVal); -} - -bool BluetoothPresenter::OnDragEnd(UIView& view, const DragEvent& event) -{ - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { - view_->DropView(view); - } - return true; -} - -bool BluetoothPresenter::OnClick(UIView &view, const ClickEvent &event) -{ - UNUSED(event); - if (strcmp(view.GetViewId(), BLUETOOTH_RESCAN_BUTTON) == 0) { - ClickRescanButton(); - } else if (strcmp(view.GetViewId(), BLUETOOTH_NEWEQUIPMENT_BUTTON) == 0) { - ClickNewEquipmentButton(); - } else if (strcmp(view.GetViewId(), BLUETOOTH_CANCELCONNEDREQUEST_BUTTON) == 0) { - ClickCancelConnedRequestButton(); - } else if (strcmp(view.GetViewId(), BLUETOOTH_UNPAIR_BUTTON) == 0) { - ClickUnpairButton(); - } else if (strcmp(view.GetViewId(), BLUETOOTH_OPTIONONE_BUTTON) == 0) { - ClickOptionsOneButton(); - } else if (strcmp(view.GetViewId(), BLUETOOTH_SUCC_BACK_BUTTON) == 0) { - ClickSuccBackButton(); - } else if (strcmp(view.GetViewId(), BLUETOOTH_FAIL_BACK_BUTTON) == 0) { - ClickFailBackButton(); - } else if (strcmp(view.GetViewId(), BLUETOOTH_CONN_FAIL_BACK_BUTTON) == 0) { - ClickConnfailBackButton(); - } - return true; -} -}; diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothReconnectView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothReconnectView.cpp deleted file mode 100644 index c1bea7573..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/BluetoothReconnectView.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: Bluetooth Reconnect View - * Create: 2021-10-13 - */ - -#include "bluetooth/BluetoothReconnectView.h" -#include "bluetooth/BluetoothModel.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "player/PlayersPresenter.h" -#include "bluetooth/BluetoothPresenter.h" -#include "common/image_cache_manager.h" - -namespace OHOS { -static BluetoothReconnectView *g_pBluetoothReconnectView{nullptr}; -#define BLUETOOTH_IMAGE_X 175 -#define BLUETOOTH_IMAGE_Y 125 -#define BLUETOOTH_IMAGE_WIDTH 104 -#define BLUETOOTH_IMAGE_HEIGHT 104 -#define BLUETOOTH_DELAY 200 - -BluetoothReconnectView::BluetoothReconnectView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothReconnectView::BluetoothReconnectView"); - g_pBluetoothReconnectView = this; -} - -BluetoothReconnectView::~BluetoothReconnectView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothReconnectView::~BluetoothReconnectView"); - group->RemoveAll(); - delete titleLabel; - titleLabel = nullptr; - delete bluetoothNameLabel; - bluetoothNameLabel = nullptr; - delete reconnectAnimator; - reconnectAnimator = nullptr; - delete group; - group = nullptr; - g_pBluetoothReconnectView = nullptr; -} - -bd_addr_t BluetoothReconnectView::GetcurrentBdAddr(void) -{ - return currentBdAddr; -} - -BluetoothReconnectView *BluetoothReconnectView::GetInstance() -{ - return g_pBluetoothReconnectView; -} - -void BluetoothReconnectView::ShowUpTitleLabel() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothReconnectView::ShowUpTitleLabel"); - if (titleLabel == nullptr) { - titleLabel = new UILabel(); - if (titleLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothReconnectView titleLabel new fail"); - return; - } - titleLabel->SetPosition(87, 285, 280, 45); // 60:x 100:y 333:width 45:height - titleLabel->SetText("正在重连..."); - titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_FORTY_SIZE); - titleLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - titleLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - group->Add(titleLabel); - } - if (bluetoothNameLabel == nullptr) { - bluetoothNameLabel = new UILabel(); - if (bluetoothNameLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothNameLabel new fail"); - return; - } - BluetoothCaseInfo *caseInfo = BluetoothModel::GetInstance()->GetTempMacValue(); - bluetoothNameLabel->SetText(reinterpret_cast(caseInfo->deviceName)); - bluetoothNameLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); - bluetoothNameLabel->SetPosition(60, 235, 333, 45); // 60:x 148:y 333:width 33:height - bluetoothNameLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_THIRTY_SIZE); - bluetoothNameLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - bluetoothNameLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - group->Add(bluetoothNameLabel); - } -} - -void BluetoothReconnectView::BtReconnectStart(void) -{ - reconnectAnimator->Start(); -} - -void BluetoothReconnectView::BtReconnectStop(void) -{ - reconnectAnimator->Stop(); -} - -UIViewGroup *BluetoothReconnectView::InitShowUpView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothReconnectView init"); - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - BtReconnectImageAnimator(); - ShowUpTitleLabel(); - UIView::OnDragListener *reDragListener = (UIView::OnDragListener *)OHOS::PlayerOnDragListener::GetInstance(); - UIView::OnDragListener *reDragListener2 = (UIView::OnDragListener *)OHOS::BluetoothPresenter::GetInstance(); - if ((reDragListener == nullptr) && (reDragListener2 == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "reDragListener GetInstance fail"); - return nullptr; - } - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - group->SetOnDragListener(reDragListener); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - group->SetOnDragListener(reDragListener2); - } - group->SetViewId(BLUETOOTH_RECONNECT_VIEW); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} - -void BluetoothReconnectView::RefreshBluetoothNameLabel() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothReconnectView::RefreshBluetoothNameLabel"); - if (bluetoothNameLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RefreshBluetoothNameLabel bluetoothNameLabel is nullptr"); - return; - } - BluetoothCaseInfo *caseInfo = BluetoothModel::GetInstance()->GetTempMacValue(); - bluetoothNameLabel->SetText(reinterpret_cast(caseInfo->deviceName)); - return; -} - -void BluetoothReconnectView::BtReconnectImageAnimator() -{ - const char *reconnectImagePath[BLUETOOTH_RECONNECT_IMAGE_NUM] = { - PNG_A019_080_IMAGE_PATH, - PNG_A019_081_IMAGE_PATH, - PNG_A019_082_IMAGE_PATH, - PNG_A019_083_IMAGE_PATH, - PNG_A019_084_IMAGE_PATH, - PNG_A019_085_IMAGE_PATH, - PNG_A019_086_IMAGE_PATH, - PNG_A019_087_IMAGE_PATH, - }; - - if (reconnectAnimator == nullptr) { - reconnectAnimator = new UIImageAnimatorView(); - if (reconnectAnimator == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothReconnectView new reconnectAnimator fail"); - } - for (uint8_t i = 0; i < BLUETOOTH_RECONNECT_IMAGE_NUM; i++) { - reconnetImageInfo[i].imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(reconnectImagePath[i]); - reconnetImageInfo[i].imageType = IMG_SRC_IMAGE_INFO; - reconnetImageInfo[i].pos.x = BLUETOOTH_IMAGE_X; - reconnetImageInfo[i].pos.y = BLUETOOTH_IMAGE_Y; - reconnetImageInfo[i].width = BLUETOOTH_IMAGE_WIDTH; - reconnetImageInfo[i].height = BLUETOOTH_IMAGE_HEIGHT; - } - reconnectAnimator->SetPosition(175, 115, 104, 104); // 175:x 175:y 104:width 104:height - reconnectAnimator->SetImageAnimatorSrc(reconnetImageInfo, BLUETOOTH_RECONNECT_IMAGE_NUM, BLUETOOTH_DELAY); - reconnectAnimator->SetRepeat(true); - group->Add(reconnectAnimator); - } -} - -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/MainBluetoothView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/MainBluetoothView.cpp deleted file mode 100644 index a7a242543..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/MainBluetoothView.cpp +++ /dev/null @@ -1,447 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: MainBluetooth view - * Author: - * Create: 2021-10-13 - */ -#include "bluetooth/MainBluetoothView.h" -#include "bluetooth/BluetoothModel.h" -#include "wearable_log.h" - -namespace OHOS { - -static MainBluetoothView *g_pMainBluetoothView = nullptr; - -MainBluetoothView::MainBluetoothView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::MainBluetoothView"); - preProcessView[BLUETOOTHEARPHONEVIEW] = &MainBluetoothView::ChangeBluetoothEarPhoneView; - preProcessView[BLUETOOTHEARLISTVIEW] = &MainBluetoothView::ChangeBluetoothEarListView; - preProcessView[BLUETOOTHDEVICELISTVIEW] = &MainBluetoothView::ChangeBluetoothDeviceListView; - preProcessView[BLUETOOTHEOPTIONSVIEW] = &MainBluetoothView::ChangeBluetoothOptionsView; - preProcessView[BLUETOOTHRECONNECTVIEW] = &MainBluetoothView::ChangeBluetoothReconnectView; - preProcessView[TIPSSUCCMESSAGEVIEW] = &MainBluetoothView::ChangeTipsSuccMessageView; - preProcessView[TIPSCONNFAILMESSAGEVIEW] = &MainBluetoothView::ChangeTipsConnFailMessageView; - preProcessView[TIPSFAILMESSAGEVIEW] = &MainBluetoothView::ChangeTipsFailMessageView; - preProcessView[BLUETOOTHEVIEW] = nullptr; - - g_pMainBluetoothView = this; -} - -MainBluetoothView::~MainBluetoothView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::~MainBluetoothView"); - delete bluetoothEarPhoneView; - bluetoothEarPhoneView = nullptr; - delete bluetoothOptionsView; - bluetoothOptionsView = nullptr; - delete bluetoothEarListView; - bluetoothEarListView = nullptr; - delete bluetoothReconnectView; - bluetoothReconnectView = nullptr; - delete bluetoothDeviceListView; - bluetoothDeviceListView = nullptr; - delete tipsSuccMessageView; - tipsSuccMessageView = nullptr; - delete tipsConnFailMessageView; - tipsConnFailMessageView = nullptr; - delete tipsFailMessageView; - tipsFailMessageView = nullptr; - g_pMainBluetoothView = nullptr; -} - -MainBluetoothView *MainBluetoothView::GetInstance() -{ - return g_pMainBluetoothView; -} - -void MainBluetoothView::OnStart() -{ - BluetoothModel *bluetoothModel = BluetoothModel::GetInstance(); - if (bluetoothModel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::InitView bluetoothModel nullptr err"); - return; - } - bluetoothModel->SetBluetoothCalleridStatus(CALLERSETTING); - bluetoothModel->SetTagConnectView(true); - List &bluetoothCaseList = BluetoothModel::GetInstance()->GetConnedDevicesCase(); - BluetoothModel::GetInstance()->SetTagReturnToDeviceListView(false); - int16_t unusedValue = BLUETOOTHEVIEW_MAX; - bool ret = bluetoothCaseList.IsEmpty(); - if (!ret) { - ChangeView(unusedValue, BLUETOOTHDEVICELISTVIEW); - } else { - ChangeView(unusedValue, BLUETOOTHEARPHONEVIEW); - } - Draw(); - return; -} - -bool MainBluetoothView::ChangeBluetoothDeviceListView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeBluetoothDeviceListView"); - bluetoothDeviceListView = new BluetoothDeviceListView(); - if (bluetoothDeviceListView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothDeviceListView new fail"); - return false; - } - // init view - UIViewGroup *group = bluetoothDeviceListView->InitShowUpView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Device group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } else { - // 刷新列表 - UIList *deviceList = bluetoothDeviceListView->GetDeviceUIList(); - if (deviceList == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick deviceList nullptr"); - return false; - } - deviceList->RefreshList(); - } - bluetoothDeviceListView->RefreshText(); - return true; -} - -bool MainBluetoothView::ChangeTipsFailMessageView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeTipsFailMessageView"); - tipsFailMessageView = new TipsFailMessageView(); - if (tipsFailMessageView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "tipsFailMessageView new fail"); - return false; - } - // init view - UIViewGroup *group = tipsFailMessageView->ShowUpViewInit(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool MainBluetoothView::ChangeTipsConnFailMessageView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeTipsConnFailMessageView"); - tipsConnFailMessageView = new TipsConnFailMessageView(); - if (tipsConnFailMessageView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "tipsConnFailMessageView new fail"); - return false; - } - // init view - UIViewGroup *group = tipsConnFailMessageView->ShowUpViewInit(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } - if (bluetoothReconnectView == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GapAclStateChangedCallback bluetoothReconnectView == nullptr"); - } else { - container[BLUETOOTHRECONNECTVIEW]->SetVisible(false); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeTipsConnFailMessageView SetVisible(false)"); - } - return true; -} - -bool MainBluetoothView::ChangeTipsSuccMessageView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeTipsSuccMessageView"); - tipsSuccMessageView = new TipsSuccMessageView(); - if (tipsSuccMessageView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "tipsSuccMessageView new fail"); - return false; - } - // init view - UIViewGroup *group = tipsSuccMessageView->ShowUpViewInit(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool MainBluetoothView::ChangeBluetoothEarPhoneView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeBluetoothEarPhoneView"); - bluetoothEarPhoneView = new BluetoothEarPhoneView(); - if (bluetoothEarPhoneView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothEarPhoneView new fail"); - return false; - } - UIViewGroup *group = bluetoothEarPhoneView->InitShowUpView(); // init view - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } - // 动画开始 - bluetoothEarPhoneView->BtAnimatorStart(); - // 蓝牙扫描&清空列表 - bluetoothEarPhoneView->BtEnable(); - return true; -} - -bool MainBluetoothView::ChangeBluetoothEarListView(int16_t hideView, int16_t thisView) -{ - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeBluetoothEarListView"); - bluetoothEarListView = new BluetoothEarListView(); - if (bluetoothEarListView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothEarListView new fail"); - return false; - } - UIViewGroup *group = bluetoothEarListView->InitShowUpView(); // init view - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } else { - // 刷新列表 - UIList *scanList = bluetoothEarListView->GetScanUIList(); - if (scanList == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick scanList nullptr"); - return false; - } - scanList->RefreshList(); - } - ResetEarListView(hideView); - return true; -} - -bool MainBluetoothView::ChangeBluetoothOptionsView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeBluetoothOptionsView"); - bluetoothOptionsView = new BluetoothOptionsView(); - if (bluetoothOptionsView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothOptionsView new fail"); - return false; - } - // init view - UIViewGroup *group = bluetoothOptionsView->InitShowUpView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool MainBluetoothView::ChangeBluetoothReconnectView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeBluetoothReconnectView"); - bluetoothReconnectView = new BluetoothReconnectView(); - if (bluetoothReconnectView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothReconnectView new fail"); - return false; - } - UIViewGroup *group = bluetoothReconnectView->InitShowUpView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } - BluetoothModel::GetInstance()->SetTagDisconnectView(true); - bluetoothReconnectView->RefreshBluetoothNameLabel(); - bluetoothReconnectView->BtReconnectStart(); - return true; -} - -void MainBluetoothView::CorrespondingJump(int16_t hideView) -{ - BluetoothModel *bluetoothModel = BluetoothModel::GetInstance(); - if (bluetoothModel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView bluetoothModel == nullptr"); - return; - } - if (bluetoothModel->GetTagReconnectJump()) { - ChangeView(hideView, BLUETOOTHEOPTIONSVIEW); - } else { - std::list &bluetoothScanList = BluetoothModel::GetInstance()->GetCase(); - bool ret = bluetoothScanList.empty(); - if (!ret) { - ChangeView(hideView, BLUETOOTHEARLISTVIEW); - } else { - ChangeView(hideView, BLUETOOTHEARPHONEVIEW); - } - } - return; -} - -void MainBluetoothView::ChangeSettingView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::ChangeSettingView"); - BluetoothModel::GetInstance()->SetTagConnectView(false); - BluetoothModel::GetInstance()->SetTagScanDeviceClicked(false); - NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); -} - -void MainBluetoothView::DropEarPhoneView() -{ - if (bluetoothEarPhoneView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView bluetoothEarPhoneView == nullptr"); - return; - } - bluetoothEarPhoneView->BtAnimatorStop(); - bluetoothEarPhoneView->StopBtDiscovery(); - bool ret = BluetoothModel::GetInstance()->IsTagReturnToDeviceListView(); - if (ret) { - ChangeView(BLUETOOTHEARPHONEVIEW, BLUETOOTHDEVICELISTVIEW); - } else { - ChangeSettingView(); - } -} - -void MainBluetoothView::DropEarListView() -{ - bool ret = BluetoothModel::GetInstance()->IsTagScanDeviceClicked(); - if (ret) { - BluetoothCaseInfo *caseInfo = BluetoothModel::GetInstance()->GetTempMacValue(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropEarListView Addr: %02x%02x%02x%02x%02x%02x", - caseInfo->addr[5], caseInfo->addr[4], caseInfo->addr[3], /* mac下标 0 1 2 3 4 5 */ - caseInfo->addr[2], caseInfo->addr[1], caseInfo->addr[0]); /* mac下标 0 1 2 3 4 5 */ - errcode_t retVal = gap_disconnect_remote_device((const bd_addr_t *)caseInfo->addr); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropEarListView gap_disconnect_remote_device retVal = %d", retVal); - } - if (bluetoothEarPhoneView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView bluetoothEarPhoneView == nullptr"); - return; - } - bluetoothEarPhoneView->StopBtDiscovery(); - BluetoothItemView *pbItermView = BluetoothModel::GetInstance()->GetConnectionView(); - if (pbItermView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DropView The GetConnectionView get failed."); - } else { - pbItermView->ConnectAnimatorStop(); - BluetoothModel::GetInstance()->SetConnectionView(nullptr); - } - ChangeSettingView(); -} - -void MainBluetoothView::DropView(UIView& view) -{ - if (&view == container[BLUETOOTHEARPHONEVIEW]) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView::container[BLUETOOTHEARPHONEVIEW]"); - DropEarPhoneView(); - } else if (&view == container[BLUETOOTHEOPTIONSVIEW]) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView::container[BLUETOOTHEOPTIONSVIEW]"); - ChangeView(BLUETOOTHEOPTIONSVIEW, BLUETOOTHDEVICELISTVIEW); - } else if (&view == container[TIPSCONNFAILMESSAGEVIEW]) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView::container[TIPSCONNFAILMESSAGEVIEW]"); - CorrespondingJump(TIPSCONNFAILMESSAGEVIEW); - } else if (&view == container[TIPSSUCCMESSAGEVIEW]) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView::container[TIPSSUCCMESSAGEVIEW]"); - ChangeView(TIPSSUCCMESSAGEVIEW, BLUETOOTHDEVICELISTVIEW); - } else if (&view == container[TIPSFAILMESSAGEVIEW]) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView::container[TIPSFAILMESSAGEVIEW]"); - ChangeView(TIPSFAILMESSAGEVIEW, BLUETOOTHEARPHONEVIEW); - } else if (&view == container[BLUETOOTHEARLISTVIEW]) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView::container[BLUETOOTHEARLISTVIEW]"); - DropEarListView(); - } else if (&view == container[BLUETOOTHDEVICELISTVIEW]) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView::container[BLUETOOTHDEVICELISTVIEW]"); - ChangeSettingView(); - } else if (&view == container[BLUETOOTHRECONNECTVIEW]) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView::container[BLUETOOTHRECONNECTVIEW]"); - CorrespondingJump(BLUETOOTHRECONNECTVIEW); - BluetoothModel::GetInstance()->SetTagDisconnectView(false); - bluetoothReconnectView->BtReconnectStop(); - } -} - -void MainBluetoothView::ResetEarListView(int16_t hideView) -{ - if (bluetoothEarListView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::ResetEarListView bluetoothEarListView == nullptr"); - return; - } - bluetoothEarListView->SetCancelConnedRequestButtonRemove(); - if (hideView == BLUETOOTHEARPHONEVIEW) { - bluetoothEarListView->SetTitleLabel("正在扫描"); - bluetoothEarListView->SetNewEquipmentButtonRemove(); - } else if (hideView == TIPSCONNFAILMESSAGEVIEW) { - bluetoothEarListView->SetTitleLabel("扫描完成"); - bluetoothEarListView->SetNewEquipmentButtonAdd(); - Draw(); - } -} - -bool MainBluetoothView::CheckViewParam(int16_t hideView, int16_t showView) -{ - if (showView < 0 || showView >= BLUETOOTHEVIEW_MAX) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::CheckViewParam showView err."); - return false; - } - - if (hideView < 0 || hideView > BLUETOOTHEVIEW_MAX) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::CheckViewParam hideView err."); - return false; - } - - if (hideView == BLUETOOTHEARLISTVIEW || showView == BLUETOOTHEARLISTVIEW) { - BluetoothModel::GetInstance()->SetTagScanDeviceClicked(false); - } - - return true; -} - -void MainBluetoothView::ChangeView(int16_t hideView, int16_t showView) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::ChangeView %d, %d", hideView, showView); - - if (!CheckViewParam(hideView, showView)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::CheckViewParam failed."); - return; - } - - PreprosssChangeView tmpPreProcessView = preProcessView[showView]; - - if (!(this->*tmpPreProcessView)(hideView, showView)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::ChangeView %d %dfailed", showView, hideView); - return; - } - if (hideView != BLUETOOTHEVIEW_MAX) { - if (container[hideView] == nullptr) { - return; - } - container[hideView]->SetVisible(false); - } - container[showView]->SetVisible(true); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView:: ChangeView end!!!%d", showView); - Draw(); - BluetoothModel::GetInstance()->SetCurView(showView); -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/TipsConnFailMessageView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/TipsConnFailMessageView.cpp deleted file mode 100644 index 21fb3c440..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/TipsConnFailMessageView.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: TipsConnFailMessageView view - * Author: - * Create: 2021-10-13 - */ -#include "bluetooth/TipsConnFailMessageView.h" -#include "bluetooth/BluetoothModel.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "player/PlayersPresenter.h" -#include "bluetooth/BluetoothPresenter.h" - -namespace OHOS { -static TipsConnFailMessageView *g_pConnFailMessageView{nullptr}; -TipsConnFailMessageView::TipsConnFailMessageView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TipsConnFailMessageView::TipsConnFailMessageView"); - g_pConnFailMessageView = this; -} - -TipsConnFailMessageView::~TipsConnFailMessageView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TipsConnFailMessageView::~TipsConnFailMessageView"); - group->RemoveAll(); - delete titleLabel; - titleLabel = nullptr; - delete backButton; - backButton = nullptr; - delete group; - group = nullptr; - delete tipImg; - tipImg = nullptr; - delete tipLabel; - tipLabel = nullptr; - delete tipTwoLabel; - tipTwoLabel = nullptr; - g_pConnFailMessageView = nullptr; -} - -TipsConnFailMessageView *TipsConnFailMessageView::GetInstance() -{ - return g_pConnFailMessageView; -} - -void TipsConnFailMessageView::ShowUpTipLabel() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TipsConnFailMessageView::ShowUpTipLabel"); - if (tipLabel == nullptr) { - tipLabel = new UILabel(); - if (tipLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TipsConnFailMessageView tipLabel new fail"); - return; - } - tipLabel->SetPosition(0, 247, HORIZONTAL_RESOLUTION, 35); // 0:x 247:y 454:width 35:height. - tipLabel->SetText("请确认该设备在通信范"); - tipLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); // 30:font data - tipLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - tipLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - group->Add(tipLabel); - } - if (tipTwoLabel == nullptr) { - tipTwoLabel = new UILabel(); - if (tipTwoLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TipsConnFailMessageView tipTwoLabel new fail"); - return; - } - tipTwoLabel->SetPosition(0, 300, HORIZONTAL_RESOLUTION, 34); // 0:x 300:y 454:width 34:height. - tipTwoLabel->SetText("围内且处于待配对状态。"); - tipTwoLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); // 30:font data - tipTwoLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - tipTwoLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - group->Add(tipTwoLabel); - } - return; -} - -void TipsConnFailMessageView::InitNameLabel(void) -{ - if (bluetoothNameLabel == nullptr) { - bluetoothNameLabel = new UILabel(); - if (bluetoothNameLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothNameLabel new fail"); - return; - } - bluetoothNameLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); - bluetoothNameLabel->SetPosition(60, 139, 333, 45); // 60:x 139:y 333:width 45:height - bluetoothNameLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_THIRTY_SIZE); - bluetoothNameLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - bluetoothNameLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - group->Add(bluetoothNameLabel); - } -} - -void TipsConnFailMessageView::ShowUpButtonBack() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TipsConnFailMessageView::ShowUpButtonBack"); - if (backButton == nullptr) { - backButton = new UILabelButton(); - if (backButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TipsConnFailMessageView backButton new fail"); - return; - } - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::PlayersPresenter::GetInstance(); - UIView::OnClickListener *clickListener2 = (UIView::OnClickListener *)OHOS::BluetoothPresenter::GetInstance(); - if ((clickListener == nullptr) && (clickListener2 == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance fail"); - return; - } - backButton->SetPosition(65, 359, 324, 101); // 65:x, 359:y, 324:width 101:height. - backButton->SetText("重试"); - backButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40:font data - backButton->SetImageSrc(PNG_NEW_DEVICE, PNG_NEW_DEVICE); - backButton->SetViewId(BLUETOOTH_CONN_FAIL_BACK_BUTTON); - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - backButton->SetTextColor(Color::Red()); - backButton->SetOnClickListener(clickListener); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - backButton->SetTextColor(Color::Blue()); - backButton->SetOnClickListener(clickListener2); - } - group->Add(backButton); - } - if (tipImg == nullptr) { - tipImg = new UIImageView(); - if (tipImg == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TipsConnFailMessageView tipImg new fail"); - return; - } - tipImg->SetPosition(178, 20, 90, 90); // 178:x 20:y 90:width 90:height. - tipImg->SetSrc(PNG_GANTAN); - group->Add(tipImg); - } - return; -} - -UIViewGroup *TipsConnFailMessageView::ShowUpViewInit(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TipsConnFailMessageView::ShowUpViewInit"); - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - if (titleLabel == nullptr) { - titleLabel = new UILabel(); - if (titleLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TipsConnFailMessageView titleLabel new fail"); - return nullptr; - } - titleLabel->SetPosition(0, 189, HORIZONTAL_RESOLUTION, 45); // 0:x 189:y 454:width 45:height. - titleLabel->SetText("连接失败"); - titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40:font data - titleLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - titleLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - group->Add(titleLabel); - } - ShowUpButtonBack(); - ShowUpTipLabel(); - InitNameLabel(); - UIView::OnDragListener *tipsDragListener = (UIView::OnDragListener *)OHOS::PlayerOnDragListener::GetInstance(); - UIView::OnDragListener *tipsDragListener2 = (UIView::OnDragListener *)OHOS::BluetoothPresenter::GetInstance(); - if ((tipsDragListener == nullptr) && (tipsDragListener2 == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "tipsDragListener GetInstance fail"); - return nullptr; - } - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - group->SetOnDragListener(tipsDragListener); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - group->SetOnDragListener(tipsDragListener2); - } - group->SetViewId(TIPS_CONN_FAIL_MESSAGE_VIEW); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} - -void TipsConnFailMessageView::RefreshNameLabel(const bd_addr_t &bdAddr) -{ - BluetoothCaseInfo caseInfo; - (void)memcpy_s(caseInfo.addr, BD_ADDR_LEN, bdAddr.addr, BD_ADDR_LEN); - bool ret = BluetoothModel::GetInstance()->FindNameFromList(&caseInfo); - if (!ret) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TipsConnFailMessageView FindNameFromList fail"); - return; - } - if (bluetoothNameLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TipsConnFailMessageView::RefreshNameLabel bluetoothNameLabel == nullptr"); - return; - } - bluetoothNameLabel->SetText(reinterpret_cast(caseInfo.deviceName)); -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/TipsFailMessageView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/TipsFailMessageView.cpp deleted file mode 100644 index ad592dc90..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/TipsFailMessageView.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: TipsFailMessageView view - * Author: - * Create: 2021-10-13 - */ -#include "bluetooth/TipsFailMessageView.h" -#include "bluetooth/BluetoothModel.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "player/PlayersPresenter.h" -#include "bluetooth/BluetoothPresenter.h" - -namespace OHOS { -static TipsFailMessageView *g_pFailMessageView{nullptr}; -TipsFailMessageView::TipsFailMessageView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TipsFailMessageView::TipsFailMessageView"); - g_pFailMessageView = this; -} - -TipsFailMessageView::~TipsFailMessageView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TipsFailMessageView::~TipsFailMessageView"); - group->RemoveAll(); - delete titleLabel; - titleLabel = nullptr; - delete backButton; - backButton = nullptr; - delete group; - group = nullptr; - delete tipImg; - tipImg = nullptr; - g_pFailMessageView = nullptr; -} - -TipsFailMessageView *TipsFailMessageView::GetInstance() -{ - return g_pFailMessageView; -} - -int TipsFailMessageView::ShowUpButtonBack() -{ - if (backButton == nullptr) { - backButton = new UILabelButton(); - if (backButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TipsFailMessageView backButton new fail"); - return OHOS_FAILURE; - } - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::PlayersPresenter::GetInstance(); - UIView::OnClickListener *clickListener2 = (UIView::OnClickListener *)OHOS::BluetoothPresenter::GetInstance(); - if ((clickListener == nullptr) && (clickListener2 == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance fail"); - return OHOS_FAILURE; - } - backButton->SetPosition(65, 359, 324, 101); // 65:x, 359:y, 324:width 101:height - backButton->SetText("重试"); - backButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40:font data - backButton->SetImageSrc(PNG_NEW_DEVICE, PNG_NEW_DEVICE); - backButton->SetViewId(BLUETOOTH_FAIL_BACK_BUTTON); - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - backButton->SetTextColor(Color::Red()); - backButton->SetOnClickListener(clickListener); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - backButton->SetTextColor(Color::Blue()); - backButton->SetOnClickListener(clickListener2); - } - group->Add(backButton); - } - if (tipImg == nullptr) { - tipImg = new UIImageView(); - if (tipImg == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TipsFailMessageView tipImg new fail"); - return OHOS_FAILURE; - } - tipImg->SetPosition(181, 111, 90, 90); // 181:x 111:y 90:width 90:height - tipImg->SetSrc(PNG_GANTAN); - group->Add(tipImg); - } - return OHOS_SUCCESS; -} - -UIViewGroup *TipsFailMessageView::ShowUpViewInit(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TipsFailMessageView::ShowUpViewInit"); - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - if (titleLabel == nullptr) { - titleLabel = new UILabel(); - if (titleLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TipsFailMessageView titleLabel new fail"); - return nullptr; - } - titleLabel->SetPosition(0, 234, HORIZONTAL_RESOLUTION, 45); // 0:x 234:y 454:width 45:height - titleLabel->SetText("未发现蓝牙耳机"); - titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40:font data - titleLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - titleLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - group->Add(titleLabel); - } - ShowUpButtonBack(); - UIView::OnDragListener *tipsDragListener = (UIView::OnDragListener *)OHOS::PlayerOnDragListener::GetInstance(); - UIView::OnDragListener *tipsDragListener2 = (UIView::OnDragListener *)OHOS::BluetoothPresenter::GetInstance(); - if ((tipsDragListener == nullptr) && (tipsDragListener2 == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "tipsDragListener GetInstance fail"); - return nullptr; - } - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - group->SetOnDragListener(tipsDragListener); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - group->SetOnDragListener(tipsDragListener2); - } - group->SetViewId(TIPS_FAIL_MESSAGE_VIEW); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/TipsSuccMessageView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/TipsSuccMessageView.cpp deleted file mode 100644 index 99b0a7f73..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/bluetooth/src/TipsSuccMessageView.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: TipsSuccMessageView view - * Author: - * Create: 2021-10-13 - */ -#include "bluetooth/TipsSuccMessageView.h" -#include "bluetooth/BluetoothModel.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "player/PlayersPresenter.h" -#include "bluetooth/BluetoothPresenter.h" - -namespace OHOS { -static TipsSuccMessageView *g_pSuccMessageView{nullptr}; -TipsSuccMessageView::TipsSuccMessageView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TipsSuccMessageView::TipsSuccMessageView"); - g_pSuccMessageView = this; -} - -TipsSuccMessageView::~TipsSuccMessageView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TipsSuccMessageView::~TipsSuccMessageView"); - group->RemoveAll(); - delete titleLabel; - titleLabel = nullptr; - delete backButton; - backButton = nullptr; - delete group; - group = nullptr; - delete tipImg; - tipImg = nullptr; - g_pSuccMessageView = nullptr; -} - -TipsSuccMessageView *TipsSuccMessageView::GetInstance() -{ - return g_pSuccMessageView; -} - -void TipsSuccMessageView::InitNameLabel(void) -{ - if (bluetoothNameLabel == nullptr) { - bluetoothNameLabel = new UILabel(); - if (bluetoothNameLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothNameLabel new fail"); - return; - } - bluetoothNameLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); - bluetoothNameLabel->SetPosition(60, 180, 333, 45); // 60:x 180:y 333:width 45:height - bluetoothNameLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_THIRTY_SIZE); - bluetoothNameLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - bluetoothNameLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - group->Add(bluetoothNameLabel); - } -} - -void TipsSuccMessageView::ShowUpButtonBack() -{ - if (backButton == nullptr) { - backButton = new UILabelButton(); - if (backButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TipsSuccMessageView backButton new fail"); - return; - } - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::PlayersPresenter::GetInstance(); - UIView::OnClickListener *clickListener2 = (UIView::OnClickListener *)OHOS::BluetoothPresenter::GetInstance(); - if ((clickListener == nullptr) && (clickListener2 == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance fail"); - return; - } - backButton->SetPosition(65, 359, 324, 101); // 65:x, 359:y, 324:width 101:height - backButton->SetText("确定"); - backButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40:font data - backButton->SetImageSrc(PNG_NEW_DEVICE, PNG_NEW_DEVICE); - backButton->SetViewId(BLUETOOTH_SUCC_BACK_BUTTON); - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - backButton->SetTextColor(Color::Red()); - backButton->SetOnClickListener(clickListener); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - backButton->SetTextColor(Color::Blue()); - backButton->SetOnClickListener(clickListener2); - } - group->Add(backButton); - } - if (tipImg == nullptr) { - tipImg = new UIImageView(); - if (tipImg == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TipsSuccMessageView tipImg new fail"); - return; - } - tipImg->SetPosition(181, 78, 90, 90); // 181:x 78:y 90:width 90:height - tipImg->SetSrc(PNG_RIGHT); - group->Add(tipImg); - } - return; -} - -UIViewGroup *TipsSuccMessageView::ShowUpViewInit(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TipsSuccMessageView::ShowUpViewInit"); - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - if (titleLabel == nullptr) { - titleLabel = new UILabel(); - if (titleLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TipsSuccMessageView titleLabel new fail"); - return nullptr; - } - titleLabel->SetPosition(0, 244, HORIZONTAL_RESOLUTION, 45); // 0:x 244:y 454:width 45:height - titleLabel->SetText("连接成功"); - titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40:font data - titleLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - titleLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - group->Add(titleLabel); - } - InitNameLabel(); - ShowUpButtonBack(); - UIView::OnDragListener *tipsDragListener = (UIView::OnDragListener *)OHOS::PlayerOnDragListener::GetInstance(); - UIView::OnDragListener *tipsDragListener2 = (UIView::OnDragListener *)OHOS::BluetoothPresenter::GetInstance(); - if ((tipsDragListener == nullptr) && (tipsDragListener2 == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "tipsDragListener GetInstance fail"); - return nullptr; - } - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - group->SetOnDragListener(tipsDragListener); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - group->SetOnDragListener(tipsDragListener2); - } - group->SetViewId(TIPS_SUCC_MESSAGE_VIEW); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} - -void TipsSuccMessageView::RefreshNameLabel(const bd_addr_t &bdAddr) -{ - BluetoothCaseInfo caseInfo; - (void)memcpy_s(caseInfo.addr, BD_ADDR_LEN, bdAddr.addr, BD_ADDR_LEN); - bool ret = BluetoothModel::GetInstance()->FindNameFromList(&caseInfo); - if (!ret) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TipsSuccMessageView FindNameFromList fail"); - return; - } - if (bluetoothNameLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TipsSuccMessageView::RefreshNameLabel bluetoothNameLabel == nullptr"); - return; - } - bluetoothNameLabel->SetText(reinterpret_cast(caseInfo.deviceName)); -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathDurPage.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathDurPage.cpp deleted file mode 100644 index fd888e58a..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathDurPage.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: BreathDurPage - * Create: 2025-5-13 - */ -#include "components/root_view.h" -#include "gfx_utils/graphic_math.h" -#include "UiConfig.h" -#include "AppViewIDs.h" -#include "wearable_log.h" -#include "NativeAbility.h" -#include "alarm/MainAlarmView.h" -#include "TransitionType.h" -#include "SlicePageFactory.h" -#include "ui_resource_breath.h" -#include "main/LoadImg.h" -#include "breath/BreathView.h" -#include "breath/BreathDurPage.h" - -namespace OHOS { -REGIST_SLICE_PAGE(VIEW_MAIN_BREATHEASE, BrearhView::BREATH_DUR_VIEW, BreathDurPage, false); - -#define WND_BTHDUR_BTN_OK_ID "BTH_DUR_OK" -#define WND_BTHDUR_TITLE_X 100 -#define WND_BTHDUR_TITLE_Y 38 -#define WND_BTHDUR_TITLE_W 253 -#define WND_BTHDUR_TITLE_H 53 -#define WND_BTHDUR_TITLE_FONT_SIZE 38 -#define WND_BTHDUR_PICKER_X 64 -#define WND_BTHDUR_PICKER_Y 109 -#define WND_BTHDUR_PICKER_W 321 -#define WND_BTHDUR_PICKER_H 218 -#define WND_BTHDUR_PICKER_B_FONT_SIZE 44 -#define WND_BTHDUR_PICKER_H_FONT_SIZE 44 -#define WND_BTHDUR_PICKER_ITEM_H 80 -#define WND_BTHDUR_OK_X 61 -#define WND_BTHDUR_OK_Y 362 -#define WND_BTHDUR_OK_W 331 -#define WND_BTHDUR_OK_H 98 -#define BREATH_GROUP_SIZE 466 - -BreathDurPage::BreathDurPage() {} - -BreathDurPage::~BreathDurPage() -{ - group->RemoveAll(); - if (lableTitle != nullptr) { - delete lableTitle; - lableTitle = nullptr; - } - if (pickerTime != nullptr) { - delete pickerTime; - pickerTime = nullptr; - } - if (buttonOk != nullptr) { - delete buttonOk; - buttonOk = nullptr; - } - if (group != nullptr) { - delete group; - group = nullptr; - } - if (center != nullptr) { - delete center; - center = nullptr; - } -} - -void BreathDurPage::OnStart(void *data) -{ - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathDurPage::OnStart new Group ERROR"); - group = new UIViewGroup(); - } - group->SetPosition(0, 0); - group->Resize(BREATH_GROUP_SIZE, BREATH_GROUP_SIZE); - group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - - if (lableTitle == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathDurPage::OnStart new lableTitle ERROR"); - lableTitle = new UILabel(); - } - lableTitle->SetPosition(WND_BTHDUR_TITLE_X, WND_BTHDUR_TITLE_Y); - lableTitle->Resize(WND_BTHDUR_TITLE_W, WND_BTHDUR_TITLE_H); - lableTitle->SetText("时间设置"); - lableTitle->SetTextColor(Color::White()); - lableTitle->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WND_BTHDUR_TITLE_FONT_SIZE); - lableTitle->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - group->Add(lableTitle); - - if (pickerTime == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathDurPage::OnStart new pickerTime ERROR"); - pickerTime = new UIPicker(); - } - pickerTime->SetPosition(WND_BTHDUR_PICKER_X, WND_BTHDUR_PICKER_Y); - pickerTime->Resize(WND_BTHDUR_PICKER_W, WND_BTHDUR_PICKER_H); - pickerTime->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - pickerTime->SetBackgroundFont(DEFAULT_VECTOR_FONT_FILENAME, WND_BTHDUR_PICKER_B_FONT_SIZE); - pickerTime->SetHighlightFont(DEFAULT_VECTOR_FONT_FILENAME, WND_BTHDUR_PICKER_H_FONT_SIZE); - pickerTime->SetItemHeight(WND_BTHDUR_PICKER_ITEM_H); - pickerTime->SetTextColor(Color::GetColorFromRGBA(0xfa, 0xf3, 0xf3, 0xff), - Color::GetColorFromRGBA(0xfa, 0xf3, 0xf3, 0xff)); - uint8_t selectTime = BreathModel::GetInstance().GetSelectTime(); - pickerTime->SetSelected(selectTime); - pickerTime->SetOnDragListener(this); - pickerTime->SetLoopState(false); - group->Add(pickerTime); - - if (center == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathDurPage::OnStart new center ERROR"); - center = new UIImageView(); - } - center->SetPosition(WND_BTHDUR_PICKER_X, WND_BTHDUR_PICKER_Y); - center->Resize(WND_BTHDUR_PICKER_W, WND_BTHDUR_PICKER_H); - LOADIMG::LoadImageViewImg(center, BREATH_IMAGE, IMAGE_CONVERTER_TOOL_BREATH013); - group->Add(center); - - if (buttonOk == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathDurPage::OnStart new buttonOk ERROR"); - buttonOk = new UIButton(); - } - buttonOk->SetPosition(WND_BTHDUR_OK_X, WND_BTHDUR_OK_Y); - buttonOk->Resize(WND_BTHDUR_OK_W, WND_BTHDUR_OK_H); - buttonOk->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - buttonOk->SetViewId(WND_BTHDUR_BTN_OK_ID); - LOADIMG::LoadBtnImage(buttonOk, BREATH_IMAGE, IMAGE_CONVERTER_TOOL_BREATH005, IMAGE_CONVERTER_TOOL_BREATH005); - buttonOk->SetStyleForState(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT, UIButton::PRESSED); - buttonOk->SetOnClickListener(this); - group->Add(buttonOk); - - AddViewToPageContainer(group); -} - -void BreathDurPage::OnStop() {} - -void BreathDurPage::OnResume() -{ - pickerTime->SetValues(BreathModel::GetInstance().GetDurListData(), BreathModel::GetInstance().GetDurListSize()); - GetSlicePageContainer()->SetIntercept(true); - GetSlicePageContainer()->SetOnDragListener(nullptr); -} - -void BreathDurPage::OnPause() {} - -bool BreathDurPage::OnClick(UIView &view, const ClickEvent &event) -{ - if (strcmp(view.GetViewId(), WND_BTHDUR_BTN_OK_ID) == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BreathDurPage OnClick...ChangeTo DUR"); - BreathModel::GetInstance().SetTimeDuration(pickerTime->GetSelected()); - NativeAbility::GetInstance().SwitchPageInSlice(BREATH_MAIN_VIEW, nullptr, TransitionType::TRANSITION_INVALID, - true); - } else { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathDurPage OnClick...ChangeTo unknow"); - return false; - } - return true; -} - -bool BreathDurPage::OnDrag(UIView &view, const DragEvent &event) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BreathDurPage::OnDrag"); - UNUSED(view); - if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && (event.GetDeltaX() > X_DRAG_OFFSET) && - (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BreathDurPage::OnDrag ChangeSlice(VIEW_APPLIST)"); - NativeAbility::GetInstance().SwitchPageInSlice(BREATH_MAIN_VIEW, nullptr, TransitionType::TRANSITION_INVALID, - true); - } - return true; -} -} // namespace OHOS \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathExerPage.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathExerPage.cpp deleted file mode 100644 index 92c689bb3..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathExerPage.cpp +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: BreathExerPage - * Create: 2025-5-13 - */ -#include -#include -#include "gfx_utils/graphic_math.h" -#include "common/image_cache_manager.h" -#include "components/ui_image_animator.h" -#include "components/root_view.h" -#include "UiConfig.h" -#include "ohos_timer.h" -#include "AppViewIDs.h" -#include "wearable_log.h" -#include "NativeAbility.h" -#include "SlicePageFactory.h" -#include "PageTransitionMgr.h" -#include "ui_resource_breath.h" -#include "main/LoadImg.h" -#include "breath/BreathView.h" -#include "breath/BreathExerPage.h" - -namespace OHOS { -REGIST_SLICE_PAGE(VIEW_MAIN_BREATHEASE, BrearhView::BREATH_EXER_VIEW, BreathExerPage, false); - -#define BREATH_GROUP_SIZE 454 -#define BREATH_ZERO 0 -#define BREATH_ONE 1 -#define BREATH_TWO 2 -#define BREATH_THREE 3 -static constexpr uint16_t BREATH_PHONE_IMAGE_POSITION_X = 0; -static constexpr uint16_t BREATH_PHONE_IMAGE_POSITION_y = 0; -static constexpr uint16_t BREATH_PHONE_IMAGE_WIDTH = 400; -static constexpr uint16_t BREATH_PHONE_IMAGE_HEIGHT = 400; -static constexpr uint16_t BREATH_PHONE_IMAGEANIMATOR_POSITION_X = 170; -static constexpr uint16_t BREATH_PHONE_IMAGEANIMATOR_POSITION_Y = 170; -static constexpr uint16_t BREATH_PHONE_IMAGEANIMATOR_WIDTH = 100; -static constexpr uint16_t BREATH_PHONE_IMAGEANIMATOR_HEIGHT = 100; -static constexpr uint16_t IMAGE_SIZE = 454; -static constexpr uint16_t IMAGEANIMATOERVIEW_SIZE = 80; -static constexpr uint16_t FIND_PHONE_IMAGE_X = 1; -static constexpr uint16_t FIND_PHONE_IMAGE_y = 1; -static constexpr uint16_t FIND_PHONE_PIXELBYTE_SIZE = 4; -static constexpr uint16_t FIND_PHONE_PIXELBYTEH = 100; -static constexpr uint16_t END_TIME = 20; - -const int g_imageAnimatorInfo[IMAGEANIMATOERVIEW_SIZE] = { - IMAGE_CONVERTER_TOOL_INOREX_HALE001, IMAGE_CONVERTER_TOOL_INOREX_HALE002, IMAGE_CONVERTER_TOOL_INOREX_HALE003, - IMAGE_CONVERTER_TOOL_INOREX_HALE004, IMAGE_CONVERTER_TOOL_INOREX_HALE005, IMAGE_CONVERTER_TOOL_INOREX_HALE006, - IMAGE_CONVERTER_TOOL_INOREX_HALE007, IMAGE_CONVERTER_TOOL_INOREX_HALE008, IMAGE_CONVERTER_TOOL_INOREX_HALE009, - IMAGE_CONVERTER_TOOL_INOREX_HALE010, IMAGE_CONVERTER_TOOL_INOREX_HALE011, IMAGE_CONVERTER_TOOL_INOREX_HALE012, - IMAGE_CONVERTER_TOOL_INOREX_HALE013, IMAGE_CONVERTER_TOOL_INOREX_HALE014, IMAGE_CONVERTER_TOOL_INOREX_HALE015, - IMAGE_CONVERTER_TOOL_INOREX_HALE016, IMAGE_CONVERTER_TOOL_INOREX_HALE017, IMAGE_CONVERTER_TOOL_INOREX_HALE018, - IMAGE_CONVERTER_TOOL_INOREX_HALE019, IMAGE_CONVERTER_TOOL_INOREX_HALE020, IMAGE_CONVERTER_TOOL_INOREX_HALE021, - IMAGE_CONVERTER_TOOL_INOREX_HALE022, IMAGE_CONVERTER_TOOL_INOREX_HALE023, IMAGE_CONVERTER_TOOL_INOREX_HALE024, - IMAGE_CONVERTER_TOOL_INOREX_HALE025, IMAGE_CONVERTER_TOOL_INOREX_HALE026, IMAGE_CONVERTER_TOOL_INOREX_HALE027, - IMAGE_CONVERTER_TOOL_INOREX_HALE028, IMAGE_CONVERTER_TOOL_INOREX_HALE029, IMAGE_CONVERTER_TOOL_INOREX_HALE030, - IMAGE_CONVERTER_TOOL_INOREX_HALE031, IMAGE_CONVERTER_TOOL_INOREX_HALE032, IMAGE_CONVERTER_TOOL_INOREX_HALE033, - IMAGE_CONVERTER_TOOL_INOREX_HALE034, IMAGE_CONVERTER_TOOL_INOREX_HALE035, IMAGE_CONVERTER_TOOL_INOREX_HALE036, - IMAGE_CONVERTER_TOOL_INOREX_HALE037, IMAGE_CONVERTER_TOOL_INOREX_HALE038, IMAGE_CONVERTER_TOOL_INOREX_HALE039, - IMAGE_CONVERTER_TOOL_INOREX_HALE040, IMAGE_CONVERTER_TOOL_INOREX_HALE041, IMAGE_CONVERTER_TOOL_INOREX_HALE042, - IMAGE_CONVERTER_TOOL_INOREX_HALE043, IMAGE_CONVERTER_TOOL_INOREX_HALE044, IMAGE_CONVERTER_TOOL_INOREX_HALE045, - IMAGE_CONVERTER_TOOL_INOREX_HALE046, IMAGE_CONVERTER_TOOL_INOREX_HALE047, IMAGE_CONVERTER_TOOL_INOREX_HALE048, - IMAGE_CONVERTER_TOOL_INOREX_HALE049, IMAGE_CONVERTER_TOOL_INOREX_HALE050, IMAGE_CONVERTER_TOOL_INOREX_HALE051, - IMAGE_CONVERTER_TOOL_INOREX_HALE052, IMAGE_CONVERTER_TOOL_INOREX_HALE053, IMAGE_CONVERTER_TOOL_INOREX_HALE054, - IMAGE_CONVERTER_TOOL_INOREX_HALE055, IMAGE_CONVERTER_TOOL_INOREX_HALE056, IMAGE_CONVERTER_TOOL_INOREX_HALE057, - IMAGE_CONVERTER_TOOL_INOREX_HALE058, IMAGE_CONVERTER_TOOL_INOREX_HALE059, IMAGE_CONVERTER_TOOL_INOREX_HALE060, - IMAGE_CONVERTER_TOOL_INOREX_HALE061, IMAGE_CONVERTER_TOOL_INOREX_HALE062, IMAGE_CONVERTER_TOOL_INOREX_HALE063, - IMAGE_CONVERTER_TOOL_INOREX_HALE064, IMAGE_CONVERTER_TOOL_INOREX_HALE065, IMAGE_CONVERTER_TOOL_INOREX_HALE066, - IMAGE_CONVERTER_TOOL_INOREX_HALE067, IMAGE_CONVERTER_TOOL_INOREX_HALE068, IMAGE_CONVERTER_TOOL_INOREX_HALE068, - IMAGE_CONVERTER_TOOL_INOREX_HALE069, IMAGE_CONVERTER_TOOL_INOREX_HALE070, IMAGE_CONVERTER_TOOL_INOREX_HALE071, - IMAGE_CONVERTER_TOOL_INOREX_HALE072, IMAGE_CONVERTER_TOOL_INOREX_HALE073, IMAGE_CONVERTER_TOOL_INOREX_HALE074, - IMAGE_CONVERTER_TOOL_INOREX_HALE075, IMAGE_CONVERTER_TOOL_INOREX_HALE076, IMAGE_CONVERTER_TOOL_INOREX_HALE077, - IMAGE_CONVERTER_TOOL_INOREX_HALE078, IMAGE_CONVERTER_TOOL_INOREX_HALE078, -}; - -BreathExerPage::BreathExerPage() {} - -BreathExerPage::~BreathExerPage() -{ - group->RemoveAll(); - if (group != nullptr) { - delete group; - group = nullptr; - } - if (imageAnimator_ != nullptr) { - delete imageAnimator_; - imageAnimator_ = nullptr; - } - if (animatorCallBack != nullptr) { - delete animatorCallBack; - animatorCallBack = nullptr; - } - ImageCacheManager::GetInstance().UnloadAllInMultiRes(BREATH_IMAGE); -} - -void BreathExerPage::OnStart(void *data) -{ - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathExerPage::OnStart new group ERROR"); - group = new UIViewGroup(); - } - group->SetPosition(0, 0); - group->Resize(BREATH_GROUP_SIZE, BREATH_GROUP_SIZE); - group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - group->SetTouchable(true); - group->SetDraggable(true); - group->SetOnDragListener(this); - - palyNumber = BreathModel::GetInstance().GetTheNumberOfPlays(); - SetUpImageAnimator(); - - imageAnimator_->Start(); - imageAnimator_->SetVisible(true); - animatorCallBack = new BreathExerPageCallback(this); - if (animatorCallBack == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathExerPage::OnStart new animatorCallBack ERROR"); - return; - } - animation = new Animator(animatorCallBack, nullptr, 0, true); - if (animation == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathExerPage::OnStart new animation ERROR"); - return; - } - animation->Start(); - - AddViewToPageContainer(group); -} -void BreathExerPage::OnStop() {} - -void BreathExerPage::SetUpImageAnimator() -{ - imageAnimator_ = new UIImageAnimatorView(); - if (imageAnimator_ == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathExerPage::UIImageAnimatorView new Label SetUpImageAnimator fail"); - return; - } - - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BreathExerPage::SetUpImageAnimator "); - imageAnimator_ = new UIImageAnimatorView(); - for (uint32_t DATA = 0; DATA < IMAGEANIMATOERVIEW_SIZE; DATA++) { - searchImageInfo[DATA].imageInfo = - ImageCacheManager::GetInstance().LoadOneInMultiRes(g_imageAnimatorInfo[DATA], BREATH_IMAGE); - searchImageInfo[DATA].imageType = IMG_SRC_IMAGE_INFO; - searchImageInfo[DATA].pos.x = FIND_PHONE_IMAGE_X; - searchImageInfo[DATA].pos.y = FIND_PHONE_IMAGE_y; - searchImageInfo[DATA].width = IMAGE_SIZE; - searchImageInfo[DATA].height = IMAGE_SIZE; - } - imageAnimator_->SetPosition(BREATH_PHONE_IMAGE_POSITION_X, BREATH_PHONE_IMAGE_POSITION_y, BREATH_PHONE_IMAGE_WIDTH, - BREATH_PHONE_IMAGE_HEIGHT); - int imageNumber = IMAGEANIMATOERVIEW_SIZE; - int ImageUpdate = BreathModel::GetInstance().GetStatusRespiratory(); - imageAnimator_->SetImageAnimatorSrc(searchImageInfo, imageNumber, ImageUpdate); - imageAnimator_->LayoutCenterOfParent(); - imageAnimator_->SetDraggable(true); - imageAnimator_->SetRepeat(false); - imageAnimator_->SetRepeatTimes(palyNumber); - imageAnimator_->SetOnDragListener(this); - group->Add(imageAnimator_); - InitImageInfo(); -} - -void BreathExerPage::BreathExerPageCallback::Callback(UIView *view) -{ - UNUSED(view); - static int count = 0; - struct timeval currentTime; - uint32_t breathingTime; - - breathingTime = BreathModel::GetInstance().GetTimeBreathing(); - gettimeofday(¤tTime, nullptr); - int32_t StartTime = BreathModel::GetInstance().GetBeginsTime(); - int32_t remTime = breathingTime - (currentTime.tv_sec - StartTime); - if (remTime <= END_TIME) { - if (BreathExerPage->imageAnimator_->GetState() == false) { - BreathExerPage->animation->Stop(); - BreathExerPage->imageAnimator_->Stop(); - BreathExerPage->imageAnimator_->SetVisible(false); - NativeAbility::GetInstance().SwitchPageInSlice(BREATH_RESULT_VIEW, nullptr, - TransitionType::TRANSITION_INVALID, true); - } - } -} - -void BreathExerPage::OnPause() -{ - animation->Stop(); - imageAnimator_->Stop(); - imageAnimator_->SetVisible(false); -} - -bool BreathExerPage::OnDrag(UIView &view, const DragEvent &event) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BreathExerPage::OnDrag"); - UNUSED(view); - if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && (event.GetDeltaX() > X_DRAG_OFFSET) && - (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BreathExerPage::OnDrag ChangeSlice(VIEW_APPLIST)"); - animation->Stop(); - imageAnimator_->Stop(); - imageAnimator_->SetVisible(false); - NativeAbility::GetInstance().SwitchPageInSlice(BREATH_MAIN_VIEW, nullptr, TransitionType::TRANSITION_INVALID, - true); - } - return true; -} -void BreathExerPage::OnTimer() {} - -void BreathExerPage::InitImageInfo() -{ - const uint16_t pixelByteSize = FIND_PHONE_PIXELBYTE_SIZE; - const uint16_t width = FIND_PHONE_PIXELBYTEH; - const uint16_t height = FIND_PHONE_PIXELBYTEH; - uint32_t dataSize = width * height * pixelByteSize; - uint8_t *srcData1 = static_cast(UIMalloc(dataSize)); - if (srcData1 == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathExerPage::InitImageInfo new srcData1 ERROR"); - return; - } - - for (uint32_t i = 0; i < dataSize; i += pixelByteSize) { - srcData1[i] = SET_INT_MAX_; - srcData1[i + BREATH_ONE] = 0; - srcData1[i + BREATH_TWO] = 0; - srcData1[i + BREATH_THREE] = OPA_OPAQUE; - } - imageInfoOen = static_cast(UIMalloc(sizeof(ImageInfo))); - if (imageInfoOen == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathExerPage::InitImageInfo new imageInfoOen ERROR"); - UIFree(srcData1); - return; - } - - imageInfoOen->header.width = width; - imageInfoOen->header.height = height; - imageInfoOen->header.colorMode = ColorMode::ARGB8888; - imageInfoOen->dataSize = dataSize; - imageInfoOen->data = srcData1; - - uint8_t *srcData2 = static_cast(UIMalloc(dataSize)); - if (srcData2 == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathExerPage::InitImageInfo new srcData2 ERROR"); - UIFree(imageInfoOen); - UIFree(srcData1); - return; - } - for (uint32_t i = 0; i < dataSize; i += pixelByteSize) { - srcData2[i] = 0; - srcData2[i + BREATH_ONE] = SET_INT_MAX_; - srcData2[i + BREATH_TWO] = 0; - srcData2[i + BREATH_THREE] = OPA_OPAQUE; - } - - imageInfoTwo = static_cast(UIMalloc(sizeof(ImageInfo))); - if (imageInfoTwo == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathExerPage::InitImageInfo new imageInfoTwo ERROR"); - UIFree(srcData2); - UIFree(imageInfoOen); - UIFree(srcData1); - return; - } - imageInfoTwo->header.width = width; - imageInfoTwo->header.height = height; - imageInfoTwo->header.colorMode = ARGB8888; - imageInfoTwo->dataSize = dataSize; - imageInfoTwo->data = srcData2; - - uint8_t *srcData3 = static_cast(UIMalloc(dataSize)); - if (srcData3 == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathExerPage::InitImageInfo new srcData3 ERROR"); - UIFree(imageInfoTwo); - UIFree(srcData2); - UIFree(imageInfoOen); - UIFree(srcData1); - return; - } - for (uint32_t i = 0; i < dataSize; i += pixelByteSize) { - srcData3[i] = 0; - srcData3[i + BREATH_ONE] = 0; - srcData3[i + BREATH_TWO] = SET_INT_MAX_; - srcData3[i + BREATH_THREE] = OPA_OPAQUE; - } - - imageInfoThree = static_cast(UIMalloc(sizeof(ImageInfo))); - if (imageInfoThree == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathExerPage::InitImageInfo new imageInfoThree ERROR"); - UIFree(srcData3); - UIFree(imageInfoTwo); - UIFree(srcData2); - UIFree(imageInfoOen); - UIFree(srcData1); - return; - } - imageInfoThree->header.width = width; - imageInfoThree->header.height = height; - imageInfoThree->header.colorMode = ARGB8888; - imageInfoThree->dataSize = dataSize; - imageInfoThree->data = srcData3; - - imageAnimatorImageInfo[BREATH_ZERO].imageInfo = imageInfoOen; - imageAnimatorImageInfo[BREATH_ZERO].pos = {BREATH_PHONE_IMAGEANIMATOR_POSITION_X, - BREATH_PHONE_IMAGEANIMATOR_POSITION_Y}; - imageAnimatorImageInfo[BREATH_ZERO].width = BREATH_PHONE_IMAGEANIMATOR_WIDTH; - imageAnimatorImageInfo[BREATH_ZERO].height = BREATH_PHONE_IMAGEANIMATOR_HEIGHT; - imageAnimatorImageInfo[BREATH_ZERO].imageType = IMG_SRC_IMAGE_INFO; - - imageAnimatorImageInfo[BREATH_ONE].imageInfo = imageInfoTwo; - imageAnimatorImageInfo[BREATH_ONE].pos = {BREATH_PHONE_IMAGEANIMATOR_POSITION_X, - BREATH_PHONE_IMAGEANIMATOR_POSITION_Y}; - imageAnimatorImageInfo[BREATH_ONE].width = BREATH_PHONE_IMAGEANIMATOR_WIDTH; - imageAnimatorImageInfo[BREATH_ONE].height = BREATH_PHONE_IMAGEANIMATOR_HEIGHT; - imageAnimatorImageInfo[BREATH_ONE].imageType = IMG_SRC_IMAGE_INFO; - - imageAnimatorImageInfo[BREATH_TWO].imageInfo = imageInfoThree; - imageAnimatorImageInfo[BREATH_TWO].pos = {BREATH_PHONE_IMAGEANIMATOR_POSITION_X, - BREATH_PHONE_IMAGEANIMATOR_POSITION_Y}; - imageAnimatorImageInfo[BREATH_TWO].width = BREATH_PHONE_IMAGEANIMATOR_WIDTH; - imageAnimatorImageInfo[BREATH_TWO].height = BREATH_PHONE_IMAGEANIMATOR_HEIGHT; - imageAnimatorImageInfo[BREATH_TWO].imageType = IMG_SRC_IMAGE_INFO; -} -} // namespace OHOS \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathMainPage.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathMainPage.cpp deleted file mode 100644 index 3b12ef70f..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathMainPage.cpp +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: BreathMainPage - * Create: 2025-5-13 - */ -#include "gfx_utils/graphic_math.h" -#include "UiConfig.h" -#include "AppViewIDs.h" -#include "AppViewIDs.h" -#include "wearable_log.h" -#include "alarm/MainAlarmView.h" -#include "NativeAbility.h" -#include "TransitionType.h" -#include "SlicePageFactory.h" -#include "PageTransitionMgr.h" -#include "ui_resource_breath.h" -#include "main/LoadImg.h" -#include "breath/BreathModel.h" -#include "breath/BreathMainPage.h" - -namespace OHOS { - -#define WND_BTHMAIN_BTN_DUR_ID "BTH_MAIN_DUR" -#define WND_BTHMAIN_BTN_RHY_ID "BTH_MAIN_RHY" -#define WND_BTHMAIN_BTN_START_ID "BTH_MAIN_START" -#define WND_BTHMAIN_TITLE_X 97 -#define WND_BTHMAIN_TITLE_Y 34 -#define WND_BTHMAIN_TITLE_W 260 -#define WND_BTHMAIN_TITLE_H 53 -#define WND_BTHMAIN_TITLE_FONT_SIZE 38 -#define WND_BTHMAIN_DURBTN_X 16 -#define WND_BTHMAIN_DURBTN_Y 190 -#define WND_BTHMAIN_DURBTN_W 74 -#define WND_BTHMAIN_DURBTN_H 74 -#define WND_BTHMAIN_RHYBTN_X 364 -#define WND_BTHMAIN_RHYBTN_Y 190 -#define WND_BTHMAIN_RHYBTN_W 74 -#define WND_BTHMAIN_RHYBTN_H 74 -#define WND_BTHMAIN_STARTBTN_X 60 -#define WND_BTHMAIN_STARTBTN_Y 358 -#define WND_BTHMAIN_STARTBTN_W 333 -#define WND_BTHMAIN_STARTBTN_H 96 -#define WND_BTHMAIN_DURLAB_X 20 -#define WND_BTHMAIN_DURLAB_Y 275 -#define WND_BTHMAIN_DURLAB_W 65 -#define WND_BTHMAIN_DURLAB_H 30 -#define WND_BTHMAIN_RHYLAB_X 376 -#define WND_BTHMAIN_RHYLAB_Y 275 -#define WND_BTHMAIN_RHYLAB_W 50 -#define WND_BTHMAIN_RHYLAB_H 30 -#define WND_BTHMAIN_CENTER_XY 127 -#define WND_BTHMAIN_CENTER_WH 200 -#define WND_BTHMAIN_lableSetting_FONT_SIZE 24 -#define WND_BTHMAIN_lableTime_FONT_SIZE 20 -#define BREATH_GROUP_SIZE 466 - -REGIST_SLICE_PAGE(VIEW_MAIN_BREATHEASE, BrearhView::BREATH_MAIN_VIEW, BreathMainPage, true); - -BreathMainPage::~BreathMainPage() -{ - group->RemoveAll(); - if (lableSetting != nullptr) { - delete lableSetting; - lableSetting = nullptr; - } - if (buttonStart != nullptr) { - delete buttonStart; - buttonStart = nullptr; - } - if (buttonSetting != nullptr) { - delete buttonSetting; - buttonSetting = nullptr; - } - if (buttonTime != nullptr) { - delete buttonTime; - buttonTime = nullptr; - } - if (lableBreathing != nullptr) { - delete lableBreathing; - lableBreathing = nullptr; - } - if (lableTime != nullptr) { - delete lableTime; - lableTime = nullptr; - } - if (group != nullptr) { - delete group; - group = nullptr; - } - if (background != nullptr) { - delete background; - background = nullptr; - } - if (center != nullptr) { - delete center; - center = nullptr; - } -} - -void BreathMainPage::OnStart(void *data) -{ - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathMainPage::OnStart new group ERROR"); - group = new UIViewGroup(); - } - group->SetPosition(0, 0); - group->Resize(BREATH_GROUP_SIZE, BREATH_GROUP_SIZE); - group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - group->SetTouchable(true); - group->SetDraggable(true); - group->SetOnDragListener(this); - - if (background == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathMainPage::OnStart new Background ERROR"); - background = new UIImageView(); - } - background->SetPosition(0, 0); - background->Resize(BREATH_GROUP_SIZE, BREATH_GROUP_SIZE); - LOADIMG::LoadImageViewImg(background, BREATH_IMAGE, IMAGE_CONVERTER_TOOL_BREATH001); - group->Add(background); - - if (center == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathMainPage::OnStart new Center ERROR"); - center = new UIImageView(); - } - center->SetPosition(WND_BTHMAIN_CENTER_XY, WND_BTHMAIN_CENTER_XY); - center->Resize(WND_BTHMAIN_CENTER_WH, WND_BTHMAIN_CENTER_WH); - LOADIMG::LoadImageViewImg(center, BREATH_IMAGE, IMAGE_CONVERTER_TOOL_BREATH012); - group->Add(center); - - if (lableBreathing == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathMainPage::OnStart new lableBreathing ERROR"); - lableBreathing = new UILabel(); - } - lableBreathing->SetPosition(WND_BTHMAIN_TITLE_X, WND_BTHMAIN_TITLE_Y); - lableBreathing->Resize(WND_BTHMAIN_TITLE_W, WND_BTHMAIN_TITLE_H); - lableBreathing->SetText("呼吸"); - lableBreathing->SetTextColor(Color::White()); - lableBreathing->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - lableBreathing->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WND_BTHMAIN_TITLE_FONT_SIZE); - group->Add(lableBreathing); - - if (buttonTime == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathMainPage::OnStart new buttonTime ERROR"); - buttonTime = new UIButton(); - } - buttonTime->SetPosition(WND_BTHMAIN_DURBTN_X, WND_BTHMAIN_DURBTN_Y); - buttonTime->Resize(WND_BTHMAIN_DURBTN_W, WND_BTHMAIN_DURBTN_H); - buttonTime->SetViewId(WND_BTHMAIN_BTN_DUR_ID); - buttonTime->SetOnClickListener(this); - LOADIMG::LoadBtnImage(buttonTime, BREATH_IMAGE, IMAGE_CONVERTER_TOOL_BREATH002, IMAGE_CONVERTER_TOOL_BREATH002); - buttonTime->SetStyleForState(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT, UIButton::PRESSED); - buttonTime->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - group->Add(buttonTime); - - if (buttonSetting == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathMainPage::OnStart new buttonSetting ERROR"); - buttonSetting = new UIButton(); - } - buttonSetting->SetPosition(WND_BTHMAIN_RHYBTN_X, WND_BTHMAIN_RHYBTN_Y); - buttonSetting->Resize(WND_BTHMAIN_RHYBTN_W, WND_BTHMAIN_RHYBTN_H); - buttonSetting->SetViewId(WND_BTHMAIN_BTN_RHY_ID); - buttonSetting->SetOnClickListener(this); - LOADIMG::LoadBtnImage(buttonSetting, BREATH_IMAGE, IMAGE_CONVERTER_TOOL_BREATH004, IMAGE_CONVERTER_TOOL_BREATH004); - buttonSetting->SetStyleForState(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT, UIButton::PRESSED); - buttonSetting->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - group->Add(buttonSetting); - - if (buttonStart == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathMainPage::OnStart new buttonStart ERROR"); - buttonStart = new UIButton(); - } - buttonStart->SetPosition(WND_BTHMAIN_STARTBTN_X, WND_BTHMAIN_STARTBTN_Y); - buttonStart->Resize(WND_BTHMAIN_STARTBTN_W, WND_BTHMAIN_STARTBTN_H); - buttonStart->SetViewId(WND_BTHMAIN_BTN_START_ID); - buttonStart->SetOnClickListener(this); - LOADIMG::LoadBtnImage(buttonStart, BREATH_IMAGE, IMAGE_CONVERTER_TOOL_BREATH006, IMAGE_CONVERTER_TOOL_BREATH006); - buttonStart->SetStyleForState(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT, UIButton::PRESSED); - buttonStart->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - group->Add(buttonStart); - - if (lableSetting == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathMainPage::OnStart new lableSetting ERROR"); - lableSetting = new UILabel(); - } - lableSetting->SetPosition(WND_BTHMAIN_RHYLAB_X, WND_BTHMAIN_RHYLAB_Y); - lableSetting->Resize(WND_BTHMAIN_RHYLAB_W, WND_BTHMAIN_RHYLAB_H); - lableSetting->SetText("设置"); - lableSetting->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); - lableSetting->SetTextColor(Color::White()); - lableSetting->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - lableSetting->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WND_BTHMAIN_lableSetting_FONT_SIZE); - group->Add(lableSetting); - - if (lableTime == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathMainPage::OnStart new lableTime ERROR"); - lableTime = new UILabel(); - } - lableTime->SetPosition(WND_BTHMAIN_DURLAB_X, WND_BTHMAIN_DURLAB_Y); - lableTime->Resize(WND_BTHMAIN_DURLAB_W, WND_BTHMAIN_DURLAB_H); - lableTime->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); - lableTime->SetTextColor(Color::White()); - lableTime->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - lableTime->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WND_BTHMAIN_lableTime_FONT_SIZE); - group->Add(lableTime); - - AddViewToPageContainer(group); -} - -void BreathMainPage::OnStop(void) {} - -void BreathMainPage::OnResume(void) -{ - lableTime->SetText(BreathModel::GetInstance().GetTimeDuration()); -} - -bool BreathMainPage::OnClick(UIView &view, const ClickEvent &event) -{ - if (strcmp(view.GetViewId(), WND_BTHMAIN_BTN_DUR_ID) == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BreathMainPage OnClick...ChangeTo DUR"); - NativeAbility::GetInstance().SwitchPageInSlice(BREATH_DUR_VIEW, nullptr, TransitionType::TRANSITION_INVALID, - true); - } else if (strcmp(view.GetViewId(), WND_BTHMAIN_BTN_RHY_ID) == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BreathMainPage OnClick...ChangeTo RHY"); - NativeAbility::GetInstance().SwitchPageInSlice(BREATH_RHY_VIEW, nullptr, TransitionType::TRANSITION_INVALID, - true); - } else if (strcmp(view.GetViewId(), WND_BTHMAIN_BTN_START_ID) == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BreathMainPage OnClick...ChangeTo START"); - NativeAbility::GetInstance().SwitchPageInSlice(BREATH_START_VIEW, nullptr, TransitionType::TRANSITION_INVALID, - true); - struct timeval current_time; - gettimeofday(¤t_time, nullptr); - uint32_t remTime = current_time.tv_sec; - BreathModel::GetInstance().SetSaveTime(remTime); - } else { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathMainPage OnClick...ChangeTo unknow"); - return false; - } - return true; -} - -bool BreathMainPage::OnDrag(UIView &view, const DragEvent &event) -{ - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathMainPage::OnDrag"); - UNUSED(view); - if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && (event.GetDeltaX() > X_DRAG_OFFSET) && - (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BreathMainPage::OnDrag ChangeSlice(VIEW_APPLIST)"); - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); - } - return true; -} -} // namespace OHOS \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathModel.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathModel.cpp deleted file mode 100644 index ef067f2c9..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathModel.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: BreathModel - * Create: 2025-5-13 - */ -#include "uiservice/ui_service.h" -#include "main/HealthModel.h" -#include "breath/BreathDurPage.h" -#include "breath/BreathModel.h" - -namespace OHOS { -#define MINUTE_IDX_1 0 -#define MINUTE_IDX_2 1 -#define MINUTE_IDX_3 2 -#define SPEED_IDX_1 0 -#define SPEED_IDX_2 1 -#define SPEED_IDX_3 2 -#define MINUTE_1 "1 分钟" -#define MINUTE_2 "2 分钟" -#define MINUTE_3 "3 分钟" -#define SPEED_FAST_8 "稍快 8次/分" -#define SPEED_SLOW_7 "舒缓 7次/分" -#define SPEED_SLOW_6 "缓慢 6次/分" -#define TIME_1 "1" -#define TIME_2 "2" -#define TIME_3 "3" -#define SPEED_FASTER_LITTLE "稍快" -#define SPEED_SOOTHING "舒缓" -#define SPEED_SLOWING "缓慢" -#define MINUTE_0_DATA 0 -#define MINUTE_1_DATA 1 -#define MINUTE_2_DATA 2 -#define MINUTE_3_DATA 3 -#define NUMBLE_PLAY_8_DATA 8 -#define NUMBLE_PLAY_7_DATA 7 -#define NUMBLE_PLAY_6_DATA 6 -#define NUMBLE_PLAY_16_DATA 16 -#define NUMBLE_PLAY_14_DATA 14 -#define NUMBLE_PLAY_12_DATA 12 -#define NUMBLE_PLAY_24_DATA 24 -#define NUMBLE_PLAY_21_DATA 21 -#define NUMBLE_PLAY_18_DATA 18 -#define Frequency_Score_LOWER 60 -#define Frequency_Score_RANGE 40 -#define Heart_Rate_LOWER 90 -#define Heart_Rate_RANGE 10 -#define ONE_MINUTE 60 -#define TWO_MINUTES 120 -#define THREE_MINUTES 180 -#define SIX_POINTS_FOR_ONE 125 -#define SEVEN_POINTS_FOR_ONE 106 -#define EIGHT_POINTS_FOR_ONE 98 -uint8_t g_frequencyScore; -uint8_t g_heartRate; - -BreathModel::BreathModel() -{ - DefaultData(); -} - -BreathModel::~BreathModel() {} - -void BreathModel::DefaultData() -{ - durList[MINUTE_IDX_1] = MINUTE_1; - durList[MINUTE_IDX_2] = MINUTE_2; - durList[MINUTE_IDX_3] = MINUTE_3; - rhyList[SPEED_IDX_1] = SPEED_FAST_8; - rhyList[SPEED_IDX_2] = SPEED_SLOW_7; - rhyList[SPEED_IDX_3] = SPEED_SLOW_6; - durListVal[MINUTE_IDX_1] = MINUTE_1_DATA; - durListVal[MINUTE_IDX_2] = MINUTE_2_DATA; - durListVal[MINUTE_IDX_3] = MINUTE_3_DATA; -} - -BreathModel &BreathModel::GetInstance() -{ - static BreathModel instance; - return instance; -} - -const char **BreathModel::GetDurListData() -{ - return durList; -} - -const char **BreathModel::GetRhyListData() -{ - return rhyList; -} - -uint8_t BreathModel::GetDurListSize() -{ - return sizeof(durList) / sizeof(durList[0]); -} - -uint8_t BreathModel::GetRhyListSize() -{ - return sizeof(rhyList) / sizeof(rhyList[0]); -} - -void BreathModel::SetTimeDuration(uint16_t idx) -{ - data = idx; -} - -void BreathModel::SetTimeRhyation(uint16_t idx) -{ - date = idx; -} - -uint8_t BreathModel::GetSelectTime() -{ - if (data == MINUTE_0_DATA) { - return MINUTE_IDX_1; - } else if (data == MINUTE_1_DATA) { - return MINUTE_IDX_2; - } else if (data == MINUTE_2_DATA) { - return MINUTE_IDX_3; - } - return 0; -} - -uint8_t BreathModel::GetSelectTempo() -{ - if (date == MINUTE_0_DATA) { - return SPEED_IDX_1; - } else if (date == MINUTE_1_DATA) { - return SPEED_IDX_2; - } else if (date == MINUTE_2_DATA) { - return SPEED_IDX_3; - } - return 0; -} - -char *BreathModel::GetTimeDuration() -{ - if (data == MINUTE_0_DATA) { - return MINUTE_1; - } else if (data == MINUTE_1_DATA) { - return MINUTE_2; - } else if (data == MINUTE_2_DATA) { - return MINUTE_3; - } - return nullptr; -} - -char *BreathModel::GetDuration() -{ - if (data == MINUTE_0_DATA) { - return TIME_1; - } else if (data == MINUTE_1_DATA) { - return TIME_2; - } else if (data == MINUTE_2_DATA) { - return TIME_3; - } - return nullptr; -} - -char *BreathModel::GetRhythm() -{ - if (date == MINUTE_0_DATA) { - return SPEED_FASTER_LITTLE; - } else if (date == MINUTE_1_DATA) { - return SPEED_SOOTHING; - } else if (date == MINUTE_2_DATA) { - return SPEED_SLOWING; - } - return nullptr; -} - -void BreathModel::SetSaveTime(int32_t idx) -{ - saveTime = idx; -} - -int32_t BreathModel::GetSaveTime() -{ - return saveTime; -} - -void BreathModel::SetBeginsTime(int32_t idx) -{ - beginsTime = idx; -} - -int32_t BreathModel::GetBeginsTime() -{ - return beginsTime; -} - -uint32_t BreathModel::GetTimeBreathing() -{ - if (data == MINUTE_0_DATA) { - return ONE_MINUTE; - } else if (data == MINUTE_1_DATA) { - return TWO_MINUTES; - } else if (data == MINUTE_2_DATA) { - return THREE_MINUTES; - } - return 0; -} - -uint32_t BreathModel::GetStatusRespiratory() -{ - if (date == MINUTE_0_DATA) { - return EIGHT_POINTS_FOR_ONE; - } else if (date == MINUTE_1_DATA) { - return SEVEN_POINTS_FOR_ONE; - } else if (date == MINUTE_2_DATA) { - return SIX_POINTS_FOR_ONE; - } - return 0; -} - -void BreathModel::SetFrequencyScore() -{ - g_frequencyScore = Frequency_Score_LOWER + rand() % Frequency_Score_RANGE; -} - -uint8_t BreathModel::GetFrequencyScore() -{ - return g_frequencyScore; -} - -void BreathModel::SetHeartRate() -{ - g_heartRate = Heart_Rate_LOWER + rand() % Heart_Rate_RANGE; -} - -uint8_t BreathModel::GetHeartRate() -{ - return g_heartRate; -} - -uint32_t BreathModel::GetTheNumberOfPlays() -{ - if (date == MINUTE_0_DATA && data == MINUTE_0_DATA) { - return NUMBLE_PLAY_8_DATA; - } else if (date == MINUTE_1_DATA && data == MINUTE_0_DATA) { - return NUMBLE_PLAY_7_DATA; - } else if (date == MINUTE_2_DATA && data == MINUTE_0_DATA) { - return NUMBLE_PLAY_6_DATA; - } else if (date == MINUTE_0_DATA && data == MINUTE_1_DATA) { - return NUMBLE_PLAY_16_DATA; - } else if (date == MINUTE_1_DATA && data == MINUTE_1_DATA) { - return NUMBLE_PLAY_14_DATA; - } else if (date == MINUTE_2_DATA && data == MINUTE_1_DATA) { - return NUMBLE_PLAY_12_DATA; - } else if (date == MINUTE_0_DATA && data == MINUTE_2_DATA) { - return NUMBLE_PLAY_24_DATA; - } else if (date == MINUTE_1_DATA && data == MINUTE_2_DATA) { - return NUMBLE_PLAY_21_DATA; - } else if (date == MINUTE_2_DATA && data == MINUTE_2_DATA) { - return NUMBLE_PLAY_18_DATA; - } - return 0; -} -} // namespace OHOS \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathPresenter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathPresenter.cpp deleted file mode 100644 index 61c31fb7d..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathPresenter.cpp +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: BreathPresenter - * Create: 2025-5-13 - */ -#include "AppViewIDs.h" -#include "NativeRegisterManager.h" -#include "breath/BreathView.h" -#include "breath/BreathPresenter.h" - -namespace OHOS { -REGIST_MENU(VIEW_MAIN_BREATHEASE, BreathView, BreathPresenter, BREATH_MAIN_ICON, BREATH_MAIN_ICON, "呼吸训练"); -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathResultPage.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathResultPage.cpp deleted file mode 100644 index 1f4796678..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathResultPage.cpp +++ /dev/null @@ -1,353 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: BreathReult - * Create: 2025-5-13 - */ -#include -#include "gfx_utils/graphic_math.h" -#include "components/root_view.h" -#include "UiConfig.h" -#include "AppViewIDs.h" -#include "wearable_log.h" -#include "NativeAbility.h" -#include "TransitionType.h" -#include "SlicePageFactory.h" -#include "main/LoadImg.h" -#include "ui_resource_breath.h" -#include "breath/BreathView.h" -#include "breath/BreathResultPage.h" - -namespace OHOS { -REGIST_SLICE_PAGE(VIEW_MAIN_BREATHEASE, BrearhView::BREATH_RESULT_VIEW, BreathResultPage, false); -#define WND_BTHMAIN_RESULTS_X 97 -#define WND_BTHMAIN_RESULTS_Y 34 -#define WND_BTHMAIN_RESULTS_W 260 -#define WND_BTHMAIN_RESULTS_H 53 -#define WND_BTHMAIN_MAX_FONT_SIZE 38 -#define WND_BTHMAIN_FREQUENCIES_X 140 -#define WND_BTHMAIN_FREQUENCIES_Y 133 -#define WND_BTHMAIN_FREQUENCIES_W 164 -#define WND_BTHMAIN_FREQUENCIES_H 30 -#define WND_BTHMAIN_MIN_FONT_SIZE 24 -#define WND_BTHMAIN_HEARTRATE_X 149 -#define WND_BTHMAIN_HEARTRATE_Y 233 -#define WND_BTHMAIN_HEARTRATE_W 120 -#define WND_BTHMAIN_HEARTRATE_H 30 -#define WND_BTHMAIN_FREQUEBCY_TIMES_X 204 -#define WND_BTHMAIN_FREQUEBCY_TIMES_Y 179 -#define WND_BTHMAIN_FREQUEBCY_TIMES_W 29 -#define WND_BTHMAIN_FREQUEBCY_TIMES_H 29 -#define WND_BTHMAIN_HEARTRATE_TIMES_X 204 -#define WND_BTHMAIN_HEARTRATE_TIMES_Y 279 -#define WND_BTHMAIN_HEARTRATE_TIMES_W 58 -#define WND_BTHMAIN_HEARTRATE_TIMES_H 29 -#define WND_BTHMAIN_DURATION_X 149 -#define WND_BTHMAIN_DURATION_Y 333 -#define WND_BTHMAIN_DURATION_W 96 -#define WND_BTHMAIN_DURATION_H 30 -#define WND_BTHMAIN_FREQUENCIES_SCOUT_X 149 -#define WND_BTHMAIN_FREQUENCIES_SCOUT_Y 165 -#define WND_BTHMAIN_FREQUENCIES_SCOUT_W 49 -#define WND_BTHMAIN_FREQUENCIES_SCOUT_H 49 -#define WND_BTHMAIN_SCOUT_FONT_SIZE 40 -#define WND_BTHMAIN_HEARTRATE_SCOUT_X 149 -#define WND_BTHMAIN_HEARTRATE_SCOUT_Y 265 -#define WND_BTHMAIN_HEARTRATE_SCOUT_W 49 -#define WND_BTHMAIN_HEARTRATE_SCOUT_H 49 -#define WND_BTHMAIN_RHYTHM_X 161 -#define WND_BTHMAIN_RHYTHM_Y 83 -#define WND_BTHMAIN_RHYTHM_W 132 -#define WND_BTHMAIN_RHYTHM_H 30 -#define WND_BTHMAIN_TIME_X 149 -#define WND_BTHMAIN_TIME_Y 365 -#define WND_BTHMAIN_TIME_W 25 -#define WND_BTHMAIN_TIME_H 48 -#define WND_BTHMAIN_TIME_UNIT_X 180 -#define WND_BTHMAIN_TIME_UNIT_Y 379 -#define WND_BTHMAIN_TIME_UNIT_W 58 -#define WND_BTHMAIN_TIME_UNIT_H 29 -#define WND_BTHMAIN_SCORES_X 241 -#define WND_BTHMAIN_SCORES_Y 177 -#define WND_BTHMAIN_SCORES_W 72 -#define WND_BTHMAIN_SCORES_H 32 -#define BREATH_GROUP_SIZE 466 -#define BREATH_GUINEAS_SIZE 100 -#define BREATH_NINETY_SIZE 90 -#define BREATH_EIGHTY_NINE_SIZE 89 -#define BREATH_EIGHTY_SIZE 80 -#define BREATH_SEVENTY_NINE_SIZE 79 -#define BREATH_SEVENTY_SIZE 70 -#define BREATH_SIXTY_NINE_SIZE 69 -#define BREATH_SIXTY_SIZE 60 -#define TEXT_OPACITY 147 -#define TEXT_SIZE 5 - -BreathResultPage::BreathResultPage() {} - -BreathResultPage::~BreathResultPage() -{ - group->RemoveAll(); - if (trainingResults != nullptr) { - delete trainingResults; - trainingResults = nullptr; - } - if (trainingFrequencies != nullptr) { - delete trainingFrequencies; - trainingFrequencies = nullptr; - } - if (trainingHeartRate != nullptr) { - delete trainingHeartRate; - trainingHeartRate = nullptr; - } - if (trainingDuration != nullptr) { - delete trainingDuration; - trainingDuration = nullptr; - } - if (frequenciesScout != nullptr) { - delete frequenciesScout; - frequenciesScout = nullptr; - } - if (heartRateScout != nullptr) { - delete heartRateScout; - heartRateScout = nullptr; - } - if (descriptionBreathing != nullptr) { - delete descriptionBreathing; - descriptionBreathing = nullptr; - } - if (time != nullptr) { - delete time; - time = nullptr; - } - if (timeUnit != nullptr) { - delete timeUnit; - timeUnit = nullptr; - } - if (heartRateTimes != nullptr) { - delete heartRateTimes; - heartRateTimes = nullptr; - } - if (frequencyTimes != nullptr) { - delete frequencyTimes; - frequencyTimes = nullptr; - } - if (group != nullptr) { - delete group; - group = nullptr; - } - if (scores != nullptr) { - delete scores; - scores = nullptr; - } -} - -void BreathResultPage::OnStart(void *data) -{ - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathResultPage::OnStart new group ERROR"); - group = new UIViewGroup(); - } - group->SetPosition(0, 0); - group->Resize(BREATH_GROUP_SIZE, BREATH_GROUP_SIZE); - group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - group->SetTouchable(true); - group->SetDraggable(true); - group->SetOnDragListener(this); - - if (trainingResults == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathResultPage::OnStart new trainingResults ERROR"); - trainingResults = new UILabel(); - } - trainingResults->SetPosition(WND_BTHMAIN_RESULTS_X, WND_BTHMAIN_RESULTS_Y); - trainingResults->Resize(WND_BTHMAIN_RESULTS_W, WND_BTHMAIN_RESULTS_H); - trainingResults->SetText("训练结果"); - trainingResults->SetTextColor(Color::White()); - trainingResults->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WND_BTHMAIN_MAX_FONT_SIZE); - trainingResults->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - group->Add(trainingResults); - - if (trainingFrequencies == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathResultPage::OnStart new trainingFrequencies ERROR"); - trainingFrequencies = new UILabel(); - } - trainingFrequencies->SetPosition(WND_BTHMAIN_FREQUENCIES_X, WND_BTHMAIN_FREQUENCIES_Y); - trainingFrequencies->Resize(WND_BTHMAIN_FREQUENCIES_W, WND_BTHMAIN_FREQUENCIES_H); - trainingFrequencies->SetText("呼吸频率得分"); - trainingFrequencies->SetTextColor(Color::White()); - trainingFrequencies->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WND_BTHMAIN_MIN_FONT_SIZE); - trainingFrequencies->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - trainingFrequencies->SetStyle(STYLE_TEXT_OPA, TEXT_OPACITY); - group->Add(trainingFrequencies); - - if (trainingHeartRate == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathResultPage::OnStart new trainingHeartRate ERROR"); - trainingHeartRate = new UILabel(); - } - trainingHeartRate->SetPosition(WND_BTHMAIN_HEARTRATE_X, WND_BTHMAIN_HEARTRATE_Y); - trainingHeartRate->Resize(WND_BTHMAIN_HEARTRATE_W, WND_BTHMAIN_HEARTRATE_H); - trainingHeartRate->SetText("呼吸前心率"); - trainingHeartRate->SetTextColor(Color::White()); - trainingHeartRate->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WND_BTHMAIN_MIN_FONT_SIZE); - trainingHeartRate->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - trainingHeartRate->SetStyle(STYLE_TEXT_OPA, TEXT_OPACITY); - group->Add(trainingHeartRate); - - if (frequencyTimes == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathResultPage::OnStart new frequencyTimes ERROR"); - frequencyTimes = new UILabel(); - } - frequencyTimes->SetPosition(WND_BTHMAIN_FREQUEBCY_TIMES_X, WND_BTHMAIN_FREQUEBCY_TIMES_Y); - frequencyTimes->Resize(WND_BTHMAIN_FREQUEBCY_TIMES_W, WND_BTHMAIN_FREQUEBCY_TIMES_H); - frequencyTimes->SetText("分"); - frequencyTimes->SetTextColor(Color::White()); - frequencyTimes->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WND_BTHMAIN_MIN_FONT_SIZE); - frequencyTimes->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - frequencyTimes->SetStyle(STYLE_TEXT_OPA, TEXT_OPACITY); - group->Add(frequencyTimes); - - if (heartRateTimes == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathResultPage::OnStart new HeartRate_Times ERROR"); - heartRateTimes = new UILabel(); - } - heartRateTimes->SetPosition(WND_BTHMAIN_HEARTRATE_TIMES_X, WND_BTHMAIN_HEARTRATE_TIMES_Y); - heartRateTimes->Resize(WND_BTHMAIN_HEARTRATE_TIMES_W, WND_BTHMAIN_HEARTRATE_TIMES_H); - heartRateTimes->SetText("次/分"); - heartRateTimes->SetTextColor(Color::White()); - heartRateTimes->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WND_BTHMAIN_MIN_FONT_SIZE); - heartRateTimes->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - heartRateTimes->SetStyle(STYLE_TEXT_OPA, TEXT_OPACITY); - group->Add(heartRateTimes); - - if (trainingDuration == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathResultPage::OnStart new trainingDuration ERROR"); - trainingDuration = new UILabel(); - } - trainingDuration->SetPosition(WND_BTHMAIN_DURATION_X, WND_BTHMAIN_DURATION_Y); - trainingDuration->Resize(WND_BTHMAIN_DURATION_W, WND_BTHMAIN_DURATION_H); - trainingDuration->SetText("训练时长"); - trainingDuration->SetTextColor(Color::White()); - trainingDuration->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WND_BTHMAIN_MIN_FONT_SIZE); - trainingDuration->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - trainingDuration->SetStyle(STYLE_TEXT_OPA, TEXT_OPACITY); - group->Add(trainingDuration); - - if (frequenciesScout == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathResultPage::OnStart new Frequencies_scout ERROR"); - frequenciesScout = new UILabel(); - } - frequenciesScout->SetPosition(WND_BTHMAIN_FREQUENCIES_SCOUT_X, WND_BTHMAIN_FREQUENCIES_SCOUT_Y); - frequenciesScout->Resize(WND_BTHMAIN_FREQUENCIES_SCOUT_W, WND_BTHMAIN_FREQUENCIES_SCOUT_H); - frequenciesScout->SetTextColor(Color::White()); - frequenciesScout->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WND_BTHMAIN_SCOUT_FONT_SIZE); - frequenciesScout->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - group->Add(frequenciesScout); - - if (heartRateScout == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathResultPage::OnStart new HeartRate_scout ERROR"); - heartRateScout = new UILabel(); - } - heartRateScout->SetPosition(WND_BTHMAIN_HEARTRATE_SCOUT_X, WND_BTHMAIN_HEARTRATE_SCOUT_Y); - heartRateScout->Resize(WND_BTHMAIN_HEARTRATE_SCOUT_W, WND_BTHMAIN_HEARTRATE_SCOUT_H); - heartRateScout->SetTextColor(Color::White()); - heartRateScout->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WND_BTHMAIN_SCOUT_FONT_SIZE); - heartRateScout->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - group->Add(heartRateScout); - - if (descriptionBreathing == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathResultPage::OnStart new Rhythm ERROR"); - descriptionBreathing = new UILabel(); - } - descriptionBreathing->SetPosition(WND_BTHMAIN_RHYTHM_X, WND_BTHMAIN_RHYTHM_Y); - descriptionBreathing->Resize(WND_BTHMAIN_RHYTHM_W, WND_BTHMAIN_RHYTHM_H); - descriptionBreathing->SetTextColor(Color::Green()); - descriptionBreathing->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WND_BTHMAIN_MIN_FONT_SIZE); - descriptionBreathing->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - group->Add(descriptionBreathing); - - if (time == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathResultPage::OnStart new Time ERROR"); - time = new UILabel(); - } - time->SetPosition(WND_BTHMAIN_TIME_X, WND_BTHMAIN_TIME_Y); - time->Resize(WND_BTHMAIN_TIME_W, WND_BTHMAIN_TIME_H); - time->SetTextColor(Color::White()); - time->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WND_BTHMAIN_SCOUT_FONT_SIZE); - time->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - group->Add(time); - - if (timeUnit == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathResultPage::OnStart new Time_Unit ERROR"); - timeUnit = new UILabel(); - } - timeUnit->SetPosition(WND_BTHMAIN_TIME_UNIT_X, WND_BTHMAIN_TIME_UNIT_Y); - timeUnit->Resize(WND_BTHMAIN_TIME_UNIT_W, WND_BTHMAIN_TIME_UNIT_H); - timeUnit->SetText("分钟"); - timeUnit->SetTextColor(Color::White()); - timeUnit->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WND_BTHMAIN_MIN_FONT_SIZE); - timeUnit->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - timeUnit->SetStyle(STYLE_TEXT_OPA, TEXT_OPACITY); - group->Add(timeUnit); - - if (scores == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathResultPage::OnStart new Scores ERROR"); - scores = new UIImageView(); - } - scores->SetPosition(WND_BTHMAIN_SCORES_X, WND_BTHMAIN_SCORES_Y); - scores->Resize(WND_BTHMAIN_SCORES_W, WND_BTHMAIN_SCORES_H); - group->Add(scores); - - AddViewToPageContainer(group); -} -void BreathResultPage::OnStop() {} -void BreathResultPage::OnResume(void) -{ - std::ostringstream oss; - oss << BreathModel::GetInstance().GetTimeDuration() << " | " << BreathModel::GetInstance().GetRhythm(); - std::string weatherHumidity = oss.str(); - descriptionBreathing->SetText(weatherHumidity.c_str()); - time->SetText(BreathModel::GetInstance().GetDuration()); - - BreathModel::GetInstance().SetFrequencyScore(); - BreathModel::GetInstance().SetHeartRate(); - - frequencyScore = BreathModel::GetInstance().GetFrequencyScore(); - char szFrequencyScore[TEXT_SIZE] = ""; - sprintf_s(szFrequencyScore, sizeof(szFrequencyScore), "%d", frequencyScore); - frequenciesScout->SetText(szFrequencyScore); - - if (frequencyScore >= BREATH_NINETY_SIZE && frequencyScore <= BREATH_GUINEAS_SIZE) { - LOADIMG::LoadImageViewImg(scores, BREATH_IMAGE, IMAGE_CONVERTER_TOOL_BREATH008); - } else if (frequencyScore >= BREATH_EIGHTY_SIZE && frequencyScore <= BREATH_EIGHTY_NINE_SIZE) { - LOADIMG::LoadImageViewImg(scores, BREATH_IMAGE, IMAGE_CONVERTER_TOOL_BREATH007); - } else if (frequencyScore >= BREATH_SEVENTY_SIZE && frequencyScore <= BREATH_SEVENTY_NINE_SIZE) { - LOADIMG::LoadImageViewImg(scores, BREATH_IMAGE, IMAGE_CONVERTER_TOOL_BREATH011); - } else if (frequencyScore >= BREATH_SIXTY_SIZE && frequencyScore <= BREATH_SIXTY_NINE_SIZE) { - LOADIMG::LoadImageViewImg(scores, BREATH_IMAGE, IMAGE_CONVERTER_TOOL_BREATH009); - } else { - LOADIMG::LoadImageViewImg(scores, BREATH_IMAGE, IMAGE_CONVERTER_TOOL_BREATH010); - } - - heartRate = BreathModel::GetInstance().GetHeartRate(); - char szHeartRate[TEXT_SIZE] = ""; - sprintf_s(szHeartRate, sizeof(szHeartRate), "%d", heartRate); - heartRateScout->SetText(szHeartRate); -} - -bool BreathResultPage::OnClick(UIView &view, const ClickEvent &event) -{ - return true; -} - -bool BreathResultPage::OnDrag(UIView &view, const DragEvent &event) -{ - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathResultPage::OnDrag"); - UNUSED(view); - if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && (event.GetDeltaX() > X_DRAG_OFFSET) && - (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BreathResultPage::OnDrag ChangeSlice(VIEW_APPLIST)"); - NativeAbility::GetInstance().SwitchPageInSlice(BREATH_MAIN_VIEW, nullptr, TransitionType::TRANSITION_INVALID, - true); - } - return true; -} -} // namespace OHOS \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathRhyPage.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathRhyPage.cpp deleted file mode 100644 index 1265c9912..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathRhyPage.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: BreathRhyPage - * Create: 2025-5-13 - */ -#include "gfx_utils/graphic_math.h" -#include "UiConfig.h" -#include "AppViewIDs.h" -#include "wearable_log.h" -#include "NativeAbility.h" -#include "alarm/MainAlarmView.h" -#include "SlicePageFactory.h" -#include "ui_resource_breath.h" -#include "main/LoadImg.h" -#include "breath/BreathView.h" -#include "breath/BreathModel.h" -#include "breath/BreathRhyPage.h" - -namespace OHOS { -REGIST_SLICE_PAGE(VIEW_MAIN_BREATHEASE, BrearhView::BREATH_RHY_VIEW, BreathRhyPage, false); -#define WND_BTHRHY_BTN_OK_ID "BTH_RHY_OK" -#define WND_BTHRHY_TITLE_X 100 -#define WND_BTHRHY_TITLE_Y 38 -#define WND_BTHRHY_TITLE_W 253 -#define WND_BTHRHY_TITLE_H 53 -#define WND_BTHRHY_TITLE_FONT_SIZE 38 -#define WND_BTHRHY_PICKER_X 64 -#define WND_BTHRHY_PICKER_Y 109 -#define WND_BTHRHY_PICKER_W 321 -#define WND_BTHRHY_PICKER_H 218 -#define WND_BTHRHY_PICKER_B_FONT_SIZE 44 -#define WND_BTHRHY_PICKER_H_FONT_SIZE 44 -#define WND_BTHRHY_PICKER_ITEM_H 80 -#define WND_BTHRHY_OK_X 61 -#define WND_BTHRHY_OK_Y 362 -#define WND_BTHRHY_OK_W 331 -#define WND_BTHRHY_OK_H 98 -#define BREATH_GROUP_SIZE 466 - -BreathRhyPage::BreathRhyPage() {} - -BreathRhyPage::~BreathRhyPage() -{ - group->RemoveAll(); - if (lableRhythm != nullptr) { - delete lableRhythm; - lableRhythm = nullptr; - } - if (pickerRhythm != nullptr) { - delete pickerRhythm; - pickerRhythm = nullptr; - } - if (buttonOk != nullptr) { - delete buttonOk; - buttonOk = nullptr; - } - if (group != nullptr) { - delete group; - group = nullptr; - } - if (center != nullptr) { - delete center; - center = nullptr; - } -} - -void BreathRhyPage::OnStart(void *data) -{ - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathRhyPage::OnStart new group ERROR"); - group = new UIViewGroup(); - } - group->SetPosition(0, 0); - group->Resize(BREATH_GROUP_SIZE, BREATH_GROUP_SIZE); - group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - group->SetTouchable(false); - group->SetDraggable(false); - - if (lableRhythm == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathRhyPage::OnStart new lableRhythm ERROR"); - lableRhythm = new UILabel(); - } - lableRhythm->SetPosition(WND_BTHRHY_TITLE_X, WND_BTHRHY_TITLE_Y); - lableRhythm->Resize(WND_BTHRHY_TITLE_W, WND_BTHRHY_TITLE_H); - lableRhythm->SetText("节奏设置"); - lableRhythm->SetTextColor(Color::White()); - lableRhythm->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - lableRhythm->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WND_BTHRHY_TITLE_FONT_SIZE); - group->Add(lableRhythm); - - if (pickerRhythm == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathRhyPage::OnStart new pickerRhythm ERROR"); - pickerRhythm = new UIPicker(); - } - pickerRhythm->SetPosition(WND_BTHRHY_PICKER_X, WND_BTHRHY_PICKER_Y); - pickerRhythm->Resize(WND_BTHRHY_PICKER_W, WND_BTHRHY_PICKER_H); - pickerRhythm->SetBackgroundFont(DEFAULT_VECTOR_FONT_FILENAME, WND_BTHRHY_PICKER_B_FONT_SIZE); - pickerRhythm->SetHighlightFont(DEFAULT_VECTOR_FONT_FILENAME, WND_BTHRHY_PICKER_H_FONT_SIZE); - pickerRhythm->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - pickerRhythm->SetItemHeight(WND_BTHRHY_PICKER_ITEM_H); - pickerRhythm->SetTextColor(Color::GetColorFromRGBA(0xfa, 0xf3, 0xf3, 0xff), - Color::GetColorFromRGBA(0xfa, 0xf3, 0xf3, 0xff)); - uint8_t selectTempo = BreathModel::GetInstance().GetSelectTempo(); - pickerRhythm->SetSelected(selectTempo); - pickerRhythm->RegisterSelectedListener(this); - pickerRhythm->SetVisible(true); - pickerRhythm->SetOnDragListener(this); - pickerRhythm->SetLoopState(false); - group->Add(pickerRhythm); - - if (center == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathRhyPage::OnStart new Center ERROR"); - center = new UIImageView(); - } - center->SetPosition(WND_BTHRHY_PICKER_X, WND_BTHRHY_PICKER_Y); - center->Resize(WND_BTHRHY_PICKER_W, WND_BTHRHY_PICKER_H); - LOADIMG::LoadImageViewImg(center, BREATH_IMAGE, IMAGE_CONVERTER_TOOL_BREATH013); - group->Add(center); - - if (buttonOk == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathRhyPage::OnStart new buttonOk ERROR"); - buttonOk = new UIButton(); - } - buttonOk->SetPosition(WND_BTHRHY_OK_X, WND_BTHRHY_OK_Y); - buttonOk->Resize(WND_BTHRHY_OK_W, WND_BTHRHY_OK_H); - buttonOk->SetViewId(WND_BTHRHY_BTN_OK_ID); - buttonOk->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - LOADIMG::LoadBtnImage(buttonOk, BREATH_IMAGE, IMAGE_CONVERTER_TOOL_BREATH005, IMAGE_CONVERTER_TOOL_BREATH005); - buttonOk->SetStyleForState(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT, UIButton::PRESSED); - buttonOk->SetOnClickListener(this); - group->Add(buttonOk); - - AddViewToPageContainer(group); -} -void BreathRhyPage::OnResume() -{ - pickerRhythm->SetValues(BreathModel::GetInstance().GetRhyListData(), BreathModel::GetInstance().GetRhyListSize()); - GetSlicePageContainer()->SetIntercept(true); - GetSlicePageContainer()->SetOnDragListener(nullptr); -} - -void BreathRhyPage::OnPause() {} - -void BreathRhyPage::OnStop() {} - -bool BreathRhyPage::OnClick(UIView &view, const ClickEvent &event) -{ - if (strcmp(view.GetViewId(), WND_BTHRHY_BTN_OK_ID) == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BreathRhyPage OnClick...ChangeTo DUR"); - NativeAbility::GetInstance().SwitchPageInSlice(BREATH_MAIN_VIEW, nullptr, TransitionType::TRANSITION_INVALID, - true); - BreathModel::GetInstance().SetTimeRhyation(pickerRhythm->GetSelected()); - } else { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathRhyPage OnClick...ChangeTo unknow"); - return false; - } - return true; -} - -bool BreathRhyPage::OnDrag(UIView &view, const DragEvent &event) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BreathRhyPage::OnDrag"); - UNUSED(view); - if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && (event.GetDeltaX() > X_DRAG_OFFSET) && - (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BreathRhyPage::OnDrag ChangeSlice(VIEW_APPLIST)"); - NativeAbility::GetInstance().SwitchPageInSlice(BREATH_MAIN_VIEW, nullptr, TransitionType::TRANSITION_INVALID, - true); - } - return true; -} -} // namespace OHOS \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathStartPage.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathStartPage.cpp deleted file mode 100644 index 6545ac442..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/breath/src/BreathStartPage.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: BreathStartPage - * Create: 2025-5-13 - */ -#include -#include -#include -#include "gfx_utils/graphic_math.h" -#include "components/root_view.h" -#include "UiConfig.h" -#include "ohos_timer.h" -#include "AppViewIDs.h" -#include "wearable_log.h" -#include "NativeAbility.h" -#include "TransitionType.h" -#include "SlicePageFactory.h" -#include "PageTransitionMgr.h" -#include "ui_resource_breath.h" -#include "main/LoadImg.h" -#include "breath/BreathView.h" -#include "breath/BreathModel.h" -#include "breath/BreathStartPage.h" - -namespace OHOS { -REGIST_SLICE_PAGE(VIEW_MAIN_BREATHEASE, BrearhView::BREATH_START_VIEW, BreathStartPage, false); - -#define WND_BTHSTART_TITLE_X 97 -#define WND_BTHSTART_TITLE_Y 40 -#define WND_BTHSTART_TITLE_W 260 -#define WND_BTHSTART_TITLE_H 53 -#define WND_BTHSTART_TITLE_FONT_SIZE 36 -#define WND_BTHSTART_CENTERIMG_X 88 -#define WND_BTHSTART_CENTERIMG_Y 88 -#define WND_BTHSTART_CENTERIMG_W 279 -#define WND_BTHSTART_CENTERIMG_H 280 -#define WND_BTHSTART_GUIDE_X 126 -#define WND_BTHSTART_GUIDE_Y 354 -#define WND_BTHSTART_GUIDE_W 202 -#define WND_BTHSTART_GUIDE_H 68 -#define WND_BTHSTART_GUIDE_FONT_SIZE 24 -#define BREATH_GROUP_SIZE 466 -#define TEXT_OPACITY 147 -#define countDown 5 -#define SIZE 64 - -BreathStartPage::BreathStartPage() {} - -BreathStartPage::~BreathStartPage() -{ - group->RemoveAll(); - if (titleLable != nullptr) { - delete titleLable; - titleLable = nullptr; - } - if (guideLable != nullptr) { - delete guideLable; - guideLable = nullptr; - } - if (centerImge != nullptr) { - delete centerImge; - centerImge = nullptr; - } - if (group != nullptr) { - delete group; - group = nullptr; - } - if (background != nullptr) { - delete background; - background = nullptr; - } - if (animation != nullptr) { - delete animation; - animation = nullptr; - } - if (animatorCallBack != nullptr) { - delete animatorCallBack; - animatorCallBack = nullptr; - } -} - -void BreathStartPage::OnStart(void *data) -{ - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathStartPage::OnStart new group ERROR"); - group = new UIViewGroup(); - } - group->SetPosition(0, 0); - group->Resize(BREATH_GROUP_SIZE, BREATH_GROUP_SIZE); - group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - group->SetTouchable(true); - group->SetDraggable(true); - group->SetOnDragListener(this); - - if (background == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathStartPage::OnStart new background ERROR"); - background = new UIImageView(); - } - background->SetPosition(0, 0); - background->Resize(BREATH_GROUP_SIZE, BREATH_GROUP_SIZE); - LOADIMG::LoadImageViewImg(background, BREATH_IMAGE, IMAGE_CONVERTER_TOOL_BREATH001); - group->Add(background); - - if (titleLable == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathStartPage::OnStart new titleLable ERROR"); - titleLable = new UILabel(); - } - titleLable->SetPosition(WND_BTHSTART_TITLE_X, WND_BTHSTART_TITLE_Y); - titleLable->Resize(WND_BTHSTART_TITLE_W, WND_BTHSTART_TITLE_H); - titleLable->SetText("请保持静止"); - titleLable->SetTextColor(Color::White()); - titleLable->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - titleLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WND_BTHSTART_TITLE_FONT_SIZE); - group->Add(titleLable); - - if (centerImge == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathStartPage::OnStart new centerImg ERROR"); - centerImge = new UIImageView(); - } - centerImge->SetPosition(WND_BTHSTART_CENTERIMG_X, WND_BTHSTART_CENTERIMG_Y); - centerImge->Resize(WND_BTHSTART_CENTERIMG_W, WND_BTHSTART_CENTERIMG_H); - LOADIMG::LoadImageViewImg(centerImge, BREATH_IMAGE, IMAGE_CONVERTER_TOOL_BREATH003); - group->Add(centerImge); - - if (guideLable == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathStartPage::OnStart new guideLable ERROR"); - guideLable = new UILabel(); - } - guideLable->SetPosition(WND_BTHSTART_GUIDE_X, WND_BTHSTART_GUIDE_Y); - guideLable->Resize(WND_BTHSTART_GUIDE_W, WND_BTHSTART_GUIDE_H); - guideLable->SetTextColor(Color::White()); - guideLable->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - guideLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WND_BTHSTART_GUIDE_FONT_SIZE); - guideLable->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - guideLable->SetStyle(STYLE_TEXT_OPA, TEXT_OPACITY); - group->Add(guideLable); - - animatorCallBack = new BreathStartCallback(this); - if (animatorCallBack == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathStartPage::OnStart new animatorCallBack ERROR"); - return; - } - animation = new Animator(animatorCallBack, nullptr, 0, true); - if (animation == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BreathStartPage::OnStart new animation ERROR"); - return; - } - animation->Start(); - AddViewToPageContainer(group); -} - -void BreathStartPage::OnStop() {} - -void BreathStartPage::BreathStartCallback::Callback(UIView *view) -{ - UNUSED(view); - struct timeval current_time; - gettimeofday(¤t_time, nullptr); - int32_t overTime = countDown; - int32_t start_time = BreathModel::GetInstance().GetSaveTime(); - int32_t remTime = overTime - (current_time.tv_sec - start_time); - - char szText[SIZE] = ""; - sprintf_s(szText, sizeof(szText), "%d秒后跟随训练指引开始吸气和呼气", remTime); - BreathStartPage->guideLable->SetText(szText); - if (remTime <= 0) { - NativeAbility::GetInstance().SwitchPageInSlice(BREATH_EXER_VIEW, nullptr, TransitionType::TRANSITION_INVALID, - true); - BreathStartPage->animation->Stop(); - struct timeval start_breathing_time; - gettimeofday(&start_breathing_time, nullptr); - uint32_t breathing_time = start_breathing_time.tv_sec; - BreathModel::GetInstance().SetBeginsTime(breathing_time); - } -} - -void BreathStartPage::OnPause() -{ - animation->Stop(); -} - -bool BreathStartPage::OnDrag(UIView &view, const DragEvent &event) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BreathStartPage::OnDrag"); - UNUSED(view); - if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && (event.GetDeltaX() > X_DRAG_OFFSET) && - (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BreathStartPage::OnDrag ChangeSlice(VIEW_APPLIST)"); - NativeAbility::GetInstance().SwitchPageInSlice(BREATH_MAIN_VIEW, nullptr, TransitionType::TRANSITION_INVALID, - true); - } - return true; -} - -void BreathStartPage::OnTimer() {} - -} // namespace OHOS \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/callerlog/src/CallerItemView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/callerlog/src/CallerItemView.cpp deleted file mode 100644 index 70b62303c..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/callerlog/src/CallerItemView.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: CallerItemView.cpp - * Author: - * Create: 2021-10-12 - */ - -#include "callerlog/CallerItemView.h" -#include "sys/time.h" -#include "wearable_log.h" -#ifdef BUILD_IN_LINUX -#include "localtime.h" -#endif - -namespace OHOS { -static constexpr int16 ICON_X = 100; -static constexpr int16 APP_ITEM_BUTTON_WIDTH = 70; -static constexpr int16 APP_ITEM_BUTTON_HEIGHT = 150; -static constexpr int16 APP_ITEM_LABEL_WIDTH = 200; -static constexpr int16 APP_ITEM_LABEL_HEIGHT = 100; - -static constexpr int16 NUM_20 = 20; -static constexpr int16 APP_ITEM_FONT_SIZE = 30; -static constexpr int16 HEAD_END_FONT_SIZE = 40; - -static constexpr int16 LABELS_X = 260; -static constexpr int16 LABELS_Y = 80; -static constexpr int16 LABELS_W = 80; -static constexpr int16 LABELS_H = 70; - -static constexpr int16 ICONS_X = 210; -static constexpr int16 ICONS_Y = 70; -static constexpr int16 NUM_10 = 10; -CallerItemView::CallerItemView(int32 yCoordinates) -{ - SetPosition(0, yCoordinates, HORIZONTAL_RESOLUTION, APP_ITEM_BUTTON_HEIGHT); - SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - SetTouchable(true); -} - -CallerItemView::~CallerItemView() -{ - Remove(&icon_); - Remove(&label_); - Remove(&icons_); - Remove(&labels_); -} - -void CallerItemView::SetUpChild() -{ - icon_.SetPosition(NUM_20, NUM_20); - icon_.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); - - icons_.SetPosition(ICONS_X, ICONS_Y); - icons_.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); - - label_.SetPosition(ICON_X + APP_ITEM_BUTTON_WIDTH, 0); - label_.Resize(APP_ITEM_LABEL_WIDTH, APP_ITEM_BUTTON_WIDTH); - label_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, APP_ITEM_FONT_SIZE); - label_.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); - label_.SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE); - label_.SetStyle(STYLE_TEXT_COLOR, Color::Gray().full); - label_.SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - label_.SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - - labels_.SetPosition(LABELS_X, LABELS_Y); - labels_.Resize(LABELS_W, LABELS_H); - labels_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, APP_ITEM_FONT_SIZE); - labels_.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - labels_.SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE); - labels_.SetStyle(STYLE_TEXT_COLOR, Color::Gray().full); - labels_.SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - labels_.SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); -} - -void CallerItemView::InitDateMonTime(time_t seconds) -{ - struct tm pTM; - localtime_r(&seconds, &pTM); - timeDisplay.erase(); - if (pTM.tm_mday < NUM_10) { - std::string day = "0" + std::to_string(pTM.tm_mday); - timeDisplay = std::to_string(pTM.tm_mon) + "/" + day; - return; - } - timeDisplay = std::to_string(pTM.tm_mon) + "/" + std::to_string(pTM.tm_mday); - return; -} - -void CallerItemView::SetItemInfo(CallLogInfo *itemInfo, char len) -{ - SetUpChild(); - icon_.SetSrc(PNG_CALLER_TMAGE_PATH); - infoTel.clear(); - infoTel.append(reinterpret_cast(itemInfo->tel), len); - label_.SetText(infoTel.c_str()); - InitDateMonTime(itemInfo->creationTime); - labels_.SetText(timeDisplay.c_str()); - - if (itemInfo->status == CALL_MISSED) { - icons_.SetSrc(PNG_HANDUP_IMAGE_PATH); - } else if (itemInfo->status == CALL_INCOMING) { - icons_.SetSrc(PNG_ANSWER_TMAGE_PATH); - } else if (itemInfo->status == CALL_OUTGOING) { - icons_.SetSrc(PNG_CALLING_TMAGE_PATH); - } - Add(&icon_); - Add(&label_); - Add(&icons_); - Add(&labels_); - return; -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp deleted file mode 100644 index 11d24831b..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp +++ /dev/null @@ -1,816 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: CallerLogModel.cpp - * Author: - * Create: 2021-10-12 - */ -#include "callerlog/CallerLogModel.h" -#include "callerlog/CallerLogView.h" -#include "makephone/DialingScreenView.h" -#include "makephone/CallingView.h" -#include "ohos_timer.h" -#include "graphic_timer.h" -#include "samgr_lite.h" -#include "makephone/MainCallingPresenter.h" -#include "player/PlayersModel.h" -#include "graphic_service.h" - -#ifdef __cplusplus -extern "C" { -#endif - -using namespace OHOS; - -static int g_callTimes{0}; -static constexpr int NO_NUMBER_STATUS = -1; -// 电话是否为多路状态,或电话结束前是否有过多路状态 -static int g_phoneStatus = PHONE_SINGLE_STATUS; -static int g_isCall{NO_NUMBER_STATUS}; // 电话状态 -static PhoneCallInfo callInfo{}; -static int g_retNum{0}; // 电话个数 -static int g_volumeLocal{0}; // 错误码返回 -GraphicTimer* g_startCounting = nullptr; // 定时器 -static constexpr uint64_t MS_ONE_SECONDS = 1000; -static PhoneCallInfo callList[MULTI_CALL_MAX_NUME]{}; -// 电话优先级标志位 -static int g_firstPriority = NO_NUMBER_STATUS; -static int g_secondPriority = NO_NUMBER_STATUS; -static int g_thirdPriority = NO_NUMBER_STATUS; -static int g_fourthPriority = NO_NUMBER_STATUS; -// 是否为手表接听状态 -static bool g_isWatchCallView = false; - -static void SetPriorityNumber() -{ - time_t seconds; - time(&seconds); - - // 接听和挂起状态需要持续显示通话计时 - if (g_firstPriority != NO_NUMBER_STATUS) { // 接听 - CallerLogModel::GetInstance()->SetoperateNumber(callList[g_firstPriority].unitCalls.number, - callList[g_firstPriority].unitCalls.number_len); - g_callTimes = seconds - callList[g_firstPriority].activeTime; - } else if (g_secondPriority != NO_NUMBER_STATUS) { // 挂起 - CallerLogModel::GetInstance()->SetoperateNumber(callList[g_secondPriority].unitCalls.number, - callList[g_secondPriority].unitCalls.number_len); - g_callTimes = seconds - callList[g_secondPriority].activeTime; - } else if (g_thirdPriority != NO_NUMBER_STATUS) { - CallerLogModel::GetInstance()->SetoperateNumber(callList[g_thirdPriority].unitCalls.number, - callList[g_thirdPriority].unitCalls.number_len); - } else if (g_fourthPriority != NO_NUMBER_STATUS) { - CallerLogModel::GetInstance()->SetoperateNumber(callList[g_fourthPriority].unitCalls.number, - callList[g_fourthPriority].unitCalls.number_len); - } - return; -} - -/* 关闭定时器 */ -static void DisableCallingTimer() -{ - if (g_startCounting != nullptr) { - delete g_startCounting; - g_startCounting = nullptr; - g_callTimes = 0; - } -} - -/* 状态复位 */ -static void StatusReset() -{ - CallerLogModel::GetInstance()->SetCallStatus(false); - CallerLogModel::GetInstance()->SetWaitingStatus(false); - DisableCallingTimer(); - // If the call is handling in the notification, the slice is not switched - if (!CallerLogModel::GetInstance()->GetNotifyFlag()) { - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE); - } else { - g_isWatchCallView = false; - } - return; -} - -/* 定时器回调函数 */ -static void CallTimerCallbackProc(void* data) -{ - g_callTimes++; - - if (CallingView::GetInstance() == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CallTimerCallbackProc] GetInstance is nullptr"); - return; - } - - if (CallingView::GetInstance()->GetCallingDurationLabel() == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CallTimerCallbackProc] GetInstance()->GetCallingDurationLabel is nullptr"); - return; - } - - CallingView::GetInstance()->GetCallingDurationLabel()-> - SetText(CallerLogModel::GetInstance()->DisplayCallDuration().c_str()); -} - -static void CallTimerCallback(void* data) -{ - GraphicService::GetInstance()->PostGraphicEvent(std::bind(CallTimerCallbackProc, data)); -} - -/* 开启定时器 */ -static void InitCallingTimer() -{ - if (g_startCounting != nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallerLogModel::CallerTimer already exists!!"); - return; - } - uint32 tick = GetOSTick(MS_ONE_SECONDS); - g_startCounting = new GraphicTimer(tick, CallTimerCallback, nullptr, true); - if (g_startCounting == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogModel::CallerTimer new GraphicTimer failed!!"); - return; - } - bool retTimer = g_startCounting->Start(); - if (!retTimer) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogModel::CallerTimer Start failed, ret = %lx!!", retTimer); - if (g_startCounting != nullptr) { - delete g_startCounting; - g_startCounting = nullptr; - } - return; - } -} - -/* 判断是否有电话,判断优先级 */ -bool FindCallListInfoAndSetPriorityNumber() -{ - g_isCall = NO_NUMBER_STATUS; - g_firstPriority = NO_NUMBER_STATUS; - g_secondPriority = NO_NUMBER_STATUS; - g_thirdPriority = NO_NUMBER_STATUS; - g_fourthPriority = NO_NUMBER_STATUS; - (void)memset_s(callList, MULTI_CALL_MAX_NUME * sizeof(PhoneCallInfo), - 0, MULTI_CALL_MAX_NUME * sizeof(PhoneCallInfo)); - int ret = GetCallInfoInCallList(callList, MULTI_CALL_MAX_NUME, &g_retNum); - if (ret != 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FindCallListInfoAndSetPriorityNumber Error ret = %d", ret); - return false; - } - if (g_retNum == 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FindCallListInfoAndSetPriorityNumber no call num"); - return false; - } - - if (g_retNum > 0 && g_retNum <= MULTI_CALL_MAX_NUME) { - for (int i = 0; i < g_retNum; i++) { - if (callList[i].lastStatus == HFP_HF_CALL_STATE_ACTIVE) { - g_firstPriority = i; - g_isCall = callList[i].lastStatus; - break; - } else if (callList[i].lastStatus == HFP_HF_CALL_STATE_HELD) { - g_secondPriority = i; - g_isCall = callList[i].lastStatus; - } else if (callList[i].lastStatus == HFP_HF_CALL_STATE_ALERTING || - callList[i].lastStatus == HFP_HF_CALL_STATE_DIALING) { - if (g_secondPriority == NO_NUMBER_STATUS) { - g_isCall = callList[i].lastStatus; - } - g_thirdPriority = i; - } else if (callList[i].lastStatus == HFP_HF_CALL_STATE_INCOMING || - callList[i].lastStatus == HFP_HF_CALL_STATE_WAITING) { - // 呼入切换通话界面,呼入等待不切换界面,通过震动和铃声提醒 - if (g_isCall == NO_NUMBER_STATUS && callList[i].lastStatus == HFP_HF_CALL_STATE_INCOMING) { - g_isCall = callList[i].lastStatus; - } - g_fourthPriority = i; - } - } - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FindCallListInfoAndSetPriorityNumber] [%d] [%d] [%d] [%d], g_isCall = %d", - g_firstPriority, g_secondPriority, g_thirdPriority, g_fourthPriority, g_isCall); - SetPriorityNumber(); - - return true; -} - -static void CallModelResumePlayer(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CallModelResumePlayer] [ResumePlayer] start"); - usleep(5000); // 延时等待通话释放媒体资源 -} - -static void CallModelPostGraphicEvent(void (*fun)(void)) -{ - GraphicService::GetInstance()->PostGraphicEvent(*fun); -} - -static int g_callOperate = OPERATE_NO_OPE; - -static void ExitMakePhoneSlice(void) -{ - if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_MAEKPHONE_SAMPLE) { - WEARABLE_LOGD(HILOG_MODULE_AAFWK, "ExitMakePhoneSlice"); - - if (GetCurrCallNum() == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE); - CallModelPostGraphicEvent(CallModelResumePlayer); - } else { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); - } - } - CallerLogModel::GetInstance()->SetCallStatus(false); - DisableCallingTimer(); - if (CallerLogModel::GetInstance()->GetNotifyFlag()) { - g_isWatchCallView = false; - } -} - -static void DialingHandle(void) -{ - CallerLogModel::GetInstance()->SetDialingStatus("正在拨号"); - CallerLogModel::GetInstance()->SetMakePhoneStatus(true); -} - -static void AlertingHandle(void) -{ - CallerLogModel::GetInstance()->SetDialingStatus("正在响铃"); - CallerLogModel::GetInstance()->SetMakePhoneStatus(true); -} - -static void IncomingHandle(void) -{ - CallerLogModel::GetInstance()->SetMakePhoneStatus(false); -} - -// 来电等待界面 -static void WaitingOpreate() -{ - if (!IsCompleteCallFlow()) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[UsingPhoneChangeStatusCallback] is not complete call flow"); - return; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[WaitingOpreate] WaitingOpreate"); - CallerLogModel::GetInstance()->SetCallStatus(false); - CallerLogModel::GetInstance()->SetWaitingStatus(true); - // If the call is handling in the notification, the slice is not switched - if (!CallerLogModel::GetInstance()->GetNotifyFlag()) { - NativeAbility::GetInstance().ChangeSlice(VIEW_MAEKPHONE_SAMPLE, TransitionType::TRANSITION_INVALID, - PRIORITY_ONE); - } else { - g_isWatchCallView = true; - } -} - -static void WatchActiveHandle(const PhoneCallInfo *phoneCall) -{ - if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_MAEKPHONE_SAMPLE || - NativeAbility::GetInstance().GetCurSliceId() == VIEW_OFFLINEVOICE || - CallerLogModel::GetInstance()->GetNotifyFlag()) { - time_t seconds; - time(&seconds); - g_callTimes = seconds - phoneCall->activeTime; - - InitCallingTimer(); - CallerLogModel::GetInstance()->SetCallStatus(true); - } - if (CallerLogModel::GetInstance()->GetNotifyFlag()) { - g_isWatchCallView = true; - } -} - -static void PhoneActiveHandle(void) -{ - if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_MAEKPHONE_SAMPLE || - g_isWatchCallView) { - if (GetCurrCallNum() > 1) { - g_phoneStatus = PHONE_MULTI_STATUS; - if (GetScoConnectState() == HFP_SCO_STATE_DISCONNECTED) { - DisableCallingTimer(); - } - } - TransCallToMobilePhone(); - // If the call is handling in the notification, the slice is not switched - if (!CallerLogModel::GetInstance()->GetNotifyFlag()) { - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE); // 退出通话界面,回到主表盘应用 - } else { - g_isWatchCallView = false; - } - CallModelPostGraphicEvent(CallModelResumePlayer); - } - usleep(5000); // 延时等待SCO连接上报完成 - g_callOperate = OPERATE_WATCH_ACTIVE; -} - -static void OppoActiveHandle(const PhoneCallInfo *phoneCall) -{ - if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_MAEKPHONE_SAMPLE || - g_isWatchCallView) { - if (GetCurrCallNum() > 1) { - g_phoneStatus = PHONE_MULTI_STATUS; - return; - } - time_t seconds; - time(&seconds); - g_callTimes = seconds - phoneCall->activeTime; - - InitCallingTimer(); - CallerLogModel::GetInstance()->SetCallStatus(true); - } -} - -bool MulitplePhoneTextReplaces() -{ - DisableCallingTimer(); - if (CallingView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[MultiplePhonesViewDisplay] GetInstance is nullptr"); - return false; - } - - if (CallingView::GetInstance()->GetCallingDurationLabel() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[MultiplePhonesViewDisplay] GetInstance()->GetCallingDurationLabel is nullptr"); - return false; - } - - if (CallingView::GetInstance()->GetCallingDisplayLabel() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[MultiplePhonesViewDisplay] GetInstance()->GetCallingDurationLabel is nullptr"); - return false; - } - - if (MainCallingPresenter::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[MultiplePhonesViewDisplay] GetInstance()->MainCallingPresenter is nullptr"); - return false; - } - - if (!MainCallingPresenter::GetInstance()->CallingViewDisplay()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[MultiplePhonesViewDisplay] GetInstance()->CallingViewDisplay is nullptr"); - return false; - } - - CallingView::GetInstance()->GetCallingDisplayLabel()->SetText("正在通话"); - CallingView::GetInstance()->GetCallingDurationLabel()->SetText(""); - return true; -} - -// 多路通话界面显示 -static bool MultiplePhonesViewDisplay() -{ - if (g_phoneStatus == PHONE_MULTI_STATUS) { - if (NativeAbility::GetInstance().GetCurSliceId() != VIEW_MAEKPHONE_SAMPLE) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[MultiplePhonesViewDisplay]GetCurSliceId no VIEW_MAEKPHONE_SAMPLE"); - DisableCallingTimer(); - CallerLogModel::GetInstance()->SetMulitplePhoneStatus(true); - CallerLogModel::GetInstance()->SetCallStatus(true); - if (!CallerLogModel::GetInstance()->GetNotifyFlag()) { - NativeAbility::GetInstance().ChangeSlice(VIEW_MAEKPHONE_SAMPLE, TransitionType::TRANSITION_INVALID, - PRIORITY_ONE); - } else { - g_isWatchCallView = true; - } - return true; - } - if (!MulitplePhoneTextReplaces()) { - return false; - } - return true; - } - return false; -} - -/* 非手表挂断 */ -static void NonWatchFinishHandle(int laststatus) -{ - if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_MAEKPHONE_SAMPLE || - CallerLogModel::GetInstance()->GetNotifyFlag()) { - if (GetCurrCallNum() == 0) { - StatusReset(); - CallModelPostGraphicEvent(CallModelResumePlayer); - g_phoneStatus = PHONE_SINGLE_STATUS; - } else if (g_phoneStatus == PHONE_MULTI_STATUS) { - MultiplePhonesViewDisplay(); - } else if (FindCallListInfoAndSetPriorityNumber()) { - if (laststatus == HFP_HF_CALL_STATE_ACTIVE || laststatus == HFP_HF_CALL_STATE_HELD) { - CallerLogModel::GetInstance()->SetCallStatus(false); - CallerLogModel::GetInstance()->SetWaitingStatus(false); - } else if (laststatus == HFP_HF_CALL_STATE_WAITING) { - CallerLogModel::GetInstance()->SetCallStatus(true); - CallerLogModel::GetInstance()->SetWaitingStatus(false); - } - // If the call is handling in the notification, the slice is not switched - if (!CallerLogModel::GetInstance()->GetNotifyFlag()) { - NativeAbility::GetInstance().ChangeSlice(VIEW_MAEKPHONE_SAMPLE, TransitionType::TRANSITION_INVALID, - PRIORITY_ONE); - } else { - g_isWatchCallView = true; - } - } - if (GetCurrCallNum() == 0) { - CallerLogModel::GetInstance()->SetNotifyFlag(false); - } - } - if (GetCurrCallNum() == 0) { - g_phoneStatus = PHONE_SINGLE_STATUS; - } -} - -static void WatchFinishHandle(void) -{ - if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_MAEKPHONE_SAMPLE || - CallerLogModel::GetInstance()->GetNotifyFlag()) { - if (GetCurrCallNum() == 0) { - StatusReset(); - CallerLogModel::GetInstance()->SetNotifyFlag(false); - } else { - StatusReset(); - for (int i = GetCurrCallNum(); i > 0; i--) { - FinishCall(); - } - } - } - g_phoneStatus = PHONE_SINGLE_STATUS; -} - -static void ChangeStatusScreendisplay(int lastStatus) -{ - if (GetScoConnectState() != HFP_SCO_STATE_CONNECTED) { - if (lastStatus == HFP_HF_CALL_STATE_ACTIVE) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ChangeStatusScreendisplay] STATE_ACTIVE"); - StatusReset(); - return; - } else if (lastStatus == HFP_HF_CALL_STATE_INCOMING) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ChangeStatusScreendisplay] STATE_INCOMING"); - } else if (GetCurrCallNum() == 1 && (lastStatus == HFP_HF_CALL_STATE_DIALING || - lastStatus == HFP_HF_CALL_STATE_ALERTING)) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ChangeStatusScreendisplay] STATE_ALERTING"); - } else if (GetCurrCallNum() > 1) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ChangeStatusScreendisplay] GetCurrCallNum MULITE"); - DisableCallingTimer(); - return; - } - } - if (!IsCompleteCallFlow()) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ChangeStatusScreendisplay] is not complete call flow"); - return; - } - if (MultiplePhonesViewDisplay()) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ChangeStatusScreendisplay] MultiplePhonesViewDisplay"); - return; - } - // If the call is handling in the notification, the slice is not switched - if (g_callOperate != OPERATE_PHONE_ACTIVE && (!CallerLogModel::GetInstance()->GetNotifyFlag())) { - NativeAbility::GetInstance().ChangeSlice(VIEW_MAEKPHONE_SAMPLE, TransitionType::TRANSITION_INVALID, - PRIORITY_ONE); - } -} - -void UsingPhoneChangeStatusCallback(const PhoneCallInfo *phoneCall) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[UsingPhoneChangeStatusCallback] operate:%d, callNUm:%d, call flow:%d", - phoneCall->operate, GetCurrCallNum(), IsCompleteCallFlow()); - - if (phoneCall->operate == OPERATE_WATCH_FINISH && GetCurrCallNum() == 0) { - g_callOperate = OPERATE_WATCH_FINISH; - WatchFinishHandle(); - return; - } - CallerLogModel::GetInstance()->SetoperateNumber(phoneCall->unitCalls.number, phoneCall->unitCalls.number_len); - g_callOperate = phoneCall->operate; - - switch (g_callOperate) { - case OPERATE_DIALING: - // 显示正在呼出界面 - DialingHandle(); - break; - case OPERATE_ALERTING: - // 显示对方响铃 - AlertingHandle(); - break; - case OPERATE_INCOMING: - // 显示电话呼入 - IncomingHandle(); - break; - case OPERATE_WAITING: - // 震动一下,提示有新电话呼入 还未对齐 - WaitingOpreate(); - return; - case OPERATE_WATCH_ACTIVE: - // 手表接听,显示界面 - WatchActiveHandle(phoneCall); - break; - case OPERATE_PHONE_ACTIVE: - // 手机接听 - PhoneActiveHandle(); - return; - case OPERATE_PEER_ACTIVE: - // 呼出被接听,显示界面 - OppoActiveHandle(phoneCall); - break; - case OPERATE_PHONE_HOLD: - // 挂起状态,不做处理 - return; - case OPERATE_WATCH_FINISH: - WatchFinishHandle(); - return; - case OPERATE_WATCH_REJECT: - case OPERATE_NON_WATCH_FINISH: - NonWatchFinishHandle(phoneCall->lastStatus); - return; - default: - break; - } - ChangeStatusScreendisplay(phoneCall->lastStatus); -} - -void UsingPhoneErrorCallback(PhoneServiceErrorType type) -{ - if (type == ERROR_DIAL) { - // 根据不同的错误码做出不同的操作 - } else if (type == ERROR_BT) { - // 蓝牙断开,直接返回APPLIST - WEARABLE_LOGD(HILOG_MODULE_AAFWK, "UsingPhoneErrorCallback BT"); - ExitMakePhoneSlice(); - } -} - -static void ScoConnectHandle(void) -{ - if (GetCurrCallNum() == 0) { - return; - } - - if (!FindCallListInfoAndSetPriorityNumber()) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ScoConnectHandle FindCallListInfoAndSetPriorityNumber false"); - return; - } - - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ScoConnectHandle] g_isCall = %d", g_isCall); - switch (g_isCall) { - case HFP_HF_CALL_STATE_ACTIVE: - if (g_callOperate == OPERATE_PHONE_ACTIVE) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ScoConnectHandle] OPERATE_PHONE_ACTIVE"); - return; - } - CallerLogModel::GetInstance()->SetCallStatus(true); - InitCallingTimer(); - break; - case HFP_HF_CALL_STATE_ALERTING: - CallerLogModel::GetInstance()->SetDialingStatus("正在响铃"); - CallerLogModel::GetInstance()->SetMakePhoneStatus(true); - break; - case HFP_HF_CALL_STATE_DIALING: - CallerLogModel::GetInstance()->SetDialingStatus("正在拨号"); - CallerLogModel::GetInstance()->SetMakePhoneStatus(true); - break; - case HFP_HF_CALL_STATE_INCOMING: - CallerLogModel::GetInstance()->SetMakePhoneStatus(false); - break; - case HFP_HF_CALL_STATE_HELD: - CallerLogModel::GetInstance()->SetCallStatus(true); - InitCallingTimer(); - break; - default: - break; - } - g_isCall = NO_NUMBER_STATUS; - if (!IsCompleteCallFlow()) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ScoConnectHandle] is not complete call flow"); - return; - } - if (MultiplePhonesViewDisplay()) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ScoConnectHandle] MultiplePhonesViewDisplay"); - return; - } - // If the call is handling in the notification, the slice is not switched - if (!CallerLogModel::GetInstance()->GetNotifyFlag()) { - NativeAbility::GetInstance().ChangeSlice(VIEW_MAEKPHONE_SAMPLE, TransitionType::TRANSITION_INVALID, - PRIORITY_ONE); - } else { - g_isWatchCallView = true; - } -} - -static void ScoDisconnectHandle(void) -{ - ExitMakePhoneSlice(); - CallerLogModel::GetInstance()->SetWaitingStatus(false); -} - -void UsingPhoneScoStatausCallback(hfp_sco_connect_state_t state) -{ - WEARABLE_LOGD(HILOG_MODULE_AAFWK, "UsingPhoneScoStatausCallback SOC state: %d", state); - - if (!IsCompleteCallFlow()) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[UsingPhoneScoStatausCallback] is not complete call flow"); - return; - } - - if (state == HFP_SCO_STATE_CONNECTED) { - ScoConnectHandle(); - } else if (state == HFP_SCO_STATE_DISCONNECTED) { - ScoDisconnectHandle(); - } -} - -/* 状态变化 */ -void PhoneChangeStatusCallback(const PhoneCallInfo *phoneCall) -{ - (void)memset_s(&callInfo, sizeof(PhoneCallInfo), 0, sizeof(PhoneCallInfo)); - (void)memcpy_s(&callInfo, sizeof(PhoneCallInfo), phoneCall, sizeof(PhoneCallInfo)); - GraphicService::GetInstance()->PostGraphicEvent(std::bind(UsingPhoneChangeStatusCallback, &callInfo)); -} - -/* 蓝牙 */ -void PhoneErrorCallback(PhoneServiceErrorType type, int volume) -{ - g_volumeLocal = volume; - GraphicService::GetInstance()->PostGraphicEvent(std::bind(UsingPhoneErrorCallback, type)); -} - -/* SCO */ -void PhoneScoStatausCallback(hfp_sco_connect_state_t state) -{ - GraphicService::GetInstance()->PostGraphicEvent(std::bind(UsingPhoneScoStatausCallback, state)); -} - -namespace OHOS { -static constexpr int32 NUM_TEN = 10; -static constexpr int16 NUM_TIME_MIN = 60; -static constexpr int16 NUM_TIME_HOUR = 3600; -static constexpr int32 NUM_TIME_DAY = 86400; - -CallerLogModel::CallerLogModel() {} - -CallerLogModel::~CallerLogModel() {} - -/* 初始化电话服务 */ -void CallerLogModel::InitPhoneService() -{ - WEARABLE_LOGD(HILOG_MODULE_AAFWK, "CallerLogModel::[InitPhoneService]::Init start"); - PhoneServiceInit(); - PhoneServiceCb serviceFoution; - - serviceFoution.callChanged = PhoneChangeStatusCallback; - serviceFoution.phoneServiceErrorCb = PhoneErrorCallback; - serviceFoution.scoStatusCb = PhoneScoStatausCallback; - int ret = RegisterCallChangedCb(&serviceFoution); - WEARABLE_LOGD(HILOG_MODULE_AAFWK, "CallerLogModel::[InitPhoneService]::Init ret = %d", ret); -} - -/* 表盘底部时间显示 */ -std::string CallerLogModel::InitDateHourTime(void) -{ - struct tm pTM; - time_t seconds; - time(&seconds); - localtime_r(&seconds, &pTM); - timers.erase(); - if (pTM.tm_min < NUM_TEN) { - std::string min = "0" + std::to_string(pTM.tm_min); - timers = std::to_string(pTM.tm_hour) + ":" + min; - return timers; - } - timers = std::to_string(pTM.tm_hour) + ":" + std::to_string(pTM.tm_min); - return timers; -} - -/* 表盘通话时间显示 */ -std::string& CallerLogModel::DisplayCallDuration() -{ - callDuration.erase(); - std::string hours; - std::string minute; - std::string seconds; - if (g_callTimes >= NUM_TIME_DAY) { - g_callTimes = 0; - } - int hour = g_callTimes / NUM_TIME_HOUR; - int min = (g_callTimes % NUM_TIME_HOUR) / NUM_TIME_MIN; - int sec = (g_callTimes % NUM_TIME_HOUR) % NUM_TIME_MIN; - if (hour >= 0 && hour < NUM_TEN) { - hours = "0" + std::to_string(hour); - } else { - hours = std::to_string(hour); - } - if (min >= 0 && min < NUM_TEN) { - minute = "0" + std::to_string(min); - } else { - minute = std::to_string(min); - } - if (sec >= 0 && sec < NUM_TEN) { - seconds = "0" + std::to_string(sec); - } else { - seconds = std::to_string(sec); - } - - if (hour == 0) { - callDuration = minute + ":" + seconds; - } else { - callDuration = hours + ":" + minute + ":" + seconds; - } - return callDuration; -} - -/* 拨号与响铃状态显示 */ -void CallerLogModel::SetDialingStatus(const char *text) -{ - dialingStatus.clear(); - dialingStatus.append(reinterpret_cast(text)); -} - -std::string CallerLogModel::GetDialingStatus(void) -{ - return dialingStatus; -} - -void CallerLogModel::SetNotifyFlag(bool flag) -{ - notifyFlag = flag; -} - -bool CallerLogModel::GetNotifyFlag(void) -{ - return notifyFlag; -} - -// 电话是否为多路状态 -bool CallerLogModel::IsMulitplePhoneStatus(void) -{ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "IsMulitplePhoneStatus phoneStatus:%d", g_phoneStatus); - return g_phoneStatus == PHONE_MULTI_STATUS; -} - -/* 是否为多路通话界面 */ -void CallerLogModel::SetMulitplePhoneStatus(bool status) -{ - mulitplePhoneStatus = status; -} - -bool CallerLogModel::GetMulitplePhoneStatus() -{ - return mulitplePhoneStatus; -} - -/* 是否为等待提示界面 */ -bool CallerLogModel::GetWaitingStatus() -{ - return waitingStatus; -} -void CallerLogModel::SetWaitingStatus(bool status) -{ - waitingStatus = status; -} - -/* 是否为接听界面 */ -void CallerLogModel::SetCallStatus(bool status) -{ - callStatus = status; -} - -bool CallerLogModel::GetCallStatus() -{ - return callStatus; -} - -/* 是否为音量界面 */ -void CallerLogModel::SetVolumeScreenStatus(bool status) -{ - volumeStatus = status; -} - -bool CallerLogModel::GetVolumeScreenStatus() -{ - return volumeStatus; -} - -/* 设置来电号码显示 */ -void CallerLogModel::SetoperateNumber(const char *number, char number_len) -{ - phoneNumber.clear(); - phoneNumber.append(reinterpret_cast(number), number_len); -} - -std::string CallerLogModel::GetPhoneNumber(void) -{ - return phoneNumber; -} - -/* 呼入呼出状态 */ -void CallerLogModel::SetMakePhoneStatus(bool status) -{ - phoneStatus = status; -} - -bool CallerLogModel::GetPhoneStatus() -{ - return phoneStatus; -} - -int CallerLogModel::CurrCallNum(void) -{ - return GetCurrCallNum(); -} - -CallerLogModel *CallerLogModel::GetInstance(void) -{ - static CallerLogModel callLogModel; - return &callLogModel; -} -} -#ifdef __cplusplus -} -#endif diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/callerlog/src/CallerLogPresenter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/callerlog/src/CallerLogPresenter.cpp deleted file mode 100644 index 398f25152..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/callerlog/src/CallerLogPresenter.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: CallerLogPresenter.cpp - * Author: - * Create: 2021-10-12 - */ - -#include "callerlog/CallerLogPresenter.h" -#include "callerlog/CallerLogView.h" -#include "common/task_manager.h" -#include "wearable_log.h" -#include "phoneservice/PhoneService.h" -#include "NativeRegisterManager.h" - -namespace OHOS { - -REGIST_MENU(VIEW_CALLER_SAMPLE, CallerLogView, CallerLogPresenter, PNG_APPLIST_CALLER_IMAGE, PNG_APPLIST_DEFAULT_IMG, "通话记录"); - -static constexpr uint64_t MS_FOUR_SECONDS = 4000; // 定时器时间 -static CallerLogPresenter *g_pMainView = nullptr; -CallerLogPresenter::CallerLogPresenter() -{ - g_pMainView = this; -} - -CallerLogPresenter::~CallerLogPresenter() -{ - g_pMainView = nullptr; -} - -CallerLogPresenter *CallerLogPresenter::GetInstance(void) -{ - return g_pMainView; -} - -void CallerLogPresenter::OnStop(void) -{ - if (hintsCounting != nullptr) { - if (g_pMainView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogPresenter::CallerLogPresenter g_pMainView nullptr"); - return; - } - g_pMainView->DisableBluetoothHints(); - return; - } -} - -/* 定时器回调函数 */ -void BuletoothHintsCallback(void* data) -{ - GraphicService::GetInstance()->PostGraphicEvent(std::bind(&CallerLogPresenter::BuletoothHintsCallbackProc, CallerLogPresenter::GetInstance(), data)); -} - -/* 开启定时器 */ -void CallerLogPresenter::InitBluetoothHints() -{ - if (hintsCounting != nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallerLogPresenter::BluetoothHints already exists!"); - return; - } - hintsCounting = new GraphicTimer(MS_FOUR_SECONDS, BuletoothHintsCallback, nullptr, true); - if (hintsCounting == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogPresenter::BluetoothHints osTimerNew failed!"); - return; - } - bool retTimer = hintsCounting->Start(); - if (!retTimer) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogPresenter::BluetoothHints osTimerStart failed!!"); - if (hintsCounting != nullptr) { - delete hintsCounting; - hintsCounting = nullptr; - } - return; - } -} -void CallerLogPresenter::BuletoothHintsCallbackProc(void* data) -{ - if (CallerLogView::GetInstance() == nullptr) { - return; - } - CallerLogView::GetInstance()->GetHintsGroup()->SetVisible(false); - CallerLogView::GetInstance()->GetContainerView()->SetVisible(true); - CallerLogView::GetInstance()->GetGroupView()->SetVisible(true); - if (g_pMainView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogPresenter::CallerLogPresenter g_pMainView nullptr"); - return; - } - g_pMainView->DisableBluetoothHints(); -} - -/* 关闭定时器 */ -void CallerLogPresenter::DisableBluetoothHints() -{ - if (hintsCounting != nullptr) { - delete hintsCounting; - hintsCounting = nullptr; - } -} - -bool CallerLogPresenter::OnClick(UIView &view, const ClickEvent &event) -{ - UNUSED(event); - if (CallerLogView::GetInstance() == nullptr) { - return false; - } - - if (CallerLogModel::GetInstance() == nullptr) { - return false; - } - - uint16 dataNumber = view_->GetCurrentNumber(); - if (view.GetViewIndex() == dataNumber) { - if (ClearCallLogFile() == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallerLogPresenter::ClearCallLogFile success"); - } - view_->GetContainerView()->SetVisible(false); - view_->GetGroupView()->SetVisible(true); - } else if (view.GetViewIndex() >= 0 && view.GetViewIndex() < dataNumber) { - // 手表拨出呼叫 - if (GetBtConnectStatus() != PROFILE_STATE_CONNECTED) { - CallerLogView::GetInstance()->GetHintsGroup()->SetVisible(true); - CallerLogView::GetInstance()->GetContainerView()->SetVisible(false); - CallerLogView::GetInstance()->GetGroupView()->SetVisible(false); - - InitBluetoothHints(); - return false; - } - if (0 <= view.GetViewIndex() && view.GetViewIndex() < dataNumber) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "callnumber %s, callnumbernum %d", - (char *)(view_->GetCurrentCallInfo() + dataNumber - view.GetViewIndex() - 1)->tel, - (view_->GetCurrentCallInfo() + dataNumber - view.GetViewIndex() - 1)->telLen); - - CallerLogModel::GetInstance()->SetoperateNumber( - (char *)(view_->GetCurrentCallInfo() + dataNumber - view.GetViewIndex() - 1)->tel, - (view_->GetCurrentCallInfo() + dataNumber - view.GetViewIndex() - 1)->telLen); - - if (DialCall( - (unsigned char *)(view_->GetCurrentCallInfo() + dataNumber - view.GetViewIndex() - 1)->tel, - (view_->GetCurrentCallInfo() + dataNumber - view.GetViewIndex() - 1)->telLen) == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallerLogPresenter::Onclick caller success"); - } - } - } - return false; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/callerlog/src/CallerLogView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/callerlog/src/CallerLogView.cpp deleted file mode 100644 index a9d012a1c..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/callerlog/src/CallerLogView.cpp +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: CallerLogView.cpp - * Author: - * Create: 2021-10-12 - */ - -#include "callerlog/CallerLogView.h" -#include "callerlog/CallerLogPresenter.h" -#include "callerlog/CallerLogModel.h" -#include "wearable_log.h" - -namespace OHOS { -static constexpr int16 ICON_X = 100; -static constexpr int16 APP_ITEM_BUTTON_HEIGHT = 150; - -static constexpr int16 NUM_20 = 20; -static constexpr int16 APP_ITEM_FONT_SIZE = 30; -static constexpr int16 HEAD_END_FONT_SIZE = 40; - -static constexpr int16 ITEM_GROUP_HEIGHT = 150; - -static int32 num = 0; -static CallerLogView *g_pMainView = nullptr; -CallerLogView::CallerLogView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "::CallerLogView::CallerLogView "); - g_pMainView = this; -} - -CallerLogView::~CallerLogView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "::CallerLogView::~CallerLogView "); - group->RemoveAll(); - container->RemoveAll(); - hintsGroup->RemoveAll(); - - delete hintsImageView; - hintsImageView = nullptr; - - delete imageView; - imageView = nullptr; - - if (!item.IsEmpty()) { - Vector().Swap(item); - } - - delete dragListener; - dragListener = nullptr; - - if (num != 0) { - delete[] info; - info = nullptr; - - groupFirst->RemoveAll(); - groupFinal->RemoveAll(); - - delete groupFirst; - groupFirst = nullptr; - - delete groupFinal; - groupFinal = nullptr; - } - - delete group; - group = nullptr; - - delete hintsGroup; - hintsGroup = nullptr; - - delete container; - container = nullptr; - - g_pMainView = nullptr; -} - -CallerLogView *CallerLogView::GetInstance() -{ - return g_pMainView; -} - -bool CallerLogView::CreateNoDataCallerLogViewGroup() -{ - group = new CallerUIScrollView(); - if (group == nullptr) { - return false; - } - group->SetPosition(0, 0); - group->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); - - imageView = new UIImageView(); - if (imageView == nullptr) { - return false; - } - imageView->SetPosition(0, 0); // 30 : offset - imageView->SetSrc(PNG_NO_CALLER_LOG_IMAGE); - group->Add(imageView); - return true; -} - -CallerUIScrollView *CallerLogView::GetContainerView() -{ - return container; -} - -CallerUIScrollView *CallerLogView::GetGroupView() -{ - return group; -} - -void CallerLogView::InitBluetoothHintsGroup() -{ - hintsGroup = new UIViewGroup(); - if (hintsGroup == nullptr) { - return; - } - hintsGroup->SetPosition(0, 0); - hintsGroup->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); - - hintsImageView = new UIImageView(); - if (hintsImageView == nullptr) { - return; - } - hintsImageView->SetPosition(0, 0); // 30 : offset - hintsImageView->SetSrc(PNG_BLUETOOTH_HINTS_PATH); - hintsGroup->Add(hintsImageView); - - AddViewToRootContainer(hintsGroup); - hintsGroup->SetVisible(false); - return; -} - -UIViewGroup *CallerLogView::GetHintsGroup() -{ - return hintsGroup; -} - -void CallerLogView::ChangeLabelsStytleLog() -{ - groupFirst = new UIViewGroup(); - if (groupFirst == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogView::new groupFirst error"); - return; - } - groupFirst->SetPosition(0, 0, HORIZONTAL_RESOLUTION, APP_ITEM_BUTTON_HEIGHT); - groupFirst->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - groupFirst->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - - labelLog.SetPosition(0, APP_ITEM_FONT_SIZE, HORIZONTAL_RESOLUTION, ICON_X + NUM_20); - labelLog.SetText("通话记录"); - labelLog.SetTextColor(Color::White()); - labelLog.SetFont(DEFAULT_VECTOR_FONT_FILENAME, HEAD_END_FONT_SIZE); - labelLog.SetAlign(TEXT_ALIGNMENT_CENTER); - groupFirst->Add(&labelLog); -} - -void CallerLogView::ChangeLabelsStytleClear(int32 groupFinaly, int32 Index) -{ - groupFinal = new UIViewGroup(); - if (groupFinal == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogView::new groupFinal error"); - return; - } - groupFinal->SetPosition(0, groupFinaly, HORIZONTAL_RESOLUTION, APP_ITEM_BUTTON_HEIGHT); - groupFinal->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - groupFinal->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - groupFinal->SetTouchable(true); - groupFinal->SetViewIndex(Index); - groupFinal->SetOnClickListener(clickLeftListener); - - labelClear.SetPosition(0, NUM_20, HORIZONTAL_RESOLUTION, APP_ITEM_BUTTON_HEIGHT); - labelClear.SetText("全部清除"); - labelClear.SetTextColor(Color::White()); - labelClear.SetFont(DEFAULT_VECTOR_FONT_FILENAME, HEAD_END_FONT_SIZE); - labelClear.SetAlign(TEXT_ALIGNMENT_CENTER); - groupFinal->Add(&labelClear); -} - -bool CallerLogView::InitOrBandOnclickEvent() -{ - clickLeftListener = (UIView::OnClickListener*)OHOS::CallerLogPresenter::GetInstance(); - if (clickLeftListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogView::new clickLeftListener error"); - return false; - } - return true; -} - -bool CallerLogView::CreateCallerLogViewGroup() -{ - container = new CallerUIScrollView(); - if (container == nullptr) { - return false; - } - container->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - container->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - container->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - container->SetThrowDrag(true); - container->SetDraggable(true); - return true; -} - -void CallerLogView::OnStart() -{ - - if (!CreateNoDataCallerLogViewGroup()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogView::CreateNoDataCallerLogViewGroup error"); - return; - } - AddViewToRootContainer(group); - - if (!CreateCallerLogViewGroup()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogView::CreateCallerLogViewGroup error"); - return; - } - - if (!InitOrBandOnclickEvent()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogView::InitOrBandOnclickEvent fail"); - return; - } - - if (GetCallLog(&info, &num) == -1) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallerLogModel::GetInstance()->ListIsEmpty"); - return; - } - - if (num != 0) { - ChangeLabelsStytleLog(); - container->Add(groupFirst); - - currentNumber = 0; - for (int i = num; i != 0; i--) { - item.PushBack(nullptr); - item[currentNumber] = new CallerItemView((currentNumber + 1)*ITEM_GROUP_HEIGHT); - item[currentNumber]->SetItemInfo((info + i - 1), (info + i -1)->telLen); - item[currentNumber]->SetViewIndex(currentNumber); - item[currentNumber]->SetOnClickListener(clickLeftListener); - container->Add(item[currentNumber]); - currentNumber++; - } - ChangeLabelsStytleClear((currentNumber + 1)*ITEM_GROUP_HEIGHT, currentNumber); - container->Add(groupFinal); - } - - dragListener = new CallerListOnDragListener(); - if (dragListener == nullptr) { - return; - } - InitBluetoothHintsGroup(); - container->SetOnDragListener(dragListener); - group->SetOnDragListener(dragListener); - AddViewToRootContainer(container); - if (num == 0) { - group->SetVisible(true); - container->SetVisible(false); - } else { - container->SetVisible(true); - group->SetVisible(false); - } -} - -uint32 CallerLogView::GetCurrentNumber() -{ - return currentNumber; -} - -CallLogInfo *CallerLogView::GetCurrentCallInfo() -{ - return info; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/connectnewphone/src/ConnectOpenView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/connectnewphone/src/ConnectOpenView.cpp deleted file mode 100644 index 2b5a5f419..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/connectnewphone/src/ConnectOpenView.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: ConnectOpen View - * Create: 2022-03-22 - */ -#include "connectnewphone/ConnectOpenView.h" -#include "PageTransitionMgr.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "connectnewphone/ConnectPhonePresenter.h" -#include "bluetooth/BluetoothModel.h" - -namespace OHOS { -static ConnectOpenView *g_pConnectOpenView{nullptr}; -ConnectOpenView::ConnectOpenView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectOpenView::ConnectOpenView"); - g_pConnectOpenView = this; -} - -ConnectOpenView::~ConnectOpenView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectOpenView::~ConnectOpenView"); - group->RemoveAll(); - delete titleLabel; - titleLabel = nullptr; - delete backButton; - backButton = nullptr; - delete group; - group = nullptr; - delete tipImg; - tipImg = nullptr; - g_pConnectOpenView = nullptr; -} - -ConnectOpenView *ConnectOpenView::GetInstance() -{ - return g_pConnectOpenView; -} - -void ConnectOpenView::ShowUpBackView() -{ - if (watchNameLabel == nullptr) { - watchNameLabel = new UILabel(); - if (watchNameLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectOpenView watchNameLabel new fail"); - return; - } - watchNameLabel->SetPosition(0, 165, HORIZONTAL_RESOLUTION, 45); // 0:x 244:y 454:width 45:height - watchNameLabel->SetText(BluetoothModel::GetInstance()->getWatchName()); - watchNameLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40:font data - watchNameLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - watchNameLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - group->Add(watchNameLabel); - } - - if (titleLabel == nullptr) { - titleLabel = new UILabel(); - if (titleLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectOpenView titleLabel new fail"); - return; - } - titleLabel->SetPosition(0, 244, HORIZONTAL_RESOLUTION, 45); // 0:x 244:y 454:width 45:height - titleLabel->SetText("连接已打开"); - titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40:font data - titleLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - titleLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - group->Add(titleLabel); - } - if (backButton == nullptr) { - backButton = new UILabelButton(); - if (backButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectOpenView backButton new fail"); - return; - } - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::ConnectPhonePresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance fail"); - return; - } - backButton->SetPosition(65, 359, 324, 101); // 65:x, 359:y, 324:width 101:height - backButton->SetText("确定"); - backButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40:font data - backButton->SetImageSrc(PNG_NEW_DEVICE, PNG_NEW_DEVICE); - backButton->SetViewId(CONNECT_OPEN_BACK_BUTTON); - backButton->SetTextColor(Color::Blue()); - backButton->SetOnClickListener(clickListener); - group->Add(backButton); - } - if (tipImg == nullptr) { - tipImg = new UIImageView(); - if (tipImg == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectOpenView tipImg new fail"); - return; - } - tipImg->SetPosition(181, 58, 90, 90); // 181:x 58:y 90:width 90:height - tipImg->SetSrc(PNG_RIGHT); - group->Add(tipImg); - } - return; -} - -UIViewGroup *ConnectOpenView::InitShowUpView(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectOpenView::ShowUpViewInit"); - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - ShowUpBackView(); - UIView::OnDragListener *tipsDragListener = (UIView::OnDragListener *)OHOS::ConnectPhonePresenter::GetInstance(); - if (tipsDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "tipsDragListener GetInstance fail"); - return nullptr; - } - if (!PageTransitionMgr::GetInstance().CanSlideBack()) { // support default slide back firstly - group->SetOnDragListener(tipsDragListener); - } - group->SetViewId(CONNECT_OPEN_VIEW); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/connectnewphone/src/ConnectPhonePresenter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/connectnewphone/src/ConnectPhonePresenter.cpp deleted file mode 100644 index a9a89852c..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/connectnewphone/src/ConnectPhonePresenter.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Connect Phone Presenter - * Create: 2022-01-19 - */ - -#include "connectnewphone/ConnectPhonePresenter.h" -#include "connectnewphone/ConnectPhoneView.h" -#include "drag_event.h" -#include "cmsis_os.h" -#include "UiConfig.h" -#include "wearable_log.h" -#include "uiservice/ui_service.h" -#include "NativeRegisterManager.h" - -namespace OHOS { - -REGIST_SLICE(VIEW_CONNECT_PHONE, ConnectPhoneView, ConnectPhonePresenter); - -static ConnectPhonePresenter *g_pConnectPhonePresenter = nullptr; - -ConnectPhonePresenter::ConnectPhonePresenter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectPhonePresenter::ConnectPhonePresenter"); - g_pConnectPhonePresenter = this; -} - -ConnectPhonePresenter::~ConnectPhonePresenter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectPhonePresenter::~ConnectPhonePresenter"); - g_pConnectPhonePresenter = nullptr; -} - -ConnectPhonePresenter *ConnectPhonePresenter::GetInstance() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectPhonePresenter GetInstance"); - return g_pConnectPhonePresenter; -} - -bool ConnectPhonePresenter::OnClick(UIView& view, const ClickEvent& event) -{ - UNUSED(event); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnClick OnClick"); - if (strcmp(view.GetViewId(), CANCEL_BUTTON) == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CANCEL_BUTTON OnClick"); - NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); - } else if (strcmp(view.GetViewId(), CONFIRM_BUTTON) == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CONFIRM_BUTTON OnClick"); - ConfirmOnClick(); - if (ConnectPhoneView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectPhoneView::GetInstance() nullptr"); - return false; - } - ConnectPhoneView::GetInstance()->ChangeView(CONNECTSELECTVIEW, CONNECTOPENVIEW); - } else if (strcmp(view.GetViewId(), CONNECT_OPEN_BACK_BUTTON) == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CONNECT_OPEN_BACK_BUTTON OnClick"); - NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); - } - return true; -} - -void ConnectPhonePresenter::ConfirmOnClick() -{ - SendMsgToUIService(CONNECT_NEW_PHONE, 0, nullptr, 0); -} - -bool ConnectPhonePresenter::OnDrag(UIView& view, const DragEvent& event) -{ - std::string viewId = view.GetViewId(); - if ((viewId == CONNECT_SELECT_VIEW) || (viewId == CONNECT_OPEN_VIEW)) { - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectPhonePresenter::OnDrag"); - NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); - } - } - return true; -} - -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/connectnewphone/src/ConnectPhoneView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/connectnewphone/src/ConnectPhoneView.cpp deleted file mode 100644 index 1e5b1c109..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/connectnewphone/src/ConnectPhoneView.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Connect Phone View - * Create: 2022-01-19 - */ - -#include "connectnewphone/ConnectPhoneView.h" -#include "components/ui_label.h" -#include "wearable_log.h" -#include "UiConfig.h" - -namespace OHOS { -static ConnectPhoneView *g_pConnectPhoneView{nullptr}; - -ConnectPhoneView::ConnectPhoneView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectPhoneView::ConnectPhoneView"); - preProcessView[CONNECTSELECTVIEW] = &ConnectPhoneView::ChangeConnectSelectView; - preProcessView[CONNECTOPENVIEW] = &ConnectPhoneView::ChangeConnectOpenView; - g_pConnectPhoneView = this; -} - -ConnectPhoneView::~ConnectPhoneView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectPhoneView::~ConnectPhoneView"); - g_pConnectPhoneView = nullptr; -} - -ConnectPhoneView *ConnectPhoneView::GetInstance() -{ - return g_pConnectPhoneView; -} - -void ConnectPhoneView::OnStart() -{ - ChangeView(CONNECTPHONE_MAX, CONNECTSELECTVIEW); - return; -} - - -bool ConnectPhoneView::ChangeConnectSelectView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeConnectSelectView"); - connectSelectView = new ConnectSelectView(); - if (connectSelectView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "connectSelectView new fail"); - return false; - } - // init view - UIViewGroup *group = connectSelectView->InitShowUpView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool ConnectPhoneView::ChangeConnectOpenView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeConnectOpenView"); - connectOpenView = new ConnectOpenView(); - if (connectOpenView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "connectOpenView new fail"); - return false; - } - // init view - UIViewGroup *group = connectOpenView->InitShowUpView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool ConnectPhoneView::CheckViewParam(int16_t hideView, int16_t showView) -{ - if (showView < 0 || showView >= CONNECTPHONE_MAX) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectPhoneView::CheckViewParam showView err."); - return false; - } - - if (hideView < 0 || hideView > CONNECTPHONE_MAX) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectPhoneView::CheckViewParam hideView err."); - return false; - } - - return true; -} - -void ConnectPhoneView::ChangeView(int16_t hideView, int16_t showView) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectPhoneView::ChangeView %d, %d", hideView, showView); - - if (!CheckViewParam(hideView, showView)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectPhoneView::CheckViewParam failed."); - return; - } - - PreprosssChangeView tmpPreProcessView = preProcessView[showView]; - - if (!(this->*tmpPreProcessView)(hideView, showView)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectPhoneView::ChangeView %d %dfailed", showView, hideView); - return; - } - if (hideView != CONNECTPHONE_MAX) { - if (container[hideView] == nullptr) { - return; - } - container[hideView]->SetVisible(false); - } - container[showView]->SetVisible(true); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectPhoneView:: ChangeView end!!!%d", showView); - Draw(); -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/connectnewphone/src/ConnectSelectView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/connectnewphone/src/ConnectSelectView.cpp deleted file mode 100644 index 4465006bc..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/connectnewphone/src/ConnectSelectView.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: ConnectSelect View - * Create: 2022-03-22 - */ -#include "connectnewphone/ConnectSelectView.h" -#include "PageTransitionMgr.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "connectnewphone/ConnectPhonePresenter.h" - -namespace OHOS { -static ConnectSelectView *g_pConnectSelectView{nullptr}; - -ConnectSelectView::ConnectSelectView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectSelectView::ConnectSelectView"); - g_pConnectSelectView = this; -} - -ConnectSelectView::~ConnectSelectView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectSelectView::~ConnectSelectView"); - group->RemoveAll(); - delete titleLabel; - titleLabel = nullptr; - delete cancelButton; - cancelButton = nullptr; - delete confirmButton; - confirmButton = nullptr; - g_pConnectSelectView = nullptr; -} - -ConnectSelectView *ConnectSelectView::GetInstance() -{ - return g_pConnectSelectView; -} - -void ConnectSelectView::ShowUpTitleLabel() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectSelectView::ShowUpTitleLabel"); - if (titleLabel == nullptr) { - titleLabel = new UILabel(); - if (titleLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectSelectView titleLabel new fail"); - return; - } - titleLabel->SetPosition(65, 100, 324, 160); // 65:x, 100:y, 324:width, 160:height - titleLabel->SetText(" 将断开已连接的手 机,同一账号的新手机配对会保留个人数 据。是否继续?"); - titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); // 35:font data - titleLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - titleLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - group->Add(titleLabel); - } -} - -void ConnectSelectView::CreateUIButton() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectSelectView::CreateUIButton"); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::ConnectPhonePresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener nullptr"); - return; - } - if (cancelButton == nullptr) { - cancelButton = new UIButton(); - if (cancelButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectSelectView cancelButton new fail"); - return; - } - cancelButton->SetPosition(85, 320, 90, 90); // 85:x, 320:y, 90:width, 90:height - cancelButton->SetViewId(CANCEL_BUTTON); - cancelButton->SetImageSrc(ALARM_DELETE_ADD_PATH, ALARM_DELETE_ADD_PATH); - cancelButton->SetOnClickListener(clickListener); - group->Add(cancelButton); - } - if (confirmButton == nullptr) { - confirmButton = new UIButton(); - if (confirmButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectSelectView confirmButton new fail"); - return; - } - confirmButton->SetPosition(279, 320, 90, 90); // 279:x, 320:y, 90:width, 90:height - confirmButton->SetViewId(CONFIRM_BUTTON); - confirmButton->SetImageSrc(ALARM_TRUE_ADD_PATH, ALARM_TRUE_ADD_PATH); - confirmButton->SetOnClickListener(clickListener); - group->Add(confirmButton); - } -} - -UIViewGroup *ConnectSelectView::InitShowUpView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectSelectView init"); - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - ShowUpTitleLabel(); - CreateUIButton(); - UIView::OnDragListener *connectDragListener = (UIView::OnDragListener *)OHOS::ConnectPhonePresenter::GetInstance(); - if (connectDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "connectDragListener GetInstance fail"); - return nullptr; - } - if (!PageTransitionMgr::GetInstance().CanSlideBack()) { // support default slide back firstly - group->SetOnDragListener(connectDragListener); - } - group->SetViewId(CONNECT_SELECT_VIEW); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/date/src/DateAdapter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/date/src/DateAdapter.cpp deleted file mode 100644 index 944e5b6fc..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/date/src/DateAdapter.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: DateAdapter - * Create: 2025-03-23 - */ - -#include "date/DateAdapter.h" - -namespace OHOS { -DateAdapter::DateAdapter() {} - -DateAdapter::~DateAdapter() -{ - listData.clear(); -} - -uint16_t DateAdapter::GetCount(void) -{ - return listData.size(); -} - -void DateAdapter::SetData(std::list &data) -{ - if (!listData.empty()) { - listData.clear(); - } - std::list::iterator it; - for (it = data.begin(); it != data.end(); it++) { - listData.push_back(*it); - } -} - -UIView *DateAdapter::GetView(UIView *inView, int16_t index) -{ - if (listData.empty()) { - return nullptr; - } - if (index < 0) { - return nullptr; - } - size_t uindex = index; - if (uindex >= listData.size()) { - return nullptr; - } - - std::list::iterator it = listData.begin(); - for (int i = 0; i < index; i++) { - it++; - } - DateItem itemData = *it; - DateItemView *item = nullptr; - if (inView == nullptr) { - item = new DateItemView(); - } else { - item = static_cast(inView); - } - - item->SetItemInfo(itemData); - item->SetOnClickListener(itemClickListener); - return item; -} - -void DateAdapter::AddListItem(const DateItem &item) -{ - listData.push_back(item); -} - -void DateAdapter::ClearListItem() -{ - listData.clear(); -} - -} // namespace OHOS diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/date/src/DateButtonAdapter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/date/src/DateButtonAdapter.cpp deleted file mode 100644 index c187d094c..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/date/src/DateButtonAdapter.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: DateButtonAdapter - * Create: 2025-03-23 - */ - -#include "date/DateButtonAdapter.h" - -namespace OHOS { -DateButtonAdapter::DateButtonAdapter() {} - -DateButtonAdapter::~DateButtonAdapter() -{ - listData.clear(); -} - -uint16_t DateButtonAdapter::GetCount(void) -{ - return listData.size(); -} - -void DateButtonAdapter::SetData(std::list &data) -{ - if (!listData.empty()) { - listData.clear(); - } - std::list::iterator it; - for (it = data.begin(); it != data.end(); it++) { - listData.push_back(*it); - } -} - -UIView *DateButtonAdapter::GetView(UIView *inView, int16_t index) -{ - if (listData.empty()) { - return nullptr; - } - if (index < 0) { - return nullptr; - } - size_t uindex = index; - if (uindex >= listData.size()) { - return nullptr; - } - - std::list::iterator it = listData.begin(); - for (int i = 0; i < index; i++) { - it++; - } - DateButtonItem itemData = *it; - DateButtonItemView *item = nullptr; - if (inView == nullptr) { - item = new DateButtonItemView(); - } else { - item = static_cast(inView); - } - - item->SetItemInfo(itemData); - item->SetOnClickListener(itemClickListener); - return item; -} - -void DateButtonAdapter::AddListItem(const DateButtonItem &item) -{ - listData.push_back(item); -} - -void DateButtonAdapter::ClearListItem() -{ - listData.clear(); -} - -} // namespace OHOS diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/date/src/DateItemView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/date/src/DateItemView.cpp deleted file mode 100644 index a20141236..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/date/src/DateItemView.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: DateItemView - * Create: 2025-03-23 - */ - -#include "date/DateItemView.h" -#include "UiConfig.h" -#include "common/image_cache_manager.h" -#include "ui_resource_date.h" -#include "wearable_log.h" - -namespace OHOS { -static constexpr int16_t DATE_ITEM_BUTTON_HEIGHT = 65; -static constexpr int16_t DATE_ITEM_LABEL_POSITION_X = 43; -static constexpr int16_t DATE_ITEM_LABEL_POSITION_Y = 22; -static constexpr int16_t DATE_ITEM_LABEL_TWO_POSITION_X = 23; -static constexpr int16_t DATE_ITEM_LABEL_TWO_POSITION_Y = 60; -static constexpr int16_t DATE_ITEM_LABEL_WIDTH = 135; -static constexpr int16_t DATE_ITEM_LABEL_HEIGHT = 40; -static constexpr int16_t DATE_ITEM_LABEL2_HEIGHT = 96; -static constexpr int16_t DATE_ITEM_LABEL_TWO_WIDTH = 314; -static constexpr int16 DATE_ITEM_FONT_SIZE = 24; -static constexpr int16 DATE_ITEM_FONT2_SIZE = 32; -static constexpr int16_t DATE_ITEM_WIDTH = 376; -static constexpr int16_t DATE_ITEM_HEIGHT = 190; - -DateItemView::DateItemView() -{ - SetPosition(0, 0, DATE_ITEM_WIDTH, DATE_ITEM_HEIGHT); - SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - SetTouchable(true); - SetUpChild(); - - Add(&sLabel_1); - Add(&sLabel_2); - Add(&Signs); - Add(&BackGround); -} - -DateItemView::~DateItemView() -{ - Remove(&sLabel_1); - Remove(&sLabel_2); - Remove(&Signs); - Remove(&BackGround); -} - -void DateItemView::SetItemInfo(const DateItem itemInfo) -{ - sItemInfo = itemInfo; - sLabel_1.SetText(itemInfo.label_1); - sLabel_2.SetText(itemInfo.label_2); - BackGround.SetPosition(0, 0); - if (itemInfo.visiable) { - int offsetX1 = 100; - int offsetY1 = 10; - int offsetX2 = 30; - int offsetY2 = 40; - sLabel_1.SetPosition(DATE_ITEM_LABEL_POSITION_X + offsetX1, DATE_ITEM_LABEL_POSITION_Y + offsetY1); - sLabel_2.SetPosition(DATE_ITEM_LABEL_TWO_POSITION_X + offsetX2, DATE_ITEM_LABEL_TWO_POSITION_Y + offsetY2); - sLabel_1.SetStyle(STYLE_TEXT_COLOR, Color::White().full); - sLabel_2.SetStyle(STYLE_TEXT_COLOR, Color::Gray().full); - sLabel_1.SetFont(DEFAULT_VECTOR_FONT_FILENAME, DATE_ITEM_FONT2_SIZE); - sLabel_2.SetFont(DEFAULT_VECTOR_FONT_FILENAME, DATE_ITEM_FONT_SIZE); - Signs.SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - } else { - sLabel_1.SetPosition(DATE_ITEM_LABEL_POSITION_X, DATE_ITEM_LABEL_POSITION_Y); - sLabel_2.SetPosition(DATE_ITEM_LABEL_TWO_POSITION_X, DATE_ITEM_LABEL_TWO_POSITION_Y); - sLabel_1.SetStyle(STYLE_TEXT_COLOR, Color::Gray().full); - sLabel_2.SetStyle(STYLE_TEXT_COLOR, Color::White().full); - sLabel_1.SetFont(DEFAULT_VECTOR_FONT_FILENAME, DATE_ITEM_FONT_SIZE); - sLabel_2.SetFont(DEFAULT_VECTOR_FONT_FILENAME, DATE_ITEM_FONT2_SIZE); - Signs.SetPosition(DATE_ITEM_LABEL_TWO_POSITION_X, DATE_ITEM_FONT_SIZE); - } - Signs.SetVisible(!itemInfo.visiable); -} - -void DateItemView::SetUpChild() -{ - sLabel_1.Resize(DATE_ITEM_LABEL_WIDTH, DATE_ITEM_LABEL_HEIGHT); - sLabel_1.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT); - sLabel_1.SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE); - sLabel_1.SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - sLabel_1.SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - - sLabel_2.Resize(DATE_ITEM_LABEL_TWO_WIDTH, DATE_ITEM_LABEL2_HEIGHT); - sLabel_2.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT); - sLabel_2.SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE); - sLabel_2.SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - sLabel_2.SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - - ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes(IMAGE_CONVERTER_TOOL_DATE5, DATE_IMAGE); - if (image == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, - "DateMessagePage::OnStart LoadStopwatchImage IMAGE_CONVERTER_TOOL_DATE5 fail"); - return; - } - Signs.SetSrc(image); - image = ImageCacheManager::GetInstance().LoadOneInMultiRes(IMAGE_CONVERTER_TOOL_DATE1, DATE_IMAGE); - if (image == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, - "DateMessagePage::OnStart LoadStopwatchImage IMAGE_CONVERTER_TOOL_DATE1 fail"); - return; - } - BackGround.SetSrc(image); -} - -const char *DateItemView ::GetViewId() -{ - return sItemInfo.index; -} -bool DateItemView::GetVisiable() -{ - return sItemInfo.visiable; -} - -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/flashlight/src/FlashLightDefaultPage.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/flashlight/src/FlashLightDefaultPage.cpp deleted file mode 100644 index 7b6582c39..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/flashlight/src/FlashLightDefaultPage.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: FlashLightDefaultPage - * Create: 2025-04-24 - */ -#include "flashlight/FlashLightDefaultPage.h" -#include "flashlight/FlashLightPresenter.h" -#include "SlicePageFactory.h" -#include "flashlight/FlashLightView.h" -#include "AppViewIDs.h" -#include "wearable_log.h" -#include "NativeAbility.h" -#include "flashlight/FlashLightModel.h" -#include "main/LoadImg.h" -#include "flashlight/FlashlightUiResourceImage.h" -namespace OHOS { -static const uint16_t RECOVER_LABEL_POS_X = 15; -static const uint16_t RECOVER_LABEL_POS_Y = 185; -static const uint16_t RECOVER_LABEL_WIDTH = 424; -static const uint16_t RECOVER_LABEL_HEIGHT = 50; -static const uint16_t RECOVER_LABEL_FONT_SIZE = 36; -static const uint16_t CANCLE_BUTTON_POS_X = 115; -static const uint16_t CANCLE_BUTTON_POS_Y = 300; -static const uint16_t CONFIRM_BUTTON_POS_X = 255; -static const uint16_t CONFIRM_BUTTON_POS_Y = 300; -static const uint16_t CANCLE_BUTTON_WIDTH = 85; -static const uint16_t CANCLE_BUTTON_HEIGHT = 85; -static const std::string CANCLE_BUTTON_ID = "cancle"; -static const std::string CONFIRM_BUTTON_ID = "confirm"; - -REGIST_SLICE_PAGE(VIEW_FLASHLIGHT, FlashLightAllView::FLASH_LIGHT_DEFAULT_VIEW, FlashLightDefaultPage, false); -void FlashLightDefaultPage::OnStart(void *data) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FlashLightDefaultPage::OnStart"); - if (container_ == nullptr) { - container_ = new UIScrollView(); - container_->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); - } - - if (recoverLabel_ == nullptr) { - recoverLabel_ = new UILabel(); - } - recoverLabel_->SetPosition(RECOVER_LABEL_POS_X, RECOVER_LABEL_POS_Y, RECOVER_LABEL_WIDTH, RECOVER_LABEL_HEIGHT); - recoverLabel_->SetText("是否恢复默认设置"); - recoverLabel_->SetStyle(STYLE_TEXT_COLOR, Color::White().full); - recoverLabel_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - recoverLabel_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, RECOVER_LABEL_FONT_SIZE); - // Add to rootView - container_->Add(recoverLabel_); - recoverLabel_->SetVisible(true); - - if (cancelButton_ == nullptr) { - cancelButton_ = new UILabelButtonExt(); - } - cancelButton_->SetPosition(CANCLE_BUTTON_POS_X, CANCLE_BUTTON_POS_Y, CANCLE_BUTTON_WIDTH, CANCLE_BUTTON_HEIGHT); - cancelButton_->SetViewId(CANCLE_BUTTON_ID.c_str()); - LOADIMG::LoadBtnImage(cancelButton_, FLASHLIGHT_IMAGE, IMAGE_CONVERTER_TOOL_RECOVERCANCLE, - IMAGE_CONVERTER_TOOL_RECOVERCANCLE); - cancelButton_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - cancelButton_->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::Black().full, UIButton::PRESSED); - container_->Add(cancelButton_); - cancelButton_->SetVisible(true); - - if (confirmButton_ == nullptr) { - confirmButton_ = new UILabelButtonExt(); - } - confirmButton_->SetPosition(CONFIRM_BUTTON_POS_X, CONFIRM_BUTTON_POS_Y, CANCLE_BUTTON_WIDTH, CANCLE_BUTTON_HEIGHT); - confirmButton_->SetViewId(CONFIRM_BUTTON_ID.c_str()); - LOADIMG::LoadBtnImage(confirmButton_, FLASHLIGHT_IMAGE, IMAGE_CONVERTER_TOOL_RECOVERCONFIRM, - IMAGE_CONVERTER_TOOL_RECOVERCONFIRM); - confirmButton_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - confirmButton_->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::Black().full, UIButton::PRESSED); - container_->Add(confirmButton_); - confirmButton_->SetVisible(true); - - // 设置界面组件回调函数 - container_->SetOnDragListener(this); - cancelButton_->SetOnClickListener(this); - confirmButton_->SetOnClickListener(this); - AddViewToPageContainer(container_); -} - -FlashLightDefaultPage::~FlashLightDefaultPage() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FlashLightDefaultPage::~FlashLightDefaultPage"); - if (container_ != nullptr) { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } - if (recoverLabel_ != nullptr) { - delete recoverLabel_; - recoverLabel_ = nullptr; - } - if (cancelButton_ != nullptr) { - delete cancelButton_; - cancelButton_ = nullptr; - } - if (confirmButton_ != nullptr) { - delete confirmButton_; - confirmButton_ = nullptr; - } - ImageCacheManager::GetInstance().UnloadSingleRes(FLASHLIGHT_IMAGE); -} - -bool FlashLightDefaultPage::OnDrag(UIView &view, const DragEvent &event) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FlashLightColorPage::OnDrag"); - if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && (event.GetDeltaX() > X_DRAG_OFFSET) && - (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { - NativeAbility::GetInstance().SwitchSlice(VIEW_FLASHLIGHT, FlashLightAllView::FLASH_LIGHT_SET_VIEW); - } - return false; -} - -bool FlashLightDefaultPage::OnClick(UIView &view, const ClickEvent &event) -{ - std::string viewId = view.GetViewId(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FlashLightDefaultPage::OnClick [%s]", viewId.c_str()); - uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - if (viewId == CONFIRM_BUTTON_ID) { - NativeAbility::GetInstance().SwitchSlice(VIEW_FLASHLIGHT, FlashLightAllView::FLASH_LIGTH_VIEW); - FlashLightModel::GetInstance().SetDefault(); - } else if (viewId == CANCLE_BUTTON_ID) { - NativeAbility::GetInstance().SwitchSlice(VIEW_FLASHLIGHT, FlashLightAllView::FLASH_LIGHT_SET_VIEW); - } else { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FlashLightDefaultPage::OnClick [Invalid]"); - } - return false; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/flashlight/src/FlashLightSetItemAdapter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/flashlight/src/FlashLightSetItemAdapter.cpp deleted file mode 100644 index 2adbf459e..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/flashlight/src/FlashLightSetItemAdapter.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: FlashLightSetItemAdapter.cpp - * Create: 2025-11-23 - */ -#include "flashlight/FlashLightSetItemAdapter.h" -#include "flashlight/FlashLightSetItemView.h" - -namespace OHOS { -FlashLightSetItemAdapter::FlashLightSetItemAdapter() {} - -FlashLightSetItemAdapter::~FlashLightSetItemAdapter() -{ - itemDatas_.Clear(); -} - -uint16_t FlashLightSetItemAdapter::GetCount(void) -{ - return itemDatas_.Size(); -} - -void FlashLightSetItemAdapter::SetData(const Graphic::Vector &data) -{ - if (!itemDatas_.IsEmpty()) { - itemDatas_.Clear(); - } - itemDatas_ = data; -} - -UIView *FlashLightSetItemAdapter::GetView(UIView *inView, int16_t index) -{ - if (itemDatas_.IsEmpty()) { - return nullptr; - } - - if (index >= itemDatas_.Size() || index < 0) { - return nullptr; - } - - FlashLightSetItem itemData = itemDatas_[index]; - FlashLightSetItemView *item = nullptr; - if (inView == nullptr) { - item = new FlashLightSetItemView(); - } else { - item = static_cast(inView); - } - item->SetItemInfo(itemData); - item->SetViewId(itemData.label.c_str()); - item->SetOnClickListener(itemClickListener); - return item; -} - -void FlashLightSetItemAdapter::AddListItem(const FlashLightSetItem &item) -{ - itemDatas_.PushBack(item); -} -} // namespace OHOS diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/heartrate/src/HeartRateView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/heartrate/src/HeartRateView.cpp deleted file mode 100644 index 2c9b2c42e..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/heartrate/src/HeartRateView.cpp +++ /dev/null @@ -1,786 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: heartRate view - * Author: - * Create: 2021-07-26 - */ - -#include -#include "heartrate/HeartRateView.h" -#include "common/screen.h" -#include "UiConfig.h" -#include "screensetting/ScreenModels.h" -#include "ui_resource_image.h" -#include "common/image_cache_manager.h" - -namespace OHOS { -static HeartRateView *g_pHeartRateView = nullptr; - -// 背景坐标图形 -#define ACT_IMAGE_X 0 // 图片坐标起点 -#define ACT_IMAGE_Y 115 // 图片坐标起点 -#define ACT_IMAGE_COOR_X 45 // 200刻度线到最左端的像素点 -#define ACT_IMAGE_COOR_Y 145 // 200刻度线到顶端的像素点 -#define ACT_IMAGE_COOR_PIXELS 160 // 实际背景坐标0到200心率值的实际像素点 -#define ACT_IMAGE_COOR_VALUE HEART_RATE_LIMIT_UPPER // 图片刻度表示的心率范围 -#define ACT_IMAGE_COOR_WIDTH 454 -#define ACT_IMAGE_COOR_HEIGHT 220 - -// 心电图坐标适配 -#define COORDINATE_VALUE 5 // 余量 -#define COORDINATE_POINT_X (ACT_IMAGE_COOR_X - COORDINATE_VALUE) -#define COORDINATE_POINT_Y (ACT_IMAGE_COOR_Y - COORDINATE_VALUE * 2) -#define COORDINATE_HEIGHT (ACT_IMAGE_COOR_PIXELS + COORDINATE_VALUE * 2) -#define COORDINATE_WIDTH (HEART_AVE_NUM + COORDINATE_VALUE * 2) // 360点,每点对应240秒(4分钟) -#define COORDINATE_GRAD_MIN_OPA 25 -#define COORDINATE_GRAD_MAX_OPA 180 - -// 心形心跳 -#define HEARTBEAT_IMAGE_WIDTH 92 -#define HEARTBEAT_IMAGE_HEIGHT 92 -#define HEARTBEAT_IMAGE_X 130 -#define HEARTBEAT_IMAGE_Y 25 -#define HEARTBEAT_IMAGE_NUM 19 -#define HEARTBEAT_DELAY 50 - -// 最高心率 -#define TOP_IMAGE_WIDTH 32 -#define TOP_IMAGE_HEIGHT 32 -#define TOP_IMAGE_X 120 -#define TOP_IMAGE_Y 340 -#define TOP_STROKE_WIDTH 1 -#define TOP_RADIUS 4 - -#define HEART_RATE_LIMIT_FONT_SIZE 30 -#define TOP_TEXT_WIDTH 80 -#define TOP_TEXT_HEIGHT (HEART_RATE_LIMIT_FONT_SIZE + 5) -#define TOP_TEXT_X 160 -#define TOP_TEXT_Y 337 - -// 最低心率 -#define BOTTOM_IMAGE_WIDTH 32 -#define BOTTOM_IMAGE_HEIGHT 32 -#define BOTTOM_IMAGE_X 250 -#define BOTTOM_IMAGE_Y 340 -#define BOTTOM_STROKE_WIDTH 1 -#define BOTTOM_RADIUS 3 - -#define BOTTOM_TEXT_WIDTH 80 -#define BOTTOM_TEXT_HEIGHT (HEART_RATE_LIMIT_FONT_SIZE + 5) -#define BOTTOM_TEXT_X 290 -#define BOTTOM_TEXT_Y 337 - -// 静息心率 -#define REST_HEART_RATE_FONT_SIZE 40 -#define REST_HEART_RATE_X 195 -#define REST_HEART_RATE_Y 380 -#define REST_HEART_RATE_WIDTH 95 -#define REST_HEART_RATE_HEIGHT (REST_HEART_RATE_FONT_SIZE + 5) - -#define REST_HEART_TEXT_FONT_SIZE 30 -#define REST_HEART_TEXT_X1 120 -#define REST_HEART_TEXT_Y1 390 -#define REST_HEART_TEXT_WIDTH1 75 -#define REST_HEART_TEXT_HEIGHT1 (REST_HEART_TEXT_FONT_SIZE + 5) - -#define REST_HEART_TEXT_X2 265 -#define REST_HEART_TEXT_Y2 390 -#define REST_HEART_TEXT_WIDTH2 75 -#define REST_HEART_TEXT_HEIGHT2 (REST_HEART_TEXT_FONT_SIZE + 5) - -// 每秒心率 -#define PERSEC_HEART_RATE_FONT_SIZE 45 -#define PERSEC_HEART_RATE_X 225 -#define PERSEC_HEART_RATE_Y 55 -#define PERSEC_HEART_RATE_WIDTH 90 -#define PERSEC_HEART_RATE_HEIGHT (PERSEC_HEART_RATE_FONT_SIZE + 5) - -#define PERSEC_HEART_TEXT_FONT_SIZE 30 -#define PERSEC_HEART_TEXT_X 310 -#define PERSEC_HEART_TEXT_Y 75 -#define PERSEC_HEART_TEXT_WIDTH 75 -#define PERSEC_HEART_TEXT_HEIGHT (PERSEC_HEART_TEXT_FONT_SIZE + 5) - -// 心跳image -static ImageAnimatorInfo g_heartBeatImageInfo[HEARTBEAT_IMAGE_NUM] = { - {PNG_A004_070_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_071_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_072_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_073_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_074_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_075_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_076_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_077_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_078_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_079_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - - {PNG_A004_080_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_081_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_082_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_083_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_084_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_085_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_086_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_087_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_088_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, -}; - -HeartRateView::HeartRateView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartRateView::HeartRateView"); - dataNume = 0; - currIndex = 0; - serialIndex = 0; - maxRate = 0; - minRate = HEART_RATE_LIMIT_UPPER; - InitHeartRateData(); - SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - - g_pHeartRateView = this; -} - -HeartRateView::~HeartRateView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartRateView::~HeartRateView"); - if (viewiInitStatus) { - int32_t i; - RemoveAll(); - delete imageViewCoordinate; - imageViewCoordinate = nullptr; - - chart->ClearDataSerial(); - for (i = 0; i < HEART_AVE_NUM; i++) { - delete dataSerial[i]; - dataSerial[i] = nullptr; - } - delete chart; - chart = nullptr; - delete imageViewTop; - imageViewTop = nullptr; - delete imageViewBottom; - imageViewBottom = nullptr; - delete dataTopAndbottom; - dataTopAndbottom = nullptr; - imageAnimator->Stop(); - delete imageAnimator; - imageAnimator = nullptr; - delete topRate; - topRate = nullptr; - delete bottomRate; - bottomRate = nullptr; - delete ratePerSec; - ratePerSec = nullptr; - delete ratePerSecText; - ratePerSecText = nullptr; - delete restRate; - restRate = nullptr; - delete restRateText1; - restRateText1 = nullptr; - delete restRateText2; - restRateText2 = nullptr; - } - g_pHeartRateView = nullptr; -} - -HeartRateView *HeartRateView::GetInstance(void) -{ - return g_pHeartRateView; -} - -int32_t HeartRateView::InitHeartRateData(void) // 初始化心率数据,将存放心率数据的有效字节设置为无效值 -{ - heartRateData[0].x = INVALID_HEART_VALUE; - heartRateData[0].y = INVALID_HEART_VALUE; - - int32_t ret = memset_s(heartRateData, sizeof(Point) * HEART_AVE_NUM, INVALID_HEART_VALUE, sizeof(Point) * HEART_AVE_NUM); - if (ret != 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartRateView::[InitHeartRateData] memset_s heartRateData fail! ret = %d", ret); - } - return ret; -} - -int32_t HeartRateView::SetHeartRateData(Point *rateData, uint32 rateDataSize) -{ - if (rateData == nullptr) { - return OHOS_FAILURE; - } - - if (rateDataSize > sizeof(Point) * HEART_AVE_NUM) { - rateDataSize = sizeof(Point) * HEART_AVE_NUM; - } - InitHeartRateData(); - int32_t ret = memcpy_s(heartRateData, sizeof(Point) * HEART_AVE_NUM, rateData, rateDataSize); - if (ret != EOK) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartRateView::[HeartRateDataProc] memcpy_s heartRateData fail! ret = %d", ret); - return OHOS_FAILURE; - } - return OHOS_SUCCESS; -} - - -int32_t HeartRateView::HeartRateDataProc(void) -{ - Point datain[HEART_AVE_NUM]; - int32_t ret = memcpy_s(datain, sizeof(Point) * HEART_AVE_NUM, heartRateData, sizeof(Point) * HEART_AVE_NUM); - if (ret != EOK) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartRateView::[HeartRateDataProc] memcpy_s rateDataTmp fail! ret = %d", ret); - return OHOS_FAILURE; - } - - ret = memset_s(rateDataTmp, sizeof(Point) * HEART_AVE_NUM, INVALID_HEART_VALUE, sizeof(Point) * HEART_AVE_NUM); // 替换为无效值 - if (ret != EOK) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartRateView::[HeartRateDataProc] memset_s rateDataTmp fail! ret = %d", ret); - return OHOS_FAILURE; - } - - dataNume = 0; - for (int32_t i = 0; i < HEART_AVE_NUM; i++) { - if (datain[i].x >= 0 && datain[i].x < HEART_AVE_NUM && datain[i].y > 0 && - datain[i].y <= HEART_RATE_LIMIT_UPPER) { - rateDataTmp[dataNume].x = datain[i].x + COORDINATE_VALUE; - rateDataTmp[dataNume].y = datain[i].y * ACT_IMAGE_COOR_PIXELS / ACT_IMAGE_COOR_VALUE; - dataNume++; - } - } - return OHOS_SUCCESS; -} - -void HeartRateView::SetLabel(UILabel *label, LabelInfo labelInfo) -{ - label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelInfo.fontSize); - label->SetPosition(labelInfo.x, labelInfo.y); - label->Resize(labelInfo.width, labelInfo.height); - label->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - Add(label); -} - -void HeartRateView::HeartRateLabelDisplay(void) -{ - LabelInfo PerSecLabel = { PERSEC_HEART_RATE_FONT_SIZE, PERSEC_HEART_RATE_X, PERSEC_HEART_RATE_Y, - PERSEC_HEART_RATE_WIDTH, PERSEC_HEART_RATE_HEIGHT }; - LabelInfo PerSecTextLabel = { PERSEC_HEART_TEXT_FONT_SIZE, PERSEC_HEART_TEXT_X, PERSEC_HEART_TEXT_Y, - PERSEC_HEART_TEXT_WIDTH, PERSEC_HEART_TEXT_HEIGHT }; - - LabelInfo topLabel = { HEART_RATE_LIMIT_FONT_SIZE, TOP_TEXT_X, TOP_TEXT_Y, TOP_TEXT_WIDTH, TOP_TEXT_HEIGHT }; - LabelInfo bottomLabel = { HEART_RATE_LIMIT_FONT_SIZE, BOTTOM_TEXT_X, BOTTOM_TEXT_Y, BOTTOM_TEXT_WIDTH, - BOTTOM_TEXT_HEIGHT }; - - LabelInfo restRateLabel = { REST_HEART_RATE_FONT_SIZE, REST_HEART_RATE_X, REST_HEART_RATE_Y, REST_HEART_RATE_WIDTH, - REST_HEART_RATE_HEIGHT }; - LabelInfo restRateTextLabel1 = { REST_HEART_TEXT_FONT_SIZE, REST_HEART_TEXT_X1, REST_HEART_TEXT_Y1, - REST_HEART_TEXT_WIDTH1, REST_HEART_TEXT_HEIGHT1 }; - LabelInfo restRateTextLabel2 = { REST_HEART_TEXT_FONT_SIZE, REST_HEART_TEXT_X2, REST_HEART_TEXT_Y2, - REST_HEART_TEXT_WIDTH2, REST_HEART_TEXT_HEIGHT2 }; - - topRate = new UILabel(); - bottomRate = new UILabel(); - ratePerSec = new UILabel(); - ratePerSecText = new UILabel(); - restRate = new UILabel(); - restRateText1 = new UILabel(); - restRateText2 = new UILabel(); - - if (topRate == nullptr || bottomRate == nullptr || ratePerSec == nullptr || ratePerSecText == nullptr || - restRate == nullptr || restRateText1 == nullptr || restRateText2 == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartRateView::[HeartRateLabelDisplay] new UILabel fail"); - } - - // 实时心率 - SetLabel(ratePerSec, PerSecLabel); - SetLabel(ratePerSecText, PerSecTextLabel); - ratePerSec->SetText("--"); - ratePerSecText->SetText("次/分"); - - // 最高最低心率 - SetLabel(topRate, topLabel); - SetLabel(bottomRate, bottomLabel); - topRate->SetText("--"); - bottomRate->SetText("--"); - - // 静息心率 - SetLabel(restRate, restRateLabel); - SetLabel(restRateText1, restRateTextLabel1); - SetLabel(restRateText2, restRateTextLabel2); - restRateText1->SetText("静息"); - restRate->SetText("--"); - restRateText2->SetText("次/分"); -} - -void HeartRateView::HeartRateCoordinate(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartRateView::HeartRateCoordinate start"); - // 坐标图片 - imageViewCoordinate = new UIImageView(); - if (imageViewCoordinate == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartRateView::[HeartRateCoordinate] new imageViewCoordinate fail"); - return; - } - imageViewCoordinate->SetPosition(ACT_IMAGE_X, ACT_IMAGE_Y); - imageViewCoordinate->SetWidth(ACT_IMAGE_COOR_WIDTH); - imageViewCoordinate->SetHeight(ACT_IMAGE_COOR_HEIGHT); - Add(imageViewCoordinate); - - // 心电图坐标适配 - chart = new UIChartPolyline(); - if (chart == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartRateView::[HeartRateCoordinate] new chart fail"); - return; - } - chart->SetPosition(COORDINATE_POINT_X, COORDINATE_POINT_Y); - chart->SetWidth(COORDINATE_WIDTH); - chart->SetHeight(COORDINATE_HEIGHT); - chart->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - chart->SetStyle(STYLE_BACKGROUND_OPA, 0); - chart->SetStyle(STYLE_LINE_WIDTH, 1); // line width - - UIXAxis &xAxis = chart->GetXAxis(); - UIYAxis &yAxis = chart->GetYAxis(); - xAxis.SetDataRange(0, COORDINATE_WIDTH); // 24小时对应的秒数 - yAxis.SetDataRange(0, COORDINATE_HEIGHT); - xAxis.SetLineColor(Color::GetColorFromRGBA(0, 0, 0, 0)); - yAxis.SetLineColor(Color::GetColorFromRGBA(0, 0, 0, 0)); - chart->SetGradientOpacity(COORDINATE_GRAD_MIN_OPA, COORDINATE_GRAD_MAX_OPA); - Add(chart); -} - -void HeartRateView::InsertTopAndBottomRateImage(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartRateView::InsertTopAndBottomRateImage start"); - imageViewTop = new UIImageView(); - imageViewBottom = new UIImageView(); - if (imageViewTop == nullptr || imageViewBottom == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartRateView::[InsertTopAndBottomRateImage] new imageViewTop or imageViewBottom fail"); - return; - } - imageViewTop->SetPosition(TOP_IMAGE_X, TOP_IMAGE_Y); - imageViewTop->SetWidth(TOP_IMAGE_WIDTH); - imageViewTop->SetHeight(TOP_IMAGE_HEIGHT); - Add(imageViewTop); - imageViewBottom->SetPosition(BOTTOM_IMAGE_X, BOTTOM_IMAGE_Y); - imageViewBottom->SetWidth(BOTTOM_IMAGE_WIDTH); - imageViewBottom->SetHeight(BOTTOM_IMAGE_HEIGHT); - Add(imageViewBottom); -} - -void HeartRateView::UpdataTopAndBottomRate(void) -{ - if (chart == nullptr) { - return; - } - if (dataTopAndbottom != nullptr) { - chart->DeleteDataSerial(dataTopAndbottom); - delete dataTopAndbottom; - dataTopAndbottom = nullptr; - } - dataTopAndbottom = new UIChartDataSerial(); - if (dataTopAndbottom == nullptr) { - return; - } - if (dataNume != 1) { - dataTopAndbottom->SetMaxDataCount(dataNume); // number of data points - dataTopAndbottom->AddPoints(rateDataTmp, dataNume); // number of data points - } else { - Point tmp[NUM_2]; - tmp[0].x = tmp[1].x = rateDataTmp[0].x; - tmp[0].y = tmp[1].y = rateDataTmp[0].y; - dataTopAndbottom->SetMaxDataCount(NUM_2); // number of data points - dataTopAndbottom->AddPoints(tmp, NUM_2); // number of data points - } - dataTopAndbottom->SetLineColor(Color::GetColorFromRGBA(0, 0, 0, 0)); // 设置透明 - chart->AddDataSerial(dataTopAndbottom); - chart->Invalidate(); - - UIChartDataSerial::PointStyle pointStyle; - // 最低心跳 - dataTopAndbottom->EnableBottomPoint(true); - pointStyle.radius = BOTTOM_RADIUS; // Inner radius - pointStyle.fillColor = Color::Gray(); - pointStyle.strokeWidth = BOTTOM_STROKE_WIDTH; // border width - pointStyle.strokeColor = Color::Black(); - dataTopAndbottom->SetBottomPointStyle(pointStyle); - chart->Invalidate(); - - uint16_t bottom = dataTopAndbottom->GetValleyData() * ACT_IMAGE_COOR_VALUE / ACT_IMAGE_COOR_PIXELS; - // 最高心跳 - dataTopAndbottom->EnableTopPoint(true); - pointStyle.fillColor = Color::Red(); - pointStyle.radius = TOP_RADIUS; // Inner radius - pointStyle.strokeColor = Color::Black(); - pointStyle.strokeWidth = TOP_STROKE_WIDTH; // border width - dataTopAndbottom->SetTopPointStyle(pointStyle); - chart->Invalidate(); - - uint16_t top = dataTopAndbottom->GetPeakData() * ACT_IMAGE_COOR_VALUE / ACT_IMAGE_COOR_PIXELS; - if (top <= HEART_RATE_LIMIT_UPPER) { - maxRate = (maxRate >= top) ? maxRate : top; - } - if (bottom != 0) { - minRate = (minRate <= bottom) ? minRate : bottom; - } -} - -void HeartRateView::ElectrocardiogramOnePoint(Point *rateData, uint16_t index) -{ - Point tmp[NUM_2]; - - if (rateData == nullptr || chart == nullptr || index >= HEART_AVE_NUM || serialIndex >= HEART_AVE_NUM) { - return; - } - - tmp[0].x = tmp[1].x = rateData[index].x; - tmp[0].y = tmp[1].y = rateData[index].y; - - dataSerial[serialIndex] = new UIChartDataSerial(); - if (dataSerial[serialIndex] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartRateView::[ElectrocardiogramOnePoint] new dataSerial[%d] fail", serialIndex); - serialIndex++; - return; - } - - dataSerial[serialIndex]->SetMaxDataCount(HEART_AVE_NUM); // 设置最大显示的像素点 - dataSerial[serialIndex]->AddPoints(tmp, NUM_2); - dataSerial[serialIndex]->SetLineColor(Color::Red()); - dataSerial[serialIndex]->SetFillColor(Color::Red()); - dataSerial[serialIndex]->EnableGradient(true); - - chart->AddDataSerial(dataSerial[serialIndex]); - chart->Invalidate(); - serialIndex++; -} - -void HeartRateView::ElectrocardiogramMultiPoint(Point *rateData, uint16_t rateDataNume) -{ - uint16_t i = 0; - uint16_t j = 0; - uint16_t tmp = 1; - if (rateData == nullptr || chart == nullptr || rateDataNume > HEART_AVE_NUM) { - return; - } - - while (i < rateDataNume) { - while ((j + 1 < rateDataNume) && (rateData[j + 1].x - rateData[j].x <= NUM_4)) { // 15分钟对应的秒数 - tmp++; - j++; - } - if (tmp == 1) { - ElectrocardiogramOnePoint(rateData, i); - } else { - if (serialIndex >= HEART_AVE_NUM) { - return; - } - if (serialIndex > 0 && dataSerial[serialIndex - 1] != nullptr && i == 0) { - dataSerial[serialIndex - 1]->AddPoints(rateData + 1, tmp - 1); // number of data points - chart->Invalidate(); - } else { - dataSerial[serialIndex] = new UIChartDataSerial(); - if (dataSerial[serialIndex] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartRateView::[ElectrocardiogramMultiPoint] new dataSerial[%d] fail", serialIndex); - serialIndex++; - return; - } - - dataSerial[serialIndex]->SetMaxDataCount(HEART_AVE_NUM); // number of data points - dataSerial[serialIndex]->AddPoints(rateData + i, tmp); // number of data points - dataSerial[serialIndex]->SetLineColor(Color::Red()); - dataSerial[serialIndex]->SetFillColor(Color::Red()); - dataSerial[serialIndex]->EnableGradient(true); - - chart->AddDataSerial(dataSerial[serialIndex]); - chart->Invalidate(); - serialIndex++; - } - } - i += tmp; - j = i; - tmp = 1; - } -} - -void HeartRateView::HeartRateElectrocardiogram(void) -{ - if (dataNume == 0) { - return; - } - serialIndex = 0; - if (dataNume != 1) { - ElectrocardiogramMultiPoint(rateDataTmp, dataNume); // 多个点 - } else { - ElectrocardiogramOnePoint(rateDataTmp, 0); // 一个点 - } - currIndex = dataNume; -} - -void HeartRateView::HeartbeatImageAnimator() -{ - imageAnimator = new UIImageAnimatorView(); - if (imageAnimator == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartRateView::[HeartbeatImageAnimator] new imageAnimator fail"); - return; - } - imageAnimator->SetPosition(HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT); - imageAnimator->SetImageAnimatorSrc(g_heartBeatImageInfo, HEARTBEAT_IMAGE_NUM, HEARTBEAT_DELAY); - imageAnimator->SetRepeat(true); - Add(imageAnimator); - imageAnimator->Start(); -} - -void HeartRateView::HeartbeatImageAnimatorStart(void) -{ - if (imageAnimator != nullptr) { - imageAnimator->Start(); - } -} - -void HeartRateView::HeartbeatImageAnimatorStop(void) -{ - if (imageAnimator != nullptr) { - imageAnimator->Stop(); - } -} - -bool HeartRateView::InitView(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartRateView::HeartRateView::InitView"); - HeartRateDataProc(); - HeartRateLabelDisplay(); - HeartbeatImageAnimator(); - HeartRateCoordinate(); - InsertTopAndBottomRateImage(); - HeartRateElectrocardiogram(); - UpdataTopAndBottomRate(); - HeartbeatImageAnimatorStop(); - InitRefreshInterface(); - return true; -} - -void HeartRateView::PreLoad(void) -{ - if (!viewiInitStatus) { - if (InitView()) { - viewiInitStatus = true; - } - } - - if (!resLoadStatus) { - ScreenModels::GetInstance()->LoadAppImages(HEART_IAMGES, imageViewTop, HEART_HEARTRATE_TOP); - ScreenModels::GetInstance()->LoadAppImages(HEART_IAMGES, imageViewBottom, HEART_HEARTRATE_BOTTOM); - ScreenModels::GetInstance()->LoadAppImages(HEART_IAMGES, imageViewCoordinate, HEART_HEARTRATECOOR); - resLoadStatus = true; - } -} - -void HeartRateView::UnLoad(void) -{ - if (resLoadStatus) { - ImageInfo* img = nullptr; - imageViewTop->SetSrc(img); - imageViewBottom->SetSrc(img); - imageViewCoordinate->SetSrc(img); - ImageCacheManager::GetInstance().UnloadAllInMultiRes(HEART_IAMGES); - resLoadStatus = false; - } -} - -void HeartRateView::InitRefreshInterface(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartRateView::HeartRateView::InitRefreshInterface"); - - Point *rateData = HeartModel::GetInstance()->GetAveHeartRate(); - uint16_t len = HeartModel::GetInstance()->GetAveHeartRateCount(); - SetHeartRateData(rateData, sizeof(Point) * len); - uint16_t maxHeartRate = HeartModel::GetInstance()->GetHeartRateMax(); - uint16_t minHeartRate = HeartModel::GetInstance()->GetHeartRateMin(); - RefreshElectrocardiogram(); - if (maxHeartRate > 0 && maxHeartRate < HEART_RATE_LIMIT_UPPER) { - RefreshHeartRateMax(HeartModel::GetInstance()->GetHeartRateMax()); - } - if (minHeartRate > 0 && minHeartRate < HEART_RATE_LIMIT_UPPER) { - RefreshHeartRateMin(HeartModel::GetInstance()->GetHeartRateMin()); - } -} - -// 刷新心率曲线 -void HeartRateView::RefreshElectrocardiogram(void) -{ - int32_t ret = HeartRateDataProc(); - if (ret != OHOS_SUCCESS) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartRateView::[RefreshElectrocardiogram()] fail"); - return; - } - Point *rate = rateDataTmp; - - if (chart == nullptr) { - return; - } - - if (currIndex >= HEART_AVE_NUM) { - currIndex = HEART_AVE_NUM; - } - if (dataNume > currIndex) { - uint16_t tmp = dataNume - currIndex; - if (currIndex > 0) { - rate += (currIndex - 1); - tmp += 1; - } - ElectrocardiogramMultiPoint(rate, tmp); - currIndex = dataNume; - } else if (dataNume == currIndex) { // 当前点平均心率刷新 - if (serialIndex > 0 && serialIndex <= HEART_AVE_NUM && dataSerial[serialIndex - 1] != nullptr) { - Point modPoint; - modPoint.x = rate[currIndex - 1].x; - modPoint.y = rate[currIndex - 1].y; - - uint16_t count = dataSerial[serialIndex - 1]->GetDataCount(); - dataSerial[serialIndex - 1]->ModifyPoint(count - 1, modPoint); - chart->Invalidate(); - } - } else { - return; - } - UpdataTopAndBottomRate(); // 最高、最低心率 -} - -// 清空心率曲线 -void HeartRateView::ClearElectrocardiogram(void) -{ - int32_t i; - dataNume = 0; - currIndex = 0; - maxRate = 0; - minRate = HEART_RATE_LIMIT_UPPER; - InitHeartRateData(); - - if (chart == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "chart == nullptr"); - return; - } - - if (ratePerSec != nullptr && topRate != nullptr && bottomRate != nullptr && restRate != nullptr) { - ratePerSec->SetText("--"); - topRate->SetText("--"); - bottomRate->SetText("--"); - restRate->SetText("--"); - } - - chart->DeleteDataSerial(dataTopAndbottom); - delete dataTopAndbottom; - dataTopAndbottom = nullptr; - for (i = 0; i < serialIndex; i++) { - delete dataSerial[i]; - dataSerial[i] = nullptr; - } - chart->ClearDataSerial(); - - serialIndex = 0; - chart->Invalidate(); -} - -// 刷新每秒上报的心率 -void HeartRateView::RefreshHeartRatePerSec(uint16_t value) -{ - char heartRate[NUM_4] = "--"; - int32_t ret = 0; - - if (ratePerSec == nullptr) { - return; - } - - if (value == 0) { - ratePerSec->SetText("--"); - HeartbeatImageAnimatorStop(); - return; - } - HeartbeatImageAnimatorStart(); - if (value > NUM_99) { - ret = sprintf_s(heartRate, sizeof(heartRate), "%u", value); - } else { - ret = sprintf_s(heartRate, sizeof(heartRate), " %u", value); - } - if (ret > EOK) { - ratePerSec->SetText(heartRate); - } -} - -// 刷新最大心率 -void HeartRateView::RefreshHeartRateMax(uint16_t max) -{ - char top[NUM_4] = "--"; - int32_t ret = 0; - maxRate = (maxRate >= max) ? maxRate : max; - if (topRate == nullptr) { - return; - } - if (maxRate <= HEART_RATE_LIMIT_LOWER) { - topRate->SetText("--"); - return; - } - ret = sprintf_s(top, sizeof(top), "%u", maxRate); - if (ret > EOK) { - topRate->SetText(top); - } -} - -// 刷新最小心率 -void HeartRateView::RefreshHeartRateMin(uint16_t min) -{ - char bottom[NUM_4] = "--"; - int32_t ret = 0; - - minRate = (minRate <= min) ? minRate : min; - if (bottomRate == nullptr) { - return; - } - if (minRate >= HEART_RATE_LIMIT_UPPER) { - bottomRate->SetText("--"); - return; - } - ret = sprintf_s(bottom, sizeof(bottom), "%u", minRate); - if (ret > EOK) { - bottomRate->SetText(bottom); - } -} - -// 刷新静息心率 -void HeartRateView::RefreshRestHeartRate(uint16_t value) -{ - char heartRate[NUM_4] = "--"; - int32_t ret = 0; - - if (restRate == nullptr) { - return; - } - - if (value == 0 || value == (uint16_t)0xFFFF) { // 无效值 - restRate->SetText("--"); - } else { - if (value > NUM_99) { - ret = sprintf_s(heartRate, sizeof(heartRate), "%u", value); - } else { - ret = sprintf_s(heartRate, sizeof(heartRate), " %u", value); - } - - if (ret > EOK) { - restRate->SetText(heartRate); - } - } -} -} // namespace OHOS diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/add_card/AddCardAdapter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/add_card/AddCardAdapter.h deleted file mode 100644 index a819ed10c..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/add_card/AddCardAdapter.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: AddCardAdapter.h - * Author: - * Create: 2021-09-18 - */ - -#ifndef ADD_CARD_ADAPTER_H -#define ADD_CARD_ADAPTER_H - -#include -#include -#include "components/ui_list.h" -#include "components/ui_label.h" -#include "components/ui_view_group.h" -#include "components/ui_image_view.h" -#include "components/abstract_adapter.h" -#include "UiConfig.h" -#include "wearable_log.h" -#include "add_card/AddCardItem.h" - -namespace OHOS { -class AddCardAdapter : public AbstractAdapter { -public: - explicit AddCardAdapter(); - ~AddCardAdapter() override; - - uint16 GetCount(void) override; - - UIView *GetView(UIView *inView, int16 index) override; - - void AddListItem(const AddCardInfo &item); - - void SetItemClickListener(UIView::OnClickListener *itemClickListener) - { - itemClickListener_ = itemClickListener; - } - - void ClearItem(void); - -private: - std::list listData_; - UIView::OnClickListener *itemClickListener_; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/add_card/AddCardItem.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/add_card/AddCardItem.h deleted file mode 100644 index 5325f4e22..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/add_card/AddCardItem.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: AddCardItem.h - * Author: - * Create: 2021-11-23 - */ - -#ifndef ADD_CARD_ITEM_H -#define ADD_CARD_ITEM_H - -#include -#include -#include "components/ui_view.h" -#include "components/ui_view_group.h" -#include "components/ui_image_view.h" -#include "components/ui_label_button.h" -#include "UiConfig.h" - -namespace OHOS { -typedef struct { - CardId id; - bool addFlag; - const char *cardImg; -} AddCardInfo; - -class AddCardItem : public UIViewGroup { -public: - AddCardItem(); - ~AddCardItem() override; - void SetItemInfo(const AddCardInfo &cardInfo); - void SetOnClickListener(OnClickListener *onClickListener); - void UpdateItemInfo(bool addFlag); -private: - void SetUpChild(); - UIImageView cardImg_; - UILabelButton cardLabel_; - AddCardInfo cardInfo_; -}; - -} - -#endif // ADD_CARD_ITEM_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/add_card/AddCardModel.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/add_card/AddCardModel.h deleted file mode 100644 index 0ef22336e..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/add_card/AddCardModel.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: AddCardModel.h - * Author: - * Create: 2021-11-23 - */ - -#ifndef ADD_CARD_MODEL_H -#define ADD_CARD_MODEL_H - -#include -#include -#include "AppViewIDs.h" -#include "UiConfig.h" -#include "add_card/AddCardPresenter.h" -#include "main/MainModel.h" - -namespace OHOS { - class AddCardModel { - public: - static AddCardModel &GetInstance(void); - void SetSelectedCardIndex(uint8_t cardIndex); - uint8_t GetSelectedCardIndex(void) const; - void AddCardSetting(void); - private: - AddCardModel(); - AddCardModel(const AddCardModel &); - AddCardModel &operator=(const AddCardModel &); - virtual ~AddCardModel(); - uint8_t selectedCardIndex{0}; - }; -} - -#endif // ADD_CARD_MODEL_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/add_card/AddCardPresenter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/add_card/AddCardPresenter.h deleted file mode 100644 index c0ea8536f..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/add_card/AddCardPresenter.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: AddCardPresenter.h - * Author: - * Create: 2021-11-23 - */ - -#ifndef ADD_CARD_PRESENTER_H -#define ADD_CARD_PRESENTER_H - -#include "Presenter.h" -#include "components/ui_list.h" -#include "components/ui_view.h" -#include "main/ModelListenerSample.h" - -#define TOAST_KEEP_TIME 1000 - -namespace OHOS { -static const char *ADD_CARD_ADD = "addcardadd"; - -class AddCardView; -class AddCardModel; -class AddCardPresenter : public Presenter, public ModelListenerSample, - public UIView::OnClickListener, public UIView::OnDragListener, - public ListScrollListener { -public: - AddCardPresenter(); - ~AddCardPresenter() override; - - void OnTickEvent() override; - void Notify() override {} - bool OnClick(UIView &view, const ClickEvent &event) override; - void OnScrollStart(int16_t index, UIView *view) override; - void OnScrollEnd(int16_t index, UIView *view) override; - void OnItemSelected(int16_t index, UIView* view) override; - bool OnDrag(UIView& view, const DragEvent& event) override; -private: - void ResetTickTimer(void); - AddCardModel *model{nullptr}; - uint64_t startTime{0}; - bool cardCountEvent{false}; -}; -} - -#endif // ADD_CARD_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/add_card/AddCardView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/add_card/AddCardView.h deleted file mode 100644 index 952590d8f..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/add_card/AddCardView.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: AddCardView.h - * Author: - * Create: 2021-11-23 - */ - -#ifndef ADD_CARD_VIEW_H -#define ADD_CARD_VIEW_H - -#include "View.h" -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_image_view.h" -#include "components/ui_toggle_button.h" -#include "ChangeSliceListener.h" -#include "UiConfig.h" -#include "add_card/AddCardAdapter.h" -#include "add_card/AddCardModel.h" - -namespace OHOS { -class AddCardPresenter; - -class AddCardView : public View { -public: - AddCardView(); - ~AddCardView() override; - - static AddCardView *GetInstance() - { - static AddCardView instance; - return &instance; - } - - void OnStart() override; - void RefreshCardList(void); - void ExceedsCardCountEvent(bool isVisible); -private: - void SetUpListInfo(void); - void SetUpListView(void); - void SetUpToast(void); - UIList contentList_; - UILabel toastLabel_; - AddCardAdapter *addCardAdapter_{nullptr}; -}; -} -#endif // ADD_CARD_VIEW_H diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bloodoxygen/BloodBandoffView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bloodoxygen/BloodBandoffView.h deleted file mode 100644 index de10edb0e..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bloodoxygen/BloodBandoffView.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: bloodBandoff view - * Author: - * Create: 2021-08-01 - */ - -#ifndef BLOOD_BANDOFF_VIEW_H -#define BLOOD_BANDOFF_VIEW_H - -#include "components/ui_label.h" -#include "components/ui_view_group.h" -#include "components/ui_image_animator.h" -#include "View.h" -#include "ohos_types.h" - -namespace OHOS { -class BloodBandoffView { -public: - BloodBandoffView(); - virtual ~BloodBandoffView(); - - UIViewGroup *CreateUIViewGroup(); - static BloodBandoffView *GetInstance(void); - - UIViewGroup *GetBandoffViewGroup(); - UIImageAnimatorView *GetImageAnimator(); -private: - UILabel *label; - UIViewGroup *group; - UIImageView *imageView; - UIImageAnimatorView *imageAnimator; -}; -} - - -#endif // 血氧跳转界面 \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bloodoxygen/BloodOxygenModel.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bloodoxygen/BloodOxygenModel.h deleted file mode 100644 index 2fd37c817..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bloodoxygen/BloodOxygenModel.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: bloodOxygen view - * Author: - * Create: 2021-08-01 - */ - -#ifndef BLOOD_OXYGEN_MODEL_H -#define BLOOD_OXYGEN_MODEL_H - -#include -#include "gfx_utils/list.h" - -namespace OHOS { -class BloodOxygenModel { -public: - ~BloodOxygenModel(){}; - static BloodOxygenModel *GetInstance(void); - bool GetBloodOxygenViewStatus(void); - bool GetBloodBandoffViewStatus(void); - void SetBloodOxygenViewStatus(bool oxygenViewStatus); - void SetBloodBandoffViewStatus(bool bandoffViewStatus); - -private: - BloodOxygenModel(); - bool OxygenView; - bool BandoffView; -}; -} - -#endif diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bloodoxygen/BloodOxygenPresenter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bloodoxygen/BloodOxygenPresenter.h deleted file mode 100644 index 70ca55d57..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bloodoxygen/BloodOxygenPresenter.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: bloodOxygen view - * Author: - * Create: 2021-08-01 - */ - -#ifndef BLOOD_OXYGEN_PRESENTER_H -#define BLOOD_OXYGEN_PRESENTER_H - -#include "Presenter.h" -#include "main/ModelListenerSample.h" -#include "components/ui_circle_progress.h" -#include "ohos_types.h" - -namespace OHOS { -class BloodOxygenView; -class BloodOxygenPresenter : public Presenter, - public UIView::OnClickListener, - public ModelListenerSample, - public UIView::OnDragListener { -public: - BloodOxygenPresenter(); - ~BloodOxygenPresenter() override; - void OnStart() override; - void OnStop() override; - void Notify() override; - static BloodOxygenPresenter *GetInstance(void); - bool OnDrag(UIView& view, const DragEvent& event) override; - bool OnClick(UIView& view, const ClickEvent& event) override; - -private: - bool CheckPointersValue(void); - void ReturnInterface(void); - void ProgressNotify(void); - int count; -}; -} - -#endif diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bloodoxygen/BloodOxygenView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bloodoxygen/BloodOxygenView.h deleted file mode 100644 index 059e1d517..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bloodoxygen/BloodOxygenView.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: bloodOxygen view - * Author: - * Create: 2021-08-01 - */ - -#ifndef BLOOD_OXYGEN_VIEW_H -#define BLOOD_OXYGEN_VIEW_H - -#include "View.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "components/ui_label.h" -#include "components/ui_button.h" -#include "components/ui_label_button.h" -#include "components/ui_image_animator.h" -#include "components/ui_circle_progress.h" -#include "components/ui_view_group.h" -#include "bloodoxygen/BloodOxygenPresenter.h" -#include "bloodoxygen/BloodBandoffView.h" - -namespace OHOS { -class BloodOxygenView : public View { -public: - BloodOxygenView(); - ~BloodOxygenView() override; - - void OnStart() override; - - static BloodOxygenView *GetInstance(void); - - UILabel *GetPercent(); - UIViewGroup *GetBloodOxygenGroup(); - UILabelButton *GetTestButton(); - UICircleProgress *GetCircleProgress(); -private: - bool InitImageDisplay(); - bool SetOnDragListener(); - UICircleProgress *CreateAndSetUICircleProgress(); - UILabelButton *CreateAndSetUIButton(const char *title); - UIView *CreateAndSetUIView(int16 x, int16 y) const; - - BloodBandoffView *bloodbandoff{nullptr}; - UIImageView *imageViewMain; - UIImageView *imageViewProgress; - UIImageAnimatorView *imageAnimator; - - UILabel *percent; - UIViewGroup *group; - UILabelButton *testButton; - UICircleProgress *circleProgress; -}; -} - - -#endif // 血氧主界面 \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothCaseListAdapter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothCaseListAdapter.h deleted file mode 100644 index 7cdad65ab..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothCaseListAdapter.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: Bluetooth Case List Adapter - * Author: - * Create: 2021-07-26 - */ -#ifndef BLUETOOTH_CASE_LIST_ADAPTER_H -#define BLUETOOTH_CASE_LIST_ADAPTER_H - -#include -#include "components/abstract_adapter.h" -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "player/PlayersPresenter.h" -#include "bluetooth/BluetoothItemView.h" - -namespace OHOS { -class BluetoothCaseListAdapter : public AbstractAdapter { -public: - BluetoothCaseListAdapter() {} - ~BluetoothCaseListAdapter(); - UIView *GetView(UIView *inView, int16_t index) override; - uint16_t GetCount() override; -private: - char addrTmp[20]; // 20:字符长度 - BluetoothItemView *item{nullptr}; - UIView::OnClickListener *listener{nullptr}; - void ClickAnimation(BluetoothCaseInfo &itemData, BluetoothItemView *itemView); -}; -} // namespace OHOS -#endif // BLUETOOTH_CASE_LIST_ADAPTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothDeviceCaseListAdapter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothDeviceCaseListAdapter.h deleted file mode 100644 index bb641b0ec..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothDeviceCaseListAdapter.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: Bluetooth CaseList Adapter - * Author: - * Create: 2021-07-26 - */ -#ifndef BLUETOOTH_DEVICE_CASE_LIST_ADAPTER_H -#define BLUETOOTH_DEVICE_CASE_LIST_ADAPTER_H - -#include -#include "components/abstract_adapter.h" -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "bluetooth/BluetoothItemView.h" - -namespace OHOS { -class BluetoothDeviceCaseListAdapter : public AbstractAdapter { -public: - BluetoothDeviceCaseListAdapter() {} - ~BluetoothDeviceCaseListAdapter(); - UIView *GetView(UIView *inView, int16_t index) override; - uint16_t GetCount() override; - -private: - char addrTmp[20]; // 20:字符长度 - BluetoothItemView *item{nullptr}; - UIView::OnClickListener *listener{nullptr}; -}; -} // namespace OHOS -#endif // BLUETOOTH_DEVICE_CASE_LIST_ADAPTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothDeviceListView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothDeviceListView.h deleted file mode 100644 index 29b302459..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothDeviceListView.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: BluetoothDeviceListView view 蓝牙耳机设备列表界面 - * Author: - * Create: 2021-10-13 - */ -#ifndef BLUETOOTH_DEVICE_LIST_VIEW_H -#define BLUETOOTH_DEVICE_LIST_VIEW_H - -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "components/ui_list.h" -#include "bluetooth/BluetoothDeviceCaseListAdapter.h" - -namespace OHOS { -class BluetoothDeviceCaseListAdapter; -class BluetoothDeviceListView { -public: - BluetoothDeviceListView(); - ~BluetoothDeviceListView(); - static BluetoothDeviceListView *GetInstance(); - UIViewGroup *InitShowUpView(void); - UIViewGroup *GetGroup(void); - UIList *GetDeviceUIList(void); - void RefreshText(void); -private: - void InitList(void); - void InItEmptyLabel(); - void InitNewEquipmentButton(); - UIViewGroup *group{nullptr}; - UIList *list{nullptr}; - UILabel *titleLabel{nullptr}; - UILabel *emptyLabel{nullptr}; - BluetoothDeviceCaseListAdapter *adapterText{nullptr}; - UILabelButton *newEquipmentButton{nullptr}; -}; -} // namespace OHOS -#endif // BLUETOOTH_DEVICE_LIST_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothEarListView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothEarListView.h deleted file mode 100644 index 298f4d90d..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothEarListView.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: BluetoothEarListView view - * Author: - * Create: 2021-10-13 - */ -#ifndef BLUETOOTH_EAR_LIST_VIEW_H -#define BLUETOOTH_EAR_LIST_VIEW_H - -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "components/ui_image_animator.h" -#include "components/ui_list.h" -#include "bluetooth/BluetoothCaseListAdapter.h" - -namespace OHOS { -class BluetoothCaseListAdapter; -class BluetoothEarListView { -public: - BluetoothEarListView(); - ~BluetoothEarListView(); - static BluetoothEarListView *GetInstance(); - UIViewGroup *InitShowUpView(void); - UIViewGroup *GetGroup(void); - UIList *GetScanUIList(void); - void SetTitleLabel(const char *text); - void SetNewEquipmentButtonAdd(void); - void SetNewEquipmentButtonRemove(void); - void SetCancelConnedRequestButtonAdd(void); - void SetCancelConnedRequestButtonRemove(void); -private: - void InitList(void); - void InitButten(UILabelButton **button, const char *text, const char* id); - UIViewGroup *group{nullptr}; - UIList *list{nullptr}; - UILabel *titleLabel{nullptr}; - BluetoothCaseListAdapter *adapterText{nullptr}; - UILabelButton *rescanButton{nullptr}; - UILabelButton *cancelConnedRequestButton{nullptr}; -}; -} // namespace OHOS -#endif // BLUETOOTH_EAR_LIST_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothEarPhoneView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothEarPhoneView.h deleted file mode 100644 index e7f40ecd7..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothEarPhoneView.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: BluetoothEarPhone view - * Author: - * Create: 2021-10-13 - */ -#ifndef BLUETOOTH_EAR_PHONE_VIEW_H -#define BLUETOOTH_EAR_PHONE_VIEW_H - -#include -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "components/ui_image_animator.h" -#include "ohos_timer.h" -#include "graphic_timer.h" -#include "bluetooth/BluetoothModel.h" -#define BLUETOOTH_SEARCH_IMAGE_NUM 8 - -namespace OHOS { -class BluetoothEarPhoneView { -public: - BluetoothEarPhoneView(); - ~BluetoothEarPhoneView(); - static BluetoothEarPhoneView *GetInstance(); - UIViewGroup *InitShowUpView(void); - void BtEnable(void); - void StopBtDiscovery(void); - void BtAnimatorStart(void); - void BtAnimatorStop(void); - void setScanStatus(bool value); - bool getScanStatus(void); -private: - ImageAnimatorInfo searchImageInfo[BLUETOOTH_SEARCH_IMAGE_NUM]; - UIViewGroup *group{nullptr}; - UILabel *titleLabel{nullptr}; - UIImageAnimatorView *imageAnimator{nullptr}; - bool scanStart{0}; - void BtScanImageAnimator(); -}; - -#ifdef __cplusplus -extern "C" { -#endif -void ScanTimerCallback(int data); -void CancelBrScanHandle(void); -void EndScanHandle(void); -#ifdef __cplusplus -} -#endif -} // namespace OHOS -#endif // BLUETOOTH_EAR_PHONE_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothHeadsetEvent.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothHeadsetEvent.h deleted file mode 100644 index 8e5341d74..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothHeadsetEvent.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag. 2022. All rights reserved. - * Description: BluetoothHeadsetEvent. - */ -#ifndef BLUETOOTH_HEADSET_EVENT_H -#define BLUETOOTH_HEADSET_EVENT_H - -#include "bts_def.h" -#include "bts_br_gap.h" -#include "td_type.h" -#include "bt_audio.h" -#ifdef __cplusplus -extern "C" { -#endif - -enum { - AVRCP_SRV_PRESS_VALUE, - AVRCP_SRV_RELEASED_VALUE, - AVRCP_SRV_INIT_VALUE -}; - -typedef struct { - td_pvoid stream_hdl; - uint8_t loc_volume; - uint8_t play_stat; - uint8_t dir_forward; - uint8_t avrcp_button_flag; - bd_addr_t bd_addr; - uint8_t reg_cap_auto; - uint8_t resrv; - profile_connect_state_t avrcp_srv_conn_stat; -} BtAvrcpTgInf; - -void UsingPressButtonStatusCallback(td_u32 keyOperation, td_u32 keyValue); -void MediaStatusCallback(bt_avrcp_tg_evt_status_param *eventStatusParam); -void PressButtonStatusCallback(td_u32 keyOperation, td_u32 keyValue); -void ConnCtStateChangedCallback(const bd_addr_t *bdAddr, profile_connect_state_t state); -void ConnectTgStateChangedCallback(const bd_addr_t *bdAddr, profile_connect_state_t state); -void InitBtHeadsetEvent(void); - -#ifdef __cplusplus -} -#endif - -#endif // BLUETOOTH_HEADSET_FUNCTION_BUTTONS_HS \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothItemView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothItemView.h deleted file mode 100644 index ed4847891..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothItemView.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: BluetoothItem view - * Author: - * Create: 2021-10-13 - */ - -#ifndef BLUETOOTH_ITEM_VIEW_H -#define BLUETOOTH_ITEM_VIEW_H - -#include "components/ui_label.h" -#include "components/ui_view_group.h" -#include "components/ui_image_view.h" -#include "components/ui_label_button.h" -#include "components/ui_image_animator.h" - -#include "bluetooth/BluetoothModel.h" -#include "UiConfig.h" -#define BLUETOOTH_CONNECT_IMAGE_NUM 8 - -namespace OHOS { -class BluetoothItemView : public UIViewGroup { -public: - explicit BluetoothItemView(); - ~BluetoothItemView() override; - void SetItemInfo(const BluetoothCaseInfo& itemInfo, bool isCaseList); - BluetoothCaseInfo *GetItemInfo(void); - void SetConnectionstatus(const BluetoothCaseInfo& infoData); - void SetUpChild(); - void ConnectAnimatorStart(void); - void ConnectAnimatorStop(void); - bool IsConnectAnimator(void); -private: - ImageAnimatorInfo connectImageInfo[BLUETOOTH_CONNECT_IMAGE_NUM]; - UIImageView image; - UIButton button; - UILabel connectStateLabel; - UILabel namelabel; - UIImageAnimatorView connectionAnimator; - BluetoothCaseInfo itemInfo_{}; - void BtConnectImageAnimator(); -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothModel.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothModel.h deleted file mode 100644 index 632af7b7c..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothModel.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: BluetoothModel view - * Author: - * Create: 2021-10-13 - */ - -#ifndef BLUETOOTH_MODEL_H -#define BLUETOOTH_MODEL_H - -#include -#include -#include "gfx_utils/list.h" - -#include "bts_def.h" -#include "bts_br_gap.h" - -namespace OHOS { -constexpr uint16_t BLUETOOTH_CONN_HANDLE = 64; -constexpr uint16_t BLUETOOTH_INTERVAL_TOMAX_MIN = 12; -constexpr uint16_t BLUETOOTH_INTERVAL_TOMAX_MAX = 12; -constexpr uint16_t BLUETOOTH_INTERVAL_TODEFAULT_MIN = 24; -constexpr uint16_t BLUETOOTH_INTERVAL_TODEFAULT_MAX = 48; -constexpr uint16_t BLUETOOTH_LATENCY = 0; -constexpr uint16_t BLUETOOTH_TIMEOUT_MUTIPLIER = 500; - -typedef enum : uint16_t { - CALLERSETTING, - CALLERPLAYERS, -} CallerFactor; - -typedef struct { - unsigned char deviceName[BD_NAME_LEN]; /* Name of the device record, must be in UTF-8 */ - unsigned char addr[BD_ADDR_LEN]; - int16_t index; - int16_t connIndex; - int16_t temp; -} BluetoothCaseInfo; - -class BluetoothItemView; -class BluetoothModel { -public: - ~BluetoothModel(){}; - static BluetoothModel *GetInstance(void); - void Init(); - int GetBluetoothCalleridStatus(void); - void SetBluetoothCalleridStatus(int16_t value); - // ɨÃèÉ豸¶ÓÁгõʼ»¯ - std::list& GetCase(); - void AddCase(BluetoothCaseInfo caseInfo); - void SetScansCaseRssi(const bd_addr_t *bdAddr, int rssi); - void SortScansCaseRssi(); - void SetCaseListClear(); - bool CheckExistScanList(BluetoothCaseInfo caseInfo); // È¥ÖØ²Ù×÷ - void ResetScanDevicesCase(const BluetoothCaseInfo& caseInfo); - // ÒÑÅä¶ÔÉ豸¶ÓÁгõʼ»¯ - void SetConnedDevicesListClear(); - void AddConnedDevicesCase(BluetoothCaseInfo caseInfo); - bool CheckExistConnedList(BluetoothCaseInfo caseInfo); - List& GetConnedDevicesCase(); - void SetTempMacValue(BluetoothCaseInfo *caseInfo); - BluetoothCaseInfo *GetTempMacValue(void); - void SetLastConnedAddr(const bd_addr_t *addr); - bd_addr_t *GetLastConnedAddr(void); - void SetTagReconnectJump(bool tag); - bool GetTagReconnectJump(void); - void SetCurView(int16_t viewNum); - int GetCurView(void); - bool GetAclConnected(void); - void SetTagConnectView(bool tag); - bool IsTagConnectView(void); - void SetTagDisconnectView(bool tag); - bool IsTagDisconnectView(void); - void SetTagConnectNew(bool tag); - bool IsTagConnectNew(void); - void SetTagReturnToDeviceListView(bool tag); - bool IsTagReturnToDeviceListView(void); - void SetTagScanDeviceClicked(bool tag); - bool IsTagScanDeviceClicked(void); - void SetBtStatus(void); - BluetoothItemView *GetConnectionView(void); - void SetConnectionView(BluetoothItemView *item); - bool FindNameFromList(BluetoothCaseInfo *caseInfo); - bool GetBluetoothAclState(void); - void BtGapDiscoveryResultCallbakHandle(const bd_addr_t &bdAddr); - void BtGapAclStateChangedHandle(gap_acl_state_t state, unsigned int reason, const bd_addr_t &bdAddr); - bool GetAdvStartState(void); - void SetAdvStartState(bool state); - int ConnectRemoteDevice(const bd_addr_t *addr); - bool ConnectRemoteCheck(const bd_addr_t *addr); - char* getWatchName(void); - void ChangeBleConnectToMax(); - void ChangeBleConnectToDefault(); - -private: - BluetoothModel(); - int16_t callerid{0}; - void SetUpListCase(); - void SetUpConnedDevicesList(); - bool FindNameByAddr(BluetoothCaseInfo &listInfo, BluetoothCaseInfo *caseInfo); - void InitBluetoothInfo(void); - bool aclConnected{false}; - BluetoothCaseInfo tempMacValue{}; - bd_addr_t lastConnedAddr{0}; - bd_addr_t remoteConnectAddr{0}; - BluetoothItemView *selectItemView{nullptr}; - std::list btScansDevicesList_{}; - List *btConnedDevicesList_{nullptr}; - bool tagReconnectJump{0}; - int16_t curView{0}; - bool tagConnectView{true}; - bool tagDisconnectView{true}; - bool tagConnectNew{false}; - bool tagReturnToDeviceListView{false}; - bool tagScanDeviceClicked{false}; - bool advStartState{false}; - char watchName[BD_NAME_LEN] = { 0 }; -}; - -#ifdef __cplusplus -extern "C" { -#endif -void BtGapReadRemoteRssiEventCallback(const bd_addr_t *bdAddr, int rssi, int status); -void BtGapDiscoveryResultCallbak(const bd_addr_t *bdAddr); -void BtGapDiscoveryStateChangedCallback(int status); -void GapAclStateChangedCallback(const bd_addr_t *bdAddr, gap_acl_state_t state, unsigned int reason); -void SetSortCaseRssi(const bd_addr_t *bdAddr, int rssi); -void BtRemoteNameChangedCallback(const bd_addr_t *bdAddr, const unsigned char *deviceName, unsigned char length); -void BtIsAcceptConnOnSafeModeCallback(const bd_addr_t *bd_addr, bool *res); -void BtInitCallBacks(void); -void BtInitCallBacksEx(void); -void BtInitGatts(void); -void BtInitSpp(void); -void BleAdvStart(void); -#ifdef __cplusplus -} -#endif -} - -#endif diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothOptionsView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothOptionsView.h deleted file mode 100644 index 0573986f5..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothOptionsView.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: BluetoothOptions view - * Author: - * Create: 2021-10-13 - */ -#ifndef BLUETOOTH_OPTIONS_VIEW_H -#define BLUETOOTH_OPTIONS_VIEW_H - -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "components/ui_image_animator.h" -#include "bluetooth/BluetoothCaseListAdapter.h" - -namespace OHOS { -class BluetoothOptionsView { -public: - BluetoothOptionsView(); - ~BluetoothOptionsView(); - static BluetoothOptionsView *GetInstance(); - UIViewGroup *InitShowUpView(void); - UILabelButton *GetOptionsOneButton(void); - UILabelButton *GetUnpairButton(void); - void SetUnpair(void); - void SetBtconnect(void); - void SetBtDisconnect(void); - void SetCurrentAddr(bd_addr_t addr); - bd_addr_t GetCurrentAddr(void); - void RefreshText(void); -private: - void InItTitleLabel(void); - void InItLabelButton(void); - UILabelButton *optionsOneButton{nullptr}; - UILabelButton *unpairButton{nullptr}; - UILabel *titleLabel{nullptr}; - UILabel *connectStateLabel{nullptr}; - UIViewGroup *group{nullptr}; - bd_addr_t currentAddr; -}; -} // namespace OHOS -#endif // BLUETOOTH_OPTIONS_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothPresenter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothPresenter.h deleted file mode 100644 index 3a70f4dc3..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothPresenter.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: BluetoothPresenter view - * Create: 2021-10-13 - */ - -#ifndef BLUETOOTH_PRESENTER_H -#define BLUETOOTH_PRESENTER_H - -#include "Presenter.h" -#include "bluetooth/BluetoothModel.h" -#include "bluetooth/MainBluetoothView.h" -#include "components/ui_view.h" -#include "components/ui_image_view.h" -#include "components/ui_label_button.h" -#include "components/ui_view_group.h" -#include "main/VolumeSettingView.h" -#include "main/UiViewId.h" - -namespace OHOS { -enum BluetoothPresenterNum : uint8_t { - BLUETOOTHEARPHONEVIEW = 0, - BLUETOOTHEARLISTVIEW, - BLUETOOTHDEVICELISTVIEW, - BLUETOOTHEOPTIONSVIEW, - BLUETOOTHRECONNECTVIEW, - TIPSSUCCMESSAGEVIEW, - TIPSCONNFAILMESSAGEVIEW, - TIPSFAILMESSAGEVIEW, - BLUETOOTHEVIEW, - BLUETOOTHEVIEW_MAX, - }; - -class MainBluetoothView; -class BluetoothPresenter : public Presenter, public UIView::OnClickListener, - public UIView::OnDragListener { -public: - BluetoothPresenter(); - ~BluetoothPresenter(); - bool OnClick(UIView &view, const ClickEvent &event) override; - static BluetoothPresenter *GetInstance(); - bool OnDragEnd(UIView& view, const DragEvent& event) override; - void OnStop() override; - void ClickRescanButton(void); - void ClickNewEquipmentButton(void); - void ClickCancelConnedRequestButton(void); - void ClickUnpairButton(void); - void ClickOptionsOneButton(void); - void ClickSuccBackButton(void); - void ClickFailBackButton(void); - void ClickConnfailBackButton(void); -private: - BluetoothModel *bluetoothMode_{nullptr}; -}; -} // namespace OHOS -#endif diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothReconnectView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothReconnectView.h deleted file mode 100644 index a65be7016..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/BluetoothReconnectView.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: Bluetooth Reconnect View - * Author: - * Create: 2021-07-26 - */ -#ifndef BLUETOOTH_RECONNECT_VIEW_H -#define BLUETOOTH_RECONNECT_VIEW_H - - -#include "components/ui_label.h" -#include "components/ui_image_animator.h" -#include "components/abstract_adapter.h" -#include "components/ui_view_group.h" -#include "bts_def.h" -#define BLUETOOTH_RECONNECT_IMAGE_NUM 8 - -namespace OHOS { -class BluetoothReconnectView { -public: - BluetoothReconnectView(); - ~BluetoothReconnectView(); - static BluetoothReconnectView *GetInstance(); - UIViewGroup *InitShowUpView(void); - void BtReconnectStart(void); - void BtReconnectStop(void); - bd_addr_t GetcurrentBdAddr(void); - void RefreshBluetoothNameLabel(); -private: - ImageAnimatorInfo reconnetImageInfo[BLUETOOTH_RECONNECT_IMAGE_NUM]; - void ShowUpTitleLabel(void); - UILabel *titleLabel{nullptr}; - UILabel *bluetoothNameLabel{nullptr}; - UIImageAnimatorView *reconnectAnimator{nullptr}; - UIViewGroup *group{nullptr}; - bd_addr_t currentBdAddr; - void BtReconnectImageAnimator(); -}; -} // namespace OHOS -#endif // BLUETOOTH_RECONNECT_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/MainBluetoothView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/MainBluetoothView.h deleted file mode 100644 index 3f04896cb..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/MainBluetoothView.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: MainBluetooth view - * Author: - * Create: 2021-10-13 - */ -#ifndef MAIN_BLUETOOTH_VIEW_H -#define MAIN_BLUETOOTH_VIEW_H - -#include "View.h" -#include "UiConfig.h" -#include "ChangeSliceListener.h" -#include "bluetooth/BluetoothPresenter.h" -#include "bluetooth/BluetoothCaseListAdapter.h" -#include "bluetooth/BluetoothEarListView.h" -#include "bluetooth/BluetoothEarPhoneView.h" -#include "bluetooth/BluetoothOptionsView.h" -#include "bluetooth/BluetoothReconnectView.h" -#include "bluetooth/TipsConnFailMessageView.h" -#include "bluetooth/TipsSuccMessageView.h" -#include "bluetooth/TipsFailMessageView.h" -#include "bluetooth/BluetoothDeviceListView.h" -#include "bluetooth/BluetoothItemView.h" - -namespace OHOS { -constexpr int16_t NUM_CONTAINER = 9; // NUM_CONTAINER :蓝牙耳机连接的9个界面容器 - -class BluetoothPresenter; -class MainBluetoothView; - -class MainBluetoothView : public View { -public: - MainBluetoothView(); - ~MainBluetoothView() override; - - void OnStart() override; - void DropView(UIView& view); - void ChangeView(int16_t hideView, int16_t showView); - static MainBluetoothView *GetInstance(void); - -private: - bool ChangeBluetoothDeviceListView(int16_t hideView, int16_t thisView); - bool ChangeTipsFailMessageView(int16_t hideView, int16_t thisView); - bool ChangeTipsConnFailMessageView(int16_t hideView, int16_t thisView); - bool ChangeTipsSuccMessageView(int16_t hideView, int16_t thisView); - bool ChangeBluetoothEarPhoneView(int16_t hideView, int16_t thisView); - bool ChangeBluetoothEarListView(int16_t hideView, int16_t thisView); - bool ChangeBluetoothView(int16_t hideView, int16_t thisView); - bool ChangeBluetoothOptionsView(int16_t hideView, int16_t thisView); - bool ChangeBluetoothReconnectView(int16_t hideView, int16_t thisView); - bool CheckViewParam(int16_t hideView, int16_t showView); - void CorrespondingJump(int16_t hideView); - void ResetEarListView(int16_t hideView); - void ChangeSettingView(); - void DropEarPhoneView(); - void DropEarListView(); - BluetoothEarListView *bluetoothEarListView{nullptr}; // 耳机连接界面 - BluetoothEarPhoneView *bluetoothEarPhoneView{nullptr}; // 搜索界面 - BluetoothOptionsView *bluetoothOptionsView{nullptr}; // 连接状态界面 - BluetoothReconnectView *bluetoothReconnectView{nullptr}; // 重新连接界面 - TipsConnFailMessageView *tipsConnFailMessageView{nullptr}; // 连接失败界面 - TipsSuccMessageView *tipsSuccMessageView{nullptr}; // 连接成功界面 - TipsFailMessageView *tipsFailMessageView{nullptr}; // 未搜索到蓝牙耳机界面 - BluetoothDeviceListView *bluetoothDeviceListView{nullptr}; // 蓝牙已连接设备界面 - UIViewGroup *container[NUM_CONTAINER]{nullptr}; // NUM_CONTAINER :蓝牙耳机连接的9个界面容器 - typedef bool (MainBluetoothView::*PreprosssChangeView)(int16_t hideView, int16_t thisView); - PreprosssChangeView preProcessView[NUM_CONTAINER]; -}; -} // namespace OHOS -#endif // MAIN_BLUETOOTH_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/TipsConnFailMessageView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/TipsConnFailMessageView.h deleted file mode 100644 index d0bcc4b06..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/TipsConnFailMessageView.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: TipsConnFailMessageView view - * Author: - * Create: 2021-10-13 - */ -#ifndef TIPS_CONN_FAIL_MESSAGE_VIEW_H -#define TIPS_CONN_FAIL_MESSAGE_VIEW_H - -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "components/ui_image_view.h" -#include "bts_def.h" - -namespace OHOS { -class TipsConnFailMessageView { -public: - TipsConnFailMessageView(); - ~TipsConnFailMessageView(); - static TipsConnFailMessageView *GetInstance(); - UIViewGroup *ShowUpViewInit(void); - void RefreshNameLabel(const bd_addr_t &bdAddr); -private: - void ShowUpButtonBack(void); - void ShowUpTipLabel(void); - void InitNameLabel(void); - UILabel *titleLabel{nullptr}; - UILabel *tipLabel{nullptr}; - UILabel *tipTwoLabel{nullptr}; - UILabel *bluetoothNameLabel{nullptr}; - UILabelButton *backButton{nullptr}; - UIImageView *tipImg{nullptr}; - UIViewGroup *group{nullptr}; -}; -} // namespace OHOS -#endif // TIPS_CONN_FAIL_MESSAGE_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/TipsFailMessageView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/TipsFailMessageView.h deleted file mode 100644 index 3420d3e5f..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/TipsFailMessageView.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: TipsFailMessageView view - * Author: - * Create: 2021-10-13 - */ -#ifndef TIPS_FAIL_MESSAGE_VIEW_H -#define TIPS_FAIL_MESSAGE_VIEW_H - -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "components/ui_image_view.h" - -namespace OHOS { -class TipsFailMessageView { -public: - TipsFailMessageView(); - ~TipsFailMessageView(); - static TipsFailMessageView *GetInstance(); - UIViewGroup *ShowUpViewInit(void); -private: - int ShowUpButtonBack(void); - UILabel *titleLabel{nullptr}; - UILabelButton *backButton{nullptr}; - UIImageView *tipImg{nullptr}; - UIViewGroup *group{nullptr}; -}; -} // namespace OHOS -#endif // TIPS_FAIL_MESSAGE_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/TipsSuccMessageView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/TipsSuccMessageView.h deleted file mode 100644 index 09ed3f255..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/bluetooth/TipsSuccMessageView.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: TipsSuccMessage view - * Author: - * Create: 2021-10-13 - */ -#ifndef TIPS_SUCC_MESSAGE_VIEW_H -#define TIPS_SUCC_MESSAGE_VIEW_H - -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "components/ui_image_view.h" -#include "bts_def.h" - -namespace OHOS { -class TipsSuccMessageView { -public: - TipsSuccMessageView(); - ~TipsSuccMessageView(); - static TipsSuccMessageView *GetInstance(); - UIViewGroup *ShowUpViewInit(void); - void RefreshNameLabel(const bd_addr_t &bdAddr); -private: - void ShowUpButtonBack(void); - void InitNameLabel(void); - UILabel *titleLabel{nullptr}; - UILabel *bluetoothNameLabel{nullptr}; - UILabelButton *backButton{nullptr}; - UIImageView *tipImg{nullptr}; - UIViewGroup *group{nullptr}; -}; -} // namespace OHOS -#endif // TIPS_SUCC_MESSAGE_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathDurPage.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathDurPage.h deleted file mode 100644 index 0376dbed5..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathDurPage.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: BreathDurPage - * Create: 2025-5-13 - */ -#ifndef BREATH_DUR_PAGE_H -#define BREATH_DUR_PAGE_H - -#include -#include "components/ui_label.h" -#include "components/ui_picker.h" -#include "components/ui_image_view.h" -#include "components/ui_view_group.h" -#include "components/ui_scroll_view.h" -#include "components/ui_label_button.h" -#include "components/ui_toggle_button.h" -#include "View.h" -#include "UiConfig.h" -#include "SlicePage.h" -#include "SlicePageFactory.h" -#include "breath/BreathModel.h" -#include "breath/BreathPresenter.h" - -namespace OHOS { - -class BreathDurPage : public SlicePage, - public UIView::OnClickListener, - public UIView::OnDragListener { -public: - BreathDurPage(); - ~BreathDurPage() override; - void OnStart(void* data) override; - void OnStop() override; - void OnResume() override; - void OnPause() override; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; -private: - UILabel *lableTitle = nullptr; - UIPicker *pickerTime = nullptr; - UIButton *buttonOk = nullptr; - UIViewGroup *group = nullptr; - UIImageView *center = nullptr; -}; -} // namespace OHOS - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathExerPage.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathExerPage.h deleted file mode 100644 index 3f3513bfa..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathExerPage.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: BreathExerPage - * Create: 2025-5-13 - */ -#ifndef BREATH_EXER_PAGE_H -#define BREATH_EXER_PAGE_H - -#include "layout/grid_layout.h" -#include "components/ui_label.h" -#include "components/ui_digital_clock.h" -#include "components/ui_image_animator.h" -#include "View.h" -#include "SlicePage.h" -#include "graphic_timer.h" -#include "SlicePageFactory.h" -#include "power_display_service.h" -#include "breath/BreathModel.h" -#include "breath/BreathPresenter.h" - -#define ALIPAY_BIND_SEARCH_IMAGE_NUM 80 -#define SPEED_IDX_3 3 - -namespace OHOS { -class BreathExerPage : public SlicePage, - public UIView::OnClickListener, - public UIView::OnDragListener { -public: - BreathExerPage(); - ~BreathExerPage() override; - void OnStart(void* data) override; - void OnStop() override; - void OnPause() override; - bool OnDrag(UIView &view, const DragEvent &event) override; - void OnTimer(); - void SetUpImageAnimator(); - void InitImageInfo(); - -private: - UIViewGroup *group = nullptr; - UIImageAnimatorView* imageAnimator_ = nullptr; - ImageInfo* imageInfoOen = nullptr; - ImageInfo* imageInfoTwo = nullptr; - ImageInfo* imageInfoThree = nullptr; - uint32_t palyNumber; - ImageAnimatorInfo imageAnimatorImageInfo[SPEED_IDX_3] = { 0 }; - ImageAnimatorInfo searchImageInfo[ALIPAY_BIND_SEARCH_IMAGE_NUM]; - - class BreathExerPageCallback : public AnimatorCallback { - public: - BreathExerPageCallback(BreathExerPage* page) : BreathExerPage(page) {} - virtual ~BreathExerPageCallback() override {} - void Callback(UIView* view) override; - private: - BreathExerPage* BreathExerPage{nullptr}; - }; - BreathExerPageCallback* animatorCallBack{nullptr}; - Animator *animation = nullptr; -}; -} // namespace OHOS - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathMainPage.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathMainPage.h deleted file mode 100644 index bd06de488..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathMainPage.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: BreathMainPage - * Create: 2025-5-13 - */ -#ifndef BREATH_MAIN_PAGE_H -#define BREATH_MAIN_PAGE_H - -#include "components/ui_label.h" -#include "components/ui_button.h" -#include "components/ui_label_button.h" -#include "components/ui_digital_clock.h" -#include "components/ui_image_animator.h" -#include "View.h" -#include "SlicePageFactory.h" -#include "SlicePage.h" -#include "breath/BreathView.h" -#include "breath/BreathModel.h" -#include "breath/BreathPresenter.h" - -namespace OHOS { - -class BreathMainPage : public SlicePage, - public UIView::OnClickListener, - public UIView::OnDragListener { -public: - BreathMainPage() = default; - ~BreathMainPage() override; - void OnStart(void* data) override; - void OnStop() override; - void OnResume() override; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; - -private: - UILabel *lableBreathing = nullptr; - UIButton *buttonTime = nullptr; - UIButton *buttonSetting = nullptr; - UIButton *buttonStart = nullptr; - UILabel *lableSetting = nullptr; - UILabel *lableTime = nullptr; - UIViewGroup *group = nullptr; - UIImageView *background = nullptr; - UIImageView *center = nullptr; -}; -} // namespace OHOS - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathModel.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathModel.h deleted file mode 100644 index 701040381..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathModel.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: BreathModel - * Create: 2025-5-13 - */ -#ifndef BREATH_MODEL_H -#define BREATH_MODEL_H - -#include "gfx_utils/graphic_math.h" -namespace OHOS { -#define SPEED_IDX_3 3 -class BreathModel { -public: - static BreathModel &GetInstance(); - virtual ~BreathModel(); - const char **GetDurListData(); - const char **GetRhyListData(); - uint8_t GetDurListSize(); - uint8_t GetRhyListSize(); - char *GetTimeDuration(); - void SetTimeDuration(uint16_t idx); - void SetTimeRhyation(uint16_t idx); - uint8_t GetSelectTime(); - uint8_t GetSelectTempo(); - char *GetDuration(); - char *GetRhythm(); - void SetSaveTime(int32_t idx); - int32_t GetSaveTime(); - uint32_t GetTimeBreathing(); - uint32_t GetStatusRespiratory(); - void SetBeginsTime(int32_t idx); - int32_t GetBeginsTime(); - void SetFrequencyScore(); - uint8_t GetFrequencyScore(); - void SetHeartRate(); - uint8_t GetHeartRate(); - uint32_t GetTheNumberOfPlays(); - -protected: - void DefaultData(); - -private: - BreathModel(); - BreathModel(const BreathModel &); - BreathModel &operator=(const BreathModel &); - const char *durList[SPEED_IDX_3]; - const char *rhyList[SPEED_IDX_3]; - uint32_t durListVal[SPEED_IDX_3]; - uint32_t rhyListVal[SPEED_IDX_3]; - uint16_t data; - uint16_t date; - int32_t saveTime; - int32_t beginsTime; -}; -} - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathPresenter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathPresenter.h deleted file mode 100644 index 1b1f6c091..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathPresenter.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: BreathPresenter - * Create: 2025-5-23 - */ - -#ifndef Breath_PRESENTER_H -#define Breath_PRESENTER_H - -#include "Presenter.h" - -namespace OHOS { -constexpr int16_t SET_INT_MAX_ = 255; - -class BreathView; -class BreathPresenter : public Presenter {}; -} - -#endif // Breath_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathResultPage.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathResultPage.h deleted file mode 100644 index 0f2b1a471..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathResultPage.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: BreathResult - * Create: 2025-5-13 - */ -#ifndef BREATH_RESULT_PAGE_H -#define BREATH_RESULT_PAGE_H - -#include "components/ui_label.h" -#include "components/ui_picker.h" -#include "components/ui_view_group.h" -#include "components/ui_image_view.h" -#include "components/ui_scroll_view.h" -#include "components/ui_label_button.h" -#include "components/ui_toggle_button.h" -#include "View.h" -#include "UiConfig.h" -#include "SlicePage.h" -#include "SlicePageFactory.h" -#include "breath/BreathModel.h" -#include "breath/BreathPresenter.h" - -namespace OHOS { - -class BreathResultPage : public SlicePage, - public UIView::OnClickListener, - public UIView::OnDragListener { -public: - BreathResultPage(); - ~BreathResultPage() override; - void OnStart(void* data) override; - void OnStop() override; - void OnResume() override; - bool OnDrag(UIView &view, const DragEvent &event) override; - bool OnClick(UIView &view, const ClickEvent &event) override; - -private: - UILabel *trainingResults = nullptr; - UILabel *trainingFrequencies = nullptr; - UILabel *trainingHeartRate = nullptr; - UILabel *trainingDuration = nullptr; - UILabel *heartRateScout = nullptr; - UILabel *frequenciesScout = nullptr; - UIImageView *scores = nullptr; - UILabel *descriptionBreathing = nullptr; - UILabel *time = nullptr; - UILabel *timeUnit = nullptr; - UILabel *frequencyTimes = nullptr; - UILabel *heartRateTimes = nullptr; - UIViewGroup *group = nullptr; - uint8_t frequencyScore; - uint8_t heartRate; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathRhyPage.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathRhyPage.h deleted file mode 100644 index 2c9780d5d..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathRhyPage.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: BreathRhyPage - * Create: 2025-5-13 - */ -#ifndef BREATH_RHY_PAGE_H -#define BREATH_RHY_PAGE_H - -#include "components/ui_label.h" -#include "components/ui_picker.h" -#include "components/ui_image_view.h" -#include "components/ui_label_button.h" -#include "View.h" -#include "SlicePage.h" -#include "SlicePageFactory.h" -#include "breath/BreathModel.h" -#include "breath/BreathPresenter.h" - -namespace OHOS { - -class BreathRhyPage : public SlicePage, - public UIView::OnClickListener, - public UIView::OnDragListener, - public UIPicker::SelectedListener { -public: - BreathRhyPage(); - ~BreathRhyPage() override; - void OnStart(void* data) override; - void OnResume() override; - void OnPause() override; - void OnStop() override; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; - -private: - UILabel *lableRhythm = nullptr; - UIPicker *pickerRhythm = nullptr; - UIButton *buttonOk = nullptr; - UIViewGroup *group = nullptr; - UIImageView *center = nullptr; -}; -} // namespace OHOS - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathStartPage.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathStartPage.h deleted file mode 100644 index 86b1a9f4b..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathStartPage.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: BreathStartPage - * Create: 2025-5-13 - */ -#ifndef BREATH_START_PAGE_H -#define BREATH_START_PAGE_H - -#include "components/ui_label.h" -#include "components/ui_image_view.h" -#include "View.h" -#include "SlicePage.h" -#include "graphic_timer.h" -#include "SlicePageFactory.h" -#include "breath/BreathModel.h" -#include "breath/BreathPresenter.h" - -namespace OHOS { - -class BreathStartPage : public SlicePage, - public UIView::OnClickListener, - public UIView::OnDragListener { -public: - BreathStartPage(); - ~BreathStartPage() override; - void OnStart(void* data) override; - void OnStop() override; - void OnTimer(); - bool OnDrag(UIView &view, const DragEvent &event) override; - void OnPause() override; -private: - UILabel *titleLable = nullptr; - UILabel *guideLable = nullptr; - UIImageView *centerImge = nullptr; - UIViewGroup *group = nullptr; - UIImageView *background = nullptr; - - class BreathStartCallback : public AnimatorCallback { - public: - BreathStartCallback(BreathStartPage* page) : BreathStartPage(page) {} - virtual ~BreathStartCallback() override {} - void Callback(UIView* view) override; - private: - BreathStartPage* BreathStartPage{nullptr}; - }; - BreathStartCallback* animatorCallBack{nullptr}; - Animator *animation = nullptr; -}; -} // namespace OHOS - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathView.h deleted file mode 100644 index 0cfa80156..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/breath/BreathView.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: BreathView - * Create: 2025-5-14 - */ - -#ifndef BREATH_VIEW_H -#define BREATH_VIEW_H - -#include "View.h" -namespace OHOS { -enum BrearhView { - BREATH_MAIN_VIEW = 1, - BREATH_DUR_VIEW = 2, - BREATH_EXER_VIEW = 3, - BREATH_RHY_VIEW = 4, - BREATH_START_VIEW = 5, - BREATH_RESULT_VIEW = 6, -}; - -class BreathPresenter; -class BreathView : public View {}; -} -#endif // BREATH_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/callerlog/CallerItemView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/callerlog/CallerItemView.h deleted file mode 100644 index 907f47d78..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/callerlog/CallerItemView.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: CallerItemView.h - * Author: - * Create: 2021-10-12 - */ - -#ifndef CALLER_ITEM_VIEW_H -#define CALLER_ITEM_VIEW_H - -#include "components/ui_label.h" -#include "components/ui_view_group.h" -#include "components/ui_image_view.h" -#include "components/ui_label_button.h" - -#include "callerlog/CallerLogModel.h" -#include "UiConfig.h" -#include "phoneservice/PhoneService.h" - -namespace OHOS { -class CallerItemView : public UIViewGroup { -public: - - // @param yCoordinates Y轴坐标值 - explicit CallerItemView(int32 yCoordinates); - ~CallerItemView() override; - - void SetItemInfo(CallLogInfo *itemInfo, char len); - void SetUpChild(); -private: - CallerItemView(const CallerItemView &); - CallerItemView &operator = (const CallerItemView &); - void InitDateMonTime(time_t seconds); - - std::string infoTel; // 电话号码 - std::string timeDisplay; // 日期显示 - UIImageView icon_; - UIImageView icons_; - UILabel label_; - UILabel labels_; -}; -} - -#endif diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/callerlog/CallerLogModel.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/callerlog/CallerLogModel.h deleted file mode 100644 index d4d51a414..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/callerlog/CallerLogModel.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: CallerLogModel.h - * Author: - * Create: 2021-10-12 - */ -#ifndef CALLER_LOG_MODEL_H -#define CALLER_LOG_MODEL_H - -#include "string" -#include "phoneservice/PhoneService.h" -#include "AppViewIDs.h" -#include "message.h" -#include "msg_center.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - CHANGE_STATUS = 0, - SCO_STATUS, - ERROR_MESSAGE -} MessageType; - -enum PhoneStatus { - PHONE_MULTI_STATUS = 0, - PHONE_SINGLE_STATUS -}; - -bool MulitplePhoneTextReplaces(); -bool FindCallListInfoAndSetPriorityNumber(); -void PhoneScoStatausCallback(hfp_sco_connect_state_t state); -void PhoneChangeStatusCallback(const PhoneCallInfo *phoneCall); -void PhoneErrorCallback(PhoneServiceErrorType type, int volume); -void UsingPhoneScoStatausCallback(hfp_sco_connect_state_t state); -void UsingPhoneChangeStatusCallback(const PhoneCallInfo *phoneCall); -void UsingPhoneErrorCallback(PhoneServiceErrorType type); - -namespace OHOS { -class CallerLogModel { -public: - void InitPhoneService(); - static CallerLogModel *GetInstance(void); - - std::string GetPhoneNumber(void); - void SetoperateNumber(const char *number, char number_len); - - bool GetPhoneStatus(); - void SetMakePhoneStatus(bool status); - - bool GetVolumeScreenStatus(); - void SetVolumeScreenStatus(bool status); - - bool GetCallStatus(); - void SetCallStatus(bool status); - - bool GetWaitingStatus(); - void SetWaitingStatus(bool status); - - bool GetMulitplePhoneStatus(); - void SetMulitplePhoneStatus(bool status); - - std::string GetDialingStatus(void); - void SetDialingStatus(const char *text); - - std::string InitDateHourTime(); - std::string& DisplayCallDuration(); - int CurrCallNum(); - - bool GetNotifyFlag(void); - void SetNotifyFlag(bool flag); - bool IsMulitplePhoneStatus(void); -private: - CallerLogModel(); - CallerLogModel(const CallerLogModel &); - CallerLogModel &operator=(const CallerLogModel &); - virtual ~CallerLogModel(); - - std::string dialingStatus; // 拨号状态 - std::string timers; // 时间显示 - std::string callDuration; // 通话时长 - std::string phoneNumber; // 电话号码 - bool mulitplePhoneStatus{false}; // 判断是否多路通话界面 - bool waitingStatus{false}; // 判断是否等待提醒界面 - bool volumeStatus{false}; // 判断是否音量界面 - bool phoneStatus{false}; // 判断是拨打界面还是呼入界面 - bool callStatus{false}; // 判断是否正在接听电话 - bool notifyFlag{false}; // 判断是否来电呼入 由notify生成界面 -}; -} -#ifdef __cplusplus -} -#endif - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/callerlog/CallerLogPresenter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/callerlog/CallerLogPresenter.h deleted file mode 100644 index e90602125..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/callerlog/CallerLogPresenter.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: CallerLogPresenter.h - * Author: - * Create: 2021-10-12 - */ - -#ifndef CALLER_LOG_PRESENTER_H -#define CALLER_LOG_PRESENTER_H - -#include "Presenter.h" -#include "ohos_types.h" -#include "callerlog/CallerLogModel.h" -#include "graphic_timer.h" -#include "sys/time.h" - - -namespace OHOS { -class CallerLogView; -class CallerLogPresenter : public Presenter, public UIView::OnClickListener { -public: - CallerLogPresenter(); - ~CallerLogPresenter() override; - void OnStop() override; - static CallerLogPresenter *GetInstance(void); - bool OnClick(UIView &view, const ClickEvent &event) override; - void BuletoothHintsCallbackProc(void* data); -private: - void InitBluetoothHints(); - void DisableBluetoothHints(); - GraphicTimer* hintsCounting{nullptr}; -}; -} - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/callerlog/CallerLogView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/callerlog/CallerLogView.h deleted file mode 100644 index a9594f02c..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/callerlog/CallerLogView.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: CallerLogView.h - * Author: - * Create: 2021-10-12 - */ - -#ifndef CALLER_LOG_VIEW_H -#define CALLER_LOG_VIEW_H - -#include "View.h" -#include "callerlog/CallerLogPresenter.h" -#include "callerlog/CallerItemView.h" -#include "components/ui_view_group.h" -#include "components/ui_image_animator.h" -#include "components/ui_scroll_view.h" -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "components/ui_list.h" -#include "components/abstract_adapter.h" -#include "phoneservice/PhoneService.h" -#include "vector.h" -#include "ChangeSliceListener.h" - -namespace OHOS { -using namespace Graphic; -class CallerListOnDragListener : public UIView::OnDragListener { -public: - CallerListOnDragListener() {} - ~CallerListOnDragListener() override {} - - bool OnDrag(UIView& view, const DragEvent& event) override - { - UNUSED(view); - if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && - (event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); - } - - return false; - } -}; - -class CallerUIScrollView : public UIScrollView { -public: - CallerUIScrollView() {} - ~CallerUIScrollView() {} - - bool OnDragEvent(const DragEvent& event) override - { - return UIScrollView::OnDragEvent(event); - } -}; - -class CallerLogView : public View { -public: - CallerLogView(); - ~CallerLogView() override; - - void OnStart() override; - UIViewGroup* GetHintsGroup(); - CallerUIScrollView *GetGroupView(); - CallerUIScrollView *GetContainerView(); - static CallerLogView *GetInstance(); - uint32 GetCurrentNumber(); - CallLogInfo *GetCurrentCallInfo(); -private: - bool InitOrBandOnclickEvent(); - bool CreateCallerLogViewGroup(void); - bool CreateNoDataCallerLogViewGroup(void); - void ChangeLabelsStytleClear(int32 groupFinaly, int32 Index); - void ChangeLabelsStytleLog(); - void InitBluetoothHintsGroup(); - - uint32 currentNumber; - UILabel labelLog; - UILabel labelClear; - CallLogInfo *info{nullptr}; - UIViewGroup *groupFirst{nullptr}; - UIViewGroup *groupFinal{nullptr}; - UIViewGroup *hintsGroup{nullptr}; - CallerUIScrollView *container{nullptr}; - CallerUIScrollView *group{nullptr}; - UIImageView *imageView{nullptr}; - UIImageView *hintsImageView{nullptr}; - UIView::OnClickListener* clickLeftListener{nullptr}; - Vectoritem; - CallerListOnDragListener *dragListener{nullptr}; -}; -} - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/connectnewphone/ConnectOpenView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/connectnewphone/ConnectOpenView.h deleted file mode 100644 index 0560c8af5..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/connectnewphone/ConnectOpenView.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: ConnectOpen View - * Create: 2022-03-22 - */ -#ifndef CONNECT_OPEN_VIEW_H -#define CONNECT_OPEN_VIEW_H - -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "components/ui_image_view.h" - -namespace OHOS { -class ConnectOpenView { -public: - ConnectOpenView(); - ~ConnectOpenView(); - static ConnectOpenView *GetInstance(); - UIViewGroup *InitShowUpView(void); - -private: - void ShowUpBackView(void); - UILabel *titleLabel{nullptr}; - UILabel *watchNameLabel{nullptr}; - UILabelButton *backButton{nullptr}; - UIImageView *tipImg{nullptr}; - UIViewGroup *group{nullptr}; -}; -} // namespace OHOS -#endif // CONNECT_OPEN_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/connectnewphone/ConnectPhonePresenter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/connectnewphone/ConnectPhonePresenter.h deleted file mode 100644 index d55eab049..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/connectnewphone/ConnectPhonePresenter.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Connect Phone Presenter - * Create: 2022-01-19 - */ - -#ifndef CONNECT_PHONE_PRESENTER_H -#define CONNECT_PHONE_PRESENTER_H - -#include "Presenter.h" -#include "connectnewphone/ConnectOpenView.h" -#include "NativeLauncher.h" -#include "NativeAbility.h" - -namespace OHOS { -enum ConnectPhonePresenterNum : uint8_t { - CONNECTSELECTVIEW = 0, - CONNECTOPENVIEW, - CONNECTPHONE_MAX, -}; - -#define CANCEL_BUTTON "cancelButton" -#define CONFIRM_BUTTON "confirmButton" -#define CONNECT_OPEN_BACK_BUTTON "backButton" - -#define CONNECT_SELECT_VIEW "connectSelectView" -#define CONNECT_OPEN_VIEW "connectOpenView" - -class ConnectPhoneView; -class ConnectPhonePresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener { -public: - ConnectPhonePresenter(); - ~ConnectPhonePresenter(); - static ConnectPhonePresenter *GetInstance(); - bool OnClick(UIView& view, const ClickEvent& event) override; - bool OnDrag(UIView& view, const DragEvent& event) override; - void ConfirmOnClick(); -private: -}; -} // namespace OHOS -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/connectnewphone/ConnectPhoneView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/connectnewphone/ConnectPhoneView.h deleted file mode 100644 index 1a248987a..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/connectnewphone/ConnectPhoneView.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Connect Phone View - * Create: 2022-01-19 - */ - -#ifndef CONNECT_PHONE_VIEW_H -#define CONNECT_PHONE_VIEW_H - -#include "View.h" -#include "connectnewphone/ConnectPhonePresenter.h" -#include "connectnewphone/ConnectSelectView.h" -#include "main/AppGroupView.h" - -namespace OHOS { -constexpr int16_t NUM_CONNECT_PHONE_CONTAINER = 2; - -class ConnectPhonePresenter; -class ConnectPhoneView : public View { -public: - ConnectPhoneView(); - ~ConnectPhoneView() override; - static ConnectPhoneView *GetInstance(); - void OnStart() override; - void ChangeView(int16_t hideView, int16_t showView); - -private: - bool ChangeConnectSelectView(int16_t hideView, int16_t thisView); - bool ChangeConnectOpenView(int16_t hideView, int16_t thisView); - bool CheckViewParam(int16_t hideView, int16_t showView); - ConnectSelectView *connectSelectView{nullptr}; - ConnectOpenView *connectOpenView{nullptr}; - UIViewGroup *container[NUM_CONNECT_PHONE_CONTAINER]{nullptr}; - typedef bool (ConnectPhoneView::*PreprosssChangeView)(int16_t hideView, int16_t thisView); - PreprosssChangeView preProcessView[NUM_CONNECT_PHONE_CONTAINER]; -}; -} // namespace OHOS -#endif // DISCONNECT_PHONE_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/connectnewphone/ConnectSelectView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/connectnewphone/ConnectSelectView.h deleted file mode 100644 index f73d4faf5..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/connectnewphone/ConnectSelectView.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: ConnectSelect View - * Create: 2022-03-22 - */ - -#ifndef CONNECT_SELECT_VIEW_H -#define CONNECT_SELECT_VIEW_H - -#include "View.h" -#include "connectnewphone/ConnectPhonePresenter.h" -#include "components/ui_label.h" -#include "components/ui_button.h" -#include "components/ui_view_group.h" - -namespace OHOS { -class ConnectSelectView { -public: - ConnectSelectView(); - ~ConnectSelectView(); - static ConnectSelectView *GetInstance(); - UIViewGroup *InitShowUpView(void); - -private: - void ShowUpTitleLabel(void); - void CreateUIButton(void); - UILabel *titleLabel{nullptr}; - UIButton *cancelButton{nullptr}; - UIButton *confirmButton{nullptr}; - UIViewGroup *group{nullptr}; -}; -} // namespace OHOS -#endif // CONNECT_SELECT_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/date/DateAdapter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/date/DateAdapter.h deleted file mode 100644 index 676b8007d..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/date/DateAdapter.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: DateAdapter - * Create: 2025-03-23 - */ - -#ifndef DATE_ADAPTER_H -#define DATE_ADAPTER_H - -#include -#include -#include "components/ui_list.h" -#include "components/ui_label.h" -#include "components/ui_view_group.h" -#include "components/ui_image_view.h" -#include "components/abstract_adapter.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "date/DateModel.h" -#include "date/DateItemView.h" - -namespace OHOS { -class DateAdapter : public AbstractAdapter { -public: - explicit DateAdapter(); - ~DateAdapter() override; - void SetData(std::list &data); - uint16_t GetCount(void) override; - UIView *GetView(UIView *inView, int16_t index) override; - void AddListItem(const DateItem &item); - void SetItemClickListener(UIView::OnClickListener *itemclicklistener) - { - itemClickListener = itemclicklistener; - } - void ClearListItem(); - -private: - std::list listData; - UIView::OnClickListener *itemClickListener{nullptr}; -}; -} - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/date/DateButtonAdapter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/date/DateButtonAdapter.h deleted file mode 100644 index da4c0136a..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/date/DateButtonAdapter.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: DateButtonAdapter - * Create: 2025-03-23 - */ - -#ifndef DATE_BUTTON_ADAPTER_H -#define DATE_BUTTON_ADAPTER_H - -#include -#include -#include "components/ui_list.h" -#include "components/ui_label.h" -#include "components/ui_view_group.h" -#include "components/ui_image_view.h" -#include "components/abstract_adapter.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "date/DateModel.h" -#include "date/DateButtonItemView.h" - -namespace OHOS { -class DateButtonAdapter : public AbstractAdapter { -public: - explicit DateButtonAdapter(); - ~DateButtonAdapter() override; - - void SetData(std::list &data); - uint16_t GetCount(void) override; - UIView *GetView(UIView *inView, int16_t index) override; - void AddListItem(const DateButtonItem &item); - void SetItemClickListener(UIView::OnClickListener *itemclicklistener) - { - itemClickListener = itemclicklistener; - } - void ClearListItem(); - -private: - std::list listData; - UIView::OnClickListener *itemClickListener{nullptr}; -}; -} - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/date/DateItemView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/date/DateItemView.h deleted file mode 100644 index 9f7d97676..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/date/DateItemView.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: DateItemView - * Create: 2025-03-23 - */ - -#ifndef DATE_ITEM_VIEW_H -#define DATE_ITEM_VIEW_H - -#include "date/DateModel.h" -#include "UiConfig.h" -#include "components/ui_canvas.h" -#include "components/ui_image_view.h" -#include "components/ui_label.h" -#include "components/ui_view_group.h" - -namespace OHOS { -class DateItemView : public UIViewGroup { -public: - explicit DateItemView(); - ~DateItemView() override; - virtual void SetItemInfo(const DateItem itemInfo); - virtual void SetUpChild(); - const char *GetViewId(); - bool GetVisiable(); - -private: - UILabel sLabel_1; - UIImageView sIcon; - UILabel sLabel_2; - UIImageView sNextImage; - UIImageView Schedule; - UIImageView Signs; - UIImageView BackGround; - DateItem sItemInfo = {nullptr, nullptr, nullptr, false}; -}; -} - -#endif diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/flashlight/FlashLightDefaultPage.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/flashlight/FlashLightDefaultPage.h deleted file mode 100644 index 0314434b6..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/flashlight/FlashLightDefaultPage.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: FlashLightDefaultPage - * Create: 2025-04-24 - */ - -#ifndef FLASHLIGHT_DEFAULT_PAGE_H -#define FLASHLIGHT_DEFAULT_PAGE_H -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_label_button_ext.h" -#include "components/ui_scroll_view.h" -#include "SlicePage.h" -#include "flashlight/FlashLightPresenter.h" - -namespace OHOS { -class FlashLightDefaultPage : public SlicePage, - public UIView::OnClickListener, - public UIView::OnDragListener { -public: - FlashLightDefaultPage(){}; - ~FlashLightDefaultPage(); - void OnStart(void* data) override; - bool OnDrag(UIView& view, const DragEvent& event) override; - bool OnClick(UIView& view, const ClickEvent& event) override; - -private: - FlashLightDefaultPage(const FlashLightDefaultPage &) = delete; - FlashLightDefaultPage &operator=(const FlashLightDefaultPage &) = delete; - FlashLightDefaultPage(FlashLightDefaultPage &&) = delete; - FlashLightDefaultPage &operator=(FlashLightDefaultPage &&) = delete; - - UIScrollView *container_ = nullptr; - UILabel *recoverLabel_ = nullptr; - UILabelButtonExt *cancelButton_ = nullptr; - UILabelButtonExt *confirmButton_ = nullptr; -}; -} // namespace OHOS -#endif /* FLASHLIGHT_DEFAULT_PAGE_H */ diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/flashlight/FlashLightSetItemAdapter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/flashlight/FlashLightSetItemAdapter.h deleted file mode 100644 index 9aeb158ed..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/flashlight/FlashLightSetItemAdapter.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: FlashLightSetItemAdapter - * Create: 2025-11-23 - */ - -#ifndef FLASHLIGHTSET_ITEM_ADAPTER_H -#define FLASHLIGHTSET_ITEM_ADAPTER_H - -#include "flashlight/FlashLightSetItemAdapter.h" -#include "flashlight/FlashLightSetItemView.h" -#include "components/abstract_adapter.h" -#include "gfx_utils/vector.h" - -namespace OHOS { - -class FlashLightSetItemAdapter : public AbstractAdapter { -public: - explicit FlashLightSetItemAdapter(); - ~FlashLightSetItemAdapter() override; - - /* * - * @brief Sets the UIView adapter data, which is a SettingItem linked list. - * - * @param data Indicates the SettingItem linked list data. - * @since 1.0 - * @version 1.0 - */ - void SetData(const Graphic::Vector &data); - - /* * - * @brief Obtains the data size of the UILabel adapter. - * - * @return Returns the data size of the UILabel adapter. - * @since 1.0 - * @version 1.0 - */ - uint16_t GetCount(void) override; - - UIView *GetView(UIView *inView, int16_t index) override; - - void AddListItem(const FlashLightSetItem &item); - - void SetItemClickListener(UIView::OnClickListener *itemclicklistener) - { - itemClickListener = itemclicklistener; - } -private: - Graphic::Vector itemDatas_; - UIView::OnClickListener *itemClickListener{nullptr}; -}; -} - -#endif // FLASHLIGHTSET_ITEM_ADAPTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/flashlight/FlashlightUiResourceImage.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/flashlight/FlashlightUiResourceImage.h deleted file mode 100644 index 50238d30b..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/flashlight/FlashlightUiResourceImage.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: FlashlightUiResourceImage - * Create: 2025-04-24 - */ - -#ifndef FLASHLIGHT_UI_RESOURCE_IMAGE_H -#define FLASHLIGHT_UI_RESOURCE_IMAGE_H -#include -namespace OHOS { -static const int IMAGE_CONVERTER_TOOL_BLINKBUTTON = 0x100001; -static const int IMAGE_CONVERTER_TOOL_BLINKITEM = 0x100002; -static const int IMAGE_CONVERTER_TOOL_COLOR1BUTTON = 0x100003; -static const int IMAGE_CONVERTER_TOOL_COLOR1PRESSBUTTON = 0x100004; -static const int IMAGE_CONVERTER_TOOL_COLOR2BUTTON = 0x100005; -static const int IMAGE_CONVERTER_TOOL_COLOR2PRESSBUTTON = 0x100006; -static const int IMAGE_CONVERTER_TOOL_COLOR3BUTTON = 0x100007; -static const int IMAGE_CONVERTER_TOOL_COLOR3PRESSBUTTON = 0x100008; -static const int IMAGE_CONVERTER_TOOL_COLOR4BUTTON = 0x100009; -static const int IMAGE_CONVERTER_TOOL_COLOR4PRESSBUTTON = 0x10000a; -static const int IMAGE_CONVERTER_TOOL_COLOR5BUTTON = 0x10000b; -static const int IMAGE_CONVERTER_TOOL_COLOR5PRESSBUTTON = 0x10000c; -static const int IMAGE_CONVERTER_TOOL_COLOR6BUTTON = 0x10000d; -static const int IMAGE_CONVERTER_TOOL_COLOR6PRESSBUTTON = 0x10000e; -static const int IMAGE_CONVERTER_TOOL_COLOR7BUTTON = 0x10000f; -static const int IMAGE_CONVERTER_TOOL_COLOR7PRESSBUTTON = 0x100010; -static const int IMAGE_CONVERTER_TOOL_COLOR8BUTTON = 0x100011; -static const int IMAGE_CONVERTER_TOOL_COLOR8PRESSBUTTON = 0x100012; -static const int IMAGE_CONVERTER_TOOL_COLOR9BUTTON = 0x100013; -static const int IMAGE_CONVERTER_TOOL_COLOR9PRESSBUTTON = 0x100014; -static const int IMAGE_CONVERTER_TOOL_COLORITEM = 0x100015; -static const int IMAGE_CONVERTER_TOOL_DOWNARROW = 0x100016; -static const int IMAGE_CONVERTER_TOOL_FLASHLIGHTON = 0x100017; -static const int IMAGE_CONVERTER_TOOL_PLAY1PAGE = 0x100018; -static const int IMAGE_CONVERTER_TOOL_PLAY2PAGE = 0x100019; -static const int IMAGE_CONVERTER_TOOL_PLAY3PAGE = 0x10001a; -static const int IMAGE_CONVERTER_TOOL_PLAY4PAGE = 0x10001b; -static const int IMAGE_CONVERTER_TOOL_PLAY5PAGE = 0x10001c; -static const int IMAGE_CONVERTER_TOOL_PLAY6PAGE = 0x10001d; -static const int IMAGE_CONVERTER_TOOL_PLAY7PAGE = 0x10001e; -static const int IMAGE_CONVERTER_TOOL_PLAY8PAGE = 0x10001f; -static const int IMAGE_CONVERTER_TOOL_PLAY9PAGE = 0x100020; -static const int IMAGE_CONVERTER_TOOL_PLAYBLACKPAGE = 0x100021; -static const int IMAGE_CONVERTER_TOOL_RECOVERBUTTON = 0x100022; -static const int IMAGE_CONVERTER_TOOL_RECOVERCANCLE = 0x100023; -static const int IMAGE_CONVERTER_TOOL_RECOVERCONFIRM = 0x100024; -static const int IMAGE_CONVERTER_TOOL_RIGHTARROW = 0x100025; -} // OHOS -#endif // FLASHLIGHT_UI_RESOURCE_IMAGE_H diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/heartrate/HeartModel.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/heartrate/HeartModel.h deleted file mode 100644 index 20336ca0b..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/heartrate/HeartModel.h +++ /dev/null @@ -1,122 +0,0 @@ -#ifndef HEART_MODEL_H -#define HEART_MODEL_H - -#include -#include "broadcast_feature.h" -#include "broadcast_service.h" -#include "samgr_lite.h" -#include "clock/MainClockView.h" - -#ifdef __cplusplus -extern "C" { -#endif - -int PushOHOSMsgToHeartModel(Request *request); -void HeartDataSubscribeTopic(Topic topic); -void HearDatatUnsubscribeTopic(Topic topic); - -#define HEART_ALL_POINTS 360 - -typedef struct { - uint16_t x; - uint16_t y; - bool flag; -} Point; - -typedef struct { - /** X coordinate */ - uint16_t x; - /** Y coordinate */ - uint16_t y; -} HeartPoint; - -typedef struct { - uint16_t perSec; - uint16_t rest; - uint16_t minX; - uint16_t minValue; - uint16_t maxX; - uint16_t maxValue; - uint16_t index; - Point value[HEART_ALL_POINTS]; -} HeartInfo; - -#pragma pack(4) -typedef struct { - uint16_t perSec; - uint16_t rest; - uint16_t minX; - uint16_t minValue; - uint16_t maxX; - uint16_t maxValue; - uint16_t index; - HeartPoint value[HEART_ALL_POINTS]; -} HeartDatas; - -#pragma pack() - -namespace OHOS { -#define HEART_AVE_NUM 360 -#define HEART_RATE_LIMIT_UPPER 200 -#define HEART_RATE_LIMIT_LOWER 0 -#define INVALID_HEART_VALUE ((int16)0xFFFF) -#define NUM_1 1 -#define NUM_2 2 -#define NUM_3 3 -#define NUM_4 4 -#define NUM_5 5 -#define NUM_6 6 -#define NUM_7 7 -#define NUM_16 16 -#define NUM_99 99 - -typedef struct { - uint32_t heartRatePerSec; - Point heartRateAvg[HEART_AVE_NUM]; - uint32_t heartRateRest; - Point heartRateMax; - Point heartRateMin; -} HealthAllDatas; - -class HeartModel { -public: - HeartModel(); - ~HeartModel(); - static HeartModel *GetInstance(void); - void ObtainingHeartRateData(void); - void PushHealthDatas(HealthMsg healthMsg); - Point* GetAveHeartRate(void); - uint16_t GetAveHeartRateCount(void); - void SetAveHeartRateCount(uint16_t value); - Point* GetMaximumHeartRate(void); - void Init(void); - void HeartRatePros(HeartDatas *heartInfo); - void RefreshHeartRateScreen(uint16_t perSec, uint16_t rest, uint16_t maxRate, uint16_t minRate); - void ClearHeartData(void); - void HandleMaxHeart(uint16_t coord, uint16_t value); - void HandleMinHeart(uint16_t coord, uint16_t value); - void SetHeartRatePerSec(uint32_t sec); - void SetWearStatus(bool status); - bool GetWearStatus(void); - uint16_t GetHeartRateMax(void); - uint16_t GetHeartRateMin(void); - -private: - HealthAllDatas healthDatas; - uint16_t pretime{0}; - uint16_t entryTimes{0}; - uint16_t aveCount{0}; - uint16_t preMaxValue{0}; - uint16_t preMaxX{NUM_1}; - uint16_t preMinValue{HEART_RATE_LIMIT_UPPER}; - uint16_t preMinX{NUM_1}; - uint16_t countMax{0}; - uint16_t countMin{0}; - bool wearStatus{false}; -}; -} - -#ifdef __cplusplus -} -#endif -#endif diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/CustomizationView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/CustomizationView.h deleted file mode 100644 index 6ad618fbd..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/CustomizationView.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Customization View - * Create: 2022-03-02 - */ - -#ifndef CUSTOMIZATION_VIEW_H -#define CUSTOMIZATION_VIEW_H - -#include "View.h" -#include "common/screen.h" -#include "components/ui_label.h" -#include "components/ui_scroll_view.h" -#include "components/ui_radio_button.h" -#include "components/ui_label_button.h" -#include "components/ui_view_group.h" - -namespace OHOS { - -class IndoorWalkUIScrollView : public UIScrollView { -public: - IndoorWalkUIScrollView() {} - ~IndoorWalkUIScrollView() override {} - - bool OnDragEvent(const DragEvent& event) override - { - return UIScrollView::OnDragEvent(event); - } -}; - -class CustomizationView { -public: - CustomizationView(); - ~CustomizationView(); - static CustomizationView *GetInstance(); - UIViewGroup *InitPropertiesView(); - UIViewGroup *GetTimeView(void); - UIViewGroup *GetDistancesView(void); - UIViewGroup *GetHeartView(void); - UIViewGroup *GetSpeedView(void); - UIViewGroup *GetStepsView(void); - UIRadioButton *GetTimeRadio(void); - UIRadioButton *GetDistancesRadio(void); - UIRadioButton *GetHeartRadio(void); - UIRadioButton *GetSpeedRadio(void); - UIRadioButton *GetStepsRadio(void); - IndoorWalkUIScrollView *GetCustomizationViewGroup(void); - -private: - bool ShowUpTitleLabel(); - bool InitTimeView(); - bool InitDistancesView(); - bool InitHeartView(); - bool InitSpeedView(); - bool InitStepsView(); - IndoorWalkUIScrollView *group{nullptr}; - UILabel *lable{nullptr}; - UIViewGroup *timeView{nullptr}; // 时间 - UIViewGroup *distancesView{nullptr}; // 距离 - UIViewGroup *heartView{nullptr}; // 心率 - UIViewGroup *speedView{nullptr}; // 速度 - UIViewGroup *stepsView{nullptr}; // 步数 - - UIRadioButton *timeRadio{nullptr}; // 时间 - UIRadioButton *distancesRadio{nullptr}; // 距离 - UIRadioButton *heartRadio{nullptr}; // 心率 - UIRadioButton *speedRadio{nullptr}; // 速度 - UIRadioButton *stepsRadio{nullptr}; // 步数 - - UILabelButton *timeButton{nullptr}; // 时间 - UILabelButton *distancesButton{nullptr}; // 距离 - UILabelButton *heartButton{nullptr}; // 心率 - UILabelButton *speedButton{nullptr}; // 速度 - UILabelButton *stepsButton{nullptr}; // 步数 -}; -} // namespace OHOS -#endif // CUSTOMIZATION_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkEndView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkEndView.h deleted file mode 100644 index 06fc19dd7..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkEndView.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: IndoorWalk End View - * Create: 2022-03-02 - */ - -#ifndef INDOORWALK_END_VIEW_H -#define INDOORWALK_END_VIEW_H - -#include "components/ui_label.h" -#include "components/ui_button.h" -#include "components/ui_view_group.h" -#include "common/screen.h" - -namespace OHOS { - -class IndoorWalkEndView { -public: - IndoorWalkEndView(); - ~IndoorWalkEndView(); - static IndoorWalkEndView *GetInstance(); - UIViewGroup *InitShowUpView(void); - -private: - bool ShowUpTitleLabel(void); - bool CreateUIButton(void); - UILabel *titleLabel{nullptr}; - UIButton *cancelButton{nullptr}; - UIButton *confirmButton{nullptr}; - UIViewGroup *group{nullptr}; -}; - -} // namespace OHOS -#endif // INDOORWALK_END_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkModel.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkModel.h deleted file mode 100644 index 2afd4efd3..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkModel.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: IndoorWalk Model - * Create: 2022-03-02 - */ - -#ifndef INDOORWALK_MODEL_H -#define INDOORWALK_MODEL_H - -#include -#include "string" -#include "gfx_utils/list.h" -#include "components/ui_label.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void InitIndoorWalkTimer(); -void DisableIndoorWalkTimer(); - -#ifdef __cplusplus -} -#endif - -namespace OHOS { -class IndoorWalkModel { -public: - ~IndoorWalkModel(); - static IndoorWalkModel *GetInstance(void); - std::string GetConnectionView(); - void SetConnectionView(const char* id); - void SetTextLableFirstTop(const char *lable, const char *lableUnit); - std::string GetTextLableFirstTop(); - std::string GetTextLableUnitFirstTop(); - void SetTextLableFirstLeft(const char *lable, const char *lableUnit); - std::string GetTextLableFirstLeft(); - std::string GetTextLableUnitFirstLeft(); - void SetTextLableFirstRight(const char *lable, const char *lableUnit); - std::string GetTextLableFirstRight(); - std::string GetTextLableUnitFirstRight(); - void SetTextLableFirstBottom(const char *lable, const char *lableUnit); - std::string GetTextLableFirstBottom(); - std::string GetTextLableUnitFirstBottom(); - void SetTextLableSecondTop(const char *lable, const char *lableUnit); - std::string GetTextLableSecondTop(); - std::string GetTextLableUnitSecondTop(); - void SetTextLableSecondLeft(const char *lable, const char *lableUnit); - std::string GetTextLableSecondLeft(); - std::string GetTextLableUnitSecondLeft(); - void SetTextLableSecondRight(const char *lable, const char *lableUnit); - std::string GetTextLableSecondRight(); - std::string GetTextLableUnitSecondRight(); - void SetTextLableThirdTop(const char *lable, const char *lableUnit); - std::string GetTextLableThirdTop(); - std::string GetTextLableUnitThirdTop(); - void SetTextLableThirdBottom(const char *lable, const char *lableUnit); - std::string GetTextLableThirdBottom(); - std::string GetTextLableUnitThirdBottom(); - void SetTextLableFourth(const char *lable, const char *lableUnit); - std::string GetTextLableFourth(); - std::string GetTextLableUnitFourth(); - void SetInitialStep(const uint32_t &value); - int GetInitialStep(); - std::string& DisplayMotionDuration(); - bool OpenDistancesSensor(void); - bool CloseDistancesSensor(void); - void SetInitialDistances(const float &value); - float GetInitialDistances(); - void SetCurrentDistances(const float &value); - float GetCurrentDistances(); - -private: - IndoorWalkModel(); - std::string selectPropertiesID; - uint32_t initialStep; - float initialDistances; - float currentDistances; - std::string textLableFirstTop{"00:00:00"}; - std::string textLableUnitFirstTop{"时间"}; - std::string textLableFirstLeft{"00:00:00"}; - std::string textLableUnitFirstLeft{"时间"}; - std::string textLableFirstRight{"00:00:00"}; - std::string textLableUnitFirstRight{"时间"}; - std::string textLableFirstBottom{"00:00:00"}; - std::string textLableUnitFirstBottom{"时间"}; - std::string textLableSecondTop{"00:00:00"}; - std::string textLableUnitSecondTop{"时间"}; - std::string textLableSecondLeft{"00:00:00"}; - std::string textLableUnitSecondLeft{"时间"}; - std::string textLableSecondRight{"00:00:00"}; - std::string textLableUnitSecondRight{"时间"}; - std::string textLableThirdTop{"00:00:00"}; - std::string textLableUnitThirdTop{"时间"}; - std::string textLableThirdBottom{"00:00:00"}; - std::string textLableUnitThirdBottom{"时间"}; - std::string textLableFourth{"00:00:00"}; - std::string textLableUnitFourth{"时间"}; - - std::string motionDuration; -}; -} - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkMotionView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkMotionView.h deleted file mode 100644 index 6619e7093..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkMotionView.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: IndoorWalk Motion View - * Create: 2022-03-02 - */ - -#ifndef INDOORWALK_MOTION_VIEW_H -#define INDOORWALK_MOTION_VIEW_H - -#include "View.h" -#include "indoorwalk/MotionPageFirst.h" -#include "indoorwalk/MotionPageSecond.h" -#include "indoorwalk/MotionPageThird.h" -#include "indoorwalk/MotionPageFourth.h" -#include "indoorwalk/MotionPageFifth.h" -#include "components/ui_swipe_view.h" - -namespace OHOS { -typedef enum { - MOTION_FIRST = 0, - MOTION_SECOND, - MOTION_THIRD, - MOTION_FOURTH, - MOTION_FIFTH, - MAX_MOTIONPAGE, -} MotionPageId; - -class IndoorWalkMotionView { -public: - IndoorWalkMotionView(); - ~IndoorWalkMotionView(); - static IndoorWalkMotionView *GetInstance(); - void PreLoad(uint16_t index); - UIViewGroup *WalkMotionViewInit(void); - AppGroupView *InitMotionPageFirst(void); - AppGroupView *InitMotionPageSecond(void); - AppGroupView *InitMotionPageThird(void); - AppGroupView *InitMotionPageFourth(void); - AppGroupView *InitMotionPageFifth(void); - void InitialStep(void); -private: - int16_t maxPage = MAX_MOTIONPAGE; - UISwipeView *walkMotionList{nullptr}; - MotionPageFirst *motionPageFirst{nullptr}; - MotionPageSecond *motionPageSecond{nullptr}; - MotionPageThird *motionPageThird{nullptr}; - MotionPageFourth *motionPageFourth{nullptr}; - MotionPageFifth *motionPageFifth{nullptr}; - AppGroupView *recordCard[MAX_MOTIONPAGE]{nullptr}; - bool pageStatus[MAX_MOTIONPAGE]{false}; -}; -} // namespace OHOS -#endif // INDOORWALK_MOTION_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkPreparedView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkPreparedView.h deleted file mode 100644 index 8f073adba..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkPreparedView.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: IndoorWalk Prepared View - * Create: 2022-03-02 - */ - -#ifndef INDOORWALK_PREPARED_VIEW_H -#define INDOORWALK_PREPARED_VIEW_H - -#include "View.h" -#include "components/ui_label.h" -#include "components/ui_image_view.h" -#include "components/ui_label_button.h" -#include "components/ui_image_animator.h" -#include "components/ui_view_group.h" -#include "common/screen.h" - -namespace OHOS { -class IndoorWalkPreparedView { -public: - IndoorWalkPreparedView(); - ~IndoorWalkPreparedView(); - static IndoorWalkPreparedView *GetInstance(); - UIViewGroup *InitShowUpView(void); - bool InitBatteryView(); - bool InitHeartbeatView(); - bool InitLableVIew(); - void IndoorWalkHeartbeatStop(); - void IndoorWalkHeartbeatStart(); - void RefreshHeartbeatData(int value); - -private: - UILabel *timeLabel{nullptr}; - UIImageView *battery{nullptr}; - UILabel *batteryLable{nullptr}; - UIImageAnimatorView *imageAnimator{nullptr}; - UILabel *heartRateLabel{nullptr}; - UILabel *titleLabel{nullptr}; - UIButton *walkButton{nullptr}; - UIViewGroup *group{nullptr}; -}; -} // namespace OHOS -#endif // INDOORWALK_PREPARED_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkPresenter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkPresenter.h deleted file mode 100644 index 1b7f95615..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkPresenter.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: IndoorWalk Presenter - * Create: 2022-03-02 - */ - -#ifndef INDOORWALK_PRESENTER_H -#define INDOORWALK_PRESENTER_H - -#include "Presenter.h" -#include "components/ui_label.h" -#include "NativeLauncher.h" -#include "NativeAbility.h" -#include "components/ui_swipe_view.h" - - -namespace OHOS { -enum IndoorWalkPresenterNum : uint8_t { - INDOORWALKPREPAREDVIEW = 0, - INDOORWALKMOTIONVIEW, - CUSTOMIZATIONVIEW, - INDOORWALKENDVIEW, - INDOORWALK_MAX, - }; - -static constexpr const char *INDOORWALK_CANCEL_BUTTON = "cancelButton"; -static constexpr const char *INDOORWALK_CONFIRM_BUTTON = "confirmButton"; -static constexpr const char *WALK_BUTTON = "walkButton"; - -static constexpr const char *INDOORWALK_PREPARED_VIEW = "indoorWalkPreparedView"; -static constexpr const char *INDOORWALK_MOTION_VIEW = "indoorWalkMotionView"; -static constexpr const char *INDOORWALK_END_VIEW = "indoorWalkEndView"; -static constexpr const char *CUSTOMIZATION_VIEW = "customizationView"; - -static constexpr const char *LABLE_FIRST_TOP = "lableFirstTop"; -static constexpr const char *LABLE_FIRST_LEFT = "lableFirstLeft"; -static constexpr const char *LABLE_FIRST_RIGHT = "lableFirstRight"; -static constexpr const char *LABLE_FIRST_BOTTOM = "lableFirstBottom"; -static constexpr const char *LABLE_SECOND_TOP = "lableSecondTop"; -static constexpr const char *LABLE_SECOND_LEFT = "lableSecondLeft"; -static constexpr const char *LABLE_SECOND_RIGHT = "lableSecondRight"; -static constexpr const char *LABLE_THIRD_TOP = "lableThirdTop"; -static constexpr const char *LABLE_THIRD_BOTTOM = "lableThirdBottom"; -static constexpr const char *LABLE_FOURTH = "lableFourth"; - -static constexpr const char *IMAGE_FIRST_TOP = "imageFirstTop"; -static constexpr const char *IMAGE_FIRST_LEFT = "imageFirstLeft"; -static constexpr const char *IMAGE_FIRST_RIGHT = "imageFirstRight"; -static constexpr const char *IMAGE_FIRST_BOTTOM = "imageFirstBottom"; -static constexpr const char *IMAGE_SECOND_TOP = "imageSecondTop"; -static constexpr const char *IMAGE_SECOND_LEFT = "imageSecondLeft"; -static constexpr const char *IMAGE_SECOND_RIGHT = "imageSecondRight"; -static constexpr const char *IMAGE_THIRD_TOP = "imageThirdTop"; -static constexpr const char *IMAGE_THIRD_BOTTOM = "imageThirdBottom"; -static constexpr const char *IMAGE_FOURTH = "imageFourth"; - -static constexpr const char *TIME_BUTTON = "timeView"; // 时间 -static constexpr const char *DISTANCES_BUTTON = "distancesView"; // 距离 -static constexpr const char *HEART_BUTTON = "heartView"; // 心率 -static constexpr const char *SPEED_BUTTON = "speedView"; // 速度 -static constexpr const char *STEPS_BUTTON = "stepsView"; // 步数 - -class IndoorWalkView; -class IndoorWalkPresenter : public Presenter, public UISwipeView::OnSwipeListener, - public UIView::OnClickListener, public UIView::OnLongPressListener, - public UIView::OnDragListener { -public: - IndoorWalkPresenter(); - ~IndoorWalkPresenter() override; - static IndoorWalkPresenter *GetInstance(); - bool OnClick(UIView& view, const ClickEvent& event) override; - bool OnDrag(UIView& view, const DragEvent& event) override; - bool OnLongPress(UIView& view, const LongPressEvent& event) override; - void OnSwipe(UISwipeView& view) override; - void HidePageImageView(void); - void ModifiesProperties(const char* id, const char *lable, const char *lableUnit); - void ModifiesPageFirstTop(const char *lable, const char *lableUnit); - void ModifiesPageFirstLeft(const char *lable, const char *lableUnit); - void ModifiesPageFirstRight(const char *lable, const char *lableUnit); - void ModifiesPageFirstBottom(const char *lable, const char *lableUnit); - void ModifiesPageSecondTop(const char *lable, const char *lableUnit); - void ModifiesPageSecondLeft(const char *lable, const char *lableUnit); - void ModifiesPageSecondRight(const char *lable, const char *lableUnit); - void ModifiesPageThirdTop(const char *lable, const char *lableUnit); - void ModifiesPageThirdBottom(const char *lable, const char *lableUnit); - void ModifiesPageFourth(const char *lable, const char *lableUnit); - void SetPropertiesState(const char* id); - void SetCustomizationState(const char *lableUnit); - void InitStepsValue(char *steps); - void ModifiesTime(void); - void ModifiesDistances(float value); - void ModifiesSteps(int step); - void ModifiesHeartRate(int value); - - void ImageOnClick(const char* id); - void CancelButtonOnClick(const char* id); - void ConfirmButtonOnClick(const char* id); - void WalkButtonOnClick(const char* id); - void TimeViewOnClick(const char* id); - void DistancesViewOnClick(const char* id); - void HeartViewOnClick(const char* id); - void SpeedViewOnClick(const char* id); - void StepsViewOnClick(const char* id); - - void LongPressPageFirst(); - void LongPressPageSecond(); - void LongPressPageThird(); - void LongPressPageFourth(); - - void DragIndoorWalkPreparedView(); - void DragIndoorWalkMotionView(); - void DragIndoorWalkEndView(); - void DragCustomizationView(); - - void SetPropertiesPageFirstTop(); - void SetPropertiesPageFirstLeft(); - void SetPropertiesPageFirstRight(); - void SetPropertiesPageFirstBottom(); - void SetPropertiesPageSecondTop(); - void SetPropertiesPageSecondLeft(); - void SetPropertiesPageSecondRight(); - void SetPropertiesPageThirdTop(); - void SetPropertiesPageThirdBottom(); - void SetPropertiesPageFourth(); - -private: - void ClickFunc(const char *buttonName); - void LongPressFunc(const char *buttonId); - void DragFunc(const char *buttonId); - void ModifiesFunc(const char *buttonName, const char *lable, const char *lableUnit); - void SetPropertiesFunc(const char *buttonName); -}; -} // namespace OHOS -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkView.h deleted file mode 100644 index c39891ce8..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/IndoorWalkView.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: IndoorWalk View - * Create: 2022-03-02 - */ - -#ifndef INDOORWALK_VIEW_H -#define INDOORWALK_VIEW_H - -#include "indoorwalk/IndoorWalkEndView.h" -#include "View.h" -#include "indoorwalk/IndoorWalkPresenter.h" -#include "indoorwalk/IndoorWalkPreparedView.h" -#include "indoorwalk/CustomizationView.h" -#include "indoorwalk/IndoorWalkMotionView.h" -#include "components/ui_view_group.h" - -namespace OHOS { -constexpr int16_t NUM_WALKCONTAINER = 4; - -class IndoorWalkPresenter; -class IndoorWalkView : public View { -public: - IndoorWalkView(); - ~IndoorWalkView() override; - static IndoorWalkView *GetInstance(); - void OnStart() override; - void OnStop() override; - void ChangeView(int16_t hideView, int16_t showView); - -private: - bool ChangeIndoorWalkPreparedView(int16_t hideView, int16_t thisView); - bool ChangeIndoorWalkMotionView(int16_t hideView, int16_t thisView); - bool ChangeCustomizationView(int16_t hideView, int16_t thisView); - bool ChangeIndoorWalkEndView(int16_t hideView, int16_t thisView); - bool CheckViewParam(int16_t hideView, int16_t showView); - IndoorWalkPreparedView *indoorWalkPreparedView{nullptr}; - IndoorWalkMotionView *indoorWalkMotionView{nullptr}; - CustomizationView *customizationView{nullptr}; - IndoorWalkEndView *indoorWalkEndView{nullptr}; - UIViewGroup *container[NUM_WALKCONTAINER]{nullptr}; - typedef bool (IndoorWalkView::*PreprosssChangeView)(int16_t hideView, int16_t thisView); - PreprosssChangeView preProcessView[NUM_WALKCONTAINER]; -}; -} // namespace OHOS -#endif // INDOORWALK_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/MotionPageFifth.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/MotionPageFifth.h deleted file mode 100644 index 5d1b8fba7..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/MotionPageFifth.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Motion PageFifth View - * Create: 2022-03-02 - */ - -#ifndef MOTION_PAGEFIFTH_VIEW_H -#define MOTION_PAGEFIFTH_VIEW_H - -#include "View.h" -#include "wearable_log.h" -#include "ohos_types.h" -#include "components/ui_label.h" -#include "components/ui_image_view.h" -#include "main/AppGroupView.h" - -namespace OHOS { -class MotionPageFifth : public AppGroupView { -public: - MotionPageFifth(); - ~MotionPageFifth() override; - static MotionPageFifth *GetInstance(void); - bool InitView(void *caller) override; - bool InitPageFifthLableView(void); - bool InitPageFifthImageView(void); -private: - UILabel *lableFifth{nullptr}; - UIImageView *imageFifthLeft{nullptr}; - UIImageView *imageFifthRight{nullptr}; -}; -} // namespace OHOS -#endif // MOTION_PAGEFIFTH_VIEW_H diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/MotionPageFirst.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/MotionPageFirst.h deleted file mode 100644 index fb4f42456..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/MotionPageFirst.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Motion PageFirst View - * Create: 2022-03-02 - */ - -#ifndef MOTION_PAGEFIRST_VIEW_H -#define MOTION_PAGEFIRST_VIEW_H - -#include "View.h" -#include "wearable_log.h" -#include "ohos_types.h" -#include "components/ui_label.h" -#include "components/ui_image_view.h" -#include "main/AppGroupView.h" - -namespace OHOS { -class MotionPageFirst : public AppGroupView { -public: - MotionPageFirst(); - ~MotionPageFirst() override; - static MotionPageFirst *GetInstance(void); - bool InitView(void *caller) override; - bool InitPageFirstImageView(void); - bool InitPageFirstLableTopView(void); - bool InitPageFirstLableLeftView(void); - bool InitPageFirstLableRightView(void); - bool InitPageFirstLableBottomView(void); - void HideInitPageFirstImageView(void); - void ShowInitPageFirstImageView(void); - UILabel *GetLableFirstTop(void); - UILabel *GetLableUnitFirstTop(void); - UILabel *GetLableFirstLeft(void); - UILabel *GetLableUnitFirstLeft(void); - UILabel *GetLableFirstRight(void); - UILabel *GetLableUnitFirstRight(void); - UILabel *GetLableFirstBottom(void); - UILabel *GetLableUnitFirstBottom(void); -private: - void SetLableTemplate(UILabel *label); - void SetUnitLableTemplate(UILabel *label); - UILabel *lableFirstTop{nullptr}; - UILabel *lableFirstLeft{nullptr}; - UILabel *lableFirstRight{nullptr}; - UILabel *lableFirstBottom{nullptr}; - UILabel *lableUnitFirstTop{nullptr}; - UILabel *lableUnitFirstLeft{nullptr}; - UILabel *lableUnitFirstRight{nullptr}; - UILabel *lableUnitFirstBottom{nullptr}; - UIImageView *backGroundFirst{nullptr}; - UIImageView *imageFirstTop{nullptr}; - UIImageView *imageFirstLeft{nullptr}; - UIImageView *imageFirstRight{nullptr}; - UIImageView *imageFirstBottom{nullptr}; -}; -} // namespace OHOS -#endif // MOTION_PAGEFIRST_VIEW_H diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/MotionPageFourth.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/MotionPageFourth.h deleted file mode 100644 index b3237f0ab..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/MotionPageFourth.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Motion PageFourth View - * Create: 2022-03-02 - */ - -#ifndef MOTION_PAGEFOURTH_VIEW_H -#define MOTION_PAGEFOURTH_VIEW_H - -#include "View.h" -#include "wearable_log.h" -#include "ohos_types.h" -#include "components/ui_label.h" -#include "components/ui_image_view.h" -#include "main/AppGroupView.h" - -namespace OHOS { -class MotionPageFourth : public AppGroupView { -public: - MotionPageFourth(); - ~MotionPageFourth() override; - static MotionPageFourth *GetInstance(void); - bool InitView(void *caller) override; - bool InitPageFourthLableView(void); - bool InitPageFourthImageView(void); - void HideInitPageFourthImageView(void); - void ShowInitPageFourthImageView(void); - UILabel *GetLableFourth(void); - UILabel *GetLableUnitFourth(void); -private: - UILabel *lableFourth{nullptr}; - UILabel *lableUnitFourth{nullptr}; - UIImageView *backGroundFourth{nullptr}; - UIImageView *imageFourth{nullptr}; -}; -} // namespace OHOS -#endif // MOTION_PAGEFOURTH_VIEW_H diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/MotionPageSecond.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/MotionPageSecond.h deleted file mode 100644 index fc44d1825..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/MotionPageSecond.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Motion PageSecond View - * Create: 2022-03-02 - */ - -#ifndef MOTION_PAGESECOND_VIEW_H -#define MOTION_PAGESECOND_VIEW_H - -#include "View.h" -#include "wearable_log.h" -#include "ohos_types.h" -#include "components/ui_label.h" -#include "components/ui_image_view.h" -#include "main/AppGroupView.h" - -namespace OHOS { -class MotionPageSecond : public AppGroupView { -public: - MotionPageSecond(); - ~MotionPageSecond() override; - static MotionPageSecond *GetInstance(void); - bool InitView(void *caller) override; - bool InitPageSecondImageView(void); - bool InitPageSecondLableTopView(void); - bool InitPageSecondLableLeftView(void); - bool InitPageSecondLableRightView(void); - void HideInitPageSecondImageView(void); - void ShowInitPageSecondImageView(void); - UILabel *GetLableSecondTop(void); - UILabel *GetLableUnitSecondTop(void); - UILabel *GetLableSecondLeft(void); - UILabel *GetLableUnitSecondLeft(void); - UILabel *GetLableSecondRight(void); - UILabel *GetLableUnitSecondRight(void); -private: - void SetLableTemplate(UILabel *label); - void SetUnitLableTemplate(UILabel *label); - UILabel *lableSecondTop{nullptr}; - UILabel *lableSecondLeft{nullptr}; - UILabel *lableSecondRight{nullptr}; - UILabel *lableUnitSecondTop{nullptr}; - UILabel *lableUnitSecondLeft{nullptr}; - UILabel *lableUnitSecondRight{nullptr}; - UIImageView *backGroundSecond{nullptr}; - UIImageView *imageSecondTop{nullptr}; - UIImageView *imageSecondLeft{nullptr}; - UIImageView *imageSecondRight{nullptr}; -}; -} // namespace OHOS -#endif // MOTION_PAGESECOND_VIEW_H diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/MotionPageThird.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/MotionPageThird.h deleted file mode 100644 index 0416dcb3a..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/indoorwalk/MotionPageThird.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Motion PageThird View - * Create: 2022-03-02 - */ - -#ifndef MOTION_PAGETHIRD_VIEW_H -#define MOTION_PAGETHIRD_VIEW_H - -#include "View.h" -#include "wearable_log.h" -#include "ohos_types.h" -#include "components/ui_label.h" -#include "components/ui_image_view.h" -#include "main/AppGroupView.h" - -namespace OHOS { -class MotionPageThird : public AppGroupView { -public: - MotionPageThird(); - ~MotionPageThird() override; - static MotionPageThird *GetInstance(void); - bool InitView(void *caller) override; - bool InitPageThirdImageView(void); - bool InitPageThirdLableTopView(void); - bool InitPageThirdLableBottomView(void); - void HideInitPageThirdImageView(void); - void ShowInitPageThirdImageView(void); - UILabel *GetLableThirdTop(void); - UILabel *GetLableUnitThirdTop(void); - UILabel *GetLableThirdBottom(void); - UILabel *GetLableUnitThirdBottom(void); -private: - void SetLableTemplate(UILabel *label); - void SetUnitLableTemplate(UILabel *label); - UILabel *lableThirdTop{nullptr}; - UILabel *lableThirdBottom{nullptr}; - UILabel *lableUnitThirdTop{nullptr}; - UILabel *lableUnitThirdBottom{nullptr}; - UIImageView *backGroundThird{nullptr}; - UIImageView *imageThirdTop{nullptr}; - UIImageView *imageThirdBottom{nullptr}; -}; -} // namespace OHOS -#endif // MOTION_PAGETHIRD_VIEW_H diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/main/MessageAdapter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/main/MessageAdapter.h deleted file mode 100644 index a3e52fe35..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/main/MessageAdapter.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - */ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: MessageAdapter.h - * Author: - * Create: 2021-11-23 - */ - -#ifndef MESSAGE_ADAPTER_H -#define MESSAGE_ADAPTER_H - -#include -#include -#include "components/ui_list.h" -#include "components/ui_label.h" -#include "components/ui_view_group.h" -#include "components/ui_image_view.h" -#include "components/abstract_adapter.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "main/MainModel.h" -#include "main/MessageItemView.h" - -namespace OHOS { -class MessageAdapter : public AbstractAdapter { -public: - explicit MessageAdapter(); - ~MessageAdapter() override; - - /* * - * @brief Sets the UIView adapter data, which is a WeatherItem linked list. - * - * @param data Indicates the MessageItem linked list data. - * @since 1.0 - * @version 1.0 - */ - void SetData(std::list &data); - - /* * - * @brief Obtains the data size of the UILabel adapter. - * - * @return Returns the data size of the UILabel adapter. - * @since 1.0 - * @version 1.0 - */ - uint16_t GetCount(void) override; - - UIView *GetView(UIView *inView, int16_t index) override; - - void AddListItem(const MessageItem &item); - - void ClearListItem(); - - void SetItemClickListener(UIView::OnClickListener *itemclicklistener) - { - itemClickListener = itemclicklistener; - } -private: - std::list listData; - UIView::OnClickListener *itemClickListener{nullptr}; -}; -} - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/main/MessageMainView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/main/MessageMainView.h deleted file mode 100644 index 79b049adf..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/main/MessageMainView.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: WeekStep - * Author: - * Create: 2021-09-11 - */ - -#ifndef MESSAGE_MAIN_VIEW_H -#define MESSAGE_MAIN_VIEW_H - -#include "graphic_types.h" -#include "wearable_log.h" -#include "components/ui_card_page.h" -#include "components/ui_view_group.h" -#include "components/ui_image_view.h" -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "main/MessageModel.h" -#include "main/MessageAdapter.h" - -namespace OHOS { -class MessageMainView : public UICardPage { -public: - MessageMainView(); - ~MessageMainView() override; - static MessageMainView *GetInstance(void); - bool InitView(); - void PreLoad(void) override; - void VerticalViewInits(void); - void ConfirmDeletion(void); - void CancelDeletion(void); - void ShowMessageList(void); - void DeletionView(void); - void NoNotify(void); - void NewNotify(void); - void RefreshMessageList(std::vector item); - bool InitScrollData(); - MessageAdapter *listAdapter{nullptr}; - UIList *contentList{nullptr}; // 列表 -private: - UILabel *messageLables{nullptr}; // 无消息 - UILabel *messageLable{nullptr}; // 通知 - UILabel *deletereminder{nullptr}; // 是否删除通知? - UILabelButton *confirm{nullptr}; // 确认 - UILabelButton *cancel{nullptr}; // 取消 - UIImageView *notice{nullptr}; // 删除图标 - UIView::OnClickListener *clickListener{nullptr}; - UIView::OnClickListener *confirmListener{nullptr}; - UIView::OnClickListener *cancelListener{nullptr}; - UIView::OnClickListener *notifyListener{nullptr}; - UIView::OnClickListener *newNotifyListener{nullptr}; -}; -} -#endif diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/CallerDisplayView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/CallerDisplayView.h deleted file mode 100644 index ef5617220..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/CallerDisplayView.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: CallerDisplayView.h - * Author: - * Create: 2021-10-12 - */ -#ifndef CALLER_DISPLAY_VIEW_H -#define CALLER_DISPLAY_VIEW_H - -#include "View.h" -#include "components/ui_label.h" -#include "components/ui_image_animator.h" -#include "components/ui_view_group.h" -#include "ohos_types.h" - -namespace OHOS { -class CallerDisplayView { -public: - CallerDisplayView(); - ~CallerDisplayView(); - UIViewGroup *CreateUIViewGroup(); - - static CallerDisplayView *GetInstance(); -private: - bool InitAddOnclickevent(void); - bool InitImageViewDisplay(void); - bool InitUILabelDisplay(void); - - UIViewGroup *group{nullptr}; - UIView::OnClickListener* clickLeftListener{nullptr}; - UIImageView *imageAgreeing{nullptr}; - UIImageView *imageDissgree{nullptr}; - UILabel *callerDisplay{nullptr}; - UILabel *currentTimes{nullptr}; -}; -} - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/CallingView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/CallingView.h deleted file mode 100644 index 6ee0de153..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/CallingView.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: CallingView.h - * Author: - * Create: 2021-10-12 - */ -#ifndef CALLING_VIEW_H -#define CALLING_VIEW_H - -#include "View.h" -#include "components/ui_label.h" -#include "components/ui_image_animator.h" -#include "components/ui_view_group.h" -#include "ohos_types.h" -#include "UiConfig.h" -#include "ChangeSliceListener.h" - - -namespace OHOS { -class CallingView { -public: - CallingView(); - ~CallingView(); - UIViewGroup *CreateUIViewGroup(); - UIImageView *GetImageMicrophone(); - static CallingView *GetInstance(); - UILabel *GetCallingDisplayLabel(); - UILabel *GetCallingDurationLabel(); -private: - bool InitAddOnclickevent(void); - bool InitImageViewDisplay(void); - bool InitUILabelDisplay(void); - - UIImageView *imageMicrophone{nullptr}; - UIViewGroup *group{nullptr}; - UIView::OnClickListener* clickLeftListener{nullptr}; - UIImageView *imageHandUp{nullptr}; - UIImageView *imageHorns{nullptr}; - UILabel *callerDisplay{nullptr}; - UILabel *currentTimes{nullptr}; - UILabel *callDuration{nullptr}; -}; -} - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/DialingScreenView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/DialingScreenView.h deleted file mode 100644 index 2b827c754..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/DialingScreenView.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: DialingScreenView.h - * Author: - * Create: 2021-10-12 - */ -#ifndef DIALING_SCREEN_VIEW_H -#define DIALING_SCREEN_VIEW_H - -#include "View.h" -#include "components/ui_label.h" -#include "components/ui_image_animator.h" -#include "components/ui_view_group.h" -#include "ohos_types.h" - -namespace OHOS { -class DialingScreenView { -public: - DialingScreenView(); - ~DialingScreenView(); - UIViewGroup *CreateUIViewGroup(); - - static DialingScreenView *GetInstance(); -private: - bool InitUILabelDisplay(); - - UIViewGroup *group{nullptr}; - UIView::OnClickListener* clickLeftListener{nullptr}; - UILabel *dialingId{nullptr}; - UILabel *dialingTime{nullptr}; - UILabel *currentTimes{nullptr}; - UIImageView *handup{nullptr}; -}; -} - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/MainCallingPresenter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/MainCallingPresenter.h deleted file mode 100644 index 56b231da4..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/MainCallingPresenter.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: MainCallingPresenter.h - * Author: - * Create: 2021-10-12 - */ -#ifndef MAIN_CALLING_PRESENTER_H -#define MAIN_CALLING_PRESENTER_H - -#include "Presenter.h" -#include "ohos_types.h" -#include "callerlog/CallerLogModel.h" -#include "main/VolumeSettingView.h" -#include "main/VolumeSettingPresenter.h" - -namespace OHOS { -class MainCallingView; -class MainCallingPresenter : public Presenter, public UIView::OnClickListener { -public: - MainCallingPresenter(); - ~MainCallingPresenter() override; - static MainCallingPresenter *GetInstance(); - - void HonrsViewChange(); - bool CallingViewDisplay(); - bool InitPointerValue(); - bool OnClick(UIView& view, const ClickEvent& event) override; - VolumeSettingView *GetvolumeSetting(); -private: - int changeImage{0}; - bool HintsHandupClick(); - VolumeSettingView *volumeSetting{nullptr}; -}; -} - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/MainCallingView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/MainCallingView.h deleted file mode 100644 index 0c7483a94..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/MainCallingView.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: MainCallingView.h - * Author: - * Create: 2021-10-12 - */ -#ifndef MAIN_CALLING_VIEW_H -#define MAIN_CALLING_VIEW_H - -#include "View.h" -#include "components/ui_view_group.h" -#include "ohos_types.h" -#include "makephone/CallerDisplayView.h" -#include "makephone/CallingView.h" -#include "makephone/DialingScreenView.h" -#include "makephone/WaitingHintsView.h" - -namespace OHOS { -class MainCallingPresenter; -class MainCallingView : public View { -public: - MainCallingView(); - ~MainCallingView() override; - - void OnStart() override; - - static MainCallingView *GetInstance(); - UIViewGroup *GetDisplayGroup(); - UIViewGroup *GetCallingGroup(); - UIViewGroup *GetScreenGroup(); - UIViewGroup *GetWaitingGroup(); - CallingView *GetCallingView(); -private: - bool InitPointerValue(); - UIViewGroup *displayGroup{nullptr}; - UIViewGroup *callingGroup{nullptr}; - UIViewGroup *screenGroup{nullptr}; - UIViewGroup *waitingGroup{nullptr}; - CallerDisplayView *displayView{nullptr}; - CallingView *callView{nullptr}; - DialingScreenView *screenView{nullptr}; - WaitingHintsView *waitingView{nullptr}; -}; -} - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/WaitingHintsView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/WaitingHintsView.h deleted file mode 100644 index 85e93c9ec..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/makephone/WaitingHintsView.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: WaitingHintsView.h - * Author: - * Create: 2022-03-14 - */ -#ifndef WAITING_HINTS_VIEW_H -#define WAITING_HINTS_VIEW_H - -#include "View.h" -#include "components/ui_label.h" -#include "components/ui_image_animator.h" -#include "components/ui_view_group.h" -#include "ohos_types.h" - -namespace OHOS { -class WaitingHintsView { -public: - WaitingHintsView(); - ~WaitingHintsView(); - UIViewGroup *CreateUIViewGroup(); - - static WaitingHintsView *GetInstance(); -private: - bool InitImageViewDisplay(void); - bool InitUILabelDisplay(void); - - UIViewGroup *group{nullptr}; - UIView::OnClickListener* clickLeftListener{nullptr}; - UIImageView *imageDissgree{nullptr}; - UILabel *callerDisplay{nullptr}; - UILabel *newcallHints{nullptr}; -}; -} - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/player/BluetoothView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/player/BluetoothView.h deleted file mode 100644 index a5465e563..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/player/BluetoothView.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: Bluetooth view 设置页面 - * Create: 2021-09-5 - */ - -#ifndef BLUETOOTH_VIEW_H -#define BLUETOOTH_VIEW_H - -#include "components/ui_label.h" -#include "components/ui_image_view.h" -#include "components/ui_radio_button.h" -#include "components/ui_label_button.h" -#include "components/ui_view_group.h" - -namespace OHOS { -class PlayerOnDragListener; -class BluetoothView { -public: - BluetoothView(); - virtual ~BluetoothView(); - UIViewGroup *LoadBluetoothView(void); - static BluetoothView *GetInstance(void); - UIViewGroup *group{nullptr}; - UIRadioButton *GetPhoneButton(void); - UIRadioButton *GetWatchButton(void); - UIButton *GetSettingButton(void); - UILabelButton *GetDeleteButton(void); -private: - UILabel *watchLabel{nullptr}; - UILabel *phoneLabel{nullptr}; - UILabel *bluetoothLabel{nullptr}; - UIImageView *watchImage{nullptr}; - UIImageView *phoneImage{nullptr}; - UIImageView *bluetoothImage{nullptr}; - UIRadioButton *watchButton{nullptr}; - UIRadioButton *phoneButton{nullptr}; - UIButton *settingButton{nullptr}; - UILabelButton *deleteButton{nullptr}; - int LoadRadioButton(); - int LoadButtonView(); - int LoadLabelButton(); - int LoadLabel(); - int LoadImage(); - - void SetUpButton(UILabelButton *btn, const Point& point, int16_t width, int16_t height, - UIView::OnClickListener *listener); -}; -} // namespace OHOS -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/player/PlayersCaseListAdapter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/player/PlayersCaseListAdapter.h deleted file mode 100644 index bf1c48788..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/player/PlayersCaseListAdapter.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: Player view - * Author: - * Create: 2021-07-26 - */ - -#ifndef PLAYERS_CASE_LIST_ADAPTER_H -#define PLAYERS_CASE_LIST_ADAPTER_H - -#include "components/abstract_adapter.h" -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "UiConfig.h" - -namespace OHOS { -class PlayersCaseListAdapter : public AbstractAdapter { -public: - PlayersCaseListAdapter() {} - ~PlayersCaseListAdapter(); - UIView *GetView(UIView *inView, int16_t index) override; - uint16_t GetCount() override; - -private: - void LabelButtonSet(); - UILabelButton *item{nullptr}; - UIView::OnClickListener *listener{nullptr}; -}; -} // namespace OHOS -#endif // PLAYERS_CASE_LIST_ADAPTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/qrcode_conn/QrcodeConnModel.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/qrcode_conn/QrcodeConnModel.h deleted file mode 100644 index 9bfab4573..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/qrcode_conn/QrcodeConnModel.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: QrcodeConnModel.h - * Author: - * Create: 2025-04-24 - */ - -#ifndef QRCODE_CONN_MODEL_H -#define QRCODE_CONN_MODEL_H - -#include -#include -#include "AppViewIDs.h" -#include "UiConfig.h" - -namespace OHOS { -class QrcodeConnModel { -public: - static QrcodeConnModel &GetInstance(void); - -private: - QrcodeConnModel(); - QrcodeConnModel(const QrcodeConnModel &); - QrcodeConnModel &operator=(const QrcodeConnModel &); - virtual ~QrcodeConnModel(); - -private: -}; -} - -#endif // QRCODE_CONN_MODEL_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/qrcode_conn/QrcodeConnPresenter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/qrcode_conn/QrcodeConnPresenter.h deleted file mode 100644 index 8914dc9d6..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/qrcode_conn/QrcodeConnPresenter.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: QrcodeConnPresenter.h - * Author: - * Create: 2025-04-24 - */ - -#ifndef QRCODE_CONN_PRESENTER_H -#define QRCODE_CONN_PRESENTER_H - -#include "Presenter.h" -#include "components/ui_view.h" -#include "qrcode_conn/QrcodeConnView.h" -#include "qrcode_conn/QrcodeConnModel.h" - -namespace OHOS { - -class QrcodeConnView; -class QrcodeConnModel; -class QrcodeConnPresenter : public Presenter, - public UIView::OnDragListener { -public: - QrcodeConnPresenter(); - ~QrcodeConnPresenter() override; - static QrcodeConnPresenter *GetInstance(); - bool OnDrag(UIView& view, const DragEvent& event) override; -private: -}; -} - -#endif // QRCODE_CONN_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/qrcode_conn/QrcodeConnView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/qrcode_conn/QrcodeConnView.h deleted file mode 100644 index 24aaae618..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/qrcode_conn/QrcodeConnView.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: QrcodeConnView.h - * Author: - * Create: 2025-04-24 - */ - -#ifndef QRCODE_CONN_VIEW_H -#define QRCODE_CONN_VIEW_H - -#include -#include "View.h" -#include "components/root_view.h" -#include "components/ui_view_group.h" -#include "components/ui_scroll_view.h" -#include "components/ui_label.h" -#include "UiConfig.h" -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_button.h" -#include "components/ui_label_button.h" -#include "components/ui_image_view.h" -#include "components/ui_qrcode.h" - -namespace OHOS { - -class QrcodeConnPresenter; -class QrcodeConnView : public View { -public: - QrcodeConnView(); - ~QrcodeConnView() override; - - static QrcodeConnView *GetInstance(); - - void OnStart() override; - void OnStop() override; - void InitView(); - void DeInit(); - -private: - UIScrollView *group_ = nullptr; - UIQrcode *qrcode_ = nullptr; -}; -} -#endif // QRCODE_CONN_VIEW_H diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/rebootdevice/RebootDeviceView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/rebootdevice/RebootDeviceView.h deleted file mode 100644 index 3e50f0b2a..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/rebootdevice/RebootDeviceView.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: RebootDevice View - * Create: 2022-04-28 - */ -#ifndef REBOOTDEVICE_VIEW_H -#define REBOOTDEVICE_VIEW_H - -#include "View.h" -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_button.h" - -namespace OHOS { -class RebootDeviceView { -public: - RebootDeviceView(); - ~RebootDeviceView(); - static RebootDeviceView *GetInstance(); - UIViewGroup *InitShowUpView(void); - -private: - bool ShowUpRebootDeviceView(void); - UILabel *rebootDeviceLabel{nullptr}; - UIButton *rebootDeviceButton{nullptr}; - UIViewGroup *group{nullptr}; -}; -} // namespace OHOS -#endif // REBOOTDEVICE_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/rebootdevice/RebootModel.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/rebootdevice/RebootModel.h deleted file mode 100644 index fba69e64f..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/rebootdevice/RebootModel.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Reboot Model - * Create: 2022-04-28 - */ - -#ifndef REBOOT_MODEL_H -#define REBOOT_MODEL_H -#include - -namespace OHOS { -enum RebootModelView : uint8_t { - REBOOT, - REBOOTDEVICE, - SHUTDOWNDEVICE, -}; - -class RebootModel { -public: - ~RebootModel(); - static RebootModel *GetInstance(void); - int16_t GetSelectView(void); - void SetSelectViewId(int16_t value); - bool GetExitsView(void); - void SetExitsView(bool value); - void SoftRebootDevice(void); - void ShutdownDevice(void); - -private: - RebootModel(); - int16_t selectView{0}; - bool exitsView{false}; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/rebootdevice/RebootPresenter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/rebootdevice/RebootPresenter.h deleted file mode 100644 index 8239ee252..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/rebootdevice/RebootPresenter.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Reboot Presenter - * Create: 2022-04-28 - */ - -#ifndef REBOOT_PRESENTER_H -#define REBOOT_PRESENTER_H - -#include "Presenter.h" -#include "NativeLauncher.h" -#include "NativeAbility.h" - -namespace OHOS { -enum RebootPresenterNum : uint8_t { - REBOOTVIEW = 0, - REBOOTDEVICEVIEW, - SHUTDOWNDEVICEVIEW, - REBOOT_MAX, -}; - -#define REBOOT_BUTTON "rebootButton" -#define SHUTDOWN_BUTTON "shutdownButton" -#define REBOOTDEVICE_BUTTON "rebootDeviceButton" -#define SHUTDOWNDEVICE_BUTTON "shutdownDeviceButton" - -#define REBOOT_VIEW "rebootView" -#define REBOOTDEVICE_VIEW "rebootDeviceView" -#define SHUTDOWNDEVICE_VIEW "shutdownDeviceView" - -class RebootView; -class RebootPresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener { -public: - RebootPresenter(); - ~RebootPresenter(); - static RebootPresenter *GetInstance(); - bool OnClick(UIView& view, const ClickEvent& event) override; - bool OnDrag(UIView& view, const DragEvent& event) override; - -private: -}; -} // namespace OHOS -#endif diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/rebootdevice/RebootView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/rebootdevice/RebootView.h deleted file mode 100644 index 7ea1ed32f..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/rebootdevice/RebootView.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Reboot View - * Create: 2022-04-28 - */ -#ifndef REBOOT_VIEW_H -#define REBOOT_VIEW_H - -#include "View.h" -#include "rebootdevice/ShutdownDeviceView.h" -#include "rebootdevice/RebootDeviceView.h" -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_button.h" - -namespace OHOS { -constexpr int16_t NUM_REBOOT_CONTAINER = 3; - -class RebootPresenter; -class RebootView : public View { -public: - RebootView(); - ~RebootView() override; - static RebootView *GetInstance(); - void OnStart() override; - UIViewGroup *InitShowUpView(void); - void ChangeView(int16_t hideView, int16_t showView); - -private: - bool ChangeRebootView(int16_t hideView, int16_t thisView); - bool ChangeRebootDeviceView(int16_t hideView, int16_t thisView); - bool ChangeShutdownDeviceView(int16_t hideView, int16_t thisView); - bool CheckViewParam(int16_t hideView, int16_t showView); - bool ShowUpRebootView(void); - bool ShowUpShutdownView(void); - UILabel *rebootLabel{nullptr}; - UIButton *rebootButton{nullptr}; - UILabel *shutdownLabel{nullptr}; - UIButton *shutdownButton{nullptr}; - UIViewGroup *group{nullptr}; - RebootDeviceView *rebootDeviceView{nullptr}; - ShutdownDeviceView *shutdownDeviceView{nullptr}; - UIViewGroup *container[NUM_REBOOT_CONTAINER]{nullptr}; - typedef bool (RebootView::*PreprosssChangeView)(int16_t hideView, int16_t thisView); - PreprosssChangeView preProcessView[NUM_REBOOT_CONTAINER]; -}; -} // namespace OHOS -#endif // REBOOT_VIEW_H diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/rebootdevice/ShutdownDeviceView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/rebootdevice/ShutdownDeviceView.h deleted file mode 100644 index 33140b50d..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/rebootdevice/ShutdownDeviceView.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: ShutdownDevice View - * Create: 2022-04-28 - */ -#ifndef SHUTDOWNDEVICE_VIEW_H -#define SHUTDOWNDEVICE_VIEW_H - -#include "View.h" -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_button.h" - -namespace OHOS { -class ShutdownDeviceView { -public: - ShutdownDeviceView(); - ~ShutdownDeviceView(); - static ShutdownDeviceView *GetInstance(); - UIViewGroup *InitShowUpView(void); - -private: - bool ShowUpShutdownDeviceView(void); - UILabel *shutdownDeviceLabel{nullptr}; - UIButton *shutdownDeviceButton{nullptr}; - UIViewGroup *group{nullptr}; -}; -} // namespace OHOS -#endif // SHUTDOWNDEVICE_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardAdapter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardAdapter.h deleted file mode 100644 index 50ca27d1e..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardAdapter.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SetCardAdapter.h - * Author: - * Create: 2021-09-18 - */ - -#ifndef SET_CARD_ADAPTER_H -#define SET_CARD_ADAPTER_H - -#include -#include -#include "components/ui_list.h" -#include "components/ui_label.h" -#include "components/ui_view_group.h" -#include "components/ui_image_view.h" -#include "components/abstract_adapter.h" -#include "UiConfig.h" -#include "wearable_log.h" -#include "set_card/SetCardItem.h" - -namespace OHOS { -class SetCardAdapter : public AbstractAdapter { -public: - explicit SetCardAdapter(); - ~SetCardAdapter() override; - - uint16 GetCount(void) override; - - UIView *GetView(UIView *inView, int16 index) override; - - void AddListItem(const CardInfo &item); - - void SetItemClickListener(UIView::OnClickListener *itemClickListener) - { - itemClickListener_ = itemClickListener; - } - - void ClearItem(void); - -private: - std::list listData_; - UIView::OnClickListener *itemClickListener_; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardDeleteView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardDeleteView.h deleted file mode 100644 index 14fd9e307..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardDeleteView.h +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved. - * Description: - * Author: - * Create: - */ - -#ifndef SET_CARD_DELETE_VIEW_H -#define SET_CARD_DELETE_VIEW_H - -#include "components/ui_label_button.h" -#include "set_card/SetCardPresenter.h" - -namespace OHOS { -class SetCardDeleteView : public UIViewGroup { -public: - SetCardDeleteView(SetCardPresenter *presenter); - ~SetCardDeleteView() override; - bool InitView(); -private: - SetCardPresenter *presenter_; - UILabelButton confirmBtn; - UILabelButton cancelBtn; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardItem.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardItem.h deleted file mode 100644 index 1d545c1bb..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardItem.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SetCardItem.h - * Author: - * Create: 2021-11-23 - */ - -#ifndef SET_CARD_ITEM_H -#define SET_CARD_ITEM_H - -#include -#include -#include "components/ui_view.h" -#include "components/ui_view_group.h" -#include "components/ui_image_view.h" -#include "main/MainModel.h" -#include "UiConfig.h" - -namespace OHOS { - -class SetCardItem : public UIViewGroup { -public: - SetCardItem(); - ~SetCardItem() override; - void SetItemInfo(const CardInfo &cardInfo); - void SetOnClickListener(OnClickListener *onClickListener); -private: - void SetUpChild(); - UIImageView cardImg_; - CardInfo cardInfo_; -}; - -} - -#endif // SET_CARD_ITEM_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardModel.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardModel.h deleted file mode 100644 index 74ca5bd2d..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardModel.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SetCardModel.h - * Author: - * Create: 2021-11-23 - */ - -#ifndef SET_CARD_MODEL_H -#define SET_CARD_MODEL_H - -#include -#include -#include "AppViewIDs.h" -#include "UiConfig.h" -#include "set_card/SetCardPresenter.h" -#include "set_card/SetCardItem.h" - -namespace OHOS { - class SetCardModel { - public: - static SetCardModel &GetInstance(void); - uint8_t *GetCardShowList(void); - uint8_t GetCardShowCount(void) const; - void InitCardShowList(void); - void SetSelectedCardIndex(uint8_t cardIndex); - uint8_t GetSelectedCardIndex(void) const; - void DeleteCardSetting(void); - void SetSelectedCard(uint8_t cardId); - uint8_t GetSelectedCard(void); - private: - SetCardModel(); - SetCardModel(const SetCardModel &); - SetCardModel &operator=(const SetCardModel &); - virtual ~SetCardModel(); - - uint8_t cardShowList[CARD_SETTING_COUNT_MAX] = { 0 }; - uint8_t cardShowCount{0}; - uint8_t selectedCardIndex{0}; - uint8_t selectedCardId{MAX_CARD}; - }; -} - -#endif // SET_CARD_MODEL_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardNoCardView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardNoCardView.h deleted file mode 100644 index 711648810..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardNoCardView.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved. - * Description: - * Author: - * Create: - */ - -#ifndef SET_CARD_NO_CARD_VIEW_H -#define SET_CARD_NO_CARD_VIEW_H - -#include "components/ui_image_view.h" -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "set_card/SetCardPresenter.h" - -namespace OHOS { -class SetCardNoCardView : public UIViewGroup { -public: - SetCardNoCardView(SetCardPresenter *presenter); - ~SetCardNoCardView() override; - bool InitView(); -private: - SetCardPresenter *presenter_; - UILabelButton addBtn; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardPresenter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardPresenter.h deleted file mode 100644 index 8af598cdd..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardPresenter.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SetCardPresenter.h - * Author: - * Create: 2021-11-23 - */ - -#ifndef SET_CARD_PRESENTER_H -#define SET_CARD_PRESENTER_H - -#include "Presenter.h" -#include "components/ui_list.h" -#include "components/ui_view.h" -#include "main/ModelListenerSample.h" - -namespace OHOS { - -static const char *SET_CARD_ADD = "setcardadd"; -static const char *SET_CARD_DEL = "setcarddel"; -static const char *SET_CARD_DEL_CONFIRM = "setcarddelconfirm"; -static const char *SET_CARD_DEL_CANCEL = "setcarddelcancel"; -static const char *SET_CARD_IMG = "setcardimg"; - -const uint16_t MISS_SET_CARD_OPERATION_TIME = 3000; - -class SetCardView; -class SetCardModel; -class SetCardPresenter : public Presenter, - public UIView::OnClickListener, public ModelListenerSample, - public ListScrollListener { -public: - SetCardPresenter(); - ~SetCardPresenter() override; - - bool OnClick(UIView &view, const ClickEvent &event) override; - void OnScrollStart(int16_t index, UIView *view) override; - void OnScrollEnd(int16_t index, UIView *view) override; - void OnItemSelected(int16_t index, UIView* view) override; - void OnTickEvent() override; - void Notify() override {} - void InitCardShowList(void); - uint8_t *GetCardShowList(void); - uint8_t GetCardShowCount(void) const; - void SetSelectedCard(uint8_t cardId); - uint8_t GetSelectedCard(void); - void SetSelectedCardIndex(uint8_t cardIndex); -private: - void GoToMainView(void); - void ResetTickTimer(void); - SetCardModel *model{nullptr}; - uint64_t startTime{0}; -}; -} - -#endif // SET_CARD_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardView.h deleted file mode 100644 index fb5c224ee..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_card/SetCardView.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SetCardView.h - * Author: - * Create: 2021-11-23 - */ - -#ifndef SET_CARD_VIEW_H -#define SET_CARD_VIEW_H - -#include "View.h" -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_image_view.h" -#include "components/ui_toggle_button.h" -#include "ChangeSliceListener.h" -#include "UiConfig.h" -#include "set_card/SetCardAdapter.h" -#include "set_card/SetCardModel.h" -#include "set_card/SetCardDeleteView.h" -#include "set_card/SetCardNoCardView.h" - -namespace OHOS { -class SetCardPresenter; - -class SetCardView : public View { -public: - SetCardView(); - ~SetCardView() override; - - static SetCardView *GetInstance() - { - static SetCardView instance; - return &instance; - } - - void OnStart() override; - void ShowDeleteView(bool show); - void ShowAddView(bool show); - void RefreshCardList(void); - void SaveSelectCardIndex(void); -private: - void SetUpListInfo(void); - void SetUpListView(void); - void SetUpDeleteView(void); - void SetUpAddView(void); - void ShowCardListView(bool show); - UIImageView addImg_; - UIList contentList_; - UIImageView delImg_; - - SetCardDeleteView *deleteView_{nullptr}; - SetCardNoCardView *noCardView_{nullptr}; - SetCardAdapter *setCardAdapter_{nullptr}; - uint32_t scrollIndex_{0}; -}; -} -#endif // SET_CARD_VIEW_H diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial/SetDialInfo.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial/SetDialInfo.h deleted file mode 100644 index abc288d24..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial/SetDialInfo.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SetDialInfo.h - * Author: - * Create: 2021-11-23 - */ - -#ifndef SET_DIAL_INFO_H -#define SET_DIAL_INFO_H -#include -#include -#include -#include "common/image_cache_manager.h" -namespace OHOS { - typedef struct { - uint8_t dialFlag; /* 1:离线表盘 0:预制表盘 */ - uint8_t id; /* 仅预制表盘使用 */ - uint32_t resId; /* 仅离线表盘使用 */ - std::string dialFullName; /* 仅离线表盘使用 */ - std::string imageFullName; /* 仅预制表盘使用 */ - std::string dialName; - std::string description; /* 仅离线表盘使用 */ - ImageInfo *preImageInfo; - uint8_t capability; - } SetDialInfo; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial/SetDialModel.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial/SetDialModel.h deleted file mode 100644 index 546e89d86..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial/SetDialModel.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SetDialModel.h - * Author: - * Create: 2021-11-23 - */ - -#ifndef SET_DIAL_MODEL_H -#define SET_DIAL_MODEL_H -#include "AppViewIDs.h" -#include "UiConfig.h" -#include "set_dial/SetDialInfo.h" - -namespace OHOS { - class SetDialModel { - public: - static SetDialModel &GetInstance(void); - void LoadAllDial(void); - size_t GetDialCount(void); - std::vector& GetDialInfo(void); - std::vector& GetAmbientDialInfo(void); - void ClearDialInfo(void); - void SaveDialSetting(uint8_t pageIndex); - uint8_t GetPageIndex(void); - private: - void LoadAllDialFromRam(void); - void LoadAllDialFromFs(void); - SetDialModel(); - SetDialModel(const SetDialModel &); - SetDialModel &operator=(const SetDialModel &); - virtual ~SetDialModel(); - int32_t ParseDialHeader(const std::string &dialFileName, SetDialInfo &dialInfo); - std::vector dialInfoList; - std::vector aodDialInfoList; - }; -} - -#endif // SET_DIAL_MODEL_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial/SetDialPresenter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial/SetDialPresenter.h deleted file mode 100644 index a50ffdada..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial/SetDialPresenter.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SetDialPresenter.h - * Author: - * Create: 2021-11-23 - */ - -#ifndef SET_DIAL_PRESENTER_H -#define SET_DIAL_PRESENTER_H -#include "set_dial/SetDialInfo.h" -#include "set_dial/SetDialModel.h" -#include "Presenter.h" -#include "components/ui_view.h" -#include "components/ui_roller_view.h" -#include "key/KeyInputListener.h" -#include "main/ModelListenerSample.h" -#include "components/ui_coverflow_view.h" -#include "main/MainModel.h" - -namespace OHOS { - -const uint16_t MISS_DIAL_OPERATION_TIME = 3000; - -class SetDialView; -class SetDialModel; -class SetDialPresenter : public Presenter, - public UIView::OnClickListener, public ModelListenerSample, - public UICoverflowView::OnCoverflowScrollListener, - public UIRollerView::OnScrollListener { -public: - SetDialPresenter(); - ~SetDialPresenter() override; - static SetDialPresenter *GetCurrentInstance(); - void SpecifyDialSetting(const DialSetting &setting); - size_t GetDialCount(void); - std::vector& GetDialInfo(void); - uint8_t GetPageIndex(void); - void OnTickEvent() override; - void Notify() override {} - void OnStop() override; - bool OnScroll() override; - void OnScroll(UIRollerView* roller, std::string currentItemName, float currentItemAngle) override; - bool OnClick(UIView &view, const ClickEvent &event) override; - void ResetTickTimer(void); -private: - void OnClickAction(void); - SetDialModel *model{nullptr}; - uint64_t startTime{0}; - bool isSpecific = false; - DialSetting specificSetting; -}; -} - -#endif // SET_DIAL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial/SetDialView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial/SetDialView.h deleted file mode 100644 index f26dc3b56..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial/SetDialView.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SetDialView.h - * Author: - * Create: 2021-11-23 - */ - -#ifndef SET_DIAL_VIEW_H -#define SET_DIAL_VIEW_H - -#include "View.h" -#include "components/ui_view_group.h" -#include "components/ui_coverflow_view.h" -#include "components/ui_roller_view.h" -#include "ChangeSliceListener.h" -#include "UiConfig.h" - -namespace OHOS { -static constexpr uint8_t DIVISOR_TWO = 2; -class SetDialPresenter; - -enum class DialStyle { - COVERFLOW = 0, - ROLLER, - STYLE_NUM -}; - -class SetDialView : public View { -public: - SetDialView(); - ~SetDialView() override; - - static SetDialView *GetInstance() - { - static SetDialView instance; - return &instance; - } - - void OnStart() override; - void CoverflowViewScroll(void); - void RollerViewScroll(std::string currentItemName, float currentItemAngle); - uint8_t GetCoverflowPage(void); -private: - void SetUpCoverflowView(void); - void SetUpRollerView(void); - UICoverflowView coverflow_; - UIRollerView rollerView_; - int16_t rollerItemNum_ = 0; - UILabel label_; - uint8_t lastIndex_; -}; -} -#endif // SET_DIAL_VIEW_H diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial_style/SetDialStyleModel.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial_style/SetDialStyleModel.h deleted file mode 100644 index 7ed274df2..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial_style/SetDialStyleModel.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2024. All rights reserved. - * Description: SetDialStyleModel.h - * Author: - * Create: 2024-06-06 - */ - -#ifndef SET_DIAL_STYLE_MODEL_H -#define SET_DIAL_STYLE_MODEL_H -#include "set_dial/SetDialView.h" -#include "components/ui_view.h" - -namespace OHOS { -class SetDialStyleModel { -public: - static SetDialStyleModel& GetInstance() - { - static SetDialStyleModel model; - return model; - } - - void SetStyle(DialStyle style); - DialStyle GetStyle(); - -private: - constexpr static uint8_t MAX_LEN = 32; - const char key_[MAX_LEN] = "set_dial_style"; - struct { - const DialStyle style; - const char value[MAX_LEN]; - } values_[static_cast(DialStyle::STYLE_NUM)] = { - {DialStyle::COVERFLOW, "DialStyle::COVERFLOW"}, - {DialStyle::ROLLER, "DialStyle::ROLLER"}, - }; - SetDialStyleModel(); - ~SetDialStyleModel(); - SetDialStyleModel(const SetDialStyleModel&) = delete; - SetDialStyleModel& operator=(const SetDialStyleModel&) = delete; -}; -} // OHOS -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial_style/SetDialStylePresenter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial_style/SetDialStylePresenter.h deleted file mode 100644 index d867280af..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial_style/SetDialStylePresenter.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2024. All rights reserved. - * Description: SetDialStylePresenter.h - * Author: - * Create: 2024-06-06 - */ - -#ifndef SET_DIAL_STYLE_PRESENTER_H -#define SET_DIAL_STYLE_PRESENTER_H -#include "set_dial/SetDialView.h" -#include "components/ui_view.h" -#include "Presenter.h" - -namespace OHOS { -class SetDialStyleModel; -class SetDialStyleView; -class SetDialStylePresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener { -public: - SetDialStylePresenter(); - ~SetDialStylePresenter() override; - SetDialStylePresenter(const SetDialStylePresenter&) = delete; - SetDialStylePresenter& operator=(const SetDialStylePresenter&) = delete; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView& view, const DragEvent& event) override; - DialStyle GetCurrentStyle() const - { - return curStyle_; - } - -private: - DialStyle curStyle_ = DialStyle::COVERFLOW; -}; - -} // OHOS -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial_style/SetDialStyleView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial_style/SetDialStyleView.h deleted file mode 100644 index a32550a0d..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_dial_style/SetDialStyleView.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2024. All rights reserved. - * Description: SetDialStyleView.h - * Author: - * Create: 2024-06-06 - */ - -#ifndef SET_DIAL_STYLE_VIEW_H -#define SET_DIAL_STYLE_VIEW_H -#include "components/ui_view.h" -#include "components/ui_label.h" -#include "components/ui_view_group.h" -#include "components/ui_toggle_button.h" -#include "set_dial/SetDialView.h" -#include "View.h" - -namespace OHOS { -class SetDialStylePresenter; -class SetDialStyleView : public View { -public: - SetDialStyleView(); - ~SetDialStyleView() override; - SetDialStyleView(const SetDialStyleView &) = delete; - SetDialStyleView& operator=(const SetDialStyleView &) = delete; - - void OnStart() override; - void OnClick(UIView &view); - -private: - UILabel labelCover_; - UILabel labelRoller_; - UILabel labelEnableAod_; - UIToggleButton btnCover_; - UIToggleButton btnRoller_; - UIToggleButton btnEnableAod_; - struct { - UIToggleButton *btn; - DialStyle style; - } styleTable_[static_cast(DialStyle::STYLE_NUM)] = { - {&btnCover_, DialStyle::COVERFLOW}, - {&btnRoller_, DialStyle::ROLLER}, - }; -}; -} // OHOS -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_ota/OTACommon.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_ota/OTACommon.h deleted file mode 100644 index 50a857419..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_ota/OTACommon.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. - * Description: ota local update - * Author: wangle - * Create: 2025-5-6 - */ -#ifndef OTA_COMMON_H -#define OTA_COMMON_H - -#define MODLE_THREAD_STACK_SIZE 4096 - -#define LOCAL_UPDATE_PROGRESS_5 5 -#define LOCAL_UPDATE_PROGRESS_25 25 -#define LOCAL_UPDATE_PROGRESS_40 40 -#define LOCAL_UPDATE_PROGRESS_50 50 -#define LOCAL_UPDATE_PROGRESS_100 100 - -#define SLEEP_TIME_S 1000 - -#define SLIDING_LENGTH 30 - -#define VIEW_MESSAGE_X 53 -#define VIEW_MESSAGE_Y 148 -#define VIEW_MESSAGE_W 360 -#define VIEW_MESSAGE_H 20 -#define VIEW_MESSAGE_FONT 20 - -#define VIEW_PROGRESS_X 73 -#define VIEW_PROGRESS_Y 226 -#define VIEW_PROGRESS_W 320 -#define VIEW_PROGRESS_H 10 - -#define VIEW_UPDATE_X 173 -#define VIEW_UPDATE_Y 312 -#define VIEW_UPDATE_W 120 -#define VIEW_UPDATE_H 40 -#define VIEW_UPDATE_FONT 16 - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_ota/OTAModel.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_ota/OTAModel.h deleted file mode 100644 index d72ea88f5..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_ota/OTAModel.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. - * Description: ota local update - * Author: wangle - * Create: 2025-5-6 - */ -#ifndef OTA_MODEL_H -#define OTA_MODEL_H -#include "osal_task.h" -#include "osal_wait.h" -#include "Model.h" -#include -namespace OHOS { - -enum class TaskType { UpdateInfo, LocalUpdate, Unknown }; - -struct LocalUpdateData { - uint32_t fileSize; -}; - -class OTAPresenter; -class OTAModel : public Model { -public: - OTAModel(); - ~OTAModel(); - -public: - bool ModelRunTask(TaskType type, void *data); - -protected: - void SwitchTask(); - void UpdateInfo(void *data); - void LocalUpdate(void *data); - -protected: - void DelayRebootFor5S(); - void UpdatePercentCallback(uint32_t percent); - -protected: - static int OSALKthreadCallback(void *data); - static int WaitCondition(const void *data); - -protected: - static void OtaUpdatePercentCallback(uint32_t percent); - -private: - osal_task *task = nullptr; - osal_wait wait; - std::atomic_bool isIdel; - TaskType type = TaskType::Unknown; - void *data = nullptr; -}; - -} // namespace OHOS - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_ota/OTAPresenter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_ota/OTAPresenter.h deleted file mode 100644 index 8c37384eb..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_ota/OTAPresenter.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. - * Description: ota local update - * Author: wangle - * Create: 2025-5-6 - */ -#ifndef OTA_PRESENTER_H -#define OTA_PRESENTER_H - -#include "Presenter.h" -#include "components/ui_view.h" -#include "set_ota/OTAModel.h" - -namespace OHOS { - -class OTAView; -class OTAPresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener { -public: - void OnStart() override; - void OnStop() override; - -public: - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; -public: - // Model调用 - void SetPackageInfo(const char* filePath, uint32_t fileSize); - void SetUpdateProgress(const char* message, uint8_t progress); - void SetErrorMessage(const char* message); - void SetMessage(const char* message); -protected: - void SaveSystemScreen(); - void BackSystemScreen(); -private: - bool updateEnable = true; - const char* updateFilePath = nullptr; - uint32_t updateFileSize = 0; - uint32_t briScrStatus = 0; -}; -} // namespace OHOS - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_ota/OTAView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_ota/OTAView.h deleted file mode 100644 index 1beee87c4..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/set_ota/OTAView.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. - * Description: ota local update - * Author: wangle - * Create: 2025-5-6 - */ -#ifndef OTA_VIEW_H -#define OTA_VIEW_H - -#include "View.h" -#include "Presenter.h" -#include "components/ui_label.h" -#include "components/ui_box_progress.h" -#include "components/ui_label_button.h" - -namespace OHOS { -class OTAPresenter; -class OTAView : public View { -public: - OTAView(){}; - ~OTAView(){}; - void OnStart() override; - void OnStop() override; - void InitMessageCtrl(); - void InitProgressCtrl(); - void InitUpdateCtrl(); - void AddCtrlToView(); - void DeInitMessageCtrl(); - void DeInitProgressCtrl(); - void DeInitUpdateCtrl(); - -public: - void SetUpdateEnable(); - void SetUpdateDisable(); - void SetMessage(const char *msg); - void SetProgress(uint8_t progress); - -private: - UILabel *message = nullptr; - UIBoxProgress *progress = nullptr; - UILabelButton *update = nullptr; -}; -} // namespace OHOS - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SetDesktopModel.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SetDesktopModel.h deleted file mode 100644 index 2866da667..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SetDesktopModel.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: SetDesktopModel - * Author: Hisi Graphic Team - * Created: 2025-4 - */ - -#ifndef SET_DESKTOP_MODEL_H -#define SET_DESKTOP_MODEL_H - -#include -#include -#include "AppViewIDs.h" -#include "UiConfig.h" - -typedef enum { - APPLIST_STYLE, - HEXAGONS_STYLE, - FOOTBALL_STYLE, - WATERFALL_STYLE -} DesktopStyle; - -namespace OHOS { - class SetDesktopModel { - public: - static SetDesktopModel &GetInstance(void); - DesktopStyle GetDesktopStyle(void); - void SetDesktopStyle(DesktopStyle style); - private: - SetDesktopModel() = default; - virtual ~SetDesktopModel() = default; - }; -} - -#endif // SET_DESKTOP_MODEL_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingAdapter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingAdapter.h deleted file mode 100644 index a3c5f69ca..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingAdapter.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SettingAdapter.h - * Author: - * Create: 2021-11-23 - */ - -#ifndef SETTING_ADAPTER_H -#define SETTING_ADAPTER_H - -#include -#include -#include "components/ui_list.h" -#include "components/ui_label.h" -#include "components/ui_view_group.h" -#include "components/ui_image_view.h" -#include "components/abstract_adapter.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "settings/SettingModel.h" -#include "settings/SettingItemView.h" - -namespace OHOS { -class SettingAdapter : public AbstractAdapter { -public: - explicit SettingAdapter(); - ~SettingAdapter() override; - - /* * - * @brief Sets the UIView adapter data, which is a SettingItem linked list. - * - * @param data Indicates the SettingItem linked list data. - * @since 1.0 - * @version 1.0 - */ - void SetData(std::list &data); - - /* * - * @brief Obtains the data size of the UILabel adapter. - * - * @return Returns the data size of the UILabel adapter. - * @since 1.0 - * @version 1.0 - */ - uint16_t GetCount(void) override; - - UIView *GetView(UIView *inView, int16_t index) override; - - void AddListItem(const SettingItem &item); - - void SetItemClickListener(UIView::OnClickListener *itemclicklistener) - { - itemClickListener = itemclicklistener; - } -private: - std::list listData; - UIView::OnClickListener *itemClickListener{nullptr}; -}; -} - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingDesktopPage.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingDesktopPage.h deleted file mode 100644 index 8e8dd1e6d..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingDesktopPage.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: SettingDesktopPage - * Author: Hisi Graphic Team - * Created: 2025-4 - */ - -#ifndef SETTING_DESKTOP_PAGE_H -#define SETTING_DESKTOP_PAGE_H - -#include "View.h" -#include "components/ui_scroll_view.h" -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_image_view.h" -#include "components/ui_toggle_button.h" -#include "SlicePage.h" -#include "UiConfig.h" -#include "settings/SetDesktopModel.h" -#include "settings/SettingPresenter.h" - -namespace OHOS { -class SettingDesktopPage : public SlicePage, - public UIView::OnClickListener, - public UIView::OnDragListener { -public: - SettingDesktopPage(); - ~SettingDesktopPage() override; - void OnStart(void* data) override; - void UpdateSelectedStyle(DesktopStyle selectedStyle); - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView& view, const DragEvent& event) override; - -private: - void InitFootballItem(); - void InitWaterfallItem(); - UIScrollView *scrollview{nullptr}; - UILabel titleText; - UIToggleButton hexagonsBtn; - UIToggleButton listBtn; - UIToggleButton footballBtn_; - UIToggleButton waterfallBtn_; - UIImageView hexagonsImage; - UIImageView listImage; - UIImageView footballImage_; - UIImageView waterfallImage_; - UILabel listText; - UILabel hexagonsText; - UILabel footballText_; - UILabel waterfallText_; -}; -} -#endif // SETTING_DESKTOP_PAGE_H diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingItem.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingItem.h deleted file mode 100644 index c45c20469..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingItem.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SettingItem.h - * Author: - * Create: 2021-11-23 - */ - -#ifndef SETTING_ITEM_H -#define SETTING_ITEM_H - -#include - -namespace OHOS { -typedef struct { - uint32_t targetId; - const char *icon; - const char *label; - bool hasSecondMenu; - bool enableSlideBack; -} SettingItem; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingItemView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingItemView.h deleted file mode 100644 index 11ba9444e..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingItemView.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SettingItemView.h - * Author: - * Create: 2021-11-23 - */ - -#ifndef SETTING_ITEM_VIEW_H -#define SETTING_ITEM_VIEW_H - -#include "components/ui_label.h" -#include "components/ui_view_group.h" -#include "components/ui_image_view.h" - -#include "UiConfig.h" -#include "settings/SettingModel.h" - -namespace OHOS { -class SettingItemView : public UIViewGroup { -public: - explicit SettingItemView(); - ~SettingItemView() override; - virtual void SetItemInfo(const SettingItem itemInfo); - virtual void SetUpChild(); - bool SlideBackEnabled() const - { - return sItemInfo.enableSlideBack; - } - uint32_t GetTargetId(); - const char* GetIconId(); -private: - UIImageView sIcon; - UILabel sLabel; - UIImageView sNextImage; - SettingItem sItemInfo = { VIEW_INVALID, nullptr, nullptr, false, false }; -}; -} - -#endif diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingMainPage.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingMainPage.h deleted file mode 100644 index 5d3a8c47d..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingMainPage.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: SettingMainPage - * Author: Hisi Graphic Team - * Created: 2025-4 - */ - -#ifndef SETTING_MAIN_PAGE_H -#define SETTING_MAIN_PAGE_H - -#include "components/ui_scroll_view.h" -#include "components/ui_label.h" -#include "components/ui_list.h" -#include "SlicePage.h" -#include "settings/SettingAdapter.h" -#include "settings/SettingPresenter.h" - -namespace OHOS { -class SettingPresenter; -class SettingMainPage : public SlicePage, - public UIView::OnClickListener, - public UIView::OnDragListener { -public: - SettingMainPage() = default; - ~SettingMainPage() override; - - void OnStart(void* data) override; - void RefreshSettingsList(const SettingItem* item, uint8_t count); - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView& view, const DragEvent& event) override; -private: - SettingAdapter *listAdapter{nullptr}; - UIScrollView *scrollView{nullptr}; - UIList *contentList{nullptr}; - UILabel *title{nullptr}; -}; -} -#endif // SETTING_MAIN_PAGE_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingModel.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingModel.h deleted file mode 100644 index 191a64913..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/settings/SettingModel.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SettingModel.h - * Author: - * Create: 2021-11-23 - */ - -#ifndef SETTING_MODEL_H -#define SETTING_MODEL_H - -#include -#include -#include "AppViewIDs.h" -#include "UiConfig.h" -#include "settings/SettingItem.h" -#include "settings/SettingPresenter.h" - -namespace OHOS { - static const uint16_t SETTING_ITEM_COUNT = 10; - class SettingModel { - public: - static SettingModel &GetInstance(void); - void InitSettingItem(); - const SettingItem *GetSettinglistItems() const; - uint8_t GetSettingListNum() const; - bool GetBlueToothConnectStatus(void); - void UpdateBlueToothConnectStatus(bool status); - private: - SettingModel(); - SettingModel(const SettingModel &); - SettingModel &operator=(const SettingModel &); - virtual ~SettingModel(); - SettingItem settings[SETTING_ITEM_COUNT] = { VIEW_INVALID, nullptr, nullptr, false }; - int usedLen; - bool btConnectStatus{false}; - }; -} - -#endif diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/SleepingDetailsPage.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/SleepingDetailsPage.h deleted file mode 100644 index 34cb969fd..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/SleepingDetailsPage.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: SleepingDetailsPage - * Created: 2025-06-05 - */ -#ifndef SLEEPING_DETAILS_PAGE_H -#define SLEEPING_DETAILS_PAGE_H - -#include "View.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "components/ui_label.h" -#include "components/ui_button.h" -#include "components/ui_label_button.h" -#include "components/ui_image_animator.h" -#include "components/ui_circle_progress.h" -#include "components/ui_view_group.h" -#include "components/ui_scroll_view.h" -#include "SlicePage.h" -#include "main/LoadImg.h" -#include "ui_resource_sleep.h" -#include "sleep/SleepingPresenter.h" -#include "sleep/SleepingView.h" -#include "sleep/SleepingModel.h" - -namespace OHOS { -class SleepingPresenter; -class SleepingDetailsPage : public SlicePage, - public UIView::OnDragListener { -public: - SleepingDetailsPage(); - ~SleepingDetailsPage() override; - - void OnStart(void* data) override; - void InitPage(); - void InitNoDeatilPage(); - void InitDetailPage(); - - void InitSoberingTime(); - void InitRapidEyeMovement(); - void InitLightSleepTime(); - void InitDeepSleepTime(); - bool OnDrag(UIView &view, const DragEvent &event) override; - bool GetRecord(); - std::string SetTimeText(std::tuple timeTuple); - void InitActualSleepTime(std::tuple timeTuple); - void IoadDeatilActualSleepTime(); -private: - - UIScrollView *group{nullptr}; - UIImageView *detailsSleepView{nullptr}; - UILabel *sleep{nullptr}; - UILabel *actualSleepTime{nullptr}; - UILabel *actualSleepTimeHours{nullptr}; - UILabel *actualSleepTimeHoursText{nullptr}; - UILabel *actualSleepTimeMinutes{nullptr}; - UILabel *actualSleepTimeMinutesText{nullptr}; - UIImageView *grayBg{nullptr}; - - UIImageView *image1{nullptr}; - UILabel *soberingTime_{nullptr}; - UILabel *soberingTimeText{nullptr}; - UIImageView *image2{nullptr}; - UILabel *rapidEyeMovement_ {nullptr}; - UILabel *rapidEyeMovementText{nullptr}; - UIImageView *image3{nullptr}; - UILabel *lightSleepTime_{nullptr}; - UILabel *lightSleepTimeText{nullptr}; - UIImageView *image4{nullptr}; - UILabel *deepSleepTime_{nullptr}; - UILabel *deepSleepTimeText{nullptr}; -}; -} - -#endif // SLEEPING_DETAILS_PAGE_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/SleepingMainPage.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/SleepingMainPage.h deleted file mode 100644 index 72492303e..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/SleepingMainPage.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: SleepingMainPage - * Created: 2025-06-05 - */ -#ifndef SLEEPING_MAIN_PAGE_H -#define SLEEPING_MAIN_PAGE_H - -#include "View.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "components/ui_label.h" -#include "components/ui_button.h" -#include "components/ui_label_button.h" -#include "components/ui_image_animator.h" -#include "components/ui_circle_progress.h" -#include "components/ui_view_group.h" -#include "components/ui_circle_progress.h" -#include "components/ui_scroll_view.h" -#include "ui_resource_sleep.h" -#include "main/LoadImg.h" -#include "sleep/TargetSleepTime.h" -#include "sleep/SleepingPresenter.h" -#include "sleep/SleepingView.h" -#include "sleep/SleepingModel.h" - - -namespace OHOS { -class SleepingPresenter; -class SleepingMainPage : public SlicePage, - public UIView::OnClickListener, - public UIView::OnDragListener { -public: - SleepingMainPage(); - ~SleepingMainPage() override; - - void OnStart(void* data) override; - void InitNoRecordPage(); - void InitRecordPage(); - void IoadActualSleepTime(std::tuple timeTuple); - void IoadTargetTimeButton(std::tuple timeTuple); - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; - void CircleProgress(); - void TargetTimeButton(); - uint32_t GetSleepingScores(); - void InitSleepTimeLabel(); - void ScoreDisplay(); - bool GetRecord(); - void InitScoreDisplayPicture(); -private: - - UIImageView *imageViewMain{nullptr}; - UILabel *sleep{nullptr}; - UIImageView *moonNoRecord{nullptr}; - UIImageView *moon{nullptr}; - UILabel *noRecord{nullptr}; - UILabel *tips{nullptr}; - - UILabel *sleepScores_{nullptr}; - UILabel *scoreText{nullptr}; - UILabel *sleepScore{nullptr}; - - UIImageView *scoreDisplayPicture1{nullptr}; - UIImageView *scoreDisplayPicture2{nullptr}; - UIImageView *scoreDisplayPicture3{nullptr}; - UIImageView *scoreDisplayPicture4{nullptr}; - UIImageView *scoreDisplayPicture5{nullptr}; - UIImageView *setting{nullptr}; - UILabel *actualSleepTimeHours{nullptr}; - UILabel *actualSleepTimeHoursText{nullptr}; - UILabel *actualSleepTimeMinutes{nullptr}; - UILabel *actualSleepTimeMinutesText{nullptr}; - - UILabelButton *targetTimeButton{nullptr}; - UILabel *targetTimeText{nullptr}; - UICircleProgress* circleProgress{nullptr}; - - UIScrollView *group{nullptr}; -}; -} - -#endif // SLEEPING_MAIN_PAGE_H diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/SleepingModel.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/SleepingModel.h deleted file mode 100644 index 08965502e..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/SleepingModel.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: SleepingModel - * Created: 2025-06-05 - */ -#ifndef SLEEPING_MODEL_H -#define SLEEPING_MODEL_H - -#include -#include -#include -#include -#include -#include -#include -#include "AppViewIDs.h" -#include "UiConfig.h" -#include "graphic_timer.h" -#include "ohos_timer.h" -#include "wearable_log.h" -#include "diag_service.h" -#include "msg_center_device.h" -#include "diag_common.h" -#include "sleep/SleepingPresenter.h" - -namespace OHOS { - static const uint16_t SLEEP_DATA_DATE_RANGE = 20; - static const uint16_t SLEEP_DATA_START_DATA_RANGE = 24; - - #pragma pack(1) - typedef struct { - bool isSend; - char date[SLEEP_DATA_DATE_RANGE]; - uint8_t type; // 睡眠类别 深睡 浅睡 快速动眼 清醒 - char start[SLEEP_DATA_START_DATA_RANGE]; - char end[SLEEP_DATA_START_DATA_RANGE]; - char sleepStart[SLEEP_DATA_START_DATA_RANGE]; - char sleepEnd[SLEEP_DATA_START_DATA_RANGE]; - } SleepData; - #pragma pack() - - - class SleepingModel { - public: - static SleepingModel &GetInstance(void); - void SendData(); - uint8_t* SerializeSleepData(const SleepData* sleepData, size_t* outSize); - void SetSleepData(); - void SetTime(uint32_t minute); - std::tuple GetTime(); - void SetData(); - std::tuple GetSoberingTime(); - std::tuple GetRapidEyeMovementTime(); - std::tuple GetLightSleepTime(); - std::tuple GetDeepSleepTime(); - std::tuple GetSleepTime(); - void SetSoberingTime(); - void SetRapidEyeMovementTime(); - void SetLightSleepTime(); - void SetDeepSleepTime(); - bool GetRecord(); - uint32_t GetSleepTimeHours(); - uint32_t GetSleepTimeMinutes(); - std::tuple MinutesToHours(uint32_t minutes); - uint32_t TimeDiffInMinutes(const std::string& timeStr1, const std::string& timeStr2); - uint32_t GetDetailData(int type); - uint32_t GetTotalSleepTime(); - - private: - SleepingModel(); - void PrintSleepData(const SleepData *data); - virtual ~SleepingModel(); - uint32_t sleepTarget = 0; - std::vector sleepDataVector; - uint32_t soberingTime; - uint32_t eyeMoveTime; - uint32_t lightTime; - uint32_t deepTime; - }; -} - -#endif diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/SleepingPresenter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/SleepingPresenter.h deleted file mode 100644 index 2e0fdfa4d..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/SleepingPresenter.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: SleepingPresenter - * Created: 2025-06-05 - */ - -#ifndef SETTING_PRESENTER_H -#define SETTING_PRESENTER_H - -#include "Presenter.h" - -namespace OHOS { -class SleepingView; -class SleepingPresenter : public Presenter { -}; -} - -#endif // SETTING_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/SleepingView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/SleepingView.h deleted file mode 100644 index 67325adf9..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/SleepingView.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: SleepingView - * Created: 2025-06-05 - */ - -#ifndef SLEEPING_VIEW_H -#define SLEEPING_VIEW_H - -#include "View.h" -namespace OHOS { -enum SLEEPING_PAGES { - SLEEPING_MAIN_PAGE = 1, // 0 is invalid - SLEEPING_DEATIL_PAGE = 2, - SLEEPING_TARGET_PAGE = 3, -}; - -class SleepingPresenter; -class SleepingView : public View { -}; -} -#endif // SLEEPING_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/TargetSleepTime.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/TargetSleepTime.h deleted file mode 100644 index 2aa0f8be1..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sleep/TargetSleepTime.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TargetSleepTime - * Created: 2025-06-05 - */ - -#ifndef TARGET_SLEEP_TIME_H -#define TARGET_SLEEP_TIME_H - -#include "View.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "components/ui_label.h" -#include "components/ui_button.h" -#include "components/ui_label_button.h" -#include "components/ui_image_animator.h" -#include "components/ui_circle_progress.h" -#include "components/ui_view_group.h" -#include "components/ui_picker.h" -#include "components/ui_scroll_view.h" -#include "main/LoadImg.h" -#include "sleep/SleepingPresenter.h" -#include "sleep/SleepingView.h" -namespace OHOS { -class TargetSleepTime : public SlicePage, - public UIPicker::SelectedListener, - public UIView::OnClickListener, - public UIView::OnDragListener { -public: - TargetSleepTime() = default; - ~TargetSleepTime() override; - - void OnStart(void* data) override; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; - void OnPickerStoped(UIPicker& picker) override; - void TargetTimeButton(); - void CreatePicker(); - void CreateLabel(); - void SetPickerTime(); -private: - UILabel* setTraget{nullptr}; - UILabel* timerLabel{nullptr}; - UILabelButton *startButton{nullptr}; - UIImageView *backgroundImage{nullptr}; - UIScrollView *group{nullptr}; - UIPicker* timerPicker[2]{nullptr}; -}; -} -#endif // TARGET_SLEEP_TIME_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sports/SportsModel.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sports/SportsModel.h deleted file mode 100644 index 8b7b56a1f..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sports/SportsModel.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: Sports Model - * Create: 2025-04-28 - */ - -#ifndef SPORTS_MODEL_H -#define SPORTS_MODEL_H -#include "graphic_timer.h" - -namespace OHOS { - -typedef struct sport_data { - uint32_t step; - uint32_t distance; - int32_t lat; - int32_t lng; - uint32_t speed; - uint16_t heartrate; -} sport_data_t; - -class SportsModel { -public: - ~SportsModel(); - static SportsModel *GetInstance(void); - void Init(); - bool StartSportsTimer(); - void StopSportsTimer(bool isDelete); - void IncrSportsTime(); - std::string CountingSportsTime(); - bool IsActive(); - sport_data_t *GetSportsData(); - void ResetSportsData(); - uint32_t CalculateSpeed(uint32_t distance); - -private: - SportsModel(); - void InitSportsTimer(); - uint32_t uiSportTime_ = 0; - bool isActive_{false}; - GraphicTimer *pGraphicTimer_{nullptr}; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sports/SportsPresenter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sports/SportsPresenter.h deleted file mode 100644 index 6ff4a6985..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sports/SportsPresenter.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: sports Presenter - * Create: 2025-04-28 - */ - -#ifndef SPORTS_PRESENTER_H -#define SPORTS_PRESENTER_H - -#include "Presenter.h" - -namespace OHOS { - -class SportsView; -class SportsPresenter : public Presenter, - public UIView::OnDragListener { -public: - SportsPresenter(); - ~SportsPresenter(); - static SportsPresenter *GetInstance(); - bool OnDrag(UIView& view, const DragEvent& event) override; -private: -}; -} // namespace OHOS -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sports/SportsView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sports/SportsView.h deleted file mode 100644 index aeca78761..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/sports/SportsView.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: sports View - * Create: 2025-04-28 - */ -#ifndef SPORTS_VIEW_H -#define SPORTS_VIEW_H - -#include "View.h" -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_image_view.h" - -namespace OHOS { - -enum SportDataType { - SPORT_TIME = 0, - SPORT_SETP, - SPORT_DISTANCE, - SPORT_HEARTRATE, - SPORT_SPEED, - SPORT_MAX, -}; - -class SportsPresenter; -class SportsView : public View { -public: - SportsView(); - ~SportsView() override; - static SportsView *GetInstance(); - void OnStart() override; - void SetStep(uint32_t step); - void SetHeartRate(uint16_t heartrate); - void SetDistance(uint32_t distance); - void SetTime(const char *time); - void SetSpeed(uint32_t speed); - -private: - bool InitView(); - bool InitLableView(int index, const char *text, uint16_t x, uint16_t y1, uint16_t w, uint16_t y2); - void InitSportDataLabel(); - UILabel TitleLabel[SPORT_MAX]; - UILabel ContentLabel[SPORT_MAX]; - UIViewGroup *group{nullptr}; - UIImageView *backGround{nullptr}; -}; -} // namespace OHOS -#endif // SPORTS_VIEW_H diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/stopwatch/StopwatchAdapter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/stopwatch/StopwatchAdapter.h deleted file mode 100644 index bd160d86e..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/stopwatch/StopwatchAdapter.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: StopwatchAdapter - * Create: 2025-06-06 - */ - -#ifndef STOPWATCH_ADAPTER_H -#define STOPWATCH_ADAPTER_H - -#include "gfx_utils/list.h" -#include "components/abstract_adapter.h" -#include "stopwatch/StopwatchItemView.h" - -namespace OHOS { - -class StopwatchAdapter : public AbstractAdapter { -public: - explicit StopwatchAdapter(); - ~StopwatchAdapter() override; - - void SetData(const List &data); - - uint16_t GetCount(void) override; - UIView *GetView(UIView *inView, int16_t index) override; - -private: - List listData_; -}; -} - -#endif // STOPWATCH_ADAPTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempClickMea.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempClickMea.h deleted file mode 100644 index 06485e007..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempClickMea.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#ifndef TEMP_CLICK_MEA_H -#define TEMP_CLICK_MEA_H - -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "components/ui_scroll_view.h" -#include "temperature/TempPresenter.h" - -namespace OHOS { -class TempClickMea : public UIScrollView { -public: - TempClickMea(); - ~TempClickMea() override; - bool InitClickMea(); - static TempClickMea *GetInstance(); - void RefreshClickMea(void); -private: - bool TempInitButton(void); - bool TempInitLabel(void); - UILabel *tempLabel{nullptr}; - UILabelButton *tempButton[SET_TWO]{nullptr}; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempContinueWarn.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempContinueWarn.h deleted file mode 100644 index 0d0ac1a38..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempContinueWarn.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#ifndef TEMP_CONTINUE_WARN_H -#define TEMP_CONTINUE_WARN_H - -#include "components/ui_image_view.h" -#include "components/ui_label.h" -#include "components/ui_view_group.h" -#include "temperature/TempPresenter.h" - -namespace OHOS { -class TempContinueWarn : public UIViewGroup { -public: - TempContinueWarn(); - ~TempContinueWarn() override; - bool InitTempContinue(); - static TempContinueWarn *GetInstance(); - void RefreshTempContinue(void); -private: - bool TempInitLabel(void); - bool TempInitImage(void); - UIImageView *tempImage{nullptr}; - UILabel *tempLabel[SET_THREE]{nullptr}; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempExitInter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempExitInter.h deleted file mode 100644 index 3b8e93eee..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempExitInter.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#ifndef TEMP_EXIT_INTER_H -#define TEMP_EXIT_INTER_H - -#include "components/ui_image_view.h" -#include "components/ui_label.h" -#include "main/AppGroupView.h" -#include "temperature/TempPresenter.h" - -namespace OHOS { -class TempExitInter : public AppGroupView { -public: - TempExitInter(); - ~TempExitInter() override; - static TempExitInter *GetInstance(); - bool InitView(void *caller) override; -private: - bool TempInitLabel(void); - bool TempInitImage(void); - bool InitSimilarImage(int16 num, int16 tempX, int16 tempY, const char* imageSrc); - UILabel *tempLabel[SET_TWO]{nullptr}; - UIImageView *tempImage[SET_FOUR]{nullptr}; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempExitPrompt.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempExitPrompt.h deleted file mode 100644 index f0395f07f..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempExitPrompt.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#ifndef TEMP_EXIT_PROMPT -#define TEMP_EXIT_PROMPT - -#include "components/ui_image_view.h" -#include "components/ui_label.h" -#include "components/ui_scroll_view.h" -#include "temperature/TempPresenter.h" - -namespace OHOS { -class TempExitPrompt : public UIScrollView { -public: - TempExitPrompt(); - ~TempExitPrompt() override; - bool InitExitPrompt(); - static TempExitPrompt *GetInstance(); -private: - bool TempInitImage(void); - bool TempInitLabel(void); - UIImageView *tempImage[SET_TWO]{nullptr}; - UILabel *tempLabel{nullptr}; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempInitInter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempInitInter.h deleted file mode 100644 index 41bb91f1a..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempInitInter.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#ifndef TEMP_INIT_INTER_H -#define TEMP_INIT_INTER_H - -#include "components/ui_image_view.h" -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "main/AppGroupView.h" -#include "temperature/TempPresenter.h" - -namespace OHOS { -class TempInitInter : public AppGroupView { -public: - TempInitInter(); - ~TempInitInter() override; - static TempInitInter *GetInstance(); - bool InitView(void *caller) override; -private: - bool TempInitImage(void); - bool TempInitButton(void); - bool SetBasicLabel(void); - bool SetAppendLabel(void); - UIImageView *tempImage[SET_THREE]{nullptr}; - UILabel *tempLabel[TEMP_SET_SIX]{nullptr}; - UILabelButton *buttonTemp{nullptr}; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempJoinStudy.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempJoinStudy.h deleted file mode 100644 index 6d66ddd42..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempJoinStudy.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#ifndef TEMP_JOIN_STUDY_H -#define TEMP_JOIN_STUDY_H - -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "components/ui_scroll_view.h" -#include "temperature/TempPresenter.h" - -namespace OHOS { -class TempJoinStudy : public UIScrollView { -public: - TempJoinStudy(); - ~TempJoinStudy() override; - bool InitJoinStudy(); - static TempJoinStudy *GetInstance(); -private: - bool TempInitLabel(void); - bool TempInitButton(void); - bool InitSimilarLabel(int16 num, int16 labelY, const char *labelText); - UILabel *tempTitle{nullptr}; - UILabel *tempLabel[SET_THREE]{nullptr}; - UILabelButton *tempButton[SET_TWO]{nullptr}; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempLittleTip.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempLittleTip.h deleted file mode 100644 index 344e6331d..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempLittleTip.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#ifndef TEMP_LITTLE_TIP -#define TEMP_LITTLE_TIP - -#include "components/ui_label.h" -#include "components/ui_scroll_view.h" -#include "temperature/TempPresenter.h" - -namespace OHOS { -class TempLittleTip : public UIScrollView { -public: - TempLittleTip(); - ~TempLittleTip() override; - bool InitLittleTip(); - static TempLittleTip *GetInstance(); - void RefreshTip(void); -private: - bool SetBasicLabel(void); - bool SetAppendLabel(void); - UILabel *tempLabel[SET_NINE]{nullptr}; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempMainView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempMainView.h deleted file mode 100644 index 6ae132c00..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempMainView.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#ifndef TEMP_MAIN_VIEW_H -#define TEMP_MAIN_VIEW_H - -#include -#include "View.h" -#include "components/ui_view_group.h" -#include "ChangeSliceListener.h" -#include "components/ui_swipe_view.h" -#include "temperature/TempPresenter.h" -#include "temperature/TempJoinStudy.h" -#include "temperature/TempMeasure.h" -#include "temperature/TempExitInter.h" -#include "temperature/TempPromptWear.h" -#include "temperature/TempClickMea.h" -#include "temperature/TempRemindWear.h" -#include "temperature/TempMeaProcess.h" -#include "temperature/TempInitInter.h" -#include "temperature/TempWarn.h" -#include "temperature/TempLittleTip.h" -#include "temperature/TempModel.h" -#include "temperature/TempStudyAbout.h" -#include "temperature/TempExitPrompt.h" -#include "temperature/TempContinueWarn.h" -#include "temperature/TempReport.h" - -namespace OHOS { -class TempMainView; -class TempMainView : public View { -public: - TempMainView(); - ~TempMainView() override; - static TempMainView *GetInstance(void); - void OnStart() override; - void ChangeView(int16 hideView, int16 showView); - void DropView(UIView& view); - int16 GetListenInter(void); - int16 GetWhichInter(void); - bool ChangeMeasure(int16 thisView); - bool ChangePrompt(int16 thisView); - bool ChangeClickMea(int16 thisView); - bool ChangeRemindWear(int16 thisView); - bool ChangeMeaProcess(int16 thisView); - bool ChangeTempInit(int16 thisView); - bool ChangeTempWarn(int16 thisView); - bool ChangeContinue(int16 thisView); - bool ChangeTempTip(int16 thisView); - bool ChangeStudyAbout(int16 thisView); - bool ChangeExitPrompt(int16 thisView); - bool ClickFunc(int16 interf); -private: - bool SetSwipeInter(int16 num); - void DeleteViceInter(void); - UIViewGroup *group{nullptr}; - UIViewGroup *container[11]{nullptr}; // 一共有11个界面 - UISwipeView *tempSwipeList[2]{nullptr}; // 下拉拖动的界面一共有2个 - TempJoinStudy *tempJoinStudy{nullptr}; - TempMeasure *tempMeasure{nullptr}; - TempExitInter *tempExitInter{nullptr}; - TempPromptWear *tempPromptWear{nullptr}; - TempClickMea *tempClickMea{nullptr}; - TempRemindWear *tempRemindWear{nullptr}; - TempMeaProcess *tempMeaProcess{nullptr}; - TempInitInter *tempInitInter{nullptr}; - TempWarn *tempWarn{nullptr}; - TempLittleTip *tempLittleTip{nullptr}; - TempContinueWarn *tempContinue{nullptr}; - TempExitPrompt *tempExitPrompt{nullptr}; - TempStudyAbout *tempStudyAbout{nullptr}; - TempReport *tempReport{nullptr}; - int16 interListen{-1}; // 监测上一个界面,-1用于还没获得监测界面时的初始化 - int16 tempWhichInter{0}; // 监测当前是哪一个温度界面 - int16 tempWhichMea{-1}; // 监测当前处于哪一个监测界面 -}; -} // namespace OHOS -#endif // MAIN_ALARM_VIEW_Ha \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempMeaProcess.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempMeaProcess.h deleted file mode 100644 index 3264e72cd..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempMeaProcess.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#ifndef TEMP_MEA_PROCESS_H -#define TEMP_MEA_PROCESS_H - -#include "components/ui_image_view.h" -#include "components/ui_label.h" -#include "components/ui_scroll_view.h" -#include "components/ui_circle_progress.h" -#include "temperature/TempPresenter.h" - -namespace OHOS { -class TempMeaProcess : public UIScrollView { -public: - TempMeaProcess(); - ~TempMeaProcess() override; - static TempMeaProcess *GetInstance(); - bool InitMeaProcess(void); - void TempMeaDelayExit(void); - UICircleProgress *GetCircleProgress(void); - bool GetCircleStatus(void); - void SetCircleStatus(bool status); -private: - bool TempInitImage(void); - bool TempInitLabel(void); - bool TempCirCleProcess(void); - UICircleProgress *tempCircle{nullptr}; - UIImageView *imageMeasure{nullptr}; - UILabel *tempLabel{nullptr}; - bool circleStatus{false}; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempMeasure.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempMeasure.h deleted file mode 100644 index 972e64e10..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempMeasure.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#ifndef TEMP_MEASURE_H -#define TEMP_MEASURE_H - -#include "components/ui_image_view.h" -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "main/AppGroupView.h" -#include "temperature/TempPresenter.h" - -namespace OHOS { -class TempMeasure : public AppGroupView { -public: - TempMeasure(); - ~TempMeasure() override; - static TempMeasure *GetInstance(); - bool InitView(void *caller) override; -private: - bool TempInitImage(void); - bool TempInitLabel(void); - bool TempInitButton(void); - UILabel *labelMeasure{nullptr}; - UIImageView *imageMeasure[SET_THREE]{nullptr}; - UILabelButton *buttonMeasure{nullptr}; - UILabelButton *backgroudButton{nullptr}; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempModel.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempModel.h deleted file mode 100644 index 0c558818b..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempModel.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#ifndef TEMP_MODEL_H -#define TEMP_MODEL_H - -#include "ohos_types.h" -#include "list.h" -#include "source.h" -#include "ChangeSliceListener.h" - -namespace OHOS { -class TempModel { -public: - TempModel(); - virtual ~TempModel(); - static TempModel *GetInstance(void); - void SetTempInterLis(int16 interListen); - int16 GetTempInterLis(void); -private: - int16 tempInterLis{0}; // 监测是否为首次进入体温应用 -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempPresenter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempPresenter.h deleted file mode 100644 index 2b1321c89..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempPresenter.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#ifndef TEMP_PRESENTER_H -#define TEMP_PRESENTER_H - -#include "Presenter.h" -#include "UiConfig.h" -#include "components/ui_image_view.h" -#include "components/ui_swipe_view.h" -#include "wearable_log.h" -#include "color.h" -#include "main/ModelListenerSample.h" - -namespace OHOS { -constexpr char* TEMP_JOIN_STUDY = (char*)"tempjoinstudy"; -constexpr char* TEMP_INTER_JOIN = (char*)"tempjoin"; -constexpr char* TEMP_INTER_EXIT = (char*)"tempexit"; -constexpr char* TEMP_MEASURE_BUTTON = (char*)"measurebutton"; -constexpr char* TEMP_MEASURE_IMAGE = (char*)"measureimage"; -constexpr char* TEMP_MEASURE_PROCESS = (char*)"measureprocess"; -constexpr char* TEMP_PROMPT_NEXT = (char*)"temppromptnext"; -constexpr char* TEMP_MEA_EXIT = (char*)"tempmeaexit"; -constexpr char* TEMP_MEA_IN = (char*)"tempmeain"; -constexpr char* TEMP_MEA_AGAIN = (char*)"tempmeaagain"; -constexpr char* TEMP_WARN_BUTTON = (char*)"tempwarn"; -constexpr char* TEMP_IMAGE_LIT_TIP = (char*)"tempimagelietip"; -constexpr char* TEMP_EXIT_THIS = (char*)"tempexitstudy"; -constexpr char* TEMP_STUDY_THIS = (char*)"tempaboutstudy"; -constexpr char* TEMP_WARN_ID = (char*)"tempwarnid"; -constexpr char* TEMP_EXIT_DELETE = (char*)"tempexitdelete"; -constexpr char* TEMP_EXIT_TRUE = (char*)"tempexittrue"; -constexpr char* TEMP_SWIPE_EXIT = (char*)"tempswipeexit"; -constexpr int16 BACKGROUND_IMAGE_WIDTH = 190; -constexpr int16 SET_ZERO = 0; -constexpr int16 SET_ONE = 1; -constexpr int16 SET_TWO = 2; -constexpr int16 SET_THREE = 3; -constexpr int16 SET_FOUR = 4; -constexpr int16 SET_FIVE = 5; -constexpr int16 TEMP_SET_SIX = 6; -constexpr int16 SET_SEVEN = 7; -constexpr int16 SET_EIGHT = 8; -constexpr int16 SET_NINE = 9; -constexpr int16 SET_HUNDRED = 100; - -typedef enum { - JOIN_STUDY_INTER = 0, - MEASURE_INTER, - PROMPT_WEAR, - CLICK_MEA, - REMIND_WEAR, - MEASURE_ING, - MEASURE_INIT, - TEMP_WARN_INTER, - TEMP_TIP, - TEMP_EXIT_STUDY, - TEMP_STUDY -} tempInterfacesId; - -class TempMainView; -class TempPresenter : public Presenter, public UIView::OnClickListener, public UIView::OnDragListener, - public ModelListenerSample, public UISwipeView::OnSwipeListener { -public: - TempPresenter(); - ~TempPresenter() override; - void OnResume() override; - void OnStop() override; - void ClickTempJoin(); - void ClickPromptWear(); - void ClickPromptNext(); - void ClickExitMea(); - void ClickIfWear(); - void ClickMeaAgain(void); - void ClickMeasure(); - void ClickTempTip(void); - void ClickTempExit(void); - void ClickStudyTip(void); - void ClickWarnBack(void); - void ClickExitDelete(void); - void ClickExit(void); - void ClickExitTemp(void); - int8 GetTempListen(void); - ColorType CyanColor(void); - static TempPresenter *GetInstance(); - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView& view, const DragEvent& event) override; - bool ClickFuncId(const char *buttonName); - void OnSwipe(UISwipeView &view) override; - void ProgressNotify(void); - void SetTempCountMax(void); - void UpdateTempCount(void); - void Notify() override; -private: - uint8 wearListen{0}; - int8 tempListen{-1}; // 监测隐藏界面 - int16 countTemp{100}; // 体温进度条默认值为100 -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempPromptWear.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempPromptWear.h deleted file mode 100644 index 2b3793cfa..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempPromptWear.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#ifndef TEMP_PROMPT_WEAR_H -#define TEMP_PROMPT_WEAR_H - -#include "components/ui_image_view.h" -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "components/ui_scroll_view.h" -#include "temperature/TempPresenter.h" - -namespace OHOS { -class TempPromptWear : public UIScrollView { -public: - TempPromptWear(); - ~TempPromptWear() override; - bool InitPromptWear(); - static TempPromptWear *GetInstance(); -private: - bool TempInitLabel(void); - bool TempInitButton(void); - bool TempInitImage(void); - UILabel *tempLabel{nullptr}; - UILabelButton *tempButton{nullptr}; - UIImageView *tempImage{nullptr}; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempRemindWear.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempRemindWear.h deleted file mode 100644 index 9375bf154..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempRemindWear.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#ifndef TEMP_REMIND_WAER_H -#define TEMP_REMIND_WAER_H - -#include "components/ui_image_view.h" -#include "components/ui_label.h" -#include "components/ui_scroll_view.h" -#include "temperature/TempPresenter.h" - -namespace OHOS { -class TempRemindWear : public UIScrollView { -public: - TempRemindWear(); - ~TempRemindWear() override; - bool InitRemindWear(); - static TempRemindWear *GetInstance(); -private: - bool TempInitImage(void); - bool TempInitLabel(void); - UIImageView *tempImage[SET_TWO]{nullptr}; - UILabel *tempLabel{nullptr}; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempReport.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempReport.h deleted file mode 100644 index 649afb5cf..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempReport.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#ifndef TEMP_REPORT_H -#define TEMP_REPORT_H - -#include "components/ui_image_view.h" -#include "components/ui_label.h" -#include "main/AppGroupView.h" -#include "temperature/TempPresenter.h" - -namespace OHOS { -class TempReport : public AppGroupView { -public: - TempReport(); - ~TempReport() override; - static TempReport *GetInstance(); - bool InitView(void *caller) override; -private: - bool SetBasicLabel(void); - bool SetAppendLabel(void); - bool InitSimilarImage(int16 num, int16 tempX, int16 tempY, const char* imageSrc); - bool TempInitImage(void); - UILabel *tempLabel[TEMP_SET_SIX]{nullptr}; - UIImageView *tempImage[SET_FIVE]{nullptr}; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempStudyAbout.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempStudyAbout.h deleted file mode 100644 index 754c3912d..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempStudyAbout.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#ifndef TEMP_STUDY_ABOUT -#define TEMP_STUDY_ABOUT - -#include "components/ui_label.h" -#include "components/ui_scroll_view.h" -#include "temperature/TempPresenter.h" - -namespace OHOS { -class TempStudyAbout : public UIScrollView { -public: - TempStudyAbout(); - ~TempStudyAbout() override; - bool InitStudyAbout(); - static TempStudyAbout *GetInstance(); - void RefreshStudy(void); -private: - bool SetBasicLabel(void); - bool SetAppendLabel(void); - UILabel *tempLabel[SET_FIVE]{nullptr}; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempWarn.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempWarn.h deleted file mode 100644 index 1fbc6ebf3..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/temperature/TempWarn.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#ifndef TEMP_WARN_H -#define TEMP_WARN_H - -#include "components/ui_image_view.h" -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "components/ui_scroll_view.h" -#include "temperature/TempPresenter.h" - -namespace OHOS { -class TempWarn : public UIScrollView { -public: - TempWarn(); - ~TempWarn() override; - bool InitTempWarn(); - static TempWarn *GetInstance(); - void RefreshTempWarn(void); -private: - bool TempInitImage(void); - bool TempInitButton(void); - bool TempInitLabel(void); - UIImageView *tempImage{nullptr}; - UILabelButton *tempButton{nullptr}; - UILabel *tempLabel{nullptr}; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/timers/TimerTimingPage.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/timers/TimerTimingPage.h deleted file mode 100644 index a64450a42..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/timers/TimerTimingPage.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TimerTimingPage - * Create: 2025-06-09 - */ - -#ifndef TIMER_TIMING_PAGE_H -#define TIMER_TIMING_PAGE_H - -#include -#include "View.h" -#include "components/ui_button.h" -#include "components/ui_label.h" -#include "components/ui_scroll_view.h" -#include "components/ui_digital_clock.h" -#include "components/ui_image_view.h" -#include "components/ui_circle_progress.h" -#include "UiConfig.h" -#include "timers/TimerModel.h" -#include "timers/TimerPresenter.h" -#include "SlicePage.h" -#include "ChangeSliceListener.h" -#include "components/ui_sweep_clock.h" -#include "ui_resource_timer.h" - -namespace OHOS { - class TimerTimingPage : public SlicePage, - public UIView::OnClickListener, - public UIView::OnDragListener { - public: - TimerTimingPage() = default; - ~TimerTimingPage() override; - void OnStart(void *data) override; - void OnResume() override; - void OnPause() override; - - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; - void CreateButton(); - void CreateTimerTime(); - void CircleProgress(); - void SetTimerTime(uint32_t durationTime); - void SetupAnimator(); - void SetAnimatorStatus(bool status); - - private: - class TimeAnimatorCallback : public AnimatorCallback { - public: - TimeAnimatorCallback() {} - virtual ~TimeAnimatorCallback() override {} - void Callback(UIView *view) override; - }; - - class TimerTimingCallback : public AnimatorCallback { - public: - explicit TimerTimingCallback(TimerTimingPage *page) : page_(page) {} - ~TimerTimingCallback() override {} - void Callback(UIView *view) override; - - private: - TimerTimingPage *page_{nullptr}; - }; - - UIScrollView *group{nullptr}; - UISweepClock *sweepClock_{nullptr}; - UIDigitalClock *dClock{nullptr}; - UILabel *title{nullptr}; - UIDigitalClock *timerTime{nullptr}; - UIImageView *reset{nullptr}; - UIImageView *start{nullptr}; - UICircleProgress *circleProgress{nullptr}; - UILabel *currentTime_{nullptr}; - TimeAnimatorCallback *timeCallback_{nullptr}; - Animator *timeAnimator_{nullptr}; - TimerTimingCallback *callBack_ = nullptr; - Animator *animator_ = nullptr; - Image *secondHand_{nullptr}; - UIImageView *backround{nullptr}; - }; -} -#endif // TIMER_TIMING_PAGE_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/DataView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/DataView.h deleted file mode 100644 index d22cc5576..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/DataView.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: Data View - * Create: 2025-03-22 - */ - -#ifndef TRAINING_DATA_VIEW_H -#define TRAINING_DATA_VIEW_H - -#include "components/ui_label.h" -#include "components/ui_canvas.h" -#include "components/ui_image_view.h" -#include "components/ui_view_group.h" - -namespace OHOS { -class DataView { -public: - DataView(); - ~DataView(); - static DataView *GetInstance(); - UIViewGroup *InitShowUpView(void); - void UpdateDataViewByType(); - -private: - void ShowupBackgroup(); - void ShowupTopView(); - void ShowupLeftView(); - void ShowupRightView(); - void ShowupBottomView(); - void ShowupSepLine(); - UIImageView *backGround{nullptr}; - UIImageView *heartrate{nullptr}; - UICanvas *sepLine{nullptr}; - UILabel *topValueLabel{nullptr}; - UILabel *topUnitLabel{nullptr}; - UILabel *leftValueLabel{nullptr}; - UILabel *leftUnitLabel{nullptr}; - UILabel *rightValueLabel{nullptr}; - UILabel *rightUnitLabel{nullptr}; - UILabel *bottomValueLabel{nullptr}; - UILabel *bottomUnitLabel{nullptr}; - UIViewGroup *group{nullptr}; -}; -} // namespace OHOS -#endif // TRAINING_DATA_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/MenuView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/MenuView.h deleted file mode 100644 index 02bd72eb0..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/MenuView.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: Menu View - * Create: 2025-03-22 - */ - -#ifndef TRAINING_MENU_VIEW_H -#define TRAINING_MENU_VIEW_H - -#include "components/ui_label.h" -#include "components/ui_list.h" -#include "components/ui_view_group.h" -#include "training/TrainingItemView.h" -#include "training/TrainingAdapter.h" -#include "UiConfig.h" -namespace OHOS { -enum TrainingTypes : uint8_t { - TRAINING_TYPE_OUTDOOR_RUNNING = 0, - TRAINING_TYPE_INDOOR_RUNNING, - TRAINING_TYPE_CYCLING, - TRAINING_TYPE_CLIMBING, - TRAINING_TYPE_INDOOR_SWIMMING, - TRAINING_TYPE_OUTDOOR_SWIMMING, - TRAINING_TYPE_MAX, -}; - -#define TRAINING_ITEM_OUTDOOR_RUNNING "trainingItemOutdoorRunning" -#define TRAINING_ITEM_INDOOR_RUNNING "trainingItemIndoorRunning" -#define TRAINING_ITEM_CYCLING "trainingItemCycling" -#define TRAINING_ITEM_CLIMBING "trainingItemClimbing" -#define TRAINING_ITEM_INDOOR_SWIMMING "trainingItemIndoorSwimming" -#define TRAINING_ITEM_OUTDOOR_SWIMMING "trainingItemOutdoorSwimming" - -class MenuView { -public: - MenuView(); - ~MenuView(); - static MenuView *GetInstance(); - UIViewGroup *InitShowUpView(void); - -private: - void CreateUILabel(void); - void CreateUIList(void); - UILabel *titleLabel{nullptr}; - UIList *trainingList{nullptr}; - TrainingAdapter *listAdapter_{nullptr}; - UIViewGroup *group{nullptr}; - TrainingItem trainings[TRAINING_TYPE_MAX] = { - {TRAINING_TYPE_OUTDOOR_RUNNING, PNG_APPLIST_WALK_IMAGE, "户外跑步", TRAINING_ITEM_OUTDOOR_RUNNING}, - {TRAINING_TYPE_INDOOR_RUNNING, PNG_APPLIST_WALK_IMAGE, "室内跑步", TRAINING_ITEM_INDOOR_RUNNING}, - {TRAINING_TYPE_CYCLING, PNG_APPLIST_WALK_IMAGE, "骑行", TRAINING_ITEM_CYCLING}, - {TRAINING_TYPE_CLIMBING, PNG_APPLIST_WALK_IMAGE, "登山", TRAINING_ITEM_CLIMBING}, - {TRAINING_TYPE_INDOOR_SWIMMING, PNG_APPLIST_WALK_IMAGE, "室内游泳", TRAINING_ITEM_INDOOR_SWIMMING}, - {TRAINING_TYPE_OUTDOOR_SWIMMING, PNG_APPLIST_WALK_IMAGE, "户外游泳", TRAINING_ITEM_OUTDOOR_SWIMMING}}; -}; -} // namespace OHOS -#endif // TRAINING_MENU_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/PauseView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/PauseView.h deleted file mode 100644 index cde8714b7..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/PauseView.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: Pause View - * Create: 2025-03-22 - */ - -#ifndef TRAINING_PAUSE_VIEW_H -#define TRAINING_PAUSE_VIEW_H - -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "components/ui_view_group.h" - -namespace OHOS { -#define TRAINING_PAUSE_CONTINUE_BUTTON "trainingPauseContinueButton" -#define TRAINING_PAUSE_FINISH_BUTTON "trainingPauseFinishButton" - -class PauseView { -public: - PauseView(); - ~PauseView(); - static PauseView *GetInstance(); - UIViewGroup *InitShowUpView(void); - -private: - void CreateUILabel(void); - void CreateUIButton(void); - UILabel *timeLabel{nullptr}; - UILabel *textLabel{nullptr}; - UILabelButton *continueButton{nullptr}; - UILabelButton *finishButton{nullptr}; - UIViewGroup *group{nullptr}; -}; -} // namespace OHOS -#endif // TRAINING_PAUSE_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/PrepareView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/PrepareView.h deleted file mode 100644 index 1805406ac..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/PrepareView.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: Prepare View - * Create: 2025-03-22 - */ - -#ifndef TRAINING_PREPARE_VIEW_H -#define TRAINING_PREPARE_VIEW_H - -#include "components/ui_label.h" -#include "components/ui_image_view.h" -#include "components/ui_label_button.h" -#include "components/ui_view_group.h" - -namespace OHOS { -#define TRAINING_PREPARE_START_BUTTON "trainingPrepareStartButton" -class PrepareView { -public: - PrepareView(); - ~PrepareView(); - static PrepareView *GetInstance(); - UIViewGroup *InitShowUpView(void); - void UpdateViewByTrainingType(uint8_t trainingType); - -private: - bool InitBatteryView(); - bool InitHeartbeatView(); - bool InitTimeLableVIew(); - bool InitLocatingLableVIew(); - bool InitCenterView(); - bool InitGPSView(); - bool InitHeartrateView(); - bool InitStartButtonView(); - UILabel *timeLabel{nullptr}; - UIImageView *battery{nullptr}; - UILabel *batteryLabel{nullptr}; - UIImageView *gpsImageView{nullptr}; - UILabel *gpsLabel{nullptr}; - UIImageView *heartRateImageView{nullptr}; - UILabel *heartRateLabel{nullptr}; - UILabel *locatingLabel{nullptr}; - UILabelButton *startButton{nullptr}; - UIButton *iconImageView{nullptr}; - UIViewGroup *group{nullptr}; -}; -} // namespace OHOS -#endif // TRAINING_PREPARE_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/PromptView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/PromptView.h deleted file mode 100644 index 7a1d38f0f..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/PromptView.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: Prompt View - * Create: 2025-03-22 - */ - -#ifndef PROMPT_VIEW_H -#define PROMPT_VIEW_H - -#include "components/ui_label.h" -#include "components/ui_button.h" -#include "components/ui_view_group.h" - -namespace OHOS { -#define TRAINING_PROMPT_CANCEL_BUTTON "trainingPromptCancelButton" -#define TRAINING_PROMPT_CONFIRM_BUTTON "trainingPromptConfirmButton" - -class PromptView { -public: - PromptView(); - ~PromptView(); - static PromptView *GetInstance(); - UIViewGroup *InitShowUpView(void); - -private: - void CreateUILabel(void); - void CreateUIButton(void); - UILabel *titleLabel{nullptr}; - UIButton *cancelButton{nullptr}; - UIButton *confirmButton{nullptr}; - UIViewGroup *group{nullptr}; -}; -} // namespace OHOS -#endif // PROMPT_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TargetAdapter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TargetAdapter.h deleted file mode 100644 index 74045cd7f..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TargetAdapter.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TargetAdapter.h - * Author: - * Create: 2025-11-23 - */ - -#ifndef TARGET_ADAPTER_H -#define TARGET_ADAPTER_H - -#include -#include "training/TargetItemView.h" -#include "components/abstract_adapter.h" - -namespace OHOS { - -class TargetAdapter : public AbstractAdapter { -public: - explicit TargetAdapter(); - ~TargetAdapter() override; - - /* * - * @brief Sets the UIView adapter data, which is a SettingItem linked list. - * - * @param data Indicates the SettingItem linked list data. - * @since 1.0 - * @version 1.0 - */ - void SetData(const std::list &data); - - /* * - * @brief Obtains the data size of the UILabel adapter. - * - * @return Returns the data size of the UILabel adapter. - * @since 1.0 - * @version 1.0 - */ - uint16_t GetCount(void) override; - - UIView *GetView(UIView *inView, int16_t index) override; - - void AddListItem(const TargetItem &item); - - void SetItemClickListener(UIView::OnClickListener *itemclicklistener) - { - itemClickListener = itemclicklistener; - } -private: - std::list listData_; - UIView::OnClickListener *itemClickListener{nullptr}; -}; -} - -#endif // TARGET_ADAPTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TargetItemView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TargetItemView.h deleted file mode 100644 index 13c211fbe..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TargetItemView.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TargetItemView - * Author: - * Create: 2025-02-15 - */ - -#ifndef TARGET_ITEM_H -#define TARGET_ITEM_H - -#include "components/ui_view_group.h" -#include "components/ui_image_view.h" -#include "components/ui_label.h" - -namespace OHOS { -typedef struct { - uint8_t type; - const char *icon; - const char *label; - const char *viewId; -} TargetItem; - -class TargetItemView : public UIViewGroup { -public: - TargetItemView(); - ~TargetItemView() override; - - virtual void SetItemInfo(const TargetItem itemInfo); - -private: - bool InitView(); - UIImageView sIcon; - UILabel sLabel; - UIImageView sNextImage; - TargetItem sItemInfo = {0, nullptr, nullptr, nullptr}; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TargetSettingView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TargetSettingView.h deleted file mode 100644 index 69ed6f1e4..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TargetSettingView.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TargetSetting View - * Create: 2025-03-22 - */ - -#ifndef TRAINING_TARGET_SETTING_VIEW_H -#define TRAINING_TARGET_SETTING_VIEW_H - -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "components/ui_view_group.h" -#include "components/ui_picker.h" - -namespace OHOS { -#define TARGET_SETTING_CONFIRM_BUTTON "targetSettingConfirmButton" - -class TargetSettingView { -public: - TargetSettingView(); - ~TargetSettingView(); - static TargetSettingView *GetInstance(); - UIViewGroup *InitShowUpView(void); - void UpdateViewByTargetType(uint8_t targetType); - -private: - void CreateUILabel(void); - void CreateUIPicker(void); - void CreateUIButton(void); - UILabel *titleLabel{nullptr}; - UIPicker *picker{nullptr}; - UILabelButton *confirmButton{nullptr}; - UIViewGroup *group{nullptr}; -}; -} // namespace OHOS -#endif // TRAINING_TARGET_SETTING_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TargetView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TargetView.h deleted file mode 100644 index 14e71ed63..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TargetView.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: Target View - * Create: 2025-03-22 - */ - -#ifndef TRAINING_TARGET_VIEW_H -#define TRAINING_TARGET_VIEW_H - -#include "components/ui_label.h" -#include "components/ui_list.h" -#include "components/ui_view_group.h" -#include "training/TargetItemView.h" -#include "training/TargetAdapter.h" -#include "UiConfig.h" -namespace OHOS { -enum TrainingTargets : uint8_t { - TRAINING_TARGET_DISTANCE = 0, - TRAINING_TARGET_TIME, - TRAINING_TARGET_CALORIE, - TRAINING_TARGET_MAX, -}; - -#define TRAINING_TARGET_ITEM_DISTANCE "trainingTargetItemDistance" -#define TRAINING_TARGET_ITEM_TIME "trainingTargetItemTime" -#define TRAINING_TARGET_ITEM_CALORIE "trainingTargetItemCalorie" - -class TargetView { -public: - TargetView(); - ~TargetView(); - static TargetView *GetInstance(); - UIViewGroup *InitShowUpView(void); - -private: - void CreateUILabel(void); - void CreateUIList(void); - UILabel *titleLabel{nullptr}; - UIList *targetList{nullptr}; - TargetAdapter *listAdapter_{nullptr}; - UIViewGroup *group{nullptr}; - TargetItem targets[TRAINING_TARGET_MAX] = { - {TRAINING_TARGET_DISTANCE, PNG_PHONE_IMAGE, "距离", TRAINING_TARGET_ITEM_DISTANCE}, - {TRAINING_TARGET_TIME, PNG_WATCH_IMAGE, "时间", TRAINING_TARGET_ITEM_TIME}, - {TRAINING_TARGET_CALORIE, PNG_BLUETOOTH_IMAGE, "热量", TRAINING_TARGET_ITEM_CALORIE}}; -}; -} // namespace OHOS -#endif // TRAINING_TARGET_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingAdapter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingAdapter.h deleted file mode 100644 index 19b747c49..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingAdapter.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TrainingAdapter.h - * Author: - * Create: 2025-11-23 - */ - -#ifndef TRAINING_ADAPTER_H -#define TRAINING_ADAPTER_H - -#include -#include "training/TrainingItemView.h" -#include "components/abstract_adapter.h" - -namespace OHOS { - -class TrainingAdapter : public AbstractAdapter { -public: - explicit TrainingAdapter(); - ~TrainingAdapter() override; - - /* * - * @brief Sets the UIView adapter data, which is a SettingItem linked list. - * - * @param data Indicates the SettingItem linked list data. - * @since 1.0 - * @version 1.0 - */ - void SetData(const std::list &data); - - /* * - * @brief Obtains the data size of the UILabel adapter. - * - * @return Returns the data size of the UILabel adapter. - * @since 1.0 - * @version 1.0 - */ - uint16_t GetCount(void) override; - - UIView *GetView(UIView *inView, int16_t index) override; - - void AddListItem(const TrainingItem &item); - - void SetItemClickListener(UIView::OnClickListener *itemclicklistener) - { - itemClickListener = itemclicklistener; - } -private: - std::list listData_; - UIView::OnClickListener *itemClickListener{nullptr}; -}; -} - -#endif // TRAINING_ADAPTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingItemView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingItemView.h deleted file mode 100644 index 7b863f997..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingItemView.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TrainingItemView - * Author: - * Create: 2025-02-15 - */ - -#ifndef TRAINING_ITEM_H -#define TRAINING_ITEM_H - -#include "components/ui_view_group.h" -#include "components/ui_image_view.h" -#include "components/ui_label.h" - -namespace OHOS { -typedef struct { - uint8_t type; - const char *icon; - const char *label; - const char *viewId; -} TrainingItem; - -class TrainingItemView : public UIViewGroup { -public: - TrainingItemView(); - ~TrainingItemView() override; - - virtual void SetItemInfo(const TrainingItem itemInfo); - -private: - bool InitView(); - UIImageView sIcon; - UILabel sLabel; - UIImageView sSettingImage; - TrainingItem sItemInfo = {0, nullptr, nullptr, nullptr}; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingModel.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingModel.h deleted file mode 100644 index 32b122ce3..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingModel.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TrainingModel.h - * Author: - * Create: 2025-11-23 - */ - -#ifndef TRAINING_MODEL_H -#define TRAINING_MODEL_H - -#include -namespace OHOS { -class TrainingModel { -public: - static TrainingModel &GetInstance(void); - void SetCurView(int16_t viewNum); - int16_t GetCurView(void); - void SetCurTrainingType(int8_t trainingType); - int8_t GetCurTrainingType(void); - -private: - TrainingModel(); - TrainingModel(const TrainingModel &); - TrainingModel &operator=(const TrainingModel &); - virtual ~TrainingModel(); - int16_t curView_{0}; - uint8_t trainingType_{0}; -}; -} - -#endif // TRAINING_MODEL_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingPresenter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingPresenter.h deleted file mode 100644 index b23bfcb35..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingPresenter.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TrainingPresenter.h - * Author: - * Create: 2025-11-23 - */ - -#ifndef TRAINING_PRESENTER_H -#define TRAINING_PRESENTER_H - -#include "Presenter.h" -#include "training/TrainingView.h" -#include "training/TrainingModel.h" -#include "components/ui_view.h" - -namespace OHOS { -class TrainingView; -class TrainingPresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener { -public: - TrainingPresenter(); - ~TrainingPresenter() override; - static TrainingPresenter *GetInstance(); - - void OnResume() override; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView& view, const DragEvent& event) override; - void OnPause() override; -private: - void ClickStartButton(void); - void ClickCountineButton(void); - void ClickFinishButton(void); - void ClickCancelButton(void); - void ClickConfirmButton(void); - void TrainingSetting(uint8_t trainingType); - void StartTraining(uint8_t trainingType); - void SettingTarget(uint8_t targetType); - void EnterTarget(void); - void ConfirmTargetSetting(void); - TrainingModel *trainingModel_{nullptr}; -}; -} - -#endif // TRAINING_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingSettingAdapter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingSettingAdapter.h deleted file mode 100644 index b0c1d823f..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingSettingAdapter.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TrainingSettingAdapter.h - * Author: - * Create: 2025-11-23 - */ - -#ifndef TRAINING_SETTING_ADAPTER_H -#define TRAINING_SETTING_ADAPTER_H - -#include -#include "training/TrainingSettingItemView.h" -#include "components/abstract_adapter.h" - -namespace OHOS { - -class TrainingSettingAdapter : public AbstractAdapter { -public: - explicit TrainingSettingAdapter(); - ~TrainingSettingAdapter() override; - - /* * - * @brief Sets the UIView adapter data, which is a SettingItem linked list. - * - * @param data Indicates the SettingItem linked list data. - * @since 1.0 - * @version 1.0 - */ - void SetData(const std::list &data); - - /* * - * @brief Obtains the data size of the UILabel adapter. - * - * @return Returns the data size of the UILabel adapter. - * @since 1.0 - * @version 1.0 - */ - uint16_t GetCount(void) override; - - UIView *GetView(UIView *inView, int16_t index) override; - - void AddListItem(const TrainingSettingItem &item); - - void SetItemClickListener(UIView::OnClickListener *itemclicklistener) - { - itemClickListener = itemclicklistener; - } -private: - std::list listData_; - UIView::OnClickListener *itemClickListener{nullptr}; -}; -} - -#endif // TRAINING_SETTING_ADAPTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingSettingItemView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingSettingItemView.h deleted file mode 100644 index 26a644259..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingSettingItemView.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TrainingSettingItemView.h - * Author: - * Create: 2025-11-23 - */ - -#ifndef TRAINING_SETTING_ITEM_H -#define TRAINING_SETTING_ITEM_H - -#include "components/ui_view_group.h" -#include "components/ui_image_view.h" -#include "components/ui_label.h" - -namespace OHOS { -typedef struct { - uint8_t type; - const char *icon; - const char *label; - const char *viewId; -} TrainingSettingItem; - -class TrainingSettingItemView : public UIViewGroup { -public: - TrainingSettingItemView(); - ~TrainingSettingItemView() override; - - virtual void SetItemInfo(const TrainingSettingItem itemInfo); - -private: - bool InitView(); - UIImageView sIcon; - UILabel sLabel; - UIImageView sNextImage; - TrainingSettingItem sItemInfo = {0, nullptr, nullptr, nullptr}; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingSettingView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingSettingView.h deleted file mode 100644 index deba904f9..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingSettingView.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TrainingSetting View - * Create: 2025-03-22 - */ - -#ifndef TRAINING_SETTING_VIEW_H -#define TRAINING_SETTING_VIEW_H - -#include "components/ui_label.h" -#include "components/ui_list.h" -#include "components/ui_view_group.h" -#include "training/TrainingSettingItemView.h" -#include "training/TrainingSettingAdapter.h" -#include "UiConfig.h" - -namespace OHOS { -enum TrainingSettings : uint8_t { - TRAINING_SETTING_TARGET = 0, - TRAINING_SETTING_REMIND, - TRAINING_SETTING_MISTOUCH, - TRAINING_SETTING_DATA_DISPLAY, - TRAINING_SETTING_METRONOME, - TRAINING_SETTING_REMOVE, - TRAINING_SETTING_MAX, -}; - -#define TRAINING_SETTING_ITEM_TARGET "trainingSettingItemTarget" -#define TRAINING_SETTING_ITEM_REMIND "trainingSettingItemTargetRemind" -#define TRAINING_SETTING_ITEM_MISTOUCH "trainingSettingItemTargetMistouch" -#define TRAINING_SETTING_ITEM_DATA_DISPLAY "trainingSettingItemTargetDataDisplay" -#define TRAINING_SETTING_ITEM_METRONOME "trainingSettingItemTargetMetronome" -#define TRAINING_SETTING_ITEM_REMOVE "trainingSettingItemTargetRemove" - -class TrainingSettingView { -public: - TrainingSettingView(); - ~TrainingSettingView(); - static TrainingSettingView *GetInstance(); - UIViewGroup *InitShowUpView(void); - -private: - void CreateUILabel(void); - void CreateUIList(void); - UILabel *titleLabel{nullptr}; - UIList *settingList{nullptr}; - TrainingSettingAdapter *listAdapter_{nullptr}; - UIViewGroup *group{nullptr}; - TrainingSettingItem settings[TRAINING_SETTING_MAX] = { - {TRAINING_SETTING_TARGET, PNG_BLUETOOTH_IMAGE, "目标", TRAINING_SETTING_ITEM_TARGET}, - {TRAINING_SETTING_REMIND, PNG_WATCH_IMAGE, "提醒", TRAINING_SETTING_ITEM_REMIND}, - {TRAINING_SETTING_MISTOUCH, PNG_PHONE_IMAGE, "防误触", TRAINING_SETTING_ITEM_MISTOUCH}, - {TRAINING_SETTING_DATA_DISPLAY, PNG_BLUETOOTH_IMAGE, "数据显示", TRAINING_SETTING_ITEM_DATA_DISPLAY}, - {TRAINING_SETTING_METRONOME, PNG_WATCH_IMAGE, "节拍器", TRAINING_SETTING_ITEM_METRONOME}, - {TRAINING_SETTING_REMOVE, PNG_PHONE_IMAGE, "移除此运动", TRAINING_SETTING_ITEM_REMOVE}}; -}; -} // namespace OHOS -#endif // SETTING_SETTING_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingView.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingView.h deleted file mode 100644 index 8c1bbd9ba..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/training/TrainingView.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TrainingViews View - * Create: 2025-03-22 - */ - -#ifndef TRAINING_VIEW_H -#define TRAINING_VIEW_H - -#include "View.h" -#include "components/ui_view_group.h" -#include "training/MenuView.h" -#include "training/PrepareView.h" -#include "training/DataView.h" -#include "training/PauseView.h" -#include "training/PromptView.h" -#include "training/TrainingSettingView.h" -#include "training/TargetView.h" -#include "training/TargetSettingView.h" - -namespace OHOS { -enum TrainingViews : uint8_t { - TRAINING_VIEW_MENU, - TRAINING_VIEW_PREPARE, - TRAINING_VIEW_DATA, - TRAINING_VIEW_PAUSE, - TRAINING_VIEW_PROMPT, - TRAINING_VIEW_SETTING, - TRAINING_VIEW_TARGET, - TRAINING_VIEW_TARGET_SETTING, - TRAINING_VIEW_MAX, -}; - -constexpr const char *MENU_VIEW_ID = "MenuViewID"; -constexpr const char *PREPARE_VIEW_ID = "PrepareViewID"; -constexpr const char *DATA_VIEW_ID = "DataViewID"; -constexpr const char *PAUSE_VIEW_ID = "PauseViewID"; -constexpr const char *PROMPT_VIEW_ID = "PromptViewID"; -constexpr const char *SETTING_VIEW_ID = "SettingViewID"; -constexpr const char *TARGET_VIEW_ID = "TargetViewID"; -constexpr const char *TARGET_SETTING_VIEW_ID = "TargetSettingViewID"; - -class TrainingPresenter; -class TrainingView : public View { -public: - TrainingView(); - ~TrainingView() override; - static TrainingView *GetInstance(); - - void OnStart() override; - void OnStop() override; - void ChangeView(int16_t hideView, int16_t showView); - -private: - UIViewGroup *container[TRAINING_VIEW_MAX]{nullptr}; - typedef bool (TrainingView::*PreprosssChangeView)(int16_t hideView, int16_t thisView); - PreprosssChangeView preProcessView[TRAINING_VIEW_MAX]; - bool CheckViewParam(int16_t hideView, int16_t showView); - MenuView *menuView{nullptr}; - PrepareView *prepareView{nullptr}; - DataView *dataView{nullptr}; - PauseView *pauseView{nullptr}; - PromptView *promptView{nullptr}; - TrainingSettingView *settingView{nullptr}; - TargetView *targetView{nullptr}; - TargetSettingView *targetSettingView{nullptr}; - bool ChangeMenuView(int16_t hideView, int16_t thisView); - bool ChangePrepareView(int16_t hideView, int16_t thisView); - bool ChangeDataView(int16_t hideView, int16_t thisView); - bool ChangePauseView(int16_t hideView, int16_t thisView); - bool ChangePromptView(int16_t hideView, int16_t thisView); - bool ChangeSettingView(int16_t hideView, int16_t thisView); - bool ChangeTargetView(int16_t hideView, int16_t thisView); - bool ChangeTargetSettingView(int16_t hideView, int16_t thisView); -}; -} -#endif // TRAINING_VIEW_H diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/weather/WeatherAdapter.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/weather/WeatherAdapter.h deleted file mode 100644 index c94553bfa..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/weather/WeatherAdapter.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: weather/WeatherAdapter.h - * Create: 2025-03-23 - */ - -#ifndef WEATHER_ADAPTER_H -#define WEATHER_ADAPTER_H - -#include -#include -#include "components/ui_list.h" -#include "components/ui_label.h" -#include "components/ui_view_group.h" -#include "components/ui_image_view.h" -#include "components/abstract_adapter.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "weather/WeatherModel.h" -#include "weather/WeatherItemView.h" - -namespace OHOS { -class WeatherAdapter : public AbstractAdapter { -public: - explicit WeatherAdapter(); - ~WeatherAdapter() override; - - /* * - * @brief Sets the UIView adapter data, which is a WeatherItem linked list. - * - * @param data Indicates the WeatherItem linked list data. - * @since 1.0 - * @version 1.0 - */ - void SetData(std::list &data); - - /* * - * @brief Obtains the data size of the UILabel adapter. - * - * @return Returns the data size of the UILabel adapter. - * @since 1.0 - * @version 1.0 - */ - uint16_t GetCount(void) override; - - UIView *GetView(UIView *inView, int16_t index) override; - - void AddListItem(const WeatherItem &item); - - void SetItemClickListener(UIView::OnClickListener *itemclicklistener) - { - itemClickListener = itemclicklistener; - } -private: - std::list listData; - UIView::OnClickListener *itemClickListener{nullptr}; -}; -} - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/weather/WeatherPageSecond.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/weather/WeatherPageSecond.h deleted file mode 100644 index 85638351d..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/weather/WeatherPageSecond.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: WeatherPageSecond - * Create: 2025-03-15 - */ - -#ifndef WEATHER_PAGESECOND_H -#define WEATHER_PAGESECOND_H - -#include "components/ui_image_view.h" -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "components/ui_swipe_view.h" -#include "ui_swipe_view.h" -#include "weather/WeatherPresenter.h" -#include "weather/WeatherView.h" -#include "SlicePage.h" -#include "UiConfig.h" -namespace OHOS { -class WeatherPresenter; -class WeatherPageSecond : public SlicePage, - public UIView::OnClickListener, - public UIView::OnDragListener, - public UISwipeView::OnSwipeListener { -public: - WeatherPageSecond(); - ~WeatherPageSecond() override; - void OnStart(void* data) override; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView& view, const DragEvent& event) override; - void OnSwipe(UISwipeView &view) override; - void WeatherInit(UIViewGroup *group); - void InitLabel(UIViewGroup *group, int count); - void InitImage(UIViewGroup *group, int count); - bool SetSwipeInter(); - void InitVecWeather(); -private: - WeatherModel *weatherModel = nullptr; - std::vector houWeather; - UISwipeView *weatherSwipeGroup = nullptr; - UIViewGroup *swipeGroup[SET_THREE]{nullptr}; - UIImageView *imgBack[SET_EIGHT]{nullptr}; - UILabel *labelTime[SET_EIGHT]{nullptr}; - UILabel *labelTemp[SET_EIGHT]{nullptr}; - UIImageView *imgWeather[SET_EIGHT]{nullptr}; - UIImageView *mainImg{nullptr}; - UIImageView *ImagePageKey{nullptr}; - int index = 0; // 记录当前是第几个swipe -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/weather/WeatherPageThird.h b/code/sdk/application/wearable/evb/nativeapp/nativeui/include/weather/WeatherPageThird.h deleted file mode 100644 index a7f72f9e7..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/include/weather/WeatherPageThird.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: WeatherPageThird - * Create: 2025-03-15 - */ - -#ifndef WEATHER_PAGETHIRD_H -#define WEATHER_PAGETHIRD_H - -#include "components/ui_image_view.h" -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "components/ui_list_nested.h" -#include "components/ui_scroll_view_nested.h" -#include "components/ui_swipe_view.h" -#include "main/AppGroupView.h" -#include "weather/WeatherPresenter.h" -#include "weather/WeatherAdapter.h" -#include "SlicePage.h" -#include "UiConfig.h" -namespace OHOS { -class WeatherPageThird : public SlicePage, - public UIView::OnClickListener, - public UIView::OnDragListener, - public UISwipeView::OnSwipeListener { -public: - WeatherPageThird(); - ~WeatherPageThird() override; - void OnStart(void* data) override; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView& view, const DragEvent& event) override; - void OnSwipe(UISwipeView &view) override; - void InitScrollView(); - bool InitScrollData(); - void RefreshWeathersList(const WeatherItem *item, uint8_t count); -private: - WeatherModel *weatherModel = nullptr; - UIViewGroup *group = nullptr; - UIList *contentList{nullptr}; - UILabel *title{nullptr}; - WeatherAdapter *listAdapter{nullptr}; - UIImageView *mainImg{nullptr}; - UIImageView *ImagePageKey{nullptr}; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/CustomizationView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/CustomizationView.cpp deleted file mode 100644 index 0546bb8c0..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/CustomizationView.cpp +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Customization View - * Create: 2022-03-02 - */ - -#include "indoorwalk/CustomizationView.h" -#include "indoorwalk/IndoorWalkPresenter.h" -#include "wearable_log.h" -#include "UiConfig.h" - -namespace OHOS { -static constexpr uint16_t VIEW_X = 52; -static constexpr uint16_t TIME_VIEW_Y = 155; -static constexpr uint16_t DISTANCES_VIEW_Y = 255; -static constexpr uint16_t HEART_VIEW_Y = 355; -static constexpr uint16_t SPEED_VIEW_Y = 455; -static constexpr uint16_t STEPS_VIEW_Y = 555; -static constexpr uint16_t VIEW_W = 350; -static constexpr uint16_t VIEW_H = 70; -static constexpr uint16_t RADIO_X = 280; -static constexpr uint16_t RADIO_Y = 0; -static constexpr uint16_t RADIO_W = 70; -static constexpr uint16_t RADIO_H = 70; - -static constexpr uint16_t LABLE_X = 152; -static constexpr uint16_t LABLE_Y = 50; -static constexpr uint16_t LABLE_W = 150; -static constexpr uint16_t LABLE_H = 60; -static CustomizationView *g_pCustomizationView{nullptr}; - -CustomizationView::CustomizationView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CustomizationView::CustomizationView"); - g_pCustomizationView = this; -} - -CustomizationView::~CustomizationView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CustomizationView::~CustomizationView"); - if (group != nullptr) { - group->RemoveAll(); - } - delete lable; - lable = nullptr; - delete timeView; - timeView = nullptr; - delete distancesView; - distancesView = nullptr; - delete heartView; - heartView = nullptr; - delete speedView; - speedView = nullptr; - delete stepsView; - stepsView = nullptr; - delete timeRadio; - timeRadio = nullptr; - delete distancesRadio; - distancesRadio = nullptr; - delete heartRadio; - heartRadio = nullptr; - delete speedRadio; - speedRadio = nullptr; - delete stepsRadio; - stepsRadio = nullptr; - delete timeButton; - timeButton = nullptr; - delete distancesButton; - distancesButton = nullptr; - delete heartButton; - heartButton = nullptr; - delete speedButton; - speedButton = nullptr; - delete stepsButton; - stepsButton = nullptr; - g_pCustomizationView = nullptr; -} - -CustomizationView *CustomizationView::GetInstance() -{ - return g_pCustomizationView; -} - -UIViewGroup *CustomizationView::GetTimeView(void) -{ - return timeView; -} - -UIViewGroup *CustomizationView::GetDistancesView(void) -{ - return distancesView; -} - -UIViewGroup *CustomizationView::GetHeartView(void) -{ - return heartView; -} - -UIViewGroup *CustomizationView::GetSpeedView(void) -{ - return speedView; -} - -UIViewGroup *CustomizationView::GetStepsView(void) -{ - return stepsView; -} - -UIRadioButton *CustomizationView::GetTimeRadio(void) -{ - return timeRadio; -} - -UIRadioButton *CustomizationView::GetDistancesRadio(void) -{ - return distancesRadio; -} - -UIRadioButton *CustomizationView::GetHeartRadio(void) -{ - return heartRadio; -} - -UIRadioButton *CustomizationView::GetSpeedRadio(void) -{ - return speedRadio; -} - -UIRadioButton *CustomizationView::GetStepsRadio(void) -{ - return stepsRadio; -} - -IndoorWalkUIScrollView *CustomizationView::GetCustomizationViewGroup() -{ - return group; -} - -bool CustomizationView::InitTimeView() -{ - timeView = new UIViewGroup; - if (timeView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "timeView new fail"); - return false; - } - timeView->SetPosition(VIEW_X, TIME_VIEW_Y, VIEW_W, VIEW_H); - timeButton = new UILabelButton; - if (timeButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "timeButton UILabelButton new fail"); - return false; - } - timeButton->SetPosition(0, 0, VIEW_W, VIEW_H); // 0 : X; 0 : Y - timeButton->SetImageSrc(PNG_WALK_TIME_IMAGE, PNG_WALK_TIME_IMAGE); - timeButton->SetText("时间"); - timeButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40 : font data - timeView->Add(timeButton); - timeRadio = new UIRadioButton("Customization"); - if (timeRadio == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "timeRadio UIRadio new fail"); - return false; - } - timeRadio->SetPosition(RADIO_X, RADIO_Y, RADIO_W, RADIO_H); - timeView->Add(timeRadio); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "InitPropertiesView::InitTimeView"); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::IndoorWalkPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance fail"); - return false; - } - timeView->SetOnClickListener(clickListener); - timeView->SetViewId(TIME_BUTTON); - timeView->SetDraggable(true); - timeView->SetTouchable(true); - return true; -} - -bool CustomizationView::InitDistancesView() -{ - distancesView = new UIViewGroup; - if (distancesView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "distancesView new fail"); - return false; - } - distancesView->SetPosition(VIEW_X, DISTANCES_VIEW_Y, VIEW_W, VIEW_H); - distancesButton = new UILabelButton; - if (distancesButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "distancesButton UILabelButton new fail"); - return false; - } - distancesButton->SetPosition(0, 0, VIEW_W, VIEW_H); // 0 : X; 0 : Y - distancesButton->SetImageSrc(PNG_WALK_DISTANCES_IMAGE, PNG_WALK_DISTANCES_IMAGE); - distancesButton->SetText("距离"); - distancesButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40 : font data - distancesView->Add(distancesButton); - distancesRadio = new UIRadioButton("Customization"); - if (distancesRadio == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "distancesRadio UIRadio new fail"); - return false; - } - distancesRadio->SetPosition(RADIO_X, RADIO_Y, RADIO_W, RADIO_H); - distancesView->Add(distancesRadio); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "InitPropertiesView::InitDistancesView"); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::IndoorWalkPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance fail"); - return false; - } - distancesView->SetOnClickListener(clickListener); - distancesView->SetViewId(DISTANCES_BUTTON); - distancesView->SetDraggable(true); - distancesView->SetTouchable(true); - return true; -} - -bool CustomizationView::InitHeartView() -{ - heartView = new UIViewGroup; - if (heartView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "heartView new fail"); - return false; - } - heartView->SetPosition(VIEW_X, HEART_VIEW_Y, VIEW_W, VIEW_H); - heartButton = new UILabelButton; - if (heartButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "heartButton UILabelButton new fail"); - return false; - } - heartButton->SetPosition(0, 0, VIEW_W, VIEW_H); // 0 : X; 0 : Y - heartButton->SetImageSrc(PNG_WALK_HEART_IMAGE, PNG_WALK_HEART_IMAGE); - heartButton->SetText("心率"); - heartButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40 : font data - heartView->Add(heartButton); - heartRadio = new UIRadioButton("Customization"); - if (heartRadio == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "heartRadio UIRadio new fail"); - return false; - } - heartRadio->SetPosition(RADIO_X, RADIO_Y, RADIO_W, RADIO_H); - heartView->Add(heartRadio); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "InitPropertiesView::InitHeartView"); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::IndoorWalkPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance fail"); - return false; - } - heartView->SetOnClickListener(clickListener); - heartView->SetViewId(HEART_BUTTON); - heartView->SetDraggable(true); - heartView->SetTouchable(true); - return true; -} - -bool CustomizationView::InitSpeedView() -{ - speedView = new UIViewGroup; - if (speedView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "speedView new fail"); - return false; - } - speedView->SetPosition(VIEW_X, SPEED_VIEW_Y, VIEW_W, VIEW_H); - speedButton = new UILabelButton; - if (speedButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "speedButton UILabelButton new fail"); - return false; - } - speedButton->SetPosition(0, 0, VIEW_W, VIEW_H); // 0 : X; 0 : Y - speedButton->SetImageSrc(PNG_WALK_SPEED_IMAGE, PNG_WALK_SPEED_IMAGE); - speedButton->SetText("速度"); - speedButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40 : font data - speedView->Add(speedButton); - speedRadio = new UIRadioButton("Customization"); - if (speedRadio == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "speedRadio UIRadio new fail"); - return false; - } - speedRadio->SetPosition(RADIO_X, RADIO_Y, RADIO_W, RADIO_H); - speedView->Add(speedRadio); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "InitPropertiesView::InitSpeedView"); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::IndoorWalkPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance fail"); - return false; - } - speedView->SetOnClickListener(clickListener); - speedView->SetViewId(SPEED_BUTTON); - speedView->SetDraggable(true); - speedView->SetTouchable(true); - return true; -} - -bool CustomizationView::InitStepsView() -{ - stepsView = new UIViewGroup; - if (stepsView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "stepsView new fail"); - return false; - } - stepsView->SetPosition(VIEW_X, STEPS_VIEW_Y, VIEW_W, VIEW_H); - stepsButton = new UILabelButton; - if (stepsButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "stepsButton UILabelButton new fail"); - return false; - } - stepsButton->SetPosition(0, 0, VIEW_W, VIEW_H); // 0 : X; 0 : Y - stepsButton->SetImageSrc(PNG_WALK_STEPS_IMAGE, PNG_WALK_STEPS_IMAGE); - stepsButton->SetText("步数"); - stepsButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40 : font data - stepsView->Add(stepsButton); - stepsRadio = new UIRadioButton("Customization"); - if (stepsRadio == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "stepsRadio UIRadio new fail"); - return false; - } - stepsRadio->SetPosition(RADIO_X, RADIO_Y, RADIO_W, RADIO_H); - stepsView->Add(stepsRadio); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "InitPropertiesView::InitStepsView"); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::IndoorWalkPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance fail"); - return false; - } - stepsView->SetOnClickListener(clickListener); - stepsView->SetViewId(STEPS_BUTTON); - stepsView->SetDraggable(true); - stepsView->SetTouchable(true); - return true; -} - -bool CustomizationView::ShowUpTitleLabel() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CustomizationView::ShowUpTitleLabel"); - lable = new UILabel(); - if (lable == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "lable new fail"); - return false; - } - lable->SetPosition(LABLE_X, LABLE_Y, LABLE_W, LABLE_H); - lable->SetText("自定义"); - lable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40 : font data - lable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - lable->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - return true; -} - -UIViewGroup *CustomizationView::InitPropertiesView() -{ - group = new IndoorWalkUIScrollView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); // 0 : X; 0 : Y - group->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - group->SetHorizontalScrollState(false); - - if ((!ShowUpTitleLabel()) || (!InitTimeView()) || (!InitDistancesView()) || - (!InitHeartView()) || (!InitSpeedView()) || (!InitStepsView())) { - return nullptr; - } - group->Add(lable); - group->Add(timeView); - group->Add(distancesView); - group->Add(heartView); - group->Add(speedView); - group->Add(stepsView); - - UIView::OnDragListener *dragListener = (UIView::OnDragListener *)OHOS::IndoorWalkPresenter::GetInstance(); - if (dragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dragListener GetInstance fail"); - return nullptr; - } - group->SetOnDragListener(dragListener); - group->SetScrollBlankSize(100); // 100 : blank size - group->SetViewId(CUSTOMIZATION_VIEW); - group->SetThrowDrag(true); - group->SetDraggable(true); - return group; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkEndView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkEndView.cpp deleted file mode 100644 index cbb22c343..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkEndView.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: IndoorWalk End View - * Create: 2022-03-02 - */ - -#include "indoorwalk/IndoorWalkEndView.h" -#include "indoorwalk/IndoorWalkPresenter.h" -#include "wearable_log.h" -#include "UiConfig.h" - -namespace OHOS { -static constexpr uint16_t LABELS_X = 75; -static constexpr uint16_t LABELS_Y = 150; -static constexpr uint16_t LABELS_W = 324; -static constexpr uint16_t LABELS_H = 160; -static constexpr uint16_t BUTTON_X1 = 85; -static constexpr uint16_t BUTTON_X2 = 279; -static constexpr uint16_t BUTTON_Y = 320; -static constexpr uint16_t BUTTON_W = 90; -static constexpr uint16_t BUTTON_H = 90; -static IndoorWalkEndView *g_pIndoorWalkEndView{nullptr}; - -IndoorWalkEndView::IndoorWalkEndView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkEndView::IndoorWalkEndView"); - g_pIndoorWalkEndView = this; -} - -IndoorWalkEndView::~IndoorWalkEndView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkEndView::~IndoorWalkEndView"); - if (group != nullptr) { - group->RemoveAll(); - } - delete titleLabel; - titleLabel = nullptr; - delete cancelButton; - cancelButton = nullptr; - delete confirmButton; - confirmButton = nullptr; - g_pIndoorWalkEndView = nullptr; -} - -IndoorWalkEndView *IndoorWalkEndView::GetInstance() -{ - return g_pIndoorWalkEndView; -} - -bool IndoorWalkEndView::ShowUpTitleLabel() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkEndView::ShowUpTitleLabel"); - titleLabel = new UILabel(); - if (titleLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "IndoorWalkEndView titleLabel new fail"); - return false; - } - titleLabel->SetPosition(LABELS_X, LABELS_Y, LABELS_W, LABELS_H); - titleLabel->SetText("是否结束运动?"); - titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 45); // 45 : font data - titleLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - titleLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - return true; -} - -bool IndoorWalkEndView::CreateUIButton() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkEndView::CreateUIButton"); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::IndoorWalkPresenter::GetInstance(); - cancelButton = new UIButton(); - if (cancelButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "IndoorWalkEndView cancelButton new fail"); - return false; - } - cancelButton->SetPosition(BUTTON_X1, BUTTON_Y, BUTTON_W, BUTTON_H); - cancelButton->SetViewId(INDOORWALK_CANCEL_BUTTON); - cancelButton->SetImageSrc(ALARM_DELETE_ADD_PATH, ALARM_DELETE_ADD_PATH); - cancelButton->SetOnClickListener(clickListener); - - confirmButton = new UIButton(); - if (confirmButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "IndoorWalkEndView confirmButton new fail"); - return false; - } - confirmButton->SetPosition(BUTTON_X2, BUTTON_Y, BUTTON_W, BUTTON_H); - confirmButton->SetViewId(INDOORWALK_CONFIRM_BUTTON); - confirmButton->SetImageSrc(ALARM_TRUE_ADD_PATH, ALARM_TRUE_ADD_PATH); - confirmButton->SetOnClickListener(clickListener); - return true; -} - -UIViewGroup *IndoorWalkEndView::InitShowUpView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkEndView InitShowUpView"); - bool ret; - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); // 0 : X; 0 : Y - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - ret = ShowUpTitleLabel(); - if (!ret) { - return nullptr; - } - group->Add(titleLabel); - ret = CreateUIButton(); - if (!ret) { - return nullptr; - } - group->Add(cancelButton); - group->Add(confirmButton); - UIView::OnDragListener *indoorWalkDragListener = (UIView::OnDragListener *)OHOS::IndoorWalkPresenter::GetInstance(); - if (indoorWalkDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "indoorWalkDragListener GetInstance fail"); - return nullptr; - } - group->SetOnDragListener(indoorWalkDragListener); - group->SetViewId(INDOORWALK_END_VIEW); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkModel.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkModel.cpp deleted file mode 100644 index 42786d830..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkModel.cpp +++ /dev/null @@ -1,338 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: IndoorWalk Model - * Create: 2022-03-02 - */ - -#include "indoorwalk/IndoorWalkModel.h" -#include "indoorwalk/IndoorWalkPresenter.h" -#include "ohos_timer.h" -#include "graphic_timer.h" - -namespace OHOS { -#define SENSOR_TYPE_TREADMILL_DISTANCE 0x10011 - -/* 跑步机距离 */ -typedef struct { - uint32_t distance_info; -} fa_treadmill_distance_result; - -static int g_motionTimes{0}; -GraphicTimer* g_startCounting = nullptr; // 定时器 -static constexpr uint64_t MS_ONE_SECONDS = 1000; -static constexpr uint16_t NUM_TEN = 10; -static constexpr uint16_t NUM_TIME_MIN = 60; -static constexpr uint16_t NUM_TIME_HOUR = 3600; -static constexpr int32_t NUM_TIME_DAY = 86400; -static constexpr uint16_t STEP_CHAR_NUM = 255; - -IndoorWalkModel::IndoorWalkModel() {} - -IndoorWalkModel::~IndoorWalkModel() {} - -IndoorWalkModel *IndoorWalkModel::GetInstance(void) -{ - static IndoorWalkModel instance; - return &instance; -} - -void IndoorWalkModel::SetConnectionView(const char* id) -{ - selectPropertiesID = id; -} - -std::string IndoorWalkModel::GetConnectionView() -{ - return selectPropertiesID; -} - -void IndoorWalkModel::SetTextLableFirstTop(const char *lable, const char *lableUnit) -{ - textLableFirstTop = lable; - textLableUnitFirstTop = lableUnit; -} - -std::string IndoorWalkModel::GetTextLableFirstTop() -{ - return textLableFirstTop; -} - -std::string IndoorWalkModel::GetTextLableUnitFirstTop() -{ - return textLableUnitFirstTop; -} - -void IndoorWalkModel::SetTextLableFirstLeft(const char *lable, const char *lableUnit) -{ - textLableFirstLeft = lable; - textLableUnitFirstLeft = lableUnit; -} - -std::string IndoorWalkModel::GetTextLableFirstLeft() -{ - return textLableFirstLeft; -} - -std::string IndoorWalkModel::GetTextLableUnitFirstLeft() -{ - return textLableUnitFirstLeft; -} - -void IndoorWalkModel::SetTextLableFirstRight(const char *lable, const char *lableUnit) -{ - textLableFirstRight = lable; - textLableUnitFirstRight = lableUnit; -} - -std::string IndoorWalkModel::GetTextLableFirstRight() -{ - return textLableFirstRight; -} - -std::string IndoorWalkModel::GetTextLableUnitFirstRight() -{ - return textLableUnitFirstRight; -} - -void IndoorWalkModel::SetTextLableFirstBottom(const char *lable, const char *lableUnit) -{ - textLableFirstBottom = lable; - textLableUnitFirstBottom = lableUnit; -} - -std::string IndoorWalkModel::GetTextLableFirstBottom() -{ - return textLableFirstBottom; -} - -std::string IndoorWalkModel::GetTextLableUnitFirstBottom() -{ - return textLableUnitFirstBottom; -} - -void IndoorWalkModel::SetTextLableSecondTop(const char *lable, const char *lableUnit) -{ - textLableSecondTop = lable; - textLableUnitSecondTop = lableUnit; -} - -std::string IndoorWalkModel::GetTextLableSecondTop() -{ - return textLableSecondTop; -} - -std::string IndoorWalkModel::GetTextLableUnitSecondTop() -{ - return textLableUnitSecondTop; -} - -void IndoorWalkModel::SetTextLableSecondLeft(const char *lable, const char *lableUnit) -{ - textLableSecondLeft = lable; - textLableUnitSecondLeft = lableUnit; -} - -std::string IndoorWalkModel::GetTextLableSecondLeft() -{ - return textLableSecondLeft; -} - -std::string IndoorWalkModel::GetTextLableUnitSecondLeft() -{ - return textLableUnitSecondLeft; -} - -void IndoorWalkModel::SetTextLableSecondRight(const char *lable, const char *lableUnit) -{ - textLableSecondRight = lable; - textLableUnitSecondRight = lableUnit; -} - -std::string IndoorWalkModel::GetTextLableSecondRight() -{ - return textLableSecondRight; -} - -std::string IndoorWalkModel::GetTextLableUnitSecondRight() -{ - return textLableUnitSecondRight; -} - -void IndoorWalkModel::SetTextLableThirdTop(const char *lable, const char *lableUnit) -{ - textLableThirdTop = lable; - textLableUnitThirdTop = lableUnit; -} - -std::string IndoorWalkModel::GetTextLableThirdTop() -{ - return textLableThirdTop; -} - -std::string IndoorWalkModel::GetTextLableUnitThirdTop() -{ - return textLableUnitThirdTop; -} - -void IndoorWalkModel::SetTextLableThirdBottom(const char *lable, const char *lableUnit) -{ - textLableThirdBottom = lable; - textLableUnitThirdBottom = lableUnit; -} - -std::string IndoorWalkModel::GetTextLableThirdBottom() -{ - return textLableThirdBottom; -} - -std::string IndoorWalkModel::GetTextLableUnitThirdBottom() -{ - return textLableUnitThirdBottom; -} - -void IndoorWalkModel::SetTextLableFourth(const char *lable, const char *lableUnit) -{ - textLableFourth = lable; - textLableUnitFourth = lableUnit; -} - -std::string IndoorWalkModel::GetTextLableFourth() -{ - return textLableFourth; -} - -std::string IndoorWalkModel::GetTextLableUnitFourth() -{ - return textLableUnitFourth; -} - -void IndoorWalkModel::SetInitialStep(const uint32_t &value) -{ - initialStep = value; -} - -int IndoorWalkModel::GetInitialStep() -{ - return initialStep; -} - -void IndoorWalkModel::SetInitialDistances(const float &value) -{ - initialDistances = value; -} - -float IndoorWalkModel::GetInitialDistances() -{ - return initialDistances; -} - -void IndoorWalkModel::SetCurrentDistances(const float &value) -{ - currentDistances = value; -} - -float IndoorWalkModel::GetCurrentDistances() -{ - return currentDistances; -} - -/* 时间显示 */ -std::string& IndoorWalkModel::DisplayMotionDuration() -{ - motionDuration.erase(); - std::string hours; - std::string minute; - std::string seconds; - if (g_motionTimes >= NUM_TIME_DAY) { - g_motionTimes = 0; - } - int hour = g_motionTimes / NUM_TIME_HOUR; - int min = (g_motionTimes % NUM_TIME_HOUR) / NUM_TIME_MIN; - int sec = (g_motionTimes % NUM_TIME_HOUR) % NUM_TIME_MIN; - if (hour >= 0 && hour < NUM_TEN) { - hours = "0" + std::to_string(hour); - } else { - hours = std::to_string(hour); - } - if (min >= 0 && min < NUM_TEN) { - minute = "0" + std::to_string(min); - } else { - minute = std::to_string(min); - } - if (sec >= 0 && sec < NUM_TEN) { - seconds = "0" + std::to_string(sec); - } else { - seconds = std::to_string(sec); - } - - motionDuration = hours + ":" + minute + ":" + seconds; - return motionDuration; -} - -#ifdef __cplusplus -extern "C" { -#endif - -/* 定时器回调函数 */ -void IndoorWalkTimerCallback(void* data) -{ - (void)data; - g_motionTimes++; - IndoorWalkPresenter *indoorWalkPresenter = IndoorWalkPresenter::GetInstance(); - if (indoorWalkPresenter == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "IndoorWalkTimerCallback::indoorWalkPresenter new fail"); - return; - } - indoorWalkPresenter->ModifiesTime(); -} - -/* 开启定时器 */ -void InitIndoorWalkTimer() -{ - if (g_startCounting != nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkModel::IndoorWalkTimer already exists!!"); - return; - } - uint32_t tick = GetOSTick(MS_ONE_SECONDS); - g_startCounting = new GraphicTimer(tick, IndoorWalkTimerCallback, nullptr, true); - if (g_startCounting == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "IndoorWalkModel::IndoorWalkTimer new GraphicTimer failed!!"); - return; - } - bool retTimer = g_startCounting->Start(); - if (!retTimer) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "IndoorWalkModel::IndoorWalkTimer Start failed!!"); - if (g_startCounting != nullptr) { - delete g_startCounting; - g_startCounting = nullptr; - } - return; - } -} -/* 关闭定时器 */ -void DisableIndoorWalkTimer() -{ - if (g_startCounting != nullptr) { - delete g_startCounting; - g_startCounting = nullptr; - g_motionTimes = 0; - } -} - - -#ifdef __cplusplus -} -#endif - -// 打开传感器 -bool IndoorWalkModel::OpenDistancesSensor(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkModel::OpenDistancesSensor!!"); - return true; -} - -bool IndoorWalkModel::CloseDistancesSensor(void) -{ - return true; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkMotionView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkMotionView.cpp deleted file mode 100644 index 4e88d67e0..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkMotionView.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: IndoorWalk Motion View - * Create: 2022-03-02 - */ - -#include "indoorwalk/IndoorWalkMotionView.h" -#include "indoorwalk/IndoorWalkPresenter.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "screensetting/ScreenModels.h" -#include "activity/ActivityModel.h" -#include "indoorwalk/IndoorWalkModel.h" -#include - -namespace OHOS { -static IndoorWalkMotionView *g_pIndoorWalkMotionView{nullptr}; - -struct WalkMotionViewMapper { - MotionPageId id; - AppGroupView *(IndoorWalkMotionView::*func)(void); -}; - -static const WalkMotionViewMapper g_pageMapper[] = { - {MOTION_FIRST, &IndoorWalkMotionView::InitMotionPageFirst}, - {MOTION_SECOND, &IndoorWalkMotionView::InitMotionPageSecond}, - {MOTION_THIRD, &IndoorWalkMotionView::InitMotionPageThird}, - {MOTION_FOURTH, &IndoorWalkMotionView::InitMotionPageFourth}, - {MOTION_FIFTH, &IndoorWalkMotionView::InitMotionPageFifth}, -}; - -IndoorWalkMotionView::IndoorWalkMotionView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkMotionView::IndoorWalkMotionView"); - InitIndoorWalkTimer(); - IndoorWalkModel::GetInstance()->OpenDistancesSensor(); - g_pIndoorWalkMotionView = this; -} - -IndoorWalkMotionView::~IndoorWalkMotionView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkMotionView::~IndoorWalkMotionView"); - for (int32_t i = 0; i < maxPage; i++) { - recordCard[i] = nullptr; - } - delete walkMotionList; - walkMotionList = nullptr; - delete motionPageFirst; - motionPageFirst = nullptr; - delete motionPageSecond; - motionPageSecond = nullptr; - delete motionPageThird; - motionPageThird = nullptr; - delete motionPageFourth; - motionPageFourth = nullptr; - delete motionPageFifth; - motionPageFifth = nullptr; - g_pIndoorWalkMotionView = nullptr; -} - -IndoorWalkMotionView *IndoorWalkMotionView::GetInstance() -{ - return g_pIndoorWalkMotionView; -} - -AppGroupView *IndoorWalkMotionView::InitMotionPageFirst(void) -{ - motionPageFirst = new MotionPageFirst(); - if (motionPageFirst == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "motionPageFirst new fail"); - return nullptr; - } - return motionPageFirst; -} - -AppGroupView *IndoorWalkMotionView::InitMotionPageSecond(void) -{ - motionPageSecond = new MotionPageSecond(); - if (motionPageSecond == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "motionPageSecond new fail"); - return nullptr; - } - return motionPageSecond; -} - -AppGroupView *IndoorWalkMotionView::InitMotionPageThird(void) -{ - motionPageThird = new MotionPageThird(); - if (motionPageThird == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "motionPageThird new fail"); - return nullptr; - } - return motionPageThird; -} - -AppGroupView *IndoorWalkMotionView::InitMotionPageFourth(void) -{ - motionPageFourth = new MotionPageFourth(); - if (motionPageFourth == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "motionPageFourth new fail"); - return nullptr; - } - return motionPageFourth; -} - -AppGroupView *IndoorWalkMotionView::InitMotionPageFifth(void) -{ - motionPageFifth = new MotionPageFifth(); - if (motionPageFifth == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "motionPageFifth new fail"); - return nullptr; - } - return motionPageFifth; -} - -UIViewGroup *IndoorWalkMotionView::WalkMotionViewInit(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkMotionView::WalkMotionViewInit"); - walkMotionList = new UISwipeView(UISwipeView::VERTICAL); - if (walkMotionList == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "walkMotionList new fail"); - return nullptr; - } - walkMotionList->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - walkMotionList->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); // 0 : X; 0 : Y - walkMotionList->SetLoopState(true); - walkMotionList->SetAnimatorTime(50); // 50:animator drag time(ms) - - for (uint16_t i = 0; i < maxPage; i++) { - recordCard[i] = (this->*(g_pageMapper[i].func))(); - if (recordCard[i] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "IndoorWalkMotionView:: recordCard %d error", i); - return nullptr; - } - recordCard[i]->InitView(this); - walkMotionList->Add(recordCard[i]); - } - UIView::OnDragListener *motionDragListener = (UIView::OnDragListener *)OHOS::IndoorWalkPresenter::GetInstance(); - if (motionDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "motionDragListener GetInstance fail"); - return nullptr; - } - UIView::OnClickListener *motionClickListener = (UIView::OnClickListener *)OHOS::IndoorWalkPresenter::GetInstance(); - if (motionClickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "motionClickListener GetInstance fail"); - return nullptr; - } - UISwipeView::OnSwipeListener *motionSwipeListener = (UISwipeView::OnSwipeListener *)OHOS::IndoorWalkPresenter::GetInstance(); - if (motionSwipeListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "motionSwipeListener GetInstance fail"); - return nullptr; - } - walkMotionList->SetOnSwipeListener(motionSwipeListener); - walkMotionList->SetOnClickListener(motionClickListener); - walkMotionList->SetOnDragListener(motionDragListener); - walkMotionList->SetViewId(INDOORWALK_MOTION_VIEW); - walkMotionList->SetDraggable(true); - walkMotionList->SetTouchable(true); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkMotionView::InitPage over"); - IndoorWalkModel::GetInstance()->SetInitialDistances(IndoorWalkModel::GetInstance()->GetCurrentDistances()); - InitialStep(); - return walkMotionList; -} - -void IndoorWalkMotionView::InitialStep() -{ - uint32_t stepValue; - int weekToday = ActivityModel::GetInstance()->GetWeekToday(); - ActivityModel::GetInstance()->GetStepData((StepDataDistribute)weekToday, &stepValue); - IndoorWalkModel::GetInstance()->SetInitialStep(stepValue); -} - -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkPreparedView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkPreparedView.cpp deleted file mode 100644 index 709ab2845..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkPreparedView.cpp +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: IndoorWalk Prepared View - * Create: 2022-03-02 - */ - -#include "indoorwalk/IndoorWalkPreparedView.h" -#include "indoorwalk/IndoorWalkPresenter.h" -#include "screensetting/ScreenModels.h" -#include "ui_resource_image.h" -#include "wearable_log.h" -#include "UiConfig.h" - -namespace OHOS { -static IndoorWalkPreparedView *g_pIndoorWalkPreparedView{nullptr}; - -static constexpr uint16_t HEARTBEAT_IMAGE_WIDTH = 92; -static constexpr uint16_t HEARTBEAT_IMAGE_HEIGHT = 92; -static constexpr uint16_t HEARTBEAT_IMAGE_X = 333; -static constexpr uint16_t HEARTBEAT_IMAGE_Y = 170; -static constexpr uint16_t HEARTBEAT_IMAGE_NUM = 19; -static constexpr uint16_t HEARTBEAT_DELAY = 50; - -static constexpr uint16_t BATTERY_X = 175; -static constexpr uint16_t BATTERY_Y = 84; -static constexpr uint16_t BATTERY_LABEL_X = 232; -static constexpr uint16_t BATTERY_LABEL_Y = 75; -static constexpr uint16_t BATTERY_LABEL_W = 86; -static constexpr uint16_t BATTERY_LABEL_H = 30; - -static constexpr uint16_t HEARTBEAT_LABEL_X = 363; -static constexpr uint16_t HEARTBEAT_LABEL_Y = 241; -static constexpr uint16_t HEARTBEAT_LABEL_W = 86; -static constexpr uint16_t HEARTBEAT_LABEL_H = 30; - -static constexpr uint16_t TIME_LABEL_X = 177; -static constexpr uint16_t TIME_LABEL_Y = 36; -static constexpr uint16_t TIME_LABEL_W = 100; -static constexpr uint16_t TIME_LABEL_H = 30; - -static constexpr uint16_t TITLE_LABEL_X = 127; -static constexpr uint16_t TITLE_LABEL_Y = 348; -static constexpr uint16_t TITLE_LABEL_W = 200; -static constexpr uint16_t TITLE_LABEL_H = 80; - -static constexpr uint16_t WALK_BUTTON_X = 138; -static constexpr uint16_t WALK_BUTTON_Y = 136; -static constexpr uint16_t WALK_BUTTON_W = 180; -static constexpr uint16_t WALK_BUTTON_H = 180; -static constexpr uint16_t STEP_CHAR_NUM = 255; - -// 心跳image -static ImageAnimatorInfo g_heartBeatImageInfo[HEARTBEAT_IMAGE_NUM] = { - {PNG_A004_070_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_071_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_072_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_073_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_074_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_075_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_076_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_077_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_078_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_079_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - - {PNG_A004_080_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_081_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_082_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_083_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_084_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_085_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_086_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_087_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, - {PNG_A004_088_IMAGE_PATH, {HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y}, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT, - IMG_SRC_FILE_PATH}, -}; - - -IndoorWalkPreparedView::IndoorWalkPreparedView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkPreparedView::IndoorWalkPreparedView"); - g_pIndoorWalkPreparedView = this; -} - -IndoorWalkPreparedView::~IndoorWalkPreparedView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkPreparedView::~IndoorWalkPreparedView"); - if (group != nullptr) { - group->RemoveAll(); - } - delete walkButton; - walkButton = nullptr; - delete titleLabel; - titleLabel = nullptr; - delete battery; - battery = nullptr; - delete batteryLable; - batteryLable = nullptr; - delete imageAnimator; - imageAnimator = nullptr; - delete heartRateLabel; - heartRateLabel = nullptr; - delete timeLabel; - timeLabel = nullptr; - g_pIndoorWalkPreparedView = nullptr; -} - -IndoorWalkPreparedView *IndoorWalkPreparedView::GetInstance() -{ - return g_pIndoorWalkPreparedView; -} - -bool IndoorWalkPreparedView::InitBatteryView() // 加载电量 -{ - battery = new UIImageView(); // 电量状态显示 - if (battery == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "battery new fail"); - return false; - } - battery->SetPosition(BATTERY_X, BATTERY_Y); - ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, battery, DROPDOWN_DROPDOWN_BATTERY); - group->Add(battery); - - batteryLable = new UILabel(); - if (batteryLable == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryLable new fail"); - return false; - } - batteryLable->SetPosition(BATTERY_LABEL_X, BATTERY_LABEL_Y, BATTERY_LABEL_W, BATTERY_LABEL_H); - batteryLable->SetText("--%"); - batteryLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); // 30 : font data - batteryLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - group->Add(batteryLable); - return true; -} - -bool IndoorWalkPreparedView::InitHeartbeatView() // 加载心跳 -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkPreparedView::InitHeartbeatView start"); - imageAnimator = new UIImageAnimatorView(); - if (imageAnimator == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "IndoorWalkPreparedView::InitHeartbeatView new imageAnimator fail"); - return false; - } - imageAnimator->SetPosition(HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y, HEARTBEAT_IMAGE_WIDTH, HEARTBEAT_IMAGE_HEIGHT); - imageAnimator->SetImageAnimatorSrc(g_heartBeatImageInfo, HEARTBEAT_IMAGE_NUM, HEARTBEAT_DELAY); - imageAnimator->SetRepeat(true); - group->Add(imageAnimator); - - heartRateLabel = new UILabel(); - if (heartRateLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "heartRateLabel new fail"); - return false; - } - heartRateLabel->SetPosition(HEARTBEAT_LABEL_X, HEARTBEAT_LABEL_Y, HEARTBEAT_LABEL_W, HEARTBEAT_LABEL_H); - heartRateLabel->SetText("--"); - heartRateLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); // 30 : font data - heartRateLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - group->Add(heartRateLabel); - return true; -} - -void IndoorWalkPreparedView::IndoorWalkHeartbeatStart(void) -{ - imageAnimator->Start(); -} - -void IndoorWalkPreparedView::IndoorWalkHeartbeatStop(void) -{ - imageAnimator->Stop(); -} - -bool IndoorWalkPreparedView::InitLableVIew() // 加载文本 -{ - timeLabel = new UILabel(); - if (timeLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "timeLabel new fail"); - return false; - } - timeLabel->SetPosition(TIME_LABEL_X, TIME_LABEL_Y, TIME_LABEL_W, TIME_LABEL_H); - timeLabel->SetText("--:--"); - timeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); // 30 : font data - timeLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - timeLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - group->Add(timeLabel); - - titleLabel = new UILabel(); - if (titleLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "titleLabel new fail"); - return false; - } - titleLabel->SetPosition(TITLE_LABEL_X, TITLE_LABEL_Y, TITLE_LABEL_W, TITLE_LABEL_H); - titleLabel->SetText(" 准备就绪 单击下键开始运动"); - titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 25); // 25 : font data - titleLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - titleLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - group->Add(titleLabel); - return true; -} - - -UIViewGroup *IndoorWalkPreparedView::InitShowUpView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkPreparedView InitShowUpView"); - bool ret; - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); // 0 : X; 0 : Y - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - - walkButton = new UIButton(); // 步行状态显示 - if (walkButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "walkButton new fail"); - return nullptr; - } - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::IndoorWalkPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance fail"); - return nullptr; - } - walkButton->SetPosition(WALK_BUTTON_X, WALK_BUTTON_Y, WALK_BUTTON_W, WALK_BUTTON_H); - walkButton->SetImageSrc(PNG_WALK_IMAGE, PNG_WALK_IMAGE); - walkButton->SetOnClickListener(clickListener); - walkButton->SetViewId(WALK_BUTTON); - group->Add(walkButton); - ret = InitBatteryView(); - if (!ret) { - return nullptr; - } - ret = InitHeartbeatView(); - if (!ret) { - return nullptr; - } - ret = InitLableVIew(); - if (!ret) { - return nullptr; - } - UIView::OnDragListener *indoorWalkDragListener = (UIView::OnDragListener *)OHOS::IndoorWalkPresenter::GetInstance(); - if (indoorWalkDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "indoorWalkDragListener GetInstance fail"); - return nullptr; - } - group->SetOnDragListener(indoorWalkDragListener); - group->SetViewId(INDOORWALK_PREPARED_VIEW); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} - -void IndoorWalkPreparedView::RefreshHeartbeatData(int value) -{ - char heartRateChar[STEP_CHAR_NUM] = {0}; - - (void)sprintf_s(heartRateChar, STEP_CHAR_NUM, "%d", value); - if (heartRateLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RefreshHeartbeatData heartRateLabel nullptr"); - return; - } - heartRateLabel->SetText(heartRateChar); -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkPresenter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkPresenter.cpp deleted file mode 100644 index fcffcc433..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkPresenter.cpp +++ /dev/null @@ -1,842 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: IndoorWalk Presenter - * Create: 2022-03-02 - */ - -#include "indoorwalk/IndoorWalkPresenter.h" -#include "indoorwalk/IndoorWalkView.h" -#include "indoorwalk/IndoorWalkModel.h" -#include "drag_event.h" -#include "UiConfig.h" -#include "wearable_log.h" -#include -#include "activity/ActivityModel.h" -#include "NativeRegisterManager.h" - -namespace OHOS { - -REGIST_MENU(VIEW_INDOORWALK, IndoorWalkView, IndoorWalkPresenter, PNG_APPLIST_WALK_IMAGE, PNG_APPLIST_DEFAULT_IMG, "室内步行"); - -static IndoorWalkPresenter *g_pIndoorWalkPresenter = nullptr; -static std::string g_distancesChar; -static constexpr uint16_t CENTERED_Y = 192; -static constexpr uint32_t CONVERSION_NUM = 100000; -static constexpr uint16_t STEP_CHAR_NUM = 255; - -struct IndoorWalkGetViewMapper { - const char *viewId; - void (IndoorWalkPresenter::*Getfunc)(const char* id); -}; - -static const IndoorWalkGetViewMapper g_pWalkGetViewMapper[] = { - {IMAGE_FIRST_TOP, &IndoorWalkPresenter::ImageOnClick}, - {IMAGE_FIRST_LEFT, &IndoorWalkPresenter::ImageOnClick}, - {IMAGE_FIRST_RIGHT, &IndoorWalkPresenter::ImageOnClick}, - {IMAGE_FIRST_BOTTOM, &IndoorWalkPresenter::ImageOnClick}, - {IMAGE_SECOND_TOP, &IndoorWalkPresenter::ImageOnClick}, - {IMAGE_SECOND_LEFT, &IndoorWalkPresenter::ImageOnClick}, - {IMAGE_SECOND_RIGHT, &IndoorWalkPresenter::ImageOnClick}, - {IMAGE_THIRD_TOP, &IndoorWalkPresenter::ImageOnClick}, - {IMAGE_THIRD_BOTTOM, &IndoorWalkPresenter::ImageOnClick}, - {IMAGE_FOURTH, &IndoorWalkPresenter::ImageOnClick}, - {INDOORWALK_CANCEL_BUTTON, &IndoorWalkPresenter::CancelButtonOnClick}, - {INDOORWALK_CONFIRM_BUTTON, &IndoorWalkPresenter::ConfirmButtonOnClick}, - {WALK_BUTTON, &IndoorWalkPresenter::WalkButtonOnClick}, - {TIME_BUTTON, &IndoorWalkPresenter::TimeViewOnClick}, - {DISTANCES_BUTTON, &IndoorWalkPresenter::DistancesViewOnClick}, - {HEART_BUTTON, &IndoorWalkPresenter::HeartViewOnClick}, - {SPEED_BUTTON, &IndoorWalkPresenter::SpeedViewOnClick}, - {STEPS_BUTTON, &IndoorWalkPresenter::StepsViewOnClick}, -}; - -void IndoorWalkPresenter::ImageOnClick(const char* id) -{ - if (id == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ImageOnClick id nullptr"); - return; - } - IndoorWalkModel::GetInstance()->SetConnectionView(id); - IndoorWalkView::GetInstance()->ChangeView(INDOORWALKMOTIONVIEW, CUSTOMIZATIONVIEW); - SetPropertiesState(id); -} - -void IndoorWalkPresenter::CancelButtonOnClick(const char* id) -{ - UNUSED(id); - IndoorWalkView::GetInstance()->ChangeView(INDOORWALKENDVIEW, INDOORWALKMOTIONVIEW); -} - -void IndoorWalkPresenter::ConfirmButtonOnClick(const char* id) -{ - UNUSED(id); - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); -} - -void IndoorWalkPresenter::WalkButtonOnClick(const char* id) -{ - UNUSED(id); - IndoorWalkView::GetInstance()->ChangeView(INDOORWALKPREPAREDVIEW, INDOORWALKMOTIONVIEW); -} - -void IndoorWalkPresenter::TimeViewOnClick(const char* id) -{ - UNUSED(id); - std::string selectPropertiesid = IndoorWalkModel::GetInstance()->GetConnectionView(); - std::string duration = IndoorWalkModel::GetInstance()->DisplayMotionDuration(); - ModifiesProperties(selectPropertiesid.c_str(), duration.c_str(), "时间"); -} - -void IndoorWalkPresenter::DistancesViewOnClick(const char* id) -{ - UNUSED(id); - std::string selectPropertiesid = IndoorWalkModel::GetInstance()->GetConnectionView(); - ModifiesProperties(selectPropertiesid.c_str(), "0.00", "距离(km)"); -} - -void IndoorWalkPresenter::HeartViewOnClick(const char* id) -{ - UNUSED(id); - std::string selectPropertiesid = IndoorWalkModel::GetInstance()->GetConnectionView(); - ModifiesProperties(selectPropertiesid.c_str(), "--", "心率(bpm)"); -} - -void IndoorWalkPresenter::SpeedViewOnClick(const char* id) -{ - UNUSED(id); - std::string selectPropertiesid = IndoorWalkModel::GetInstance()->GetConnectionView(); - ModifiesProperties(selectPropertiesid.c_str(), "0.00", "速度(km/h)"); -} - -void IndoorWalkPresenter::StepsViewOnClick(const char* id) -{ - UNUSED(id); - std::string selectPropertiesid = IndoorWalkModel::GetInstance()->GetConnectionView(); - char stepChar[STEP_CHAR_NUM] = {0}; - InitStepsValue(stepChar); - ModifiesProperties(selectPropertiesid.c_str(), stepChar, "步数(steps)"); -} - -void IndoorWalkPresenter::ClickFunc(const char *buttonId) -{ - if (buttonId == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClickFunc buttonId nullptr"); - return; - } - unsigned int mapperSize = sizeof(g_pWalkGetViewMapper) / sizeof(g_pWalkGetViewMapper[0]); - for (unsigned int i = 0; i < mapperSize; i++) { - if (strcmp(buttonId, g_pWalkGetViewMapper[i].viewId) == 0) { - (this->*(g_pWalkGetViewMapper[i].Getfunc))(buttonId); - return; - } - } - HidePageImageView(); -} - -IndoorWalkPresenter::IndoorWalkPresenter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkPresenter::IndoorWalkPresenter"); - g_pIndoorWalkPresenter = this; -} - -IndoorWalkPresenter::~IndoorWalkPresenter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkPresenter::~IndoorWalkPresenter"); - g_pIndoorWalkPresenter = nullptr; -} - -IndoorWalkPresenter *IndoorWalkPresenter::GetInstance() -{ - return g_pIndoorWalkPresenter; -} - -void IndoorWalkPresenter::OnSwipe(UISwipeView &view) -{ - UNUSED(view); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkPresenter::OnSwipe"); - HidePageImageView(); - return; -} - -bool IndoorWalkPresenter::OnClick(UIView& view, const ClickEvent& event) -{ - UNUSED(event); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "%s OnClick", view.GetViewId()); - ClickFunc(view.GetViewId()); - return true; -} - -void IndoorWalkPresenter::InitStepsValue(char *steps) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkPresenter::InitStepsValue"); - uint32_t stepValue; - int weekToday = ActivityModel::GetInstance()->GetWeekToday(); - ActivityModel::GetInstance()->GetStepData((StepDataDistribute)weekToday, &stepValue); - std::ostringstream ostrHour; - ostrHour << stepValue - IndoorWalkModel::GetInstance()->GetInitialStep(); - std::string weekStr = ostrHour.str(); - uint32_t ret = memcpy_s(steps, STEP_CHAR_NUM, weekStr.c_str(), weekStr.length()); - if (ret != EOK) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SaveStepToFile memcpy_s fail. ret=%d", ret); - return; - } -} - -void IndoorWalkPresenter::HidePageImageView() -{ - MotionPageFirst *motionPageFirst = MotionPageFirst::GetInstance(); - if (motionPageFirst == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HidePageImageView:motionPageFirst new fail"); - return; - } - motionPageFirst->HideInitPageFirstImageView(); - MotionPageSecond *motionPageSecond = MotionPageSecond::GetInstance(); - if (motionPageSecond == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HidePageImageView:motionPageSecond new fail"); - return; - } - motionPageSecond->HideInitPageSecondImageView(); - MotionPageThird *motionPageThird = MotionPageThird::GetInstance(); - if (motionPageThird == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HidePageImageView:motionPageThird new fail"); - return; - } - motionPageThird->HideInitPageThirdImageView(); - MotionPageFourth *motionPageFourth = MotionPageFourth::GetInstance(); - if (motionPageFourth == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HidePageImageView:motionPageFourth new fail"); - return; - } - motionPageFourth->HideInitPageFourthImageView(); -} - -struct IndoorWalkDragMapper { - const char *viewId; - void (IndoorWalkPresenter::*Getfunc)(); -}; - -static const IndoorWalkDragMapper g_pWalkDragMapper[] = { - {INDOORWALK_PREPARED_VIEW, &IndoorWalkPresenter::DragIndoorWalkPreparedView}, - {INDOORWALK_MOTION_VIEW, &IndoorWalkPresenter::DragIndoorWalkMotionView}, - {INDOORWALK_END_VIEW, &IndoorWalkPresenter::DragIndoorWalkEndView}, - {CUSTOMIZATION_VIEW, &IndoorWalkPresenter::DragCustomizationView}, -}; - -void IndoorWalkPresenter::DragIndoorWalkPreparedView() -{ - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); -} - -void IndoorWalkPresenter::DragIndoorWalkMotionView() -{ - IndoorWalkView::GetInstance()->ChangeView(INDOORWALKMOTIONVIEW, INDOORWALKENDVIEW); -} - -void IndoorWalkPresenter::DragIndoorWalkEndView() -{ - IndoorWalkView::GetInstance()->ChangeView(INDOORWALKENDVIEW, INDOORWALKMOTIONVIEW); -} - -void IndoorWalkPresenter::DragCustomizationView() -{ - IndoorWalkView::GetInstance()->ChangeView(CUSTOMIZATIONVIEW, INDOORWALKMOTIONVIEW); -} - -void IndoorWalkPresenter::DragFunc(const char *buttonId) -{ - if (buttonId == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DragFunc nullptr"); - return; - } - unsigned int mapperSize = sizeof(g_pWalkDragMapper) / sizeof(g_pWalkDragMapper[0]); - for (unsigned int i = 0; i < mapperSize; i++) { - if (strcmp(buttonId, g_pWalkDragMapper[i].viewId) == 0) { - (this->*(g_pWalkDragMapper[i].Getfunc))(); - return; - } - } -} - -bool IndoorWalkPresenter::OnDrag(UIView& view, const DragEvent& event) -{ - HidePageImageView(); - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { - DragFunc(view.GetViewId()); - } - return true; -} - -struct IndoorWalkLongPressMapper { - const char *viewId; - void (IndoorWalkPresenter::*Getfunc)(); -}; - -static const IndoorWalkLongPressMapper g_pWalkLongPressMapper[] = { - {LABLE_FIRST_TOP, &IndoorWalkPresenter::LongPressPageFirst}, - {LABLE_FIRST_LEFT, &IndoorWalkPresenter::LongPressPageFirst}, - {LABLE_FIRST_RIGHT, &IndoorWalkPresenter::LongPressPageFirst}, - {LABLE_FIRST_BOTTOM, &IndoorWalkPresenter::LongPressPageFirst}, - {LABLE_SECOND_TOP, &IndoorWalkPresenter::LongPressPageSecond}, - {LABLE_SECOND_LEFT, &IndoorWalkPresenter::LongPressPageSecond}, - {LABLE_SECOND_RIGHT, &IndoorWalkPresenter::LongPressPageSecond}, - {LABLE_THIRD_TOP, &IndoorWalkPresenter::LongPressPageThird}, - {LABLE_THIRD_BOTTOM, &IndoorWalkPresenter::LongPressPageThird}, - {LABLE_FOURTH, &IndoorWalkPresenter::LongPressPageFourth}, -}; - -void IndoorWalkPresenter::LongPressPageFirst() -{ - MotionPageFirst *motionPageFirst = MotionPageFirst::GetInstance(); - if (motionPageFirst == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnLongPress:motionPageFirst new fail"); - return; - } - motionPageFirst->ShowInitPageFirstImageView(); -} - -void IndoorWalkPresenter::LongPressPageSecond() -{ - MotionPageSecond *motionPageSecond = MotionPageSecond::GetInstance(); - if (motionPageSecond == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnLongPress:motionPageSecond new fail"); - return; - } - motionPageSecond->ShowInitPageSecondImageView(); -} - -void IndoorWalkPresenter::LongPressPageThird() -{ - MotionPageThird *motionPageThird = MotionPageThird::GetInstance(); - if (motionPageThird == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnLongPress:motionPageThird new fail"); - return; - } - motionPageThird->ShowInitPageThirdImageView(); -} - -void IndoorWalkPresenter::LongPressPageFourth() -{ - MotionPageFourth *motionPageFourth = MotionPageFourth::GetInstance(); - if (motionPageFourth == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnLongPress:motionPageFourth new fail"); - return; - } - motionPageFourth->ShowInitPageFourthImageView(); -} - -void IndoorWalkPresenter::LongPressFunc(const char *buttonId) -{ - if (buttonId == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LongPressFunc nullptr"); - return; - } - unsigned int mapperSize = sizeof(g_pWalkLongPressMapper) / sizeof(g_pWalkLongPressMapper[0]); - for (unsigned int i = 0; i < mapperSize; i++) { - if (strcmp(buttonId, g_pWalkLongPressMapper[i].viewId) == 0) { - (this->*(g_pWalkLongPressMapper[i].Getfunc))(); - return; - } - } -} - -bool IndoorWalkPresenter::OnLongPress(UIView& view, const LongPressEvent& event) -{ - UNUSED(event); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnLongPress OnLongPress"); - LongPressFunc(view.GetViewId()); - return true; -} - -struct IndoorWalkModifiesMapper { - const char *viewId; - void (IndoorWalkPresenter::*Getfunc)(const char *lable, const char *lableUnit); -}; - -static const IndoorWalkModifiesMapper g_pWalkModifiesMapper[] = { - {IMAGE_FIRST_TOP, &IndoorWalkPresenter::ModifiesPageFirstTop}, - {IMAGE_FIRST_LEFT, &IndoorWalkPresenter::ModifiesPageFirstLeft}, - {IMAGE_FIRST_RIGHT, &IndoorWalkPresenter::ModifiesPageFirstRight}, - {IMAGE_FIRST_BOTTOM, &IndoorWalkPresenter::ModifiesPageFirstBottom}, - {IMAGE_SECOND_TOP, &IndoorWalkPresenter::ModifiesPageSecondTop}, - {IMAGE_SECOND_LEFT, &IndoorWalkPresenter::ModifiesPageSecondLeft}, - {IMAGE_SECOND_RIGHT, &IndoorWalkPresenter::ModifiesPageSecondRight}, - {IMAGE_THIRD_TOP, &IndoorWalkPresenter::ModifiesPageThirdTop}, - {IMAGE_THIRD_BOTTOM, &IndoorWalkPresenter::ModifiesPageThirdBottom}, - {IMAGE_FOURTH, &IndoorWalkPresenter::ModifiesPageFourth}, -}; - -void IndoorWalkPresenter::ModifiesFunc(const char *buttonId, const char *lable, const char *lableUnit) -{ - if ((buttonId == nullptr) || (lable == nullptr) || (lableUnit == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesFunc nullptr"); - return; - } - unsigned int mapperSize = sizeof(g_pWalkModifiesMapper) / sizeof(g_pWalkModifiesMapper[0]); - for (unsigned int i = 0; i < mapperSize; i++) { - if (strcmp(buttonId, g_pWalkModifiesMapper[i].viewId) == 0) { - (this->*(g_pWalkModifiesMapper[i].Getfunc))(lable, lableUnit); - IndoorWalkView::GetInstance()->ChangeView(CUSTOMIZATIONVIEW, INDOORWALKMOTIONVIEW); - return; - } - } -} - -void IndoorWalkPresenter::ModifiesProperties(const char* id, const char *lable, const char *lableUnit) -{ - if ((id == nullptr) || (lable == nullptr) || (lableUnit == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesProperties nullptr"); - return; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ModifiesProperties == %s", id); - HidePageImageView(); - ModifiesFunc(id, lable, lableUnit); -} - -struct IndoorWalkPropertiesMapper { - const char *viewId; - void (IndoorWalkPresenter::*Getfunc)(); -}; - -static const IndoorWalkPropertiesMapper g_pWalkPropertiesMapper[] = { - {IMAGE_FIRST_TOP, &IndoorWalkPresenter::SetPropertiesPageFirstTop}, - {IMAGE_FIRST_LEFT, &IndoorWalkPresenter::SetPropertiesPageFirstLeft}, - {IMAGE_FIRST_RIGHT, &IndoorWalkPresenter::SetPropertiesPageFirstRight}, - {IMAGE_FIRST_BOTTOM, &IndoorWalkPresenter::SetPropertiesPageFirstBottom}, - {IMAGE_SECOND_TOP, &IndoorWalkPresenter::SetPropertiesPageSecondTop}, - {IMAGE_SECOND_LEFT, &IndoorWalkPresenter::SetPropertiesPageSecondLeft}, - {IMAGE_SECOND_RIGHT, &IndoorWalkPresenter::SetPropertiesPageSecondRight}, - {IMAGE_THIRD_TOP, &IndoorWalkPresenter::SetPropertiesPageThirdTop}, - {IMAGE_THIRD_BOTTOM, &IndoorWalkPresenter::SetPropertiesPageThirdBottom}, - {IMAGE_FOURTH, &IndoorWalkPresenter::SetPropertiesPageFourth}, -}; - -void IndoorWalkPresenter::SetPropertiesPageFirstTop() -{ - std::string lableUnit = IndoorWalkModel::GetInstance()->GetTextLableUnitFirstTop(); - SetCustomizationState(lableUnit.c_str()); -} - -void IndoorWalkPresenter::SetPropertiesPageFirstLeft() -{ - std::string lableUnit = IndoorWalkModel::GetInstance()->GetTextLableUnitFirstLeft(); - SetCustomizationState(lableUnit.c_str()); -} - -void IndoorWalkPresenter::SetPropertiesPageFirstRight() -{ - std::string lableUnit = IndoorWalkModel::GetInstance()->GetTextLableUnitFirstRight(); - SetCustomizationState(lableUnit.c_str()); -} - -void IndoorWalkPresenter::SetPropertiesPageFirstBottom() -{ - std::string lableUnit = IndoorWalkModel::GetInstance()->GetTextLableUnitFirstBottom(); - SetCustomizationState(lableUnit.c_str()); -} - -void IndoorWalkPresenter::SetPropertiesPageSecondTop() -{ - std::string lableUnit = IndoorWalkModel::GetInstance()->GetTextLableUnitSecondTop(); - SetCustomizationState(lableUnit.c_str()); -} - -void IndoorWalkPresenter::SetPropertiesPageSecondLeft() -{ - std::string lableUnit = IndoorWalkModel::GetInstance()->GetTextLableUnitSecondLeft(); - SetCustomizationState(lableUnit.c_str()); -} - -void IndoorWalkPresenter::SetPropertiesPageSecondRight() -{ - std::string lableUnit = IndoorWalkModel::GetInstance()->GetTextLableUnitSecondRight(); - SetCustomizationState(lableUnit.c_str()); -} - -void IndoorWalkPresenter::SetPropertiesPageThirdTop() -{ - std::string lableUnit = IndoorWalkModel::GetInstance()->GetTextLableUnitThirdTop(); - SetCustomizationState(lableUnit.c_str()); -} - -void IndoorWalkPresenter::SetPropertiesPageThirdBottom() -{ - std::string lableUnit = IndoorWalkModel::GetInstance()->GetTextLableUnitThirdBottom(); - SetCustomizationState(lableUnit.c_str()); -} - -void IndoorWalkPresenter::SetPropertiesPageFourth() -{ - std::string lableUnit = IndoorWalkModel::GetInstance()->GetTextLableUnitFourth(); - SetCustomizationState(lableUnit.c_str()); -} - -void IndoorWalkPresenter::SetPropertiesFunc(const char *buttonId) -{ - if (buttonId == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetPropertiesFunc buttonId nullptr"); - return; - } - unsigned int mapperSize = sizeof(g_pWalkPropertiesMapper) / sizeof(g_pWalkPropertiesMapper[0]); - for (unsigned int i = 0; i < mapperSize; i++) { - if (strcmp(buttonId, g_pWalkPropertiesMapper[i].viewId) == 0) { - (this->*(g_pWalkPropertiesMapper[i].Getfunc))(); - return; - } - } -} - -void IndoorWalkPresenter::SetPropertiesState(const char* id) -{ - if (id == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetPropertiesState id nullptr"); - return; - } - SetPropertiesFunc(id); -} - -void IndoorWalkPresenter::SetCustomizationState(const char *lableUnit) -{ - if (lableUnit == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetCustomizationState lableUnit nullptr"); - return; - } - uint16_t customizationY = 0; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCustomizationState %s", lableUnit); - CustomizationView *customizationView = CustomizationView::GetInstance(); - if (customizationView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetCustomizationState::customizationView new fail"); - return; - } - customizationView->GetTimeRadio()->SetState(UICheckBox::UICheckBoxState::UNSELECTED); - customizationView->GetDistancesRadio()->SetState(UICheckBox::UICheckBoxState::UNSELECTED); - customizationView->GetHeartRadio()->SetState(UICheckBox::UICheckBoxState::UNSELECTED); - customizationView->GetSpeedRadio()->SetState(UICheckBox::UICheckBoxState::UNSELECTED); - customizationView->GetStepsRadio()->SetState(UICheckBox::UICheckBoxState::UNSELECTED); - if (strcmp(lableUnit, "时间") == 0) { - customizationView->GetTimeRadio()->SetState(UICheckBox::UICheckBoxState::SELECTED); - customizationY = customizationView->GetTimeView()->GetY(); - } else if (strcmp(lableUnit, "距离(km)") == 0) { - customizationView->GetDistancesRadio()->SetState(UICheckBox::UICheckBoxState::SELECTED); - customizationY = customizationView->GetDistancesView()->GetY(); - } else if (strcmp(lableUnit, "心率(bpm)") == 0) { - customizationView->GetHeartRadio()->SetState(UICheckBox::UICheckBoxState::SELECTED); - customizationY = customizationView->GetHeartView()->GetY(); - } else if (strcmp(lableUnit, "速度(km/h)") == 0) { - customizationView->GetSpeedRadio()->SetState(UICheckBox::UICheckBoxState::SELECTED); - customizationY = customizationView->GetSpeedView()->GetY(); - } else if (strcmp(lableUnit, "步数(steps)") == 0) { - customizationView->GetStepsRadio()->SetState(UICheckBox::UICheckBoxState::SELECTED); - customizationY = customizationView->GetStepsView()->GetY(); - } - customizationView->GetCustomizationViewGroup()->ScrollBy(0, CENTERED_Y - customizationY); -} - -void IndoorWalkPresenter::ModifiesTime() -{ - std::string duration = IndoorWalkModel::GetInstance()->DisplayMotionDuration(); - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitFirstTop().c_str(), "时间") == 0) { - ModifiesPageFirstTop(duration.c_str(), "时间"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitFirstLeft().c_str(), "时间") == 0) { - ModifiesPageFirstLeft(duration.c_str(), "时间"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitFirstRight().c_str(), "时间") == 0) { - ModifiesPageFirstRight(duration.c_str(), "时间"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitFirstBottom().c_str(), "时间") == 0) { - ModifiesPageFirstBottom(duration.c_str(), "时间"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitSecondTop().c_str(), "时间") == 0) { - ModifiesPageSecondTop(duration.c_str(), "时间"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitSecondLeft().c_str(), "时间") == 0) { - ModifiesPageSecondLeft(duration.c_str(), "时间"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitSecondRight().c_str(), "时间") == 0) { - ModifiesPageSecondRight(duration.c_str(), "时间"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitThirdTop().c_str(), "时间") == 0) { - ModifiesPageThirdTop(duration.c_str(), "时间"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitThirdBottom().c_str(), "时间") == 0) { - ModifiesPageThirdBottom(duration.c_str(), "时间"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitFourth().c_str(), "时间") == 0) { - ModifiesPageFourth(duration.c_str(), "时间"); - } -} - -void IndoorWalkPresenter::ModifiesDistances(float value) -{ - g_distancesChar.erase(); - value -= IndoorWalkModel::GetInstance()->GetInitialDistances(); - value /= CONVERSION_NUM; - g_distancesChar = std::to_string(value).substr(0, std::to_string(value).find(".") + 3); - - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitFirstTop().c_str(), "距离(km)") == 0) { - ModifiesPageFirstTop(g_distancesChar.c_str(), "距离(km)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitFirstLeft().c_str(), "距离(km)") == 0) { - ModifiesPageFirstLeft(g_distancesChar.c_str(), "距离(km)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitFirstRight().c_str(), "距离(km)") == 0) { - ModifiesPageFirstRight(g_distancesChar.c_str(), "距离(km)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitFirstBottom().c_str(), "距离(km)") == 0) { - ModifiesPageFirstBottom(g_distancesChar.c_str(), "距离(km)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitSecondTop().c_str(), "距离(km)") == 0) { - ModifiesPageSecondTop(g_distancesChar.c_str(), "距离(km)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitSecondLeft().c_str(), "距离(km)") == 0) { - ModifiesPageSecondLeft(g_distancesChar.c_str(), "距离(km)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitSecondRight().c_str(), "距离(km)") == 0) { - ModifiesPageSecondRight(g_distancesChar.c_str(), "距离(km)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitThirdTop().c_str(), "距离(km)") == 0) { - ModifiesPageThirdTop(g_distancesChar.c_str(), "距离(km)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitThirdBottom().c_str(), "距离(km)") == 0) { - ModifiesPageThirdBottom(g_distancesChar.c_str(), "距离(km)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitFourth().c_str(), "距离(km)") == 0) { - ModifiesPageFourth(g_distancesChar.c_str(), "距离(km)"); - } -} - -void IndoorWalkPresenter::ModifiesHeartRate(int value) -{ - char heartRateChar[STEP_CHAR_NUM] = {0}; - (void)sprintf_s(heartRateChar, STEP_CHAR_NUM, "%d", value); - - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitFirstTop().c_str(), "心率(bpm)") == 0) { - ModifiesPageFirstTop(heartRateChar, "心率(bpm)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitFirstLeft().c_str(), "心率(bpm)") == 0) { - ModifiesPageFirstLeft(heartRateChar, "心率(bpm)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitFirstRight().c_str(), "心率(bpm)") == 0) { - ModifiesPageFirstRight(heartRateChar, "心率(bpm)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitFirstBottom().c_str(), "心率(bpm)") == 0) { - ModifiesPageFirstBottom(heartRateChar, "心率(bpm)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitSecondTop().c_str(), "心率(bpm)") == 0) { - ModifiesPageSecondTop(heartRateChar, "心率(bpm)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitSecondLeft().c_str(), "心率(bpm)") == 0) { - ModifiesPageSecondLeft(heartRateChar, "心率(bpm)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitSecondRight().c_str(), "心率(bpm)") == 0) { - ModifiesPageSecondRight(heartRateChar, "心率(bpm)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitThirdTop().c_str(), "心率(bpm)") == 0) { - ModifiesPageThirdTop(heartRateChar, "心率(bpm)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitThirdBottom().c_str(), "心率(bpm)") == 0) { - ModifiesPageThirdBottom(heartRateChar, "心率(bpm)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitFourth().c_str(), "心率(bpm)") == 0) { - ModifiesPageFourth(heartRateChar, "心率(bpm)"); - } -} - -void IndoorWalkPresenter::ModifiesSteps(int step) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ModifiesSteps "); - char stepChar[STEP_CHAR_NUM] = {0}; - - (void)sprintf_s(stepChar, STEP_CHAR_NUM, "%d", step - IndoorWalkModel::GetInstance()->GetInitialStep()); - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitFirstTop().c_str(), "步数(steps)") == 0) { - ModifiesPageFirstTop(stepChar, "步数(steps)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitFirstLeft().c_str(), "步数(steps)") == 0) { - ModifiesPageFirstLeft(stepChar, "步数(steps)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitFirstRight().c_str(), "步数(steps)") == 0) { - ModifiesPageFirstRight(stepChar, "步数(steps)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitFirstBottom().c_str(), "步数(steps)") == 0) { - ModifiesPageFirstBottom(stepChar, "步数(steps)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitSecondTop().c_str(), "步数(steps)") == 0) { - ModifiesPageSecondTop(stepChar, "步数(steps)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitSecondLeft().c_str(), "步数(steps)") == 0) { - ModifiesPageSecondLeft(stepChar, "步数(steps)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitSecondRight().c_str(), "步数(steps)") == 0) { - ModifiesPageSecondRight(stepChar, "步数(steps)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitThirdTop().c_str(), "步数(steps)") == 0) { - ModifiesPageThirdTop(stepChar, "步数(steps)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitThirdBottom().c_str(), "步数(steps)") == 0) { - ModifiesPageThirdBottom(stepChar, "步数(steps)"); - } - if (strcmp(IndoorWalkModel::GetInstance()->GetTextLableUnitFourth().c_str(), "步数(steps)") == 0) { - ModifiesPageFourth(stepChar, "步数(steps)"); - } -} - -void IndoorWalkPresenter::ModifiesPageFirstTop(const char *lable, const char *lableUnit) -{ - if ((lable == nullptr) || (lableUnit == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesPageFirstTop lable nullptr"); - return; - } - MotionPageFirst *motionPageFirst = MotionPageFirst::GetInstance(); - if (motionPageFirst == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesPageFirstTop:motionPageFirst new fail"); - return; - } - motionPageFirst->GetLableFirstTop()->SetText(lable); - motionPageFirst->GetLableUnitFirstTop()->SetText(lableUnit); - IndoorWalkModel::GetInstance()->SetTextLableFirstTop(lable, lableUnit); -} - -void IndoorWalkPresenter::ModifiesPageFirstLeft(const char *lable, const char *lableUnit) -{ - if ((lable == nullptr) || (lableUnit == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesPageFirstLeft lable nullptr"); - return; - } - MotionPageFirst *motionPageFirst = MotionPageFirst::GetInstance(); - if (motionPageFirst == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesPageFirstLeft:motionPageFirst new fail"); - return; - } - motionPageFirst->GetLableFirstLeft()->SetText(lable); - motionPageFirst->GetLableUnitFirstLeft()->SetText(lableUnit); - IndoorWalkModel::GetInstance()->SetTextLableFirstLeft(lable, lableUnit); -} - -void IndoorWalkPresenter::ModifiesPageFirstRight(const char *lable, const char *lableUnit) -{ - if ((lable == nullptr) || (lableUnit == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesPageFirstRight lable nullptr"); - return; - } - MotionPageFirst *motionPageFirst = MotionPageFirst::GetInstance(); - if (motionPageFirst == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesPageFirstRight:motionPageFirst new fail"); - return; - } - motionPageFirst->GetLableFirstRight()->SetText(lable); - motionPageFirst->GetLableUnitFirstRight()->SetText(lableUnit); - IndoorWalkModel::GetInstance()->SetTextLableFirstRight(lable, lableUnit); -} - -void IndoorWalkPresenter::ModifiesPageFirstBottom(const char *lable, const char *lableUnit) -{ - if ((lable == nullptr) || (lableUnit == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesPageFirstBottom lable nullptr"); - return; - } - MotionPageFirst *motionPageFirst = MotionPageFirst::GetInstance(); - if (motionPageFirst == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesPageFirstBottom:motionPageFirst new fail"); - return; - } - motionPageFirst->GetLableFirstBottom()->SetText(lable); - motionPageFirst->GetLableUnitFirstBottom()->SetText(lableUnit); - IndoorWalkModel::GetInstance()->SetTextLableFirstBottom(lable, lableUnit); -} - -void IndoorWalkPresenter::ModifiesPageSecondTop(const char *lable, const char *lableUnit) -{ - if ((lable == nullptr) || (lableUnit == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesPageSecondTop lable nullptr"); - return; - } - MotionPageSecond *motionPageSecond = MotionPageSecond::GetInstance(); - if (motionPageSecond == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesPageSecondTop:motionPageSecond new fail"); - return; - } - motionPageSecond->GetLableSecondTop()->SetText(lable); - motionPageSecond->GetLableUnitSecondTop()->SetText(lableUnit); - IndoorWalkModel::GetInstance()->SetTextLableSecondTop(lable, lableUnit); -} - -void IndoorWalkPresenter::ModifiesPageSecondLeft(const char *lable, const char *lableUnit) -{ - if ((lable == nullptr) || (lableUnit == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesPageSecondLeft lable nullptr"); - return; - } - MotionPageSecond *motionPageSecond = MotionPageSecond::GetInstance(); - if (motionPageSecond == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesPageSecondLeft:motionPageSecond new fail"); - return; - } - motionPageSecond->GetLableSecondLeft()->SetText(lable); - motionPageSecond->GetLableUnitSecondLeft()->SetText(lableUnit); - IndoorWalkModel::GetInstance()->SetTextLableSecondLeft(lable, lableUnit); -} - -void IndoorWalkPresenter::ModifiesPageSecondRight(const char *lable, const char *lableUnit) -{ - if ((lable == nullptr) || (lableUnit == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesPageSecondRight lable nullptr"); - return; - } - MotionPageSecond *motionPageSecond = MotionPageSecond::GetInstance(); - if (motionPageSecond == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesPageSecondRight:motionPageSecond new fail"); - return; - } - motionPageSecond->GetLableSecondRight()->SetText(lable); - motionPageSecond->GetLableUnitSecondRight()->SetText(lableUnit); - IndoorWalkModel::GetInstance()->SetTextLableSecondRight(lable, lableUnit); -} - -void IndoorWalkPresenter::ModifiesPageThirdTop(const char *lable, const char *lableUnit) -{ - if ((lable == nullptr) || (lableUnit == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesPageThirdTop lable nullptr"); - return; - } - MotionPageThird *motionPageThird = MotionPageThird::GetInstance(); - if (motionPageThird == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesPageThirdTop:motionPageThird new fail"); - return; - } - motionPageThird->GetLableThirdTop()->SetText(lable); - motionPageThird->GetLableUnitThirdTop()->SetText(lableUnit); - IndoorWalkModel::GetInstance()->SetTextLableThirdTop(lable, lableUnit); -} - -void IndoorWalkPresenter::ModifiesPageThirdBottom(const char *lable, const char *lableUnit) -{ - if ((lable == nullptr) || (lableUnit == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesPageThirdBottom lable nullptr"); - return; - } - MotionPageThird *motionPageThird = MotionPageThird::GetInstance(); - if (motionPageThird == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesPageThirdBottom:motionPageThird new fail"); - return; - } - motionPageThird->GetLableThirdBottom()->SetText(lable); - motionPageThird->GetLableUnitThirdBottom()->SetText(lableUnit); - IndoorWalkModel::GetInstance()->SetTextLableThirdBottom(lable, lableUnit); -} - -void IndoorWalkPresenter::ModifiesPageFourth(const char *lable, const char *lableUnit) -{ - if ((lable == nullptr) || (lableUnit == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesPageFourth lable nullptr"); - return; - } - MotionPageFourth *motionPageFourth = MotionPageFourth::GetInstance(); - if (motionPageFourth == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesPageFourth:motionPageFourth new fail"); - return; - } - motionPageFourth->GetLableFourth()->SetText(lable); - motionPageFourth->GetLableUnitFourth()->SetText(lableUnit); - IndoorWalkModel::GetInstance()->SetTextLableFourth(lable, lableUnit); -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkView.cpp deleted file mode 100644 index 4cbdb8eb5..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/IndoorWalkView.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: IndoorWalk View - * Create: 2022-03-02 - */ - -#include "indoorwalk/IndoorWalkView.h" -#include "indoorwalk/IndoorWalkModel.h" -#include "wearable_log.h" -#include "UiConfig.h" - -namespace OHOS { -static IndoorWalkView *g_pIndoorWalkView{nullptr}; - -IndoorWalkView::IndoorWalkView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkView::IndoorWalkView"); - preProcessView[INDOORWALKPREPAREDVIEW] = &IndoorWalkView::ChangeIndoorWalkPreparedView; - preProcessView[INDOORWALKMOTIONVIEW] = &IndoorWalkView::ChangeIndoorWalkMotionView; - preProcessView[CUSTOMIZATIONVIEW] = &IndoorWalkView::ChangeCustomizationView; - preProcessView[INDOORWALKENDVIEW] = &IndoorWalkView::ChangeIndoorWalkEndView; - - g_pIndoorWalkView = this; -} - -IndoorWalkView::~IndoorWalkView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkView::~IndoorWalkView"); - g_pIndoorWalkView = nullptr; -} - -IndoorWalkView *IndoorWalkView::GetInstance() -{ - return g_pIndoorWalkView; -} - -void IndoorWalkView::OnStart() -{ - - ChangeView(INDOORWALK_MAX, INDOORWALKPREPAREDVIEW); - return; -} - -void IndoorWalkView::OnStop() -{ - DisableIndoorWalkTimer(); - IndoorWalkModel::GetInstance()->CloseDistancesSensor(); - return; -} - -bool IndoorWalkView::ChangeIndoorWalkPreparedView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeIndoorWalkPreparedView"); - indoorWalkPreparedView = new IndoorWalkPreparedView(); - if (indoorWalkPreparedView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "indoorWalkPreparedView new fail"); - return false; - } - // init view - UIViewGroup *group = indoorWalkPreparedView->InitShowUpView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - indoorWalkPreparedView->IndoorWalkHeartbeatStart(); - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool IndoorWalkView::ChangeIndoorWalkMotionView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeIndoorWalkMotionView"); - indoorWalkMotionView = new IndoorWalkMotionView(); - if (indoorWalkMotionView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "indoorWalkMotionView new fail"); - return false; - } - // init view - UIViewGroup *group = indoorWalkMotionView->WalkMotionViewInit(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool IndoorWalkView::ChangeCustomizationView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeCustomizationView"); - customizationView = new CustomizationView(); - if (customizationView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "customizationView new fail"); - return false; - } - // init view - UIViewGroup *group = customizationView->InitPropertiesView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool IndoorWalkView::ChangeIndoorWalkEndView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeIndoorWalkEndView"); - indoorWalkEndView = new IndoorWalkEndView(); - if (indoorWalkEndView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "indoorWalkEndView new fail"); - return false; - } - // init view - UIViewGroup *group = indoorWalkEndView->InitShowUpView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool IndoorWalkView::CheckViewParam(int16_t hideView, int16_t showView) -{ - if (showView < 0 || showView >= INDOORWALK_MAX) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "IndoorWalkView::CheckViewParam showView err."); - return false; - } - - if (hideView < 0 || hideView > INDOORWALK_MAX) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "IndoorWalkView::CheckViewParam hideView err."); - return false; - } - - return true; -} - -void IndoorWalkView::ChangeView(int16_t hideView, int16_t showView) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkView::ChangeView %d, %d", hideView, showView); - - if (!CheckViewParam(hideView, showView)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "IndoorWalkView::CheckViewParam failed."); - return; - } - - PreprosssChangeView tmpPreProcessView = preProcessView[showView]; - - if (!(this->*tmpPreProcessView)(hideView, showView)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "IndoorWalkView::ChangeView %d %dfailed", showView, hideView); - return; - } - if (hideView != INDOORWALK_MAX) { - if (container[hideView] == nullptr) { - return; - } - container[hideView]->SetVisible(false); - } - container[showView]->SetVisible(true); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "IndoorWalkView:: ChangeView end!!!%d", showView); - Draw(); -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/MotionPageFifth.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/MotionPageFifth.cpp deleted file mode 100644 index 7c41f0fa2..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/MotionPageFifth.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Motion PageFifth View - * Create: 2022-03-02 - */ -#include "indoorwalk/MotionPageFifth.h" -#include "wearable_log.h" -#include "UiConfig.h" - -namespace OHOS { -static constexpr uint16_t LABELS_X = 137; -static constexpr uint16_t LABELS_Y = 62; -static constexpr uint16_t LABELS_W = 180; -static constexpr uint16_t LABELS_H = 60; -static constexpr uint16_t IMAGE_X1 = 42; -static constexpr uint16_t IMAGE_X2 = 242; -static constexpr uint16_t IMAGE_Y = 142; -static MotionPageFifth *g_pMotionPageFifth{nullptr}; - -MotionPageFifth::MotionPageFifth() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionPageFifth::MotionPageFifth"); - g_pMotionPageFifth = this; -} - -MotionPageFifth::~MotionPageFifth() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionPageFifth::~MotionPageFifth"); - RemoveAll(); - delete lableFifth; - lableFifth = nullptr; - delete imageFifthLeft; - imageFifthLeft = nullptr; - delete imageFifthRight; - imageFifthRight = nullptr; - g_pMotionPageFifth = nullptr; -} - -MotionPageFifth *MotionPageFifth::GetInstance() -{ - return g_pMotionPageFifth; -} - -bool MotionPageFifth::InitPageFifthLableView() -{ - lableFifth = new UILabel(); - if (lableFifth == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "lableFifth new fail"); - return false; - } - lableFifth->SetPosition(LABELS_X, LABELS_Y, LABELS_W, LABELS_H); - lableFifth->SetText("训练压力"); - lableFifth->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40 : font data - lableFifth->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - lableFifth->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - Add(lableFifth); - return true; -} - -bool MotionPageFifth::InitPageFifthImageView() -{ - imageFifthLeft = new UIImageView(); - if (imageFifthLeft == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "imageFifthLeft new fail"); - return false; - } - imageFifthLeft->SetPosition(IMAGE_X1, IMAGE_Y); - imageFifthLeft->SetSrc(PNG_AEROBIC_IMAGE); - Add(imageFifthLeft); - - imageFifthRight = new UIImageView(); - if (imageFifthRight == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "imageFifthRight new fail"); - return false; - } - imageFifthRight->SetPosition(IMAGE_X2, IMAGE_Y); - imageFifthRight->SetSrc(PNG_ANAEROBIC_IMAGE); - Add(imageFifthRight); - return true; -} - -bool MotionPageFifth::InitView(void *caller) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionPageFifth InitView %p", caller); - bool ret = InitPageFifthLableView(); - if (!ret) { - return false; - } - ret = InitPageFifthImageView(); - if (!ret) { - return false; - } - return true; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/MotionPageFirst.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/MotionPageFirst.cpp deleted file mode 100644 index 0975cbedb..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/MotionPageFirst.cpp +++ /dev/null @@ -1,383 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Motion PageFirst View - * Create: 2022-03-02 - */ - -#include "indoorwalk/MotionPageFirst.h" -#include "indoorwalk/IndoorWalkPresenter.h" -#include "indoorwalk/IndoorWalkModel.h" -#include "wearable_log.h" -#include "UiConfig.h" - -namespace OHOS { -static constexpr uint16_t TOP_X = 92; -static constexpr uint16_t TOP_Y = 92; -static constexpr uint16_t TOP_W = 270; -static constexpr uint16_t LEFT_X = 47; -static constexpr uint16_t LEFT_Y = 192; -static constexpr uint16_t LEFT_W = 180; -static constexpr uint16_t RIGHT_X = 227; -static constexpr uint16_t RIGHT_Y = 192; -static constexpr uint16_t RIGHT_W = 180; -static constexpr uint16_t BOTTOM_X = 92; -static constexpr uint16_t BOTTOM_Y = 292; -static constexpr uint16_t BOTTOM_W = 270; -static constexpr uint16_t LABLE_H = 70; -static constexpr uint16_t UNIT_TOP_Y = 151; -static constexpr uint16_t UNIT_LEFT_Y = 250; -static constexpr uint16_t UNIT_RIGHT_Y = 250; -static constexpr uint16_t UNIT_BOTTOM_Y = 350; -static constexpr uint16_t UNIT_H = 50; - -static MotionPageFirst *g_pMotionPageFirst{nullptr}; - -MotionPageFirst::MotionPageFirst() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionPageFirst::MotionPageFirst"); - g_pMotionPageFirst = this; -} - -MotionPageFirst::~MotionPageFirst() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionPageFirst::~MotionPageFirst"); - RemoveAll(); - delete lableFirstTop; - lableFirstTop = nullptr; - delete lableFirstLeft; - lableFirstLeft = nullptr; - delete lableFirstRight; - lableFirstRight = nullptr; - delete lableFirstBottom; - lableFirstBottom = nullptr; - delete lableUnitFirstTop; - lableUnitFirstTop = nullptr; - delete lableUnitFirstLeft; - lableUnitFirstLeft = nullptr; - delete lableUnitFirstRight; - lableUnitFirstRight = nullptr; - delete lableUnitFirstBottom; - lableUnitFirstBottom = nullptr; - delete imageFirstTop; - imageFirstTop = nullptr; - delete imageFirstLeft; - imageFirstLeft = nullptr; - delete imageFirstRight; - imageFirstRight = nullptr; - delete imageFirstBottom; - imageFirstBottom = nullptr; - g_pMotionPageFirst = nullptr; -} - -MotionPageFirst *MotionPageFirst::GetInstance() -{ - return g_pMotionPageFirst; -} - -void MotionPageFirst::SetLableTemplate(UILabel *label) -{ - if (label == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetLableTemplate label nullptr"); - return; - } - UIView::OnLongPressListener *longPressListener = (UIView::OnLongPressListener *)OHOS::IndoorWalkPresenter::GetInstance(); - if (longPressListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "longPressListener GetInstance fail"); - return; - } - label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40 : font data - label->SetOnLongPressListener(longPressListener); - label->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - label->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - label->SetTouchable(true); -} - -void MotionPageFirst::SetUnitLableTemplate(UILabel *label) -{ - if (label == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetUnitLableTemplate label nullptr"); - return; - } - label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); // 30 : font data - label->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - label->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); -} - -bool MotionPageFirst::InitPageFirstLableTopView() -{ - std::string lable; - std::string lableUnit; - lable = IndoorWalkModel::GetInstance()->GetTextLableFirstTop(); - lableUnit = IndoorWalkModel::GetInstance()->GetTextLableUnitFirstTop(); - if (strcmp(lableUnit.c_str(), "步数(steps)") == 0) { - lable = "0"; - } else if (strcmp(lableUnit.c_str(), "时间") == 0) { - lable = "00:00:00"; - } else if (strcmp(lableUnit.c_str(), "距离(km)") == 0) { - lable = "0.00"; - } - lableFirstTop = new UILabel(); - lableUnitFirstTop = new UILabel(); - if ((lableFirstTop == nullptr) || (lableUnitFirstTop == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "lableFirstTop new fail"); - return false; - } - lableFirstTop->SetPosition(TOP_X, TOP_Y, TOP_W, LABLE_H); - lableFirstTop->SetText(lable.c_str()); - SetLableTemplate(lableFirstTop); - lableFirstTop->SetViewId(LABLE_FIRST_TOP); - Add(lableFirstTop); - - lableUnitFirstTop->SetPosition(TOP_X, UNIT_TOP_Y, TOP_W, UNIT_H); - lableUnitFirstTop->SetText(lableUnit.c_str()); - SetUnitLableTemplate(lableUnitFirstTop); - Add(lableUnitFirstTop); - return true; -} - -bool MotionPageFirst::InitPageFirstLableLeftView() -{ - std::string lable; - std::string lableUnit; - lable = IndoorWalkModel::GetInstance()->GetTextLableFirstLeft(); - lableUnit = IndoorWalkModel::GetInstance()->GetTextLableUnitFirstLeft(); - if (strcmp(lableUnit.c_str(), "步数(steps)") == 0) { - lable = "0"; - } else if (strcmp(lableUnit.c_str(), "时间") == 0) { - lable = "00:00:00"; - } else if (strcmp(lableUnit.c_str(), "距离(km)") == 0) { - lable = "0.00"; - } - lableFirstLeft = new UILabel(); - lableUnitFirstLeft = new UILabel(); - if ((lableFirstLeft == nullptr) || (lableUnitFirstLeft == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "lableFirstLeft new fail"); - return false; - } - - lableFirstLeft->SetPosition(LEFT_X, LEFT_Y, LEFT_W, LABLE_H); - lableFirstLeft->SetText(lable.c_str()); - SetLableTemplate(lableFirstLeft); - lableFirstLeft->SetViewId(LABLE_FIRST_LEFT); - Add(lableFirstLeft); - - lableUnitFirstLeft->SetPosition(LEFT_X, UNIT_LEFT_Y, LEFT_W, UNIT_H); - lableUnitFirstLeft->SetText(lableUnit.c_str()); - SetUnitLableTemplate(lableUnitFirstLeft); - Add(lableUnitFirstLeft); - return true; -} - -bool MotionPageFirst::InitPageFirstLableRightView() -{ - std::string lable; - std::string lableUnit; - lable = IndoorWalkModel::GetInstance()->GetTextLableFirstRight(); - lableUnit = IndoorWalkModel::GetInstance()->GetTextLableUnitFirstRight(); - if (strcmp(lableUnit.c_str(), "步数(steps)") == 0) { - lable = "0"; - } else if (strcmp(lableUnit.c_str(), "时间") == 0) { - lable = "00:00:00"; - } else if (strcmp(lableUnit.c_str(), "距离(km)") == 0) { - lable = "0.00"; - } - lableFirstRight = new UILabel(); - lableUnitFirstRight = new UILabel(); - if ((lableFirstRight == nullptr) || (lableUnitFirstRight == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "lableFirstRight new fail"); - return false; - } - lableFirstRight->SetPosition(RIGHT_X, RIGHT_Y, RIGHT_W, LABLE_H); - lableFirstRight->SetText(lable.c_str()); - SetLableTemplate(lableFirstRight); - lableFirstRight->SetViewId(LABLE_FIRST_RIGHT); - Add(lableFirstRight); - - lableUnitFirstRight->SetPosition(RIGHT_X, UNIT_RIGHT_Y, RIGHT_W, UNIT_H); - lableUnitFirstRight->SetText(lableUnit.c_str()); - SetUnitLableTemplate(lableUnitFirstRight); - Add(lableUnitFirstRight); - return true; -} - -bool MotionPageFirst::InitPageFirstLableBottomView() -{ - std::string lable; - std::string lableUnit; - lable = IndoorWalkModel::GetInstance()->GetTextLableFirstBottom(); - lableUnit = IndoorWalkModel::GetInstance()->GetTextLableUnitFirstBottom(); - if (strcmp(lableUnit.c_str(), "步数(steps)") == 0) { - lable = "0"; - } else if (strcmp(lableUnit.c_str(), "时间") == 0) { - lable = "00:00:00"; - } else if (strcmp(lableUnit.c_str(), "距离(km)") == 0) { - lable = "0.00"; - } - lableFirstBottom = new UILabel(); - lableUnitFirstBottom = new UILabel(); - if ((lableFirstBottom == nullptr) || (lableUnitFirstBottom == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "lableFirstBottom new fail"); - return false; - } - lableFirstBottom->SetPosition(BOTTOM_X, BOTTOM_Y, BOTTOM_W, LABLE_H); - lableFirstBottom->SetText(lable.c_str()); - SetLableTemplate(lableFirstBottom); - lableFirstBottom->SetViewId(LABLE_FIRST_BOTTOM); - Add(lableFirstBottom); - - lableUnitFirstBottom->SetPosition(BOTTOM_X, UNIT_BOTTOM_Y, BOTTOM_W, UNIT_H); - lableUnitFirstBottom->SetText(lableUnit.c_str()); - SetUnitLableTemplate(lableUnitFirstBottom); - Add(lableUnitFirstBottom); - return true; -} - -UILabel *MotionPageFirst::GetLableFirstTop(void) -{ - return lableFirstTop; -} - -UILabel *MotionPageFirst::GetLableUnitFirstTop(void) -{ - return lableUnitFirstTop; -} - -UILabel *MotionPageFirst::GetLableFirstLeft(void) -{ - return lableFirstLeft; -} - -UILabel *MotionPageFirst::GetLableUnitFirstLeft(void) -{ - return lableUnitFirstLeft; -} - -UILabel *MotionPageFirst::GetLableFirstRight(void) -{ - return lableFirstRight; -} - -UILabel *MotionPageFirst::GetLableUnitFirstRight(void) -{ - return lableUnitFirstRight; -} - -UILabel *MotionPageFirst::GetLableFirstBottom(void) -{ - return lableFirstBottom; -} - -UILabel *MotionPageFirst::GetLableUnitFirstBottom(void) -{ - return lableUnitFirstBottom; -} - - -bool MotionPageFirst::InitPageFirstImageView() -{ - imageFirstTop = new UIImageView(); - imageFirstLeft = new UIImageView(); - imageFirstRight = new UIImageView(); - imageFirstBottom = new UIImageView(); - if ((imageFirstTop == nullptr) || (imageFirstLeft == nullptr) || (imageFirstRight == nullptr) || (imageFirstBottom == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "imageFirst new fail"); - return false; - } - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::IndoorWalkPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance fail"); - return false; - } - imageFirstTop->SetPosition(TOP_X, TOP_Y); - imageFirstTop->SetSrc(PNG_OPTIONS_BOX2_IMAGE); - imageFirstTop->SetOnClickListener(clickListener); - imageFirstTop->SetViewId(IMAGE_FIRST_TOP); - imageFirstTop->SetTouchable(true); - Add(imageFirstTop); - - imageFirstLeft->SetPosition(LEFT_X, LEFT_Y); - imageFirstLeft->SetSrc(PNG_OPTIONS_BOX1_IMAGE); - imageFirstLeft->SetOnClickListener(clickListener); - imageFirstLeft->SetViewId(IMAGE_FIRST_LEFT); - imageFirstLeft->SetTouchable(true); - Add(imageFirstLeft); - - imageFirstRight->SetPosition(RIGHT_X, RIGHT_Y); - imageFirstRight->SetSrc(PNG_OPTIONS_BOX1_IMAGE); - imageFirstRight->SetOnClickListener(clickListener); - imageFirstRight->SetViewId(IMAGE_FIRST_RIGHT); - imageFirstRight->SetTouchable(true); - Add(imageFirstRight); - - imageFirstBottom->SetPosition(BOTTOM_X, BOTTOM_Y); - imageFirstBottom->SetSrc(PNG_OPTIONS_BOX2_IMAGE); - imageFirstBottom->SetOnClickListener(clickListener); - imageFirstBottom->SetViewId(IMAGE_FIRST_BOTTOM); - imageFirstBottom->SetTouchable(true); - Add(imageFirstBottom); - return true; -} - -void MotionPageFirst::HideInitPageFirstImageView() -{ - if ((imageFirstTop == nullptr) || (imageFirstLeft == nullptr) || (imageFirstRight == nullptr) || (imageFirstBottom == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HideInitPageFirstImageView imageFirst nullptr"); - return; - } - imageFirstTop->SetVisible(false); - imageFirstLeft->SetVisible(false); - imageFirstRight->SetVisible(false); - imageFirstBottom->SetVisible(false); -} - -void MotionPageFirst::ShowInitPageFirstImageView() -{ - if ((imageFirstTop == nullptr) || (imageFirstLeft == nullptr) || (imageFirstRight == nullptr) || (imageFirstBottom == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowInitPageFirstImageView imageFirst nullptr"); - return; - } - imageFirstTop->SetVisible(true); - imageFirstLeft->SetVisible(true); - imageFirstRight->SetVisible(true); - imageFirstBottom->SetVisible(true); -} - -bool MotionPageFirst::InitView(void *caller) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionPageFirst InitView %p", caller); - bool ret; - backGroundFirst = new UIImageView(); - if (backGroundFirst == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "backGroundFirst new fail"); - return false; - } - backGroundFirst->SetPosition(0, 0); // 0 : X; 0 : Y - backGroundFirst->SetSrc(PNG_WALK_BACK_GROUND); - Add(backGroundFirst); - ret = InitPageFirstLableTopView(); - if (!ret) { - return false; - } - ret = InitPageFirstLableLeftView(); - if (!ret) { - return false; - } - ret = InitPageFirstLableRightView(); - if (!ret) { - return false; - } - ret = InitPageFirstLableBottomView(); - if (!ret) { - return false; - } - ret = InitPageFirstImageView(); - if (!ret) { - return false; - } - HideInitPageFirstImageView(); - SetTouchable(true); - return true; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/MotionPageFourth.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/MotionPageFourth.cpp deleted file mode 100644 index 8ea8febb0..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/MotionPageFourth.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Motion PageFourth View - * Create: 2022-03-02 - */ -#include "indoorwalk/MotionPageFourth.h" -#include "indoorwalk/IndoorWalkPresenter.h" -#include "indoorwalk/IndoorWalkModel.h" -#include "wearable_log.h" -#include "UiConfig.h" - -namespace OHOS { -static constexpr uint16_t LABLE_X = 52; -static constexpr uint16_t LABLE_Y = 177; -static constexpr uint16_t LABLE_W = 350; -static constexpr uint16_t LABLE_H = 100; -static constexpr uint16_t LABLE_UNIT_Y = 269; -static constexpr uint16_t LABLE_UNIT_H = 50; -static MotionPageFourth *g_pMotionPageFourth{nullptr}; - -MotionPageFourth::MotionPageFourth() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionPageFourth::MotionPageFourth"); - g_pMotionPageFourth = this; -} - -MotionPageFourth::~MotionPageFourth() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionPageFourth::~MotionPageFourth"); - RemoveAll(); - delete lableFourth; - lableFourth = nullptr; - delete lableUnitFourth; - lableUnitFourth = nullptr; - delete imageFourth; - imageFourth = nullptr; - g_pMotionPageFourth = nullptr; -} - -MotionPageFourth *MotionPageFourth::GetInstance() -{ - return g_pMotionPageFourth; -} - -bool MotionPageFourth::InitPageFourthLableView() -{ - std::string lable; - std::string lableUnit; - lable = IndoorWalkModel::GetInstance()->GetTextLableFourth(); - lableUnit = IndoorWalkModel::GetInstance()->GetTextLableUnitFourth(); - if (strcmp(lableUnit.c_str(), "步数(steps)") == 0) { - lable = "0"; - } else if (strcmp(lableUnit.c_str(), "时间") == 0) { - lable = "00:00:00"; - } else if (strcmp(lableUnit.c_str(), "距离(km)") == 0) { - lable = "0.00"; - } - lableFourth = new UILabel(); - if (lableFourth == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "lableFourth new fail"); - return false; - } - UIView::OnLongPressListener *longPressListener = (UIView::OnLongPressListener *)OHOS::IndoorWalkPresenter::GetInstance(); - if (longPressListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "longPressListener GetInstance fail"); - return false; - } - lableFourth->SetPosition(LABLE_X, LABLE_Y, LABLE_W, LABLE_H); - lableFourth->SetText(lable.c_str()); - lableFourth->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 65); // 65 : font data - lableFourth->SetOnLongPressListener(longPressListener); - lableFourth->SetViewId(LABLE_FOURTH); - lableFourth->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - lableFourth->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - lableFourth->SetTouchable(true); - Add(lableFourth); - - lableUnitFourth = new UILabel(); - if (lableUnitFourth == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "lableUnitFourth new fail"); - return false; - } - lableUnitFourth->SetPosition(LABLE_X, LABLE_UNIT_Y, LABLE_W, LABLE_UNIT_H); - lableUnitFourth->SetText(lableUnit.c_str()); - lableUnitFourth->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 45); // 45 : font data - lableUnitFourth->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - lableUnitFourth->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - Add(lableUnitFourth); - return true; -} - -UILabel *MotionPageFourth::GetLableFourth(void) -{ - return lableFourth; -} - -UILabel *MotionPageFourth::GetLableUnitFourth(void) -{ - return lableUnitFourth; -} - -bool MotionPageFourth::InitPageFourthImageView() -{ - imageFourth = new UIImageView(); - if (imageFourth == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "imageFourth new fail"); - return false; - } - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::IndoorWalkPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance fail"); - return false; - } - imageFourth->SetPosition(LABLE_X, LABLE_Y); - imageFourth->SetSrc(PNG_OPTIONS_BOX4_IMAGE); - imageFourth->SetViewId(IMAGE_FOURTH); - imageFourth->SetOnClickListener(clickListener); - imageFourth->SetTouchable(true); - Add(imageFourth); - return true; -} - -void MotionPageFourth::HideInitPageFourthImageView() -{ - if (imageFourth == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HideInitPageFourthImageView imageFourth nullptr"); - return; - } - imageFourth->SetVisible(false); -} - -void MotionPageFourth::ShowInitPageFourthImageView() -{ - if (imageFourth == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowInitPageFourthImageView imageFourth nullptr"); - return; - } - imageFourth->SetVisible(true); -} - -bool MotionPageFourth::InitView(void *caller) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionPageFourth InitView %p", caller); - bool ret; - backGroundFourth = new UIImageView(); - if (backGroundFourth == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "backGroundFourth new fail"); - return false; - } - backGroundFourth->SetPosition(0, 0); // 0 : X; 0 : Y - backGroundFourth->SetSrc(PNG_WALK_BACK_GROUND); - Add(backGroundFourth); - ret = InitPageFourthLableView(); - if (!ret) { - return false; - } - ret = InitPageFourthImageView(); - if (!ret) { - return false; - } - HideInitPageFourthImageView(); - SetTouchable(true); - return true; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/MotionPageSecond.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/MotionPageSecond.cpp deleted file mode 100644 index 33fc94f8c..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/MotionPageSecond.cpp +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Motion PageSecond View - * Create: 2022-03-02 - */ -#include "indoorwalk/MotionPageSecond.h" -#include "indoorwalk/IndoorWalkPresenter.h" -#include "indoorwalk/IndoorWalkModel.h" -#include "wearable_log.h" -#include "UiConfig.h" - -namespace OHOS { -static constexpr uint16_t TOP_X = 92; -static constexpr uint16_t TOP_Y = 97; -static constexpr uint16_t TOP_W = 270; -static constexpr uint16_t LEFT_X = 47; -static constexpr uint16_t LEFT_Y = 232; -static constexpr uint16_t LEFT_W = 180; -static constexpr uint16_t RIGHT_X = 227; -static constexpr uint16_t RIGHT_Y = 232; -static constexpr uint16_t RIGHT_W = 180; -static constexpr uint16_t LABLE_H = 70; -static constexpr uint16_t UNIT_TOP_Y = 154; -static constexpr uint16_t UNIT_Y = 289; -static constexpr uint16_t UNIT_H = 50; -static MotionPageSecond *g_pMotionPageSecond{nullptr}; - -MotionPageSecond::MotionPageSecond() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionPageSecond::MotionPageSecond"); - g_pMotionPageSecond = this; -} - -MotionPageSecond::~MotionPageSecond() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionPageSecond::~MotionPageSecond"); - RemoveAll(); - delete lableSecondTop; - lableSecondTop = nullptr; - delete lableSecondLeft; - lableSecondLeft = nullptr; - delete lableSecondRight; - lableSecondRight = nullptr; - delete lableUnitSecondTop; - lableUnitSecondTop = nullptr; - delete lableUnitSecondLeft; - lableUnitSecondLeft = nullptr; - delete lableUnitSecondRight; - lableUnitSecondRight = nullptr; - delete imageSecondTop; - imageSecondTop = nullptr; - delete imageSecondLeft; - imageSecondLeft = nullptr; - delete imageSecondRight; - imageSecondRight = nullptr; - g_pMotionPageSecond = nullptr; -} - -MotionPageSecond *MotionPageSecond::GetInstance() -{ - return g_pMotionPageSecond; -} - -void MotionPageSecond::SetLableTemplate(UILabel *label) -{ - if (label == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetLableTemplate label nullptr"); - return; - } - UIView::OnLongPressListener *longPressListener = (UIView::OnLongPressListener *)OHOS::IndoorWalkPresenter::GetInstance(); - if (longPressListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "longPressListener GetInstance fail"); - return; - } - label->SetOnLongPressListener(longPressListener); - label->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - label->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - label->SetTouchable(true); -} - -bool MotionPageSecond::InitPageSecondLableTopView() -{ - std::string lable; - std::string lableUnit; - lable = IndoorWalkModel::GetInstance()->GetTextLableSecondTop(); - lableUnit = IndoorWalkModel::GetInstance()->GetTextLableUnitSecondTop(); - if (strcmp(lableUnit.c_str(), "步数(steps)") == 0) { - lable = "0"; - } else if (strcmp(lableUnit.c_str(), "时间") == 0) { - lable = "00:00:00"; - } else if (strcmp(lableUnit.c_str(), "距离(km)") == 0) { - lable = "0.00"; - } - lableSecondTop = new UILabel(); - lableUnitSecondTop = new UILabel(); - if ((lableSecondTop == nullptr) || (lableUnitSecondTop == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "lableSecondTop new fail"); - return false; - } - lableSecondTop->SetPosition(TOP_X, TOP_Y, TOP_W, LABLE_H); - lableSecondTop->SetText(lable.c_str()); - lableSecondTop->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 45); // 45 : font data - SetLableTemplate(lableSecondTop); - lableSecondTop->SetViewId(LABLE_SECOND_TOP); - Add(lableSecondTop); - - lableUnitSecondTop->SetPosition(TOP_X, UNIT_TOP_Y, TOP_W, UNIT_H); - lableUnitSecondTop->SetText(lableUnit.c_str()); - SetUnitLableTemplate(lableUnitSecondTop); - Add(lableUnitSecondTop); - return true; -} - -bool MotionPageSecond::InitPageSecondLableLeftView() -{ - std::string lable; - std::string lableUnit; - lable = IndoorWalkModel::GetInstance()->GetTextLableSecondLeft(); - lableUnit = IndoorWalkModel::GetInstance()->GetTextLableUnitSecondLeft(); - if (strcmp(lableUnit.c_str(), "步数(steps)") == 0) { - lable = "0"; - } else if (strcmp(lableUnit.c_str(), "时间") == 0) { - lable = "00:00:00"; - } else if (strcmp(lableUnit.c_str(), "距离(km)") == 0) { - lable = "0.00"; - } - lableSecondLeft = new UILabel(); - lableUnitSecondLeft = new UILabel(); - if ((lableSecondLeft == nullptr) || (lableUnitSecondLeft == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "lableSecondLeft new fail"); - return false; - } - lableSecondLeft->SetPosition(LEFT_X, LEFT_Y, LEFT_W, LABLE_H); - lableSecondLeft->SetText(lable.c_str()); - lableSecondLeft->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40 : font data - SetLableTemplate(lableSecondLeft); - lableSecondLeft->SetViewId(LABLE_SECOND_LEFT); - Add(lableSecondLeft); - - lableUnitSecondLeft->SetPosition(LEFT_X, UNIT_Y, LEFT_W, UNIT_H); - lableUnitSecondLeft->SetText(lableUnit.c_str()); - SetUnitLableTemplate(lableUnitSecondLeft); - Add(lableUnitSecondLeft); - return true; -} - -bool MotionPageSecond::InitPageSecondLableRightView() -{ - std::string lable; - std::string lableUnit; - lable = IndoorWalkModel::GetInstance()->GetTextLableSecondRight(); - lableUnit = IndoorWalkModel::GetInstance()->GetTextLableUnitSecondRight(); - if (strcmp(lableUnit.c_str(), "步数(steps)") == 0) { - lable = "0"; - } else if (strcmp(lableUnit.c_str(), "时间") == 0) { - lable = "00:00:00"; - } else if (strcmp(lableUnit.c_str(), "距离(km)") == 0) { - lable = "0.00"; - } - lableSecondRight = new UILabel(); - lableUnitSecondRight = new UILabel(); - if ((lableSecondRight == nullptr) || (lableUnitSecondRight == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "lableSecondRight new fail"); - return false; - } - lableSecondRight->SetPosition(RIGHT_X, RIGHT_Y, RIGHT_W, LABLE_H); - lableSecondRight->SetText(lable.c_str()); - lableSecondRight->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40 : font data - SetLableTemplate(lableSecondRight); - lableSecondRight->SetViewId(LABLE_SECOND_RIGHT); - Add(lableSecondRight); - - lableUnitSecondRight->SetPosition(RIGHT_X, UNIT_Y, RIGHT_W, UNIT_H); - lableUnitSecondRight->SetText(lableUnit.c_str()); - SetUnitLableTemplate(lableUnitSecondRight); - Add(lableUnitSecondRight); - return true; -} - -void MotionPageSecond::SetUnitLableTemplate(UILabel *label) -{ - if (label == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetUnitLableTemplate label nullptr"); - return; - } - label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); // 30 : font data - label->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - label->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); -} - -UILabel *MotionPageSecond::GetLableSecondTop(void) -{ - return lableSecondTop; -} - -UILabel *MotionPageSecond::GetLableUnitSecondTop(void) -{ - return lableUnitSecondTop; -} - -UILabel *MotionPageSecond::GetLableSecondLeft(void) -{ - return lableSecondLeft; -} - -UILabel *MotionPageSecond::GetLableUnitSecondLeft(void) -{ - return lableUnitSecondLeft; -} - -UILabel *MotionPageSecond::GetLableSecondRight(void) -{ - return lableSecondRight; -} - -UILabel *MotionPageSecond::GetLableUnitSecondRight(void) -{ - return lableUnitSecondRight; -} - -bool MotionPageSecond::InitPageSecondImageView() -{ - imageSecondTop = new UIImageView(); - imageSecondLeft = new UIImageView(); - imageSecondRight = new UIImageView(); - if ((imageSecondTop == nullptr) || (imageSecondLeft == nullptr) || (imageSecondRight == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "imageSecond new fail"); - return false; - } - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::IndoorWalkPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance fail"); - return false; - } - imageSecondTop->SetPosition(TOP_X, TOP_Y); - imageSecondTop->SetSrc(PNG_OPTIONS_BOX2_IMAGE); - imageSecondTop->SetViewId(IMAGE_SECOND_TOP); - imageSecondTop->SetOnClickListener(clickListener); - imageSecondTop->SetTouchable(true); - Add(imageSecondTop); - - imageSecondLeft->SetPosition(LEFT_X, LEFT_Y); - imageSecondLeft->SetSrc(PNG_OPTIONS_BOX1_IMAGE); - imageSecondLeft->SetViewId(IMAGE_SECOND_LEFT); - imageSecondLeft->SetOnClickListener(clickListener); - imageSecondLeft->SetTouchable(true); - Add(imageSecondLeft); - - imageSecondRight->SetPosition(RIGHT_X, RIGHT_Y); - imageSecondRight->SetSrc(PNG_OPTIONS_BOX1_IMAGE); - imageSecondRight->SetViewId(IMAGE_SECOND_RIGHT); - imageSecondRight->SetOnClickListener(clickListener); - imageSecondRight->SetTouchable(true); - Add(imageSecondRight); - return true; -} - -void MotionPageSecond::HideInitPageSecondImageView() -{ - if ((imageSecondTop == nullptr) || (imageSecondLeft == nullptr) || (imageSecondRight == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HideInitPageSecondImageView imageSecond nullptr"); - return; - } - imageSecondTop->SetVisible(false); - imageSecondLeft->SetVisible(false); - imageSecondRight->SetVisible(false); -} - -void MotionPageSecond::ShowInitPageSecondImageView() -{ - if ((imageSecondTop == nullptr) || (imageSecondLeft == nullptr) || (imageSecondRight == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowInitPageSecondImageView imageSecond nullptr"); - return; - } - imageSecondTop->SetVisible(true); - imageSecondLeft->SetVisible(true); - imageSecondRight->SetVisible(true); -} - -bool MotionPageSecond::InitView(void *caller) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionPageSecond InitView %p", caller); - bool ret; - backGroundSecond = new UIImageView(); - if (backGroundSecond == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "backGroundSecond new fail"); - return false; - } - backGroundSecond->SetPosition(0, 0); // 0 : X; 0 : Y - backGroundSecond->SetSrc(PNG_WALK_BACK_GROUND); - Add(backGroundSecond); - ret = InitPageSecondLableTopView(); - if (!ret) { - return false; - } - ret = InitPageSecondLableLeftView(); - if (!ret) { - return false; - } - ret = InitPageSecondLableRightView(); - if (!ret) { - return false; - } - ret = InitPageSecondImageView(); - if (!ret) { - return false; - } - HideInitPageSecondImageView(); - SetTouchable(true); - return true; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/MotionPageThird.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/MotionPageThird.cpp deleted file mode 100644 index d6730e95b..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/indoorwalk/src/MotionPageThird.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Motion PageThird View - * Create: 2022-03-02 - */ -#include "indoorwalk/MotionPageThird.h" -#include "indoorwalk/IndoorWalkPresenter.h" -#include "indoorwalk/IndoorWalkModel.h" -#include "wearable_log.h" -#include "UiConfig.h" - -namespace OHOS { -static constexpr uint16_t LABLE_X = 52; -static constexpr uint16_t TOP_Y = 112; -static constexpr uint16_t BOTTOM_Y = 252; -static constexpr uint16_t LABLE_W = 350; -static constexpr uint16_t LABLE_H = 80; -static constexpr uint16_t UNIT_TOP_Y = 180; -static constexpr uint16_t UNIT_BOTTOM_Y = 320; -static constexpr uint16_t UNIT_H = 50; -static MotionPageThird *g_pMotionPageThird{nullptr}; - -MotionPageThird::MotionPageThird() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionPageThird::MotionPageThird"); - g_pMotionPageThird = this; -} - -MotionPageThird::~MotionPageThird() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionPageThird::~MotionPageThird"); - RemoveAll(); - delete lableThirdTop; - lableThirdTop = nullptr; - delete lableUnitThirdTop; - lableUnitThirdTop = nullptr; - delete lableThirdBottom; - lableThirdBottom = nullptr; - delete lableUnitThirdBottom; - lableUnitThirdBottom = nullptr; - delete imageThirdTop; - imageThirdTop = nullptr; - delete imageThirdBottom; - imageThirdBottom = nullptr; - g_pMotionPageThird = nullptr; -} - -MotionPageThird *MotionPageThird::GetInstance() -{ - return g_pMotionPageThird; -} - -void MotionPageThird::SetLableTemplate(UILabel *label) -{ - if (label == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetLableTemplate label nullptr"); - return; - } - UIView::OnLongPressListener *longPressListener = (UIView::OnLongPressListener *)OHOS::IndoorWalkPresenter::GetInstance(); - if (longPressListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "longPressListener GetInstance fail"); - return; - } - label->SetOnLongPressListener(longPressListener); - label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 60); // 60 : font data - label->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - label->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - label->SetTouchable(true); -} - -bool MotionPageThird::InitPageThirdLableTopView() -{ - std::string lable; - std::string lableUnit; - lable = IndoorWalkModel::GetInstance()->GetTextLableThirdTop(); - lableUnit = IndoorWalkModel::GetInstance()->GetTextLableUnitThirdTop(); - if (strcmp(lableUnit.c_str(), "步数(steps)") == 0) { - lable = "0"; - } else if (strcmp(lableUnit.c_str(), "时间") == 0) { - lable = "00:00:00"; - } else if (strcmp(lableUnit.c_str(), "距离(km)") == 0) { - lable = "0.00"; - } - lableThirdTop = new UILabel(); - lableUnitThirdTop = new UILabel(); - if ((lableThirdTop == nullptr) || (lableUnitThirdTop == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "lableThirdTop new fail"); - return false; - } - lableThirdTop->SetPosition(LABLE_X, TOP_Y, LABLE_W, LABLE_H); - lableThirdTop->SetText(lable.c_str()); - SetLableTemplate(lableThirdTop); - lableThirdTop->SetViewId(LABLE_THIRD_TOP); - Add(lableThirdTop); - - lableUnitThirdTop->SetPosition(LABLE_X, UNIT_TOP_Y, LABLE_W, UNIT_H); - lableUnitThirdTop->SetText(lableUnit.c_str()); - SetUnitLableTemplate(lableUnitThirdTop); - Add(lableUnitThirdTop); - return true; -} - -void MotionPageThird::SetUnitLableTemplate(UILabel *label) -{ - if (label == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetUnitLableTemplate label nullptr"); - return; - } - label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); // 30 : font data - label->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - label->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); -} - -bool MotionPageThird::InitPageThirdLableBottomView() -{ - std::string lable; - std::string lableUnit; - lable = IndoorWalkModel::GetInstance()->GetTextLableThirdBottom(); - lableUnit = IndoorWalkModel::GetInstance()->GetTextLableUnitThirdBottom(); - if (strcmp(lableUnit.c_str(), "步数(steps)") == 0) { - lable = "0"; - } else if (strcmp(lableUnit.c_str(), "时间") == 0) { - lable = "00:00:00"; - } else if (strcmp(lableUnit.c_str(), "距离(km)") == 0) { - lable = "0.00"; - } - lableThirdBottom = new UILabel(); - lableUnitThirdBottom = new UILabel(); - if ((lableThirdBottom == nullptr) || (lableUnitThirdBottom == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "lableThirdBottom new fail"); - return false; - } - lableThirdBottom->SetPosition(LABLE_X, BOTTOM_Y, LABLE_W, LABLE_H); - lableThirdBottom->SetText(lable.c_str()); - SetLableTemplate(lableThirdBottom); - lableThirdBottom->SetViewId(LABLE_THIRD_BOTTOM); - Add(lableThirdBottom); - - lableUnitThirdBottom->SetPosition(LABLE_X, UNIT_BOTTOM_Y, LABLE_W, UNIT_H); - lableUnitThirdBottom->SetText(lableUnit.c_str()); - SetUnitLableTemplate(lableUnitThirdBottom); - Add(lableUnitThirdBottom); - return true; -} - -UILabel *MotionPageThird::GetLableThirdTop(void) -{ - return lableThirdTop; -} - -UILabel *MotionPageThird::GetLableUnitThirdTop(void) -{ - return lableUnitThirdTop; -} - -UILabel *MotionPageThird::GetLableThirdBottom(void) -{ - return lableThirdBottom; -} - -UILabel *MotionPageThird::GetLableUnitThirdBottom(void) -{ - return lableUnitThirdBottom; -} - -bool MotionPageThird::InitPageThirdImageView() -{ - imageThirdTop = new UIImageView(); - imageThirdBottom = new UIImageView(); - if ((imageThirdTop == nullptr) || (imageThirdBottom == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "imageThird new fail"); - return false; - } - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::IndoorWalkPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance fail"); - return false; - } - imageThirdTop->SetPosition(LABLE_X, TOP_Y); - imageThirdTop->SetSrc(PNG_OPTIONS_BOX3_IMAGE); - imageThirdTop->SetViewId(IMAGE_THIRD_TOP); - imageThirdTop->SetOnClickListener(clickListener); - imageThirdTop->SetTouchable(true); - Add(imageThirdTop); - - imageThirdBottom->SetPosition(LABLE_X, BOTTOM_Y); - imageThirdBottom->SetSrc(PNG_OPTIONS_BOX3_IMAGE); - imageThirdBottom->SetViewId(IMAGE_THIRD_BOTTOM); - imageThirdBottom->SetOnClickListener(clickListener); - imageThirdBottom->SetTouchable(true); - Add(imageThirdBottom); - return true; -} - -void MotionPageThird::HideInitPageThirdImageView() -{ - if ((imageThirdTop == nullptr) || (imageThirdBottom == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HideInitPageThirdImageView imageThird nullptr"); - return; - } - imageThirdTop->SetVisible(false); - imageThirdBottom->SetVisible(false); -} - -void MotionPageThird::ShowInitPageThirdImageView() -{ - if ((imageThirdTop == nullptr) || (imageThirdBottom == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowInitPageThirdImageView imageThird nullptr"); - return; - } - imageThirdTop->SetVisible(true); - imageThirdBottom->SetVisible(true); -} - -bool MotionPageThird::InitView(void *caller) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionPageThird InitView %p", caller); - bool ret; - backGroundThird = new UIImageView(); - if (backGroundThird == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "backGroundThird new fail"); - return false; - } - backGroundThird->SetPosition(0, 0); // 0 : X; 0 : Y - backGroundThird->SetSrc(PNG_WALK_BACK_GROUND); - Add(backGroundThird); - ret = InitPageThirdLableTopView(); - if (!ret) { - return false; - } - ret = InitPageThirdLableBottomView(); - if (!ret) { - return false; - } - ret = InitPageThirdImageView(); - if (!ret) { - return false; - } - HideInitPageThirdImageView(); - SetTouchable(true); - return true; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/main/src/MessageAdapter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/main/src/MessageAdapter.cpp deleted file mode 100644 index 8d5748cec..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/main/src/MessageAdapter.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - */ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: MessageAdapter.cpp - * Author: - * Create: 2021-11-23 - */ - -#include "main/MessageAdapter.h" - -namespace OHOS { -MessageAdapter::MessageAdapter() {} - -MessageAdapter::~MessageAdapter() -{ - listData.clear(); -} - -uint16_t MessageAdapter::GetCount(void) -{ - return listData.size(); -} - -void MessageAdapter::SetData(std::list &data) -{ - if (!listData.empty()) { - listData.clear(); - } - std::list::iterator it; - for (it = data.begin(); it != data.end(); it++) { - listData.push_back(*it); - } -} - -UIView *MessageAdapter::GetView(UIView *inView, int16_t index) -{ - if (listData.empty()) { - return nullptr; - } - if (index < 0) { - return nullptr; - } - size_t uindex = index; - if (uindex >= listData.size()) { - return nullptr; - } - - std::list::iterator it = listData.begin(); - for (int i = 0; i < index; i++) { - it++; - } - MessageItem itemData = *it; - MessageItemView *item = nullptr; - if (inView == nullptr) { - item = new MessageItemView(); - } else { - item = static_cast(inView); - } - - item->SetItemInfo(itemData); - item->SetOnClickListener(itemClickListener); - return item; -} - -void MessageAdapter::AddListItem(const MessageItem &item) -{ - listData.push_back(item); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "listData == %d-------zsy", listData.size()); - for (const auto& item : listData) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MessageItem.App == %s-------zsy", item.label_1.c_str()); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MessageItem.Content == %s-------zsy", item.label_2.c_str()); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MessageItem.Info == %s-------zsy", item.label_3.c_str()); - } -} - -void MessageAdapter::ClearListItem() -{ - listData.clear(); -} -} // namespace OHOS diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/main/src/MessageMainView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/main/src/MessageMainView.cpp deleted file mode 100644 index ed1000dd2..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/main/src/MessageMainView.cpp +++ /dev/null @@ -1,374 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: WeekStep - * Author: - * Create: 2021-09-11 - */ - -#include "main/MessageMainView.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "common/screen.h" -#include "main/MainPresenterSample.h" -#include "screensetting/ScreenModels.h" -#include "settings/SettingModel.h" -#include "ui_resource_image.h" - -namespace OHOS { - -static MessageMainView *g_pMessageMainView = nullptr; - -constexpr int16_t DISTURB_IMG_X = 117; -constexpr int16_t DISTURB_IMG_Y = 50; -constexpr int16_t SCREEN_IMG_X = 251; -constexpr int16_t SCREEN_IMG_Y = 50; -constexpr int16_t PHONE_IMG_X = 49; -constexpr int16_t PHONE_IMG_Y = 184; -constexpr int16_t ALARM_IMG_X = 184; -constexpr int16_t ALARM_IMG_Y = 184; -constexpr int16_t SETTING_IMG_X = 319; -constexpr int16_t SETTING_IMG_Y = 184; - -constexpr int16_t BLUETOOTH_IMG_X = 145; -constexpr int16_t BLUETOOTH_IMG_Y = 335; -constexpr int16_t BATTERY_IMG_X = 195; -constexpr int16_t BATTERY_IMG_Y = 340; - -constexpr int16_t DISTURB_LABEL_X = 136; -constexpr int16_t DISTURB_LABEL_Y = 145; -constexpr int16_t SCREEN_LABEL_X = 270; -constexpr int16_t SCREEN_LABEL_Y = 145; -constexpr int16_t PHONE_LABEL_X = 68; -constexpr int16_t PHONE_LABEL_Y = 279; -constexpr int16_t ALARM_LABEL_X = 203; -constexpr int16_t ALARM_LABEL_Y = 279; -constexpr int16_t SETTING_LABEL_X = 338; -constexpr int16_t SETTING_LABEL_Y = 279; - -constexpr int16_t BATTERY_LABEL_X = 247; -constexpr int16_t BATTERY_LABEL_Y = 335; -constexpr int16_t DATE_LABEL_X = 173; -constexpr int16_t DATE_LABEL_Y = 374; - -constexpr int16_t FONT_DEFAULT_SIZE = 24; -constexpr int16_t TEXT_WIDTH = 86; -constexpr int16_t TEXT_HEIGHT = 30; - -constexpr int16_t NONOTICE_LABLE_X = 141; -constexpr int16_t NONOTICE_LABLE_Y = 212; - -MessageMainView::MessageMainView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MessageMainView::MessageMainView"); - g_pMessageMainView = this; -} - -MessageMainView::~MessageMainView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MessageMainView::~MessageMainView"); - RemoveAll(); - delete messageLables; - messageLables = nullptr; - delete messageLable; - messageLable = nullptr; - delete deletereminder; - deletereminder = nullptr; - delete confirm; - confirm = nullptr; - delete cancel; - cancel = nullptr; - delete notice; - notice = nullptr; - delete contentList; - contentList = nullptr; - if (listAdapter != nullptr) { - delete listAdapter; - listAdapter = nullptr; - } - g_pMessageMainView = nullptr; - MessageModel::GetInstance().SetViewStatus(false); -} - -MessageMainView *MessageMainView::GetInstance(void) -{ - return g_pMessageMainView; -} - -bool MessageMainView::InitView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MessageMainView::InitView"); - messageLable = new UILabel(); - if (messageLable == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "messageLable new fail"); - return false; - } - messageLable->SetPosition(175, 20, 100, 30); - messageLable->SetText("通知"); - messageLable->SetAlign(TEXT_ALIGNMENT_CENTER); - messageLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24); - messageLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - messageLable->SetViewId("Notify"); - messageLable->SetTouchable(true); - notifyListener = (UIView::OnClickListener *)OHOS::MainPresenterSample::GetInstance(); - messageLable->SetOnClickListener(notifyListener); - // 删除图标 - notice = new UIImageView(); - if (notice == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TimerTimingView:: new startButton fail"); - return false; - } - notice->SetPosition(175, 330); - notice->Resize(100, 100); - notice->SetSrc(ALARM_TRUE_ADD_PATH); - notice->SetViewId("Delete"); - notice->SetTouchable(true); - clickListener = (UIView::OnClickListener *)OHOS::MainPresenterSample::GetInstance(); - notice->SetOnClickListener(clickListener); - ShowMessageList(); - InitScrollData(); - Add(messageLable); - Add(notice); - return true; -} - -void MessageMainView::PreLoad(void) -{ - if (! MessageModel::GetInstance().GetViewStatus()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageMainView::PreLoad,viewiInitStatus == false"); - InitView(); - DeletionView(); - NoNotify(); - const std::vector itemInfo = MessageModel::GetInstance().GetMessagelistItems(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageMainView::PreLoad,itemInfo == %d", itemInfo.size()); - if (itemInfo.size() == 0) { - messageLable->SetVisible(false); - notice->SetVisible(false); - contentList->SetVisible(false); - deletereminder->SetVisible(false); - confirm->SetVisible(false); - cancel->SetVisible(false); - messageLables->SetVisible(true); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageMainView::PreLoad,itemInfo.size() == 0"); - } else { - messageLable->SetVisible(true); - notice->SetVisible(true); - contentList->SetVisible(true); - deletereminder->SetVisible(false); - confirm->SetVisible(false); - cancel->SetVisible(false); - messageLables->SetVisible(false); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageMainView::PreLoad,itemInfo.size() != 0"); - } - MessageModel::GetInstance().SetViewStatus(true); - } -} - -void MessageMainView::ShowMessageList(void) -{ - contentList = new UIList(); - if (contentList == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MessageMainView::ShowMessageList contentList is nullptr"); - return; - } - contentList->SetPosition(32, 70); - contentList->Resize(HORIZONTAL_RESOLUTION, 318); // 364: height - contentList->SetSelectPosition(120); // middle position - contentList->SetDraggable(true); - contentList->SetThrowDrag(true); - contentList->EnableAutoAlign(true); - contentList->SetElastic(true); - Add(contentList); -} - -void MessageMainView::ConfirmDeletion(void) -{ - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageMainView::ConfirmDeletion"); - if (notice->IsVisible()) { - notice->SetVisible(false); - } - if (messageLable->IsVisible()) { - messageLable->SetVisible(false); - } - if (contentList->IsVisible()) { - contentList->SetVisible(false); - } - if (! deletereminder->IsVisible()) { - deletereminder->SetVisible(true); - } - if (! confirm->IsVisible()) { - confirm->SetVisible(true); - } - if (! cancel->IsVisible()) { - cancel->SetVisible(true); - } -} - -void MessageMainView::NewNotify(void) -{ - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageMainView::NewNotify"); - if (messageLables->IsVisible()) { - messageLables->SetVisible(false); - } - if (! notice->IsVisible()) { - notice->SetVisible(true); - } - if (! messageLable->IsVisible()) { - messageLable->SetVisible(true); - } - if (! contentList->IsVisible()) { - contentList->SetVisible(true); - } -} - -void MessageMainView::DeletionView(void) -{ - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageMainView::DeletionView"); - // 标题 - deletereminder = new UILabel(); - if (deletereminder == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "deletereminder new fail"); - return; - } - deletereminder->SetPosition(177, 145); // widget's left position and top position - deletereminder->Resize(260, 204); // widget's width and height - deletereminder->SetViewId("deletereminder");// Set style - - // Set additional property - deletereminder->SetText("是否删除通知?"); - deletereminder->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - deletereminder->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - deletereminder->SetRollSpeed(0); - - // 确认按钮 - confirm = new UILabelButton(); - if (confirm == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "confirm new fail"); - return; - } - confirm->SetPosition(88, 255); // widget's left position and top position - confirm->Resize(70, 50); // widget's width and height - confirm->SetViewId("Confirm");// Set style - - // Set additional property - confirm->SetText("确认"); - confirm->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 16); - confirm->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - confirmListener = (UIView::OnClickListener *)OHOS::MainPresenterSample::GetInstance(); - confirm->SetOnClickListener(confirmListener); - - // 取消按钮 - cancel = new UILabelButton(); - if (cancel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cancel new fail"); - return; - // cancel = new UILabelButton(); - } - cancel->SetPosition(301, 251); // widget's left position and top position - cancel->Resize(70, 50); // widget's width and height - cancel->SetViewId("Cancel");// Set style - - // Set additional property - cancel->SetText("取消"); - cancel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 16); - cancel->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - cancelListener = (UIView::OnClickListener *)OHOS::MainPresenterSample::GetInstance(); - cancel->SetOnClickListener(cancelListener); - Add(deletereminder); - Add(confirm); - Add(cancel); -} - -void MessageMainView::VerticalViewInits(void) -{ - if (deletereminder->IsVisible()) { - deletereminder->SetVisible(false); - } - if (confirm->IsVisible()) { - confirm->SetVisible(false); - } - if (cancel->IsVisible()) { - cancel->SetVisible(false); - } - if (! messageLables->IsVisible()) { - messageLables->SetVisible(true); - } -} - -void MessageMainView::NoNotify(void) -{ - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageMainView::NoNotify"); - messageLables = new UILabel(); - if (messageLables == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "messageLable new fail"); - return; - } - messageLables->SetPosition(177, 212, 100, 30); - messageLables->SetText("无消息"); - messageLables->SetAlign(TEXT_ALIGNMENT_CENTER); - messageLables->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24); - messageLables->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - messageLables->SetViewId("NoNotify"); - messageLables->SetTouchable(true); - newNotifyListener = (UIView::OnClickListener *)OHOS::MainPresenterSample::GetInstance(); - messageLables->SetOnClickListener(newNotifyListener); - Add(messageLables); -} - -void MessageMainView::CancelDeletion(void) -{ - if (deletereminder->IsVisible()) { - deletereminder->SetVisible(false); - } - if (confirm->IsVisible()) { - confirm->SetVisible(false); - } - if (cancel->IsVisible()) { - cancel->SetVisible(false); - } - if (! messageLable->IsVisible()) { - messageLable->SetVisible(true); - } - if (! notice->IsVisible()) { - notice->SetVisible(true); - } - if (! contentList->IsVisible()) { - contentList->SetVisible(true); - } -} - -void MessageMainView::RefreshMessageList(std::vector item) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MessageMainView::RefreshMessageList"); - if (listAdapter == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MessageMainView::RefreshMessageList listAdapter is nullptr"); - listAdapter = new MessageAdapter(); - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MessageMainView::RefreshMessageList"); - if (item.size() == 0) { - return; - } else { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MessageMainView::RefreshMessageList %d", item.size()); - listAdapter->ClearListItem(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "listAdapter->ClearListItem"); - for (size_t i = 0; i < item.size(); ++i) { - listAdapter->AddListItem(item[i]); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "listAdapter->AddListItem"); - } - } - if (contentList == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MessageMainView::contentList fail"); - return; - } - contentList->ScrollTo(0); - contentList->SetAdapter(listAdapter); - contentList->RefreshList(); -} - -bool MessageMainView::InitScrollData() -{ - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageMainView::InitScrollData"); - const std::vector itemInfo = MessageModel::GetInstance().GetMessagelistItems(); - RefreshMessageList(itemInfo); - return true; -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/CallerDisplayView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/CallerDisplayView.cpp deleted file mode 100644 index 5617586d1..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/CallerDisplayView.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: CallerDisplayView.cpp - * Author: - * Create: 2021-10-12 - */ -#include "makephone/CallerDisplayView.h" -#include "makephone/MainCallingPresenter.h" -#include "UiConfig.h" - -namespace OHOS { -static constexpr uint16 MATH_ZERO = 0; - -// 来电显示 -static constexpr uint16 LABEL_PERCENT_POSITION_X = 0; -static constexpr uint16 LABEL_PERCENT_POSITION_Y = 80; -static constexpr uint16 VIEW_DISTANCE_TO_LEFT_SIDE = HORIZONTAL_RESOLUTION; -static constexpr uint16 TITLE_LABEL_DEFAULT_HEIGHT = 80; - -// 当前时间 -static constexpr uint16 LABEL_CURREMTTIME_POSITION_X = 0; -static constexpr uint16 LABEL_CURREMTTIME_POSITION_Y = 340; - -// 图片坐标 -static constexpr uint16 IMAGE_DISSGREE_POSITION_X = 80; -static constexpr uint16 IMAGE_AGREEING_POSITION_X = 270; -static constexpr uint16 IMAGE_ALL_POSITION_Y = 240; - -// 字体大小 -static constexpr uint16 FONT_CURRENT_SIZE = 25; -static constexpr uint16 FONT_CALLER_SIZE = 40; -static CallerDisplayView *g_pMainView = nullptr; -CallerDisplayView::CallerDisplayView() -{ - g_pMainView = this; -} - -CallerDisplayView::~CallerDisplayView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallerDisplayView::~CallerDisplayView"); - group->RemoveAll(); - - delete imageAgreeing; - imageAgreeing = nullptr; - - delete imageDissgree; - imageDissgree = nullptr; - - delete callerDisplay; - callerDisplay = nullptr; - - delete currentTimes; - currentTimes = nullptr; - - delete group; - group = nullptr; - - g_pMainView = nullptr; -} - -CallerDisplayView *CallerDisplayView::GetInstance() -{ - return g_pMainView; -} - -bool CallerDisplayView::InitAddOnclickevent() -{ - clickLeftListener = (UIView::OnClickListener*)OHOS::MainCallingPresenter::GetInstance(); - if (clickLeftListener == nullptr) { - return false; - } - imageAgreeing->SetOnClickListener(clickLeftListener); - imageDissgree->SetOnClickListener(clickLeftListener); - return true; -} - -bool CallerDisplayView::InitImageViewDisplay() -{ - imageAgreeing = new UIImageView(); - if (imageAgreeing == nullptr) { - return false; - } - imageAgreeing->SetPosition(IMAGE_AGREEING_POSITION_X, IMAGE_ALL_POSITION_Y); // 30 : offset - imageAgreeing->SetSrc(PNG_AGREEING_IMAGE_PATH); - imageAgreeing->SetTouchable(true); - imageAgreeing->SetViewId("answer"); - group->Add(imageAgreeing); - - imageDissgree = new UIImageView(); - if (imageDissgree == nullptr) { - return false; - } - imageDissgree->SetPosition(IMAGE_DISSGREE_POSITION_X, IMAGE_ALL_POSITION_Y); // 30 : offset - imageDissgree->SetSrc(PNG_DISSGREE_IMAGE_PATH); - imageDissgree->SetTouchable(true); - imageDissgree->SetViewId("displayHandUp"); - group->Add(imageDissgree); - - return true; -} - -bool CallerDisplayView::InitUILabelDisplay() -{ - callerDisplay = new UILabel(); - if (callerDisplay == nullptr) { - return false; - } - callerDisplay->SetPosition(LABEL_PERCENT_POSITION_X, LABEL_PERCENT_POSITION_Y, VIEW_DISTANCE_TO_LEFT_SIDE, - TITLE_LABEL_DEFAULT_HEIGHT); - callerDisplay->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - callerDisplay->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); - callerDisplay->SetAlign(TEXT_ALIGNMENT_CENTER); - callerDisplay->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CALLER_SIZE); - callerDisplay->SetTextColor(Color::White()); - group->Add(callerDisplay); - - currentTimes = new UILabel(); - if (currentTimes == nullptr) { - return false; - } - currentTimes->SetPosition(LABEL_CURREMTTIME_POSITION_X, LABEL_CURREMTTIME_POSITION_Y, - VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); - currentTimes->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - currentTimes->SetAlign(TEXT_ALIGNMENT_CENTER); - currentTimes->SetText(CallerLogModel::GetInstance()->InitDateHourTime().c_str()); - currentTimes->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CURRENT_SIZE); - currentTimes->SetTextColor(Color::White()); - group->Add(currentTimes); - return true; -} - -UIViewGroup *CallerDisplayView::CreateUIViewGroup() -{ - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerDisplayView::UIViewGroup::new group error"); - return nullptr; - } - group->SetPosition(MATH_ZERO, MATH_ZERO); - group->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); // 454 : value - - if (!InitImageViewDisplay()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerDisplayView::InitImageViewDisplay error"); - return nullptr; - } - - if (!InitAddOnclickevent()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerDisplayView::InitAddOnclickevent error"); - return nullptr; - } - - if (!InitUILabelDisplay()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerDisplayView::InitUILabelDisplay error"); - return nullptr; - } - - return group; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/CallingView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/CallingView.cpp deleted file mode 100644 index 953900e8b..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/CallingView.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: CallingView.cpp - * Author: - * Create: 2021-10-12 - */ -#include "makephone/CallingView.h" -#include "makephone/MainCallingPresenter.h" -#include "wearable_log.h" -#include "UiConfig.h" - - -namespace OHOS { -static constexpr uint16 MATH_ZERO = 0; - -// 来电显示 -static constexpr uint16 LABEL_PERCENT_POSITION_X = 0; -static constexpr uint16 LABEL_PERCENT_POSITION_Y = 100; - -static constexpr uint16 VIEW_DISTANCE_TO_LEFT_SIDE = HORIZONTAL_RESOLUTION; -static constexpr uint16 TITLE_LABEL_DEFAULT_HEIGHT = 80; - -// 当前时间 -static constexpr uint16 LABEL_CURREMTTIME_POSITION_X = 0; -static constexpr uint16 LABEL_CURREMTTIME_POSITION_Y = 360; - -// 图片坐标 -static constexpr uint16 LABEL_CALLERD_POSITION_X = 0; -static constexpr uint16 LABEL_CALLERD_POSITION_Y = 160; -static constexpr uint16 IMAGE_HONRS_POSITION_X = 185; -static constexpr uint16 IMAGE_HONRS_POSITION_Y = 10; -static constexpr uint16 IMAGE_DISSGREE_POSITION_X = 70; -static constexpr uint16 IMAGE_AGREEING_POSITION_X = 280; -static constexpr uint16 IMAGE_ALL_POSITION_Y = 240; - -// 字体大小 -static constexpr uint16 LABEL_TIME_FONT_SIZE = 25; -static constexpr uint16 LABEL_DISPLAY_FONE_SIZE = 40; -static CallingView *g_pMainView = nullptr; - -CallingView::CallingView() -{ - g_pMainView = this; -} - -CallingView::~CallingView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallingView::~CallingView"); - group->RemoveAll(); - delete imageMicrophone; - imageMicrophone = nullptr; - - delete imageHandUp; - imageHandUp = nullptr; - - delete imageHorns; - imageHorns = nullptr; - - delete callerDisplay; - callerDisplay = nullptr; - - delete currentTimes; - currentTimes = nullptr; - - delete callDuration; - callDuration = nullptr; - - delete group; - group = nullptr; - - g_pMainView = nullptr; -} - -CallingView *CallingView::GetInstance() -{ - return g_pMainView; -} - -bool CallingView::InitAddOnclickevent() -{ - clickLeftListener = (UIView::OnClickListener*)OHOS::MainCallingPresenter::GetInstance(); - if (clickLeftListener == nullptr) { - return false; - } - - imageMicrophone->SetOnClickListener(clickLeftListener); - imageHandUp->SetOnClickListener(clickLeftListener); - imageHorns->SetOnClickListener(clickLeftListener); - - return true; -} - - -UILabel *CallingView::GetCallingDurationLabel() -{ - return callDuration; -} - -bool CallingView::InitImageViewDisplay() -{ - imageMicrophone = new UIImageView(); - if (imageMicrophone == nullptr) { - return false; - } - imageMicrophone->SetPosition(IMAGE_AGREEING_POSITION_X, IMAGE_ALL_POSITION_Y); // 30 : offset - imageMicrophone->SetSrc(PNG_MICROPHONE_OPEN_IMAGE_PATH); - imageMicrophone->SetTouchable(true); - imageMicrophone->SetViewId("microphoneChange"); - group->Add(imageMicrophone); - - imageHandUp = new UIImageView(); - if (imageHandUp == nullptr) { - return false; - } - imageHandUp->SetPosition(IMAGE_DISSGREE_POSITION_X, IMAGE_ALL_POSITION_Y); // 30 : offset - imageHandUp->SetSrc(PNG_DISSGREE_IMAGE_PATH); - imageHandUp->SetTouchable(true); - imageHandUp->SetViewId("callingHandUp"); - group->Add(imageHandUp); - - imageHorns = new UIImageView(); - if (imageHorns == nullptr) { - return false; - } - imageHorns->SetPosition(IMAGE_HONRS_POSITION_X, IMAGE_HONRS_POSITION_Y); // 30 : offset - imageHorns->SetSrc(PNG_SOUNDBUTTON2); - imageHorns->SetTouchable(true); - imageHorns->SetViewId("volumeSwitch"); - - group->Add(imageHorns); - return true; -} - -UIImageView *CallingView::GetImageMicrophone() -{ - return imageMicrophone; -} - -UILabel *CallingView::GetCallingDisplayLabel() -{ - return callerDisplay; -} - -bool CallingView::InitUILabelDisplay() -{ - callerDisplay = new UILabel(); - if (callerDisplay == nullptr) { - return false; - } - callerDisplay->SetPosition(LABEL_PERCENT_POSITION_X, LABEL_PERCENT_POSITION_Y, - VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); - callerDisplay->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - callerDisplay->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); - callerDisplay->SetAlign(TEXT_ALIGNMENT_CENTER); - callerDisplay->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_DISPLAY_FONE_SIZE); - callerDisplay->SetTextColor(Color::White()); - group->Add(callerDisplay); - - callDuration = new UILabel(); - if (callDuration == nullptr) { - return false; - } - callDuration->SetPosition(LABEL_CALLERD_POSITION_X, LABEL_CALLERD_POSITION_Y, - VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); - callDuration->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - callDuration->SetAlign(TEXT_ALIGNMENT_CENTER); - callDuration->SetText(CallerLogModel::GetInstance()->DisplayCallDuration().c_str()); - callDuration->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_TIME_FONT_SIZE); - callDuration->SetTextColor(Color::White()); - group->Add(callDuration); - - currentTimes = new UILabel(); - if (currentTimes == nullptr) { - return false; - } - currentTimes->SetPosition(LABEL_CURREMTTIME_POSITION_X, LABEL_CURREMTTIME_POSITION_Y, - VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); - currentTimes->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - currentTimes->SetAlign(TEXT_ALIGNMENT_CENTER); - currentTimes->SetText(CallerLogModel::GetInstance()->InitDateHourTime().c_str()); - currentTimes->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_TIME_FONT_SIZE); - currentTimes->SetTextColor(Color::White()); - - group->Add(currentTimes); - return true; -} - -UIViewGroup *CallingView::CreateUIViewGroup() -{ - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::UIViewGroup::new group error"); - return nullptr; - } - group->SetPosition(MATH_ZERO, MATH_ZERO); - group->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); // 454 : value - - if (!InitImageViewDisplay()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::InitImageViewDisplay error"); - return nullptr; - } - - if (!InitAddOnclickevent()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::InitAddOnclickevent error"); - return nullptr; - } - - if (!InitUILabelDisplay()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::InitUILabelDisplay error"); - return nullptr; - } - - return group; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/DialingScreenView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/DialingScreenView.cpp deleted file mode 100644 index e18ae2a72..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/DialingScreenView.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: DialingScreenView.cpp - * Author: - * Create: 2021-10-12 - */ -#include "wearable_log.h" -#include "UiConfig.h" -#include "makephone/DialingScreenView.h" -#include "makephone/MainCallingPresenter.h" - -namespace OHOS { -static constexpr uint16 MATH_ZERO = 0; - -// 图片显示 -static constexpr uint16 IMAGE_HANDUP_POSITION_X = 177; -static constexpr uint16 IMAGE_HANDUP_POSITION_Y = 210; - -// 来电显示 -static constexpr uint16 LABEL_ADRESS_POSITION_X = 0; -static constexpr uint16 LABEL_ADRESS_POSITION_Y = 90; -static constexpr uint16 VIEW_DISTANCE_TO_LEFT_SIDE = HORIZONTAL_RESOLUTION; -static constexpr uint16 TITLE_LABEL_DEFAULT_HEIGHT = 60; - -// 拨出时间 -static constexpr uint16 LABEL_DIALING_POSITION_X = 0; -static constexpr uint16 LABEL_DIALING_POSITION_Y = 150; - -// 当前时间 -static constexpr uint16 LABEL_CURRENT_POSITION_X = 0; -static constexpr uint16 LABEL_CURRENT_POSITION_Y = 340; - -// 字体大小 -static constexpr uint16 FONT_TIME_SIZE = 25; -static constexpr uint16 FONT_AIALING_SIZE = 40; -static constexpr uint16 FONT_CURRENT_SIZE = 20; -static DialingScreenView *g_pMainView = nullptr; -DialingScreenView::DialingScreenView() -{ - g_pMainView = this; -} - -DialingScreenView::~DialingScreenView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialingScreenView::~DialingScreenView"); - group->RemoveAll(); - delete dialingId; - dialingId = nullptr; - - delete dialingTime; - dialingTime = nullptr; - - delete currentTimes; - currentTimes = nullptr; - - delete handup; - handup = nullptr; - - delete group; - group = nullptr; - - g_pMainView = nullptr; -} - -DialingScreenView *DialingScreenView::GetInstance() -{ - return g_pMainView; -} - -bool DialingScreenView::InitUILabelDisplay() -{ - dialingId = new UILabel(); - if (dialingId == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingScreenView::new UILabel fail"); - return false; - } - dialingId->SetPosition(LABEL_ADRESS_POSITION_X, LABEL_ADRESS_POSITION_Y, - VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); - dialingId->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - dialingId->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); - dialingId->SetAlign(TEXT_ALIGNMENT_CENTER); - dialingId->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_AIALING_SIZE); - dialingId->SetTextColor(Color::White()); - group->Add(dialingId); - - dialingTime = new UILabel(); - if (dialingTime == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingScreenView::new Label fail"); - return false; - } - dialingTime->SetPosition(LABEL_DIALING_POSITION_X, LABEL_DIALING_POSITION_Y, - VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); - dialingTime->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - dialingTime->SetAlign(TEXT_ALIGNMENT_CENTER); - dialingTime->SetText(CallerLogModel::GetInstance()->GetDialingStatus().c_str()); - dialingTime->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_TIME_SIZE); - dialingTime->SetTextColor(Color::White()); - group->Add(dialingTime); - - currentTimes = new UILabel(); - if (currentTimes == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerDisplayView::new Label fail"); - return false; - } - currentTimes->SetPosition(LABEL_CURRENT_POSITION_X, LABEL_CURRENT_POSITION_Y, - VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); - currentTimes->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - currentTimes->SetAlign(TEXT_ALIGNMENT_CENTER); - currentTimes->SetText(CallerLogModel::GetInstance()->InitDateHourTime().c_str()); - currentTimes->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CURRENT_SIZE); - currentTimes->SetTextColor(Color::White()); - group->Add(currentTimes); - - return true; -} - -UIViewGroup *DialingScreenView::CreateUIViewGroup() -{ - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingScreenView::new group error"); - return nullptr; - } - group->SetPosition(MATH_ZERO, MATH_ZERO); - group->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); // 454 : value - - if (!InitUILabelDisplay()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingScreenView::InitImageViewDisplay error"); - return nullptr; - } - - handup = new UIImageView(); - if (handup == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingScreenView::new UIImageView error"); - return nullptr; - } - handup->SetPosition(IMAGE_HANDUP_POSITION_X, IMAGE_HANDUP_POSITION_Y); // 30 : offset - handup->SetSrc(PNG_DISSGREE_IMAGE_PATH); - handup->SetTouchable(true); - handup->SetViewId("dialingHandUp"); - - clickLeftListener = (UIView::OnClickListener*)OHOS::MainCallingPresenter::GetInstance(); - if (clickLeftListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingScreenView::new clickLeftListener error"); - return nullptr; - } - handup->SetOnClickListener(clickLeftListener); - group->Add(handup); - - return group; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp deleted file mode 100644 index 07b4d2cec..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: MainCallingPresenter.cpp - * Author: - * Create: 2021-10-12 - */ - -#include "wearable_log.h" -#include "common/image_cache_manager.h" -#include "UiConfig.h" -#include "ui_resource_image.h" -#include "makephone/MainCallingPresenter.h" -#include "makephone/CallingView.h" -#include "makephone/CallerDisplayView.h" -#include "makephone/DialingScreenView.h" -#include "makephone/MainCallingView.h" -#include "NativeRegisterManager.h" -#include "phoneservice/PhoneService.h" -#include "makephone/WaitingHintsView.h" - -namespace OHOS { - -REGIST_SLICE(VIEW_MAEKPHONE_SAMPLE, MainCallingView, MainCallingPresenter); - -static MainCallingPresenter *g_pMainView = nullptr; -static constexpr int32 NUM_10 = 10; -MainCallingPresenter::MainCallingPresenter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::MainCallingPresenter"); - g_pMainView = this; -} - -MainCallingPresenter::~MainCallingPresenter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::~MainCallingPresenter"); - if (volumeSetting != nullptr) { - delete volumeSetting; - volumeSetting = nullptr; - } - g_pMainView = nullptr; -} - -MainCallingPresenter *MainCallingPresenter::GetInstance() -{ - return g_pMainView; -} - -void MainCallingPresenter::HonrsViewChange() -{ - if (volumeSetting == nullptr) { - volumeSetting = new VolumeSettingView(); - if (volumeSetting == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::volumeSetting nullptr err"); - return; - } - if (!volumeSetting->SetUpVolume()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::volumeSetting SetUpVolume fail"); - return; - } - volumeSetting->GetProgress()->SetValue(AudioManager::GetInstance().GetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO)); - if (AudioManager::GetInstance().GetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO) == 0) { - ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_MUTE_BUTTON, PLAYER_IAMGES); - volumeSetting->GetDecreaseButton()->SetImageSrc(image, image); - } - view_->AddViewToRootContainer(volumeSetting); - } - VolumeSliderEventListener *volumeSliderEventListener = volumeSetting->GetVolumeEventListener(); - if (volumeSliderEventListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::volumeSliderEventListener nullptr err"); - return; - } - - volumeSliderEventListener->SetPlayerCoefficients(VOLUMEPHONE); // 进度条系数 - - if (!InitPointerValue()) { - return; - } - - view_->GetScreenGroup()->SetVisible(false); - view_->GetDisplayGroup()->SetVisible(false); - view_->GetCallingGroup()->SetVisible(false); - view_->GetWaitingGroup()->SetVisible(false); - - volumeSetting->SetVisible(true); - // 刷新UI - RootView::GetInstance()->Invalidate(); -} - -bool MainCallingPresenter::CallingViewDisplay() -{ - if (!InitPointerValue()) { - return false; - } - view_->GetScreenGroup()->SetVisible(false); - view_->GetDisplayGroup()->SetVisible(false); - view_->GetCallingGroup()->SetVisible(true); - view_->GetWaitingGroup()->SetVisible(false); - return true; -} - -bool MainCallingPresenter::InitPointerValue() -{ - if (CallerDisplayView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] CallerDisplayView error"); - return false; - } - - if (DialingScreenView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] DialingScreenView error"); - return false; - } - - if (CallingView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] CallingView error"); - return false; - } - - if (WaitingHintsView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] WaitingHintsView error"); - return false; - } - - if (view_->GetScreenGroup() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] view_ GetScreenGroup error"); - return false; - } - - if (view_->GetDisplayGroup() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] view_ GetDisplayGroup error"); - return false; - } - - if (view_->GetCallingGroup() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] view_ GetCallingGroup error"); - return false; - } - - if (view_->GetWaitingGroup() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] view_ GetWaitingGroup error"); - return false; - } - return true; -} - -bool MainCallingPresenter::HintsHandupClick() -{ - if (RejectIncomingCall() != 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[HintsHandupClick] RejectIncomingCall error"); - return false; - } - CallerLogModel::GetInstance()->SetWaitingStatus(false); - CallerLogModel::GetInstance()->SetCallStatus(true); - NativeAbility::GetInstance().ChangeSlice(VIEW_MAEKPHONE_SAMPLE, TransitionType::TRANSITION_INVALID, PRIORITY_ONE); - return true; -} - -bool MainCallingPresenter::OnClick(UIView& view, const ClickEvent& event) -{ - UNUSED(event); - - if (!InitPointerValue()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::InitPointerValue error"); - return false; - } - - if (strcmp(view.GetViewId(), "microphoneChange") == 0) { - if (changeImage == 0) { - changeImage = 1; - view_->GetCallingView()->GetImageMicrophone()->SetSrc(PNG_MICROPHONE_CLOSE_IMAGE_PATH); - SetMicMute(true); - } else { - changeImage = 0; - view_->GetCallingView()->GetImageMicrophone()->SetSrc(PNG_MICROPHONE_OPEN_IMAGE_PATH); - SetMicMute(false); - } - return true; - } else if (strcmp(view.GetViewId(), "displayHandUp") == 0 || strcmp(view.GetViewId(), "callingHandUp") == 0|| - strcmp(view.GetViewId(), "dialingHandUp") == 0) { - if (strcmp(view.GetViewId(), "displayHandUp") == 0) { - // 手表拒接呼入来电 - if (RejectIncomingCall() != 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::RejectIncomingCall() fail"); - return false; - } - } - if (FinishCall() != 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::FinishCall() fail"); - return false; - } - return true; - } else if (strcmp(view.GetViewId(), "volumeSwitch") == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::honrs show"); - HonrsViewChange(); - } else if (strcmp(view.GetViewId(), "hintsHandup") == 0) { - if (!HintsHandupClick()) { - return false; - } - } else if (strcmp(view.GetViewId(), "answer") == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::phone calling"); - // 界面的显示和隐藏 - SetMicMute(false); - // 手表接听呼入来电 - if (AcceptIncomingCall() != 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::AcceptIncomingCall() fail"); - return false; - } - return true; - } - return true; -} - -VolumeSettingView *MainCallingPresenter::GetvolumeSetting() -{ - return volumeSetting; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/MainCallingView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/MainCallingView.cpp deleted file mode 100644 index d079a9676..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/MainCallingView.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: MainCallingView.cpp - * Author: - * Create: 2021-10-12 - */ -#include "wearable_log.h" -#include "UiConfig.h" -#include "makephone/MainCallingView.h" -#include "makephone/MainCallingPresenter.h" -#include "callerlog/CallerLogModel.h" - -namespace OHOS { -static MainCallingView *g_pMainView = nullptr; -MainCallingView::MainCallingView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingView::MainCallingView"); - g_pMainView = this; -} - -MainCallingView::~MainCallingView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingView::~MainCallingView"); - delete displayView; - displayView = nullptr; - - delete callView; - callView = nullptr; - - delete screenView; - screenView = nullptr; - - g_pMainView = nullptr; -} - -MainCallingView *MainCallingView::GetInstance() -{ - return g_pMainView; -} - -UIViewGroup *MainCallingView::GetDisplayGroup() -{ - return displayGroup; -} - -UIViewGroup *MainCallingView::GetCallingGroup() -{ - return callingGroup; -} - -UIViewGroup *MainCallingView::GetScreenGroup() -{ - return screenGroup; -} - -UIViewGroup *MainCallingView::GetWaitingGroup() -{ - return waitingGroup; -} - -CallingView *MainCallingView::GetCallingView() -{ - return callView; -} - -bool MainCallingView::InitPointerValue() -{ - displayView = new CallerDisplayView(); - if (displayView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::displayView"); - return false; - } - - displayGroup = displayView->CreateUIViewGroup(); - if (displayGroup == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::displayGroup"); - return false; - } - - callView = new CallingView(); - if (callView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::callView"); - return false; - } - - callingGroup = callView->CreateUIViewGroup(); - if (callingGroup == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::callingGroup"); - return false; - } - - screenView = new DialingScreenView(); - if (screenView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::screenView"); - return false; - } - - screenGroup = screenView->CreateUIViewGroup(); - if (screenGroup == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::screenGroup"); - return false; - } - - waitingView = new WaitingHintsView(); - if (waitingView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::WaitingHintsView"); - return false; - } - - waitingGroup = waitingView->CreateUIViewGroup(); - if (waitingGroup == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::waitingGroup"); - return false; - } - return true; -} - -void MainCallingView::OnStart() -{ - - if (!InitPointerValue()) { - return; - } - - AddViewToRootContainer(displayGroup); - AddViewToRootContainer(callingGroup); - AddViewToRootContainer(screenGroup); - AddViewToRootContainer(waitingGroup); - - waitingGroup->SetVisible(false); - callingGroup->SetVisible(false); - if (CallerLogModel::GetInstance()->GetCallStatus()) { - displayGroup->SetVisible(false); - callingGroup->SetVisible(true); - screenGroup->SetVisible(false); - } else if (CallerLogModel::GetInstance()->GetWaitingStatus()) { - screenGroup->SetVisible(false); - displayGroup->SetVisible(false); - waitingGroup->SetVisible(true); - } else if (CallerLogModel::GetInstance()->GetPhoneStatus()) { - displayGroup->SetVisible(false); - } else { - screenGroup->SetVisible(false); - } - CallerLogModel::GetInstance()->SetVolumeScreenStatus(false); - if (CallerLogModel::GetInstance()->GetMulitplePhoneStatus()) { - MulitplePhoneTextReplaces(); - CallerLogModel::GetInstance()->SetMulitplePhoneStatus(false); - } - return; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/WaitingHintsView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/WaitingHintsView.cpp deleted file mode 100644 index 549e699f3..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/makephone/src/WaitingHintsView.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: WaitingHintsView.cpp - * Author: - * Create: 2022-03-14 - */ -#include "makephone/WaitingHintsView.h" -#include "UiConfig.h" -#include "callerlog/CallerLogModel.h" -#include "makephone/MainCallingPresenter.h" - -namespace OHOS { -static constexpr uint16 MATH_ZERO = 0; -// 挂断按钮位置 -static constexpr uint16 IMAGE_HANDUP_POSITION_X = 177; -static constexpr uint16 IMAGE_HANDUP_POSITION_Y = 270; - -// 新来电显示 -static constexpr uint16 LABEL_PERCENT_POSITION_X = 0; -static constexpr uint16 LABEL_PERCENT_POSITION_Y = 100; - -static constexpr uint16 VIEW_DISTANCE_TO_LEFT_SIDE = HORIZONTAL_RESOLUTION; -static constexpr uint16 TITLE_LABEL_DEFAULT_HEIGHT = 80; - -// 字体大小 -static constexpr uint16 LABEL_DISPLAY_FONE_SIZE = 40; - -// 标签坐标 -static constexpr uint16 LABEL_CALLERD_POSITION_X = 0; -static constexpr uint16 LABEL_CALLERD_POSITION_Y = 180; - -static WaitingHintsView *g_pMainView = nullptr; -WaitingHintsView::WaitingHintsView() -{ - g_pMainView = this; -} - -WaitingHintsView::~WaitingHintsView() -{ - g_pMainView = nullptr; -} - -UIViewGroup *WaitingHintsView::CreateUIViewGroup() -{ - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WaitingHintsView::new group error"); - return nullptr; - } - group->SetPosition(MATH_ZERO, MATH_ZERO); - group->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); // 454 : value - - if (!InitImageViewDisplay()) { - return nullptr; - } - if (!InitUILabelDisplay()) { - return nullptr; - } - return group; -} - -WaitingHintsView *WaitingHintsView::GetInstance() -{ - return g_pMainView; -} - -bool WaitingHintsView::InitImageViewDisplay() -{ - imageDissgree = new UIImageView(); - if (imageDissgree == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WaitingHintsView::new imageDissgree error"); - return false; - } - imageDissgree->SetPosition(IMAGE_HANDUP_POSITION_X, IMAGE_HANDUP_POSITION_Y); // 30 : offset - imageDissgree->SetSrc(PNG_DISSGREE_IMAGE_PATH); - imageDissgree->SetTouchable(true); - imageDissgree->SetViewId("hintsHandup"); - - clickLeftListener = (UIView::OnClickListener*)OHOS::MainCallingPresenter::GetInstance(); - if (clickLeftListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WaitingHintsView::new clickLeftListener error"); - return false; - } - imageDissgree->SetOnClickListener(clickLeftListener); - group->Add(imageDissgree); - return true; -} - -bool WaitingHintsView::InitUILabelDisplay() -{ - callerDisplay = new UILabel(); - if (callerDisplay == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WaitingHintsView::new callerDisplay error"); - return false; - } - callerDisplay->SetPosition(LABEL_PERCENT_POSITION_X, LABEL_PERCENT_POSITION_Y, - VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); - callerDisplay->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - callerDisplay->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); - callerDisplay->SetAlign(TEXT_ALIGNMENT_CENTER); - callerDisplay->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_DISPLAY_FONE_SIZE); - callerDisplay->SetTextColor(Color::White()); - group->Add(callerDisplay); - - newcallHints = new UILabel(); - if (newcallHints == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WaitingHintsView::new newcallHints error"); - return false; - } - newcallHints->SetPosition(LABEL_CALLERD_POSITION_X, LABEL_CALLERD_POSITION_Y, - VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); - newcallHints->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - newcallHints->SetText("新来电"); - newcallHints->SetAlign(TEXT_ALIGNMENT_CENTER); - newcallHints->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_DISPLAY_FONE_SIZE); - newcallHints->SetTextColor(Color::White()); - group->Add(newcallHints); - return true; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/player/src/BluetoothView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/player/src/BluetoothView.cpp deleted file mode 100644 index b05219ea4..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/player/src/BluetoothView.cpp +++ /dev/null @@ -1,356 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: bluetooth view 设置页面 - * Create: 2021-09-5 - */ -#include "player/BluetoothView.h" -#include "player/PlayersView.h" -#include "UiConfig.h" -#include "bluetooth/BluetoothEarPhoneView.h" -#include "player/PlayersPresenter.h" - -namespace OHOS { -static BluetoothView *g_bluetoothView{nullptr}; -static constexpr uint16_t TEXT_WIDTH = 155; -static constexpr uint16_t TEXT_HEIGHT = 40; -static constexpr uint16_t HEIGHT = 55; -static constexpr uint16_t HEIGHT2 = 75; -static constexpr uint16_t WIDTH = 55; -static constexpr uint16_t WIDTH2 = 75; -static constexpr uint16_t BUTTON_WIDTH = 180; -static constexpr uint16_t BUTTON_HEIGHT = 40; - -constexpr uint16_t BLUETOOTH_OK = 0; -constexpr int16_t BLUETOOTH_ERROR = (-1); - -static constexpr uint16_t IMAGE_X = 50; -static constexpr uint16_t IMAGE_Y = 98; -static constexpr uint16_t IMAGE_Y2 = 187; -static constexpr uint16_t IMAGE_Y3 = 278; -static constexpr uint16_t STEP_LABEL_X = 155; -static constexpr uint16_t BUTTON_X = 320; -static constexpr uint16_t BUTTON_X2 = 313; -static constexpr uint16_t BUTTON_X3 = 135; -static constexpr uint16_t BUTTON_Y = 104; -static constexpr uint16_t BUTTON_Y2 = 194; -static constexpr uint16_t BUTTON_Y3 = 278; -static constexpr uint16_t BUTTON_Y4 = 402; -static constexpr uint16_t STEP_LABEL_Y = 108; -static constexpr uint16_t STEP_LABEL_Y2 = 199; -static constexpr uint16_t STEP_LABEL_Y3 = 290; - -BluetoothView::BluetoothView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothView::BluetoothView"); - g_bluetoothView = this; -} - -BluetoothView::~BluetoothView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothView::~BluetoothView"); - group->RemoveAll(); - UIView::OnClickListener *click = watchButton->GetOnClickListener(); - if (click != nullptr) { - delete click; - } - delete watchButton; - watchButton = nullptr; - click = phoneButton->GetOnClickListener(); - if (click != nullptr) { - delete click; - } - delete phoneButton; - phoneButton = nullptr; - delete settingButton; - settingButton = nullptr; - click = deleteButton->GetOnClickListener(); - if (click != nullptr) { - delete click; - } - click = nullptr; - delete deleteButton; - deleteButton = nullptr; - delete watchLabel; - watchLabel = nullptr; - delete phoneLabel; - phoneLabel = nullptr; - delete bluetoothLabel; - bluetoothLabel = nullptr; - delete watchImage; - watchImage = nullptr; - delete phoneImage; - phoneImage = nullptr; - delete bluetoothImage; - bluetoothImage = nullptr; - delete group; - group = nullptr; - g_bluetoothView = nullptr; -} - -BluetoothView *BluetoothView::GetInstance(void) -{ - return g_bluetoothView; -} - -UIButton *BluetoothView::GetSettingButton(void) -{ - return settingButton; -} - -UILabelButton *BluetoothView::GetDeleteButton(void) -{ - return deleteButton; -} - -UIRadioButton *BluetoothView::GetWatchButton(void) -{ - return watchButton; -} - -UIRadioButton *BluetoothView::GetPhoneButton(void) -{ - return phoneButton; -} - -// Button OnClick -class BluetoothOnClickListener : public UIView::OnClickListener { -public: - explicit BluetoothOnClickListener(UIView* view) : view_(view) {} - ~BluetoothOnClickListener() {} - - bool OnClick(UIView& view, const ClickEvent& event) override - { - UNUSED(view); - UNUSED(event); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothOnClickListener OnClick"); - BluetoothView *bluetoothView = BluetoothView::GetInstance(); - if (bluetoothView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothView is nullptr"); - return false; - } - if (view_ == (UIView *)bluetoothView->GetWatchButton()) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "watchButton OnClick"); - } else if (view_ == (UIView *)bluetoothView->GetPhoneButton()) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "phoneButton OnClick"); - } else if (view_ == (UIView *)bluetoothView->GetSettingButton()) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "settingButton OnClick"); - JumpView *jumpView = JumpView::GetInstance(); - if (jumpView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "jumpView GetInstance fail"); - return false; - } - jumpView->ChangeView(JumpView::BluetoothJumpViewNum::BLUETOOTHEVIEW, - JumpView::BluetoothJumpViewNum::BLUETOOTHEARPHONEVIEW); - } else if (view_ == (UIView *)bluetoothView->GetDeleteButton()) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "deleteButton OnClick"); - } - return true; - } -private: - UIView *view_ = nullptr; -}; - -void BluetoothView::SetUpButton(UILabelButton *btn, const Point& point, - int16_t width, int16_t height, UIView::OnClickListener *listener) -{ - if (btn == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "btn null!"); - return; - } - btn->SetPosition(point.x, point.y, width, height); - btn->SetOnClickListener(listener); -} - -int BluetoothView::LoadRadioButton() -{ - if (watchButton == nullptr) { - watchButton = new UIRadioButton("MusicCategory"); - if (watchButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "watchButton UIRadio new fail"); - return BLUETOOTH_ERROR; - } - } - if (phoneButton == nullptr) { - phoneButton = new UIRadioButton("MusicCategory"); - if (phoneButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneButton UIRadio new fail"); - return BLUETOOTH_ERROR; - } - } - UIView::OnClickListener *listener1 = new BluetoothOnClickListener(reinterpret_cast(watchButton)); - if (listener1 == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "listener1 new fail"); - return BLUETOOTH_ERROR; - } - watchButton->SetPosition(BUTTON_X, BUTTON_Y, WIDTH, HEIGHT); - watchButton->SetOnClickListener(listener1); - watchButton->SetTouchable(false); - UIView::OnClickListener *listener2 = new BluetoothOnClickListener(reinterpret_cast(phoneButton)); - if (listener2 == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "listener2 new fail"); - return BLUETOOTH_ERROR; - } - phoneButton->SetPosition(BUTTON_X, BUTTON_Y2, WIDTH, HEIGHT); - phoneButton->SetOnClickListener(listener2); - phoneButton->SetTouchable(false); - return BLUETOOTH_OK; -} - -int BluetoothView::LoadLabelButton() -{ - struct Point pointBtn; - // 跳转按钮 - pointBtn.x = BUTTON_X2; - pointBtn.y = BUTTON_Y3; - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::PlayersPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance fail"); - return BLUETOOTH_ERROR; - } - settingButton->SetPosition(pointBtn.x, pointBtn.y, WIDTH, HEIGHT); - settingButton->SetOnClickListener(clickListener); - settingButton->SetImageSrc(PNG_SETTTING_BUTTON_IMAGE, PNG_SETTTING_BUTTON_IMAGE); - settingButton->SetViewId(BLUETOOTH_SETTING_BUTTON); - // 删除按钮 - pointBtn.x = BUTTON_X3; - pointBtn.y = BUTTON_Y4; - UIView::OnClickListener *listener4 = new BluetoothOnClickListener(reinterpret_cast(deleteButton)); - if (listener4 == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "listener4 new fail"); - return BLUETOOTH_ERROR; - } - SetUpButton(deleteButton, pointBtn, BUTTON_WIDTH, BUTTON_HEIGHT, listener4); - deleteButton->SetText("删除音乐"); - deleteButton->SetVisible(false); - return BLUETOOTH_OK; -} - -int BluetoothView::LoadButtonView() -{ - if (LoadRadioButton() == BLUETOOTH_ERROR) { - return BLUETOOTH_ERROR; - } - if (settingButton == nullptr) { - settingButton = new UIButton(); - if (settingButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "settingButton UIButton new fail"); - return BLUETOOTH_ERROR; - } - } - if (deleteButton == nullptr) { - deleteButton = new UILabelButton(); - if (deleteButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "deleteButton UILabelButton new fail"); - return BLUETOOTH_ERROR; - } - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "LoadButtonView"); - if (LoadLabelButton() == BLUETOOTH_ERROR) { - return BLUETOOTH_ERROR; - } - return BLUETOOTH_OK; -} - -int BluetoothView::LoadLabel(void) -{ - // 标题文本 - if (watchLabel == nullptr) { - watchLabel = new UILabel(); - if (watchLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "watchLabel new fail"); - return BLUETOOTH_ERROR; - } - } - watchLabel->SetPosition(STEP_LABEL_X, STEP_LABEL_Y, TEXT_WIDTH, TEXT_HEIGHT); - watchLabel->SetText("手表音乐"); - watchLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_THIRTY_SIZE); - if (phoneLabel == nullptr) { - phoneLabel = new UILabel(); - if (phoneLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneLabel new fail"); - return BLUETOOTH_ERROR; - } - } - phoneLabel->SetPosition(STEP_LABEL_X, STEP_LABEL_Y2, TEXT_WIDTH, TEXT_HEIGHT); - phoneLabel->SetText("手机音乐"); - phoneLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_THIRTY_SIZE); - if (bluetoothLabel == nullptr) { - bluetoothLabel = new UILabel(); - if (bluetoothLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothLabel new fail"); - return BLUETOOTH_ERROR; - } - } - bluetoothLabel->SetPosition(STEP_LABEL_X, STEP_LABEL_Y3, TEXT_WIDTH, TEXT_HEIGHT); - bluetoothLabel->SetText("蓝牙音乐"); - bluetoothLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_THIRTY_SIZE); - return BLUETOOTH_OK; -} - -int BluetoothView::LoadImage(void) -{ - // 图片图标 - watchImage = new UIImageView(); - if (watchImage == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "watchImage new fail"); - return BLUETOOTH_ERROR; - } - watchImage->SetPosition(IMAGE_X, IMAGE_Y, WIDTH2, HEIGHT2); - watchImage->SetSrc(PNG_WATCH_IMAGE); - - phoneImage = new UIImageView(); - if (phoneImage == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneImage new fail"); - return BLUETOOTH_ERROR; - } - phoneImage->SetPosition(IMAGE_X, IMAGE_Y2, WIDTH2, HEIGHT2); - phoneImage->SetSrc(PNG_PHONE_IMAGE); - - bluetoothImage = new UIImageView(); - if (bluetoothImage == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothImage new fail"); - return BLUETOOTH_ERROR; - } - bluetoothImage->SetPosition(IMAGE_X, IMAGE_Y3, WIDTH2, HEIGHT2); - bluetoothImage->SetSrc(PNG_BLUETOOTH_IMAGE); - return BLUETOOTH_OK; -} - -UIViewGroup *BluetoothView::LoadBluetoothView() -{ - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - } - group->SetPosition(0, 0); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - LoadButtonView(); - LoadLabel(); - LoadImage(); - - group->Add(watchLabel); - group->Add(phoneLabel); - group->Add(bluetoothLabel); - group->Add(watchButton); - group->Add(phoneButton); - group->Add(settingButton); - group->Add(deleteButton); - group->Add(watchImage); - group->Add(phoneImage); - group->Add(bluetoothImage); - UIView::OnDragListener *earDragListener = (UIView::OnDragListener *)OHOS::PlayerOnDragListener::GetInstance(); - if (earDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "earDragListener GetInstance fail"); - return nullptr; - } - group->SetOnDragListener(earDragListener); - group->SetViewId(BLUETOOTH_VIEW); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/player/src/PlayersCaseListAdapter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/player/src/PlayersCaseListAdapter.cpp deleted file mode 100644 index 06775205a..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/player/src/PlayersCaseListAdapter.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: Player view - * Author: - * Create: 2021-07-26 - */ -#include -#include "player/PlayersCaseListAdapter.h" -#include "gfx_utils/list.h" -#include "player/PlayersView.h" -#include "player/PlayersPresenter.h" -#include "wearable_log.h" -#include "player/PlayersModel.h" - -namespace OHOS { -constexpr uint16_t TESTCASE_BUTTON_HEIGHT = 64; -constexpr uint16_t STYLE_BORDER_WIDTH_VALUE = 4; -constexpr uint16_t STYLE_BORDER_RADIUS_VALUE = 12; -static constexpr uint32 BUTTON_STYLE_BACKGROUND_COLOR_VALUE = 0xFF333333; - -PlayersCaseListAdapter::~PlayersCaseListAdapter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PlayersCaseListAdapter::~PlayersCaseListAdapter"); - delete listener; - listener = nullptr; -} - -uint16_t PlayersCaseListAdapter::GetCount() -{ - return PlayersListGroup::GetInstance()->GetCase().Size(); -} - -class BtnOnClickListListener : public UIView::OnClickListener { -public: - BtnOnClickListListener() {} - ~BtnOnClickListListener() {} - bool OnClick(UIView& view, const ClickEvent& event) override; - -private: - void BtnOnListData(UIView& view); - char *sliceId_{nullptr}; - int16_t index_{0}; -}; - -bool BtnOnClickListListener::OnClick(UIView& view, const ClickEvent& event) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BtnOnClickListListener sliceId_: %s.", sliceId_); - UNUSED(event); - int ret; - int32_t playerState; - uint8_t state = UICheckBox::UICheckBoxState::MAX_STATUS_NUM; - PlayersView *playersView = PlayersView::GetInstance(); - if (playersView == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "playersView null!"); - return false; - } - BtnOnListData(view); - // 标记当前播放歌曲index_ - PlayersModel::GetInstance()->SetCurrentIndex(index_); - // 本地播放文件路径和状态 - std::string strSrcMusic(APP_MUSIC_PATH); - std::string tempStr("/"); - std::string strName = sliceId_; - PlayersModel::GetInstance()->SetPlayerUri(strSrcMusic + tempStr + strName); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "uri: %s.", PlayersModel::GetInstance()->GetPlayerUri().c_str()); - std::string strSongName = sliceId_; - std::string pureName = strSongName.substr(0, strSongName.rfind(".")); - playersView->TitleSetText(pureName.c_str()); - playersView->SetPlayerListGroupStatus(false); - // 刷新UI - RootView::GetInstance()->Invalidate(); - - state = playersView->GetPlayerButtonState(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "state %d", state); - if (state == UICheckBox::UICheckBoxState::UNSELECTED) { - playersView->SetPlayerButtonState(UICheckBox::UICheckBoxState::SELECTED); - /* start play */ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "play"); - PlayersModel::GetInstance()->GetPlayerCtr()->GetPlayerState(playerState); - if (playerState == PlayerStates::PLAYER_PAUSED) { - ret = PlayersModel::GetInstance()->GetPlayerCtr()->Reset(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Reset, ret:%d", ret); - } - PlayersModel::GetInstance()->PlayerStat(); // 播放 - } else if (state == UICheckBox::UICheckBoxState::SELECTED) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "List to play"); - PlayersModel::GetInstance()->GetPlayerCtr()->GetPlayerState(playerState); - if (playerState == PlayerStates::PLAYER_STARTED) { - ret = PlayersModel::GetInstance()->GetPlayerCtr()->Stop(); // 停止 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Stop, ret:%d", ret); - ret = PlayersModel::GetInstance()->GetPlayerCtr()->Reset(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Reset, ret:%d", ret); - } - PlayersModel::GetInstance()->PlayerStat(); - } - return true; -} - -void BtnOnClickListListener::BtnOnListData(UIView& view) -{ - index_ = view.GetViewIndex(); - List &playersCaseList = PlayersListGroup::GetInstance()->GetCase(); - ListNode* node = playersCaseList.Begin(); - for (uint16_t i = 0; i < index_; i++) { - node = node->next_; - } - sliceId_ = node->data_.sliceId; -} - -void PlayersCaseListAdapter::LabelButtonSet() -{ - if (item == nullptr) { - return; - } - item->SetStyleForState(STYLE_BORDER_RADIUS, STYLE_BORDER_RADIUS_VALUE, UIButton::RELEASED); - item->SetStyleForState(STYLE_BORDER_RADIUS, STYLE_BORDER_RADIUS_VALUE, UIButton::PRESSED); - item->SetStyleForState(STYLE_BORDER_RADIUS, STYLE_BORDER_RADIUS_VALUE, UIButton::INACTIVE); - item->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::RELEASED); - item->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::PRESSED); - item->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::INACTIVE); -} - -UIView *PlayersCaseListAdapter::GetView(UIView* inView, int16_t index) -{ - List &playersCaseList = PlayersListGroup::GetInstance()->GetCase(); - if (playersCaseList.IsEmpty()) { - return nullptr; - } - if ((index > playersCaseList.Size() - 1) || (index < 0)) { - return nullptr; - } - if (inView == nullptr) { - item = new UILabelButton(); - if (item == nullptr) { - return nullptr; - } - item->SetPosition(0, 0); - item->SetStyleForState(STYLE_BORDER_WIDTH, STYLE_BORDER_WIDTH_VALUE, UIButton::RELEASED); - item->SetStyleForState(STYLE_BORDER_WIDTH, STYLE_BORDER_WIDTH_VALUE, UIButton::PRESSED); - item->SetStyleForState(STYLE_BORDER_WIDTH, STYLE_BORDER_WIDTH_VALUE, UIButton::INACTIVE); - item->SetStyleForState(STYLE_BORDER_OPA, 0, UIButton::RELEASED); - item->SetStyleForState(STYLE_BORDER_OPA, 0, UIButton::PRESSED); - item->SetStyleForState(STYLE_BORDER_OPA, 0, UIButton::INACTIVE); - item->Resize(HORIZONTAL_RESOLUTION, TESTCASE_BUTTON_HEIGHT); - } else { - item = static_cast(inView); - } - ListNode* node = playersCaseList.Begin(); - for (uint16_t i = 0; i < index; i++) { - node = node->next_; - } - if (listener == nullptr) { - listener = new BtnOnClickListListener(); - if (listener == nullptr) { - return nullptr; - } - item->SetOnClickListener(listener); - } else { - item->SetOnClickListener(listener); - } - std::string strSongName = node->data_.sliceId; - std::string pureName = strSongName.substr(0, strSongName.rfind(".")); - const char *songName = pureName.c_str(); - item->SetText(songName); - item->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24); // 24: means font size - item->SetViewIndex(index); - item->SetAlign(TEXT_ALIGNMENT_CENTER); - item->SetLabelPosition(24, 0); // 24: lable x-coordinate - LabelButtonSet(); - return item; -} -} // namespace OHOS diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/qrcode_conn/src/QrcodeConnModel.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/qrcode_conn/src/QrcodeConnModel.cpp deleted file mode 100644 index 2a78dc648..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/qrcode_conn/src/QrcodeConnModel.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: QrcodeConnModel.cpp - * Author: - * Create: 2025-04-24 - */ - -#include "qrcode_conn/QrcodeConnModel.h" - -namespace OHOS { -QrcodeConnModel::QrcodeConnModel() {} - -QrcodeConnModel::~QrcodeConnModel() {} - -QrcodeConnModel &QrcodeConnModel::GetInstance() -{ - static QrcodeConnModel instance; - return instance; -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/qrcode_conn/src/QrcodeConnPresenter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/qrcode_conn/src/QrcodeConnPresenter.cpp deleted file mode 100644 index cf94db4d2..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/qrcode_conn/src/QrcodeConnPresenter.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: QrcodeConnPresenter.cpp - * Author: - * Create: 2025-04-24 - */ -#include "qrcode_conn/QrcodeConnPresenter.h" -#include "uiservice/ui_service.h" -#include "NativeRegisterManager.h" - -namespace OHOS { - -REGIST_MENU(VIEW_QRCODE_CONN, QrcodeConnView, QrcodeConnPresenter, PNG_APPLIST_UI_SAMPLE_IMAGE, PNG_APPLIST_DEFAULT_IMG, - "二维码连接"); - -static QrcodeConnPresenter *g_QrcodeConnPresenter = nullptr; - -QrcodeConnPresenter::QrcodeConnPresenter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "QrcodeConnPresenter::QrcodeConnPresenter"); - g_QrcodeConnPresenter = this; -} - -QrcodeConnPresenter::~QrcodeConnPresenter() {} - -QrcodeConnPresenter *QrcodeConnPresenter::GetInstance() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "QrcodeConnPresenter GetInstance"); - return g_QrcodeConnPresenter; -} - -bool QrcodeConnPresenter::OnDrag(UIView &view, const DragEvent &event) -{ - std::string id = view.GetViewId(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "QrcodeConnPresenter::OnDrag [%s]", id.c_str()); - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); - return false; -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/qrcode_conn/src/QrcodeConnView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/qrcode_conn/src/QrcodeConnView.cpp deleted file mode 100644 index 02efc59b7..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/qrcode_conn/src/QrcodeConnView.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: QrcodeConnView.cpp - * Author: - * Create: 2025-04-24 - */ - -#include "qrcode_conn/QrcodeConnView.h" -#include "qrcode_conn/QrcodeConnPresenter.h" -#include "qrcode_conn/QrcodeConnModel.h" -#include "bluetooth/BluetoothModel.h" -#include "wearable_log.h" - -namespace OHOS { -static const uint32_t QRCODE_POS_X = 76; -static const uint32_t QRCODE_POS_Y = 76; -static const uint32_t QRCODE_WIDTH = 282; -static const uint32_t QRCODE_HEIGHT = 282; -static const uint32_t PAD_SIZE = 10; - -static QrcodeConnView *g_pQrcodeConnView = nullptr; - -QrcodeConnView::QrcodeConnView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "QrcodeConnView::QrcodeConnView"); - g_pQrcodeConnView = this; -} - -QrcodeConnView::~QrcodeConnView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "QrcodeConnView::~QrcodeConnView"); - g_pQrcodeConnView = nullptr; -} - -QrcodeConnView *QrcodeConnView::GetInstance() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "QrcodeConnView::GetInstance"); - return g_pQrcodeConnView; -} - -void QrcodeConnView::InitView() -{ - if (group_ == nullptr) { - group_ = new UIScrollView(); - group_->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - group_->SetStyle(STYLE_BACKGROUND_OPA, 0); - } - if (qrcode_ == nullptr) { - qrcode_ = new UIQrcode(); - } - qrcode_->SetPosition(QRCODE_POS_X, QRCODE_POS_Y, QRCODE_WIDTH, QRCODE_HEIGHT); - qrcode_->SetQrcodeInfo(BluetoothModel::GetInstance()->getWatchName()); - qrcode_->SetStyle(STYLE_PADDING_LEFT, PAD_SIZE); - qrcode_->SetStyle(STYLE_PADDING_RIGHT, PAD_SIZE); - qrcode_->SetStyle(STYLE_PADDING_TOP, PAD_SIZE); - qrcode_->SetStyle(STYLE_PADDING_BOTTOM, PAD_SIZE); - group_->Add(qrcode_); - UIView::OnDragListener *dragListener = (UIView::OnDragListener *)OHOS::QrcodeConnPresenter::GetInstance(); - group_->SetOnDragListener(dragListener); - // 更新 - group_->SetVisible(true); - AddViewToRootContainer(group_); - GetRootContainer()->Invalidate(); -} - -void QrcodeConnView::DeInit() -{ - if (group_ != nullptr) { - group_->RemoveAll(); - delete group_; - group_ = nullptr; - } - if (qrcode_ != nullptr) { - delete qrcode_; - qrcode_ = nullptr; - } -} - -void QrcodeConnView::OnStart() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "QrcodeConnView::OnStart"); - InitView(); -} - -void QrcodeConnView::OnStop() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "QrcodeConnView::OnStop"); - DeInit(); - return; -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/rebootdevice/src/RebootDeviceView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/rebootdevice/src/RebootDeviceView.cpp deleted file mode 100644 index 60dad05ba..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/rebootdevice/src/RebootDeviceView.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: RebootDevice View - * Create: 2022-04-28 - */ - -#include "rebootdevice/RebootDeviceView.h" -#include "PageTransitionMgr.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "rebootdevice/RebootPresenter.h" - -namespace OHOS { -static RebootDeviceView *g_pRebootDeviceView{nullptr}; -RebootDeviceView::RebootDeviceView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootDeviceView::RebootDeviceView"); - g_pRebootDeviceView = this; -} - -RebootDeviceView::~RebootDeviceView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootDeviceView::~RebootDeviceView"); - if (group != nullptr) { - group->RemoveAll(); - } - delete rebootDeviceLabel; - rebootDeviceLabel = nullptr; - delete rebootDeviceButton; - rebootDeviceButton = nullptr; - delete group; - group = nullptr; - g_pRebootDeviceView = nullptr; -} - -RebootDeviceView *RebootDeviceView::GetInstance() -{ - return g_pRebootDeviceView; -} - -bool RebootDeviceView::ShowUpRebootDeviceView() -{ - if (rebootDeviceLabel == nullptr) { - rebootDeviceLabel = new UILabel(); - if (rebootDeviceLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpRebootDeviceView rebootDeviceLabel new fail"); - return false; - } - } - rebootDeviceLabel->SetPosition(152, 272, 150, 45); // 152:x 272:y 150:width 45:height - rebootDeviceLabel->SetText("重启"); - rebootDeviceLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); // 35:font data - rebootDeviceLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - rebootDeviceLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - - if (rebootDeviceButton == nullptr) { - rebootDeviceButton = new UIButton(); - if (rebootDeviceButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpRebootDeviceView rebootDeviceButton new fail"); - return false; - } - } - rebootDeviceButton->SetPosition(172, 147, 110, 110); // 172:x 147:y 110:width 110:height - rebootDeviceButton->SetImageSrc(PNG_REBOOT_BUTTON_IMAGE, PNG_REBOOT_BUTTON_IMAGE); - rebootDeviceButton->SetViewId(REBOOTDEVICE_BUTTON); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::RebootPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance nullptr"); - return false; - } - rebootDeviceButton->SetOnClickListener(clickListener); - return true; -} - -UIViewGroup *RebootDeviceView::InitShowUpView(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootDeviceView::InitShowUpView"); - bool ret; - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); // 0:x; 0:y - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - ret = ShowUpRebootDeviceView(); - if (!ret) { - return nullptr; - } - group->Add(rebootDeviceLabel); - group->Add(rebootDeviceButton); - - UIView::OnDragListener *rebootDeviceDragListener = (UIView::OnDragListener *)OHOS::RebootPresenter::GetInstance(); - if (rebootDeviceDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootDeviceDragListener GetInstance fail"); - return nullptr; - } - if (!PageTransitionMgr::GetInstance().CanSlideBack()) { // support default slide back firstly - group->SetOnDragListener(rebootDeviceDragListener); - } - group->SetViewId(REBOOTDEVICE_VIEW); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/rebootdevice/src/RebootModel.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/rebootdevice/src/RebootModel.cpp deleted file mode 100644 index 889715b37..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/rebootdevice/src/RebootModel.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Reboot Model - * Create: 2022-04-28 - */ - -#include "rebootdevice/RebootModel.h" -#include "dfx_reboot.h" - -namespace OHOS { -RebootModel::RebootModel() {} - -RebootModel::~RebootModel() {} - -RebootModel *RebootModel::GetInstance(void) -{ - static RebootModel instance; - return &instance; -} - -int16_t RebootModel::GetSelectView(void) -{ - return selectView; -} - -void RebootModel::SetSelectViewId(int16_t value) -{ - selectView = value; -} - -bool RebootModel::GetExitsView(void) -{ - return exitsView; -} - -void RebootModel::SetExitsView(bool value) -{ - exitsView = value; -} - -void RebootModel::SoftRebootDevice(void) -{ - uapi_system_reboot(SYSTEM_SOFT_REBOOT); -} - -void RebootModel::ShutdownDevice(void) -{ - uapi_system_shutdown(0); -} - -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/rebootdevice/src/RebootPresenter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/rebootdevice/src/RebootPresenter.cpp deleted file mode 100644 index 223e102dd..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/rebootdevice/src/RebootPresenter.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Reboot Presenter - * Create: 2022-04-28 - */ - -#include "rebootdevice/RebootPresenter.h" -#include "rebootdevice/RebootView.h" -#include "rebootdevice/RebootModel.h" -#include "drag_event.h" -#include "wearable_log.h" -#include "NativeRegisterManager.h" - -namespace OHOS { - -REGIST_SLICE(VIEW_REBOOT, RebootView, RebootPresenter); - -static RebootPresenter *g_pRebootPresenter = nullptr; - -RebootPresenter::RebootPresenter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootPresenter::RebootPresenter"); - g_pRebootPresenter = this; -} - -RebootPresenter::~RebootPresenter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootPresenter::~RebootPresenter"); - g_pRebootPresenter = nullptr; -} - -RebootPresenter *RebootPresenter::GetInstance() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootPresenter GetInstance"); - return g_pRebootPresenter; -} - -bool RebootPresenter::OnClick(UIView& view, const ClickEvent& event) -{ - UNUSED(event); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnClick OnClick"); - if (strcmp(view.GetViewId(), REBOOT_BUTTON) == 0) { - RebootView::GetInstance()->ChangeView(REBOOTVIEW, REBOOTDEVICEVIEW); - } else if (strcmp(view.GetViewId(), SHUTDOWN_BUTTON) == 0) { - RebootView::GetInstance()->ChangeView(REBOOTVIEW, SHUTDOWNDEVICEVIEW); - } else if (strcmp(view.GetViewId(), REBOOTDEVICE_BUTTON) == 0) { - // 重启 - - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "REBOOTDEVICE_BUTTON OnClick"); - RebootModel::GetInstance()->SoftRebootDevice(); - } else if (strcmp(view.GetViewId(), SHUTDOWNDEVICE_BUTTON) == 0) { - // 关机 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SHUTDOWNDEVICE_BUTTON OnClick"); - RebootModel::GetInstance()->ShutdownDevice(); - } - return true; -} - -bool RebootPresenter::OnDrag(UIView& view, const DragEvent& event) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootPresenter::OnDrag"); - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { - if (strcmp(view.GetViewId(), REBOOT_VIEW) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE); - } else if (strcmp(view.GetViewId(), REBOOTDEVICE_VIEW) == 0) { - if (RebootModel::GetInstance()->GetExitsView() == 0) { - RebootView::GetInstance()->ChangeView(REBOOTDEVICEVIEW, REBOOTVIEW); - } else { - NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); - RebootModel::GetInstance()->SetExitsView(false); - } - } else if (strcmp(view.GetViewId(), SHUTDOWNDEVICE_VIEW) == 0) { - if (RebootModel::GetInstance()->GetExitsView() == 0) { - RebootView::GetInstance()->ChangeView(SHUTDOWNDEVICEVIEW, REBOOTVIEW); - } else { - NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); - RebootModel::GetInstance()->SetExitsView(false); - } - } - } - return true; -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/rebootdevice/src/RebootView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/rebootdevice/src/RebootView.cpp deleted file mode 100644 index 5c7956474..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/rebootdevice/src/RebootView.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Reboot View - * Create: 2022-04-28 - */ - -#include "rebootdevice/RebootView.h" -#include "PageTransitionMgr.h" -#include "rebootdevice/RebootModel.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "rebootdevice/RebootPresenter.h" - -namespace OHOS { -static RebootView *g_pRebootView{nullptr}; -RebootView::RebootView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::RebootView"); - preProcessView[REBOOTVIEW] = &RebootView::ChangeRebootView; - preProcessView[REBOOTDEVICEVIEW] = &RebootView::ChangeRebootDeviceView; - preProcessView[SHUTDOWNDEVICEVIEW] = &RebootView::ChangeShutdownDeviceView; - g_pRebootView = this; -} - -RebootView::~RebootView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::~RebootView"); - if (group != nullptr) { - group->RemoveAll(); - } - delete rebootLabel; - rebootLabel = nullptr; - delete rebootButton; - rebootButton = nullptr; - delete shutdownLabel; - shutdownLabel = nullptr; - delete shutdownButton; - shutdownButton = nullptr; - delete group; - group = nullptr; - g_pRebootView = nullptr; -} - -RebootView *RebootView::GetInstance() -{ - return g_pRebootView; -} - -void RebootView::OnStart() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::~OnStart"); - if (RebootModel::GetInstance()->GetSelectView() == REBOOT) { - ChangeView(REBOOT_MAX, REBOOTVIEW); - } else if (RebootModel::GetInstance()->GetSelectView() == REBOOTDEVICE) { - ChangeView(REBOOT_MAX, REBOOTDEVICEVIEW); - RebootModel::GetInstance()->SetSelectViewId(REBOOT); - } else if (RebootModel::GetInstance()->GetSelectView() == SHUTDOWNDEVICE) { - ChangeView(REBOOT_MAX, SHUTDOWNDEVICEVIEW); - RebootModel::GetInstance()->SetSelectViewId(REBOOT); - } - return; -} - -bool RebootView::ShowUpRebootView() -{ - if (rebootLabel == nullptr) { - rebootLabel = new UILabel(); - if (rebootLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpRebootView rebootLabel new fail"); - return false; - } - } - rebootLabel->SetPosition(49, 272, 150, 45); // 49:x 272:y 150:width 45:height - rebootLabel->SetText("重启"); - rebootLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); // 35:font data - rebootLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - rebootLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - - if (rebootButton == nullptr) { - rebootButton = new UIButton(); - if (rebootButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpRebootView rebootButton new fail"); - return false; - } - } - rebootButton->SetPosition(69, 147, 110, 110); // 69:x 147:y 110:width 110:height - rebootButton->SetImageSrc(PNG_REBOOT_BUTTON_IMAGE, PNG_REBOOT_BUTTON_IMAGE); - rebootButton->SetViewId(REBOOT_BUTTON); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::RebootPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance nullptr"); - return false; - } - rebootButton->SetOnClickListener(clickListener); - return true; -} - -bool RebootView::ShowUpShutdownView() -{ - if (shutdownLabel == nullptr) { - shutdownLabel = new UILabel(); - if (shutdownLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpShutdownView shutdownLabel new fail"); - return false; - } - } - shutdownLabel->SetPosition(255, 272, 150, 45); // 255:x 272:y 150:width 45:height - shutdownLabel->SetText("关机"); - shutdownLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); // 35:font data - shutdownLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - shutdownLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - - if (shutdownButton == nullptr) { - shutdownButton = new UIButton(); - if (shutdownButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpShutdownView shutdownButton new fail"); - return false; - } - } - shutdownButton->SetPosition(275, 147, 110, 110); // 275:x 147:y 110:width 110:height - shutdownButton->SetImageSrc(PNG_SHUTDOWN_BUTTON_IMAGE, PNG_SHUTDOWN_BUTTON_IMAGE); - shutdownButton->SetViewId(SHUTDOWN_BUTTON); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::RebootPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance nullptr"); - return false; - } - shutdownButton->SetOnClickListener(clickListener); - return true; -} - -UIViewGroup *RebootView::InitShowUpView(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::InitShowUpView"); - bool ret; - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); // 0:x; 0:y - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - ret = ShowUpRebootView(); - if (!ret) { - return nullptr; - } - group->Add(rebootLabel); - group->Add(rebootButton); - - ret = ShowUpShutdownView(); - if (!ret) { - return nullptr; - } - group->Add(shutdownLabel); - group->Add(shutdownButton); - UIView::OnDragListener *rebootDragListener = (UIView::OnDragListener *)OHOS::RebootPresenter::GetInstance(); - if (rebootDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootDragListener GetInstance fail"); - return nullptr; - } - if (!PageTransitionMgr::GetInstance().CanSlideBack()) { // support default slide back firstly - group->SetOnDragListener(rebootDragListener); - } - group->SetViewId(REBOOT_VIEW); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} - -bool RebootView::ChangeRebootView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - // init view - UIViewGroup *viewGroup = InitShowUpView(); - if (viewGroup == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "viewGroup nullptr fail"); - return false; - } - container[thisView] = viewGroup; - AddViewToRootContainer(container[thisView]); - return true; -} - -bool RebootView::ChangeRebootDeviceView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeRebootDeviceView"); - rebootDeviceView = new RebootDeviceView(); - if (rebootDeviceView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootDeviceView new fail"); - return false; - } - // init view - UIViewGroup *viewGroup = rebootDeviceView->InitShowUpView(); - if (viewGroup == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "viewGroup nullptr fail"); - return false; - } - container[thisView] = viewGroup; - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool RebootView::ChangeShutdownDeviceView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeShutdownDeviceView"); - shutdownDeviceView = new ShutdownDeviceView(); - if (shutdownDeviceView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutdownDeviceView new fail"); - return false; - } - // init view - UIViewGroup *viewGroup = shutdownDeviceView->InitShowUpView(); - if (viewGroup == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "viewGroup nullptr fail"); - return false; - } - container[thisView] = viewGroup; - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool RebootView::CheckViewParam(int16_t hideView, int16_t showView) -{ - if (showView < 0 || showView >= REBOOT_MAX) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootView::CheckViewParam showView err."); - return false; - } - - if (hideView < 0 || hideView > REBOOT_MAX) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootView::CheckViewParam hideView err."); - return false; - } - - return true; -} - -void RebootView::ChangeView(int16_t hideView, int16_t showView) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::ChangeView %d, %d", hideView, showView); - - if (!CheckViewParam(hideView, showView)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootView::CheckViewParam failed."); - return; - } - - PreprosssChangeView tmpPreProcessView = preProcessView[showView]; - - if (!(this->*tmpPreProcessView)(hideView, showView)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootView::ChangeView %d %dfailed", showView, hideView); - return; - } - if (hideView != REBOOT_MAX) { - if (container[hideView] == nullptr) { - return; - } - container[hideView]->SetVisible(false); - } - container[showView]->SetVisible(true); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView:: ChangeView end!!!%d", showView); - Draw(); -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/rebootdevice/src/ShutdownDeviceView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/rebootdevice/src/ShutdownDeviceView.cpp deleted file mode 100644 index f2acf7ea8..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/rebootdevice/src/ShutdownDeviceView.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: ShutdownDevice View - * Create: 2022-04-28 - */ - -#include "rebootdevice/ShutdownDeviceView.h" -#include "PageTransitionMgr.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "rebootdevice/RebootPresenter.h" - -namespace OHOS { -static ShutdownDeviceView *g_pShutdownDeviceView{nullptr}; -ShutdownDeviceView::ShutdownDeviceView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShutdownDeviceView::ShutdownDeviceView"); - g_pShutdownDeviceView = this; -} - -ShutdownDeviceView::~ShutdownDeviceView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShutdownDeviceView::~ShutdownDeviceView"); - if (group != nullptr) { - group->RemoveAll(); - } - delete shutdownDeviceLabel; - shutdownDeviceLabel = nullptr; - delete shutdownDeviceButton; - shutdownDeviceButton = nullptr; - delete group; - group = nullptr; - g_pShutdownDeviceView = nullptr; -} - -ShutdownDeviceView *ShutdownDeviceView::GetInstance() -{ - return g_pShutdownDeviceView; -} - -bool ShutdownDeviceView::ShowUpShutdownDeviceView() -{ - if (shutdownDeviceLabel == nullptr) { - shutdownDeviceLabel = new UILabel(); - if (shutdownDeviceLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpShutdownDeviceView shutdownDeviceLabel new fail"); - return false; - } - } - shutdownDeviceLabel->SetPosition(152, 272, 150, 45); // 152:x 272:y 150:width 45:height - shutdownDeviceLabel->SetText("关机"); - shutdownDeviceLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); // 35:font data - shutdownDeviceLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - shutdownDeviceLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - - if (shutdownDeviceButton == nullptr) { - shutdownDeviceButton = new UIButton(); - if (shutdownDeviceButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpShutdownDeviceView shutdownDeviceButton new fail"); - return false; - } - } - shutdownDeviceButton->SetPosition(172, 147, 110, 110); // 172:x 147:y 110:width 110:height - shutdownDeviceButton->SetImageSrc(PNG_SHUTDOWN_BUTTON_IMAGE, PNG_SHUTDOWN_BUTTON_IMAGE); - shutdownDeviceButton->SetViewId(SHUTDOWNDEVICE_BUTTON); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::RebootPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance nullptr"); - return false; - } - shutdownDeviceButton->SetOnClickListener(clickListener); - return true; -} - -UIViewGroup *ShutdownDeviceView::InitShowUpView(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShutdownDeviceView::InitShowUpView"); - bool ret; - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); // 0:x; 0:y - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - - ret = ShowUpShutdownDeviceView(); - if (!ret) { - return nullptr; - } - group->Add(shutdownDeviceLabel); - group->Add(shutdownDeviceButton); - UIView::OnDragListener *rebootDragListener = (UIView::OnDragListener *)OHOS::RebootPresenter::GetInstance(); - if (rebootDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootDragListener GetInstance fail"); - return nullptr; - } - if (!PageTransitionMgr::GetInstance().CanSlideBack()) { // support default slide back firstly - group->SetOnDragListener(rebootDragListener); - } - group->SetViewId(SHUTDOWNDEVICE_VIEW); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardAdapter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardAdapter.cpp deleted file mode 100644 index 5d15eb63e..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardAdapter.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SetCardAdapter.cpp - * Author: - * Create: 2021-09-18 - */ - -#include "set_card/SetCardAdapter.h" - -namespace OHOS { -SetCardAdapter::SetCardAdapter() {} - -SetCardAdapter::~SetCardAdapter() -{ - listData_.clear(); -} - -uint16 SetCardAdapter::GetCount(void) -{ - return listData_.size(); -} - -void SetCardAdapter::ClearItem(void) -{ - listData_.clear(); -} - -UIView *SetCardAdapter::GetView(UIView *inView, int16 index) -{ - if (index >= (int16)listData_.size() || index < 0) { - return nullptr; - } - - std::list::iterator it = listData_.begin(); - for (int i = 0; i < index; i++) { - it++; - } - - SetCardItem *item = nullptr; - if (inView == nullptr) { - item = new SetCardItem(); - if (item == nullptr) { - return nullptr; - } - } else { - item = static_cast(inView); - } - - item->SetItemInfo(*it); - item->SetViewIndex(index); - item->SetOnClickListener(itemClickListener_); - return item; -} - -void SetCardAdapter::AddListItem(const CardInfo &item) -{ - listData_.push_back(item); -} -} // namespace OHOS diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardDeleteView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardDeleteView.cpp deleted file mode 100644 index f37a50d36..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardDeleteView.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved. - * Description. - * Author: - * Create: - */ - -#include "UiConfig.h" -#include -#include "set_card/SetCardDeleteView.h" -#include "wearable_log.h" - -namespace OHOS { - -SetCardDeleteView::SetCardDeleteView(SetCardPresenter *presenter) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardDeleteView::SetCardDeleteView"); - presenter_ = presenter; - SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - InitView(); - Add(&confirmBtn); - Add(&cancelBtn); -} - -SetCardDeleteView::~SetCardDeleteView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardDeleteView::~SetCardDeleteView"); - Remove(&confirmBtn); - Remove(&cancelBtn); -} - -bool SetCardDeleteView::InitView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardDeleteView::InitView"); - confirmBtn.SetPosition(184, 118); - confirmBtn.Resize(86, 50); - confirmBtn.SetViewId(SET_CARD_DEL_CONFIRM); - confirmBtn.SetText("删除"); - confirmBtn.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - confirmBtn.SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - confirmBtn.SetOnClickListener(presenter_); - - cancelBtn.SetPosition(186, 231); - cancelBtn.Resize(82, 50); - cancelBtn.SetViewId(SET_CARD_DEL_CANCEL); - cancelBtn.SetText("取消"); - cancelBtn.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - cancelBtn.SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - cancelBtn.SetOnClickListener(presenter_); - return true; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardItem.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardItem.cpp deleted file mode 100644 index 7d08205d9..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardItem.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "set_card/SetCardItem.h" -#include "set_card/SetCardPresenter.h" -#include "wearable_log.h" - -namespace OHOS { - SetCardItem::SetCardItem() - { - SetPosition(0, 0, 454, 280); - SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - SetUpChild(); - Add(&cardImg_); - } - - SetCardItem::~SetCardItem() - { - Remove(&cardImg_); - } - - void SetCardItem::SetUpChild() - { - cardImg_.SetPosition(87, 0); - cardImg_.Resize(280, 280); - cardImg_.SetResizeMode(UIImageView::FILL); - cardImg_.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); - } - - void SetCardItem::SetItemInfo(const CardInfo &cardInfo) - { - cardInfo_ = cardInfo; - cardImg_.SetSrc(cardInfo.cardImg); - cardImg_.SetViewId(SET_CARD_IMG); - } - - void SetCardItem::SetOnClickListener(OnClickListener *onClickListener) - { - cardImg_.SetOnClickListener(onClickListener); - cardImg_.SetTouchable(true); - } -}; diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardModel.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardModel.cpp deleted file mode 100644 index df4d971e3..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardModel.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SetCardModel.cpp - * Author: - * Create: 2021-11-23 - */ - -#include "set_card/SetCardModel.h" -#include "main/MainModel.h" -#include "kv_store.h" -#include "securec.h" - -namespace OHOS { - SetCardModel::SetCardModel() {} - - SetCardModel::~SetCardModel() {} - - SetCardModel &SetCardModel::GetInstance() - { - static SetCardModel instance; - return instance; - } - - void SetCardModel::InitCardShowList(void) - { - MainModel::GetInstance().InitCardSettings(); - uint8_t cardCount = MainModel::GetInstance().GetCardSettingCount(); - CardId *cardSettings = MainModel::GetInstance().GetCardSettings(); - cardShowCount = 0; - for (uint8_t i = 0; i < cardCount; i++) { - if (cardSettings[i] == WATCH_FACE) { - continue; - } - cardShowList[cardShowCount++] = cardSettings[i]; - } - } - - uint8_t *SetCardModel::GetCardShowList(void) - { - return cardShowList; - } - - uint8_t SetCardModel::GetCardShowCount(void) const - { - return cardShowCount; - } - - void SetCardModel::SetSelectedCardIndex(uint8_t cardIndex) - { - selectedCardIndex = cardIndex; - } - - uint8_t SetCardModel::GetSelectedCardIndex(void) const - { - return selectedCardIndex; - } - - void SetCardModel::DeleteCardSetting(void) - { - MainModel::GetInstance().DeleteCardSetting(selectedCardIndex); - } - - void SetCardModel::SetSelectedCard(uint8_t cardId) - { - selectedCardId = cardId; - } - - uint8_t SetCardModel::GetSelectedCard(void) - { - return selectedCardId; - } -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardNoCardView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardNoCardView.cpp deleted file mode 100644 index f09315818..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardNoCardView.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved. - * Description. - * Author: - * Create: - */ - -#include "UiConfig.h" -#include -#include "set_card/SetCardNoCardView.h" -#include "wearable_log.h" - -namespace OHOS { - -SetCardNoCardView::SetCardNoCardView(SetCardPresenter *presenter) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardNoCardView::SetCardNoCardView"); - presenter_ = presenter; - SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - InitView(); - Add(&addBtn); -} - -SetCardNoCardView::~SetCardNoCardView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardNoCardView::~SetCardNoCardView"); - Remove(&addBtn); -} - -bool SetCardNoCardView::InitView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardNoCardView::InitView"); - addBtn.SetPosition(184, 118); - addBtn.Resize(86, 50); - addBtn.SetViewId(SET_CARD_ADD); - addBtn.SetText("添加"); - addBtn.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - addBtn.SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - addBtn.SetOnClickListener(presenter_); - return true; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardPresenter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardPresenter.cpp deleted file mode 100644 index 0a93f42d8..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardPresenter.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SetCardPresenter.cpp - * Author: - * Create: 2021-11-23 - */ - -#include "set_card/SetCardView.h" -#include "set_card/SetCardModel.h" -#include "set_card/SetCardPresenter.h" -#include "hal_tick.h" -#include "NativeRegisterManager.h" - - -namespace OHOS { - -REGIST_SLICE(VIEW_SET_CARD, SetCardView, SetCardPresenter); - - SetCardPresenter::SetCardPresenter() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::SetCardPresenter"); - model = &SetCardModel::GetInstance(); - ResetTickTimer(); - } - - SetCardPresenter::~SetCardPresenter() - { - } - - bool SetCardPresenter::OnClick(UIView &view, const ClickEvent &event) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::OnClick"); - if (strcmp(view.GetViewId(), SET_CARD_ADD) == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::SET_CARD_ADD"); - NativeAbility::GetInstance().ChangeSlice(VIEW_ADD_CARD); - } else if (strcmp(view.GetViewId(), SET_CARD_DEL) == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::SET_CARD_DEL"); - view_->SaveSelectCardIndex(); - view_->ShowDeleteView(true); - } else if (strcmp(view.GetViewId(), SET_CARD_DEL_CONFIRM) == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::SET_CARD_DEL_CONFIRM"); - model->DeleteCardSetting(); - view_->ShowDeleteView(false); - view_->RefreshCardList(); - } else if (strcmp(view.GetViewId(), SET_CARD_DEL_CANCEL) == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::SET_CARD_DEL_CANCEL"); - view_->ShowDeleteView(false); - } else if (strcmp(view.GetViewId(), SET_CARD_IMG) == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::SET_CARD_IMG"); - GoToMainView(); - } - ResetTickTimer(); - return true; - } - - void SetCardPresenter::OnScrollStart(int16_t index, UIView *view) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::OnScrollStart index = %d", index); - return; - } - - void SetCardPresenter::OnScrollEnd(int16_t index, UIView *view) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::OnScrollEnd index = %d", index); - if (view == nullptr) { - return; - } - SetSelectedCardIndex(index); - ResetTickTimer(); - } - - void SetCardPresenter::OnItemSelected(int16_t index, UIView* view) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::OnItemSelected index = %d", index); - if (view == nullptr) { - return; - } - } - void SetCardPresenter::InitCardShowList(void) - { - model->InitCardShowList(); - } - - uint8_t *SetCardPresenter::GetCardShowList(void) - { - return model->GetCardShowList(); - } - - uint8_t SetCardPresenter::GetCardShowCount(void) const - { - return model->GetCardShowCount(); - } - - void SetCardPresenter::SetSelectedCard(uint8_t cardId) - { - model->SetSelectedCard(cardId); - } - - uint8_t SetCardPresenter::GetSelectedCard(void) - { - return model->GetSelectedCard(); - } - - void SetCardPresenter::SetSelectedCardIndex(uint8_t cardIndex) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::SetSelectedCardIndex %d", cardIndex); - model->SetSelectedCardIndex(cardIndex); - } - - void SetCardPresenter::GoToMainView(void) - { - uint8_t *cardSettings = model->GetCardShowList(); - uint8_t selectIndex = model->GetSelectedCardIndex(); - if (selectIndex < model->GetCardShowCount()) { - const CardInfo *info = MainModel::GetInstance().GetCardInfo(static_cast(cardSettings[selectIndex])); - if (info != nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::GoToMainView %d", info->id); - MainModel::GetInstance().SetFromSetCardView(true); - MainModel::GetInstance().SetFromCardId(info->id); - } - } - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE); - } - - void SetCardPresenter::OnTickEvent() - { - uint64_t current_time = static_cast(HALTick::GetInstance().GetTime()); - - if ((startTime != 0) && (current_time - startTime > MISS_SET_CARD_OPERATION_TIME)) { - GoToMainView(); - } - } - - void SetCardPresenter::ResetTickTimer(void) - { - startTime = static_cast(HALTick::GetInstance().GetTime()); - - } -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardView.cpp deleted file mode 100644 index b9d31c386..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_card/src/SetCardView.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SetCardView.cpp - * Author: - * Create: 2021-11-23 - */ - -#include -#include "set_card/SetCardView.h" -#include "set_card/SetCardPresenter.h" - -namespace OHOS { -SetCardView::SetCardView():contentList_(UIList::HORIZONTAL) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardView::SetCardView"); -} - -SetCardView::~SetCardView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardView::~SetCardView"); - if (deleteView_ != nullptr) { - delete deleteView_; - deleteView_ = nullptr; - } - - if (noCardView_ != nullptr) { - delete noCardView_; - noCardView_ = nullptr; - } - - if (setCardAdapter_ != nullptr) { - delete setCardAdapter_; - setCardAdapter_ = nullptr; - } -} - -void SetCardView::OnStart() -{ - setCardAdapter_ = new SetCardAdapter(); - setCardAdapter_->SetItemClickListener(presenter_); - SetUpListInfo(); - SetUpListView(); - SetUpDeleteView(); - SetUpAddView(); - ShowDeleteView(false); - if (setCardAdapter_->GetCount() == 0) { - ShowAddView(true); - } -} - -void SetCardView::SetUpListInfo(void) -{ - presenter_->InitCardShowList(); - uint8_t num = presenter_->GetCardShowCount(); - uint8_t *cardSettings = presenter_->GetCardShowList(); - uint8_t selectCardId = presenter_->GetSelectedCard(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetUpListInfo::selectCardId = %u", selectCardId); - setCardAdapter_->ClearItem(); - for (uint8_t i = 0; i < num; i++) { - const CardInfo *info = MainModel::GetInstance().GetCardInfo( - static_cast(cardSettings[i])); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetUpListInfo::%d %s", info->id, info->cardImg); - if (selectCardId == info->id) { - presenter_->SetSelectedCardIndex(i); - scrollIndex_ = i; - presenter_->SetSelectedCard(MAX_CARD); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetUpListInfo::scrollIndex_ = %u", scrollIndex_); - } - setCardAdapter_->AddListItem(*info); - } -} - -void SetCardView::SetUpListView(void) -{ - addImg_.SetPosition(187, 10); - addImg_.Resize(80, 80); - addImg_.SetResizeMode(UIImageView::FILL); - addImg_.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); - addImg_.SetSrc(PNG_SET_CARD_ADD); - addImg_.SetViewId(SET_CARD_ADD); - addImg_.SetVisible(false); - - contentList_.SetPosition(0, 92); - contentList_.Resize(HORIZONTAL_RESOLUTION, 280); - contentList_.SetScrollBlankSize(HORIZONTAL_RESOLUTION / 2); - contentList_.SetSelectPosition(HORIZONTAL_RESOLUTION / 2); - contentList_.SetDraggable(true); - contentList_.SetThrowDrag(true); - contentList_.EnableAutoAlign(true); - contentList_.SetScrollStateListener(presenter_); - contentList_.SetMaxScrollDistance(1000); - contentList_.SetAdapter(setCardAdapter_); - contentList_.SetVisible(false); - contentList_.ScrollTo(scrollIndex_); - - delImg_.SetPosition(187, 374); - delImg_.Resize(80, 80); - delImg_.SetResizeMode(UIImageView::FILL); - delImg_.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); - delImg_.SetSrc(PNG_SET_CARD_DEL); - delImg_.SetViewId(SET_CARD_DEL); - delImg_.SetVisible(false); - - addImg_.SetTouchable(true); - addImg_.SetOnClickListener(presenter_); - delImg_.SetTouchable(true); - delImg_.SetOnClickListener(presenter_); - - AddViewToRootContainer(&addImg_); - AddViewToRootContainer(&contentList_); - AddViewToRootContainer(&delImg_); -} - -void SetCardView::SetUpDeleteView(void) -{ - deleteView_ = new SetCardDeleteView(presenter_); - if (deleteView_ == nullptr) { - return; - } - deleteView_->SetVisible(false); - AddViewToRootContainer(deleteView_); -} - -void SetCardView::SetUpAddView(void) -{ - noCardView_ = new SetCardNoCardView(presenter_); - if (noCardView_ == nullptr) { - return; - } - noCardView_->SetVisible(false); - AddViewToRootContainer(noCardView_); -} - -void SetCardView::ShowCardListView(bool show) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardView::ShowCardListView %u", show); - if (show) { - addImg_.SetVisible(true); - contentList_.SetVisible(true); - delImg_.SetVisible(true); - } else { - addImg_.SetVisible(false); - contentList_.SetVisible(false); - delImg_.SetVisible(false); - } -} - -void SetCardView::ShowDeleteView(bool show) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardView::ShowDeleteView %u", show); - if (show) { - ShowCardListView(false); - deleteView_->SetVisible(true); - } else { - ShowCardListView(true); - deleteView_->SetVisible(false); - } -} - -void SetCardView::ShowAddView(bool show) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardView::ShowAddView %u", show); - if (show) { - ShowCardListView(false); - noCardView_->SetVisible(true); - } else { - ShowCardListView(true); - noCardView_->SetVisible(false); - } -} - -void SetCardView::RefreshCardList(void) -{ - contentList_.RemoveAll(); - SetUpListInfo(); - contentList_.RefreshList(); - if (setCardAdapter_->GetCount() == 0) { - ShowAddView(true); - } -} - -void SetCardView::SaveSelectCardIndex(void) -{ - uint8_t cardIdex = contentList_.GetSelectView()->GetViewIndex(); - presenter_->SetSelectedCardIndex(cardIdex); -} - -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial/src/SetDialModel.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial/src/SetDialModel.cpp deleted file mode 100644 index 8f15cfcd0..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial/src/SetDialModel.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SetDialModel.cpp - * Author: - * Create: 2021-11-23 - */ -#include -#include "main/MainModel.h" -#include "set_dial/SetDialModel.h" -#include "kv_store.h" -#include "securec.h" -#include "dirent.h" -#include "main/DialBinParser.h" -#include "wearable_log.h" - -namespace OHOS { - SetDialModel::SetDialModel() {} - - SetDialModel::~SetDialModel() {} - - SetDialModel &SetDialModel::GetInstance() - { - static SetDialModel instance; - return instance; - } - void SetDialModel::LoadAllDial() - { - LoadAllDialFromRam(); // 导入在线表盘 - size_t dialSize = dialInfoList.size(); - size_t aodSize = aodDialInfoList.size(); - LoadAllDialFromFs(); // 导入离线表盘 - /* 只排序离线表盘 */ - std::sort(dialInfoList.begin() + dialSize, dialInfoList.end(), [](const SetDialInfo& f, const SetDialInfo& n) { - return f.dialName < n.dialName; - }); - std::sort(aodDialInfoList.begin() + aodSize, - aodDialInfoList.end(), - [](const SetDialInfo &f, const SetDialInfo &n) { return f.dialName < n.dialName; }); - } - - void SetDialModel::LoadAllDialFromRam() - { - for (uint8_t i = 0; i < MainModel::GetInstance().GetDialInfoNum(); i++) { - const DialInfo *info = MainModel::GetInstance().GetDialInfo(i); - if (info != nullptr) { - SetDialInfo dialInfo{0}; - dialInfo.dialFlag = 0; - dialInfo.id = i; - dialInfo.dialName = info->dialName; - dialInfo.imageFullName = info->dialImg; - ImageInfo* imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(info->dialImg, false); - if (info == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "LoadAllDialFromRam loadimage %s fail", - info->dialImg); - continue; - } - dialInfo.preImageInfo = imageInfo; - if (info->capability == DIAL_DISPLAY_CAPABILITY_NORMAL_ONLY) { - dialInfoList.push_back(dialInfo); - } else if (info->capability == DIAL_DISPLAY_CAPABILITY_AMBITIENT_ONLY) { - aodDialInfoList.push_back(dialInfo); - } else { - dialInfoList.push_back(dialInfo); - aodDialInfoList.push_back(dialInfo); - } - } - } - } - - void SetDialModel::LoadAllDialFromFs() - { - int ret; - struct dirent *direntp; - - // 打开目录 - DIR *dirp = opendir(APP_DIAL_PATH); - // 遍历文件 - if (dirp != nullptr) { - while ((direntp = readdir(dirp)) != nullptr) { - SetDialInfo dialInfo{0}; - int ret = ParseDialHeader(direntp->d_name, dialInfo); - if (ret == 0) { - if (dialInfo.capability == DIAL_DISPLAY_CAPABILITY_NORMAL_ONLY) { - dialInfoList.push_back(dialInfo); - } else if (dialInfo.capability == DIAL_DISPLAY_CAPABILITY_AMBITIENT_ONLY) { - aodDialInfoList.push_back(dialInfo); - } else { - dialInfoList.push_back(dialInfo); - aodDialInfoList.push_back(dialInfo); - } - } - } - } - // 关闭目录 - closedir(dirp); - return; - } - - int32_t SetDialModel::ParseDialHeader(const std::string &dialFileName, SetDialInfo &dialInfo) - { - std::string dialFullName = APP_DIAL_PATH; - dialFullName += "/"; - dialFullName += dialFileName; - FILE *fp = fopen(dialFullName.c_str(), "rb"); - if (fp == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ParseDialHeader cannot open file: %s", - dialFullName.c_str()); - return -1; - } - DialPreviewInfo preInfo{0}; - bool ret = DialBinParserManager::GetInstance()->GetDialPreviewInfo(dialFullName, fp, &preInfo); - if (!ret) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GetDialPreviewInfo %s fail", - dialFullName.c_str()); - fclose(fp); - return -1; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ParseDialHeader dialFullName: %s", - dialFullName.c_str()); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ParseDialHeader dialName: %s", - preInfo.dialName); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ParseDialHeader description: %s", - preInfo.description); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ParseDialHeader previewImgId: %u", - preInfo.imgId); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ParseDialHeader imageOffset: %u", - preInfo.offset); - ImageInfo *info = ImageCacheManager::GetInstance().LoadOneInMultiRes( - preInfo.imgId, dialFullName, fp, false, preInfo.offset); - if (info == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ParseDialHeader loadimage fail"); - fclose(fp); - return -1; - } - - dialInfo.dialFlag = 1; - dialInfo.id = 0; - dialInfo.resId = preInfo.imgId; - dialInfo.dialFullName = dialFullName; - dialInfo.dialName = preInfo.dialName; - dialInfo.description = preInfo.description; - dialInfo.preImageInfo = info; - dialInfo.capability = preInfo.capability; - - fclose(fp); - return 0; - } - - void SetDialModel::SaveDialSetting(uint8_t pageIndex) - { - if (pageIndex >= dialInfoList.size()) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialModel SaveDialSetting [%u %u]", - pageIndex, dialInfoList.size()); - return; - } - DialSetting diagSetting; - SetDialInfo &info = dialInfoList[pageIndex]; - diagSetting.dialFlag = info.dialFlag; - diagSetting.dialId = info.id; - diagSetting.dialFullName = info.dialFullName; - MainModel::GetInstance().AddDialSetting(diagSetting); - } - - size_t SetDialModel::GetDialCount(void) - { - return dialInfoList.size(); - } - - std::vector& SetDialModel::GetDialInfo(void) - { - return dialInfoList; - } - - std::vector& SetDialModel::GetAmbientDialInfo(void) - { - return aodDialInfoList; - } - - void SetDialModel::ClearDialInfo(void) - { - for (auto iter : dialInfoList) { - if (iter.dialFlag) { - ImageCacheManager::GetInstance().UnloadOneInMultiRes(iter.resId, iter.dialFullName); - } else { - ImageCacheManager::GetInstance().UnloadSingleRes(iter.imageFullName); - } - } - dialInfoList.clear(); - aodDialInfoList.clear(); - } - - uint8_t SetDialModel::GetPageIndex(void) - { - uint8_t index = 0; - DialSetting dialSetting = MainModel::GetInstance().GetDialSetting(); - for (auto iter : dialInfoList) { - if (dialSetting.dialFlag) { - if (strcmp(iter.dialFullName.c_str(), dialSetting.dialFullName.c_str()) == 0) { - return index; - } - } else { - if ((!iter.dialFlag) && (iter.id == dialSetting.dialId)) { - return index; - } - } - index++; - } - return 0; - } - -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial/src/SetDialPresenter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial/src/SetDialPresenter.cpp deleted file mode 100644 index e33267320..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial/src/SetDialPresenter.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SetDialPresenter.cpp - * Author: - * Create: 2021-11-23 - */ - -#include "set_dial/SetDialView.h" -#include "set_dial/SetDialModel.h" -#include "set_dial/SetDialPresenter.h" -#include "hal_tick.h" -#include "NativeRegisterManager.h" - - -namespace OHOS { -namespace { -SetDialPresenter *g_presenter = nullptr; -} // anonymous namespace - -REGIST_SLICE(VIEW_SET_DIAL, SetDialView, SetDialPresenter); - - SetDialPresenter::SetDialPresenter() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialPresenter::SetDialPresenter"); - model = &SetDialModel::GetInstance(); - model->LoadAllDial(); - ResetTickTimer(); - g_presenter = this; - specificSetting.dialFlag = 0; - specificSetting.dialId = 0; - } - - SetDialPresenter::~SetDialPresenter() - { - g_presenter = nullptr; - } - - SetDialPresenter *SetDialPresenter::GetCurrentInstance() - { - return g_presenter; - } - - void SetDialPresenter::SpecifyDialSetting(const DialSetting &setting) - { - isSpecific = true; - specificSetting = setting; - } - - void SetDialPresenter::OnClickAction(void) - { - uint8_t pageIndex = view_->GetCoverflowPage(); - model->SaveDialSetting(pageIndex); - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE); - } - - bool SetDialPresenter::OnClick(UIView &view, const ClickEvent &event) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialPresenter::OnClick"); - OnClickAction(); - return true; - } - - bool SetDialPresenter::OnScroll() - { - view_->CoverflowViewScroll(); - return true; - } - - void SetDialPresenter::OnScroll(UIRollerView* roller, std::string currentItemName, float currentItemAngle) - { - view_->RollerViewScroll(currentItemName, currentItemAngle); - } - - size_t SetDialPresenter::GetDialCount(void) - { - return model->GetDialCount(); - } - - std::vector& SetDialPresenter::GetDialInfo(void) - { - return model->GetDialInfo(); - } - - uint8_t SetDialPresenter::GetPageIndex(void) - { - return model->GetPageIndex(); - } - - void SetDialPresenter::OnTickEvent() - { - uint64_t current_time = static_cast(HALTick::GetInstance().GetTime()); - if ((startTime != 0) && (current_time - startTime > MISS_DIAL_OPERATION_TIME)) { - OnClickAction(); - } - } - - void SetDialPresenter::OnStop() - { - model->ClearDialInfo(); - if (isSpecific) { - MainModel::GetInstance().GetDialSetting() = specificSetting; - MainModel::GetInstance().AddDialSetting(specificSetting); - } - } - - void SetDialPresenter::ResetTickTimer(void) - { - startTime = static_cast(HALTick::GetInstance().GetTime()); - } -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial/src/SetDialView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial/src/SetDialView.cpp deleted file mode 100644 index a932d18be..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial/src/SetDialView.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SetDialView.cpp - * Author: - * Create: 2021-11-23 - */ - -#include -#include "set_dial/SetDialView.h" -#include "set_dial/SetDialPresenter.h" -#include "set_dial_style/SetDialStyleModel.h" - -namespace OHOS { -SetDialView::SetDialView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialView::SetDialView"); -} - -SetDialView::~SetDialView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialView::~SetDialView"); -} - -void SetDialView::OnStart() -{ - if (SetDialStyleModel::GetInstance().GetStyle() == DialStyle::COVERFLOW) { - SetUpCoverflowView(); - } else { - SetUpRollerView(); - } -} - -void SetDialView::SetUpCoverflowView(void) -{ - coverflow_.SetPosition(0, 0, GetRootContainer()->GetWidth(), GetRootContainer()->GetHeight()); - coverflow_.SetIntercept(true); - coverflow_.SetOnCoverflowListener(presenter_); - coverflow_.SetOnClickListener(presenter_); - coverflow_.SetThrowDrag(true); - std::vector &dialInfo = presenter_->GetDialInfo(); - for (auto iter : dialInfo) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialView::SetUpCoverflowView %s", - iter.dialName.c_str()); - coverflow_.Add(iter.dialName.c_str(), iter.preImageInfo); - } - lastIndex_ = presenter_->GetPageIndex(); - coverflow_.SetCurrentPage(lastIndex_); - - label_.SetPosition(127, 50, 200, 50); - label_.SetTextColor(Color::White()); - label_.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label_.SetText(dialInfo[lastIndex_].dialName.c_str()); - label_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - - AddViewToRootContainer(&coverflow_); - AddViewToRootContainer(&label_); -} - -void SetDialView::SetUpRollerView(void) -{ - rollerView_.SetPosition(0, 0, GetRootContainer()->GetWidth(), GetRootContainer()->GetHeight()); - rollerView_.SetItemSize(150, 150); // 150: item size - rollerView_.SetThrowDrag(true); - rollerView_.SetItemPadding(80); // 80: item padding - AddViewToRootContainer(&rollerView_); - - std::vector &dialInfo = presenter_->GetDialInfo(); - for (auto iter : dialInfo) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialView::SetUpRollerView %s", - iter.dialName.c_str()); - bool succ = rollerView_.AddItem(iter.dialName, iter.preImageInfo); - rollerItemNum_ += succ ? 1 : 0; - } - float scalerCoef = 0.55; - uint16_t w = GetRootContainer()->GetWidth(); - uint16_t h = GetRootContainer()->GetHeight(); - rollerView_.SetItemSize(w * scalerCoef, h * scalerCoef); - lastIndex_ = presenter_->GetPageIndex(); - rollerView_.SetCurrentItem(dialInfo[lastIndex_].dialName); - rollerView_.SetOnClickListener(presenter_); - rollerView_.SetOnScrollListener(presenter_); - - label_.SetPosition(127, 50, 200, 50); - label_.SetTextColor(Color::White()); - label_.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label_.SetText(dialInfo[lastIndex_].dialName.c_str()); - label_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - AddViewToRootContainer(&label_); -} - -void SetDialView::CoverflowViewScroll(void) -{ - int16_t contMidX = static_cast(GetRootContainer()->GetWidth() / DIVISOR_TWO); - int16_t minOffset = contMidX; - uint8_t newCenterIndex = lastIndex_; - for (uint8_t i = 0; i < coverflow_.GetChildrenNumber(); i++) { - Rect rect = coverflow_.GetViewByIndex(i)->GetOrigRect(); - int16_t x = rect.GetLeft(); - int16_t x1 = rect.GetRight(); - int16_t xMid = static_cast(x + (x1 - x + 1) / DIVISOR_TWO); - int16_t distance = MATH_ABS(xMid - contMidX); - if (distance < minOffset) { - newCenterIndex = i; - minOffset = distance; - } - } - if (newCenterIndex != lastIndex_) { - lastIndex_ = newCenterIndex; - std::vector &dialInfo = presenter_->GetDialInfo(); - label_.SetText(dialInfo[lastIndex_].dialName.c_str()); - } - - Rect curViewRect = coverflow_.GetViewByIndex(lastIndex_)->GetOrigRect(); - int16_t centerMid = curViewRect.GetLeft() + curViewRect.GetWidth() / DIVISOR_TWO; - int16_t offset = MATH_ABS(contMidX - centerMid); - if (offset > curViewRect.GetWidth() / DIVISOR_TWO) { - label_.SetStyle(STYLE_TEXT_OPA, 0); - } else { - uint8_t alpha = (uint8_t)((1.0f - ((float)offset / (curViewRect.GetWidth() / DIVISOR_TWO))) * OPA_OPAQUE); - label_.SetStyle(STYLE_TEXT_OPA, alpha); - } - presenter_->ResetTickTimer(); -} - -void SetDialView::RollerViewScroll(std::string currentItemName, float currentItemAngle) -{ - const float baseAngle = 360.0; - const float halfBaseAngle = 180.0; - if (FloatMoreEqual(currentItemAngle, halfBaseAngle)) { - currentItemAngle -= baseAngle; - } - if (currentItemAngle < 0) { - currentItemAngle = -currentItemAngle; - } - float maxAngle = baseAngle / rollerItemNum_; - float coef = 1.0 - 1.0 / (maxAngle) * currentItemAngle; - label_.SetStyle(STYLE_TEXT_OPA, coef * OPA_OPAQUE); - label_.SetText(currentItemName.c_str()); - std::vector &dialInfo = presenter_->GetDialInfo(); - for (uint8_t i = 0; i < dialInfo.size(); ++i) { - if (dialInfo[i].dialName == currentItemName) { - lastIndex_ = i; - } - } - presenter_->ResetTickTimer(); -} - -uint8_t SetDialView::GetCoverflowPage(void) -{ - return lastIndex_; -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial_style/src/SetDialStyleModel.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial_style/src/SetDialStyleModel.cpp deleted file mode 100644 index 3126804b3..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial_style/src/SetDialStyleModel.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2024. All rights reserved. - * Description: SetDialStyleModel.cpp - * Author: - * Create: 2024-06-06 - */ - -#include "set_dial_style/SetDialStyleModel.h" -#include "kv_store.h" - -namespace OHOS { -void SetDialStyleModel::SetStyle(DialStyle style) -{ - int len = sizeof(values_) / sizeof(values_[0]); - for (int i = 0; i < len; ++i) { - if (values_[i].style == style) { - UtilsSetValue(key_, values_[i].value); - break; - } - } -} - -DialStyle SetDialStyleModel::GetStyle() -{ - int len = sizeof(values_) / sizeof(values_[0]); - char temp[MAX_LEN]; - UtilsGetValue(key_, temp, MAX_LEN); - for (int i = 0; i < len; ++i) { - if (strcmp(temp, values_[i].value) == 0) { - return values_[i].style; - } - } - return DialStyle::COVERFLOW; -} - -SetDialStyleModel::SetDialStyleModel() -{ -} - -SetDialStyleModel::~SetDialStyleModel() -{ -} -} // OHOS \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial_style/src/SetDialStylePresenter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial_style/src/SetDialStylePresenter.cpp deleted file mode 100644 index 8c85a6a34..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial_style/src/SetDialStylePresenter.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2024. All rights reserved. - * Description: SetDialStylePresenter.cpp - * Author: - * Create: 2024-06-06 - */ - -#include "set_dial_style/SetDialStyleView.h" -#include "set_dial_style/SetDialStyleModel.h" -#include "set_dial_style/SetDialStylePresenter.h" -#include "NativeRegisterManager.h" - -namespace OHOS { - -REGIST_SLICE(VIEW_SET_DIAL_STYLE, SetDialStyleView, SetDialStylePresenter); - -SetDialStylePresenter::SetDialStylePresenter() -{ - Attach(&SetDialStyleModel::GetInstance()); -} - -SetDialStylePresenter::~SetDialStylePresenter() -{ -} - -bool SetDialStylePresenter::OnClick(UIView &view, const ClickEvent &event) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialStylePresenter::OnClick"); - view_->OnClick(view); - return true; -} - -bool SetDialStylePresenter::OnDrag(UIView& view, const DragEvent& event) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialStylePresenter::OnDrag"); - UNUSED(view); - if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && - (event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnDrag ChangeSlice"); - uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(preSlice); - } - return true; -} -} // OHOS \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial_style/src/SetDialStyleView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial_style/src/SetDialStyleView.cpp deleted file mode 100644 index 85d72a819..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_dial_style/src/SetDialStyleView.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2024. All rights reserved. - * Description: SetDialStyleView.cpp - * Author: - * Create: 2024-06-06 - */ - -#include "set_dial_style/SetDialStyleView.h" -#include "PageTransitionMgr.h" -#include "set_dial_style/SetDialStyleModel.h" -#include "set_dial_style/SetDialStylePresenter.h" -#include "main/MainModel.h" - -namespace OHOS { -SetDialStyleView::SetDialStyleView() -{ -} - -SetDialStyleView::~SetDialStyleView() -{ -} - -void SetDialStyleView::OnStart() -{ - GetRootContainer()->SetDraggable(true); - GetRootContainer()->SetTouchable(true); - if (!PageTransitionMgr::GetInstance().CanSlideBack()) { // support default slide back firstly - GetRootContainer()->SetOnDragListener(presenter_); - } - const int16_t BTN_HEIGHT = 55; - const int16_t BTN_WIDTH = 113; - const int16_t LABEL_WIDTH = 110; - const int16_t LABEL_HEIGHT = 18; - const int16_t COVER_X = 20; - const int16_t ROLLER_X = 158; - const int16_t ENABLE_X = 296; - const int16_t Y1 = 176; - const int16_t Y2 = 250; - - labelCover_.SetPosition(COVER_X, Y2, LABEL_WIDTH, LABEL_HEIGHT); - labelCover_.SetText("Coverflow"); - AddViewToRootContainer(&labelCover_); - - labelRoller_.SetPosition(ROLLER_X, Y2, LABEL_WIDTH, LABEL_HEIGHT); - labelRoller_.SetText("Roller"); - AddViewToRootContainer(&labelRoller_); - - btnCover_.SetPosition(COVER_X, Y1, BTN_WIDTH, BTN_HEIGHT); - AddViewToRootContainer(&btnCover_); - btnRoller_.SetPosition(ROLLER_X, Y1, BTN_WIDTH, BTN_HEIGHT); - AddViewToRootContainer(&btnRoller_); - - labelEnableAod_.SetPosition(ENABLE_X, Y2, LABEL_WIDTH, LABEL_HEIGHT); - labelEnableAod_.SetText("打开熄屏显示"); - AddViewToRootContainer(&labelEnableAod_); - btnEnableAod_.SetPosition(ENABLE_X, Y1, BTN_WIDTH, BTN_HEIGHT); - AddViewToRootContainer(&btnEnableAod_); - btnEnableAod_.SetState(MainModel::GetInstance().IsAodEnabled()); - - const DialStyle style = SetDialStyleModel::GetInstance().GetStyle(); - int len = sizeof(styleTable_) / sizeof(styleTable_[0]); - for (int i = 0; i < len; ++i) { - if (style == styleTable_[i].style) { - styleTable_[i].btn->SetState(true); - } else { - styleTable_[i].btn->SetState(false); - } - } - - btnCover_.SetOnClickListener(presenter_); - btnRoller_.SetOnClickListener(presenter_); - btnEnableAod_.SetOnClickListener(presenter_); -} - -void SetDialStyleView::OnClick(UIView &view) -{ - const UIToggleButton *ptr = dynamic_cast(&view); - if (ptr == nullptr) { - return; - } - if (ptr == &btnEnableAod_) { - MainModel::GetInstance().EnableAod(ptr->GetState()); - return; - } - int len = sizeof(styleTable_) / sizeof(styleTable_[0]); - for (int i = 0; i < len; ++i) { - if (ptr == styleTable_[i].btn) { - styleTable_[i].btn->SetState(true); - SetDialStyleModel::GetInstance().SetStyle(styleTable_[i].style); - } else { - styleTable_[i].btn->SetState(false); - } - } -} -} // OHOS \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_ota/src/OTAModel.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/set_ota/src/OTAModel.cpp deleted file mode 100644 index 60715c5f4..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_ota/src/OTAModel.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. - * Description: ota local update - * Author: wangle - * Create: 2025-5-6 - */ -#include "set_ota/OTACommon.h" -#include "set_ota/OTAModel.h" -#include "set_ota/OTAPresenter.h" -#include "tcxo.h" -#include "upg.h" -#include "upg_porting.h" -#include "upg_definitions.h" -#include "upg_common_porting.h" -#include "wearable_log.h" - - -namespace OHOS { -OTAModel::OTAModel() -{ - isIdel = true; - wait.wait = nullptr; - if (osal_wait_init(&wait) != 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ota osal_wait_init error"); - return; - } - task = osal_kthread_create(&OTAModel::OSALKthreadCallback, this, "ota_model", MODLE_THREAD_STACK_SIZE); - if (task == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ota osal_wait_init error"); - osal_wait_destroy(&wait); - return; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "model init succ"); -} -OTAModel::~OTAModel() -{ - if (task != nullptr) { - osal_kthread_destroy(task, 0); - } - if (wait.wait != nullptr) { - osal_wait_destroy(&wait); - } -} - -int OTAModel::WaitCondition(const void *data) -{ - OTAModel *model = (OTAModel *)data; - return model->isIdel ? 0 : 1; // 不空闲说明有任务 -} - -int OTAModel::OSALKthreadCallback(void *data) -{ - OTAModel *model = (OTAModel *)data; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "model thread... callback"); - while (true) { // osal_kthread_destroy规定 线程销毁前必须一直存在 - osal_wait_interruptible(&model->wait, &OTAModel::WaitCondition, data); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "model thread... wait done"); - model->SwitchTask(); - } - return 0; -} -bool OTAModel::ModelRunTask(TaskType tasktype, void *taskdata) -{ - if (!isIdel) - return false; - type = tasktype; - data = taskdata; - isIdel = false; - osal_wait_wakeup(&wait); - return true; -} -void OTAModel::SwitchTask() -{ - switch (type) { - case TaskType::UpdateInfo: - UpdateInfo(data); - isIdel = true; - break; - case TaskType::LocalUpdate: - LocalUpdate(data); - isIdel = true; - break; - default: - break; // 不处理 - } -} - -void OTAModel::UpdateInfo(void *data) -{ - uint32_t total_size = 0; - do { - FILE *fp = fopen(upg_get_pkg_file_path(), "rb"); - if (fp == nullptr) { - break; - } - fseek(fp, 0L, SEEK_END); - total_size = ftell(fp); - fclose(fp); - } while (false); - presenter_->SetPackageInfo(upg_get_pkg_file_path(), total_size); -} -void OTAModel::LocalUpdate(void *data) -{ - upg_prepare_info_t info{((LocalUpdateData *)data)->fileSize}; - - // update 准备工作 - presenter_->SetUpdateProgress("upg_prepare", LOCAL_UPDATE_PROGRESS_5); - errcode_t ret = uapi_upg_prepare(&info); - if (ret != ERRCODE_SUCC) { - presenter_->SetErrorMessage("uapi_upg_prepare error"); - return; - } - - // update 申请升级 - presenter_->SetUpdateProgress("upg_request_upgrade", LOCAL_UPDATE_PROGRESS_25); - ret = uapi_upg_request_upgrade(false); - if (ret != ERRCODE_SUCC) { - presenter_->SetErrorMessage("uapi_upg_request_upgrade error"); - return; - } - // 备份 - presenter_->SetUpdateProgress("upg_image_backups", LOCAL_UPDATE_PROGRESS_40); - ret = upg_image_backups_update(); - if (ret != ERRCODE_SUCC) { - presenter_->SetErrorMessage("upg_image_backups_update error"); - return; - } - - // update 开始升级 - presenter_->SetUpdateProgress("upg_start", LOCAL_UPDATE_PROGRESS_50); - ret = uapi_upg_start(); - if (ret != ERRCODE_SUCC) { - presenter_->SetErrorMessage("uapi_upg_start error"); - return; - } - presenter_->SetUpdateProgress("reboot", LOCAL_UPDATE_PROGRESS_100); - DelayRebootFor5S(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "update"); -} -void OTAModel::DelayRebootFor5S() -{ - char temp[60] = ""; - for (int i = 5; i > 0; i--) { - sprintf_s(temp, sizeof(temp), "%ds后系统将进行重启\r\n完成后续升级操作", i); - presenter_->SetMessage(temp); - osal_msleep(SLEEP_TIME_S); - } - upg_reboot(); -} -} // namespace OHOS diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_ota/src/OTAPresenter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/set_ota/src/OTAPresenter.cpp deleted file mode 100644 index a77f53fc4..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_ota/src/OTAPresenter.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. - * Description: ota local update - * Author: wangle - * Create: 2025-5-6 - */ -#include "AppViewIDs.h" -#include "NativeRegisterManager.h" -#include "gfx_utils/graphic_math.h" -#include "set_ota/OTACommon.h" -#include "set_ota/OTAView.h" -#include "set_ota/OTAPresenter.h" -#include "set_ota/OTAModel.h" -#include "main/HealthModel.h" -#include "uiservice/ui_service.h" - -namespace OHOS { - -REGIST_SLICE(VIEW_SET_OTA, OTAView, OTAPresenter); - -void OTAPresenter::OnStart() -{ - if (model_ == nullptr) { - Attach(new OTAModel); - } - if (model_ != nullptr) { - model_->Attach(this); - } - view_->SetUpdateDisable(); - view_->SetMessage("正在获取升级文件信息..."); - view_->SetProgress(0); - model_->ModelRunTask(TaskType::UpdateInfo, nullptr); -} -void OTAPresenter::OnStop() -{ - if (model_ != nullptr) { - delete model_; - model_ = nullptr; - } -} -bool OTAPresenter::OnClick(UIView &view, const ClickEvent &event) -{ - if (strcmp(view.GetViewId(), "update") == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OTA OnClick... update"); - // 调用model升级方法 - model_->ModelRunTask(TaskType::LocalUpdate, nullptr); - view_->SetMessage("正在升级..."); - view_->SetProgress(0); - view_->SetUpdateDisable(); - updateEnable = true; // 升级中, 禁止右滑退出 - SaveSystemScreen(); // 升级中, 设置屏幕常亮 - } - return true; -} -bool OTAPresenter::OnDrag(UIView &view, const DragEvent &event) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OTA OnDrag..."); - if (updateEnable && event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { - int16_t deltaX = event.GetDeltaX(); - int16_t deltaY = event.GetDeltaY(); - if (MATH_ABS(deltaX) >= MATH_ABS(deltaY) && MATH_ABS(deltaX) > SLIDING_LENGTH) { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TransitionType::TRANSITION_ZOOM); - } - } - return true; -} - -void OTAPresenter::SetPackageInfo(const char *filePath, uint32_t fileSize) -{ - char tempBuffer[60] = ""; - updateFilePath = filePath; - updateFileSize = fileSize; - updateEnable = true; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OTA SetPackageInfo"); - if (fileSize != 0) { - double tempSizeMB = 1.0 * updateFileSize / 1024 / 1024; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "calc"); - sprintf_s(tempBuffer, sizeof(tempBuffer), "升级文件:%s\r\n大小:%.2lfMB", filePath, tempSizeMB); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "sprintf"); - view_->SetUpdateEnable(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "View setEnable"); - view_->SetMessage(tempBuffer); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "view SetMessage"); - } else { - sprintf_s(tempBuffer, sizeof(tempBuffer), "升级文件:%s\r\n不存在或已损坏", filePath); - view_->SetUpdateDisable(); - view_->SetMessage(tempBuffer); - } -} - -void OTAPresenter::SetUpdateProgress(const char *message, uint8_t progress) -{ - char tempBuffer[60] = ""; - sprintf_s(tempBuffer, sizeof(tempBuffer), "正在升级...%u%%...\r\n%s", progress, message); - view_->SetMessage(tempBuffer); - view_->SetProgress(progress); -} -void OTAPresenter::SetErrorMessage(const char *message) -{ - char tempBuffer[60] = ""; - sprintf_s(tempBuffer, sizeof(tempBuffer), "升级失败...\r\n%s", message); - view_->SetMessage(tempBuffer); - view_->SetUpdateEnable(); // 升级失败后, 允许重新升级 - updateEnable = false; // 升级失败后, 允许右滑退出 - BackSystemScreen(); // 升级失败后, 回滚屏幕亮屏设置 -} -void OTAPresenter::SetMessage(const char *message) -{ - view_->SetMessage(message); -} -void OTAPresenter::SaveSystemScreen() -{ - briScrStatus = HealthModel::GetInstance()->GetBriScrStatus(); - if (briScrStatus == 0) { // 若系统常亮未打开则打开系统常亮 - ScreenOffEnable(0); - HealthModel::GetInstance()->UpdateBriScrStatus(1); - } -} -void OTAPresenter::BackSystemScreen() -{ - if (briScrStatus == 0) { // 若系统原本未处于常亮则恢复 - ScreenOffEnable(1); - HealthModel::GetInstance()->UpdateBriScrStatus(0); - } -} -} // namespace OHOS \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_ota/src/OTAView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/set_ota/src/OTAView.cpp deleted file mode 100644 index 1161894fa..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/set_ota/src/OTAView.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. - * Description: ota local update - * Author: wangle - * Create: 2025-5-6 - */ -#include "UiConfig.h" -#include "set_ota/OTACommon.h" -#include "set_ota/OTAView.h" -#include "set_ota/OTAPresenter.h" -#include "wearable_log.h" - -namespace OHOS { -void OTAView::OnStart() -{ - InitMessageCtrl(); - InitProgressCtrl(); - InitUpdateCtrl(); - AddCtrlToView(); -} -void OTAView::InitMessageCtrl() -{ - if (message == nullptr) { - message = new UILabel(); - } - message->SetPosition(VIEW_MESSAGE_X, VIEW_MESSAGE_Y); - message->Resize(VIEW_MESSAGE_W, VIEW_MESSAGE_H); - message->SetViewId("message"); - message->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - message->SetStyle(STYLE_TEXT_FONT, VIEW_MESSAGE_FONT); - message->SetStyle(STYLE_LINE_SPACE, 0); - - message->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - message->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - message->SetRollSpeed(0); - message->SetFont(DEFAULT_VECTOR_FONT_FILENAME, VIEW_MESSAGE_FONT); -} -void OTAView::InitProgressCtrl() -{ - if (progress == nullptr) { - progress = new UIBoxProgress(); - } - progress->SetViewId("progress"); - progress->SetDirection(UIBoxProgress::Direction::DIR_LEFT_TO_RIGHT); - progress->SetPosition(VIEW_PROGRESS_X, VIEW_PROGRESS_Y, VIEW_PROGRESS_W, VIEW_PROGRESS_H); - progress->SetValue(0); - progress->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, Color::Red().full); - progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, Color::Green().full); - progress->SetStyle(STYLE_BORDER_COLOR, Color::Yellow().full); - progress->SetStep(1); - progress->EnableBackground(true); -} -void OTAView::InitUpdateCtrl() -{ - if (update == nullptr) { - update = new UILabelButton(); - } - update->SetPosition(VIEW_UPDATE_X, VIEW_UPDATE_Y); - update->Resize(VIEW_UPDATE_W, VIEW_UPDATE_H); - update->SetViewId("update"); - update->SetText("升级"); - update->SetFont(DEFAULT_VECTOR_FONT_FILENAME, VIEW_UPDATE_FONT); - update->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - update->SetOnClickListener(presenter_); -} -void OTAView::AddCtrlToView() -{ - if (GetRootContainer() == nullptr) - return; - message->SetVisible(true); - progress->SetVisible(true); - update->SetVisible(true); - GetRootContainer()->Add(message); - GetRootContainer()->Add(progress); - GetRootContainer()->Add(update); - GetRootContainer()->SetTouchable(true); // 添加滑动响应 - GetRootContainer()->SetDraggable(true); - GetRootContainer()->SetOnDragListener(presenter_); -} -void OTAView::OnStop() -{ - DeInitMessageCtrl(); - DeInitProgressCtrl(); - DeInitUpdateCtrl(); -} -void OTAView::DeInitMessageCtrl() -{ - if (message != nullptr) { - delete message; - message = nullptr; - } -} -void OTAView::DeInitProgressCtrl() -{ - if (progress != nullptr) { - delete progress; - progress = nullptr; - } -} -void OTAView::DeInitUpdateCtrl() -{ - if (update != nullptr) { - delete update; - update = nullptr; - } -} -void OTAView::SetUpdateEnable() -{ - if (update == nullptr) - return; - update->Enable(); -} -void OTAView::SetUpdateDisable() -{ - if (update == nullptr) - return; - update->Disable(); -} - -void OTAView::SetMessage(const char *msg) -{ - if (message == nullptr) - return; - message->SetText(msg); -} -void OTAView::SetProgress(uint8_t progressNum) -{ - if (progress == nullptr) - return; - progress->SetValue(progressNum); -} - -} // namespace OHOS diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SetDesktopModel.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SetDesktopModel.cpp deleted file mode 100644 index f18610db0..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SetDesktopModel.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: SetDesktopModel - * Author: Hisi Graphic Team - * Created: 2025-4 - */ - -#include "settings/SetDesktopModel.h" -#include "kv_store.h" -#include "securec.h" - -namespace OHOS { - static const int STYLE_VALUE_LEN = 32; - - SetDesktopModel &SetDesktopModel::GetInstance() - { - static SetDesktopModel instance; - return instance; - } - - DesktopStyle SetDesktopModel::GetDesktopStyle(void) - { - DesktopStyle style; - char temp[STYLE_VALUE_LEN] = { 0 }; - (void)UtilsGetValue("applist_style", temp, STYLE_VALUE_LEN); - if (strcmp(temp, "hexagons") == 0) { - style = HEXAGONS_STYLE; - } else if (strcmp(temp, "football") == 0) { - style = FOOTBALL_STYLE; - } else if (strcmp(temp, "waterfall") == 0) { - style = WATERFALL_STYLE; - } else { - style = APPLIST_STYLE; - } - return style; - } - - void SetDesktopModel::SetDesktopStyle(DesktopStyle style) - { - if (style == APPLIST_STYLE) { - (void)UtilsSetValue("applist_style", "list"); - } else if (style == HEXAGONS_STYLE) { - (void)UtilsSetValue("applist_style", "hexagons"); - } else if (style == FOOTBALL_STYLE) { - (void)UtilsSetValue("applist_style", "football"); - } else if (style == WATERFALL_STYLE) { - (void)UtilsSetValue("applist_style", "waterfall"); - } - } - -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SettingAdapter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SettingAdapter.cpp deleted file mode 100644 index 535c672ce..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SettingAdapter.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SettingAdapter.cpp - * Author: - * Create: 2021-11-23 - */ - -#include "settings/SettingAdapter.h" - -namespace OHOS { -SettingAdapter::SettingAdapter() {} - -SettingAdapter::~SettingAdapter() -{ - listData.clear(); -} - -uint16_t SettingAdapter::GetCount(void) -{ - return listData.size(); -} - -void SettingAdapter::SetData(std::list &data) -{ - if (!listData.empty()) { - listData.clear(); - } - std::list::iterator it; - for (it = data.begin(); it != data.end(); it++) { - listData.push_back(*it); - } -} - -UIView *SettingAdapter::GetView(UIView *inView, int16_t index) -{ - if (listData.empty()) { - return nullptr; - } - if (index < 0) { - return nullptr; - } - size_t uindex = index; - if (uindex >= listData.size()) { - return nullptr; - } - - std::list::iterator it = listData.begin(); - for (int i = 0; i < index; i++) { - it++; - } - SettingItem itemData = *it; - SettingItemView *item = nullptr; - if (inView == nullptr) { - item = new SettingItemView(); - } else { - item = static_cast(inView); - } - - item->SetItemInfo(itemData); - item->SetOnClickListener(itemClickListener); - return item; -} - -void SettingAdapter::AddListItem(const SettingItem &item) -{ - listData.push_back(item); -} -} // namespace OHOS diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SettingDesktopPage.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SettingDesktopPage.cpp deleted file mode 100644 index 0c1c2cd3d..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SettingDesktopPage.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: SettingDesktopPage - * Author: Hisi Graphic Team - * Created: 2025-4 - */ - -#include "settings/SettingDesktopPage.h" -#include -#include "components/ui_scroll_view_nested.h" -#include "common/screen.h" -#include "wearable_log.h" -#include "NativeAbility.h" -#include "PageTransitionMgr.h" -#include "SlicePageFactory.h" -#include "settings/SettingView.h" - -namespace OHOS { -static const char *SET_DESKTOP_LIST = "setdesktopList"; -static const char *SET_DESKTOP_HEXAGONS = "setdesktopHexagons"; -static const char *SET_DESKTOP_FOOTBALL = "setdesktopFootball"; -static const char *SET_DESKTOP_WATERFALL = "setdesktopWaterfall"; - -REGIST_SLICE_PAGE(VIEW_SETTING, SETTING_PAGES::SETTING_DESKTOP_PAGE, SettingDesktopPage, false); -SettingDesktopPage::SettingDesktopPage() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingDesktopPage::SettingDesktopPage"); -} - -SettingDesktopPage::~SettingDesktopPage() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingDesktopPage::~SettingDesktopPage"); - if (scrollview != nullptr) { - scrollview->RemoveAll(); - delete scrollview; - scrollview = nullptr; - } -} - -void SettingDesktopPage::OnStart(void *data) -{ - if (GetBackDragListener() == nullptr) { // support default slide back firstly - GetSlicePageContainer()->SetOnDragListener(this); - } - - scrollview = new UIScrollViewNested(UIAbstractScroll::HORIZONTAL); - UIScrollViewNested *nested = dynamic_cast(scrollview); - if (nested != nullptr) { - nested->SetBoundaryIntercept(DragEvent::DIRECTION_LEFT_TO_RIGHT, false); - } - scrollview->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - AddViewToPageContainer(scrollview); - - titleText.SetPosition(180, 45, 260, 110); - titleText.SetText("桌面"); - titleText.SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - titleText.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); - titleText.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - AddViewToPageContainer(&titleText); - - listImage.SetPosition(0, 135, 190, 190); - listImage.SetSrc(PNG_SET_DESKTOP_BG_IMAGE); - scrollview->Add(&listImage); - - listBtn.SetPosition(22, 157, 148, 148); - listBtn.SetImages(PNG_SET_DESKTOP_LIST_IMAGE, PNG_SET_DESKTOP_LIST_IMAGE); - listBtn.SetViewId(SET_DESKTOP_LIST); - scrollview->Add(&listBtn); - - listText.SetPosition(61, 328, 200, 60); - listText.SetText("列表"); - listText.SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - listText.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - listText.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - scrollview->Add(&listText); - - hexagonsImage.SetPosition(150, 135, 190, 190); - hexagonsImage.SetSrc(PNG_SET_DESKTOP_BG_IMAGE); - scrollview->Add(&hexagonsImage); - - hexagonsBtn.SetPosition(172, 157, 148, 148); - hexagonsBtn.SetImages(PNG_SET_DESKTOP_HEXAGONS_IMAGE, PNG_SET_DESKTOP_HEXAGONS_IMAGE); - hexagonsBtn.SetViewId(SET_DESKTOP_HEXAGONS); - scrollview->Add(&hexagonsBtn); - - hexagonsText.SetPosition(218, 328, 200, 60); - hexagonsText.SetText("蜂窝"); - hexagonsText.SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - hexagonsText.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - hexagonsText.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - scrollview->Add(&hexagonsText); - - InitFootballItem(); - InitWaterfallItem(); - listBtn.SetOnClickListener(this); - hexagonsBtn.SetOnClickListener(this); - footballBtn_.SetOnClickListener(this); - waterfallBtn_.SetOnClickListener(this); - UpdateSelectedStyle(SetDesktopModel::GetInstance().GetDesktopStyle()); -} - -void SettingDesktopPage::UpdateSelectedStyle(DesktopStyle selectedStyle) -{ - hexagonsImage.SetVisible(false); - hexagonsBtn.SetState(false); - listImage.SetVisible(false); - listBtn.SetState(false); - footballImage_.SetVisible(false); - footballBtn_.SetState(false); - waterfallImage_.SetVisible(false); - waterfallBtn_.SetState(false); - - if (selectedStyle == HEXAGONS_STYLE) { // 1: select hexagons style - hexagonsImage.SetVisible(true); - hexagonsBtn.SetState(true); - } else if (selectedStyle == FOOTBALL_STYLE) { // 2: select football style - footballImage_.SetVisible(true); - footballBtn_.SetState(true); - } else if (selectedStyle == WATERFALL_STYLE) { // 3: select waterfall style - waterfallImage_.SetVisible(true); - waterfallBtn_.SetState(true); - } else { - listImage.SetVisible(true); - listBtn.SetState(true); - } -} - -void SettingDesktopPage::InitFootballItem() -{ - footballImage_.SetPosition(300, 135, 190, 190); - footballImage_.SetSrc(PNG_SET_DESKTOP_BG_IMAGE); - scrollview->Add(&footballImage_); - - footballBtn_.SetPosition(322, 157, 148, 148); - footballBtn_.SetImages(PNG_SET_DESKTOP_HEXAGONS_IMAGE, PNG_SET_DESKTOP_HEXAGONS_IMAGE); - footballBtn_.SetViewId(SET_DESKTOP_FOOTBALL); - scrollview->Add(&footballBtn_); - - footballText_.SetPosition(368, 328, 200, 60); - footballText_.SetText("足球"); - footballText_.SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - footballText_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - footballText_.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - scrollview->Add(&footballText_); -} - -void SettingDesktopPage::InitWaterfallItem() -{ - waterfallImage_.SetPosition(450, 135, 190, 190); - waterfallImage_.SetSrc(PNG_SET_DESKTOP_BG_IMAGE); - scrollview->Add(&waterfallImage_); - - waterfallBtn_.SetPosition(472, 157, 148, 148); - waterfallBtn_.SetImages(PNG_SET_DESKTOP_HEXAGONS_IMAGE, PNG_SET_DESKTOP_HEXAGONS_IMAGE); - waterfallBtn_.SetViewId(SET_DESKTOP_WATERFALL); - scrollview->Add(&waterfallBtn_); - - waterfallText_.SetPosition(518, 328, 200, 60); - waterfallText_.SetText("瀑布"); - waterfallText_.SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - waterfallText_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - waterfallText_.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - scrollview->Add(&waterfallText_); -} - -bool SettingDesktopPage::OnDrag(UIView& view, const DragEvent& event) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingDesktopPage::OnDrag"); - UNUSED(view); - if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && - (event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnDrag ChangeSlice"); - uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(preSlice); - } - return false; -} - -bool SettingDesktopPage::OnClick(UIView &view, const ClickEvent &event) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingDesktopPage::OnClick"); - if (strcmp(view.GetViewId(), SET_DESKTOP_HEXAGONS) == 0) { - SetDesktopModel::GetInstance().SetDesktopStyle(DesktopStyle::HEXAGONS_STYLE); - } else if (strcmp(view.GetViewId(), SET_DESKTOP_LIST) == 0) { - SetDesktopModel::GetInstance().SetDesktopStyle(DesktopStyle::APPLIST_STYLE); - } else if (strcmp(view.GetViewId(), SET_DESKTOP_FOOTBALL) == 0) { - SetDesktopModel::GetInstance().SetDesktopStyle(DesktopStyle::FOOTBALL_STYLE); - } else if (strcmp(view.GetViewId(), SET_DESKTOP_WATERFALL) == 0) { - SetDesktopModel::GetInstance().SetDesktopStyle(DesktopStyle::WATERFALL_STYLE); - } - uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(preSlice); - return true; -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SettingItemView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SettingItemView.cpp deleted file mode 100644 index 9e88a4e28..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SettingItemView.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SettingItemView.cpp - * Author: - * Create: 2021-11-23 - */ - -#include "wearable_log.h" -#include "settings/SettingItemView.h" - -namespace OHOS { - static constexpr int16 SETTING_ICON_X = 20; - static constexpr int16 NUM_22 = 22; - static constexpr int16_t SETTING_ITEM_BUTTON_HEIGHT = 100; - static constexpr int16_t SETTING_ITEM_LABEL_WIDTH = 155; - static constexpr int16_t SETTING_ITEM_LABEL_HEIGHT = 100; - static constexpr int16 SETTING_ITEM_FONT_SIZE = 35; - static constexpr int16_t SETTINGS_RESIZE_SIZE = 100; - static constexpr int16_t SETTING_SICON_Y = 15; - static constexpr int16 NUMS_2 = 2; - static constexpr int16 NUMS_50 = 50; - - SettingItemView::SettingItemView() - { - SetPosition(0, 0, HORIZONTAL_RESOLUTION, SETTING_ITEM_BUTTON_HEIGHT); - SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY); - SetTouchable(true); - SetUpChild(); - - Add(&sIcon); - Add(&sLabel); - Add(&sNextImage); - } - - SettingItemView::~SettingItemView() - { - Remove(&sIcon); - Remove(&sLabel); - Remove(&sNextImage); - } - - void SettingItemView::SetItemInfo(const SettingItem itemInfo) - { - sItemInfo = itemInfo; - sIcon.SetSrc(itemInfo.icon); - sLabel.SetText(itemInfo.label); - sNextImage.SetVisible(itemInfo.hasSecondMenu); - } - - void SettingItemView::SetUpChild() - { - sIcon.SetPosition(SETTING_ICON_X, SETTING_SICON_Y); - sIcon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); - - sLabel.SetPosition(SETTING_ITEM_LABEL_WIDTH, 0); - sLabel.Resize(SETTING_ITEM_LABEL_WIDTH, SETTING_ITEM_LABEL_HEIGHT); - sLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, SETTING_ITEM_FONT_SIZE); - sLabel.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - sLabel.SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE); - sLabel.SetStyle(STYLE_TEXT_COLOR, Color::White().full); - sLabel.SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - sLabel.SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - - sNextImage.SetSrc(PNG_SETTING_NEXT_IMAGE); - sNextImage.SetPosition(LA_HORIZONTAL_RESOLUTION - NUMS_50, (SETTING_ITEM_HEIGHT - sNextImage.GetHeight()) / NUMS_2); - sNextImage.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); - } - - uint32_t SettingItemView::GetTargetId() - { - return sItemInfo.targetId; - } - - const char* SettingItemView::GetIconId() - { - return sItemInfo.icon; - } -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SettingMainPage.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SettingMainPage.cpp deleted file mode 100644 index 207eef016..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SettingMainPage.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: SettingMainPage - * Author: Hisi Graphic Team - * Created: 2025-4 - */ - -#include - -#include "settings/SettingMainPage.h" -#include "components/ui_list_nested.h" -#include "components/ui_scroll_view_nested.h" -#include "NativeAbility.h" -#include "SlicePageFactory.h" -#include "settings/SettingItem.h" -#include "settings/SettingPresenter.h" -#include "settings/SettingView.h" -#include "PageTransitionMgr.h" -#include "settings/SetDesktopModel.h" -#include "rebootdevice/RebootModel.h" -#include "settings/SettingModel.h" - -namespace OHOS { -REGIST_SLICE_PAGE(VIEW_SETTING, SETTING_PAGES::SETTING_MAIN_PAGE, SettingMainPage, true); - -static constexpr uint8_t SETTINGS_ITEM_FONT_SIZE = 40; -static constexpr int16_t SETTINGS_RESIZE_SIZE_WIDTH = 100; -static constexpr int16_t SETTINGS_RESIZE_SIZE_HEIGHT = 60; -static constexpr int16_t SETTING_TITLE_POSITION_X = 187; -static constexpr int16_t SETTING_LIST_POSITION_X = 32; -static constexpr int16_t SETTING_LIST_POSITION_Y = 90; -static constexpr int16_t SETTING_SCROLLBLANKSIZE = 50; -static constexpr int16 MAX_SCR_DIS = 1000; -static constexpr int16 LIST_POS = 20; -static constexpr int16 SNUM_2 = 2; - -SettingMainPage::~SettingMainPage() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingMainPage::~SettingMainPage"); - if (scrollView != nullptr) { - scrollView->RemoveAll(); - delete scrollView; - scrollView = nullptr; - } - - if (title != nullptr) { - delete title; - title = nullptr; - } - - if (listAdapter != nullptr) { - delete listAdapter; - listAdapter = nullptr; - } - - if (contentList != nullptr) { - delete contentList; - contentList = nullptr; - } -} - -void SettingMainPage::OnStart(void* data) -{ - title = new UILabel(); - if (title == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingMainPage::OnStart::title is nullptr"); - return; - } - title->SetPosition(SETTING_TITLE_POSITION_X, 0); - title->SetText("设置"); - title->Resize(SETTINGS_RESIZE_SIZE_WIDTH, SETTINGS_RESIZE_SIZE_HEIGHT); - title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SETTINGS_ITEM_FONT_SIZE); - title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - title->SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE); - title->SetStyle(STYLE_TEXT_COLOR, Color::White().full); - title->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - title->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - - contentList = new UIListNested(); - if (contentList == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingMainPage::OnStart::contentList is nullptr"); - return; - } - contentList->SetPosition(SETTING_LIST_POSITION_X, SETTING_LIST_POSITION_Y); - contentList->Resize(HORIZONTAL_RESOLUTION, 364); // 364: height - contentList->SetScrollBlankSize(SETTING_SCROLLBLANKSIZE); - contentList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position - contentList->SetDraggable(true); - contentList->SetThrowDrag(true); - contentList->EnableAutoAlign(true); - contentList->SetMaxScrollDistance(MAX_SCR_DIS); - - scrollView = new UIScrollViewNested(); - if (scrollView == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingMainPage::OnStart::scrollView is nullptr"); - return; - } - scrollView->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - scrollView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - scrollView->SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY); - scrollView->SetThrowDrag(true); - - if (PageTransitionMgr::GetInstance().GetTopSlideBackImage() == nullptr) { // support default slide back firstly - scrollView->SetOnDragListener(this); - } - scrollView->Add(title); - scrollView->Add(contentList); - SettingModel::GetInstance().InitSettingItem(); - AddViewToPageContainer(scrollView); - RefreshSettingsList(SettingModel::GetInstance().GetSettinglistItems(), - SettingModel::GetInstance().GetSettingListNum()); -} - -void SettingMainPage::RefreshSettingsList(const SettingItem* item, uint8_t count) -{ - listAdapter = new SettingAdapter(); - if (listAdapter == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SettingMainPage::OnStart::listAdapter is nullptr"); - return; - } - listAdapter->SetItemClickListener(this); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingMainPage::RefreshSettingsList"); - for (int i = 0; i < count; i++) { - listAdapter->AddListItem(item[i]); - } - contentList->SetAdapter(listAdapter); -} - -bool SettingMainPage::OnDrag(UIView& view, const DragEvent& event) -{ - UNUSED(view); - if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && - (event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnDrag ChangeSlice(VIEW_APPLIST)"); - if (SetDesktopModel::GetInstance().GetDesktopStyle() == HEXAGONS_STYLE) { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TransitionType::TRANSITION_BACK_TO_HEXAGONS); - } else if (SetDesktopModel::GetInstance().GetDesktopStyle() == WATERFALL_STYLE) { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TransitionType::TRANSITION_BACK_TO_WATERFALL); - } else { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); - } - } - return false; -} - -bool SettingMainPage::OnClick(UIView &view, const ClickEvent &event) -{ - UNUSED(event); - SettingItemView *settingItemView = static_cast(&view); - uint32_t targetId = settingItemView->GetTargetId(); - uint16_t sliceId = static_cast(targetId & SLICE_MASK); - uint16_t pageId = static_cast(targetId >> PAGE_OFFSET); - if (sliceId == VIEW_REBOOT) { - if (strstr(settingItemView->GetIconId(), "REBOOT") != nullptr) { - RebootModel::GetInstance()->SetSelectViewId(REBOOTDEVICE); - RebootModel::GetInstance()->SetExitsView(true); - } else { - RebootModel::GetInstance()->SetSelectViewId(SHUTDOWNDEVICE); - RebootModel::GetInstance()->SetExitsView(true); - } - } - if (sliceId != VIEW_SETTING) { - if (settingItemView->SlideBackEnabled()) { - NativeAbility::GetInstance().ChangeSlice(sliceId, TransitionType::TRANSITION_INVALID, - gSliceDefaultPriority, true); - } else { - NativeAbility::GetInstance().ChangeSlice(sliceId); - } - } else { - NativeAbility::GetInstance().SwitchPageInSlice(pageId, nullptr, TransitionType::TRANSITION_INVALID, true); - } - return true; -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SettingModel.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SettingModel.cpp deleted file mode 100644 index d732125d7..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/settings/src/SettingModel.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SettingModel.cpp - * Author: - * Create: 2021-11-23 - */ - -#include "settings/SettingModel.h" -#include "Slice.h" -#include "main/PullUpDownView.h" -#include "settings/SettingView.h" - -namespace OHOS { - SettingModel::SettingModel() {} - - SettingModel::~SettingModel() {} - - SettingModel &SettingModel::GetInstance() - { - static SettingModel instance; - return instance; - } - - void SettingModel::InitSettingItem() - { - int index = 0; - settings[index++] = {static_cast(VIEW_BLUETOOTH_EARPHONE), PNG_BLUETOOTH_STITLE, - "蓝牙耳机", true, false}; - settings[index++] = {static_cast(VIEW_CONNECT_PHONE), PNG_CONNECT_PHONE_IMAGE, "连接手机", true, true}; - settings[index++] = {static_cast(VIEW_REBOOT), PNG_SETTTING_REBOOT_IMAGE, "重启", true, true}; - settings[index++] = {static_cast(VIEW_REBOOT), PNG_SETTTING_SHUTDOWN_IMAGE, "关机", true, true}; - settings[index++] = {static_cast(VIEW_SET_DIAL), PNG_SETTTING_DESKTOP_IMAGE, "表盘", true, false}; - settings[index++] = {static_cast(VIEW_SETTING) | (SETTING_DESKTOP_PAGE << PAGE_OFFSET), - PNG_SETTTING_DESKTOP_IMAGE, "桌面", true, true}; - settings[index++] = {static_cast(VIEW_SET_CARD), PNG_SETTTING_DESKTOP_IMAGE, "卡片", true, false}; - settings[index++] = {static_cast(VIEW_SET_DIAL_STYLE), PNG_SETTTING_DESKTOP_IMAGE, - "表盘风格", true, true}; - settings[index++] = {static_cast(VIEW_RESTORE_DEFAULTS), PNG_SETTTING_DESKTOP_IMAGE, - "恢复出厂", true, true}; - settings[index++] = {static_cast(VIEW_SET_OTA), PNG_SETTTING_DESKTOP_IMAGE, "OTA升级", true, true}; - usedLen = index; - } - - const SettingItem *SettingModel::GetSettinglistItems() const - { - return settings; - } - - uint8_t SettingModel::GetSettingListNum() const - { - return usedLen; - } - - bool SettingModel::GetBlueToothConnectStatus(void) - { - return btConnectStatus; - } - - void SettingModel::UpdateBlueToothConnectStatus(bool status) - { - btConnectStatus = status; - if (PullUpDownView::GetInstance() != nullptr) { - PullUpDownView::GetInstance()->UpdateBlueToothStatus(status); - } - } -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/sleep/src/SleepingDetailsPage.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/sleep/src/SleepingDetailsPage.cpp deleted file mode 100644 index 1341d7b1b..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/sleep/src/SleepingDetailsPage.cpp +++ /dev/null @@ -1,635 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: SleepingDetailsPage - * Created: 2025-06-05 - */ -#include -#include -#include "ohos_timer.h" -#include "wearable_log.h" -#include "SlicePageFactory.h" -#include "common/image_cache_manager.h" -#include "AppViewIDs.h" -#include "NativeAbility.h" -#include "sleep/SleepingView.h" -#include "sleep/SleepingModel.h" -#include "sleep/SleepingDetailsPage.h" - -namespace OHOS { - -static constexpr int16_t SLEEPDETAIL_SLEEP_X = 97; -static constexpr int16_t SLEEPDETAIL_SLEEP_Y = 31; -static constexpr int16_t SLEEPDETAIL_SLEEP_WIDTH = 260; -static constexpr int16_t SLEEPDETAIL_SLEEP_HEIGHT = 53; -static constexpr int16_t SLEEPDETAIL_SLEEP_FONT_SIZE = 38; -static constexpr int16_t SLEEPDETAIL_IMAGE1_X = 77; -static constexpr int16_t SLEEPDETAIL_IMAGE1_Y = 215; -static constexpr int16_t SLEEPDETAIL_SOBERINGTIME_X = 103; -static constexpr int16_t SLEEPDETAIL_SOBERINGTIME_Y = 205; -static constexpr int16_t SLEEPDETAIL_SOBERINGTIME_WIDTH = 48; -static constexpr int16_t SLEEPDETAIL_SOBERINGTIME_HEIGHT = 29; -static constexpr int16_t SLEEPDETAIL_SOBERINGTIME_FONT_SIZE = 24; -static constexpr int16_t SLEEPDETAIL_IMAGE2_Y = 254; -static constexpr int16_t SLEEPDETAIL_IMAGE3_Y = 291; -static constexpr int16_t SLEEPDETAIL_IMAGE4_Y = 330; -static constexpr int16_t SLEEPDETAIL_RAPID_Y = 244; -static constexpr int16_t SLEEPDETAIL_RAPID_WIDTH = 100; -static constexpr int16_t SLEEPDETAIL_RAPID_HEIGHT = 38; -static constexpr int16_t SLEEPDETAIL_LIGHT_Y = 283; -static constexpr int16_t SLEEPDETAIL_DEEP_Y = 322; -static constexpr int16_t SLEEPDETAIL_GRAYBG_X = 62; -static constexpr int16_t SLEEPDETAIL_GRAYBG_Y = 185; -static constexpr int16_t SLEEPDETAIL_ACTUALSLEEP_X = 180; -static constexpr int16_t SLEEPDETAIL_ACTUAL_NORECODE_X = 96; -static constexpr int16_t SLEEPDETAIL_ACTUALSLEEP_Y = 100; -static constexpr int16_t SLEEPDETAIL_ACTUALSLEEP_WIDTH = 200; -static constexpr int16_t SLEEPDETAIL_ACTUALSLEEP_HEIGHT = 35; -static constexpr int16_t SLEEPDETAIL_ACTUALSLEEP_FONT_SIZE = 32; -static constexpr int16_t SLEEPDETAIL_LABEL_WIDTH = 160; -static constexpr int16_t SLEEPDETAIL_PADDING_RIGHT = 30; -static constexpr int16_t SLEEPDETAIL_SOBERINGTEXT_X = 220; -static constexpr int16_t SLEEPDETAIL_ACTUALSLEEP_NORECORD_X = 179; -static constexpr int16_t SLEEPDETAIL_ACTUALSLEEP_NORECORD_Y = 110; -static constexpr int16_t SLEEPDETAIL_SOBERTIMETEXT_X = 300; -static constexpr int16_t SLEEPDETAIL_SOBERTIMETEXT_Y = 190; -static constexpr int16_t SLEEPDETAIL_RAPIDTIMETEXT_Y = 230; -static constexpr int16_t SLEEPDETAIL_LIGHTIMETEXT_Y = 270; -static constexpr int16_t SLEEPDETAIL_DEEPIMETEXT_Y = 310; -static constexpr int16_t SLEEPDETAIL_ACTUALSLEEPTIMEHOURS_FONT_SIZE = 40; -static constexpr int16_t SLEEPDETAIL_ACTUALSLEEPTIMINUTES_HEIGHT = 50; -static constexpr int16_t SLEEPDETAIL_ACTUALSLEEPTIMINUTES_FONT_SIZE = 40; -static constexpr int16_t SLEEPDETAIL_ACTUALMINUTE_X = 230; -static constexpr int16_t SLEEPDETAIL_ACTUALMINUTE_Y = 116; -static constexpr int16_t SLEEPDETAIL_ACTUALHOUR_X = 135; -static constexpr int16_t SLEEPDETAIL_ACTUALHOUR_Y = 100; -static constexpr int16_t SLEEPDETAIL_ACTUALHOURTEXT_X = 170; -static constexpr int16_t SLEEPDETAIL_ACTUALMINUTETEXT_X = 280; -static constexpr int16_t ACTUALHOURS_X = 140; -static constexpr int16_t ACTUALHOURSTEXT_X = 180; -static constexpr int16_t ACTUALMINUTESTEXT_X = 270; - -REGIST_SLICE_PAGE(VIEW_SLEEPING, SLEEPING_PAGES::SLEEPING_DEATIL_PAGE, SleepingDetailsPage, false); - -SleepingDetailsPage::SleepingDetailsPage() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SleepingDetailsPage::SleepingDetailsPage"); -} - -SleepingDetailsPage::~SleepingDetailsPage() -{ - if (group != nullptr) { - group->RemoveAll(); - delete group; - group = nullptr; - } - - if (detailsSleepView != nullptr) { - delete detailsSleepView; - detailsSleepView = nullptr; - } - - if (sleep != nullptr) { - delete sleep; - sleep = nullptr; - } - - if (actualSleepTime != nullptr) { - delete actualSleepTime; - actualSleepTime = nullptr; - } - - if (actualSleepTimeHours != nullptr) { - delete actualSleepTimeHours; - actualSleepTimeHours = nullptr; - } - - if (actualSleepTimeHoursText != nullptr) { - delete actualSleepTimeHoursText; - actualSleepTimeHoursText = nullptr; - } - - if (actualSleepTimeMinutes != nullptr) { - delete actualSleepTimeMinutes; - actualSleepTimeMinutes = nullptr; - } - - if (actualSleepTimeMinutesText != nullptr) { - delete actualSleepTimeMinutesText; - actualSleepTimeMinutesText = nullptr; - } - - if (grayBg != nullptr) { - delete grayBg; - grayBg = nullptr; - } - - if (image1 != nullptr) { - delete image1; - image1 = nullptr; - } - - if (soberingTime_ != nullptr) { - delete soberingTime_; - soberingTime_ = nullptr; - } - - if (soberingTimeText != nullptr) { - delete soberingTimeText; - soberingTimeText = nullptr; - } - - if (image2 != nullptr) { - delete image2; - image2 = nullptr; - } - - if (rapidEyeMovement_ != nullptr) { - delete rapidEyeMovement_; - rapidEyeMovement_ = nullptr; - } - - if (rapidEyeMovementText != nullptr) { - delete rapidEyeMovementText; - rapidEyeMovementText = nullptr; - } - - if (image3 != nullptr) { - delete image3; - image3 = nullptr; - } - - if (lightSleepTime_ != nullptr) { - delete lightSleepTime_; - lightSleepTime_ = nullptr; - } - - if (lightSleepTimeText != nullptr) { - delete lightSleepTimeText; - lightSleepTimeText = nullptr; - } - - if (image4 != nullptr) { - delete image4; - image4 = nullptr; - } - - if (deepSleepTime_ != nullptr) { - delete deepSleepTime_; - deepSleepTime_ = nullptr; - } - - if (deepSleepTimeText != nullptr) { - delete deepSleepTimeText; - deepSleepTimeText = nullptr; - } - - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SleepingDetailsPage::~SleepingDetailsPage"); -} - -void SleepingDetailsPage::OnStart(void* data) -{ - group = new UIScrollView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group is nullptr"); - return; - } - group->SetPosition(0, 0); - group->Resize(RESOLUTION_WIDTH, RESOLUTION_HEIGHT); - group->SetViewId("sleepDetails"); - - detailsSleepView = new UIImageView(); - if (detailsSleepView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "detailsSleepView is nullptr"); - return; - } - LOADIMG::LoadImageViewImg(detailsSleepView, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_BACKGROUND); - detailsSleepView->SetPosition(0, 0, RESOLUTION_WIDTH, RESOLUTION_HEIGHT); - group->Add(detailsSleepView); - - sleep = new UILabel(); - if (sleep == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sleep is nullptr"); - return; - } - sleep->SetPosition(SLEEPDETAIL_SLEEP_X, SLEEPDETAIL_SLEEP_Y); - sleep->Resize(SLEEPDETAIL_SLEEP_WIDTH, SLEEPDETAIL_SLEEP_HEIGHT); - sleep->SetText("睡眠"); - sleep->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - sleep->SetTextColor(Color::White()); - sleep->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPDETAIL_SLEEP_FONT_SIZE); - sleep->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - group->Add(sleep); - - InitPage(); - - if (GetRecord() == true) { - InitDetailPage(); - } else { - InitNoDeatilPage(); - }; - group->SetOnDragListener(this); - group->SetDraggable(true); - group->SetTouchable(true); - AddViewToPageContainer(group); -} - -void SleepingDetailsPage::InitSoberingTime() -{ - image1 = new UIImageView(); - if (image1 == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "image1 is nullptr"); - return; - } - image1->SetPosition(SLEEPDETAIL_IMAGE1_X, SLEEPDETAIL_IMAGE1_Y); - LOADIMG::LoadImageViewImg(image1, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_RED_CIR); - group->Add(image1); - soberingTime_ = new UILabel(); - if (soberingTime_ == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "soberingTime_ is nullptr"); - return; - } - soberingTime_->SetPosition(SLEEPDETAIL_SOBERINGTIME_X, SLEEPDETAIL_SOBERINGTIME_Y); - soberingTime_->Resize(SLEEPDETAIL_SOBERINGTIME_WIDTH, SLEEPDETAIL_SOBERINGTIME_HEIGHT); - soberingTime_->SetText("清醒"); - soberingTime_->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - soberingTime_->SetTextColor(Color::White()); - soberingTime_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPDETAIL_SOBERINGTIME_FONT_SIZE); - soberingTime_->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); - group->Add(soberingTime_); -} - -void SleepingDetailsPage::InitRapidEyeMovement() -{ - image2 = new UIImageView(); - if (image2 == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "image2 is nullptr"); - return; - } - image2->SetPosition(SLEEPDETAIL_IMAGE1_X, SLEEPDETAIL_IMAGE2_Y); - LOADIMG::LoadImageViewImg(image2, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_ORANGE_CIR); - group->Add(image2); - - rapidEyeMovement_ = new UILabel(); - if (rapidEyeMovement_ == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rapidEyeMovement_ is nullptr"); - return; - } - rapidEyeMovement_->SetPosition(SLEEPDETAIL_SOBERINGTIME_X, SLEEPDETAIL_RAPID_Y); - rapidEyeMovement_->Resize(SLEEPDETAIL_RAPID_WIDTH, SLEEPDETAIL_RAPID_HEIGHT); - rapidEyeMovement_->SetText("快速动眼"); - rapidEyeMovement_->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - rapidEyeMovement_->SetTextColor(Color::White()); - rapidEyeMovement_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPDETAIL_SOBERINGTIME_FONT_SIZE); - rapidEyeMovement_->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); - group->Add(rapidEyeMovement_); -} - -void SleepingDetailsPage::InitLightSleepTime() -{ - image3 = new UIImageView(); - if (image3 == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "image3 is nullptr"); - return; - } - image3->SetPosition(SLEEPDETAIL_IMAGE1_X, SLEEPDETAIL_IMAGE3_Y); - LOADIMG::LoadImageViewImg(image3, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_GREEN_CIR); - group->Add(image3); - - lightSleepTime_ = new UILabel(); - if (lightSleepTime_ == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "lightSleepTime_ is nullptr"); - return; - } - lightSleepTime_->SetPosition(SLEEPDETAIL_SOBERINGTIME_X, SLEEPDETAIL_LIGHT_Y); - lightSleepTime_->Resize(SLEEPDETAIL_SOBERINGTIME_WIDTH, SLEEPDETAIL_SOBERINGTIME_HEIGHT); - lightSleepTime_->SetText("浅睡"); - lightSleepTime_->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - lightSleepTime_->SetTextColor(Color::White()); - lightSleepTime_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPDETAIL_SOBERINGTIME_FONT_SIZE); - lightSleepTime_->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); - group->Add(lightSleepTime_); -} - -void SleepingDetailsPage::InitDeepSleepTime() -{ - image4 = new UIImageView(); - if (image4 == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "image4 is nullptr"); - return; - } - image4->SetPosition(SLEEPDETAIL_IMAGE1_X, SLEEPDETAIL_IMAGE4_Y); - LOADIMG::LoadImageViewImg(image4, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_BLUE_CIR); - group->Add(image4); - - deepSleepTime_ = new UILabel(); - if (deepSleepTime_ == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "deepSleepTime_ is nullptr"); - return; - } - deepSleepTime_->SetPosition(SLEEPDETAIL_SOBERINGTIME_X, SLEEPDETAIL_DEEP_Y); - deepSleepTime_->Resize(SLEEPDETAIL_SOBERINGTIME_WIDTH, SLEEPDETAIL_SOBERINGTIME_HEIGHT); - deepSleepTime_->SetText("深睡"); - deepSleepTime_->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - deepSleepTime_->SetTextColor(Color::White()); - deepSleepTime_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPDETAIL_SOBERINGTIME_FONT_SIZE); - deepSleepTime_->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); - group->Add(deepSleepTime_); -} - -void SleepingDetailsPage::InitPage() -{ - grayBg = new UIImageView(); - if (grayBg == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "grayBg is nullptr"); - return; - } - grayBg->SetPosition(SLEEPDETAIL_GRAYBG_X, SLEEPDETAIL_GRAYBG_Y); - LOADIMG::LoadImageViewImg(grayBg, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_RECORD_BG); - group->Add(grayBg); - - // 加载详情四项 - InitSoberingTime(); - InitRapidEyeMovement(); - InitLightSleepTime(); - InitDeepSleepTime(); -} - -void SleepingDetailsPage::IoadDeatilActualSleepTime() -{ - actualSleepTimeHours = new UILabel(); - if (actualSleepTimeHours == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "actualSleepTimeHours is nullptr"); - return; - } - - actualSleepTimeHours->SetTextColor(Color::White()); - actualSleepTimeHours->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPDETAIL_ACTUALSLEEPTIMEHOURS_FONT_SIZE); - actualSleepTimeHours->SetVisible(false); - - actualSleepTimeHoursText = new UILabel(); - if (actualSleepTimeHoursText == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "actualSleepTimeHoursText is nullptr"); - return; - } - actualSleepTimeHoursText->SetText("小时"); - actualSleepTimeHoursText->Resize(SLEEPDETAIL_SOBERINGTIME_WIDTH, SLEEPDETAIL_SOBERINGTIME_HEIGHT); - actualSleepTimeHoursText->SetTextColor(Color::White()); - actualSleepTimeHoursText->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPDETAIL_SOBERINGTIME_FONT_SIZE); - actualSleepTimeHoursText->SetVisible(false); - - actualSleepTimeMinutes = new UILabel(); - if (actualSleepTimeMinutes == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "actualSleepTimeMinutes is nullptr"); - return; - } - - actualSleepTimeMinutes->Resize(SLEEPDETAIL_RAPID_WIDTH, SLEEPDETAIL_ACTUALSLEEPTIMINUTES_HEIGHT); - actualSleepTimeMinutes->SetTextColor(Color::White()); - actualSleepTimeMinutes->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPDETAIL_ACTUALSLEEPTIMINUTES_FONT_SIZE); - actualSleepTimeMinutes->SetVisible(false); - - actualSleepTimeMinutesText = new UILabel(); - if (actualSleepTimeMinutesText == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "actualSleepTimeHours is nullptr"); - return; - } - - actualSleepTimeMinutesText->SetText("分钟"); - actualSleepTimeMinutesText->Resize(SLEEPDETAIL_SOBERINGTIME_WIDTH, SLEEPDETAIL_SOBERINGTIME_HEIGHT); - actualSleepTimeMinutesText->SetTextColor(Color::White()); - actualSleepTimeMinutesText->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPDETAIL_SOBERINGTIME_FONT_SIZE); - actualSleepTimeMinutesText->SetVisible(false); -} - -void SleepingDetailsPage::InitActualSleepTime(std::tuple timeTuple) -{ - IoadDeatilActualSleepTime(); - uint32_t hours = std::get<0>(timeTuple); - uint32_t minutes = std::get<1>(timeTuple); - - if ((hours == 0) && (minutes != 0)) { - actualSleepTimeMinutes->SetPosition(SLEEPDETAIL_ACTUALSLEEP_X, SLEEPDETAIL_ACTUALSLEEP_Y); - actualSleepTimeMinutes->SetVisible(true); - actualSleepTimeMinutes->SetText(std::to_string(minutes).c_str()); - group->Add(actualSleepTimeMinutes); - - actualSleepTimeMinutesText->SetPosition(SLEEPDETAIL_ACTUALMINUTE_X, SLEEPDETAIL_ACTUALMINUTE_Y); - actualSleepTimeMinutesText->SetVisible(true); - group->Add(actualSleepTimeMinutesText); - } else if ((hours != 0) && (minutes == 0)) { - actualSleepTimeHours->SetPosition(SLEEPDETAIL_ACTUALSLEEP_X, SLEEPDETAIL_ACTUALSLEEP_Y); - actualSleepTimeHours->Resize(SLEEPDETAIL_ACTUALSLEEPTIMINUTES_HEIGHT, SLEEPDETAIL_ACTUALSLEEPTIMINUTES_HEIGHT); - actualSleepTimeHours->SetVisible(true); - actualSleepTimeHours->SetText(std::to_string(hours).c_str()); - group->Add(actualSleepTimeHours); - - actualSleepTimeHoursText->SetPosition(SLEEPDETAIL_ACTUALMINUTE_X, SLEEPDETAIL_ACTUALMINUTE_Y); - actualSleepTimeHoursText->SetVisible(true); - group->Add(actualSleepTimeHoursText); - } else if ((hours != 0) && (minutes != 0)) { - actualSleepTimeHours->SetPosition(SLEEPDETAIL_ACTUALHOUR_X, SLEEPDETAIL_ACTUALHOUR_Y); - actualSleepTimeHours->Resize(SLEEPDETAIL_ACTUALSLEEPTIMINUTES_HEIGHT, SLEEPDETAIL_ACTUALSLEEPTIMINUTES_HEIGHT); - - actualSleepTimeHours->SetVisible(true); - actualSleepTimeHours->SetText(std::to_string(hours).c_str()); - group->Add(actualSleepTimeHours); - - actualSleepTimeHoursText->SetPosition(SLEEPDETAIL_ACTUALHOURTEXT_X, SLEEPDETAIL_ACTUALMINUTE_Y); - actualSleepTimeHoursText->SetVisible(true); - group->Add(actualSleepTimeHoursText); - - actualSleepTimeMinutes->SetPosition(SLEEPDETAIL_ACTUALMINUTE_X, SLEEPDETAIL_ACTUALHOUR_Y); - actualSleepTimeMinutes->SetVisible(true); - actualSleepTimeMinutes->SetText(std::to_string(minutes).c_str()); - group->Add(actualSleepTimeMinutes); - - actualSleepTimeMinutesText->SetPosition(SLEEPDETAIL_ACTUALMINUTETEXT_X, SLEEPDETAIL_ACTUALMINUTE_Y); - actualSleepTimeMinutesText->SetVisible(true); - group->Add(actualSleepTimeMinutesText); - } else if ((hours == 0) && (minutes == 0)) { - actualSleepTimeHours->SetPosition(ACTUALHOURS_X, SLEEPDETAIL_ACTUALHOUR_Y); - actualSleepTimeHours->Resize(SLEEPDETAIL_ACTUALSLEEPTIMINUTES_HEIGHT, SLEEPDETAIL_ACTUALSLEEPTIMINUTES_HEIGHT); - actualSleepTimeHours->SetVisible(true); - actualSleepTimeHours->SetText("--"); - group->Add(actualSleepTimeHours); - - actualSleepTimeHoursText->SetPosition(ACTUALHOURSTEXT_X, SLEEPDETAIL_ACTUALMINUTE_Y); - actualSleepTimeHoursText->SetVisible(true); - group->Add(actualSleepTimeHoursText); - - actualSleepTimeMinutes->SetPosition(SLEEPDETAIL_ACTUALMINUTE_X, SLEEPDETAIL_ACTUALHOUR_Y); - actualSleepTimeMinutes->SetVisible(true); - actualSleepTimeMinutes->SetText("--"); - group->Add(actualSleepTimeMinutes); - - actualSleepTimeMinutesText->SetPosition(ACTUALMINUTESTEXT_X, SLEEPDETAIL_ACTUALMINUTE_Y); - actualSleepTimeMinutesText->SetVisible(true); - group->Add(actualSleepTimeMinutesText); - } -} - -void SleepingDetailsPage::InitDetailPage() -{ - InitActualSleepTime(SleepingModel::GetInstance().GetSleepTime()); - - soberingTimeText = new UILabel(); - if (soberingTimeText == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "soberingTimeText is nullptr"); - return; - } - soberingTimeText->SetText((SetTimeText(SleepingModel::GetInstance().GetSoberingTime())).c_str()); - soberingTimeText->SetPosition(SLEEPDETAIL_SOBERINGTEXT_X, SLEEPDETAIL_SOBERINGTIME_Y); - - soberingTimeText->Resize(SLEEPDETAIL_LABEL_WIDTH, SLEEPDETAIL_RAPID_HEIGHT); - soberingTimeText->SetTextColor(Color::White()); - soberingTimeText->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPDETAIL_SOBERINGTIME_FONT_SIZE); - soberingTimeText->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER); - soberingTimeText->SetStyle(STYLE_PADDING_RIGHT, SLEEPDETAIL_PADDING_RIGHT); - group->Add(soberingTimeText); - - rapidEyeMovementText = new UILabel(); - if (rapidEyeMovementText == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rapidEyeMovementText is nullptr"); - return; - } - rapidEyeMovementText->SetText((SetTimeText(SleepingModel::GetInstance().GetRapidEyeMovementTime())).c_str()); - rapidEyeMovementText->SetPosition(SLEEPDETAIL_SOBERINGTEXT_X, SLEEPDETAIL_RAPID_Y); - - rapidEyeMovementText->Resize(SLEEPDETAIL_LABEL_WIDTH, SLEEPDETAIL_RAPID_HEIGHT); - rapidEyeMovementText->SetTextColor(Color::White()); - rapidEyeMovementText->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPDETAIL_SOBERINGTIME_FONT_SIZE); - rapidEyeMovementText->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER); - rapidEyeMovementText->SetStyle(STYLE_PADDING_RIGHT, SLEEPDETAIL_PADDING_RIGHT); - group->Add(rapidEyeMovementText); - - lightSleepTimeText = new UILabel(); - if (lightSleepTimeText == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "lightSleepTimeText is nullptr"); - return; - } - lightSleepTimeText->SetText((SetTimeText(SleepingModel::GetInstance().GetLightSleepTime())).c_str()); - lightSleepTimeText->SetPosition(SLEEPDETAIL_SOBERINGTEXT_X, SLEEPDETAIL_LIGHT_Y); - lightSleepTimeText->Resize(SLEEPDETAIL_LABEL_WIDTH, SLEEPDETAIL_RAPID_HEIGHT); - lightSleepTimeText->SetTextColor(Color::White()); - lightSleepTimeText->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPDETAIL_SOBERINGTIME_FONT_SIZE); - lightSleepTimeText->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER); - lightSleepTimeText->SetStyle(STYLE_PADDING_RIGHT, SLEEPDETAIL_PADDING_RIGHT); - group->Add(lightSleepTimeText); - - deepSleepTimeText = new UILabel(); - if (deepSleepTimeText == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "deepSleepTimeText is nullptr"); - return; - } - deepSleepTimeText->SetText((SetTimeText(SleepingModel::GetInstance().GetDeepSleepTime())).c_str()); - deepSleepTimeText->SetPosition(SLEEPDETAIL_SOBERINGTEXT_X, SLEEPDETAIL_DEEP_Y); - deepSleepTimeText->Resize(SLEEPDETAIL_LABEL_WIDTH, SLEEPDETAIL_RAPID_HEIGHT); - deepSleepTimeText->SetTextColor(Color::White()); - deepSleepTimeText->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPDETAIL_SOBERINGTIME_FONT_SIZE); - deepSleepTimeText->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER); - deepSleepTimeText->SetStyle(STYLE_PADDING_RIGHT, SLEEPDETAIL_PADDING_RIGHT); - group->Add(deepSleepTimeText); -} - -void SleepingDetailsPage::InitNoDeatilPage() -{ - actualSleepTime = new UILabel(); - if (actualSleepTime == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "actualSleepTime is nullptr"); - return; - } - actualSleepTime->SetText("无记录"); - actualSleepTime->SetPosition(SLEEPDETAIL_ACTUALSLEEP_NORECORD_X, SLEEPDETAIL_ACTUALSLEEP_NORECORD_Y); - actualSleepTime->Resize(SLEEPDETAIL_ACTUAL_NORECODE_X, SLEEPDETAIL_SOBERINGTIME_WIDTH); - actualSleepTime->SetTextColor(Color::White()); - actualSleepTime->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPDETAIL_ACTUALSLEEP_FONT_SIZE); - group->Add(actualSleepTime); - - soberingTimeText = new UILabel(); - if (soberingTimeText == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "soberingTimeText is nullptr"); - return; - } - soberingTimeText->SetText("--"); - soberingTimeText->SetPosition(SLEEPDETAIL_SOBERTIMETEXT_X, SLEEPDETAIL_SOBERTIMETEXT_Y); - soberingTimeText->Resize(SLEEPDETAIL_RAPID_WIDTH, SLEEPDETAIL_RAPID_HEIGHT); - soberingTimeText->SetTextColor(Color::White()); - soberingTimeText->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPDETAIL_SOBERINGTIME_FONT_SIZE); - soberingTimeText->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER); - group->Add(soberingTimeText); - - rapidEyeMovementText = new UILabel(); - if (rapidEyeMovementText == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rapidEyeMovementText is nullptr"); - return; - } - rapidEyeMovementText->SetText("--"); - rapidEyeMovementText->SetPosition(SLEEPDETAIL_SOBERTIMETEXT_X, SLEEPDETAIL_RAPIDTIMETEXT_Y); - rapidEyeMovementText->Resize(SLEEPDETAIL_RAPID_WIDTH, SLEEPDETAIL_RAPID_HEIGHT); - rapidEyeMovementText->SetTextColor(Color::White()); - rapidEyeMovementText->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPDETAIL_SOBERINGTIME_FONT_SIZE); - rapidEyeMovementText->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER); - group->Add(rapidEyeMovementText); - - lightSleepTimeText = new UILabel(); - if (lightSleepTimeText == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "lightSleepTimeText is nullptr"); - return; - } - lightSleepTimeText->SetText("--"); - lightSleepTimeText->SetPosition(SLEEPDETAIL_SOBERTIMETEXT_X, SLEEPDETAIL_LIGHTIMETEXT_Y); - lightSleepTimeText->Resize(SLEEPDETAIL_RAPID_WIDTH, SLEEPDETAIL_RAPID_HEIGHT); - lightSleepTimeText->SetTextColor(Color::White()); - lightSleepTimeText->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPDETAIL_SOBERINGTIME_FONT_SIZE); - lightSleepTimeText->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER); - group->Add(lightSleepTimeText); - - deepSleepTimeText = new UILabel(); - if (deepSleepTimeText == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "deepSleepTimeText is nullptr"); - return; - } - deepSleepTimeText->SetText("--"); - deepSleepTimeText->SetPosition(SLEEPDETAIL_SOBERTIMETEXT_X, SLEEPDETAIL_DEEPIMETEXT_Y); - deepSleepTimeText->Resize(SLEEPDETAIL_RAPID_WIDTH, SLEEPDETAIL_RAPID_HEIGHT); - deepSleepTimeText->SetTextColor(Color::White()); - deepSleepTimeText->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPDETAIL_SOBERINGTIME_FONT_SIZE); - deepSleepTimeText->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER); - group->Add(deepSleepTimeText); -} - -std::string SleepingDetailsPage::SetTimeText(std::tuple timeTuple) -{ - uint32_t hours = std::get<0>(timeTuple); - uint32_t minutes = std::get<1>(timeTuple); - - std::string str = ""; - if ((hours == 0) && (minutes != 0)) { - str = std::to_string(minutes) + "分钟"; - } else if ((hours != 0) && (minutes == 0)) { - str = std::to_string(hours) + "小时"; - } else if ((hours != 0) && (minutes != 0)) { - str = std::to_string(hours) + "小时" + std::to_string(minutes) + "分钟"; - } else if ((hours == 0) && (minutes == 0)) { - str = "---"; - } - return str; -} - -bool SleepingDetailsPage::OnDrag(UIView &view, const DragEvent &event) -{ - UNUSED(view); - if (event.GetDragDirection() == DragEvent::DIRECTION_TOP_TO_BOTTOM) { - NativeAbility::GetInstance().SwitchSlice(VIEW_SLEEPING, SLEEPING_PAGES::SLEEPING_MAIN_PAGE); - } - return true; -} - -bool SleepingDetailsPage::GetRecord() -{ - if (SleepingModel::GetInstance().GetRecord()) { - return true; - } - return false; -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/sleep/src/SleepingMainPage.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/sleep/src/SleepingMainPage.cpp deleted file mode 100644 index d88a582cc..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/sleep/src/SleepingMainPage.cpp +++ /dev/null @@ -1,705 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: SleepingMainPage - * Created: 2025-06-05 - */ - -#include -#include "components/ui_list_nested.h" -#include "components/ui_scroll_view_nested.h" -#include "NativeAbility.h" -#include "SlicePageFactory.h" -#include "PageTransitionMgr.h" -#include "settings/SetDesktopModel.h" -#include "rebootdevice/RebootModel.h" -#include "common/image_cache_manager.h" -#include "diag_service.h" -#include "msg_center_device.h" -#include "diag_common.h" -#include "sleep/TargetSleepTime.h" -#include "sleep/SleepingMainPage.h" -#include "sleep/SleepingPresenter.h" -#include "sleep/SleepingView.h" - -namespace OHOS { - -REGIST_SLICE_PAGE(VIEW_SLEEPING, SLEEPING_PAGES::SLEEPING_MAIN_PAGE, SleepingMainPage, true); - -static constexpr int16_t SLEEPMAIN_SLEEP_X = 190; -static constexpr int16_t SLEEPMAIN_SLEEP_Y = 50; -static constexpr int16_t SLEEPMAIN_SLEEP_WIDTH = 64; -static constexpr int16_t SLEEPMAIN_SLEEP_HEIGHT = 38; -static constexpr int16_t SLEEPMAIN_SLEEP_FONT_SIZE = 38; -static constexpr int16_t SLEEPMAIN_NORECORD_X = 179; -static constexpr int16_t SLEEPMAIN_NORECORD_Y = 179; -static constexpr int16_t SLEEPMAIN_NORECORD_WIDTH = 96; -static constexpr int16_t SLEEPMAIN_NORECORD_HEIGHT = 48; -static constexpr int16_t SLEEPMAIN_NORECORD_FONT_SIZE = 38; -static constexpr int16_t SLEEPMAIN_TIPS_X = 93; -static constexpr int16_t SLEEPMAIN_TIPS_Y = 321; -static constexpr int16_t SLEEPMAIN_TIPS_WIDTH = 188; -static constexpr int16_t SLEEPMAIN_TIPS_HEIGHT = 87; -static constexpr int16_t SLEEPMAIN_TIPS_FONT_SIZE = 24; -static constexpr int16_t SLEEPMAIN_SCORE_X = 164; -static constexpr int16_t SLEEPMAIN_SCORE_Y = 129; -static constexpr int16_t SLEEPMAIN_SCORE_WIDTH = 95; -static constexpr int16_t SLEEPMAIN_SCORE_HEIGHT = 65; -static constexpr int16_t SLEEPMAIN_SCORE_FONT_SIZE = 56; -static constexpr int16_t SLEEPMAIN_MOONNORECORD_X = 154; -static constexpr int16_t SLEEPMAIN_MOONNORECORD_Y = 154; -static constexpr int16_t SLEEPMAIN_SCORETEXT_FONT_SIZE = 21; -static constexpr int16_t SLEEP_SCORE_THRESHOLD_1 = 20; -static constexpr int16_t SLEEP_SCORE_THRESHOLD_2 = 40; -static constexpr int16_t SLEEP_SCORE_THRESHOLD_3 = 60; -static constexpr int16_t SLEEP_SCORE_THRESHOLD_4 = 80; -static constexpr int16_t SLEEP_SCORE_THRESHOLD_5 = 100; -static constexpr int16_t SLEEP_FONT_SIZE_LARGE = 40; -static constexpr int16_t SLEEPMAIN_SCORETEXT_X = 265; -static constexpr int16_t SLEEPMAIN_SCORETEXT_Y = 161; -static constexpr int16_t SLEEP_LABEL_WIDTH = 48; -static constexpr int16_t SLEEP_LABEL_HEIGHT = 29; -static constexpr int16_t SLEEP_TIME_LABEL_WIDTH = 100; -static constexpr int16_t SLEEP_TIME_LABEL_HEIGHT = 50; -static constexpr int16_t SLEEPMAIN_SETTING_X = 280; -static constexpr int16_t SLEEPMAIN_SETTING_Y = 374; -static constexpr int16_t SLEEPMAIN_ACTUALMINUTE_X = 230; -static constexpr int16_t SLEEPMAIN_ACTUALMINUTE_Y = 319; -static constexpr int16_t SLEEPMAIN_ACTUALHOUR_X = 135; -static constexpr int16_t ACTUALHOURS_X = 140; -static constexpr int16_t ACTUALMINUTES_X = 180; -static constexpr int16_t ACTUALMINUTES_Y = 303; -static constexpr int16_t SLEEPMAIN_ACTUALHOURTEXT_X = 170; -static constexpr int16_t SLEEPDETAIL_ACTUALSLEEPTIMEHOURS_FONT_SIZE = 32; -static constexpr int16_t SLEEPMAIN_HEIGHT = 50; -static constexpr int16_t SLEEPDETAIL_ACTUALSLEEPTIMINUTES_FONT_SIZE = 40; -static constexpr int16_t SLEEPMAIN_ACTUALMINUTETEXT_X = 280; -static constexpr int16_t SLEEPMAIN_ACTUALH_X = 170; -static constexpr int16_t SLEEPMAIN_ACTUALMINUTETEXT2_X = 270; -static constexpr int16_t SLEEPMAIN_CIR_HIGHT = 444; -static constexpr int16_t SLEEPMAIN_CIR_X = 228; -static constexpr int16_t SLEEPMAIN_CIR_Y = 228; -static constexpr int16_t SLEEPMAIN_CIR_RADIUS = 215; -static constexpr int16_t SLEEPMAIN_CIR_ANGLE = 360; -static constexpr int16_t SLEEPMAIN_CIR_RANGE = 100; -static constexpr int16_t SLEEPMAIN_CIR_LINE_WIDTH = 10; -static constexpr int16_t SLEEPMAIN_SCORE = 100; -static constexpr int16_t SLEEPMAIN_RATE = 100; -static constexpr float MINUTE_HOUR = 60.0f; -static constexpr int16_t TARGETTIMETEXT_Y = 363; -static constexpr int16_t TARGETTIMEBUTTON_X = 137; -static constexpr int16_t TARGETTIMETEXT_WIDTH = 184; -static constexpr int16_t TARGETTIMETEXT_HIGHT = 46; -static constexpr int16_t MAIN_SLEEP_COLOR_R = 181; -static constexpr int16_t MAIN_SLEEP_COLOR_G = 402; -static constexpr int16_t MAIN_SLEEP_COLOR_B = 255; -static constexpr int16_t MAIN_SLEEP_OPT = 110; -static constexpr int16_t MAIN_SLEEP_RANGE = 10; -static constexpr int16_t MAIN_SLEEP_POSX_2 = 2; -static constexpr int16_t MAIN_SLEEP_POSX_3 = 3; -static constexpr int16_t MAIN_SLEEP_POSX_4 = 4; -static constexpr int16_t MAIN_SLEEP_MOON_POSX = 198; -static constexpr int16_t MAIN_SLEEP_SCORE_HEIGHT = 192; -static constexpr int16_t MAIN_SLEEP_SCORE_X = 131; -static constexpr int16_t MAIN_SLEEP_SCORE_Y = 200; -static constexpr int16_t MAIN_SLEEP_STAR1_X = 145; -static constexpr int16_t MAIN_SLEEP_STAR2_X = 180; -static constexpr int16_t MAIN_SLEEP_STAR3_X = 215; -static constexpr int16_t MAIN_SLEEP_STAR4_X = 250; -static constexpr int16_t MAIN_SLEEP_STAR5_X = 285; -static constexpr int16_t MAIN_SLEEP_STAR_Y = 255; -static constexpr int16_t MAIN_SLEEP_SCORE_TEXT_FONT_SIZE = 55; -static constexpr int16_t MAIN_SLEEP_STAR_NUM = 5; - -int posX[MAIN_SLEEP_STAR_NUM] = {MAIN_SLEEP_STAR1_X, MAIN_SLEEP_STAR2_X, MAIN_SLEEP_STAR3_X, MAIN_SLEEP_STAR4_X, MAIN_SLEEP_STAR5_X}; -int posY = MAIN_SLEEP_STAR_Y; - -SleepingMainPage::SleepingMainPage() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SleepingMainPage::SleepingMainPage"); -} - -SleepingMainPage::~SleepingMainPage() -{ - if (group != nullptr) { - group->RemoveAll(); - delete group; - group = nullptr; - } - - if (imageViewMain != nullptr) { - delete imageViewMain; - imageViewMain = nullptr; - } - - if (sleep != nullptr) { - delete sleep; - sleep = nullptr; - } - - if (moonNoRecord != nullptr) { - delete moonNoRecord; - moonNoRecord = nullptr; - } - - if (moon != nullptr) { - delete moon; - moon = nullptr; - } - - if (noRecord != nullptr) { - delete noRecord; - noRecord = nullptr; - } - - if (tips != nullptr) { - delete tips; - tips = nullptr; - } - - if (sleepScores_ != nullptr) { - delete sleepScores_; - sleepScores_ = nullptr; - } - - if (scoreText != nullptr) { - delete scoreText; - scoreText = nullptr; - } - - if (sleepScore != nullptr) { - delete sleepScore; - sleepScore = nullptr; - } - - if (scoreDisplayPicture1 != nullptr) { - delete scoreDisplayPicture1; - scoreDisplayPicture1 = nullptr; - } - - if (scoreDisplayPicture2 != nullptr) { - delete scoreDisplayPicture2; - scoreDisplayPicture2 = nullptr; - } - - if (scoreDisplayPicture3 != nullptr) { - delete scoreDisplayPicture3; - scoreDisplayPicture3 = nullptr; - } - if (scoreDisplayPicture4 != nullptr) { - delete scoreDisplayPicture4; - scoreDisplayPicture4 = nullptr; - } - - if (scoreDisplayPicture5 != nullptr) { - delete scoreDisplayPicture5; - scoreDisplayPicture5 = nullptr; - } - - if (setting != nullptr) { - delete setting; - setting = nullptr; - } - - if (targetTimeText != nullptr) { - delete targetTimeText; - targetTimeText = nullptr; - } - - if (actualSleepTimeHours != nullptr) { - delete actualSleepTimeHours; - actualSleepTimeHours = nullptr; - } - - if (actualSleepTimeHoursText != nullptr) { - delete actualSleepTimeHoursText; - actualSleepTimeHoursText = nullptr; - } - - if (actualSleepTimeMinutes != nullptr) { - delete actualSleepTimeMinutes; - actualSleepTimeMinutes = nullptr; - } - - if (actualSleepTimeMinutesText != nullptr) { - delete actualSleepTimeMinutesText; - actualSleepTimeMinutesText = nullptr; - } - - if (targetTimeButton != nullptr) { - delete targetTimeButton; - targetTimeButton = nullptr; - } - - if (circleProgress != nullptr) { - delete circleProgress; - circleProgress = nullptr; - } - - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SleepingMainPage::~SleepingMainPage"); -} - -void SleepingMainPage::OnStart(void* data) -{ - group = new UIScrollView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group is nullptr"); - return; - } - group->SetPosition(0, 0); - group->Resize(RESOLUTION_WIDTH, RESOLUTION_HEIGHT); - group->SetViewId("sleepMain"); - - imageViewMain = new UIImageView(); - if (imageViewMain == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "imageViewMain is nullptr"); - return; - } - LOADIMG::LoadImageViewImg(imageViewMain, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_BACKGROUND); - imageViewMain->SetPosition(0, 0, RESOLUTION_WIDTH, RESOLUTION_HEIGHT); - group->Add(imageViewMain); - - if (GetRecord() == false) { - InitNoRecordPage(); - } else { - InitRecordPage(); - } - - group->SetOnDragListener(this); - group->SetDraggable(true); - group->SetTouchable(true); - AddViewToPageContainer(group); -} - -void SleepingMainPage::InitNoRecordPage() -{ - sleep = new UILabel(); - if (sleep == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sleep is nullptr"); - return; - } - sleep->SetPosition(SLEEPMAIN_SLEEP_X, SLEEPMAIN_SLEEP_Y); - sleep->Resize(SLEEPMAIN_SLEEP_WIDTH, SLEEPMAIN_SLEEP_HEIGHT); - sleep->SetText("睡眠"); - sleep->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - sleep->SetTextColor(Color::White()); - sleep->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPMAIN_SLEEP_FONT_SIZE); - sleep->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - group->Add(sleep); - - moonNoRecord = new UIImageView(); - if (moonNoRecord == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "moonNoRecord is nullptr"); - return; - } - LOADIMG::LoadImageViewImg(moonNoRecord, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_NORECORD_SLEEP); - moonNoRecord->SetPosition(SLEEPMAIN_MOONNORECORD_X, SLEEPMAIN_MOONNORECORD_Y); - group->Add(moonNoRecord); - - noRecord = new UILabel(); - if (noRecord == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "noRecord is nullptr"); - return; - } - noRecord->SetPosition(SLEEPMAIN_NORECORD_X, SLEEPMAIN_NORECORD_Y); - noRecord->Resize(SLEEPMAIN_NORECORD_WIDTH, SLEEPMAIN_NORECORD_HEIGHT); - noRecord->SetText("无记录"); - noRecord->SetTextColor(Color::White()); - noRecord->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPMAIN_NORECORD_FONT_SIZE); - noRecord->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - group->Add(noRecord); - - tips = new UILabel(); - if (tips == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "tips is nullptr"); - return; - } - tips->SetPosition(SLEEPMAIN_TIPS_X, SLEEPMAIN_TIPS_Y); - tips->Resize(SLEEPMAIN_TIPS_WIDTH, SLEEPMAIN_TIPS_HEIGHT); - tips->SetText("睡眠时间过短或睡眠中动作幅度大,手表可能检测不到睡眠"); - tips->SetTextColor(Color::White()); - tips->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPMAIN_TIPS_FONT_SIZE); - tips->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - group->Add(tips); -} - -void SleepingMainPage::InitRecordPage() -{ - SleepingModel::GetInstance().SendData(); - CircleProgress(); - moon = new UIImageView(); - if (moon == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "moon is nullptr"); - return; - } - - moon->SetPosition(MAIN_SLEEP_MOON_POSX, TARGETTIMETEXT_HIGHT); - LOADIMG::LoadImageViewImg(moon, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_RECORD_SLEEP); - group->Add(moon); - - sleepScores_ = new UILabel(); - if (sleepScores_ == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sleepScores_ is nullptr"); - return; - } - - sleepScores_->SetText(std::to_string(GetSleepingScores()).c_str()); - sleepScores_->SetPosition(SLEEPMAIN_SCORE_X, SLEEPMAIN_SCORE_Y); - sleepScores_->Resize(SLEEPMAIN_SCORE_WIDTH, SLEEPMAIN_SCORE_HEIGHT); - sleepScores_->SetTextColor(Color::White()); - sleepScores_->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - sleepScores_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPMAIN_SCORE_FONT_SIZE); - sleepScores_->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER); - group->Add(sleepScores_); - - scoreText = new UILabel(); - if (scoreText == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scoreText is nullptr"); - return; - } - scoreText->SetText("分"); - scoreText->SetPosition(SLEEPMAIN_SCORETEXT_X, SLEEPMAIN_SCORETEXT_Y); - scoreText->Resize(MAIN_SLEEP_SCORE_TEXT_FONT_SIZE, SLEEPMAIN_TIPS_FONT_SIZE); - scoreText->SetTextColor(Color::White()); - scoreText->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPMAIN_SCORETEXT_FONT_SIZE); - group->Add(scoreText); - ScoreDisplay(); - sleepScore = new UILabel(); - if (sleepScore == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sleepScore is nullptr"); - return; - } - sleepScore->SetText("夜间睡眠得分"); - sleepScore->Resize(MAIN_SLEEP_SCORE_HEIGHT, SLEEPMAIN_NORECORD_HEIGHT); - sleepScore->SetPosition(MAIN_SLEEP_SCORE_X, MAIN_SLEEP_SCORE_Y); - sleepScore->SetTextColor(Color::White()); - sleepScore->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPDETAIL_ACTUALSLEEPTIMEHOURS_FONT_SIZE); - group->Add(sleepScore); - - // 显示具体睡觉时间 - IoadActualSleepTime(SleepingModel::GetInstance().GetSleepTime()); - - // 加载目标按钮 - IoadTargetTimeButton(SleepingModel::GetInstance().GetTime()); -} -void SleepingMainPage::InitScoreDisplayPicture() -{ - if (scoreDisplayPicture1 == nullptr) { - scoreDisplayPicture1 = new UIImageView(); - } - scoreDisplayPicture1->SetPosition(posX[0], posY); - group->Add(scoreDisplayPicture1); - - if (scoreDisplayPicture2 == nullptr) { - scoreDisplayPicture2 = new UIImageView(); - } - scoreDisplayPicture2->SetPosition(posX[1], posY); - group->Add(scoreDisplayPicture2); - - if (scoreDisplayPicture3 == nullptr) { - scoreDisplayPicture3 = new UIImageView(); - } - scoreDisplayPicture3->SetPosition(posX[MAIN_SLEEP_POSX_2], posY); - group->Add(scoreDisplayPicture3); - - if (scoreDisplayPicture4 == nullptr) { - scoreDisplayPicture4 = new UIImageView(); - } - scoreDisplayPicture4->SetPosition(posX[MAIN_SLEEP_POSX_3], posY); - group->Add(scoreDisplayPicture4); - - if (scoreDisplayPicture5 == nullptr) { - scoreDisplayPicture5 = new UIImageView(); - } - - scoreDisplayPicture5->SetPosition(posX[MAIN_SLEEP_POSX_4], posY); - group->Add(scoreDisplayPicture5); -} - -void SleepingMainPage::ScoreDisplay() -{ - InitScoreDisplayPicture(); - if (GetSleepingScores() < SLEEP_SCORE_THRESHOLD_1) { - LOADIMG::LoadImageViewImg(scoreDisplayPicture1, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_GRAY); - LOADIMG::LoadImageViewImg(scoreDisplayPicture2, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_GRAY); - LOADIMG::LoadImageViewImg(scoreDisplayPicture3, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_GRAY); - LOADIMG::LoadImageViewImg(scoreDisplayPicture4, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_GRAY); - LOADIMG::LoadImageViewImg(scoreDisplayPicture5, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_GRAY); - } else if (GetSleepingScores() >= SLEEP_SCORE_THRESHOLD_1 && GetSleepingScores() < SLEEP_SCORE_THRESHOLD_2) { - LOADIMG::LoadImageViewImg(scoreDisplayPicture1, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_YELLOW); - LOADIMG::LoadImageViewImg(scoreDisplayPicture2, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_GRAY); - LOADIMG::LoadImageViewImg(scoreDisplayPicture3, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_GRAY); - LOADIMG::LoadImageViewImg(scoreDisplayPicture4, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_GRAY); - LOADIMG::LoadImageViewImg(scoreDisplayPicture5, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_GRAY); - } else if (GetSleepingScores() >= SLEEP_SCORE_THRESHOLD_2 && GetSleepingScores() < SLEEP_SCORE_THRESHOLD_3) { - LOADIMG::LoadImageViewImg(scoreDisplayPicture1, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_YELLOW); - LOADIMG::LoadImageViewImg(scoreDisplayPicture2, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_YELLOW); - LOADIMG::LoadImageViewImg(scoreDisplayPicture3, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_GRAY); - LOADIMG::LoadImageViewImg(scoreDisplayPicture4, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_GRAY); - LOADIMG::LoadImageViewImg(scoreDisplayPicture5, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_GRAY); - } else if (GetSleepingScores() >= SLEEP_SCORE_THRESHOLD_3 && GetSleepingScores() < SLEEP_SCORE_THRESHOLD_4) { - LOADIMG::LoadImageViewImg(scoreDisplayPicture1, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_YELLOW); - LOADIMG::LoadImageViewImg(scoreDisplayPicture2, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_YELLOW); - LOADIMG::LoadImageViewImg(scoreDisplayPicture3, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_YELLOW); - LOADIMG::LoadImageViewImg(scoreDisplayPicture4, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_GRAY); - LOADIMG::LoadImageViewImg(scoreDisplayPicture5, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_GRAY); - } else if (GetSleepingScores() >= SLEEP_SCORE_THRESHOLD_4 && GetSleepingScores() < SLEEP_SCORE_THRESHOLD_5) { - LOADIMG::LoadImageViewImg(scoreDisplayPicture1, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_YELLOW); - LOADIMG::LoadImageViewImg(scoreDisplayPicture2, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_YELLOW); - LOADIMG::LoadImageViewImg(scoreDisplayPicture3, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_YELLOW); - LOADIMG::LoadImageViewImg(scoreDisplayPicture4, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_YELLOW); - LOADIMG::LoadImageViewImg(scoreDisplayPicture5, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_GRAY); - } else if (GetSleepingScores() == SLEEP_SCORE_THRESHOLD_5) { - LOADIMG::LoadImageViewImg(scoreDisplayPicture1, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_YELLOW); - LOADIMG::LoadImageViewImg(scoreDisplayPicture2, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_YELLOW); - LOADIMG::LoadImageViewImg(scoreDisplayPicture3, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_YELLOW); - LOADIMG::LoadImageViewImg(scoreDisplayPicture4, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_YELLOW); - LOADIMG::LoadImageViewImg(scoreDisplayPicture5, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_STAR_YELLOW); - } -} - -void SleepingMainPage::InitSleepTimeLabel() -{ - actualSleepTimeHours = new UILabel(); - if (actualSleepTimeHours == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "actualSleepTimeHours is nullptr"); - return; - } - - actualSleepTimeHours->SetTextColor(Color::White()); - actualSleepTimeHours->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEP_FONT_SIZE_LARGE); - actualSleepTimeHours->SetVisible(false); - - actualSleepTimeHoursText = new UILabel(); - if (actualSleepTimeHoursText == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "actualSleepTimeHoursText is nullptr"); - return; - } - actualSleepTimeHoursText->SetText("小时"); - actualSleepTimeHoursText->Resize(SLEEP_LABEL_WIDTH, SLEEP_LABEL_HEIGHT); - actualSleepTimeHoursText->SetTextColor(Color::White()); - actualSleepTimeHoursText->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPMAIN_TIPS_FONT_SIZE); - actualSleepTimeHoursText->SetVisible(false); - - actualSleepTimeMinutes = new UILabel(); - if (actualSleepTimeMinutes == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "actualSleepTimeMinutes is nullptr"); - return; - } - - actualSleepTimeMinutes->Resize(SLEEP_TIME_LABEL_WIDTH, SLEEP_TIME_LABEL_HEIGHT); - actualSleepTimeMinutes->SetTextColor(Color::White()); - actualSleepTimeMinutes->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEP_FONT_SIZE_LARGE); - actualSleepTimeMinutes->SetVisible(false); - - actualSleepTimeMinutesText = new UILabel(); - if (actualSleepTimeMinutesText == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "actualSleepTimeMinutesText is nullptr"); - return; - } - - actualSleepTimeMinutesText->SetText("分钟"); - actualSleepTimeMinutesText->Resize(SLEEP_LABEL_WIDTH, SLEEP_LABEL_HEIGHT); - actualSleepTimeMinutesText->SetTextColor(Color::White()); - actualSleepTimeMinutesText->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPMAIN_TIPS_FONT_SIZE); - actualSleepTimeMinutesText->SetVisible(false); -} - -void SleepingMainPage::IoadTargetTimeButton(std::tuple timeTuple) -{ - uint32_t hours = std::get<0>(timeTuple); - uint32_t minutes = std::get<1>(timeTuple); - - std::string str = ""; - if ((hours == 0) && (minutes != 0)) { - str = std::to_string(minutes) + "分钟"; - } else if ((hours != 0) && (minutes == 0)) { - str = std::to_string(hours) + "小时"; - } else if ((hours != 0) && (minutes != 0)) { - if (minutes < MAIN_SLEEP_RANGE && hours >= MAIN_SLEEP_RANGE) { - str = " " + std::to_string(hours) + ":0" + std::to_string(minutes); - } else if (hours < MAIN_SLEEP_RANGE && minutes >= MAIN_SLEEP_RANGE) { - str = " 0"+ std::to_string(hours) + ":" + std::to_string(minutes); - } else if (minutes < MAIN_SLEEP_RANGE && hours < MAIN_SLEEP_RANGE) { - str = " 0" + std::to_string(hours) + ":0" + std::to_string(minutes); - } else if (minutes >= MAIN_SLEEP_RANGE && hours >= MAIN_SLEEP_RANGE) { - str = " " + std::to_string(hours) + ":" + std::to_string(minutes); - } - } - targetTimeButton = new UILabelButton(); - if (targetTimeButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "targetTimeButton is nullptr"); - return; - } - targetTimeButton->SetPosition(TARGETTIMEBUTTON_X, TARGETTIMETEXT_Y); - targetTimeButton->SetViewId("targetTime"); - targetTimeButton->SetOnClickListener(this); - targetTimeButton->SetStyle(STYLE_BACKGROUND_COLOR, - Color::GetColorFromRGBA(MAIN_SLEEP_COLOR_R, MAIN_SLEEP_COLOR_G, - MAIN_SLEEP_COLOR_B, MAIN_SLEEP_OPT).full); - targetTimeButton->SetStyleForState ( - STYLE_BACKGROUND_COLOR, Color::GetColorFromRGBA( - MAIN_SLEEP_COLOR_R, MAIN_SLEEP_COLOR_G, MAIN_SLEEP_COLOR_B, MAIN_SLEEP_OPT).full, UIButton::PRESSED); - targetTimeButton->Resize(TARGETTIMETEXT_WIDTH, TARGETTIMETEXT_HIGHT); - targetTimeButton->SetTextColor(Color::White()); - targetTimeButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPMAIN_TIPS_FONT_SIZE); - group->Add(targetTimeButton); - - targetTimeText = new UILabel(); - if (targetTimeText == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "targetTimeText is nullptr"); - return; - } - std::string targetText = "目标" + str; - targetTimeText->SetText(targetText.c_str()); - targetTimeText->SetPosition(SLEEPMAIN_MOONNORECORD_X, TARGETTIMETEXT_Y); - targetTimeText->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - targetTimeText->Resize(TARGETTIMETEXT_WIDTH, TARGETTIMETEXT_HIGHT); - targetTimeText->SetTextColor(Color::White()); - targetTimeText->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SLEEPMAIN_TIPS_FONT_SIZE); - targetTimeText->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); - group->Add(targetTimeText); - - if (setting == nullptr) { - setting = new UIImageView(); - } - setting->SetPosition(SLEEPMAIN_SETTING_X, SLEEPMAIN_SETTING_Y); - LOADIMG::LoadImageViewImg(setting, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_SETTING); - group->Add(setting); -} - -void SleepingMainPage::IoadActualSleepTime(std::tuple timeTuple) -{ - InitSleepTimeLabel(); - uint32_t hours = std::get<0>(timeTuple); - uint32_t minutes = std::get<1>(timeTuple); - - if ((hours == 0) && (minutes != 0)) { - actualSleepTimeMinutes->SetPosition(ACTUALMINUTES_X, ACTUALMINUTES_Y); - actualSleepTimeMinutes->SetVisible(true); - actualSleepTimeMinutes->SetText(std::to_string(minutes).c_str()); - group->Add(actualSleepTimeMinutes); - - actualSleepTimeMinutesText->SetPosition(SLEEPMAIN_ACTUALMINUTE_X, SLEEPMAIN_ACTUALMINUTE_Y); - actualSleepTimeMinutesText->SetVisible(true); - group->Add(actualSleepTimeMinutesText); - } else if ((hours != 0) && (minutes == 0)) { - actualSleepTimeHours->SetPosition(ACTUALMINUTES_X, ACTUALMINUTES_Y); - actualSleepTimeHours->Resize(SLEEPMAIN_HEIGHT, SLEEPMAIN_HEIGHT); - - actualSleepTimeHours->SetVisible(true); - actualSleepTimeHours->SetText(std::to_string(hours).c_str()); - group->Add(actualSleepTimeHours); - - actualSleepTimeHoursText->SetPosition(SLEEPMAIN_ACTUALMINUTE_X, SLEEPMAIN_ACTUALMINUTE_Y); - actualSleepTimeHoursText->SetVisible(true); - group->Add(actualSleepTimeHoursText); - } else if ((hours != 0) && (minutes != 0)) { - actualSleepTimeHours->SetPosition(SLEEPMAIN_ACTUALHOUR_X, ACTUALMINUTES_Y); - actualSleepTimeHours->Resize(SLEEPMAIN_HEIGHT, SLEEPMAIN_HEIGHT); - - actualSleepTimeHours->SetVisible(true); - actualSleepTimeHours->SetText(std::to_string(hours).c_str()); - group->Add(actualSleepTimeHours); - - actualSleepTimeHoursText->SetPosition(SLEEPMAIN_ACTUALHOURTEXT_X, SLEEPMAIN_ACTUALMINUTE_Y); - actualSleepTimeHoursText->SetVisible(true); - group->Add(actualSleepTimeHoursText); - - actualSleepTimeMinutes->SetPosition(SLEEPMAIN_ACTUALMINUTE_X, ACTUALMINUTES_Y); - actualSleepTimeMinutes->SetVisible(true); - actualSleepTimeMinutes->SetText(std::to_string(minutes).c_str()); - group->Add(actualSleepTimeMinutes); - - actualSleepTimeMinutesText->SetPosition(SLEEPMAIN_ACTUALMINUTETEXT_X, SLEEPMAIN_ACTUALMINUTE_Y); - actualSleepTimeMinutesText->SetVisible(true); - group->Add(actualSleepTimeMinutesText); - } else if ((hours == 0) && (minutes == 0)) { - actualSleepTimeHours->SetPosition(ACTUALHOURS_X, ACTUALMINUTES_Y); - actualSleepTimeHours->Resize(SLEEPMAIN_HEIGHT, SLEEPMAIN_HEIGHT); - actualSleepTimeHours->SetVisible(true); - actualSleepTimeHours->SetText("--"); - group->Add(actualSleepTimeHours); - - actualSleepTimeHoursText->SetPosition(ACTUALMINUTES_X, SLEEPMAIN_ACTUALMINUTE_Y); - actualSleepTimeHoursText->SetVisible(true); - group->Add(actualSleepTimeHoursText); - - actualSleepTimeMinutes->SetPosition(SLEEPMAIN_ACTUALMINUTE_X, ACTUALMINUTES_Y); - actualSleepTimeMinutes->SetVisible(true); - actualSleepTimeMinutes->SetText("--"); - group->Add(actualSleepTimeMinutes); - - actualSleepTimeMinutesText->SetPosition(SLEEPMAIN_ACTUALMINUTETEXT2_X, SLEEPMAIN_ACTUALMINUTE_Y); - actualSleepTimeMinutesText->SetVisible(true); - group->Add(actualSleepTimeMinutesText); - } -} - -void SleepingMainPage::CircleProgress() -{ - if (circleProgress == nullptr) { - circleProgress = new UICircleProgress(); - } - circleProgress->SetPosition(0, 0); - circleProgress->Resize(SLEEPMAIN_CIR_HIGHT, SLEEPMAIN_CIR_HIGHT); - - circleProgress->SetCenterPosition(SLEEPMAIN_CIR_X, SLEEPMAIN_CIR_Y); - circleProgress->SetRadius(SLEEPMAIN_CIR_RADIUS); - circleProgress->SetStartAngle(0); - circleProgress->SetEndAngle(SLEEPMAIN_CIR_ANGLE); - circleProgress->SetRange(0, SLEEPMAIN_CIR_RANGE); - circleProgress->SetBackgroundStyle(STYLE_LINE_COLOR, 0xFF6f29a0); - circleProgress->SetForegroundStyle(STYLE_LINE_COLOR, 0xFFB566FF); - circleProgress->SetBackgroundStyle(STYLE_LINE_WIDTH, SLEEPMAIN_CIR_LINE_WIDTH); - circleProgress->SetForegroundStyle(STYLE_LINE_WIDTH, SLEEPMAIN_CIR_LINE_WIDTH); - - group->Add(circleProgress); - circleProgress->SetValue(GetSleepingScores()); - circleProgress->Invalidate(); -} - -uint32_t SleepingMainPage::GetSleepingScores() -{ - uint32_t hours = SleepingModel::GetInstance().GetSleepTimeHours(); - uint32_t minutes = SleepingModel::GetInstance().GetSleepTimeMinutes(); - std::tuple timeTuple = SleepingModel::GetInstance().GetTime(); - uint32_t timeHours = std::get<0>(timeTuple); - uint32_t timeMinutes = std::get<1>(timeTuple); - if (((hours * MINUTE_HOUR) + minutes) > ((timeHours * MINUTE_HOUR) + timeMinutes)) { - return SLEEPMAIN_SCORE; - } else { - float score = ((hours * MINUTE_HOUR) + minutes) / ((timeHours * MINUTE_HOUR) + timeMinutes); - return uint32_t(score * SLEEPMAIN_RATE); - } -} - -bool SleepingMainPage::GetRecord() -{ - if (SleepingModel::GetInstance().GetRecord()) { - return true; - } - return false; -} - -bool SleepingMainPage::OnClick(UIView &view, const ClickEvent &event) -{ - UNUSED(view); - if (strcmp(view.GetViewId(), "targetTime") == 0) { - NativeAbility::GetInstance().SwitchSlice(VIEW_SLEEPING, SLEEPING_PAGES::SLEEPING_TARGET_PAGE); - } - return true; -} - -bool SleepingMainPage::OnDrag(UIView &view, const DragEvent &event) -{ - UNUSED(view); - if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && - (event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SleepingMainPage::OnDrag ChangeSlice(VIEW_APPLIST)"); - } else if (event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) { - NativeAbility::GetInstance().SwitchSlice(VIEW_SLEEPING, SLEEPING_PAGES::SLEEPING_DEATIL_PAGE); - } - return true; -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/sleep/src/SleepingModel.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/sleep/src/SleepingModel.cpp deleted file mode 100644 index fc254503d..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/sleep/src/SleepingModel.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: SleepingModel - * Created: 2025-06-05 - */ - -#include -#include -#include -#include -#include "main/HealthModel.h" -#include "uiservice/ui_service.h" -#include "wearable_log.h" -#include "NativeAbility.h" -#include "ui_test_group.h" -#include "graphic_timer.h" -#include "ohos_timer.h" -#include "wearable_onlinelog.h" -#include "sleep/SleepingModel.h" - -namespace OHOS { -static constexpr uint64_t SLEEPMODEL_MINUTE_HOUR = 60; -static constexpr uint64_t SLEEPMODEL_HOUR = 23; -static constexpr uint64_t SLEEPMODEL_MINUTE = 59; -static constexpr uint64_t SLEEPMODEL_ERROR = 100; -static constexpr uint64_t SLEEPMODEL_DEEP = 4; -static constexpr uint64_t SLEEPMODEL_LIGHT = 3; -static constexpr uint64_t SLEEPMODEL_EYEMOVE = 2; -static constexpr uint64_t SLEEPMODEL_EIGHT_HOUR = 480; - -SleepingModel::SleepingModel() -{ - SetSleepData(); - SetSoberingTime(); - SetRapidEyeMovementTime(); - SetLightSleepTime(); - SetDeepSleepTime(); - SetTime(SLEEPMODEL_EIGHT_HOUR); -} - -SleepingModel::~SleepingModel() -{ -} - -bool SleepingModel::GetRecord() -{ - if (sleepDataVector.empty() == true) { - return false; - } - return true; -} - -uint8_t* SleepingModel::SerializeSleepData(const SleepData* sleepData, size_t* outSize) -{ - if (sleepData == nullptr) { - return nullptr; - } - size_t dataSize = sizeof(SleepData); - *outSize = dataSize; - uint8_t* buffer = new uint8_t[dataSize]; - uint8_t isSendValue = sleepData->isSend ? 1 : 0; - memcpy_s(buffer, sizeof(isSendValue), &isSendValue, sizeof(isSendValue)); - memcpy_s(buffer + offsetof(SleepData, date), sizeof(sleepData->date), - sleepData->date, sizeof(sleepData->date)); - memcpy_s(buffer + offsetof(SleepData, type), sizeof(sleepData->type), - &sleepData->type, sizeof(sleepData->type)); - memcpy_s(buffer + offsetof(SleepData, start), sizeof(sleepData->start), - sleepData->start, sizeof(sleepData->start)); - memcpy_s(buffer + offsetof(SleepData, end), sizeof(sleepData->end), - sleepData->end, sizeof(sleepData->end)); - memcpy_s(buffer + offsetof(SleepData, sleepStart), sizeof(sleepData->sleepStart), - sleepData->sleepStart, sizeof(sleepData->sleepStart)); - memcpy_s(buffer + offsetof(SleepData, sleepEnd), sizeof(sleepData->sleepEnd), - sleepData->sleepEnd, sizeof(sleepData->sleepEnd)); - return buffer; -} - -void SleepingModel::SendData() -{ -#ifndef _WIN32 - // 发送数据 - size_t dataSize; - for (int i = 0; i < sleepDataVector.size(); i++) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "send Date number: %d\n", i+1); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "send front isSend: %s\n\n", - sleepDataVector[i].isSend ? "true" : "false"); - if (sleepDataVector[i].isSend == true) { - continue; - } - PrintSleepData(&sleepDataVector[i]); - uint8_t* serializedData = SerializeSleepData(&sleepDataVector[i], &dataSize); - errcode_t ret = uapi_diag_service_send_log(msg_center_get_trans_channel(), - MSGCENTER_TYPE_ID_SLEEP_DATA, serializedData, dataSize); - delete[] serializedData; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MSGCENTER_TYPE_ID_SLEEP_DATA ret = %d", ret); - if (ret == 0) { - sleepDataVector[i].isSend = true; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "isSend after: %s\n\n", sleepDataVector[i].isSend ? "true" : "false"); - } -#endif -} - -void SleepingModel::SetSleepData() -{ -#ifndef _WIN32 - sleepDataVector.push_back({ - false, "2025-06-03", 4, "2025-06-03 00:00:00", "2025-06-03 00:30:00", - "2025-06-03 00:00:00", "2025-06-03 07:50:00" - }); - sleepDataVector.push_back({ - false, "2025-06-03", 2, "2025-06-03 00:30:00", "2025-06-03 03:00:00", - "2025-06-03 00:00:00", "2025-06-03 07:50:00" - }); - sleepDataVector.push_back({ - false, "2025-06-03", 3, "2025-06-03 03:00:00", "2025-06-03 03:30:00", - "2025-06-03 00:00:00", "2025-06-03 07:50:00" - }); - sleepDataVector.push_back({ - false, "2025-06-03", 1, "2025-06-03 03:30:00", "2025-06-03 05:30:00", - "2025-06-03 00:00:00", "2025-06-03 07:50:00" - }); - sleepDataVector.push_back({ - false, "2025-06-03", 3, "2025-06-03 05:30:00", "2025-06-03 06:00:00", - "2025-06-03 00:00:00", "2025-06-03 07:50:00" - }); - sleepDataVector.push_back({ - false, "2025-06-03", 2, "2025-06-03 06:00:00", "2025-06-03 07:30:00", - "2025-06-03 00:00:00", "2025-06-03 07:50:00" - }); - sleepDataVector.push_back({ - false, "2025-06-03", 4, "2025-06-03 07:30:00", "2025-06-03 07:50:00", - "2025-06-03 00:00:00", "2025-06-03 07:50:00" - }); -#endif -} - -void SleepingModel::PrintSleepData(const SleepData *data) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "isSend: %s\n\n", data->isSend ? "true" : "false"); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PrintSleepData Date: %s\n", data->date); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Sleep type: %u\n", data->type); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Start: %s\n", data->start); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "End: %s\n", data->end); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Sleep Start: %s\n", data->sleepStart); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Sleep End: %s\n", data->sleepEnd); -} - -SleepingModel &SleepingModel::GetInstance() -{ - static SleepingModel instance; - return instance; -} - -std::tuple SleepingModel::GetSoberingTime() -{ - return MinutesToHours(soberingTime); -} - -std::tuple SleepingModel::GetRapidEyeMovementTime() -{ - return MinutesToHours(eyeMoveTime); -} - -std::tuple SleepingModel::GetLightSleepTime() -{ - return MinutesToHours(lightTime); -} - -std::tuple SleepingModel::GetDeepSleepTime() -{ - return MinutesToHours(deepTime); -} - -std::tuple SleepingModel::GetSleepTime() -{ - return MinutesToHours(GetTotalSleepTime()); -} - -std::tuple SleepingModel::MinutesToHours(uint32_t minutes) -{ - if (minutes == 0) { - return std::make_tuple(0, 0); - } - int hours = minutes / SLEEPMODEL_MINUTE_HOUR; - int remainingMinutes = minutes % SLEEPMODEL_MINUTE_HOUR; - - if (hours > SLEEPMODEL_HOUR || remainingMinutes > SLEEPMODEL_MINUTE) { - return std::make_tuple(SLEEPMODEL_ERROR, 0); - } - - return std::make_tuple(hours, remainingMinutes); -} - -uint32_t SleepingModel::GetSleepTimeHours() -{ - std::tuple timeTuple = GetSleepTime(); - return std::get<0>(timeTuple); -} - -uint32_t SleepingModel::GetSleepTimeMinutes() -{ - std::tuple timeTuple = GetSleepTime(); - return std::get<1>(timeTuple); -} - -void SleepingModel::SetTime(uint32_t minute) -{ - sleepTarget = minute; -} - -std::tuple SleepingModel::GetTime() -{ - return MinutesToHours(sleepTarget); -} - -uint32_t SleepingModel::TimeDiffInMinutes(const std::string& timeStr1, const std::string& timeStr2) -{ - std::tm tm1 = {}; - std::tm tm2 = {}; - - std::istringstream iss1(timeStr1); - std::istringstream iss2(timeStr2); - - iss1 >> std::get_time(&tm1, "%Y-%m-%d %H:%M:%S"); - if (iss1.fail()) { - return -1; - } - - iss2 >> std::get_time(&tm2, "%Y-%m-%d %H:%M:%S"); - if (iss2.fail()) { - return -1; - } - - std::time_t t1 = std::mktime(&tm1); - std::time_t t2 = std::mktime(&tm2); - if (t1 == -1 || t2 == -1) { - return -1; - } - - double diff_seconds = std::difftime(t2, t1); - return static_cast(diff_seconds / SLEEPMODEL_MINUTE_HOUR); -} - -// 遍历vector中的结构体 获取对应类型的时间差 -uint32_t SleepingModel::GetDetailData(int type) -{ - uint32_t min = 0; - for (size_t i = 0; i < sleepDataVector.size(); ++i) { - if (sleepDataVector[i].type == type) { - min += TimeDiffInMinutes(sleepDataVector[i].start, sleepDataVector[i].end); - } - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GetDetailData type: %d\n", type); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GetDetailData min: %d\n", min); - return min; -} - -// 获取总睡觉时间的时间差 -uint32_t SleepingModel::GetTotalSleepTime() -{ - uint32_t time = TimeDiffInMinutes(sleepDataVector[0].sleepStart, sleepDataVector[0].sleepEnd); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GetTotalSleepTime time: %d\n", time); - return time; -} - -void SleepingModel::SetSoberingTime() -{ - soberingTime = GetDetailData(SLEEPMODEL_DEEP); -} -void SleepingModel::SetRapidEyeMovementTime() -{ - eyeMoveTime=GetDetailData(SLEEPMODEL_LIGHT); -} -void SleepingModel::SetLightSleepTime() -{ - lightTime = GetDetailData(SLEEPMODEL_EYEMOVE); -} -void SleepingModel::SetDeepSleepTime() -{ - deepTime = GetDetailData(1); -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/sleep/src/SleepingPresenter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/sleep/src/SleepingPresenter.cpp deleted file mode 100644 index e1b9bf839..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/sleep/src/SleepingPresenter.cpp +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: SleepingPresenter - * Created: 2025-06-05 - */ - -#include "NativeRegisterManager.h" -#include "sleep/SleepingView.h" -#include "sleep/SleepingPresenter.h" - -namespace OHOS { -REGIST_MENU(VIEW_SLEEPING, SleepingView, SleepingPresenter, SLEEP_ICON, PNG_APPLIST_DEFAULT_IMG, "睡眠"); -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/sleep/src/TargetSleepTime.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/sleep/src/TargetSleepTime.cpp deleted file mode 100644 index 4eab1f32f..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/sleep/src/TargetSleepTime.cpp +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TargetSleepTime - * Created: 2025-06-05 - */ -#include -#include "components/ui_list_nested.h" -#include "components/ui_scroll_view_nested.h" -#include "NativeAbility.h" -#include "SlicePageFactory.h" -#include "PageTransitionMgr.h" -#include "settings/SetDesktopModel.h" -#include "rebootdevice/RebootModel.h" -#include "common/image_cache_manager.h" -#include "sleep/TargetSleepTime.h" -#include "sleep/SleepingMainPage.h" -#include "sleep/SleepingPresenter.h" -#include "sleep/SleepingView.h" - -namespace OHOS { -constexpr uint8_t BACKGROUND_FONT = 40; -constexpr uint8_t HIGHTLIGHT_FONT = 50; -static constexpr int16_t TARGET_SLEEP_SETTARGET_X = 120; -static constexpr int16_t TARGET_SLEEP_SETTARGET_Y = 40; -static constexpr int16_t TARGET_SLEEP_SETTARGET_WIDTH = 200; -static constexpr int16_t TARGET_SLEEP_SETTARGET_HIGHT = 38; -static constexpr int16_t TARGET_SLEEP_SETTARGET_FONT_SIZE = 32; -static constexpr int16_t TARGET_SLEEP_START_X = 112; -static constexpr int16_t TARGET_SLEEP_START_Y = 347; -static constexpr int16_t TARGET_SLEEP_START_WIDTH = 232; -static constexpr int16_t TARGET_SLEEP_START_HIGHT = 76; -static constexpr int16_t TARGET_SLEEP_PICKER2_X = 270; -static constexpr int16_t TARGET_SLEEP_PICKER_Y = 132; -static constexpr int16_t TARGET_SLEEP_PICKER_WIDTH = 80; -static constexpr int16_t TARGET_SLEEP_PICKER_HIGHT = 188; -static constexpr int16_t TARGET_SLEEP_PICKER_BORDER = 3; -static constexpr int16_t TARGET_SLEEP_PICKER_RADIUS = 11; -static constexpr int16_t TARGET_SLEEP_PICKER_ITEM = 63; -static constexpr int16_t TARGET_SLEEP_PICKER_HOUR = 24; -static constexpr int16_t TARGET_SLEEP_PICKER_MINUTE = 60; -static constexpr int16_t TARGET_SLEEP_PICKER_HOUR_RANGE = 23; -static constexpr int16_t TARGET_SLEEP_PICKER_MINUTE_RANGE = 59; -static constexpr int16_t TARGET_SLEEP_TIMERLABEL_X = 131; -static constexpr int16_t TARGET_SLEEP_TIMERLABEL2_X = 273; -static constexpr int16_t TARGET_SLEEP_TIMERLABEL_Y = 99; -static constexpr int16_t TARGET_SLEEP_TIMERLABEL2_Y = 90; -static constexpr int16_t TARGET_SLEEP_TIMERLABEL_WIDTH = 55; -static constexpr int16_t TARGET_SLEEP_TIMERLABEL_HEIGHT = 30; -static constexpr uint8_t TIMERLABEL_FONT = 24; -static constexpr int16_t TARGET_SLEEP_COLOR_R = 181; -static constexpr int16_t TARGET_SLEEP_COLOR_G = 402; -static constexpr int16_t TARGET_SLEEP_COLOR_B = 255; -static constexpr int16_t NUM_PICKER = 2; -static constexpr int16_t TARGET_SLEEP_PICKER1_X = 115; -static constexpr int16_t TARGET_SLEEP_PICKER2_Y = 255; - -// 时间选择器分钟列 -const char *uiPickerMinute[] = {"00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", - "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", - "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", - "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", - "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", - "51", "52", "53", "54", "55", "56", "57", "58", "59"}; - -// 时间选择器小时列 -const char *uiPickerHour[] = {"00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", - "15", "16", "17", "18", "19", "20", "21", "22", "23"}; - -REGIST_SLICE_PAGE(VIEW_SLEEPING, SLEEPING_PAGES::SLEEPING_TARGET_PAGE, TargetSleepTime, false); - -TargetSleepTime::~TargetSleepTime() -{ - if (group != nullptr) { - group->RemoveAll(); - delete group; - group = nullptr; - } - - if (setTraget != nullptr) { - delete setTraget; - setTraget = nullptr; - } - - if (timerLabel != nullptr) { - delete timerLabel; - timerLabel = nullptr; - } - - if (startButton != nullptr) { - delete startButton; - startButton = nullptr; - } - - if (backgroundImage != nullptr) { - delete backgroundImage; - backgroundImage = nullptr; - } - - for (int i = 0; i < NUM_PICKER; i++) { - if (timerPicker[i] != nullptr) { - delete timerPicker[i]; - timerPicker[i] = nullptr; - } - } - - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TargetSleepTime::~TargetSleepTime"); -} - -void TargetSleepTime::OnStart(void* data) -{ - group = new UIScrollView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group is nullptr"); - return; - } - group->SetPosition(0, 0); - group->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); - - backgroundImage = new UIImageView(); - if (backgroundImage == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "backgroundImage is nullptr"); - return; - } - backgroundImage->SetPosition(0, 0); - LOADIMG::LoadImageViewImg(backgroundImage, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_BLACK_BG); - group->Add(backgroundImage); - - setTraget = new UILabel(); - if (setTraget == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "setTraget is nullptr"); - return; - } - setTraget->SetPosition(TARGET_SLEEP_SETTARGET_X, TARGET_SLEEP_SETTARGET_Y); - setTraget->Resize(TARGET_SLEEP_SETTARGET_WIDTH, TARGET_SLEEP_SETTARGET_HIGHT); - setTraget->SetText("设置目标"); - setTraget->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - setTraget->SetTextColor(Color::White()); - setTraget->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TARGET_SLEEP_SETTARGET_FONT_SIZE); - setTraget->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - group->Add(setTraget); - - TargetTimeButton(); - CreateLabel(); - CreatePicker(); - - group->SetOnDragListener(this); - group->SetDraggable(true); - group->SetTouchable(true); - AddViewToPageContainer(group); -} - -void TargetSleepTime::TargetTimeButton() -{ - startButton = new UILabelButton(); - if (startButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "startButton is nullptr"); - return; - } - startButton->SetPosition(TARGET_SLEEP_START_X, TARGET_SLEEP_START_Y); - startButton->Resize(TARGET_SLEEP_START_WIDTH, TARGET_SLEEP_START_HIGHT); - startButton->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - startButton->SetAlign(TEXT_ALIGNMENT_CENTER); - startButton->SetViewId("start"); - - startButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TARGET_SLEEP_SETTARGET_FONT_SIZE); - startButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Purple().full); - startButton->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::White().full, UIButton::PRESSED); - startButton->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::White().full, UIButton::RELEASED); - startButton->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::Black().full, UIButton::INACTIVE); - LOADIMG::LoadBtnImage(startButton, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_SETTIMEBTN, IMAGE_CONVERTER_TOOL_SETTIMEBTN); - startButton->SetText("开始"); - startButton->SetTextColor(Color::White()); - startButton->Enable(); - startButton->SetOnClickListener(this); - group->Add(startButton); -} - -void TargetSleepTime::SetPickerTime() -{ - std::tuple time = SleepingModel::GetInstance().GetTime(); - uint32_t timeHours = std::get<0>(time); - uint32_t timeMinutes = std::get<1>(time); - timerPicker[0] -> SetSelected(timeHours); - timerPicker[1] -> SetSelected(timeMinutes); -} - -void TargetSleepTime::CreatePicker() -{ - int posX[NUM_PICKER] = {TARGET_SLEEP_PICKER1_X, TARGET_SLEEP_PICKER2_Y}; - int posY = TARGET_SLEEP_PICKER_Y; - for (int i = 0; i < NUM_PICKER; i++) { - if (timerPicker[i] == nullptr) { - timerPicker[i] = new UIPicker(); - } - timerPicker[i]->SetPosition(posX[i], posY); - timerPicker[i]->Resize(TARGET_SLEEP_PICKER_WIDTH, TARGET_SLEEP_PICKER_HIGHT); - timerPicker[i]->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - timerPicker[i]->SetStyle(STYLE_BORDER_WIDTH, TARGET_SLEEP_PICKER_BORDER); - timerPicker[i]->SetStyle(STYLE_BORDER_RADIUS, TARGET_SLEEP_PICKER_RADIUS); - timerPicker[i]->SetStyle(STYLE_BORDER_COLOR, Color::Gray().full); - timerPicker[i]->SetItemHeight(TARGET_SLEEP_PICKER_ITEM); - timerPicker[i]->SetLoopState(true); - timerPicker[i]->SetBackgroundFont(DEFAULT_VECTOR_FONT_FILENAME, BACKGROUND_FONT); - timerPicker[i]->SetHighlightFont(DEFAULT_VECTOR_FONT_FILENAME, HIGHTLIGHT_FONT); - timerPicker[i]->SetTextColor(Color::Gray(), Color::White()); - if (i == 0) { - timerPicker[i]->SetValues(uiPickerHour, TARGET_SLEEP_PICKER_HOUR); - timerPicker[i]->SetSelected(TARGET_SLEEP_PICKER_HOUR_RANGE); - } else { - timerPicker[i]->SetValues(uiPickerMinute, TARGET_SLEEP_PICKER_MINUTE); - timerPicker[i]->SetSelected(TARGET_SLEEP_PICKER_MINUTE_RANGE); - } - timerPicker[i]->SetOnClickListener(this); - timerPicker[i]->SetOnDragListener(this); - timerPicker[i]->RegisterSelectedListener(this); - timerPicker[i]->SetDraggable(true); - group->Add(timerPicker[i]); - } - - timerPicker[0]->SetViewId("hourPicker"); - timerPicker[1]->SetViewId("minPicker"); - SetPickerTime(); -} - -bool TargetSleepTime::OnClick(UIView &view, const ClickEvent &event) -{ - UNUSED(event); - std::string viewId = view.GetViewId(); - if (viewId == "start") { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TimerMainPage::OnClick viewId == ONE_MIN"); - int hour = std::stoi(uiPickerHour[timerPicker[0]->GetSelected()]); - uint8_t minute = std::stoi(uiPickerMinute[timerPicker[1]->GetSelected()]); - SleepingModel::GetInstance().SetTime((hour * TARGET_SLEEP_PICKER_MINUTE) + minute); - NativeAbility::GetInstance().SwitchSlice(VIEW_SLEEPING, SLEEPING_PAGES::SLEEPING_MAIN_PAGE); - } - return false; -} - -void TargetSleepTime::CreateLabel() -{ - if (timerLabel == nullptr) { - timerLabel = new UILabel(); - } - timerLabel->SetPosition(TARGET_SLEEP_TIMERLABEL_X, TARGET_SLEEP_TIMERLABEL_Y); - timerLabel->Resize(TARGET_SLEEP_TIMERLABEL_WIDTH, TARGET_SLEEP_TIMERLABEL_HEIGHT); - timerLabel->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - timerLabel->SetText("小时"); - timerLabel->SetStyle(STYLE_BACKGROUND_COLOR, 0xFFB566FF); - timerLabel->SetTextColor(Color::Black()); - timerLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - timerLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TIMERLABEL_FONT); - timerLabel->SetVisible(false); - - group->Add(timerLabel); -} - -bool TargetSleepTime::OnDrag(UIView& view, const DragEvent& event) -{ - if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && - (event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TargetSleepTime::OnDrag ChangeSlice(VIEW_APPLIST)"); - NativeAbility::GetInstance().SwitchSlice(VIEW_SLEEPING, SLEEPING_PAGES::SLEEPING_MAIN_PAGE); - } - if (view.GetViewId() == "hourPicker") { - timerPicker[0]->SetStyle(STYLE_BORDER_COLOR, - Color::GetColorFromRGB(TARGET_SLEEP_COLOR_R, TARGET_SLEEP_COLOR_G, TARGET_SLEEP_COLOR_B).full); - timerPicker[1]->SetStyle(STYLE_BORDER_COLOR, Color::Gray().full); - timerPicker[0]->Invalidate(); - timerPicker[1]->Invalidate(); - timerLabel->SetVisible(true); - timerLabel->SetPosition(TARGET_SLEEP_TIMERLABEL_X, TARGET_SLEEP_TIMERLABEL2_Y); - timerLabel->SetText("小时"); - timerLabel->Invalidate(); - } else if (view.GetViewId() == "minPicker") { - timerPicker[1]->SetStyle(STYLE_BORDER_COLOR, - Color::GetColorFromRGB(TARGET_SLEEP_COLOR_R, TARGET_SLEEP_COLOR_G, TARGET_SLEEP_COLOR_B).full); - timerPicker[0]->SetStyle(STYLE_BORDER_COLOR, Color::Gray().full); - timerPicker[0]->Invalidate(); - timerPicker[1]->Invalidate(); - timerLabel->SetVisible(true); - timerLabel->SetPosition(TARGET_SLEEP_TIMERLABEL2_X, TARGET_SLEEP_TIMERLABEL2_Y); - timerLabel->SetText("分钟"); - timerLabel->Invalidate(); - } - return true; -} - -void TargetSleepTime::OnPickerStoped(UIPicker& picker) -{ - if (picker.GetViewId() == "hourPicker") { - uint16_t hour = picker.GetSelected(); - picker.SetStyle(STYLE_BORDER_COLOR, - Color::GetColorFromRGB(TARGET_SLEEP_COLOR_R, TARGET_SLEEP_COLOR_G, TARGET_SLEEP_COLOR_B).full); - picker.Invalidate(); - if ((hour == 0) && (timerPicker[1]->GetSelected() == 0)) { - startButton->SetText(""); - startButton->Disable(); - LOADIMG::LoadBtnImage(startButton, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_START_GRAY, - IMAGE_CONVERTER_TOOL_START_GRAY); - } else { - startButton->SetText("开始"); - startButton->SetTextColor(Color::White()); - startButton->Enable(); - LOADIMG::LoadBtnImage(startButton, SLEEP_IMAGE, - IMAGE_CONVERTER_TOOL_SETTIMEBTN, IMAGE_CONVERTER_TOOL_SETTIMEBTN); - } - timerLabel->SetVisible(true); - timerLabel->SetPosition(TARGET_SLEEP_TIMERLABEL_X, TARGET_SLEEP_TIMERLABEL2_Y); - timerLabel->SetText("小时"); - timerLabel->Invalidate(); - } else { - uint16_t minute = picker.GetSelected(); - picker.SetStyle(STYLE_BORDER_COLOR, - Color::GetColorFromRGB(TARGET_SLEEP_COLOR_R, TARGET_SLEEP_COLOR_G, TARGET_SLEEP_COLOR_B).full); - picker.Invalidate(); - if ((minute == 0) && (timerPicker[0]->GetSelected() == 0)) { - startButton->SetText(""); - startButton->Disable(); - LOADIMG::LoadBtnImage(startButton, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_START_GRAY, - IMAGE_CONVERTER_TOOL_START_GRAY); - } else { - startButton->SetText("开始"); - startButton->SetTextColor(Color::White()); - startButton->Enable(); - LOADIMG::LoadBtnImage(startButton, SLEEP_IMAGE, IMAGE_CONVERTER_TOOL_SETTIMEBTN, - IMAGE_CONVERTER_TOOL_SETTIMEBTN); - } - timerLabel->SetVisible(true); - timerLabel->SetPosition(TARGET_SLEEP_TIMERLABEL2_X, TARGET_SLEEP_TIMERLABEL2_Y); - timerLabel->SetText("分钟"); - timerLabel->Invalidate(); - } -} -} - diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/sports/src/SportsModel.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/sports/src/SportsModel.cpp deleted file mode 100644 index 4854d19a9..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/sports/src/SportsModel.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: Sports Model - * Create: 2025-04-28 - */ - -#include "sports/SportsView.h" -#include "sports/SportsModel.h" -#include "samgr_lite.h" -#include "broadcast_feature.h" -#include "broadcast_service.h" -#include "wearable_log.h" -#include "heartrate/HeartModel.h" -#include "device_location.h" - -#ifdef __cplusplus -extern "C" { -#endif - -using namespace OHOS; -static sport_data_t g_sportData = {0}; -static void Notify(void *args, const Topic topic, Request *request); - -Subscriber sportsSubscirber = { - .identity = nullptr, - .args = nullptr, - .Notify = Notify, -}; - -void SportsSubscribeTopic(Topic topic) -{ -#if !defined(_WIN32) - BroadcastApi *broadcastApi = nullptr; - IUnknown *api = SAMGR_GetInstance()->GetFeatureApi(BROADCAST_SERVICE_NAME, BROADCAST_FEATURE_NAME); - if (api == nullptr) { - return; - } - int result = api->QueryInterface(api, DEFAULT_VERSION, (void **)&broadcastApi); - if (result != 0 || broadcastApi == nullptr) { - return; - } - int ret = broadcastApi->SubscribeTopic((IUnknown *)broadcastApi, topic, &sportsSubscirber); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SportsSubscribeTopic ret = %d, topic = %u", ret, topic); - broadcastApi->Release((IUnknown *)broadcastApi); -#endif -} - -void SportsUnsubscribeTopic(Topic topic) -{ -#if !defined(_WIN32) - BroadcastApi *broadcastApi = nullptr; - IUnknown *api = SAMGR_GetInstance()->GetFeatureApi(BROADCAST_SERVICE_NAME, BROADCAST_FEATURE_NAME); - if (api == nullptr) { - return; - } - int result = api->QueryInterface(api, DEFAULT_VERSION, (void **)&broadcastApi); - if (result != 0 || broadcastApi == nullptr) { - return; - } - broadcastApi->UnsubscribeTopic((IUnknown *)broadcastApi, topic, &sportsSubscirber); - broadcastApi->Release((IUnknown *)broadcastApi); -#endif -} - -static void Notify(void *args, const Topic topic, Request *request) -{ - UNUSED(args); - UNUSED(topic); - if (request == nullptr) { - return; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "topic=[%d,%d]\n", topic, request->msgId); - SportsView *sportView = SportsView::GetInstance(); - bool active = OHOS::SportsModel::GetInstance()->IsActive(); - if (sportView != nullptr && active) { - if (request->msgId == TOPIC_EVENT_HEARTRATE_UPDATA) { - HeartDatas *sportsInfo = (HeartDatas *)request->data; - g_sportData.heartrate = sportsInfo->perSec; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "heartrate=[%d]\n", g_sportData.heartrate); - sportView->SetHeartRate(g_sportData.heartrate); - } - if (request->msgId == TOPIC_EVENT_STEPDATA_UPDATE) { - g_sportData.step += *(uint32_t *)request->data; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "step=[%d]\n", g_sportData.step); - sportView->SetStep(g_sportData.step); - } - if (request->msgId == TOPIC_EVENT_SPORT_DISTANCE) { - g_sportData.distance += *(uint32_t *)request->data; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "distance=[%d]\n", g_sportData.distance); - sportView->SetDistance(g_sportData.distance); - uint32_t speed = OHOS::SportsModel::GetInstance()->CalculateSpeed(g_sportData.distance); - g_sportData.speed = speed; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "speed=[%d]\n", g_sportData.speed); - sportView->SetSpeed(speed); - } - if (request->msgId == TOPIC_EVENT_LOCATION) { - LocationInfo_t *locationData = (LocationInfo_t *)request->data; - g_sportData.lat = locationData->latitude_; - g_sportData.lng = locationData->longitude_; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "location=[%d,%d]\n", g_sportData.lat, g_sportData.lng); - } - } -} - -#ifdef __cplusplus -} -#endif - -namespace OHOS { - -static constexpr uint16_t MS_ONE_SECONDS = 1000; -static constexpr uint16_t NUM_TEN = 10; -static constexpr uint16_t NUM_TIME_MIN = 60; -static constexpr uint16_t NUM_TIME_HOUR = 3600; -static constexpr uint32_t NUM_TIME_DAY = 86400; - -SportsModel::SportsModel() -{ - InitSportsTimer(); -} - -SportsModel::~SportsModel() -{ - StopSportsTimer(true); - SportsUnsubscribeTopic(TOPIC_EVENT_HEARTRATE_UPDATA); - SportsUnsubscribeTopic(TOPIC_EVENT_STEPDATA_UPDATE); - SportsUnsubscribeTopic(TOPIC_EVENT_SPORT_DISTANCE); - SportsUnsubscribeTopic(TOPIC_EVENT_LOCATION); -} - -SportsModel *SportsModel::GetInstance(void) -{ - static SportsModel instance; - return &instance; -} - -void SportsModel::Init() -{ - SportsSubscribeTopic(TOPIC_EVENT_HEARTRATE_UPDATA); - SportsSubscribeTopic(TOPIC_EVENT_STEPDATA_UPDATE); - SportsSubscribeTopic(TOPIC_EVENT_SPORT_DISTANCE); - SportsSubscribeTopic(TOPIC_EVENT_LOCATION); -} - -std::string SportsModel::CountingSportsTime() -{ - std::string strSportTime; - std::string hours; - std::string minute; - std::string seconds; - if (uiSportTime_ >= NUM_TIME_DAY) { - uiSportTime_ = 0; - } - int hour = uiSportTime_ / NUM_TIME_HOUR; - int min = (uiSportTime_ % NUM_TIME_HOUR) / NUM_TIME_MIN; - int sec = (uiSportTime_ % NUM_TIME_HOUR) % NUM_TIME_MIN; - if (hour >= 0 && hour < NUM_TEN) { - hours = "0" + std::to_string(hour); - } else { - hours = std::to_string(hour); - } - if (min >= 0 && min < NUM_TEN) { - minute = "0" + std::to_string(min); - } else { - minute = std::to_string(min); - } - if (sec >= 0 && sec < NUM_TEN) { - seconds = "0" + std::to_string(sec); - } else { - seconds = std::to_string(sec); - } - - strSportTime = hours + ":" + minute + ":" + seconds; - return strSportTime; -} - -void SportsModel::IncrSportsTime() -{ - uiSportTime_++; -} - -/* 定时器回调函数 */ -static void SportsTimerCallback(void *data) -{ - (void)data; - SportsModel::GetInstance()->IncrSportsTime(); - SportsView *view = SportsView::GetInstance(); - if (view != nullptr) { - std::string sportTime = SportsModel::GetInstance()->CountingSportsTime(); - view->SetTime(sportTime.c_str()); - } -} - -/* 创建定时器 */ -void SportsModel::InitSportsTimer() -{ - if (pGraphicTimer_ != nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SportsModel::InitSportsTimer GraphicTimer already exists!!"); - return; - } - uint32_t tick = GetOSTick(MS_ONE_SECONDS); - pGraphicTimer_ = new GraphicTimer(tick, SportsTimerCallback, nullptr, true); - if (pGraphicTimer_ == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SportsModel::InitSportsTimer new GraphicTimer failed!!"); - return; - } -} - -/* 开启定时器 */ -bool SportsModel::StartSportsTimer() -{ - if (pGraphicTimer_ != nullptr) { - bool retTimer = pGraphicTimer_->Start(); - if (!retTimer) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartSportsTimer GraphicTimer Start failed!!"); - if (pGraphicTimer_ != nullptr) { - delete pGraphicTimer_; - pGraphicTimer_ = nullptr; - } - return false; - } - isActive_ = true; - return true; - } - return false; -} - -/* 关闭定时器 */ -void SportsModel::StopSportsTimer(bool isDelete) -{ - if (pGraphicTimer_ != nullptr) { - pGraphicTimer_->Stop(); - isActive_ = false; - if (isDelete) { - delete pGraphicTimer_; - pGraphicTimer_ = nullptr; - uiSportTime_ = 0; - } - } -} - -bool SportsModel::IsActive() -{ - return isActive_; -} - -sport_data_t *SportsModel::GetSportsData() -{ - return &g_sportData; -} - -void SportsModel::ResetSportsData() -{ - uiSportTime_ = 0; - memset_s(&g_sportData, sizeof(sport_data_t), 0, sizeof(sport_data_t)); -} - -uint32_t SportsModel::CalculateSpeed(uint32_t distance) -{ - uint32_t speed_multiply100 = 0; - if (uiSportTime_ != 0) { - speed_multiply100 = (distance * NUM_TIME_HOUR) / (uiSportTime_ * NUM_TEN); - } - return speed_multiply100; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/sports/src/SportsPresenter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/sports/src/SportsPresenter.cpp deleted file mode 100644 index 363bf930f..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/sports/src/SportsPresenter.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: SPorts Presenter - * Create: 2025-04-28 - */ - -#include "sports/SportsPresenter.h" -#include "sports/SportsView.h" -#include "sports/SportsModel.h" -#include "wearable_log.h" -#include "NativeRegisterManager.h" - -namespace OHOS { - -REGIST_SLICE(VIEW_SPORTS, SportsView, SportsPresenter); - -static SportsPresenter *g_pSportsPresenter = nullptr; - -SportsPresenter::SportsPresenter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SportsPresenter::SportsPresenter"); - g_pSportsPresenter = this; -} - -SportsPresenter::~SportsPresenter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SportsPresenter::~SportsPresenter"); - g_pSportsPresenter = nullptr; -} - -SportsPresenter *SportsPresenter::GetInstance() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SportsPresenter GetInstance"); - return g_pSportsPresenter; -} - -bool SportsPresenter::OnDrag(UIView &view, const DragEvent &event) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SportsPresenter::OnDrag"); - UNUSED(view); - if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && (event.GetDeltaX() > X_DRAG_OFFSET) && - (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SportsPresenter::OnDrag ChangeSlice"); - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE); - } - return true; -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/sports/src/SportsView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/sports/src/SportsView.cpp deleted file mode 100644 index 2b3b50bff..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/sports/src/SportsView.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: Sports View - * Create: 2025-04-28 - */ - -#include "sports/SportsView.h" -#include "sports/SportsModel.h" -#include "sports/SportsPresenter.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "uiservice/ui_service.h" - -namespace OHOS { -static constexpr uint16_t NUM_TEN = 10; -static constexpr uint16_t NUM_HUNDRED = 100; -static constexpr uint16_t NUM_THOUSAND = 1000; -static constexpr uint16_t LEFT1_X = 47; -static constexpr uint16_t LEFT1_Y = 100; -static constexpr uint16_t LEFT1_W = 180; -static constexpr uint16_t RIGHT1_X = 227; -static constexpr uint16_t RIGHT1_Y = 100; -static constexpr uint16_t RIGHT1_W = 180; -static constexpr uint16_t LEFT2_X = 47; -static constexpr uint16_t LEFT2_Y = 210; -static constexpr uint16_t LEFT2_W = 180; -static constexpr uint16_t RIGHT2_X = 227; -static constexpr uint16_t RIGHT2_Y = 210; -static constexpr uint16_t RIGHT2_W = 180; -static constexpr uint16_t BOTTOM_X = 92; -static constexpr uint16_t BOTTOM_Y = 320; -static constexpr uint16_t BOTTOM_W = 270; -static constexpr uint16_t LABLE_H = 70; -static constexpr uint16_t UNIT_LEFT1_Y = 150; -static constexpr uint16_t UNIT_RIGHT1_Y = 150; -static constexpr uint16_t UNIT_LEFT2_Y = 260; -static constexpr uint16_t UNIT_RIGHT2_Y = 260; -static constexpr uint16_t UNIT_BOTTOM_Y = 370; -static constexpr uint16_t UNIT_H = 50; -static constexpr uint16_t CONTENT_FONT = 40; -static constexpr uint16_t TITLE_FONT = 30; - -static SportsView *g_pSportsView{nullptr}; -SportsView::SportsView() -{ - ScreenTurnOn(-1); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SportsView::SportsView"); - g_pSportsView = this; -} - -SportsView::~SportsView() -{ - ScreenTurnOff(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SportsView::~SportsView"); - if (group != nullptr) { - group->RemoveAll(); - } - if (backGround != nullptr) { - delete backGround; - backGround = nullptr; - } - delete group; - group = nullptr; - g_pSportsView = nullptr; -} - -SportsView *SportsView::GetInstance() -{ - return g_pSportsView; -} - -bool SportsView::InitLableView(int index, const char *text, uint16_t x, uint16_t y1, uint16_t w, uint16_t y2) -{ - if (index < SPORT_TIME || index >= SPORT_MAX) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SportsView::InitLableView index param error"); - return false; - } - - ContentLabel[index].SetPosition(x, y1, w, LABLE_H); - ContentLabel[index].SetFont(DEFAULT_VECTOR_FONT_FILENAME, CONTENT_FONT); - ContentLabel[index].SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - ContentLabel[index].SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - group->Add(&ContentLabel[index]); - - TitleLabel[index].SetPosition(x, y2, w, UNIT_H); - TitleLabel[index].SetText(text); - TitleLabel[index].SetFont(DEFAULT_VECTOR_FONT_FILENAME, TITLE_FONT); - TitleLabel[index].SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - TitleLabel[index].SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - group->Add(&TitleLabel[index]); - return true; -} - -void SportsView::InitSportDataLabel() -{ - ContentLabel[SPORT_TIME].SetText("00:00:00"); - ContentLabel[SPORT_SETP].SetText("0"); - ContentLabel[SPORT_DISTANCE].SetText("0.00"); - ContentLabel[SPORT_HEARTRATE].SetText("0"); - ContentLabel[SPORT_SPEED].SetText("0.00"); -} - -bool SportsView::InitView() -{ - bool ret = false; - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return false; - } - group->SetPosition(0, 0); // 0:x; 0:y - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - group->SetStyle(STYLE_BACKGROUND_OPA, 0); - group->SetDraggable(true); - group->SetTouchable(true); - - backGround = new UIImageView(); - if (backGround == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "backGroundFirst new fail"); - return false; - } - backGround->SetPosition(0, 0); // 0 : X; 0 : Y - backGround->SetSrc(PNG_WALK_BACK_GROUND); - group->Add(backGround); - - InitSportDataLabel(); - ret = InitLableView(SPORT_SETP, "步数", LEFT1_X, LEFT1_Y, LEFT1_W, UNIT_LEFT1_Y); - if (!ret) { - return false; - } - ret = InitLableView(SPORT_DISTANCE, "距离(km)", RIGHT1_X, RIGHT1_Y, RIGHT1_W, UNIT_RIGHT1_Y); - if (!ret) { - return false; - } - ret = InitLableView(SPORT_HEARTRATE, "心率(bpm)", LEFT2_X, LEFT2_Y, LEFT2_W, UNIT_LEFT2_Y); - if (!ret) { - return false; - } - ret = InitLableView(SPORT_SPEED, "速度(km/h)", RIGHT2_X, RIGHT2_Y, RIGHT2_W, UNIT_RIGHT2_Y); - if (!ret) { - return false; - } - ret = InitLableView(SPORT_TIME, "时间", BOTTOM_X, BOTTOM_Y, BOTTOM_W, UNIT_BOTTOM_Y); - if (!ret) { - return false; - } - UIView::OnDragListener *dragListener = static_cast(SportsPresenter::GetInstance()); - group->SetOnDragListener(dragListener); - - AddViewToRootContainer(group); - return true; -} - -void SportsView::OnStart() -{ - if (!InitView()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SportsView::OnStart InitView fail"); - } - return; -} - -void SportsView::SetStep(uint32_t step) -{ - ContentLabel[SPORT_SETP].SetText(std::to_string(step).c_str()); - ContentLabel[SPORT_SETP].Invalidate(); -} - -void SportsView::SetHeartRate(uint16_t heartrate) -{ - ContentLabel[SPORT_HEARTRATE].SetText(std::to_string(heartrate).c_str()); - ContentLabel[SPORT_HEARTRATE].Invalidate(); -} - -void SportsView::SetDistance(uint32_t distance) -{ - std::string distance_str; - uint32_t distance_int_part = distance / NUM_THOUSAND; - uint32_t distance_fractional_part = (distance % NUM_THOUSAND) / NUM_TEN; - if (distance_fractional_part < NUM_TEN) { - distance_str = std::to_string(distance_int_part) + ".0" + std::to_string(distance_fractional_part); - } else { - distance_str = std::to_string(distance_int_part) + "." + std::to_string(distance_fractional_part); - } - ContentLabel[SPORT_DISTANCE].SetText(distance_str.c_str()); - ContentLabel[SPORT_DISTANCE].Invalidate(); -} - -void SportsView::SetSpeed(uint32_t speed) -{ - std::string speed_str; - uint32_t speed_int_part = speed / NUM_HUNDRED; - uint32_t speed_fractional_part = speed % NUM_HUNDRED; - - if (speed_fractional_part < NUM_TEN) { - speed_str = std::to_string(speed_int_part) + ".0" + std::to_string(speed_fractional_part); - } else { - speed_str = std::to_string(speed_int_part) + "." + std::to_string(speed_fractional_part); - } - - ContentLabel[SPORT_SPEED].SetText(speed_str.c_str()); - ContentLabel[SPORT_SPEED].Invalidate(); -} - -void SportsView::SetTime(const char *time) -{ - ContentLabel[SPORT_TIME].SetText(time); - ContentLabel[SPORT_TIME].Invalidate(); -} - -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/stopwatch/src/StopwatchAdapter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/stopwatch/src/StopwatchAdapter.cpp deleted file mode 100644 index 41959502d..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/stopwatch/src/StopwatchAdapter.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: StopwatchAdapter - * Create: 2025-06-06 - */ -#include "stopwatch/StopwatchAdapter.h" -#include "stopwatch/StopwatchItemView.h" - -namespace OHOS { -StopwatchAdapter::StopwatchAdapter() {} - -StopwatchAdapter::~StopwatchAdapter() -{ - listData_.Clear(); -} - -uint16_t StopwatchAdapter::GetCount(void) -{ - return listData_.Size(); -} - -void StopwatchAdapter::SetData(const List &data) -{ - if (!listData_.IsEmpty()) { - listData_.Clear(); - } - ListNode *node = data.Head(); - while (node != data.End()) { - listData_.PushBack(node->data_); - node = node->next_; - } -} - -UIView *StopwatchAdapter::GetView(UIView *inView, int16_t index) -{ - if (listData_.IsEmpty()) { - return nullptr; - } - if (index < 0) { - return nullptr; - } - size_t uindex = index; - if (uindex >= listData_.Size()) { - return nullptr; - } - - ListNode *node = listData_.Head(); - for (int i = 0; i < index; i++) { - node = node->next_; - } - StopwatchItem itemData = node->data_; - StopwatchItemView *item = nullptr; - if (inView == nullptr) { - item = new StopwatchItemView(); - } else { - item = static_cast(inView); - } - size_t rindex = listData_.Size() - index; - item->SetItemInfo(rindex, itemData); - return item; -} - -} // namespace OHOS diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempClickMea.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempClickMea.cpp deleted file mode 100644 index 45982b555..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempClickMea.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#include "UiConfig.h" -#include -#include "font/ui_font.h" -#include "temperature/TempClickMea.h" - -namespace OHOS { -static TempClickMea *g_tempClickMea = nullptr; - -static const int16 TEMP_LABEL_FIRST_X = 40; -static const int16 TEMP_LABEL_FIRST_Y = 100; -static const int16 TEMP_LABEL_FIRST_WIDTH = 350; -static const int16 TEMP_LABEL_FIRST_HEIGHT = 180; -static const int16 TEMP_BUTTON_X = 120; -static const int16 TEMP_BUTTON_FIRST_Y = 290; -static const int16 TEMP_BUTTON_SECOND_Y = 390; -static const int16 TEMP_BUTTON_WIDTH = 220; -static const int16 TEMP_BUTTON_HEIGHT = 80; -static const int16 TEMP_LABEL_FONT = 36; -static const char *TEMP_CLICK_MEA_LABEL = (char*)"为减少环境影响,建议在室内、无风、无冷/热源干扰条件下进行测量。"; -static const char *TEMP_BUTTON_INTER_LABEL = (char*)"立即测量"; -static const char *TEMP_BUTTON_CLOSE_LABEL = (char*)"稍后测量"; - -TempClickMea::TempClickMea() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempClickMea::TempClickMea"); - g_tempClickMea = this; -} - -TempClickMea::~TempClickMea() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempClickMea::~TempClickMea"); - RemoveAll(); - int num; - if (tempLabel != nullptr) { - delete tempLabel; - tempLabel = nullptr; - } - for (num = SET_ZERO; num < SET_TWO; num++) { - if (tempButton[num] != nullptr) { - delete tempButton[num]; - tempButton[num] = nullptr; - } - } - g_tempClickMea = nullptr; -} - -TempClickMea *TempClickMea::GetInstance(void) -{ - return g_tempClickMea; -} - -bool TempClickMea::TempInitButton(void) -{ - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::TempPresenter::GetInstance(); - tempButton[SET_ZERO] = new UILabelButton(); - if (tempButton[SET_ZERO] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempClickMea::TempInitButton new tempButton[SET_ZERO] error"); - return false; - } - tempButton[SET_ZERO]->SetPosition(TEMP_BUTTON_X, TEMP_BUTTON_FIRST_Y, TEMP_BUTTON_WIDTH, TEMP_BUTTON_HEIGHT); - tempButton[SET_ZERO]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TEMP_LABEL_FONT); - tempButton[SET_ZERO]->SetText(TEMP_BUTTON_INTER_LABEL); - tempButton[SET_ZERO]->SetViewId(TEMP_MEA_IN); - tempButton[SET_ZERO]->SetOnClickListener(clickListener); - tempButton[SET_ZERO]->SetStyleForState(STYLE_BACKGROUND_COLOR, - TempPresenter::GetInstance()->CyanColor().full, UIButton::RELEASED); - tempButton[SET_ZERO]->SetStyleForState(STYLE_BACKGROUND_COLOR, - TempPresenter::GetInstance()->CyanColor().full, UIButton::PRESSED); - tempButton[SET_ZERO]->SetStyleForState(STYLE_BACKGROUND_COLOR, - TempPresenter::GetInstance()->CyanColor().full, UIButton::INACTIVE); - Add(tempButton[SET_ZERO]); - - tempButton[SET_ONE] = new UILabelButton(); - if (tempButton[SET_ONE] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempJoinStudy::TempInitButton new tempButton[SET_ONE] error"); - return false; - } - tempButton[SET_ONE]->SetPosition(TEMP_BUTTON_X, TEMP_BUTTON_SECOND_Y, TEMP_BUTTON_WIDTH, TEMP_BUTTON_HEIGHT); - tempButton[SET_ONE]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TEMP_LABEL_FONT); - tempButton[SET_ONE]->SetText(TEMP_BUTTON_CLOSE_LABEL); - tempButton[SET_ONE]->SetViewId(TEMP_MEA_EXIT); - tempButton[SET_ONE]->SetOnClickListener(clickListener); - tempButton[SET_ONE]->SetTextColor(OHOS::TempPresenter::GetInstance()->CyanColor()); - tempButton[SET_ONE]->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::Gray().full, UIButton::RELEASED); - tempButton[SET_ONE]->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::Gray().full, UIButton::PRESSED); - tempButton[SET_ONE]->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::Gray().full, UIButton::INACTIVE); - Add(tempButton[SET_ONE]); - - return true; -} - -bool TempClickMea::TempInitLabel(void) -{ - tempLabel = new UILabel(); - if (tempLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempClickMea::TempInitLabel new label fail"); - return false; - } - tempLabel->SetText(TEMP_CLICK_MEA_LABEL); - tempLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TEMP_LABEL_FONT); - tempLabel->SetPosition(TEMP_LABEL_FIRST_X, TEMP_LABEL_FIRST_Y, TEMP_LABEL_FIRST_WIDTH, TEMP_LABEL_FIRST_HEIGHT); - Add(tempLabel); - return true; -} - -bool TempClickMea::InitClickMea(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempClickMea::InitClickMea"); - SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - if (TempPresenter::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempClickMea::InitClickMea TempPresenter::GetInstance() nullptr"); - return false; - } - UIView::OnDragListener *listener = static_cast(TempPresenter::GetInstance()); - SetScrollBlankSize(50); // 50:font size - SetOnDragListener(listener); - SetDraggable(true); - SetTouchable(true); - - if (!TempInitLabel()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempClickMea::InitClickMea TempInitLabel() false"); - return false; - } - if (!TempInitButton()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempClickMea::InitClickMea TempInitButton() false"); - return false; - } - return true; -} - -void TempClickMea::RefreshClickMea(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempClickMea::RefreshClickMea"); - ScrollBy(0, TEMP_LABEL_FIRST_Y - tempLabel->GetY()); -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempContinueWarn.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempContinueWarn.cpp deleted file mode 100644 index e8f599deb..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempContinueWarn.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#include "UiConfig.h" -#include -#include "temperature/TempContinueWarn.h" - -namespace OHOS { -static TempContinueWarn *g_tempContinueWarn = nullptr; - -static const int16 TEMP_IMAGE_X = 182; -static const int16 TEMP_IMAGE_Y = 30; -static const int16 TEMP_LABEL_ONE_X = 190; -static const int16 TEMP_LABEL_ONE_Y = 130; -static const int16 TEMP_LABEL_ONE_WIDTH = 100; -static const int16 TEMP_LABEL_ONE_HEIGHT = 35; -static const int16 TEMP_LABEL_ONE_FONT = 35; -static const int16 TEMP_LABEL_TWO_X = 155; -static const int16 TEMP_LABEL_TWO_Y = 200; -static const int16 TEMP_LABEL_TWO_WIDTH = 200; -static const int16 TEMP_LABEL_TWO_HEIGHT = 45; -static const int16 TEMP_LABEL_TWO_FONT = 40; -static const int16 TEMP_LABEL_THREE_X = 70; -static const int16 TEMP_LABEL_THREE_Y = 265; -static const int16 TEMP_LABEL_THREE_WIDTH = 290; -static const int16 TEMP_LABEL_THREE_HEIGHT = 60; -static const char *TEMP_LABEL_ONE_TEXT = (char*)"体温"; -static const char *TEMP_HOT_WARN = (char*)"体温过高"; -static const char *TEMP_COLD_WARN = (char*)"体温过低"; -static const char *TEMP_HOT_WARN_LABEL = (char*)"最近10分钟体温高于37.2"; -static const char *TEMP_COLD_WARN_LABEL = (char*)"最近10分钟体温低于35.5"; - -TempContinueWarn::TempContinueWarn() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempContinueWarn::TempContinueWarn"); - g_tempContinueWarn = this; -} - -TempContinueWarn::~TempContinueWarn() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempContinueWarn::~TempContinueWarn"); - RemoveAll(); - int16 num; - if (tempImage != nullptr) { - delete tempImage; - tempImage = nullptr; - } - for (num = SET_ZERO; num < SET_THREE; num++) { - if (tempLabel[num] != nullptr) { - delete tempLabel[num]; - tempLabel[num] = nullptr; - } - } - g_tempContinueWarn = nullptr; -} - -TempContinueWarn *TempContinueWarn::GetInstance(void) -{ - return g_tempContinueWarn; -} - -bool TempContinueWarn::TempInitLabel(void) -{ - tempLabel[SET_ZERO] = new UILabel(); - if (tempLabel[SET_ZERO] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempContinueWarn::TempInitLabel new tempLabel[SET_ZERO] fail"); - return false; - } - tempLabel[SET_ZERO]->SetPosition(TEMP_LABEL_ONE_X, TEMP_LABEL_ONE_Y, TEMP_LABEL_ONE_WIDTH, TEMP_LABEL_ONE_HEIGHT); - tempLabel[SET_ZERO]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TEMP_LABEL_ONE_FONT); - tempLabel[SET_ZERO]->SetText(TEMP_LABEL_ONE_TEXT); - tempLabel[SET_ZERO]->SetTextColor(Color::Gray()); - tempLabel[SET_ZERO]->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - Add(tempLabel[SET_ZERO]); - - tempLabel[SET_ONE] = new UILabel(); - if (tempLabel[SET_ONE] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempContinueWarn::TempInitLabel new tempLabel[SET_ONE] fail"); - return false; - } - tempLabel[SET_ONE]->SetPosition(TEMP_LABEL_TWO_X, TEMP_LABEL_TWO_Y, TEMP_LABEL_TWO_WIDTH, TEMP_LABEL_TWO_HEIGHT); - tempLabel[SET_ONE]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TEMP_LABEL_TWO_FONT); - Add(tempLabel[SET_ONE]); - - tempLabel[SET_TWO] = new UILabel(); - if (tempLabel[SET_TWO] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempContinueWarn::TempInitLabel new tempLabel[2] fail"); - return false; - } - tempLabel[SET_TWO]->SetPosition(TEMP_LABEL_THREE_X, TEMP_LABEL_THREE_Y, TEMP_LABEL_THREE_WIDTH, - TEMP_LABEL_THREE_HEIGHT); - tempLabel[SET_TWO]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TEMP_LABEL_ONE_FONT); - tempLabel[SET_TWO]->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - tempLabel[SET_TWO]->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - Add(tempLabel[SET_TWO]); - - return true; -} - -bool TempContinueWarn::TempInitImage(void) -{ - tempImage = new UIImageView(); - if (tempImage == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempContinueWarn::TempInitImage new tempImage fail"); - return false; - } - tempImage->SetPosition(TEMP_IMAGE_X, TEMP_IMAGE_Y); - tempImage->SetSrc(TEMP_LITTLE_MEASURE); - Add(tempImage); - - return true; -} - -bool TempContinueWarn::InitTempContinue(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempContinueWarn::InitTempContinue"); - SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - if (TempPresenter::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempContinueWarn::InitTempContinue TempPresenter::GetInstance() nullptr"); - return false; - } - UIView::OnDragListener *listener = static_cast(TempPresenter::GetInstance()); - SetOnDragListener(listener); - SetDraggable(true); - SetTouchable(true); - - if (!TempInitImage()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempContinueWarn::InitTempContinue TempInitImage() error"); - return false; - } - if (!TempInitLabel()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempContinueWarn::InitTempContinue TempInitLabel() error"); - return false; - } - return true; -} - -void TempContinueWarn::RefreshTempContinue(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempContinueWarn::RefreshTempContinue"); - int8 tempListener = TempPresenter::GetInstance()->GetTempListen(); - if (tempListener == 0) { - tempLabel[SET_ONE]->SetText(TEMP_COLD_WARN); - tempLabel[SET_ONE]->SetTextColor(Color::Blue()); - tempLabel[SET_TWO]->SetText(TEMP_HOT_WARN_LABEL); - } else if (tempListener == 1) { - tempLabel[SET_ONE]->SetText(TEMP_HOT_WARN); - tempLabel[SET_ONE]->SetTextColor(Color::Orange()); - tempLabel[SET_TWO]->SetText(TEMP_COLD_WARN_LABEL); - } - return; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempExitInter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempExitInter.cpp deleted file mode 100644 index 215e46833..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempExitInter.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#include "UiConfig.h" -#include "layout/grid_layout.h" -#include "font/ui_font.h" -#include -#include "temperature/TempExitInter.h" - -namespace OHOS { -static TempExitInter *g_tempExitInter = nullptr; - -static const int16 EXIT_LABEL_X = 40; -static const int16 EXIT_LABEL_Y_FIRST = 140; -static const int16 EXIT_THIS_Y_FIRST = 155; -static const int16 EXIT_LABEL_Y_SECOND = 265; -static const int16 EXIT_THIS_Y_SECOND = 275; -static const int16 EXIT_IMAGE_X = 65; -static const int16 EXIT_IMAGE_THIS_X = 325; -static const int16 EXIT_IMAGE_EXIT_Y = 145; -static const int16 EXIT_IMAGE_STUDY_Y = 270; -static const int16 EXIT_LABEL_WIDTH = 400; -static const int16 EXIT_LABEL_HEIGHT = 80; -static const int16 EXIT_LABEL_GROUP_WIDTH = 390; -static const int16 EXIT_LABEL_GROUP_HEIGHT = 110; -static const int16 EXIT_GROUP_ONE_X = 40; -static const int16 EXIT_GROUP_ONE_Y = 140; -static const int16 EXIT_GROUP_TWO_Y = 265; -static const int16 EXIT_LABEL_FONT = 35; -static const char *EXIT_LABEL_TEXT_FIRST = (char*)"退出研究"; -static const char *EXIT_LABEL_TEXT_SECOND = (char*)"关于研究"; - -TempExitInter::TempExitInter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempExitInter::TempExitInter"); - g_tempExitInter = this; -} - -TempExitInter::~TempExitInter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempExitInter::~TempExitInter"); - RemoveAll(); - for (int32_t labelNum = SET_ZERO; labelNum < SET_TWO; labelNum++) { - if (tempLabel[labelNum] != nullptr) { - delete tempLabel[labelNum]; - tempLabel[labelNum] = nullptr; - } - } - for (int32_t ImageNum = SET_ZERO; ImageNum < SET_FOUR; ImageNum++) { - if (tempImage[ImageNum] != nullptr) { - delete tempImage[ImageNum]; - tempImage[ImageNum] = nullptr; - } - } - g_tempExitInter = nullptr; -} - -TempExitInter *TempExitInter::GetInstance(void) -{ - return g_tempExitInter; -} - -bool TempExitInter::TempInitLabel(void) -{ - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::TempPresenter::GetInstance(); - tempLabel[SET_ZERO] = new UILabel(); - if (tempLabel[SET_ZERO] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempExitInter::InitExit new tempLabel[SET_ZERO] fail"); - return false; - } - tempLabel[SET_ZERO]->SetPosition(EXIT_LABEL_X, EXIT_LABEL_Y_FIRST, EXIT_LABEL_WIDTH, EXIT_LABEL_HEIGHT); - tempLabel[SET_ZERO]->SetText(EXIT_LABEL_TEXT_FIRST); - tempLabel[SET_ZERO]->SetViewId(TEMP_EXIT_THIS); - tempLabel[SET_ZERO]->SetTouchable(true); - tempLabel[SET_ZERO]->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - tempLabel[SET_ZERO]->SetOnClickListener(clickListener); - tempLabel[SET_ZERO]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, EXIT_LABEL_FONT); - Add(tempLabel[SET_ZERO]); - - tempLabel[SET_ONE] = new UILabel(); - if (tempLabel[SET_ONE] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempExitInter::InitExit new tempLabel[SET_ONE] fail"); - return false; - } - tempLabel[SET_ONE]->SetPosition(EXIT_LABEL_X, EXIT_LABEL_Y_SECOND, EXIT_LABEL_WIDTH, EXIT_LABEL_HEIGHT); - tempLabel[SET_ONE]->SetText(EXIT_LABEL_TEXT_SECOND); - tempLabel[SET_ONE]->SetViewId(TEMP_STUDY_THIS); - tempLabel[SET_ONE]->SetTouchable(true); - tempLabel[SET_ONE]->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - tempLabel[SET_ONE]->SetOnClickListener(clickListener); - tempLabel[SET_ONE]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, EXIT_LABEL_FONT); - Add(tempLabel[SET_ONE]); - - return true; -} - -bool TempExitInter::InitSimilarImage(int16 num, int16 tempX, int16 tempY, const char* imageSrc) -{ - tempImage[num] = new UIImageView(); - if (tempImage[num] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempExitInter::InitSimilarImage new tempImage[%d] fail", num); - return false; - } - tempImage[num]->SetPosition(tempX, tempY); - tempImage[num]->SetSrc(imageSrc); - Add(tempImage[num]); - - return true; -} - -bool TempExitInter::TempInitImage(void) -{ - if (!InitSimilarImage(SET_ZERO, EXIT_IMAGE_X, EXIT_IMAGE_EXIT_Y, TEMP_EXIT)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempExitInter::TempInitImage new tempImage[SET_ZERO] fail"); - return false; - } - if (!InitSimilarImage(SET_ONE, EXIT_IMAGE_X, EXIT_IMAGE_STUDY_Y, TEMP_ABOUT_STUDY)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempExitInter::TempInitImage new tempImage[SET_ONE] fail"); - return false; - } - if (!InitSimilarImage(SET_TWO, EXIT_IMAGE_THIS_X, EXIT_THIS_Y_FIRST, PNG_SETTTING_BUTTON_IMAGE)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempExitInter::TempInitImage new tempImage[SET_TWO] fail"); - return false; - } - if (!InitSimilarImage(SET_THREE, EXIT_IMAGE_THIS_X, EXIT_THIS_Y_SECOND, PNG_SETTTING_BUTTON_IMAGE)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempExitInter::TempInitImage new tempImage[SET_THREE] fail"); - return false; - } - - return true; -} - -bool TempExitInter::InitView(void *caller) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempExitInter::InitExit"); - if (TempPresenter::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempExitInter::InitView TempPresenter::GetInstance() nullptr"); - return false; - } - UNUSED(caller); - UIView::OnDragListener *listener = static_cast(TempPresenter::GetInstance()); - - SetOnDragListener(listener); - SetViewId(TEMP_SWIPE_EXIT); - SetDraggable(true); - SetTouchable(true); - - if (!TempInitLabel()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempExitInter::InitView TempInitLabel() false"); - return false; - } - if (!TempInitImage()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempExitInter::InitView TempInitImage() false"); - return false; - } - return true; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempExitPrompt.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempExitPrompt.cpp deleted file mode 100644 index d4155fcb3..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempExitPrompt.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#include "UiConfig.h" -#include "layout/grid_layout.h" -#include -#include "temperature/TempExitPrompt.h" - -namespace OHOS { -static TempExitPrompt *g_tempExitPrompt = nullptr; - -static const int16 EXIT_PROMPT_LABEL_X = 40; -static const int16 EXIT_PROMPT_LABEL_Y = 90; -static const int16 EXIT_PROMPT_LABEL_WEIGHT = 380; -static const int16 EXIT_PROMPT_LABEL_HEIGHT = 320; -static const int16 EXIT_PROMPT_DELETE_X = 80; -static const int16 EXIT_PROMPT_TRUE_X = 290; -static const int16 EXIT_PROMPT_IMAGE_Y = 325; -static const int16 EXIT_PROMPT_LABEL_FONT = 35; -static const char *EXIT_PROMPT_LABEL = (char*)"退出研究后,您的历史相关数据将被清除,且无法继续使用该应用。若需体验,需重新加入体温研究。是否退出?"; - -TempExitPrompt::TempExitPrompt() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempExitPrompt::TempExitPrompt"); - g_tempExitPrompt = this; -} - -TempExitPrompt::~TempExitPrompt() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempExitPrompt::~TempExitPrompt"); - RemoveAll(); - int num; - if (tempLabel != nullptr) { - delete tempLabel; - tempLabel = nullptr; - } - for (num = SET_ZERO; num < SET_TWO; num++) { - if (tempImage[num] != nullptr) { - delete tempImage[num]; - tempImage[num] = nullptr; - } - } - g_tempExitPrompt = nullptr; -} - -TempExitPrompt *TempExitPrompt::GetInstance(void) -{ - return g_tempExitPrompt; -} - -bool TempExitPrompt::TempInitImage(void) -{ - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::TempPresenter::GetInstance(); - tempImage[SET_ZERO] = new UIImageView(); - if (tempImage[SET_ZERO] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempInitInter::TempInitImage new tempImage[SET_ZERO] fail"); - return false; - } - tempImage[SET_ZERO]->SetPosition(EXIT_PROMPT_DELETE_X, EXIT_PROMPT_IMAGE_Y); - tempImage[SET_ZERO]->SetSrc(TEMP_DELETE); - tempImage[SET_ZERO]->SetOnClickListener(clickListener); - tempImage[SET_ZERO]->SetViewId(TEMP_EXIT_DELETE); - tempImage[SET_ZERO]->SetTouchable(true); - Add(tempImage[SET_ZERO]); - - tempImage[SET_ONE] = new UIImageView(); - if (tempImage[SET_ONE] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempInitInter::TempInitImage new tempImage[SET_ONE] fail"); - return false; - } - tempImage[SET_ONE]->SetPosition(EXIT_PROMPT_TRUE_X, EXIT_PROMPT_IMAGE_Y); - tempImage[SET_ONE]->SetSrc(TEMP_TRUE); - tempImage[SET_ONE]->SetOnClickListener(clickListener); - tempImage[SET_ONE]->SetViewId(TEMP_EXIT_TRUE); - tempImage[SET_ONE]->SetTouchable(true); - Add(tempImage[SET_ONE]); - - return true; -} - -bool TempExitPrompt::TempInitLabel(void) -{ - tempLabel = new UILabel(); - if (tempLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempExitPrompt::TempInitLabel new tempLabel fail"); - return false; - } - tempLabel->SetPosition(EXIT_PROMPT_LABEL_X, EXIT_PROMPT_LABEL_Y, - EXIT_PROMPT_LABEL_WEIGHT, EXIT_PROMPT_LABEL_HEIGHT); - tempLabel->SetText(EXIT_PROMPT_LABEL); - tempLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, EXIT_PROMPT_LABEL_FONT); - tempLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - Add(tempLabel); - - return true; -} - -bool TempExitPrompt::InitExitPrompt(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempExitPrompt::InitExitPrompt"); - SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - SetThrowDrag(true); - if (TempPresenter::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempExitPrompt::InitExitPrompt TempPresenter::GetInstance() nullptr"); - return false; - } - UIView::OnDragListener *listener = static_cast(TempPresenter::GetInstance()); - SetOnDragListener(listener); - SetDraggable(true); - SetTouchable(true); - - if (!TempInitLabel()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempExitPrompt::InitExitPrompt TempInitLabel() false"); - return false; - } - if (!TempInitImage()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempExitPrompt::InitExitPrompt TempInitImage() false"); - return false; - } - - return true; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempInitInter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempInitInter.cpp deleted file mode 100644 index da8a03ad0..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempInitInter.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#include "UiConfig.h" -#include -#include "temperature/TempInitInter.h" - -namespace OHOS { -static TempInitInter *g_tempInitInter = nullptr; - -static const int16 TEMP_INIT_DROP_X = 200; -static const int16 TEMP_INIT_DROP_Y = 405; -static const int16 TEMP_INIT_DROP_WIDTH = 45; -static const int16 TEMP_INIT_BUTTON_X = 110; -static const int16 TEMP_INIT_BUTTON_Y = 330; -static const int16 TEMP_INIT_BUTTON_WIDTH = 220; -static const int16 TEMP_INIT_BUTTON_HEIGHT = 80; -static const int16 TEMP_INIT_BUTTON_FONT = 35; -static const int16 LABEL_ONE_X = 90; -static const int16 LABEL_TWO_X = 265; -static const int16 TEMP_INIT_LABEL_THREE_X = 105; -static const int16 TEMP_INIT_LABEL_THREE_Y = 80; -static const int16 TEMP_INIT_IMAGE_TIP_X = 255; -static const int16 TEMP_INIT_IMAGE_TIP_Y = 85; -static const int16 TEMP_INIT_IMAGE_TIP_WIDTH = 35; -static const int16 TEMP_INIT_IMAGE_TIP_HEIGHT = 35; -static const int16 LABEL_THREE_WIDTH = 300; -static const int16 TEMP_INIT_LABEL_FOUR_X = 180; -static const int16 TEMP_INIT_LABEL_FOUR_Y = 120; -static const int16 TEMP_INIT_LABEL_TIME_X = 200; -static const int16 TEMP_INIT_LABEL_TIME_Y = 120; -static const int16 LABEL_FIVE_X = 80; -static const int16 TEMP_INIT_LABEL_FIVE_Y = 275; -static const int16 LABEL_FIVE_WIDTH = 320; -static const int16 LABEL_FIVE_HEIGHT = 50; -static const int16 TEMP_INIT_LABEL_TEMP_Y = 160; -static const int16 TITLE_WIDTH = 90; -static const int16 TITLE_HEIGHT = 50; -static const int16 TEMP_INIT_LABEL_WIDTH = 120; -static const int16 TEMP_INIT_LABEL_HEIGHT = 60; -static const int16 TEMP_INIT_LABEL_SKIN_Y = 220; -static const int16 TEMP_INIT_LABEL_SKIN_HEIGHT = 25; -static const int16 TEMP_INIT_TEMP_FONT = 55; -static const int16 TEMP_INIT_TEMP_SKIN_FONT = 20; -static const int16 TEMP_INIT_TEMP_TITLE_FONT = 35; -static const int16 TEMP_LABEL_MAX = 6; -static const char *TEMP_INIT_BUTTON = (char *)"再次测量"; -static const char *TEMP_INIT_TEMP_LABEL = (char *)"36.5"; -static const char *TEMP_INIT_SKIN_TEMP_LABEL = (char *)"34.5"; -static const char *TEMP_INIT_SKIN_SMALL_LABEL = (char *)"体温(℃) 皮肤温度(℃)"; -static const char *TEMP_INIT_TITLE = (char *)"体温"; -static const char *TEMP_INIT_TITLE_TIME = (char *)"刚刚"; -static const char *TEMP_INIT_LABEL_TIP = (char *)"佩戴不足10分钟,可能影响到温度精确性,数据仅供参考"; - -TempInitInter::TempInitInter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempInitInter::TempInitInter"); - g_tempInitInter = this; -} - -TempInitInter::~TempInitInter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempInitInter::~TempInitInter"); - RemoveAll(); - for (int8_t stNum = SET_ZERO; stNum < SET_THREE; stNum++) { - if (tempImage[stNum] != nullptr) { - delete tempImage[stNum]; - tempImage[stNum] = nullptr; - } - } - for (int8_t ndNum = SET_ZERO; ndNum < TEMP_LABEL_MAX; ndNum++) { - if (tempLabel[ndNum] != nullptr) { - delete tempLabel[ndNum]; - tempLabel[ndNum] = nullptr; - } - } - if (buttonTemp != nullptr) { - delete buttonTemp; - buttonTemp = nullptr; - } - g_tempInitInter = nullptr; -} - -TempInitInter *TempInitInter::GetInstance(void) -{ - return g_tempInitInter; -} - -bool TempInitInter::TempInitImage(void) -{ - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::TempPresenter::GetInstance(); - tempImage[SET_ZERO] = new UIImageView(); - if (tempImage[SET_ZERO] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempInitInter::TempInitImage new tempImage[SET_ZERO] fail"); - return false; - } - tempImage[SET_ZERO]->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - tempImage[SET_ZERO]->SetSrc(TEMP_BACKGROUND); - Add(tempImage[SET_ZERO]); - - tempImage[SET_ONE] = new UIImageView(); - if (tempImage[SET_ONE] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMeasure::InitMeasure new image[SET_ONE] fail"); - return false; - } - tempImage[SET_ONE]->SetPosition(TEMP_INIT_DROP_X, TEMP_INIT_DROP_Y, TEMP_INIT_DROP_WIDTH, TEMP_INIT_DROP_WIDTH); - tempImage[SET_ONE]->SetSrc(TEMP_UP_DROP); - Add(tempImage[SET_ONE]); - - tempImage[SET_TWO] = new UIImageView(); - if (tempImage[SET_TWO] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMeasure::InitMeasure new image[SET_TWO] fail"); - return false; - } - tempImage[SET_TWO]->SetPosition(TEMP_INIT_IMAGE_TIP_X, - TEMP_INIT_IMAGE_TIP_Y, TEMP_INIT_IMAGE_TIP_WIDTH, TEMP_INIT_IMAGE_TIP_HEIGHT); - tempImage[SET_TWO]->SetTouchable(true); - tempImage[SET_TWO]->SetViewId(TEMP_IMAGE_LIT_TIP); - tempImage[SET_TWO]->SetSrc(TEMP_LIT_TIP); - tempImage[SET_TWO]->SetOnClickListener(clickListener); - tempImage[SET_TWO]->SetTouchable(true); - Add(tempImage[SET_TWO]); - - return true; -} - -typedef struct { - int16 labelNum; - int16 x; - int16 y; - int16 width; - int16 height; - char* name; - int16 font; - const char* text; -} TempInitItem; - -static const TempInitItem tempInitItem[] = { - { SET_ZERO, LABEL_ONE_X, TEMP_INIT_LABEL_TEMP_Y, TEMP_INIT_LABEL_WIDTH, TEMP_INIT_LABEL_HEIGHT, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_INIT_TEMP_FONT, TEMP_INIT_TEMP_LABEL }, - { SET_ONE, LABEL_TWO_X, TEMP_INIT_LABEL_TEMP_Y, TEMP_INIT_LABEL_WIDTH, TEMP_INIT_LABEL_WIDTH, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_INIT_TEMP_FONT, TEMP_INIT_SKIN_TEMP_LABEL }, - { SET_TWO, TEMP_INIT_LABEL_THREE_X, TEMP_INIT_LABEL_SKIN_Y, LABEL_THREE_WIDTH, TITLE_HEIGHT, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_INIT_TEMP_SKIN_FONT, TEMP_INIT_SKIN_SMALL_LABEL }, - { SET_THREE, TEMP_INIT_LABEL_FOUR_X, TEMP_INIT_LABEL_THREE_Y, TITLE_WIDTH, TITLE_WIDTH, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_INIT_TEMP_TITLE_FONT, TEMP_INIT_TITLE }, - { SET_FOUR, TEMP_INIT_LABEL_TIME_X, TEMP_INIT_LABEL_TIME_Y, TITLE_WIDTH, TITLE_HEIGHT, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_INIT_TEMP_SKIN_FONT, TEMP_INIT_TITLE_TIME }, - { SET_FIVE, LABEL_FIVE_X, TEMP_INIT_LABEL_FIVE_Y, LABEL_FIVE_WIDTH, LABEL_FIVE_HEIGHT, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_INIT_TEMP_SKIN_FONT, TEMP_INIT_LABEL_TIP }, -}; - -bool TempInitInter::SetBasicLabel(void) -{ - for (int num = 0; num <= SET_FIVE; num++) { - tempLabel[tempInitItem[num].labelNum] = new UILabel(); - if (tempLabel[tempInitItem[num].labelNum] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempInitInter::SetBasicLabel new tempLabel[%d] fail", - tempInitItem[num].labelNum); - return false; - } - tempLabel[tempInitItem[num].labelNum]->SetPosition(tempInitItem[num].x, tempInitItem[num].y, - tempInitItem[num].width, tempInitItem[num].height); - tempLabel[tempInitItem[num].labelNum]->SetFont(tempInitItem[num].name, tempInitItem[num].font); - tempLabel[tempInitItem[num].labelNum]->SetText(tempInitItem[num].text); - Add(tempLabel[tempInitItem[num].labelNum]); - } - return true; -} - -bool TempInitInter::SetAppendLabel(void) -{ - tempLabel[SET_ZERO]->SetTextColor(TempPresenter::GetInstance()->CyanColor()); - tempLabel[SET_TWO]->SetTextColor(Color::Gray()); - tempLabel[SET_FOUR]->SetTextColor(Color::Gray()); - tempLabel[SET_FIVE]->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - tempLabel[SET_FIVE]->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - - return true; -} - -bool TempInitInter::TempInitButton(void) -{ - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::TempPresenter::GetInstance(); - buttonTemp = new UILabelButton(); - if (buttonTemp == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempInitInter::TempInitButton new label fail"); - return false; - } - buttonTemp->SetPosition(TEMP_INIT_BUTTON_X, TEMP_INIT_BUTTON_Y, TEMP_INIT_BUTTON_WIDTH, TEMP_INIT_BUTTON_HEIGHT); - buttonTemp->SetText(TEMP_INIT_BUTTON); - buttonTemp->SetViewId(TEMP_MEA_AGAIN); - buttonTemp->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TEMP_INIT_BUTTON_FONT); - buttonTemp->SetTextColor(OHOS::TempPresenter::GetInstance()->CyanColor()); - buttonTemp->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::Gray().full, UIButton::RELEASED); - buttonTemp->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::Gray().full, UIButton::PRESSED); - buttonTemp->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::Gray().full, UIButton::INACTIVE); - buttonTemp->SetOnClickListener(clickListener); - Add(buttonTemp); - return true; -} - -bool TempInitInter::InitView(void *caller) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempInitInter::InitView"); - UNUSED(caller); - if (TempPresenter::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempInitInter::InitView TempPresenter::GetInstance() nullptr"); - return false; - } - - if (!TempInitImage()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempInitInter::InitView TempInitImage() false"); - return false; - } - if (!SetBasicLabel()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempInitInter::InitView TempInitLabel() false"); - return false; - } - if (!SetAppendLabel()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempInitInter::InitView TempLowLabel() false"); - return false; - } - if (!TempInitButton()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempInitInter::InitView TempInitButton() false"); - return false; - } - return true; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempJoinStudy.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempJoinStudy.cpp deleted file mode 100644 index 22153997b..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempJoinStudy.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#include "UiConfig.h" -#include "layout/grid_layout.h" -#include -#include "temperature/TempJoinStudy.h" - -namespace OHOS { -static TempJoinStudy *g_tempJoinStudy = nullptr; -static const int16 TEMP_TITLE_X = 150; -static const int16 TEMP_TITLE_Y = 50; -static const int16 TEMP_TITLE_WIDTH = 150; -static const int16 TEMP_TITLE_HEIGHT = 45; -static const int16 TEMP_TITLE_FONT = 36; -static const int16 TEMP_FIRST_LABEL_FONT = 35; -static const int16 TEMP_LABEL_FIRST_X = 45; -static const int16 TEMP_LABEL_FIRST_Y = 120; -static const int16 TEMP_LABEL_SECOND_Y = 350; -static const int16 TEMP_LABEL_THIRD_Y = 650; -static const int16 TEMP_LABEL_FIRST_WIDTH = 350; -static const int16 TEMP_LABEL_FIRST_HEIGHT = 400; -static const int16 TEMP_BUTTON_X = 120; -static const int16 TEMP_BUTTON_FIRST_Y = 940; -static const int16 TEMP_BUTTON_SECOND_Y = 1040; -static const int16 TEMP_BUTTON_WEDITH = 220; -static const int16 TEMP_BUTTON_HEIGHT = 80; -static const int16 TEMP_LABEL_MAX = 3; -static const int16 TEMP_BUTTON_MAX = 2; -static const char *TEMP_TITLE_TEXT = (char*)"体温研究"; -static const char *TEMP_LABEL_ONE = (char*)"本功能通过内置温度传感器测量腕部皮肤温度,主要研究腕部皮肤温度和体温的关系。"; -static const char *TEMP_LABEL_TWO = (char*)"本功能用于18岁以上健康人群测量运动过程,及之后腕部皮肤温度和体温的变化,请加入研究,以便及时观察运动前后身体的变化。"; -static const char *TEMP_LABEL_THREE = (char*)"测量需佩戴10分钟以上,且容易受到环境因素影响。目前达不到水银体温计的精度,测量结果仅供参考,不作为医疗诊断依据。"; -static const char *TEMP_BUTTON_ONE = (char*)"加入研究"; -static const char *TEMP_BUTTON_TWO = (char*)"退出"; - -TempJoinStudy::TempJoinStudy() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempJoinStudy::TempJoinStudy"); - g_tempJoinStudy = this; -} - -TempJoinStudy::~TempJoinStudy() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempJoinStudy::~TempJoinStudy"); - RemoveAll(); - if (tempTitle != nullptr) { - delete tempTitle; - tempTitle = nullptr; - } - for (int32_t numLabel = SET_ZERO; numLabel < TEMP_LABEL_MAX; numLabel++) { - if (tempLabel[numLabel] != nullptr) { - delete tempLabel[numLabel]; - tempLabel[numLabel] = nullptr; - } - } - for (int32_t numButton = SET_ZERO; numButton < TEMP_BUTTON_MAX; numButton++) { - if (tempButton[numButton] != nullptr) { - delete tempButton[numButton]; - tempButton[numButton] = nullptr; - } - } - g_tempJoinStudy = nullptr; -} - -TempJoinStudy *TempJoinStudy::GetInstance(void) -{ - return g_tempJoinStudy; -} - -bool TempJoinStudy::InitSimilarLabel(int16 num, int16 labelY, const char *labelText) -{ - tempLabel[num] = new UILabel(); - if (tempLabel[num] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempJoinStudy::TempInitLabel new tempLabel[%d] error", num); - return false; - } - tempLabel[num]->SetPosition(TEMP_LABEL_FIRST_X, labelY, TEMP_LABEL_FIRST_WIDTH, TEMP_LABEL_FIRST_HEIGHT); - tempLabel[num]->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - tempLabel[num]->SetText(labelText); - tempLabel[num]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TEMP_FIRST_LABEL_FONT); - Add(tempLabel[num]); - - return true; -} - -bool TempJoinStudy::TempInitLabel(void) -{ - tempTitle = new UILabel(); - if (tempTitle == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempJoinStudy::TempInitLabel new tempTitle error"); - return false; - } - tempTitle->SetPosition(TEMP_TITLE_X, TEMP_TITLE_Y, TEMP_TITLE_WIDTH, TEMP_TITLE_HEIGHT); - tempTitle->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TEMP_TITLE_FONT); - tempTitle->SetText(TEMP_TITLE_TEXT); - Add(tempTitle); - - if (!InitSimilarLabel(SET_ZERO, TEMP_LABEL_FIRST_Y, TEMP_LABEL_ONE)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempJoinStudy::TempInitLabel new tempLabel[SET_ZERO] error"); - return false; - } - if (!InitSimilarLabel(SET_ONE, TEMP_LABEL_SECOND_Y, TEMP_LABEL_TWO)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempJoinStudy::TempInitLabel new tempLabel[SET_ONE] error"); - return false; - } - if (!InitSimilarLabel(SET_TWO, TEMP_LABEL_THIRD_Y, TEMP_LABEL_THREE)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempJoinStudy::TempInitLabel new tempLabel[SET_ONE] error"); - return false; - } - - return true; -} - -bool TempJoinStudy::TempInitButton(void) -{ - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::TempPresenter::GetInstance(); - tempButton[SET_ZERO] = new UILabelButton(); - if (tempButton[SET_ZERO] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempJoinStudy::TempInitButton new tempButton[SET_ZERO] error"); - return false; - } - tempButton[SET_ZERO]->SetPosition(TEMP_BUTTON_X, TEMP_BUTTON_FIRST_Y, TEMP_BUTTON_WEDITH, TEMP_BUTTON_HEIGHT); - tempButton[SET_ZERO]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TEMP_TITLE_FONT); - tempButton[SET_ZERO]->SetText(TEMP_BUTTON_ONE); - tempButton[SET_ZERO]->SetViewId(TEMP_INTER_JOIN); - tempButton[SET_ZERO]->SetOnClickListener(clickListener); - tempButton[SET_ZERO]->SetStyleForState(STYLE_BACKGROUND_COLOR, - OHOS::TempPresenter::GetInstance()->CyanColor().full, UIButton::RELEASED); - tempButton[SET_ZERO]->SetStyleForState(STYLE_BACKGROUND_COLOR, - OHOS::TempPresenter::GetInstance()->CyanColor().full, UIButton::PRESSED); - tempButton[SET_ZERO]->SetStyleForState(STYLE_BACKGROUND_COLOR, - OHOS::TempPresenter::GetInstance()->CyanColor().full, UIButton::INACTIVE); - Add(tempButton[SET_ZERO]); - - tempButton[SET_ONE] = new UILabelButton(); - if (tempButton[SET_ONE] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempJoinStudy::TempInitButton new tempButton[SET_ONE] error"); - return false; - } - tempButton[SET_ONE]->SetPosition(TEMP_BUTTON_X, TEMP_BUTTON_SECOND_Y, TEMP_BUTTON_WEDITH, TEMP_BUTTON_HEIGHT); - tempButton[SET_ONE]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TEMP_TITLE_FONT); - tempButton[SET_ONE]->SetText(TEMP_BUTTON_TWO); - tempButton[SET_ONE]->SetViewId(TEMP_INTER_EXIT); - tempButton[SET_ONE]->SetOnClickListener(clickListener); - tempButton[SET_ONE]->SetTextColor(OHOS::TempPresenter::GetInstance()->CyanColor()); - tempButton[SET_ONE]->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::Gray().full, UIButton::RELEASED); - tempButton[SET_ONE]->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::Gray().full, UIButton::PRESSED); - tempButton[SET_ONE]->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::Gray().full, UIButton::INACTIVE); - Add(tempButton[SET_ONE]); - - return true; -} - -bool TempJoinStudy::InitJoinStudy(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempJoinStudy::InitJoinStudy"); - SetViewId(TEMP_JOIN_STUDY); - SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - SetThrowDrag(true); - SetScrollBlankSize(50); // 50:font size - if (TempPresenter::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempJoinStudy::InitJoinStudy TempPresenter::GetInstance() nullptr"); - return false; - } - UIView::OnDragListener *listener = static_cast(TempPresenter::GetInstance()); - SetOnDragListener(listener); - SetDraggable(true); - SetTouchable(true); - - if (!TempInitLabel()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempJoinStudy::InitJoinStudy TempInitLabel() false"); - return false; - } - if (!TempInitButton()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempJoinStudy::InitJoinStudy TempInitButton() false"); - return false; - } - - return true; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempLittleTip.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempLittleTip.cpp deleted file mode 100644 index 5f4d4fa94..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempLittleTip.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#include "UiConfig.h" -#include -#include "temperature/TempLittleTip.h" - -namespace OHOS { -static TempLittleTip *g_tempJoinStudy = nullptr; - -static const int16 TEMP_TIP_LABEL_ONE_X = 180; -static const int16 TEMP_TIP_LABEL_ONE_Y = 45; -static const int16 TEMP_TIP_LABEL_TITLE_WIDTH = 230; -static const int16 TEMP_TIP_LABEL_TITLE_HEIGHT = 70; -static const int16 TEMP_TIP_LABEL_X = 45; -static const int16 TEMP_TIP_LABEL_TWO_Y = 130; -static const int16 TEMP_TIP_LABEL_THREE_Y = 610; -static const int16 TEMP_TIP_LABEL_FOUR_Y = 670; -static const int16 TEMP_TIP_LABEL_FIVE_Y = 1070; -static const int16 TEMP_TIP_LABEL_SIX_Y = 1120; -static const int16 TEMP_TIP_LABEL_SIX_HEIGHT = 300; -static const int16 TEMP_TIP_LABEL_SEVEN_Y = 1340; -static const int16 TEMP_TIP_LABEL_SEVEN_HEIGHT = 480; -static const int16 TEMP_TIP_LABEL_EIGHT_Y = 2030; -static const int16 TEMP_TIP_LABEL_NIGHT_Y = 2330; -static const int16 TEMP_TIP_LABEL_TITLE_X = 160; -static const int16 TEMP_LABEL_WIDTH = 350; -static const int16 TEMP_LABEL_HEIGHT = 420; -static const int16 TEMP_TIP_TITLE_FONT = 38; -static const int16 TEMP_TIP_TEXT_FONT = 34; -static const int16 TEMP_LABEL_MAX = 9; -static const int16 SET_SIX = 6; -static const char *TEMP_TIP_LABEL_ONE = (char *)"体温"; -static const char *TEMP_TIP_LABEL_TWO = (char *)"人体内部的温度称体温。保持恒定的体温,是保持新陈代谢和生命活动的正常进行的必要条件。正常的体温不是一个温度点,\ -而是一个体温的范围,大概在36℃-37℃之间(腋窝)通常人体低于35℃为低体温,高于37.2℃为发热。"; -static const char *TEMP_TIP_LABEL_THREE = (char *)"皮肤温度"; -static const char *TEMP_TIP_LABEL_FOUR = (char *)"皮肤温度是指皮肤表面的温度。人体各部位的皮肤温度不同,且受环境、生理因素等影响显著。室内环境下,\ -人体腕部皮肤温度大概在32-34℃,维持舒适的皮肤温度是保证人体热舒适的重要条件"; -static const char *TEMP_TIP_LABEL_FIVE = (char *)"测量须知"; -static const char *TEMP_TIP_LABEL_SIX = (char *)"● 本设备支持的测量范围为:体温:34-42℃皮肤温度:20-42℃"; -static const char *TEMP_TIP_LABEL_SEVEN = (char *)"● 受周围环境影响,测量精度可能会下降。注意以下事项,有助于减少误差:·确保偏紧佩戴10分钟以上,\ -在室温(25℃左右)安静状态下测量;·确保手腕处没有水、酒精等液体;·运动、洗澡、室内室外环境切换时,请等待30分钟后在测量;·请避免在阳光直射,有风,又冷/热源的环境下进行测量。"; -static const char *TEMP_TIP_LABEL_EIGHT = (char *)"● 穿戴设备在未佩戴、环境温度过低(< 35℃)、过高(> 37.2℃)等条件下会进行出值限制。"; -static const char *TEMP_TIP_LABEL_NINE = (char *)"● 测量结果仅供参考,不作为医疗诊断依据"; - -TempLittleTip::TempLittleTip() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempLittleTip::TempLittleTip"); - g_tempJoinStudy = this; -} - -TempLittleTip::~TempLittleTip() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempLittleTip::~TempLittleTip"); - RemoveAll(); - int8 num; - for (num = 0; num < TEMP_LABEL_MAX; num++) { - if (tempLabel[num] != nullptr) { - delete tempLabel[num]; - tempLabel[num] = nullptr; - } - } - g_tempJoinStudy = nullptr; -} - -TempLittleTip *TempLittleTip::GetInstance(void) -{ - return g_tempJoinStudy; -} - -typedef struct { - int16 labelNum; - int16 x; - int16 y; - int16 width; - int16 height; - char* name; - int16 font; - const char* text; -} TempTipItem; - -static const TempTipItem tempTipItem[] = { - { SET_ZERO, TEMP_TIP_LABEL_ONE_X, TEMP_TIP_LABEL_ONE_Y, TEMP_TIP_LABEL_TITLE_WIDTH, TEMP_TIP_LABEL_TITLE_HEIGHT, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_TIP_TITLE_FONT, TEMP_TIP_LABEL_ONE }, - { SET_ONE, TEMP_TIP_LABEL_X, TEMP_TIP_LABEL_TWO_Y, TEMP_LABEL_WIDTH, TEMP_LABEL_HEIGHT, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_TIP_TEXT_FONT, TEMP_TIP_LABEL_TWO }, - { SET_TWO, TEMP_TIP_LABEL_TITLE_X, TEMP_TIP_LABEL_THREE_Y, TEMP_TIP_LABEL_TITLE_WIDTH, - TEMP_TIP_LABEL_TITLE_HEIGHT, (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_TIP_TITLE_FONT, TEMP_TIP_LABEL_THREE }, - { SET_THREE, TEMP_TIP_LABEL_X, TEMP_TIP_LABEL_FOUR_Y, TEMP_LABEL_WIDTH, TEMP_LABEL_HEIGHT, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_TIP_TEXT_FONT, TEMP_TIP_LABEL_FOUR }, - { SET_FOUR, TEMP_TIP_LABEL_TITLE_X, TEMP_TIP_LABEL_FIVE_Y, TEMP_TIP_LABEL_TITLE_WIDTH, - TEMP_TIP_LABEL_TITLE_HEIGHT, (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_TIP_TITLE_FONT, TEMP_TIP_LABEL_FIVE }, - { SET_FIVE, TEMP_TIP_LABEL_X, TEMP_TIP_LABEL_SIX_Y, TEMP_LABEL_WIDTH, TEMP_TIP_LABEL_SIX_HEIGHT, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_TIP_TEXT_FONT, TEMP_TIP_LABEL_SIX }, - { SET_SIX, TEMP_TIP_LABEL_X, TEMP_TIP_LABEL_SEVEN_Y, TEMP_LABEL_WIDTH, TEMP_TIP_LABEL_SEVEN_HEIGHT, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_TIP_TEXT_FONT, TEMP_TIP_LABEL_SEVEN }, - { SET_SEVEN, TEMP_TIP_LABEL_X, TEMP_TIP_LABEL_EIGHT_Y, TEMP_LABEL_WIDTH, TEMP_TIP_LABEL_SIX_HEIGHT, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_TIP_TEXT_FONT, TEMP_TIP_LABEL_EIGHT }, - { SET_EIGHT, TEMP_TIP_LABEL_X, TEMP_TIP_LABEL_NIGHT_Y, TEMP_LABEL_WIDTH, TEMP_TIP_LABEL_SIX_HEIGHT, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_TIP_TEXT_FONT, TEMP_TIP_LABEL_NINE }, -}; - -bool TempLittleTip::SetBasicLabel(void) -{ - for (int num = 0; num <= SET_EIGHT; num++) { - tempLabel[tempTipItem[num].labelNum] = new UILabel(); - if (tempLabel[tempTipItem[num].labelNum] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempLittleTip::SetBasicLabel new tempLabel[%d] fail", - tempTipItem[num].labelNum); - return false; - } - tempLabel[tempTipItem[num].labelNum]->SetPosition(tempTipItem[num].x, tempTipItem[num].y, - tempTipItem[num].width, tempTipItem[num].height); - tempLabel[tempTipItem[num].labelNum]->SetFont(tempTipItem[num].name, tempTipItem[num].font); - tempLabel[tempTipItem[num].labelNum]->SetText(tempTipItem[num].text); - Add(tempLabel[tempTipItem[num].labelNum]); - } - return true; -} - -bool TempLittleTip::SetAppendLabel(void) -{ - for (int num = 0; num <= SET_EIGHT; num++) { - if (tempLabel[tempTipItem[num].labelNum] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempLittleTip::SetAppendLabel tempTipItem[%d] nullptr", - tempTipItem[num].labelNum); - return false; - } - if (num == SET_ZERO || num == SET_TWO || num == SET_FOUR) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempLittleTip::SetAppendLabel continue"); - continue; - } - tempLabel[tempTipItem[num].labelNum]->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - } - return true; -} - -bool TempLittleTip::InitLittleTip(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempLittleTip::InitLittleTip"); - SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - SetThrowDrag(true); - SetScrollBlankSize(50); // 50:font size - if (TempPresenter::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempLittleTip::InitLittleTip TempPresenter::GetInstance() nullptr"); - return false; - } - UIView::OnDragListener *listener = static_cast(TempPresenter::GetInstance()); - SetOnDragListener(listener); - SetDraggable(true); - SetTouchable(true); - - if (!SetBasicLabel()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempLittleTip::InitLittleTip SetLabel() false"); - return false; - } - if (!SetAppendLabel()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempLittleTip::InitLittleTip SetAppendLabel() false"); - return false; - } - return true; -} - -void TempLittleTip::RefreshTip(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempLittleTip::RefreshTip"); - ScrollBy(0, TEMP_TIP_LABEL_ONE_Y - tempLabel[0]->GetY()); -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempMainView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempMainView.cpp deleted file mode 100644 index 10cbbae6f..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempMainView.cpp +++ /dev/null @@ -1,589 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#include "temperature/TempMainView.h" -#include "UiConfig.h" -#include "temperature/TempMeaProcess.h" -#include "temperature/TempWarn.h" - -namespace OHOS { -static TempMainView *g_tempMainView = nullptr; - -static const int16 FIRST_TIME_JOIN = 0; -static const int16 SECOND_TIME_JOIN = 1; -static const int16 LABEL_FIRST_X = 200; -static const int16 LABEL_FIRST_Y = 60; -static const int16 LABEL_FIRST_WIDTH = 150; -static const int16 LABEL_FIRST_HEIGHT = 45; -static const int16 LABEL_FIRST_FONT = 35; -static const int16 INTERFACES_MAX = 10; - -TempMainView::TempMainView() -{ - g_tempMainView = this; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::TempMainView"); -} - -TempMainView::~TempMainView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::~TempMainView"); - for (int16_t numGroup = SET_ZERO; numGroup <= INTERFACES_MAX; numGroup++) { - if (container[numGroup] != nullptr) { - container[numGroup] = nullptr; - } - } - for (int16_t numSwipe = SET_ZERO; numSwipe < SET_TWO; numSwipe++) { - if (tempSwipeList[numSwipe] != nullptr) { - tempSwipeList[numSwipe]->RemoveAll(); - delete tempSwipeList[numSwipe]; - tempSwipeList[numSwipe] = nullptr; - } - } - DeleteViceInter(); - group = nullptr; - g_tempMainView = nullptr; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::~TempMainView"); -} - -TempMainView *TempMainView::GetInstance(void) -{ - return g_tempMainView; -} - -void TempMainView::OnStart() -{ - - int16 tempInterListen = TempModel::GetInstance()->GetTempInterLis(); - if (tempInterListen == FIRST_TIME_JOIN) { - tempJoinStudy = new TempJoinStudy(); - if (tempJoinStudy == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView:: OnStart tempJoinStudy null error!"); - return; - } - container[0] = tempJoinStudy; - tempJoinStudy->InitJoinStudy(); - tempWhichInter = JOIN_STUDY_INTER; - group = container[0]; - } else if (tempInterListen == SECOND_TIME_JOIN) { - AppGroupView *view[SET_TWO] = {nullptr}; - if (!SetSwipeInter(0)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView::OnStart SetSwipeInter[0] null error!"); - return; - } - tempMeasure = new TempMeasure(); - if (tempMeasure == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView:: OnStart tempMeasure null error!"); - return; - } - view[0] = tempMeasure; - view[0]->InitView(this); - - tempExitInter = new TempExitInter(); - if (tempExitInter == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView:: OnStart tempExitInter null error!"); - return; - } - view[1] = tempExitInter; - view[1]->InitView(this); - tempSwipeList[0]->Add(view[0]); - tempSwipeList[0]->Add(view[1]); - container[MEASURE_INTER] = tempSwipeList[0]; - group = container[MEASURE_INTER]; - tempWhichInter = MEASURE_INTER; - } - AddViewToRootContainer(group); - return; -} - -void TempMainView::DeleteViceInter(void) -{ - if (tempJoinStudy != nullptr) { - delete tempJoinStudy; - tempJoinStudy = nullptr; - } - if (tempMeasure != nullptr) { - delete tempMeasure; - tempMeasure = nullptr; - } - if (tempExitInter != nullptr) { - delete tempExitInter; - tempExitInter = nullptr; - } - if (tempPromptWear != nullptr) { - delete tempPromptWear; - tempPromptWear = nullptr; - } - if (tempClickMea != nullptr) { - delete tempClickMea; - tempClickMea = nullptr; - } - if (tempRemindWear != nullptr) { - delete tempRemindWear; - tempRemindWear = nullptr; - } - if (tempMeaProcess != nullptr) { - delete tempMeaProcess; - tempMeaProcess = nullptr; - } - if (tempInitInter != nullptr) { - delete tempInitInter; - tempInitInter = nullptr; - } - if (tempWarn != nullptr) { - delete tempWarn; - tempWarn = nullptr; - } - if (tempLittleTip != nullptr) { - delete tempLittleTip; - tempLittleTip = nullptr; - } - if (tempExitPrompt != nullptr) { - delete tempExitPrompt; - tempExitPrompt = nullptr; - } - if (tempStudyAbout != nullptr) { - delete tempStudyAbout; - tempStudyAbout = nullptr; - } -} - -int16 TempMainView::GetWhichInter(void) -{ - return tempWhichInter; -} - -bool TempMainView::SetSwipeInter(int16 num) -{ - if (TempPresenter::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView:: SetSwipeInter TempPresenter null!"); - return false; - } - UIView::OnDragListener *listener = static_cast(TempPresenter::GetInstance()); - UISwipeView::OnSwipeListener* onSwipeListener = - static_cast(OHOS::TempPresenter::GetInstance()); - tempSwipeList[num] = new UISwipeView(UISwipeView::VERTICAL); - if (tempSwipeList[num] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "tempSwipeList[num] new fail"); - return false; - } - tempSwipeList[num]->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - tempSwipeList[num]->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - tempSwipeList[num]->SetOnDragListener(listener); - tempSwipeList[num]->SetOnSwipeListener(onSwipeListener); - tempSwipeList[num]->SetDraggable(true); - tempSwipeList[num]->SetTouchable(true); - tempSwipeList[num]->SetAnimatorTime(50); // 50 animator drag time(ms) - - return true; -} - -int16 TempMainView::GetListenInter(void) -{ - return interListen; -} - -void TempMainView::DropView(UIView& view) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::DropView"); - if (&view == container[PROMPT_WEAR]) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::DropView::container[PROMPT_WEAR]"); - ChangeView(PROMPT_WEAR, MEASURE_INTER); - } else if (&view == container[CLICK_MEA]) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::DropView::container[CLICK_MEA]"); - ChangeView(CLICK_MEA, PROMPT_WEAR); - } else if (&view == container[REMIND_WEAR]) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::DropView::container[REMIND_WEAR]"); - ChangeView(REMIND_WEAR, CLICK_MEA); - } else if (&view == container[TEMP_EXIT_STUDY]) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::DropView::container[TEMP_EXIT_STUDY]"); - ChangeView(TEMP_EXIT_STUDY, tempWhichMea); - } else if (&view == container[TEMP_WARN_INTER]) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::DropView::container[TEMP_WARN_INTER]"); - ChangeView(TEMP_WARN_INTER, MEASURE_INTER); - } else if (&view == container[TEMP_STUDY]) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::DropView::container[TEMP_STUDY] tempWhichMea = %d", tempWhichMea); - ChangeView(TEMP_STUDY, tempWhichMea); - } else if (&view == container[TEMP_TIP]) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::DropView::container[TEMP_TIP]"); - ChangeView(TEMP_TIP, MEASURE_INIT); - } else if (&view == container[MEASURE_ING]) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::DropView::container[MEASURE_ING]"); - if (interListen == CLICK_MEA) { - ChangeView(MEASURE_ING, CLICK_MEA); - } else if (interListen == MEASURE_INIT) { - ChangeView(MEASURE_ING, MEASURE_INIT); - } - if (TempMeaProcess::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMeaProcess::GetInstance() null error!"); - return; - } - if (TempPresenter::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempPresenter::GetInstance() null error!"); - return; - } - TempMeaProcess::GetInstance()->SetCircleStatus(false); - TempPresenter::GetInstance()->SetTempCountMax(); - } else { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); - } - return; -} - -bool TempMainView::ChangePrompt(int16 thisView) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangePrompt"); - if (container[thisView] == nullptr) { - tempPromptWear = new TempPromptWear(); - if (tempPromptWear == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView:: OnStart tempPromptWear null error!"); - return false; - } - container[thisView] = tempPromptWear; - tempPromptWear->InitPromptWear(); - AddViewToRootContainer(container[thisView]); - } - tempWhichInter = thisView; - return true; -} - -bool TempMainView::ChangeMeasure(int16 thisView) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeMeasure"); - if (container[thisView] == nullptr) { - AppGroupView *view[SET_THREE] = {nullptr}; - if (!SetSwipeInter(SET_ZERO)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeMeasure SetSwipeInter[0] null error!"); - return false; - } - tempMeasure = new TempMeasure(); - if (tempMeasure == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeMeasure tempMeasure null error!"); - return false; - } - view[SET_ZERO] = tempMeasure; - if (!view[SET_ZERO]->InitView(this)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeMeasure view [0] InitView null error!"); - return false; - } - - tempExitInter = new TempExitInter(); - if (tempExitInter == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeMeasure tempExitInter null error!"); - return false; - } - view[SET_ONE] = tempExitInter; - if (!view[SET_ONE]->InitView(this)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeMeasure view [1] InitView null error!"); - return false; - } - tempSwipeList[SET_ZERO]->Add(view[SET_ZERO]); - tempSwipeList[SET_ZERO]->Add(view[SET_ONE]); - container[thisView] = tempSwipeList[SET_ZERO]; - - AddViewToRootContainer(container[thisView]); - TempModel::GetInstance()->SetTempInterLis(SECOND_TIME_JOIN); - } - tempWhichInter = thisView; - tempWhichMea = thisView; - return true; -} - -bool TempMainView::ChangeClickMea(int16 thisView) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeClickMea"); - if (container[thisView] == nullptr) { - tempClickMea = new TempClickMea(); - if (tempClickMea == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeClickMea tempClickMea null error!"); - return false; - } - container[thisView] = tempClickMea; - if (!tempClickMea->InitClickMea()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeClickMea InitClickMea error!"); - return false; - } - AddViewToRootContainer(container[thisView]); - } - if (TempClickMea::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempClickMea:: GetInstance error!"); - return false; - } - TempClickMea::GetInstance()->RefreshClickMea(); - tempWhichInter = thisView; - return true; -} - -bool TempMainView::ChangeRemindWear(int16 thisView) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeRemindWear"); - if (container[thisView] == nullptr) { - tempRemindWear = new TempRemindWear(); - if (tempRemindWear == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView:: OnStart tempRemindWear null error!"); - return false; - } - container[thisView] = tempRemindWear; - if (!tempRemindWear->InitRemindWear()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeRemindWear InitRemindWear error!"); - return false; - } - AddViewToRootContainer(container[thisView]); - } - tempWhichInter = thisView; - return true; -} - -bool TempMainView::ChangeMeaProcess(int16 thisView) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeMeaProcess"); - if (container[thisView] == nullptr) { - tempMeaProcess = new TempMeaProcess(); - if (tempMeaProcess == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView:: OnStart tempMeaProcess null error!"); - return false; - } - container[thisView] = tempMeaProcess; - if (!tempMeaProcess->InitMeaProcess()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeMeaProcess InitMeaProcess error!"); - return false; - } - AddViewToRootContainer(container[thisView]); - } - if (TempMeaProcess::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMeaProcess:: GetInstance error!"); - return false; - } - TempMeaProcess::GetInstance()->SetCircleStatus(true); - tempWhichInter = thisView; - return true; -} - -bool TempMainView::ChangeTempInit(int16 thisView) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeTempInit"); - if (container[thisView] == nullptr) { - AppGroupView *view[SET_THREE] = {nullptr}; - if (!SetSwipeInter(SET_ONE)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeMeasure SetSwipeInter[1] null error!"); - return false; - } - tempInitInter = new TempInitInter(); - if (tempInitInter == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView:: OnStart tempInitInter null error!"); - return false; - } - view[SET_ZERO] = tempInitInter; - if (!view[SET_ZERO]->InitView(this)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeTempInit view [0] InitView null error!"); - return false; - } - - tempExitInter = new TempExitInter(); - if (tempExitInter == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView:: OnStart tempExitInter null error!"); - return false; - } - view[SET_ONE] = tempExitInter; - if (!view[SET_ONE]->InitView(this)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeTempInit view [1] InitView null error!"); - return false; - } - - tempReport = new TempReport(); - if (tempReport == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeMeasure tempReport null error!"); - return false; - } - view[SET_TWO] = tempReport; - if (!view[SET_TWO]->InitView(this)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeMeasure view [2] InitView null error!"); - return false; - } - tempSwipeList[SET_ONE]->Add(view[SET_ZERO]); - tempSwipeList[SET_ONE]->Add(view[SET_ONE]); - tempSwipeList[SET_ONE]->Add(view[SET_TWO]); - container[thisView] = tempSwipeList[SET_ONE]; - - AddViewToRootContainer(container[thisView]); - } - tempWhichInter = thisView; - tempWhichMea = thisView; - return true; -} - -bool TempMainView::ChangeTempWarn(int16 thisView) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeTempWarn"); - if (container[thisView] == nullptr) { - tempWarn = new TempWarn(); - if (tempWarn == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeTempWarn tempWarn null error!"); - return false; - } - container[thisView] = tempWarn; - if (!tempWarn->InitTempWarn()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView::InitTempWarn tempWarn null error!"); - return false; - } - AddViewToRootContainer(container[thisView]); - } - if (TempWarn::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempWarn::GetInstance null error!"); - return false; - } - TempWarn::GetInstance()->RefreshTempWarn(); - tempWhichInter = thisView; - return true; -} - -bool TempMainView::ChangeContinue(int16 thisView) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeContinue"); - if (container[thisView] == nullptr) { - tempContinue = new TempContinueWarn(); - if (tempContinue == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeTempWarn tempContinue null error!"); - return false; - } - container[thisView] = tempContinue; - if (!tempContinue->InitTempContinue()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView::InitTempWarn tempContinue null error!"); - return false; - } - AddViewToRootContainer(container[thisView]); - } - if (TempContinueWarn::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempContinueWarn::GetInstance null error!"); - return false; - } - tempWhichInter = thisView; - return true; -} - -bool TempMainView::ChangeTempTip(int16 thisView) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeTempTip"); - if (container[thisView] == nullptr) { - tempLittleTip = new TempLittleTip(); - if (tempLittleTip == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView:: ChangeTempTip tempLittleTip null error!"); - return false; - } - container[thisView] = tempLittleTip; - if (!tempLittleTip->InitLittleTip()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView:: ChangeTempTip InitLittleTip null error!"); - return false; - } - AddViewToRootContainer(container[thisView]); - } - if (TempLittleTip::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempLittleTip:: GetInstance error!"); - return false; - } - TempLittleTip::GetInstance()->RefreshTip(); - tempWhichInter = thisView; - return true; -} - -bool TempMainView::ChangeExitPrompt(int16 thisView) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeExitPrompt"); - if (container[thisView] == nullptr) { - tempExitPrompt = new TempExitPrompt(); - if (tempExitPrompt == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView:: ChangeExitPrompt tempExitPrompt null error!"); - return false; - } - container[thisView] = tempExitPrompt; - if (!tempExitPrompt->InitExitPrompt()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView:: ChangeExitPrompt InitExitPrompt null error!"); - return false; - } - AddViewToRootContainer(container[thisView]); - } - tempWhichInter = thisView; - return true; -} - -bool TempMainView::ChangeStudyAbout(int16 thisView) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeStudyAbout"); - if (container[thisView] == nullptr) { - tempStudyAbout = new TempStudyAbout(); - if (tempStudyAbout == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView:: ChangeStudyAbout tempStudyAbout null error!"); - return false; - } - container[thisView] = tempStudyAbout; - if (!tempStudyAbout->InitStudyAbout()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView:: ChangeStudyAbout InitStudyAbout null error!"); - return false; - } - AddViewToRootContainer(container[thisView]); - } - if (TempStudyAbout::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempStudyAbout:: GetInstance error!"); - return false; - } - TempStudyAbout::GetInstance()->RefreshStudy(); - tempWhichInter = thisView; - return true; -} - -struct TempViewMapper { - const int16 viewId; - bool (TempMainView::*func)(int16 thisView); -}; - -static const TempViewMapper ViewMapper[] = { - {MEASURE_INTER, &TempMainView::ChangeMeasure}, - {PROMPT_WEAR, &TempMainView::ChangePrompt}, - {CLICK_MEA, &TempMainView::ChangeClickMea}, - {REMIND_WEAR, &TempMainView::ChangeRemindWear}, - {MEASURE_ING, &TempMainView::ChangeMeaProcess}, - {MEASURE_INIT, &TempMainView::ChangeTempInit}, - {TEMP_WARN_INTER, &TempMainView::ChangeTempWarn}, - {TEMP_TIP, &TempMainView::ChangeTempTip}, - {TEMP_EXIT_STUDY, &TempMainView::ChangeExitPrompt}, - {TEMP_STUDY, &TempMainView::ChangeStudyAbout}, -}; - -bool TempMainView::ClickFunc(int16 interf) -{ - int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]); - for (int i = 0; i < funcSize; i++) { - if (interf == ViewMapper[i].viewId) { - bool jug = (this->*(ViewMapper[i].func))(interf); - if (!jug) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainAlarmView:: ChangeInterFace[%d] false", interf); - return false; - } - return true; - } - } - return false; -} - -void TempMainView::ChangeView(int16 hideView, int16 showView) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeView hideView = %d, showView = %d", hideView, showView); - if (hideView > INTERFACES_MAX) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeView Overstep ones bounds"); - return; - } - interListen = hideView; - if (!ClickFunc(showView)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMainView::ChangeView ClickFunc error"); - return; - } - container[hideView]->SetVisible(false); - container[showView]->SetVisible(true); - - Draw(); - return; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempMeaProcess.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempMeaProcess.cpp deleted file mode 100644 index 7a8fa1d8c..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempMeaProcess.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#include "UiConfig.h" -#include -#include "temperature/TempMeaProcess.h" -#include "temperature/TempMainView.h" - -namespace OHOS { -static TempMeaProcess *g_tempMeaProcess = nullptr; - -static const int16 MEASURE_PROCESS_IMAGE_X = 130; -static const int16 MEASURE_PROCESS_IMAGE_Y = 128; -static const int16 MEASURE_PROCESS_BUTTON_X = 120; -static const int16 MEASURE_PROCESS_BUTTON_Y = 135; -static const int16 MEASURE_PROCESS_WIDTH = 80; -static const int16 MEASURE_PROCESS_CIRCLE_WIDTH = 300; -static const int16 CIRCLE_PROGRESS_CENTER_X = 161; -static const int16 CIRCLE_PROGRESS_CENTER_Y = 161; -static const int16 MEA_CIRCLE_RADIUS = 115; -static const int16 MEA_CIRCLE_VALUE = 100; -static const int16 MEA_CIRCLE_PROGRESS_WIDTH = 20; -static const int16 MEA_CIRCLE_PROGRESS_LEFT = 10; -static const int16 MEA_CIRCLE_PROGRESS_TOP = 5; -static const int16 MEA_CIRCLE_PROGRESS_STARTANGLE = 360; -static const int16 MEA_CIRCLE_PROGRESS_ENDANGLE = 0; -static const int16 MEA_PROCESS_LABEL_FONT = 34; -static const int16 MEA_PROCESS_LABEL_X = 155; -static const int16 MEA_PROCESS_LABEL_Y = 370; -static const int16 MEA_PROCESS_LABEL_WIDTH = 150; -static const int16 MEA_PROCESS_LABEL_HEIGHT = 80; -static const int16 MEASURE_IMAGE_WAITING_X = 114; -static const int16 MEASURE_IMAGE_WAITING_Y = 112; -static const int16 CIRCLE_PROGRESS_POSITION_X = 50; -static const int16 CIRCLE_PROGRESS_POSITION_Y = 52; -static const int16 CIRCLE_PROGRESS_POSITION_WIDTH = 300; -constexpr char *MEA_PROCESS_LABEL_TEXT = (char*)"正在测试"; - -TempMeaProcess::TempMeaProcess() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMeaProcess::TempMeaProcess"); - g_tempMeaProcess = this; -} - -TempMeaProcess::~TempMeaProcess() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMeaProcess::~TempMeaProcess"); - RemoveAll(); - if (tempCircle != nullptr) { - delete tempCircle; - tempCircle = nullptr; - } - if (imageMeasure != nullptr) { - delete imageMeasure; - imageMeasure = nullptr; - } - if (tempLabel != nullptr) { - delete tempLabel; - tempLabel = nullptr; - } - g_tempMeaProcess = nullptr; -} - -TempMeaProcess *TempMeaProcess::GetInstance(void) -{ - return g_tempMeaProcess; -} - -bool TempMeaProcess::TempCirCleProcess() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMeaProcess::TempCirCleProcess"); - tempCircle = new UICircleProgress(); - if (tempCircle == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMeaProcess::TempCirCleProcess new tempCircle fail"); - return false; - } - tempCircle->SetPosition(CIRCLE_PROGRESS_POSITION_X, CIRCLE_PROGRESS_POSITION_Y, - CIRCLE_PROGRESS_POSITION_WIDTH, CIRCLE_PROGRESS_POSITION_WIDTH); - tempCircle->SetCenterPosition(CIRCLE_PROGRESS_CENTER_X, CIRCLE_PROGRESS_CENTER_Y); - tempCircle->SetRadius(MEA_CIRCLE_RADIUS); - tempCircle->SetValue(MEA_CIRCLE_VALUE); - tempCircle->SetBackgroundStyle(STYLE_LINE_WIDTH, - tempCircle->GetBackgroundStyle(STYLE_LINE_WIDTH) + MEA_CIRCLE_PROGRESS_WIDTH); - tempCircle->SetForegroundStyle(STYLE_LINE_WIDTH, - tempCircle->GetForegroundStyle(STYLE_LINE_WIDTH) + MEA_CIRCLE_PROGRESS_WIDTH); - tempCircle->SetStyle(STYLE_PADDING_LEFT, MEA_CIRCLE_PROGRESS_LEFT); - tempCircle->SetStyle(STYLE_PADDING_TOP, MEA_CIRCLE_PROGRESS_TOP); - tempCircle->SetStartAngle(MEA_CIRCLE_PROGRESS_STARTANGLE); - tempCircle->SetEndAngle(MEA_CIRCLE_PROGRESS_ENDANGLE); - tempCircle->SetLineColor(Color::Gray()); - Add(tempCircle); - return true; -} - -bool TempMeaProcess::TempInitImage(void) -{ - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::TempPresenter::GetInstance(); - - imageMeasure = new UIImageView(); - if (imageMeasure == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMeaProcess::InitMeasure new image fail"); - return false; - } - imageMeasure->SetPosition(MEASURE_PROCESS_IMAGE_X, MEASURE_PROCESS_IMAGE_Y, - MEASURE_PROCESS_WIDTH, MEASURE_PROCESS_WIDTH); - imageMeasure->SetSrc(TEMP_MEASURE); - imageMeasure->SetViewId(TEMP_MEASURE_IMAGE); - imageMeasure->SetOnClickListener(clickListener); - Add(imageMeasure); - - return true; -} - -bool TempMeaProcess::TempInitLabel(void) -{ - tempLabel = new UILabel(); - if (tempLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMeaProcess::InitMeasure new label fail"); - return false; - } - tempLabel->SetText(MEA_PROCESS_LABEL_TEXT); - tempLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, MEA_PROCESS_LABEL_FONT); - tempLabel->SetPosition(MEA_PROCESS_LABEL_X, MEA_PROCESS_LABEL_Y, MEA_PROCESS_LABEL_WIDTH, - MEA_PROCESS_LABEL_HEIGHT); - Add(tempLabel); - return true; -} - -UICircleProgress *TempMeaProcess::GetCircleProgress() -{ - return tempCircle; -} - -bool TempMeaProcess::GetCircleStatus(void) -{ - return circleStatus; -} - -void TempMeaProcess::SetCircleStatus(bool status) -{ - circleStatus = status; -} - -bool TempMeaProcess::InitMeaProcess(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMeaProcess::InitMeaProcess"); - SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - if (TempPresenter::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMeaProcess::InitMeaProcess TempPresenter::GetInstance() nullptr"); - return false; - } - UIView::OnDragListener *listener = static_cast(TempPresenter::GetInstance()); - SetOnDragListener(listener); - SetViewId(TEMP_MEASURE_PROCESS); - SetDraggable(true); - SetTouchable(true); - - if (!TempInitImage()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMeaProcess::InitMeaProcess TempInitImage() false"); - return false; - } - if (!TempInitLabel()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMeaProcess::InitMeaProcess TempInitLabel() false"); - return false; - } - if (!TempCirCleProcess()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMeaProcess::InitMeaProcess TempCirCleProcess() false"); - return false; - } - - return true; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempMeasure.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempMeasure.cpp deleted file mode 100644 index 2ea184b71..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempMeasure.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#include "UiConfig.h" -#include -#include "temperature/TempMeasure.h" - -namespace OHOS { -static TempMeasure *g_tempMeasure = nullptr; - -static const char *MEASURE_TITLE = (char*)"体温"; -static const char *MEASURE_BUTTON = (char*)"测量"; -static const int16 MEASURE_TITLE_FONT = 40; -static const int16 MEASURE_BUTTON_FONT = 35; -static const int16 MEASURE_TITLE_X = 185; -static const int16 MEASURE_TITLE_Y = 30; -static const int16 MEASURE_TITLE_WIDTH = 155; -static const int16 MEASURE_TITLE_HEIGHT = 155; -static const int16 MEASURE_IMAGE_X = 130; -static const int16 MEASURE_IMAGE_Y = 126; -static const int16 MEASURE_IMAGE_WAITING_X = 114; -static const int16 MEASURE_IMAGE_WAITING_Y = 111; -static const int16 BACKGROUND_IMAGE_X = 135; -static const int16 BACKGROUND_IMAGE_Y = 125; -static const int16 MEASURE_WIDTH = 80; -static const int16 MEASURE_DROP_WIDTH = 45; -static const int16 MEASURE_DROP_X = 200; -static const int16 MEASURE_DROP_Y = 415; -static const int16 MEASURE_BUTTON_X = 110; -static const int16 MEASURE_BUTTON_Y = 340; -static const int16 MEASURE_BUTTON_WIDTH = 220; -static const int16 MEASURE_BUTTON_HEIGHT = 80; -static const int16 TEMP_IMAGE_MAX = 2; -static const int16 TEMP_IMAGE_Y = 35; -static const int16 TEMP_COLD_IMAGE_X = 120; -static const int16 TEMP_HOT_IMAGE_X = 275; -static const int16 TEMP_IMAGE_WIDTH = 60; -static const int16 TEMP_IMAGE_HEIGHT = 58; - -TempMeasure::TempMeasure() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMeasure::TempMeasure"); - g_tempMeasure = this; -} - -TempMeasure::~TempMeasure() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMeasure::~TempMeasure"); - RemoveAll(); - int numMeasure; - if (labelMeasure != nullptr) { - delete labelMeasure; - labelMeasure = nullptr; - } - if (buttonMeasure != nullptr) { - delete buttonMeasure; - buttonMeasure = nullptr; - } - if (backgroudButton != nullptr) { - delete backgroudButton; - backgroudButton = nullptr; - } - for (numMeasure = SET_ZERO; numMeasure < SET_THREE; numMeasure++) { - if (imageMeasure[numMeasure] != nullptr) { - delete imageMeasure[numMeasure]; - imageMeasure[numMeasure] = nullptr; - } - } - g_tempMeasure = nullptr; -} - -TempMeasure *TempMeasure::GetInstance(void) -{ - return g_tempMeasure; -} - -bool TempMeasure::TempInitImage(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMeasure::TempInitImage"); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::TempPresenter::GetInstance(); - imageMeasure[SET_ZERO] = new UIImageView(); - if (imageMeasure[SET_ZERO] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMeasure::InitMeasure new image fail"); - return false; - } - imageMeasure[SET_ZERO]->SetPosition(MEASURE_IMAGE_X, MEASURE_IMAGE_Y, MEASURE_WIDTH, MEASURE_WIDTH); - imageMeasure[SET_ZERO]->SetSrc(TEMP_MEASURE); - imageMeasure[SET_ZERO]->SetViewId(TEMP_MEASURE_IMAGE); - imageMeasure[SET_ZERO]->SetTouchable(true); - imageMeasure[SET_ZERO]->SetOnClickListener(clickListener); - Add(imageMeasure[SET_ZERO]); - - imageMeasure[SET_ONE] = new UIImageView(); - if (imageMeasure[SET_ONE] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMeasure::InitMeasure new image fail"); - return false; - } - imageMeasure[SET_ONE]->SetPosition(MEASURE_DROP_X, MEASURE_DROP_Y, MEASURE_DROP_WIDTH, MEASURE_DROP_WIDTH); - imageMeasure[SET_ONE]->SetSrc(TEMP_UP_DROP); - Add(imageMeasure[SET_ONE]); - - imageMeasure[SET_TWO] = new UIImageView(); - if (imageMeasure[SET_TWO] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMeasure::InitMeasure new image fail"); - return false; - } - imageMeasure[SET_TWO]->SetPosition(MEASURE_IMAGE_WAITING_X, MEASURE_IMAGE_WAITING_Y); - imageMeasure[SET_TWO]->SetSrc(TEMP_WAITING); - Add(imageMeasure[SET_TWO]); - - return true; -} - -bool TempMeasure::TempInitLabel(void) -{ - labelMeasure = new UILabel(); - if (labelMeasure == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMeasure::InitMeasure new label fail"); - return false; - } - labelMeasure->SetText(MEASURE_TITLE); - labelMeasure->SetFont(DEFAULT_VECTOR_FONT_FILENAME, MEASURE_TITLE_FONT); - labelMeasure->SetPosition(MEASURE_TITLE_X, MEASURE_TITLE_Y, MEASURE_TITLE_WIDTH, MEASURE_TITLE_HEIGHT); - Add(labelMeasure); - - return true; -} - -bool TempMeasure::TempInitButton(void) -{ - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::TempPresenter::GetInstance(); - buttonMeasure = new UILabelButton(); - if (buttonMeasure == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMeasure::InitMeasure new label fail"); - return false; - } - buttonMeasure->SetPosition(MEASURE_BUTTON_X, MEASURE_BUTTON_Y, MEASURE_BUTTON_WIDTH, MEASURE_BUTTON_HEIGHT); - buttonMeasure->SetText(MEASURE_BUTTON); - buttonMeasure->SetFont(DEFAULT_VECTOR_FONT_FILENAME, MEASURE_BUTTON_FONT); - buttonMeasure->SetViewId(TEMP_MEASURE_BUTTON); - buttonMeasure->SetTextColor(OHOS::TempPresenter::GetInstance()->CyanColor()); - buttonMeasure->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::Gray().full, UIButton::RELEASED); - buttonMeasure->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::Gray().full, UIButton::PRESSED); - buttonMeasure->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::Gray().full, UIButton::INACTIVE); - buttonMeasure->SetOnClickListener(clickListener); - Add(buttonMeasure); - - return true; -} - -bool TempMeasure::InitView(void *caller) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempMeasure::InitView"); - UNUSED(caller); - if (TempPresenter::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMeasure::InitView TempPresenter::GetInstance() nullptr"); - return false; - } - UIView::OnDragListener *listener = static_cast(TempPresenter::GetInstance()); - SetDraggable(true); - SetTouchable(true); - SetOnDragListener(listener); - - if (!TempInitLabel()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMeasure::InitView TempInitLabel() false"); - return false; - } - if (!TempInitButton()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMeasure::InitView TempInitButton() false"); - return false; - } - if (!TempInitImage()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempMeasure::InitView TempInitImage() false"); - return false; - } - return true; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempModel.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempModel.cpp deleted file mode 100644 index 2078ffda7..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempModel.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#include "temperature/TempModel.h" -#include "UiConfig.h" -#include "temperature/TempModel.h" - -namespace OHOS { -TempModel::TempModel() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempModel::TempModel"); -} - -TempModel::~TempModel() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempModel::~TempModel"); -} - -TempModel *TempModel::GetInstance(void) -{ - static TempModel tempModel; - return &tempModel; -} - -void TempModel::SetTempInterLis(int16 interListen) -{ - tempInterLis = interListen; -} - -int16 TempModel::GetTempInterLis(void) -{ - return tempInterLis; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempPresenter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempPresenter.cpp deleted file mode 100644 index 9b9a81898..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempPresenter.cpp +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#include "temperature/TempPresenter.h" -#include "temperature/TempMainView.h" -#include "ChangeSliceListener.h" -#include "graphic_service.h" -#include "uiservice/ui_service.h" -#include "string" -#include "iostream" -#include "sstream" -#include "NativeRegisterManager.h" - -namespace OHOS { - -REGIST_MENU(VIEW_MAIN_TEMP, TempMainView, TempPresenter, PNG_APPLIST_TEMP_IMAGE, PNG_APPLIST_DEFAULT_IMG, "体温"); - -static TempPresenter *g_tempPresenter = nullptr; - -ColorType TempPresenter::CyanColor() -{ - return Color::GetColorFromRGB(0x1C, 0xF4, 0xED); -} - -TempPresenter::TempPresenter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter new"); - g_tempPresenter = this; -} - -TempPresenter::~TempPresenter() -{ - g_tempPresenter = nullptr; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter::~TempPresenter"); -} - -TempPresenter *TempPresenter::GetInstance() -{ - return g_tempPresenter; -} - -void TempPresenter::OnResume(void) -{ - SendMsgToUIService(UI_ADD_SLEEP_VETO, 0, nullptr, 0); -} - -void TempPresenter::OnStop(void) -{ - SendMsgToUIService(UI_RM_SLEEP_VETO, 0, nullptr, 0); -} - -bool TempPresenter::OnDrag(UIView& view, const DragEvent& event) -{ - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { - if (TempMainView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempPresenter::OnDrag TempMainView::GetInstance() nullptr"); - return false; - } - TempMainView::GetInstance()->DropView(view); - } - return true; -} - -void TempPresenter::ProgressNotify(void) -{ - if (TempMeaProcess::GetInstance() == nullptr) { - return; - } - if (TempMeaProcess::GetInstance()->GetCircleStatus() && - TempMeaProcess::GetInstance()->GetCircleProgress() != nullptr) { - if (countTemp > 0) { - GraphicService::GetInstance()->PostGraphicEvent(std::bind(&TempPresenter::UpdateTempCount, this)); - } else { - TempMeaProcess::GetInstance()->SetCircleStatus(false); - if (TempMainView::GetInstance() != nullptr) { - TempMainView::GetInstance()->ChangeView(MEASURE_ING, MEASURE_INIT); - } - SetTempCountMax(); - } - } - return; -} - -void TempPresenter::SetTempCountMax(void) -{ - countTemp = SET_HUNDRED; -} - -void TempPresenter::UpdateTempCount(void) -{ - if (TempMeaProcess::GetInstance() != nullptr) { - TempMeaProcess::GetInstance()->GetCircleProgress()->SetValue(countTemp); - } - countTemp--; -} - -void TempPresenter::ClickTempJoin(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickTempJoin start"); - if (TempMainView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickTempJoin TempMainView::GetInstance() nullptr"); - return; - } - TempMainView::GetInstance()->ChangeView(JOIN_STUDY_INTER, MEASURE_INTER); - return; -} - -void TempPresenter::ClickPromptWear(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickPromptWear start"); - if (TempMainView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickPromptWear TempMainView::GetInstance() nullptr"); - return; - } - TempMainView::GetInstance()->ChangeView(MEASURE_INTER, PROMPT_WEAR); - return; -} - -void TempPresenter::ClickPromptNext(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickPromptWear start"); - if (TempMainView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickPromptNext TempMainView::GetInstance() nullptr"); - return; - } - TempMainView::GetInstance()->ChangeView(PROMPT_WEAR, CLICK_MEA); - return; -} - -void TempPresenter::ClickExitMea(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickExitMea start"); - if (TempMainView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickExitMea TempMainView::GetInstance() nullptr"); - return; - } - TempMainView::GetInstance()->ChangeView(CLICK_MEA, MEASURE_INTER); - return; -} - -void TempPresenter::ClickIfWear(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickIfWear start"); - if (TempMainView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickIfWear TempMainView::GetInstance() nullptr"); - return; - } - if (wearListen == 0) { - TempMainView::GetInstance()->ChangeView(CLICK_MEA, MEASURE_ING); - } else { - TempMainView::GetInstance()->ChangeView(CLICK_MEA, REMIND_WEAR); - } - return; -} - -void TempPresenter::ClickMeaAgain(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickMeaAgain start"); - if (TempMainView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickMeaAgain TempMainView::GetInstance() nullptr"); - return; - } - TempMainView::GetInstance()->ChangeView(MEASURE_INIT, MEASURE_ING); - return; -} - -void TempPresenter::ClickMeasure(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickMeasure start"); - if (TempMainView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickMeasure TempMainView::GetInstance() nullptr"); - return; - } - TempMainView::GetInstance()->ChangeView(CLICK_MEA, MEASURE_ING); - return; -} - -void TempPresenter::ClickTempTip(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickTempTip start"); - if (TempMainView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickTempTip TempMainView::GetInstance() nullptr"); - return; - } - TempMainView::GetInstance()->ChangeView(MEASURE_INTER, TEMP_TIP); - return; -} - -void TempPresenter::ClickTempExit(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickTempExit start"); - if (TempMainView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickTempExit TempMainView::GetInstance() nullptr"); - return; - } - int theView = TempMainView::GetInstance()->GetWhichInter(); - if (theView != MEASURE_INTER && theView != MEASURE_INIT) { - theView = MEASURE_INIT; - } - TempMainView::GetInstance()->ChangeView(theView, TEMP_EXIT_STUDY); - return; -} - -void TempPresenter::ClickStudyTip(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickStudyTip start"); - if (TempMainView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickStudyTip TempMainView::GetInstance() nullptr"); - return; - } - int theView = TempMainView::GetInstance()->GetWhichInter(); - if (theView != MEASURE_INTER && theView != MEASURE_INIT) { - theView = MEASURE_INIT; - } - TempMainView::GetInstance()->ChangeView(theView, TEMP_STUDY); - return; -} - -void TempPresenter::ClickWarnBack(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickWarnBack start"); - if (TempMainView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickStudyTip TempMainView::GetInstance() nullptr"); - return; - } - TempMainView::GetInstance()->ChangeView(TEMP_WARN_INTER, MEASURE_INTER); - return; -} - -void TempPresenter::ClickExitDelete(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickExitDelete start"); - if (TempMainView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickExitDelete TempMainView::GetInstance() nullptr"); - return; - } - TempMainView::GetInstance()->ChangeView(TEMP_EXIT_STUDY, TempMainView::GetInstance()->GetListenInter()); - return; -} - -void TempPresenter::ClickExit(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickExit start"); - uint16 preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(preSlice); - if (TempModel::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempModel::GetInstance null error!"); - return; - } - TempModel::GetInstance()->SetTempInterLis(0); - return; -} - -void TempPresenter::ClickExitTemp(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickExitTemp start"); - uint16 preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(preSlice); - return; -} - -int8 TempPresenter::GetTempListen(void) -{ - return tempListen; -} - -struct TempPresentMapper1 { - const char *viewId; - void (TempPresenter::*func)(void); -}; - -static const TempPresentMapper1 PresentMapper[] = { - {TEMP_INTER_EXIT, &TempPresenter::ClickExitTemp}, - {TEMP_INTER_JOIN, &TempPresenter::ClickTempJoin}, - {TEMP_MEASURE_IMAGE, &TempPresenter::ClickPromptWear}, - {TEMP_MEASURE_BUTTON, &TempPresenter::ClickPromptWear}, - {TEMP_PROMPT_NEXT, &TempPresenter::ClickPromptNext}, - {TEMP_MEA_EXIT, &TempPresenter::ClickExitMea}, - {TEMP_MEA_IN, &TempPresenter::ClickIfWear}, - {TEMP_MEA_AGAIN, &TempPresenter::ClickMeaAgain}, - {TEMP_IMAGE_LIT_TIP, &TempPresenter::ClickTempTip}, - {TEMP_EXIT_THIS, &TempPresenter::ClickTempExit}, - {TEMP_STUDY_THIS, &TempPresenter::ClickStudyTip}, - {TEMP_WARN_ID, &TempPresenter::ClickWarnBack}, - {TEMP_EXIT_DELETE, &TempPresenter::ClickExitDelete}, - {TEMP_EXIT_TRUE, &TempPresenter::ClickExit}, -}; - -bool TempPresenter::ClickFuncId(const char *buttonName) -{ - if (buttonName == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickFuncId buttonName nullptr error!"); - return false; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter::ClickFuncId buttonName = %s", buttonName); - for (uint16 i = 0; i < sizeof(PresentMapper) / sizeof(PresentMapper[0]); i++) { - if (strcmp(buttonName, PresentMapper[i].viewId) == 0) { - (this->*(PresentMapper[i].func))(); - return true; - } - } - return false; -} - -bool TempPresenter::OnClick(UIView &view, const ClickEvent &event) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter::OnClick "); - UNUSED(event); - ClickFuncId(view.GetViewId()); - return true; -} - -void TempPresenter::OnSwipe(UISwipeView &view) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter::OnSwipe "); - UNUSED(view); - return; -} - -void TempPresenter::Notify(void) -{ - ProgressNotify(); - return; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempPromptWear.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempPromptWear.cpp deleted file mode 100644 index 856e77275..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempPromptWear.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#include "UiConfig.h" -#include -#include "temperature/TempPromptWear.h" - -namespace OHOS { -static TempPromptWear *g_tempPromptWear = nullptr; - -static const int16 PROMPT_LABEL_X = 45; -static const int16 PROMPT_LABEL_Y = 180; -static const int16 PROMPT_LABEL_WIDTH = 350; -static const int16 PROMPT_LABEL_HEIGHT = 200; -static const int16 PROMPT_LABEL_BUTTON_X = 63; -static const int16 PROMPT_LABEL_BUTTON_Y = 366; -static const int16 PROMPT_IMAGE_X = 120; -static const int16 PROMPT_IMAGE_Y = 70; -static const int16 PROMPT_BUTTON_WIDHT = 320; -static const int16 PROMPT_BUTTON_HEIGHT = 101; -static const int16 PROMPT_LABEL_FONT = 35; -static const char *PROMPT_WEAR_LABEL = (char*)"为确保测量准确,建议偏紧佩戴,并保持佩戴10分钟以上再测量"; -static const char *PROMPT_BUTTON_LABEL = (char*)"下一步"; - -TempPromptWear::TempPromptWear() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPromptWear::TempPromptWear"); - g_tempPromptWear = this; -} - -TempPromptWear::~TempPromptWear() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPromptWear::~TempPromptWear"); - RemoveAll(); - if (tempLabel != nullptr) { - delete tempLabel; - tempLabel = nullptr; - } - if (tempButton != nullptr) { - delete tempButton; - tempButton = nullptr; - } - if (tempImage != nullptr) { - delete tempImage; - tempImage = nullptr; - } - g_tempPromptWear = nullptr; -} - -TempPromptWear *TempPromptWear::GetInstance(void) -{ - return g_tempPromptWear; -} - -bool TempPromptWear::TempInitLabel(void) -{ - tempLabel = new UILabel(); - if (tempLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempPromptWear::TempInitLabel new tempLabel fail"); - return false; - } - tempLabel->SetPosition(PROMPT_LABEL_X, PROMPT_LABEL_Y, PROMPT_LABEL_WIDTH, PROMPT_LABEL_HEIGHT); - tempLabel->SetText(PROMPT_WEAR_LABEL); - tempLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, PROMPT_LABEL_FONT); - Add(tempLabel); - - return true; -} - -bool TempPromptWear::TempInitButton(void) -{ - tempButton = new UILabelButton(); - if (tempButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempPromptWear::InitMeasure new tempButton fail"); - return false; - } - tempButton->SetPosition(PROMPT_LABEL_BUTTON_X, PROMPT_LABEL_BUTTON_Y, PROMPT_BUTTON_WIDHT, PROMPT_BUTTON_HEIGHT); - tempButton->SetText(PROMPT_BUTTON_LABEL); - tempButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, PROMPT_LABEL_FONT); - tempButton->SetViewId(TEMP_PROMPT_NEXT); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::TempPresenter::GetInstance(); - tempButton->SetOnClickListener(clickListener); - tempButton->SetTextColor(OHOS::TempPresenter::GetInstance()->CyanColor()); - tempButton->SetImageSrc(PNG_NEW_DEVICE, PNG_NEW_DEVICE); - Add(tempButton); - - return true; -} - -bool TempPromptWear::TempInitImage(void) -{ - tempImage = new UIImageView(); - if (tempImage == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempPromptWear::InitMeasure new UIImageView fail"); - return false; - } - tempImage->SetPosition(PROMPT_IMAGE_X, PROMPT_IMAGE_Y); // 30 : offset - tempImage->SetSrc(TEMP_ICON_ENTER); - Add(tempImage); - - return true; -} - -bool TempPromptWear::InitPromptWear(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPromptWear::InitPromptWear"); - SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);\ - if (TempPresenter::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempPromptWear::InitPromptWear TempPresenter::GetInstance() nullptr"); - return false; - } - UIView::OnDragListener *listener = static_cast(TempPresenter::GetInstance()); - SetOnDragListener(listener); - SetDraggable(true); - SetTouchable(true); - - if (!TempInitLabel()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempPromptWear::InitPromptWear TempInitLabel() fail"); - return false; - } - if (!TempInitButton()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempPromptWear::InitPromptWear TempInitButton() fail"); - return false; - } - if (!TempInitImage()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempPromptWear::InitPromptWear TempInitImage() fail"); - return false; - } - return true; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempRemindWear.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempRemindWear.cpp deleted file mode 100644 index b44a8289c..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempRemindWear.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#include "UiConfig.h" -#include -#include "temperature/TempRemindWear.h" - -namespace OHOS { -static TempRemindWear *g_tempRemindWear = nullptr; - -static const int16 REMIND_BACKGROUND_X = 180; -static const int16 REMIND_BACKGROUND_Y = 350; -static const int16 REMIND_WEAR_IMAGE_X = 120; -static const int16 REMIND_WEAR_IMAGE_WIDTH = 100; -static const int16 REMIND_ROTATE_X = 180; -static const int16 REMIND_ROTATE_Y = 345; -static const int16 REMIND_WEAR_IMAGE_Y = 70; -static const int16 REMIND_LABEL_X = 105; -static const int16 REMIND_LABEL_Y = 200; -static const int16 REMIND_LABEL_WIDTH = 350; -static const int16 REMIND_LABEL_HEIGHT = 200; -static const int16 REMIND_LABEL_FONT = 35; -static const char *REMIND_WEAR_LABEL = (char*)"请佩戴手表测量"; - -TempRemindWear::TempRemindWear() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempRemindWear::TempRemindWear"); - g_tempRemindWear = this; -} - -TempRemindWear::~TempRemindWear() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempRemindWear::~TempRemindWear"); - RemoveAll(); - int num; - if (tempLabel != nullptr) { - delete tempLabel; - tempLabel = nullptr; - } - for (num = 0; num < SET_TWO; num++) { - if (tempImage[num] != nullptr) { - delete tempImage[num]; - tempImage[num] = nullptr; - } - } - g_tempRemindWear = nullptr; -} - -TempRemindWear *TempRemindWear::GetInstance(void) -{ - return g_tempRemindWear; -} - -bool TempRemindWear::TempInitImage(void) -{ - tempImage[0] = new UIImageView(); - if (tempImage[0] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempRemindWear::InitRemindWear new tempImage[0] fail"); - return false; - } - tempImage[0]->SetPosition(REMIND_WEAR_IMAGE_X, REMIND_WEAR_IMAGE_Y); - tempImage[0]->SetSrc(TEMP_ICON_ENTER); - Add(tempImage[0]); - - tempImage[1] = new UIImageView(); - if (tempImage[1] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempRemindWear::InitRemindWear new tempImage[1] fail"); - return false; - } - tempImage[1]->SetPosition(REMIND_ROTATE_X, REMIND_ROTATE_Y); - tempImage[1]->SetSrc(TEMP_ROTATE); - Add(tempImage[1]); - - return true; -} - -bool TempRemindWear::TempInitLabel(void) -{ - tempLabel = new UILabel(); - if (tempLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempRemindWear::InitPromptWear new tempLabel fail"); - return false; - } - tempLabel->SetPosition(REMIND_LABEL_X, REMIND_LABEL_Y, REMIND_LABEL_WIDTH, REMIND_LABEL_HEIGHT); - tempLabel->SetText(REMIND_WEAR_LABEL); - tempLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, REMIND_LABEL_FONT); - Add(tempLabel); - - return true; -} - -bool TempRemindWear::InitRemindWear(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempRemindWear::InitRemindWear"); - SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - SetThrowDrag(true); - if (TempPresenter::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempRemindWear::InitRemindWear TempPresenter::GetInstance() nullptr"); - return false; - } - UIView::OnDragListener *listener = static_cast(TempPresenter::GetInstance()); - SetOnDragListener(listener); - SetDraggable(true); - SetTouchable(true); - - if (!TempInitImage()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempRemindWear::InitRemindWear TempInitImage() false"); - return false; - } - if (!TempInitLabel()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempRemindWear::InitRemindWear TempInitLabel() false"); - return false; - } - - return true; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempReport.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempReport.cpp deleted file mode 100644 index 2f7166d3c..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempReport.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#include "UiConfig.h" -#include "layout/grid_layout.h" -#include "font/ui_font.h" -#include -#include "temperature/TempReport.h" - -namespace OHOS { -static TempReport *g_tempReport = nullptr; - -static const int16 TEMP_LABEL_ONE_X = 170; -static const int16 TEMP_LABEL_ONE_Y = 30; -static const int16 TEMP_LABEL_ONE_WIDTH = 100; -static const int16 TEMP_LABEL_ONE_HEIGHT = 55; -static const int16 TEMP_LABEL_TWO_X = 180; -static const int16 TEMP_LABEL_TWO_Y = 90; -static const int16 TEMP_LABEL_TWO_WIDTH = 130; -static const int16 TEMP_LABEL_TWO_HEIGHT = 35; -static const int16 TEMP_LABEL_THREE_X = 150; -static const int16 TEMP_LABEL_THREE_Y = 270; -static const int16 TEMP_LABEL_THREE_WIDTH = 90; -static const int16 TEMP_LABEL_THREE_HEIGHT = 40; -static const int16 TEMP_LABEL_FOUR_X = 260; -static const int16 TEMP_LABEL_FIVE_X = 60; -static const int16 TEMP_LABEL_FIVE_Y = 320; -static const int16 TEMP_LABEL_FIVE_WIDTH = 300; -static const int16 TEMP_LABEL_FIVE_HEIGHT = 60; -static const int16 TEMP_LABEL_SIX_X = 190; -static const int16 TEMP_LABEL_SIX_Y = 385; -static const int16 TEMP_LABEL_SIX_WIDTH = 80; -static const int16 TEMP_LABEL_SIX_HEIGHT = 40; -static const int16 TEMP_IMAGE_ONE_X = 70; -static const int16 TEMP_IMAGE_ONE_Y = 30; -static const int16 TEMP_IMAGE_TWO_X = 275; -static const int16 TEMP_IMAGE_TWO_Y = 50; -static const int16 TEMP_IMAGE_THREE_X = 117; -static const int16 TEMP_IMAGE_THREE_Y = 273; -static const int16 TEMP_IMAGE_FOUR_X = 230; -static const int16 TEMP_FOUR_X = 40; -static const int16 TEMP_IMAGE_FOUR_Y = 120; -static const int16 TEMP_TITLE_FONT = 50; -static const int16 TEMP_LABEL_FONT = 35; -static const int16 TEMP_TIP_FONT = 30; -static const int16 TEMP_LITTLE_TIP_FONT = 25; -static const char *TEMP_LABEL_FIVE_TEXT = (char *)"可能受佩带松紧、环境冷热等影响,测量结果仅供参考"; -static const char *TEMP_LABEL_SIX_TEXT = (char *)"测量"; -static const char *TEMP_NUMBERS = (char *)"36.5"; -static const char *TEMP_TIME_TIP = (char *)"1分钟前"; - -TempReport::TempReport() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempReport::TempReport"); - g_tempReport = this; -} - -TempReport::~TempReport() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempReport::~TempReport"); - RemoveAll(); - for (int16_t labelNum = 0; labelNum < TEMP_SET_SIX; labelNum++) { - if (tempLabel[labelNum] != nullptr) { - delete tempLabel[labelNum]; - tempLabel[labelNum] = nullptr; - } - } - for (int16_t imageNum = 0; imageNum < SET_FIVE; imageNum++) { - if (tempImage[imageNum] != nullptr) { - delete tempImage[imageNum]; - tempImage[imageNum] = nullptr; - } - } - g_tempReport = nullptr; -} - -TempReport *TempReport::GetInstance(void) -{ - return g_tempReport; -} - -typedef struct { - int16 labelNum; - int16 x; - int16 y; - int16 width; - int16 height; - char* name; - int16 font; - const char* text; -} TempReportItem; - -static const TempReportItem tempReportItem[] = { - {SET_ZERO, TEMP_LABEL_ONE_X, TEMP_LABEL_ONE_Y, TEMP_LABEL_ONE_WIDTH, TEMP_LABEL_ONE_HEIGHT, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_TITLE_FONT, TEMP_NUMBERS}, - {SET_ONE, TEMP_LABEL_TWO_X, TEMP_LABEL_TWO_Y, TEMP_LABEL_TWO_WIDTH, TEMP_LABEL_TWO_HEIGHT, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_TIP_FONT, TEMP_TIME_TIP}, - {SET_TWO, TEMP_LABEL_THREE_X, TEMP_LABEL_THREE_Y, TEMP_LABEL_THREE_WIDTH, TEMP_LABEL_THREE_HEIGHT, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_LABEL_FONT, TEMP_NUMBERS}, - {SET_THREE, TEMP_LABEL_FOUR_X, TEMP_LABEL_THREE_Y, TEMP_LABEL_THREE_WIDTH, TEMP_LABEL_THREE_HEIGHT, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_LABEL_FONT, TEMP_NUMBERS}, - {SET_FOUR, TEMP_LABEL_FIVE_X, TEMP_LABEL_FIVE_Y, TEMP_LABEL_FIVE_WIDTH, TEMP_LABEL_FIVE_HEIGHT, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_LITTLE_TIP_FONT, TEMP_LABEL_FIVE_TEXT}, - {SET_FIVE, TEMP_LABEL_SIX_X, TEMP_LABEL_SIX_Y, TEMP_LABEL_SIX_WIDTH, TEMP_LABEL_SIX_HEIGHT, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_LABEL_FONT, TEMP_LABEL_SIX_TEXT}, -}; - -bool TempReport::SetBasicLabel(void) -{ - for (int num = 0; num <= SET_FIVE; num++) { - tempLabel[tempReportItem[num].labelNum] = new UILabel(); - if (tempLabel[tempReportItem[num].labelNum] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempReport::InitLittleTip new tempLabel[%d] fail", - tempReportItem[num].labelNum); - return false; - } - tempLabel[tempReportItem[num].labelNum]->SetPosition(tempReportItem[num].x, tempReportItem[num].y, - tempReportItem[num].width, tempReportItem[num].height); - tempLabel[tempReportItem[num].labelNum]->SetFont(tempReportItem[num].name, tempReportItem[num].font); - tempLabel[tempReportItem[num].labelNum]->SetText(tempReportItem[num].text); - Add(tempLabel[tempReportItem[num].labelNum]); - } - return true; -} - -bool TempReport::SetAppendLabel(void) -{ - if (tempLabel[SET_FOUR] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempReport::SetAppendLabel new tempLabel[SET_FOUR] fail"); - return false; - } - tempLabel[SET_FOUR]->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - tempLabel[SET_FOUR]->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - tempLabel[SET_FIVE]->SetTextColor(TempPresenter::GetInstance()->CyanColor()); - - return true; -} - -bool TempReport::InitSimilarImage(int16 num, int16 tempX, int16 tempY, const char* imageSrc) -{ - tempImage[num] = new UIImageView(); - if (tempImage[num] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempReport::InitSimilarImage new tempImage[%d] fail", num); - return false; - } - tempImage[num]->SetPosition(tempX, tempY); - tempImage[num]->SetSrc(imageSrc); - Add(tempImage[num]); - - return true; -} - -bool TempReport::TempInitImage(void) -{ - if (!InitSimilarImage(SET_ZERO, TEMP_IMAGE_ONE_X, TEMP_IMAGE_ONE_Y, TEMP_LITTLE_MEASURE)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempReport::TempReport InitSimilarImage false"); - return false; - } - if (!InitSimilarImage(SET_ONE, TEMP_IMAGE_TWO_X, TEMP_IMAGE_TWO_Y, TEMP_LIT_TIP)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempReport::TempReport InitSimilarImage false"); - return false; - } - if (!InitSimilarImage(SET_TWO, TEMP_IMAGE_THREE_X, TEMP_IMAGE_THREE_Y, TEMP_POINT)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempReport::TempReport InitSimilarImage false"); - return false; - } - if (!InitSimilarImage(SET_THREE, TEMP_IMAGE_FOUR_X, TEMP_IMAGE_THREE_Y, TEMP_REV_POINTER)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempReport::TempReport InitSimilarImage false"); - return false; - } - if (!InitSimilarImage(SET_FOUR, TEMP_FOUR_X, TEMP_IMAGE_FOUR_Y, TEMP_REPORT)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempReport::TempReport InitSimilarImage false"); - return false; - } - - return true; -} - -bool TempReport::InitView(void *caller) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempReport::InitView"); - if (TempPresenter::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempReport::InitView TempPresenter::GetInstance() nullptr"); - return false; - } - UNUSED(caller); - UIView::OnDragListener *listener = static_cast(TempPresenter::GetInstance()); - - SetOnDragListener(listener); - SetDraggable(true); - SetTouchable(true); - - if (!TempInitImage()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempReport::InitView TempInitImage false"); - return false; - } - if (!SetBasicLabel()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempReport::InitView SetBasicLabel false"); - return false; - } - if (!SetAppendLabel()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempReport::InitView SetAppendLabel false"); - return false; - } - return true; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempStudyAbout.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempStudyAbout.cpp deleted file mode 100644 index b1fe71b1a..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempStudyAbout.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#include "UiConfig.h" -#include -#include "temperature/TempStudyAbout.h" - -namespace OHOS { -static TempStudyAbout *g_tempStudyAbout = nullptr; - -static const int16 TEMP_LABEL_ONE_X = 150; -static const int16 TEMP_LABEL_ONE_Y = 50; -static const int16 TEMP_LABEL_ONE_WIDTH = 150; -static const int16 TEMP_LABEL_ONE_HEIGHT = 45; -static const int16 TEMP_LABEL_TWO_X = 45; -static const int16 TEMP_LABEL_TWO_Y = 110; -static const int16 TEMP_LABEL_TWO_WIDTH = 390; -static const int16 TEMP_LABEL_TWO_HEIGHT = 200; -static const int16 TEMP_LABEL_THREE_Y = 310; -static const int16 TEMP_LABEL_FOUR_Y = 520; -static const int16 LABEL_FOUR_HEIGHT = 310; -static const int16 TEMP_LABEL_FIVE_Y = 843; -static const int16 TEMP_LABEL_FONT = 35; -static const int16 TEMP_LABEL_TIP_FONT = 28; -static const char *TEMP_STUDY_LABEL_ONE = (char *)"关于研究"; -static const char *TEMP_STUDY_LABEL_TWO = (char *)"本功能通过内置温度传感器测量腕部皮肤温度,主要研究腕部皮肤温度和体温的关系"; -static const char *TEMP_STUDY_LABEL_THREE = (char *)"本功能用于18岁以上健康人群测量运动过程,及之后腕部皮肤温度和体温的变化。"; -static const char *TEMP_STUDY_LABEL_FOUR = (char *)"测量需佩戴10分钟以上,且容易受到环境因素影响。目前达不到水银体温计精度,测量结果仅供参考,不作为医疗诊断依据。"; -static const char *TEMP_STUDY_LABEL_FIVE = (char *)"加入研究时间2022/3/84:16:35OPM"; - -TempStudyAbout::TempStudyAbout() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempStudyAbout::TempStudyAbout"); - g_tempStudyAbout = this; -} - -TempStudyAbout::~TempStudyAbout() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempStudyAbout::~TempStudyAbout"); - RemoveAll(); - int8 num; - for (num = SET_ZERO; num < SET_FIVE; num++) { - if (tempLabel[num] != nullptr) { - delete tempLabel[num]; - tempLabel[num] = nullptr; - } - } - g_tempStudyAbout = nullptr; -} - -TempStudyAbout *TempStudyAbout::GetInstance(void) -{ - return g_tempStudyAbout; -} - -typedef struct { - int16 labelNum; - int16 x; - int16 y; - int16 width; - int16 height; - char* name; - int16 font; - const char* text; -} TempStudyItem; - -static const TempStudyItem tempStudyItem[] = { - { SET_ZERO, TEMP_LABEL_ONE_X, TEMP_LABEL_ONE_Y, TEMP_LABEL_ONE_WIDTH, TEMP_LABEL_ONE_HEIGHT, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_LABEL_FONT, TEMP_STUDY_LABEL_ONE }, - { SET_ONE, TEMP_LABEL_TWO_X, TEMP_LABEL_TWO_Y, TEMP_LABEL_TWO_WIDTH, TEMP_LABEL_TWO_HEIGHT, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_LABEL_FONT, TEMP_STUDY_LABEL_TWO }, - { SET_TWO, TEMP_LABEL_TWO_X, TEMP_LABEL_THREE_Y, TEMP_LABEL_TWO_WIDTH, TEMP_LABEL_TWO_HEIGHT, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_LABEL_FONT, TEMP_STUDY_LABEL_THREE }, - { SET_THREE, TEMP_LABEL_TWO_X, TEMP_LABEL_FOUR_Y, TEMP_LABEL_TWO_WIDTH, LABEL_FOUR_HEIGHT, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_LABEL_FONT, TEMP_STUDY_LABEL_FOUR }, - { SET_FOUR, TEMP_LABEL_TWO_X, TEMP_LABEL_FIVE_Y, TEMP_LABEL_TWO_WIDTH, TEMP_LABEL_TWO_HEIGHT, - (char *)DEFAULT_VECTOR_FONT_FILENAME, TEMP_LABEL_TIP_FONT, TEMP_STUDY_LABEL_FIVE }, -}; - -bool TempStudyAbout::SetBasicLabel(void) -{ - for (int num = 0; num <= SET_FOUR; num++) { - tempLabel[tempStudyItem[num].labelNum] = new UILabel(); - if (tempLabel[tempStudyItem[num].labelNum] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempStudyAbout::InitLittleTip new tempLabel[%d] fail", - tempStudyItem[num].labelNum); - return false; - } - tempLabel[tempStudyItem[num].labelNum]->SetPosition(tempStudyItem[num].x, tempStudyItem[num].y, - tempStudyItem[num].width, tempStudyItem[num].height); - tempLabel[tempStudyItem[num].labelNum]->SetFont(tempStudyItem[num].name, tempStudyItem[num].font); - tempLabel[tempStudyItem[num].labelNum]->SetText(tempStudyItem[num].text); - Add(tempLabel[tempStudyItem[num].labelNum]); - } - return true; -} - -bool TempStudyAbout::SetAppendLabel(void) -{ - if (tempLabel[SET_FOUR] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempStudyAbout::SetAppendLabel new tempLabel[SET_FOUR] fail"); - return false; - } - tempLabel[SET_FOUR]->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - tempLabel[SET_FOUR]->SetTextColor(Color::Gray()); - - return true; -} - -bool TempStudyAbout::InitStudyAbout(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempStudyAbout::InitStudyAbout"); - SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - SetThrowDrag(true); - if (TempPresenter::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempStudyAbout::InitStudyAbout TempPresenter::GetInstance() nullptr"); - return false; - } - UIView::OnDragListener *listener = static_cast(TempPresenter::GetInstance()); - SetOnDragListener(listener); - SetHorizontalScrollState(false); - SetScrollBlankSize(50); // 50:font size - SetDraggable(true); - SetTouchable(true); - - if (!SetBasicLabel()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempStudyAbout::InitStudyAbout SetBasicLabel() false"); - return false; - } - if (!SetAppendLabel()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempStudyAbout::InitStudyAbout SetAppendLabel() false"); - return false; - } - return true; -} - -void TempStudyAbout::RefreshStudy(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempStudyAbout::RefreshStudy"); - ScrollBy(0, TEMP_LABEL_ONE_Y - tempLabel[0]->GetY()); -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempWarn.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempWarn.cpp deleted file mode 100644 index 879fd41c3..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/temperature/src/TempWarn.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: temperature - * Author: - * Create: 2022-02-15 - */ - -#include "UiConfig.h" -#include -#include "temperature/TempWarn.h" - -namespace OHOS { -static TempWarn *g_tempWarn = nullptr; - -static const int16 TEMP_WARN_IMAGE_X = 182; -static const int16 TEMP_WARN_IMAGE_Y = 57; -static const int16 TEMP_WARN_BUTTON_X = 63; -static const int16 TEMP_WARN_BUTTON_Y = 366; -static const int16 TEMP_WARN_BUTTON_WIDHT = 320; -static const int16 TEMP_WARN_BUTTON_HEIGHT = 101; -static const int16 TEMP_WARN_LABEL_FONT = 35; -static const int16 TEMP_WARN_LABEL_X = 60; -static const int16 TEMP_WARN_LABEL_Y = 160; -static const int16 TEMP_WARN_LABEL_WIDTH = 350; -static const int16 TEMP_WARN_LABEL_HEIGHT = 200; -static const char *TEMP_WARN_BUTTON_TEXT = (char*)"知道了"; -static const char *TEMP_WARN_COLD_LABEL = (char*)"当前体温温度过低(低于35℃),请检测佩戴状态并做好重复测量"; -static const char *TEMP_WARN_HOT_LABEL = (char*)"当前体温温度过高(高于37.2℃),请检测佩戴状态并做好重复测量"; -static const char *TEMP_WARN_ENVIR = (char*)"检测到手表周围温度波动。可能是受环境变化、高功耗应用、佩戴郭松、手表沾水等影响,请进行相应调整并等待10分钟在进行测量"; - -TempWarn::TempWarn() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempWarn::TempWarn"); - g_tempWarn = this; -} - -TempWarn::~TempWarn() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempWarn::~TempWarn"); - RemoveAll(); - if (tempImage != nullptr) { - delete tempImage; - tempImage = nullptr; - } - if (tempButton != nullptr) { - delete tempButton; - tempButton = nullptr; - } - if (tempLabel != nullptr) { - delete tempLabel; - tempLabel = nullptr; - } - g_tempWarn = nullptr; -} - -TempWarn *TempWarn::GetInstance(void) -{ - return g_tempWarn; -} - -bool TempWarn::TempInitImage(void) -{ - tempImage = new UIImageView(); - if (tempImage == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempWarn::InitRemindWear new tempImage fail"); - return false; - } - tempImage->SetPosition(TEMP_WARN_IMAGE_X, TEMP_WARN_IMAGE_Y); - tempImage->SetSrc(TEMP_WARN); - Add(tempImage); - - return true; -} - -bool TempWarn::TempInitButton(void) -{ - tempButton = new UILabelButton(); - if (tempButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempWarn::InitMeasure new tempButton fail"); - return false; - } - tempButton->SetPosition(TEMP_WARN_BUTTON_X, TEMP_WARN_BUTTON_Y, TEMP_WARN_BUTTON_WIDHT, TEMP_WARN_BUTTON_HEIGHT); - tempButton->SetText(TEMP_WARN_BUTTON_TEXT); - tempButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TEMP_WARN_LABEL_FONT); - tempButton->SetViewId(TEMP_WARN_ID); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::TempPresenter::GetInstance(); - tempButton->SetOnClickListener(clickListener); - tempButton->SetTextColor(OHOS::TempPresenter::GetInstance()->CyanColor()); - tempButton->SetImageSrc(PNG_NEW_DEVICE, PNG_NEW_DEVICE); - Add(tempButton); - - return true; -} - -bool TempWarn::TempInitLabel(void) -{ - tempLabel = new UILabel(); - if (tempLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempWarn::TempInitLabel new tempLabel fail"); - return false; - } - tempLabel->SetPosition(TEMP_WARN_LABEL_X, TEMP_WARN_LABEL_Y, TEMP_WARN_LABEL_WIDTH, TEMP_WARN_LABEL_HEIGHT); - tempLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TEMP_WARN_LABEL_FONT); - tempLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - Add(tempLabel); - - return true; -} - -bool TempWarn::InitTempWarn(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempWarn::InitTempWarn"); - SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - SetThrowDrag(true); - if (TempPresenter::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempWarn::InitTempWarn TempPresenter::GetInstance() nullptr"); - return false; - } - UIView::OnDragListener *listener = static_cast(TempPresenter::GetInstance()); - SetOnDragListener(listener); - SetDraggable(true); - SetTouchable(true); - - if (!TempInitImage()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempWarn::InitTempWarn TempInitImage() false"); - return false; - } - if (!TempInitButton()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempWarn::InitTempWarn TempInitButton() false"); - return false; - } - if (!TempInitLabel()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempWarn::InitTempWarn TempInitLabel() false"); - return false; - } - - return true; -} - -void TempWarn::RefreshTempWarn(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempWarn::RefreshTempWarn"); - if (TempPresenter::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempWarn::RefreshTempWarn GetInstance nullptr"); - return; - } - if (tempLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TempWarn::RefreshTempWarn tempLabel nullptr"); - return; - } - int8 tempListener = TempPresenter::GetInstance()->GetTempListen(); - if (tempListener == 0) { - tempLabel->SetText(TEMP_WARN_COLD_LABEL); - } else if (tempListener == 1) { - tempLabel->SetText(TEMP_WARN_HOT_LABEL); - } else { - tempLabel->SetText(TEMP_WARN_ENVIR); - } - return; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/timers/src/TimerTimingPage.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/timers/src/TimerTimingPage.cpp deleted file mode 100644 index f9da1e9bd..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/timers/src/TimerTimingPage.cpp +++ /dev/null @@ -1,548 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TimerTimingPage - * Create: 2025-06-09 - */ - -#include -#include -#include "timers/TimerTimingPage.h" -#include "ui_test_group.h" -#include "timers/TimerPresenter.h" -#include "wearable_log.h" -#include "timers/TimerView.h" -#include "SlicePageFactory.h" -#include "common/image_cache_manager.h" -#include "pwm.h" -#include "main/LoadImg.h" -#ifdef BUILD_IN_LINUX -#include "localtime.h" -#endif - -namespace OHOS { -static constexpr uint16_t NUM_TEN = 10; -static constexpr uint16_t TIMING_TITLE_POSITION_X = 170; -static constexpr uint16_t TIMING_TITLE_POSITION_Y = 110; -static constexpr uint16_t TIMING_TITLE_SIZE_WIDTH = 114; -static constexpr uint16_t TIMING_TITLE_SIZE_HEIGHT = 38; -static constexpr uint16_t TIMING_TITLE_FONT = 38; -static constexpr uint16_t TIMING_LABEL_CURTIME_XPOS = 199; -static constexpr uint16_t TIMING_LABEL_CURTIME_YPOS = 54; -static constexpr uint16_t TIMING_LABEL_CURTIME_WIDTH = 67; -static constexpr uint16_t TIMING_LABEL_CURTIME_HEIGHT = 24; -static constexpr uint16_t TIMING_LABEL_CURTIME_FONT_SIZE = 24; -static constexpr uint16_t TIMING_START_IMAGE_XPOS = 251; -static constexpr uint16_t TIMING_START_IMAGE_YPOS = 306; -static constexpr uint16_t TIMING_START_IMAGE_SIZE = 96; -static constexpr uint16_t TIMING_RESET_IMAGE_XPOS = 107; -static constexpr uint16_t TIMING_RESET_IMAGE_YPOS = 306; -static constexpr uint16_t TIMING_RESET_IMAGE_SIZE = 96; -static constexpr uint16_t TIMING_TIMER_TIME_XPOS = 85; -static constexpr uint16_t TIMING_TIMER_TIME_YPOS = 182; -static constexpr uint16_t TIMING_TIMER_TIME_WIDTH = 322; -static constexpr uint16_t TIMING_TIMER_TIME_HEIGHT = 90; -static constexpr uint16_t TIMING_TIMER_TIME_FONT_SIZE = 72; -static constexpr uint16_t HOUR_TIME = 3600; -static constexpr uint16_t MIN_TIME = 60; -static constexpr uint16_t TIMING_CIRCLE_LINE_WIDTH = 10; -static constexpr uint16_t TIMING_CIRCLE = 227; -static constexpr uint16_t CIRCLE_RADIUS = 222; -static constexpr uint16_t TIMING_CIRCLE_END = 360; -static constexpr uint32_t TIMING_CIRCLE_RANGE = 100000; -static constexpr uint16_t MAX_SCR_DIS = 1000; -static constexpr uint32_t HOUR_RANGE = 60000; -static constexpr uint16_t TIMING_HAND_POSITION_XPOS = 224; -static constexpr uint16_t TIMING_HAND_POSITION_YPOS = 4; -static constexpr uint16_t TIMING_HAND_CENTER_XPOS = 3; -static constexpr uint16_t TIMING_HAND_CENTER_YPOS = 223; -static constexpr uint16_t TIMING_HAND_WIDTH = 2; -static constexpr uint16_t TIMING_HAND_HEIGHT = 5; - -REGIST_SLICE_PAGE(VIEW_TIMER, TIMER_PAGES::TIMER_TIMING_PAGE, TimerTimingPage, false); - -static std::string GetCurrentTimeStr() -{ - struct tm localTime; - time_t seconds = time(nullptr); - localtime_r(&seconds, &localTime); - std::string currTime; - if (localTime.tm_hour < NUM_TEN) { - currTime += "0"; - } - currTime += std::to_string(localTime.tm_hour) + ":"; - if (localTime.tm_min < NUM_TEN) { - currTime += "0"; - } - currTime += std::to_string(localTime.tm_min); - return currTime; -} - -TimerTimingPage::~TimerTimingPage() -{ - bool ret = ImageCacheManager::GetInstance().UnloadAllInMultiRes(TIMER_IMAGE); - if (ret == false) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UnloadTimerImage fail"); - } - - if (group != nullptr) { - group->RemoveAll(); - delete group; - group = nullptr; - } - - if (sweepClock_ != nullptr) { - sweepClock_->RemoveAll(); - delete sweepClock_; - sweepClock_ = nullptr; - } - - if (dClock != nullptr) { - delete dClock; - dClock = nullptr; - } - - if (title != nullptr) { - delete title; - title = nullptr; - } - - if (timerTime != nullptr) { - delete timerTime; - timerTime = nullptr; - } - - if (reset != nullptr) { - delete reset; - reset = nullptr; - } - - if (start != nullptr) { - delete start; - start = nullptr; - } - - if (circleProgress != nullptr) { - delete circleProgress; - circleProgress = nullptr; - } - - if (currentTime_ != nullptr) { - delete currentTime_; - currentTime_ = nullptr; - } - - if (timeCallback_ != nullptr) { - delete timeCallback_; - timeCallback_ = nullptr; - } - - if (timeAnimator_ != nullptr) { - delete timeAnimator_; - timeAnimator_ = nullptr; - } - - if (callBack_ != nullptr) { - delete callBack_; - callBack_ = nullptr; - } - - if (animator_ != nullptr) { - delete animator_; - animator_ = nullptr; - } - - if (secondHand_ != nullptr) { - delete secondHand_; - secondHand_ = nullptr; - } - - if (backround != nullptr) { - delete backround; - backround = nullptr; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TimerTimingPage::~TimerTimingPage"); -} - -void TimerTimingPage::OnStart(void *data) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TimerTimingPage::OnStart() Start!"); - bool ret = ImageCacheManager::GetInstance().LoadAllInMultiRes(TIMER_IMAGE); - if (ret == false) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LoadTimerImage fail"); - return; - } - if (group == nullptr) { - group = new UIScrollView(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TimerTimingPage::OnStart new group"); - } - group->SetPosition(0, 0, VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); - group->SetThrowDrag(true); - - if (backround == nullptr) { - backround = new UIImageView(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TimerTimingPage::OnStart new backround"); - } - ImageInfo *image = - ImageCacheManager::GetInstance().LoadOneInMultiRes(IMAGE_CONVERTER_TOOL_TIMER_BG, TIMER_IMAGE); - if (image == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TimerTimingPage::OnStart backround source fail"); - return; - } - backround->SetSrc(image); - backround->SetPosition(0, 0, VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); - - if (sweepClock_ == nullptr) { - sweepClock_ = new UISweepClock(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TimerTimingPage::OnStart new sweepClock_"); - } - sweepClock_->SetPosition(0, 0); - sweepClock_->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - sweepClock_->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - - if (secondHand_ == nullptr) { - secondHand_ = new Image(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TimerTimingPage::OnStart new secondHand_"); - } - ImageInfo *second = - ImageCacheManager::GetInstance().LoadOneInMultiRes(IMAGE_CONVERTER_TOOL_TIMER_POINTER, TIMER_IMAGE); - if (second == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TimerTimingPage::OnStart second source fail"); - return; - } - secondHand_->SetSrc(second); - sweepClock_->SetHandImage(UISweepClock::HandType::SECOND_HAND, *secondHand_, - {TIMING_HAND_POSITION_XPOS, TIMING_HAND_POSITION_YPOS}, {TIMING_HAND_CENTER_XPOS, TIMING_HAND_CENTER_YPOS}); - sweepClock_->SetHandLine(UISweepClock::HandType::HOUR_HAND, {TIMING_HAND_POSITION_XPOS, TIMING_HAND_POSITION_YPOS}, - {TIMING_HAND_CENTER_XPOS, TIMING_HAND_CENTER_YPOS}, Color::White(), TIMING_HAND_WIDTH, TIMING_HAND_HEIGHT, - OPA_TRANSPARENT); - sweepClock_->SetHandLine(UISweepClock::HandType::MINUTE_HAND, - {TIMING_HAND_POSITION_XPOS, TIMING_HAND_POSITION_YPOS}, {TIMING_HAND_CENTER_XPOS, TIMING_HAND_CENTER_YPOS}, - Color::White(), TIMING_HAND_WIDTH, TIMING_HAND_HEIGHT, OPA_TRANSPARENT); - - // 标题 - if (title == nullptr) { - title = new UILabel(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TimerTimingPage::OnStart new title"); - } - title->SetPosition(TIMING_TITLE_POSITION_X, TIMING_TITLE_POSITION_Y); - title->Resize(TIMING_TITLE_SIZE_WIDTH, TIMING_TITLE_SIZE_HEIGHT); - title->SetText("计时器"); - title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TIMING_TITLE_FONT); - title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - title->SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE); - title->SetStyle(STYLE_TEXT_COLOR, Color::White().full); - title->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - - if (currentTime_ == nullptr) { - currentTime_ = new UILabel(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TimerTimingPage::OnStart new currentTime_"); - } - currentTime_->SetPosition(TIMING_LABEL_CURTIME_XPOS, TIMING_LABEL_CURTIME_YPOS); - currentTime_->Resize(TIMING_LABEL_CURTIME_WIDTH, TIMING_LABEL_CURTIME_HEIGHT); - currentTime_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TIMING_LABEL_CURTIME_FONT_SIZE); - currentTime_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - currentTime_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - currentTime_->SetVisible(true); - - group->Add(backround); - CircleProgress(); - group->Add(sweepClock_); - CreateButton(); - CreateTimerTime(); - group->Add(title); - group->Add(currentTime_); - group->SetOnDragListener(this); - AddViewToPageContainer(group); - - if (timeCallback_ == nullptr) { - timeCallback_ = new TimeAnimatorCallback(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TimerTimingPage::OnStart new timeCallback_"); - } - - if (timeAnimator_ == nullptr) { - timeAnimator_ = new Animator(timeCallback_, currentTime_, 0, true); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TimerTimingPage::OnStart new Animator timeAnimator_"); - } - timeAnimator_->Start(); -} - -void TimerTimingPage::OnResume() -{ - if (TimerModel::GetInstance().GetExistTimer()) { - SetAnimatorStatus(true); - TimerModel::GetInstance().SetExistTimer(false); - } - if (timeAnimator_ != nullptr) { - if (timeAnimator_->GetState() == Animator::STOP) { - timeAnimator_->Start(); - } - } - if (!start->IsTouchable()) { - LOADIMG::LoadImageViewImg(start, TIMER_IMAGE, IMAGE_CONVERTER_TOOL_TIMER_PAUSE); - } -} - -void TimerTimingPage::OnPause() -{ - if (TimerModel::GetInstance().GetIsTiming()) { - TimerModel::GetInstance().SetExistTimer(true); - } - if (timeAnimator_ != nullptr) { - if (timeAnimator_->GetState() != Animator::STOP) { - timeAnimator_->Stop(); - } - } - SetAnimatorStatus(false); -} - -void TimerTimingPage::CreateButton() -{ - ImageInfo *image1 = ImageCacheManager::GetInstance().LoadOneInMultiRes( - IMAGE_CONVERTER_TOOL_TIMER_PLAY, TIMER_IMAGE); - ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes( - IMAGE_CONVERTER_TOOL_TIMER_EXIT, TIMER_IMAGE); - // 开始/暂停按钮 - if (start == nullptr) { - start = new UIImageView(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TimerTimingPage::CreateButton new start"); - } - start->SetPosition(TIMING_START_IMAGE_XPOS, TIMING_START_IMAGE_YPOS); - start->Resize(TIMING_START_IMAGE_SIZE, TIMING_START_IMAGE_SIZE); - start->SetViewId(START_PAUSE); - start->SetTouchable(true); - start->SetOnClickListener(this); - start->SetSrc(image1); - group->Add(start); - - // 复位按钮 - ImageInfo *image2 = ImageCacheManager::GetInstance().LoadOneInMultiRes( - IMAGE_CONVERTER_TOOL_TIMER_EXIT, TIMER_IMAGE); - if (reset == nullptr) { - reset = new UIImageView(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TimerTimingPage::CreateButton new reset"); - } - reset->SetPosition(TIMING_RESET_IMAGE_XPOS, TIMING_RESET_IMAGE_YPOS); - reset->Resize(TIMING_RESET_IMAGE_SIZE, TIMING_RESET_IMAGE_SIZE); - reset->SetViewId(RESET); - reset->SetTouchable(true); - reset->SetOnClickListener(this); - reset->SetSrc(image2); - group->Add(reset); -} - -void TimerTimingPage::CreateTimerTime() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TimerTimingPage::CreateTimerTime() Start!"); - if (timerTime == nullptr) { - timerTime = new UIDigitalClock(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TimerTimingPage::CreateTimerTime() new timerTime!"); - } - timerTime->SetPosition(TIMING_TIMER_TIME_XPOS, TIMING_TIMER_TIME_YPOS); - timerTime->Resize(TIMING_TIMER_TIME_WIDTH, TIMING_TIMER_TIME_HEIGHT); - timerTime->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TIMING_TIMER_TIME_FONT_SIZE); - timerTime->SetDisplayMode(UIDigitalClock::DISPLAY_24_HOUR); - timerTime->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full); - uint32_t durationTime = TimerModel::GetInstance().GetDurationTime(); - uint8_t hour = durationTime / HOUR_TIME; - uint8_t minute = durationTime % HOUR_TIME / MIN_TIME; - uint8_t second = durationTime % MIN_TIME; - timerTime->SetTime24Hour(hour, minute, second); - group->Add(timerTime); -} - -void TimerTimingPage::CircleProgress() -{ - // 动态计时圈 - if (circleProgress == nullptr) { - circleProgress = new UICircleProgress(); - } - circleProgress->SetPosition(0, 0); // widget's left position and top position - circleProgress->Resize(RESOLUTION_WIDTH, RESOLUTION_HEIGHT); // widget's width and height - ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes( - IMAGE_CONVERTER_TOOL_BG_CIR, TIMER_IMAGE); - ImageInfo *image1 = ImageCacheManager::GetInstance().LoadOneInMultiRes( - IMAGE_CONVERTER_TOOL_TIMER_PBG, TIMER_IMAGE); - circleProgress->SetImage(image1, image); - circleProgress->EnableBackground(true); - circleProgress->SetBackgroundStyle(STYLE_LINE_WIDTH, TIMING_CIRCLE_LINE_WIDTH); - circleProgress->SetForegroundStyle(STYLE_LINE_WIDTH, TIMING_CIRCLE_LINE_WIDTH); - circleProgress->EnableBackground(true); - circleProgress->SetCenterPosition(TIMING_CIRCLE, TIMING_CIRCLE); - circleProgress->SetRadius(CIRCLE_RADIUS); - circleProgress->SetStartAngle(0); - circleProgress->SetEndAngle(TIMING_CIRCLE_END); - circleProgress->SetRange(TIMING_CIRCLE_RANGE, 0); - circleProgress->SetValue(TIMING_CIRCLE_RANGE); - // Add to rootView - SetupAnimator(); - group->Add(circleProgress); -} - -// 单位为毫秒计算 -void TimerTimingPage::SetTimerTime(uint32_t onTime) -{ - uint64_t time = onTime / MAX_SCR_DIS; - uint8_t hour = time / HOUR_TIME; - uint8_t minute = time % HOUR_TIME / MIN_TIME; - uint8_t second = time % MIN_TIME; - timerTime->SetTime24Hour(hour, minute, second); - uint32_t totalTime = TimerModel::GetInstance().GetDurationTime(); - double percentage = static_cast(onTime) / (totalTime * MAX_SCR_DIS); - double value = round(percentage * TIMING_CIRCLE_RANGE); - circleProgress->SetValue(value); - sweepClock_->SetSweepTime24Hour(0, 0, percentage * HOUR_RANGE); - - if (onTime <= 0) { - ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes( - IMAGE_CONVERTER_TOOL_TIMER_PAUSE, TIMER_IMAGE); - ImageInfo *image1 = ImageCacheManager::GetInstance().LoadOneInMultiRes( - IMAGE_CONVERTER_TOOL_TIMER_EXIT, TIMER_IMAGE); - start->SetSrc(image); - start->SetTouchable(false); - reset->SetSrc(image1); - TimerModel::GetInstance().SetIsPause(false); - TimerModel::GetInstance().SetIsTiming(false); - start->Invalidate(); - reset->Invalidate(); - } - circleProgress->Invalidate(); - timerTime->Invalidate(); -} - -void TimerTimingPage::SetupAnimator() -{ - callBack_ = new TimerTimingCallback(this); - animator_ = new Animator(callBack_, nullptr, 0, true); -} - -void TimerTimingPage::TimerTimingCallback::Callback(UIView *view) -{ - (void)view; - static int count = 0; - struct timeval current_time; - gettimeofday(¤t_time, nullptr); - - uint32_t overTime = TimerModel::GetInstance().GetDurationTime(); - uint32_t s_time = TimerModel::GetInstance().GetStartTime(); - uint32_t saveTime = TimerModel::GetInstance().GetSaveTime(); - uint64_t c_time = current_time.tv_sec * MAX_SCR_DIS + current_time.tv_usec / MAX_SCR_DIS; - int32_t remTime = overTime * MAX_SCR_DIS - (c_time - s_time) - saveTime; - - page_->SetTimerTime(remTime); - if (remTime <= 0) { - page_->animator_->Stop(); - page_->SetTimerTime(0); - // 调用pwm接口实现马达震动,客户自实现 - } -} - -void TimerTimingPage::SetAnimatorStatus(bool status) -{ - ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes( - IMAGE_CONVERTER_TOOL_TIMER_PAUSE_ORANGE, TIMER_IMAGE); - ImageInfo *image1 = ImageCacheManager::GetInstance().LoadOneInMultiRes( - IMAGE_CONVERTER_TOOL_TIMER_PLAY, TIMER_IMAGE); - ImageInfo *image2 = ImageCacheManager::GetInstance().LoadOneInMultiRes( - IMAGE_CONVERTER_TOOL_TIMER_RESTART, TIMER_IMAGE); - if (status) { - start->SetSrc(image); - reset->SetSrc(image2); - animator_->Start(); - TimerModel::GetInstance().InitTimer(); - } else { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TimerTimingPage::SetAnimatorStatus status == false"); - animator_->Stop(); - start->SetSrc(image1); - TimerModel::GetInstance().DisableTimer(); - } -} - -bool TimerTimingPage::OnDrag(UIView &view, const DragEvent &event) -{ - UNUSED(view); - if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && - (event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { - if (TimerModel::GetInstance().GetIsTiming()) { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TimerTimingPage::OnDrag ChangeSlice(VIEW_APPLIST)"); - } else { - NativeAbility::GetInstance().SwitchSlice(VIEW_TIMER, TIMER_PAGES::TIMER_MAIN_PAGE); - } - } - return true; -} - -bool TimerTimingPage::OnClick(UIView &view, const ClickEvent &event) -{ - UNUSED(event); - std::string viewId = view.GetViewId(); - if (viewId == RESET) { - if (TimerModel::GetInstance().GetIsTiming()) { - // 停止计时器 修改复位图标 重新将时间复原 - SetAnimatorStatus(false); - TimerModel::GetInstance().SetIsTiming(false); - uint32_t durationTime = TimerModel::GetInstance().GetDurationTime(); - uint8_t hour = durationTime / HOUR_TIME; - uint8_t minute = durationTime % HOUR_TIME / MIN_TIME; - uint8_t second = durationTime % MIN_TIME; - timerTime->SetTime24Hour(hour, minute, second); - TimerModel::GetInstance().SetSaveTime(true, 0); - ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes( - IMAGE_CONVERTER_TOOL_TIMER_EXIT, TIMER_IMAGE); - reset->SetSrc(image); - circleProgress->SetValue(TIMING_CIRCLE_RANGE); - sweepClock_->SetSweepTime24Hour(0, 0, 0); - } else if (! TimerModel::GetInstance().GetIsTiming() && TimerModel::GetInstance().GetIsPause()) { - TimerModel::GetInstance().SetIsTiming(false); - uint32_t durationTime = TimerModel::GetInstance().GetDurationTime(); - uint8_t hour = durationTime / HOUR_TIME; - uint8_t minute = durationTime % HOUR_TIME / MIN_TIME; - uint8_t second = durationTime % MIN_TIME; - timerTime->SetTime24Hour(hour, minute, second); - TimerModel::GetInstance().SetSaveTime(true, 0); - ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes( - IMAGE_CONVERTER_TOOL_TIMER_EXIT, TIMER_IMAGE); - reset->SetSrc(image); - circleProgress->SetValue(TIMING_CIRCLE_RANGE); - sweepClock_->SetSweepTime24Hour(0, 0, 0); - TimerModel::GetInstance().SetIsPause(false); - } else { - NativeAbility::GetInstance().SwitchSlice(VIEW_TIMER, TIMER_PAGES::TIMER_MAIN_PAGE); - } - } else if (viewId == START_PAUSE) { - if (TimerModel::GetInstance().GetIsTiming()) { - SetAnimatorStatus(false); - TimerModel::GetInstance().SetIsTiming(false); - struct timeval current_time; - gettimeofday(¤t_time, nullptr); - uint32_t time = (current_time.tv_sec * MAX_SCR_DIS + current_time.tv_usec / MAX_SCR_DIS) - - TimerModel::GetInstance().GetStartTime(); - TimerModel::GetInstance().SetSaveTime(false, time); - TimerModel::GetInstance().SetIsPause(true); - } else { - SetAnimatorStatus(true); - TimerModel::GetInstance().SetIsTiming(true); - struct timeval current_time; - gettimeofday(¤t_time, nullptr); - uint32_t s_time = current_time.tv_sec * MAX_SCR_DIS + current_time.tv_usec / MAX_SCR_DIS; // 转换成ms - TimerModel::GetInstance().SetStartTime(s_time); - TimerModel::GetInstance().SetIsPause(false); - } - } else { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TimerTimingPage::OnClick"); - return false; - } - return true; -} - -void TimerTimingPage::TimeAnimatorCallback::Callback(UIView *view) -{ - UILabel *timeLabel = dynamic_cast(view); - if (timeLabel == nullptr) { - return; - } - std::string currTime = GetCurrentTimeStr(); - timeLabel->SetText(currTime.c_str()); - timeLabel->Invalidate(); -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/DataView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/DataView.cpp deleted file mode 100644 index 0abd0f6d3..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/DataView.cpp +++ /dev/null @@ -1,363 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: Data View - * Create: 2025-03-22 - */ -#include "training/DataView.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "training/TrainingPresenter.h" - -namespace OHOS { -static constexpr uint16_t TOP_VALUE_LABEL_FONT = 80; -static constexpr uint16_t VALUE_LABEL_FONT = 60; -static constexpr uint16_t UNIT_LABEL_FONT = 30; -static constexpr uint16_t TOP_VALUE_LABEL_X = 164; -static constexpr uint16_t TOP_VALUE_LABEL_Y = 45; -static constexpr uint16_t TOP_VALUE_LABEL_W = 200; -static constexpr uint16_t TOP_VALUE_LABEL_H = 60; -static constexpr uint16_t TOP_UNIT_LABEL_X = 184; -static constexpr uint16_t TOP_UNIT_LABEL_Y = 135; -static constexpr uint16_t TOP_UNIT_LABEL_W = 200; -static constexpr uint16_t TOP_UNIT_LABEL_H = 60; -static constexpr uint16_t LEFT_VALUE_LABEL_X = 52; -static constexpr uint16_t LEFT_VALUE_LABEL_Y = 176; -static constexpr uint16_t LEFT_VALUE_LABEL_W = 200; -static constexpr uint16_t LEFT_VALUE_LABEL_H = 60; -static constexpr uint16_t LEFT_UNIT_LABEL_X = 71; -static constexpr uint16_t LEFT_UNIT_LABEL_Y = 247; -static constexpr uint16_t LEFT_UNIT_LABEL_W = 200; -static constexpr uint16_t LEFT_UNIT_LABEL_H = 60; -static constexpr uint16_t RIGHT_VALUE_LABEL_X = 310; -static constexpr uint16_t RIGHT_VALUE_LABEL_Y = 181; -static constexpr uint16_t RIGHT_VALUE_LABEL_W = 200; -static constexpr uint16_t RIGHT_VALUE_LABEL_H = 60; -static constexpr uint16_t RIGHT_UNIT_LABEL_X = 323; -static constexpr uint16_t RIGHT_UNIT_LABEL_Y = 253; -static constexpr uint16_t RIGHT_UNIT_LABEL_W = 200; -static constexpr uint16_t RIGHT_UNIT_LABEL_H = 60; -static constexpr uint16_t BOTTOM_VALUE_LABEL_X = 113; -static constexpr uint16_t BOTTOM_VALUE_LABEL_Y = 297; -static constexpr uint16_t BOTTOM_VALUE_LABEL_W = 200; -static constexpr uint16_t BOTTOM_VALUE_LABEL_H = 60; -static constexpr uint16_t BOTTOM_UNIT_LABEL_X = 217; -static constexpr uint16_t BOTTOM_UNIT_LABEL_Y = 374; -static constexpr uint16_t BOTTOM_UNIT_LABEL_W = 200; -static constexpr uint16_t BOTTOM_UNIT_LABEL_H = 60; -static constexpr uint16_t SEP_LINE_X = 234; -static constexpr uint16_t SEP_LINE_Y = 181; -static constexpr uint16_t SEP_LINE_W = 4; -static constexpr uint16_t SEP_LINE_H = 85; - -static DataView *g_pDataView{nullptr}; - -DataView::DataView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DataView::DataView"); - g_pDataView = this; -} - -DataView::~DataView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DataView::~DataView"); - if (group != nullptr) { - group->RemoveAll(); - delete group; - group = nullptr; - } - if (backGround != nullptr) { - delete backGround; - backGround = nullptr; - } - if (heartrate != nullptr) { - delete heartrate; - heartrate = nullptr; - } - if (sepLine != nullptr) { - delete sepLine; - sepLine = nullptr; - } - if (topValueLabel != nullptr) { - delete topValueLabel; - topValueLabel = nullptr; - } - if (topUnitLabel != nullptr) { - delete topUnitLabel; - topUnitLabel = nullptr; - } - if (leftValueLabel != nullptr) { - delete leftValueLabel; - leftValueLabel = nullptr; - } - if (leftUnitLabel != nullptr) { - delete leftUnitLabel; - leftUnitLabel = nullptr; - } - if (rightValueLabel != nullptr) { - delete rightValueLabel; - rightValueLabel = nullptr; - } - if (rightUnitLabel != nullptr) { - delete rightUnitLabel; - rightUnitLabel = nullptr; - } - if (bottomValueLabel != nullptr) { - delete bottomValueLabel; - bottomValueLabel = nullptr; - } - if (bottomUnitLabel != nullptr) { - delete bottomUnitLabel; - bottomUnitLabel = nullptr; - } - g_pDataView = nullptr; -} - -DataView *DataView::GetInstance() -{ - return g_pDataView; -} - -void DataView::ShowupBackgroup() -{ - backGround = new UIImageView(); - if (backGround == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "backGroundFirst new fail"); - return; - } - backGround->SetPosition(0, 0); - backGround->SetSrc(PNG_WALK_BACK_GROUND); - group->Add(backGround); -} - -void DataView::ShowupTopView() -{ - // Add Label to App - if (topValueLabel == nullptr) { - topValueLabel = new UILabel(); - } - topValueLabel->SetPosition(TOP_VALUE_LABEL_X, TOP_VALUE_LABEL_Y); - topValueLabel->Resize(TOP_VALUE_LABEL_W, TOP_VALUE_LABEL_H); - - // Set additional property - topValueLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - topValueLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - topValueLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, VALUE_LABEL_FONT); - - // Add to rootView - group->Add(topValueLabel); - - // Add Label to App - if (topUnitLabel == nullptr) { - topUnitLabel = new UILabel(); - } - topUnitLabel->SetPosition(TOP_UNIT_LABEL_X, TOP_UNIT_LABEL_Y); - topUnitLabel->Resize(TOP_UNIT_LABEL_W, TOP_UNIT_LABEL_H); - - // Set additional property - topUnitLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - topUnitLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - topUnitLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, UNIT_LABEL_FONT); - - // Add to rootView - group->Add(topUnitLabel); -} - -void DataView::ShowupLeftView() -{ - // Add Label to App - if (leftValueLabel == nullptr) { - leftValueLabel = new UILabel(); - } - leftValueLabel->SetPosition(LEFT_VALUE_LABEL_X, LEFT_VALUE_LABEL_Y); - leftValueLabel->Resize(LEFT_VALUE_LABEL_W, LEFT_VALUE_LABEL_H); - - // Set additional property - leftValueLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - leftValueLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - leftValueLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, VALUE_LABEL_FONT); - - // Add to rootView - group->Add(leftValueLabel); - - // Add Label to App - if (leftUnitLabel == nullptr) { - leftUnitLabel = new UILabel(); - } - leftUnitLabel->SetPosition(LEFT_UNIT_LABEL_X, LEFT_UNIT_LABEL_Y); - leftUnitLabel->Resize(LEFT_UNIT_LABEL_W, LEFT_UNIT_LABEL_H); - - // Set additional property - leftUnitLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - leftUnitLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - leftUnitLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, UNIT_LABEL_FONT); - - // Add to rootView - group->Add(leftUnitLabel); -} - -void DataView::ShowupRightView() -{ - // Add Label to App - if (rightValueLabel == nullptr) { - rightValueLabel = new UILabel(); - } - rightValueLabel->SetPosition(RIGHT_VALUE_LABEL_X, RIGHT_VALUE_LABEL_Y); - rightValueLabel->Resize(RIGHT_VALUE_LABEL_W, RIGHT_VALUE_LABEL_H); - - // Set additional property - rightValueLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - rightValueLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - rightValueLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, VALUE_LABEL_FONT); - - // Add to rootView - group->Add(rightValueLabel); - - // Add Label to App - if (rightUnitLabel == nullptr) { - rightUnitLabel = new UILabel(); - } - rightUnitLabel->SetPosition(RIGHT_UNIT_LABEL_X, RIGHT_UNIT_LABEL_Y); - rightUnitLabel->Resize(RIGHT_UNIT_LABEL_W, RIGHT_UNIT_LABEL_H); - - // Set additional property - rightUnitLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - rightUnitLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - rightUnitLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, UNIT_LABEL_FONT); - - // Add to rootView - group->Add(rightUnitLabel); -} - -void DataView::ShowupBottomView() -{ - // Add Label to App - if (bottomValueLabel == nullptr) { - bottomValueLabel = new UILabel(); - } - bottomValueLabel->SetPosition(BOTTOM_VALUE_LABEL_X, BOTTOM_VALUE_LABEL_Y); - bottomValueLabel->Resize(BOTTOM_VALUE_LABEL_W, BOTTOM_VALUE_LABEL_H); - - // Set additional property - bottomValueLabel->SetText("00:12:15"); - bottomValueLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - bottomValueLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - bottomValueLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, VALUE_LABEL_FONT); - - // Add to rootView - group->Add(bottomValueLabel); - - // Add Label to App - if (bottomUnitLabel == nullptr) { - bottomUnitLabel = new UILabel(); - } - bottomUnitLabel->SetPosition(BOTTOM_UNIT_LABEL_X, BOTTOM_UNIT_LABEL_Y); - bottomUnitLabel->Resize(BOTTOM_UNIT_LABEL_W, BOTTOM_UNIT_LABEL_H); - - // Set additional property - bottomUnitLabel->SetText("时间"); - bottomUnitLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - bottomUnitLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - bottomUnitLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, UNIT_LABEL_FONT); - - // Add to rootView - group->Add(bottomUnitLabel); -} - -void DataView::ShowupSepLine() -{ - sepLine = new UICanvas(); - if (sepLine == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowupSepLine new fail"); - return; - } - sepLine->SetPosition(SEP_LINE_X, SEP_LINE_Y, SEP_LINE_W, SEP_LINE_H); - sepLine->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full); - sepLine->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - group->Add(sepLine); -} - -UIViewGroup *DataView::InitShowUpView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DataView init"); - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - ShowupBackgroup(); - ShowupTopView(); - ShowupLeftView(); - ShowupRightView(); - ShowupBottomView(); - ShowupSepLine(); - UIView::OnDragListener *trainingDragListener = (UIView::OnDragListener *)OHOS::TrainingPresenter::GetInstance(); - if (trainingDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "trainingDragListener GetInstance fail"); - return nullptr; - } - group->SetOnDragListener(trainingDragListener); - group->SetViewId(DATA_VIEW_ID); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} - -void DataView::UpdateDataViewByType() -{ - uint8_t trainingType = TrainingModel::GetInstance().GetCurTrainingType(); - if (trainingType == TRAINING_TYPE_OUTDOOR_RUNNING) { - topValueLabel->SetText("105"); - topUnitLabel->SetText("心率(次/分钟)"); - leftValueLabel->SetText("00'35\""); - leftUnitLabel->SetText("配速(/km)"); - rightValueLabel->SetText("3.25"); - rightUnitLabel->SetText("距离(km)"); - } else if (trainingType == TRAINING_TYPE_INDOOR_RUNNING) { - topValueLabel->SetText("105"); - topUnitLabel->SetText("心率(次/分钟)"); - leftValueLabel->SetText("00'35\""); - leftUnitLabel->SetText("配速(/km)"); - rightValueLabel->SetText("3.25"); - rightUnitLabel->SetText("距离(km)"); - } else if (trainingType == TRAINING_TYPE_CYCLING) { - topValueLabel->SetText("105"); - topUnitLabel->SetText("心率(次/分钟)"); - leftValueLabel->SetText("00'35\""); - leftUnitLabel->SetText("配速(/km)"); - rightValueLabel->SetText("3.25"); - rightUnitLabel->SetText("距离(km)"); - } else if (trainingType == TRAINING_TYPE_CLIMBING) { - topValueLabel->SetText("198"); - topUnitLabel->SetText("海拔(m)"); - leftValueLabel->SetText("535"); - leftUnitLabel->SetText("累计上升(m)"); - rightValueLabel->SetText("180"); - rightUnitLabel->SetText("累计下降(m)"); - } else if (trainingType == TRAINING_TYPE_INDOOR_SWIMMING) { - topValueLabel->SetText("105"); - topUnitLabel->SetText("心率(次/分钟)"); - leftValueLabel->SetText("235"); - leftUnitLabel->SetText("热量(kcal)"); - rightValueLabel->SetText("125"); - rightUnitLabel->SetText("距离(km)"); - } else if (trainingType == TRAINING_TYPE_OUTDOOR_SWIMMING) { - topValueLabel->SetText("105"); - topUnitLabel->SetText("心率(次/分钟)"); - leftValueLabel->SetText("235"); - leftUnitLabel->SetText("热量(kcal)"); - rightValueLabel->SetText("125"); - rightUnitLabel->SetText("距离(km)"); - } - topValueLabel->Invalidate(); - topUnitLabel->Invalidate(); - leftValueLabel->Invalidate(); - leftUnitLabel->Invalidate(); - rightValueLabel->Invalidate(); - rightUnitLabel->Invalidate(); -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/MenuView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/MenuView.cpp deleted file mode 100644 index e313fd6d2..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/MenuView.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: Menu View - * Create: 2025-03-22 - */ -#include "training/MenuView.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "training/TrainingPresenter.h" - -namespace OHOS { -static constexpr uint16_t TITLI_LABEL_FONT = 50; -static constexpr uint16_t TITLI_LABEL_X = 133; -static constexpr uint16_t TITLI_LABEL_Y = 36; -static constexpr uint16_t TITLI_LABEL_W = 200; -static constexpr uint16_t TITLI_LABEL_H = 60; -static constexpr uint16_t LIST_X = 42; -static constexpr uint16_t LIST_Y = 95; -static constexpr uint16_t LIST_W = 420; -static constexpr uint16_t LIST_H = 305; - -static MenuView *g_pMenuView{nullptr}; - -MenuView::MenuView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MenuView::MenuView"); - g_pMenuView = this; -} - -MenuView::~MenuView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MenuView::~MenuView"); - if (group != nullptr) { - group->RemoveAll(); - delete group; - group = nullptr; - } - if (titleLabel != nullptr) { - delete titleLabel; - titleLabel = nullptr; - } - if (trainingList != nullptr) { - delete trainingList; - trainingList = nullptr; - } - if (listAdapter_ != nullptr) { - delete listAdapter_; - listAdapter_ = nullptr; - } - g_pMenuView = nullptr; -} - -MenuView *MenuView::GetInstance() -{ - return g_pMenuView; -} - -void MenuView::CreateUILabel() -{ - // Add Label to App - if (titleLabel == nullptr) { - titleLabel = new UILabel(); - } - titleLabel->SetPosition(TITLI_LABEL_X, TITLI_LABEL_Y); - titleLabel->Resize(TITLI_LABEL_W, TITLI_LABEL_H); - - // Set additional property - titleLabel->SetText("体能训练"); - titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TITLI_LABEL_FONT); - - // Add to rootView - group->Add(titleLabel); -} - -void MenuView::CreateUIList() -{ - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::TrainingPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener nullptr"); - return; - } - - // Add List to App - if (trainingList == nullptr) { - trainingList = new UIList(); - } - trainingList->SetPosition(LIST_X, LIST_Y); - trainingList->Resize(LIST_W, LIST_H); - - // Set additional property - if (listAdapter_ == nullptr) { - listAdapter_ = new TrainingAdapter(); - } - listAdapter_->SetItemClickListener(clickListener); - std::list trainingItemList(trainings, trainings + TRAINING_TYPE_MAX); - listAdapter_->SetData(trainingItemList); - - trainingList->SetAdapter(listAdapter_); - trainingList->RefreshList(); - - // Add to rootView - group->Add(trainingList); -} - -UIViewGroup *MenuView::InitShowUpView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MenuView init"); - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - CreateUILabel(); - CreateUIList(); - UIView::OnDragListener *trainingDragListener = (UIView::OnDragListener *)OHOS::TrainingPresenter::GetInstance(); - if (trainingDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "trainingDragListener GetInstance fail"); - return nullptr; - } - group->SetOnDragListener(trainingDragListener); - group->SetViewId(MENU_VIEW_ID); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/PauseView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/PauseView.cpp deleted file mode 100644 index 17e343462..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/PauseView.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - */ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Pause View - * Create: 2025-03-22 - */ -#include "training/PauseView.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "training/TrainingPresenter.h" - -namespace OHOS { -static constexpr uint16_t TIME_LABEL_FONT = 30; -static constexpr uint16_t TIME_LABEL_X = 194; -static constexpr uint16_t TIME_LABEL_Y = 42; -static constexpr uint16_t TIME_LABEL_W = 200; -static constexpr uint16_t TIME_LABEL_H = 60; -static constexpr uint16_t TEXT_LABEL_FONT = 70; -static constexpr uint16_t TEXT_LABEL_X = 128; -static constexpr uint16_t TEXT_LABEL_Y = 133; -static constexpr uint16_t TEXT_LABEL_W = 337; -static constexpr uint16_t TEXT_LABEL_H = 152; -static constexpr uint16_t BUTTON_FONT = 40; -static constexpr uint16_t BUTTON_X = 136; -static constexpr uint16_t BUTTON_Y1 = 236; -static constexpr uint16_t BUTTON_Y2 = 329; -static constexpr uint16_t BUTTON_W = 193; -static constexpr uint16_t BUTTON_H = 75; - -#define BUTTON_TEXT_CONTINUE "ç»§ç»­" -#define BUTTON_TEXT_FINISH "结束" - -static PauseView *g_pPauseView{nullptr}; - -PauseView::PauseView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PauseView::PauseView"); - g_pPauseView = this; -} - -PauseView::~PauseView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PauseView::~PauseView"); - if (group != nullptr) { - group->RemoveAll(); - delete group; - group = nullptr; - } - if (timeLabel != nullptr) { - delete timeLabel; - timeLabel = nullptr; - } - if (textLabel != nullptr) { - delete textLabel; - textLabel = nullptr; - } - if (continueButton != nullptr) { - delete continueButton; - continueButton = nullptr; - } - if (finishButton != nullptr) { - delete finishButton; - finishButton = nullptr; - } - g_pPauseView = nullptr; -} - -PauseView *PauseView::GetInstance() -{ - return g_pPauseView; -} - -void PauseView::CreateUILabel() -{ - // Add Label to App - if (timeLabel == nullptr) { - timeLabel = new UILabel(); - } - timeLabel->SetPosition(TIME_LABEL_X, TIME_LABEL_Y); - timeLabel->Resize(TIME_LABEL_W, TIME_LABEL_H); - - // Set additional property - timeLabel->SetText("11:59"); - timeLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - timeLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - timeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TIME_LABEL_FONT); - - // Add to rootView - group->Add(timeLabel); - - // Add Label to App - if (textLabel == nullptr) { - textLabel = new UILabel(); - } - textLabel->SetPosition(TEXT_LABEL_X, TEXT_LABEL_Y); - textLabel->Resize(TEXT_LABEL_W, TEXT_LABEL_H); - - // Set additional property - textLabel->SetText("已暂停"); - textLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - textLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - textLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TEXT_LABEL_FONT); - - // Add to rootView - group->Add(textLabel); -} - -void PauseView::CreateUIButton() -{ - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::TrainingPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener nullptr"); - return; - } - // Add LabelButtonExt to App - if (continueButton == nullptr) { - continueButton = new UILabelButton(); - } - continueButton->SetPosition(BUTTON_X, BUTTON_Y1); - continueButton->Resize(BUTTON_W, BUTTON_H); - continueButton->SetViewId(TRAINING_PAUSE_CONTINUE_BUTTON); - - // Set additional property - continueButton->SetText(BUTTON_TEXT_CONTINUE); - continueButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, BUTTON_FONT); - continueButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - continueButton->SetOnClickListener(clickListener); - - // Add to rootView - group->Add(continueButton); - - // Add LabelButtonExt to App - if (finishButton == nullptr) { - finishButton = new UILabelButton(); - } - finishButton->SetPosition(BUTTON_X, BUTTON_Y2); - finishButton->Resize(BUTTON_W, BUTTON_H); - finishButton->SetViewId(TRAINING_PAUSE_FINISH_BUTTON); - finishButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffbc321e); - - // Set additional property - finishButton->SetText(BUTTON_TEXT_FINISH); - finishButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, BUTTON_FONT); - finishButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - finishButton->SetOnClickListener(clickListener); - - // Add to rootView - group->Add(finishButton); -} - -UIViewGroup *PauseView::InitShowUpView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PauseView init"); - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - CreateUILabel(); - CreateUIButton(); - UIView::OnDragListener *trainingDragListener = (UIView::OnDragListener *)OHOS::TrainingPresenter::GetInstance(); - if (trainingDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "trainingDragListener GetInstance fail"); - return nullptr; - } - group->SetOnDragListener(trainingDragListener); - group->SetViewId(PAUSE_VIEW_ID); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/PrepareView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/PrepareView.cpp deleted file mode 100644 index 1e2e14af0..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/PrepareView.cpp +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: Prepare View - * Create: 2025-03-22 - */ -#include "training/PrepareView.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "training/TrainingPresenter.h" -#include "screensetting/ScreenModels.h" -#include "ui_resource_image.h" - -namespace OHOS { - -static constexpr uint16_t HEARTBEAT_IMAGE_X = 366; -static constexpr uint16_t HEARTBEAT_IMAGE_Y = 165; -static constexpr uint16_t HEARTBEAT_IMAGE_W = 56; -static constexpr uint16_t HEARTBEAT_IMAGE_H = 56; -static constexpr uint16_t HEARTBEAT_IMAGE_NUM = 19; -static constexpr uint16_t HEARTBEAT_DELAY = 50; -static constexpr uint16_t HEARTBEAT_LABEL_X = 363; -static constexpr uint16_t HEARTBEAT_LABEL_Y = 241; -static constexpr uint16_t HEARTBEAT_LABEL_W = 86; -static constexpr uint16_t HEARTBEAT_LABEL_H = 30; -static constexpr uint16_t HEARTBEAT_LABEL_FONT = 30; -static constexpr uint16_t BATTERY_X = 175; -static constexpr uint16_t BATTERY_Y = 84; -static constexpr uint16_t BATTERY_LABEL_FONT = 30; -static constexpr uint16_t BATTERY_LABEL_X = 232; -static constexpr uint16_t BATTERY_LABEL_Y = 75; -static constexpr uint16_t BATTERY_LABEL_W = 86; -static constexpr uint16_t BATTERY_LABEL_H = 30; -static constexpr uint16_t GPS_X = 30; -static constexpr uint16_t GPS_Y = 167; -static constexpr uint16_t GPS_W = 56; -static constexpr uint16_t GPS_H = 56; -static constexpr uint16_t GPS_LABEL_FONT = 30; -static constexpr uint16_t GPS_LABEL_X = 29; -static constexpr uint16_t GPS_LABEL_Y = 227; -static constexpr uint16_t GPS_LABEL_W = 200; -static constexpr uint16_t GPS_LABEL_H = 60; -static constexpr uint16_t TIME_LABEL_FONT = 30; -static constexpr uint16_t TIME_LABEL_X = 177; -static constexpr uint16_t TIME_LABEL_Y = 36; -static constexpr uint16_t TIME_LABEL_W = 100; -static constexpr uint16_t TIME_LABEL_H = 30; -static constexpr uint16_t LOCATING_LABEL_FONT = 25; -static constexpr uint16_t LOCATING_LABEL_X = 127; -static constexpr uint16_t LOCATING_LABEL_Y = 348; -static constexpr uint16_t LOCATING_LABEL_W = 200; -static constexpr uint16_t LOCATING_LABEL_H = 80; -static constexpr uint16_t WALK_BUTTON_X = 138; -static constexpr uint16_t WALK_BUTTON_Y = 136; -static constexpr uint16_t WALK_BUTTON_W = 180; -static constexpr uint16_t WALK_BUTTON_H = 180; -static constexpr uint16_t START_BUTTON_X = 196; -static constexpr uint16_t START_BUTTON_Y = 373; -static constexpr uint16_t START_BUTTON_W = 73; -static constexpr uint16_t START_BUTTON_H = 73; -static constexpr uint16_t START_BUTTON_FONT = 30; - -static PrepareView *g_pPrepareView{nullptr}; - -PrepareView::PrepareView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PrepareView::PrepareView"); - g_pPrepareView = this; -} - -PrepareView::~PrepareView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PrepareView::~PrepareView"); - if (group != nullptr) { - group->RemoveAll(); - delete group; - group = nullptr; - } - if (timeLabel != nullptr) { - delete timeLabel; - timeLabel = nullptr; - } - if (battery != nullptr) { - delete battery; - battery = nullptr; - } - if (batteryLabel != nullptr) { - delete batteryLabel; - batteryLabel = nullptr; - } - if (gpsImageView != nullptr) { - delete gpsImageView; - gpsImageView = nullptr; - } - if (gpsLabel != nullptr) { - delete gpsLabel; - gpsLabel = nullptr; - } - if (heartRateImageView != nullptr) { - delete heartRateImageView; - heartRateImageView = nullptr; - } - if (heartRateLabel != nullptr) { - delete heartRateLabel; - heartRateLabel = nullptr; - } - if (locatingLabel != nullptr) { - delete locatingLabel; - locatingLabel = nullptr; - } - if (startButton != nullptr) { - delete startButton; - startButton = nullptr; - } - if (iconImageView != nullptr) { - delete iconImageView; - iconImageView = nullptr; - } - g_pPrepareView = nullptr; -} - -PrepareView *PrepareView::GetInstance() -{ - return g_pPrepareView; -} - -bool PrepareView::InitTimeLableVIew() -{ - timeLabel = new UILabel(); - if (timeLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "timeLabel new fail"); - return false; - } - timeLabel->SetPosition(TIME_LABEL_X, TIME_LABEL_Y, TIME_LABEL_W, TIME_LABEL_H); - timeLabel->SetText("11:59"); - timeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TIME_LABEL_FONT); - timeLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - timeLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - group->Add(timeLabel); - return true; -} - -bool PrepareView::InitLocatingLableVIew() -{ - locatingLabel = new UILabel(); - if (locatingLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "locatingLabel new fail"); - return false; - } - locatingLabel->SetPosition(LOCATING_LABEL_X, LOCATING_LABEL_Y, LOCATING_LABEL_W, LOCATING_LABEL_H); - locatingLabel->SetText("定位中\n请在空旷处等待"); - locatingLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LOCATING_LABEL_FONT); - locatingLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - locatingLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - group->Add(locatingLabel); - return true; -} - -bool PrepareView::InitBatteryView() // 加载电量 -{ - battery = new UIImageView(); // 电量状态显示 - if (battery == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "battery new fail"); - return false; - } - battery->SetPosition(BATTERY_X, BATTERY_Y); - ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, battery, DROPDOWN_DROPDOWN_BATTERY); - group->Add(battery); - - batteryLabel = new UILabel(); - if (batteryLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryLabel new fail"); - return false; - } - batteryLabel->SetPosition(BATTERY_LABEL_X, BATTERY_LABEL_Y, BATTERY_LABEL_W, BATTERY_LABEL_H); - batteryLabel->SetText("30%"); - batteryLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, BATTERY_LABEL_FONT); - batteryLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - group->Add(batteryLabel); - return true; -} - -bool PrepareView::InitCenterView() -{ - iconImageView = new UIButton(); // 步行状态显示 - if (iconImageView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "iconImageView new fail"); - return false; - } - - iconImageView->SetPosition(WALK_BUTTON_X, WALK_BUTTON_Y, WALK_BUTTON_W, WALK_BUTTON_H); - - group->Add(iconImageView); - return true; -} - -bool PrepareView::InitGPSView() -{ - // Add ImageView to App - if (gpsImageView == nullptr) { - gpsImageView = new UIImageView(); - } - gpsImageView->SetPosition(GPS_X, GPS_Y); - gpsImageView->Resize(GPS_W, GPS_H); - - // Set additional property - - // Add to rootView - group->Add(gpsImageView); - - // Add Label to App - if (gpsLabel == nullptr) { - gpsLabel = new UILabel(); - } - gpsLabel->SetPosition(GPS_LABEL_X, GPS_LABEL_Y); - gpsLabel->Resize(GPS_LABEL_W, GPS_LABEL_H); - - // Set additional property - gpsLabel->SetText("GPS"); - gpsLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - gpsLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - gpsLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, GPS_LABEL_FONT); - - // Add to rootView - group->Add(gpsLabel); - return true; -} - -bool PrepareView::InitHeartrateView() -{ - // Add ImageView to App - if (heartRateImageView == nullptr) { - heartRateImageView = new UIImageView(); - } - heartRateImageView->SetPosition(HEARTBEAT_IMAGE_X, HEARTBEAT_IMAGE_Y); - heartRateImageView->Resize(HEARTBEAT_IMAGE_W, HEARTBEAT_IMAGE_H); - - // Add to rootView - group->Add(heartRateImageView); - - heartRateLabel = new UILabel(); - if (heartRateLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "heartRateLabel new fail"); - return false; - } - heartRateLabel->SetPosition(HEARTBEAT_LABEL_X, HEARTBEAT_LABEL_Y, HEARTBEAT_LABEL_W, HEARTBEAT_LABEL_H); - heartRateLabel->SetText("95"); - heartRateLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, HEARTBEAT_LABEL_FONT); - heartRateLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - group->Add(heartRateLabel); - return true; -} - -bool PrepareView::InitStartButtonView() -{ - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::TrainingPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener nullptr"); - return false; - } - - // Add LabelButtonExt to App - if (startButton == nullptr) { - startButton = new UILabelButton(); - } - startButton->SetPosition(START_BUTTON_X, START_BUTTON_Y); // widget's left position and top position - startButton->Resize(START_BUTTON_W, START_BUTTON_H); // widget's width and height - startButton->SetViewId(TRAINING_PREPARE_START_BUTTON); // Set style - startButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffff1500); - - // Set additional property - startButton->SetText("开始"); - startButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, START_BUTTON_FONT); - startButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - startButton->SetOnClickListener(clickListener); - - // Add to rootView - group->Add(startButton); - return true; -} - -UIViewGroup *PrepareView::InitShowUpView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PrepareView init"); - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - InitTimeLableVIew(); - InitBatteryView(); - // InitLocatingLableVIew(); - InitCenterView(); - InitGPSView(); - InitHeartrateView(); - InitStartButtonView(); - UIView::OnDragListener *trainingDragListener = (UIView::OnDragListener *)OHOS::TrainingPresenter::GetInstance(); - if (trainingDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "trainingDragListener GetInstance fail"); - return nullptr; - } - group->SetOnDragListener(trainingDragListener); - group->SetViewId(PREPARE_VIEW_ID); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} - -void PrepareView::UpdateViewByTrainingType(uint8_t trainingType) -{ - if (trainingType == TRAINING_TYPE_OUTDOOR_RUNNING) { - gpsImageView->SetVisible(true); - gpsLabel->SetVisible(true); - iconImageView->SetImageSrc(PNG_WALK_IMAGE, PNG_WALK_IMAGE); - } else if (trainingType == TRAINING_TYPE_INDOOR_RUNNING) { - gpsImageView->SetVisible(false); - gpsLabel->SetVisible(false); - iconImageView->SetImageSrc(PNG_WALK_IMAGE, PNG_WALK_IMAGE); - } else if (trainingType == TRAINING_TYPE_CYCLING) { - gpsImageView->SetVisible(true); - gpsLabel->SetVisible(true); - iconImageView->SetImageSrc(PNG_WALK_IMAGE, PNG_WALK_IMAGE); - } else if (trainingType == TRAINING_TYPE_CLIMBING) { - gpsImageView->SetVisible(true); - gpsLabel->SetVisible(true); - iconImageView->SetImageSrc(PNG_WALK_IMAGE, PNG_WALK_IMAGE); - } else if (trainingType == TRAINING_TYPE_INDOOR_SWIMMING) { - gpsImageView->SetVisible(false); - gpsLabel->SetVisible(false); - iconImageView->SetImageSrc(PNG_WALK_IMAGE, PNG_WALK_IMAGE); - } else if (trainingType == TRAINING_TYPE_OUTDOOR_SWIMMING) { - gpsImageView->SetVisible(true); - gpsLabel->SetVisible(true); - iconImageView->SetImageSrc(PNG_WALK_IMAGE, PNG_WALK_IMAGE); - } - iconImageView->Invalidate(); - gpsImageView->Invalidate(); - gpsLabel->Invalidate(); -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/PromptView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/PromptView.cpp deleted file mode 100644 index 581a2c555..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/PromptView.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: Prompt View - * Create: 2025-03-22 - */ -#include "training/PromptView.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "training/TrainingPresenter.h" - -namespace OHOS { -static constexpr uint16_t LABELS_X = 65; -static constexpr uint16_t LABELS_Y = 100; -static constexpr uint16_t LABELS_W = 324; -static constexpr uint16_t LABELS_H = 160; -static constexpr uint16_t LABELS_FONT = 35; -static constexpr uint16_t BUTTON_X1 = 85; -static constexpr uint16_t BUTTON_X2 = 279; -static constexpr uint16_t BUTTON_Y = 320; -static constexpr uint16_t BUTTON_W = 90; -static constexpr uint16_t BUTTON_H = 90; -static const char *PROMPT_CONTENT = "本次运动距离过短,不会记录数据。是否结束?"; -static PromptView *g_pPromptView{nullptr}; - -PromptView::PromptView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PromptView::PromptView"); - g_pPromptView = this; -} - -PromptView::~PromptView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PromptView::~PromptView"); - if (group != nullptr) { - group->RemoveAll(); - delete group; - group = nullptr; - } - if (titleLabel != nullptr) { - delete titleLabel; - titleLabel = nullptr; - } - if (cancelButton != nullptr) { - delete cancelButton; - cancelButton = nullptr; - } - if (confirmButton != nullptr) { - delete confirmButton; - confirmButton = nullptr; - } - g_pPromptView = nullptr; -} - -PromptView *PromptView::GetInstance() -{ - return g_pPromptView; -} - -void PromptView::CreateUILabel() -{ - if (titleLabel == nullptr) { - titleLabel = new UILabel(); - if (titleLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PromptView titleLabel new fail"); - return; - } - titleLabel->SetPosition(LABELS_X, LABELS_Y, LABELS_W, LABELS_H); - titleLabel->SetText(PROMPT_CONTENT); - titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABELS_FONT); - titleLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - titleLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - group->Add(titleLabel); - } -} - -void PromptView::CreateUIButton() -{ - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::TrainingPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener nullptr"); - return; - } - - if (cancelButton == nullptr) { - cancelButton = new UIButton(); - if (cancelButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PromptView cancelButton new fail"); - return; - } - cancelButton->SetPosition(BUTTON_X1, BUTTON_Y, BUTTON_W, BUTTON_H); - cancelButton->SetViewId(TRAINING_PROMPT_CANCEL_BUTTON); - cancelButton->SetImageSrc(ALARM_DELETE_ADD_PATH, ALARM_DELETE_ADD_PATH); - cancelButton->SetOnClickListener(clickListener); - group->Add(cancelButton); - } - if (confirmButton == nullptr) { - confirmButton = new UIButton(); - if (confirmButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PromptView confirmButton new fail"); - return; - } - confirmButton->SetPosition(BUTTON_X2, BUTTON_Y, BUTTON_W, BUTTON_H); - confirmButton->SetViewId(TRAINING_PROMPT_CONFIRM_BUTTON); - confirmButton->SetImageSrc(ALARM_TRUE_ADD_PATH, ALARM_TRUE_ADD_PATH); - confirmButton->SetOnClickListener(clickListener); - group->Add(confirmButton); - } -} - -UIViewGroup *PromptView::InitShowUpView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PromptView InitShowUpView"); - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - CreateUILabel(); - CreateUIButton(); - UIView::OnDragListener *trainingDragListener = (UIView::OnDragListener *)OHOS::TrainingPresenter::GetInstance(); - if (trainingDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "trainingDragListener GetInstance fail"); - return nullptr; - } - group->SetOnDragListener(trainingDragListener); - group->SetViewId(PROMPT_VIEW_ID); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TargetAdapter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TargetAdapter.cpp deleted file mode 100644 index a19958b65..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TargetAdapter.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TargetAdapter - * Author: - * Create: 2025-11-23 - */ -#include "training/TargetAdapter.h" -#include "training/TargetItemView.h" - -namespace OHOS { -TargetAdapter::TargetAdapter() {} - -TargetAdapter::~TargetAdapter() -{ - listData_.clear(); -} - -uint16_t TargetAdapter::GetCount(void) -{ - return listData_.size(); -} - -void TargetAdapter::SetData(const std::list &data) -{ - if (!listData_.empty()) { - listData_.clear(); - } - listData_ = data; -} - -UIView *TargetAdapter::GetView(UIView *inView, int16_t index) -{ - if (listData_.empty()) { - return nullptr; - } - if (index < 0) { - return nullptr; - } - size_t uindex = index; - if (uindex >= listData_.size()) { - return nullptr; - } - - std::list::iterator it = listData_.begin(); - for (int i = 0; i < index; i++) { - it++; - } - TargetItem itemData = *it; - TargetItemView *item = nullptr; - if (inView == nullptr) { - item = new TargetItemView(); - } else { - item = static_cast(inView); - } - item->SetItemInfo(itemData); - item->SetOnClickListener(itemClickListener); - return item; -} - -void TargetAdapter::AddListItem(const TargetItem &item) -{ - listData_.push_back(item); -} -} // namespace OHOS diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TargetItemView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TargetItemView.cpp deleted file mode 100644 index 6814bb1b5..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TargetItemView.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TargetItemView - * Author: - * Create: 2025-02-15 - */ - -#include "wearable_log.h" -#include "UiConfig.h" -#include "training/TargetItemView.h" - -namespace OHOS { -static constexpr uint16_t ITEM_X = 0; -static constexpr uint16_t ITEM_Y = 0; -static constexpr uint16_t ITEM_W = 382; -static constexpr uint16_t ITEM_H = 100; -static constexpr uint16_t ICON_X = 0; -static constexpr uint16_t ICON_Y = 0; -static constexpr uint16_t LABEL_X = 100; -static constexpr uint16_t LABEL_Y = 0; -static constexpr uint16_t LABEL_W = 200; -static constexpr uint16_t LABEL_H = 100; -static constexpr uint16_t LABEL_FONT = 35; -static constexpr uint16_t IMAGE_W = 300; -static constexpr uint16_t IMAGE_H = 0; - -TargetItemView::TargetItemView() -{ - InitView(); -} - -TargetItemView::~TargetItemView() -{ - Remove(&sIcon); - Remove(&sLabel); - Remove(&sNextImage); -} - -bool TargetItemView::InitView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TargetItemView::InitView"); - SetPosition(ITEM_X, ITEM_Y, ITEM_W, ITEM_H); - SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY); - SetTouchable(true); - - sIcon.SetPosition(ICON_X, ICON_Y); - sIcon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); - - sLabel.SetPosition(LABEL_X, LABEL_Y); - sLabel.Resize(LABEL_W, LABEL_H); - sLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT); - sLabel.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); - sLabel.SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE); - sLabel.SetStyle(STYLE_TEXT_COLOR, Color::White().full); - sLabel.SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - sLabel.SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - - sNextImage.SetSrc(PNG_SETTING_NEXT_IMAGE); - sNextImage.SetPosition(IMAGE_W, IMAGE_H); - sNextImage.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); - - Add(&sIcon); - Add(&sLabel); - Add(&sNextImage); - return true; -} - -void TargetItemView::SetItemInfo(const TargetItem itemInfo) -{ - sItemInfo = itemInfo; - sIcon.SetSrc(itemInfo.icon); - sLabel.SetText(itemInfo.label); - SetViewId(itemInfo.viewId); -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TargetSettingView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TargetSettingView.cpp deleted file mode 100644 index 1e2eee87c..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TargetSettingView.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TargetSetting View - * Create: 2025-03-22 - */ -#include "training/TargetSettingView.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "training/TrainingPresenter.h" - -namespace OHOS { -static constexpr uint16_t LABELS_X = 153; -static constexpr uint16_t LABELS_Y = 30; -static constexpr uint16_t LABELS_W = 200; -static constexpr uint16_t LABELS_H = 50; -static constexpr uint16_t LABELS_FONT = 40; -static constexpr uint16_t PICKER_X = 160; -static constexpr uint16_t PICKER_Y = 85; -static constexpr uint16_t PICKER_W = 199; -static constexpr uint16_t PICKER_H = 241; -static constexpr uint16_t PICKER_ITEM_H = 50; -static constexpr uint16_t BUTTON_X = 87; -static constexpr uint16_t BUTTON_Y = 351; -static constexpr uint16_t BUTTON_W = 279; -static constexpr uint16_t BUTTON_H = 116; -static constexpr uint16_t BUTTON_FONT = 40; -static constexpr uint8_t BACKGROUND_FONT = 40; -static constexpr uint8_t HIGHTLIGHT_FONT = 50; - -static TargetSettingView *g_pTargetSettingView{nullptr}; - -TargetSettingView::TargetSettingView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TargetSettingView::TargetSettingView"); - g_pTargetSettingView = this; -} - -TargetSettingView::~TargetSettingView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TargetSettingView::~TargetSettingView"); - if (group != nullptr) { - group->RemoveAll(); - delete group; - group = nullptr; - } - if (titleLabel != nullptr) { - delete titleLabel; - titleLabel = nullptr; - } - if (picker != nullptr) { - delete picker; - picker = nullptr; - } - if (confirmButton != nullptr) { - delete confirmButton; - confirmButton = nullptr; - } - g_pTargetSettingView = nullptr; -} - -TargetSettingView *TargetSettingView::GetInstance() -{ - return g_pTargetSettingView; -} - -void TargetSettingView::CreateUILabel() -{ - // Add Label to App - if (titleLabel == nullptr) { - titleLabel = new UILabel(); - } - titleLabel->SetPosition(LABELS_X, LABELS_Y); - titleLabel->Resize(LABELS_W, LABELS_H); - titleLabel->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - - // Set additional property - titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABELS_FONT); - - // Add to rootView - group->Add(titleLabel); -} - -void TargetSettingView::CreateUIPicker() -{ - // Add Picker to App - if (picker == nullptr) { - picker = new UIPicker(); - } - picker->SetPosition(PICKER_X, PICKER_Y); - picker->Resize(PICKER_W, PICKER_H); - picker->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - - // Set additional property - picker->SetItemHeight(PICKER_ITEM_H); - - picker->SetBackgroundFont(DEFAULT_VECTOR_FONT_FILENAME, BACKGROUND_FONT); - picker->SetHighlightFont(DEFAULT_VECTOR_FONT_FILENAME, HIGHTLIGHT_FONT); - - // Add to rootView - group->Add(picker); -} - -void TargetSettingView::CreateUIButton() -{ - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::TrainingPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener nullptr"); - return; - } - - // Add LabelButtonExt to App - if (confirmButton == nullptr) { - confirmButton = new UILabelButton(); - } - confirmButton->SetPosition(BUTTON_X, BUTTON_Y); - confirmButton->Resize(BUTTON_W, BUTTON_H); - confirmButton->SetViewId(TARGET_SETTING_CONFIRM_BUTTON); - confirmButton->SetTouchable(true); - - // Set additional property - confirmButton->SetText("确定"); - confirmButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, BUTTON_FONT); - - confirmButton->SetOnClickListener(clickListener); - - // Add to rootView - group->Add(confirmButton); -} - -UIViewGroup *TargetSettingView::InitShowUpView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TargetSettingView InitShowUpView"); - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - CreateUILabel(); - CreateUIPicker(); - CreateUIButton(); - UIView::OnDragListener *trainingDragListener = (UIView::OnDragListener *)OHOS::TrainingPresenter::GetInstance(); - if (trainingDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "trainingDragListener GetInstance fail"); - return nullptr; - } - group->SetOnDragListener(trainingDragListener); - group->SetViewId(TARGET_SETTING_VIEW_ID); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} - -void TargetSettingView::UpdateViewByTargetType(uint8_t targetType) -{ - if (targetType == TRAINING_TARGET_DISTANCE) { - titleLabel->SetText("距离"); - const char *uiDistanceData[] = {"1km", "3km", "5km", "10km"}; - picker->SetValues(uiDistanceData, sizeof(uiDistanceData) / sizeof(uiDistanceData[0])); - picker->SetTextColor(Color::Gray(), Color::Teal()); - confirmButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Teal().full); - } else if (targetType == TRAINING_TARGET_TIME) { - titleLabel->SetText("时间"); - const char *uiTimeData[] = {"10分钟", "20分钟", "30分钟", "60分钟"}; - picker->SetValues(uiTimeData, sizeof(uiTimeData) / sizeof(uiTimeData[0])); - picker->SetTextColor(Color::Gray(), Color::Orange()); - confirmButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Orange().full); - } else if (targetType == TRAINING_TARGET_CALORIE) { - titleLabel->SetText("热量"); - const char *uiCalorieData[] = {"100千卡", "200千卡", "300千卡", "500千卡", "1000千卡"}; - picker->SetValues(uiCalorieData, sizeof(uiCalorieData) / sizeof(uiCalorieData[0])); - picker->SetTextColor(Color::Gray(), Color::Magenta()); - confirmButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Magenta().full); - } - titleLabel->Invalidate(); - picker->Invalidate(); - confirmButton->Invalidate(); -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TargetView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TargetView.cpp deleted file mode 100644 index 46d55c0d8..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TargetView.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: Target View - * Create: 2025-03-22 - */ -#include "training/TargetView.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "training/TrainingPresenter.h" - -namespace OHOS { -static constexpr uint16_t LABELS_X = 133; -static constexpr uint16_t LABELS_Y = 36; -static constexpr uint16_t LABELS_W = 200; -static constexpr uint16_t LABELS_H = 60; -static constexpr uint16_t LABELS_FONT = 50; -static constexpr uint16_t LIST_X = 42; -static constexpr uint16_t LIST_Y = 95; -static constexpr uint16_t LIST_W = 382; -static constexpr uint16_t LIST_H = 305; - -static TargetView *g_pTargetView{nullptr}; - -TargetView::TargetView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TargetView::TargetView"); - g_pTargetView = this; -} - -TargetView::~TargetView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TargetView::~TargetView"); - if (group != nullptr) { - group->RemoveAll(); - delete group; - group = nullptr; - } - if (titleLabel != nullptr) { - delete titleLabel; - titleLabel = nullptr; - } - if (targetList != nullptr) { - delete targetList; - targetList = nullptr; - } - if (listAdapter_ != nullptr) { - delete listAdapter_; - listAdapter_ = nullptr; - } - g_pTargetView = nullptr; -} - -TargetView *TargetView::GetInstance() -{ - return g_pTargetView; -} - -void TargetView::CreateUILabel() -{ - // Add Label to App - if (titleLabel == nullptr) { - titleLabel = new UILabel(); - } - titleLabel->SetPosition(LABELS_X, LABELS_Y); - titleLabel->Resize(LABELS_W, LABELS_H); - - // Set additional property - titleLabel->SetText("目标"); - titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABELS_FONT); - - // Add to rootView - group->Add(titleLabel); -} - -void TargetView::CreateUIList() -{ - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::TrainingPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener nullptr"); - return; - } - - // Add List to App - if (targetList == nullptr) { - targetList = new UIList(); - } - targetList->SetPosition(LIST_X, LIST_Y); - targetList->Resize(LIST_W, LIST_H); - targetList->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - - // Set additional property - if (listAdapter_ == nullptr) { - listAdapter_ = new TargetAdapter(); - } - listAdapter_->SetItemClickListener(clickListener); - std::list targetItemList(targets, targets + TRAINING_TARGET_MAX); - listAdapter_->SetData(targetItemList); - - targetList->SetAdapter(listAdapter_); - targetList->RefreshList(); - - // Add to rootView - group->Add(targetList); -} - -UIViewGroup *TargetView::InitShowUpView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TargetView InitShowUpView"); - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - CreateUILabel(); - CreateUIList(); - UIView::OnDragListener *trainingDragListener = (UIView::OnDragListener *)OHOS::TrainingPresenter::GetInstance(); - if (trainingDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "trainingDragListener GetInstance fail"); - return nullptr; - } - group->SetOnDragListener(trainingDragListener); - group->SetViewId(TARGET_VIEW_ID); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingAdapter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingAdapter.cpp deleted file mode 100644 index 9ae2d4c94..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingAdapter.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TrainingAdapter.cpp - * Author: - * Create: 2025-11-23 - */ -#include "training/TrainingAdapter.h" -#include "training/TrainingItemView.h" - -namespace OHOS { -TrainingAdapter::TrainingAdapter() {} - -TrainingAdapter::~TrainingAdapter() -{ - listData_.clear(); -} - -uint16_t TrainingAdapter::GetCount(void) -{ - return listData_.size(); -} - -void TrainingAdapter::SetData(const std::list &data) -{ - if (!listData_.empty()) { - listData_.clear(); - } - listData_ = data; -} - -UIView *TrainingAdapter::GetView(UIView *inView, int16_t index) -{ - if (listData_.empty()) { - return nullptr; - } - if (index < 0) { - return nullptr; - } - size_t uindex = index; - if (uindex >= listData_.size()) { - return nullptr; - } - - std::list::iterator it = listData_.begin(); - for (int i = 0; i < index; i++) { - it++; - } - TrainingItem itemData = *it; - TrainingItemView *item = nullptr; - if (inView == nullptr) { - item = new TrainingItemView(); - } else { - item = static_cast(inView); - } - item->SetItemInfo(itemData); - item->SetOnClickListener(itemClickListener); - return item; -} - -void TrainingAdapter::AddListItem(const TrainingItem &item) -{ - listData_.push_back(item); -} -} // namespace OHOS diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingItemView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingItemView.cpp deleted file mode 100644 index ff03e79b8..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingItemView.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: temperature - * Author: - * Create: 2025-02-15 - */ - -#include "wearable_log.h" -#include "UiConfig.h" -#include "ui_resource_image.h" -#include "training/TrainingItemView.h" -#include "screensetting/ScreenModels.h" - -namespace OHOS { -static constexpr uint16_t ITEM_X = 0; -static constexpr uint16_t ITEM_Y = 0; -static constexpr uint16_t ITEM_W = 382; -static constexpr uint16_t ITEM_H = 100; -static constexpr uint16_t ICON_X = 0; -static constexpr uint16_t ICON_Y = 0; -static constexpr uint16_t LABEL_X = 100; -static constexpr uint16_t LABEL_Y = 0; -static constexpr uint16_t LABEL_W = 200; -static constexpr uint16_t LABEL_H = 100; -static constexpr uint16_t LABEL_FONT = 35; -static constexpr uint16_t IMAGE_W = 300; -static constexpr uint16_t IMAGE_H = 0; - -TrainingItemView::TrainingItemView() -{ - InitView(); -} - -TrainingItemView::~TrainingItemView() -{ - Remove(&sIcon); - Remove(&sLabel); - Remove(&sSettingImage); -} - -bool TrainingItemView::InitView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingItemView::InitView"); - SetPosition(ITEM_X, ITEM_Y, ITEM_W, ITEM_H); - SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY); - SetTouchable(true); - - sIcon.SetPosition(ICON_X, ICON_Y); - sIcon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); - - sLabel.SetPosition(LABEL_X, LABEL_Y); - sLabel.Resize(LABEL_W, LABEL_H); - sLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT); - sLabel.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); - sLabel.SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE); - sLabel.SetStyle(STYLE_TEXT_COLOR, Color::White().full); - sLabel.SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - sLabel.SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - - ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, &sSettingImage, DROPDOWN_DROPDOWN_SETTING); - sSettingImage.SetPosition(IMAGE_W, IMAGE_H); - sSettingImage.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); - - Add(&sIcon); - Add(&sLabel); - Add(&sSettingImage); - return true; -} - -void TrainingItemView::SetItemInfo(const TrainingItem itemInfo) -{ - sItemInfo = itemInfo; - sIcon.SetSrc(itemInfo.icon); - sLabel.SetText(itemInfo.label); - SetViewId(itemInfo.viewId); -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingModel.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingModel.cpp deleted file mode 100644 index 9efb70247..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingModel.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TrainingModel.cpp - * Author: - * Create: 2025-11-23 - */ - -#include "training/TrainingModel.h" - -namespace OHOS { -TrainingModel::TrainingModel() {} - -TrainingModel::~TrainingModel() {} - -TrainingModel &TrainingModel::GetInstance() -{ - static TrainingModel instance; - return instance; -} - -void TrainingModel::SetCurView(int16_t viewNum) -{ - curView_ = viewNum; -} - -int16_t TrainingModel::GetCurView(void) -{ - return curView_; -} - -void TrainingModel::SetCurTrainingType(int8_t trainingType) -{ - trainingType_ = trainingType; -} - -int8_t TrainingModel::GetCurTrainingType(void) -{ - return trainingType_; -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingPresenter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingPresenter.cpp deleted file mode 100644 index 5c34aa19f..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingPresenter.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: SettingPresenter.cpp - * Author: - * Create: 2025-11-23 - */ - -#include "training/TrainingModel.h" -#include "training/TrainingPresenter.h" -#include "NativeRegisterManager.h" -namespace OHOS { - -REGIST_MENU(VIEW_TRAINING, TrainingView, TrainingPresenter, PNG_APPLIST_WALK_IMAGE, PNG_APPLIST_DEFAULT_IMG, - "体能训练"); - -static TrainingPresenter *g_trainingPresenter = nullptr; -TrainingPresenter::TrainingPresenter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingPresenter::TrainingPresenter"); - trainingModel_ = &TrainingModel::GetInstance(); - g_trainingPresenter = this; -} - -TrainingPresenter::~TrainingPresenter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingPresenter::~TrainingPresenter"); - g_trainingPresenter = nullptr; -} - -TrainingPresenter *TrainingPresenter::GetInstance(void) -{ - return g_trainingPresenter; -} - -void TrainingPresenter::OnResume(void) -{ - Presenter::OnResume(); -} - -void TrainingPresenter::OnPause(void) -{ - Presenter::OnPause(); - return; -} - -void TrainingPresenter::ClickStartButton(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingPresenter::OnClick ClickStartButton"); - view_->ChangeView(TRAINING_VIEW_PREPARE, TRAINING_VIEW_DATA); - DataView::GetInstance()->UpdateDataViewByType(); -} - -void TrainingPresenter::ClickCountineButton(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingPresenter::OnClick ClickCountineButton"); - view_->ChangeView(TRAINING_VIEW_PAUSE, TRAINING_VIEW_DATA); - DataView::GetInstance()->UpdateDataViewByType(); -} - -void TrainingPresenter::ClickFinishButton(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingPresenter::OnClick ClickFinishButton"); - view_->ChangeView(TRAINING_VIEW_PAUSE, TRAINING_VIEW_PROMPT); -} - -void TrainingPresenter::ClickCancelButton(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingPresenter::OnClick ClickCancelButton"); - view_->ChangeView(TRAINING_VIEW_PROMPT, TRAINING_VIEW_PAUSE); -} - -void TrainingPresenter::ClickConfirmButton(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingPresenter::OnClick ClickConfirmButton"); - view_->ChangeView(TRAINING_VIEW_PROMPT, TRAINING_VIEW_MENU); -} - -void TrainingPresenter::TrainingSetting(uint8_t trainingType) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingPresenter::OnClick TrainingSetting, type = %d", trainingType); - view_->ChangeView(TRAINING_VIEW_MENU, TRAINING_VIEW_SETTING); -} - -void TrainingPresenter::StartTraining(uint8_t trainingType) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingPresenter::OnClick TrainingSetting, type = %d", trainingType); - view_->ChangeView(TRAINING_VIEW_MENU, TRAINING_VIEW_PREPARE); - trainingModel_->SetCurTrainingType(trainingType); - PrepareView::GetInstance()->UpdateViewByTrainingType(trainingType); -} - -void TrainingPresenter::EnterTarget(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingPresenter::OnClick EnterTarget"); - view_->ChangeView(TRAINING_VIEW_SETTING, TRAINING_VIEW_TARGET); -} - -void TrainingPresenter::SettingTarget(uint8_t targetType) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingPresenter::OnClick SettingTarget, type = %d", targetType); - view_->ChangeView(TRAINING_VIEW_TARGET, TRAINING_VIEW_TARGET_SETTING); - TargetSettingView::GetInstance()->UpdateViewByTargetType(targetType); -} - -void TrainingPresenter::ConfirmTargetSetting(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingPresenter::OnClick ConfirmTargetSetting"); - view_->ChangeView(TRAINING_VIEW_TARGET_SETTING, TRAINING_VIEW_SETTING); -} - -bool TrainingPresenter::OnClick(UIView &view, const ClickEvent &event) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingPresent::OnClick view:%s", view.GetViewId()); - bool isSettingClicked = event.GetCurrentPos().x > 350 ? true : false; - if (strcmp(view.GetViewId(), TRAINING_PREPARE_START_BUTTON) == 0) { - ClickStartButton(); - } else if (strcmp(view.GetViewId(), TRAINING_PAUSE_CONTINUE_BUTTON) == 0) { - ClickCountineButton(); - } else if (strcmp(view.GetViewId(), TRAINING_PAUSE_FINISH_BUTTON) == 0) { - ClickFinishButton(); - } else if (strcmp(view.GetViewId(), TRAINING_PROMPT_CANCEL_BUTTON) == 0) { - ClickCancelButton(); - } else if (strcmp(view.GetViewId(), TRAINING_PROMPT_CONFIRM_BUTTON) == 0) { - ClickConfirmButton(); - } else if (strcmp(view.GetViewId(), TRAINING_SETTING_ITEM_TARGET) == 0) { - EnterTarget(); - } else if (strcmp(view.GetViewId(), TRAINING_TARGET_ITEM_DISTANCE) == 0) { - SettingTarget(TRAINING_TARGET_DISTANCE); - } else if (strcmp(view.GetViewId(), TRAINING_TARGET_ITEM_TIME) == 0) { - SettingTarget(TRAINING_TARGET_TIME); - } else if (strcmp(view.GetViewId(), TRAINING_TARGET_ITEM_CALORIE) == 0) { - SettingTarget(TRAINING_TARGET_CALORIE); - } else if (strcmp(view.GetViewId(), TARGET_SETTING_CONFIRM_BUTTON) == 0) { - ConfirmTargetSetting(); - } else if (strcmp(view.GetViewId(), TRAINING_ITEM_OUTDOOR_RUNNING) == 0) { - if (isSettingClicked) { - TrainingSetting(TRAINING_TYPE_OUTDOOR_RUNNING); - } else { - StartTraining(TRAINING_TYPE_OUTDOOR_RUNNING); - } - } else if (strcmp(view.GetViewId(), TRAINING_ITEM_INDOOR_RUNNING) == 0) { - if (isSettingClicked) { - TrainingSetting(TRAINING_TYPE_INDOOR_RUNNING); - } else { - StartTraining(TRAINING_TYPE_INDOOR_RUNNING); - } - } else if (strcmp(view.GetViewId(), TRAINING_ITEM_CYCLING) == 0) { - if (isSettingClicked) { - TrainingSetting(TRAINING_TYPE_CYCLING); - } else { - StartTraining(TRAINING_TYPE_CYCLING); - } - } else if (strcmp(view.GetViewId(), TRAINING_ITEM_CLIMBING) == 0) { - if (isSettingClicked) { - TrainingSetting(TRAINING_TYPE_CLIMBING); - } else { - StartTraining(TRAINING_TYPE_CLIMBING); - } - } else if (strcmp(view.GetViewId(), TRAINING_ITEM_INDOOR_SWIMMING) == 0) { - if (isSettingClicked) { - TrainingSetting(TRAINING_TYPE_INDOOR_SWIMMING); - } else { - StartTraining(TRAINING_TYPE_INDOOR_SWIMMING); - } - } else if (strcmp(view.GetViewId(), TRAINING_ITEM_OUTDOOR_SWIMMING) == 0) { - if (isSettingClicked) { - TrainingSetting(TRAINING_TYPE_OUTDOOR_SWIMMING); - } else { - StartTraining(TRAINING_TYPE_OUTDOOR_SWIMMING); - } - } - return true; -} - -bool TrainingPresenter::OnDrag(UIView &view, const DragEvent &event) -{ - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingOnDragListener::OnDrag"); - if (event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT) { - if (strcmp(view.GetViewId(), MENU_VIEW_ID) == 0) { - // view_->ChangeView(TRAINING_VIEW_MENU, TRAINING_VIEW_PREPARE); - } else if (strcmp(view.GetViewId(), PREPARE_VIEW_ID) == 0) { - // view_->ChangeView(TRAINING_VIEW_PREPARE, TRAINING_VIEW_DATA); - // DataView::GetInstance()->UpdateDataViewByType(); - } else if (strcmp(view.GetViewId(), DATA_VIEW_ID) == 0) { - view_->ChangeView(TRAINING_VIEW_DATA, TRAINING_VIEW_PAUSE); - } else if (strcmp(view.GetViewId(), PAUSE_VIEW_ID) == 0) { - // view_->ChangeView(TRAINING_VIEW_PAUSE, TRAINING_VIEW_PROMPT); - } else if (strcmp(view.GetViewId(), PROMPT_VIEW_ID) == 0) { - // view_->ChangeView(TRAINING_VIEW_PROMPT, TRAINING_VIEW_MENU); - } - } else if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { - if (strcmp(view.GetViewId(), MENU_VIEW_ID) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); - } else if (strcmp(view.GetViewId(), PREPARE_VIEW_ID) == 0) { - view_->ChangeView(TRAINING_VIEW_PREPARE, TRAINING_VIEW_MENU); - } else if (strcmp(view.GetViewId(), DATA_VIEW_ID) == 0) { - view_->ChangeView(TRAINING_VIEW_DATA, TRAINING_VIEW_PREPARE); - } else if (strcmp(view.GetViewId(), PAUSE_VIEW_ID) == 0) { - view_->ChangeView(TRAINING_VIEW_PAUSE, TRAINING_VIEW_DATA); - } else if (strcmp(view.GetViewId(), PROMPT_VIEW_ID) == 0) { - view_->ChangeView(TRAINING_VIEW_PROMPT, TRAINING_VIEW_PAUSE); - } else if (strcmp(view.GetViewId(), SETTING_VIEW_ID) == 0) { - view_->ChangeView(TRAINING_VIEW_SETTING, TRAINING_VIEW_MENU); - } else if (strcmp(view.GetViewId(), TARGET_VIEW_ID) == 0) { - view_->ChangeView(TRAINING_VIEW_TARGET, TRAINING_VIEW_SETTING); - } else if (strcmp(view.GetViewId(), TARGET_SETTING_VIEW_ID) == 0) { - view_->ChangeView(TRAINING_VIEW_TARGET_SETTING, TRAINING_VIEW_TARGET); - } - } - return false; -} - -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingSettingAdapter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingSettingAdapter.cpp deleted file mode 100644 index f7fa89945..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingSettingAdapter.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TrainingSettingAdapter.cpp - * Author: - * Create: 2025-11-23 - */ -#include "training/TrainingSettingAdapter.h" -#include "training/TrainingSettingItemView.h" - -namespace OHOS { -TrainingSettingAdapter::TrainingSettingAdapter() {} - -TrainingSettingAdapter::~TrainingSettingAdapter() -{ - listData_.clear(); -} - -uint16_t TrainingSettingAdapter::GetCount(void) -{ - return listData_.size(); -} - -void TrainingSettingAdapter::SetData(const std::list &data) -{ - if (!listData_.empty()) { - listData_.clear(); - } - listData_ = data; -} - -UIView *TrainingSettingAdapter::GetView(UIView *inView, int16_t index) -{ - if (listData_.empty()) { - return nullptr; - } - if (index < 0) { - return nullptr; - } - size_t uindex = index; - if (uindex >= listData_.size()) { - return nullptr; - } - - std::list::iterator it = listData_.begin(); - for (int i = 0; i < index; i++) { - it++; - } - TrainingSettingItem itemData = *it; - TrainingSettingItemView *item = nullptr; - if (inView == nullptr) { - item = new TrainingSettingItemView(); - } else { - item = static_cast(inView); - } - item->SetItemInfo(itemData); - item->SetOnClickListener(itemClickListener); - return item; -} - -void TrainingSettingAdapter::AddListItem(const TrainingSettingItem &item) -{ - listData_.push_back(item); -} -} // namespace OHOS diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingSettingItemView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingSettingItemView.cpp deleted file mode 100644 index 4d135b462..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingSettingItemView.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TrainingSettingItemView.cpp - * Author: - * Create: 2025-02-15 - */ - -#include "wearable_log.h" -#include "UiConfig.h" -#include "training/TrainingSettingItemView.h" - -namespace OHOS { -static constexpr uint16_t ITEM_X = 0; -static constexpr uint16_t ITEM_Y = 0; -static constexpr uint16_t ITEM_W = 382; -static constexpr uint16_t ITEM_H = 100; -static constexpr uint16_t ICON_X = 0; -static constexpr uint16_t ICON_Y = 0; -static constexpr uint16_t LABEL_X = 100; -static constexpr uint16_t LABEL_Y = 0; -static constexpr uint16_t LABEL_W = 200; -static constexpr uint16_t LABEL_H = 100; -static constexpr uint16_t LABEL_FONT = 35; -static constexpr uint16_t IMAGE_W = 300; -static constexpr uint16_t IMAGE_H = 0; - -TrainingSettingItemView::TrainingSettingItemView() -{ - InitView(); -} - -TrainingSettingItemView::~TrainingSettingItemView() -{ - Remove(&sIcon); - Remove(&sLabel); - Remove(&sNextImage); -} - -bool TrainingSettingItemView::InitView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingSettingItemView::InitView"); - SetPosition(ITEM_X, ITEM_Y, ITEM_W, ITEM_H); - SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY); - SetTouchable(true); - - sIcon.SetPosition(ICON_X, ICON_Y); - sIcon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); - - sLabel.SetPosition(LABEL_X, LABEL_Y); - sLabel.Resize(LABEL_W, LABEL_H); - sLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT); - sLabel.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); - sLabel.SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE); - sLabel.SetStyle(STYLE_TEXT_COLOR, Color::White().full); - sLabel.SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - sLabel.SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - - sNextImage.SetSrc(PNG_SETTING_NEXT_IMAGE); - sNextImage.SetPosition(IMAGE_W, IMAGE_H); - sNextImage.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); - Add(&sIcon); - Add(&sLabel); - Add(&sNextImage); - return true; -} - -void TrainingSettingItemView::SetItemInfo(const TrainingSettingItem itemInfo) -{ - sItemInfo = itemInfo; - sIcon.SetSrc(itemInfo.icon); - sLabel.SetText(itemInfo.label); - SetViewId(itemInfo.viewId); -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingSettingView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingSettingView.cpp deleted file mode 100644 index 04d868651..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingSettingView.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TrainingSettingView - * Create: 2025-03-22 - */ -#include "training/TrainingSettingView.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "training/TrainingPresenter.h" - -namespace OHOS { -static constexpr uint16_t LABELS_X = 133; -static constexpr uint16_t LABELS_Y = 36; -static constexpr uint16_t LABELS_W = 200; -static constexpr uint16_t LABELS_H = 60; -static constexpr uint16_t LABELS_FONT = 50; -static constexpr uint16_t LIST_X = 42; -static constexpr uint16_t LIST_Y = 95; -static constexpr uint16_t LIST_W = 382; -static constexpr uint16_t LIST_H = 305; - -static TrainingSettingView *g_pSettingView{nullptr}; - -TrainingSettingView::TrainingSettingView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingSettingView::TrainingSettingView"); - g_pSettingView = this; -} - -TrainingSettingView::~TrainingSettingView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingSettingView::~TrainingSettingView"); - if (group != nullptr) { - group->RemoveAll(); - delete group; - group = nullptr; - } - if (titleLabel != nullptr) { - delete titleLabel; - titleLabel = nullptr; - } - if (settingList != nullptr) { - delete settingList; - settingList = nullptr; - } - if (listAdapter_ != nullptr) { - delete listAdapter_; - listAdapter_ = nullptr; - } - g_pSettingView = nullptr; -} - -TrainingSettingView *TrainingSettingView::GetInstance() -{ - return g_pSettingView; -} - -void TrainingSettingView::CreateUILabel() -{ - // Add Label to App - if (titleLabel == nullptr) { - titleLabel = new UILabel(); - } - titleLabel->SetPosition(LABELS_X, LABELS_Y); - titleLabel->Resize(LABELS_W, LABELS_H); - - // Set additional property - titleLabel->SetText("设置"); - titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABELS_FONT); - - // Add to rootView - group->Add(titleLabel); -} - -void TrainingSettingView::CreateUIList() -{ - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::TrainingPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener nullptr"); - return; - } - - // Add List to App - if (settingList == nullptr) { - settingList = new UIList(); - } - settingList->SetPosition(LIST_X, LIST_Y); - settingList->Resize(LIST_W, LIST_H); - settingList->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - - // Set additional property - if (listAdapter_ == nullptr) { - listAdapter_ = new TrainingSettingAdapter(); - } - listAdapter_->SetItemClickListener(clickListener); - std::list trainingSettingItemList(settings, settings + TRAINING_SETTING_MAX); - listAdapter_->SetData(trainingSettingItemList); - - settingList->SetAdapter(listAdapter_); - settingList->RefreshList(); - - // Add to rootView - group->Add(settingList); -} - -UIViewGroup *TrainingSettingView::InitShowUpView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingSettingView InitShowUpView"); - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - CreateUILabel(); - CreateUIList(); - UIView::OnDragListener *trainingDragListener = (UIView::OnDragListener *)OHOS::TrainingPresenter::GetInstance(); - if (trainingDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "trainingDragListener GetInstance fail"); - return nullptr; - } - group->SetOnDragListener(trainingDragListener); - group->SetViewId(SETTING_VIEW_ID); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingView.cpp deleted file mode 100644 index 0b2d1fa55..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/training/src/TrainingView.cpp +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: TrainingView.cpp - * Author: - * Create: 2025-11-23 - */ - -#include "training/TrainingView.h" -#include "training/TrainingPresenter.h" -#include "wearable_log.h" - -namespace OHOS { -static TrainingView *g_pTrainingView = nullptr; - -TrainingView::TrainingView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingView::TrainingView"); - preProcessView[TRAINING_VIEW_MENU] = &TrainingView::ChangeMenuView; - preProcessView[TRAINING_VIEW_PREPARE] = &TrainingView::ChangePrepareView; - preProcessView[TRAINING_VIEW_DATA] = &TrainingView::ChangeDataView; - preProcessView[TRAINING_VIEW_PAUSE] = &TrainingView::ChangePauseView; - preProcessView[TRAINING_VIEW_PROMPT] = &TrainingView::ChangePromptView; - preProcessView[TRAINING_VIEW_SETTING] = &TrainingView::ChangeSettingView; - preProcessView[TRAINING_VIEW_TARGET] = &TrainingView::ChangeTargetView; - preProcessView[TRAINING_VIEW_TARGET_SETTING] = &TrainingView::ChangeTargetSettingView; - g_pTrainingView = this; -} - -TrainingView::~TrainingView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingView::~TrainingView"); - g_pTrainingView = nullptr; -} - -TrainingView *TrainingView::GetInstance() -{ - return g_pTrainingView; -} - -void TrainingView::OnStart() -{ - ChangeView(TRAINING_VIEW_MAX, TRAINING_VIEW_MENU); -} - -void TrainingView::OnStop() -{ - if (menuView != nullptr) { - delete menuView; - menuView = nullptr; - } - if (prepareView != nullptr) { - delete prepareView; - prepareView = nullptr; - } - if (dataView != nullptr) { - delete dataView; - dataView = nullptr; - } - if (pauseView != nullptr) { - delete pauseView; - pauseView = nullptr; - } - if (promptView != nullptr) { - delete promptView; - promptView = nullptr; - } - if (settingView != nullptr) { - delete settingView; - settingView = nullptr; - } - if (targetView != nullptr) { - delete targetView; - targetView = nullptr; - } - if (targetSettingView != nullptr) { - delete targetSettingView; - targetSettingView = nullptr; - } -} - -bool TrainingView::ChangeMenuView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeMenuView"); - menuView = new MenuView(); - if (menuView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingView new fail"); - return false; - } - // init view - UIViewGroup *group = menuView->InitShowUpView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool TrainingView::ChangePrepareView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangePrepareView"); - prepareView = new PrepareView(); - if (prepareView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingView new fail"); - return false; - } - // init view - UIViewGroup *group = prepareView->InitShowUpView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool TrainingView::ChangeDataView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeDataView"); - dataView = new DataView(); - if (dataView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingView new fail"); - return false; - } - // init view - UIViewGroup *group = dataView->InitShowUpView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool TrainingView::ChangePauseView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangePauseView"); - pauseView = new PauseView(); - if (pauseView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingView new fail"); - return false; - } - // init view - UIViewGroup *group = pauseView->InitShowUpView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool TrainingView::ChangePromptView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangePromptView"); - promptView = new PromptView(); - if (promptView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingView new fail"); - return false; - } - // init view - UIViewGroup *group = promptView->InitShowUpView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool TrainingView::ChangeSettingView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeSettingView"); - settingView = new TrainingSettingView(); - if (settingView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingView new fail"); - return false; - } - // init view - UIViewGroup *group = settingView->InitShowUpView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool TrainingView::ChangeTargetView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeTargetView"); - targetView = new TargetView(); - if (targetView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingView new fail"); - return false; - } - // init view - UIViewGroup *group = targetView->InitShowUpView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool TrainingView::ChangeTargetSettingView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeTargetSettingView"); - targetSettingView = new TargetSettingView(); - if (targetSettingView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingView new fail"); - return false; - } - // init view - UIViewGroup *group = targetSettingView->InitShowUpView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool TrainingView::CheckViewParam(int16_t hideView, int16_t showView) -{ - if (showView < 0 || showView >= TRAINING_VIEW_MAX) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingView::CheckViewParam showView err."); - return false; - } - - if (hideView < 0 || hideView > TRAINING_VIEW_MAX) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingView::CheckViewParam hideView err."); - return false; - } - - return true; -} - -void TrainingView::ChangeView(int16_t hideView, int16_t showView) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingView::ChangeView %d, %d", hideView, showView); - - if (!CheckViewParam(hideView, showView)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingView::CheckViewParam failed."); - return; - } - - PreprosssChangeView tmpPreProcessView = preProcessView[showView]; - - if (!(this->*tmpPreProcessView)(hideView, showView)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingView::ChangeView %d %dfailed", showView, hideView); - return; - } - if (hideView != TRAINING_VIEW_MAX) { - if (container[hideView] == nullptr) { - return; - } - container[hideView]->SetVisible(false); - } - container[showView]->SetVisible(true); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingView:: ChangeView end!!!%d", showView); - Draw(); -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/uisample/src/UISampleView.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/uisample/src/UISampleView.cpp deleted file mode 100644 index 4dbb8092e..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/uisample/src/UISampleView.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SettingView.cpp - * Author: - * Create: 2021-11-23 - */ - -#include - -#include "uisample/UISampleView.h" -#include "uisample/UISamplePresenter.h" -#include "ui_test_group.h" - -namespace OHOS { -static UISampleView *g_pUISampleView = nullptr; - -UISampleView::UISampleView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UISampleView::UISampleView"); - g_pUISampleView = this; -} - -UISampleView::~UISampleView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UISampleView::~UISampleView"); - g_pUISampleView = nullptr; -} - -UISampleView* UISampleView::GetInstance() -{ - return g_pUISampleView; -} - -void UISampleView::InitView() -{ - if ((mainList_ == nullptr) && (adapter_ == nullptr)) { - mainList_ = new UIList(UIList::VERTICAL); - mainList_->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - mainList_->SetThrowDrag(true); - mainList_->SetReboundSize(100); // 100: rebound size - mainList_->SetElastic(true); - mainList_->SetYScrollBarVisible(true); - adapter_ = new TestCaseListAdapter(); - UITestGroup::GetInstance()->SetUpTestCase(); - mainList_->SetAdapter(adapter_); - - dragListener_ = new UISampleOnDragListener(); - if (dragListener_ == nullptr) { - return; - } - mainList_->SetOnDragListener(dragListener_); - } - AddViewToRootContainer(mainList_); - GetRootContainer()->Invalidate(); -} - -void UISampleView::OnStart() -{ - InitView(); -} - -void UISampleView::OnStop() -{ - if (adapter_ != nullptr) { - delete adapter_; - adapter_ = nullptr; - } - if (dragListener_ != nullptr) { - delete dragListener_; - dragListener_ = nullptr; - } - if (mainList_ != nullptr) { - delete mainList_; - mainList_ = nullptr; - } - return; -} -} diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/uisample/uitest/framework/src/test_case_list_adapter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/uisample/uitest/framework/src/test_case_list_adapter.cpp deleted file mode 100644 index 4f652b307..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/uisample/uitest/framework/src/test_case_list_adapter.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. - * 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. - */ - -#include "test_case_list_adapter.h" -#include "common/screen.h" -#include "components/ui_button.h" -#include "components/ui_label_button.h" -#include "gfx_utils/list.h" -#include "ui_test.h" -#include "uisample/UISampleView.h" -#include "ui_test_group.h" -#include "wearable_log.h" - -namespace OHOS { -namespace { -const uint16_t TESTCASE_BUTTON_HEIGHT = 100; -const uint16_t STYLE_BORDER_WIDTH_VALUE = 4; -} // namespace - -static RootView::OnKeyActListener *g_keyListener = nullptr; - -uint16_t TestCaseListAdapter::GetCount() -{ - return UITestGroup::GetInstance()->GetTestCase().Size(); -} - -class TransparentBackButton : public UIButton { -public: - TransparentBackButton() : UIButton() - { - opaScale_ = OPA_TRANSPARENT; - } - - bool OnClickEvent(const ClickEvent& event) override - { - UISampleView::GetInstance()->GetRootContainer()->RemoveAll(); - UITest* uiTest = UITestGroup::GetInstance()->GetTestCase(GetViewId()); - if (uiTest != nullptr) { - uiTest->TearDown(); - } - RootView::GetInstance()->SetOnKeyActListener(g_keyListener); - g_keyListener = nullptr; - UISampleView::GetInstance()->InitView(); - return true; - } -}; - -class UiTestClickListener : public UIView::OnClickListener { -public: - UiTestClickListener() {} - ~UiTestClickListener() - { - if (backBtn_ != nullptr) { - delete backBtn_; - backBtn_ = nullptr; - } - } - - bool OnClick(UIView& view, const ClickEvent& event) override - { - UIViewGroup* rootContainer = UISampleView::GetInstance()->GetRootContainer(); - UITest* uiTest = UITestGroup::GetInstance()->GetTestCase(view.GetViewId()); - if (uiTest == nullptr) { - return false; - } - uiTest->SetUp(); - rootContainer->RemoveAll(); - UIView* tempView = const_cast(uiTest->GetTestView()); - if (tempView != nullptr) { - tempView->SetTouchable(true); - tempView->SetViewId(view.GetViewId()); - tempView->SetPosition(tempView->GetX(), tempView->GetY()); - rootContainer->Add(tempView); - g_keyListener = RootView::GetInstance()->GetOnKeyActListener(); - RootView::GetInstance()->SetOnKeyActListener(nullptr); - } - if (backBtn_ == nullptr) { - backBtn_ = new TransparentBackButton(); - backBtn_->SetPosition(0, 202, 50, 50); // 0: x position, 202: y position, 50: width and height - } - backBtn_->SetViewId(view.GetViewId()); - rootContainer->Add(backBtn_); - rootContainer->Invalidate(); - return true; - } - -private: - UIButton* backBtn_{nullptr}; -}; - -UIView* TestCaseListAdapter::GetView(UIView* inView, int16_t index) -{ - List testCaseList = UITestGroup::GetInstance()->GetTestCase(); - if (testCaseList.IsEmpty()) { - return nullptr; - } - if ((index > testCaseList.Size() - 1) || (index < 0)) { - return nullptr; - } - UILabelButton* item = nullptr; - if (inView == nullptr) { - item = new UILabelButton(); - item->SetPosition(0, 0); - item->SetStyleForState(STYLE_BORDER_WIDTH, STYLE_BORDER_WIDTH_VALUE, UIButton::RELEASED); - item->SetStyleForState(STYLE_BORDER_WIDTH, STYLE_BORDER_WIDTH_VALUE, UIButton::PRESSED); - item->SetStyleForState(STYLE_BORDER_WIDTH, STYLE_BORDER_WIDTH_VALUE, UIButton::INACTIVE); - item->SetStyleForState(STYLE_BORDER_OPA, 0, UIButton::RELEASED); - item->SetStyleForState(STYLE_BORDER_OPA, 0, UIButton::PRESSED); - item->SetStyleForState(STYLE_BORDER_OPA, 0, UIButton::INACTIVE); - item->Resize(HORIZONTAL_RESOLUTION - TEXT_DISTANCE_TO_LEFT_SIDE, TESTCASE_BUTTON_HEIGHT); - } else { - item = static_cast(inView); - } - - if (listener_ == nullptr) { - listener_ = new UiTestClickListener(); - } - ListNode* node = testCaseList.Begin(); - for (uint16_t i = 0; i < index; i++) { - node = node->next_; - } - item->SetOnClickListener(listener_); - item->SetText(node->data_.sliceId); - item->SetViewId(node->data_.sliceId); - item->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40: means font size - item->SetViewIndex(index); - item->SetAlign(TEXT_ALIGNMENT_LEFT); - item->SetLabelPosition(150, 0); // 150: label x-coordinate - item->SetStyleForState(STYLE_BORDER_RADIUS, 0, UIButton::RELEASED); - item->SetStyleForState(STYLE_BORDER_RADIUS, 0, UIButton::PRESSED); - item->SetStyleForState(STYLE_BORDER_RADIUS, 0, UIButton::INACTIVE); - item->SetStyleForState(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT, UIButton::RELEASED); - item->SetStyleForState(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT, UIButton::PRESSED); - item->SetStyleForState(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT, UIButton::INACTIVE); - return item; -} - -int16_t TestCaseListAdapter::GetItemWidthWithMargin(int16_t index) -{ - // 2: two borders on both sides - return HORIZONTAL_RESOLUTION - TEXT_DISTANCE_TO_LEFT_SIDE + STYLE_BORDER_WIDTH_VALUE * 2; -} - -int16_t TestCaseListAdapter::GetItemHeightWithMargin(int16_t index) -{ - return TESTCASE_BUTTON_HEIGHT + STYLE_BORDER_WIDTH_VALUE * 2; // 2: two borders on both sides -} -} // namespace OHOS diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/weather/src/WeatherAdapter.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/weather/src/WeatherAdapter.cpp deleted file mode 100644 index 65aae4f0b..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/weather/src/WeatherAdapter.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: WeatherAdapter - * Create: 2025-03-23 - */ - -#include "weather/WeatherAdapter.h" - -namespace OHOS { -WeatherAdapter::WeatherAdapter() {} - -WeatherAdapter::~WeatherAdapter() -{ - listData.clear(); -} - -uint16_t WeatherAdapter::GetCount(void) -{ - return listData.size(); -} - -void WeatherAdapter::SetData(std::list &data) -{ - if (!listData.empty()) { - listData.clear(); - } - std::list::iterator it; - for (it = data.begin(); it != data.end(); it++) { - listData.push_back(*it); - } -} - -UIView *WeatherAdapter::GetView(UIView *inView, int16_t index) -{ - if (listData.empty()) { - return nullptr; - } - if (index < 0) { - return nullptr; - } - size_t uindex = index; - if (uindex >= listData.size()) { - return nullptr; - } - - std::list::iterator it = listData.begin(); - for (int i = 0; i < index; i++) { - it++; - } - WeatherItem itemData = *it; - WeatherItemView *item = nullptr; - if (inView == nullptr) { - item = new WeatherItemView(); - } else { - item = static_cast(inView); - } - - item->SetItemInfo(itemData); - item->SetOnClickListener(itemClickListener); - return item; -} - -void WeatherAdapter::AddListItem(const WeatherItem &item) -{ - listData.push_back(item); -} -} // namespace OHOS diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/weather/src/WeatherPageSecond.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/weather/src/WeatherPageSecond.cpp deleted file mode 100644 index f9e9e768f..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/weather/src/WeatherPageSecond.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: WeatherPageSecond - * Create: 2025-03-15 - */ - -#include "weather/WeatherPageSecond.h" -#include "components/ui_list_nested.h" -#include "components/ui_scroll_view_nested.h" -#include "NativeAbility.h" -#include "SlicePageFactory.h" -#include "weather/WeatherPresenter.h" -#include "weather/WeatherView.h" -#include "weather/WeatherModel.h" -#include "ui_resource_weather.h" -#include "common/image_cache_manager.h" -#include "wearable_log.h" - -namespace OHOS { -static constexpr uint16_t WEATHER_TITLE_WIDTH = 51; -static constexpr uint16_t WEATHER_TITLE_HEIGHT = 26; -static constexpr uint16_t WEATHER_TOPLABEL_X = 156; -static constexpr uint16_t WEATHER_TOPLABEL_Y = 22; -static constexpr uint16_t WEATHER_TOPLABEL_WIDTH = 150; -static constexpr uint16_t WEATHER_TOPLABEL_HEIGHT = 60; -static constexpr uint16_t WEATHER_TOPLABEL_FRONT = 26; -static constexpr uint16_t WEATHER_LABELTIME_FRONT = 20; -static constexpr uint16_t WEATHER_LABELTIME_FRONT_TWO = 24; -static constexpr int16_t WEATHER_IMAGEPAGEKEY_X = 199; -static constexpr int16_t WEATHER_IMAGEPAGEKEY_Y = 429; -static constexpr int16_t WEATHER_IMAGEPAGEKEY_WIDTH = 56; -static constexpr int16_t WEATHER_IMAGEPAGEKEY_HEIGHT = 10; -static constexpr uint16_t ANIMATOR_TIME = 50; - -REGIST_SLICE_PAGE(VIEW_WEATHER, WEATHER_PAGES::WEATHER_SECOND_PAGE, WeatherPageSecond, false); - -WeatherPageSecond::WeatherPageSecond() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherPageSecond::WeatherPageSecond"); - weatherModel = &WeatherModel::GetInstance(); -} - -WeatherPageSecond::~WeatherPageSecond() -{ - if (weatherSwipeGroup != nullptr) { - weatherSwipeGroup->RemoveAll(); - delete weatherSwipeGroup; - weatherSwipeGroup = nullptr; - } - - for (int i = 0; i < SET_THREE; ++i) { - if (swipeGroup[i] != nullptr) { - swipeGroup[i]->RemoveAll(); - delete swipeGroup[i]; - swipeGroup[i] = nullptr; - } - } - - for (int i = 0; i < SET_EIGHT; ++i) { - if (imgBack[i] != nullptr) { - delete imgBack[i]; - imgBack[i] = nullptr; - } - } - - for (int i = 0; i < SET_EIGHT; ++i) { - if (labelTime[i] != nullptr) { - delete labelTime[i]; - labelTime[i] = nullptr; - } - } - - for (int i = 0; i < SET_EIGHT; ++i) { - if (labelTemp[i] != nullptr) { - delete labelTemp[i]; - labelTemp[i] = nullptr; - } - } - - for (int i = 0; i < SET_EIGHT; ++i) { - if (imgWeather[i] != nullptr) { - delete imgWeather[i]; - imgWeather[i] = nullptr; - } - } - if (mainImg != nullptr) { - delete mainImg; - mainImg = nullptr; - } - if (ImagePageKey != nullptr) { - delete ImagePageKey; - ImagePageKey = nullptr; - } - ImageCacheManager::GetInstance().UnloadAllInMultiRes(WEATHER_IMAGE); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherPageSecond::~WeatherPageSecond"); -} - -void WeatherPageSecond::OnStart(void *data) -{ - weatherSwipeGroup = new UISwipeView(UISwipeView::VERTICAL); - if (weatherSwipeGroup == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "weatherSwipeGroup new fail"); - return; - } - weatherSwipeGroup->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - weatherSwipeGroup->SetViewId("weatherSwipeGroup"); - weatherSwipeGroup->SetOnDragListener(this); - weatherSwipeGroup->SetOnSwipeListener(this); - weatherSwipeGroup->SetDraggable(true); - weatherSwipeGroup->SetTouchable(true); - weatherSwipeGroup->SetAnimatorTime(ANIMATOR_TIME); - for (int i = 0; i < SET_THREE; i++) { - swipeGroup[i] = new UIViewGroup(); - if (swipeGroup[i] == nullptr) { - return; - } - WeatherInit(swipeGroup[i]); - weatherSwipeGroup->Add(swipeGroup[i]); - } - - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherPageFirst::InitPageFirst successful"); - AddViewToPageContainer(weatherSwipeGroup); -} - -void WeatherPageSecond::WeatherInit(UIViewGroup *group) -{ - group->SetPosition(0, 0); - group->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); - group->SetOnDragListener(this); - group->SetViewId("weather"); - group->SetDraggable(true); - group->SetTouchable(true); - mainImg = new UIImageView(); - mainImg->SetPosition(0, 0); - mainImg->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - ImageInfo *imgSrc = - ImageCacheManager::GetInstance().LoadOneInMultiRes(IMAGE_CONVERTER_TOOL_WEATHER65, WEATHER_IMAGE); - if (imgSrc == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherMainPage::LoadOneInMultiRes fail"); - } - if (weatherModel->GetDayStatus()) { - LOADIMG::LoadImageViewImg(mainImg, WEATHER_IMAGE, IMAGE_CONVERTER_TOOL_WEATHER64); - } else { - LOADIMG::LoadImageViewImg(mainImg, WEATHER_IMAGE, IMAGE_CONVERTER_TOOL_WEATHER65); - } - group->Add(mainImg); - houWeather = weatherModel->GetHourWeather(); - ImagePageKey = new UIImageView(); - if (ImagePageKey == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherPageFirst::ImagePageKey new image fail"); - return; - } - ImagePageKey->SetPosition(WEATHER_IMAGEPAGEKEY_X, WEATHER_IMAGEPAGEKEY_Y, WEATHER_IMAGEPAGEKEY_WIDTH, - WEATHER_IMAGEPAGEKEY_HEIGHT); - ImagePageKey->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - LOADIMG::LoadImageViewImg(ImagePageKey, WEATHER_IMAGE, IMAGE_CONVERTER_TOOL_WEATHER67); - group->Add(ImagePageKey); - int count = index * SET_EIGHT; - index++; - InitImage(group, count); - InitLabel(group, count); - return; -} - -void WeatherPageSecond::InitImage(UIViewGroup *group, int count) -{ - int weatherPosX[SET_EIGHT] = {67, 161, 257, 351, 67, 161, 257, 351}; - int weatherPosY[SET_EIGHT] = {125, 125, 125, 125, 289, 289, 289, 289}; - int backPosX[SET_EIGHT] = {47, 141, 235, 329, 47, 141, 235, 329}; - int backPosY[SET_EIGHT] = {71, 71, 71, 71, 235, 235, 235, 235}; - for (int i = 0; i < SET_EIGHT; i++) { - imgBack[i] = new UIImageView(); - if (imgBack[i] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherPageSecond::InitPageSecond new UIImageView fail"); - return; - } - imgBack[i]->SetPosition(backPosX[i], backPosY[i]); - if (weatherModel->GetDayStatus()) { - LOADIMG::LoadImageViewImg(imgBack[i], WEATHER_IMAGE, IMAGE_CONVERTER_TOOL_WEATHER73); - } else { - LOADIMG::LoadImageViewImg(imgBack[i], WEATHER_IMAGE, IMAGE_CONVERTER_TOOL_WEATHER74); - } - - imgWeather[i] = new UIImageView(); - if (imgWeather[i] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherPageSecond::InitPageSecond new labelTime fail"); - return; - } - imgWeather[i]->SetPosition(weatherPosX[i], weatherPosY[i]); - int curWeather_code = std::atoi(houWeather[count + i].weather); - LOADIMG::LoadImageViewImg(imgWeather[i], WEATHER_IMAGE, smallWeatherImage[curWeather_code]); - group->Add(imgBack[i]); - group->Add(imgWeather[i]); - } -} - -void WeatherPageSecond::InitLabel(UIViewGroup *group, int count) -{ - int timePosX[SET_EIGHT] = {67, 161, 255, 349, 67, 161, 255, 349}; - int timePosY[SET_EIGHT] = {91, 91, 91, 91, 255, 255, 255, 255}; - int tempPosX[SET_EIGHT] = {75, 169, 263, 356, 75, 169, 263, 356}; - int tempPosY[SET_EIGHT] = {175, 175, 175, 175, 339, 339, 339, 339}; - UILabel *topLabel = new UILabel(); - if (topLabel == nullptr) { - return; - } - topLabel->SetText("24小时预报"); - topLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WEATHER_TOPLABEL_FRONT); - topLabel->SetPosition(WEATHER_TOPLABEL_X, WEATHER_TOPLABEL_Y, WEATHER_TOPLABEL_WIDTH, WEATHER_TOPLABEL_HEIGHT); - group->Add(topLabel); - for (int i = 0; i < SET_EIGHT; i++) { - labelTemp[i] = new UILabel(); - if (labelTemp[i] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherPageSecond::InitPageSecond new labelTemp fail"); - return; - } - std::ostringstream oss; - oss << houWeather[count + i].degree << "°"; - std::string temp = oss.str(); - labelTemp[i]->SetText(temp.c_str()); - labelTemp[i]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WEATHER_LABELTIME_FRONT_TWO); - labelTemp[i]->SetPosition(tempPosX[i], tempPosY[i], WEATHER_TITLE_WIDTH, WEATHER_TITLE_HEIGHT); - - labelTime[i] = new UILabel(); - if (labelTime[i] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherPageSecond::InitPageSecond new labelTime fail"); - return; - } - std::string strHour = houWeather[count + i].hour; - labelTime[i]->SetText(strHour.c_str()); - labelTime[i]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WEATHER_LABELTIME_FRONT); - labelTime[i]->SetPosition(timePosX[i], timePosY[i], WEATHER_TITLE_WIDTH, WEATHER_TITLE_HEIGHT); - group->Add(labelTemp[i]); - group->Add(labelTime[i]); - } -} - -bool WeatherPageSecond::OnDrag(UIView &view, const DragEvent &event) -{ - UNUSED(view); - if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && (event.GetDeltaX() > X_DRAG_OFFSET) && - (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { - NativeAbility::GetInstance().SwitchPageInSlice(WEATHER_PAGES::WEATHER_MAIN_PAGE, nullptr, - TransitionType::TRANSITION_INVALID, true); - } else if (event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT) { - NativeAbility::GetInstance().SwitchPageInSlice(WEATHER_PAGES::WEATHER_THIRD_PAGE, nullptr, - TransitionType::TRANSITION_INVALID, true); - } - return false; -} - -void WeatherPageSecond::OnSwipe(UISwipeView &view) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter::OnSwipe "); - UNUSED(view); - return; -} - -bool WeatherPageSecond::OnClick(UIView &view, const ClickEvent &event) -{ - UNUSED(event); - return true; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/nativeapp/nativeui/weather/src/WeatherPageThird.cpp b/code/sdk/application/wearable/evb/nativeapp/nativeui/weather/src/WeatherPageThird.cpp deleted file mode 100644 index d6ca8fbaf..000000000 --- a/code/sdk/application/wearable/evb/nativeapp/nativeui/weather/src/WeatherPageThird.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: WeatherPageThird - * Create: 2025-03-23 - */ - -#include "weather/WeatherPageThird.h" -#include "components/ui_list_nested.h" -#include "components/ui_scroll_view_nested.h" -#include "NativeAbility.h" -#include "SlicePageFactory.h" -#include "weather/WeatherPresenter.h" -#include "weather/WeatherView.h" -#include "weather/WeatherModel.h" -#include "ui_resource_weather.h" -#include "common/image_cache_manager.h" -#include "wearable_log.h" - -namespace OHOS { -static constexpr uint8_t WEATHER_ITEM_FONT_SIZE = 25; -static constexpr int16_t WEATHER_RESIZE_SIZE_WIDTH = 200; -static constexpr int16_t WEATHER_RESIZE_SIZE_HEIGHT = 50; -static constexpr int16_t WEATHER_TITLE_POSITION_X = 130; -static constexpr int16_t WEATHER_LIST_POSITION_X = 32; -static constexpr int16_t WEATHER_LIST_POSITION_Y = 70; -static constexpr int16_t WEATHER_LIST_WIDTH = 390; -static constexpr int16_t WEATHER_LIST_HEIGHT = 318; -static constexpr int16_t WEATHER_LIST_SELECT_POSITION = 80; -static constexpr int16_t LIST_POS = 20; -static constexpr int16_t WEATHER_LABEL_FRONT_ONE = 20; -static constexpr int16_t WEATHER_LABEL_FRONT = 40; -static constexpr int16_t WEATHER_IMAGEPAGEKEY_X = 199; -static constexpr int16_t WEATHER_IMAGEPAGEKEY_Y = 429; -static constexpr int16_t WEATHER_IMAGEPAGEKEY_WIDTH = 56; -static constexpr int16_t WEATHER_IMAGEPAGEKEY_HEIGHT = 10; - -REGIST_SLICE_PAGE(VIEW_WEATHER, WEATHER_PAGES::WEATHER_THIRD_PAGE, WeatherPageThird, false); - -WeatherPageThird::WeatherPageThird() -{ - weatherModel = &WeatherModel::GetInstance(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherPageThird::WeatherPageThird"); -} - -WeatherPageThird::~WeatherPageThird() -{ - if (group != nullptr) { - group->RemoveAll(); - delete group; - group = nullptr; - } - - if (contentList != nullptr) { - delete contentList; - contentList = nullptr; - } - - if (title != nullptr) { - delete title; - title = nullptr; - } - - if (listAdapter != nullptr) { - delete listAdapter; - listAdapter = nullptr; - } - - if (mainImg != nullptr) { - delete mainImg; - mainImg = nullptr; - } - - if (ImagePageKey != nullptr) { - delete ImagePageKey; - ImagePageKey = nullptr; - } - ImageCacheManager::GetInstance().UnloadAllInMultiRes(WEATHER_IMAGE); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherPageThird::~WeatherPageThird"); -} - -void WeatherPageThird::OnStart(void *data) -{ - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::OnStart::group is nullptr"); - return; - } - group->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - group->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - group->SetOnDragListener(this); - - title = new UILabel(); - if (title == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::OnStart::title is nullptr"); - return; - } - title->SetPosition(WEATHER_TITLE_POSITION_X, WEATHER_LABEL_FRONT_ONE); - title->SetText("7日天气预报"); - title->Resize(WEATHER_RESIZE_SIZE_WIDTH, WEATHER_RESIZE_SIZE_HEIGHT); - title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, WEATHER_ITEM_FONT_SIZE); - title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - title->SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE); - title->SetStyle(STYLE_TEXT_COLOR, Color::White().full); - title->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - - mainImg = new UIImageView(); - mainImg->SetPosition(0, 0); - mainImg->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - if (weatherModel->GetDayStatus()) { - LOADIMG::LoadImageViewImg(mainImg, WEATHER_IMAGE, IMAGE_CONVERTER_TOOL_WEATHER64); - } else { - LOADIMG::LoadImageViewImg(mainImg, WEATHER_IMAGE, IMAGE_CONVERTER_TOOL_WEATHER65); - } - InitScrollView(); - InitScrollData(); - AddViewToPageContainer(group); -} - -void WeatherPageThird::InitScrollView() -{ - contentList = new UIList(); - if (contentList == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::OnStart::contentList is nullptr"); - return; - } - - contentList->SetPosition(WEATHER_LIST_POSITION_X, WEATHER_LIST_POSITION_Y); - contentList->Resize(WEATHER_LIST_WIDTH, WEATHER_LIST_HEIGHT); - contentList->SetSelectPosition(WEATHER_LIST_SELECT_POSITION); - contentList->SetDraggable(true); - contentList->SetThrowDrag(true); - contentList->EnableAutoAlign(true); - contentList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - contentList->SetElastic(true); - ImagePageKey = new UIImageView(); - if (ImagePageKey == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherPageFirst::ImagePageKey new image fail"); - return; - } - ImagePageKey->SetPosition(WEATHER_IMAGEPAGEKEY_X, WEATHER_IMAGEPAGEKEY_Y, WEATHER_IMAGEPAGEKEY_WIDTH, - WEATHER_IMAGEPAGEKEY_HEIGHT); - ImagePageKey->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - LOADIMG::LoadImageViewImg(ImagePageKey, WEATHER_IMAGE, IMAGE_CONVERTER_TOOL_WEATHER68); - group->Add(mainImg); - group->Add(title); - group->Add(contentList); - group->Add(ImagePageKey); -} - -bool WeatherPageThird::InitScrollData() -{ - const WeatherItem *itemInfo = weatherModel->GetWeatherlistItems(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::InitWeatherItem %s", itemInfo); - RefreshWeathersList(itemInfo, weatherModel->GetWeatherListNum()); - return true; -} - -void WeatherPageThird::RefreshWeathersList(const WeatherItem *item, uint8_t count) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::OnStart::listAdapter"); - listAdapter = new WeatherAdapter(); - if (listAdapter == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::OnStart::listAdapter is nullptr"); - return; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::RefreshWeathersList"); - if (item == nullptr) { - return; - } else { - for (int i = 0; i < count; i++) { - listAdapter->AddListItem(item[i]); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::RefreshWeathersList %d", i); - } - } - if (contentList == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::contentList fail"); - return; - } - contentList->ScrollTo(0); - contentList->SetAdapter(listAdapter); -} - -bool WeatherPageThird::OnDrag(UIView &view, const DragEvent &event) -{ - UNUSED(view); - if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && (event.GetDeltaX() > X_DRAG_OFFSET) && - (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { - NativeAbility::GetInstance().SwitchPageInSlice(WEATHER_PAGES::WEATHER_SECOND_PAGE, nullptr, - TransitionType::TRANSITION_INVALID, true); - } - return false; -} - -void WeatherPageThird::OnSwipe(UISwipeView &view) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter::OnSwipe "); - UNUSED(view); - return; -} - -bool WeatherPageThird::OnClick(UIView &view, const ClickEvent &event) -{ - UNUSED(event); - return true; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/service/device_msg/device_location.cpp b/code/sdk/application/wearable/evb/service/device_msg/device_location.cpp deleted file mode 100644 index d24a14f75..000000000 --- a/code/sdk/application/wearable/evb/service/device_msg/device_location.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - */ -#include "device_location.h" -#include "wearable_log.h" -#include "locator.h" - -using namespace OHOS::Location; - -LocationInfo_t g_locationInfo = {0}; - -class GnssStatusCallback : public IGnssStatusCallback { -public: - GnssStatusCallback() {} - ~GnssStatusCallback() {} - - void OnStatusChange(const std::shared_ptr &statusInfo) override - { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "OnStatusChange, num:%d\n", statusInfo->GetSatellitesNumber()); - for (int32_t satIdx = 0; satIdx < statusInfo->GetSatellitesNumber(); satIdx++) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "sat index:%d svid:%d ele:%.3f az:%.3f cnr:%.3f \n", satIdx, - statusInfo->GetSatelliteIds()[satIdx], statusInfo->GetAltitudes()[satIdx], - statusInfo->GetAzimuths()[satIdx], statusInfo->GetCarrierToNoiseDensitys()[satIdx]); - } - } - -private: -}; - -class NmeaMessageCallback : public INmeaMessageCallback { -public: - NmeaMessageCallback() {} - ~NmeaMessageCallback() {} - - void OnMessageChange(int64_t timestamp, const std::string msg) override - { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "OnMessageChange timestamp :%lld msg:%s\n", timestamp, msg.c_str()); - } - -private: -}; - -class LocatorCallback : public ILocatorCallback { -public: - LocatorCallback() {} - - ~LocatorCallback() {} - - void OnLocationReport(const std::shared_ptr &location) override - { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "OnLocationReport Lat:%.3f Long:%.3f Alt:%.3f Speed:%.3f dir:%.3f\n", - location->GetLatitude(), location->GetLongitude(), location->GetAltitude(), location->GetSpeed(), - location->GetDirection()); - } - - void OnErrorReport(const int errorCode) override - { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "error code:%d\n", errorCode); - } - - void OnLocatingStatusChange(const int status) override - { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "OnLocatingStatusChange status:%d\n", status); - } - -private: -}; - -typedef struct { - Locator *locator; - bool isStarted; - LocatorCallback locatorCallback; - GnssStatusCallback gnssStatusCallback; - NmeaMessageCallback nmeaMessageCallback; -} LocationSampleContext; - -static LocationSampleContext g_locationContext = { - .locator = nullptr, - .isStarted = false, -}; - -int32_t deviceLocationStartLocating() -{ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "LocationStartLocating\n"); - if (g_locationContext.locator == nullptr) { - g_locationContext.locator = &Locator::GetInstance(); - } - if (g_locationContext.locator == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "locator is nullptr\n"); - return ERRCODE_FAILURE; - } - - bool isEnabled = false; - LocationErrCode errCode = g_locationContext.locator->IsLocationEnabled(isEnabled); - if (errCode != ERRCODE_SUCCESS) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "locator IsLocationEnabled failed:%d\n", errCode); - return errCode; - } - - if (!isEnabled) { - errCode = g_locationContext.locator->EnableAbility(true); - if (errCode != ERRCODE_SUCCESS) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "locator EnableAbility failed:%d\n", errCode); - return errCode; - } - } - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "RegisterGnssStatusCallback\n"); - errCode = g_locationContext.locator->RegisterGnssStatusCallback(&g_locationContext.gnssStatusCallback); - if (errCode != ERRCODE_SUCCESS) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "locator RegisterGnssStatusCallback failed:%d\n", errCode); - return errCode; - } - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "RegisterNmeaMessageCallback\n"); - errCode = g_locationContext.locator->RegisterNmeaMessageCallback(&g_locationContext.nmeaMessageCallback); - if (errCode != ERRCODE_SUCCESS) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "locator RegisterNmeaMessageCallback failed:%d\n", errCode); - return errCode; - } - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "StartLocating\n"); - RequestConfig requestConfig; - requestConfig.SetPriority(PRIORITY_ACCURACY); - errCode = g_locationContext.locator->StartLocating(&requestConfig, &g_locationContext.locatorCallback); - if (errCode != ERRCODE_SUCCESS) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "locator StartLocating failed:%d\n", errCode); - return errCode; - } - g_locationContext.isStarted = true; - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "StartLocating end\n"); - return ERRCODE_SUCCESS; -} - -int32_t deviceLocationStopLocating() -{ - if (!g_locationContext.isStarted) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "locator is not started\n"); - return ERRCODE_FAILURE; - } - LocationErrCode errCode = - g_locationContext.locator->UnregisterNmeaMessageCallback(&g_locationContext.nmeaMessageCallback); - if (errCode != ERRCODE_SUCCESS) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "locator UnregisterNmeaMessageCallback failed:%d\n", errCode); - return errCode; - } - errCode = g_locationContext.locator->UnregisterGnssStatusCallback(&g_locationContext.gnssStatusCallback); - if (errCode != ERRCODE_SUCCESS) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "locator RegisterGnssStatusCallback failed:%d\n", errCode); - return errCode; - } - errCode = g_locationContext.locator->StopLocating(&g_locationContext.locatorCallback); - if (errCode != ERRCODE_SUCCESS) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "locator StopLocating failed:%d\n", errCode); - return errCode; - } - g_locationContext.isStarted = false; - - bool isEnabled = false; - errCode = g_locationContext.locator->IsLocationEnabled(isEnabled); - if (errCode != ERRCODE_SUCCESS) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "locator IsLocationEnabled failed:%d\n", errCode); - return errCode; - } - if (!isEnabled) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "locator Is not Enabled\n"); - return ERRCODE_FAILURE; - } - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "EnableAbility false\n"); - errCode = g_locationContext.locator->EnableAbility(false); - if (errCode != ERRCODE_SUCCESS) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "locator EnableAbility failed:%d\n", errCode); - return errCode; - } - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Disable end\n"); - return ERRCODE_SUCCESS; -} \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/service/device_msg/device_location.h b/code/sdk/application/wearable/evb/service/device_msg/device_location.h deleted file mode 100644 index 3305d698c..000000000 --- a/code/sdk/application/wearable/evb/service/device_msg/device_location.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - */ -#ifndef DEVICE_LOCATION_H -#define DEVICE_LOCATION_H -#include - -typedef struct LocationInfo { - int32_t latitude_; - int32_t longitude_; - uint16_t altitude_; - uint16_t accuracy_; - uint16_t speed_; - uint16_t direction_; - int64_t timeStamp_; -} LocationInfo_t; - -int32_t deviceLocationStartLocating(); -int32_t deviceLocationStopLocating(); -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/evb/service/msg_center/include/notify/makephone_notification.h b/code/sdk/application/wearable/evb/service/msg_center/include/notify/makephone_notification.h deleted file mode 100644 index 82210db63..000000000 --- a/code/sdk/application/wearable/evb/service/msg_center/include/notify/makephone_notification.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved. - * Description: makephone notification api - * Author: CompanyName - * Create: 2023-08-11 - */ - -#ifndef MAKEPHONE_NOTIFICATION_H -#define MAKEPHONE_NOTIFICATION_H - -enum class CallTimerType { - NOTIFY_PHONE_CALLING_DISPLAY = 0, - NOTIFY_PHONE_CURTIME_DISPLAY = 1, - NOTIFY_PHONE_UNKNOWN = 10, -}; - -namespace OHOS { -class VolumeSettingView; -UIViewGroup* CreatePhoneCallView(void); -UIViewGroup* CreateCallingView(void); -UIViewGroup* CreateMultiplePhoneView(void); -UIViewGroup* CreateWaitingHintsView(void); -void HonrsViewChange(void); -VolumeSettingView *GetvolumeSetting(void); -void FreeCallingView(void); -void FreePhoneCallView(void); -void FreeMultiplePhoneCallView(void); -void FreeWaitingHintsView(void); -void RefreshMicrophoneImageSrc(const char* src); -void CallTimerCallBackProc(int data); -void CallCurTimerCallBack(int data); -void StartCallTimer(CallTimerType type, int32_t interval); -void DisableCallTimer(CallTimerType type); -void EnableWaitingView(void); -void DisableWatingView(void); - -class CallViewEventListener : public OHOS::UIView::OnClickListener, - public OHOS::UIView::OnLongPressListener, - public OHOS::UIView::OnTouchListener, - public OHOS::UIView::OnDragListener { -public: - CallViewEventListener(); - ~CallViewEventListener() override; - static CallViewEventListener *GetInstance(void); - bool OnClick(OHOS::UIView& view, const OHOS::ClickEvent& event) override; - bool OnDrag(UIView& view, const DragEvent& event) override - { - return true; - } - bool OnDragEnd(OHOS::UIView& view, const OHOS::DragEvent& event) override - { - return true; - } - bool OnPress(OHOS::UIView& view, const OHOS::PressEvent& event) override - { - return true; - } - bool OnLongPress(OHOS::UIView& view, const OHOS::LongPressEvent& event) override - { - return true; - } - bool OnRelease(OHOS::UIView& view, const OHOS::ReleaseEvent& event) override - { - return true; - } - - bool OnDragStart(OHOS::UIView& view, const OHOS::DragEvent& event) override - { - return true; - } -}; -}; // namespace OHOS - -#endif /* MAKEPHONE_NOTIFICATION_H */ diff --git a/code/sdk/application/wearable/evb/service/msg_center/src/notify/makephone_notification.cpp b/code/sdk/application/wearable/evb/service/msg_center/src/notify/makephone_notification.cpp deleted file mode 100644 index 1c150c208..000000000 --- a/code/sdk/application/wearable/evb/service/msg_center/src/notify/makephone_notification.cpp +++ /dev/null @@ -1,778 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved. - * Description: makephone notification implement - * Author: CompanyName - * Create: 2023-08-11 - */ - -#include "notification_manager.h" -#include "wearable_log.h" -#include "callerlog/CallerLogModel.h" -#include "phoneservice/PhoneService.h" -#include "cmsis_os.h" -#include "UiConfig.h" -#include "components/ui_image_view.h" -#include "components/ui_label.h" -#include "common/image_cache_manager.h" -#include "main/VolumeSettingView.h" -#include "main/VolumeSettingPresenter.h" -#include "ui_resource_image.h" - -namespace OHOS { -constexpr int32_t NOTIFY_THREE_SECONDS = 3000; -constexpr int32_t NOTIFY_ONE_SECOND = 1000; -constexpr int32_t NOTIFY_THIRTY_SECONDS = 30000; -constexpr int32_t NOTIFY_ONE_MINUTE = 60000; -constexpr int32_t NOTOFY_NO_OPERATE_TIME = 35000; -int g_changeImage = 0; -osTimerId_t g_callDurationTimer = nullptr; // timer of call duration -osTimerId_t g_callCurrentTime = nullptr; // timer of current time - -static constexpr uint16 MATH_ZERO = 0; - -// 来电显示 -static constexpr uint16 LABEL_PERCENT_POSITION_X = 0; -static constexpr uint16 LABEL_PERCENT_POSITION_Y = 100; -static constexpr uint16 LABEL_COMINGVIEW_POSITION_X = 0; -static constexpr uint16 LABEL_COMINGVIEW_POSITION_Y = 80; -static constexpr uint16 TITLE_LABEL_DEFAULT_HEIGHT = 80; - -// 当前时间 -static constexpr uint16 LABEL_CURREMTTIME_POSITION_X = 0; -static constexpr uint16 LABEL_CURREMTTIME_POSITION_Y = 360; -static constexpr uint16 LABEL_COMINGTIME_POSITION_X = 0; -static constexpr uint16 LABEL_COMINGTIME_POSITION_Y = 340; - -// 图片坐标 -static constexpr uint16 LABEL_CALLERD_POSITION_X = 0; -static constexpr uint16 LABEL_CALLERD_POSITION_Y = 160; -static constexpr uint16 LABEL_NEWCALLERD_POSITION_X = 0; -static constexpr uint16 LABEL_NEWCALLERD_POSITION_Y = 160; -static constexpr uint16 IMAGE_HONRS_POSITION_X = 185; -static constexpr uint16 IMAGE_HONRS_POSITION_Y = 10; -static constexpr uint16 IMAGE_HANDUP_POSITION_X = 70; -static constexpr uint16 IMAGE_MIC_POSITION_X = 280; -static constexpr uint16 IMAGE_DISSGREE_POSITION_X = 80; -static constexpr uint16 IMAGE_AGREEING_POSITION_X = 270; -static constexpr uint16 IMAGE_ALL_POSITION_Y = 240; -static constexpr uint16 IMAGE_HANDUP2_POSITION_X = 177; -static constexpr uint16 IMAGE_HANDUP2_POSITION_Y = 270; - -// 字体大小 -static constexpr uint16 FONT_CURRENT_SIZE = 25; -static constexpr uint16 FONT_CALLER_SIZE = 40; -UIViewGroup* g_phoneView = nullptr; -UIViewGroup* g_multiPhoneView = nullptr; -UIViewGroup* g_callingView = nullptr; -UIViewGroup* g_waitingHintsView = nullptr; -VolumeSettingView *g_volumeSetting = nullptr; -UIImageView* g_imageAgree = nullptr; -UIImageView* g_imageDissgree = nullptr; -UIImageView* g_imageMicrophone = nullptr; -UIImageView* g_imageHandUp = nullptr; -UIImageView* g_imageHorns = nullptr; -UIImageView* g_imageDissgreeNew = nullptr; -UILabel* g_callerNum = nullptr; -UILabel* g_callerDisplay = nullptr; -UILabel* g_callDuration = nullptr; -UILabel* g_currentTimes = nullptr; -UILabel* g_comingTimes = nullptr; -UILabel* g_newCallHints = nullptr; -UILabel* g_newCallNum = nullptr; - -void CallTimerCallBack(int data) -{ - GraphicService::GetInstance()->PostGraphicEvent(std::bind(CallTimerCallBackProc, data)); -} - -void CallTimerCallBackProc(int data) -{ - if (g_callDuration != nullptr) { - g_callDuration->SetText(CallerLogModel::GetInstance()->DisplayCallDuration().c_str()); - } -} - -void CallCurTimerCallBack(int data) -{ - if (g_currentTimes != nullptr) { - g_currentTimes->SetText(CallerLogModel::GetInstance()->InitDateHourTime().c_str()); - } -} - -void StartCallTimer(CallTimerType type, int32_t interval) -{ - uint32_t tick; - osStatus_t retTimer; - if (type >= CallTimerType::NOTIFY_PHONE_UNKNOWN) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartCallTimer type:%d invalid!!", type); - return; - } - switch (type) { - case CallTimerType::NOTIFY_PHONE_CALLING_DISPLAY: - g_callDurationTimer = osTimerNew((osTimerFunc_t)CallTimerCallBack, osTimerPeriodic, nullptr, nullptr); - tick = osMs2Tick(interval); - retTimer = osTimerStart(g_callDurationTimer, tick); - if (retTimer != osOK && g_callDurationTimer != nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, - "StartCallTimer osTimerStart failed, type = %d ret = %lx!!", type, retTimer); - osTimerDelete(g_callDurationTimer); - g_callDurationTimer = nullptr; - return; - } - break; - case CallTimerType::NOTIFY_PHONE_CURTIME_DISPLAY: - g_callCurrentTime = osTimerNew((osTimerFunc_t)CallCurTimerCallBack, osTimerPeriodic, nullptr, nullptr); - tick = osMs2Tick(interval); - retTimer = osTimerStart(g_callCurrentTime, tick); - if (retTimer != osOK && g_callCurrentTime != nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, - "StartCallTimer osTimerStart failed, type = %d ret = %lx!!", type, retTimer); - osTimerDelete(g_callCurrentTime); - g_callCurrentTime = nullptr; - return; - } - break; - default: - break; - } -} - -void DisableCallTimer(CallTimerType type) -{ - if (type >= CallTimerType::NOTIFY_PHONE_UNKNOWN) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisableCallTimer type:%d invalid!!", type); - return; - } - osStatus_t ret; - switch (type) { - case CallTimerType::NOTIFY_PHONE_CALLING_DISPLAY: - if (g_callDurationTimer != nullptr) { - ret = osTimerDelete(g_callDurationTimer); - if (ret != osOK) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisableCallTimer failed, type= %d ret = %lx!", type, ret); - return; - } - g_callDurationTimer = nullptr; - } - break; - case CallTimerType::NOTIFY_PHONE_CURTIME_DISPLAY: - if (g_callCurrentTime != nullptr) { - ret = osTimerDelete(g_callCurrentTime); - if (ret != osOK) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisableCallTimer failed, type= %d ret = %lx!", type, ret); - return; - } - g_callCurrentTime = nullptr; - } - break; - default: - break; - } -} - -void HonrsViewChange(void) -{ - if (g_volumeSetting == nullptr) { - g_volumeSetting = new VolumeSettingView(); - if (g_volumeSetting == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "makephone_notification::g_volumeSetting nullptr err"); - return; - } - if (!g_volumeSetting->SetUpVolume()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "makephone_notification::g_volumeSetting SetUpVolume fail"); - return; - } - g_volumeSetting->GetProgress()->SetValue( - AudioManager::GetInstance().GetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO)); - if (AudioManager::GetInstance().GetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO) == 0) { - ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_MUTE_BUTTON, PLAYER_IAMGES); - g_volumeSetting->GetDecreaseButton()->SetImageSrc(image, image); - } - NotificationManager::GetInstance()->screenContainer_->Add(g_volumeSetting); - } - VolumeSliderEventListener *volumeSliderEventListener = g_volumeSetting->GetVolumeEventListener(); - if (volumeSliderEventListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "makephone_notification::volumeSliderEventListener nullptr err"); - return; - } - - volumeSliderEventListener->SetPlayerCoefficients(VOLUMEPHONENOTIFY); // 进度条系数 - g_volumeSetting->SetVisible(true); - // 刷新UI - RootView::GetInstance()->Invalidate(); -} -VolumeSettingView *GetvolumeSetting(void) -{ - return g_volumeSetting; -} - -static void FreeCallingViewImage(void) -{ - if (g_imageMicrophone != nullptr) { - delete g_imageMicrophone; - g_imageMicrophone = nullptr; - } - if (g_imageHandUp != nullptr) { - delete g_imageHandUp; - g_imageHandUp = nullptr; - } - if (g_imageHorns != nullptr) { - delete g_imageHorns; - g_imageHorns = nullptr; - } -} - -static bool DrawCallingViewImage(void) -{ - g_imageMicrophone = new UIImageView(); - if (g_imageMicrophone == nullptr) { - return false; - } - g_imageMicrophone->SetPosition(IMAGE_MIC_POSITION_X, IMAGE_ALL_POSITION_Y); - g_imageMicrophone->SetSrc(PNG_MICROPHONE_OPEN_IMAGE_PATH); - g_imageMicrophone->SetTouchable(true); - g_imageMicrophone->SetViewId("microphoneChange"); - - g_imageHandUp = new UIImageView(); - if (g_imageHandUp == nullptr) { - FreeCallingViewImage(); - return false; - } - g_imageHandUp->SetPosition(IMAGE_HANDUP_POSITION_X, IMAGE_ALL_POSITION_Y); - g_imageHandUp->SetSrc(PNG_DISSGREE_IMAGE_PATH); - g_imageHandUp->SetTouchable(true); - g_imageHandUp->SetViewId("callingHandUp"); - - g_imageHorns = new UIImageView(); - if (g_imageHorns == nullptr) { - FreeCallingViewImage(); - return false; - } - g_imageHorns->SetPosition(IMAGE_HONRS_POSITION_X, IMAGE_HONRS_POSITION_Y); - g_imageHorns->SetSrc(PNG_SOUNDBUTTON2); - g_imageHorns->SetTouchable(true); - g_imageHorns->SetViewId("volumeSwitch"); - - return true; -} - -static void FreeCallingViewUILabel(void) -{ - if (g_callerDisplay != nullptr) { - delete g_callerDisplay; - g_callerDisplay = nullptr; - } - if (g_callDuration != nullptr) { - delete g_callDuration; - g_callDuration = nullptr; - } - if (g_currentTimes != nullptr) { - delete g_currentTimes; - g_currentTimes = nullptr; - } -} - -static bool DrawCallingViewUILabel(void) -{ - g_callerDisplay = new UILabel(); - if (g_callerDisplay == nullptr) { - return false; - } - g_callerDisplay->SetPosition(LABEL_PERCENT_POSITION_X, LABEL_PERCENT_POSITION_Y, - Screen::GetInstance().GetWidth(), TITLE_LABEL_DEFAULT_HEIGHT); - g_callerDisplay->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - g_callerDisplay->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); - g_callerDisplay->SetAlign(TEXT_ALIGNMENT_CENTER); - g_callerDisplay->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CALLER_SIZE); - g_callerDisplay->SetTextColor(Color::White()); - - g_callDuration = new UILabel(); - if (g_callDuration == nullptr) { - FreeCallingViewUILabel(); - return false; - } - g_callDuration->SetPosition(LABEL_CALLERD_POSITION_X, LABEL_CALLERD_POSITION_Y, - Screen::GetInstance().GetWidth(), TITLE_LABEL_DEFAULT_HEIGHT); - g_callDuration->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - g_callDuration->SetAlign(TEXT_ALIGNMENT_CENTER); - g_callDuration->SetText(CallerLogModel::GetInstance()->DisplayCallDuration().c_str()); - g_callDuration->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CURRENT_SIZE); - g_callDuration->SetTextColor(Color::White()); - - g_currentTimes = new UILabel(); - if (g_currentTimes == nullptr) { - FreeCallingViewUILabel(); - return false; - } - g_currentTimes->SetPosition(LABEL_CURREMTTIME_POSITION_X, LABEL_CURREMTTIME_POSITION_Y, - Screen::GetInstance().GetWidth(), TITLE_LABEL_DEFAULT_HEIGHT); - g_currentTimes->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - g_currentTimes->SetAlign(TEXT_ALIGNMENT_CENTER); - g_currentTimes->SetText(CallerLogModel::GetInstance()->InitDateHourTime().c_str()); - g_currentTimes->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CURRENT_SIZE); - g_currentTimes->SetTextColor(Color::White()); - - return true; -} - -static bool DrawWaitingHintsViewImage(void) -{ - g_imageDissgreeNew = new UIImageView(); - if (g_imageDissgreeNew == nullptr) { - FreeCallingViewImage(); - return false; - } - g_imageDissgreeNew->SetPosition(IMAGE_HANDUP2_POSITION_X, IMAGE_HANDUP2_POSITION_Y); - g_imageDissgreeNew->SetSrc(PNG_DISSGREE_IMAGE_PATH); - g_imageDissgreeNew->SetTouchable(true); - g_imageDissgreeNew->SetViewId("newCallHandUp"); - return true; -} - -static void FreeWaitingHintsViewImage(void) -{ - if (g_imageDissgreeNew != nullptr) { - delete g_imageDissgreeNew; - g_imageDissgreeNew = nullptr; - } -} - -static void FreeWaitingHintsViewLabel(void) -{ - if (g_newCallNum != nullptr) { - delete g_newCallNum; - g_newCallNum = nullptr; - } - if (g_newCallHints != nullptr) { - delete g_newCallHints; - g_newCallHints = nullptr; - } -} - -static bool DrawWaitingHintsViewLabel(void) -{ - g_newCallNum = new UILabel(); - if (g_newCallNum == nullptr) { - return false; - } - g_newCallNum->SetPosition(LABEL_PERCENT_POSITION_X, LABEL_PERCENT_POSITION_Y, - Screen::GetInstance().GetWidth(), TITLE_LABEL_DEFAULT_HEIGHT); - g_newCallNum->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - g_newCallNum->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); - g_newCallNum->SetAlign(TEXT_ALIGNMENT_CENTER); - g_newCallNum->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CALLER_SIZE); - g_newCallNum->SetTextColor(Color::White()); - - g_newCallHints = new UILabel(); - if (g_newCallHints == nullptr) { - FreeWaitingHintsViewLabel(); - return false; - } - g_newCallHints->SetPosition(LABEL_NEWCALLERD_POSITION_X, LABEL_NEWCALLERD_POSITION_Y, - Screen::GetInstance().GetWidth(), TITLE_LABEL_DEFAULT_HEIGHT); - g_newCallHints->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - g_newCallHints->SetText("新来电"); - g_newCallHints->SetAlign(TEXT_ALIGNMENT_CENTER); - g_newCallHints->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CALLER_SIZE); - g_newCallHints->SetTextColor(Color::White()); - return true; -} - -static void FreePhoneCallViewImage(void) -{ - if (g_imageAgree != nullptr) { - delete g_imageAgree; - g_imageAgree = nullptr; - } - if (g_imageDissgree != nullptr) { - delete g_imageDissgree; - g_imageDissgree = nullptr; - } -} - -static bool DrawPhoneCallViewImage(void) -{ - g_imageAgree = new UIImageView(); - if (g_imageAgree == nullptr) { - return false; - } - g_imageAgree->SetPosition(IMAGE_AGREEING_POSITION_X, IMAGE_ALL_POSITION_Y); - g_imageAgree->SetSrc(PNG_AGREEING_IMAGE_PATH); - g_imageAgree->SetTouchable(true); - g_imageAgree->SetViewId("answer"); - UIView::OnClickListener *clickListener = static_cast\ - (OHOS::CallViewEventListener::GetInstance()); - g_imageAgree->SetOnClickListener(clickListener); - g_imageDissgree = new UIImageView(); - if (g_imageDissgree == nullptr) { - FreePhoneCallViewImage(); - return false; - } - g_imageDissgree->SetPosition(IMAGE_DISSGREE_POSITION_X, IMAGE_ALL_POSITION_Y); - g_imageDissgree->SetSrc(PNG_DISSGREE_IMAGE_PATH); - g_imageDissgree->SetTouchable(true); - g_imageDissgree->SetViewId("displayHandUp"); - g_imageDissgree->SetOnClickListener(clickListener); - return true; -} - -static void FreePhoneCallViewLabel(void) -{ - if (g_callerNum != nullptr) { - delete g_callerNum; - g_callerNum = nullptr; - } - if (g_comingTimes != nullptr) { - delete g_comingTimes; - g_comingTimes = nullptr; - } -} - -static bool DrawPhoneCallViewLabel(void) -{ - g_callerNum = new UILabel(); - if (g_callerNum == nullptr) { - return false; - } - g_callerNum->SetPosition(LABEL_COMINGVIEW_POSITION_X, LABEL_COMINGVIEW_POSITION_Y, - Screen::GetInstance().GetWidth(), TITLE_LABEL_DEFAULT_HEIGHT); - g_callerNum->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "CreatePhoneCallView phonenum:%s!", - CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); - g_callerNum->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); - g_callerNum->SetAlign(TEXT_ALIGNMENT_CENTER); - g_callerNum->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CALLER_SIZE); - g_callerNum->SetTextColor(Color::White()); - - g_comingTimes = new UILabel(); - if (g_comingTimes == nullptr) { - FreePhoneCallViewLabel(); - return false; - } - g_comingTimes->SetPosition(LABEL_COMINGTIME_POSITION_X, LABEL_COMINGTIME_POSITION_Y, - Screen::GetInstance().GetWidth(), TITLE_LABEL_DEFAULT_HEIGHT); - g_comingTimes->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - g_comingTimes->SetAlign(TEXT_ALIGNMENT_CENTER); - g_comingTimes->SetText(CallerLogModel::GetInstance()->InitDateHourTime().c_str()); - g_comingTimes->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CURRENT_SIZE); - g_comingTimes->SetTextColor(Color::White()); - return true; -} - -UIViewGroup* CreatePhoneCallView(void) -{ - g_phoneView = new UIViewGroup(); - if (g_phoneView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreatePhoneCallView g_phoneView null!"); - return nullptr; - } - g_phoneView->SetPosition(MATH_ZERO, MATH_ZERO); - g_phoneView->SetWidth(Screen::GetInstance().GetWidth()); - g_phoneView->SetHeight(Screen::GetInstance().GetHeight()); - if (!DrawPhoneCallViewImage()) { - delete g_phoneView; - g_phoneView = nullptr; - return nullptr; - } - if (!DrawPhoneCallViewLabel()) { - FreePhoneCallViewImage(); - delete g_phoneView; - g_phoneView = nullptr; - return nullptr; - } - g_phoneView->Add(g_imageAgree); - g_phoneView->Add(g_imageDissgree); - g_phoneView->Add(g_callerNum); - g_phoneView->Add(g_comingTimes); - g_phoneView->SetDraggable(true); - g_phoneView->SetTouchable(true); - NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreePhoneCallView); - return g_phoneView; -} - -void FreePhoneCallView(void) -{ - if (g_phoneView != nullptr) { - g_phoneView->RemoveAll(); - FreePhoneCallViewImage(); - FreePhoneCallViewLabel(); - RootView::GetInstance()->Remove(g_phoneView); - delete g_phoneView; - g_phoneView = nullptr; - } -} - -UIViewGroup* CreateMultiplePhoneView(void) -{ - g_multiPhoneView = new UIViewGroup(); - if (g_multiPhoneView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateMultiplePhoneView g_multiPhoneView null!"); - return nullptr; - } - g_multiPhoneView->SetPosition(MATH_ZERO, MATH_ZERO); - g_multiPhoneView->SetWidth(Screen::GetInstance().GetWidth()); - g_multiPhoneView->SetHeight(Screen::GetInstance().GetHeight()); - if (!DrawCallingViewImage()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateMultiplePhoneView create image error!"); - delete g_multiPhoneView; - g_multiPhoneView = nullptr; - return nullptr; - } - if (!DrawCallingViewUILabel()) { - FreeCallingViewImage(); - delete g_multiPhoneView; - g_multiPhoneView = nullptr; - return nullptr; - } - g_callerDisplay->SetText("正在通话"); - g_callDuration->SetText(""); - g_multiPhoneView->Add(g_imageMicrophone); - g_multiPhoneView->Add(g_imageHandUp); - g_multiPhoneView->Add(g_imageHorns); - g_multiPhoneView->Add(g_callerDisplay); - g_multiPhoneView->Add(g_callDuration); - g_multiPhoneView->Add(g_currentTimes); - g_multiPhoneView->SetDraggable(true); - g_multiPhoneView->SetTouchable(true); - UIView::OnClickListener *clickListener = static_cast\ - (OHOS::CallViewEventListener::GetInstance()); - g_imageMicrophone->SetOnClickListener(clickListener); - g_imageHandUp->SetOnClickListener(clickListener); - g_imageHorns->SetOnClickListener(clickListener); - StartCallTimer(CallTimerType::NOTIFY_PHONE_CURTIME_DISPLAY, NOTIFY_THIRTY_SECONDS); - NotificationManager::GetInstance()->SetVolumeScreenStatus(false); - NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeMultiplePhoneCallView); - return g_multiPhoneView; -} - -void FreeMultiplePhoneCallView(void) -{ - if (g_multiPhoneView != nullptr) { - DisableCallTimer(CallTimerType::NOTIFY_PHONE_CURTIME_DISPLAY); - g_multiPhoneView->RemoveAll(); - FreeCallingViewImage(); - FreeCallingViewUILabel(); - RootView::GetInstance()->Remove(g_multiPhoneView); - delete g_multiPhoneView; - g_multiPhoneView = nullptr; - } - if (g_volumeSetting != nullptr) { - delete g_volumeSetting; - g_volumeSetting = nullptr; - } -} - -UIViewGroup* CreateCallingView(void) -{ - g_callingView = new UIViewGroup(); - if (g_callingView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateCallingView g_callingView null!"); - return nullptr; - } - g_callingView->SetPosition(MATH_ZERO, MATH_ZERO); - g_callingView->SetWidth(Screen::GetInstance().GetWidth()); - g_callingView->SetHeight(Screen::GetInstance().GetHeight()); - if (!DrawCallingViewImage()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateCallingView create image error!"); - delete g_callingView; - g_callingView = nullptr; - return nullptr; - } - if (!DrawCallingViewUILabel()) { - FreeCallingViewImage(); - delete g_callingView; - g_callingView = nullptr; - return nullptr; - } - g_callingView->Add(g_imageMicrophone); - g_callingView->Add(g_imageHandUp); - g_callingView->Add(g_imageHorns); - g_callingView->Add(g_callerDisplay); - g_callingView->Add(g_callDuration); - g_callingView->Add(g_currentTimes); - g_callingView->SetDraggable(true); - g_callingView->SetTouchable(true); - UIView::OnClickListener *clickListener = static_cast\ - (OHOS::CallViewEventListener::GetInstance()); - g_imageMicrophone->SetOnClickListener(clickListener); - g_imageHandUp->SetOnClickListener(clickListener); - g_imageHorns->SetOnClickListener(clickListener); - StartCallTimer(CallTimerType::NOTIFY_PHONE_CALLING_DISPLAY, NOTIFY_ONE_SECOND); - StartCallTimer(CallTimerType::NOTIFY_PHONE_CURTIME_DISPLAY, NOTIFY_THIRTY_SECONDS); - NotificationManager::GetInstance()->SetVolumeScreenStatus(false); - NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeCallingView); - return g_callingView; -} - -void FreeCallingView(void) -{ - if (g_callingView != nullptr) { - DisableCallTimer(CallTimerType::NOTIFY_PHONE_CALLING_DISPLAY); - DisableCallTimer(CallTimerType::NOTIFY_PHONE_CURTIME_DISPLAY); - g_callingView->RemoveAll(); - FreeCallingViewImage(); - FreeCallingViewUILabel(); - RootView::GetInstance()->Remove(g_callingView); - delete g_callingView; - g_callingView = nullptr; - } - if (g_volumeSetting != nullptr) { - delete g_volumeSetting; - g_volumeSetting = nullptr; - } -} - -UIViewGroup* CreateWaitingHintsView(void) -{ - g_waitingHintsView = new UIViewGroup(); - if (g_waitingHintsView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateWaitingHintsView g_waitingHintsView null!"); - return nullptr; - } - g_waitingHintsView->SetPosition(MATH_ZERO, MATH_ZERO); - g_waitingHintsView->SetWidth(Screen::GetInstance().GetWidth()); - g_waitingHintsView->SetHeight(Screen::GetInstance().GetHeight()); - if (!DrawWaitingHintsViewImage()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateWaitingHintsView create image error!"); - delete g_waitingHintsView; - g_waitingHintsView = nullptr; - return nullptr; - } - if (!DrawWaitingHintsViewLabel()) { - FreeWaitingHintsViewImage(); - delete g_waitingHintsView; - g_waitingHintsView = nullptr; - return nullptr; - } - g_waitingHintsView->Add(g_imageDissgreeNew); - g_waitingHintsView->Add(g_newCallNum); - g_waitingHintsView->Add(g_newCallHints); - g_waitingHintsView->SetDraggable(true); - g_waitingHintsView->SetTouchable(true); - UIView::OnClickListener *clickListener = static_cast\ - (OHOS::CallViewEventListener::GetInstance()); - g_imageDissgreeNew->SetOnClickListener(clickListener); - NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeWaitingHintsView); - return g_waitingHintsView; -} - -void FreeWaitingHintsView(void) -{ - if (g_waitingHintsView != nullptr) { - g_waitingHintsView->RemoveAll(); - FreeWaitingHintsViewImage(); - FreeWaitingHintsViewLabel(); - RootView::GetInstance()->Remove(g_waitingHintsView); - delete g_waitingHintsView; - g_waitingHintsView = nullptr; - } -} - -void RefreshMicrophoneImageSrc(const char* src) -{ - g_imageMicrophone->SetSrc(src); -} - -void EnableWaitingView(void) -{ - if (g_waitingHintsView == nullptr) { - CreateWaitingHintsView(); - } - if (NotificationManager::GetInstance()->screenContainer_ != nullptr) { - NotificationManager::GetInstance()->screenContainer_->SetVisible(false); - } - RootView::GetInstance()->Add(g_waitingHintsView); - g_waitingHintsView->SetVisible(true); - RootView::GetInstance()->Invalidate(); -} - -void DisableWatingView(void) -{ - if (g_waitingHintsView != nullptr) { - g_waitingHintsView->SetVisible(false); - FreeWaitingHintsView(); - if (NotificationManager::GetInstance()->screenContainer_ != nullptr) { - NotificationManager::GetInstance()->screenContainer_->SetVisible(true); - } - RootView::GetInstance()->Invalidate(); - } -} - -bool HintsHandupClick(void) -{ - if (RejectIncomingCall() != 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[HintsHandupClick] RejectIncomingCall error"); - return false; - } - CallerLogModel::GetInstance()->SetWaitingStatus(false); - CallerLogModel::GetInstance()->SetCallStatus(true); - - return true; -} - -CallViewEventListener::CallViewEventListener() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallViewEventListener :%p", this); -} - -CallViewEventListener::~CallViewEventListener() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "~CallViewEventListener"); -} - -CallViewEventListener *CallViewEventListener::GetInstance(void) -{ - static CallViewEventListener callViewEventListener; - return &callViewEventListener; -} - -bool CallViewEventListener::OnClick(UIView& view, const ClickEvent& event) -{ - UNUSED(event); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MakephoneNotify ClickListener %s", view.GetViewId()); - if (strcmp(view.GetViewId(), "answer") == 0) { - // watch answer the call - if (AcceptIncomingCall() != 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AcceptIncomingCall() fail"); - return false; - } - return true; - } else if (strcmp(view.GetViewId(), "displayHandUp") == 0 || - strcmp(view.GetViewId(), "callingHandUp") == 0) { - if (strcmp(view.GetViewId(), "displayHandUp") == 0) { - // The watch rejects the call - if (RejectIncomingCall() != 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RejectIncomingCall() fail"); - return false; - } - } - if (FinishCall() != 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FinishCall() fail"); - return false; - } - return true; - } else if (strcmp(view.GetViewId(), "microphoneChange") == 0) { - if (g_changeImage == 0) { - g_changeImage = 1; - RefreshMicrophoneImageSrc(PNG_MICROPHONE_CLOSE_IMAGE_PATH); - SetMicMute(true); - } else { - g_changeImage = 0; - RefreshMicrophoneImageSrc(PNG_MICROPHONE_OPEN_IMAGE_PATH); - SetMicMute(false); - } - return true; - } else if (strcmp(view.GetViewId(), "volumeSwitch") == 0) { - HonrsViewChange(); - } else if (strcmp(view.GetViewId(), "newCallHandUp") == 0) { - if (!HintsHandupClick()) { - return false; - } - } - if (strcmp(view.GetViewId(), "SOS_FAIL") == 0) { - NotificationManager::GetInstance()->StopNotify(); - } - - return true; -} -} // namespace OHOS diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/include/ConnectOpenView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/include/ConnectOpenView.h deleted file mode 100644 index 0560c8af5..000000000 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/include/ConnectOpenView.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: ConnectOpen View - * Create: 2022-03-22 - */ -#ifndef CONNECT_OPEN_VIEW_H -#define CONNECT_OPEN_VIEW_H - -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_label_button.h" -#include "components/ui_image_view.h" - -namespace OHOS { -class ConnectOpenView { -public: - ConnectOpenView(); - ~ConnectOpenView(); - static ConnectOpenView *GetInstance(); - UIViewGroup *InitShowUpView(void); - -private: - void ShowUpBackView(void); - UILabel *titleLabel{nullptr}; - UILabel *watchNameLabel{nullptr}; - UILabelButton *backButton{nullptr}; - UIImageView *tipImg{nullptr}; - UIViewGroup *group{nullptr}; -}; -} // namespace OHOS -#endif // CONNECT_OPEN_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/include/ConnectPhonePresenter.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/include/ConnectPhonePresenter.h deleted file mode 100644 index 2167c081c..000000000 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/include/ConnectPhonePresenter.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Connect Phone Presenter - * Create: 2022-01-19 - */ - -#ifndef CONNECT_PHONE_PRESENTER_H -#define CONNECT_PHONE_PRESENTER_H - -#include "key/include/KeyInputListener.h" -#include "Presenter.h" -#include "connectnewphone/include/ConnectOpenView.h" -#include "NativeLauncher.h" -#include "NativeAbility.h" - -namespace OHOS { -enum ConnectPhonePresenterNum : uint8_t { - CONNECTSELECTVIEW = 0, - CONNECTOPENVIEW, - CONNECTPHONE_MAX, -}; - -#define CANCEL_BUTTON "cancelButton" -#define CONFIRM_BUTTON "confirmButton" -#define CONNECT_OPEN_BACK_BUTTON "backButton" - -#define CONNECT_SELECT_VIEW "connectSelectView" -#define CONNECT_OPEN_VIEW "connectOpenView" - -class ConnectPhoneView; -class ConnectPhonePresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener { -public: - ConnectPhonePresenter(); - ~ConnectPhonePresenter(); - static ConnectPhonePresenter *GetInstance(); - bool OnClick(UIView& view, const ClickEvent& event) override; - bool OnDrag(UIView& view, const DragEvent& event) override; - void ConfirmOnClick(); -private: -}; -} // namespace OHOS -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/include/ConnectPhoneView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/include/ConnectPhoneView.h deleted file mode 100644 index 834ad8e06..000000000 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/include/ConnectPhoneView.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Connect Phone View - * Create: 2022-01-19 - */ - -#ifndef CONNECT_PHONE_VIEW_H -#define CONNECT_PHONE_VIEW_H - -#include "View.h" -#include "connectnewphone/include/ConnectPhonePresenter.h" -#include "ConnectSelectView.h" -#include "AppGroupView.h" - -namespace OHOS { -constexpr int16_t NUM_CONNECT_PHONE_CONTAINER = 2; - -class ConnectPhonePresenter; -class ConnectPhoneView : public View { -public: - ConnectPhoneView(); - ~ConnectPhoneView() override; - static ConnectPhoneView *GetInstance(); - void OnStart() override; - void ChangeView(int16_t hideView, int16_t showView); - -private: - bool ChangeConnectSelectView(int16_t hideView, int16_t thisView); - bool ChangeConnectOpenView(int16_t hideView, int16_t thisView); - bool CheckViewParam(int16_t hideView, int16_t showView); - ConnectSelectView *connectSelectView{nullptr}; - ConnectOpenView *connectOpenView{nullptr}; - UIViewGroup *container[NUM_CONNECT_PHONE_CONTAINER]{nullptr}; - typedef bool (ConnectPhoneView::*PreprosssChangeView)(int16_t hideView, int16_t thisView); - PreprosssChangeView preProcessView[NUM_CONNECT_PHONE_CONTAINER]; -}; -} // namespace OHOS -#endif // DISCONNECT_PHONE_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/include/ConnectSelectView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/include/ConnectSelectView.h deleted file mode 100644 index 263be0e03..000000000 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/include/ConnectSelectView.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: ConnectSelect View - * Create: 2022-03-22 - */ - -#ifndef CONNECT_SELECT_VIEW_H -#define CONNECT_SELECT_VIEW_H - -#include "View.h" -#include "connectnewphone/include/ConnectPhonePresenter.h" -#include "components/ui_label.h" -#include "components/ui_button.h" -#include "components/ui_view_group.h" - -namespace OHOS { -class ConnectSelectView { -public: - ConnectSelectView(); - ~ConnectSelectView(); - static ConnectSelectView *GetInstance(); - UIViewGroup *InitShowUpView(void); - -private: - void ShowUpTitleLabel(void); - void CreateUIButton(void); - UILabel *titleLabel{nullptr}; - UIButton *cancelButton{nullptr}; - UIButton *confirmButton{nullptr}; - UIViewGroup *group{nullptr}; -}; -} // namespace OHOS -#endif // CONNECT_SELECT_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/src/ConnectOpenView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/src/ConnectOpenView.cpp deleted file mode 100644 index 23e80b29f..000000000 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/src/ConnectOpenView.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: ConnectOpen View - * Create: 2022-03-22 - */ -#include "connectnewphone/include/ConnectOpenView.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "connectnewphone/include/ConnectPhonePresenter.h" -#include "bluetooth/include/BluetoothModel.h" -#include "PageTransitionMgr.h" - -namespace OHOS { -static ConnectOpenView *g_pConnectOpenView{nullptr}; -ConnectOpenView::ConnectOpenView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectOpenView::ConnectOpenView"); - g_pConnectOpenView = this; -} - -ConnectOpenView::~ConnectOpenView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectOpenView::~ConnectOpenView"); - group->RemoveAll(); - delete titleLabel; - titleLabel = nullptr; - delete backButton; - backButton = nullptr; - delete group; - group = nullptr; - delete tipImg; - tipImg = nullptr; - g_pConnectOpenView = nullptr; -} - -ConnectOpenView *ConnectOpenView::GetInstance() -{ - return g_pConnectOpenView; -} - -void ConnectOpenView::ShowUpBackView() -{ - if (watchNameLabel == nullptr) { - watchNameLabel = new UILabel(); - if (watchNameLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectOpenView watchNameLabel new fail"); - return; - } - watchNameLabel->SetPosition(0, 165, HORIZONTAL_RESOLUTION, 45); // 0:x 244:y 454:width 45:height - watchNameLabel->SetText(BluetoothModel::GetInstance()->getWatchName()); - watchNameLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40:font data - watchNameLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - watchNameLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - group->Add(watchNameLabel); - } - - if (titleLabel == nullptr) { - titleLabel = new UILabel(); - if (titleLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectOpenView titleLabel new fail"); - return; - } - titleLabel->SetPosition(0, 244, HORIZONTAL_RESOLUTION, 45); // 0:x 244:y 454:width 45:height - titleLabel->SetText("连接已打开"); - titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40:font data - titleLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - titleLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - group->Add(titleLabel); - } - if (backButton == nullptr) { - backButton = new UILabelButton(); - if (backButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectOpenView backButton new fail"); - return; - } - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::ConnectPhonePresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance fail"); - return; - } - backButton->SetPosition(65, 359, 324, 101); // 65:x, 359:y, 324:width 101:height - backButton->SetText("确定"); - backButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40:font data - backButton->SetImageSrc(PNG_NEW_DEVICE, PNG_NEW_DEVICE); - backButton->SetViewId(CONNECT_OPEN_BACK_BUTTON); - backButton->SetTextColor(Color::Blue()); - backButton->SetOnClickListener(clickListener); - group->Add(backButton); - } - if (tipImg == nullptr) { - tipImg = new UIImageView(); - if (tipImg == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectOpenView tipImg new fail"); - return; - } - tipImg->SetPosition(181, 58, 90, 90); // 181:x 58:y 90:width 90:height - tipImg->SetSrc(PNG_RIGHT); - group->Add(tipImg); - } - return; -} - -UIViewGroup *ConnectOpenView::InitShowUpView(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectOpenView::ShowUpViewInit"); - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - ShowUpBackView(); - UIView::OnDragListener *tipsDragListener = (UIView::OnDragListener *)OHOS::ConnectPhonePresenter::GetInstance(); - if (tipsDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "tipsDragListener GetInstance fail"); - return nullptr; - } - if (PageTransitionMgr::GetInstance().GetTopSlideBackImage() == nullptr) { // support default slide back firstly - group->SetOnDragListener(tipsDragListener); - } - group->SetViewId(CONNECT_OPEN_VIEW); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/src/ConnectPhonePresenter.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/src/ConnectPhonePresenter.cpp deleted file mode 100644 index 8d228da67..000000000 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/src/ConnectPhonePresenter.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Connect Phone Presenter - * Create: 2022-01-19 - */ - -#include "connectnewphone/include/ConnectPhonePresenter.h" -#include "connectnewphone/include/ConnectPhoneView.h" -#include "drag_event.h" -#include "cmsis_os.h" -#include "UiConfig.h" -#include "wearable_log.h" -#include "uiservice/include/ui_service.h" -#include "NativeRegisterManager.h" - -namespace OHOS { - -REGIST_SLICE(VIEW_CONNECT_PHONE, ConnectPhoneView, ConnectPhonePresenter); - -static ConnectPhonePresenter *g_pConnectPhonePresenter = nullptr; - -ConnectPhonePresenter::ConnectPhonePresenter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectPhonePresenter::ConnectPhonePresenter"); - g_pConnectPhonePresenter = this; -} - -ConnectPhonePresenter::~ConnectPhonePresenter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectPhonePresenter::~ConnectPhonePresenter"); - g_pConnectPhonePresenter = nullptr; -} - -ConnectPhonePresenter *ConnectPhonePresenter::GetInstance() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectPhonePresenter GetInstance"); - return g_pConnectPhonePresenter; -} - -bool ConnectPhonePresenter::OnClick(UIView& view, const ClickEvent& event) -{ - UNUSED(event); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnClick OnClick"); - if (strcmp(view.GetViewId(), CANCEL_BUTTON) == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CANCEL_BUTTON OnClick"); - NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); - } else if (strcmp(view.GetViewId(), CONFIRM_BUTTON) == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CONFIRM_BUTTON OnClick"); - ConfirmOnClick(); - if (ConnectPhoneView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectPhoneView::GetInstance() nullptr"); - return false; - } - ConnectPhoneView::GetInstance()->ChangeView(CONNECTSELECTVIEW, CONNECTOPENVIEW); - } else if (strcmp(view.GetViewId(), CONNECT_OPEN_BACK_BUTTON) == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CONNECT_OPEN_BACK_BUTTON OnClick"); - NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); - } - return true; -} - -void ConnectPhonePresenter::ConfirmOnClick() -{ - // SendMsgToUIService(CONNECT_NEW_PHONE, 0, nullptr, 0); -} - -bool ConnectPhonePresenter::OnDrag(UIView& view, const DragEvent& event) -{ - std::string viewId = view.GetViewId(); - if ((viewId == CONNECT_SELECT_VIEW) || (viewId == CONNECT_OPEN_VIEW)) { - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectPhonePresenter::OnDrag"); - NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); - } - } - return true; -} - -} diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/src/ConnectPhoneView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/src/ConnectPhoneView.cpp deleted file mode 100644 index 943b546ac..000000000 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/src/ConnectPhoneView.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Connect Phone View - * Create: 2022-01-19 - */ - -#include "connectnewphone/include/ConnectPhoneView.h" -#include "components/ui_label.h" -#include "wearable_log.h" -#include "UiConfig.h" - -namespace OHOS { -static ConnectPhoneView *g_pConnectPhoneView{nullptr}; - -ConnectPhoneView::ConnectPhoneView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectPhoneView::ConnectPhoneView"); - preProcessView[CONNECTSELECTVIEW] = &ConnectPhoneView::ChangeConnectSelectView; - preProcessView[CONNECTOPENVIEW] = &ConnectPhoneView::ChangeConnectOpenView; - g_pConnectPhoneView = this; -} - -ConnectPhoneView::~ConnectPhoneView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectPhoneView::~ConnectPhoneView"); - g_pConnectPhoneView = nullptr; -} - -ConnectPhoneView *ConnectPhoneView::GetInstance() -{ - return g_pConnectPhoneView; -} - -void ConnectPhoneView::OnStart() -{ - ChangeView(CONNECTPHONE_MAX, CONNECTSELECTVIEW); - return; -} - - -bool ConnectPhoneView::ChangeConnectSelectView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeConnectSelectView"); - connectSelectView = new ConnectSelectView(); - if (connectSelectView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "connectSelectView new fail"); - return false; - } - // init view - UIViewGroup *group = connectSelectView->InitShowUpView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool ConnectPhoneView::ChangeConnectOpenView(int16_t hideView, int16_t thisView) -{ - UNUSED(hideView); - if (container[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeConnectOpenView"); - connectOpenView = new ConnectOpenView(); - if (connectOpenView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "connectOpenView new fail"); - return false; - } - // init view - UIViewGroup *group = connectOpenView->InitShowUpView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - AddViewToRootContainer(container[thisView]); - } - return true; -} - -bool ConnectPhoneView::CheckViewParam(int16_t hideView, int16_t showView) -{ - if (showView < 0 || showView >= CONNECTPHONE_MAX) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectPhoneView::CheckViewParam showView err."); - return false; - } - - if (hideView < 0 || hideView > CONNECTPHONE_MAX) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectPhoneView::CheckViewParam hideView err."); - return false; - } - - return true; -} - -void ConnectPhoneView::ChangeView(int16_t hideView, int16_t showView) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectPhoneView::ChangeView %d, %d", hideView, showView); - - if (!CheckViewParam(hideView, showView)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectPhoneView::CheckViewParam failed."); - return; - } - - PreprosssChangeView tmpPreProcessView = preProcessView[showView]; - - if (!(this->*tmpPreProcessView)(hideView, showView)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectPhoneView::ChangeView %d %dfailed", showView, hideView); - return; - } - if (hideView != CONNECTPHONE_MAX) { - if (container[hideView] == nullptr) { - return; - } - container[hideView]->SetVisible(false); - } - container[showView]->SetVisible(true); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectPhoneView:: ChangeView end!!!%d", showView); - Draw(); -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/src/ConnectSelectView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/src/ConnectSelectView.cpp deleted file mode 100644 index 0723cdb02..000000000 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/connectnewphone/src/ConnectSelectView.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: ConnectSelect View - * Create: 2022-03-22 - */ -#include "connectnewphone/include/ConnectSelectView.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "connectnewphone/include/ConnectPhonePresenter.h" -#include "PageTransitionMgr.h" - -namespace OHOS { -static ConnectSelectView *g_pConnectSelectView{nullptr}; - -ConnectSelectView::ConnectSelectView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectSelectView::ConnectSelectView"); - g_pConnectSelectView = this; -} - -ConnectSelectView::~ConnectSelectView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectSelectView::~ConnectSelectView"); - group->RemoveAll(); - delete titleLabel; - titleLabel = nullptr; - delete cancelButton; - cancelButton = nullptr; - delete confirmButton; - confirmButton = nullptr; - g_pConnectSelectView = nullptr; -} - -ConnectSelectView *ConnectSelectView::GetInstance() -{ - return g_pConnectSelectView; -} - -void ConnectSelectView::ShowUpTitleLabel() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectSelectView::ShowUpTitleLabel"); - if (titleLabel == nullptr) { - titleLabel = new UILabel(); - if (titleLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectSelectView titleLabel new fail"); - return; - } - titleLabel->SetPosition(65, 100, 324, 160); // 65:x, 100:y, 324:width, 160:height - titleLabel->SetText(" 将断开已连接的手 机,同一账号的新手机配对会保留个人数 据。是否继续?"); - titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); // 35:font data - titleLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - titleLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - group->Add(titleLabel); - } -} - -void ConnectSelectView::CreateUIButton() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectSelectView::CreateUIButton"); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::ConnectPhonePresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener nullptr"); - return; - } - if (cancelButton == nullptr) { - cancelButton = new UIButton(); - if (cancelButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectSelectView cancelButton new fail"); - return; - } - cancelButton->SetPosition(85, 320, 90, 90); // 85:x, 320:y, 90:width, 90:height - cancelButton->SetViewId(CANCEL_BUTTON); - cancelButton->SetImageSrc(ALARM_DELETE_ADD_PATH, ALARM_DELETE_ADD_PATH); - cancelButton->SetOnClickListener(clickListener); - group->Add(cancelButton); - } - if (confirmButton == nullptr) { - confirmButton = new UIButton(); - if (confirmButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectSelectView confirmButton new fail"); - return; - } - confirmButton->SetPosition(279, 320, 90, 90); // 279:x, 320:y, 90:width, 90:height - confirmButton->SetViewId(CONFIRM_BUTTON); - confirmButton->SetImageSrc(ALARM_TRUE_ADD_PATH, ALARM_TRUE_ADD_PATH); - confirmButton->SetOnClickListener(clickListener); - group->Add(confirmButton); - } -} - -UIViewGroup *ConnectSelectView::InitShowUpView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectSelectView init"); - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - ShowUpTitleLabel(); - CreateUIButton(); - UIView::OnDragListener *connectDragListener = (UIView::OnDragListener *)OHOS::ConnectPhonePresenter::GetInstance(); - if (connectDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "connectDragListener GetInstance fail"); - return nullptr; - } - if (PageTransitionMgr::GetInstance().GetTopSlideBackImage() == nullptr) { // support default slide back firstly - group->SetOnDragListener(connectDragListener); - } - group->SetViewId(CONNECT_SELECT_VIEW); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/src/HeartModel.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/src/HeartModel.cpp deleted file mode 100644 index 044aba69d..000000000 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/src/HeartModel.cpp +++ /dev/null @@ -1,1105 +0,0 @@ -#include "heartrate/include/HeartModel.h" -#include "indoorwalk/include/IndoorWalkPreparedView.h" -#include "indoorwalk/include/IndoorWalkPresenter.h" -#include "main/include/MainViewSample.h" -#include "graphic_service.h" -#include "wearable_log.h" - -#include "main/include/dial/DialModelHeartRate.h" -#include "heartrate/include/HeartChartView.h" -#include "heartrate/include/HeartDetectionPresenter.h" -#include "heartrate/include/HeartRateView.h" -#include "heartrate/include/HeartResultPresenter.h" - -#include "ConfigModel.h" -#include "main/include/dial/DialModelHeartRate.h" -#include "custom_runtime.h" -#include "custom_utils.h" - -#include "health/health_service/health_service.h" -#include - -#ifdef SUPPORT_PPG_SERVICE -#include "ppg_hal.h" -#include "ppg_service.h" -#endif - -#include "settings/include/SettingModel.h" -#include "uiservice/include/ui_service.h" -#include "wearable_log.h" -#include - -#include "clock/include/MainClockView.h" - -#ifdef SUPPORT_BLE_SERVICE -#include "bleEvent.h" -#include "bleInstruct.h" -#include "bleService.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef SUPPORT_BATTERY_SERVICE -#include "battery_hal.h" -#endif - -#include "languagecode/LanguageInit.h" -#include "uiservice/include/ui_service.h" - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define MAX_UNWEAR_COUNT 2 -#define MAX_VALID_HRS_COUNT 10 //最大有效数 -#define MAX_DISVALID_HRS_COUNT 15 //最大无效数 -#define MIN_DISPLAY_HEART 50 //最新心率 -#define DISPLAY_COUNT 0 -#define HEARTTEST 1 //[0 开启测试 1 关闭] -#define KEEP_SCREEN_ON_HEART 1 -#define HEART_TIMER_DATA 1 - -/*佩戴检测结果*/ -enum { - SENSOR_WEAR_ON = 0, - SENSOR_WEAR_OFF, - SENSOR_WEAR_UNKNOW, - SENSOR_WEAR_MAX -}; - -using namespace OHOS; -#define LEN 32 - -static void Notify(void *args, const Topic topic, Request *request); - -Subscriber heartSubscirber = { - .identity = nullptr, - .args = nullptr, - .Notify = Notify, -}; -static void ProcessHeartRateUpdate(Request *request); -static void RefreshHeartData(); -void save_heart_maxmin(); -void HeartDataSubscribeTopic(Topic topic) { - BroadcastApi *broadcastApi = nullptr; - IUnknown *api = SAMGR_GetInstance()->GetFeatureApi(BROADCAST_SERVICE_NAME, - BROADCAST_FEATURE_NAME); - if (api == nullptr) { - return; - } - int result = - api->QueryInterface(api, DEFAULT_VERSION, (void **)&broadcastApi); - if (result != 0 || broadcastApi == nullptr) { - return; - } - int ret = broadcastApi->SubscribeTopic((IUnknown *)broadcastApi, topic, - &heartSubscirber); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartSubscribeTopic ret=%d,topic=%u", - ret, topic); - broadcastApi->Release((IUnknown *)broadcastApi); -} - -void HearDatatUnsubscribeTopic(Topic topic) { - BroadcastApi *broadcastApi = nullptr; - IUnknown *api = SAMGR_GetInstance()->GetFeatureApi(BROADCAST_SERVICE_NAME, - BROADCAST_FEATURE_NAME); - if (api == nullptr) { - return; - } - int result = - api->QueryInterface(api, DEFAULT_VERSION, (void **)&broadcastApi); - if (result != 0 || broadcastApi == nullptr) { - return; - } - broadcastApi->UnsubscribeTopic((IUnknown *)broadcastApi, topic, - &heartSubscirber); - broadcastApi->Release((IUnknown *)broadcastApi); -} - -static void Notify(void *args, const Topic topic, Request *request) { - UNUSED(args); - UNUSED(topic); - - // 训练过程中不需要判断数据准确性,不需要存储心率数据 - if (uapi_dev_runtime_get_train_status() == 1 || - uapi_dev_runtime_get_respiratory_training_status() || request == NULL) { - return; - } - if (request->msgId == TOPIC_EVENT_HEARTRATE_UPDATA) { - GraphicService::GetInstance()->PostGraphicEvent(std::bind( - &HeartModel::RefreshHeartRateScreen, HeartModel::GetInstance())); - } -} - -static void ProcessHeartRateUpdate(Request *request) { - uint16_t preheart = *reinterpret_cast(request->data); - - // 直接处理心率数据,不进行筛选 - uint16_t index_ = HeartModel::GetInstance()->GetIndex(); - HeartDatas *heartInfo = (HeartDatas *)malloc(sizeof(HeartDatas)); - if (heartInfo == NULL) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[Notify] malloc fail"); - return; - } - - heartInfo->index = index_; - heartInfo->maxX = index_; - heartInfo->minX = index_; - heartInfo->perSec = preheart; - heartInfo->rest = preheart; - /*最大最小值不为0*/ - heartInfo->maxValue = preheart; - heartInfo->minValue = preheart; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "heartRateData=%d%d", heartInfo->index, - preheart); - OHOS::HeartModel::GetInstance()->HeartRatePros(heartInfo); - - free(heartInfo); // 释放内存 - heartInfo = nullptr; -} - -static void RefreshHeartData() { - OHOS::HeartModel::GetInstance()->ClearHeartData(); - GraphicService::GetInstance()->PostGraphicEvent(std::bind( - &OHOS::HeartModel::Heart_Update_View, OHOS::HeartModel::GetInstance())); -} - -#ifdef __cplusplus -} -#endif - -namespace OHOS { -void HeartModel::ClearHeartData(void) { - pretime = 0; - entryTimes = 0; - aveCount = 0; - preMaxValue = 0; - preMaxX = NUM_1; - preMinValue = HEART_RATE_LIMIT_UPPER; - preMinX = NUM_1; - countMax = 0; - countMin = 0; - healthDatas.heartRateMax.x = (uint16_t)0XFFFF; - healthDatas.heartRateMax.y = 0; - healthDatas.heartRateMin.x = (uint16_t)0XFFFF; - healthDatas.heartRateMin.y = (uint16_t)0XFFFF; - for (int i = 0; i < HEART_AVE_NUM; i++) { - healthDatas.heartRateAvg[i].x = (uint16_t)0XFFFF; - healthDatas.heartRateAvg[i].y = (uint16_t)0XFFFF; - } - if (HeartRateView::GetInstance() != nullptr) { - HeartRateView::GetInstance()->ClearElectrocardiogram(); - } - SetAveHeartRateCount(0); - // GraphicService::GetInstance()->PostGraphicEvent( - // std::bind(&HeartModel::RefreshHeartRateScreen, - // HeartModel::GetInstance(), - // healthDatas.heartRatePerSec, healthDatas.heartRateRest, - // healthDatas.heartRateMax.y, healthDatas.heartRateMin.y)); -} - -HeartModel::HeartModel() { - /*初始化读取文件*/ - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartModel::HeartModel()"); - /*初始化历史文件*/ - HealthService::GetInstance()->LoadDailyHeartRate(); - /*读取上一次心率数据*/ - HeartRateData data; - HealthService::GetInstance()->ReadHeartRateData(data); - currentheart = data.Heart; - timestamp_ms = data.timestamp; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "currentheart %d timestamp_ms %d", - currentheart, timestamp_ms); - // 更新表盘心率数据 - DialModelHeartRate::GetInstance()->UpdateHeartRate(currentheart); - - //读取最大最小值 - HealthService::GetInstance()->LoadHeartMaxMin(displayheart_max, - displayheart_min); - // 配置动态数组 - SetArrayData(); -} - -HeartModel::~HeartModel() { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartModel::~HeartModel()"); - HearDatatUnsubscribeTopic(TOPIC_EVENT_HEARTRATE_UPDATA); - HearDatatUnsubscribeTopic(TOPIC_EVENT_NEXTDAY_UPDATE); - HearDatatUnsubscribeTopic(TOPIC_EVENT_UTCTIME_UPDATE); - HearDatatUnsubscribeTopic(TOPIC_EVENT_WEARSTATE_UPDATE); -} - -HeartModel *HeartModel::GetInstance(void) { - static HeartModel heartModel; - return &heartModel; -} -uint16_t HeartModel::GetIndex() { return index_; } -void HeartModel::SetIndex(uint16_t index) { index_ = index; } - -void HeartModel::Init(void) { - HeartDataSubscribeTopic(TOPIC_EVENT_HEARTRATE_UPDATA); - HeartDataSubscribeTopic(TOPIC_EVENT_NEXTDAY_UPDATE); - HeartDataSubscribeTopic(TOPIC_EVENT_UTCTIME_UPDATE); - HeartDataSubscribeTopic(TOPIC_EVENT_WEARSTATE_UPDATE); -} - -Point *HeartModel::GetAveHeartRate(void) { return healthDatas.heartRateAvg; } - -void HeartModel::HandleMaxHeart(uint16 coord, uint16 value) { - healthDatas.heartRateMax.x = coord; - healthDatas.heartRateMax.y = value; - // 插入最大心率 countMax 数据个数 - if (preMaxValue != healthDatas.heartRateMax.y && aveCount < HEART_AVE_NUM) { - if (preMaxX == healthDatas.heartRateMax.x && countMax < HEART_AVE_NUM) { - healthDatas.heartRateAvg[countMax].y = healthDatas.heartRateMax.y; - } else if (aveCount > NUM_2 && (healthDatas.heartRateMax.x == - healthDatas.heartRateAvg[aveCount - 1].x)) { - healthDatas.heartRateAvg[aveCount - 1].y = healthDatas.heartRateMax.y; - } else { - healthDatas.heartRateAvg[aveCount] = healthDatas.heartRateMax; - countMax = aveCount; - aveCount++; - } - if (healthDatas.heartRateMax.x != 0) { - if (healthDatas.heartRateAvg[0].x == 0 && - healthDatas.heartRateAvg[1].x == 0) { - for (int i = 1; i < (aveCount - 1); i++) { - healthDatas.heartRateAvg[i] = healthDatas.heartRateAvg[i + 1]; - } - aveCount--; - countMax--; - } - } - } - preMaxValue = healthDatas.heartRateMax.y; - preMaxX = healthDatas.heartRateMax.x; -} - -void HeartModel::HandleMinHeart(uint16 coord, uint16 value) { - // 最小心率 - healthDatas.heartRateMin.x = coord; - healthDatas.heartRateMin.y = value; - // 插入最小心率 - // avecount 当下有效数据个数,在MaxHeart中也用到,看起来似乎有问题??? - // preMinValue 上一个心率最小值 - // preMinX 上一个最小值对应的坐标 - // 当上一个值与当前值不等,且没有超过总数限制,则进行数据处理 - if (preMinValue != healthDatas.heartRateMin.y && aveCount < HEART_AVE_NUM) { - - if (preMinX == healthDatas.heartRateMin.x && countMin < HEART_AVE_NUM) { - // 上一个最小坐标和当前值一致,且数据没超过限制,则直接赋值给有效数据 - // countMin 即可 - healthDatas.heartRateAvg[countMin].y = healthDatas.heartRateMin.y; - } else if (aveCount > NUM_2 && (healthDatas.heartRateMin.x == - healthDatas.heartRateAvg[aveCount - 1].x)) { - // 有效数据大于2,且当前x值与原始数据最后一个x一致,最后一个数据赋值 - healthDatas.heartRateAvg[aveCount - 1].y = healthDatas.heartRateMin.y; - } else { - healthDatas.heartRateAvg[aveCount] = healthDatas.heartRateMin; - countMin = aveCount; - aveCount++; - } - - // 最初的值一直是0 ,则只显示1个 ,不会在后面增加数据。 - if (healthDatas.heartRateMin.x != 0) { - if (healthDatas.heartRateAvg[0].x == 0 && - healthDatas.heartRateAvg[1].x == 0) { - for (int i = 0; i < (aveCount - 1); i++) { - healthDatas.heartRateAvg[i] = healthDatas.heartRateAvg[i + 1]; - } - aveCount--; - countMin--; - } - } - } - preMinValue = healthDatas.heartRateMin.y; - preMinX = healthDatas.heartRateMin.x; -} - -void HeartModel::HeartRatePros(HeartDatas *heartInfo) { - uint16_t perSecHeartRate = 0; - uint16_t restHeartRate = 0; - - // 每秒心率 - perSecHeartRate = heartInfo->perSec; - if (perSecHeartRate >= HEART_RATE_LIMIT_LOWER && - perSecHeartRate <= HEART_RATE_LIMIT_UPPER) { - healthDatas.heartRatePerSec = perSecHeartRate; - } - - // GraphicService::GetInstance()->PostGraphicEvent( - // std::bind(&HeartModel::RefreshHeartRateScreen, - // HeartModel::GetInstance(), - // healthDatas.heartRatePerSec, healthDatas.heartRateRest, - // healthDatas.heartRateMax.y, healthDatas.heartRateMin.y)); -} - -uint16_t HeartModel::GetAveHeartRateCount(void) { return aveCount; } - -uint16_t HeartModel::GetHeartRateMax(void) { - return healthDatas.heartRateMax.y; -} - -uint16_t HeartModel::GetHeartRateMin(void) { - return healthDatas.heartRateMin.y; -} - -void HeartModel::SetHeartRatePerSec(uint32 sec) { - healthDatas.heartRatePerSec = sec; - if (HeartRateView::GetInstance() == nullptr) { - return; - } - HeartRateView::GetInstance()->RefreshHeartRatePerSec( - healthDatas.heartRatePerSec); -} - -void HeartModel::SetAveHeartRateCount(uint16_t value) { aveCount = value; } - -void HeartModel::RefreshHeartRateScreen() { - if (MainViewSample::GetInstance() != nullptr && - HeartChartView::GetInstance() != nullptr) { - if (MainViewSample::GetInstance()->GetHorCurrentCard() == HEART_RATE) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, - "HeartChartView::GetInstance() start"); - HeartChartView::GetInstance()->UpdateShowHeart(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, - "HeartChartView::GetInstance() end"); - } - } -} -/*----------------------------------状态检测 - *----------------------------------*/ - -// 重新初始化 -void HeartModel::ClearDisplayData() { - /*显示的心率数据清空*/ - // currentheart = 0; - // timestamp_ms = 0; - displayheart = 0; - displayheart_max = 0; // 显示最大心率 - displayheart_min = 0; // 显示最小心率 -} -// 获取心率数据 -uint16_t HeartModel::GetHeartdata() { return currentheart; } - -uint16_t HeartModel::GetShowHeartdata() { return displayheart; } -uint16_t HeartModel::GetShowMaxHeartdata() { return displayheart_max; } -uint16_t HeartModel::GetShowMinHeartdata() { return displayheart_min; } -uint32_t HeartModel::GetCheckTime() { return timestamp_ms; } - -void HeartModel::SetCheckTime(uint32_t time) { timestamp_ms = time; } -void HeartModel::SetResult(HeartResult result) { heartresult_ = result; } -HeartResult HeartModel::GetResult() { return heartresult_; } -// 控制心率检测 -void HeartModel::Heart_Control(HeartState state, HeartCheck check) { - - //优先级低不对高优先级处理 - if (check < checkstate) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, - "Higher execution instruction exists"); - return; - } - - //被动 - if (check == HeartCheck::PASSIVITY) { - uapi_dev_runtime_set_hrs_passivity(1); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, - "uapi_dev_runtime_set_hrs_passivity(1)"); - } else { - uapi_dev_runtime_set_hrs_passivity(0); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, - "uapi_dev_runtime_set_hrs_passivity(0)"); - } - - if (state == HeartState::End && heartstate == true) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartState End"); - //状态数全部清空 - valid_counter_ = 0; - disvalid_counter_ = 0; - unwear_counter_ = 0; - display_counter_ = 0; - displayheart = 0; -#ifdef SUPPORT_PPG_SERVICE - ppg_hr_stop(); -#endif - heartstate = false; - if (checkstate == HeartCheck::CARDCHECK) { - //重置传感器状态 - sensorstate = false; - uapi_dev_runtime_set_heartrate_detect_status(0); - } -#ifdef SYSTEM_LOG_SERVICE - //记录日志 - if (checkstate == HeartCheck::PASSIVITY) { - uapi_save_runtime_log(RUNTIME_LOG_OXYGEN_PASSIVE_MEASURE_END); - } else { - uapi_save_runtime_log(RUNTIME_LOG_HEART_MEASURE_END); - } -#endif - - // 复原检测状态 - checkstate = HeartCheck::RESTSTSTE; - heart_stop_data_timer(); //关闭数据获取 - } else if (state == HeartState::Start && heartstate == false) { - /*充电状态下不进行检测*/ - bool isCharging = false; - #ifdef SUPPORT_BATTERY_SERVICE - isCharging = get_charge_stat(); // 获取充电状态 - #endif - if (isCharging) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "充电不能检测"); - return; - } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartState Start"); -#ifdef SUPPORT_PPG_SERVICE - ppg_hr_start(); -#endif - heartstate = true; - checkstate = check; -#ifdef SYSTEM_LOG_SERVICE - //记录日志 - if (checkstate == HeartCheck::PASSIVITY) { - uapi_save_runtime_log(RUNTIME_LOG_HEART_PASSIVE_MEASURE); - } else { - uapi_save_runtime_log(RUNTIME_LOG_HEART_MEASURE); - } -#endif - heart_data_timer(); // 开始检测 - } -} -// 开始检测 -void HeartModel::Heart_Start(HeartCheck check) { - if (!sensorstate) { - displayheart = 0; - SetResult(HeartResult::NOT_TESTED); // 重置检测 - Heart_Control(HeartState::Start, check); - // ScreenTurnOn(60 * 1000); // 亮屏操作 600000ms 60秒关闭 - sensorstate = true; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "开始心率检测"); - // 设置runtime - if (uapi_dev_runtime_get_heartrate_detect_status() == 0) { - uapi_dev_runtime_set_heartrate_detect_status(1); - ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); - // 主动检测的亮屏60s - heart_start_screen60s_timer(); - } - } -} - -// 结束检测 -void HeartModel::Heart_Stop() { - valid_counter_ = 0; - disvalid_counter_ = 0; - unwear_counter_ = 0; - - /*主界面卡片检测 或者 被动检测*/ - if (checkstate == HeartCheck::PASSIVITY) { - if (heartresult_ == HeartResult::SUCCESS) { - Heart_Save(); - /*更新曲线*/ - GraphicService::GetInstance()->PostGraphicEvent( - std::bind(&HeartModel::Heart_Update_View, HeartModel::GetInstance())); - } - /*关闭被动检测*/ - Heart_Control(HeartState::End, HeartCheck::PASSIVITY); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "结束周期心率检测"); - return; - } - //呼吸训练模式下不进行息屏与保存 - if (sensorstate && uapi_dev_runtime_get_respiratory_training_status() != 1) { - // 恢复正常亮屏 - HeartModel::GetInstance()->heart_stop_screen60s_timer(); - // 取消常亮屏 - ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); - //设置runtime - - Heart_Result(); // 处理结果 - - //为了防止主界面卡片一直重复开传感器 - if (checkstate != HeartCheck::CARDCHECK) { - //重置传感器状态 - sensorstate = false; - uapi_dev_runtime_set_heartrate_detect_status(0); - } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "本次心率检测结束"); - } -} -// 保存检测数据 -void HeartModel::Heart_Save() { - - uint32_t timestamp = HeartResultPresenter::GetInstance()->GetCurrentTime(); - SetCheckTime(timestamp); - - HealthService::GetInstance()->send_heart_save(); - - // 更新最大和最小心率 - displayheart_max = - (displayheart_max < currentheart ? currentheart : displayheart_max); - - // 确保最小心率的第一次赋值大于50 - if (displayheart_min == 0 && currentheart > MIN_DISPLAY_HEART) { - displayheart_min = currentheart; // 初始化最小心率 - } else { - displayheart_min = - (displayheart_min > currentheart && currentheart > MIN_DISPLAY_HEART) - ? currentheart - : displayheart_min; - } - - // 将更新曲线写到这里提前更新 - HealthService::GetInstance()->UpdateHourlyHeartRate(timestamp_ms, - currentheart); - // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存的心率数据:%d%ld", - // currentheart,data.timestamp); -} - -void HeartModel::Heart_Result() { - - if (heartresult_ == HeartResult::SUCCESS) { - // 获取心率提醒状态和阈值 - heartRemindState = ConfigModel::GetInstance()->get_configData_int( - ConfigModel::CONFIGMODEL_ITEM_HEARTRATE_REMIND); - thresholdValue = ConfigModel::GetInstance()->get_configData_int( - ConfigModel::CONFIGMODEL_ITEM_HEARTRATE_THRESHOLD_VALUE); - - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "心率提醒状态:%d,阈值:%d,當前值:%d", - heartRemindState, thresholdValue, currentheart); - - if (heartRemindState) { - // 获取当前心率状态 - thresholdState = ConfigModel::GetInstance()->get_configData_int( - ConfigModel::CONFIGMODEL_ITEM_HEARTRATE_MAX_MIN); - - if (currentheart != 0) { - if (thresholdState == 0 && currentheart < thresholdValue) { - // 当前心率低于阈值 - heartresult_ = HeartResult::LOW_RESULT; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, - "检测结果:低结果情况,currentheart=%d,ThresholdValue=%d", - currentheart, thresholdValue); - } else if (thresholdState == 1 && currentheart > thresholdValue) { - // 当前心率高于阈值 - heartresult_ = HeartResult::HIGH_RESULT; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, - "检测结果:高结果情况,currentheart=%d,ThresholdValue=%d", - currentheart, thresholdValue); - } - } - } - } - // 根据结果进行处理 - handleHeartResult(); -} -// 处理检测结果 -void HeartModel::handleHeartResult() { - switch (heartresult_) { - case HeartResult::SUCCESS: - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "检测结果:成功"); - Heart_Save(); - // 更新曲线 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "准备更新UI"); - GraphicService::GetInstance()->PostGraphicEvent( - std::bind(&HeartModel::Heart_Update_View, HeartModel::GetInstance())); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "更新UI完成"); - break; - - case HeartResult::NOT_WORN: - case HeartResult::TIMEOUT: - case HeartResult::INVALID_DATA: - logAndChangeSlice(heartresult_); - break; - - case HeartResult::LOW_RESULT: - Heart_Save(); - handleLowHeartRate(); - break; - - case HeartResult::HIGH_RESULT: - Heart_Save(); - handleHighHeartRate(); - break; - - default: - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "检测结果:未知状态"); - break; - } -} -//进行日志打印与界面切换 -void HeartModel::logAndChangeSlice(HeartResult result) { - const char *resultMsg = (result == HeartResult::NOT_WORN) ? "未佩戴状态" - : (result == HeartResult::TIMEOUT) ? "超时" - : "无效数据"; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "检测结果:%s情况", resultMsg); - uapi_set_screen_on_api(); // 亮屏 - //需要先判断界面 心率卡片界面 - if (MainViewSample::GetInstance()) { - if (MainViewSample::GetInstance()->GetHorCurrentCard() == HEART_RATE) - NativeAbility::GetInstance().ChangeSlice(VIEW_CHECK_ABNORMAL); - } else - NativeAbility::GetInstance().ChangeSlice(VIEW_CHECK_ABNORMAL); -} -// 处理低心率情况 -void HeartModel::handleLowHeartRate() { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "检测结果:低结果情况"); - HealthState lowHealthState = {HEART_CHECK, LOW, thresholdValue}; - HealthService::GetInstance()->SetHealthCurrent(lowHealthState); - uapi_set_screen_on_api(); // 亮屏 - if (MainViewSample::GetInstance()) { - if (MainViewSample::GetInstance()->GetHorCurrentCard() == HEART_RATE) - NativeAbility::GetInstance().ChangeSlice(VIEW_CHECK_INVALID); - } else - NativeAbility::GetInstance().ChangeSlice(VIEW_CHECK_INVALID); -} -// 处理高心率情况 -void HeartModel::handleHighHeartRate() { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "检测结果:高结果情况"); - HealthState highHealthState = {HEART_CHECK, HIGH, thresholdValue}; - HealthService::GetInstance()->SetHealthCurrent(highHealthState); - uapi_set_screen_on_api(); // 亮屏 - if (MainViewSample::GetInstance()) { - if (MainViewSample::GetInstance()->GetHorCurrentCard() == HEART_RATE) - NativeAbility::GetInstance().ChangeSlice(VIEW_CHECK_INVALID); - } else - NativeAbility::GetInstance().ChangeSlice(VIEW_CHECK_INVALID); -} -// 设置佩戴状态 -void HeartModel::SetWearStatus() { - - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "佩戴状态 %d %d", - uapi_dev_runtime_get_heartrate_detect_status(), - unwear_counter_); - - // 如果处于训练模式,提前返回 - if (uapi_dev_runtime_get_train_status() == 1 || - // uapi_dev_runtime_get_heartrate_detect_status() == 0 || - uapi_dev_runtime_get_respiratory_training_status()) - return; - - unwear_counter_++; -#ifdef SYSTEM_LOG_SERVICE - uapi_save_runtime_log(RUNTIME_LOG_HEART_NOT_WEAR); -#endif - // 设置佩戴状态 - if (checkstate == HeartCheck::CARDCHECK) { - if (unwear_counter_ > MAX_UNWEAR_COUNT) { - if (MainViewSample::GetInstance()) { - //只有在心率卡片界面才触发 - if (MainViewSample::GetInstance()->GetHorCurrentCard() == HEART_RATE) { - SetResult(HeartResult::NOT_WORN); -#ifdef SYSTEM_LOG_SERVICE - uapi_save_runtime_log(RUNTIME_LOG_HEART_ERROR_NOT_WEAR); -#endif - Heart_Stop(); - } - } - } - } else { - SetResult(HeartResult::NOT_WORN); -#ifdef SYSTEM_LOG_SERVICE - uapi_save_runtime_log(RUNTIME_LOG_HEART_ERROR_NOT_WEAR); -#endif - Heart_Stop(); - } -} - -void HeartModel::UpHeartdata(uint16_t heart) { - // 如果处于训练模式,提前返回 - if (uapi_dev_runtime_get_train_status() == 1) - return; - - int max_valid_count = 0; - - // if (heart != 0) { - // if (display_counter_ >= DISPLAY_COUNT) { - // displayheart = heart; - // } else { - // displayheart = 0; - // } - // display_counter_++; - // } else { - // displayheart = 0; - // } - - displayheart = heart; - - // 更新心率和计数器 - if (displayheart != 0) { - currentheart = displayheart; // 更新当前心率 - valid_counter_++; // 增加有效计数器 - disvalid_counter_ = 0; // 清空无效计数器 -#ifdef SYSTEM_LOG_SERVICE - uapi_save_runtime_log(RUNTIME_LOG_HEART_VALID_VALUE); -#endif - } else { - disvalid_counter_++; // 增加无效计数器 - valid_counter_ = 0; // 清零有效计数器 -#ifdef SYSTEM_LOG_SERVICE - uapi_save_runtime_log(RUNTIME_LOG_HEART_INVALID_VALUE); -#endif - } - - // 检查无效计数器是否达标 - if (uapi_dev_runtime_get_sleep_monitoring_status()) //睡眠监测模式下,增加未佩戴个数最大值,避免误判 - max_valid_count = MAX_DISVALID_HRS_COUNT * 2; - else - max_valid_count = MAX_DISVALID_HRS_COUNT; - - if (disvalid_counter_ >= max_valid_count) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, - "检测结果:无效数达标 disvalid_counter:%d", disvalid_counter_); - SetResult(HeartResult::INVALID_DATA); // 标记为无效数据 -#ifdef SYSTEM_LOG_SERVICE - uapi_save_runtime_log(RUNTIME_LOG_HEAR_ERROR_INVALID_VALUE); -#endif - Heart_Stop(); - return; - } - - // 检查有效计数器是否达标 - if (valid_counter_ >= MAX_VALID_HRS_COUNT) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, - "检测结果:成功 valid_counter:%d currentheart:%d", - valid_counter_, currentheart); -#ifdef SYSTEM_LOG_SERVICE - uapi_save_runtime_log(RUNTIME_LOG_HEAR_SUCCESS); -#endif - SetResult(HeartResult::SUCCESS); // 标记为成功检测 - Heart_Stop(); - return; - } - - // 刷新心率显示 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, - "[heart data update displayheart%d displayheart_max%d " - "displayheart_min%d]", - displayheart, displayheart_max, displayheart_min); - - // GraphicService::GetInstance()->PostGraphicEvent( - // std::bind(&HeartModel::RefreshHeartRateScreen, - // HeartModel::GetInstance(), - // displayheart)); -} - -void HeartModel::Heart_Update_View(void) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "更新心率界面"); - int hour = HealthService::GetInstance()->GetCurrentHour(); - if (HeartRateView::GetInstance() != nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "更新主界面卡片"); - HeartRateView::GetInstance()->Update_data_Chart(hour); - } - if (HeartChartView::GetInstance() != nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "更新测量心率卡片"); - HeartChartView::GetInstance()->Update_data_Chart(hour); - } -} - -void HeartModel::CleanAllData(void) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Nextday!"); - if (MainViewSample::GetInstance() != nullptr && - HeartRateView::GetInstance() != nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "更新主界面心率卡片"); - HeartRateView::GetInstance()->CleanAllDataView(); - } - if (HeartChartView::GetInstance() != nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "更新测量心率卡片"); - HeartChartView::GetInstance()->CleanAllDataView(); - } -} - -// 配置5个动态心率数据 -// 最大 最小 -void HeartModel::SetArrayData() { - // 如果没有进行心率检测,则默认为0-220 - if (displayheart_max == 0 || displayheart_min == 0) { - dynamic_heartrate[0] = 0; - dynamic_heartrate[1] = 40; - dynamic_heartrate[2] = 100; - dynamic_heartrate[3] = 160; - dynamic_heartrate[4] = 220; - return; // 直接返回 - } - - // 计算心率范围并添加缓冲 - uint16_t adjusted_min = - (displayheart_min > 10) ? (displayheart_min / 2) : displayheart_min; - uint16_t adjusted_max = - (displayheart_max < 210) ? (displayheart_max + 10) : displayheart_max; - - uint16_t range = adjusted_max - adjusted_min; - uint16_t interval = range / 4; // 每个部分的宽度 - - // 设置动态心率数据 - dynamic_heartrate[0] = adjusted_min; - dynamic_heartrate[1] = adjusted_min + interval; - dynamic_heartrate[2] = adjusted_min + 2 * interval; - dynamic_heartrate[3] = adjusted_min + 3 * interval; - dynamic_heartrate[4] = adjusted_max; - - // 确保所有值为整数 - for (int i = 0; i < 5; i++) { - dynamic_heartrate[i] = static_cast(round(dynamic_heartrate[i])); - } - - // 打印动态心率数据 - for (int i = 0; i < 5; i++) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "dynamic_heartrate[%d]=%d", i, - dynamic_heartrate[i]); - } -} -// 获取动态心率配置数组 -uint16_t *HeartModel::GetArrayData() { return dynamic_heartrate; } - -// 获取检测字符串 -// 获取检测字符串 -// TODO: 适配多国语言 -std::string HeartModel::GetCheckString() { - std::string check_string = "检测结果未知"; - - // 获取检测数据 - if (currentheart == 0) { - if (ConfigModel::GetInstance()->GetLanguage() == ZH_CN) { - check_string = "暂无检测数据"; - } else { - check_string = "No detection data is available"; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "检测数据:%s", check_string.c_str()); - return check_string; - } - - // 获取目前的时间戳 - uint32_t currentTime; - if (uapi_get_timestampe_ss(¤tTime) != ERRCODE_SUCC) { - if (ConfigModel::GetInstance()->GetLanguage() == ZH_CN) { - check_string = "获取当前时间失败"; - } else { - check_string = "Get time failed"; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "获取当前时间失败"); - return check_string; - } - - // 检查时间戳是否有效 - if (timestamp_ms == 0) { - if (ConfigModel::GetInstance()->GetLanguage() == ZH_CN) { - check_string = std::to_string(currentheart) + " " + "时间无效,无法检测"; - } else { - check_string = - std::to_string(currentheart) + " " + "Invalid time, cannot detect"; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "时间戳无效,无法检测:%s", - check_string.c_str()); - return check_string; - } - - // 进行时间戳相减计算 - uint32_t diff = currentTime - timestamp_ms; - uint32_t diff_min = diff / 60; - uint32_t diff_hour = diff_min / 60; - - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "当前时间:%d, 上次检测时间:%d", - currentTime, timestamp_ms); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, - "时间差(秒):%d, 时间差(分钟):%d, 时间差(小时):%d", diff, - diff_min, diff_hour); - - // 根据时间差生成检测字符串 - if (diff_min < 1) { - if (ConfigModel::GetInstance()->GetLanguage() == ZH_CN) { - check_string = std::to_string(currentheart) + "次/分 " + "刚刚检测"; // - } else { - check_string = std::to_string(currentheart) + " bpm " + "Just detected"; - } - } else if (diff_hour < 1) { // Within one hour - if (ConfigModel::GetInstance()->GetLanguage() == ZH_CN) { - check_string = std::to_string(currentheart) + "次/分 " + - std::to_string(diff_min) + "分钟前"; - } else { - check_string = std::to_string(currentheart) + " bpm " + - std::to_string(diff_min) + " minutes ago"; - } - } else { - if (ConfigModel::GetInstance()->GetLanguage() == ZH_CN) { - check_string = std::to_string(currentheart) + "次/分 " + "超过一个小时前"; - } else { - check_string = - std::to_string(currentheart) + " bpm " + "More than an hour ago"; - } - } - - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "检测结果:%s", check_string.c_str()); - return check_string; // Return the final string -} - -#if KEEP_SCREEN_ON_HEART -/////////////////////////////////////////亮屏定时器//////////////////////////////////////////// -// 声明定时器变量 -static osTimerId_t g_screen60s_timer = nullptr; -static uint16_t SCREEN_60S_TIME = 60; -static void heart_start_screen60s_timer_callbackProc(int data) { - WEARABLE_LOGD( - WEARABLE_LOG_MODULE_APP, - "HeartModel::heart_start_screen60s_timer_callbackProc,time = %d", - SCREEN_60S_TIME); - SCREEN_60S_TIME -= 30; - WEARABLE_LOGD( - WEARABLE_LOG_MODULE_APP, - "HeartModel::heart_start_screen60s_timer_callbackProc,time = %d", - SCREEN_60S_TIME); - if (SCREEN_60S_TIME <= 0) { - // 60s后息屏停止定时 - HeartModel::GetInstance()->heart_stop_screen60s_timer(); - // 取消常亮屏 - ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "heart_stop_screen60s_timer"); - } -} -static void heart_start_screen60s_timer_callback(int data) { - GraphicService::GetInstance()->PostGraphicEvent( - std::bind(heart_start_screen60s_timer_callbackProc, data)); -} -void HeartModel::heart_start_screen60s_timer(uint32_t interval) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, - "HeartModel::heart_start_screen60s_timer"); - /* -------------------------- 1.检查定时器是否已经存在,如果存在则返回 - * ------------------------- */ - if (g_screen60s_timer != nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Timer already exists!!"); - return; - } - /* --------------------------------- 2.创建定时器 - * -------------------------------- */ - g_screen60s_timer = - osTimerNew((osTimerFunc_t)heart_start_screen60s_timer_callback, - osTimerPeriodic, nullptr, nullptr); - // 检查定时器创建是否成功 - if (g_screen60s_timer == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Timer create failed!!"); - return; - } - /* ----------------------------- 3.将毫秒转换为系统时钟节拍数 - * ---------------------------- */ - int tick = osMs2Tick(interval); - /* --------------------------------- 4.启动定时器 - * -------------------------------- */ - osStatus_t ret = osTimerStart(g_screen60s_timer, tick); - /* -------------------- 5.检查定时器启动是否成功,如果启动失败,删除定时器并置为 - * nullptr -------------------- */ - if (ret != osOK) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "osTimerDelete failed, ret = %lx!!", - ret); - if (g_screen60s_timer != nullptr) { - ret = osTimerDelete(g_screen60s_timer); - } - g_screen60s_timer = nullptr; - return; - } -} -void HeartModel::heart_stop_screen60s_timer(void) { - // 检查定时器是否存在 - if (g_screen60s_timer != nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, - "HeartModel::heart_stop_screen60s_timer"); - osTimerStop(g_screen60s_timer); - // 删除定时器并置为 nullptr - osStatus_t ret = osTimerDelete(g_screen60s_timer); - if (ret != osOK) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, - "osTimerDelete failed, ret = %lx!!", ret); - } - g_screen60s_timer = nullptr; - SCREEN_60S_TIME = 60; - } -} -void HeartModel::reset_heart_screen60s_timer_time() { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "reset_heart_screen60s_timer_time"); - SCREEN_60S_TIME = 60; - if (nullptr == g_screen60s_timer) { - ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 重新常亮屏 - heart_start_screen60s_timer(); // 开启定时器 - } -} -#endif -////////////////////////////////////////////////////////////////////////////////// -#if HEART_TIMER_DATA -// 声明定时器变量 -static osTimerId_t g_data_timer = nullptr; - -static void heart_data_callbackProc(int data) { - //更新佩戴 - uint8_t wear = 1; -#ifdef SUPPORT_PPG_SERVICE - wear = ppg_get_wear_status(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"heart_data_callbackProc::hrs = %d\n", hrs); -#endif - if (wear == 0) { - OHOS::HeartModel::GetInstance()->SetWearStatus(); - } - //更新心率 - uint8_t hrs = 0; -#ifdef SUPPORT_PPG_SERVICE - hrs = ppg_get_hrs(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"heart_data_callbackProc::hrs = %d\n", hrs); -#endif - OHOS::HeartModel::GetInstance()->UpHeartdata(hrs); - //打印佩戴与心率 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "wear = %d, hrs = %d\n", wear, hrs); -} -static void heart_data_timer_callback(int data) { - GraphicService::GetInstance()->PostGraphicEvent( - std::bind(heart_data_callbackProc, data)); -} -void HeartModel::heart_data_timer(uint32_t interval) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, - "HeartModel::heart_data_timer"); - if (g_data_timer != nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Timer already exists!!"); - return; - } - g_data_timer = osTimerNew((osTimerFunc_t)heart_data_timer_callback, - osTimerPeriodic, nullptr, nullptr); - if (g_data_timer == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Timer create failed!!"); - return; - } - int tick = osMs2Tick(interval); - osStatus_t ret = osTimerStart(g_data_timer, tick); - if (ret != osOK) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "osTimerDelete failed, ret = %lx!!", - ret); - if (g_data_timer != nullptr) { - ret = osTimerDelete(g_data_timer); - } - g_data_timer = nullptr; - return; - } -} -void HeartModel::heart_stop_data_timer(void) { - // 检查定时器是否存在 - if (g_data_timer != nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, - "HeartModel::heart_stop_data_timer"); - osTimerStop(g_data_timer); - // 删除定时器并置为 nullptr - osStatus_t ret = osTimerDelete(g_data_timer); - if (ret != osOK) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, - "osTimerDelete failed, ret = %lx!!", ret); - } - g_data_timer = nullptr; - } -} -#endif -} // namespace OHOS diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_transform_list/scale_item_adapter.cpp b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_transform_list/scale_item_adapter.cpp deleted file mode 100644 index 4c487a688..000000000 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_transform_list/scale_item_adapter.cpp +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright (c) 2024 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. - */ - -#include "scale_item_adapter.h" -#include "common/image_cache_manager.h" -#include "components/ui_transform_group.h" -#include "components/ui_image_view.h" -#include "components/ui_label_ext.h" -#include "graphic_config.h" -#include "ui_test_list_fps/ui_list_fps_res.h" -#include "securec.h" - -namespace OHOS { -class ItemContainer : public UITransformGroup { -public: - ItemContainer() : leftImg_(nullptr), label_(nullptr), rightImg_(nullptr) - { - SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - } - - ~ItemContainer() override - { - ClearRes(); - } - - void ClearRes() - { - RemoveAll(); - if (leftImg_ != nullptr) { - delete leftImg_; - leftImg_ = nullptr; - } - if (label_ != nullptr) { - delete label_; - label_ = nullptr; - } - if (rightImg_ != nullptr) { - delete rightImg_; - rightImg_ = nullptr; - } - } - - bool InitContainer() - { - if (leftImg_ == nullptr) { - leftImg_ = new UIImageView(); - if (leftImg_ == nullptr) { - return false; - } - } - leftImg_->SetResizeMode(UIImageView::ImageResizeMode::CENTER); - - if (label_ == nullptr) { - label_ = new UILabelExt(); - if (label_ == nullptr) { - ClearRes(); - return false; - } - } - label_->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40: item font size - - if (rightImg_ == nullptr) { - rightImg_ = new UIImageView(); - if (rightImg_ == nullptr) { - ClearRes(); - return false; - } - } - rightImg_->SetResizeMode(UIImageView::ImageResizeMode::CENTER); - - Add(label_); - Add(leftImg_); - Add(rightImg_); - return true; - } - - UIImageView* GetLeftImageView() - { - return leftImg_; - } - - UILabelExt* GetLabelView() - { - return label_; - } - - UIImageView* GetRightImgView() - { - return rightImg_; - } - - ItemContainer(const ItemContainer &) = delete; - ItemContainer &operator=(const ItemContainer &) = delete; - -private: - UIImageView* leftImg_; - UILabelExt* label_; - UIImageView* rightImg_; -}; - -ScaleItemAdapter::~ScaleItemAdapter() -{ - ClearData(); -} - -uint16_t ScaleItemAdapter::GetCount() -{ - return nodeList_.Size(); -} - -void ScaleItemAdapter::ClearData() -{ - ListNode* node = nodeList_.Begin(); - while (node != nodeList_.End()) { - if (node->data_ != nullptr) { - if (node->data_->txt != nullptr) { - UIFree(node->data_->txt); - node->data_->txt = nullptr; - } - UIFree(node->data_); - node->data_ = nullptr; - } - node = node->next_; - } - ImageCacheManager::GetInstance().UnloadAllInMultiRes(LIST_FPS); -} - -void ScaleItemAdapter::FreeNode(ItemDataNode* node) -{ - if (node != nullptr) { - if (node->txt != nullptr) { - UIFree(node->txt); - node->txt = nullptr; - } - UIFree(node); - node = nullptr; - } -} - -void ScaleItemAdapter::SetData(const List* data) -{ - if (data == nullptr) { - return; - } - if (!nodeList_.IsEmpty()) { - ClearData(); - } - ListNode* node = data->Begin(); - while (node != data->End()) { - ItemDataNode* tmpNode = static_cast(UIMalloc(sizeof(ItemDataNode))); - if (tmpNode == nullptr) { - return; - } - - tmpNode->resId = node->data_->resId; - uint32_t len = strlen(node->data_->txt); - tmpNode->txt = static_cast(UIMalloc(len + 1)); - if (tmpNode->txt == nullptr) { - FreeNode(tmpNode); - return; - } - if (memcpy_s(tmpNode->txt, len + 1, node->data_->txt, len) != EOK) { - FreeNode(tmpNode); - return; - } - tmpNode->txt[len] = '\0'; - tmpNode->lineBreakMode = node->data_->lineBreakMode; - tmpNode->imgInfo = nullptr; - - nodeList_.PushBack(tmpNode); - node = node->next_; - } -} - -UIView* ScaleItemAdapter::GetView(UIView* inView, int16_t index) -{ - if (nodeList_.IsEmpty() || index > nodeList_.Size() - 1 || index < 0) { - return nullptr; - } - - ListNode* node = nodeList_.Begin(); - for (uint16_t i = 0; i < index; i++) { - node = node->next_; - } - ItemContainer* item = nullptr; - if (inView == nullptr) { - item = new ItemContainer(); - if (item == nullptr) { - return nullptr; - } - if (!item->InitContainer()) { - delete item; - return nullptr; - } - item->Resize(width_, height_); - - UIImageView* leftImg = item->GetLeftImageView(); - leftImg->SetPosition(imageRect_.GetX(), imageRect_.GetY(), imageRect_.GetWidth(), imageRect_.GetHeight()); - - UILabelExt* label = item->GetLabelView(); - label->SetPosition(labelRect_.GetX(), labelRect_.GetY(), labelRect_.GetWidth(), labelRect_.GetHeight()); - - UIImageView* rightImg = item->GetRightImgView(); - rightImg->SetPosition(labelRect_.GetX() + labelRect_.GetWidth(), - imageRect_.GetY(), imageRect_.GetWidth(), imageRect_.GetHeight()); - } else { - item = static_cast(inView); - } - - if (item != nullptr) { - UIImageView* leftImg = item->GetLeftImageView(); - if (leftImg != nullptr) { - if (node->data_->imgInfo == nullptr) { - node->data_->imgInfo = ImageCacheManager::GetInstance().LoadOneInMultiRes(node->data_->resId, LIST_FPS); - } - leftImg->SetSrc(node->data_->imgInfo); - } - - UILabelExt* label = item->GetLabelView(); - if (label != nullptr) { - label->SetText(node->data_->txt); - label->SetLineBreakMode(node->data_->lineBreakMode); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - } - - UIImageView* rightImg = item->GetRightImgView(); - if (rightImg != nullptr) { - if (arrowImg_ == nullptr) { - arrowImg_ = ImageCacheManager::GetInstance().LoadSingleRes(RES_PATH"left_arrow.bin"); - } - rightImg->SetSrc(arrowImg_); - } - - item->SetViewIndex(index); - } - return item; -} - -void ScaleItemAdapter::ItemResize(uint16_t w, uint16_t h) -{ - width_ = w; - height_ = h; -} - -void ScaleItemAdapter::SetLabelPosition(int16_t x, int16_t y, uint16_t w, uint16_t h) -{ - labelRect_.SetPosition(x, y); - labelRect_.SetWidth(w); - labelRect_.SetHeight(h); -} - -void ScaleItemAdapter::SetImagePosition(int16_t x, int16_t y, uint16_t w, uint16_t h) -{ - imageRect_.SetPosition(x, y); - imageRect_.SetWidth(w); - imageRect_.SetHeight(h); -} -} // namespace OHOS \ No newline at end of file diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_transform_list/scale_item_adapter.h b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_transform_list/scale_item_adapter.h deleted file mode 100644 index b8053b155..000000000 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_transform_list/scale_item_adapter.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2024 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 SCALE_ITEM_ADAPTER_H -#define SCALE_ITEM_ADAPTER_H -#include "components/abstract_adapter.h" -#include "gfx_utils/list.h" -#include "gfx_utils/vector.h" - -namespace OHOS { -struct ItemDataNode { - int resId; - char* txt; - uint8_t lineBreakMode; - ImageInfo* imgInfo; -}; - -class ScaleItemAdapter : public AbstractAdapter { -public: - ScaleItemAdapter() : width_(0), height_(0), arrowImg_(nullptr) {} - ~ScaleItemAdapter() override; - - UIView* GetView(UIView* inView, int16_t index) override; - uint16_t GetCount() override; - void SetData(const List* data); - - void ItemResize(uint16_t w, uint16_t h); - void SetLabelPosition(int16_t x, int16_t y, uint16_t w, uint16_t h); - void SetImagePosition(int16_t x, int16_t y, uint16_t w, uint16_t h); -private: - void ClearData(void); - void FreeNode(ItemDataNode* node); - List nodeList_; - uint16_t width_; - uint16_t height_; - Rect imageRect_; - Rect labelRect_; - ImageInfo* arrowImg_; -}; -} // namespace OHOS -#endif // SCALE_ITEM_ADAPTER_H diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_transform_list/ui_test_scale_list.cpp b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_transform_list/ui_test_scale_list.cpp deleted file mode 100644 index 3d8a15f54..000000000 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_transform_list/ui_test_scale_list.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2024 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. - */ - -#include "ui_test_scale_list.h" -#include "ui_test_list_fps/ui_list_fps_res.h" -#include "graphic_config.h" -#include "securec.h" - -namespace OHOS { -static const int16_t LIST_WIDTH = 454; -static const int16_t LIST_HEIGHT = 454; -static const uint16_t ITEM_WIDTH = 400; -static const uint16_t ITEM_HEIGHT = 100; -static const uint16_t IMAGE_WIDTH = 50; -static const uint16_t IMAGE_HEIGHT = 50; -static const uint16_t LABEL_WIDTH = 300; -static const uint16_t LABEL_HEIGHT = 100; -static const uint16_t SCALE_FACTOR = 400; -static ItemDataNode g_itemNode[] = { - {APPLIST_ALARM, "闹钟", UILabel::LINE_BREAK_ELLIPSIS}, - {BLUETOOTH_TITLE, "蓝牙", UILabel::LINE_BREAK_ELLIPSIS}, - {APPLIST_CALLER_IMAGE, "通话记录", UILabel::LINE_BREAK_ELLIPSIS}, - {APPLIST_COMPASS_IMAGE, "指南针", UILabel::LINE_BREAK_ELLIPSIS}, - {APPLIST_SETTING, "设置", UILabel::LINE_BREAK_ELLIPSIS}, - {APPLIST_SPO2, "血氧饱和度", UILabel::LINE_BREAK_ELLIPSIS}, - {APPLIST_VOCASSIST_IMAGE, "语音助手", UILabel::LINE_BREAK_ELLIPSIS}, - {APPLIST_ALARM, "长文本滚动测试ABCD", UILabel::LINE_BREAK_MARQUEE}, - {APPLIST_ALARM, "闹钟", UILabel::LINE_BREAK_ELLIPSIS}, - {BLUETOOTH_TITLE, "蓝牙", UILabel::LINE_BREAK_ELLIPSIS}, - {APPLIST_CALLER_IMAGE, "通话记录", UILabel::LINE_BREAK_ELLIPSIS}, - {APPLIST_COMPASS_IMAGE, "指南针", UILabel::LINE_BREAK_ELLIPSIS} -}; - -static bool TransformItemBaseOnPosition(UITransformList* list, UIView* item) -{ - if (list == nullptr || item == nullptr) { - return false; - } - if (item->GetViewType() != UI_TRANSFORM_GROUP) { - return false; - } - UITransformGroup* group = dynamic_cast(item); - if (group == nullptr) { - return false; - } - int16_t w = group->GetWidth(); - int16_t h = group->GetHeight(); - if (list->GetDirection() == UIList::VERTICAL) { - int16_t midY = list->GetY() + (list->GetHeight() >> 1); - int16_t y = group->GetY(); - int offset = (y + (h >> 1) - midY); - int temp = EasingEquation::SineEaseIn(0, SCALE_FACTOR, abs(offset), SCALE_FACTOR); - float scale = 1.0 - (static_cast(temp) / SCALE_FACTOR); - group->Scale(Vector2(scale, scale), Vector2(w >> 1, h >> 1)); - if ((y <= midY) && (y + group->GetHeight() >= midY)) { - return true; - } - } - return false; -} - -void UITestScaleList::SetUp() -{ - if (data_ == nullptr) { - data_ = new List(); - if (data_ == nullptr) { - return; - } - for (uint8_t i = 0; i < (sizeof(g_itemNode) / sizeof(ItemDataNode)); ++i) { - data_->PushBack(&g_itemNode[i]); - } - } -} - -void UITestScaleList::TearDown() -{ - if (data_ != nullptr) { - data_->Clear(); - delete data_; - data_ = nullptr; - } - if (adapter_ != nullptr) { - delete adapter_; - adapter_ = nullptr; - } - if (list_ != nullptr) { - delete list_; - list_ = nullptr; - } -} - -UIView* UITestScaleList::GetTestView() -{ - UIScaleListTest(); - return list_; -} - -void UITestScaleList::UIScaleListTest() -{ - adapter_ = new ScaleItemAdapter(); - if (adapter_ == nullptr) { - TearDown(); - return; - } - adapter_->ItemResize(ITEM_WIDTH, ITEM_HEIGHT); - adapter_->SetLabelPosition(IMAGE_WIDTH, 0, LABEL_WIDTH, LABEL_HEIGHT); - adapter_->SetImagePosition(0, 25, IMAGE_WIDTH, IMAGE_HEIGHT); // 25:image start pos y - adapter_->SetData(data_); - - if (list_ == nullptr) { - list_ = new UITransformList(); - } - list_->SetPosition(0, 0, LIST_WIDTH, LIST_HEIGHT); - list_->SetItemTransformFunc(&TransformItemBaseOnPosition); - list_->SetAdapter(adapter_); - list_->SetThrowDrag(true); - list_->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - list_->SetMaxScrollDistance(1000); // 1000: max scroll distance - list_->SetSwipeACCLevel(200); // 200: compensation distance - list_->SetDragACCLevel(5); // 5: drag acceleration - list_->SetYScrollBarVisible(true); - - list_->EnableAutoAlign(false); - list_->SetSelectPosition(LIST_HEIGHT / 2); // 2: divisor - list_->EnableCrossDragBack(false); - list_->SetElastic(true); - list_->SetReboundSize(LIST_HEIGHT / 2); // 2: divisor - list_->SetItemSpace(30); // 30: item space - list_->SetAutoAlignTime(300); // 300: align time - list_->SetScrollBlankSize(LIST_HEIGHT / 2); // 2: divisor - list_->SetScrollBlankSize(LIST_HEIGHT / 2 - ITEM_HEIGHT / 2, UIAbstractScroll::Direction::BOTTOM); - list_->SetReboundSize(0, UIAbstractScroll::Direction::BOTTOM); - list_->SetDragFunc(EasingEquation::QuadEaseOut); -} -} // namespace OHOS \ No newline at end of file diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_transform_list/ui_test_scale_list.h b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_transform_list/ui_test_scale_list.h deleted file mode 100644 index 3b5cb1566..000000000 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_transform_list/ui_test_scale_list.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2024 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 UI_TEST_SCALEABEL_LIST_H -#define UI_TEST_SCALEABEL_LIST_H - -#include "graphic_config.h" -#include "components/ui_transform_list.h" -#include "ui_test.h" -#include "ui_test_transform_list/scale_item_adapter.h" - -namespace OHOS { -class UITestScaleList : public UITest { -public: - UITestScaleList() : list_(nullptr), data_(nullptr), adapter_(nullptr) {} - ~UITestScaleList() override {} - void SetUp() override; - void TearDown() override; - UIView* GetTestView() override; - void UIScaleListTest(); - -private: - UITransformList* list_; - List* data_; - ScaleItemAdapter* adapter_; -}; -} // namespace OHOS -#endif // UI_TEST_SCALEABEL_LIST_H \ No newline at end of file diff --git "a/code/sdk/open_source/openharmony/base/startup/syspara_lite/src/\346\226\207\344\273\266\345\244\2711201patch\345\220\210\345\271\266\346\217\220\344\272\244" "b/code/sdk/open_source/openharmony/base/startup/syspara_lite/src/\346\226\207\344\273\266\345\244\2711201patch\345\220\210\345\271\266\346\217\220\344\272\244" deleted file mode 100644 index 0065aa274..000000000 --- "a/code/sdk/open_source/openharmony/base/startup/syspara_lite/src/\346\226\207\344\273\266\345\244\2711201patch\345\220\210\345\271\266\346\217\220\344\272\244" +++ /dev/null @@ -1 +0,0 @@ -文件夹1201patch合并提交 \ No newline at end of file diff --git a/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/CMakeLists.txt b/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/CMakeLists.txt deleted file mode 100644 index 379720053..000000000 --- a/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/CMakeLists.txt +++ /dev/null @@ -1,60 +0,0 @@ -set(COMPONENT_NAME "sensor_hdi") -set(MODULE_NAME "ohos") -set(AUTO_DEF_FILE_ID TRUE) - -set(PUBLIC_HEADER -) - -set(PRIVATE_HEADER - ${ROOT_DIR}/application/wearable/ohos_deps - ${CMAKE_CURRENT_SOURCE_DIR}/../interfaces/include - ${CMAKE_CURRENT_SOURCE_DIR}/include -) - -set(SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/src/sensor_log.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/sensor_manager.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/sensor_controller.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/sensor_thread.c -) - -set(COMPONENT_PUBLIC_CCFLAGS -) - -set(COMPONENT_CCFLAGS - -Wno-error - -Wno-unused-parameter - -fno-exceptions - -fno-unwind-tables - -fno-asynchronous-unwind-tables - -Wno-undef - -Wno-bitwise-op-parentheses - -Wno-shift-op-parentheses - -nostdlibinc - -nostdinc - -nostdlib - -Wno-error=unused-function -) - - -set(WHOLE_LINK - true -) - -set(MAIN_COMPONENT - false -) - -set(AUTO_ADD_PATH - false -) - -set(PUBLIC_DEFINES -) - -set(CDEFINES ${CDEFINES} "CMSIS_SUPPORT") -set(PRIVATE_DEFINES - ${CDEFINES} -) - -build_component() diff --git a/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/include/sensor_common.h b/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/include/sensor_common.h deleted file mode 100644 index 16f7d2a14..000000000 --- a/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/include/sensor_common.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * 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 HDI_SENSOR_COMMON_H -#define HDI_SENSOR_COMMON_H - -#include -#include "sensor_log.h" - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) -#endif - -#define CHECK_NULL_PTR_RETURN_VALUE(ptr, ret) do { \ - if ((ptr) == NULL) { \ - HILOG_ERROR(HILOG_MODULE_SEN, "pointer is null and return ret:%d", ret); \ - return (ret); \ - } \ -} while (0) - -#define CHECK_NULL_PTR_RETURN(ptr) do { \ - if ((ptr) == NULL) { \ - HILOG_ERROR(HILOG_MODULE_SEN, "pointer is null and return"); \ - return; \ - } \ -} while (0) - -#endif /* HDI_SENSOR_COMMON_H */ diff --git a/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/include/sensor_controller.h b/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/include/sensor_controller.h deleted file mode 100644 index 941087727..000000000 --- a/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/include/sensor_controller.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * 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 HDI_SENSOR_CONTROLLER_H -#define HDI_SENSOR_CONTROLLER_H - -#include -#include -#include "sensor_if.h" -#include "sensor_type.h" - -void GetSensorDeviceMethods(struct SensorInterface *device); -void ReleaseAllSensorInfo(void); - -#endif /* HDI_SENSOR_CONTROLLER_H */ \ No newline at end of file diff --git a/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/include/sensor_manager.h b/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/include/sensor_manager.h deleted file mode 100644 index ce8ba1278..000000000 --- a/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/include/sensor_manager.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * 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 HDI_SENSOR_MANAGER_H -#define HDI_SENSOR_MANAGER_H - -#include -#include "sensor_type.h" -#include "sensor_thread.h" - -#define THREAD_NAME_MAX_LEN 128 - -struct SensorDev { - enum SensorTypeTag sensorType; /* scb sensor type */ - bool sensorEnabled; - RecordDataCallback recordDataCb; - ThreadId listenDataThreadId; - ThreadFunc threadFunc; - char threadName[THREAD_NAME_MAX_LEN]; - MutexId mutex; - struct SensorInformation *sensorInfo; -}; - -struct SensorDevManager { - bool initState; - bool hasSensorListener; -}; - -struct SensorDevManager *GetSensorDevManager(void); - -#endif /* HDI_SENSOR_MANAGER_H */ diff --git a/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/include/sensor_thread.h b/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/include/sensor_thread.h deleted file mode 100644 index b461b218b..000000000 --- a/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/include/sensor_thread.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Device Co., Ltd. - * 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 SENSOR_THREAD_H -#define SENSOR_THREAD_H - -#include -#include -#include -#include -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif -#endif - -typedef struct { - bool isRecursive; -} MutexAttr; - -typedef void *MutexId; - -MutexId SensorMutexCreate(MutexAttr *attr); - -void SensorMutexDestroy(MutexId *mutex); - -void SensorMutexLock(MutexId mutex); - -void SensorMutexUnLock(MutexId mutex); - -void SensorMutexGlobalLock(void); - -void SensorMutexGlobalUnLock(void); - -void SensorInitStaticMutexLock(MutexId *mutex); - -typedef void *ThreadId; -typedef void (*ThreadFunc)(void *argv); - -typedef struct { - const char *name; // name of the thread - uint32_t stackSize; // size of stack - uint8_t priority; // initial thread priority - uint8_t reserved1; // reserved1 (must be 0) - uint16_t reserved2; // reserved2 (must be 0) -} ThreadAttr; - -ThreadId SensorThreadCreate(ThreadFunc func, void *argv, const ThreadAttr *attr); - -#ifdef __cplusplus -#if __cplusplus -} -#endif -#endif -#endif // SENSOR_THREAD_H diff --git a/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/src/sensor_controller.c b/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/src/sensor_controller.c deleted file mode 100644 index 28da77ad6..000000000 --- a/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/src/sensor_controller.c +++ /dev/null @@ -1,446 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * 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. - */ - -#include "sensor_controller.h" -#include -#include -#include "securec.h" -#include "sensor_common.h" -#include "sensor_if.h" -#include "sensor_manager.h" - -#define LISTEN_TIME_THR 1000 - -const static int16_t DEFAULT_AXIS_X = 80; -const static int16_t DEFAULT_AXIS_Y = 90; -const static int16_t DEFAULT_AXIS_Z = 100; - -static void ListenAccelDataProc(void *argv); -static void ListenBarDataProc(void *argv); -static void ListenCyroDataProc(void *argv); -static void ListenHrDataProc(void *argv); -static void ListenObsDataProc(void *argv); -static void ListenScDataProc(void *argv); - -struct SensorInformation g_sensorInfo[] = { - {"accel_mock", "vendor_mock", "fmw_1.00", "hw_1.00", SENSOR_TYPE_ACCELEROMETER, 0, 0.0, 0.0, 0.0}, - {"bar_mock", "vendor_mock", "fmw_1.00", "hw_1.00", SENSOR_TYPE_BAROMETER, 1, 0.0, 0.0, 0.0}, - {"cyro_mock", "vendor_mock", "fmw_1.00", "hw_1.00", SENSOR_TYPE_GYROSCOPE, 2, 0.0, 0.0, 0.0}, - {"hr_mock", "vendor_mock", "fmw_1.00", "hw_1.00", SENSOR_TYPE_HEART_RATE, 3, 0.0, 0.0, 0.0}, - {"obs_mock", "vendor_mock", "fmw_1.00", "hw_1.00", SENSOR_TYPE_WEAR_DETECTION, 4, 0.0, 0.0, 0.0}, - {"sc_mock", "vendor_mock", "fmw_1.00", "hw_1.00", SENSOR_TYPE_PEDOMETER, 5, 0.0, 0.0, 0.0}, -}; - -struct SensorDev g_sensorDev[] = { - {SENSOR_TYPE_ACCELEROMETER, false, NULL, NULL, ListenAccelDataProc, "ListenAccelDataTask", NULL, &g_sensorInfo[0]}, - {SENSOR_TYPE_BAROMETER, false, NULL, NULL, ListenBarDataProc, "ListenBarDataTask", NULL, &g_sensorInfo[0]}, - {SENSOR_TYPE_GYROSCOPE, false, NULL, NULL, ListenCyroDataProc, "ListenCyroDataTask", NULL, &g_sensorInfo[0]}, - {SENSOR_TYPE_HEART_RATE, false, NULL, NULL, ListenHrDataProc, "ListenHrDataTask", NULL, &g_sensorInfo[0]}, - {SENSOR_TYPE_WEAR_DETECTION, false, NULL, NULL, ListenObsDataProc, "ListenObsDataTask", NULL, &g_sensorInfo[0]}, - {SENSOR_TYPE_PEDOMETER, false, NULL, NULL, ListenScDataProc, "ListenScDataTask", NULL, &g_sensorInfo[0]}, -}; - -static int64_t GetTimestampMS(void) -{ - static int64_t US_PER_MS = 1000; - static int64_t MS_PER_S = 1000; - struct timeval tv; - gettimeofday(&tv, NULL); - int64_t ms = tv.tv_usec / US_PER_MS; - return tv.tv_sec * MS_PER_S + ms; -} - -static void ListenAccelDataProc(void *argv) -{ - HILOG_INFO(HILOG_MODULE_SEN, "enter"); - struct SensorDev *sensorDev = (struct SensorDev *)argv; - if (sensorDev == NULL) { - HILOG_ERROR(HILOG_MODULE_SEN, "argv invalid"); - return; - } - struct AccelData accelData = { - .axisX = DEFAULT_AXIS_X, - .axisY = DEFAULT_AXIS_Y, - .axisZ = DEFAULT_AXIS_Z, - }; - while (sensorDev->sensorEnabled) { - struct SensorEvents sensorEvents = { - .sensorId = sensorDev->sensorType, - .version = 0, - .timestamp = GetTimestampMS(), - .option = 0, - .mode = SENSOR_MODE_DEFAULT, - .data = (uint8_t *)&accelData, - .dataLen = sizeof(struct AccelData), - }; - SensorMutexLock(sensorDev->mutex); - if (sensorDev->recordDataCb) { - sensorDev->recordDataCb(&sensorEvents); - } - SensorMutexUnLock(sensorDev->mutex); - osDelay(LISTEN_TIME_THR); - } - HILOG_INFO(HILOG_MODULE_SEN, "exit"); -} - -static void ListenBarDataProc(void *argv) -{ - HILOG_INFO(HILOG_MODULE_SEN, "enter"); - struct SensorDev *sensorDev = (struct SensorDev *)argv; - if (sensorDev == NULL) { - HILOG_ERROR(HILOG_MODULE_SEN, "argv invalid"); - return; - } - const uint32_t DEFAULT_PRESSURE = 101300; - struct PressureData pressureData = { - .pressure = DEFAULT_PRESSURE, - .temperature = 0, - .dataValid = true, - }; - while (sensorDev->sensorEnabled) { - struct SensorEvents sensorEvents = { - .sensorId = sensorDev->sensorType, - .version = 0, - .timestamp = GetTimestampMS(), - .option = 0, - .mode = SENSOR_MODE_DEFAULT, - .data = (uint8_t *)&pressureData, - .dataLen = sizeof(struct PressureData), - }; - SensorMutexLock(sensorDev->mutex); - if (sensorDev->recordDataCb) { - sensorDev->recordDataCb(&sensorEvents); - } - SensorMutexUnLock(sensorDev->mutex); - osDelay(LISTEN_TIME_THR); - } - HILOG_INFO(HILOG_MODULE_SEN, "exit"); -} - -static void ListenCyroDataProc(void *argv) -{ - HILOG_INFO(HILOG_MODULE_SEN, "enter"); - struct SensorDev *sensorDev = (struct SensorDev *)argv; - if (sensorDev == NULL) { - HILOG_ERROR(HILOG_MODULE_SEN, "argv invalid"); - return; - } - - while (sensorDev->sensorEnabled) { - struct GyroData gyroData = { - .axisX = DEFAULT_AXIS_X, - .axisY = DEFAULT_AXIS_Y, - .axisZ = DEFAULT_AXIS_Z, - }; - struct SensorEvents sensorEvents = { - .sensorId = sensorDev->sensorType, - .version = 0, - .timestamp = GetTimestampMS(), - .option = 0, - .mode = SENSOR_MODE_DEFAULT, - .data = (uint8_t *)&gyroData, - .dataLen = sizeof(struct GyroData), - }; - SensorMutexLock(sensorDev->mutex); - if (sensorDev->recordDataCb) { - sensorDev->recordDataCb(&sensorEvents); - } - SensorMutexUnLock(sensorDev->mutex); - osDelay(LISTEN_TIME_THR); - } - HILOG_INFO(HILOG_MODULE_SEN, "exit"); -} - -static void ListenHrDataProc(void *argv) -{ - HILOG_INFO(HILOG_MODULE_SEN, "enter"); - struct SensorDev *sensorDev = (struct SensorDev *)argv; - if (sensorDev == NULL) { - HILOG_ERROR(HILOG_MODULE_SEN, "argv invalid"); - return; - } - const uint32_t DEFAULT_HEARTRATE = 80; - while (sensorDev->sensorEnabled) { - uint32_t heartRate = DEFAULT_HEARTRATE; - struct SensorEvents sensorEvents = { - .sensorId = sensorDev->sensorType, - .version = 0, - .timestamp = GetTimestampMS(), - .option = 0, - .mode = SENSOR_MODE_DEFAULT, - .data = (uint8_t *)&heartRate, - .dataLen = sizeof(uint32_t), - }; - SensorMutexLock(sensorDev->mutex); - if (sensorDev->recordDataCb) { - sensorDev->recordDataCb(&sensorEvents); - } - SensorMutexUnLock(sensorDev->mutex); - osDelay(LISTEN_TIME_THR); - } - HILOG_INFO(HILOG_MODULE_SEN, "exit"); -} - -static void ListenObsDataProc(void *argv) -{ - HILOG_INFO(HILOG_MODULE_SEN, "enter"); - struct SensorDev *sensorDev = (struct SensorDev *)argv; - if (sensorDev == NULL) { - HILOG_ERROR(HILOG_MODULE_SEN, "argv invalid"); - return; - } - while (sensorDev->sensorEnabled) { - const uint8_t defaultIsonbody = 1; - struct SensorEvents sensorEvents = { - .sensorId = sensorDev->sensorType, - .version = 0, - .timestamp = GetTimestampMS(), - .option = 0, - .mode = SENSOR_MODE_DEFAULT, - .data = (uint8_t *)&defaultIsonbody, - .dataLen = sizeof(uint8_t), - }; - SensorMutexLock(sensorDev->mutex); - if (sensorDev->recordDataCb) { - sensorDev->recordDataCb(&sensorEvents); - } - SensorMutexUnLock(sensorDev->mutex); - osDelay(LISTEN_TIME_THR); - } - HILOG_INFO(HILOG_MODULE_SEN, "exit"); -} - -static void ListenScDataProc(void *argv) -{ - HILOG_INFO(HILOG_MODULE_SEN, "enter"); - struct SensorDev *sensorDev = (struct SensorDev *)argv; - if (sensorDev == NULL) { - HILOG_ERROR(HILOG_MODULE_SEN, "argv invalid"); - return; - } - const uint32_t DEFAULT_STEPS = 2000; - while (sensorDev->sensorEnabled) { - uint32_t steps = DEFAULT_STEPS; - struct SensorEvents sensorEvents = { - .sensorId = sensorDev->sensorType, - .version = 0, - .timestamp = GetTimestampMS(), - .option = 0, - .mode = SENSOR_MODE_DEFAULT, - .data = (uint8_t *)&steps, - .dataLen = sizeof(uint32_t), - }; - SensorMutexLock(sensorDev->mutex); - if (sensorDev->recordDataCb) { - sensorDev->recordDataCb(&sensorEvents); - } - SensorMutexUnLock(sensorDev->mutex); - osDelay(LISTEN_TIME_THR); - } - HILOG_INFO(HILOG_MODULE_SEN, "exit"); -} - -static int32_t InitAllSensorInfo(void) -{ - for (int32_t i = 0; i < (int32_t)ARRAY_SIZE(g_sensorDev); i++) { - g_sensorDev[i].mutex = SensorMutexCreate(NULL); - if (!g_sensorDev[i].mutex) { - HILOG_ERROR(HILOG_MODULE_SEN, "SensorMutexCreate failed"); - return SENSOR_FAILURE; - } - } - return SENSOR_SUCCESS; -} - -static void DeInitAllSensorInfo(void) -{ - for (int32_t i = 0; i < (int32_t)ARRAY_SIZE(g_sensorDev); i++) { - SensorMutexDestroy(&g_sensorDev[i].mutex); - g_sensorDev[i].mutex = NULL; - } -} - -void ReleaseAllSensorInfo(void) -{ - struct SensorDevManager *manager = GetSensorDevManager(); - manager->hasSensorListener = false; - DeInitAllSensorInfo(); -} - -static struct SensorDev *GetSensorBySensorTypeId(int32_t sensorTypeId) -{ - if ((sensorTypeId >= SENSOR_TYPE_MAX) || (sensorTypeId < SENSOR_TYPE_NONE)) { - HILOG_ERROR(HILOG_MODULE_SEN, "invalid sensorTypeId:%d", sensorTypeId); - return NULL; - } - for (int32_t i = 0; i < (int32_t)ARRAY_SIZE(g_sensorDev); i++) { - if (g_sensorDev[i].sensorType == sensorTypeId) { - return &g_sensorDev[i]; - } - } - return NULL; -} - -static int32_t GetSensorInfo(struct SensorInformation **sensor, int32_t *count) -{ - HILOG_DEBUG(HILOG_MODULE_SEN, "enter"); - struct SensorDevManager *manager = GetSensorDevManager(); - CHECK_NULL_PTR_RETURN_VALUE(sensor, SENSOR_NULL_PTR); - CHECK_NULL_PTR_RETURN_VALUE(count, SENSOR_NULL_PTR); - - int32_t snsCnt = ARRAY_SIZE(g_sensorInfo); - - if (snsCnt <= 0) { - HILOG_ERROR(HILOG_MODULE_SEN, "sensor snsCnt invalid"); - return SENSOR_FAILURE; - } - int32_t ret = InitAllSensorInfo(); - if (ret != SENSOR_SUCCESS) { - return SENSOR_FAILURE; - } - *count = snsCnt; - *sensor = g_sensorInfo; - HILOG_INFO(HILOG_MODULE_SEN, "sensor count:%d", *count); - return SENSOR_SUCCESS; -} - -static int32_t EnableSensor(int32_t sensorTypeId) -{ - HILOG_DEBUG(HILOG_MODULE_SEN, "enter"); - struct SensorDev *sendorDev = GetSensorBySensorTypeId(sensorTypeId); - if (sendorDev == NULL) { - HILOG_ERROR(HILOG_MODULE_SEN, "Failed to obtain sensorId"); - return SENSOR_INVALID_PARAM; - } - if (sendorDev->sensorEnabled) { - HILOG_INFO(HILOG_MODULE_SEN, "sensor has enabled"); - return SENSOR_SUCCESS; - } - sendorDev->sensorEnabled = true; - ThreadAttr attr = {sendorDev->threadName, 0x2000, (uint8_t)osPriorityNormal, 0, 0}; - ThreadId threadId = (ThreadId)SensorThreadCreate(sendorDev->threadFunc, sendorDev, &attr); - if (threadId == NULL) { - return SENSOR_FAILURE; - } - sendorDev->listenDataThreadId = threadId; - return SENSOR_SUCCESS; -} - -static int32_t DisableSensor(int32_t sensorTypeId) -{ - HILOG_DEBUG(HILOG_MODULE_SEN, "enter"); - struct SensorDev *sendorDev = GetSensorBySensorTypeId(sensorTypeId); - if (sendorDev == NULL) { - HILOG_ERROR(HILOG_MODULE_SEN, "Failed to obtain sensorId"); - return SENSOR_INVALID_PARAM; - } - if (!sendorDev->sensorEnabled) { - HILOG_INFO(HILOG_MODULE_SEN, "sensor has not enabled"); - return SENSOR_INVALID_SERVICE; - } - sendorDev->sensorEnabled = false; - sendorDev->listenDataThreadId = NULL; - return SENSOR_SUCCESS; -} - -static int32_t RegisterSensorDataCb(int32_t sensorTypeId, RecordDataCallback cb) -{ - HILOG_DEBUG(HILOG_MODULE_SEN, "enter sensorId:%d", sensorTypeId); - struct SensorDev *sendorDev = GetSensorBySensorTypeId(sensorTypeId); - if (sendorDev == NULL) { - HILOG_ERROR(HILOG_MODULE_SEN, "Failed to obtain sensorId"); - return SENSOR_INVALID_PARAM; - } - SensorMutexLock(sendorDev->mutex); - sendorDev->recordDataCb = cb; - SensorMutexUnLock(sendorDev->mutex); - return SENSOR_SUCCESS; -} - -static int32_t UnregisterSensorDataCb(int32_t sensorTypeId, RecordDataCallback cb) -{ - HILOG_DEBUG(HILOG_MODULE_SEN, "enter sensorId:%d", sensorTypeId); - struct SensorDev *sendorDev = GetSensorBySensorTypeId(sensorTypeId); - if (sendorDev == NULL) { - HILOG_ERROR(HILOG_MODULE_SEN, "Failed to obtain sensorId"); - return SENSOR_INVALID_PARAM; - } - if (!sendorDev->recordDataCb) { - HILOG_ERROR(HILOG_MODULE_SEN, "recordDataCb NOT register"); - return SENSOR_INVALID_SERVICE; - } - SensorMutexLock(sendorDev->mutex); - sendorDev->recordDataCb = NULL; - SensorMutexUnLock(sendorDev->mutex); - return SENSOR_SUCCESS; -} - -static int32_t SetSensorBatch(int32_t sensorTypeId, int64_t samplingInterval, int64_t interval) -{ - HILOG_DEBUG(HILOG_MODULE_SEN, "enter"); - struct SensorDev *sendorDev = GetSensorBySensorTypeId(sensorTypeId); - if (sendorDev == NULL) { - HILOG_ERROR(HILOG_MODULE_SEN, "Failed to obtain sensorId"); - return SENSOR_INVALID_PARAM; - } - if (sendorDev->sensorEnabled) { - HILOG_INFO(HILOG_MODULE_SEN, "sensor has enabled"); - return SENSOR_NOT_SUPPORT; - } - return SENSOR_NOT_SUPPORT; -} - -static int32_t SetSensorMode(int32_t sensorTypeId, int32_t mode) -{ - HILOG_DEBUG(HILOG_MODULE_SEN, "enter"); - struct SensorDev *sendorDev = GetSensorBySensorTypeId(sensorTypeId); - if (sendorDev == NULL) { - HILOG_ERROR(HILOG_MODULE_SEN, "Failed to obtain sensorId"); - return SENSOR_INVALID_PARAM; - } - if (sendorDev->sensorEnabled) { - HILOG_INFO(HILOG_MODULE_SEN, "sensor has enabled"); - return SENSOR_NOT_SUPPORT; - } - return SENSOR_NOT_SUPPORT; -} - -static int32_t SetSensorOption(int32_t sensorTypeId, uint32_t option) -{ - HILOG_DEBUG(HILOG_MODULE_SEN, "enter"); - struct SensorDev *sendorDev = GetSensorBySensorTypeId(sensorTypeId); - if (sendorDev == NULL) { - HILOG_ERROR(HILOG_MODULE_SEN, "Failed to obtain sensorId"); - return SENSOR_INVALID_PARAM; - } - if (sendorDev->sensorEnabled) { - HILOG_INFO(HILOG_MODULE_SEN, "sensor has enabled"); - return SENSOR_NOT_SUPPORT; - } - return SENSOR_NOT_SUPPORT; -} - -void GetSensorDeviceMethods(struct SensorInterface *device) -{ - CHECK_NULL_PTR_RETURN(device); - device->GetAllSensors = GetSensorInfo; - device->Enable = EnableSensor; - device->Disable = DisableSensor; - device->SetBatch = SetSensorBatch; - device->SetMode = SetSensorMode; - device->SetOption = SetSensorOption; - device->Register = RegisterSensorDataCb; - device->Unregister = UnregisterSensorDataCb; -} diff --git a/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/src/sensor_log.c b/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/src/sensor_log.c deleted file mode 100644 index d7151d3ea..000000000 --- a/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/src/sensor_log.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. - * 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. - */ - -#include "sensor_log.h" -#include -#include -#include -#include -#include -#include -#include -#include "sensor_type.h" - -#ifdef ENABLE_INFO_LEVEL_LOG -static SENSOR_LOG_LEVEL g_enabledLevel = SENSOR_LOG_INFO; -#else -static SENSOR_LOG_LEVEL g_enabledLevel = SENSOR_LOG_DEBUG; -#endif - -static const uint32_t MAX_BUFFER_SZ = 256; - -static void LogTime() -{ - struct timeval tv = {}; - gettimeofday(&tv, NULL); - struct tm tm = {}; - localtime_r(&tv.tv_sec, &tm); - const int64_t usecToMsec = 1000; - printf("[%02d:%02d:%02d:%03lld]", tm.tm_hour, tm.tm_min, tm.tm_sec, tv.tv_usec / usecToMsec); -} - -int32_t SensorLogPrintf(SENSOR_LOG_LEVEL level, const char *fmt, ...) -{ - if (level < g_enabledLevel) { - return SENSOR_SUCCESS; - } - if (fmt == NULL) { - return SENSOR_INVALID_PARAM; - } - const char *levelStr = NULL; - char out[MAX_BUFFER_SZ] = {0}; - switch (level) { - case SENSOR_LOG_DEBUG: - levelStr = "D"; - break; - case SENSOR_LOG_INFO: - levelStr = "I"; - break; - case SENSOR_LOG_WARN: - levelStr = "W"; - break; - case SENSOR_LOG_ERR: - levelStr = "E"; - break; - case SENSOR_LOG_FATAL: - levelStr = "F"; - break; - default: - levelStr = "E"; - break; - } - LogTime(); - va_list args; - printf("[%s]", levelStr); - va_start(args, fmt); - int result = vsnprintf_s(out, MAX_BUFFER_SZ, MAX_BUFFER_SZ - 1, fmt, args); - if (result == -1) { - printf("vsnprintf_s failed!\n"); - va_end(args); - return SENSOR_INVALID_PARAM; - } - va_end(args); - printf("%s \n", out); - return SENSOR_SUCCESS; -} - -int32_t SetSensorLogEnabledLevel(SENSOR_LOG_LEVEL level) -{ - if (level < SENSOR_LOG_DEBUG || - level > SENSOR_LOG_FATAL) { - return SENSOR_INVALID_PARAM; - } - g_enabledLevel = level; - return SENSOR_SUCCESS; -} \ No newline at end of file diff --git a/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/src/sensor_manager.c b/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/src/sensor_manager.c deleted file mode 100644 index 5c7d78727..000000000 --- a/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/src/sensor_manager.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * 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. - */ - -#include "sensor_manager.h" -#include -#include "sensor_common.h" -#include "sensor_controller.h" -#include "sensor_if.h" - -#define HDF_LOG_TAG sensor_manager_c - -struct SensorDevManager *GetSensorDevManager(void) -{ - static struct SensorDevManager devManager = { - .initState = false, - .hasSensorListener = false, - }; - - return &devManager; -} - -const struct SensorInterface *NewSensorInterfaceInstance(void) -{ - static struct SensorInterface sensorDevInstance; - struct SensorDevManager *manager = GetSensorDevManager(); - - if (manager->initState) { - return &sensorDevInstance; - } - - // Construct device interface instance - GetSensorDeviceMethods(&sensorDevInstance); - - manager->initState = true; - HILOG_DEBUG(HILOG_MODULE_APP, "Get sensor device instance success"); - return &sensorDevInstance; -} - -int32_t FreeSensorInterfaceInstance(void) -{ - struct SensorDevManager *manager = GetSensorDevManager(); - - if (!manager->initState) { - return SENSOR_SUCCESS; - } - - ReleaseAllSensorInfo(); - - manager->initState = false; - - return SENSOR_SUCCESS; -} diff --git a/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/src/sensor_thread.c b/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/src/sensor_thread.c deleted file mode 100644 index d288e2272..000000000 --- a/code/sdk/open_source/openharmony/drivers/peripheral/sensor/hal/src/sensor_thread.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. - * 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. - */ - -#include "sensor_thread.h" -#include -#include -#include "securec.h" - -#ifndef CMSIS_SUPPORT -pthread_mutex_t g_globalMutexLock = PTHREAD_MUTEX_INITIALIZER; -static void *ThreadMallocZ(uint32_t len) -{ - if (len == 0) { - return NULL; - } - - void *value = malloc(len); - if (value == NULL) { - return NULL; - } - - if (memset_s(value, len, 0, len) != EOK) { - free(value); - value = NULL; - } - - return value; -} -#endif - -MutexId SensorMutexCreate(MutexAttr *attr) -{ -#ifdef CMSIS_SUPPORT - osMutexAttr_t mutexAttr = { NULL, 0, NULL, 0 }; - osMutexAttr_t *pAttr = NULL; - if (attr != NULL && attr->isRecursive) { - mutexAttr.attr_bits |= osMutexRecursive; - pAttr = &mutexAttr; - } - osMutexId_t mutex = osMutexNew(pAttr); - return mutex; -#else - pthread_mutex_t *mutexId = (pthread_mutex_t *)ThreadMallocZ(sizeof(pthread_mutex_t)); - if (mutexId == NULL) { - return NULL; - } - pthread_mutexattr_t mutexAttr = {0}; - pthread_mutexattr_t *pAttr = NULL; - bool needSetAttr = (attr != NULL && attr->isRecursive && pthread_mutexattr_init(&mutexAttr) == 0); - if (needSetAttr) { - if (pthread_mutexattr_settype(&mutexAttr, PTHREAD_MUTEX_RECURSIVE) == 0) { - pAttr = &mutexAttr; - } - } - (void)pthread_mutex_init(mutexId, pAttr); - if (needSetAttr) { - pthread_mutexattr_destroy(&mutexAttr); - } - return mutexId; -#endif -} - -void SensorMutexDestroy(MutexId *mutex) -{ - if (mutex == NULL || *mutex == NULL) { - return; - } -#ifdef CMSIS_SUPPORT - (void)osMutexDelete(*mutex); -#else - if (*mutex == NULL) { - return; - } - - (void)pthread_mutex_destroy((pthread_mutex_t *)*mutex); - free(*mutex); -#endif - *mutex = NULL; -} - -void SensorMutexLock(MutexId mutex) -{ - if (mutex == NULL) { - return; - } - -#ifdef CMSIS_SUPPORT - (void)osMutexAcquire(mutex, osWaitForever); -#else - (void)pthread_mutex_lock((pthread_mutex_t *)mutex); -#endif -} - -void SensorMutexUnLock(MutexId mutex) -{ - if (mutex == NULL) { - return; - } - -#ifdef CMSIS_SUPPORT - (void)osMutexRelease(mutex); -#else - (void)pthread_mutex_unlock((pthread_mutex_t *)mutex); -#endif -} - -void SensorMutexGlobalLock(void) -{ -#ifdef CMSIS_SUPPORT - osKernelLock(); -#else - pthread_mutex_lock(&g_globalMutexLock); -#endif -} - -void SensorMutexGlobalUnLock(void) -{ -#ifdef CMSIS_SUPPORT - osKernelUnlock(); -#else - pthread_mutex_unlock(&g_globalMutexLock); -#endif -} - -void SensorInitStaticMutexLock(MutexId *mutex) -{ - if (mutex == NULL || *mutex != NULL) { - return; - } - - SensorMutexGlobalLock(); - if (*mutex == NULL) { - MutexAttr attr = { false }; - *mutex = SensorMutexCreate(&attr); - } - SensorMutexGlobalUnLock(); -} - -ThreadId SensorThreadCreate(ThreadFunc func, void *argv, const ThreadAttr *attr) -{ - osThreadAttr_t taskAttr = {attr->name, 0, NULL, 0, NULL, attr->stackSize, (osPriority_t)(attr->priority), 0, 0}; - const int MEM_ALIGN = 16; - taskAttr.stack_mem = memalign(MEM_ALIGN, attr->stackSize); - return (ThreadId)osThreadNew((osThreadFunc_t)func, argv, &taskAttr); -} \ No newline at end of file diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/net/http_module.h b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/net/http_module.h deleted file mode 100644 index feeba8f73..000000000 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/net/http_module.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag. 2024-2025. All rights reserved. - * Description: http control interfaces - * Author: Software Group - * Create: 2025-03-28 - */ - -#ifndef HTTP_CLIENT_MODULE_H -#define HTTP_CLIENT_MODULE_H - -#include -#include "jsi.h" -#include -#include -#include "httpclient.h" - -namespace OHOS { -namespace ACELite { - -struct EventCallback { - JSIValue callback; - JSIValue context; - bool isOnce; -}; - -struct ThreadNewObj { - JSIValue thisVal; - HttpClient *newHttpClient; - HttpClientData *newHttpClientData; - char *method; - char *url; - JSIValue header; - JSIValue callback; -}; - -// httpClient -constexpr char METHOD[] = "method"; -constexpr char HTTP_CLIENT[] = "httpClient"; -constexpr char URL[] = "url"; -constexpr char HEADER[] = "header"; -constexpr char CLIENT_CERT[] = "clientCert"; - -// httpClientData -constexpr char HTTP_CLIENT_DATA[] = "httpClientData"; -constexpr char POST_BUF[] = "postBuf"; -constexpr char EXTRA_DATA[] = "extraData"; - -// subscriptions -char* DATA_RECEIVE = "dataReceive"; -char* DATA_END = "dataEnd"; -char* DATA_RECEIVE_PROGRESS = "dataReceiveProgress"; -char* DATA_SEND_PROGRESS = "dataSendProgress"; - -class HttpModule final : public MemoryHeap { -public: - HttpModule() = default; - ~HttpModule() = default; - static HttpClient *CreateHttpClient(const JSIValue *args); - static HttpClientData *CreateHttpClientData(const JSIValue *args); - static char *HeaderJsonToString(char* headerJson); - static JSIValue Request(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize); - static JSIValue RequestInStream(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize); - static JSIValue CreateHttp(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize); - static JSIValue On(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize); - static JSIValue Once(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize); - static JSIValue Off(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize); - static JSIValue Destroy(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize); - static std::map eventCallbacks; - static std::map httpClientInstances; - static std::map httpClientDataInstances; - static void OnTerminate(); - static void CheckSubscription(char *type, JSIValue value); - static int GetErrorCode(int8_t errorCode); -}; -void InitHttpModule(JSIValue exports); - -} // namespace ACELite -} // namespace OHOS - -#endif // HTTP_CLIENT_MODULE_H \ No newline at end of file diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_debug.h b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_debug.h deleted file mode 100644 index 00c99b6cc..000000000 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_debug.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - */ - -#ifndef __NET_WEBSOCKET_DEBUG_H__ -#define __NET_WEBSOCKET_DEBUG_H__ - -#include - -#define WS_DBG_LEVEL WEBSOCKET_DBG_ON - -#define WS_INFO_LEVEL WEBSOCKET_DBG_ON - -#define WS_ERR_LEVEL WEBSOCKET_DBG_ON - -/** flag for WEBSOCKET_DEBUGF to enable that debug message */ -#define WEBSOCKET_DBG_ON 0x80U -/** flag for WEBSOCKET_DEBUGF to disable that debug message */ -#define WEBSOCKET_DBG_OFF 0x00U - -#define WEBSOCKET_DEBUG - -#ifdef WEBSOCKET_DEBUG -#define WS_PLATFORM_DIAG(x) \ - do { \ - printf x; \ - } while (0) -#define WEBSOCKET_DEBUGF(debug, message) \ - do { \ - if (((debug)&WEBSOCKET_DBG_ON)) { \ - WS_PLATFORM_DIAG(message); \ - } \ - } while (0) - -#else /* WEBSOCKET_DEBUG */ -#define WEBSOCKET_DEBUGF(debug, message) -#endif /* WEBSOCKET_DEBUG */ - -#endif \ No newline at end of file diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_frame.h b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_frame.h deleted file mode 100644 index 1112cedc9..000000000 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_frame.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - */ - -#ifndef _WS_FRAME_H__ -#define _WS_FRAME_H__ - -#include "net_websocket.h" -#include - -typedef enum _rws_opcode { - WS_OPCODE_CONTINUATION = 0x0, // %x0 denotes a continuation frame - WS_OPCODE_TEXT_FRAME = 0x1, // %x1 denotes a text frame - WS_OPCODE_BINARY_FRAME = 0x2, // %x2 denotes a binary frame - WS_OPCODE_CONNECTION_CLOSE = 0x8, // %x8 denotes a connection close - WS_OPCODE_PING = 0x9, // %x9 denotes a ping - WS_OPCODE_PONG = 0xA // %xA denotes a pong -} WsOpcode; - -typedef enum WsBinaryCode { WS_BINARY_START, WS_BINARY_CONTINUE, WS_BINARY_END } WsBinary; - -typedef struct WsFrameStruct { - void *data; - size_t length; - WsOpcode opcode; - uint8_t mask[4]; /* 4: mask length */ - bool isMasked; - bool isFinished; - uint8_t headerSize; -} WsFrame; - -size_t WsCheckRecvFrameSize(const void *data, const size_t data_size); - -WsFrame *WsFrameCreateWithRecvData(const void *data, const size_t data_size); - -void WsFrameFillWithSendBinData(WsFrame *f, const void *data, const size_t length, WsBinary binType); - -// data - should be null, and setted by newly created. 'data' & 'data_size' can be null -void WsFrameFillWithSendData(WsFrame *f, const void *data, const size_t data_size, bool is_finish); - -// combine datas of 2 frames. combined is 'to' -void WsFrameCombineDatas(WsFrame *to, WsFrame *from); - -WsFrame *WsFrameCreate(void); - -void WsDeleteFrame(WsFrame *f); - -#endif diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_list.h b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_list.h deleted file mode 100644 index 1a34ddc37..000000000 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_list.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - */ - -#ifndef __WS_LIST_H__ -#define __WS_LIST_H__ - -#include - -typedef union WsNodeValueUnion { - void *object; - char *string; -} WsNodeValue; - -typedef struct WsNodeStruct { - WsNodeValue value; - struct WsNodeStruct *next; -} WsNode, WsList; - -WsList *WsListCreate(void); - -void WsListDelete(WsList *list); - -void WsListDeleteClean(WsList **list); - -int WsListAppend(WsList *list, WsNodeValue value); - -#endif diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_opts.h b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_opts.h deleted file mode 100644 index 61ec0835a..000000000 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_opts.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - */ - -#ifndef NET_WEBSOCKET_OPTS_H -#define NET_WEBSOCKET_OPTS_H - -#define WEBSOCKET_RECV_BUFF_SIZE (20 * 1024) - -#define WS_MAX_THRESH_VAL (20 * 1024) /* common TTS play size */ - -#define WS_MAX_CLIENT_NUM 4 - -#define WS_MAX_URI_LENGTH 512 - -#define WS_MAX_DATA_LENGTH (20 * 1024) - -#define WS_HANDSHAKE_BUF_LEN 1024 - -#define WSS_READ_TIMEOUT_MS 100 - - -#endif \ No newline at end of file diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_priv.h b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_priv.h deleted file mode 100644 index 2159d7b66..000000000 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_priv.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - */ - -#ifndef __NET_WEBSOCKET_PRIV_H__ -#define __NET_WEBSOCKET_PRIV_H__ - -#include "lwip/sockets.h" -#include -#include -#include - -#include "net_websocket.h" -#include "net_websocket_type.h" -#include "net_websocket_opts.h" -#include "net_websocket_thread.h" -#include "net_websocket_frame.h" -#include "net_websocket_list.h" - -#ifdef WEBSOCKET_SSL_ENABLE -#include "mbedtls/net_sockets.h" -#include "mbedtls/ssl.h" -#include "mbedtls/entropy.h" -#include "mbedtls/ctr_drbg.h" -#endif - -typedef int WsSocket; -#define WS_INVALID_SOCKET -1 -#define WS_SOCK_CLOSE(sock) closesocket(sock) - -#define O_NONBLOCK 04000 - -#ifdef WEBSOCKET_SSL_ENABLE -typedef struct WsSslStruct { - mbedtls_ssl_context sslCtx; /* mbedtls ssl context */ - mbedtls_net_context netCtx; /* Fill in socket id */ - mbedtls_ssl_config sslConf; /* SSL configuration */ - mbedtls_entropy_context entropy; - mbedtls_ctr_drbg_context ctrDrbg; - mbedtls_x509_crt_profile profile; - mbedtls_x509_crt cacert; - mbedtls_x509_crt clicert; - mbedtls_pk_context pkey; -} WsSsl; -#endif - -struct WebSocketClient { - int clientfd; - int port; - WsSocket socket; - char scheme[WS_MAX_URI_LENGTH]; - char host[WS_MAX_URI_LENGTH]; - char path[WS_MAX_URI_LENGTH]; - - char *secWsProtocol; // "Sec-WebSocket-Protocol" field - char *secWsAccept; // "Sec-WebSocket-Accept" field from handshake - - WsThread workThread; - - int command; - - bool isConnected; // sock connected + handshake done - - void *userObject; - /** Pointer to the callback invoked when a connection message is received */ - WebSocketOnOpenCallback onOpen; - /** Pointer to the callback invoked when a message is received */ - WebSocketOnMessageCallback onMessage; - /** Pointer to the callback invoked when an error message is received */ - WebSocketOnErrorCallback onError; - /** Pointer to the callback invoked when a close message is received */ - WebSocketOnCloseCallback onClose; - - void *received; - size_t receivedSize; // size of 'received' memory - size_t receivedLen; // length of actualy readed message - - WsList *sendFrames; - WsList *recvdFrames; - - WsMutex workMutex; - WsMutex sendMutex; - WsSem exitSem; - -#ifdef WEBSOCKET_SSL_ENABLE - const char *serverCert; /**< Server certification. */ - const char *clientCert; /**< Client certification. */ - const char *clientPk; /**< Client private key. */ - int serverCertLen; /**< Server certification lenght, server_cert buffer size. */ - int clientCertLen; /**< Client certification lenght, client_cert buffer size. */ - int clientPkLen; /**< Client private key lenght, client_pk buffer size. */ - WsSsl *ssl; /**< Ssl content. */ -#endif - char *recvBuffer; - int recvBufferSize; -}; - -void WebSocketClientClosePriv(struct WebSocketClient *clientPtr); - -struct WebSocketClient *WsGetClient(int fd); - -int AllocWsClient(void); - -bool WsParseUrl(const char *url, char *prefix, char *address, char *path, int *port); - -int WsSocketSendTextPriv(struct WebSocketClient *clientPtr, const char *text); - -int WsClientSendBinStartPriv(struct WebSocketClient *clientPtr, const char *data, size_t length); - -int WsClientIdleDataSend(struct WebSocketClient *clientPtr); - -#define COMMAND_IDLE -1 -#define COMMAND_NONE 0 -#define COMMAND_CONNECT_TO_HOST 1 -#define COMMAND_SEND_HANDSHAKE 2 -#define COMMAND_WAIT_HANDSHAKE_RESPONCE 3 -#define COMMAND_INFORM_CONNECTED 4 -#define COMMAND_INFORM_DISCONNECTED 5 - -#define COMMAND_END 9999 - -#endif diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_string.h b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_string.h deleted file mode 100644 index 12451a505..000000000 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_string.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - */ -#ifndef __RWS_STRING_H__ -#define __RWS_STRING_H__ - -#include -#include -#include - -char *WsStringCopy(const char *str); - -char *WsStringCopyLen(const char *str, const size_t len); - -void WsStringDelete(char *str); - -void WsStringDeleteClean(char **str); - -#endif diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_thread.h b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_thread.h deleted file mode 100644 index 9da00ec0f..000000000 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/websocket/include/net_websocket_thread.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - */ - -#ifndef __RWS_THREAD_H__ -#define __RWS_THREAD_H__ - -#include -#include - -#define RWS_WAIT_FOREVER 0xffffffffu - -/** - @brief Callback type of thread function. - @param userObject User object provided during thread creation. - */ -typedef void (*WsThreadFunct)(void *userObject); - -struct WsThreadStruct { - WsThreadFunct threadFunction; - void *userObject; - pthread_t thread; -}; - -/** - @brief Type of all public objects. - */ -typedef void *WsHandle; - -/** - @brief Mutex object handle. - */ -typedef WsHandle WsMutex; - -/** - @brief Mutex object handle. - */ -typedef WsHandle WsSem; - -/** - @brief Thread object handle. - */ -typedef struct WsThreadStruct *WsThread; - -WsThread WsThreadCreate(WsThreadFunct threadFunction, void *userObject); - -void WsThreadMsleep(const unsigned int millisec); - -WsMutex WsMutexCreateRecursive(void); - -void WsMutexLock(WsMutex mutex); - -void WsMutexUnLock(WsMutex mutex); - -void WsMutexDelete(WsMutex mutex); - -WsSem WsSemCreate(void); - -void WsSemDelete(WsSem sem); - -void WsSemSignal(WsSem sem); - - -#endif diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/network_module.cpp b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/network_module.cpp deleted file mode 100644 index e99d6ae93..000000000 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/network_module.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2020 Huawei Device Co., Ltd. - * 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. - */ - -#include "ace_log.h" -#include "js_app_context.h" -#include "js_async_work.h" -#include "product_adapter.h" -#include -#include -#include "media_log.h" -#include "network_module.h" - -namespace OHOS { -namespace ACELite { -NetCallBack NetWorkModule::callback_; - -void NetWorkModule::TriggerCallbackListener(uint8_t netConnectStatus, uint8_t type) -{ - callback_.netParam.status = netConnectStatus; - callback_.netParam.net_type = type; - if (!JsAsyncWork::DispatchAsyncWork(AsyncExecuteCallback, const_cast(&callback_.netParam))) { - MEDIA_ERR_LOG("dispatch async work failed."); - } -} - -static bool ValidJsValue(JSIValue value) -{ - return (value != nullptr) && (!JSI::ValueIsUndefined(value)); -} - -const char* GetNetworkStatusString(uint8_t type, uint8_t status) { - // 网络类型 - const char *networkType; - switch (type) { - case NETWORK_TYPE_WIFI: - networkType = "WIFI"; - break; - case NETWORK_TYPE_BLUETOOTH: - networkType = "Bluetooth"; - break; - default: - networkType = "Unknown Network Type"; - break; - } - - // 连接状态 - const char *connectionStatus; - switch (status) { - case CONNECTION_STATUS_CONNECTING: - connectionStatus = "Connecting"; - break; - case CONNECTION_STATUS_CONNECTED: - connectionStatus = "Connected"; - break; - case CONNECTION_STATUS_DISCONNECTED: - connectionStatus = "Disconnected"; - break; - default: - connectionStatus = "Unknown Status"; - break; - } - - // 静态字符串缓冲区,用于返回结果 - static char result[MAX_STATUS_LENGTH]; - snprintf(result, sizeof(result), "%s: %s", networkType, connectionStatus); - - return result; -} - -void NetWorkModule::AsyncExecuteCallback(void *arg) -{ - NetParam *netParam = static_cast(arg); - if (ValidJsValue(callback_.net_connect_callback) && netParam != nullptr) { - JSIValue result = JSI::CreateString(const_cast(GetNetworkStatusString(netParam->net_type, netParam->status))); - JSIValue argv[ARGC_ONE] = {result}; - JSI::CallFunction(callback_.net_connect_callback, callback_.net_connect_thisVal, argv, ARGC_ONE); - JSI::ReleaseValue(result); - } -} - -JSIValue NetWorkModule::RegisterConnectListener(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum) -{ - if ((args == nullptr) || (argsNum == 0) || JSI::ValueIsUndefined(args[0])) { - HILOG_ERROR(HILOG_MODULE_ACE, "Invalid arguments for registering net connection callback"); - return JSI::CreateUndefined(); - } - - JSI::ReleaseValue(callback_.net_connect_thisVal); - JSI::ReleaseValue(callback_.net_connect_callback); - callback_.net_connect_thisVal = JSI::AcquireValue(thisVal); - callback_.net_connect_callback = JSI::AcquireValue(args[0]); - if (callback_.net_connect_callback == nullptr) { - HILOG_ERROR(HILOG_MODULE_ACE, "Failed to register net connection callback"); - return JSI::CreateUndefined(); - } - - // 可以在注册回调后执行其他必要的操作 - net_connect_status_change(CONNECTION_STATUS_DISCONNECTED, NETWORK_TYPE_BLUETOOTH); - - return JSI::CreateUndefined(); -} - -JSIValue NetWorkModule::UnregisterConnectListener(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum) -{ - if (callback_.net_connect_callback == nullptr) { - HILOG_ERROR(HILOG_MODULE_ACE, "No net connection callback registered to unregister"); - return JSI::CreateUndefined(); - } - JSI::ReleaseValue(callback_.net_connect_thisVal); - JSI::ReleaseValue(callback_.net_connect_callback); - callback_.net_connect_thisVal = nullptr; - callback_.net_connect_callback = nullptr; - - return JSI::CreateUndefined(); -} - -JSIValue NetWorkModule::GetConnectState(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum) -{ - - return JSI::CreateString(const_cast(GetNetworkStatusString(callback_.netParam.net_type, callback_.netParam.status))); -} - -} -} - -#ifdef __cplusplus -extern "C" { -#endif - -void net_connect_status_change(uint8_t netConnectStatus,uint8_t type) -{ - OHOS::ACELite::NetWorkModule::TriggerCallbackListener(netConnectStatus, type); -} - -#ifdef __cplusplus -} -#endif diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/network_module.h b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/network_module.h deleted file mode 100644 index 176cf91ce..000000000 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/network_module.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag. 2024-2025. All rights reserved. - * Description: network wrapper - * Author: SoftwarePlatform Group - * Create: 2024-08-10 - */ - -#ifndef NET_CONNECT_MODULE_H -#define NET_CONNECT_MODULE_H - -#include -#include "acelite_config.h" -#include "jsi.h" -#include "js_async_work.h" -#include "non_copyable.h" -#include "product_adapter.h" -#include "abilityms_slite_client.h" - -#ifdef __cplusplus -extern "C" { -#endif -void net_connect_status_change(uint8_t netConnectStatus, uint8_t type); -#ifdef __cplusplus -}; -#endif - -namespace OHOS { -namespace ACELite { -#define MAX_STATUS_LENGTH 128 -// 网络类型枚举 -typedef enum { - NETWORK_TYPE_WIFI = 0, - NETWORK_TYPE_BLUETOOTH, - NETWORK_TYPE_UNKNOWN -} NetworkType; - -// 连接状态枚举 -typedef enum { - CONNECTION_STATUS_CONNECTING = 0, - CONNECTION_STATUS_CONNECTED, - CONNECTION_STATUS_DISCONNECTED, - CONNECTION_STATUS_UNKNOWN -} ConnectionStatus; - -struct NetParam { - uint8_t status; - uint8_t net_type = -1; -}; - -struct NetCallBack { - JSIValue net_connect_callback = nullptr; - JSIValue net_connect_thisVal = nullptr; - NetParam netParam; -}; - -class NetWorkModule final : public MemoryHeap { -public: - ACE_DISALLOW_COPY_AND_MOVE(NetWorkModule); - NetWorkModule() = default; - ~NetWorkModule() = default; - static NetCallBack callback_; - static JSIValue RegisterConnectListener(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum); - static JSIValue UnregisterConnectListener(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum); - static JSIValue GetConnectState(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum); - static void AsyncExecuteCallback(void *arg); - static void TriggerCallbackListener(uint8_t netConnectStatus, uint8_t type); -}; - -void InitNetWorkModule(JSIValue exports) -{ - JSI::SetModuleAPI(exports, "registerConnectListener", NetWorkModule::RegisterConnectListener); - JSI::SetModuleAPI(exports, "unregisterConnectListener", NetWorkModule::UnregisterConnectListener); - JSI::SetModuleAPI(exports, "getConnectState", NetWorkModule::GetConnectState); -} - -} // namespace ACELite -} // namespace OHOS - -#endif diff --git a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/websocket/websocket_module.cpp b/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/websocket/websocket_module.cpp deleted file mode 100644 index 307e315d1..000000000 --- a/code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/websocket/websocket_module.cpp +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * 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. - */ - -#include -#include "websocket_module.h" -#include "net_websocket.h" -#include -#include "ace_log.h" -#include "errcode.h" -#include "cmsis_os2.h" - -namespace OHOS { -namespace ACELite { - -JSIValue ws; -JSIValue close; -JSIValue on; -JSIValue off; -JSIValue send; -JSIValue connect; - -std::map WebsocketModule::eventCallbacks; - -JSIValue WebsocketModule::CreateWebsocket(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize) -{ - ws = JSI::CreateObject(); - connect = JSI::CreateFunction(WebsocketModule::Connect); - send = JSI::CreateFunction(WebsocketModule::Send); - on = JSI::CreateFunction(WebsocketModule::On); - off = JSI::CreateFunction(WebsocketModule::Off); - close = JSI::CreateFunction(WebsocketModule::Close); - JSI::SetNamedProperty(ws, "send", send); - JSI::SetNamedProperty(ws, "connect", connect); - JSI::SetNamedProperty(ws, "on", on); - JSI::SetNamedProperty(ws, "off", off); - JSI::SetNamedProperty(ws, "close", close); - return ws; -} - -static void OnOpen(int client) -{ - auto it = WebsocketModule::eventCallbacks.find(std::string("open")); - if (it == WebsocketModule::eventCallbacks.end()) { - HILOG_ERROR(HILOG_MODULE_ACE, "Can not find OnOpen Callback!"); - } - JSIValue value = JSI::CreateObject(); - if (value != nullptr) { - JSI::SetNumberProperty(value, "client", client); - } - JSIValue err = JSI::CreateBoolean(false); - JSIValue argv[2] = {err, value}; - if (it != WebsocketModule::eventCallbacks.end()) { - JSI::CallFunction(it->second->callback, it->second->context, argv, 2); - } - JSI::ReleaseValueList(value, err); -} - -static void OnMessage(int client, const char *data, size_t length, bool isFinished,bool isBinary) -{ - auto it = WebsocketModule::eventCallbacks.find(std::string("message")); - if (it == WebsocketModule::eventCallbacks.end()) { - HILOG_ERROR(HILOG_MODULE_ACE, "Can not find OnMessage Callback!"); - } - JSIValue value = JSI::CreateObject(); - if (value != nullptr) { - JSI::SetNumberProperty(value, "length", length); - JSI::SetStringProperty(value, "data", data); - JSI::SetNumberProperty(value, "client", client); - } - JSIValue err = JSI::CreateBoolean(false); - JSIValue argv[2] = {err, value}; - if (it != WebsocketModule::eventCallbacks.end()) { - JSI::CallFunction(it->second->callback, it->second->context, argv, 2); - } - JSI::ReleaseValueList(value, err); -} - -static void OnError(int client, struct WebSocketErrorResult errorResult) -{ - auto it = WebsocketModule::eventCallbacks.find(std::string("error")); - if (it == WebsocketModule::eventCallbacks.end()) { - HILOG_ERROR(HILOG_MODULE_ACE, "Can not find OnError Callback!"); - } - JSIValue value = JSI::CreateObject(); - if (value != nullptr) { - JSI::SetNumberProperty(value, "client", client); - } - JSIValue err = JSI::CreateBoolean(false); - JSIValue argv[2] = {err, value}; - if (it != WebsocketModule::eventCallbacks.end()) { - JSI::CallFunction(it->second->callback, it->second->context, argv, 2); - } - JSI::ReleaseValueList(value, err); -} - -static void OnClose(int client) -{ - auto it = WebsocketModule::eventCallbacks.find(std::string("open")); - if (it == WebsocketModule::eventCallbacks.end()) { - HILOG_ERROR(HILOG_MODULE_ACE, "Can not find OnError Callback!"); - } - JSIValue value = JSI::CreateObject(); - if (value != nullptr) { - JSI::SetNumberProperty(value, "client", client); - } - JSIValue err = JSI::CreateBoolean(false); - JSIValue argv[2] = {err, value}; - if (it != WebsocketModule::eventCallbacks.end()) { - JSI::CallFunction(it->second->callback, it->second->context, argv, 2); - } - JSI::ReleaseValueList(value, err); -} - -JSIValue WebsocketModule::Send(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize) -{ - int client = JSI::ValueToNumber(JSI::AcquireValue(args[1])); - char *message = JSI::ValueToString(JSI::AcquireValue(args[0])); - - size_t length = strlen(message); - int ret = WebSocketClientSendText(client, message, length); - - JSIValue isError; - isError = JSI::CreateBoolean(ret == 0 ? false : true); - JSIValue value = JSI::CreateObject(); - if (value != nullptr) { - JSI::SetNumberProperty(value, "client", client); - } - - JSIValue callback = JSI::AcquireValue(args[2]); - JSIValue argv[ARGC_TWO] = {isError, value}; - JSI::CallFunction(callback, thisVal, argv, ARGC_TWO); - JSI::ReleaseValueList(value, callback); - JSI::ReleaseString(message); - return JSI::CreateUndefined(); -} - -JSIValue WebsocketModule::Connect(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize) -{ - char *url = JSI::ValueToString(JSI::AcquireValue(args[0])); - int client = WebSocketClientConstructor(OnOpen, OnMessage, OnError, OnClose); - if (client < 0) { - HILOG_ERROR(HILOG_MODULE_ACE, "WebSocketClientConstructor fail!"); - return JSI::CreateUndefined(); - } - - int ret = WebSocketClientConnect(client, url,NULL); - if (ret != 0) { - HILOG_ERROR(HILOG_MODULE_ACE, "WebSocketClientConnect fail!"); - return JSI::CreateUndefined(); - } - - JSIValue isError; - isError = JSI::CreateBoolean(ret == 0 ? false : true); - - JSIValue value = JSI::CreateObject(); - if (value != nullptr) { - JSI::SetNumberProperty(value, "client", client); - } - - JSIValue callback = JSI::AcquireValue(args[1]); - JSIValue argv[ARGC_TWO] = {isError, value}; - JSI::CallFunction(callback, thisVal, argv, ARGC_TWO); - JSI::ReleaseValueList(value, callback, isError); - JSI::ReleaseString(url); - return JSI::CreateUndefined(); -} - -JSIValue WebsocketModule::Close(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize) -{ - int client = JSI::ValueToNumber(JSI::AcquireValue(args[0])); - int ret = WebSocketClientClose(client); - if (ret != 0) { - HILOG_ERROR(HILOG_MODULE_ACE, "WebSocketClientConnect fail!"); - } - JSIValue isError; - isError = JSI::CreateBoolean(ret == 0 ? false : true); - JSIValue value = JSI::CreateObject(); - if (value != nullptr) { - JSI::SetNumberProperty(value, "client", client); - } - - JSIValue callback = JSI::AcquireValue(args[1]); - JSIValue argv[ARGC_TWO] = {isError, value}; - JSI::CallFunction(callback, thisVal, argv, ARGC_TWO); - JSI::ReleaseValueList(isError, value, callback); - return JSI::CreateUndefined(); -} - -void WebsocketModule::Destroy() -{ - for (auto it = eventCallbacks.begin(); it != eventCallbacks.end();) { - auto currentIt = it; - ++it; - EventCallback *ec = currentIt->second; - JSI::ReleaseValue(ec->context); - JSI::ReleaseValue(ec->callback); - delete ec; - eventCallbacks.erase(currentIt); - } - eventCallbacks.clear(); - - JSI::ReleaseValue(on); - JSI::ReleaseValue(off); - JSI::ReleaseValue(connect); - JSI::ReleaseValue(close); - JSI::ReleaseValue(send); - JSI::ReleaseValue(ws); -} - -JSIValue WebsocketModule::On(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize) -{ - if (argsSize < 2) { - HILOG_ERROR(HILOG_MODULE_ACE, "Function parameters are not enough!"); - return JSI::CreateBoolean(false); - } - - char *eventName = JSI::ValueToString(JSI::AcquireValue(args[0])); - - auto it = eventCallbacks.find(eventName); - if (it != eventCallbacks.end()) { - EventCallback *oldEc = it->second; - JSI::ReleaseValue(oldEc->callback); - JSI::ReleaseValue(oldEc->context); - delete oldEc; - eventCallbacks.erase(it); - } - - JSIValue callback = JSI::AcquireValue(args[1]); - - EventCallback *ec = new EventCallback; - if (ec != nullptr) { - ec->callback = JSI::AcquireValue(callback); - ec->context = JSI::AcquireValue(thisVal); - eventCallbacks[eventName] = ec; - JSI::ReleaseString(eventName); - JSI::ReleaseValue(callback); - return JSI::CreateBoolean(true); - } else { - JSI::ReleaseString(eventName); - JSI::ReleaseValue(callback); - } - - return JSI::CreateBoolean(false); -} - -JSIValue WebsocketModule::Off(const JSIValue thisVal, const JSIValue *args, uint8_t argsSize) -{ - if (argsSize < 1) { - HILOG_ERROR(HILOG_MODULE_ACE, "Function parameters are not enough!"); - return JSI::CreateBoolean(false); - } - - char *eventName = JSI::ValueToString(JSI::AcquireValue(args[0])); - - auto it = eventCallbacks.find(eventName); - if (it != eventCallbacks.end()) { - JSI::ReleaseValue(it->second->callback); - JSI::ReleaseValue(it->second->context); - delete it->second; - eventCallbacks.erase(it); - JSI::ReleaseString(eventName); - return JSI::CreateBoolean(true); - }else { - HILOG_ERROR(HILOG_MODULE_ACE, "Off failed, target not found!"); - JSI::ReleaseString(eventName); - } - return JSI::CreateBoolean(false); -} - -void InitWebsocketClientModule(JSIValue exports) -{ - JSI::SetModuleAPI(exports, "createWebsocket", WebsocketModule::CreateWebsocket); - JSI::SetOnTerminate(exports, WebsocketModule::OnTerminate); -} - -void WebsocketModule::OnTerminate() -{ - WebsocketModule::Destroy(); -} -} // namespace ACELite -} // namespace OHOS \ No newline at end of file diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/freertos/src/test/lwip_test.c b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/freertos/src/test/lwip_test.c deleted file mode 100644 index 99e96bdba..000000000 --- a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/freertos/src/test/lwip_test.c +++ /dev/null @@ -1,63 +0,0 @@ -#include "lwip_test.h" -#include "lwip/netif.h" -#include "lwip/netifapi.h" -#include "lwip/ethernetif.h" -#define IP_ADDR0 192 -#define IP_ADDR1 168 -#define IP_ADDR2 1 -#define IP_ADDR3 122 - -#define NETMASK_ADDR0 255 -#define NETMASK_ADDR1 255 -#define NETMASK_ADDR2 255 -#define NETMASK_ADDR3 0 - -#define GW_ADDR0 192 -#define GW_ADDR1 168 -#define GW_ADDR2 1 -#define GW_ADDR3 1 - -#define WIFI_DRIVER_IF 801 -#define HWADDR_LEN 6 - -struct netif g_netif; - -err_t my_hw_input(struct pbuf *p, struct netif *netif); - -err_t my_hw_input(struct pbuf *p, struct netif *netif) -{ - (void)p; - (void)netif; - printf("enter my_hw_input\n"); - return 0; -} - -void lwip_test_init(void) -{ - int ret = 0; - ip4_addr_t ip, gw, netmask; - - IP4_ADDR(&ip, IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3); - IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3); - IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3); - - g_netif.hwaddr_len = HWADDR_LEN; - g_netif.hwaddr[0] = 0x00; - g_netif.hwaddr[1] = 0x11; - g_netif.hwaddr[2] = 0x22; - g_netif.hwaddr[3] = 0x33; - g_netif.hwaddr[4] = 0x44; - g_netif.hwaddr[5] = 0x55; - - g_netif.flags = 4; - g_netif.input = my_hw_input; - /* Initilialize the LwIP stack */ - /* add the network interface */ - netif_add(&g_netif, &ip, &netmask, &gw, NULL, ðernetif_init, tcpip_input); - /* Registers the default network interface */ - netif_set_default(&g_netif); - - netif_is_link_up(&g_netif); - /* When the netif is fully configured this function must be called */ - netif_set_up(&g_netif); -} diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/freertos/src/test/socket_test.c b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/freertos/src/test/socket_test.c deleted file mode 100644 index d6f62e2e0..000000000 --- a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/freertos/src/test/socket_test.c +++ /dev/null @@ -1,113 +0,0 @@ -#include "socket_test.h" -#include "lwip/opt.h" -#include "lwip/sys.h" -#include "lwip/api.h" -#include -#include - -#define SERVER_IP "192.168.1.121" -#define SEND_PORT 5002 -#define BUFFER_SIZE 1024 - -void udp_client(void) { - int sockfd; - struct sockaddr_in server_addr; - char buffer[BUFFER_SIZE]; - - // 创建 UDP 套接字 - sockfd = socket(AF_INET, SOCK_DGRAM, 0); - if (sockfd == -1) { - perror("Error creating socket"); - exit(EXIT_FAILURE); - } - - // 设置服务器地址信息 - memset(&server_addr, 0, sizeof(server_addr)); - server_addr.sin_family = AF_INET; - server_addr.sin_port = lwip_htons(SEND_PORT); - if (inet_aton(SERVER_IP, &server_addr.sin_addr) == 0) { - perror("Invalid server IP address"); - close(sockfd); - exit(EXIT_FAILURE); - } - - while (1) { - // 发送数据 - const char *message = "Hello, UDP Server!"; - int len = strlen(message); - printf("send message: \n"); - for (int i = 0; i < len; i++) { - printf(" %x ", message[i]); - } - printf("\n"); - if (sendto(sockfd, message, strlen(message), 0, (struct sockaddr *)&server_addr, sizeof(server_addr)) == -1) { - perror("Error sending data"); - close(sockfd); - exit(EXIT_FAILURE); - } - sleep(1); - } -} - -#define REV_PORT 5001 -#define BUFFER_SIZE 1024 - -void udp_server(void) -{ - int sockfd; - struct sockaddr_in server_addr; - char buffer[BUFFER_SIZE]; - - // 创建 UDP 套接字 - sockfd = socket(AF_INET, SOCK_DGRAM, 0); - if (sockfd == -1) { - perror("Error creating socket"); - exit(EXIT_FAILURE); - } - - // 设置服务器地址信息 - memset(&server_addr, 0, sizeof(server_addr)); - server_addr.sin_family = AF_INET; - server_addr.sin_addr.s_addr = INADDR_ANY; - server_addr.sin_port = lwip_htons(REV_PORT); - - // 绑定套接字 - if (bind(sockfd, (struct sockaddr *)&server_addr, sizeof(server_addr)) == -1) { - perror("Error binding socket"); - close(sockfd); - exit(EXIT_FAILURE); - } - - while (1) { - socklen_t client_len = sizeof(struct sockaddr_in); - struct sockaddr_in client_addr; - - // 接收数据 - ssize_t bytes_received = recvfrom(sockfd, buffer, BUFFER_SIZE, 0, (struct sockaddr *)&client_addr, &client_len); - if (bytes_received == -1) { - perror("Error receiving data"); - continue; - } - - // 打印接收到的数据 - printf("Received message from %s:%d\n", inet_ntoa(client_addr.sin_addr), lwip_ntohs(client_addr.sin_port)); - printf("Received message: %d %s\n", (int)bytes_received, buffer); - printf("message: "); - for (int i = 0; i < bytes_received; i++) { - printf(" %02x ", buffer[i]); - } - printf("\n"); - - // 清空缓冲区 - memset(buffer, 0, BUFFER_SIZE); - // break; - } - - close(sockfd); -} - -void client_init(void) { - printf("___enter client_init function___\n"); - sys_thread_new("server", udp_server, NULL, 4096, 4); - sys_thread_new("client", udp_client, NULL, 4096, 4); -} \ No newline at end of file diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/lwip_test.c b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/lwip_test.c deleted file mode 100644 index 99e96bdba..000000000 --- a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/lwip_test.c +++ /dev/null @@ -1,63 +0,0 @@ -#include "lwip_test.h" -#include "lwip/netif.h" -#include "lwip/netifapi.h" -#include "lwip/ethernetif.h" -#define IP_ADDR0 192 -#define IP_ADDR1 168 -#define IP_ADDR2 1 -#define IP_ADDR3 122 - -#define NETMASK_ADDR0 255 -#define NETMASK_ADDR1 255 -#define NETMASK_ADDR2 255 -#define NETMASK_ADDR3 0 - -#define GW_ADDR0 192 -#define GW_ADDR1 168 -#define GW_ADDR2 1 -#define GW_ADDR3 1 - -#define WIFI_DRIVER_IF 801 -#define HWADDR_LEN 6 - -struct netif g_netif; - -err_t my_hw_input(struct pbuf *p, struct netif *netif); - -err_t my_hw_input(struct pbuf *p, struct netif *netif) -{ - (void)p; - (void)netif; - printf("enter my_hw_input\n"); - return 0; -} - -void lwip_test_init(void) -{ - int ret = 0; - ip4_addr_t ip, gw, netmask; - - IP4_ADDR(&ip, IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3); - IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3); - IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3); - - g_netif.hwaddr_len = HWADDR_LEN; - g_netif.hwaddr[0] = 0x00; - g_netif.hwaddr[1] = 0x11; - g_netif.hwaddr[2] = 0x22; - g_netif.hwaddr[3] = 0x33; - g_netif.hwaddr[4] = 0x44; - g_netif.hwaddr[5] = 0x55; - - g_netif.flags = 4; - g_netif.input = my_hw_input; - /* Initilialize the LwIP stack */ - /* add the network interface */ - netif_add(&g_netif, &ip, &netmask, &gw, NULL, ðernetif_init, tcpip_input); - /* Registers the default network interface */ - netif_set_default(&g_netif); - - netif_is_link_up(&g_netif); - /* When the netif is fully configured this function must be called */ - netif_set_up(&g_netif); -} diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/socket_test.c b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/socket_test.c deleted file mode 100644 index 2e8f48b01..000000000 --- a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/socket_test.c +++ /dev/null @@ -1,113 +0,0 @@ -#include "socket_test.h" -#include "lwip/opt.h" -#include "lwip/sys.h" -#include "lwip/api.h" -#include -#include - -#define SERVER_IP "192.168.1.121" -#define SEND_PORT 5002 -#define BUFFER_SIZE 1024 - -void udp_client(void) { - int sockfd; - struct sockaddr_in server_addr; - char buffer[BUFFER_SIZE]; - - // 创建 UDP 套接字 - sockfd = socket(AF_INET, SOCK_DGRAM, 0); - if (sockfd == -1) { - perror("Error creating socket"); - exit(EXIT_FAILURE); - } - - // 设置服务器地址信息 - memset(&server_addr, 0, sizeof(server_addr)); - server_addr.sin_family = AF_INET; - server_addr.sin_port = lwip_htons(SEND_PORT); - if (inet_aton(SERVER_IP, &server_addr.sin_addr) == 0) { - perror("Invalid server IP address"); - close(sockfd); - exit(EXIT_FAILURE); - } - - while (1) { - // 发送数据 - const char *message = "Hello, UDP Server!"; - int len = strlen(message); - printf("send message: \n"); - for (int i = 0; i < len; i++) { - printf(" %x ", message[i]); - } - printf("\n"); - if (sendto(sockfd, message, strlen(message), 0, (struct sockaddr *)&server_addr, sizeof(server_addr)) == -1) { - perror("Error sending data"); - close(sockfd); - exit(EXIT_FAILURE); - } - sleep(1); - } -} - -#define REV_PORT 5001 -#define BUFFER_SIZE 1024 - -void udp_server(void) -{ - int sockfd; - struct sockaddr_in server_addr; - char buffer[BUFFER_SIZE]; - - // 创建 UDP 套接字 - sockfd = socket(AF_INET, SOCK_DGRAM, 0); - if (sockfd == -1) { - perror("Error creating socket"); - exit(EXIT_FAILURE); - } - - // 设置服务器地址信息 - memset(&server_addr, 0, sizeof(server_addr)); - server_addr.sin_family = AF_INET; - server_addr.sin_addr.s_addr = INADDR_ANY; - server_addr.sin_port = lwip_htons(REV_PORT); - - // 绑定套接字 - if (bind(sockfd, (struct sockaddr *)&server_addr, sizeof(server_addr)) == -1) { - perror("Error binding socket"); - close(sockfd); - exit(EXIT_FAILURE); - } - - while (1) { - socklen_t client_len = sizeof(struct sockaddr_in); - struct sockaddr_in client_addr; - - // 接收数据 - ssize_t bytes_received = recvfrom(sockfd, buffer, BUFFER_SIZE, 0, (struct sockaddr *)&client_addr, &client_len); - if (bytes_received == -1) { - perror("Error receiving data"); - continue; - } - - // 打印接收到的数据 - printf("Received message from %s:%d\n", inet_ntoa(client_addr.sin_addr), lwip_ntohs(client_addr.sin_port)); - printf("Received message: %d %s\n", (int)bytes_received, buffer); - printf("message: "); - for (int i = 0; i < bytes_received; i++) { - printf(" %02x ", buffer[i]); - } - printf("\n"); - - // 清空缓冲区 - memset(buffer, 0, BUFFER_SIZE); - // break; - } - - close(sockfd); -} - -void client_init(void) { - printf("___enter client_init function___\n"); - sys_thread_new("server", udp_server, NULL, 512, 4); - sys_thread_new("client", udp_client, NULL, 512, 4); -} \ No newline at end of file -- 2.17.1