602SDK patch 2024-4-3
authorSnickerSun <snickersun@163.com>
Sat, 6 Apr 2024 15:27:14 +0000 (23:27 +0800)
committerSnickerSun <snickersun@163.com>
Sat, 6 Apr 2024 15:27:14 +0000 (23:27 +0800)
163 files changed:
code/sdk/application/wearable/nativeabilityfwk/src/Ability.cpp
code/sdk/application/wearable/nativeabilityfwk/src/SliceTransition.cpp
code/sdk/application/wearable/nativeapp/CMakeLists.txt
code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h
code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h
code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h
code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp
code/sdk/application/wearable/nativeapp/nativeui/add_card/include/AddCardAdapter.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/add_card/include/AddCardItem.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/add_card/include/AddCardModel.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/add_card/include/AddCardPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/add_card/include/AddCardView.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/add_card/src/AddCardAdapter.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/add_card/src/AddCardItem.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/add_card/src/AddCardModel.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/add_card/src/AddCardPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/add_card/src/AddCardView.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/alipay/src/AlipayMainView.cpp
code/sdk/application/wearable/nativeapp/nativeui/applist/include/AppItemView.h
code/sdk/application/wearable/nativeapp/nativeui/applist/include/ApplistModel.h
code/sdk/application/wearable/nativeapp/nativeui/applist/include/ApplistPresenter.h
code/sdk/application/wearable/nativeapp/nativeui/applist/include/ApplistView.h
code/sdk/application/wearable/nativeapp/nativeui/applist/src/AppItemView.cpp
code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistModel.cpp
code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistPresenter.cpp
code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistView.cpp
code/sdk/application/wearable/nativeapp/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp
code/sdk/application/wearable/nativeapp/nativeui/bluetooth/include/BluetoothModel.h
code/sdk/application/wearable/nativeapp/nativeui/bluetooth/src/BluetoothHeadsetEvent.cpp
code/sdk/application/wearable/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp
code/sdk/application/wearable/nativeapp/nativeui/callerlog/include/CallerLogModel.h
code/sdk/application/wearable/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp
code/sdk/application/wearable/nativeapp/nativeui/heartrate/src/HeartModel.cpp
code/sdk/application/wearable/nativeapp/nativeui/indoorwalk/include/IndoorWalkMotionView.h
code/sdk/application/wearable/nativeapp/nativeui/indoorwalk/src/IndoorWalkMotionView.cpp
code/sdk/application/wearable/nativeapp/nativeui/key/include/KeyInputListener.h
code/sdk/application/wearable/nativeapp/nativeui/key/src/KeyInputListener.cpp
code/sdk/application/wearable/nativeapp/nativeui/main/include/DialBinParser.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/main/include/DialBinTypes.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/main/include/MainModel.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/main/include/MainPresenterSample.h
code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h
code/sdk/application/wearable/nativeapp/nativeui/main/include/VolumeSettingPresenter.h
code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialKaleidoscopeView.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/main/src/MainModel.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/main/src/MainPresenterSample.cpp
code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp
code/sdk/application/wearable/nativeapp/nativeui/main/src/VolumeSettingPresenter.cpp
code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/parser/DialBinParser.cpp
code/sdk/application/wearable/nativeapp/nativeui/phoneservice/src/PhoneService.cpp
code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersPresenter.cpp
code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h
code/sdk/application/wearable/nativeapp/nativeui/screensetting/src/ScreenModels.cpp
code/sdk/application/wearable/nativeapp/nativeui/set_card/include/SetCardAdapter.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_card/include/SetCardDeleteView.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_card/include/SetCardItem.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_card/include/SetCardModel.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_card/include/SetCardNoCardView.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_card/include/SetCardPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_card/include/SetCardView.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardAdapter.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardDeleteView.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardItem.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardModel.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardNoCardView.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardView.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_desktop/include/SetDesktopModel.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_desktop/include/SetDesktopPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_desktop/include/SetDesktopView.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_desktop/src/SetDesktopModel.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_desktop/src/SetDesktopPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_desktop/src/SetDesktopView.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_dial/include/SetDialInfo.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_dial/include/SetDialModel.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_dial/include/SetDialPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_dial/include/SetDialView.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_dial/src/SetDialModel.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_dial/src/SetDialPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_dial/src/SetDialView.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItem.h
code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItemView.h
code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingModel.h
code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingItemView.cpp
code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingModel.cpp
code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingPresenter.cpp
code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingView.cpp
code/sdk/application/wearable/nativeapp/nativeui/temperature/src/TempPresenter.cpp
code/sdk/application/wearable/nativeapp/nativeui/uisample/src/UISamplePresenter.cpp
code/sdk/application/wearable/nativeapp/nativeui/uisample/uitest/framework/src/ui_test_group.cpp
code/sdk/application/wearable/nativeapp/nativeui/uiservice/include/ui_service.h
code/sdk/application/wearable/nativeapp/nativeui/uiservice/src/ui_service.cpp
code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_ACTIVITY.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_ADD.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_COMPASS.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_DEL.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_HEART.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_PLAYER.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/DIAL_CLOCK.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/SETTTING_DESKTOP.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/SET_DESKTOP_BG.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/SET_DESKTOP_HEXAGONS.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/SET_DESKTOP_LIST.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/hexagons.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/kaleidoscope.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/planet.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/rabbit454.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/rainbow.bin [new file with mode: 0644]
code/sdk/build/config/target_config/common_config.py
code/sdk/middleware/services/gui/hal/common/include/graphic_hardware_config.h
code/sdk/middleware/services/gui/hal/display/brandy-native-js/libdisplay_gfx.a
code/sdk/middleware/services/gui/hal/display/brandy-target1/libdisplay_gfx.a
code/sdk/middleware/services/gui/hal/display/brandy-target3/libdisplay_gfx.a
code/sdk/middleware/services/gui/hal/display/brandy-target5/libdisplay_gfx.a
code/sdk/middleware/services/gui/hal/display/brandy-xts/libdisplay_gfx.a
code/sdk/middleware/services/gui/hal/display/src/display_gralloc.c
code/sdk/middleware/services/gui/uikit/CMakeLists.txt
code/sdk/middleware/services/gui/uikit/brandy-native-js/libuikit_ext.a
code/sdk/middleware/services/gui/uikit/brandy-target3/libuikit_ext.a
code/sdk/middleware/services/gui/uikit/brandy-xts/libuikit_ext.a
code/sdk/middleware/services/gui/uikit/proprietary/include/components/kaleidoscope_utils.h [new file with mode: 0644]
code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_barcode.h
code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_card_page.h
code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_coverflow_view.h [new file with mode: 0644]
code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_cross_view.h
code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_custom_hexagons_list.h [new file with mode: 0644]
code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_hexagons_list.h [new file with mode: 0644]
code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_kaleidoscope_view.h [new file with mode: 0644]
code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_map_view.h [new file with mode: 0644]
code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_menu_item.h
code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_custom_hexagons_list.cpp [new file with mode: 0644]
code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_list_ext.cpp
code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_lite_surface_view.cpp
code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components_ext/hor_swipe_view.h
code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components_ext/map_svg_parser.h [new file with mode: 0644]
code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components_ext/ui_card_container.h
code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/draw/clip_img.cpp
code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/draw/clip_img.h
code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/draw/hw_draw_utils.cpp
code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/draw/hw_draw_utils.h
code/sdk/middleware/services/gui/uikit/res/hexagons.bin [new file with mode: 0644]
code/sdk/middleware/services/gui/uikit/res/kaleidoscope_dial.bin [new file with mode: 0644]
code/sdk/middleware/services/gui/uikit/res/map.bin [new file with mode: 0644]
code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_coverflow/ui_test_coverflow.cpp [new file with mode: 0644]
code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_coverflow/ui_test_coverflow.h [new file with mode: 0644]
code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_cross/ui_test_cross.h
code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_cube_rotate/cube_rotate_view.cpp
code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_hexagons_list/ui_test_hexagons_list.cpp [new file with mode: 0644]
code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_hexagons_list/ui_test_hexagons_list.h [new file with mode: 0644]
code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_kaleidoscope/ui_test_kaleidoscope.cpp [new file with mode: 0644]
code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_kaleidoscope/ui_test_kaleidoscope.h [new file with mode: 0644]
code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_map/ui_test_map.cpp [new file with mode: 0644]
code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_map/ui_test_map.h [new file with mode: 0644]
code/sdk/middleware/services/gui/uikit/sample/uitest/framework/src/test_case_list_adapter.cpp
code/sdk/middleware/services/gui/uikit/sample/uitest/framework/src/ui_test_group.cpp
code/sdk/middleware/services/gui/uikit/ui/frameworks/components/root_view.cpp
code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_list.cpp
code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_view.cpp
code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_scroll_view.h
code/sdk/middleware/services/gui/uikit/ui/interfaces/kits/components/ui_view.h
code/sdk/middleware/services/gui/uikit/utils/frameworks/geometry2d.cpp
code/sdk/middleware/services/gui/uikit/utils/frameworks/graphic_math.cpp
code/sdk/middleware/services/gui/uikit/utils/interfaces/kits/gfx_utils/graphic_math.h

index 2da2024..20e64c6 100755 (executable)
@@ -20,7 +20,7 @@
 namespace OHOS {
 void Ability::AddSliceProxy(const uint16_t sliceId, SliceProxy* proxy)
 {
-    WEARABLE_LOGI(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "Ability::AddSliceProxy sliceId = %d", sliceId);
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "Ability::AddSliceProxy sliceId = %d", sliceId);
     if (sliceId <= gSliceInvalid || proxy == nullptr) {
         return;
     }
@@ -35,7 +35,7 @@ void Ability::AddSliceProxy(const uint16_t sliceId, SliceProxy* proxy)
 
 void Ability::StartSlice(const uint16_t sliceId, const uint16_t priority)
 {
-    WEARABLE_LOGI(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "Ability::StartSlice sliceId = %d", sliceId);
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "Ability::StartSlice sliceId = %d", sliceId);
     if (sliceId <= gSliceInvalid) {
         return;
     }
@@ -50,7 +50,7 @@ void Ability::StartSlice(const uint16_t sliceId, const uint16_t priority)
         return;
     }
 
-    WEARABLE_LOGI(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "Ability::StartSlice Size = %d", allSlices_.size());
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "Ability::StartSlice Size = %d", allSlices_.size());
     // 记录最多gMaxHistorySlices个页面id
     if (allSlices_.size() == gMaxHistorySlices) {
         allSlices_.erase(allSlices_.begin());
@@ -65,8 +65,9 @@ void Ability::StartSlice(const uint16_t sliceId, const uint16_t priority)
     nextSlice->OnResume();
 }
 
-void Ability::ReleaseCurSlice() {
-    WEARABLE_LOGI(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "Ability::ReleaseCurSlice");
+void Ability::ReleaseCurSlice()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "Ability::ReleaseCurSlice");
     if (curSlice_.slice != nullptr) {
         curSlice_.sliceId = gSliceInvalid;
         delete curSlice_.slice;
index ee2c348..540c39f 100755 (executable)
@@ -92,7 +92,7 @@ ImageInfo SliceTransition::RectifySnapshot(ImageInfo& srcInfo)
     if (Screen::GetInstance().GetScreenShape() == CIRCLE) {
         int16_t radius = Screen::GetInstance().GetWidth() / 2; // 2: half of width/height
         ImageInfo dstInfo = {{0}};
-        dstInfo = ClipImg::ClipImgByCircle(srcInfo, nullptr, { radius, radius }, radius, ARGB8888);
+        dstInfo = ClipImg::ClipImgByCircle(srcInfo, { radius, radius }, radius, ARGB8888, true);
         if (dstInfo.data == nullptr) {
             return srcInfo;
         } else {
index ad92a89..15f8c8f 100755 (executable)
@@ -29,6 +29,10 @@ set(PRIVATE_HEADER
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/temperature/include
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/offlinevoice/include
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/settings/include
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/set_desktop/include
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/set_card/include
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/add_card/include
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/set_dial/include
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/key/include
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/player/include
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/applist/include
@@ -52,7 +56,6 @@ set(PRIVATE_HEADER
     ${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/src/ui/innerkits
-    ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/include/components
 
     ${ROOT_DIR}/middleware/services/gui/uikit/ui/interfaces/kits/events
     ${ROOT_DIR}/middleware/services/gui/uikit/ui/interfaces/kits
@@ -82,6 +85,8 @@ set(PRIVATE_HEADER
     ${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}/open_source/openharmony/utils/native/lite/include
+    ${ROOT_DIR}/open_source/openharmony/utils/native/lite/kv_store/innerkits
 )
 
 set(SOURCES
@@ -89,6 +94,7 @@ set(SOURCES
     ${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/MainModel.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/MainPresenterSample.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/ModelListenerSample.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/PresenterTask.cpp
@@ -203,6 +209,24 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/settings/src/SettingView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/settings/src/SettingModel.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/settings/src/SettingItemView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/set_desktop/src/SetDesktopModel.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/set_desktop/src/SetDesktopPresenter.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/set_desktop/src/SetDesktopView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/set_card/src/SetCardAdapter.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/set_card/src/SetCardItem.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/set_card/src/SetCardModel.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/set_card/src/SetCardPresenter.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/set_card/src/SetCardView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/set_card/src/SetCardNoCardView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/set_card/src/SetCardDeleteView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/add_card/src/AddCardAdapter.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/add_card/src/AddCardItem.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/add_card/src/AddCardModel.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/add_card/src/AddCardPresenter.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/add_card/src/AddCardView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/set_dial/src/SetDialModel.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/set_dial/src/SetDialPresenter.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/set_dial/src/SetDialView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/key/src/KeyInputListener.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassControlView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassCalibrationView.cpp
@@ -241,6 +265,9 @@ set(SOURCES
     ${UI_SAMPLE_ROOT}/components/ui_test_cube_rotate/cube_rotate_view.cpp
     ${UI_SAMPLE_ROOT}/components/ui_test_cube_rotate/ui_test_cube_rotate.cpp
     ${UI_SAMPLE_ROOT}/components/ui_test_video_play/ui_test_video_play.cpp
+    ${UI_SAMPLE_ROOT}/components/ui_test_hexagons_list/ui_test_hexagons_list.cpp
+    ${UI_SAMPLE_ROOT}/components/ui_test_coverflow/ui_test_coverflow.cpp
+    ${UI_SAMPLE_ROOT}/components/ui_test_kaleidoscope/ui_test_kaleidoscope.cpp
 
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/dial/DialRotateImgView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/dial/DialOptionImgView.cpp
index 79e8581..1c77878 100755 (executable)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 2020-2021 CompanyNameMagicTag.
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -49,6 +48,10 @@ typedef enum : uint16_t {
 #ifdef SUPPORT_ALIPAY_SEC
     VIEW_MAIN_ALIPAY,
 #endif
+    VIEW_SET_DESKTOP,
+    VIEW_SET_CARD,
+    VIEW_ADD_CARD,
+    VIEW_SET_DIAL,
     VIEW_MAX_INTER_APP, // 在此之前添加native应用ID.
     VIEW_EXTERN_APP = 0xFFFE, // 三方应用
     VIEW_INVALIDE_APP = 0xFFFF,
index c34e4a9..cadd1ee 100755 (executable)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 2020-2021 CompanyNameMagicTag.
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,7 +16,6 @@
 #ifndef NATIVE_LAUNCHER_H
 #define NATIVE_LAUNCHER_H
 #include "AppViewIDs.h"
-#include "components/ui_label_ext.h"
 
 namespace OHOS {
 class NativeLauncher {
@@ -45,6 +43,10 @@ public:
     void InitRebootSlice(void);
     void InitUISampleSlice(void);
     void InitMainAlipaySlice(void);
+    void InitSetDesktopSlice(void);
+    void InitSetCardSlice(void);
+    void InitAddCardSlice(void);
+    void InitSetDialSlice(void);
 private:
     void InitAllNativeSlices(void);
 
index 153407a..7f19352 100755 (executable)
 #include "graphic_config.h"
 
 namespace OHOS {
+    static const int CARD_SETTING_COUNT_MAX = 5;
+    typedef enum {
+        WATCH_FACE = 0, /* 主表盘枚举值不能修改 */
+        HEART_RATE,
+        COMPASS,
+        ACTIVITY,
+        MUSIC_PLAYER,
+        MAX_CARD,
+    } CardId;
+
+    typedef enum {
+        DIAL_CLOCK = 0,
+        DIAL_MAX,
+    } DialId;
+
     #ifndef UNUSED
     #define UNUSED(x) ((void)(x))
     #endif
@@ -38,6 +53,7 @@ namespace OHOS {
     #define APP_RES_PATH "/user/res"
     #define APP_MUSIC_PATH "/user/music"
     #define APP_VIDEO_PATH "/user/video"
+    #define APP_DIAL_PATH "/user/dial"
 
     static constexpr const char *CARD_CONFIG_PATH = "/user/cardconfig.bin";
 
@@ -139,6 +155,10 @@ namespace OHOS {
     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_DESKTOP_IMAGE = APP_RES_PATH"/SETTTING_DESKTOP.bin";
+    static constexpr const char *PNG_SET_DESKTOP_LIST_IMAGE = APP_RES_PATH"/SET_DESKTOP_LIST.bin";
+    static constexpr const char *PNG_SET_DESKTOP_HEXAGONS_IMAGE = APP_RES_PATH"/SET_DESKTOP_HEXAGONS.bin";
+    static constexpr const char *PNG_SET_DESKTOP_BG_IMAGE = APP_RES_PATH"/SET_DESKTOP_BG.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";
@@ -300,7 +320,7 @@ namespace OHOS {
     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_ALIPAY_IMAGE = APP_RES_PATH"/alipay/alipay_logo.bin"; // 支付宝
+    static constexpr const char *PNG_APPLIST_ALIPAY_IMAGE = APP_RES_PATH"/alipay_logo.bin"; // 支付宝
     static constexpr const char *PNG_ALIPAY_BIND_FAILURE = APP_RES_PATH"/ALIPAY_BIND_FAILURE.bin";
     static constexpr const char *PNG_ALIPAY_BIND_SUCCESS = APP_RES_PATH"/ALIPAY_BIND_SUCCESS.bin";
     static constexpr const char *PNG_ALIPAY_LIST_PAY = APP_RES_PATH"/ALIPAY_LIST_PAY.bin";
@@ -328,6 +348,15 @@ namespace OHOS {
     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_SET_CARD_ADD = APP_RES_PATH"/CARD_ADD.bin";
+    static constexpr const char *PNG_SET_CARD_DEL = APP_RES_PATH"/CARD_DEL.bin";
+    static constexpr const char *PNG_SET_CARD_HEART = APP_RES_PATH"/CARD_HEART.bin";
+    static constexpr const char *PNG_SET_CARD_COMPASS = APP_RES_PATH"/CARD_COMPASS.bin";
+    static constexpr const char *PNG_SET_CARD_ACTIVITY = APP_RES_PATH"/CARD_ACTIVITY.bin";
+    static constexpr const char *PNG_SET_CARD_PLAYER = APP_RES_PATH"/CARD_PLAYER.bin";
+
+    static constexpr const char *PNG_SET_DIAL_CLOCK = APP_RES_PATH"/DIAL_CLOCK.bin";
 }
 
 #endif // UI_CONFIG_H
index 3637aee..0d578df 100755 (executable)
 #include "AlipayMainView.h"
 #include "AlipayPresenter.h"
 #endif
+#include "SetDesktopView.h"
+#include "SetDesktopPresenter.h"
+#include "SetCardView.h"
+#include "SetCardPresenter.h"
+#include "AddCardView.h"
+#include "AddCardPresenter.h"
+#include "SetDialView.h"
+#include "SetDialPresenter.h"
+#ifdef JS_ENABLE
+#include "product_adapter.h"
+#endif
 
 namespace OHOS {
 struct AppViewMapper
@@ -102,6 +113,10 @@ static const AppViewMapper SLICE_MAPPER[] = {
 #ifdef SUPPORT_ALIPAY_SEC
     {VIEW_MAIN_ALIPAY, &NativeLauncher::InitMainAlipaySlice},
 #endif
+    {VIEW_SET_DESKTOP, &NativeLauncher::InitSetDesktopSlice},
+    {VIEW_SET_CARD, &NativeLauncher::InitSetCardSlice},
+    {VIEW_ADD_CARD, &NativeLauncher::InitAddCardSlice},
+    {VIEW_SET_DIAL, &NativeLauncher::InitSetDialSlice},
 };
 
 static const ViewIdToString VIEW_MAPPER[] = {
@@ -126,6 +141,10 @@ static const ViewIdToString VIEW_MAPPER[] = {
 #ifdef SUPPORT_ALIPAY_SEC
     {VIEW_MAIN_ALIPAY, "mianAlipayView"},
 #endif
+    {VIEW_SET_DESKTOP, "SetDesktop"},
+    {VIEW_SET_CARD, "SetCard"},
+    {VIEW_ADD_CARD, "AddCard"},
+    {VIEW_SET_DIAL, "SetDial"},
 };
 
 NativeLauncher::NativeLauncher() {}
@@ -137,7 +156,11 @@ NativeLauncher &NativeLauncher::GetInstance(void)
     return instance;
 }
 
-void NativeLauncher::InitNativeLauncher() {
+void NativeLauncher::InitNativeLauncher()
+{
+#ifdef JS_ENABLE
+    ACELite::ProductAdapter::SetScreenSize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+#endif
     GraphicStartUp::InitFontEngine(MEM_POOL_UI_FONT, MEM_POOL_UI_FONT_SIZE, OHOS::VECTOR_FONT_DIR, DEFAULT_VECTOR_FONT_FILENAME);
     WEARABLE_LOGI(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "NativeLauncher::InitNativeLauncher");
     // 初始化所有预加载slice
@@ -146,7 +169,7 @@ void NativeLauncher::InitNativeLauncher() {
     CallerLogModel::GetInstance()->InitPhoneService();
     PlayersModel::GetInstance()->AudioInit();
     ActivityModel::GetInstance()->Init();
-    ScreenModels::GetInstance()->InitCardConfig();
+    ScreenModels::GetInstance()->InitKvStorage();
     VocassistModel::GetInstance()->Init();
     HeartModel::GetInstance()->Init();
     BluetoothModel::GetInstance()->Init();
@@ -375,4 +398,49 @@ void NativeLauncher::InitUISampleSlice(void)
     }
     NativeAbility::GetInstance().AddSliceProxy(VIEW_UISAMPLE, uisampleView);
 }
+
+void NativeLauncher::InitSetDesktopSlice(void)
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitSetDesktopSlice");
+    SliceProxy *setDesktopView = new AbilitySliceProxy<SetDesktopView, SetDesktopPresenter>;
+    if (setDesktopView == nullptr) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "setDesktopView");
+        return;
+    }
+    NativeAbility::GetInstance().AddSliceProxy(VIEW_SET_DESKTOP, setDesktopView);
+}
+
+void NativeLauncher::InitSetCardSlice(void)
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitSetCardSlice");
+    SliceProxy *setCardView = new AbilitySliceProxy<SetCardView, SetCardPresenter>;
+    if (setCardView == nullptr) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "setCardView");
+        return;
+    }
+    NativeAbility::GetInstance().AddSliceProxy(VIEW_SET_CARD, setCardView);
+}
+
+void NativeLauncher::InitAddCardSlice(void)
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitAddCardSlice");
+    SliceProxy *addCardView = new AbilitySliceProxy<AddCardView, AddCardPresenter>;
+    if (addCardView == nullptr) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "addCardView");
+        return;
+    }
+    NativeAbility::GetInstance().AddSliceProxy(VIEW_ADD_CARD, addCardView);
+}
+
+void NativeLauncher::InitSetDialSlice(void)
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitSetDialSlice");
+    SliceProxy *setDialView = new AbilitySliceProxy<SetDialView, SetDialPresenter>;
+    if (setDialView == nullptr) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "setCardView");
+        return;
+    }
+    NativeAbility::GetInstance().AddSliceProxy(VIEW_SET_DIAL, setDialView);
+}
+
 }
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/add_card/include/AddCardAdapter.h b/code/sdk/application/wearable/nativeapp/nativeui/add_card/include/AddCardAdapter.h
new file mode 100644 (file)
index 0000000..34882c9
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: AddCardAdapter.h
+ * Author:
+ * Create: 2021-09-18
+ */
+
+#ifndef ADD_CARD_ADAPTER_H
+#define ADD_CARD_ADAPTER_H
+
+#include <list>
+#include <string>
+#include "components/ui_list.h"
+#include "components/ui_label.h"
+#include "components/ui_view_group.h"
+#include "components/ui_image_view.h"
+#include "components/abstract_adapter.h"
+#include "UiConfig.h"
+#include "wearable_log.h"
+#include "AddCardItem.h"
+
+namespace OHOS {
+class AddCardAdapter : public AbstractAdapter {
+public:
+    explicit AddCardAdapter();
+    virtual ~AddCardAdapter();
+
+    virtual uint16 GetCount(void) override;
+
+    virtual UIView *GetView(UIView *inView, int16 index) override;
+
+    virtual void AddListItem(const AddCardInfo &item);
+
+    void SetItemClickListener(UIView::OnClickListener *itemClickListener)
+    {
+        itemClickListener_ = itemClickListener;
+    }
+
+    void ClearItem(void);
+
+private:
+    std::list<AddCardInfo> listData_;
+    UIView::OnClickListener *itemClickListener_;
+};
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/add_card/include/AddCardItem.h b/code/sdk/application/wearable/nativeapp/nativeui/add_card/include/AddCardItem.h
new file mode 100644 (file)
index 0000000..5ce44d5
--- /dev/null
@@ -0,0 +1,42 @@
+/*\r
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.\r
+ * Description: AddCardItem.h\r
+ * Author:\r
+ * Create: 2021-11-23\r
+ */\r
+\r
+#ifndef ADD_CARD_ITEM_H\r
+#define ADD_CARD_ITEM_H\r
+\r
+#include <cstdint>\r
+#include <map>\r
+#include "components/ui_view.h"\r
+#include "components/ui_view_group.h"\r
+#include "components/ui_image_view.h"\r
+#include "components/ui_label_button.h"\r
+#include "UiConfig.h"\r
+\r
+namespace OHOS {\r
+typedef struct {\r
+    CardId id;\r
+    bool addFlag;\r
+    const char *cardImg;\r
+} AddCardInfo;\r
+\r
+class AddCardItem :public UIViewGroup {\r
+public:\r
+    AddCardItem();\r
+    virtual ~AddCardItem();\r
+    void SetItemInfo(const AddCardInfo &cardInfo);\r
+    void SetOnClickListener(OnClickListener *onClickListener);\r
+    void UpdateItemInfo(bool addFlag);\r
+private:\r
+    void SetUpChild();\r
+    UIImageView cardImg_;\r
+    UILabelButton cardLabel_;\r
+    AddCardInfo cardInfo_;\r
+};\r
+\r
+}\r
+\r
+#endif // ADD_CARD_ITEM_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/add_card/include/AddCardModel.h b/code/sdk/application/wearable/nativeapp/nativeui/add_card/include/AddCardModel.h
new file mode 100644 (file)
index 0000000..ae17e1a
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: AddCardModel.h
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#ifndef ADD_CARD_MODEL_H
+#define ADD_CARD_MODEL_H
+
+#include <cstdint>
+#include <map>
+#include "AppViewIDs.h"
+#include "UiConfig.h"
+#include "AddCardPresenter.h"
+#include "MainModel.h"
+
+namespace OHOS {
+    class AddCardModel {
+    public:
+        static AddCardModel &GetInstance(void);
+        void SetSelectedCardIndex(uint8_t cardIndex);
+        uint8_t GetSelectedCardIndex(void) const;
+        void AddCardSetting(void);
+    private:
+        AddCardModel();
+        AddCardModel(const AddCardModel &);
+        AddCardModel &operator=(const AddCardModel &);
+        virtual ~AddCardModel();
+        uint8_t selectedCardIndex{0};
+
+    };
+}
+
+#endif // ADD_CARD_MODEL_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/add_card/include/AddCardPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/add_card/include/AddCardPresenter.h
new file mode 100644 (file)
index 0000000..f8e6f88
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: AddCardPresenter.h
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#ifndef ADD_CARD_PRESENTER_H
+#define ADD_CARD_PRESENTER_H
+
+#include "Presenter.h"
+#include "components/ui_list.h"
+#include "components/ui_view.h"
+#include "KeyInputListener.h"
+
+namespace OHOS {
+static const char *ADD_CARD_ADD = "addcardadd";
+class AddCardView;
+class AddCardModel;
+class AddCardPresenter : public Presenter<AddCardView>,
+                         public UIView::OnClickListener, public UIView::OnDragListener,
+                         public ListScrollListener  {
+public:
+    AddCardPresenter();
+    virtual ~AddCardPresenter();
+
+    virtual void OnStart() override;
+    virtual void OnResume() override;
+    virtual void OnStop() override;
+
+    bool OnClick(UIView &view, const ClickEvent &event) override;
+    virtual void OnScrollStart(int16_t index, UIView *view) override;
+    virtual void OnScrollEnd(int16_t index, UIView *view) override;
+    virtual void OnItemSelected(int16_t index, UIView* view) override;
+    virtual bool OnDrag(UIView& view, const DragEvent& event) override;
+private:
+    KeyInputListener *keyActListenr{nullptr};
+    AddCardModel *model{nullptr};
+
+};
+}
+
+#endif // ADD_CARD_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/add_card/include/AddCardView.h b/code/sdk/application/wearable/nativeapp/nativeui/add_card/include/AddCardView.h
new file mode 100644 (file)
index 0000000..63d51bb
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: AddCardView.h
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#ifndef ADD_CARD_VIEW_H
+#define ADD_CARD_VIEW_H
+
+#include "View.h"
+#include "components/ui_view_group.h"
+#include "components/ui_label.h"
+#include "components/ui_image_view.h"
+#include "components/ui_toggle_button.h"
+#include "window/window.h"
+#include "BaseView.h"
+#include "ChangeSliceListener.h"
+#include "UiConfig.h"
+#include "AddCardAdapter.h"
+#include "AddCardModel.h"
+
+namespace OHOS {
+class AddCardPresenter;
+
+class AddCardView : public View<AddCardPresenter> {
+public:
+    AddCardView();
+    virtual ~AddCardView();
+
+    static AddCardView *GetInstance()
+    {
+        static AddCardView instance;
+        return &instance;
+    }
+
+    virtual void OnStart() override;
+    virtual void OnSetUpView() override;
+    virtual void OnTearDownView() override;
+    virtual void OnStop() override;
+    void RefreshCardList(void);
+private:
+    void SetUpListInfo(void);
+    void SetUpListView(void);
+    UIList contentList_;
+    AddCardAdapter *addCardAdapter_{nullptr};
+};
+}
+#endif // ADD_CARD_VIEW_H
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/add_card/src/AddCardAdapter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/add_card/src/AddCardAdapter.cpp
new file mode 100644 (file)
index 0000000..d92f38d
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: AddCardAdapter.cpp
+ * Author:
+ * Create: 2021-09-18
+ */
+
+#include "AddCardAdapter.h"
+
+namespace OHOS {
+AddCardAdapter::AddCardAdapter() {}
+
+AddCardAdapter::~AddCardAdapter()
+{
+    listData_.clear();
+}
+
+uint16 AddCardAdapter::GetCount(void)
+{
+    return listData_.size();
+}
+
+void AddCardAdapter::ClearItem(void)
+{
+    listData_.clear();
+}
+
+UIView *AddCardAdapter::GetView(UIView *inView, int16 index)
+{
+    if (index >= (int16)listData_.size() || index < 0) {
+        return nullptr;
+    }
+
+    std::list<AddCardInfo>::iterator it = listData_.begin();
+    for (int i = 0; i < index; i++) {
+        it++;
+    }
+
+    AddCardItem *item = nullptr;
+    if (inView == nullptr) {
+        item = new AddCardItem();
+        if (item == nullptr) {
+            return nullptr;
+        }
+    } else {
+        item = static_cast<AddCardItem *>(inView);
+    }
+
+    item->SetItemInfo(*it);
+    item->SetViewIndex(index);
+    item->SetOnClickListener(itemClickListener_);
+    return item;
+}
+
+void AddCardAdapter::AddListItem(const AddCardInfo &item)
+{
+    listData_.push_back(item);
+}
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/add_card/src/AddCardItem.cpp b/code/sdk/application/wearable/nativeapp/nativeui/add_card/src/AddCardItem.cpp
new file mode 100644 (file)
index 0000000..67e287e
--- /dev/null
@@ -0,0 +1,58 @@
+#include "AddCardItem.h"\r
+#include "AddCardPresenter.h"\r
+#include "wearable_log.h"\r
+\r
+namespace OHOS {\r
+    AddCardItem::AddCardItem()\r
+    {\r
+        SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);\r
+        SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);\r
+        SetUpChild();\r
+        Add(&cardImg_);\r
+        Add(&cardLabel_);\r
+    }\r
+\r
+    AddCardItem::~AddCardItem()\r
+    {\r
+        Remove(&cardImg_);\r
+        Remove(&cardLabel_);\r
+    }\r
+\r
+    void AddCardItem::SetUpChild()\r
+    {\r
+        cardImg_.SetPosition(87, 60);\r
+        cardImg_.Resize(280, 280);\r
+        cardImg_.SetResizeMode(UIImageView::FILL);\r
+        cardImg_.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);\r
+\r
+        cardLabel_.SetPosition(175, 360);\r
+        cardLabel_.Resize(100, 50);\r
+        cardLabel_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);\r
+    }\r
+\r
+    void AddCardItem::SetItemInfo(const AddCardInfo &cardInfo)\r
+    {\r
+        cardInfo_ = cardInfo;\r
+        cardImg_.SetSrc(cardInfo.cardImg);\r
+        if (cardInfo.addFlag) {\r
+            cardLabel_.SetText("已添加");\r
+        } else {\r
+            cardLabel_.SetText("添加");\r
+        }\r
+    }\r
+\r
+    void AddCardItem::UpdateItemInfo(bool addFlag)\r
+    {\r
+        if (addFlag) {\r
+            cardLabel_.SetText("已添加");\r
+            cardInfo_.addFlag = addFlag;\r
+            Invalidate();\r
+        }\r
+    }\r
+\r
+    void AddCardItem::SetOnClickListener(OnClickListener *onClickListener)\r
+    {\r
+        cardLabel_.SetOnClickListener(onClickListener);\r
+    }\r
+\r
+};\r
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/add_card/src/AddCardModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/add_card/src/AddCardModel.cpp
new file mode 100644 (file)
index 0000000..fa052de
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: AddCardModel.cpp
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#include "AddCardModel.h"
+#include "kv_store.h"
+#include "securec.h"
+
+namespace OHOS {
+    AddCardModel::AddCardModel() {}
+
+    AddCardModel::~AddCardModel() {}
+
+    AddCardModel &AddCardModel::GetInstance()
+    {
+        static AddCardModel instance;
+        return instance;
+    }
+
+    void AddCardModel::SetSelectedCardIndex(uint8_t cardIndex)
+    {
+        selectedCardIndex = cardIndex;
+    }
+
+    uint8_t AddCardModel::GetSelectedCardIndex(void) const
+    {
+        return selectedCardIndex;
+    }
+
+    void AddCardModel::AddCardSetting(void)
+    {
+        MainModel::GetInstance().AddCardSetting(selectedCardIndex);
+    }
+}
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/add_card/src/AddCardPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/add_card/src/AddCardPresenter.cpp
new file mode 100644 (file)
index 0000000..73044d5
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: AddCardPresenter.cpp
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#include "AddCardView.h"
+#include "AddCardModel.h"
+#include "AddCardPresenter.h"
+
+namespace OHOS {
+    AddCardPresenter::AddCardPresenter()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardPresenter::AddCardPresenter");
+        model = &AddCardModel::GetInstance();
+    }
+
+    AddCardPresenter::~AddCardPresenter() {
+    }
+
+    void AddCardPresenter::OnStart()
+    {
+        Presenter<AddCardView>::OnStart();
+    }
+
+    void AddCardPresenter::OnResume(void)
+    {
+    }
+
+    void AddCardPresenter::OnStop(void)
+    {
+    }
+
+    bool AddCardPresenter::OnDrag(UIView& view, const DragEvent& event)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardPresenter::OnDrag");
+        UNUSED(view);
+        if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) &&
+            (event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardPresenter::OnDrag ChangeSlice");
+            NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE);
+        }
+        return false;
+    }
+
+    bool AddCardPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardPresenter::OnClick");
+        model->AddCardSetting();
+        view_->RefreshCardList();
+               return true;
+    }
+
+    void AddCardPresenter::OnScrollStart(int16_t index, UIView *view)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardPresenter::OnScrollStart index = %d", index);
+        return;
+    }
+
+    void AddCardPresenter::OnScrollEnd(int16_t index, UIView *view)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardPresenter::OnScrollEnd index = %d", index);
+        if (view == nullptr) {
+            return;
+        }
+        model->SetSelectedCardIndex(index);
+    }
+
+    void AddCardPresenter::OnItemSelected(int16_t index, UIView* view) 
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardPresenter::OnItemSelected index = %d", index);
+        if (view == nullptr) {
+            return;
+        }    
+    }
+
+}
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/add_card/src/AddCardView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/add_card/src/AddCardView.cpp
new file mode 100644 (file)
index 0000000..a696032
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: AddCardView.cpp
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#include <string>
+#include "AddCardView.h"
+#include "AddCardPresenter.h"
+
+namespace OHOS {
+AddCardView::AddCardView()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardView::AddCardView");
+}
+
+AddCardView::~AddCardView()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardView::~AddCardView");
+    if (addCardAdapter_ != nullptr) {
+        delete addCardAdapter_;
+        addCardAdapter_ = nullptr;
+    }
+}
+
+void AddCardView::OnStart()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardView::OnStart");
+    View<AddCardPresenter>::OnStart();
+    SetContainerView(new UIViewGroup());
+    container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+    addCardAdapter_ = new AddCardAdapter();
+    addCardAdapter_->SetItemClickListener(presenter_);
+    SetUpListInfo();
+    SetUpListView();
+}
+
+void AddCardView::OnSetUpView()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardView::OnSetUpView");
+    View<AddCardPresenter>::OnSetUpView();
+}
+
+void AddCardView::OnTearDownView()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardView::OnTearDownView");
+    View<AddCardPresenter>::OnTearDownView();
+}
+
+void AddCardView::OnStop()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardView::OnStop");
+    View<AddCardPresenter>::OnStop();
+    if (container_ != nullptr) {
+        container_->RemoveAll();
+        delete container_;
+        container_ = nullptr;
+    }
+}
+
+void AddCardView::SetUpListInfo(void)
+{
+    MainModel::GetInstance().InitCardSettings();
+    uint8_t cardCount = MainModel::GetInstance().GetCardSettingCount();
+    CardId *cardSettings = MainModel::GetInstance().GetCardSettings();
+    addCardAdapter_->ClearItem();
+    for (uint8_t i = WATCH_FACE + 1; i < MAX_CARD; i++) {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "All:cardId = %d", i);
+        const CardInfo *info = MainModel::GetInstance().GetCardInfo((CardId)i);
+        if (info != nullptr) {
+            AddCardInfo addInfo;
+            addInfo.id = info->id;
+            addInfo.cardImg = info->cardImg;
+            addInfo.addFlag = false;
+            for (uint8_t j = 0; j < cardCount; j++) {
+                WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Settings:cardId = %d", cardSettings[j]);
+                if (cardSettings[j] == i) {
+                    addInfo.addFlag = true;
+                    break;
+                }
+            }
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetUpListInfo::%d %s %d",
+                          addInfo.id, addInfo.cardImg, addInfo.addFlag);
+            addCardAdapter_->AddListItem(addInfo);
+        }
+    }
+}
+
+void AddCardView::SetUpListView(void)
+{
+    contentList_.SetPosition(0, 0);
+    contentList_.Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+    contentList_.SetScrollBlankSize(VERTICAL_RESOLUTION / 2);
+    contentList_.SetSelectPosition(VERTICAL_RESOLUTION / 2);
+    contentList_.SetDraggable(true);
+    contentList_.SetThrowDrag(true);
+    contentList_.EnableAutoAlign(true);
+    contentList_.SetScrollStateListener(presenter_);
+    contentList_.SetOnDragListener(presenter_);
+    contentList_.SetMaxScrollDistance(1000);
+    contentList_.SetAdapter(addCardAdapter_);
+    contentList_.SetVisible(true);
+    container_->Add(&contentList_);
+}
+
+void AddCardView::RefreshCardList(void)
+{
+    SetUpListInfo();
+    contentList_.RefreshList();
+}
+
+}
index 10bad7d..9aca06a 100644 (file)
@@ -753,6 +753,7 @@ static const int16 DestroyMapper[] = {
     ALIPAY_GET_TRANS_LIST_VIEW,\r
     ALIPAY_TRANS_VIEW,\r
     ALIPAY_TRANS_LIST_VIEW,\r
+    ALIPAY_SETTING_VIEW,\r
 };\r
 \r
 void AlipayMainView::DestroyTempView(int16 hideView)\r
@@ -780,6 +781,9 @@ void AlipayMainView::DestroyTempView(int16 hideView)
     } else if (hideView == ALIPAY_TRANS_LIST_VIEW) {\r
         delete alipayTransList;\r
         alipayTransList = nullptr;\r
+    } else if (hideView == ALIPAY_SETTING_VIEW) {\r
+        delete alipaySetting;\r
+        alipaySetting = nullptr;\r
     }\r
 }\r
 \r
index ffb9c80..b6f9568 100755 (executable)
@@ -33,6 +33,20 @@ private:
     UILabel label_;
     AppItem itemInfo_ = { VIEW_INVALID, nullptr, nullptr, nullptr, nullptr };
 };
+
+class HexagonsItemView : public UIImageView {
+public:
+    explicit HexagonsItemView();
+    virtual ~HexagonsItemView();
+    void SetItemInfo(const AppItem &itemInfo);
+    AppViewId GetViewId();
+    const char *GetAppUid();
+private:
+    HexagonsItemView(const HexagonsItemView &);
+    HexagonsItemView &operator = (const HexagonsItemView &);
+    AppItem itemInfo_ = { VIEW_INVALID, nullptr, nullptr, nullptr, nullptr };
+};
+
 }
 
 #endif
index c0a5d91..1350710 100755 (executable)
@@ -10,7 +10,6 @@
 
 #include "bundle_info.h"
 #include "AppViewIDs.h"
-#include "components/ui_label_ext.h"
 #include "ohos_types.h"
 
 #define APP_MAX_NUM 50
@@ -29,7 +28,7 @@ class ApplistModel {
 public:
     static ApplistModel &GetInstance(void);
 
-    void initApplist();
+    void Init();
     const AppItem *GetApplistItems() const;
     uint8 GetAppListNum() const;
     void ResolvingJSAppItems(void);
@@ -39,7 +38,7 @@ public:
     int GetHeadItemY(void);
     void ApplistUpdate(void);
     void SetPresenter(ApplistPresenter *p);
-
+    bool GetIsUseListStyle(void);
 private:
     ApplistModel();
     ApplistModel(const ApplistModel &);
@@ -54,6 +53,7 @@ private:
 
     uint16_t startIndex = 0;
     int headItemY = 0;
+    bool initFlag{false};
 };
 }
 
index fd60401..c0d53a2 100755 (executable)
@@ -17,7 +17,8 @@
 #include "KeyInputListener.h"
 
 namespace OHOS {
-    class ApplistPresenter : public Presenter<ApplistView>, public UIView::OnClickListener {
+    class ApplistPresenter : public Presenter<ApplistView>, public UIView::OnClickListener,
+                             public ListScrollListener {
     public:
         ApplistPresenter();
         virtual ~ApplistPresenter();
@@ -28,14 +29,18 @@ namespace OHOS {
         virtual void OnStop() override;
 
         bool OnClick(UIView &view, const ClickEvent &event) override;
+        void OnItemSelected(int16 index, UIView *view) override;
         void SetStartIndex(uint16_t index);
         uint16_t GetStartIndex(void);
         void SetHeadItemY(int y);
         int GetHeadItemY(void);
         uint8_t GetListItemNum(void);
         ApplistView* GetAppListView();
+        bool GetIsUseListStyle(void);
 
     private:
+        AppItemView *itemViewSele{nullptr};
+        AppItemView *preItemViewSele{nullptr};
         ApplistModel *model{nullptr};
         KeyInputListener *keyActListenr{nullptr};
     };
index 88be5fe..6689efb 100755 (executable)
@@ -14,6 +14,7 @@
 #include "components/ui_scroll_view.h"
 #include "components/ui_label.h"
 #include "components/ui_list.h"
+#include "components/ui_custom_hexagons_list.h"
 #include "window/window.h"
 #include "ohos_types.h"
 #include "BaseView.h"
@@ -66,7 +67,7 @@ private:
 };
 
 class ApplistPresenter;
-class ApplistView : public View<ApplistPresenter>, public ListScrollListener {
+class ApplistView : public View<ApplistPresenter> {
 public:
     ApplistView();
     virtual ~ApplistView();
@@ -78,15 +79,28 @@ public:
 
     void AddAppItemToList(const AppItem &item);
     void ClearAppItemToList();
-    void OnItemSelected(int16 index, UIView *view) override;
-    UIList* GetAppUIList(void);
-
+    void RefreshAppList(void);
 private:
+    void HexagonsStyleOnStart();
+    void ListStyleOnStart();
+    void HexagonsStyleOnSetUpView();
+    void ListStyleOnSetUpView();
+    void HexagonsStyleOnStop();
+    void ListStyleOnStop();
+
+    /* for list style */
     ApplistAdapter *listAdapter_{nullptr};
     UIList *contentList_{nullptr};
     UIView::OnDragListener *dragListener{nullptr};
-    AppItemView *itemViewSele{nullptr};
-    AppItemView *preItemViewSele{nullptr};
+
+    /* for hexagons style */
+    UICustomHexagonsList* hexagonsList_{nullptr};
+    std::list<HexagonsItemView*> listHexagonsView_;
+    int16_t horMargin_ = 0;
+    int16_t verMargin_ = 0;
+    uint16_t imgSize_ = 0;
+    uint16_t imgDistance_ = 0;
+
 };
 }
 #endif // APPLIST_VIEW_H
\ No newline at end of file
index 87ed2e4..cd35ebb 100755 (executable)
@@ -82,4 +82,25 @@ namespace OHOS {
         icon_.ResetTransParameter();
     }
 
+    HexagonsItemView::HexagonsItemView()
+    {
+    }
+
+    HexagonsItemView::~HexagonsItemView()
+    {
+    }
+    void HexagonsItemView::SetItemInfo(const AppItem &itemInfo)
+    {
+        itemInfo_ = itemInfo;
+    }
+
+    AppViewId HexagonsItemView::GetViewId()
+    {
+        return itemInfo_.id;
+    }
+
+    const char *HexagonsItemView::GetAppUid()
+    {
+        return itemInfo_.uid;
+    }
 }
index d085822..f6a21be 100755 (executable)
@@ -16,6 +16,7 @@
 #include "UiConfig.h"
 #include "ApplistModel.h"
 #include "ApplistPresenter.h"
+#include "SetDesktopModel.h"
 
 namespace OHOS {
     const AppItem g_nativeAppList[] = {
@@ -50,9 +51,13 @@ namespace OHOS {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistModel::~ApplistModel()");
     }
 
-    void ApplistModel::initApplist()
+
+    void ApplistModel::Init()
     {
-        ResolvingJSAppItems();
+        if (!initFlag) {
+            ResolvingJSAppItems();
+            initFlag = true;
+        }
     }
 
     void ApplistModel::ResolvingJSAppItems(void)
@@ -107,6 +112,8 @@ namespace OHOS {
                 appLen++;
                 bundleInfos[len].abilityInfo = nullptr;
             }
+        } else {
+            WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "ResolvingJSAppItems GetBundleInfos ret = %d \r", ret);
         }
 #endif
     }
@@ -149,7 +156,7 @@ namespace OHOS {
             for (uint8 i = 0; i < GetAppListNum(); i++) {
                 presenter->GetAppListView()->AddAppItemToList(itemInfo[i]);
             }
-            presenter->GetAppListView()->GetAppUIList()->RefreshList();
+            presenter->GetAppListView()->RefreshAppList();
         }
     }
 
@@ -157,4 +164,9 @@ namespace OHOS {
     {
         presenter = p;
     }
+
+    bool ApplistModel::GetIsUseListStyle(void)
+    {
+        return (SetDesktopModel::GetInstance().GetDesktopStyle() == APPLIST_STYLE);
+    }
 }
index 6676313..49e02f8 100755 (executable)
@@ -7,7 +7,6 @@
 
 #include "ApplistPresenter.h"
 #include "ability_manager.h"
-
 #include "securec.h"
 
 namespace OHOS {
@@ -15,6 +14,7 @@ namespace OHOS {
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::ApplistPresenter()");
         model = &ApplistModel::GetInstance();
+        model->Init();
         model->SetPresenter(this);
     }
 
@@ -30,8 +30,6 @@ namespace OHOS {
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnStart()");
         Presenter<ApplistView>::OnStart();
-        model->initApplist();
-
         if (keyActListenr == nullptr) {
             keyActListenr = new KeyInputListener();
             if (keyActListenr != nullptr) {
@@ -53,6 +51,7 @@ namespace OHOS {
         for (uint8 i = 0; i < model->GetAppListNum(); i++) {
             view_->AddAppItemToList(itemInfo[i]);
         }
+        view_->RefreshAppList();
     }
 
     void ApplistPresenter::OnPause()
@@ -63,28 +62,35 @@ namespace OHOS {
     void ApplistPresenter::OnStop(void)
     {
         Presenter<ApplistView>::OnStop();
-        RootView::GetInstance()->ClearOnKeyActListener();
     }
 
     bool ApplistPresenter::OnClick(UIView &view, const ClickEvent &event)
     {
         UNUSED(event);
-        AppItemView *itemView = static_cast<AppItemView *>(&view);
-        AppViewId viewId = itemView->GetViewId();
-
+        AppViewId viewId = VIEW_INVALID;
+        char *uid =  nullptr;
+        if (GetIsUseListStyle() == true) {
+            AppItemView *itemView = static_cast<AppItemView *>(&view);
+            viewId = itemView->GetViewId();
+            uid = (char *)itemView->GetAppUid();
+        } else {
+            HexagonsItemView *itemView = static_cast<HexagonsItemView *>(&view);
+            viewId = itemView->GetViewId();
+            uid = (char *)itemView->GetAppUid();
+        }
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick viewid = %d", viewId);
         if (viewId < VIEW_MAX_INTER_APP) {
             NativeAbility::GetInstance().ChangeSlice(viewId);
             return true;
         } else if (viewId == VIEW_EXTERN_APP) {
 #ifdef JS_ENABLE
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick bundleName = %s", itemView->GetAppUid());
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick bundleName = %s", uid);
             Want *want = new Want();
             memset_s(want, sizeof(Want), 0, sizeof(Want));
 
             ElementName startElement = {};
             startElement.abilityName = (char *)"default";
-            startElement.bundleName = (char *)itemView->GetAppUid();
+            startElement.bundleName = uid;
             startElement.deviceId = nullptr;
             SetWantElement(want, startElement);
 
@@ -95,7 +101,19 @@ namespace OHOS {
         }
         return false;
     }
+    void ApplistPresenter::OnItemSelected(int16 index, UIView *view)
+    {
+        UNUSED(index);
+        if (view != nullptr) {
+            itemViewSele = static_cast<AppItemView *>(view);
+            itemViewSele->SelectedChange();
 
+            if (preItemViewSele != nullptr && preItemViewSele != itemViewSele) {
+                preItemViewSele->Reset();
+            }
+            preItemViewSele = itemViewSele;
+        }
+    }
     void ApplistPresenter::SetStartIndex(uint16_t index)
     {
         model->SetStartIndex(index);
@@ -123,6 +141,11 @@ namespace OHOS {
         return model->GetAppListNum();
     }
 
+    bool ApplistPresenter::GetIsUseListStyle(void)
+    {
+        return model->GetIsUseListStyle();
+    }
+
     ApplistView* ApplistPresenter::GetAppListView()
     {
         return view_;
index c0f0cf6..07b7ef0 100755 (executable)
@@ -22,19 +22,60 @@ ApplistView::ApplistView()
 ApplistView::~ApplistView()
 {
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::~ApplistView ");
-    delete listAdapter_;
-    listAdapter_ = nullptr;
-    delete contentList_;
-    contentList_ = nullptr;
-    delete dragListener;
-    dragListener = nullptr;
+    if (listAdapter_ != nullptr) {
+        delete listAdapter_;
+        listAdapter_ = nullptr;
+    }
+    if (contentList_ != nullptr) {
+        delete contentList_;
+        contentList_ = nullptr;
+    }
+    if (dragListener != nullptr) {
+        delete dragListener;
+        dragListener = nullptr;
+    }  
+    if (hexagonsList_ != nullptr) {
+        delete hexagonsList_;
+        hexagonsList_ = nullptr;
+    }
 }
 
 void ApplistView::OnStart()
 {
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::OnStart ");
     View<ApplistPresenter>::OnStart();
+    SetContainerView(new UIViewGroup());
+    container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+    if (presenter_->GetIsUseListStyle() == true) {
+        ListStyleOnStart();
+    } else {
+        HexagonsStyleOnStart();
+    }
+}
 
+void ApplistView::HexagonsStyleOnStart()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::HexagonsStyleOnStart ");
+    if (hexagonsList_ == nullptr) {
+        hexagonsList_ = new UICustomHexagonsList();
+    }
+    container_->Add(hexagonsList_);
+    hexagonsList_->SetPosition(0, 0,
+        container_->GetWidth() - 2 * (horMargin_ + 1), container_->GetHeight() - 2 * (verMargin_ + 1)); // 2, two
+    imgDistance_ = container_->GetWidth() * 0.25991; // 0.25991, empirical coefficient
+    imgSize_ = container_->GetWidth() * 0.23348; // 0.23348, empirical coefficient
+    hexagonsList_->SetImageDistance(imgDistance_);
+    hexagonsList_->SetImageSizeInCenter(imgSize_);
+    int16_t blankSize = hexagonsList_->GetRelativeRect().GetWidth() > hexagonsList_->GetRelativeRect().GetHeight() ?
+        hexagonsList_->GetRelativeRect().GetWidth() / 2 : hexagonsList_->GetRelativeRect().GetHeight() / 2; // 2, half
+    hexagonsList_->SetScrollBlankSize(blankSize);
+    hexagonsList_->SetReboundSize(blankSize);
+    hexagonsList_->SetThrowDrag(true);
+}
+
+void ApplistView::ListStyleOnStart()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::ListStyleOnStart");
     listAdapter_ = new ApplistAdapter();
     if (listAdapter_ == nullptr) {
         return;
@@ -52,10 +93,10 @@ void ApplistView::OnStart()
     contentList_->SetDraggable(true);
     contentList_->SetThrowDrag(true);
     contentList_->EnableAutoAlign(true);
-    contentList_->SetScrollStateListener(this);
+    contentList_->SetScrollStateListener(presenter_);
     contentList_->SetMaxScrollDistance(MAX_SCROLL_DIS);
     contentList_->SetYScrollBarVisible(true);
-    SetContainerView(contentList_);
+    container_->Add(contentList_);
 
     dragListener = new AppListOnDragListener();
     if (dragListener == nullptr) {
@@ -68,6 +109,21 @@ void ApplistView::OnSetUpView()
 {
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::OnSetUpView");
     View<ApplistPresenter>::OnSetUpView();
+    if (presenter_->GetIsUseListStyle() == true) {
+        ListStyleOnSetUpView();
+    } else {
+        HexagonsStyleOnSetUpView();
+    }
+}
+
+void ApplistView::HexagonsStyleOnSetUpView()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::HexagonsStyleOnSetUpView ");
+}
+
+void ApplistView::ListStyleOnSetUpView()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::ListStyleOnSetUpView");
 
     if (contentList_ == nullptr || listAdapter_ == nullptr) {
         return;
@@ -88,7 +144,6 @@ void ApplistView::OnSetUpView()
     contentList_->SetStartIndex(startIndex);
     contentList_->SetAdapter(listAdapter_);
     contentList_->ScrollBy(headY);
-    Draw();
     return;
 }
 
@@ -102,48 +157,79 @@ void ApplistView::OnTearDownView()
 void ApplistView::OnStop()
 {
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::OnStop");
-    int16_t listHeadY = contentList_->GetChildrenHead()->GetY();
-    int16_t listHeadIndex = contentList_->GetChildrenHead()->GetViewIndex();
-
-    presenter_->SetHeadItemY(listHeadY);
-    presenter_->SetStartIndex(listHeadIndex);
-
+    if (presenter_->GetIsUseListStyle() == true) {
+        ListStyleOnStop();
+    } else {
+        HexagonsStyleOnStop();
+    }
+    if (container_ != nullptr) {
+        container_->RemoveAll();
+    }
     View<ApplistPresenter>::OnStop();
-    container_ = nullptr;
-
     RootView::GetInstance()->ClearOnKeyActListener();
-    RootView::GetInstance()->RemoveAll();
     return;
 }
 
-void ApplistView::AddAppItemToList(const AppItem &item)
+void ApplistView::HexagonsStyleOnStop()
 {
-    listAdapter_->AddListItem(item);
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::HexagonsStyleOnStop");
+    if (hexagonsList_ != nullptr) {
+        hexagonsList_->RemoveAll();
+    }
+    for (auto iter : listHexagonsView_) {
+        delete iter;
+    }
+    listHexagonsView_.clear();
 }
 
-void ApplistView::ClearAppItemToList()
+void ApplistView::ListStyleOnStop()
 {
-    listAdapter_->ClearItem();
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::ListStyleOnStop");
+    int16_t listHeadY = contentList_->GetChildrenHead()->GetY();
+    int16_t listHeadIndex = contentList_->GetChildrenHead()->GetViewIndex();
+    presenter_->SetHeadItemY(listHeadY);
+    presenter_->SetStartIndex(listHeadIndex);
 }
 
-void ApplistView::OnItemSelected(int16 index, UIView *view)
+void ApplistView::AddAppItemToList(const AppItem &item)
 {
-    UNUSED(index);
-    if (view != nullptr) {
-        itemViewSele = static_cast<AppItemView *>(view);
-        itemViewSele->SelectedChange();
+    if (presenter_->GetIsUseListStyle() == true) {
+        listAdapter_->AddListItem(item);
+    } else {
+        HexagonsItemView *itemView = new HexagonsItemView();
+        itemView->SetItemInfo(item);
+        itemView->SetSrc(item.iconSmall);
+        itemView->SetTouchable(true);
+        itemView->SetOnClickListener(presenter_);
+
+        hexagonsList_->Add(itemView);
+        listHexagonsView_.push_back(itemView);
+    }
+}
 
-        if (preItemViewSele != nullptr && preItemViewSele != itemViewSele) {
-            preItemViewSele->Reset();
+void ApplistView::ClearAppItemToList()
+{
+    if (presenter_->GetIsUseListStyle() == true) {
+        listAdapter_->ClearItem();
+    } else {
+        if (hexagonsList_ != nullptr) {
+            hexagonsList_->RemoveAll();
+        }
+        for (auto iter : listHexagonsView_) {
+            delete iter;
         }
-        preItemViewSele = itemViewSele;
+        listHexagonsView_.clear();
     }
 }
 
-UIList* ApplistView::GetAppUIList(void)
+void ApplistView::RefreshAppList(void)
 {
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::GetAppUIList");
-    return contentList_;
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::RefreshAppList");
+    if (presenter_->GetIsUseListStyle() == true) {
+        contentList_->RefreshList();
+    } else {
+        hexagonsList_->LayoutChildren(true);
+    }
 }
 
 }
index 4c8f4aa..c940ac8 100755 (executable)
@@ -12,6 +12,7 @@
 #include "components/ui_label.h"\r
 #include "BloodBandoffView.h"\r
 #include "ChangeSliceListener.h"\r
+#include "ui_service.h"\r
 \r
 namespace OHOS {\r
 static BloodOxygenPresenter *g_pMainView = nullptr;\r
@@ -38,6 +39,7 @@ BloodOxygenPresenter* BloodOxygenPresenter::GetInstance()
 void BloodOxygenPresenter::OnStart()\r
 {\r
     Presenter<BloodOxygenView>::OnStart();\r
+    SendMsgToUIService(UI_ADD_SLEEP_VETO, 0, NULL, 0);\r
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::On Start ");\r
 }\r
 \r
@@ -45,7 +47,9 @@ void BloodOxygenPresenter::OnPause(void) {}
 \r
 void BloodOxygenPresenter::OnResume(void) {}\r
 \r
-void BloodOxygenPresenter::OnStop(void) {}\r
+void BloodOxygenPresenter::OnStop(void) {\r
+    SendMsgToUIService(UI_RM_SLEEP_VETO, 0, NULL, 0);\r
+}\r
 \r
 bool BloodOxygenPresenter::CheckPointersValue()\r
 {\r
index 25c7d41..5cbb440 100755 (executable)
@@ -29,18 +29,6 @@ typedef struct {
     int16_t temp;\r
 } BluetoothCaseInfo;\r
 \r
-typedef struct {\r
-    void *stream_hdl;\r
-    uint8_t loc_volume;\r
-    uint8_t play_stat;\r
-    uint8_t dir_forward;\r
-    uint8_t avrcp_button_flag;\r
-    bd_addr_t bd_addr;\r
-    uint8_t reg_cap_auto;\r
-    uint8_t resrv;\r
-    profile_connect_state_t avrcp_srv_conn_stat;\r
-} BtAvrcpTgInftrerface;\r
-\r
 class BluetoothItemView;\r
 class BluetoothModel {\r
 public:\r
index 6b1d6e7..94994ca 100755 (executable)
@@ -33,6 +33,15 @@ static profile_connect_state_t BtAvrcpStat()
     return g_avrcpTgStat;\r
 }\r
 \r
+void BtAvrcpVolumeChangedSyncMedia(uint8_t a2dp_volume)\r
+{\r
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "[BtAvrcpVolumeChangedSyncMedia]::a2dp_volume = 0x%x\r\n", a2dp_volume);\r
+    int32_t audio_volume = a2dp_volume * BT_A2DP_MEDIA_VOL_LEVEL / AVRCP_ABSOLUTE_VOLUME_PERCENTAGE_100;\r
+    AudioManager::GetInstance().SetVolume(AUDIO_STREAM_A2DP_MUSIC, audio_volume); /* 设置增益音量 */\r
+    g_avrcp_tg_local_media_vol = a2dp_volume;\r
+    avrcp_tg_notify_volume_changed(a2dp_volume);\r
+}\r
+\r
 /* tg通知媒体状态 */\r
 static void BtAvrcpTgNotifyMeidaStatus(bt_avrcp_tg_evt_status_param *notifyEventStatusParam)\r
 {\r
@@ -74,9 +83,10 @@ static void BtAvrcpTgNotifyMeidaStatus(bt_avrcp_tg_evt_status_param *notifyEvent
             avrcp_tg_notify_uid_changed(*(td_u16 *)notifyEventStatusParam->event_status);\r
             break;\r
         case AVRCP_NOTIFY_EVENT_VOLUME_CHANGED:\r
-            avrcp_tg_notify_volume_changed(*(td_u8 *)notifyEventStatusParam->event_status);\r
+            BtAvrcpVolumeChangedSyncMedia(notifyEventStatusParam->event_status[0]);\r
             break;\r
         case AVRCP_NOTIFY_EVENT_RESERVED:\r
+            break;\r
         default:\r
             break;\r
     }\r
@@ -84,7 +94,7 @@ static void BtAvrcpTgNotifyMeidaStatus(bt_avrcp_tg_evt_status_param *notifyEvent
 \r
 void PressButtonStatusCallback(td_u32 keyOperation, td_u32 keyValue)\r
 {\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[PressButtonStatusCallback]::keyValue = %x  keyOperation = %x",\r
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[PressButtonStatusCallback]::keyValue = 0x%x  keyOperation = 0x%x",\r
         keyValue, keyOperation);\r
     GraphicService::GetInstance()->PostGraphicEvent(std::bind(UsingPressButtonStatusCallback, keyOperation, keyValue));\r
 }\r
@@ -92,7 +102,7 @@ void PressButtonStatusCallback(td_u32 keyOperation, td_u32 keyValue)
 void BtAvrcpTgNotifyVolumeChangedProc(uint8_t a2dp_volume)\r
 {\r
     int32_t audio_volume = a2dp_volume * BT_A2DP_MEDIA_VOL_LEVEL / AVRCP_ABSOLUTE_VOLUME_PERCENTAGE_100;\r
-    AudioManager::GetInstance().SetVolume(AUDIO_STREAM_MUSIC, audio_volume);\r
+    AudioManager::GetInstance().SetVolume(AUDIO_STREAM_MUSIC, audio_volume); // 耳机连接手表场景调节手表音量\r
 }\r
 \r
 void UsingPressButtonStatusCallback(td_u32 keyOperation, td_u32 keyValue)\r
@@ -145,10 +155,15 @@ void UsingPressButtonStatusCallback(td_u32 keyOperation, td_u32 keyValue)
 \r
 uint8_t BtAvrcpTgGetLocMediaVolume(void)\r
 {\r
-    uint32_t audio_volume = AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC);\r
-    uint8_t a2dp_volume = audio_volume * AVRCP_ABSOLUTE_VOLUME_PERCENTAGE_100 / BT_A2DP_MEDIA_VOL_LEVEL;\r
-    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "get local media volume, a2dp_volume = 0x%x", a2dp_volume);\r
-    return a2dp_volume;\r
+    if (g_avrcp_tg_local_media_vol == AVRCP_ABSOLUTE_VOLUME_INVALID) {\r
+        int32_t audio_volume = AudioManager::GetInstance().GetVolume(AUDIO_STREAM_A2DP_MUSIC);\r
+        uint8_t a2dp_volume = (uint8_t)(audio_volume * AVRCP_ABSOLUTE_VOLUME_PERCENTAGE_100 / BT_A2DP_MEDIA_VOL_LEVEL);\r
+        WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "audio_volume 0x%x, a2dp_volume 0x%x\n", audio_volume, a2dp_volume);\r
+        g_avrcp_tg_local_media_vol = a2dp_volume;\r
+    }\r
+\r
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "get local media volume, a2dp_volume = 0x%x", g_avrcp_tg_local_media_vol);\r
+    return g_avrcp_tg_local_media_vol;\r
 }\r
 \r
 void MediaStatusCallback(bt_avrcp_tg_evt_status_param *eventStatusParam)\r
index a89f5f3..e58b3f6 100755 (executable)
@@ -23,9 +23,6 @@
 #include "bts_gatt_server.h"\r
 #include "bts_le_gap.h"\r
 #include "bts_spp.h"\r
-\r
-// #include "bleService.h"\r
-\r
 #include "osal_task.h"\r
 #ifdef SUPPORT_ALIPAY_SEC\r
 #include "alipay_feature.h"\r
 #include "bts_avrcp_target.h"\r
 \r
 namespace OHOS {\r
-#define BLE_SERVICE_UUID 0x18E0\r
-#define BLE_RX_UUID 0x2ae3\r
-#define BLE_TX_UUID 0x2ae5\r
-#define BLE_BAE_UUID  {0xfb,0x34,0x9b,0x5f,0x80,0x00,0x00,0x80,0x00,0x10,0x00,0x00,0xE3,0x2A,0x00,0x00}\r
 \r
 #define BT_SPP_TASK_STACK_SIZE 2048\r
 #define BT_SPP_TASK_PRI        20\r
@@ -51,8 +44,6 @@ constexpr uint16_t BLUETOOTH_MAX_NUM = 20;
 osal_timer g_a2dp_stream_accept_timer = {NULL, NULL, 0, 0};\r
 #define A2DP_STREAM_ACCEPT_TIMER_PERIOD 500\r
 AudioFormatConfig g_audio_format_config = {AUDIO_DEFAULT, 0, 0};\r
-BtAvrcpTgInftrerface g_avrcp_srv_infterface;\r
-\r
 \r
 void BluetoothModel::SetBluetoothCalleridStatus(int16_t value)\r
 {\r
@@ -77,16 +68,16 @@ BluetoothModel *BluetoothModel::GetInstance(void)
 \r
 void BluetoothModel::Init()\r
 {\r
-    // bool ret = enable_bt_stack();\r
-    // WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "bt enable_bt_stack ret = %d", ret);\r
+    bool ret = enable_bt_stack();\r
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "bt enable_bt_stack ret = %d", ret);\r
 \r
     BtInitCallBacks();\r
-\r
-\r
-    // svr_bluetooth_init();\r
+#ifdef SUPPORT_ALIPAY_SEC\r
+    svr_alipay_bluetooth_init();\r
+#else\r
     BtInitCallBacksEx();\r
     BtInitGatts();\r
-\r
+#endif\r
     BtInitSpp();\r
 \r
     SetUpListCase();\r
@@ -756,7 +747,6 @@ static void DisconnectBluetoothPause()
 \r
 static void DisconnectedHandle()\r
 {\r
-    DisconnectBluetoothPause();\r
     BluetoothModel::GetInstance()->SetTagDisconnectView(false);\r
     BluetoothDeviceListView *bluetoothDeviceListView = BluetoothDeviceListView::GetInstance();\r
     if (bluetoothDeviceListView == nullptr) {\r
@@ -939,8 +929,8 @@ static void BtGattsServiceAddCallback(uint8_t serverId, bt_uuid_t *uuid, uint16_
     WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BtGattsServiceAddCallback 0x%x 0x%x 0x%x",\r
         status, serverId, srvcHandle);\r
 \r
-    if ((uuid->uuid_len == sizeof(uint16_t)) && (*((uint16_t*)uuid->uuid) == BLE_SERVICE_UUID)) {\r
-        uint16_t id = BLE_RX_UUID;\r
+    if ((uuid->uuid_len == sizeof(uint16_t)) && (*((uint16_t*)uuid->uuid) == 0x1FF0)) {\r
+        uint16_t id = 0x1FF1;\r
         gatts_add_chara_info_t character;\r
         uint16_t value = 0;\r
 \r
@@ -948,27 +938,12 @@ static void BtGattsServiceAddCallback(uint8_t serverId, bt_uuid_t *uuid, uint16_
         character.chara_uuid.uuid_len = sizeof(id);\r
         memcpy_s(character.chara_uuid.uuid, sizeof(character.chara_uuid.uuid), (char *)&id, sizeof(id));\r
         character.permissions = GATT_ATTRIBUTE_PERMISSION_WRITE;\r
-        character.properties = GATT_CHARACTER_PROPERTY_BIT_WRITE | GATT_CHARACTER_PROPERTY_BIT_READ |GATT_CHARACTER_PROPERTY_BIT_WRITE_NO_RSP|GATT_CHARACTER_PROPERTY_BIT_NOTIFY;\r
+        character.properties = GATT_CHARACTER_PROPERTY_BIT_WRITE;\r
         character.value_len = (uint16_t)sizeof(value);\r
         character.value = (uint8_t *)(&value);\r
 \r
         ret = gatts_add_characteristic(serverId, srvcHandle, &character);\r
         WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gatts_add_characteristic ret 0x%x", ret);\r
-\r
-        uint16_t tx_uuid[16] = BLE_BAE_UUID;\r
-        gatts_add_chara_info_t txcharacter;\r
-        uint16_t txvalue = 0;\r
-\r
-        memset_s(&txcharacter, sizeof(gatts_add_chara_info_t), 0, sizeof(gatts_add_chara_info_t));\r
-        txcharacter.chara_uuid.uuid_len = sizeof(tx_uuid);\r
-        memcpy_s(txcharacter.chara_uuid.uuid, sizeof(txcharacter.chara_uuid.uuid), (char *)&tx_uuid, sizeof(tx_uuid));\r
-        txcharacter.permissions = GATT_ATTRIBUTE_PERMISSION_WRITE;\r
-        txcharacter.properties = GATT_CHARACTER_PROPERTY_BIT_WRITE | GATT_CHARACTER_PROPERTY_BIT_READ |GATT_CHARACTER_PROPERTY_BIT_WRITE_NO_RSP|GATT_CHARACTER_PROPERTY_BIT_NOTIFY;\r
-        txcharacter.value_len = (uint16_t)sizeof(txvalue);\r
-        txcharacter.value = (uint8_t *)(&txvalue);\r
-\r
-        ret = gatts_add_characteristic(serverId, srvcHandle, &txcharacter);\r
-        WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gatts_add_characteristic ret 0x%x", ret);\r
     }\r
 }\r
 \r
@@ -1011,7 +986,7 @@ static void BtGattsRequestReadCallback(uint8_t serverId, uint16_t connId, gatts_
 \r
 static void BtGattsRequestWriteCallback(uint8_t serverId, uint16_t connId, gatts_req_write_cb_t *writeCbPara,  errcode_t status)\r
 {\r
-    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BtGattsRequestWriteCallback2 %s length:%d",writeCbPara->value,writeCbPara->length);\r
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BtGattsRequestWriteCallback");\r
 }\r
 \r
 static void BtA2dpSnkAcceptTimerStop(void)\r
@@ -1086,8 +1061,8 @@ static int32_t BtA2dpSnkAudioDestroy()
 \r
 static void BtA2dpSnkConnectStateChangedCb(bd_addr_t *bd_addr, int conn_state)\r
 {\r
-    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "addr1111: ****%02x%02x%02x%02x%02x%02x conn_state: %x\n",\r
-        bd_addr->addr[5],bd_addr->addr[4],bd_addr->addr[3], bd_addr->addr[2], bd_addr->addr[1], bd_addr->addr[0], conn_state); /* 3 2 1 0 idx */\r
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "addr: ****%02x%02x%02x%02x conn_state: %x\n",\r
+        bd_addr->addr[3], bd_addr->addr[2], bd_addr->addr[1], bd_addr->addr[0], conn_state); /* 3 2 1 0 idx */\r
 }\r
 \r
 static void BtA2dpSnkStartStreamReqCb(bd_addr_t *bd_addr)\r
@@ -1162,7 +1137,6 @@ static a2dp_snk_callbacks_t g_a2dp_snk_callbacks = {
 \r
 void BtInitCallBacks()\r
 {\r
-    return;\r
     g_btGapCallBacks.discovery_result_callback = BtGapDiscoveryResultCallback;\r
     g_btGapCallBacks.discovery_state_changed_callback = BtGapDiscoveryStateChangedCallback;\r
     g_btGapCallBacks.acl_state_changed_callbak = GapAclStateChangedCallback;\r
@@ -1185,7 +1159,6 @@ void BtInitCallBacks()
 \r
 void BtInitCallBacksEx()\r
 {\r
-    return;\r
     g_gapBleCallbacks.conn_state_change_cb = BleConnStateChangeCallback;\r
     g_gapBleCallbacks.start_adv_cb = BleAdvStartCallback;\r
     g_gapBleCallbacks.stop_adv_cb = BleAdvStopCallback;\r
@@ -1205,8 +1178,7 @@ void BtInitCallBacksEx()
 \r
 void BtInitGatts(void)\r
 {\r
-    return;\r
-    uint16_t id = BLE_SERVICE_UUID;\r
+    uint16_t id = 0x1FF0;\r
     uint16_t ser_id = 0x1FFF;\r
     uint8_t serverId = 0;\r
     bt_uuid_t uuid;\r
@@ -1325,7 +1297,6 @@ void BtInitSpp(void)
 \r
 void BleAdvStart(void)\r
 {\r
-    return;\r
     int advId = 1;\r
     if (BluetoothModel::GetInstance()->GetAdvStartState()) {\r
         WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BleAdvStart already started");\r
index 9786748..4bd2900 100755 (executable)
@@ -45,7 +45,6 @@ namespace OHOS {
 using namespace std;\r
 \r
 class CallerLogModel {\r
-   \r
 public:\r
     typedef enum {\r
         CallSourcePhone,\r
@@ -81,7 +80,7 @@ public:
 \r
     bool GetNotifyFlag(void);\r
     void SetNotifyFlag(bool flag);\r
-\r
+    bool IsMulitplePhoneStatus(void);\r
     CallSource GetCallSource(void)\r
     {\r
         return callsrc;\r
@@ -90,8 +89,6 @@ public:
     {\r
         callsrc = source;\r
     }\r
-\r
-    \r
 private:\r
     CallerLogModel();\r
     CallerLogModel(const CallerLogModel &);\r
index 62f6994..facd7fc 100755 (executable)
@@ -37,7 +37,8 @@ static int g_firstPriority = NO_NUMBER_STATUS;
 static int g_secondPriority = NO_NUMBER_STATUS;
 static int g_thirdPriority = NO_NUMBER_STATUS;
 static int g_fourthPriority = NO_NUMBER_STATUS;
-
+// 是否为手表接听状态
+static bool g_isWatchCallView = false;
 void g_callTimesclean()
 {
     g_callTimes=0;
@@ -95,6 +96,8 @@ static void StatusReset()
     // If the call is handling in the notification, the slice is not switched
     if (CallerLogModel::GetInstance()->GetNotifyFlag() == false) {
         NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE);
+    } else {
+        g_isWatchCallView = false;
     }
     return;
 }
@@ -241,6 +244,9 @@ static void ExitMakePhoneSlice(void)
     }
     CallerLogModel::GetInstance()->SetCallStatus(false);
     DisableCallingTimer();
+    if (CallerLogModel::GetInstance()->GetNotifyFlag() == true) {
+        g_isWatchCallView = false;
+    }
 }
 
 static void DialingHandle(void)
@@ -273,6 +279,8 @@ static void WaitingOpreate()
     // If the call is handling in the notification, the slice is not switched
     if (CallerLogModel::GetInstance()->GetNotifyFlag() == false) {
         NativeAbility::GetInstance().ChangeSlice(VIEW_MAEKPHONE_SAMPLE, TRANSITION_INVALID, PRIORITY_ONE);
+    } else {
+        g_isWatchCallView = true;
     }
 }
 
@@ -288,12 +296,15 @@ static void WatchActiveHandle(const PhoneCallInfo *phoneCall)
         InitCallingTimer();
         CallerLogModel::GetInstance()->SetCallStatus(true);
     }
+    if (CallerLogModel::GetInstance()->GetNotifyFlag() == true) {
+        g_isWatchCallView = true;
+    }
 }
 
 static void PhoneActiveHandle(void)
 {
     if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_MAEKPHONE_SAMPLE ||
-        CallerLogModel::GetInstance()->GetNotifyFlag() == true) {
+        g_isWatchCallView == true) {
         if (GetCurrCallNum() > 1) {
             g_phoneStatus = PHONE_MULTI_STATUS;
             if (GetScoConnectState() == HFP_SCO_STATE_DISCONNECTED) {
@@ -304,6 +315,8 @@ static void PhoneActiveHandle(void)
         // If the call is handling in the notification, the slice is not switched
         if (CallerLogModel::GetInstance()->GetNotifyFlag() == false) {
             NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE); // 退出通话界面,回到主表盘应用
+        } else {
+            g_isWatchCallView = false;
         }
         CallModelPostGraphicEvent(CallModelResumePlayer);
     }
@@ -314,7 +327,7 @@ static void PhoneActiveHandle(void)
 static void OppoActiveHandle(const PhoneCallInfo *phoneCall)
 {
     if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_MAEKPHONE_SAMPLE ||
-        CallerLogModel::GetInstance()->GetNotifyFlag() == true) {
+        g_isWatchCallView == true) {
         if (GetCurrCallNum() > 1) {
             g_phoneStatus = PHONE_MULTI_STATUS;
             return;
@@ -370,7 +383,11 @@ static bool MultiplePhonesViewDisplay()
             DisableCallingTimer();
             CallerLogModel::GetInstance()->SetMulitplePhoneStatus(true);
             CallerLogModel::GetInstance()->SetCallStatus(true);
-            NativeAbility::GetInstance().ChangeSlice(VIEW_MAEKPHONE_SAMPLE, TRANSITION_INVALID, PRIORITY_ONE);
+            if (CallerLogModel::GetInstance()->GetNotifyFlag() == false) {
+                NativeAbility::GetInstance().ChangeSlice(VIEW_MAEKPHONE_SAMPLE, TRANSITION_INVALID, PRIORITY_ONE);
+            } else {
+                g_isWatchCallView = true;
+            }
             return true;
         }
         if (MulitplePhoneTextReplaces() == false) {
@@ -403,9 +420,13 @@ static void NonWatchFinishHandle(int laststatus)
             // If the call is handling in the notification, the slice is not switched
             if (CallerLogModel::GetInstance()->GetNotifyFlag() == false) {
                 NativeAbility::GetInstance().ChangeSlice(VIEW_MAEKPHONE_SAMPLE, TRANSITION_INVALID, PRIORITY_ONE);
+            } else {
+                g_isWatchCallView = true;
             }
         }
-        CallerLogModel::GetInstance()->SetNotifyFlag(false);
+        if (GetCurrCallNum() == 0) {
+            CallerLogModel::GetInstance()->SetNotifyFlag(false);
+        }
     }
     if (GetCurrCallNum() == 0) {
         g_phoneStatus = PHONE_SINGLE_STATUS;
@@ -418,13 +439,13 @@ static void WatchFinishHandle(void)
         CallerLogModel::GetInstance()->GetNotifyFlag() == true) {
         if (GetCurrCallNum() == 0) {
             StatusReset();
+            CallerLogModel::GetInstance()->SetNotifyFlag(false);
         } else {
             StatusReset();
             for (int i = GetCurrCallNum(); i > 0; i--) {
                 FinishCall();
             }
         }
-        CallerLogModel::GetInstance()->SetNotifyFlag(false);
     }
     g_phoneStatus = PHONE_SINGLE_STATUS;
 }
@@ -577,6 +598,8 @@ static void ScoConnectHandle(void)
     // If the call is handling in the notification, the slice is not switched
     if (CallerLogModel::GetInstance()->GetNotifyFlag() == false) {
         NativeAbility::GetInstance().ChangeSlice(VIEW_MAEKPHONE_SAMPLE, TRANSITION_INVALID, PRIORITY_ONE);
+    } else {
+        g_isWatchCallView = true;
     }
 }
 
@@ -725,6 +748,13 @@ bool CallerLogModel::GetNotifyFlag(void)
     return notifyFlag;
 }
 
+// 电话是否为多路状态
+bool CallerLogModel::IsMulitplePhoneStatus(void)
+{
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "IsMulitplePhoneStatus phoneStatus:%d", g_phoneStatus);
+    return g_phoneStatus == PHONE_MULTI_STATUS;
+}
+
 /* 是否为多路通话界面 */
 void CallerLogModel::SetMulitplePhoneStatus(bool status)
 {
index e8b7713..54098cc 100755 (executable)
@@ -338,7 +338,7 @@ void HeartModel::RefreshHeartRateScreen(uint16_t perSec, uint16_t rest, uint16_t
     }\r
 \r
     if (MainViewSample::GetInstance() != nullptr && HeartRateView::GetInstance() != nullptr) {\r
-        if (MainViewSample::GetInstance()->GetHorCurrentPage() == HEART_RATE) {\r
+        if (MainViewSample::GetInstance()->GetHorCurrentCard() == HEART_RATE) {\r
             HeartRateView::GetInstance()->SetHeartRateData(rateData, sizeof(Point) * len);\r
             HeartRateView::GetInstance()->RefreshElectrocardiogram();\r
             HeartRateView::GetInstance()->RefreshHeartRatePerSec(perSec);\r
index 4a4ebaa..303045f 100755 (executable)
@@ -50,7 +50,6 @@ private:
     bool pageStatus[MAX_MOTIONPAGE]{false};\r
     UISwipeView::OnSwipeListener* motionclickListener{nullptr};\r
     UIView::OnDragListener* motionDragListener{nullptr};\r
-    AppGroupView *GreatePage(int32_t MotionPageId);\r
 };\r
 } // namespace OHOS\r
 #endif // INDOORWALK_MOTION_VIEW_H
\ No newline at end of file
index 866e42f..a3350f2 100755 (executable)
@@ -127,7 +127,7 @@ UIViewGroup *IndoorWalkMotionView::WalkMotionViewInit(void)
     walkMotionList->SetAnimatorTime(50); // 50:animator drag time(ms)\r
 \r
     for (uint16_t i = 0; i < maxPage; i++) {\r
-        recordCard[i] = GreatePage(i);\r
+        recordCard[i] = (this->*(g_pageMapper[i].func))();\r
         if (recordCard[i] == nullptr) {\r
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "IndoorWalkMotionView:: recordCard %d error", i);\r
             return nullptr;\r
@@ -170,20 +170,4 @@ void IndoorWalkMotionView::InitialStep()
     IndoorWalkModel::GetInstance()->SetInitialStep(stepValue);\r
 }\r
 \r
-AppGroupView *IndoorWalkMotionView::GreatePage(int32_t StreamId)\r
-{\r
-    uint16_t i;\r
-    AppGroupView *view = nullptr;\r
-    int32_t MotionPageId = ScreenModels::GetInstance()->GetCardPage(StreamId);\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GreatePage MotionPageId:%d", MotionPageId);\r
-    for (i = 0; i < sizeof(g_pageMapper) / sizeof(g_pageMapper[0]); i++) {\r
-        if (g_pageMapper[i].id == MotionPageId) {\r
-            view = (this->*(g_pageMapper[i].func))();\r
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GreatePage view:%p", view);\r
-            return view;\r
-        }\r
-    }\r
-    return nullptr;\r
-}\r
-\r
 }
\ No newline at end of file
index b9724f9..e7ca76f 100755 (executable)
@@ -25,8 +25,8 @@ private:
     void OnKeyPress(void);\r
     void OnKeyLongPress(const KeyEvent& event);\r
     void OnKeyRelease(const KeyEvent& event);\r
-    void CallVolumeDipSwitchControl(uint8_t status);\r
-    void PlayerVolumeDipSwitchControl(uint8_t model);\r
+    void CallVolumeDipSwitchControl(VolumeChangeStatus status);\r
+    void PlayerVolumeDipSwitchControl(VolumeChangeStatus status);\r
 private:\r
     int32 pressFlag{0};\r
     int32 longPressFlag{0};\r
index d70e633..877ad1b 100755 (executable)
@@ -8,7 +8,6 @@
 #include "KeyInputListener.h"
 #include "common/key_code.h"
 #include "AppViewIDs.h"
-#include "components/ui_label_ext.h"
 #include "View.h"
 #include "MainViewSample.h"
 #include "wearable_log.h"
@@ -75,7 +74,7 @@ void KeyInputListener::OnKeyLongPress(const KeyEvent& event)
     return;
 }
 
-void KeyInputListener::CallVolumeDipSwitchControl(uint8_t model)
+void KeyInputListener::CallVolumeDipSwitchControl(VolumeChangeStatus status)
 {
     if (MainCallingPresenter::GetInstance() != nullptr && CallerLogModel::GetInstance()->GetCallStatus()) {
         if (CallerLogModel::GetInstance()->GetVolumeScreenStatus() == true) {
@@ -83,7 +82,7 @@ void KeyInputListener::CallVolumeDipSwitchControl(uint8_t model)
             if (volumeSliderEventListener == nullptr) {
                 return;
             }
-            volumeSliderEventListener->ChangeVolume(model);
+            volumeSliderEventListener->ChangeVolume(status);
         } else {
             MainCallingPresenter::GetInstance()->HonrsViewChange();
             CallerLogModel::GetInstance()->SetVolumeScreenStatus(true);
@@ -95,7 +94,7 @@ void KeyInputListener::CallVolumeDipSwitchControl(uint8_t model)
             if (volumeSliderEventListener == nullptr) {
                 return;
             }
-            volumeSliderEventListener->ChangeVolume(model);
+            volumeSliderEventListener->ChangeVolume(status);
         } else {
             HonrsViewChange();
             NotificationManager::GetInstance()->SetVolumeScreenStatus(true);
@@ -111,7 +110,7 @@ void KeyInputListener::OnKeyRelease(const KeyEvent& event)
         if (longPressFlag == 0 && pressFlag == 1) { // 短按电源键
             if (currentViewId == VIEW_MAEKPHONE_SAMPLE || IsCallingNotify() == true) { // 音量卡片
                 // 音量+
-                CallVolumeDipSwitchControl(1);
+                CallVolumeDipSwitchControl(VOLUMEUP);
             } else if (currentViewId != VIEW_MAIN_SAMPLE) { // 主表盘
                 PressAlarmNotify(); // 当前为闹钟通知页面时,先处理闹钟再切换页面
                 NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE, TRANSITION_ZOOM);
@@ -128,7 +127,7 @@ void KeyInputListener::OnKeyRelease(const KeyEvent& event)
         if (longPressFlag == 0 && pressFlag == 1) { // 短按功能键
             if (currentViewId == VIEW_MAEKPHONE_SAMPLE || IsCallingNotify() == true) { // 音量卡片
                 // 音量-
-                CallVolumeDipSwitchControl(0);
+                CallVolumeDipSwitchControl(VOLUMEDOWN);
             } else {
                 // 切换到用户配置的快捷卡片
             }
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/DialBinParser.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/DialBinParser.h
new file mode 100644 (file)
index 0000000..dc73723
--- /dev/null
@@ -0,0 +1,61 @@
+/*\r
+ * Copyright (c) 2023 CompanyNameMagicTag.\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+#ifndef GRAPHIC_LITE_DIAL_BIN_PARSER_H\r
+#define GRAPHIC_LITE_DIAL_BIN_PARSER_H\r
+#include <iostream>\r
+#include <cstring>\r
+#include "graphic_types.h"\r
+#include "DialViewGroup.h"\r
+#include "DialBinTypes.h"\r
+#include "components/ui_abstract_progress.h"\r
+\r
+namespace OHOS {\r
+class DialBinParser {\r
+public:\r
+    static DialBinParser* GetInstance(void);\r
+    bool UpdateDial(const std::string& file, FILE* fp, DialViewGroup* group);\r
+    bool GetDialPreviewInfo(FILE* fp, DialPreviewInfo* info);\r
+\r
+protected:\r
+    int32_t ParseDialHeader(FILE* file);\r
+    int32_t ParserDialStaticImg(FILE* fp);\r
+    int32_t ParserDialSequenceImg(FILE* fp);\r
+    int32_t ParserDialRotateImg(FILE* fp);\r
+    int32_t ParserDialOptionImg(FILE* fp);\r
+    int32_t ParserDialDigitalImg(FILE* fp);\r
+    int32_t ParserDialLabel(FILE* fp);\r
+    int32_t ParserDialArcLabel(FILE* fp);\r
+    int32_t ParserDialBoxProgress(FILE* fp);\r
+    int32_t ParserDialArcProgress(FILE* fp);\r
+    int32_t ParserDialVideo(FILE* fp);\r
+    int32_t ParserDialClick(FILE* fp);\r
+    int32_t ParserDialKaleidoscope(FILE* fp);\r
+\r
+private:\r
+    DialBinParser();\r
+    virtual ~DialBinParser();\r
+    void* MallocAndReadBuf(FILE* file, uint32_t readSize);\r
+    bool SetProgressType(FILE* fp, UIAbstractProgress* view, DialProgressType data);\r
+\r
+    static constexpr uint8_t DIAL_BIN_PARSER_FUNC_NUM = 12; // 12: func max value\r
+    int32_t (DialBinParser::*funcArray_[DIAL_BIN_PARSER_FUNC_NUM])(FILE*);\r
+\r
+    DialViewGroup* dialGroup_ = nullptr;\r
+    std::string file_;\r
+    uint32_t dirId_ = 0xfef << 20; // 20: offset\r
+    uint32_t imageOffset_ = 0;\r
+};\r
+}\r
+#endif\r
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/DialBinTypes.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/DialBinTypes.h
new file mode 100644 (file)
index 0000000..1f8f493
--- /dev/null
@@ -0,0 +1,175 @@
+/*\r
+ * Copyright (c) 2023 CompanyNameMagicTag.\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+#ifndef GRAPHIC_LITE_DIAL_BIN_TYPE_H\r
+#define GRAPHIC_LITE_DIAL_BIN_TYPE_H\r
+#include "color.h"\r
+#include "graphic_types.h"\r
+#include "components/ui_canvas_ext.h"\r
+\r
+namespace OHOS {\r
+static constexpr uint8_t DIAL_NAME_MAX_LEN = 16;\r
+static constexpr uint8_t DIAL_VERSION_MAX_LEN = 16;\r
+static constexpr uint8_t DIAL_DESCRIPTION_MAX_LEN = 128;\r
+static constexpr uint8_t DIAL_DIGITALIMG_IMG_MAX_NUM = 10;\r
+\r
+struct DialPreviewInfo {\r
+    char dialName[DIAL_NAME_MAX_LEN];\r
+    char description[DIAL_DESCRIPTION_MAX_LEN];\r
+    uint32_t imgId;\r
+    uint32_t offset;\r
+};\r
+\r
+struct DialRect {\r
+    int16_t x;\r
+    int16_t y;\r
+    int16_t w;\r
+    int16_t h;\r
+};\r
+\r
+struct DialHeader {\r
+    char dialName[DIAL_NAME_MAX_LEN];\r
+    int16_t width;\r
+    int16_t height;\r
+    char version[DIAL_VERSION_MAX_LEN];\r
+    uint16_t previewImgId;\r
+    char description[DIAL_DESCRIPTION_MAX_LEN];\r
+    uint32_t imageOffset;\r
+    uint8_t freq;\r
+    uint8_t dialViewCount;\r
+};\r
+\r
+struct DialStaticImg {\r
+    Point pos;\r
+    Point center;\r
+    float rotate;\r
+    uint16_t imgId;\r
+};\r
+\r
+struct DialSequenceImg {\r
+    Point pos;\r
+    uint16_t interval;\r
+    bool repeat;\r
+    uint8_t imgNum;\r
+};\r
+\r
+struct DialRotateImg {\r
+    Point pos;\r
+    Point center;\r
+    int16_t rotateStart;\r
+    int16_t rotateEnd;\r
+    uint16_t imgId;\r
+    int16_t bindData;\r
+    bool isPeriod;\r
+};\r
+\r
+struct DialOptionImg {\r
+    Point pos;\r
+    int16_t bindData;\r
+    bool isPeriod;\r
+    uint8_t count;\r
+};\r
+\r
+struct DialDigitalImg {\r
+    uint8_t alignType : 4;\r
+    uint8_t integerLength : 4;\r
+    uint8_t decimalPrecision;\r
+    uint16_t imgIds[DIAL_DIGITALIMG_IMG_MAX_NUM];\r
+    int16_t signImgId;\r
+    int16_t decimalPointImgId;\r
+    uint16_t space;\r
+    Point alignPosition;\r
+    int16_t bindData;\r
+    bool isPeriod;\r
+};\r
+\r
+struct DialLabel {\r
+    uint8_t breakMode;\r
+    uint8_t align;\r
+    uint8_t fontSize;\r
+    bool isPeriod;\r
+    DialRect rect;\r
+    uint32_t color;\r
+    char fontName[64];\r
+    char text[64];\r
+    int16_t bindData;\r
+};\r
+\r
+struct DialArcLabel {\r
+    uint8_t align;\r
+    uint8_t fontSize;\r
+    Point center;\r
+    int16_t radius;\r
+    int16_t rotateStart;\r
+    int16_t rotateEnd;\r
+    uint32_t color;\r
+    char fontName[64];\r
+    char text[64];\r
+    int16_t bindData;\r
+    bool isPeriod;\r
+};\r
+\r
+struct DialProgressType {\r
+    uint8_t type;       //  image | color | gradient_color\r
+    DialRect rect;\r
+    union {\r
+        uint8_t stopCount;\r
+        uint16_t imgId;\r
+        Color32 color;\r
+    };\r
+};\r
+\r
+struct DialBoxProgress {\r
+    uint8_t cap;\r
+    uint8_t direction;\r
+    bool isPeriod;\r
+    int16_t bindData;\r
+    uint32_t bgColor;\r
+    DialProgressType typeData;\r
+};\r
+\r
+struct DialArcProgress {\r
+    uint8_t cap;\r
+    bool isPeriod;\r
+    uint16_t radius;\r
+    uint16_t startAngle;\r
+    uint16_t endAngle;\r
+    uint16_t lineWidth;\r
+    int16_t bindData;\r
+    uint32_t bgColor;\r
+    DialProgressType typeData;\r
+};\r
+\r
+struct DialVideo {\r
+    DialRect rect;\r
+    uint32_t offset;\r
+    Color32 colorKey;\r
+};\r
+\r
+struct DialClick {\r
+    uint8_t type;\r
+    DialRect rect;\r
+    union {\r
+        uint32_t sliceId;\r
+        char bundleName[64];\r
+    };\r
+};\r
+\r
+struct DialKaleidoscope {\r
+    uint16_t imgId;\r
+    float crownRotateStep;\r
+    float animatorRotateStep;\r
+};\r
+}\r
+#endif // GRAPHIC_LITE_DIAL_BIN_TYPE_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainModel.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainModel.h
new file mode 100644 (file)
index 0000000..6bc09a0
--- /dev/null
@@ -0,0 +1,59 @@
+/*\r
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.\r
+ * Description: MainModel.h\r
+ * Author:\r
+ * Create: 2021-11-23\r
+ */\r
+\r
+#ifndef MAIN_MODEL_H\r
+#define MAIN_MODEL_H\r
+\r
+#include <string>\r
+#include "UiConfig.h"\r
+\r
+namespace OHOS {\r
+    typedef struct {\r
+        CardId id;\r
+        const char *cardImg;\r
+    } CardInfo;\r
+\r
+    typedef struct {\r
+        DialId id;\r
+        const char *dialName;\r
+        const char *dialImg;\r
+        uint8_t freq;\r
+    } DialInfo;\r
+\r
+    typedef struct {\r
+      uint8_t dialFlag;\r
+      uint8_t dialId;\r
+      std::string dialFullName;\r
+    } DialSetting;\r
+\r
+    class MainModel {\r
+    public:\r
+        static MainModel &GetInstance(void);\r
+        void InitCardSettings(void);\r
+        uint8_t GetCardSettingCount(void);\r
+        CardId *GetCardSettings(void);\r
+        void DeleteCardSetting(uint8_t index);\r
+        void AddCardSetting(uint8_t index);\r
+        const CardInfo *GetCardInfo(CardId card) const;\r
+        const DialInfo *GetDialInfo(DialId dial) const;\r
+        void AddDialSetting(const DialSetting &setting);\r
+        void InitDialSettings(void);\r
+        DialSetting &GetDialSetting();\r
+    private:\r
+        void InitDialSettingDefault(void);\r
+        MainModel();\r
+        MainModel(const MainModel &);\r
+        MainModel &operator=(const MainModel &);\r
+        virtual ~MainModel();\r
+\r
+        CardId cardSettings[CARD_SETTING_COUNT_MAX] = { MAX_CARD };\r
+        uint8_t cardSettingCount{0};\r
+        DialSetting dialSetting;\r
+    };\r
+}\r
+\r
+#endif
\ No newline at end of file
index 1feb8bc..08fc301 100755 (executable)
@@ -14,6 +14,7 @@
 #include "KeyInputListener.h"
 #include "drag_event.h"
 #include "MainViewSample.h"
+#include "MainModel.h"
 #include "components/ui_swipe_view.h"
 #include "components/ui_view.h"
 #include "CompassView.h"
@@ -41,7 +42,7 @@ constexpr uint16_t HORIZONTAL_STATUS = 0;
 class MainViewSample;
 class MainPresenterSample : public Presenter<MainViewSample>, public ModelListenerSample,
                             public UIView::OnClickListener, public UISwipeView::OnSwipeListener,
-                            public UISwipeView, public CompassPresenter {
+                            public UIView::OnLongPressListener, public UISwipeView, public CompassPresenter {
 public:
     MainPresenterSample();
     virtual ~MainPresenterSample();
@@ -53,24 +54,20 @@ public:
     void OnStop() override;
     virtual void Notify() override;
     bool OnClick(UIView& view, const ClickEvent& event) override;
+    bool OnLongPress(UIView& view, const LongPressEvent& event) override;
     virtual void OnSwipe(UISwipeView& view) override;
     void SetPage(int8_t id);
-    void SetTaskPeroid(int page);
+    void SetTaskPeroid(CardId cardId);
     void setCallback(ZoomEffect* callback)
     {
         callback_ = callback;
     }
 
-    void SetDialPath(std::string filePath)
-    {
-        filePath_ = filePath;
-    }
-
-    std::string GetDialPath()
-    {
-        return filePath_;
-    }
-
+    void InitCardSettings(void);
+    uint8_t GetCardSettingCount(void);
+    CardId *GetCardSettings(void);
+    void InitDialSettings(void);
+    DialSetting& GetDialSetting();
 private:
     void ProcessDataNotify(void);
     void SetCircleProgress(void);
@@ -82,7 +79,6 @@ private:
     int64_t playerMusicDuration_{0};
     int64_t playerProgressValue_{0};
     bool isCompassSensorOpened_{false};
-    std::string filePath_;
 };
 }
 
index 7c0e55d..243a5db 100755 (executable)
 #include "ScreenModels.h"
 #include "ActivityWeekView.h"
 #include "CompassControlView.h"
-#if USE_OFFLINE_DIAL
 #include "DialViewGroup.h"
-#else
 #include "MainClockView.h"
-#endif
 #include "PlayersView.h"
 #include "MainPresenterSample.h"
 #include "HeartRateView.h"
 #include "components/ui_card_page.h"
 #include "PullUpDownView.h"
 #include "components/ui_cross_view.h"
+#include "SetCardModel.h"
 
 namespace OHOS {
 class MainPresenterSample;
@@ -51,11 +49,7 @@ public:
     UICardPage *InitMusicPlayerPage(void);
     void AnimatorStart(int pageIndex);
     void AnimatorStop(void);
-    uint16_t GetHorCurrentPage() const
-    {
-        return mainSwipeGroup->GetCurrentPageId(UISwipeView::HORIZONTAL); // 0: horizontal; 1: vertical
-    }
-
+    CardId GetHorCurrentCard() const;
     UIView* GetMainViewGroup(void) const
     {
         return mainSwipeGroup;
@@ -82,11 +76,7 @@ private:
     PullUpDownView *dropDownView{nullptr};
     UICardPage *messageView{nullptr};
     UILabel *messageLable{nullptr};
-#if USE_OFFLINE_DIAL
-    DialViewGroup *mainClockView{nullptr};
-#else
-    MainClockView *mainClockView{nullptr};
-#endif
+    UICardPage *mainClockView{nullptr};
     ActivityWeekView *activityWeekView{nullptr};
     PlayersView *playersView{nullptr};
     CompassControlView *compassControlView{nullptr};
@@ -100,6 +90,8 @@ private:
     void VerticalViewInit(void);
     void VertViewLoad(void);
     void HorViewLoad(void);
+    UICardPage *InitWathOffDial(DialSetting &setting);
+    UICardPage *InitWathDial(DialSetting &setting);
 };
 } // namespace OHOS
 #endif // MAIN_VIEW_SAMPLE_H
index 26cc098..f18dac4 100755 (executable)
@@ -28,8 +28,8 @@ typedef enum : uint16_t {
 } VolumeFactor;
 
 typedef enum : uint8_t {
-    VOLUMELOWERS = 0,
-    VOLUMELEVATED = 1,
+    VOLUMEDOWN = 0,
+    VOLUMEUP = 1,
     VOLUMEDRAG = 2,
 } VolumeChangeStatus;
 
@@ -42,8 +42,7 @@ public:
     static VolumeSliderEventListener *GetInstance();
     void OnChange(int32_t progress) override;
     void OnRelease(int32_t progress) override;
-    void ChangeImage(void);
-    void ChangeVolume(uint8_t status);
+    void ChangeVolume(VolumeChangeStatus status);
     bool OnClick(UIView& view, const ClickEvent& event) override;
     bool OnDrag(UIView& view, const DragEvent& event) override;
     void SetPlayerCoefficients(int16_t value);
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialKaleidoscopeView.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/dial/DialKaleidoscopeView.h
new file mode 100644 (file)
index 0000000..f73c2b8
--- /dev/null
@@ -0,0 +1,11 @@
+/*\r
+ * Copyright (c) @CompanyNameMagicTag. 2024. All rights reserved.\r
+ */\r
+\r
+#ifndef DIAL_KALEIDOSCOPE_VIEW_H\r
+#define DIAL_KALEIDOSCOPE_VIEW_H\r
+#include "components/ui_kaleidoscope_view.h"\r
+namespace OHOS{\r
+using DialKaleidoscopeView = UIKaleidoscopeView;\r
+}\r
+#endif\r
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainModel.cpp
new file mode 100644 (file)
index 0000000..53a0dd3
--- /dev/null
@@ -0,0 +1,203 @@
+/*\r
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.\r
+ * Description: MainModel.cpp\r
+ * Author:\r
+ * Create: 2021-11-23\r
+ */\r
+\r
+#include "unistd.h"\r
+#include "MainModel.h"\r
+#include "kv_store.h"\r
+#include "securec.h"\r
+#include "wearable_log.h"\r
+\r
+namespace OHOS {\r
+    static const int CARD_SETTING_VALUE_LEN = 32;\r
+    static const int DIAL_SETTING_VALUE_LEN = 64;\r
+    const CardInfo cardInfoMap[] = {\r
+        { HEART_RATE, PNG_SET_CARD_HEART },\r
+        { COMPASS, PNG_SET_CARD_COMPASS },\r
+        { ACTIVITY, PNG_SET_CARD_ACTIVITY },\r
+        { MUSIC_PLAYER, PNG_SET_CARD_PLAYER },\r
+    };\r
+\r
+    const DialInfo dialInfoMap[] = {\r
+        { DIAL_CLOCK, "扫秒表盘", PNG_SET_DIAL_CLOCK, DEFAULT_TASK_PERIOD },\r
+    };\r
+\r
+    MainModel::MainModel() {}\r
+\r
+    MainModel::~MainModel() {}\r
+\r
+    MainModel &MainModel::GetInstance()\r
+    {\r
+        static MainModel instance;\r
+        return instance;\r
+    }\r
+\r
+    const CardInfo *MainModel::GetCardInfo(CardId card) const\r
+    {\r
+        for (uint8_t i = 0; i < (sizeof(cardInfoMap) / sizeof(cardInfoMap[0])); i++) {\r
+            if (card == cardInfoMap[i].id) {\r
+                return &cardInfoMap[i];\r
+            }\r
+        }\r
+        return nullptr;\r
+    }\r
+\r
+    const DialInfo *MainModel::GetDialInfo(DialId dialId) const\r
+    {\r
+        for (uint8_t i = 0; i < (sizeof(dialInfoMap) / sizeof(dialInfoMap[0])); i++) {\r
+            if (dialId == dialInfoMap[i].id) {\r
+                return &dialInfoMap[i];\r
+            }\r
+        }\r
+        return nullptr;\r
+    }\r
+\r
+    void MainModel::InitCardSettings(void)\r
+    {\r
+        char temp[CARD_SETTING_VALUE_LEN] = { 0 };\r
+        int len;\r
+        int index = 0;\r
+\r
+        memset_s(cardSettings, CARD_SETTING_COUNT_MAX, 0, CARD_SETTING_COUNT_MAX);\r
+        len = UtilsGetValue("card_setting", temp, CARD_SETTING_VALUE_LEN);\r
+        if (len >= 0) {\r
+            /* 读取用户card配置 */\r
+            char *setBuffer = nullptr;\r
+            char *setValue = strtok_s(temp, ",", &setBuffer);\r
+            while (setValue != nullptr) {\r
+                if (index >= CARD_SETTING_COUNT_MAX) {\r
+                    break;\r
+                }\r
+                cardSettings[index++] = (CardId)atoi(setValue);\r
+                setValue = strtok_s(nullptr, ",", &setBuffer);\r
+            }\r
+            cardSettingCount = index;\r
+        } else {\r
+            /* 使用默认card配置 */\r
+            cardSettings[index++] = WATCH_FACE;\r
+            cardSettings[index++] = HEART_RATE;\r
+            cardSettings[index++] = COMPASS;\r
+            cardSettings[index++] = ACTIVITY;\r
+            cardSettings[index++] = MUSIC_PLAYER;\r
+            cardSettingCount = index;\r
+        }\r
+    }\r
+\r
+    void MainModel::DeleteCardSetting(uint8_t index)\r
+    {\r
+        char temp[CARD_SETTING_VALUE_LEN] = { 0 };\r
+        for (uint8_t i = 0; i < cardSettingCount; i++) {\r
+            if (i == index + 1) {\r
+                uint8_t j = i;\r
+                for (; j < cardSettingCount - 1; j++) {\r
+                    cardSettings[j] = cardSettings[j + 1];\r
+                }\r
+                cardSettings[j] = MAX_CARD;\r
+                cardSettingCount--;\r
+            }\r
+        }\r
+\r
+        for (uint8_t i = 0; i < cardSettingCount; i++) {\r
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "cardSettings[%d] = %d", i, cardSettings[i]);\r
+            (void)sprintf_s(temp + strlen(temp), CARD_SETTING_VALUE_LEN, "%d,", cardSettings[i]);\r
+        }\r
+        (void)UtilsSetValue("card_setting", temp);\r
+    }\r
+\r
+    void MainModel::AddCardSetting(uint8_t index)\r
+    {\r
+        char temp[CARD_SETTING_VALUE_LEN] = { 0 };\r
+        if (cardSettingCount >= CARD_SETTING_COUNT_MAX) {\r
+            return;\r
+        }\r
+        for (int i = 0; i < cardSettingCount; i++) {\r
+            if (cardSettings[i] == cardInfoMap[index].id) {\r
+                return;\r
+            }\r
+        }\r
+        cardSettings[cardSettingCount++] = cardInfoMap[index].id;\r
+        for (uint8_t i = 0; i < cardSettingCount; i++) {\r
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "cardSettings[%d] = %d", i, cardSettings[i]);\r
+            (void)sprintf_s(temp + strlen(temp), CARD_SETTING_VALUE_LEN, "%d,", cardSettings[i]);\r
+        }\r
+        (void)UtilsSetValue("card_setting", temp);\r
+    }\r
+\r
+    uint8_t MainModel::GetCardSettingCount(void)\r
+    {\r
+        return cardSettingCount;\r
+    }\r
+\r
+    CardId *MainModel::GetCardSettings(void)\r
+    {\r
+        return cardSettings;\r
+    }\r
+\r
+    void MainModel::InitDialSettingDefault(void)\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "InitDialSettingDefault");\r
+        dialSetting.dialFlag = 0;\r
+        dialSetting.dialId = DIAL_CLOCK;\r
+        dialSetting.dialFullName = "";\r
+    }\r
+\r
+    void MainModel::AddDialSetting(const DialSetting &setting)\r
+    {\r
+        std::string tmp;\r
+        tmp += std::to_string(setting.dialFlag);\r
+        tmp += ",";\r
+        tmp += std::to_string(setting.dialId);\r
+        tmp += ",";\r
+        tmp += setting.dialFullName;\r
+        tmp += ",";\r
+        (void)UtilsSetValue("dial_setting", tmp.c_str());\r
+    }\r
+\r
+    void MainModel::InitDialSettings(void)\r
+    {\r
+        char temp[DIAL_SETTING_VALUE_LEN] = { 0 };\r
+        int len;\r
+        len = UtilsGetValue("dial_setting", temp, DIAL_SETTING_VALUE_LEN);\r
+        if (len >= 0) {\r
+            char *setBuffer = nullptr;\r
+            char *setValue = strtok_s(temp, ",", &setBuffer);\r
+            if (setValue != nullptr) {\r
+                dialSetting.dialFlag = atoi(setValue);\r
+            } else {\r
+                InitDialSettingDefault();\r
+                return;\r
+            }\r
+\r
+            setValue = strtok_s(nullptr, ",", &setBuffer);\r
+            if (setValue != nullptr) {\r
+                dialSetting.dialId = atoi(setValue);\r
+            } else {\r
+                InitDialSettingDefault();\r
+                return;\r
+            }\r
+\r
+            setValue = strtok_s(nullptr, ",", &setBuffer);\r
+            if (setValue != nullptr) {\r
+                dialSetting.dialFullName = setValue;\r
+                if (!((dialSetting.dialFullName.length() > 0) &&\r
+                    (access(dialSetting.dialFullName.c_str(), F_OK) == 0))) {\r
+                    InitDialSettingDefault();\r
+                    return;\r
+                }\r
+            } else {\r
+                InitDialSettingDefault();\r
+                return;\r
+            }\r
+        } else {\r
+            InitDialSettingDefault();\r
+        }\r
+    }\r
+\r
+    DialSetting& MainModel::GetDialSetting()\r
+    {\r
+        return dialSetting;\r
+    }\r
+}
\ No newline at end of file
index e3ad3fd..0cef9ed 100755 (executable)
@@ -23,9 +23,7 @@
 #include "ModelDialDataFactory.h"
 #include "PresenterTask.h"
 #include "DialModelTime.h"
-#if USE_OFFLINE_DIAL
 #include "DialViewGroup.h"
-#endif
 #include "ui_service.h"
 
 namespace OHOS {
@@ -133,6 +131,21 @@ bool MainPresenterSample::OnClick(UIView &view, const ClickEvent &event)
     return true;
 }
 
+bool MainPresenterSample::OnLongPress(UIView& view, const LongPressEvent& event)
+{
+    UNUSED(event);
+    UNUSED(view);
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainPresenterSample OnLongPress");
+    uint8_t cardId = view_->GetHorCurrentCard();
+    if (cardId != WATCH_FACE ) {
+        SetCardModel::GetInstance().SetSelectedCard(cardId);
+        NativeAbility::GetInstance().ChangeSlice(VIEW_SET_CARD);        
+    } else {
+        NativeAbility::GetInstance().ChangeSlice(VIEW_SET_DIAL);
+    }
+    return true;
+}
+
 void MainPresenterSample::SetPage(int8_t id)
 {
     if (view_ != nullptr) {
@@ -140,18 +153,20 @@ void MainPresenterSample::SetPage(int8_t id)
     }
 }
 
-void MainPresenterSample::SetTaskPeroid(int page)
+void MainPresenterSample::SetTaskPeroid(CardId cardId)
 {
-    if (page == COMPASS) {
+    if (cardId == COMPASS) {
         PresenterTask::GetInstance()->SetPeriod(DEFAULT_TASK_PERIOD);
-    } else if (page == WATCH_FACE) {
-#if USE_OFFLINE_DIAL
-        uint32_t time = dynamic_cast<DialViewGroup*>(view_->GetViewById(WATCH_FACE))->GetPeriod();
-#else
-        uint32_t time = DEFAULT_TASK_PERIOD;
-#endif
+    } else if (cardId == WATCH_FACE) {
+        uint32_t time;
+        DialSetting &setting = GetDialSetting();
+        if (setting.dialFlag) {
+            time = dynamic_cast<DialViewGroup*>(view_->GetViewById(WATCH_FACE))->GetPeriod();
+        } else {
+            time = DEFAULT_TASK_PERIOD;
+        }
         PresenterTask::GetInstance()->SetPeriod(time);
-    } else if (page == MUSIC_PLAYER) {
+    } else if (cardId == MUSIC_PLAYER) {
         PresenterTask::GetInstance()->SetPeriod(PLAYER_PERIOD);
     } else {
         PresenterTask::GetInstance()->SetPeriod(MAX_PERIOD);
@@ -161,10 +176,10 @@ void MainPresenterSample::SetTaskPeroid(int page)
 void MainPresenterSample::OnSwipe(UISwipeView &view)
 {
     UNUSED(view);
-    int page = view_->GetHorCurrentPage();
+    CardId cardId = view_->GetHorCurrentCard();
     callback_->OnSwipe(view);
-    SetTaskPeroid(page);
-    if (page == COMPASS) {
+    SetTaskPeroid(cardId);
+    if (cardId == COMPASS) {
         if (!isCompassSensorOpened_) {
             CompassModel::GetInstance()->OpenCompassSensor();
             isCompassSensorOpened_ = true;
@@ -205,6 +220,12 @@ void MainPresenterSample::SetCircleProgress()
     }
     state_ = playersView->GetPlayerButtonState();
     if (state_ == UICheckBox::UICheckBoxState::SELECTED) {
+        int32_t playerState;
+        PlayersModel::GetInstance()->GetPlayerCtr()->GetPlayerState(playerState);
+        if (playerState != PLAYER_STARTED) {
+            playersView->SetPlayerButtonState(UICheckBox::UICheckBoxState::UNSELECTED);
+            return;
+        }
         PlayersModel::GetInstance()->GetPlayerCtr()->GetCurrentTime(playerCurrentTime_);
         PlayersModel::GetInstance()->GetDuration(playerMusicDuration_);
         if (playerMusicDuration_ != 0) {
@@ -229,18 +250,44 @@ void MainPresenterSample::SetCompassRotate()
 
 void MainPresenterSample::Notify(void)
 {
-    if (view_->GetHorCurrentPage() == COMPASS) {
+    CardId cardId = view_->GetHorCurrentCard();
+    if (cardId == COMPASS) {
         SetCompassRotate();
-    } else if (view_->GetHorCurrentPage() == MUSIC_PLAYER) {
+    } else if (cardId == MUSIC_PLAYER) {
         SetCircleProgress();
-    } else if (view_->GetHorCurrentPage() == WATCH_FACE) {
-#if USE_OFFLINE_DIAL
-        DialModelTime::GetInstance()->UpdateTime();
-        dynamic_cast<DialViewGroup*>(view_->GetViewById(WATCH_FACE))->UpdateViewsByPeriodicUpdateData();
-#else
-        dynamic_cast<MainClockView*>(view_->GetViewById(WATCH_FACE))->UpdateTime();
-#endif
+    } else if (cardId == WATCH_FACE) {
+        DialSetting &setting = GetDialSetting();
+        if (setting.dialFlag) {
+            DialModelTime::GetInstance()->UpdateTime();
+            dynamic_cast<DialViewGroup*>(view_->GetViewById(WATCH_FACE))->UpdateViewsByPeriodicUpdateData();
+        } else {
+            dynamic_cast<MainClockView*>(view_->GetViewById(WATCH_FACE))->UpdateTime();
+        }
     }
 }
 
+void MainPresenterSample::InitCardSettings(void)
+{
+    MainModel::GetInstance().InitCardSettings();
+}
+
+uint8_t MainPresenterSample::GetCardSettingCount(void)
+{
+    return MainModel::GetInstance().GetCardSettingCount();
+}
+
+CardId *MainPresenterSample::GetCardSettings(void)
+{
+    return MainModel::GetInstance().GetCardSettings();
+}
+
+void MainPresenterSample::InitDialSettings(void)
+{
+    return MainModel::GetInstance().InitDialSettings();
+}
+DialSetting& MainPresenterSample::GetDialSetting()
+{
+    return MainModel::GetInstance().GetDialSetting();
+}
+
 }
index 6be82a6..b540ca6 100755 (executable)
@@ -22,7 +22,7 @@ struct MainViewMapper {
     UICardPage *(MainViewSample::*func)(void);
 };
 
-static const MainViewMapper PageMapper[] = {
+static const MainViewMapper CardMapper[] = {
     {WATCH_FACE, &MainViewSample::InitWatchFacePage},
     {HEART_RATE, &MainViewSample::InitHeartRatePage},
     {COMPASS, &MainViewSample::InitCompassPage},
@@ -92,6 +92,11 @@ MainViewSample::~MainViewSample()
         compassControlView = nullptr;
     }
 
+    if (callback != nullptr) {
+        delete callback;
+        callback = nullptr;
+    }
+
     g_pMainView = nullptr;
 }
 
@@ -138,31 +143,44 @@ void MainViewSample::OnStart()
 bool MainViewSample::HorizontalViewInit(void)
 {
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::HorizontalViewInit");
-    UISwipeView::OnSwipeListener *listener = nullptr;
-
-    for (int16_t i = 0; i < MAX_CARD; i++) {
-        recordCard[i] = (this->*(PageMapper[i].func))();
-        if (recordCard[i] == nullptr) {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainViewSample:: recordCard %d error", i);
-            return false;
+    presenter_->InitDialSettings();
+    presenter_->InitCardSettings();
+    uint8_t cardSettingNum = presenter_->GetCardSettingCount();
+    CardId *cardSettings = presenter_->GetCardSettings();
+    uint8_t cardMapNumber = sizeof(CardMapper) / sizeof(CardMapper[0]);
+    for (int16_t i = 0; i < cardSettingNum; i++) {
+        for (uint8_t j = 0; j < cardMapNumber; j++) {
+            if (cardSettings[i] == CardMapper[j].id) {
+                recordCard[j] = (this->*(CardMapper[j].func))();
+                if (recordCard[j] == nullptr) {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                                  "MainViewSample:: recordCard %d error", j);
+                    return false;
+                }
+                WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
+                              "MainViewSample:: recordCard[%d]:%p", j, recordCard[j]);
+                break;
+            }
         }
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample:: recordCard[%d]:%p", i, recordCard[i]);
-    }
-
-    listener = static_cast<UISwipeView::OnSwipeListener *>(MainPresenterSample::GetInstance());
-    if (listener == nullptr) {
-        return false;
     }
-    MainPresenterSample::GetInstance()->setCallback(callback);
-    mainSwipeGroup->SetOnSwipeListener(listener);
+    presenter_->setCallback(callback);
+    mainSwipeGroup->SetOnSwipeListener(presenter_);
+    mainSwipeGroup->SetOnLongPressListener(presenter_);
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::InitPage over");
     return true;
 }
 
 void MainViewSample::HorViewLoad(void)
 {
-    for (int16_t i = 0; i < MAX_CARD; i++) {
-        mainSwipeGroup->HorAdd(recordCard[i]);
+    uint8_t cardSettingNum = presenter_->GetCardSettingCount();
+    CardId *cardSettings = presenter_->GetCardSettings();
+    for (int16_t i = 0; i < cardSettingNum; i++) {
+        CardId cardId = cardSettings[i];
+        if (recordCard[cardId] != nullptr) {
+            mainSwipeGroup->HorAdd(recordCard[cardId]);
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample:: HorViewLoad cardid = %d ViewIndex = %d",
+                          cardId, recordCard[cardId]->GetViewIndex());
+        }
     }
 }
 
@@ -239,18 +257,31 @@ void MainViewSample::OnStop()
     return;
 }
 
+UICardPage *MainViewSample::InitWathOffDial(DialSetting &setting)
+{
+    DialViewGroup *dial = new DialViewGroup();
+    dial->SetDial(setting.dialFullName);
+    return dial;
+}
+
+UICardPage *MainViewSample::InitWathDial(DialSetting &setting)
+{
+    switch (setting.dialId) {
+        case DIAL_CLOCK:
+            return new MainClockView();
+        default:
+            return nullptr;
+    }
+}
+
 UICardPage *MainViewSample::InitWatchFacePage(void)
 {
-#if USE_OFFLINE_DIAL
-    mainClockView = new DialViewGroup();
-    std::string filePath = dynamic_cast<MainPresenterSample*>(presenter_)->GetDialPath();
-    if (filePath.size() == 0) {
-        filePath = RES_PATH"maomao.bin";
+    DialSetting &setting = presenter_->GetDialSetting();
+    if (setting.dialFlag) {
+        mainClockView = InitWathOffDial(setting);
+    } else {
+        mainClockView = InitWathDial(setting);
     }
-    mainClockView->SetDial(filePath);
-#else
-    mainClockView = new MainClockView();
-#endif
 
     if (mainClockView == nullptr) {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainClockView new fail");
@@ -299,7 +330,6 @@ UICardPage *MainViewSample::InitMusicPlayerPage(void)
     return playersView;
 }
 
-
 void MainViewSample::SetPage(int16_t page)
 {
     if (mainSwipeGroup != nullptr) {
@@ -307,17 +337,28 @@ void MainViewSample::SetPage(int16_t page)
     }
 
     if (presenter_ != nullptr) {
-        presenter_->SetTaskPeroid(page);
+        CardId *cardSettings = presenter_->GetCardSettings();
+        /* page 与CardId 没有对应关系,需要一次转换 */
+        presenter_->SetTaskPeroid(cardSettings[page]);
     }
 }
 
 bool MainViewSample::IsMainClockPage(void)
 {
-    if (mainSwipeGroup->GetCurrentPageId(0) == WATCH_FACE &&
+    if (mainSwipeGroup->GetCurrentPageId(0) == mainClockView->GetViewIndex() &&
         mainSwipeGroup->GetCurrentPageId(1) == 1) { // 0: horizontal; 1: vertical
         return true;
     } else {
         return false;
     }
 }
+
+CardId MainViewSample::GetHorCurrentCard() const
+{
+    CardId *cardSettings = presenter_->GetCardSettings();
+    int pageId = mainSwipeGroup->GetCurrentPageId(UISwipeView::HORIZONTAL); // 0: horizontal; 1: vertical
+    /* pageId 与CardId 没有对应关系,需要一次转换 */
+    return cardSettings[pageId];
+}
+
 }
index e35841c..ca79d10 100755 (executable)
 #include "bts_avrcp_controller.h"\r
 #include "bts_avrcp_target.h"\r
 #include "notification_manager.h"\r
+#include "BluetoothHeadsetEvent.h"\r
+#include "bts_avrcp_controller.h"\r
 \r
 namespace OHOS {\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
 static VolumeSliderEventListener *g_pVolumeSliderEventListener = nullptr;\r
 \r
 constexpr int16_t SOUND_CHANGE = 10;\r
@@ -46,51 +53,18 @@ bool VolumeSliderEventListener::OnClick(UIView& view, const ClickEvent& event)
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnClick OnClick");\r
     if (strcmp(view.GetViewId(), INCREASE_BUTTON) == 0) {\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GetIncreaseButton OnClick");\r
-        ChangeVolume(VOLUMELEVATED);\r
+        ChangeVolume(VOLUMEUP);\r
     } else if (strcmp(view.GetViewId(), DECREASE_BUTTON) == 0) {\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GetDecreaseButton OnClick");\r
-        ChangeVolume(VOLUMELOWERS);\r
+        ChangeVolume(VOLUMEDOWN);\r
     } else if (strcmp(view.GetViewId(), VOLUME_PROGRESS) == 0) {\r
-        ChangeImage();\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GetDragButton OnClick");\r
         ChangeVolume(VOLUMEDRAG);\r
     }\r
     return true;\r
 }\r
 \r
-void VolumeSliderEventListener::ChangeImage()\r
-{\r
-    ImageInfo *image;\r
-    VolumeSettingView *volumeSettingView = VolumeSettingView::GetInstance();\r
-    if (volumeSettingView == nullptr) {\r
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ChangeImage:volumeSettingView new fail");\r
-        return;\r
-    }\r
-    UISlider *progress = volumeSettingView->GetProgress();\r
-    if (progress == nullptr) {\r
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ChangeImage:progress new fail");\r
-        return;\r
-    }\r
-    UIButton *decrease = volumeSettingView->GetDecreaseButton();\r
-    if (decrease == nullptr) {\r
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ChangeImage:decrease new fail");\r
-        return;\r
-    }\r
-\r
-    volumeSettingView->sounding = progress->GetValue();\r
-    if (volumeSettingView->sounding == 0) {\r
-        image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_MUTE_BUTTON, PLAYER_IAMGES);\r
-        decrease->SetImageSrc(image, image);\r
-        // 刷新UI\r
-        decrease->Invalidate();\r
-    } else {\r
-        image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_DECREASE_BUTTON, PLAYER_IAMGES);\r
-        decrease->SetImageSrc(image, image);\r
-        // 刷新UI\r
-        decrease->Invalidate();\r
-    }\r
-}\r
-\r
-void VolumeSliderEventListener::ChangeVolume(uint8_t status)\r
+void VolumeSliderEventListener::ChangeVolume(VolumeChangeStatus status)\r
 {\r
     ImageInfo *image;\r
     VolumeSettingView *volumeSettingView = VolumeSettingView::GetInstance();\r
@@ -110,7 +84,7 @@ void VolumeSliderEventListener::ChangeVolume(uint8_t status)
     }\r
 \r
     preSound = volumeSettingView->sounding;\r
-    if (status == 1) {\r
+    if (status == VOLUMEUP) {\r
         volumeSettingView->sounding  = progress->GetValue() + SOUND_CHANGE;\r
         if (volumeSettingView->sounding > VOLUME_MAX) {\r
             volumeSettingView->sounding = VOLUME_MAX;\r
@@ -119,19 +93,45 @@ void VolumeSliderEventListener::ChangeVolume(uint8_t status)
         decrease->SetImageSrc(image, image);\r
         // 刷新UI\r
         decrease->Invalidate();\r
-    } else if (status == 0) {\r
+        progress->SetValue(volumeSettingView->sounding);\r
+    } else if (status == VOLUMEDOWN) {\r
         volumeSettingView->sounding = progress->GetValue() - SOUND_CHANGE;\r
         if (volumeSettingView->sounding < VOLUME_MIN) {\r
             volumeSettingView->sounding = VOLUME_MIN;\r
         }\r
+        if (volumeSettingView->sounding == VOLUME_MIN &&\r
+            (playerCoefficients == VOLUMEPHONE || playerCoefficients == VOLUMEPHONENOTIFY)) {\r
+            // 通话场景音量不能设置为0\r
+            volumeSettingView->sounding = SOUND_CHANGE;\r
+        }\r
         if ((volumeSettingView->sounding == 0) && (preSound != 0)) {\r
             image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_MUTE_BUTTON, PLAYER_IAMGES);\r
             decrease->SetImageSrc(image, image);\r
             // 刷新UI\r
             decrease->Invalidate();\r
         }\r
+        progress->SetValue(volumeSettingView->sounding);\r
+    } else if (status == VOLUMEDRAG) {\r
+        volumeSettingView->sounding = progress->GetValue();\r
+        if (volumeSettingView->sounding == VOLUME_MIN &&\r
+            (playerCoefficients == VOLUMEPHONE || playerCoefficients == VOLUMEPHONENOTIFY)) {\r
+            // 通话场景音量不能设置为0\r
+            volumeSettingView->sounding = SOUND_CHANGE;\r
+            progress->SetValue(volumeSettingView->sounding);\r
+        }\r
+        if (volumeSettingView->sounding == 0) {\r
+            image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_MUTE_BUTTON, PLAYER_IAMGES);\r
+            decrease->SetImageSrc(image, image);\r
+            // 刷新UI\r
+            decrease->Invalidate();\r
+        } else {\r
+            image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_DECREASE_BUTTON, PLAYER_IAMGES);\r
+            decrease->SetImageSrc(image, image);\r
+            // 刷新UI\r
+            decrease->Invalidate();\r
+        }\r
     }\r
-    progress->SetValue(volumeSettingView->sounding);\r
+\r
     if (playerCoefficients == VOLUMEPLAYERS) {\r
         BtAndLocalVolumeSet(volumeSettingView->sounding);\r
     }\r
@@ -142,16 +142,22 @@ void VolumeSliderEventListener::ChangeVolume(uint8_t status)
     }\r
 }\r
 \r
+extern BtAvrcpTgInf g_avrcp_srv_inf;\r
 void VolumeSliderEventListener::BtAndLocalVolumeSet(int16_t sounding)\r
 {\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BtAndLocalVolumeSet %d", sounding);\r
-    AudioManager::GetInstance().SetVolume(AUDIO_STREAM_MUSIC, sounding); // 本地音量设置\r
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BtAndLocalVolumeSet %d", sounding);\r
+    if (g_avrcp_srv_inf.avrcp_srv_conn_stat == PROFILE_STATE_CONNECTED) {\r
+        uint8_t volume = sounding * AVRCP_ABSOLUTE_VOLUME_PERCENTAGE_100 / 100; // 100:本地音量最大值\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "volume 0x%x", volume);\r
+        (void)avrcp_ct_set_absolute_volume(&(g_avrcp_srv_inf.bd_addr), volume); // 手表音量设置同步远端BT音量\r
+    } else {\r
+        AudioManager::GetInstance().SetVolume(AUDIO_STREAM_MUSIC, sounding); // 本地音量设置\r
+    }\r
 }\r
 \r
 void VolumeSliderEventListener::OnRelease(int32_t value)\r
 {\r
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnRelease %d", value);\r
-    ChangeImage();\r
     ChangeVolume(VOLUMEDRAG);\r
 }\r
 \r
@@ -163,7 +169,6 @@ void VolumeSliderEventListener::SetPlayerCoefficients(int16_t value)
 void VolumeSliderEventListener::OnChange(int32_t value)\r
 {\r
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnChange %d", value);\r
-    ChangeImage();\r
     ChangeVolume(VOLUMEDRAG);\r
 }\r
 \r
@@ -207,4 +212,7 @@ bool VolumeSliderEventListener::OnDrag(UIView& view, const DragEvent& event)
     }\r
     return true;\r
 }\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
 }
\ No newline at end of file
index 3316e96..6e54b0a 100644 (file)
@@ -29,6 +29,7 @@
 #include "DialBoxProgressView.h"\r
 #include "DialArcProgressView.h"\r
 #include "DialArcLabelView.h"\r
+#include "DialKaleidoscopeView.h"\r
 \r
 namespace OHOS {\r
 DialBinParser::DialBinParser()\r
@@ -44,6 +45,7 @@ DialBinParser::DialBinParser()
     funcArray_[8] = &DialBinParser::ParserDialArcProgress; // 8: index\r
     funcArray_[9] = &DialBinParser::ParserDialVideo; // 9: index\r
     funcArray_[10] = &DialBinParser::ParserDialClick; // 10: index\r
+    funcArray_[11] = &DialBinParser::ParserDialKaleidoscope; // 11: index\r
 }\r
 \r
 DialBinParser::~DialBinParser()\r
@@ -76,6 +78,39 @@ DialBinParser* DialBinParser::GetInstance(void)
     return &instance;\r
 }\r
 \r
+bool DialBinParser::GetDialPreviewInfo(FILE* fp, DialPreviewInfo* info)\r
+{\r
+    if (fp == nullptr || info == nullptr) {\r
+        GRAPHIC_LOGE("Get dial preview fail, param error!\n");\r
+        return false;\r
+    }\r
+\r
+    DialHeader* dialHeader = static_cast<DialHeader*>(MallocAndReadBuf(fp, sizeof(DialHeader)));\r
+    if (dialHeader == nullptr) {\r
+        GRAPHIC_LOGE("[%s: %d]malloc or read fail!\n", __FUNCTION__, __LINE__);\r
+        return false;\r
+    }\r
+\r
+    if (memcpy_s(info->dialName, DIAL_NAME_MAX_LEN, dialHeader->dialName, DIAL_NAME_MAX_LEN) != EOK) {\r
+        GRAPHIC_LOGE("[%s: %d]memcpy_s dial name fail!\n", __FUNCTION__, __LINE__);\r
+        free(dialHeader);\r
+        return false;\r
+    }\r
+\r
+    if (memcpy_s(info->description, DIAL_DESCRIPTION_MAX_LEN,\r
+        dialHeader->description, DIAL_DESCRIPTION_MAX_LEN) != EOK) {\r
+        GRAPHIC_LOGE("[%s: %d]memcpy_s dial description fail!\n", __FUNCTION__, __LINE__);\r
+        free(dialHeader);\r
+        return false;\r
+    }\r
+\r
+    info->imgId =  dialHeader->previewImgId | dirId_;\r
+    info->offset = dialHeader->imageOffset;\r
+\r
+    free(dialHeader);\r
+    return true;\r
+}\r
+\r
 bool DialBinParser::UpdateDial(const std::string& file, FILE* fp, DialViewGroup* group)\r
 {\r
     if (fp == nullptr) {\r
@@ -340,8 +375,8 @@ int32_t DialBinParser::ParserDialDigitalImg(FILE* fp)
         fseek(fp, curReadPt, SEEK_SET);\r
     }\r
 \r
-    ImageInfo* numInfoArray[DIGITALIMG_IMG_MAX_NUM] = {};\r
-    for (uint16_t i = 0; i < DIGITALIMG_IMG_MAX_NUM; i++) {\r
+    ImageInfo* numInfoArray[DIAL_DIGITALIMG_IMG_MAX_NUM] = {};\r
+    for (uint16_t i = 0; i < DIAL_DIGITALIMG_IMG_MAX_NUM; i++) {\r
         resId = data->imgIds[i] | dirId_;\r
         curReadPt = ftell(fp);\r
         numInfoArray[i] = ImageCacheManager::GetInstance().LoadOneInMultiRes(resId,\r
@@ -355,7 +390,7 @@ int32_t DialBinParser::ParserDialDigitalImg(FILE* fp)
         fseek(fp, curReadPt, SEEK_SET);\r
     }\r
     view->SetParent(dialGroup_);\r
-    view->SetNumRes(const_cast<const ImageInfo**>(numInfoArray), DIGITALIMG_IMG_MAX_NUM);\r
+    view->SetNumRes(const_cast<const ImageInfo**>(numInfoArray), DIAL_DIGITALIMG_IMG_MAX_NUM);\r
     dialGroup_->AddView(static_cast<DialDataType>(data->bindData), view, data->isPeriod);\r
 \r
     UIFree(data);\r
@@ -444,7 +479,11 @@ bool DialBinParser::SetProgressType(FILE* fp, UIAbstractProgress* view, DialProg
         fseek(fp, curReadPt, SEEK_SET);\r
         view->SetImage(foregroundInfo, nullptr);\r
     } else if (data.type == 1) {\r
-        view->SetForegroundStyle(STYLE_BACKGROUND_COLOR, data.color.full);\r
+        if (view->GetViewType() == UI_BOX_PROGRESS) {\r
+            view->SetForegroundStyle(STYLE_BACKGROUND_COLOR, data.color.full);\r
+        } else if (view->GetViewType() == UI_CIRCLE_PROGRESS) {\r
+            view->SetForegroundStyle(STYLE_LINE_COLOR, data.color.full);\r
+        }\r
     } else if (data.type == 2) { // 2: gradient\r
         ColorStop* stopArray = static_cast<ColorStop*>(MallocAndReadBuf(fp, (sizeof(ColorStop) * data.stopCount)));\r
         if (stopArray == nullptr) {\r
@@ -567,4 +606,40 @@ int32_t DialBinParser::ParserDialClick(FILE* fp)
 \r
     return 0;\r
 }\r
-}
\ No newline at end of file
+\r
+int32_t DialBinParser::ParserDialKaleidoscope(FILE* fp)\r
+{\r
+    if (fp == nullptr) {\r
+        GRAPHIC_LOGE("Parser dial option image fail, file is nullptr!\n");\r
+        return -1;\r
+    }\r
+\r
+    DialKaleidoscope* data = static_cast<DialKaleidoscope*>(MallocAndReadBuf(fp, sizeof(DialKaleidoscope)));\r
+    if (data == nullptr) {\r
+        GRAPHIC_LOGE("[%s: %d]malloc or read fail!\n", __FUNCTION__, __LINE__);\r
+        return -1;\r
+    }\r
+\r
+    DialKaleidoscopeView* view = new DialKaleidoscopeView();\r
+    uint32_t resId = data->imgId | dirId_;\r
+    uint32_t curReadPt = ftell(fp);\r
+    ImageInfo* imgInfo = ImageCacheManager::GetInstance().LoadOneInMultiRes(resId,\r
+        file_, fp, false, imageOffset_);\r
+    if (imgInfo == nullptr) {\r
+        GRAPHIC_LOGE("[%s: %d]load img fail! file: %s resId: %x\n",\r
+            __FUNCTION__, __LINE__, file_.c_str(), resId);\r
+        return false;\r
+    }\r
+    fseek(fp, curReadPt, SEEK_SET);\r
+\r
+    view->SetSrc(imgInfo);\r
+    view->RequestFocus();\r
+    view->SetRotateEventFactor(data->crownRotateStep); // 0.2: rotate event factor\r
+    view->SetRotateAnimatorValue(data->animatorRotateStep); // 0.1: rotate animator value\r
+    view->StartRotateAnimator();\r
+    dialGroup_->AddView(view);\r
+\r
+    UIFree(data);\r
+    return 0;\r
+}\r
+}\r
index 07d41f3..a156394 100755 (executable)
@@ -568,9 +568,6 @@ static void BtDisconnectedPro(void)
     PhoneServiceErrorCallback(ERROR_BT, PROFILE_STATE_DISCONNECTED);
     CallListInit();
 
-    // 释放媒体资源
-    PostGraphicEvent(AudioRelease);
-
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BtDisconnectedPro callState: %d", g_currCallState);
     if (g_currCallState == HFP_HF_CALL_STATE_INCOMING) {
         /* 处理呼入阶段,取消手表配对 */
@@ -732,7 +729,7 @@ static int GetCallLogFileSize(void)
 }
 
 // 添加通话进通话记录文件
-void AddToCallLog(CallLogInfo *info)
+static void AddToCallLog(CallLogInfo *info)
 {
     FILE *fp = NULL;
     size_t ret;
@@ -1245,7 +1242,7 @@ static void CallChangeActivePro(const hfp_hf_calls_info_t *call)
     if (phoneCall->operate == OPERATE_PHONE_ACTIVE) {
         // 发布电话接听事件,手表关闭来电通知
         HfpIncomingEventPublish(TOPIC_EVENT_HFP_PHONE_ACTIVE, phoneCall->unitCalls);
-    } else if (phoneCall->operate == OPERATE_WATCH_ACTIVE) {
+    } else if (phoneCall->operate == OPERATE_WATCH_ACTIVE && g_scoFlag == HFP_SCO_STATE_CONNECTED) {
         // 发布手表接听事件,通知切换接听界面
         HfpIncomingEventPublish(TOPIC_EVENT_HFP_WATCH_ACTIVE, phoneCall->unitCalls);
     }
@@ -1453,37 +1450,34 @@ static void CallStateChanged(const bd_addr_t *bdAddr, const hfp_hf_calls_info_t
     }
 
     if (g_currCallNum == 0) {
-        PostGraphicEvent(AudioRelease);
         g_completeCallFlag = false;
     }
 }
 
-static int g_hfpVolumeType;
-static unsigned char g_hfpVolume;
-
-static void BtHfpVolumeChanged(void)
+static void BtHfpVolumeChanged(int volumeType, unsigned char hfpVolume)
 {
-    int maxVolume, minVolume, tmp;
+    int maxVolume, minVolume, volume;
     bool ret;
 
     // mic
-    if (g_hfpVolumeType == HFP_VOLUME_MIC) {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[BtHfpVolumeChanged] g_hfpVolumeType = %d, g_hfpVolume = %d  ",
-            g_hfpVolumeType, g_hfpVolume);
+    if (volumeType == HFP_VOLUME_MIC) {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VolumeChanged Type = %d, hfpVolume = %d",
+            volumeType, hfpVolume);
     }
 
     // speak
-    if (g_hfpVolumeType == HFP_VOLUME_SPEAKER) {
+    if (volumeType == HFP_VOLUME_SPEAKER) {
         minVolume = PhoneAudioGetMinVolume();
         maxVolume = PhoneAudioGetMaxVolume();
-        tmp = g_hfpVolume * (maxVolume - minVolume) / CALL_VOLUME_MAX; // 转换
-
-        ret = PhoneAudioSetVolume(tmp);
+        volume = hfpVolume * (maxVolume - minVolume) / CALL_VOLUME_MAX; // 转换
+        volume = (volume == 0) ? ((maxVolume - minVolume) / CALL_VOLUME_MAX) : volume;
+        ret = PhoneAudioSetVolume(volume);
         if (ret != true) {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[BtHfpVolumeChanged] g_hfpVolumeType: %d, ret: %d", g_hfpVolumeType, ret);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VolumeChanged Type: %d, ret: %d",
+                          volumeType, ret);
         }
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[BtHfpVolumeChanged] g_hfpVolumeType: %d, minVolume: %d, maxVolume: %d tmp: %d\
-            ret: %d ", g_hfpVolumeType, minVolume, maxVolume, tmp, ret);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VolumeChanged Type: %d, min: %d, max: %d volume: %d ret: %d",
+                      volumeType, minVolume, maxVolume, volume, ret);
     }
 }
 
@@ -1491,10 +1485,8 @@ static void BtHfpVolumeChanged(void)
 static void VolumeChanged(const bd_addr_t *bdAddr, hfp_volume_type_t type, unsigned char volume)
 {
     UNUSED(bdAddr);
-    g_hfpVolumeType = type;
-    g_hfpVolume = volume;
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[VolumeChanged] type = %d volume = %d", type, volume);
-    PostGraphicEvent(BtHfpVolumeChanged); // 解决SdkMsgThread爆栈问题
+    GraphicService::GetInstance()->PostGraphicEvent(std::bind(BtHfpVolumeChanged, type, volume));
 }
 
 // 拨号失败回调
@@ -1794,71 +1786,53 @@ int GetCallInfoInCallList(PhoneCallInfo callList[], int listNum, int *retNum)
     return OHOS_SUCCESS;
 }
 
-static unsigned char g_changeSpkVolume;
-
-static void GetCallCurrVolumeEvent(void)
+// 获取当前通话音量大小 (0 - 15)
+// hfp音量范围 0-15, media 音量范围 0-100
+unsigned char GetCallCurrVolume(void)
 {
     int volume;
     int minVolume;
     int maxVolume;
-    unsigned char tmp;
+    unsigned char hfpVolume;
 
     volume = PhoneAudioGetVolume();
     minVolume = PhoneAudioGetMinVolume();
     maxVolume = PhoneAudioGetMaxVolume();
-    tmp = (unsigned char)((volume * CALL_VOLUME_MAX) / (maxVolume - minVolume)); // 转换
+    hfpVolume = (unsigned char)((volume * CALL_VOLUME_MAX) / (maxVolume - minVolume)); // 转换
 
-    if (volume != 0 && tmp == 0) {
-        tmp = 1;
+    if (volume != 0 && hfpVolume == 0) {
+        hfpVolume = 1;
     }
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[GetCallCurrVolumeEvent] volume = %d, minVolume = %d, maxVolume = %d, tmp = %d",
-        volume, minVolume, maxVolume, tmp);
-    g_changeSpkVolume = tmp;
-}
-
-// 获取当前通话音量大小 (0 - 15)
-unsigned char GetCallCurrVolume(void)
-{
-    GetCallCurrVolumeEvent();
-    return g_changeSpkVolume;
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[GetCallCurrVolume] volume = %d, minVolume = %d, maxVolume = %d, hfpVolume = %d",
+        volume, minVolume, maxVolume, hfpVolume);
+    return hfpVolume;
 }
 
-static void SetSpeakerVolumeEvent(void)
+void SetSpeakerVolume(unsigned char hfpVolume)
 {
-    int ret, minVolume, maxVolume, tmp;
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[SetSpeakerVolume] start, hfpVolume = %d", hfpVolume);
+    int ret, minVolume, maxVolume, volume;
 
     minVolume = PhoneAudioGetMinVolume();
     maxVolume = PhoneAudioGetMaxVolume();
-    tmp = g_changeSpkVolume * (maxVolume - minVolume) / CALL_VOLUME_MAX; // 转换
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[SetSpeakerVolumeEvent] minVolume = %d, maxVolume = %d, tmp = %d",
-        minVolume, maxVolume, tmp);
+    volume = hfpVolume * (maxVolume - minVolume) / CALL_VOLUME_MAX; // 转换
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[SetSpeakerVolume] minVolume = %d, maxVolume = %d, volume = %d",
+        minVolume, maxVolume, volume);
 
-    ret = PhoneAudioSetVolume(tmp);
+    ret = PhoneAudioSetVolume(volume);
     if (ret != true) {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SetSpeakerVolumeEvent] PhoneAudioSetVolume ret = %d", ret);
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SetSpeakerVolume] PhoneAudioSetVolume ret = %d", ret);
         return;
     }
 
-    ret = hfp_hf_set_volume(&g_bdAddr, HFP_VOLUME_SPEAKER, g_changeSpkVolume);
+    ret = hfp_hf_set_volume(&g_bdAddr, HFP_VOLUME_SPEAKER, hfpVolume);
     if (ret != ERRCODE_BT_SUCCESS) {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SetSpeakerVolumeEvent] hfp_hf_set_volume fail ret = %d, g_changeSpkVolume = %d",
-            ret, g_changeSpkVolume);
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SetSpeakerVolume] set_volume fail ret = %d, hfpVolume = %d",
+            ret, hfpVolume);
         return;
     }
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[SetSpeakerVolumeEvent] success!");
-}
-
-// 设置手表通话Speaker音量:0 - 15
-void SetSpeakerVolume(unsigned char volume)
-{
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[SetSpeakerVolume] start, volume = %d", volume);
-    if (volume > CALL_VOLUME_MAX) {
-        g_changeSpkVolume = CALL_VOLUME_MAX;
-    } else {
-        g_changeSpkVolume = volume;
-    }
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[SetSpeakerVolume] success!");
 
-    SetSpeakerVolumeEvent();
     return;
 }
 
index cdafd26..3a22d8c 100755 (executable)
@@ -847,8 +847,6 @@ void PlayerInterruptListener::ResumePlayer(void)
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[PlayerInterruptListener::ResumePlayer] this is in calling");
         return; // 通话界面,禁止音乐恢复播放
     }
-    AudioRelease(); // 适配某些机型不触发SCO
-
     PlayerPostGraphicEvent(Resume);
 }
 
index 78bab7b..ffa8c36 100755 (executable)
 #include "ui_image_view.h"
 
 namespace OHOS {
-typedef enum {
-    WATCH_FACE = 0,
-    HEART_RATE,
-    COMPASS,
-    ACTIVITY,
-    MUSIC_PLAYER,
-    MAX_CARD,
-} CardId;
-
-
-struct CardInfo {
-    int16_t cardId;
-};
-
 class ScreenModels {
 public:
     ScreenModels();
     ~ScreenModels();
     static ScreenModels *GetInstance(void);
- // card funtion
-    bool SetUpListCase(void);
-    bool SaveCardConfig(void);
-    bool InitCardConfig(void);
-    void SetCardConfigDefault(void);
-    int16_t GetCardPage(uint16_t page);
-    bool CardInsertFirst(int32_t card);
-    bool CardDelete(int32_t card);
-    int16_t GetMaxCard(void);
-    int16_t GetLastCardPage(void);
     bool LoadAppImages(std::string file, UIImageView *view, uint32_t resId);
     void PreLoadAppimages(void);
+    void InitKvStorage(void);
 private:
     void LoadAppMultiImages(std::string file, uint32_t startId, uint32_t lastId);
-    List<CardInfo> *listMainView{nullptr};  // record main view pages
-    int16_t maxPage = MAX_CARD;
 };
 }
 #endif
index 082bfc4..5eebb98 100755 (executable)
@@ -11,6 +11,8 @@
 #include "stdio.h"
 #include <fcntl.h>
 #include <unistd.h>
+#include "kvstore_env.h"
+#include "kv_store.h"
 #include "ScreenModels.h"
 #include "common/image_cache_manager.h"
 #include "UiConfig.h"
@@ -32,115 +34,10 @@ ScreenModels *ScreenModels::GetInstance(void)
     return &screenModel;
 }
 
-bool ScreenModels::SetUpListCase(void)
+void ScreenModels::InitKvStorage(void)
 {
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetUpListCase");
-    listMainView = new List<CardInfo>();
-    if (listMainView == nullptr) {
-        return false;
-    }
-    listMainView->Clear();
-    return true;
-}
-
-bool ScreenModels::InitCardConfig(void)
-{
-    if (SetUpListCase() == false) {
-        return false;
-    }
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "InitCardConfig1");
-    int32_t fd = open(CARD_CONFIG_PATH, O_RDWR, S_IRWXU);
-    ListNode<CardInfo> *node;
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "InitCardConfig2");
-    struct CardInfo cardInfoData;
-    if (fd < 0) {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "InitCardConfig open fail");
-        fd = open(CARD_CONFIG_PATH, O_RDWR | O_CREAT, S_IRWXU);
-        if (fd < 0) {
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "InitCardConfig open fail 2");
-            return false;
-        }
-        SetCardConfigDefault();
-        node = listMainView->Begin();
-        for (int32_t i = 0; i < maxPage; i++) {
-            cardInfoData = node->data_;
-            node = node->next_;
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Init write cardInfoData.i:%d ", cardInfoData.cardId);
-            if (write(fd, &cardInfoData, sizeof(CardInfo)) != sizeof(CardInfo)) {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Init SaveGlobalHealthToFile fail");
-            }
-        }
-        close(fd);
-        return true;
-    } else {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "InitCardConfig3");
-        for (int32_t i = 0; i < maxPage; i++) {
-            if (read(fd, &cardInfoData, sizeof(CardInfo)) != sizeof(CardInfo)) {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Init Read GlobalHealthToFile fail");
-            }
-            listMainView->PushBack(cardInfoData);
-        }
-        close(fd);
-        return true;
-    }
-    return false;
-}
-
-bool ScreenModels::SaveCardConfig(void)
-{
-    int32_t fd = open(CARD_CONFIG_PATH, O_RDWR | O_CREAT, S_IRWXU);
-    if (fd < 0) {
-        close(fd);
-        return false;
-    } else {
-        if (write(fd, &listMainView, listMainView->Size()) != listMainView->Size()) {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SaveGlobalHealthToFile fail");
-        }
-        close(fd);
-        return true;
-    }
-}
-
-void ScreenModels::SetCardConfigDefault(void)
-{
-    int16_t i;
-    struct CardInfo cardInfoData;
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardConfigDefault");
-    for (i = 0; i < MAX_CARD; i++) {
-        cardInfoData.cardId = i;
-        listMainView->PushBack(cardInfoData);
-    }
-}
-
-int16_t ScreenModels::GetCardPage(uint16_t page)
-{
-    ListNode<CardInfo> *node = listMainView->Begin();
-    for (uint8_t i = 0; i < page; i++) {
-        if (node->next_ != NULL) {
-            node = node->next_;
-        } else {
-            return -1;
-        }
-    }
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GetCardPage cardId:%d", node->data_.cardId);
-    return node->data_.cardId;
-}
-
-int16_t ScreenModels::GetLastCardPage(void)
-{
-    ListNode<CardInfo> *node = listMainView->Begin();
-    for (uint8_t i = 0; i < MAX_CARD; i++) {
-        if (node->next_ == NULL) {
-            node = node->next_;
-        }
-    }
-    return node->data_.cardId;
-}
-
-int16_t ScreenModels::GetMaxCard(void)
-{
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GetMaxCard maxPage:%d", maxPage);
-    return maxPage;
+    int ret = UtilsSetEnv("/user");
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "UtilsSetEnv /user ret = %d", ret);
 }
 
 void ScreenModels::LoadAppMultiImages(std::string file, uint32_t startId, uint32_t lastId)
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_card/include/SetCardAdapter.h b/code/sdk/application/wearable/nativeapp/nativeui/set_card/include/SetCardAdapter.h
new file mode 100644 (file)
index 0000000..417891c
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SetCardAdapter.h
+ * Author:
+ * Create: 2021-09-18
+ */
+
+#ifndef SET_CARD_ADAPTER_H
+#define SET_CARD_ADAPTER_H
+
+#include <list>
+#include <string>
+#include "components/ui_list.h"
+#include "components/ui_label.h"
+#include "components/ui_view_group.h"
+#include "components/ui_image_view.h"
+#include "components/abstract_adapter.h"
+#include "UiConfig.h"
+#include "wearable_log.h"
+#include "SetCardItem.h"
+
+namespace OHOS {
+class SetCardAdapter : public AbstractAdapter {
+public:
+    explicit SetCardAdapter();
+    virtual ~SetCardAdapter();
+
+    virtual uint16 GetCount(void) override;
+
+    virtual UIView *GetView(UIView *inView, int16 index) override;
+
+    virtual void AddListItem(const CardInfo &item);
+
+    void ClearItem(void);
+
+private:
+    std::list<CardInfo> listData_;
+};
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_card/include/SetCardDeleteView.h b/code/sdk/application/wearable/nativeapp/nativeui/set_card/include/SetCardDeleteView.h
new file mode 100644 (file)
index 0000000..99b0c8c
--- /dev/null
@@ -0,0 +1,26 @@
+/**\r
+ * Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved.\r
+ * Description:\r
+ * Author:\r
+ * Create:\r
+ */\r
+\r
+#ifndef SET_CARD_DELETE_VIEW_H\r
+#define SET_CARD_DELETE_VIEW_H\r
+\r
+#include "components/ui_label_button.h"\r
+#include "SetCardPresenter.h"\r
+\r
+namespace OHOS {\r
+class SetCardDeleteView : public UIViewGroup {\r
+public:\r
+    SetCardDeleteView(SetCardPresenter *presenter);\r
+    virtual ~SetCardDeleteView();\r
+    bool InitView();\r
+private:\r
+    SetCardPresenter *presenter_;\r
+    UILabelButton confirmBtn;\r
+    UILabelButton cancelBtn;\r
+};\r
+}\r
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_card/include/SetCardItem.h b/code/sdk/application/wearable/nativeapp/nativeui/set_card/include/SetCardItem.h
new file mode 100644 (file)
index 0000000..646f24f
--- /dev/null
@@ -0,0 +1,34 @@
+/*\r
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.\r
+ * Description: SetCardItem.h\r
+ * Author:\r
+ * Create: 2021-11-23\r
+ */\r
+\r
+#ifndef SET_CARD_ITEM_H\r
+#define SET_CARD_ITEM_H\r
+\r
+#include <cstdint>\r
+#include <map>\r
+#include "components/ui_view.h"\r
+#include "components/ui_view_group.h"\r
+#include "components/ui_image_view.h"\r
+#include "MainModel.h"\r
+#include "UiConfig.h"\r
+\r
+namespace OHOS {\r
+\r
+class SetCardItem :public UIViewGroup {\r
+public:\r
+    SetCardItem();\r
+    virtual ~SetCardItem();\r
+    void SetItemInfo(const CardInfo &cardInfo);\r
+private:\r
+    void SetUpChild();\r
+    UIImageView cardImg_;\r
+    CardInfo cardInfo_;\r
+};\r
+\r
+}\r
+\r
+#endif // SET_CARD_ITEM_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_card/include/SetCardModel.h b/code/sdk/application/wearable/nativeapp/nativeui/set_card/include/SetCardModel.h
new file mode 100644 (file)
index 0000000..43ed70b
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SetCardModel.h
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#ifndef SET_CARD_MODEL_H
+#define SET_CARD_MODEL_H
+
+#include <cstdint>
+#include <map>
+#include "AppViewIDs.h"
+#include "UiConfig.h"
+#include "SetCardPresenter.h"
+#include "SetCardItem.h"
+
+namespace OHOS {
+    class SetCardModel {
+    public:
+        static SetCardModel &GetInstance(void);
+        uint8_t *GetCardShowList(void);
+        uint8_t GetCardShowCount(void) const;
+        void InitCardShowList(void);
+        void SetSelectedCardIndex(uint8_t cardIndex);
+        uint8_t GetSelectedCardIndex(void) const;
+        void DeleteCardSetting(void);
+        void SetSelectedCard(uint8_t cardId);
+        uint8_t GetSelectedCard(void);
+    private:
+        SetCardModel();
+        SetCardModel(const SetCardModel &);
+        SetCardModel &operator=(const SetCardModel &);
+        virtual ~SetCardModel();
+
+        uint8_t cardShowList[CARD_SETTING_COUNT_MAX] = { 0 };
+        uint8_t cardShowCount{0};
+        uint8_t selectedCardIndex{0};
+        uint8_t selectedCardId{MAX_CARD};
+    };
+}
+
+#endif // SET_CARD_MODEL_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_card/include/SetCardNoCardView.h b/code/sdk/application/wearable/nativeapp/nativeui/set_card/include/SetCardNoCardView.h
new file mode 100644 (file)
index 0000000..16264fa
--- /dev/null
@@ -0,0 +1,27 @@
+/**\r
+ * Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved.\r
+ * Description:\r
+ * Author:\r
+ * Create:\r
+ */\r
+\r
+#ifndef SET_CARD_NO_CARD_VIEW_H\r
+#define SET_CARD_NO_CARD_VIEW_H\r
+\r
+#include "components/ui_image_view.h"\r
+#include "components/ui_label.h"\r
+#include "components/ui_label_button.h"\r
+#include "SetCardPresenter.h"\r
+\r
+namespace OHOS {\r
+class SetCardNoCardView : public UIViewGroup {\r
+public:\r
+    SetCardNoCardView(SetCardPresenter *presenter);\r
+    virtual ~SetCardNoCardView();\r
+    bool InitView();\r
+private:\r
+    SetCardPresenter *presenter_;\r
+    UILabelButton addBtn;\r
+};\r
+}\r
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_card/include/SetCardPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/set_card/include/SetCardPresenter.h
new file mode 100644 (file)
index 0000000..5c9b4e0
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SetCardPresenter.h
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#ifndef SET_CARD_PRESENTER_H
+#define SET_CARD_PRESENTER_H
+
+#include "Presenter.h"
+#include "components/ui_list.h"
+#include "components/ui_view.h"
+#include "KeyInputListener.h"
+
+namespace OHOS {
+
+static const char *SET_CARD_ADD = "setcardadd";
+static const char *SET_CARD_DEL = "setcarddel";
+static const char *SET_CARD_DEL_CONFIRM = "setcarddelconfirm";
+static const char *SET_CARD_DEL_CANCEL = "setcarddelcancel";
+
+class SetCardView;
+class SetCardModel;
+class SetCardPresenter : public Presenter<SetCardView>,
+                         public UIView::OnClickListener,
+                         public ListScrollListener  {
+public:
+    SetCardPresenter();
+    virtual ~SetCardPresenter();
+
+    virtual void OnStart() override;
+    virtual void OnResume() override;
+    virtual void OnStop() override;
+    bool OnClick(UIView &view, const ClickEvent &event) override;
+    virtual void OnScrollStart(int16_t index, UIView *view) override;
+    virtual void OnScrollEnd(int16_t index, UIView *view) override;
+    virtual void OnItemSelected(int16_t index, UIView* view) override;
+    void InitCardShowList(void);
+    uint8_t *GetCardShowList(void);
+    uint8_t GetCardShowCount(void) const;
+    void SetSelectedCard(uint8_t cardId);
+    uint8_t GetSelectedCard(void);
+private:
+    KeyInputListener *keyActListenr{nullptr};
+    SetCardModel *model{nullptr};
+
+};
+}
+
+#endif // SET_CARD_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_card/include/SetCardView.h b/code/sdk/application/wearable/nativeapp/nativeui/set_card/include/SetCardView.h
new file mode 100644 (file)
index 0000000..9c18e0d
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SetCardView.h
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#ifndef SET_CARD_VIEW_H
+#define SET_CARD_VIEW_H
+
+#include "View.h"
+#include "components/ui_view_group.h"
+#include "components/ui_label.h"
+#include "components/ui_image_view.h"
+#include "components/ui_toggle_button.h"
+#include "window/window.h"
+#include "BaseView.h"
+#include "ChangeSliceListener.h"
+#include "UiConfig.h"
+#include "SetCardAdapter.h"
+#include "SetCardModel.h"
+#include "SetCardDeleteView.h"
+#include "SetCardNoCardView.h"
+
+namespace OHOS {
+class SetCardPresenter;
+
+class SetCardView : public View<SetCardPresenter> {
+public:
+    SetCardView();
+    virtual ~SetCardView();
+
+    static SetCardView *GetInstance()
+    {
+        static SetCardView instance;
+        return &instance;
+    }
+
+    virtual void OnStart() override;
+    virtual void OnSetUpView() override;
+    virtual void OnTearDownView() override;
+    virtual void OnStop() override;
+    void ShowDeleteView(bool show);
+    void ShowAddView(bool show);
+    void RefreshCardList(void);
+private:
+    void SetUpListInfo(void);
+    void SetUpListView(void);
+    void SetUpDeleteView(void);
+    void SetUpAddView(void);
+    void ShowCardListView(bool show);
+    UIImageView addImg_;
+    UIList contentList_;
+    UIImageView delImg_;
+
+    SetCardDeleteView *deleteView_{nullptr};
+    SetCardNoCardView *noCardView_{nullptr};
+    SetCardAdapter *setCardAdapter_{nullptr};
+    uint32_t scrollIndex_{0};
+};
+}
+#endif // SET_CARD_VIEW_H
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardAdapter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardAdapter.cpp
new file mode 100644 (file)
index 0000000..4bce9db
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SetCardAdapter.cpp
+ * Author:
+ * Create: 2021-09-18
+ */
+
+#include "SetCardAdapter.h"
+
+namespace OHOS {
+SetCardAdapter::SetCardAdapter() {}
+
+SetCardAdapter::~SetCardAdapter()
+{
+    listData_.clear();
+}
+
+uint16 SetCardAdapter::GetCount(void)
+{
+    return listData_.size();
+}
+
+void SetCardAdapter::ClearItem(void)
+{
+    listData_.clear();
+}
+
+UIView *SetCardAdapter::GetView(UIView *inView, int16 index)
+{
+    if (index >= (int16)listData_.size() || index < 0) {
+        return nullptr;
+    }
+
+    std::list<CardInfo>::iterator it = listData_.begin();
+    for (int i = 0; i < index; i++) {
+        it++;
+    }
+
+    SetCardItem *item = nullptr;
+    if (inView == nullptr) {
+        item = new SetCardItem();
+        if (item == nullptr) {
+            return nullptr;
+        }
+    } else {
+        item = static_cast<SetCardItem *>(inView);
+    }
+
+    item->SetItemInfo(*it);
+    item->SetViewIndex(index);
+    return item;
+}
+
+void SetCardAdapter::AddListItem(const CardInfo &item)
+{
+    listData_.push_back(item);
+}
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardDeleteView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardDeleteView.cpp
new file mode 100644 (file)
index 0000000..d957515
--- /dev/null
@@ -0,0 +1,53 @@
+/**\r
+ * Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved.\r
+ * Description.\r
+ * Author:\r
+ * Create:\r
+ */\r
+\r
+#include "UiConfig.h"\r
+#include <string>\r
+#include "cmsis_os.h"\r
+#include "SetCardDeleteView.h"\r
+\r
+namespace OHOS {\r
+\r
+SetCardDeleteView::SetCardDeleteView(SetCardPresenter *presenter)\r
+{\r
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardDeleteView::SetCardDeleteView");\r
+    presenter_ = presenter;\r
+    SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);\r
+    SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);\r
+    InitView();\r
+    Add(&confirmBtn);\r
+    Add(&cancelBtn);\r
+}\r
+\r
+SetCardDeleteView::~SetCardDeleteView()\r
+{\r
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardDeleteView::~SetCardDeleteView");\r
+    Remove(&confirmBtn);\r
+    Remove(&cancelBtn);\r
+}\r
+\r
+bool SetCardDeleteView::InitView()\r
+{\r
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardDeleteView::InitView");\r
+    confirmBtn.SetPosition(184, 118);\r
+    confirmBtn.Resize(86, 50);\r
+    confirmBtn.SetViewId(SET_CARD_DEL_CONFIRM);\r
+    confirmBtn.SetText("删除");\r
+    confirmBtn.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+    confirmBtn.SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
+    confirmBtn.SetOnClickListener(presenter_);\r
+\r
+    cancelBtn.SetPosition(186, 231);\r
+    cancelBtn.Resize(82, 50);\r
+    cancelBtn.SetViewId(SET_CARD_DEL_CANCEL);\r
+    cancelBtn.SetText("取消");\r
+    cancelBtn.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+    cancelBtn.SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
+    cancelBtn.SetOnClickListener(presenter_);\r
+    return true;\r
+}\r
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardItem.cpp b/code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardItem.cpp
new file mode 100644 (file)
index 0000000..61b9c49
--- /dev/null
@@ -0,0 +1,32 @@
+#include "SetCardItem.h"\r
+#include "SetCardPresenter.h"\r
+#include "wearable_log.h"\r
+\r
+namespace OHOS {\r
+    SetCardItem::SetCardItem()\r
+    {\r
+        SetPosition(0, 0, 454, 280);\r
+        SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);\r
+        SetUpChild();\r
+        Add(&cardImg_);\r
+    }\r
+\r
+    SetCardItem::~SetCardItem()\r
+    {\r
+        Remove(&cardImg_);\r
+    }\r
+\r
+    void SetCardItem::SetUpChild()\r
+    {\r
+        cardImg_.SetPosition(87, 0);\r
+        cardImg_.Resize(280, 280);\r
+        cardImg_.SetResizeMode(UIImageView::FILL);\r
+        cardImg_.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);\r
+    }\r
+\r
+    void SetCardItem::SetItemInfo(const CardInfo &cardInfo)\r
+    {\r
+        cardInfo_ = cardInfo;\r
+        cardImg_.SetSrc(cardInfo.cardImg);\r
+    }\r
+};\r
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardModel.cpp
new file mode 100644 (file)
index 0000000..32ca2b5
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SetCardModel.cpp
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#include "SetCardModel.h"
+#include "MainModel.h"
+#include "kv_store.h"
+#include "securec.h"
+
+namespace OHOS {
+    SetCardModel::SetCardModel() {}
+
+    SetCardModel::~SetCardModel() {}
+
+    SetCardModel &SetCardModel::GetInstance()
+    {
+        static SetCardModel instance;
+        return instance;
+    }
+
+    void SetCardModel::InitCardShowList(void)
+    {
+        MainModel::GetInstance().InitCardSettings();
+        uint8_t cardCount = MainModel::GetInstance().GetCardSettingCount();
+        CardId *cardSettings = MainModel::GetInstance().GetCardSettings();
+        cardShowCount = 0;
+        for (uint8_t i = 0; i < cardCount; i++) {
+            if (cardSettings[i] == WATCH_FACE) {
+                continue;
+            }
+            cardShowList[cardShowCount++] = cardSettings[i];
+        }
+    }
+
+    uint8_t *SetCardModel::GetCardShowList(void)
+    {
+        return cardShowList;
+    }
+
+    uint8_t SetCardModel::GetCardShowCount(void) const
+    {
+        return cardShowCount;
+    }
+
+    void SetCardModel::SetSelectedCardIndex(uint8_t cardIndex)
+    {
+        selectedCardIndex = cardIndex;
+    }
+
+    uint8_t SetCardModel::GetSelectedCardIndex(void) const
+    {
+        return selectedCardIndex;
+    }
+
+    void SetCardModel::DeleteCardSetting(void)
+    {
+        MainModel::GetInstance().DeleteCardSetting(selectedCardIndex);
+    }
+
+    void SetCardModel::SetSelectedCard(uint8_t cardId)
+    {
+        selectedCardId = cardId;
+    }
+
+    uint8_t SetCardModel::GetSelectedCard(void)
+    {
+        return selectedCardId;
+    }
+}
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardNoCardView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardNoCardView.cpp
new file mode 100644 (file)
index 0000000..15cb462
--- /dev/null
@@ -0,0 +1,43 @@
+/**\r
+ * Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved.\r
+ * Description.\r
+ * Author:\r
+ * Create:\r
+ */\r
+\r
+#include "UiConfig.h"\r
+#include <string>\r
+#include "cmsis_os.h"\r
+#include "SetCardNoCardView.h"\r
+\r
+namespace OHOS {\r
+\r
+SetCardNoCardView::SetCardNoCardView(SetCardPresenter *presenter)\r
+{\r
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardNoCardView::SetCardNoCardView");\r
+    presenter_ = presenter;\r
+    SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);\r
+    SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);\r
+    InitView();\r
+    Add(&addBtn);\r
+}\r
+\r
+SetCardNoCardView::~SetCardNoCardView()\r
+{\r
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardNoCardView::~SetCardNoCardView");\r
+    Remove(&addBtn);\r
+}\r
+\r
+bool SetCardNoCardView::InitView()\r
+{\r
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardNoCardView::InitView");\r
+    addBtn.SetPosition(184, 118);\r
+    addBtn.Resize(86, 50);\r
+    addBtn.SetViewId(SET_CARD_ADD);\r
+    addBtn.SetText("添加");\r
+    addBtn.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+    addBtn.SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
+    addBtn.SetOnClickListener(presenter_);\r
+    return true;\r
+}\r
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardPresenter.cpp
new file mode 100644 (file)
index 0000000..f32df85
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SetCardPresenter.cpp
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#include "SetCardView.h"
+#include "SetCardModel.h"
+#include "SetCardPresenter.h"
+
+namespace OHOS {
+    SetCardPresenter::SetCardPresenter()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::SetCardPresenter");
+        model = &SetCardModel::GetInstance();
+    }
+
+    SetCardPresenter::~SetCardPresenter() {
+        if (keyActListenr != nullptr) {
+            delete keyActListenr;
+            keyActListenr = nullptr;
+        }
+    }
+
+    void SetCardPresenter::OnStart()
+    {
+        Presenter<SetCardView>::OnStart();
+        if (keyActListenr == nullptr) {
+            keyActListenr = new KeyInputListener();
+            if (keyActListenr != nullptr) {
+                RootView::GetInstance()->SetOnKeyActListener(keyActListenr);
+            } else {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnStart: new KeyInputListener fail");
+            }
+        }
+    }
+
+    void SetCardPresenter::OnResume(void)
+    {
+    }
+
+    void SetCardPresenter::OnStop(void)
+    {
+        RootView::GetInstance()->ClearOnKeyActListener();
+    }
+
+    bool SetCardPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::OnClick");
+        if (strcmp(view.GetViewId(), SET_CARD_ADD) == 0) {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::SET_CARD_ADD");
+            NativeAbility::GetInstance().ChangeSlice(VIEW_ADD_CARD); 
+        } else if (strcmp(view.GetViewId(), SET_CARD_DEL) == 0) {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::SET_CARD_DEL");
+            view_->ShowDeleteView(true);
+        } else if (strcmp(view.GetViewId(), SET_CARD_DEL_CONFIRM) == 0) {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::SET_CARD_DEL_CONFIRM");
+            model->DeleteCardSetting();
+            view_->ShowDeleteView(false);
+            view_->RefreshCardList();
+        } else if (strcmp(view.GetViewId(), SET_CARD_DEL_CANCEL) == 0) {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::SET_CARD_DEL_CANCEL");
+            view_->ShowDeleteView(false);
+        }
+               return true;
+    }
+
+    void SetCardPresenter::OnScrollStart(int16_t index, UIView *view)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::OnScrollStart index = %d", index);
+        return;
+    }
+
+    void SetCardPresenter::OnScrollEnd(int16_t index, UIView *view)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::OnScrollEnd index = %d", index);
+        if (view == nullptr) {
+            return;
+        }
+        model->SetSelectedCardIndex(index);
+    }
+
+    void SetCardPresenter::OnItemSelected(int16_t index, UIView* view) 
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::OnItemSelected index = %d", index);
+        if (view == nullptr) {
+            return;
+        }    
+    }
+    void SetCardPresenter::InitCardShowList(void)
+    {
+        model->InitCardShowList();
+    }
+
+    uint8_t *SetCardPresenter::GetCardShowList(void)
+    {
+        return model->GetCardShowList();
+    }
+
+    uint8_t SetCardPresenter::GetCardShowCount(void) const
+    {
+        return model->GetCardShowCount();
+    }
+
+    void SetCardPresenter::SetSelectedCard(uint8_t cardId)
+    {
+        model->SetSelectedCard(cardId);
+    }
+
+    uint8_t SetCardPresenter::GetSelectedCard(void)
+    {
+        return model->GetSelectedCard();
+    }
+
+}
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardView.cpp
new file mode 100644 (file)
index 0000000..f18a1c8
--- /dev/null
@@ -0,0 +1,208 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SetCardView.cpp
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#include <string>
+#include "SetCardView.h"
+#include "SetCardPresenter.h"
+
+namespace OHOS {
+SetCardView::SetCardView():contentList_(UIList::HORIZONTAL)
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardView::SetCardView");
+}
+
+SetCardView::~SetCardView()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardView::~SetCardView");
+    if (deleteView_ != nullptr) {
+        delete deleteView_;
+        deleteView_ = nullptr;
+    }
+
+    if (noCardView_ != nullptr) {
+        delete noCardView_;
+        noCardView_ = nullptr;
+    }
+
+    if (setCardAdapter_ != nullptr) {
+        delete setCardAdapter_;
+        setCardAdapter_ = nullptr;
+    }
+}
+
+void SetCardView::OnStart()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardView::OnStart");
+    View<SetCardPresenter>::OnStart();
+    SetContainerView(new UIViewGroup());
+    container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+    setCardAdapter_ = new SetCardAdapter();
+    SetUpListInfo();
+    SetUpListView();
+    SetUpDeleteView();
+    SetUpAddView();
+}
+
+void SetCardView::OnSetUpView()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardView::OnSetUpView");
+    View<SetCardPresenter>::OnSetUpView();
+    ShowDeleteView(false);
+    if (setCardAdapter_->GetCount() == 0) {
+        ShowAddView(true);
+    }
+}
+
+void SetCardView::OnTearDownView()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardView::OnTearDownView");
+    View<SetCardPresenter>::OnTearDownView();
+}
+
+void SetCardView::OnStop()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardView::OnStop");
+    View<SetCardPresenter>::OnStop();
+    RootView::GetInstance()->ClearOnKeyActListener();
+    if (container_ != nullptr) {
+        container_->RemoveAll();
+        delete container_;
+        container_ = nullptr;
+    }
+}
+
+void SetCardView::SetUpListInfo(void)
+{
+    presenter_->InitCardShowList();
+    uint8_t num = presenter_->GetCardShowCount();
+    uint8_t *cardSettings = presenter_->GetCardShowList();
+    uint8_t selectCardId = presenter_->GetSelectedCard();
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetUpListInfo::selectCardId = %u", selectCardId);
+    setCardAdapter_->ClearItem();
+    for (uint8_t i = 0; i < num; i++) {
+        const CardInfo *info = MainModel::GetInstance().GetCardInfo(
+            static_cast<CardId>(cardSettings[i]));
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetUpListInfo::%d %s", info->id, info->cardImg);
+        if (selectCardId == info->id) {
+            scrollIndex_ = i;
+            presenter_->SetSelectedCard(MAX_CARD);
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetUpListInfo::scrollIndex_ = %u", scrollIndex_);
+        }
+        setCardAdapter_->AddListItem(*info);
+    }
+}
+
+void SetCardView::SetUpListView(void)
+{
+    addImg_.SetPosition(187, 10);
+    addImg_.Resize(80, 80);
+    addImg_.SetResizeMode(UIImageView::FILL);
+    addImg_.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);
+    addImg_.SetSrc(PNG_SET_CARD_ADD);
+    addImg_.SetViewId(SET_CARD_ADD);
+    addImg_.SetVisible(false);
+
+    contentList_.SetPosition(0, 92);
+    contentList_.Resize(HORIZONTAL_RESOLUTION, 280);
+    contentList_.SetScrollBlankSize(HORIZONTAL_RESOLUTION / 2);
+    contentList_.SetSelectPosition(HORIZONTAL_RESOLUTION / 2);
+    contentList_.SetDraggable(true);
+    contentList_.SetThrowDrag(true);
+    contentList_.EnableAutoAlign(true);
+    contentList_.SetScrollStateListener(presenter_);
+    contentList_.SetMaxScrollDistance(1000);
+    contentList_.SetAdapter(setCardAdapter_);
+    contentList_.SetVisible(false);
+    contentList_.ScrollTo(scrollIndex_);
+
+    delImg_.SetPosition(187, 374);
+    delImg_.Resize(80, 80);
+    delImg_.SetResizeMode(UIImageView::FILL);
+    delImg_.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);
+    delImg_.SetSrc(PNG_SET_CARD_DEL);
+    delImg_.SetViewId(SET_CARD_DEL);
+    delImg_.SetVisible(false);
+
+    addImg_.SetTouchable(true);
+    addImg_.SetOnClickListener(presenter_);
+    delImg_.SetTouchable(true);
+    delImg_.SetOnClickListener(presenter_);
+
+    container_->Add(&addImg_);
+    container_->Add(&contentList_);
+    container_->Add(&delImg_);
+}
+
+void SetCardView::SetUpDeleteView(void)
+{
+    deleteView_ = new SetCardDeleteView(presenter_);
+    if (deleteView_ == nullptr) {
+        return;
+    }
+    deleteView_->SetVisible(false);
+    container_->Add(deleteView_);
+}
+
+void SetCardView::SetUpAddView(void)
+{
+    noCardView_ = new SetCardNoCardView(presenter_);
+    if (noCardView_ == nullptr) {
+        return;
+    }
+    noCardView_->SetVisible(false);
+    container_->Add(noCardView_);
+}
+
+void SetCardView::ShowCardListView(bool show)
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardView::ShowCardListView %u", show);
+    if (show) {
+        addImg_.SetVisible(true);
+        contentList_.SetVisible(true);
+        delImg_.SetVisible(true);        
+    } else {
+        addImg_.SetVisible(false);
+        contentList_.SetVisible(false);
+        delImg_.SetVisible(false);
+    }  
+}
+
+void SetCardView::ShowDeleteView(bool show)
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardView::ShowDeleteView %u", show);
+    if (show) {
+        ShowCardListView(false);
+        deleteView_->SetVisible(true);
+    } else {
+        ShowCardListView(true);
+        deleteView_->SetVisible(false);        
+    }
+}
+
+void SetCardView::ShowAddView(bool show)
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardView::ShowAddView %u", show);
+    if (show) {
+        ShowCardListView(false);
+        noCardView_->SetVisible(true);
+    } else {
+        ShowCardListView(true);
+        noCardView_->SetVisible(false);        
+    }
+}
+
+void SetCardView::RefreshCardList(void)
+{
+    contentList_.RemoveAll();
+    SetUpListInfo();
+    contentList_.RefreshList();
+    if (setCardAdapter_->GetCount() == 0) {
+        ShowAddView(true);
+    }
+}
+
+}
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_desktop/include/SetDesktopModel.h b/code/sdk/application/wearable/nativeapp/nativeui/set_desktop/include/SetDesktopModel.h
new file mode 100644 (file)
index 0000000..5c5a926
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SetDesktopModel.h
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#ifndef SET_DESKTOP_MODEL_H
+#define SET_DESKTOP_MODEL_H
+
+#include <cstdint>
+#include <map>
+#include "AppViewIDs.h"
+#include "UiConfig.h"
+#include "SetDesktopPresenter.h"
+
+typedef enum {
+    APPLIST_STYLE,
+    HEXAGONS_STYLE,
+} DesktopStyle;
+
+namespace OHOS {
+    class SetDesktopModel {
+    public:
+        static SetDesktopModel &GetInstance(void);
+        DesktopStyle GetDesktopStyle(void);
+        void SetDesktopStyle(DesktopStyle style);
+    private:
+        SetDesktopModel();
+        SetDesktopModel(const SetDesktopModel &);
+        SetDesktopModel &operator=(const SetDesktopModel &);
+        virtual ~SetDesktopModel();
+
+    };
+}
+
+#endif // SET_DESKTOP_MODEL_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_desktop/include/SetDesktopPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/set_desktop/include/SetDesktopPresenter.h
new file mode 100644 (file)
index 0000000..1e8d0c1
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SetDesktopPresenter.h
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#ifndef SET_DESKTOP_PRESENTER_H
+#define SET_DESKTOP_PRESENTER_H
+
+#include "Presenter.h"
+#include "components/ui_view.h"
+
+namespace OHOS {
+static const char *SET_DESKTOP_LIST = "setdesktopList";
+static const char *SET_DESKTOP_HEXAGONS = "setdesktopHexagons";
+
+class SetDesktopView;
+class SetDesktopModel;
+class SetDesktopPresenter : public Presenter<SetDesktopView>,
+                         public UIView::OnClickListener,
+                         public UIView::OnDragListener {
+public:
+    SetDesktopPresenter();
+    virtual ~SetDesktopPresenter();
+
+    virtual void OnStart() override;
+    virtual void OnResume() override;
+    virtual void OnStop() override;
+
+    bool OnClick(UIView &view, const ClickEvent &event) override;
+    virtual bool OnDrag(UIView& view, const DragEvent& event) override;
+    bool GetHexagonsStyleState(void);
+private:
+
+};
+}
+
+#endif // SET_DESKTOP_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_desktop/include/SetDesktopView.h b/code/sdk/application/wearable/nativeapp/nativeui/set_desktop/include/SetDesktopView.h
new file mode 100644 (file)
index 0000000..4c99274
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SetDesktopView.h
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#ifndef SET_DESKTOP_VIEW_H
+#define SET_DESKTOP_VIEW_H
+
+#include "View.h"
+#include "components/ui_view_group.h"
+#include "components/ui_label.h"
+#include "components/ui_image_view.h"
+#include "components/ui_toggle_button.h"
+#include "window/window.h"
+#include "BaseView.h"
+#include "ChangeSliceListener.h"
+#include "UiConfig.h"
+
+namespace OHOS {
+class SetDesktopPresenter;
+
+class SetDesktopView : public View<SetDesktopPresenter> {
+public:
+    SetDesktopView();
+    virtual ~SetDesktopView();
+
+    static SetDesktopView *GetInstance()
+    {
+        static SetDesktopView instance;
+        return &instance;
+    }
+
+    virtual void OnStart() override;
+    virtual void OnSetUpView() override;
+    virtual void OnTearDownView() override;
+    virtual void OnStop() override;
+    void UpdateSelectedStyle(bool hexagonsSelected);
+private:
+    UILabel titleText;
+    UIToggleButton hexagonsBtn;
+    UIToggleButton listBtn;
+    UIImageView hexagonsImage;
+    UIImageView listImage;
+    UILabel listText;
+    UILabel hexagonsText;
+};
+}
+#endif // SET_DESKTOP_VIEW_H
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_desktop/src/SetDesktopModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/set_desktop/src/SetDesktopModel.cpp
new file mode 100644 (file)
index 0000000..d5f64f3
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SettingModel.cpp
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#include "SetDesktopModel.h"
+#include "kv_store.h"
+#include "securec.h"
+
+namespace OHOS {
+    static const int STYLE_VALUE_LEN = 32;
+    SetDesktopModel::SetDesktopModel() {}
+
+    SetDesktopModel::~SetDesktopModel() {}
+
+    SetDesktopModel &SetDesktopModel::GetInstance()
+    {
+        static SetDesktopModel instance;
+        return instance;
+    }
+
+    DesktopStyle SetDesktopModel::GetDesktopStyle(void)
+    {
+        DesktopStyle style;
+        char temp[STYLE_VALUE_LEN] = { 0 };
+        (void)UtilsGetValue("applist_style", temp, STYLE_VALUE_LEN);
+        if (strcmp(temp, "hexagons") == 0) {
+            style = HEXAGONS_STYLE;
+        } else {
+            style = APPLIST_STYLE;
+        }
+        return style;     
+    }
+
+    void SetDesktopModel::SetDesktopStyle(DesktopStyle style)
+    {
+        if (style == APPLIST_STYLE) {
+            (void)UtilsSetValue("applist_style", "list");
+        } else if (style == HEXAGONS_STYLE) {
+            (void)UtilsSetValue("applist_style", "hexagons");
+        }
+    }
+
+}
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_desktop/src/SetDesktopPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/set_desktop/src/SetDesktopPresenter.cpp
new file mode 100644 (file)
index 0000000..0c361bc
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SettingPresenter.cpp
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#include "SetDesktopView.h"
+#include "SetDesktopModel.h"
+#include "SetDesktopPresenter.h"
+
+namespace OHOS {
+    SetDesktopPresenter::SetDesktopPresenter()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDesktopPresenter::SetDesktopPresenter");
+    }
+
+    SetDesktopPresenter::~SetDesktopPresenter() {}
+
+    void SetDesktopPresenter::OnStart()
+    {
+        Presenter<SetDesktopView>::OnStart();
+    }
+
+    void SetDesktopPresenter::OnResume(void)
+    {
+    }
+
+    void SetDesktopPresenter::OnStop(void)
+    {
+    }
+
+    bool SetDesktopPresenter::OnDrag(UIView& view, const DragEvent& event)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDesktopPresenter::OnDrag");
+        UNUSED(view);
+        if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) &&
+            (event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnDrag ChangeSlice");
+            uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
+            NativeAbility::GetInstance().ChangeSlice(preSlice);
+        }
+        return false;
+    }
+
+    bool SetDesktopPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDesktopPresenter::OnClick");
+        if (strcmp(view.GetViewId(), SET_DESKTOP_HEXAGONS) == 0) {
+            SetDesktopModel::GetInstance().SetDesktopStyle(HEXAGONS_STYLE);
+        } else if (strcmp(view.GetViewId(), SET_DESKTOP_LIST) == 0) {
+            SetDesktopModel::GetInstance().SetDesktopStyle(APPLIST_STYLE);
+        }
+        uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
+        NativeAbility::GetInstance().ChangeSlice(preSlice);
+               return true; 
+    }
+    bool SetDesktopPresenter::GetHexagonsStyleState(void)
+    {
+        return (SetDesktopModel::GetInstance().GetDesktopStyle() == HEXAGONS_STYLE);
+    }
+}
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_desktop/src/SetDesktopView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/set_desktop/src/SetDesktopView.cpp
new file mode 100644 (file)
index 0000000..c5f2b49
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SetDesktopView.cpp
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#include <string>
+#include "SetDesktopView.h"
+#include "SetDesktopPresenter.h"
+
+namespace OHOS {
+SetDesktopView::SetDesktopView()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDesktopView::SetDesktopView");
+}
+
+SetDesktopView::~SetDesktopView()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDesktopView::~SetDesktopView");
+}
+
+void SetDesktopView::OnStart()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDesktopView::OnStart");
+    View<SetDesktopPresenter>::OnStart();
+    SetContainerView(new UIViewGroup());
+    container_->SetDraggable(true);
+    container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+    container_->SetOnDragListener(presenter_);
+    container_->SetTouchable(true);
+}
+
+void SetDesktopView::OnSetUpView()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDesktopView::OnSetUpView");
+    View<SetDesktopPresenter>::OnSetUpView();
+
+    titleText.SetPosition(180, 45, 260, 110);
+    titleText.SetText("桌面");
+    titleText.SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
+    titleText.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40);
+    titleText.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+    container_->Add(&titleText);
+
+    listImage.SetPosition(25, 135, 190, 190);
+    listImage.SetSrc(PNG_SET_DESKTOP_BG_IMAGE);
+    container_->Add(&listImage);
+
+    listBtn.SetPosition(47, 157, 148, 148);
+    listBtn.SetImages(PNG_SET_DESKTOP_LIST_IMAGE, PNG_SET_DESKTOP_LIST_IMAGE);
+    listBtn.SetViewId(SET_DESKTOP_LIST);
+    container_->Add(&listBtn);
+
+    listText.SetPosition(96, 328, 200, 60);
+    listText.SetText("列表");
+    listText.SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
+    listText.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+    listText.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+    container_->Add(&listText);
+
+    hexagonsImage.SetPosition(247, 135, 190, 190);
+    hexagonsImage.SetSrc(PNG_SET_DESKTOP_BG_IMAGE);
+    container_->Add(&hexagonsImage);
+
+    hexagonsBtn.SetPosition(267, 157, 148, 148);
+    hexagonsBtn.SetImages(PNG_SET_DESKTOP_HEXAGONS_IMAGE, PNG_SET_DESKTOP_HEXAGONS_IMAGE);
+    hexagonsBtn.SetViewId(SET_DESKTOP_HEXAGONS);
+    container_->Add(&hexagonsBtn);
+
+    hexagonsText.SetPosition(305, 328, 200, 60);
+    hexagonsText.SetText("蜂窝");
+    hexagonsText.SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
+    hexagonsText.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+    hexagonsText.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+    container_->Add(&hexagonsText);
+
+    listBtn.SetOnClickListener(presenter_);
+    hexagonsBtn.SetOnClickListener(presenter_);
+    UpdateSelectedStyle(presenter_->GetHexagonsStyleState());
+}
+
+void SetDesktopView::OnTearDownView()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDesktopView::OnTearDownView");
+    View<SetDesktopPresenter>::OnTearDownView();
+}
+
+void SetDesktopView::OnStop()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDesktopView::OnStop");
+    View<SetDesktopPresenter>::OnStop();
+    if (container_ != nullptr) {
+        container_->RemoveAll();
+        delete container_;
+        container_ = nullptr;
+    }
+}
+
+void SetDesktopView::UpdateSelectedStyle(bool hexagonsSelected)
+{
+    listImage.SetVisible(!hexagonsSelected);
+    hexagonsImage.SetVisible(hexagonsSelected);
+    hexagonsBtn.SetState(hexagonsSelected);
+    listBtn.SetState(!hexagonsSelected);
+}
+}
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_dial/include/SetDialInfo.h b/code/sdk/application/wearable/nativeapp/nativeui/set_dial/include/SetDialInfo.h
new file mode 100644 (file)
index 0000000..7ccb798
--- /dev/null
@@ -0,0 +1,26 @@
+/*\r
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.\r
+ * Description: SetDialInfo.h\r
+ * Author:\r
+ * Create: 2021-11-23\r
+ */\r
+\r
+#ifndef SET_DIAL_INFO_H\r
+#define SET_DIAL_INFO_H\r
+#include <cstdint>\r
+#include <vector>\r
+#include <string>\r
+#include "common/image_cache_manager.h"\r
+namespace OHOS {\r
+    typedef struct {\r
+        uint8_t dialFlag; /* 1:离线表盘 0:预制表盘 */\r
+        uint8_t id;    /* 仅预制表盘使用 */\r
+        std::string dialFullName;  /* 仅离线表盘使用 */\r
+        std::string imageFullName; /* 仅预制表盘使用 */\r
+        std::string dialName;\r
+        std::string description;   /* 仅离线表盘使用 */\r
+        uint8_t freq;\r
+        ImageInfo *preImageInfo;\r
+    } SetDialInfo;\r
+}\r
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_dial/include/SetDialModel.h b/code/sdk/application/wearable/nativeapp/nativeui/set_dial/include/SetDialModel.h
new file mode 100644 (file)
index 0000000..695c5be
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SetDialModel.h
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#ifndef SET_DIAL_MODEL_H
+#define SET_DIAL_MODEL_H
+#include "AppViewIDs.h"
+#include "UiConfig.h"
+#include "SetDialInfo.h"
+
+namespace OHOS {
+    class SetDialModel {
+    public:
+        static SetDialModel &GetInstance(void);
+        void LoadAllDial(void);
+        size_t GetDialCount(void);
+        std::vector<SetDialInfo>& GetDialInfo(void);
+        void SaveDialSetting(uint8_t pageIndex);
+        uint8_t GetPageIndex(void);
+    private:
+        void LoadAllDialFromRam(void);
+        void LoadAllDialFromFs(void);
+        SetDialModel();
+        SetDialModel(const SetDialModel &);
+        SetDialModel &operator=(const SetDialModel &);
+        virtual ~SetDialModel();
+        int32_t ParseDialHeader(const std::string &dialFileName, SetDialInfo &dialInfo);
+        std::vector<SetDialInfo> dialInfoList;
+        uint8_t pageIndex_{0};
+    };
+}
+
+#endif // SET_DIAL_MODEL_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_dial/include/SetDialPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/set_dial/include/SetDialPresenter.h
new file mode 100644 (file)
index 0000000..65b4a74
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SetDialPresenter.h
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#ifndef SET_DIAL_PRESENTER_H
+#define SET_DIAL_PRESENTER_H
+#include "SetDialInfo.h"
+#include "SetDialModel.h"
+#include "Presenter.h"
+#include "components/ui_view.h"
+#include "KeyInputListener.h"
+
+namespace OHOS {
+
+class SetDialView;
+class SetDialModel;
+class SetDialPresenter : public Presenter<SetDialView>,
+                         public UIView::OnClickListener,
+                         public UICoverflowView::OnCoverflowScrollListener {
+public:
+    SetDialPresenter();
+    virtual ~SetDialPresenter();
+    size_t GetDialCount(void);
+    std::vector<SetDialInfo>& GetDialInfo(void);
+    uint8_t GetPageIndex(void);
+    virtual void OnStart() override;
+    virtual void OnResume() override;
+    virtual void OnStop() override;
+    bool OnScroll() override;
+    bool OnClick(UIView &view, const ClickEvent &event) override;
+private:
+    KeyInputListener *keyActListenr{nullptr};
+    SetDialModel *model{nullptr};
+};
+}
+
+#endif // SET_DIAL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_dial/include/SetDialView.h b/code/sdk/application/wearable/nativeapp/nativeui/set_dial/include/SetDialView.h
new file mode 100644 (file)
index 0000000..85ee938
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SetDialView.h
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#ifndef SET_DIAL_VIEW_H
+#define SET_DIAL_VIEW_H
+
+#include "View.h"
+#include "components/ui_view_group.h"
+#include "components/ui_coverflow_view.h"
+#include "window/window.h"
+#include "BaseView.h"
+#include "ChangeSliceListener.h"
+#include "UiConfig.h"
+
+namespace OHOS {
+static constexpr uint8_t DIVISOR_TWO = 2;
+class SetDialPresenter;
+
+class SetDialView : public View<SetDialPresenter> {
+public:
+    SetDialView();
+    virtual ~SetDialView();
+
+    static SetDialView *GetInstance()
+    {
+        static SetDialView instance;
+        return &instance;
+    }
+
+    virtual void OnStart() override;
+    virtual void OnSetUpView() override;
+    virtual void OnTearDownView() override;
+    virtual void OnStop() override;
+    void CoverflowViewScroll(void);
+    uint8_t GetCoverflowPage(void);
+private:
+    void SetUpCoverflowView(void);
+    UICoverflowView coverflow_;
+    UILabel label_;
+    uint8_t lastIndex_;
+};
+}
+#endif // SET_DIAL_VIEW_H
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_dial/src/SetDialModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/set_dial/src/SetDialModel.cpp
new file mode 100644 (file)
index 0000000..122c0ad
--- /dev/null
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SetDialModel.cpp
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#include "MainModel.h"
+#include "SetDialModel.h"
+#include "kv_store.h"
+#include "securec.h"
+#include "dirent.h"
+#include "DialBinTypes.h"
+#include "wearable_log.h"
+
+namespace OHOS {
+    SetDialModel::SetDialModel() {}
+
+    SetDialModel::~SetDialModel() {}
+
+    SetDialModel &SetDialModel::GetInstance()
+    {
+        static SetDialModel instance;
+        return instance;
+    }
+    void SetDialModel::LoadAllDial()
+    {
+        dialInfoList.clear();
+        LoadAllDialFromRam();
+        LoadAllDialFromFs();
+    }
+
+    void SetDialModel::LoadAllDialFromRam()
+    {
+        for (uint8_t i = DIAL_CLOCK; i < DIAL_MAX; i++) {
+            const DialInfo *info = MainModel::GetInstance().GetDialInfo((DialId)i);
+            if (info != nullptr) {
+                SetDialInfo dialInfo;
+                dialInfo.dialFlag = 0;
+                dialInfo.id = i;
+                dialInfo.dialName = info->dialName;
+                dialInfo.imageFullName = info->dialImg;
+                dialInfo.freq = info->freq;
+                ImageInfo* imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(info->dialImg, false);
+                if (info == nullptr) {
+                    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "LoadAllDialFromRam loadimage %s fail",
+                                  info->dialImg);
+                    continue;
+                }
+                dialInfo.preImageInfo = imageInfo;
+                dialInfoList.push_back(dialInfo);
+            }
+        }
+    }
+
+    void SetDialModel::LoadAllDialFromFs()
+    {
+        int ret;
+        struct dirent *direntp;
+
+        // 打开目录
+        DIR *dirp = opendir(APP_DIAL_PATH);
+        // 遍历文件
+        if (dirp != NULL) {
+            while ((direntp = readdir(dirp)) != NULL) {
+                SetDialInfo dialInfo;
+                int ret = ParseDialHeader(direntp->d_name, dialInfo);
+                if (ret == 0) {
+                    dialInfoList.push_back(dialInfo);
+                }
+            }
+        }
+        // 关闭目录
+        closedir(dirp);
+        return;
+    }
+
+    int32_t SetDialModel::ParseDialHeader(const std::string &dialFileName, SetDialInfo &dialInfo)
+    {
+        DialHeader dialHeader{0};
+        std::string dialFullName = APP_DIAL_PATH;
+        dialFullName += "/";
+        dialFullName += dialFileName;
+        FILE *fp = fopen(dialFullName.c_str(), "rb");
+        if (fp == nullptr) {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ParseDialHeader cannot open file: %s",
+                        dialFullName.c_str());
+            return -1;
+        }
+        if (fread(&dialHeader, 1, sizeof(dialHeader), fp) != sizeof(dialHeader)) {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ParseDialHeader fread %s fail",
+                        dialFullName.c_str());
+            return -1;
+        }
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ParseDialHeader dialFullName: %s",
+                      dialFullName.c_str());
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ParseDialHeader dialName: %s",
+                      dialHeader.dialName);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ParseDialHeader description: %s",
+                      dialHeader.description);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ParseDialHeader freq: %u",
+                      dialHeader.freq);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ParseDialHeader previewImgId: %u",
+                      dialHeader.previewImgId);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ParseDialHeader imageOffset: %u",
+                      dialHeader.imageOffset);
+        ImageInfo *info = ImageCacheManager::GetInstance().LoadOneInMultiRes(
+            dialHeader.previewImgId | (0xfef << 20), dialFullName, fp, false, dialHeader.imageOffset);
+        if (info == nullptr) {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ParseDialHeader loadimage fail");
+            return -1;
+        }
+
+        dialInfo.dialFlag = 1;
+        dialInfo.id = 0;
+        dialInfo.dialFullName = dialFullName;
+        dialInfo.dialName = dialHeader.dialName;
+        dialInfo.description = dialHeader.description;
+        dialInfo.freq = dialHeader.freq;
+        dialInfo.preImageInfo = info;
+
+        fclose(fp);
+        return 0;
+    }
+
+    void SetDialModel::SaveDialSetting(uint8_t pageIndex)
+    {
+        if (pageIndex >= dialInfoList.size()) {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialModel SaveDialSetting [%u %u]",
+                          pageIndex, dialInfoList.size());
+            return;
+        }
+        DialSetting diagSetting;
+        SetDialInfo &info = dialInfoList[pageIndex];
+        diagSetting.dialFlag = info.dialFlag;
+        diagSetting.dialId = info.id;
+        diagSetting.dialFullName = info.dialFullName;
+        MainModel::GetInstance().AddDialSetting(diagSetting);
+        pageIndex_ = pageIndex;
+    }
+
+    size_t SetDialModel::GetDialCount(void)
+    {
+        return dialInfoList.size();
+    }
+
+    std::vector<SetDialInfo>& SetDialModel::GetDialInfo(void)
+    {
+        return dialInfoList;
+    }
+
+    uint8_t SetDialModel::GetPageIndex(void)
+    {
+        if (pageIndex_ >= dialInfoList.size()) {
+            return 0;
+        } else {
+            return pageIndex_;
+        }
+    }
+
+}
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_dial/src/SetDialPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/set_dial/src/SetDialPresenter.cpp
new file mode 100644 (file)
index 0000000..5aa0bb2
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SetDialPresenter.cpp
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#include "SetDialView.h"
+#include "SetDialModel.h"
+#include "SetDialPresenter.h"
+
+namespace OHOS {
+    SetDialPresenter::SetDialPresenter()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialPresenter::SetDialPresenter");
+        model = &SetDialModel::GetInstance();
+        model->LoadAllDial();
+    }
+
+    SetDialPresenter::~SetDialPresenter()
+    {
+        if (keyActListenr != nullptr) {
+            delete keyActListenr;
+            keyActListenr = nullptr;
+        }
+    }
+
+    void SetDialPresenter::OnStart()
+    {
+        Presenter<SetDialView>::OnStart();
+        if (keyActListenr == nullptr) {
+            keyActListenr = new KeyInputListener();
+            if (keyActListenr != nullptr) {
+                RootView::GetInstance()->SetOnKeyActListener(keyActListenr);
+            } else {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnStart: new KeyInputListener fail");
+            }
+        }
+    }
+
+    void SetDialPresenter::OnResume(void)
+    {
+    }
+
+    void SetDialPresenter::OnStop(void)
+    {
+    }
+
+    bool SetDialPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialPresenter::OnClick");
+        uint8_t pageIndex = view_->GetCoverflowPage();
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialPresenter select pageIndex = %u", pageIndex);
+        model->SaveDialSetting(pageIndex);
+        NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE);
+               return true; 
+    }
+
+    bool SetDialPresenter::OnScroll()
+    {
+        view_->CoverflowViewScroll();
+        return true;
+    }
+
+    size_t SetDialPresenter::GetDialCount(void)
+    {
+        return model->GetDialCount();
+    }
+
+    std::vector<SetDialInfo>& SetDialPresenter::GetDialInfo(void)
+    {
+        return model->GetDialInfo();
+    }
+
+    uint8_t SetDialPresenter::GetPageIndex(void)
+    {
+        return model->GetPageIndex();
+    }
+}
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_dial/src/SetDialView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/set_dial/src/SetDialView.cpp
new file mode 100644 (file)
index 0000000..b683a86
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SetDialView.cpp
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#include <string>
+#include "SetDialView.h"
+#include "SetDialPresenter.h"
+
+namespace OHOS {
+SetDialView::SetDialView()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialView::SetDialView");
+}
+
+SetDialView::~SetDialView()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialView::~SetDialView");
+}
+
+void SetDialView::OnStart()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialView::OnStart");
+    View<SetDialPresenter>::OnStart();
+    SetContainerView(new UIViewGroup());
+    container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+    SetUpCoverflowView();
+}
+
+void SetDialView::SetUpCoverflowView(void)
+{
+    coverflow_.SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+    coverflow_.SetIntercept(true);
+    coverflow_.SetOnCoverflowListener(presenter_);
+    coverflow_.SetOnClickListener(presenter_);
+    std::vector<SetDialInfo> &dialInfo = presenter_->GetDialInfo();
+    for (auto iter : dialInfo) {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialView::SetUpCoverflowView %s",
+                      iter.dialName.c_str());
+        coverflow_.Add(iter.dialName.c_str(), iter.preImageInfo);
+    }
+    lastIndex_ = presenter_->GetPageIndex();
+    coverflow_.SetCurrentPage(lastIndex_);
+
+    label_.SetPosition(127, 50, 200, 50);
+    label_.SetTextColor(Color::White());
+    label_.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+    label_.SetText(dialInfo[lastIndex_].dialName.c_str());
+    label_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+        
+    container_->Add(&coverflow_);
+    container_->Add(&label_);
+}
+
+void SetDialView::OnSetUpView()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialView::OnSetUpView");
+    View<SetDialPresenter>::OnSetUpView();
+}
+
+void SetDialView::OnTearDownView()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialView::OnTearDownView");
+    View<SetDialPresenter>::OnTearDownView();
+}
+
+void SetDialView::OnStop()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialView::OnStop");
+    View<SetDialPresenter>::OnStop();
+    if (container_ != nullptr) {
+        container_->RemoveAll();
+        delete container_;
+        container_ = nullptr;
+    }
+}
+
+void SetDialView::CoverflowViewScroll(void) 
+{
+    int16_t contMidX = static_cast<int16_t>(Screen::GetInstance().GetWidth() / DIVISOR_TWO);
+    int16_t minOffset = contMidX;
+    uint8_t newCenterIndex = lastIndex_;
+    for (uint8_t i = 0; i < coverflow_.GetChildrenNumber(); i++) {
+        Rect rect =  coverflow_.GetViewByIndex(i)->GetOrigRect();
+        int16_t x = rect.GetLeft();
+        int16_t x1 = rect.GetRight();
+        int16_t xMid = static_cast<int16_t>(x + (x1 - x + 1) / DIVISOR_TWO);
+        int16_t distance = MATH_ABS(xMid - contMidX);
+        if (distance < minOffset) {
+            newCenterIndex = i;
+            minOffset = distance;
+        }
+    }
+    if (newCenterIndex != lastIndex_) {
+        lastIndex_ = newCenterIndex;
+        std::vector<SetDialInfo> &dialInfo = presenter_->GetDialInfo();
+        label_.SetText(dialInfo[lastIndex_].dialName.c_str());
+    }
+
+    Rect curViewRect = coverflow_.GetViewByIndex(lastIndex_)->GetOrigRect();
+    int16_t centerMid = curViewRect.GetLeft() + curViewRect.GetWidth() / DIVISOR_TWO;
+    int16_t offset = MATH_ABS(contMidX - centerMid);
+    if (offset > curViewRect.GetWidth() / DIVISOR_TWO) {
+        label_.SetStyle(STYLE_TEXT_OPA, 0);
+    } else {
+        uint8_t alpha =  (uint8_t)((1.0f - ((float)offset / (curViewRect.GetWidth() / DIVISOR_TWO))) * OPA_OPAQUE);
+        label_.SetStyle(STYLE_TEXT_OPA, alpha);
+    }  
+}
+
+uint8_t SetDialView::GetCoverflowPage(void)
+{
+    return lastIndex_;
+}
+
+}
index 448deb5..250105c 100755 (executable)
 #include <cstdint>
 
 namespace OHOS {
-/*
- * setting id.
- */
-typedef enum : uint16_t {
-    // setting item index
-    SETTING_ITEM_ZERO = 0x0000,
-    SETTING_ITEM_ONE,
-    SETTING_ITEM_TWO,
-    SETTING_ITEM_THREE,
-} SettingIndex;
-
 typedef struct {
-    SettingIndex index;
+    AppViewId viewId;
     const char *icon;
     const char *label;
     bool hasSecondMenu;
index 20de716..aa5de7a 100755 (executable)
@@ -22,15 +22,15 @@ public:
     virtual ~SettingItemView();
     virtual void SetItemInfo(const SettingItem itemInfo);
     virtual void SetUpChild();
-    SettingIndex GetSettingIndex();
-
+    AppViewId GetViewId();
+    const char* GetIconId();
 private:
     SettingItemView(const SettingItemView &);
 
     UIImageView sIcon;
     UILabel sLabel;
     UIImageView sNextImage;
-    SettingItem sItemInfo = { SETTING_ITEM_ZERO, nullptr, nullptr, false };
+    SettingItem sItemInfo = { VIEW_INVALID, nullptr, nullptr, false };
 };
 }
 
index be1e4d5..6a50ebf 100755 (executable)
 #include <cstdint>
 #include <map>
 #include "AppViewIDs.h"
-#include "components/ui_label_ext.h"
 #include "UiConfig.h"
 #include "SettingItem.h"
 #include "SettingPresenter.h"
 
 namespace OHOS {
+    static const uint16_t SETTING_ITEM_COUNT = 10;
     class SettingModel {
     public:
         static SettingModel &GetInstance(void);
         void InitSettingItem();
         const SettingItem *GetSettinglistItems() const;
         uint8_t GetSettingListNum() const;
-        const std::map<SettingIndex, AppViewId> &GetSettingIdToViewId() const;
         bool GetBlueToothConnectStatus(void);
         void UpdateBlueToothConnectStatus(bool status);
     private:
@@ -31,9 +30,8 @@ namespace OHOS {
         SettingModel(const SettingModel &);
         SettingModel &operator=(const SettingModel &);
         virtual ~SettingModel();
-        static const uint16_t SETTING_ITEM_LEN = 4;
-        SettingItem settings[SETTING_ITEM_LEN] = { SETTING_ITEM_ZERO, nullptr, nullptr, false };
-        std::map<SettingIndex, AppViewId> settingIdToViewId;
+        SettingItem settings[SETTING_ITEM_COUNT] = { VIEW_INVALID, nullptr, nullptr, false };
+        int usedLen;
         bool btConnectStatus{false};
     };
 }
index f9b7424..fed442c 100755 (executable)
@@ -67,8 +67,13 @@ namespace OHOS {
         sNextImage.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);
     }
 
-    SettingIndex SettingItemView::GetSettingIndex()
+    AppViewId SettingItemView::GetViewId()
     {
-        return sItemInfo.index;
+        return sItemInfo.viewId;
+    }
+
+    const char* SettingItemView::GetIconId()
+    {
+        return sItemInfo.icon;
     }
 }
\ No newline at end of file
index 016996c..47c9c91 100755 (executable)
@@ -21,14 +21,15 @@ 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<SettingIndex, AppViewId>(SETTING_ITEM_ZERO, VIEW_BLUETOOTH_EARPHONE));
-        settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_ONE, VIEW_CONNECT_PHONE));
-        settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_TWO, VIEW_REBOOT));
-        settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_THREE, VIEW_REBOOT));
+        int index = 0;
+        settings[index++] = {VIEW_BLUETOOTH_EARPHONE, PNG_BLUETOOTH_STITLE, "蓝牙耳机", true};
+        settings[index++] = {VIEW_CONNECT_PHONE, PNG_CONNECT_PHONE_IMAGE, "连接手机", true};
+        settings[index++] = {VIEW_REBOOT, PNG_SETTTING_REBOOT_IMAGE, "重启", true};
+        settings[index++] = {VIEW_REBOOT, PNG_SETTTING_SHUTDOWN_IMAGE, "关机", true};
+        settings[index++] = {VIEW_SET_DESKTOP, PNG_SETTTING_DESKTOP_IMAGE, "桌面", true};
+        settings[index++] = {VIEW_SET_DIAL, PNG_SETTTING_DESKTOP_IMAGE, "表盘", true};
+        settings[index++] = {VIEW_SET_CARD, PNG_SETTTING_DESKTOP_IMAGE, "卡片", true};
+        usedLen = index;
     }
 
     const SettingItem *SettingModel::GetSettinglistItems() const
@@ -38,12 +39,7 @@ namespace OHOS {
 
     uint8_t SettingModel::GetSettingListNum() const
     {
-        return SETTING_ITEM_LEN;
-    }
-
-    const std::map<SettingIndex, AppViewId> &SettingModel::GetSettingIdToViewId() const
-    {
-        return settingIdToViewId;
+        return usedLen;
     }
 
     bool SettingModel::GetBlueToothConnectStatus(void)
index 6f6fd5a..368d367 100755 (executable)
@@ -56,20 +56,17 @@ namespace OHOS {
     {
         UNUSED(event);
         SettingItemView *settingItemView = static_cast<SettingItemView *>(&view);
-        SettingIndex index = settingItemView->GetSettingIndex();
-        if (index >= SettingModel::GetInstance().GetSettingListNum()) {
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnClick is no index");
-            return false;
-        } else {
-            if (index == SETTING_ITEM_TWO) {
+        AppViewId viewId = settingItemView->GetViewId();
+        if (viewId == VIEW_REBOOT) {
+            if (strstr(settingItemView->GetIconId(), "REBOOT") != nullptr){
                 RebootModel::GetInstance()->SetSelectViewId(REBOOTDEVICE);
                 RebootModel::GetInstance()->SetExitsView(true);
-            } else if (index == SETTING_ITEM_THREE) {
+            } else {
                 RebootModel::GetInstance()->SetSelectViewId(SHUTDOWNDEVICE);
                 RebootModel::GetInstance()->SetExitsView(true);
             }
-            NativeAbility::GetInstance().ChangeSlice(SettingModel::GetInstance().GetSettingIdToViewId().at(index));
-            return true;
         }
+        NativeAbility::GetInstance().ChangeSlice(viewId);
+        return true;
     }
 }
index 9de644b..b38f9a6 100755 (executable)
@@ -122,8 +122,6 @@ void SettingView::OnSetUpView()
     scrollView->Add(contentList);
     RootView::GetInstance()->Add(scrollView);
     contentList->SetAdapter(listAdapter);
-
-    Draw();
     return;
 }
 
index 9826b50..5f44a54 100755 (executable)
@@ -9,15 +9,11 @@
 #include "TempMainView.h"\r
 #include "ChangeSliceListener.h"\r
 #include "graphic_service.h"\r
+#include "ui_service.h"\r
 #include "string"\r
 #include "iostream"\r
 #include "sstream"\r
 \r
-#include "errcode.h"\r
-#include "pm_definition.h"\r
-extern "C" errcode_t uapi_pm_add_sleep_veto(pm_id_t veto_id);\r
-extern "C" errcode_t uapi_pm_remove_sleep_veto(pm_id_t veto_id);\r
-\r
 namespace OHOS {\r
 static TempPresenter *g_tempPresenter = nullptr;\r
 \r
@@ -47,13 +43,16 @@ void TempPresenter::OnStart()
 {\r
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter OnStart");\r
     Presenter<TempMainView>::OnStart();\r
+    SendMsgToUIService(UI_ADD_SLEEP_VETO, 0, NULL, 0);\r
 }\r
 \r
 void TempPresenter::OnPause(void) {}\r
 \r
 void TempPresenter::OnResume(void) {}\r
 \r
-void TempPresenter::OnStop(void) {}\r
+void TempPresenter::OnStop(void) {\r
+    SendMsgToUIService(UI_RM_SLEEP_VETO, 0, NULL, 0);\r
+}\r
 \r
 bool TempPresenter::OnDrag(UIView& view, const DragEvent& event)\r
 {\r
@@ -75,9 +74,6 @@ void TempPresenter::ProgressNotify(void)
     if (TempMeaProcess::GetInstance()->GetCircleStatus() == true &&\r
         TempMeaProcess::GetInstance()->GetCircleProgress() != nullptr) {\r
         if (countTemp > 0) {\r
-            if (countTemp == SET_HUNDRED) {\r
-                uapi_pm_add_sleep_veto(PM_ID_SCREEN);\r
-            }\r
             GraphicService::GetInstance()->PostGraphicEvent(std::bind(&TempPresenter::UpdateTempCount, this));\r
         } else {\r
             TempMeaProcess::GetInstance()->SetCircleStatus(false);\r
@@ -85,7 +81,6 @@ void TempPresenter::ProgressNotify(void)
                 TempMainView::GetInstance()->ChangeView(MEASURE_ING, MEASURE_INIT);\r
             }\r
             SetTempCountMax();\r
-            uapi_pm_remove_sleep_veto(PM_ID_SCREEN);\r
         }\r
     }\r
     return;\r
index 2214401..59fe703 100755 (executable)
@@ -8,6 +8,7 @@
 #include "UISampleView.h"
 #include "UISampleModel.h"
 #include "UISamplePresenter.h"
+#include "ui_service.h"
 
 namespace OHOS {
     UISamplePresenter::UISamplePresenter()
@@ -21,17 +22,16 @@ namespace OHOS {
     void UISamplePresenter::OnStart()
     {
         Presenter<UISampleView>::OnStart();
+        SendMsgToUIService(UI_ADD_SLEEP_VETO, 0, NULL, 0);
     }
 
     void UISamplePresenter::OnResume(void)
     {
-        if (view_ == nullptr) {
-            return;
-        }
     }
 
     void UISamplePresenter::OnStop(void)
     {
+        SendMsgToUIService(UI_RM_SLEEP_VETO, 0, NULL, 0);
         return;
     }
 
index db1ab83..a6307df 100755 (executable)
 #include "ui_test_running_ball/ui_test_running_ball.h"
 #endif
 #include "ui_test_tiger/ui_test_tiger.h"
+#include "ui_test_hexagons_list/ui_test_hexagons_list.h"
 #include "ui_test_video_play/ui_test_video_play.h"
+#include "ui_test_coverflow/ui_test_coverflow.h"
+#include "ui_test_kaleidoscope/ui_test_kaleidoscope.h"
 
 namespace OHOS {
 void UITestGroup::AddTestCase(TestCaseInfo testCaseInfo)
@@ -44,11 +47,14 @@ void UITestGroup::SetUpTestCase()
     }
     testCaseList_->Clear();
     testCaseList_->PushBack(TestCaseInfo{"老虎头", new UITestTiger()});
+    testCaseList_->PushBack(TestCaseInfo{"蜂窝表盘", new UITestHexagonsList()});
     testCaseList_->PushBack(TestCaseInfo{"滑动列表", new UITestListFPS()});
     testCaseList_->PushBack(TestCaseInfo{"卡片切换", new UITestCardSwitch()});
     testCaseList_->PushBack(TestCaseInfo{"立方体旋转", new UITestCubeRotate()});
     testCaseList_->PushBack(TestCaseInfo{"消息", new UITestMessage()});
     testCaseList_->PushBack(TestCaseInfo{"呼吸效果", new UITestBreath()});
+    testCaseList_->PushBack(TestCaseInfo{"覆盖流", new UITestCoverflow()});
+    testCaseList_->PushBack(TestCaseInfo{"万花筒", new UITestKaleidoscope()});
 
 #if ENABLE_VGU_ENGINE && CAPABILITY_HWDRAW_PATH
     testCaseList_->PushBack(TestCaseInfo{"倒计时", new UITestCountdown()});
index 5e442e7..4792e4f 100755 (executable)
@@ -47,6 +47,9 @@ typedef enum {
     SCREEN_TURN_ON_TO_UI,
     SCREEN_TURN_OFF_TO_UI,
     SCREEN_OFF_ENABLE_TO_UI,
+    UI_ADD_SLEEP_VETO,
+    UI_RM_SLEEP_VETO,
+
 } UiServiceMsgId;
 
 #define BUNDLE_NAME_LEN 128
index b12fcf3..3ede659 100755 (executable)
 #include "ui_screennotify.h"
 #include "HealthModel.h"
 
+#include "errcode.h"
+#include "pm_definition.h"
+extern "C" errcode_t uapi_pm_add_sleep_veto(pm_id_t veto_id);
+extern "C" errcode_t uapi_pm_remove_sleep_veto(pm_id_t veto_id);
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -158,7 +163,12 @@ void ServiceMsgProcess(Request *request)
         case SCREEN_OFF_ENABLE_TO_UI:
             ScreenOffEnable(request);
             break;
-
+        case UI_ADD_SLEEP_VETO:
+            uapi_pm_add_sleep_veto(PM_ID_SCREEN);
+            break;
+        case UI_RM_SLEEP_VETO:
+            uapi_pm_remove_sleep_veto(PM_ID_SCREEN);
+            break;
     }
     SAMGR_FreeRequestMsg(request);
 }
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_ACTIVITY.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_ACTIVITY.bin
new file mode 100644 (file)
index 0000000..45a459d
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_ACTIVITY.bin differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_ADD.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_ADD.bin
new file mode 100644 (file)
index 0000000..f308fc0
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_ADD.bin differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_COMPASS.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_COMPASS.bin
new file mode 100644 (file)
index 0000000..e253bbe
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_COMPASS.bin differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_DEL.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_DEL.bin
new file mode 100644 (file)
index 0000000..0c0adcb
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_DEL.bin differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_HEART.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_HEART.bin
new file mode 100644 (file)
index 0000000..a19125d
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_HEART.bin differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_PLAYER.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_PLAYER.bin
new file mode 100644 (file)
index 0000000..6b09852
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/CARD_PLAYER.bin differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/DIAL_CLOCK.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/DIAL_CLOCK.bin
new file mode 100644 (file)
index 0000000..7441412
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/DIAL_CLOCK.bin differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/SETTTING_DESKTOP.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/SETTTING_DESKTOP.bin
new file mode 100644 (file)
index 0000000..332ebc0
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/SETTTING_DESKTOP.bin differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/SET_DESKTOP_BG.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/SET_DESKTOP_BG.bin
new file mode 100644 (file)
index 0000000..fafbd1b
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/SET_DESKTOP_BG.bin differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/SET_DESKTOP_HEXAGONS.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/SET_DESKTOP_HEXAGONS.bin
new file mode 100644 (file)
index 0000000..6c94776
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/SET_DESKTOP_HEXAGONS.bin differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/SET_DESKTOP_LIST.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/SET_DESKTOP_LIST.bin
new file mode 100644 (file)
index 0000000..14547a2
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/SET_DESKTOP_LIST.bin differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/hexagons.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/hexagons.bin
new file mode 100644 (file)
index 0000000..f3dc2e8
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/hexagons.bin differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/kaleidoscope.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/kaleidoscope.bin
new file mode 100644 (file)
index 0000000..eac0b90
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/kaleidoscope.bin differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/planet.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/planet.bin
new file mode 100644 (file)
index 0000000..9a6e5ba
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/planet.bin differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/rabbit454.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/rabbit454.bin
new file mode 100644 (file)
index 0000000..f98a0c1
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/rabbit454.bin differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/rainbow.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/rainbow.bin
new file mode 100644 (file)
index 0000000..3419bad
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/evb4/fs/user/res/rainbow.bin differ
index f01bdee..be29f06 100755 (executable)
@@ -116,10 +116,11 @@ component_set = {
     'efuse_v120': ['efuse', 'hal_efuse_v120', 'efuse_porting'],
     'efuse_v100': ['efuse', 'hal_efuse_v100', 'efuse_porting'],
     'efuse_v130': ['efuse', 'hal_efuse_v130', 'efuse_port'],
-    'ohos_set' : ['bootstrap', 'samgr', 'ams', 'bms', 'ace', 'ace_adapt', 'permission', 'appverify', 'jerryscript','js_player', 'js_audio_captuer','i18n', 'resmgr', 'syspara'],
+    'ohos_set' : ['bootstrap', 'samgr', 'ams', 'bms', 'ace', 'ace_adapt', 'permission', 'appverify', 'jerryscript','js_player', 'js_audio_captuer', 'i18n',
+                  'resmgr', 'syspara', 'utils_kv_store', 'native_file'],
     'wearable_set' : ['nativeabilityfwk', 'ai_voice_service', 'ai_voice_engine_hal', 'ai_voice_audio_stream_wrapper', 'ohos_deps',
                       'broadcast', 'msg_center', 'msg_center_adapt', 'ohos_startup'],
-    'xts_set' : ["syspara", "utils_kv_store", "native_file", "xts_adapt", "ohos_drv_v3.2",
+    'xts_set' : ["xts_adapt", "ohos_drv_v3.2",
                  "hiview_lite", "hievent_lite", "hilog_lite", "huks_sdk"],
     'xts_test_set' : ["hctest", "ActsHuksHalFunctionTest", "huks_test_common", "ActsAbilityMgrTest", "ActsBundleMgrTest",
                       "ActsKvStoreTest", "ActsUtilsFileTest", "ActsHieventLiteTest", "ActsDfxFuncTest", "ActsWifiIotTest",
index 8867e30..43bcb9d 100755 (executable)
 /**
  * @brief Memory pool define.
  */
-#define ALIGN_UP(x, a) ((((x) + ((a)-1)) / (a)) * (a))
+#define ALIGN_UP(x, a) ((((x) + ((a) - 1)) / (a)) * (a))
 
 #ifndef CONFIG_PSRAM_SUPPORT // equal to MEMORY_MINI
 #define MEM_POOL_UI_POOL_SIZE  0x13c000 // 1408 - 144 = 1264k
index 5a1a1d1..f20d975 100755 (executable)
Binary files a/code/sdk/middleware/services/gui/hal/display/brandy-native-js/libdisplay_gfx.a and b/code/sdk/middleware/services/gui/hal/display/brandy-native-js/libdisplay_gfx.a differ
index 66994fb..eb73ea8 100755 (executable)
Binary files a/code/sdk/middleware/services/gui/hal/display/brandy-target1/libdisplay_gfx.a and b/code/sdk/middleware/services/gui/hal/display/brandy-target1/libdisplay_gfx.a differ
index 42abaaf..f5f1c39 100755 (executable)
Binary files a/code/sdk/middleware/services/gui/hal/display/brandy-target3/libdisplay_gfx.a and b/code/sdk/middleware/services/gui/hal/display/brandy-target3/libdisplay_gfx.a differ
index c8e9fcb..4a8ab12 100755 (executable)
Binary files a/code/sdk/middleware/services/gui/hal/display/brandy-target5/libdisplay_gfx.a and b/code/sdk/middleware/services/gui/hal/display/brandy-target5/libdisplay_gfx.a differ
index f0ca757..d78c316 100755 (executable)
Binary files a/code/sdk/middleware/services/gui/hal/display/brandy-xts/libdisplay_gfx.a and b/code/sdk/middleware/services/gui/hal/display/brandy-xts/libdisplay_gfx.a differ
index cf2f290..6f64ebd 100755 (executable)
@@ -147,7 +147,7 @@ static int32_t InitBufferHandle(BufferHandle *buffer, const AllocInfo *info)
     } else {
         const FormatInfo *fmtInfo = GetFormatInfo(info->format);
         if (fmtInfo == NULL) {
-            DISP_LOGE("%s: can not get format information : %d\n", __func__, buffer->format);
+            DISP_LOGE("%s: can not get format information : %d\n", __func__, info->format);
             return DISPLAY_FAILURE;
         }
 
index e3c1d6b..c2aa262 100755 (executable)
@@ -206,9 +206,15 @@ set(COMPONENT_SRC
     ${PROP_UI_SRC}/components_ext/text_ext.cpp\r
     ${PROP_UI_SRC}/components_ext/ui_label_button_ext.cpp\r
     ${PROP_UI_SRC}/components_ext/image_cache_manager.cpp\r
+    ${PROP_UI_SRC}/components_ext/ui_hexagons_list.cpp\r
     ${PROP_UI_SRC}/components_ext/ui_canvas_ext.cpp\r
     ${PROP_UI_SRC}/components_ext/ui_card_container.cpp\r
     ${PROP_UI_SRC}/components_ext/ui_cross_view.cpp\r
+    ${PROP_UI_SRC}/components_ext/kaleidoscope_utils.cpp\r
+    ${PROP_UI_SRC}/components_ext/ui_kaleidoscope_view.cpp\r
+    ${PROP_UI_SRC}/components_ext/ui_map_view.cpp\r
+    ${PROP_UI_SRC}/components_ext/map_svg_parser.cpp\r
+    ${PROP_UI_SRC}/components_ext/ui_coverflow_view.cpp\r
 )\r
 \r
 set(SOURCES\r
@@ -261,4 +267,4 @@ set(MAIN_COMPONENT
     false\r
 )\r
 \r
-build_component()
\ No newline at end of file
+build_component()\r
index 989d7e9..8161135 100755 (executable)
Binary files a/code/sdk/middleware/services/gui/uikit/brandy-native-js/libuikit_ext.a and b/code/sdk/middleware/services/gui/uikit/brandy-native-js/libuikit_ext.a differ
index efe4813..8161135 100755 (executable)
Binary files a/code/sdk/middleware/services/gui/uikit/brandy-target3/libuikit_ext.a and b/code/sdk/middleware/services/gui/uikit/brandy-target3/libuikit_ext.a differ
index 6a175b7..8161135 100755 (executable)
Binary files a/code/sdk/middleware/services/gui/uikit/brandy-xts/libuikit_ext.a and b/code/sdk/middleware/services/gui/uikit/brandy-xts/libuikit_ext.a differ
diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/kaleidoscope_utils.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/kaleidoscope_utils.h
new file mode 100644 (file)
index 0000000..c126d1b
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) @CompanyNameMagicTag. 2024. All rights reserved.
+ */
+
+/**
+ * @file kaleidoscope_utils.h
+ *
+ * @brief Declares a KaleidoscopeUtils.
+ */
+
+#ifndef KALEIDOSCOPE_UTILS_H
+#define KALEIDOSCOPE_UTILS_H
+
+#include "gfx_utils/heap_base.h"
+#include "components/ui_canvas_ext.h"
+#include "gfx_utils/image_info.h"
+
+namespace OHOS {
+
+typedef struct {
+    ImageInfo info;
+    uint32_t stride;
+} ImageInfoExt;
+
+class KaleidoscopeUtils : public HeapBase {
+public:
+
+    KaleidoscopeUtils() {};
+
+    virtual ~KaleidoscopeUtils();
+
+    /**
+    * @brief  Init KaleidoscopeUtils.
+    * @param  [in]  src    Pointer to a ImageInfo struct, which is the source img for kaleidoscope img.
+    * @param  [in]  dst    Pointer to a ImageInfoExt struct, which will be used to store kaleidoscope data.
+                           If it is NULL, it will be created and managed internally.
+    * @return Return true if init successfully; and false otherwise.
+    */
+    bool Init(const ImageInfo* src, const ImageInfoExt* dst);
+
+    /**
+    * @brief  Update the kaleidoscope img by a rotate value.
+    * @param  [in]  rotate    Rotate value.
+    * @return Return true if update successfully; and false otherwise.
+    */
+    bool Rotate(float rotate);
+
+    /**
+    * @brief  Update the address of kaleidoscope data, when init with an externally managed ImageInfoExt.
+    * @param  [in]  addr    Address of kaleidoscope data.
+    * @return Return true if update successfully; and false otherwise.
+    */
+    bool UpdateKaleidoscopeAddr(const uint8_t* addr);
+
+    /**
+    * @brief  Obtain kaleidoscope img.
+    * @return Return pointer to ImageInfoExt struct.
+    */
+    ImageInfoExt* GetKaleidoscopeInfo();
+
+private:
+    ImageInfo* imgInfo_ = nullptr;
+    ImageInfoExt* kaleidoscopeInfo_ = nullptr;
+    ImageInfoExt* partialInfo_ = nullptr;
+    Path sectorPath_ = {0};
+    Path imgPath_ = {0};
+    float thetaVal_ = 0.0f;
+    float radius_ = 0.0f;
+    Point point_ = {0, 0};
+    Point startPoint_ = {0, 0};
+    bool isInternalMem_ = false;
+
+    void UpdatePoint(float rotate);
+    bool ConstructPartial();
+    bool ConstructKaleidoscope();
+    Rect GetBoundingArea(const ImageHeader& header);
+    bool InitKaleidoscopeInfo(const ImageInfo* src, const ImageInfoExt* dst);
+    bool InitInnerPath();
+    bool InitPartialInfo();
+    void DeinitKaleidoscopeInfo();
+    void DeInitPartialInfo();
+    void DeinitInnerPath();
+    void DeinitImgInfo();
+    bool ConstructFirstQuadrant(BufferInfo& bufferInfo);
+    bool ConstructRestQuadrant(BufferInfo& bufferInfo);
+};
+}
+#endif
+/**
+ * @}
+ */
index 57cbacd..ac83426 100644 (file)
@@ -51,7 +51,7 @@ public:
      * @since 3.0
      * @version 5.0
      */
-    virtual ~UIBarcode();
+    ~UIBarcode() override;
 
     /**
      * @brief Sets the bar code information.
index a51a2bd..d3b668c 100755 (executable)
@@ -49,7 +49,7 @@ public:
      * @since 1.0
      * @version 1.0
      */
-    virtual ~UICardPage() {}
+    ~UICardPage() override {}
 
     /* *
      * @brief Preload resource callback function, it will be called at the end of swipe animator or the function
@@ -132,6 +132,13 @@ public:
         return UI_CARD_PAGE;
     }
 
+    /* *
+     * @brief Clear the image cache of this page.
+     * @since 1.0
+     * @version 1.0
+     */
+    void ClearCache(void);
+
 private:
     bool isCoverable_ = false;
 };
diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_coverflow_view.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_coverflow_view.h
new file mode 100644 (file)
index 0000000..e063a8a
--- /dev/null
@@ -0,0 +1,110 @@
+/*\r
+ * Copyright (c) 2024 CompanyNameMagicTag.\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#ifndef UI_COVERFLOW_VIEW_H\r
+#define UI_COVERFLOW_VIEW_H\r
+#include "components/ui_swipe_view.h"\r
+#include <string>\r
+#include <map>\r
+#include "components/ui_image_view.h"\r
+#include "components/ui_label.h"\r
+\r
+namespace OHOS {\r
+class UICoverflowView : public UISwipeView {\r
+public:\r
+    UICoverflowView();\r
+    ~UICoverflowView() override;\r
+\r
+    /**\r
+     * @brief Add a item to coverflow.\r
+     *\r
+     * @param id Indicates the pointer to the view ID.\r
+     * @param src point item show main image imageinfo.\r
+     */\r
+    void Add(const char* id, const ImageInfo* src);\r
+\r
+    /**\r
+     * @brief remove a item from coverflow.\r
+     *\r
+     * @param id Indicates the pointer to the view ID.\r
+     */\r
+    void Remove(const char* id);\r
+\r
+    /**\r
+     * @brief Set center item width in static display mode.\r
+     *\r
+     * @param width setting item width.\r
+     */\r
+    void SetItemWidth(uint16_t width);\r
+\r
+    /**\r
+     * @brief Set ratote angle between the left and right items in static display mode.\r
+     *\r
+     * @param angle setting ratote angle.\r
+     */\r
+    void SetRotateAngle(float angle);\r
+\r
+    /**\r
+     * @brief Set mirror image opacity.\r
+     *\r
+     * @param opa setting mirror opacity value.\r
+     */\r
+    void SetMirrorOpacity(uint8_t opa);\r
+\r
+    /**\r
+     * @brief Represents a listener for swipe of the coverflow view.\r
+     */\r
+    class OnCoverflowScrollListener : public HeapBase {\r
+    public:\r
+        virtual bool OnScroll() = 0;\r
+        virtual ~OnCoverflowScrollListener() {}\r
+    };\r
+\r
+    /**\r
+     * @brief Sets the listener that contains a callback to be invoked upon a swipe event.\r
+     *\r
+     * @param onCoverflowListener Indicates the listener to set.\r
+     * @since 1.0\r
+     * @version 1.0\r
+     */\r
+    void SetOnCoverflowListener(OnCoverflowScrollListener* onCoverflowListener)\r
+    {\r
+        coverflowListener_ = onCoverflowListener;\r
+    }\r
+\r
+    void SetDirection(uint8_t direction) = delete;\r
+    uint8_t GetDirection() const = delete;\r
+protected:\r
+    bool DragXInner(int16_t distance) override;\r
+\r
+private:\r
+    void UpdatePerspectiveMatrix();\r
+    void ReMeasure(void) override;\r
+    void TransformImage(UIImageView* view);\r
+    void TransformPage(uint16_t index);\r
+    void DeleteGroup(UIViewGroup* group);\r
+\r
+    using UISwipeView::Add;\r
+    using UISwipeView::Remove;\r
+\r
+    OnCoverflowScrollListener* coverflowListener_;\r
+    uint16_t itemWidth_;\r
+    uint8_t mirrorOpa_;\r
+    float rotateAngle_;\r
+    std::map<UIView*, Matrix4<float>> map_;\r
+    Matrix4<float> perspectiveMatrix_;\r
+};\r
+} // namespace OHOS\r
+#endif // UI_COVERFLOW_VIEW_H\r
index 0f05ee0..e0d4fef 100755 (executable)
@@ -40,6 +40,9 @@ namespace OHOS {
  */
 class UICrossView : public UIViewGroup, public UISwipeView::OnSwipeListener {
 public:
+    UICrossView(const UICrossView &) = delete;
+    UICrossView &operator=(const UICrossView &) = delete;
+
     /* *
      * @brief Scale align mode.
      */
@@ -60,7 +63,7 @@ public:
      * @since 1.0
      * @version 1.0
      */
-    virtual ~UICrossView() override;
+    ~UICrossView() override;
 
     /* *
      * @brief Get the static instance for <b>UICrossView</b>.
@@ -89,7 +92,7 @@ public:
     void HorAdd(UICardPage* view);
 
     /* *
-     * @brief Insert view by horizontal direction.
+     * @brief Insert view by horizontal direction. set as first page if preview is nullptr
      * @since 1.0
      * @version 1.0
      */
@@ -203,18 +206,22 @@ public:
     }
 
 private:
+    void UpdateCardPageIndex();
+    static constexpr uint16_t INVALID_VIEW_INDEX = 0xff;
     bool loop_ = false;
     bool enableScreenCap_ = false;
     bool GaussianBlurEnable_ = false;
     int swipeDirect_ = 0;
     int pullIndex_ = 0;
-    int16_t hDragStartIndex_ = 0xff;
-    int16_t vBlankIndex_ = 0xff;
-    UIView* Vertblank_ = nullptr;
+    int16_t hDragStartIndex_ = INVALID_VIEW_INDEX;
+    int16_t vBlankIndex_ = INVALID_VIEW_INDEX;
+    UIView* vBlankView_ = nullptr;
     UISwipeView vertical_;
     HorSwipeView horizontal_;
+    UIView* tailView_ = nullptr;
     UISwipeView::OnSwipeListener *swipeListener_ = nullptr;
 
+    void RemoveAllInner(UISwipeView& view);
     void ProcessRes(void);
     void VertSetGausBlur(uint16_t direct);
     void HorHandleCardEvent(int16_t index, uint16_t scrollStage);
diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_custom_hexagons_list.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_custom_hexagons_list.h
new file mode 100644 (file)
index 0000000..a17072c
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) @CompanyNameMagicTag. 2024. All rights reserved.
+ */
+
+#ifndef UI_HEXAGONS_LIST_EXT_H
+#define UI_HEXAGONS_LIST_EXT_H
+#include "components/ui_hexagons_list.h"
+
+namespace OHOS {
+class UICustomHexagonsList : public UIHexagonsList {
+public:
+    UICustomHexagonsList() {}
+    ~UICustomHexagonsList() override;
+    UICustomHexagonsList(const UICustomHexagonsList &) = delete;
+    UICustomHexagonsList &operator=(const UICustomHexagonsList &) = delete;
+
+#if ENABLE_ROTATE_INPUT
+    bool OnRotateStartEvent(const RotateEvent& event) override;
+
+    bool OnRotateEvent(const RotateEvent& event) override;
+
+    bool OnRotateEndEvent(const RotateEvent& event) override;
+#endif
+    void StartRotateAnimator(uint8_t center, int16_t xDistance, int16_t yDistance, float startScale, float endScale);
+    void StopRotateAnimator();
+    float GetScaleInSmallState()
+    {
+        return scaleInSmallState_;
+    }
+
+protected:
+    class RotateAnimatorCallback : public ListAnimatorCallback {
+    public:
+        RotateAnimatorCallback();
+        ~RotateAnimatorCallback() override {}
+        RotateAnimatorCallback(const RotateAnimatorCallback &) = delete;
+        RotateAnimatorCallback &operator=(const RotateAnimatorCallback &) = delete;
+
+        void SetDuration(uint16_t times)
+        {
+            totalTime_ = times;
+        }
+
+        void SetCenterIndex(uint8_t center)
+        {
+            centerIndex_ = center;
+        }
+
+        void SetRotateRange(int16_t xDistance, int16_t yDistance, float startScale, float endScale)
+        {
+            xDistance_ = xDistance;
+            yDistance_ = yDistance;
+            startScale_ = startScale;
+            endScale_ = endScale;
+        }
+
+        void ResetCallback()
+        {
+            curTime_ = 0;
+            totalTime_ = 0;
+            xDistance_ = 0;
+            prevX_ = 0;
+            yDistance_ = 0;
+            prevY_ = 0;
+            startScale_ = 0.0f;
+            endScale_ = 0.0f;
+            centerIndex_ = 0;
+        }
+
+        void Callback(UIView* view) override;
+
+    private:
+        uint16_t curTime_;
+        uint16_t totalTime_;
+        int16_t xDistance_;
+        int16_t yDistance_;
+        int16_t prevX_;
+        int16_t prevY_;
+        float startScale_;
+        float endScale_;
+        uint8_t centerIndex_;
+    };
+private:
+    RotateAnimatorCallback rotateCallback_;
+    Animator* rotateAnimator_ = nullptr;
+    float scaleInSmallState_ = 0.42f;
+    uint8_t rotateCenterIndexInNormal_ = 0;
+};
+}
+#endif // UI_HEXAGONS_LIST_EXT_H
\ No newline at end of file
diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_hexagons_list.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_hexagons_list.h
new file mode 100644 (file)
index 0000000..5a7e3d1
--- /dev/null
@@ -0,0 +1,231 @@
+/*
+ * Copyright (c) @CompanyNameMagicTag. 2024. All rights reserved.
+ */
+
+#ifndef UI_HEXAGONS_LIST_H
+#define UI_HEXAGONS_LIST_H
+
+#include "components/ui_view.h"
+#include "components/ui_abstract_scroll.h"
+#include "components/ui_scroll_view.h"
+#include "gfx_utils/list.h"
+#include "gfx_utils/vector.h"
+
+namespace OHOS {
+class UIHexagonsList : public UIScrollView {
+public:
+    UIHexagonsList();
+
+    ~UIHexagonsList() override {}
+
+    /**
+     * @brief Set origin image distance between the center of the two adjacent images
+     *        imageDistance = oriImgDistance * globalScale
+     *        globalScale: refer to function Scale
+     *        LayoutChildren(true) must be invoked mannualy after invoking this method.
+     *
+     * @param distance Indicates image distance to set when the image in the center region
+     */
+    void SetImageDistance(uint16_t distance)
+    {
+        oriImgDistance_ = distance;
+    }
+
+    /**
+     * @brief Set image size
+     *        LayoutChildren(true) must be invoked mannualy after invoking this method.
+     *
+     * @param size Indicates size to set, when the image in the center
+     */
+    void SetImageSizeInCenter(uint16_t size)
+    {
+        imgSizeInCenter_ = size;
+    }
+
+    /**
+     * @brief Set origin image scale factor, scale strategy will follow the below rules
+     *        if globalScale >= 1
+     *           scaleFactor = oriScaleFactor
+     *        elif globalScale > scaleThreshold
+     *           scaleFactor = oriScaleFactor * (globalScale - scaleThreshold) / (1 - scaleThrethold)
+     *        else
+     *           scaleFactor = 0
+     *        img size is inversely proportional to distance * scaleFactor
+     *
+     *        oriScaleFactor: refer to function SetScaleFactorByDistance
+     *        scaleThreshold: refer to function SetScaleThesholdOfZeroFactor
+     *        globalScale: refer to function Scale
+     *
+     * @param factor Indicates scale factor to set, which will decide scale value together with distance
+     */
+    void SetScaleFactorByDistance(float factor)
+    {
+        oriScaleFactor_ = factor;
+    }
+
+    float GetScaleFactorByDistance()
+    {
+        return oriScaleFactor_;
+    }
+
+    /**
+     * @brief Set scale threshold, scale factor will decrese to 0 if global scale equal and less than scaleThreshold,
+     *        default value is 0.6, more information can  refer to method SetScaleFactorByDistance
+     *
+     * @param threshold Indicates factor to set, the scale factor when the image is not in the center
+     */
+    void SetScaleThesholdOfZeroFactor(float threshold)
+    {
+        scaleThresholdOfZeroFactor_ = threshold;
+    }
+
+    float GetScaleThesholdOfZeroFactor()
+    {
+        return scaleThresholdOfZeroFactor_;
+    }
+
+    /**
+     * @brief Adds a child image view whose resize mode will set to be UIImageView::COVER.
+     *        LayoutChildren(true) should be invoked mannualy after invoking this method.
+     *        Note: View index was set for children innner in order of addition, so you can
+     *        get its index by call method GetViewIndex()
+     *
+     * @param view Indicates the pointer to the child view to add.
+     */
+    void Add(UIView* view) override;
+
+    /**
+     * @brief Inserts a child image view whose resize mode will set to be UIImageView::COVER.
+     *        LayoutChildren(true) should be invoked mannualy after invoking this method.
+     *        Note: View index was set for children innner in order of addition, so you can
+     *        get its index by call method GetViewIndex()
+     *
+     * @param prevView Indicates the pointer to the child image view, previous to the new child image view.
+     * @param view Indicates the pointer to the new child image view to insert.
+     */
+    void Insert(UIView* prevView, UIView* insertView) override;
+
+    bool OnDragEvent(const DragEvent& event) override;
+
+    /**
+     * @brief Lays out all children views according to the hexagons shape, it must be invoked after method:
+     *        1. Add(UIView* view)
+     *        2. Insert(UIView* prevView, UIView* insertView)
+     *        3. void SetImageSizeInCenter(uint16_t size)
+     *        4. void SetImageDistance(uint16_t distance)
+     *
+     * @param needInvalidate Specifies whether to refresh the invalidated area after the layout is complete.
+     *                       Value <b>true</b> means to refresh the invalidated area after the layout is complete,
+     *                       and <b>false</b> means the opposite.
+     */
+    void LayoutChildren(bool needInvalidate = false) override;
+
+    /**
+     * @brief Moves all child views.
+     *
+     * @param x Indicates the offset distance by which this view group is moved on the x-axis.
+     * @param y Indicates the offset distance by which this view group is moved on the y-axis.
+     */
+    void MoveChildByOffset(int16_t offsetX, int16_t offsetY) override;
+
+    /**
+     * @brief Set global scale, and image with centerIndex will be focused
+     *
+     * @param scale Indicates global scale value both for x- and y- axes.
+     * @param pivot Indicates index of scaling center.
+     */
+    void Scale(float scale, uint8_t centerIndex);
+
+    float GetGlobalScale()
+    {
+        return globalScale_;
+    }
+
+    /**
+     * @brief Get the Index Of View object in this view group
+     *
+     * @param view, Indicates the view to search
+     * @return Returns the index, -1 if not exsit
+     */
+    UIView* GetViewByIndex(uint8_t index);
+
+    enum class ReboundMode : uint8_t {
+        NEAREST_IMG_ON_SCR_CENTER,
+        CENTER_IMG_ON_SCR_CENTER,
+        NORMAL, // same with UIScrollView
+    };
+
+    void SetReboundMode(ReboundMode mode)
+    {
+        reboundMode = mode;
+    }
+
+    /**
+     * @brief Get index of focused image, default 0, changed by scale and scroll
+     *        When scroll animator end, the index of image in the center screen will set to be focus index
+     *        When start Scale(scale, index), scale center index will set to be focus index
+     * @return Returns index of focused image, -1 if rebound mode is NORMAL
+     */
+    int8_t GetFocusedImgIndex()
+    {
+        if (reboundMode == ReboundMode::NORMAL) {
+            return -1;
+        } else {
+            return focusImgIndex_;
+        }
+    }
+
+    /**
+     * @brief Get center position of the special(index) image
+     *        Note: the position is not actual position, it is position in regular hexagon without futher adjustment
+     *        which include adjusting the img zoom and distance in order to improve display experience
+     *
+     * @return Returns postion in regular hexagon
+     */
+    Vector2<int16_t> GetCurrentPosition(uint8_t index);
+
+protected:
+    bool DragXInner(int16_t distance) override;
+    bool DragYInner(int16_t distance) override;
+    void ReMeasure() override;
+    /**
+     * @brief Get center position of the special(index) image when scale and center image index in screen is specified
+     *
+     * @return Returns position
+     */
+    Vector2<int16_t> GetPositionWithCondition(uint8_t index, uint8_t centerIndex, float scale);
+
+    float globalScale_{1.0f};
+    float scaleThresholdOfZeroFactor_{0.75f};
+
+private:
+    void InitParametersAndImgIndex();
+    bool IsCenterInPolygons(const Vector2<int16_t>& offset = {0, 0});
+    Rect GetChildrenRegion();
+    void CalculateAdjustDistanceForRectScreen(Vector2<float>& position, float& imgScaleRatio);
+    void AdjustViewByDistance(UIView& view, const Vector2<int16_t>& position);
+    void CalculateReboundDistance(int16_t& dragDistanceX, int16_t& dragDistanceY) override;
+    void CalculateReboundDistanceForNormal(int16_t& dragDistanceX, int16_t& dragDistanceY);
+    void CalculateReboundDistanceForNearestOnCenter(int16_t& dragDistanceX, int16_t& dragDistanceY);
+    void CalculateNearestPointFromOutterPoint(const Vector2<int16_t>& outerPoint);
+    void UpdateNearestPointFromFixedPoint(const Vector2<int16_t>& fixedPoint, uint8_t index);
+    void CreatePolygons(uint16_t lap, int16_t angle);
+    Graphic::Vector<Vector2<int16_t>> imgPoints_{64};
+    uint16_t maxLap_ = 0;
+    uint16_t maxAngleInMaxLap_ = 0;
+    Graphic::Vector<uint8_t> polygonPoints_{10};
+    uint16_t imgDistance_{0};
+    uint16_t oriImgDistance_{0};
+    float oriScaleFactor_{0.23f};
+    int16_t imgSizeInCenter_{0};
+    uint32_t minDistancePow_{0xFFFFFFFF};
+    uint8_t nearestIndex_{0};
+    uint8_t focusImgIndex_{0};
+    float oriImgRadius_{0.0f};
+    float imgRadius_{0.0f};
+    int16_t centerX_{0};
+    int16_t centerY_{0};
+    ReboundMode reboundMode{ReboundMode::NEAREST_IMG_ON_SCR_CENTER};
+};
+}
+#endif // UI_HEXAGONS_LIST_H
\ No newline at end of file
diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_kaleidoscope_view.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_kaleidoscope_view.h
new file mode 100644 (file)
index 0000000..fcb0021
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) @CompanyNameMagicTag. 2024. All rights reserved.
+ */
+
+/**
+ * @addtogroup UI_Components
+ * @{
+ *
+ * @brief Defines UI components such as buttons, texts, images, lists, and progress bars.
+ */
+
+/**
+ * @file ui_kaleidoscope_view.h
+ *
+ * @brief Declares a UIKaleidoscopeView.
+ */
+
+#ifndef UI_KALEIDOSCOPE_VIEW_H
+#define UI_KALEIDOSCOPE_VIEW_H
+
+#include "components/ui_view.h"
+#include "gfx_utils/image_info.h"
+#include "components/kaleidoscope_utils.h"
+#include "hals/display_dev.h"
+
+namespace OHOS {
+/**
+ * @brief It provide kaleidoscope view.
+ */
+class UIKaleidoscopeView : public UIView {
+public:
+    UIKaleidoscopeView(const UIKaleidoscopeView &) = delete;
+    UIKaleidoscopeView &operator=(const UIKaleidoscopeView &) = delete;
+
+    /**
+     * @brief A constructor used to create the <b>UIKaleidoscopeView</b> instance.
+              This view will directly modify the buffer, and it is the same size as the screen.
+     */
+    UIKaleidoscopeView();
+
+    /**
+     * @brief A destructor used to delete the <b>UIKaleidoscopeView</b> instance.
+     */
+    ~UIKaleidoscopeView() override;
+
+    /**
+     * @brief Obtains the view type.
+     * @return Returns <b>UI_KALEIDOSCOPE_VIEW</b>, as defined in {@link UIViewType}.
+     */
+    UIViewType GetViewType() const override
+    {
+        return UI_KALEIDOSCOPE_VIEW;
+    }
+
+    /**
+    * @brief  Set src img for kaleidoscope.
+    * @param  [in]  src    Pointer to a ImageInfo struct, which is the source img for kaleidoscope img.
+                           The size of img must match the size of screen.
+    * @return Return true if set successfully; and false otherwise.
+    */
+    bool SetSrc(const ImageInfo* info);
+
+    /**
+    * @brief  Update the kaleidoscope by a rotate value.
+    * @param  [in]  rotate    Rotate value.
+    */
+    void Rotate(float rotate);
+
+#if ENABLE_ROTATE_INPUT
+    /**
+    * @brief  Set rotate factor for rotate event.
+    */
+    void SetRotateEventFactor(float factor);
+
+    /**
+    * @brief  Handle Rotate Event. Update the kaleidoscope by a rotate event.
+    * @param  [in]  event    Rotate event.
+    */
+    bool OnRotateEvent(const RotateEvent& event) override;
+#endif
+
+    /**
+    * @brief  Set rotate value for rotate animator callback.
+    * @param  [in]  rotate    Rotate value.
+    */
+    void SetRotateAnimatorValue(float rotate);
+
+    /**
+    * @brief  Start rotate animator
+    */
+    void StartRotateAnimator();
+
+    /**
+    * @brief  Stop rotate animator
+    */
+    void StopRotateAnimator();
+
+    void OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea) override;
+private:
+    class RotateCallback : public AnimatorCallback {
+    public:
+        RotateCallback() {}
+        ~RotateCallback() override {}
+        void SetRotateValue(float rotate);
+        void Callback(UIView* view) override;
+    private:
+        float rotate_ = 0.0f;
+    };
+
+#if ENABLE_ROTATE_INPUT
+    float factor_ = 1.0f;
+#endif
+    float rotate_ = 0.0f;
+    KaleidoscopeUtils kaleidoscope_;
+    RotateCallback callback_;
+    Animator* animator_ = nullptr;
+};
+}
+#endif
+/**
+ * @}
+ */
diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_map_view.h b/code/sdk/middleware/services/gui/uikit/proprietary/include/components/ui_map_view.h
new file mode 100644 (file)
index 0000000..75a2557
--- /dev/null
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2024 CompanyNameMagicTag.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @addtogroup UI_Components
+ * @{
+ *
+ * @brief Defines UI components such as buttons, texts, images, lists, and progress bars.
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+
+/**
+ * @file ui_map_view.h
+ *
+ * @brief Defines the class to extend canvas/paint ability.
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+
+#ifndef GRAPHIC_LITE_UI_MAP_VIEW_H
+#define GRAPHIC_LITE_UI_MAP_VIEW_H
+#include "components_ext/map_svg_parser.h"
+#include "components/ui_view_group.h"
+
+namespace OHOS {
+#if ENABLE_VGU_ENGINE && CAPABILITY_HWDRAW_PATH
+struct POIInfo {
+    ImageDetail* img;
+    TextDetail* text[2];
+    uint8_t tag;
+    uint16_t rank;
+    uint16_t id;
+    Rect rect;
+    Point orignPos;
+    bool visible;
+};
+
+struct RoadInfo {
+    TextDetail* text;
+    Rect rect;
+    Point orignPos;
+    bool visible;
+};
+
+class OnPOIClickListener : public HeapBase {
+public:
+    /* *
+     * @brief Called when a POI is clicked.
+     * @since 1.0
+     * @version 1.0
+     */
+    virtual bool OnClick(uint32_t index)
+    {
+        return false;
+    }
+
+    /* *
+     * @brief A destructor used to delete the <b>OnPOIClickListener</b> instance.
+     * @since 1.0
+     * @version 1.0
+     */
+    virtual ~OnPOIClickListener() {}
+};
+
+class UIMapView : public UIViewGroup, public UIView::OnClickListener {
+public:
+    UIMapView(const UIMapView &) = delete;
+    UIMapView &operator=(const UIMapView &) = delete;
+
+    /* *
+     * @brief A constructor used to create an <b>UIMapView</b> instance.
+     *
+     */
+    UIMapView();
+
+    /* *
+     * @brief A destructor used to delete the <b>UIMapView</b> instance.
+     *
+     */
+    ~UIMapView() override;
+
+    /* *
+     * @brief Get current view type.
+     *
+     */
+    UIViewType GetViewType() const override
+    {
+        return UI_MAP_VIEW;
+    }
+
+    /* *
+     * @brief Set SVG src with file path.
+     *
+     */
+    bool SetSVG(const char* path);
+
+    /* *
+     * @brief Set SVG src with file buffer.
+     *
+     */
+    bool SetSVG(uint8_t* data, uint32_t length);
+
+    /* *
+     * @brief Set POI on cick listener.
+     *
+     */
+    void SetOnPOIClickListener(OnPOIClickListener* listener);
+
+    /* *
+     * @brief Enable cache. It will cache this tile immediately when enable is true,
+     *        and free cache buffer immediately. We need to enable cache when setting svg,
+     *        or after scale map finished, and disable cache before scale map.
+     *
+     */
+    void EnableCache(bool enable);
+
+    /* *
+     * @brief Used to scale map base the target point.
+     *
+     */
+    void ScaleMap(float scale, const Vector2<float>& pivot);
+
+    /* *
+     * @brief Hide the POI by tag.
+     *
+     */
+    void HidePOI(uint16_t tag, bool isHide = true);
+    void SetX(int16_t x) override;
+    void SetY(int16_t x) override;
+
+private:
+    POIInfo* POIs_ = nullptr;
+    RoadInfo* roads_ = nullptr;
+    OnPOIClickListener* POIlistener_ = nullptr;
+    bool cacheEnable_ = false;
+    bool needUpdate_ = false;
+    ImageInfo cacheInfo_ = {{0}};
+    MapSVGParser parser_;
+    uint8_t* data_ = nullptr;
+    char* filePath_ = nullptr;
+    PathDetail* pathArray_ = nullptr;
+    uint8_t pathCount_ = 0;
+    RoadDetail* roadArray_ = nullptr;
+    uint8_t roadCount_ = 0;
+    POIDetail* POIArray_ = nullptr;
+    uint8_t POICount_ = 0;
+    char* fontName_ = DEFAULT_VECTOR_FONT_FILENAME;
+    uint8_t fontId_ = 0xff;
+    uint8_t fontSize_ = 0;
+    uint32_t POIMask_ = 0;
+    float scale_ = 1.0f;
+
+    void DrawPath(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea);
+    void DrawText(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea, TextDetail& info, Point offset = {0, 0},
+        bool isPOIText = false);
+    Rect DrawImage(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea, ImageInfo& info, MapRect& rect);
+    void DrawPOIs(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea);
+    void DrawRoads(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea);
+    bool RenderMapToCache(void);
+    void OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea) override;
+    bool OnClick(UIView& view, const ClickEvent& event) override;
+    void HandlePOICollision();
+    void HandleRoadCollision();
+    bool InitPOIInfo(int num);
+    bool InitRoadInfo(int num);
+    void ClearSVG();
+};
+#endif
+}
+#endif
+/**
+ * @}
+ */
index 5463c07..d2bea3e 100755 (executable)
@@ -48,6 +48,9 @@ namespace OHOS {
  */\r
 class UIMenuItem : public UIButton {\r
 public:\r
+    UIMenuItem(const UIMenuItem &) = delete;\r
+    UIMenuItem &operator=(const UIMenuItem &) = delete;\r
+\r
     /**\r
      * @brief Scale align mode.\r
      */\r
@@ -85,7 +88,7 @@ public:
         return UI_MENU_ITEM;\r
     }\r
 \r
-    /**
+    /**\r
      * @brief Sets the image path for menu image.\r
      *\r
      * @since 1.0\r
diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_custom_hexagons_list.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/ui_custom_hexagons_list.cpp
new file mode 100644 (file)
index 0000000..c6a48d5
--- /dev/null
@@ -0,0 +1,187 @@
+/*
+ * Copyright (c) @CompanyNameMagicTag. 2024. All rights reserved.
+ */
+
+#include "components/ui_custom_hexagons_list.h"
+#include "animator/easing_equation.h"
+
+namespace OHOS {
+static const float TRASPANRENT_SCALE = 2.5f;
+static const float ROTATE_SCALE_FACTOR = 0.02f;
+static const float SCALE_SMALLEST_VALUE = 0.1f;
+static const float ROTATE_ANIMATION_DURATION = 10;
+
+UICustomHexagonsList::~UICustomHexagonsList()
+{
+    if (rotateAnimator_ != nullptr) {
+        delete rotateAnimator_;
+        rotateAnimator_ = nullptr;
+    }
+}
+
+UICustomHexagonsList::RotateAnimatorCallback::RotateAnimatorCallback()
+    : curTime_(0),
+      totalTime_(0),
+      xDistance_(0),
+      yDistance_(0),
+      prevX_(0),
+      prevY_(0),
+      startScale_(0.0f),
+      endScale_(0.0f),
+      centerIndex_(0)
+{}
+
+void UICustomHexagonsList::RotateAnimatorCallback::Callback(UIView* view)
+{
+    UICustomHexagonsList* hexView = dynamic_cast<UICustomHexagonsList*>(view);
+    if (hexView == nullptr) {
+        return;
+    }
+    curTime_++;
+    if (curTime_ > totalTime_) {
+        hexView->StopRotateAnimator();
+        return;
+    }
+    float timeRatio = curTime_ * 1.0f / totalTime_;
+    if (!FloatEqual(xDistance_, 0)) {
+        if (!FloatEqual(prevX_, xDistance_)) {
+            int16_t curX = static_cast<int16_t>(timeRatio * xDistance_);
+            hexView->DragXInner(curX - prevX_);
+            prevX_ = curX;
+        }
+    }
+    if (!FloatEqual(yDistance_, 0)) {
+        if (!FloatEqual(prevY_, yDistance_)) {
+            int16_t curY = static_cast<int16_t>(timeRatio * yDistance_);
+            hexView->DragYInner(curY - prevY_);
+            prevY_ = curY;
+        }
+    }
+    float curScale = timeRatio * (endScale_ - startScale_) + startScale_;
+    if (FloatMoreEqual(curScale, 1.0f)) {
+        uint8_t opa = static_cast<uint8_t>((1 - (curScale - 1.0f) / (TRASPANRENT_SCALE - 1.0f)) * OPA_OPAQUE);
+        hexView->GetViewByIndex(centerIndex_)->SetOpaScale(opa);
+    }
+    if ((FloatMore(startScale_, endScale_) && (curScale >= endScale_)) ||
+        (FloatLess(startScale_, endScale_) || (curScale <= endScale_))) {
+        hexView->Scale(curScale, centerIndex_);
+    }
+    if (FloatEqual(curScale, endScale_)) {
+        hexView->StopRotateAnimator();
+    }
+}
+
+void UICustomHexagonsList::StartRotateAnimator(uint8_t center, int16_t xDistance, int16_t yDistance,
+    float startScale, float endScale)
+{
+    if (rotateAnimator_ == nullptr) {
+        rotateAnimator_ = new Animator(&rotateCallback_, this, 0, true);
+    }
+    rotateCallback_.ResetCallback();
+    rotateCallback_.SetCenterIndex(center);
+    rotateCallback_.SetDuration(ROTATE_ANIMATION_DURATION);
+    rotateCallback_.SetRotateRange(xDistance, yDistance, startScale, endScale);
+    rotateAnimator_->Start();
+}
+
+void UICustomHexagonsList::StopRotateAnimator()
+{
+    rotateAnimator_->Stop();
+    rotateCallback_.ResetCallback();
+}
+
+#if ENABLE_ROTATE_INPUT
+bool UICustomHexagonsList::OnRotateStartEvent(const RotateEvent& event)
+{
+    if (scrollAnimator_.GetState() != Animator::STOP) {
+        UIAbstractScroll::StopAnimator();
+    }
+    if ((rotateAnimator_ != nullptr) && (rotateAnimator_->GetState() != Animator::STOP)) {
+        StopRotateAnimator();
+    }
+
+    // Record rotate center index when scale is large than 1.0f
+    if (FloatMoreEqual(GetGlobalScale(), 1.0f)) {
+        int8_t focusIndex = GetFocusedImgIndex();
+        if (focusIndex < 0) {
+            GRAPHIC_LOGE("wrong focus index %d, force to be 0 !!", focusIndex);
+            rotateCenterIndexInNormal_ = 0;
+        } else {
+            rotateCenterIndexInNormal_ = static_cast<uint8_t>(focusIndex);
+        }
+    }
+    return UIView::OnRotateStartEvent(event);
+}
+
+bool UICustomHexagonsList::OnRotateEvent(const RotateEvent& event)
+{
+    float deltaScale = event.GetRotate() * ROTATE_SCALE_FACTOR;
+    float targetScale = globalScale_ + deltaScale;
+    Vector2<int16_t> position = GetCurrentPosition(rotateCenterIndexInNormal_);
+    Vector2<int16_t> deltaDistance;
+    // Current scale > Normal(1.0f), scale and change opaque
+    if (FloatMore(targetScale, 1.0f)) {
+        UIView* view = GetViewByIndex(rotateCenterIndexInNormal_);
+        uint8_t opa = static_cast<uint8_t>((1 - (targetScale - 1.0f) / (TRASPANRENT_SCALE - 1.0f)) * OPA_OPAQUE);
+        if (view != nullptr) {
+            view->SetOpaScale(opa);
+        }
+        Scale(targetScale, rotateCenterIndexInNormal_);
+    // Current scale in [Equal-Threshold, Normal], only scale
+    } else if (FloatMoreEqual(targetScale, scaleThresholdOfZeroFactor_)) {
+        Scale(targetScale, rotateCenterIndexInNormal_);
+    // Current scale in [Small, Equal-Threshold), scale and scroll
+    } else if (FloatMore(targetScale, scaleInSmallState_)) {
+        if (deltaScale < 0) {
+            Vector2<int16_t> targetPos = GetPositionWithCondition(rotateCenterIndexInNormal_, 0, scaleInSmallState_);
+            deltaDistance = targetPos - position;
+            float deltaScaleToSmallState = scaleInSmallState_ - globalScale_;
+            int16_t deltaX = static_cast<int16_t>(deltaDistance.x_ / deltaScaleToSmallState  * deltaScale);
+            int16_t deltaY = static_cast<int16_t>(deltaDistance.y_ / deltaScaleToSmallState  * deltaScale);
+            ScrollBy(deltaX, deltaY);
+        } else {
+            deltaDistance = Vector2<int16_t>(GetWidth() / 2, GetHeight() / 2) - position; // 2, center
+            float deltaScaleToSmallState = scaleThresholdOfZeroFactor_ - globalScale_;
+            int16_t deltaX = static_cast<int16_t>(deltaDistance.x_ / deltaScaleToSmallState  * deltaScale);
+            int16_t deltaY = static_cast<int16_t>(deltaDistance.y_ / deltaScaleToSmallState  * deltaScale);
+            ScrollBy(deltaX, deltaY);
+        }
+        Scale(targetScale, rotateCenterIndexInNormal_);
+    // Current scale in [Smallest, Small), only scale
+    } else if (FloatMore(targetScale, SCALE_SMALLEST_VALUE)) {
+        Vector2<int16_t> centerImgPosition = GetCurrentPosition(0);
+        Vector2<int16_t> targetPos(GetWidth() / 2, GetHeight() / 2); // 2, center
+        deltaDistance = targetPos - centerImgPosition;
+        ScrollBy(deltaDistance.x_, deltaDistance.y_);
+        Scale(targetScale, 0);
+    }
+    return UIView::OnRotateEvent(event);
+}
+
+bool UICustomHexagonsList::OnRotateEndEvent(const RotateEvent& event)
+{
+    // Rotate end in (Normal, .), start animator to enter Normal State
+    if (FloatMore(globalScale_, 1.0f)) {
+        StartRotateAnimator(rotateCenterIndexInNormal_, 0, 0, globalScale_, 1.0f);
+        SetReboundMode(ReboundMode::NEAREST_IMG_ON_SCR_CENTER);
+    // Rotate end in (Equal-Threshold, Normal), start animator to enter Normal State
+    } else if (FloatMore(globalScale_, scaleThresholdOfZeroFactor_)) {
+        StartRotateAnimator(rotateCenterIndexInNormal_, 0, 0, globalScale_, 1.0f);
+        SetReboundMode(ReboundMode::NEAREST_IMG_ON_SCR_CENTER);
+    // Rotate end in (Small, Equal-Threshold), start animator to enter Small State
+    } else if (FloatMore(globalScale_, scaleInSmallState_)) {
+        Vector2<int16_t> targetPos = GetPositionWithCondition(rotateCenterIndexInNormal_, 0, scaleInSmallState_);
+        Vector2<int16_t> curPos = GetCurrentPosition(rotateCenterIndexInNormal_);
+        Vector2<int16_t> delta = targetPos - curPos;
+        StartRotateAnimator(rotateCenterIndexInNormal_, delta.x_, delta.y_, globalScale_, scaleInSmallState_);
+        SetReboundMode(ReboundMode::CENTER_IMG_ON_SCR_CENTER);
+    // Rotate end in (., Small), start animator to enter Small State
+    } else {
+        StartRotateAnimator(0, 0, 0, globalScale_, scaleInSmallState_);
+        SetReboundMode(ReboundMode::CENTER_IMG_ON_SCR_CENTER);
+    }
+
+    return UIView::OnRotateEndEvent(event);
+}
+#endif
+}
\ No newline at end of file
index 1eaaacb..628788d 100755 (executable)
@@ -35,12 +35,12 @@ void UIListExt::ReMeasure()
         if (direction_ == VERTICAL) {\r
             int offset = (y + view->GetHeight() / 2 - midY);\r
             int temp = EasingEquation::SineEaseIn(0, scaleFactor_, abs(offset), scaleFactor_);\r
-            float scale = 1.0 - ((float)temp / scaleFactor_);\r
+            float scale = 1.0 - (static_cast<float>(temp) / scaleFactor_);\r
             view->Scale(Vector2<float>(scale, scale), view->GetScaleCenter());\r
         } else {\r
             int offset = (x + view->GetWidth() / 2 - midX);\r
             int temp = EasingEquation::SineEaseIn(0, scaleFactor_, abs(offset), scaleFactor_);\r
-            float scale = 1.0 - ((float)temp / scaleFactor_);\r
+            float scale = 1.0 - (static_cast<float>(temp) / scaleFactor_);\r
             view->Scale(Vector2<float>(scale, scale), view->GetScaleCenter());\r
         }\r
         view = static_cast<UIMenuItem*>(view->GetNextSibling());\r
index dc4ccb5..ca25858 100755 (executable)
@@ -214,8 +214,8 @@ bool UILiteSurfaceView::GetBitmap(ImageInfo& bitmap)
         UIView::GetBitmap(bitmap);\r
     } else {\r
         CscYuvBuf yuv = {0};\r
-        yuv.yAddr = (uint8_t*)lastFlushedBuffer_->addr;\r
-        yuv.uvAddr = (uint8_t*)yuv.yAddr + ALIGN_BYTE(lastFlushedBuffer_->width, YUV_WIDTH_ALIGNMENT) *\r
+        yuv.yAddr = reinterpret_cast<uint8_t*>(lastFlushedBuffer_->addr);\r
+        yuv.uvAddr = static_cast<uint8_t*>(yuv.yAddr) + ALIGN_BYTE(lastFlushedBuffer_->width, YUV_WIDTH_ALIGNMENT) *\r
             lastFlushedBuffer_->height;\r
         yuv.width = lastFlushedBuffer_->width;\r
         yuv.height = lastFlushedBuffer_->height;\r
@@ -236,7 +236,7 @@ bool UILiteSurfaceView::GetBitmap(ImageInfo& bitmap)
         rgb.addr = reinterpret_cast<uint8_t*>(ImageCacheMalloc(bitmap));\r
         CscConvertYuvToRgb(&rgb, &yuv);\r
     }\r
-    return true;
+    return true;\r
 }\r
 \r
 void UILiteSurfaceView::BlitBitmapToFb(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea, ImageInfo& bitmap)\r
index 1900882..5a5fb8e 100755 (executable)
@@ -25,7 +25,7 @@ public:
      * @since 1.0
      * @version 1.0
      */
-    virtual ~HorSwipeView() {}
+    ~HorSwipeView() override {}
 
     bool DragXInner(int16_t distance) override;
     bool OnDragEvent(const DragEvent& event) override;
diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components_ext/map_svg_parser.h b/code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components_ext/map_svg_parser.h
new file mode 100644 (file)
index 0000000..d2efc3b
--- /dev/null
@@ -0,0 +1,165 @@
+/*\r
+ * Copyright (c) 2024 CompanyNameMagicTag.\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+#ifndef GRAPHIC_LITE_MAP_SVG_PARSER_H\r
+#define GRAPHIC_LITE_MAP_SVG_PARSER_H\r
+#include <cstdint>\r
+#include "gfx_utils/color.h"\r
+\r
+namespace OHOS {\r
+struct MapRect {\r
+    int16_t x;\r
+    int16_t y;\r
+    int16_t width;\r
+    int16_t height;\r
+};\r
+\r
+struct PathStyle {\r
+    uint8_t strokeCap : 4;\r
+    uint8_t strokeJoin : 4;\r
+    Color24 strokeColor;\r
+    Color24 fillColor;\r
+    float strokeWidth;\r
+};\r
+\r
+struct MapPathBase {\r
+    uint8_t type;\r
+    uint8_t pathStyleIndex;\r
+    uint16_t cmdNum;\r
+    uint16_t dataNum;\r
+};\r
+\r
+struct PathDetail {\r
+    MapPathBase base;\r
+    uint8_t* cmd;\r
+    float* data;\r
+};\r
+\r
+struct ImageBase {\r
+    uint8_t id;\r
+    MapRect rect;\r
+};\r
+\r
+struct ImageDetail {\r
+    ImageBase base;\r
+    ImageInfo* info;\r
+};\r
+\r
+struct MapTextBase {\r
+    uint8_t fontSize;\r
+    Color24 fontColor;\r
+    Color24 strokeColor;\r
+    float strokeWidth;\r
+    MapRect rect;\r
+    uint16_t charLen;\r
+};\r
+\r
+struct TextDetail {\r
+    MapTextBase base;\r
+    char* text;\r
+    Point* offset;\r
+};\r
+\r
+struct POIDetail {\r
+    int8_t imgIndex;\r
+    int8_t textIndex[2];\r
+    uint8_t tag;\r
+    uint16_t rank;\r
+    uint16_t id;\r
+};\r
+\r
+struct RoadDetail {\r
+    int8_t textIndex;\r
+};\r
+\r
+class MapSVGParser {\r
+public:\r
+    MapSVGParser(void);\r
+    virtual ~MapSVGParser(void);\r
+\r
+    bool SetSVG(uint8_t* data, uint32_t length);\r
+    Color24 GetBackGroundColor(void);\r
+    uint32_t GetImageOffset(void);\r
+    void GetSize(int16_t& width, int16_t& height);\r
+\r
+    uint8_t GetPaths(PathDetail*& pathList);\r
+    uint8_t GetPOIs(POIDetail*& poiList);\r
+    uint8_t GetRoads(RoadDetail*& roadList);\r
+\r
+    PathStyle* GetPathStyleByIndex(uint8_t index);\r
+    TextDetail* GetTextByIndex(uint8_t index);\r
+    ImageDetail* GetImageByIndex(uint8_t index);\r
+    void ClearSVG(uint8_t* data);\r
+\r
+private:\r
+    struct MapHeader {\r
+        Color24 bgColor;\r
+        uint8_t nodeNum;\r
+        uint8_t pathStyleNum;\r
+        int16_t width;\r
+        int16_t height;\r
+        uint32_t imgDataOffset;\r
+    };\r
+\r
+    struct MapNode {\r
+        uint8_t type;\r
+        uint8_t count;\r
+        uint32_t offset;\r
+    };\r
+\r
+    static constexpr uint8_t PARSER_TYPE_NUM = 5;\r
+    typedef uint32_t (MapSVGParser::*MapTypeParserInit)(uint8_t* data, uint32_t length, uint32_t offset, uint8_t count);\r
+    typedef void (MapSVGParser::*MapTypeParserDeinit)(uint8_t count);\r
+\r
+    uint32_t ReadMapNode(uint8_t* data, uint32_t length, uint32_t offset);\r
+    uint32_t ReadPathStyle(uint8_t* data, uint32_t length, uint32_t offset);\r
+    uint32_t ReadMapPath(uint8_t* data, uint32_t length, uint32_t offset, uint8_t count);\r
+    uint32_t ReadMapText(uint8_t* data, uint32_t length, uint32_t offset, uint8_t count);\r
+    uint32_t ReadMapImg(uint8_t* data, uint32_t length, uint32_t offset, uint8_t count);\r
+    uint32_t ReadMapRoad(uint8_t* data, uint32_t length, uint32_t offset, uint8_t count);\r
+    uint32_t ReadMapPOI(uint8_t* data, uint32_t length, uint32_t offset, uint8_t count);\r
+    uint32_t ReadImage(uint8_t* data, uint32_t length, uint32_t offset);\r
+\r
+    void ReleaseMapPath(uint8_t count);\r
+    void ReleaseMapText(uint8_t count);\r
+    void ReleaseMapImg(uint8_t count);\r
+    void ReleaseMapRoad(uint8_t count);\r
+    void ReleaseMapPOI(uint8_t count);\r
+    void ReleaseResource(void);\r
+    bool AllocPath(PathDetail& path, uint32_t cmdNum, uint32_t dataNum);\r
+\r
+    MapTypeParserInit parserInitFunc[PARSER_TYPE_NUM] = { &MapSVGParser::ReadMapPath, &MapSVGParser::ReadMapText,\r
+                                                          &MapSVGParser::ReadMapImg, &MapSVGParser::ReadMapRoad,\r
+                                                          &MapSVGParser::ReadMapPOI };\r
+    MapTypeParserDeinit parserDeinitFunc[PARSER_TYPE_NUM] = {\r
+        &MapSVGParser::ReleaseMapPath, &MapSVGParser::ReleaseMapText, &MapSVGParser::ReleaseMapImg,\r
+        &MapSVGParser::ReleaseMapRoad, &MapSVGParser::ReleaseMapPOI\r
+    };\r
+\r
+    MapHeader mapHeader_;\r
+    MapNode* nodeArray_ = nullptr;\r
+    PathStyle* pathStyleArray_ = nullptr;\r
+    PathDetail* pathArray_ = nullptr;\r
+    uint8_t pathCount_ = 0;\r
+    TextDetail* textArray_ = nullptr;\r
+    uint8_t textCount_ = 0;\r
+    ImageDetail* imageArray_ = nullptr;\r
+    uint8_t imageCount_ = 0;\r
+    RoadDetail* roadArray_ = nullptr;\r
+    uint8_t roadCount_ = 0;\r
+    POIDetail* poiArray_ = nullptr;\r
+    uint8_t poiCount_ = 0;\r
+};\r
+}\r
+#endif // GRAPHIC_LITE_MAP_SVG_PARSER_H\r
index 0ada8aa..c009fcd 100755 (executable)
@@ -15,13 +15,16 @@ namespace OHOS {
 class UICardContainer : public UIViewGroup {
 public:
     UICardContainer();
-    virtual ~UICardContainer() override;
+    ~UICardContainer() override;
+    UICardContainer(const UICardContainer &) = delete;
+    UICardContainer &operator=(const UICardContainer &) = delete;
     void SwitchCardToBitmap(bool bitMapFromFB = false);
     void SwitchBitmapToCard(void);
 
     void SetCardPage(UICardPage* page)
     {
         cardPage_ = page;
+        Add(cardPage_);
         Resize(page->GetWidth(), page->GetHeight());
     }
 
@@ -51,6 +54,14 @@ private:
     bool OnDragStartEvent(const DragEvent& event) override;
     bool OnDragEvent(const DragEvent& event) override;
     bool OnDragEndEvent(const DragEvent& event) override;
+    bool OnLongPressEvent(const LongPressEvent& event) override;
+    bool OnClickEvent(const ClickEvent& event) override;
+    bool OnPressEvent(const PressEvent& event) override;
+    bool OnReleaseEvent(const ReleaseEvent& event) override;
+    bool OnCancelEvent(const CancelEvent& event) override;
+#if ENABLE_ROTATE_INPUT
+    bool OnRotateEvent(const RotateEvent& event) override;
+#endif
     bool IsVideoContained(UIView* view);
 };
 }
index 960e761..ca7d64c 100755 (executable)
@@ -44,11 +44,10 @@ void ClipImg::ClipImgByPath(ImageInfo& dstInfo, ImageInfo& srcInfo, const Path*
     uintptr_t handle = LiteMGfxEngine::GetInstance()->InitPath(true);
     LiteMGfxEngine::GetInstance()->SetPathData(handle, path->cmdNum, path->cmds, path->dataNum, path->data);
     LiteMGfxEngine::GetInstance()->ClipImgByPath(dstInfo, srcInfo, handle, srcImgArea, pathMatrix, imgMatrix);
-    LiteMGfxEngine::GetInstance()->SyncHwDraw();
 }
 
-ImageInfo ClipImg::ClipImgByCircle(ImageInfo& srcInfo, Rect* srcImgArea, Point center, int16_t radius,
-    ColorMode mode)
+ImageInfo ClipImg::ClipImgByCircle(ImageInfo& srcInfo, Point center, int16_t radius,
+    ColorMode mode, bool immediatelySync)
 {
     ImageInfo dstInfo = {{0}};
     Path path = {0};
@@ -63,6 +62,9 @@ ImageInfo ClipImg::ClipImgByCircle(ImageInfo& srcInfo, Rect* srcImgArea, Point c
     }
 
     ClipImgByPath(dstInfo, srcInfo, &path, nullptr, nullptr, nullptr);
+    if (immediatelySync) {
+        LiteMGfxEngine::GetInstance()->SyncHwDraw();
+    }
     ClearPath(&path);
     return dstInfo;
 }
index 222a00a..f16b708 100755 (executable)
@@ -20,8 +20,8 @@ class ClipImg : public HeapBase {
 public:
     static void ClipImgByPath(ImageInfo& dstInfo, ImageInfo& srcInfo, const Path* path, Rect* srcImgArea,
         const Matrix4<float>* pathMatrix, const Matrix4<float>* imgMatrix);
-    static ImageInfo ClipImgByCircle(ImageInfo& srcInfo, Rect* srcImgArea, Point center, int16_t radius,
-        ColorMode mode = RGB888);
+    static ImageInfo ClipImgByCircle(ImageInfo& srcInfo, Point center, int16_t radius,
+        ColorMode mode = RGB888, bool immediatelySync = false);
     static ImageInfo ClipImgByRect(ImageInfo& srcInfo, Rect* srcImgArea, Rect clipArea, ColorMode mode = RGB888);
 };
 } // namespace OHOS
index 3d848f6..72db48c 100755 (executable)
@@ -98,6 +98,37 @@ int8_t HWDrawUtils::GetArcData(float* arcData, const Point& center,
     return bezierSegmentCount;
 }
 
+void HWDrawUtils::Obtain30DegSectorPath(const ArcInfo& arc, uint8_t* cmd, float* data)
+{
+    float startAngle = arc.startAngle;
+    float endAngle = arc.endAngle;
+    float angleExtend = endAngle - startAngle;
+    float neg = (startAngle < endAngle) ? 1 : -1;
+
+    ConvertCircularDegree(startAngle);
+    float startAngleRad = startAngle / RADIAN_TO_ANGLE;
+    float extendRad = static_cast<float>(angleExtend) / RADIAN_TO_ANGLE;
+    float endAngleRad = startAngleRad + extendRad;
+
+    cmd[0] = CMD_MOVE_TO;
+    cmd[1] = CMD_LINE_TO;
+    cmd[2] = CMD_CUBIC_TO; // 2: index
+    cmd[3] = CMD_CLOSE; // 3: index
+
+    float a = startAngleRad + neg * RAD_90_DEG;
+    a = RAD_90_DEG - (a - endAngleRad) * neg;
+
+    data[0] = arc.center.x;
+    data[1] = arc.center.y;
+    data[2] = arc.center.x + arc.radius * cos(startAngleRad); // 2: index
+    data[3] = arc.center.y + arc.radius * sin(startAngleRad); // 3: index
+    data[8] = arc.center.x + arc.radius * cos(endAngleRad); // 8: index
+    data[9] = arc.center.y + arc.radius * sin(endAngleRad); // 9: index
+
+    float magicNum = 4.0f / 3.0f * (1 - cos(a / 2)) / sin(a / 2); // 2: divisor
+    GetArcControlPoint(&data[2], arc.center, magicNum, neg); // 2: index
+}
+
 bool HWDrawUtils::ObtainArcPath(const ArcInfo& arc, uint32_t& cmdNum, uint8_t*& cmds, uint32_t& dataNum, float*& data)
 {
     float startAngle = arc.startAngle;
index 2136aab..1284abf 100755 (executable)
@@ -31,6 +31,7 @@ public:
     bool ObtainArcPath(const ArcInfo& arc, uint32_t& cmdNum, uint8_t*& cmds, uint32_t& dataNum, float*& data);
     bool ObtainCirclePath(const ArcInfo& arc, uint32_t& cmdNum, uint8_t*& cmds, uint32_t& dataNum, float*& data);
     bool AllocBufferForData(uint16_t dataNum, float*& addr);
+    void Obtain30DegSectorPath(const ArcInfo& arc, uint8_t* cmd, float* data);
 
 private:
     HWDrawUtils() {}
diff --git a/code/sdk/middleware/services/gui/uikit/res/hexagons.bin b/code/sdk/middleware/services/gui/uikit/res/hexagons.bin
new file mode 100644 (file)
index 0000000..f3dc2e8
Binary files /dev/null and b/code/sdk/middleware/services/gui/uikit/res/hexagons.bin differ
diff --git a/code/sdk/middleware/services/gui/uikit/res/kaleidoscope_dial.bin b/code/sdk/middleware/services/gui/uikit/res/kaleidoscope_dial.bin
new file mode 100644 (file)
index 0000000..4c1cfd0
Binary files /dev/null and b/code/sdk/middleware/services/gui/uikit/res/kaleidoscope_dial.bin differ
diff --git a/code/sdk/middleware/services/gui/uikit/res/map.bin b/code/sdk/middleware/services/gui/uikit/res/map.bin
new file mode 100644 (file)
index 0000000..1aa3a3a
Binary files /dev/null and b/code/sdk/middleware/services/gui/uikit/res/map.bin differ
diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_coverflow/ui_test_coverflow.cpp b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_coverflow/ui_test_coverflow.cpp
new file mode 100644 (file)
index 0000000..fd3e579
--- /dev/null
@@ -0,0 +1,242 @@
+/*\r
+ * Copyright (c) 2024 CompanyNameMagicTag.\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include "ui_test_coverflow.h"\r
+#include "common/screen.h"\r
+#include "font/ui_font.h"\r
+#include "gfx_utils/graphic_math.h"\r
+#include "gfx_utils/rect.h"\r
+#include "common/image_cache_manager.h"\r
+\r
+namespace OHOS {\r
+namespace {\r
+struct FaceInfo {\r
+    const char* name;\r
+    const char* path;\r
+} ;\r
+\r
+static constexpr uint8_t COVERFLOW_MAX_PAGE_NUM = 6;\r
+static FaceInfo g_faceInfo[COVERFLOW_MAX_PAGE_NUM] = {\r
+    {"1 rainbow", RES_PATH"/rainbow.bin"},\r
+    {"2 kaleidoscope", RES_PATH"/kaleidoscope.bin"},\r
+    {"3 planet", RES_PATH"/planet.bin"},\r
+    {"4 rainbow", RES_PATH"/rainbow.bin"},\r
+    {"5 kaleidoscope", RES_PATH"/kaleidoscope.bin"},\r
+    {"6 planet", RES_PATH"/planet.bin"}\r
+};\r
+\r
+static constexpr uint8_t COVERFLOW_PRELOAD_PAGE_NUM = 3;\r
+static constexpr int16_t LABEL_FONT_SIZE = 30;\r
+static constexpr uint8_t DEFAULT_STEP = 10;\r
+static constexpr uint16_t BUTTON_WIDTH = 60;\r
+static constexpr uint16_t BUTTON_HEIGHT = 40;\r
+static constexpr uint16_t BUTTON_GROUP_WIDTH = 300;\r
+static constexpr uint16_t BUTTON_GROUP_HEIGHT = 80;\r
+static constexpr uint8_t DIVISOR_TWO = 2;\r
+} // namespace\r
+\r
+void UITestCoverflow::SetUp()\r
+{\r
+    if (container_ == nullptr) {\r
+        container_ = new UIScrollView();\r
+        container_->SetThrowDrag(true);\r
+        container_->SetHorizontalScrollState(false);\r
+        container_->Resize(Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+    }\r
+}\r
+\r
+void UITestCoverflow::TearDown()\r
+{\r
+    container_->Remove(coverflow_);\r
+    DeleteChildren(container_);\r
+    if (container_ != nullptr) {\r
+        container_ = nullptr;\r
+    }\r
+    delete coverflow_;\r
+    coverflow_ = nullptr;\r
+    showBtn_ = nullptr;\r
+    btnGrp_ = nullptr;\r
+    label_ = nullptr;\r
+    addBtn_ = nullptr;\r
+    removeBtn_ = nullptr;\r
+    mirrorOpaAddBtn_ = nullptr;\r
+    mirrorOpaSubBtn_ = nullptr;\r
+    pageWidthAddBtn_ = nullptr;\r
+    pageWidthSubBtn_ = nullptr;\r
+    maxAngleAddBtn_ = nullptr;\r
+    maxAngleSubBtn_ = nullptr;\r
+    loopBtn_ = nullptr;\r
+}\r
+\r
+const UIView* UITestCoverflow::GetTestView()\r
+{\r
+    UITestCoverflowView001();\r
+    return container_;\r
+}\r
+\r
+\r
+void UITestCoverflow::CreateLabelButton(UILabelButton** btn, const char* tile, int16_t x, int16_t y)\r
+{\r
+    UILabelButton* tempBtn = nullptr;\r
+    if (tempBtn == nullptr) {\r
+        tempBtn = new UILabelButton();\r
+    }\r
+    tempBtn->SetPosition(x, y, BUTTON_WIDTH, BUTTON_HEIGHT);\r
+    tempBtn->SetText(tile);\r
+    tempBtn->SetOnClickListener(this);\r
+    btnGrp_->Add(tempBtn);\r
+    *btn = tempBtn;\r
+}\r
+\r
+void UITestCoverflow::InitButtonGroup()\r
+{\r
+    if (showBtn_ == nullptr) {\r
+        showBtn_ = new UIButton();\r
+        showBtn_->SetPosition(202, 10, BUTTON_WIDTH, BUTTON_HEIGHT);  // 202: x position 10: y position\r
+        showBtn_->SetStyleForState(STYLE_BACKGROUND_OPA, 0, UIButton::ButtonState::RELEASED);\r
+        showBtn_->SetStyleForState(STYLE_BACKGROUND_OPA, 0, UIButton::ButtonState::PRESSED);\r
+        showBtn_->SetOnClickListener(this);\r
+        container_->Add(showBtn_);\r
+    }\r
+    if (btnGrp_ == nullptr) {\r
+        btnGrp_ = new UIViewGroup();\r
+        btnGrp_->SetPosition(77, 40, BUTTON_GROUP_WIDTH, BUTTON_GROUP_HEIGHT); // 77: x position 40: y position\r
+        btnGrp_->SetStyle(STYLE_BACKGROUND_OPA, 0);\r
+        btnGrp_->SetVisible(false);\r
+        container_->Add(btnGrp_);\r
+    }\r
+    CreateLabelButton(&mirrorOpaAddBtn_, "opa+", 0, 0);\r
+    CreateLabelButton(&mirrorOpaSubBtn_, "opa-", 60, 0);    // 60: x position\r
+    CreateLabelButton(&pageWidthAddBtn_, "wid+", 120, 0);   // 120: x position\r
+    CreateLabelButton(&pageWidthSubBtn_, "wid-", 180, 0);   // 180: x position\r
+    CreateLabelButton(&maxAngleAddBtn_, "ang+", 0, 40);     // 40: y position\r
+    CreateLabelButton(&maxAngleSubBtn_, "ang-", 60, 40);    // 60: x position 40: y position\r
+    CreateLabelButton(&addBtn_, "add", 120, 40);            // 120: x position 40: y position\r
+    CreateLabelButton(&removeBtn_, "sub", 180, 40);         // 180: x position 40: y position\r
+    CreateLabelButton(&loopBtn_, "loop", 240, 40);          // 240: x position 40: y position\r
+}\r
+\r
+void UITestCoverflow::UITestCoverflowView001()\r
+{\r
+    if (container_ != nullptr) {\r
+        if (coverflow_ == nullptr) {\r
+            coverflow_ = new UICoverflowView();\r
+        }\r
+        coverflow_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+        coverflow_->SetIntercept(true);\r
+        for (uint8_t i = 0; i < COVERFLOW_PRELOAD_PAGE_NUM; i++) {\r
+            ImageInfo* src = ImageCacheManager::GetInstance().LoadSingleRes(std::string(g_faceInfo[i].path));\r
+            if (src == nullptr) {\r
+                continue;\r
+            }\r
+            coverflow_->Add(g_faceInfo[i].name, src);\r
+            loadNum_++;\r
+        }\r
+\r
+        if (label_ == nullptr) {\r
+            label_ = new UILabel();\r
+        }\r
+        label_->SetPosition(127, 50, 200, 50); // 127 50 200 50: label position\r
+        label_->SetTextColor(Color::White());\r
+        label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+        lastIndex_ = coverflow_->GetCurrentPage();\r
+        label_->SetText(g_faceInfo[lastIndex_].name);\r
+        label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE);\r
+\r
+        coverflow_->SetOnCoverflowListener(this);\r
+        container_->Add(coverflow_);\r
+        container_->Add(label_);\r
+        InitButtonGroup();\r
+    }\r
+}\r
+\r
+bool UITestCoverflow::OnScroll()\r
+{\r
+    int16_t contMidX = static_cast<int16_t>(Screen::GetInstance().GetWidth() / DIVISOR_TWO);\r
+    int16_t minOffset = contMidX;\r
+    uint8_t newCenterIndex = lastIndex_;\r
+    for (uint8_t i = 0; i < coverflow_->GetChildrenNumber(); i++) {\r
+        Rect rect =  coverflow_->GetViewByIndex(i)->GetOrigRect();\r
+        int16_t x = rect.GetLeft();\r
+        int16_t x1 = rect.GetRight();\r
+        int16_t xMid = static_cast<int16_t>(x + (x1 - x + 1) / DIVISOR_TWO);\r
+        int16_t distance = MATH_ABS(xMid - contMidX);\r
+        if (distance < minOffset) {\r
+            newCenterIndex = i;\r
+            minOffset = distance;\r
+        }\r
+    }\r
+    if (newCenterIndex != lastIndex_) {\r
+        lastIndex_ = newCenterIndex;\r
+        label_->SetText(g_faceInfo[lastIndex_].name);\r
+    }\r
+\r
+    Rect curViewRect = coverflow_->GetViewByIndex(lastIndex_)->GetOrigRect();\r
+    int16_t centerMid = curViewRect.GetLeft() + curViewRect.GetWidth() / DIVISOR_TWO;\r
+    int16_t offset = MATH_ABS(contMidX - centerMid);\r
+    if (offset > curViewRect.GetWidth() / DIVISOR_TWO) {\r
+        label_->SetStyle(STYLE_TEXT_OPA, 0);\r
+    } else {\r
+        uint8_t alpha =  (uint8_t)((1.0f - ((float)offset / (curViewRect.GetWidth() / DIVISOR_TWO))) * OPA_OPAQUE);\r
+        label_->SetStyle(STYLE_TEXT_OPA, alpha);\r
+    }\r
+    return true;\r
+}\r
+\r
+bool UITestCoverflow::OnClick(UIView& view, const ClickEvent& event)\r
+{\r
+    if (&view == mirrorOpaAddBtn_) {\r
+        mirrorOpa_ += DEFAULT_STEP;\r
+        coverflow_->SetMirrorOpacity(mirrorOpa_);\r
+    } else if (&view == mirrorOpaSubBtn_) {\r
+        mirrorOpa_ -= DEFAULT_STEP;\r
+        coverflow_->SetMirrorOpacity(mirrorOpa_);\r
+    } else if (&view == showBtn_) {\r
+        btnGrp_->SetVisible(!btnGrp_->IsVisible());\r
+    } else if (&view == loopBtn_) {\r
+        isLoop_ = !isLoop_;\r
+        coverflow_->SetLoopState(isLoop_);\r
+        if (isLoop_) {\r
+            loopBtn_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);\r
+        } else {\r
+            loopBtn_->SetStyle(STYLE_BACKGROUND_COLOR, Color::GetColorFromRGB(0x00, 0x7d, 0xff).full);\r
+        }\r
+    } else if (&view == pageWidthAddBtn_) {\r
+        itemWidth_ += DEFAULT_STEP;\r
+        coverflow_->SetItemWidth(itemWidth_);\r
+    } else if (&view == pageWidthSubBtn_) {\r
+        itemWidth_ -= DEFAULT_STEP;\r
+        coverflow_->SetItemWidth(itemWidth_);\r
+    } else if (&view == addBtn_) {\r
+        if (loadNum_ >= COVERFLOW_MAX_PAGE_NUM) {\r
+            return true;\r
+        }\r
+        ImageInfo* src = ImageCacheManager::GetInstance().LoadSingleRes(std::string(g_faceInfo[loadNum_].path));\r
+        coverflow_->Add(g_faceInfo[loadNum_++].name, src);\r
+    } else if (&view == removeBtn_) {\r
+        if (loadNum_ > 0) {\r
+            coverflow_->Remove(g_faceInfo[--loadNum_].name);\r
+        }\r
+    } else if (&view == maxAngleAddBtn_) {\r
+        rotateAngle_ += 2.0;  // 2.0 variables per click\r
+        coverflow_->SetRotateAngle(rotateAngle_);\r
+    } else if (&view == maxAngleSubBtn_) {\r
+        rotateAngle_ -= 2.0; // 2.0 variables per click\r
+        coverflow_->SetRotateAngle(rotateAngle_);\r
+    }\r
+    coverflow_->Invalidate();\r
+    return true;\r
+}\r
+} // namespace OHOS\r
diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_coverflow/ui_test_coverflow.h b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_coverflow/ui_test_coverflow.h
new file mode 100644 (file)
index 0000000..b67c47e
--- /dev/null
@@ -0,0 +1,69 @@
+/*\r
+ * Copyright (c) 2024 CompanyNameMagicTag.\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#ifndef UI_TEST_COVERFLOW_VIEW_H\r
+#define UI_TEST_COVERFLOW_VIEW_H\r
+\r
+#include "components/ui_coverflow_view.h"\r
+#include "components/ui_scroll_view.h"\r
+#include "components/ui_label_button.h"\r
+#include "animator/animator.h"\r
+#include "ui_test.h"\r
+\r
+namespace OHOS {\r
+class UITestCoverflow : public UITest,\r
+    public UICoverflowView::OnCoverflowScrollListener, public UIView::OnClickListener {\r
+public:\r
+    UITestCoverflow() {}\r
+    ~UITestCoverflow() override {}\r
+    void SetUp() override;\r
+    void TearDown() override;\r
+    const UIView* GetTestView() override;\r
+    /**\r
+     * @brief Test display UICoverflow\r
+     */\r
+    void UITestCoverflowView001();\r
+\r
+    bool OnScroll();\r
+\r
+    bool OnClick(UIView& view, const ClickEvent& event);\r
+private:\r
+    void InitButtonGroup();\r
+    void CreateLabelButton(UILabelButton** btn, const char* tile, int16_t x, int16_t y);\r
+\r
+    UIScrollView* container_ = nullptr;\r
+    UICoverflowView* coverflow_ = nullptr;\r
+    UILabel* label_ = nullptr;\r
+    uint16_t lastIndex_ = 0;\r
+    UIButton* showBtn_ = nullptr;\r
+    bool isShowBtnGrp_ = false;\r
+    UIViewGroup* btnGrp_ = nullptr;\r
+    uint8_t loadNum_ = 0;\r
+    UILabelButton* addBtn_ = nullptr;\r
+    UILabelButton* removeBtn_ = nullptr;\r
+    UILabelButton* mirrorOpaAddBtn_ = nullptr;\r
+    UILabelButton* mirrorOpaSubBtn_ = nullptr;\r
+    UILabelButton* pageWidthAddBtn_ = nullptr;\r
+    UILabelButton* pageWidthSubBtn_ = nullptr;\r
+    UILabelButton* maxAngleAddBtn_ = nullptr;\r
+    UILabelButton* maxAngleSubBtn_ = nullptr;\r
+    UILabelButton* loopBtn_ = nullptr;\r
+    uint16_t itemWidth_ = 250;  // 250: default value\r
+    uint8_t mirrorOpa_ = 30;    // 30: default value\r
+    float rotateAngle_ = 70.0f; // 70: default value\r
+    bool isLoop_ = false;\r
+};\r
+} // namespace OHOS\r
+#endif // UI_TEST_QRCODE_H
\ No newline at end of file
index 9423f75..5890f17 100755 (executable)
@@ -36,8 +36,10 @@ public:
 #ifndef _WIN32
     class VideoPage : public UICardPage {
     public:
+        VideoPage(const VideoPage &) = delete;
+        VideoPage &operator=(const VideoPage &) = delete;
         VideoPage(void) {}
-        ~VideoPage();
+        ~VideoPage() override;
         void ScrollBegin(bool isActive) override;
         void ScrollEnd(bool isActive) override;
         void CoverBegin(bool isCovered) override;
index 5edb653..7d54432 100755 (executable)
@@ -261,7 +261,7 @@ bool CubeRotateView::OnDragEvent(const DragEvent& event)
     int y = (point.y - startPoint_.y);
     float len = Sqrt(x * x + y * y);
     float angle = RADIAN_TO_ANGLE * len / IMG_WIDTH;
-    const Vector3<float> center = {CENTER_X, CENTER_Y, -IMG_SIZE/2.0f};
+    const Vector3<float> center = {CENTER_X, CENTER_Y, -IMG_SIZE / 2.0f};
     RotatePlanes(angle, center, {center.x_ + normal.x_, center.y_ + normal.y_, center.z_ + normal.z_});
     return true;
 }
diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_hexagons_list/ui_test_hexagons_list.cpp b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_hexagons_list/ui_test_hexagons_list.cpp
new file mode 100644 (file)
index 0000000..5cb8964
--- /dev/null
@@ -0,0 +1,236 @@
+/*
+ * Copyright (c) @CompanyNameMagicTag. 2024. All rights reserved.
+ */
+
+#include "ui_test_hexagons_list/ui_test_hexagons_list.h"
+#include "components/root_view.h"
+#include "components/ui_image_view.h"
+#include "common/image_cache_manager.h"
+#include "common/screen.h"
+#include "ui_test_list_fps/ui_list_fps_res.h"
+#include "dock/focus_manager.h"
+
+namespace OHOS {
+const uint8_t IMG_COUNT = 45;
+const uint8_t IMG_DISTANCE_DELTA = 1;
+const uint8_t IMG_SIZE_DELTA = 1;
+const int16_t BUTTON_SIZE = 60;
+const float IMG_SCALE_FACTOR_DELTA = 0.01f;
+const int16_t MARGIN_DELTA = 1;
+const int16_t BORDER_RADIUS_DELTA = 1;
+const float GLOBAL_SCALE = 1.0f;
+const float GLOBAL_SCALE_DELTA = 0.02f;
+const float CLICK_SCALE_TARGET_IN_NORMAL = 2.0f;
+
+void UITestHexagonsList::ConfigButtonAttr(UIView& view, int16_t x, int16_t y, int16_t width, int16_t height)
+{
+    view.SetOpaScale(OPA_TRANSPARENT);
+    view.SetOnClickListener(this);
+    view.SetOnLongPressListener(this);
+    view.SetPosition(x, y, width, height);
+    container_->Add(&view);
+}
+
+void UITestHexagonsList::SetUpButtons(int16_t xEnd, int16_t yEnd, int16_t xMiddle, int16_t yMiddle)
+{
+    if (modifyImgSizeButton_ == nullptr) {
+        modifyImgSizeButton_ = new UIButton();
+        ConfigButtonAttr(*modifyImgSizeButton_, xMiddle - BUTTON_SIZE, 0, BUTTON_SIZE, BUTTON_SIZE);
+    }
+    if (modifyImgDistanceButton_ == nullptr) {
+        modifyImgDistanceButton_ = new UIButton();
+        ConfigButtonAttr(*modifyImgDistanceButton_, xMiddle, 0, BUTTON_SIZE, BUTTON_SIZE);
+    }
+    if (modifyScaleFatorButton_ == nullptr) {
+        modifyScaleFatorButton_ = new UIButton();
+        ConfigButtonAttr(*modifyScaleFatorButton_, xEnd - BUTTON_SIZE, yMiddle - BUTTON_SIZE, BUTTON_SIZE, BUTTON_SIZE);
+    }
+    if (modifyGlobalScaleButton_ == nullptr) {
+        modifyGlobalScaleButton_ = new UIButton();
+        ConfigButtonAttr(*modifyGlobalScaleButton_, xEnd - BUTTON_SIZE, yMiddle, BUTTON_SIZE, BUTTON_SIZE);
+    }
+    if (modifyHorMarginButton_ == nullptr) {
+        modifyHorMarginButton_ = new UIButton();
+        ConfigButtonAttr(*modifyHorMarginButton_, xMiddle - BUTTON_SIZE, yEnd - BUTTON_SIZE, BUTTON_SIZE, BUTTON_SIZE);
+    }
+    if (modifyVerMarginButton_ == nullptr) {
+        modifyVerMarginButton_ = new UIButton();
+        ConfigButtonAttr(*modifyVerMarginButton_, xMiddle, yEnd - BUTTON_SIZE, BUTTON_SIZE, BUTTON_SIZE);
+    }
+    if (modifyBorderRadiusButton_ == nullptr) {
+        modifyBorderRadiusButton_ = new UIButton();
+        ConfigButtonAttr(*modifyBorderRadiusButton_, xMiddle - BUTTON_SIZE, yMiddle, BUTTON_SIZE, BUTTON_SIZE);
+    }
+}
+
+void UITestHexagonsList::SetUp()
+{
+    if (container_ == nullptr) {
+        container_ = new UIViewGroup();
+    }
+    container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+    if (hexagonsList_ == nullptr) {
+        hexagonsList_ = new UICustomHexagonsList();
+    }
+    container_->Add(hexagonsList_);
+
+    if (Screen::GetInstance().GetScreenShape() == RECTANGLE) {
+        borderRadius_ = Screen::GetInstance().GetWidth() * 0.336; // 0.336, empirical coefficient
+        hexagonsList_->SetStyle(STYLE_BORDER_RADIUS, borderRadius_);
+        // STYLE_BORDER_WIDTH was used to debug, it should be removed in the actual running content
+        hexagonsList_->SetStyle(STYLE_BORDER_WIDTH, 1);
+        hexagonsList_->SetStyle(STYLE_MARGIN_LEFT, horMargin_);
+        hexagonsList_->SetStyle(STYLE_MARGIN_RIGHT, horMargin_);
+        hexagonsList_->SetStyle(STYLE_MARGIN_TOP, verMargin_);
+        hexagonsList_->SetStyle(STYLE_MARGIN_BOTTOM, verMargin_);
+        hexagonsList_->SetStyle(STYLE_BORDER_COLOR, Color::Red().full);
+        imgDistance_ = container_->GetWidth() * 0.31; // 0.31, empirical coefficient
+        imgSize_ = container_->GetWidth() * 0.27; // 0.27, empirical coefficient
+    } else {
+        imgDistance_ = container_->GetWidth() * 0.25991; // 0.25991, empirical coefficient
+        imgSize_ = container_->GetWidth() * 0.23348; // 0.23348, empirical coefficient
+    }
+    hexagonsList_->SetPosition(0, 0,
+        container_->GetWidth() - 2 * (horMargin_ + 1), container_->GetHeight() - 2 * (verMargin_ + 1)); // 2, two
+
+    ImageInfo* info = ImageCacheManager::GetInstance().LoadSingleRes(RES_PATH"hexagons.bin");
+    for (int16_t i = 0; i < IMG_COUNT; i++) {
+        UIImageView* img = new UIImageView();
+        img->SetSrc(info);
+        img->SetTouchable(true);
+        img->SetOnClickListener(this);
+        hexagonsList_->Add(img);
+    }
+    imgScaleFactor_ = hexagonsList_->GetScaleFactorByDistance();
+    globalScale_ = hexagonsList_->GetGlobalScale();
+    hexagonsList_->SetImageDistance(imgDistance_);
+    hexagonsList_->SetImageSizeInCenter(imgSize_);
+    int16_t blankSize = hexagonsList_->GetRelativeRect().GetWidth() > hexagonsList_->GetRelativeRect().GetHeight() ?
+        hexagonsList_->GetRelativeRect().GetWidth() / 2 : hexagonsList_->GetRelativeRect().GetHeight() / 2; // 2, half
+    hexagonsList_->SetScrollBlankSize(blankSize);
+    hexagonsList_->SetReboundSize(blankSize);
+    hexagonsList_->SetThrowDrag(true);
+    hexagonsList_->LayoutChildren(true);
+    SetUpButtons(container_->GetWidth() - 1, container_->GetHeight() - 1,
+        container_->GetWidth() / 2, container_->GetHeight() / 2); // 2, half size
+    FocusManager::GetInstance()->RequestFocus(hexagonsList_);
+}
+
+void UITestHexagonsList::TearDown()
+{
+    FocusManager::GetInstance()->ClearFocus();
+    DeleteChildren(container_);
+    container_ = nullptr;
+    hexagonsList_ = nullptr;
+    modifyImgSizeButton_ = nullptr;
+    modifyImgDistanceButton_ = nullptr;
+    modifyScaleFatorButton_ = nullptr;
+    modifyGlobalScaleButton_ = nullptr;
+    modifyHorMarginButton_ = nullptr;
+    modifyVerMarginButton_ = nullptr;
+    modifyBorderRadiusButton_ = nullptr;
+}
+
+void UITestHexagonsList::HandleClickEventForRectScreen(const UIView& view)
+{
+    if (modifyHorMarginButton_ == &view) {
+        horMargin_ += isIncreaseHorMargin_ ? MARGIN_DELTA : -MARGIN_DELTA;
+        horMargin_ = horMargin_ < 0 ? 0 : horMargin_;
+        hexagonsList_->SetPosition(horMargin_, verMargin_,
+            container_->GetWidth() - 2 * (horMargin_ + 1), container_->GetHeight() - 2 * (verMargin_ + 1)); // 2, two
+        hexagonsList_->LayoutChildren(true);
+    } else if (modifyVerMarginButton_ == &view) {
+        verMargin_ += isIncreaseVerMargin_ ? MARGIN_DELTA : -MARGIN_DELTA;
+        verMargin_ = verMargin_ < 0 ? 0 : verMargin_;
+        hexagonsList_->SetPosition(horMargin_, verMargin_,
+            container_->GetWidth() - 2 * (horMargin_ + 1), container_->GetHeight() - 2 * (verMargin_ + 1)); // 2, two
+        hexagonsList_->LayoutChildren(true);
+    } else if (modifyBorderRadiusButton_ == &view) {
+        borderRadius_ += isIncreaseBorderRadius_ ? BORDER_RADIUS_DELTA : -BORDER_RADIUS_DELTA;
+        borderRadius_ = borderRadius_ < 0 ? 0 : borderRadius_;
+        int8_t index = hexagonsList_->GetFocusedImgIndex();
+        hexagonsList_->SetStyle(STYLE_BORDER_RADIUS, borderRadius_);
+    }
+    container_->Invalidate();
+}
+
+bool UITestHexagonsList::OnClick(UIView& view, const ClickEvent& event)
+{
+    // Handle content click for image view
+    if (view.GetViewType() == UI_IMAGE_VIEW) {
+        uint8_t index = static_cast<uint8_t>(view.GetViewIndex());
+        float scaleInSmall = hexagonsList_->GetScaleInSmallState();
+        Vector2<int16_t> center(hexagonsList_->GetWidth() / 2, hexagonsList_->GetHeight() / 2); // 2, center
+        Vector2<int16_t> delta = center - hexagonsList_->GetCurrentPosition(index);
+        if (FloatEqual(hexagonsList_->GetGlobalScale(), scaleInSmall)) {
+            hexagonsList_->StartRotateAnimator(index, delta.x_, delta.y_, scaleInSmall, 1.0f);
+        } else if (FloatEqual(hexagonsList_->GetGlobalScale(), 1.0f)) {
+            hexagonsList_->StartRotateAnimator(index, delta.x_, delta.y_, 1.0f, CLICK_SCALE_TARGET_IN_NORMAL);
+        } else if (FloatEqual(hexagonsList_->GetGlobalScale(), CLICK_SCALE_TARGET_IN_NORMAL)) {
+            hexagonsList_->StartRotateAnimator(index, delta.x_, delta.y_, CLICK_SCALE_TARGET_IN_NORMAL, 1.0f);
+        }
+    }
+
+    if (modifyImgSizeButton_ == &view) {
+        imgSize_ += isIncreaseImgSize_ ? IMG_SIZE_DELTA : -IMG_SIZE_DELTA;
+        hexagonsList_->SetImageSizeInCenter(imgSize_);
+        hexagonsList_->LayoutChildren(true);
+    } else if (modifyImgDistanceButton_ == &view) {
+        imgDistance_ += isIncreaseImgDistance_ ? IMG_DISTANCE_DELTA : -IMG_DISTANCE_DELTA;
+        hexagonsList_->SetImageDistance(imgDistance_);
+        hexagonsList_->LayoutChildren(true);
+    } else if (modifyScaleFatorButton_ == &view) {
+        imgScaleFactor_ += isIncreaseScaleFactor_ ? IMG_SCALE_FACTOR_DELTA : -IMG_SCALE_FACTOR_DELTA;
+        hexagonsList_->SetScaleFactorByDistance(imgScaleFactor_);
+        hexagonsList_->LayoutChildren(true);
+    }  else if (modifyGlobalScaleButton_ == &view) {
+        globalScale_ += isIncreaseGlobalScale_ ? GLOBAL_SCALE_DELTA : -GLOBAL_SCALE_DELTA;
+        int8_t index = hexagonsList_->GetFocusedImgIndex();
+        if (index >= 0) {
+            hexagonsList_->Scale(globalScale_, static_cast<uint8_t>(index));
+        }
+    }
+    if (FloatLess(globalScale_, hexagonsList_->GetScaleThesholdOfZeroFactor())) {
+        hexagonsList_->SetReboundMode(UIHexagonsList::ReboundMode::CENTER_IMG_ON_SCR_CENTER);
+    } else {
+        hexagonsList_->SetReboundMode(UIHexagonsList::ReboundMode::NEAREST_IMG_ON_SCR_CENTER);
+    }
+
+    if (Screen::GetInstance().GetScreenShape() == RECTANGLE) {
+        HandleClickEventForRectScreen(view);
+    }
+
+    GRAPHIC_LOGE("%d-%d imgDist_=%d imgSize=%d imgScaleFactor=%f globalScale=%f horPad=%d verPad=%d boderRadius=%d",
+        view.GetViewType(), view.GetViewIndex(), imgDistance_, imgSize_, imgScaleFactor_, globalScale_,
+        horMargin_, verMargin_, borderRadius_);
+    return true;
+}
+
+bool UITestHexagonsList::OnLongPress(UIView& view, const LongPressEvent& event)
+{
+    if (modifyImgSizeButton_ == &view) {
+        isIncreaseImgSize_ = !isIncreaseImgSize_;
+    } else if (modifyImgDistanceButton_ == &view) {
+        isIncreaseImgDistance_ = !isIncreaseImgDistance_;
+    } else if (modifyScaleFatorButton_ == &view) {
+        isIncreaseScaleFactor_ = !isIncreaseScaleFactor_;
+    } else if (modifyGlobalScaleButton_ == &view) {
+        isIncreaseGlobalScale_ = !isIncreaseGlobalScale_;
+    } else if (modifyHorMarginButton_ == &view) {
+        isIncreaseHorMargin_ = !isIncreaseHorMargin_;
+    } else if (modifyVerMarginButton_ == &view) {
+        isIncreaseVerMargin_ = !isIncreaseVerMargin_;
+    } else if (modifyBorderRadiusButton_ == &view) {
+        isIncreaseBorderRadius_ = !isIncreaseBorderRadius_;
+    }
+    GRAPHIC_LOGE("incSize=%d incDist=%d incFactor=%d incGloScale=%d incHPadding=%d incVPadding=%d incBRadius=%d",
+        isIncreaseImgSize_, isIncreaseImgDistance_, isIncreaseScaleFactor_, isIncreaseGlobalScale_,
+        isIncreaseHorMargin_, isIncreaseVerMargin_, isIncreaseBorderRadius_);
+    return true;
+}
+
+const UIView* UITestHexagonsList::GetTestView()
+{
+    return container_;
+}
+}
\ No newline at end of file
diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_hexagons_list/ui_test_hexagons_list.h b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_hexagons_list/ui_test_hexagons_list.h
new file mode 100644 (file)
index 0000000..999b41b
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) @CompanyNameMagicTag. 2024. All rights reserved.
+ */
+
+#ifndef UI_TEST_HEXAGONS_LIST_H
+#define UI_TEST_HEXAGONS_LIST_H
+
+#include "ui_test.h"
+#include "gfx_utils/list.h"
+#include "components/ui_custom_hexagons_list.h"
+#include "components/ui_button.h"
+
+namespace OHOS {
+class UITestHexagonsList : public UITest, public UIView::OnClickListener, public UIView::OnLongPressListener {
+public:
+    UITestHexagonsList() {}
+    ~UITestHexagonsList() override {}
+    void SetUp() override;
+    void TearDown() override;
+    const UIView *GetTestView() override;
+    bool OnClick(UIView& view, const ClickEvent& event) override;
+    bool OnLongPress(UIView& view, const LongPressEvent& event) override;
+
+private:
+    void HandleClickEventForRectScreen(const UIView& view);
+    void ConfigButtonAttr(UIView& view, int16_t x, int16_t y, int16_t width, int16_t height);
+    void SetUpButtons(int16_t xEnd, int16_t yEnd, int16_t xMiddle, int16_t yMiddle);
+    UICustomHexagonsList* hexagonsList_ = nullptr;
+    int16_t horMargin_ = 0;
+    int16_t verMargin_ = 0;
+    int16_t borderRadius_ = 0;
+    UIViewGroup* container_ = nullptr;
+    uint16_t imgSize_ = 0;
+    uint16_t imgDistance_ = 0;
+    float imgScaleFactor_ = 0;
+    float globalScale_ = 0;
+    bool isIncreaseImgSize_ = true;
+    UIButton* modifyImgSizeButton_ = nullptr;
+    bool isIncreaseImgDistance_ = true;
+    UIButton* modifyImgDistanceButton_ = nullptr;
+    bool isIncreaseScaleFactor_ = true;
+    UIButton* modifyScaleFatorButton_ = nullptr;
+    bool isIncreaseGlobalScale_ = true;
+    UIButton* modifyGlobalScaleButton_ = nullptr;
+    bool isIncreaseHorMargin_ = true;
+    UIButton* modifyHorMarginButton_ = nullptr;
+    bool isIncreaseVerMargin_ = true;
+    UIButton* modifyVerMarginButton_ = nullptr;
+    bool isIncreaseBorderRadius_ = true;
+    UIButton* modifyBorderRadiusButton_ = nullptr;
+};
+}
+#endif // UI_TEST_HEXAGONS_LIST_H
\ No newline at end of file
diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_kaleidoscope/ui_test_kaleidoscope.cpp b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_kaleidoscope/ui_test_kaleidoscope.cpp
new file mode 100644 (file)
index 0000000..3f528d9
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) @CompanyNameMagicTag. 2024. All rights reserved.
+ */
+
+#include "ui_test_kaleidoscope.h"
+#include "common/image_cache_manager.h"
+
+namespace OHOS {
+
+void UITestKaleidoscope::KaleidoscopeAnimator::Callback(UIView* view)
+{
+    if (view == nullptr) {
+        return;
+    }
+
+    kaleidoscopeUtils_->Rotate(0.1f); // 0.1: rotate by 0.1
+    view->Invalidate();
+}
+
+void UITestKaleidoscope::SetUp()
+{
+    container_ = new UIViewGroup();
+    container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+    container_->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE);
+    container_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+
+    imgInfo_ = ImageCacheManager::GetInstance().LoadSingleRes(RES_PATH"rabbit454.bin");
+
+    if ((Screen::GetInstance().GetWidth() == imgInfo_->header.width) &&
+        (Screen::GetInstance().GetHeight() == imgInfo_->header.height)) {
+        kaleidoscope_ = new UIKaleidoscopeView();
+        if (kaleidoscope_->SetSrc(imgInfo_) == false) {
+            return;
+        }
+
+        container_->Add(kaleidoscope_);
+        kaleidoscope_->RequestFocus();
+        kaleidoscope_->SetRotateEventFactor(0.2f); // 0.2: rotate event factor
+        kaleidoscope_->SetRotateAnimatorValue(0.1f); // 0.1: rotate animator value
+        kaleidoscope_->StartRotateAnimator();
+        return;
+    }
+
+    kaleidoscopeUtils_ = new KaleidoscopeUtils();
+    kaleidoscopeUtils_->Init(imgInfo_, nullptr);
+    ImageInfoExt* infoExt = kaleidoscopeUtils_->GetKaleidoscopeInfo();
+
+    img_ = new UIImageView();
+    img_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+    img_->SetAutoEnable(false);
+    img_->SetResizeMode(UIImageView::ImageResizeMode::FILL);
+    img_->SetSrc(&infoExt->info);
+    container_->Add(img_);
+
+    if (utilsAnimator_ == nullptr) {
+        utilsAnimator_ = new KaleidoscopeAnimator(kaleidoscopeUtils_, img_);
+        utilsAnimator_->Start();
+    }
+}
+
+void UITestKaleidoscope::TearDown()
+{
+    if (utilsAnimator_ != nullptr) {
+        utilsAnimator_->Stop();
+        delete utilsAnimator_;
+        utilsAnimator_ = nullptr;
+    }
+
+    if (kaleidoscope_ != nullptr) {
+        kaleidoscope_->StopRotateAnimator();
+        kaleidoscope_->ClearFocus();
+        kaleidoscope_ = nullptr;
+    }
+
+    DeleteChildren(container_);
+    container_ = nullptr;
+    imgInfo_ = nullptr;
+    img_ = nullptr;
+
+    if (kaleidoscopeUtils_ != nullptr) {
+        delete kaleidoscopeUtils_;
+        kaleidoscopeUtils_ = nullptr;
+    }
+    ImageCacheManager::GetInstance().UnloadSingleRes(RES_PATH"rabbit454.bin");
+}
+
+const UIView* UITestKaleidoscope::GetTestView()
+{
+    return container_;
+}
+}
diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_kaleidoscope/ui_test_kaleidoscope.h b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_kaleidoscope/ui_test_kaleidoscope.h
new file mode 100644 (file)
index 0000000..15c3d93
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) @CompanyNameMagicTag. 2024. All rights reserved.
+ */
+
+#ifndef UI_TEST_KALEIDOSCOPE_H
+#define UI_TEST_KALEIDOSCOPE_H
+
+#include "ui_test.h"
+#include "components/ui_kaleidoscope_view.h"
+#include "components/kaleidoscope_utils.h"
+#include "animator/animator.h"
+#include "components/ui_image_view.h"
+
+namespace OHOS {
+class UITestKaleidoscope : public UITest {
+public:
+    UITestKaleidoscope() {}
+    ~UITestKaleidoscope() override {}
+    void SetUp() override;
+    void TearDown() override;
+    const UIView* GetTestView() override;
+
+private:
+    class KaleidoscopeAnimator : public Animator, public AnimatorCallback {
+    public:
+        KaleidoscopeAnimator(KaleidoscopeUtils* kaleidoscopeUtils, UIImageView* img)
+            : Animator(this, img, 0, true), kaleidoscopeUtils_(kaleidoscopeUtils) {}
+        virtual ~KaleidoscopeAnimator() {}
+        void Callback(UIView* view) override;
+
+    private:
+        KaleidoscopeUtils* kaleidoscopeUtils_;
+    };
+
+    UIViewGroup* container_ = nullptr;
+    ImageInfo* imgInfo_ = nullptr;
+
+    UIKaleidoscopeView* kaleidoscope_ = nullptr;
+
+    UIImageView* img_ = nullptr;
+    KaleidoscopeUtils* kaleidoscopeUtils_ = nullptr;
+    KaleidoscopeAnimator* utilsAnimator_ = nullptr;
+};
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_map/ui_test_map.cpp b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_map/ui_test_map.cpp
new file mode 100644 (file)
index 0000000..53cee95
--- /dev/null
@@ -0,0 +1,98 @@
+/*\r
+ * Copyright (c) 2024 CompanyNameMagicTag.\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include "ui_test_map.h"\r
+#include "common/screen.h"\r
+#include "components/root_view.h"\r
+\r
+namespace OHOS {\r
+static float g_scale = 1.0;\r
+static const float SCALE_LIMIT = 0.5;\r
+static const float SCALE_STEP = 0.1;\r
+static const Vector2<float> SCALE_CENTER = {228, 178}; // 228, 178: scale center\r
+\r
+void UITestMap::SetUp()\r
+{\r
+    container_ = new UIScrollView();\r
+    container_->Resize(Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+    container_->SetScrollBlankSize(200); // 200: blank size\r
+\r
+    map_ = new UIMapView();\r
+    map_->SetPosition(100, 50, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); // 100, 50: x, y\r
+    map_->SetSVG(RES_PATH"map.bin");\r
+    container_->Add(map_);\r
+\r
+    scale_ = new UILabelButton();\r
+    scale_->SetPosition(57, 340, 100, 50); // 57: x, 340: y, 100: width, 50: height\r
+    scale_->SetText("scale");\r
+    scale_->SetOnClickListener(this);\r
+    container_->Add(scale_);\r
+\r
+    cache_ = new UILabelButton();\r
+    cache_->SetPosition(177, 340, 100, 50); // 177: x, 340: y, 100: width, 50: height\r
+    cache_->SetText("cache");\r
+    cache_->SetOnClickListener(this);\r
+    container_->Add(cache_);\r
+\r
+    reset_ = new UILabelButton();\r
+    reset_->SetPosition(297, 340, 100, 50); // 297: x, 340: y, 100: width, 50: height\r
+    reset_->SetText("reset");\r
+    reset_->SetOnClickListener(this);\r
+    container_->Add(reset_);\r
+}\r
+\r
+void UITestMap::TearDown()\r
+{\r
+    DeleteChildren(container_);\r
+    container_ = nullptr;\r
+    scale_ = nullptr;\r
+    cache_ = nullptr;\r
+    reset_ = nullptr;\r
+    map_ = nullptr;\r
+}\r
+\r
+const UIView* UITestMap::GetTestView()\r
+{\r
+    return container_;\r
+}\r
+\r
+bool UITestMap::OnClick(UIView& view, const ClickEvent& event)\r
+{\r
+    if (&view == scale_) {\r
+        g_scale -= SCALE_STEP;\r
+        if (g_scale < SCALE_LIMIT) {\r
+            g_scale = SCALE_LIMIT;\r
+        }\r
+        map_->EnableCache(false);\r
+        map_->ScaleMap(g_scale, SCALE_CENTER);\r
+    } else if (&view == cache_) {\r
+        if (!cached_) {\r
+            cache_->SetText("clear cache");\r
+            map_->EnableCache(true);\r
+            cached_ = true;\r
+        } else {\r
+            cache_->SetText("cache");\r
+            map_->EnableCache(false);\r
+            cached_ = false;\r
+        }\r
+    } else if (&view == reset_) {\r
+        g_scale = 1.0;\r
+        map_->EnableCache(false);\r
+        map_->ScaleMap(g_scale, SCALE_CENTER);\r
+    }\r
+    RootView::GetInstance()->Invalidate();\r
+    return true;\r
+}\r
+}\r
diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_map/ui_test_map.h b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_map/ui_test_map.h
new file mode 100644 (file)
index 0000000..927a098
--- /dev/null
@@ -0,0 +1,43 @@
+/*\r
+ * Copyright (c) 2024 CompanyNameMagicTag.\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#ifndef UI_TEST_MAP_H\r
+#define UI_TEST_MAP_H\r
+\r
+#include "ui_test.h"\r
+#include "components/ui_label_button.h"\r
+#include "components/ui_map_view.h"\r
+#include "components/ui_scroll_view.h"\r
+\r
+namespace OHOS {\r
+class UITestMap : public UITest, public UIView::OnClickListener {\r
+public:\r
+    UITestMap() {}\r
+    ~UITestMap() override {}\r
+    void SetUp() override;\r
+    void TearDown() override;\r
+    const UIView* GetTestView() override;\r
+    bool OnClick(UIView& view, const ClickEvent& event) override;\r
+\r
+private:\r
+    UIScrollView* container_ = nullptr;\r
+    UILabelButton* scale_ = nullptr;\r
+    UILabelButton* cache_ = nullptr;\r
+    UILabelButton* reset_ = nullptr;\r
+    UIMapView* map_ = nullptr;\r
+    bool cached_ = false;\r
+};\r
+}\r
+#endif\r
index b3ec251..ce6b1e7 100755 (executable)
@@ -26,6 +26,7 @@ namespace OHOS {
 namespace {
 const uint16_t TESTCASE_BUTTON_HEIGHT = 100;
 const uint16_t STYLE_BORDER_WIDTH_VALUE = 4;
+const uint16_t BACK_BUTTON_SIZE = 50;
 } // namespace
 
 uint16_t TestCaseListAdapter::GetCount()
@@ -82,7 +83,8 @@ public:
             rootView->Add(tempView);
             if (backBtn_ == nullptr) {
                 backBtn_ = new TransparentBackButton();
-                backBtn_->SetPosition(0, 202, 50, 50); // 0: x position, 202: y position, 50: width and height
+                backBtn_->SetPosition(0, (Screen::GetInstance().GetHeight() - BACK_BUTTON_SIZE) / 2, // 2, half size
+                    BACK_BUTTON_SIZE, BACK_BUTTON_SIZE);
             }
             backBtn_->SetViewId(view.GetViewId());
             rootView->Add(backBtn_);
index 5379804..7109caf 100755 (executable)
 #include "ui_test_sweepclock/ui_test_sweepclock.h"
 #include "ui_test_text_fps/ui_test_text_fps.h"
 #include "ui_test_tiger/ui_test_tiger.h"
+#include "ui_test_hexagons_list/ui_test_hexagons_list.h"
 #include "ui_test_list_fps/ui_test_list_fps.h"
 #include "ui_test_card_switch/ui_test_card_switch.h"
 #include "ui_test_message/ui_test_message.h"
 #include "ui_test_breath/ui_test_breath.h"
 #include "ui_test_cube_rotate/ui_test_cube_rotate.h"
 #include "ui_test_cross/ui_test_cross.h"
+#include "ui_test_map/ui_test_map.h"
+#include "ui_test_coverflow/ui_test_coverflow.h"
+#include "ui_test_kaleidoscope/ui_test_kaleidoscope.h"
 
 namespace OHOS {
 void UITestGroup::AddTestCase(TestCaseInfo testCaseInfo)
@@ -92,6 +96,7 @@ void UITestGroup::SetUpTestCase()
     }
     testCaseList_->Clear();
     testCaseList_->PushBack(TestCaseInfo{"老虎头", new UITestTiger()});
+    testCaseList_->PushBack(TestCaseInfo{"蜂窝表盘", new UITestHexagonsList()});
     testCaseList_->PushBack(TestCaseInfo{"滑动列表", new UITestListFPS()});
     testCaseList_->PushBack(TestCaseInfo{"扫秒", new UITestSweepClock()});
     testCaseList_->PushBack(TestCaseInfo{"指南针", new UITestCompass()});
@@ -101,12 +106,18 @@ void UITestGroup::SetUpTestCase()
     testCaseList_->PushBack(TestCaseInfo{"卡片切换", new UITestCardSwitch()});
     testCaseList_->PushBack(TestCaseInfo{"消息", new UITestMessage()});
     testCaseList_->PushBack(TestCaseInfo{"呼吸效果", new UITestBreath()});
+    testCaseList_->PushBack(TestCaseInfo{"地图", new UITestMap()});
 #if !defined(_WIN32) && !defined(QSPI_DISPLAY)
     testCaseList_->PushBack(TestCaseInfo{"视频播放", new UITestVideoPlay()});
 #endif
 #if !defined(QSPI_DISPLAY)
     testCaseList_->PushBack(TestCaseInfo{"翻转动效", new UITestCross()});
 #endif
+#if !defined(_WIN32)
+    testCaseList_->PushBack(TestCaseInfo{"万花筒", new UITestKaleidoscope()});
+#endif
+    testCaseList_->PushBack(TestCaseInfo{"覆盖流", new UITestCoverflow()});
+
 #if ENABLE_VGU_ENGINE && CAPABILITY_HWDRAW_PATH
     testCaseList_->PushBack(TestCaseInfo{"倒计时", new UITestCountdown()});
     testCaseList_->PushBack(TestCaseInfo{"动画曲线", new UITestRunningBall()});
index cf86bbf..d87f0f5 100755 (executable)
@@ -802,7 +802,7 @@ void RootView::DrawTop(UIView* view, const Rect& rect)
 #if ENABLE_MAP_BUFFER
                     if ((curView->GetViewType() != UI_IMAGE_VIEW) && (curView->GetViewType() != UI_TEXTURE_MAPPER) &&
                         (curView->GetViewType() != UI_CANVAS_EXT) && (curView->GetViewType() != UI_MENU_ITEM) &&
-                        !curView->IsTransInvalid() && !enableAnimator) {
+                        (curView->GetViewType() != UI_MAP_VIEW) && !curView->IsTransInvalid() && !enableAnimator) {
                         origRect = curView->GetOrigRect();
                         relativeRect = curView->GetRelativeRect();
                         curView->GetTransformMap().SetInvalid(true);
index 360a751..74a13ec 100755 (executable)
@@ -272,7 +272,7 @@ void UIView::Rotate(int16_t angle, const Vector2<float>& pivot)
 {
 #if !ENABLE_MAP_BUFFER
     UIViewType type = GetViewType();
-    if ((type != UI_IMAGE_VIEW) && (type != UI_TEXTURE_MAPPER) && (type != UI_CANVAS_EXT)) {
+    if ((type != UI_IMAGE_VIEW) && (type != UI_TEXTURE_MAPPER) && (type != UI_CANVAS_EXT) && (type != UI_MAP_VIEW)) {
         GRAPHIC_LOGE("Rotate is not supported for view type %d if ENABLE_MAP_BUFFER is 0", type);
         return;
     }
@@ -291,7 +291,7 @@ void UIView::Rotate(int16_t angle, const Vector3<float>& pivotStart, const Vecto
 {
 #if !ENABLE_MAP_BUFFER
     UIViewType type = GetViewType();
-    if ((type != UI_IMAGE_VIEW) && (type != UI_TEXTURE_MAPPER) && (type != UI_CANVAS_EXT)) {
+    if ((type != UI_IMAGE_VIEW) && (type != UI_TEXTURE_MAPPER) && (type != UI_CANVAS_EXT) && (type != UI_MAP_VIEW)) {
         GRAPHIC_LOGE("Rotate is not supported for view type %d if ENABLE_MAP_BUFFER is 0", type);
         return;
     }
@@ -306,10 +306,10 @@ void UIView::Rotate(int16_t angle, const Vector3<float>& pivotStart, const Vecto
     transMap_->Rotate(angle, pivotStart, pivotEnd);
     if (firstTrans) {
         joinRect = transMap_->GetBoxRect();
+        joinRect.Join(joinRect, GetOrigRect());
     } else {
         joinRect.Join(joinRect, transMap_->GetBoxRect());
     }
-    joinRect.Join(joinRect, GetOrigRect());
     InvalidateRect(joinRect);
 }
 
@@ -317,7 +317,7 @@ void UIView::Scale(const Vector2<float>& scale, const Vector2<float>& pivot)
 {
 #if !ENABLE_MAP_BUFFER
     UIViewType type = GetViewType();
-    if ((type != UI_IMAGE_VIEW) && (type != UI_TEXTURE_MAPPER) && (type != UI_CANVAS_EXT)) {
+    if ((type != UI_IMAGE_VIEW) && (type != UI_TEXTURE_MAPPER) && (type != UI_CANVAS_EXT) && (type != UI_MAP_VIEW)) {
         GRAPHIC_LOGE("Scale is not supported for view type %d if ENABLE_MAP_BUFFER is 0", type);
         return;
     }
@@ -331,7 +331,7 @@ void UIView::Scale(const Vector3<float>& scale, const Vector3<float>& pivot)
 {
 #if !ENABLE_MAP_BUFFER
     UIViewType type = GetViewType();
-    if ((type != UI_IMAGE_VIEW) && (type != UI_TEXTURE_MAPPER) && (type != UI_CANVAS_EXT)) {
+    if ((type != UI_IMAGE_VIEW) && (type != UI_TEXTURE_MAPPER) && (type != UI_CANVAS_EXT) && (type != UI_MAP_VIEW)) {
         GRAPHIC_LOGE("Scale is not supported for view type %d if ENABLE_MAP_BUFFER is 0", type);
         return;
     }
@@ -354,10 +354,10 @@ void UIView::Scale(const Vector3<float>& scale, const Vector3<float>& pivot)
     transMap_->Scale(scale, pivot);
     if (firstTrans) {
         joinRect = transMap_->GetBoxRect();
+        joinRect.Join(joinRect, GetOrigRect());
     } else {
         joinRect.Join(joinRect, transMap_->GetBoxRect());
     }
-    joinRect.Join(joinRect, GetOrigRect());
     InvalidateRect(joinRect);
 }
 
@@ -365,7 +365,7 @@ void UIView::Shear(const Vector2<float>& shearX, const Vector2<float>& shearY, c
 {
 #if !ENABLE_MAP_BUFFER
     UIViewType type = GetViewType();
-    if ((type != UI_IMAGE_VIEW) && (type != UI_TEXTURE_MAPPER) && (type != UI_CANVAS_EXT)) {
+    if ((type != UI_IMAGE_VIEW) && (type != UI_TEXTURE_MAPPER) && (type != UI_CANVAS_EXT) && (type != UI_MAP_VIEW)) {
         GRAPHIC_LOGE("Shear is not supported for view type %d if ENABLE_MAP_BUFFER is 0", type);
         return;
     }
@@ -380,10 +380,10 @@ void UIView::Shear(const Vector2<float>& shearX, const Vector2<float>& shearY, c
     transMap_->Shear(shearX, shearY, shearZ);
     if (firstTrans) {
         joinRect = transMap_->GetBoxRect();
+        joinRect.Join(joinRect, GetOrigRect());
     } else {
         joinRect.Join(joinRect, transMap_->GetBoxRect());
     }
-    joinRect.Join(joinRect, GetOrigRect());
     InvalidateRect(joinRect);
 }
 
@@ -391,7 +391,7 @@ void UIView::Translate(const Vector2<int16_t>& trans)
 {
 #if !ENABLE_MAP_BUFFER
     UIViewType type = GetViewType();
-    if ((type != UI_IMAGE_VIEW) && (type != UI_TEXTURE_MAPPER) && (type != UI_CANVAS_EXT)) {
+    if ((type != UI_IMAGE_VIEW) && (type != UI_TEXTURE_MAPPER) && (type != UI_CANVAS_EXT) && (type != UI_MAP_VIEW)) {
         GRAPHIC_LOGE("Translate is not supported for view type %d if ENABLE_MAP_BUFFER is 0", type);
         return;
     }
@@ -404,7 +404,7 @@ void UIView::Translate(const Vector3<int16_t>& trans)
 {
 #if !ENABLE_MAP_BUFFER
     UIViewType type = GetViewType();
-    if ((type != UI_IMAGE_VIEW) && (type != UI_TEXTURE_MAPPER) && (type != UI_CANVAS_EXT)) {
+    if ((type != UI_IMAGE_VIEW) && (type != UI_TEXTURE_MAPPER) && (type != UI_CANVAS_EXT) && (type != UI_MAP_VIEW)) {
         GRAPHIC_LOGE("Translate is not supported for view type %d if ENABLE_MAP_BUFFER is 0", type);
         return;
     }
@@ -419,10 +419,10 @@ void UIView::Translate(const Vector3<int16_t>& trans)
     transMap_->Translate(trans);
     if (firstTrans) {
         joinRect = transMap_->GetBoxRect();
+        joinRect.Join(joinRect, GetOrigRect());
     } else {
         joinRect.Join(joinRect, transMap_->GetBoxRect());
     }
-    joinRect.Join(joinRect, GetOrigRect());
     InvalidateRect(joinRect);
 }
 
@@ -799,7 +799,7 @@ void UIView::SetTransformMap(const TransformMap& transMap)
 {
 #if !ENABLE_MAP_BUFFER
     UIViewType type = GetViewType();
-    if ((type != UI_IMAGE_VIEW) && (type != UI_TEXTURE_MAPPER) && (type != UI_CANVAS_EXT)) {
+    if ((type != UI_IMAGE_VIEW) && (type != UI_TEXTURE_MAPPER) && (type != UI_CANVAS_EXT) && (type != UI_MAP_VIEW)) {
         GRAPHIC_LOGE("SetTransformMap is not supported for view type %d if ENABLE_MAP_BUFFER is 0", type);
         return;
     }
index 3ad3579..c5039a7 100755 (executable)
@@ -241,10 +241,10 @@ protected:
     bool DragXInner(int16_t distance) override;
     bool DragYInner(int16_t distance) override;
     bool MoveOffset(int16_t offsetX, int16_t offsetY);
+    void CalculateReboundDistance(int16_t& dragDistanceX, int16_t& dragDistanceY) override;
 
 private:
     void Drag(const DragEvent& event);
-    void CalculateReboundDistance(int16_t& dragDistanceX, int16_t& dragDistanceY) override;
     void RefreshScrollBar();
     OnScrollListener* scrollListener_;
 #if ENABLE_VIBRATOR
index f3c3c76..3c9227f 100755 (executable)
@@ -113,6 +113,8 @@ enum UIViewType : uint8_t {
     UI_CARD_PAGE,
     UI_CROSS_VIEW,
     UI_BARCODE,
+    UI_MAP_VIEW,
+    UI_KALEIDOSCOPE_VIEW,
     UI_NUMBER_MAX
 };
 
index df8f05d..2444ccc 100755 (executable)
@@ -82,6 +82,9 @@ uint32_t Rect::GetSize() const
 
 bool Rect::Intersect(const Rect& rect1, const Rect& rect2)
 {
+    if (!rect1.IsValid() || !rect2.IsValid()) {
+        return false;
+    }
     /* Get the smaller area from 'rect1' and 'rect2' */
     left_ = MATH_MAX(rect1.left_, rect2.left_);
     top_ = MATH_MAX(rect1.top_, rect2.top_);
index e7941cd..d544bf7 100755 (executable)
@@ -57,6 +57,27 @@ float Sin(float angle)
 #endif
 }
 
+float Acos(float value)
+{
+#if defined(ENABLE_CMATH) && ENABLE_CMATH
+    return acos(value);
+#else
+    float result, l, r;
+    l = 0;
+    r = UI_PI;
+    result = (l + r) / 2;
+    while (MATH_ABS(Sin(QUARTER_IN_DEGREE - result * RADIAN_TO_ANGLE) - value) > UI_FLT_EPSILON) {
+        if (Sin(QUARTER_IN_DEGREE - result * RADIAN_TO_ANGLE) - value > UI_FLT_EPSILON) {
+            l = result;
+        } else {
+            r = result;
+        }
+        result = (l + r) / 2;
+    }
+    return result;
+#endif
+}
+
 /* arctan(x) = x - p3 * x^3 + p5 * x^5 - p7 * x^7 */
 uint16_t FastAtan2(int16_t x, int16_t y)
 {
index b0d571b..7780787 100755 (executable)
@@ -84,6 +84,7 @@ static constexpr float UI_FLT_EPSILON = 1E-5;
 static constexpr int16_t ORDER_MATRIX_4 = 4;
 
 float Sin(float angle);
+float Acos(float value);
 uint16_t FastAtan2(int16_t x, int16_t y);
 float Sqrt(float x);
 
@@ -956,7 +957,27 @@ inline int64_t FloatToInt64(float f)
 
 inline bool FloatEqual(float lhs, float rhs, float precision = 0.00001f)
 {
-    return (MATH_ABS(lhs - rhs) < precision) ? true : false;
+    return MATH_ABS(lhs - rhs) < precision;
+}
+
+inline bool FloatMore(float lhs, float rhs, float precision = 0.00001f)
+{
+    return lhs - rhs > precision;
+}
+
+inline bool FloatLess(float lhs, float rhs, float precision = 0.00001f)
+{
+    return lhs - rhs < -precision;
+}
+
+inline bool FloatMoreEqual(float lhs, float rhs, float precision = 0.00001f)
+{
+    return lhs - rhs > -precision;
+}
+
+inline bool FloatLessEqual(float lhs, float rhs, float precision = 0.00001f)
+{
+    return lhs - rhs < precision;
 }
 
 bool IsIdentity(Matrix3<float>& matrix);