From: Caisking Date: Mon, 28 Apr 2025 09:59:15 +0000 (+0800) Subject: 【makephone]意义不明 Slice X-Git-Tag: leiniao_debug_1.0.0_20250922_020716~333 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=c7341ec43a8c6349c5ad3710d25c9823bdf23d93;p=mirrors%2FFD230.git 【makephone]意义不明 Slice --- diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/CallerDisplayView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/CallerDisplayView.h index ef5617220..bf1594868 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/CallerDisplayView.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/CallerDisplayView.h @@ -1,38 +1,46 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: CallerDisplayView.h - * Author: - * Create: 2021-10-12 - */ -#ifndef CALLER_DISPLAY_VIEW_H -#define CALLER_DISPLAY_VIEW_H - -#include "View.h" -#include "components/ui_label.h" -#include "components/ui_image_animator.h" -#include "components/ui_view_group.h" -#include "ohos_types.h" - -namespace OHOS { -class CallerDisplayView { -public: - CallerDisplayView(); - ~CallerDisplayView(); - UIViewGroup *CreateUIViewGroup(); - - static CallerDisplayView *GetInstance(); -private: - bool InitAddOnclickevent(void); - bool InitImageViewDisplay(void); - bool InitUILabelDisplay(void); - - UIViewGroup *group{nullptr}; - UIView::OnClickListener* clickLeftListener{nullptr}; - UIImageView *imageAgreeing{nullptr}; - UIImageView *imageDissgree{nullptr}; - UILabel *callerDisplay{nullptr}; - UILabel *currentTimes{nullptr}; -}; -} - +/* + * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: CallerDisplayView.h + * Author: + * Create: 2021-10-12 + */ +#ifndef CALLER_DISPLAY_VIEW_H +#define CALLER_DISPLAY_VIEW_H + +#include "View.h" + +#include "components/ui_label.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_animator.h" +#include "components/ui_view_group.h" +#include "ohos_types.h" + +namespace OHOS { +class CallerDisplayView { +public: + CallerDisplayView(); + ~CallerDisplayView(); + UIViewGroup *CreateUIViewGroup(); + + static CallerDisplayView *GetInstance(); + void updataCallingname(); +private: + bool InitAddOnclickevent(void); + bool InitImageViewDisplay(void); + bool InitUILabelDisplay(void); + + UIViewGroup *group{nullptr}; + UIView::OnClickListener* clickLeftListener{nullptr}; + UIImageView *imageAgreeing{nullptr}; + UIImageView *imageDissgree{nullptr}; + UIImageView *imageperson{nullptr}; + + UILabelExt *callerDisplay{nullptr}; + UILabelExt *currentTimes{nullptr}; + + UILabelExt *label_call_source{nullptr}; + UILabelExt *label_call_hint{nullptr}; +}; +} + #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/CallingView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/CallingView.h index 6ee0de153..e457e3bb1 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/CallingView.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/CallingView.h @@ -1,45 +1,69 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: CallingView.h - * Author: - * Create: 2021-10-12 - */ -#ifndef CALLING_VIEW_H -#define CALLING_VIEW_H - -#include "View.h" -#include "components/ui_label.h" -#include "components/ui_image_animator.h" -#include "components/ui_view_group.h" -#include "ohos_types.h" -#include "UiConfig.h" -#include "ChangeSliceListener.h" - - -namespace OHOS { -class CallingView { -public: - CallingView(); - ~CallingView(); - UIViewGroup *CreateUIViewGroup(); - UIImageView *GetImageMicrophone(); - static CallingView *GetInstance(); - UILabel *GetCallingDisplayLabel(); - UILabel *GetCallingDurationLabel(); -private: - bool InitAddOnclickevent(void); - bool InitImageViewDisplay(void); - bool InitUILabelDisplay(void); - - UIImageView *imageMicrophone{nullptr}; - UIViewGroup *group{nullptr}; - UIView::OnClickListener* clickLeftListener{nullptr}; - UIImageView *imageHandUp{nullptr}; - UIImageView *imageHorns{nullptr}; - UILabel *callerDisplay{nullptr}; - UILabel *currentTimes{nullptr}; - UILabel *callDuration{nullptr}; -}; -} - +/* + * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: CallingView.h + * Author: + * Create: 2021-10-12 + */ +#ifndef CALLING_VIEW_H +#define CALLING_VIEW_H + +#include "View.h" + +#include "components/ui_label.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_animator.h" +#include "components/ui_view_group.h" +#include "ohos_types.h" +#include "UiConfig.h" +#include "ChangeSliceListener.h" +#include "components/ui_label_button.h" +#include "BluetoothEarListView.h" + +namespace OHOS { +class CallingView { +public: + CallingView(); + ~CallingView(); + UIViewGroup *CreateUIViewGroup(); + UIViewGroup *CreateUIViewGroup(uint8_t); + UIImageView *GetImageMicrophone(); + static CallingView *GetInstance(); + UILabel *GetCallingDisplayLabel(); + UILabel *GetCallingDurationLabel(); + void showdial(bool); + void text_updata_buf(const char *buf); + void updataCallingname(void); + void update_headset_state(uint8_t state); + + private: + bool InitAddOnclickevent(void); + bool InitImageViewDisplay(void); + bool InitUILabelDisplay(void); + bool Initshowdial(void); + + + UIViewGroup *group{nullptr}; + UIView::OnClickListener* clickLeftListener{nullptr}; + UIView:: OnDragListener* dragListener{nullptr}; + + UIImageView *imageMicrophone{nullptr}; + + UIImageView *imageHandUp{nullptr}; + UIImageView *imageHorns{nullptr}; + + UIImageView *imagedial{nullptr}; + UIImageView *imageheadset{nullptr}; + + UIImageView *imageperson{nullptr}; + UILabel *callerDisplay{nullptr}; + UILabelExt *currentTimes{nullptr}; + UILabel *callDuration{nullptr}; + + UIViewGroup *dial_group{nullptr}; + UILabelButton* labelButton[12]={nullptr}; + UIImageView *image_line{nullptr}; + UILabel * label_number{nullptr}; +}; +} + #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/DialingScreenView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/DialingScreenView.h index 2b827c754..3917e91f0 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/DialingScreenView.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/DialingScreenView.h @@ -1,36 +1,38 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: DialingScreenView.h - * Author: - * Create: 2021-10-12 - */ -#ifndef DIALING_SCREEN_VIEW_H -#define DIALING_SCREEN_VIEW_H - -#include "View.h" -#include "components/ui_label.h" -#include "components/ui_image_animator.h" -#include "components/ui_view_group.h" -#include "ohos_types.h" - -namespace OHOS { -class DialingScreenView { -public: - DialingScreenView(); - ~DialingScreenView(); - UIViewGroup *CreateUIViewGroup(); - - static DialingScreenView *GetInstance(); -private: - bool InitUILabelDisplay(); - - UIViewGroup *group{nullptr}; - UIView::OnClickListener* clickLeftListener{nullptr}; - UILabel *dialingId{nullptr}; - UILabel *dialingTime{nullptr}; - UILabel *currentTimes{nullptr}; - UIImageView *handup{nullptr}; -}; -} - +/* + * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: DialingScreenView.h + * Author: + * Create: 2021-10-12 + */ +#ifndef DIALING_SCREEN_VIEW_H +#define DIALING_SCREEN_VIEW_H + +#include "View.h" + +#include "components/ui_label.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_animator.h" +#include "components/ui_view_group.h" +#include "ohos_types.h" + +namespace OHOS { +class DialingScreenView { +public: + DialingScreenView(); + ~DialingScreenView(); + UIViewGroup *CreateUIViewGroup(); + + static DialingScreenView *GetInstance(); +private: + bool InitUILabelDisplay(); + + UIViewGroup *group{nullptr}; + UIView::OnClickListener* clickLeftListener{nullptr}; + UILabel *dialingId{nullptr}; + UILabel *dialingTime{nullptr}; + UILabel *currentTimes{nullptr}; + UIImageView *handup{nullptr}; +}; +} + #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/MainCallingPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/MainCallingPresenter.h index a9b800fce..ecae95120 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/MainCallingPresenter.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/MainCallingPresenter.h @@ -1,36 +1,50 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: MainCallingPresenter.h - * Author: - * Create: 2021-10-12 - */ -#ifndef MAIN_CALLING_PRESENTER_H -#define MAIN_CALLING_PRESENTER_H - -#include "Presenter.h" -#include "ohos_types.h" -#include "CallerLogModel.h" -#include "VolumeSettingView.h" -#include "VolumeSettingPresenter.h" - -namespace OHOS { -class MainCallingView; -class MainCallingPresenter : public Presenter, public UIView::OnClickListener { -public: - MainCallingPresenter(); - ~MainCallingPresenter() override; - static MainCallingPresenter *GetInstance(); - - void HonrsViewChange(); - bool CallingViewDisplay(); - bool InitPointerValue(); - bool OnClick(UIView& view, const ClickEvent& event) override; - VolumeSettingView *GetvolumeSetting(); -private: - int changeImage{0}; - bool HintsHandupClick(); - VolumeSettingView *volumeSetting{nullptr}; -}; -} - +/* + * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: MainCallingPresenter.h + * Author: + * Create: 2021-10-12 + */ +#ifndef MAIN_CALLING_PRESENTER_H +#define MAIN_CALLING_PRESENTER_H + +#include "Presenter.h" +#include "ohos_types.h" +#include "CallerLogModel.h" +#include "VolumeSettingView.h" +#include "VolumeSettingPresenter.h" +#include "KeyInputListener.h" + +namespace OHOS { +class MainCallingView; +class MainCallingPresenter : public Presenter, + public RootView::OnKeyActListener, + public UIView::OnClickListener , + public UIView::OnDragListener{ +public: + MainCallingPresenter(); + ~MainCallingPresenter() override; + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + static MainCallingPresenter *GetInstance(); + + void HonrsViewChange(); + bool CallingViewDisplay(); + bool InitPointerValue(); + bool OnClick(UIView& view, const ClickEvent& event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + + bool OnDragEnd(UIView &view, const DragEvent &event) override; + VolumeSettingView *GetvolumeSetting(); +private: + int changeImage{0}; + bool HintsHandupClick(); + KeyInputListener *keyActListenr{nullptr}; + VolumeSettingView *volumeSetting{nullptr}; + +}; +} + #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/MainCallingView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/MainCallingView.h index e4bf8dd9d..d16f41c32 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/MainCallingView.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/MainCallingView.h @@ -1,46 +1,52 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: MainCallingView.h - * Author: - * Create: 2021-10-12 - */ -#ifndef MAIN_CALLING_VIEW_H -#define MAIN_CALLING_VIEW_H - -#include "View.h" -#include "components/ui_view_group.h" -#include "ohos_types.h" -#include "CallerDisplayView.h" -#include "CallingView.h" -#include "DialingScreenView.h" -#include "WaitingHintsView.h" - -namespace OHOS { -class MainCallingPresenter; -class MainCallingView : public View { -public: - MainCallingView(); - ~MainCallingView() override; - - void OnStart() override; - - static MainCallingView *GetInstance(); - UIViewGroup *GetDisplayGroup(); - UIViewGroup *GetCallingGroup(); - UIViewGroup *GetScreenGroup(); - UIViewGroup *GetWaitingGroup(); - CallingView *GetCallingView(); -private: - bool InitPointerValue(); - UIViewGroup *displayGroup{nullptr}; - UIViewGroup *callingGroup{nullptr}; - UIViewGroup *screenGroup{nullptr}; - UIViewGroup *waitingGroup{nullptr}; - CallerDisplayView *displayView{nullptr}; - CallingView *callView{nullptr}; - DialingScreenView *screenView{nullptr}; - WaitingHintsView *waitingView{nullptr}; -}; -} - +/* + * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: MainCallingView.h + * Author: + * Create: 2021-10-12 + */ +#ifndef MAIN_CALLING_VIEW_H +#define MAIN_CALLING_VIEW_H + +#include "View.h" + +#include "components/ui_view_group.h" +#include "ohos_types.h" +#include "CallerDisplayView.h" +#include "CallingView.h" +#include "DialingScreenView.h" +#include "WaitingHintsView.h" + +namespace OHOS { +class MainCallingPresenter; +class MainCallingView : public View { +public: + MainCallingView(); + ~MainCallingView(); + + + void OnStart() override; + + static MainCallingView *GetInstance(); + UIViewGroup *GetDisplayGroup(); + UIViewGroup *GetCallingGroup(); + UIViewGroup *GetScreenGroup(); + UIViewGroup *GetWaitingGroup(); + CallingView *GetCallingView(); + CallingView *GetScreenView(); + + void updataCallingname(void); + void update_headset_state(uint8_t data); +private: + bool InitPointerValue(); + UIViewGroup *displayGroup{nullptr}; + UIViewGroup *callingGroup{nullptr}; + UIViewGroup *screenGroup{nullptr}; + UIViewGroup *waitingGroup{nullptr}; + CallerDisplayView *displayView{nullptr}; + CallingView *callView{nullptr}; + CallingView *screenView{nullptr}; + WaitingHintsView *waitingView{nullptr}; +}; +} + #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/WaitingHintsView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/WaitingHintsView.h index 85e93c9ec..b6c5e3350 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/WaitingHintsView.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/include/WaitingHintsView.h @@ -1,36 +1,50 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: WaitingHintsView.h - * Author: - * Create: 2022-03-14 - */ -#ifndef WAITING_HINTS_VIEW_H -#define WAITING_HINTS_VIEW_H - -#include "View.h" -#include "components/ui_label.h" -#include "components/ui_image_animator.h" -#include "components/ui_view_group.h" -#include "ohos_types.h" - -namespace OHOS { -class WaitingHintsView { -public: - WaitingHintsView(); - ~WaitingHintsView(); - UIViewGroup *CreateUIViewGroup(); - - static WaitingHintsView *GetInstance(); -private: - bool InitImageViewDisplay(void); - bool InitUILabelDisplay(void); - - UIViewGroup *group{nullptr}; - UIView::OnClickListener* clickLeftListener{nullptr}; - UIImageView *imageDissgree{nullptr}; - UILabel *callerDisplay{nullptr}; - UILabel *newcallHints{nullptr}; -}; -} - +/* + * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. + * Description: WaitingHintsView.h + * Author: + * Create: 2022-03-14 + */ +#ifndef WAITING_HINTS_VIEW_H +#define WAITING_HINTS_VIEW_H + +#include "View.h" + +#include "components/ui_label.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_animator.h" +#include "components/ui_view_group.h" +#include "ohos_types.h" +#include "UiConfig.h" +#include "ChangeSliceListener.h" +#include "components/ui_label_button.h" + +namespace OHOS { +class WaitingHintsView { +public: + WaitingHintsView(); + ~WaitingHintsView(); + UIViewGroup *CreateUIViewGroup(); + + static WaitingHintsView *GetInstance(); + void updataCallingname(); +private: + bool InitImageViewDisplay(void); + bool InitUILabelDisplay(void); + bool InitAddOnclickevent(void); + + UIViewGroup *group{nullptr}; + UIView::OnClickListener* clickLeftListener{nullptr}; + + UIImageView *imageDissgree{nullptr}; + + UILabel *callerDisplay{nullptr}; + UIImageView *imageAgreeing{nullptr}; + UIImageView *imageperson{nullptr}; + + UILabelExt *currentTimes{nullptr}; + UILabelExt *label_call_source{nullptr}; + UILabelExt *label_call_hint{nullptr}; +}; +} + #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/CallerDisplayView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/CallerDisplayView.cpp index 2426ea21e..beb1d83cc 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/CallerDisplayView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/CallerDisplayView.cpp @@ -1,159 +1,284 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: CallerDisplayView.cpp - * Author: - * Create: 2021-10-12 - */ -#include "CallerDisplayView.h" -#include "MainCallingPresenter.h" -#include "UiConfig.h" - -namespace OHOS { -static constexpr uint16 MATH_ZERO = 0; - -// 来电显示 -static constexpr uint16 LABEL_PERCENT_POSITION_X = 0; -static constexpr uint16 LABEL_PERCENT_POSITION_Y = 80; -static constexpr uint16 VIEW_DISTANCE_TO_LEFT_SIDE = HORIZONTAL_RESOLUTION; -static constexpr uint16 TITLE_LABEL_DEFAULT_HEIGHT = 80; - -// 当前时间 -static constexpr uint16 LABEL_CURREMTTIME_POSITION_X = 0; -static constexpr uint16 LABEL_CURREMTTIME_POSITION_Y = 340; - -// 图片坐标 -static constexpr uint16 IMAGE_DISSGREE_POSITION_X = 80; -static constexpr uint16 IMAGE_AGREEING_POSITION_X = 270; -static constexpr uint16 IMAGE_ALL_POSITION_Y = 240; - -// 字体大小 -static constexpr uint16 FONT_CURRENT_SIZE = 25; -static constexpr uint16 FONT_CALLER_SIZE = 40; -static CallerDisplayView *g_pMainView = nullptr; -CallerDisplayView::CallerDisplayView() -{ - g_pMainView = this; -} - -CallerDisplayView::~CallerDisplayView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallerDisplayView::~CallerDisplayView"); - group->RemoveAll(); - - delete imageAgreeing; - imageAgreeing = nullptr; - - delete imageDissgree; - imageDissgree = nullptr; - - delete callerDisplay; - callerDisplay = nullptr; - - delete currentTimes; - currentTimes = nullptr; - - delete group; - group = nullptr; - - g_pMainView = nullptr; -} - -CallerDisplayView *CallerDisplayView::GetInstance() -{ - return g_pMainView; -} - -bool CallerDisplayView::InitAddOnclickevent() -{ - clickLeftListener = (UIView::OnClickListener*)OHOS::MainCallingPresenter::GetInstance(); - if (clickLeftListener == nullptr) { - return false; - } - imageAgreeing->SetOnClickListener(clickLeftListener); - imageDissgree->SetOnClickListener(clickLeftListener); - return true; -} - -bool CallerDisplayView::InitImageViewDisplay() -{ - imageAgreeing = new UIImageView(); - if (imageAgreeing == nullptr) { - return false; - } - imageAgreeing->SetPosition(IMAGE_AGREEING_POSITION_X, IMAGE_ALL_POSITION_Y); // 30 : offset - imageAgreeing->SetSrc(PNG_AGREEING_IMAGE_PATH); - imageAgreeing->SetTouchable(true); - imageAgreeing->SetViewId("answer"); - group->Add(imageAgreeing); - - imageDissgree = new UIImageView(); - if (imageDissgree == nullptr) { - return false; - } - imageDissgree->SetPosition(IMAGE_DISSGREE_POSITION_X, IMAGE_ALL_POSITION_Y); // 30 : offset - imageDissgree->SetSrc(PNG_DISSGREE_IMAGE_PATH); - imageDissgree->SetTouchable(true); - imageDissgree->SetViewId("displayHandUp"); - group->Add(imageDissgree); - - return true; -} - -bool CallerDisplayView::InitUILabelDisplay() -{ - callerDisplay = new UILabel(); - if (callerDisplay == nullptr) { - return false; - } - callerDisplay->SetPosition(LABEL_PERCENT_POSITION_X, LABEL_PERCENT_POSITION_Y, VIEW_DISTANCE_TO_LEFT_SIDE, - TITLE_LABEL_DEFAULT_HEIGHT); - callerDisplay->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - callerDisplay->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); - callerDisplay->SetAlign(TEXT_ALIGNMENT_CENTER); - callerDisplay->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CALLER_SIZE); - callerDisplay->SetTextColor(Color::White()); - group->Add(callerDisplay); - - currentTimes = new UILabel(); - if (currentTimes == nullptr) { - return false; - } - currentTimes->SetPosition(LABEL_CURREMTTIME_POSITION_X, LABEL_CURREMTTIME_POSITION_Y, - VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); - currentTimes->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - currentTimes->SetAlign(TEXT_ALIGNMENT_CENTER); - currentTimes->SetText(CallerLogModel::GetInstance()->InitDateHourTime().c_str()); - currentTimes->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CURRENT_SIZE); - currentTimes->SetTextColor(Color::White()); - group->Add(currentTimes); - return true; -} - -UIViewGroup *CallerDisplayView::CreateUIViewGroup() -{ - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerDisplayView::UIViewGroup::new group error"); - return nullptr; - } - group->SetPosition(MATH_ZERO, MATH_ZERO); - group->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); // 454 : value - - if (!InitImageViewDisplay()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerDisplayView::InitImageViewDisplay error"); - return nullptr; - } - - if (!InitAddOnclickevent()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerDisplayView::InitAddOnclickevent error"); - return nullptr; - } - - if (!InitUILabelDisplay()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerDisplayView::InitUILabelDisplay error"); - return nullptr; - } - - return group; -} +/* + * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: CallerDisplayView.cpp + * Author: + * Create: 2021-10-12 + */ +#include "CallerDisplayView.h" +#include "MainCallingPresenter.h" +#include "UiConfig.h" + +#include "phone/include/phoneaddressmodel.h" + +#include "ui_resource_string.h" + +namespace OHOS { +static constexpr uint16 MATH_ZERO = 0; + +// 来电显示 +static constexpr uint16 LABEL_PERCENT_POSITION_X = 93; +static constexpr uint16 LABEL_PERCENT_POSITION_Y = 80; +static constexpr uint16 VIEW_DISTANCE_TO_LEFT_SIDE = 280; +static constexpr uint16 TITLE_LABEL_DEFAULT_HEIGHT = 80; + +// 当前时间 +static constexpr uint16 LABEL_CURREMTTIME_POSITION_X = 0; +static constexpr uint16 LABEL_CURREMTTIME_POSITION_Y = 340; + +// 图片坐标 +static constexpr uint16 IMAGE_DISSGREE_POSITION_X = 80; +static constexpr uint16 IMAGE_AGREEING_POSITION_X = 270; +static constexpr uint16 IMAGE_ALL_POSITION_Y = 240; + +// 字体大小 +static constexpr uint16 FONT_CURRENT_SIZE = 25; +static constexpr uint16 FONT_CALLER_SIZE = 40; +static CallerDisplayView *g_pMainView = nullptr; + +#define PHONE_DIR_GIRL_1 "/user/res/Phone/girl.bin" +#define PHONE_DIR_BOY_1 "/user/res/Phone/boy.bin" + +CallerDisplayView::CallerDisplayView() +{ + g_pMainView = this; +} + +CallerDisplayView::~CallerDisplayView() +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallerDisplayView::~CallerDisplayView"); + group->RemoveAll(); + + delete imageAgreeing; + imageAgreeing = nullptr; + + delete imageDissgree; + imageDissgree = nullptr; + + + delete imageperson; + imageperson = nullptr; + + delete callerDisplay; + callerDisplay = nullptr; + + delete label_call_source; + label_call_source = nullptr; + + delete currentTimes; + currentTimes = nullptr; + + delete label_call_hint; + label_call_hint = nullptr; + + delete group; + group = nullptr; + + g_pMainView = nullptr; +} + +CallerDisplayView *CallerDisplayView::GetInstance() +{ + return g_pMainView; +} + +bool CallerDisplayView::InitAddOnclickevent() +{ + clickLeftListener = (UIView::OnClickListener*)OHOS::MainCallingPresenter::GetInstance(); + if (clickLeftListener == nullptr) { + return false; + } + imageAgreeing->SetOnClickListener(clickLeftListener); + imageDissgree->SetOnClickListener(clickLeftListener); + return true; +} + +bool CallerDisplayView::InitImageViewDisplay() +{ + imageAgreeing = new UIImageView(); + if (imageAgreeing == nullptr) { + return false; + } + imageAgreeing->SetPosition(369-24, 207-24); // 30 : offset + imageAgreeing->Resize(100, 100); + imageAgreeing->SetAutoEnable (false); + imageAgreeing->SetResizeMode(UIImageView::CENTER); + imageAgreeing->SetSrc(PNG_ANSWER_230_TMAGE_PATH); + imageAgreeing->SetTouchable(true); + imageAgreeing->SetViewId("answer"); + group->Add(imageAgreeing); + + imageDissgree = new UIImageView(); + if (imageDissgree == nullptr) { + return false; + } + imageDissgree->SetPosition(46-24, 207-24); // 30 : offset + imageDissgree->Resize(100, 100); + imageDissgree->SetAutoEnable (false); + imageDissgree->SetResizeMode(UIImageView::CENTER); + imageDissgree->SetSrc(PNG_HANDUP_230_IMAGE_PATH); + imageDissgree->SetTouchable(true); + imageDissgree->SetViewId("displayHandUp"); + group->Add(imageDissgree); + + imageperson = new UIImageView(); + if (imageperson == nullptr) { + return false; + } + imageperson->SetPosition(158, 158); // 30 : offset + imageperson->SetSrc(PNG_230_PERSON_IMAGE_PATH); + imageperson->SetTouchable(true); + imageperson->SetViewId("headset"); + + char name_buf[NAME_LEN+1]={0}; + uint8_t sex; + if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),&sex)) + { + if(sex==1) + imageperson->SetSrc(PHONE_DIR_BOY_1); + else + imageperson->SetSrc(PHONE_DIR_GIRL_1); + } + + group->Add(imageperson); + + + + return true; +} + +void CallerDisplayView::updataCallingname(void) +{ + //if(CallerLogModel::GetInstance()->Getphonename().length()>5) + if(strcmp(CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),CallerLogModel::GetInstance()->Getphonenumberpbap().c_str())==0) + { + if(CallerLogModel::GetInstance()->Getphonename().length()!=0) + callerDisplay->SetText(CallerLogModel::GetInstance()->Getphonename().c_str()); + } +} + + + +bool CallerDisplayView::InitUILabelDisplay() +{ + callerDisplay = new UILabelExt(); + if (callerDisplay == nullptr) { + return false; + } + callerDisplay->SetPosition(LABEL_PERCENT_POSITION_X, LABEL_PERCENT_POSITION_Y, VIEW_DISTANCE_TO_LEFT_SIDE, + TITLE_LABEL_DEFAULT_HEIGHT); + callerDisplay->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + + char name_buf[NAME_LEN+1]={0}; + if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),NULL)) + { + callerDisplay->SetText(name_buf); + } + else + { + callerDisplay->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); + } + // if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourcePhone) + updataCallingname(); + + callerDisplay->SetAlign(TEXT_ALIGNMENT_CENTER); + callerDisplay->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CALLER_SIZE); + callerDisplay->SetTextColor(Color::White()); + callerDisplay->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + group->Add(callerDisplay); + + if (label_call_hint == nullptr) { + label_call_hint = new UILabelExt(); + } + + label_call_hint->SetPosition(133, 353); // widget's left position and top position + label_call_hint->Resize(200, 35); // widget's width and height + label_call_hint->SetViewId("label3");// Set style + label_call_hint->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + // label_call_hint->SetText("挂断/接听"); + label_call_hint->SetTextId(STR_HANG_UP_OR_ANSWER); + + label_call_hint->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + label_call_hint->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_call_hint->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_call_hint->SetRollSpeed(0); + label_call_hint->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + //group->Add(label_call_hint); + + + if (label_call_source == nullptr) { + label_call_source = new UILabelExt(); + } + label_call_source->SetPosition(133, 34); // widget's left position and top position + label_call_source->Resize(200, 60); // widget's width and height + label_call_source->SetViewId("label1");// Set style + label_call_source->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1) + { + label_call_source->SetText("手表来电"); + label_call_source->SetTextId(STR_WATCH_CALL); + } + else + { + label_call_source->SetText("手机来电"); + label_call_source->SetTextId(STR_PHONE_CALL); + } + + + label_call_source->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + label_call_source->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_call_source->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_call_source->SetRollSpeed(0); + label_call_source->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + group->Add(label_call_source); + + + + // currentTimes = new UILabel(); + // if (currentTimes == nullptr) { + // return false; + // } + // currentTimes->SetPosition(LABEL_CURREMTTIME_POSITION_X, LABEL_CURREMTTIME_POSITION_Y, + // VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); + // currentTimes->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + // currentTimes->SetAlign(TEXT_ALIGNMENT_CENTER); + // currentTimes->SetText(CallerLogModel::GetInstance()->InitDateHourTime().c_str()); + // currentTimes->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CURRENT_SIZE); + // currentTimes->SetTextColor(Color::White()); + // group->Add(currentTimes); + + + return true; +} + +UIViewGroup *CallerDisplayView::CreateUIViewGroup() +{ + group = new UIViewGroup(); + if (group == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerDisplayView::UIViewGroup::new group error"); + return nullptr; + } + group->SetPosition(MATH_ZERO, MATH_ZERO); + group->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); // 454 : value + + if (!InitImageViewDisplay()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerDisplayView::InitImageViewDisplay error"); + return nullptr; + } + + if (!InitAddOnclickevent()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerDisplayView::InitAddOnclickevent error"); + return nullptr; + } + + if (!InitUILabelDisplay()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerDisplayView::InitUILabelDisplay error"); + return nullptr; + } + + return group; +} } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/CallingView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/CallingView.cpp index 2c19d7599..1414afec2 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/CallingView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/CallingView.cpp @@ -1,215 +1,551 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: CallingView.cpp - * Author: - * Create: 2021-10-12 - */ -#include "CallingView.h" -#include "MainCallingPresenter.h" -#include "wearable_log.h" -#include "UiConfig.h" - - -namespace OHOS { -static constexpr uint16 MATH_ZERO = 0; - -// 来电显示 -static constexpr uint16 LABEL_PERCENT_POSITION_X = 0; -static constexpr uint16 LABEL_PERCENT_POSITION_Y = 100; - -static constexpr uint16 VIEW_DISTANCE_TO_LEFT_SIDE = HORIZONTAL_RESOLUTION; -static constexpr uint16 TITLE_LABEL_DEFAULT_HEIGHT = 80; - -// 当前时间 -static constexpr uint16 LABEL_CURREMTTIME_POSITION_X = 0; -static constexpr uint16 LABEL_CURREMTTIME_POSITION_Y = 360; - -// 图片坐标 -static constexpr uint16 LABEL_CALLERD_POSITION_X = 0; -static constexpr uint16 LABEL_CALLERD_POSITION_Y = 160; -static constexpr uint16 IMAGE_HONRS_POSITION_X = 185; -static constexpr uint16 IMAGE_HONRS_POSITION_Y = 10; -static constexpr uint16 IMAGE_DISSGREE_POSITION_X = 70; -static constexpr uint16 IMAGE_AGREEING_POSITION_X = 280; -static constexpr uint16 IMAGE_ALL_POSITION_Y = 240; - -// 字体大小 -static constexpr uint16 LABEL_TIME_FONT_SIZE = 25; -static constexpr uint16 LABEL_DISPLAY_FONE_SIZE = 40; -static CallingView *g_pMainView = nullptr; - -CallingView::CallingView() -{ - g_pMainView = this; -} - -CallingView::~CallingView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallingView::~CallingView"); - group->RemoveAll(); - delete imageMicrophone; - imageMicrophone = nullptr; - - delete imageHandUp; - imageHandUp = nullptr; - - delete imageHorns; - imageHorns = nullptr; - - delete callerDisplay; - callerDisplay = nullptr; - - delete currentTimes; - currentTimes = nullptr; - - delete callDuration; - callDuration = nullptr; - - delete group; - group = nullptr; - - g_pMainView = nullptr; -} - -CallingView *CallingView::GetInstance() -{ - return g_pMainView; -} - -bool CallingView::InitAddOnclickevent() -{ - clickLeftListener = (UIView::OnClickListener*)OHOS::MainCallingPresenter::GetInstance(); - if (clickLeftListener == nullptr) { - return false; - } - - imageMicrophone->SetOnClickListener(clickLeftListener); - imageHandUp->SetOnClickListener(clickLeftListener); - imageHorns->SetOnClickListener(clickLeftListener); - - return true; -} - - -UILabel *CallingView::GetCallingDurationLabel() -{ - return callDuration; -} - -bool CallingView::InitImageViewDisplay() -{ - imageMicrophone = new UIImageView(); - if (imageMicrophone == nullptr) { - return false; - } - imageMicrophone->SetPosition(IMAGE_AGREEING_POSITION_X, IMAGE_ALL_POSITION_Y); // 30 : offset - imageMicrophone->SetSrc(PNG_MICROPHONE_OPEN_IMAGE_PATH); - imageMicrophone->SetTouchable(true); - imageMicrophone->SetViewId("microphoneChange"); - group->Add(imageMicrophone); - - imageHandUp = new UIImageView(); - if (imageHandUp == nullptr) { - return false; - } - imageHandUp->SetPosition(IMAGE_DISSGREE_POSITION_X, IMAGE_ALL_POSITION_Y); // 30 : offset - imageHandUp->SetSrc(PNG_DISSGREE_IMAGE_PATH); - imageHandUp->SetTouchable(true); - imageHandUp->SetViewId("callingHandUp"); - group->Add(imageHandUp); - - imageHorns = new UIImageView(); - if (imageHorns == nullptr) { - return false; - } - imageHorns->SetPosition(IMAGE_HONRS_POSITION_X, IMAGE_HONRS_POSITION_Y); // 30 : offset - imageHorns->SetSrc(PNG_SOUNDBUTTON2); - imageHorns->SetTouchable(true); - imageHorns->SetViewId("volumeSwitch"); - - group->Add(imageHorns); - return true; -} - -UIImageView *CallingView::GetImageMicrophone() -{ - return imageMicrophone; -} - -UILabel *CallingView::GetCallingDisplayLabel() -{ - return callerDisplay; -} - -bool CallingView::InitUILabelDisplay() -{ - callerDisplay = new UILabel(); - if (callerDisplay == nullptr) { - return false; - } - callerDisplay->SetPosition(LABEL_PERCENT_POSITION_X, LABEL_PERCENT_POSITION_Y, - VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); - callerDisplay->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - callerDisplay->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); - callerDisplay->SetAlign(TEXT_ALIGNMENT_CENTER); - callerDisplay->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_DISPLAY_FONE_SIZE); - callerDisplay->SetTextColor(Color::White()); - group->Add(callerDisplay); - - callDuration = new UILabel(); - if (callDuration == nullptr) { - return false; - } - callDuration->SetPosition(LABEL_CALLERD_POSITION_X, LABEL_CALLERD_POSITION_Y, - VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); - callDuration->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - callDuration->SetAlign(TEXT_ALIGNMENT_CENTER); - callDuration->SetText(CallerLogModel::GetInstance()->DisplayCallDuration().c_str()); - callDuration->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_TIME_FONT_SIZE); - callDuration->SetTextColor(Color::White()); - group->Add(callDuration); - - currentTimes = new UILabel(); - if (currentTimes == nullptr) { - return false; - } - currentTimes->SetPosition(LABEL_CURREMTTIME_POSITION_X, LABEL_CURREMTTIME_POSITION_Y, - VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); - currentTimes->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - currentTimes->SetAlign(TEXT_ALIGNMENT_CENTER); - currentTimes->SetText(CallerLogModel::GetInstance()->InitDateHourTime().c_str()); - currentTimes->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_TIME_FONT_SIZE); - currentTimes->SetTextColor(Color::White()); - - group->Add(currentTimes); - return true; -} - -UIViewGroup *CallingView::CreateUIViewGroup() -{ - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::UIViewGroup::new group error"); - return nullptr; - } - group->SetPosition(MATH_ZERO, MATH_ZERO); - group->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); // 454 : value - - if (!InitImageViewDisplay()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::InitImageViewDisplay error"); - return nullptr; - } - - if (!InitAddOnclickevent()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::InitAddOnclickevent error"); - return nullptr; - } - - if (!InitUILabelDisplay()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::InitUILabelDisplay error"); - return nullptr; - } - - return group; -} +/* + * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: CallingView.cpp + * Author: + * Create: 2021-10-12 + */ +#include "CallingView.h" +#include "MainCallingPresenter.h" +#include "wearable_log.h" +#include "UiConfig.h" +#include "PhoneService.h" +#include "cat1_server.h" +#include "cat1_server_hal.h" +#include "custom_utils.h" + +#include "phone/include/phoneaddressmodel.h" + + +#ifdef SUPPORT_BLE_SERVICE +#include +#include "bleService.h" +#include "bletest.h" +#endif + +#include "ui_resource_string.h" + +#ifdef SUPPORT_PHONE_SERVICE +#include "PhoneAGService.h" +#endif + +namespace OHOS { +static constexpr uint16 MATH_ZERO = 0; + +// 来电显示 +static constexpr uint16 LABEL_PERCENT_POSITION_X = 0; +static constexpr uint16 LABEL_PERCENT_POSITION_Y = 100; + +static constexpr uint16 VIEW_DISTANCE_TO_LEFT_SIDE = HORIZONTAL_RESOLUTION; +static constexpr uint16 TITLE_LABEL_DEFAULT_HEIGHT = 80; + +// 当前时间 +static constexpr uint16 LABEL_CURREMTTIME_POSITION_X = 0; +static constexpr uint16 LABEL_CURREMTTIME_POSITION_Y = 360; + +// 图片坐标 +static constexpr uint16 LABEL_CALLERD_POSITION_X = 0; +static constexpr uint16 LABEL_CALLERD_POSITION_Y = 160; +static constexpr uint16 IMAGE_HONRS_POSITION_X = 185; +static constexpr uint16 IMAGE_HONRS_POSITION_Y = 10; +static constexpr uint16 IMAGE_DISSGREE_POSITION_X = 70; +static constexpr uint16 IMAGE_AGREEING_POSITION_X = 280; +static constexpr uint16 IMAGE_ALL_POSITION_Y = 240; + +// 字体大小 +static constexpr uint16 LABEL_TIME_FONT_SIZE = 25; +static constexpr uint16 LABEL_DISPLAY_FONE_SIZE = 40; +static CallingView *g_pMainView = nullptr; + +#define PHONE_DIR_GIRL_1 "/user/res/Phone/girl.bin" +#define PHONE_DIR_BOY_1 "/user/res/Phone/boy.bin" + +CallingView::CallingView() +{ + g_pMainView = this; +} + + +CallingView::~CallingView() +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallingView::~CallingView"); + group->RemoveAll(); + delete imageMicrophone; + imageMicrophone = nullptr; + + delete imageHandUp; + imageHandUp = nullptr; + + delete imageHorns; + imageHorns = nullptr; + + delete callerDisplay; + callerDisplay = nullptr; + + delete currentTimes; + currentTimes = nullptr; + + delete callDuration; + callDuration = nullptr; + + delete group; + group = nullptr; + + delete imagedial; + imagedial = nullptr; + + + delete imageheadset; + imageheadset = nullptr; + + delete imageperson; + imageperson = nullptr; + + + if(dial_group) + { + dial_group->RemoveAll(); + for( int i=0;i<12;i++) + { + delete labelButton[i]; + labelButton[i]=nullptr; + } + delete image_line; + image_line= nullptr; + + + delete label_number; + label_number= nullptr; + + delete dial_group; + dial_group = nullptr; + } + + + g_pMainView = nullptr; +} + +CallingView *CallingView::GetInstance() +{ + return g_pMainView; +} + +bool CallingView::InitAddOnclickevent() +{ + clickLeftListener = (UIView::OnClickListener*)OHOS::MainCallingPresenter::GetInstance(); + if (clickLeftListener == nullptr) { + return false; + } + + imageMicrophone->SetOnClickListener(clickLeftListener); + imageHandUp->SetOnClickListener(clickLeftListener); + imageHorns->SetOnClickListener(clickLeftListener); + imagedial->SetOnClickListener(clickLeftListener); + imageheadset->SetOnClickListener(clickLeftListener); + + for( int i=0;i<12;i++) + { + labelButton[i]->SetOnClickListener(clickLeftListener); + } + return true; +} + + +UILabel *CallingView::GetCallingDurationLabel() +{ + return currentTimes; +} + +void CallingView::updataCallingname(void) +{ + if(strcmp(CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),CallerLogModel::GetInstance()->Getphonenumberpbap().c_str())==0) + { + if(CallerLogModel::GetInstance()->Getphonename().length()!=0) + callerDisplay->SetText(CallerLogModel::GetInstance()->Getphonename().c_str()); + } +} + +bool CallingView::InitImageViewDisplay() +{ + imageMicrophone = new UIImageView(); + if (imageMicrophone == nullptr) { + return false; + } + imageMicrophone->SetPosition(46, 207); // 30 : offset + imageMicrophone->SetSrc(PNG_230_MICROPHONE_OPEN_IMAGE_PATH); + imageMicrophone->SetTouchable(true); + imageMicrophone->SetViewId("microphoneChange"); + + + + group->Add(imageMicrophone); + + imageHandUp = new UIImageView(); + if (imageHandUp == nullptr) { + return false; + } + imageHandUp->SetPosition(188, 340); // 30 : offset + imageHandUp->SetSrc(PNG_230_VECTOR_IMAGE_PATH); + imageHandUp->SetTouchable(true); + imageHandUp->SetViewId("callingHandUp"); + group->Add(imageHandUp); + + imageHorns = new UIImageView(); + if (imageHorns == nullptr) { + return false; + } + imageHorns->SetPosition(369, 207); // 30 : offset + imageHorns->SetSrc(PNG_230_VOICE_OPEN_IMAGE_PATH); + imageHorns->SetTouchable(true); + imageHorns->SetViewId("volumeSwitch"); + group->Add(imageHorns); + + imagedial = new UIImageView(); + if (imagedial == nullptr) { + return false; + } + imagedial->SetPosition(80, 296); // 30 : offset + imagedial->SetSrc(PNG_230_DIAL_IMAGE_PATH); + imagedial->SetTouchable(true); + imagedial->SetViewId("dial"); + group->Add(imagedial); + + + imageheadset = new UIImageView(); + if (imagedial == nullptr) { + return false; + } + imageheadset->SetPosition(296, 296); // 30 : offset + + #ifdef SUPPORT_CAT1_HFP_AG_SERV + if(headset_SCO_Is_connect()) + { + imageheadset->SetSrc(PNG_230_HEADSET_2_IIMAGE_PATH); + imageheadset->SetViewId("callingheadset"); + } + else if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1) + { + imageheadset->SetSrc(PNG_230_HEADSET_3_IIMAGE_PATH); + imageheadset->SetViewId("callingheadset"); + } + else + #endif + + { + imageheadset->SetSrc(PNG_230_HEADSET_1_IIMAGE_PATH); + imageheadset->SetViewId("headset"); + } + + + imageheadset->SetTouchable(true); + + group->Add(imageheadset); + + imageperson = new UIImageView(); + if (imagedial == nullptr) { + return false; + } + imageperson->SetPosition(158, 158); // 30 : offset + imageperson->SetSrc(PNG_230_PERSON_IMAGE_PATH); + imageperson->SetTouchable(true); + imageperson->SetViewId("imageperson"); + group->Add(imageperson); + + char name_buf[NAME_LEN+1]={0}; + uint8_t sex; + if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),&sex)) + { + if(sex==1) + imageperson->SetSrc(PHONE_DIR_BOY_1); + else + imageperson->SetSrc(PHONE_DIR_GIRL_1); + } + + return true; +} + +void CallingView::update_headset_state(uint8_t state) +{ + if(imageheadset) + { + if(state) + { + imageheadset->SetSrc(PNG_230_HEADSET_2_IIMAGE_PATH); + } + else + { + imageheadset->SetSrc(PNG_230_HEADSET_3_IIMAGE_PATH); + } + } + +} + + + + +UIImageView *CallingView::GetImageMicrophone() +{ + return imageMicrophone; +} + +UILabel *CallingView::GetCallingDisplayLabel() +{ + return callerDisplay; +} + +bool CallingView::InitUILabelDisplay() +{ + callerDisplay = new UILabel(); + if (callerDisplay == nullptr) { + return false; + } + callerDisplay->SetPosition(88, 81, + 289, 40); + callerDisplay->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + + char name_buf[NAME_LEN+1]={0}; + if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),NULL)) + { + callerDisplay->SetText(name_buf); + } + else + { + callerDisplay->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); + } + + // if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourcePhone) + updataCallingname(); + + callerDisplay->SetAlign(TEXT_ALIGNMENT_CENTER); + callerDisplay->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_DISPLAY_FONE_SIZE); + callerDisplay->SetTextColor(Color::White()); + callerDisplay->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + group->Add(callerDisplay); + + // callDuration = new UILabel(); + // if (callDuration == nullptr) { + // return false; + // } + // callDuration->SetPosition(194, 38, + // 79, 35); + // callDuration->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + // callDuration->SetAlign(TEXT_ALIGNMENT_CENTER); + // callDuration->SetText(CallerLogModel::GetInstance()->DisplayCallDuration().c_str()); + // callDuration->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // callDuration->SetTextColor(Color::GetColorFromRGBA(0xaa, 0xaa, 0xaa, 0xff)); + // group->Add(callDuration); + + + currentTimes = new UILabelExt(); + if (currentTimes == nullptr) { + return false; + } + currentTimes->SetPosition(133, 38, + 200, 35); + currentTimes->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + currentTimes->SetAlign(TEXT_ALIGNMENT_CENTER); + currentTimes->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + currentTimes->SetText(CallerLogModel::GetInstance()->InitDateHourTime().c_str()); + + + + + currentTimes->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + currentTimes->SetTextColor(Color::GetColorFromRGBA(0xaa, 0xaa, 0xaa, 0xff)); + + group->Add(currentTimes); + return true; +} + +static char *dial_id_str[]={"1","2","3","4","5","6","7","8","9","*","0","#"}; +void CallingView::showdial(bool flag) +{ + if(flag) + { + label_number->SetText(""); + dial_group->SetVisible(true); + } + else + { + dial_group->SetVisible(false); + } + return; +} + +void CallingView::text_updata_buf(const char *buf) +{ + #ifdef FD230_650 + if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1){ + SendDtfmStrNumberToCat1(buf[0]); + } + else{ + uapi_hfp_send_DTMF_CODE(buf[0]); + } + #endif + + char new_buf[16]={0}; + const char*text_buf=label_number->GetText(); + sprintf_s(new_buf,16,"%s%s",text_buf,buf); + label_number->SetText(new_buf); + RootView::GetInstance()->Invalidate(); + + return; +} + + +bool CallingView::Initshowdial() +{ + dial_group = new UIViewGroup(); + if (dial_group == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::UIViewGroup::new group error"); + return false; + } + dial_group->SetPosition(MATH_ZERO, MATH_ZERO); + dial_group->Resize(466, 466); // 454 : value + dial_group->SetViewId("dialing"); + dial_group->SetTouchable(true); + dial_group->SetDraggable(true); + + dragListener = (UIView::OnDragListener*)OHOS::MainCallingPresenter::GetInstance(); + if (dragListener == nullptr) { + + return false; + } + dial_group->SetOnDragListener(dragListener); + + uint8_t showdial_i=0; + for(int i=0;i<4;i++) + { + for(int j=0;j<3;j++) + { + if (labelButton[showdial_i] == nullptr) { + labelButton[showdial_i] = new UILabelButton(); + } + if(labelButton[showdial_i]==nullptr) + { + return false; + } + labelButton[showdial_i]->SetPosition(69+(j*111), 107+(i*78)); // widget's left position and top position + + labelButton[showdial_i]->Resize(107, 70); // widget's width and height + labelButton[showdial_i]->SetViewId(dial_id_str[showdial_i]);// Set style + labelButton[showdial_i]->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + + labelButton[showdial_i]->SetText(dial_id_str[showdial_i]); + labelButton[showdial_i]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + labelButton[showdial_i]->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + + dial_group->Add(labelButton[showdial_i]); + labelButton[showdial_i]->SetVisible(true); + showdial_i++; + } + } + + if (image_line == nullptr) { + image_line = new UIImageView(); + } + if(image_line == nullptr) + { + return false; + } + image_line->SetPosition(193, 25); // widget's left position and top position + image_line->Resize(80, 8); // widget's width and height + image_line->SetViewId("image1");// Set style + image_line->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + image_line->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + image_line->SetStyle(STYLE_BORDER_RADIUS, 100); + + dial_group->Add(image_line); + image_line->SetVisible(true); + + // Add Label to App + if (label_number == nullptr) { + label_number = new UILabel(); + } + if(label_number == nullptr) + { + return false; + } + label_number->SetPosition(100, 43); // widget's left position and top position + label_number->Resize(265, 60); // widget's width and height + label_number->SetViewId("label3");// Set style + label_number->SetStyle(STYLE_TEXT_FONT, 40); + + // Set additional property + label_number->SetText(""); + label_number->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + label_number->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_number->SetRollSpeed(0); + label_number->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + dial_group->Add(label_number); + + group->Add(dial_group); + dial_group->SetVisible(false); + return true; + +} + +UIViewGroup *CallingView::CreateUIViewGroup() +{ + group = new UIViewGroup(); + if (group == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::UIViewGroup::new group error"); + return nullptr; + } + group->SetPosition(MATH_ZERO, MATH_ZERO); + group->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); // 454 : value + + if (!InitImageViewDisplay()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::InitImageViewDisplay error"); + return nullptr; + } + if (!InitUILabelDisplay()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::InitUILabelDisplay error"); + return nullptr; + } + + if(!Initshowdial()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::InitUILabelDisplay error"); + return nullptr; + } + if (!InitAddOnclickevent()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::InitAddOnclickevent error"); + return nullptr; + } + return group; +} + +UIViewGroup *CallingView::CreateUIViewGroup(uint8_t type) +{ + group = new UIViewGroup(); + if (group == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::UIViewGroup::new group error"); + return nullptr; + } + group->SetPosition(MATH_ZERO, MATH_ZERO); + group->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); // 454 : value + + if (!InitImageViewDisplay()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::InitImageViewDisplay error"); + return nullptr; + } + if (!InitUILabelDisplay()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::InitUILabelDisplay error"); + return nullptr; + } + currentTimes->SetTextId(STR_CALLING); /* code */ + imageMicrophone->SetStyle(STYLE_IMAGE_OPA, 97); + + if(!Initshowdial()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::InitUILabelDisplay error"); + return nullptr; + } + if (!InitAddOnclickevent()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::InitAddOnclickevent error"); + return nullptr; + } + return group; +} + } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/DialingScreenView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/DialingScreenView.cpp index 99808b2e9..1c11fc2eb 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/DialingScreenView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/DialingScreenView.cpp @@ -1,152 +1,154 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: DialingScreenView.cpp - * Author: - * Create: 2021-10-12 - */ -#include "wearable_log.h" -#include "UiConfig.h" -#include "DialingScreenView.h" -#include "MainCallingPresenter.h" - -namespace OHOS { -static constexpr uint16 MATH_ZERO = 0; - -// 图片显示 -static constexpr uint16 IMAGE_HANDUP_POSITION_X = 177; -static constexpr uint16 IMAGE_HANDUP_POSITION_Y = 210; - -// 来电显示 -static constexpr uint16 LABEL_ADRESS_POSITION_X = 0; -static constexpr uint16 LABEL_ADRESS_POSITION_Y = 90; -static constexpr uint16 VIEW_DISTANCE_TO_LEFT_SIDE = HORIZONTAL_RESOLUTION; -static constexpr uint16 TITLE_LABEL_DEFAULT_HEIGHT = 60; - -// 拨出时间 -static constexpr uint16 LABEL_DIALING_POSITION_X = 0; -static constexpr uint16 LABEL_DIALING_POSITION_Y = 150; - -// 当前时间 -static constexpr uint16 LABEL_CURRENT_POSITION_X = 0; -static constexpr uint16 LABEL_CURRENT_POSITION_Y = 340; - -// 字体大小 -static constexpr uint16 FONT_TIME_SIZE = 25; -static constexpr uint16 FONT_AIALING_SIZE = 40; -static constexpr uint16 FONT_CURRENT_SIZE = 20; -static DialingScreenView *g_pMainView = nullptr; -DialingScreenView::DialingScreenView() -{ - g_pMainView = this; -} - -DialingScreenView::~DialingScreenView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialingScreenView::~DialingScreenView"); - group->RemoveAll(); - delete dialingId; - dialingId = nullptr; - - delete dialingTime; - dialingTime = nullptr; - - delete currentTimes; - currentTimes = nullptr; - - delete handup; - handup = nullptr; - - delete group; - group = nullptr; - - g_pMainView = nullptr; -} - -DialingScreenView *DialingScreenView::GetInstance() -{ - return g_pMainView; -} - -bool DialingScreenView::InitUILabelDisplay() -{ - dialingId = new UILabel(); - if (dialingId == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingScreenView::new UILabel fail"); - return false; - } - dialingId->SetPosition(LABEL_ADRESS_POSITION_X, LABEL_ADRESS_POSITION_Y, - VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); - dialingId->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - dialingId->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); - dialingId->SetAlign(TEXT_ALIGNMENT_CENTER); - dialingId->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_AIALING_SIZE); - dialingId->SetTextColor(Color::White()); - group->Add(dialingId); - - dialingTime = new UILabel(); - if (dialingTime == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingScreenView::new Label fail"); - return false; - } - dialingTime->SetPosition(LABEL_DIALING_POSITION_X, LABEL_DIALING_POSITION_Y, - VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); - dialingTime->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - dialingTime->SetAlign(TEXT_ALIGNMENT_CENTER); - dialingTime->SetText(CallerLogModel::GetInstance()->GetDialingStatus().c_str()); - dialingTime->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_TIME_SIZE); - dialingTime->SetTextColor(Color::White()); - group->Add(dialingTime); - - currentTimes = new UILabel(); - if (currentTimes == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerDisplayView::new Label fail"); - return false; - } - currentTimes->SetPosition(LABEL_CURRENT_POSITION_X, LABEL_CURRENT_POSITION_Y, - VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); - currentTimes->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - currentTimes->SetAlign(TEXT_ALIGNMENT_CENTER); - currentTimes->SetText(CallerLogModel::GetInstance()->InitDateHourTime().c_str()); - currentTimes->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CURRENT_SIZE); - currentTimes->SetTextColor(Color::White()); - group->Add(currentTimes); - - return true; -} - -UIViewGroup *DialingScreenView::CreateUIViewGroup() -{ - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingScreenView::new group error"); - return nullptr; - } - group->SetPosition(MATH_ZERO, MATH_ZERO); - group->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); // 454 : value - - if (!InitUILabelDisplay()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingScreenView::InitImageViewDisplay error"); - return nullptr; - } - - handup = new UIImageView(); - if (handup == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingScreenView::new UIImageView error"); - return nullptr; - } - handup->SetPosition(IMAGE_HANDUP_POSITION_X, IMAGE_HANDUP_POSITION_Y); // 30 : offset - handup->SetSrc(PNG_DISSGREE_IMAGE_PATH); - handup->SetTouchable(true); - handup->SetViewId("dialingHandUp"); - - clickLeftListener = (UIView::OnClickListener*)OHOS::MainCallingPresenter::GetInstance(); - if (clickLeftListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingScreenView::new clickLeftListener error"); - return nullptr; - } - handup->SetOnClickListener(clickLeftListener); - group->Add(handup); - - return group; -} +/* + * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: DialingScreenView.cpp + * Author: + * Create: 2021-10-12 + */ +#include "wearable_log.h" +#include "UiConfig.h" +#include "DialingScreenView.h" +#include "MainCallingPresenter.h" + +namespace OHOS { +static constexpr uint16 MATH_ZERO = 0; + +// 图片显示 +static constexpr uint16 IMAGE_HANDUP_POSITION_X = 177; +static constexpr uint16 IMAGE_HANDUP_POSITION_Y = 210; + +// 来电显示 +static constexpr uint16 LABEL_ADRESS_POSITION_X = 0; +static constexpr uint16 LABEL_ADRESS_POSITION_Y = 90; +static constexpr uint16 VIEW_DISTANCE_TO_LEFT_SIDE = HORIZONTAL_RESOLUTION; +static constexpr uint16 TITLE_LABEL_DEFAULT_HEIGHT = 60; + +// 拨出时间 +static constexpr uint16 LABEL_DIALING_POSITION_X = 0; +static constexpr uint16 LABEL_DIALING_POSITION_Y = 150; + +// 当前时间 +static constexpr uint16 LABEL_CURRENT_POSITION_X = 0; +static constexpr uint16 LABEL_CURRENT_POSITION_Y = 340; + +// 字体大小 +static constexpr uint16 FONT_TIME_SIZE = 25; +static constexpr uint16 FONT_AIALING_SIZE = 40; +static constexpr uint16 FONT_CURRENT_SIZE = 20; +static DialingScreenView *g_pMainView = nullptr; +DialingScreenView::DialingScreenView() +{ + g_pMainView = this; +} + +DialingScreenView::~DialingScreenView() +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialingScreenView::~DialingScreenView"); + group->RemoveAll(); + delete dialingId; + dialingId = nullptr; + + delete dialingTime; + dialingTime = nullptr; + + delete currentTimes; + currentTimes = nullptr; + + delete handup; + handup = nullptr; + + delete group; + group = nullptr; + + g_pMainView = nullptr; +} + +DialingScreenView *DialingScreenView::GetInstance() +{ + return g_pMainView; +} + +bool DialingScreenView::InitUILabelDisplay() +{ + dialingId = new UILabel(); + if (dialingId == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingScreenView::new UILabel fail"); + return false; + } + dialingId->SetPosition(LABEL_ADRESS_POSITION_X, LABEL_ADRESS_POSITION_Y, + VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); + dialingId->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + + dialingId->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); + + dialingId->SetAlign(TEXT_ALIGNMENT_CENTER); + dialingId->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_AIALING_SIZE); + dialingId->SetTextColor(Color::White()); + group->Add(dialingId); + + dialingTime = new UILabel(); + if (dialingTime == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingScreenView::new Label fail"); + return false; + } + dialingTime->SetPosition(LABEL_DIALING_POSITION_X, LABEL_DIALING_POSITION_Y, + VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); + dialingTime->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + dialingTime->SetAlign(TEXT_ALIGNMENT_CENTER); + dialingTime->SetText(CallerLogModel::GetInstance()->GetDialingStatus().c_str()); + dialingTime->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_TIME_SIZE); + dialingTime->SetTextColor(Color::White()); + group->Add(dialingTime); + + currentTimes = new UILabel(); + if (currentTimes == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerDisplayView::new Label fail"); + return false; + } + currentTimes->SetPosition(LABEL_CURRENT_POSITION_X, LABEL_CURRENT_POSITION_Y, + VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); + currentTimes->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + currentTimes->SetAlign(TEXT_ALIGNMENT_CENTER); + currentTimes->SetText(CallerLogModel::GetInstance()->InitDateHourTime().c_str()); + currentTimes->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CURRENT_SIZE); + currentTimes->SetTextColor(Color::White()); + group->Add(currentTimes); + + return true; +} + +UIViewGroup *DialingScreenView::CreateUIViewGroup() +{ + group = new UIViewGroup(); + if (group == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingScreenView::new group error"); + return nullptr; + } + group->SetPosition(MATH_ZERO, MATH_ZERO); + group->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); // 454 : value + + if (!InitUILabelDisplay()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingScreenView::InitImageViewDisplay error"); + return nullptr; + } + + handup = new UIImageView(); + if (handup == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingScreenView::new UIImageView error"); + return nullptr; + } + handup->SetPosition(IMAGE_HANDUP_POSITION_X, IMAGE_HANDUP_POSITION_Y); // 30 : offset + handup->SetSrc(PNG_DISSGREE_IMAGE_PATH); + handup->SetTouchable(true); + handup->SetViewId("dialingHandUp"); + + clickLeftListener = (UIView::OnClickListener*)OHOS::MainCallingPresenter::GetInstance(); + if (clickLeftListener == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingScreenView::new clickLeftListener error"); + return nullptr; + } + handup->SetOnClickListener(clickLeftListener); + group->Add(handup); + + return group; +} } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp index ba2b91cfc..a6dd3d1dc 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp @@ -1,217 +1,480 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: MainCallingPresenter.cpp - * Author: - * Create: 2021-10-12 - */ - -#include "wearable_log.h" -#include "common/image_cache_manager.h" -#include "UiConfig.h" -#include "ui_resource_image.h" -#include "MainCallingPresenter.h" -#include "CallingView.h" -#include "CallerDisplayView.h" -#include "DialingScreenView.h" -#include "MainCallingView.h" -#include "NativeRegisterManager.h" -#include "PhoneService.h" -#include "WaitingHintsView.h" - -namespace OHOS { - -REGIST_SLICE(VIEW_MAEKPHONE_SAMPLE, MainCallingView, MainCallingPresenter); - -static MainCallingPresenter *g_pMainView = nullptr; -static constexpr int32 NUM_10 = 10; -MainCallingPresenter::MainCallingPresenter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::MainCallingPresenter"); - g_pMainView = this; -} - -MainCallingPresenter::~MainCallingPresenter() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::~MainCallingPresenter"); - RootView::GetInstance()->RemoveAll(); - if (volumeSetting != nullptr) { - delete volumeSetting; - volumeSetting = nullptr; - } - g_pMainView = nullptr; -} - -MainCallingPresenter *MainCallingPresenter::GetInstance() -{ - return g_pMainView; -} - -void MainCallingPresenter::HonrsViewChange() -{ - if (volumeSetting == nullptr) { - volumeSetting = new VolumeSettingView(); - if (volumeSetting == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::volumeSetting nullptr err"); - return; - } - if (!volumeSetting->SetUpVolume()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::volumeSetting SetUpVolume fail"); - return; - } - volumeSetting->GetProgress()->SetValue(AudioManager::GetInstance().GetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO)); - if (AudioManager::GetInstance().GetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO) == 0) { - ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_MUTE_BUTTON, PLAYER_IAMGES); - volumeSetting->GetDecreaseButton()->SetImageSrc(image, image); - } - view_->AddViewToRootContainer(volumeSetting); - } - VolumeSliderEventListener *volumeSliderEventListener = volumeSetting->GetVolumeEventListener(); - if (volumeSliderEventListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::volumeSliderEventListener nullptr err"); - return; - } - - volumeSliderEventListener->SetPlayerCoefficients(VOLUMEPHONE); // 进度条系数 - - if (!InitPointerValue()) { - return; - } - - view_->GetScreenGroup()->SetVisible(false); - view_->GetDisplayGroup()->SetVisible(false); - view_->GetCallingGroup()->SetVisible(false); - view_->GetWaitingGroup()->SetVisible(false); - - volumeSetting->SetVisible(true); - // 刷新UI - RootView::GetInstance()->Invalidate(); -} - -bool MainCallingPresenter::CallingViewDisplay() -{ - if (!InitPointerValue()) { - return false; - } - view_->GetScreenGroup()->SetVisible(false); - view_->GetDisplayGroup()->SetVisible(false); - view_->GetCallingGroup()->SetVisible(true); - view_->GetWaitingGroup()->SetVisible(false); - return true; -} - -bool MainCallingPresenter::InitPointerValue() -{ - if (CallerDisplayView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] CallerDisplayView error"); - return false; - } - - if (DialingScreenView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] DialingScreenView error"); - return false; - } - - if (CallingView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] CallingView error"); - return false; - } - - if (WaitingHintsView::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] WaitingHintsView error"); - return false; - } - - if (view_->GetScreenGroup() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] view_ GetScreenGroup error"); - return false; - } - - if (view_->GetDisplayGroup() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] view_ GetDisplayGroup error"); - return false; - } - - if (view_->GetCallingGroup() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] view_ GetCallingGroup error"); - return false; - } - - if (view_->GetWaitingGroup() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] view_ GetWaitingGroup error"); - return false; - } - return true; -} - -bool MainCallingPresenter::HintsHandupClick() -{ - if (RejectIncomingCall() != 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[HintsHandupClick] RejectIncomingCall error"); - return false; - } - CallerLogModel::GetInstance()->SetWaitingStatus(false); - CallerLogModel::GetInstance()->SetCallStatus(true); - NativeAbility::GetInstance().ChangeSlice(VIEW_MAEKPHONE_SAMPLE, TransitionType::TRANSITION_INVALID, PRIORITY_ONE); - return true; -} - -bool MainCallingPresenter::OnClick(UIView& view, const ClickEvent& event) -{ - UNUSED(event); - - if (!InitPointerValue()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::InitPointerValue error"); - return false; - } - - if (strcmp(view.GetViewId(), "microphoneChange") == 0) { - if (changeImage == 0) { - changeImage = 1; - view_->GetCallingView()->GetImageMicrophone()->SetSrc(PNG_MICROPHONE_CLOSE_IMAGE_PATH); - SetMicMute(true); - } else { - changeImage = 0; - view_->GetCallingView()->GetImageMicrophone()->SetSrc(PNG_MICROPHONE_OPEN_IMAGE_PATH); - SetMicMute(false); - } - return true; - } else if (strcmp(view.GetViewId(), "displayHandUp") == 0 || strcmp(view.GetViewId(), "callingHandUp") == 0|| - strcmp(view.GetViewId(), "dialingHandUp") == 0) { - if (strcmp(view.GetViewId(), "displayHandUp") == 0) { - // 手表拒接呼入来电 - if (RejectIncomingCall() != 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::RejectIncomingCall() fail"); - return false; - } - } - if (FinishCall() != 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::FinishCall() fail"); - return false; - } - return true; - } else if (strcmp(view.GetViewId(), "volumeSwitch") == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::honrs show"); - HonrsViewChange(); - } else if (strcmp(view.GetViewId(), "hintsHandup") == 0) { - if (!HintsHandupClick()) { - return false; - } - } else if (strcmp(view.GetViewId(), "answer") == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::phone calling"); - // 界面的显示和隐藏 - SetMicMute(false); - // 手表接听呼入来电 - if (AcceptIncomingCall() != 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::AcceptIncomingCall() fail"); - return false; - } - return true; - } - return true; -} - -VolumeSettingView *MainCallingPresenter::GetvolumeSetting() -{ - return volumeSetting; -} +/* + * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: MainCallingPresenter.cpp + * Author: + * Create: 2021-10-12 + */ + +#include "wearable_log.h" +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include "MainCallingPresenter.h" +#include "CallingView.h" +#include "CallerDisplayView.h" +#include "DialingScreenView.h" +#include "MainCallingView.h" +#include "PhoneService.h" +#include "WaitingHintsView.h" +#include "cat1_server.h" +#include "cat1_server_hal.h" +#include "custom_utils.h" + + +#include "phone/include/phoneaddressmodel.h" + + +#ifdef SUPPORT_BLE_SERVICE +#include +#include "bleService.h" +#include "bletest.h" +#endif + +#include "NativeAbility.h" + +#ifdef FD230_650 +#include "dial_sos_c.h" +#endif + +#include "soundandvibration/include/SoundAndVibrationVolumeSettingC.h" +namespace OHOS { +static MainCallingPresenter *g_pMainView = nullptr; +static constexpr int32 NUM_10 = 10; +MainCallingPresenter::MainCallingPresenter() +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::MainCallingPresenter"); + g_pMainView = this; +} + +MainCallingPresenter::~MainCallingPresenter() +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::~MainCallingPresenter"); + RootView::GetInstance()->RemoveAll(); + if (volumeSetting != nullptr) { + delete volumeSetting; + volumeSetting = nullptr; + } + g_pMainView = nullptr; +} + +MainCallingPresenter *MainCallingPresenter::GetInstance() +{ + return g_pMainView; +} + +void MainCallingPresenter::OnStart() +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::OnStart"); + + +} + +void MainCallingPresenter::OnPause(void) {} + +void MainCallingPresenter::OnResume(void) {} + +void MainCallingPresenter::OnStop(void) +{ + RootView::GetInstance()->ClearOnKeyActListener(); + +} + +void MainCallingPresenter::HonrsViewChange() +{ + if (volumeSetting == nullptr) { + volumeSetting = new VolumeSettingView(); + if (volumeSetting == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::volumeSetting nullptr err"); + return; + } + if (!volumeSetting->SetUpVolume()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::volumeSetting SetUpVolume fail"); + return; + } + volumeSetting->GetProgress()->SetValue(CallVolumeGet()); + // volumeSetting->GetProgress()->SetValue(AudioManager::GetInstance().GetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO)); + // if (AudioManager::GetInstance().GetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO) == 0) { + // ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_MUTE_BUTTON, PLAYER_IAMGES); + // volumeSetting->GetDecreaseButton()->SetImageSrc(image, image); + // } + RootView::GetInstance()->Add(volumeSetting); + } + VolumeSliderEventListener *volumeSliderEventListener = volumeSetting->GetVolumeEventListener(); + if (volumeSliderEventListener == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::volumeSliderEventListener nullptr err"); + return; + } + + volumeSliderEventListener->SetPlayerCoefficients(VOLUMEPHONE); // 进度条系数 + + if (!InitPointerValue()) { + return; + } + + view_->GetScreenGroup()->SetVisible(false); + view_->GetDisplayGroup()->SetVisible(false); + view_->GetCallingGroup()->SetVisible(false); + view_->GetWaitingGroup()->SetVisible(false); + + volumeSetting->SetVisible(true); + // 刷新UI + RootView::GetInstance()->Invalidate(); +} + +bool MainCallingPresenter::CallingViewDisplay() +{ + if (!InitPointerValue()) { + return false; + } + view_->GetScreenGroup()->SetVisible(false); + view_->GetDisplayGroup()->SetVisible(false); + view_->GetCallingGroup()->SetVisible(true); + view_->GetWaitingGroup()->SetVisible(false); + return true; +} + +bool MainCallingPresenter::InitPointerValue() +{ + if (CallerDisplayView::GetInstance() == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] CallerDisplayView error"); + return false; + } + + // if (DialingScreenView::GetInstance() == nullptr) { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] DialingScreenView error"); + // return false; + // } + + if (CallingView::GetInstance() == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] CallingView error"); + return false; + } + + if (WaitingHintsView::GetInstance() == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] WaitingHintsView error"); + return false; + } + + if (view_->GetScreenGroup() == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] view_ GetScreenGroup error"); + return false; + } + + if (view_->GetDisplayGroup() == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] view_ GetDisplayGroup error"); + return false; + } + + if (view_->GetCallingGroup() == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] view_ GetCallingGroup error"); + return false; + } + + if (view_->GetWaitingGroup() == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[InitPointerValue] view_ GetWaitingGroup error"); + return false; + } + return true; +} + +bool MainCallingPresenter::HintsHandupClick() +{ + if (RejectIncomingCall() != 0) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[HintsHandupClick] RejectIncomingCall error"); + return false; + } + CallerLogModel::GetInstance()->SetWaitingStatus(false); + CallerLogModel::GetInstance()->SetCallStatus(true); + NativeAbility::GetInstance().ChangeSlice(VIEW_INCOMING_CALL, TransitionType::TRANSITION_INVALID, PRIORITY_ONE); + return true; +} + +bool MainCallingPresenter::OnClick(UIView& view, const ClickEvent& event) +{ + #ifdef FD230_650 + UNUSED(event); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",view.GetViewId()); + if (!InitPointerValue()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::InitPointerValue error"); + return false; + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",view.GetViewId()); + if (strcmp(view.GetViewId(), "microphoneChange") == 0) { + if (changeImage == 0) { + changeImage = 1; + if(CallerLogModel::GetInstance()->GetCallStatus()) + { + view_->GetCallingView()->GetImageMicrophone()->SetSrc(PNG_230_MICROPHONE_CLOSE_IMAGE_PATH); + + } + else + { + return false; + view_->GetScreenView()->GetImageMicrophone()->SetSrc(PNG_230_MICROPHONE_CLOSE_IMAGE_PATH); + } + if(CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1) + { + SetMicMutecat1(true); + } + else + { + SetMicMute(true); + } + + + } else { + changeImage = 0; + if(CallerLogModel::GetInstance()->GetCallStatus()) + { + view_->GetCallingView()->GetImageMicrophone()->SetSrc(PNG_230_MICROPHONE_OPEN_IMAGE_PATH); + + } + else + { + return false; + view_->GetScreenView()->GetImageMicrophone()->SetSrc(PNG_230_MICROPHONE_OPEN_IMAGE_PATH); + } + if(CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1) + { + SetMicMutecat1(false); + } + else + { + SetMicMute(false); + } + } + return true; + } else if (strcmp(view.GetViewId(), "displayHandUp") == 0 || strcmp(view.GetViewId(), "callingHandUp") == 0|| + strcmp(view.GetViewId(), "dialingHandUp") == 0) { + if(strcmp(view.GetViewId(), "callingHandUp") == 0 || strcmp(view.GetViewId(), "dialingHandUp") == 0) + { + if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1) + { + + { + sos_falg_clean(); + } + + //cat1_handle_call_disconnected((char *)CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); + + cat1_call_hungup_timer(); + + + } + else + { + if (FinishCall() != 0) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::FinishCall() fail"); + return false; + } + } + return true; + } + if (strcmp(view.GetViewId(), "displayHandUp") == 0) + { + if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1) + { + //cat1_handle_call_disconnected((char *)CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); + cat1_call_hungup_timer(); + return true; + //#endif + + } + else + { + // 手表拒接呼入来电 + if (RejectIncomingCall() != 0) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::RejectIncomingCall() fail"); + return false; + } + } + } + if (FinishCall() != 0) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::FinishCall() fail"); + return false; + } + return true; + + } else if (strcmp(view.GetViewId(), "volumeSwitch") == 0) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::honrs show"); + HonrsViewChange(); + } else if (strcmp(view.GetViewId(), "hintsHandup") == 0) + { + + if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1) + { + //cat1_handle_call_disconnected((char *)CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); + cat1_call_hungup_timer(); + + return true; + //#endif + + }else + { + if (!HintsHandupClick()) + { + return false; + } + } + + + + + } else if (strcmp(view.GetViewId(), "answer") == 0) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::phone calling"); + if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MakephoneNotify 11111111 "); + cat1_call_answer(); + //incomedcall_event_sendmsg_toUI("ok"); + + return true; + + //#endif + } + else + { + // 界面的显示和隐藏 + SetMicMute(false); + + // 手表接听呼入来电 + if (AcceptIncomingCall() != 0) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::AcceptIncomingCall() fail"); + return false; + } + return true; + + } + + + } + else if ((strcmp(view.GetViewId(), "dial") == 0)) + { + if(view_->GetScreenGroup()->IsVisible()) + view_->GetScreenView()->showdial(true); + else + view_->GetCallingView()->showdial(true); + } + + if (strcmp(view.GetViewId(), "0") == 0) + { + if(view_->GetScreenGroup()->IsVisible()) + view_->GetScreenView()->text_updata_buf(view.GetViewId()); + else + view_->GetCallingView()->text_updata_buf(view.GetViewId()); + } + else if (strcmp(view.GetViewId(), "1") == 0) + { + if(view_->GetScreenGroup()->IsVisible()) + view_->GetScreenView()->text_updata_buf(view.GetViewId()); + else + view_->GetCallingView()->text_updata_buf(view.GetViewId()); + } + else if (strcmp(view.GetViewId(), "2") == 0) + { + if(view_->GetScreenGroup()->IsVisible()) + view_->GetScreenView()->text_updata_buf(view.GetViewId()); + else + view_->GetCallingView()->text_updata_buf(view.GetViewId()); + } + else if (strcmp(view.GetViewId(), "3") == 0) + { + if(view_->GetScreenGroup()->IsVisible()) + view_->GetScreenView()->text_updata_buf(view.GetViewId()); + else + view_->GetCallingView()->text_updata_buf(view.GetViewId()); + } + else if (strcmp(view.GetViewId(), "4") == 0) + { + if(view_->GetScreenGroup()->IsVisible()) + view_->GetScreenView()->text_updata_buf(view.GetViewId()); + else + view_->GetCallingView()->text_updata_buf(view.GetViewId()); + } + else if (strcmp(view.GetViewId(), "5") == 0) + { + if(view_->GetScreenGroup()->IsVisible()) + view_->GetScreenView()->text_updata_buf(view.GetViewId()); + else + view_->GetCallingView()->text_updata_buf(view.GetViewId()); + } + else if (strcmp(view.GetViewId(), "6") == 0) + { + if(view_->GetScreenGroup()->IsVisible()) + view_->GetScreenView()->text_updata_buf(view.GetViewId()); + else + view_->GetCallingView()->text_updata_buf(view.GetViewId()); + } + else if (strcmp(view.GetViewId(), "7") == 0) + { + if(view_->GetScreenGroup()->IsVisible()) + view_->GetScreenView()->text_updata_buf(view.GetViewId()); + else + view_->GetCallingView()->text_updata_buf(view.GetViewId()); + } + else if (strcmp(view.GetViewId(), "8") == 0) + { + if(view_->GetScreenGroup()->IsVisible()) + view_->GetScreenView()->text_updata_buf(view.GetViewId()); + else + view_->GetCallingView()->text_updata_buf(view.GetViewId()); + } + else if (strcmp(view.GetViewId(), "9") == 0) + { + if(view_->GetScreenGroup()->IsVisible()) + view_->GetScreenView()->text_updata_buf(view.GetViewId()); + else + view_->GetCallingView()->text_updata_buf(view.GetViewId()); + + }else if (strcmp(view.GetViewId(), "*") == 0) + { + if(view_->GetScreenGroup()->IsVisible()) + view_->GetScreenView()->text_updata_buf(view.GetViewId()); + else + view_->GetCallingView()->text_updata_buf(view.GetViewId()); /* code */ + } + else if (strcmp(view.GetViewId(), "#") == 0) + { + if(view_->GetScreenGroup()->IsVisible()) + view_->GetScreenView()->text_updata_buf(view.GetViewId()); + else + view_->GetCallingView()->text_updata_buf(view.GetViewId()); + } + else if (strcmp(view.GetViewId(), "callingheadset") == 0) + { + NativeAbility::GetInstance().EnterSlice(VIEW_BLUETOOTH_EARPHONE); + } + +#endif + return true; +} + +bool MainCallingPresenter::OnDragEnd(OHOS::UIView& view, const OHOS::DragEvent& event) +{ + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter OnDragEnd"); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) + { + + if((strcmp(view.GetViewId(), "dialing") == 0)) + { + if(view_->GetScreenGroup()->IsVisible()) + view_->GetScreenView()->showdial(false); + else + view_->GetCallingView()->showdial(false); + } + + } + return true; +} + +bool MainCallingPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 +{ + return true; +} + +VolumeSettingView *MainCallingPresenter::GetvolumeSetting() +{ + return volumeSetting; +} } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/MainCallingView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/MainCallingView.cpp index c4e6af6ac..a7fe86808 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/MainCallingView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/MainCallingView.cpp @@ -1,152 +1,207 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: MainCallingView.cpp - * Author: - * Create: 2021-10-12 - */ -#include "wearable_log.h" -#include "UiConfig.h" -#include "MainCallingView.h" -#include "MainCallingPresenter.h" -#include "CallerLogModel.h" - -namespace OHOS { -static MainCallingView *g_pMainView = nullptr; -MainCallingView::MainCallingView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingView::MainCallingView"); - g_pMainView = this; -} - -MainCallingView::~MainCallingView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingView::~MainCallingView"); - delete displayView; - displayView = nullptr; - - delete callView; - callView = nullptr; - - delete screenView; - screenView = nullptr; - - g_pMainView = nullptr; -} - -MainCallingView *MainCallingView::GetInstance() -{ - return g_pMainView; -} - -UIViewGroup *MainCallingView::GetDisplayGroup() -{ - return displayGroup; -} - -UIViewGroup *MainCallingView::GetCallingGroup() -{ - return callingGroup; -} - -UIViewGroup *MainCallingView::GetScreenGroup() -{ - return screenGroup; -} - -UIViewGroup *MainCallingView::GetWaitingGroup() -{ - return waitingGroup; -} - -CallingView *MainCallingView::GetCallingView() -{ - return callView; -} - -bool MainCallingView::InitPointerValue() -{ - displayView = new CallerDisplayView(); - if (displayView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::displayView"); - return false; - } - - displayGroup = displayView->CreateUIViewGroup(); - if (displayGroup == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::displayGroup"); - return false; - } - - callView = new CallingView(); - if (callView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::callView"); - return false; - } - - callingGroup = callView->CreateUIViewGroup(); - if (callingGroup == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::callingGroup"); - return false; - } - - screenView = new DialingScreenView(); - if (screenView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::screenView"); - return false; - } - - screenGroup = screenView->CreateUIViewGroup(); - if (screenGroup == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::screenGroup"); - return false; - } - - waitingView = new WaitingHintsView(); - if (waitingView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::WaitingHintsView"); - return false; - } - - waitingGroup = waitingView->CreateUIViewGroup(); - if (waitingGroup == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::waitingGroup"); - return false; - } - return true; -} - -void MainCallingView::OnStart() -{ - - if (!InitPointerValue()) { - return; - } - - AddViewToRootContainer(displayGroup); - AddViewToRootContainer(callingGroup); - AddViewToRootContainer(screenGroup); - AddViewToRootContainer(waitingGroup); - - waitingGroup->SetVisible(false); - callingGroup->SetVisible(false); - if (CallerLogModel::GetInstance()->GetCallStatus()) { - displayGroup->SetVisible(false); - callingGroup->SetVisible(true); - screenGroup->SetVisible(false); - } else if (CallerLogModel::GetInstance()->GetWaitingStatus()) { - screenGroup->SetVisible(false); - displayGroup->SetVisible(false); - waitingGroup->SetVisible(true); - } else if (CallerLogModel::GetInstance()->GetPhoneStatus()) { - displayGroup->SetVisible(false); - } else { - screenGroup->SetVisible(false); - } - CallerLogModel::GetInstance()->SetVolumeScreenStatus(false); - if (CallerLogModel::GetInstance()->GetMulitplePhoneStatus()) { - MulitplePhoneTextReplaces(); - CallerLogModel::GetInstance()->SetMulitplePhoneStatus(false); - } - return; -} +/* + * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: MainCallingView.cpp + * Author: + * Create: 2021-10-12 + */ +#include "wearable_log.h" +#include "UiConfig.h" +#include "MainCallingView.h" +#include "MainCallingPresenter.h" +#include "CallerLogModel.h" + +namespace OHOS { +static MainCallingView *g_pMainView = nullptr; +MainCallingView::MainCallingView() +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingView::MainCallingView"); + g_pMainView = this; +} + +MainCallingView::~MainCallingView() +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingView::~MainCallingView"); + delete displayView; + displayView = nullptr; + + delete callView; + callView = nullptr; + + delete screenView; + screenView = nullptr; + + delete waitingView; + waitingView = nullptr; + + + + g_pMainView = nullptr; +} + +MainCallingView *MainCallingView::GetInstance() +{ + return g_pMainView; +} + +UIViewGroup *MainCallingView::GetDisplayGroup() +{ + return displayGroup; +} + +UIViewGroup *MainCallingView::GetCallingGroup() +{ + return callingGroup; +} + +UIViewGroup *MainCallingView::GetScreenGroup() +{ + return screenGroup; +} + +UIViewGroup *MainCallingView::GetWaitingGroup() +{ + return waitingGroup; +} + +CallingView *MainCallingView::GetCallingView() +{ + return callView; +} + +CallingView *MainCallingView::GetScreenView() +{ + return screenView; +} + +bool MainCallingView::InitPointerValue() +{ + displayView = new CallerDisplayView(); + if (displayView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::displayView"); + return false; + } + + displayGroup = displayView->CreateUIViewGroup(); + if (displayGroup == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::displayGroup"); + return false; + } + + + screenView = new CallingView(); + if (screenView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::screenView"); + return false; + } + + callView = new CallingView(); + if (callView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::callView"); + return false; + } + + callingGroup = callView->CreateUIViewGroup(); + if (callingGroup == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::callingGroup"); + return false; + } + + + screenGroup = screenView->CreateUIViewGroup(0); + if (screenGroup == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::screenGroup"); + return false; + } + + waitingView = new WaitingHintsView(); + if (waitingView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::WaitingHintsView"); + return false; + } + + waitingGroup = waitingView->CreateUIViewGroup(); + if (waitingGroup == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingView::waitingGroup"); + return false; + } + return true; +} + +void MainCallingView::updataCallingname(void) +{ + //if(CallerLogModel::GetInstance()->Getphonename().length()>5) + if(strcmp(CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),CallerLogModel::GetInstance()->Getphonenumberpbap().c_str())==0) + { + if(CallerLogModel::GetInstance()->Getphonename().length()!=0) + { + if(screenView) + screenView->updataCallingname(); + if(callView) + callView->updataCallingname(); + if(displayView) + displayView->updataCallingname(); + + RootView::GetInstance()->Invalidate(); + + //callerDisplay->SetText(CallerLogModel::GetInstance()->Getphonename().c_str()); + } + + + } +} + +void MainCallingView::update_headset_state(uint8_t data) +{ + if(callView) + { + callView->update_headset_state(data); + RootView::GetInstance()->Invalidate(); + } + +} + + + +void MainCallingView::OnStart() +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingView::OnStart"); + + + if (InitPointerValue() == false) { + return; + } + + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::MainCallingPresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); + + RootView::GetInstance()->Add(displayGroup); + RootView::GetInstance()->Add(callingGroup); + RootView::GetInstance()->Add(screenGroup); + RootView::GetInstance()->Add(waitingGroup); + + waitingGroup->SetVisible(false); + callingGroup->SetVisible(false); + if (CallerLogModel::GetInstance()->GetCallStatus()) { + displayGroup->SetVisible(false); + callingGroup->SetVisible(true); + screenGroup->SetVisible(false); + } else if (CallerLogModel::GetInstance()->GetWaitingStatus()) { + screenGroup->SetVisible(false); + displayGroup->SetVisible(false); + waitingGroup->SetVisible(true); + } else if (CallerLogModel::GetInstance()->GetPhoneStatus()) { + displayGroup->SetVisible(false); + } else { + screenGroup->SetVisible(false); + } + CallerLogModel::GetInstance()->SetVolumeScreenStatus(false); + + if (CallerLogModel::GetInstance()->GetMulitplePhoneStatus()) { + MulitplePhoneTextReplaces(); + CallerLogModel::GetInstance()->SetMulitplePhoneStatus(false); + } + + return; +} + } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/WaitingHintsView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/WaitingHintsView.cpp index e27e55dbc..580011a98 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/WaitingHintsView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/WaitingHintsView.cpp @@ -1,120 +1,274 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: WaitingHintsView.cpp - * Author: - * Create: 2022-03-14 - */ -#include "WaitingHintsView.h" -#include "UiConfig.h" -#include "CallerLogModel.h" -#include "MainCallingPresenter.h" - -namespace OHOS { -static constexpr uint16 MATH_ZERO = 0; -// 挂断按钮位置 -static constexpr uint16 IMAGE_HANDUP_POSITION_X = 177; -static constexpr uint16 IMAGE_HANDUP_POSITION_Y = 270; - -// 新来电显示 -static constexpr uint16 LABEL_PERCENT_POSITION_X = 0; -static constexpr uint16 LABEL_PERCENT_POSITION_Y = 100; - -static constexpr uint16 VIEW_DISTANCE_TO_LEFT_SIDE = HORIZONTAL_RESOLUTION; -static constexpr uint16 TITLE_LABEL_DEFAULT_HEIGHT = 80; - -// 字体大小 -static constexpr uint16 LABEL_DISPLAY_FONE_SIZE = 40; - -// 标签坐标 -static constexpr uint16 LABEL_CALLERD_POSITION_X = 0; -static constexpr uint16 LABEL_CALLERD_POSITION_Y = 180; - -static WaitingHintsView *g_pMainView = nullptr; -WaitingHintsView::WaitingHintsView() -{ - g_pMainView = this; -} - -WaitingHintsView::~WaitingHintsView() -{ - g_pMainView = nullptr; -} - -UIViewGroup *WaitingHintsView::CreateUIViewGroup() -{ - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WaitingHintsView::new group error"); - return nullptr; - } - group->SetPosition(MATH_ZERO, MATH_ZERO); - group->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); // 454 : value - - if (!InitImageViewDisplay()) { - return nullptr; - } - if (!InitUILabelDisplay()) { - return nullptr; - } - return group; -} - -WaitingHintsView *WaitingHintsView::GetInstance() -{ - return g_pMainView; -} - -bool WaitingHintsView::InitImageViewDisplay() -{ - imageDissgree = new UIImageView(); - if (imageDissgree == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WaitingHintsView::new imageDissgree error"); - return false; - } - imageDissgree->SetPosition(IMAGE_HANDUP_POSITION_X, IMAGE_HANDUP_POSITION_Y); // 30 : offset - imageDissgree->SetSrc(PNG_DISSGREE_IMAGE_PATH); - imageDissgree->SetTouchable(true); - imageDissgree->SetViewId("hintsHandup"); - - clickLeftListener = (UIView::OnClickListener*)OHOS::MainCallingPresenter::GetInstance(); - if (clickLeftListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WaitingHintsView::new clickLeftListener error"); - return false; - } - imageDissgree->SetOnClickListener(clickLeftListener); - group->Add(imageDissgree); - return true; -} - -bool WaitingHintsView::InitUILabelDisplay() -{ - callerDisplay = new UILabel(); - if (callerDisplay == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WaitingHintsView::new callerDisplay error"); - return false; - } - callerDisplay->SetPosition(LABEL_PERCENT_POSITION_X, LABEL_PERCENT_POSITION_Y, - VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); - callerDisplay->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - callerDisplay->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); - callerDisplay->SetAlign(TEXT_ALIGNMENT_CENTER); - callerDisplay->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_DISPLAY_FONE_SIZE); - callerDisplay->SetTextColor(Color::White()); - group->Add(callerDisplay); - - newcallHints = new UILabel(); - if (newcallHints == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WaitingHintsView::new newcallHints error"); - return false; - } - newcallHints->SetPosition(LABEL_CALLERD_POSITION_X, LABEL_CALLERD_POSITION_Y, - VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); - newcallHints->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - newcallHints->SetText("新来电"); - newcallHints->SetAlign(TEXT_ALIGNMENT_CENTER); - newcallHints->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_DISPLAY_FONE_SIZE); - newcallHints->SetTextColor(Color::White()); - group->Add(newcallHints); - return true; -} +/* + * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. + * Description: WaitingHintsView.cpp + * Author: + * Create: 2022-03-14 + */ +#include "WaitingHintsView.h" +#include "UiConfig.h" +#include "CallerLogModel.h" +#include "MainCallingPresenter.h" +#include "ui_resource_string.h" + +#ifdef SUPPORT_BLE_SERVICE +#include +#include "bleService.h" +#include "bletest.h" +#endif + +#include "custom_utils.h" + +#include "wearable_log.h" +#include "PhoneService.h" +#include "cat1_server.h" +#include "cat1_server_hal.h" + +#include "phone/include/phoneaddressmodel.h" + + + + + +#define PHONE_DIR_GIRL_1 "/user/res/Phone/girl.bin" +#define PHONE_DIR_BOY_1 "/user/res/Phone/boy.bin" +namespace OHOS { +static constexpr uint16 MATH_ZERO = 0; +// 挂断按钮位置 +static constexpr uint16 IMAGE_HANDUP_POSITION_X = 177; +static constexpr uint16 IMAGE_HANDUP_POSITION_Y = 270; + +// 新来电显示 +static constexpr uint16 LABEL_PERCENT_POSITION_X = 0; +static constexpr uint16 LABEL_PERCENT_POSITION_Y = 100; + +static constexpr uint16 VIEW_DISTANCE_TO_LEFT_SIDE = HORIZONTAL_RESOLUTION; +static constexpr uint16 TITLE_LABEL_DEFAULT_HEIGHT = 80; + +// 字体大小 +static constexpr uint16 LABEL_DISPLAY_FONE_SIZE = 40; + +// 标签坐标 +static constexpr uint16 LABEL_CALLERD_POSITION_X = 0; +static constexpr uint16 LABEL_CALLERD_POSITION_Y = 180; + +static WaitingHintsView *g_pMainView = nullptr; + +// 字体大小 +static constexpr uint16 LABEL_TIME_FONT_SIZE = 25; + + +WaitingHintsView::WaitingHintsView() +{ + g_pMainView = this; +} + +WaitingHintsView::~WaitingHintsView() +{ + group->RemoveAll(); + + delete imageAgreeing; + imageAgreeing = nullptr; + + delete imageDissgree; + imageDissgree = nullptr; + + + delete imageperson; + imageperson = nullptr; + + delete callerDisplay; + callerDisplay = nullptr; + + delete label_call_source; + label_call_source = nullptr; + + delete currentTimes; + currentTimes = nullptr; + + delete label_call_hint; + label_call_hint = nullptr; + + delete group; + group = nullptr; + + g_pMainView = nullptr; + +} + +void WaitingHintsView::updataCallingname(void) +{ + if(strcmp(CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),CallerLogModel::GetInstance()->Getphonenumberpbap().c_str())==0) + { + if(CallerLogModel::GetInstance()->Getphonename().length()!=0) + callerDisplay->SetText(CallerLogModel::GetInstance()->Getphonename().c_str()); + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "updataCallingname 000000000000"); + } +} + + + +UIViewGroup *WaitingHintsView::CreateUIViewGroup() +{ + group = new UIViewGroup(); + if (group == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WaitingHintsView::new group error"); + return nullptr; + } + group->SetPosition(MATH_ZERO, MATH_ZERO); + group->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); // 454 : value + + if (!InitImageViewDisplay()) { + return nullptr; + } + if (!InitUILabelDisplay()) { + return nullptr; + } + return group; +} + +bool WaitingHintsView::InitAddOnclickevent() +{ + clickLeftListener = (UIView::OnClickListener*)OHOS::MainCallingPresenter::GetInstance(); + if (clickLeftListener == nullptr) { + return false; + } + imageAgreeing->SetOnClickListener(clickLeftListener); + imageDissgree->SetOnClickListener(clickLeftListener); + return true; +} + +WaitingHintsView *WaitingHintsView::GetInstance() +{ + return g_pMainView; +} + +bool WaitingHintsView::InitImageViewDisplay() +{ + imageAgreeing = new UIImageView(); + if (imageAgreeing == nullptr) { + return false; + } + imageAgreeing->SetPosition(369, 207); // 30 : offset + imageAgreeing->SetSrc(PNG_ANSWER_230_TMAGE_PATH); + imageAgreeing->SetTouchable(true); + imageAgreeing->SetViewId("answer"); + //group->Add(imageAgreeing); + + imageDissgree = new UIImageView(); + if (imageDissgree == nullptr) { + return false; + } + imageDissgree->SetPosition(46, 207); // 30 : offset + imageDissgree->SetSrc(PNG_HANDUP_230_IMAGE_PATH); + imageDissgree->SetTouchable(true); + imageDissgree->SetViewId("hintsHandup"); + //group->Add(imageDissgree); + + imageperson = new UIImageView(); + if (imageperson == nullptr) { + return false; + } + imageperson->SetPosition(158, 158); // 30 : offset + imageperson->SetSrc(PNG_230_PERSON_IMAGE_PATH); + imageperson->SetTouchable(true); + imageperson->SetViewId("headset"); + + char name_buf[NAME_LEN+1]={0}; + uint8_t sex; + if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),&sex)) + { + if(sex==1) + imageperson->SetSrc(PHONE_DIR_BOY_1); + else + imageperson->SetSrc(PHONE_DIR_GIRL_1); + } + + group->Add(imageperson); + InitAddOnclickevent(); + return true; +} + +bool WaitingHintsView::InitUILabelDisplay() +{ + callerDisplay = new UILabelExt(); + if (callerDisplay == nullptr) { + return false; + } + callerDisplay->SetPosition(LABEL_PERCENT_POSITION_X, LABEL_PERCENT_POSITION_Y, VIEW_DISTANCE_TO_LEFT_SIDE, + TITLE_LABEL_DEFAULT_HEIGHT); + callerDisplay->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + + char name_buf[NAME_LEN+1]={0}; + if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),NULL)) + { + callerDisplay->SetText(name_buf); + } + else + { + callerDisplay->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); + } + // if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourcePhone) + updataCallingname(); + + callerDisplay->SetAlign(TEXT_ALIGNMENT_CENTER); + callerDisplay->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + callerDisplay->SetTextColor(Color::White()); + callerDisplay->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + group->Add(callerDisplay); + + if (label_call_hint == nullptr) { + label_call_hint = new UILabelExt(); + } + + label_call_hint->SetPosition(133, 353); // widget's left position and top position + label_call_hint->Resize(200, 35); // widget's width and height + label_call_hint->SetViewId("label3");// Set style + label_call_hint->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + // label_call_hint->SetText("挂断/接听"); + label_call_hint->SetTextId(STR_HANG_UP_OR_ANSWER); + + label_call_hint->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + label_call_hint->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_call_hint->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_call_hint->SetRollSpeed(0); + label_call_hint->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + group->Add(label_call_hint); + + + if (label_call_source == nullptr) { + label_call_source = new UILabelExt(); + } + label_call_source->SetPosition(133, 34); // widget's left position and top position + label_call_source->Resize(200, 60); // widget's width and height + label_call_source->SetViewId("label1");// Set style + label_call_source->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1) + { + // label_call_source->SetText("手表来电"); + label_call_source->SetTextId(STR_WATCH_CALL); + } + else + { + // label_call_source->SetText("手机来电"); + label_call_source->SetTextId(STR_PHONE_CALL); + } + + + label_call_source->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + label_call_source->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_call_source->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_call_source->SetRollSpeed(0); + label_call_source->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + group->Add(label_call_source); + + return true; + +} } \ No newline at end of file