From: 罗正yun <1732036298@qq.com> Date: Wed, 29 Nov 2023 03:41:22 +0000 (+0800) Subject: 通过按键进入的“辅助功能”视图完成,并将亮屏时长和亮度调节文件夹下文件移动到显示与亮度文件夹下 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=7d4446972f9a15d9c927b9ed129d9e635a4fdb86;p=mirrors%2FFD230.git 通过按键进入的“辅助功能”视图完成,并将亮屏时长和亮度调节文件夹下文件移动到显示与亮度文件夹下 --- diff --git a/Resource/res/FastTrainingAttentionVector.bin b/Resource/res/FastTrainingAttentionVector.bin new file mode 100644 index 000000000..b8120b857 Binary files /dev/null and b/Resource/res/FastTrainingAttentionVector.bin differ diff --git a/code/sdk/application/wearable/nativeapp/CMakeLists.txt b/code/sdk/application/wearable/nativeapp/CMakeLists.txt index f403b5ef7..17b1df448 100644 --- a/code/sdk/application/wearable/nativeapp/CMakeLists.txt +++ b/code/sdk/application/wearable/nativeapp/CMakeLists.txt @@ -265,7 +265,13 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/EndBackTrackingCompassView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/GPSLossCompassPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/GPSLossCompassView.cpp - + #辅助功能 + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/SecondaryFunctionPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/SecondaryFunctionView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/FastTrainingAttentionPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/FastTrainingAttentionView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/FastTrainingPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/FastTrainingView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phoneservice/src/PhoneService.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phoneservice/src/PhoneAudio.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/offlinevoice/src/VocassistModel.cpp @@ -280,10 +286,10 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/DisplayBrightnessView.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/brightnesscontrol/src/BrightnessControlPresenter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/brightnesscontrol/src/BrightnessControlView.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/screenduration/src/ScreenDurationPresenter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/screenduration/src/ScreenDurationView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/BrightnessControlPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/BrightnessControlView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/ScreenDurationPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/ScreenDurationView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bluetoothofsetting/src/BlueToothOfSettingModel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bluetoothofsetting/src/BlueToothOfSettingPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bluetoothofsetting/src/BlueToothOfSettingView.cpp diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h index 8639114de..386d5b802 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h @@ -109,7 +109,10 @@ typedef enum : uint16_t VIEW_SYSTEM_FACTORY_RESET, // 系统:恢复出厂设置 VIEW_BRIGHTNESS_CONTROL, // 亮度调节 VIEW_SCREEN_DURATION, // 亮屏时长 - + //按键按下进入的视图 + VIEW_SECONDARY_FUNCTION, //辅助功能 + VIEW_FAST_TRAINING, //快速训练 + VIEW_FAST_TRAINING_ATTENTION,//快速训练项目选择超出提示 VIEW_MAX_INTER_APP, // 在此之前添加native应用ID VIEW_EXTERN_APP = 0xFFFE, // 三方应用 VIEW_INVALIDE_APP = 0xFFFF, diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h index 8ac739c10..dbf78e21d 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h @@ -89,7 +89,10 @@ public: void InitCompassPathRetracingSlice(void); void InitCompassEndBackTrackingEarlySlice(); void InitCompassEndBackTrackingSlice(void); - void InitCompassGPSLossSlice(void); + void InitCompassGPSLossSlice(void); + void InitSecondaryFunction(void); + void InitFastTrainingSlice(void); + void InitFastTrainingAttentionSlice(void); private: void InitAllNativeSlices(void); diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h index 70a8593d5..2f30c60fb 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h @@ -208,6 +208,7 @@ namespace OHOS static constexpr const char *PNG_FACTORY_RESET = APP_RES_PATH "/SYSTEM_FactoryReset.bin"; // 恢复出厂设置 static constexpr const char *PNG_SYSTEM_CHECK_ON_IMAGE = APP_RES_PATH "/SYSTEM_CheckOn.bin"; // 勾 static constexpr const char *PNG_SYSTEM_CHECK_OFF_IMAGE = APP_RES_PATH "/SYSTEM_CheckOff.bin"; // 叉 + static constexpr const char *PNG_FAST_TRAINING_ATTENTION_IMAGE = APP_RES_PATH "/FastTrainingAttentionVector.bin"; //快速训练选中操过三个后出现 // 录音 static constexpr const char *PNG_ANIMATOR1_IMAGE = APP_RES_PATH "/Record/animator1.bin"; static constexpr const char *PNG_ANIMATOR2_IMAGE = APP_RES_PATH "/Record/animator2.bin"; diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp index 1326761a0..70ca048d3 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp @@ -103,10 +103,10 @@ #include "displaybrightness/include/DisplayBrightnessView.h" #include "bluetoothofsetting/include/BlueToothOfSettingPresenter.h" #include "bluetoothofsetting/include/BlueToothOfSettingView.h" -#include "brightnesscontrol/include/BrightnessControlPresenter.h" -#include "brightnesscontrol/include/BrightnessControlView.h" -#include "screenduration/include/ScreenDurationPresenter.h" -#include "screenduration/include/ScreenDurationView.h" +#include "displaybrightness/include/BrightnessControlPresenter.h" +#include "displaybrightness/include/BrightnessControlView.h" +#include "displaybrightness/include/ScreenDurationPresenter.h" +#include "displaybrightness/include/ScreenDurationView.h" #include "soundandvibration/include/SoundAndVibrationPresenter.h" #include "soundandvibration/include/SoundAndVibrationView.h" #include "soundandvibration/include/SystemVolumePresenter.h" @@ -157,6 +157,12 @@ #include "EndBackTrackingCompassView.h" #include "GPSLossCompassPresenter.h" #include "GPSLossCompassView.h" +#include "secondaryfunction/include/SecondaryFunctionPresenter.h" +#include "secondaryfunction/include/SecondaryFunctionView.h" +#include "secondaryfunction/include/FastTrainingPresenter.h" +#include "secondaryfunction/include/FastTrainingView.h" +#include "secondaryfunction/include/FastTrainingAttentionPresenter.h" +#include "secondaryfunction/include/FastTrainingAttentionView.h" namespace OHOS { struct AppViewMapper { @@ -237,6 +243,9 @@ static const AppViewMapper SLICE_MAPPER[] = { {VIEW_COMPASS_END_BACK_TRACKING,&NativeLauncher::InitCompassEndBackTrackingSlice}, //指南针结束路径回溯 {VIEW_COMPASS_END_BACK_TRACKING_EARLY,&NativeLauncher::InitCompassEndBackTrackingEarlySlice},//指南针提前结束路径回溯 {VIEW_COMPASS_GPS_LOSS,&NativeLauncher::InitCompassGPSLossSlice}, //指南针GPS丢失实例化地址 + {VIEW_SECONDARY_FUNCTION,&NativeLauncher::InitSecondaryFunction}, //按键按下进入辅助功能 + {VIEW_FAST_TRAINING,&NativeLauncher::InitFastTrainingSlice}, //快速训练 + {VIEW_FAST_TRAINING_ATTENTION,&NativeLauncher::InitFastTrainingAttentionSlice}, //快速训练 {VIEW_UISAMPLE, &NativeLauncher::InitUISampleSlice} }; @@ -287,6 +296,9 @@ static const ViewIdToString VIEW_MAPPER[] = { {VIEW_COMPASS_END_BACK_TRACKING_EARLY,"EndBackTrackingEarlyCompass"},//指南针提前结束路径回溯 {VIEW_COMPASS_END_BACK_TRACKING,"EndBackTrackingCompass"}, //指南针提前结束路径回溯 {VIEW_COMPASS_GPS_LOSS,"GPSLossCompass"}, //指南针GPS丢失 + {VIEW_SECONDARY_FUNCTION,"SecondaryFunction"}, //辅助功能 + {VIEW_FAST_TRAINING,"FastTraining"}, //快速训练 + {VIEW_FAST_TRAINING_ATTENTION,"FastTrainingAttention"}, {VIEW_UISAMPLE, "UISample"} }; @@ -1010,4 +1022,31 @@ void NativeLauncher::InitCompassGPSLossSlice(void) //指南针:GPS丢 } NativeAbility::GetInstance().AddSliceProxy(VIEW_COMPASS_GPS_LOSS, GPSlosscompass); } + +void NativeLauncher::InitSecondaryFunction(void) //辅助功能 +{ + SliceProxy *secondaryfunction = new AbilitySliceProxy; + if (secondaryfunction == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_SECONDARY_FUNCTION, secondaryfunction); +} + +void NativeLauncher::InitFastTrainingSlice(void) +{ + SliceProxy *fasttraining = new AbilitySliceProxy; + if (fasttraining == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_FAST_TRAINING, fasttraining); +} + +void NativeLauncher::InitFastTrainingAttentionSlice(void) +{ + SliceProxy *fasttrainingattention = new AbilitySliceProxy; + if (fasttrainingattention == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_FAST_TRAINING_ATTENTION, fasttrainingattention); +} } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/brightnesscontrol/include/BrightnessControlPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/include/BrightnessControlPresenter.h similarity index 100% rename from code/sdk/application/wearable/nativeapp/nativeui/brightnesscontrol/include/BrightnessControlPresenter.h rename to code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/include/BrightnessControlPresenter.h diff --git a/code/sdk/application/wearable/nativeapp/nativeui/brightnesscontrol/include/BrightnessControlView.h b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/include/BrightnessControlView.h similarity index 100% rename from code/sdk/application/wearable/nativeapp/nativeui/brightnesscontrol/include/BrightnessControlView.h rename to code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/include/BrightnessControlView.h diff --git a/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h index 574274b4a..c442537e4 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h @@ -1,7 +1,7 @@ #ifndef _DISPLAY_BRIGHTNESS_PRESENTER_H #define _DISPLAY_BRIGHTNESS_PRESENTER_H - +/*显示与亮度*/ #include "Presenter.h" #include "DisplayBrightnessView.h" diff --git a/code/sdk/application/wearable/nativeapp/nativeui/screenduration/include/ScreenDurationPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/include/ScreenDurationPresenter.h similarity index 100% rename from code/sdk/application/wearable/nativeapp/nativeui/screenduration/include/ScreenDurationPresenter.h rename to code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/include/ScreenDurationPresenter.h diff --git a/code/sdk/application/wearable/nativeapp/nativeui/screenduration/include/ScreenDurationView.h b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/include/ScreenDurationView.h similarity index 68% rename from code/sdk/application/wearable/nativeapp/nativeui/screenduration/include/ScreenDurationView.h rename to code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/include/ScreenDurationView.h index a808060f9..7496db087 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/screenduration/include/ScreenDurationView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/include/ScreenDurationView.h @@ -1,6 +1,6 @@ #ifndef SCREEN_DUATION_VIEW_H #define SCREEN_DUATION_VIEW_H - +//屏幕时长 #include "BaseView.h" #include "View.h" #include "components/ui_view_group.h" @@ -28,11 +28,6 @@ namespace OHOS void OnStop() override; public: - // void AddLabelImageViewCheckbox(UIScrollView *parentView, int labelLeft, int labelTop, int labelWidth, int labelHeight, - // const char *labelText, const char *labeId, int imageLeft, int imageTop, int imageWidth, int imageHeight, const char *imageId, - // const char *imagePath, UICheckBox *checkbox, int checkboxLeft, int checkboxTop, int checkboxWidth, int checkboxHeight, const char *checkboxId, - // const char *selectedImagePath, const char *unselectedImagePath); - UICheckBox *second5checkbox = nullptr; UICheckBox *second10checkbox = nullptr; UICheckBox *second15checkbox = nullptr; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/brightnesscontrol/src/BrightnessControlPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/src/BrightnessControlPresenter.cpp similarity index 96% rename from code/sdk/application/wearable/nativeapp/nativeui/brightnesscontrol/src/BrightnessControlPresenter.cpp rename to code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/src/BrightnessControlPresenter.cpp index 60f410107..7f02c719b 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/brightnesscontrol/src/BrightnessControlPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/src/BrightnessControlPresenter.cpp @@ -2,7 +2,7 @@ #include "NativeAbility.h" #include "graphic_math.h" #include "string.h" -#include "brightnesscontrol/include/BrightnessControlPresenter.h" +#include "displaybrightness/include/BrightnessControlPresenter.h" namespace OHOS{ diff --git a/code/sdk/application/wearable/nativeapp/nativeui/brightnesscontrol/src/BrightnessControlView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/src/BrightnessControlView.cpp similarity index 97% rename from code/sdk/application/wearable/nativeapp/nativeui/brightnesscontrol/src/BrightnessControlView.cpp rename to code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/src/BrightnessControlView.cpp index 341ce8b28..883e1e2b5 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/brightnesscontrol/src/BrightnessControlView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/src/BrightnessControlView.cpp @@ -1,5 +1,5 @@ -#include "brightnesscontrol/include/BrightnessControlView.h" -#include "brightnesscontrol/include/BrightnessControlPresenter.h" +#include "displaybrightness/include/BrightnessControlView.h" +#include "displaybrightness/include/BrightnessControlPresenter.h" #include "UiConfig.h" namespace OHOS { diff --git a/code/sdk/application/wearable/nativeapp/nativeui/screenduration/src/ScreenDurationPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/src/ScreenDurationPresenter.cpp similarity index 97% rename from code/sdk/application/wearable/nativeapp/nativeui/screenduration/src/ScreenDurationPresenter.cpp rename to code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/src/ScreenDurationPresenter.cpp index 823f4ebbe..1719669eb 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/screenduration/src/ScreenDurationPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/src/ScreenDurationPresenter.cpp @@ -2,7 +2,7 @@ #include "NativeAbility.h" #include "graphic_math.h" #include "string.h" -#include "screenduration/include/ScreenDurationPresenter.h" +#include "displaybrightness/include/ScreenDurationPresenter.h" #include "components/ui_checkbox.h" namespace OHOS { diff --git a/code/sdk/application/wearable/nativeapp/nativeui/screenduration/src/ScreenDurationView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/src/ScreenDurationView.cpp similarity index 81% rename from code/sdk/application/wearable/nativeapp/nativeui/screenduration/src/ScreenDurationView.cpp rename to code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/src/ScreenDurationView.cpp index 1037433c9..95b82e0b2 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/screenduration/src/ScreenDurationView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/displaybrightness/src/ScreenDurationView.cpp @@ -1,5 +1,5 @@ -#include "screenduration/include/ScreenDurationView.h" -#include "screenduration/include/ScreenDurationPresenter.h" +#include "displaybrightness/include/ScreenDurationView.h" +#include "displaybrightness/include/ScreenDurationPresenter.h" #include "UiConfig.h" namespace OHOS @@ -15,6 +15,13 @@ namespace OHOS ScreenDurationView::~ScreenDurationView() { + container_->RemoveAll(); + delete ScreenDurationScrollView; + ScreenDurationScrollView = nullptr; + delete ScreenDurationLabel; + ScreenDurationLabel = nullptr; + delete container_; + container_ = nullptr; g_pScreenDurationView = nullptr; } @@ -22,55 +29,7 @@ namespace OHOS { return g_pScreenDurationView; } - /* - 不知道什么原因:在使用这个函数时为三个复选框绑定点击事件时视图创建不了,或者是视图创建了,点击复选框屏幕卡死然后重启 - void ScreenDurationView::AddLabelImageViewCheckbox(UIScrollView *parentView, int labelLeft, int labelTop, int labelWidth, int labelHeight, - const char *labelText, const char *labeId, int imageLeft, int imageTop, int imageWidth, int imageHeight, const char *imageId, - const char *imagePath, UICheckBox *checkbox, int checkboxLeft, int checkboxTop, int checkboxWidth, int checkboxHeight, const char *checkboxId, - const char *selectedImagePath, const char *unselectedImagePath) - { - // Add ImageView to App - UIImageView *image = new UIImageView(); - image->SetPosition(imageLeft, imageTop); - image->Resize(imageWidth, imageHeight); - image->SetViewId(imageId); - image->SetStyle(STYLE_BORDER_RADIUS, 50); - image->SetSrc(imagePath); - parentView->Add(image); - image->SetVisible(true); - - // Add Label to App - UILabel *label = new UILabel(); - label->SetPosition(labelLeft, labelTop); - label->Resize(labelWidth, labelHeight); - label->SetViewId(labeId); - label->SetStyle(STYLE_TEXT_FONT, 30); - label->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - label->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - label->SetStyle(STYLE_LINE_HEIGHT, 35); - - label->SetText(labelText); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(6); - label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - - parentView->Add(label); - label->SetVisible(true); - // Add CheckBox to App - checkbox = new UICheckBox(); - checkbox->SetPosition(checkboxLeft, checkboxTop); - checkbox->Resize(checkboxWidth, checkboxHeight); - checkbox->SetViewId(checkboxId); - checkbox->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - checkbox->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - checkbox->SetImages(selectedImagePath, unselectedImagePath); - - parentView->Add(checkbox); - checkbox->SetVisible(true); - } - */ void ScreenDurationView::InitView(void) { if (container_ == nullptr) diff --git a/code/sdk/application/wearable/nativeapp/nativeui/quickaccess/src/QuickAccessPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/quickaccess/src/QuickAccessPresenter.cpp index d94129e1b..7c719303b 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/quickaccess/src/QuickAccessPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/quickaccess/src/QuickAccessPresenter.cpp @@ -72,6 +72,7 @@ namespace OHOS if (strcmp(view.GetViewId(), HEART_RATE_DETECTION) == 0) { printf("<心率检测>\n"); + NativeAbility::GetInstance().ChangeSlice(VIEW_SECONDARY_FUNCTION); return true; } else if(strcmp(view.GetViewId(), BLOOD_OXYGEN_MONITOR) == 0) diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingAttentionPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingAttentionPresenter.h new file mode 100644 index 000000000..673c4e601 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingAttentionPresenter.h @@ -0,0 +1,32 @@ +#ifndef FAST_TRAINING_ATTENTION_PRESENTER_H +#define FAST_TRAINING_ATTENTION_PRESENTER_H + +#include "Presenter.h" + +#include "FastTrainingAttentionView.h" + +namespace OHOS +{ + class FastTrainingAttentionView; + + class FastTrainingAttentionPresenter : public Presenter, + public UIView::OnClickListener + { + public: + FastTrainingAttentionPresenter(); + virtual ~FastTrainingAttentionPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static FastTrainingAttentionPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + }; +} // namespace OHOS + +#endif // FastTrainingAttention_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingAttentionView.h b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingAttentionView.h new file mode 100644 index 000000000..c6e75cf0c --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingAttentionView.h @@ -0,0 +1,42 @@ +#ifndef FAST_TRAINING_ATTENTION_VIEW_H +#define FAST_TRAINING_ATTENTION_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_label_button.h" +namespace OHOS +{ + static const char *LABELBUTTON = "FastTrainingAttentionLabelButton"; + class FastTrainingAttentionPresenter; + class FastTrainingAttentionView : public View + { + + public: + FastTrainingAttentionView(); + virtual ~FastTrainingAttentionView(); + static FastTrainingAttentionView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + UIView::OnDragListener *draglistener{nullptr}; + + void InitView(void); + void DeInitView(void); + + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UILabel *label15_ = nullptr; + UIImageView *image7_ = nullptr; + UILabel *label16_ = nullptr; + UILabelButton *FastTrainingAttentionLabelButton = nullptr; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingPresenter.h new file mode 100644 index 000000000..c8c21e591 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingPresenter.h @@ -0,0 +1,53 @@ +#ifndef FAST_TRAINING_PRESENTER_H +#define FAST_TRAINING_PRESENTER_H + +#include "Presenter.h" +#include "FastTrainingView.h" +#include "components/ui_checkbox.h" +namespace OHOS +{ + class FastTrainingView; + + class FastTrainingPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener, + public UICheckBox::OnChangeListener + { + public: + FastTrainingPresenter(); + virtual ~FastTrainingPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static FastTrainingPresenter *GetInstance(); + void setCheckbox(UICheckBox *checkBox1, UICheckBox *checkBox2, UICheckBox *checkBox3, UICheckBox *checkBox4, UICheckBox *checkBox5, UICheckBox *checkBox6) + { + m_checkBox1 = checkBox1; + m_checkBox2 = checkBox2; + m_checkBox3 = checkBox3; + m_checkBox4 = checkBox4; + m_checkBox5 = checkBox5; + m_checkBox6 = checkBox6; + } + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnChange(UICheckBox::UICheckBoxState state) override; + + private: + static int CheckBoxSelectCount; + UICheckBox *m_checkBox1 = nullptr; + UICheckBox *m_checkBox2 = nullptr; + UICheckBox *m_checkBox3 = nullptr; + UICheckBox *m_checkBox4 = nullptr; + UICheckBox *m_checkBox5 = nullptr; + UICheckBox *m_checkBox6 = nullptr; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingView.h b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingView.h new file mode 100644 index 000000000..1e3aa97e8 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingView.h @@ -0,0 +1,78 @@ +#ifndef FAST_TRAINING_VIEW_H +#define FAST_TRAINING_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_image_view.h" +#include "components/ui_label.h" +#include "components/ui_button.h" +#include "components/ui_checkbox.h" + +namespace OHOS +{ + static const char *CHECKBOX1 = "checkBox1"; + static const char *CHECKBOX2 = "checkBox2"; + static const char *CHECKBOX3 = "checkBox3"; + static const char *CHECKBOX4 = "checkBox4"; + static const char *CHECKBOX5 = "checkBox5"; + static const char *CHECKBOX6 = "checkBox6"; + class FastTrainingPresenter; + class FastTrainingView : public View + { + + public: + FastTrainingView(); + virtual ~FastTrainingView(); + static FastTrainingView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + void InitImageLabelCheckbox(UIImageView *image, int image_x, int image_y, int image_w, int image_h, + UILabel *label, int label_x, int label_y, const char *labelText, + UICheckBox *checkbox, int check_x, int check_y, int check_w, int check_h, const char *checkboxID, + UICheckBox::OnChangeListener *ChangeListener, UIScrollView *scrollView); + + private: + UIView::OnDragListener *draglistener{nullptr}; + + private: + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView = nullptr; + UIImageView *image5_ = nullptr; + UIImageView *image6_ = nullptr; + UIImageView *image1 = nullptr; + UIImageView *image2 = nullptr; + UIImageView *image3 = nullptr; + UIImageView *image4 = nullptr; + UIImageView *image5 = nullptr; + UIImageView *image6 = nullptr; + UILabel *label = nullptr; + UILabel *label1 = nullptr; + UILabel *label2 = nullptr; + UILabel *label3 = nullptr; + UILabel *label4 = nullptr; + UILabel *label5 = nullptr; + UILabel *label6 = nullptr; + UICheckBox *checkBox1 = nullptr; + UICheckBox *checkBox2 = nullptr; + UICheckBox *checkBox3 = nullptr; + UICheckBox *checkBox4 = nullptr; + UICheckBox *checkBox5 = nullptr; + UICheckBox *checkBox6 = nullptr; + UICheckBox::OnChangeListener *ChangeListener1 = nullptr; + UICheckBox::OnChangeListener *ChangeListener2 = nullptr; + UICheckBox::OnChangeListener *ChangeListener3 = nullptr; + UICheckBox::OnChangeListener *ChangeListener4 = nullptr; + UICheckBox::OnChangeListener *ChangeListener5 = nullptr; + UICheckBox::OnChangeListener *ChangeListener6 = nullptr; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/SecondaryFunctionPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/SecondaryFunctionPresenter.h new file mode 100644 index 000000000..0f77dbbfa --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/SecondaryFunctionPresenter.h @@ -0,0 +1,33 @@ +#ifndef SECONDARY_FUNCTION_PRESENTER_H +#define SECONDARY_FUNCTION_PRESENTER_H + +#include "Presenter.h" + +#include "SecondaryFunctionView.h" + +namespace OHOS +{ + class SecondaryFunctionView; + + class SecondaryFunctionPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + SecondaryFunctionPresenter(); + virtual ~SecondaryFunctionPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static SecondaryFunctionPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/SecondaryFunctionView.h b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/SecondaryFunctionView.h new file mode 100644 index 000000000..82ee60c0d --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/SecondaryFunctionView.h @@ -0,0 +1,44 @@ +#ifndef SECONDARY_FUNCTION_VIEW_H +#define SECONDARY_FUNCTION_VIEW_H +/*辅助功能*/ +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_button.h" +#include "components/ui_image_view.h" +namespace OHOS +{ + static const char * SECONDARY_FUNCTION_BUTTON1ID = "SECONDARY_FUNCTION_BUTTON1"; + static const char * SECONDARY_FUNCTION_BUTTON2ID = "SECONDARY_FUNCTION_BUTTON2"; + class SecondaryFunctionPresenter; + class SecondaryFunctionView : public View + { + + public: + SecondaryFunctionView(); + virtual ~SecondaryFunctionView(); + static SecondaryFunctionView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + + private: + UIViewGroup *container_ = nullptr; + UILabel *label1_ = nullptr; + UIButton *SECONDARY_FUNCTION_BUTTON1 = nullptr; + UIImageView *image3_ = nullptr; + UILabel *label2_ = nullptr; + UIButton *SECONDARY_FUNCTION_BUTTON2 = nullptr; + UIImageView *image4_ = nullptr; + UILabel *label4_ = nullptr; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingAttentionPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingAttentionPresenter.cpp new file mode 100644 index 000000000..b2b5691eb --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingAttentionPresenter.cpp @@ -0,0 +1,63 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "secondaryfunction/include/FastTrainingAttentionPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static FastTrainingAttentionPresenter *g_pFastTrainingAttentionPresenter = nullptr; + + FastTrainingAttentionPresenter::FastTrainingAttentionPresenter() + { + + g_pFastTrainingAttentionPresenter = this; + } + + FastTrainingAttentionPresenter::~FastTrainingAttentionPresenter() + { + + g_pFastTrainingAttentionPresenter = nullptr; + } + + FastTrainingAttentionPresenter *FastTrainingAttentionPresenter::GetInstance() + { + + return g_pFastTrainingAttentionPresenter; + } + + void FastTrainingAttentionPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void FastTrainingAttentionPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void FastTrainingAttentionPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void FastTrainingAttentionPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool FastTrainingAttentionPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), LABELBUTTON) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_FAST_TRAINING); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingAttentionView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingAttentionView.cpp new file mode 100644 index 000000000..732a27a8c --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingAttentionView.cpp @@ -0,0 +1,193 @@ +#include "secondaryfunction/include/FastTrainingAttentionView.h" +#include "secondaryfunction/include/FastTrainingAttentionPresenter.h" +#include "UiConfig.h" + +namespace OHOS +{ + + static FastTrainingAttentionView *g_pFastTrainingAttentionView{nullptr}; + + FastTrainingAttentionView::FastTrainingAttentionView() + { + + g_pFastTrainingAttentionView = this; + } + + FastTrainingAttentionView::~FastTrainingAttentionView() + { + DeInitView(); + g_pFastTrainingAttentionView = nullptr; + } + + FastTrainingAttentionView *FastTrainingAttentionView::GetInstance() + { + + return g_pFastTrainingAttentionView; + } + + void FastTrainingAttentionView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add ScrollView to App + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); + scrollView1_->Resize(466, 466); + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // Set additional property + + // Add to rootView + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + + // Add Label to App + if (label15_ == nullptr) + { + label15_ = new UILabel(); + } + label15_->SetPosition(203, 52); + label15_->Resize(200, 60); + label15_->SetStyle(STYLE_TEXT_FONT, 30); + label15_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label15_->SetText("注意"); + label15_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label15_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label15_->SetRollSpeed(0); + label15_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label15_); + label15_->SetVisible(true); + + // Add ImageView to App + if (image7_ == nullptr) + { + image7_ = new UIImageView(); + } + image7_->SetPosition(193, 121); + image7_->Resize(80, 80); + image7_->SetSrc(PNG_FAST_TRAINING_ATTENTION_IMAGE); + + // Add to scrollView1 + scrollView1_->Add(image7_); + image7_->SetVisible(true); + + // Add Label to App + if (label16_ == nullptr) + { + label16_ = new UILabel(); + } + label16_->SetPosition(128, 228); + label16_->Resize(200, 60); + label16_->SetStyle(STYLE_TEXT_FONT, 30); + label16_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label16_->SetText("最多只能选三个"); + label16_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label16_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label16_->SetRollSpeed(0); + label16_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label16_); + label16_->SetVisible(true); + + // Add LabelButtonExt to App + if (FastTrainingAttentionLabelButton == nullptr) + { + FastTrainingAttentionLabelButton = new UILabelButton(); + } + FastTrainingAttentionLabelButton->SetPosition(0, 366); + FastTrainingAttentionLabelButton->Resize(466, 100); + FastTrainingAttentionLabelButton->SetViewId(LABELBUTTON); + char *labelButton1triggeredImgSrc = nullptr; + FastTrainingAttentionLabelButton->SetImageSrc(PNG_NEW_DEVICE, PNG_NEW_DEVICE); + FastTrainingAttentionLabelButton->SetText("知道了"); + FastTrainingAttentionLabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + FastTrainingAttentionLabelButton->SetStyleForState(STYLE_BORDER_COLOR, 0xffffffff, UIButton::PRESSED); + FastTrainingAttentionLabelButton->SetStyleForState(STYLE_BORDER_OPA, 0x00, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *labelButton1Click = static_cast(FastTrainingAttentionPresenter::GetInstance()); + FastTrainingAttentionLabelButton->SetOnClickListener(labelButton1Click); + // Add to scrollView1 + scrollView1_->Add(FastTrainingAttentionLabelButton); + FastTrainingAttentionLabelButton->SetVisible(true); + } + + void FastTrainingAttentionView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (label15_ != nullptr) + { + delete label15_; + label15_ = nullptr; + } + if (image7_ != nullptr) + { + delete image7_; + image7_ = nullptr; + } + if (label16_ != nullptr) + { + delete label16_; + label16_ = nullptr; + } + if (FastTrainingAttentionLabelButton != nullptr) + { + delete FastTrainingAttentionLabelButton; + FastTrainingAttentionLabelButton = nullptr; + } + delete container_; + container_ = nullptr; + } + + void FastTrainingAttentionView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void FastTrainingAttentionView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void FastTrainingAttentionView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void FastTrainingAttentionView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingPresenter.cpp new file mode 100644 index 000000000..9c0c0cee0 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingPresenter.cpp @@ -0,0 +1,92 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "secondaryfunction/include/FastTrainingPresenter.h" +#include "secondaryfunction/include/FastTrainingPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static FastTrainingPresenter *g_pFastTrainingPresenter = nullptr; + int FastTrainingPresenter::CheckBoxSelectCount = 0; // 复选框选中数量 + FastTrainingPresenter::FastTrainingPresenter() + { + + g_pFastTrainingPresenter = this; + } + + FastTrainingPresenter::~FastTrainingPresenter() + { + + g_pFastTrainingPresenter = nullptr; + } + + FastTrainingPresenter *FastTrainingPresenter::GetInstance() + { + + return g_pFastTrainingPresenter; + } + + void FastTrainingPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void FastTrainingPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void FastTrainingPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void FastTrainingPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool FastTrainingPresenter::OnDrag(UIView &view, const DragEvent &event) + { + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SECONDARY_FUNCTION); + } + return true; + } + + bool FastTrainingPresenter::OnChange(UICheckBox::UICheckBoxState state) + { + if (state == UICheckBox::UICheckBoxState::SELECTED) + { + CheckBoxSelectCount += 1; + printf("CheckBoxSelectCount:%d\n", CheckBoxSelectCount); + } + else + { + CheckBoxSelectCount -= 1; + printf("CheckBoxSelectCount:%d\n", CheckBoxSelectCount); + } + if (CheckBoxSelectCount > 3) + { + CheckBoxSelectCount = 0;//->测试用的到时候需要改因为复选框选中的状态需要被保存 + NativeAbility::GetInstance().ChangeSlice(VIEW_FAST_TRAINING_ATTENTION); + } + return true; + } + + bool FastTrainingPresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(view); + UNUSED(event); + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingView.cpp new file mode 100644 index 000000000..7a8536be7 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingView.cpp @@ -0,0 +1,235 @@ +#include "secondaryfunction/include/FastTrainingView.h" +#include "secondaryfunction/include/FastTrainingPresenter.h" +#include "UiConfig.h" + +namespace OHOS +{ + + static FastTrainingView *g_pFastTrainingView{nullptr}; + + FastTrainingView::FastTrainingView() + { + + g_pFastTrainingView = this; + } + + FastTrainingView::~FastTrainingView() + { + DeInitView(); + g_pFastTrainingView = nullptr; + } + + FastTrainingView *FastTrainingView::GetInstance() + { + + return g_pFastTrainingView; + } + void FastTrainingView::InitImageLabelCheckbox(UIImageView *image, int image_x, int image_y, int image_w, int image_h, + UILabel *label, int label_x, int label_y, const char *labelText, + UICheckBox *checkbox, int check_x, int check_y, int check_w, int check_h, const char *checkboxID, + UICheckBox::OnChangeListener *ChangeListener, UIScrollView *scrollView) + { + image = new UIImageView(); + image->SetPosition(image_x, image_y); + image->Resize(image_w, image_h); + image->SetStyle(STYLE_BORDER_RADIUS, 50); + image->SetSrc(PNG_SETTING_BACKGROUND_IMAGE); + scrollView->Add(image); + image->SetVisible(true); + /* -------------------------------------------------------------------------- */ + label = new UILabel(); + label->SetPosition(label_x, label_y); + label->SetStyle(STYLE_TEXT_FONT, 30); + label->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + label->SetText(labelText); + label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(0); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + scrollView->Add(label); + label->SetVisible(true); + /* -------------------------------------------------------------------------- */ + checkbox = new UICheckBox(); + checkbox->SetPosition(check_x, check_y); + checkbox->Resize(check_w, check_h); + checkbox->SetViewId(checkboxID); + checkbox->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + checkbox->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + checkbox->SetImages(PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE); + ChangeListener = static_cast(FastTrainingPresenter::GetInstance()); + checkbox->SetOnChangeListener(ChangeListener); + scrollView->Add(checkbox); + checkbox->SetVisible(true); + } + + void FastTrainingView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + draglistener = static_cast(FastTrainingPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + container_->SetTouchable(true); + container_->SetDraggable(true); + } + // Add ScrollView to App + if (scrollView == nullptr) + { + scrollView = new UIScrollView(); + } + scrollView->SetPosition(0, 0); + scrollView->Resize(466, 466); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + container_->Add(scrollView); + scrollView->SetVisible(true); + // Add Label to App + if (label == nullptr) + { + label = new UILabel(); + } + label->SetPosition(173, 52); + label->Resize(200, 60); + label->SetViewId("label9"); + label->SetStyle(STYLE_TEXT_FONT, 30); + label->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + label->SetText("快速训练"); + label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(0); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView1 + scrollView->Add(label); + label->SetVisible(true); + /* -------------------------------------------------------------------------- */ + InitImageLabelCheckbox(image1, 43, 120, 380, 100, label1, 90, 153, "骑行", checkBox1, 343, 148, 50, 50, "checkBox1", ChangeListener1, scrollView); + /* -------------------------------------------------------------------------- */ + InitImageLabelCheckbox(image2, 43, 240, 380, 100, label2, 90, 273, "户外跑步", checkBox2, 343, 268, 50, 50, "checkBox2", ChangeListener2, scrollView); + /* -------------------------------------------------------------------------- */ + InitImageLabelCheckbox(image3, 43, 360, 380, 100, label3, 90, 393, "健走", checkBox3, 343, 388, 50, 50, "checkBox3", ChangeListener3, scrollView); + /* -------------------------------------------------------------------------- */ + InitImageLabelCheckbox(image4, 43, 480, 380, 100, label4, 90, 513, "登山", checkBox4, 343, 508, 50, 50, "checkBox4", ChangeListener4, scrollView); + /* -------------------------------------------------------------------------- */ + InitImageLabelCheckbox(image5, 43, 600, 380, 100, label5, 90, 633, "跳绳", checkBox5, 343, 628, 50, 50, "checkBox5", ChangeListener6, scrollView); + /* -------------------------------------------------------------------------- */ + InitImageLabelCheckbox(image6, 43, 720, 380, 100, label6, 90, 753, "乒乓球", checkBox6, 343, 748, 50, 50, "checkBox6", ChangeListener6, scrollView); + /* -------------------------------------------------------------------------- */ + FastTrainingPresenter::GetInstance()->setCheckbox(checkBox1, checkBox2, checkBox3, checkBox4, checkBox5, checkBox6); + /* -------------------------------------------------------------------------- */ + // Add ImageView to App + if (image5_ == nullptr) + { + image5_ = new UIImageView(); + } + image5_->SetPosition(183, 790); + image5_->Resize(100, 100); + scrollView->Add(image5_); + image5_->SetVisible(true); + // Add ImageView to App + if (image6_ == nullptr) + { + image6_ = new UIImageView(); + } + image6_->SetPosition(183, 19); + image6_->Resize(100, 100); + scrollView->Add(image6_); + image6_->SetVisible(true); + } + void FastTrainingView::DeInitView() + { + container_->RemoveAll(); + delete scrollView; + scrollView = nullptr; + delete image5_; + image5_ = nullptr; + delete image6_; + image6_ = nullptr; + delete image1; + image1 = nullptr; + delete image2; + image2 = nullptr; + delete image3; + image3 = nullptr; + delete image4; + image4 = nullptr; + delete image5; + image5 = nullptr; + delete image6; + image6 = nullptr; + delete label; + label = nullptr; + delete label1; + label1 = nullptr; + delete label2; + label2 = nullptr; + delete label3; + label3 = nullptr; + delete label4; + label4 = nullptr; + delete label5; + label5 = nullptr; + delete label6; + label6 = nullptr; + delete checkBox1; + checkBox1 = nullptr; + delete checkBox2; + checkBox2 = nullptr; + delete checkBox3; + checkBox3 = nullptr; + delete checkBox4; + checkBox4 = nullptr; + delete checkBox5; + checkBox5 = nullptr; + delete checkBox6; + checkBox6 = nullptr; + delete container_; + delete ChangeListener1; + ChangeListener1 = nullptr; + delete ChangeListener2; + ChangeListener2 = nullptr; + delete ChangeListener3; + ChangeListener3 = nullptr; + delete ChangeListener4; + ChangeListener4 = nullptr; + delete ChangeListener5; + ChangeListener5 = nullptr; + delete ChangeListener6; + ChangeListener6 = nullptr; + container_ = nullptr; + } + void FastTrainingView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void FastTrainingView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void FastTrainingView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void FastTrainingView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/SecondaryFunctionPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/SecondaryFunctionPresenter.cpp new file mode 100644 index 000000000..0021299ef --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/SecondaryFunctionPresenter.cpp @@ -0,0 +1,80 @@ + +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "secondaryfunction/include/SecondaryFunctionPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static SecondaryFunctionPresenter *g_pSecondaryFunctionPresenter = nullptr; + + SecondaryFunctionPresenter::SecondaryFunctionPresenter() + { + + g_pSecondaryFunctionPresenter = this; + } + + SecondaryFunctionPresenter::~SecondaryFunctionPresenter() + { + + g_pSecondaryFunctionPresenter = nullptr; + } + + SecondaryFunctionPresenter *SecondaryFunctionPresenter::GetInstance() + { + + return g_pSecondaryFunctionPresenter; + } + + void SecondaryFunctionPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void SecondaryFunctionPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void SecondaryFunctionPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void SecondaryFunctionPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool SecondaryFunctionPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + UNUSED(view); + UNUSED(event); + return true; + } + + bool SecondaryFunctionPresenter::OnClick(UIView &view, const ClickEvent &event) + { + + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), SECONDARY_FUNCTION_BUTTON1ID) == 0) + { + printf("SECONDARY_FUNCTION_BUTTON1ID\n"); + return true; + } + else if(strcmp(view.GetViewId(), SECONDARY_FUNCTION_BUTTON2ID) == 0) + { + printf("SECONDARY_FUNCTION_BUTTON2ID\n"); + NativeAbility::GetInstance().ChangeSlice(VIEW_FAST_TRAINING); + return true; + } + return false; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/SecondaryFunctionView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/SecondaryFunctionView.cpp new file mode 100644 index 000000000..e4da06d7b --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/SecondaryFunctionView.cpp @@ -0,0 +1,229 @@ +#include "secondaryfunction/include/SecondaryFunctionView.h" +#include "secondaryfunction/include/SecondaryFunctionPresenter.h" + +#include "UiConfig.h" +namespace OHOS +{ + + static SecondaryFunctionView *g_pSecondaryFunctionView{nullptr}; + + SecondaryFunctionView::SecondaryFunctionView() + { + + g_pSecondaryFunctionView = this; + } + + SecondaryFunctionView::~SecondaryFunctionView() + { + DeInitView(); + g_pSecondaryFunctionView = nullptr; + } + + SecondaryFunctionView *SecondaryFunctionView::GetInstance() + { + + return g_pSecondaryFunctionView; + } + + void SecondaryFunctionView::InitView(void) + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(172, 52); + label1_->SetStyle(STYLE_TEXT_FONT, 30); + label1_->SetStyle(STYLE_LINE_HEIGHT, 35); + label1_->SetText("辅助功能"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + container_->Add(label1_); + label1_->SetVisible(true); + + // Add Button to App + if (SECONDARY_FUNCTION_BUTTON1 == nullptr) + { + SECONDARY_FUNCTION_BUTTON1 = new UIButton(); + } + SECONDARY_FUNCTION_BUTTON1->SetPosition(43, 120); + SECONDARY_FUNCTION_BUTTON1->Resize(380, 100); + SECONDARY_FUNCTION_BUTTON1->SetViewId(SECONDARY_FUNCTION_BUTTON1ID); + SECONDARY_FUNCTION_BUTTON1->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + SECONDARY_FUNCTION_BUTTON1->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + SECONDARY_FUNCTION_BUTTON1->SetStyle(STYLE_BORDER_OPA, 0x00); + SECONDARY_FUNCTION_BUTTON1->SetStyle(STYLE_BORDER_COLOR, 0xffffffff); + SECONDARY_FUNCTION_BUTTON1->SetImageSrc(PNG_SETTING_BACKGROUND_IMAGE, PNG_SETTING_BACKGROUND_IMAGE); + SECONDARY_FUNCTION_BUTTON1->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xfffafafa, UIButton::PRESSED); + SECONDARY_FUNCTION_BUTTON1->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + SECONDARY_FUNCTION_BUTTON1->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + SECONDARY_FUNCTION_BUTTON1->SetStyleForState(STYLE_BORDER_OPA, 0x00, UIButton::PRESSED); + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(SecondaryFunctionPresenter::GetInstance()); + SECONDARY_FUNCTION_BUTTON1->SetOnClickListener(button1Click); + // Add to rootView + container_->Add(SECONDARY_FUNCTION_BUTTON1); + SECONDARY_FUNCTION_BUTTON1->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(90, 153); + label2_->SetStyle(STYLE_TEXT_FONT, 30); + label2_->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + label2_->SetText("辅助按钮"); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to rootView + container_->Add(label2_); + label2_->SetVisible(true); + + // Add ImageView to App + if (image3_ == nullptr) + { + image3_ = new UIImageView(); + } + image3_->SetPosition(369, 157); + image3_->SetSrc(PNG_SETTING_NEXT_IMAGE); + // Add to rootView + container_->Add(image3_); + image3_->SetVisible(true); + + // Add Button to App + if (SECONDARY_FUNCTION_BUTTON2 == nullptr) + { + SECONDARY_FUNCTION_BUTTON2 = new UIButton(); + } + SECONDARY_FUNCTION_BUTTON2->SetPosition(43, 240); + SECONDARY_FUNCTION_BUTTON2->Resize(380, 100); + SECONDARY_FUNCTION_BUTTON2->SetViewId(SECONDARY_FUNCTION_BUTTON2ID); + SECONDARY_FUNCTION_BUTTON2->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + SECONDARY_FUNCTION_BUTTON2->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + SECONDARY_FUNCTION_BUTTON2->SetStyle(STYLE_BORDER_OPA, 0x00); + SECONDARY_FUNCTION_BUTTON2->SetStyle(STYLE_BORDER_COLOR, 0xffffffff); + SECONDARY_FUNCTION_BUTTON2->SetImageSrc(PNG_SETTING_BACKGROUND_IMAGE, PNG_SETTING_BACKGROUND_IMAGE); + SECONDARY_FUNCTION_BUTTON2->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + SECONDARY_FUNCTION_BUTTON2->SetStyleForState(STYLE_BORDER_OPA, 0x00, UIButton::PRESSED); + // Add the CallBack about events + UIView::OnClickListener *button2Click = static_cast(SecondaryFunctionPresenter::GetInstance()); + SECONDARY_FUNCTION_BUTTON2->SetOnClickListener(button2Click); + // Add to rootView + container_->Add(SECONDARY_FUNCTION_BUTTON2); + SECONDARY_FUNCTION_BUTTON2->SetVisible(true); + // Add Label to App + if (label4_ == nullptr) + { + label4_ = new UILabel(); + } + label4_->SetPosition(90, 273); + label4_->SetStyle(STYLE_TEXT_FONT, 30); + label4_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label4_->SetText("快速训练"); + label4_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label4_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label4_->SetRollSpeed(0); + label4_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to rootView + container_->Add(label4_); + label4_->SetVisible(true); + + // Add ImageView to App + if (image4_ == nullptr) + { + image4_ = new UIImageView(); + } + image4_->SetPosition(369, 277); + image4_->SetSrc(PNG_SETTING_NEXT_IMAGE); + // Add to rootView + container_->Add(image4_); + image4_->SetVisible(true); + } + void SecondaryFunctionView::DeInitView(void) + { + if (container_ != nullptr) + { + container_->RemoveAll(); + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (SECONDARY_FUNCTION_BUTTON1 != nullptr) + { + delete SECONDARY_FUNCTION_BUTTON1; + SECONDARY_FUNCTION_BUTTON1 = nullptr; + } + if (image3_ != nullptr) + { + delete image3_; + image3_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (SECONDARY_FUNCTION_BUTTON2 != nullptr) + { + delete SECONDARY_FUNCTION_BUTTON2; + SECONDARY_FUNCTION_BUTTON2 = nullptr; + } + if (image4_ != nullptr) + { + delete image4_; + image4_ = nullptr; + } + if (label4_ != nullptr) + { + delete label4_; + label4_ = nullptr; + } + delete container_; + container_ = nullptr; + } + + void SecondaryFunctionView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void SecondaryFunctionView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void SecondaryFunctionView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void SecondaryFunctionView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } + +} \ No newline at end of file diff --git a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_api.a b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_api.a index bb17203a5..1ee34b27c 100644 Binary files a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_api.a and b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_api.a differ diff --git a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_core.a b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_core.a index 6271a1b97..60fa59edd 100644 Binary files a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_core.a and b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_core.a differ diff --git a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_drv.a b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_drv.a index eccaa7e90..41c0be165 100644 Binary files a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_drv.a and b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_drv.a differ diff --git a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_sample.a b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_sample.a index 9a03cc4c2..595e79d33 100644 Binary files a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_sample.a and b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_sample.a differ diff --git a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_vendor.a b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_vendor.a index b385fef2d..3ac147c73 100644 Binary files a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_vendor.a and b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_vendor.a differ diff --git a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_brandy_sample.a b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_brandy_sample.a index 8d6c0bd44..8e80899c2 100644 Binary files a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_brandy_sample.a and b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_brandy_sample.a differ diff --git a/code/sdk/interim_binary/brandy/libs/gpu/evb_standard/libgpu.a b/code/sdk/interim_binary/brandy/libs/gpu/evb_standard/libgpu.a index c1a00dfa2..04594f39d 100644 Binary files a/code/sdk/interim_binary/brandy/libs/gpu/evb_standard/libgpu.a and b/code/sdk/interim_binary/brandy/libs/gpu/evb_standard/libgpu.a differ diff --git a/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_audio_captuer.a b/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_audio_captuer.a index 11e8cbc5a..90fa93187 100644 Binary files a/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_audio_captuer.a and b/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_audio_captuer.a differ diff --git a/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_player.a b/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_player.a index 4f1cd2fd3..0b56bf5e2 100644 Binary files a/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_player.a and b/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_player.a differ diff --git a/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/application.bin b/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/application.bin index e5a9f00e0..3adbae73e 100644 Binary files a/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/application.bin and b/code/sdk/tools/pkg/fwpkg/brandy/tempFiles/application.bin differ