3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.tizenopensource.org/license
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 #include "FaceTracker.h"
19 #include "FaceTrackerFrame.h"
20 #include "FaceTrackerForm.h"
22 using namespace Tizen::App;
23 using namespace Tizen::Base;
24 using namespace Tizen::System;
25 using namespace Tizen::Ui;
26 using namespace Tizen::Ui::Controls;
28 FaceTrackerApp::FaceTrackerApp(void)
32 FaceTrackerApp::~FaceTrackerApp(void)
34 DeviceManager::RemoveDeviceEventListener(Charger,*this);
38 FaceTrackerApp::CreateInstance(void)
40 return new (std::nothrow) FaceTrackerApp();
44 FaceTrackerApp::OnAppInitializing(AppRegistry& appRegistry)
50 FaceTrackerApp::OnAppInitialized(void)
52 DeviceManager::AddDeviceEventListener(Charger,*this);
54 FaceTrackerFrame* pFaceTrackerFrame = new (std::nothrow) FaceTrackerFrame();
55 TryReturn(pFaceTrackerFrame != null, false, "Failed to create FaceTrackerFrame");
56 result r = pFaceTrackerFrame->Construct();
57 TryReturn(r == E_SUCCESS, false, "Failed to construct FaceTrackerFrame");
58 pFaceTrackerFrame->SetName(L"FaceTracker");
59 AddFrame(*pFaceTrackerFrame);
65 FaceTrackerApp::OnAppWillTerminate(void)
72 FaceTrackerApp::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
78 FaceTrackerApp::OnForeground(void)
80 FaceTrackerForm *pFaceTrackerForm = (FaceTrackerForm *)(GetFrame(L"FaceTracker")->GetCurrentForm());
81 pFaceTrackerForm->StartCamera();
85 FaceTrackerApp::OnBackground(void)
87 FaceTrackerForm *pFaceTrackerForm = (FaceTrackerForm *)(GetFrame(L"FaceTracker")->GetCurrentForm());
88 pFaceTrackerForm->StopCamera();
92 FaceTrackerApp::OnLowMemory(void)
97 FaceTrackerApp::OnBatteryLevelChanged(BatteryLevel batteryLevel)
99 bool isCharging = false;
101 Tizen::System::RuntimeInfo::GetValue(String(L"IsCharging"),isCharging);
108 if ((batteryLevel == BATTERY_LEVEL_LOW) || (batteryLevel == BATTERY_LEVEL_CRITICAL) || (batteryLevel == BATTERY_LEVEL_EMPTY))
112 result r = msgBox.Construct("Warning","Battery is low. Terminating App.",MSGBOX_STYLE_NONE,4000);
113 TryReturn(r == E_SUCCESS, , "Failed to construct MessageBox");
114 msgBox.ShowAndWait(modalResult);
116 Application::GetInstance()->Terminate();
121 FaceTrackerApp::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String &state)
123 BatteryLevel level = BATTERY_FULL;
125 if (deviceType == Charger)
127 Tizen::System::Battery::GetCurrentLevel(level);
128 OnBatteryLevelChanged(level);
133 FaceTrackerApp::OnScreenOn(void)
138 FaceTrackerApp::OnScreenOff(void)