#include <string>
extern DialInfo dialInfo[MAX_DIALNUM];
-
+extern DialInfo_1 dialInfo_1[MAX_DIALNUM_1];
+extern int dial_num;
namespace OHOS
{
void DialUpdateView::TestPicker()
{
- /* -------------------------------- 加载展示表盘信息 -------------------------------- */
- labelStr = dialInfo[dialId].title;
- dialpath = dialInfo[dialId].thumbnailPath;
- if (labelStr.empty() || dialpath.empty())
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialInfo is error!");
- return;
- }
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TestPicker");
- if (container_ == nullptr)
- {
- container_ = new UIViewGroup();
- container_->SetPosition(0, 0, 466, 466);
- container_->SetStyle(STYLE_BACKGROUND_OPA, 0);
- }
- /* -------------------------------------------------------------------------- */
- // Add Label to App
- if (label1_ == nullptr)
- {
- label1_ = new UILabel();
- }
- label1_->SetPosition(181, 50); // widget's left position and top position
- label1_->Resize(200, 60); // widget's width and height
- label1_->SetViewId("label_title"); // Set style
- label1_->SetStyle(STYLE_TEXT_FONT, 26);
- // Set additional property
- label1_->SetText(labelStr.c_str());
- label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
- label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- label1_->SetRollSpeed(0);
- label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26);
-
- // Add to rootView
- container_->Add(label1_);
- label1_->SetVisible(true);
- // Add ImageView to App
- if (image1_ == nullptr)
- {
- image1_ = new UIImageView();
- }
- image1_->SetPosition(103, 103); // widget's left position and top position
- image1_->Resize(100, 100); // widget's width and height
- image1_->SetViewId("image1"); // Set style
- // Set additional property
- image1_->SetSrc(dialpath.c_str());
- // Add to rootView
- container_->Add(image1_);
- image1_->SetVisible(true);
+ // /* -------------------------------- 加载展示表盘信息 -------------------------------- */
+ // labelStr = dialInfo[dialId].title;
+ // dialpath = dialInfo[dialId].thumbnailPath;
+ // if (labelStr.empty() || dialpath.empty())
+ // {
+ // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialInfo is error!");
+ // return;
+ // }
+ // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TestPicker");
+ // if (container_ == nullptr)
+ // {
+ // container_ = new UICardPage();
+ // container_->SetPosition(0, 0, 466, 466);
+ // container_->SetStyle(STYLE_BACKGROUND_OPA, 0);
+ // }
+ // /* -------------------------------------------------------------------------- */
+ // // Add Label to App
+ // if (label1_ == nullptr)
+ // {
+ // label1_ = new UILabel();
+ // }
+ // label1_->SetPosition(181, 50); // widget's left position and top position
+ // label1_->Resize(200, 60); // widget's width and height
+ // label1_->SetViewId("label_title"); // Set style
+ // label1_->SetStyle(STYLE_TEXT_FONT, 26);
+ // // Set additional property
+ // label1_->SetText(labelStr.c_str());
+ // label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
+ // label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ // label1_->SetRollSpeed(0);
+ // label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26);
- // Add Button to App
- if (button3_ == nullptr)
- {
- button3_ = new UIButton();
- }
- button3_->SetPosition(103, 103); // widget's left position and top position
- button3_->Resize(260, 260); // widget's width and height
- button3_->SetViewId("button_choose"); // Set style
- button3_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
- button3_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
-
- // Set additional property
- button3_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED);
- button3_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);
- button3_->SetStyleForState(STYLE_BORDER_COLOR, 0xfffafafa, UIButton::PRESSED);
- button3_->SetStyleForState(STYLE_BORDER_OPA, 0x00, UIButton::PRESSED);
-
- // Add the CallBack about events
- UIView::OnClickListener *button3Click = static_cast<UIView::OnClickListener *>(DialUpdatePresenter::GetInstance());
- button3_->SetOnClickListener(button3Click);
- // Add to rootView
- container_->Add(button3_);
- button3_->SetVisible(true);
-
- // Add Button to App
- if (button1_ == nullptr)
- {
- button1_ = new UIButton();
- }
- button1_->SetPosition(402, 208); // widget's left position and top position
- button1_->Resize(23, 50); // widget's width and height
- button1_->SetViewId("button_right"); // Set style
- button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
- button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
-
- // Set additional property
- char *button1defaultImgSrc = "/user/res/dialupdate/right_boutton.bin";
-
- char *button1triggeredImgSrc = nullptr;
- button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc);
- button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
-
- // Add the CallBack about events
- UIView::OnClickListener *button1Click = static_cast<UIView::OnClickListener *>(DialUpdatePresenter::GetInstance());
- button1_->SetOnClickListener(button1Click);
- // Add to rootView
- container_->Add(button1_);
- button1_->SetVisible(true);
-
- // Add Button to App
- if (button2_ == nullptr)
+ // // Add to rootView
+ // container_->Add(label1_);
+ // label1_->SetVisible(true);
+ // // Add ImageView to App
+ // if (image1_ == nullptr)
+ // {
+ // image1_ = new UIImageView();
+ // }
+ // image1_->SetPosition(103, 103); // widget's left position and top position
+ // image1_->Resize(100, 100); // widget's width and height
+ // image1_->SetViewId("image1"); // Set style
+ // // Set additional property
+ // image1_->SetSrc(dialpath.c_str());
+ // // Add to rootView
+ // container_->Add(image1_);
+ // image1_->SetVisible(true);
+
+ // // Add Button to App
+ // if (button3_ == nullptr)
+ // {
+ // button3_ = new UIButton();
+ // }
+ // button3_->SetPosition(103, 103); // widget's left position and top position
+ // button3_->Resize(260, 260); // widget's width and height
+ // button3_->SetViewId("button_choose"); // Set style
+ // button3_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
+ // button3_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+
+ // // Set additional property
+ // button3_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED);
+ // button3_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);
+ // button3_->SetStyleForState(STYLE_BORDER_COLOR, 0xfffafafa, UIButton::PRESSED);
+ // button3_->SetStyleForState(STYLE_BORDER_OPA, 0x00, UIButton::PRESSED);
+
+ // // Add the CallBack about events
+ // UIView::OnClickListener *button3Click = static_cast<UIView::OnClickListener *>(DialUpdatePresenter::GetInstance());
+ // button3_->SetOnClickListener(button3Click);
+ // // Add to rootView
+ // container_->Add(button3_);
+ // button3_->SetVisible(true);
+
+ // // Add Button to App
+ // if (button1_ == nullptr)
+ // {
+ // button1_ = new UIButton();
+ // }
+ // button1_->SetPosition(402, 208); // widget's left position and top position
+ // button1_->Resize(23, 50); // widget's width and height
+ // button1_->SetViewId("button_right"); // Set style
+ // button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
+ // button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+
+ // // Set additional property
+ // char *button1defaultImgSrc = "/user/res/dialupdate/right_boutton.bin";
+
+ // char *button1triggeredImgSrc = nullptr;
+ // button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc);
+ // button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
+
+ // // Add the CallBack about events
+ // UIView::OnClickListener *button1Click = static_cast<UIView::OnClickListener *>(DialUpdatePresenter::GetInstance());
+ // button1_->SetOnClickListener(button1Click);
+ // // Add to rootView
+ // container_->Add(button1_);
+ // button1_->SetVisible(true);
+
+ // // Add Button to App
+ // if (button2_ == nullptr)
+ // {
+ // button2_ = new UIButton();
+ // }
+ // button2_->SetPosition(40, 208); // widget's left position and top position
+ // button2_->Resize(23, 50); // widget's width and height
+ // button2_->SetViewId("button_left"); // Set style
+ // button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
+ // button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+
+ // // Set additional property
+ // char *button2defaultImgSrc = "/user/res/dialupdate/left_boutton.bin";
+
+ // char *button2triggeredImgSrc = nullptr;
+ // button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc);
+ // button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
+
+ // // Add the CallBack about events
+ // UIView::OnClickListener *button2Click = static_cast<UIView::OnClickListener *>(DialUpdatePresenter::GetInstance());
+ // button2_->SetOnClickListener(button2Click);
+ // // Add to rootView
+ // container_->Add(button2_);
+ // button2_->SetVisible(true);
+ }
+
+ UILabelButtonExt* Button[10]={};
+ void DialUpdateView::init_button()
+ {
+ //read_dial();
+ printf_dial();//dial_num
+ for(int i=0;i<dial_num;i++)
{
- button2_ = new UIButton();
+ Button[i] = new UILabelButtonExt();
+ if (Button == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemUpgradeButtonExt new fail!");
+ }
+ Button[i]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetWidth());
+ Button[i]->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+ Button[i]->SetImagePosition(103, 103);
+ Button[i]->SetViewId(dialInfo_1[i].title);
+ // uint32_t resId=5|( 0xfef << 20);
+ // //uint32_t resId=1|( 0xfef << 20);
+ // //ImageInfo* image = ImageCacheManager::GetInstance().LoadOneInMultiRes((uint8_t*)dialInfo_1[i].dialPath,resId);
+ // // std::string str="user/res/dials/KUMI.bin";
+ // // FILE * fp = fopen(dialInfo_1[i].dialPath, "rb");
+ // // if (fp == nullptr)
+ // // {
+ // // return;
+ // // }
+ // // ImageInfo* LoadOneInMultiRes(uint32_t resId, const std::string& file, FILE* userFP = nullptr,
+ // // bool isLongTerm = false, int offset = 0);
+ // ImageInfo* image = ImageCacheManager::GetInstance().LoadOneInMultiRes(resId,dialInfo_1[i].thumbnailPath);//,fp,false,dialInfo_1[i].imageOffset);//dialInfo_1[i].dialPath);
+ // if (image == nullptr) {
+ // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LoadAppImages %x %s fail", resId,dialInfo_1[1].thumbnailPath);
+ // // return ;
+ // }
+ //view->SetSrc(image);
+
+
+ //Button[i]->SetImageSrc(dialInfo_1[i].dialPath,dialInfo_1[i].dialPath);
+ Button[i]->SetImageSrc(dialInfo_1[i].thumbnailPath,dialInfo_1[i].thumbnailPath);
+ Button[i]->SetText(dialInfo_1[i].title);
+ Button[i]->SetAlign(TEXT_ALIGNMENT_CENTER);
+ Button[i]->SetLabelPosition(0, -380);
+ Button[i]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ Button[i]->SetStyleForState(STYLE_BORDER_COLOR, Color::Black().full, UIButton::PRESSED);
+ Button[i]->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::Black().full, UIButton::PRESSED);
+ UIView::OnClickListener *buttonClick = static_cast<UIView::OnClickListener *>(DialUpdatePresenter::GetInstance());
+ Button[i]->SetOnClickListener(buttonClick);
+ // button2_->SetOnClickListener(button2Click);
+ container_->Add( Button[i]);
}
- button2_->SetPosition(40, 208); // widget's left position and top position
- button2_->Resize(23, 50); // widget's width and height
- button2_->SetViewId("button_left"); // Set style
- button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
- button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
-
- // Set additional property
- char *button2defaultImgSrc = "/user/res/dialupdate/left_boutton.bin";
-
- char *button2triggeredImgSrc = nullptr;
- button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc);
- button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
-
- // Add the CallBack about events
- UIView::OnClickListener *button2Click = static_cast<UIView::OnClickListener *>(DialUpdatePresenter::GetInstance());
- button2_->SetOnClickListener(button2Click);
- // Add to rootView
- container_->Add(button2_);
- button2_->SetVisible(true);
+
+
}
+ UICardPage *cade[10]={nullptr};
+
+
void DialUpdateView::OnStart()
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialUpdateView");
View<DialUpdatePresenter>::OnStart();
BaseView::RootView(Color::Red().full);
- container_ = new UIViewGroup();
- container_->SetPosition(0, 0);
- container_->SetWidth(Screen::GetInstance().GetWidth());
- container_->SetHeight(Screen::GetInstance().GetHeight());
-
- // 创建 draglistener 实例并设置为拖动监听器
- UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(DialUpdatePresenter::GetInstance());
- if (draglistener == nullptr)
+ if (container_ == nullptr)
{
- return;
+ container_ = new UISwipeView(UISwipeView::HORIZONTAL);
+ container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+ container_->SetThrowDrag(true);
+ container_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+ container_->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE);
+ container_->SetBlankSize(0);
+ container_->SetReboundSize(200); // 200: rebound size
+ container_->SetElastic(true);
}
- container_->SetOnDragListener(draglistener);
- container_->SetTouchable(true);
- container_->SetDraggable(true);
- // 取到展示表盘id
- dialId = DialUpdatePresenter::GetInstance()->GetShowId();
- GetTestView();
+
+
+ init_button();
+
+
RootView::GetInstance()->Add(container_);
+
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainSwipeGroup new fail");
+
+ //container_->RegisterSwipeCallback(callback);
+
}
void DialUpdateView::OnSetUpView()
{