${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/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
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,
/* ---------------------------------- 界面 ---------------------------------- */
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, // 极限运动列表
VIEW_PHONECALLUP, // 通话界面
VIEW_PHONEDIR, // 电话簿
+ VIEW_MAIN_PHONE, // 主电话Slice
+
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, // 三方应用
void InitPhoneCallupSlice(void);
void InitPhoneRingSlice(void);
+ /* -------------------------------------------------------------------------- */
+ void InitMainPhoneSlice(void);
+ /* -------------------------------------------------------------------------- */
+
void InittestSlice(void);
private:
#include "phone/include/PhoneRingView.h"
#include "phone/include/PhoneRingPresenter.h"
+/* -------------------------------------------------------------------------- */
+#include "phone/include/MainPhoneView.h"
+#include "phone/include/MainPhonePresenter.h"
+/* -------------------------------------------------------------------------- */
+
#include "producttest/include/testPresenter.h"
#include "producttest/include/testView.h"
{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},
{VIEW_PHONECALLUP, &NativeLauncher::InitPhoneCallupSlice},
{VIEW_PHONERING, &NativeLauncher::InitPhoneRingSlice},
+ /* -------------------------------------------------------------------------- */
+ {VIEW_MAIN_PHONE, &NativeLauncher::InitMainPhoneSlice},
+ /* -------------------------------------------------------------------------- */
+
{VIEW_TEST, &NativeLauncher::InittestSlice},
/* ---------------------------------- 省电模式 ---------------------------------- */
// }
// NativeAbility::GetInstance().AddSliceProxy(VIEW_DIALUPDATE, dialupdate);
// }
- //传统蓝牙
+ // 传统蓝牙
void NativeLauncher::InitClassicBluetoothSlice(void)
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitClassicBluetoothSlice");
NativeAbility::GetInstance().AddSliceProxy(VIEW_PHONERING, phoneringview);
}
+ /* ----------------------------------- 电话 ----------------------------------- */
+ void NativeLauncher::InitMainPhoneSlice(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitMainPhoneSlice");
+ SliceProxy *mainphoneview = new AbilitySliceProxy<MainPhoneView, MainPhonePresenter>;
+ if (mainphoneview == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainphoneview");
+ return;
+ }
+ NativeAbility::GetInstance().AddSliceProxy(VIEW_MAIN_PHONE, mainphoneview);
+ }
+ /* -------------------------------------------------------------------------- */
+
void NativeLauncher::InittestSlice(void)
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitestSlice");
}
if (disturbIcon != nullptr)
{
+ mainClockView->Remove(disturbIcon);
delete disturbIcon;
disturbIcon = nullptr;
}
{
if (group[DROPDOWNVIEW] != nullptr)
{
+ RemoveAll();
group[DROPDOWNVIEW]->RemoveAll();
group[DROPDOWNVIEW]->ClearBackgroundBlur();
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_;
progressanimator_ = nullptr;
}
- Remove(group[DROPDOWNVIEW]);
-
delete group[DROPDOWNVIEW];
group[DROPDOWNVIEW] = nullptr;
}
{
delete connectedStatusView;
connectedStatusView = nullptr;
+ group[CONNECTEDSTATUSVIEW] = nullptr;
}
}
/// @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);
--- /dev/null
+/*
+ * @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<MainPhoneView>,
+ 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
--- /dev/null
+/*
+ * @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<MainPhonePresenter>
+ {
+
+ 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
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-04-28 09:58:04
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-04-28 16:55:20
+ * @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"
+
+namespace OHOS
+{
+
+ // 视图id
+ static constexpr const char *MAINPHONE_VIEWID = "MainPhoneView";
+ static constexpr const char *DIALINGMETHODBUTTON_VIEWID = "DialingMethodButton"; // 通话方式按钮视图id
+ static constexpr const char *FREQUENTLYCONTACTEDBUTTON_VIEWID = "FrequentlyContactedButton"; // 常用联系人按钮视图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
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-03-28 14:17:43
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-04-28 16:54:51
+ * @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 <custom_utils.h>
+#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<MainPhoneView>::OnStart();
+ }
+
+ void MainPhonePresenter::OnPause(void)
+ {
+ Presenter<MainPhoneView>::OnPause();
+ }
+
+ void MainPhonePresenter::OnResume(void)
+ {
+ Presenter<MainPhoneView>::OnResume();
+ }
+
+ void MainPhonePresenter::OnStop(void)
+ {
+ Presenter<MainPhoneView>::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, "DIALINGMETHODBUTTON_VIEWID OnClick");
+ }
+ else if (curViewId == FREQUENTLYCONTACTEDBUTTON_VIEWID)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FREQUENTLYCONTACTEDBUTTON_VIEWID OnClick");
+ }
+
+ return true;
+ }
+
+ bool MainPhonePresenter::OnDrag(UIView &view, const DragEvent &event)
+ {
+ UNUSED(view);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainPhonePresenter::OnDrag");
+ if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) &&
+ (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 (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<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0)
+ {
+ uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
+ NativeAbility::GetInstance().ChangeSlice(preSlice);
+ }
+ return true;
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-04-28 10:09:51
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-04-28 15:58:43
+ * @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)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::ClearAll");
+ 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;
+ }
+ }
+
+ 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<UIView::OnDragListener *>(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<UIView::OnClickListener *>(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<MainPhonePresenter>::OnStart();
+ MainPhoneViewInit();
+ // 增加按键监听
+ RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::MainPhonePresenter::GetInstance();
+ RootView::GetInstance()->SetOnKeyActListener(keyactListener);
+ }
+
+ void MainPhoneView::OnSetUpView()
+ {
+ View<MainPhonePresenter>::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<MainPhonePresenter>::OnTearDownView();
+ return;
+ }
+
+ void MainPhoneView::OnStop()
+ {
+
+ View<MainPhonePresenter>::OnStop();
+ RootView::GetInstance()->RemoveAll();
+ RootView::GetInstance()->ClearOnKeyActListener();
+ return;
+ }
+}
\ No newline at end of file
--- /dev/null
+#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
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:5e8b292f9fe15f5ec9e14fc9c9a02176913886df510cb045ba68db092e10ca51
+size 1944
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:4859266196224bb10fffa9bc4df0c42eea83f43c98f5e3fa35930906d9a422a9
+size 1944
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:d2e96c7c6f4f268c431a56cdef91a57aa33af0a5ee9d3e23c4a333309a4cd3cc
+size 824