\r
#include "phone/include/PhoneDirView.h"\r
\r
-#include "common/image_cache_manager.h"\r
-#include "UiConfig.h"\r
-#include "ui_resource_image.h"\r
-#include <ui_scroll_view.h>\r
-#include "components/ui_button.h"\r
-#include "components/ui_label_button.h"\r
+#include "phone/include/phoneaddressmodel.h"\r
+#define PHONE_DIR_GIRL "/user/res/Phone/little-girl.bin"\r
+#define PHONE_DIR_BOY "/user/res/Phone/little-boy.bin"\r
+#define PHONE_DIR_GIRL_1 "/user/res/Phone/girl.bin"\r
+#define PHONE_DIR_BOY_1 "/user/res/Phone/boy.bin"\r
namespace OHOS\r
{\r
\r
static PhoneDirView *g_pPhoneDirView{nullptr};\r
\r
+ extern addressbook addressbook_t;\r
PhoneDirView::PhoneDirView()\r
{\r
\r
\r
PhoneDirView *PhoneDirView::GetInstance()\r
{\r
-\r
return g_pPhoneDirView;\r
}\r
-#if 0\r
- void PhoneDirView::Init()\r
+ static char *number_str[]={"0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"};\r
+ UILabelButtonExt *PhoneDirView::SetTheButton_ext(ButtonConfig_ext_t &buttonconfig, UIView::OnClickListener *clickListener)\r
{\r
- if (container_ == nullptr)\r
- {\r
- container_ = new UIViewGroup();\r
- container_->SetPosition(0, 0, 466, 466);\r
- container_->SetStyle(STYLE_BACKGROUND_OPA, 0);\r
- }\r
-\r
- // Add ScrollView to App\r
- if (scrollView1_ == nullptr)\r
- {\r
- scrollView1_ = new UIScrollView();\r
- }\r
- scrollView1_->SetPosition(0, 0); // widget's left position and top position\r
- scrollView1_->Resize(466, 466); // widget's width and height\r
- scrollView1_->SetViewId("scrollView1"); // Set style\r
- scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-\r
- // Set additional property\r
-\r
- // Add to rootView\r
- container_->Add(scrollView1_);\r
- scrollView1_->SetVisible(true);\r
-\r
- // Add Label to App\r
- if (label1_ == nullptr)\r
- {\r
- label1_ = new UILabel();\r
- }\r
- label1_->SetPosition(158, 52); // widget's left position and top position\r
- label1_->Resize(200, 60); // widget's width and height\r
- label1_->SetViewId("label1"); // Set style\r
- label1_->SetStyle(STYLE_TEXT_FONT, 30);\r
-\r
- // Set additional property\r
- label1_->SetText("常用联系人");\r
- label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
- label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
- label1_->SetRollSpeed(0);\r
- label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
-\r
- // Add to scrollView1\r
- scrollView1_->Add(label1_);\r
- label1_->SetVisible(true);\r
-\r
- // Add Label to App\r
- if (label2_ == nullptr)\r
- {\r
- label2_ = new UILabel();\r
- }\r
- label2_->SetPosition(51, 291); // widget's left position and top position\r
- label2_->Resize(400, 124); // widget's width and height\r
- label2_->SetViewId("label2"); // Set style\r
- label2_->SetStyle(STYLE_TEXT_FONT, 26);\r
-\r
- // Set additional property\r
- label2_->SetText("未添加联系人,请前往“小希爱\n玩”APP进行设置");\r
- label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
- label2_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff));\r
- label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
- label2_->SetRollSpeed(0);\r
- label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26);\r
-\r
- // Add to scrollView1\r
- scrollView1_->Add(label2_);\r
- label2_->SetVisible(true);\r
-\r
- // Add ImageView to App\r
- if (image1_ == nullptr)\r
- {\r
- image1_ = new UIImageView();\r
- }\r
- image1_->SetPosition(158, 120); // widget's left position and top position\r
- image1_->Resize(150, 150); // widget's width and height\r
- image1_->SetViewId("image1"); // Set style\r
-\r
- // Set additional property\r
-#ifdef _WIN32\r
- char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/PhoneDir/PhoneDirdir.bin";\r
-#else\r
- char *image1imagesPath = "/user/res/Phone/phonedir.bin";\r
-#endif\r
- image1_->SetSrc(image1imagesPath);\r
-\r
- // Add to scrollView1\r
- scrollView1_->Add(image1_);\r
- image1_->SetVisible(true);\r
+ UILabelButtonExt *button = new UILabelButtonExt();\r
+ if (button == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: button new fail!");\r
+ return nullptr;\r
+ }\r
+ button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h);\r
+ button->SetViewId(buttonconfig.ViewId);\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "----------%s ---",buttonconfig.ViewId);\r
+ button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+ button->SetImageSrc(buttonconfig.ImageSrc, buttonconfig.ImageSrc);\r
+ button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
+ if(clickListener!=NULL)\r
+ button->SetOnClickListener(clickListener);\r
+\r
+ button->SetText(buttonconfig.str);\r
+ button->SetAlign(TEXT_ALIGNMENT_LEFT);\r
+ button->SetLabelPosition(buttonconfig.label_x,buttonconfig.label_y );\r
+ button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, buttonconfig.Fontsize);\r
+ //button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
+\r
+ button->SetImagePosition(30, 25);\r
+ return button;\r
}\r
\r
- void PhoneDirView::DeInit()\r
+ \r
+ void PhoneDirView::initView_ext(int x,int y,int w,int h,int interval,const char *imagsrc)\r
{\r
- if (container_ != nullptr)\r
- {\r
- container_->RemoveAll();\r
- delete container_;\r
- container_ = nullptr;\r
- }\r
- if (scrollView1_ != nullptr)\r
- {\r
- delete scrollView1_;\r
- scrollView1_ = nullptr;\r
- }\r
- if (label1_ != nullptr)\r
- {\r
- delete label1_;\r
- label1_ = nullptr;\r
- }\r
- if (label2_ != nullptr)\r
- {\r
- delete label2_;\r
- label2_ = nullptr;\r
- }\r
- if (image1_ != nullptr)\r
- {\r
- delete image1_;\r
- image1_ = nullptr;\r
- }\r
+ /* -------------------------------------------------------------------------- */\r
+ UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>(PhoneDirPresenter::GetInstance());\r
+ /* -------------------------------------------------------------------------- */\r
+ ButtonConfig_ext_t buttonconfig;\r
+ buttonconfig.x = x;\r
+ buttonconfig.y = y;\r
+ buttonconfig.w = w;\r
+ buttonconfig.h = h;\r
+\r
+ int len =addressbook_t.num;\r
+\r
+ for(int i=0;i<len;i++)\r
+ {\r
+ buttonconfig.str=addressbook_t.Contact_t[i].name;\r
+ //char buf[32]={0};\r
+ //sprintf(buf,"1",i);\r
+ //buf[0]=i+48;\r
+ buttonconfig.ViewId =number_str[i];\r
+ \r
+ buttonconfig.ImageSrc = addressbook_t.Contact_t[i].sex ? PHONE_DIR_BOY:PHONE_DIR_GIRL;\r
+ buttonconfig.label_x=120;\r
+ buttonconfig.label_y=0;\r
+ buttonconfig.Fontsize=30;\r
+ buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT;\r
+ button[i] = SetTheButton_ext(buttonconfig, clickListener);\r
+ buttonconfig.y+=interval;\r
+ container_->Add(button[i]);\r
+ }\r
+ onepage_address_init();\r
+ /* -------------------------------------------------------------------------- */ \r
}\r
\r
-#endif\r
- void PhoneDirView::Init()\r
+ void PhoneDirView :: onepage_address_init(void)\r
{\r
- if (container_ == nullptr)\r
- {\r
- container_ = new UIViewGroup();\r
- container_->SetPosition(0, 0, 466, 466);\r
- container_->SetStyle(STYLE_BACKGROUND_OPA, 0);\r
+ if (container_one_page == nullptr) {\r
+ container_one_page = new UIScrollView();\r
+ container_one_page->SetPosition(0, 0,Screen::GetInstance().GetWidth(),Screen::GetInstance().GetHeight());\r
+ container_one_page->SetStyle(STYLE_BACKGROUND_OPA, 0);\r
+ container_one_page->SetViewId("container_one_page");\r
}\r
-\r
- // Add ScrollView to App\r
- if (scrollView1_ == nullptr)\r
- {\r
- scrollView1_ = new UIScrollView();\r
- }\r
- scrollView1_->SetPosition(0, 0); // widget's left position and top position\r
- scrollView1_->Resize(466, 466); // widget's width and height\r
- scrollView1_->SetViewId("scrollView1"); // Set style\r
- scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-\r
- // Set additional property\r
-\r
- // Add the CallBack about events\r
- UIView::OnDragListener *scrollView1Drag = static_cast<UIView::OnDragListener *>(PhoneDirPresenter::GetInstance());\r
- scrollView1_->SetOnDragListener(scrollView1Drag);\r
- // Add to rootView\r
- container_->Add(scrollView1_);\r
- scrollView1_->SetVisible(true);\r
-\r
+ \r
// Add Label to App\r
- if (label1_ == nullptr)\r
- {\r
- label1_ = new UILabel();\r
+ if (label1_phone_name == nullptr) {\r
+ label1_phone_name = new UILabel();\r
}\r
- label1_->SetPosition(158, 52); // widget's left position and top position\r
- label1_->Resize(200, 60); // widget's width and height\r
- label1_->SetViewId("label1"); // Set style\r
- label1_->SetStyle(STYLE_TEXT_FONT, 30);\r
+ label1_phone_name->SetPosition(158, 63); // widget's left position and top position\r
+ label1_phone_name->Resize(206, 69); // widget's width and height\r
+ label1_phone_name->SetViewId("label1");// Set style\r
+ label1_phone_name->SetStyle(STYLE_TEXT_FONT, 50);\r
\r
// Set additional property\r
- label1_->SetText("常用联系人");\r
- label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
- label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
- label1_->SetRollSpeed(0);\r
- label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
-\r
- // Add to scrollView1\r
- scrollView1_->Add(label1_);\r
- label1_->SetVisible(true);\r
-\r
- // Add LabelButtonExt to App\r
- if (labelButton8_ == nullptr)\r
- {\r
- labelButton8_ = new UILabelButtonExt();\r
- }\r
- labelButton8_->SetPosition(43, 243); // widget's left position and top position\r
- labelButton8_->Resize(380, 100); // widget's width and height\r
- labelButton8_->SetViewId("labelButton2"); // Set style\r
- labelButton8_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
-\r
- // Set additional property\r
- labelButton8_->SetText("张三");\r
- labelButton8_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26);\r
- labelButton8_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
-\r
- // Add the CallBack about events\r
- UIView::OnClickListener *labelButton8Click = static_cast<UIView::OnClickListener *>(PhoneDirPresenter::GetInstance());\r
- labelButton8_->SetOnClickListener(labelButton8Click);\r
- // Add to scrollView1\r
- scrollView1_->Add(labelButton8_);\r
- labelButton8_->SetVisible(true);\r
+ label1_phone_name->SetText(addressbook_t.Contact_t[0].name);\r
+ label1_phone_name->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
+ label1_phone_name->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+ label1_phone_name->SetRollSpeed(0);\r
+ label1_phone_name->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 50);\r
\r
+ // Add to rootView\r
+ container_one_page->Add(label1_phone_name);\r
+ label1_phone_name->SetVisible(true);\r
+ \r
// Add ImageView to App\r
- if (image2_ == nullptr)\r
- {\r
- image2_ = new UIImageView();\r
- }\r
- image2_->SetPosition(82, 260); // widget's left position and top position\r
- image2_->Resize(89, 80); // widget's width and height\r
- image2_->SetViewId("image2"); // Set style\r
-\r
+ if (phone_name == nullptr) {\r
+ phone_name = new UIImageView();\r
+ }\r
+ phone_name->SetPosition(170, 140); // widget's left position and top position\r
+ phone_name->Resize(109, 111); // widget's width and height\r
+ phone_name->SetViewId("image1");// Set style\r
+ const char *Imagesrc=addressbook_t.Contact_t[0].sex ? PHONE_DIR_BOY_1:PHONE_DIR_GIRL_1;\r
+ phone_name->SetSrc(Imagesrc);\r
// Set additional property\r
-#ifdef _WIN32\r
- char *image2imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-boy.bin";\r
-#else\r
- char *image2imagesPath = "/user/res/Phone/little-boy.bin";\r
-#endif\r
- image2_->SetSrc(image2imagesPath);\r
-\r
- // Add to scrollView1\r
- scrollView1_->Add(image2_);\r
- image2_->SetVisible(true);\r
-\r
- // Add LabelButtonExt to App\r
- if (labelButton9_ == nullptr)\r
- {\r
- labelButton9_ = new UILabelButtonExt();\r
- }\r
- labelButton9_->SetPosition(43, 363); // widget's left position and top position\r
- labelButton9_->Resize(380, 100); // widget's width and height\r
- labelButton9_->SetViewId("labelButton3"); // Set style\r
- labelButton9_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
\r
- // Set additional property\r
- labelButton9_->SetText("徐七");\r
- labelButton9_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26);\r
- labelButton9_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
+ // SystemScrollView[TESTVIEW]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+ // SystemScrollView[TESTVIEW]->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
+ // SystemScrollView[TESTVIEW]->SetScrollBlankSize(35);\r
+ // SystemScrollView[TESTVIEW]->SetReboundSize(50);\r
+ // SystemScrollView[TESTVIEW]->SetDirection(1);\r
+ // Add to rootView\r
+ container_one_page->Add(phone_name);\r
+ phone_name->SetVisible(true);\r
+ container_one_page->SetVisible(false);\r
+ container_one_page->SetDraggable(true);\r
+ container_one_page->SetTouchable(true);\r
+ RootView::GetInstance()->Add(container_one_page);\r
\r
- // Add the CallBack about events\r
- UIView::OnClickListener *labelButton9Click = static_cast<UIView::OnClickListener *>(PhoneDirPresenter::GetInstance());\r
- labelButton9_->SetOnClickListener(labelButton9Click);\r
- // Add to scrollView1\r
- scrollView1_->Add(labelButton9_);\r
- labelButton9_->SetVisible(true);\r
\r
- // Add ImageView to App\r
- if (image3_ == nullptr)\r
- {\r
- image3_ = new UIImageView();\r
- }\r
- image3_->SetPosition(86, 381); // widget's left position and top position\r
- image3_->Resize(100, 100); // widget's width and height\r
- image3_->SetViewId("image3"); // Set style\r
\r
- // Set additional property\r
-#ifdef _WIN32\r
- char *image3imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-boy.bin";\r
-#else\r
- char *image3imagesPath = "/user/res/Phone/little-boy.bin";\r
-#endif\r
- image3_->SetSrc(image3imagesPath);\r
+ UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>(PhoneDirPresenter::GetInstance());\r
+ /* -------------------------------------------------------------------------- */\r
+ ButtonConfig_ext_t buttonconfig;\r
+ buttonconfig.x = 80;\r
+ buttonconfig.y = 300;\r
+ buttonconfig.w = 319;\r
+ buttonconfig.h = 106;\r
\r
- // Add to scrollView1\r
- scrollView1_->Add(image3_);\r
- image3_->SetVisible(true);\r
+ int len =addressbook_t.Contact_t[0].phone_num;\r
\r
- // Add LabelButtonExt to App\r
- if (labelButton10_ == nullptr)\r
+ for(int i=0;i<2;i++)\r
{\r
- labelButton10_ = new UILabelButtonExt();\r
+ buttonconfig.str=addressbook_t.Contact_t[0].phone_number_t[0].number;\r
+ char buf[32]={0};\r
+ sprintf(buf,"button_%d",i);\r
+ buttonconfig.ViewId =buf;\r
+ \r
+ buttonconfig.label_x=50;\r
+ buttonconfig.label_y=0;\r
+ buttonconfig.Fontsize=30;\r
+ buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT;\r
+ number_button[i] = SetTheButton_ext(buttonconfig,NULL);\r
+ buttonconfig.y+=120;\r
+ container_one_page->Add(number_button[i]);\r
}\r
- labelButton10_->SetPosition(43, 483); // widget's left position and top position\r
- labelButton10_->Resize(380, 100); // widget's width and height\r
- labelButton10_->SetViewId("labelButton4"); // Set style\r
- labelButton10_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
-\r
- // Set additional property\r
- labelButton10_->SetText("萧炎");\r
- labelButton10_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26);\r
- labelButton10_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
\r
- // Add the CallBack about events\r
- UIView::OnClickListener *labelButton10Click = static_cast<UIView::OnClickListener *>(PhoneDirPresenter::GetInstance());\r
- labelButton10_->SetOnClickListener(labelButton10Click);\r
- // Add to scrollView1\r
- scrollView1_->Add(labelButton10_);\r
- labelButton10_->SetVisible(true);\r
\r
- // Add ImageView to App\r
- if (image5_ == nullptr)\r
+ UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(PhoneDirPresenter::GetInstance());\r
+ if (draglistener == nullptr)\r
{\r
- image5_ = new UIImageView();\r
+ return;\r
}\r
- image5_->SetPosition(92, 499); // widget's left position and top position\r
- image5_->Resize(100, 100); // widget's width and height\r
- image5_->SetViewId("image5"); // Set style\r
+ container_one_page->SetOnDragListener(draglistener);\r
\r
- // Set additional property\r
-#ifdef _WIN32\r
- char *image5imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-girl.bin";\r
-#else\r
- char *image5imagesPath = "/user/res/Phone/little-girl.bin";\r
-#endif\r
- image5_->SetSrc(image5imagesPath);\r
\r
- // Add to scrollView1\r
- scrollView1_->Add(image5_);\r
- image5_->SetVisible(true);\r
+ return;\r
+ \r
+ }\r
\r
- // Add ImageView to App\r
- if (image7_ == nullptr)\r
+ void PhoneDirView::Set_onepage_address(const char *idstr)\r
+ {\r
+ if(strcmp("container_one_page",idstr)==0)\r
{\r
- image7_ = new UIImageView();\r
- }\r
- image7_->SetPosition(167, -106); // widget's left position and top position\r
- image7_->Resize(100, 100); // widget's width and height\r
- image7_->SetViewId("image7"); // Set style\r
-\r
- // Set additional property\r
-\r
- // Add to scrollView1\r
- scrollView1_->Add(image7_);\r
- image7_->SetVisible(true);\r
+ container_->SetVisible(true);\r
+ container_one_page->SetVisible(false);\r
+ return;\r
\r
- // Add LabelButtonExt to App\r
- if (labelButton13_ == nullptr)\r
- {\r
- labelButton13_ = new UILabelButtonExt();\r
}\r
- labelButton13_->SetPosition(43, 723); // widget's left position and top position\r
- labelButton13_->Resize(380, 100); // widget's width and height\r
- labelButton13_->SetViewId("labelButton6"); // Set style\r
- labelButton13_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
\r
- // Set additional property\r
- labelButton13_->SetText("李四");\r
- labelButton13_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26);\r
- labelButton13_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
+ container_->SetVisible(false);\r
+ container_one_page->SetVisible(true);\r
+ uint8_t id= atoi(idstr);//idstr[16];\r
+ if(addressbook_t.Contact_t[id].name) \r
+ label1_phone_name->SetText(addressbook_t.Contact_t[id].name);\r
+ const char *Imagesrc=addressbook_t.Contact_t[id].sex ? PHONE_DIR_BOY_1:PHONE_DIR_GIRL_1;\r
+ phone_name->SetSrc(Imagesrc);\r
\r
- // Add the CallBack about events\r
- UIView::OnClickListener *labelButton13Click = static_cast<UIView::OnClickListener *>(PhoneDirPresenter::GetInstance());\r
- labelButton13_->SetOnClickListener(labelButton13Click);\r
- // Add to scrollView1\r
- scrollView1_->Add(labelButton13_);\r
- labelButton13_->SetVisible(true);\r
+ int len =addressbook_t.Contact_t[id].phone_num;\r
\r
- // Add ImageView to App\r
- if (image9_ == nullptr)\r
+ for(int i=0;i<len;i++)\r
{\r
- image9_ = new UIImageView();\r
+ number_button[i]->SetVisible(true);\r
+ if(addressbook_t.Contact_t[id].phone_number_t[i].number)\r
+ number_button[i]->SetText(addressbook_t.Contact_t[id].phone_number_t[i].number); \r
}\r
- image9_->SetPosition(100, 745); // widget's left position and top position\r
- image9_->Resize(100, 100); // widget's width and height\r
- image9_->SetViewId("image9"); // Set style\r
-\r
- // Set additional property\r
-#ifdef _WIN32\r
- char *image9imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-boy.bin";\r
-#else\r
- char *image9imagesPath = "/user/res/Phone/little-boy.bin";\r
-#endif\r
- image9_->SetSrc(image9imagesPath);\r
-\r
- // Add to scrollView1\r
- scrollView1_->Add(image9_);\r
- image9_->SetVisible(true);\r
-\r
- // Add ImageView to App\r
- if (image8_ == nullptr)\r
+ if(len<2)\r
{\r
- image8_ = new UIImageView();\r
+ number_button[1]->SetVisible(false);\r
}\r
- image8_->SetPosition(183, 874); // widget's left position and top position\r
- image8_->Resize(100, 100); // widget's width and height\r
- image8_->SetViewId("image8"); // Set style\r
-\r
- // Set additional property\r
-\r
- // Add to scrollView1\r
- scrollView1_->Add(image8_);\r
- image8_->SetVisible(true);\r
+ RootView::GetInstance()->Invalidate();\r
+ return;\r
+ \r
+ // // Add LabelButtonExt to App\r
+ // if (labelButton5_ == nullptr) {\r
+ // labelButton5_ = new UILabelButtonExt();\r
+ // }\r
+ // labelButton5_->SetPosition(107, 293); // widget's left position and top position\r
+ // labelButton5_->Resize(252, 77); // widget's width and height\r
+ // labelButton5_->SetViewId("labelButton5");// Set style\r
+\r
+ // // Set additional property\r
+ // labelButton5_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 16);\r
+ // labelButton5_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
+\r
+ // // Add to rootView\r
+ // container_->Add(labelButton5_);\r
+ // labelButton5_->SetVisible(true);\r
+ }\r
+ \r
+ // void PhoneDirView::phone_have_Init()\r
+ // {\r
+ \r
+ // }\r
\r
- // Add LabelButtonExt to App\r
- if (labelButton11_ == nullptr)\r
+ void PhoneDirView::DeInit()\r
+ {\r
+ if (container_ != nullptr)\r
{\r
- labelButton11_ = new UILabelButtonExt();\r
- }\r
- labelButton11_->SetPosition(43, 603); // widget's left position and top position\r
- labelButton11_->Resize(380, 100); // widget's width and height\r
- labelButton11_->SetViewId("labelButton5"); // Set style\r
- labelButton11_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
-\r
- // Set additional property\r
- labelButton11_->SetText("王六");\r
- labelButton11_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26);\r
- labelButton11_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
-\r
- // Add the CallBack about events\r
- UIView::OnClickListener *labelButton11Click = static_cast<UIView::OnClickListener *>(PhoneDirPresenter::GetInstance());\r
- labelButton11_->SetOnClickListener(labelButton11Click);\r
- // Add to scrollView1\r
- scrollView1_->Add(labelButton11_);\r
- labelButton11_->SetVisible(true);\r
-\r
- // Add ImageView to App\r
- if (image6_ == nullptr)\r
+ container_->RemoveAll();\r
+ delete container_;\r
+ container_ = nullptr;\r
+ if(label1_no==NULL)\r
+ {\r
+ if(label1_)\r
+ {\r
+ delete label1_;\r
+ label1_ = nullptr;\r
+ }\r
+ for(int i=0;i<addressbook_t.num;i++)\r
+ { \r
+ if( button[i])\r
+ {\r
+ delete button[i];\r
+ button[i] = nullptr;\r
+ }\r
+ }\r
+\r
+ container_one_page->RemoveAll();\r
+ delete container_one_page;\r
+ container_one_page = nullptr;\r
+ if(phone_name)\r
+ {\r
+ delete phone_name;\r
+ phone_name = nullptr;\r
+ }\r
+ if(label1_phone_name)\r
+ {\r
+ delete label1_phone_name;\r
+ label1_phone_name = nullptr;\r
+ }\r
+ for(int i=0;i<2;i++)\r
+ { \r
+ if( number_button[i])\r
+ {\r
+ delete number_button[i];\r
+ number_button[i] = nullptr;\r
+ }\r
+ }\r
+ write_addressbook_bin_flle();\r
+ }\r
+ else\r
+ {\r
+ delete label1_no;\r
+ label1_no=nullptr;\r
+ delete label2_no;\r
+ label2_no=nullptr;\r
+ delete image1_no;\r
+ image1_no=nullptr;\r
+ \r
+ }\r
+ }\r
+ \r
+ }\r
+ UIView *PhoneDirView::GetView()\r
+ {\r
+ if (label1_no == nullptr)\r
{\r
- image6_ = new UIImageView();\r
+ label1_no = new UILabel();\r
}\r
- image6_->SetPosition(95, 617); // widget's left position and top position\r
- image6_->Resize(100, 100); // widget's width and height\r
- image6_->SetViewId("image6"); // Set style\r
+ label1_no->SetPosition(158, 52); // widget's left position and top position\r
+ label1_no->Resize(200, 60); // widget's width and height\r
+ label1_no->SetViewId("label1"); // Set style\r
+ label1_no->SetStyle(STYLE_TEXT_FONT, 30);\r
\r
// Set additional property\r
-#ifdef _WIN32\r
- char *image6imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-girl.bin";\r
-#else\r
- char *image6imagesPath = "/user/res/Phone/little-girl.bin";\r
-#endif\r
- image6_->SetSrc(image6imagesPath);\r
+ label1_no->SetText("常用联系人");\r
+ label1_no->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
+ label1_no->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+ label1_no->SetRollSpeed(0);\r
+ label1_no->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
\r
// Add to scrollView1\r
- scrollView1_->Add(image6_);\r
- image6_->SetVisible(true);\r
+ container_->Add(label1_no);\r
+ label1_no->SetVisible(false);\r
\r
- // Add LabelButtonExt to App\r
- if (labelButton7_ == nullptr)\r
+ // Add Label to App\r
+ if (label2_no == nullptr)\r
{\r
- labelButton7_ = new UILabelButtonExt();\r
+ label2_no = new UILabel();\r
}\r
- labelButton7_->SetPosition(43, 123); // widget's left position and top position\r
- labelButton7_->Resize(380, 100); // widget's width and height\r
- labelButton7_->SetViewId("labelButton1"); // Set style\r
- labelButton7_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+ label2_no->SetPosition(51, 291); // widget's left position and top position\r
+ label2_no->Resize(400, 124); // widget's width and height\r
+ label2_no->SetViewId("label2"); // Set style\r
+ label2_no->SetStyle(STYLE_TEXT_FONT, 26);\r
\r
// Set additional property\r
- labelButton7_->SetText("KUMI同学(客服热线)");\r
- labelButton7_->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff));\r
- labelButton7_->SetAlign(TEXT_ALIGNMENT_RIGHT);\r
- labelButton7_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26);\r
- labelButton7_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
-\r
- // Add the CallBack about events\r
- UIView::OnClickListener *labelButton7Click = static_cast<UIView::OnClickListener *>(PhoneDirPresenter::GetInstance());\r
- labelButton7_->SetOnClickListener(labelButton7Click);\r
+ label2_no->SetText("未添加联系人,请前往“小希爱\n玩”APP进行设置");\r
+ label2_no->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
+ label2_no->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff));\r
+ label2_no->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+ label2_no->SetRollSpeed(0);\r
+ label2_no->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26);\r
+\r
// Add to scrollView1\r
- scrollView1_->Add(labelButton7_);\r
- labelButton7_->SetVisible(true);\r
+ container_->Add(label2_no);\r
+ label2_no->SetVisible(true);\r
\r
// Add ImageView to App\r
- if (image1_ == nullptr)\r
+ if (image1_no == nullptr)\r
{\r
- image1_ = new UIImageView();\r
+ image1_no = new UIImageView();\r
}\r
- image1_->SetPosition(76, 141); // widget's left position and top position\r
- image1_->Resize(100, 100); // widget's width and height\r
- image1_->SetViewId("image1"); // Set style\r
+ image1_no->SetPosition(158, 120); // widget's left position and top position\r
+ image1_no->Resize(150, 150); // widget's width and height\r
+ image1_no->SetViewId("image1"); // Set style\r
\r
// Set additional property\r
#ifdef _WIN32\r
- char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Phone/little-girl.bin";\r
+ char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/PhoneDir/PhoneDirdir.bin";\r
#else\r
- char *image1imagesPath = "/user/res/Phone/little-girl.bin";\r
+ char *image1imagesPath = "/user/res/Phone/phonedir.bin";\r
#endif\r
- image1_->SetSrc(image1imagesPath);\r
+ image1_no->SetSrc(image1imagesPath);\r
\r
// Add to scrollView1\r
- scrollView1_->Add(image1_);\r
- image1_->SetVisible(true);\r
- }\r
-\r
- void PhoneDirView::DeInit()\r
- {\r
- if (container_ != nullptr)\r
- {\r
- container_->RemoveAll();\r
- delete container_;\r
- container_ = nullptr;\r
- }\r
- if (scrollView1_ != nullptr)\r
- {\r
- delete scrollView1_;\r
- scrollView1_ = nullptr;\r
- }\r
- if (label1_ != nullptr)\r
- {\r
- delete label1_;\r
- label1_ = nullptr;\r
- }\r
- if (labelButton8_ != nullptr)\r
- {\r
- delete labelButton8_;\r
- labelButton8_ = nullptr;\r
- }\r
- if (image2_ != nullptr)\r
- {\r
- delete image2_;\r
- image2_ = nullptr;\r
- }\r
- if (labelButton9_ != nullptr)\r
- {\r
- delete labelButton9_;\r
- labelButton9_ = nullptr;\r
- }\r
- if (image3_ != nullptr)\r
- {\r
- delete image3_;\r
- image3_ = nullptr;\r
- }\r
- if (labelButton10_ != nullptr)\r
- {\r
- delete labelButton10_;\r
- labelButton10_ = nullptr;\r
- }\r
- if (image5_ != nullptr)\r
- {\r
- delete image5_;\r
- image5_ = nullptr;\r
- }\r
- if (image7_ != nullptr)\r
- {\r
- delete image7_;\r
- image7_ = nullptr;\r
- }\r
- if (labelButton13_ != nullptr)\r
- {\r
- delete labelButton13_;\r
- labelButton13_ = nullptr;\r
- }\r
- if (image9_ != nullptr)\r
- {\r
- delete image9_;\r
- image9_ = nullptr;\r
- }\r
- if (image8_ != nullptr)\r
- {\r
- delete image8_;\r
- image8_ = nullptr;\r
- }\r
- if (labelButton11_ != nullptr)\r
- {\r
- delete labelButton11_;\r
- labelButton11_ = nullptr;\r
- }\r
- if (image6_ != nullptr)\r
- {\r
- delete image6_;\r
- image6_ = nullptr;\r
- }\r
- if (labelButton7_ != nullptr)\r
- {\r
- delete labelButton7_;\r
- labelButton7_ = nullptr;\r
- }\r
- if (image1_ != nullptr)\r
- {\r
- delete image1_;\r
- image1_ = nullptr;\r
- }\r
- }\r
- UIView *PhoneDirView::GetView()\r
- {\r
- Init();\r
+ container_->Add(image1_no);\r
+ image1_no->SetVisible(true);\r
return container_;\r
}\r
void PhoneDirView::OnStart()\r
container_->SetWidth(Screen::GetInstance().GetWidth());\r
container_->SetHeight(Screen::GetInstance().GetHeight());\r
\r
+ container_->SetScrollBlankSize(35);\r
+ container_->SetReboundSize(50);\r
+ container_->SetDirection(1);\r
+\r
// 创建 draglistener 实例并设置为拖动监听器\r
UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(PhoneDirPresenter::GetInstance());\r
if (draglistener == nullptr)\r
\r
container_->SetTouchable(true);\r
container_->SetDraggable(true);\r
+ //read_addressbook_bin_file();\r
+\r
+\r
+ if (label1_ == nullptr) {\r
+ label1_ = new UILabel();\r
+ }\r
+ label1_->SetPosition(158, 18); // widget's left position and top position\r
+ label1_->Resize(800, 88); // widget's width and height\r
+ label1_->SetViewId("label1");// Set style\r
+ label1_->SetStyle(STYLE_TEXT_FONT, 50);\r
+\r
+ label1_->SetText("通讯录");\r
+ label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
+ label1_->SetTextColor(Color::GetColorFromRGBA(0xac, 0xa4, 0xa4, 0xff));\r
+ label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+ label1_->SetRollSpeed(0);\r
+ label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 50);\r
+ container_->Add(label1_);\r
+\r
+ if(addressbook_t.num<=0 ||addressbook_t.num>20)\r
+ {\r
+ GetView();\r
+ }\r
+ else\r
+ {\r
+ initView_ext(73,95,319,106,120,NULL);\r
+ }\r
+ \r
+\r
+ \r
\r
- GetView();\r
RootView::GetInstance()->Add(container_);\r
}\r
\r
\r
void PhoneView::Init()\r
{\r
- if (container_ == nullptr)\r
- {\r
- container_ = new UIViewGroup();\r
- container_->SetPosition(0, 0, 466, 466);\r
- container_->SetStyle(STYLE_BACKGROUND_OPA, 0);\r
- }\r
+ // if (container_ == nullptr)\r
+ // {\r
+ // container_ = new UIViewGroup();\r
+ // container_->SetPosition(0, 0, 466, 466);\r
+ // container_->SetStyle(STYLE_BACKGROUND_OPA, 0);\r
+ // }\r
\r
// Add ScrollView to App\r
- if (scrollView1_ == nullptr)\r
+ if (container_ == nullptr)\r
{\r
- scrollView1_ = new UIScrollView();\r
+ container_ = new UIScrollView();\r
}\r
- scrollView1_->SetPosition(0, 0); // widget's left position and top position\r
- scrollView1_->Resize(466, 466); // widget's width and height\r
- scrollView1_->SetViewId("scrollView1"); // Set style\r
- scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
+ container_->SetPosition(0, 0); // widget's left position and top position\r
+ container_->Resize(466, 466); // widget's width and height\r
+ container_->SetViewId("scrollView1"); // Set style\r
+ container_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
\r
// Set additional property\r
\r
- // Add the CallBack about events\r
- UIView::OnDragListener *scrollView1Drag = static_cast<UIView::OnDragListener *>(PhonePresenter::GetInstance());\r
- scrollView1_->SetOnDragListener(scrollView1Drag);\r
+ // // Add the CallBack about events\r
+ // UIView::OnDragListener *scrollView1Drag = static_cast<UIView::OnDragListener *>(PhonePresenter::GetInstance());\r
+ // container_->SetOnDragListener(scrollView1Drag);\r
// Add to rootView\r
- container_->Add(scrollView1_);\r
- scrollView1_->SetVisible(true);\r
+ //container_->Add(scrollView1_);\r
+ container_->SetVisible(true);\r
\r
// Add Label to App\r
if (label1_ == nullptr)\r
label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
\r
// Add to scrollView1\r
- scrollView1_->Add(label1_);\r
+ container_->Add(label1_);\r
label1_->SetVisible(true);\r
\r
// Add ImageView to App\r
// Set additional property\r
\r
// Add to scrollView1\r
- scrollView1_->Add(image1_);\r
+ container_->Add(image1_);\r
image1_->SetVisible(true);\r
\r
// Add Button to App\r
UIView::OnClickListener *button2Click = static_cast<UIView::OnClickListener *>(PhonePresenter::GetInstance());\r
button2_->SetOnClickListener(button2Click);\r
// Add to scrollView1\r
- scrollView1_->Add(button2_);\r
+ container_->Add(button2_);\r
button2_->SetVisible(true);\r
\r
// Add Button to App\r
UIView::OnClickListener *button1Click = static_cast<UIView::OnClickListener *>(PhonePresenter::GetInstance());\r
button1_->SetOnClickListener(button1Click);\r
// Add to scrollView1\r
- scrollView1_->Add(button1_);\r
+ container_->Add(button1_);\r
button1_->SetVisible(true);\r
\r
// Add Button to App\r
UIView::OnClickListener *button5Click = static_cast<UIView::OnClickListener *>(PhonePresenter::GetInstance());\r
button5_->SetOnClickListener(button5Click);\r
// Add to scrollView1\r
- scrollView1_->Add(button5_);\r
+ container_->Add(button5_);\r
button5_->SetVisible(true);\r
\r
// Add Label to App\r
label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
\r
// Add to scrollView1\r
- scrollView1_->Add(label2_);\r
+ container_->Add(label2_);\r
label2_->SetVisible(true);\r
\r
// Add Label to App\r
label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35);\r
\r
// Add to scrollView1\r
- scrollView1_->Add(label3_);\r
+ container_->Add(label3_);\r
label3_->SetVisible(true);\r
\r
// Add Label to App\r
label4_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);\r
\r
// Add to scrollView1\r
- scrollView1_->Add(label4_);\r
+ container_->Add(label4_);\r
label4_->SetVisible(true);\r
\r
// Add Label to App\r
label9_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);\r
\r
// Add to scrollView1\r
- scrollView1_->Add(label9_);\r
+ container_->Add(label9_);\r
label9_->SetVisible(true);\r
\r
// Add Label to App\r
label14_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26);\r
\r
// Add to scrollView1\r
- scrollView1_->Add(label14_);\r
+ container_->Add(label14_);\r
label14_->SetVisible(true);\r
\r
// Add Button to App\r
UIView::OnClickListener *button3Click = static_cast<UIView::OnClickListener *>(PhonePresenter::GetInstance());\r
button3_->SetOnClickListener(button3Click);\r
// Add to scrollView1\r
- scrollView1_->Add(button3_);\r
+ container_->Add(button3_);\r
button3_->SetVisible(true);\r
\r
// Add Label to App\r
label13_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);\r
\r
// Add to scrollView1\r
- scrollView1_->Add(label13_);\r
+ container_->Add(label13_);\r
label13_->SetVisible(true);\r
\r
// Add Label to App\r
label12_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35);\r
\r
// Add to scrollView1\r
- scrollView1_->Add(label12_);\r
+ container_->Add(label12_);\r
label12_->SetVisible(true);\r
\r
// Add Label to App\r
label10_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);\r
\r
// Add to scrollView1\r
- scrollView1_->Add(label10_);\r
+ container_->Add(label10_);\r
label10_->SetVisible(true);\r
\r
// Add Button to App\r
UIView::OnClickListener *button7Click = static_cast<UIView::OnClickListener *>(PhonePresenter::GetInstance());\r
button7_->SetOnClickListener(button7Click);\r
// Add to scrollView1\r
- scrollView1_->Add(button7_);\r
+ container_->Add(button7_);\r
button7_->SetVisible(true);\r
\r
// Add Label to App\r
label11_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);\r
\r
// Add to scrollView1\r
- scrollView1_->Add(label11_);\r
+ container_->Add(label11_);\r
label11_->SetVisible(true);\r
\r
// Add Label to App\r
label16_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26);\r
\r
// Add to scrollView1\r
- scrollView1_->Add(label16_);\r
+ container_->Add(label16_);\r
label16_->SetVisible(true);\r
\r
// Add Label to App\r
label15_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);\r
\r
// Add to scrollView1\r
- scrollView1_->Add(label15_);\r
+ container_->Add(label15_);\r
label15_->SetVisible(true);\r
\r
// Add ImageView to App\r
// Set additional property\r
\r
// Add to scrollView1\r
- scrollView1_->Add(image3_);\r
+ container_->Add(image3_);\r
image3_->SetVisible(true);\r
}\r
\r
void PhoneView::DeInit()\r
{\r
+ // if (container_ != nullptr)\r
+ // {\r
+ // container_->RemoveAll();\r
+ // delete container_;\r
+ // container_ = nullptr;\r
+ // }\r
if (container_ != nullptr)\r
{\r
container_->RemoveAll();\r
delete container_;\r
container_ = nullptr;\r
}\r
- if (scrollView1_ != nullptr)\r
- {\r
- delete scrollView1_;\r
- scrollView1_ = nullptr;\r
- }\r
if (label1_ != nullptr)\r
{\r
delete label1_;\r
--- /dev/null
+#include "phone/include/phoneaddressmodel.h"
+#include "wearable_log.h"
+#include <iostream>
+#include <string>
+#include "custom_utils.h"
+#include <cmsis_os2.h>
+#include <service/graphic_service.h>
+#include "thread_adapter.h"
+#include <iostream>
+#include <sstream>
+#include <iomanip>
+#include <string>
+#include "cmsis_os.h"
+
+#include "samgr_lite.h"
+
+
+
+
+namespace OHOS
+{
+ struct addressbook addressbook_t;
+
+ void read_addressbook_bin_file()
+ {
+
+ FILE *fp= fopen(ADDRESS_BOOK_PATH,"rb+");
+ if(fp==NULL)
+ {
+ fp= fopen(ADDRESS_BOOK_PATH,"wb+");
+ fclose(fp);
+ return;
+ }
+ char buf[124*20];
+ int ret=fread(buf,1,512,fp);
+ int offset_f=512;
+ while (ret==512)
+ {
+ ret=fread(&buf[offset_f],1,512,fp);
+ offset_f+=512;
+ }
+
+ int num=buf[0];//人数
+ printf("人数: %d\r\n",num);
+ addressbook_t.num=num;
+ int offset=1;
+ for (int j=0;j<num;j++)
+ {
+ uint8_t sex = buf[offset];
+ printf("性别: %d\r\n",sex);
+ addressbook_t.Contact_t[j].sex=sex;
+ offset=offset+1;
+ uint8_t name_len=buf[offset];
+ printf("name_len %d\r\n",name_len);
+ char *name=(char *)malloc(sizeof(char)*name_len+1);
+ memset(name,0,name_len+1);
+ if(name_len==0)
+ {
+ name_len=strlen("未知");
+ printf("未知\r\n");
+ }
+ else
+ {
+ memcpy(name,&buf[offset+1],name_len);
+ printf("姓名: %s\r\n",name);
+ addressbook_t.Contact_t[j].name=name;
+ }
+ offset=offset+name_len+1;
+ uint8_t phone_num=buf[offset];
+ offset=offset+1;
+ addressbook_t.Contact_t[j].phone_num=phone_num;
+ for(int i=0;i<phone_num;i++)
+ {
+
+ uint8_t phonen_len=buf[offset];
+ //char phonen_name[32]={0};
+ char *phonen_name=(char *)malloc(sizeof(char)*phonen_len+1);
+ memset(phonen_name,0,phonen_len+1);
+ memcpy(phonen_name,&buf[offset+1],phonen_len);
+ printf("号码: %s\r\n",phonen_name);
+ addressbook_t.Contact_t[j].phone_number_t[i].number=phonen_name;
+ offset=offset+phonen_len+1;
+ }
+ for(int i=0;i<phone_num;i++)
+ {
+ uint8_t add = buf[offset];
+ printf("归属地长度: %d\r\n",add);
+ char *add_buf=(char *)malloc(sizeof(char)*add+1);
+ memset(add_buf,0,add+1);
+ memcpy(add_buf,&buf[offset+1],add);
+ printf("归属地: %s\r\n",add_buf);
+ addressbook_t.Contact_t[j].phone_number_t[i].affiliating_area=add_buf;
+ offset=offset+add+1;
+
+ uint8_t yun = buf[offset];
+ char *yun_buf=(char *)malloc(sizeof(char)*yun+1);
+ memset(yun_buf,0,yun+1);
+ memcpy(yun_buf,&buf[offset+1],yun);
+ printf("运营商: %s\r\n",add_buf);
+ addressbook_t.Contact_t[j].phone_number_t[i].operator_t=yun_buf;
+
+ offset=offset+yun+1;
+ }
+ }
+ fclose(fp);
+ }
+
+ void get_phone_addrss_name(char *name,const char *phone)
+ {
+ for(int i=0;i<addressbook_t.num;i++)
+ {
+ if(strcmp(phone,addressbook_t.Contact_t[i].phone_number_t[0].number)==0)
+ {
+ strcpy(name,addressbook_t.Contact_t[i].name);
+ return;
+ }
+ else if(phone,addressbook_t.Contact_t[i].phone_num==2)
+ {
+ if(strcmp(phone,addressbook_t.Contact_t[i].phone_number_t[1].number)==0)
+ {
+ strcpy(name,addressbook_t.Contact_t[i].name);
+ return;
+ }
+ }
+ }
+ strcpy(name,"未知");
+ return;
+ }
+
+ void write_addressbook_bin_flle()
+ {
+ FILE *fp= fopen(ADDRESS_BOOK_PATH,"wb+");
+ if(fp==NULL)
+ return;
+ char buf[256*20];
+ // int ret=fread(buf,1,512,fp);
+ // int offset_f=512;
+ // while (ret==512)
+ // {
+ // ret=fread(&buf[offset_f],1,512,fp);
+ // offset_f+=512;
+ // }
+
+ buf[0] =addressbook_t.num;
+ printf("人数: %d\r\n",buf[0]);
+ int offset=1;
+ for(int i=0;i<addressbook_t.num;i++)
+ {
+ buf[offset]= addressbook_t.Contact_t[i].sex;
+ offset=offset+1;
+ printf("性别 %d\r\n",buf[offset]);
+ buf[offset]=strlen(addressbook_t.Contact_t[i].name)+1;
+ printf("写入名字长度: %d\r\n",buf[offset]);
+ memcpy(&buf[offset+1],addressbook_t.Contact_t[i].name,buf[offset]);
+ printf("写入名字: %s\r\n",&buf[offset+1]);
+ offset=offset+1+strlen(addressbook_t.Contact_t[i].name)+1;
+
+ buf[offset]=addressbook_t.Contact_t[i].phone_num;
+ printf("写入号码个数: %d\r\n",buf[offset]);
+ offset=offset+1;
+ for(int j=0;j<addressbook_t.Contact_t[i].phone_num;j++)
+ {
+ buf[offset]=strlen(addressbook_t.Contact_t[i].phone_number_t[j].number)+1;
+ memcpy(&buf[offset+1],addressbook_t.Contact_t[i].phone_number_t[j].number,buf[offset]);
+ printf("写入号码: %s\r\n",&buf[offset+1]);
+ offset=offset+1+strlen(addressbook_t.Contact_t[i].phone_number_t[j].number)+1;
+ }
+ for(int j=0;j<addressbook_t.Contact_t[i].phone_num;j++)
+ {
+ buf[offset]=strlen(addressbook_t.Contact_t[i].phone_number_t[j].affiliating_area)+1;
+ memcpy(&buf[offset+1],addressbook_t.Contact_t[i].phone_number_t[j].affiliating_area,buf[offset]);
+ printf("写入运营商: %s\r\n",&buf[offset+1]);
+ offset=offset+1+strlen(addressbook_t.Contact_t[i].phone_number_t[j].affiliating_area)+1;
+
+ buf[offset]=strlen(addressbook_t.Contact_t[i].phone_number_t[j].operator_t)+1;
+ memcpy(&buf[offset+1],addressbook_t.Contact_t[i].phone_number_t[j].operator_t,buf[offset]);
+ printf("写入所属地: %s\r\n",&buf[offset+1]);
+ offset=offset+1+strlen(addressbook_t.Contact_t[i].phone_number_t[j].operator_t)+1;
+ }
+ }
+ fwrite((void *)buf,1,offset,fp);
+ fclose(fp);
+ }
+
+ void add_addressbook(struct Contact *data)
+ {
+
+
+ if(data->name!=NULL)
+ {
+
+ addressbook_t.Contact_t[addressbook_t.num].name=(char *)malloc(strlen(data->name));
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s %d",data->name,addressbook_t.num);
+ strcpy(addressbook_t.Contact_t[addressbook_t.num].name,data->name);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",addressbook_t.Contact_t[addressbook_t.num].name);
+ }
+ else
+ {
+ addressbook_t.num-=1;
+ return;
+ addressbook_t.Contact_t[addressbook_t.num].name=(char *)malloc(strlen("未知"));
+ strcpy(addressbook_t.Contact_t[addressbook_t.num+1].name,"未知");
+ }
+
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneaddressbook::phoneaddressbook");
+
+ addressbook_t.Contact_t[addressbook_t.num].sex=data->sex;
+ addressbook_t.Contact_t[addressbook_t.num].phone_num=data->phone_num;
+ if(data->phone_num>2)
+ data->phone_num=2;
+ for(int i=0;i<data->phone_num;i++)
+ {
+ if(data->phone_number_t[i].number)
+ {
+ addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].number
+ =(char *)malloc(strlen(data->phone_number_t[i].number));
+ strcpy(addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].number,data->phone_number_t[i].number);
+ }
+ else
+ {
+ addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].number
+ =(char *)malloc(strlen("未知"));
+ strcpy(addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].number,"未知");
+ }
+
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneaddressbook::phoneaddressbook1111111111");
+
+ if(data->phone_number_t[i].affiliating_area)
+ {
+ addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].affiliating_area
+ =(char *)malloc(strlen(data->phone_number_t[i].affiliating_area));
+ strcpy(addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].affiliating_area,data->phone_number_t[i].affiliating_area);
+ }
+ else
+ {
+ addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].affiliating_area
+ =(char *)malloc(strlen("未知"));
+ strcpy(addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].affiliating_area,"未知");
+ }
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneaddressbook::phoneaddressbook2222222222");
+
+ if(data->phone_number_t[i].operator_t)
+ {
+ addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].operator_t
+ =(char *)malloc(strlen(data->phone_number_t[i].operator_t));
+ strcpy(addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].operator_t,data->phone_number_t[i].operator_t);
+ }
+ else
+ {
+ addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].operator_t
+ =(char *)malloc(strlen("未知"));
+ strcpy(addressbook_t.Contact_t[addressbook_t.num].phone_number_t[i].operator_t,"未知");
+ }
+ }
+ addressbook_t.num+=1;
+
+
+ }
+
+ void add_addressbook_by_AT(char *name,char *phone)
+ {
+ Contact data;
+ data.sex=0;
+ data.name=name;
+ data.phone_num=1;
+ data.phone_number_t[0].number=phone;
+ data.phone_number_t[0].affiliating_area=NULL;
+ data.phone_number_t[0].operator_t=NULL;
+
+ data.phone_number_t[1].number=NULL;
+ data.phone_number_t[1].affiliating_area=NULL;
+ data.phone_number_t[1].operator_t=NULL;
+
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneaddressbook::phoneaddressbook");
+ add_addressbook(&data);
+ }
+
+ void free_address()
+{
+ for(int i=0;i<addressbook_t.num;i++)
+ {
+ if(addressbook_t.Contact_t[i].name)
+ {
+ free(addressbook_t.Contact_t[i].name);
+ }
+ for(int y=0;y<addressbook_t.Contact_t[i].phone_num;y++)
+ {
+ if(addressbook_t.Contact_t[i].phone_number_t[y].number)
+ {
+ free(addressbook_t.Contact_t[i].phone_number_t[y].number);
+ }
+ if(addressbook_t.Contact_t[i].phone_number_t[y].affiliating_area)
+ {
+ free(addressbook_t.Contact_t[i].phone_number_t[y].affiliating_area);
+ }
+ if(addressbook_t.Contact_t[i].phone_number_t[y].operator_t)
+ {
+ free(addressbook_t.Contact_t[i].phone_number_t[y].operator_t);
+ }
+
+ }
+
+ }
+}
+
+ phoneaddressbook::phoneaddressbook()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "phoneaddressbook::phoneaddressbook");
+ }
+
+ phoneaddressbook::~phoneaddressbook()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "phoneaddressbook::~phoneaddressbook");
+ }
+
+ phoneaddressbook &phoneaddressbook::GetInstance()
+ {
+ static phoneaddressbook instance;
+ return instance;
+ }
+
+}
\ No newline at end of file