*/
#include "phone/include/MainPhoneView.h"
#include "phone/include/MainPhonePresenter.h"
+#include "components/ui_label_button_ext.h"
#include "wearable_log.h"
namespace OHOS
return g_pMainPhoneView;
}
+ UILabelButtonExt *MainPhoneView::SetTheButton_ext(MainPhoneView_ButtonConfig_ext_t &buttonconfig, UIView::OnClickListener *clickListener)
+ {
+ UILabelButtonExt *button = new UILabelButtonExt();
+ if (button == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: button new fail!");
+ return nullptr;
+ }
+ button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h);
+ button->SetViewId(buttonconfig.ViewId);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "----------%s ---",buttonconfig.ViewId);
+ button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+ if(clickListener!=NULL)
+ button->SetOnClickListener(clickListener);
+
+ button->SetText(buttonconfig.str);
+ button->SetAlign(TEXT_ALIGNMENT_LEFT);
+ button->SetLabelPosition(50,-23);
+ button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35);
+
+ return button;
+ }
+
+
void MainPhoneView::ClearAll(void)
{
if (MainPhoneViewScrollView != nullptr)
delete TelephoneLineImageView;
TelephoneLineImageView = nullptr;
- delete NoCallsLabel;
- NoCallsLabel = nullptr;
+ if(NoCallsLabel)
+ {
+ delete NoCallsLabel;
+ NoCallsLabel = nullptr;
+ }
+
+ for(int i=0;i<20;i++)
+ {
+ if(button_calllog[i])
+ {
+ delete button_calllog[i];
+ button_calllog[i] = nullptr;
+ }
+ }
+
+ for(int i=0;i<20;i++)
+ {
+ if(button_calllog_time[i])
+ {
+ delete button_calllog_time[i];
+ button_calllog_time[i] = nullptr;
+ }
+ }
+
+ for(int i=0;i<20;i++)
+ {
+ if(button_calllog_status[i])
+ {
+ delete button_calllog_status[i];
+ button_calllog_status[i] = nullptr;
+ }
+ }
+
+ if(hintCallsLabel)
+ {
+ delete hintCallsLabel;
+ hintCallsLabel = nullptr;
+ }
delete MainPhoneViewScrollView;
MainPhoneViewScrollView = nullptr;
}
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::ClearAll success!!");
}
+ static int32 num = 0;
void MainPhoneView::MainPhoneViewInit(void)
{
return;
}
/* ------------------------------ NoCallsLabel ------------------------------ */
+ info = new CallLogInfo[sizeof(CallLogInfo) * CALL_LOG_MAX_NUM];
+ if (GetCallLog(&info, &num) == -1) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogModel::GetInstance()->ListIsEmpty");
+ return;
+ }
+
+ MainPhoneView_ButtonConfig_ext_t buttonconfig;
+ buttonconfig.x = 38;
+ buttonconfig.y = 360;
+ buttonconfig.w = 390;
+ buttonconfig.h = 104;
+ buttonconfig.ViewId="xxxx";
+
labelParam = {
+ .x = 94,
+ .y = 420,
+ .width = 160,
+ .height = 35,
+ .fontSize = 23,
+ .lineHeigh = 0,
+ .text = "2023-1-23 14:22",
+ .lineBreakMode = UILabel::LINE_BREAK_ADAPT,
+ };
+
+
+ if (num != 0) {
+
+ for (int i = num; i != 0; i--) {
+
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",(info + i - 1)->tel);
+ char buf[20]={0};
+ sprintf_s(buf,20,"%s",(const char*)(info + i - 1)->tel);
+ buttonconfig.str=buf;
+ button_calllog[i]=SetTheButton_ext(buttonconfig,NULL);
+ if(button_calllog[i]==nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::button_calllog new fail!");
+ }
+ buttonconfig.y += 20+104;
+ MainPhoneViewScrollView->Add(button_calllog[i]);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",(info + i - 1)->tel);
+
+ time_t currtime;
+ struct tm *timeinfo;
+ currtime=(info + i - 1)->creationTime;
+ timeinfo = localtime(&currtime);
+ char time_buf[20]={0};
+
+ labelParam.x=94,
+ labelParam.text=time_buf;
+ sprintf_s(time_buf,20 ,"%d-%d-%d %d:%d", timeinfo->tm_year + 1900,timeinfo->tm_mon + 1,timeinfo->tm_mday,timeinfo->tm_hour,timeinfo->tm_min);
+
+
+ button_calllog_time[i] = TelephonyInitInterface::LabelViewInit(labelParam,Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff));
+ if (button_calllog_time[i] == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::MainPhoneViewTitleLabel new fail!");
+ }
+ MainPhoneViewScrollView->Add(button_calllog_time[i]);
+
+ labelParam.fontSize=18;
+ labelParam.x=286;
+
+
+ ColorType color;
+
+ if((info + i - 1)->status==CALL_MISSED)
+ {
+ labelParam.text="未接来电";
+ color=Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff);
+ }
+ else if((info + i - 1)->status==CALL_INCOMING)
+ {
+ labelParam.text="拨入电话";
+ color=Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff);
+ }
+ else if((info + i - 1)->status==CALL_OUTGOING)
+ {
+ labelParam.text="拨出电话";
+ color=Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff);
+ }
+
+
+ button_calllog_status[i] = TelephonyInitInterface::LabelViewInit(labelParam,color);
+ if (button_calllog_status[i] == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::MainPhoneViewTitleLabel new fail!");
+ }
+ MainPhoneViewScrollView->Add(button_calllog_status[i]);
+
+ labelParam.y += 20+104;
+ }
+ labelParam.x = 83;
+ labelParam.y -= 50;
+ labelParam.width = 300;
+ labelParam.height = 100;
+ labelParam.fontSize = 22;
+ labelParam.lineHeigh = 15;
+ labelParam.text = "注:只保留最近20条通话记录";
+ labelParam.lineBreakMode = UILabel::LINE_BREAK_MARQUEE,
+
+
+ hintCallsLabel = TelephonyInitInterface::LabelViewInit(labelParam,Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff));
+ if (hintCallsLabel == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::MainPhoneViewTitleLabel new fail!");
+ }
+
+ MainPhoneViewScrollView->Add(hintCallsLabel);
+ }
+ else
+ {
+ labelParam = {
.x = 83,
.y = 363,
.width = 300,
.lineHeigh = 40,
.text = "暂无通话",
.lineBreakMode = UILabel::LINE_BREAK_MARQUEE,
- };
- NoCallsLabel = TelephonyInitInterface::LabelViewInit(labelParam);
- if (NoCallsLabel == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::NoCallsLabel new fail!");
- return;
+ };
+ NoCallsLabel = TelephonyInitInterface::LabelViewInit(labelParam);
+ if (NoCallsLabel == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::NoCallsLabel new fail!");
+ return;
+ }
+ NoCallsLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff));
+ NoCallsLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+
}
- NoCallsLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff));
- NoCallsLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+
+
+
/* -------------------------------------------------------------------------- */
}
}
MainPhoneViewScrollView->Add(FrequentlyContactedButton);
MainPhoneViewScrollView->Add(RecentCallLabel);
MainPhoneViewScrollView->Add(TelephoneLineImageView);
+
+ if(NoCallsLabel)
MainPhoneViewScrollView->Add(NoCallsLabel);
+
RootView::GetInstance()->Add(MainPhoneViewScrollView);
Draw();
}