diff --git a/apps/hardware_test/Makefile b/apps/hardware_test/Makefile index 9dccad367..209104e22 100644 --- a/apps/hardware_test/Makefile +++ b/apps/hardware_test/Makefile @@ -12,5 +12,4 @@ app_objs += $(addprefix apps/hardware_test/,\ screen_test_controller.o\ screen_test_controller.o\ serial_number_controller.o\ - usb_test_controller.o\ ) diff --git a/apps/hardware_test/app.cpp b/apps/hardware_test/app.cpp index 4852060f6..fa0720758 100644 --- a/apps/hardware_test/app.cpp +++ b/apps/hardware_test/app.cpp @@ -28,13 +28,12 @@ App::WizardViewController::WizardViewController(Responder * parentResponder) : m_screenTestController(this), m_ledTestController(this), m_batteryTestController(this), - m_USBTestController(this), m_serialNumberController(this) { } int App::WizardViewController::numberOfChildren() { - return 6; + return 5; } ViewController * App::WizardViewController::childAtIndex(int i) { @@ -43,7 +42,6 @@ ViewController * App::WizardViewController::childAtIndex(int i) { &m_screenTestController, &m_ledTestController, &m_batteryTestController, - &m_USBTestController, &m_serialNumberController }; return children[i]; diff --git a/apps/hardware_test/app.h b/apps/hardware_test/app.h index 12e9b3dc2..6d5047ffc 100644 --- a/apps/hardware_test/app.h +++ b/apps/hardware_test/app.h @@ -6,7 +6,6 @@ #include "screen_test_controller.h" #include "led_test_controller.h" #include "battery_test_controller.h" -#include "usb_test_controller.h" #include "serial_number_controller.h" class AppsContainer; @@ -32,7 +31,6 @@ private: ScreenTestController m_screenTestController; LEDTestController m_ledTestController; BatteryTestController m_batteryTestController; - USBTestController m_USBTestController; SerialNumberController m_serialNumberController; }; diff --git a/apps/hardware_test/usb_test_controller.cpp b/apps/hardware_test/usb_test_controller.cpp deleted file mode 100644 index 16dd459ce..000000000 --- a/apps/hardware_test/usb_test_controller.cpp +++ /dev/null @@ -1,95 +0,0 @@ -#include "usb_test_controller.h" -extern "C" { -#include -} -#include - -using namespace Poincare; - -namespace HardwareTest { - -USBTestController::USBTestController(Responder * parentResponder) : - ViewController(parentResponder), - m_view(), - m_shouldPlugUSB(true) -{ -} - -View * USBTestController::view() { - return &m_view; -} - -bool USBTestController::handleEvent(Ion::Events::Event e) { - if (Ion::USB::isPlugged() && m_shouldPlugUSB) { - m_view.USBTextView()->setText(k_USBUnplugText); - m_view.arrowView()->setDirection(false); - m_view.arrowView()->setColor(KDColorRed); - m_shouldPlugUSB = false; - return true; - } - if (!Ion::USB::isPlugged() && !m_shouldPlugUSB) { - // We're done, tell WizardViewController to go to the next step - return false; - } - return true; -} - -void USBTestController::viewWillAppear() { - m_shouldPlugUSB = true; - m_view.USBTextView()->setText(k_USBPlugText); - m_view.arrowView()->setDirection(true); - m_view.arrowView()->setColor(KDColorGreen); -} - -void USBTestController::ContentView::USBView::drawRect(KDContext * ctx, KDRect rect) const { - KDCoordinate width = bounds().width(); - KDCoordinate height = bounds().height(); - ctx->fillRect(KDRect((width-k_USBHoleWidth+10)/2, 0, k_USBHoleWidth-10, 5), KDColorBlack); - ctx->fillRect(KDRect((width-k_USBHoleWidth)/2, 5, k_USBHoleWidth, k_USBHoleHeight-5), KDColorBlack); - ctx->fillRect(KDRect((width-k_USBHoleWidth)/2, k_USBHoleHeight+k_marginHeight, k_USBHoleWidth, 25), KDColorBlack); - ctx->fillRect(KDRect((width-k_USBHoleWidth)/2+10, k_USBHoleHeight+k_marginHeight+10, 7, 5), KDColorWhite); - ctx->fillRect(KDRect((width-k_USBHoleWidth)/2+10+7+6, k_USBHoleHeight+k_marginHeight+10, 7, 5), KDColorWhite); - ctx->fillRect(KDRect((width-k_USBHoleWidth)/2, k_USBHoleHeight+k_marginHeight+30, k_USBHoleWidth, 50), KDColorBlack); - ctx->fillRect(KDRect((width-10)/2, k_USBHoleHeight+k_marginHeight+30+50, 10, 10), KDColorBlack); - ctx->fillRect(KDRect((width-4)/2, k_USBHoleHeight+k_marginHeight+30+50+10, 4, height-(k_USBHoleHeight+k_marginHeight+30+50+10)), KDColorBlack); -} - -USBTestController::ContentView::ContentView() : - SolidColorView(KDColorWhite), - m_USBTextView(KDText::FontSize::Large), - m_USBView(), - m_arrowView() -{ -} - -BufferTextView * USBTestController::ContentView::USBTextView() { - return &m_USBTextView; -} - -ArrowView * USBTestController::ContentView::arrowView() { - return &m_arrowView; -} - -void USBTestController::ContentView::layoutSubviews() { - m_USBTextView.setFrame(KDRect(0, 0, bounds().width(), k_textHeight)); - m_USBView.setFrame(KDRect(0, k_textHeight, bounds().width(), bounds().height()-k_textHeight)); - m_arrowView.setFrame(KDRect(0, k_textHeight+USBView::k_USBHoleHeight+5, bounds().width(), USBView::k_marginHeight-10)); -} - -int USBTestController::ContentView::numberOfSubviews() const { - return 3; -} - -View * USBTestController::ContentView::subviewAtIndex(int index) { - assert(index >= 0 && index < 3); - if(index == 0) { - return &m_USBTextView; - } - if (index == 2) { - return &m_USBView; - } - return &m_arrowView; -} - -} - diff --git a/apps/hardware_test/usb_test_controller.h b/apps/hardware_test/usb_test_controller.h deleted file mode 100644 index 228641ceb..000000000 --- a/apps/hardware_test/usb_test_controller.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef HARDWARE_TEST_USB_TEST_CONTROLLER_H -#define HARDWARE_TEST_USB_TEST_CONTROLLER_H - -#include -#include "arrow_view.h" - -namespace HardwareTest { - -class USBTestController : public ViewController { -public: - USBTestController(Responder * parentResponder); - View * view() override; - void viewWillAppear() override; - bool handleEvent(Ion::Events::Event e) override; -private: - //bool fire() override; - class ContentView : public SolidColorView { - public: - ContentView(); - BufferTextView * USBTextView(); - ArrowView * arrowView(); - private: - class USBView : public View { - public: - void drawRect(KDContext * ctx, KDRect rect) const override; - constexpr static KDCoordinate k_USBHoleWidth = 40; - constexpr static KDCoordinate k_USBHoleHeight = 20; - constexpr static KDCoordinate k_marginHeight = 50; - }; - constexpr static KDCoordinate k_textHeight = 50; - void layoutSubviews() override; - int numberOfSubviews() const override; - View * subviewAtIndex(int index) override; - BufferTextView m_USBTextView; - USBView m_USBView; - ArrowView m_arrowView; - }; - constexpr static const char * k_USBPlugText = "PLUG USB"; - constexpr static const char * k_USBUnplugText = "OK, UNPLUG USB"; - ContentView m_view; - bool m_shouldPlugUSB; -}; - -} - -#endif -