mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[on_boarding] Move update_controller->pop_up_controller: enable other
pop_up_controller with different messages
This commit is contained in:
committed by
LeaNumworks
parent
1917ee8588
commit
c87adf79cc
@@ -4,7 +4,6 @@
|
||||
#include "home/app.h"
|
||||
#include "on_boarding/app.h"
|
||||
#include "hardware_test/app.h"
|
||||
#include "on_boarding/update_controller.h"
|
||||
#include "usb/app.h"
|
||||
#include "apps_window.h"
|
||||
#include "empty_battery_window.h"
|
||||
@@ -21,6 +20,10 @@
|
||||
#include "picview/picview_app.h"
|
||||
#endif
|
||||
|
||||
#if EPSILON_SOFTWARE_UPDATE_PROMPT
|
||||
#include "on_boarding/pop_up_controller.h"
|
||||
#endif
|
||||
|
||||
#include <ion/events.h>
|
||||
|
||||
class AppsContainer : public Container, ExamPopUpControllerDelegate {
|
||||
|
||||
@@ -3,7 +3,7 @@ app_objs += $(addprefix apps/on_boarding/,\
|
||||
language_controller.o\
|
||||
logo_controller.o\
|
||||
logo_view.o\
|
||||
update_controller.o\
|
||||
pop_up_controller.o\
|
||||
)
|
||||
|
||||
i18n_files += $(addprefix apps/on_boarding/,\
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <escher.h>
|
||||
#include "language_controller.h"
|
||||
#include "logo_controller.h"
|
||||
#include "update_controller.h"
|
||||
|
||||
namespace OnBoarding {
|
||||
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
#include "update_controller.h"
|
||||
#include "pop_up_controller.h"
|
||||
#include "../apps_container.h"
|
||||
#include <assert.h>
|
||||
|
||||
namespace OnBoarding {
|
||||
|
||||
UpdateController::MessageViewWithSkip::MessageViewWithSkip(I18n::Message * messages, KDColor * colors, uint8_t numberOfMessages) :
|
||||
#if EPSILON_SOFTWARE_UPDATE_PROMPT
|
||||
|
||||
PopUpController::MessageViewWithSkip::MessageViewWithSkip(I18n::Message * messages, KDColor * colors, uint8_t numberOfMessages) :
|
||||
MessageView(messages, colors, numberOfMessages),
|
||||
m_skipView(KDFont::SmallFont, I18n::Message::Skip, 1.0f, 0.5f),
|
||||
m_okView()
|
||||
{
|
||||
}
|
||||
|
||||
int UpdateController::MessageViewWithSkip::numberOfSubviews() const {
|
||||
int PopUpController::MessageViewWithSkip::numberOfSubviews() const {
|
||||
return MessageView::numberOfSubviews() + 2;
|
||||
}
|
||||
|
||||
View * UpdateController::MessageViewWithSkip::subviewAtIndex(int index) {
|
||||
View * PopUpController::MessageViewWithSkip::subviewAtIndex(int index) {
|
||||
uint8_t numberOfMainMessages = MessageView::numberOfSubviews();
|
||||
if (index < numberOfMainMessages) {
|
||||
return MessageView::subviewAtIndex(index);
|
||||
@@ -30,7 +32,7 @@ View * UpdateController::MessageViewWithSkip::subviewAtIndex(int index) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void UpdateController::MessageViewWithSkip::layoutSubviews() {
|
||||
void PopUpController::MessageViewWithSkip::layoutSubviews() {
|
||||
// Layout the main message
|
||||
MessageView::layoutSubviews();
|
||||
// Layout the "skip (OK)"
|
||||
@@ -42,6 +44,28 @@ void UpdateController::MessageViewWithSkip::layoutSubviews() {
|
||||
m_okView.setFrame(KDRect(width - okSize.width()-k_okMargin, height-okSize.height()-k_okMargin, okSize));
|
||||
}
|
||||
|
||||
PopUpController::PopUpController(I18n::Message * messages, KDColor * colors, uint8_t numberOfMessages) :
|
||||
ViewController(nullptr),
|
||||
m_messageViewWithSkip(messages, colors, numberOfMessages)
|
||||
{
|
||||
}
|
||||
|
||||
bool PopUpController::handleEvent(Ion::Events::Event event) {
|
||||
if (event != Ion::Events::Back && event != Ion::Events::OnOff && event != Ion::Events::USBPlug && event != Ion::Events::USBEnumeration) {
|
||||
app()->dismissModalViewController();
|
||||
AppsContainer * appsContainer = (AppsContainer *)app()->container();
|
||||
if (appsContainer->activeApp()->snapshot() == appsContainer->onBoardingAppSnapshot()) {
|
||||
appsContainer->switchTo(appsContainer->appSnapshotAtIndex(0));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if EPSILON_SOFTWARE_UPDATE_PROMPT
|
||||
|
||||
static I18n::Message sOnBoardingMessages[] = {
|
||||
I18n::Message::UpdateAvailable,
|
||||
I18n::Message::UpdateMessage1,
|
||||
@@ -59,21 +83,8 @@ static KDColor sOnBoardingColors[] = {
|
||||
Palette::YellowDark};
|
||||
|
||||
UpdateController::UpdateController() :
|
||||
ViewController(nullptr),
|
||||
m_messageViewWithSkip(sOnBoardingMessages, sOnBoardingColors, 6)
|
||||
{
|
||||
}
|
||||
PopUpController(sOnBoardingMessages, sOnBoardingColors, 6) {}
|
||||
|
||||
bool UpdateController::handleEvent(Ion::Events::Event event) {
|
||||
if (event != Ion::Events::Back && event != Ion::Events::OnOff && event != Ion::Events::USBPlug && event != Ion::Events::USBEnumeration) {
|
||||
app()->dismissModalViewController();
|
||||
AppsContainer * appsContainer = (AppsContainer *)app()->container();
|
||||
if (appsContainer->activeApp()->snapshot() == appsContainer->onBoardingAppSnapshot()) {
|
||||
appsContainer->switchTo(appsContainer->appSnapshotAtIndex(0));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef ON_BOARDING_UPDATE_CONTROLLER_H
|
||||
#define ON_BOARDING_UPDATE_CONTROLLER_H
|
||||
#ifndef ON_BOARDING_POP_UP_CONTROLLER_H
|
||||
#define ON_BOARDING_POP_UP_CONTROLLER_H
|
||||
|
||||
#include <escher.h>
|
||||
#include "../i18n.h"
|
||||
@@ -8,9 +8,11 @@
|
||||
|
||||
namespace OnBoarding {
|
||||
|
||||
class UpdateController : public ViewController {
|
||||
#if EPSILON_SOFTWARE_UPDATE_PROMPT
|
||||
|
||||
class PopUpController : public ViewController {
|
||||
public:
|
||||
UpdateController();
|
||||
PopUpController(I18n::Message * messages, KDColor * colors, uint8_t numberOfMessages);
|
||||
View * view() override { return &m_messageViewWithSkip; }
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
private:
|
||||
@@ -31,6 +33,17 @@ private:
|
||||
MessageViewWithSkip m_messageViewWithSkip;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if EPSILON_SOFTWARE_UPDATE_PROMPT
|
||||
|
||||
class UpdateController : public PopUpController {
|
||||
public:
|
||||
UpdateController();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user