, public Tizen::System::IScreenEventListener
, public Tizen::Ui::IActionEventListener
, public Tizen::Ui::Controls::IFormBackEventListener
+ , public Tizen::System::IDeviceEventListener
{
public:
static Tizen::App::Application* CreateInstance(void);
void OnFormBackRequested(Tizen::Ui::Controls::Form &source);
+ // Called when device is connected or removed
+ virtual void OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String &state);
+
private:
Tracker* __pTracker;
TouchForm* __pForm;
#include "GLtools.h"
using namespace Tizen::App;
+using namespace Tizen::Base;
using namespace Tizen::Ui::Controls;
using namespace Tizen::System;
QrCodeRecognizer::~QrCodeRecognizer()
{
+ DeviceManager::RemoveDeviceEventListener(Charger,*this);
}
__pForm->Initialize(this, this);
pAppFrame->AddControl(*__pForm);
+ // dealing with low battery
+ DeviceManager::AddDeviceEventListener(Charger,*this);
+ bool isCharging = true;
+ Tizen::System::RuntimeInfo::GetValue(String(L"IsCharging"),isCharging);
+ if (isCharging == false)
+ {
+ BatteryLevel level = BATTERY_FULL;
+ Tizen::System::Battery::GetCurrentLevel(level);
+ if ((level == BATTERY_EMPTY) || (level == BATTERY_CRITICAL) || (level == BATTERY_LOW))
+ {
+ MessageBox msgBox;
+ int result = 0;
+
+ msgBox.Construct("Warning", "Low battery. Terminating App.", MSGBOX_STYLE_NONE, 3000);
+ msgBox.ShowAndWait(result);
+
+ switch (result)
+ {
+ case MSGBOX_RESULT_CLOSE:
+ Tizen::App::Application::GetInstance()->Terminate();
+ return false;
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
if (!GLtools::initGL(__pForm))
{
MessageBox msgBox;
void
QrCodeRecognizer::OnBatteryLevelChanged(BatteryLevel batteryLevel)
{
+ bool isCharging = true;
+ Tizen::System::RuntimeInfo::GetValue(String(L"IsCharging"),isCharging);
+ if (isCharging == false)
+ {
+ if ((batteryLevel == BATTERY_EMPTY) || (batteryLevel == BATTERY_CRITICAL) || (batteryLevel == BATTERY_LOW))
+ {
+ MessageBox msgBox;
+ int result = 0;
+
+ msgBox.Construct("Warning","Low Battery.\nPlease charge to use.",MSGBOX_STYLE_OK);
+ msgBox.ShowAndWait(result);
+
+ if(result == MSGBOX_RESULT_OK)
+ {
+ Application::GetInstance()->Terminate();
+ return;
+ }
+ }
+ }
}
void
__pPopup->SetShowState(true);
__pPopup->Show();
}
+
+void
+QrCodeRecognizer::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String &state)
+{
+ if (deviceType == Charger)
+ {
+ BatteryLevel level = BATTERY_FULL;
+ Tizen::System::Battery::GetCurrentLevel(level);
+ OnBatteryLevelChanged(level);
+ }
+}