From: 罗正 <1732036298@qq.com> Date: Mon, 29 Apr 2024 06:48:54 +0000 (+0000) Subject: Merge #108 into xts_origin from refs/changes/108/head X-Git-Tag: release_V1.2.70_20241020_135402~1025^2~48^2~1^2~1 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=8c0c2d792b54b455c8fb6141f59b02b54f5aa202;p=mirrors%2FFD230.git Merge #108 into xts_origin from refs/changes/108/head Code review from 罗正 * refs/changes/108/head: (8 commits squashed) - 通过设置拦截函数优化连接状态视图的退出逻辑 - Merge branch 'xts_origin' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into xts_origin - Merge branch 'xts_origin' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into xts_origin - 修复下拉时间不更新问题 - Merge branch 'xts_origin' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into xts_origin - 重构电话视图,解决主界面内存泄漏问题 - Merge branch 'xts_origin' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into xts_origin - 添加拨号方式Slice Signed-off-by: 罗正 <1732036298@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/108 --- diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 045d8d834..dbbe46a20 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -595,6 +595,13 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneRingPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/phoneaddressmodel.cpp + #电话 + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/MainPhonePresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/MainPhoneView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/DialingMethodPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/DialingMethodView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/TelephonyInitInterface.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testabout.cpp diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h index d7ec73eea..46c023433 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h @@ -32,35 +32,35 @@ typedef enum : uint16_t VIEW_APPLIST, // App应用 VIEW_DIALUPDATE, // 更新表盘ID ,请不要在前面增加任何Slice /* -------------------------------------------------------------------------- */ - VIEW_MAIN_ALARM, // 闹钟 - VIEW_ALARM_POP_UP, // 闹铃界面 - VIEW_BLUETOOTH_EARPHONE, // 连接蓝牙耳机界面 - VIEW_CLASSIC_BLUETOOTH, // 经典蓝牙 - VIEW_BLUETOOTH_SERVICE_OPTIONS,// 蓝牙服务选项 - VIEW_CALLER_LOG, // 通话记录界面 - VIEW_INCOMING_CALL, // 来电界面 - VIEW_COMPASS, // 指南针界面 - VIEW_CONNECT_PHONE, // 连接手机界面 - VIEW_INDOORWALK, // 室内步行 - VIEW_SHUTDOWN_OR_REBOOT, // 关机或重启界面 - VIEW_WEATHER, // 天气 - VIEW_SYSTEM, // 系统 - VIEW_SOUND_VIBRATION, // 声音与震动 - VIEW_SYSTEM_VOLUME, // 系统音量 - VIEW_CALL_VOLUME, // 通话音量 - VIEW_DISPLAY_BRIGHTNESS, // 屏幕与亮度 - VIEW_SECONDARY_FUNCTION, // 辅助功能 - VIEW_FAST_TRAINING, // 快速训练 - VIEW_FAST_TRAINING_ATTENTION, // 快速训练项目选择超出提示 - VIEW_FIND_PHONE, // 查找手机 - VIEW_LANGUAGE_SWITCH, // 语言切换 - VIEW_MAIN_STOPWATCH, // 秒表 - VIEW_MAIN_COUNTDOWN, // 计时器 - VIEW_DNOTDISTURB, // 勿扰模式 - VIEW_FLASHLIGHT, // 手电筒 - VIEW_BRIGHTNESSLEVEL, // 亮度调节 - VIEW_NETWORKANDCALL, // 网络与通话 - VIEW_MOTION_RECOGNITION, // 运动识别 + VIEW_MAIN_ALARM, // 闹钟 + VIEW_ALARM_POP_UP, // 闹铃界面 + VIEW_BLUETOOTH_EARPHONE, // 连接蓝牙耳机界面 + VIEW_CLASSIC_BLUETOOTH, // 经典蓝牙 + VIEW_BLUETOOTH_SERVICE_OPTIONS, // 蓝牙服务选项 + VIEW_CALLER_LOG, // 通话记录界面 + VIEW_INCOMING_CALL, // 来电界面 + VIEW_COMPASS, // 指南针界面 + VIEW_CONNECT_PHONE, // 连接手机界面 + VIEW_INDOORWALK, // 室内步行 + VIEW_SHUTDOWN_OR_REBOOT, // 关机或重启界面 + VIEW_WEATHER, // 天气 + VIEW_SYSTEM, // 系统 + VIEW_SOUND_VIBRATION, // 声音与震动 + VIEW_SYSTEM_VOLUME, // 系统音量 + VIEW_CALL_VOLUME, // 通话音量 + VIEW_DISPLAY_BRIGHTNESS, // 屏幕与亮度 + VIEW_SECONDARY_FUNCTION, // 辅助功能 + VIEW_FAST_TRAINING, // 快速训练 + VIEW_FAST_TRAINING_ATTENTION, // 快速训练项目选择超出提示 + VIEW_FIND_PHONE, // 查找手机 + VIEW_LANGUAGE_SWITCH, // 语言切换 + VIEW_MAIN_STOPWATCH, // 秒表 + VIEW_MAIN_COUNTDOWN, // 计时器 + VIEW_DNOTDISTURB, // 勿扰模式 + VIEW_FLASHLIGHT, // 手电筒 + VIEW_BRIGHTNESSLEVEL, // 亮度调节 + VIEW_NETWORKANDCALL, // 网络与通话 + VIEW_MOTION_RECOGNITION, // 运动识别 /* ----------------------------------- 录音 ----------------------------------- */ VIEW_RECORD, /* ---------------------------------- 界面 ---------------------------------- */ @@ -73,12 +73,12 @@ typedef enum : uint16_t VIEW_SAVEELE, // 省电模式 VIEW_SAVEBAT, // 省电模式界面 /* ----------------------------------- 训练 ----------------------------------- */ - VIEW_TRAINING, // 训练 - VIEW_TRAININGNOMAL, // 正常训练开始界面(除骑行,健走,跑步外) - VIEW_TRAININGSET, // 训练目标(时长,卡路里) - VIEW_TRAININGCRAD, // 训练控制卡片 - VIEW_TRAININGENDDATA, // 训练结束详细数据 - VIEW_TRAINING_RECORD, // 训练记录 + VIEW_TRAINING, // 训练 + VIEW_TRAININGNOMAL, // 正常训练开始界面(除骑行,健走,跑步外) + VIEW_TRAININGSET, // 训练目标(时长,卡路里) + VIEW_TRAININGCRAD, // 训练控制卡片 + VIEW_TRAININGENDDATA, // 训练结束详细数据 + VIEW_TRAINING_RECORD, // 训练记录 /* ---------------------------------- 训练列表 ---------------------------------- */ VIEW_TRAININGMORE, // 更多训练 VIEW_TRAININGLIMIT, // 极限运动列表 @@ -102,15 +102,18 @@ typedef enum : uint16_t VIEW_PHONECALLUP, // 通话界面 VIEW_PHONEDIR, // 电话簿 + VIEW_MAIN_PHONE, // 主电话Slice + VIEW_DIALING_METHOD, // 拨号方式 + VIEW_TEST, // 测试 /* -------------------------------------------------------------------------- */ #ifdef SUPPORT_ALIPAY_SEC VIEW_MAIN_ALIPAY, #endif - VIEW_SET_DESKTOP, // 主题样式//显示方式 - VIEW_SET_CARD, // 卡片管理 - VIEW_ADD_CARD, // 添加卡片 - VIEW_SET_DIAL, // 切换表盘 + VIEW_SET_DESKTOP, // 主题样式//显示方式 + VIEW_SET_CARD, // 卡片管理 + VIEW_ADD_CARD, // 添加卡片 + VIEW_SET_DIAL, // 切换表盘 VIEW_MAX_INTER_APP, // 在此之前添加native应用ID. VIEW_EXTERN_APP = 0xFFFE, // 三方应用 diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h index 2fbaa41e3..e9657b937 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h @@ -95,6 +95,11 @@ namespace OHOS void InitPhoneCallupSlice(void); void InitPhoneRingSlice(void); + /* -------------------------------------------------------------------------- */ + void InitMainPhoneSlice(void); + void InitDialingMethodSlice(void); + /* -------------------------------------------------------------------------- */ + void InittestSlice(void); private: diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index 2c5672532..8ce45ddb0 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -132,6 +132,13 @@ #include "phone/include/PhoneRingView.h" #include "phone/include/PhoneRingPresenter.h" +/* -------------------------------------------------------------------------- */ +#include "phone/include/MainPhoneView.h" +#include "phone/include/MainPhonePresenter.h" +#include "phone/include/DialingMethodView.h" +#include "phone/include/DialingMethodPresenter.h" +/* -------------------------------------------------------------------------- */ + #include "producttest/include/testPresenter.h" #include "producttest/include/testView.h" @@ -244,16 +251,16 @@ namespace OHOS {VIEW_CONNECT_PHONE, &NativeLauncher::InitConnectPhoneSlice}, {VIEW_INDOORWALK, &NativeLauncher::InitIndoorWalkSlice}, {VIEW_SHUTDOWN_OR_REBOOT, &NativeLauncher::InitRebootSlice}, - {VIEW_WEATHER, &NativeLauncher::InitWeatherSlice}, // 天气 - {VIEW_SYSTEM, &NativeLauncher::InitSystemSlice}, // 系统实例化地址 - {VIEW_SOUND_VIBRATION, &NativeLauncher::InitSoundAndVibrationSlice}, // 声音与震动实例化地址 - {VIEW_SYSTEM_VOLUME, &NativeLauncher::InitSystemVolumeSlice}, // 系统音量 - {VIEW_CALL_VOLUME, &NativeLauncher::InitCallVolumeSlice}, // 系统音量 - {VIEW_CLASSIC_BLUETOOTH, &NativeLauncher::InitClassicBluetoothSlice}, // 经典蓝牙slice - {VIEW_BLUETOOTH_SERVICE_OPTIONS, &NativeLauncher::InitBluetoothServiceOptionsSlice}, // 蓝牙服务slice - {VIEW_DISPLAY_BRIGHTNESS, &NativeLauncher::InitDisplayBrightnessSlice}, // 显示与亮度的实例化地址 - {VIEW_NETWORKANDCALL, &NativeLauncher::InitNetworkAndCallSlice}, // 网络与通话 - {VIEW_MOTION_RECOGNITION, &NativeLauncher::InitMotionRecognitionSlice}, // 网络与通话 + {VIEW_WEATHER, &NativeLauncher::InitWeatherSlice}, // 天气 + {VIEW_SYSTEM, &NativeLauncher::InitSystemSlice}, // 系统实例化地址 + {VIEW_SOUND_VIBRATION, &NativeLauncher::InitSoundAndVibrationSlice}, // 声音与震动实例化地址 + {VIEW_SYSTEM_VOLUME, &NativeLauncher::InitSystemVolumeSlice}, // 系统音量 + {VIEW_CALL_VOLUME, &NativeLauncher::InitCallVolumeSlice}, // 系统音量 + {VIEW_CLASSIC_BLUETOOTH, &NativeLauncher::InitClassicBluetoothSlice}, // 经典蓝牙slice + {VIEW_BLUETOOTH_SERVICE_OPTIONS, &NativeLauncher::InitBluetoothServiceOptionsSlice}, // 蓝牙服务slice + {VIEW_DISPLAY_BRIGHTNESS, &NativeLauncher::InitDisplayBrightnessSlice}, // 显示与亮度的实例化地址 + {VIEW_NETWORKANDCALL, &NativeLauncher::InitNetworkAndCallSlice}, // 网络与通话 + {VIEW_MOTION_RECOGNITION, &NativeLauncher::InitMotionRecognitionSlice}, // 网络与通话 // {VIEW_SECONDARY_FUNCTION, &NativeLauncher::InitSecondaryFunction}, // {VIEW_FAST_TRAINING, &NativeLauncher::InitFastTrainingSlice}, @@ -281,6 +288,11 @@ namespace OHOS {VIEW_PHONECALLUP, &NativeLauncher::InitPhoneCallupSlice}, {VIEW_PHONERING, &NativeLauncher::InitPhoneRingSlice}, + /* -------------------------------------------------------------------------- */ + {VIEW_MAIN_PHONE, &NativeLauncher::InitMainPhoneSlice}, + {VIEW_DIALING_METHOD, &NativeLauncher::InitDialingMethodSlice}, + /* -------------------------------------------------------------------------- */ + {VIEW_TEST, &NativeLauncher::InittestSlice}, /* ---------------------------------- 省电模式 ---------------------------------- */ @@ -759,7 +771,7 @@ namespace OHOS // } // NativeAbility::GetInstance().AddSliceProxy(VIEW_DIALUPDATE, dialupdate); // } - //传统蓝牙 + // 传统蓝牙 void NativeLauncher::InitClassicBluetoothSlice(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitClassicBluetoothSlice"); @@ -867,6 +879,33 @@ namespace OHOS NativeAbility::GetInstance().AddSliceProxy(VIEW_PHONERING, phoneringview); } + /* ----------------------------------- 电话 ----------------------------------- */ + void NativeLauncher::InitMainPhoneSlice(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitMainPhoneSlice"); + SliceProxy *mainphoneview = new AbilitySliceProxy; + if (mainphoneview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainphoneview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_MAIN_PHONE, mainphoneview); + } + + //拨号方式 + void NativeLauncher::InitDialingMethodSlice(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitMainPhoneSlice"); + SliceProxy *dialingmethodview = new AbilitySliceProxy; + if (dialingmethodview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dialingmethodview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_DIALING_METHOD, dialingmethodview); + } + /* -------------------------------------------------------------------------- */ + void NativeLauncher::InittestSlice(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitestSlice"); diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp index 4ce02bcbc..9af296267 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp @@ -33,7 +33,7 @@ namespace OHOS {VIEW_TRAINING_RECORD, PNG_APPLIST_TRAINING_RECORD_IMAGE, PNG_APPLIST_TRAINING_RECORD_IMAGE, "训练记录", nullptr}, {VIEW_RECORD, PNG_APPLIST_RECORD_IMAGE, PNG_APPLIST_RECORD_IMAGE, "录音", nullptr}, {VIEW_CALLER_LOG, PNG_APPLIST_CALLLOG_IMAGE, PNG_APPLIST_CALLLOG_IMAGE, "通话记录", nullptr}, - {VIEW_PHONE, PNG_APPLIST_CALLER_IMAGE, PNG_APPLIST_CALLER_IMAGE, "电话", nullptr}, + {VIEW_MAIN_PHONE, PNG_APPLIST_CALLER_IMAGE, PNG_APPLIST_CALLER_IMAGE, "电话", nullptr}, {VIEW_MAIN_STOPWATCH, PNG_APPLIST_STOPWATCH_IMAGE, PNG_APPLIST_STOPWATCH_IMAGE, "秒表", nullptr}, {VIEW_MAIN_COUNTDOWN, PNG_APPLIST_COUNTDOWN_IMAGE, PNG_APPLIST_COUNTDOWN_IMAGE, "计时器", nullptr}, {VIEW_FIND_PHONE, PNG_APPLIST_FINDPHONE_IMAGE, PNG_APPLIST_FINDPHONE_IMAGE, "查找手机", nullptr}, diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp index b2735f5a5..499a77801 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp @@ -104,6 +104,7 @@ namespace OHOS } if (disturbIcon != nullptr) { + mainClockView->Remove(disturbIcon); delete disturbIcon; disturbIcon = nullptr; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp index 62ec2c94c..a15efe7b8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp @@ -111,6 +111,7 @@ namespace OHOS { if (group[DROPDOWNVIEW] != nullptr) { + RemoveAll(); group[DROPDOWNVIEW]->RemoveAll(); group[DROPDOWNVIEW]->ClearBackgroundBlur(); @@ -119,40 +120,50 @@ namespace OHOS delete dropIconBackground[i]; dropIconBackground[i] = nullptr; } - + delete dropSetting; dropSetting = nullptr; - + delete dropLighting; dropLighting = nullptr; - + delete dropDnotDisturb; dropDnotDisturb = nullptr; - + delete dropLine; dropLine = nullptr; - + delete dropSavePower; dropSavePower = nullptr; - + delete drofindPhone; drofindPhone = nullptr; - + delete showTimeLabel; showTimeLabel = nullptr; - + delete showDateLabel; showDateLabel = nullptr; - + delete showWeekLabel; showWeekLabel = nullptr; /* -------------------------------------------------------------------------- */ ClearAllSingalComponentsView(); ClearAllConnectedStatusComponentsView(); /* -------------------------------------------------------------------------- */ - delete progress; - progress = nullptr; - + if (batteryimage != nullptr) + { + delete batteryimage; + batteryimage = nullptr; + } + + if (progress != nullptr) + { + delete progress; + progress = nullptr; + } + + if (progresscallback_ != nullptr) { delete progresscallback_; @@ -166,8 +177,6 @@ namespace OHOS progressanimator_ = nullptr; } - Remove(group[DROPDOWNVIEW]); - delete group[DROPDOWNVIEW]; group[DROPDOWNVIEW] = nullptr; } @@ -176,6 +185,7 @@ namespace OHOS { delete connectedStatusView; connectedStatusView = nullptr; + group[CONNECTEDSTATUSVIEW] = nullptr; } } @@ -327,10 +337,12 @@ namespace OHOS /// @brief 连接状态 /// @param void void PullUpDownView::InitTimeDateWeekLabelAndConnectedStatusImage(void) - { + { + connectedStatusBackgroundButton = new UIButton(); if (connectedStatusBackgroundButton == nullptr) { - connectedStatusBackgroundButton = new UIButton(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "connectedStatusBackgroundButton new fail"); + return; } connectedStatusBackgroundButton->SetPosition(113, 348, 240, 64); connectedStatusBackgroundButton->SetViewId(CONNECTEDSTATUSBACKGROUNDBUTTON); diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/DialingMethodPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/DialingMethodPresenter.h new file mode 100644 index 000000000..fc64f7dd4 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/DialingMethodPresenter.h @@ -0,0 +1,42 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-28 18:22:08 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-28 18:33:29 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/phone/include/DialingMethodPresenter.h + */ + +#ifndef DIALING_METHOD_PRESENTER_H +#define DIALING_METHOD_PRESENTER_H + +#include "Presenter.h" +#include "View.h" + +namespace OHOS +{ + class DialingMethodView; + class DialingMethodPresenter : public Presenter, + public UIView::OnClickListener, + public RootView::OnKeyActListener, + public UIView::OnDragListener + { + public: + DialingMethodPresenter(); + virtual ~DialingMethodPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static DialingMethodPresenter *GetInstance(); + + private: + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnDragEnd(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/DialingMethodView.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/DialingMethodView.h new file mode 100644 index 000000000..65a99f255 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/DialingMethodView.h @@ -0,0 +1,46 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-28 18:21:10 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-29 09:25:43 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/phone/include/DialingMethodView.h + */ + +#ifndef DIALING_METHOD_VIEW_H +#define DIALING_METHOD_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_button.h" +#include "components/ui_label_ext.h" + +namespace OHOS +{ + class DialingMethodPresenter; + class DialingMethodView : public View + { + + public: + DialingMethodView(); + virtual ~DialingMethodView(); + static DialingMethodView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void DialingMethodViewInit(void); + void ClearAll(void); + UIScrollView *DialingMethodScrollView{nullptr}; + UILabelExt *DialingMethodTitleLabel{nullptr}; + UIButton *UsingWatchSimButton{nullptr}; // 手表SIM卡拨号 + UIButton *UsingPhoneButton = nullptr; // 通过手机拨号 + UILabelExt *UsingWatchSimLabel{nullptr}; + UILabelExt *UsingPhoneLabel{nullptr}; + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhonePresenter.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhonePresenter.h new file mode 100644 index 000000000..72237a1a0 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhonePresenter.h @@ -0,0 +1,42 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-28 10:12:12 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-28 10:12:46 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhonePresenter.h + */ + +#ifndef MAIN_PHONE_PRESENTER_H +#define MAIN_PHONE_PRESENTER_H + +#include "Presenter.h" +#include "View.h" + +namespace OHOS +{ + class MainPhoneView; + class MainPhonePresenter : public Presenter, + public UIView::OnClickListener, + public RootView::OnKeyActListener, + public UIView::OnDragListener + { + public: + MainPhonePresenter(); + virtual ~MainPhonePresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static MainPhonePresenter *GetInstance(); + + private: + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnDragEnd(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhoneView.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhoneView.h new file mode 100644 index 000000000..67be2c221 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhoneView.h @@ -0,0 +1,49 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-28 10:09:39 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-28 15:40:14 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/phone/include/MainPhoneView.h + */ + +#ifndef MAIN_PHONE_VIEW_H +#define MAIN_PHONE_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_scroll_view.h" +#include "components/ui_button.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" +#include "phone/include/TelephonyInitInterface.h" + +namespace OHOS +{ + + class MainPhonePresenter; + class MainPhoneView : public View + { + + public: + MainPhoneView(); + virtual ~MainPhoneView(); + static MainPhoneView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void MainPhoneViewInit(void); + void ClearAll(void); + UIScrollView *MainPhoneViewScrollView{nullptr}; + UILabelExt *MainPhoneViewTitleLabel{nullptr}; // 标题 + UIButton *DialingMethodButton{nullptr}; // 拨号方式 + UIButton *FrequentlyContactedButton{nullptr}; // 常用联系人 + UILabelExt *RecentCallLabel{nullptr}; //"最近通话" + UIImageView *TelephoneLineImageView{nullptr}; // 线 + UILabelExt *NoCallsLabel{nullptr}; // 暂无通话 + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h new file mode 100644 index 000000000..76fadc395 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h @@ -0,0 +1,98 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-28 09:58:04 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-29 09:24:21 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h + */ +#ifndef TELEPHONY_INIT_INTERFACE_H +#define TELEPHONY_INIT_INTERFACE_H +/*与电话通信相关的初始化接口*/ + +#include "components/ui_scroll_view.h" +#include "components/ui_label_ext.h" +#include "components/ui_button.h" +#include "components/ui_image_view.h" +#include "iostream" +#include "UiConfig.h" +namespace OHOS +{ + + // 视图id + static constexpr const char *MAINPHONE_VIEWID = "MainPhoneView"; + static constexpr const char *DIALINGMETHODVIEW_VIEWID = "DialingMethodView"; + static constexpr const char *DIALINGMETHODBUTTON_VIEWID = "DialingMethodButton"; // 通话方式按钮视图id + static constexpr const char *FREQUENTLYCONTACTEDBUTTON_VIEWID = "FrequentlyContactedButton"; // 常用联系人按钮视图id + static constexpr const char *USINGWATCHSIMBUTTON_VIEWID = "UsingWatchSimButton"; // 手表SIM卡拨号按钮视图id + static constexpr const char *USINGPHONEBUTTON_VIEWID = "UsingPhoneButton"; // 通过手机拨号按钮视图id + + // 图片 + static constexpr const char *PNG_DIALINGMETHODBUTTON_IMAGE = "/user/res/Phone/Telephone/DialingMethod.bin"; // 通话方式按钮icon图片 + static constexpr const char *PNG_FREQUENTLYCONTACTEDBUTTON_IMAGE = "/user/res/Phone/Telephone/FrequentlyContacted.bin"; // 常用联系人按钮icon图片 + static constexpr const char *PNG_TELEPHONELINE_IMAGE = "/user/res/Phone/Telephone/TelephoneLine.bin"; // 线 + + class TelephonyInitInterface + { + public: + static bool X_DRAG_FLAG; // 水平拖拽标志 + + typedef struct + { + int x; + int y; + int width; + int height; + const char *viewId; + int scrollBlankSize; + int reboundSize; + int direction; + } ScrollViewParams; + + typedef struct + { + int16_t x; + int16_t y; + int16_t width; + int16_t height; + int16_t fontSize; // 字体大小 + int16_t lineHeigh; // 行高 + const char *text; // 文本 + uint8_t lineBreakMode; // 断行模式。 + } LabelParams; + + typedef struct + { + int16_t x; + int16_t y; + int16_t width; + int16_t height; + const char *viewId; + int64_t backgroundColor; + int64_t pressedBackgroundColor; + } ButtonParams; + + typedef struct + { + int16_t x; + int16_t y; + int16_t width; + int16_t height; + const char *viewId; + const char *imgsrc; + } ImageParams; + + static UIScrollView *ScrollViewInit(const ScrollViewParams ¶ms); + static UILabelExt *LabelViewInit(const LabelParams ¶ms); + static UIButton *ButtonViewInit(const ButtonParams ¶ms); + static UIImageView *ImageViewInit(const ImageParams ¶ms); + + public: + TelephonyInitInterface(); + ~TelephonyInitInterface(); + + private: + }; + +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodPresenter.cpp new file mode 100644 index 000000000..6d44a9a6d --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodPresenter.cpp @@ -0,0 +1,109 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-28 14:17:43 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-29 10:01:43 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/language/src/DialingMethodPresenter.cpp + */ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "phone/include/DialingMethodView.h" +#include "phone/include/DialingMethodPresenter.h" +#include "common/key_code.h" +#include +#include "phone/include/TelephonyInitInterface.h" +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static DialingMethodPresenter *g_pDialingMethodPresenter = nullptr; + + DialingMethodPresenter::DialingMethodPresenter() + { + g_pDialingMethodPresenter = this; + } + + DialingMethodPresenter::~DialingMethodPresenter() + { + g_pDialingMethodPresenter = nullptr; + } + + DialingMethodPresenter *DialingMethodPresenter::GetInstance() + { + return g_pDialingMethodPresenter; + } + + void DialingMethodPresenter::OnStart() + { + Presenter::OnStart(); + } + + void DialingMethodPresenter::OnPause(void) + { + Presenter::OnPause(); + } + + void DialingMethodPresenter::OnResume(void) + { + Presenter::OnResume(); + } + + void DialingMethodPresenter::OnStop(void) + { + Presenter::OnStop(); + } + + bool DialingMethodPresenter::OnClick(UIView &view, const ClickEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialingMethodPresenter::OnClick"); + std::string curViewId = view.GetViewId(); + + if (curViewId == USINGWATCHSIMBUTTON_VIEWID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick",curViewId.c_str()); + } + else if (curViewId == USINGPHONEBUTTON_VIEWID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick",curViewId.c_str()); + } + return true; + } + + bool DialingMethodPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialingMethodPresenter::OnDrag"); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + TelephonyInitInterface::X_DRAG_FLAG = true; + } + return true; + } + + bool DialingMethodPresenter::OnDragEnd(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialingMethodPresenter::OnDragEnd"); + if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && TelephonyInitInterface::X_DRAG_FLAG) // 拖动结束判断是否是右滑 + { + NativeAbility::GetInstance().Back(); + TelephonyInitInterface::X_DRAG_FLAG = false; + } + + return true; + } + + bool DialingMethodPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialingMethodPresenter::OnKeyAct"); + unsigned short keyID = event.GetKeyId(); + unsigned short keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) + { + NativeAbility::GetInstance().Back(); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodView.cpp new file mode 100644 index 000000000..f2695f7d5 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodView.cpp @@ -0,0 +1,225 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-23 17:28:52 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-29 10:00:25 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/src/DialingMethodView.cpp + */ +#include "phone/include/DialingMethodView.h" +#include "phone/include/DialingMethodPresenter.h" +#include "wearable_log.h" +#include "phone/include/TelephonyInitInterface.h" +namespace OHOS +{ + + static DialingMethodView *g_pDialingMethodView{nullptr}; + + DialingMethodView::DialingMethodView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingMethodView::DialingMethodView"); + g_pDialingMethodView = this; + } + + DialingMethodView::~DialingMethodView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingMethodView::~DialingMethodView"); + ClearAll(); + g_pDialingMethodView = nullptr; + } + + DialingMethodView *DialingMethodView::GetInstance() + { + + return g_pDialingMethodView; + } + + void DialingMethodView::ClearAll(void) + { + if (DialingMethodScrollView != nullptr) + { + DialingMethodScrollView->RemoveAll(); + + delete DialingMethodTitleLabel; + DialingMethodTitleLabel = nullptr; + + delete UsingWatchSimButton; + UsingWatchSimButton = nullptr; + + delete UsingPhoneButton; + UsingPhoneButton = nullptr; + + delete UsingWatchSimLabel; + UsingWatchSimLabel = nullptr; + + delete UsingPhoneLabel; + UsingPhoneLabel = nullptr; + + delete DialingMethodScrollView; + DialingMethodScrollView = nullptr; + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingMethodView::ClearAll success!!"); + } + + void DialingMethodView::DialingMethodViewInit(void) + { + if (DialingMethodScrollView == nullptr) + { + /* ------------------------- DialingMethodScrollView ------------------------ */ + TelephonyInitInterface::ScrollViewParams scrollviewParam = { + .x = 0, + .y = 0, + .width = Screen::GetInstance().GetWidth(), + .height = Screen::GetInstance().GetHeight(), + .viewId = DIALINGMETHODVIEW_VIEWID, + .scrollBlankSize = 50, + .reboundSize = 35, + .direction = 1, + }; + DialingMethodScrollView = TelephonyInitInterface::ScrollViewInit(scrollviewParam); + if (DialingMethodScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingMethodView::DialingMethodScrollView new fail!"); + return; + } + UIView::OnDragListener *dragListener = static_cast(DialingMethodPresenter::GetInstance()); + if (dragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dragListener new fail!"); + return; + } + DialingMethodScrollView->SetOnDragListener(dragListener); + /* ------------------------- DialingMethodTitleLabel ------------------------ */ + TelephonyInitInterface::LabelParams labelParam = { + .x = 83, + .y = 53, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "拨号方式", + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + DialingMethodTitleLabel = TelephonyInitInterface::LabelViewInit(labelParam); + if (DialingMethodTitleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::DialingMethodTitleLabel new fail!"); + return; + } + DialingMethodTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + /* --------------------------- UsingWatchSimButton -------------------------- */ + TelephonyInitInterface::ButtonParams buttonParam = { + .x = 43, + .y = 120, + .width = 380, + .height = 100, + .viewId = USINGWATCHSIMBUTTON_VIEWID, + .backgroundColor = 0xff191919, + .pressedBackgroundColor = 0xff1996ff, + }; + UsingWatchSimButton = TelephonyInitInterface::ButtonViewInit(buttonParam); + if (UsingWatchSimButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::UsingWatchSimButton new fail!"); + return; + } + /* ------------------------ UsingPhoneButton ----------------------- */ + buttonParam = { + .x = 43, + .y = 240, + .width = 380, + .height = 100, + .viewId = USINGPHONEBUTTON_VIEWID, + .backgroundColor = 0xff191919, + .pressedBackgroundColor = 0xff1996ff, + }; + UsingPhoneButton = TelephonyInitInterface::ButtonViewInit(buttonParam); + if (UsingPhoneButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::UsingPhoneButton new fail!"); + return; + } + /* --------------------------- ButtonOnclickListen -------------------------- */ + UIView::OnClickListener *ButtonOnclickListen = static_cast(DialingMethodPresenter::GetInstance()); + if (ButtonOnclickListen == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ButtonOnclickListen new fail!"); + return; + } + UsingWatchSimButton->SetOnClickListener(ButtonOnclickListen); + UsingPhoneButton->SetOnClickListener(ButtonOnclickListen); + /* --------------------------- UsingWatchSimLabel --------------------------- */ + labelParam = { + .x = 83, + .y = 153, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "通过手表SIM卡拨号", + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + UsingWatchSimLabel = TelephonyInitInterface::LabelViewInit(labelParam); + if (UsingWatchSimLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::UsingWatchSimLabel new fail!"); + return; + } + UsingWatchSimLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + /* --------------------------- UsingPhoneLabel --------------------------- */ + labelParam = { + .x = 83, + .y = 273, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "通过手机拨号", + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + UsingPhoneLabel = TelephonyInitInterface::LabelViewInit(labelParam); + if (UsingPhoneLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::UsingPhoneLabel new fail!"); + return; + } + UsingPhoneLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + } + } + + void DialingMethodView::OnStart() + { + View::OnStart(); + DialingMethodViewInit(); + // 增加按键监听 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::DialingMethodPresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); + } + + void DialingMethodView::OnSetUpView() + { + View::OnSetUpView(); + DialingMethodScrollView->Add(DialingMethodTitleLabel); + DialingMethodScrollView->Add(UsingWatchSimButton); + DialingMethodScrollView->Add(UsingPhoneButton); + DialingMethodScrollView->Add(UsingWatchSimLabel); + DialingMethodScrollView->Add(UsingPhoneLabel); + RootView::GetInstance()->Add(DialingMethodScrollView); + Draw(); + } + + void DialingMethodView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void DialingMethodView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + RootView::GetInstance()->ClearOnKeyActListener(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp new file mode 100644 index 000000000..4cb20db41 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp @@ -0,0 +1,115 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-28 14:17:43 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-29 10:02:49 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/language/src/MainPhonePresenter.cpp + */ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "phone/include/MainPhonePresenter.h" +#include "phone/include/MainPhoneView.h" +#include "common/key_code.h" +#include +#include "iostream" +#include "UiConfig.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static MainPhonePresenter *g_pMainPhonePresenter = nullptr; + + MainPhonePresenter::MainPhonePresenter() + { + g_pMainPhonePresenter = this; + } + + MainPhonePresenter::~MainPhonePresenter() + { + g_pMainPhonePresenter = nullptr; + } + + MainPhonePresenter *MainPhonePresenter::GetInstance() + { + return g_pMainPhonePresenter; + } + + void MainPhonePresenter::OnStart() + { + Presenter::OnStart(); + } + + void MainPhonePresenter::OnPause(void) + { + Presenter::OnPause(); + } + + void MainPhonePresenter::OnResume(void) + { + Presenter::OnResume(); + } + + void MainPhonePresenter::OnStop(void) + { + Presenter::OnStop(); + } + + bool MainPhonePresenter::OnClick(UIView &view, const ClickEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainPhonePresenter::OnClick"); + + std::string curViewId = view.GetViewId(); + + if (curViewId == DIALINGMETHODBUTTON_VIEWID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick",curViewId.c_str()); + NativeAbility::GetInstance().EnterSlice(VIEW_DIALING_METHOD); + } + else if (curViewId == FREQUENTLYCONTACTEDBUTTON_VIEWID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick",curViewId.c_str()); + + } + + return true; + } + + bool MainPhonePresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainPhonePresenter::OnDrag"); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + TelephonyInitInterface::X_DRAG_FLAG = true; + } + return true; + } + + bool MainPhonePresenter::OnDragEnd(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainPhonePresenter::OnDragEnd"); + if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && TelephonyInitInterface::X_DRAG_FLAG) // 拖动结束判断是否是右滑 + { + NativeAbility::GetInstance().Back(); + TelephonyInitInterface::X_DRAG_FLAG = false; + } + + return true; + } + + bool MainPhonePresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainPhonePresenter::OnKeyAct"); + unsigned short keyID = event.GetKeyId(); + unsigned short keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) + { + NativeAbility::GetInstance().Back(); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp new file mode 100644 index 000000000..2791bd475 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp @@ -0,0 +1,242 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-28 10:09:51 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-29 10:08:42 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp + */ +#include "phone/include/MainPhoneView.h" +#include "phone/include/MainPhonePresenter.h" + +#include "wearable_log.h" +namespace OHOS +{ + + static MainPhoneView *g_pMainPhoneView{nullptr}; + + MainPhoneView::MainPhoneView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::MainPhoneView"); + g_pMainPhoneView = this; + } + + MainPhoneView::~MainPhoneView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::~MainPhoneView"); + ClearAll(); + g_pMainPhoneView = nullptr; + } + + MainPhoneView *MainPhoneView::GetInstance() + { + return g_pMainPhoneView; + } + + void MainPhoneView::ClearAll(void) + { + if (MainPhoneViewScrollView != nullptr) + { + MainPhoneViewScrollView->RemoveAll(); + + delete MainPhoneViewTitleLabel; + MainPhoneViewTitleLabel = nullptr; + + delete DialingMethodButton; + DialingMethodButton = nullptr; + + delete FrequentlyContactedButton; + FrequentlyContactedButton = nullptr; + + delete RecentCallLabel; + RecentCallLabel = nullptr; + + delete TelephoneLineImageView; + TelephoneLineImageView = nullptr; + + delete NoCallsLabel; + NoCallsLabel = nullptr; + + delete MainPhoneViewScrollView; + MainPhoneViewScrollView = nullptr; + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::ClearAll success!!"); + } + + void MainPhoneView::MainPhoneViewInit(void) + { + if (MainPhoneViewScrollView == nullptr) + { + /* ------------------------- MainPhoneViewScrollView ------------------------ */ + TelephonyInitInterface::ScrollViewParams scrollviewParam = { + .x = 0, + .y = 0, + .width = Screen::GetInstance().GetWidth(), + .height = Screen::GetInstance().GetHeight(), + .viewId = MAINPHONE_VIEWID, + .scrollBlankSize = 50, + .reboundSize = 35, + .direction = 1, + }; + MainPhoneViewScrollView = TelephonyInitInterface::ScrollViewInit(scrollviewParam); + if (MainPhoneViewScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::MainPhoneViewScrollView new fail!"); + return; + } + UIView::OnDragListener *dragListener = static_cast(MainPhonePresenter::GetInstance()); + if (dragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dragListener new fail!"); + return; + } + MainPhoneViewScrollView->SetOnDragListener(dragListener); + /* ------------------------- MainPhoneViewTitleLabel ------------------------ */ + TelephonyInitInterface::LabelParams labelParam = { + .x = 83, + .y = 53, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "通话", + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + MainPhoneViewTitleLabel = TelephonyInitInterface::LabelViewInit(labelParam); + if (MainPhoneViewTitleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::MainPhoneViewTitleLabel new fail!"); + return; + } + MainPhoneViewTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + /* --------------------------- DialingMethodButton -------------------------- */ + TelephonyInitInterface::ButtonParams buttonParam = { + .x = 63, + .y = 116, + .width = 140, + .height = 140, + .viewId = DIALINGMETHODBUTTON_VIEWID, + .backgroundColor = 0xff4fc34c, + .pressedBackgroundColor = 0xff1996ff, + }; + DialingMethodButton = TelephonyInitInterface::ButtonViewInit(buttonParam); + if (DialingMethodButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::DialingMethodButton new fail!"); + return; + } + DialingMethodButton->SetImagePosition(46, 46); + DialingMethodButton->SetImageSrc(PNG_DIALINGMETHODBUTTON_IMAGE, PNG_DIALINGMETHODBUTTON_IMAGE); + /* ------------------------ FrequentlyContactedButton ----------------------- */ + buttonParam.x = 263; + buttonParam.viewId = FREQUENTLYCONTACTEDBUTTON_VIEWID; + FrequentlyContactedButton = TelephonyInitInterface::ButtonViewInit(buttonParam); + if (FrequentlyContactedButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::FrequentlyContactedButton new fail!"); + return; + } + FrequentlyContactedButton->SetImagePosition(46, 46); + FrequentlyContactedButton->SetImageSrc(PNG_FREQUENTLYCONTACTEDBUTTON_IMAGE, PNG_FREQUENTLYCONTACTEDBUTTON_IMAGE); + /* --------------------------- ButtonOnclickListen -------------------------- */ + UIView::OnClickListener *ButtonOnclickListen = static_cast(MainPhonePresenter::GetInstance()); + if (ButtonOnclickListen == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ButtonOnclickListen new fail!"); + return; + } + DialingMethodButton->SetOnClickListener(ButtonOnclickListen); + FrequentlyContactedButton->SetOnClickListener(ButtonOnclickListen); + /* ----------------------------- RecentCallLabel ---------------------------- */ + labelParam = { + .x = 83, + .y = 290, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "最近通话", + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + RecentCallLabel = TelephonyInitInterface::LabelViewInit(labelParam); + if (RecentCallLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::RecentCallLabel new fail!"); + return; + } + RecentCallLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + /* ------------------------- TelephoneLineImageView ------------------------- */ + TelephonyInitInterface::ImageParams imageParam = { + .x = 83, + .y = 344, + .width = 300, + .height = 0, + .viewId = "TelephoneLineImageView", + .imgsrc = PNG_TELEPHONELINE_IMAGE, + }; + TelephoneLineImageView = TelephonyInitInterface::ImageViewInit(imageParam); + if (TelephoneLineImageView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::TelephoneLineImageView new fail!"); + return; + } + /* ------------------------------ NoCallsLabel ------------------------------ */ + labelParam = { + .x = 83, + .y = 363, + .width = 300, + .height = 40, + .fontSize = 30, + .lineHeigh = 40, + .text = "暂无通话", + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + NoCallsLabel = TelephonyInitInterface::LabelViewInit(labelParam); + if (NoCallsLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::NoCallsLabel new fail!"); + return; + } + NoCallsLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); + NoCallsLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + /* -------------------------------------------------------------------------- */ + } + } + + void MainPhoneView::OnStart() + { + View::OnStart(); + MainPhoneViewInit(); + // 增加按键监听 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::MainPhonePresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); + } + + void MainPhoneView::OnSetUpView() + { + View::OnSetUpView(); + MainPhoneViewScrollView->Add(MainPhoneViewTitleLabel); + MainPhoneViewScrollView->Add(DialingMethodButton); + MainPhoneViewScrollView->Add(FrequentlyContactedButton); + MainPhoneViewScrollView->Add(RecentCallLabel); + MainPhoneViewScrollView->Add(TelephoneLineImageView); + MainPhoneViewScrollView->Add(NoCallsLabel); + RootView::GetInstance()->Add(MainPhoneViewScrollView); + Draw(); + } + + void MainPhoneView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void MainPhoneView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + RootView::GetInstance()->ClearOnKeyActListener(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/TelephonyInitInterface.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/TelephonyInitInterface.cpp new file mode 100644 index 000000000..aa04152f2 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/TelephonyInitInterface.cpp @@ -0,0 +1,85 @@ +#include "phone/include/TelephonyInitInterface.h" +#include "wearable_log.h" + +namespace OHOS +{ + bool TelephonyInitInterface::X_DRAG_FLAG = false; // 水平拖拽标志 + + TelephonyInitInterface::TelephonyInitInterface() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TelephonyInitInterface::TelephonyInitInterface"); + } + + TelephonyInitInterface::~TelephonyInitInterface() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TelephonyInitInterface::~TelephonyInitInterface"); + } + + // 显示与亮度视图scrollView初始化 + UIScrollView *TelephonyInitInterface::ScrollViewInit(const ScrollViewParams ¶ms) + { + UIScrollView *scrollView = new UIScrollView(); + if (scrollView == nullptr) + { + return nullptr; + } + scrollView->SetPosition(params.x, params.y, params.width, params.height); + scrollView->SetViewId(params.viewId); + scrollView->SetScrollBlankSize(params.scrollBlankSize); + scrollView->SetReboundSize(params.reboundSize); + scrollView->SetDirection(params.direction); + scrollView->SetTouchable(true); + scrollView->SetDraggable(true); + + return scrollView; + } + + UILabelExt *TelephonyInitInterface::LabelViewInit(const LabelParams ¶ms) + { + UILabelExt *label = new UILabelExt(); + if (label == nullptr) + { + return nullptr; + } + label->SetPosition(params.x, params.y, params.width, params.height); // 位置大小 + label->SetStyle(STYLE_TEXT_FONT, params.fontSize); // 字体大小 + label->SetStyle(STYLE_LINE_HEIGHT, params.lineHeigh); // 字体行高 + label->SetText(params.text); // 内容 + label->SetLineBreakMode(params.lineBreakMode); // 断行模式 + // label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); // 设置此文本的对齐模式 + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, params.fontSize); // 设置标签的字体 + + return label; + } + + UIButton *TelephonyInitInterface::ButtonViewInit(const ButtonParams ¶ms) + { + UIButton *button = new UIButton(); + if (button == nullptr) + { + return nullptr; + } + button->SetPosition(params.x, params.y, params.width, params.height); + button->SetViewId(params.viewId); + button->SetStyle(STYLE_BACKGROUND_COLOR, params.backgroundColor); + button->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + button->SetStyleForState(STYLE_BACKGROUND_COLOR, params.pressedBackgroundColor, UIButton::PRESSED); + + return button; + } + + UIImageView *TelephonyInitInterface::ImageViewInit(const ImageParams ¶ms) + { + UIImageView *image = new UIImageView(); + if (image == nullptr) + { + return nullptr; + } + image->SetPosition(params.x, params.y, params.width, params.height); + image->SetViewId(params.viewId); + image->SetSrc(params.imgsrc); + + return image; + } + +} \ No newline at end of file diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Phone/Telephone/DialingMethod.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Phone/Telephone/DialingMethod.bin new file mode 100644 index 000000000..ef5997363 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Phone/Telephone/DialingMethod.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5e8b292f9fe15f5ec9e14fc9c9a02176913886df510cb045ba68db092e10ca51 +size 1944 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Phone/Telephone/FrequentlyContacted.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Phone/Telephone/FrequentlyContacted.bin new file mode 100644 index 000000000..c28b517b8 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Phone/Telephone/FrequentlyContacted.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4859266196224bb10fffa9bc4df0c42eea83f43c98f5e3fa35930906d9a422a9 +size 1944 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Phone/Telephone/TelephoneLine.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Phone/Telephone/TelephoneLine.bin new file mode 100644 index 000000000..785c33384 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Phone/Telephone/TelephoneLine.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d2e96c7c6f4f268c431a56cdef91a57aa33af0a5ee9d3e23c4a333309a4cd3cc +size 824