From: Caisking <3449750381@qq.com> Date: Thu, 23 Nov 2023 08:25:53 +0000 (+0800) Subject: ### 功能列表;APPList X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=eecd650e1cfbdc5e6cd7fd4ad8a7a834f69d0270;p=mirrors%2FFD230.git ### 功能列表;APPList ### 省电模式;SaveEle ### 拍照功能;GetPic ### 表盘缩略图选择;Dail ### 通话功能;Phone #### 1.电话簿:PhoneDir #### 2.通话记录:Phone #### 3.拨号盘:PhoneCall #### 4.接听/拨打通话界面:PhoneCalling PhoneRing ### 睡眠记录:Sleep ### 血氧监测:Blood --- diff --git a/.deveco/build/brandy/.sconsign38.db.dblite b/.deveco/build/brandy/.sconsign38.db.dblite new file mode 100644 index 000000000..2dcaf6f90 Binary files /dev/null and b/.deveco/build/brandy/.sconsign38.db.dblite differ diff --git a/.deveco/build/project.checksum b/.deveco/build/project.checksum new file mode 100644 index 000000000..5530d0285 --- /dev/null +++ b/.deveco/build/project.checksum @@ -0,0 +1 @@ +c0389db02554db67956ab00cc608f7b642d47418 \ No newline at end of file diff --git a/.deveco/burntool/fwpkgPath.ini b/.deveco/burntool/fwpkgPath.ini new file mode 100644 index 000000000..be074e967 --- /dev/null +++ b/.deveco/burntool/fwpkgPath.ini @@ -0,0 +1 @@ +C:\Users\caiking\project\1.haisi\FD230\code\sdk\tools\pkg\fwpkg\brandy\upload_app.fwpkg \ No newline at end of file diff --git a/.deveco/burntool/historyConfig.ini b/.deveco/burntool/historyConfig.ini new file mode 100644 index 000000000..6ec488df2 --- /dev/null +++ b/.deveco/burntool/historyConfig.ini @@ -0,0 +1 @@ +{"serialPortValue":"COM7","baudRateValue":"500000","stopBitValue":"0","verifyTypeValue":"0"} \ No newline at end of file diff --git a/.deveco/deveco.cfg b/.deveco/deveco.cfg new file mode 100644 index 000000000..b494bbc21 --- /dev/null +++ b/.deveco/deveco.cfg @@ -0,0 +1,16 @@ +{ + "envs": [ + { + "name": "brandy", + "tool_selected": {}, + "builtin": [ + "uploaders" + ], + "platform": "cfbb", + "board": "brandy", + "product": "" + } + ], + "project_type": "blank", + "blank": {} +} \ No newline at end of file diff --git a/.deveco/deveco.ini b/.deveco/deveco.ini new file mode 100644 index 000000000..c01150364 --- /dev/null +++ b/.deveco/deveco.ini @@ -0,0 +1,45 @@ +; DevEco Project Configuration File +; Version: 3.0.4 +; Core Version: 4.0.400 + +[env] +download_type = +download_name = +download_url = +download_size = +is_reload_rust = init +download_status = +download_profile = +profile_pdf = +framework = cmake + +[env:brandy] +platform = cfbb +board = brandy +framework = cmake +upload_port = +upload_protocol = burn-serial +suite_burn_enable = no +upload_partitions = partition:brandy_app +upload_reset = no +upload_speed = 750000 +build_type = debug +debug_client = gdb +debug_tool = jlink +debug_interface = swd +debug_elf = ./software/code/sdk/output/brandy/acore/brandy-liteos/application.elf +debug_device = CPU CORE|RISC-V|RISC-V +monitor_port = +monitor_speed = 115200 +analysis_compiler_path = ./software/code/sdk/tools/bin/compiler/linx/linx_170/linx-llvm-binary-debug/linx-llvm-binary-release-win-musl/bin/riscv32 +compiler_bin_path = C:\Users\caiking\my_app\DevTools_CFBB_V1.0.6 +custom_build_command = brandy-native-js -release -nhso +analysis_rec_stats = 1 +analysis_mode = 0 +build_config_path = ./software/code/sdk/build/config/target_config/brandy/image_analysis_cfg/module.json + +[partition:brandy_app] +partition_env = brandy +partition_type = app +partition_board = brandy +partition_platform = cfbb diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 000000000..1f75d5089 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,17 @@ +{ + "configurations": [ + { + "name": "DevEco", + "includePath": [ + "${workspaceFolder}/**" + ], + "browse": { + "limitSymbolsToIncludedHeaders": true, + "path": [ + "${workspaceFolder}/**" + ] + } + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..ce6273769 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,34 @@ +{ + "version": "0.2.0", + "configurations": [ + // Deveco auto-generated start + { + "type": "deveco-device-tool-debug", + "request": "launch", + "DevEcoDebugInitPath": "${workspaceRoot}/.deveco/.debug-cache/brandy", + "servertype": "jlink", + "name": "brandy: DevEco GDB Launch", + "executable": "C:/Users/caiking/project/1.haisi/FD230/./software/code/sdk/output/brandy/acore/brandy-liteos/application.elf", + "toolchainBinDir": "C:/Users/caiking/my_app/DevTools_CFBB_V1.0.6/cc_riscv32_win_env", + "projectEnvName": "brandy", + "coreDir": "C:/Users/caiking/my_app/DevEco-Device-Tool/core", + "preLaunchTask": "deveco: run debug server - brandy", + "internalConsoleOptions": "openOnSessionStart" + }, + { + "type": "deveco-device-tool-debug", + "request": "attach", + "DevEcoDebugInitPath": "${workspaceRoot}/.deveco/.debug-cache/brandy", + "servertype": "jlink", + "name": "brandy: DevEco GDB Attach", + "executable": "C:/Users/caiking/project/1.haisi/FD230/./software/code/sdk/output/brandy/acore/brandy-liteos/application.elf", + "toolchainBinDir": "C:/Users/caiking/my_app/DevTools_CFBB_V1.0.6/cc_riscv32_win_env", + "projectEnvName": "brandy", + "coreDir": "C:/Users/caiking/my_app/DevEco-Device-Tool/core", + "preLaunchTask": "deveco: run debug server - brandy", + "internalConsoleOptions": "openOnSessionStart" + } + // Deveco auto-generated end + + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..54fe105db --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,12 @@ +{ + "C_Cpp.default.includePath": [ + "${workspaceFolder}/**" + ], + "C_Cpp.default.browse.path": [ + "${workspaceFolder}/**" + ], + "debug.onTaskErrors": "debugAnyway", + "files.associations": { + "pinctrl_porting.h": "c" + } +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..36cb2db27 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,147 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "deveco: clean - brandy", + "detail": "deveco: autogenerated", + "problemMatcher": [ + "$deveco" + ], + "command": "C:\\Users\\caiking\\my_app\\DevEco-Device-Tool\\core\\deveco-venv\\Scripts\\hos.exe", + "args": [ + "run", + "--target", + "clean", + "--project-dir", + "C:\\Users\\caiking\\project\\1.haisi\\FD230", + "--environment", + "brandy" + ] + }, + { + "label": "deveco: build - brandy", + "detail": "deveco: autogenerated", + "problemMatcher": [ + "$deveco" + ], + "command": "C:\\Users\\caiking\\my_app\\DevEco-Device-Tool\\core\\deveco-venv\\Scripts\\hos.exe", + "args": [ + "run", + "--project-dir", + "C:\\Users\\caiking\\project\\1.haisi\\FD230", + "--environment", + "brandy" + ] + }, + { + "label": "deveco: rebuild - brandy", + "detail": "deveco: autogenerated", + "problemMatcher": [ + "$deveco" + ], + "command": "C:\\Users\\caiking\\my_app\\DevEco-Device-Tool\\core\\deveco-venv\\Scripts\\hos.exe", + "args": [ + "run", + "--target", + "clean", + "--target", + "buildprog", + "--project-dir", + "C:\\Users\\caiking\\project\\1.haisi\\FD230", + "--environment", + "brandy" + ] + }, + { + "label": "deveco: Portion of upload - brandy", + "detail": "deveco: autogenerated", + "problemMatcher": [ + "$deveco" + ], + "command": "C:\\Users\\caiking\\my_app\\DevEco-Device-Tool\\core\\deveco-venv\\Scripts\\hos.exe", + "args": [ + "run", + "--target", + "Portion of upload" + ] + }, + { + "label": "deveco: upload - brandy", + "detail": "deveco: autogenerated", + "problemMatcher": [ + "$deveco" + ], + "command": "C:\\Users\\caiking\\my_app\\DevEco-Device-Tool\\core\\deveco-venv\\Scripts\\hos.exe", + "args": [ + "run", + "--target", + "upload", + "--project-dir", + "C:\\Users\\caiking\\project\\1.haisi\\FD230", + "--environment", + "brandy" + ] + }, + { + "label": "deveco: stack analysis - brandy", + "detail": "deveco: autogenerated", + "problemMatcher": [ + "$deveco" + ], + "command": "C:\\Users\\caiking\\my_app\\DevEco-Device-Tool\\core\\deveco-venv\\Scripts\\hos.exe", + "args": [ + "run", + "--target", + "stackAnalysis", + "--project-dir", + "C:\\Users\\caiking\\project\\1.haisi\\FD230", + "--environment", + "brandy" + ] + }, + { + "label": "deveco: image analysis - brandy", + "detail": "deveco: autogenerated", + "problemMatcher": [ + "$deveco" + ], + "command": "C:\\Users\\caiking\\my_app\\DevEco-Device-Tool\\core\\deveco-venv\\Scripts\\hos.exe", + "args": [ + "run", + "--target", + "imageAnalysis", + "--project-dir", + "C:\\Users\\caiking\\project\\1.haisi\\FD230", + "--environment", + "brandy" + ] + }, + { + "label": "deveco: run debug server - brandy", + "detail": "deveco: autogenerated", + "problemMatcher": { + "pattern": { + "regexp": "^.*$" + }, + "background": { + "activeOnStart": true, + "beginsPattern": "^.*Debug\\sServer\\sConnected*", + "endsPattern": "^.*Listening\\son\\sTCP/IP\\sport.*" + } + }, + "command": "C:\\Users\\caiking\\my_app\\DevEco-Device-Tool\\core\\deveco-venv\\Scripts\\hos.exe", + "args": [ + "debug", + "--interface=server", + "--environment=brandy", + "--client-port=${command:deveco-device-tool.getDebugRemotePort}" + ], + "isBackground": true + } + ], + "options": { + "env": { + "DEVECO_REMOTE_SERVER_PORT": "${command:deveco-device-tool.getRemoteServerPort}" + } + } +} \ No newline at end of file diff --git a/Resource/res/BLUETOOTH.bin b/Resource/res/BLUETOOTH.bin new file mode 100644 index 000000000..d875fde65 Binary files /dev/null and b/Resource/res/BLUETOOTH.bin differ diff --git a/Resource/res/Blood/SaO2.bin b/Resource/res/Blood/SaO2.bin new file mode 100644 index 000000000..7f77e35dc Binary files /dev/null and b/Resource/res/Blood/SaO2.bin differ diff --git a/Resource/res/Blood/Vector.bin b/Resource/res/Blood/Vector.bin new file mode 100644 index 000000000..ea9887da9 Binary files /dev/null and b/Resource/res/Blood/Vector.bin differ diff --git a/Resource/res/Blood/beijing.bin b/Resource/res/Blood/beijing.bin new file mode 100644 index 000000000..960d11214 Binary files /dev/null and b/Resource/res/Blood/beijing.bin differ diff --git a/Resource/res/Blood/boutton.bin b/Resource/res/Blood/boutton.bin new file mode 100644 index 000000000..5be4c17d5 Binary files /dev/null and b/Resource/res/Blood/boutton.bin differ diff --git a/Resource/res/Blood/warning.bin b/Resource/res/Blood/warning.bin new file mode 100644 index 000000000..b8120b857 Binary files /dev/null and b/Resource/res/Blood/warning.bin differ diff --git a/Resource/res/BringhtnessContuolVector.bin b/Resource/res/BringhtnessContuolVector.bin new file mode 100644 index 000000000..21d20587e Binary files /dev/null and b/Resource/res/BringhtnessContuolVector.bin differ diff --git a/Resource/res/CALL_VOLUME.bin b/Resource/res/CALL_VOLUME.bin new file mode 100644 index 000000000..cb2c53a07 Binary files /dev/null and b/Resource/res/CALL_VOLUME.bin differ diff --git a/Resource/res/CHECKBOX_OFF.bin b/Resource/res/CHECKBOX_OFF.bin new file mode 100644 index 000000000..02f4511df Binary files /dev/null and b/Resource/res/CHECKBOX_OFF.bin differ diff --git a/Resource/res/CHECKBOX_ON.bin b/Resource/res/CHECKBOX_ON.bin new file mode 100644 index 000000000..1212ce47e Binary files /dev/null and b/Resource/res/CHECKBOX_ON.bin differ diff --git a/Resource/res/DISPLAY_BRIGHTNESS.bin b/Resource/res/DISPLAY_BRIGHTNESS.bin new file mode 100644 index 000000000..d35045010 Binary files /dev/null and b/Resource/res/DISPLAY_BRIGHTNESS.bin differ diff --git a/Resource/res/Dial/Diallogo.bin b/Resource/res/Dial/Diallogo.bin new file mode 100644 index 000000000..118e7754c Binary files /dev/null and b/Resource/res/Dial/Diallogo.bin differ diff --git a/Resource/res/Dial/KUMI.bin b/Resource/res/Dial/KUMI.bin new file mode 100644 index 000000000..6c6260582 Binary files /dev/null and b/Resource/res/Dial/KUMI.bin differ diff --git a/Resource/res/Dial/Malio.bin b/Resource/res/Dial/Malio.bin new file mode 100644 index 000000000..cf4441b53 Binary files /dev/null and b/Resource/res/Dial/Malio.bin differ diff --git a/Resource/res/Dial/Vector.bin b/Resource/res/Dial/Vector.bin new file mode 100644 index 000000000..489261160 Binary files /dev/null and b/Resource/res/Dial/Vector.bin differ diff --git a/Resource/res/Dial/dog.bin b/Resource/res/Dial/dog.bin new file mode 100644 index 000000000..49f7ff345 Binary files /dev/null and b/Resource/res/Dial/dog.bin differ diff --git a/Resource/res/Dial/setup.bin b/Resource/res/Dial/setup.bin new file mode 100644 index 000000000..0b6c77df1 Binary files /dev/null and b/Resource/res/Dial/setup.bin differ diff --git a/Resource/res/GetPic/camera.bin b/Resource/res/GetPic/camera.bin new file mode 100644 index 000000000..49f2abe79 Binary files /dev/null and b/Resource/res/GetPic/camera.bin differ diff --git a/Resource/res/GetPic/pic_button.bin b/Resource/res/GetPic/pic_button.bin new file mode 100644 index 000000000..5be4c17d5 Binary files /dev/null and b/Resource/res/GetPic/pic_button.bin differ diff --git a/Resource/res/GetPic/smile.bin b/Resource/res/GetPic/smile.bin new file mode 100644 index 000000000..bcb2b081b Binary files /dev/null and b/Resource/res/GetPic/smile.bin differ diff --git a/Resource/res/KUMI_LOGO.bin b/Resource/res/KUMI_LOGO.bin new file mode 100644 index 000000000..bd590ef4f Binary files /dev/null and b/Resource/res/KUMI_LOGO.bin differ diff --git a/Resource/res/MEDIA_VOLUME.bin b/Resource/res/MEDIA_VOLUME.bin new file mode 100644 index 000000000..16f64f013 Binary files /dev/null and b/Resource/res/MEDIA_VOLUME.bin differ diff --git a/Resource/res/Phone/0.bin b/Resource/res/Phone/0.bin new file mode 100644 index 000000000..bc7bf55b1 Binary files /dev/null and b/Resource/res/Phone/0.bin differ diff --git a/Resource/res/Phone/1.bin b/Resource/res/Phone/1.bin new file mode 100644 index 000000000..64eace654 Binary files /dev/null and b/Resource/res/Phone/1.bin differ diff --git a/Resource/res/Phone/2.bin b/Resource/res/Phone/2.bin new file mode 100644 index 000000000..4bb124f1b Binary files /dev/null and b/Resource/res/Phone/2.bin differ diff --git a/Resource/res/Phone/21-avatar-outline 1.bin b/Resource/res/Phone/21-avatar-outline 1.bin new file mode 100644 index 000000000..f123d8b8f Binary files /dev/null and b/Resource/res/Phone/21-avatar-outline 1.bin differ diff --git a/Resource/res/Phone/3.bin b/Resource/res/Phone/3.bin new file mode 100644 index 000000000..b2a915897 Binary files /dev/null and b/Resource/res/Phone/3.bin differ diff --git a/Resource/res/Phone/4.bin b/Resource/res/Phone/4.bin new file mode 100644 index 000000000..4305e5edb Binary files /dev/null and b/Resource/res/Phone/4.bin differ diff --git a/Resource/res/Phone/5.bin b/Resource/res/Phone/5.bin new file mode 100644 index 000000000..301bd19d1 Binary files /dev/null and b/Resource/res/Phone/5.bin differ diff --git a/Resource/res/Phone/6.bin b/Resource/res/Phone/6.bin new file mode 100644 index 000000000..b37f07a88 Binary files /dev/null and b/Resource/res/Phone/6.bin differ diff --git a/Resource/res/Phone/7.bin b/Resource/res/Phone/7.bin new file mode 100644 index 000000000..4837f770b Binary files /dev/null and b/Resource/res/Phone/7.bin differ diff --git a/Resource/res/Phone/8.bin b/Resource/res/Phone/8.bin new file mode 100644 index 000000000..527ee5d34 Binary files /dev/null and b/Resource/res/Phone/8.bin differ diff --git a/Resource/res/Phone/9.bin b/Resource/res/Phone/9.bin new file mode 100644 index 000000000..79f49452c Binary files /dev/null and b/Resource/res/Phone/9.bin differ diff --git a/Resource/res/Phone/Phone_Call.bin b/Resource/res/Phone/Phone_Call.bin new file mode 100644 index 000000000..b5fb6744c Binary files /dev/null and b/Resource/res/Phone/Phone_Call.bin differ diff --git a/Resource/res/Phone/Phone_Ring.bin b/Resource/res/Phone/Phone_Ring.bin new file mode 100644 index 000000000..3934d2d68 Binary files /dev/null and b/Resource/res/Phone/Phone_Ring.bin differ diff --git a/Resource/res/Phone/boy.bin b/Resource/res/Phone/boy.bin new file mode 100644 index 000000000..06dd386ca Binary files /dev/null and b/Resource/res/Phone/boy.bin differ diff --git a/Resource/res/Phone/call.bin b/Resource/res/Phone/call.bin new file mode 100644 index 000000000..82f5574d7 Binary files /dev/null and b/Resource/res/Phone/call.bin differ diff --git a/Resource/res/Phone/del.bin b/Resource/res/Phone/del.bin new file mode 100644 index 000000000..93acb6361 Binary files /dev/null and b/Resource/res/Phone/del.bin differ diff --git a/Resource/res/Phone/girl.bin b/Resource/res/Phone/girl.bin new file mode 100644 index 000000000..94082bdca Binary files /dev/null and b/Resource/res/Phone/girl.bin differ diff --git a/Resource/res/Phone/little-boy.bin b/Resource/res/Phone/little-boy.bin new file mode 100644 index 000000000..34c720726 Binary files /dev/null and b/Resource/res/Phone/little-boy.bin differ diff --git a/Resource/res/Phone/little-girl.bin b/Resource/res/Phone/little-girl.bin new file mode 100644 index 000000000..d59cd7d62 Binary files /dev/null and b/Resource/res/Phone/little-girl.bin differ diff --git a/Resource/res/Phone/microphone-no.bin b/Resource/res/Phone/microphone-no.bin new file mode 100644 index 000000000..d2df91a1e Binary files /dev/null and b/Resource/res/Phone/microphone-no.bin differ diff --git a/Resource/res/Phone/microphone.bin b/Resource/res/Phone/microphone.bin new file mode 100644 index 000000000..7c719cfca Binary files /dev/null and b/Resource/res/Phone/microphone.bin differ diff --git a/Resource/res/Phone/phone-call.bin b/Resource/res/Phone/phone-call.bin new file mode 100644 index 000000000..03acc44d6 Binary files /dev/null and b/Resource/res/Phone/phone-call.bin differ diff --git a/Resource/res/Phone/phone-call1.bin b/Resource/res/Phone/phone-call1.bin new file mode 100644 index 000000000..0f8ea222a Binary files /dev/null and b/Resource/res/Phone/phone-call1.bin differ diff --git a/Resource/res/Phone/phone-off-round.bin b/Resource/res/Phone/phone-off-round.bin new file mode 100644 index 000000000..a08c7895a Binary files /dev/null and b/Resource/res/Phone/phone-off-round.bin differ diff --git a/Resource/res/Phone/phone-off.bin b/Resource/res/Phone/phone-off.bin new file mode 100644 index 000000000..12338573a Binary files /dev/null and b/Resource/res/Phone/phone-off.bin differ diff --git a/Resource/res/Phone/phonedir.bin b/Resource/res/Phone/phonedir.bin new file mode 100644 index 000000000..f123d8b8f Binary files /dev/null and b/Resource/res/Phone/phonedir.bin differ diff --git a/Resource/res/Phone/voice-no.bin b/Resource/res/Phone/voice-no.bin new file mode 100644 index 000000000..90de78f2e Binary files /dev/null and b/Resource/res/Phone/voice-no.bin differ diff --git a/Resource/res/Phone/voice.bin b/Resource/res/Phone/voice.bin new file mode 100644 index 000000000..59f2276a4 Binary files /dev/null and b/Resource/res/Phone/voice.bin differ diff --git a/Resource/res/QUICK_ACCESS.bin b/Resource/res/QUICK_ACCESS.bin new file mode 100644 index 000000000..e09c149a2 Binary files /dev/null and b/Resource/res/QUICK_ACCESS.bin differ diff --git a/Resource/res/Record/RECORD1.bin b/Resource/res/Record/RECORD1.bin new file mode 100644 index 000000000..d1322a55e Binary files /dev/null and b/Resource/res/Record/RECORD1.bin differ diff --git a/Resource/res/Record/RECORD2.bin b/Resource/res/Record/RECORD2.bin new file mode 100644 index 000000000..387fa4073 Binary files /dev/null and b/Resource/res/Record/RECORD2.bin differ diff --git a/Resource/res/Record/RECORD3.bin b/Resource/res/Record/RECORD3.bin new file mode 100644 index 000000000..f1c2f15d6 Binary files /dev/null and b/Resource/res/Record/RECORD3.bin differ diff --git a/Resource/res/Record/RECORD_DELETE_BACKGROUND.bin b/Resource/res/Record/RECORD_DELETE_BACKGROUND.bin new file mode 100644 index 000000000..694867488 Binary files /dev/null and b/Resource/res/Record/RECORD_DELETE_BACKGROUND.bin differ diff --git a/Resource/res/Record/RECORD_PLAY_BACKGROUND.bin b/Resource/res/Record/RECORD_PLAY_BACKGROUND.bin new file mode 100644 index 000000000..57a72780b Binary files /dev/null and b/Resource/res/Record/RECORD_PLAY_BACKGROUND.bin differ diff --git a/Resource/res/Record/RECORD_PLAY_DELETE.bin b/Resource/res/Record/RECORD_PLAY_DELETE.bin new file mode 100644 index 000000000..3734ac8ef Binary files /dev/null and b/Resource/res/Record/RECORD_PLAY_DELETE.bin differ diff --git a/Resource/res/Record/RECORD_PLAY_NEXT.bin b/Resource/res/Record/RECORD_PLAY_NEXT.bin new file mode 100644 index 000000000..72567d16e Binary files /dev/null and b/Resource/res/Record/RECORD_PLAY_NEXT.bin differ diff --git a/Resource/res/Record/RECORD_PLAY_PROVE.bin b/Resource/res/Record/RECORD_PLAY_PROVE.bin new file mode 100644 index 000000000..893d42d9a Binary files /dev/null and b/Resource/res/Record/RECORD_PLAY_PROVE.bin differ diff --git a/Resource/res/Record/RECORD_PLAY_VOLUME.bin b/Resource/res/Record/RECORD_PLAY_VOLUME.bin new file mode 100644 index 000000000..7af937be9 Binary files /dev/null and b/Resource/res/Record/RECORD_PLAY_VOLUME.bin differ diff --git a/Resource/res/Record/UNIVERSAL_PAUSE.bin b/Resource/res/Record/UNIVERSAL_PAUSE.bin new file mode 100644 index 000000000..93008102a Binary files /dev/null and b/Resource/res/Record/UNIVERSAL_PAUSE.bin differ diff --git a/Resource/res/Record/UNIVERSAL_PLAY.bin b/Resource/res/Record/UNIVERSAL_PLAY.bin new file mode 100644 index 000000000..65be736c3 Binary files /dev/null and b/Resource/res/Record/UNIVERSAL_PLAY.bin differ diff --git a/Resource/res/Record/animator1.bin b/Resource/res/Record/animator1.bin new file mode 100644 index 000000000..96f896968 Binary files /dev/null and b/Resource/res/Record/animator1.bin differ diff --git a/Resource/res/Record/animator2.bin b/Resource/res/Record/animator2.bin new file mode 100644 index 000000000..aa9e47652 Binary files /dev/null and b/Resource/res/Record/animator2.bin differ diff --git a/Resource/res/SETTING_BACKGROUND.bin b/Resource/res/SETTING_BACKGROUND.bin new file mode 100644 index 000000000..abffa0ed8 Binary files /dev/null and b/Resource/res/SETTING_BACKGROUND.bin differ diff --git a/Resource/res/SETTING_NEXT.bin b/Resource/res/SETTING_NEXT.bin index fccee00b9..1a68bf4f1 100644 Binary files a/Resource/res/SETTING_NEXT.bin and b/Resource/res/SETTING_NEXT.bin differ diff --git a/Resource/res/SOUND_VIBRATION.bin b/Resource/res/SOUND_VIBRATION.bin new file mode 100644 index 000000000..229cb6c1d Binary files /dev/null and b/Resource/res/SOUND_VIBRATION.bin differ diff --git a/Resource/res/SYSTEM.bin b/Resource/res/SYSTEM.bin new file mode 100644 index 000000000..4942e1cbe Binary files /dev/null and b/Resource/res/SYSTEM.bin differ diff --git a/Resource/res/SYSTEM_ABOUT_THE_WATCH.bin b/Resource/res/SYSTEM_ABOUT_THE_WATCH.bin new file mode 100644 index 000000000..80d4c93fa Binary files /dev/null and b/Resource/res/SYSTEM_ABOUT_THE_WATCH.bin differ diff --git a/Resource/res/SYSTEM_CheckOff.bin b/Resource/res/SYSTEM_CheckOff.bin new file mode 100644 index 000000000..fb89e49c2 Binary files /dev/null and b/Resource/res/SYSTEM_CheckOff.bin differ diff --git a/Resource/res/SYSTEM_CheckOn.bin b/Resource/res/SYSTEM_CheckOn.bin new file mode 100644 index 000000000..2e1463050 Binary files /dev/null and b/Resource/res/SYSTEM_CheckOn.bin differ diff --git a/Resource/res/SYSTEM_FACTORY_RESET.bin b/Resource/res/SYSTEM_FACTORY_RESET.bin new file mode 100644 index 000000000..8f865576d Binary files /dev/null and b/Resource/res/SYSTEM_FACTORY_RESET.bin differ diff --git a/Resource/res/SYSTEM_FactoryReset.bin b/Resource/res/SYSTEM_FactoryReset.bin new file mode 100644 index 000000000..803e4346b Binary files /dev/null and b/Resource/res/SYSTEM_FactoryReset.bin differ diff --git a/Resource/res/SYSTEM_REBOOT.bin b/Resource/res/SYSTEM_REBOOT.bin new file mode 100644 index 000000000..ac88ca2bb Binary files /dev/null and b/Resource/res/SYSTEM_REBOOT.bin differ diff --git a/Resource/res/SYSTEM_SHOUTDOWM.bin b/Resource/res/SYSTEM_SHOUTDOWM.bin new file mode 100644 index 000000000..5fb1c58ef Binary files /dev/null and b/Resource/res/SYSTEM_SHOUTDOWM.bin differ diff --git a/Resource/res/SYSTEM_SUPERVISE.bin b/Resource/res/SYSTEM_SUPERVISE.bin new file mode 100644 index 000000000..af74f08aa Binary files /dev/null and b/Resource/res/SYSTEM_SUPERVISE.bin differ diff --git a/Resource/res/SYSTEM_SYSTEM_LANGUAGE.bin b/Resource/res/SYSTEM_SYSTEM_LANGUAGE.bin new file mode 100644 index 000000000..1ebc74b5c Binary files /dev/null and b/Resource/res/SYSTEM_SYSTEM_LANGUAGE.bin differ diff --git a/Resource/res/SYSTEM_ShoutDown.bin b/Resource/res/SYSTEM_ShoutDown.bin new file mode 100644 index 000000000..8ee51a27d Binary files /dev/null and b/Resource/res/SYSTEM_ShoutDown.bin differ diff --git a/Resource/res/SYSTEM_VOLUME.bin b/Resource/res/SYSTEM_VOLUME.bin new file mode 100644 index 000000000..95333ff29 Binary files /dev/null and b/Resource/res/SYSTEM_VOLUME.bin differ diff --git a/Resource/res/SYSTEM__Reboot.bin b/Resource/res/SYSTEM__Reboot.bin new file mode 100644 index 000000000..fb50225d1 Binary files /dev/null and b/Resource/res/SYSTEM__Reboot.bin differ diff --git a/Resource/res/Save_Ele/Battery-E.bin b/Resource/res/Save_Ele/Battery-E.bin new file mode 100644 index 000000000..f6fe312e4 Binary files /dev/null and b/Resource/res/Save_Ele/Battery-E.bin differ diff --git a/Resource/res/Save_Ele/Battery-F.bin b/Resource/res/Save_Ele/Battery-F.bin new file mode 100644 index 000000000..7b3c3a859 Binary files /dev/null and b/Resource/res/Save_Ele/Battery-F.bin differ diff --git a/Resource/res/Save_Ele/SaveEle.bin b/Resource/res/Save_Ele/SaveEle.bin new file mode 100644 index 000000000..59d8ed98a Binary files /dev/null and b/Resource/res/Save_Ele/SaveEle.bin differ diff --git a/Resource/res/Save_Ele/Save_Error.bin b/Resource/res/Save_Ele/Save_Error.bin new file mode 100644 index 000000000..fb89e49c2 Binary files /dev/null and b/Resource/res/Save_Ele/Save_Error.bin differ diff --git a/Resource/res/Save_Ele/Save_Right.bin b/Resource/res/Save_Ele/Save_Right.bin new file mode 100644 index 000000000..2e1463050 Binary files /dev/null and b/Resource/res/Save_Ele/Save_Right.bin differ diff --git a/Resource/res/Save_Ele/finger.bin b/Resource/res/Save_Ele/finger.bin new file mode 100644 index 000000000..9cbfbac9d Binary files /dev/null and b/Resource/res/Save_Ele/finger.bin differ diff --git a/Resource/res/Save_Ele/finger2.bin b/Resource/res/Save_Ele/finger2.bin new file mode 100644 index 000000000..b08089fff Binary files /dev/null and b/Resource/res/Save_Ele/finger2.bin differ diff --git a/Resource/res/Save_Ele/wathch.bin b/Resource/res/Save_Ele/wathch.bin new file mode 100644 index 000000000..7ae6bf2ac Binary files /dev/null and b/Resource/res/Save_Ele/wathch.bin differ diff --git a/Resource/res/SleepTime/Battery-E.bin b/Resource/res/SleepTime/Battery-E.bin new file mode 100644 index 000000000..f6fe312e4 Binary files /dev/null and b/Resource/res/SleepTime/Battery-E.bin differ diff --git a/Resource/res/SleepTime/Battery-F.bin b/Resource/res/SleepTime/Battery-F.bin new file mode 100644 index 000000000..7b3c3a859 Binary files /dev/null and b/Resource/res/SleepTime/Battery-F.bin differ diff --git a/Resource/res/SleepTime/Ellipse 185.bin b/Resource/res/SleepTime/Ellipse 185.bin new file mode 100644 index 000000000..976b16634 Binary files /dev/null and b/Resource/res/SleepTime/Ellipse 185.bin differ diff --git a/Resource/res/SleepTime/Line 1.bin b/Resource/res/SleepTime/Line 1.bin new file mode 100644 index 000000000..c76a3d11a Binary files /dev/null and b/Resource/res/SleepTime/Line 1.bin differ diff --git a/Resource/res/SleepTime/Line 2.bin b/Resource/res/SleepTime/Line 2.bin new file mode 100644 index 000000000..6ebe6c809 Binary files /dev/null and b/Resource/res/SleepTime/Line 2.bin differ diff --git a/Resource/res/SleepTime/Line 3.bin b/Resource/res/SleepTime/Line 3.bin new file mode 100644 index 000000000..2f1218c8a Binary files /dev/null and b/Resource/res/SleepTime/Line 3.bin differ diff --git a/Resource/res/SleepTime/Vector.bin b/Resource/res/SleepTime/Vector.bin new file mode 100644 index 000000000..48ab51d86 Binary files /dev/null and b/Resource/res/SleepTime/Vector.bin differ diff --git a/Resource/res/SleepTime/Vector2.bin b/Resource/res/SleepTime/Vector2.bin new file mode 100644 index 000000000..ef5f8a5f5 Binary files /dev/null and b/Resource/res/SleepTime/Vector2.bin differ diff --git a/Resource/res/SleepTime/button.bin b/Resource/res/SleepTime/button.bin new file mode 100644 index 000000000..3364f30ac Binary files /dev/null and b/Resource/res/SleepTime/button.bin differ diff --git a/Resource/res/SleepTime/finger.bin b/Resource/res/SleepTime/finger.bin new file mode 100644 index 000000000..9cbfbac9d Binary files /dev/null and b/Resource/res/SleepTime/finger.bin differ diff --git a/Resource/res/SleepTime/finger2.bin b/Resource/res/SleepTime/finger2.bin new file mode 100644 index 000000000..b08089fff Binary files /dev/null and b/Resource/res/SleepTime/finger2.bin differ diff --git a/Resource/res/SleepTime/quan.bin b/Resource/res/SleepTime/quan.bin new file mode 100644 index 000000000..981f836d1 Binary files /dev/null and b/Resource/res/SleepTime/quan.bin differ diff --git a/Resource/res/SleepTime/room.bin b/Resource/res/SleepTime/room.bin new file mode 100644 index 000000000..481b31a43 Binary files /dev/null and b/Resource/res/SleepTime/room.bin differ diff --git a/Resource/res/SleepTime/up.bin b/Resource/res/SleepTime/up.bin new file mode 100644 index 000000000..96f896968 Binary files /dev/null and b/Resource/res/SleepTime/up.bin differ diff --git a/Resource/res/SleepTime/wathch.bin b/Resource/res/SleepTime/wathch.bin new file mode 100644 index 000000000..7ae6bf2ac Binary files /dev/null and b/Resource/res/SleepTime/wathch.bin differ diff --git a/Resource/res/TOGGLEBUTTON_OFF.bin b/Resource/res/TOGGLEBUTTON_OFF.bin new file mode 100644 index 000000000..d96672bf3 Binary files /dev/null and b/Resource/res/TOGGLEBUTTON_OFF.bin differ diff --git a/Resource/res/TOGGLEBUTTON_ON.bin b/Resource/res/TOGGLEBUTTON_ON.bin new file mode 100644 index 000000000..99056d1b6 Binary files /dev/null and b/Resource/res/TOGGLEBUTTON_ON.bin differ diff --git a/Resource/res/Training record.bin b/Resource/res/Training record.bin new file mode 100644 index 000000000..26664922a Binary files /dev/null and b/Resource/res/Training record.bin differ diff --git a/Resource/res/VolumeControlVector.bin b/Resource/res/VolumeControlVector.bin new file mode 100644 index 000000000..da3928e81 Binary files /dev/null and b/Resource/res/VolumeControlVector.bin differ diff --git a/Resource/res/blood.bin b/Resource/res/blood.bin new file mode 100644 index 000000000..cc9c66482 Binary files /dev/null and b/Resource/res/blood.bin differ diff --git a/Resource/res/bloodpressure.bin b/Resource/res/bloodpressure.bin new file mode 100644 index 000000000..66dc07e85 Binary files /dev/null and b/Resource/res/bloodpressure.bin differ diff --git a/Resource/res/boold oxygen.bin b/Resource/res/boold oxygen.bin new file mode 100644 index 000000000..cc9c66482 Binary files /dev/null and b/Resource/res/boold oxygen.bin differ diff --git a/Resource/res/chronometer.bin b/Resource/res/chronometer.bin new file mode 100644 index 000000000..2284a6a5d Binary files /dev/null and b/Resource/res/chronometer.bin differ diff --git a/Resource/res/clock.bin b/Resource/res/clock.bin new file mode 100644 index 000000000..61b893e48 Binary files /dev/null and b/Resource/res/clock.bin differ diff --git a/Resource/res/compass/COMPASS_END_BACK_TRACKING.bin b/Resource/res/compass/COMPASS_END_BACK_TRACKING.bin new file mode 100644 index 000000000..eb9a17e01 Binary files /dev/null and b/Resource/res/compass/COMPASS_END_BACK_TRACKING.bin differ diff --git a/Resource/res/compass/COMPASS_END_BACK_TRACKING_EARLY.bin b/Resource/res/compass/COMPASS_END_BACK_TRACKING_EARLY.bin new file mode 100644 index 000000000..d94c849ce Binary files /dev/null and b/Resource/res/compass/COMPASS_END_BACK_TRACKING_EARLY.bin differ diff --git a/Resource/res/compass/COMPASS_END_PATH_RECORD.bin b/Resource/res/compass/COMPASS_END_PATH_RECORD.bin new file mode 100644 index 000000000..4d847352d Binary files /dev/null and b/Resource/res/compass/COMPASS_END_PATH_RECORD.bin differ diff --git a/Resource/res/compass/COMPASS_GPS_LOSS.bin b/Resource/res/compass/COMPASS_GPS_LOSS.bin new file mode 100644 index 000000000..f14758991 Binary files /dev/null and b/Resource/res/compass/COMPASS_GPS_LOSS.bin differ diff --git a/Resource/res/compass/COMPASS_PATH_BACKTRACKING.bin b/Resource/res/compass/COMPASS_PATH_BACKTRACKING.bin new file mode 100644 index 000000000..6e203b391 Binary files /dev/null and b/Resource/res/compass/COMPASS_PATH_BACKTRACKING.bin differ diff --git a/Resource/res/compass/COMPASS_PATH_BACKTRACKING_DIRECT.bin b/Resource/res/compass/COMPASS_PATH_BACKTRACKING_DIRECT.bin new file mode 100644 index 000000000..9025b565d Binary files /dev/null and b/Resource/res/compass/COMPASS_PATH_BACKTRACKING_DIRECT.bin differ diff --git a/Resource/res/compass/COMPASS_RESET_PLACE_MAKER_BACKGROUND.bin b/Resource/res/compass/COMPASS_RESET_PLACE_MAKER_BACKGROUND.bin new file mode 100644 index 000000000..307b505f8 Binary files /dev/null and b/Resource/res/compass/COMPASS_RESET_PLACE_MAKER_BACKGROUND.bin differ diff --git a/Resource/res/compass/COMPASS_START_PATH_RECORD.bin b/Resource/res/compass/COMPASS_START_PATH_RECORD.bin new file mode 100644 index 000000000..6684c3cec Binary files /dev/null and b/Resource/res/compass/COMPASS_START_PATH_RECORD.bin differ diff --git a/Resource/res/compass/MAKER_POINT_BACKGROUND.bin b/Resource/res/compass/MAKER_POINT_BACKGROUND.bin new file mode 100644 index 000000000..eb172a455 Binary files /dev/null and b/Resource/res/compass/MAKER_POINT_BACKGROUND.bin differ diff --git a/Resource/res/compass/PLACE_MAKER_BACKGROUND.bin b/Resource/res/compass/PLACE_MAKER_BACKGROUND.bin new file mode 100644 index 000000000..19dcbe371 Binary files /dev/null and b/Resource/res/compass/PLACE_MAKER_BACKGROUND.bin differ diff --git a/Resource/res/compass/compass.bin b/Resource/res/compass/compass.bin index 2d0c5d882..8b5b2dbef 100644 Binary files a/Resource/res/compass/compass.bin and b/Resource/res/compass/compass.bin differ diff --git a/Resource/res/compass/compass0.bin b/Resource/res/compass/compass0.bin new file mode 100644 index 000000000..937d73d00 Binary files /dev/null and b/Resource/res/compass/compass0.bin differ diff --git a/Resource/res/compass/compass1.bin b/Resource/res/compass/compass1.bin new file mode 100644 index 000000000..b03f5e344 Binary files /dev/null and b/Resource/res/compass/compass1.bin differ diff --git a/Resource/res/compass/compass2.bin b/Resource/res/compass/compass2.bin new file mode 100644 index 000000000..7ffd4d8a8 Binary files /dev/null and b/Resource/res/compass/compass2.bin differ diff --git a/Resource/res/compass/file.txt b/Resource/res/compass/file.txt new file mode 100644 index 000000000..e69de29bb diff --git a/Resource/res/countdown.bin b/Resource/res/countdown.bin new file mode 100644 index 000000000..16a718da3 Binary files /dev/null and b/Resource/res/countdown.bin differ diff --git a/Resource/res/getpic.bin b/Resource/res/getpic.bin new file mode 100644 index 000000000..a59584962 Binary files /dev/null and b/Resource/res/getpic.bin differ diff --git a/Resource/res/heart rate.bin b/Resource/res/heart rate.bin new file mode 100644 index 000000000..5c0e448a5 Binary files /dev/null and b/Resource/res/heart rate.bin differ diff --git a/Resource/res/music.bin b/Resource/res/music.bin new file mode 100644 index 000000000..203639f96 Binary files /dev/null and b/Resource/res/music.bin differ diff --git a/Resource/res/phone.bin b/Resource/res/phone.bin new file mode 100644 index 000000000..c711f6658 Binary files /dev/null and b/Resource/res/phone.bin differ diff --git a/Resource/res/phonebook.bin b/Resource/res/phonebook.bin new file mode 100644 index 000000000..381dbe9d6 Binary files /dev/null and b/Resource/res/phonebook.bin differ diff --git a/Resource/res/record.bin b/Resource/res/record.bin new file mode 100644 index 000000000..3e7b20054 Binary files /dev/null and b/Resource/res/record.bin differ diff --git a/Resource/res/setting.bin b/Resource/res/setting.bin new file mode 100644 index 000000000..bf4e8395a Binary files /dev/null and b/Resource/res/setting.bin differ diff --git a/Resource/res/sport.bin b/Resource/res/sport.bin new file mode 100644 index 000000000..1c8d1456b Binary files /dev/null and b/Resource/res/sport.bin differ diff --git a/Resource/res/training.bin b/Resource/res/training.bin new file mode 100644 index 000000000..2d76136e5 Binary files /dev/null and b/Resource/res/training.bin differ diff --git a/Resource/res/weather.bin b/Resource/res/weather.bin new file mode 100644 index 000000000..30da839a2 Binary files /dev/null and b/Resource/res/weather.bin differ diff --git a/code/sdk/application/wearable/nativeapp/CMakeLists.txt b/code/sdk/application/wearable/nativeapp/CMakeLists.txt index 653e403e4..c7c3515d0 100644 --- a/code/sdk/application/wearable/nativeapp/CMakeLists.txt +++ b/code/sdk/application/wearable/nativeapp/CMakeLists.txt @@ -9,6 +9,7 @@ set(PUBLIC_HEADER ) set(PRIVATE_HEADER + ${ROOT_DIR}/open_source/openharmony/foundation/ace/ace_engine_lite/interfaces/base ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/clock/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodoxygen/include @@ -35,6 +36,8 @@ set(PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/screensetting/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/uiservice/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/uisample/include + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/InitComponent/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/uisample/uitest/framework/include ${UI_SAMPLE_ROOT}/components ${CMAKE_CURRENT_SOURCE_DIR}/../service/smart_voice/smart_voice_service/interfaces/innerkits/native_c/include @@ -44,6 +47,8 @@ set(PRIVATE_HEADER ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/src/utils/innerkits ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/include ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/src/ui/frameworks + ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/include/service + ${ROOT_DIR}/middleware/services/gui/uikit/ui/interfaces/innerkits ${ROOT_DIR}/open_source/openharmony/foundation/graphic/ui/interfaces/kits/events ${ROOT_DIR}/open_source/openharmony/foundation/graphic/ui/interfaces/kits @@ -54,7 +59,12 @@ set(PRIVATE_HEADER ${ROOT_DIR}/open_source/openharmony/foundation/graphic/ui/frameworks ${ROOT_DIR}/open_source/openharmony/foundation/graphic/surface/interfaces/kits ${ROOT_DIR}/open_source/openharmony/foundation/graphic/ui/interfaces/kits/components + ${ROOT_DIR}/open_source/openharmony/foundation/graphic/service/include + ${ROOT_DIR}/open_source/openharmony/foundation/multimedia/audio_player/interfaces/kits + ${ROOT_DIR}/open_source/openharmony/foundation/multimedia/audiomanager/interfaces/kits/audiomanager + ${ROOT_DIR}/open_source/openharmony/foundation/multimedia/audiomanager/interfaces/kits/audiocommon ${ROOT_DIR}/open_source/openharmony/foundation/multimedia/player/interfaces/kits/ + ${ROOT_DIR}/open_source/openharmony/foundation/multimedia/utils/include ${ROOT_DIR}/include/middleware/services/bts/common ${ROOT_DIR}/include/middleware/services/bts/ble @@ -66,10 +76,12 @@ set(PRIVATE_HEADER set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativelauncher/src/NativeLauncher.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/uiservice/src/ui_service.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativelauncher/src/slices/main/MainPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativelauncher/src/slices/main/MainView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/MainViewSample.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/MainPresenterSample.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/MainSwipeViewGroup.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/ModelListenerSample.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/PresenterTask.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/HealthModel.cpp @@ -179,6 +191,48 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/settings/src/SettingModel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/settings/src/SettingItemView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/key/src/KeyInputListener.cpp + #ʡ�� + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/saveele/src/SaveEleModel.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/saveele/src/SaveElePresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/saveele/src/SaveEleView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/saveele/src/SaveBatPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/saveele/src/SaveBatView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleep/src/SleepPresenter.cpp + #˯�� + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleep/src/SleepView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleep/src/SleepTimePresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleep/src/SleepTimeView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleep/src/SleepActPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleep/src/SleepActView.cpp + #�绰 + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhonePresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneDirView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneDirPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallingView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallingPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallupView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallupPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneRingView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneRingPresenter.cpp + #�������� + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/getpic/src/GetPicPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/getpic/src/GetPicView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/getpic/src/TakePicPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/getpic/src/TakePicView.cpp + #Ѫ�� + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/blood/src/BloodView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/blood/src/BloodPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/blood/src/BloodShowView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/blood/src/BloodShowPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/blood/src/BloodCheckView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/blood/src/BloodCheckPresenter.cpp + #���� + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/dial/src/DialView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/dial/src/DialPresenter.cpp + #ָ���� ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassControlView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassCalibrationView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassModel.cpp @@ -186,6 +240,27 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/MainCompassView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/MainCompassPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/PlaceMakerCompassPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/PlaceMakerCompassView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/MakerPointCompassPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/MakerPointCompassView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/StartPathRecordCompassPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/StartPathRecordCompassView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/EndPathRecordCompassPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/EndPathRecordCompassView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/PathBackTrackingCompassPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/PathBackTrackingCompassView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/ResetPlaceMakerCompassPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/ResetPlaceMakerCompassView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/PathRetracingCompassPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/PathRetracingCompassView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/EndBackTrackingEarlyCompassPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/EndBackTrackingEarlyCompassView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/EndBackTrackingCompassPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/EndBackTrackingCompassView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/GPSLossCompassPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/GPSLossCompassView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phoneservice/src/PhoneService.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phoneservice/src/PhoneAudio.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/offlinevoice/src/VocassistModel.cpp @@ -196,7 +271,48 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/alarmclockmanage/src/AlarmClockManage.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/rtcservice/src/RtcService.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/uiservice/src/ui_service.cpp + + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/DisplayBrightnessView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/brightnesscontrol/src/BrightnessControlPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/brightnesscontrol/src/BrightnessControlView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/screenduration/src/ScreenDurationPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/screenduration/src/ScreenDurationView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bluetoothofsetting/src/BlueToothOfSettingModel.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bluetoothofsetting/src/BlueToothOfSettingPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bluetoothofsetting/src/BlueToothOfSettingView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp #�������𶯵�presenter� + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SoundAndVibrationView.cpp #�������𶯵�vie� + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/systemvolume/src/SystemVolumePresenter.cpp #ϵͳ���� + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/systemvolume/src/SystemVolumeView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/quickaccess/src/QuickAccessPresenter.cpp #���ٷ��ʵ�presenter� + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/quickaccess/src/QuickAccessView.cpp #���ٷ��ʵ�View� + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemPresenter.cpp #ϵͳpresenter� + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemView.cpp #ϵͳView� + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/systemaboutwatch/src/SystemAboutPresenter.cpp #ϵͳ�������ֱ���View� + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/systemaboutwatch/src/SystemAboutView.cpp #ϵͳ�������ֱ���presenter� + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/systemsupervise/src/SystemSupervisePresenter.cpp #ϵͳ����ܵ�View� + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/systemsupervise/src/SystemSuperviseView.cpp #ϵͳ����ܵ�presenter� + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/systemlanguage/src/SystemLanguagePresenter.cpp #ϵͳ��ϵͳ���Ե�View� + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/systemlanguage/src/SystemLanguageView.cpp #ϵͳ��ϵͳ���Ե�presenter� + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordListPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordListView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordPlayPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordPlayView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordDeletePresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordDeleteView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordGoingPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordGoingView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/systemreboot/src/SystemRebootPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/systemreboot/src/SystemRebootView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/steamshoutdown/src/SystemShoutDownPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/steamshoutdown/src/SystemShoutDownView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/steamfactoryreset/src/SystemFactoryResetPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/steamfactoryreset/src/SystemFactoryResetView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/InitComponent/src/InitComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/uisample/src/UISampleView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/uisample/src/UISamplePresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/uisample/src/UISampleModel.cpp diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h index 698decade..cab6cc1d4 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h @@ -39,13 +39,74 @@ typedef enum : uint16_t { VIEW_OFFLINEVOICE, VIEW_WIFI, VIEW_VOLUME, - VIEW_COMPASS, VIEW_CONNECT_PHONE, VIEW_MAIN_TEMP, VIEW_INDOORWALK, VIEW_REBOOT, - VIEW_UISAMPLE, - VIEW_MAX_INTER_APP, // 在此之前添加native应用ID. + VIEW_UISAMPLE, // 实例 + VIEW_GETPIC, // 手势拍照 + VIEW_TAKEPIC, // 拍照 + VIEW_BLOOD, // 血氧 + VIEW_BLOODSHOW, // 血氧说明 + VIEW_BLOODCHECK, // 血氧检查 + VIEW_DIAL, // 表盘 + VIEW_DIALSETUP, // 表盘安装 + VIEW_DIALSUCCES, // 表盘安装成功 + VIEW_SAVEELE, // 省电模式 + VIEW_SAVEBAT, // 省电模式界面 + VIEW_COMPASS, // 指南针 + VIEW_COMPASS_PLACE_MAKER, // 指南针:放置标记点 + VIEW_COMPASS_MAKER_POINT, // 指南针:标记点介绍 + VIEW_COMPASS_START_PATH_RECORD, // 指南针:开始路径记录 + VIEW_COMPASS_END_PATH_RECORD, // 指南针:结束路径记录 + VIEW_COMPASS_PATH_BACKTRACKING, // 指南针:路径回溯 + VIEW_COMPASS_RESET_PLACE_MAKER, // 指南针:重置标记点 + VIEW_COMPASS_PATH_RETRACING, // 指南针:路径回溯中 + VIEW_COMPASS_GPS_LOSS, // 指南针:GPS丢失 + VIEW_COMPASS_END_BACK_TRACKING, // 指南针:结束路径回溯 + VIEW_COMPASS_END_BACK_TRACKING_EARLY, // 指南针:提前结束路径回溯 + VIEW_SPORT, // 活动 + VIEW_HEARTRATE, // 心率 + VIEW_TRAINING, // 训练 + VIEW_TRAINING_RECORD, // 训练记录 + VIEW_BLOODPRESSURE, // 昨日睡眠时间 + VIEW_SLEEPTIME, // 睡眠详细数据 + VIEW_SLEEPACT, // 睡眠事项说明 + VIEW_MUSIC, // 音乐 + VIEW_WEATHER, // 天气 + VIEW_RECORD, // 录音 + // 录音 + VIEW_RECORD_LIST, + VIEW_RECORD_PLAY, + VIEW_RECORD_DELETE, + VIEW_RECORD_GOING, + //电话 + VIEW_PHONE, // 电话 + VIEW_PHONECALL, // 拨号 + VIEW_PHONERING, // 拨号界面 + VIEW_PHONECALLING, // 来电 + VIEW_PHONECALLUP, // 通话界面 + VIEW_PHONEDIR, // 电话簿 + VIEW_CHRONOMETER, // 秒表 + VIEW_COUNTDOWN, // 计时器 + VIEW_BLUETOOTH, // 蓝牙 + // 设置 + VIEW_DISPLAY_BRIGHTNESS, // 屏幕与亮度 + VIEW_CONNECT_BLUETOOTH, // 蓝牙 + VIEW_SOUND_VIBRATION, // 声音与震动 + VIEW_SYSTEM_VOLUME, // 系统音量 + VIEW_QUICK_ACCESS, // 快速访问 + VIEW_SYSTEM, // 系统 + // 系统 + VIEW_SYSTEM_ABOUT_WATCH, // 系统:关于手表 + VIEW_SYSTEM_SUPERVISE, // 系统:监管 + VIEW_SYSTEM_SYSTEM_LANGUAGE, // 系统:系统语言 + VIEW_SYSTEM_REBOOT, // 系统:重新启动 + VIEW_SYSTEM_SHOUTDOWN, // 系统:关机 + VIEW_SYSTEM_FACTORY_RESET, // 系统:恢复出厂设置 + VIEW_BRIGHTNESS_CONTROL, // 亮度调节 + VIEW_SCREEN_DURATION, // 亮屏时长 + VIEW_MAX_INTER_APP, // 在此之前添加native应用ID VIEW_EXTERN_APP = 0xFFFE, // 三方应用 VIEW_INVALIDE_APP = 0xFFFF, } AppViewId; diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h index 7b07cbf76..8b76c7a07 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h @@ -41,7 +41,53 @@ public: void InitMainTempSlice(void); void InitIndoorWalkSlice(void); void InitRebootSlice(void); - void InitUISampleSlice(void); + void InitUISampleSlice(void); //ʾÀý + void InitSaveEleSlice(void); + void InitSaveBatSlice(void); + void InitSleepSlice(void); + void InitSleepTimeSlice(void); + void InitSleepActSlice(void); + void InitGetPicSlice(void); + void InitTakePicSlice(void); + void InitBloodSlice(void); + void InitBloodShowSlice(void); + void InitBloodCheckSlice(void); + void InitDialSlice(void); + void InitPhoneSlice(void); + void InitPhoneCallSlice(void); + void InitPhoneDirSlice(void); + void InitPhoneCallingSlice(void); + void InitPhoneCallupSlice(void); + void InitPhoneRingSlice(void); + void InitUIDisplayBrightnessSlice(void); //ÏÔʾÓëÁÁ¶È + void InitBlueToothSettingSlice(void); //À¶ÑÀÉèÖà + void InitBrightnessControlSlice(void); //ÁÁ¶Èµ÷½Ú + void InitScreenDurationSlice(void); //ÁÁÆÁʱ³¤ + void InitSoundAndVibrationSlice(void); //ÉùÒôÓëÕ𶯠+ void InitSystemVolumeSlice(void); //ϵͳÒôÁ¿ + void InitQuickAccessSlice(void); //¿ìËÙ·ÃÎÊ + void InitSystemSlice(void); //ϵͳ + void InitSystemAboutWatchSlice(void); //ϵͳ£º¹ØÓÚÊÖ±í + void InitSystemSuperviseSlice(void); //ϵͳ£º¼à¹Ü + void InitSystemLanguageSlice(void); //ϵͳ£ºÏµÍ³ÓïÑÔ + void InitSystemRebootSlice(void); //ϵͳ£ºÖØÐÂÆô¶¯ + void InitSystemShoutDownSlice(void); //ϵͳ£º¹Ø»ú + void InitSystemFactoryResetSlice(void); //ϵͳ£º»Ö¸´³ö³§ÉèÖà + void InitRecordingSlice(void); //¼Òô + void InitRecordingListSlice(void); //¼ÒôÁбí + void InitRecordingPlaySlice(void); //¼Òô²¥·Å + void InitRecordingDeleteSlice(void); //¼Òôɾ³ý + void InitRecordingGoingSlice(void); //ÕýÔÚ¼Òô + void InitCompassPlaceMakerSlice(void); //Ö¸ÄÏÕ룺·ÅÖñê¼Çµã + void InitCompassMakerPointSlice(void); //Ö¸ÄÏÕ룺±ê¼Çµã½éÉÜ + void InitCompassStartPathRecordSlice(void); //Ö¸ÄÏÕ룺¿ªÊ¼Â·¾¶¼Ç¼ + void InitCompassEndPathRecordSlice(void); //Ö¸ÄÏÕ룺½áÊøÂ·¾¶¼Ç¼ + void InitCompassPathBackTrackingSlice(void); //Ö¸ÄÏÕ룺·¾¶»ØËÝ + void InitCompassResetPlaceMakerSlice(void); //Ö¸ÄÏÕë£ºÖØÖñê¼Çµã + void InitCompassPathRetracingSlice(void); //Ö¸ÄÏÕ룺·¾¶»ØËÝÖÐ + void InitCompassEndBackTrackingEarlySlice(); //Ö¸ÄÏÕ룺Ìáǰ½áÊøÂ·¾¶»ØËÝ + void InitCompassEndBackTrackingSlice(void); //Ö¸ÄÏÕ룺½áÊøÂ·¾¶»ØËÝ + void InitCompassGPSLossSlice(void); //Ö¸ÄÏÕ룺GPS¶ªÊ§ private: void InitAllNativeSlices(void); diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h index dd1cfaeda..98e5731ea 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h @@ -12,311 +12,400 @@ #include "ohos_types.h" #include "graphic_config.h" -namespace OHOS { - #ifndef UNUSED - #define UNUSED(x) ((void)(x)) - #endif +namespace OHOS +{ +#ifndef UNUSED +#define UNUSED(x) ((void)(x)) +#endif - #define LA_HORIZONTAL_RESOLUTION 400 // watch width - #define LA_VERTICAL_RESOLUTION 400 // watch height - #define NORMAL_BUTTON_WIDTH 100 // normal button width - #define NORMAL_BUTTON_HEIGHT 50 // normal button height - #define NORMAL_MARGIN 5 // normal margin - #define DIAL_SQUARE 250 // watch plate sauqre - #define SETTING_ITEM_HEIGHT 100 // setting item height - #define UN_OPACITY 255 // UN_OPACITY +#define LA_HORIZONTAL_RESOLUTION 400 // watch width +#define LA_VERTICAL_RESOLUTION 400 // watch height +#define NORMAL_BUTTON_WIDTH 100 // normal button width +#define NORMAL_BUTTON_HEIGHT 50 // normal button height +#define NORMAL_MARGIN 5 // normal margin +#define DIAL_SQUARE 250 // watch plate sauqre +#define SETTING_ITEM_HEIGHT 100 // setting item height +#define UN_OPACITY 255 // UN_OPACITY - #define MILLESECOND 1 - #define SECOND 1000 // 1s 1000ms - #define MINUTE (60 * SECOND) // 1min 60s - #define HOUR (60 * MINUTE) // 1hour 60min +#define MILLESECOND 1 +#define SECOND 1000 // 1s 1000ms +#define MINUTE (60 * SECOND) // 1min 60s +#define HOUR (60 * MINUTE) // 1hour 60min - #define FONT_COMMON 20 // 20px - #define X_DRAG_OFFSET 20 - #define DOUBLES 2 +#define FONT_COMMON 20 // 20px +#define X_DRAG_OFFSET 20 +#define DOUBLES 2 - #define APP_RES_PATH "/user/res" - #define APP_MUSIC_PATH "/user/music" - #define APP_VIDEO_PATH "/user/video" +#define APP_RES_PATH "/user/res" +#define APP_MUSIC_PATH "/user/music" +#define APP_VIDEO_PATH "/user/video" static constexpr const char *CARD_CONFIG_PATH = "/user/cardconfig.bin"; - static constexpr const char *CLOCK_IAMGES = APP_RES_PATH"/clock/clock.bin"; - static constexpr const char *PLAYER_IAMGES = APP_RES_PATH"/player/player.bin"; - static constexpr const char *COMPASS_IAMGES = APP_RES_PATH"/compass/compass.bin"; - static constexpr const char *DROPDOWN_IAMGES = APP_RES_PATH"/dropdown/dropdown.bin"; - static constexpr const char *HEART_IAMGES = APP_RES_PATH"/heart/heart.bin"; - static constexpr const char *PNG_BLUETOOTH_HINTS_PATH = APP_RES_PATH"/BLUETOOTH_HINTS.bin"; - static constexpr const char *PNG_BLOODOXYGEN_IMAGE_PATH = APP_RES_PATH"/BLOODOXYGEN_VIEW.bin"; + static constexpr const char *CLOCK_IAMGES = APP_RES_PATH "/clock/clock.bin"; + static constexpr const char *PLAYER_IAMGES = APP_RES_PATH "/player/player.bin"; + static constexpr const char *COMPASS_IAMGES = APP_RES_PATH "/compass/compass.bin"; + static constexpr const char *DROPDOWN_IAMGES = APP_RES_PATH "/dropdown/dropdown.bin"; + static constexpr const char *HEART_IAMGES = APP_RES_PATH "/heart/heart.bin"; + static constexpr const char *PNG_BLUETOOTH_HINTS_PATH = APP_RES_PATH "/BLUETOOTH_HINTS.bin"; + static constexpr const char *PNG_BLOODOXYGEN_IMAGE_PATH = APP_RES_PATH "/BLOODOXYGEN_VIEW.bin"; - static constexpr const char *PNG_BLOOD_ICON_ENTER = APP_RES_PATH"/BLOOD_ICON_ENTER.bin"; + static constexpr const char *PNG_BLOOD_ICON_ENTER = APP_RES_PATH "/BLOOD_ICON_ENTER.bin"; - static constexpr const char *PNG_AGREEING_IMAGE_PATH = APP_RES_PATH"/AGREEING.bin"; - static constexpr const char *PNG_DISSGREE_IMAGE_PATH = APP_RES_PATH"/DISSGREE.bin"; - static constexpr const char *PNG_MICROPHONE_OPEN_IMAGE_PATH = APP_RES_PATH"/MICRO_PHONE_OPEN.bin"; - static constexpr const char *PNG_MICROPHONE_CLOSE_IMAGE_PATH = APP_RES_PATH"/MICRO_PHONE_CLOSE.bin"; - static constexpr const char *PNG_HANDUP_IMAGE_PATH = APP_RES_PATH"/HANDUP.bin"; - static constexpr const char *PNG_ANSWER_TMAGE_PATH = APP_RES_PATH"/ANSWER_PHONE.bin"; - static constexpr const char *PNG_CALLING_TMAGE_PATH = APP_RES_PATH"/CALLING_PHONE.bin"; - static constexpr const char *PNG_CALLER_TMAGE_PATH = APP_RES_PATH"/CALLER_LOG_IMAGE.bin"; - static constexpr const char *PNG_NO_CALLER_LOG_IMAGE = APP_RES_PATH"/NO_CALLER_LOG_IMAGE.bin"; - static constexpr const char *PNG_APPLIST_CALLER_IMAGE = APP_RES_PATH"/APPLIST_CALLER_IMAGE.bin"; - static constexpr const char *PNG_APPLIST_COMPASS_IMAGE = APP_RES_PATH"/APPLIST_COMPASS_IMAGE.bin"; + static constexpr const char *PNG_AGREEING_IMAGE_PATH = APP_RES_PATH "/AGREEING.bin"; + static constexpr const char *PNG_DISSGREE_IMAGE_PATH = APP_RES_PATH "/DISSGREE.bin"; + static constexpr const char *PNG_MICROPHONE_OPEN_IMAGE_PATH = APP_RES_PATH "/MICRO_PHONE_OPEN.bin"; + static constexpr const char *PNG_MICROPHONE_CLOSE_IMAGE_PATH = APP_RES_PATH "/MICRO_PHONE_CLOSE.bin"; + static constexpr const char *PNG_HANDUP_IMAGE_PATH = APP_RES_PATH "/HANDUP.bin"; + static constexpr const char *PNG_ANSWER_TMAGE_PATH = APP_RES_PATH "/ANSWER_PHONE.bin"; + static constexpr const char *PNG_CALLING_TMAGE_PATH = APP_RES_PATH "/CALLING_PHONE.bin"; + static constexpr const char *PNG_CALLER_TMAGE_PATH = APP_RES_PATH "/CALLER_LOG_IMAGE.bin"; + static constexpr const char *PNG_NO_CALLER_LOG_IMAGE = APP_RES_PATH "/NO_CALLER_LOG_IMAGE.bin"; + static constexpr const char *PNG_APPLIST_CALLER_IMAGE = APP_RES_PATH "/APPLIST_CALLER_IMAGE.bin"; + static constexpr const char *PNG_APPLIST_COMPASS_IMAGE = APP_RES_PATH "/APPLIST_COMPASS_IMAGE.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_0 = APP_RES_PATH"/COUNTDOWN_IMAGE_01.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_1 = APP_RES_PATH"/COUNTDOWN_IMAGE_02.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_2 = APP_RES_PATH"/COUNTDOWN_IMAGE_03.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_3 = APP_RES_PATH"/COUNTDOWN_IMAGE_04.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_4 = APP_RES_PATH"/COUNTDOWN_IMAGE_05.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_5 = APP_RES_PATH"/COUNTDOWN_IMAGE_06.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_6 = APP_RES_PATH"/COUNTDOWN_IMAGE_07.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_7 = APP_RES_PATH"/COUNTDOWN_IMAGE_08.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_8 = APP_RES_PATH"/COUNTDOWN_IMAGE_09.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_9 = APP_RES_PATH"/COUNTDOWN_IMAGE_10.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_10 = APP_RES_PATH"/COUNTDOWN_IMAGE_11.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_11 = APP_RES_PATH"/COUNTDOWN_IMAGE_12.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_12 = APP_RES_PATH"/COUNTDOWN_IMAGE_13.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_13 = APP_RES_PATH"/COUNTDOWN_IMAGE_14.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_14 = APP_RES_PATH"/COUNTDOWN_IMAGE_15.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_15 = APP_RES_PATH"/COUNTDOWN_IMAGE_16.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_16 = APP_RES_PATH"/COUNTDOWN_IMAGE_17.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_17 = APP_RES_PATH"/COUNTDOWN_IMAGE_18.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_18 = APP_RES_PATH"/COUNTDOWN_IMAGE_19.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_19 = APP_RES_PATH"/COUNTDOWN_IMAGE_20.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_20 = APP_RES_PATH"/COUNTDOWN_IMAGE_21.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_21 = APP_RES_PATH"/COUNTDOWN_IMAGE_22.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_22 = APP_RES_PATH"/COUNTDOWN_IMAGE_23.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_23 = APP_RES_PATH"/COUNTDOWN_IMAGE_24.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_0 = APP_RES_PATH "/COUNTDOWN_IMAGE_01.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_1 = APP_RES_PATH "/COUNTDOWN_IMAGE_02.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_2 = APP_RES_PATH "/COUNTDOWN_IMAGE_03.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_3 = APP_RES_PATH "/COUNTDOWN_IMAGE_04.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_4 = APP_RES_PATH "/COUNTDOWN_IMAGE_05.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_5 = APP_RES_PATH "/COUNTDOWN_IMAGE_06.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_6 = APP_RES_PATH "/COUNTDOWN_IMAGE_07.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_7 = APP_RES_PATH "/COUNTDOWN_IMAGE_08.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_8 = APP_RES_PATH "/COUNTDOWN_IMAGE_09.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_9 = APP_RES_PATH "/COUNTDOWN_IMAGE_10.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_10 = APP_RES_PATH "/COUNTDOWN_IMAGE_11.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_11 = APP_RES_PATH "/COUNTDOWN_IMAGE_12.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_12 = APP_RES_PATH "/COUNTDOWN_IMAGE_13.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_13 = APP_RES_PATH "/COUNTDOWN_IMAGE_14.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_14 = APP_RES_PATH "/COUNTDOWN_IMAGE_15.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_15 = APP_RES_PATH "/COUNTDOWN_IMAGE_16.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_16 = APP_RES_PATH "/COUNTDOWN_IMAGE_17.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_17 = APP_RES_PATH "/COUNTDOWN_IMAGE_18.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_18 = APP_RES_PATH "/COUNTDOWN_IMAGE_19.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_19 = APP_RES_PATH "/COUNTDOWN_IMAGE_20.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_20 = APP_RES_PATH "/COUNTDOWN_IMAGE_21.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_21 = APP_RES_PATH "/COUNTDOWN_IMAGE_22.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_22 = APP_RES_PATH "/COUNTDOWN_IMAGE_23.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_23 = APP_RES_PATH "/COUNTDOWN_IMAGE_24.bin"; - static constexpr const char *PNG_PROGRESS_BAR_TMAGE = APP_RES_PATH"/PROGRESS_BAR_TMAGE.bin"; - static constexpr const char *TEMP_WAITING = APP_RES_PATH"/TEMP_WAITING.bin"; - static constexpr const char *TEMP_REPORT = APP_RES_PATH"/TEMP_REPORT.bin"; - static constexpr const char *TEMP_POINT = APP_RES_PATH"/TEMP_POINT.bin"; - static constexpr const char *TEMP_REV_POINTER = APP_RES_PATH"/TEMP_REV_POINTER.bin"; + static constexpr const char *PNG_PROGRESS_BAR_TMAGE = APP_RES_PATH "/PROGRESS_BAR_TMAGE.bin"; + static constexpr const char *TEMP_WAITING = APP_RES_PATH "/TEMP_WAITING.bin"; + static constexpr const char *TEMP_REPORT = APP_RES_PATH "/TEMP_REPORT.bin"; + static constexpr const char *TEMP_POINT = APP_RES_PATH "/TEMP_POINT.bin"; + static constexpr const char *TEMP_REV_POINTER = APP_RES_PATH "/TEMP_REV_POINTER.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_0 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_02.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_1 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_03.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_2 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_04.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_3 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_05.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_4 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_06.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_5 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_07.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_6 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_08.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_7 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_09.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_8 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_10.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_9 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_11.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_10 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_12.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_11 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_13.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_12 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_14.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_13 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_15.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_14 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_16.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_15 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_17.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_16 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_18.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_17 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_19.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_18 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_20.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_19 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_21.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_20 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_22.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_21 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_23.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_22 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_24.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_23 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_25.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_24 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_26.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_25 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_27.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_26 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_28.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_27 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_29.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_28 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_30.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_29 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_31.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_30 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_32.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_0 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_02.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_1 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_03.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_2 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_04.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_3 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_05.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_4 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_06.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_5 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_07.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_6 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_08.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_7 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_09.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_8 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_10.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_9 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_11.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_10 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_12.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_11 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_13.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_12 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_14.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_13 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_15.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_14 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_16.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_15 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_17.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_16 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_18.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_17 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_19.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_18 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_20.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_19 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_21.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_20 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_22.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_21 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_23.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_22 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_24.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_23 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_25.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_24 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_26.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_25 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_27.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_26 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_28.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_27 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_29.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_28 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_30.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_29 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_31.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_30 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_32.bin"; - static constexpr const char *PNG_SOUNDBUTTON2 = APP_RES_PATH"/SOUND_IMAGE.bin"; - static constexpr const char *PNG_PULLBUTTON_FACE_IMAGE = APP_RES_PATH"/BLOOD_FLOW_IMAGE_01.bin"; - static constexpr const char *MUSIC_2 = APP_RES_PATH"/mp3_48k_caiqing.mp3"; - static constexpr const char *MUSIC_1 = APP_RES_PATH"/one.mp3"; + static constexpr const char *PNG_SOUNDBUTTON2 = APP_RES_PATH "/SOUND_IMAGE.bin"; + static constexpr const char *PNG_PULLBUTTON_FACE_IMAGE = APP_RES_PATH "/BLOOD_FLOW_IMAGE_01.bin"; + static constexpr const char *MUSIC_2 = APP_RES_PATH "/mp3_48k_caiqing.mp3"; + static constexpr const char *MUSIC_1 = APP_RES_PATH "/one.mp3"; - static constexpr const char *PNG_SETTTING_BUTTON_IMAGE = APP_RES_PATH"/SETTTING_BUTTON.bin"; - static constexpr const char *PNG_BLUETOOTH_IMAGE = APP_RES_PATH"/BLUETOOTH_IMAGE.bin"; - static constexpr const char *PNG_WATCH_IMAGE = APP_RES_PATH"/WATCH_IMAGE.bin"; - static constexpr const char *PNG_PHONE_IMAGE = APP_RES_PATH"/PHONE_IMAGE.bin"; - static constexpr const char *PNG_REBOOT_BUTTON_IMAGE = APP_RES_PATH"/REBOOT_BUTTON.bin"; - static constexpr const char *PNG_SHUTDOWN_BUTTON_IMAGE = APP_RES_PATH"/SHUTDOWN_BUTTON.bin"; - static constexpr const char *PNG_SETTTING_REBOOT_IMAGE = APP_RES_PATH"/SETTTING_REBOOT.bin"; - static constexpr const char *PNG_SETTTING_SHUTDOWN_IMAGE = APP_RES_PATH"/SETTTING_SHUTDOWN.bin"; + static constexpr const char *PNG_SETTTING_BUTTON_IMAGE = APP_RES_PATH "/SETTTING_BUTTON.bin"; + static constexpr const char *PNG_BLUETOOTH_IMAGE = APP_RES_PATH "/BLUETOOTH_IMAGE.bin"; + static constexpr const char *PNG_WATCH_IMAGE = APP_RES_PATH "/WATCH_IMAGE.bin"; + static constexpr const char *PNG_PHONE_IMAGE = APP_RES_PATH "/PHONE_IMAGE.bin"; + static constexpr const char *PNG_REBOOT_BUTTON_IMAGE = APP_RES_PATH "/REBOOT_BUTTON.bin"; + static constexpr const char *PNG_SHUTDOWN_BUTTON_IMAGE = APP_RES_PATH "/SHUTDOWN_BUTTON.bin"; + static constexpr const char *PNG_SETTTING_REBOOT_IMAGE = APP_RES_PATH "/SETTTING_REBOOT.bin"; + static constexpr const char *PNG_SETTTING_SHUTDOWN_IMAGE = APP_RES_PATH "/SETTTING_SHUTDOWN.bin"; - static constexpr const char *PNG_CONNECT_PHONE_IMAGE = APP_RES_PATH"/CONNECT_PHONE.bin"; - static constexpr const char *PNG_BLUETOOTH_STITLE = APP_RES_PATH"/BLUETOOTH_TITLE.bin"; + static constexpr const char *PNG_CONNECT_PHONE_IMAGE = APP_RES_PATH "/CONNECT_PHONE.bin"; + static constexpr const char *PNG_BLUETOOTH_STITLE = APP_RES_PATH "/BLUETOOTH_TITLE.bin"; - static constexpr const char *PNG_NEW_DEVICE = APP_RES_PATH"/NEW_DEVICE.bin"; - static constexpr const char *PNG_BT_LIST = APP_RES_PATH"/BT_LIST.bin"; - static constexpr const char *PNG_SELECTION_BOX = APP_RES_PATH"/SELECTION_BOX.bin"; - static constexpr const char *PNG_GANTAN = APP_RES_PATH"/GANTAN.bin"; - static constexpr const char *PNG_RIGHT = APP_RES_PATH"/RIGHT.bin"; + static constexpr const char *PNG_DISPLAY_BRIGHTNESS = APP_RES_PATH "/DISPLAY_BRIGHTNESS.bin"; // 显示与亮度 + static constexpr const char *PNG_BLUETOOTH = APP_RES_PATH "/BLUETOOTH.bin"; // 蓝牙 + static constexpr const char *PNG_SOUND_VIBRATION = APP_RES_PATH "/SOUND_VIBRATION.bin"; // 声音与震动 + static constexpr const char *PNG_QUICK_ACCESS = APP_RES_PATH "/QUICK_ACCESS.bin"; // 快速访问 + static constexpr const char *PNG_SYSTEM = APP_RES_PATH "/SYSTEM.bin"; // 系统 - static constexpr const char *PNG_NEW_WLAN_WIFI = APP_RES_PATH"/FULL_SIGNAL_OPEN.bin"; - static constexpr const char *FULL_SIGNAL_ENCRYPTION = APP_RES_PATH"/FULL_SIGNAL_ENCRYPTION.bin"; + static constexpr const char *PNG_NEW_DEVICE = APP_RES_PATH "/NEW_DEVICE.bin"; + static constexpr const char *PNG_BT_LIST = APP_RES_PATH "/BT_LIST.bin"; + static constexpr const char *PNG_SELECTION_BOX = APP_RES_PATH "/SELECTION_BOX.bin"; + static constexpr const char *PNG_GANTAN = APP_RES_PATH "/GANTAN.bin"; + static constexpr const char *PNG_RIGHT = APP_RES_PATH "/RIGHT.bin"; - static constexpr const char *PNG_MAIN_FACE_IMAGE = APP_RES_PATH"/MAIN_FACE_IMAGE.bin"; - static constexpr const char *B024_009_IMAGE_PATH = APP_RES_PATH"/HOURHAND.bin"; - static constexpr const char *B024_010_IMAGE_PATH = APP_RES_PATH"/SECONDHAND.bin"; - static constexpr const char *B024_011_IMAGE_PATH = APP_RES_PATH"/MINUTEHAND.bin"; - static constexpr const char *ALARM_ADD_BUTTON_PATH = APP_RES_PATH"/BLUE_ADD.bin"; - static constexpr const char *ALARM_CLOCK_CLOSE_ADD_PATH = APP_RES_PATH"/CLOSE_RING_CLOCK.bin"; - static constexpr const char *ALARM_CLOCK_ADD_PATH = APP_RES_PATH"/POP_UP_CLOCK.bin"; - static constexpr const char *ALARM_CLOCK_POP_ADD_PATH = APP_RES_PATH"/RING_CLOCK.bin"; - static constexpr const char *ALARM_DELETE_ADD_PATH = APP_RES_PATH"/DELETE.bin"; - static constexpr const char *ALARM_TRUE_ADD_PATH = APP_RES_PATH"/TRUE_ADD.bin"; - static constexpr const char *TEMP_MEASURE = APP_RES_PATH"/TEMP_MEASURE.bin"; - static constexpr const char *TEMP_UP_DROP = APP_RES_PATH"/TEMP_UP_DROP.bin"; - static constexpr const char *TEMP_EXIT = APP_RES_PATH"/TEMP_EXIT.bin"; - static constexpr const char *TEMP_ROTATE = APP_RES_PATH"/TEMP_ROTATE.bin"; - static constexpr const char *TEMP_ICON_ENTER = APP_RES_PATH"/TEMP_ICON_ENTER.bin"; - static constexpr const char *TEMP_BACKGROUND = APP_RES_PATH"/TEMP_BACKGROUND.bin"; - static constexpr const char *TEMP_WARN = APP_RES_PATH"/TEMP_WARN.bin"; - static constexpr const char *TEMP_LITTLE_MEASURE = APP_RES_PATH"/TEMP_LITTLE_MEASURE.bin"; - static constexpr const char *TEMP_HOT = APP_RES_PATH"/TEMP_HOT.bin"; - static constexpr const char *TEMP_COLD = APP_RES_PATH"/TEMP_COLD.bin"; - static constexpr const char *TEMP_LIT_TIP = APP_RES_PATH"/TEMP_LIT_TIP.bin"; - static constexpr const char *TEMP_ABOUT_STUDY = APP_RES_PATH"/TEMP_ABOUT_STUDY.bin"; - static constexpr const char *TEMP_TRUE = APP_RES_PATH"/TEMP_TRUE.bin"; - static constexpr const char *TEMP_DELETE = APP_RES_PATH"/TEMP_DELETE.bin"; + static constexpr const char *PNG_NEW_WLAN_WIFI = APP_RES_PATH "/FULL_SIGNAL_OPEN.bin"; + static constexpr const char *FULL_SIGNAL_ENCRYPTION = APP_RES_PATH "/FULL_SIGNAL_ENCRYPTION.bin"; - static constexpr const char *COMPASS_CALIBRATE_IMAGE = APP_RES_PATH"/COMPASS_CALIBRATE_IMAGE.bin"; - static constexpr const char *PNG_SETTING_NEXT_IMAGE = APP_RES_PATH"/SETTING_NEXT.bin"; + static constexpr const char *PNG_MAIN_FACE_IMAGE = APP_RES_PATH "/MAIN_FACE_IMAGE.bin"; + static constexpr const char *B024_009_IMAGE_PATH = APP_RES_PATH "/HOURHAND.bin"; + static constexpr const char *B024_010_IMAGE_PATH = APP_RES_PATH "/SECONDHAND.bin"; + static constexpr const char *B024_011_IMAGE_PATH = APP_RES_PATH "/MINUTEHAND.bin"; + static constexpr const char *ALARM_ADD_BUTTON_PATH = APP_RES_PATH "/BLUE_ADD.bin"; + static constexpr const char *ALARM_CLOCK_CLOSE_ADD_PATH = APP_RES_PATH "/CLOSE_RING_CLOCK.bin"; + static constexpr const char *ALARM_CLOCK_ADD_PATH = APP_RES_PATH "/POP_UP_CLOCK.bin"; + static constexpr const char *ALARM_CLOCK_POP_ADD_PATH = APP_RES_PATH "/RING_CLOCK.bin"; + static constexpr const char *ALARM_DELETE_ADD_PATH = APP_RES_PATH "/DELETE.bin"; + static constexpr const char *ALARM_TRUE_ADD_PATH = APP_RES_PATH "/TRUE_ADD.bin"; + static constexpr const char *TEMP_MEASURE = APP_RES_PATH "/TEMP_MEASURE.bin"; + static constexpr const char *TEMP_UP_DROP = APP_RES_PATH "/TEMP_UP_DROP.bin"; + static constexpr const char *TEMP_EXIT = APP_RES_PATH "/TEMP_EXIT.bin"; + static constexpr const char *TEMP_ROTATE = APP_RES_PATH "/TEMP_ROTATE.bin"; + static constexpr const char *TEMP_ICON_ENTER = APP_RES_PATH "/TEMP_ICON_ENTER.bin"; + static constexpr const char *TEMP_BACKGROUND = APP_RES_PATH "/TEMP_BACKGROUND.bin"; + static constexpr const char *TEMP_WARN = APP_RES_PATH "/TEMP_WARN.bin"; + static constexpr const char *TEMP_LITTLE_MEASURE = APP_RES_PATH "/TEMP_LITTLE_MEASURE.bin"; + static constexpr const char *TEMP_HOT = APP_RES_PATH "/TEMP_HOT.bin"; + static constexpr const char *TEMP_COLD = APP_RES_PATH "/TEMP_COLD.bin"; + static constexpr const char *TEMP_LIT_TIP = APP_RES_PATH "/TEMP_LIT_TIP.bin"; + static constexpr const char *TEMP_ABOUT_STUDY = APP_RES_PATH "/TEMP_ABOUT_STUDY.bin"; + static constexpr const char *TEMP_TRUE = APP_RES_PATH "/TEMP_TRUE.bin"; + static constexpr const char *TEMP_DELETE = APP_RES_PATH "/TEMP_DELETE.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE01 = APP_RES_PATH"/VOICE_ASSISTANT_01.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE02 = APP_RES_PATH"/VOICE_ASSISTANT_02.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE03 = APP_RES_PATH"/VOICE_ASSISTANT_03.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE04 = APP_RES_PATH"/VOICE_ASSISTANT_04.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE05 = APP_RES_PATH"/VOICE_ASSISTANT_05.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE06 = APP_RES_PATH"/VOICE_ASSISTANT_06.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE07 = APP_RES_PATH"/VOICE_ASSISTANT_07.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE08 = APP_RES_PATH"/VOICE_ASSISTANT_08.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE09 = APP_RES_PATH"/VOICE_ASSISTANT_09.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE10 = APP_RES_PATH"/VOICE_ASSISTANT_10.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE11 = APP_RES_PATH"/VOICE_ASSISTANT_11.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE12 = APP_RES_PATH"/VOICE_ASSISTANT_12.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE13 = APP_RES_PATH"/VOICE_ASSISTANT_13.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE14 = APP_RES_PATH"/VOICE_ASSISTANT_14.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE15 = APP_RES_PATH"/VOICE_ASSISTANT_15.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE16 = APP_RES_PATH"/VOICE_ASSISTANT_16.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE17 = APP_RES_PATH"/VOICE_ASSISTANT_17.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE18 = APP_RES_PATH"/VOICE_ASSISTANT_18.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE19 = APP_RES_PATH"/VOICE_ASSISTANT_19.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE20 = APP_RES_PATH"/VOICE_ASSISTANT_20.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE21 = APP_RES_PATH"/VOICE_ASSISTANT_21.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE22 = APP_RES_PATH"/VOICE_ASSISTANT_22.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE23 = APP_RES_PATH"/VOICE_ASSISTANT_23.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE24 = APP_RES_PATH"/VOICE_ASSISTANT_24.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE25 = APP_RES_PATH"/VOICE_ASSISTANT_25.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE26 = APP_RES_PATH"/VOICE_ASSISTANT_26.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE27 = APP_RES_PATH"/VOICE_ASSISTANT_27.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE28 = APP_RES_PATH"/VOICE_ASSISTANT_28.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE29 = APP_RES_PATH"/VOICE_ASSISTANT_29.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE30 = APP_RES_PATH"/VOICE_ASSISTANT_30.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE31 = APP_RES_PATH"/VOICE_ASSISTANT_31.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE32 = APP_RES_PATH"/VOICE_ASSISTANT_32.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE33 = APP_RES_PATH"/VOICE_ASSISTANT_33.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE34 = APP_RES_PATH"/VOICE_ASSISTANT_34.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE35 = APP_RES_PATH"/VOICE_ASSISTANT_35.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE36 = APP_RES_PATH"/VOICE_ASSISTANT_36.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE37 = APP_RES_PATH"/VOICE_ASSISTANT_37.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE38 = APP_RES_PATH"/VOICE_ASSISTANT_38.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE39 = APP_RES_PATH"/VOICE_ASSISTANT_39.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE40 = APP_RES_PATH"/VOICE_ASSISTANT_40.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE41 = APP_RES_PATH"/VOICE_ASSISTANT_41.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE42 = APP_RES_PATH"/VOICE_ASSISTANT_42.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE43 = APP_RES_PATH"/VOICE_ASSISTANT_43.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE44 = APP_RES_PATH"/VOICE_ASSISTANT_44.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE45 = APP_RES_PATH"/VOICE_ASSISTANT_45.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE46 = APP_RES_PATH"/VOICE_ASSISTANT_46.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE47 = APP_RES_PATH"/VOICE_ASSISTANT_47.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE48 = APP_RES_PATH"/VOICE_ASSISTANT_48.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE49 = APP_RES_PATH"/VOICE_ASSISTANT_49.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE50 = APP_RES_PATH"/VOICE_ASSISTANT_50.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE51 = APP_RES_PATH"/VOICE_ASSISTANT_51.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE52 = APP_RES_PATH"/VOICE_ASSISTANT_52.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE53 = APP_RES_PATH"/VOICE_ASSISTANT_53.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE54 = APP_RES_PATH"/VOICE_ASSISTANT_54.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE55 = APP_RES_PATH"/VOICE_ASSISTANT_55.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE56 = APP_RES_PATH"/VOICE_ASSISTANT_56.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE57 = APP_RES_PATH"/VOICE_ASSISTANT_57.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE58 = APP_RES_PATH"/VOICE_ASSISTANT_58.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE59 = APP_RES_PATH"/VOICE_ASSISTANT_59.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE60 = APP_RES_PATH"/VOICE_ASSISTANT_60.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE61 = APP_RES_PATH"/VOICE_ASSISTANT_61.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE62 = APP_RES_PATH"/VOICE_ASSISTANT_62.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE63 = APP_RES_PATH"/VOICE_ASSISTANT_63.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE64 = APP_RES_PATH"/VOICE_ASSISTANT_64.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE65 = APP_RES_PATH"/VOICE_ASSISTANT_65.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE66 = APP_RES_PATH"/VOICE_ASSISTANT_66.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE67 = APP_RES_PATH"/VOICE_ASSISTANT_67.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE68 = APP_RES_PATH"/VOICE_ASSISTANT_68.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE69 = APP_RES_PATH"/VOICE_ASSISTANT_69.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE70 = APP_RES_PATH"/VOICE_ASSISTANT_70.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE71 = APP_RES_PATH"/VOICE_ASSISTANT_71.bin"; - static constexpr const char *PNG_APPLIST_VOCASSIST_IMAGE = APP_RES_PATH"/APPLIST_VOCASSIST_IMAGE.bin"; + static constexpr const char *COMPASS_CALIBRATE_IMAGE = APP_RES_PATH "/COMPASS_CALIBRATE_IMAGE.bin"; + static constexpr const char *PNG_SETTING_NEXT_IMAGE = APP_RES_PATH "/SETTING_NEXT.bin"; // 箭头图片 + static constexpr const char *PNG_SETTING_BACKGROUND_IMAGE = APP_RES_PATH "/SETTING_BACKGROUND.bin"; // 按钮的背景图片 + static constexpr const char *PNG_BRIGHTNESS_CONTROL_VECTOR = APP_RES_PATH "/BringhtnessContuolVector.bin"; // 调节亮度图片 + static constexpr const char *PNG_VOLUME_CONTROL_VECTOR = APP_RES_PATH "/VolumeControlVector.bin"; // 调节音量图片 + static constexpr const char *PNG_SYSTEM_VOLUME_IMAGE = APP_RES_PATH "/SYSTEM_VOLUME.bin"; // 系统音量 + static constexpr const char *PNG_CALL_VOLUME_IMAGE = APP_RES_PATH "/CALL_VOLUME.bin"; // 通话音量 + static constexpr const char *PNG_MEDIA_VOLUME_IMAGE = APP_RES_PATH "/MEDIA_VOLUME.bin"; // 媒体音量 + static constexpr const char *PNG_CHECKBOX_OFF_IMAGE = APP_RES_PATH "/CHECKBOX_OFF.bin"; // checkbox未选中图片 + static constexpr const char *PNG_CHECKBOX_ON_IMAGE = APP_RES_PATH "/CHECKBOX_ON.bin"; // checkbox选中图片 + static constexpr const char *PNG_TOGGLEBUTTON_OFF_IMAGE = APP_RES_PATH "/TOGGLEBUTTON_OFF.bin"; // togglebuttton未选中图片 + static constexpr const char *PNG_TOGGLEBUTTON_ON_IMAGE = APP_RES_PATH "/TOGGLEBUTTON_ON.bin"; // togglebuttton选中图片 + static constexpr const char *PNG_SYSTEM_ABOUT_THE_WATCH_IMAGE = APP_RES_PATH "/SYSTEM_ABOUT_THE_WATCH.bin"; // 系统:关于手表 + static constexpr const char *PNG_SYSTEM_SUPERVISE_IMAGE = APP_RES_PATH "/SYSTEM_SUPERVISE.bin"; // 系统:监管 + static constexpr const char *PNG_SYSTEM_SYSTEM_LANGUAGE_IMAGE = APP_RES_PATH "/SYSTEM_SYSTEM_LANGUAGE.bin"; // 系统:系统语言 + static constexpr const char *PNG_SYSTEM_REBOOT_IMAGE = APP_RES_PATH "/SYSTEM_REBOOT.bin"; // 系统:重新启动 + static constexpr const char *PNG_SYSTEM_SHOUTDOWM_IMAGE = APP_RES_PATH "/SYSTEM_SHOUTDOWM.bin"; // 系统:关机 + static constexpr const char *PNG_SYSTEM_FACTORY_RESET_IMAGE = APP_RES_PATH "/SYSTEM_FACTORY_RESET.bin"; // 系统:恢复出厂设置 + static constexpr const char *PNG_REBOOT_IMAGE = APP_RES_PATH "/SYSTEM__Reboot.bin"; // 重新启动 + static constexpr const char *PNG_SHOUTDOWN_IMAGE = APP_RES_PATH "/SYSTEM_ShoutDown.bin"; // 关机 + static constexpr const char *PNG_FACTORY_RESET = APP_RES_PATH "/SYSTEM_FactoryReset.bin"; // 恢复出厂设置 + static constexpr const char *PNG_SYSTEM_CHECK_ON_IMAGE = APP_RES_PATH "/SYSTEM_CheckOn.bin"; // 勾 + static constexpr const char *PNG_SYSTEM_CHECK_OFF_IMAGE = APP_RES_PATH "/SYSTEM_CheckOff.bin"; // 叉 + // 录音 + static constexpr const char *PNG_ANIMATOR1_IMAGE = APP_RES_PATH "/Record/animator1.bin"; + static constexpr const char *PNG_ANIMATOR2_IMAGE = APP_RES_PATH "/Record/animator2.bin"; + static constexpr const char *PNG_RECORD1_IMAGE = APP_RES_PATH "/Record/RECORD1.bin"; + static constexpr const char *PNG_RECORD2_IMAGE = APP_RES_PATH "/Record/RECORD2.bin"; + static constexpr const char *PNG_RECORD3_IMAGE = APP_RES_PATH "/Record/RECORD3.bin"; + static constexpr const char *PNG_UNIVERSAL_PAUSE_IMAGE = APP_RES_PATH "/Record/UNIVERSAL_PAUSE.bin"; // 暂停 + static constexpr const char *PNG_UNIVERSAL_PLAY_IMAGE = APP_RES_PATH "/Record/UNIVERSAL_PLAY.bin"; // 播放 + static constexpr const char *PNG_RECORD_PLAY_BACKGROUND_IMAGE = APP_RES_PATH "/Record/RECORD_PLAY_BACKGROUND.bin"; // 背景 + static constexpr const char *PNG_RECORD_PLAY_PROVE_IMAGE = APP_RES_PATH "/Record/RECORD_PLAY_PROVE.bin"; // 上一首 + static constexpr const char *PNG_RECORD_PLAY_NEXT_IMAGE = APP_RES_PATH "/Record/RECORD_PLAY_NEXT.bin"; // 下一首 + static constexpr const char *PNG_RECORD_PLAY_DELETE_IMAGE = APP_RES_PATH "/Record/RECORD_PLAY_DELETE.bin"; // 删除 + static constexpr const char *PNG_RECORD_PLAY_VOLUME_IMAGE = APP_RES_PATH "/Record/RECORD_PLAY_VOLUME.bin"; // 音量 + static constexpr const char *PNG_RECORD_DELETE_BACKGROUND_IMAGE = APP_RES_PATH "/Record/RECORD_DELETE_BACKGROUND.bin"; // 删除录音的背景图 + // 指南针 + static constexpr const char *PNG_COMPASS_BACKGROUND_IMAGE = APP_RES_PATH "/compass/compass0.bin"; // 指南针的背景图片 + static constexpr const char *PNG_COMPASS_PLACE_MARKER_BUTTON_IMAGE = APP_RES_PATH "/compass/compass1.bin"; // 指南针放置标记点按钮图片 + static constexpr const char *PNG_COMPASS_TRIANGULATION_IMAGE = APP_RES_PATH "/compass/compass2.bin"; // 指南针三角形图片 + static constexpr const char *PNG_COMPASS_PLACE_MAKER_BACKGROUND_IMAGE = APP_RES_PATH "/compass/PLACE_MAKER_BACKGROUND.bin"; // 指南针放置标记点背景图片 + static constexpr const char *PNG_COMPASS_MAKER_POINT_BACKGROUND_IMAGE = APP_RES_PATH "/compass/MAKER_POINT_BACKGROUND.bin"; // 指南针标记点介绍背景图片 + static constexpr const char *PNG_COMPASS_START_PATH_RECORD_IMAGE = APP_RES_PATH "/compass/COMPASS_START_PATH_RECORD.bin"; // 指南针开始路径记录图片 + static constexpr const char *PNG_COMPASS_END_PATH_RECORD_IMAGE = APP_RES_PATH "/compass/COMPASS_END_PATH_RECORD.bin"; // 指南针结束路径记录图片 + static constexpr const char *PNG_COMPASS_PATH_BACKTRACKING_IMAGE = APP_RES_PATH "/compass/COMPASS_PATH_BACKTRACKING.bin"; // 指南针路径回溯按钮图片 + static constexpr const char *PNG_COMPASS_RESET_PLACE_MAKER_BACKGROUND_IMAGE = APP_RES_PATH "/compass/COMPASS_RESET_PLACE_MAKER_BACKGROUND.bin"; // 指南针:重置标记点背景图片 + static constexpr const char *PNG_COMPASS_PATH_BACKTRACKING_DIRECT_IMAGE = APP_RES_PATH "/compass/COMPASS_PATH_BACKTRACKING_DIRECT.bin"; // 指南针:路径回溯中的方向箭头图片 + static constexpr const char *PNG_COMPASS_END_BACK_TRACKING_EARLY_IMAGE = APP_RES_PATH "/compass/COMPASS_END_BACK_TRACKING_EARLY.bin"; // 指南针提前结束路径回溯 + static constexpr const char *PNG_COMPASS_END_BACK_TRACKING_IMAGE = APP_RES_PATH "/compass/COMPASS_END_BACK_TRACKING.bin"; // 指南针结束路径回溯 + static constexpr const char *PNG_COMPASS_GPS_LOSS_IMAGE = APP_RES_PATH "/compass/COMPASS_GPS_LOSS.bin"; // 指南针GPS丢失背景图片 + // 睡眠记录 + static constexpr const char *PNG_SLEEP_ROOM_IMAGE = APP_RES_PATH "/SleepTime/room.bin"; + static constexpr const char *PNG_SLEEP_NOTE_IMAGE = APP_RES_PATH "/SleepTime/Ellipse 185.bin"; + static constexpr const char *PNG_SLEEP_UP_IMAGE = APP_RES_PATH "/SleepTime/up.bin"; + static constexpr const char *PNG_SLEEP_VECTOR_IMAGE = APP_RES_PATH "/SleepTime/Vector.bin"; + static constexpr const char *PNG_SLEEP_VECTOR2_IMAGE = APP_RES_PATH "/SleepTime/Vector2.bin"; + static constexpr const char *PNG_SLEEP_LINE1_IMAGE = APP_RES_PATH "/SleepTime/Line 1.bin"; + static constexpr const char *PNG_SLEEP_LINE3_IMAGE = APP_RES_PATH "/SleepTime/Line 3.bin"; + static constexpr const char *PNG_SLEEP_BUTTON_IMAGE = APP_RES_PATH "/SleepTime/button.bin"; + // 手势拍照 + static constexpr const char *PNG_GETPIC_CAMERA_IMAGE = APP_RES_PATH "/GetPic/camera.bin"; + static constexpr const char *PNG_GETPIC_PICBOUTTON_IMAGE = APP_RES_PATH "/GetPic/pic_button.bin"; + static constexpr const char *PNG_GETPIC_SMILE_IMAGE = APP_RES_PATH "/GetPic/smile.bin"; + // 省电模式 + static constexpr const char *PNG_SAVEELE_BATE_IMAGE = APP_RES_PATH "/Save_Ele/Battery-E.bin"; + static constexpr const char *PNG_SAVEELE_BATF_IMAGE = APP_RES_PATH "/Save_Ele/Battery-F.bin"; + static constexpr const char *PNG_SAVEELE_FINGER_IMAGE = APP_RES_PATH "/Save_Ele/finger.bin"; + // 通话 - static constexpr const char *PNG_STEP_SHOE_IMAGE_PATH = APP_RES_PATH"/SHOE_IMAGE.bin"; + static constexpr const char *PNG_PHONE_FINGER_IMAGE = APP_RES_PATH "/Save_Ele/finger.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE01 = APP_RES_PATH "/VOICE_ASSISTANT_01.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE02 = APP_RES_PATH "/VOICE_ASSISTANT_02.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE03 = APP_RES_PATH "/VOICE_ASSISTANT_03.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE04 = APP_RES_PATH "/VOICE_ASSISTANT_04.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE05 = APP_RES_PATH "/VOICE_ASSISTANT_05.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE06 = APP_RES_PATH "/VOICE_ASSISTANT_06.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE07 = APP_RES_PATH "/VOICE_ASSISTANT_07.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE08 = APP_RES_PATH "/VOICE_ASSISTANT_08.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE09 = APP_RES_PATH "/VOICE_ASSISTANT_09.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE10 = APP_RES_PATH "/VOICE_ASSISTANT_10.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE11 = APP_RES_PATH "/VOICE_ASSISTANT_11.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE12 = APP_RES_PATH "/VOICE_ASSISTANT_12.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE13 = APP_RES_PATH "/VOICE_ASSISTANT_13.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE14 = APP_RES_PATH "/VOICE_ASSISTANT_14.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE15 = APP_RES_PATH "/VOICE_ASSISTANT_15.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE16 = APP_RES_PATH "/VOICE_ASSISTANT_16.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE17 = APP_RES_PATH "/VOICE_ASSISTANT_17.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE18 = APP_RES_PATH "/VOICE_ASSISTANT_18.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE19 = APP_RES_PATH "/VOICE_ASSISTANT_19.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE20 = APP_RES_PATH "/VOICE_ASSISTANT_20.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE21 = APP_RES_PATH "/VOICE_ASSISTANT_21.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE22 = APP_RES_PATH "/VOICE_ASSISTANT_22.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE23 = APP_RES_PATH "/VOICE_ASSISTANT_23.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE24 = APP_RES_PATH "/VOICE_ASSISTANT_24.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE25 = APP_RES_PATH "/VOICE_ASSISTANT_25.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE26 = APP_RES_PATH "/VOICE_ASSISTANT_26.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE27 = APP_RES_PATH "/VOICE_ASSISTANT_27.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE28 = APP_RES_PATH "/VOICE_ASSISTANT_28.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE29 = APP_RES_PATH "/VOICE_ASSISTANT_29.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE30 = APP_RES_PATH "/VOICE_ASSISTANT_30.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE31 = APP_RES_PATH "/VOICE_ASSISTANT_31.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE32 = APP_RES_PATH "/VOICE_ASSISTANT_32.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE33 = APP_RES_PATH "/VOICE_ASSISTANT_33.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE34 = APP_RES_PATH "/VOICE_ASSISTANT_34.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE35 = APP_RES_PATH "/VOICE_ASSISTANT_35.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE36 = APP_RES_PATH "/VOICE_ASSISTANT_36.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE37 = APP_RES_PATH "/VOICE_ASSISTANT_37.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE38 = APP_RES_PATH "/VOICE_ASSISTANT_38.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE39 = APP_RES_PATH "/VOICE_ASSISTANT_39.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE40 = APP_RES_PATH "/VOICE_ASSISTANT_40.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE41 = APP_RES_PATH "/VOICE_ASSISTANT_41.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE42 = APP_RES_PATH "/VOICE_ASSISTANT_42.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE43 = APP_RES_PATH "/VOICE_ASSISTANT_43.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE44 = APP_RES_PATH "/VOICE_ASSISTANT_44.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE45 = APP_RES_PATH "/VOICE_ASSISTANT_45.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE46 = APP_RES_PATH "/VOICE_ASSISTANT_46.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE47 = APP_RES_PATH "/VOICE_ASSISTANT_47.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE48 = APP_RES_PATH "/VOICE_ASSISTANT_48.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE49 = APP_RES_PATH "/VOICE_ASSISTANT_49.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE50 = APP_RES_PATH "/VOICE_ASSISTANT_50.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE51 = APP_RES_PATH "/VOICE_ASSISTANT_51.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE52 = APP_RES_PATH "/VOICE_ASSISTANT_52.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE53 = APP_RES_PATH "/VOICE_ASSISTANT_53.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE54 = APP_RES_PATH "/VOICE_ASSISTANT_54.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE55 = APP_RES_PATH "/VOICE_ASSISTANT_55.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE56 = APP_RES_PATH "/VOICE_ASSISTANT_56.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE57 = APP_RES_PATH "/VOICE_ASSISTANT_57.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE58 = APP_RES_PATH "/VOICE_ASSISTANT_58.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE59 = APP_RES_PATH "/VOICE_ASSISTANT_59.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE60 = APP_RES_PATH "/VOICE_ASSISTANT_60.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE61 = APP_RES_PATH "/VOICE_ASSISTANT_61.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE62 = APP_RES_PATH "/VOICE_ASSISTANT_62.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE63 = APP_RES_PATH "/VOICE_ASSISTANT_63.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE64 = APP_RES_PATH "/VOICE_ASSISTANT_64.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE65 = APP_RES_PATH "/VOICE_ASSISTANT_65.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE66 = APP_RES_PATH "/VOICE_ASSISTANT_66.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE67 = APP_RES_PATH "/VOICE_ASSISTANT_67.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE68 = APP_RES_PATH "/VOICE_ASSISTANT_68.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE69 = APP_RES_PATH "/VOICE_ASSISTANT_69.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE70 = APP_RES_PATH "/VOICE_ASSISTANT_70.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE71 = APP_RES_PATH "/VOICE_ASSISTANT_71.bin"; + static constexpr const char *PNG_APPLIST_VOCASSIST_IMAGE = APP_RES_PATH "/APPLIST_VOCASSIST_IMAGE.bin"; - static constexpr const char *PNG_A004_070_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_01.bin"; - static constexpr const char *PNG_A004_071_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_02.bin"; - static constexpr const char *PNG_A004_072_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_03.bin"; - static constexpr const char *PNG_A004_073_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_04.bin"; - static constexpr const char *PNG_A004_074_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_05.bin"; - static constexpr const char *PNG_A004_075_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_06.bin"; - static constexpr const char *PNG_A004_076_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_07.bin"; - static constexpr const char *PNG_A004_077_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_08.bin"; - static constexpr const char *PNG_A004_078_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_09.bin"; - static constexpr const char *PNG_A004_079_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_10.bin"; - static constexpr const char *PNG_A004_080_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_11.bin"; - static constexpr const char *PNG_A004_081_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_12.bin"; - static constexpr const char *PNG_A004_082_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_13.bin"; - static constexpr const char *PNG_A004_083_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_14.bin"; - static constexpr const char *PNG_A004_084_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_15.bin"; - static constexpr const char *PNG_A004_085_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_16.bin"; - static constexpr const char *PNG_A004_086_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_17.bin"; - static constexpr const char *PNG_A004_087_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_18.bin"; - static constexpr const char *PNG_A004_088_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_19.bin"; + static constexpr const char *PNG_STEP_SHOE_IMAGE_PATH = APP_RES_PATH "/SHOE_IMAGE.bin"; - static constexpr const char *PNG_A019_080_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_01.bin"; - static constexpr const char *PNG_A019_081_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_02.bin"; - static constexpr const char *PNG_A019_082_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_03.bin"; - static constexpr const char *PNG_A019_083_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_04.bin"; - static constexpr const char *PNG_A019_084_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_05.bin"; - static constexpr const char *PNG_A019_085_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_06.bin"; - static constexpr const char *PNG_A019_086_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_07.bin"; - static constexpr const char *PNG_A019_087_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_08.bin"; + static constexpr const char *PNG_A004_070_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_01.bin"; + static constexpr const char *PNG_A004_071_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_02.bin"; + static constexpr const char *PNG_A004_072_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_03.bin"; + static constexpr const char *PNG_A004_073_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_04.bin"; + static constexpr const char *PNG_A004_074_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_05.bin"; + static constexpr const char *PNG_A004_075_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_06.bin"; + static constexpr const char *PNG_A004_076_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_07.bin"; + static constexpr const char *PNG_A004_077_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_08.bin"; + static constexpr const char *PNG_A004_078_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_09.bin"; + static constexpr const char *PNG_A004_079_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_10.bin"; + static constexpr const char *PNG_A004_080_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_11.bin"; + static constexpr const char *PNG_A004_081_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_12.bin"; + static constexpr const char *PNG_A004_082_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_13.bin"; + static constexpr const char *PNG_A004_083_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_14.bin"; + static constexpr const char *PNG_A004_084_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_15.bin"; + static constexpr const char *PNG_A004_085_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_16.bin"; + static constexpr const char *PNG_A004_086_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_17.bin"; + static constexpr const char *PNG_A004_087_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_18.bin"; + static constexpr const char *PNG_A004_088_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_19.bin"; - static constexpr const char *PNG_A019_088_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_09.bin"; - static constexpr const char *PNG_A019_089_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_10.bin"; - static constexpr const char *PNG_A019_090_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_11.bin"; - static constexpr const char *PNG_A019_091_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_12.bin"; - static constexpr const char *PNG_A019_092_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_13.bin"; - static constexpr const char *PNG_A019_093_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_14.bin"; - static constexpr const char *PNG_A019_094_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_15.bin"; - static constexpr const char *PNG_A019_095_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_16.bin"; - static constexpr const char *PNG_BLUETOOTHEAR = APP_RES_PATH"/BLUETOOTHEAR.bin"; + static constexpr const char *PNG_A019_080_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_01.bin"; + static constexpr const char *PNG_A019_081_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_02.bin"; + static constexpr const char *PNG_A019_082_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_03.bin"; + static constexpr const char *PNG_A019_083_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_04.bin"; + static constexpr const char *PNG_A019_084_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_05.bin"; + static constexpr const char *PNG_A019_085_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_06.bin"; + static constexpr const char *PNG_A019_086_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_07.bin"; + static constexpr const char *PNG_A019_087_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_08.bin"; + + static constexpr const char *PNG_A019_088_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_09.bin"; + static constexpr const char *PNG_A019_089_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_10.bin"; + static constexpr const char *PNG_A019_090_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_11.bin"; + static constexpr const char *PNG_A019_091_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_12.bin"; + static constexpr const char *PNG_A019_092_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_13.bin"; + static constexpr const char *PNG_A019_093_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_14.bin"; + static constexpr const char *PNG_A019_094_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_15.bin"; + static constexpr const char *PNG_A019_095_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_16.bin"; + static constexpr const char *PNG_BLUETOOTHEAR = APP_RES_PATH "/BLUETOOTHEAR.bin"; // AppList + static constexpr const char *PNG_APPLIST_ALARM_IMAGE = APP_RES_PATH "/APPLIST_ALARM.bin"; // 闹钟 + static constexpr const char *PNG_APPLIST_SPO2_IMAGE = APP_RES_PATH "/APPLIST_SPO2.bin"; // 血氧 + static constexpr const char *PNG_APPLIST_SETTING_IMAGE = APP_RES_PATH "/APPLIST_SETTING.bin"; // 设置 + static constexpr const char *PNG_APPLIST_TEMP_IMAGE = APP_RES_PATH "/TEMP_IMAGE.bin"; // 体温 - static constexpr const char *PNG_APPLIST_ALARM_IMAGE = APP_RES_PATH"/APPLIST_ALARM.bin"; // 闹钟 - static constexpr const char *PNG_APPLIST_SPO2_IMAGE = APP_RES_PATH"/APPLIST_SPO2.bin"; // 血氧 - static constexpr const char *PNG_APPLIST_SETTING_IMAGE = APP_RES_PATH"/APPLIST_SETTING.bin"; // 设置 - static constexpr const char *PNG_APPLIST_TEMP_IMAGE = APP_RES_PATH"/TEMP_IMAGE.bin"; // 体温 + static constexpr const char *PNG_APPLIST_SPORT_IMAGE = APP_RES_PATH "/sport.bin"; // 活动 + static constexpr const char *PNG_APPLIST_HEARTRATE_IMAGE = APP_RES_PATH "/heart rate.bin"; // 心率 + static constexpr const char *PNG_APPLIST_TRAINING_IMAGE = APP_RES_PATH "/training.bin"; // 训练 + static constexpr const char *PNG_APPLIST_TRAINING_RECORD_IMAGE = APP_RES_PATH "/Training record.bin"; // 训练记录 + static constexpr const char *PNG_APPLIST_BLOODPRESSURE_IMAGE = APP_RES_PATH "/bloodpressure.bin"; // 睡眠 + static constexpr const char *PNG_APPLIST_GETPIC_IMAGE = APP_RES_PATH "/getpic.bin"; // 拍照 + static constexpr const char *PNG_APPLIST_BLOOD_IMAGE = APP_RES_PATH "/blood.bin"; // 血氧 + static constexpr const char *PNG_APPLIST_MUSIC_IMAGE = APP_RES_PATH "/music.bin"; // 音乐 + static constexpr const char *PNG_APPLIST_WEATHER_IMAGE = APP_RES_PATH "/weather.bin"; // 天气 + static constexpr const char *PNG_APPLIST_RECORD_IMAGE = APP_RES_PATH "/record.bin"; // 录音 + static constexpr const char *PNG_APPLIST_PHONE_IMAGE = APP_RES_PATH "/phone.bin"; // 电话 + static constexpr const char *PNG_APPLIST_CHRONOMETER_IMAGE = APP_RES_PATH "/chronometer.bin"; // 秒表 + static constexpr const char *PNG_APPLIST_COUNTDOWN_IMAGE = APP_RES_PATH "/countdown.bin"; // 计时器 + static constexpr const char *PNG_APPLIST_BLUETOOTH_IMAGE = APP_RES_PATH "/Bluetooth.bin"; // 蓝牙 // 室内步行 - static constexpr const char *PNG_APPLIST_WALK_IMAGE = APP_RES_PATH"/APPLIST_WALK.bin"; // Applist图标 - static constexpr const char *PNG_WALK_BACK_GROUND = APP_RES_PATH"/WALK_BACK_GROUND.bin"; - static constexpr const char *PNG_WALK_IMAGE = APP_RES_PATH"/INDOORWALK.bin"; - static constexpr const char *PNG_AEROBIC_IMAGE = APP_RES_PATH"/AEROBIC.bin"; - static constexpr const char *PNG_ANAEROBIC_IMAGE = APP_RES_PATH"/ANAEROBIC.bin"; - static constexpr const char *PNG_OPTIONS_BOX1_IMAGE = APP_RES_PATH"/OPTIONS_BOX1.bin"; - static constexpr const char *PNG_OPTIONS_BOX2_IMAGE = APP_RES_PATH"/OPTIONS_BOX2.bin"; - static constexpr const char *PNG_OPTIONS_BOX3_IMAGE = APP_RES_PATH"/OPTIONS_BOX3.bin"; - static constexpr const char *PNG_OPTIONS_BOX4_IMAGE = APP_RES_PATH"/OPTIONS_BOX4.bin"; - static constexpr const char *PNG_WALK_TIME_IMAGE = APP_RES_PATH"/TIME_IMAGE.bin"; - static constexpr const char *PNG_WALK_DISTANCES_IMAGE = APP_RES_PATH"/DISTANCES_IMAGE.bin"; - static constexpr const char *PNG_WALK_HEART_IMAGE = APP_RES_PATH"/HEART_IMAGE.bin"; - static constexpr const char *PNG_WALK_SPEED_IMAGE = APP_RES_PATH"/SPEED_IMAGE.bin"; - static constexpr const char *PNG_WALK_STEPS_IMAGE = APP_RES_PATH"/STEPS_IMAGE.bin"; + static constexpr const char *PNG_APPLIST_WALK_IMAGE = APP_RES_PATH "/APPLIST_WALK.bin"; // Applist图标 + static constexpr const char *PNG_WALK_BACK_GROUND = APP_RES_PATH "/WALK_BACK_GROUND.bin"; + static constexpr const char *PNG_WALK_IMAGE = APP_RES_PATH "/INDOORWALK.bin"; + static constexpr const char *PNG_AEROBIC_IMAGE = APP_RES_PATH "/AEROBIC.bin"; + static constexpr const char *PNG_ANAEROBIC_IMAGE = APP_RES_PATH "/ANAEROBIC.bin"; + static constexpr const char *PNG_OPTIONS_BOX1_IMAGE = APP_RES_PATH "/OPTIONS_BOX1.bin"; + static constexpr const char *PNG_OPTIONS_BOX2_IMAGE = APP_RES_PATH "/OPTIONS_BOX2.bin"; + static constexpr const char *PNG_OPTIONS_BOX3_IMAGE = APP_RES_PATH "/OPTIONS_BOX3.bin"; + static constexpr const char *PNG_OPTIONS_BOX4_IMAGE = APP_RES_PATH "/OPTIONS_BOX4.bin"; + static constexpr const char *PNG_WALK_TIME_IMAGE = APP_RES_PATH "/TIME_IMAGE.bin"; + static constexpr const char *PNG_WALK_DISTANCES_IMAGE = APP_RES_PATH "/DISTANCES_IMAGE.bin"; + static constexpr const char *PNG_WALK_HEART_IMAGE = APP_RES_PATH "/HEART_IMAGE.bin"; + static constexpr const char *PNG_WALK_SPEED_IMAGE = APP_RES_PATH "/SPEED_IMAGE.bin"; + static constexpr const char *PNG_WALK_STEPS_IMAGE = APP_RES_PATH "/STEPS_IMAGE.bin"; - static constexpr const char *PNG_APPLIST_UI_SAMPLE_IMAGE = APP_RES_PATH"/APPLIST_UI_SAMPLE.bin"; // Applist图标 + static constexpr const char *PNG_APPLIST_UI_SAMPLE_IMAGE = APP_RES_PATH "/APPLIST_UI_SAMPLE.bin"; // Applist图标 } #endif // UI_CONFIG_H diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp index e6075716e..1faa323d1 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp @@ -62,7 +62,98 @@ #include "graphic_hardware_config.h" #include "graphic_service.h" #include "common/graphic_startup.h" - +#include "saveele/include/SaveEleView.h" +#include "saveele/include/SaveElePresenter.h" +#include "saveele/include/SaveBatView.h" +#include "saveele/include/SaveBatPresenter.h" +#include "sleep/include/SleepView.h" +#include "sleep/include/SleepPresenter.h" +#include "sleep/include/SleepTimeView.h" +#include "sleep/include/SleepTimePresenter.h" +#include "sleep/include/SleepActView.h" +#include "sleep/include/SleepActPresenter.h" +#include "getpic/include/GetPicView.h" +#include "getpic/include/GetPicPresenter.h" +#include "getpic/include/TakePicView.h" +#include "getpic/include/TakePicPresenter.h" +#include "phone/include/PhoneView.h" +#include "phone/include/PhonePresenter.h" +#include "phone/include/PhoneCallView.h" +#include "phone/include/PhoneCallPresenter.h" +#include "phone/include/PhoneDirView.h" +#include "phone/include/PhoneDirPresenter.h" +#include "phone/include/PhoneCallingView.h" +#include "phone/include/PhoneCallingPresenter.h" +#include "phone/include/PhoneCallupView.h" +#include "phone/include/PhoneCallupPresenter.h" +#include "phone/include/PhoneRingView.h" +#include "phone/include/PhoneRingPresenter.h" +#include "blood/include/BloodView.h" +#include "blood/include/BloodPresenter.h" +#include "blood/include/BloodCheckPresenter.h" +#include "blood/include/BloodCheckView.h" +#include "blood/include/BloodShowPresenter.h" +#include "blood/include/BloodShowView.h" +#include "dial/include/DialPresenter.h" +#include "dial/include/DialView.h" +#include "displaybrightness/include/DisplayBrightnessPresenter.h" +#include "displaybrightness/include/DisplayBrightnessView.h" +#include "bluetoothofsetting/include/BlueToothOfSettingPresenter.h" +#include "bluetoothofsetting/include/BlueToothOfSettingView.h" +#include "brightnesscontrol/include/BrightnessControlPresenter.h" +#include "brightnesscontrol/include/BrightnessControlView.h" +#include "screenduration/include/ScreenDurationPresenter.h" +#include "screenduration/include/ScreenDurationView.h" +#include "soundandvibration/include/SoundAndVibrationPresenter.h" +#include "soundandvibration/include/SoundAndVibrationView.h" +#include "systemvolume/include/SystemVolumePresenter.h" +#include "systemvolume/include/SystemVolumeView.h" +#include "quickaccess/include/QuickAccessPresenter.h" +#include "quickaccess/include/QuickAccessView.h" +#include "system/include/SystemPresenter.h" +#include "system/include/SystemView.h" +#include "systemaboutwatch/include/SystemAboutPresenter.h" +#include "systemaboutwatch/include/SystemAboutView.h" +#include "systemsupervise/include/SystemSupervisePresenter.h" +#include "systemsupervise/include/SystemSuperviseView.h" +#include "systemlanguage/include/SystemLanguagePresenter.h" +#include "systemlanguage/include/SystemLanguageView.h" +#include "systemreboot/include/SystemRebootPresenter.h" +#include "systemreboot/include/SystemRebootView.h" +#include "steamshoutdown/include/SystemShoutDownPresenter.h" +#include "steamshoutdown/include/SystemShoutDownView.h" +#include "steamfactoryreset/include/SystemFactoryResetPresenter.h" +#include "steamfactoryreset/include/SystemFactoryResetView.h" +#include "record/include/RecordPresenter.h" +#include "record/include/RecordView.h" +#include "record/include/RecordListPresenter.h" +#include "record/include/RecordListView.h" +#include "record/include/RecordPlayPresenter.h" +#include "record/include/RecordPlayView.h" +#include "record/include/RecordDeletePresenter.h" +#include "record/include/RecordDeleteView.h" +#include "record/include/RecordGoingPresenter.h" +#include "record/include/RecordGoingView.h" +#include "PlaceMakerCompassPresenter.h" +#include "PlaceMakerCompassView.h" +#include "MakerPointCompassPresenter.h" +#include "MakerPointCompassView.h" +#include "StartPathRecordCompassPresenter.h" +#include "StartPathRecordCompassView.h" +#include "EndPathRecordCompassPresenter.h" +#include "EndPathRecordCompassView.h" +#include "PathBackTrackingCompassPresenter.h" +#include "PathBackTrackingCompassView.h" +#include "ResetPlaceMakerCompassPresenter.h" +#include "ResetPlaceMakerCompassView.h" +#include "PathRetracingCompassPresenter.h" +#include "PathRetracingCompassView.h" +#include "EndBackTrackingEarlyCompassPresenter.h" +#include "EndBackTrackingEarlyCompassView.h" +#include "EndBackTrackingCompassPresenter.h" +#include "EndBackTrackingCompassView.h" +#include "GPSLossCompassPresenter.h" +#include "GPSLossCompassView.h" namespace OHOS { struct AppViewMapper { @@ -94,6 +185,53 @@ static const AppViewMapper SLICE_MAPPER[] = { {VIEW_MAIN_TEMP, &NativeLauncher::InitMainTempSlice}, {VIEW_INDOORWALK, &NativeLauncher::InitIndoorWalkSlice}, {VIEW_REBOOT, &NativeLauncher::InitRebootSlice}, + {VIEW_SAVEELE, &NativeLauncher::InitSaveEleSlice}, + {VIEW_SAVEBAT, &NativeLauncher::InitSaveBatSlice}, + {VIEW_BLOODPRESSURE, &NativeLauncher::InitSleepSlice}, + {VIEW_SLEEPTIME, &NativeLauncher::InitSleepTimeSlice}, + {VIEW_SLEEPACT, &NativeLauncher::InitSleepActSlice}, + {VIEW_GETPIC, &NativeLauncher::InitGetPicSlice}, //拍照 + {VIEW_TAKEPIC, &NativeLauncher::InitTakePicSlice}, + {VIEW_PHONE, &NativeLauncher::InitPhoneSlice}, //电话 + {VIEW_PHONECALL, &NativeLauncher::InitPhoneCallSlice}, + {VIEW_PHONEDIR, &NativeLauncher::InitPhoneDirSlice}, + {VIEW_PHONECALLING, &NativeLauncher::InitPhoneCallingSlice}, + {VIEW_PHONECALLUP, &NativeLauncher::InitPhoneCallupSlice}, + {VIEW_PHONERING, &NativeLauncher::InitPhoneRingSlice}, + {VIEW_BLOOD, &NativeLauncher::InitBloodSlice}, //血氧 + {VIEW_BLOODSHOW, &NativeLauncher::InitBloodShowSlice}, + {VIEW_BLOODCHECK, &NativeLauncher::InitBloodCheckSlice}, + {VIEW_DIAL, &NativeLauncher::InitDialSlice}, //表盘 + {VIEW_DISPLAY_BRIGHTNESS,&NativeLauncher::InitUIDisplayBrightnessSlice}, //显示与亮度的实例化地址 + {VIEW_CONNECT_BLUETOOTH,&NativeLauncher::InitBlueToothSettingSlice}, //蓝牙设置的实例化地址 + {VIEW_BRIGHTNESS_CONTROL,&NativeLauncher::InitBrightnessControlSlice}, //调节亮度的实例化地址 + {VIEW_SCREEN_DURATION,&NativeLauncher::InitScreenDurationSlice}, //亮屏时长实例化地址 + {VIEW_SOUND_VIBRATION,&NativeLauncher::InitSoundAndVibrationSlice}, //声音与震动实例化地址 + {VIEW_SYSTEM_VOLUME,&NativeLauncher::InitSystemVolumeSlice}, //系统音量 + {VIEW_QUICK_ACCESS,&NativeLauncher::InitQuickAccessSlice}, //快速访问实例化地址 + {VIEW_SYSTEM,&NativeLauncher::InitSystemSlice}, //系统实例化地址 + {VIEW_SYSTEM_ABOUT_WATCH,&NativeLauncher::InitSystemAboutWatchSlice}, //系统:关于手表实例化地址 + {VIEW_SYSTEM_SUPERVISE,&NativeLauncher::InitSystemSuperviseSlice}, //系统:监管实例化地址 + {VIEW_SYSTEM_SYSTEM_LANGUAGE,&NativeLauncher::InitSystemLanguageSlice}, //系统:系统语言实例化地址 + {VIEW_SYSTEM_REBOOT,&NativeLauncher::InitSystemRebootSlice}, //系统:重启实例化地址 + {VIEW_SYSTEM_SHOUTDOWN,&NativeLauncher::InitSystemShoutDownSlice}, //系统:关机实例化地址 + {VIEW_SYSTEM_FACTORY_RESET,&NativeLauncher::InitSystemFactoryResetSlice}, //系统:恢复出厂设置实例化地址 + {VIEW_RECORD,&NativeLauncher::InitRecordingSlice}, //录音实例化地址 + {VIEW_RECORD_LIST,&NativeLauncher::InitRecordingListSlice}, + {VIEW_RECORD_PLAY,&NativeLauncher::InitRecordingPlaySlice}, + {VIEW_RECORD_DELETE,&NativeLauncher::InitRecordingDeleteSlice}, + {VIEW_RECORD_DELETE,&NativeLauncher::InitRecordingDeleteSlice}, + {VIEW_RECORD_GOING,&NativeLauncher::InitRecordingGoingSlice}, + {VIEW_COMPASS_PLACE_MAKER,&NativeLauncher::InitCompassPlaceMakerSlice}, //指南针放置标记点实例化地址 + {VIEW_COMPASS_MAKER_POINT,&NativeLauncher::InitCompassMakerPointSlice}, //指南针标记点介绍实例化地址 + {VIEW_COMPASS_START_PATH_RECORD,&NativeLauncher::InitCompassStartPathRecordSlice}, //指南针开始路径记录实例化地址 + {VIEW_COMPASS_END_PATH_RECORD,&NativeLauncher::InitCompassEndPathRecordSlice}, //指南针结束路径记录实例化地址 + {VIEW_COMPASS_PATH_BACKTRACKING,&NativeLauncher::InitCompassPathBackTrackingSlice}, //指南针路径回溯实例化地址 + {VIEW_COMPASS_RESET_PLACE_MAKER,&NativeLauncher::InitCompassResetPlaceMakerSlice}, //指南针重置标记点实例化地址 + {VIEW_COMPASS_PATH_RETRACING,&NativeLauncher::InitCompassPathRetracingSlice}, //指南针路径回溯实例化地址 + {VIEW_COMPASS_END_BACK_TRACKING,&NativeLauncher::InitCompassEndBackTrackingSlice}, //指南针结束路径回溯 + {VIEW_COMPASS_END_BACK_TRACKING_EARLY,&NativeLauncher::InitCompassEndBackTrackingEarlySlice},//指南针提前结束路径回溯 + {VIEW_COMPASS_GPS_LOSS,&NativeLauncher::InitCompassGPSLossSlice}, //指南针GPS丢失实例化地址 {VIEW_UISAMPLE, &NativeLauncher::InitUISampleSlice} }; @@ -115,6 +253,35 @@ static const ViewIdToString VIEW_MAPPER[] = { {VIEW_MAIN_TEMP, "mianTempView"}, {VIEW_INDOORWALK, "IndoorWalkView"}, {VIEW_REBOOT, "RebootView"}, + {VIEW_DISPLAY_BRIGHTNESS,"DisplayBrightness"}, //显示与亮度 + {VIEW_CONNECT_BLUETOOTH,"BlueToothSetting"}, //蓝牙 + {VIEW_BRIGHTNESS_CONTROL,"BrightnessControl"}, //亮度调节 + {VIEW_SCREEN_DURATION,"ScreenDuration"}, //亮屏时长 + {VIEW_SOUND_VIBRATION,"SoundAndVibration"}, //声音与震动 + {VIEW_SYSTEM_VOLUME,"SystemVolume"}, //系统音量 + {VIEW_QUICK_ACCESS,"QuickAccess"}, //快速访问 + {VIEW_SYSTEM,"System"}, //系统 + {VIEW_SYSTEM_ABOUT_WATCH,"SystemAboutWatch"}, //系统:关于手表 + {VIEW_SYSTEM_SUPERVISE,"SystemSupervise"}, //系统:监管 + {VIEW_SYSTEM_SYSTEM_LANGUAGE,"SystemLanguage"}, //系统:系统语言 + {VIEW_SYSTEM_REBOOT,"SystemReboot"}, //系统:重新启动 + {VIEW_SYSTEM_SHOUTDOWN,"SystemShoutDown"}, //系统:关机 + {VIEW_SYSTEM_FACTORY_RESET,"SystemFactoryReset"},//系统:恢复出厂设置 + {VIEW_RECORD,"Recording"}, //录音 + {VIEW_RECORD_LIST,"RecordingList"}, + {VIEW_RECORD_PLAY,"RecordingPlay"}, + {VIEW_RECORD_DELETE,"RecordingDelete"}, + {VIEW_RECORD_GOING,"RecordingGoing"}, + {VIEW_COMPASS_PLACE_MAKER,"PlaceMakerCompass"}, //指南针放置标记点 + {VIEW_COMPASS_MAKER_POINT,"MakerPointCompass"}, //指南针标记点介绍 + {VIEW_COMPASS_START_PATH_RECORD,"StartPathRecordCompass"}, //指南针开始路径记录 + {VIEW_COMPASS_END_PATH_RECORD,"StartPathRecordCompass"}, //指南针结束路径记录 + {VIEW_COMPASS_PATH_BACKTRACKING,"PathBackTrackingCompass"}, //指南针路径回溯 + {VIEW_COMPASS_RESET_PLACE_MAKER,"ResetPlaceMakerCompass"}, //指南针重置路径标记点 + {VIEW_COMPASS_PATH_RETRACING,"PathRetracingCompass"}, //指南针路径回溯中 + {VIEW_COMPASS_END_BACK_TRACKING_EARLY,"EndBackTrackingEarlyCompass"},//指南针提前结束路径回溯 + {VIEW_COMPASS_END_BACK_TRACKING,"EndBackTrackingCompass"}, //指南针提前结束路径回溯 + {VIEW_COMPASS_GPS_LOSS,"GPSLossCompass"}, //指南针GPS丢失 {VIEW_UISAMPLE, "UISample"} }; @@ -353,4 +520,465 @@ void NativeLauncher::InitUISampleSlice(void) } NativeAbility::GetInstance().AddSliceProxy(VIEW_UISAMPLE, uisampleView); } +// 省电模式 +void NativeLauncher::InitSaveEleSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitSaveEleSlice"); + SliceProxy *saveeleview = new AbilitySliceProxy; + if (saveeleview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "saveeleview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_SAVEELE, saveeleview); +} + +void NativeLauncher::InitSaveBatSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitSaveBatSlice"); + SliceProxy *savebatview = new AbilitySliceProxy; + if (savebatview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "savebatview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_SAVEBAT, savebatview); +} +// 睡眠记录 +void NativeLauncher::InitSleepSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitSleepSlice"); + SliceProxy *sleepview = new AbilitySliceProxy; + if (sleepview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sleepview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_BLOODPRESSURE, sleepview); +} +void NativeLauncher::InitSleepTimeSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitSleepTimeSlice"); + SliceProxy *sleeptimeview = new AbilitySliceProxy; + if (sleeptimeview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sleeptimeview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_SLEEPTIME, sleeptimeview); +} +void NativeLauncher::InitSleepActSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitSleepActSlice"); + SliceProxy *sleepactview = new AbilitySliceProxy; + if (sleepactview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sleepactview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_SLEEPACT, sleepactview); +} + +void NativeLauncher::InitGetPicSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitGetPicSlice"); + SliceProxy *getpicview = new AbilitySliceProxy; + if (getpicview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "getpicview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_GETPIC, getpicview); +} + +void NativeLauncher::InitTakePicSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitTakePicSlice"); + SliceProxy *takepicview = new AbilitySliceProxy; + if (takepicview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "takepicview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_TAKEPIC, takepicview); +} + +void NativeLauncher::InitPhoneSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitPhoneSlice"); + SliceProxy *phoneview = new AbilitySliceProxy; + if (phoneview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_PHONE, phoneview); +} + +void NativeLauncher::InitPhoneCallSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitPhoneCallSlice"); + SliceProxy *phonecallview = new AbilitySliceProxy; + if (phonecallview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phonecallview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_PHONECALL, phonecallview); +} + +void NativeLauncher::InitPhoneDirSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitPhoneCallSlice"); + SliceProxy *phonedirview = new AbilitySliceProxy; + if (phonedirview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phonedirview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_PHONEDIR, phonedirview); +} + +void NativeLauncher::InitPhoneCallingSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitPhoneCallingSlice"); + SliceProxy *phonecallingview = new AbilitySliceProxy; + if (phonecallingview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phonecallingview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_PHONECALLING, phonecallingview); +} + +void NativeLauncher::InitPhoneCallupSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitPhoneCallupSlice"); + SliceProxy *phonecallupview = new AbilitySliceProxy; + if (phonecallupview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phonecallview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_PHONECALLUP, phonecallupview); +} + +void NativeLauncher::InitPhoneRingSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitPhoneRingSlice"); + SliceProxy *phoneringview = new AbilitySliceProxy; + if (phoneringview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneringview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_PHONERING, phoneringview); +} + +void NativeLauncher::InitBloodSlice(void) //血氧 +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitBloodSlice"); + SliceProxy *bloodview = new AbilitySliceProxy; + if (bloodview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bloodview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_BLOOD, bloodview); +} + +void NativeLauncher::InitBloodShowSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitBloodSlice"); + SliceProxy *bloodshowview = new AbilitySliceProxy; + if (bloodshowview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bloodview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_BLOODSHOW, bloodshowview); +} + +void NativeLauncher::InitBloodCheckSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitBloodSlice"); + SliceProxy *bloodcheckview = new AbilitySliceProxy; + if (bloodcheckview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bloodview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_BLOODCHECK, bloodcheckview); +} + +void NativeLauncher::InitDialSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitBloodSlice"); + SliceProxy *dialview = new AbilitySliceProxy; + if (dialview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dialview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_DIAL, dialview); +} + +//DisplayBrightness的实例化 +void NativeLauncher::InitUIDisplayBrightnessSlice(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitUISampleSlice"); + SliceProxy *uidisplaybrightnessView = new AbilitySliceProxy; + if (uidisplaybrightnessView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uidisplaybrightnessView"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_DISPLAY_BRIGHTNESS, uidisplaybrightnessView); +} + +void NativeLauncher::InitBlueToothSettingSlice(void) +{ + SliceProxy *bluetoothsetting = new AbilitySliceProxy; + if (bluetoothsetting == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_CONNECT_BLUETOOTH, bluetoothsetting); +} + +void NativeLauncher::InitBrightnessControlSlice(void) +{ + SliceProxy *brightnesscontrol = new AbilitySliceProxy; + if (brightnesscontrol == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_BRIGHTNESS_CONTROL, brightnesscontrol); +} + +void NativeLauncher::InitScreenDurationSlice(void) +{ + SliceProxy *ScreenDuration = new AbilitySliceProxy; + if (ScreenDuration == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_SCREEN_DURATION, ScreenDuration); +} + +void NativeLauncher::InitSoundAndVibrationSlice(void) //声音与震动 +{ + SliceProxy *SoundAndVibration = new AbilitySliceProxy; + if (SoundAndVibration == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_SOUND_VIBRATION, SoundAndVibration); +} + +void NativeLauncher::InitQuickAccessSlice(void) //快速访问 +{ + SliceProxy *QuickAccess = new AbilitySliceProxy; + if (QuickAccess == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_QUICK_ACCESS, QuickAccess); +} + +void NativeLauncher::InitSystemSlice(void) //系统 +{ + SliceProxy *system = new AbilitySliceProxy; + if (system == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_SYSTEM, system); +} +void NativeLauncher::InitSystemAboutWatchSlice(void) //系统:关于手表 +{ + SliceProxy *systemaboutwatch = new AbilitySliceProxy; + if (systemaboutwatch == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_SYSTEM_ABOUT_WATCH, systemaboutwatch); +} + +void NativeLauncher::InitSystemSuperviseSlice(void) //系统:监管 +{ + SliceProxy *systemsupervise = new AbilitySliceProxy; + if (systemsupervise == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_SYSTEM_SUPERVISE, systemsupervise); +} + +void NativeLauncher::InitSystemLanguageSlice(void) //系统:系统语言 +{ + SliceProxy *systemlanguage = new AbilitySliceProxy; + if (systemlanguage == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_SYSTEM_SYSTEM_LANGUAGE, systemlanguage); +} +void NativeLauncher::InitSystemRebootSlice(void) //系统:重新启动 +{ + SliceProxy *systemreboot = new AbilitySliceProxy; + if (systemreboot == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_SYSTEM_REBOOT, systemreboot); +} +void NativeLauncher::InitSystemShoutDownSlice(void) //系统:关机 +{ + SliceProxy *systemshoutdown = new AbilitySliceProxy; + if (systemshoutdown == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_SYSTEM_SHOUTDOWN, systemshoutdown); +} +void NativeLauncher::InitSystemFactoryResetSlice(void) //系统:恢复出厂设置 +{ + SliceProxy *systemfactoryreset = new AbilitySliceProxy; + if (systemfactoryreset == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_SYSTEM_FACTORY_RESET, systemfactoryreset); +} + +void NativeLauncher::InitSystemVolumeSlice(void) //系统音量 +{ + SliceProxy *systemvolume = new AbilitySliceProxy; + if (systemvolume == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_SYSTEM_VOLUME, systemvolume); +} + +void NativeLauncher::InitRecordingSlice(void) //录音 +{ + SliceProxy *record = new AbilitySliceProxy; + if (record == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_RECORD, record); +} + +void NativeLauncher::InitRecordingListSlice(void) +{ + SliceProxy *recordlist = new AbilitySliceProxy; + if (recordlist == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_RECORD_LIST, recordlist); +} + +void NativeLauncher::InitRecordingPlaySlice(void) +{ + SliceProxy *recordplay = new AbilitySliceProxy; + if (recordplay == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_RECORD_PLAY, recordplay); +} +void NativeLauncher::InitRecordingDeleteSlice(void) +{ + SliceProxy *recorddelete = new AbilitySliceProxy; + if (recorddelete == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_RECORD_DELETE, recorddelete); +} + +void NativeLauncher::InitRecordingGoingSlice(void) //正在录音 +{ + SliceProxy *recordgoing = new AbilitySliceProxy; + if (recordgoing == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_RECORD_GOING, recordgoing); +} + +void NativeLauncher::InitCompassPlaceMakerSlice(void) //指南针:放置标记点 +{ + + SliceProxy *placemakercompass = new AbilitySliceProxy; + if (placemakercompass == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_COMPASS_PLACE_MAKER, placemakercompass); +} + +void NativeLauncher::InitCompassMakerPointSlice(void) //指南针:标记点介绍 +{ + SliceProxy *makerpointcompass = new AbilitySliceProxy; + if (makerpointcompass == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_COMPASS_MAKER_POINT, makerpointcompass); +} + +void NativeLauncher::InitCompassStartPathRecordSlice(void) //指南针:开始路径记录 +{ + SliceProxy *startpathrecordcompass = new AbilitySliceProxy; + if (startpathrecordcompass == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_COMPASS_START_PATH_RECORD, startpathrecordcompass); +} + +void NativeLauncher::InitCompassEndPathRecordSlice(void) //指南针:结束路径记录 +{ + SliceProxy *endtpathrecordcompass = new AbilitySliceProxy; + if (endtpathrecordcompass == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_COMPASS_END_PATH_RECORD, endtpathrecordcompass); +} + +void NativeLauncher::InitCompassPathBackTrackingSlice(void) //指南针:路径回溯 +{ + SliceProxy *pathbacktrackingcompass = new AbilitySliceProxy; + if (pathbacktrackingcompass == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_COMPASS_PATH_BACKTRACKING, pathbacktrackingcompass); +} + +void NativeLauncher::InitCompassResetPlaceMakerSlice(void) //指南针:重置标记点 +{ + SliceProxy *resetplacemakercompass = new AbilitySliceProxy; + if (resetplacemakercompass == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_COMPASS_RESET_PLACE_MAKER, resetplacemakercompass); +} + +void NativeLauncher::InitCompassPathRetracingSlice(void) //指南针:路径回溯中 +{ + SliceProxy *pathretracingcompass = new AbilitySliceProxy; + if (pathretracingcompass == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_COMPASS_PATH_RETRACING, pathretracingcompass); +} +void NativeLauncher::InitCompassEndBackTrackingEarlySlice() //指南针:提前结束路径回溯 +{ + SliceProxy *endbacktrackingearlycompass = new AbilitySliceProxy; + if (endbacktrackingearlycompass == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_COMPASS_END_BACK_TRACKING_EARLY, endbacktrackingearlycompass); +} + +void NativeLauncher::InitCompassEndBackTrackingSlice(void) //指南针:结束路径回溯 +{ + SliceProxy *endbacktrackingecompass = new AbilitySliceProxy; + if (endbacktrackingecompass == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_COMPASS_END_BACK_TRACKING, endbacktrackingecompass); +} + +void NativeLauncher::InitCompassGPSLossSlice(void) //指南针:GPS丢失 +{ + SliceProxy *GPSlosscompass = new AbilitySliceProxy; + if (GPSlosscompass == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_COMPASS_GPS_LOSS, GPSlosscompass); +} } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/InitComponent/include/InitComponent.h b/code/sdk/application/wearable/nativeapp/nativeui/InitComponent/include/InitComponent.h new file mode 100644 index 000000000..dfd7c5fb5 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/InitComponent/include/InitComponent.h @@ -0,0 +1,26 @@ +#ifndef INIT_COMPONENT_H +#define INIT_COMPONENT_H + +#include "components/ui_label.h" +#include "components/ui_button.h" +#include "components/ui_image_view.h" +#include +namespace OHOS +{ + class InitComponent + { + public: + static InitComponent &GetInstance(void) + { + static InitComponent instance; + return instance; + } + + UILabel *InitLabel(int left, int top, int width, int height, const char * text, const char * viewId, int fontSize); + UIButton *InitButton(int left, int top, int width, int height, const char *viewId,const char *defimagesrc,const char *toggleimagesrc); + UIImageView *InitImageView(int left, int top, int width, int height, const char *viewId,const char *imagesrc); + }; + +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/InitComponent/src/InitComponent.cpp b/code/sdk/application/wearable/nativeapp/nativeui/InitComponent/src/InitComponent.cpp new file mode 100644 index 000000000..265229db1 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/InitComponent/src/InitComponent.cpp @@ -0,0 +1,61 @@ +#include "InitComponent.h" + +namespace OHOS +{ + + /// @brief 标签初始化函数 + /// @param left 坐标x + /// @param top 坐标y + /// @param width 标签宽 + /// @param height 标签高 + /// @param text 标签内容 + /// @param viewId 标签视图ID + /// @param fontSize 内容字体大小 + /// @return + UILabel *InitComponent::InitLabel(int left, int top, int width, int height, const char *text, const char *viewId, int fontSize) + { + UILabel *label = new UILabel(); + label->SetPosition(left, top); + label->Resize(width, height); + label->SetViewId(viewId); + label->SetStyle(STYLE_TEXT_FONT, fontSize); + label->SetStyle(STYLE_LINE_HEIGHT, height); + + label->SetText(text); + label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(6); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, fontSize); + + return label; + } + // 按钮初始化 + UIButton *InitComponent::InitButton(int left, int top, int width, int height, const char *viewId, const char *defimagesrc, const char *toggleimagesrc) + { + UIButton *button = new UIButton(); + button->SetPosition(left, top); + button->Resize(width, height); + button->SetViewId(viewId); + button->SetStyle(STYLE_BORDER_RADIUS, 50); + button->SetStyle(STYLE_BORDER_COLOR, 0x191919); + button->SetImageSrc(defimagesrc, toggleimagesrc); + button->SetStyleForState(STYLE_BORDER_COLOR, 0x191919, UIButton::PRESSED); + button->SetStyleForState(STYLE_BORDER_RADIUS, 50, UIButton::PRESSED); + + return button; + } + // 图片view初始化 + UIImageView *InitComponent::InitImageView(int left, int top, int width, int height, const char *viewId, const char *imagesrc) + { + UIImageView *imageView = new UIImageView(); + imageView->SetPosition(left, top); + imageView->Resize(width, height); + imageView->SetViewId(viewId); + imageView->SetStyle(STYLE_BACKGROUND_COLOR, 0xff991199); + imageView->SetStyle(STYLE_BACKGROUND_OPA, 0x11); + imageView->SetSrc(imagesrc); + + return imageView; + } + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistModel.cpp index 45b47ee81..616ca1926 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistModel.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistModel.cpp @@ -28,6 +28,20 @@ namespace OHOS { {VIEW_MAIN_TEMP, PNG_APPLIST_TEMP_IMAGE, PNG_APPLIST_TEMP_IMAGE, "体温", nullptr}, {VIEW_INDOORWALK, PNG_APPLIST_WALK_IMAGE, PNG_APPLIST_WALK_IMAGE, "室内步行", nullptr}, {VIEW_UISAMPLE, PNG_APPLIST_UI_SAMPLE_IMAGE, PNG_APPLIST_UI_SAMPLE_IMAGE, "示例", nullptr}, + {VIEW_SPORT, PNG_APPLIST_SPORT_IMAGE, PNG_APPLIST_SPORT_IMAGE, "活动", nullptr}, + {VIEW_GETPIC,PNG_APPLIST_GETPIC_IMAGE,PNG_APPLIST_GETPIC_IMAGE,"拍照",nullptr}, + {VIEW_BLOOD, PNG_APPLIST_BLOOD_IMAGE, PNG_APPLIST_BLOOD_IMAGE, "血氧监测", nullptr}, + {VIEW_SPORT, PNG_APPLIST_HEARTRATE_IMAGE, PNG_APPLIST_HEARTRATE_IMAGE, "心率", nullptr}, + {VIEW_TRAINING, PNG_APPLIST_TRAINING_IMAGE, PNG_APPLIST_TRAINING_IMAGE, "训练", nullptr}, + {VIEW_TRAINING_RECORD, PNG_APPLIST_TRAINING_RECORD_IMAGE, PNG_APPLIST_TRAINING_RECORD_IMAGE, "训练记录", nullptr}, + {VIEW_BLOODPRESSURE, PNG_APPLIST_BLOODPRESSURE_IMAGE, PNG_APPLIST_BLOODPRESSURE_IMAGE, "睡眠", nullptr}, + {VIEW_MUSIC, PNG_APPLIST_MUSIC_IMAGE, PNG_APPLIST_MUSIC_IMAGE, "音乐", nullptr}, + {VIEW_WEATHER, PNG_APPLIST_WEATHER_IMAGE, PNG_APPLIST_WEATHER_IMAGE, "天气", nullptr}, + {VIEW_RECORD, PNG_APPLIST_RECORD_IMAGE, PNG_APPLIST_RECORD_IMAGE, "录音", nullptr}, + {VIEW_PHONE, PNG_APPLIST_PHONE_IMAGE, PNG_APPLIST_PHONE_IMAGE, "电话", nullptr}, + {VIEW_CHRONOMETER, PNG_APPLIST_CHRONOMETER_IMAGE, PNG_APPLIST_CHRONOMETER_IMAGE, "秒表", nullptr}, + {VIEW_COUNTDOWN, PNG_APPLIST_COUNTDOWN_IMAGE, PNG_APPLIST_COUNTDOWN_IMAGE, "计时器", nullptr}, + {VIEW_BLUETOOTH, PNG_APPLIST_BLUETOOTH_IMAGE, PNG_APPLIST_BLUETOOTH_IMAGE, "蓝牙", nullptr}, }; ApplistModel &ApplistModel::GetInstance(void) diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodCheckPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodCheckPresenter.h new file mode 100644 index 000000000..c47212af4 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodCheckPresenter.h @@ -0,0 +1,33 @@ +#ifndef _BloodCheck_PRESENTER_H +#define _BloodCheck_PRESENTER_H + +#include "Presenter.h" +#include "BloodCheckView.h" + +namespace OHOS +{ + class BloodCheckView; + + class BloodCheckPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + BloodCheckPresenter(); + virtual ~BloodCheckPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static BloodCheckPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodCheckView.h b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodCheckView.h new file mode 100644 index 000000000..92b859756 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodCheckView.h @@ -0,0 +1,47 @@ +#ifndef _BloodCheck_VIEW_H +#define _BloodCheck_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_image_animator.h" +#include "components/ui_label_button_ext.h" + +#include "BloodCheckPresenter.h" +namespace OHOS +{ + + class BloodCheckPresenter; + class BloodCheckView : public View + { + + public: + BloodCheckView(); + virtual ~BloodCheckView(); + static BloodCheckView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + BloodCheckView(BloodCheckView &&) = delete; + BloodCheckView &operator=(BloodCheckView &&) = delete; + + UIViewGroup *container_ = nullptr; + UILabel *label1_ = nullptr; + UIImageView *image1_ = nullptr; + UILabelButtonExt *labelButton1_ = nullptr; + }; +} // namespace OHOS +#endif // BloodCheck_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodPresenter.h new file mode 100644 index 000000000..88b028215 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodPresenter.h @@ -0,0 +1,33 @@ +#ifndef _Blood_PRESENTER_H +#define _Blood_PRESENTER_H + +#include "Presenter.h" +#include "BloodView.h" + +namespace OHOS +{ + class BloodView; + + class BloodPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + BloodPresenter(); + virtual ~BloodPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static BloodPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodShowPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodShowPresenter.h new file mode 100644 index 000000000..68e819598 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodShowPresenter.h @@ -0,0 +1,33 @@ +#ifndef _BloodShow_PRESENTER_H +#define _BloodShow_PRESENTER_H + +#include "Presenter.h" +#include "BloodShowView.h" + +namespace OHOS +{ + class BloodShowView; + + class BloodShowPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + BloodShowPresenter(); + virtual ~BloodShowPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static BloodShowPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodShowView.h b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodShowView.h new file mode 100644 index 000000000..155753362 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodShowView.h @@ -0,0 +1,49 @@ +#ifndef _BloodShow_VIEW_H +#define _BloodShow_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_image_animator.h" + +#include "BloodShowPresenter.h" +namespace OHOS +{ + + class BloodShowPresenter; + class BloodShowView : public View + { + + public: + BloodShowView(); + virtual ~BloodShowView(); + static BloodShowView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + BloodShowView(BloodShowView &&) = delete; + BloodShowView &operator=(BloodShowView &&) = delete; + + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UIImageView *image1_ = nullptr; + UILabel *label1_ = nullptr; + UILabel *label3_ = nullptr; + UIImageView *image2_ = nullptr; + UILabel *label2_ = nullptr; + }; +} // namespace OHOS +#endif // BloodShow_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodView.h b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodView.h new file mode 100644 index 000000000..591e121cb --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodView.h @@ -0,0 +1,53 @@ +#ifndef _Blood_VIEW_H +#define _Blood_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_image_animator.h" +#include "components/ui_label_button_ext.h" + +#include "BloodPresenter.h" +namespace OHOS +{ + +#define WARNING "button1" +#define CHECK "button2" + + class BloodPresenter; + class BloodView : public View + { + + public: + BloodView(); + virtual ~BloodView(); + static BloodView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + BloodView(BloodView &&) = delete; + BloodView &operator=(BloodView &&) = delete; + + UIViewGroup *container_ = nullptr; + UIImageView *image1_ = nullptr; + UIButton *button1_ = nullptr; + UILabelButtonExt *labelButton1_ = nullptr; + UILabel *label2_ = nullptr; + UILabel *label1_ = nullptr; + UILabel *label3_ = nullptr; + }; +} // namespace OHOS +#endif // Blood_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodCheckPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodCheckPresenter.cpp new file mode 100644 index 000000000..38b245365 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodCheckPresenter.cpp @@ -0,0 +1,76 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "/blood/include/BloodCheckPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static BloodCheckPresenter *g_pBloodCheckPresenter = nullptr; + + BloodCheckPresenter::BloodCheckPresenter() + { + + g_pBloodCheckPresenter = this; + } + + BloodCheckPresenter::~BloodCheckPresenter() + { + + g_pBloodCheckPresenter = nullptr; + } + + BloodCheckPresenter *BloodCheckPresenter::GetInstance() + { + + return g_pBloodCheckPresenter; + } + + void BloodCheckPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void BloodCheckPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void BloodCheckPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void BloodCheckPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool BloodCheckPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + // if (event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT) + // { + // printf("draglistene is ok!\n"); + // NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + // } + UNUSED(view); + return true; + } + + bool BloodCheckPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), "labelButton1") == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_BLOOD); + } + + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodCheckView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodCheckView.cpp new file mode 100644 index 000000000..70c6c9571 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodCheckView.cpp @@ -0,0 +1,182 @@ + + +#include "/blood/include/BloodCheckView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + static BloodCheckView *g_pBloodCheckView{nullptr}; + + BloodCheckView::BloodCheckView() + { + + g_pBloodCheckView = this; + } + + BloodCheckView::~BloodCheckView() + { + DeInit(); + g_pBloodCheckView = nullptr; + } + + BloodCheckView *BloodCheckView::GetInstance() + { + + return g_pBloodCheckView; + } + void BloodCheckView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(173, 52); // widget's left position and top position + label1_->Resize(120, 35); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + label1_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label1_->SetText("正在检测"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label1_); + label1_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(116, 103); // widget's left position and top position + image1_->Resize(234, 260); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/BloodCheckOxygen/SaO2.bin"; +#else + char *image1imagesPath = "/user/res/Blood/SaO2.bin"; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to rootView + container_->Add(image1_); + image1_->SetVisible(true); + + // Add LabelButtonExt to App + if (labelButton1_ == nullptr) + { + labelButton1_ = new UILabelButtonExt(); + } + labelButton1_->SetPosition(118, 336); // widget's left position and top position + labelButton1_->Resize(230, 80); // widget's width and height + labelButton1_->SetViewId("labelButton1"); // Set style + labelButton1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + + // Set additional property + labelButton1_->SetText("停止检测"); + labelButton1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + labelButton1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *labelButton1Click = static_cast(BloodCheckPresenter::GetInstance()); + labelButton1_->SetOnClickListener(labelButton1Click); + // Add to rootView + container_->Add(labelButton1_); + labelButton1_->SetVisible(true); + } + + void BloodCheckView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (labelButton1_ != nullptr) + { + delete labelButton1_; + labelButton1_ = nullptr; + } + } + + UIView *BloodCheckView::GetView() + { + Init(); + return container_; + } + void BloodCheckView::OnStart() + { + container_ = new UIScrollView(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(BloodCheckPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void BloodCheckView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void BloodCheckView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void BloodCheckView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodPresenter.cpp new file mode 100644 index 000000000..0ed4c65c0 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodPresenter.cpp @@ -0,0 +1,79 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "/blood/include/BloodPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static BloodPresenter *g_pBloodPresenter = nullptr; + + BloodPresenter::BloodPresenter() + { + + g_pBloodPresenter = this; + } + + BloodPresenter::~BloodPresenter() + { + + g_pBloodPresenter = nullptr; + } + + BloodPresenter *BloodPresenter::GetInstance() + { + + return g_pBloodPresenter; + } + + void BloodPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void BloodPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void BloodPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void BloodPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool BloodPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) + { + printf("draglistene is ok!\n"); + NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + } + UNUSED(view); + return true; + } + + bool BloodPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), WARNING) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_BLOODSHOW); + } + if (strcmp(view.GetViewId(), CHECK) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_BLOODCHECK); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodShowPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodShowPresenter.cpp new file mode 100644 index 000000000..3ed16060e --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodShowPresenter.cpp @@ -0,0 +1,73 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "/blood/include/BloodShowPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static BloodShowPresenter *g_pBloodShowPresenter = nullptr; + + BloodShowPresenter::BloodShowPresenter() + { + + g_pBloodShowPresenter = this; + } + + BloodShowPresenter::~BloodShowPresenter() + { + + g_pBloodShowPresenter = nullptr; + } + + BloodShowPresenter *BloodShowPresenter::GetInstance() + { + + return g_pBloodShowPresenter; + } + + void BloodShowPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void BloodShowPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void BloodShowPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void BloodShowPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool BloodShowPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT) + { + printf("draglistene is ok!\n"); + NativeAbility::GetInstance().ChangeSlice(VIEW_BLOOD); + } + UNUSED(view); + return true; + } + + bool BloodShowPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + // if (strcmp(view.GetViewId(), 控件ID) == 0) + + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodShowView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodShowView.cpp new file mode 100644 index 000000000..9d5d04981 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodShowView.cpp @@ -0,0 +1,241 @@ + + +#include "/blood/include/BloodShowView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + static BloodShowView *g_pBloodShowView{nullptr}; + + BloodShowView::BloodShowView() + { + + g_pBloodShowView = this; + } + + BloodShowView::~BloodShowView() + { + DeInit(); + g_pBloodShowView = nullptr; + } + + BloodShowView *BloodShowView::GetInstance() + { + + return g_pBloodShowView; + } + + void BloodShowView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add ScrollView to App + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); // widget's left position and top position + scrollView1_->Resize(466, 466); // widget's width and height + scrollView1_->SetViewId("scrollView1"); // Set style + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // Set additional property + + // Add to rootView + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(183, -20); // widget's left position and top position + image1_->Resize(100, 100); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Set additional property + + // Add to scrollView1 + scrollView1_->Add(image1_); + image1_->SetVisible(true); + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(203, 52); // widget's left position and top position + label1_->Resize(60, 35); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label1_->SetText("说明"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label1_); + label1_->SetVisible(true); + + // Add Label to App + if (label3_ == nullptr) + { + label3_ = new UILabel(); + } + label3_->SetPosition(33, 656); // widget's left position and top position + label3_->Resize(200, 60); // widget's width and height + label3_->SetViewId("label3"); // Set style + label3_->SetStyle(STYLE_TEXT_FONT, 26); + + // Set additional property + label3_->SetText("注:本产品非医疗器械,提供的检\n测结果仅供参考,不可作为诊断及\n治疗根据;"); + label3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label3_->SetTextColor(Color::GetColorFromRGBA(0xff, 0x8a, 0x26, 0xff)); + label3_->SetRollSpeed(0); + label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + + // Add to scrollView1 + scrollView1_->Add(label3_); + label3_->SetVisible(true); + + // Add ImageView to App + if (image2_ == nullptr) + { + image2_ = new UIImageView(); + } + image2_->SetPosition(183, 773); // widget's left position and top position + image2_->Resize(100, 100); // widget's width and height + image2_->SetViewId("image2"); // Set style + + // Set additional property + + // Add to scrollView1 + scrollView1_->Add(image2_); + image2_->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(33, 133); // widget's left position and top position + label2_->Resize(200, 60); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 26); + + // Set additional property + label2_->SetText("血氧饱和度(Oxygen saturation)\n是指血中「氧饱和血红蛋白」相对\n于「总血红蛋白(不饱和+饱\n和)」的比值。\n\n人体需要并调节血液中氧气的非常\n精确和特定的平衡。人体的正常动\n脉血氧饱和度(SaO2)为\n97-100%,或96-99%。如果该水\n平低于90%,则被认为是低氧血\n症。动脉血氧水平低于80%可能会\n损害器官功能。\n\n请按照提示进行正确佩戴检测,晃\n动手臂、佩戴倾斜或松弛可能会影\n响检测结果及其准确性。"); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + + // Add to scrollView1 + scrollView1_->Add(label2_); + label2_->SetVisible(true); + } + + void BloodShowView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (label3_ != nullptr) + { + delete label3_; + label3_ = nullptr; + } + if (image2_ != nullptr) + { + delete image2_; + image2_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + } + + UIView *BloodShowView::GetView() + { + Init(); + return container_; + } + void BloodShowView::OnStart() + { + container_ = new UIScrollView(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(BloodShowPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void BloodShowView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void BloodShowView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void BloodShowView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodView.cpp new file mode 100644 index 000000000..f002dc82b --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodView.cpp @@ -0,0 +1,254 @@ + + +#include "/blood/include/BloodView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + static BloodView *g_pBloodView{nullptr}; + + BloodView::BloodView() + { + + g_pBloodView = this; + } + + BloodView::~BloodView() + { + DeInit(); + g_pBloodView = nullptr; + } + + BloodView *BloodView::GetInstance() + { + + return g_pBloodView; + } + +void BloodView::Init() +{ + if (container_ == nullptr) { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add ImageView to App + if (image1_ == nullptr) { + image1_ = new UIImageView(); + } + image1_->SetPosition(0, 0); // widget's left position and top position + image1_->Resize(100, 100); // widget's width and height + image1_->SetViewId("image1");// Set style + + // Set additional property +#ifdef _WIN32 + char* image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/BloodOxygen/beijing.bin"; +#else + char* image1imagesPath = "/user/res/Blood/beijing.bin"; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to rootView + container_->Add(image1_); + image1_->SetVisible(true); + + // Add Button to App + if (button1_ == nullptr) { + button1_ = new UIButton(); + } + button1_->SetPosition(300, 57); // widget's left position and top position + button1_->Resize(26, 26); // widget's width and height + button1_->SetViewId(WARNING);// Set style + button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char* button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/BloodOxygen/Vector.bin"; +#else + char* button1defaultImgSrc = "/user/res/Blood/Vector.bin"; +#endif + char * button1triggeredImgSrc = nullptr; + button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener* button1Click = static_cast(BloodPresenter::GetInstance()); + button1_->SetOnClickListener(button1Click); + // Add to rootView + container_->Add(button1_); + button1_->SetVisible(true); + + // Add LabelButtonExt to App + if (labelButton1_ == nullptr) { + labelButton1_ = new UILabelButtonExt(); + } + labelButton1_->SetPosition(118, 336); // widget's left position and top position + labelButton1_->Resize(230, 80); // widget's width and height + labelButton1_->SetViewId(CHECK);// Set style + labelButton1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffcd492c); + + // Set additional property + labelButton1_->SetText("检测"); + labelButton1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + labelButton1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener* labelButton1Click = static_cast(BloodPresenter::GetInstance()); + labelButton1_->SetOnClickListener(labelButton1Click); + // Add to rootView + container_->Add(labelButton1_); + labelButton1_->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) { + label2_ = new UILabel(); + } + label2_->SetPosition(157, 105); // widget's left position and top position + label2_->Resize(200, 60); // widget's width and height + label2_->SetViewId("label2");// Set style + label2_->SetStyle(STYLE_TEXT_FONT, 140); + + // Set additional property + label2_->SetText("98"); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 140); + + // Add to rootView + container_->Add(label2_); + label2_->SetVisible(true); + + // Add Label to App + if (label1_ == nullptr) { + label1_ = new UILabel(); + } + label1_->SetPosition(141, 263); // widget's left position and top position + label1_->Resize(185, 35); // widget's width and height + label1_->SetViewId("label1");// Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label1_->SetText("20分钟前检测"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label1_); + label1_->SetVisible(true); + + // Add Label to App + if (label3_ == nullptr) { + label3_ = new UILabel(); + } + label3_->SetPosition(143, 52); // widget's left position and top position + label3_->Resize(200, 60); // widget's width and height + label3_->SetViewId("label3");// Set style + label3_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label3_->SetText("血氧饱和度"); + label3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label3_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label3_->SetRollSpeed(0); + label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label3_); + label3_->SetVisible(true); + +} + +void BloodView::DeInit() +{ + if (container_ != nullptr) { + container_->RemoveAll(); + delete container_ ; + container_ = nullptr; + } + if (image1_ != nullptr) { + delete image1_; + image1_ = nullptr; + } + if (button1_ != nullptr) { + delete button1_; + button1_ = nullptr; + } + if (labelButton1_ != nullptr) { + delete labelButton1_; + labelButton1_ = nullptr; + } + if (label2_ != nullptr) { + delete label2_; + label2_ = nullptr; + } + if (label1_ != nullptr) { + delete label1_; + label1_ = nullptr; + } + if (label3_ != nullptr) { + delete label3_; + label3_ = nullptr; + } +} + +UIView* BloodView::GetView() +{ + Init(); + return container_; +} + void BloodView::OnStart() + { + container_ = new UIScrollView(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(BloodPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void BloodView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void BloodView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void BloodView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/bluetoothofsetting/include/BlueToothOfSettingModel.h b/code/sdk/application/wearable/nativeapp/nativeui/bluetoothofsetting/include/BlueToothOfSettingModel.h new file mode 100644 index 000000000..f691a20fa --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/bluetoothofsetting/include/BlueToothOfSettingModel.h @@ -0,0 +1,4 @@ +#ifndef BLUETOOTH_OF_SETTING_MODEL_H +#define BLUETOOTH_OF_SETTING_MODEL_H + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/bluetoothofsetting/include/BlueToothOfSettingPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/bluetoothofsetting/include/BlueToothOfSettingPresenter.h new file mode 100644 index 000000000..1bbf8b2fd --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/bluetoothofsetting/include/BlueToothOfSettingPresenter.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: SettingPresenter.h + * Author: + * Create: 2021-11-23 + */ + +#ifndef BLUETOOTH_OF_SETTING_PRESENTER_H +#define BLUETOOTH_OF_SETTING_PRESENTER_H +#include "Presenter.h" +#include "components/ui_view.h" + +namespace OHOS +{ + class BlueToothOfSettingView; + class BlueToothOfSettingPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + BlueToothOfSettingPresenter(); + virtual ~BlueToothOfSettingPresenter(); + + virtual void OnStart() override; + virtual void OnPause() override; + virtual void OnResume() override; + virtual void OnStop() override; + + static BlueToothOfSettingPresenter * GetInstance(); + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/bluetoothofsetting/include/BlueToothOfSettingView.h b/code/sdk/application/wearable/nativeapp/nativeui/bluetoothofsetting/include/BlueToothOfSettingView.h new file mode 100644 index 000000000..0cb733c37 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/bluetoothofsetting/include/BlueToothOfSettingView.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: SettingView.h + * Author: + * Create: 2021-11-23 + */ + +#ifndef BLUETOOTH_OF_SETTING_VIEW_H +#define BLUETOOTH_OF_SETTING_VIEW_H + +#include "BaseView.h" +#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 "components/ui_button.h" +#include "components/ui_image_view.h" +#include "components/ui_toggle_button.h" +#include "ChangeSliceListener.h" +#include "BlueToothOfSettingPresenter.h" +namespace OHOS +{ + + // 返回setting视图界面 + class BlueToothOfSettingPresenter; + class BlueToothOfSettingView : public View + { + public: + BlueToothOfSettingView(); + virtual ~BlueToothOfSettingView(); + static BlueToothOfSettingView *GetInstance(void); + + virtual void OnStart() override; + virtual void OnSetUpView() override; + virtual void OnTearDownView() override; + virtual void OnStop() override; + + private: + void InitView(); + void DeInit(); + + private: + UIScrollView *BlueToothScrollView = nullptr; + UILabel *BlueToothLabel = nullptr; + UIButton *BlueToothPhoneBbutton = nullptr; + UILabel *BlueToothPhoneLabel = nullptr; + UIImageView *BlueToothPhoneImage = nullptr; + UIImageView *TradionalBlueTootImage = nullptr; + UILabel *TradionalBlueToothLabel = nullptr; + UIToggleButton *TradionalBlueToothToggleButton = nullptr; + UIImageView *image = nullptr; + UILabel *AttentionLabel = nullptr; + }; +} +#endif diff --git a/code/sdk/application/wearable/nativeapp/nativeui/bluetoothofsetting/src/BlueToothOfSettingModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/bluetoothofsetting/src/BlueToothOfSettingModel.cpp new file mode 100644 index 000000000..7ccee60fa --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/bluetoothofsetting/src/BlueToothOfSettingModel.cpp @@ -0,0 +1,2 @@ +#include "bluetoothofsetting/include/BlueToothOfSettingModel.h" + diff --git a/code/sdk/application/wearable/nativeapp/nativeui/bluetoothofsetting/src/BlueToothOfSettingPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/bluetoothofsetting/src/BlueToothOfSettingPresenter.cpp new file mode 100644 index 000000000..8a407c8dd --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/bluetoothofsetting/src/BlueToothOfSettingPresenter.cpp @@ -0,0 +1,68 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "bluetoothofsetting/include/BlueToothOfSettingPresenter.h" + +namespace OHOS +{ + // 当前Presenter属性实例化的内存指针 + static BlueToothOfSettingPresenter *g_pBlueToothOfSettingPresenter = nullptr; + + BlueToothOfSettingPresenter::BlueToothOfSettingPresenter() + { + g_pBlueToothOfSettingPresenter = this; + } + + BlueToothOfSettingPresenter::~BlueToothOfSettingPresenter() + { + g_pBlueToothOfSettingPresenter = nullptr; + } + + BlueToothOfSettingPresenter *BlueToothOfSettingPresenter::GetInstance() + { + return g_pBlueToothOfSettingPresenter; + } + + void BlueToothOfSettingPresenter::OnStart() + { + Presenter::OnStart(); + } + + void BlueToothOfSettingPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void BlueToothOfSettingPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void BlueToothOfSettingPresenter::OnStop(void) + { + Presenter::OnStop(); + } + + bool BlueToothOfSettingPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); + } + return true; + } + + bool BlueToothOfSettingPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), "BlueToothPhoneBbutton") == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_BLUETOOTH_EARPHONE); + } + return true; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/bluetoothofsetting/src/BlueToothOfSettingView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/bluetoothofsetting/src/BlueToothOfSettingView.cpp new file mode 100644 index 000000000..8925f696c --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/bluetoothofsetting/src/BlueToothOfSettingView.cpp @@ -0,0 +1,238 @@ +#include "bluetoothofsetting/include/BlueToothOfSettingView.h" +#include "bluetoothofsetting/include/BlueToothOfSettingPresenter.h" +#include "UiConfig.h" + +#include "InitComponent.h" //组件初始化头文件 +namespace OHOS +{ + static BlueToothOfSettingView *g_pBlueToothOfSettingView{nullptr}; + BlueToothOfSettingView::BlueToothOfSettingView() + { + g_pBlueToothOfSettingView = this; + } + + BlueToothOfSettingView::~BlueToothOfSettingView() + { + g_pBlueToothOfSettingView = nullptr; + } + BlueToothOfSettingView *BlueToothOfSettingView::GetInstance() + { + return g_pBlueToothOfSettingView; + } + // 销毁 + void BlueToothOfSettingView::DeInit() + { + if (BlueToothScrollView != nullptr) + { + delete BlueToothScrollView; + BlueToothScrollView = nullptr; + } + if (BlueToothLabel != nullptr) + { + delete BlueToothLabel; + BlueToothLabel = nullptr; + } + if (BlueToothPhoneBbutton != nullptr) + { + delete BlueToothPhoneBbutton; + BlueToothPhoneBbutton = nullptr; + } + if (BlueToothPhoneLabel != nullptr) + { + delete BlueToothPhoneLabel; + BlueToothPhoneLabel = nullptr; + } + if (BlueToothPhoneImage != nullptr) + { + delete BlueToothPhoneImage; + BlueToothPhoneImage = nullptr; + } + if (TradionalBlueTootImage != nullptr) + { + delete TradionalBlueTootImage; + TradionalBlueTootImage = nullptr; + } + if (TradionalBlueToothLabel != nullptr) + { + delete TradionalBlueToothLabel; + TradionalBlueToothLabel = nullptr; + } + if (TradionalBlueToothLabel != nullptr) + { + delete TradionalBlueToothLabel; + TradionalBlueToothLabel = nullptr; + } + if (TradionalBlueToothToggleButton != nullptr) + { + delete TradionalBlueToothToggleButton; + TradionalBlueToothToggleButton = nullptr; + } + if (image != nullptr) + { + delete image; + image = nullptr; + } + if (AttentionLabel != nullptr) + { + delete AttentionLabel; + AttentionLabel = nullptr; + } + } + // 初始化 + void BlueToothOfSettingView::InitView() + { + InitComponent &Component = InitComponent::GetInstance(); // 获取类的实例 + /********************************************************************************************************/ + BlueToothScrollView = new UIScrollView(); + if (BlueToothScrollView == nullptr) + { + return; + } + UIView::OnDragListener *dragListener_ = static_cast(BlueToothOfSettingPresenter::GetInstance()); + if (dragListener_ == nullptr) + { + return; + } + BlueToothScrollView->SetOnDragListener(dragListener_); + BlueToothScrollView->SetTouchable(true); + BlueToothScrollView->SetDraggable(true); + BlueToothScrollView->SetPosition(0, 0); + BlueToothScrollView->Resize(466, 466); + BlueToothScrollView->SetViewId("BlueToothScrollView"); + BlueToothScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + BlueToothScrollView->ScrollBy(466,466); + BlueToothScrollView->SetVisible(true); + /********************************************************************************************************/ + if (BlueToothLabel == nullptr) + { + BlueToothLabel = Component.InitLabel(203, 52, 60, 35, "蓝牙", "BlueToothLabel", 30); + } + BlueToothScrollView->Add(BlueToothLabel); + BlueToothLabel->SetVisible(true); + /********************************************************************************************************/ + if (BlueToothPhoneBbutton == nullptr) + { + BlueToothPhoneBbutton = Component.InitButton(43, 120, 380, 100, "BlueToothPhoneBbutton", PNG_SETTING_BACKGROUND_IMAGE, nullptr); + } + // Add the CallBack about events + UIView::OnClickListener *buttonClick = static_cast(BlueToothOfSettingPresenter::GetInstance()); + BlueToothPhoneBbutton->SetOnClickListener(buttonClick); + // Add to scrollView1 + BlueToothScrollView->Add(BlueToothPhoneBbutton); + BlueToothPhoneBbutton->SetVisible(true); + /********************************************************************************************************/ + if (BlueToothPhoneLabel == nullptr) + { + BlueToothPhoneLabel = Component.InitLabel(90, 153, 120, 35, "蓝牙耳机", "BlueToothPhoneLabel", 30); + } + BlueToothScrollView->Add(BlueToothPhoneLabel); + BlueToothPhoneLabel->SetVisible(true); + /********************************************************************************************************/ + if (BlueToothPhoneImage == nullptr) + { + BlueToothPhoneImage = Component.InitImageView(369, 157, 14, 26, "BlueToothPhoneImage", PNG_SETTING_NEXT_IMAGE); + } + BlueToothScrollView->Add(BlueToothPhoneImage); + BlueToothPhoneImage->SetVisible(true); + /********************************************************************************************************/ + if (TradionalBlueTootImage == nullptr) + { + TradionalBlueTootImage = Component.InitImageView(43, 240, 100, 100, "TradionalBlueTootImage", PNG_SETTING_BACKGROUND_IMAGE); + } + BlueToothScrollView->Add(TradionalBlueTootImage); + TradionalBlueTootImage->SetVisible(true); + /********************************************************************************************************/ + if (TradionalBlueToothLabel == nullptr) + { + TradionalBlueToothLabel = Component.InitLabel(90, 273, 120, 35, "传统蓝牙", "TradionalBlueToothLabel", 30); + } + BlueToothScrollView->Add(TradionalBlueToothLabel); + TradionalBlueToothLabel->SetVisible(true); + /********************************************************************************************************/ + if (TradionalBlueToothToggleButton == nullptr) + { + TradionalBlueToothToggleButton = new UIToggleButton(); + } + TradionalBlueToothToggleButton->SetPosition(298, 265); + TradionalBlueToothToggleButton->Resize(100, 50); + TradionalBlueToothToggleButton->SetViewId("toggleButton_1"); + TradionalBlueToothToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + TradionalBlueToothToggleButton->SetStyle(STYLE_BORDER_RADIUS, 50); + TradionalBlueToothToggleButton->SetStyle(STYLE_BORDER_COLOR, 0xff07c146); + TradionalBlueToothToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE,PNG_TOGGLEBUTTON_OFF_IMAGE); + // Add the CallBack about events + // UIView::OnClickListener *toggleButton4Click = static_cast(new Togglebutton4OnClickListener()); + // TradionalBlueToothToggleButton->SetOnClickListener(toggleButton4Click); + // Add to scrollView1 + BlueToothScrollView->Add(TradionalBlueToothToggleButton); + TradionalBlueToothToggleButton->SetVisible(true); + /********************************************************************************************************/ + if (image == nullptr) + { + image = new UIImageView(); + } + image->SetPosition(183, 521); + image->Resize(100, 100); + image->SetViewId("image"); + BlueToothScrollView->Add(image); + image->SetVisible(true); + /********************************************************************************************************/ + if (AttentionLabel == nullptr) + { + AttentionLabel = new UILabel(); + } + AttentionLabel->SetPosition(53, 379); // widget's left position and top position + AttentionLabel->Resize(360, 209); // widget's width and height + AttentionLabel->SetViewId("AttentionLabel"); // Set style + AttentionLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + AttentionLabel->SetStyle(STYLE_BORDER_COLOR, 0xff999999); + AttentionLabel->SetStyle(STYLE_TEXT_FONT, 20); + AttentionLabel->SetStyle(STYLE_LINE_HEIGHT, 30); + + // Set additional property + AttentionLabel->SetText("注:开启后10分钟没连接成功会自动关闭,因为传统蓝牙长时间打开会增加电耗,建议在有需要的时候使用\n\n(该功能主要用于电话拨打/通知、音乐控制/传输等)"); + AttentionLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + AttentionLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + AttentionLabel->SetRollSpeed(6); + AttentionLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + + // Add to scrollView1 + BlueToothScrollView->Add(AttentionLabel); + AttentionLabel->SetVisible(true); + /********************************************************************************************************/ + } + + void BlueToothOfSettingView::OnStart() + { + View::OnStart(); + + InitView(); + + RootView::GetInstance()->Add(BlueToothScrollView); + RootView::GetInstance()->Invalidate(); + } + + void BlueToothOfSettingView::OnSetUpView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BlueToothOfSettingView::OnSetUpView"); + View::OnSetUpView(); + return; + } + + void BlueToothOfSettingView::OnTearDownView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BlueToothOfSettingView::OnTearDownView"); + View::OnTearDownView(); + RootView::GetInstance()->RemoveAll(); + DeInit(); + return; + } + + void BlueToothOfSettingView::OnStop() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BlueToothOfSettingView::OnStop"); + View::OnStop(); + return; + } + +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/brightnesscontrol/include/BrightnessControlPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/brightnesscontrol/include/BrightnessControlPresenter.h new file mode 100644 index 000000000..96ff641c6 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/brightnesscontrol/include/BrightnessControlPresenter.h @@ -0,0 +1,37 @@ +#ifndef BRIGHTNESS_CONTROL_PRESENTER_H +#define BRIGHTNESS_CONTROL_PRESENTER_H + + +#include "Presenter.h" + +#include "BrightnessControlView.h" + +namespace OHOS +{ + class BrightnessControlView; + + class BrightnessControlPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + BrightnessControlPresenter(); + virtual ~BrightnessControlPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static BrightnessControlPresenter *GetInstance(); + + private: + //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} //namespace OHOS + + + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/brightnesscontrol/include/BrightnessControlView.h b/code/sdk/application/wearable/nativeapp/nativeui/brightnesscontrol/include/BrightnessControlView.h new file mode 100644 index 000000000..b23a359bf --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/brightnesscontrol/include/BrightnessControlView.h @@ -0,0 +1,43 @@ +#ifndef BRIGHTNESS_CONTROL_VIEW_H +#define BRIGHTNESS_CONTROL_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_slider.h" +#include "components/ui_image_view.h" +namespace OHOS +{ + static const char *BRIGHTNESS_CONTROL_SLIDER = "BCslider"; + + class BrightnessControlPresenter; + class BrightnessControlView : public View{ + + public: + BrightnessControlView(); + virtual ~BrightnessControlView(); + static BrightnessControlView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + UIView::OnDragListener *draglistener{nullptr}; + UIView::OnClickListener *sliderClick{nullptr}; + UIView::OnDragListener *sliderDrag{nullptr}; + void InitView(void); + + UIViewGroup* container_ = nullptr; + UISlider* BCslider = nullptr; + UIImageView* BCimageicon = nullptr; + }; +} //namespace OHOS + + + + + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/brightnesscontrol/src/BrightnessControlPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/brightnesscontrol/src/BrightnessControlPresenter.cpp new file mode 100644 index 000000000..60f410107 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/brightnesscontrol/src/BrightnessControlPresenter.cpp @@ -0,0 +1,77 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "brightnesscontrol/include/BrightnessControlPresenter.h" + +namespace OHOS{ + + //当前Presenter属性实例化的内存指针 + static BrightnessControlPresenter *g_pBrightnessControlPresenter = nullptr; + + BrightnessControlPresenter::BrightnessControlPresenter(){ + + g_pBrightnessControlPresenter = this; + } + + BrightnessControlPresenter::~BrightnessControlPresenter(){ + + g_pBrightnessControlPresenter = nullptr; + } + + BrightnessControlPresenter *BrightnessControlPresenter::GetInstance(){ + + return g_pBrightnessControlPresenter; + } + + void BrightnessControlPresenter::OnStart(){ + + Presenter::OnStart(); + } + + void BrightnessControlPresenter::OnPause(void){ + + Presenter::OnPause(); + } + + void BrightnessControlPresenter::OnResume(void){ + + Presenter::OnResume(); + } + + void BrightnessControlPresenter::OnStop(void){ + + Presenter::OnStop(); + } + + bool BrightnessControlPresenter::OnDrag(UIView &view, const DragEvent &event){ + + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_DISPLAY_BRIGHTNESS);//跳转到显示与亮度view + } + if(strcmp(view.GetViewId(), BRIGHTNESS_CONTROL_SLIDER)) + { + + } + return true; + } + + bool BrightnessControlPresenter::OnClick(UIView &view, const ClickEvent &event){ + + // 根据控件id查找是哪个控件触发了点击回调 + // if (strcmp(view.GetViewId(), 控件ID) == 0) + if(strcmp(view.GetViewId(), BRIGHTNESS_CONTROL_SLIDER)) + { + + } + return true; + } +} + + + + + + diff --git a/code/sdk/application/wearable/nativeapp/nativeui/brightnesscontrol/src/BrightnessControlView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/brightnesscontrol/src/BrightnessControlView.cpp new file mode 100644 index 000000000..341ce8b28 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/brightnesscontrol/src/BrightnessControlView.cpp @@ -0,0 +1,118 @@ +#include "brightnesscontrol/include/BrightnessControlView.h" +#include "brightnesscontrol/include/BrightnessControlPresenter.h" +#include "UiConfig.h" +namespace OHOS +{ + + static BrightnessControlView *g_pBrightnessControlView{nullptr}; + + BrightnessControlView::BrightnessControlView() + { + g_pBrightnessControlView = this; + } + + BrightnessControlView::~BrightnessControlView() + { + g_pBrightnessControlView = nullptr; + if (container_ != nullptr) + { + delete container_; + container_ = nullptr; + } + if (BCslider != nullptr) + { + delete BCslider; + BCslider = nullptr; + } + if (BCimageicon != nullptr) + { + delete BCimageicon; + BCimageicon = nullptr; + } + } + + BrightnessControlView *BrightnessControlView::GetInstance() + { + + return g_pBrightnessControlView; + } + void BrightnessControlView::InitView(void) + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + container_->SetStyle(STYLE_BACKGROUND_COLOR, 0x000000); + } + draglistener = static_cast(BrightnessControlPresenter::GetInstance()); + container_->SetOnDragListener(draglistener); + container_->SetTouchable(true); + container_->SetDraggable(true); + /********************************************************************************************************/ + if (BCslider == nullptr) + { + BCslider = new UISlider(); + } + BCslider->SetPosition(167, 77); + BCslider->Resize(130, 310); + BCslider->SetViewId(BRIGHTNESS_CONTROL_SLIDER); + BCslider->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + BCslider->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + BCslider->SetStyle(STYLE_BORDER_OPA, 0x19); + BCslider->SetStyle(STYLE_BORDER_RADIUS, 100); + BCslider->SetDirection(UISlider::Direction::DIR_BOTTOM_TO_TOP); + BCslider->SetValue(20); + BCslider->SetSliderColor(Color::GetColorFromRGBA(0x19, 0x19, 0x19, 0xff), Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff)); + BCslider->SetKnobStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + BCslider->SetForegroundStyle(STYLE_BACKGROUND_OPA, 0xff); + BCslider->SetBackgroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND); // 圆帽式 + BCslider->SetForegroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND); // 设置进度条的前景样式。圆帽式 + BCslider->SetStyle(STYLE_BORDER_COLOR, 0xff000000); + sliderClick = static_cast(BrightnessControlPresenter::GetInstance()); // 用来处理之后点击slider的点击事件 + BCslider->SetOnClickListener(sliderClick); + sliderDrag = static_cast(BrightnessControlPresenter::GetInstance()); // 用来处理之后拖动slider的拖动事件 + BCslider->SetOnDragListener(sliderDrag); + container_->Add(BCslider); + BCslider->SetVisible(true); + /********************************************************************************************************/ + if (BCimageicon == nullptr) + { + BCimageicon = new UIImageView(); + } + BCimageicon->SetPosition(213, 213); // widget's left position and top position + BCimageicon->Resize(100, 100); // widget's width and height + BCimageicon->SetViewId("BCimageicon"); // Set style + BCimageicon->SetStyle(STYLE_BORDER_COLOR, 0xffAAAAAA); + BCimageicon->SetSrc(PNG_BRIGHTNESS_CONTROL_VECTOR); + + container_->Add(BCimageicon); + BCimageicon->SetVisible(true); + } + + void BrightnessControlView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void BrightnessControlView::OnSetUpView() + { + View::OnSetUpView(); + Draw(); + } + + void BrightnessControlView::OnTearDownView() + { + View::OnTearDownView(); + return; + } + + void BrightnessControlView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/CompassCalibrationView.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/CompassCalibrationView.h index b6469cccf..b37a86bb1 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/CompassCalibrationView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/CompassCalibrationView.h @@ -27,8 +27,6 @@ private: UILabel *labelOne{nullptr}; UILabel *labelTwo{nullptr}; UIImageView *imageView{nullptr}; - - void ClearAll(void); }; } #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/CompassControlView.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/CompassControlView.h index 7fa5ee943..5b7c6a7f6 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/CompassControlView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/CompassControlView.h @@ -10,25 +10,20 @@ #include "components/root_view.h" #include "UiConfig.h" -#include "components/ui_card_page.h" +#include "AppGroupView.h" #include "CompassCalibrationView.h" #include "CompassView.h" namespace OHOS { -class CompassControlView : public UICardPage { +class CompassControlView : public AppGroupView { public: CompassControlView(); virtual ~CompassControlView(); - bool InitView(void); - void PreLoad(void) override; - void UnLoad(void) override; + bool InitView(void *caller) override; private: CompassCalibrationView *compassCalibrationView{nullptr}; CompassView *compassView{nullptr}; - bool viewiInitStatus{false}; - - void ClearAll(void); }; } -#endif +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/CompassPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/CompassPresenter.h index 85c5d6fd5..e742c53b6 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/CompassPresenter.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/CompassPresenter.h @@ -36,9 +36,9 @@ public: void DisplayAngleRight(uint16_t angle); private: - int16_t lastRotateAngle{0}; - int16_t currentRotateAngle{0}; - int16_t angleDiff{0}; + int16_t lastRotateAngle{0}; //上一次的旋转角度 + int16_t currentRotateAngle{0}; //当前的旋转角度 + int16_t angleDiff{0}; //角度差 bool getAngleStatus{false}; bool initDisplayStatus{true}; }; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/CompassView.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/CompassView.h index 276ae7d85..0703cfb78 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/CompassView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/CompassView.h @@ -16,11 +16,15 @@ #include "UiConfig.h" #include "AppGroupView.h" #include "CompassCalibrationView.h" - +#include "components/ui_button.h" +#include "MainCompassPresenter.h" +#include namespace OHOS { static constexpr float VIEW_CENTERS = 227; - -class CompassView : public AppGroupView { +static const char * PLACE_MARKER_BUTTON_VIEWID = "PlaceMarker"; //放置标记点按钮视图ID +static const char * PATH_BACKTRACKING_BUTTON_VIEWID = "PathBackTracking"; //路径回溯按钮视图ID +class MainCompassPresenter; +class CompassView : public AppGroupView ,public View{ public: CompassView(); virtual ~CompassView(); @@ -33,15 +37,19 @@ public: bool GetInitViewState(void); bool InitCompassImage(void); + bool ReadFlagToFile(); private: bool LoadCompassImage(UIImageView *view, uint32_t resId); - void ClearAll(void); - UILabel *directionLabel{nullptr}; - UILabel *angledLabel{nullptr}; - UIImageView *backGround{nullptr}; - UIImageView *rotateShaft{nullptr}; - UIImageView *triangulation{nullptr}; - const Vector2 VIEW_CENTER = {VIEW_CENTERS, VIEW_CENTERS}; + UILabel *directionLabel{nullptr}; //方向标签 + UILabel *angledLabel{nullptr}; //角度标签 + UIImageView *backGround{nullptr}; //背景图片 + //UIImageView *rotateShaft{nullptr}; //旋转轴图片 + UIButton *PlaceMarkerButton{nullptr}; //放置标记按钮 + UIButton *PathBackTrackingButton{nullptr};//路径回溯按钮 + UIView::OnClickListener* PlaceMarkerButtonClick = nullptr; //放置标记点按钮的点击回调 + UIView::OnClickListener* PathBackTrackingButtonClick =nullptr; //路径回溯按钮的点击回调 + UIImageView *triangulation{nullptr}; //三角图片 + const Vector2 VIEW_CENTER = {VIEW_CENTERS, VIEW_CENTERS}; //二维向量 }; } #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/EndBackTrackingCompassPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/EndBackTrackingCompassPresenter.h new file mode 100644 index 000000000..8731b39ca --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/EndBackTrackingCompassPresenter.h @@ -0,0 +1,33 @@ +#ifndef END_BACK_TRACKING_COMPASS_PRESENTER_H +#define END_BACK_TRACKING_COMPASS_PRESENTER_H + +/*结束路径回溯*/ +#include "Presenter.h" +#include "EndBackTrackingCompassView.h" +#include "EndPathRecordCompassPresenter.h" +namespace OHOS +{ + class EndBackTrackingCompassView; + class EndBackTrackingCompassPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + EndBackTrackingCompassPresenter(); + virtual ~EndBackTrackingCompassPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static EndBackTrackingCompassPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/EndBackTrackingCompassView.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/EndBackTrackingCompassView.h new file mode 100644 index 000000000..9986695a1 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/EndBackTrackingCompassView.h @@ -0,0 +1,44 @@ +#ifndef END_BACK_TRACKING_COMPASS_VIEW_H +#define END_BACK_TRACKING_COMPASS_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_image_view.h" +#include "components/ui_label_button_ext.h" +namespace OHOS +{ + static const char *COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1_VIEWID = "COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1"; // 结束路径回溯 + static const char *COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2_VIEWID = "COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2"; // 暂不 + class EndBackTrackingCompassPresenter; + class EndBackTrackingCompassView : public View + { + + public: + EndBackTrackingCompassView(); + virtual ~EndBackTrackingCompassView(); + static EndBackTrackingCompassView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + + private: + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UIImageView *COMPASS_END_BACK_TRACKING_EARLY_IMAGE = nullptr; + UIImageView *image = nullptr; + UILabelButtonExt *COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1 = nullptr; + UILabelButtonExt *COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2 = nullptr; + UIView::OnClickListener *COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1_CLICK{nullptr}; + UIView::OnClickListener *COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2_CLICK{nullptr}; + }; +} // namespace OHOS +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/EndBackTrackingEarlyCompassPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/EndBackTrackingEarlyCompassPresenter.h new file mode 100644 index 000000000..cff585ea9 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/EndBackTrackingEarlyCompassPresenter.h @@ -0,0 +1,33 @@ +#ifndef END_BACK_TRACKING_EARLY_COMPASS_PRESENTER_H +#define END_BACK_TRACKING_EARLY_COMPASS_PRESENTER_H + +/*提前结束路径回溯*/ +#include "Presenter.h" +#include "EndBackTrackingEarlyCompassView.h" +#include "EndPathRecordCompassPresenter.h" +namespace OHOS +{ + class EndBackTrackingEarlyCompassView; + class EndBackTrackingEarlyCompassPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + EndBackTrackingEarlyCompassPresenter(); + virtual ~EndBackTrackingEarlyCompassPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static EndBackTrackingEarlyCompassPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/EndBackTrackingEarlyCompassView.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/EndBackTrackingEarlyCompassView.h new file mode 100644 index 000000000..ba32ce6b3 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/EndBackTrackingEarlyCompassView.h @@ -0,0 +1,41 @@ +#ifndef END_BACK_TRACKING_EARLY_COMPASS_VIEW_H +#define END_BACK_TRACKING_EARLY_COMPASS_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_image_view.h" +#include "components/ui_label_button_ext.h" +namespace OHOS +{ + static const char *COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON_VIEWID = "COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON"; // 提前结束路径回溯 + class EndBackTrackingEarlyCompassPresenter; + class EndBackTrackingEarlyCompassView : public View + { + + public: + EndBackTrackingEarlyCompassView(); + virtual ~EndBackTrackingEarlyCompassView(); + static EndBackTrackingEarlyCompassView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + + private: + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UIImageView *image4_ = nullptr; + UIImageView *COMPASS_END_BACK_TRACKING_EARLY_IMAGE = nullptr; + UILabelButtonExt *COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON = nullptr; + UIView::OnClickListener *COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON_CLICK{nullptr}; + }; +} // namespace OHOS +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/EndPathRecordCompassPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/EndPathRecordCompassPresenter.h new file mode 100644 index 000000000..215c599e3 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/EndPathRecordCompassPresenter.h @@ -0,0 +1,36 @@ +#ifndef END_PATH_RECORD_COMPASS_PRESENTER_H +#define END_PATH_RECORD_COMPASS_PRESENTER_H + +/*结束路径记录*/ +#include "Presenter.h" +#include "EndPathRecordCompassView.h" +#include +namespace OHOS +{ + + class EndPathRecordCompassView; + class EndPathRecordCompassPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + EndPathRecordCompassPresenter(); + virtual ~EndPathRecordCompassPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static EndPathRecordCompassPresenter *GetInstance(); + static void WriteFlagToFile(const char *EndPathRecordFlag,int flag); + + private: + //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} //namespace OHOS + + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/EndPathRecordCompassView.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/EndPathRecordCompassView.h new file mode 100644 index 000000000..5a22a79bb --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/EndPathRecordCompassView.h @@ -0,0 +1,44 @@ +#ifndef END_PATH_RECORD_COMPASS_VIEW_H +#define END_PATH_RECORD_COMPASS_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +namespace OHOS +{ + static const char *END_PATH_RECORD_BUTTON1_VIEWID = "END_PATH_RECORD_BUTTON1"; //结束路径记录:结束按钮视图ID + static const char *END_PATH_RECORD_BUTTON2_VIEWID = "END_PATH_RECORD_BUTTON2"; //结束路径记录:暂不按钮视图ID + class EndPathRecordCompassPresenter; + class EndPathRecordCompassView : public View + { + + public: + EndPathRecordCompassView(); + virtual ~EndPathRecordCompassView(); + static EndPathRecordCompassView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + + private: + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView = nullptr; + UIImageView *COMPASS_END_PATH_RECORD_IMAGE = nullptr; + UIImageView *image = nullptr; + UIButton *END_PATH_RECORD_BUTTON1 = nullptr; // 结束路径记录:结束按钮 + UIButton *END_PATH_RECORD_BUTTON2 = nullptr; // 结束路径记录:暂不按钮 + UIView::OnClickListener *END_PATH_RECORD_BUTTON1_CLICK{nullptr}; // 结束路径记录:结束按钮点击回调 + UIView::OnClickListener *END_PATH_RECORD_BUTTON2_CLICK{nullptr}; // 结束路径记录:暂不按钮点击回调 + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/GPSLossCompassPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/GPSLossCompassPresenter.h new file mode 100644 index 000000000..9e2fabc0a --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/GPSLossCompassPresenter.h @@ -0,0 +1,32 @@ +#ifndef GPS_LOSS_COMPASS_PRESENTER_H +#define GPS_LOSS_COMPASS_PRESENTER_H +/*GPS丢失*/ +#include "Presenter.h" +#include "GPSLossCompassView.h" +namespace OHOS +{ + class GPSLossCompassView; + + class GPSLossCompassPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + GPSLossCompassPresenter(); + virtual ~GPSLossCompassPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static GPSLossCompassPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/GPSLossCompassView.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/GPSLossCompassView.h new file mode 100644 index 000000000..c7de332d1 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/GPSLossCompassView.h @@ -0,0 +1,39 @@ +#ifndef GPS_LOSS_COMPASS_VIEW_H +#define GPS_LOSS_COMPASS_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_image_view.h" +#include "components/ui_label_button_ext.h" +namespace OHOS +{ + static const char *GPS_LOSS_COMPASS_LABELBUTTON_VIEWID = "GPSLossLabelButton"; + class GPSLossCompassPresenter; + class GPSLossCompassView : public View + { + + public: + GPSLossCompassView(); + virtual ~GPSLossCompassView(); + static GPSLossCompassView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + + private: + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UIImageView *COMPASS_GPS_LOSS_IMAGE = nullptr; + UILabelButtonExt *GPSLossLabelButton = nullptr; + UIView::OnClickListener *GPSLossLabelButtonClick = nullptr; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/MainCompassPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/MainCompassPresenter.h index 30580afcd..61e87f299 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/MainCompassPresenter.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/MainCompassPresenter.h @@ -20,7 +20,7 @@ namespace OHOS { class CompassView; class MainCompassPresenter : public Presenter, public CompassPresenter, - public ModelListenerSample, public UIView::OnDragListener { + public ModelListenerSample, public UIView::OnDragListener,public UIView::OnClickListener { public: MainCompassPresenter(); virtual ~MainCompassPresenter(); @@ -32,6 +32,7 @@ public: static MainCompassPresenter *GetInstance(void); bool OnDrag(UIView& view, const DragEvent& event) override; + bool OnClick(UIView &view, const ClickEvent &event) override; virtual void Notify() override; }; } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/MainCompassView.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/MainCompassView.h index cb5a25815..62c0fc12c 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/MainCompassView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/MainCompassView.h @@ -36,7 +36,7 @@ public: void OnStop() override; static MainCompassView *GetInstance(void); - void SetDisplayTure(void); + void SetDisplayTrue(void); void SetDisplayFalse(void); private: diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/MakerPointCompassPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/MakerPointCompassPresenter.h new file mode 100644 index 000000000..308c59282 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/MakerPointCompassPresenter.h @@ -0,0 +1,35 @@ +#ifndef MAKER_POINT_COMPASS_PRESENTER_H +#define MAKER_POINT_COMPASS_PRESENTER_H + +/*标记点介绍*/ +#include "Presenter.h" +#include "MakerPointCompassView.h" + +namespace OHOS +{ + class MakerPointCompassView; + + class MakerPointCompassPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + MakerPointCompassPresenter(); + virtual ~MakerPointCompassPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static MakerPointCompassPresenter *GetInstance(); + + private: + //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} //namespace OHOS + + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/MakerPointCompassView.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/MakerPointCompassView.h new file mode 100644 index 000000000..82b2a463f --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/MakerPointCompassView.h @@ -0,0 +1,38 @@ +#ifndef MAKER_POINT_COMPASS_VIEW_H +#define MAKER_POINT_COMPASS_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +namespace OHOS +{ + static const char *COMPASS_MAKER_POINT_BUTTON_VIEWID = "COMPASS_MAKER_POINT_BUTTON"; + class MakerPointCompassPresenter; + class MakerPointCompassView : public View + { + + public: + MakerPointCompassView(); + virtual ~MakerPointCompassView(); + static MakerPointCompassView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + + private: + UIView::OnClickListener *buttonClick{nullptr}; + UIViewGroup *container_ = nullptr; + UIImageView *COMPASS_MAKER_POINT_BACKGROUND_IMAGE = nullptr; + UIButton *COMPASS_MAKER_POINT_BUTTON = nullptr; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/PathBackTrackingCompassPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/PathBackTrackingCompassPresenter.h new file mode 100644 index 000000000..8afb53340 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/PathBackTrackingCompassPresenter.h @@ -0,0 +1,34 @@ +#ifndef PATH_BACKTRACKING_COMPASS_PRESENTER_H +#define PATH_BACKTRACKING_COMPASS_PRESENTER_H + +/*路径回溯*/ +#include "Presenter.h" +#include "PathBackTrackingCompassView.h" + +namespace OHOS +{ + class PathBackTrackingCompassView; + + class PathBackTrackingCompassPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + PathBackTrackingCompassPresenter(); + virtual ~PathBackTrackingCompassPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static PathBackTrackingCompassPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/PathBackTrackingCompassView.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/PathBackTrackingCompassView.h new file mode 100644 index 000000000..18ac39fe5 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/PathBackTrackingCompassView.h @@ -0,0 +1,44 @@ +#ifndef PATH_BACKTRACKING_COMPASS_VIEW_H +#define PATH_BACKTRACKING_COMPASS_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_label_button_ext.h" +namespace OHOS +{ + static const char *PATH_BACKTRACKING_LABELBUTTON1_VIEWID = "labelButton1"; //开始回溯 + static const char *PATH_BACKTRACKING_LABELBUTTON2_VIEWID = "labelButton2"; //暂不 + class PathBackTrackingCompassPresenter; + class PathBackTrackingCompassView : public View + { + + public: + PathBackTrackingCompassView(); + virtual ~PathBackTrackingCompassView(); + static PathBackTrackingCompassView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + + private: + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView = nullptr; + UILabel *label1_ = nullptr; + UILabel *label2_ = nullptr; + UILabelButtonExt *labelButton1 = nullptr; + UILabelButtonExt *labelButton2 = nullptr; + UIView::OnClickListener *labelButton1Click{nullptr}; + UIView::OnClickListener *labelButton2Click{nullptr}; + }; +} // namespace OHOS +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/PathRetracingCompassPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/PathRetracingCompassPresenter.h new file mode 100644 index 000000000..d4b31d3d1 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/PathRetracingCompassPresenter.h @@ -0,0 +1,31 @@ +#ifndef PATH_RETRACING_COMPASS_PRESENTER_H +#define PATH_RETRACING_COMPASS_PRESENTER_H + +/*路径回溯中*/ +#include "Presenter.h" +#include "PathRetracingCompassView.h" +namespace OHOS +{ + class PathRetracingCompassView; + + class PathRetracingCompassPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + PathRetracingCompassPresenter(); + virtual ~PathRetracingCompassPresenter(); + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + static PathRetracingCompassPresenter *GetInstance(); + double GetCurrentToEndDistance(void); + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/PathRetracingCompassView.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/PathRetracingCompassView.h new file mode 100644 index 000000000..0f04bc58d --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/PathRetracingCompassView.h @@ -0,0 +1,42 @@ +#ifndef PATH_RETRACING_COMPASS_VIEW_H +#define PATH_RETRACING_COMPASS_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_label_button_ext.h" +namespace OHOS +{ + static const char *PATH_RETRACING_LABELBUTTON_VIEWID = "PATH_RETRACING_LABELBUTTON"; //结束路径回溯按钮ID + class PathRetracingCompassPresenter; + class PathRetracingCompassView : public View + { + + public: + PathRetracingCompassView(); + virtual ~PathRetracingCompassView(); + static PathRetracingCompassView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + + private: + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UILabel *label1_ = nullptr; + UIImageView *image2_ = nullptr; + UIImageView *image1_ = nullptr; + UILabelButtonExt *PATH_RETRACING_LABELBUTTON = nullptr; + UIView::OnClickListener *PATH_RETRACING_LABELBUTTON_CLICK{nullptr}; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/PlaceMakerCompassPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/PlaceMakerCompassPresenter.h new file mode 100644 index 000000000..c5e91ff66 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/PlaceMakerCompassPresenter.h @@ -0,0 +1,33 @@ +#ifndef PLACE_MAKER_COMPASS_PRESENTER_H +#define PLACE_MAKER_COMPASS_PRESENTER_H + +/*放置标记点*/ +#include "Presenter.h" +#include "PlaceMakerCompassView.h" + +namespace OHOS +{ + class PlaceMakerCompassView; + + class PlaceMakerCompassPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + PlaceMakerCompassPresenter(); + virtual ~PlaceMakerCompassPresenter(); + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + static PlaceMakerCompassPresenter *GetInstance(); + bool GetGPSConnectStatus(void); + private: + //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} //namespace OHOS + + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/PlaceMakerCompassView.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/PlaceMakerCompassView.h new file mode 100644 index 000000000..21d7a4e10 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/PlaceMakerCompassView.h @@ -0,0 +1,42 @@ +#ifndef PLACE_MAKER_COMPASS_VIEW_H +#define PLACE_MAKER_COMPASS_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +namespace OHOS +{ + static const char *PLACE_MAKER_BUTTON1_VIEWID = "PLACE_MAKER_BUTTON1"; + static const char *PLACE_MAKER_BUTTON2_VIEWID = "PLACE_MAKER_BUTTON2"; + class PlaceMakerCompassPresenter; + class PlaceMakerCompassView : public View + { + + public: + PlaceMakerCompassView(); + virtual ~PlaceMakerCompassView(); + static PlaceMakerCompassView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + + private: + UIView::OnDragListener *draglistener{nullptr}; + UIView::OnClickListener *button1Click{nullptr}; + UIView::OnClickListener *button2Click{nullptr}; + UIViewGroup *container_ = nullptr; + UIImageView *PLACE_MAKER_BACKGROUND_IMAGE = nullptr; + UIButton *PLACE_MAKER_BUTTON1 = nullptr; + UIButton *PLACE_MAKER_BUTTON2 = nullptr; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/ResetPlaceMakerCompassPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/ResetPlaceMakerCompassPresenter.h new file mode 100644 index 000000000..ddba1d815 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/ResetPlaceMakerCompassPresenter.h @@ -0,0 +1,34 @@ +#ifndef RESET_PLACE_MAKER_COMPASS_PRESENTER_H +#define RESET_PLACE_MAKER_COMPASS_PRESENTER_H + +/*重置路径标记点*/ +#include "Presenter.h" +#include "ResetPlaceMakerCompassView.h" + +namespace OHOS +{ + class ResetPlaceMakerCompassView; + + class ResetPlaceMakerCompassPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + ResetPlaceMakerCompassPresenter(); + virtual ~ResetPlaceMakerCompassPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static ResetPlaceMakerCompassPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/ResetPlaceMakerCompassView.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/ResetPlaceMakerCompassView.h new file mode 100644 index 000000000..81db380d3 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/ResetPlaceMakerCompassView.h @@ -0,0 +1,43 @@ +#ifndef RESET_PLACE_MAKER_COMPASS_VIEW_H +#define RESET_PLACE_MAKER_COMPASS_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +namespace OHOS +{ + static const char *RESET_PLACE_MAKER_BUTTON1_VIEWID = "RESET_PLACE_MAKER_BUTTON1"; //重置标记点按钮1视图ID + static const char *RESET_PLACE_MAKER_BUTTON2_VIEWID = "RESET_PLACE_MAKER_BUTTON2"; //重置标记点按钮2视图ID + class ResetPlaceMakerCompassPresenter; + class ResetPlaceMakerCompassView : public View + { + + public: + ResetPlaceMakerCompassView(); + virtual ~ResetPlaceMakerCompassView(); + static ResetPlaceMakerCompassView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + + private: + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView = nullptr; + UIImageView *COMPASS_RESET_PLACE_MAKER_BACKGROUND_IMAGE = nullptr; + UIImageView *image = nullptr; + UIButton *RESET_PLACE_MAKER_BUTTON1 = nullptr; + UIButton *RESET_PLACE_MAKER_BUTTON2 = nullptr; + UIView::OnClickListener *RESET_PLACE_MAKER_BUTTON1Click{nullptr}; + UIView::OnClickListener *RESET_PLACE_MAKER_BUTTON2Click{nullptr}; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/StartPathRecordCompassPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/StartPathRecordCompassPresenter.h new file mode 100644 index 000000000..e5098ea99 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/StartPathRecordCompassPresenter.h @@ -0,0 +1,35 @@ +#ifndef START_PATH_RECORD_COMPASS_PRESENTER_H +#define START_PATH_RECORD_COMPASS_PRESENTER_H + +/*开始路径记录*/ +#include "Presenter.h" +#include "StartPathRecordCompassView.h" +#include "components/ui_canvas.h" +namespace OHOS +{ + class StartPathRecordCompassView; + + class StartPathRecordCompassPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + StartPathRecordCompassPresenter(); + virtual ~StartPathRecordCompassPresenter(); + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + static StartPathRecordCompassPresenter *GetInstance(); + public: + bool GetGPSConnectStatus(void); //获取GPS的连接状态 + UICanvas*RecordingPath(UIView &view); //记录路径线:UICanvas是一个画线的类 + private: + //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} //namespace OHOS + + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/include/StartPathRecordCompassView.h b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/StartPathRecordCompassView.h new file mode 100644 index 000000000..c08fb627d --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/include/StartPathRecordCompassView.h @@ -0,0 +1,37 @@ +#ifndef START_PATH_RECORD_COMPASS_VIEW_H +#define START_PATH_RECORD_COMPASS_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +namespace OHOS +{ + static const char *COMPASS_START_PATH_RECORD_BUTTON_VIEWID = "COMPASS_START_PATH_RECORD_BUTTON"; //停止记录按钮id + class StartPathRecordCompassPresenter; + class StartPathRecordCompassView : public View + { + + public: + StartPathRecordCompassView(); + virtual ~StartPathRecordCompassView(); + static StartPathRecordCompassView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + + private: + UIViewGroup *container_ = nullptr; + UIImageView *COMPASS_START_PATH_RECORD_IMAGE = nullptr; + UIButton *COMPASS_START_PATH_RECORD_BUTTON = nullptr; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/CompassCalibrationView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/CompassCalibrationView.cpp index 568a6558b..3a2d48291 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/CompassCalibrationView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/CompassCalibrationView.cpp @@ -26,32 +26,20 @@ static CompassCalibrationView *g_pMainView = nullptr; CompassCalibrationView::CompassCalibrationView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CompassCalibrationView::CompassCalibrationView"); - SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); g_pMainView = this; } CompassCalibrationView::~CompassCalibrationView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CompassCalibrationView::~CompassCalibrationView"); - ClearAll(); - g_pMainView = nullptr; -} - -void CompassCalibrationView::ClearAll(void) -{ RemoveAll(); - if (labelOne != nullptr) { - delete labelOne; - labelOne = nullptr; - } - if (imageView != nullptr) { - delete imageView; - imageView = nullptr; - } - if (labelTwo != nullptr) { - delete labelTwo; - labelTwo = nullptr; - } + delete labelOne; + delete imageView; + delete labelTwo; + labelOne = nullptr; + imageView = nullptr; + labelTwo = nullptr; + g_pMainView = nullptr; } CompassCalibrationView *CompassCalibrationView::GetInstance(void) @@ -73,7 +61,6 @@ bool CompassCalibrationView::CreateUIViewGroup(void) labelOne = new UILabel(); if (labelOne == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CompassCalibrationView::new labelOne fail"); - ClearAll(); return false; } @@ -88,7 +75,6 @@ bool CompassCalibrationView::CreateUIViewGroup(void) labelTwo = new UILabel(); if (labelTwo == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CompassCalibrationView::new labelTwo fail"); - ClearAll(); return false; } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/CompassControlView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/CompassControlView.cpp index ab61623bd..836fc14c7 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/CompassControlView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/CompassControlView.cpp @@ -8,34 +8,28 @@ #include "CompassModel.h" namespace OHOS { +static CompassControlView *g_pCompassControlView = nullptr; + CompassControlView::CompassControlView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CompassControlView::CompassControlView()"); - SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + g_pCompassControlView = this; } CompassControlView::~CompassControlView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CompassControlView::~CompassControlView()"); - ClearAll(); -} - -void CompassControlView::ClearAll(void) -{ RemoveAll(); - if (compassCalibrationView != nullptr) { - delete compassCalibrationView; - compassCalibrationView = nullptr; - } - if (compassView != nullptr) { - delete compassView; - compassView = nullptr; - } + delete compassCalibrationView; + compassCalibrationView = nullptr; + delete compassView; + compassView = nullptr; + g_pCompassControlView = nullptr; } -bool CompassControlView::InitView(void) +bool CompassControlView::InitView(void *caller) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CompassControlView InitView"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CompassControlView InitView %p", caller); compassCalibrationView = new CompassCalibrationView(); if (compassCalibrationView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CompassCalibrationView::new compassCalibrationView fail"); @@ -63,19 +57,7 @@ bool CompassControlView::InitView(void) compassView->SetVisible(true); compassCalibrationView->SetVisible(false); } + initViewStatus = true; return true; } - -void CompassControlView::PreLoad(void) -{ - if (!viewiInitStatus) { - InitView(); - viewiInitStatus = true; - } -} - -void CompassControlView::UnLoad(void) -{ - // Compass's usage scenes is complicated, so we do not release it's resources inner slice. -} } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/CompassModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/CompassModel.cpp index 1675aa814..55204a625 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/CompassModel.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/CompassModel.cpp @@ -35,7 +35,7 @@ uint8_t CompassModel::GetCalibrationStatus(void) { return 0; } - +//显示的角度范围:0~359 void CompassModel::SetDisplayAngle(uint16_t angle) { displayAngle += angle; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/CompassPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/CompassPresenter.cpp index 5c78f2643..3c7b30454 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/CompassPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/CompassPresenter.cpp @@ -69,15 +69,15 @@ CompassPresenter* CompassPresenter::GetInstance(void) { return g_pMainView; } - +//显示指南针的角度 void CompassPresenter::DisplayAngleRight(uint16_t angle) { if ((angle >= RIGHT_WESTNORTH_UP_338) || (angle >= 0 && angle < RIGHT_NORTH_DOWN_23)) { - CompassView::GetInstance()->DirectionSetText(NORTH_DIRECTION, (std::to_string(angle) + "°").c_str()); + CompassView::GetInstance()->DirectionSetText(NORTH_DIRECTION, ("~" + std::to_string(angle) + "°").c_str()); } for (int i = 0; i < DIRECTION_COUNT; i++) { if ((angle >= g_compassList[i].beginAngle) && (angle < g_compassList[i].endAngle)) { - CompassView::GetInstance()->DirectionSetText(g_compassList[i].dir, (std::to_string(angle) + "°").c_str()); + CompassView::GetInstance()->DirectionSetText(g_compassList[i].dir, ("~" + std::to_string(angle) + "°").c_str()); } } } @@ -93,7 +93,7 @@ void CompassPresenter::DisplayAngleDir(uint16_t angle) } } - +//在范围内旋转指南针 void CompassPresenter::InScopeRotate(void) { angleDiff = lastRotateAngle - currentRotateAngle; @@ -137,7 +137,7 @@ void CompassPresenter::InScopeRotate(void) } } } - +//在指南针视图初始化的情况下,根据旋转角度的变化来执行指南针的旋转操作,并在需要的时候更新显示的角度和方向。 void CompassPresenter::DetermineToRotate(void) { if (CompassView::GetInstance() == nullptr) { @@ -166,7 +166,7 @@ void CompassPresenter::DetermineToRotate(void) } } GraphicService::GetInstance()->PostGraphicEvent(std::bind(&CompassModel::SetDisplayAngle, - CompassModel::GetInstance(), 1)); + CompassModel::GetInstance(), 1));//将任务发布到异步线程 } } \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/CompassView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/CompassView.cpp index 5f4b901a5..5092654a2 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/CompassView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/CompassView.cpp @@ -9,69 +9,97 @@ #include "ui_resource_image.h" #include "CompassView.h" #include "MainCompassView.h" - +#include "CompassPresenter.h" namespace OHOS { static constexpr int16_t POINT_CENTER_IMAGE_X = 150; static constexpr int16_t POINT_CENTER_IMAGE_Y = 150; static constexpr int16_t TRIANGULATION_X = 210; static constexpr int16_t TRIANGULATION_Y = 0; -static constexpr int16_t DIRECTIONLABEL_X = 160; -static constexpr int16_t DIRECTIONLABEL_Y = 215; -static constexpr int16_t FONT_TEXT_SIZE = 25; -static constexpr int16_t ANGLEDLABEL_X = 215; -static constexpr int16_t ANGLEDLABEL_Y = 215; -static constexpr int16_t TEXT_WIDTH = 90; -static constexpr int16_t TEXT_HEIGHT = 35; +static constexpr int16_t DIRECTIONLABEL_X = 198; +static constexpr int16_t DIRECTIONLABEL_Y = 131; +static constexpr int16_t DIRECTIONLABEL_TEXT_WIDTH = 70; +static constexpr int16_t DIRECTIONLABEL_TEXT_HEIGH = 42; +static constexpr int16_t DIRECTIONLABEL_FONT_TEXT_SIZE = 35; +static constexpr int16_t DIRECTIONLABEL_STYLE_LINE_HEIGHT = 42; +static constexpr int16_t ANGLEDLABEL_X = 136; +static constexpr int16_t ANGLEDLABEL_Y = 182; +static constexpr int16_t ANGLEDLABEL_TEXT_WIDTH = 194; +static constexpr int16_t ANGLEDLABEL_TEXT_HEIGHT = 94; +static constexpr int16_t ANGLEDLABEL_FONT_TEXT_SIZE = 80; +static constexpr int16_t ANGLEDLABEL_STYLE_LINE_HEIGHT = 94; static constexpr int16_t RANDOM_NUMBER_720 = 720; static constexpr int16_t RANDOM_NUMBER_360 = 360; static constexpr int16_t DELAYING_NUMS = 2000; static CompassView *g_pCompassView = nullptr; - +static bool EndPathRecordFlag = false; //一开始路径回溯的按钮不显示,因为没有放置标记点 CompassView::CompassView() { - SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); g_pCompassView = this; + EndPathRecordFlag = ReadFlagToFile(); } -CompassView::~CompassView() +//从文件中读取一个字符串:"EndPathRecordFlag"和其标志位:如果字符串对应为1则有放置标记点,否则没有 +bool CompassView::ReadFlagToFile() { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CompassView::~CompassView()"); - ClearAll(); - g_pCompassView = nullptr; + FILE *fp =fopen("/user/res/compass/file.txt","rb"); + if(fp == NULL) + { + perror("fopen file error\n"); + return false; + } + char buf[32]={0}; + int flag = 0; + fscanf(fp,"%s %d",buf,&flag); + if(strcmp(buf,"EndPathRecordFlag") == 0 && flag == 1) + { + return true; + } + fclose(fp); + return false; } -void CompassView::ClearAll(void) + +CompassView::~CompassView() { - RemoveAll(); - if (directionLabel != nullptr) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CompassView::~CompassView()"); + if (initViewStatus == true) { + RemoveAll(); delete directionLabel; - directionLabel= nullptr; - } - if (angledLabel != nullptr) { + directionLabel = nullptr; + delete angledLabel; angledLabel = nullptr; - } - if (backGround != nullptr) { + delete backGround; backGround = nullptr; - } - if (rotateShaft != nullptr) { - delete rotateShaft; - rotateShaft = nullptr; - } - if (triangulation != nullptr) { + + //delete rotateShaft; + //rotateShaft = nullptr; + delete PlaceMarkerButton; + PlaceMarkerButton = nullptr; + + if(PathBackTrackingButton != nullptr) + { + delete PathBackTrackingButton ; + PathBackTrackingButton = nullptr; + } + + delete PlaceMarkerButtonClick; + PlaceMarkerButtonClick =nullptr; + delete triangulation; triangulation = nullptr; } + g_pCompassView = nullptr; } - +//方向和角度设置 void CompassView::DirectionSetText(const char *text, const char *angle) { directionLabel->SetText(text); angledLabel->SetText(angle); } - +//加载指南针图片 bool CompassView::LoadCompassImage(UIImageView *view, uint32_t resId) { std::string file = COMPASS_IAMGES; @@ -84,9 +112,10 @@ bool CompassView::LoadCompassImage(UIImageView *view, uint32_t resId) view->SetSrc(image); return true; } - +//初始化指南针图片 bool CompassView::InitCompassImage(void) { + /* backGround = new UIImageView(); if (backGround == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d], backGround new fail", __LINE__); @@ -121,26 +150,92 @@ bool CompassView::InitCompassImage(void) return false; } return true; + */ + backGround = new UIImageView(); + if (backGround == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d], backGround new fail", __LINE__); + return false; + } + backGround->SetPosition(0, 0); + backGround->Resize(466, 466); + backGround->SetViewId("backGround"); + backGround->SetSrc(PNG_COMPASS_BACKGROUND_IMAGE); + backGround->SetVisible(true); + /***********************************************************************************************************/ + // Add Button to App + if (PlaceMarkerButton == nullptr) { + PlaceMarkerButton = new UIButton(); + } + if(EndPathRecordFlag == false) + { + PlaceMarkerButton->SetPosition(198, 282); + } + else + { + PlaceMarkerButton->SetPosition(148, 282); + if (PathBackTrackingButton == nullptr) { + PathBackTrackingButton = new UIButton(); + } + PathBackTrackingButton->SetPosition(248, 282); + PathBackTrackingButton->Resize(70, 70); + PathBackTrackingButton->SetViewId(PATH_BACKTRACKING_BUTTON_VIEWID); + PathBackTrackingButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xfffafafa); + PathBackTrackingButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + PathBackTrackingButton->SetImageSrc(PNG_COMPASS_PATH_BACKTRACKING_IMAGE, nullptr); + PathBackTrackingButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + PathBackTrackingButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + PathBackTrackingButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + // Add the CallBack about events + PathBackTrackingButtonClick = static_cast(MainCompassPresenter::GetInstance()); + PathBackTrackingButton->SetOnClickListener(PathBackTrackingButtonClick); + PathBackTrackingButton->SetVisible(true); + } + PlaceMarkerButton->Resize(70, 70); + PlaceMarkerButton->SetViewId(PLACE_MARKER_BUTTON_VIEWID); + PlaceMarkerButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + PlaceMarkerButton->SetStyle(STYLE_BORDER_RADIUS, 0); + PlaceMarkerButton->SetImageSrc(PNG_COMPASS_PLACE_MARKER_BUTTON_IMAGE, nullptr); + PlaceMarkerButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + PlaceMarkerButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + PlaceMarkerButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + PlaceMarkerButton->SetStyleForState(STYLE_BORDER_RADIUS, 0, UIButton::PRESSED); + // Add the CallBack about events + PlaceMarkerButtonClick = static_cast(MainCompassPresenter::GetInstance()); + PlaceMarkerButton->SetOnClickListener(PlaceMarkerButtonClick); + PlaceMarkerButton->SetVisible(true); + /***********************************************************************************************************/ + triangulation = new UIImageView(); + if (triangulation == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d], triangulation new fail", __LINE__); + return false; + } + triangulation->SetPosition(221, 20); + triangulation->Resize(24, 20); + triangulation->SetViewId("triangulation"); + triangulation->SetSrc(PNG_COMPASS_TRIANGULATION_IMAGE); + triangulation->SetVisible(true); + return true; } - +//初始化页面 bool CompassView::InitPage(void) { if (InitCompassImage() == false) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitCompassImage fail"); - ClearAll(); return false; } directionLabel = new UILabel(); if (directionLabel == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "directionLabel new fail"); - ClearAll(); return false; } directionLabel->SetPosition(DIRECTIONLABEL_X, DIRECTIONLABEL_Y); - directionLabel->Resize(TEXT_WIDTH, TEXT_HEIGHT); + directionLabel->Resize(DIRECTIONLABEL_TEXT_WIDTH, DIRECTIONLABEL_TEXT_HEIGH); directionLabel->SetText("北"); - directionLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_TEXT_SIZE); + directionLabel->SetStyle(STYLE_TEXT_FONT, DIRECTIONLABEL_FONT_TEXT_SIZE); + directionLabel->SetStyle(STYLE_LINE_HEIGHT, DIRECTIONLABEL_STYLE_LINE_HEIGHT); + directionLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, DIRECTIONLABEL_FONT_TEXT_SIZE); + directionLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); directionLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); directionLabel->SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE); directionLabel->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); @@ -149,20 +244,27 @@ bool CompassView::InitPage(void) angledLabel = new UILabel(); if (angledLabel == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "angledLabel new fail"); - ClearAll(); return false; } - angledLabel->SetPosition(ANGLEDLABEL_X, ANGLEDLABEL_Y); - angledLabel->Resize(TEXT_WIDTH, TEXT_HEIGHT); - angledLabel->SetText("0°"); - angledLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_TEXT_SIZE); + angledLabel->SetPosition(ANGLEDLABEL_X, ANGLEDLABEL_Y); + angledLabel->Resize(ANGLEDLABEL_TEXT_WIDTH, ANGLEDLABEL_TEXT_HEIGHT); + angledLabel->SetText("~0°"); + angledLabel->SetStyle(STYLE_TEXT_FONT, ANGLEDLABEL_FONT_TEXT_SIZE); + angledLabel->SetStyle(STYLE_LINE_HEIGHT, ANGLEDLABEL_STYLE_LINE_HEIGHT); + angledLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, ANGLEDLABEL_FONT_TEXT_SIZE); + angledLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); angledLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); angledLabel->SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE); angledLabel->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); angledLabel->SetStyle(STYLE_TEXT_COLOR, Color::White().full); Add(backGround); - Add(rotateShaft); + Add(PlaceMarkerButton); + if(EndPathRecordFlag == true) + { + Add(PathBackTrackingButton); + } + //Add(rotateShaft); Add(triangulation); Add(directionLabel); Add(angledLabel); @@ -172,7 +274,7 @@ bool CompassView::InitPage(void) return true; } - +//初始化视图为可拖拽,可触摸 bool CompassView::InitView(void *caller) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CompassView InitView %p", caller); @@ -194,7 +296,7 @@ CompassView *CompassView::GetInstance(void) { return g_pCompassView; } - +//背景图片逆时针旋转numb度 void CompassView::CompassStartRotate(int16_t numb) { if (backGround == nullptr) { diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/EndBackTrackingCompassPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/EndBackTrackingCompassPresenter.cpp new file mode 100644 index 000000000..8990966db --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/EndBackTrackingCompassPresenter.cpp @@ -0,0 +1,77 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "EndBackTrackingCompassPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static EndBackTrackingCompassPresenter *g_pEndBackTrackingCompassPresenter = nullptr; + + EndBackTrackingCompassPresenter::EndBackTrackingCompassPresenter() + { + + g_pEndBackTrackingCompassPresenter = this; + } + + EndBackTrackingCompassPresenter::~EndBackTrackingCompassPresenter() + { + + g_pEndBackTrackingCompassPresenter = nullptr; + } + + EndBackTrackingCompassPresenter *EndBackTrackingCompassPresenter::GetInstance() + { + + return g_pEndBackTrackingCompassPresenter; + } + + void EndBackTrackingCompassPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void EndBackTrackingCompassPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void EndBackTrackingCompassPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void EndBackTrackingCompassPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool EndBackTrackingCompassPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + UNUSED(event); + return true; + } + + bool EndBackTrackingCompassPresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1_VIEWID) == 0) + { + printf("end backtracking labelbutton being clicked\n"); + EndPathRecordCompassPresenter::WriteFlagToFile("EndPathRecordFlag", 0); + NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS); + } + else if(strcmp(view.GetViewId(), COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2_VIEWID) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS_PATH_RETRACING); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/EndBackTrackingCompassView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/EndBackTrackingCompassView.cpp new file mode 100644 index 000000000..51d016ddd --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/EndBackTrackingCompassView.cpp @@ -0,0 +1,186 @@ +#include "EndBackTrackingCompassView.h" +#include "EndBackTrackingCompassPresenter.h" +#include "UiConfig.h" + +namespace OHOS +{ + + static EndBackTrackingCompassView *g_pEndBackTrackingCompassView{nullptr}; + + EndBackTrackingCompassView::EndBackTrackingCompassView() + { + + g_pEndBackTrackingCompassView = this; + } + + EndBackTrackingCompassView::~EndBackTrackingCompassView() + { + DeInitView(); + g_pEndBackTrackingCompassView = nullptr; + } + + EndBackTrackingCompassView *EndBackTrackingCompassView::GetInstance() + { + + return g_pEndBackTrackingCompassView; + } + + void EndBackTrackingCompassView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + container_->SetTouchable(true); + } + // Add ScrollView to App + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); + scrollView1_->Resize(466, 466); + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + // Add ImageView to App + if (COMPASS_END_BACK_TRACKING_EARLY_IMAGE == nullptr) + { + COMPASS_END_BACK_TRACKING_EARLY_IMAGE = new UIImageView(); + } + COMPASS_END_BACK_TRACKING_EARLY_IMAGE->SetPosition(0, 0); + COMPASS_END_BACK_TRACKING_EARLY_IMAGE->Resize(466, 466); + COMPASS_END_BACK_TRACKING_EARLY_IMAGE->SetSrc(PNG_COMPASS_END_BACK_TRACKING_IMAGE); + // Add to scrollView1 + scrollView1_->Add(COMPASS_END_BACK_TRACKING_EARLY_IMAGE); + COMPASS_END_BACK_TRACKING_EARLY_IMAGE->SetVisible(true); + // Add LabelButtonExt to App + if (COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1 == nullptr) + { + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1 = new UILabelButtonExt(); + } + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1->SetPosition(118, 378); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1->Resize(230, 80); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1->SetViewId(COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1_VIEWID); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1->SetStyle(STYLE_BORDER_RADIUS, 100); + // Set additional property + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1->SetText("结束回溯"); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED); + // Add the CallBack about events + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1_CLICK = static_cast(EndBackTrackingCompassPresenter::GetInstance()); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1->SetOnClickListener(COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1_CLICK); + // Add to scrollView1 + scrollView1_->Add(COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1->SetVisible(true); + /****************************************************************************************************/ + // Add LabelButtonExt to App + if (COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2 == nullptr) + { + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2 = new UILabelButtonExt(); + } + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2->SetPosition(118, 484); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2->Resize(230, 80); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2->SetViewId(COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2_VIEWID); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2->SetStyle(STYLE_BORDER_RADIUS, 100); + // Set additional property + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2->SetText("暂不"); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED); + // Add the CallBack about events + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2_CLICK = static_cast(EndBackTrackingCompassPresenter::GetInstance()); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2->SetOnClickListener(COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2_CLICK); + // Add to scrollView1 + scrollView1_->Add(COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2->SetVisible(true); + // Add ImageView to App + if (image == nullptr) + { + image = new UIImageView(); + } + image->SetPosition(183, 493); + image->Resize(100, 100); + scrollView1_->Add(image); + image->SetVisible(true); + } + + void EndBackTrackingCompassView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (image != nullptr) + { + delete image; + image = nullptr; + } + if (COMPASS_END_BACK_TRACKING_EARLY_IMAGE != nullptr) + { + delete COMPASS_END_BACK_TRACKING_EARLY_IMAGE; + COMPASS_END_BACK_TRACKING_EARLY_IMAGE = nullptr; + } + if (COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1 != nullptr) + { + delete COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1; + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1 = nullptr; + } + if (COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2 != nullptr) + { + delete COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2; + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2 = nullptr; + } + if (COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1_CLICK != nullptr) + { + delete COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1_CLICK; + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON1_CLICK = nullptr; + } + if (COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2_CLICK != nullptr) + { + delete COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2_CLICK; + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON2_CLICK = nullptr; + } + } + + void EndBackTrackingCompassView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void EndBackTrackingCompassView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void EndBackTrackingCompassView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void EndBackTrackingCompassView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/EndBackTrackingEarlyCompassPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/EndBackTrackingEarlyCompassPresenter.cpp new file mode 100644 index 000000000..8fbc2bf36 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/EndBackTrackingEarlyCompassPresenter.cpp @@ -0,0 +1,73 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "EndBackTrackingEarlyCompassPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static EndBackTrackingEarlyCompassPresenter *g_pEndBackTrackingEarlyCompassPresenter = nullptr; + + EndBackTrackingEarlyCompassPresenter::EndBackTrackingEarlyCompassPresenter() + { + + g_pEndBackTrackingEarlyCompassPresenter = this; + } + + EndBackTrackingEarlyCompassPresenter::~EndBackTrackingEarlyCompassPresenter() + { + + g_pEndBackTrackingEarlyCompassPresenter = nullptr; + } + + EndBackTrackingEarlyCompassPresenter *EndBackTrackingEarlyCompassPresenter::GetInstance() + { + + return g_pEndBackTrackingEarlyCompassPresenter; + } + + void EndBackTrackingEarlyCompassPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void EndBackTrackingEarlyCompassPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void EndBackTrackingEarlyCompassPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void EndBackTrackingEarlyCompassPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool EndBackTrackingEarlyCompassPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + UNUSED(event); + return true; + } + + bool EndBackTrackingEarlyCompassPresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON_VIEWID) == 0) + { + printf("end backtracking labelbutton being clicked\n"); + EndPathRecordCompassPresenter::WriteFlagToFile("EndPathRecordFlag", 0); + NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/EndBackTrackingEarlyCompassView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/EndBackTrackingEarlyCompassView.cpp new file mode 100644 index 000000000..0596c28a0 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/EndBackTrackingEarlyCompassView.cpp @@ -0,0 +1,155 @@ +#include "EndBackTrackingEarlyCompassView.h" +#include "EndBackTrackingEarlyCompassPresenter.h" +#include "UiConfig.h" + +namespace OHOS +{ + + static EndBackTrackingEarlyCompassView *g_pEndBackTrackingEarlyCompassView{nullptr}; + + EndBackTrackingEarlyCompassView::EndBackTrackingEarlyCompassView() + { + + g_pEndBackTrackingEarlyCompassView = this; + } + + EndBackTrackingEarlyCompassView::~EndBackTrackingEarlyCompassView() + { + DeInitView(); + g_pEndBackTrackingEarlyCompassView = nullptr; + } + + EndBackTrackingEarlyCompassView *EndBackTrackingEarlyCompassView::GetInstance() + { + + return g_pEndBackTrackingEarlyCompassView; + } + + void EndBackTrackingEarlyCompassView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + container_->SetTouchable(true); + } + // Add ScrollView to App + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); + scrollView1_->Resize(466, 466); + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + // Add ImageView to App + if (COMPASS_END_BACK_TRACKING_EARLY_IMAGE == nullptr) + { + COMPASS_END_BACK_TRACKING_EARLY_IMAGE = new UIImageView(); + } + COMPASS_END_BACK_TRACKING_EARLY_IMAGE->SetPosition(0, 0); + COMPASS_END_BACK_TRACKING_EARLY_IMAGE->Resize(466, 466); + COMPASS_END_BACK_TRACKING_EARLY_IMAGE->SetSrc(PNG_COMPASS_END_BACK_TRACKING_EARLY_IMAGE); + // Add to scrollView1 + scrollView1_->Add(COMPASS_END_BACK_TRACKING_EARLY_IMAGE); + COMPASS_END_BACK_TRACKING_EARLY_IMAGE->SetVisible(true); + // Add LabelButtonExt to App + if (COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON == nullptr) + { + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON = new UILabelButtonExt(); + } + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON->SetPosition(118, 378); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON->Resize(230, 80); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON->SetViewId(COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON_VIEWID); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON->SetStyle(STYLE_BORDER_RADIUS, 100); + // Set additional property + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON->SetText("结束回溯"); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED); + // Add the CallBack about events + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON_CLICK = static_cast(EndBackTrackingEarlyCompassPresenter::GetInstance()); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON->SetOnClickListener(COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON_CLICK); + // Add to scrollView1 + scrollView1_->Add(COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON); + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON->SetVisible(true); + + // Add ImageView to App + if (image4_ == nullptr) + { + image4_ = new UIImageView(); + } + image4_->SetPosition(183, 414); + image4_->Resize(100, 100); + scrollView1_->Add(image4_); + image4_->SetVisible(true); + } + + void EndBackTrackingEarlyCompassView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (image4_ != nullptr) + { + delete image4_; + image4_ = nullptr; + } + if (COMPASS_END_BACK_TRACKING_EARLY_IMAGE != nullptr) + { + delete COMPASS_END_BACK_TRACKING_EARLY_IMAGE; + COMPASS_END_BACK_TRACKING_EARLY_IMAGE = nullptr; + } + if (COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON != nullptr) + { + delete COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON; + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON = nullptr; + } + if (COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON_CLICK != nullptr) + { + delete COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON_CLICK; + COMPASS_END_BACK_TRACKING_EARLY_LABELBUTTON_CLICK = nullptr; + } + } + + void EndBackTrackingEarlyCompassView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void EndBackTrackingEarlyCompassView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void EndBackTrackingEarlyCompassView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void EndBackTrackingEarlyCompassView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/EndPathRecordCompassPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/EndPathRecordCompassPresenter.cpp new file mode 100644 index 000000000..d672363bb --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/EndPathRecordCompassPresenter.cpp @@ -0,0 +1,92 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "EndPathRecordCompassPresenter.h" +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static EndPathRecordCompassPresenter *g_pEndPathRecordCompassPresenter = nullptr; + + EndPathRecordCompassPresenter::EndPathRecordCompassPresenter() + { + + g_pEndPathRecordCompassPresenter = this; + } + + EndPathRecordCompassPresenter::~EndPathRecordCompassPresenter() + { + + g_pEndPathRecordCompassPresenter = nullptr; + } + + EndPathRecordCompassPresenter *EndPathRecordCompassPresenter::GetInstance() + { + + return g_pEndPathRecordCompassPresenter; + } + + void EndPathRecordCompassPresenter::WriteFlagToFile(const char *EndPathRecordFlag, int flag) + { + FILE *fp = fopen("/user/res/compass/file.txt","wb"); + if(fp == NULL) + { + perror("fopen file error\n"); + return; + } + fprintf(fp,"%s %d\n",EndPathRecordFlag,flag); + fclose(fp); + } + + void EndPathRecordCompassPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void EndPathRecordCompassPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void EndPathRecordCompassPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void EndPathRecordCompassPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool EndPathRecordCompassPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + UNUSED(event); + return true; + } + + bool EndPathRecordCompassPresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), END_PATH_RECORD_BUTTON1_VIEWID) == 0) //点击结束按钮后在指南针主视图上创建路径回溯按钮,点击后可进行路径回溯 + { + printf("back main compass view.....\n"); + EndPathRecordCompassPresenter::GetInstance()->WriteFlagToFile("EndPathRecordFlag",1); + NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS); + return true; + } + else if(strcmp(view.GetViewId(), END_PATH_RECORD_BUTTON2_VIEWID) == 0) //点击暂不按钮后回到开始路径记录视图继续记录路径 + { + // uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); + // NativeAbility::GetInstance().ChangeSlice(preSlice); + NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS_START_PATH_RECORD); + return true; + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/EndPathRecordCompassView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/EndPathRecordCompassView.cpp new file mode 100644 index 000000000..eff9ed39f --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/EndPathRecordCompassView.cpp @@ -0,0 +1,195 @@ +#include "EndPathRecordCompassView.h" +#include "EndPathRecordCompassPresenter.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" + +namespace OHOS +{ + + static EndPathRecordCompassView *g_pEndPathRecordCompassView{nullptr}; + + EndPathRecordCompassView::EndPathRecordCompassView() + { + + g_pEndPathRecordCompassView = this; + } + + EndPathRecordCompassView::~EndPathRecordCompassView() + { + DeInitView(); + g_pEndPathRecordCompassView = nullptr; + } + + EndPathRecordCompassView *EndPathRecordCompassView::GetInstance() + { + + return g_pEndPathRecordCompassView; + } + + void EndPathRecordCompassView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + container_->SetTouchable(true); + container_->SetDraggable(true); + } + if (scrollView == nullptr) + { + scrollView = new UIScrollView(); + } + scrollView->SetPosition(0, 0); + scrollView->Resize(466, 466); + scrollView->SetViewId("scrollView"); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + container_->Add(scrollView); + scrollView->SetVisible(true); + // Add ImageView to App + if (COMPASS_END_PATH_RECORD_IMAGE == nullptr) + { + COMPASS_END_PATH_RECORD_IMAGE = new UIImageView(); + } + COMPASS_END_PATH_RECORD_IMAGE->SetPosition(0, 0); + COMPASS_END_PATH_RECORD_IMAGE->Resize(466, 466); + COMPASS_END_PATH_RECORD_IMAGE->SetSrc(PNG_COMPASS_END_PATH_RECORD_IMAGE); + scrollView->Add(COMPASS_END_PATH_RECORD_IMAGE); + COMPASS_END_PATH_RECORD_IMAGE->SetVisible(true); + + // Add Button to App + if (END_PATH_RECORD_BUTTON1 == nullptr) + { + END_PATH_RECORD_BUTTON1 = new UIButton(); + } + END_PATH_RECORD_BUTTON1->SetPosition(118, 345); + END_PATH_RECORD_BUTTON1->Resize(230, 80); + END_PATH_RECORD_BUTTON1->SetViewId(END_PATH_RECORD_BUTTON1_VIEWID); + END_PATH_RECORD_BUTTON1->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + END_PATH_RECORD_BUTTON1->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + END_PATH_RECORD_BUTTON1->SetStyle(STYLE_BORDER_RADIUS, 100); + // Set additional property + END_PATH_RECORD_BUTTON1->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + END_PATH_RECORD_BUTTON1->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + END_PATH_RECORD_BUTTON1->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + END_PATH_RECORD_BUTTON1->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED); + // Add the CallBack about events + END_PATH_RECORD_BUTTON1_CLICK = static_cast(EndPathRecordCompassPresenter::GetInstance()); + END_PATH_RECORD_BUTTON1->SetOnClickListener(END_PATH_RECORD_BUTTON1_CLICK); + // Add to scrollView3 + scrollView->Add(END_PATH_RECORD_BUTTON1); + END_PATH_RECORD_BUTTON1->SetVisible(true); + + // Add Button to App + if (END_PATH_RECORD_BUTTON2 == nullptr) + { + END_PATH_RECORD_BUTTON2 = new UIButton(); + } + END_PATH_RECORD_BUTTON2->SetPosition(118, 451); + END_PATH_RECORD_BUTTON2->Resize(230, 80); + END_PATH_RECORD_BUTTON2->SetViewId(END_PATH_RECORD_BUTTON2_VIEWID); + END_PATH_RECORD_BUTTON2->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + END_PATH_RECORD_BUTTON2->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + END_PATH_RECORD_BUTTON2->SetStyle(STYLE_BORDER_RADIUS, 100); + + // Set additional property + END_PATH_RECORD_BUTTON2->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + END_PATH_RECORD_BUTTON2->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + END_PATH_RECORD_BUTTON2->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + END_PATH_RECORD_BUTTON2->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED); + + // Add the CallBack about events + END_PATH_RECORD_BUTTON2_CLICK = static_cast(EndPathRecordCompassPresenter::GetInstance()); + END_PATH_RECORD_BUTTON2->SetOnClickListener(END_PATH_RECORD_BUTTON2_CLICK); + // Add to scrollView3 + scrollView->Add(END_PATH_RECORD_BUTTON2); + END_PATH_RECORD_BUTTON2->SetVisible(true); + + // Add ImageView to App + if (image == nullptr) + { + image = new UIImageView(); + } + image->SetPosition(183, 475); + image->Resize(100, 100); + image->SetViewId("image"); + scrollView->Add(image); + image->SetVisible(true); + } + + void EndPathRecordCompassView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView != nullptr) + { + delete scrollView; + scrollView = nullptr; + } + if (COMPASS_END_PATH_RECORD_IMAGE != nullptr) + { + delete COMPASS_END_PATH_RECORD_IMAGE; + COMPASS_END_PATH_RECORD_IMAGE = nullptr; + } + if (image != nullptr) + { + delete image; + image = nullptr; + } + if (END_PATH_RECORD_BUTTON1 != nullptr) + { + delete END_PATH_RECORD_BUTTON1; + END_PATH_RECORD_BUTTON1 = nullptr; + } + if (END_PATH_RECORD_BUTTON2 != nullptr) + { + delete END_PATH_RECORD_BUTTON2; + END_PATH_RECORD_BUTTON2 = nullptr; + } + if (END_PATH_RECORD_BUTTON1_CLICK != nullptr) + { + delete END_PATH_RECORD_BUTTON1_CLICK; + END_PATH_RECORD_BUTTON1_CLICK = nullptr; + } + if (END_PATH_RECORD_BUTTON2_CLICK != nullptr) + { + delete END_PATH_RECORD_BUTTON2_CLICK; + END_PATH_RECORD_BUTTON2_CLICK = nullptr; + } + } + + void EndPathRecordCompassView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void EndPathRecordCompassView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void EndPathRecordCompassView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void EndPathRecordCompassView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/GPSLossCompassPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/GPSLossCompassPresenter.cpp new file mode 100644 index 000000000..856a4467c --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/GPSLossCompassPresenter.cpp @@ -0,0 +1,70 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "GPSLossCompassPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static GPSLossCompassPresenter *g_pGPSLossCompassPresenter = nullptr; + + GPSLossCompassPresenter::GPSLossCompassPresenter() + { + + g_pGPSLossCompassPresenter = this; + } + + GPSLossCompassPresenter::~GPSLossCompassPresenter() + { + + g_pGPSLossCompassPresenter = nullptr; + } + + GPSLossCompassPresenter *GPSLossCompassPresenter::GetInstance() + { + + return g_pGPSLossCompassPresenter; + } + + void GPSLossCompassPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void GPSLossCompassPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void GPSLossCompassPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void GPSLossCompassPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool GPSLossCompassPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + UNUSED(event); + return true; + } + + bool GPSLossCompassPresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), GPS_LOSS_COMPASS_LABELBUTTON_VIEWID) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS_END_PATH_RECORD); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/GPSLossCompassView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/GPSLossCompassView.cpp new file mode 100644 index 000000000..870418712 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/GPSLossCompassView.cpp @@ -0,0 +1,139 @@ +#include "GPSLossCompassView.h" +#include "GPSLossCompassPresenter.h" +#include "UiConfig.h" + +namespace OHOS +{ + + static GPSLossCompassView *g_pGPSLossCompassView{nullptr}; + + GPSLossCompassView::GPSLossCompassView() + { + g_pGPSLossCompassView = this; + } + + GPSLossCompassView::~GPSLossCompassView() + { + DeInitView(); + g_pGPSLossCompassView = nullptr; + } + + GPSLossCompassView *GPSLossCompassView::GetInstance() + { + return g_pGPSLossCompassView; + } + + void GPSLossCompassView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + container_->SetTouchable(true); + } + // Add ScrollView to App + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); + scrollView1_->Resize(466, 466); + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + // Add ImageView to App + if (COMPASS_GPS_LOSS_IMAGE == nullptr) + { + COMPASS_GPS_LOSS_IMAGE = new UIImageView(); + } + COMPASS_GPS_LOSS_IMAGE->SetPosition(0, 0); + COMPASS_GPS_LOSS_IMAGE->Resize(466, 466); + COMPASS_GPS_LOSS_IMAGE->SetSrc(PNG_COMPASS_GPS_LOSS_IMAGE); + // Add to scrollView1 + scrollView1_->Add(COMPASS_GPS_LOSS_IMAGE); + COMPASS_GPS_LOSS_IMAGE->SetVisible(true); + // Add LabelButtonExt to App + if (GPSLossLabelButton == nullptr) + { + GPSLossLabelButton = new UILabelButtonExt(); + } + GPSLossLabelButton->SetPosition(118, 329); + GPSLossLabelButton->Resize(230, 80); + GPSLossLabelButton->SetViewId(GPS_LOSS_COMPASS_LABELBUTTON_VIEWID); + GPSLossLabelButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + GPSLossLabelButton->SetStyle(STYLE_BORDER_RADIUS, 100); + // Set additional property + GPSLossLabelButton->SetText("结束记录"); + GPSLossLabelButton->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); + GPSLossLabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + GPSLossLabelButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + GPSLossLabelButton->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED); + // Add the CallBack about events + GPSLossLabelButtonClick = static_cast(GPSLossCompassPresenter::GetInstance()); + GPSLossLabelButton->SetOnClickListener(GPSLossLabelButtonClick); + // Add to scrollView1 + scrollView1_->Add(GPSLossLabelButton); + GPSLossLabelButton->SetVisible(true); + } + + void GPSLossCompassView::DeInitView() + { + + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (COMPASS_GPS_LOSS_IMAGE != nullptr) + { + delete COMPASS_GPS_LOSS_IMAGE; + COMPASS_GPS_LOSS_IMAGE = nullptr; + } + if (GPSLossLabelButton != nullptr) + { + delete GPSLossLabelButton; + GPSLossLabelButton = nullptr; + } + if (GPSLossLabelButtonClick != nullptr) + { + delete GPSLossLabelButtonClick; + GPSLossLabelButtonClick = nullptr; + } + } + + void GPSLossCompassView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void GPSLossCompassView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void GPSLossCompassView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void GPSLossCompassView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/MainCompassPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/MainCompassPresenter.cpp index be62e81a9..c9adaaa89 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/MainCompassPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/MainCompassPresenter.cpp @@ -46,6 +46,34 @@ bool MainCompassPresenter::OnDrag(UIView& view, const DragEvent& event) } return true; } +//放置标记点的点击回调函数,用来跳转视图 +bool MainCompassPresenter::OnClick(UIView &view, const ClickEvent &event) +{ + UNUSED(event); + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), PLACE_MARKER_BUTTON_VIEWID) == 0) + { + printf("PlaceMarkerButton being clicked\n"); + if(CompassView::GetInstance()->ReadFlagToFile() == true ) //已经有了标记点后再次点击会跳转到是否重置标记点视图 + { + NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS_RESET_PLACE_MAKER); + } + else + { + NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS_PLACE_MAKER); + } + + return true; + } + else if(strcmp(view.GetViewId(), PATH_BACKTRACKING_BUTTON_VIEWID) == 0) + { + printf("PathBackTrackingButton being clicked\n"); + NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS_PATH_BACKTRACKING); + return true; + } + + return false; +} void MainCompassPresenter::Notify() { @@ -55,7 +83,7 @@ void MainCompassPresenter::Notify() } uint8_t status = CompassModel::GetInstance()->GetCalibrationStatus(); if (status == 1) { - MainCompassView::GetInstance()->SetDisplayTure(); + MainCompassView::GetInstance()->SetDisplayTrue(); } else { MainCompassView::GetInstance()->SetDisplayFalse(); DetermineToRotate(); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/MainCompassView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/MainCompassView.cpp index 9e762804a..c55bdeb63 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/MainCompassView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/MainCompassView.cpp @@ -34,7 +34,7 @@ MainCompassView *MainCompassView::GetInstance() return g_pMainCompassView; } -void MainCompassView::SetDisplayTure() +void MainCompassView::SetDisplayTrue() { if (compassView == nullptr || compassCalibrationView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCompassView::SetDisplayTure null"); @@ -71,13 +71,13 @@ void MainCompassView::OnStart() return; } - UIView::OnDragListener *compassCalibrationDragListener = (UIView::OnDragListener *) - OHOS::MainCompassPresenter::GetInstance(); + UIView::OnDragListener *compassCalibrationDragListener = (UIView::OnDragListener *)OHOS::MainCompassPresenter::GetInstance(); if (compassCalibrationDragListener == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "compassCalibrationDragListener new fail"); return; } - + compassCalibrationView->SetOnDragListener(compassCalibrationDragListener); + compassCalibrationView->InitView(this); UIView::OnDragListener *compassDragListener = (UIView::OnDragListener *)OHOS::MainCompassPresenter::GetInstance(); if (compassDragListener == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "compassDragListener new fail"); @@ -86,8 +86,7 @@ void MainCompassView::OnStart() compassView->SetOnDragListener(compassDragListener); compassView->InitView(this); - compassCalibrationView->SetOnDragListener(compassCalibrationDragListener); - compassCalibrationView->InitView(this); + RootView::GetInstance()->Add(compassView); RootView::GetInstance()->Add(compassCalibrationView); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/MakerPointCompassPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/MakerPointCompassPresenter.cpp new file mode 100644 index 000000000..4c31c7ffa --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/MakerPointCompassPresenter.cpp @@ -0,0 +1,71 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "MakerPointCompassPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static MakerPointCompassPresenter *g_pMakerPointCompassPresenter = nullptr; + + MakerPointCompassPresenter::MakerPointCompassPresenter() + { + + g_pMakerPointCompassPresenter = this; + } + + MakerPointCompassPresenter::~MakerPointCompassPresenter() + { + + g_pMakerPointCompassPresenter = nullptr; + } + + MakerPointCompassPresenter *MakerPointCompassPresenter::GetInstance() + { + + return g_pMakerPointCompassPresenter; + } + + void MakerPointCompassPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void MakerPointCompassPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void MakerPointCompassPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void MakerPointCompassPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool MakerPointCompassPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + UNUSED(event); + return true; + } + + bool MakerPointCompassPresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), COMPASS_MAKER_POINT_BUTTON_VIEWID) == 0) //放置标记点 + { + NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS_PLACE_MAKER); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/MakerPointCompassView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/MakerPointCompassView.cpp new file mode 100644 index 000000000..3b774552a --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/MakerPointCompassView.cpp @@ -0,0 +1,124 @@ +#include "MakerPointCompassView.h" +#include "MakerPointCompassPresenter.h" +#include "UiConfig.h" + +namespace OHOS +{ + + static MakerPointCompassView *g_pMakerPointCompassView{nullptr}; + + MakerPointCompassView::MakerPointCompassView() + { + + g_pMakerPointCompassView = this; + } + + MakerPointCompassView::~MakerPointCompassView() + { + DeInitView(); + g_pMakerPointCompassView = nullptr; + } + + MakerPointCompassView *MakerPointCompassView::GetInstance() + { + + return g_pMakerPointCompassView; + } + + void MakerPointCompassView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + container_->SetTouchable(true); + } + if (COMPASS_MAKER_POINT_BACKGROUND_IMAGE == nullptr) + { + COMPASS_MAKER_POINT_BACKGROUND_IMAGE = new UIImageView(); + } + COMPASS_MAKER_POINT_BACKGROUND_IMAGE->SetPosition(0, 0); + COMPASS_MAKER_POINT_BACKGROUND_IMAGE->Resize(466, 466); + COMPASS_MAKER_POINT_BACKGROUND_IMAGE->SetSrc(PNG_COMPASS_MAKER_POINT_BACKGROUND_IMAGE); + container_->Add(COMPASS_MAKER_POINT_BACKGROUND_IMAGE); + COMPASS_MAKER_POINT_BACKGROUND_IMAGE->SetVisible(true); + + // Add Button to App + if (COMPASS_MAKER_POINT_BUTTON == nullptr) + { + COMPASS_MAKER_POINT_BUTTON = new UIButton(); + } + COMPASS_MAKER_POINT_BUTTON->SetPosition(83, 366); + COMPASS_MAKER_POINT_BUTTON->Resize(300, 100); + COMPASS_MAKER_POINT_BUTTON->SetViewId("COMPASS_MAKER_POINT_BUTTON"); + COMPASS_MAKER_POINT_BUTTON->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + COMPASS_MAKER_POINT_BUTTON->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property + COMPASS_MAKER_POINT_BUTTON->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + COMPASS_MAKER_POINT_BUTTON->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + COMPASS_MAKER_POINT_BUTTON->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + buttonClick = static_cast(MakerPointCompassPresenter::GetInstance()); + COMPASS_MAKER_POINT_BUTTON->SetOnClickListener(buttonClick); + // Add to rootView + container_->Add(COMPASS_MAKER_POINT_BUTTON); + COMPASS_MAKER_POINT_BUTTON->SetVisible(true); + } + + void MakerPointCompassView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (COMPASS_MAKER_POINT_BACKGROUND_IMAGE != nullptr) + { + delete COMPASS_MAKER_POINT_BACKGROUND_IMAGE; + COMPASS_MAKER_POINT_BACKGROUND_IMAGE = nullptr; + } + if (COMPASS_MAKER_POINT_BUTTON != nullptr) + { + delete COMPASS_MAKER_POINT_BUTTON; + COMPASS_MAKER_POINT_BUTTON = nullptr; + } + if(buttonClick != nullptr) + { + delete buttonClick; + buttonClick =nullptr; + } + } + + void MakerPointCompassView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void MakerPointCompassView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void MakerPointCompassView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void MakerPointCompassView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/PathBackTrackingCompassPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/PathBackTrackingCompassPresenter.cpp new file mode 100644 index 000000000..901d24e93 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/PathBackTrackingCompassPresenter.cpp @@ -0,0 +1,78 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "PathBackTrackingCompassPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static PathBackTrackingCompassPresenter *g_pPathBackTrackingCompassPresenter = nullptr; + + PathBackTrackingCompassPresenter::PathBackTrackingCompassPresenter() + { + + g_pPathBackTrackingCompassPresenter = this; + } + + PathBackTrackingCompassPresenter::~PathBackTrackingCompassPresenter() + { + + g_pPathBackTrackingCompassPresenter = nullptr; + } + + PathBackTrackingCompassPresenter *PathBackTrackingCompassPresenter::GetInstance() + { + + return g_pPathBackTrackingCompassPresenter; + } + + void PathBackTrackingCompassPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void PathBackTrackingCompassPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void PathBackTrackingCompassPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void PathBackTrackingCompassPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool PathBackTrackingCompassPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + UNUSED(event); + return true; + } + + bool PathBackTrackingCompassPresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), PATH_BACKTRACKING_LABELBUTTON1_VIEWID) == 0) //路径回溯按钮 + { + printf("start path backtracking....\n"); + NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS_PATH_RETRACING); + return true; + } + else if(strcmp(view.GetViewId(), PATH_BACKTRACKING_LABELBUTTON2_VIEWID) == 0) //取消路径回溯 + { + NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS); + return true; + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/PathBackTrackingCompassView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/PathBackTrackingCompassView.cpp new file mode 100644 index 000000000..8c46f5d21 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/PathBackTrackingCompassView.cpp @@ -0,0 +1,218 @@ +#include "PathBackTrackingCompassView.h" +#include "PathBackTrackingCompassPresenter.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" + +namespace OHOS +{ + + static PathBackTrackingCompassView *g_pPathBackTrackingCompassView{nullptr}; + + PathBackTrackingCompassView::PathBackTrackingCompassView() + { + + g_pPathBackTrackingCompassView = this; + } + + PathBackTrackingCompassView::~PathBackTrackingCompassView() + { + DeInitView(); + g_pPathBackTrackingCompassView = nullptr; + } + + PathBackTrackingCompassView *PathBackTrackingCompassView::GetInstance() + { + + return g_pPathBackTrackingCompassView; + } + + void PathBackTrackingCompassView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + // Add ScrollView to App + if (scrollView == nullptr) + { + scrollView = new UIScrollView(); + } + scrollView->SetPosition(0, 0); + scrollView->Resize(466, 466); + scrollView->SetViewId("scrollView"); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + container_->Add(scrollView); + scrollView->SetVisible(true); + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(173, 52); + label1_->Resize(120, 35); + label1_->SetViewId("label1"); + label1_->SetStyle(STYLE_TEXT_FONT, 30); + label1_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label1_->SetText("路径回溯"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView->Add(label1_); + label1_->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(33, 100); + label2_->Resize(200, 60); + label2_->SetViewId("label2"); + label2_->SetStyle(STYLE_TEXT_FONT, 30); + label2_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + char buf[120] = {0}; + int num = 66; + sprintf(buf, "标志点距离当前位置直线距离\n约%dKM,是否开始回溯", num); + label2_->SetText(buf); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView->Add(label2_); + label2_->SetVisible(true); + + // Add LabelButtonExt to App + if (labelButton1 == nullptr) + { + labelButton1 = new UILabelButtonExt(); + } + labelButton1->SetPosition(118, 226); + labelButton1->Resize(230, 80); + labelButton1->SetViewId(PATH_BACKTRACKING_LABELBUTTON1_VIEWID); + labelButton1->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + labelButton1->SetStyle(STYLE_BORDER_RADIUS, 100); + + // Set additional property + labelButton1->SetText("开始回溯"); + labelButton1->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); + labelButton1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + labelButton1->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + labelButton1->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED); + // Add the CallBack about events + labelButton1Click = static_cast(PathBackTrackingCompassPresenter::GetInstance()); + labelButton1->SetOnClickListener(labelButton1Click); + // Add to scrollView1 + scrollView->Add(labelButton1); + labelButton1->SetVisible(true); + + // Add LabelButtonExt to App + if (labelButton2 == nullptr) + { + labelButton2 = new UILabelButtonExt(); + } + labelButton2->SetPosition(118, 333); + labelButton2->Resize(230, 80); + labelButton2->SetViewId(PATH_BACKTRACKING_LABELBUTTON2_VIEWID); + labelButton2->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + labelButton2->SetStyle(STYLE_BORDER_RADIUS, 100); + + // Set additional property + labelButton2->SetText("暂不"); + labelButton2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + labelButton2->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + labelButton2->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED); + // Add the CallBack about events + labelButton2Click = static_cast(PathBackTrackingCompassPresenter::GetInstance()); + labelButton2->SetOnClickListener(labelButton2Click); + // Add to scrollView1 + scrollView->Add(labelButton2); + labelButton2->SetVisible(true); + } + + void PathBackTrackingCompassView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView != nullptr) + { + delete scrollView; + scrollView = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (labelButton2 != nullptr) + { + delete labelButton2; + labelButton2 = nullptr; + } + if (labelButton1 != nullptr) + { + delete labelButton1; + labelButton1 = nullptr; + } + if (labelButton1Click != nullptr) + { + delete labelButton1Click; + labelButton1Click = nullptr; + } + if (labelButton2Click != nullptr) + { + delete labelButton2Click; + labelButton2Click = nullptr; + } + } + + void PathBackTrackingCompassView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void PathBackTrackingCompassView::OnSetUpView() + { + View::OnSetUpView(); + Draw(); + } + + void PathBackTrackingCompassView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void PathBackTrackingCompassView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/PathRetracingCompassPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/PathRetracingCompassPresenter.cpp new file mode 100644 index 000000000..a8b0009a6 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/PathRetracingCompassPresenter.cpp @@ -0,0 +1,85 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "PathRetracingCompassPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static PathRetracingCompassPresenter *g_pPathRetracingCompassPresenter = nullptr; + + PathRetracingCompassPresenter::PathRetracingCompassPresenter() + { + + g_pPathRetracingCompassPresenter = this; + } + + PathRetracingCompassPresenter::~PathRetracingCompassPresenter() + { + + g_pPathRetracingCompassPresenter = nullptr; + } + + PathRetracingCompassPresenter *PathRetracingCompassPresenter::GetInstance() + { + + return g_pPathRetracingCompassPresenter; + } + + void PathRetracingCompassPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void PathRetracingCompassPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void PathRetracingCompassPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void PathRetracingCompassPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + //获取当前的位置和标记点的距离 + double PathRetracingCompassPresenter::GetCurrentToEndDistance(void) + { + //double distance = XXX();//获取距离的函数 + return 0; + } + bool PathRetracingCompassPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + UNUSED(event); + return true; + } + + bool PathRetracingCompassPresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), PATH_RETRACING_LABELBUTTON_VIEWID) == 0) //点击结束回溯按钮后会判断当前位置和标记点距离 + { + printf("path retracing labelbutton being click\n"); + if(1) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS_END_BACK_TRACKING_EARLY); + } + else + { + NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS_END_BACK_TRACKING); + } + } + return true; + } + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/PathRetracingCompassView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/PathRetracingCompassView.cpp new file mode 100644 index 000000000..1c7b09032 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/PathRetracingCompassView.cpp @@ -0,0 +1,189 @@ +#include "PathRetracingCompassView.h" +#include "PathRetracingCompassPresenter.h" +#include "UiConfig.h" + +namespace OHOS +{ + + static PathRetracingCompassView *g_pPathRetracingCompassView{nullptr}; + + PathRetracingCompassView::PathRetracingCompassView() + { + g_pPathRetracingCompassView = this; + } + + PathRetracingCompassView::~PathRetracingCompassView() + { + DeInitView(); + g_pPathRetracingCompassView = nullptr; + } + + PathRetracingCompassView *PathRetracingCompassView::GetInstance() + { + return g_pPathRetracingCompassView; + } + + void PathRetracingCompassView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + container_->SetTouchable(true); + } + // Add ScrollView to App + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); + scrollView1_->Resize(466, 466); + scrollView1_->SetViewId("scrollView"); + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(158, 52); + label1_->Resize(150, 35); + label1_->SetViewId("label1"); + label1_->SetStyle(STYLE_TEXT_FONT, 30); + label1_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label1_->SetText("路径回溯中"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label1_); + label1_->SetVisible(true); + + // Add ImageView to App + if (image2_ == nullptr) + { + image2_ = new UIImageView(); + } + image2_->SetPosition(315, 227); + image2_->Resize(47, 58); + image2_->SetViewId("image2"); + image2_->SetSrc(PNG_COMPASS_PLACE_MARKER_BUTTON_IMAGE); + + // Add to scrollView1 + scrollView1_->Add(image2_); + image2_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(110, 267); + image1_->Resize(40, 46); + image1_->SetViewId("image1"); + image1_->SetSrc(PNG_COMPASS_PATH_BACKTRACKING_DIRECT_IMAGE); + + // Add to scrollView1 + scrollView1_->Add(image1_); + image1_->SetVisible(true); + + // Add LabelButtonExt to App + if (PATH_RETRACING_LABELBUTTON == nullptr) + { + PATH_RETRACING_LABELBUTTON = new UILabelButtonExt(); + } + PATH_RETRACING_LABELBUTTON->SetPosition(118, 345); + PATH_RETRACING_LABELBUTTON->Resize(230, 80); + PATH_RETRACING_LABELBUTTON->SetViewId(PATH_RETRACING_LABELBUTTON_VIEWID); + PATH_RETRACING_LABELBUTTON->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + PATH_RETRACING_LABELBUTTON->SetStyle(STYLE_BORDER_RADIUS, 100); + // Set additional property + PATH_RETRACING_LABELBUTTON->SetText("结束回溯"); + PATH_RETRACING_LABELBUTTON->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); + PATH_RETRACING_LABELBUTTON->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + PATH_RETRACING_LABELBUTTON->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + PATH_RETRACING_LABELBUTTON->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED); + // Add the CallBack about events + PATH_RETRACING_LABELBUTTON_CLICK = static_cast(PathRetracingCompassPresenter::GetInstance()); + PATH_RETRACING_LABELBUTTON->SetOnClickListener(PATH_RETRACING_LABELBUTTON_CLICK); + // Add to scrollView1 + scrollView1_->Add(PATH_RETRACING_LABELBUTTON); + PATH_RETRACING_LABELBUTTON->SetVisible(true); + } + + void PathRetracingCompassView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (image2_ != nullptr) + { + delete image2_; + image2_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (PATH_RETRACING_LABELBUTTON != nullptr) + { + delete PATH_RETRACING_LABELBUTTON; + PATH_RETRACING_LABELBUTTON = nullptr; + } + if (PATH_RETRACING_LABELBUTTON_CLICK != nullptr) + { + delete PATH_RETRACING_LABELBUTTON_CLICK; + PATH_RETRACING_LABELBUTTON_CLICK = nullptr; + } + } + + void PathRetracingCompassView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void PathRetracingCompassView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void PathRetracingCompassView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void PathRetracingCompassView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/PlaceMakerCompassPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/PlaceMakerCompassPresenter.cpp new file mode 100644 index 000000000..3df3ae8c9 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/PlaceMakerCompassPresenter.cpp @@ -0,0 +1,98 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "PlaceMakerCompassPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static PlaceMakerCompassPresenter *g_pPlaceMakerCompassPresenter = nullptr; + + PlaceMakerCompassPresenter::PlaceMakerCompassPresenter() + { + + g_pPlaceMakerCompassPresenter = this; + } + + PlaceMakerCompassPresenter::~PlaceMakerCompassPresenter() + { + + g_pPlaceMakerCompassPresenter = nullptr; + } + + PlaceMakerCompassPresenter *PlaceMakerCompassPresenter::GetInstance() + { + + return g_pPlaceMakerCompassPresenter; + } + + void PlaceMakerCompassPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void PlaceMakerCompassPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void PlaceMakerCompassPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void PlaceMakerCompassPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + //获取GPS的连接状态 + bool PlaceMakerCompassPresenter::GetGPSConnectStatus(void) + { + //获取GPS的连接状态XXX函数 + return true; + } + + bool PlaceMakerCompassPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS); + } + return true; + } + + bool PlaceMakerCompassPresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), PLACE_MAKER_BUTTON1_VIEWID) == 0) //标记点介绍的按钮 + { + printf("place maker button1 being clicked\n"); + NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS_MAKER_POINT); + return true; + } + else if (strcmp(view.GetViewId(), PLACE_MAKER_BUTTON2_VIEWID) == 0) //开始路径记录的按钮 + { + printf("place maker button2 being clicked\n"); + if(GetGPSConnectStatus() == true) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS_START_PATH_RECORD); + } + else + { + NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS_GPS_LOSS); + } + return true; + } + return false; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/PlaceMakerCompassView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/PlaceMakerCompassView.cpp new file mode 100644 index 000000000..403d064e9 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/PlaceMakerCompassView.cpp @@ -0,0 +1,161 @@ +#include "PlaceMakerCompassView.h" +#include "PlaceMakerCompassPresenter.h" +#include "UiConfig.h" + +namespace OHOS +{ + + static PlaceMakerCompassView *g_pPlaceMakerCompassView{nullptr}; + + PlaceMakerCompassView::PlaceMakerCompassView() + { + + g_pPlaceMakerCompassView = this; + } + + PlaceMakerCompassView::~PlaceMakerCompassView() + { + DeInitView(); + g_pPlaceMakerCompassView = nullptr; + } + + PlaceMakerCompassView *PlaceMakerCompassView::GetInstance() + { + + return g_pPlaceMakerCompassView; + } + + void PlaceMakerCompassView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + draglistener = static_cast(PlaceMakerCompassPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + container_->SetTouchable(true); + container_->SetDraggable(true); + } + if (PLACE_MAKER_BACKGROUND_IMAGE == nullptr) + { + PLACE_MAKER_BACKGROUND_IMAGE = new UIImageView(); + } + PLACE_MAKER_BACKGROUND_IMAGE->SetPosition(0, 0); + PLACE_MAKER_BACKGROUND_IMAGE->Resize(466, 466); + PLACE_MAKER_BACKGROUND_IMAGE->SetSrc(PNG_COMPASS_PLACE_MAKER_BACKGROUND_IMAGE); + container_->Add(PLACE_MAKER_BACKGROUND_IMAGE); + PLACE_MAKER_BACKGROUND_IMAGE->SetVisible(true); + + if (PLACE_MAKER_BUTTON1 == nullptr) + { + PLACE_MAKER_BUTTON1 = new UIButton(); + } + PLACE_MAKER_BUTTON1->SetPosition(294, 51); + PLACE_MAKER_BUTTON1->Resize(40, 40); + PLACE_MAKER_BUTTON1->SetViewId(PLACE_MAKER_BUTTON1_VIEWID); + PLACE_MAKER_BUTTON1->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + PLACE_MAKER_BUTTON1->SetStyle(STYLE_BORDER_OPA, 0x00); + PLACE_MAKER_BUTTON1->SetStyle(STYLE_BORDER_COLOR, 0xffffffff); + PLACE_MAKER_BUTTON1->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + PLACE_MAKER_BUTTON1->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + PLACE_MAKER_BUTTON1->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + button1Click = static_cast(PlaceMakerCompassPresenter::GetInstance()); + PLACE_MAKER_BUTTON1->SetOnClickListener(button1Click); + container_->Add(PLACE_MAKER_BUTTON1); + PLACE_MAKER_BUTTON1->SetVisible(true); + + // Add Button to App + if (PLACE_MAKER_BUTTON2 == nullptr) + { + PLACE_MAKER_BUTTON2 = new UIButton(); + } + PLACE_MAKER_BUTTON2->SetPosition(118, 366); + PLACE_MAKER_BUTTON2->Resize(230, 80); + PLACE_MAKER_BUTTON2->SetViewId(PLACE_MAKER_BUTTON2_VIEWID); + PLACE_MAKER_BUTTON2->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + PLACE_MAKER_BUTTON2->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + PLACE_MAKER_BUTTON2->SetStyle(STYLE_BORDER_RADIUS, 100); + PLACE_MAKER_BUTTON2->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + PLACE_MAKER_BUTTON2->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + PLACE_MAKER_BUTTON2->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + PLACE_MAKER_BUTTON2->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED); + button2Click = static_cast(PlaceMakerCompassPresenter::GetInstance()); + PLACE_MAKER_BUTTON2->SetOnClickListener(button2Click); + container_->Add(PLACE_MAKER_BUTTON2); + PLACE_MAKER_BUTTON2->SetVisible(true); + } + + void PlaceMakerCompassView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (PLACE_MAKER_BACKGROUND_IMAGE != nullptr) + { + delete PLACE_MAKER_BACKGROUND_IMAGE; + PLACE_MAKER_BACKGROUND_IMAGE = nullptr; + } + if (PLACE_MAKER_BUTTON1 != nullptr) + { + delete PLACE_MAKER_BUTTON1; + PLACE_MAKER_BUTTON1 = nullptr; + } + if (PLACE_MAKER_BUTTON2 != nullptr) + { + delete PLACE_MAKER_BUTTON2; + PLACE_MAKER_BUTTON2 = nullptr; + } + if (button1Click != nullptr) + { + delete button1Click; + button1Click = nullptr; + } + if (button2Click != nullptr) + { + delete button2Click; + button2Click = nullptr; + } + if (draglistener != nullptr) + { + delete draglistener; + draglistener = nullptr; + } + } + + void PlaceMakerCompassView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void PlaceMakerCompassView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void PlaceMakerCompassView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void PlaceMakerCompassView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/ResetPlaceMakerCompassPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/ResetPlaceMakerCompassPresenter.cpp new file mode 100644 index 000000000..019177022 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/ResetPlaceMakerCompassPresenter.cpp @@ -0,0 +1,74 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "ResetPlaceMakerCompassPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static ResetPlaceMakerCompassPresenter *g_pResetPlaceMakerCompassPresenter = nullptr; + + ResetPlaceMakerCompassPresenter::ResetPlaceMakerCompassPresenter() + { + + g_pResetPlaceMakerCompassPresenter = this; + } + + ResetPlaceMakerCompassPresenter::~ResetPlaceMakerCompassPresenter() + { + + g_pResetPlaceMakerCompassPresenter = nullptr; + } + + ResetPlaceMakerCompassPresenter *ResetPlaceMakerCompassPresenter::GetInstance() + { + + return g_pResetPlaceMakerCompassPresenter; + } + + void ResetPlaceMakerCompassPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void ResetPlaceMakerCompassPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void ResetPlaceMakerCompassPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void ResetPlaceMakerCompassPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool ResetPlaceMakerCompassPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + UNUSED(event); + return true; + } + + bool ResetPlaceMakerCompassPresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), RESET_PLACE_MAKER_BUTTON1_VIEWID) == 0) //点击按钮1会覆盖之前的标记点跳转到开始路径记录视图重新记录 + { + NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS_START_PATH_RECORD); + } + else if (strcmp(view.GetViewId(), RESET_PLACE_MAKER_BUTTON2_VIEWID) == 0) //取消覆盖按钮 + { + NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/ResetPlaceMakerCompassView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/ResetPlaceMakerCompassView.cpp new file mode 100644 index 000000000..7abb9f428 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/ResetPlaceMakerCompassView.cpp @@ -0,0 +1,188 @@ +#include "ResetPlaceMakerCompassView.h" +#include "ResetPlaceMakerCompassPresenter.h" +#include "UiConfig.h" + +namespace OHOS +{ + + static ResetPlaceMakerCompassView *g_pResetPlaceMakerCompassView{nullptr}; + + ResetPlaceMakerCompassView::ResetPlaceMakerCompassView() + { + + g_pResetPlaceMakerCompassView = this; + } + + ResetPlaceMakerCompassView::~ResetPlaceMakerCompassView() + { + DeInitView(); + g_pResetPlaceMakerCompassView = nullptr; + } + + ResetPlaceMakerCompassView *ResetPlaceMakerCompassView::GetInstance() + { + + return g_pResetPlaceMakerCompassView; + } + + void ResetPlaceMakerCompassView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + container_->SetTouchable(true); + } + // Add ScrollView to App + if (scrollView == nullptr) + { + scrollView = new UIScrollView(); + } + scrollView->SetPosition(0, 0); + scrollView->Resize(466, 466); + scrollView->SetViewId("scrollView"); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + container_->Add(scrollView); + scrollView->SetVisible(true); + + // Add ImageView to App + if (COMPASS_RESET_PLACE_MAKER_BACKGROUND_IMAGE == nullptr) + { + COMPASS_RESET_PLACE_MAKER_BACKGROUND_IMAGE = new UIImageView(); + } + COMPASS_RESET_PLACE_MAKER_BACKGROUND_IMAGE->SetPosition(0, 0); + COMPASS_RESET_PLACE_MAKER_BACKGROUND_IMAGE->Resize(466, 466); + COMPASS_RESET_PLACE_MAKER_BACKGROUND_IMAGE->SetViewId("COMPASS_RESET_PLACE_MAKER_BACKGROUND_IMAGE"); + COMPASS_RESET_PLACE_MAKER_BACKGROUND_IMAGE->SetSrc(PNG_COMPASS_RESET_PLACE_MAKER_BACKGROUND_IMAGE); + // Add to scrollView1 + scrollView->Add(COMPASS_RESET_PLACE_MAKER_BACKGROUND_IMAGE); + COMPASS_RESET_PLACE_MAKER_BACKGROUND_IMAGE->SetVisible(true); + + // Add Button to App + if (RESET_PLACE_MAKER_BUTTON1 == nullptr) + { + RESET_PLACE_MAKER_BUTTON1 = new UIButton(); + } + RESET_PLACE_MAKER_BUTTON1->SetPosition(118, 334); + RESET_PLACE_MAKER_BUTTON1->Resize(230, 80); + RESET_PLACE_MAKER_BUTTON1->SetViewId(RESET_PLACE_MAKER_BUTTON1_VIEWID); + RESET_PLACE_MAKER_BUTTON1->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + RESET_PLACE_MAKER_BUTTON1->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + // Set additional property + RESET_PLACE_MAKER_BUTTON1->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xfffdfdfd, UIButton::PRESSED); + RESET_PLACE_MAKER_BUTTON1->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + RESET_PLACE_MAKER_BUTTON1->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + // Add the CallBack about events + RESET_PLACE_MAKER_BUTTON1Click = static_cast(ResetPlaceMakerCompassPresenter::GetInstance()); + RESET_PLACE_MAKER_BUTTON1->SetOnClickListener(RESET_PLACE_MAKER_BUTTON1Click); + // Add to scrollView1 + scrollView->Add(RESET_PLACE_MAKER_BUTTON1); + RESET_PLACE_MAKER_BUTTON1->SetVisible(true); + + // Add Button to App + if (RESET_PLACE_MAKER_BUTTON2 == nullptr) + { + RESET_PLACE_MAKER_BUTTON2 = new UIButton(); + } + RESET_PLACE_MAKER_BUTTON2->SetPosition(118, 440); + RESET_PLACE_MAKER_BUTTON2->Resize(230, 80); + RESET_PLACE_MAKER_BUTTON2->SetViewId(RESET_PLACE_MAKER_BUTTON2_VIEWID); + RESET_PLACE_MAKER_BUTTON2->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + RESET_PLACE_MAKER_BUTTON2->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + // Set additional property + RESET_PLACE_MAKER_BUTTON2->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xfffdfdfd, UIButton::PRESSED); + RESET_PLACE_MAKER_BUTTON2->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + RESET_PLACE_MAKER_BUTTON2->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + // Add the CallBack about events + RESET_PLACE_MAKER_BUTTON2Click = static_cast(ResetPlaceMakerCompassPresenter::GetInstance()); + RESET_PLACE_MAKER_BUTTON2->SetOnClickListener(RESET_PLACE_MAKER_BUTTON2Click); + // Add to scrollView1 + scrollView->Add(RESET_PLACE_MAKER_BUTTON2); + RESET_PLACE_MAKER_BUTTON2->SetVisible(true); + + if (image == nullptr) + { + image = new UIImageView(); + } + image->SetPosition(12, 472); + image->Resize(100, 100); + image->SetViewId("image2"); + scrollView->Add(image); + image->SetVisible(true); + } + + void ResetPlaceMakerCompassView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView != nullptr) + { + delete scrollView; + scrollView = nullptr; + } + if (COMPASS_RESET_PLACE_MAKER_BACKGROUND_IMAGE != nullptr) + { + delete COMPASS_RESET_PLACE_MAKER_BACKGROUND_IMAGE; + COMPASS_RESET_PLACE_MAKER_BACKGROUND_IMAGE = nullptr; + } + if (image != nullptr) + { + delete image; + image = nullptr; + } + if (RESET_PLACE_MAKER_BUTTON1 != nullptr) + { + delete RESET_PLACE_MAKER_BUTTON1; + RESET_PLACE_MAKER_BUTTON1 = nullptr; + } + if (RESET_PLACE_MAKER_BUTTON2 != nullptr) + { + delete RESET_PLACE_MAKER_BUTTON2; + RESET_PLACE_MAKER_BUTTON2 = nullptr; + } + if (RESET_PLACE_MAKER_BUTTON1Click != nullptr) + { + delete RESET_PLACE_MAKER_BUTTON1Click; + RESET_PLACE_MAKER_BUTTON1Click = nullptr; + } + if (RESET_PLACE_MAKER_BUTTON2Click != nullptr) + { + delete RESET_PLACE_MAKER_BUTTON2Click; + RESET_PLACE_MAKER_BUTTON2Click = nullptr; + } + } + + void ResetPlaceMakerCompassView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void ResetPlaceMakerCompassView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void ResetPlaceMakerCompassView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void ResetPlaceMakerCompassView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/StartPathRecordCompassPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/StartPathRecordCompassPresenter.cpp new file mode 100644 index 000000000..5d8120bc3 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/StartPathRecordCompassPresenter.cpp @@ -0,0 +1,88 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "StartPathRecordCompassPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static StartPathRecordCompassPresenter *g_pStartPathRecordCompassPresenter = nullptr; + + StartPathRecordCompassPresenter::StartPathRecordCompassPresenter() + { + + g_pStartPathRecordCompassPresenter = this; + } + + StartPathRecordCompassPresenter::~StartPathRecordCompassPresenter() + { + + g_pStartPathRecordCompassPresenter = nullptr; + } + + StartPathRecordCompassPresenter *StartPathRecordCompassPresenter::GetInstance() + { + + return g_pStartPathRecordCompassPresenter; + } + + void StartPathRecordCompassPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void StartPathRecordCompassPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void StartPathRecordCompassPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void StartPathRecordCompassPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + // 获取GPS的连接状态 + bool StartPathRecordCompassPresenter::GetGPSConnectStatus(void) + { + // if (XXX() == false) + // { + // NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS_GPS_LOSS); //若GPS信号丢失则跳转该视图 + // return true; + // } + return true; + } + // 记录路径线:UICanvas是一个画线的类 + UICanvas *StartPathRecordCompassPresenter::RecordingPath(UIView &view) + { + // 如果GPS信号良好且没有点击停止记录按钮则进行路径绘制 + while ((GetGPSConnectStatus() == true) && (strcmp(view.GetViewId(), COMPASS_START_PATH_RECORD_BUTTON_VIEWID) != 0)) + { + } + return nullptr; + } + bool StartPathRecordCompassPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + UNUSED(event); + return true; + } + + bool StartPathRecordCompassPresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), COMPASS_START_PATH_RECORD_BUTTON_VIEWID) == 0) // 路径记录过程中如果点击该按钮会停止记录 + { + NativeAbility::GetInstance().ChangeSlice(VIEW_COMPASS_END_PATH_RECORD); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/compass/src/StartPathRecordCompassView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/StartPathRecordCompassView.cpp new file mode 100644 index 000000000..e8f43a9a0 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/compass/src/StartPathRecordCompassView.cpp @@ -0,0 +1,121 @@ +#include "StartPathRecordCompassView.h" +#include "StartPathRecordCompassPresenter.h" + +#include "UiConfig.h" + +namespace OHOS +{ + + static StartPathRecordCompassView *g_pStartPathRecordCompassView{nullptr}; + + StartPathRecordCompassView::StartPathRecordCompassView() + { + + g_pStartPathRecordCompassView = this; + } + + StartPathRecordCompassView::~StartPathRecordCompassView() + { + DeInitView(); + g_pStartPathRecordCompassView = nullptr; + } + + StartPathRecordCompassView *StartPathRecordCompassView::GetInstance() + { + + return g_pStartPathRecordCompassView; + } + + void StartPathRecordCompassView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + container_->SetTouchable(true); + } + if (COMPASS_START_PATH_RECORD_IMAGE == nullptr) + { + COMPASS_START_PATH_RECORD_IMAGE = new UIImageView(); + } + COMPASS_START_PATH_RECORD_IMAGE->SetPosition(0, 0); + COMPASS_START_PATH_RECORD_IMAGE->Resize(466, 466); + COMPASS_START_PATH_RECORD_IMAGE->SetSrc(PNG_COMPASS_START_PATH_RECORD_IMAGE); + container_->Add(COMPASS_START_PATH_RECORD_IMAGE); + COMPASS_START_PATH_RECORD_IMAGE->SetVisible(true); + // Add Button to App + if (COMPASS_START_PATH_RECORD_BUTTON == nullptr) + { + COMPASS_START_PATH_RECORD_BUTTON = new UIButton(); + } + COMPASS_START_PATH_RECORD_BUTTON->SetPosition(118, 345); + COMPASS_START_PATH_RECORD_BUTTON->Resize(230, 80); + COMPASS_START_PATH_RECORD_BUTTON->SetViewId(COMPASS_START_PATH_RECORD_BUTTON_VIEWID); + COMPASS_START_PATH_RECORD_BUTTON->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + COMPASS_START_PATH_RECORD_BUTTON->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + COMPASS_START_PATH_RECORD_BUTTON->SetStyle(STYLE_BORDER_RADIUS, 100); + + // Set additional property + COMPASS_START_PATH_RECORD_BUTTON->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + COMPASS_START_PATH_RECORD_BUTTON->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + COMPASS_START_PATH_RECORD_BUTTON->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + COMPASS_START_PATH_RECORD_BUTTON->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *buttonClick = static_cast(StartPathRecordCompassPresenter::GetInstance()); + COMPASS_START_PATH_RECORD_BUTTON->SetOnClickListener(buttonClick); + // Add to rootView + container_->Add(COMPASS_START_PATH_RECORD_BUTTON); + COMPASS_START_PATH_RECORD_BUTTON->SetVisible(true); + } + + void StartPathRecordCompassView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (COMPASS_START_PATH_RECORD_IMAGE != nullptr) + { + delete COMPASS_START_PATH_RECORD_IMAGE; + COMPASS_START_PATH_RECORD_IMAGE = nullptr; + } + if (COMPASS_START_PATH_RECORD_BUTTON != nullptr) + { + delete COMPASS_START_PATH_RECORD_BUTTON; + COMPASS_START_PATH_RECORD_BUTTON = nullptr; + } + } + + void StartPathRecordCompassView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void StartPathRecordCompassView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void StartPathRecordCompassView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void StartPathRecordCompassView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialPresenter.h new file mode 100644 index 000000000..47de7bc13 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialPresenter.h @@ -0,0 +1,33 @@ +#ifndef _Dial_PRESENTER_H +#define _Dial_PRESENTER_H + +#include "Presenter.h" +#include "DialView.h" + +namespace OHOS +{ + class DialView; + + class DialPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + DialPresenter(); + virtual ~DialPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static DialPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialSetupView.h b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialSetupView.h new file mode 100644 index 000000000..c02549e66 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialSetupView.h @@ -0,0 +1,45 @@ +#ifndef _DIALSETUP_VIEW_H +#define _DIALSETUP_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" + +// #include "DialSetupPresenter.h" +namespace OHOS +{ + class DialSetupPresenter; + class DialSetupView : public View + { + + public: + DialSetupView(); + virtual ~DialSetupView(); + static DialSetupView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + // 以下控件属性通过new实例化后,add到对应root属性上; + DialSetupView(DialSetupView &&) = delete; + DialSetupView &operator=(DialSetupView &&) = delete; + + UIViewGroup *container_ = nullptr; + UILabel *label1_ = nullptr; + UIImageView *image2_ = nullptr; + UILabel *label2_ = nullptr; + UIImageView *image1_ = nullptr; + }; +} // namespace OHOS +#endif // DialSetup_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialSuccesView.h b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialSuccesView.h new file mode 100644 index 000000000..7992af112 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialSuccesView.h @@ -0,0 +1,44 @@ +#ifndef _DIALSUCCES_VIEW_H +#define _DIALSUCCES_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" + +// #include "DialSuccesPresenter.h" +namespace OHOS +{ + class DialSuccesPresenter; + class DialSuccesView : public View + { + + public: + DialSuccesView(); + virtual ~DialSuccesView(); + static DialSuccesView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + // 以下控件属性通过new实例化后,add到对应root属性上; + DialSuccesView(DialSuccesView &&) = delete; + DialSuccesView &operator=(DialSuccesView &&) = delete; + + UIViewGroup *container_ = nullptr; + UILabel *label1_ = nullptr; + UIImageView *image1_ = nullptr; + UILabel *label2_ = nullptr; + }; +} // namespace OHOS +#endif // DialSucces_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialView.h b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialView.h new file mode 100644 index 000000000..fec58e502 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialView.h @@ -0,0 +1,50 @@ +#ifndef _Dial_VIEW_H +#define _Dial_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_image_animator.h" +#include "components/ui_label_button_ext.h" + +#include "DialPresenter.h" +namespace OHOS +{ + + class DialPresenter; + class DialView : public View + { + + public: + DialView(); + virtual ~DialView(); + static DialView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + DialView(DialView &&) = delete; + DialView &operator=(DialView &&) = delete; + + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UIButton *button3_ = nullptr; + UIImageView *image2_ = nullptr; + UIButton *button2_ = nullptr; + UIImageView *image1_ = nullptr; + UIButton *button1_ = nullptr; + }; +} // namespace OHOS +#endif // Dial_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/src/DiaLsetupView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/DiaLsetupView.cpp new file mode 100644 index 000000000..55b98b7ad --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/DiaLsetupView.cpp @@ -0,0 +1,171 @@ +#include "dial/include/DialSetupView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + + static DialSetupView *g_pDialSetupView{nullptr}; + + DialSetupView::DialSetupView() + { + + g_pDialSetupView = this; + } + + DialSetupView::~DialSetupView() + { + DeInit(); + g_pDialSetupView = nullptr; + } + + DialSetupView *DialSetupView::GetInstance() + { + + return g_pDialSetupView; + } + void DialSetupView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(158, 52); // widget's left position and top position + label1_->Resize(150, 35); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label1_->SetText("表盘安装中"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label1_); + label1_->SetVisible(true); + + // Add ImageView to App + if (image2_ == nullptr) + { + image2_ = new UIImageView(); + } + image2_->SetPosition(183, 136); // widget's left position and top position + image2_->Resize(100, 110); // widget's width and height + image2_->SetViewId("Steup"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image2imagesPath = "c:/Users/caiking/project/image_converter_tool/output/DialSetup/setup.bin"; +#else + char *image2imagesPath = "/user/res/Dial/setup.bin"; +#endif + image2_->SetSrc(image2imagesPath); + + // Add to rootView + container_->Add(image2_); + image2_->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(68, 280); // widget's left position and top position + label2_->Resize(400, 124); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label2_->SetText("正在安装表盘,请不要做\n其他操作或关闭手表"); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label2_); + label2_->SetVisible(true); + } + + void DialSetupView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (image2_ != nullptr) + { + delete image2_; + image2_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + } + + UIView *DialSetupView::GetView() + { + Init(); + return container_; + } + void DialSetupView::OnStart() + { + container_ = new UIViewGroup(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void DialSetupView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void DialSetupView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void DialSetupView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/src/DialPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/DialPresenter.cpp new file mode 100644 index 000000000..4b0d67871 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/DialPresenter.cpp @@ -0,0 +1,76 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "dial/include/DialPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static DialPresenter *g_pDialPresenter = nullptr; + + DialPresenter::DialPresenter() + { + + g_pDialPresenter = this; + } + + DialPresenter::~DialPresenter() + { + + g_pDialPresenter = nullptr; + } + + DialPresenter *DialPresenter::GetInstance() + { + + return g_pDialPresenter; + } + + void DialPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void DialPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void DialPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void DialPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool DialPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) + { + printf("draglistene is ok!\n"); + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE); + } + UNUSED(view); + return true; + } + + bool DialPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // // 根据控件id查找是哪个控件触发了点击回调 + // if (strcmp(view.GetViewId(), "labelButton1") == 0) + // { + // NativeAbility::GetInstance().ChangeSlice(VIEW_BLOOD); + // } + + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/src/DialSucces.cpp b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/DialSucces.cpp new file mode 100644 index 000000000..1ed8312a9 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/DialSucces.cpp @@ -0,0 +1,171 @@ +#include "dial/include/DialSuccesView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + + static DialSuccesView *g_pDialSuccesView{nullptr}; + + DialSuccesView::DialSuccesView() + { + + g_pDialSuccesView = this; + } + + DialSuccesView::~DialSuccesView() + { + DeInit(); + g_pDialSuccesView = nullptr; + } + + DialSuccesView *DialSuccesView::GetInstance() + { + + return g_pDialSuccesView; + } + void DialSuccesView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(173, 52); // widget's left position and top position + label1_->Resize(220, 35); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label1_->SetText("安装成功"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label1_); + label1_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(193, 150); // widget's left position and top position + image1_->Resize(100, 100); // widget's width and height + image1_->SetViewId("success"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/DialSucces/Vector.bin"; +#else + char *image1imagesPath = "/user/res/Dial/Vector.bin"; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to rootView + container_->Add(image1_); + image1_->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(83, 293); // widget's left position and top position + label2_->Resize(200, 60); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label2_->SetText("表盘安装成功\n正在更新表盘,请稍等"); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label2_); + label2_->SetVisible(true); + } + + void DialSuccesView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + } + + UIView *DialSuccesView::GetView() + { + Init(); + return container_; + } + void DialSuccesView::OnStart() + { + container_ = new UIViewGroup(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void DialSuccesView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void DialSuccesView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void DialSuccesView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/src/DialView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/DialView.cpp new file mode 100644 index 000000000..8226cc92f --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/DialView.cpp @@ -0,0 +1,265 @@ + + +#include "dial/include/DialView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + static DialView *g_pDialView{nullptr}; + + DialView::DialView() + { + + g_pDialView = this; + } + + DialView::~DialView() + { + DeInit(); + g_pDialView = nullptr; + } + + DialView *DialView::GetInstance() + { + + return g_pDialView; + } + void DialView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add ScrollView to App + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); // widget's left position and top position + scrollView1_->Resize(466, 466); // widget's width and height + scrollView1_->SetViewId("scrollView1"); // Set style + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // Set additional property + + // Add to rootView + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + + // Add Button to App + if (button3_ == nullptr) + { + button3_ = new UIButton(); + } + button3_->SetPosition(390, 103); // widget's left position and top position + button3_->Resize(260, 260); // widget's width and height + button3_->SetViewId("button3"); // Set style + button3_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button3_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *button3defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Dial/dog.bin"; +#else + char *button3defaultImgSrc = "/user/res/Dial/dog.bin"; +#endif + char *button3triggeredImgSrc = nullptr; + button3_->SetImageSrc(button3defaultImgSrc, button3triggeredImgSrc); + button3_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + button3_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button3Click = static_cast(DialPresenter::GetInstance()); + button3_->SetOnClickListener(button3Click); + // Add to scrollView1 + scrollView1_->Add(button3_); + button3_->SetVisible(true); + + // Add ImageView to App + if (image2_ == nullptr) + { + image2_ = new UIImageView(); + } + image2_->SetPosition(691, 172); // widget's left position and top position + image2_->Resize(100, 100); // widget's width and height + image2_->SetViewId("image2"); // Set style + + // Set additional property + + // Add to scrollView1 + scrollView1_->Add(image2_); + image2_->SetVisible(true); + + // Add Button to App + if (button2_ == nullptr) + { + button2_ = new UIButton(); + } + button2_->SetPosition(-190, 103); // widget's left position and top position + button2_->Resize(260, 260); // widget's width and height + button2_->SetViewId("button2"); // Set style + button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *button2defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Dial/Malio.bin"; +#else + char *button2defaultImgSrc = "/user/res/Dial/Malio.bin"; +#endif + char *button2triggeredImgSrc = nullptr; + button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc); + button2_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button2Click = static_cast(DialPresenter::GetInstance()); + button2_->SetOnClickListener(button2Click); + // Add to scrollView1 + scrollView1_->Add(button2_); + button2_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(-343, 183); // widget's left position and top position + image1_->Resize(100, 100); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Set additional property + + // Add to scrollView1 + scrollView1_->Add(image1_); + image1_->SetVisible(true); + + // Add Button to App + if (button1_ == nullptr) + { + button1_ = new UIButton(); + } + button1_->SetPosition(103, 103); // widget's left position and top position + button1_->Resize(260, 260); // widget's width and height + button1_->SetViewId("button1"); // Set style + button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Dial/KUMI.bin"; +#else + char *button1defaultImgSrc = "/user/res/Dial/KUMI.bin"; +#endif + char *button1triggeredImgSrc = nullptr; + button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + button1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(DialPresenter::GetInstance()); + // Add to scrollView1 + scrollView1_->Add(button1_); + button1_->SetVisible(true); + } + + void DialView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (button3_ != nullptr) + { + delete button3_; + button3_ = nullptr; + } + if (image2_ != nullptr) + { + delete image2_; + image2_ = nullptr; + } + if (button2_ != nullptr) + { + delete button2_; + button2_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + } + + UIView *DialView::GetView() + { + Init(); + return container_; + } + + void DialView::OnStart() + { + container_ = new UIScrollView(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(DialPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void DialView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void DialView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void DialView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/include/DisplayBrightnessModel.h b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/include/DisplayBrightnessModel.h new file mode 100644 index 000000000..7e7e6a6fc --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/include/DisplayBrightnessModel.h @@ -0,0 +1,9 @@ +#ifndef _DISPLAY_BRIGHTNESS_MODEL_H_ +#define _DISPLAY_BRIGHTNESS_MODEL_H_ + + + + + + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h new file mode 100644 index 000000000..574274b4a --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h @@ -0,0 +1,34 @@ +#ifndef _DISPLAY_BRIGHTNESS_PRESENTER_H +#define _DISPLAY_BRIGHTNESS_PRESENTER_H + + +#include "Presenter.h" +#include "DisplayBrightnessView.h" + +namespace OHOS +{ + class DisplayBrightnessView; + + class DisplayBrightnessPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + DisplayBrightnessPresenter(); + virtual ~DisplayBrightnessPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static DisplayBrightnessPresenter *GetInstance(); + + private: + //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} //namespace OHOS + +#endif //_DisplayBrightness_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/include/DisplayBrightnessView.h b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/include/DisplayBrightnessView.h new file mode 100644 index 000000000..3ada8a4cb --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/include/DisplayBrightnessView.h @@ -0,0 +1,50 @@ +#ifndef _DISPLAY_BRIGHTNESS_VIEW_H +#define _DISPLAY_BRIGHTNESS_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_scroll_view.h" +#include "components/ui_checkbox.h" +#include "components/ui_toggle_button.h" +#include "DisplayBrightnessPresenter.h" +namespace OHOS +{ + + class DisplayBrightnessPresenter; + class DisplayBrightnessView : public View + { + public: + DisplayBrightnessView(); + virtual ~DisplayBrightnessView(); + static DisplayBrightnessView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + UIView::OnDragListener *draglistener{nullptr}; + void Init(void); + + UIViewGroup *DisplayBrightness_container = nullptr; + UIScrollView *DisplayBrightness_scrollView = nullptr; + UIButton *ScreenDuration_Button = nullptr; + UIButton *BringhtnessControl_Button = nullptr; + UILabel *BringhtnessContuol_Label = nullptr; + UIImageView *BringhtnessContuol_Image = nullptr; + UIImageView *ScreenDuration_Image = nullptr; + UIImageView *imag =nullptr; + UIImageView *imag1 =nullptr; + UIImageView *RaiseToBrightness_Image = nullptr; + UICheckBox *RaiseToBrightness_CheckBoxButton = nullptr; + UILabel *RaiseToBrightness_Label = nullptr; + UILabel *ScreenDuration_Label = nullptr; + UILabel *DisplayBrightness_Label = nullptr; + }; +} // namespace OHOS +#endif // DisplayBrightness_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp new file mode 100644 index 000000000..5a94007f2 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp @@ -0,0 +1 @@ +#include "displaybrightness/include/DisplayBrightnessModel.h" \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp new file mode 100644 index 000000000..318009f7c --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp @@ -0,0 +1,80 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "displaybrightness/include/DisplayBrightnessPresenter.h" + +namespace OHOS +{ + // 当前Presenter属性实例化的内存指针 + static DisplayBrightnessPresenter *g_pDisplayBrightnessPresenter = nullptr; + + DisplayBrightnessPresenter::DisplayBrightnessPresenter() + { + + g_pDisplayBrightnessPresenter = this; + } + + DisplayBrightnessPresenter::~DisplayBrightnessPresenter() + { + + g_pDisplayBrightnessPresenter = nullptr; + } + + DisplayBrightnessPresenter *DisplayBrightnessPresenter::GetInstance() + { + + return g_pDisplayBrightnessPresenter; + } + + void DisplayBrightnessPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void DisplayBrightnessPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void DisplayBrightnessPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void DisplayBrightnessPresenter::OnStop(void) + { + Presenter::OnStop(); + } + + bool DisplayBrightnessPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); + return true; + } + return false; + } + + bool DisplayBrightnessPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), "BringhtnessControl_Button") == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_BRIGHTNESS_CONTROL);//亮度调节 + return true; + } + if(strcmp(view.GetViewId(), "ScreenDuration_Button") == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SCREEN_DURATION); //亮屏时长 + return true; + } + return false; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/src/DisplayBrightnessView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/src/DisplayBrightnessView.cpp new file mode 100644 index 000000000..4faa49b92 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/src/DisplayBrightnessView.cpp @@ -0,0 +1,284 @@ +#include "displaybrightness/include/DisplayBrightnessView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" + +namespace OHOS +{ + static DisplayBrightnessView *g_pDisplayBrightnessView{nullptr}; + + DisplayBrightnessView::DisplayBrightnessView() + { + + g_pDisplayBrightnessView = this; + } + + DisplayBrightnessView::~DisplayBrightnessView() + { + g_pDisplayBrightnessView = nullptr; + } + + DisplayBrightnessView *DisplayBrightnessView::GetInstance() + { + + return g_pDisplayBrightnessView; + } + + void DisplayBrightnessView::Init() + { + /***********************************************************************************************************/ + // Add ScrollView to App + if (DisplayBrightness_scrollView == nullptr) + { + DisplayBrightness_scrollView = new UIScrollView(); + } + DisplayBrightness_scrollView->SetPosition(0, 0); + DisplayBrightness_scrollView->Resize(466, 466); + DisplayBrightness_scrollView->SetViewId("DisplayBrightness_scrollView"); + DisplayBrightness_scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + DisplayBrightness_scrollView->SetVisible(true); + DisplayBrightness_scrollView->SetVerticalScrollState(true); // 设置纵向是否可滚动。 + /***********************************************************************************************************/ + if (imag1 == nullptr) + { + imag1 = new UIImageView(); + } + imag1->SetPosition(158, 0); + imag1->SetViewId("imag1"); + // Add to scrollView1 + DisplayBrightness_scrollView->Add(imag1); + // Add Label to App + if (DisplayBrightness_Label == nullptr) + { + DisplayBrightness_Label = new UILabel(); + } + DisplayBrightness_Label->SetPosition(158, 52); + DisplayBrightness_Label->Resize(150, 35); + DisplayBrightness_Label->SetViewId("DisplayBrightness_Label"); + DisplayBrightness_Label->SetStyle(STYLE_TEXT_FONT, 30); + DisplayBrightness_Label->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + DisplayBrightness_Label->SetText("显示与亮度"); + DisplayBrightness_Label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + DisplayBrightness_Label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DisplayBrightness_Label->SetRollSpeed(6); + DisplayBrightness_Label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to rootView + DisplayBrightness_scrollView->Add(DisplayBrightness_Label); + DisplayBrightness_Label->SetVisible(true); + /***********************************************************************************************************/ + // Add Button to App + if (BringhtnessControl_Button == nullptr) + { + BringhtnessControl_Button = new UIButton(); + } + BringhtnessControl_Button->SetPosition(43, 120); + BringhtnessControl_Button->Resize(380, 100); + BringhtnessControl_Button->SetViewId("BringhtnessControl_Button"); // 亮度调节按钮 + BringhtnessControl_Button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + BringhtnessControl_Button->SetImageSrc(PNG_SETTING_BACKGROUND_IMAGE, nullptr); + BringhtnessControl_Button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + BringhtnessControl_Button->SetStyleForState(STYLE_BORDER_RADIUS, 50, UIButton::PRESSED); + UIView::OnClickListener *BCButton = static_cast(DisplayBrightnessPresenter::GetInstance()); + BringhtnessControl_Button->SetOnClickListener(BCButton); + // Add to scrollView1 + DisplayBrightness_scrollView->Add(BringhtnessControl_Button); + BringhtnessControl_Button->SetVisible(true); + /***********************************************************************************************************/ + // Add Label to App + if (BringhtnessContuol_Label == nullptr) + { + BringhtnessContuol_Label = new UILabel(); + } + BringhtnessContuol_Label->SetPosition(90, 153); + BringhtnessContuol_Label->Resize(200, 60); + BringhtnessContuol_Label->SetViewId("BringhtnessContuol_Label"); + BringhtnessContuol_Label->SetStyle(STYLE_TEXT_FONT, 30); + BringhtnessContuol_Label->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + BringhtnessContuol_Label->SetText("亮度调节"); + BringhtnessContuol_Label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + BringhtnessContuol_Label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + BringhtnessContuol_Label->SetRollSpeed(6); + BringhtnessContuol_Label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView1 + DisplayBrightness_scrollView->Add(BringhtnessContuol_Label); + BringhtnessContuol_Label->SetVisible(true); + /***********************************************************************************************************/ + // Add ImageView to App + if (BringhtnessContuol_Image == nullptr) + { + BringhtnessContuol_Image = new UIImageView(); + } + BringhtnessContuol_Image->SetPosition(369, 157); + BringhtnessContuol_Image->Resize(14, 26); + BringhtnessContuol_Image->SetViewId("BringhtnessContuol_Image"); + BringhtnessContuol_Image->SetSrc(PNG_SETTING_NEXT_IMAGE); + // Add to scrollView1 + DisplayBrightness_scrollView->Add(BringhtnessContuol_Image); + BringhtnessContuol_Image->SetVisible(true); + /***********************************************************************************************************/ + // Add Button to App + if (ScreenDuration_Button == nullptr) + { + ScreenDuration_Button = new UIButton(); + } + ScreenDuration_Button->SetPosition(43, 240); + ScreenDuration_Button->Resize(380, 100); + ScreenDuration_Button->SetViewId("ScreenDuration_Button"); // 亮屏时长 + ScreenDuration_Button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + ScreenDuration_Button->SetStyle(STYLE_BORDER_RADIUS, 50); + ScreenDuration_Button->SetImageSrc(PNG_SETTING_BACKGROUND_IMAGE, nullptr); + ScreenDuration_Button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + ScreenDuration_Button->SetStyleForState(STYLE_BORDER_RADIUS, 50, UIButton::PRESSED); + UIView::OnClickListener *SDButton = static_cast(DisplayBrightnessPresenter::GetInstance()); + ScreenDuration_Button->SetOnClickListener(SDButton); + // Add to scrollView1 + DisplayBrightness_scrollView->Add(ScreenDuration_Button); + ScreenDuration_Button->SetVisible(true); + /***********************************************************************************************************/ + // Add Label to App + if (ScreenDuration_Label == nullptr) + { + ScreenDuration_Label = new UILabel(); + } + ScreenDuration_Label->SetPosition(90, 273); // widget's left position and top position + ScreenDuration_Label->Resize(200, 60); // widget's width and height + ScreenDuration_Label->SetViewId("ScreenDuration_Label"); // Set style + ScreenDuration_Label->SetStyle(STYLE_TEXT_FONT, 30); + ScreenDuration_Label->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + ScreenDuration_Label->SetText("亮屏时长"); + ScreenDuration_Label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + ScreenDuration_Label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + ScreenDuration_Label->SetRollSpeed(6); + ScreenDuration_Label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to rootView + DisplayBrightness_scrollView->Add(ScreenDuration_Label); + ScreenDuration_Label->SetVisible(true); + /***********************************************************************************************************/ + // Add ImageView to App + if (ScreenDuration_Image == nullptr) + { + ScreenDuration_Image = new UIImageView(); + } + ScreenDuration_Image->SetPosition(369, 277); + ScreenDuration_Image->Resize(14, 26); + ScreenDuration_Image->SetViewId("ScreenDuration_Image"); + // Set additional property + ScreenDuration_Image->SetSrc(PNG_SETTING_NEXT_IMAGE); + // Add to scrollView1 + DisplayBrightness_scrollView->Add(ScreenDuration_Image); + ScreenDuration_Image->SetVisible(true); + /***********************************************************************************************************/ + // Add Button to App + if (RaiseToBrightness_Image == nullptr) + { + RaiseToBrightness_Image = new UIImageView(); + } + RaiseToBrightness_Image->SetPosition(43, 360); + RaiseToBrightness_Image->Resize(380, 100); + RaiseToBrightness_Image->SetViewId("RaiseToBrightness_Image"); // 抬腕亮屏 + RaiseToBrightness_Image->SetStyle(STYLE_BORDER_RADIUS, 50); + RaiseToBrightness_Image->SetStyle(STYLE_BACKGROUND_COLOR, 0xff991199); + RaiseToBrightness_Image->SetStyle(STYLE_BACKGROUND_OPA, 0x11); + RaiseToBrightness_Image->SetSrc(PNG_SETTING_BACKGROUND_IMAGE); + // Add to scrollView + DisplayBrightness_scrollView->Add(RaiseToBrightness_Image); + RaiseToBrightness_Image->SetVisible(true); + /***********************************************************************************************************/ + // Add Label to App + if (RaiseToBrightness_Label == nullptr) + { + RaiseToBrightness_Label = new UILabel(); + } + RaiseToBrightness_Label->SetPosition(90, 393); + RaiseToBrightness_Label->Resize(200, 60); + RaiseToBrightness_Label->SetViewId("RaiseToBrightness_Label"); + RaiseToBrightness_Label->SetStyle(STYLE_TEXT_FONT, 30); + RaiseToBrightness_Label->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + RaiseToBrightness_Label->SetText("抬腕亮屏"); + RaiseToBrightness_Label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + RaiseToBrightness_Label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + RaiseToBrightness_Label->SetRollSpeed(6); + RaiseToBrightness_Label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to rootView + DisplayBrightness_scrollView->Add(RaiseToBrightness_Label); + RaiseToBrightness_Label->SetVisible(true); + /***********************************************************************************************************/ + // Add Button to App + if (RaiseToBrightness_CheckBoxButton == nullptr) + { + RaiseToBrightness_CheckBoxButton = static_cast(new UIToggleButton()); + } + RaiseToBrightness_CheckBoxButton->SetPosition(298, 385); + RaiseToBrightness_CheckBoxButton->Resize(100, 50); + RaiseToBrightness_CheckBoxButton->SetViewId("RaiseToBrightness_CheckBoxButton"); + RaiseToBrightness_CheckBoxButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE,PNG_TOGGLEBUTTON_OFF_IMAGE); + // Add to rootView + DisplayBrightness_scrollView->Add(RaiseToBrightness_CheckBoxButton); + RaiseToBrightness_CheckBoxButton->SetVisible(true); + /***********************************************************************************************************/ + if (imag == nullptr) + { + imag = new UIImageView(); + } + imag->SetPosition(183, 540); + imag->SetViewId("imag"); + // Add to scrollView1 + DisplayBrightness_scrollView->Add(imag); + } + + void DisplayBrightnessView::OnStart() + { + View::OnStart(); + // DisplayBrightness_container容器属性 new + DisplayBrightness_scrollView = new UIScrollView(); + if (DisplayBrightness_scrollView == nullptr) + { + return; + } + + // DisplayBrightness_container容器属性 扩展 + DisplayBrightness_scrollView->SetPosition(0, 0); + DisplayBrightness_scrollView->SetWidth(Screen::GetInstance().GetWidth()); + DisplayBrightness_scrollView->SetHeight(Screen::GetInstance().GetHeight()); + + draglistener = static_cast(DisplayBrightnessPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + DisplayBrightness_scrollView->SetOnDragListener(draglistener); + DisplayBrightness_scrollView->SetTouchable(true); + DisplayBrightness_scrollView->SetDraggable(true); + + Init(); + + RootView::GetInstance()->Add(DisplayBrightness_scrollView); + RootView::GetInstance()->Invalidate(); + } + + void DisplayBrightnessView::OnSetUpView() + { + View::OnSetUpView(); + Draw(); + } + + void DisplayBrightnessView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void DisplayBrightnessView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/getpic/include/GetPicPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/getpic/include/GetPicPresenter.h new file mode 100644 index 000000000..1b3535dbf --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/getpic/include/GetPicPresenter.h @@ -0,0 +1,33 @@ +#ifndef _GETPIC_PRESENTER_H +#define _GETPIC_PRESENTER_H + +#include "Presenter.h" +#include "GetPicView.h" + +namespace OHOS +{ + class GetPicView; + + class GetPicPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + GetPicPresenter(); + virtual ~GetPicPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static GetPicPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/getpic/include/GetPicView.h b/code/sdk/application/wearable/nativeapp/nativeui/getpic/include/GetPicView.h new file mode 100644 index 000000000..1abc9b470 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/getpic/include/GetPicView.h @@ -0,0 +1,45 @@ +#ifndef _GETPIC_VIEW_H +#define _GETPIC_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" + +#include "GetPicPresenter.h" +namespace OHOS +{ + class GetPicPresenter; + class GetPicView : public View + { + + public: + GetPicView(); + virtual ~GetPicView(); + static GetPicView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + // 以下控件属性通过new实例化后,add到对应root属性上; + GetPicView(GetPicView &&) = delete; + GetPicView &operator=(GetPicView &&) = delete; + + UIViewGroup *container_ = nullptr; + UILabel *label1_ = nullptr; + UIImageView *image1_ = nullptr; + UILabel *label2_ = nullptr; + UIButton *button1_ = nullptr; + }; +} // namespace OHOS +#endif // GetPic_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/getpic/include/TakePicPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/getpic/include/TakePicPresenter.h new file mode 100644 index 000000000..eec4ad31b --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/getpic/include/TakePicPresenter.h @@ -0,0 +1,33 @@ +#ifndef _TAKEPIC_PRESENTER_H +#define _TAKEPIC_PRESENTER_H + +#include "Presenter.h" +#include "TakePicView.h" + +namespace OHOS +{ + class TakePicView; + + class TakePicPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + TakePicPresenter(); + virtual ~TakePicPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static TakePicPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/getpic/include/TakePicView.h b/code/sdk/application/wearable/nativeapp/nativeui/getpic/include/TakePicView.h new file mode 100644 index 000000000..8a8d2e534 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/getpic/include/TakePicView.h @@ -0,0 +1,45 @@ +#ifndef _TAKEPIC_VIEW_H +#define _TAKEPIC_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" + +#include "TakePicPresenter.h" +namespace OHOS +{ + class TakePicPresenter; + class TakePicView : public View + { + + public: + TakePicView(); + virtual ~TakePicView(); + static TakePicView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + // 以下控件属性通过new实例化后,add到对应root属性上; + TakePicView(TakePicView &&) = delete; + TakePicView &operator=(TakePicView &&) = delete; + + UIViewGroup *container_ = nullptr; + UILabel *label1_ = nullptr; + UIImageView *image1_ = nullptr; + UILabel *label2_ = nullptr; + UILabel *label3_ = nullptr; + }; +} // namespace OHOS +#endif // TakePic_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/getpic/src/GetPicPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/getpic/src/GetPicPresenter.cpp new file mode 100644 index 000000000..fa74bf1c0 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/getpic/src/GetPicPresenter.cpp @@ -0,0 +1,74 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "getpic/include/GetPicPresenter.h" +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static GetPicPresenter *g_pGetPicPresenter = nullptr; + + GetPicPresenter::GetPicPresenter() + { + + g_pGetPicPresenter = this; + } + + GetPicPresenter::~GetPicPresenter() + { + + g_pGetPicPresenter = nullptr; + } + + GetPicPresenter *GetPicPresenter::GetInstance() + { + + return g_pGetPicPresenter; + } + + void GetPicPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void GetPicPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void GetPicPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void GetPicPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool GetPicPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + } + UNUSED(view); + return true; + } + + bool GetPicPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + // if (strcmp(view.GetViewId(), 控件ID) == 0) + if (strcmp(view.GetViewId(), "button1") == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_TAKEPIC); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/getpic/src/GetPicView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/getpic/src/GetPicView.cpp new file mode 100644 index 000000000..3e018ed65 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/getpic/src/GetPicView.cpp @@ -0,0 +1,214 @@ +#include "getpic/include/GetPicView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + + static GetPicView *g_pGetPicView{nullptr}; + + GetPicView::GetPicView() + { + + g_pGetPicView = this; + } + + GetPicView::~GetPicView() + { + DeInit(); + g_pGetPicView = nullptr; + } + + GetPicView *GetPicView::GetInstance() + { + + return g_pGetPicView; + } + void GetPicView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(173, 52); // widget's left position and top position + label1_->Resize(120, 35); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label1_->SetText("手势拍照"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label1_); + label1_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(163, 103); // widget's left position and top position + image1_->Resize(140, 140); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/GetPic/camera.bin"; +#else + char *image1imagesPath = "/user/res/GetPic/camera.bin"; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to rootView + container_->Add(image1_); + image1_->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(53, 253); // widget's left position and top position + label2_->Resize(360, 70); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label2_->SetText("请先打开小希爱玩app,进\n入“设备”-“拍照”"); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label2_); + label2_->SetVisible(true); + + // Add Button to App + if (button1_ == nullptr) + { + button1_ = new UIButton(); + } + button1_->SetPosition(0, 366); // widget's left position and top position + button1_->Resize(466, 100); // widget's width and height + button1_->SetViewId("button1"); // Set style + button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/GetPic/button.bin"; +#else + char *button1defaultImgSrc = "/user/res/GetPic/pic_button.bin"; +#endif + char *button1triggeredImgSrc = nullptr; + button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + button1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(GetPicPresenter::GetInstance()); + button1_->SetOnClickListener(button1Click); + // Add to rootView + container_->Add(button1_); + button1_->SetVisible(true); + } + + void GetPicView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + } + + UIView *GetPicView::GetView() + { + Init(); + return container_; + } + + void GetPicView::OnStart() + { + container_ = new UIScrollView(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight() * 2); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(GetPicPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void GetPicView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void GetPicView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void GetPicView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/getpic/src/TakePicPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/getpic/src/TakePicPresenter.cpp new file mode 100644 index 000000000..9e5e5ebc3 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/getpic/src/TakePicPresenter.cpp @@ -0,0 +1,75 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "getpic/include/TakePicPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static TakePicPresenter *g_pTakePicPresenter = nullptr; + + TakePicPresenter::TakePicPresenter() + { + + g_pTakePicPresenter = this; + } + + TakePicPresenter::~TakePicPresenter() + { + + g_pTakePicPresenter = nullptr; + } + + TakePicPresenter *TakePicPresenter::GetInstance() + { + + return g_pTakePicPresenter; + } + + void TakePicPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void TakePicPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void TakePicPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void TakePicPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool TakePicPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_TOP_TO_BOTTOM) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_GETPIC); + } + UNUSED(view); + return true; + } + + bool TakePicPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + // if (strcmp(view.GetViewId(), 控件ID) == 0) + // if (strcmp(view.GetViewId(), "button1") == 0) + // { + // NativeAbility::GetInstance().ChangeSlice(VIEW_SAVEBAT); + // } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/getpic/src/TakePicView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/getpic/src/TakePicView.cpp new file mode 100644 index 000000000..f6cda2b33 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/getpic/src/TakePicView.cpp @@ -0,0 +1,206 @@ +#include "getpic/include/TakePicView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + + static TakePicView *g_pTakePicView{nullptr}; + + TakePicView::TakePicView() + { + + g_pTakePicView = this; + } + + TakePicView::~TakePicView() + { + DeInit(); + g_pTakePicView = nullptr; + } + + TakePicView *TakePicView::GetInstance() + { + + return g_pTakePicView; + } + void TakePicView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(173, 52); // widget's left position and top position + label1_->Resize(120, 35); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label1_->SetText("手势拍照"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label1_); + label1_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(163, 140); // widget's left position and top position + image1_->Resize(140, 140); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/TakePic/smile.bin"; +#else + char *image1imagesPath = "/user/res/GetPic/smile.bin"; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to rootView + container_->Add(image1_); + image1_->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(128, 310); // widget's left position and top position + label2_->Resize(360, 70); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label2_->SetText("晃一晃手腕拍照"); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label2_); + label2_->SetVisible(true); + + // Add Label to App + if (label3_ == nullptr) + { + label3_ = new UILabel(); + } + label3_->SetPosition(159, 347); // widget's left position and top position + label3_->Resize(200, 60); // widget's width and height + label3_->SetViewId("label3"); // Set style + label3_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label3_->SetText("已拍摄0å¼ "); + label3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label3_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label3_->SetRollSpeed(0); + label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label3_); + label3_->SetVisible(true); + } + + void TakePicView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (label3_ != nullptr) + { + delete label3_; + label3_ = nullptr; + } + } + + UIView *TakePicView::GetView() + { + Init(); + return container_; + } + void TakePicView::OnStart() + { + container_ = new UIScrollView(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight() * 2); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(TakePicPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void TakePicView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void TakePicView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void TakePicView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainPresenterSample.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainPresenterSample.h index d0ce3ac36..62082c75b 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainPresenterSample.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainPresenterSample.h @@ -35,6 +35,7 @@ static constexpr const char *DROPDOWN_CLICK_BRIGHTENSCREEN = "dropdownclickbrigh static constexpr const char *DROPDOWN_CLICK_FINDMYPHONE = "dropdownclickfindmyphone"; static constexpr const char *DROPDOWN_CLICK_ALARM = "dropdownclickalarm"; static constexpr const char *DROPDOWN_CLICK_SETTING = "dropdownclicksetting"; +static constexpr const char *DROPDOWN_CLICK_SAVEELE = "dropdownclicksaveele"; constexpr uint16_t VERTICAL_STATUS = 1; constexpr uint16_t HORIZONTAL_STATUS = 0; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainSwipeViewGroup.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainSwipeViewGroup.h new file mode 100644 index 000000000..e636b09c6 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainSwipeViewGroup.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: MainSwipeViewGroup + * Author: + * Create: 2022-02 + */ + +#ifndef MAIN_SWIPE_VIEW_GROUP_H +#define MAIN_SWIPE_VIEW_GROUP_H + +#include "components/ui_swipe_view.h" +namespace OHOS { +class UISwipeViewApp : public UISwipeView { +public: + UISwipeViewApp(uint8_t direction = HORIZONTAL) + { + SetDirection(direction); + } + virtual ~UISwipeViewApp(){}; + bool OnDragEvent(const DragEvent& event) override; +}; + +class MainSwipeViewGroup : public UIViewGroup { +public: + MainSwipeViewGroup (); + virtual ~MainSwipeViewGroup(); + static MainSwipeViewGroup *GetInstance(void); + bool OnDragStartEvent(const DragEvent& event) override; + bool OnDragEvent(const DragEvent& event) override; + bool OnDragEndEvent(const DragEvent& event) override; + void AddSwipeView(UISwipeViewApp *view); + void AddSwipeView(UISwipeView *view); + bool MainClockPage(void); + +private: + int swipeDirect{0}; + int pullIndex{0}; + UISwipeView *vertical{nullptr}; + UISwipeViewApp *horizontal{nullptr}; + Point dragStartPos; +}; +} +#endif diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/PullUpDownView.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/PullUpDownView.h index 08d62125e..57468228b 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/PullUpDownView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/PullUpDownView.h @@ -41,7 +41,7 @@ private: UILabel *batteryLable{nullptr}; UILabel *dateLable{nullptr}; bool viewiInitStatus{false}; - + UILabel *timeLable{nullptr}; void InitSubViewImg(void); void InitViewImg(void); void InitViewLable(void); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainPresenterSample.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainPresenterSample.cpp index afe856c96..ca923bc77 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainPresenterSample.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainPresenterSample.cpp @@ -21,195 +21,230 @@ #include #include -namespace OHOS { - -map g_jumpView = { { MAIN_CLICK_WEATHER, VIEW_MAIN_SAMPLE }, // 天气界面 - { MAIN_CLICK_ACTIVITY, VIEW_MAIN_ACTIVITY }, // 活动记录界面 - { MAIN_CLICK_MESSAGE, VIEW_MAIN_SAMPLE }, // 消息app - { MAIN_CLICK_HEARTRATE, VIEW_MAIN_SAMPLE }, // 心率界面 - { DROPDOWN_CLICK_ALARM, VIEW_MAIN_ALARM }, // 闹钟app - { DROPDOWN_CLICK_SETTING, VIEW_SETTING } }; // 设置界面 - -map g_chanColor = { { DROPDOWN_CLICK_FINDMYPHONE, DROPDOWN_DROPDOWN_FIND_PHONE_B }, - { DROPDOWN_CLICK_ALARM, DROPDOWN_DROPDOWN_ALARM_B }, - { DROPDOWN_CLICK_SETTING, DROPDOWN_DROPDOWN_SETTING_B } }; - -static MainPresenterSample *g_pMainPresenterSample = nullptr; - -static constexpr uint16_t DROP_X_MAX = 360; -static constexpr uint16_t PROGRESS_PERCENTAGE = 100; -static constexpr uint16_t PROGRESS_COUNTDOWN = 20; -static constexpr uint16_t HORIZONTAL_SWIPE = 1; - -MainPresenterSample::MainPresenterSample() +namespace OHOS { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainPresenterSample :%p", this); - g_pMainPresenterSample = this; -} -MainPresenterSample::~MainPresenterSample() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "~MainPresenterSample"); -} + map g_jumpView = {{MAIN_CLICK_WEATHER, VIEW_MAIN_SAMPLE}, // 天气界面 + {MAIN_CLICK_ACTIVITY, VIEW_MAIN_ACTIVITY}, // 活动记录界面 + {MAIN_CLICK_MESSAGE, VIEW_MAIN_SAMPLE}, // 消息app + {MAIN_CLICK_HEARTRATE, VIEW_MAIN_SAMPLE}, // 心率界面 + {DROPDOWN_CLICK_ALARM, VIEW_MAIN_ALARM}, // 闹钟app + {DROPDOWN_CLICK_SAVEELE, VIEW_SAVEELE}, // 省电模式 + {DROPDOWN_CLICK_SETTING, VIEW_SETTING}}; // 设置界面 + + map g_chanColor = {{DROPDOWN_CLICK_FINDMYPHONE, DROPDOWN_DROPDOWN_FIND_PHONE_B}, + {DROPDOWN_CLICK_ALARM, DROPDOWN_DROPDOWN_ALARM_B}, + {DROPDOWN_CLICK_SETTING, DROPDOWN_DROPDOWN_SETTING_B}}; + + static MainPresenterSample *g_pMainPresenterSample = nullptr; + + static constexpr uint16_t DROP_X_MAX = 360; + static constexpr uint16_t PROGRESS_PERCENTAGE = 100; + static constexpr uint16_t PROGRESS_COUNTDOWN = 20; + static constexpr uint16_t HORIZONTAL_SWIPE = 1; + + MainPresenterSample::MainPresenterSample() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainPresenterSample :%p", this); + g_pMainPresenterSample = this; + } -MainPresenterSample *MainPresenterSample::GetInstance(void) -{ - return g_pMainPresenterSample; -} + MainPresenterSample::~MainPresenterSample() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "~MainPresenterSample"); + } -void MainPresenterSample::OnStart() -{ - Presenter::OnStart(); - if (keyActListenr == nullptr) { - keyActListenr = new KeyInputListener(); - if (keyActListenr != nullptr) { - RootView::GetInstance()->SetOnKeyActListener(keyActListenr); + MainPresenterSample *MainPresenterSample::GetInstance(void) + { + return g_pMainPresenterSample; + } + + void MainPresenterSample::OnStart() + { + Presenter::OnStart(); + if (keyActListenr == nullptr) + { + keyActListenr = new KeyInputListener(); + if (keyActListenr != nullptr) + { + RootView::GetInstance()->SetOnKeyActListener(keyActListenr); + } } } -} -void MainPresenterSample::OnPause(void) {} + void MainPresenterSample::OnPause(void) {} -void MainPresenterSample::OnResume(void) {} + void MainPresenterSample::OnResume(void) {} -void MainPresenterSample::OnStop(void) -{ - if (entryTimes == 0) { - CompassModel::GetInstance()->CloseCompassSensor(); - } - Presenter::OnStop(); - RootView::GetInstance()->ClearOnKeyActListener(); - if (keyActListenr != nullptr) { - delete keyActListenr; - keyActListenr = nullptr; + void MainPresenterSample::OnStop(void) + { + if (entryTimes == 0) + { + CompassModel::GetInstance()->CloseCompassSensor(); + } + Presenter::OnStop(); + RootView::GetInstance()->ClearOnKeyActListener(); + if (keyActListenr != nullptr) + { + delete keyActListenr; + keyActListenr = nullptr; + } } -} -bool MainPresenterSample::OnClick(UIView &view, const ClickEvent &event) -{ - UNUSED(event); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "StatusButtonClickListener: %s", view.GetViewId()); - string curViewId = view.GetViewId(); - - UIImageView *imgView = static_cast(&view); - if (HealthModel::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "health model nullptr"); - return false; - } - if (curViewId == DROPDOWN_CLICK_DONOTDISTURB) { - if (HealthModel::GetInstance()->GetDntDistStatus() == 0) { - ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, imgView, DROPDOWN_DROPDOWN_DN_DISTURB_B); - HealthModel::GetInstance()->UpdateDntDistStatus(1); - } else { - ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, imgView, DROPDOWN_DROPDOWN_DN_DISTURB); - HealthModel::GetInstance()->UpdateDntDistStatus(0); + bool MainPresenterSample::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "StatusButtonClickListener: %s", view.GetViewId()); + string curViewId = view.GetViewId(); + + UIImageView *imgView = static_cast(&view); + if (HealthModel::GetInstance() == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "health model nullptr"); + return false; } - } - if (curViewId == DROPDOWN_CLICK_BRIGHTENSCREEN) { - if (HealthModel::GetInstance()->GetBriScrStatus() == 0) { - ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, imgView, DROPDOWN_DROPDOWN_BRI_SCREEN_B); - HealthModel::GetInstance()->UpdateBriScrStatus(1); - } else { - ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, imgView, DROPDOWN_DROPDOWN_BRI_SCREEN); - HealthModel::GetInstance()->UpdateBriScrStatus(0); + if (curViewId == DROPDOWN_CLICK_DONOTDISTURB) + { + if (HealthModel::GetInstance()->GetDntDistStatus() == 0) + { + ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, imgView, DROPDOWN_DROPDOWN_DN_DISTURB_B); + HealthModel::GetInstance()->UpdateDntDistStatus(1); + } + else + { + ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, imgView, DROPDOWN_DROPDOWN_DN_DISTURB); + HealthModel::GetInstance()->UpdateDntDistStatus(0); + } + } + if (curViewId == DROPDOWN_CLICK_BRIGHTENSCREEN) + { + if (HealthModel::GetInstance()->GetBriScrStatus() == 0) + { + ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, imgView, DROPDOWN_DROPDOWN_BRI_SCREEN_B); + HealthModel::GetInstance()->UpdateBriScrStatus(1); + } + else + { + ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, imgView, DROPDOWN_DROPDOWN_BRI_SCREEN); + HealthModel::GetInstance()->UpdateBriScrStatus(0); + } } - } - if (g_jumpView.count(curViewId) != 0) { - NativeAbility::GetInstance().ChangeSlice(g_jumpView[curViewId]); + if (g_jumpView.count(curViewId) != 0) + { + NativeAbility::GetInstance().ChangeSlice(g_jumpView[curViewId]); + } + return true; } - return true; -} -void MainPresenterSample::OnSwipe(UISwipeView &view) -{ - UNUSED(view); - int page = MainViewSample::GetInstance()->GetHorCurrentPage(); - callback_->OnSwipe(view); - if (page == COMPASS) { - if (entryTimes != 0) { - CompassModel::GetInstance()->OpenCompassSensor(); - entryTimes = 0; - } - } else if (entryTimes == 0) { - CompassModel::GetInstance()->CloseCompassSensor(); - entryTimes++; - } + void MainPresenterSample::OnSwipe(UISwipeView &view) + { + UNUSED(view); + int page = MainViewSample::GetInstance()->GetHorCurrentPage(); + callback_->OnSwipe(view); + if (page == COMPASS) + { + if (entryTimes != 0) + { + CompassModel::GetInstance()->OpenCompassSensor(); + entryTimes = 0; + } + } + else if (entryTimes == 0) + { + CompassModel::GetInstance()->CloseCompassSensor(); + entryTimes++; + } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnSwipe OnSwipe"); - return; -} + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnSwipe OnSwipe"); + return; + } -void MainPresenterSample::ProcessDataNotify(void) -{ - HealthMsg healthMsg; - uint16_t len; + void MainPresenterSample::ProcessDataNotify(void) + { + HealthMsg healthMsg; + uint16_t len; - while ((HealthModel::GetInstance()->FetchedHealthData(&healthMsg) == true)) { - switch (healthMsg.type) { + while ((HealthModel::GetInstance()->FetchedHealthData(&healthMsg) == true)) + { + switch (healthMsg.type) + { case BATTERY_LIFE: break; default: break; + } } } -} -void MainPresenterSample::SetCircleProgress() -{ - PlayersView *playersView = PlayersView::GetInstance(); - if (playersView == nullptr) { - return; - } - UICircleProgress *playbackProgress = playersView->GetPlaybackProgress(); - if (playbackProgress == nullptr) { - return; - } - state = playersView->GetPlayerButtonState(); - if (state == UICheckBox::UICheckBoxState::SELECTED) { - if (musicCount++ % PROGRESS_COUNTDOWN == 0) { - PlayersModel::GetInstance()->GetPlayerCtr()->GetCurrentTime(playerCurrentTime); - PlayersModel::GetInstance()->GetDuration(playerMusicDuration); - if (playerMusicDuration != 0) { - playerProgressVlaue = (playerCurrentTime * PROGRESS_PERCENTAGE) / playerMusicDuration; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "playerProgressVlaue %lld", playerProgressVlaue); - } else { - playerProgressVlaue = 100; - } - PlayersModel::GetInstance()->SetCircleProgress(playerProgressVlaue); - GraphicService::GetInstance()->PostGraphicEvent(std::bind(&PlayersPresenter::SetPlaybackProgress, - PlayersPresenter::GetInstance(), playerProgressVlaue)); + void MainPresenterSample::SetCircleProgress() + { + PlayersView *playersView = PlayersView::GetInstance(); + if (playersView == nullptr) + { + return; } - if (musicCount >= PROGRESS_COUNTDOWN) { - musicCount = 0; + UICircleProgress *playbackProgress = playersView->GetPlaybackProgress(); + if (playbackProgress == nullptr) + { + return; + } + state = playersView->GetPlayerButtonState(); + if (state == UICheckBox::UICheckBoxState::SELECTED) + { + if (musicCount++ % PROGRESS_COUNTDOWN == 0) + { + PlayersModel::GetInstance()->GetPlayerCtr()->GetCurrentTime(playerCurrentTime); + PlayersModel::GetInstance()->GetDuration(playerMusicDuration); + if (playerMusicDuration != 0) + { + playerProgressVlaue = (playerCurrentTime * PROGRESS_PERCENTAGE) / playerMusicDuration; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "playerProgressVlaue %lld", playerProgressVlaue); + } + else + { + playerProgressVlaue = 100; + } + PlayersModel::GetInstance()->SetCircleProgress(playerProgressVlaue); + GraphicService::GetInstance()->PostGraphicEvent(std::bind(&PlayersPresenter::SetPlaybackProgress, + PlayersPresenter::GetInstance(), playerProgressVlaue)); + } + if (musicCount >= PROGRESS_COUNTDOWN) + { + musicCount = 0; + } } } -} -void MainPresenterSample::SetCompassRotate() -{ - if (CompassCalibrationView::GetInstance() == nullptr) { - return; - } - if (CompassView::GetInstance() == nullptr) { - return; - } + void MainPresenterSample::SetCompassRotate() + { + if (CompassCalibrationView::GetInstance() == nullptr) + { + return; + } + if (CompassView::GetInstance() == nullptr) + { + return; + } - uint8_t status = CompassModel::GetInstance()->GetCalibrationStatus(); - if (status == 1) { - CompassCalibrationView::GetInstance()->SetVisible(true); - CompassView::GetInstance()->SetVisible(false); - } else { - CompassCalibrationView::GetInstance()->SetVisible(false); - CompassView::GetInstance()->SetVisible(true); - DetermineToRotate(); + uint8_t status = CompassModel::GetInstance()->GetCalibrationStatus(); + if (status == 1) + { + CompassCalibrationView::GetInstance()->SetVisible(true); + CompassView::GetInstance()->SetVisible(false); + } + else + { + CompassCalibrationView::GetInstance()->SetVisible(false); + CompassView::GetInstance()->SetVisible(true); + DetermineToRotate(); + } } -} -void MainPresenterSample::Notify(void) -{ - SetCircleProgress(); - SetCompassRotate(); -} + void MainPresenterSample::Notify(void) + { + SetCircleProgress(); + SetCompassRotate(); + } } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainSwipeViewGroup.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainSwipeViewGroup.cpp new file mode 100644 index 000000000..adfa835a4 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainSwipeViewGroup.cpp @@ -0,0 +1,182 @@ +/* + * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: MainSwipeViewGroup + * Author: + * Create: 2022-02 + */ + +#include "wearable_log.h" +#include "MainSwipeViewGroup.h" +#include "MainPresenterSample.h" +#include "CompassModel.h" + +namespace OHOS { +static MainSwipeViewGroup *g_pMainGroup = nullptr; +static constexpr uint16_t NULL_SWIPE_SELECT = 0; +static constexpr uint16_t HORIZONTAL_SWIPE = 1; +static constexpr uint16_t VERTICAL_SWIPE = 2; +static constexpr uint16_t DROP_DOWN_MIN = 0; +static constexpr uint16_t DROP_DOWN_MAX = 75; +static constexpr uint16_t PULL_UP_MIN = 380; +static constexpr uint16_t DROP_DOWM_VIEW = 0; +static constexpr uint16_t PULL_UP_VIEW = 2; +static constexpr uint16_t HOR_MAIN_CLOCK_VIEW = 0; +static constexpr uint16_t VER_MAIN_CLOCK_VIEW = 1; +static constexpr uint16_t TWO_HOUR_SECOND = 7200; + +MainSwipeViewGroup::MainSwipeViewGroup() +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainSwipeViewGroup::MainSwipeViewGroup"); + g_pMainGroup = this; +} + +MainSwipeViewGroup::~MainSwipeViewGroup() +{ + RemoveAll(); +} + +MainSwipeViewGroup *MainSwipeViewGroup::GetInstance(void) +{ + return g_pMainGroup; +} + +void MainSwipeViewGroup::AddSwipeView(UISwipeViewApp *view) +{ + if (view == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AddSwipeViewApp is nullptr"); + return; + } + + UIViewGroup::Add(view); + Invalidate(); + horizontal = view; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "horizontal: %02x", horizontal); +} + +void MainSwipeViewGroup::AddSwipeView(UISwipeView *view) +{ + + if (view == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AddSwipeView is nullptr"); + return; + } + + UIViewGroup::Add(view); + Invalidate(); + vertical = view; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "vertical: %02x", vertical); +} + +bool MainSwipeViewGroup::OnDragStartEvent(const DragEvent& event) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnDragStartEvent index: %d", horizontal->GetCurrentPage()); + UNUSED(event); + time_t currTime = CompassModel::GetInstance()->GetCurrentTime(); + time_t lastTime = CompassModel::GetInstance()->GetLastTime(); + CompassModel::GetInstance()->SetCalibrationStatus(0); + return true; +} + +bool MainSwipeViewGroup::OnDragEvent(const DragEvent& event) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainSwipeViewGroup OnDragEvent: %d", event.GetDragDirection()); + + if (swipeDirect == NULL_SWIPE_SELECT) { + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT || + event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT) { + if (vertical->GetCurrentPage() != DROP_DOWM_VIEW && vertical->GetCurrentPage() != PULL_UP_VIEW) { + swipeDirect = HORIZONTAL_SWIPE; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "horizontal->OnDragEvent1, direct:%d index: %d", swipeDirect, horizontal->GetCurrentPage()); + horizontal->OnDragEvent(event); + } + } else if ((event.GetDragDirection() == DragEvent::DIRECTION_TOP_TO_BOTTOM || + event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP)) { + dragStartPos = event.GetStartPoint(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "dragStartPos (%d, %d)", dragStartPos.x, dragStartPos.y); + if ((horizontal->GetCurrentPage() == HOR_MAIN_CLOCK_VIEW && + vertical->GetCurrentPage() == VER_MAIN_CLOCK_VIEW) && + ((dragStartPos.y >= DROP_DOWN_MIN && dragStartPos.y < DROP_DOWN_MAX) || + (dragStartPos.y > PULL_UP_MIN && dragStartPos.y <= VERTICAL_RESOLUTION))) { + swipeDirect = VERTICAL_SWIPE; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "vertical->OnDragEvent1, direct:%d index: %d", swipeDirect, vertical->GetCurrentPage()); + pullIndex = VER_MAIN_CLOCK_VIEW; + if (dragStartPos.y >= DROP_DOWN_MIN && dragStartPos.y < DROP_DOWN_MAX) { + pullIndex -=1; + } else { + pullIndex +=1; + } + UIView* view = vertical->GetViewByIndex(pullIndex); + view->SetBackgroundBlur(10); // 10: blurRadius + vertical->OnDragEvent(event); + } else if (vertical->GetCurrentPage() == DROP_DOWM_VIEW || vertical->GetCurrentPage() == PULL_UP_VIEW) { + swipeDirect = VERTICAL_SWIPE; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "vertical->OnDragEvent2, direct:%d index: %d", swipeDirect, vertical->GetCurrentPage()); + vertical->OnDragEvent(event); + } else if ((event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) && + (event.GetStartPoint().y > 300) && (horizontal->GetCurrentPage() == MUSIC_PLAYER)) { + PlayersPresenter::GetInstance()->ShowPlayerListGroup(); + } + } + } else if (swipeDirect == HORIZONTAL_SWIPE) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "horizontal->OnDragEvent2, direct:%d index: %d", swipeDirect, horizontal->GetCurrentPage()); + horizontal->OnDragEvent(event); + } else if (swipeDirect == VERTICAL_SWIPE) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "vertical->OnDragEvent3, direct:%d index: %d", swipeDirect, vertical->GetCurrentPage()); + if (vertical->GetCurrentPage() == VER_MAIN_CLOCK_VIEW) { + UIView* view = vertical->GetViewByIndex(pullIndex); + view->SetOpaScale(128); + } + vertical->OnDragEvent(event); + RootView::GetInstance()->Invalidate(); + } + return true; +} + +bool MainSwipeViewGroup::OnDragEndEvent(const DragEvent& event) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnDragEndEvent"); + if (swipeDirect == HORIZONTAL_SWIPE) { + horizontal->OnDragEndEvent(event); + } else if (swipeDirect == VERTICAL_SWIPE) { + vertical->OnDragEndEvent(event); + if (vertical->GetCurrentPage() == VER_MAIN_CLOCK_VIEW) { + vertical->GetViewByIndex(pullIndex)->ClearBackgroundBlur(); + RootView::GetInstance()->Invalidate(); + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "vertical->OnDragEndEvent, index: %d", vertical->GetCurrentPage()); + } + swipeDirect = 0; + return true; +} + +bool MainSwipeViewGroup::MainClockPage(void) +{ + if (horizontal->GetCurrentPage() == 0 && vertical->GetCurrentPage() == 1) { + return true; + } + return false; +} + +bool UISwipeViewApp::OnDragEvent(const DragEvent& event) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnDragEvent"); + + UIView* currentView = GetViewByIndex(curIndex_); + if (currentView == nullptr) { + return UIView::OnDragEvent(event); + } + if (scrollAnimator_.GetState() != Animator::STOP) { + UIAbstractScroll::StopAnimator(); + } + + if (direction_ == HORIZONTAL) { + DragXInner(event.GetDeltaX()); + RefreshDelta(event.GetDeltaX()); + } else { + DragYInner(event.GetDeltaY()); + RefreshDelta(event.GetDeltaY()); + } + return UIView::OnDragEvent(event); +} + +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/PullUpDownView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/PullUpDownView.cpp index 7e8cb3053..bd815081d 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/PullUpDownView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/PullUpDownView.cpp @@ -14,45 +14,57 @@ #include "SettingModel.h" #include "ui_resource_image.h" -namespace OHOS { - -static PullUpDownView *g_pPullUpDownView = 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; +namespace OHOS +{ + + static PullUpDownView *g_pPullUpDownView = nullptr; + + // 勿扰 + constexpr int16_t DISTURB_IMG_X = 186; + constexpr int16_t DISTURB_IMG_Y = 30; + + // 亮屏 + constexpr int16_t SCREEN_IMG_X = 76; + constexpr int16_t SCREEN_IMG_Y = 76; + + // 找手机 + constexpr int16_t PHONE_IMG_X = 342; + constexpr int16_t PHONE_IMG_Y = 186; + + // 闹钟 + constexpr int16_t ALARM_IMG_X = 296; + constexpr int16_t ALARM_IMG_Y = 76; + + // 设置 + constexpr int16_t SETTING_IMG_X = 30; + constexpr int16_t SETTING_IMG_Y = 186; + + 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 = 128; + constexpr int16_t DATE_LABEL_Y = 299; + + constexpr int16_t FONT_DEFAULT_SIZE = 30; + constexpr int16_t TEXT_WIDTH = 400; + constexpr int16_t TEXT_HEIGHT = 35; constexpr int16_t NONOTICE_LABLE_X = 141; constexpr int16_t NONOTICE_LABLE_Y = 212; @@ -63,40 +75,42 @@ PullUpDownView::PullUpDownView() g_pPullUpDownView = this; } -PullUpDownView::~PullUpDownView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::~PullUpDownView"); - RemoveAll(); - delete dnotDisturb; - dnotDisturb = nullptr; - delete briScreen; - briScreen = nullptr; - delete finPhone; - finPhone = nullptr; - delete droAlarm; - droAlarm = nullptr; - delete droSetting; - droSetting = nullptr; - delete dnotDisturbLable; - dnotDisturbLable = nullptr; - delete briScreenLable; - briScreenLable = nullptr; - delete finPhoneLable; - finPhoneLable = nullptr; - delete droAlarmLable; - droAlarmLable = nullptr; - delete droSettingLable; - droSettingLable = nullptr; - delete bluetooth; - bluetooth = nullptr; - delete battery; - battery = nullptr; - delete batteryLable; - batteryLable = nullptr; - delete dateLable; - dateLable = nullptr; - g_pPullUpDownView = nullptr; -} + PullUpDownView::~PullUpDownView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::~PullUpDownView"); + RemoveAll(); + delete dnotDisturb; + dnotDisturb = nullptr; + delete briScreen; + briScreen = nullptr; + delete finPhone; + finPhone = nullptr; + delete droAlarm; + droAlarm = nullptr; + delete droSetting; + droSetting = nullptr; + delete dnotDisturbLable; + dnotDisturbLable = nullptr; + delete briScreenLable; + briScreenLable = nullptr; + delete finPhoneLable; + finPhoneLable = nullptr; + delete droAlarmLable; + droAlarmLable = nullptr; + delete droSettingLable; + droSettingLable = nullptr; + delete bluetooth; + bluetooth = nullptr; + delete battery; + battery = nullptr; + delete batteryLable; + batteryLable = nullptr; + delete dateLable; + dateLable = nullptr; + delete timeLable; + timeLable = nullptr; + g_pPullUpDownView = nullptr; + } PullUpDownView *PullUpDownView::GetInstance(void) { @@ -110,20 +124,24 @@ void PullUpDownView::InitSubViewImg(void) return; } - dnotDisturb = new UIImageView(); - if (dnotDisturb == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dnotDisturb new fail"); - return; - } - dnotDisturb->SetPosition(DISTURB_IMG_X, DISTURB_IMG_Y); - if (HealthModel::GetInstance()->GetDntDistStatus() == 0) { - ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dnotDisturb, DROPDOWN_DROPDOWN_DN_DISTURB); - } else { - ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dnotDisturb, DROPDOWN_DROPDOWN_DN_DISTURB_B); - } - dnotDisturb->SetViewId(DROPDOWN_CLICK_DONOTDISTURB); - dnotDisturb->SetTouchable(true); - dnotDisturb->SetOnClickListener(clickListener); // 进入勿扰模式 + dnotDisturb = new UIImageView(); + if (dnotDisturb == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dnotDisturb new fail"); + return; + } + dnotDisturb->SetPosition(DISTURB_IMG_X, DISTURB_IMG_Y); + if (HealthModel::GetInstance()->GetDntDistStatus() == 0) + { + ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dnotDisturb, DROPDOWN_DROPDOWN_DN_DISTURB); + } + else + { + ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dnotDisturb, DROPDOWN_DROPDOWN_DN_DISTURB_B); + } + dnotDisturb->SetViewId(DROPDOWN_CLICK_SAVEELE); + dnotDisturb->SetTouchable(true); + dnotDisturb->SetOnClickListener(clickListener); // 进入勿扰模式 briScreen = new UIImageView(); if (briScreen == nullptr) { @@ -179,54 +197,61 @@ void PullUpDownView::InitViewImg(void) droSetting->SetOnClickListener(clickListener); } -void PullUpDownView::InitViewLable(void) -{ - dnotDisturbLable = new UILabel(); - if (dnotDisturbLable == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dnotDisturbLable new fail"); - return; - } - dnotDisturbLable->SetPosition(DISTURB_LABEL_X, DISTURB_LABEL_Y, TEXT_WIDTH, TEXT_HEIGHT); - dnotDisturbLable->SetText("勿扰"); - dnotDisturbLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); - dnotDisturbLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - briScreenLable = new UILabel(); - if (briScreenLable == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "briScreenLable new fail"); - return; - } - briScreenLable->SetPosition(SCREEN_LABEL_X, SCREEN_LABEL_Y, TEXT_WIDTH, TEXT_HEIGHT); - briScreenLable->SetText("亮屏"); - briScreenLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); - briScreenLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - finPhoneLable = new UILabel(); - if (finPhoneLable == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "finPhoneLable new fail"); - return; - } - finPhoneLable->SetPosition(PHONE_LABEL_X, PHONE_LABEL_Y, TEXT_WIDTH, TEXT_HEIGHT); - finPhoneLable->SetText("找手机"); - finPhoneLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); - finPhoneLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - droAlarmLable = new UILabel(); - if (finPhoneLable == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "finPhoneLable new fail"); - return; - } - droAlarmLable->SetPosition(ALARM_LABEL_X, ALARM_LABEL_Y, TEXT_WIDTH, TEXT_HEIGHT); - droAlarmLable->SetText("闹钟"); - droAlarmLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); - droAlarmLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - droSettingLable = new UILabel(); - if (droSettingLable == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "droSettingLable new fail"); - return; + void PullUpDownView::InitViewLable(void) + { + dnotDisturbLable = new UILabel(); + if (dnotDisturbLable == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dnotDisturbLable new fail"); + return; + } + dnotDisturbLable->SetPosition(DISTURB_LABEL_X, DISTURB_LABEL_Y, TEXT_WIDTH, TEXT_HEIGHT); + // dnotDisturbLable->SetText("勿扰"); + dnotDisturbLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); + dnotDisturbLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + + briScreenLable = new UILabel(); + if (briScreenLable == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "briScreenLable new fail"); + return; + } + briScreenLable->SetPosition(SCREEN_LABEL_X, SCREEN_LABEL_Y, TEXT_WIDTH, TEXT_HEIGHT); + // briScreenLable->SetText("亮屏"); + briScreenLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); + briScreenLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + + finPhoneLable = new UILabel(); + if (finPhoneLable == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "finPhoneLable new fail"); + return; + } + finPhoneLable->SetPosition(PHONE_LABEL_X, PHONE_LABEL_Y, TEXT_WIDTH, TEXT_HEIGHT); + // finPhoneLable->SetText("找手机"); + finPhoneLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); + finPhoneLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + droAlarmLable = new UILabel(); + if (finPhoneLable == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "finPhoneLable new fail"); + return; + } + droAlarmLable->SetPosition(ALARM_LABEL_X, ALARM_LABEL_Y, TEXT_WIDTH, TEXT_HEIGHT); + // droAlarmLable->SetText("闹钟"); + droAlarmLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); + droAlarmLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + droSettingLable = new UILabel(); + if (droSettingLable == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "droSettingLable new fail"); + return; + } + droSettingLable->SetPosition(SETTING_LABEL_X, SETTING_LABEL_Y, TEXT_WIDTH, TEXT_HEIGHT); + // droSettingLable->SetText("设置"); + droSettingLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); + droSettingLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); } - droSettingLable->SetPosition(SETTING_LABEL_X, SETTING_LABEL_Y, TEXT_WIDTH, TEXT_HEIGHT); - droSettingLable->SetText("设置"); - droSettingLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); - droSettingLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); -} void PullUpDownView::InitViewInfo(void) { @@ -247,56 +272,71 @@ void PullUpDownView::InitViewInfo(void) ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, bluetooth, DROPDOWN_DROPDOWN_BLUETOOTH); } - battery = new UIImageView(); // 电量状态显示 - if (battery == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "battery new fail"); - return; - } - battery->SetPosition(BATTERY_IMG_X, BATTERY_IMG_Y); - ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, battery, DROPDOWN_DROPDOWN_BATTERY); - batteryLable = new UILabel(); - if (batteryLable == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryLable new fail"); - return; - } - batteryLable->SetPosition(BATTERY_LABEL_X, BATTERY_LABEL_Y, TEXT_WIDTH, TEXT_HEIGHT); - batteryLable->SetText("90%"); - batteryLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); - batteryLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - dateLable = new UILabel(); - if (dateLable == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dateLable new fail"); - return; + battery = new UIImageView(); // 电量状态显示 + if (battery == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "battery new fail"); + return; + } + battery->SetPosition(BATTERY_IMG_X, BATTERY_IMG_Y); + ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, battery, DROPDOWN_DROPDOWN_BATTERY); + batteryLable = new UILabel(); + if (batteryLable == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryLable new fail"); + return; + } + batteryLable->SetPosition(BATTERY_LABEL_X, BATTERY_LABEL_Y, TEXT_WIDTH, TEXT_HEIGHT); + batteryLable->SetText("90%"); + batteryLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); + batteryLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + dateLable = new UILabel(); + if (dateLable == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dateLable new fail"); + return; + } + dateLable->SetPosition(DATE_LABEL_X, DATE_LABEL_Y, 210, TEXT_HEIGHT); // TEXT_WIDTH = 192 + dateLable->SetText("11月1号 星期三"); + dateLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); + dateLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + + timeLable = new UILabel(); + if (timeLable == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "timeLable new fail"); + return; + } + timeLable->SetPosition(172,230,500,59); + timeLable->SetText("23:54"); + timeLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME,50); + timeLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); } - dateLable->SetPosition(DATE_LABEL_X, DATE_LABEL_Y, 192, TEXT_HEIGHT); // TEXT_WIDTH = 192 - dateLable->SetText("10/23 星期五"); - dateLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); - dateLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); -} -bool PullUpDownView::InitView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::InitDropDownView caller:%p", caller); - clickListener = (UIView::OnClickListener *)OHOS::MainPresenterSample::GetInstance(); - - InitViewImg(); - InitViewLable(); - InitViewInfo(); - - Add(dnotDisturb); - Add(dnotDisturbLable); - Add(briScreen); - Add(briScreenLable); - Add(finPhone); - Add(finPhoneLable); - Add(droAlarm); - Add(droAlarmLable); - Add(droSetting); - Add(droSettingLable); - Add(bluetooth); - Add(battery); - Add(batteryLable); - Add(dateLable); + bool PullUpDownView::InitView( ) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::InitDropDownView caller:%p", caller); + clickListener = (UIView::OnClickListener *)OHOS::MainPresenterSample::GetInstance(); + + InitViewImg(); + InitViewLable(); + InitViewInfo(); + + Add(dnotDisturb); + Add(dnotDisturbLable); + Add(briScreen); + Add(briScreenLable); + Add(finPhone); + Add(finPhoneLable); + Add(droAlarm); + Add(droAlarmLable); + Add(droSetting); + Add(droSettingLable); + Add(bluetooth); + Add(battery); + Add(batteryLable); + Add(dateLable); + Add(timeLable); SetTouchable(true); SetIntercept(true); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallPresenter.h new file mode 100644 index 000000000..3d9f7919b --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallPresenter.h @@ -0,0 +1,38 @@ +#ifndef _PhoneCall_PRESENTER_H +#define _PhoneCall_PRESENTER_H + +#include "Presenter.h" +#include "PhoneCallView.h" +#include "string" + +namespace OHOS +{ + + class PhoneCallView; + class PhoneCallPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + PhoneCallPresenter(); + virtual ~PhoneCallPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + void Invalidate(); + void UpdatePhoneNumberView(const std::string &number); + static PhoneCallPresenter *GetInstance(); + std::string phoneNumber; + + private: + // 声明一个字符串变量用于存储用户输入的号码 + + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallView.h b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallView.h new file mode 100644 index 000000000..4080c5b5a --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallView.h @@ -0,0 +1,97 @@ +#ifndef _PHONECALL_VIEW_H +#define _PHONECALL_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" + +#include "PhoneCallPresenter.h" +namespace OHOS +{ +#define BUTTON1 "button1" +#define BUTTON2 "button2" +#define BUTTON3 "button3" +#define BUTTON4 "button4" +#define BUTTON5 "button5" +#define BUTTON6 "button6" +#define BUTTON7 "button7" +#define BUTTON8 "button8" +#define BUTTON9 "button9" +#define BUTTONCALL "buttoncall" +#define BUTTON0 "button0" +#define BUTTONDEL "buttondel" + +#define BUTTON_PATH "/user/res/Phone/" + + static const char *button1Path = BUTTON_PATH "1.bin"; + static const char *button2Path = BUTTON_PATH "2.bin"; + static const char *button3Path = BUTTON_PATH "3.bin"; + static const char *button4Path = BUTTON_PATH "4.bin"; + static const char *button5Path = BUTTON_PATH "5.bin"; + static const char *button6Path = BUTTON_PATH "6.bin"; + static const char *button7Path = BUTTON_PATH "7.bin"; + static const char *button8Path = BUTTON_PATH "8.bin"; + static const char *button9Path = BUTTON_PATH "9.bin"; + static const char *buttonCallPath = BUTTON_PATH "call.bin"; + static const char *button0Path = BUTTON_PATH "0.bin"; + static const char *buttonDelPath = BUTTON_PATH "del.bin"; + + // 定义包含按钮初始化参数的结构体 + struct ButtonInitParams + { + UIButton *button; + const char *buttonNumber; + int leftPos; + int topPos; + int width; + int height; + const char *defaultImgSrc; + const char *triggeredImgSrc; + }; + + class PhoneCallPresenter; + class PhoneCallView : public View + { + + public: + PhoneCallView(); + virtual ~PhoneCallView(); + static PhoneCallView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Invalidate(); + void Init(); + void DeInit(); + + void initButton(const ButtonInitParams ¶ms); + void UpdateLabel(const std::string &text); + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + PhoneCallView(PhoneCallView &&) = delete; + PhoneCallView &operator=(PhoneCallView &&) = delete; + UIViewGroup *container_ = nullptr; + UILabel *label_ = nullptr; + UIButton *button1_ = nullptr; + UIButton *button2_ = nullptr; + UIButton *button3_ = nullptr; + UIButton *button4_ = nullptr; + UIButton *button5_ = nullptr; + UIButton *button6_ = nullptr; + UIButton *button7_ = nullptr; + UIButton *button8_ = nullptr; + UIButton *button9_ = nullptr; + UIButton *button0_ = nullptr; + UIButton *buttoncall_ = nullptr; + UIButton *buttondel_ = nullptr; + }; +} // namespace OHOS +#endif diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallingPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallingPresenter.h new file mode 100644 index 000000000..3d3e3f1ea --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallingPresenter.h @@ -0,0 +1,33 @@ +#ifndef _PhoneCalling_PRESENTER_H +#define _PhoneCalling_PRESENTER_H + +#include "Presenter.h" +#include "PhoneCallingView.h" + +namespace OHOS +{ + class PhoneCallingView; + + class PhoneCallingPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + PhoneCallingPresenter(); + virtual ~PhoneCallingPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static PhoneCallingPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallingView.h b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallingView.h new file mode 100644 index 000000000..035e308e8 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallingView.h @@ -0,0 +1,53 @@ +#ifndef _PhoneCalling_VIEW_H +#define _PhoneCalling_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_image_animator.h" + +#include "PhoneCallingPresenter.h" +namespace OHOS +{ +#define PHONECALLBUTTON "phonecall" +#define PHONEOFFBUTTON "phoneoff" + + + class PhoneCallingPresenter; + class PhoneCallingView : public View + { + + public: + PhoneCallingView(); + virtual ~PhoneCallingView(); + static PhoneCallingView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + PhoneCallingView(PhoneCallingView &&) = delete; + PhoneCallingView &operator=(PhoneCallingView &&) = delete; + + UIViewGroup *container_ = nullptr; + UILabel *label1_ = nullptr; + UILabel *label2_ = nullptr; + UIButton *button2_ = nullptr; + UIImageView *image1_ = nullptr; + UIButton *button1_ = nullptr; + UIImageAnimatorView *imageAnimator1_ = nullptr; + UILabel *label3_ = nullptr; + }; +} // namespace OHOS +#endif // PhoneCalling_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallupPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallupPresenter.h new file mode 100644 index 000000000..6d5e96071 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallupPresenter.h @@ -0,0 +1,36 @@ +#ifndef _PhoneCallup_PRESENTER_H +#define _PhoneCallup_PRESENTER_H + +#include "Presenter.h" +#include "PhoneCallupView.h" + +namespace OHOS +{ + +#define OFFBUTTON "button1" + + class PhoneCallupView; + + class PhoneCallupPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + PhoneCallupPresenter(); + virtual ~PhoneCallupPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static PhoneCallupPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallupView.h b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallupView.h new file mode 100644 index 000000000..952f30626 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneCallupView.h @@ -0,0 +1,60 @@ +#ifndef _PhoneCallup_VIEW_H +#define _PhoneCallup_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_toggle_button.h" +#include "components/ui_button.h" +#include "animator/animator.h" + +#include "PhoneCallupPresenter.h" +namespace OHOS +{ + class PhoneAnimatorCallback : public AnimatorCallback + { + public: + explicit PhoneAnimatorCallback(UILabel *label) : label_(label) {} + ~PhoneAnimatorCallback() override {} + void Callback(UIView *view) override; + + private: + UILabel *label_ = nullptr; + }; + class PhoneCallupPresenter; + class PhoneCallupView : public View + { + + public: + explicit PhoneCallupView(); + virtual ~PhoneCallupView(); + static PhoneCallupView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + PhoneCallupView(PhoneCallupView &&) = delete; + PhoneCallupView &operator=(PhoneCallupView &&) = delete; + + UIViewGroup *container_ = nullptr; + UILabel *label2_ = nullptr; + UILabel *label1_ = nullptr; + UIToggleButton *toggleButton1_ = nullptr; + UIImageView *image1_ = nullptr; + UIToggleButton *toggleButton2_ = nullptr; + UIButton *button1_ = nullptr; + PhoneAnimatorCallback *callBack_ = nullptr; + Animator *animator_ = nullptr; + }; +} // namespace OHOS +#endif // PhoneCallup_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneDirPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneDirPresenter.h new file mode 100644 index 000000000..7568164d2 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneDirPresenter.h @@ -0,0 +1,33 @@ +#ifndef _PhoneDir_PRESENTER_H +#define _PhoneDir_PRESENTER_H + +#include "Presenter.h" +#include "PhoneDirView.h" + +namespace OHOS +{ + class PhoneDirView; + + class PhoneDirPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + PhoneDirPresenter(); + virtual ~PhoneDirPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static PhoneDirPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneDirView.h b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneDirView.h new file mode 100644 index 000000000..2e192fb67 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneDirView.h @@ -0,0 +1,68 @@ +#ifndef _PhoneDir_VIEW_H +#define _PhoneDir_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_label_button_ext.h" +#include "graphic_config.h" +#include "components/ui_label_button.h" + +#include "PhoneDirPresenter.h" +namespace OHOS +{ + + class PhoneDirPresenter; + class PhoneDirView : public View + { + + public: + PhoneDirView(); + virtual ~PhoneDirView(); + static PhoneDirView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + PhoneDirView(PhoneDirView &&) = delete; + PhoneDirView &operator=(PhoneDirView &&) = delete; + +#if 0 + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UILabel *label1_ = nullptr; + UILabel *label2_ = nullptr; + UIImageView *image1_ = nullptr; +#endif + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UILabel *label1_ = nullptr; + UILabelButtonExt *labelButton8_ = nullptr; + UIImageView *image2_ = nullptr; + UILabelButtonExt *labelButton9_ = nullptr; + UIImageView *image3_ = nullptr; + UILabelButtonExt *labelButton10_ = nullptr; + UIImageView *image5_ = nullptr; + UIImageView *image7_ = nullptr; + UILabelButtonExt *labelButton13_ = nullptr; + UIImageView *image9_ = nullptr; + UIImageView *image8_ = nullptr; + UILabelButtonExt *labelButton11_ = nullptr; + UIImageView *image6_ = nullptr; + UILabelButtonExt *labelButton7_ = nullptr; + UIImageView *image1_ = nullptr; + }; +} // namespace OHOS +#endif // PhoneDir_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhonePresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhonePresenter.h new file mode 100644 index 000000000..04db09c6b --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhonePresenter.h @@ -0,0 +1,33 @@ +#ifndef _PHONE_PRESENTER_H +#define _PHONE_PRESENTER_H + +#include "Presenter.h" +#include "PhoneView.h" + +namespace OHOS +{ + class PhoneView; + + class PhonePresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + PhonePresenter(); + virtual ~PhonePresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static PhonePresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneRingPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneRingPresenter.h new file mode 100644 index 000000000..60f970c11 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneRingPresenter.h @@ -0,0 +1,36 @@ +#ifndef _PhoneRing_PRESENTER_H +#define _PhoneRing_PRESENTER_H + +#include "Presenter.h" +#include "PhoneRingView.h" + +namespace OHOS +{ + +#define OFFBUTTON "button1" + + class PhoneRingView; + + class PhoneRingPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + PhoneRingPresenter(); + virtual ~PhoneRingPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static PhoneRingPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneRingView.h b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneRingView.h new file mode 100644 index 000000000..4ee4d85e4 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneRingView.h @@ -0,0 +1,49 @@ +#ifndef _PhoneRing_VIEW_H +#define _PhoneRing_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_toggle_button.h" +#include "components/ui_button.h" + +#include "PhoneRingPresenter.h" +namespace OHOS +{ + + class PhoneRingPresenter; + class PhoneRingView : public View + { + + public: + PhoneRingView(); + virtual ~PhoneRingView(); + static PhoneRingView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + PhoneRingView(PhoneRingView &&) = delete; + PhoneRingView &operator=(PhoneRingView &&) = delete; + + UIViewGroup *container_ = nullptr; + UILabel *label2_ = nullptr; + UILabel *label1_ = nullptr; + UIToggleButton *toggleButton1_ = nullptr; + UIImageView *image1_ = nullptr; + UIToggleButton *toggleButton2_ = nullptr; + UIButton *button1_ = nullptr; + }; +} // namespace OHOS +#endif // PhoneRing_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneView.h b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneView.h new file mode 100644 index 000000000..7420ef388 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/include/PhoneView.h @@ -0,0 +1,65 @@ +#ifndef _Phone_VIEW_H +#define _Phone_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" + +#include "PhonePresenter.h" +namespace OHOS +{ +#define SCROLLVIEW "scrollView1" +#define CALLBUTTON "Call" +#define RINGBUTTON "Ring" + + class PhonePresenter; + class PhoneView : public View + { + + public: + PhoneView(); + virtual ~PhoneView(); + static PhoneView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + PhoneView(PhoneView &&) = delete; + PhoneView &operator=(PhoneView &&) = delete; + + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UILabel *label1_ = nullptr; + UIImageView *image1_ = nullptr; + UIButton *button2_ = nullptr; + UIButton *button1_ = nullptr; + UIButton *button5_ = nullptr; + UILabel *label2_ = nullptr; + UILabel *label3_ = nullptr; + UILabel *label4_ = nullptr; + UILabel *label9_ = nullptr; + UILabel *label14_ = nullptr; + UIButton *button3_ = nullptr; + UILabel *label13_ = nullptr; + UILabel *label12_ = nullptr; + UILabel *label10_ = nullptr; + UIButton *button7_ = nullptr; + UILabel *label11_ = nullptr; + UILabel *label16_ = nullptr; + UILabel *label15_ = nullptr; + UIImageView *image3_ = nullptr; + }; +} // namespace OHOS +#endif // Phone_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallPresenter.cpp new file mode 100644 index 000000000..372769aca --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallPresenter.cpp @@ -0,0 +1,156 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "string" +#include "phone/include/PhoneCallPresenter.h" +#include +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static PhoneCallPresenter *g_pPhoneCallPresenter = nullptr; + + PhoneCallPresenter::PhoneCallPresenter() + { + g_pPhoneCallPresenter = this; + } + + PhoneCallPresenter::~PhoneCallPresenter() + { + + g_pPhoneCallPresenter = nullptr; + } + + PhoneCallPresenter *PhoneCallPresenter::GetInstance() + { + + return g_pPhoneCallPresenter; + } + + void PhoneCallPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void PhoneCallPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void PhoneCallPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void PhoneCallPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool PhoneCallPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT) + { + printf("draglistene is ok!\n"); + NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + } + if (event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_PHONECALLING); + } + UNUSED(view); + return true; + } + bool PhoneCallPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 获取控件id + const char *viewId = view.GetViewId(); + + // 根据控件id处理点击事件 + if (strcmp(viewId, BUTTONCALL) == 0) + { + // 拨号键 + NativeAbility::GetInstance().ChangeSlice(VIEW_PHONERING); + } + else if (strcmp(viewId, BUTTONDEL) == 0) + { + // 点击删除键,从号码字符串中删除最后一个字符 + if (!phoneNumber.empty()) + { + phoneNumber.pop_back(); + } + } + else if (phoneNumber.length() < 11) // 检查号码字符串长度是否小于11 + { + if (strcmp(viewId, BUTTON0) == 0) + { + // 点击0键,将字符'0'追加到号码字符串中 + phoneNumber += "0"; + printf("----0-----\n"); + } + else if (strcmp(viewId, BUTTON1) == 0) + { + // 点击1键,将字符'1'追加到号码字符串中 + phoneNumber += "1"; + printf("----1-----\n"); + } + else if (strcmp(viewId, BUTTON2) == 0) + { + // 点击2键,将字符'2'追加到号码字符串中 + phoneNumber += "2"; + printf("----2-----\n"); + } + else if (strcmp(viewId, BUTTON3) == 0) + { + // 点击3键,将字符'3'追加到号码字符串中 + phoneNumber += "3"; + } + else if (strcmp(viewId, BUTTON4) == 0) + { + // 点击4键,将字符'4'追加到号码字符串中 + phoneNumber += "4"; + } + else if (strcmp(viewId, BUTTON5) == 0) + { + // 点击5键,将字符'5'追加到号码字符串中 + phoneNumber += "5"; + } + else if (strcmp(viewId, BUTTON6) == 0) + { + // 点击6键,将字符'6'追加到号码字符串中 + phoneNumber += "6"; + } + else if (strcmp(viewId, BUTTON7) == 0) + { + // 点击7键,将字符'7'追加到号码字符串中 + phoneNumber += "7"; + } + else if (strcmp(viewId, BUTTON8) == 0) + { + // 点击8键,将字符'8'追加到号码字符串中 + phoneNumber += "8"; + } + else if (strcmp(viewId, BUTTON9) == 0) + { + // 点击9键,将字符'9'追加到号码字符串中 + phoneNumber += "9"; + } + } + printf("**************************\n"); + printf("per phoneNumber: %s\n", phoneNumber.c_str()); + + + PhoneCallView::GetInstance()->Init(); + + //view.Invalidate(); + // RootView::GetInstance()->Invalidate(); + + printf("now phoneNumber: %s\n", phoneNumber.c_str()); + printf("**************************\n"); + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallView.cpp new file mode 100644 index 000000000..d80c640fd --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallView.cpp @@ -0,0 +1,242 @@ +#include "phone/include/PhoneCallView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + + static PhoneCallView *g_pPhoneCallView{nullptr}; + + // 声明全局变量phoneNumber + extern std::string phoneNumber; + + PhoneCallView::PhoneCallView() + { + g_pPhoneCallView = this; + } + + PhoneCallView::~PhoneCallView() + { + DeInit(); + g_pPhoneCallView = nullptr; + } + + PhoneCallView *PhoneCallView::GetInstance() + { + + return g_pPhoneCallView; + } + + void PhoneCallView ::initButton(const ButtonInitParams ¶ms) + { + UIButton *button = params.button; + if (button == nullptr) + { + button = new UIButton(); + } + + const char *buttonNumber = params.buttonNumber; + int leftPos = params.leftPos; + int topPos = params.topPos; + int width = params.width; + int height = params.height; + const char *defaultImgSrc = params.defaultImgSrc; + const char *triggeredImgSrc = params.triggeredImgSrc; + + button->SetPosition(leftPos, topPos); + button->Resize(width, height); + button->SetViewId(buttonNumber); + button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + + // Set additional properties + button->SetImageSrc(defaultImgSrc, triggeredImgSrc); + button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the callback for events + UIView::OnClickListener *buttonClick = static_cast(PhoneCallPresenter::GetInstance()); + button->SetOnClickListener(buttonClick); + + // Add to rootView + container_->Add(button); + button->SetVisible(true); + } + + void PhoneCallView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + // Add Label to App + if (label_ == nullptr) + { + label_ = new UILabel(); + } + label_->SetPosition(115, 40); // widget's left position and top position + label_->Resize(236, 47); // widget's width and height + label_->SetViewId("label1"); // Set style + label_->SetStyle(STYLE_TEXT_FONT, 40); + + // Set additional property + + label_->SetText(PhoneCallPresenter::GetInstance()->phoneNumber.c_str()); + printf("view phoneNumber: %s\n", PhoneCallPresenter::GetInstance()->phoneNumber.c_str()); + label_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + + // Add to rootView + container_->Add(label_); + label_->SetVisible(true); + ButtonInitParams buttonParams[] = { + {button1_, BUTTON1, 68, 104, 104, 70, button1Path, nullptr}, + {button2_, BUTTON2, 181, 104, 104, 70, button2Path, nullptr}, + {button3_, BUTTON3, 293, 104, 104, 70, button3Path, nullptr}, + {button4_, BUTTON4, 69, 182, 104, 70, button4Path, nullptr}, + {button5_, BUTTON5, 182, 182, 104, 70, button5Path, nullptr}, + {button6_, BUTTON6, 293, 182, 104, 70, button6Path, nullptr}, + {button7_, BUTTON7, 69, 260, 104, 70, button7Path, nullptr}, + {button8_, BUTTON8, 181, 260, 104, 70, button8Path, nullptr}, + {button9_, BUTTON9, 293, 260, 104, 70, button9Path, nullptr}, + {button0_, BUTTON0, 181, 338, 104, 70, button0Path, nullptr}, + {buttoncall_, BUTTONCALL, 69, 338, 104, 70, buttonCallPath, nullptr}, + {buttondel_, BUTTONDEL, 293, 338, 104, 70, buttonDelPath, nullptr}, + }; + + for (const auto ¶ms : buttonParams) + { + initButton(params); + } + } + void PhoneCallView::DeInit() + { + printf("DeInit is ok !\n"); + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + if (button2_ != nullptr) + { + delete button2_; + button2_ = nullptr; + } + if (button3_ != nullptr) + { + delete button3_; + button3_ = nullptr; + } + if (button4_ != nullptr) + { + delete button4_; + button4_ = nullptr; + } + if (button5_ != nullptr) + { + delete button5_; + button5_ = nullptr; + } + if (button6_ != nullptr) + { + delete button6_; + button6_ = nullptr; + } + if (button7_ != nullptr) + { + delete button7_; + button7_ = nullptr; + } + if (button8_ != nullptr) + { + delete button8_; + button8_ = nullptr; + } + if (button9_ != nullptr) + { + delete button9_; + button9_ = nullptr; + } + if (button0_ != nullptr) + { + delete button0_; + button0_ = nullptr; + } + if (buttoncall_ != nullptr) + { + delete buttoncall_; + buttoncall_ = nullptr; + } + if (buttondel_ != nullptr) + { + delete buttondel_; + buttondel_ = nullptr; + } + } + UIView *PhoneCallView::GetView() + { + Init(); + return container_; + } + void PhoneCallView::OnStart() + { + printf("Start\n"); + container_ = new UIViewGroup(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(PhoneCallPresenter::GetInstance()); + if (draglistener == nullptr) + { + printf("draglistene is error!\n"); + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + // GetView(); + GetView(); + RootView::GetInstance()->Add(container_); + } + + void PhoneCallView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void PhoneCallView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void PhoneCallView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } + +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallingPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallingPresenter.cpp new file mode 100644 index 000000000..c56348c8c --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallingPresenter.cpp @@ -0,0 +1,80 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "phone/include/PhoneCallingPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static PhoneCallingPresenter *g_pPhoneCallingPresenter = nullptr; + + PhoneCallingPresenter::PhoneCallingPresenter() + { + + g_pPhoneCallingPresenter = this; + } + + PhoneCallingPresenter::~PhoneCallingPresenter() + { + + g_pPhoneCallingPresenter = nullptr; + } + + PhoneCallingPresenter *PhoneCallingPresenter::GetInstance() + { + + return g_pPhoneCallingPresenter; + } + + void PhoneCallingPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void PhoneCallingPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void PhoneCallingPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void PhoneCallingPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool PhoneCallingPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + // if (event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT) + // { + // printf("draglistene is ok!\n"); + // NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + // } + UNUSED(view); + return true; + } + + bool PhoneCallingPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + // if (strcmp(view.GetViewId(), 控件ID) == 0) + if (strcmp(view.GetViewId(), PHONECALLBUTTON) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_PHONECALLUP); + } + if (strcmp(view.GetViewId(), PHONEOFFBUTTON) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallingView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallingView.cpp new file mode 100644 index 000000000..2f0738158 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallingView.cpp @@ -0,0 +1,320 @@ + + +#include "phone/include/PhoneCallingView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + + static PhoneCallingView *g_pPhoneCallingView{nullptr}; + +#ifdef _WIN32 + const char *IMAGEANIMATOR1_1_PATH = "c:/Users/caiking/project/image_converter_tool/output/Phone/phone-call.bin"; +#else + const char *IMAGEANIMATOR1_1_PATH = "/user/res/Phone/phone-call.bin"; +#endif +#ifdef _WIN32 + const char *IMAGEANIMATOR1_2_PATH = "c:/Users/caiking/project/image_converter_tool/output/Phone/phone-call1.bin"; +#else + const char *IMAGEANIMATOR1_2_PATH = "/user/res/Phone/phone-call1.bin"; +#endif + + static ImageAnimatorInfo g_imageAnimator1Info[2] = { + {IMAGEANIMATOR1_1_PATH, {369, 207}, 52, 52, IMG_SRC_FILE_PATH}, + {IMAGEANIMATOR1_2_PATH, {369, 207}, 52, 52, IMG_SRC_FILE_PATH}, + }; + + PhoneCallingView::PhoneCallingView() + { + + g_pPhoneCallingView = this; + } + + PhoneCallingView::~PhoneCallingView() + { + DeInit(); + g_pPhoneCallingView = nullptr; + } + + PhoneCallingView *PhoneCallingView::GetInstance() + { + + return g_pPhoneCallingView; + } + + void PhoneCallingView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(203, 52); // widget's left position and top position + label1_->Resize(200, 60); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label1_->SetText("来电"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label1_); + label1_->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(104, 109); // widget's left position and top position + label2_->Resize(249, 40); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 40); + + // Set additional property + label2_->SetText("15576711544"); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + + // Add to rootView + container_->Add(label2_); + label2_->SetVisible(true); + + // Add Button to App + if (button2_ == nullptr) + { + button2_ = new UIButton(); + } + button2_->SetPosition(369, 207); // widget's left position and top position + button2_->Resize(52, 52); // widget's width and height + button2_->SetViewId(PHONECALLBUTTON); // Set style + button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + button2_->SetStyle(STYLE_IMAGE_OPA, 0); + + // Set additional property +#ifdef _WIN32 + char *button2defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Phone/phone-call.bin"; +#else + char *button2defaultImgSrc = "/user/res/Phone/phone-call.bin"; +#endif + char *button2triggeredImgSrc = nullptr; + button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc); + button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button2Click = static_cast(PhoneCallingPresenter::GetInstance()); + button2_->SetOnClickListener(button2Click); + // Add to rootView + container_->Add(button2_); + button2_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(158, 174); // widget's left position and top position + image1_->Resize(100, 100); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/boy.bin"; +#else + char *image1imagesPath = "/user/res/Phone/boy.bin"; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to rootView + container_->Add(image1_); + image1_->SetVisible(true); + + // Add Button to App + if (button1_ == nullptr) + { + button1_ = new UIButton(); + } + button1_->SetPosition(46, 207); // widget's left position and top position + button1_->Resize(52, 52); // widget's width and height + button1_->SetViewId(PHONEOFFBUTTON); // Set style + button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Phone/phone-off.bin"; +#else + char *button1defaultImgSrc = "/user/res/Phone/phone-off.bin"; +#endif + char *button1triggeredImgSrc = nullptr; + button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(PhoneCallingPresenter::GetInstance()); + button1_->SetOnClickListener(button1Click); + // Add to rootView + container_->Add(button1_); + button1_->SetVisible(true); + + // Add ImageAnimatorView to App + if (imageAnimator1_ == nullptr) + { + imageAnimator1_ = new UIImageAnimatorView(); + } + imageAnimator1_->SetPosition(369, 207); // widget's left position and top position + imageAnimator1_->Resize(52, 52); // widget's width and height + imageAnimator1_->SetViewId("imageAnimator1"); // Set style + imageAnimator1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + imageAnimator1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // Set additional property + imageAnimator1_->SetImageAnimatorSrc(g_imageAnimator1Info, 2, 200); + imageAnimator1_->SetTimeOfPause(200); + imageAnimator1_->SetRepeatTimes(1); + imageAnimator1_->SetReverse(true); + imageAnimator1_->Start(); + + // Add to rootView + container_->Add(imageAnimator1_); + imageAnimator1_->SetVisible(true); + + // Add Label to App + if (label3_ == nullptr) + { + label3_ = new UILabel(); + } + label3_->SetPosition(167, 353); // widget's left position and top position + label3_->Resize(132, 35); // widget's width and height + label3_->SetViewId("label3"); // Set style + label3_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label3_->SetText("挂断/接听"); + label3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label3_->SetTextColor(Color::GetColorFromRGBA(0xaa, 0xaa, 0xaa, 0xff)); + label3_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label3_->SetRollSpeed(0); + label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label3_); + label3_->SetVisible(true); + } + + void PhoneCallingView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (button2_ != nullptr) + { + delete button2_; + button2_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + if (imageAnimator1_ != nullptr) + { + delete imageAnimator1_; + imageAnimator1_ = nullptr; + } + if (label3_ != nullptr) + { + delete label3_; + label3_ = nullptr; + } + } + + UIView *PhoneCallingView::GetView() + { + Init(); + return container_; + } + + void PhoneCallingView::OnStart() + { + container_ = new UIScrollView(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(PhoneCallingPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void PhoneCallingView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void PhoneCallingView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void PhoneCallingView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallupPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallupPresenter.cpp new file mode 100644 index 000000000..d0a7179b6 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallupPresenter.cpp @@ -0,0 +1,75 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "phone/include/PhoneCallupPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static PhoneCallupPresenter *g_pPhoneCallupPresenter = nullptr; + + PhoneCallupPresenter::PhoneCallupPresenter() + { + + g_pPhoneCallupPresenter = this; + } + + PhoneCallupPresenter::~PhoneCallupPresenter() + { + + g_pPhoneCallupPresenter = nullptr; + } + + PhoneCallupPresenter *PhoneCallupPresenter::GetInstance() + { + + return g_pPhoneCallupPresenter; + } + + void PhoneCallupPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void PhoneCallupPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void PhoneCallupPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void PhoneCallupPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool PhoneCallupPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + // if (event.GetDragCallupection() == DragEvent::CallupECTION_RIGHT_TO_LEFT) + // { + // printf("draglistene is ok!\n"); + // NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + // } + UNUSED(view); + return true; + } + + bool PhoneCallupPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), OFFBUTTON) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallupView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallupView.cpp new file mode 100644 index 000000000..f1149256a --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneCallupView.cpp @@ -0,0 +1,305 @@ + + +#include "phone/include/PhoneCallupView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +#include "sys/time.h" +#include "securec.h" + +namespace OHOS +{ + + static PhoneCallupView *g_pPhoneCallupView{nullptr}; + static constexpr int16_t TIME_CONVERT = 60; // sec to min, and min to hor + static constexpr int16_t USEC_TO_MILLI = 1000; + static constexpr int16_t TEXT_BUFFER_SIEZ = 20; + + PhoneCallupView::PhoneCallupView() + { + g_pPhoneCallupView = this; + } + PhoneCallupView::~PhoneCallupView() + { + DeInit(); + animator_->~Animator(); + g_pPhoneCallupView = nullptr; + } + + PhoneCallupView *PhoneCallupView::GetInstance() + { + + return g_pPhoneCallupView; + } + void GetTime(char *buf, int len) + { + struct timeval tv; + gettimeofday(&tv, NULL); + uint32_t second = tv.tv_sec % TIME_CONVERT; + uint32_t minute = tv.tv_sec / TIME_CONVERT; + uint32_t hour = (minute / TIME_CONVERT) % 24; // 24: 24 hours per day + uint32_t realMilliSecond = tv.tv_usec / USEC_TO_MILLI; + minute = minute % TIME_CONVERT; + + sprintf_s(buf, len, "%02d : %02d", minute, second); + } + void PhoneAnimatorCallback::Callback(UIView *view) + { + (void)view; + char buf[TEXT_BUFFER_SIEZ] = {0}; + GetTime(buf, TEXT_BUFFER_SIEZ); + label_->SetText(buf); + RootView::GetInstance()->Invalidate(); + } + void PhoneCallupView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + char buf[TEXT_BUFFER_SIEZ] = {0}; + GetTime(buf, TEXT_BUFFER_SIEZ); + label2_->SetPosition(190, 52); // widget's left position and top position + label2_->Resize(85, 35); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 35); + // Set additional property + label2_->SetText(buf); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetTextColor(Color::GetColorFromRGBA(0xaa, 0xaa, 0xaa, 0xff)); + label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + // label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); + + // Add to rootView + callBack_ = new PhoneAnimatorCallback(label2_); + animator_ = new Animator(callBack_, label2_, 0, true); + animator_->Start(); + + container_->Add(label2_); + label2_->SetVisible(true); + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(109, 104); // widget's left position and top position + label1_->Resize(249, 40); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 40); + + // Set additional property + label1_->SetText("155 7671 1544"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + + container_->Add(label1_); + label1_->SetVisible(true); + + // Add ToggleButton to App + if (toggleButton1_ == nullptr) + { + toggleButton1_ = new UIToggleButton(); + } + toggleButton1_->SetPosition(46, 207); // widget's left position and top position + toggleButton1_->Resize(52, 52); // widget's width and height + toggleButton1_->SetViewId("toggleButton1"); // Set style + toggleButton1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *toggleButton1selectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/microphone.bin"; +#else + char *toggleButton1selectedImg = "/user/res/Phone/microphone.bin"; +#endif +#ifdef _WIN32 + char *toggleButton1unSelectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/microphone-no.bin"; +#else + char *toggleButton1unSelectedImg = "/user/res/Phone/microphone-no.bin"; +#endif + toggleButton1_->SetImages(toggleButton1selectedImg, toggleButton1unSelectedImg); + + // Add to rootView + container_->Add(toggleButton1_); + toggleButton1_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(158, 158); // widget's left position and top position + image1_->Resize(100, 100); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/boy.bin"; +#else + char *image1imagesPath = "/user/res/Phone/boy.bin"; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to rootView + container_->Add(image1_); + image1_->SetVisible(true); + + // Add ToggleButton to App + if (toggleButton2_ == nullptr) + { + toggleButton2_ = new UIToggleButton(); + } + toggleButton2_->SetPosition(369, 207); // widget's left position and top position + toggleButton2_->Resize(52, 52); // widget's width and height + toggleButton2_->SetViewId("toggleButton2"); // Set style + toggleButton2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *toggleButton2selectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/voice.bin"; +#else + char *toggleButton2selectedImg = "/user/res/Phone/voice.bin"; +#endif +#ifdef _WIN32 + char *toggleButton2unSelectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/voice-no.bin"; +#else + char *toggleButton2unSelectedImg = "/user/res/Phone/voice-no.bin"; +#endif + toggleButton2_->SetImages(toggleButton2selectedImg, toggleButton2unSelectedImg); + + // Add to rootView + container_->Add(toggleButton2_); + toggleButton2_->SetVisible(true); + + // Add Button to App + if (button1_ == nullptr) + { + button1_ = new UIButton(); + } + button1_->SetPosition(188, 340); // widget's left position and top position + button1_->Resize(90, 90); // widget's width and height + button1_->SetViewId(OFFBUTTON); // Set style + + // Set additional property +#ifdef _WIN32 + char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Phone/phone-off-round.bin"; +#else + char *button1defaultImgSrc = "/user/res/Phone/phone-off-round.bin"; +#endif + char *button1triggeredImgSrc = nullptr; + button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(PhoneCallupPresenter::GetInstance()); + button1_->SetOnClickListener(button1Click); + // Add to rootView + container_->Add(button1_); + button1_->SetVisible(true); + } + + void PhoneCallupView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (toggleButton1_ != nullptr) + { + delete toggleButton1_; + toggleButton1_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (toggleButton2_ != nullptr) + { + delete toggleButton2_; + toggleButton2_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + } + + UIView *PhoneCallupView::GetView() + { + Init(); + return container_; + } + void PhoneCallupView::OnStart() + { + container_ = new UIScrollView(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(PhoneCallupPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void PhoneCallupView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void PhoneCallupView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void PhoneCallupView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneDirPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneDirPresenter.cpp new file mode 100644 index 000000000..2fe8fed3c --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneDirPresenter.cpp @@ -0,0 +1,72 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "phone/include/PhoneDirPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static PhoneDirPresenter *g_pPhoneDirPresenter = nullptr; + + PhoneDirPresenter::PhoneDirPresenter() + { + + g_pPhoneDirPresenter = this; + } + + PhoneDirPresenter::~PhoneDirPresenter() + { + + g_pPhoneDirPresenter = nullptr; + } + + PhoneDirPresenter *PhoneDirPresenter::GetInstance() + { + + return g_pPhoneDirPresenter; + } + + void PhoneDirPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void PhoneDirPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void PhoneDirPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void PhoneDirPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool PhoneDirPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT) + { + printf("draglistene is ok!\n"); + NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + } + UNUSED(view); + return true; + } + + bool PhoneDirPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + // if (strcmp(view.GetViewId(), 控件ID) == 0) + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneDirView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneDirView.cpp new file mode 100644 index 000000000..f67a486b5 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneDirView.cpp @@ -0,0 +1,635 @@ + + +#include "phone/include/PhoneDirView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +#include "components/ui_label_button.h" +namespace OHOS +{ + + static PhoneDirView *g_pPhoneDirView{nullptr}; + + PhoneDirView::PhoneDirView() + { + + g_pPhoneDirView = this; + } + + PhoneDirView::~PhoneDirView() + { + DeInit(); + g_pPhoneDirView = nullptr; + } + + PhoneDirView *PhoneDirView::GetInstance() + { + + return g_pPhoneDirView; + } +#if 0 + void PhoneDirView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add ScrollView to App + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); // widget's left position and top position + scrollView1_->Resize(466, 466); // widget's width and height + scrollView1_->SetViewId("scrollView1"); // Set style + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // Set additional property + + // Add to rootView + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(158, 52); // widget's left position and top position + label1_->Resize(200, 60); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label1_->SetText("常用联系人"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label1_); + label1_->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(51, 291); // widget's left position and top position + label2_->Resize(400, 124); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 26); + + // Set additional property + label2_->SetText("未添加联系人,请前往“小希爱\n玩”APP进行设置"); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + + // Add to scrollView1 + scrollView1_->Add(label2_); + label2_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(158, 120); // widget's left position and top position + image1_->Resize(150, 150); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/PhoneDir/PhoneDirdir.bin"; +#else + char *image1imagesPath = "/user/res/Phone/phonedir.bin"; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to scrollView1 + scrollView1_->Add(image1_); + image1_->SetVisible(true); + } + + void PhoneDirView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + } + +#endif + void PhoneDirView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add ScrollView to App + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); // widget's left position and top position + scrollView1_->Resize(466, 466); // widget's width and height + scrollView1_->SetViewId("scrollView1"); // Set style + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // Set additional property + + // Add the CallBack about events + UIView::OnDragListener *scrollView1Drag = static_cast(PhoneDirPresenter::GetInstance()); + scrollView1_->SetOnDragListener(scrollView1Drag); + // Add to rootView + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(158, 52); // widget's left position and top position + label1_->Resize(200, 60); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label1_->SetText("常用联系人"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label1_); + label1_->SetVisible(true); + + // Add LabelButtonExt to App + if (labelButton8_ == nullptr) + { + labelButton8_ = new UILabelButtonExt(); + } + labelButton8_->SetPosition(43, 243); // widget's left position and top position + labelButton8_->Resize(380, 100); // widget's width and height + labelButton8_->SetViewId("labelButton2"); // Set style + labelButton8_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + + // Set additional property + labelButton8_->SetText("蔡小小"); + labelButton8_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + labelButton8_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *labelButton8Click = static_cast(PhoneDirPresenter::GetInstance()); + labelButton8_->SetOnClickListener(labelButton8Click); + // Add to scrollView1 + scrollView1_->Add(labelButton8_); + labelButton8_->SetVisible(true); + + // Add ImageView to App + if (image2_ == nullptr) + { + image2_ = new UIImageView(); + } + image2_->SetPosition(82, 260); // widget's left position and top position + image2_->Resize(89, 80); // widget's width and height + image2_->SetViewId("image2"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image2imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-boy.bin"; +#else + char *image2imagesPath = "/user/res/Phone/little-boy.bin"; +#endif + image2_->SetSrc(image2imagesPath); + + // Add to scrollView1 + scrollView1_->Add(image2_); + image2_->SetVisible(true); + + // Add LabelButtonExt to App + if (labelButton9_ == nullptr) + { + labelButton9_ = new UILabelButtonExt(); + } + labelButton9_->SetPosition(43, 363); // widget's left position and top position + labelButton9_->Resize(380, 100); // widget's width and height + labelButton9_->SetViewId("labelButton3"); // Set style + labelButton9_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + + // Set additional property + labelButton9_->SetText("坤钟"); + labelButton9_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + labelButton9_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *labelButton9Click = static_cast(PhoneDirPresenter::GetInstance()); + labelButton9_->SetOnClickListener(labelButton9Click); + // Add to scrollView1 + scrollView1_->Add(labelButton9_); + labelButton9_->SetVisible(true); + + // Add ImageView to App + if (image3_ == nullptr) + { + image3_ = new UIImageView(); + } + image3_->SetPosition(86, 381); // widget's left position and top position + image3_->Resize(100, 100); // widget's width and height + image3_->SetViewId("image3"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image3imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-boy.bin"; +#else + char *image3imagesPath = "/user/res/Phone/little-boy.bin"; +#endif + image3_->SetSrc(image3imagesPath); + + // Add to scrollView1 + scrollView1_->Add(image3_); + image3_->SetVisible(true); + + // Add LabelButtonExt to App + if (labelButton10_ == nullptr) + { + labelButton10_ = new UILabelButtonExt(); + } + labelButton10_->SetPosition(43, 483); // widget's left position and top position + labelButton10_->Resize(380, 100); // widget's width and height + labelButton10_->SetViewId("labelButton4"); // Set style + labelButton10_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + + // Set additional property + labelButton10_->SetText("萧炎"); + labelButton10_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + labelButton10_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *labelButton10Click = static_cast(PhoneDirPresenter::GetInstance()); + labelButton10_->SetOnClickListener(labelButton10Click); + // Add to scrollView1 + scrollView1_->Add(labelButton10_); + labelButton10_->SetVisible(true); + + // Add ImageView to App + if (image5_ == nullptr) + { + image5_ = new UIImageView(); + } + image5_->SetPosition(92, 499); // widget's left position and top position + image5_->Resize(100, 100); // widget's width and height + image5_->SetViewId("image5"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image5imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-girl.bin"; +#else + char *image5imagesPath = "/user/res/Phone/little-girl.bin"; +#endif + image5_->SetSrc(image5imagesPath); + + // Add to scrollView1 + scrollView1_->Add(image5_); + image5_->SetVisible(true); + + // Add ImageView to App + if (image7_ == nullptr) + { + image7_ = new UIImageView(); + } + image7_->SetPosition(167, -106); // widget's left position and top position + image7_->Resize(100, 100); // widget's width and height + image7_->SetViewId("image7"); // Set style + + // Set additional property + + // Add to scrollView1 + scrollView1_->Add(image7_); + image7_->SetVisible(true); + + // Add LabelButtonExt to App + if (labelButton13_ == nullptr) + { + labelButton13_ = new UILabelButtonExt(); + } + labelButton13_->SetPosition(43, 723); // widget's left position and top position + labelButton13_->Resize(380, 100); // widget's width and height + labelButton13_->SetViewId("labelButton6"); // Set style + labelButton13_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + + // Set additional property + labelButton13_->SetText("五月天"); + labelButton13_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + labelButton13_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *labelButton13Click = static_cast(PhoneDirPresenter::GetInstance()); + labelButton13_->SetOnClickListener(labelButton13Click); + // Add to scrollView1 + scrollView1_->Add(labelButton13_); + labelButton13_->SetVisible(true); + + // Add ImageView to App + if (image9_ == nullptr) + { + image9_ = new UIImageView(); + } + image9_->SetPosition(100, 745); // widget's left position and top position + image9_->Resize(100, 100); // widget's width and height + image9_->SetViewId("image9"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image9imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-boy.bin"; +#else + char *image9imagesPath = "/user/res/Phone/little-boy.bin"; +#endif + image9_->SetSrc(image9imagesPath); + + // Add to scrollView1 + scrollView1_->Add(image9_); + image9_->SetVisible(true); + + // Add ImageView to App + if (image8_ == nullptr) + { + image8_ = new UIImageView(); + } + image8_->SetPosition(183, 874); // widget's left position and top position + image8_->Resize(100, 100); // widget's width and height + image8_->SetViewId("image8"); // Set style + + // Set additional property + + // Add to scrollView1 + scrollView1_->Add(image8_); + image8_->SetVisible(true); + + // Add LabelButtonExt to App + if (labelButton11_ == nullptr) + { + labelButton11_ = new UILabelButtonExt(); + } + labelButton11_->SetPosition(43, 603); // widget's left position and top position + labelButton11_->Resize(380, 100); // widget's width and height + labelButton11_->SetViewId("labelButton5"); // Set style + labelButton11_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + + // Set additional property + labelButton11_->SetText("舒芸芸"); + labelButton11_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + labelButton11_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *labelButton11Click = static_cast(PhoneDirPresenter::GetInstance()); + labelButton11_->SetOnClickListener(labelButton11Click); + // Add to scrollView1 + scrollView1_->Add(labelButton11_); + labelButton11_->SetVisible(true); + + // Add ImageView to App + if (image6_ == nullptr) + { + image6_ = new UIImageView(); + } + image6_->SetPosition(95, 617); // widget's left position and top position + image6_->Resize(100, 100); // widget's width and height + image6_->SetViewId("image6"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image6imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-girl.bin"; +#else + char *image6imagesPath = "/user/res/Phone/little-girl.bin"; +#endif + image6_->SetSrc(image6imagesPath); + + // Add to scrollView1 + scrollView1_->Add(image6_); + image6_->SetVisible(true); + + // Add LabelButtonExt to App + if (labelButton7_ == nullptr) + { + labelButton7_ = new UILabelButtonExt(); + } + labelButton7_->SetPosition(43, 123); // widget's left position and top position + labelButton7_->Resize(380, 100); // widget's width and height + labelButton7_->SetViewId("labelButton1"); // Set style + labelButton7_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + + // Set additional property + labelButton7_->SetText("小梦同学(客服热线)"); + labelButton7_->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff)); + labelButton7_->SetAlign(TEXT_ALIGNMENT_RIGHT); + labelButton7_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + labelButton7_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *labelButton7Click = static_cast(PhoneDirPresenter::GetInstance()); + labelButton7_->SetOnClickListener(labelButton7Click); + // Add to scrollView1 + scrollView1_->Add(labelButton7_); + labelButton7_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(76, 141); // widget's left position and top position + image1_->Resize(100, 100); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-girl.bin"; +#else + char *image1imagesPath = "/user/res/Phone/little-girl.bin"; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to scrollView1 + scrollView1_->Add(image1_); + image1_->SetVisible(true); + } + + void PhoneDirView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (labelButton8_ != nullptr) + { + delete labelButton8_; + labelButton8_ = nullptr; + } + if (image2_ != nullptr) + { + delete image2_; + image2_ = nullptr; + } + if (labelButton9_ != nullptr) + { + delete labelButton9_; + labelButton9_ = nullptr; + } + if (image3_ != nullptr) + { + delete image3_; + image3_ = nullptr; + } + if (labelButton10_ != nullptr) + { + delete labelButton10_; + labelButton10_ = nullptr; + } + if (image5_ != nullptr) + { + delete image5_; + image5_ = nullptr; + } + if (image7_ != nullptr) + { + delete image7_; + image7_ = nullptr; + } + if (labelButton13_ != nullptr) + { + delete labelButton13_; + labelButton13_ = nullptr; + } + if (image9_ != nullptr) + { + delete image9_; + image9_ = nullptr; + } + if (image8_ != nullptr) + { + delete image8_; + image8_ = nullptr; + } + if (labelButton11_ != nullptr) + { + delete labelButton11_; + labelButton11_ = nullptr; + } + if (image6_ != nullptr) + { + delete image6_; + image6_ = nullptr; + } + if (labelButton7_ != nullptr) + { + delete labelButton7_; + labelButton7_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + } + UIView *PhoneDirView::GetView() + { + Init(); + return container_; + } + void PhoneDirView::OnStart() + { + container_ = new UIScrollView(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(PhoneDirPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void PhoneDirView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void PhoneDirView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void PhoneDirView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhonePresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhonePresenter.cpp new file mode 100644 index 000000000..bec5520be --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhonePresenter.cpp @@ -0,0 +1,80 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "phone/include/PhonePresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static PhonePresenter *g_pPhonePresenter = nullptr; + + PhonePresenter::PhonePresenter() + { + + g_pPhonePresenter = this; + } + + PhonePresenter::~PhonePresenter() + { + + g_pPhonePresenter = nullptr; + } + + PhonePresenter *PhonePresenter::GetInstance() + { + + return g_pPhonePresenter; + } + + void PhonePresenter::OnStart() + { + + Presenter::OnStart(); + } + + void PhonePresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void PhonePresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void PhonePresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool PhonePresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + } + UNUSED(view); + return true; + } + + bool PhonePresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + // if (strcmp(view.GetViewId(), 控件ID) == 0) + if (strcmp(view.GetViewId(), RINGBUTTON) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_PHONEDIR); + } + if (strcmp(view.GetViewId(), CALLBUTTON) == 0) + { + printf("phonecall!\n"); + NativeAbility::GetInstance().ChangeSlice(VIEW_PHONECALL); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneRingPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneRingPresenter.cpp new file mode 100644 index 000000000..b4c81ff32 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneRingPresenter.cpp @@ -0,0 +1,75 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "phone/include/PhoneRingPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static PhoneRingPresenter *g_pPhoneRingPresenter = nullptr; + + PhoneRingPresenter::PhoneRingPresenter() + { + + g_pPhoneRingPresenter = this; + } + + PhoneRingPresenter::~PhoneRingPresenter() + { + + g_pPhoneRingPresenter = nullptr; + } + + PhoneRingPresenter *PhoneRingPresenter::GetInstance() + { + + return g_pPhoneRingPresenter; + } + + void PhoneRingPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void PhoneRingPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void PhoneRingPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void PhoneRingPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool PhoneRingPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + // if (event.GetDragCallupection() == DragEvent::CallupECTION_RIGHT_TO_LEFT) + // { + // printf("draglistene is ok!\n"); + // NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + // } + UNUSED(view); + return true; + } + + bool PhoneRingPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), OFFBUTTON) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneRingView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneRingView.cpp new file mode 100644 index 000000000..8a5041ad4 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneRingView.cpp @@ -0,0 +1,278 @@ + + +#include "phone/include/PhoneRingView.h" +#include "phone/include/PhoneCallPresenter.h" +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + + static PhoneRingView *g_pPhoneRingView{nullptr}; + + PhoneRingView::PhoneRingView() + { + + g_pPhoneRingView = this; + } + + PhoneRingView::~PhoneRingView() + { + DeInit(); + g_pPhoneRingView = nullptr; + } + + PhoneRingView *PhoneRingView::GetInstance() + { + + return g_pPhoneRingView; + } + + void PhoneRingView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(190, 52); // widget's left position and top position + label2_->Resize(85, 35); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label2_->SetText("拨号中..."); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetTextColor(Color::GetColorFromRGBA(0xaa, 0xaa, 0xaa, 0xff)); + label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label2_); + label2_->SetVisible(true); + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(109, 104); // widget's left position and top position + label1_->Resize(249, 40); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 40); + + // Set additional property + label1_->SetText(PhoneCallPresenter::GetInstance()->phoneNumber.c_str()); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + + // Add to rootView + container_->Add(label1_); + label1_->SetVisible(true); + + // Add ToggleButton to App + if (toggleButton1_ == nullptr) + { + toggleButton1_ = new UIToggleButton(); + } + toggleButton1_->SetPosition(46, 207); // widget's left position and top position + toggleButton1_->Resize(52, 52); // widget's width and height + toggleButton1_->SetViewId("toggleButton1"); // Set style + toggleButton1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *toggleButton1selectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/microphone.bin"; +#else + char *toggleButton1selectedImg = "/user/res/Phone/microphone.bin"; +#endif +#ifdef _WIN32 + char *toggleButton1unSelectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/microphone-no.bin"; +#else + char *toggleButton1unSelectedImg = "/user/res/Phone/microphone-no.bin"; +#endif + toggleButton1_->SetImages(toggleButton1selectedImg, toggleButton1unSelectedImg); + + // Add to rootView + container_->Add(toggleButton1_); + toggleButton1_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(158, 158); // widget's left position and top position + image1_->Resize(100, 100); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/girl.bin"; +#else + char *image1imagesPath = "/user/res/Phone/girl.bin"; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to rootView + container_->Add(image1_); + image1_->SetVisible(true); + + // Add ToggleButton to App + if (toggleButton2_ == nullptr) + { + toggleButton2_ = new UIToggleButton(); + } + toggleButton2_->SetPosition(369, 207); // widget's left position and top position + toggleButton2_->Resize(52, 52); // widget's width and height + toggleButton2_->SetViewId("toggleButton2"); // Set style + toggleButton2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *toggleButton2selectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/voice.bin"; +#else + char *toggleButton2selectedImg = "/user/res/Phone/voice.bin"; +#endif +#ifdef _WIN32 + char *toggleButton2unSelectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/voice-no.bin"; +#else + char *toggleButton2unSelectedImg = "/user/res/Phone/voice-no.bin"; +#endif + toggleButton2_->SetImages(toggleButton2selectedImg, toggleButton2unSelectedImg); + + // Add to rootView + container_->Add(toggleButton2_); + toggleButton2_->SetVisible(true); + + // Add Button to App + if (button1_ == nullptr) + { + button1_ = new UIButton(); + } + button1_->SetPosition(188, 340); // widget's left position and top position + button1_->Resize(90, 90); // widget's width and height + button1_->SetViewId("button1"); // Set style + + // Set additional property +#ifdef _WIN32 + char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Phone/phone-off-round.bin"; +#else + char *button1defaultImgSrc = "/user/res/Phone/phone-off-round.bin"; +#endif + char *button1triggeredImgSrc = nullptr; + button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(PhoneRingPresenter::GetInstance()); + button1_->SetOnClickListener(button1Click); + // Add to rootView + container_->Add(button1_); + button1_->SetVisible(true); + } + + void PhoneRingView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (toggleButton1_ != nullptr) + { + delete toggleButton1_; + toggleButton1_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (toggleButton2_ != nullptr) + { + delete toggleButton2_; + toggleButton2_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + } + + UIView *PhoneRingView::GetView() + { + Init(); + return container_; + } + void PhoneRingView::OnStart() + { + container_ = new UIScrollView(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(PhoneRingPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void PhoneRingView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void PhoneRingView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void PhoneRingView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneView.cpp new file mode 100644 index 000000000..fe18a2ba2 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/phone/src/PhoneView.cpp @@ -0,0 +1,626 @@ + + +#include "phone/include/PhoneView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + + static PhoneView *g_pPhoneView{nullptr}; + + PhoneView::PhoneView() + { + + g_pPhoneView = this; + } + + PhoneView::~PhoneView() + { + DeInit(); + g_pPhoneView = nullptr; + } + + PhoneView *PhoneView::GetInstance() + { + + return g_pPhoneView; + } + + void PhoneView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add ScrollView to App + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); // widget's left position and top position + scrollView1_->Resize(466, 466); // widget's width and height + scrollView1_->SetViewId("scrollView1"); // Set style + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // Set additional property + + // Add the CallBack about events + UIView::OnDragListener *scrollView1Drag = static_cast(PhonePresenter::GetInstance()); + scrollView1_->SetOnDragListener(scrollView1Drag); + // Add to rootView + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(203, 52); // widget's left position and top position + label1_->Resize(200, 60); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label1_->SetText("电话"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label1_); + label1_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(183, -73); // widget's left position and top position + image1_->Resize(100, 100); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Set additional property + + // Add to scrollView1 + scrollView1_->Add(image1_); + image1_->SetVisible(true); + + // Add Button to App + if (button2_ == nullptr) + { + button2_ = new UIButton(); + } + button2_->SetPosition(263, 116); // widget's left position and top position + button2_->Resize(140, 140); // widget's width and height + button2_->SetViewId("Call"); // Set style + button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *button2defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Phone/Phone_Call.bin"; +#else + char *button2defaultImgSrc = "/user/res/Phone/Phone_Call.bin"; +#endif + char *button2triggeredImgSrc = nullptr; + button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc); + button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button2Click = static_cast(PhonePresenter::GetInstance()); + button2_->SetOnClickListener(button2Click); + // Add to scrollView1 + scrollView1_->Add(button2_); + button2_->SetVisible(true); + + // Add Button to App + if (button1_ == nullptr) + { + button1_ = new UIButton(); + } + button1_->SetPosition(63, 116); // widget's left position and top position + button1_->Resize(140, 140); // widget's width and height + button1_->SetViewId("Ring"); // Set style + button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Phone/ring.bin"; +#else + char *button1defaultImgSrc = "/user/res/Phone/Phone_Ring.bin"; +#endif + char *button1triggeredImgSrc = nullptr; + button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(PhonePresenter::GetInstance()); + button1_->SetOnClickListener(button1Click); + // Add to scrollView1 + scrollView1_->Add(button1_); + button1_->SetVisible(true); + + // Add Button to App + if (button5_ == nullptr) + { + button5_ = new UIButton(); + } + button5_->SetPosition(54, 358); // widget's left position and top position + button5_->Resize(390, 104); // widget's width and height + button5_->SetViewId("test1"); // Set style + button5_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + + // Set additional property + button5_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button5Click = static_cast(PhonePresenter::GetInstance()); + button5_->SetOnClickListener(button5Click); + // Add to scrollView1 + scrollView1_->Add(button5_); + button5_->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(173, 290); // widget's left position and top position + label2_->Resize(200, 60); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 30); + + // 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, 30); + + // Add to scrollView1 + scrollView1_->Add(label2_); + label2_->SetVisible(true); + + // Add Label to App + if (label3_ == nullptr) + { + label3_ = new UILabel(); + } + label3_->SetPosition(83, 379); // widget's left position and top position + label3_->Resize(200, 60); // widget's width and height + label3_->SetViewId("label3"); // Set style + label3_->SetStyle(STYLE_TEXT_FONT, 35); + + // Set additional property + label3_->SetText("138 8888 4270"); + label3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label3_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label3_->SetRollSpeed(0); + label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); + + // Add to scrollView1 + scrollView1_->Add(label3_); + label3_->SetVisible(true); + + // Add Label to App + if (label4_ == nullptr) + { + label4_ = new UILabel(); + } + label4_->SetPosition(87, 420); // widget's left position and top position + label4_->Resize(200, 60); // widget's width and height + label4_->SetViewId("label4"); // Set style + label4_->SetStyle(STYLE_TEXT_FONT, 20); + + // Set additional property + label4_->SetText("2023-11-11 14:56"); + label4_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label4_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label4_->SetRollSpeed(0); + label4_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + + // Add to scrollView1 + scrollView1_->Add(label4_); + label4_->SetVisible(true); + + // Add Label to App + if (label9_ == nullptr) + { + label9_ = new UILabel(); + } + label9_->SetPosition(262, 419); // widget's left position and top position + label9_->Resize(200, 60); // widget's width and height + label9_->SetViewId("label5"); // Set style + label9_->SetStyle(STYLE_TEXT_FONT, 20); + + // Set additional property + label9_->SetText("拨入来电"); + label9_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label9_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label9_->SetRollSpeed(0); + label9_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + + // Add to scrollView1 + scrollView1_->Add(label9_); + label9_->SetVisible(true); + + // Add Label to App + if (label14_ == nullptr) + { + label14_ = new UILabel(); + } + label14_->SetPosition(62, 850); // widget's left position and top position + label14_->Resize(200, 60); // widget's width and height + label14_->SetViewId("label14"); // Set style + label14_->SetStyle(STYLE_TEXT_FONT, 26); + + // Set additional property + label14_->SetText("注:只保留最近20条通话记录"); + label14_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label14_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + label14_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label14_->SetRollSpeed(0); + label14_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + + // Add to scrollView1 + scrollView1_->Add(label14_); + label14_->SetVisible(true); + + // Add Button to App + if (button3_ == nullptr) + { + button3_ = new UIButton(); + } + button3_->SetPosition(54, 482); // widget's left position and top position + button3_->Resize(390, 104); // widget's width and height + button3_->SetViewId("test2"); // Set style + button3_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + + // Set additional property + button3_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff4266c3, UIButton::PRESSED); + button3_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button3Click = static_cast(PhonePresenter::GetInstance()); + button3_->SetOnClickListener(button3Click); + // Add to scrollView1 + scrollView1_->Add(button3_); + button3_->SetVisible(true); + + // Add Label to App + if (label13_ == nullptr) + { + label13_ = new UILabel(); + } + label13_->SetPosition(90, 537); // widget's left position and top position + label13_->Resize(200, 60); // widget's width and height + label13_->SetViewId("label4"); // Set style + label13_->SetStyle(STYLE_TEXT_FONT, 20); + + // Set additional property + label13_->SetText("2023-11-10 17:00"); + label13_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label13_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label13_->SetRollSpeed(0); + label13_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + + // Add to scrollView1 + scrollView1_->Add(label13_); + label13_->SetVisible(true); + + // Add Label to App + if (label12_ == nullptr) + { + label12_ = new UILabel(); + } + label12_->SetPosition(86, 491); // widget's left position and top position + label12_->Resize(200, 60); // widget's width and height + label12_->SetViewId("label3"); // Set style + label12_->SetStyle(STYLE_TEXT_FONT, 35); + + // Set additional property + label12_->SetText("0734 5411 6565"); + label12_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label12_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label12_->SetRollSpeed(0); + label12_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); + + // Add to scrollView1 + scrollView1_->Add(label12_); + label12_->SetVisible(true); + + // Add Label to App + if (label10_ == nullptr) + { + label10_ = new UILabel(); + } + label10_->SetPosition(269, 536); // widget's left position and top position + label10_->Resize(200, 60); // widget's width and height + label10_->SetViewId("lable10"); // Set style + label10_->SetStyle(STYLE_TEXT_FONT, 20); + + // Set additional property + label10_->SetText("未接来电"); + label10_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label10_->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); + label10_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label10_->SetRollSpeed(0); + label10_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + + // Add to scrollView1 + scrollView1_->Add(label10_); + label10_->SetVisible(true); + + // Add Button to App + if (button7_ == nullptr) + { + button7_ = new UIButton(); + } + button7_->SetPosition(54, 603); // widget's left position and top position + button7_->Resize(390, 104); // widget's width and height + button7_->SetViewId("test3"); // Set style + button7_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + button7_->SetStyle(STYLE_BORDER_RADIUS, 52); + + // Set additional property + button7_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + button7_->SetStyleForState(STYLE_BORDER_RADIUS, 52, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button7Click = static_cast(PhonePresenter::GetInstance()); + button7_->SetOnClickListener(button7Click); + // Add to scrollView1 + scrollView1_->Add(button7_); + button7_->SetVisible(true); + + // Add Label to App + if (label11_ == nullptr) + { + label11_ = new UILabel(); + } + label11_->SetPosition(89, 650); // widget's left position and top position + label11_->Resize(200, 60); // widget's width and height + label11_->SetViewId("label11"); // Set style + label11_->SetStyle(STYLE_TEXT_FONT, 20); + + // Set additional property + label11_->SetText("2023-11-9 12:00"); + label11_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label11_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label11_->SetRollSpeed(0); + label11_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + + // Add to scrollView1 + scrollView1_->Add(label11_); + label11_->SetVisible(true); + + // Add Label to App + if (label16_ == nullptr) + { + label16_ = new UILabel(); + } + label16_->SetPosition(86, 613); // widget's left position and top position + label16_->Resize(200, 60); // widget's width and height + label16_->SetViewId("label11"); // Set style + label16_->SetStyle(STYLE_TEXT_FONT, 26); + + // Set additional property + label16_->SetText("小梦同学"); + label16_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label16_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label16_->SetRollSpeed(0); + label16_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + + // Add to scrollView1 + scrollView1_->Add(label16_); + label16_->SetVisible(true); + + // Add Label to App + if (label15_ == nullptr) + { + label15_ = new UILabel(); + } + label15_->SetPosition(257, 650); // widget's left position and top position + label15_->Resize(200, 60); // widget's width and height + label15_->SetViewId("label11"); // Set style + label15_->SetStyle(STYLE_TEXT_FONT, 20); + + // Set additional property + label15_->SetText("拨出电话"); + label15_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label15_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label15_->SetRollSpeed(0); + label15_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + + // Add to scrollView1 + scrollView1_->Add(label15_); + label15_->SetVisible(true); + + // Add ImageView to App + if (image3_ == nullptr) + { + image3_ = new UIImageView(); + } + image3_->SetPosition(183, 927); // widget's left position and top position + image3_->Resize(100, 100); // widget's width and height + image3_->SetViewId("image3"); // Set style + + // Set additional property + + // Add to scrollView1 + scrollView1_->Add(image3_); + image3_->SetVisible(true); + } + + void PhoneView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (button2_ != nullptr) + { + delete button2_; + button2_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + if (button5_ != nullptr) + { + delete button5_; + button5_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (label3_ != nullptr) + { + delete label3_; + label3_ = nullptr; + } + if (label4_ != nullptr) + { + delete label4_; + label4_ = nullptr; + } + if (label9_ != nullptr) + { + delete label9_; + label9_ = nullptr; + } + if (label14_ != nullptr) + { + delete label14_; + label14_ = nullptr; + } + if (button3_ != nullptr) + { + delete button3_; + button3_ = nullptr; + } + if (label13_ != nullptr) + { + delete label13_; + label13_ = nullptr; + } + if (label12_ != nullptr) + { + delete label12_; + label12_ = nullptr; + } + if (label10_ != nullptr) + { + delete label10_; + label10_ = nullptr; + } + if (button7_ != nullptr) + { + delete button7_; + button7_ = nullptr; + } + if (label11_ != nullptr) + { + delete label11_; + label11_ = nullptr; + } + if (label16_ != nullptr) + { + delete label16_; + label16_ = nullptr; + } + if (label15_ != nullptr) + { + delete label15_; + label15_ = nullptr; + } + if (image3_ != nullptr) + { + delete image3_; + image3_ = nullptr; + } + } + + UIView *PhoneView::GetView() + { + Init(); + return container_; + } + void PhoneView::OnStart() + { + container_ = new UIScrollView(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(PhonePresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void PhoneView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void PhoneView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void PhoneView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/quickaccess/include/QuickAccessPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/quickaccess/include/QuickAccessPresenter.h new file mode 100644 index 000000000..6e34df34b --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/quickaccess/include/QuickAccessPresenter.h @@ -0,0 +1,39 @@ +#ifndef QUICK_ACCESS_PRESENTER_H +#define QUICK_ACCESS_PRESENTER_H + +#include "Presenter.h" + +#include "QuickAccessView.h" + +namespace OHOS +{ + class QuickAccessView; + + class QuickAccessPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + QuickAccessPresenter(); + virtual ~QuickAccessPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static QuickAccessPresenter *GetInstance(); + + private: + //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} //namespace OHOS + + + + + + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/quickaccess/include/QuickAccessView.h b/code/sdk/application/wearable/nativeapp/nativeui/quickaccess/include/QuickAccessView.h new file mode 100644 index 000000000..13a154e62 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/quickaccess/include/QuickAccessView.h @@ -0,0 +1,51 @@ +#ifndef QUICK_ACCESS_VIEW_H +#define QUICK_ACCESS_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_image_view.h" +#include "components/ui_label.h" +#include "components/ui_checkbox.h" +namespace OHOS +{ + static const char *HEART_RATE_DETECTION = "HeartRateDetectionCheckBox"; //心率检测 + static const char *BLOOD_OXYGEN_MONITOR = "BloodOxygenMonitoringCheckBox"; //血氧检测 + + class QuickAccessPresenter; + class QuickAccessView : public View + { + + public: + QuickAccessView(); + virtual ~QuickAccessView(); + static QuickAccessView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + + private: + UIViewGroup *container_ = nullptr; + UIScrollView *QuickAccessScrollView = nullptr; + UIImageView *image1 = nullptr; + UILabel *QuickAccessLabel = nullptr; + UIImageView *image2 = nullptr; + UILabel *label = nullptr; + UIImageView *HeartRateDetectionImage = nullptr; + UICheckBox *HeartRateDetectionCheckBox = nullptr; + UILabel *HeartRateDetectionLabel = nullptr; + UIImageView *BloodOxygenMonitoringImage = nullptr; + UICheckBox *BloodOxygenMonitoringCheckBox = nullptr; + UILabel *BloodOxygenMonitoringLabel = nullptr; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/quickaccess/src/QuickAccessPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/quickaccess/src/QuickAccessPresenter.cpp new file mode 100644 index 000000000..d94129e1b --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/quickaccess/src/QuickAccessPresenter.cpp @@ -0,0 +1,84 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" + +#include "quickaccess/include/QuickAccessPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static QuickAccessPresenter *g_pQuickAccessPresenter = nullptr; + + QuickAccessPresenter::QuickAccessPresenter() + { + + g_pQuickAccessPresenter = this; + } + + QuickAccessPresenter::~QuickAccessPresenter() + { + + g_pQuickAccessPresenter = nullptr; + } + + QuickAccessPresenter *QuickAccessPresenter::GetInstance() + { + + return g_pQuickAccessPresenter; + } + + void QuickAccessPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void QuickAccessPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void QuickAccessPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void QuickAccessPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool QuickAccessPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); + return true; + } + return false; + } + + bool QuickAccessPresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), HEART_RATE_DETECTION) == 0) + { + printf("<心率检测>\n"); + return true; + } + else if(strcmp(view.GetViewId(), BLOOD_OXYGEN_MONITOR) == 0) + { + printf("<血氧检测>\n"); + return true; + } + return false; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/quickaccess/src/QuickAccessView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/quickaccess/src/QuickAccessView.cpp new file mode 100644 index 000000000..338f80bfb --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/quickaccess/src/QuickAccessView.cpp @@ -0,0 +1,310 @@ +#include "UiConfig.h" + +#include "quickaccess/include/QuickAccessView.h" +#include "quickaccess/include/QuickAccessPresenter.h" +namespace OHOS +{ + + static QuickAccessView *g_pQuickAccessView{nullptr}; + + QuickAccessView::QuickAccessView() + { + + g_pQuickAccessView = this; + } + + QuickAccessView::~QuickAccessView() + { + DeInitView(); + g_pQuickAccessView = nullptr; + } + + QuickAccessView *QuickAccessView::GetInstance() + { + + return g_pQuickAccessView; + } + + void QuickAccessView::InitView(void) + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + UIView::OnDragListener *draglistener = static_cast(QuickAccessPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + container_->SetTouchable(true); + container_->SetDraggable(true); + } + /***********************************************************************************************************/ + // Add QuickAccessScrollView to App + if (QuickAccessScrollView == nullptr) + { + QuickAccessScrollView = new UIScrollView(); + } + QuickAccessScrollView->SetPosition(0, 0); + QuickAccessScrollView->Resize(466, 466); + QuickAccessScrollView->SetViewId("QuickAccessScrollView"); + QuickAccessScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + // Add to rootView + container_->Add(QuickAccessScrollView); + QuickAccessScrollView->SetVisible(true); + /***********************************************************************************************************/ + // Add Label to App + if (QuickAccessLabel == nullptr) + { + QuickAccessLabel = new UILabel(); + } + QuickAccessLabel->SetPosition(173, 52); + QuickAccessLabel->Resize(120, 35); + QuickAccessLabel->SetViewId("QuickAccessLabel"); + QuickAccessLabel->SetStyle(STYLE_TEXT_FONT, 30); + QuickAccessLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + QuickAccessLabel->SetText("快速访问"); + QuickAccessLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + QuickAccessLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + QuickAccessLabel->SetRollSpeed(6); + QuickAccessLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView3 + QuickAccessScrollView->Add(QuickAccessLabel); + QuickAccessLabel->SetVisible(true); + /***********************************************************************************************************/ + // Add Label to App + if (label == nullptr) + { + label = new UILabel(); + } + label->SetPosition(86, 126); + label->Resize(286, 60); + label->SetViewId("label"); + label->SetStyle(STYLE_TEXT_FONT, 26); + label->SetStyle(STYLE_LINE_HEIGHT, 30); + // Set additional property + label->SetText("此功能可设置右下方按钮\n快速访问的APP"); + label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label->SetTextColor(Color::GetColorFromRGBA(0xbb, 0xbb, 0xbb, 0xff)); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(6); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + // Add to scrollView3 + QuickAccessScrollView->Add(label); + label->SetVisible(true); + /***********************************************************************************************************/ + // Add ImageView to App + if (HeartRateDetectionImage == nullptr) + { + HeartRateDetectionImage = new UIImageView(); + } + HeartRateDetectionImage->SetPosition(43, 220); // widget's left position and top position + HeartRateDetectionImage->Resize(380, 100); // widget's width and height + HeartRateDetectionImage->SetViewId("HeartRateDetectionImage"); // Set style + HeartRateDetectionImage->SetStyle(STYLE_BORDER_RADIUS, 50); + HeartRateDetectionImage->SetSrc(PNG_SETTING_BACKGROUND_IMAGE); + // Add to scrollView3 + QuickAccessScrollView->Add(HeartRateDetectionImage); + HeartRateDetectionImage->SetVisible(true); + /***********************************************************************************************************/ + // Add Label to App + if (HeartRateDetectionLabel == nullptr) + { + HeartRateDetectionLabel = new UILabel(); + } + HeartRateDetectionLabel->SetPosition(103, 253); + HeartRateDetectionLabel->Resize(120, 35); + HeartRateDetectionLabel->SetViewId("HeartRateDetectionLabel"); + HeartRateDetectionLabel->SetStyle(STYLE_TEXT_FONT, 30); + HeartRateDetectionLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + HeartRateDetectionLabel->SetText("心率监测"); + HeartRateDetectionLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + HeartRateDetectionLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + HeartRateDetectionLabel->SetRollSpeed(6); + HeartRateDetectionLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView3 + QuickAccessScrollView->Add(HeartRateDetectionLabel); + HeartRateDetectionLabel->SetVisible(true); + /***********************************************************************************************************/ + // Add CheckBox to App + if (HeartRateDetectionCheckBox == nullptr) + { + HeartRateDetectionCheckBox = new UICheckBox(); + } + HeartRateDetectionCheckBox->SetPosition(343, 250); + HeartRateDetectionCheckBox->Resize(40, 40); + HeartRateDetectionCheckBox->SetViewId(HEART_RATE_DETECTION); + HeartRateDetectionCheckBox->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + HeartRateDetectionCheckBox->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + // Set additional property + HeartRateDetectionCheckBox->SetImages(PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE); + // Add the CallBack about events + UIView::OnClickListener *HeartRateDetectionCheckBoxClick = static_cast(QuickAccessPresenter::GetInstance()); + HeartRateDetectionCheckBox->SetOnClickListener(HeartRateDetectionCheckBoxClick); + // Add to scrollView3 + QuickAccessScrollView->Add(HeartRateDetectionCheckBox); + HeartRateDetectionCheckBox->SetVisible(true); + /***********************************************************************************************************/ + // Add ImageView to App + if (BloodOxygenMonitoringImage == nullptr) + { + BloodOxygenMonitoringImage = new UIImageView(); + } + BloodOxygenMonitoringImage->SetPosition(43, 340); + BloodOxygenMonitoringImage->Resize(380, 100); + BloodOxygenMonitoringImage->SetViewId("BloodOxygenMonitoringImage"); + BloodOxygenMonitoringImage->SetStyle(STYLE_BORDER_RADIUS, 50); + // Set additional property + BloodOxygenMonitoringImage->SetSrc(PNG_SETTING_BACKGROUND_IMAGE); + // Add to scrollView3 + QuickAccessScrollView->Add(BloodOxygenMonitoringImage); + BloodOxygenMonitoringImage->SetVisible(true); + /***********************************************************************************************************/ + // Add CheckBox to App + if (BloodOxygenMonitoringCheckBox == nullptr) + { + BloodOxygenMonitoringCheckBox = new UICheckBox(); + } + BloodOxygenMonitoringCheckBox->SetPosition(343, 370); + BloodOxygenMonitoringCheckBox->Resize(50, 50); + BloodOxygenMonitoringCheckBox->SetViewId(BLOOD_OXYGEN_MONITOR); + BloodOxygenMonitoringCheckBox->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + BloodOxygenMonitoringCheckBox->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + BloodOxygenMonitoringCheckBox->SetImages(PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE); + // Add the CallBack about events + UIView::OnClickListener *BloodOxygenMonitoringCheckBoxClick = static_cast(QuickAccessPresenter::GetInstance()); + BloodOxygenMonitoringCheckBox->SetOnClickListener(BloodOxygenMonitoringCheckBoxClick); + // Add to scrollView3 + QuickAccessScrollView->Add(BloodOxygenMonitoringCheckBox); + BloodOxygenMonitoringCheckBox->SetVisible(true); + /***********************************************************************************************************/ + // Add Label to App + if (BloodOxygenMonitoringLabel == nullptr) + { + BloodOxygenMonitoringLabel = new UILabel(); + } + BloodOxygenMonitoringLabel->SetPosition(103, 373); + BloodOxygenMonitoringLabel->Resize(120, 35); + BloodOxygenMonitoringLabel->SetViewId("BloodOxygenMonitoringLabel"); + BloodOxygenMonitoringLabel->SetStyle(STYLE_TEXT_FONT, 30); + BloodOxygenMonitoringLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + BloodOxygenMonitoringLabel->SetText("血氧监测"); + BloodOxygenMonitoringLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + BloodOxygenMonitoringLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + BloodOxygenMonitoringLabel->SetRollSpeed(6); + BloodOxygenMonitoringLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView3 + QuickAccessScrollView->Add(BloodOxygenMonitoringLabel); + BloodOxygenMonitoringLabel->SetVisible(true); + /***********************************************************************************************************/ + // Add ImageView to App + if (image1 == nullptr) + { + image1 = new UIImageView(); + } + image1->SetPosition(183, 23); + image1->Resize(100, 100); + image1->SetViewId("image1"); + + QuickAccessScrollView->Add(image1); + image1->SetVisible(true); + /***********************************************************************************************************/ + // Add ImageView to App + if (image2 == nullptr) + { + image2 = new UIImageView(); + } + image2->SetPosition(183, 423); + image2->Resize(100, 100); + image2->SetViewId("image2"); + QuickAccessScrollView->Add(image2); + image2->SetVisible(true); + } + + void QuickAccessView::DeInitView(void) + { + if (container_ != nullptr) { + container_->RemoveAll(); + delete container_ ; + container_ = nullptr; + } + if (QuickAccessScrollView != nullptr) { + delete QuickAccessScrollView; + QuickAccessScrollView = nullptr; + } + if (image1 != nullptr) { + delete image1; + image1 = nullptr; + } + if (QuickAccessLabel != nullptr) { + delete QuickAccessLabel; + QuickAccessLabel = nullptr; + } + if (image2 != nullptr) { + delete image2; + image2 = nullptr; + } + if (label != nullptr) { + delete label; + label = nullptr; + } + if (HeartRateDetectionImage != nullptr) { + delete HeartRateDetectionImage; + HeartRateDetectionImage = nullptr; + } + if (HeartRateDetectionCheckBox != nullptr) { + delete HeartRateDetectionCheckBox; + HeartRateDetectionCheckBox = nullptr; + } + if (HeartRateDetectionLabel != nullptr) { + delete HeartRateDetectionLabel; + HeartRateDetectionLabel = nullptr; + } + if (BloodOxygenMonitoringImage != nullptr) { + delete BloodOxygenMonitoringImage; + BloodOxygenMonitoringImage = nullptr; + } + if (BloodOxygenMonitoringCheckBox != nullptr) { + delete BloodOxygenMonitoringCheckBox; + BloodOxygenMonitoringCheckBox = nullptr; + } + if (BloodOxygenMonitoringLabel != nullptr) { + delete BloodOxygenMonitoringLabel; + BloodOxygenMonitoringLabel = nullptr; + } + } + + void QuickAccessView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void QuickAccessView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void QuickAccessView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void QuickAccessView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordDeletePresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordDeletePresenter.h new file mode 100644 index 000000000..549efa45f --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordDeletePresenter.h @@ -0,0 +1,34 @@ +#ifndef RECORD_DELETE_PRESENTER_H +#define RECORD_DELETE_PRESENTER_H + +#include "Presenter.h" + +#include "RecordDeleteView.h" + +namespace OHOS +{ + class RecordDeleteView; + + class RecordDeletePresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + RecordDeletePresenter(); + virtual ~RecordDeletePresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static RecordDeletePresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordDeleteView.h b/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordDeleteView.h new file mode 100644 index 000000000..ef98ce817 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordDeleteView.h @@ -0,0 +1,41 @@ +#ifndef RECORD_DELETE_VIEW_H +#define RECORD_DELETE_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +namespace OHOS +{ + static const char *RECORD_DELETE_ON_BUTTON_VIEWID = "RECORD_DELETE_ON_BUTTON"; // 录音删除 + static const char *RECORD_DELETE_OFF_BUTTON_VIEWID = "RECORD_DELETE_OFF_BUTTON"; // 录音不删除 + class RecordDeletePresenter; + class RecordDeleteView : public View + { + + public: + RecordDeleteView(); + virtual ~RecordDeleteView(); + static RecordDeleteView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + + UIViewGroup *container_ = nullptr; + UIImageView *RECORD_DELETE_BACKGROUND_IMAGE = nullptr; + UIButton *RECORD_DELETE_ON_BUTTON = nullptr; // 是否删除录音:是 + UIButton *RECORD_DELETE_OFF_BUTTON = nullptr; // 是否删除录音:否 + + UIView::OnClickListener *RECORD_DELETE_ON_BUTTON_CLICK{nullptr}; //删除录音按钮点击回调 + UIView::OnClickListener *RECORD_DELETE_OFF_BUTTON_CLICK{nullptr};//不删除录音按钮点击回调 + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordGoingPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordGoingPresenter.h new file mode 100644 index 000000000..8b84a206f --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordGoingPresenter.h @@ -0,0 +1,33 @@ +#ifndef RECORD_GOING_PRESENTER_H +#define RECORD_GOING_PRESENTER_H + +#include "Presenter.h" + +#include "RecordGoingView.h" +#include "animator/animator.h" +namespace OHOS +{ + class RecordGoingView; + + class RecordGoingPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + RecordGoingPresenter(); + virtual ~RecordGoingPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static RecordGoingPresenter *GetInstance(); + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordGoingView.h b/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordGoingView.h new file mode 100644 index 000000000..2223d6684 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordGoingView.h @@ -0,0 +1,63 @@ +#ifndef RECORD_GOING_VIEW_H +#define RECORD_GOING_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_scroll_view.h" +#include "animator/animator.h" +#include "sys/time.h" +namespace OHOS +{ + static constexpr int16_t TIME_CONVERT = 60; // sec to min, and min to hor + static constexpr int16_t TEXT_BUFFER_SIEZ = 20; + class TimerAnimatorCallback : public AnimatorCallback + { + public: + explicit TimerAnimatorCallback(UILabel *label) : label_(label) {} + ~TimerAnimatorCallback() override {} + void Callback(UIView *view) override; + + private: + UILabel *label_ = nullptr; + }; + + static const char *RECORD_GOING_BUTTON_VIEWID = "RECORD_GOING_BUTTON"; // 点击按钮后停止录音 + class RecordGoingPresenter; + class RecordGoingView : public View + { + + public: + RecordGoingView(); + virtual ~RecordGoingView(); + static RecordGoingView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + UIView::OnClickListener *RECORD_GOING_BUTTON_CLICK{nullptr}; + + void InitView(void); + void DeInitView(void); + + //有bug + TimerAnimatorCallback *callBack_ = nullptr; + Animator *animator_ = nullptr; + + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView = nullptr; + UILabel *RECORD_GOING_LABEL1 = nullptr; + UIImageView *RECORD_GOING_IMAGE = nullptr; + UIButton *RECORD_GOING_BUTTON = nullptr; + UILabel *RECORD_GOING_LABEL2 = nullptr; + UILabel *RECORD_GOING_LABEL3 = nullptr; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordListPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordListPresenter.h new file mode 100644 index 000000000..6ee3b11eb --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordListPresenter.h @@ -0,0 +1,41 @@ +#ifndef RECORD_LIST_PRESENTER_H +#define RECORD_LIST_PRESENTER_H + +#include "Presenter.h" + +#include "RecordListView.h" + +namespace OHOS +{ + class RecordListView; + + class RecordListPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener, + public UIView::OnLongPressListener + { + public: + RecordListPresenter(); + virtual ~RecordListPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static RecordListPresenter *GetInstance(); + + private: + //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnLongPress(UIView& view, const LongPressEvent& event) override; + }; +} //namespace OHOS + + + + + + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordListView.h b/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordListView.h new file mode 100644 index 000000000..990359445 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordListView.h @@ -0,0 +1,56 @@ +#ifndef RECORD_LIST_VIEW_H +#define RECORD_LIST_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +namespace OHOS +{ + class RecordListPresenter; + class RecordListView : public View + { + + public: + RecordListView(); + virtual ~RecordListView(); + static RecordListView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + UIView::OnDragListener *draglistener{nullptr}; + + void InitView(void); + void DeInitView(void); + + UIViewGroup *container_ = nullptr; + UIScrollView *RecordListScrollView = nullptr; + UILabel *RecordListlabel1 = nullptr; + UIImageView *RecordImage = nullptr; + UIButton *RecordButton = nullptr; + + UIImageView *image6_ = nullptr; + UIButton *button3 = nullptr; + UIButton *button1 = nullptr; + UILabel *label3 = nullptr; + UILabel *label2 = nullptr; + UILabel *label1 = nullptr; + UIButton *button2 = nullptr; + UILabel *label9 = nullptr; + UILabel *label6 = nullptr; + UILabel *label8 = nullptr; + UILabel *label5 = nullptr; + UILabel *label7 = nullptr; + UILabel *label4 = nullptr; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordPlayPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordPlayPresenter.h new file mode 100644 index 000000000..b66216d56 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordPlayPresenter.h @@ -0,0 +1,35 @@ +#ifndef RECORD_PLAY_PRESENTER_H +#define RECORD_PLAY_PRESENTER_H + +#include "Presenter.h" + +#include "RecordPlayView.h" + +namespace OHOS +{ + class RecordPlayView; + + class RecordPlayPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + RecordPlayPresenter(); + virtual ~RecordPlayPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static RecordPlayPresenter *GetInstance(); + + private: + //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} //namespace OHOS + + +#endif //SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordPlayView.h b/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordPlayView.h new file mode 100644 index 000000000..3806e4b86 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordPlayView.h @@ -0,0 +1,59 @@ +#ifndef RECORD_PLAY_VIEW_H +#define RECORD_PLAY_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_image_view.h" +#include "components/ui_circle_progress.h" +#include "components/ui_checkbox.h" +#include "components/ui_label.h" +#include "components/ui_button.h" +namespace OHOS +{ + static const char *RECORD_PLAY_PAUSE_CHECKBOX_VIEWID = "RECORD_PLAY_PAUSE_CHECKBOX"; // 播放和暂停复选框视图id + static const char *RECORD_PLAY_PROVE_BUTTON_VIEWID = "RECORD_PLAY_PROVE_BUTTON"; // 上一首按钮的视图id + static const char *RECORD_PLAY_NEXT_BUTTON_VIEWID = "RECORD_PLAY_NEXT_BUTTON"; // 下一首按钮的视图id + static const char *RECORD_PLAY_DELETE_BUTTON_VIEWID = "RECORD_PLAY_DELETE_BUTTON"; // 删除按钮的视图id + static const char *RECORD_PLAY_VOLUME_BUTTON_VIEWID = "RECORD_PLAY_VOLUME_BUTTON"; // 音量按钮的视图id + + class RecordPlayPresenter; + class RecordPlayView : public View + { + + public: + RecordPlayView(); + virtual ~RecordPlayView(); + static RecordPlayView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + UIButton *CreateUIButton(int left, int top, int width, int height, const char *viewId, + const char *defimagesrc, const char *toggleimagesrc, UIView::OnClickListener **buttonClick); + + private: + UIView::OnDragListener *draglistener{nullptr}; + UIView::OnClickListener *RECORD_PLAY_PROVE_BUTTON_CLICK{nullptr}; // 上一首按钮点击回调 + UIView::OnClickListener *RECORD_PLAY_NEXT_BUTTON_CLICK{nullptr}; // 下一首按钮点击回调 + UIView::OnClickListener *RECORD_PLAY_DELETE_BUTTON_CLICK{nullptr}; // 删除按钮的点击回调 + UIView::OnClickListener *RECORD_PLAY_VOLUME_BUTTON_CLICK{nullptr}; // 音量按钮点击回调 + + void InitView(void); + void DeInitView(void); + + UIViewGroup *container_ = nullptr; + UIImageView *RECORD_PLAY_BACKGROUND_IMAGE = nullptr; + UICircleProgress *RECORD_PLAY_CircleProgress = nullptr; + UICheckBox *RECORD_PLAY_PAUSE_CHECKBOX = nullptr; + UILabel *RecordLabel1 = nullptr; + UILabel *RecordLabel2 = nullptr; + UIButton *RECORD_PLAY_PROVE_BUTTON = nullptr; // 上一首按钮 + UIButton *RECORD_PLAY_NEXT_BUTTON = nullptr; // 下一首按钮 + UIButton *RECORD_PLAY_DELETE_BUTTON = nullptr; // 删除按钮 + UIButton *RECORD_PLAY_VOLUME_BUTTON = nullptr; // 音量按钮 + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordPresenter.h new file mode 100644 index 000000000..837035de1 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordPresenter.h @@ -0,0 +1,38 @@ +#ifndef RECORD_PRESENTER_H +#define RECORD_PRESENTER_H + +#include "Presenter.h" + +#include "RecordView.h" + +namespace OHOS +{ + class RecordView; + + class RecordPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + RecordPresenter(); + virtual ~RecordPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static RecordPresenter *GetInstance(); + + private: + //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} //namespace OHOS + + + + + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordView.h b/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordView.h new file mode 100644 index 000000000..e0bc583ac --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/record/include/RecordView.h @@ -0,0 +1,49 @@ +#ifndef RECORD_VIEW_H +#define RECORD_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_image_animator.h" + +namespace OHOS +{ + static const char *RECORD_BUTTON = "RecordButton"; //录音按钮 + class RecordPresenter; + class RecordView : public View + { + + public: + RecordView(); + virtual ~RecordView(); + static RecordView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + UIView::OnDragListener *draglistener{nullptr}; + + void InitView(void); + void DeInitView(void); + + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView = nullptr; + UILabel *label1 = nullptr; + UIImageView *RECORD1_Image = nullptr; + UIButton *button = nullptr; + UILabel *label2 = nullptr; + UIImageAnimatorView *imageAnimator1_ = nullptr; + + + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordDeletePresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordDeletePresenter.cpp new file mode 100644 index 000000000..f3cd6f73f --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordDeletePresenter.cpp @@ -0,0 +1,78 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "record/include/RecordDeletePresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static RecordDeletePresenter *g_pRecordDeletePresenter = nullptr; + + RecordDeletePresenter::RecordDeletePresenter() + { + + g_pRecordDeletePresenter = this; + } + + RecordDeletePresenter::~RecordDeletePresenter() + { + + g_pRecordDeletePresenter = nullptr; + } + + RecordDeletePresenter *RecordDeletePresenter::GetInstance() + { + + return g_pRecordDeletePresenter; + } + + void RecordDeletePresenter::OnStart() + { + + Presenter::OnStart(); + } + + void RecordDeletePresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void RecordDeletePresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void RecordDeletePresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool RecordDeletePresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + UNUSED(event); + } + + bool RecordDeletePresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), RECORD_DELETE_ON_BUTTON_VIEWID) == 0) + { + printf("delete button being clicked\n"); + return true; + } + else if (strcmp(view.GetViewId(), RECORD_DELETE_OFF_BUTTON_VIEWID) == 0) + { + printf("delete not button being clicked\n"); + NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD_PLAY); + return true; + } + return false; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordDeleteView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordDeleteView.cpp new file mode 100644 index 000000000..aa308337c --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordDeleteView.cpp @@ -0,0 +1,151 @@ +#include "record/include/RecordDeleteView.h" +#include "record/include/RecordDeletePresenter.h" + +#include "UiConfig.h" + +namespace OHOS +{ + + static RecordDeleteView *g_pRecordDeleteView{nullptr}; + + RecordDeleteView::RecordDeleteView() + { + + g_pRecordDeleteView = this; + } + + RecordDeleteView::~RecordDeleteView() + { + DeInitView(); + g_pRecordDeleteView = nullptr; + } + + RecordDeleteView *RecordDeleteView::GetInstance() + { + + return g_pRecordDeleteView; + } + + void RecordDeleteView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + + } + + // Add ImageView to App + if (RECORD_DELETE_BACKGROUND_IMAGE == nullptr) + { + RECORD_DELETE_BACKGROUND_IMAGE = new UIImageView(); + } + RECORD_DELETE_BACKGROUND_IMAGE->SetPosition(0, 0); + RECORD_DELETE_BACKGROUND_IMAGE->Resize(466, 466); + RECORD_DELETE_BACKGROUND_IMAGE->SetViewId("RECORD_DELETE_BACKGROUND_IMAGE"); + RECORD_DELETE_BACKGROUND_IMAGE->SetSrc(PNG_RECORD_DELETE_BACKGROUND_IMAGE); + + // Add to rootView + container_->Add(RECORD_DELETE_BACKGROUND_IMAGE); + RECORD_DELETE_BACKGROUND_IMAGE->SetVisible(true); + + // Add Button to App + if (RECORD_DELETE_ON_BUTTON == nullptr) + { + RECORD_DELETE_ON_BUTTON = new UIButton(); + } + RECORD_DELETE_ON_BUTTON->SetPosition(254, 299); + RECORD_DELETE_ON_BUTTON->Resize(100, 100); + RECORD_DELETE_ON_BUTTON->SetViewId(RECORD_DELETE_ON_BUTTON_VIEWID); + RECORD_DELETE_ON_BUTTON->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + RECORD_DELETE_ON_BUTTON->SetStyle(STYLE_BORDER_COLOR, 0xffffffff); + RECORD_DELETE_ON_BUTTON->SetImageSrc(PNG_SYSTEM_CHECK_ON_IMAGE, nullptr); + RECORD_DELETE_ON_BUTTON->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + RECORD_DELETE_ON_BUTTON->SetStyleForState(STYLE_BACKGROUND_OPA, 0x2b, UIButton::PRESSED); + RECORD_DELETE_ON_BUTTON->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + RECORD_DELETE_ON_BUTTON_CLICK = static_cast(RecordDeletePresenter::GetInstance()); + RECORD_DELETE_ON_BUTTON->SetOnClickListener(RECORD_DELETE_ON_BUTTON_CLICK); + // Add to rootView + container_->Add(RECORD_DELETE_ON_BUTTON); + RECORD_DELETE_ON_BUTTON->SetVisible(true); + + // Add Button to App + if (RECORD_DELETE_OFF_BUTTON == nullptr) + { + RECORD_DELETE_OFF_BUTTON = new UIButton(); + } + RECORD_DELETE_OFF_BUTTON->SetPosition(111, 299); + RECORD_DELETE_OFF_BUTTON->Resize(100, 100); + RECORD_DELETE_OFF_BUTTON->SetViewId(RECORD_DELETE_OFF_BUTTON_VIEWID); + RECORD_DELETE_OFF_BUTTON->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + RECORD_DELETE_OFF_BUTTON->SetStyle(STYLE_BORDER_COLOR, 0xffffffff); + RECORD_DELETE_OFF_BUTTON->SetImageSrc(PNG_SYSTEM_CHECK_OFF_IMAGE, nullptr); + RECORD_DELETE_OFF_BUTTON->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + RECORD_DELETE_OFF_BUTTON->SetStyleForState(STYLE_BACKGROUND_OPA, 0x2b, UIButton::PRESSED); + RECORD_DELETE_OFF_BUTTON->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + RECORD_DELETE_OFF_BUTTON_CLICK = static_cast(RecordDeletePresenter::GetInstance()); + RECORD_DELETE_OFF_BUTTON->SetOnClickListener(RECORD_DELETE_OFF_BUTTON_CLICK); + // Add to rootView + container_->Add(RECORD_DELETE_OFF_BUTTON); + RECORD_DELETE_OFF_BUTTON->SetVisible(true); + } + + void RecordDeleteView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (RECORD_DELETE_BACKGROUND_IMAGE != nullptr) + { + delete RECORD_DELETE_BACKGROUND_IMAGE; + RECORD_DELETE_BACKGROUND_IMAGE = nullptr; + } + if (RECORD_DELETE_ON_BUTTON != nullptr) + { + delete RECORD_DELETE_ON_BUTTON; + RECORD_DELETE_ON_BUTTON = nullptr; + } + if (RECORD_DELETE_OFF_BUTTON != nullptr) + { + delete RECORD_DELETE_OFF_BUTTON; + RECORD_DELETE_OFF_BUTTON = nullptr; + } + } + + void RecordDeleteView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void RecordDeleteView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void RecordDeleteView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void RecordDeleteView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordGoingPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordGoingPresenter.cpp new file mode 100644 index 000000000..f5013dae2 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordGoingPresenter.cpp @@ -0,0 +1,71 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "string.h" +#include "record/include/RecordGoingPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static RecordGoingPresenter *g_pRecordGoingPresenter = nullptr; + + RecordGoingPresenter::RecordGoingPresenter() + { + + g_pRecordGoingPresenter = this; + } + + RecordGoingPresenter::~RecordGoingPresenter() + { + + g_pRecordGoingPresenter = nullptr; + } + + RecordGoingPresenter *RecordGoingPresenter::GetInstance() + { + + return g_pRecordGoingPresenter; + } + + void RecordGoingPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void RecordGoingPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void RecordGoingPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void RecordGoingPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool RecordGoingPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + UNUSED(event); + } + + bool RecordGoingPresenter::OnClick(UIView &view, const ClickEvent &event) + { + + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), RECORD_GOING_BUTTON_VIEWID) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD); + return true; + } + return false; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordGoingView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordGoingView.cpp new file mode 100644 index 000000000..2794f2ef6 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordGoingView.cpp @@ -0,0 +1,246 @@ +#include "record/include/RecordGoingView.h" +#include "record/include/RecordGoingPresenter.h" +#include "UiConfig.h" + +namespace OHOS +{ + + static RecordGoingView *g_pRecordGoingView{nullptr}; + + RecordGoingView::RecordGoingView() + { + + g_pRecordGoingView = this; + } + + RecordGoingView::~RecordGoingView() + { + DeInitView(); + g_pRecordGoingView = nullptr; + } + + RecordGoingView *RecordGoingView::GetInstance() + { + + return g_pRecordGoingView; + } + static void GetTime(char *buf, int len) + { + struct timeval tv; + gettimeofday(&tv, NULL); + uint32_t second = tv.tv_sec % TIME_CONVERT; + uint32_t minute = tv.tv_sec / TIME_CONVERT; + uint32_t hour = (minute / TIME_CONVERT) % 24; // 24: 24 hours per day + // uint32_t realMilliSecond = tv.tv_usec / USEC_TO_MILLI; + minute = minute % TIME_CONVERT; + + sprintf_s(buf, len, "%02d : %02d : %02d", hour, minute, second); + } + + void TimerAnimatorCallback::Callback(UIView *view) + { + (void)view; + char buf[TEXT_BUFFER_SIEZ] = {0}; + GetTime(buf, TEXT_BUFFER_SIEZ); + label_->SetText(buf); + RootView::GetInstance()->Invalidate(); + } + + void RecordGoingView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + container_->SetTouchable(true); + } + if (scrollView == nullptr) + { + scrollView = new UIScrollView(); + } + scrollView->SetPosition(0, 0); + scrollView->Resize(466, 466); + scrollView->SetViewId("scrollView"); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // Add to rootView + container_->Add(scrollView); + scrollView->SetVisible(true); + + // Add Label to App + if (RECORD_GOING_LABEL1 == nullptr) + { + RECORD_GOING_LABEL1 = new UILabel(); + } + RECORD_GOING_LABEL1->SetPosition(188, 52); + RECORD_GOING_LABEL1->Resize(90, 35); + RECORD_GOING_LABEL1->SetViewId("RECORD_GOING_LABEL1"); + RECORD_GOING_LABEL1->SetStyle(STYLE_TEXT_FONT, 30); + RECORD_GOING_LABEL1->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + RECORD_GOING_LABEL1->SetText("录音机"); + RECORD_GOING_LABEL1->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + RECORD_GOING_LABEL1->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + RECORD_GOING_LABEL1->SetRollSpeed(0); + RECORD_GOING_LABEL1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + scrollView->Add(RECORD_GOING_LABEL1); + RECORD_GOING_LABEL1->SetVisible(true); + + // Add ImageView to App + if (RECORD_GOING_IMAGE == nullptr) + { + RECORD_GOING_IMAGE = new UIImageView(); + } + RECORD_GOING_IMAGE->SetPosition(158, 129); + RECORD_GOING_IMAGE->Resize(150, 150); + RECORD_GOING_IMAGE->SetViewId("RECORD_GOING_IMAGE"); + RECORD_GOING_IMAGE->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + RECORD_GOING_IMAGE->SetStyle(STYLE_BORDER_RADIUS, 15); + RECORD_GOING_IMAGE->SetSrc(PNG_RECORD3_IMAGE); + + // Add to rootView + scrollView->Add(RECORD_GOING_IMAGE); + RECORD_GOING_IMAGE->SetVisible(true); + + // Add Button to App + if (RECORD_GOING_BUTTON == nullptr) + { + RECORD_GOING_BUTTON = new UIButton(); + } + RECORD_GOING_BUTTON->SetPosition(210, 180); + RECORD_GOING_BUTTON->Resize(60, 60); + RECORD_GOING_BUTTON->SetViewId(RECORD_GOING_BUTTON_VIEWID); + RECORD_GOING_BUTTON->SetStyle(STYLE_BACKGROUND_COLOR, 0xffff5a36); + RECORD_GOING_BUTTON->SetStyle(STYLE_BORDER_RADIUS, 20); + + // Set additional property + RECORD_GOING_BUTTON->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + RECORD_GOING_BUTTON->SetStyleForState(STYLE_BORDER_RADIUS, 20, UIButton::PRESSED); + // Add the CallBack about events + RECORD_GOING_BUTTON_CLICK = static_cast(RecordGoingPresenter::GetInstance()); + RECORD_GOING_BUTTON->SetOnClickListener(RECORD_GOING_BUTTON_CLICK); + // Add to rootView + scrollView->Add(RECORD_GOING_BUTTON); + RECORD_GOING_BUTTON->SetVisible(true); + + // Add Label to App + if (RECORD_GOING_LABEL2 == nullptr) + { + RECORD_GOING_LABEL2 = new UILabel(); + } + RECORD_GOING_LABEL2->SetPosition(107, 290); + RECORD_GOING_LABEL2->Resize(253, 77); + RECORD_GOING_LABEL2->SetViewId("RECORD_GOING_LABEL2"); + RECORD_GOING_LABEL2->SetStyle(STYLE_TEXT_FONT, 65); + RECORD_GOING_LABEL2->SetStyle(STYLE_LINE_HEIGHT, 77); + + // Set additional property + RECORD_GOING_LABEL2->SetText("00:00:00"); + RECORD_GOING_LABEL2->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + RECORD_GOING_LABEL2->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + RECORD_GOING_LABEL2->SetRollSpeed(0); + RECORD_GOING_LABEL2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 65); + + callBack_ = new TimerAnimatorCallback(RECORD_GOING_LABEL2); + animator_ = new Animator(callBack_, RECORD_GOING_LABEL2, 0, true); + animator_->Start(); + // Add to rootView + container_->Add(RECORD_GOING_LABEL2); + RECORD_GOING_LABEL2->SetVisible(true); + + // Add Label to App + if (RECORD_GOING_LABEL3 == nullptr) + { + RECORD_GOING_LABEL3 = new UILabel(); + } + RECORD_GOING_LABEL3->SetPosition(188, 370); + RECORD_GOING_LABEL3->Resize(90, 95); + RECORD_GOING_LABEL3->SetViewId("RECORD_GOING_LABEL3"); + RECORD_GOING_LABEL3->SetStyle(STYLE_TEXT_FONT, 30); + RECORD_GOING_LABEL3->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + RECORD_GOING_LABEL3->SetText("录音中"); + RECORD_GOING_LABEL3->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + RECORD_GOING_LABEL3->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + RECORD_GOING_LABEL3->SetRollSpeed(0); + RECORD_GOING_LABEL3->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + scrollView->Add(RECORD_GOING_LABEL3); + RECORD_GOING_LABEL3->SetVisible(true); + } + + void RecordGoingView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView != nullptr) + { + scrollView->RemoveAll(); + delete scrollView; + scrollView = nullptr; + } + if (RECORD_GOING_LABEL1 != nullptr) + { + delete RECORD_GOING_LABEL1; + RECORD_GOING_LABEL1 = nullptr; + } + if (RECORD_GOING_IMAGE != nullptr) + { + delete RECORD_GOING_IMAGE; + RECORD_GOING_IMAGE = nullptr; + } + if (RECORD_GOING_BUTTON != nullptr) + { + delete RECORD_GOING_BUTTON; + RECORD_GOING_BUTTON = nullptr; + } + if (RECORD_GOING_LABEL2 != nullptr) + { + delete RECORD_GOING_LABEL2; + RECORD_GOING_LABEL2 = nullptr; + } + if (RECORD_GOING_LABEL3 != nullptr) + { + delete RECORD_GOING_LABEL3; + RECORD_GOING_LABEL3 = nullptr; + } + } + + void RecordGoingView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void RecordGoingView::OnSetUpView() + { + View::OnSetUpView(); + Draw(); + } + + void RecordGoingView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void RecordGoingView::OnStop() + { + animator_->Stop(); + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordListPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordListPresenter.cpp new file mode 100644 index 000000000..a6ccb4c11 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordListPresenter.cpp @@ -0,0 +1,91 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "record/include/RecordListPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static RecordListPresenter *g_pRecordListPresenter = nullptr; + + RecordListPresenter::RecordListPresenter() + { + + g_pRecordListPresenter = this; + } + + RecordListPresenter::~RecordListPresenter() + { + + g_pRecordListPresenter = nullptr; + } + + RecordListPresenter *RecordListPresenter::GetInstance() + { + + return g_pRecordListPresenter; + } + + void RecordListPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void RecordListPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void RecordListPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void RecordListPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool RecordListPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_TOP_TO_BOTTOM && + (event.GetDeltaY() > 30) && (event.GetDeltaY() > (2 * MATH_ABS(event.GetDeltaX())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD); + } + return true; + } + + bool RecordListPresenter::OnLongPress(UIView &view, const LongPressEvent &event) + { + + return false; + } + + bool RecordListPresenter::OnClick(UIView &view, const ClickEvent &event) + { + if (strcmp(view.GetViewId(), "button1") == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD_PLAY); + return true; + } + else if(strcmp(view.GetViewId(), "button2") == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD_PLAY); + return true; + } + else if(strcmp(view.GetViewId(), "button3") == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD_PLAY); + return true; + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordListView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordListView.cpp new file mode 100644 index 000000000..a004e2685 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordListView.cpp @@ -0,0 +1,526 @@ +#include "record/include/RecordListView.h" +#include "record/include/RecordListPresenter.h" + +#include "UiConfig.h" + +namespace OHOS +{ + + static RecordListView *g_pRecordListView{nullptr}; + + RecordListView::RecordListView() + { + + g_pRecordListView = this; + } + + RecordListView::~RecordListView() + { + g_pRecordListView = nullptr; + } + + RecordListView *RecordListView::GetInstance() + { + + return g_pRecordListView; + } + + void RecordListView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + draglistener = static_cast(RecordListPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + container_->SetTouchable(true); + container_->SetDraggable(true); + } + + // Add ScrollView to App + if (RecordListScrollView == nullptr) + { + RecordListScrollView = new UIScrollView(); + } + RecordListScrollView->SetPosition(0, 0); + RecordListScrollView->Resize(466, 466); + RecordListScrollView->SetViewId("RecordListScrollView"); + RecordListScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + // Add to rootView + container_->Add(RecordListScrollView); + RecordListScrollView->SetVisible(true); + + // Add Label to App + if (RecordListlabel1 == nullptr) + { + RecordListlabel1 = new UILabel(); + } + RecordListlabel1->SetPosition(188, 52); + RecordListlabel1->Resize(90, 35); + RecordListlabel1->SetViewId("RecordListlabel1"); + RecordListlabel1->SetStyle(STYLE_TEXT_FONT, 30); + RecordListlabel1->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + RecordListlabel1->SetText("录音机"); + RecordListlabel1->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + RecordListlabel1->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + RecordListlabel1->SetRollSpeed(0); + RecordListlabel1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + RecordListScrollView->Add(RecordListlabel1); + RecordListlabel1->SetVisible(true); + /********************************************************************************************************/ + // Add ImageView to App + if (RecordImage == nullptr) + { + RecordImage = new UIImageView(); + } + RecordImage->SetPosition(158, 129); + RecordImage->Resize(150, 150); + RecordImage->SetViewId("RecordImage"); + RecordImage->SetStyle(STYLE_BORDER_RADIUS, 10); + RecordImage->SetSrc(PNG_RECORD1_IMAGE); + + // Add to scrollView1 + RecordListScrollView->Add(RecordImage); + RecordImage->SetVisible(true); + /********************************************************************************************************/ + // Add Button to App + if (RecordButton == nullptr) + { + RecordButton = new UIButton(); + } + RecordButton->SetPosition(178, 150); + RecordButton->Resize(120, 120); + RecordButton->SetViewId("RecordButton"); + RecordButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffff5a36); + RecordButton->SetStyle(STYLE_BORDER_RADIUS, 100); + + // Set additional property + RecordButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffff5a36, UIButton::PRESSED); + RecordButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + RecordButton->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button4Click = static_cast(RecordListPresenter::GetInstance()); + RecordButton->SetOnClickListener(button4Click); + // Add to scrollView1 + RecordListScrollView->Add(RecordButton); + RecordButton->SetVisible(true); + /********************************************************************************************************/ + // Add Button to App + if (button1 == nullptr) + { + button1 = new UIButton(); + } + button1->SetPosition(43, 323); + button1->Resize(380, 100); + button1->SetViewId("button1"); + button1->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button1->SetStyle(STYLE_BORDER_RADIUS, 50); + button1->SetImageSrc(PNG_SETTING_BACKGROUND_IMAGE, nullptr); + button1->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + button1->SetStyleForState(STYLE_BACKGROUND_OPA, 0x82, UIButton::PRESSED); + button1->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + button1->SetStyleForState(STYLE_BORDER_RADIUS, 50, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(RecordListPresenter::GetInstance()); + button1->SetOnClickListener(button1Click); + UIView::OnLongPressListener *button1LongPress = static_cast(RecordListPresenter::GetInstance()); + button1->SetOnLongPressListener(button1LongPress); + // Add to scrollView1 + RecordListScrollView->Add(button1); + button1->SetVisible(true); + /********************************************************************************************************/ + // Add Label to App + if (label1 == nullptr) + { + label1 = new UILabel(); + } + label1->SetPosition(88, 356); + label1->Resize(200, 60); + label1->SetViewId("label1"); + label1->SetStyle(STYLE_TEXT_FONT, 30); + label1->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label1->SetText("录音 3"); + label1->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff)); + label1->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1->SetRollSpeed(0); + label1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + RecordListScrollView->Add(label1); + label1->SetVisible(true); + /********************************************************************************************************/ + // Add Label to App + if (label2 == nullptr) + { + label2 = new UILabel(); + } + label2->SetPosition(301, 342); // widget's left position and top position + label2->Resize(200, 60); // widget's width and height + label2->SetViewId("label2"); // Set style + label2->SetStyle(STYLE_TEXT_FONT, 30); + label2->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label2->SetText("20:57"); + label2->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff)); + label2->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER); + label2->SetRollSpeed(0); + label2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView1 + RecordListScrollView->Add(label2); + label2->SetVisible(true); + /********************************************************************************************************/ + // Add Label to App + if (label3 == nullptr) + { + label3 = new UILabel(); + } + label3->SetPosition(280, 380); // widget's left position and top position + label3->Resize(200, 60); // widget's width and height + label3->SetViewId("label3"); // Set style + label3->SetStyle(STYLE_TEXT_FONT, 20); + label3->SetStyle(STYLE_LINE_HEIGHT, 23); + + // Set additional property + label3->SetText("2022.04.21"); + label3->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label3->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); + label3->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label3->SetRollSpeed(0); + label3->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + + // Add to scrollView1 + RecordListScrollView->Add(label3); + label3->SetVisible(true); + + /********************************************************************************************************/ + // Add Button to App + if (button2 == nullptr) + { + button2 = new UIButton(); + } + button2->SetPosition(43, 443); // widget's left position and top position + button2->Resize(380, 100); // widget's width and height + button2->SetViewId("button2"); // Set style + button2->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button2->SetImageSrc(PNG_SETTING_BACKGROUND_IMAGE, nullptr); + button2->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + button2->SetStyleForState(STYLE_BACKGROUND_OPA, 0x82, UIButton::PRESSED); + button2->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button2Click = static_cast(RecordListPresenter::GetInstance()); + button2->SetOnClickListener(button2Click); + UIView::OnLongPressListener *button2LongPress = static_cast(RecordListPresenter::GetInstance()); + button2->SetOnLongPressListener(button2LongPress); + // Add to scrollView1 + RecordListScrollView->Add(button2); + button2->SetVisible(true); + /********************************************************************************************************/ + // Add Label to App + if (label4 == nullptr) + { + label4 = new UILabel(); + } + label4->SetPosition(88, 480); + label4->Resize(200, 60); + label4->SetViewId("label4"); + label4->SetStyle(STYLE_TEXT_FONT, 30); + label4->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label4->SetText("录音 2"); + label4->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label4->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff)); + label4->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label4->SetRollSpeed(0); + label4->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView1 + RecordListScrollView->Add(label4); + label4->SetVisible(true); + /********************************************************************************************************/ + // Add Label to App + if (label5 == nullptr) + { + label5 = new UILabel(); + } + label5->SetPosition(301, 462); + label5->Resize(200, 60); + label5->SetViewId("label5"); + label5->SetStyle(STYLE_TEXT_FONT, 30); + label5->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label5->SetText("09:51"); + label5->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label5->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff)); + label5->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label5->SetRollSpeed(0); + label5->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + RecordListScrollView->Add(label5); + label5->SetVisible(true); + /********************************************************************************************************/ + // Add Label to App + if (label6 == nullptr) + { + label6 = new UILabel(); + } + label6->SetPosition(280, 500); + label6->Resize(200, 60); + label6->SetViewId("label6"); + label6->SetStyle(STYLE_TEXT_FONT, 20); + label6->SetStyle(STYLE_LINE_HEIGHT, 23); + + // Set additional property + label6->SetText("2023.05.20"); + label6->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label6->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); + label6->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label6->SetRollSpeed(0); + label6->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + // Add to scrollView1 + RecordListScrollView->Add(label6); + label6->SetVisible(true); + /********************************************************************************************************/ + // Add Button to App + if (button3 == nullptr) + { + button3 = new UIButton(); + } + button3->SetPosition(43, 563); // widget's left position and top position + button3->Resize(380, 100); // widget's width and height + button3->SetViewId("button3"); // Set style + button3->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button3->SetImageSrc(PNG_SETTING_BACKGROUND_IMAGE, nullptr); + button3->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + button3->SetStyleForState(STYLE_BACKGROUND_OPA, 0x82, UIButton::PRESSED); + button3->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + // Add the CallBack about events + UIView::OnClickListener *button3Click = static_cast(RecordListPresenter::GetInstance()); + button2->SetOnClickListener(button3Click); + UIView::OnLongPressListener *button3LongPress = static_cast(RecordListPresenter::GetInstance()); + button2->SetOnLongPressListener(button3LongPress); + // Add to scrollView1 + RecordListScrollView->Add(button3); + button3->SetVisible(true); + /********************************************************************************************************/ + // Add Label to App + if (label7 == nullptr) + { + label7 = new UILabel(); + } + label7->SetPosition(88, 596); // widget's left position and top position + label7->Resize(200, 60); // widget's width and height + label7->SetViewId("label7"); // Set style + label7->SetStyle(STYLE_TEXT_FONT, 30); + label7->SetStyle(STYLE_LINE_HEIGHT, 35); + label7->SetText("录音 1"); + label7->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label7->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff)); + label7->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label7->SetRollSpeed(0); + label7->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView1 + RecordListScrollView->Add(label7); + label7->SetVisible(true); + /********************************************************************************************************/ + // Add Label to App + if (label8 == nullptr) + { + label8 = new UILabel(); + } + label8->SetPosition(301, 582); // widget's left position and top position + label8->Resize(200, 60); // widget's width and height + label8->SetViewId("label8"); // Set style + label8->SetStyle(STYLE_TEXT_FONT, 30); + label8->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label8->SetText("12:33"); + label8->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label8->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff)); + label8->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label8->SetRollSpeed(0); + label8->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView1 + RecordListScrollView->Add(label8); + label8->SetVisible(true); + /********************************************************************************************************/ + // Add Label to App + if (label9 == nullptr) + { + label9 = new UILabel(); + } + label9->SetPosition(280, 620); // widget's left position and top position + label9->Resize(200, 60); // widget's width and height + label9->SetViewId("label9"); // Set style + label9->SetStyle(STYLE_TEXT_FONT, 20); + label9->SetStyle(STYLE_LINE_HEIGHT, 23); + // Set additional property + label9->SetText("2022.04.21"); + label9->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label9->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); + label9->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label9->SetRollSpeed(0); + label9->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + // Add to scrollView1 + RecordListScrollView->Add(label9); + label9->SetVisible(true); + /********************************************************************************************************/ + // Add ImageView to App + if (image6_ == nullptr) + { + image6_ = new UIImageView(); + } + image6_->SetPosition(183, 632); // widget's left position and top position + image6_->Resize(100, 100); // widget's width and height + image6_->SetViewId("image6"); // Set style + + // Set additional property + + // Add to scrollView1 + RecordListScrollView->Add(image6_); + image6_->SetVisible(true); + } + + void RecordListView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (RecordListScrollView != nullptr) + { + delete RecordListScrollView; + RecordListScrollView = nullptr; + } + if (RecordListlabel1 != nullptr) + { + delete RecordListlabel1; + RecordListlabel1 = nullptr; + } + if (RecordImage != nullptr) + { + delete RecordImage; + RecordImage = nullptr; + } + if (RecordButton != nullptr) + { + delete RecordButton; + RecordButton = nullptr; + } + if (image6_ != nullptr) + { + delete image6_; + image6_ = nullptr; + } + if (button3 != nullptr) + { + delete button3; + button3 = nullptr; + } + if (button1 != nullptr) + { + delete button1; + button1 = nullptr; + } + if (label3 != nullptr) + { + delete label3; + label3 = nullptr; + } + if (label2 != nullptr) + { + delete label2; + label2 = nullptr; + } + if (label1 != nullptr) + { + delete label1; + label1 = nullptr; + } + if (button2 != nullptr) + { + delete button2; + button2 = nullptr; + } + if (label9 != nullptr) + { + delete label9; + label9 = nullptr; + } + if (label6 != nullptr) + { + delete label6; + label6 = nullptr; + } + if (label8 != nullptr) + { + delete label8; + label8 = nullptr; + } + if (label5 != nullptr) + { + delete label5; + label5 = nullptr; + } + if (label7 != nullptr) + { + delete label7; + label7 = nullptr; + } + if (label4 != nullptr) + { + delete label4; + label4 = nullptr; + } + } + + void RecordListView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void RecordListView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void RecordListView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void RecordListView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordPlayPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordPlayPresenter.cpp new file mode 100644 index 000000000..cb4c862e7 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordPlayPresenter.cpp @@ -0,0 +1,100 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "record/include/RecordPlayPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static RecordPlayPresenter *g_pRecordPlayPresenter = nullptr; + + RecordPlayPresenter::RecordPlayPresenter() + { + + g_pRecordPlayPresenter = this; + } + + RecordPlayPresenter::~RecordPlayPresenter() + { + + g_pRecordPlayPresenter = nullptr; + } + + RecordPlayPresenter *RecordPlayPresenter::GetInstance() + { + + return g_pRecordPlayPresenter; + } + + void RecordPlayPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void RecordPlayPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void RecordPlayPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void RecordPlayPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool RecordPlayPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 30) && (event.GetDeltaX() > (3 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD_LIST); + return true; + } + } + + bool RecordPlayPresenter::OnClick(UIView &view, const ClickEvent &event) + { + + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), RECORD_PLAY_PAUSE_CHECKBOX_VIEWID) == 0) + { + printf("play or pause checkbox being clicked\n"); + return true; + } + else if (strcmp(view.GetViewId(), RECORD_PLAY_PROVE_BUTTON_VIEWID) == 0) + { + printf("prove button being clicked\n"); + return true; + } + else if (strcmp(view.GetViewId(), RECORD_PLAY_NEXT_BUTTON_VIEWID) == 0) + { + printf("next button being clicked\n"); + + return true; + } + else if (strcmp(view.GetViewId(), RECORD_PLAY_DELETE_BUTTON_VIEWID) == 0) + { + printf("delete button being clicked\n"); + NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD_DELETE); + return true; + } + else if (strcmp(view.GetViewId(), RECORD_PLAY_VOLUME_BUTTON_VIEWID) == 0) + { + printf("volume button being clicked\n"); + NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME); + return true; + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordPlayView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordPlayView.cpp new file mode 100644 index 000000000..b4675c1f0 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordPlayView.cpp @@ -0,0 +1,320 @@ +#include "record/include/RecordPlayView.h" +#include "record/include/RecordPlayPresenter.h" + +#include "UiConfig.h" + +namespace OHOS +{ + + static RecordPlayView *g_pRecordPlayView{nullptr}; + + RecordPlayView::RecordPlayView() + { + + g_pRecordPlayView = this; + } + + RecordPlayView::~RecordPlayView() + { + DeInitView(); + g_pRecordPlayView = nullptr; + } + + RecordPlayView *RecordPlayView::GetInstance() + { + + return g_pRecordPlayView; + } + // 按钮初始化 + UIButton *RecordPlayView::CreateUIButton(int left, int top, int width, int height, const char *viewId, + const char *defimagesrc, const char *toggleimagesrc, UIView::OnClickListener **buttonClick) + { + UIButton *button = new UIButton(); + if (button == nullptr) + return nullptr; + button->SetPosition(left, top); + button->Resize(width, height); + button->SetViewId(viewId); + button->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + button->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + button->SetStyle(STYLE_BORDER_OPA, 0x00); + button->SetStyle(STYLE_BORDER_RADIUS, 0); + button->SetStyle(STYLE_BORDER_COLOR, 0xffffffff); + + button->SetImageSrc(defimagesrc, toggleimagesrc); + button->SetStyle(STYLE_BORDER_COLOR, 0x191919); + button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + button->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + button->SetStyleForState(STYLE_BORDER_RADIUS, 0, UIButton::PRESSED); + + // Add the CallBack about events + *buttonClick = static_cast(RecordPlayPresenter::GetInstance()); + button->SetOnClickListener(*buttonClick); + return button; + } + + void RecordPlayView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + draglistener = static_cast(RecordPlayPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + container_->SetTouchable(true); + container_->SetDraggable(true); + } + + // Add ImageView to App + if (RECORD_PLAY_BACKGROUND_IMAGE == nullptr) + { + RECORD_PLAY_BACKGROUND_IMAGE = new UIImageView(); + } + RECORD_PLAY_BACKGROUND_IMAGE->SetPosition(0, 0); + RECORD_PLAY_BACKGROUND_IMAGE->Resize(466, 466); + RECORD_PLAY_BACKGROUND_IMAGE->SetViewId("RECORD_PLAY_BACKGROUND_IMAGE"); + RECORD_PLAY_BACKGROUND_IMAGE->SetSrc(PNG_RECORD_PLAY_BACKGROUND_IMAGE); + + // Add to rootView + container_->Add(RECORD_PLAY_BACKGROUND_IMAGE); + RECORD_PLAY_BACKGROUND_IMAGE->SetVisible(true); + /********************************************************************************************************/ + // Add Label to App + if (RecordLabel1 == nullptr) + { + RecordLabel1 = new UILabel(); + } + RecordLabel1->SetPosition(187, 52); + RecordLabel1->Resize(92, 41); + RecordLabel1->SetViewId("RecordLabel1"); + RecordLabel1->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + RecordLabel1->SetStyle(STYLE_TEXT_FONT, 35); + RecordLabel1->SetStyle(STYLE_LINE_HEIGHT, 41); + + // Set additional property + RecordLabel1->SetText("录音3"); + RecordLabel1->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + RecordLabel1->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + RecordLabel1->SetRollSpeed(0); + RecordLabel1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); + + // Add to rootView + container_->Add(RecordLabel1); + RecordLabel1->SetVisible(true); + /********************************************************************************************************/ + // Add Label to App + if (RecordLabel2 == nullptr) + { + RecordLabel2 = new UILabel(); + } + RecordLabel2->SetPosition(122, 102); + RecordLabel2->Resize(222, 33); + RecordLabel2->SetViewId("RecordLabel2"); + RecordLabel2->SetStyle(STYLE_TEXT_FONT, 28); + RecordLabel2->SetStyle(STYLE_LINE_HEIGHT, 33); + + // Set additional property + RecordLabel2->SetText("2022.04.21 -20:57"); + RecordLabel2->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + RecordLabel2->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + RecordLabel2->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + RecordLabel2->SetRollSpeed(0); + RecordLabel2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 28); + + // Add to rootView + container_->Add(RecordLabel2); + RecordLabel2->SetVisible(true); + /********************************************************************************************************/ + // Add CircleProgress to App + if (RECORD_PLAY_CircleProgress == nullptr) + { + RECORD_PLAY_CircleProgress = new UICircleProgress(); + } + RECORD_PLAY_CircleProgress->SetPosition(173, 173); + RECORD_PLAY_CircleProgress->Resize(120, 120); + RECORD_PLAY_CircleProgress->SetViewId("RECORD_PLAY_CircleProgress"); + RECORD_PLAY_CircleProgress->SetStyle(STYLE_BACKGROUND_OPA, 0x2b); + RECORD_PLAY_CircleProgress->SetStyle(STYLE_BORDER_RADIUS, 100); + RECORD_PLAY_CircleProgress->SetForegroundStyle(STYLE_BORDER_COLOR, 0xff000000); + RECORD_PLAY_CircleProgress->SetForegroundStyle(STYLE_LINE_COLOR, 0xffffffff); + RECORD_PLAY_CircleProgress->SetForegroundStyle(STYLE_LINE_WIDTH, 6); + RECORD_PLAY_CircleProgress->SetCenterPosition(60, 60); + RECORD_PLAY_CircleProgress->SetRadius(60); + RECORD_PLAY_CircleProgress->SetEndAngle(359); + RECORD_PLAY_CircleProgress->SetValue(20); + + // Add to rootView + container_->Add(RECORD_PLAY_CircleProgress); + RECORD_PLAY_CircleProgress->SetVisible(true); + /********************************************************************************************************/ + // Add CheckBox to App + if (RECORD_PLAY_PAUSE_CHECKBOX == nullptr) + { + RECORD_PLAY_PAUSE_CHECKBOX = new UICheckBox(); + } + RECORD_PLAY_PAUSE_CHECKBOX->SetPosition(208, 208); + RECORD_PLAY_PAUSE_CHECKBOX->Resize(50, 50); + RECORD_PLAY_PAUSE_CHECKBOX->SetViewId(RECORD_PLAY_PAUSE_CHECKBOX_VIEWID); + RECORD_PLAY_PAUSE_CHECKBOX->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + RECORD_PLAY_PAUSE_CHECKBOX->SetImages(PNG_UNIVERSAL_PAUSE_IMAGE, PNG_UNIVERSAL_PLAY_IMAGE); + + // Add the CallBack about events + UIView::OnClickListener *checkBoxClick = static_cast(RecordPlayPresenter::GetInstance()); + RECORD_PLAY_PAUSE_CHECKBOX->SetOnClickListener(checkBoxClick); + // Add to rootView + container_->Add(RECORD_PLAY_PAUSE_CHECKBOX); + RECORD_PLAY_PAUSE_CHECKBOX->SetVisible(true); + /********************************************************************************************************/ + // Add Button to App + if (RECORD_PLAY_PROVE_BUTTON == nullptr) + { + RECORD_PLAY_PROVE_BUTTON = CreateUIButton(60, 213, 40, 40, RECORD_PLAY_PROVE_BUTTON_VIEWID, PNG_RECORD_PLAY_PROVE_IMAGE, nullptr, &RECORD_PLAY_PROVE_BUTTON_CLICK); + } + // Add to rootView + container_->Add(RECORD_PLAY_PROVE_BUTTON); + RECORD_PLAY_PROVE_BUTTON->SetVisible(true); + /********************************************************************************************************/ + // Add Button to App + if (RECORD_PLAY_NEXT_BUTTON == nullptr) + { + RECORD_PLAY_NEXT_BUTTON = CreateUIButton(366, 213, 40, 40, RECORD_PLAY_NEXT_BUTTON_VIEWID, PNG_RECORD_PLAY_NEXT_IMAGE, nullptr, &RECORD_PLAY_NEXT_BUTTON_CLICK); + } + // Add to rootView + container_->Add(RECORD_PLAY_NEXT_BUTTON); + RECORD_PLAY_NEXT_BUTTON->SetVisible(true); + /********************************************************************************************************/ + // Add Button to App + if (RECORD_PLAY_DELETE_BUTTON == nullptr) + { + RECORD_PLAY_DELETE_BUTTON = CreateUIButton(137, 346, 40, 40, RECORD_PLAY_DELETE_BUTTON_VIEWID, PNG_RECORD_PLAY_DELETE_IMAGE, nullptr, &RECORD_PLAY_DELETE_BUTTON_CLICK); + } + // Add to rootView + container_->Add(RECORD_PLAY_DELETE_BUTTON); + RECORD_PLAY_DELETE_BUTTON->SetVisible(true); + /********************************************************************************************************/ + // Add Button to App + if (RECORD_PLAY_VOLUME_BUTTON == nullptr) + { + RECORD_PLAY_VOLUME_BUTTON = CreateUIButton(290, 346, 40, 40, RECORD_PLAY_VOLUME_BUTTON_VIEWID, PNG_RECORD_PLAY_VOLUME_IMAGE, nullptr, &RECORD_PLAY_VOLUME_BUTTON_CLICK); + } + // Add to rootView + container_->Add(RECORD_PLAY_VOLUME_BUTTON); + RECORD_PLAY_VOLUME_BUTTON->SetVisible(true); + /********************************************************************************************************/ + } + + void RecordPlayView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (RECORD_PLAY_BACKGROUND_IMAGE != nullptr) + { + delete RECORD_PLAY_BACKGROUND_IMAGE; + RECORD_PLAY_BACKGROUND_IMAGE = nullptr; + } + if (RECORD_PLAY_CircleProgress != nullptr) + { + delete RECORD_PLAY_CircleProgress; + RECORD_PLAY_CircleProgress = nullptr; + } + if (RECORD_PLAY_PAUSE_CHECKBOX != nullptr) + { + delete RECORD_PLAY_PAUSE_CHECKBOX; + RECORD_PLAY_PAUSE_CHECKBOX = nullptr; + } + if (RecordLabel1 != nullptr) + { + delete RecordLabel1; + RecordLabel1 = nullptr; + } + if (RecordLabel2 != nullptr) + { + delete RecordLabel2; + RecordLabel2 = nullptr; + } + if (RECORD_PLAY_PROVE_BUTTON != nullptr) + { + delete RECORD_PLAY_PROVE_BUTTON; + RECORD_PLAY_PROVE_BUTTON = nullptr; + } + if (RECORD_PLAY_NEXT_BUTTON != nullptr) + { + delete RECORD_PLAY_NEXT_BUTTON; + RECORD_PLAY_NEXT_BUTTON = nullptr; + } + if (RECORD_PLAY_DELETE_BUTTON != nullptr) + { + delete RECORD_PLAY_DELETE_BUTTON; + RECORD_PLAY_DELETE_BUTTON = nullptr; + } + if (RECORD_PLAY_VOLUME_BUTTON != nullptr) + { + delete RECORD_PLAY_VOLUME_BUTTON; + RECORD_PLAY_VOLUME_BUTTON = nullptr; + } + if (draglistener != nullptr) + { + delete draglistener; + draglistener = nullptr; + } + if (RECORD_PLAY_PROVE_BUTTON_CLICK != nullptr) + { + delete RECORD_PLAY_PROVE_BUTTON_CLICK; + RECORD_PLAY_PROVE_BUTTON_CLICK = nullptr; + } + if (RECORD_PLAY_NEXT_BUTTON_CLICK != nullptr) + { + delete RECORD_PLAY_NEXT_BUTTON_CLICK; + RECORD_PLAY_NEXT_BUTTON_CLICK = nullptr; + } + if (RECORD_PLAY_DELETE_BUTTON_CLICK != nullptr) + { + delete RECORD_PLAY_DELETE_BUTTON_CLICK; + RECORD_PLAY_DELETE_BUTTON_CLICK = nullptr; + } + if (RECORD_PLAY_VOLUME_BUTTON_CLICK != nullptr) + { + delete RECORD_PLAY_VOLUME_BUTTON_CLICK; + RECORD_PLAY_VOLUME_BUTTON_CLICK = nullptr; + } + } + + void RecordPlayView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void RecordPlayView::OnSetUpView() + { + View::OnSetUpView(); + Draw(); + } + + void RecordPlayView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void RecordPlayView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordPresenter.cpp new file mode 100644 index 000000000..d40f9ff9c --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordPresenter.cpp @@ -0,0 +1,83 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "record/include/RecordPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static RecordPresenter *g_pRecordPresenter = nullptr; + + RecordPresenter::RecordPresenter() + { + + g_pRecordPresenter = this; + } + + RecordPresenter::~RecordPresenter() + { + + g_pRecordPresenter = nullptr; + } + + RecordPresenter *RecordPresenter::GetInstance() + { + + return g_pRecordPresenter; + } + + void RecordPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void RecordPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void RecordPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void RecordPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool RecordPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + return true; + } + else if (event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD_LIST); + return true; + } + return false; + } + + bool RecordPresenter::OnClick(UIView &view, const ClickEvent &event) + { + + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), RECORD_BUTTON) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_RECORD_GOING); + return true; + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordView.cpp new file mode 100644 index 000000000..fa335e921 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/record/src/RecordView.cpp @@ -0,0 +1,228 @@ +#include "record/include/RecordView.h" +#include "record/include/RecordPresenter.h" +#include "UiConfig.h" + +namespace OHOS +{ + static ImageAnimatorInfo g_imageAnimator1Info[2] = { + {PNG_ANIMATOR1_IMAGE, {213, 400}, 40, 40, IMG_SRC_FILE_PATH}, + {PNG_ANIMATOR2_IMAGE, {213, 400}, 40, 40, IMG_SRC_FILE_PATH}, + }; + + static RecordView *g_pRecordView{nullptr}; + + RecordView::RecordView() + { + g_pRecordView = this; + } + + RecordView::~RecordView() + { + DeInitView(); + g_pRecordView = nullptr; + } + + RecordView *RecordView::GetInstance() + { + + return g_pRecordView; + } + void RecordView::InitView(void) + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + draglistener = static_cast(RecordPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + container_->SetTouchable(true); + container_->SetDraggable(true); + } + // Add ScrollView to App + if (scrollView == nullptr) + { + scrollView = new UIScrollView(); + } + scrollView->SetPosition(0, 0); + scrollView->Resize(466, 466); + scrollView->SetViewId("ScrollView"); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + // Add to rootView + container_->Add(scrollView); + scrollView->SetVisible(true); + + // Add Label to App + if (label1 == nullptr) + { + label1 = new UILabel(); + } + label1->SetPosition(188, 52); // widget's left position and top position + label1->Resize(90, 35); // widget's width and height + label1->SetViewId("label11"); // Set style + label1->SetStyle(STYLE_TEXT_FONT, 30); + label1->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label1->SetText("录音机"); + label1->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1->SetRollSpeed(0); + label1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView->Add(label1); + label1->SetVisible(true); + + // Add ImageView to App + if (RECORD1_Image == nullptr) + { + RECORD1_Image = new UIImageView(); + } + RECORD1_Image->SetPosition(158, 129); // widget's left position and top position + RECORD1_Image->Resize(150, 150); // widget's width and height + RECORD1_Image->SetViewId("RECORD1_Image"); // Set style + RECORD1_Image->SetStyle(STYLE_BORDER_RADIUS, 10); + RECORD1_Image->SetSrc(PNG_RECORD1_IMAGE); + // Add to scrollView1 + scrollView->Add(RECORD1_Image); + RECORD1_Image->SetVisible(true); + // Add Button to App + if (button == nullptr) + { + button = new UIButton(); + } + button->SetPosition(178, 150); + button->Resize(120, 120); + button->SetViewId(RECORD_BUTTON); + button->SetStyle(STYLE_BACKGROUND_COLOR, 0xffff5a36); + button->SetStyle(STYLE_BORDER_RADIUS, 100); + + // Set additional property + button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffff5a36, UIButton::PRESSED); + button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + button->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *buttonClick = static_cast(RecordPresenter::GetInstance()); + button->SetOnClickListener(buttonClick); + // Add to scrollView1 + scrollView->Add(button); + button->SetVisible(true); + + // Add Label to App + if (label2 == nullptr) + { + label2 = new UILabel(); + } + label2->SetPosition(143, 330); // widget's left position and top position + label2->Resize(180, 35); // widget's width and height + label2->SetViewId("label2"); // Set style + label2->SetStyle(STYLE_TEXT_FONT, 30); + label2->SetStyle(STYLE_LINE_HEIGHT, 35); + + // 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, 30); + + // Add to scrollView1 + scrollView->Add(label2); + label2->SetVisible(true); + + // Add ImageAnimatorView to App + if (imageAnimator1_ == nullptr) + { + imageAnimator1_ = new UIImageAnimatorView(); + } + imageAnimator1_->SetPosition(213, 400); + imageAnimator1_->Resize(40, 40); + imageAnimator1_->SetViewId("imageAnimator1"); + imageAnimator1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // Set additional property + imageAnimator1_->SetImageAnimatorSrc(g_imageAnimator1Info, 2, 200); + imageAnimator1_->SetTimeOfPause(200); + imageAnimator1_->SetRepeatTimes(1); + imageAnimator1_->SetReverse(true); + imageAnimator1_->Start(); + + // Add to scrollView1 + scrollView->Add(imageAnimator1_); + imageAnimator1_->SetVisible(true); + } + void RecordView::DeInitView(void) + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView != nullptr) + { + delete scrollView; + scrollView = nullptr; + } + if (label1 != nullptr) + { + delete label1; + label1 = nullptr; + } + if (RECORD1_Image != nullptr) + { + delete RECORD1_Image; + RECORD1_Image = nullptr; + } + if (button != nullptr) + { + delete button; + button = nullptr; + } + if (label2 != nullptr) + { + delete label2; + label2 = nullptr; + } + if (imageAnimator1_ != nullptr) + { + delete imageAnimator1_; + imageAnimator1_ = nullptr; + } + } + void RecordView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void RecordView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void RecordView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void RecordView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/saveele/include/SaveBatPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/saveele/include/SaveBatPresenter.h new file mode 100644 index 000000000..11892758c --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/saveele/include/SaveBatPresenter.h @@ -0,0 +1,36 @@ +#ifndef _SAVEBAT_PRESENTER_H +#define _SAVEBAT_PRESENTER_H + +#include "Presenter.h" +#include "SaveBatView.h" + +namespace OHOS +{ + class SaveBatView; + + class SaveBatPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener, + public UIView::OnLongPressListener + { + public: + SaveBatPresenter(); + virtual ~SaveBatPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static SaveBatPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnLongPress(UIView &view, const LongPressEvent &event); + + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/saveele/include/SaveBatView.h b/code/sdk/application/wearable/nativeapp/nativeui/saveele/include/SaveBatView.h new file mode 100644 index 000000000..b4c4bdabb --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/saveele/include/SaveBatView.h @@ -0,0 +1,60 @@ +#ifndef _SAVEBAT_VIEW_H +#define _SAVEBAT_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" + +#include "SaveBatPresenter.h" +#include + +namespace OHOS +{ + class SaveBatPresenter; + class SaveBatView : public View + { + + public: + SaveBatView(); + virtual ~SaveBatView(); + static SaveBatView *GetInstance(void); + void updateClock(); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + + // void InitImage(void); + // void InitLable(void); + + // 以下控件属性通过new实例化后,add到对应root属性上; + // SaveBatView(constSaveBatView &) = dBatte; + // SaveBatView &operator=(constSaveBatView &) = delete; + + SaveBatView(SaveBatView &&) = delete; + SaveBatView &operator=(SaveBatView &&) = delete; + UIViewGroup *container_ = nullptr; + UILabel *label1_ = nullptr; + UIImageView *image7_ = nullptr; + UIImageView *image8_ = nullptr; + UILabel *label2_ = nullptr; + UILabel *label3_ = nullptr; + UIButton *button1_ = nullptr; + + bool isRunning_; // 标志变量,用于控制线程的运行状态 + std::thread clockThread_; // 保存时针线程的对象 + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/saveele/include/SaveEleModel.h b/code/sdk/application/wearable/nativeapp/nativeui/saveele/include/SaveEleModel.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/nativeapp/nativeui/saveele/include/SaveElePresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/saveele/include/SaveElePresenter.h new file mode 100644 index 000000000..4e5e91c3b --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/saveele/include/SaveElePresenter.h @@ -0,0 +1,35 @@ +#ifndef _SAVEELE_PRESENTER_H +#define _SAVEELE_PRESENTER_H + + +#include "Presenter.h" +#include "SaveEleView.h" + +namespace OHOS +{ + class SaveEleView; + + class SaveElePresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + SaveElePresenter(); + virtual ~SaveElePresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static SaveElePresenter *GetInstance(); + + private: + //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} //namespace OHOS + + +#endif //SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/saveele/include/SaveEleView.h b/code/sdk/application/wearable/nativeapp/nativeui/saveele/include/SaveEleView.h new file mode 100644 index 000000000..625ff3ce0 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/saveele/include/SaveEleView.h @@ -0,0 +1,56 @@ +#ifndef _SAVEELE_VIEW_H +#define _SAVEELE_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" + +#include "SaveElePresenter.h" +namespace OHOS +{ + class SaveElePresenter; + class SaveEleView : public View + { + + public: + SaveEleView(); + virtual ~SaveEleView(); + static SaveEleView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + + // void InitImage(void); + // void InitLable(void); + + // 以下控件属性通过new实例化后,add到对应root属性上; + // SaveEleView(constSaveEleView &) = delete; + // SaveEleView &operator=(constSaveEleView &) = delete; + SaveEleView(SaveEleView &&) = delete; + SaveEleView &operator=(SaveEleView &&) = delete; + + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UILabel *label1_ = nullptr; + UILabel *label3_ = nullptr; + UILabel *label4_ = nullptr; + UIButton *button1_ = nullptr; + UIButton *button2_ = nullptr; + UIImageView *image2_ = nullptr; + UIImageView *image1_ = nullptr; + UILabel *label2_ = nullptr; + }; +} // namespace OHOS +#endif // SaveEle_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/saveele/src/SaveBatPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/saveele/src/SaveBatPresenter.cpp new file mode 100644 index 000000000..f6a241c3b --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/saveele/src/SaveBatPresenter.cpp @@ -0,0 +1,82 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "saveele/include/SaveBatPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static SaveBatPresenter *g_pSaveBatPresenter = nullptr; + + SaveBatPresenter::SaveBatPresenter() + { + + g_pSaveBatPresenter = this; + } + + SaveBatPresenter::~SaveBatPresenter() + { + + g_pSaveBatPresenter = nullptr; + } + + SaveBatPresenter *SaveBatPresenter::GetInstance() + { + + return g_pSaveBatPresenter; + } + + void SaveBatPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void SaveBatPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void SaveBatPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void SaveBatPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool SaveBatPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + // 返回 true 以消耗拖动事件 + return true; + } + + bool SaveBatPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 执行点击事件的处理逻辑 + // 根据控件id查找是哪个控件触发了点击回调 + // if (strcmp(view.GetViewId(), 控件ID) == 0 + // 返回 true 以消耗点击事件 + + + return true; + } + bool SaveBatPresenter::OnLongPress(UIView &view, const LongPressEvent &event) + { + // 1.长按三秒button1 + // 2.退出 button1NativeAbility::GetInstance().ChangeSlice(VIEW_SAVEELE); + // 3.返回 true 以消耗点击事件 + if (strcmp(view.GetViewId(), "button1") == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SAVEELE); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/saveele/src/SaveBatView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/saveele/src/SaveBatView.cpp new file mode 100644 index 000000000..d39012784 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/saveele/src/SaveBatView.cpp @@ -0,0 +1,278 @@ +/* + * Copyright (c) 2023 CompanyNameMagicTag. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "saveele/include/SaveBatView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include +#include +#include + +namespace OHOS +{ + static SaveBatView *g_pSaveBatView{nullptr}; + + SaveBatView::SaveBatView() + { + + g_pSaveBatView = this; + } + + SaveBatView::~SaveBatView() + { + DeInit(); + g_pSaveBatView = nullptr; + } + + SaveBatView *SaveBatView::GetInstance() + { + + return g_pSaveBatView; + } + void SaveBatView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(239, 52); // widget's left position and top position + label1_->Resize(200, 60); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 27); + + // Set additional property + label1_->SetText("10%"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 27); + + // Add to rootView + container_->Add(label1_); + label1_->SetVisible(true); + + // Add ImageView to App + if (image7_ == nullptr) + { + image7_ = new UIImageView(); + } + image7_->SetPosition(179, 52); // widget's left position and top position + image7_->Resize(48, 30); // widget's width and height + image7_->SetViewId("image7"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image7imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Save_Bat/Battery-E.bin"; +#else + char *image7imagesPath = "/user/res/Save_Ele/Battery-E.bin"; +#endif + image7_->SetSrc(image7imagesPath); + + // Add to rootView + container_->Add(image7_); + image7_->SetVisible(true); + + // Add ImageView to App + if (image8_ == nullptr) + { + image8_ = new UIImageView(); + } + image8_->SetPosition(182, 58); // widget's left position and top position + image8_->Resize(10, 18); // widget's width and height + image8_->SetViewId("image8"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image8imagesPath = "c:/Users/caiking/project/count/app/SaveBatView/image_converter_tool/output/Save_Bat/Battery-F.bin"; +#else + char *image8imagesPath = "/user/res/Save_Ele/Battery-F.bin"; +#endif + image8_->SetSrc(image8imagesPath); + + // Add to rootView + container_->Add(image8_); + image8_->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(118, 148); // widget's left position and top position + label2_->Resize(231, 115); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 100); + label2_->SetStyle(STYLE_LINE_HEIGHT, 115); + + // Set additional property + label2_->SetText("23:59"); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); + label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 100); + + // Add to rootView + container_->Add(label2_); + label2_->SetVisible(true); + + // Add Label to App + if (label3_ == nullptr) + { + label3_ = new UILabel(); + } + label3_->SetPosition(128, 268); // widget's left position and top position + label3_->Resize(210, 35); // widget's width and height + label3_->SetViewId("label3"); // Set style + label3_->SetStyle(STYLE_TEXT_FONT, 30); + label3_->SetStyle(STYLE_LETTER_SPACE, 2); + label3_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label3_->SetText("11月3号 星期五"); + label3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label3_->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); + label3_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label3_->SetRollSpeed(0); + label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label3_); + label3_->SetVisible(true); + + // Add Button to App + if (button1_ == nullptr) + { + button1_ = new UIButton(); + } + button1_->SetPosition(204, 350); // widget's left position and top position + button1_->Resize(60, 60); // widget's width and height + button1_->SetViewId("button1"); // Set style + button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Save_Bat/finger.bin"; +#else + char *button1defaultImgSrc = "/user/res/Save_Ele/finger.bin"; +#endif + char *button1triggeredImgSrc = nullptr; + button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + button1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnLongPressListener *button1LongPress = static_cast(SaveBatPresenter::GetInstance()); + button1_->SetOnLongPressListener(button1LongPress); + // Add to rootView + container_->Add(button1_); + button1_->SetVisible(true); + } + + void SaveBatView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (image7_ != nullptr) + { + delete image7_; + image7_ = nullptr; + } + if (image8_ != nullptr) + { + delete image8_; + image8_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (label3_ != nullptr) + { + delete label3_; + label3_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + } + + UIView *SaveBatView::GetView() + { + Init(); + return container_; + } + void SaveBatView::OnStart() + { + container_ = new UIViewGroup(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void SaveBatView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void SaveBatView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void SaveBatView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/saveele/src/SaveEleModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/saveele/src/SaveEleModel.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/nativeapp/nativeui/saveele/src/SaveElePresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/saveele/src/SaveElePresenter.cpp new file mode 100644 index 000000000..0d3e24f8f --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/saveele/src/SaveElePresenter.cpp @@ -0,0 +1,79 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "saveele/include/SaveElePresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static SaveElePresenter *g_pSaveElePresenter = nullptr; + + SaveElePresenter::SaveElePresenter() + { + + g_pSaveElePresenter = this; + } + + SaveElePresenter::~SaveElePresenter() + { + + g_pSaveElePresenter = nullptr; + } + + SaveElePresenter *SaveElePresenter::GetInstance() + { + + return g_pSaveElePresenter; + } + + void SaveElePresenter::OnStart() + { + + Presenter::OnStart(); + } + + void SaveElePresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void SaveElePresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void SaveElePresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool SaveElePresenter::OnDrag(UIView &view, const DragEvent &event) + { + + // if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) + // { + // NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + // } + UNUSED(view); + return true; + } + + bool SaveElePresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + // if (strcmp(view.GetViewId(), 控件ID) == 0) + if (strcmp(view.GetViewId(), "button1") == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + } + if (strcmp(view.GetViewId(), "button2") == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SAVEBAT); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/saveele/src/SaveEleView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/saveele/src/SaveEleView.cpp new file mode 100644 index 000000000..87ec8f3d8 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/saveele/src/SaveEleView.cpp @@ -0,0 +1,356 @@ + + +#include "saveele/include/SaveEleView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + + static SaveEleView *g_pSaveEleView{nullptr}; + + SaveEleView::SaveEleView() + { + + g_pSaveEleView = this; + } + + SaveEleView::~SaveEleView() + { + DeInit(); + g_pSaveEleView = nullptr; + } + + SaveEleView *SaveEleView::GetInstance() + { + + return g_pSaveEleView; + } + + void SaveEleView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add ScrollView to App + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); // widget's left position and top position + scrollView1_->Resize(466, 466); // widget's width and height + scrollView1_->SetViewId("scrollView1"); // Set style + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // Set additional property + scrollView1_->SetDirection(1); + + // Add the CallBack about events + UIView::OnDragListener *scrollView1Drag = static_cast(SaveElePresenter::GetInstance()); + scrollView1_->SetOnDragListener(scrollView1Drag); + // Add to rootView + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(173, 52); // widget's left position and top position + label1_->Resize(120, 35); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + label1_->SetStyle(STYLE_LINE_SPACE, 0); + label1_->SetStyle(STYLE_LETTER_SPACE, 1); + label1_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label1_->SetText("省电模式"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label1_); + label1_->SetVisible(true); + + // Add Label to App + if (label3_ == nullptr) + { + label3_ = new UILabel(); + } + label3_->SetPosition(33, 440); // widget's left position and top position + label3_->Resize(200, 60); // widget's width and height + label3_->SetViewId("label3"); // Set style + label3_->SetStyle(STYLE_TEXT_FONT, 30); + label3_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label3_->SetText("长按屏幕3秒以上或充电可退\n出省电模式"); + label3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label3_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xc3, 0x00, 0xff)); + label3_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label3_->SetRollSpeed(0); + label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label3_); + label3_->SetVisible(true); + + // Add Label to App + if (label4_ == nullptr) + { + label4_ = new UILabel(); + } + label4_->SetPosition(173, 547); // widget's left position and top position + label4_->Resize(400, 395); // widget's width and height + label4_->SetViewId("label4"); // Set style + label4_->SetStyle(STYLE_TEXT_FONT, 30); + label4_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label4_->SetText("是否开启"); + label4_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label4_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + label4_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label4_->SetRollSpeed(0); + label4_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label4_); + label4_->SetVisible(true); + + // Add Button to App + if (button1_ == nullptr) + { + button1_ = new UIButton(); + } + button1_->SetPosition(110, 636); // widget's left position and top position + button1_->Resize(100, 100); // widget's width and height + button1_->SetViewId("button1"); // Set style + button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/SaveEle/Save_Error.bin"; +#else + char *button1defaultImgSrc = "/user/res/Save_Ele/Save_Error.bin"; +#endif + char *button1triggeredImgSrc = nullptr; + button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + button1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffff1919, UIButton::PRESSED); + button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(SaveElePresenter::GetInstance()); + button1_->SetOnClickListener(button1Click); + // Add to scrollView1 + scrollView1_->Add(button1_); + button1_->SetVisible(true); + + // Add Button to App + if (button2_ == nullptr) + { + button2_ = new UIButton(); + } + button2_->SetPosition(255, 636); // widget's left position and top position + button2_->Resize(100, 100); // widget's width and height + button2_->SetViewId("button2"); // Set style + button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *button2defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/SaveEle/Save_Right.bin"; +#else + char *button2defaultImgSrc = "/user/res/Save_Ele/Save_Right.bin"; +#endif + char *button2triggeredImgSrc = nullptr; + button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc); + button2_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff19ff5e, UIButton::PRESSED); + button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button2Click = static_cast(SaveElePresenter::GetInstance()); + button2_->SetOnClickListener(button2Click); + // Add to scrollView1 + scrollView1_->Add(button2_); + button2_->SetVisible(true); + + // Add ImageView to App + if (image2_ == nullptr) + { + image2_ = new UIImageView(); + } + image2_->SetPosition(183, 775); // widget's left position and top position + image2_->Resize(100, 100); // widget's width and height + image2_->SetViewId("image2"); // Set style + + // Set additional property + + // Add to scrollView1 + scrollView1_->Add(image2_); + image2_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(188, 121); // widget's left position and top position + image1_->Resize(90, 90); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/SaveEle/SaveEle.bin"; +#else + char *image1imagesPath = "/user/res/Save_Ele/SaveEle.bin"; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to scrollView1 + scrollView1_->Add(image1_); + image1_->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(33, 217); // widget's left position and top position + label2_->Resize(400, 395); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 30); + label2_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label2_->SetText("开启省电模式会关闭非必要的\n蓝牙连接(通话/耳机蓝牙),以\n及传感器监测(心率监测及血\n氧监测等会停止)等功能\n 仅保留时间日期可查看"); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label2_); + label2_->SetVisible(true); + } + + void SaveEleView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (label3_ != nullptr) + { + delete label3_; + label3_ = nullptr; + } + if (label4_ != nullptr) + { + delete label4_; + label4_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + if (button2_ != nullptr) + { + delete button2_; + button2_ = nullptr; + } + if (image2_ != nullptr) + { + delete image2_; + image2_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + } + + UIView *SaveEleView::GetView() + { + Init(); + return container_; + } + void SaveEleView::OnStart() + { + container_ = new UIScrollView(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight() * 2); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(SaveElePresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void SaveEleView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void SaveEleView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void SaveEleView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/screenduration/include/ScreenDurationPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/screenduration/include/ScreenDurationPresenter.h new file mode 100644 index 000000000..05f761263 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/screenduration/include/ScreenDurationPresenter.h @@ -0,0 +1,44 @@ +#ifndef SCREEN_DUATION_PRESENTER_H +#define SCREEN_DUATION_PRESENTER_H + +#include "Presenter.h" + +#include "ScreenDurationView.h" +#include "components/ui_checkbox.h" +#include "components/ui_label.h" +namespace OHOS +{ + class ScreenDurationView; + + class ScreenDurationPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + ScreenDurationPresenter(); + virtual ~ScreenDurationPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + static ScreenDurationPresenter *GetInstance(); + void getcheckbox(UICheckBox *checkbox_5,UICheckBox *checkbox_10,UICheckBox *checkbox_15){ + m_checkbox_5 = checkbox_5; + m_checkbox_10 = checkbox_10; + m_checkbox_15 = checkbox_15; + } + void UpdateCheckBoxState(UICheckBox &checkbox, bool isSelected); + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + + private: + UICheckBox *m_checkbox_5 = nullptr; + UICheckBox *m_checkbox_10 = nullptr; + UICheckBox *m_checkbox_15 = nullptr; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/screenduration/include/ScreenDurationView.h b/code/sdk/application/wearable/nativeapp/nativeui/screenduration/include/ScreenDurationView.h new file mode 100644 index 000000000..a808060f9 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/screenduration/include/ScreenDurationView.h @@ -0,0 +1,50 @@ +#ifndef SCREEN_DUATION_VIEW_H +#define SCREEN_DUATION_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_image_view.h" +#include "components/ui_label.h" +#include "components/ui_checkbox.h" +namespace OHOS +{ + static const char *SECOND5_CHECKBOX = "5secCheckbox"; // 5秒 + static const char *SECOND10_CHECKBOX = "10secCheckbox"; // 10秒 + static const char *SECOND15_CHECKBOX = "15secCheckbox"; // 15秒 + class ScreenDurationPresenter; + class ScreenDurationView : public View + { + + public: + ScreenDurationView(); + virtual ~ScreenDurationView(); + static ScreenDurationView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + public: + // void AddLabelImageViewCheckbox(UIScrollView *parentView, int labelLeft, int labelTop, int labelWidth, int labelHeight, + // const char *labelText, const char *labeId, int imageLeft, int imageTop, int imageWidth, int imageHeight, const char *imageId, + // const char *imagePath, UICheckBox *checkbox, int checkboxLeft, int checkboxTop, int checkboxWidth, int checkboxHeight, const char *checkboxId, + // const char *selectedImagePath, const char *unselectedImagePath); + + UICheckBox *second5checkbox = nullptr; + UICheckBox *second10checkbox = nullptr; + UICheckBox *second15checkbox = nullptr; + + private: + void InitView(void); + + private: + UIViewGroup *container_ = nullptr; + UIScrollView *ScreenDurationScrollView = nullptr; + UILabel *ScreenDurationLabel = nullptr; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/screenduration/src/ScreenDurationPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/screenduration/src/ScreenDurationPresenter.cpp new file mode 100644 index 000000000..823f4ebbe --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/screenduration/src/ScreenDurationPresenter.cpp @@ -0,0 +1,98 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "screenduration/include/ScreenDurationPresenter.h" +#include "components/ui_checkbox.h" +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static ScreenDurationPresenter *g_pScreenDurationPresenter = nullptr; + + ScreenDurationPresenter::ScreenDurationPresenter() + { + + g_pScreenDurationPresenter = this; + } + + ScreenDurationPresenter::~ScreenDurationPresenter() + { + + g_pScreenDurationPresenter = nullptr; + } + + ScreenDurationPresenter *ScreenDurationPresenter::GetInstance() + { + + return g_pScreenDurationPresenter; + } + + + + void ScreenDurationPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void ScreenDurationPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void ScreenDurationPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void ScreenDurationPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool ScreenDurationPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_DISPLAY_BRIGHTNESS); // 跳转到显示与亮度view + } + return true; + } + + + + bool ScreenDurationPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), SECOND5_CHECKBOX) == 0) + { + m_checkbox_5->SetState(UICheckBox::SELECTED); + UpdateCheckBoxState(*m_checkbox_10, false); + UpdateCheckBoxState(*m_checkbox_15, false); + return true; + } + else if (strcmp(view.GetViewId(), SECOND10_CHECKBOX) == 0) + { + m_checkbox_10->SetState(UICheckBox::SELECTED); + UpdateCheckBoxState(*m_checkbox_5, false); + UpdateCheckBoxState(*m_checkbox_15, false); + } + else if (strcmp(view.GetViewId(), SECOND15_CHECKBOX) == 0) + { + m_checkbox_15->SetState(UICheckBox::SELECTED); + UpdateCheckBoxState(*m_checkbox_5, false); + UpdateCheckBoxState(*m_checkbox_10, false); + } + return false; + } + void ScreenDurationPresenter::UpdateCheckBoxState(UICheckBox &checkbox, bool isSelected) + { + checkbox.SetState(isSelected ? UICheckBox::SELECTED : UICheckBox::UNSELECTED); + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/screenduration/src/ScreenDurationView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/screenduration/src/ScreenDurationView.cpp new file mode 100644 index 000000000..1037433c9 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/screenduration/src/ScreenDurationView.cpp @@ -0,0 +1,312 @@ +#include "screenduration/include/ScreenDurationView.h" +#include "screenduration/include/ScreenDurationPresenter.h" +#include "UiConfig.h" + +namespace OHOS +{ + + static ScreenDurationView *g_pScreenDurationView{nullptr}; + + ScreenDurationView::ScreenDurationView() + { + + g_pScreenDurationView = this; + } + + ScreenDurationView::~ScreenDurationView() + { + g_pScreenDurationView = nullptr; + } + + ScreenDurationView *ScreenDurationView::GetInstance() + { + return g_pScreenDurationView; + } + /* + 不知道什么原因:在使用这个函数时为三个复选框绑定点击事件时视图创建不了,或者是视图创建了,点击复选框屏幕卡死然后重启 + void ScreenDurationView::AddLabelImageViewCheckbox(UIScrollView *parentView, int labelLeft, int labelTop, int labelWidth, int labelHeight, + const char *labelText, const char *labeId, int imageLeft, int imageTop, int imageWidth, int imageHeight, const char *imageId, + const char *imagePath, UICheckBox *checkbox, int checkboxLeft, int checkboxTop, int checkboxWidth, int checkboxHeight, const char *checkboxId, + const char *selectedImagePath, const char *unselectedImagePath) + { + // Add ImageView to App + UIImageView *image = new UIImageView(); + image->SetPosition(imageLeft, imageTop); + image->Resize(imageWidth, imageHeight); + image->SetViewId(imageId); + image->SetStyle(STYLE_BORDER_RADIUS, 50); + image->SetSrc(imagePath); + parentView->Add(image); + image->SetVisible(true); + + // Add Label to App + UILabel *label = new UILabel(); + label->SetPosition(labelLeft, labelTop); + label->Resize(labelWidth, labelHeight); + label->SetViewId(labeId); + label->SetStyle(STYLE_TEXT_FONT, 30); + label->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + label->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + label->SetStyle(STYLE_LINE_HEIGHT, 35); + + label->SetText(labelText); + label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(6); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + parentView->Add(label); + label->SetVisible(true); + + // Add CheckBox to App + checkbox = new UICheckBox(); + checkbox->SetPosition(checkboxLeft, checkboxTop); + checkbox->Resize(checkboxWidth, checkboxHeight); + checkbox->SetViewId(checkboxId); + checkbox->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + checkbox->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + checkbox->SetImages(selectedImagePath, unselectedImagePath); + + parentView->Add(checkbox); + checkbox->SetVisible(true); + } + */ + void ScreenDurationView::InitView(void) + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + UIView::OnDragListener *draglistener = static_cast(ScreenDurationPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + container_->SetTouchable(true); + container_->SetDraggable(true); + } + + // Add ScrollView to App + if (ScreenDurationScrollView == nullptr) + { + ScreenDurationScrollView = new UIScrollView(); + } + ScreenDurationScrollView->SetPosition(0, 0); + ScreenDurationScrollView->Resize(466, 466); + ScreenDurationScrollView->SetViewId("ScreenDurationScrollView"); + ScreenDurationScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + container_->Add(ScreenDurationScrollView); + ScreenDurationScrollView->SetVisible(true); + + // Add Label to App + if (ScreenDurationLabel == nullptr) + { + ScreenDurationLabel = new UILabel(); + } + ScreenDurationLabel->SetPosition(173, 52); // widget's left position and top position + ScreenDurationLabel->Resize(120, 35); // widget's width and height + ScreenDurationLabel->SetViewId("ScreenDurationLabel"); // Set style + ScreenDurationLabel->SetStyle(STYLE_TEXT_FONT, 30); + ScreenDurationLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + ScreenDurationLabel->SetText("亮屏时长"); + ScreenDurationLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + ScreenDurationLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + ScreenDurationLabel->SetRollSpeed(0); + ScreenDurationLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + ScreenDurationScrollView->Add(ScreenDurationLabel); + ScreenDurationLabel->SetVisible(true); + /********************************************************************************************************/ + // Add ImageView to App + UIImageView *secImage5 = new UIImageView(); + secImage5->SetPosition(39, 120); + secImage5->Resize(380, 100); + secImage5->SetViewId("5secImage"); + secImage5->SetStyle(STYLE_BORDER_RADIUS, 50); + secImage5->SetSrc(PNG_SETTING_BACKGROUND_IMAGE); + ScreenDurationScrollView->Add(secImage5); + secImage5->SetVisible(true); + // Add Label to App + UILabel *secLabel5 = new UILabel(); + secLabel5->SetPosition(99, 153); + secLabel5->Resize(48, 35); + secLabel5->SetViewId("5secLabel"); + secLabel5->SetStyle(STYLE_TEXT_FONT, 30); + secLabel5->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + secLabel5->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + secLabel5->SetStyle(STYLE_LINE_HEIGHT, 35); + + secLabel5->SetText("5秒"); + secLabel5->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + secLabel5->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + secLabel5->SetRollSpeed(6); + secLabel5->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + ScreenDurationScrollView->Add(secLabel5); + secLabel5->SetVisible(true); + + // Add CheckBox to App + second5checkbox = new UICheckBox(); + second5checkbox->SetPosition(300, 130); + second5checkbox->Resize(80, 80); + second5checkbox->SetViewId(SECOND5_CHECKBOX); + second5checkbox->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + second5checkbox->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + second5checkbox->SetImages(PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE); + + ScreenDurationScrollView->Add(second5checkbox); + second5checkbox->SetVisible(true); + /********************************************************************************************************/ + // Add ImageView to App + UIImageView *secImage10 = new UIImageView(); + secImage10->SetPosition(39, 240); + secImage10->Resize(380, 100); + secImage10->SetViewId("10secImage"); + secImage10->SetStyle(STYLE_BORDER_RADIUS, 50); + secImage10->SetSrc(PNG_SETTING_BACKGROUND_IMAGE); + ScreenDurationScrollView->Add(secImage10); + secImage10->SetVisible(true); + + // Add Label to App + UILabel *secLabel10 = new UILabel(); + secLabel10->SetPosition(99, 273); + secLabel10->Resize(65, 35); + secLabel10->SetViewId("10secLabel"); + secLabel10->SetStyle(STYLE_TEXT_FONT, 30); + secLabel10->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + secLabel10->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + secLabel10->SetStyle(STYLE_LINE_HEIGHT, 35); + + secLabel10->SetText("10秒"); + secLabel10->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + secLabel10->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + secLabel10->SetRollSpeed(6); + secLabel10->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + ScreenDurationScrollView->Add(secLabel10); + secLabel10->SetVisible(true); + + // Add CheckBox to App + second10checkbox = new UICheckBox(); + second10checkbox->SetPosition(300, 250); + second10checkbox->Resize(80, 80); + second10checkbox->SetViewId(SECOND10_CHECKBOX); + second10checkbox->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + second10checkbox->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + second10checkbox->SetImages(PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE); + + ScreenDurationScrollView->Add(second10checkbox); + second10checkbox->SetVisible(true); + /********************************************************************************************************/ + // Add ImageView to App + UIImageView *secImage15 = new UIImageView(); + secImage15->SetPosition(39, 360); + secImage15->Resize(380, 100); + secImage15->SetViewId("15secImage"); + secImage15->SetStyle(STYLE_BORDER_RADIUS, 50); + secImage15->SetSrc(PNG_SETTING_BACKGROUND_IMAGE); + ScreenDurationScrollView->Add(secImage15); + secImage15->SetVisible(true); + + // Add Label to App + UILabel *secLabel15 = new UILabel(); + secLabel15->SetPosition(99, 393); + secLabel15->Resize(65, 35); + secLabel15->SetViewId("15secLabel"); + secLabel15->SetStyle(STYLE_TEXT_FONT, 30); + secLabel15->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + secLabel15->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + secLabel15->SetStyle(STYLE_LINE_HEIGHT, 35); + + secLabel15->SetText("15秒"); + secLabel15->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + secLabel15->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + secLabel15->SetRollSpeed(6); + secLabel15->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + ScreenDurationScrollView->Add(secLabel15); + secLabel15->SetVisible(true); + + // Add CheckBox to App + second15checkbox = new UICheckBox(); + second15checkbox->SetPosition(300, 370); + second15checkbox->Resize(80, 80); + second15checkbox->SetViewId(SECOND15_CHECKBOX); + second15checkbox->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + second15checkbox->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + second15checkbox->SetImages(PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE); + + ScreenDurationScrollView->Add(second15checkbox); + second15checkbox->SetVisible(true); + /********************************************************************************************************/ + // AddLabelImageViewCheckbox(ScreenDurationScrollView, 99, 153, 48, 35, "5秒", "5secLabel", + // 39, 120, 380, 100, "5secImage", PNG_SETTING_BACKGROUND_IMAGE, + // second5checkbox, 300, 130, 80, 80, SECOND5_CHECKBOX, PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE); + /* + AddLabelImageViewCheckbox(ScreenDurationScrollView, 99, 273, 65, 35, "10秒", "10secLabel", + 39, 240, 380, 100, "10secImage", PNG_SETTING_BACKGROUND_IMAGE, + second10checkbox, 300, 250, 80, 80, SECOND10_CHECKBOX, PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE); + + AddLabelImageViewCheckbox(ScreenDurationScrollView, 99, 393, 65, 35, "15秒", "15secLabel", + 39, 360, 380, 100, "15secImage", PNG_SETTING_BACKGROUND_IMAGE, + second15checkbox, 300, 370, 80, 80, SECOND15_CHECKBOX, PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE); + */ + + /********************************************************************************************************/ + UIImageView *image1_ = new UIImageView(); + + image1_->SetPosition(183, 440); + image1_->Resize(100, 100); + image1_->SetViewId("image1"); + ScreenDurationScrollView->Add(image1_); + image1_->SetVisible(true); + /********************************************************************************************************/ + + UIImageView *image2_ = new UIImageView(); + + image2_->SetPosition(183, 19); + image2_->Resize(100, 100); + image2_->SetViewId("image2"); + ScreenDurationScrollView->Add(image2_); + image2_->SetVisible(true); + + ScreenDurationPresenter::GetInstance()->getcheckbox(second5checkbox,second10checkbox,second15checkbox); + UIView::OnClickListener *checkboxClick = static_cast(ScreenDurationPresenter::GetInstance()); + second5checkbox->SetOnClickListener(checkboxClick); + second10checkbox->SetOnClickListener(checkboxClick); + second15checkbox->SetOnClickListener(checkboxClick); + } + + void ScreenDurationView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void ScreenDurationView::OnSetUpView() + { + View::OnSetUpView(); + Draw(); + } + + void ScreenDurationView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void ScreenDurationView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItem.h b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItem.h index 448deb599..3010026ea 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItem.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItem.h @@ -20,6 +20,7 @@ typedef enum : uint16_t { SETTING_ITEM_ONE, SETTING_ITEM_TWO, SETTING_ITEM_THREE, + SETTING_ITEM_FIVE, } SettingIndex; typedef struct { diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItemView.h b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItemView.h index 20de7163c..98cbb7715 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItemView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItemView.h @@ -26,7 +26,7 @@ public: private: SettingItemView(const SettingItemView &); - + UIImageView sBackgroundImage; UIImageView sIcon; UILabel sLabel; UIImageView sNextImage; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingItemView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingItemView.cpp index f9b7424e3..5ec8fb319 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingItemView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingItemView.cpp @@ -9,17 +9,18 @@ #include "SettingItemView.h" namespace OHOS { - static constexpr int16 SETTING_ICON_X = 20; + static constexpr int16 SETTING_ICON_X = 19; + static constexpr int16_t SETTING_SICON_Y = 19; 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 SETTING_ITEM_LABEL_WIDTH = 150; + static constexpr int16_t SETTING_ITEM_LABEL_HEIGHT = 35; + static constexpr int16 SETTING_ITEM_FONT_SIZE = 30; 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; - + static int SETTIG_BACKGROUND_HEIGHT_COUNT = 1; SettingItemView::SettingItemView() { SetPosition(0, 0, HORIZONTAL_RESOLUTION, SETTING_ITEM_BUTTON_HEIGHT); @@ -27,7 +28,7 @@ namespace OHOS { SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY); SetTouchable(true); SetUpChild(); - + Add(&sBackgroundImage); Add(&sIcon); Add(&sLabel); Add(&sNextImage); @@ -35,6 +36,7 @@ namespace OHOS { SettingItemView::~SettingItemView() { + Remove(&sBackgroundImage); Remove(&sIcon); Remove(&sLabel); Remove(&sNextImage); @@ -50,20 +52,28 @@ namespace OHOS { void SettingItemView::SetUpChild() { + sBackgroundImage.SetSrc(PNG_SETTING_BACKGROUND_IMAGE); + sBackgroundImage.Resize(380,100); + sBackgroundImage.SetStyle(STYLE_BORDER_RADIUS,50); + sBackgroundImage.SetPosition(13,(SETTING_ITEM_HEIGHT - sBackgroundImage.GetHeight())); + sBackgroundImage.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); + sIcon.SetPosition(SETTING_ICON_X, SETTING_SICON_Y); sIcon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); - sLabel.SetPosition(SETTING_ITEM_LABEL_WIDTH, 0); + sLabel.SetPosition(115,33); 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_LINE_HEIGHT,35); + 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); + sLabel.SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); sNextImage.SetSrc(PNG_SETTING_NEXT_IMAGE); - sNextImage.SetPosition(LA_HORIZONTAL_RESOLUTION - NUMS_50, (SETTING_ITEM_HEIGHT - sNextImage.GetHeight()) / NUMS_2); + sNextImage.Resize(14,26); + sNextImage.SetPosition(326, (SETTING_ITEM_HEIGHT - sNextImage.GetHeight()) / NUMS_2); sNextImage.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingModel.cpp index 016996c62..4422e0f7c 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingModel.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingModel.cpp @@ -21,14 +21,24 @@ namespace OHOS { void SettingModel::InitSettingItem() { - settings[0] = {SETTING_ITEM_ZERO, PNG_BLUETOOTH_STITLE, "蓝牙耳机", true}; - settings[1] = {SETTING_ITEM_ONE, PNG_CONNECT_PHONE_IMAGE, "连接手机", true}; - settings[2] = {SETTING_ITEM_TWO, PNG_SETTTING_REBOOT_IMAGE, "重启", true}; - settings[3] = {SETTING_ITEM_THREE, PNG_SETTTING_SHUTDOWN_IMAGE, "关机", true}; - settingIdToViewId.insert(std::pair(SETTING_ITEM_ZERO, VIEW_BLUETOOTH_EARPHONE)); - settingIdToViewId.insert(std::pair(SETTING_ITEM_ONE, VIEW_CONNECT_PHONE)); - settingIdToViewId.insert(std::pair(SETTING_ITEM_TWO, VIEW_REBOOT)); - settingIdToViewId.insert(std::pair(SETTING_ITEM_THREE, VIEW_REBOOT)); + // settings[0] = {SETTING_ITEM_ZERO, PNG_BLUETOOTH_STITLE, "蓝牙耳机", true}; + // settings[1] = {SETTING_ITEM_ONE, PNG_CONNECT_PHONE_IMAGE, "连接手机", true}; + // settings[2] = {SETTING_ITEM_TWO, PNG_SETTTING_REBOOT_IMAGE, "重启", true}; + // settings[3] = {SETTING_ITEM_THREE, PNG_SETTTING_SHUTDOWN_IMAGE, "关机", true}; + // settingIdToViewId.insert(std::pair(SETTING_ITEM_ZERO, VIEW_BLUETOOTH_EARPHONE)); + // settingIdToViewId.insert(std::pair(SETTING_ITEM_ONE, VIEW_CONNECT_PHONE)); + // settingIdToViewId.insert(std::pair(SETTING_ITEM_TWO, VIEW_REBOOT)); + // settingIdToViewId.insert(std::pair(SETTING_ITEM_THREE, VIEW_REBOOT)); + settings[0] = {SETTING_ITEM_ZERO, PNG_DISPLAY_BRIGHTNESS, "屏幕与亮度", true}; + settings[1] = {SETTING_ITEM_ONE, PNG_BLUETOOTH, "蓝牙", true}; + settings[2] = {SETTING_ITEM_TWO, PNG_SOUND_VIBRATION, "声音与震动", true}; + settings[3] = {SETTING_ITEM_THREE, PNG_QUICK_ACCESS, "快速访问", true}; + settings[4] = {SETTING_ITEM_FIVE, PNG_SYSTEM, "系统", true}; + settingIdToViewId.insert(std::pair(SETTING_ITEM_ZERO, VIEW_DISPLAY_BRIGHTNESS)); + settingIdToViewId.insert(std::pair(SETTING_ITEM_ONE, VIEW_CONNECT_BLUETOOTH)); + settingIdToViewId.insert(std::pair(SETTING_ITEM_TWO, VIEW_SOUND_VIBRATION)); + settingIdToViewId.insert(std::pair(SETTING_ITEM_THREE, VIEW_QUICK_ACCESS)); + settingIdToViewId.insert(std::pair(SETTING_ITEM_FIVE, VIEW_SYSTEM)); } const SettingItem *SettingModel::GetSettinglistItems() const diff --git a/code/sdk/application/wearable/nativeapp/nativeui/sleep/include/SleepActPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/sleep/include/SleepActPresenter.h new file mode 100644 index 000000000..71f0b97b4 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/sleep/include/SleepActPresenter.h @@ -0,0 +1,32 @@ +#ifndef _SLEEPACT_PRESENTER_H +#define _SLEEPACT_PRESENTER_H + +#include "Presenter.h" +#include "SleepActView.h" + +namespace OHOS +{ + class SleepActView; + + class SleepActPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + SleepActPresenter(); + virtual ~SleepActPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static SleepActPresenter *GetInstance(); + + private: + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // _SleepAct_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/sleep/include/SleepActView.h b/code/sdk/application/wearable/nativeapp/nativeui/sleep/include/SleepActView.h new file mode 100644 index 000000000..4eb0f2cea --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/sleep/include/SleepActView.h @@ -0,0 +1,56 @@ +#ifndef _SLEEPACT_VIEW_H +#define _SLEEPACT_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" + +#include "SleepActPresenter.h" +namespace OHOS +{ + class SleepActPresenter; + class SleepActView : public View + { + + public: + SleepActView(); + virtual ~SleepActView(); + static SleepActView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + UIView *GetView(); + + private: + // UIView::OnDragListener *draglistener{nullptr}; + + // void InitImage(void); + // void InitLable(void); + + // 以下控件属性通过new实例化后,add到对应root属性上; + // SleepActView(constSleepActView &) = delete; + // SleepActView &operator=(constSleepActView &) = delete; + SleepActView(SleepActView &&) = delete; + SleepActView &operator=(SleepActView &&) = delete; + + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UILabel *label1_ = nullptr; + UIButton *button1_ = nullptr; + UILabel *label4_ = nullptr; + UIImageView *image3_ = nullptr; + UIImageView *image1_ = nullptr; + UIImageView *image2_ = nullptr; + UILabel *label2_ = nullptr; + UILabel *label3_ = nullptr; + }; +} // namespace OHOS +#endif // SleepAct_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/sleep/include/SleepPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/sleep/include/SleepPresenter.h new file mode 100644 index 000000000..f52cdfdd5 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/sleep/include/SleepPresenter.h @@ -0,0 +1,35 @@ +#ifndef _SLEEP_PRESENTER_H +#define _SLEEP_PRESENTER_H + + +#include "Presenter.h" +#include "SleepView.h" + +namespace OHOS +{ + class SleepView; + + class SleepPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + SleepPresenter(); + virtual ~SleepPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static SleepPresenter *GetInstance(); + + private: + //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} //namespace OHOS + + +#endif //SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/sleep/include/SleepTimePresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/sleep/include/SleepTimePresenter.h new file mode 100644 index 000000000..7495db76f --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/sleep/include/SleepTimePresenter.h @@ -0,0 +1,32 @@ +#ifndef _SLEEPTIME_PRESENTER_H +#define _SLEEPTIME_PRESENTER_H + +#include "Presenter.h" +#include "SleepTimeView.h" + +namespace OHOS +{ + class SleepTimeView; + + class SleepTimePresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + SleepTimePresenter(); + virtual ~SleepTimePresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static SleepTimePresenter *GetInstance(); + + private: + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // _SLEEPTIME_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/sleep/include/SleepTimeView.h b/code/sdk/application/wearable/nativeapp/nativeui/sleep/include/SleepTimeView.h new file mode 100644 index 000000000..9706e8b87 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/sleep/include/SleepTimeView.h @@ -0,0 +1,58 @@ +#ifndef _SLEEPTIME_VIEW_H +#define _SLEEPTIME_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" + +#include "SleepTimePresenter.h" +namespace OHOS +{ + class SleepTimePresenter; + class SleepTimeView : public View + { + + public: + SleepTimeView(); + virtual ~SleepTimeView(); + static SleepTimeView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + UIView *GetView(); + + private: + // UIView::OnDragListener *draglistener{nullptr}; + + // void InitImage(void); + // void InitLable(void); + + // 以下控件属性通过new实例化后,add到对应root属性上; + // SleepTimeView(constSleepTimeView &) = delete; + // SleepTimeView &operator=(constSleepTimeView &) = delete; + SleepTimeView(SleepTimeView &&) = delete; + SleepTimeView &operator=(SleepTimeView &&) = delete; + + UIViewGroup *container_ = nullptr; + UILabel *label1_ = nullptr; + UIButton *button1_ = nullptr; + UILabel *label2_ = nullptr; + UIImageView *image1_ = nullptr; + UILabel *label4_ = nullptr; + UILabel *label3_ = nullptr; + UIImageView *image2_ = nullptr; + UILabel *label5_ = nullptr; + UILabel *label6_ = nullptr; + UIImageView *image3_ = nullptr; + UILabel *label7_ = nullptr; + }; +} // namespace OHOS +#endif // SleepTime_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/sleep/include/SleepView.h b/code/sdk/application/wearable/nativeapp/nativeui/sleep/include/SleepView.h new file mode 100644 index 000000000..e5d54819e --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/sleep/include/SleepView.h @@ -0,0 +1,56 @@ +#ifndef _SLEEP_VIEW_H +#define _SLEEP_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" + +#include "SleepPresenter.h" +namespace OHOS +{ + class SleepPresenter; + class SleepView : public View + { + + public: + SleepView(); + virtual ~SleepView(); + static SleepView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + + // void InitImage(void); + // void InitLable(void); + + // 以下控件属性通过new实例化后,add到对应root属性上; + // SleepView(constSleepView &) = delete; + // SleepView &operator=(constSleepView &) = delete; + SleepView(SleepView &&) = delete; + SleepView &operator=(SleepView &&) = delete; + + UIViewGroup *container_ = nullptr; + UILabel *label1_ = nullptr; + UIImageView *image2_ = nullptr; + UIImageView *image1_ = nullptr; + UILabel *label3_ = nullptr; + UILabel *label2_ = nullptr; + UILabel *label5_ = nullptr; + UILabel *label6_ = nullptr; + UILabel *label4_ = nullptr; + UIImageView *image3_ = nullptr; + }; +} // namespace OHOS +#endif // Sleep_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/sleep/src/SleepActPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/sleep/src/SleepActPresenter.cpp new file mode 100644 index 000000000..1d8b99de8 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/sleep/src/SleepActPresenter.cpp @@ -0,0 +1,86 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "sleep/include/SleepActPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static SleepActPresenter *g_pSleepActPresenter = nullptr; + + SleepActPresenter::SleepActPresenter() + { + + g_pSleepActPresenter = this; + } + + SleepActPresenter::~SleepActPresenter() + { + + g_pSleepActPresenter = nullptr; + } + + SleepActPresenter *SleepActPresenter::GetInstance() + { + + return g_pSleepActPresenter; + } + + void SleepActPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void SleepActPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void SleepActPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void SleepActPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + // void Button1OnClickCallBack2(UIView &view, const ClickEvent &event) + // { + // NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + // return; + // } + + bool SleepActPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + + return true; + } + + bool SleepActPresenter::OnClick(UIView &view, const ClickEvent &event) + { + + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), "button1") == 0) + { + + // 执行按键1点击事件的处理逻辑 + //Button1OnClickCallBack2(view, event); + + NativeAbility::GetInstance().ChangeSlice(VIEW_SLEEPTIME); + + // 返回 true 以消耗点击事件 + return true; + } + + // 返回 false 表示未处理点击事件 + return false; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/sleep/src/SleepActView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/sleep/src/SleepActView.cpp new file mode 100644 index 000000000..9e6c9a6d1 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/sleep/src/SleepActView.cpp @@ -0,0 +1,328 @@ +#include "sleep/include/SleepActView.h" +#include "sleep/include/SleepActPresenter.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + + static SleepActView *g_pSleepActView{nullptr}; + + SleepActView::SleepActView() + { + + g_pSleepActView = this; + } + + SleepActView::~SleepActView() + { + DeInit(); + g_pSleepActView = nullptr; + } + + SleepActView *SleepActView::GetInstance() + { + + return g_pSleepActView; + } + void SleepActView::OnStart() + { + container_ = new UIViewGroup(); + if (container_ == nullptr) + { + return; + } + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(SleepActPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + void SleepActView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add ScrollView to App + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); // widget's left position and top position + scrollView1_->Resize(466, 466); // widget's width and height + scrollView1_->SetViewId("scrollView1"); // Set style + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // Set additional property + + // Add the CallBack about events + UIView::OnDragListener *scrollView1Drag = static_cast(SleepActPresenter::GetInstance()); + scrollView1_->SetOnDragListener(scrollView1Drag); + // Add to rootView + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(203, 52); // widget's left position and top position + label1_->Resize(60, 35); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + label1_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label1_->SetText("睡眠"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label1_); + label1_->SetVisible(true); + + // Add Button to App + if (button1_ == nullptr) + { + button1_ = new UIButton(); + } + button1_->SetPosition(118, 648); // widget's left position and top position + button1_->Resize(230, 80); // widget's width and height + button1_->SetViewId("button1"); // Set style + button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff999999); + + // Set additional property +#ifdef _WIN32 + char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/SleepAct/button.bin"; +#else + char *button1defaultImgSrc = "/user/res/SleepTime/button.bin"; +#endif + char *button1triggeredImgSrc = nullptr; + button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + button1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff999999, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(SleepActPresenter::GetInstance()); + button1_->SetOnClickListener(button1Click); + // Add to scrollView1 + scrollView1_->Add(button1_); + button1_->SetVisible(true); + + // Add Label to App + if (label4_ == nullptr) + { + label4_ = new UILabel(); + } + label4_->SetPosition(38, 477); // widget's left position and top position + label4_->Resize(200, 60); // widget's width and height + label4_->SetViewId("label4"); // Set style + label4_->SetStyle(STYLE_TEXT_FONT, 30); + label4_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label4_->SetText("3.如睡眠中有过多的手部移\n动,可能会造成血氧及心率数\n据无法检测或不够准确。"); + label4_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label4_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + label4_->SetRollSpeed(0); + label4_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label4_); + label4_->SetVisible(true); + + // Add ImageView to App + if (image3_ == nullptr) + { + image3_ = new UIImageView(); + } + image3_->SetPosition(183, 772); // widget's left position and top position + image3_->Resize(100, 100); // widget's width and height + image3_->SetViewId("image3"); // Set style + + // Set additional property + + // Add to scrollView1 + scrollView1_->Add(image3_); + image3_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(193, 112); // widget's left position and top position + image1_->Resize(80, 80); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/SleepAct/Vector2.bin"; +#else + char *image1imagesPath = "/user/res/SleepTime/Vector2.bin"; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to scrollView1 + scrollView1_->Add(image1_); + image1_->SetVisible(true); + + // Add ImageView to App + if (image2_ == nullptr) + { + image2_ = new UIImageView(); + } + image2_->SetPosition(183, -98); // widget's left position and top position + image2_->Resize(100, 100); // widget's width and height + image2_->SetViewId("image2"); // Set style + + // Set additional property + + // Add to scrollView1 + scrollView1_->Add(image2_); + image2_->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(33, 217); // widget's left position and top position + label2_->Resize(400, 395); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label2_->SetText("1.请前往APP睡眠页面设置作\n息时间,设定好就寝时间及起\n床时间,以便协助你更好的记\n录与改善睡眠。"); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label2_); + label2_->SetVisible(true); + + // Add Label to App + if (label3_ == nullptr) + { + label3_ = new UILabel(); + } + label3_->SetPosition(40, 384); // widget's left position and top position + label3_->Resize(200, 60); // widget's width and height + label3_->SetViewId("label3"); // Set style + label3_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label3_->SetText(" 2.睡觉请佩戴手表以便分析睡\n眠质量 "); + label3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label3_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + label3_->SetRollSpeed(0); + label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label3_); + label3_->SetVisible(true); + } + + void SleepActView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + if (label4_ != nullptr) + { + delete label4_; + label4_ = nullptr; + } + if (image3_ != nullptr) + { + delete image3_; + image3_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (image2_ != nullptr) + { + delete image2_; + image2_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (label3_ != nullptr) + { + delete label3_; + label3_ = nullptr; + } + } + + UIView *SleepActView::GetView() + { + Init(); + return container_; + } + void SleepActView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void SleepActView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void SleepActView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/sleep/src/SleepPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/sleep/src/SleepPresenter.cpp new file mode 100644 index 000000000..c4c77962a --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/sleep/src/SleepPresenter.cpp @@ -0,0 +1,77 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "sleep/include/SleepPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static SleepPresenter *g_pSleepPresenter = nullptr; + + SleepPresenter::SleepPresenter() + { + + g_pSleepPresenter = this; + } + + SleepPresenter::~SleepPresenter() + { + + g_pSleepPresenter = nullptr; + } + + SleepPresenter *SleepPresenter::GetInstance() + { + + return g_pSleepPresenter; + } + + void SleepPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void SleepPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void SleepPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void SleepPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + + bool SleepPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + } + if (event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SLEEPTIME); + } + // 返回 true 以消耗拖动事件 + return true; + } + + bool SleepPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 执行点击事件的处理逻辑 + // 根据控件id查找是哪个控件触发了点击回调 + // if (strcmp(view.GetViewId(), 控件ID) == 0 + // 返回 true 以消耗点击事件 + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/sleep/src/SleepTimePresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/sleep/src/SleepTimePresenter.cpp new file mode 100644 index 000000000..0eb0974db --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/sleep/src/SleepTimePresenter.cpp @@ -0,0 +1,91 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "sleep/include/SleepTimePresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static SleepTimePresenter *g_pSleepTimePresenter = nullptr; + + SleepTimePresenter::SleepTimePresenter() + { + + g_pSleepTimePresenter = this; + } + + SleepTimePresenter::~SleepTimePresenter() + { + + g_pSleepTimePresenter = nullptr; + } + + SleepTimePresenter *SleepTimePresenter::GetInstance() + { + + return g_pSleepTimePresenter; + } + + void SleepTimePresenter::OnStart() + { + + Presenter::OnStart(); + } + + void SleepTimePresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void SleepTimePresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void SleepTimePresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + // void Button1OnClickCallBack2(UIView &view, const ClickEvent &event) + // { + // NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + // return; + // } + + bool SleepTimePresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + if (event.GetDragDirection() == DragEvent::DIRECTION_TOP_TO_BOTTOM) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_BLOODPRESSURE); + } + // 返回 true 以消耗拖动事件 + // 返回 true 以消耗拖动事件 + return true; + } + + bool SleepTimePresenter::OnClick(UIView &view, const ClickEvent &event) + { + + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), "button1") == 0) + { + + // 执行按键1点击事件的处理逻辑 + // Button1OnClickCallBack2(view, event); + + NativeAbility::GetInstance().ChangeSlice(VIEW_SLEEPACT); + + // 返回 true 以消耗点击事件 + return true; + } + + // 返回 false 表示未处理点击事件 + return false; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/sleep/src/SleepTimeView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/sleep/src/SleepTimeView.cpp new file mode 100644 index 000000000..79aeee4d9 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/sleep/src/SleepTimeView.cpp @@ -0,0 +1,409 @@ +#include "sleep/include/SleepTimeView.h" +#include "sleep/include/SleepTimePresenter.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + + static SleepTimeView *g_pSleepTimeView{nullptr}; + + SleepTimeView::SleepTimeView() + { + + g_pSleepTimeView = this; + } + + SleepTimeView::~SleepTimeView() + { + DeInit(); + g_pSleepTimeView = nullptr; + } + + SleepTimeView *SleepTimeView::GetInstance() + { + + return g_pSleepTimeView; + } + void SleepTimeView::OnStart() + { + container_ = new UIViewGroup(); + if (container_ == nullptr) + { + return; + } + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(SleepTimePresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + void SleepTimeView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(156, 52); // widget's left position and top position + label1_->Resize(120, 35); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + label1_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label1_->SetText("作息时间"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label1_); + label1_->SetVisible(true); + + // Add Button to App + if (button1_ == nullptr) + { + button1_ = new UIButton(); + } + button1_->SetPosition(283, 57); // widget's left position and top position + button1_->Resize(26, 26); // widget's width and height + button1_->SetViewId("button1"); // Set style + button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/SleepTime/Vector.bin"; +#else + char *button1defaultImgSrc = "/user/res/SleepTime/Vector.bin"; +#endif + char *button1triggeredImgSrc = nullptr; + button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(SleepTimePresenter::GetInstance()); + button1_->SetOnClickListener(button1Click); + + // Add to rootView + container_->Add(button1_); + button1_->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(211, 95); // widget's left position and top position + label2_->Resize(42, 47); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 40); + label2_->SetStyle(STYLE_LINE_HEIGHT, 47); + + // Set additional property + label2_->SetText("--"); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + + // Add to rootView + container_->Add(label2_); + label2_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(2, 169); // widget's left position and top position + image1_->Resize(466, 100); // widget's width and height + image1_->SetViewId("image1"); // Set style + image1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff333333); + image1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + image1_->SetStyle(STYLE_BORDER_COLOR, 0xff333333); + + // Set additional property +#ifdef _WIN32 + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/SleepTimeTime/Line 1.bin"; +#else + char *image1imagesPath = "/user/res/SleepTime/Line 1.bin"; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to rootView + container_->Add(image1_); + image1_->SetVisible(true); + + // Add Label to App + if (label4_ == nullptr) + { + label4_ = new UILabel(); + } + label4_->SetPosition(283, 203); // widget's left position and top position + label4_->Resize(120, 35); // widget's width and height + label4_->SetViewId("label4"); // Set style + label4_->SetStyle(STYLE_TEXT_FONT, 30); + label4_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label4_->SetText("醒来时间"); + label4_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label4_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label4_->SetRollSpeed(0); + label4_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label4_); + label4_->SetVisible(true); + + // Add Label to App + if (label3_ == nullptr) + { + label3_ = new UILabel(); + } + label3_->SetPosition(61, 203); // widget's left position and top position + label3_->Resize(120, 35); // widget's width and height + label3_->SetViewId("label3"); // Set style + label3_->SetStyle(STYLE_TEXT_FONT, 30); + label3_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label3_->SetText("入睡时间"); + label3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label3_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label3_->SetRollSpeed(0); + label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label3_); + label3_->SetVisible(true); + + // Add ImageView to App + if (image2_ == nullptr) + { + image2_ = new UIImageView(); + } + image2_->SetPosition(233, 199); // widget's left position and top position + image2_->Resize(100, 100); // widget's width and height + image2_->SetViewId("image2"); // Set style + image2_->SetStyle(STYLE_BORDER_COLOR, 0xff333333); + + // Set additional property +#ifdef _WIN32 + char *image2imagesPath = "c:/Users/caiking/project/image_converter_tool/output/SleepTimeTime/Line 3.bin"; +#else + char *image2imagesPath = "/user/res/SleepTime/Line 3.bin"; +#endif + image2_->SetSrc(image2imagesPath); + + // Add to rootView + container_->Add(image2_); + image2_->SetVisible(true); + + // Add Label to App + if (label5_ == nullptr) + { + label5_ = new UILabel(); + } + label5_->SetPosition(99, 238); // widget's left position and top position + label5_->Resize(42, 47); // widget's width and height + label5_->SetViewId("label5"); // Set style + label5_->SetStyle(STYLE_TEXT_FONT, 40); + label5_->SetStyle(STYLE_LINE_HEIGHT, 47); + + // Set additional property + label5_->SetText("--"); + label5_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label5_->SetTextColor(Color::GetColorFromRGBA(0x53, 0x20, 0xE2, 0xff)); + label5_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label5_->SetRollSpeed(0); + label5_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + + // Add to rootView + container_->Add(label5_); + label5_->SetVisible(true); + + // Add Label to App + if (label6_ == nullptr) + { + label6_ = new UILabel(); + } + label6_->SetPosition(321, 238); // widget's left position and top position + label6_->Resize(42, 47); // widget's width and height + label6_->SetViewId("label6"); // Set style + label6_->SetStyle(STYLE_TEXT_FONT, 40); + label6_->SetStyle(STYLE_LINE_HEIGHT, 47); + + // Set additional property + label6_->SetText("--"); + label6_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label6_->SetTextColor(Color::GetColorFromRGBA(0x53, 0x20, 0xE2, 0xff)); + label6_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label6_->SetRollSpeed(0); + label6_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + + // Add to rootView + container_->Add(label6_); + label6_->SetVisible(true); + + // Add ImageView to App + if (image3_ == nullptr) + { + image3_ = new UIImageView(); + } + image3_->SetPosition(-1, 319); // widget's left position and top position + image3_->Resize(466, 100); // widget's width and height + image3_->SetViewId("image3"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image3imagesPath = "c:/Users/caiking/project/image_converter_tool/output/SleepTimeTime/Line 1.bin"; +#else + char *image3imagesPath = "/user/res/SleepTime/Line 1.bin"; +#endif + image3_->SetSrc(image3imagesPath); + + // Add to rootView + container_->Add(image3_); + image3_->SetVisible(true); + + // Add Label to App + if (label7_ == nullptr) + { + label7_ = new UILabel(); + } + label7_->SetPosition(92, 359); // widget's left position and top position + label7_->Resize(283, 60); // widget's width and height + label7_->SetViewId("label7"); // Set style + label7_->SetStyle(STYLE_TEXT_FONT, 26); + label7_->SetStyle(STYLE_LINE_HEIGHT, 30); + + // Set additional property + label7_->SetText("更多详情请前往手机APP\n“小希爱玩”查看"); + label7_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label7_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + label7_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label7_->SetRollSpeed(0); + label7_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + + // Add to rootView + container_->Add(label7_); + label7_->SetVisible(true); + } + + void SleepTimeView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (label4_ != nullptr) + { + delete label4_; + label4_ = nullptr; + } + if (label3_ != nullptr) + { + delete label3_; + label3_ = nullptr; + } + if (image2_ != nullptr) + { + delete image2_; + image2_ = nullptr; + } + if (label5_ != nullptr) + { + delete label5_; + label5_ = nullptr; + } + if (label6_ != nullptr) + { + delete label6_; + label6_ = nullptr; + } + if (image3_ != nullptr) + { + delete image3_; + image3_ = nullptr; + } + if (label7_ != nullptr) + { + delete label7_; + label7_ = nullptr; + } + } + + UIView *SleepTimeView::GetView() + { + Init(); + return container_; + } + void SleepTimeView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void SleepTimeView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void SleepTimeView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/sleep/src/SleepView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/sleep/src/SleepView.cpp new file mode 100644 index 000000000..ba0713f68 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/sleep/src/SleepView.cpp @@ -0,0 +1,340 @@ +#include "sleep/include/SleepView.h" + + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + + static SleepView *g_pSleepView{nullptr}; + + SleepView::SleepView() + { + + g_pSleepView = this; + } + + SleepView::~SleepView() + { + DeInit(); + g_pSleepView = nullptr; + } + + SleepView *SleepView::GetInstance() + { + + return g_pSleepView; + } + void SleepView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(173, 52); // widget's left position and top position + label1_->Resize(200, 60); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + label1_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label1_->SetText("昨夜睡眠"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label1_); + label1_->SetVisible(true); + + // Add ImageView to App + if (image2_ == nullptr) + { + image2_ = new UIImageView(); + } + image2_->SetPosition(192, 127); // widget's left position and top position + image2_->Resize(82, 82); // widget's width and height + image2_->SetViewId("image2"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image2imagesPath = "c:/Users/caiking/project/image_converter_tool/output/sleep/room.bin"; +#else + char *image2imagesPath = "/user/res/SleepTime/room.bin"; +#endif + image2_->SetSrc(image2imagesPath); + + // Add to rootView + container_->Add(image2_); + image2_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(28, 85); // widget's left position and top position + image1_->Resize(410, 356); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/sleep/Ellipse 185.bin"; +#else + char *image1imagesPath = "/user/res/SleepTime/Ellipse 185.bin"; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to rootView + container_->Add(image1_); + image1_->SetVisible(true); + + // Add Label to App + if (label3_ == nullptr) + { + label3_ = new UILabel(); + } + label3_->SetPosition(321, 260); // widget's left position and top position + label3_->Resize(200, 60); // widget's width and height + label3_->SetViewId("label3"); // Set style + label3_->SetStyle(STYLE_TEXT_FONT, 26); + label3_->SetStyle(STYLE_LINE_HEIGHT, 30); + + // Set additional property + label3_->SetText("分钟"); + label3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label3_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label3_->SetRollSpeed(0); + label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + + // Add to rootView + container_->Add(label3_); + label3_->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(173, 260); // widget's left position and top position + label2_->Resize(52, 30); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 26); + label2_->SetStyle(STYLE_LINE_HEIGHT, 30); + + // 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, 26); + + // Add to rootView + container_->Add(label2_); + label2_->SetVisible(true); + + // Add Label to App + if (label5_ == nullptr) + { + label5_ = new UILabel(); + } + label5_->SetPosition(94, 237); // widget's left position and top position + label5_->Resize(200, 60); // widget's width and height + label5_->SetViewId("label5"); // Set style + label5_->SetStyle(STYLE_TEXT_FONT, 65); + + // Set additional property + label5_->SetText("--"); + label5_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label5_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label5_->SetRollSpeed(0); + label5_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 65); + + // Add to rootView + container_->Add(label5_); + label5_->SetVisible(true); + + // Add Label to App + if (label6_ == nullptr) + { + label6_ = new UILabel(); + } + label6_->SetPosition(236, 237); // widget's left position and top position + label6_->Resize(40, 75); // widget's width and height + label6_->SetViewId("label6"); // Set style + label6_->SetStyle(STYLE_TEXT_FONT, 64); + + // Set additional property + label6_->SetText("--"); + label6_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label6_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label6_->SetRollSpeed(0); + label6_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 64); + + // Add to rootView + container_->Add(label6_); + label6_->SetVisible(true); + + // Add Label to App + if (label4_ == nullptr) + { + label4_ = new UILabel(); + } + label4_->SetPosition(158, 312); // widget's left position and top position + label4_->Resize(150, 35); // widget's width and height + label4_->SetViewId("label4"); // Set style + label4_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label4_->SetText("目标--小时"); + label4_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label4_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + label4_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label4_->SetRollSpeed(0); + label4_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label4_); + label4_->SetVisible(true); + + // Add ImageView to App + if (image3_ == nullptr) + { + image3_ = new UIImageView(); + } + image3_->SetPosition(213, 360); // widget's left position and top position + image3_->Resize(40, 40); // widget's width and height + image3_->SetViewId("image3"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image3imagesPath = "c:/Users/caiking/project/image_converter_tool/output/sleep/up.bin"; +#else + char *image3imagesPath = "/user/res/SleepTime/up.bin"; +#endif + image3_->SetSrc(image3imagesPath); + + // Add to rootView + container_->Add(image3_); + image3_->SetVisible(true); + } + + void SleepView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (image2_ != nullptr) + { + delete image2_; + image2_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (label3_ != nullptr) + { + delete label3_; + label3_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (label5_ != nullptr) + { + delete label5_; + label5_ = nullptr; + } + if (label6_ != nullptr) + { + delete label6_; + label6_ = nullptr; + } + if (label4_ != nullptr) + { + delete label4_; + label4_ = nullptr; + } + if (image3_ != nullptr) + { + delete image3_; + image3_ = nullptr; + } + } + + UIView *SleepView::GetView() + { + Init(); + return container_; + } + + void SleepView::OnStart() + { + container_ = new UIViewGroup(); + if (container_ == nullptr) + { + return; + } + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(SleepPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void SleepView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void SleepView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void SleepView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationPresenter.h new file mode 100644 index 000000000..e105fbe36 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationPresenter.h @@ -0,0 +1,36 @@ +#ifndef SOUND_AND_VIBRATION_PRESENTER_H +#define SOUND_AND_VIBRATION_PRESENTER_H + +#include "Presenter.h" +#include "SoundAndVibrationView.h" + +namespace OHOS +{ + class SoundAndVibrationView; + + class SoundAndVibrationPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + SoundAndVibrationPresenter(); + virtual ~SoundAndVibrationPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static SoundAndVibrationPresenter *GetInstance(); + + private: + //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} //namespace OHOS + + + + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationView.h b/code/sdk/application/wearable/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationView.h new file mode 100644 index 000000000..6d6a5264e --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationView.h @@ -0,0 +1,57 @@ +#ifndef SOUND_AND_VIBRATION_VIEW_H +#define SOUND_AND_VIBRATION_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_button.h" +#include "components/ui_image_view.h" +#include "components/ui_toggle_button.h" +namespace OHOS +{ + static const char * SYSTEM_VOLUME_BUTTON = "SystemVolumeButton"; //系统音量 + static const char * CALL_VOLUME_BUTTON = "CallVolumeButton"; //通话音量 + static const char * MEDIAVOLUMEBUTTON = "MediaVolumeButton"; //媒体音量 + static const char * VIBRATION_REMINDER_TOGGLEBUTTON = "VibrationReminderToggleButton";//震动提醒 + static const char * SILENT_MODEL_TOGGLEBUTTON = "SilentModeToggleButton"; //静音模式 + class SoundAndVibrationPresenter; + class SoundAndVibrationView : public View + { + + public: + SoundAndVibrationView(); + virtual ~SoundAndVibrationView(); + static SoundAndVibrationView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInit(void); + + private: + UIViewGroup *container_ = nullptr; + UIScrollView *SoundAndVibrationScrollView = nullptr; + UILabel *SoundAndVibrationLabel = nullptr; + UIButton *SystemVolumeButton = nullptr; + UIButton *CallVolumeButton = nullptr; + UIImageView *image1 = nullptr; + UIImageView *image2 = nullptr; + UIImageView *SilentModeImage = nullptr; + UILabel *SilentModeLabe_ = nullptr; + UIToggleButton * VibrationReminderToggleButton = nullptr; + UILabel *SilentModeLabel = nullptr; + UIImageView *VibrationReminderImage = nullptr; + UIToggleButton *SilentModeToggleButton = nullptr; + UILabel *VibrationReminderLabel = nullptr; + UIButton *MediaVolumeButton = nullptr; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp new file mode 100644 index 000000000..cac59366a --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp @@ -0,0 +1,91 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "soundandvibration/include/SoundAndVibrationPresenter.h" + +namespace OHOS{ + + //当前Presenter属性实例化的内存指针 + static SoundAndVibrationPresenter *g_pSoundAndVibrationPresenter = nullptr; + + SoundAndVibrationPresenter::SoundAndVibrationPresenter(){ + + g_pSoundAndVibrationPresenter = this; + } + + SoundAndVibrationPresenter::~SoundAndVibrationPresenter(){ + + g_pSoundAndVibrationPresenter = nullptr; + } + + SoundAndVibrationPresenter *SoundAndVibrationPresenter::GetInstance(){ + + return g_pSoundAndVibrationPresenter; + } + + void SoundAndVibrationPresenter::OnStart(){ + + Presenter::OnStart(); + } + + void SoundAndVibrationPresenter::OnPause(void){ + + Presenter::OnPause(); + } + + void SoundAndVibrationPresenter::OnResume(void){ + + Presenter::OnResume(); + } + + void SoundAndVibrationPresenter::OnStop(void){ + + Presenter::OnStop(); + } + + bool SoundAndVibrationPresenter::OnDrag(UIView &view, const DragEvent &event){ + + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); + return true; + } + return false; + } + + bool SoundAndVibrationPresenter::OnClick(UIView &view, const ClickEvent &event){ + + // 根据控件id查找是哪个控件触发了点击回调 + UNUSED(event); + if (strcmp(view.GetViewId(), SYSTEM_VOLUME_BUTTON) == 0) + { + printf("1\n"); + NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME); + return true; + } + else if(strcmp(view.GetViewId(), CALL_VOLUME_BUTTON) == 0) + { + printf("2\n"); + NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME); + return true; + }else if(strcmp(view.GetViewId(), MEDIAVOLUMEBUTTON) == 0) + { + printf("3\n"); + NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME); + return true; + } + else if(strcmp(view.GetViewId(), VIBRATION_REMINDER_TOGGLEBUTTON) == 0) + { + printf("4\n"); + return true; + } + else if(strcmp(view.GetViewId(), SILENT_MODEL_TOGGLEBUTTON) == 0) + { + printf("5\n"); + return true; + } + return false; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/soundandvibration/src/SoundAndVibrationView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/soundandvibration/src/SoundAndVibrationView.cpp new file mode 100644 index 000000000..cf63b5820 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/soundandvibration/src/SoundAndVibrationView.cpp @@ -0,0 +1,397 @@ +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" + +#include "soundandvibration/include/SoundAndVibrationView.h" +#include "soundandvibration/include/SoundAndVibrationPresenter.h" + +namespace OHOS +{ + + static SoundAndVibrationView *g_pSoundAndVibrationView{nullptr}; + + SoundAndVibrationView::SoundAndVibrationView() + { + g_pSoundAndVibrationView = this; + } + + SoundAndVibrationView::~SoundAndVibrationView() + { + DeInit(); + g_pSoundAndVibrationView = nullptr; + } + + SoundAndVibrationView *SoundAndVibrationView::GetInstance() + { + + return g_pSoundAndVibrationView; + } + void SoundAndVibrationView::InitView(void) + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + UIView::OnDragListener *draglistener = static_cast(SoundAndVibrationPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + container_->SetTouchable(true); + container_->SetDraggable(true); + } + /***********************************************************************************************************/ + // Add ScrollView to App + if (SoundAndVibrationScrollView == nullptr) + { + SoundAndVibrationScrollView = new UIScrollView(); + } + SoundAndVibrationScrollView->SetPosition(0, 0); + SoundAndVibrationScrollView->Resize(466, 466); + SoundAndVibrationScrollView->SetViewId("SoundAndVibrationScrollView"); + SoundAndVibrationScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + // Add to rootView + container_->Add(SoundAndVibrationScrollView); + SoundAndVibrationScrollView->SetVisible(true); + /***********************************************************************************************************/ + // Add Label to App + if (SoundAndVibrationLabel == nullptr) + { + SoundAndVibrationLabel = new UILabel(); + } + SoundAndVibrationLabel->SetPosition(158, 52); + SoundAndVibrationLabel->Resize(200, 60); + SoundAndVibrationLabel->SetViewId("SoundAndVibrationLabel"); + SoundAndVibrationLabel->SetStyle(STYLE_TEXT_FONT, 30); + SoundAndVibrationLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + SoundAndVibrationLabel->SetText("声音与震动"); + SoundAndVibrationLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + SoundAndVibrationLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + SoundAndVibrationLabel->SetRollSpeed(6); + SoundAndVibrationLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView + SoundAndVibrationScrollView->Add(SoundAndVibrationLabel); + SoundAndVibrationLabel->SetVisible(true); + /***********************************************************************************************************/ + // Add SystemVolumeButton to App + if (SystemVolumeButton == nullptr) + { + SystemVolumeButton = new UIButton(); + } + SystemVolumeButton->SetPosition(43, 120); + SystemVolumeButton->Resize(380, 100); + SystemVolumeButton->SetViewId(SYSTEM_VOLUME_BUTTON); + SystemVolumeButton->SetStyle(STYLE_BORDER_RADIUS, 50); + // Set additional property + SystemVolumeButton->SetImageSrc(PNG_SYSTEM_VOLUME_IMAGE, nullptr); + SystemVolumeButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + SystemVolumeButton->SetStyleForState(STYLE_BORDER_RADIUS, 50, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *SystemVolumeButtonClick = static_cast(SoundAndVibrationPresenter::GetInstance()); + SystemVolumeButton->SetOnClickListener(SystemVolumeButtonClick); + // Add to scrollView1 + SoundAndVibrationScrollView->Add(SystemVolumeButton); + SystemVolumeButton->SetVisible(true); + /***********************************************************************************************************/ + // Add CallVolumeButton to App + if (CallVolumeButton == nullptr) + { + CallVolumeButton = new UIButton(); + } + CallVolumeButton->SetPosition(43, 240); + CallVolumeButton->Resize(380, 100); + CallVolumeButton->SetViewId(CALL_VOLUME_BUTTON); + CallVolumeButton->SetStyle(STYLE_BORDER_RADIUS, 50); + CallVolumeButton->SetImageSrc(PNG_CALL_VOLUME_IMAGE, nullptr); + CallVolumeButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + CallVolumeButton->SetStyleForState(STYLE_BORDER_RADIUS, 50, UIButton::PRESSED); + // Add the CallBack about events + UIView::OnClickListener *CallVolumeButtonClick = static_cast(SoundAndVibrationPresenter::GetInstance()); + CallVolumeButton->SetOnClickListener(CallVolumeButtonClick); + // Add to SoundAndVibrationScrollView + SoundAndVibrationScrollView->Add(CallVolumeButton); + CallVolumeButton->SetVisible(true); + /***********************************************************************************************************/ + // Add MediaVolumeButton to App + if (MediaVolumeButton == nullptr) + { + MediaVolumeButton = new UIButton(); + } + MediaVolumeButton->SetPosition(43, 360); + MediaVolumeButton->Resize(380, 100); + MediaVolumeButton->SetViewId(MEDIAVOLUMEBUTTON); + + MediaVolumeButton->SetImageSrc(PNG_MEDIA_VOLUME_IMAGE, nullptr); + MediaVolumeButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *MediaVolumeButtonClick = static_cast(SoundAndVibrationPresenter::GetInstance()); + MediaVolumeButton->SetOnClickListener(MediaVolumeButtonClick); + // Add to scrollView1 + SoundAndVibrationScrollView->Add(MediaVolumeButton); + MediaVolumeButton->SetVisible(true); + /***********************************************************************************************************/ + if (VibrationReminderImage == nullptr) + { + VibrationReminderImage = new UIImageView(); + } + VibrationReminderImage->SetPosition(43, 480); + VibrationReminderImage->Resize(100, 100); + VibrationReminderImage->SetViewId("VibrationReminderImage"); + VibrationReminderImage->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + VibrationReminderImage->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + VibrationReminderImage->SetStyle(STYLE_BORDER_RADIUS, 50); + VibrationReminderImage->SetSrc(PNG_SETTING_BACKGROUND_IMAGE); + SoundAndVibrationScrollView->Add(VibrationReminderImage); + VibrationReminderImage->SetVisible(true); + /***********************************************************************************************************/ + // Add Label to App + if (VibrationReminderLabel == nullptr) + { + VibrationReminderLabel = new UILabel(); + } + VibrationReminderLabel->SetPosition(90, 513); // widget's left position and top position + VibrationReminderLabel->Resize(120, 35); // widget's width and height + VibrationReminderLabel->SetViewId("VibrationReminderLabel"); // Set style + VibrationReminderLabel->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + VibrationReminderLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + VibrationReminderLabel->SetStyle(STYLE_TEXT_FONT, 30); + VibrationReminderLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + VibrationReminderLabel->SetText("震动提醒"); + VibrationReminderLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + VibrationReminderLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + VibrationReminderLabel->SetRollSpeed(6); + VibrationReminderLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to SoundAndVibrationScrollView + SoundAndVibrationScrollView->Add(VibrationReminderLabel); + VibrationReminderLabel->SetVisible(true); + /***********************************************************************************************************/ + // Add ToggleButton to App + if (VibrationReminderToggleButton == nullptr) + { + VibrationReminderToggleButton = new UIToggleButton(); + } + VibrationReminderToggleButton->SetPosition(298, 505); + VibrationReminderToggleButton->Resize(100, 50); + VibrationReminderToggleButton->SetViewId(VIBRATION_REMINDER_TOGGLEBUTTON); + VibrationReminderToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + VibrationReminderToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + VibrationReminderToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE,PNG_TOGGLEBUTTON_OFF_IMAGE); + // Add the CallBack about events + UIView::OnClickListener *VibrationReminderToggleButtonClick = static_cast(SoundAndVibrationPresenter::GetInstance()); + VibrationReminderToggleButton->SetOnClickListener(VibrationReminderToggleButtonClick); + // Add to SoundAndVibrationScrollView + SoundAndVibrationScrollView->Add(VibrationReminderToggleButton); + VibrationReminderToggleButton->SetVisible(true); + /***********************************************************************************************************/ + // Add ImageView to App + if (SilentModeImage == nullptr) + { + SilentModeImage = new UIImageView(); + } + SilentModeImage->SetPosition(43, 600); + SilentModeImage->Resize(380, 100); + SilentModeImage->SetViewId("SilentModeImage"); + SilentModeImage->SetStyle(STYLE_BORDER_RADIUS, 50); + SilentModeImage->SetSrc(PNG_SETTING_BACKGROUND_IMAGE); + // Add to scrollView1 + SoundAndVibrationScrollView->Add(SilentModeImage); + SilentModeImage->SetVisible(true); + /***********************************************************************************************************/ + if (SilentModeLabel == nullptr) + { + SilentModeLabel = new UILabel(); + } + SilentModeLabel->SetPosition(90, 620); + SilentModeLabel->Resize(120, 35); + SilentModeLabel->SetViewId("SilentModeLabel"); + SilentModeLabel->SetStyle(STYLE_TEXT_FONT, 30); + SilentModeLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + SilentModeLabel->SetText("静音模式"); + SilentModeLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + SilentModeLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + SilentModeLabel->SetRollSpeed(6); + SilentModeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to SoundAndVibrationScrollView + SoundAndVibrationScrollView->Add(SilentModeLabel); + SilentModeLabel->SetVisible(true); + /***********************************************************************************************************/ + if (SilentModeLabe_ == nullptr) + { + SilentModeLabe_ = new UILabel(); + } + SilentModeLabe_->SetPosition(90, 657); + SilentModeLabe_->Resize(160, 23); + SilentModeLabe_->SetViewId("label9"); + SilentModeLabe_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + SilentModeLabe_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + SilentModeLabe_->SetStyle(STYLE_TEXT_FONT, 20); + SilentModeLabe_->SetStyle(STYLE_LINE_HEIGHT, 23); + // Set additional property + SilentModeLabe_->SetText("系统音量不受影响"); + SilentModeLabe_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + SilentModeLabe_->SetTextColor(Color::GetColorFromRGBA(0xfd, 0xfd, 0xfd, 0x7f)); + SilentModeLabe_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + SilentModeLabe_->SetRollSpeed(6); + SilentModeLabe_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + // Add to SoundAndVibrationScrollView + SoundAndVibrationScrollView->Add(SilentModeLabe_); + SilentModeLabe_->SetVisible(true); + /***********************************************************************************************************/ + // Add SilentModeToggleButton to App + if (SilentModeToggleButton == nullptr) + { + SilentModeToggleButton = new UIToggleButton(); + } + SilentModeToggleButton->SetPosition(298, 625); + SilentModeToggleButton->Resize(100, 50); + SilentModeToggleButton->SetViewId(SILENT_MODEL_TOGGLEBUTTON); + SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + SilentModeToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE,PNG_TOGGLEBUTTON_OFF_IMAGE); + UIView::OnClickListener *SilentModeToggleButtonClick = static_cast(SoundAndVibrationPresenter::GetInstance()); + SilentModeToggleButton->SetOnClickListener(SilentModeToggleButtonClick); + // Add to scrollView1 + SoundAndVibrationScrollView->Add(SilentModeToggleButton); + SilentModeToggleButton->SetVisible(true); + /***********************************************************************************************************/ + // Add ImageView to App + if (image1 == nullptr) + { + image1 = new UIImageView(); + } + image1->SetPosition(183, 18); + image1->Resize(100, 100); + image1->SetViewId("image1"); + + SoundAndVibrationScrollView->Add(image1); + image1->SetVisible(true); + /***********************************************************************************************************/ + // Add ImageView to App + if (image2 == nullptr) + { + image2 = new UIImageView(); + } + image2->SetPosition(183, 668); + image2->Resize(100, 100); + image2->SetViewId("image2"); + + SoundAndVibrationScrollView->Add(image2); + image2->SetVisible(true); + } + + void SoundAndVibrationView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (SoundAndVibrationScrollView != nullptr) + { + delete SoundAndVibrationScrollView; + SoundAndVibrationScrollView = nullptr; + } + if (SoundAndVibrationLabel != nullptr) + { + delete SoundAndVibrationLabel; + SoundAndVibrationLabel = nullptr; + } + if (SystemVolumeButton != nullptr) + { + delete SystemVolumeButton; + SystemVolumeButton = nullptr; + } + if (CallVolumeButton != nullptr) + { + delete CallVolumeButton; + CallVolumeButton = nullptr; + } + if (image1 != nullptr) + { + delete image1; + image1 = nullptr; + } + if (image2 != nullptr) + { + delete image2; + image2 = nullptr; + } + if (SilentModeImage != nullptr) + { + delete SilentModeImage; + SilentModeImage = nullptr; + } + if (SilentModeLabe_ != nullptr) + { + delete SilentModeLabe_; + SilentModeLabe_ = nullptr; + } + if (VibrationReminderToggleButton != nullptr) + { + delete VibrationReminderToggleButton; + VibrationReminderToggleButton = nullptr; + } + if (SilentModeLabel != nullptr) + { + delete SilentModeLabel; + SilentModeLabel = nullptr; + } + if (VibrationReminderImage != nullptr) + { + delete VibrationReminderImage; + VibrationReminderImage = nullptr; + } + if (SilentModeToggleButton != nullptr) + { + delete SilentModeToggleButton; + SilentModeToggleButton = nullptr; + } + if (VibrationReminderLabel != nullptr) + { + delete VibrationReminderLabel; + VibrationReminderLabel = nullptr; + } + if (MediaVolumeButton != nullptr) + { + delete MediaVolumeButton; + MediaVolumeButton = nullptr; + } + } + + void SoundAndVibrationView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void SoundAndVibrationView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void SoundAndVibrationView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void SoundAndVibrationView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/steamfactoryreset/include/SystemFactoryResetPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/steamfactoryreset/include/SystemFactoryResetPresenter.h new file mode 100644 index 000000000..1edf1b9f1 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/steamfactoryreset/include/SystemFactoryResetPresenter.h @@ -0,0 +1,34 @@ +#ifndef SYSTEM_FACTORYRESET_PRESENTER_H +#define SYSTEM_FACTORYRESET_PRESENTER_H + +#include "Presenter.h" + +#include "SystemFactoryResetView.h" + +namespace OHOS +{ + class SystemFactoryResetView; + + class SystemFactoryResetPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + SystemFactoryResetPresenter(); + virtual ~SystemFactoryResetPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static SystemFactoryResetPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/steamfactoryreset/include/SystemFactoryResetView.h b/code/sdk/application/wearable/nativeapp/nativeui/steamfactoryreset/include/SystemFactoryResetView.h new file mode 100644 index 000000000..ec5f3cf5e --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/steamfactoryreset/include/SystemFactoryResetView.h @@ -0,0 +1,39 @@ +#ifndef SYSTEM_FACTORYRESET_VIEW_H +#define SYSTEM_FACTORYRESET_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +namespace OHOS +{ + static const char *FACTORYRESET_CHECKON = "ShoutDownButtonCheckOn";//确认 + static const char *FACTORYRESET_CHECKOFF = "ShoutDownButtonCheckOff";//取消 + class SystemFactoryResetPresenter; + class SystemFactoryResetView : public View + { + + public: + SystemFactoryResetView(); + virtual ~SystemFactoryResetView(); + static SystemFactoryResetView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + + void InitView(void); + void DeInitView(void); + + UIViewGroup *container_ = nullptr; + UIImageView *FactoryResetImage = nullptr; + UIButton *FactoryResetButtonCheckOn = nullptr; + UIButton *FactoryResetButtonCheckOff = nullptr; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/steamfactoryreset/src/SystemFactoryResetPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/steamfactoryreset/src/SystemFactoryResetPresenter.cpp new file mode 100644 index 000000000..daf1f7af7 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/steamfactoryreset/src/SystemFactoryResetPresenter.cpp @@ -0,0 +1,79 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "steamfactoryreset/include/SystemFactoryResetPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static SystemFactoryResetPresenter *g_pSystemFactoryResetPresenter = nullptr; + + SystemFactoryResetPresenter::SystemFactoryResetPresenter() + { + + g_pSystemFactoryResetPresenter = this; + } + + SystemFactoryResetPresenter::~SystemFactoryResetPresenter() + { + + g_pSystemFactoryResetPresenter = nullptr; + } + + SystemFactoryResetPresenter *SystemFactoryResetPresenter::GetInstance() + { + + return g_pSystemFactoryResetPresenter; + } + + void SystemFactoryResetPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void SystemFactoryResetPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void SystemFactoryResetPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void SystemFactoryResetPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool SystemFactoryResetPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + UNUSED(view); + UNUSED(event); + return true; + } + + bool SystemFactoryResetPresenter::OnClick(UIView &view, const ClickEvent &event) + { + + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), FACTORYRESET_CHECKON) == 0) + { + printf("file:%s line:%d\n shoutdown button check on being clicked\n", __FILE__, __LINE__); + return true; + } + else if (strcmp(view.GetViewId(), FACTORYRESET_CHECKOFF) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM); + return true; + } + return false; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/steamfactoryreset/src/SystemFactoryResetView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/steamfactoryreset/src/SystemFactoryResetView.cpp new file mode 100644 index 000000000..dc8da2a5e --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/steamfactoryreset/src/SystemFactoryResetView.cpp @@ -0,0 +1,138 @@ +#include "steamfactoryreset/include/SystemFactoryResetView.h" +#include "steamfactoryreset/include/SystemFactoryResetPresenter.h" + +#include "UiConfig.h" + +namespace OHOS +{ + + static SystemFactoryResetView *g_pSystemFactoryResetView{nullptr}; + + SystemFactoryResetView::SystemFactoryResetView() + { + g_pSystemFactoryResetView = this; + } + + SystemFactoryResetView::~SystemFactoryResetView() + { + DeInitView(); + g_pSystemFactoryResetView = nullptr; + } + + SystemFactoryResetView *SystemFactoryResetView::GetInstance() + { + return g_pSystemFactoryResetView; + } + + void SystemFactoryResetView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + // Add ImageView to App + if (FactoryResetImage == nullptr) + { + FactoryResetImage = new UIImageView(); + } + FactoryResetImage->SetPosition(0, 0); // widget's left position and top position + FactoryResetImage->Resize(466, 466); // widget's width and height + FactoryResetImage->SetViewId("FactoryResetImage"); // Set style + FactoryResetImage->SetStyle(STYLE_BORDER_RADIUS, 300); + FactoryResetImage->SetSrc(PNG_FACTORY_RESET); + // Add to rootView + container_->Add(FactoryResetImage); + FactoryResetImage->SetVisible(true); + + // Add Button to App + if (FactoryResetButtonCheckOn == nullptr) + { + FactoryResetButtonCheckOn = new UIButton(); + } + FactoryResetButtonCheckOn->SetPosition(256, 336); // widget's left position and top position + FactoryResetButtonCheckOn->Resize(100, 100); // widget's width and height + FactoryResetButtonCheckOn->SetViewId(FACTORYRESET_CHECKON); // Set style + FactoryResetButtonCheckOn->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + FactoryResetButtonCheckOn->SetImageSrc(PNG_SYSTEM_CHECK_ON_IMAGE, nullptr); + FactoryResetButtonCheckOn->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + FactoryResetButtonCheckOn->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + // Add the CallBack about events + UIView::OnClickListener *FactoryResetButtonCheckOnClick = static_cast(SystemFactoryResetPresenter::GetInstance()); + FactoryResetButtonCheckOn->SetOnClickListener(FactoryResetButtonCheckOnClick); + // Add to rootView + container_->Add(FactoryResetButtonCheckOn); + FactoryResetButtonCheckOn->SetVisible(true); + + // Add Button to App + if (FactoryResetButtonCheckOff == nullptr) + { + FactoryResetButtonCheckOff = new UIButton(); + } + FactoryResetButtonCheckOff->SetPosition(111, 336); // widget's left position and top position + FactoryResetButtonCheckOff->Resize(100, 100); // widget's width and height + FactoryResetButtonCheckOff->SetViewId(FACTORYRESET_CHECKOFF); // Set style + FactoryResetButtonCheckOff->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + FactoryResetButtonCheckOff->SetImageSrc(PNG_SYSTEM_CHECK_OFF_IMAGE, nullptr); + FactoryResetButtonCheckOff->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + FactoryResetButtonCheckOff->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + // Add the CallBack about events + UIView::OnClickListener *FactoryResetButtonCheckOffClick = static_cast(SystemFactoryResetPresenter::GetInstance()); + FactoryResetButtonCheckOff->SetOnClickListener(FactoryResetButtonCheckOffClick); + // Add to rootView + container_->Add(FactoryResetButtonCheckOff); + FactoryResetButtonCheckOff->SetVisible(true); + } + + void SystemFactoryResetView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (FactoryResetImage != nullptr) + { + delete FactoryResetImage; + FactoryResetImage = nullptr; + } + if (FactoryResetButtonCheckOn != nullptr) + { + delete FactoryResetButtonCheckOn; + FactoryResetButtonCheckOn = nullptr; + } + if (FactoryResetButtonCheckOff != nullptr) + { + delete FactoryResetButtonCheckOff; + FactoryResetButtonCheckOff = nullptr; + } + } + + void SystemFactoryResetView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void SystemFactoryResetView::OnSetUpView() + { + View::OnSetUpView(); + Draw(); + } + + void SystemFactoryResetView::OnTearDownView() + { + View::OnTearDownView(); + return; + } + + void SystemFactoryResetView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/steamshoutdown/include/SystemShoutDownPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/steamshoutdown/include/SystemShoutDownPresenter.h new file mode 100644 index 000000000..349e4c79e --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/steamshoutdown/include/SystemShoutDownPresenter.h @@ -0,0 +1,34 @@ +#ifndef SYSTEM_SHOUTDOWN_PRESENTER_H +#define SYSTEM_SHOUTDOWN_PRESENTER_H + +#include "Presenter.h" + +#include "SystemShoutDownView.h" + +namespace OHOS +{ + class SystemShoutDownView; + + class SystemShoutDownPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + SystemShoutDownPresenter(); + virtual ~SystemShoutDownPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static SystemShoutDownPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/steamshoutdown/include/SystemShoutDownView.h b/code/sdk/application/wearable/nativeapp/nativeui/steamshoutdown/include/SystemShoutDownView.h new file mode 100644 index 000000000..1f7458126 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/steamshoutdown/include/SystemShoutDownView.h @@ -0,0 +1,39 @@ +#ifndef SYSTEM_SHOUTDOWN_VIEW_H +#define SYSTEM_SHOUTDOWN_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +namespace OHOS +{ + static const char *SHOUTDOWN_BUTTON_CHECKON = "ShoutDownButtonCheckOn";//确认 + static const char *SHOUTDOWN_BUTTON_CHECKOFF = "ShoutDownButtonCheckOff";//取消 + class SystemShoutDownPresenter; + class SystemShoutDownView : public View + { + + public: + SystemShoutDownView(); + virtual ~SystemShoutDownView(); + static SystemShoutDownView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + + void InitView(void); + void DeInitView(void); + + UIViewGroup *container_ = nullptr; + UIImageView *ShoutDownImage = nullptr; + UIButton *ShoutDownButtonCheckOn = nullptr; + UIButton *ShoutDownButtonCheckOff = nullptr; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/steamshoutdown/src/SystemShoutDownPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/steamshoutdown/src/SystemShoutDownPresenter.cpp new file mode 100644 index 000000000..42da34f3f --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/steamshoutdown/src/SystemShoutDownPresenter.cpp @@ -0,0 +1,78 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "steamshoutdown/include/SystemShoutDownPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static SystemShoutDownPresenter *g_pSystemShoutDownPresenter = nullptr; + + SystemShoutDownPresenter::SystemShoutDownPresenter() + { + + g_pSystemShoutDownPresenter = this; + } + + SystemShoutDownPresenter::~SystemShoutDownPresenter() + { + + g_pSystemShoutDownPresenter = nullptr; + } + + SystemShoutDownPresenter *SystemShoutDownPresenter::GetInstance() + { + + return g_pSystemShoutDownPresenter; + } + + void SystemShoutDownPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void SystemShoutDownPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void SystemShoutDownPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void SystemShoutDownPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool SystemShoutDownPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + UNUSED(event); + return true; + } + + bool SystemShoutDownPresenter::OnClick(UIView &view, const ClickEvent &event) + { + + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), SHOUTDOWN_BUTTON_CHECKON) == 0) + { + printf("file:%s line:%d\n shoutdown button check on being clicked\n", __FILE__, __LINE__); + return true; + } + else if (strcmp(view.GetViewId(), SHOUTDOWN_BUTTON_CHECKOFF) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM); + return true; + } + return false; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/steamshoutdown/src/SystemShoutDownView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/steamshoutdown/src/SystemShoutDownView.cpp new file mode 100644 index 000000000..23cecf1b8 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/steamshoutdown/src/SystemShoutDownView.cpp @@ -0,0 +1,138 @@ +#include "steamshoutdown/include/SystemShoutDownView.h" +#include "steamshoutdown/include/SystemShoutDownPresenter.h" + +#include "UiConfig.h" + +namespace OHOS +{ + + static SystemShoutDownView *g_pSystemShoutDownView{nullptr}; + + SystemShoutDownView::SystemShoutDownView() + { + g_pSystemShoutDownView = this; + } + + SystemShoutDownView::~SystemShoutDownView() + { + DeInitView(); + g_pSystemShoutDownView = nullptr; + } + + SystemShoutDownView *SystemShoutDownView::GetInstance() + { + return g_pSystemShoutDownView; + } + + void SystemShoutDownView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + // Add ImageView to App + if (ShoutDownImage == nullptr) + { + ShoutDownImage = new UIImageView(); + } + ShoutDownImage->SetPosition(0, 0); // widget's left position and top position + ShoutDownImage->Resize(466, 466); // widget's width and height + ShoutDownImage->SetViewId("ShoutDownImage"); // Set style + ShoutDownImage->SetStyle(STYLE_BORDER_RADIUS, 300); + ShoutDownImage->SetSrc(PNG_SHOUTDOWN_IMAGE); + // Add to rootView + container_->Add(ShoutDownImage); + ShoutDownImage->SetVisible(true); + + // Add Button to App + if (ShoutDownButtonCheckOn == nullptr) + { + ShoutDownButtonCheckOn = new UIButton(); + } + ShoutDownButtonCheckOn->SetPosition(256, 299); // widget's left position and top position + ShoutDownButtonCheckOn->Resize(100, 100); // widget's width and height + ShoutDownButtonCheckOn->SetViewId(SHOUTDOWN_BUTTON_CHECKON); // Set style + ShoutDownButtonCheckOn->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + ShoutDownButtonCheckOn->SetImageSrc(PNG_SYSTEM_CHECK_ON_IMAGE, nullptr); + ShoutDownButtonCheckOn->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + ShoutDownButtonCheckOn->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + // Add the CallBack about events + UIView::OnClickListener *ShoutDownButtonCheckOnClick = static_cast(SystemShoutDownPresenter::GetInstance()); + ShoutDownButtonCheckOn->SetOnClickListener(ShoutDownButtonCheckOnClick); + // Add to rootView + container_->Add(ShoutDownButtonCheckOn); + ShoutDownButtonCheckOn->SetVisible(true); + + // Add Button to App + if (ShoutDownButtonCheckOff == nullptr) + { + ShoutDownButtonCheckOff = new UIButton(); + } + ShoutDownButtonCheckOff->SetPosition(111, 299); // widget's left position and top position + ShoutDownButtonCheckOff->Resize(100, 100); // widget's width and height + ShoutDownButtonCheckOff->SetViewId(SHOUTDOWN_BUTTON_CHECKOFF); // Set style + ShoutDownButtonCheckOff->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + ShoutDownButtonCheckOff->SetImageSrc(PNG_SYSTEM_CHECK_OFF_IMAGE, nullptr); + ShoutDownButtonCheckOff->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + ShoutDownButtonCheckOff->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + // Add the CallBack about events + UIView::OnClickListener *ShoutDownButtonCheckOffClick = static_cast(SystemShoutDownPresenter::GetInstance()); + ShoutDownButtonCheckOff->SetOnClickListener(ShoutDownButtonCheckOffClick); + // Add to rootView + container_->Add(ShoutDownButtonCheckOff); + ShoutDownButtonCheckOff->SetVisible(true); + } + + void SystemShoutDownView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (ShoutDownImage != nullptr) + { + delete ShoutDownImage; + ShoutDownImage = nullptr; + } + if (ShoutDownButtonCheckOn != nullptr) + { + delete ShoutDownButtonCheckOn; + ShoutDownButtonCheckOn = nullptr; + } + if (ShoutDownButtonCheckOff != nullptr) + { + delete ShoutDownButtonCheckOff; + ShoutDownButtonCheckOff = nullptr; + } + } + + void SystemShoutDownView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void SystemShoutDownView::OnSetUpView() + { + View::OnSetUpView(); + Draw(); + } + + void SystemShoutDownView::OnTearDownView() + { + View::OnTearDownView(); + return; + } + + void SystemShoutDownView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemPresenter.h new file mode 100644 index 000000000..0680e26df --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemPresenter.h @@ -0,0 +1,40 @@ +#ifndef SYSTEM_PRESENTER_H +#define SYSTEM_PRESENTER_H + +#include "Presenter.h" + +#include "SystemView.h" + +namespace OHOS +{ + class SystemView; + + class SystemPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + SystemPresenter(); + virtual ~SystemPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static SystemPresenter *GetInstance(); + + private: + //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} //namespace OHOS + + + + + + + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemView.h b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemView.h new file mode 100644 index 000000000..11b3627c3 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemView.h @@ -0,0 +1,56 @@ +#ifndef SYSTEM_VIEW_H +#define SYSTEM_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" + +namespace OHOS +{ + static const char *ABOUT_THE_WATCH = "AboutTheWatchButton"; // 关于手表 + static const char *SUPERVISE = "SuperviseButton"; // 监管 + static const char *SYSTEM_LANGUAGE = "SystemLanguageButton"; // 系统语言 + static const char *REBOOT = "RebootButton"; // 重启 + static const char *SHOUTDOWM = "ShoutdownButton"; // 关机 + static const char *FACTORY_RESET = "FactoryResetButton"; // 恢复出厂设置 + class SystemPresenter; + class SystemView : public View + { + + public: + SystemView(); + virtual ~SystemView(); + static SystemView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + UIView::OnDragListener *draglistener{nullptr}; + + void InitIView(void); + void DeInitView(void); + + private: + UIViewGroup *container_ = nullptr; + UIScrollView *SystemScrollView = nullptr; + UILabel *SystemLabel = nullptr; + UIImageView *image2_ = nullptr; + UIImageView *image1_ = nullptr; + UIButton *FactoryResetButton = nullptr; + UIButton *ShoutdownButton = nullptr; + UIButton *RebootButton = nullptr; + UIButton *AboutTheWatchButton = nullptr; + UIButton *SuperviseButton = nullptr; + UIButton *SystemLanguageButton = nullptr; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemPresenter.cpp new file mode 100644 index 000000000..be286181f --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemPresenter.cpp @@ -0,0 +1,103 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "system/include/SystemPresenter.h" +#include "systemaboutwatch//include/SystemAboutView.h" +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static SystemPresenter *g_pSystemPresenter = nullptr; + + SystemPresenter::SystemPresenter() + { + + g_pSystemPresenter = this; + } + + SystemPresenter::~SystemPresenter() + { + + g_pSystemPresenter = nullptr; + } + + SystemPresenter *SystemPresenter::GetInstance() + { + + return g_pSystemPresenter; + } + + void SystemPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void SystemPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void SystemPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void SystemPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool SystemPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); + return true; + } + return false; + } + + bool SystemPresenter::OnClick(UIView &view, const ClickEvent &event) + { + + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), ABOUT_THE_WATCH) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_ABOUT_WATCH); + return true; + } + else if (strcmp(view.GetViewId(), SUPERVISE) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_SUPERVISE); + return true; + } + else if (strcmp(view.GetViewId(), SYSTEM_LANGUAGE) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_SYSTEM_LANGUAGE); + return true; + } + else if (strcmp(view.GetViewId(), REBOOT) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_REBOOT); + return true; + } + else if (strcmp(view.GetViewId(), SHOUTDOWM) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_SHOUTDOWN); + return true; + } + else if (strcmp(view.GetViewId(), FACTORY_RESET) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_FACTORY_RESET); + return true; + } + return false; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemView.cpp new file mode 100644 index 000000000..0906dec32 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemView.cpp @@ -0,0 +1,319 @@ +#include "system/include/SystemView.h" +#include "system/include/SystemPresenter.h" + +#include "UiConfig.h" + +namespace OHOS +{ + + static SystemView *g_pSystemView{nullptr}; + + SystemView::SystemView() + { + g_pSystemView = this; + } + + SystemView::~SystemView() + { + DeInitView(); + g_pSystemView = nullptr; + } + + SystemView *SystemView::GetInstance() + { + + return g_pSystemView; + } + + void SystemView::InitIView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + UIView::OnDragListener *draglistener = static_cast(SystemPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + container_->SetTouchable(true); + container_->SetDraggable(true); + } + /***********************************************************************************************************/ + // Add ScrollView to App + if (SystemScrollView == nullptr) + { + SystemScrollView = new UIScrollView(); + } + SystemScrollView->SetPosition(0, 0); // widget's left position and top position + SystemScrollView->Resize(466, 466); // widget's width and height + SystemScrollView->SetViewId("SystemScrollView"); // Set style + SystemScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + container_->Add(SystemScrollView); + SystemScrollView->SetVisible(true); + /***********************************************************************************************************/ + // Add Label to App + if (SystemLabel == nullptr) + { + SystemLabel = new UILabel(); + } + SystemLabel->SetPosition(203, 52); // widget's left position and top position + SystemLabel->Resize(200, 60); // widget's width and height + SystemLabel->SetViewId("SystemLabel"); // Set style + SystemLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + SystemLabel->SetStyle(STYLE_TEXT_FONT, 30); + SystemLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + SystemLabel->SetText("系统"); + SystemLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + SystemLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + SystemLabel->SetRollSpeed(6); + SystemLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView3 + SystemScrollView->Add(SystemLabel); + SystemLabel->SetVisible(true); + /***********************************************************************************************************/ + // Add Button to App + if (AboutTheWatchButton == nullptr) + { + AboutTheWatchButton = new UIButton(); + } + AboutTheWatchButton->SetPosition(43, 120); // widget's left position and top position + AboutTheWatchButton->Resize(380, 100); // widget's width and height + AboutTheWatchButton->SetViewId(ABOUT_THE_WATCH); // Set style //关于手表 + AboutTheWatchButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + AboutTheWatchButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + AboutTheWatchButton->SetImageSrc(PNG_SYSTEM_ABOUT_THE_WATCH_IMAGE, nullptr); + AboutTheWatchButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + // Add the CallBack about events + UIView::OnClickListener *AboutTheWatchButtonClick = static_cast(SystemPresenter::GetInstance()); + AboutTheWatchButton->SetOnClickListener(AboutTheWatchButtonClick); + // Add to scrollView3 + SystemScrollView->Add(AboutTheWatchButton); + AboutTheWatchButton->SetVisible(true); + /***********************************************************************************************************/ + // Add Button to App + if (SuperviseButton == nullptr) + { + SuperviseButton = new UIButton(); + } + SuperviseButton->SetPosition(43, 240); // widget's left position and top position + SuperviseButton->Resize(380, 100); // widget's width and height + SuperviseButton->SetViewId(SUPERVISE); // Set style //监管 + SuperviseButton->SetStyle(STYLE_BORDER_RADIUS, 50); + SuperviseButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + SuperviseButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + SuperviseButton->SetImageSrc(PNG_SYSTEM_SUPERVISE_IMAGE, nullptr); + SuperviseButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + SuperviseButton->SetStyleForState(STYLE_BORDER_RADIUS, 50, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *SuperviseButtonClick = static_cast(SystemPresenter::GetInstance()); + SuperviseButton->SetOnClickListener(SuperviseButtonClick); + // Add to scrollView3 + SystemScrollView->Add(SuperviseButton); + SuperviseButton->SetVisible(true); + /***********************************************************************************************************/ + // Add Button to App + if (SystemLanguageButton == nullptr) + { + SystemLanguageButton = new UIButton(); + } + SystemLanguageButton->SetPosition(43, 360); // widget's left position and top position + SystemLanguageButton->Resize(380, 100); // widget's width and height + SystemLanguageButton->SetViewId(SYSTEM_LANGUAGE); // Set style //系统语言 + SystemLanguageButton->SetStyle(STYLE_BORDER_RADIUS, 50); + SystemLanguageButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + SystemLanguageButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + SystemLanguageButton->SetImageSrc(PNG_SYSTEM_SYSTEM_LANGUAGE_IMAGE, nullptr); + SystemLanguageButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + SystemLanguageButton->SetStyleForState(STYLE_BORDER_RADIUS, 50, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *SystemLanguageButtonClick = static_cast(SystemPresenter::GetInstance()); + SystemLanguageButton->SetOnClickListener(SystemLanguageButtonClick); + // Add to scrollView3 + SystemScrollView->Add(SystemLanguageButton); + SystemLanguageButton->SetVisible(true); + /***********************************************************************************************************/ + // Add Button to App + if (RebootButton == nullptr) + { + RebootButton = new UIButton(); + } + RebootButton->SetPosition(43, 480); // widget's left position and top position + RebootButton->Resize(380, 100); // widget's width and height + RebootButton->SetViewId(REBOOT); // Set style //重启 + RebootButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + RebootButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + RebootButton->SetImageSrc(PNG_SYSTEM_REBOOT_IMAGE, nullptr); + RebootButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + // Add the CallBack about events + UIView::OnClickListener *RebootButtonClick = static_cast(SystemPresenter::GetInstance()); + RebootButton->SetOnClickListener(RebootButtonClick); + // Add to scrollView3 + SystemScrollView->Add(RebootButton); + RebootButton->SetVisible(true); + /***********************************************************************************************************/ + // Add Button to App + if (ShoutdownButton == nullptr) + { + ShoutdownButton = new UIButton(); + } + ShoutdownButton->SetPosition(43, 600); // widget's left position and top position + ShoutdownButton->Resize(380, 100); // widget's width and height + ShoutdownButton->SetViewId(SHOUTDOWM); // Set style //关机 + ShoutdownButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + ShoutdownButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + // Set additional property + char *button5triggeredImgSrc = nullptr; + ShoutdownButton->SetImageSrc(PNG_SYSTEM_SHOUTDOWM_IMAGE, nullptr); + ShoutdownButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *ShoutdownButtonClick = static_cast(SystemPresenter::GetInstance()); + ShoutdownButton->SetOnClickListener(ShoutdownButtonClick); + // Add to scrollView3 + SystemScrollView->Add(ShoutdownButton); + ShoutdownButton->SetVisible(true); + + /***********************************************************************************************************/ + // Add Button to App + if (FactoryResetButton == nullptr) + { + FactoryResetButton = new UIButton(); + } + FactoryResetButton->SetPosition(43, 720); // widget's left position and top position + FactoryResetButton->Resize(380, 100); // widget's width and height + FactoryResetButton->SetViewId(FACTORY_RESET); // Set style //恢复出厂设置 + FactoryResetButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + FactoryResetButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + FactoryResetButton->SetImageSrc(PNG_SYSTEM_FACTORY_RESET_IMAGE, nullptr); + FactoryResetButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *FactoryResetButtonClick = static_cast(SystemPresenter::GetInstance()); + FactoryResetButton->SetOnClickListener(FactoryResetButtonClick); + // Add to scrollView3 + SystemScrollView->Add(FactoryResetButton); + FactoryResetButton->SetVisible(true); + /***********************************************************************************************************/ + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(171, 801); // widget's left position and top position + image1_->Resize(100, 100); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Add to scrollView3 + SystemScrollView->Add(image1_); + image1_->SetVisible(true); + /***********************************************************************************************************/ + // Add ImageView to App + if (image2_ == nullptr) + { + image2_ = new UIImageView(); + } + image2_->SetPosition(183, 21); // widget's left position and top position + image2_->Resize(100, 100); // widget's width and height + image2_->SetViewId("image2"); // Set style + // Add to scrollView3 + SystemScrollView->Add(image2_); + image2_->SetVisible(true); + } + + void SystemView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (SystemScrollView != nullptr) + { + delete SystemScrollView; + SystemScrollView = nullptr; + } + if (SystemLabel != nullptr) + { + delete SystemLabel; + SystemLabel = nullptr; + } + if (image2_ != nullptr) + { + delete image2_; + image2_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (FactoryResetButton != nullptr) + { + delete FactoryResetButton; + FactoryResetButton = nullptr; + } + if (ShoutdownButton != nullptr) + { + delete ShoutdownButton; + ShoutdownButton = nullptr; + } + if (RebootButton != nullptr) + { + delete RebootButton; + RebootButton = nullptr; + } + if (AboutTheWatchButton != nullptr) + { + delete AboutTheWatchButton; + AboutTheWatchButton = nullptr; + } + if (SuperviseButton != nullptr) + { + delete SuperviseButton; + SuperviseButton = nullptr; + } + if (SystemLanguageButton != nullptr) + { + delete SystemLanguageButton; + SystemLanguageButton = nullptr; + } + } + + void SystemView::OnStart() + { + View::OnStart(); + InitIView(); + RootView::GetInstance()->Add(container_); + } + + void SystemView::OnSetUpView() + { + View::OnSetUpView(); + Draw(); + } + + void SystemView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void SystemView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/systemaboutwatch/include/SystemAboutPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/systemaboutwatch/include/SystemAboutPresenter.h new file mode 100644 index 000000000..bcbcb0ee0 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/systemaboutwatch/include/SystemAboutPresenter.h @@ -0,0 +1,35 @@ +#ifndef SYSTEM_ABOUT_PRESENTER_H +#define SYSTEM_ABOUT_PRESENTER_H + +#include "Presenter.h" + +#include "SystemAboutView.h" + +namespace OHOS +{ + class SystemAboutView; + + class SystemAboutPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + SystemAboutPresenter(); + virtual ~SystemAboutPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static SystemAboutPresenter *GetInstance(); + + private: + //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} //namespace OHOS + + +#endif //SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/systemaboutwatch/include/SystemAboutView.h b/code/sdk/application/wearable/nativeapp/nativeui/systemaboutwatch/include/SystemAboutView.h new file mode 100644 index 000000000..8f3f6a645 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/systemaboutwatch/include/SystemAboutView.h @@ -0,0 +1,53 @@ +#ifndef SYSTEM_ABOUT_VIEW_H +#define SYSTEM_ABOUT_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +namespace OHOS +{ + class SystemAboutPresenter; + class SystemAboutView : public View + { + + public: + SystemAboutView(); + virtual ~SystemAboutView(); + static SystemAboutView *GetInstance(void); + + UILabel *InitLabel(int left, int top, int width, int height, const char *text, const char *viewId, int fontSize, int fontlineHeigh, uint16_t speed); + + public: + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void SystemAboutInitIView(void); + void DeSystemAboutInitIView(void); + + private: + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UILabel *label1_ = nullptr; + UILabel *label2_ = nullptr; + UILabel *label3_ = nullptr; + UILabel *label4_ = nullptr; + UILabel *label5_ = nullptr; + UILabel *label6_ = nullptr; + UILabel *label7_ = nullptr; + UILabel *label8_ = nullptr; + UILabel *label9_ = nullptr; + UILabel *label10_ = nullptr; + UILabel *label11_ = nullptr; + UILabel *label12_ = nullptr; + UILabel *label13_ = nullptr; + + UIImageView *image = nullptr; + }; +} // namespace OHOS +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/systemaboutwatch/src/SystemAboutPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/systemaboutwatch/src/SystemAboutPresenter.cpp new file mode 100644 index 000000000..d4038f02a --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/systemaboutwatch/src/SystemAboutPresenter.cpp @@ -0,0 +1,74 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "systemaboutwatch/include/SystemAboutPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static SystemAboutPresenter *g_pSystemAboutPresenter = nullptr; + + SystemAboutPresenter::SystemAboutPresenter() + { + + g_pSystemAboutPresenter = this; + } + + SystemAboutPresenter::~SystemAboutPresenter() + { + + g_pSystemAboutPresenter = nullptr; + } + + SystemAboutPresenter *SystemAboutPresenter::GetInstance() + { + + return g_pSystemAboutPresenter; + } + + void SystemAboutPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void SystemAboutPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void SystemAboutPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void SystemAboutPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool SystemAboutPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM); + return true; + } + return false; + } + + bool SystemAboutPresenter::OnClick(UIView &view, const ClickEvent &event) + { + + // 根据控件id查找是哪个控件触发了点击回调 + // if (strcmp(view.GetViewId(), 控件ID) == 0) + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/systemaboutwatch/src/SystemAboutView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/systemaboutwatch/src/SystemAboutView.cpp new file mode 100644 index 000000000..6f4ae67b1 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/systemaboutwatch/src/SystemAboutView.cpp @@ -0,0 +1,299 @@ +#include "systemaboutwatch/include/SystemAboutView.h" +#include "systemaboutwatch/include/SystemAboutPresenter.h" +#include "UiConfig.h" + +namespace OHOS +{ + + static SystemAboutView *g_pSystemAboutView{nullptr}; + + SystemAboutView::SystemAboutView() + { + + g_pSystemAboutView = this; + } + + SystemAboutView::~SystemAboutView() + { + + g_pSystemAboutView = nullptr; + } + + SystemAboutView *SystemAboutView::GetInstance() + { + + return g_pSystemAboutView; + } + UILabel *SystemAboutView::InitLabel(int left, int top, int width, int height, const char *text, const char *viewId, int fontSize, int fontlineHeigh, uint16_t speed) + { + UILabel *label = new UILabel(); + label->SetPosition(left, top); // 位置 + label->Resize(width, height); // 大小 + label->SetViewId(viewId); // id + label->SetStyle(STYLE_TEXT_FONT, fontSize); // 字体大小 + label->SetStyle(STYLE_LINE_HEIGHT, fontlineHeigh); // 字体行高 + label->SetText(text); // 内容 + label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(speed); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, fontSize); + + return label; + } + + void SystemAboutView::SystemAboutInitIView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + UIView::OnDragListener *draglistener = static_cast(SystemAboutPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + container_->SetTouchable(true); + container_->SetDraggable(true); + } + // Add ScrollView to App + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); // widget's left position and top position + scrollView1_->Resize(466, 466); // widget's width and height + scrollView1_->SetViewId("scrollView"); // Set style + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + scrollView1_->SetStyle(STYLE_BORDER_RADIUS, 1294); + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + /***********************************************************************************************************/ + if (label1_ == nullptr) + { + label1_ = InitLabel(203, 52, 60, 35, "关于", "label1", 30, 35, 6); + } + scrollView1_->Add(label1_); + label1_->SetVisible(true); + /***********************************************************************************************************/ + if (label2_ == nullptr) + { + label2_ = InitLabel(173, 160, 120, 35, "手表名称", "label2", 30, 35, 6); + } + scrollView1_->Add(label2_); + label2_->SetVisible(true); + /***********************************************************************************************************/ + if (label3_ == nullptr) + { + label3_ = InitLabel(97, 217, 263, 30, "周冰鸿的 Smart Watch", "label3", 26, 30, 6); + } + label3_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + scrollView1_->Add(label3_); + label3_->SetVisible(true); + /***********************************************************************************************************/ + // Add Label to App + if (label4_ == nullptr) + { + label4_ = InitLabel(173, 305, 120, 35, "固件版本", "label4", 30, 35, 6); + } + scrollView1_->Add(label4_); + label4_->SetVisible(true); + /***********************************************************************************************************/ + // Add Label to App + if (label5_ == nullptr) + { + label5_ = InitLabel(174, 361, 119, 30, "V02.03.01", "label5", 26, 30, 6); + } + label5_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + scrollView1_->Add(label5_); + label5_->SetVisible(true); + /***********************************************************************************************************/ + if (label6_ == nullptr) + { + label6_ = InitLabel(173, 450, 120, 35, "算法版本", "label6", 30, 35, 6); + } + scrollView1_->Add(label6_); + label6_->SetVisible(true); + RootView::GetInstance()->Add(container_); + /***********************************************************************************************************/ + if (label7_ == nullptr) + { + label7_ = InitLabel(131, 506, 204, 30, "V02.03.01 OTA88", "label7", 26, 30, 6); + } + label7_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + scrollView1_->Add(label7_); + label7_->SetVisible(true); + /***********************************************************************************************************/ + if (label8_ == nullptr) + { + label8_ = InitLabel(173, 595, 120, 35, "蓝牙地址", "label8", 30, 35, 6); + } + + scrollView1_->Add(label8_); + label8_->SetVisible(true); + /***********************************************************************************************************/ + if (label9_ == nullptr) + { + label9_ = InitLabel(123, 651, 220, 30, "D4:FF:E3:12:00:A4", "label9", 26, 30, 6); + } + + label9_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + scrollView1_->Add(label9_); + label9_->SetVisible(true); + /***********************************************************************************************************/ + if (label10_ == nullptr) + { + label10_ = InitLabel(158, 740, 120, 35, "局域网地址", "label10", 30, 35, 6); + } + scrollView1_->Add(label10_); + label10_->SetVisible(true); + /***********************************************************************************************************/ + if (label11_ == nullptr) + { + label11_ = InitLabel(123, 796, 220, 30, "D4:FF:E3:12:00:A4", "label11", 26, 30, 6); + } + label11_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + scrollView1_->Add(label11_); + label11_->SetVisible(true); + /***********************************************************************************************************/ + if (label12_ == nullptr) + { + label12_ = InitLabel(185, 885, 97, 35, "FONTS", "label12", 30, 35, 6); + } + scrollView1_->Add(label12_); + label12_->SetVisible(true); + /***********************************************************************************************************/ + if (label13_ == nullptr) + { + label13_ = InitLabel(130, 941, 207, 30, "HarmonyOS Sans", "label13", 26, 30, 6); + } + label13_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + scrollView1_->Add(label13_); + label13_->SetVisible(true); + /***********************************************************************************************************/ + // Add ImageView to App + if (image == nullptr) + { + image = new UIImageView(); + } + image->SetPosition(183, 941); // widget's left position and top position + image->Resize(100, 100); // widget's width and height + image->SetViewId("image"); // Set style + + scrollView1_->Add(image); + image->SetVisible(true); + } + void SystemAboutView::DeSystemAboutInitIView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (label3_ != nullptr) + { + delete label3_; + label3_ = nullptr; + } + if (label4_ != nullptr) + { + delete label4_; + label4_ = nullptr; + } + if (label5_ != nullptr) + { + delete label5_; + label5_ = nullptr; + } + if (label6_ != nullptr) + { + delete label6_; + label6_ = nullptr; + } + if (label7_ != nullptr) + { + delete label7_; + label7_ = nullptr; + } + if (label8_ != nullptr) + { + delete label8_; + label8_ = nullptr; + } + if (label9_ != nullptr) + { + delete label9_; + label9_ = nullptr; + } + if (label10_ != nullptr) + { + delete label10_; + label10_ = nullptr; + } + if (label11_ != nullptr) + { + delete label11_; + label11_ = nullptr; + } + if (label12_ != nullptr) + { + delete label12_; + label12_ = nullptr; + } + if (label13_ != nullptr) + { + delete label13_; + label13_ = nullptr; + } + if (image != nullptr) + { + delete image; + image = nullptr; + } + } + + void SystemAboutView::OnStart() + { + SystemAboutInitIView(); + RootView::GetInstance()->Add(container_); + } + + void SystemAboutView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void SystemAboutView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void SystemAboutView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/systemlanguage/include/SystemLanguagePresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/systemlanguage/include/SystemLanguagePresenter.h new file mode 100644 index 000000000..08f3f3e91 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/systemlanguage/include/SystemLanguagePresenter.h @@ -0,0 +1,42 @@ +#ifndef SYSTEM_LANGUAGE_PRESENTER_H +#define SYSTEM_LANGUAGE_PRESENTER_H + +#include "Presenter.h" +#include "SystemLanguageView.h" +#include "components/ui_checkbox.h" +namespace OHOS +{ + class SystemLanguageView; + + class SystemLanguagePresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + SystemLanguagePresenter(); + SystemLanguagePresenter(UICheckBox *checkbox1, UICheckBox *checkbox2) : m_checkbox1(checkbox1), m_checkbox2(checkbox2) {} + virtual ~SystemLanguagePresenter(); + + void UpdateCheckBoxState(UICheckBox &checkbox, bool isSelected); + //void ToggleCheckBoxState(UICheckBox &checkbox); + + public: + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static SystemLanguagePresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + + private: + UICheckBox *m_checkbox1 = nullptr; + UICheckBox *m_checkbox2 = nullptr; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/systemlanguage/include/SystemLanguageView.h b/code/sdk/application/wearable/nativeapp/nativeui/systemlanguage/include/SystemLanguageView.h new file mode 100644 index 000000000..4e939a2c7 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/systemlanguage/include/SystemLanguageView.h @@ -0,0 +1,51 @@ +#ifndef SYSTEM_LANGUAGE_VIEW_H +#define SYSTEM_LANGUAGE_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_checkbox.h" +#include "components/ui_image_view.h" +namespace OHOS +{ + static const char *SIMPLIFIED_CHINESE_BUTTON = "SimplifiedChineseButton"; // 简体中文 button + static const char *ENGLISH_BUTTON = "EnglishButton"; // English button + static const char *SIMPLIFIED_CHINESE_CHECKBOX = "SimplifiedChineseCheckBox"; // 简体中文 checkbox + static const char *ENGLISH_CHECKBOX = "EnglishCheckBox"; // English checkbox + + class SystemLanguagePresenter; + class SystemLanguageView : public View + { + + public: + SystemLanguageView(); + virtual ~SystemLanguageView(); + static SystemLanguageView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + + void init(void); + + private: + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView = nullptr; + UILabel *LanguageLabel = nullptr; + UIImageView *SimplifiedChineseImage = nullptr; + UICheckBox *SimplifiedChineseCheckBox = nullptr; + UIImageView *EnglishImage = nullptr; + UILabel *SimplifiedChineseLabel = nullptr; + UILabel *EnglishLabel = nullptr; + UICheckBox *EnglishCheckBox = nullptr; + }; +} // namespace OHOS +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/systemlanguage/src/SystemLanguagePresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/systemlanguage/src/SystemLanguagePresenter.cpp new file mode 100644 index 000000000..7e9b9f7f5 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/systemlanguage/src/SystemLanguagePresenter.cpp @@ -0,0 +1,90 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "systemlanguage/include/SystemLanguagePresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static SystemLanguagePresenter *g_pSystemLanguagePresenter = nullptr; + int count = 1; + SystemLanguagePresenter::SystemLanguagePresenter() + { + + g_pSystemLanguagePresenter = this; + } + + SystemLanguagePresenter::~SystemLanguagePresenter() + { + + g_pSystemLanguagePresenter = nullptr; + } + + SystemLanguagePresenter *SystemLanguagePresenter::GetInstance() + { + + return g_pSystemLanguagePresenter; + } + + void SystemLanguagePresenter::OnStart() + { + + Presenter::OnStart(); + } + + void SystemLanguagePresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void SystemLanguagePresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void SystemLanguagePresenter::OnStop(void) + { + + Presenter::OnStop(); + } + bool SystemLanguagePresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM); + return true; + } + return false; + } + + bool SystemLanguagePresenter::OnClick(UIView &view, const ClickEvent &event) + { + if (strcmp(view.GetViewId(), SIMPLIFIED_CHINESE_CHECKBOX) == 0) + { + + m_checkbox1->SetState(UICheckBox::SELECTED); + UpdateCheckBoxState(*m_checkbox2, false); + + return true; + } + else if (strcmp(view.GetViewId(), ENGLISH_CHECKBOX) == 0) + { + m_checkbox2->SetState(UICheckBox::SELECTED); + UpdateCheckBoxState(*m_checkbox1, false); + return true; + } + return false; + } + + // 根据传入的选中状态更新复选框的状态 + void SystemLanguagePresenter::UpdateCheckBoxState(UICheckBox &checkbox, bool isSelected) + { + checkbox.SetState(isSelected ? UICheckBox::SELECTED : UICheckBox::UNSELECTED); + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/systemlanguage/src/SystemLanguageView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/systemlanguage/src/SystemLanguageView.cpp new file mode 100644 index 000000000..c4086b07f --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/systemlanguage/src/SystemLanguageView.cpp @@ -0,0 +1,270 @@ +#include "systemlanguage/include/SystemLanguageView.h" +#include "systemlanguage/include/SystemLanguagePresenter.h" +#include "string.h" +#include "UiConfig.h" +#include "ui_view.h" +namespace OHOS +{ + + static SystemLanguageView *g_pSystemLanguageView{nullptr}; + + SystemLanguageView::SystemLanguageView() + { + + g_pSystemLanguageView = this; + } + + SystemLanguageView::~SystemLanguageView() + { + DeInitView(); + g_pSystemLanguageView = nullptr; + } + + SystemLanguageView *SystemLanguageView::GetInstance() + { + + return g_pSystemLanguageView; + } + + void SystemLanguageView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + UIView::OnDragListener *draglistener = static_cast(SystemLanguagePresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + container_->SetTouchable(true); + container_->SetDraggable(true); + } + /***********************************************************************************************************/ + if (scrollView == nullptr) + { + scrollView = new UIScrollView(); + } + scrollView->SetPosition(0, 0); + scrollView->Resize(466, 466); + scrollView->SetViewId("scrollView"); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + scrollView->SetStyle(STYLE_BORDER_RADIUS, 1294); + container_->Add(scrollView); + scrollView->SetVisible(true); + /***********************************************************************************************************/ + // Add Label to App + if (LanguageLabel == nullptr) + { + LanguageLabel = new UILabel(); + } + LanguageLabel->SetPosition(203, 52); // widget's left position and top position + LanguageLabel->Resize(200, 60); // widget's width and height + LanguageLabel->SetViewId("LanguageLabel"); // Set style + LanguageLabel->SetStyle(STYLE_TEXT_FONT, 30); + LanguageLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + LanguageLabel->SetText("语言"); + LanguageLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + LanguageLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + LanguageLabel->SetRollSpeed(0); + LanguageLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + scrollView->Add(LanguageLabel); + LanguageLabel->SetVisible(true); + /***********************************************************************************************************/ + if (SimplifiedChineseImage == nullptr) + { + SimplifiedChineseImage = new UIImageView(); + } + SimplifiedChineseImage->SetPosition(43, 120); + SimplifiedChineseImage->Resize(380, 100); + SimplifiedChineseImage->SetViewId(SIMPLIFIED_CHINESE_BUTTON); + SimplifiedChineseImage->SetStyle(STYLE_BORDER_RADIUS, 50); + SimplifiedChineseImage->SetSrc(PNG_SETTING_BACKGROUND_IMAGE); + // Add to scrollView1 + scrollView->Add(SimplifiedChineseImage); + SimplifiedChineseImage->SetVisible(true); + /***********************************************************************************************************/ + if (SimplifiedChineseLabel == nullptr) + { + SimplifiedChineseLabel = new UILabel(); + } + SimplifiedChineseLabel->SetPosition(90, 153); + SimplifiedChineseLabel->Resize(120, 35); + SimplifiedChineseLabel->SetViewId("SimplifiedChineseLabel"); + SimplifiedChineseLabel->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + SimplifiedChineseLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + SimplifiedChineseLabel->SetStyle(STYLE_TEXT_FONT, 30); + SimplifiedChineseLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + SimplifiedChineseLabel->SetText("简体中文"); + SimplifiedChineseLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + SimplifiedChineseLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + SimplifiedChineseLabel->SetRollSpeed(0); + SimplifiedChineseLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView1 + scrollView->Add(SimplifiedChineseLabel); + SimplifiedChineseLabel->SetVisible(true); + /***********************************************************************************************************/ + // Add CheckBox to App + if (SimplifiedChineseCheckBox == nullptr) + { + SimplifiedChineseCheckBox = new UICheckBox(); + } + SimplifiedChineseCheckBox->SetState(UICheckBox::SELECTED); + SimplifiedChineseCheckBox->SetPosition(300, 130); // widget's left position and top position + SimplifiedChineseCheckBox->Resize(80, 80); // widget's width and height + SimplifiedChineseCheckBox->SetViewId(SIMPLIFIED_CHINESE_CHECKBOX); // Set style + SimplifiedChineseCheckBox->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + SimplifiedChineseCheckBox->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + SimplifiedChineseCheckBox->SetImages(PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE); + // Add the CallBack about events + UIView::OnClickListener *SimplifiedChineseCheckBoxClick = static_cast(SystemLanguagePresenter::GetInstance()); + SimplifiedChineseCheckBox->SetOnClickListener(SimplifiedChineseCheckBoxClick); + // Add to scrollView1 + scrollView->Add(SimplifiedChineseCheckBox); + SimplifiedChineseCheckBox->SetVisible(true); + /***********************************************************************************************************/ + if (EnglishImage == nullptr) + { + EnglishImage = new UIImageView(); + } + EnglishImage->SetPosition(43, 240); + EnglishImage->Resize(380, 100); + EnglishImage->SetViewId(ENGLISH_BUTTON); + EnglishImage->SetStyle(STYLE_BORDER_RADIUS, 50); + EnglishImage->SetSrc(PNG_SETTING_BACKGROUND_IMAGE); + scrollView->Add(EnglishImage); + EnglishImage->SetVisible(true); + /***********************************************************************************************************/ + if (EnglishLabel == nullptr) + { + EnglishLabel = new UILabel(); + } + EnglishLabel->SetPosition(90, 273); // widget's left position and top position + EnglishLabel->Resize(126, 35); // widget's width and height + EnglishLabel->SetViewId("EnglishLabel"); // Set style + EnglishLabel->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + EnglishLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + EnglishLabel->SetStyle(STYLE_TEXT_FONT, 30); + EnglishLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + EnglishLabel->SetText("ENGLISH"); + EnglishLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + EnglishLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + EnglishLabel->SetRollSpeed(0); + EnglishLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView->Add(EnglishLabel); + EnglishLabel->SetVisible(true); + + // Add CheckBox to App + if (EnglishCheckBox == nullptr) + { + EnglishCheckBox = new UICheckBox(); + } + EnglishCheckBox->SetPosition(300, 250); + EnglishCheckBox->Resize(80, 80); + EnglishCheckBox->SetViewId(ENGLISH_CHECKBOX); + EnglishCheckBox->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + EnglishCheckBox->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + EnglishCheckBox->SetImages(PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE); + + // Add the CallBack about events + UIView::OnClickListener *EnglishCheckBoxClick = static_cast(SystemLanguagePresenter::GetInstance()); + EnglishCheckBox->SetOnClickListener(EnglishCheckBoxClick); + // Add to scrollView1 + scrollView->Add(EnglishCheckBox); + EnglishCheckBox->SetVisible(true); + + /***********************************************************************************************************/ + // Add the CallBack about SimplifiedChineseImage sevents + UIView::OnClickListener *ButtonClick = static_cast(new SystemLanguagePresenter(SimplifiedChineseCheckBox, EnglishCheckBox)); + SimplifiedChineseCheckBox->SetOnClickListener(ButtonClick); + EnglishCheckBox->SetOnClickListener(ButtonClick); + } + + void SystemLanguageView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView != nullptr) + { + delete scrollView; + scrollView = nullptr; + } + if (LanguageLabel != nullptr) + { + delete LanguageLabel; + LanguageLabel = nullptr; + } + if (SimplifiedChineseImage != nullptr) + { + delete SimplifiedChineseImage; + SimplifiedChineseImage = nullptr; + } + if (SimplifiedChineseCheckBox != nullptr) + { + delete SimplifiedChineseCheckBox; + SimplifiedChineseCheckBox = nullptr; + } + if (EnglishImage != nullptr) + { + delete EnglishImage; + EnglishImage = nullptr; + } + if (SimplifiedChineseLabel != nullptr) + { + delete SimplifiedChineseLabel; + SimplifiedChineseLabel = nullptr; + } + if (EnglishLabel != nullptr) + { + delete EnglishLabel; + EnglishLabel = nullptr; + } + if (EnglishCheckBox != nullptr) + { + delete EnglishCheckBox; + EnglishCheckBox = nullptr; + } + } + + void SystemLanguageView::OnStart() + { + View::OnStart(); + InitView(); + // container_容器属性 add + RootView::GetInstance()->Add(container_); + } + + void SystemLanguageView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void SystemLanguageView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void SystemLanguageView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/systemreboot/include/SystemRebootPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/systemreboot/include/SystemRebootPresenter.h new file mode 100644 index 000000000..1f1b93ebb --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/systemreboot/include/SystemRebootPresenter.h @@ -0,0 +1,34 @@ +#ifndef SYSTEM_REBOOT_PRESENTER_H +#define SYSTEM_REBOOT_PRESENTER_H + +#include "Presenter.h" + +#include "SystemRebootView.h" + +namespace OHOS +{ + class SystemRebootView; + + class SystemRebootPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + SystemRebootPresenter(); + virtual ~SystemRebootPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static SystemRebootPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/systemreboot/include/SystemRebootView.h b/code/sdk/application/wearable/nativeapp/nativeui/systemreboot/include/SystemRebootView.h new file mode 100644 index 000000000..a4b758745 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/systemreboot/include/SystemRebootView.h @@ -0,0 +1,39 @@ +#ifndef SYSTEM_REBOOT_VIEW_H +#define SYSTEM_REBOOT_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +namespace OHOS +{ + static const char *REBOOT_CHECKON = "ShoutDownButtonCheckOn";//确认 + static const char *REBOOT_CHECKOFF = "ShoutDownButtonCheckOff";//取消 + class SystemRebootPresenter; + class SystemRebootView : public View + { + + public: + SystemRebootView(); + virtual ~SystemRebootView(); + static SystemRebootView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + + void InitView(void); + void DeInitView(void); + + UIViewGroup *container_ = nullptr; + UIImageView *RebootImage = nullptr; + UIButton *RebootButtonCheckOn = nullptr; + UIButton *RebootButtonCheckOff = nullptr; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/systemreboot/src/SystemRebootPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/systemreboot/src/SystemRebootPresenter.cpp new file mode 100644 index 000000000..ccc461adb --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/systemreboot/src/SystemRebootPresenter.cpp @@ -0,0 +1,79 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "systemreboot/include/SystemRebootPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static SystemRebootPresenter *g_pSystemRebootPresenter = nullptr; + + SystemRebootPresenter::SystemRebootPresenter() + { + + g_pSystemRebootPresenter = this; + } + + SystemRebootPresenter::~SystemRebootPresenter() + { + + g_pSystemRebootPresenter = nullptr; + } + + SystemRebootPresenter *SystemRebootPresenter::GetInstance() + { + + return g_pSystemRebootPresenter; + } + + void SystemRebootPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void SystemRebootPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void SystemRebootPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void SystemRebootPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool SystemRebootPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + UNUSED(view); + UNUSED(event); + return true; + } + + bool SystemRebootPresenter::OnClick(UIView &view, const ClickEvent &event) + { + + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), REBOOT_CHECKON) == 0) + { + printf("file:%s line:%d\n shoutdown button check on being clicked\n", __FILE__, __LINE__); + return true; + } + else if (strcmp(view.GetViewId(), REBOOT_CHECKOFF) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM); + return true; + } + return false; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/systemreboot/src/SystemRebootView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/systemreboot/src/SystemRebootView.cpp new file mode 100644 index 000000000..3dfffa9fb --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/systemreboot/src/SystemRebootView.cpp @@ -0,0 +1,138 @@ +#include "systemreboot/include/SystemRebootView.h" +#include "systemreboot/include/SystemRebootPresenter.h" + +#include "UiConfig.h" + +namespace OHOS +{ + + static SystemRebootView *g_pSystemRebootView{nullptr}; + + SystemRebootView::SystemRebootView() + { + g_pSystemRebootView = this; + } + + SystemRebootView::~SystemRebootView() + { + DeInitView(); + g_pSystemRebootView = nullptr; + } + + SystemRebootView *SystemRebootView::GetInstance() + { + return g_pSystemRebootView; + } + + void SystemRebootView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + // Add ImageView to App + if (RebootImage == nullptr) + { + RebootImage = new UIImageView(); + } + RebootImage->SetPosition(0, 0); // widget's left position and top position + RebootImage->Resize(466, 466); // widget's width and height + RebootImage->SetViewId("RebootImage"); // Set style + RebootImage->SetStyle(STYLE_BORDER_RADIUS, 300); + RebootImage->SetSrc(PNG_REBOOT_IMAGE); + // Add to rootView + container_->Add(RebootImage); + RebootImage->SetVisible(true); + + // Add Button to App + if (RebootButtonCheckOn == nullptr) + { + RebootButtonCheckOn = new UIButton(); + } + RebootButtonCheckOn->SetPosition(256, 299); // widget's left position and top position + RebootButtonCheckOn->Resize(100, 100); // widget's width and height + RebootButtonCheckOn->SetViewId(REBOOT_CHECKON); // Set style + RebootButtonCheckOn->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + RebootButtonCheckOn->SetImageSrc(PNG_SYSTEM_CHECK_ON_IMAGE, nullptr); + RebootButtonCheckOn->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + RebootButtonCheckOn->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + // Add the CallBack about events + UIView::OnClickListener *RebootButtonCheckOnClick = static_cast(SystemRebootPresenter::GetInstance()); + RebootButtonCheckOn->SetOnClickListener(RebootButtonCheckOnClick); + // Add to rootView + container_->Add(RebootButtonCheckOn); + RebootButtonCheckOn->SetVisible(true); + + // Add Button to App + if (RebootButtonCheckOff == nullptr) + { + RebootButtonCheckOff = new UIButton(); + } + RebootButtonCheckOff->SetPosition(111, 299); // widget's left position and top position + RebootButtonCheckOff->Resize(100, 100); // widget's width and height + RebootButtonCheckOff->SetViewId(REBOOT_CHECKOFF); // Set style + RebootButtonCheckOff->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + RebootButtonCheckOff->SetImageSrc(PNG_SYSTEM_CHECK_OFF_IMAGE, nullptr); + RebootButtonCheckOff->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + RebootButtonCheckOff->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + // Add the CallBack about events + UIView::OnClickListener *RebootButtonCheckOffClick = static_cast(SystemRebootPresenter::GetInstance()); + RebootButtonCheckOff->SetOnClickListener(RebootButtonCheckOffClick); + // Add to rootView + container_->Add(RebootButtonCheckOff); + RebootButtonCheckOff->SetVisible(true); + } + + void SystemRebootView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (RebootImage != nullptr) + { + delete RebootImage; + RebootImage = nullptr; + } + if (RebootButtonCheckOn != nullptr) + { + delete RebootButtonCheckOn; + RebootButtonCheckOn = nullptr; + } + if (RebootButtonCheckOff != nullptr) + { + delete RebootButtonCheckOff; + RebootButtonCheckOff = nullptr; + } + } + + void SystemRebootView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void SystemRebootView::OnSetUpView() + { + View::OnSetUpView(); + Draw(); + } + + void SystemRebootView::OnTearDownView() + { + View::OnTearDownView(); + return; + } + + void SystemRebootView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/systemsupervise/include/SystemSupervisePresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/systemsupervise/include/SystemSupervisePresenter.h new file mode 100644 index 000000000..198bcc7da --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/systemsupervise/include/SystemSupervisePresenter.h @@ -0,0 +1,34 @@ +#ifndef SYSTEM_SUPERVISE_PRESENTER_H +#define SYSTEM_SUPERVISE_PRESENTER_H + +#include "Presenter.h" + +#include "SystemSuperviseView.h" + +namespace OHOS +{ + class SystemSuperviseView; + + class SystemSupervisePresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + SystemSupervisePresenter(); + virtual ~SystemSupervisePresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static SystemSupervisePresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/systemsupervise/include/SystemSuperviseView.h b/code/sdk/application/wearable/nativeapp/nativeui/systemsupervise/include/SystemSuperviseView.h new file mode 100644 index 000000000..9c7173fd4 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/systemsupervise/include/SystemSuperviseView.h @@ -0,0 +1,40 @@ +#ifndef SYSTEM_SUPERVISE_VIEW_H +#define SYSTEM_SUPERVISE_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +namespace OHOS +{ + class SystemSupervisePresenter; + class SystemSuperviseView : public View + { + + public: + SystemSuperviseView(); + virtual ~SystemSuperviseView(); + static SystemSuperviseView *GetInstance(void); + UILabel *InitLabel(int left, int top, int width, int height, const char *text, const char *viewId, int fontSize, int fontlineHeigh, uint16_t speed); + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + + private: + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UILabel *label1_ = nullptr; + UILabel *label2_ = nullptr; + UILabel *label3_ = nullptr; + UILabel *label4_ = nullptr; + UILabel *label5_ = nullptr; + }; +} // namespace OHOS +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/systemsupervise/src/SystemSupervisePresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/systemsupervise/src/SystemSupervisePresenter.cpp new file mode 100644 index 000000000..0c9c5b927 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/systemsupervise/src/SystemSupervisePresenter.cpp @@ -0,0 +1,74 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "systemsupervise/include/SystemSupervisePresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static SystemSupervisePresenter *g_pSystemSupervisePresenter = nullptr; + + SystemSupervisePresenter::SystemSupervisePresenter() + { + + g_pSystemSupervisePresenter = this; + } + + SystemSupervisePresenter::~SystemSupervisePresenter() + { + + g_pSystemSupervisePresenter = nullptr; + } + + SystemSupervisePresenter *SystemSupervisePresenter::GetInstance() + { + + return g_pSystemSupervisePresenter; + } + + void SystemSupervisePresenter::OnStart() + { + + Presenter::OnStart(); + } + + void SystemSupervisePresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void SystemSupervisePresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void SystemSupervisePresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool SystemSupervisePresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM); + return true; + } + return false; + } + + bool SystemSupervisePresenter::OnClick(UIView &view, const ClickEvent &event) + { + + // 根据控件id查找是哪个控件触发了点击回调 + // if (strcmp(view.GetViewId(), 控件ID) == 0) + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/systemsupervise/src/SystemSuperviseView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/systemsupervise/src/SystemSuperviseView.cpp new file mode 100644 index 000000000..9a8db2117 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/systemsupervise/src/SystemSuperviseView.cpp @@ -0,0 +1,176 @@ +#include "systemsupervise/include/SystemSuperviseView.h" +#include "systemsupervise/include/SystemSupervisePresenter.h" + +namespace OHOS +{ + + static SystemSuperviseView *g_pSystemSuperviseView{nullptr}; + + SystemSuperviseView::SystemSuperviseView() + { + + g_pSystemSuperviseView = this; + } + + SystemSuperviseView::~SystemSuperviseView() + { + DeInitView(); + g_pSystemSuperviseView = nullptr; + } + + SystemSuperviseView *SystemSuperviseView::GetInstance() + { + + return g_pSystemSuperviseView; + } + UILabel *SystemSuperviseView::InitLabel(int left, int top, int width, int height, const char *text, const char *viewId, int fontSize, int fontlineHeigh, uint16_t speed) + { + UILabel *label = new UILabel(); + label->SetPosition(left, top); // 位置 + label->Resize(width, height); // 大小 + label->SetViewId(viewId); // id + label->SetStyle(STYLE_TEXT_FONT, fontSize); // 字体大小 + label->SetStyle(STYLE_LINE_HEIGHT, fontlineHeigh); // 字体行高 + label->SetText(text); // 内容 + label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(speed); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, fontSize); + + return label; + } + + void SystemSuperviseView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + UIView::OnDragListener *draglistener = static_cast(SystemSupervisePresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + container_->SetTouchable(true); + container_->SetDraggable(true); + } + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); // widget's left position and top position + scrollView1_->Resize(466, 466); // widget's width and height + scrollView1_->SetViewId("scrollView"); // Set style + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + scrollView1_->SetStyle(STYLE_BORDER_RADIUS, 1294); + + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + /***********************************************************************************************************/ + if (label1_ == nullptr) + { + label1_ = InitLabel(203, 52, 60, 35, "监管", "label1", 30, 35, 6); + } + scrollView1_->Add(label1_); + label1_->SetVisible(true); + /***********************************************************************************************************/ + if (label2_ == nullptr) + { + label2_ = InitLabel(203, 164, 60, 35, "型号", "label2", 30, 35, 6); + } + scrollView1_->Add(label2_); + label2_->SetVisible(true); + /***********************************************************************************************************/ + if (label3_ == nullptr) + { + label3_ = InitLabel(102, 221, 263, 30, "周冰鸿的 Smart Watch", "label3", 26, 30, 6); + } + label3_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + scrollView1_->Add(label3_); + label3_->SetVisible(true); + /***********************************************************************************************************/ + if (label4_ == nullptr) + { + label4_ = InitLabel(198, 310, 71, 35, "CMIT", "label4", 30, 35, 6); + } + scrollView1_->Add(label4_); + label4_->SetVisible(true); + /***********************************************************************************************************/ + if (label5_ == nullptr) + { + label5_ = InitLabel(175, 367, 119, 30, "V02.03.01", "label5", 26, 30, 6); + } + label5_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + scrollView1_->Add(label5_); + label5_->SetVisible(true); + } + + void SystemSuperviseView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (label3_ != nullptr) + { + delete label3_; + label3_ = nullptr; + } + if (label4_ != nullptr) + { + delete label4_; + label4_ = nullptr; + } + if (label5_ != nullptr) + { + delete label5_; + label5_ = nullptr; + } + } + + void SystemSuperviseView::OnStart() + { + InitView(); + RootView::GetInstance()->Add(container_); + } + + void SystemSuperviseView::OnSetUpView() + { + View::OnSetUpView(); + Draw(); + } + + void SystemSuperviseView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void SystemSuperviseView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/systemvolume/include/SystemVolumePresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/systemvolume/include/SystemVolumePresenter.h new file mode 100644 index 000000000..66e7e6318 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/systemvolume/include/SystemVolumePresenter.h @@ -0,0 +1,34 @@ +#ifndef SYSTEM_VOLUME_PRESENTER_H +#define SYSTEM_VOLUME_PRESENTER_H + +#include "Presenter.h" + +#include "SystemVolumeView.h" + +namespace OHOS +{ + class SystemVolumeView; + + class SystemVolumePresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + SystemVolumePresenter(); + virtual ~SystemVolumePresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static SystemVolumePresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/systemvolume/include/SystemVolumeView.h b/code/sdk/application/wearable/nativeapp/nativeui/systemvolume/include/SystemVolumeView.h new file mode 100644 index 000000000..c12f596c0 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/systemvolume/include/SystemVolumeView.h @@ -0,0 +1,40 @@ +#ifndef SYSTEM_VOLUME_VIEW_H +#define SYSTEM_VOLUME_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_slider.h" +#include "components/ui_image_view.h" +namespace OHOS +{ + static const char *SYSTEM_VOLUME_SLIDER = "SystemVolumeSlider"; + + class SystemVolumePresenter; + class SystemVolumeView : public View + { + + public: + SystemVolumeView(); + virtual ~SystemVolumeView(); + static SystemVolumeView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + UIView::OnDragListener *draglistener{nullptr}; + UIView::OnClickListener *sliderClick{nullptr}; + UIView::OnDragListener *sliderDrag{nullptr}; + void InitView(void); + + UIViewGroup *container_ = nullptr; + UISlider *SystemVolumeslider = nullptr; + UIImageView *SystemVolumeimageicon = nullptr; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/systemvolume/src/SystemVolumePresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/systemvolume/src/SystemVolumePresenter.cpp new file mode 100644 index 000000000..e06058d29 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/systemvolume/src/SystemVolumePresenter.cpp @@ -0,0 +1,79 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "systemvolume/include/SystemVolumePresenter.h" + +namespace OHOS{ + + //当前Presenter属性实例化的内存指针 + static SystemVolumePresenter *g_pSystemVolumePresenter = nullptr; + + SystemVolumePresenter::SystemVolumePresenter(){ + + g_pSystemVolumePresenter = this; + } + + SystemVolumePresenter::~SystemVolumePresenter(){ + + g_pSystemVolumePresenter = nullptr; + } + + SystemVolumePresenter *SystemVolumePresenter::GetInstance(){ + + return g_pSystemVolumePresenter; + } + + void SystemVolumePresenter::OnStart(){ + + Presenter::OnStart(); + } + + void SystemVolumePresenter::OnPause(void){ + + Presenter::OnPause(); + } + + void SystemVolumePresenter::OnResume(void){ + + Presenter::OnResume(); + } + + void SystemVolumePresenter::OnStop(void){ + + Presenter::OnStop(); + } + + bool SystemVolumePresenter::OnDrag(UIView &view, const DragEvent &event){ + + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 30) && (event.GetDeltaX() > (3 * MATH_ABS(event.GetDeltaY())))) + { + //NativeAbility::GetInstance().ChangeSlice(VIEW_SOUND_VIBRATION); + uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); + NativeAbility::GetInstance().ChangeSlice(preSlice); + } + // if(strcmp(view.GetViewId(), BRIGHTNESS_CONTROL_SLIDER)) + // { + + // } + return true; + } + + bool SystemVolumePresenter::OnClick(UIView &view, const ClickEvent &event){ + + // 根据控件id查找是哪个控件触发了点击回调 + // if (strcmp(view.GetViewId(), 控件ID) == 0) + // if(strcmp(view.GetViewId(), BRIGHTNESS_CONTROL_SLIDER)) + // { + + // } + return true; + } +} + + + + + + diff --git a/code/sdk/application/wearable/nativeapp/nativeui/systemvolume/src/SystemVolumeView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/systemvolume/src/SystemVolumeView.cpp new file mode 100644 index 000000000..bce0ce418 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/systemvolume/src/SystemVolumeView.cpp @@ -0,0 +1,118 @@ +#include "systemvolume/include/SystemVolumeView.h" +#include "systemvolume/include/SystemVolumePresenter.h" +#include "UiConfig.h" +namespace OHOS +{ + + static SystemVolumeView *g_pSystemVolumeView{nullptr}; + + SystemVolumeView::SystemVolumeView() + { + g_pSystemVolumeView = this; + } + + SystemVolumeView::~SystemVolumeView() + { + g_pSystemVolumeView = nullptr; + if (container_ != nullptr) + { + delete container_; + container_ = nullptr; + } + if (SystemVolumeslider != nullptr) + { + delete SystemVolumeslider; + SystemVolumeslider = nullptr; + } + if (SystemVolumeimageicon != nullptr) + { + delete SystemVolumeimageicon; + SystemVolumeimageicon = nullptr; + } + } + + SystemVolumeView *SystemVolumeView::GetInstance() + { + + return g_pSystemVolumeView; + } + void SystemVolumeView::InitView(void) + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + container_->SetStyle(STYLE_BACKGROUND_COLOR, 0x000000); + } + draglistener = static_cast(SystemVolumePresenter::GetInstance()); + container_->SetOnDragListener(draglistener); + container_->SetTouchable(true); + container_->SetDraggable(true); + /********************************************************************************************************/ + if (SystemVolumeslider == nullptr) + { + SystemVolumeslider = new UISlider(); + } + SystemVolumeslider->SetPosition(167, 77); + SystemVolumeslider->Resize(130, 310); + SystemVolumeslider->SetViewId(SYSTEM_VOLUME_SLIDER); + SystemVolumeslider->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + SystemVolumeslider->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + SystemVolumeslider->SetStyle(STYLE_BORDER_OPA, 0x19); + SystemVolumeslider->SetStyle(STYLE_BORDER_RADIUS, 100); + SystemVolumeslider->SetDirection(UISlider::Direction::DIR_BOTTOM_TO_TOP); + SystemVolumeslider->SetValue(20); + SystemVolumeslider->SetSliderColor(Color::GetColorFromRGBA(0x19, 0x19, 0x19, 0xff), Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff)); + SystemVolumeslider->SetKnobStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + SystemVolumeslider->SetForegroundStyle(STYLE_BACKGROUND_OPA, 0xff); + SystemVolumeslider->SetBackgroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND); // 圆帽式 + SystemVolumeslider->SetForegroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND); // 设置进度条的前景样式。圆帽式 + SystemVolumeslider->SetStyle(STYLE_BORDER_COLOR, 0xff000000); + sliderClick = static_cast(SystemVolumePresenter::GetInstance()); // 用来处理之后点击slider的点击事件 + SystemVolumeslider->SetOnClickListener(sliderClick); + sliderDrag = static_cast(SystemVolumePresenter::GetInstance()); // 用来处理之后拖动slider的拖动事件 + SystemVolumeslider->SetOnDragListener(sliderDrag); + container_->Add(SystemVolumeslider); + SystemVolumeslider->SetVisible(true); + /********************************************************************************************************/ + if (SystemVolumeimageicon == nullptr) + { + SystemVolumeimageicon = new UIImageView(); + } + SystemVolumeimageicon->SetPosition(213, 213); // widget's left position and top position + SystemVolumeimageicon->Resize(100, 100); // widget's width and height + SystemVolumeimageicon->SetViewId("SystemVolumeimageicon"); // Set style + SystemVolumeimageicon->SetStyle(STYLE_BORDER_COLOR, 0xffAAAAAA); + SystemVolumeimageicon->SetSrc(PNG_VOLUME_CONTROL_VECTOR); + + container_->Add(SystemVolumeimageicon); + SystemVolumeimageicon->SetVisible(true); + } + + void SystemVolumeView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void SystemVolumeView::OnSetUpView() + { + View::OnSetUpView(); + Draw(); + } + + void SystemVolumeView::OnTearDownView() + { + View::OnTearDownView(); + return; + } + + void SystemVolumeView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/drivers/boards/brandy_evb/product/product_evb4_standard.h b/code/sdk/drivers/boards/brandy_evb/product/product_evb4_standard.h index a186079fc..bc1bda19d 100644 --- a/code/sdk/drivers/boards/brandy_evb/product/product_evb4_standard.h +++ b/code/sdk/drivers/boards/brandy_evb/product/product_evb4_standard.h @@ -198,6 +198,7 @@ // LCD VCI_EN #define VCI_LCD_GPIO S_AGPIO_L24 +//#define VCI_LCD_GPIO S_AGPIO_L6 /** * @} */ diff --git a/code/sdk/drivers/drivers/driver/lcd/lcd_private.c b/code/sdk/drivers/drivers/driver/lcd/lcd_private.c index 349135a18..930d3462b 100644 --- a/code/sdk/drivers/drivers/driver/lcd/lcd_private.c +++ b/code/sdk/drivers/drivers/driver/lcd/lcd_private.c @@ -14,6 +14,7 @@ #include "product.h" #ifdef PRE_ASIC +//#define RESET_LCD_GPIO S_AGPIO_R3 #define RESET_LCD_GPIO S_AGPIO_L27 #else #define RESET_LCD_GPIO S_HGPIO0 diff --git a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_api.a b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_api.a index c2d6feade..fdafeec09 100644 Binary files a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_api.a and b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_api.a differ diff --git a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_core.a b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_core.a index 38c5054bd..e2a0637da 100644 Binary files a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_core.a and b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_core.a differ diff --git a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_drv.a b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_drv.a index 308100191..6b9ad796d 100644 Binary files a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_drv.a and b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_drv.a differ diff --git a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_sample.a b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_sample.a index 9759d1a7e..ce0f93d2d 100644 Binary files a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_sample.a and b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_sample.a differ diff --git a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_vendor.a b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_vendor.a index 215402ca4..0eab7d7ff 100644 Binary files a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_vendor.a and b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_vendor.a differ diff --git a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_brandy_sample.a b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_brandy_sample.a index 3bfddb70b..fce89853c 100644 Binary files a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_brandy_sample.a and b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_brandy_sample.a differ diff --git a/code/sdk/interim_binary/brandy/libs/gpu/evb_standard/libgpu.a b/code/sdk/interim_binary/brandy/libs/gpu/evb_standard/libgpu.a index 2092ad1b1..bda18c055 100644 Binary files a/code/sdk/interim_binary/brandy/libs/gpu/evb_standard/libgpu.a and b/code/sdk/interim_binary/brandy/libs/gpu/evb_standard/libgpu.a differ diff --git a/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_audio_captuer.a b/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_audio_captuer.a index c68afe3bb..aac6771bf 100644 Binary files a/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_audio_captuer.a and b/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_audio_captuer.a differ diff --git a/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_player.a b/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_player.a index d12453cbc..4d311e5f4 100644 Binary files a/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_player.a and b/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_player.a differ diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/service/src/graphic_service_wrapper.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/service/src/graphic_service_wrapper.cpp index 9f267feb3..3e1ae5f51 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/service/src/graphic_service_wrapper.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/service/src/graphic_service_wrapper.cpp @@ -40,7 +40,7 @@ static OHOS::ImageInfo* g_imgInfo = nullptr; #ifdef QSPI_DISPLAY #define IMAGE_OPEN_LOGO_PATH "/user/res/OPEN_LOGO_QSPI.bin" #else -#define IMAGE_OPEN_LOGO_PATH "/user/res/OPEN_LOGO.bin" +#define IMAGE_OPEN_LOGO_PATH "/user/res/KUMI_LOGO.bin" #endif static void UikitRTCCallBack(uintptr_t data) diff --git a/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/application.bin b/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/application.bin new file mode 100644 index 000000000..a29056c35 Binary files /dev/null and b/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/application.bin differ diff --git a/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/brandy_all_nv.bin b/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/brandy_all_nv.bin new file mode 100644 index 000000000..d8153937f Binary files /dev/null and b/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/brandy_all_nv.bin differ diff --git a/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/bt.bin b/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/bt.bin new file mode 100644 index 000000000..6abda3fa5 Binary files /dev/null and b/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/bt.bin differ diff --git a/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/dsp_main.bin b/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/dsp_main.bin new file mode 100644 index 000000000..c81668ff0 Binary files /dev/null and b/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/dsp_main.bin differ diff --git a/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/dsp_overlay.bin b/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/dsp_overlay.bin new file mode 100644 index 000000000..8885f6cbc Binary files /dev/null and b/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/dsp_overlay.bin differ diff --git a/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/partition_table.bin b/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/partition_table.bin new file mode 100644 index 000000000..e231dbaf8 Binary files /dev/null and b/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/partition_table.bin differ diff --git a/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/ssb.bin b/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/ssb.bin new file mode 100644 index 000000000..334ae0714 Binary files /dev/null and b/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/ssb.bin differ