--- /dev/null
+#include "safemodemanager/include/RepairView.h"
+#include "safemodemanager/include/SafeModeManagerModel.h"
+#include "safemodemanager/include/SafeModeManagerPresenter.h"
+
+#include "UiConfig.h"
+#include "ui_resource_string.h"
+#include "wearable_log.h"
+
+namespace OHOS {
+
+static RepairView *g_pRepairView{nullptr};
+
+RepairView::RepairView() {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RepairView::RepairView");
+ g_pRepairView = this;
+}
+
+RepairView::~RepairView() {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RepairView::~RepairView");
+ ClearAll();
+ g_pRepairView = nullptr;
+}
+
+RepairView *RepairView::GetInstance() { return g_pRepairView; }
+
+void RepairView::ClearAll() {
+ scrollView_->RemoveAll();
+ delete signalLabel_;
+ signalLabel_ = nullptr;
+ delete operationLabel_;
+ operationLabel_ = nullptr;
+ delete instructionLabel_;
+ instructionLabel_ = nullptr;
+ delete versionLabel_;
+ versionLabel_ = nullptr;
+ delete wakeUpButton_;
+ wakeUpButton_ = nullptr;
+ delete repairButton_;
+ repairButton_ = nullptr;
+ delete downLabel_;
+ downLabel_ = nullptr;
+ delete totalLabel_;
+ totalLabel_ = nullptr;
+ delete downingLabel_;
+ downingLabel_ = nullptr;
+ delete scrollView_;
+ scrollView_ = nullptr;
+}
+
+void RepairView::InitScrollView() {
+ if (scrollView_ == nullptr) {
+ scrollView_ = new UIScrollView();
+ scrollView_->SetPosition(0, 0, Screen::GetInstance().GetWidth(),
+ Screen::GetInstance().GetHeight());
+ scrollView_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ scrollView_->SetScrollBlankSize(100);
+ scrollView_->SetMaxScrollDistance(1000);
+ scrollView_->SetThrowDrag(true);
+ scrollView_->SetHorizontalScrollState(false);
+ }
+}
+
+void RepairView::InitLabels() {
+ // Signal Label
+ if (signalLabel_ == nullptr) {
+ signalLabel_ = new UILabel();
+ signalLabel_->SetPosition(133, 130);
+ signalLabel_->Resize(200, 60);
+ signalLabel_->SetViewId("signalLabel");
+ signalLabel_->SetText("Signal: 26");
+ signalLabel_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+ signalLabel_->SetAlign(TEXT_ALIGNMENT_CENTER);
+ signalLabel_->SetFont(GILROY_BOLD_FONT,
+ 30); // Updated font size
+ signalLabel_->SetTextColor(
+ Color::GetColorFromRGBA(0x15, 0xcb, 0x06, 0xff)); // Updated text color
+ scrollView_->Add(signalLabel_);
+ signalLabel_->SetVisible(true);
+ }
+
+ // Operation Label
+ if (operationLabel_ == nullptr) {
+ operationLabel_ = new UILabel();
+ operationLabel_->SetPosition(83, 80);
+ operationLabel_->Resize(300, 60);
+ operationLabel_->SetViewId("operationLabel");
+ operationLabel_->SetText("Operation: CHN_CT");
+ operationLabel_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+ operationLabel_->SetAlign(TEXT_ALIGNMENT_CENTER);
+ operationLabel_->SetFont(GILROY_BOLD_FONT,
+ 30); // Updated font size
+ scrollView_->Add(operationLabel_);
+ operationLabel_->SetVisible(true);
+ }
+
+ // Instruction Label
+ if (instructionLabel_ == nullptr) {
+ instructionLabel_ = new UILabel();
+ instructionLabel_->SetPosition(20, 180);
+ instructionLabel_->Resize(400, 60);
+ instructionLabel_->SetViewId("instructionLabel");
+ instructionLabel_->SetText("If the signal is outside the range of 0 to 30, "
+ "please click 'Wake Up' and wait for a moment.");
+ instructionLabel_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+ instructionLabel_->SetAlign(TEXT_ALIGNMENT_CENTER);
+ instructionLabel_->SetTextColor(
+ Color::GetColorFromRGBA(0xeb, 0x05, 0x05, 0xff));
+ instructionLabel_->SetFont(GILROY_BOLD_FONT,
+ 20); // Updated font size
+ // scrollView_->Add(instructionLabel_);
+ // instructionLabel_->SetVisible(true);
+ }
+
+ // Version Label
+ if (versionLabel_ == nullptr) {
+ versionLabel_ = new UILabel();
+ versionLabel_->SetPosition(133, 180);
+ versionLabel_->Resize(200, 60);
+ versionLabel_->SetViewId("versionLabel");
+ versionLabel_->SetText("Version: 1.1.47");
+ versionLabel_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+ versionLabel_->SetAlign(TEXT_ALIGNMENT_CENTER);
+ versionLabel_->SetFont(GILROY_BOLD_FONT,
+ 30); // Updated font size
+ scrollView_->Add(versionLabel_);
+ versionLabel_->SetVisible(true);
+ }
+
+ // down Label
+ if (downingLabel_ == nullptr) {
+ downingLabel_ = new UILabel();
+ downingLabel_->SetPosition(133, 406);
+ downingLabel_->Resize(200, 60);
+ downingLabel_->SetViewId("label11");
+ downingLabel_->SetStyle(STYLE_TEXT_FONT, 26);
+ downingLabel_->SetText("downing...");
+ downingLabel_->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ downingLabel_->SetTextColor(
+ Color::GetColorFromRGBA(0xef, 0x0e, 0x0e, 0xff));
+ downingLabel_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ downingLabel_->SetRollSpeed(0);
+ downingLabel_->SetFont(GILROY_BOLD_FONT, 26);
+ scrollView_->Add(versionLabel_);
+ versionLabel_->SetVisible(false);
+ }
+}
+
+void RepairView::InitButtons() {
+ // Repair Button
+ if (repairButton_ == nullptr) {
+ repairButton_ = new UILabelButtonExt();
+ repairButton_->SetPosition(265, 245);
+ repairButton_->Resize(160, 80); // Updated size
+ repairButton_->SetViewId("repairButton");
+ repairButton_->SetText("Repair File");
+ repairButton_->SetFont(GILROY_BOLD_FONT,
+ 26); // Updated font size
+ repairButton_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff14ff00);
+ scrollView_->Add(repairButton_);
+ repairButton_->SetVisible(true);
+ }
+
+ // Wake Up Button
+ if (wakeUpButton_ == nullptr) {
+ wakeUpButton_ = new UILabelButtonExt();
+ wakeUpButton_->SetPosition(45, 245);
+ wakeUpButton_->Resize(160, 80); // Updated size
+ wakeUpButton_->SetViewId("wakeUpButton");
+ wakeUpButton_->SetText("Wake Up");
+ wakeUpButton_->SetFont(GILROY_BOLD_FONT,
+ 26); // Updated font size
+ wakeUpButton_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff0c77e6);
+ scrollView_->Add(wakeUpButton_);
+ wakeUpButton_->SetVisible(true);
+ }
+}
+UIScrollView *RepairView::RepairViewInit() {
+
+ InitScrollView();
+ // 设置拖拽监听器
+ UIView::OnDragListener *dragListener = static_cast<UIView::OnDragListener *>(
+ SafeModeManagerPresenter::GetInstance());
+ if (!dragListener) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+ "SafeModeManagerPresenter::获取实例失败!");
+ return nullptr; // 获取失败,返回空指针
+ }
+ scrollView_->SetOnDragListener(dragListener);
+
+ InitLabels();
+ InitButtons();
+
+ // Adding other labels
+ if (downLabel_ == nullptr) {
+ downLabel_ = new UILabel();
+ downLabel_->SetPosition(26, 366);
+ downLabel_->Resize(200, 60);
+ downLabel_->SetViewId("downLabel");
+ downLabel_->SetText("down: 10");
+ downLabel_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+ downLabel_->SetAlign(TEXT_ALIGNMENT_CENTER);
+ downLabel_->SetFont(GILROY_BOLD_FONT,
+ 30); // Updated font size
+ downLabel_->SetTextColor(
+ Color::GetColorFromRGBA(0x15, 0xcb, 0x06, 0xff)); // Updated text color
+ scrollView_->Add(downLabel_);
+ downLabel_->SetVisible(true);
+ }
+
+ if (totalLabel_ == nullptr) {
+ totalLabel_ = new UILabel();
+ totalLabel_->SetPosition(230, 366);
+ totalLabel_->Resize(200, 60);
+ totalLabel_->SetViewId("totalLabel");
+ totalLabel_->SetText("total: 100");
+ totalLabel_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+ totalLabel_->SetAlign(TEXT_ALIGNMENT_CENTER);
+ totalLabel_->SetFont(GILROY_BOLD_FONT,
+ 30); // Updated font size
+ scrollView_->Add(totalLabel_);
+ totalLabel_->SetVisible(true);
+ }
+
+ return scrollView_;
+}
+
+//初始化版本号与运营商
+void RepairView::InitBasicdata() {
+ if (versionLabel_ != nullptr) {
+ }
+ if (downLabel_ != nullptr) {
+ }
+}
+
+//更新信号值与下载进度
+void RepairView::UpdateRepairView(int date) {
+ if (downingLabel_ == nullptr) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+ "ResourceCheckView::downingLabel_ is null");
+ return;
+ }
+ //显示下载中
+ if (downingLabel_->IsVisible() == false) {
+ downingLabel_->SetVisible(true);
+ }
+ std::string display = "downing";
+ // 检查状态并更新提示文本
+ if (date >= 0 && date <= 60) {
+ int progress = date % 4;
+ display.append(progress, '.'); // 添加进度标记点
+ downingLabel_->SetText(display.c_str());
+ } else {
+ switch (date) {
+ //下载修复文件成功
+ case 61:
+ downingLabel_->SetText("Repair file download success!");
+ break;
+ case -1:
+ //下载修复文件失败
+ downingLabel_->SetText("Repair file download failed!");
+ break;
+ default:
+ downingLabel_->SetText("Unknown status...");
+ break;
+ }
+ }
+}
+} // namespace OHOS
\ No newline at end of file