From: HyungKyu Song Date: Fri, 15 Feb 2013 06:11:10 +0000 (+0900) Subject: Tizen 2.0 Release X-Git-Tag: 2.0_release X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Ftags%2F2.0_release;p=samples%2Fnative%2FMetalDetector.git Tizen 2.0 Release --- diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..917b21e --- /dev/null +++ b/LICENSE @@ -0,0 +1,206 @@ +Flora License + +Version 1.0, May, 2012 + +http://www.tizenopensource.org/license + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and +all other entities that control, are controlled by, or are +under common control with that entity. For the purposes of +this definition, "control" means (i) the power, direct or indirect, +to cause the direction or management of such entity, +whether by contract or otherwise, or (ii) ownership of fifty percent (50%) +or more of the outstanding shares, or (iii) beneficial ownership of +such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation source, +and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, +made available under the License, as indicated by a copyright notice +that is included in or attached to the work (an example is provided +in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, +that is based on (or derived from) the Work and for which the editorial +revisions, annotations, elaborations, or other modifications represent, +as a whole, an original work of authorship. For the purposes of this License, +Derivative Works shall not include works that remain separable from, +or merely link (or bind by name) to the interfaces of, the Work and +Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original +version of the Work and any modifications or additions to that Work or +Derivative Works thereof, that is intentionally submitted to Licensor +for inclusion in the Work by the copyright owner or by an individual or +Legal Entity authorized to submit on behalf of the copyright owner. +For the purposes of this definition, "submitted" means any form of +electronic, verbal, or written communication sent to the Licensor or +its representatives, including but not limited to communication on +electronic mailing lists, source code control systems, and issue +tracking systems that are managed by, or on behalf of, the Licensor +for the purpose of discussing and improving the Work, but excluding +communication that is conspicuously marked or otherwise designated +in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +"Tizen Certified Platform" shall mean a software platform that complies +with the standards set forth in the Compatibility Definition Document +and passes the Compatibility Test Suite as defined from time to time +by the Tizen Technical Steering Group and certified by the Tizen +Association or its designated agent. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work +solely as incorporated into a Tizen Certified Platform, where such +license applies only to those patent claims licensable by such +Contributor that are necessarily infringed by their Contribution(s) +alone or by combination of their Contribution(s) with the Work solely +as incorporated into a Tizen Certified Platform to which such +Contribution(s) was submitted. If You institute patent litigation +against any entity (including a cross-claim or counterclaim +in a lawsuit) alleging that the Work or a Contribution incorporated +within the Work constitutes direct or contributory patent infringement, +then any patent licenses granted to You under this License for that +Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof pursuant to the copyright license +above, in any medium, with or without modifications, and in Source or +Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works + a copy of this License; and + 2. You must cause any modified files to carry prominent notices stating + that You changed the files; and + 3. You must retain, in the Source form of any Derivative Works that + You distribute, all copyright, patent, trademark, and attribution + notices from the Source form of the Work, excluding those notices + that do not pertain to any part of the Derivative Works; and + 4. If the Work includes a "NOTICE" text file as part of its distribution, + then any Derivative Works that You distribute must include a readable + copy of the attribution notices contained within such NOTICE file, + excluding those notices that do not pertain to any part of + the Derivative Works, in at least one of the following places: + within a NOTICE text file distributed as part of the Derivative Works; + within the Source form or documentation, if provided along with the + Derivative Works; or, within a display generated by the Derivative Works, + if and wherever such third-party notices normally appear. + The contents of the NOTICE file are for informational purposes only + and do not modify the License. + +You may add Your own attribution notices within Derivative Works +that You distribute, alongside or as an addendum to the NOTICE text +from the Work, provided that such additional attribution notices +cannot be construed as modifying the License. You may add Your own +copyright statement to Your modifications and may provide additional or +different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works +as a whole, provided Your use, reproduction, and distribution of +the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Flora License to your work + +To apply the Flora License to your work, attach the following +boilerplate notice, with the fields enclosed by brackets "[]" +replaced with your own identifying information. (Don't include +the brackets!) The text should be enclosed in the appropriate +comment syntax for the file format. We also recommend that a +file or class name and description of purpose be included on the +same "printed page" as the copyright notice for easier +identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Flora License, Version 1.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.tizenopensource.org/license + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..3997999 --- /dev/null +++ b/NOTICE @@ -0,0 +1,4 @@ +Copyright (c) Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under Flora License, Version 1. +Please, see the LICENSE file for Flora License terms and conditions. + diff --git a/description.xml b/description.xml new file mode 100644 index 0000000..97ecb3b --- /dev/null +++ b/description.xml @@ -0,0 +1,9 @@ + + + + + MetalDetector + 1.0 + screenshot.png + The MetalDetector sample application demonstrates how you can use the magnetic sensor to enable your device to detect metallic objects around it. + diff --git a/project/data/nofile.dummy b/project/data/nofile.dummy new file mode 100644 index 0000000..e69de29 diff --git a/project/home/nofile.dummy b/project/home/nofile.dummy new file mode 100644 index 0000000..e69de29 diff --git a/project/inc/MetalDetector.h b/project/inc/MetalDetector.h new file mode 100644 index 0000000..ef1693c --- /dev/null +++ b/project/inc/MetalDetector.h @@ -0,0 +1,76 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _METAL_DETECTOR_H_ +#define _METAL_DETECTOR_H_ + +#include +#include +#include +#include + +/** + * [MetalDetectorApp] UiApp must inherit from UiApp class + * which provides basic features necessary to define an UiApp. + */ +class MetalDetectorApp + : public Tizen::App::UiApp + , public Tizen::System::IScreenEventListener +{ +public: + /** + * [Test] UiApp must have a factory method that creates an instance of itself. + */ + static Tizen::App::UiApp* CreateInstance(void); + +public: + MetalDetectorApp(void); + virtual~MetalDetectorApp(void); + +public: + // Called when the UiApp is initializing. + bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry); + + // Called when the UiApp initializing is finished. + bool OnAppInitialized(void); + + // Called when the UiApp is requested to terminate. + bool OnAppWillTerminate(void); + + // Called when the UiApp is terminating. + bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false); + + // Called when the UiApp's frame moves to the top of the screen. + void OnForeground(void); + + // Called when this UiApp's frame is moved from top of the screen to the background. + void OnBackground(void); + + // Called when the system memory is not sufficient to run the UiApp any further. + void OnLowMemory(void); + + // Called when the battery level changes. + void OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel); + + // Called when the screen turns on. + void OnScreenOn(void); + + // Called when the screen turns off. + void OnScreenOff(void); +}; + +#endif // _METAL_DETECTOR_H_ diff --git a/project/inc/MetalDetectorDetectForm.h b/project/inc/MetalDetectorDetectForm.h new file mode 100644 index 0000000..3eedecd --- /dev/null +++ b/project/inc/MetalDetectorDetectForm.h @@ -0,0 +1,79 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _METAL_DETECTOR_DETECT_FORM_H_ +#define _METAL_DETECTOR_DETECT_FORM_H_ + +#include +#include +#include +#include +#include + +class MetalDetectorDetectForm + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IFormBackEventListener + , public Tizen::Ui::Scenes::ISceneEventListener + , public Tizen::Uix::Sensor::ISensorEventListener + , public Tizen::Base::Runtime::ITimerEventListener +{ +public: + MetalDetectorDetectForm(void); + virtual ~MetalDetectorDetectForm(void); + bool Initialize(void); + +public: + bool InitTimer(void); + void RegisterSensor(void); + void UnRegisterSensor(void); + bool IsSensorStart(void); + + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source); + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, + const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, + const Tizen::Ui::Scenes::SceneId& nextSceneId); + + virtual result OnDraw(void); + virtual void OnDataReceived(Tizen::Uix::Sensor::SensorType sensorType, Tizen::Uix::Sensor::SensorData& sensorData, result r); + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + +private: + result GetFileList(Tizen::Base::String dirPath); + result AddElementInFileList(Tizen::Base::Collection::ArrayList& fileList, Tizen::Base::String& dirPath, Tizen::Io::DirEntry& DirEntry); + void StartTimer(int interval); + void StopTimer(void); + void StartSensor(void); + void StopSensor(void); + +private: + Tizen::Uix::Sensor::SensorManager __sensorMgr; + Tizen::Base::Collection::ArrayList __fileList; + Tizen::Media::Image* __pImage; + Tizen::Graphics::Canvas* __pCanvas; + Tizen::Base::Runtime::Timer* __pTimer; + Tizen::Ui::Controls::Label* __pDetectingMessageLabel; + int __timerInterval; + int __fileIndex; + double __magneticFieldMagnitude; + bool __isSensorStart; + bool __isFirstDrawing; +}; + +#endif //_METAL_DETECTOR_DETECT_FORM_H_ diff --git a/project/inc/MetalDetectorFormFactory.h b/project/inc/MetalDetectorFormFactory.h new file mode 100644 index 0000000..6dcb28c --- /dev/null +++ b/project/inc/MetalDetectorFormFactory.h @@ -0,0 +1,33 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _METAL_DETECTOR_FORM_FACTORY_H_ +#define _METAL_DETECTOR_FORM_FACTORY_H_ + +#include + +class MetalDetectorFormFactory + : public Tizen::Ui::Scenes::IFormFactory +{ +public: + MetalDetectorFormFactory(void); + virtual ~MetalDetectorFormFactory(void); + + virtual Tizen::Ui::Controls::Form* CreateFormN(const Tizen::Base::String& formId, const Tizen::Ui::Scenes::SceneId& sceneId); +}; + +#endif // _METAL_DETECTOR_FORM_FACTORY_H_ diff --git a/project/inc/MetalDetectorFrame.h b/project/inc/MetalDetectorFrame.h new file mode 100644 index 0000000..97292f2 --- /dev/null +++ b/project/inc/MetalDetectorFrame.h @@ -0,0 +1,36 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _METAL_DETECTOR_FRAME_H_ +#define _METAL_DETECTOR_FRAME_H_ + +#include +#include + +class MetalDetectorFrame + : public Tizen::Ui::Controls::Frame +{ +public: + MetalDetectorFrame(void); + virtual ~MetalDetectorFrame(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); +}; + +#endif // _METAL_DETECTOR_FRAME_H_ diff --git a/project/inc/MetalDetectorMainForm.h b/project/inc/MetalDetectorMainForm.h new file mode 100644 index 0000000..38abbd8 --- /dev/null +++ b/project/inc/MetalDetectorMainForm.h @@ -0,0 +1,48 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _METAL_DETECTOR_MAIN_FORM_H_ +#define _METAL_DETECTOR_MAIN_FORM_H_ + +#include +#include + +class MetalDetectorMainForm + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IActionEventListener + , public Tizen::Ui::Scenes::ISceneEventListener + , public Tizen::Ui::Controls::IFormBackEventListener +{ +public: + MetalDetectorMainForm(void); + virtual ~MetalDetectorMainForm(void); + bool Initialize(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, + const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, + const Tizen::Ui::Scenes::SceneId& nextSceneId); + virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source); +protected: + static const int ID_BUTTON_START = 101; +}; + +#endif // _METAL_DETECTOR_MAIN_FORM_H_ diff --git a/project/inc/MetalDetectorPanelFactory.h b/project/inc/MetalDetectorPanelFactory.h new file mode 100644 index 0000000..227386f --- /dev/null +++ b/project/inc/MetalDetectorPanelFactory.h @@ -0,0 +1,33 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _METAL_DETECTOR_PANEL_FACTORY_H_ +#define _METAL_DETECTOR_PANEL_FACTORY_H_ + +#include + +class MetalDetectorPanelFactory + : public Tizen::Ui::Scenes::IPanelFactory +{ +public: + MetalDetectorPanelFactory(void); + virtual ~MetalDetectorPanelFactory(void); + + virtual Tizen::Ui::Controls::Panel* CreatePanelN(const Tizen::Base::String& panelId, const Tizen::Ui::Scenes::SceneId& sceneId); +}; + +#endif // _METAL_DETECTOR_PANEL_FACTORY_H_ diff --git a/project/manifest.xml b/project/manifest.xml new file mode 100644 index 0000000..bb59da2 --- /dev/null +++ b/project/manifest.xml @@ -0,0 +1,28 @@ + + + $(manifestAppId) + 3.0.0 + C++App + + + + + 2.0 + + http://tizen.org/privilege/alarm + http://tizen.org/privilege/power + + + + + + $(projectName) + + + mainmenu.png + + + + + + diff --git a/project/packaging/org.tizen.MetalDetector.spec b/project/packaging/org.tizen.MetalDetector.spec new file mode 100755 index 0000000..d0ae9bc --- /dev/null +++ b/project/packaging/org.tizen.MetalDetector.spec @@ -0,0 +1,49 @@ +Name: org.tizen.MetalDetector +Summary: MetalDetector sample application +Version: 1.2.1.0 +Release: 1 +Group: TO_BE/FILLED_IN +License: TO BE FILLED IN +Source0: %{name}-%{version}.tar.gz +BuildRequires: cmake +BuildRequires: pkgconfig(osp-appfw) +BuildRequires: pkgconfig(osp-uifw) +BuildRequires: pkgconfig(osp-image) +BuildRequires: pkgconfig(osp-media) +BuildRequires: pkgconfig(osp-net) +BuildRequires: osp-appfw-internal-devel + +%description +MetalDetector sample application + +%prep +%setup -q + +%build +MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` +%ifarch %{ix86} +CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ -D_OSP_EMUL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} +%else +CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_ARMEL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} +%endif + +# Call make instruction with smp support +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install + +%post -p /sbin/ldconfig +app_id=r8g4676332 +echo "/usr/etc/package-manager/backend/oap -i /opt/apps/org.tizen."${app_id} +/usr/etc/package-manager/backend/oap -i /opt/apps/org.tizen.${app_id} + +%postun -p /sbin/ldconfig +app_id=r8g4676332 +echo "/usr/etc/package-manager/backend/oap -u "${app_id} +/usr/etc/package-manager/backend/oap -u ${APP_ID} + +%files +%defattr(-,root,root,-) +/opt/apps/* diff --git a/project/res/1.jpg b/project/res/1.jpg new file mode 100644 index 0000000..b729b3b Binary files /dev/null and b/project/res/1.jpg differ diff --git a/project/res/2.jpg b/project/res/2.jpg new file mode 100644 index 0000000..9197924 Binary files /dev/null and b/project/res/2.jpg differ diff --git a/project/res/3.jpg b/project/res/3.jpg new file mode 100644 index 0000000..389e7e0 Binary files /dev/null and b/project/res/3.jpg differ diff --git a/project/res/4.jpg b/project/res/4.jpg new file mode 100644 index 0000000..ba91edf Binary files /dev/null and b/project/res/4.jpg differ diff --git a/project/res/5.jpg b/project/res/5.jpg new file mode 100644 index 0000000..2d74464 Binary files /dev/null and b/project/res/5.jpg differ diff --git a/project/res/6.jpg b/project/res/6.jpg new file mode 100644 index 0000000..55d101f Binary files /dev/null and b/project/res/6.jpg differ diff --git a/project/res/7.jpg b/project/res/7.jpg new file mode 100644 index 0000000..6478803 Binary files /dev/null and b/project/res/7.jpg differ diff --git a/project/res/8.jpg b/project/res/8.jpg new file mode 100644 index 0000000..fd94efc Binary files /dev/null and b/project/res/8.jpg differ diff --git a/project/res/magnetic.txt b/project/res/magnetic.txt new file mode 100644 index 0000000..c0b621b --- /dev/null +++ b/project/res/magnetic.txt @@ -0,0 +1,37 @@ +100,10,30,30 +200,11,31,30 +300,12,32,30 +400,13,33,30 +800,14,34,30 +900,15,35,30 +1000,16,36,30 +1100,17,37,30 +1200,18,38,30 +1300,19,39,30 +1400,20,40,30 +1500,21,41,30 +1600,22,42,30 +1700,23,43,30 +1800,24,44,30 +1900,25,45,30 +2000,26,46,30 +2100,27,47,30 +2200,28,48,30 +2300,29,49,30 +2400,30,50,30 +2500,31,51,30 +2600,32,52,30 +2700,33,53,30 +2800,34,54,30 +2900,35,55,30 +3000,36,56,30 +3100,37,57,30 +3200,38,58,30 +3300,41,59,30 +3400,42,60,30 +3500,43,61,30 +3600,44,62,30 +3700,45,63,30 +3800,46,64,30 +3900,47,65,30 +4000,48,66,30 \ No newline at end of file diff --git a/project/shared/data/nofile.dummy b/project/shared/data/nofile.dummy new file mode 100644 index 0000000..e69de29 diff --git a/project/shared/res/screen-density-xhigh/mainmenu.png b/project/shared/res/screen-density-xhigh/mainmenu.png new file mode 100755 index 0000000..983c883 Binary files /dev/null and b/project/shared/res/screen-density-xhigh/mainmenu.png differ diff --git a/project/shared/trusted/nofile.dummy b/project/shared/trusted/nofile.dummy new file mode 100644 index 0000000..e69de29 diff --git a/project/src/MetalDetector.cpp b/project/src/MetalDetector.cpp new file mode 100644 index 0000000..550852d --- /dev/null +++ b/project/src/MetalDetector.cpp @@ -0,0 +1,117 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include +#include "MetalDetector.h" +#include "MetalDetectorFrame.h" +#include "MetalDetectorFormFactory.h" +#include "MetalDetectorPanelFactory.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::System; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +MetalDetectorApp::MetalDetectorApp(void) +{ +} + +MetalDetectorApp::~MetalDetectorApp(void) +{ +} + +UiApp* +MetalDetectorApp::CreateInstance(void) +{ + return new (std::nothrow) MetalDetectorApp(); +} + +bool +MetalDetectorApp::OnAppInitializing(AppRegistry& appRegistry) +{ + return true; +} + +bool +MetalDetectorApp::OnAppInitialized(void) +{ + // Create a Frame + MetalDetectorFrame* pMetalDetectorFrame = new (std::nothrow) MetalDetectorFrame(); + TryReturn(pMetalDetectorFrame, false, "MetalDetectorFrame creation failed."); + pMetalDetectorFrame->Construct(); + pMetalDetectorFrame->SetName(L"MetalDetector"); + AddFrame(*pMetalDetectorFrame); + + // Prepare Scene management. + SceneManager* pSceneManager = SceneManager::GetInstance(); + static MetalDetectorFormFactory formFactory; + static MetalDetectorPanelFactory panelFactory; + pSceneManager->RegisterFormFactory(formFactory); + pSceneManager->RegisterPanelFactory(panelFactory); + pSceneManager->RegisterScene(L"MainScene", L"MainForm", L""); + pSceneManager->RegisterScene(L"DetectScene", L"DetectForm", L""); + + // Goto the scene. + if (pSceneManager->GoForward(ForwardSceneTransition(L"MainScene")) != E_SUCCESS) + return false; + + return true; +} + +bool +MetalDetectorApp::OnAppWillTerminate(void) +{ + return true; +} + +bool +MetalDetectorApp::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination) +{ + return true; +} + +void +MetalDetectorApp::OnForeground(void) +{ +} + +void +MetalDetectorApp::OnBackground(void) +{ +} + +void +MetalDetectorApp::OnLowMemory(void) +{ +} + +void +MetalDetectorApp::OnBatteryLevelChanged(BatteryLevel batteryLevel) +{ +} + +void +MetalDetectorApp::OnScreenOn(void) +{ +} + +void +MetalDetectorApp::OnScreenOff(void) +{ +} diff --git a/project/src/MetalDetectorDetectForm.cpp b/project/src/MetalDetectorDetectForm.cpp new file mode 100644 index 0000000..d35446d --- /dev/null +++ b/project/src/MetalDetectorDetectForm.cpp @@ -0,0 +1,478 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include +#include +#include +#include +#include "MetalDetectorDetectForm.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Base::Utility; +using namespace Tizen::App; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; +using namespace Tizen::Graphics; +using namespace Tizen::Io; +using namespace Tizen::Media; +using namespace Tizen::System; +using namespace Tizen::Uix::Sensor; + +static const int MAX_B_VALUE = 100; +static const int TIMEINTERVAL_LEVEL0 = 5000; +static const int TIMEINTERVAL_LEVEL1 = 1100; +static const int TIMEINTERVAL_LEVEL2 = 900; +static const int TIMEINTERVAL_LEVEL3 = 600; +static const int TIMEINTERVAL_LEVEL4 = 400; +static const int TIMEINTERVAL_LEVEL5 = 250; +static const int TIMEINTERVAL_LEVEL6 = 150; +static const int IMAGE_COUNT = 8; +static const wchar_t IMAGE_EXT[] = L"jpg"; + +MetalDetectorDetectForm::MetalDetectorDetectForm(void) + : __sensorMgr() + , __fileList() + , __pImage(null) + , __pCanvas(null) + , __pTimer(null) + , __pDetectingMessageLabel(null) + , __timerInterval(TIMEINTERVAL_LEVEL1) + , __fileIndex(0) + , __magneticFieldMagnitude(0.0) + , __isSensorStart(false) + , __isFirstDrawing(true) +{ + __fileList.Construct(); +} + +MetalDetectorDetectForm::~MetalDetectorDetectForm(void) +{ +} + +bool +MetalDetectorDetectForm::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL|FORM_STYLE_HEADER|FORM_STYLE_FOOTER|FORM_STYLE_INDICATOR); + SetName(L"DetectForm"); + SetBackgroundColor(Color::GetColor(COLOR_ID_BLACK)); + + Header* pHeader = this->GetHeader(); + pHeader->SetTitleText(String(L"METAL DETECTOR")); + + Footer* pFooter = this->GetFooter(); + pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT); + pFooter->SetBackButton(); + this->SetFormBackEventListener(this); + + return true; +} + +result +MetalDetectorDetectForm::OnInitializing(void) +{ + result r = PowerManager::KeepScreenOnState(true, false); + TryReturn(!IsFailed(r), r, "[%s] Screen on state keeping failed.", GetErrorMessage(r)); + + r = GetFileList(App::GetInstance()->GetAppRootPath() + String(L"res/")); + TryReturn(!IsFailed(r), r, "[%s] FileList getting failed.", GetErrorMessage(r)); + + Label* pLabel = new (std::nothrow) Label(); + TryReturn(pLabel, E_OUT_OF_MEMORY, "[%s] Label creation failed.", GetErrorMessage(r)); + + Image* pImage = new (std::nothrow) Image(); + if (!pImage) + { + delete pLabel; + AppLogException("[%s] Image creation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + return E_OUT_OF_MEMORY; + } + + __pDetectingMessageLabel = pLabel; + __pImage = pImage; + + Rectangle clientAreaBound = GetClientAreaBounds(); + Rectangle labelRect; + labelRect.x = static_cast(clientAreaBound.width * 0.25); // 1/3 + labelRect.y = static_cast(clientAreaBound.height * 0.45); // 9/20 + labelRect.width = static_cast(clientAreaBound.width * 0.5); // 1/3 + labelRect.height = static_cast(clientAreaBound.height * 0.14); // 1/7 + + __pDetectingMessageLabel->Construct(labelRect, L""); + __pDetectingMessageLabel->SetTextHorizontalAlignment(ALIGNMENT_CENTER); + __pDetectingMessageLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + __pDetectingMessageLabel->SetTextColor(Color::GetColor(COLOR_ID_WHITE)); + this->AddControl(*__pDetectingMessageLabel); + + __pImage->Construct(); + + __timerInterval = TIMEINTERVAL_LEVEL1; + __magneticFieldMagnitude = 150.0; + + RegisterSensor(); + + return r; +} + +result +MetalDetectorDetectForm::OnTerminating(void) +{ + PowerManager::KeepScreenOnState(false); + + __timerInterval = 0; + + StopTimer(); + UnRegisterSensor(); + + delete __pImage; + __pImage = null; + + __fileList.RemoveAll(true); + + return E_SUCCESS; +} + +void +MetalDetectorDetectForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + AppAssert(pSceneManager->GoBackward(BackwardSceneTransition("MainScene")) == E_SUCCESS); +} + +void +MetalDetectorDetectForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, + const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs) +{ + AppLog("MetalDetectorDetectForm activated"); + InitTimer(); + StartSensor(); +} + +void +MetalDetectorDetectForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, + const Tizen::Ui::Scenes::SceneId& nextSceneId) +{ + AppLog("MetalDetectorDetectForm deactivated"); + UnRegisterSensor(); + StopTimer(); +} + +result +MetalDetectorDetectForm::OnDraw(void) +{ + static Rectangle clientAreaBound = GetClientAreaBounds(); + static Rectangle frameRect = clientAreaBound; + static int frameMargin = static_cast(clientAreaBound.width * 0.05); // width/21 + + if (__isFirstDrawing) + { + __isFirstDrawing = false; + frameRect = clientAreaBound; + frameRect.x += frameMargin; + frameRect.y += frameMargin; + frameRect.width -= frameMargin * 2; + frameRect.height -= frameMargin * 2; + } + + static int drawingMargin = static_cast(frameRect.width * 0.02); // width/50 + static int drawingBitmapWidth = static_cast(frameRect.width * 0.5); + static int drawingArchWidth = static_cast(frameRect.width * 0.4); + static int drawingBitmapX = frameRect.x + static_cast(frameRect.width * 0.25); // width/4 + static int drawingBitmapY = frameRect.y + drawingMargin; // width*3/50 + static int drawingArchX = frameRect.x + static_cast(frameRect.width * 0.3); + static int drawingArchY = frameRect.y + static_cast(frameRect.height * 0.67); + + if (IsSensorStart()) + { + static int fileCount = __fileList.GetCount(); + + __fileIndex = (__fileIndex-1+fileCount)%fileCount; + + __pCanvas = GetCanvasN(); + if (__pCanvas != null) + { + __pCanvas->SetBackgroundColor(Color::GetColor(COLOR_ID_BLACK)); + __pCanvas->SetForegroundColor(Color::GetColor(COLOR_ID_WHITE)); + __pCanvas->Clear(); + + Font font; + font.Construct(FONT_STYLE_PLAIN, 30); + __pCanvas->SetFont(font); + + String* nextImageName = static_cast(__fileList.GetAt(__fileIndex)); + String msg; + + if (__timerInterval == TIMEINTERVAL_LEVEL0) + { + msg = L"++No Metal....++"; + } + else + { + if (__timerInterval == TIMEINTERVAL_LEVEL6) + { + msg = L"++Metal Detected++"; + } + else + { + msg = L"++Scanning....++"; + } + + Bitmap* pBmp = __pImage->DecodeN(*nextImageName, BITMAP_PIXEL_FORMAT_ARGB8888); + TryReturn(pBmp != null, E_IO, "Get bitmap failed."); + + __pCanvas->DrawRectangle(frameRect); + __pCanvas->DrawBitmap(Rectangle(drawingBitmapX, drawingBitmapY, drawingBitmapWidth, drawingBitmapWidth), *pBmp); + double result = __magneticFieldMagnitude*1.5; + + if (__magneticFieldMagnitude >= MAX_B_VALUE) + { + result = 359.999; + } + + __pCanvas->DrawArc(Rectangle(drawingArchX, drawingArchY, drawingArchWidth, drawingArchWidth), 0, result, ARC_STYLE_FILLED_PIE ); + delete pBmp; + } + __pDetectingMessageLabel->SetText(msg); + delete __pCanvas; + } + } + + StartTimer(__timerInterval); + return E_SUCCESS; +} + +void +MetalDetectorDetectForm::OnDataReceived(SensorType sensorType, SensorData& sensorData, result r) +{ + float x = 0.0F; + float y = 0.0F; + float z = 0.0F; + + sensorData.GetValue(static_cast(MAGNETIC_DATA_KEY_X), x); + sensorData.GetValue(static_cast(MAGNETIC_DATA_KEY_Y), y); + sensorData.GetValue(static_cast(MAGNETIC_DATA_KEY_Z), z); + + __magneticFieldMagnitude = Math::Sqrt((Math::Pow(x,2)+ Math::Pow(y,2)+ Math::Pow(z,2))); + + AppLog("Magnetic field magnitude (%5.3f)", __magneticFieldMagnitude); + if (__magneticFieldMagnitude <= 0) + { + __timerInterval = TIMEINTERVAL_LEVEL0; + } + else if (__magneticFieldMagnitude > 0 && __magneticFieldMagnitude <= 170) + { + __timerInterval = TIMEINTERVAL_LEVEL1; + } + else if (__magneticFieldMagnitude <= 190) + { + __timerInterval = TIMEINTERVAL_LEVEL2; + } + else if (__magneticFieldMagnitude <= 200) + { + __timerInterval = TIMEINTERVAL_LEVEL3; + } + else if (__magneticFieldMagnitude <= 220) + { + __timerInterval = TIMEINTERVAL_LEVEL4; + } + else if (__magneticFieldMagnitude < 240) + { + __timerInterval = TIMEINTERVAL_LEVEL5; + } + else + { + __timerInterval = TIMEINTERVAL_LEVEL6; + } +} + + +bool +MetalDetectorDetectForm::InitTimer(void) +{ + __pTimer = new (std::nothrow) Timer; + TryReturn(__pTimer, false, "[%s] Timer creation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + __pTimer->Construct(*this); + + return true; +} + +void +MetalDetectorDetectForm::StartTimer(int interval) +{ + __pTimer->Start(interval); +} + +void +MetalDetectorDetectForm::StopTimer(void) +{ + if (__pTimer != null) + { + __pTimer->Cancel(); + delete __pTimer; + __pTimer = null; + } +} + +void +MetalDetectorDetectForm::OnTimerExpired(Timer& timer) +{ + if (__timerInterval != 0) + { + this->RequestRedraw(); + } +} + +void +MetalDetectorDetectForm::RegisterSensor() +{ + __sensorMgr.Construct(); +} + +void +MetalDetectorDetectForm::UnRegisterSensor(void) +{ + StopSensor(); +} + +void +MetalDetectorDetectForm::StartSensor(void) +{ + if (!__sensorMgr.IsAvailable(SENSOR_TYPE_MAGNETIC)) + { + AppLogException("MAGNETIC Sensor does not supported. This sample cannot be activated."); + + Application::GetInstance()->Terminate(); + } + + long interval = 0; + AppLog("Activating Metal Detector..."); + __sensorMgr.GetMinInterval(SENSOR_TYPE_MAGNETIC, interval); + + if (interval < 50) + { + interval = 50; + } + + __sensorMgr.AddSensorListener(*this, SENSOR_TYPE_MAGNETIC, interval, false); + + __isSensorStart = true; +} + +void +MetalDetectorDetectForm::StopSensor(void) +{ + AppLog("Deactivating Metal Detector..."); + __sensorMgr.RemoveSensorListener(*this); +} + +bool +MetalDetectorDetectForm::IsSensorStart(void) +{ + return __isSensorStart; +} + +result +MetalDetectorDetectForm::AddElementInFileList(ArrayList& fileList, String& dirPath, DirEntry& dirEntry) +{ + if (!dirEntry.IsDirectory()) + { + String ext(IMAGE_EXT); + String subStr; + String tempStr(dirPath); + String fileName(dirEntry.GetName()); + + fileName.SubString(fileName.GetLength()-3, 3, subStr); + if (subStr.Equals(ext, false)) + { + tempStr.Append(fileName); + + String* pNewString = new (std::nothrow) String(tempStr); + TryReturn(pNewString != null, E_OUT_OF_MEMORY, "[%s] NewString creation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + fileList.Add(*pNewString); + } + } + + return E_SUCCESS; +} + +result +MetalDetectorDetectForm::GetFileList(String dirPath) +{ + Directory* pDir = new (std::nothrow) Directory(); + TryReturn(pDir, E_OUT_OF_MEMORY, "[%s] Directory creation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + result r = pDir->Construct(dirPath); + if (IsFailed(r)) + { + delete pDir; + AppLogException("[%s] Directory construction failed.", GetErrorMessage(r)); + return r; + } + + DirEnumerator* pDirEnum = pDir->ReadN(); + if (!pDirEnum) + { + delete pDir; + AppLogException("[%s] Directory reading failed.", GetErrorMessage(r)); + } + + while (pDirEnum->MoveNext() == E_SUCCESS) + { + DirEntry dirEntry = pDirEnum->GetCurrentDirEntry(); + AddElementInFileList(__fileList, dirPath, dirEntry); + } + + delete pDirEnum; + pDirEnum = null; + delete pDir; + pDir = null; + + TryReturn(__fileList.GetCount() == IMAGE_COUNT, E_IO, "[%s] Unexpected IO exception occurred.", GetErrorMessage(E_IO)); + + String fileNames[IMAGE_COUNT]; + String* pFileName; + String fileIndex; + int index = 0; + for (int i = 0; i < IMAGE_COUNT; i++) + { + pFileName = static_cast(__fileList.GetAt(i)); + pFileName->SubString(pFileName->GetLength() - 5, 1, fileIndex); + Integer::Parse(fileIndex, index); + fileNames[index - 1] = *pFileName; + } + + __fileList.RemoveAll(true); + + for (int i = 0; i < IMAGE_COUNT; i++) + { + __fileList.Add(*(new (std::nothrow) String(fileNames[i]))); + } + + if (__fileList.GetCount() != IMAGE_COUNT) + { + __fileList.RemoveAll(true); + TryReturn(pDir, E_OUT_OF_MEMORY, "[%s] FileList getting failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + return E_OUT_OF_MEMORY; + } + + return E_SUCCESS; +} diff --git a/project/src/MetalDetectorEntry.cpp b/project/src/MetalDetectorEntry.cpp new file mode 100644 index 0000000..2aaa0af --- /dev/null +++ b/project/src/MetalDetectorEntry.cpp @@ -0,0 +1,60 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * This file contains the Tizen application entry point. + */ +#include +#include "MetalDetector.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +_EXPORT_ int OspMain(int argc, char *pArgv[]); + +/** + * The entry function of Tizen application called by the operating system. + */ +int +OspMain(int argc, char *pArgv[]) +{ + result r = E_SUCCESS; + + AppLog("Application started."); + ArrayList args; + args.Construct(); + for (int i = 0; i < argc; i++) + { + args.Add(*(new (std::nothrow) String(pArgv[i]))); + } + + r = Tizen::App::Application::Execute(MetalDetectorApp::CreateInstance, &args); + TryLog(r == E_SUCCESS, "[%s] Application execution failed", GetErrorMessage(r)); + + args.RemoveAll(true); + AppLog("Application finished."); + + return static_cast(r); +} +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/project/src/MetalDetectorFormFactory.cpp b/project/src/MetalDetectorFormFactory.cpp new file mode 100644 index 0000000..7d806bd --- /dev/null +++ b/project/src/MetalDetectorFormFactory.cpp @@ -0,0 +1,61 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "MetalDetectorFormFactory.h" +#include "MetalDetectorMainForm.h" +#include "MetalDetectorDetectForm.h" + +using namespace Tizen::Ui::Scenes; + +MetalDetectorFormFactory::MetalDetectorFormFactory(void) +{ +} + +MetalDetectorFormFactory::~MetalDetectorFormFactory(void) +{ +} + +Tizen::Ui::Controls::Form* +MetalDetectorFormFactory::CreateFormN(const Tizen::Base::String& formId, const Tizen::Ui::Scenes::SceneId& sceneId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + Tizen::Ui::Controls::Form* pNewForm = null; + + if (formId == L"MainForm") + { + MetalDetectorMainForm* pForm = new (std::nothrow) MetalDetectorMainForm(); + TryReturn(pForm, null, "[%s] MetalDetectorMainForm creation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == L"DetectForm") + { + MetalDetectorDetectForm* pForm = new (std::nothrow) MetalDetectorDetectForm(); + TryReturn(pForm, null, "[%s] MetalDetectorDetectForm creation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else + { + AppAssert(false); + } + + return pNewForm; +} diff --git a/project/src/MetalDetectorFrame.cpp b/project/src/MetalDetectorFrame.cpp new file mode 100644 index 0000000..a16e643 --- /dev/null +++ b/project/src/MetalDetectorFrame.cpp @@ -0,0 +1,44 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "MetalDetectorFrame.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +MetalDetectorFrame::MetalDetectorFrame(void) +{ +} + +MetalDetectorFrame::~MetalDetectorFrame(void) +{ +} + +result +MetalDetectorFrame::OnInitializing(void) +{ + return E_SUCCESS; +} + +result +MetalDetectorFrame::OnTerminating(void) +{ + return E_SUCCESS; +} + + diff --git a/project/src/MetalDetectorMainForm.cpp b/project/src/MetalDetectorMainForm.cpp new file mode 100644 index 0000000..f1cf92c --- /dev/null +++ b/project/src/MetalDetectorMainForm.cpp @@ -0,0 +1,123 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include +#include +#include +#include "MetalDetectorMainForm.h" + +using namespace Tizen::Base; +using namespace Tizen::App; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; +using namespace Tizen::Graphics; + +MetalDetectorMainForm::MetalDetectorMainForm(void) +{ +} + +MetalDetectorMainForm::~MetalDetectorMainForm(void) +{ +} + +bool +MetalDetectorMainForm::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL|FORM_STYLE_HEADER|FORM_STYLE_FOOTER|FORM_STYLE_INDICATOR); + SetName(L"MainForm"); + + Header* pHeader = this->GetHeader(); + pHeader->SetTitleText(String(L"METAL DETECTOR")); + + Footer* pFooter = this->GetFooter(); + pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT); + pFooter->SetBackButton(); + this->SetFormBackEventListener(this); + + SetBackgroundColor(Color::GetColor(COLOR_ID_BLACK)); + + + return true; +} + +result +MetalDetectorMainForm::OnInitializing(void) +{ + Button* pStartButton = new (std::nothrow) Button(); + TryReturn(pStartButton != null, E_OUT_OF_MEMORY, "[%s] StartButton creation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + Rectangle clientAreaBound = GetClientAreaBounds(); + int buttonX = static_cast(clientAreaBound.width * 0.33); + int buttonY = static_cast(clientAreaBound.height * 0.75); + int buttonWidth = static_cast(clientAreaBound.width * 0.34); + int buttonHeight = static_cast(clientAreaBound.height * 0.14); + + pStartButton->Construct(Rectangle(buttonX, buttonY, buttonWidth, buttonHeight)); + pStartButton->SetText(String(L"Start")); + pStartButton->SetActionId(ID_BUTTON_START); + pStartButton->AddActionEventListener(*this); + AddControl(*pStartButton); + + return E_SUCCESS; +} + +result +MetalDetectorMainForm::OnTerminating(void) +{ + return E_SUCCESS; +} + +void +MetalDetectorMainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + + switch(actionId) + { + case ID_BUTTON_START: + AppAssert(pSceneManager->GoForward(ForwardSceneTransition(L"DetectScene")) == E_SUCCESS); + break; + + default: + break; + } +} + +void +MetalDetectorMainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, + const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs) +{ + AppLog("MetalDetectorMainForm activated"); +} + +void +MetalDetectorMainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, + const Tizen::Ui::Scenes::SceneId& nextSceneId) +{ + AppLog("MetalDetectorMainForm deactivated"); +} + + +void +MetalDetectorMainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source) +{ + UiApp* pApp = UiApp::GetInstance(); + AppAssert(pApp); + pApp->Terminate(); +} diff --git a/project/src/MetalDetectorPanelFactory.cpp b/project/src/MetalDetectorPanelFactory.cpp new file mode 100644 index 0000000..75ab905 --- /dev/null +++ b/project/src/MetalDetectorPanelFactory.cpp @@ -0,0 +1,39 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "MetalDetectorPanelFactory.h" +#include + +using namespace Tizen::Ui::Scenes; + +MetalDetectorPanelFactory::MetalDetectorPanelFactory(void) +{ +} + +MetalDetectorPanelFactory::~MetalDetectorPanelFactory(void) +{ +} + +Tizen::Ui::Controls::Panel* +MetalDetectorPanelFactory::CreatePanelN(const Tizen::Base::String& panelId, const Tizen::Ui::Scenes::SceneId& sceneId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + Tizen::Ui::Controls::Panel* pNewPanel = null; + + return pNewPanel; +} diff --git a/sample.xml b/sample.xml new file mode 100644 index 0000000..b4697d3 --- /dev/null +++ b/sample.xml @@ -0,0 +1,37 @@ + + diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..83362ef Binary files /dev/null and b/screenshot.png differ