about_controller unfinished commit

Co-Authored-By: null <MixedMatched@users.noreply.github.com>
This commit is contained in:
BuildTools
2019-11-07 23:57:05 -05:00
parent ae8157782e
commit 32ac8cc70a
2 changed files with 27 additions and 19 deletions

View File

@@ -1,11 +1,13 @@
#include "about_controller.h"
#include <assert.h>
#include <cmath>
#include <apps/settings/main_controller.h>
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]);
}

View File

@@ -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;
};