From 0738828b3c7fc7eda238a5ef08b69b3eeb25e666 Mon Sep 17 00:00:00 2001 From: Jinkun Jang Date: Mon, 18 Mar 2013 15:33:07 +0900 Subject: [PATCH] sync with master --- AUTHORS | 1 + LICENSE.Flora | 206 ++++++ NOTICE | 3 + description.xml | 11 + project/data/nofile.dummy | 0 project/inc/AddressbookListPopup.h | 64 ++ project/inc/CategoryAddMemberForm.h | 79 +++ project/inc/CategoryListForm.h | 79 +++ project/inc/CategoryMemberForm.h | 77 +++ project/inc/CategoryRemoveMemberForm.h | 79 +++ project/inc/Contacts.h | 76 +++ project/inc/ContactsFormFactory.h | 43 ++ project/inc/ContactsFrame.h | 37 ++ project/inc/CreateContactForm.h | 91 +++ project/inc/DetailViewForm.h | 73 +++ project/inc/EditContactForm.h | 92 +++ project/inc/FavoriteListForm.h | 65 ++ project/inc/MainForm.h | 75 +++ project/inc/SceneRegister.h | 42 ++ project/manifest.xml | 32 + .../res/screen-size-normal/IDF_FORM_CONTACTS.xml | 22 + project/shared/data/nofile.dummy | 0 .../shared/res/screen-density-xhigh/mainmenu.png | Bin 0 -> 17581 bytes project/shared/trusted/nofile.dummy | 0 project/src/AddressbookListPopup.cpp | 210 ++++++ project/src/CategoryAddMemberForm.cpp | 378 +++++++++++ project/src/CategoryListForm.cpp | 374 +++++++++++ project/src/CategoryMemberForm.cpp | 363 +++++++++++ project/src/CategoryRemoveMemberForm.cpp | 315 +++++++++ project/src/Contacts.cpp | 153 +++++ project/src/ContactsEntry.cpp | 64 ++ project/src/ContactsFormFactory.cpp | 129 ++++ project/src/ContactsFrame.cpp | 52 ++ project/src/CreateContactForm.cpp | 427 ++++++++++++ project/src/DetailViewForm.cpp | 468 ++++++++++++++ project/src/EditContactForm.cpp | 719 +++++++++++++++++++++ project/src/FavoriteListForm.cpp | 234 +++++++ project/src/MainForm.cpp | 286 ++++++++ project/src/SceneRegister.cpp | 64 ++ sample.xml | 34 + screenshot.png | Bin 0 -> 5567 bytes 41 files changed, 5517 insertions(+) create mode 100644 AUTHORS create mode 100644 LICENSE.Flora create mode 100644 NOTICE create mode 100644 description.xml create mode 100644 project/data/nofile.dummy create mode 100644 project/inc/AddressbookListPopup.h create mode 100644 project/inc/CategoryAddMemberForm.h create mode 100644 project/inc/CategoryListForm.h create mode 100644 project/inc/CategoryMemberForm.h create mode 100644 project/inc/CategoryRemoveMemberForm.h create mode 100644 project/inc/Contacts.h create mode 100644 project/inc/ContactsFormFactory.h create mode 100644 project/inc/ContactsFrame.h create mode 100644 project/inc/CreateContactForm.h create mode 100644 project/inc/DetailViewForm.h create mode 100644 project/inc/EditContactForm.h create mode 100644 project/inc/FavoriteListForm.h create mode 100644 project/inc/MainForm.h create mode 100644 project/inc/SceneRegister.h create mode 100644 project/manifest.xml create mode 100644 project/res/screen-size-normal/IDF_FORM_CONTACTS.xml create mode 100644 project/shared/data/nofile.dummy create mode 100644 project/shared/res/screen-density-xhigh/mainmenu.png create mode 100644 project/shared/trusted/nofile.dummy create mode 100644 project/src/AddressbookListPopup.cpp create mode 100755 project/src/CategoryAddMemberForm.cpp create mode 100644 project/src/CategoryListForm.cpp create mode 100755 project/src/CategoryMemberForm.cpp create mode 100644 project/src/CategoryRemoveMemberForm.cpp create mode 100644 project/src/Contacts.cpp create mode 100644 project/src/ContactsEntry.cpp create mode 100644 project/src/ContactsFormFactory.cpp create mode 100644 project/src/ContactsFrame.cpp create mode 100644 project/src/CreateContactForm.cpp create mode 100644 project/src/DetailViewForm.cpp create mode 100644 project/src/EditContactForm.cpp create mode 100644 project/src/FavoriteListForm.cpp create mode 100644 project/src/MainForm.cpp create mode 100644 project/src/SceneRegister.cpp create mode 100644 sample.xml create mode 100755 screenshot.png diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..35760d6 --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Gwangbok Kim diff --git a/LICENSE.Flora b/LICENSE.Flora new file mode 100644 index 0000000..9c95663 --- /dev/null +++ b/LICENSE.Flora @@ -0,0 +1,206 @@ +Flora License + +Version 1.0, May, 2012 + +http://floralicense.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://floralicense.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..419db21 --- /dev/null +++ b/NOTICE @@ -0,0 +1,3 @@ +Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under Flora License, Version 1. +Please, see the LICENSE.Flora file for Flora License, Version 1 terms and conditions. diff --git a/description.xml b/description.xml new file mode 100644 index 0000000..379a622 --- /dev/null +++ b/description.xml @@ -0,0 +1,11 @@ + + + + + Contacts + 1.0 + screenshot.png + +The Contact sample application demonstrates how you can implement contacts. + + diff --git a/project/data/nofile.dummy b/project/data/nofile.dummy new file mode 100644 index 0000000..e69de29 diff --git a/project/inc/AddressbookListPopup.h b/project/inc/AddressbookListPopup.h new file mode 100644 index 0000000..a187f9b --- /dev/null +++ b/project/inc/AddressbookListPopup.h @@ -0,0 +1,64 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 _ADDRESSBOOK_LIST_POPUP_H_ +#define _ADDRESSBOOK_LIST_POPUP_H_ + +#include +#include + +class AddressbookListPopup + : public Tizen::Ui::Controls::Popup + , public Tizen::Ui::IActionEventListener + , public Tizen::Ui::Controls::IListViewItemEventListener + , public Tizen::Ui::Controls::IListViewItemProvider +{ +public: + AddressbookListPopup(void); + virtual ~AddressbookListPopup(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + + virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, + Tizen::Ui::Controls::ListItemStatus status); + virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, + Tizen::Ui::Controls::SweepDirection direction); + virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, + int elementId, Tizen::Ui::Controls::ListContextItemStatus state); + virtual void OnItemReordered(Tizen::Ui::Controls::ListView& view, int oldIndex, int newIndex); + + virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth); + virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth); + virtual int GetItemCount(void); + + result Construct(const Tizen::Ui::Controls::Form* pForm); + result GetAddressbookList(void); + +public: + static const int ID_BUTTON_CANCEL_POPUP = 302; + +private: + Tizen::Base::Collection::IList* __pAddressbookList; + Tizen::Ui::Controls::ListView* __pListView; + Tizen::Ui::Controls::Form* __pForm; +}; + +#endif //_ADDRESSBOOK_LIST_POPUP_H_ diff --git a/project/inc/CategoryAddMemberForm.h b/project/inc/CategoryAddMemberForm.h new file mode 100644 index 0000000..3f92549 --- /dev/null +++ b/project/inc/CategoryAddMemberForm.h @@ -0,0 +1,79 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 _CATEGORY_ADD_MEMBER_FORM_H_ +#define _CATEGORY_ADD_MEMBER_FORM_H_ + +#include +#include +#include + +class CategoryAddMemberForm + : public Tizen::Ui::IActionEventListener + , public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IFormBackEventListener + , public Tizen::Ui::Controls::IListViewItemEventListener + , public Tizen::Ui::Controls::IListViewItemProvider + , public Tizen::Ui::Scenes::ISceneEventListener +{ +public: + CategoryAddMemberForm(void); + virtual ~CategoryAddMemberForm(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 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 void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, + Tizen::Ui::Controls::ListItemStatus status); + virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, + Tizen::Ui::Controls::SweepDirection direction); + virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, + int elementId, Tizen::Ui::Controls::ListContextItemStatus state); + virtual void OnItemReordered(Tizen::Ui::Controls::ListView& view, int oldIndex, int newIndex); + + virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth); + virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth); + virtual int GetItemCount(void); + +protected: + static const int ID_FOOTER_ADD = 200; + +private: + result AddMember(void); + result GetCandidateContactList(void); + + +private: + Tizen::Base::Collection::IList* __pCandidateContactList; + Tizen::Ui::Controls::ListView* __pListView; + + Tizen::Social::Category* __pCategory; + Tizen::Social::Contact* __pContact; + Tizen::Social::AddressbookManager* __pAddressbookMgr; + + int __checkedIndex; +}; + +#endif //_CATEGORY_ADD_MEMBER_FORM_H_ diff --git a/project/inc/CategoryListForm.h b/project/inc/CategoryListForm.h new file mode 100644 index 0000000..60fb05c --- /dev/null +++ b/project/inc/CategoryListForm.h @@ -0,0 +1,79 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 _CATEGORY_LIST_FORM_H_ +#define _CATEGORY_LIST_FORM_H_ + +#include +#include + +class CategoryListForm + : public Tizen::Ui::IActionEventListener + , public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IFormBackEventListener + , public Tizen::Ui::Controls::IListViewItemEventListener + , public Tizen::Ui::Controls::IListViewItemProvider + , public Tizen::Ui::Scenes::ISceneEventListener +{ +public: + CategoryListForm(void); + virtual ~CategoryListForm(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 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 Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth); + virtual int GetItemCount(void); + virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth); + + virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, + Tizen::Ui::Controls::ListItemStatus status); + virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, + Tizen::Ui::Controls::SweepDirection direction); + virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, + int elementId, Tizen::Ui::Controls::ListContextItemStatus state); + virtual void OnItemReordered(Tizen::Ui::Controls::ListView& view, int oldIndex, int newIndex); + +protected: + static const int ID_FOOTER_CREATE = 204; + static const int ID_BUTTON_CANCEL_POPUP = 302; + static const int ID_BUTTON_SAVE_POPUP = 304; + +private: + result AddCategory(void); + result GetCategoryList(void); + void CreateCategoryPopup(void); + +private: + Tizen::Base::Collection::IList* __pCategoryList; + Tizen::Ui::Controls::EditField* __pNameEditField; + Tizen::Ui::Controls::ListView* __pListView; + Tizen::Ui::Controls::Popup* __pCreatePopup; + + Tizen::Social::AddressbookManager* __pAddressbookMgr; +}; + +#endif //_CATEGORY_LIST_FORM_H_ diff --git a/project/inc/CategoryMemberForm.h b/project/inc/CategoryMemberForm.h new file mode 100644 index 0000000..07340af --- /dev/null +++ b/project/inc/CategoryMemberForm.h @@ -0,0 +1,77 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 _CATEGORY_MEMBER_FORM_H_ +#define _CATEGORY_MEMBER_FORM_H_ + +#include +#include +#include + +class CategoryMemberForm + : public Tizen::Ui::IActionEventListener + , public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IFormBackEventListener + , public Tizen::Ui::Controls::IListViewItemEventListener + , public Tizen::Ui::Controls::IListViewItemProvider + , public Tizen::Ui::Scenes::ISceneEventListener +{ +public: + CategoryMemberForm(void); + virtual ~CategoryMemberForm(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 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 void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, + Tizen::Ui::Controls::ListItemStatus status); + virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, + Tizen::Ui::Controls::SweepDirection direction); + virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, + int elementId, Tizen::Ui::Controls::ListContextItemStatus state); + virtual void OnItemReordered(Tizen::Ui::Controls::ListView& view, int oldIndex, int newIndex); + + virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth); + virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth); + virtual int GetItemCount(void); + +protected: + static const int ID_HEADER_REMOVE_BUTTON = 100; + static const int ID_FOOTER_ADD = 200; + static const int ID_FOOTER_DELETE = 205; + +private: + result GetMemberList(void); + result RemoveCategory(void); + +private: + Tizen::Base::Collection::IList* __pContactList; + Tizen::Ui::Controls::ListView* __pListView; + + Tizen::Social::Category* __pCategory; + Tizen::Social::AddressbookManager* __pAddressbookMgr; +}; + +#endif //_CATEGORY_MEMBER_FORM_H_ diff --git a/project/inc/CategoryRemoveMemberForm.h b/project/inc/CategoryRemoveMemberForm.h new file mode 100644 index 0000000..afa2eee --- /dev/null +++ b/project/inc/CategoryRemoveMemberForm.h @@ -0,0 +1,79 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 _CATEGORY_REMOVE_MEMBER_FORM_H_ +#define _CATEGORY_REMOVE_MEMBER_FORM_H_ + +#include +#include +#include + +class CategoryRemoveMemberForm + : public Tizen::Ui::IActionEventListener + , public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IFormBackEventListener + , public Tizen::Ui::Controls::IListViewItemEventListener + , public Tizen::Ui::Controls::IListViewItemProvider + , public Tizen::Ui::Scenes::ISceneEventListener +{ +public: + CategoryRemoveMemberForm(void); + virtual ~CategoryRemoveMemberForm(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 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 void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, + Tizen::Ui::Controls::ListItemStatus status); + virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, + Tizen::Ui::Controls::SweepDirection direction); + virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, + int elementId, Tizen::Ui::Controls::ListContextItemStatus state); + virtual void OnItemReordered(Tizen::Ui::Controls::ListView& view, int oldIndex, int newIndex); + + virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth); + virtual bool DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth); + virtual int GetItemCount(void); + +protected: + static const int ID_FOOTER_DELETE = 205; + +private: + result GetMemberList(void); + result RemoveMember(void); + +private: + Tizen::Base::Collection::IList* __pContactList; + Tizen::Ui::Controls::ListView* __pListView; + + Tizen::Social::Category* __pCategory; + Tizen::Social::Contact* __pContact; + Tizen::Social::AddressbookManager* __pAddressbookMgr; + + int __checkedIndex; +}; + +#endif //_CATEGORY_REMOVE_MEMBER_FORM_H_ diff --git a/project/inc/Contacts.h b/project/inc/Contacts.h new file mode 100644 index 0000000..7e3d7bd --- /dev/null +++ b/project/inc/Contacts.h @@ -0,0 +1,76 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 _CONTACTS_H_ +#define _CONTACTS_H_ + +#include +#include +#include +#include + +/** + * [ContactsApp] UiApp must inherit from UiApp class + * which provides basic features necessary to define an UiApp. + */ +class ContactsApp + : 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: + ContactsApp(void); + virtual~ContactsApp(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 // _CONTACTS_H_ diff --git a/project/inc/ContactsFormFactory.h b/project/inc/ContactsFormFactory.h new file mode 100644 index 0000000..55afdac --- /dev/null +++ b/project/inc/ContactsFormFactory.h @@ -0,0 +1,43 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 _CONTACTS_FORM_FACTORY_H_ +#define _CONTACTS_FORM_FACTORY_H_ + +#include + +extern const wchar_t* FORM_MAIN; +extern const wchar_t* FORM_CATEGORY_LIST; +extern const wchar_t* FORM_CREATE_CONTACT; +extern const wchar_t* FORM_DETAIL_VIEW; +extern const wchar_t* FORM_CATEGORY_MEMBER; +extern const wchar_t* FORM_EDIT_CONTACT; +extern const wchar_t* FORM_CATEGORY_REMOVE_MEMBER; +extern const wchar_t* FORM_CATEGORY_ADD_MEMBER; +extern const wchar_t* FORM_FAVORITE_LIST; + +class ContactsFormFactory + : public Tizen::Ui::Scenes::IFormFactory +{ +public: + ContactsFormFactory(void); + virtual ~ContactsFormFactory(void); + + virtual Tizen::Ui::Controls::Form* CreateFormN(const Tizen::Base::String& formId, const Tizen::Ui::Scenes::SceneId& sceneId); +}; + +#endif // _CONTACTS_FORM_FACTORY_H_ diff --git a/project/inc/ContactsFrame.h b/project/inc/ContactsFrame.h new file mode 100644 index 0000000..df365bc --- /dev/null +++ b/project/inc/ContactsFrame.h @@ -0,0 +1,37 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 _CONTACTSFRAME_H_ +#define _CONTACTSFRAME_H_ + +#include +#include + + +class ContactsFrame + : public Tizen::Ui::Controls::Frame +{ +public: + ContactsFrame(void); + virtual ~ContactsFrame(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); +}; + +#endif //_CONTACTSFRAME_H_ diff --git a/project/inc/CreateContactForm.h b/project/inc/CreateContactForm.h new file mode 100644 index 0000000..26cb042 --- /dev/null +++ b/project/inc/CreateContactForm.h @@ -0,0 +1,91 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 _CREATE_CONTACT_FORM_H_ +#define _CREATE_CONTACT_FORM_H_ + +#include +#include +#include + +#include "AddressbookListPopup.h" + +class CreateContactForm + : public Tizen::Ui::IActionEventListener + , public Tizen::Ui::IDateChangeEventListener + , public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IFormBackEventListener + , public Tizen::Ui::Scenes::ISceneEventListener +{ +public: + CreateContactForm(void); + virtual ~CreateContactForm(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 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 void OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs); + + virtual void OnDateChanged(const Tizen::Ui::Control& source, int year, int month, int day); + virtual void OnDateChangeCanceled(const Tizen::Ui::Control& source); + +protected: + static const int ID_FOOTER_SAVE = 207; + static const int ID_BUTTON_ADDRESSBOOK_LIST = 301; + +private: + result AddContact(void); + result GetAddressbookList(void); + Tizen::Base::String GetAddressbookName(Tizen::Social::AddressbookId addressbookId); + +private: + Tizen::Base::String __firstName; + Tizen::Base::String __lastName; + Tizen::Base::String __phoneNumber; + Tizen::Base::String __email; + Tizen::Base::String __url; + Tizen::Base::String __organization; + Tizen::Base::String __note; + + Tizen::Ui::Controls::EditField* __pFirstNameEditField; + Tizen::Ui::Controls::EditField* __pLastNameEditField; + Tizen::Ui::Controls::EditField* __pPhoneNumberEditField; + Tizen::Ui::Controls::EditField* __pEmailEditField; + Tizen::Ui::Controls::EditField* __pUrlEditField; + Tizen::Ui::Controls::EditField* __pOrganizationEditField; + Tizen::Ui::Controls::EditField* __pNoteEditField; + Tizen::Ui::Controls::EditDate* __pEventEditDate; + Tizen::Ui::Controls::Label* __pAddressbookNameLabel; + + Tizen::Social::AddressbookId __addressbookId; + Tizen::Social::AddressbookManager* __pAddressbookMgr; + + AddressbookListPopup* __pAddressbookListPopup; + + bool __isDateChanged; +}; + +#endif //_CREATE_CONTACT_FORM_H_ diff --git a/project/inc/DetailViewForm.h b/project/inc/DetailViewForm.h new file mode 100644 index 0000000..675a0ec --- /dev/null +++ b/project/inc/DetailViewForm.h @@ -0,0 +1,73 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 _DETAIL_VIEW_FORM_H_ +#define _DETAIL_VIEW_FORM_H_ + +#include +#include +#include + +class DetailViewForm + : public Tizen::Ui::IActionEventListener + , public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IFormBackEventListener + , public Tizen::Ui::Scenes::ISceneEventListener +{ +public: + DetailViewForm(void); + virtual ~DetailViewForm(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 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); + +protected: + static const int ID_HEADER_FAVORITE_BUTTON = 108; + static const int ID_FOOTER_DELETE = 205; + static const int ID_FOOTER_EDIT = 206; + +private: + result RemovePerson(void); + result GetContactsDetail(void); + result ChangeFavoriteStatus(void); + +private: + Tizen::Ui::Controls::Popup* __pPopup; + Tizen::Ui::Controls::Label* __pPhoneNumberLabelData; + Tizen::Ui::Controls::Label* __pEmailLabelData; + Tizen::Ui::Controls::Label* __pUrlLabelData; + Tizen::Ui::Controls::Label* __pOrganizationLabelData; + Tizen::Ui::Controls::Label* __pEventLabelData; + Tizen::Ui::Controls::Label* __pNoteLabelData; + + Tizen::Social::AddressbookManager* __pAddressbookMgr; + Tizen::Social::Person* __pPerson; + + Tizen::Graphics::Color __favoriteTextColor; + Tizen::Graphics::Color __normalTextColor; +}; + +#endif //_DETAIL_VIEW_FORM_H_ diff --git a/project/inc/EditContactForm.h b/project/inc/EditContactForm.h new file mode 100644 index 0000000..a20e0d2 --- /dev/null +++ b/project/inc/EditContactForm.h @@ -0,0 +1,92 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 _EDIT_CONTACT_FORM_H_ +#define _EDIT_CONTACT_FORM_H_ + +#include +#include +#include + +class EditContactForm + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IActionEventListener + , public Tizen::Ui::IDateChangeEventListener + , public Tizen::Ui::Controls::IFormBackEventListener + , public Tizen::Ui::Scenes::ISceneEventListener +{ +public: + EditContactForm(void); + virtual ~EditContactForm(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 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 void OnDateChanged(const Tizen::Ui::Control& source, int year, int month, int day); + virtual void OnDateChangeCanceled(const Tizen::Ui::Control& source); + +protected: + static const int ID_HEADER_TAB_ID_START = 0; + static const int ID_FOOTER_SAVE = 207; + +private: + void CreateHeaderTabs(void); + void UpdateTabContent(int index); + result SaveContact(int index); + Tizen::Base::Collection::IList* GetContactList(Tizen::Social::PersonId personid); + Tizen::Social::Contact* GetContactAt(int index); + Tizen::Base::String GetAddressbookName(Tizen::Social::AddressbookId addressbookId); + +private: + Tizen::Base::String __firstName; + Tizen::Base::String __lastName; + Tizen::Base::String __phoneNumber; + Tizen::Base::String __email; + Tizen::Base::String __url; + Tizen::Base::String __organization; + Tizen::Base::String __note; + Tizen::Base::DateTime __event; + Tizen::Base::Collection::IList* __pContactList; + + Tizen::Ui::Controls::EditField* __pFirstNameEditField; + Tizen::Ui::Controls::EditField* __pLastNameEditField; + Tizen::Ui::Controls::EditField* __pPhoneNumberEditField; + Tizen::Ui::Controls::EditField* __pEmailEditField; + Tizen::Ui::Controls::EditField* __pUrlEditField; + Tizen::Ui::Controls::EditField* __pOrganizationEditField; + Tizen::Ui::Controls::EditField* __pNoteEditField; + Tizen::Ui::Controls::EditDate* __pEventEditDate; + + Tizen::Social::AddressbookManager* __pAddressbookMgr; + Tizen::Social::PersonId __personId; + + int __selectedTabId; + int __headerTabCount; + int __birthdayIndex; + bool __isBirthdayChanged; +}; + +#endif //_EDIT_CONTACT_FORM_H_ diff --git a/project/inc/FavoriteListForm.h b/project/inc/FavoriteListForm.h new file mode 100644 index 0000000..2de8cc4 --- /dev/null +++ b/project/inc/FavoriteListForm.h @@ -0,0 +1,65 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 _FAVORITE_LIST_FORM_H_ +#define _FAVORITE_LIST_FORM_H_ + +#include +#include + +class FavoriteListForm + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IFormBackEventListener + , public Tizen::Ui::Controls::IListViewItemEventListener + , public Tizen::Ui::Controls::IListViewItemProvider + , public Tizen::Ui::Scenes::ISceneEventListener +{ +public: + FavoriteListForm(void); + virtual ~FavoriteListForm(void); + bool Initialize(void); + +public: + 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 void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, + Tizen::Ui::Controls::ListItemStatus status); + virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, + Tizen::Ui::Controls::SweepDirection direction); + virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, + int elementId, Tizen::Ui::Controls::ListContextItemStatus state); + virtual void OnItemReordered(Tizen::Ui::Controls::ListView& view, int oldIndex, int newIndex); + + virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth); + virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth); + virtual int GetItemCount(void); + +private: + result GetFavoriteList(void); + +private: + Tizen::Base::Collection::IList* __pFavoriteList; + Tizen::Ui::Controls::ListView* __pListView; +}; + +#endif //_MAIN_FORM_H_ diff --git a/project/inc/MainForm.h b/project/inc/MainForm.h new file mode 100644 index 0000000..53a70ac --- /dev/null +++ b/project/inc/MainForm.h @@ -0,0 +1,75 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 _MAIN_FORM_H_ +#define _MAIN_FORM_H_ + +#include +#include + +class MainForm + : public Tizen::Ui::IActionEventListener + , public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IFormBackEventListener + , public Tizen::Ui::Controls::IListViewItemEventListener + , public Tizen::Ui::Controls::IListViewItemProvider + , public Tizen::Ui::Scenes::ISceneEventListener +{ +public: + MainForm(void); + virtual ~MainForm(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 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 void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, + Tizen::Ui::Controls::ListItemStatus status); + virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, + Tizen::Ui::Controls::SweepDirection direction); + virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, + int elementId, Tizen::Ui::Controls::ListContextItemStatus state); + virtual void OnItemReordered(Tizen::Ui::Controls::ListView& view, int oldIndex, int newIndex); + + virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth); + virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth); + virtual int GetItemCount(void); + +protected: + static const int ID_FOOTER_CREATE = 204; + static const int ID_FOOTER_MORE = 209; + static const int ID_CONTEXT_MENU_CATEGORY = 300; + static const int ID_CONTEXT_MENU_FAVORITE = 301; + +private: + result GetPersonList(void); + +private: + Tizen::Base::Collection::IList* __pPersonList; + Tizen::Ui::Controls::ListView* __pListView; + Tizen::Ui::Controls::ContextMenu* __pContextMenu; +}; + +#endif //_MAIN_FORM_H_ diff --git a/project/inc/SceneRegister.h b/project/inc/SceneRegister.h new file mode 100644 index 0000000..baa60c1 --- /dev/null +++ b/project/inc/SceneRegister.h @@ -0,0 +1,42 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 _SCENE_REGISTER_H_ +#define _SCENE_REGISTER_H_ + +// Use 'extern' to eliminate duplicate data allocation. +extern const wchar_t* SCENE_MAIN_FORM; +extern const wchar_t* SCENE_CATEGORY_LIST_FORM; +extern const wchar_t* SCENE_CREATE_CONTACT_FORM; +extern const wchar_t* SCENE_DETAIL_VIEW_FORM; +extern const wchar_t* SCENE_CATEGORY_MEMBER_FORM; +extern const wchar_t* SCENE_EDIT_CONTACT_FORM; +extern const wchar_t* SCENE_CATEGORY_REMOVE_MEMBER_FORM; +extern const wchar_t* SCENE_CATEGORY_ADD_MEMBER_FORM; +extern const wchar_t* SCENE_FAVORITE_LIST_FORM; + +class SceneRegister +{ +public: + static void RegisterAllScenes(void); + +private: + SceneRegister(void); + ~SceneRegister(void); +}; + +#endif // _SCENE_REGISTER_H_ diff --git a/project/manifest.xml b/project/manifest.xml new file mode 100644 index 0000000..e5dc4d4 --- /dev/null +++ b/project/manifest.xml @@ -0,0 +1,32 @@ + + + $(manifestAppId) + 2.0.0 + C++App + + + + + + 2.1 + + http://tizen.org/privilege/contact.read + http://tizen.org/privilege/contact.write + + + + $(projectName) + + + + + mainmenu.png + + + + + + + + + diff --git a/project/res/screen-size-normal/IDF_FORM_CONTACTS.xml b/project/res/screen-size-normal/IDF_FORM_CONTACTS.xml new file mode 100644 index 0000000..da61141 --- /dev/null +++ b/project/res/screen-size-normal/IDF_FORM_CONTACTS.xml @@ -0,0 +1,22 @@ + + + + + + 720 +
+ + + + +
+ + +
+
+ + +
+
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 100644 index 0000000000000000000000000000000000000000..983c883493a0ae561b9592d54ea8204042b4b6fb GIT binary patch literal 17581 zcmWh!1yCGI6g=ErgFA=2yL<2e!JP!R;O-JMxI=K4;O-JEK!D(SxV!%SRdZ|=vb!_$ zrr+!CN0iz}IW%MGn)_u zLRS4EC8efjQ%n4@*V{mUuKj5+*J#Fcwdp88sSt31OGAFfODhGJ5=Z z%cscpZ|D8~saqJr4fBf}U#us$G@QEF;WP-q4S zSN2Lr_>!px6T%3rR7Qhv8;yWWkUk=dGlGr|D;ao7fq)5@*A&_`Q=GNmE8_!a5I4r= z^=}X;KM@a@?e(kY6nf3n6mMKJx-rX95Bxionc2?U-gKptI0&@m=0E$!%+^R0CHoEnDM)BrUf$c?T~ZvB)Hfa1@q4rGH}2JW zwR`jze!0Kh?B1pc;xr7BgMHZS|9zueO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;;O*zu%knwmo(+Y8Nkanr{ol=5+0Ena1#UM2gKQrvp$ zt&|XAKK$^**7oh&Ujy*wDW{w=EgTNtpeV{sygkB~rFz*=B9T6dr$Hn}xg~13B$(H9 zUH@5ITiYKw4zkN-9DNjS`baLMkHb+P#nmGY>?4mn!bGByOeUlC_4QY(s(Otq%jfdt zo;$jOq<`*3u9S0pps=ajSQv1*8ruuK=s1vziF#(2g z-_oT^DIvrngjkO}@`y1wIQS%hUp6&0)x_iR%Vb&pv@FYi<%Qt9VEM6ZEic5!d;FbA zu*tHl*9(Qh3%hph+Tw)BEdchdx86!cSpRVi*#A+E`ncQj<;%yCkN_nbjRqPT8ctVL zb&(`V3nWRJNeDUlPj%FCgzcl0?y_xrvuT>^Mn*>7>FVklbO>WP+(ZA|-1EPNqdx9- z^UXK23KtuIxqSI@ZRgINZ=tv>w*)}0tgH;CQmHA5qD+!yc_JYsMF>d(2m** +#include +#include + +#include "AddressbookListPopup.h" +#include "SceneRegister.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Utility; +using namespace Tizen::Graphics; +using namespace Tizen::Social; +using namespace Tizen::System; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +AddressbookListPopup::AddressbookListPopup(void) + : __pAddressbookList(null) + , __pListView(null) + , __pForm(null) +{ +} + +AddressbookListPopup::~AddressbookListPopup(void) +{ +} + +result +AddressbookListPopup::Construct(const Form* pForm) +{ + result r = E_SUCCESS; + + r = Popup::Construct(true, Dimension(600, 510)); + TryReturn(!IsFailed(r), r, "Failed to construct popup (%s)", GetErrorMessage(r)); + + SetTitleText(L"Select an addressbook"); + + if (pForm == null) + { + return E_FAILURE; + } + + __pForm = const_cast (pForm); + + ScrollPanel* pPopupScrollPanel = new (std::nothrow) ScrollPanel(); + pPopupScrollPanel->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height)); + AddControl(*pPopupScrollPanel); + + Button* pButtonCancel = new (std::nothrow) Button(); + pButtonCancel->Construct(Rectangle(120, 340, 300, 70), L"Cancel"); + pButtonCancel->SetActionId(ID_BUTTON_CANCEL_POPUP); + pButtonCancel->AddActionEventListener(*this); + AddControl(*pButtonCancel); + + __pListView = new (std::nothrow) ListView(); + __pListView->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height)); + __pListView->SetItemProvider(*this); + __pListView->AddListViewItemEventListener(*this); + pPopupScrollPanel->AddControl(*__pListView); + + r = GetAddressbookList(); + TryReturn(!IsFailed(r), r, "Failed to get addressbook list (%s)", GetErrorMessage(r)); + + return r; +} + +result +AddressbookListPopup::OnInitializing(void) +{ + result r = E_SUCCESS; + + return r; +} + +result +AddressbookListPopup::OnTerminating(void) +{ + result r = E_SUCCESS; + + if (__pAddressbookList != null) + { + __pAddressbookList->RemoveAll(true); + delete __pAddressbookList; + } + + return r; +} + +void +AddressbookListPopup::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) +{ + switch(actionId) + { + case ID_BUTTON_CANCEL_POPUP: + __pForm->SendUserEvent(0, null); + break; + + default: + break; + } +} + +bool +AddressbookListPopup::DeleteItem(int itemIndex, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth) +{ + delete pItem; + pItem = null; + + return true; +} + +int +AddressbookListPopup::GetItemCount(void) +{ + if (__pAddressbookList != null) + { + return __pAddressbookList->GetCount(); + } + + return 0; +} + +void +AddressbookListPopup::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status) +{ + if (status == LIST_ITEM_STATUS_SELECTED) + { + Addressbook* pAddressbook = static_cast (__pAddressbookList->GetAt(index)); + AppAssert(pAddressbook); + + ArrayList* pArgs = new (std::nothrow) ArrayList(); + pArgs->Construct(); + pArgs->Add(*new Integer(pAddressbook->GetId())); + __pForm->SendUserEvent(0, pArgs); + } +} + +void +AddressbookListPopup::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction) +{ +} + +void +AddressbookListPopup::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state) +{ +} + +void +AddressbookListPopup::OnItemReordered(Tizen::Ui::Controls::ListView& view, int oldIndex, int newIndex) +{ +} + +Tizen::Ui::Controls::ListItemBase* +AddressbookListPopup::CreateItem(int index, int itemWidth) +{ + SimpleItem* pItem = new (std::nothrow) SimpleItem(); + AppAssert(pItem); + + pItem->Construct(Dimension(itemWidth, 112), LIST_ANNEX_STYLE_NORMAL); + + Addressbook* pAddressbook = static_cast (__pAddressbookList->GetAt(index)); + AppAssert(pAddressbook); + + String delim(L"/"); + StringTokenizer tokenizer(pAddressbook->GetName(), delim); + + String addressbookName; + + while (tokenizer.HasMoreTokens()) + { + tokenizer.GetNextToken(addressbookName); + } + + pItem->SetElement(addressbookName); + + return pItem; +} + +result +AddressbookListPopup::GetAddressbookList() +{ + result r = E_SUCCESS; + + AddressbookManager* pAddressbookMgr = AddressbookManager::GetInstance(); + + __pAddressbookList = pAddressbookMgr->GetAllAddressbooksN(); + r = GetLastResult(); + TryReturn(!IsFailed(r), r, "Failed to get addressbook list. (%s)", GetErrorMessage(r)); + + return r; +} diff --git a/project/src/CategoryAddMemberForm.cpp b/project/src/CategoryAddMemberForm.cpp new file mode 100755 index 0000000..5059c8b --- /dev/null +++ b/project/src/CategoryAddMemberForm.cpp @@ -0,0 +1,378 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 "CategoryAddMemberForm.h" +#include "SceneRegister.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Social; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +CategoryAddMemberForm::CategoryAddMemberForm(void) + : __pCandidateContactList(null) + , __pListView(null) + , __pCategory(null) + , __pContact(null) + , __pAddressbookMgr(null) + , __checkedIndex(0) +{ +} + +CategoryAddMemberForm::~CategoryAddMemberForm(void) +{ +} + +bool +CategoryAddMemberForm::Initialize(void) +{ + result r = E_SUCCESS; + + __pAddressbookMgr = AddressbookManager::GetInstance(); + r = GetLastResult(); + TryReturn(!IsFailed(r), false, "Failed to get instance of addressbook manager (%s)", GetErrorMessage(r)); + + r = Construct(L"IDF_FORM_CONTACTS"); + TryReturn(!IsFailed(r), false, "Failed to construct the form (%s).", GetErrorMessage(r)); + + return true; +} + +result +CategoryAddMemberForm::OnInitializing(void) +{ + result r = E_SUCCESS; + + Header* pHeader = GetHeader(); + AppAssert(pHeader); + + pHeader->SetStyle(HEADER_STYLE_TITLE); + pHeader->SetTitleText(L"ADD MEMBER"); + + Footer* pFooter = GetFooter(); + AppAssert(pFooter); + + pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT); + + FooterItem footerAdd; + footerAdd.Construct(ID_FOOTER_ADD); + footerAdd.SetText(L"Add Member"); + pFooter->AddItem(footerAdd); + pFooter->SetBackButton(); + pFooter->AddActionEventListener(*this); + + ScrollPanel* pScrollPanel = new (std::nothrow) ScrollPanel(); + pScrollPanel->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height)); + + static int UI_X_POSITION = 5; + static int UI_Y_POSITION = 0; + + __pListView = new (std::nothrow) ListView(); + __pListView->Construct(Rectangle(UI_X_POSITION, UI_Y_POSITION, GetClientAreaBounds().width, GetClientAreaBounds().height)); + __pListView->SetItemProvider(*this); + __pListView->AddListViewItemEventListener(*this); + pScrollPanel->AddControl(*__pListView); + + AddControl(*pScrollPanel); + SetFormBackEventListener(this); + + return r; +} + +result +CategoryAddMemberForm::OnTerminating(void) +{ + result r = E_SUCCESS; + + if (__pCandidateContactList != null) + { + __pCandidateContactList->RemoveAll(true); + delete __pCandidateContactList; + } + + if (__pCategory != null) + { + delete __pCategory; + } + + return r; +} + +void +CategoryAddMemberForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + + result r = E_SUCCESS; + + switch(actionId) + { + case ID_FOOTER_ADD: + { + r = AddMember(); + TryReturnVoid(!IsFailed(r), "Failed to add member to category (%s).", GetErrorMessage(r)); + + ArrayList* pList = new (std::nothrow) ArrayList(); + AppAssert(pList); + + r = pList->Construct(); + TryReturnVoid(!IsFailed(r), "Failed to construct list (%s)", GetErrorMessage(r)); + + r = pList->Add(*(new (std::nothrow) Category(*__pCategory))); + TryReturnVoid(!IsFailed(r), "Failed to add category (%s).", GetErrorMessage(r)); + + pSceneManager->GoBackward(BackwardSceneTransition(SCENE_CATEGORY_MEMBER_FORM), pList); + break; + } + + default: + break; + } +} + +void +CategoryAddMemberForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + + result r = E_SUCCESS; + + ArrayList* pList = new (std::nothrow) ArrayList(); + AppAssert(pList); + + r = pList->Construct(); + TryReturnVoid(!IsFailed(r), "Failed to construct list (%s)", GetErrorMessage(r)); + + r = pList->Add(*(new (std::nothrow) Category(*__pCategory))); + TryReturnVoid(!IsFailed(r), "Failed to add category (%s).", GetErrorMessage(r)); + + pSceneManager->GoBackward(BackwardSceneTransition(SCENE_CATEGORY_MEMBER_FORM), pList); +} + +bool +CategoryAddMemberForm::DeleteItem(int itemIndex, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth) +{ + delete pItem; + pItem = null; + + return true; +} + +int +CategoryAddMemberForm::GetItemCount(void) +{ + if (__pCandidateContactList != null) + { + return __pCandidateContactList->GetCount(); + } + + return 0; +} + +void +CategoryAddMemberForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status) +{ + if (status == LIST_ITEM_STATUS_CHECKED) + { + if (__checkedIndex != index || __checkedIndex != 0) + { + listView.SetItemChecked(__checkedIndex, false); + listView.Invalidate(true); + } + + __pContact = static_cast (__pCandidateContactList->GetAt(index)); + + __checkedIndex = index; + } + + else if (status == LIST_ITEM_STATUS_UNCHECKED) + { + listView.SetItemChecked(index, false); + listView.Invalidate(true); + __pContact = null; + } +} + +void +CategoryAddMemberForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction) +{ +} + +void +CategoryAddMemberForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state) +{ +} + +void +CategoryAddMemberForm::OnItemReordered(Tizen::Ui::Controls::ListView& view, int oldIndex, int newIndex) +{ +} + +Tizen::Ui::Controls::ListItemBase* +CategoryAddMemberForm::CreateItem(int index, int itemWidth) +{ + String memberName, firstName, lastName; + SimpleItem* pItem = null; + Contact* pContact = null; + + pItem = new SimpleItem(); + AppAssert(pItem); + + pItem->Construct(Dimension(itemWidth, 112), LIST_ANNEX_STYLE_RADIO); + + pContact = static_cast (__pCandidateContactList->GetAt(index)); + TryReturn(pContact, null, "Failed to get the contact."); + + pContact->GetValue(CONTACT_PROPERTY_ID_FIRST_NAME, firstName); + pContact->GetValue(CONTACT_PROPERTY_ID_LAST_NAME, lastName); + + memberName.Append(firstName + " " + lastName); + pItem->SetElement(memberName); + + return pItem; +} + +void +CategoryAddMemberForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, + const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs) +{ + result r = E_SUCCESS; + + __pCategory = static_cast (pArgs->GetAt(0)); + TryReturnVoid(__pCategory, "Failed to get the category"); + pArgs->RemoveAll(false); + delete pArgs; + + if (__pCategory != null) + { + r = GetCandidateContactList(); + TryReturnVoid(!IsFailed(r), "Failed to get candidate contact list (%s).", GetErrorMessage(r)); + } + + __pListView->UpdateList(); +} + +void +CategoryAddMemberForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, + const Tizen::Ui::Scenes::SceneId& nextSceneId) +{ +} + +result +CategoryAddMemberForm::GetCandidateContactList(void) +{ + result r = E_SUCCESS; + AddressbookId addressbookId = INVALID_ADDRESSBOOK_ID; + + Contact* pMemberContact = null; + Contact* pCandidateContact = null; + IList* pCandidateList = null; + IList* pMemberList = null; + + addressbookId = __pCategory->GetAddressbookId(); + + AddressbookFilter filter(AB_FI_TYPE_CONTACT); + filter.AppendInt(FI_CONJ_OP_NONE, CONTACT_FI_PR_ADDRESSBOOK_ID, FI_CMP_OP_EQUAL, addressbookId); + + pCandidateList = __pAddressbookMgr->SearchN(filter, CONTACT_FI_PR_DISPLAY_NAME, SORT_ORDER_ASCENDING); + r = GetLastResult(); + TryReturn(!IsFailed(r), r, "Failed to get the contacts in selected addressbook (%s).", GetErrorMessage(r)); + + pMemberList = __pAddressbookMgr->GetContactsByCategoryN(__pCategory->GetRecordId()); + r = GetLastResult(); + + if (IsFailed(r)) + { + pCandidateList->RemoveAll(true); + delete pCandidateList; + TryReturn(!IsFailed(r), r, "Failed to get member list of category (%s).", GetErrorMessage(r)); + } + + IEnumerator* pCandidateEnum = pCandidateList->GetEnumeratorN(); + IEnumerator* pMemberEnum = pMemberList->GetEnumeratorN(); + + ArrayList* pRemovalList = new (std::nothrow) ArrayList(); + AppAssert(pRemovalList); + + while (pCandidateEnum->MoveNext() == E_SUCCESS) + { + pCandidateContact = static_cast (pCandidateEnum->GetCurrent()); + pMemberEnum->Reset(); + + while (pMemberEnum->MoveNext() == E_SUCCESS) + { + pMemberContact = static_cast (pMemberEnum->GetCurrent()); + + if (pMemberContact->GetRecordId() == pCandidateContact->GetRecordId()) + { + pRemovalList->Add(*pCandidateContact); + break; + } + } + } + + IEnumerator* pRemovalListEnum = pRemovalList->GetEnumeratorN(); + Contact* pRemovalListContact = null; + + while (pRemovalListEnum->MoveNext() == E_SUCCESS) + { + pRemovalListContact = static_cast (pRemovalListEnum->GetCurrent()); + pCandidateList->Remove(*pRemovalListContact, true); + } + + __pCandidateContactList = pCandidateList; + + pMemberList->RemoveAll(true); + pRemovalList->RemoveAll(false); + + delete pMemberList; + delete pRemovalList; + delete pMemberEnum; + delete pCandidateEnum; + delete pRemovalListEnum; + + return r; +} + +result +CategoryAddMemberForm::AddMember(void) +{ + result r = E_SUCCESS; + + if (__pContact == null) + { + MessageBox messageBox; + messageBox.Construct(L"Error", "Select to add member.", MSGBOX_STYLE_OK, 0); + int doModal; + messageBox.ShowAndWait(doModal); + + return E_INVALID_ARG; + } + + r = __pAddressbookMgr->AddMemberToCategory(__pCategory->GetRecordId(), __pContact->GetRecordId()); + TryReturn(!IsFailed(r), r, "Failed to add member to category (%s).", GetErrorMessage(r)); + + return r; +} diff --git a/project/src/CategoryListForm.cpp b/project/src/CategoryListForm.cpp new file mode 100644 index 0000000..3e6048c --- /dev/null +++ b/project/src/CategoryListForm.cpp @@ -0,0 +1,374 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 "CategoryListForm.h" +#include "SceneRegister.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Social; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +CategoryListForm::CategoryListForm(void) + : __pCategoryList(null) + , __pNameEditField(null) + , __pListView(null) + , __pCreatePopup(null) + , __pAddressbookMgr(null) +{ +} + +CategoryListForm::~CategoryListForm(void) +{ +} + +bool +CategoryListForm::Initialize(void) +{ + result r = E_SUCCESS; + + __pAddressbookMgr = AddressbookManager::GetInstance(); + r = GetLastResult(); + TryReturn(!IsFailed(r), false, "Failed to get instance of addressbook manager (%s)", GetErrorMessage(r)); + + r = Construct(L"IDF_FORM_CONTACTS"); + TryReturn(!IsFailed(r), false, "Failed to construct the form (%s).", GetErrorMessage(r)); + + return true; +} + +result +CategoryListForm::OnInitializing(void) +{ + result r = E_SUCCESS; + + Header* pHeader = GetHeader(); + AppAssert(pHeader); + + pHeader->SetStyle(HEADER_STYLE_TITLE); + pHeader->SetTitleText(L"CATEGORIES"); + + Footer* pFooter = GetFooter(); + AppAssert(pFooter); + + pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT); + + FooterItem footerCreate; + footerCreate.Construct(ID_FOOTER_CREATE); + footerCreate.SetText(L"Create"); + pFooter->AddItem(footerCreate); + pFooter->SetBackButton (); + pFooter->AddActionEventListener(*this); + + ScrollPanel* pScrollPanel = new (std::nothrow) ScrollPanel(); + pScrollPanel->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height)); + + unsigned int backgroundColor = 0xABABAB; + Color color(backgroundColor, false); + + Label* pAddressbookName = new (std::nothrow) Label(); + pAddressbookName->Construct(Rectangle(20, 0, GetClientAreaBounds().width - 40, 70), L"phone"); + pAddressbookName->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pAddressbookName->SetBackgroundColor(color); + pAddressbookName->SetTextConfig(50, LABEL_TEXT_STYLE_BOLD); + pScrollPanel->AddControl(*pAddressbookName); + + static int UI_X_POSITION_LEFT = 5; + static int UI_HEIGHT = 80; + static int UI_Y_POSITION = 0; + + __pListView = new (std::nothrow) ListView(); + __pListView->Construct(Rectangle(UI_X_POSITION_LEFT, UI_Y_POSITION + UI_HEIGHT, GetClientAreaBounds().width, GetClientAreaBounds().height)); + __pListView->SetItemProvider(*this); + __pListView->AddListViewItemEventListener(*this); + pScrollPanel->AddControl(*__pListView); + + AddControl(*pScrollPanel); + SetFormBackEventListener(this); + + CreateCategoryPopup(); + + return r; +} + +void +CategoryListForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) +{ + result r = E_SUCCESS; + + switch(actionId) + { + case ID_FOOTER_CREATE: + __pNameEditField->Clear(); + __pCreatePopup->SetShowState(true); + __pCreatePopup->Show(); + break; + + case ID_BUTTON_CANCEL_POPUP: + __pCreatePopup->SetShowState(false); + Invalidate(true); + break; + + case ID_BUTTON_SAVE_POPUP: + __pCreatePopup->SetShowState(false); + r = AddCategory(); + TryReturnVoid(!IsFailed(r), "Failed to add category", GetErrorMessage(r)); + r = GetCategoryList(); + TryReturnVoid(!IsFailed(r), "Failed to get the category list (%s).", GetErrorMessage(r)); + __pListView->UpdateList(); + Invalidate(true); + break; + + default: + break; + } +} + +result +CategoryListForm::OnTerminating(void) +{ + result r = E_SUCCESS; + + if (__pCategoryList != null) + { + __pCategoryList->RemoveAll(true); + delete __pCategoryList; + } + + if (__pCreatePopup != null) + { + delete __pCreatePopup; + __pCreatePopup = null; + } + + return r; +} + +bool +CategoryListForm::DeleteItem(int itemIndex, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth) +{ + delete pItem; + pItem = null; + + return true; +} + +int +CategoryListForm::GetItemCount(void) +{ + if (__pCategoryList != null) + { + return __pCategoryList->GetCount(); + } + + return 0; +} + +Tizen::Ui::Controls::ListItemBase* +CategoryListForm::CreateItem(int index, int itemWidth) +{ + SimpleItem* pItem = null; + Category* pCategory = null; + + String categoryName; + int contactsCount; + + pItem = new SimpleItem(); + AppAssert(pItem); + + pItem->Construct(Dimension(itemWidth, 112), LIST_ANNEX_STYLE_NORMAL); + + pCategory = static_cast(__pCategoryList->GetAt(index)); + TryReturn(pCategory != null, null, "Failed to get category."); + + categoryName = pCategory->GetName(); + contactsCount = pCategory->GetMemberCount(); + + categoryName.Append(L" ("); + categoryName.Append(contactsCount); + categoryName.Append(L")"); + + pItem->SetElement(categoryName); + + return pItem; +} + +void +CategoryListForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status) +{ + if (status == LIST_ITEM_STATUS_SELECTED) + { + result r = E_SUCCESS; + + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + + Category* pCategory = static_cast (__pCategoryList->GetAt(index)); + TryReturnVoid(pCategory != null, "Failed to get category"); + + ArrayList* pList = new (std::nothrow) ArrayList(); + AppAssert(pList); + + pList->Construct(); + TryReturnVoid(pList != null, "Failed to construct list"); + + r = pList->Add(*(new (std::nothrow) Category (*pCategory))); + TryReturnVoid(!IsFailed(r), "Failed to add category (%s).", GetErrorMessage(r)); + + pSceneManager->GoForward(ForwardSceneTransition(SCENE_CATEGORY_MEMBER_FORM), pList); + } +} + +void +CategoryListForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction) +{ +} + +void +CategoryListForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state) +{ +} + +void +CategoryListForm::OnItemReordered(Tizen::Ui::Controls::ListView& view, int oldIndex, int newIndex) +{ +} + +void +CategoryListForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + pSceneManager->GoBackward(BackwardSceneTransition(SCENE_MAIN_FORM)); +} + +void +CategoryListForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, + const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs) +{ + result r = E_SUCCESS; + + r = GetCategoryList(); + TryReturnVoid(!IsFailed(r), "Failed to get the category list (%s).", GetErrorMessage(r)); + + __pListView->UpdateList(); +} + +void +CategoryListForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, + const Tizen::Ui::Scenes::SceneId& nextSceneId) +{ +} + +result +CategoryListForm::AddCategory(void) +{ + result r = E_SUCCESS; + Category category; + String categoryName; + + categoryName = __pNameEditField->GetText(); + + if (categoryName.IsEmpty() == true) + { + MessageBox messageBox; + messageBox.Construct(L"Error", "The category name is empty", MSGBOX_STYLE_OK, 0); + int doModal; + messageBox.ShowAndWait(doModal); + + return E_INVALID_ARG; + } + + category.SetName(categoryName); + + r = __pAddressbookMgr->AddCategory(category, DEFAULT_ADDRESSBOOK_ID); + + if(IsFailed(r) == true) + { + MessageBox messageBox; + messageBox.Construct(L"Error", "Failed to create a category", MSGBOX_STYLE_OK, 0); + int doModal; + messageBox.ShowAndWait(doModal); + + TryReturn(!IsFailed(r), r, "Failed to create a category (%s)", GetErrorMessage(r)); + } + + return r; +} + +result +CategoryListForm::GetCategoryList(void) +{ + result r = E_SUCCESS; + + IList* pCategoryList = null; + AddressbookFilter filter(AB_FI_TYPE_CATEGORY); + + filter.AppendInt(FI_CONJ_OP_NONE, CATEGORY_FI_PR_ADDRESSBOOK_ID, FI_CMP_OP_EQUAL, DEFAULT_ADDRESSBOOK_ID); + pCategoryList = __pAddressbookMgr->SearchN(filter, CATEGORY_FI_PR_NAME, SORT_ORDER_ASCENDING); + + r = GetLastResult(); + TryReturn(!IsFailed(r), r, "Failed to get the category list (%s)", GetErrorMessage(r)); + + if (__pCategoryList != null) + { + __pCategoryList->RemoveAll(true); + delete __pCategoryList; + } + + __pCategoryList = pCategoryList; + + return r; +} + +void +CategoryListForm::CreateCategoryPopup(void) +{ + __pCreatePopup = new (std::nothrow) Popup(); + __pCreatePopup->Construct(true, Dimension(600, 300)); + __pCreatePopup->SetTitleText(L"Create Category"); + + Button* pButtonCancel = new (std::nothrow) Button(); + pButtonCancel->Construct(Rectangle(70, 140, 200, 70), L"Cancel"); + pButtonCancel->SetActionId(ID_BUTTON_CANCEL_POPUP); + pButtonCancel->AddActionEventListener(*this); + __pCreatePopup->AddControl(*pButtonCancel); + + Button* pButtonSave = new (std::nothrow) Button(); + pButtonSave->Construct(Rectangle(290, 140, 200, 70), L"Save"); + pButtonSave->SetActionId(ID_BUTTON_SAVE_POPUP); + pButtonSave->AddActionEventListener(*this); + __pCreatePopup->AddControl(*pButtonSave); + + Label* pNameLabel = new (std::nothrow) Label(); + pNameLabel->Construct(Rectangle(30, 20, 150, 70), L"Name: "); + pNameLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + __pCreatePopup->AddControl(*pNameLabel); + + __pNameEditField = new (std::nothrow) EditField(); + __pNameEditField->Construct(Rectangle(170, 20, 350, 70), EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY); + __pNameEditField->SetGuideText(L"Group Name"); + __pNameEditField->AddActionEventListener(*this); + __pCreatePopup->AddControl(*__pNameEditField); +} diff --git a/project/src/CategoryMemberForm.cpp b/project/src/CategoryMemberForm.cpp new file mode 100755 index 0000000..947e17c --- /dev/null +++ b/project/src/CategoryMemberForm.cpp @@ -0,0 +1,363 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 "CategoryMemberForm.h" +#include "SceneRegister.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Social; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +CategoryMemberForm::CategoryMemberForm(void) + : __pContactList(null) + , __pListView(null) + , __pCategory(null) + , __pAddressbookMgr(null) +{ +} + +CategoryMemberForm::~CategoryMemberForm(void) +{ +} + +bool +CategoryMemberForm::Initialize(void) +{ + result r = E_SUCCESS; + + __pAddressbookMgr = AddressbookManager::GetInstance(); + r = GetLastResult(); + TryReturn(!IsFailed(r), false, "Failed to get instance of addressbook manager (%s)", GetErrorMessage(r)); + + r = Construct(L"IDF_FORM_CONTACTS"); + TryReturn(!IsFailed(r), false, "Failed to construct the form (%s).", GetErrorMessage(r)); + + return true; +} + +result +CategoryMemberForm::OnInitializing(void) +{ + result r = E_SUCCESS; + + Header* pHeader = GetHeader(); + AppAssert(pHeader); + + pHeader->SetStyle(HEADER_STYLE_TITLE); + + ButtonItem buttonItem; + buttonItem.Construct(BUTTON_ITEM_STYLE_TEXT, ID_HEADER_REMOVE_BUTTON); + buttonItem.SetText(L"Delete"); + + unsigned int backgroundColor = 0xABABAB; + Tizen::Graphics::Color color(backgroundColor, false); + + pHeader->SetButton(BUTTON_POSITION_LEFT, buttonItem); + pHeader->SetButtonColor(BUTTON_ITEM_STATUS_NORMAL, color); + pHeader->AddActionEventListener(*this); + + Footer* pFooter = GetFooter(); + AppAssert(pFooter); + + pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT); + + FooterItem footerAdd; + footerAdd.Construct(ID_FOOTER_ADD); + footerAdd.SetText(L"Add Member"); + pFooter->AddItem(footerAdd); + + FooterItem footerDelete; + footerDelete.Construct(ID_FOOTER_DELETE); + footerDelete.SetText(L"Remove Member"); + pFooter->AddItem(footerDelete); + pFooter->SetBackButton(); + pFooter->AddActionEventListener(*this); + + ScrollPanel* pScrollPanel = new (std::nothrow) ScrollPanel(); + pScrollPanel->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height)); + + static int UI_X_POSITION = 5; + static int UI_Y_POSITION = 0; + + __pListView = new (std::nothrow) ListView(); + __pListView->Construct(Rectangle(UI_X_POSITION, UI_Y_POSITION, GetClientAreaBounds().width, GetClientAreaBounds().height)); + __pListView->SetItemProvider(*this); + __pListView->AddListViewItemEventListener(*this); + pScrollPanel->AddControl(*__pListView); + + AddControl(*pScrollPanel); + SetFormBackEventListener(this); + + return r; +} + +result +CategoryMemberForm::OnTerminating(void) +{ + result r = E_SUCCESS; + + if (__pContactList != null) + { + __pContactList->RemoveAll(true); + delete __pContactList; + } + + if (__pCategory != null) + { + delete __pCategory; + __pCategory = null; + } + + return r; +} + +void +CategoryMemberForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + + result r = E_SUCCESS; + + switch(actionId) + { + case ID_FOOTER_ADD: + { + ArrayList* pList = new (std::nothrow) ArrayList(); + AppAssert(pList); + + r = pList->Construct(); + TryReturnVoid(!IsFailed(r), "Failed to construct list", GetErrorMessage(r)); + + r = pList->Add(*(new (std::nothrow) Category(*__pCategory))); + TryReturnVoid(!IsFailed(r), "Failed to add category (%s).", GetErrorMessage(r)); + + pSceneManager->GoForward(ForwardSceneTransition(SCENE_CATEGORY_ADD_MEMBER_FORM), pList); + break; + } + + case ID_FOOTER_DELETE: + { + ArrayList* pList = new (std::nothrow) ArrayList(); + AppAssert(pList); + + r = pList->Construct(); + TryReturnVoid(!IsFailed(r), "Failed to construct list", GetErrorMessage(r)); + + r = pList->Add(*(new (std::nothrow) Category(*__pCategory))); + TryReturnVoid(!IsFailed(r), "Failed to add category (%s).", GetErrorMessage(r)); + + pSceneManager->GoForward(ForwardSceneTransition(SCENE_CATEGORY_REMOVE_MEMBER_FORM), pList); + break; + } + + case ID_HEADER_REMOVE_BUTTON: + { + MessageBox messageBox; + messageBox.Construct(L"Caution", L"Remove this category?", MSGBOX_STYLE_YESNO, 0); + + int modalResult; + messageBox.ShowAndWait(modalResult); + + if (modalResult == MSGBOX_RESULT_YES) + { + r = RemoveCategory(); + TryReturnVoid(!IsFailed(r), "Failed to remove category (%s).", GetErrorMessage(r)); + + pSceneManager->GoBackward(BackwardSceneTransition(SCENE_CATEGORY_LIST_FORM)); + } + + Invalidate(true); + + break; + } + + default: + break; + } +} + +void +CategoryMemberForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + pSceneManager->GoBackward(BackwardSceneTransition(SCENE_CATEGORY_LIST_FORM)); +} + +bool +CategoryMemberForm::DeleteItem(int itemIndex, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth) +{ + delete pItem; + pItem = null; + + return true; +} + +int +CategoryMemberForm::GetItemCount(void) +{ + if (__pContactList != null) + { + return __pContactList->GetCount(); + } + + return 0; +} + +void +CategoryMemberForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status) +{ +} + +void +CategoryMemberForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction) +{ +} + +void +CategoryMemberForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state) +{ +} + +void +CategoryMemberForm::OnItemReordered(Tizen::Ui::Controls::ListView& view, int oldIndex, int newIndex) +{ +} + +Tizen::Ui::Controls::ListItemBase* +CategoryMemberForm::CreateItem(int index, int itemWidth) +{ + String displayName; + SimpleItem* pItem = new SimpleItem(); + AppAssert(pItem); + + Contact* pContact = null; + + pItem->Construct(Dimension(itemWidth, 112), LIST_ANNEX_STYLE_NORMAL); + pContact = static_cast (__pContactList->GetAt(index)); + TryReturn(pContact != null, null, "Failed to get contact"); + + pContact->GetValue(CONTACT_PROPERTY_ID_DISPLAY_NAME, displayName); + + if (displayName.IsEmpty() == true) + { + displayName = L"(No name)"; + } + + pItem->SetElement(displayName); + + return pItem; +} + +void +CategoryMemberForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, + const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs) +{ + if (pArgs != null) + { + result r = E_SUCCESS; + + if (__pCategory != null) + { + delete __pCategory; + __pCategory = null; + } + + __pCategory = static_cast (pArgs->GetAt(0)); + TryReturnVoid(__pCategory, "Failed to get the category (%s).", GetErrorMessage(r)); + pArgs->RemoveAll(false); + delete pArgs; + + Header* pHeader = GetHeader(); + AppAssert(pHeader); + pHeader->SetTitleText(__pCategory->GetName()); + + r = GetMemberList(); + TryReturnVoid(!IsFailed(r), "Failed to get contact (%s).", GetErrorMessage(r)); + + __pListView->UpdateList(); + } +} + +void +CategoryMemberForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, + const Tizen::Ui::Scenes::SceneId& nextSceneId) +{ +} + +result +CategoryMemberForm::GetMemberList(void) +{ + result r = E_SUCCESS; + + IList* pMemberList = __pAddressbookMgr->GetContactsByCategoryN(__pCategory->GetRecordId()); + + r = GetLastResult(); + TryReturn(!IsFailed(r), r, "Failed to get the contact list (%s).", GetErrorMessage(r)); + + if (__pContactList != null) + { + __pContactList->RemoveAll(true); + delete __pContactList; + } + + __pContactList = pMemberList; + + return r; +} + +result +CategoryMemberForm::RemoveCategory(void) +{ + result r = E_SUCCESS; + + if (__pCategory->IsDefault() == false) + { + r = __pAddressbookMgr->RemoveCategory(__pCategory->GetRecordId()); + + if (IsFailed(r)) + { + MessageBox messageBox; + int doModal; + messageBox.Construct(L"Error", "Failed to remove a category", MSGBOX_STYLE_OK, 0); + messageBox.ShowAndWait(doModal); + + return r; + } + } + + else + { + MessageBox messageBox; + int doModal; + messageBox.Construct(L"Error", "The default category cannot remove.", MSGBOX_STYLE_OK, 0); + messageBox.ShowAndWait(doModal); + + return E_INVALID_ARG; + } + + return r; +} + diff --git a/project/src/CategoryRemoveMemberForm.cpp b/project/src/CategoryRemoveMemberForm.cpp new file mode 100644 index 0000000..8c24bea --- /dev/null +++ b/project/src/CategoryRemoveMemberForm.cpp @@ -0,0 +1,315 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 "CategoryRemoveMemberForm.h" +#include "SceneRegister.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Social; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +CategoryRemoveMemberForm::CategoryRemoveMemberForm(void) + : __pContactList(null) + , __pListView(null) + , __pCategory(null) + , __pContact(null) + , __pAddressbookMgr(null) + , __checkedIndex(0) +{ +} + +CategoryRemoveMemberForm::~CategoryRemoveMemberForm(void) +{ +} + +bool +CategoryRemoveMemberForm::Initialize(void) +{ + result r = E_SUCCESS; + + __pAddressbookMgr = AddressbookManager::GetInstance(); + r = GetLastResult(); + TryReturn(!IsFailed(r), false, "Failed to get instance of addressbook manager (%s)", GetErrorMessage(r)); + + r = Construct(L"IDF_FORM_CONTACTS"); + TryReturn(!IsFailed(r), false, "Failed to construct the form (%s).", GetErrorMessage(r)); + + return true; +} + +result +CategoryRemoveMemberForm::OnInitializing(void) +{ + result r = E_SUCCESS; + + Header* pHeader = GetHeader(); + AppAssert(pHeader); + + pHeader->SetStyle(HEADER_STYLE_TITLE); + pHeader->SetTitleText("REMOVE MEMBER"); + + Footer* pFooter = GetFooter(); + AppAssert(pFooter); + + pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT); + + FooterItem footerDelete; + footerDelete.Construct(ID_FOOTER_DELETE); + footerDelete.SetText(L"Remove"); + pFooter->AddItem(footerDelete); + pFooter->SetBackButton(); + pFooter->AddActionEventListener(*this); + + ScrollPanel* pScrollPanel = new (std::nothrow) ScrollPanel(); + pScrollPanel->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height)); + + static int UI_X_POSITION = 5; + static int UI_Y_POSITION = 0; + + __pListView = new (std::nothrow) ListView(); + __pListView->Construct(Rectangle(UI_X_POSITION, UI_Y_POSITION, GetClientAreaBounds().width, GetClientAreaBounds().height)); + __pListView->SetItemProvider(*this); + __pListView->AddListViewItemEventListener(*this); + pScrollPanel->AddControl(*__pListView); + + AddControl(*pScrollPanel); + SetFormBackEventListener(this); + + return r; +} + +result +CategoryRemoveMemberForm::OnTerminating(void) +{ + result r = E_SUCCESS; + + if (__pContactList != null) + { + __pContactList->RemoveAll(true); + delete __pContactList; + } + + return r; +} + +void +CategoryRemoveMemberForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + + switch(actionId) + { + case ID_FOOTER_DELETE: + { + result r = E_SUCCESS; + + MessageBox messageBox; + messageBox.Construct(L"Caution", "Remove selected member(s)?", MSGBOX_STYLE_YESNO, 0); + + int modalResult; + messageBox.ShowAndWait(modalResult); + + if (modalResult == MSGBOX_RESULT_YES) + { + r = RemoveMember(); + TryReturnVoid(!IsFailed(r), "Failed to remove member (%s).", GetErrorMessage(r)); + + ArrayList* pCategoryList = new (std::nothrow) ArrayList(); + AppAssert(pCategoryList); + + r = pCategoryList->Construct(); + TryReturnVoid(!IsFailed(r), "Failed to construct the list (%s)", GetErrorMessage(r)); + + r = pCategoryList->Add(*(new (std::nothrow) Category(*__pCategory))); + TryReturnVoid(!IsFailed(r), "Failed to add category (%s).", GetErrorMessage(r)); + + pSceneManager->GoBackward(BackwardSceneTransition(SCENE_CATEGORY_MEMBER_FORM), pCategoryList); + } + + break; + } + + default: + break; + } +} + +void +CategoryRemoveMemberForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + + result r = E_SUCCESS; + + ArrayList* pCategoryList = new (std::nothrow) ArrayList(); + AppAssert(pCategoryList); + + r = pCategoryList->Construct(); + TryReturnVoid(!IsFailed(r), "Failed to construct the list (%s)", GetErrorMessage(r)); + + r = pCategoryList->Add(*(new (std::nothrow) Category(*__pCategory))); + TryReturnVoid(!IsFailed(r), "Failed to add category (%s).", GetErrorMessage(r)); + + pSceneManager->GoBackward(BackwardSceneTransition(SCENE_CATEGORY_MEMBER_FORM), pCategoryList); +} + +bool +CategoryRemoveMemberForm::DeleteItem(int itemIndex, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth) +{ + delete pItem; + pItem = null; + + return true; +} + +int +CategoryRemoveMemberForm::GetItemCount(void) +{ + if (__pContactList != null) + { + return __pContactList->GetCount(); + } + + return 0; +} + +void +CategoryRemoveMemberForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status) +{ + if (status == LIST_ITEM_STATUS_CHECKED) + { + if (__checkedIndex != index || __checkedIndex != 0) + { + listView.SetItemChecked(__checkedIndex, false); + listView.Invalidate(true); + } + + __pContact = static_cast (__pContactList->GetAt(index)); + __checkedIndex = index; + } + + else if (status == LIST_ITEM_STATUS_UNCHECKED) + { + listView.SetItemChecked(index, false); + listView.Invalidate(true); + __pContact = null; + } +} + +void +CategoryRemoveMemberForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction) +{ +} + +void +CategoryRemoveMemberForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state) +{ +} + +void +CategoryRemoveMemberForm::OnItemReordered(Tizen::Ui::Controls::ListView& view, int oldIndex, int newIndex) +{ +} + +Tizen::Ui::Controls::ListItemBase* +CategoryRemoveMemberForm::CreateItem(int index, int itemWidth) +{ + String name; + + SimpleItem* pItem = null; + Contact* pContact = null; + + pItem = new SimpleItem(); + AppAssert(pItem); + + pItem->Construct(Dimension(itemWidth, 112), LIST_ANNEX_STYLE_RADIO); + pContact = static_cast (__pContactList->GetAt(index)); + AppAssert(pContact); + + pContact->GetValue(CONTACT_PROPERTY_ID_DISPLAY_NAME, name); + pItem->SetElement(name); + + return pItem; +} + +void +CategoryRemoveMemberForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, + const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs) +{ + if (pArgs != null) + { + result r = E_SUCCESS; + + __pCategory = static_cast (pArgs->GetAt(0)); + TryReturnVoid(__pCategory, "Failed to get the category (%s).", GetErrorMessage(r)); + pArgs->RemoveAll(false); + delete pArgs; + + r = GetMemberList(); + TryReturnVoid(!IsFailed(r), "Failed to get the contact list (%s).", GetErrorMessage(r)); + + __pListView->UpdateList(); + } +} + +void +CategoryRemoveMemberForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, + const Tizen::Ui::Scenes::SceneId& nextSceneId) +{ +} + +result +CategoryRemoveMemberForm::GetMemberList(void) +{ + result r = E_SUCCESS; + + __pContactList = __pAddressbookMgr->GetContactsByCategoryN(__pCategory->GetRecordId()); + r = GetLastResult(); + TryReturn(!IsFailed(r), r, "Failed to get the contact list (%s).", GetErrorMessage(r)); + + return r; +} + +result +CategoryRemoveMemberForm::RemoveMember(void) +{ + result r = E_SUCCESS; + + if (__pContact == null) + { + MessageBox messageBox; + messageBox.Construct(L"Error", "Select to remove member.", MSGBOX_STYLE_OK, 0); + int doModal; + messageBox.ShowAndWait(doModal); + + return E_INVALID_ARG; + } + + r = __pAddressbookMgr->RemoveMemberFromCategory(__pCategory->GetRecordId(), __pContact->GetRecordId()); + TryReturn(!IsFailed(r), r, "Failed to remove member from category (%s).", GetErrorMessage(r)); + + return r; +} diff --git a/project/src/Contacts.cpp b/project/src/Contacts.cpp new file mode 100644 index 0000000..df2d216 --- /dev/null +++ b/project/src/Contacts.cpp @@ -0,0 +1,153 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 "Contacts.h" +#include "ContactsFrame.h" +#include "ContactsFormFactory.h" +#include "SceneRegister.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; + + +ContactsApp::ContactsApp(void) +{ +} + +ContactsApp::~ContactsApp(void) +{ +} + +UiApp* +ContactsApp::CreateInstance(void) +{ + // Create the instance through the constructor. + return new ContactsApp(); +} + +bool +ContactsApp::OnAppInitializing(AppRegistry& appRegistry) +{ + // TODO: + // Initialize Frame and App specific data. + // The App's permanent data and context can be obtained from the appRegistry. + // + // If this method is successful, return true; otherwise, return false. + // If this method returns false, the App will be terminated. + + // Uncomment the following statement to listen to the screen on/off events. + //PowerManager::SetScreenEventListener(*this); + + // TODO: + // Add your initialization code here + + return true; +} + +bool +ContactsApp::OnAppInitialized(void) +{ + // TODO: + // Comment. + + // Create a Frame + ContactsFrame* pContactsFrame = new ContactsFrame(); + pContactsFrame->Construct(); + pContactsFrame->SetName(L"Contacts"); + AddFrame(*pContactsFrame); + + SceneRegister::RegisterAllScenes(); + + // Prepare Scene management. + SceneManager* pSceneManager = SceneManager::GetInstance(); + + // Goto the scene. + if (pSceneManager->GoForward(ForwardSceneTransition(SCENE_MAIN_FORM)) != E_SUCCESS) + { + return false; + } + + return true; +} + +bool +ContactsApp::OnAppWillTerminate(void) +{ + // TODO: + // Comment. + return true; +} + +bool +ContactsApp::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination) +{ + // TODO: + // Deallocate resources allocated by this App for termination. + // The App's permanent data and context can be saved via appRegistry. + return true; +} + +void +ContactsApp::OnForeground(void) +{ + // TODO: + // Start or resume drawing when the application is moved to the foreground. +} + +void +ContactsApp::OnBackground(void) +{ + // TODO: + // Stop drawing when the application is moved to the background. +} + +void +ContactsApp::OnLowMemory(void) +{ + // TODO: + // Free unused resources or close the application. +} + +void +ContactsApp::OnBatteryLevelChanged(BatteryLevel batteryLevel) +{ + // TODO: + // Handle any changes in battery level here. + // Stop using multimedia features(camera, mp3 etc.) if the battery level is CRITICAL. +} + +void +ContactsApp::OnScreenOn(void) +{ + // TODO: + // Get the released resources or resume the operations that were paused or stopped in OnScreenOff(). +} + +void +ContactsApp::OnScreenOff(void) +{ + // TODO: + // Unless there is a strong reason to do otherwise, release resources (such as 3D, media, and sensors) to allow the device + // to enter the sleep mode to save the battery. + // Invoking a lengthy asynchronous method within this listener method can be risky, because it is not guaranteed to invoke a + // callback before the device enters the sleep mode. + // Similarly, do not perform lengthy operations in this listener method. Any operation must be a quick one. +} diff --git a/project/src/ContactsEntry.cpp b/project/src/ContactsEntry.cpp new file mode 100644 index 0000000..f7739e5 --- /dev/null +++ b/project/src/ContactsEntry.cpp @@ -0,0 +1,64 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 "Contacts.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* pArgs = new ArrayList(); + pArgs->Construct(); + for (int i = 0; i < argc; i++) + { + pArgs->Add(*(new String(pArgv[i]))); + } + + r = Tizen::App::UiApp::Execute(ContactsApp::CreateInstance, pArgs); + if (IsFailed(r)) + { + AppLogException("Application execution failed-[%s].", GetErrorMessage(r)); + r &= 0x0000FFFF; + } + + pArgs->RemoveAll(true); + delete pArgs; + AppLog("Application finished."); + + return static_cast(r); +} +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/project/src/ContactsFormFactory.cpp b/project/src/ContactsFormFactory.cpp new file mode 100644 index 0000000..6976d0b --- /dev/null +++ b/project/src/ContactsFormFactory.cpp @@ -0,0 +1,129 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 "ContactsFormFactory.h" +#include "MainForm.h" +#include "CreateContactForm.h" +#include "CategoryListForm.h" +#include "DetailViewForm.h" +#include "CategoryMemberForm.h" +#include "EditContactForm.h" +#include "CategoryRemoveMemberForm.h" +#include "CategoryAddMemberForm.h" +#include "FavoriteListForm.h" + +using namespace Tizen::Ui::Scenes; + +const wchar_t* FORM_MAIN = L"MainForm"; +const wchar_t* FORM_CATEGORY_LIST = L"CategoryListForm"; +const wchar_t* FORM_CREATE_CONTACT = L"CreateContactForm"; +const wchar_t* FORM_DETAIL_VIEW = L"DetailViewForm"; +const wchar_t* FORM_CATEGORY_MEMBER = L"CategoryMemberForm"; +const wchar_t* FORM_EDIT_CONTACT = L"EditContactForm"; +const wchar_t* FORM_CATEGORY_REMOVE_MEMBER = L"CategoryRemoveMemberForm"; +const wchar_t* FORM_CATEGORY_ADD_MEMBER = L"CategoryAddMemberForm"; +const wchar_t* FORM_FAVORITE_LIST = L"FavoriteListForm"; + +ContactsFormFactory::ContactsFormFactory(void) +{ +} + +ContactsFormFactory::~ContactsFormFactory(void) +{ +} + +Tizen::Ui::Controls::Form* +ContactsFormFactory::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") + { + MainForm* pForm = new MainForm(); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + // TODO: + // Add your form creation code here + else if (formId == L"CategoryListForm") + { + CategoryListForm* pForm = new CategoryListForm(); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + + else if (formId == L"CreateContactForm") + { + CreateContactForm* pForm = new CreateContactForm(); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + + else if (formId == L"DetailViewForm") + { + DetailViewForm* pForm = new DetailViewForm(); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + + else if (formId == L"CategoryMemberForm") + { + CategoryMemberForm* pForm = new CategoryMemberForm(); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + + else if (formId == L"EditContactForm") + { + EditContactForm* pForm = new EditContactForm(); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + + else if (formId == L"CategoryRemoveMemberForm") + { + CategoryRemoveMemberForm* pForm = new CategoryRemoveMemberForm(); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + + else if (formId == L"CategoryAddMemberForm") + { + CategoryAddMemberForm* pForm = new CategoryAddMemberForm(); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + + else if (formId == L"FavoriteListForm") + { + FavoriteListForm* pForm = new FavoriteListForm(); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + return pNewForm; +} diff --git a/project/src/ContactsFrame.cpp b/project/src/ContactsFrame.cpp new file mode 100644 index 0000000..b73d12b --- /dev/null +++ b/project/src/ContactsFrame.cpp @@ -0,0 +1,52 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 "ContactsFrame.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +ContactsFrame::ContactsFrame(void) +{ +} + +ContactsFrame::~ContactsFrame(void) +{ +} + +result +ContactsFrame::OnInitializing(void) +{ + result r = E_SUCCESS; + + // TODO: + // Add your initialization code here + return r; +} + +result +ContactsFrame::OnTerminating(void) +{ + result r = E_SUCCESS; + + // TODO: + // Add your termination code here + return r; +} + + diff --git a/project/src/CreateContactForm.cpp b/project/src/CreateContactForm.cpp new file mode 100644 index 0000000..c94f12b --- /dev/null +++ b/project/src/CreateContactForm.cpp @@ -0,0 +1,427 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 "CreateContactForm.h" +#include "SceneRegister.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Utility; +using namespace Tizen::Graphics; +using namespace Tizen::Social; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +CreateContactForm::CreateContactForm(void) + : __pFirstNameEditField(null) + , __pLastNameEditField(null) + , __pPhoneNumberEditField(null) + , __pEmailEditField(null) + , __pUrlEditField(null) + , __pOrganizationEditField(null) + , __pNoteEditField(null) + , __pEventEditDate(null) + , __pAddressbookNameLabel(null) + , __addressbookId(DEFAULT_ADDRESSBOOK_ID) + , __pAddressbookMgr(null) + , __pAddressbookListPopup(null) + , __isDateChanged(false) +{ +} + +CreateContactForm::~CreateContactForm(void) +{ +} + +bool +CreateContactForm::Initialize(void) +{ + result r = E_SUCCESS; + + __pAddressbookMgr = AddressbookManager::GetInstance(); + r = GetLastResult(); + TryReturn(!IsFailed(r), false, "Failed to get instance of addressbook manager (%s)", GetErrorMessage(r)); + + r = Construct(L"IDF_FORM_CONTACTS"); + TryReturn(!IsFailed(r), false, "Failed to construct the form (%s).", GetErrorMessage(r)); + + return true; +} + +result +CreateContactForm::OnInitializing(void) +{ + result r = E_SUCCESS; + + Header* pHeader = GetHeader(); + AppAssert(pHeader); + + pHeader->SetStyle(HEADER_STYLE_TITLE); + pHeader->SetTitleText(L"CREATE CONTACT"); + + Footer* pFooter = GetFooter(); + AppAssert(pFooter); + + pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT); + + FooterItem footerSave; + footerSave.Construct(ID_FOOTER_SAVE); + footerSave.SetText(L"Save"); + pFooter->AddItem(footerSave); + + pFooter->SetBackButton(); + pFooter->AddActionEventListener(*this); + + ScrollPanel* pScrollPanel = new (std::nothrow) ScrollPanel(); + pScrollPanel->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height)); + + __pAddressbookNameLabel = new (std::nothrow) Label(); + __pAddressbookNameLabel->Construct(Rectangle(0, 0, 500 , 112), L""); + __pAddressbookNameLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + __pAddressbookNameLabel->SetTextConfig(50, LABEL_TEXT_STYLE_BOLD); + pScrollPanel->AddControl(*__pAddressbookNameLabel); + + Button* pAddressbookButton = new (std::nothrow) Button(); + pAddressbookButton->Construct(Rectangle(600, 0, 80 , 74), L">"); + pAddressbookButton->SetTextHorizontalAlignment(ALIGNMENT_CENTER); + pAddressbookButton->SetActionId(ID_BUTTON_ADDRESSBOOK_LIST); + pAddressbookButton->AddActionEventListener(*this); + pScrollPanel->AddControl(*pAddressbookButton); + + static const int UI_X_POSITION_LEFT = 20; + static const int UI_X_RIGHT_MARGIN = 40; + static const int UI_HEIGHT = 112; + static const int UI_LABEL_HEIGHT = 50; + int yPosition = 50; + + unsigned int backgroundColor = 0xABABAB; + Tizen::Graphics::Color color(backgroundColor, false); + + Label* pNameLabel = new (std::nothrow) Label(); + pNameLabel->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 90, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN , UI_LABEL_HEIGHT), L"Name"); + pNameLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pNameLabel->SetBackgroundColor(color); + pScrollPanel->AddControl(*pNameLabel); + + __pFirstNameEditField = new (std::nothrow) EditField(); + __pFirstNameEditField->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 60, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN, UI_HEIGHT), EDIT_FIELD_STYLE_NORMAL); + __pFirstNameEditField->SetGuideText("First Name"); + pScrollPanel->AddControl(*__pFirstNameEditField); + + + __pLastNameEditField = new (std::nothrow) EditField(); + __pLastNameEditField->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 122, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN, UI_HEIGHT), EDIT_FIELD_STYLE_NORMAL); + __pLastNameEditField->SetGuideText("Last Name"); + pScrollPanel->AddControl(*__pLastNameEditField); + + Label* pPhoneNumberLabel = new (std::nothrow) Label(); + pPhoneNumberLabel->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 122, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN , UI_LABEL_HEIGHT), L"Phone Number"); + pPhoneNumberLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pPhoneNumberLabel->SetBackgroundColor(color); + pScrollPanel->AddControl(*pPhoneNumberLabel); + + __pPhoneNumberEditField = new (std::nothrow) EditField(); + __pPhoneNumberEditField->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 60, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN, UI_HEIGHT), EDIT_FIELD_STYLE_PHONE_NUMBER); + __pPhoneNumberEditField->SetGuideText("Phone Number"); + pScrollPanel->AddControl(*__pPhoneNumberEditField); + + Label* pEmailLabel = new (std::nothrow) Label(); + pEmailLabel->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 122, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN , UI_LABEL_HEIGHT), L"Email"); + pEmailLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pEmailLabel->SetBackgroundColor(color); + pScrollPanel->AddControl(*pEmailLabel); + + __pEmailEditField = new (std::nothrow) EditField(); + __pEmailEditField->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 60, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN, UI_HEIGHT), EDIT_FIELD_STYLE_EMAIL); + __pEmailEditField->SetGuideText("Email"); + pScrollPanel->AddControl(*__pEmailEditField); + + Label* pUrlLabel = new (std::nothrow) Label(); + pUrlLabel->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 122, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN , UI_LABEL_HEIGHT), L"Url"); + pUrlLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pUrlLabel->SetBackgroundColor(color); + pScrollPanel->AddControl(*pUrlLabel); + + __pUrlEditField = new (std::nothrow) EditField(); + __pUrlEditField->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 60, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN, UI_HEIGHT), EDIT_FIELD_STYLE_URL); + __pUrlEditField->SetGuideText("Url"); + pScrollPanel->AddControl(*__pUrlEditField); + + Label* pOrganizationLabel = new (std::nothrow) Label(); + pOrganizationLabel->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 122, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN , UI_LABEL_HEIGHT), L"Company"); + pOrganizationLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pOrganizationLabel->SetBackgroundColor(color); + pScrollPanel->AddControl(*pOrganizationLabel); + + __pOrganizationEditField = new (std::nothrow) EditField(); + __pOrganizationEditField->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 60, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN, UI_HEIGHT), EDIT_FIELD_STYLE_NORMAL); + __pOrganizationEditField->SetGuideText("Company"); + pScrollPanel->AddControl(*__pOrganizationEditField); + + Label* pEventLabel = new (std::nothrow) Label(); + pEventLabel->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 122, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN , UI_LABEL_HEIGHT), L"Birthday"); + pEventLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pEventLabel->SetBackgroundColor(color); + pScrollPanel->AddControl(*pEventLabel); + + __pEventEditDate = new (std::nothrow) EditDate(); + __pEventEditDate->Construct(Point(UI_X_POSITION_LEFT, yPosition + 32)); + __pEventEditDate->SetCurrentDate(); + __pEventEditDate->AddDateChangeEventListener(*this); + pScrollPanel->AddControl(*__pEventEditDate); + + Label* pNoteLabel = new (std::nothrow) Label(); + pNoteLabel->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 122, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN , UI_LABEL_HEIGHT), L"Note"); + pNoteLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pNoteLabel->SetBackgroundColor(color); + pScrollPanel->AddControl(*pNoteLabel); + + __pNoteEditField = new (std::nothrow) EditField(); + __pNoteEditField->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 60, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN, UI_HEIGHT), EDIT_FIELD_STYLE_NORMAL); + __pNoteEditField->SetGuideText("Note"); + pScrollPanel->AddControl(*__pNoteEditField); + + AddControl(*pScrollPanel); + SetFormBackEventListener(this); + + return r; +} + +result +CreateContactForm::OnTerminating(void) +{ + result r = E_SUCCESS; + + if (__pAddressbookListPopup != null) + { + delete __pAddressbookListPopup; + __pAddressbookListPopup = null; + } + + return r; +} + +void +CreateContactForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + + result r = E_SUCCESS; + + switch(actionId) + { + case ID_FOOTER_SAVE: + if (__pFirstNameEditField->GetText().IsEmpty() == true && __pLastNameEditField->GetText().IsEmpty() == true) + { + MessageBox messageBox; + int doModal; + messageBox.Construct("info", "Please enter the first name or last name", MSGBOX_STYLE_OK, 0); + messageBox.ShowAndWait(doModal); + } + + else + { + r = AddContact(); + TryReturnVoid(!IsFailed(r), "Failed to create contact (%s)", GetErrorMessage(r)); + pSceneManager->GoBackward(BackwardSceneTransition(SCENE_MAIN_FORM)); + } + break; + + case ID_BUTTON_ADDRESSBOOK_LIST: + { + if (__pAddressbookListPopup == null) + { + __pAddressbookListPopup = new (std::nothrow) AddressbookListPopup(); + __pAddressbookListPopup->Construct(this); + } + + __pAddressbookListPopup->Show(); + break; + } + + default: + break; + } +} + +void +CreateContactForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + pSceneManager->GoBackward(BackwardSceneTransition(SCENE_MAIN_FORM)); +} + +void +CreateContactForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, + const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs) +{ + __pAddressbookNameLabel->SetText(GetAddressbookName(__addressbookId)); +} + +void +CreateContactForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, + const Tizen::Ui::Scenes::SceneId& nextSceneId) +{ +} + +void +CreateContactForm::OnUserEventReceivedN(RequestId requestId, IList* pArgs) +{ + if (__pAddressbookListPopup != null) + { + delete __pAddressbookListPopup; + __pAddressbookListPopup = null; + } + + if (pArgs) + { + Integer* pInteger = static_cast (pArgs->GetAt(0)); + AppAssert(pInteger); + + __addressbookId = pInteger->ToInt(); + pArgs->RemoveAll(true); + delete pArgs; + + __pAddressbookNameLabel->SetText(GetAddressbookName(__addressbookId)); + } +} + +void +CreateContactForm::OnDateChanged(const Control& source, int year, int month, int day) +{ + __isDateChanged = true; +} + +void +CreateContactForm::OnDateChangeCanceled(const Control& source) +{ +} + +String +CreateContactForm::GetAddressbookName(AddressbookId addressbookId) +{ + result r = E_SUCCESS; + + Addressbook* pAddressbook = __pAddressbookMgr->GetAddressbookN(addressbookId); + r = GetLastResult(); + TryReturn(!IsFailed(r), null, "Failed to get addressbook. (%s)", GetErrorMessage(r)); + + String delim(L"/"); + StringTokenizer tokenizer(pAddressbook->GetName(), delim); + + String name; + + while (tokenizer.HasMoreTokens()) + { + tokenizer.GetNextToken(name); + } + + return name; +} + +result +CreateContactForm::AddContact() +{ + result r = E_SUCCESS; + String strValue = __pFirstNameEditField->GetText(); + Contact contact; + + if (strValue.IsEmpty() == false) + { + contact.SetValue(CONTACT_PROPERTY_ID_FIRST_NAME, strValue); + } + + strValue = __pLastNameEditField->GetText(); + + if (strValue.IsEmpty() == false) + { + contact.SetValue(CONTACT_PROPERTY_ID_LAST_NAME, strValue); + } + + strValue = __pPhoneNumberEditField->GetText(); + + if (strValue.IsEmpty() == false) + { + PhoneNumber phoneNumber; + phoneNumber.SetPhoneNumber(strValue); + contact.AddPhoneNumber(phoneNumber); + } + + strValue = __pEmailEditField->GetText(); + + if (strValue.IsEmpty() == false) + { + Email email; + email.SetEmail(strValue); + contact.AddEmail(email); + } + + strValue = __pUrlEditField->GetText(); + + if (strValue.IsEmpty() == false) + { + Url url; + url.SetUrl(strValue); + contact.AddUrl(url); + } + + strValue = __pOrganizationEditField->GetText(); + + if (strValue.IsEmpty() == false) + { + Organization organization; + organization.SetName(strValue); + contact.AddOrganization(organization); + } + + if (__isDateChanged == true) + { + DateTime dateTime = __pEventEditDate->GetDate(); + ContactEvent contactEvent; + contactEvent.SetLabel(L"Birthday"); + contactEvent.SetType(CONTACT_EVENT_TYPE_BIRTHDAY); + contactEvent.SetDate(dateTime); + contact.AddEvent(contactEvent); + } + + strValue = __pNoteEditField->GetText(); + + if (strValue.IsEmpty() == false) + { + contact.AddNote(strValue); + } + + r = __pAddressbookMgr->AddContact(contact, __addressbookId); + + if(IsFailed(r)) + { + MessageBox messageBox; + int doModal; + messageBox.Construct(L"Error", "Failed to create Contact", MSGBOX_STYLE_OK, 0); + messageBox.ShowAndWait(doModal); + } + + TryReturn(!IsFailed(r), r, "Failed to create Contact (%s)", GetErrorMessage(r)); + + return r; +} diff --git a/project/src/DetailViewForm.cpp b/project/src/DetailViewForm.cpp new file mode 100644 index 0000000..3353499 --- /dev/null +++ b/project/src/DetailViewForm.cpp @@ -0,0 +1,468 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 "DetailViewForm.h" +#include "SceneRegister.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Social; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +DetailViewForm::DetailViewForm(void) + : __pPopup(null) + , __pPhoneNumberLabelData(null) + , __pEmailLabelData(null) + , __pUrlLabelData(null) + , __pOrganizationLabelData(null) + , __pEventLabelData(null) + , __pNoteLabelData(null) + , __pAddressbookMgr(null) + , __pPerson(null) +{ +} + +DetailViewForm::~DetailViewForm(void) +{ +} + +bool +DetailViewForm::Initialize(void) +{ + result r = E_SUCCESS; + + __pAddressbookMgr = AddressbookManager::GetInstance(); + r = GetLastResult(); + TryReturn(!IsFailed(r), false, "Failed to get instance of addressbook manager (%s)", GetErrorMessage(r)); + + r = Construct(L"IDF_FORM_CONTACTS"); + TryReturn(!IsFailed(r), false, "Failed to construct the form (%s).", GetErrorMessage(r)); + + return true; +} + +result +DetailViewForm::OnInitializing(void) +{ + result r = E_SUCCESS; + + Header* pHeader = GetHeader(); + AppAssert(pHeader); + pHeader->SetStyle(HEADER_STYLE_TITLE); + + ButtonItem buttonFavorite; + buttonFavorite.Construct(BUTTON_ITEM_STYLE_TEXT, ID_HEADER_FAVORITE_BUTTON); + buttonFavorite.SetText(L"Fav."); + + unsigned int backgroundColor = 0xABABAB; + Color color(backgroundColor, false); + + pHeader->SetButton(BUTTON_POSITION_RIGHT, buttonFavorite); + pHeader->AddActionEventListener(*this); + + __favoriteTextColor = pHeader->GetButtonTextColor(BUTTON_ITEM_STATUS_PRESSED); + __normalTextColor = pHeader->GetButtonTextColor(BUTTON_ITEM_STATUS_NORMAL); + + Footer* pFooter = GetFooter(); + AppAssert(pFooter); + pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT); + + FooterItem footerEdit; + footerEdit.Construct(ID_FOOTER_EDIT); + footerEdit.SetText(L"Edit"); + pFooter->AddItem(footerEdit); + + FooterItem footerDelete; + footerDelete.Construct(ID_FOOTER_DELETE); + footerDelete.SetText(L"Delete"); + pFooter->AddItem(footerDelete); + pFooter->SetBackButton(); + pFooter->AddActionEventListener(*this); + + ScrollPanel* pScrollPanel = new (std::nothrow) ScrollPanel(); + pScrollPanel->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height)); + + static const int UI_X_POSITION_LEFT = 20; + static const int UI_X_MARGIN_RIGHT = 40; + static const int UI_LABEL_HEIGHT = 50; + static const int UI_HEIGHT = 80; + int yPosition = 0; + + Label* pPhoneNumberLabel = new (std::nothrow) Label(); + pPhoneNumberLabel->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition+=10, GetClientAreaBounds().width - UI_X_MARGIN_RIGHT, UI_LABEL_HEIGHT), L"Phone Number"); + pPhoneNumberLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pPhoneNumberLabel->SetBackgroundColor(color); + pScrollPanel->AddControl(*pPhoneNumberLabel); + + __pPhoneNumberLabelData = new (std::nothrow) Label(); + __pPhoneNumberLabelData->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition+=60, GetClientAreaBounds().width - UI_X_MARGIN_RIGHT, UI_HEIGHT), L""); + __pPhoneNumberLabelData->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + __pPhoneNumberLabelData->SetTextConfig(50, LABEL_TEXT_STYLE_NORMAL); + pScrollPanel->AddControl(*__pPhoneNumberLabelData); + + Label* pEmailLabel = new (std::nothrow) Label(); + pEmailLabel->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition+=90, GetClientAreaBounds().width - UI_X_MARGIN_RIGHT, UI_LABEL_HEIGHT), L"Email"); + pEmailLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pEmailLabel->SetBackgroundColor(color); + pScrollPanel->AddControl(*pEmailLabel); + + __pEmailLabelData = new (std::nothrow) Label(); + __pEmailLabelData->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition+=60, GetClientAreaBounds().width - UI_X_MARGIN_RIGHT, UI_HEIGHT), L""); + __pEmailLabelData->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + __pEmailLabelData->SetTextConfig(50, LABEL_TEXT_STYLE_NORMAL); + pScrollPanel->AddControl(*__pEmailLabelData); + + Label* pUrlLabel = new (std::nothrow) Label(); + pUrlLabel->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition+=90, GetClientAreaBounds().width - UI_X_MARGIN_RIGHT, UI_LABEL_HEIGHT), L"Url"); + pUrlLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pUrlLabel->SetBackgroundColor(color); + pScrollPanel->AddControl(*pUrlLabel); + + __pUrlLabelData = new (std::nothrow) Label(); + __pUrlLabelData->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition+=60, GetClientAreaBounds().width - UI_X_MARGIN_RIGHT, UI_HEIGHT), L""); + __pUrlLabelData->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + __pUrlLabelData->SetTextConfig(50, LABEL_TEXT_STYLE_NORMAL); + pScrollPanel->AddControl(*__pUrlLabelData); + + Label* pOrganizationLabel = new (std::nothrow) Label(); + pOrganizationLabel->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition+=90, GetClientAreaBounds().width - UI_X_MARGIN_RIGHT, UI_LABEL_HEIGHT), L"Company"); + pOrganizationLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pOrganizationLabel->SetBackgroundColor(color); + pScrollPanel->AddControl(*pOrganizationLabel); + + __pOrganizationLabelData = new (std::nothrow) Label(); + __pOrganizationLabelData->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition+=60, GetClientAreaBounds().width - UI_X_MARGIN_RIGHT, UI_HEIGHT), L""); + __pOrganizationLabelData->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + __pOrganizationLabelData->SetTextConfig(50, LABEL_TEXT_STYLE_NORMAL); + pScrollPanel->AddControl(*__pOrganizationLabelData); + + Label* pEventLabel = new (std::nothrow) Label(); + pEventLabel->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition+=90, GetClientAreaBounds().width - UI_X_MARGIN_RIGHT, UI_LABEL_HEIGHT), L"Birthday"); + pEventLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pEventLabel->SetBackgroundColor(color); + pScrollPanel->AddControl(*pEventLabel); + + __pEventLabelData = new (std::nothrow) Label(); + __pEventLabelData->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition+=60, GetClientAreaBounds().width - UI_X_MARGIN_RIGHT, UI_HEIGHT), L""); + __pEventLabelData->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + __pEventLabelData->SetTextConfig(50, LABEL_TEXT_STYLE_NORMAL); + pScrollPanel->AddControl(*__pEventLabelData); + + Label* pNoteLabel = new (std::nothrow) Label(); + pNoteLabel->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition+=90, GetClientAreaBounds().width - UI_X_MARGIN_RIGHT, UI_LABEL_HEIGHT), L"Note"); + pNoteLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pNoteLabel->SetBackgroundColor(color); + pScrollPanel->AddControl(*pNoteLabel); + + __pNoteLabelData = new (std::nothrow) Label(); + __pNoteLabelData->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition+=60, GetClientAreaBounds().width - UI_X_MARGIN_RIGHT, UI_HEIGHT), L""); + __pNoteLabelData->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + __pNoteLabelData->SetTextConfig(50, LABEL_TEXT_STYLE_NORMAL); + pScrollPanel->AddControl(*__pNoteLabelData); + + AddControl(*pScrollPanel); + SetFormBackEventListener(this); + + return r; +} + +result +DetailViewForm::OnTerminating(void) +{ + result r = E_SUCCESS; + + if (__pPerson != null) + { + delete __pPerson; + __pPerson = null; + } + + return r; +} + +void +DetailViewForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + + result r = E_SUCCESS; + + switch(actionId) + { + case ID_FOOTER_EDIT: + { + ArrayList* pPersonIdList = new (std::nothrow) ArrayList(); + AppAssert(pPersonIdList); + + r = pPersonIdList->Construct(); + TryReturnVoid(!IsFailed(r), "Failed to construct person list (%s)", GetErrorMessage(r)); + + r = pPersonIdList->Add(*new Integer(__pPerson->GetId())); + TryReturnVoid(!IsFailed(r), "Failed to get add contact record id (%s).", GetErrorMessage(r)); + + pSceneManager->GoForward(ForwardSceneTransition(SCENE_EDIT_CONTACT_FORM), pPersonIdList); + + break; + } + + case ID_FOOTER_DELETE: + { + MessageBox messageBox; + int doModal; + messageBox.Construct(L"Warning", "Do you really want to delete?", MSGBOX_STYLE_YESNO, 0); + messageBox.ShowAndWait(doModal); + + if (doModal == MSGBOX_RESULT_YES) + { + r = RemovePerson(); + TryReturnVoid(!IsFailed(r), "Failed to remove the person (%s).", GetErrorMessage(r)); + pSceneManager->GoBackward(BackwardSceneTransition()); + } + + break; + } + case ID_HEADER_FAVORITE_BUTTON: + r = ChangeFavoriteStatus(); + TryReturnVoid(!IsFailed(r), "Failed to change person's favorite status (%s).", GetErrorMessage(r)); + break; + + default: + break; + } +} + +void +DetailViewForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + pSceneManager->GoBackward(BackwardSceneTransition()); +} + +void +DetailViewForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, + const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs) +{ + if (pArgs) + { + result r = E_SUCCESS; + + Integer* pRecordId = static_cast (pArgs->GetAt(0)); + AppAssert(pRecordId); + + PersonId personId = pRecordId->ToInt(); + pArgs->RemoveAll(true); + delete pArgs; + + if (__pPerson) + { + delete __pPerson; + __pPerson = null; + } + + __pPerson = __pAddressbookMgr->GetPersonN(personId); + r = GetLastResult(); + TryReturnVoid(!IsFailed(r), "Failed to get the Person (%s).", GetErrorMessage(r)); + + GetContactsDetail(); + } +} + +void +DetailViewForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, + const Tizen::Ui::Scenes::SceneId& nextSceneId) +{ +} + +result +DetailViewForm::RemovePerson(void) +{ + result r = E_SUCCESS; + + r = __pAddressbookMgr->RemovePerson(__pPerson->GetId()); + + if (IsFailed(r)) + { + MessageBox messageBox; + messageBox.Construct(L"Error", "Failed to remove person", MSGBOX_STYLE_OK, 0); + int doModal; + messageBox.ShowAndWait(doModal); + } + + TryReturn(!IsFailed(r), r, "Failed to remove person (%s).", GetErrorMessage(r)); + + return r; +} + +result +DetailViewForm::GetContactsDetail(void) +{ + result r = E_SUCCESS; + + Header* pHeader = GetHeader(); + AppAssert(pHeader); + pHeader->SetTitleText(__pPerson->GetDisplayName()); + + if (__pPerson->IsFavorite() == true) + { + pHeader->SetButtonTextColor(BUTTON_ITEM_STATUS_NORMAL, __favoriteTextColor); + } + + PhoneNumber phoneNumber = __pPerson->GetPrimaryPhoneNumber(); + r = GetLastResult(); + TryReturn(!IsFailed(r), r, "Failed to get primary phone number (%s).", GetErrorMessage(r)); + __pPhoneNumberLabelData->SetText(phoneNumber.GetPhoneNumber()); + + Email email = __pPerson->GetPrimaryEmail(); + r = GetLastResult(); + TryReturn(!IsFailed(r), r, "Failed to get primary email address (%s)", GetErrorMessage(r)); + __pEmailLabelData->SetText(email.GetEmail()); + + IList* pContactList = __pAddressbookMgr->GetContactsByPersonN(__pPerson->GetId()); + r = GetLastResult(); + TryReturn(!IsFailed(r), r, "Failed to get contacts (%s)", GetErrorMessage(r)); + + bool hasUrl = false; + bool hasOrganization = false; + bool hasEvent = false; + bool hasNote = false; + + IList* pMultiPropertyList = null; + Contact* pContact = null; + + IEnumerator* pContactListEnum = pContactList->GetEnumeratorN(); + + while (pContactListEnum->MoveNext() == E_SUCCESS) + { + pContact = static_cast (pContactListEnum->GetCurrent()); + + if (hasUrl == false) + { + pMultiPropertyList = pContact->GetValuesN(CONTACT_MPROPERTY_ID_URLS); + + if (pMultiPropertyList && pMultiPropertyList->GetCount() > 0) + { + Url* pUrl = static_cast (pMultiPropertyList->GetAt(0)); + __pUrlLabelData->SetText(pUrl->GetUrl()); + hasUrl = true; + } + + pMultiPropertyList->RemoveAll(true); + delete pMultiPropertyList; + } + + if (hasOrganization == false) + { + pMultiPropertyList = pContact->GetValuesN(CONTACT_MPROPERTY_ID_ORGANIZATIONS); + + if (pMultiPropertyList && pMultiPropertyList->GetCount() > 0) + { + Organization* pOrganization = static_cast (pMultiPropertyList->GetAt(0)); + + if (pOrganization->GetName().IsEmpty() == false) + { + __pOrganizationLabelData->SetText(pOrganization->GetName()); + hasOrganization = true; + } + } + + pMultiPropertyList->RemoveAll(true); + delete pMultiPropertyList; + } + + if (hasEvent == false) + { + pMultiPropertyList = pContact->GetValuesN(CONTACT_MPROPERTY_ID_EVENTS); + IEnumerator* pEventEnum = pMultiPropertyList->GetEnumeratorN(); + + while (pEventEnum->MoveNext() == E_SUCCESS) + { + ContactEvent* pContactEvent = static_cast (pEventEnum->GetCurrent()); + + if (pContactEvent->GetType() == CONTACT_EVENT_TYPE_BIRTHDAY) + { + DateTime dateTime = pContactEvent->GetDate(); + String event = dateTime.ToString(); + event.SetLength(10); + __pEventLabelData->SetTextConfig(50, LABEL_TEXT_STYLE_NORMAL); + __pEventLabelData->SetText(event); + hasEvent = true; + break; + } + } + + pMultiPropertyList->RemoveAll(true); + delete pMultiPropertyList; + delete pEventEnum; + } + + if (hasNote == false) + { + pMultiPropertyList = pContact->GetValuesN(CONTACT_MPROPERTY_ID_NOTES); + + if (pMultiPropertyList && pMultiPropertyList->GetCount() > 0) + { + String* pNote = static_cast (pMultiPropertyList->GetAt(0)); + __pNoteLabelData->SetText(*pNote); + hasNote = true; + } + + pMultiPropertyList->RemoveAll(true); + delete pMultiPropertyList; + } + } + + pContactList->RemoveAll(true); + delete pContactList; + delete pContactListEnum; + + return r; +} + +result +DetailViewForm::ChangeFavoriteStatus(void) +{ + result r = E_SUCCESS; + Header* pHeader = GetHeader(); + + if (__pPerson->IsFavorite() == true) + { + r = __pPerson->SetAsFavorite(false); + TryReturn(!IsFailed(r), r, "Failed to set person as favorite. (%s)", GetErrorMessage(r)); + + pHeader->SetButtonTextColor(BUTTON_ITEM_STATUS_NORMAL, __normalTextColor); + } + + else + { + r = __pPerson->SetAsFavorite(true); + TryReturn(!IsFailed(r), r, "Failed to set person as favorite. (%s)", GetErrorMessage(r)); + + pHeader->SetButtonTextColor(BUTTON_ITEM_STATUS_NORMAL, __favoriteTextColor); + } + + pHeader->Invalidate(true); + + return r; +} diff --git a/project/src/EditContactForm.cpp b/project/src/EditContactForm.cpp new file mode 100644 index 0000000..6b4c9c5 --- /dev/null +++ b/project/src/EditContactForm.cpp @@ -0,0 +1,719 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 "EditContactForm.h" +#include "SceneRegister.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +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::Social; + +EditContactForm::EditContactForm(void) + : __pContactList(null) + , __pFirstNameEditField(null) + , __pLastNameEditField(null) + , __pPhoneNumberEditField(null) + , __pEmailEditField(null) + , __pUrlEditField(null) + , __pOrganizationEditField(null) + , __pNoteEditField(null) + , __pEventEditDate(null) + , __pAddressbookMgr(null) + , __personId(0) + , __selectedTabId(0) + , __headerTabCount(0) + , __birthdayIndex(-1) + , __isBirthdayChanged(false) +{ +} + +EditContactForm::~EditContactForm(void) +{ +} + +bool +EditContactForm::Initialize(void) +{ + result r = E_SUCCESS; + + __pAddressbookMgr = AddressbookManager::GetInstance(); + r = GetLastResult(); + TryReturn(!IsFailed(r), false, "Failed to get instance of addressbook manager (%s)", GetErrorMessage(r)); + + r = Construct(L"IDF_FORM_CONTACTS"); + TryReturn(!IsFailed(r), false, "Failed to construct the form (%s).", GetErrorMessage(r)); + + return true; +} + +result +EditContactForm::OnInitializing(void) +{ + result r = E_SUCCESS; + + Header* pHeader = GetHeader(); + AppAssert(pHeader); + pHeader->SetStyle(HEADER_STYLE_TAB_WITH_TITLE); + pHeader->SetTitleText(L"EDIT CONTACT"); + pHeader->AddActionEventListener(*this); + + Footer* pFooter = GetFooter(); + AppAssert(pFooter); + pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT); + + FooterItem footerSave; + footerSave.Construct(ID_FOOTER_SAVE); + footerSave.SetText(L"Save"); + pFooter->AddItem(footerSave); + pFooter->SetBackButton(); + pFooter->AddActionEventListener(*this); + + unsigned int backgroundColor = 0xABABAB; + Color color(backgroundColor, false); + + static const int UI_X_POSITION_LEFT = 20; + static const int UI_HEIGHT = 112; + static const int UI_LABEL_HEIGHT = 50; + static const int UI_X_RIGHT_MARGIN = 40; + + int yPosition = 0; + + ScrollPanel* pScrollPanel = new (std::nothrow) ScrollPanel(); + pScrollPanel->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height)); + + Label* pNameLabel = new (std::nothrow) Label(); + pNameLabel->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 10, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN , UI_LABEL_HEIGHT), L"Name"); + pNameLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pNameLabel->SetBackgroundColor(color); + pScrollPanel->AddControl(*pNameLabel); + + __pFirstNameEditField = new (std::nothrow) EditField(); + __pFirstNameEditField->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 60, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN, UI_HEIGHT), EDIT_FIELD_STYLE_NORMAL); + __pFirstNameEditField->SetGuideText(L"First Name"); + pScrollPanel->AddControl(*__pFirstNameEditField); + + __pLastNameEditField = new (std::nothrow) EditField(); + __pLastNameEditField->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 122, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN, UI_HEIGHT), EDIT_FIELD_STYLE_NORMAL); + __pLastNameEditField->SetGuideText(L"Last Name"); + pScrollPanel->AddControl(*__pLastNameEditField); + + Label* pPhoneNumberLabel = new (std::nothrow) Label(); + pPhoneNumberLabel->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 122, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN , UI_LABEL_HEIGHT), L"Phone Number"); + pPhoneNumberLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pPhoneNumberLabel->SetBackgroundColor(color); + pScrollPanel->AddControl(*pPhoneNumberLabel); + + __pPhoneNumberEditField = new (std::nothrow) EditField(); + __pPhoneNumberEditField->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 60, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN, UI_HEIGHT), EDIT_FIELD_STYLE_PHONE_NUMBER); + __pPhoneNumberEditField->SetGuideText(L"Phone Number"); + pScrollPanel->AddControl(*__pPhoneNumberEditField); + + Label* pEmailLabel = new (std::nothrow) Label(); + pEmailLabel->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 122, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN , UI_LABEL_HEIGHT), L"Email"); + pEmailLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pEmailLabel->SetBackgroundColor(color); + pScrollPanel->AddControl(*pEmailLabel); + + __pEmailEditField = new (std::nothrow) EditField(); + __pEmailEditField->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 60, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN, UI_HEIGHT), EDIT_FIELD_STYLE_EMAIL); + __pEmailEditField->SetGuideText(L"Email"); + pScrollPanel->AddControl(*__pEmailEditField); + + Label* pUrlLabel = new (std::nothrow) Label(); + pUrlLabel->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 122, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN , UI_LABEL_HEIGHT), L"Url"); + pUrlLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pUrlLabel->SetBackgroundColor(color); + pScrollPanel->AddControl(*pUrlLabel); + + __pUrlEditField = new (std::nothrow) EditField(); + __pUrlEditField->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 60, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN, UI_HEIGHT), EDIT_FIELD_STYLE_URL); + __pUrlEditField->SetGuideText(L"Url"); + pScrollPanel->AddControl(*__pUrlEditField); + + Label* pOrganizationLabel = new (std::nothrow) Label(); + pOrganizationLabel->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 122, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN , UI_LABEL_HEIGHT), L"Company"); + pOrganizationLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pOrganizationLabel->SetBackgroundColor(color); + pScrollPanel->AddControl(*pOrganizationLabel); + + __pOrganizationEditField = new (std::nothrow) EditField(); + __pOrganizationEditField->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 60, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN, UI_HEIGHT), EDIT_FIELD_STYLE_URL); + __pOrganizationEditField->SetGuideText(L"Organization"); + pScrollPanel->AddControl(*__pOrganizationEditField); + + Label* pEventLabel = new (std::nothrow) Label(); + pEventLabel->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 122, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN , UI_LABEL_HEIGHT), L"Birthday"); + pEventLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pEventLabel->SetBackgroundColor(color); + pScrollPanel->AddControl(*pEventLabel); + + __pEventEditDate = new (std::nothrow) EditDate(); + __pEventEditDate->Construct(Point(UI_X_POSITION_LEFT, yPosition + 32)); + __pEventEditDate->SetCurrentDate(); + __pEventEditDate->AddDateChangeEventListener(*this); + pScrollPanel->AddControl(*__pEventEditDate); + + Label* pNoteLabel = new (std::nothrow) Label(); + pNoteLabel->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 122, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN , UI_LABEL_HEIGHT), L"Note"); + pNoteLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pNoteLabel->SetBackgroundColor(color); + pScrollPanel->AddControl(*pNoteLabel); + + __pNoteEditField = new (std::nothrow) EditField(); + __pNoteEditField->Construct(Rectangle(UI_X_POSITION_LEFT, yPosition += 60, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN, UI_HEIGHT), EDIT_FIELD_STYLE_URL); + __pNoteEditField->SetGuideText(L"Note"); + pScrollPanel->AddControl(*__pNoteEditField); + + AddControl(*pScrollPanel); + SetFormBackEventListener(this); + + return r; +} + +result +EditContactForm::OnTerminating(void) +{ + result r = E_SUCCESS; + + return r; +} + +void +EditContactForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) +{ + if (ID_HEADER_TAB_ID_START <= actionId && actionId < __headerTabCount) + { + + if (actionId == __selectedTabId) + { + return; + } + + MessageBox messageBox; + messageBox.Construct("Caution", "Added or edited data will be lost.", MSGBOX_STYLE_OK, 0); + int modalResult; + messageBox.ShowAndWait(modalResult); + + __selectedTabId = actionId; + UpdateTabContent(__selectedTabId); + Invalidate(true); + + return; + } + + switch(actionId) + { + case ID_FOOTER_SAVE: + { + SaveContact(__selectedTabId); + + ArrayList* pPersonIdList = new (std::nothrow) ArrayList(); + AppAssert(pPersonIdList); + result r = E_SUCCESS; + r = pPersonIdList->Construct(); + TryReturnVoid(!IsFailed(r), "Failed to construct person list (%s).", GetErrorMessage(r)); + r = pPersonIdList->Add(*new (std::nothrow) Integer(__personId)); + TryReturnVoid(!IsFailed(r), "Failed to get add contact record id (%s).", GetErrorMessage(r)); + + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + pSceneManager->GoBackward(BackwardSceneTransition(SCENE_DETAIL_VIEW_FORM), pPersonIdList); + + break; + } + + default: + break; + } +} + +void +EditContactForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source) +{ + result r = E_SUCCESS; + + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + + ArrayList* pPersonIdList = new (std::nothrow) ArrayList(); + AppAssert(pPersonIdList); + + r = pPersonIdList->Construct(); + TryReturnVoid(!IsFailed(r), "Failed to construct person id list"); + + r = pPersonIdList->Add(*new (std::nothrow) Integer(__personId)); + TryReturnVoid(!IsFailed(r), "Failed to get add contact record id (%s).", GetErrorMessage(r)); + + pSceneManager->GoBackward(BackwardSceneTransition(SCENE_DETAIL_VIEW_FORM), pPersonIdList); +} + +void +EditContactForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, + const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs) +{ + if (pArgs) + { + Integer* pRecordId = static_cast (pArgs->GetAt(0)); + AppAssert(pRecordId); + + __personId = pRecordId->ToInt(); + pArgs->RemoveAll(true); + delete pArgs; + + __pContactList = GetContactList(__personId); + CreateHeaderTabs(); + __selectedTabId = ID_HEADER_TAB_ID_START; + UpdateTabContent(__selectedTabId); + } +} + +void +EditContactForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, + const Tizen::Ui::Scenes::SceneId& nextSceneId) +{ +} + +void +EditContactForm::OnDateChanged(const Control& source, int year, int month, int day) +{ + __isBirthdayChanged = true; +} + +void +EditContactForm::OnDateChangeCanceled(const Control& source) +{ +} + +void +EditContactForm::CreateHeaderTabs(void) +{ + __headerTabCount = 0; + + if (__pContactList && __pContactList->GetCount() > 0) + { + Header* pHeader = GetHeader(); + + IEnumerator* pContactListEnum = __pContactList->GetEnumeratorN(); + Contact* pContact = null; + AddressbookId addressbookId; + + int headerTabId = 0; + + while (pContactListEnum->MoveNext() == E_SUCCESS) + { + pContact = static_cast (pContactListEnum->GetCurrent()); + AppAssert(pContact); + addressbookId = pContact->GetAddressbookId(); + + HeaderItem item; + item.Construct(headerTabId); + item.SetText(GetAddressbookName(addressbookId)); + pHeader->AddItem(item); + + headerTabId++; + } + + __headerTabCount = headerTabId; + delete pContactListEnum; + } +} + +void +EditContactForm::UpdateTabContent(int index) +{ + Contact* pContact = GetContactAt(index); + AppAssert(pContact); + + pContact->GetValue(CONTACT_PROPERTY_ID_FIRST_NAME, __firstName); + __pFirstNameEditField->SetText(__firstName); + + pContact->GetValue(CONTACT_PROPERTY_ID_LAST_NAME, __lastName); + __pLastNameEditField->SetText(__lastName); + + IList* pMultiPropertyList = null; + __phoneNumber.Clear(); + pMultiPropertyList = pContact->GetValuesN(CONTACT_MPROPERTY_ID_PHONE_NUMBERS); + + if (pMultiPropertyList->GetCount() > 0) + { + PhoneNumber* pPhoneNumber = static_cast (pMultiPropertyList->GetAt(0)); + + if (pPhoneNumber != null) + { + __phoneNumber = pPhoneNumber->GetPhoneNumber(); + } + } + + __pPhoneNumberEditField->SetText(__phoneNumber); + + pMultiPropertyList->RemoveAll(true); + delete pMultiPropertyList; + pMultiPropertyList = null; + + __email.Clear(); + pMultiPropertyList = pContact->GetValuesN(CONTACT_MPROPERTY_ID_EMAILS); + + if (pMultiPropertyList->GetCount() > 0) + { + Email* pEmail = static_cast (pMultiPropertyList->GetAt(0)); + + if (pEmail != null) + { + __email = pEmail->GetEmail(); + } + } + + __pEmailEditField->SetText(__email); + + pMultiPropertyList->RemoveAll(true); + delete pMultiPropertyList; + pMultiPropertyList = null; + + __url.Clear(); + pMultiPropertyList = pContact->GetValuesN(CONTACT_MPROPERTY_ID_URLS); + + if (pMultiPropertyList->GetCount() > 0) + { + Url* pUrl = static_cast (pMultiPropertyList->GetAt(0)); + + if (pUrl != null) + { + __url = pUrl->GetUrl(); + } + } + + __pUrlEditField->SetText(__url); + + pMultiPropertyList->RemoveAll(true); + delete pMultiPropertyList; + pMultiPropertyList = null; + + __organization.Clear(); + pMultiPropertyList = pContact->GetValuesN(CONTACT_MPROPERTY_ID_ORGANIZATIONS); + + if (pMultiPropertyList->GetCount() > 0) + { + Organization* pOrganization = static_cast (pMultiPropertyList->GetAt(0)); + + if (pOrganization != null) + { + __organization = pOrganization->GetName(); + } + } + + __pOrganizationEditField->SetText(__organization); + + pMultiPropertyList->RemoveAll(true); + delete pMultiPropertyList; + pMultiPropertyList = null; + + DateTime dateTime = __pEventEditDate->GetDate(); + __event.SetValue(dateTime); + pMultiPropertyList = pContact->GetValuesN(CONTACT_MPROPERTY_ID_EVENTS); + + if (pMultiPropertyList->GetCount() > 0) + { + int index = 0; + __birthdayIndex = -1; + __isBirthdayChanged = false; + + ContactEvent* pContactEvent = null; + IEnumerator* pMultiPropertyListEnum = pMultiPropertyList->GetEnumeratorN(); + + while (pMultiPropertyListEnum->MoveNext() == E_SUCCESS) + { + pContactEvent = static_cast (pMultiPropertyListEnum->GetCurrent()); + + if (pContactEvent->GetType() == CONTACT_EVENT_TYPE_BIRTHDAY) + { + __event = pContactEvent->GetDate(); + __birthdayIndex = index; + + break; + } + + index++; + } + + delete pMultiPropertyListEnum; + } + + __pEventEditDate->SetDate(__event); + + pMultiPropertyList->RemoveAll(true); + delete pMultiPropertyList; + pMultiPropertyList = null; + + __note.Clear(); + pMultiPropertyList = pContact->GetValuesN(CONTACT_MPROPERTY_ID_NOTES); + + if (pMultiPropertyList->GetCount() > 0) + { + String* pNote = static_cast (pMultiPropertyList->GetAt(0)); + + if (pNote != null) + { + __note = *pNote; + } + } + + __pNoteEditField->SetText(__note); + + pMultiPropertyList->RemoveAll(true); + delete pMultiPropertyList; + pMultiPropertyList = null; +} + +result +EditContactForm::SaveContact(int index) +{ + result r = E_SUCCESS; + + Contact* pContact = GetContactAt(index); + AppAssert(pContact); + + __firstName = __pFirstNameEditField->GetText(); + __lastName = __pLastNameEditField->GetText(); + + if (__firstName.IsEmpty() && __lastName.IsEmpty()) + { + MessageBox messageBox; + messageBox.Construct(L"Info", "Enter the first name and last name", MSGBOX_STYLE_OK, 0); + int doModal; + messageBox.ShowAndWait(doModal); + + return E_FAILURE; + } + + pContact->SetValue(CONTACT_PROPERTY_ID_FIRST_NAME, __firstName); + pContact->SetValue(CONTACT_PROPERTY_ID_LAST_NAME, __lastName); + + String previousValue = __phoneNumber; + __phoneNumber = __pPhoneNumberEditField->GetText(); + + if (!__phoneNumber.IsEmpty()) + { + PhoneNumber phoneNumber(PHONENUMBER_TYPE_HOME, __phoneNumber); + + if (!previousValue.IsEmpty()) + { + pContact->SetPhoneNumberAt(0, phoneNumber); + } + + else + { + pContact->AddPhoneNumber(phoneNumber); + } + } + + else + { + if (!previousValue.IsEmpty()) + { + pContact->RemoveAt(CONTACT_MPROPERTY_ID_PHONE_NUMBERS, 0); + } + } + + previousValue = __email; + __email = __pEmailEditField->GetText(); + + if (!__email.IsEmpty()) + { + Email email(EMAIL_TYPE_PERSONAL, __email); + + if (!previousValue.IsEmpty()) + { + pContact->SetEmailAt(0, email); + } + + else + { + pContact->AddEmail(email); + } + } + + else + { + if (!previousValue.IsEmpty()) + { + pContact->RemoveAt(CONTACT_MPROPERTY_ID_EMAILS, 0); + } + } + + previousValue = __url; + __url = __pUrlEditField->GetText(); + + if (!__url.IsEmpty()) + { + Url url(URL_TYPE_PERSONAL, __url); + + if (!previousValue.IsEmpty()) + { + pContact->SetUrlAt(0, url); + } + + else + { + pContact->AddUrl(url); + } + } + + else + { + if (!previousValue.IsEmpty()) + { + pContact->RemoveAt(CONTACT_MPROPERTY_ID_URLS, 0); + } + } + + previousValue = __organization; + __organization = __pOrganizationEditField->GetText(); + + if (!__organization.IsEmpty()) + { + Organization organization; + organization.SetName(__organization); + + if (!previousValue.IsEmpty()) + { + pContact->SetOrganizationAt(0, organization); + } + + else + { + pContact->AddOrganization(organization); + } + } + + else + { + if (!previousValue.IsEmpty()) + { + pContact->RemoveAt(CONTACT_MPROPERTY_ID_ORGANIZATIONS, 0); + } + } + + if (__isBirthdayChanged == true) + { + __event = __pEventEditDate->GetDate(); + ContactEvent contactEvent; + contactEvent.SetType(CONTACT_EVENT_TYPE_BIRTHDAY); + contactEvent.SetDate(__event); + + if (__birthdayIndex >= 0) + { + pContact->SetEventAt(__birthdayIndex, contactEvent); + } + + else + { + pContact->AddEvent(contactEvent); + } + } + + previousValue = __note; + __note = __pNoteEditField->GetText(); + + if (!__note.IsEmpty()) + { + if (!previousValue.IsEmpty()) + { + pContact->SetNoteAt(0, __note); + } + + else + { + pContact->AddNote(__note); + } + } + + else + { + if (!previousValue.IsEmpty()) + { + pContact->RemoveAt(CONTACT_MPROPERTY_ID_NOTES, 0); + } + } + + r = __pAddressbookMgr->UpdateContact(*pContact); + + if(IsFailed(r)) + { + MessageBox messageBox; + messageBox.Construct(L"Error", "Failed to update contact", MSGBOX_STYLE_OK, 0); + int doModal; + messageBox.ShowAndWait(doModal); + } + + TryReturn(!IsFailed(r), r, "Failed to update Contact (%s)", GetErrorMessage(r)); + + return r; +} + +IList* +EditContactForm::GetContactList(PersonId personId) +{ + result r = E_SUCCESS; + + IList* pContactList = __pAddressbookMgr->GetContactsByPersonN(personId); + r = GetLastResult(); + TryReturn(!IsFailed(r), null, "Failed to get contacts of the person (%s)", GetErrorMessage(r)); + + return pContactList; +} + +Contact* +EditContactForm::GetContactAt(int index) +{ + TryReturn(__pContactList && ((index >= 0) && (__pContactList->GetCount() > index)), null, "Contact list is invalid."); + + Contact* pContact = static_cast (__pContactList->GetAt(index)); + + return pContact; +} + +String +EditContactForm::GetAddressbookName(AddressbookId addressbookId) +{ + result r = E_SUCCESS; + + Addressbook* pAddressbook = __pAddressbookMgr->GetAddressbookN(addressbookId); + r = GetLastResult(); + TryReturn(!IsFailed(r), null, "Failed to get an addressbook (%s)", GetErrorMessage(r)); + + String delim(L"/"); + StringTokenizer tokenizer(pAddressbook->GetName(), delim); + + String name; + + while (tokenizer.HasMoreTokens()) + { + tokenizer.GetNextToken(name); + } + + delete pAddressbook; + + return name; +} diff --git a/project/src/FavoriteListForm.cpp b/project/src/FavoriteListForm.cpp new file mode 100644 index 0000000..d88a02a --- /dev/null +++ b/project/src/FavoriteListForm.cpp @@ -0,0 +1,234 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 "FavoriteListForm.h" +#include "SceneRegister.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Social; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +FavoriteListForm::FavoriteListForm(void) + : __pFavoriteList(null) + , __pListView(null) +{ +} + +FavoriteListForm::~FavoriteListForm(void) +{ +} + +bool +FavoriteListForm::Initialize(void) +{ + result r = E_SUCCESS; + + r = Construct(L"IDF_FORM_CONTACTS"); + TryReturn(!IsFailed(r), false, "Failed to construct the form (%s).", GetErrorMessage(r)); + + return true; +} + +result +FavoriteListForm::OnInitializing(void) +{ + result r = E_SUCCESS; + + Header* pHeader = GetHeader(); + AppAssert(pHeader); + + pHeader->SetStyle(HEADER_STYLE_TITLE); + pHeader->SetTitleText(L"FAVORITES"); + + Footer* pFooter = GetFooter(); + AppAssert(pFooter); + + pFooter->SetBackButton(); + + static int UI_X_POSITION_LEFT = 5; + static int UI_Y_POSITION = 0; + + ScrollPanel* pScrollPanel = new (std::nothrow) ScrollPanel(); + pScrollPanel->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height)); + + __pListView = new (std::nothrow) ListView(); + __pListView->Construct(Rectangle(UI_X_POSITION_LEFT, UI_Y_POSITION, GetClientAreaBounds().width, GetClientAreaBounds().height)); + __pListView->SetItemProvider(*this); + __pListView->AddListViewItemEventListener(*this); + pScrollPanel->AddControl(*__pListView); + + AddControl(*pScrollPanel); + SetFormBackEventListener(this); + + return r; +} + +result +FavoriteListForm::OnTerminating(void) +{ + result r = E_SUCCESS; + + if (__pFavoriteList != null) + { + __pFavoriteList->RemoveAll(true); + delete __pFavoriteList; + } + + return r; +} + +void +FavoriteListForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + pSceneManager->GoBackward(BackwardSceneTransition(SCENE_MAIN_FORM)); +} + +bool +FavoriteListForm::DeleteItem(int itemIndex, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth) +{ + delete pItem; + pItem = null; + + return true; +} + +int +FavoriteListForm::GetItemCount(void) +{ + if (__pFavoriteList != null) + { + return __pFavoriteList->GetCount(); + } + + return 0; +} + +void +FavoriteListForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status) +{ + if (status == LIST_ITEM_STATUS_SELECTED) + { + result r = E_SUCCESS; + + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + + Person* pPerson = static_cast (__pFavoriteList->GetAt(index)); + TryReturnVoid(pPerson, "Failed to get person."); + + ArrayList* pPersonList = new (std::nothrow) ArrayList(); + AppAssert(pPersonList); + + r = pPersonList->Construct(); + TryReturnVoid(!IsFailed(r), "Failed to construct person list (%s)", GetErrorMessage(r)); + + r = pPersonList->Add(*new Integer(pPerson->GetId())); + TryReturnVoid(!IsFailed(r), "Failed to get add person id (%s).", GetErrorMessage(r)); + + pSceneManager->GoForward(ForwardSceneTransition(SCENE_DETAIL_VIEW_FORM), pPersonList); + } +} + +void +FavoriteListForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction) +{ +} + +void +FavoriteListForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state) +{ +} + +void +FavoriteListForm::OnItemReordered(Tizen::Ui::Controls::ListView& view, int oldIndex, int newIndex) +{ +} + +Tizen::Ui::Controls::ListItemBase* +FavoriteListForm::CreateItem(int index, int itemWidth) +{ + String personName = null; + + SimpleItem* pItem = new (std::nothrow) SimpleItem(); + AppAssert(pItem); + + pItem->Construct(Dimension(itemWidth, 112), LIST_ANNEX_STYLE_NORMAL); + + Person* pPerson = static_cast (__pFavoriteList->GetAt(index)); + TryReturn(pPerson, null, "Failed to get person"); + + personName = pPerson->GetDisplayName(); + + if (personName.IsEmpty()) + { + personName = L"(No name)"; + } + + pItem->SetElement(personName); + + return pItem; +} + +void +FavoriteListForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, + const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs) +{ + result r = E_SUCCESS; + + r = GetFavoriteList(); + TryReturnVoid(!IsFailed(r), "Failed to get the person list (%s).", GetErrorMessage(r)); + + __pListView->UpdateList(); +} + +void +FavoriteListForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, + const Tizen::Ui::Scenes::SceneId& nextSceneId) +{ +} + +result +FavoriteListForm::GetFavoriteList(void) +{ + result r = E_SUCCESS; + + AddressbookManager* pAddressbookMgr = AddressbookManager::GetInstance(); + IList* pFavoriteList = pAddressbookMgr->GetFavoritePersonsN(); + + r = GetLastResult(); + TryReturn(!IsFailed(r), r, "Failed to get the person list (%s).", GetErrorMessage(r)); + + if (__pFavoriteList != null) + { + __pFavoriteList->RemoveAll(true); + delete __pFavoriteList; + } + + __pFavoriteList = pFavoriteList; + + return r; +} diff --git a/project/src/MainForm.cpp b/project/src/MainForm.cpp new file mode 100644 index 0000000..39f6976 --- /dev/null +++ b/project/src/MainForm.cpp @@ -0,0 +1,286 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 "MainForm.h" +#include "SceneRegister.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Social; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +MainForm::MainForm(void) + : __pPersonList(null) + , __pListView(null) + , __pContextMenu(null) +{ +} + +MainForm::~MainForm(void) +{ +} + +bool +MainForm::Initialize(void) +{ + result r = E_SUCCESS; + + r = Construct(L"IDF_FORM_CONTACTS"); + TryReturn(!IsFailed(r), false, "Failed to construct the form (%s).", GetErrorMessage(r)); + + return true; +} + +result +MainForm::OnInitializing(void) +{ + result r = E_SUCCESS; + + Header* pHeader = GetHeader(); + AppAssert(pHeader); + + pHeader->SetStyle(HEADER_STYLE_TITLE); + pHeader->SetTitleText(L"CONTACTS"); + + Footer* pFooter = GetFooter(); + AppAssert(pFooter); + + ButtonItem buttonItem; + buttonItem.Construct(BUTTON_ITEM_STYLE_TEXT, ID_FOOTER_MORE); + buttonItem.SetText(L"More"); + + pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT); + pFooter->SetButton(BUTTON_POSITION_LEFT, buttonItem); + + FooterItem footerCreate; + footerCreate.Construct(ID_FOOTER_CREATE); + footerCreate.SetText(L"Create"); + pFooter->AddItem(footerCreate); + + __pContextMenu = new (std::nothrow) ContextMenu(); + __pContextMenu->Construct(Point(50, 1200), CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD); + __pContextMenu->AddItem(L"Category", ID_CONTEXT_MENU_CATEGORY); + __pContextMenu->AddItem(L"Favorite", ID_CONTEXT_MENU_FAVORITE); + __pContextMenu->AddActionEventListener(*this); + + pFooter->SetBackButton (); + pFooter->AddActionEventListener(*this); + + static int UI_X_POSITION_LEFT = 0; + static int UI_Y_POSITION = 0; + static int UI_X_RIGHT_MARGIN = 0; + + ScrollPanel* pScrollPanel = new (std::nothrow) ScrollPanel(); + pScrollPanel->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height)); + + __pListView = new (std::nothrow) ListView(); + __pListView->Construct(Rectangle(UI_X_POSITION_LEFT, UI_Y_POSITION, GetClientAreaBounds().width - UI_X_RIGHT_MARGIN, GetClientAreaBounds().height)); + __pListView->SetItemProvider(*this); + __pListView->AddListViewItemEventListener(*this); + pScrollPanel->AddControl(*__pListView); + + AddControl(*pScrollPanel); + SetFormBackEventListener(this); + + return r; +} + +result +MainForm::OnTerminating(void) +{ + result r = E_SUCCESS; + + if (__pPersonList != null) + { + __pPersonList->RemoveAll(true); + delete __pPersonList; + } + + return r; +} + +void +MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + + switch(actionId) + { + case ID_FOOTER_CREATE: + pSceneManager->GoForward(ForwardSceneTransition(SCENE_CREATE_CONTACT_FORM)); + break; + + case ID_CONTEXT_MENU_CATEGORY: + pSceneManager->GoForward(ForwardSceneTransition(SCENE_CATEGORY_LIST_FORM)); + break; + + case ID_CONTEXT_MENU_FAVORITE: + pSceneManager->GoForward(ForwardSceneTransition(SCENE_FAVORITE_LIST_FORM)); + break; + + case ID_FOOTER_MORE: + __pContextMenu->SetShowState(true); + __pContextMenu->Show(); + break; + + default: + break; + } +} + +void +MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source) +{ + UiApp* pApp = UiApp::GetInstance(); + AppAssert(pApp); + pApp->Terminate(); +} + +bool +MainForm::DeleteItem(int itemIndex, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth) +{ + delete pItem; + pItem = null; + + return true; +} + +int +MainForm::GetItemCount(void) +{ + if (__pPersonList != null) + { + return __pPersonList->GetCount(); + } + + return 0; +} + +void +MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status) +{ + if (status == LIST_ITEM_STATUS_SELECTED) + { + result r = E_SUCCESS; + + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + + Person* pPerson = static_cast (__pPersonList->GetAt(index)); + AppAssert(pPerson); + + ArrayList* pPersonList = new (std::nothrow) ArrayList(); + AppAssert(pPersonList); + + r = pPersonList->Construct(); + TryReturnVoid(!IsFailed(r), "Failed to construct person list (%s)", GetErrorMessage(r)); + + r = pPersonList->Add(*new (std::nothrow) Integer(pPerson->GetId())); + TryReturnVoid(!IsFailed(r), "Failed to get add person id (%s).", GetErrorMessage(r)); + + pSceneManager->GoForward(ForwardSceneTransition(SCENE_DETAIL_VIEW_FORM), pPersonList); + } +} + +void +MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction) +{ +} + +void +MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state) +{ +} + +void +MainForm::OnItemReordered(Tizen::Ui::Controls::ListView& view, int oldIndex, int newIndex) +{ +} + +Tizen::Ui::Controls::ListItemBase* +MainForm::CreateItem(int index, int itemWidth) +{ + String personName; + + SimpleItem* pItem = new (std::nothrow) SimpleItem(); + AppAssert(pItem); + + pItem->Construct(Dimension(itemWidth, 112), LIST_ANNEX_STYLE_NORMAL); + + Person* pPerson = static_cast (__pPersonList->GetAt(index)); + AppAssert(pPerson); + + personName = pPerson->GetDisplayName(); + + if (personName.IsEmpty() == true) + { + personName = L"(No name)"; + } + + pItem->SetElement(personName); + + return pItem; +} + +void +MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, + const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs) +{ + result r = E_SUCCESS; + + r = GetPersonList(); + TryReturnVoid(!IsFailed(r), "Failed to get the person list (%s).", GetErrorMessage(r)); + + __pListView->UpdateList(); +} + +void +MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, + const Tizen::Ui::Scenes::SceneId& nextSceneId) +{ +} + +result +MainForm::GetPersonList(void) +{ + result r = E_SUCCESS; + + AddressbookManager* pAddressbookMgr = AddressbookManager::GetInstance(); + IList* pPersonList = pAddressbookMgr->GetAllPersonsN(); + + r = GetLastResult(); + TryReturn(!IsFailed(r), r, "Failed to get the person list (%s).", GetErrorMessage(r)); + + if (__pPersonList != null) + { + __pPersonList->RemoveAll(true); + delete __pPersonList; + } + + __pPersonList = pPersonList; + + return r; +} diff --git a/project/src/SceneRegister.cpp b/project/src/SceneRegister.cpp new file mode 100644 index 0000000..c8bef8b --- /dev/null +++ b/project/src/SceneRegister.cpp @@ -0,0 +1,64 @@ +// +// Open Service Platform +// Copyright (c) 2013 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://floralicense.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 "SceneRegister.h" +#include "ContactsFormFactory.h" + +#include + +using namespace Tizen::Ui::Scenes; + +// Definitions of extern. +const wchar_t* SCENE_MAIN_FORM = L"MainScene"; +const wchar_t* SCENE_CATEGORY_LIST_FORM = L"CategoryListScene"; +const wchar_t* SCENE_CREATE_CONTACT_FORM = L"CreateContactScene"; +const wchar_t* SCENE_DETAIL_VIEW_FORM = L"DetailViewScene"; +const wchar_t* SCENE_CATEGORY_MEMBER_FORM = L"CategoryMemberScene"; +const wchar_t* SCENE_EDIT_CONTACT_FORM = L"EditContactForm"; +const wchar_t* SCENE_CATEGORY_REMOVE_MEMBER_FORM = L"CategoryRemoveMemberScene"; +const wchar_t* SCENE_CATEGORY_ADD_MEMBER_FORM = L"CategoryAddMemberScene"; +const wchar_t* SCENE_FAVORITE_LIST_FORM = L"FavoriteListScene"; + +SceneRegister::SceneRegister(void) +{ +} + +SceneRegister::~SceneRegister(void) +{ +} + +void +SceneRegister::RegisterAllScenes(void) +{ + static const wchar_t* PANEL_BLANK = L""; + static ContactsFormFactory formFactory; + + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + + pSceneManager->RegisterFormFactory(formFactory); + + pSceneManager->RegisterScene(SCENE_MAIN_FORM, FORM_MAIN, PANEL_BLANK); + pSceneManager->RegisterScene(SCENE_CATEGORY_LIST_FORM, FORM_CATEGORY_LIST, PANEL_BLANK); + pSceneManager->RegisterScene(SCENE_CREATE_CONTACT_FORM, FORM_CREATE_CONTACT, PANEL_BLANK); + pSceneManager->RegisterScene(SCENE_DETAIL_VIEW_FORM, FORM_DETAIL_VIEW, PANEL_BLANK); + pSceneManager->RegisterScene(SCENE_CATEGORY_MEMBER_FORM, FORM_CATEGORY_MEMBER, PANEL_BLANK); + pSceneManager->RegisterScene(SCENE_EDIT_CONTACT_FORM, FORM_EDIT_CONTACT, PANEL_BLANK); + pSceneManager->RegisterScene(SCENE_CATEGORY_REMOVE_MEMBER_FORM, FORM_CATEGORY_REMOVE_MEMBER, PANEL_BLANK); + pSceneManager->RegisterScene(SCENE_CATEGORY_ADD_MEMBER_FORM, FORM_CATEGORY_ADD_MEMBER, PANEL_BLANK); + pSceneManager->RegisterScene(SCENE_FAVORITE_LIST_FORM, FORM_FAVORITE_LIST, PANEL_BLANK); +} diff --git a/sample.xml b/sample.xml new file mode 100644 index 0000000..ceae72b --- /dev/null +++ b/sample.xml @@ -0,0 +1,34 @@ + + diff --git a/screenshot.png b/screenshot.png new file mode 100755 index 0000000000000000000000000000000000000000..eded4c10884fbe2a546f11c6a57552530f89d9c3 GIT binary patch literal 5567 zcmeHL=QkUU`;A>OYtIy|y*D*Ni%_$uP^+letM-Uhd$(0pRMZ|N)ZVjbtr9zkQL#(x z?bq+0@jK`9;yL%ZukJa|dG392;|=s66hIar005xS(o{42hiL!+9^fAFzs&-Ar~eP| zybU2w09B)GTmJ~5gQ~7708o=kc5OrSkCS?8nt1~NlzsmjypMvEtN;MLv6h;uae&oc zHfg5u)W?CldeKE)S*bdoTA(8;jy1b9oQzBRw;CsnG2NMPO4fJ;p6~15eBx_;Av6@v z$K&yI9$^?MBJ*i<^LzhB=E-nqKdqILIyMQO$_Y+%&fC(+QRa9vdLmdBbh6#%e|v{f zI9q^Dr6|LLia2}<4f!);QCr`j9JM1Wo?VJ8Xh^9=a&f!0yiNJ*F5J~koEn!*aIG*y zV)vdOdIlS)2!fcHFwn#k=8u=czv%GnxkwJX9LbmUzA!dEkL&x>yCT+~(#}!6ZaM1x*<{ZKjt1Me>*ZOtEJaxZZmJ+${&DS$YIi|tgPltwF;>*hg>O3%@`ucj4 zCq^}e6gBjNJ14eFZJo9=RhF}DfwVljSxJ$R_=Im&zrCyn4rK`c*lWZ@h<2C~5SV*; zi6T;3)m0D~-}yWf)7t^cAYIWd?JNE_rIJ{BrY zWmXPRgMV14-Pj^Dl2`R2eeC}?>G1H)?ovA|FCs)@RBlb@n`uo>*Ic|43IzEiVp#(l zVbMX{vJU4eWebeIMAK^J^sv!DZ9c=A^%2TaO6t`CxV!wqLXrmeMSKE7uKOkYuAifA zH-CRM{r);Wx_1pXD_|e=kha%V(&+0SkS3c-f50ac1@D62NB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