From 32ac8cc70a5effbbc06529830972962b99261209 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Thu, 7 Nov 2019 23:57:05 -0500 Subject: [PATCH] about_controller unfinished commit Co-Authored-By: null --- apps/settings/sub_menu/about_controller.cpp | 33 ++++++++++----------- apps/settings/sub_menu/about_controller.h | 13 ++++++-- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/apps/settings/sub_menu/about_controller.cpp b/apps/settings/sub_menu/about_controller.cpp index 5ccf77c6e..7816d8f3d 100644 --- a/apps/settings/sub_menu/about_controller.cpp +++ b/apps/settings/sub_menu/about_controller.cpp @@ -1,11 +1,13 @@ #include "about_controller.h" #include #include +#include namespace Settings { AboutController::AboutController(Responder * parentResponder) : - GenericSubController(parentResponder) + GenericSubController(parentResponder), + m_contributorsController(this) { for (int i = 0; i < k_totalNumberOfCell; i++) { m_cells[i].setMessageFont(KDFont::LargeFont); @@ -15,18 +17,15 @@ AboutController::AboutController(Responder * parentResponder) : } bool AboutController::handleEvent(Ion::Events::Event event) { + I18n::Message childLabel = m_messageTreeModel->children(selectedRow())->label(); /* We hide here the activation hardware test app: in the menu "about", by * clicking on '6' on the last row. */ - if ((event == Ion::Events::Six || event == Ion::Events::LowerT || event == Ion::Events::UpperT) && m_messageTreeModel->label() == I18n::Message::About && selectedRow() == numberOfRows()-1) { + if ((event == Ion::Events::Six || event == Ion::Events::LowerT || event == Ion::Events::UpperT) && m_messageTreeModel->label() == I18n::Message::About) { Container::activeApp()->displayModalViewController(&m_hardwareTestPopUpController, 0.f, 0.f, Metric::ExamPopUpTopMargin, Metric::PopUpRightMargin, Metric::ExamPopUpBottomMargin, Metric::PopUpLeftMargin); return true; } if (event == Ion::Events::OK || event == Ion::Events::EXE) { -#ifdef USERNAME - if (selectedRow() == 1) { -#else - if (selectedRow() == 0) { -#endif + if (selectedRow() == 0 + hasUsername()) { MessageTableCellWithBuffer * myCell = (MessageTableCellWithBuffer *)m_selectableTableView.selectedCell(); if (strcmp(myCell->accessoryText(), Ion::patchLevel()) == 0) { myCell->setAccessoryText(Ion::softwareVersion()); @@ -35,11 +34,7 @@ bool AboutController::handleEvent(Ion::Events::Event event) { myCell->setAccessoryText(Ion::patchLevel()); return true; } -#ifdef USERNAME - if (selectedRow() == 2) { -#else - if (selectedRow() == 1) { -#endif + if (selectedRow() == 1 + hasUsername()) { MessageTableCellWithBuffer * myCell = (MessageTableCellWithBuffer *)m_selectableTableView.selectedCell(); if (strcmp(myCell->accessoryText(), Ion::customSoftwareVersion()) == 0) { myCell->setAccessoryText("Public"); //Change for public/dev @@ -48,6 +43,13 @@ bool AboutController::handleEvent(Ion::Events::Event event) { myCell->setAccessoryText(Ion::customSoftwareVersion()); return true; } + if (childLabel == I18n::Message::Contributors) { + GenericSubController * subController = &m_contributorsController; + subController->setMessageTreeModel(MainController::model()->children(aboutIndex)->children(selectedRow())); + StackViewController * stack = stackController(); + stack->push(subController); + return true; + } return false; } return GenericSubController::handleEvent(event); @@ -66,6 +68,7 @@ int AboutController::reusableCellCount(int type) { void AboutController::willDisplayCellForIndex(HighlightCell * cell, int index) { GenericSubController::willDisplayCellForIndex(cell, index); + if (MainController) MessageTableCellWithBuffer * myCell = (MessageTableCellWithBuffer *)cell; static const char * messages[] = { #ifdef USERNAME @@ -76,11 +79,7 @@ void AboutController::willDisplayCellForIndex(HighlightCell * cell, int index) { Ion::serialNumber(), Ion::fccId() }; -#ifdef USERNAME - assert(index >= 0 && index < 5); -#else - assert(index >= 0 && index < 4); -#endif + assert(index >= 0 && index < k_totalNumberOfCell); myCell->setAccessoryText(messages[index]); } diff --git a/apps/settings/sub_menu/about_controller.h b/apps/settings/sub_menu/about_controller.h index 61fa22e2b..7506e46df 100644 --- a/apps/settings/sub_menu/about_controller.h +++ b/apps/settings/sub_menu/about_controller.h @@ -3,6 +3,7 @@ #include "generic_sub_controller.h" #include "../../hardware_test/pop_up_controller.h" +#include "contributors_controller.h" namespace Settings { @@ -14,11 +15,19 @@ public: int reusableCellCount(int type) override; void willDisplayCellForIndex(HighlightCell * cell, int index) override; private: + bool hasUsername(){ #ifdef USERNAME - constexpr static int k_totalNumberOfCell = 5; + return true; #else - constexpr static int k_totalNumberOfCell = 4; + return false #endif + } +#ifdef USERNAME + constexpr static int k_totalNumberOfCell = 6; +#else + constexpr static int k_totalNumberOfCell = 5; +#endif + ContributorsController m_contributorsController; MessageTableCellWithBuffer m_cells[k_totalNumberOfCell]; HardwareTest::PopUpController m_hardwareTestPopUpController; };