mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[apps] Dismiss the Exam mode before connecting the calculator.
Change-Id: If9754841aaa17c677a451387c8c7ec43926890da
This commit is contained in:
@@ -14,7 +14,7 @@ AppsContainer::AppsContainer() :
|
||||
m_emptyBatteryWindow(),
|
||||
m_globalContext(),
|
||||
m_variableBoxController(&m_globalContext),
|
||||
m_examPopUpController(),
|
||||
m_examPopUpController(this),
|
||||
m_updateController(),
|
||||
m_ledTimer(LedTimer()),
|
||||
m_batteryTimer(BatteryTimer(this)),
|
||||
@@ -90,8 +90,9 @@ bool AppsContainer::dispatchEvent(Ion::Events::Event event) {
|
||||
if (Ion::USB::isPlugged()) {
|
||||
if (GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::Activate) {
|
||||
displayExamModePopUp(false);
|
||||
} else {
|
||||
Ion::USB::enable();
|
||||
}
|
||||
Ion::USB::enable();
|
||||
Ion::Backlight::setBrightness(Ion::Backlight::MaxBrightness);
|
||||
} else {
|
||||
Ion::USB::disable();
|
||||
@@ -208,6 +209,12 @@ void AppsContainer::redrawWindow() {
|
||||
m_window.redraw();
|
||||
}
|
||||
|
||||
void AppsContainer::examDeactivatingPopUpIsDismissed() {
|
||||
if (Ion::USB::isPlugged()) {
|
||||
Ion::USB::enable();
|
||||
}
|
||||
}
|
||||
|
||||
Window * AppsContainer::window() {
|
||||
return &m_window;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "math_toolbox.h"
|
||||
#include "variable_box_controller.h"
|
||||
#include "exam_pop_up_controller.h"
|
||||
#include "exam_pop_up_controller_delegate.h"
|
||||
#include "led_timer.h"
|
||||
#include "battery_timer.h"
|
||||
#include "suspend_timer.h"
|
||||
@@ -23,7 +24,7 @@
|
||||
|
||||
#include <ion/events.h>
|
||||
|
||||
class AppsContainer : public Container {
|
||||
class AppsContainer : public Container, ExamPopUpControllerDelegate {
|
||||
public:
|
||||
AppsContainer();
|
||||
static bool poincareCircuitBreaker();
|
||||
@@ -47,6 +48,8 @@ public:
|
||||
void setShiftAlphaStatus(Ion::Events::ShiftAlphaStatus newStatus);
|
||||
OnBoarding::UpdateController * updatePopUpController();
|
||||
void redrawWindow();
|
||||
// Exam pop-up controller delegate
|
||||
void examDeactivatingPopUpIsDismissed() override;
|
||||
protected:
|
||||
Home::App::Snapshot * homeAppSnapshot() { return &m_homeSnapshot; }
|
||||
private:
|
||||
|
||||
@@ -4,17 +4,31 @@
|
||||
#include "global_preferences.h"
|
||||
#include <assert.h>
|
||||
|
||||
ExamPopUpController::ExamPopUpController() :
|
||||
ExamPopUpController::ExamPopUpController(ExamPopUpControllerDelegate * delegate) :
|
||||
ViewController(nullptr),
|
||||
m_contentView(this),
|
||||
m_isActivatingExamMode(false)
|
||||
m_isActivatingExamMode(false),
|
||||
m_delegate(delegate)
|
||||
{
|
||||
}
|
||||
|
||||
void ExamPopUpController::setActivatingExamMode(bool activatingExamMode) {
|
||||
if (m_isActivatingExamMode != activatingExamMode) {
|
||||
m_isActivatingExamMode = activatingExamMode;
|
||||
m_contentView.setMessages(activatingExamMode);
|
||||
}
|
||||
}
|
||||
|
||||
View * ExamPopUpController::view() {
|
||||
return &m_contentView;
|
||||
}
|
||||
|
||||
void ExamPopUpController::viewDidDisappear() {
|
||||
if (m_isActivatingExamMode == false) {
|
||||
m_delegate->examDeactivatingPopUpIsDismissed();
|
||||
}
|
||||
}
|
||||
|
||||
void ExamPopUpController::didBecomeFirstResponder() {
|
||||
m_contentView.setSelectedButton(0, app());
|
||||
}
|
||||
@@ -31,17 +45,6 @@ bool ExamPopUpController::handleEvent(Ion::Events::Event event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void ExamPopUpController::setActivatingExamMode(bool activatingExamMode) {
|
||||
if (m_isActivatingExamMode != activatingExamMode) {
|
||||
m_isActivatingExamMode = activatingExamMode;
|
||||
m_contentView.setMessages(activatingExamMode);
|
||||
}
|
||||
}
|
||||
|
||||
bool ExamPopUpController::isActivatingExamMode() {
|
||||
return m_isActivatingExamMode;
|
||||
}
|
||||
|
||||
ExamPopUpController::ContentView::ContentView(Responder * parentResponder) :
|
||||
m_cancelButton(parentResponder, I18n::Message::Cancel, Invocation([](void * context, void * sender) {
|
||||
ExamPopUpController * controller = (ExamPopUpController *)context;
|
||||
|
||||
@@ -2,15 +2,19 @@
|
||||
#define APPS_EXAM_POP_UP_CONTROLLER_H
|
||||
|
||||
#include <escher.h>
|
||||
#include "exam_pop_up_controller_delegate.h"
|
||||
|
||||
class ExamPopUpController : public ViewController {
|
||||
public:
|
||||
ExamPopUpController();
|
||||
ExamPopUpController(ExamPopUpControllerDelegate * delegate);
|
||||
void setActivatingExamMode(bool activingExamMode);
|
||||
bool isActivatingExamMode() const { return m_isActivatingExamMode; }
|
||||
// View Controller
|
||||
View * view() override;
|
||||
void viewDidDisappear() override;
|
||||
// Responder
|
||||
void didBecomeFirstResponder() override;
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
void setActivatingExamMode(bool activingExamMode);
|
||||
bool isActivatingExamMode();
|
||||
private:
|
||||
class ContentView : public View {
|
||||
public:
|
||||
@@ -36,6 +40,7 @@ private:
|
||||
};
|
||||
ContentView m_contentView;
|
||||
bool m_isActivatingExamMode;
|
||||
ExamPopUpControllerDelegate * m_delegate;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
10
apps/exam_pop_up_controller_delegate.h
Normal file
10
apps/exam_pop_up_controller_delegate.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef APPS_EXAM_POP_UP_CONTROLLER_DELEGATE_H
|
||||
#define APPS_EXAM_POP_UP_CONTROLLER_DELEGATE_H
|
||||
|
||||
class ExamPopUpControllerDelegate {
|
||||
public:
|
||||
virtual void examDeactivatingPopUpIsDismissed() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user