From: Jinkun Jang Date: Tue, 12 Mar 2013 16:38:55 +0000 (+0900) Subject: Tizen 2.1 base X-Git-Tag: 2.1b_release~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e9f39e470d58cf029f4b4c3ea067cebc304df158;p=apps%2Fosp%2FHome.git Tizen 2.1 base --- diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..d64264f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,32 @@ +# Target name and PKGID +## TODO : set application name and ID +SET(this_target Home) +SET(PKGID cwkuromqdr) + +# include directory +INCLUDE_DIRECTORIES( + /usr/include/osp + inc + ) + +# Source files +FILE(GLOB ${this_target}_SOURCE_FILES src/*.cpp) + +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -DCUSTOM_TEXT_RENDERING") + +# Create executable +SET(CMAKE_EXECUTABLE_SUFFIX ".exe") +ADD_EXECUTABLE (${this_target} ${${this_target}_SOURCE_FILES}) + +# Set link libraries and link options +## TODO : add more link libraries and options +TARGET_LINK_LIBRARIES(${this_target} -L/usr/lib/osp osp-appfw osp-uifw osp-media osp-image pthread) +TARGET_LINK_LIBRARIES(${this_target} -Xlinker --allow-shlib-undefined -pthread -pie) + +# Copy info, data, res, and icons directories +INSTALL(TARGETS ${this_target} DESTINATION ../usr/apps/${PKGID}/bin) + +# Copy resource +INSTALL(FILES ${CMAKE_SOURCE_DIR}/manifest.xml DESTINATION ../usr/apps/${PKGID}/info) +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res DESTINATION ../usr/apps/${PKGID}) +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/shared DESTINATION ../usr/apps/${PKGID}) diff --git a/LICENSE.Flora b/LICENSE.Flora new file mode 100755 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 100755 index 0000000..9ec42be --- /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. \ No newline at end of file diff --git a/inc/HmApplicationUtils.h b/inc/HmApplicationUtils.h new file mode 100644 index 0000000..677bc57 --- /dev/null +++ b/inc/HmApplicationUtils.h @@ -0,0 +1,93 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmApplicationUtils.h + * @brief Keeps the declaration for Utility functions, + * declaration of the various Utility function which may be used throughout the application + */ + +#ifndef _HM_APPLICATION_UTILS_H_ +#define _HM_APPLICATION_UTILS_H_ + +#include + +/** + * @class ApplicationUtils + * @brief Keeps the static methods used throughout the application + */ +class ApplicationUtils +{ +public: + /** + * Creates an icon's bitmap to be placed in main menu + * + * @return Bitmap*, new bitmap for the application icon. + * @param[in] imagePath, the absolute path of the image file. + * @param[in] appCaption, Caption of the application. + */ + static Tizen::Graphics::Bitmap* GetApplicationIconBitmapN(const Tizen::Base::String& imagePath, const Tizen::Base::String& appCaption = L"", bool isResourceBitmap = false); + + /** + * Decodes a bitmap. + * + * @return Tizen::Graphics::Bitmap*, the decoded images. + * @param[in] Image's absolute path. + */ + static Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& imageAbsolutePath); + + /** + * Decodes a bitmap which is present in the resource. + * + * @return Tizen::Graphics::Bitmap*, the decoded images. + * @param[in] name of the resource image + */ + static Tizen::Graphics::Bitmap* GetResourceBitmapN(const Tizen::Base::String& imageName); + + /** + * fetches the string from the localized string resource. + * + * @return E_SUCCESS, for successful execution else system wide error code + * @param[in] stringId, the id of the string + * @param[out] retString, retrieved string value for the mentioned string id. + */ + static result GetStringResource(const Tizen::Base::String& stringId, Tizen::Base::String& retString); + + /** + * Shows delete confirmation message + * + * @return int, the ID of the command pressed + * @param[in] name, name of the application to be deleted + * + */ + static int ShowDeletePopup(Tizen::Base::String& applicationName); + +private: + /** + * Constructor + * Intentionally declared it in private scope as all the methods in this class are static, so creating object is not required + */ + ApplicationUtils(void); + + /** + * Destructor + * Intentionally declared it in private scope as all the methods in this class are static, so creating/destroying object is not required + */ + virtual ~ApplicationUtils(void); + +}; + +#endif //_HM_APPLICATION_UTILS_H_ diff --git a/inc/HmCustomIconListProvider.h b/inc/HmCustomIconListProvider.h new file mode 100644 index 0000000..2743704 --- /dev/null +++ b/inc/HmCustomIconListProvider.h @@ -0,0 +1,133 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmCustomIconListProvider.h + * @brief This is the class declaration for the IconListItemProviderCustom class + * This class contains the functions which are required managing the IconListView's items + */ + +#ifndef _HM_CUSTOM_ICON_LIST_ITEM_PROVIDER_H_ +#define _HM_CUSTOM_ICON_LIST_ITEM_PROVIDER_H_ + +#include +#include +#include "HmIPageControlItemProvider.h" + +/** + * @class CustomIconListProvider + * @brief Provider implementation for the HmCustomIconListViews in pagging control + */ +class CustomIconListProvider + : public Tizen::Base::Object + , public Tizen::Ui::Controls::IIconListViewItemProvider +{ +public: + /** + * Constructor + */ + CustomIconListProvider(int index); + + /** + * Destructor + */ + ~CustomIconListProvider(void); + + /** + * Gets the value of edit mode + */ + bool GetEditMode(void) const; + + /** + * Returns the item, which is getting moved currently + */ + Tizen::Ui::Controls::IconListViewItem* GetMovingItem(void) const; + + /** + * Returns the Moving Item's index + */ + int GetMovingItemIndex() const; + + /** + * Returns the item provider instance. + */ + IPageControlItemProvider* GetPageControlItemProvider(void); + + /** + * Sets the value of edit mode + */ + void SetEditMode(bool editMode); + + /** + * Sets the index of this provider object. + */ + void SetIndex(int index); + + /** + * Sets the maximum number of icons in a page. + */ + void SetMaxCountOfIcons(int iconCount); + + /** + * Sets the Moving items instance + */ + void SetMovingItem(Tizen::Ui::Controls::IconListViewItem* pMovedItem); + + /** + * Set the index of moving item, for projecting the expected project. + */ + void SetMovingItemIndex(int movedIndex); + + /** + * Sets the item Provider for this panel. + */ + void SetPageControlItemProvider(IPageControlItemProvider* pItemProvider); + + /** + * Sets the moving item to be egnored while drawing, as this is an invalid item now + */ + void SetProjectedItemInvalid(bool isInvalid); + + // from IIconListViewItemProvider + virtual Tizen::Ui::Controls::IconListViewItem* CreateItem(int index); + virtual bool DeleteItem(int index, Tizen::Ui::Controls::IconListViewItem* pItem); + virtual int GetItemCount(void); + +private: + /** + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + */ + CustomIconListProvider(const CustomIconListProvider&); + + /** + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + */ + CustomIconListProvider& operator =(const CustomIconListProvider&); + +private: + bool __editMode; // keeps the value of editmode + bool __isProjectedItemInvalid; // Is the projection item to be egnored + int __index; // keeps track of index + int __iconsPerPage; // number of icons per page + int __currentIndex; // the index of current projected item + IPageControlItemProvider* __pPageItemProvider; // item provider instance + Tizen::Ui::Controls::IconListViewItem* __pMovementItem; //The item pointer to be projected in expected position + Tizen::Graphics::Bitmap* __pOverayBitmap; //The close button bitmap + + +}; + +#endif //_HM_CUSTOM_ICON_LIST_ITEM_PROVIDER_H_ diff --git a/inc/HmCustomPageControl.h b/inc/HmCustomPageControl.h new file mode 100644 index 0000000..94b7a3b --- /dev/null +++ b/inc/HmCustomPageControl.h @@ -0,0 +1,184 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmCustomPageControl.h + * @brief Keeps declaration of the HmCustomPageControl + * declares HmCustomPageControl class, it overrides default scrolling functionality of IconListView + */ + +#ifndef _HM_CUSTOM_PAGE_CONTROL_H_ +#define _HM_CUSTOM_PAGE_CONTROL_H_ + +#include +#include + +class HomeItemInfo; +class ICustomPageControlEventListener; +class IPageControlItemProvider; + +/** + * @class CustomPageControl + * @brief This is the control which handles page by page scrolling of the application icons. + * It contains a custom IconListView and Provider for it. + */ +class CustomPageControl + : public Tizen::Ui::Controls::Panel + , public Tizen::Ui::Controls::IIconListViewItemEventListener + , public Tizen::Base::Runtime::ITimerEventListener + , public Tizen::Ui::ITouchEventListener + , public Tizen::Ui::ITouchLongPressGestureEventListener +{ +public: + /** + * The object is not fully constructed after this constructor is called. + * For full construction, the Construct() method must be called right after calling this constructor. + */ + CustomPageControl(void); + + /** + * Destructor, this destructor overrides ~Tizen::Ui::Controls::Panel + */ + virtual ~CustomPageControl(void); + + /** + * This function constructs the control properly + */ + result Construct(const Tizen::Graphics::Rectangle& controlRect, int noOfPages, int pageWidth); + + /** + * Adds a new page in the page control + */ + result AddPage(void); + + /** + * Returns currently selected page number + */ + int GetCurrentSelectedPage(void); + + /** + * Returns currently selected page number + */ + Tizen::Base::Collection::ArrayList* GetIconLists(void); + + /** + * returns the total no. of pages in the control + */ + const int GetPageCount(void); + + /** + * Marks a page to be deleted + */ + void MarkPageToDelete(int pageNumber); + + /** + * Scrolls to the next or previous page on crossing the bounds while moving icons in edit mode + */ + void MovePage(void); + + /** + * Sets the maximum number of icons in one page + */ + void SetMaxNumberOfIcons(int iconsCount); + + /** + * Sets the listener to intercept events on the page control. + */ + void SetPageControlEventListener(ICustomPageControlEventListener* pListener); + + /** + * Sets item provider for the Page control + */ + void SetPageControlItemProvider(IPageControlItemProvider* pItemProvider); + + /** + * Scrolls to the specified page number + */ + void SetPageSelected(int pageNumber); + + /** + * Enables/Disables edit mode + */ + void ToggleEditMode(void); + + // from IIconListViewItemEventListener + virtual void OnIconListViewItemStateChanged(Tizen::Ui::Controls::IconListView& iconListView, int index, Tizen::Ui::Controls::IconListViewItemStatus status); + virtual void OnIconListViewOverlayBitmapSelected(Tizen::Ui::Controls::IconListView& iconListView, int index, int overlayBitmapId); + + // From ITimerEventListener + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + + //from ITouchEventListener + virtual void OnTouchCanceled(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {} + virtual void OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {} + virtual void OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {} + virtual void OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo); + virtual void OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo); + virtual void OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo); + + // From ITouchLongPressGestureEventListener + virtual void OnLongPressGestureCanceled(Tizen::Ui::TouchLongPressGestureDetector& gestureDetector) {} + virtual void OnLongPressGestureDetected(Tizen::Ui::TouchLongPressGestureDetector& gestureDetector); + +private: + /** + * Removes a page from the Page control + */ + result RemovePage(int pageNumber); + + /** + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + */ + CustomPageControl(const CustomPageControl&); + + /** + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + */ + CustomPageControl& operator =(const CustomPageControl&); + +private: + bool __hasPageMoved; // keeps info if the page transition completed or not + bool __isDragging; // tell if an icon is being dragged + bool __isInEditMode; // tells if the control is in edit mode or not + bool __needAnimation; //indicates, if scroll animation needs to be played. + HomeItemInfo* __pDraggingAppInfo; // the app info of moving item + ICustomPageControlEventListener* __pEventListener; // the listener object to notify about the events + int __currentIndex; //the index in which the moving item is projected at the moment + int __currentPageNumber; //Currently shown page number + int __iconsCount; //max number of icons per page + int __pageNumber; // current page number + int __pageToBeDeleted; // page number to be deleted + int __pageWidth; // width of one page + int __startIndex; // start index of the dragged icon + int __sweepTraveled; // the distance the touch has traveled, + int __totalPages; // total number of pages in this control + IPageControlItemProvider* __pPageItemProvider; // the provider for the PageItem + Tizen::Base::Collection::ArrayList* __pIconListProviders; // list of provider objects + Tizen::Base::Collection::ArrayList* __pIconLists; //keeps the list of IconListViews + Tizen::Base::Runtime::Timer* __pPageMovementTimer; // Time to be created for the duration for Page Movement + Tizen::Graphics::Bitmap* __pMovingItemBitmap; //The item bitmap of the moving item + Tizen::Graphics::Point __animationEndPoint; // starting position of touch from where the animation to be started + Tizen::Graphics::Point __animationStartPoint; // starting position control to be animated to. + Tizen::Graphics::Point __dragStartPosition; // starting position of touch dragging an item started + Tizen::Graphics::Point __iconListCurrentPos; // current position of the current page + Tizen::Graphics::Point __iconListRestPosition; // current position of the current page + Tizen::Graphics::Point __touchStartPoint; // starting position of touch from where the scrolling started + Tizen::Ui::Controls::IconListViewItem* __pMovementItem; //The Moving item + Tizen::Ui::Controls::Label* __pMovementLabel; // The label to show current position of touch location, to guide while repositioning + Tizen::Ui::TouchLongPressGestureDetector* __pGetureDetector; //LongTouchGesture detector +}; + +#endif // _HM_CUSTOM_PAGE_CONTROL_H_ diff --git a/inc/HmCustomPageMarker.h b/inc/HmCustomPageMarker.h new file mode 100644 index 0000000..3feac4e --- /dev/null +++ b/inc/HmCustomPageMarker.h @@ -0,0 +1,121 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmCustomPageMarker.h + * @brief Keeps declaration of the CustomPageMarker + * declares CustomPageMarker class, which contains the top bubble's bar which indicates the page number + */ + +#ifndef _HM_CUSTOM_PAGE_MARKER_H_ +#define _HM_CUSTOM_PAGE_MARKER_H_ + +#include +#include "HmICustomPageMarkerEventListener.h" + +/** + * @class CustomPageMarker + * @brief The control which keeps the bubbles and current state of the bubbles + */ +class CustomPageMarker + : public Tizen::Ui::Controls::Panel + , public Tizen::Ui::ITouchEventListener +{ +public: + /** + * Constructor + */ + CustomPageMarker(void); + + /** + * Destructor, this destructor overrides ~Tizen::Ui::Controls::Panel(). + */ + virtual ~CustomPageMarker(void); + + /** + * Constructs the object completely + * + * @param[in] controlRect, position of the control. + * @param[in] noOfPages, total no of bubbles to be initialized with. + * @param[in] markPos, position of the marker within the form. + */ + result Construct(const Tizen::Graphics::Rectangle& controlRect, int bubbleCount = 1); + + /** + * Adds a new bubble in the marker control + * + * @return result, E_SUCCESS if successfully created the control else Error Code. + */ + result AddBubble(void); + + /** + * returns the total no. of bubbles in the control + * + * @return the no of bubbles in the control + */ + const int GetBubbleCount(void); + + /** + * Deletes a bubble from the marker control + * + * @return result, E_SUCCESS if successfully created the control else Error Code. + * @param[in] index, bubble number to be deleted. + */ + result RemoveBubble(int index); + + /** + * Sets the listener to intercept events on the marker control. + * + * @param[in] pListener, Listener object to be notified. + */ + void SetPageMarkerEventListener(ICustomPageMarkerEventListener* pListner); + + /** + * Sets the specified bubble as a current bubble, and highlights it + * + * @return result, E_SUCCESS if successfully created the control else Error Code. + * @param[in] index, bubble number to be highlighted. + */ + void SetSelectedBubble(int index); + + // From ITouchEventListener + virtual void OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {} + virtual void OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo); + virtual void OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {} + virtual void OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {} + virtual void OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {} + virtual void OnTouchCanceled(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {} + +private: + /** + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + */ + CustomPageMarker(const CustomPageMarker&); + + /** + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + */ + CustomPageMarker& operator =(const CustomPageMarker&); + +private: + ICustomPageMarkerEventListener* __pMarkerListener; // listener to the marker events + int __bubbleCount; // total number of bubbles in marker control + int __selectedBubble; // currently highlighted bubble in the marker + Tizen::Base::Collection::ArrayList* __pBubbleLabels; // list of labels in the marker control + Tizen::Base::Collection::ArrayList* __pBubbleBitmaps; // the bitmaps to be shown as bubble +}; + +#endif //_HM_CUSTOM_PAGE_MARKER_H_ diff --git a/inc/HmGenericDatabaseManager.h b/inc/HmGenericDatabaseManager.h new file mode 100644 index 0000000..06d3e26 --- /dev/null +++ b/inc/HmGenericDatabaseManager.h @@ -0,0 +1,169 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmGenericDatabaseManager.h + * @brief Keeps the declaration of DatabaseManager and related interfaces + * declaration of the various functions which may be needed for various database operations + */ + +#ifndef _HM_GENERIC_DATABASE_MANAGER_H_ +#define _HM_GENERIC_DATABASE_MANAGER_H_ + +#include +#include + +/** + * @class GenericDatabaseManager + * @brief The class contains declaration of various database functions. + */ +class GenericDatabaseManager + : public Tizen::Base::Object +{ +public: + /** + * Returns an object of the database manager + * + * @return HomeDatabaseManager*, pointer to the singleton object of HomeDatabaseManager + */ + static GenericDatabaseManager* GetInstance(void); + + /** + * Creates or opens(if already created) the database. + * + * @return E_SUCCESS in case of success else system wide error code + * @param[in] dbName, absolute path for the database file. + */ + result CreateDataBase(const Tizen::Base::String& dbName); + + /** + * Creates a Table of given name if not already exists. + * + * @return E_SUCCESS in case of success else system wide error code + * @param[in] tableName, name of the table to be created. + * @param[in] pColumnNames, the names for each columns in the table + * @param[in] pColumnTypes, the type of corresponding column names + */ + result CreateTable(const Tizen::Base::String& tableName, Tizen::Base::Collection::ArrayList* pColumnNames, Tizen::Base::Collection::ArrayList* pColumnTypes); + + /** + * Deletes records from the table + * + * @return E_SUCCESS in case of success else system wide error code + * @param[in] tableName, the table name from which the rows to be deleted + * @param[in] whereCondition, the criteria to select the correct row to be modified + */ + result DeleteFromTable(const Tizen::Base::String& tableName, const Tizen::Base::String& whereCondition); + + /** + * Reads data from the database. + * + * @return E_SUCCESS in case of success else system wide error code + * @param[in] tableName, the table name from which the rows to be deleted + * @param[in] whereCondition, the criteria to select the correct row to be modified + * @param[out] the retrieved data, the column name to be keys and values as value. + */ + result GetDataRowFromTable(const Tizen::Base::String& tableName, const Tizen::Base::String& whereCondition, Tizen::Base::Collection::HashMap& rowDataHashMap); + + /** + * Returns the last added records recordId, + * this record id is the value of the PRIMARY AutoIncremented column in the table + * + * @return int, the value of record id. + * @param[in] tableName, table name for which the record id has to be fetched + * + * @remark : if fails it returns -1 and the error can be fetched using GetLastResult() Method + */ + int GetLastAddedRowID(const Tizen::Base::String& tableName); + + /** + * Inserts the data in given table. + * + * @return E_SUCCESS in case of success else system wide error code + * @param[in] tableName, name of the table to be created. + * @param[in] pColumnNames, the names for each columns in the table + * @param[in] pColumnTypes, the type of corresponding columns + * @param[in] pColumnValues, the values for corresponding columns + */ + result InsertToTable(const Tizen::Base::String& tableName, Tizen::Base::Collection::ArrayList* pColumnNames, Tizen::Base::Collection::ArrayList* pColumnTypes, Tizen::Base::Collection::ArrayList* pColumnValues); + + /** + * Inserts the data in given table. + * + * @return E_SUCCESS in case of success else system wide error code + * @param[in] tableName, name of the table to be created. + * @param[in] pColumnsToModify, the column names which needs to be updated + * @param[in] pColumnTypes, the type of corresponding columns + * @param[in] pColumnsNewData, the values for corresponding columns + * @param[in] whereCondition, the criteria to select the correct row to be modified + */ + result UpdateTable(const Tizen::Base::String& tableName, Tizen::Base::Collection::ArrayList* pColumnsToModify, Tizen::Base::Collection::ArrayList* pColumnTypes, Tizen::Base::Collection::ArrayList* pColumnsNewData, const Tizen::Base::String* pWhereCondition); + +private: + /** + * Destructor + * This destructor is intentionally declared as private to implement the Singleton semantic. + */ + ~GenericDatabaseManager(void); + + /** + * Constructor + * This Constructor is intentionally declared as private to implement the Singleton semantic. + */ + GenericDatabaseManager(void); + + /** + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + */ + GenericDatabaseManager(const GenericDatabaseManager&); + + /** + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + */ + GenericDatabaseManager& operator =(const GenericDatabaseManager&); + + /** + * Creates the singleton object of HomeDatabaseManager + */ + static void CreateInstance(void); + + /** + * Destroys the singleton object of HomeDatabaseManager + */ + static void DestroyInstance(void); + + /** + * returns the column type of the mentioned column name + * + * @return DbColumnType, tells about the data type of the column. + * @param[in] columnName, column name for which type is to be known. + */ + Tizen::Io::DbColumnType GetColumnType(Tizen::Io::DbEnumerator* pDbEnumerator, Tizen::Base::String* pColumnName); + + /** + * returns the columntype of the mentioned columnName + * + * @return int, tells about the datatype of the column. + * @param[in] pColumnName, column name for which type is to be known. + */ + int GetColumnIndex(Tizen::Io::DbEnumerator* pDbEnumerator, Tizen::Base::String* pColumnName); + +private: + static GenericDatabaseManager* __pDatabaseManager; // singleton object of this class + Tizen::Io::Database* __pDatabase; // database instance +}; + +#endif //_HM_GENERIC_DATABASE_MANAGER_H_ diff --git a/inc/HmHomeApp.h b/inc/HmHomeApp.h new file mode 100644 index 0000000..9485952 --- /dev/null +++ b/inc/HmHomeApp.h @@ -0,0 +1,79 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmHomeApp.h + * @brief Keeps declaration of UiApp derived class. + */ + +#ifndef _HM_HOME_APP_H_ +#define _HM_HOME_APP_H_ + +#include +#include + +class HomeForm; +class HomePresentationModel; + +/** + * @class HomeApp + * @brief UiApp must inherit from UiApp class + * which provides basic features necessary to define an UiApp. + */ +class HomeApp + : public Tizen::App::UiApp + , public Tizen::System::IScreenEventListener +{ +public: + /** + * UiApp must have a factory method that creates an instance of itself. + */ + static Tizen::App::UiApp* CreateInstance(void); + +public: + /** + * Constructor + * Initializes the object with default values + */ + HomeApp(void); + + /* + * desctructor + * used to free allocated resources + */ + virtual ~HomeApp(void); + +public: + bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry); + bool OnAppInitialized(void); + bool OnAppWillTerminate(void); + bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false); + void OnLowMemory(void); + void OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel); + void OnScreenOn(void); + void OnScreenOff(void); + void OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs); + + void OnForeground(void); + void OnBackground(void); + +private: + bool __presentationModelInitialized; //Indicates if the Model is initialized on not + HomeForm* __pHomeForm; //the object of Form to be shown for this application + HomePresentationModel* __pPresentationModel; //the Model instance +}; + +#endif //_HM_HOME_APP_H_ diff --git a/inc/HmHomeForm.h b/inc/HmHomeForm.h new file mode 100644 index 0000000..be67121 --- /dev/null +++ b/inc/HmHomeForm.h @@ -0,0 +1,162 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmHomeForm.h + * @brief Keeps declaration of Main Form for the application + */ + +#ifndef _HM_HOME_FORM_H_ +#define _HM_HOME_FORM_H_ + +#include +#include +#include "HmCustomPageControl.h" +#include "HmCustomPageMarker.h" +#include "HmHomePresentationModel.h" +#include "HmICustomPageControlEventListener.h" +#include "HmIPageControlItemProvider.h" + +class HomeItemInfo; +class ProgressPanel; + +/** + * @class HomeForm + * @brief The form class for this application, it represents the Home Screen + */ +class HomeForm + : public Tizen::Ui::Controls::Form + , public Tizen::System::ISettingEventListener + , public Tizen::Ui::ITouchEventListener + , public ICustomPageControlEventListener + , public ICustomPageMarkerEventListener + , public IHomePresentationModelEventListener + , public IPageControlItemProvider +{ +public: + /** + * Constructor + */ + HomeForm(void); + + /** + * Destructor + */ + virtual ~HomeForm(void); + + /** + * Called when we need to initialize the Form + */ + bool Initialize(void); + + /** + * Creates and initializes Page controls + */ + result InitializePageControls(HomePresentationModel* pPresentationModel); + + /** + * Updates all the pages in the Home Screen + */ + void UpdateAllPages(void); + + /** + * Updates pages in home screen + */ + void UpdatePage(Tizen::Base::Collection::ArrayList* pArgs); + +public: + //methods from Form + virtual result OnInitializing(void); + virtual result OnTerminating(void); + + // From ISettingEventListener + virtual void OnSettingChanged(Tizen::Base::String& key); + + // from ITouchEventListener + virtual void OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {} + virtual void OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo); + virtual void OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {} + virtual void OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {} + virtual void OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {} + virtual void OnTouchCanceled(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {} + + // from ICustomPageControlEventListener + // Called when any page gets swept, this method gets called. + virtual void OnPageSwept(int pageNumber); + + // Called when a new page gets added in the Page Control + virtual void OnPageAdded(int pageNumber); + + // Called when a new page gets deleted in the Page Control + virtual void OnPageRemoved(int pageNumber); + + // from ICustomPageMarkerEventListener + // Called when any bubble in the Page Marker gets pressed + virtual void OnMarkerBubbleMoved(int bubbleNumber); + + //from IHomePresentationModelEventListener + // Called when Installation completed successfully + virtual void OnInstallationCompleted(const HomeItemInfo& pItemInfo); + + // Called when an un-install request occures + virtual void OnAppUninstallRequested(HomeItemInfo* pItemInfo); + + // Called when Un-Installation completed successfully + virtual void OnUnInstallationCompleted(const HomeItemInfo& pItemInfo); + + // Called, when it needs to update some pages + virtual void OnUpdatePageRequestedN(Tizen::Base::Collection::ArrayList* pPageList); + + // from IPageControlItemProvider + /** + * Returns the total number of pages + */ + virtual int GetPageCount(void); + + /** + * Returns the number of items, which belongs to the mentioned page + */ + virtual int GetItemCount(int pageNumber); + + /** + * Returns the actual item pointer, at the mentioned position + */ + virtual HomeItemInfo* GetItem(int pageNumber, int index); + + /** + * Rearranges the items within a page, across page and moved icons. + */ + virtual void RearrangeItems(HomeItemInfo* pMovedAppInfo, int newPageNumber, int newIndex); + +private: + bool __isEditEnabled; //indicates if the Home screen is in edit mode. + bool __isLanguageChanged; + CustomPageControl* __pPageControl; // PageControl instance + CustomPageMarker* __pPageMarker; // PageMarker instance + HomePresentationModel* __pHomePresentationModel; // HmHomePresentationModel instance + ProgressPanel* __pProgressPanel; //Progress panel + Tizen::Base::String __currentLanguage; + Tizen::Graphics::Bitmap* __pBackgroundBitmap; //the background bitmap + Tizen::Graphics::Bitmap* __pSettingsBitmap; //The setting button bitmap + Tizen::Graphics::Bitmap* __pSettingsPressedBitmap; //The pressed setting button bitmap + Tizen::Ui::Controls::Label* __pBackgroundLabel; // the background label to show the wallpaper + Tizen::Ui::Controls::Panel* __pSettingsPanel; // the setting panel + + + +}; + +#endif //_HM_HOME_FORM_H_ diff --git a/inc/HmHomeItemInfo.h b/inc/HmHomeItemInfo.h new file mode 100644 index 0000000..8741163 --- /dev/null +++ b/inc/HmHomeItemInfo.h @@ -0,0 +1,163 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmHomeItemInfo.h + * @brief Keeps declaration of the HomeItemInfo + * Declares the HomeItemInfo class, it keeps the information of all the applications installed. + */ + +#ifndef _HM_HOME_APP_INFO_H_ +#define _HM_HOME_APP_INFO_H_ + +#include +#include + +/** + * @class HomeItemInfo + * @brief Keeps all the informations of the applications. + */ +class HomeItemInfo + : public Tizen::Base::Object +{ +public: + /** + * Constructor + */ + HomeItemInfo(void); + + /** + * Destructor + */ + virtual ~HomeItemInfo(void); + + /** + * Returns applications ID + * + * @return Tizen::Base::String, Application's id + */ + Tizen::Base::String GetAppId(void) const; + + /** + * returns the application icon, the bitmap object to shown in the screen + * + * @return Bitmap*, the bitmap object for app icon + */ + Tizen::Graphics::Bitmap* GetApplicationIcon(void) const; + + /** + * Returns applications Name + * + * @return Tizen::Base::String*, Application's Name + */ + Tizen::Base::String GetAppName(void) const; + + /** + * tell about, the application's icon path + * + * @return bool, true if can be shown in Home else false. + */ + Tizen::Base::String GetIconPath(void) const; + + /** + * Returns package ID + * + * @return Tizen::Base::String, Package's id + */ + Tizen::Base::String GetPackageId(void) const; + + /** + * Gets the position of the application's icon in the home screen. + * + * @param[out] pageNumber, the page number + * @param[out] position, position in that page + */ + void GetPositionInHomeScreen(int& pageNumber, int& position) const; + + /** + * Initializes data by fetching information from the PackageInfo + * + * @return E_SUCCESS, otherwise standard error code + * @param[in] pPackInfo, the information of the package + */ + result Initialize(Tizen::App::Package::PackageAppInfo* pPackAppInfo, Tizen::App::Package::PackageInfo* pPackInfo); + + /** + * tells about, if the application can be uninstalled or not + * + * @return bool, true if can be uninstalled else false. + */ + bool IsUnistallable(void) const; + + /** + * tell about, if the app icon can be shown in the home screen + * + * @return bool, true if can be shown in Home else false. + */ + bool IsVisibleInMainMenu(void) const; + + /** + * sets the application icon, the bitmap object to shown in the screen + * + * @param[in] pBitmap, the bitmap object for app icon + */ + void SetApplicationIcon(Tizen::Graphics::Bitmap* pAppIconBitmap); + + /** + * sets the application name + * + * @param[in] newAppName, the name for this application + */ + void SetApplicationName(Tizen::Base::String& newAppName); + /** + * Sets the index of this item + * + * @param[in] newIndex, the new index for this application + */ + void SetItemIndex(int newIndex); + + /** + * Sets the position of the app icon in the home screen + * + * @param[in] pageNumber, the page number + * @param[in] position, position in that page + */ + void SetPositionInHomeScreen(int pageNumber, int position); + +private: + /** + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + */ + HomeItemInfo(const HomeItemInfo&); + + /** + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + */ + HomeItemInfo& operator =(const HomeItemInfo&); + +private: + bool __isVisibleInMainMenu; // can be shown in the home screen + bool __isUninstallable; // can be un-installed + int __pageNumber; //Page number of this application in home screen + int __position; // position of the application in home screen page + Tizen::Base::String __appId; //application ID + Tizen::Base::String __appIconPath; // Application's Icon Path + Tizen::Base::String __appName; //Application name + Tizen::Graphics::Bitmap* __pAppIcon; // decoded bitmap for the application Icon + Tizen::Base::String __packageId; //package ID +}; + +#endif //_HM_HOME_APP_INFO_H_ diff --git a/inc/HmHomePresentationModel.h b/inc/HmHomePresentationModel.h new file mode 100644 index 0000000..f461362 --- /dev/null +++ b/inc/HmHomePresentationModel.h @@ -0,0 +1,236 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmHomePresentationModel.h + * @brief Keeps declaration of the HomePresentationModel + * Declares the HomePresentationModel classe, it keeps the data required to show the application icons in the home view + */ + + +#ifndef _HM_HOME_PRESENTATION_MODEL_H_ +#define _HM_HOME_PRESENTATION_MODEL_H_ + +#include +#include "HmGenericDatabaseManager.h" +#include "HmIHomePresentationModelListener.h" +#include "HmIPackageInfoListListener.h" +#include "HmPackageInfoListRetrieveThread.h" +#include "HmTypes.h" + +class HomeItemInfo; +class PackageInfoListRetrieveThread; + +/** + * @enum HomePresentationRequestIds + * Request IDs to the Model Thread + */ +enum HomePresentationModelRequestTypes +{ + MODEL_REQUEST_INITIALIZE = 100, /** Initialization request */ +}; + +/** + * @class HomePresentationModel + * @brief Home data presenter + */ + +class HomePresentationModel + : public Tizen::Base::Object + , public Tizen::App::Package::IPackageInstallationEventListener + , public IPackageInfoListListener +{ + + class HomeApplicationsComparer + : public Tizen::Base::Collection::IComparer + { + public: + virtual result Compare(const Tizen::Base::Object& obj1, const Tizen::Base::Object& obj2, int& cmp) const; + }; + +public: + /** + * The default constructor for the class + * The object is not fully constructed after this constructor is called. + * For full construction, the Construct() method must be called right after calling this constructor + */ + HomePresentationModel(void); + + /** + * This is the destructor for this class. + */ + virtual ~HomePresentationModel(void); + + /** + * Constructs the model, initializes the members with proper values + * + * @return result, E_SUCCESS or standard error code if failed. + */ + result Construct(void); + + /** + * Returns the item instance to be shown in mentioned position + * + * @return HomeItemInfo*, the pointer to the actual item. + * @param[in] page Number, the page number to which the Item belongs + * @param[in] index, The index for which the item is to be retrieved + */ + HomeItemInfo* GetItem(int pageNumber, int index) const; + + /** + * Returns the number of items in the mentioned page + * + * @return int, number of items in page. + * @param[in] pageNumber, the page number for which the Item count needed + */ + int GetItemCount(int pageNumber) const; + + /** + * Returns the number of pages to be created to show all the application icons + * + * @return int, number of pages. + */ + int GetPageCount(void) const; + + /** + * Updates the application informations etc in case of language changed + */ + void LanguageChanged(void); + + /** + * Rearranges the items within a page, across page and moves icons . + * + * @param[in] pMovedAppInfo, The HomeItemInfo's pointer, which has to be moved + * @param[in] newPageNumber, New Page number, where the icon has to be placed + * @param[in] newIndex, The index to which the mentioned application to be placed + */ + void RearrangeItems(HomeItemInfo* pMovedAppInfo, int newPageNumber, int newIndex); + + /** + * Sets the installation/un-installation event listener. + * + * @param[in] pListener, the listener object to be set. + */ + void SetHomePackageEventListener(IHomePresentationModelEventListener* pListener); + + /** + * Updates the applications data into the database. + * + * @return E_SUCCESS, in case of success else system wide error code. + */ + result UpdatePageData(void); + + //from IPackageInstallationEventListener + virtual void OnPackageInstallationCompleted(const Tizen::App::PackageId& packageId, Tizen::App::Package::PackageInstallationResult installationResult); + virtual void OnPackageInstallationInProgress(const Tizen::App::PackageId& packageId, int progress) {} + virtual void OnPackageUninstallationCompleted(const Tizen::App::PackageId& packageId, bool uninstallationResult); + + //from IPackageInfoListListener + /** + * Called when PackageListing completes + * + * @param[in] pAppsList, list of installed packages + * @param[in] totalApps, total number of installed applications + * @param[in] totalPages, total number of pages + */ + virtual void OnPackageInfoRetrievedN(Tizen::Base::Collection::HashMap* pAppsList, int totalApps, int totalPages); + +private: + /** + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + */ + HomePresentationModel(const HomePresentationModel&); + + /** + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + */ + HomePresentationModel& operator =(const HomePresentationModel&); + + /** + * Tries to find a HomeItemInfo with the name sa provided in parameters + * + * @return HomeItemInfo*, valid pointer if found else null + * @param[in] packageId, the packageId to be searched for + */ + HomeItemInfo* FindAppObjectInList(const Tizen::Base::String& packageIdToFind); + + /** + * Initializes the DataBase with initial values, create databse and tables if not already created. + * + * @return E_SUCCESS, in case of success else system wide error code. + */ + result InitializeDatabase(void); + + /** + * Inserts page position data into the database. + * + * @return E_SUCCESS, in case of success else system wide error code. + * @param[in] pItemInfo, the application object to get the data from. + */ + result InsertPageDataInDataBase(const HomeItemInfo* pItemInfo); + + /** + * Notify the ui about the package manager installation event + * + * @return result, E_SUCCESS, in case of success else system wide error code. + * @param[in] appId, the application id for which installation completed + */ + result NotifyInstallationEvent(const Tizen::App::PackageId& packageId); + + /** + * this api prepares the application list, by using data in database, to retain the previous state. + * + * @return, E_SUCCESS, in case of success else system wide error code. + */ + result PrepareApplicationsList(void); + + /** + * Sorts the pages, depending upon the position of the application icons + */ + void SortPages(void); + + /** + * Updates the applications information into the database table. + * @return E_SUCCESS, in case of success else system wide error code. + * @param[in] pItemInfo, the application object to get the data from. + */ + result UpdateDataToDatabase(HomeItemInfo* pItemInfo); + + /** + * Update the applications info objects within the mentioned ArrayList, with corresponding postions + * Gets called, after re-arrangement completes. + */ + void UpdatePositions(Tizen::Base::Collection::ArrayList& pAppListToUpdate); + + /** + * Reads the database and updates the local copy of the applications information + * + * @return E_SUCCESS, in case of success else system wide error code. + */ + result UpdateWithPositions(void); + +private: + GenericDatabaseManager* __pDataBaseManager; // HmDatabaseManager instance. + HomeApplicationsComparer __comparerObject; // IComparer derived class to be passed in Sort method + IHomePresentationModelEventListener* __pDataListener; // listener for various events + int __totalApps; //total number of applications + int __totalPages; //total number of pages + Tizen::App::Package::PackageManager* __pPackMgr; //PackageManager instance + Tizen::Base::Collection::HashMap* __pAppHashMap; // application informations + PackageInfoListRetrieveThread* __pPackageInfoRetrieveThread; // the worker thread instance to fetch packages list +}; + +#endif //_HM_HOME_PRESENTATION_MODEL_H_ diff --git a/inc/HmICustomPageControlEventListener.h b/inc/HmICustomPageControlEventListener.h new file mode 100644 index 0000000..9f8a052 --- /dev/null +++ b/inc/HmICustomPageControlEventListener.h @@ -0,0 +1,69 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmICustomPageControlEventListener.h + * @brief Listener interface for CustomPageControl events + */ + +#ifndef _HM_ICUSTOM_PAGE_CONTROL_EVENT_LISTENER_H_ +#define _HM_ICUSTOM_PAGE_CONTROL_EVENT_LISTENER_H_ + +class HomeItemInfo; + +/** + * @class ICustomPageControlEventListener + * @brief Notifies about the events occurred in page control * + */ + +class ICustomPageControlEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. + * This way, the destructor of the derived classes are called when the + * destructor of this interface is called + */ + virtual ~ICustomPageControlEventListener(void) {} + + /** + * This method gets called when Uninstall of an application requested + * @param[in] pItemInfo, the application's information to be un-installed + */ + virtual void OnAppUninstallRequested(HomeItemInfo* pItemInfo) = 0; + + /** + * This method gets called when a new page gets added. + */ + virtual void OnPageAdded(int pageNumber) = 0; + + /** + * This method gets called when the page gets deleted + * @param[in] pageNumber, gives the deleted page number + */ + virtual void OnPageRemoved(int pageNumber) = 0; + + /** + * This method gets called when the page gets swept or scrolled + * + * @param[in] pageNumber, gives the currently shown page number + */ + virtual void OnPageSwept(int pageNumber) = 0; + +}; + + +#endif // _HM_ICUSTOM_PAGE_CONTROL_EVENT_LISTENER_H_ diff --git a/inc/HmICustomPageMarkerEventListener.h b/inc/HmICustomPageMarkerEventListener.h new file mode 100644 index 0000000..a72e53e --- /dev/null +++ b/inc/HmICustomPageMarkerEventListener.h @@ -0,0 +1,47 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmICustomPageMarkerEventListener.h + * @brief Listener interface for CustomPageMarker control events + */ + +#ifndef _HM_ICUSTOM_PAGE_MARKER_EVENT_LISTENER_H_ +#define _HM_ICUSTOM_PAGE_MARKER_EVENT_LISTENER_H_ + +/** + * @class ICustomPageMarkerEventListener + * @brief Event listener for the marker bubbles + */ +class ICustomPageMarkerEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. + * This way, the destructor of the derived classes are called when the + * destructor of this interface is called + */ + virtual ~ICustomPageMarkerEventListener(void) {} + + /** + * Notifies about the currently selected bubble. + * + * @param[in] bubbleNo, the bubble number which got selected. + */ + virtual void OnMarkerBubbleMoved(int bubbleNo) = 0; +}; + +#endif // _HM_ICUSTOM_PAGE_MARKER_EVENT_LISTENER_H_ diff --git a/inc/HmIHomePresentationModelListener.h b/inc/HmIHomePresentationModelListener.h new file mode 100644 index 0000000..84f7e5b --- /dev/null +++ b/inc/HmIHomePresentationModelListener.h @@ -0,0 +1,69 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmIHomePresentationModelListener.h + * @brief keeps the declaration for IHomePresentationModelEventListener, + * which contains the event callback methods for HomePresentationModel events. + */ + +#ifndef _HM_IHOME_PRESENTATION_MODEL_LISTENER_H_ +#define _HM_IHOME_PRESENTATION_MODEL_LISTENER_H_ + +/** + * @class IHomePresentationModelEventListener + * @brief Event listener for the Model events + */ +class IHomePresentationModelEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. + * This way, the destructors of the derived classes are called when the + * destructor of this interface is called + */ + virtual ~IHomePresentationModelEventListener(void) {} + + /** + * Installation completed successfully + * + * @param[in] Info, application info of the installed application + */ + virtual void OnInstallationCompleted(const HomeItemInfo& pItemInfo) = 0; + + /** + * Installation is in progress + * + * @param[in] Info, application info of the application being installed. + */ + virtual void OnInstallationInProgress(const HomeItemInfo& pInfo, int progress) {} + + /** + * Un-Installation completed successfully + * + * @param[in] Info, application info of the un-installed application + */ + virtual void OnUnInstallationCompleted(const HomeItemInfo& pItemInfo) = 0; + + /** + * Installation completed successfully + * + * @param[in] Info, application info of the installed application + */ + virtual void OnUpdatePageRequestedN(Tizen::Base::Collection::ArrayList* pPageList) = 0; + +}; +#endif //_HM_IHOME_PRESENTATION_MODEL_LISTENER_H_ diff --git a/inc/HmIPackageInfoListListener.h b/inc/HmIPackageInfoListListener.h new file mode 100644 index 0000000..bda57cc --- /dev/null +++ b/inc/HmIPackageInfoListListener.h @@ -0,0 +1,53 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmIPackageListRetriverListener.h + * @brief Listener interface for PackageListRetrieverThread + */ + +#ifndef _HM_IPACKAGE_INFO_LIST_LISTENER_H_ +#define _HM_IPACKAGE_INFO_LIST_LISTENER_H_ + +#include + +/** + * @class IPackageRetriverListener + * @brief the listener class to notify about completion of package listing. + */ +class IPackageInfoListListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. + * This way, the destructors of the derived classes are called when the + * destructor of this interface is called + */ + virtual ~IPackageInfoListListener(void) {} + + /** + * Called when Package informations of installed packages completes. + * + * @param[in] pAppsList, the list of installed applications + * @param[in] totalApps, total number of installed applications + * @param[in] totalPages, total number of pages to be created + */ + virtual void OnPackageInfoRetrievedN(Tizen::Base::Collection::HashMap* pAppsList, int totalApps, int totalPages) = 0; +}; + + + +#endif // _HM_IPACKAGE_INFO_LIST_LISTENER_H_ diff --git a/inc/HmIPageControlItemProvider.h b/inc/HmIPageControlItemProvider.h new file mode 100644 index 0000000..9b48c83 --- /dev/null +++ b/inc/HmIPageControlItemProvider.h @@ -0,0 +1,76 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmIPageControlItemProvider.h + * @brief Keeps declaration of the IPageControlItemProvider + * The class keeps necessary methods which can be used for creating items for the Page data control. + */ + +#ifndef _HM_IPAGE_CONTROL_ITEM_PROVIDER_H_ +#define _HM_IPAGE_CONTROL_ITEM_PROVIDER_H_ + +class HomeItemInfo; + +/** + * @class IPageControlItemProvider + * @brief declares of the IPageControlItemProvider + * The class keeps necessary methods which can be used for creating items for the PageControl. + */ +class IPageControlItemProvider +{ +public: + /** + * This polymorphic destructor should be overridden if required. + * This way, the destructors of the derived classes are called when the destructor of this interface is called. + */ + virtual ~IPageControlItemProvider(void) {} + + /** + * Returns the actual item pointer, at the mentioned position + * + * @return HomeItemInfo*, The actual item's pointer + * @param[in] pageNumber, page number in which the item to be located + * @param[in] index, The index for which the item to be retrieved + */ + virtual HomeItemInfo* GetItem(int pageNumber, int index) = 0; + + /** + * Returns the number of items, which belongs to the mentioned page + * + * @return int, The number of items in the page + * @param[in] pageNumber, Page number + */ + virtual int GetItemCount(int pageNumber) = 0; + + /** + * Returns the total number of pages + * + * @return int, the number of pages + */ + virtual int GetPageCount(void) = 0; + + /** + * Rearranges the items within a page, across page and moved icons. + * + * @param[in] pMovedAppInfo, The HomeItemInfo's pointer, which has to be moved + * @param[in] newPageNumber, New Page number, where the icon has to be placed + * @param[in] newIndex, The index to which the mentioned application to be placed + */ + virtual void RearrangeItems(HomeItemInfo* pMovedAppInfo, int newPageNumber, int newIndex) = 0; +}; + +#endif // _HM_IPAGE_CONTROL_ITEM_PROVIDER_H_ diff --git a/inc/HmMainFrame.h b/inc/HmMainFrame.h new file mode 100644 index 0000000..355283f --- /dev/null +++ b/inc/HmMainFrame.h @@ -0,0 +1,52 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmMainFrame.h + * @brief Keeps declaration of Main Frame for the application + */ + +#ifndef _HM_HOME_FRAME_H_ +#define _HM_HOME_FRAME_H_ + +#include +#include + +/** + * @class MainFrame + * @brief This is Frame for the application. + */ +class MainFrame + : public Tizen::Ui::Controls::Frame +{ +public: + /** + * Constructor + */ + MainFrame(void); + + /** + * Destructor + */ + virtual ~MainFrame(void); + +public: + // from Frame + virtual result OnInitializing(void); + virtual result OnTerminating(void); +}; + +#endif //_HM_HOME_FRAME_H_ diff --git a/inc/HmPackageInfoListRetrieveThread.h b/inc/HmPackageInfoListRetrieveThread.h new file mode 100644 index 0000000..ebaa0d0 --- /dev/null +++ b/inc/HmPackageInfoListRetrieveThread.h @@ -0,0 +1,73 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file PackageInfoListRetrieveThread.h + * @brief The file contains declaration of PackageInfoListRetrieveThread, + * which is a worker thread and being used to retrieve the list PackageInfos, for the Applications installed on device. + */ + +#ifndef _HM_PACKAGE_INFO_LIST_RETRIEVE_THREAD_H_ +#define _HM_PACKAGE_INFO_LIST_RETRIEVE_THREAD_H_ + +#include +#include "HmIPackageInfoListListener.h" + +/** + * @class PackageInfoListRetrieveThread + * @brief The worker thread class for retriving and listing of various types of packages. + */ +class PackageInfoListRetrieveThread + : public Tizen::Base::Runtime::Thread +{ +public: + /** + * Constructor + */ + PackageInfoListRetrieveThread(IPackageInfoListListener* pPackageListener); + + /** + * Destructor + */ + virtual ~PackageInfoListRetrieveThread(void); + + /** + * Starts this Thread, for listing specified type of packages. + * + * @return result, E_SUCCESS if thread starts properly, else system wide error code. + * @param[in] typeOfInstall, tells of which kind of packages to be listed. + */ + result SetPackageType(void); + + //this method gets called when the thread is created without an IRunnable instance. In this thread it lists the specified type of packages. + virtual Tizen::Base::Object* Run(void); + +private: + /** + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + */ + PackageInfoListRetrieveThread(const PackageInfoListRetrieveThread&); + + /** + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + */ + PackageInfoListRetrieveThread& operator =(const PackageInfoListRetrieveThread&); + +private: + IPackageInfoListListener* __pPackageListener; //The listener to listen about the completion of package listing +}; + +#endif //_HM_PACKAGE_INFO_LIST_RETRIEVE_THREAD_H_ diff --git a/inc/HmProgressPanel.h b/inc/HmProgressPanel.h new file mode 100644 index 0000000..0feca96 --- /dev/null +++ b/inc/HmProgressPanel.h @@ -0,0 +1,80 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmProgressPanel.h + * @brief Keeps declaration of ProgressPanel Implementation + */ + +#ifndef _HM_HOME_PROGRESS_PANEL_H_ +#define _HM_HOME_PROGRESS_PANEL_H_ + +#include + +/** + * @class ProgressPanel + * @brief Keeps the required functions and objects in showing a wait cursor + */ +class ProgressPanel + : public Tizen::Ui::Controls::Panel +{ + +public: + /** + * default Constructor + * The object is not fully constructed after this constructor is called. + * For full construction, the Construct() method must be called right after calling this constructor + */ + ProgressPanel(void); + + /** + * Destructor + * Handles all the deallocations and cleanup tasks reuired for this object + */ + virtual ~ProgressPanel(void); + + /** + * Second phase of Construction + */ + result Construct(const Tizen::Graphics::Rectangle& controlRectangle); + + /** + * Start animating the wait cursor + */ + result StartAnimation(void); + + /** + * Stops the running animations + */ + result StopAnimation(void); + +private: + /** + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + */ + ProgressPanel(const ProgressPanel&); + + /** + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + */ + ProgressPanel& operator =(const ProgressPanel&); + +private: + Tizen::Base::Collection::ArrayList* __pAnimationFrameList; // The list of AnimationFrames + Tizen::Ui::Controls::Animation* __pAnimation; // The animation control +}; + +#endif //_HM_HOME_PROGRESS_PANEL_H_ diff --git a/inc/HmTypes.h b/inc/HmTypes.h new file mode 100644 index 0000000..898275e --- /dev/null +++ b/inc/HmTypes.h @@ -0,0 +1,118 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmTypes.h + * @brief Keeps all the constants used throughout the application + */ + +#ifndef _HM_TYPES_H_ +#define _HM_TYPES_H_ + +// string constants +// bitmap paths +extern const wchar_t* IDB_BACKGROUND_IMAGE; +extern const wchar_t* IDB_CLOSE_ICON; +extern const wchar_t* IDB_SELECTED_BUBBLE_TOP; +extern const wchar_t* IDB_BUBBLE_TOP; +extern const wchar_t* IDB_DEFAULT_APP_ICON; +extern const wchar_t* IDB_SETTING_BUTTON; +extern const wchar_t* IDB_SETTING_BUTTON_PRESSED; +// application specific constants +extern const wchar_t* SETTINGS_KEY_WALLPAPER; +extern const wchar_t* SETTINGS_KEY_LANGUAGE; +extern const wchar_t* WAIT_CURSOR_IMAGE_BASE; +extern const wchar_t* BITMAP_EXTENSION; +extern const wchar_t* APP_ID_REPLACE_STR; +extern const wchar_t* SETTING_ANIMATION_PROPERTY_NAME; +// database constants +extern const wchar_t* HOME_DATABASE_NAME; +// database table names +extern const wchar_t* HOME_APPLICATIONS_TABLE; +// database column names +extern const wchar_t* APPS_RECORD_ID; +extern const wchar_t* APPS_APP_ID; +extern const wchar_t* APPS_APP_NAME; +extern const wchar_t* APPS_APP_ICON; +extern const wchar_t* APPS_APP_PAGE; +extern const wchar_t* APPS_APP_PAGEINDEX; +//DATATYPES used for database +extern const wchar_t* DATATYPE_INTEGER_PRIMARY; +extern const wchar_t* DATATYPE_INTEGER; +extern const wchar_t* DATATYPE_TEXT; +extern const wchar_t* DATATYPE_UNIQUE; +// database queries +extern const wchar_t* CREATE_TABLE; +extern const wchar_t* INSERT_TABLE; +extern const wchar_t* SELECT_TABLE; +extern const wchar_t* DELETE_TABLE; +extern const wchar_t* UPDATE_TABLE; +extern const wchar_t* GET_LAST_RECORD_ID; + +extern const unsigned int COLOR_SETTING_BOUNDARY_INNER; + +// int constants +// Ui Bounds +extern const int X_MARKER_LABEL_OFFSET; +extern const int X_MARKER_POSITION; +extern const int Y_MARKER_POSITION; +extern const int W_MARKER_LABEL; +extern const int H_MARKER_LABEL; +extern const int W_MARKER_OFFSET; +extern const int X_PAGE_POSITION; +extern const int H_APP_CAPTION_TEXT; +extern const int Y_APP_ICON_IMAGE_START; +extern const int W_APPLICATION_ICON; +extern const int H_APPLICATION_ICON; +extern const int X_PAGE_OFFSET; +extern const int H_EDIT; +extern const int H_CONTROL_OFFSET; +extern const int H_PAGE_MARKER; +extern const int W_DEFAULT_PAGE; +extern const int X_SETTING_PANEL; +extern const int Y_SETTING_PANEL; +extern const int W_SETTING_PANEL; +extern const int H_SETTING_PANEL; +extern const int X_SETTING_PANEL_PRESSED_OFFSET; +extern const int SIZE_SETTING_LABEL_OFFSET; +extern const int OVERLAY_BITMAP_DIMENSION; +extern const int GAP_ICON_HORIZONTAL; +extern const int GAP_ICON_VERTICAL; +extern const int WAIT_CURSUR_DIMESION; +extern const int APP_ICON_IMAGE_SIZE; +// timer durations +extern const int DURATION_FOR_EACH_IMAGE; +extern const int DURATION_SETTING_ANIMATION; +extern const int MOVEMENT_UPDATE_DURATION; +extern const int LONG_TOUCH_GESTURE_DURATION; +extern const int SCROLL_ANIMATION_DURATION; +// font size +extern const int FONT_SIZE_APP_CAPTION; +// color values +extern const unsigned int COLOR_APP_ICON_CAPTION; +extern const unsigned int COLOR_APP_CAPTION_SHADOW1; +extern const unsigned int COLOR_APP_CAPTION_SHADOW2; +// action ids +extern const int IDA_OVERLAYBITMAP_CLOSE; +extern const int IDA_SETTING_BUTTON; +// other constants +extern const int MAX_ICONS_PER_PAGE; +extern const int MAX_PAGE_COUNT; +extern const int MAX_BITMAP_COUNT; +extern const int REPEAT_COUNT; +extern const int MOVING_ICON_OPACITY; + +#endif //_HM_TYPES_H_ diff --git a/manifest.xml b/manifest.xml new file mode 100644 index 0000000..5826edd --- /dev/null +++ b/manifest.xml @@ -0,0 +1,34 @@ + + + cwkuromqdr + 1.0.0 + C++App + + + + + + + + 2.0 + + http://tizen.org/privilege/application.launch + http://tizen.org/privilege/packageinfo + http://tizen.org/privilege/packagemanager.install + http://tizen.org/privilege/packagesetting + + + + + + Home-Ref + + + mainmenu.png + + + + + + + diff --git a/packaging/apps.Home.spec b/packaging/apps.Home.spec new file mode 100755 index 0000000..17cea2b --- /dev/null +++ b/packaging/apps.Home.spec @@ -0,0 +1,62 @@ +Name: apps.Home +Summary: Home application +Version: 1.0.0 +Release: 1 +Group: TO_BE/FILLED_IN +License: TO BE FILLED IN +Source0: %{name}-%{version}.tar.gz +BuildRequires: cmake +BuildRequires: pkgconfig(osp-appfw) +BuildRequires: pkgconfig(osp-uifw) +BuildRequires: osp-appfw-internal-devel +BuildRequires: osp-uifw-internal-devel +BuildRequires: pkgconfig(osp-uifw) +BuildRequires: osp-uifw-internal-devel +BuildRequires: pkgconfig(osp-media) +BuildRequires: osp-media-internal-devel +BuildRequires: pkgconfig(osp-image) +BuildRequires: osp-media-internal-devel +BuildRequires: pkgconfig(osp-net) +BuildRequires: osp-net-internal-devel +BuildRequires: pkgconfig(osp-image-core) + +Requires: osp-installer + +%description +Verification application: Home + +%prep +%setup -q + +%build +MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` +%ifarch %{ix86} +CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ -D_OSP_EMUL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} +%else +CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_ARMEL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} +%endif + +# Call make instruction with smp support +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install + +%post +/sbin/ldconfig +PKG_ID=cwkuromqdr +echo "/usr/etc/package-manager/backend/tpk -i /usr/apps/"${PKG_ID} +/usr/etc/package-manager/backend/tpk -i /usr/apps/${PKG_ID} +cp -f /usr/lib/osp/osp-ui-app-loader /usr/apps/${PKG_ID}/bin/Home +vconftool set -t string db/setting/menuscreen/package_name "cwkuromqdr.Home" -i -u 5000 -f + +%postun +/sbin/ldconfig +PKG_ID=cwkuromqdr +echo "/usr/etc/package-manager/backend/tpk -u "${PKG_ID} +/usr/etc/package-manager/backend/tpk -u ${PKG_ID} + +%files +%defattr(-,root,root,-) +/usr/apps/* diff --git a/res/ara-AE.xml b/res/ara-AE.xml new file mode 100644 index 0000000..6a32ecd --- /dev/null +++ b/res/ara-AE.xml @@ -0,0 +1,14 @@ + + + + نوع الشاشة الرئيسية + تمت + إلغاء + إعدادات الشاشة الرئيسية + Uninstall %ls? + الشاشة الرئيسية الافتراضية + الشاشة الرئيسية + ضبط كصفحة رئيسية + diff --git a/res/aze-AZ.xml b/res/aze-AZ.xml new file mode 100644 index 0000000..e3fcab8 --- /dev/null +++ b/res/aze-AZ.xml @@ -0,0 +1,14 @@ + + + + Başlanğıc ekranı növü + Yerinə yetirildi + Ləğv et + Başlanğıc ekranı parametrləri + Uninstall %ls? + Susmaya görə iş masası + Əsas ekran + Ev kimi qur + diff --git a/res/bul-BG.xml b/res/bul-BG.xml new file mode 100644 index 0000000..360e2bc --- /dev/null +++ b/res/bul-BG.xml @@ -0,0 +1,14 @@ + + + + Тип начален екран + Готово + Отказ + Настройки на началния екран + Uninstall %ls? + Начален екран по подразбиране + Начален екран + Като начало + diff --git a/res/cat-ES.xml b/res/cat-ES.xml new file mode 100644 index 0000000..540ee80 --- /dev/null +++ b/res/cat-ES.xml @@ -0,0 +1,14 @@ + + + + Tipus de pantalla d'inici + Finalitzat + Cancel·lar + Configuració de la pantalla d'inici + Uninstall %ls? + Pantalla d'inici predeterminada + Pantalla d'inici + Def com ini + diff --git a/res/ces-CZ.xml b/res/ces-CZ.xml new file mode 100644 index 0000000..2125f47 --- /dev/null +++ b/res/ces-CZ.xml @@ -0,0 +1,14 @@ + + + + Typ domovské obrazovky + Hotovo + Zrušit + Nastavení domovské obrazovky + Uninstall %ls? + Výchozí domovská obrazovka + Domovská obrazovka + Domovská + diff --git a/res/dan-DK.xml b/res/dan-DK.xml new file mode 100644 index 0000000..9182299 --- /dev/null +++ b/res/dan-DK.xml @@ -0,0 +1,14 @@ + + + + Type af startskærm + Udført + Annullér + Indstillinger for startskærm + Uninstall %ls? + Standardstartskærm + Startskærm + Som start + diff --git a/res/deu-DE.xml b/res/deu-DE.xml new file mode 100644 index 0000000..5863d4e --- /dev/null +++ b/res/deu-DE.xml @@ -0,0 +1,14 @@ + + + + Startanzeige-Typ + OK + Abbrechen + Startseiten-Einstellungen + Uninstall %ls? + Standard-Startbildschirm + Home-Bildschirm + Home-Taste + diff --git a/res/ell-GR.xml b/res/ell-GR.xml new file mode 100644 index 0000000..179624d --- /dev/null +++ b/res/ell-GR.xml @@ -0,0 +1,14 @@ + + + + Τύπος αρχικής οθόνης + Τέλος + Ακύρωση + Ρυθμίσεις αρχικής οθόνης + Uninstall %ls? + Προεπιλεγμένη αρχική οθόνη + Αρχική οθόνη + Ως αρχική + diff --git a/res/eng-GB.xml b/res/eng-GB.xml new file mode 100644 index 0000000..ffc2d04 --- /dev/null +++ b/res/eng-GB.xml @@ -0,0 +1,14 @@ + + + + Home screen type + Done + Cancel + Home screen settings + Uninstall %ls? + Default home screen + Home screen + Set as home + diff --git a/res/eng-PH.xml b/res/eng-PH.xml new file mode 100644 index 0000000..ffc2d04 --- /dev/null +++ b/res/eng-PH.xml @@ -0,0 +1,14 @@ + + + + Home screen type + Done + Cancel + Home screen settings + Uninstall %ls? + Default home screen + Home screen + Set as home + diff --git a/res/eng-US.xml b/res/eng-US.xml new file mode 100644 index 0000000..ffc2d04 --- /dev/null +++ b/res/eng-US.xml @@ -0,0 +1,14 @@ + + + + Home screen type + Done + Cancel + Home screen settings + Uninstall %ls? + Default home screen + Home screen + Set as home + diff --git a/res/est-EE.xml b/res/est-EE.xml new file mode 100644 index 0000000..882fe0d --- /dev/null +++ b/res/est-EE.xml @@ -0,0 +1,14 @@ + + + + Avaekraani tüüp + Valmis + Tühista + Avaekraani seaded + Uninstall %ls? + Vaikimisi avaekraan + Avaleht + Avaekr.-ks + diff --git a/res/eus-ES.xml b/res/eus-ES.xml new file mode 100644 index 0000000..3a0cf92 --- /dev/null +++ b/res/eus-ES.xml @@ -0,0 +1,14 @@ + + + + Pantaila nagusi mota + Amaituta + Ezeztatu + Pantaila nagusiaren ezarpenak + Uninstall %ls? + Lehenetsitako hasierako pantaila + Hasierako pantaila + Ez. nagusi + diff --git a/res/fin-FI.xml b/res/fin-FI.xml new file mode 100644 index 0000000..f867dcb --- /dev/null +++ b/res/fin-FI.xml @@ -0,0 +1,14 @@ + + + + Alkunäytön tyyppi + Tehty + Peruuta + Alkunäytön asetukset + Uninstall %ls? + Oletusalkunäyttö + Alkunäyttö + As. alkun. + diff --git a/res/fra-CA.xml b/res/fra-CA.xml new file mode 100644 index 0000000..e97a035 --- /dev/null +++ b/res/fra-CA.xml @@ -0,0 +1,14 @@ + + + + Type d'écran d'accueil + OK + Annuler + Paramètres de l'écran d'accueil + Uninstall %ls? + Écran d'accueil par défaut + Écran d'accueil + Définir en tant qu'Accueil + diff --git a/res/fra-FR.xml b/res/fra-FR.xml new file mode 100644 index 0000000..06c808e --- /dev/null +++ b/res/fra-FR.xml @@ -0,0 +1,14 @@ + + + + Type d'écran d'accueil + Effectué + Annuler + Paramètres de l'écran d'accueil + Uninstall %ls? + Écran d'accueil par défaut + Écran d'accueil + Accueil + diff --git a/res/gle-IE.xml b/res/gle-IE.xml new file mode 100644 index 0000000..c767e6d --- /dev/null +++ b/res/gle-IE.xml @@ -0,0 +1,14 @@ + + + + Cineál scáileáin bhaile + Déanta + Cuir ar ceal + Socruithe an scáileáin bhaile + Uninstall %ls? + Scáileán baile réamhshocraithe + Scáileán baile + Mar bhaile + diff --git a/res/glg-ES.xml b/res/glg-ES.xml new file mode 100644 index 0000000..5ac12d8 --- /dev/null +++ b/res/glg-ES.xml @@ -0,0 +1,14 @@ + + + + Tipo de pantalla de inicio + Finalizado + Cancelar + Axustes da pantalla de inicio + Uninstall %ls? + Pantalla de inicio predeterminada + Pantalla de inicio + Def inicio + diff --git a/res/hin-IN.xml b/res/hin-IN.xml new file mode 100644 index 0000000..3e94a99 --- /dev/null +++ b/res/hin-IN.xml @@ -0,0 +1,14 @@ + + + + होम स्क्रीन प्रकार + हुआ + रद्द करें + होम स्क्रीन सेटिंग्स + Uninstall %ls? + डिफ़ॉल्ट होम स्क्रीन + होम स्क्रीन + होम जैसे सेट + diff --git a/res/hrv-HR.xml b/res/hrv-HR.xml new file mode 100644 index 0000000..0ef367b --- /dev/null +++ b/res/hrv-HR.xml @@ -0,0 +1,14 @@ + + + + Vrsta početnog zaslona + OK + Prekid + Postavke početnog zaslona + Uninstall %ls? + Zadani početni zaslon + Početni zaslon + Za početnu + diff --git a/res/hun-HU.xml b/res/hun-HU.xml new file mode 100644 index 0000000..23a3834 --- /dev/null +++ b/res/hun-HU.xml @@ -0,0 +1,14 @@ + + + + Kezdőképernyő típusa + Kész + Mégse + Kezdőképernyő beállításai + Uninstall %ls? + Alapértelmezett kezdőképernyő + Kezdőképernyő + Kezdő könyv. + diff --git a/res/hye-AM.xml b/res/hye-AM.xml new file mode 100644 index 0000000..0498d7f --- /dev/null +++ b/res/hye-AM.xml @@ -0,0 +1,14 @@ + + + + Հիմնական էկրանի տեսակը + Կատարված է + Չեղարկել + Հիմնական էկրանի դրվածքներ + Uninstall %ls? + Կանխադրված հիմնական էկրան + Աշխատասեղան + Դնել հմնկն + diff --git a/res/isl-IS.xml b/res/isl-IS.xml new file mode 100644 index 0000000..b8d7c0e --- /dev/null +++ b/res/isl-IS.xml @@ -0,0 +1,14 @@ + + + + Gerð heimaskjás + Lokið + Hætta við + Stillingar heimaskjás + Uninstall %ls? + Sjálfgefinn heimaskjár + Heimaskjár + Heim + diff --git a/res/ita-IT.xml b/res/ita-IT.xml new file mode 100644 index 0000000..4d570d7 --- /dev/null +++ b/res/ita-IT.xml @@ -0,0 +1,14 @@ + + + + Tipo schermata Home + Fatto + Annulla + Impostazioni schermata iniziale + Uninstall %ls? + Schermata Home predefinita + Schermata Home + Come sfondo + diff --git a/res/jpn-JP.xml b/res/jpn-JP.xml new file mode 100644 index 0000000..35e4e67 --- /dev/null +++ b/res/jpn-JP.xml @@ -0,0 +1,14 @@ + + + + ホーム画面タイプ + 完了 + キャンセル + ホーム画面設定 + Uninstall %ls? + 標準ホーム画面 + ホーム画面 + ホームに設定 + diff --git a/res/kat-GE.xml b/res/kat-GE.xml new file mode 100644 index 0000000..4616abe --- /dev/null +++ b/res/kat-GE.xml @@ -0,0 +1,14 @@ + + + + საწყისი ეკრანის ტიპი + შესრულებულია + გაუქმება + საწყისი ეკრანის პარამეტრები + Uninstall %ls? + ნაგულისხმევი საწყისი ეკრანი + საწყისი ეკრანი + საწყ. არჩ. + diff --git a/res/kaz-KZ.xml b/res/kaz-KZ.xml new file mode 100644 index 0000000..8f5e653 --- /dev/null +++ b/res/kaz-KZ.xml @@ -0,0 +1,14 @@ + + + + Бастапқы экран түрі + Аяқталды + Тоқтату + Бастапқы экран параметрлері + Uninstall %ls? + Әдепкі бастапқы экран + Бейнебеттің өзіндік беті + Бас. орнату + diff --git a/res/kor-KR.xml b/res/kor-KR.xml new file mode 100644 index 0000000..1c237f0 --- /dev/null +++ b/res/kor-KR.xml @@ -0,0 +1,14 @@ + + + + 홈 화면 종류 + 완료 + 취소 + 홈 화면 설정 + Uninstall %ls? + 기본 홈 화면 + 홈 화면 + 홈으로 설정 + diff --git a/res/lav-LV.xml b/res/lav-LV.xml new file mode 100644 index 0000000..c33b7b9 --- /dev/null +++ b/res/lav-LV.xml @@ -0,0 +1,14 @@ + + + + Sākums ekrāna veids + Gatavs + Atcelt + Sākuma ekrāna iestatījumi + Uninstall %ls? + Noklusētais sākuma ekrāns + Sākuma ekrāns + Ies. kā sāk. + diff --git a/res/lit-LT.xml b/res/lit-LT.xml new file mode 100644 index 0000000..21e3671 --- /dev/null +++ b/res/lit-LT.xml @@ -0,0 +1,14 @@ + + + + Pradžios ekrano tipas + Atlikta + Atšaukti + Pradžios ekrano nustatymai + Uninstall %ls? + Numatytasis pradžios ekranas + Pradžios ekranas + Nust. prad. + diff --git a/res/mkd-MK.xml b/res/mkd-MK.xml new file mode 100644 index 0000000..d0592aa --- /dev/null +++ b/res/mkd-MK.xml @@ -0,0 +1,14 @@ + + + + Вид почетен екран + Извршено + Откажи + Опции за почетниот екран + Uninstall %ls? + Основен почетен екран + Почетен екран + Пост. почет. + diff --git a/res/nld-NL.xml b/res/nld-NL.xml new file mode 100644 index 0000000..8619c1f --- /dev/null +++ b/res/nld-NL.xml @@ -0,0 +1,14 @@ + + + + Type startscherm + Gereed + Annuleren + Instellingen startscherm + Uninstall %ls? + Standaard startscherm + Startscherm + Startpagina + diff --git a/res/nob-NO.xml b/res/nob-NO.xml new file mode 100644 index 0000000..c68b519 --- /dev/null +++ b/res/nob-NO.xml @@ -0,0 +1,14 @@ + + + + Startskjermtype + Utført + Avbryt + Startskjerminnstillinger + Uninstall %ls? + Standard startskjermbilde + Startskjerm + Angi hjem + diff --git a/res/pol-PL.xml b/res/pol-PL.xml new file mode 100644 index 0000000..36354a4 --- /dev/null +++ b/res/pol-PL.xml @@ -0,0 +1,14 @@ + + + + Typ ekranu startowego + Gotowe + Anuluj + Ustawienia ekranu startowego + Uninstall %ls? + Domyślny ekran startowy + Ekran startowy + Jako domowy + diff --git a/res/por-BR.xml b/res/por-BR.xml new file mode 100644 index 0000000..fd244f9 --- /dev/null +++ b/res/por-BR.xml @@ -0,0 +1,14 @@ + + + + Tipo da tela de início + Concluído + Cancelar + Config. da tela de início + Uninstall %ls? + Tela de início padrão + Tela principal + Definir como inicial + diff --git a/res/por-PT.xml b/res/por-PT.xml new file mode 100644 index 0000000..e00b074 --- /dev/null +++ b/res/por-PT.xml @@ -0,0 +1,14 @@ + + + + Tipo de ecrã principal + Concluído + Cancelar + Definições do ecrã inicial + Uninstall %ls? + Ecrã principal padrão + Ecrã principal + Def. c/ in. + diff --git a/res/ron-RO.xml b/res/ron-RO.xml new file mode 100644 index 0000000..d79c8c3 --- /dev/null +++ b/res/ron-RO.xml @@ -0,0 +1,14 @@ + + + + Tip ecran de pornire + Efectuat + Anulare + Setări ecran de pornire + Uninstall %ls? + Ecran de pornire implicit + Ecran de pornire + Set. acasă + diff --git a/res/rus-RU.xml b/res/rus-RU.xml new file mode 100644 index 0000000..3bbeca9 --- /dev/null +++ b/res/rus-RU.xml @@ -0,0 +1,14 @@ + + + + Тип главного экрана + Готово + Отмена + Параметры главного экрана + Uninstall %ls? + Главный экран по умолчанию + Главный экран + Как главную + diff --git a/res/screen-density-xhigh/BG.png b/res/screen-density-xhigh/BG.png new file mode 100644 index 0000000..12a7b34 Binary files /dev/null and b/res/screen-density-xhigh/BG.png differ diff --git a/res/screen-density-xhigh/Menu_Btn_Uninstall.png b/res/screen-density-xhigh/Menu_Btn_Uninstall.png new file mode 100644 index 0000000..285c14a Binary files /dev/null and b/res/screen-density-xhigh/Menu_Btn_Uninstall.png differ diff --git a/res/screen-density-xhigh/Menu_Btn_Uninstall_press.png b/res/screen-density-xhigh/Menu_Btn_Uninstall_press.png new file mode 100644 index 0000000..c76a367 Binary files /dev/null and b/res/screen-density-xhigh/Menu_Btn_Uninstall_press.png differ diff --git a/res/screen-density-xhigh/Menu_Btn_setting.png b/res/screen-density-xhigh/Menu_Btn_setting.png new file mode 100644 index 0000000..1b357fc Binary files /dev/null and b/res/screen-density-xhigh/Menu_Btn_setting.png differ diff --git a/res/screen-density-xhigh/Menu_Btn_setting_press.png b/res/screen-density-xhigh/Menu_Btn_setting_press.png new file mode 100644 index 0000000..3858945 Binary files /dev/null and b/res/screen-density-xhigh/Menu_Btn_setting_press.png differ diff --git a/res/screen-density-xhigh/Page_indicator_001.png b/res/screen-density-xhigh/Page_indicator_001.png new file mode 100644 index 0000000..214c81a Binary files /dev/null and b/res/screen-density-xhigh/Page_indicator_001.png differ diff --git a/res/screen-density-xhigh/Page_indicator_002.png b/res/screen-density-xhigh/Page_indicator_002.png new file mode 100644 index 0000000..4144553 Binary files /dev/null and b/res/screen-density-xhigh/Page_indicator_002.png differ diff --git a/res/screen-density-xhigh/Page_indicator_01.png b/res/screen-density-xhigh/Page_indicator_01.png new file mode 100644 index 0000000..7c87be5 Binary files /dev/null and b/res/screen-density-xhigh/Page_indicator_01.png differ diff --git a/res/screen-density-xhigh/Page_indicator_010.png b/res/screen-density-xhigh/Page_indicator_010.png new file mode 100644 index 0000000..0894754 Binary files /dev/null and b/res/screen-density-xhigh/Page_indicator_010.png differ diff --git a/res/screen-density-xhigh/Page_indicator_02.png b/res/screen-density-xhigh/Page_indicator_02.png new file mode 100644 index 0000000..98b1334 Binary files /dev/null and b/res/screen-density-xhigh/Page_indicator_02.png differ diff --git a/res/screen-density-xhigh/Page_indicator_03.png b/res/screen-density-xhigh/Page_indicator_03.png new file mode 100644 index 0000000..1cb20f4 Binary files /dev/null and b/res/screen-density-xhigh/Page_indicator_03.png differ diff --git a/res/screen-density-xhigh/Page_indicator_04.png b/res/screen-density-xhigh/Page_indicator_04.png new file mode 100644 index 0000000..752b8fb Binary files /dev/null and b/res/screen-density-xhigh/Page_indicator_04.png differ diff --git a/res/screen-density-xhigh/Page_indicator_05.png b/res/screen-density-xhigh/Page_indicator_05.png new file mode 100644 index 0000000..872982e Binary files /dev/null and b/res/screen-density-xhigh/Page_indicator_05.png differ diff --git a/res/screen-density-xhigh/Page_indicator_06.png b/res/screen-density-xhigh/Page_indicator_06.png new file mode 100644 index 0000000..930f5d8 Binary files /dev/null and b/res/screen-density-xhigh/Page_indicator_06.png differ diff --git a/res/screen-density-xhigh/Page_indicator_07.png b/res/screen-density-xhigh/Page_indicator_07.png new file mode 100644 index 0000000..cdf1a99 Binary files /dev/null and b/res/screen-density-xhigh/Page_indicator_07.png differ diff --git a/res/screen-density-xhigh/Page_indicator_08.png b/res/screen-density-xhigh/Page_indicator_08.png new file mode 100644 index 0000000..f13a8ef Binary files /dev/null and b/res/screen-density-xhigh/Page_indicator_08.png differ diff --git a/res/screen-density-xhigh/Page_indicator_09.png b/res/screen-density-xhigh/Page_indicator_09.png new file mode 100644 index 0000000..36c0d32 Binary files /dev/null and b/res/screen-density-xhigh/Page_indicator_09.png differ diff --git a/res/screen-density-xhigh/default_app_icon.png b/res/screen-density-xhigh/default_app_icon.png new file mode 100644 index 0000000..b0979b1 Binary files /dev/null and b/res/screen-density-xhigh/default_app_icon.png differ diff --git a/res/screen-density-xhigh/progressing00.png b/res/screen-density-xhigh/progressing00.png new file mode 100644 index 0000000..3f96c5a Binary files /dev/null and b/res/screen-density-xhigh/progressing00.png differ diff --git a/res/screen-density-xhigh/progressing00_big.png b/res/screen-density-xhigh/progressing00_big.png new file mode 100644 index 0000000..43fc7d0 Binary files /dev/null and b/res/screen-density-xhigh/progressing00_big.png differ diff --git a/res/screen-density-xhigh/progressing01.png b/res/screen-density-xhigh/progressing01.png new file mode 100644 index 0000000..a2fd21e Binary files /dev/null and b/res/screen-density-xhigh/progressing01.png differ diff --git a/res/screen-density-xhigh/progressing01_big.png b/res/screen-density-xhigh/progressing01_big.png new file mode 100644 index 0000000..71d0ad1 Binary files /dev/null and b/res/screen-density-xhigh/progressing01_big.png differ diff --git a/res/screen-density-xhigh/progressing02.png b/res/screen-density-xhigh/progressing02.png new file mode 100644 index 0000000..32a69c3 Binary files /dev/null and b/res/screen-density-xhigh/progressing02.png differ diff --git a/res/screen-density-xhigh/progressing02_big.png b/res/screen-density-xhigh/progressing02_big.png new file mode 100644 index 0000000..094ca9d Binary files /dev/null and b/res/screen-density-xhigh/progressing02_big.png differ diff --git a/res/screen-density-xhigh/progressing03.png b/res/screen-density-xhigh/progressing03.png new file mode 100644 index 0000000..46bf26e Binary files /dev/null and b/res/screen-density-xhigh/progressing03.png differ diff --git a/res/screen-density-xhigh/progressing03_big.png b/res/screen-density-xhigh/progressing03_big.png new file mode 100644 index 0000000..8d2a57e Binary files /dev/null and b/res/screen-density-xhigh/progressing03_big.png differ diff --git a/res/screen-density-xhigh/progressing04.png b/res/screen-density-xhigh/progressing04.png new file mode 100644 index 0000000..a52f0a0 Binary files /dev/null and b/res/screen-density-xhigh/progressing04.png differ diff --git a/res/screen-density-xhigh/progressing04_big.png b/res/screen-density-xhigh/progressing04_big.png new file mode 100644 index 0000000..e62c6fd Binary files /dev/null and b/res/screen-density-xhigh/progressing04_big.png differ diff --git a/res/screen-density-xhigh/progressing05.png b/res/screen-density-xhigh/progressing05.png new file mode 100644 index 0000000..b7e60d9 Binary files /dev/null and b/res/screen-density-xhigh/progressing05.png differ diff --git a/res/screen-density-xhigh/progressing05_big.png b/res/screen-density-xhigh/progressing05_big.png new file mode 100644 index 0000000..d76826b Binary files /dev/null and b/res/screen-density-xhigh/progressing05_big.png differ diff --git a/res/screen-density-xhigh/progressing06.png b/res/screen-density-xhigh/progressing06.png new file mode 100644 index 0000000..665a1d5 Binary files /dev/null and b/res/screen-density-xhigh/progressing06.png differ diff --git a/res/screen-density-xhigh/progressing06_big.png b/res/screen-density-xhigh/progressing06_big.png new file mode 100644 index 0000000..738bdf9 Binary files /dev/null and b/res/screen-density-xhigh/progressing06_big.png differ diff --git a/res/screen-density-xhigh/progressing07.png b/res/screen-density-xhigh/progressing07.png new file mode 100644 index 0000000..d56600e Binary files /dev/null and b/res/screen-density-xhigh/progressing07.png differ diff --git a/res/screen-density-xhigh/progressing07_big.png b/res/screen-density-xhigh/progressing07_big.png new file mode 100644 index 0000000..ff3d34d Binary files /dev/null and b/res/screen-density-xhigh/progressing07_big.png differ diff --git a/res/screen-size-normal/IDL_FORM.xml b/res/screen-size-normal/IDL_FORM.xml new file mode 100644 index 0000000..dc8e3b0 --- /dev/null +++ b/res/screen-size-normal/IDL_FORM.xml @@ -0,0 +1,34 @@ + + + + + + 720 +
+ + + + + + + + + + + + +
diff --git a/res/slk-SK.xml b/res/slk-SK.xml new file mode 100644 index 0000000..c2ffa12 --- /dev/null +++ b/res/slk-SK.xml @@ -0,0 +1,14 @@ + + + + Typ domovskej obrazovky + Hotovo + Zrušiť + Nastavenia domovskej obrazovky + Uninstall %ls? + Predvolená domovská obrazovka + Úvodná obrazovka + Nast. domov + diff --git a/res/slv-SI.xml b/res/slv-SI.xml new file mode 100644 index 0000000..61e6bff --- /dev/null +++ b/res/slv-SI.xml @@ -0,0 +1,14 @@ + + + + Vrsta domačega zaslona + Končano + Prekliči + Nastavitve domačega zaslona + Uninstall %ls? + Privzeti domači zaslon + Domači zaslon + Nast. domov + diff --git a/res/spa-ES.xml b/res/spa-ES.xml new file mode 100644 index 0000000..a52c333 --- /dev/null +++ b/res/spa-ES.xml @@ -0,0 +1,14 @@ + + + + Tipo de pantalla de inicio + Guardar + Cancelar + Ajustes de la pantalla de inicio + Uninstall %ls? + Pantalla de inicio predeterminada + Pantalla de inicio + Def inicio + diff --git a/res/spa-MX.xml b/res/spa-MX.xml new file mode 100644 index 0000000..369012a --- /dev/null +++ b/res/spa-MX.xml @@ -0,0 +1,14 @@ + + + + Tipo de pantalla de inicio + Realizado + Cancelar + Configuración de pantalla de inicio + Uninstall %ls? + Pantalla de inicio predeterminada + Pantalla de inicio + Def. inicio + diff --git a/res/srp-RS.xml b/res/srp-RS.xml new file mode 100644 index 0000000..309b868 --- /dev/null +++ b/res/srp-RS.xml @@ -0,0 +1,14 @@ + + + + Tip početnog ekrana + Gotovo + Poništi + Podešavanja početnog ekrana + Uninstall %ls? + Podrazumevani početni ekran + Početni ekran + Kao početni + diff --git a/res/swe-SE.xml b/res/swe-SE.xml new file mode 100644 index 0000000..a1a6f7e --- /dev/null +++ b/res/swe-SE.xml @@ -0,0 +1,14 @@ + + + + Typ för startsida + Klar + Avbryt + Inställningar för hemskärmen + Uninstall %ls? + Standardhemskärm + Hemskärm + Ange st.sid + diff --git a/res/tur-TR.xml b/res/tur-TR.xml new file mode 100644 index 0000000..4754210 --- /dev/null +++ b/res/tur-TR.xml @@ -0,0 +1,14 @@ + + + + Ana ekran tipi + Tamamlandı + İptal + Ana ekran ayarları + Uninstall %ls? + Varsayılan ana ekran + Ana sayfa ekranı + Ana syf yap + diff --git a/res/ukr-UA.xml b/res/ukr-UA.xml new file mode 100644 index 0000000..c364030 --- /dev/null +++ b/res/ukr-UA.xml @@ -0,0 +1,14 @@ + + + + Тип головного екрана + Готово + Скасувати + Установки головного екрана + Uninstall %ls? + Головний екран за замовчанням + Головний екран + Вст.як дом. + diff --git a/res/uzb-UZ.xml b/res/uzb-UZ.xml new file mode 100644 index 0000000..9da8d58 --- /dev/null +++ b/res/uzb-UZ.xml @@ -0,0 +1,14 @@ + + + + Asosiy ekran turi + Bajarildi + Bekor qilish + Asosiy ekran parametrlari + Uninstall %ls? + Birlamchi o‘rnatma bo‘yicha asosiy ekran + Asosiy ekran + Asosiy kabi + diff --git a/res/zho-CN.xml b/res/zho-CN.xml new file mode 100644 index 0000000..f0a57bd --- /dev/null +++ b/res/zho-CN.xml @@ -0,0 +1,14 @@ + + + + 主屏类型 + 完成 + 取消 + 主屏设置 + Uninstall %ls? + 默认主屏 + 主屏 + 设为主页 + diff --git a/res/zho-HK.xml b/res/zho-HK.xml new file mode 100644 index 0000000..353fd4f --- /dev/null +++ b/res/zho-HK.xml @@ -0,0 +1,14 @@ + + + + 主螢幕類型 + 完成 + 取消 + 主螢幕設定 + Uninstall %ls? + 預設主螢幕 + 主螢幕 + 設為首頁 + diff --git a/res/zho-SG.xml b/res/zho-SG.xml new file mode 100644 index 0000000..2e4fa37 --- /dev/null +++ b/res/zho-SG.xml @@ -0,0 +1,14 @@ + + + + 主屏类型 + 已完成 + 取消 + 主屏设置 + Uninstall %ls? + 默认主屏 + 主屏 + 设置为首页 + diff --git a/res/zho-TW.xml b/res/zho-TW.xml new file mode 100644 index 0000000..353fd4f --- /dev/null +++ b/res/zho-TW.xml @@ -0,0 +1,14 @@ + + + + 主螢幕類型 + 完成 + 取消 + 主螢幕設定 + Uninstall %ls? + 預設主螢幕 + 主螢幕 + 設為首頁 + diff --git a/shared/data/nofile.dummy b/shared/data/nofile.dummy new file mode 100644 index 0000000..e69de29 diff --git a/shared/res/screen-density-xhigh/mainmenu.png b/shared/res/screen-density-xhigh/mainmenu.png new file mode 100644 index 0000000..b0979b1 Binary files /dev/null and b/shared/res/screen-density-xhigh/mainmenu.png differ diff --git a/shared/trusted/nofile.dummy b/shared/trusted/nofile.dummy new file mode 100644 index 0000000..e69de29 diff --git a/src/HmApplicationUtils.cpp b/src/HmApplicationUtils.cpp new file mode 100644 index 0000000..dc0480a --- /dev/null +++ b/src/HmApplicationUtils.cpp @@ -0,0 +1,315 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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 exprs or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file HmApplicationUtils.cpp + * @brief Keeps the implementations for Utility functions, + * Implementations of the various Utility function which may be used throughout the application + */ + +#include +#include +#include +#include +#include +#include "HmApplicationUtils.h" +#include "HmTypes.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Media; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +Bitmap* +ApplicationUtils::GetApplicationIconBitmapN(const String& imagePath, const String& appCaption, bool isResourceBitmap) +{ + result r = E_SUCCESS; + Canvas* pCanvas = null; + Bitmap* pBitmap = null; + Bitmap* pAppIconBitmap = null; + EnrichedText appEnrichedCaption; + EnrichedText appEnrichedShadowCaption; + TryReturn(!imagePath.IsEmpty(), null, "Invalid Parameter"); + + if (isResourceBitmap) + { + pBitmap = GetResourceBitmapN(imagePath); + } + + if (pBitmap == null) + { + pBitmap = GetBitmapN(imagePath); + // creates bitmap for the icon if is default icon path + if (pBitmap == null) + { + pBitmap = GetResourceBitmapN(IDB_DEFAULT_APP_ICON); + } + } + + TryCatch(pBitmap != null, , "Failed to create bitmap"); + + if (pBitmap->GetHeight() != APP_ICON_IMAGE_SIZE || pBitmap->GetWidth() != APP_ICON_IMAGE_SIZE) + { + pBitmap->Scale(Dimension(APP_ICON_IMAGE_SIZE, APP_ICON_IMAGE_SIZE)); + } + // get a Canvas instance + pCanvas = new (std::nothrow) Canvas(); + TryCatch(pCanvas != null, , "Failed to allocate for Canvas"); + + r = pCanvas->Construct(Rectangle(0, 0, W_APPLICATION_ICON, H_APPLICATION_ICON)); + TryCatch(r == E_SUCCESS, , "pCanvas->Construct failed with error %s", GetErrorMessage(r)); + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + r = pCanvas->DrawBitmap(Point((W_APPLICATION_ICON - pBitmap->GetWidth()) / 2, Y_APP_ICON_IMAGE_START) /*, APP_ICON_IMAGE_SIZE, APP_ICON_IMAGE_SIZE)*/, *pBitmap); + TryCatch(r == E_SUCCESS, , "pCanvas->DrawBitmap failed with error %s", GetErrorMessage(r)); + + if (!appCaption.IsEmpty()) + { + Font font; + String fontToUse; + TextElement captionElement; + + IList* pFontsList = Font::GetSystemFontListN(); + + if (pFontsList != null) + { + IEnumerator* pEnum = pFontsList->GetEnumeratorN(); + + if (pEnum != null) + { + while (pEnum->MoveNext() == E_SUCCESS) + { + String* pFontName = static_cast(pEnum->GetCurrent()); + + if (pFontName && pFontName->Contains(L"HelveticaNeue")) + { + fontToUse = *pFontName; + break; + } + } + + delete pEnum; + pEnum = null; + } + + pFontsList->RemoveAll(true); + delete pFontsList; + pFontsList = null; + } + + if (fontToUse.IsEmpty()) + { + r = font.Construct(FONT_STYLE_PLAIN, FONT_SIZE_APP_CAPTION); + TryCatch(r == E_SUCCESS, , "font.Construct failed with error = %s", GetErrorMessage(r)); + } + else + { + AppLogDebug("FontTest :: Calling with font.Construct(name) "); + r = font.Construct(fontToUse, FONT_STYLE_PLAIN, FONT_SIZE_APP_CAPTION); + TryCatch(r == E_SUCCESS, , "font.Construct failed with error = %s", GetErrorMessage(r)); + } + + // app name text + r = captionElement.Construct(appCaption); + TryCatch(r == E_SUCCESS, , "captionElement.Construct failed with error = %s", GetErrorMessage(r)); + captionElement.SetTextColor(COLOR_APP_ICON_CAPTION); + captionElement.SetFont(font); + captionElement.SetOutlineColor(COLOR_APP_CAPTION_SHADOW1); + appEnrichedCaption.Construct(Dimension(W_APPLICATION_ICON, H_APP_CAPTION_TEXT)); + appEnrichedCaption.SetHorizontalAlignment(TEXT_ALIGNMENT_CENTER); + appEnrichedCaption.SetVerticalAlignment(TEXT_ALIGNMENT_MIDDLE); + appEnrichedCaption.SetTextWrapStyle(TEXT_WRAP_NONE); + appEnrichedCaption.SetTextAbbreviationEnabled(true); + appEnrichedCaption.Add(captionElement); + + // app name shadow text + TextElement shadowCaptionElement; + r = shadowCaptionElement.Construct(appCaption); + TryCatch(r == E_SUCCESS, , "shadowCaptionElement.Construct failed with error = %s", GetErrorMessage(r)); + shadowCaptionElement.SetTextColor(COLOR_APP_CAPTION_SHADOW2); + shadowCaptionElement.SetFont(font); + shadowCaptionElement.SetOutlineColor(COLOR_APP_CAPTION_SHADOW2); + appEnrichedShadowCaption.Construct(Dimension(W_APPLICATION_ICON, H_APP_CAPTION_TEXT)); + appEnrichedShadowCaption.SetHorizontalAlignment(TEXT_ALIGNMENT_CENTER); + appEnrichedShadowCaption.SetVerticalAlignment(TEXT_ALIGNMENT_MIDDLE); + appEnrichedShadowCaption.SetTextWrapStyle(TEXT_WRAP_NONE); + appEnrichedShadowCaption.SetTextAbbreviationEnabled(true); + appEnrichedShadowCaption.Add(shadowCaptionElement); + + pCanvas->DrawText(Point(0, Y_APP_ICON_IMAGE_START + APP_ICON_IMAGE_SIZE + 2), appEnrichedShadowCaption); + pCanvas->DrawText(Point(0, Y_APP_ICON_IMAGE_START + APP_ICON_IMAGE_SIZE), appEnrichedCaption); + } + + pAppIconBitmap = new (std::nothrow) Bitmap(); + TryCatch(pAppIconBitmap != null, , "Failed to allocate for Bitmap"); + r = pAppIconBitmap->Construct(*pCanvas, Rectangle(0, 0, W_APPLICATION_ICON, H_APPLICATION_ICON)); + TryCatch(r == E_SUCCESS, , "pCanvas->Construct failed with error %s", GetErrorMessage(r)); + + if (pBitmap != null) + { + delete pBitmap; + pBitmap = null; + } + + if (pCanvas != null) + { + delete pCanvas; + pCanvas = null; + } + + return pAppIconBitmap; + +CATCH: + + if (pBitmap != null) + { + delete pBitmap; + pBitmap = null; + } + + if (pCanvas != null) + { + delete pCanvas; + pCanvas = null; + } + + if (pAppIconBitmap != null) + { + delete pAppIconBitmap; + pAppIconBitmap = null; + } + + return null; +} + +Bitmap* +ApplicationUtils::GetBitmapN(const String& imageAbsolutePath) +{ + result r = E_SUCCESS; + Bitmap* pBitmap = null; + Image* pImage = new (std::nothrow) Image(); + + String fullname; + fullname.Append(imageAbsolutePath); + + if (pImage != null) + { + r = pImage->Construct(); + // goes to CATCH to release memory and return null if failed to construct Image + TryCatch(r == E_SUCCESS, , "Image Construct Failed = (%s)\n", GetErrorMessage(r)); + // creates bitmap for the specified path of the image which is of jpeg format. + if (fullname.EndsWith(L"jpg") || fullname.EndsWith(L"JPG") || fullname.EndsWith(L"jpeg") || fullname.EndsWith(L"JPEG")) + { + pBitmap = pImage->DecodeN(fullname, BITMAP_PIXEL_FORMAT_RGB565); + } + // creates bitmap for the specified path of the image which is of bmp format. + else if (fullname.EndsWith(L"bmp") || fullname.EndsWith(L"BMP")) + { + pBitmap = pImage->DecodeN(fullname, BITMAP_PIXEL_FORMAT_RGB565); + } + // creates bitmap for the specified path of the image which is of png and wbmp formats. + else if (fullname.EndsWith(L"png") || fullname.EndsWith(L"PNG") || fullname.EndsWith(L"wbmp") || fullname.EndsWith(L"WBMP")) + { + pBitmap = pImage->DecodeN(fullname, BITMAP_PIXEL_FORMAT_ARGB8888); + } + // creates bitmap for the specified path of the image which is of gif format. + else if (fullname.EndsWith(L"gif") || fullname.EndsWith(L"GIF")) + { + pBitmap = pImage->DecodeN(fullname, BITMAP_PIXEL_FORMAT_RGB565); + } + + // goes to CATCH to release memory and return null if failed to construct bitmap + TryCatch(pBitmap != null, , "not found image path or not enough memory %ls error = %s", fullname.GetPointer() + , GetErrorMessage(GetLastResult())); + + delete pImage; + return pBitmap; + } + +CATCH: + + if (pImage != null) + { + delete pImage; + } + + return null; +} + +Bitmap* +ApplicationUtils::GetResourceBitmapN(const String& imageName) +{ + //sanity test + TryReturn(!imageName.IsEmpty(), null, "Invalid parameter"); + + AppResource* pAppResource = UiApp::GetInstance()->GetAppResource(); + Bitmap* pBitmap = null; + + // creates bitmap for the specified image name from the application resource. + pBitmap = pAppResource->GetBitmapN(imageName, BITMAP_PIXEL_FORMAT_ARGB8888); + + TryReturn(pBitmap != null, pBitmap, "failed to create bitmap error = %s", GetErrorMessage(GetLastResult())); + + return pBitmap; +} + +result +ApplicationUtils::GetStringResource(const String& stringId, String& retString) +{ + result r = E_INVALID_ARG; + + if (!stringId.IsEmpty()) + { + AppResource* pAppResource = UiApp::GetInstance()->GetAppResource(); + r = pAppResource->GetString(stringId, retString); + } + + return r; +} + +//Shows delete confirmation message box +int +ApplicationUtils::ShowDeletePopup(String& applicationName) +{ + MessageBox messsageBox; + String message; + String messageTitle; + String displayMessage; + int modalResult = 0; + //get the resource string + GetStringResource(L"IDS_IDLE_POP_UNINSTALL_PS_Q", message); + //format the message by including the application name + displayMessage.Format(256, message.GetPointer(), applicationName.GetPointer()); + messsageBox.Construct(messageTitle, displayMessage, MSGBOX_STYLE_YESNO); + //Show message box and wait for user response + messsageBox.ShowAndWait(modalResult); + + return modalResult; +} + +ApplicationUtils::ApplicationUtils(void) +{ + // No implementation required +} + +ApplicationUtils::~ApplicationUtils(void) +{ + // No implementation required +} diff --git a/src/HmCustomIconListProvider.cpp b/src/HmCustomIconListProvider.cpp new file mode 100644 index 0000000..7138b70 --- /dev/null +++ b/src/HmCustomIconListProvider.cpp @@ -0,0 +1,228 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmCustomIconListProvider.cpp = false; + * @brief This is the implementation for the IconListItemProviderCustom class + * This class contains the functions which are required managing the IconListView's items + */ + +#include "HmApplicationUtils.h" +#include "HmCustomIconListProvider.h" +#include "HmCustomPageControl.h" +#include "HmHomeItemInfo.h" +#include "HmTypes.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +CustomIconListProvider::CustomIconListProvider(int index) + : __editMode(false) + , __isProjectedItemInvalid(false) + , __index(index) + , __iconsPerPage(0) + , __currentIndex(-1) + , __pPageItemProvider(null) + , __pMovementItem(null) + , __pOverayBitmap(null) +{ + // No implementation required +} + +CustomIconListProvider::~CustomIconListProvider(void) +{ + if (__pOverayBitmap != null) + { + delete __pOverayBitmap; + __pOverayBitmap = null; + } +} + +bool +CustomIconListProvider::GetEditMode(void) const +{ + return __editMode; +} + +IconListViewItem* +CustomIconListProvider::GetMovingItem(void) const +{ + return __pMovementItem; +} + +int +CustomIconListProvider::GetMovingItemIndex() const +{ + return __currentIndex; +} + +IPageControlItemProvider* +CustomIconListProvider::GetPageControlItemProvider(void) +{ + return __pPageItemProvider; +} + +void +CustomIconListProvider::SetEditMode(bool editMode) +{ + // sets the edit mode + __editMode = editMode; + return; +} + +void +CustomIconListProvider::SetIndex(int index) +{ + // sets the index of the provider + __index = index; + return; +} + +void +CustomIconListProvider::SetMaxCountOfIcons(int iconCount) +{ + // sets the maximum number of icons in the page. + __iconsPerPage = iconCount; + return; +} + +void +CustomIconListProvider::SetMovingItem(Tizen::Ui::Controls::IconListViewItem* pMovedItem) +{ + __pMovementItem = pMovedItem; +} + +void +CustomIconListProvider::SetMovingItemIndex(int movedIndex) +{ + __currentIndex = movedIndex; +} + +void +CustomIconListProvider::SetPageControlItemProvider(IPageControlItemProvider* pItemProvider) +{ + __pPageItemProvider = pItemProvider; +} + +void +CustomIconListProvider::SetProjectedItemInvalid(bool isInvalid) +{ + __isProjectedItemInvalid = isInvalid; +} + +IconListViewItem* +CustomIconListProvider::CreateItem(int index) +{ + IconListViewItem* pItem = null; + HomeItemInfo* pItemInfo = null; + + pItemInfo = __pPageItemProvider->GetItem(__index, index); + // if application icon + if (pItemInfo != null) + { + + if (__pMovementItem != null && __currentIndex == index && !__isProjectedItemInvalid) + { + pItem = __pMovementItem; + } + else + { + Bitmap* pItemBitmap = null; + String appName = static_cast(pItemInfo)->GetAppName(); + String iconPath = pItemInfo->GetIconPath(); + + if (!iconPath.IsEmpty()) + { + // gets the application icon if exists + pItemBitmap = pItemInfo->GetApplicationIcon(); + // creates the icon if application icon doesn't exist. + if (pItemBitmap == null) + { + pItemBitmap = ApplicationUtils::GetApplicationIconBitmapN(iconPath, appName); + pItemInfo->SetApplicationIcon(pItemBitmap); + } + } + // constructs the item for the IconListView + if (pItemBitmap != null) + { + pItem = new (std::nothrow) IconListViewItem(); // + pItem->Construct(*pItemBitmap); + } + } + + + if (__editMode) + { + bool showDeleteButton = true; + + if (pItemInfo != null) + { + showDeleteButton = pItemInfo->IsUnistallable(); + } + + if (showDeleteButton) + { + if (__pOverayBitmap == null) + { + __pOverayBitmap = ApplicationUtils::GetResourceBitmapN(IDB_CLOSE_ICON); + } + + if (__pOverayBitmap != null) + { + // adds overlay bitmap to IconListView items if in edit mode. + if (pItem != null) + { + pItem->SetOverlayBitmap(IDA_OVERLAYBITMAP_CLOSE, __pOverayBitmap, ALIGNMENT_RIGHT, ALIGNMENT_TOP); + } + } + } + } + } + return pItem; +} + +bool +CustomIconListProvider::DeleteItem(int index, IconListViewItem* pItem) +{ + if (pItem != null) + { + if (__pMovementItem != null && __pMovementItem->GetHashCode() == pItem->GetHashCode()) + { + return true; + } + + delete pItem; + pItem = null; + return true; + } + + return false; +} + +int +CustomIconListProvider::GetItemCount(void) +{ + if (__pPageItemProvider != null) + { + return __pPageItemProvider->GetItemCount(__index); + } + + return 0; +} diff --git a/src/HmCustomPageControl.cpp b/src/HmCustomPageControl.cpp new file mode 100644 index 0000000..c9877ce --- /dev/null +++ b/src/HmCustomPageControl.cpp @@ -0,0 +1,947 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmCustomPageControl.h + * @brief Keeps implementation of the HmCustomPageControl + * Implements the CustomPageControl class, it overrides default scrolling functionality of IconListView + */ + +#include +#include +#include "HmApplicationUtils.h" +#include "HmCustomIconListProvider.h" +#include "HmCustomPageControl.h" +#include "HmCustomPageMarker.h" +#include "HmHomeItemInfo.h" +#include "HmICustomPageControlEventListener.h" +#include "HmTypes.h" + +using namespace Tizen::App; +using namespace Tizen::App::Package; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Ui::Controls; + +CustomPageControl::CustomPageControl(void) + : __hasPageMoved(false) + , __isDragging(false) + , __isInEditMode(false) + , __needAnimation(false) + , __pDraggingAppInfo(null) + , __pEventListener(null) + , __currentIndex(-1) + , __currentPageNumber(0) + , __iconsCount(MAX_ICONS_PER_PAGE) + , __pageNumber(0) + , __pageToBeDeleted(-1) + , __pageWidth(W_DEFAULT_PAGE) + , __startIndex(-1) + , __sweepTraveled(0) + , __totalPages(1) + , __pPageItemProvider(null) + , __pIconListProviders(null) + , __pIconLists(null) + , __pPageMovementTimer(null) + , __pMovingItemBitmap(null) + , __animationEndPoint(0, 0) + , __animationStartPoint(0, 0) + , __dragStartPosition(0, 0) + , __iconListCurrentPos(0, 0) + , __iconListRestPosition(0, 0) + , __touchStartPoint(0, 0) + , __pMovementItem(null) + , __pMovementLabel(null) + , __pGetureDetector(null) +{ + //no implementation required +} + +CustomPageControl::~CustomPageControl(void) +{ + if (__pPageMovementTimer != null) + { + __pPageMovementTimer->Cancel(); + delete __pPageMovementTimer; + __pPageMovementTimer = null; + } + + if (__pIconLists != null) + { + __pIconLists->RemoveAll(false); //the controls will be deleted using removeControl calls by framework + delete __pIconLists; + } + + if (__pIconListProviders != null) + { + __pIconListProviders->RemoveAll(true); + delete __pIconListProviders; + } + + if (__pGetureDetector != null) + { + __pGetureDetector->RemoveLongPressGestureEventListener(*this); + delete __pGetureDetector; + } +} + +result +CustomPageControl::Construct(const Rectangle& controlRect, int noOfPages, + int pageWidth) +{ + result r = E_SUCCESS; + int width = noOfPages* pageWidth; + int xPos = X_PAGE_POSITION; + int yPos = 0; + String iconListViewNameBase; + + r = Panel::Construct(controlRect); + TryCatch(r == E_SUCCESS, , "Panel::Construct(controlRect) failed with error = %s", GetErrorMessage(r)); + __totalPages = noOfPages; + __pageWidth = pageWidth; + __currentPageNumber = 1; + __pIconLists = new (std::nothrow) ArrayList(); + __pIconLists->Construct(); + + __pGetureDetector = new (std::nothrow) TouchLongPressGestureDetector(); + __pGetureDetector->Construct(); + __pGetureDetector->SetDuration(LONG_TOUCH_GESTURE_DURATION); + __pGetureDetector->AddLongPressGestureEventListener(*this); + + __pIconListProviders = new (std::nothrow) ArrayList(); + __pIconListProviders->Construct(); + SetSize(Dimension(width, controlRect.height)); + + for (int pageNumber = 1; pageNumber <= __totalPages; pageNumber++) + { + IconListView* pIconListView = new (std::nothrow) IconListView(); + + if (pIconListView != null) + { + CustomIconListProvider* pProvider = null; + r = pIconListView->Construct(Rectangle(xPos, yPos, __pageWidth /*- (2 * POSITION_OFFSET)*/, (controlRect.height)), Dimension(W_APPLICATION_ICON, H_APPLICATION_ICON), + ICON_LIST_VIEW_STYLE_NORMAL, ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL); + + TryCatch(r == E_SUCCESS, delete pIconListView; + pIconListView = null, "pIconListView->Construct pageNumber %d error %s", pageNumber, GetErrorMessage(r)); + + String iconListName(iconListViewNameBase); + iconListName.Append(pageNumber); + pIconListView->SetName(iconListName); + pIconListView->SetMargin(MARGIN_TYPE_LEFT, 0); + pIconListView->SetMargin(MARGIN_TYPE_RIGHT, 0); + pIconListView->SetTextOfEmptyList(L""); + pIconListView->SetItemTextSize(FONT_SIZE_APP_CAPTION); + pIconListView->SetTouchAnimationEnabled(false); + pIconListView->AddTouchEventListener(*this); + pIconListView->AddGestureDetector(*__pGetureDetector); + pIconListView->SetItemSpacing(GAP_ICON_HORIZONTAL, GAP_ICON_VERTICAL); + pIconListView->AddIconListViewItemEventListener(*this); + + pProvider = new (std::nothrow) CustomIconListProvider(pageNumber); + + if (pProvider != null) + { + pProvider->SetMaxCountOfIcons(__iconsCount); + __pIconListProviders->Add(pProvider); + + pIconListView->SetItemProvider(*pProvider); + AddControl(*pIconListView); + __pIconLists->Add(pIconListView); + xPos += __pageWidth; + } + else + { + if (pIconListView != null) + { + delete pIconListView; + pIconListView = null; + } + } + } + } + + __pMovementLabel = new (std::nothrow) Label(); + r = __pMovementLabel->Construct(Rectangle(0, 0, W_APPLICATION_ICON, H_APPLICATION_ICON), L""); + TryCatch(r == E_SUCCESS, , "__pLabel->Construct failed with error %s", GetErrorMessage(r)); + __pMovementLabel->SetShowState(false); + + r = AddControl(*__pMovementLabel); + TryCatch(r == E_SUCCESS, , "AddControl(*__pLabel)failed with error %s", GetErrorMessage(r)); + + return r; + +CATCH: + + if (__pIconLists != null) + { + delete __pIconLists; + __pIconLists = null; + } + + if (__pIconListProviders != null) + { + __pIconListProviders->RemoveAll(true); + delete __pIconListProviders; + __pIconListProviders = null; + } + + return r; +} + +result +CustomPageControl::AddPage(void) +{ + if (__totalPages > MAX_PAGE_COUNT) + { + return E_FAILURE; + } + + result r = E_SUCCESS; + Rectangle currentBounds = GetBounds(); + IconListView* pIconListView = null; + String iconListName; + CustomIconListProvider* pProviderTemp = null; + int xPos = currentBounds.width + X_PAGE_POSITION; + + __totalPages++; + pIconListView = new (std::nothrow) IconListView(); + r = pIconListView->Construct(Rectangle(xPos, 0, __pageWidth - (2 * X_PAGE_POSITION), (currentBounds.height)), + Dimension(W_APPLICATION_ICON, H_APPLICATION_ICON), ICON_LIST_VIEW_STYLE_NORMAL, ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL); + TryCatch(r == E_SUCCESS, , "pIconListView->Construct failed with error %s", GetErrorMessage(r)); + iconListName.Append(__totalPages); + pIconListView->SetName(iconListName); + // adds IconListViewItemEventListener for the IconListView + pIconListView->AddTouchEventListener(*this); + pIconListView->AddIconListViewItemEventListener(*this); + pIconListView->SetMargin(MARGIN_TYPE_LEFT, 0); + pIconListView->SetMargin(MARGIN_TYPE_RIGHT, 0); + pIconListView->SetTouchAnimationEnabled(false); + // Sets the vertical alignment of the text of IconListView item + pIconListView->AddGestureDetector(*__pGetureDetector); + pIconListView->SetItemSpacing(GAP_ICON_HORIZONTAL, GAP_ICON_VERTICAL); + + pProviderTemp = new (std::nothrow) CustomIconListProvider(__totalPages); + pProviderTemp->SetPageControlItemProvider(static_cast(__pIconListProviders->GetAt(0))->GetPageControlItemProvider()); + pProviderTemp->SetEditMode(__isInEditMode); + r = __pIconListProviders->Add(pProviderTemp); + TryCatch(r == E_SUCCESS, delete pProviderTemp; + pProviderTemp = null, "__pIconListProviders->Add(pProviderTemp) %s", GetErrorMessage(r)); + // sets provider for the IconListView + pIconListView->SetItemProvider(*pProviderTemp); + + __pIconLists->Add(pIconListView); + TryCatch(r == E_SUCCESS, , "__pIconLists->Add(pIconListView) %s", GetErrorMessage(r)); + + currentBounds.width += __pageWidth; + SetBounds(currentBounds); + r = AddControl(*pIconListView); + TryCatch(r == E_SUCCESS, , "AddControl(*pIconListView) %s", GetErrorMessage(r)); + SetControlAlwaysOnTop(*__pMovementLabel, true); + + if (__pEventListener != null) + { + __pEventListener->OnPageAdded(__totalPages); + } + + return r; + +CATCH: + + if (pIconListView != null) + { + delete pIconListView; + pIconListView = null; + } + + return r; +} + +int +CustomPageControl::GetCurrentSelectedPage(void) +{ + return __currentPageNumber; +} + +ArrayList* +CustomPageControl::GetIconLists(void) +{ + return __pIconLists; +} + +const int +CustomPageControl::GetPageCount(void) +{ + return __totalPages; +} + +void +CustomPageControl::MarkPageToDelete(int pageNumber) +{ + if (pageNumber > 1 && pageNumber <= __totalPages) + { + SetPageSelected(pageNumber - 1); + + __pageToBeDeleted = pageNumber; + + if (__pPageMovementTimer == null) + { + __pPageMovementTimer = new (std::nothrow) Timer(); + __pPageMovementTimer->Construct(*this); + } + + __pPageMovementTimer->Cancel(); + __pPageMovementTimer->Start(MOVEMENT_UPDATE_DURATION); + } + return; +} + +void +CustomPageControl::MovePage(void) +{ + __pEventListener->OnPageSwept(__pageNumber); + SetPageSelected(__pageNumber); + __hasPageMoved = true; + __isDragging = true; + + if (__pPageMovementTimer == null) + { + __pPageMovementTimer = new Timer(); + __pPageMovementTimer->Construct(*this); + } + + __pPageMovementTimer->Start(MOVEMENT_UPDATE_DURATION); + return; +} + +void +CustomPageControl::SetMaxNumberOfIcons(int iconsCount) +{ + __iconsCount = iconsCount; +} + +void +CustomPageControl::SetPageControlEventListener(ICustomPageControlEventListener* pListener) +{ + __pEventListener = pListener; + return; +} + +void +CustomPageControl::SetPageControlItemProvider(IPageControlItemProvider* pItemProvider) +{ + __pPageItemProvider = pItemProvider; + + for (int providerCount = 0; providerCount < __pIconListProviders->GetCount(); providerCount++) + { + CustomIconListProvider* pProvider = static_cast(__pIconListProviders->GetAt(providerCount)); + + if (pProvider != null) + { + pProvider->SetPageControlItemProvider(pItemProvider); + } + } +} + +void +CustomPageControl::SetPageSelected(int pageNumber) +{ + if (__currentPageNumber == pageNumber || pageNumber < 1 || pageNumber > __totalPages) + { + return; + } + else + { + Point newPosition = GetPosition(); + + if (pageNumber > __totalPages && pageNumber <= MAX_PAGE_COUNT + 1) + { + // pageNumber = __totalPages; + AddPage(); + } + + __animationStartPoint = GetPosition(); + newPosition.x = (pageNumber - 1) * (-__pageWidth); + __animationEndPoint = newPosition; + __currentPageNumber = pageNumber; + __needAnimation = true; + + if (__pPageMovementTimer == null) + { + __pPageMovementTimer = new Timer(); + __pPageMovementTimer->Construct(*this); + } + + __pPageMovementTimer->Start(SCROLL_ANIMATION_DURATION); + + } + return; + +} + +void +CustomPageControl::ToggleEditMode(void) +{ + if (!__isInEditMode) + { + IEnumerator* pIconListViewEnum = __pIconLists->GetEnumeratorN(); + IEnumerator* pIconListProviderEnum = __pIconListProviders->GetEnumeratorN(); + + while (!IsFailed(pIconListViewEnum->MoveNext()) && !IsFailed(pIconListProviderEnum->MoveNext())) + { + IconListView* pIconListView = static_cast(pIconListViewEnum->GetCurrent()); + + if (pIconListView != null) + { + CustomIconListProvider* pProvider = static_cast + (pIconListProviderEnum->GetCurrent()); + if (pProvider != null) + { + pProvider->SetEditMode(true); + // updates the edit mode value + __isInEditMode = true; + // updates list to add overlay bitmap to provide uninstall option. + pIconListView->UpdateList(); + } + } + } + delete pIconListViewEnum; + delete pIconListProviderEnum; + + } + else + { + IEnumerator* pIconListViewEnum = __pIconLists->GetEnumeratorN(); + IEnumerator* pIconListProviderEnum = __pIconListProviders->GetEnumeratorN(); + + while (!IsFailed(pIconListViewEnum->MoveNext()) && !IsFailed(pIconListProviderEnum->MoveNext())) + { + IconListView* pIconListView = static_cast(pIconListViewEnum->GetCurrent()); + + if (pIconListView != null) + { + CustomIconListProvider* pProvider = static_cast + (pIconListProviderEnum->GetCurrent()); + + if (pProvider != null) + { + pProvider->SetEditMode(false); + // updates the edit mode value + __isInEditMode = false; + __isDragging = false; + // updates list to remove overlay bitmap. + pIconListView->UpdateList(); + __pMovementLabel->SetShowState(false); + } + } + } + delete pIconListViewEnum; + delete pIconListProviderEnum; + } +} + +void +CustomPageControl::OnIconListViewItemStateChanged(Controls::IconListView& iconListView, int index, Controls::IconListViewItemStatus status) +{ + int pageNumber = 0; + Integer::Parse(iconListView.GetName(), pageNumber); + HomeItemInfo* pItemInfo = static_cast(__pPageItemProvider->GetItem(pageNumber, index)); + // launches the application if its an application icon and if in edit mode + if (pItemInfo != null) + { + if (!__isInEditMode) + { + String appId = static_cast(pItemInfo)->GetAppId(); + AppManager* pAppManager = AppManager::GetInstance(); + + if (pAppManager != null) + { + pAppManager->LaunchApplication(appId); + } + } + } + return; +} + +void +CustomPageControl::OnIconListViewOverlayBitmapSelected(Controls::IconListView& iconListView, int index, int overlayBitmapId) +{ + int pageNumber = 1; + HomeItemInfo* pItemInfo = null; + Integer::Parse(iconListView.GetName(), pageNumber); + + pItemInfo = __pPageItemProvider->GetItem(pageNumber, index); + + if (pItemInfo != null) + { + PackageManager* pPackageManager = null; + String appId = pItemInfo->GetAppId(); + String applicationName = pItemInfo->GetAppName(); + if (ApplicationUtils::ShowDeletePopup(applicationName) != MSGBOX_RESULT_YES) + { + return; + } + + pPackageManager = PackageManager::GetInstance(); + + if (pPackageManager != null) + { + // uninstalls the application + String packageId = pPackageManager->GetPackageIdByAppId(appId); + result r = pPackageManager->UninstallPackage(packageId, null); + + if (IsFailed(r)) + { + AppLogException("UninstallPackage returned %s", GetErrorMessage(r)); + } + else + { + __pEventListener->OnAppUninstallRequested(pItemInfo); + } + } + } +} + +void +CustomPageControl::OnTimerExpired(Timer& timer) +{ + if (__pPageMovementTimer != null && timer.Equals(*__pPageMovementTimer)) + { + if (__needAnimation) + { + result r = E_SUCCESS; + ControlAnimator* pAnimatorLeft = GetControlAnimator(); + + if (pAnimatorLeft->GetStatus() == ANIMATOR_STATUS_PLAYING) + { + r = pAnimatorLeft->StopAllAnimations(); + } + + r = pAnimatorLeft->SetPosition(__animationEndPoint); + + if (IsFailed(r)) + { + AppLogDebug("ScrollCheck::pAnimatorLeft->SetPosition failed %s", GetErrorMessage(r)); + SetPosition(__animationEndPoint); + Invalidate(false); + } + + __needAnimation = false; + return; + + } + + if (__pageToBeDeleted == -1) + { + __hasPageMoved = false; + } + else + { + RemovePage(__pageToBeDeleted); + __pageToBeDeleted = -1; + } + } + + + return; +} + +void +CustomPageControl::OnTouchMoved(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo) +{ + result r = E_SUCCESS; + + if (!__isDragging /*&& !__isInEditMode*/) + { + int panelWidth = GetWidth() - __pageWidth; + int x = 0, y = 0; + GetPosition(x, y); + x = x + (currentPosition.x - __touchStartPoint.x); + + if (x <= 0 && x >= panelWidth - (2* panelWidth)) + { + SetPosition(Point(x, y)); + } + } + else if (__isDragging /* && __isInEditMode*/) + { + + int startPageNumber; + int xMaxBounds; + int xMinBounds; + + r = Integer::Parse(source.GetName(), startPageNumber); + __pageNumber = GetCurrentSelectedPage(); + + xMinBounds = source.GetBounds().x + (source.GetBounds().width) * (__pageNumber - startPageNumber) + X_PAGE_OFFSET; + xMaxBounds = source.GetBounds().x + (source.GetBounds().width) * (__pageNumber - startPageNumber + 1) - X_PAGE_OFFSET; + IconListView* pIconListView = static_cast(__pIconLists->GetAt(__pageNumber - 1)); + CustomIconListProvider* pProvider = static_cast(__pIconListProviders->GetAt(__pageNumber - 1)); + + if ((source.GetBounds().x + currentPosition.x) >= xMaxBounds && !__hasPageMoved) + { + if (!IsFailed(r)) + { + int totalPages = GetPageCount(); + + if (__pageNumber < totalPages) + { + __pageNumber++; + CustomIconListProvider* pProviderTemp = static_cast(__pIconListProviders->GetAt(__pageNumber - 1)); + pProvider->SetProjectedItemInvalid(true); + pProviderTemp->SetMovingItem(__pMovementItem); + pProviderTemp->SetMovingItemIndex(-1); + MovePage(); + } + } + } + else if ((source.GetBounds().x + currentPosition.x) <= xMinBounds && !__hasPageMoved) + { + if (!IsFailed(r)) + { + if (__pageNumber > 1) + { + CustomIconListProvider* pProviderTemp = null; + __pageNumber--; + pProviderTemp = static_cast(__pIconListProviders->GetAt(__pageNumber - 1)); + pProvider->SetProjectedItemInvalid(true); + pProviderTemp->SetMovingItem(__pMovementItem); + pProviderTemp->SetMovingItemIndex(-1); + MovePage(); + } + } + } + else + { + if (pIconListView != null) + { + Point tempCurrentPoint(0, 0); + int pageNumber = 0; + int x = 0; + int y = 0; + int oldIndex = __currentIndex; + // gets the current page number + Integer::Parse(source.GetName(), pageNumber); + x = currentPosition.x - W_DEFAULT_PAGE * (__pageNumber - pageNumber); + y = currentPosition.y; + tempCurrentPoint.SetPosition(x, y); + __currentIndex = pIconListView->GetItemIndexFromPosition(tempCurrentPoint); + + if (__currentIndex != -1) + { + if (__pDraggingAppInfo == null) + { + __pDraggingAppInfo = static_cast(__pPageItemProvider->GetItem(__pageNumber, __startIndex)); + } + + if (__pMovementItem == null) + { + Bitmap* pIconBitmap = __pDraggingAppInfo->GetApplicationIcon(); + __pMovingItemBitmap = new Bitmap(); + __pMovingItemBitmap->Construct(*pIconBitmap, Rectangle(0, 0, pIconBitmap->GetWidth(), pIconBitmap->GetHeight())); + __pMovingItemBitmap->SetAlphaConstant(MOVING_ICON_OPACITY); + __pMovementItem = new (std::nothrow) IconListViewItem(); + __pMovementItem->Construct(*__pMovingItemBitmap); + pProvider->SetMovingItem(__pMovementItem); + pProvider->SetMovingItemIndex(__currentIndex); + pIconListView->RefreshList(__startIndex, LIST_REFRESH_TYPE_ITEM_MODIFY); + } + else if (__currentIndex != oldIndex) + { + HomeItemInfo* pItemInfo = __pPageItemProvider->GetItem(__pageNumber, __currentIndex); + + if (pItemInfo != null) + { + __pPageItemProvider->RearrangeItems(__pDraggingAppInfo, __pageNumber, __currentIndex); + pProvider->SetMovingItemIndex(__currentIndex); + pIconListView->UpdateList(); + } + } + } + } + } + + __pMovementLabel->SetShowState(true); + __pMovementLabel->SetPosition(source.GetBounds().x + currentPosition.x - (W_APPLICATION_ICON / 2), source.GetBounds().y + currentPosition.y - (H_APPLICATION_ICON / 2)); + + } + return; +} + +void +CustomPageControl::OnTouchPressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo) +{ + const IconListView* pSourceControl = static_cast(&source); + __dragStartPosition = currentPosition; + + if (pSourceControl != null) + { + __touchStartPoint.x = currentPosition.x; + __iconListCurrentPos = GetPosition(); + __iconListRestPosition = GetPosition(); + __sweepTraveled = 0; + } + + return; +} + +void +CustomPageControl::OnTouchReleased(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo) +{ + result r = E_SUCCESS; + + if (/*!__isInEditMode &&*/ !__isDragging) + { + Point tempPoint = GetPosition(); + int panelWidth = GetWidth() - __pageWidth; + //int threshold = (GetParent()->GetWidth() / 2); + int threshold = (__pageWidth / 2); + int diff = 0; + + if (tempPoint.x < __iconListCurrentPos.x) + { + diff = (__iconListCurrentPos.x - tempPoint.x); + } + else + { + diff = (tempPoint.x - __iconListCurrentPos.x); + } + + if (diff >= threshold /*|| touchInfo.IsFlicked()*/) + { + // need to scroll horizontally + + if (tempPoint.x > __iconListCurrentPos.x && __currentPageNumber > 1) + { + __currentPageNumber--; + + } + else + { + if (__currentPageNumber < __totalPages) + { + __currentPageNumber++; + } + } + + __iconListCurrentPos.x = (__currentPageNumber - 1) * (__pageWidth) - (2 * (__currentPageNumber - 1) * (__pageWidth)); + + if (__iconListCurrentPos.x <= 0 && __iconListCurrentPos.x >= panelWidth - (2* panelWidth)) + { + ControlAnimator* pAnimatorLeft = GetControlAnimator(); + + if (pAnimatorLeft != null) + { + __needAnimation = true; + __animationStartPoint = GetPosition(); + __animationEndPoint = __iconListCurrentPos; + if (__pPageMovementTimer == null) + { + __pPageMovementTimer = new Timer(); + __pPageMovementTimer->Construct(*this); + } + + __pPageMovementTimer->Start(SCROLL_ANIMATION_DURATION); + } + else + { + r = E_FAILURE; + } + + if (__pEventListener != null) + { + __pEventListener->OnPageSwept(__currentPageNumber); + } + } + } + else + { + if (__iconListRestPosition.x <= 0 && __iconListRestPosition.x >= panelWidth - (2* panelWidth)) + { + int position = (__currentPageNumber - 1) * (__pageWidth); + __iconListRestPosition.x = position - (2* position); + __needAnimation = true; + __animationStartPoint = GetPosition(); + __animationEndPoint = __iconListRestPosition; + + if (__pPageMovementTimer == null) + { + __pPageMovementTimer = new Timer(); + __pPageMovementTimer->Construct(*this); + } + + __pPageMovementTimer->Start(SCROLL_ANIMATION_DURATION); + } + } + } + else + { + if (__isDragging && __startIndex > -1) + { + int pageNumber = 0; + // gets the current page number + Integer::Parse(source.GetName(), pageNumber); + // gets the IconListView of the current page + IconListView* pIconListView = static_cast(__pIconLists->GetAt(__pageNumber - 1)); + + if (pIconListView != null) + { + // gets the index for the current position + for (int providerCount = 0; providerCount < __pIconListProviders->GetCount(); providerCount++) + { + + CustomIconListProvider* pProvider = static_cast(__pIconListProviders->GetAt(providerCount)); + + if (pProvider->GetMovingItemIndex() != -1 || pProvider->GetMovingItem() != null) + { + IconListView* pIconListView = static_cast(__pIconLists->GetAt(__pageNumber - 1)); + pProvider->SetProjectedItemInvalid(true); + pIconListView->RefreshList(pProvider->GetMovingItemIndex(), LIST_REFRESH_TYPE_ITEM_MODIFY); + pProvider->SetMovingItemIndex(-1); + pProvider->SetMovingItem(null); + pProvider->SetProjectedItemInvalid(false); + } + } + + if (__pMovementItem != null) + { + delete __pMovementItem; + __pMovementItem = null; + + if (__pMovingItemBitmap) + { + delete __pMovingItemBitmap; + __pMovingItemBitmap = null; + } + } + + if (__startIndex != __currentIndex && __currentIndex != -1) + { + pIconListView->UpdateList(); + } + + __currentIndex = -1; + __pMovementLabel->SetShowState(false); + __isDragging = false; + __hasPageMoved = false; + __startIndex = -1; + __pDraggingAppInfo = null; + return; + } + } + + __pMovementLabel->SetShowState(false); + __isDragging = false; + __hasPageMoved = false; + } + __sweepTraveled = 0; + return; +} + +void +CustomPageControl::OnLongPressGestureDetected(TouchLongPressGestureDetector& gestureDetector) +{ + if (gestureDetector.Equals(*__pGetureDetector)) + { + if (__isInEditMode && !__isDragging) + { + IconListView* pIconListView = null; + // gets the IconListView of the current page + pIconListView = static_cast(__pIconLists->GetAt(__currentPageNumber - 1)); + + if (pIconListView != null) + { + HomeItemInfo* pItemInfo = null; + // gets the index of the item that is being dragged + __startIndex = pIconListView->GetItemIndexFromPosition(__dragStartPosition); + pItemInfo = __pPageItemProvider->GetItem(__currentPageNumber, __startIndex); + //gets the info of the item that is being dragged + if (pItemInfo != null) + { + __pDraggingAppInfo = pItemInfo; + + if (__pDraggingAppInfo != null) + { + if (__startIndex > -1) + { + Bitmap* pLabelBitmap = null; + __pageNumber = GetCurrentSelectedPage(); + pLabelBitmap = __pDraggingAppInfo->GetApplicationIcon(); + + if (pLabelBitmap == null) + { + String appIconPath = __pDraggingAppInfo->GetIconPath(); + pLabelBitmap = ApplicationUtils::GetBitmapN(appIconPath); + } + + __pMovementLabel->SetBackgroundBitmap(*pLabelBitmap); + __pMovementLabel->Invalidate(false); + __pMovementLabel->SetShowState(true); + __pMovementLabel->SetPosition(pIconListView->GetBounds().x + __dragStartPosition.x - (W_APPLICATION_ICON / 2), pIconListView->GetBounds().y + __dragStartPosition.y - (H_APPLICATION_ICON / 2)); + __isDragging = true; + } + } + } + + } + } + } + + return; +} + +result +CustomPageControl::RemovePage(int pageNumber) +{ + result r = E_SUCCESS; + IconListView* pControl = static_cast(__pIconLists->GetAt(pageNumber - 1)); + + if (pControl != null) + { + RemoveControl(*pControl); + __pIconLists->Remove(*pControl, false); + __pIconListProviders->RemoveAt(pageNumber - 1, true); + + for (int controlCount = pageNumber + 1; controlCount <= __totalPages; controlCount++) + { + String controlName; + IconListView* pControl = null; + controlName.Append(pageNumber); + pControl = static_cast(GetControl(controlName)); + + if (pControl != null) + { + Point curPos = pControl->GetPosition(); + curPos.x -= __pageWidth; + SetPosition(curPos); + } + } + + __totalPages--; + + if (__pEventListener != null) + { + __pEventListener->OnPageRemoved(pageNumber); + } + + Invalidate(true); + } + return r; +} diff --git a/src/HmCustomPageMarker.cpp b/src/HmCustomPageMarker.cpp new file mode 100644 index 0000000..8fd0ead --- /dev/null +++ b/src/HmCustomPageMarker.cpp @@ -0,0 +1,314 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file CustomPageMarker.cpp + * @brief Keeps implementation of the CustomPageMarker + * implements CustomPageMarker class, which contains the top bubble's bar which indicates the page number + */ + + +#include +#include +#include +#include +#include "HmApplicationUtils.h" +#include "HmCustomPageMarker.h" +#include "HmTypes.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Ui::Controls; + +CustomPageMarker::CustomPageMarker(void) + : __pMarkerListener(null) + , __bubbleCount(1) + , __selectedBubble(0) + , __pBubbleLabels(null) + , __pBubbleBitmaps(null) +{ + //No implementation needed +} + +CustomPageMarker::~CustomPageMarker(void) +{ + if (__pBubbleLabels != null) + { + __pBubbleLabels->RemoveAll(false); //the controls will be deleted using removeControl calls by framework + delete __pBubbleLabels; + } + + if (__pBubbleBitmaps != null) + { + __pBubbleBitmaps->RemoveAll(true); + delete __pBubbleBitmaps; + } +} + +result +CustomPageMarker::Construct(const Rectangle& controlRect, int bubbleCount) +{ + result r = E_SUCCESS; + int xPos = 0; + int yPos = Y_MARKER_POSITION; + int width = 0; + int xFactor = 0; + Bitmap* pUnselectedBitmap = null; + Bitmap* pSelectedBitmap = null; + __bubbleCount = bubbleCount; + + r = Panel::Construct(controlRect, GROUP_STYLE_NONE); + TryCatch(r == E_SUCCESS, , "Panel::Construct failed with error %s", GetErrorMessage(r)); + + __pBubbleLabels = new (std::nothrow) ArrayList(); + r = __pBubbleLabels->Construct(); + TryCatch(r == E_SUCCESS, , "__pLabels->Construct(); failed with error %s", GetErrorMessage(r)); + + __pBubbleBitmaps = new (std::nothrow) ArrayList(); + r = __pBubbleBitmaps->Construct(); + pUnselectedBitmap = ApplicationUtils::GetResourceBitmapN(IDB_BUBBLE_TOP); + + if (pUnselectedBitmap != null) + { + __pBubbleBitmaps->Add(pUnselectedBitmap); + } + + for (int bubbleCountTemp = 1; bubbleCountTemp <= __bubbleCount; bubbleCountTemp++) + { + String bubbleName(IDB_SELECTED_BUBBLE_TOP); + bubbleName.Append(bubbleCountTemp); + bubbleName.Append(BITMAP_EXTENSION); + pSelectedBitmap = ApplicationUtils::GetResourceBitmapN(bubbleName); + + if (pSelectedBitmap != null) + { + __pBubbleBitmaps->Add(pSelectedBitmap); + } + } + + width = (controlRect.width); + xFactor = width - ((W_MARKER_LABEL * __bubbleCount) + (X_MARKER_LABEL_OFFSET * (__bubbleCount - 1))); + + xPos = xFactor / 2; + + for (int bubbleCount = 1; bubbleCount <= __bubbleCount; bubbleCount++) + { + Label* pLabel = new (std::nothrow) Label(); + String labelName; + labelName.Append(bubbleCount); + + if (pLabel != null) + { + Rectangle labelRect(xPos, yPos, W_MARKER_LABEL, H_MARKER_LABEL); + pLabel->Construct(labelRect, L""); + pLabel->SetBackgroundBitmap(*static_cast(__pBubbleBitmaps->GetAt(0))); + pLabel->SetTextColor(Color::GetColor(COLOR_ID_BLACK)); + pLabel->SetTextHorizontalAlignment(ALIGNMENT_CENTER); + pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pLabel->SetName(labelName); + pLabel->AddTouchEventListener(*this); + AddControl(*pLabel); + __pBubbleLabels->Add(pLabel); + xPos += W_MARKER_LABEL + X_MARKER_LABEL_OFFSET; + } + } + + return r; + +CATCH: + + if (__pBubbleLabels != null) + { + delete __pBubbleLabels; + __pBubbleLabels = null; + } + return r; +} + +result +CustomPageMarker::AddBubble(void) +{ + result r = E_SUCCESS; + Rectangle controlRect = GetBounds(); + int width = 0; + int xFactor = 0; + int xPos = 0; + int yPos = Y_MARKER_POSITION; + Label* pLabel = null; + String labelName; + __bubbleCount++; + + width = (controlRect.width); + xFactor = width - ((W_MARKER_LABEL * __bubbleCount) + (X_MARKER_LABEL_OFFSET * (__bubbleCount - 1))); + + xPos = xFactor / 2; + + for (int bubbleCount = 1; bubbleCount < __bubbleCount; bubbleCount++) + { + String labelName; + labelName.Append(bubbleCount); + Label* pLabel = static_cast(GetControl(labelName)); + + if (pLabel != null) + { + Rectangle labelRect(xPos, yPos, W_MARKER_LABEL, H_MARKER_LABEL); + pLabel->SetBounds(labelRect); + xPos += (X_MARKER_LABEL_OFFSET + W_MARKER_LABEL); + } + } + + pLabel = new (std::nothrow) Label(); + labelName.Append(__bubbleCount); + + if (pLabel != null) + { + String bubbleName(IDB_SELECTED_BUBBLE_TOP); + Bitmap* pNewBubbleBitmap = null; + Rectangle labelRect(xPos, yPos, W_MARKER_LABEL, H_MARKER_LABEL); + pLabel->Construct(labelRect, L""); + bubbleName.Append(__bubbleCount); + bubbleName.Append(BITMAP_EXTENSION); + pNewBubbleBitmap = ApplicationUtils::GetResourceBitmapN(bubbleName); + + if (pNewBubbleBitmap != null) + { + __pBubbleBitmaps->Add(pNewBubbleBitmap); + } + + pLabel->SetBackgroundBitmap(*static_cast(__pBubbleBitmaps->GetAt(0))); + pLabel->SetTextColor(Color::GetColor(COLOR_ID_BLACK)); + pLabel->SetTextHorizontalAlignment(ALIGNMENT_CENTER); + pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pLabel->SetName(labelName); + pLabel->AddTouchEventListener(*this); + r = AddControl(*pLabel); + __pBubbleLabels->Add(pLabel); + xPos += (W_MARKER_LABEL + X_MARKER_LABEL_OFFSET); + } + return r; +} + +const int +CustomPageMarker::GetBubbleCount(void) +{ + return __bubbleCount; +} + +result +CustomPageMarker::RemoveBubble(int bubbleNo) +{ + result r = E_SUCCESS; + Label* pLabel = static_cast(__pBubbleLabels->GetAt(bubbleNo - 1)); + + if (pLabel != null) + { + RemoveControl(bubbleNo - 1); + __pBubbleLabels->RemoveAt(bubbleNo - 1, false); + __pBubbleBitmaps->RemoveAt(bubbleNo, true); + + for (int bubbleCount = bubbleNo; bubbleCount < __bubbleCount; bubbleCount++) + { + Label* pLabel = static_cast(GetControl(bubbleCount)); + + if (pLabel != null) + { + Point curPos = pLabel->GetPosition(); + curPos.x -= (W_MARKER_LABEL + X_MARKER_LABEL_OFFSET); + pLabel->SetPosition(curPos); + } + } + + RequestRedraw(true); + __bubbleCount--; + } + return r; +} + +void +CustomPageMarker::SetPageMarkerEventListener(ICustomPageMarkerEventListener* pListner) +{ + __pMarkerListener = pListner; + return; +} + +void +CustomPageMarker::SetSelectedBubble(int bubbleNumber) +{ + TryReturnVoid(bubbleNumber != __selectedBubble, "Passed page is already being shown"); + String controlName; + controlName.Append(bubbleNumber); + Label* pLabel = null; + + if (__selectedBubble != 0) + { + String controlName; + controlName.Append(__selectedBubble); + Label* pLabel = static_cast(GetControl(controlName)); + + if (pLabel != null) + { + Bitmap* pBitmapToBeSet = null; + pLabel->SetText(L""); + + pBitmapToBeSet = static_cast(__pBubbleBitmaps->GetAt(0)); + + if (pBitmapToBeSet != null) + { + pLabel->SetBackgroundBitmap(*pBitmapToBeSet); + } + pLabel->RequestRedraw(true); + __selectedBubble = bubbleNumber; + } + } + + pLabel = static_cast(GetControl(controlName)); + + if (pLabel != null) + { + Bitmap* pBitmapToBeSet = null; + pBitmapToBeSet = static_cast(__pBubbleBitmaps->GetAt(bubbleNumber)); + + if (pBitmapToBeSet != null) + { + pLabel->SetBackgroundBitmap(*pBitmapToBeSet); + } + + pLabel->RequestRedraw(true); + __selectedBubble = bubbleNumber; + } + + return; +} + +void +CustomPageMarker::OnTouchReleased(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo) +{ + if (__pMarkerListener != null) + { + String controlName = source.GetName(); + + if (!controlName.IsEmpty()) + { + int bubbleNumber = 0; + Integer::Parse(controlName, bubbleNumber); + __pMarkerListener->OnMarkerBubbleMoved(bubbleNumber); + } + } + return; +} diff --git a/src/HmGenericDatabaseManager.cpp b/src/HmGenericDatabaseManager.cpp new file mode 100644 index 0000000..b487ed0 --- /dev/null +++ b/src/HmGenericDatabaseManager.cpp @@ -0,0 +1,679 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmGenericDatabaseManager.cpp + * @brief Keeps the Implementation of GenericDatabaseManager and related interfaces + * declaration of the various functions which may be needed for various database operations + */ + +#include +#include "HmGenericDatabaseManager.h" +#include "HmTypes.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Io; + +GenericDatabaseManager* GenericDatabaseManager::__pDatabaseManager = null; + +void +GenericDatabaseManager::DestroyInstance(void) +{ + if (__pDatabaseManager != null) + { + delete __pDatabaseManager; + __pDatabaseManager = null; + } +} + +GenericDatabaseManager* +GenericDatabaseManager::GetInstance(void) +{ + if (__pDatabaseManager == null) + { + CreateInstance(); + } + return __pDatabaseManager; +} + +result +GenericDatabaseManager::CreateDataBase(const String& databaseName) +{ + result r = E_INVALID_ARG; + String folderName(databaseName); + int indexOfDirectory = 0; + //Santiy test + TryReturn(!databaseName.IsEmpty(), r, "Invalid argument passed"); + + if (__pDatabase != null) + { + if (__pDatabase->GetName().Equals(databaseName, true)) + { + return E_SUCCESS; + } + else + { + delete __pDatabase; + __pDatabase = null; + } + } + + folderName.LastIndexOf(L'/', databaseName.GetLength() - 1, indexOfDirectory); + folderName.Remove(indexOfDirectory, (folderName.GetLength() - indexOfDirectory)); + Directory::Create(folderName, true); + __pDatabase = new (std::nothrow) Database(); + TryReturn(__pDatabase != null, E_OUT_OF_MEMORY, "unable to allocate memory for Database"); + r = __pDatabase->Construct(databaseName, "a+"); + TryCatch(r == E_SUCCESS, , "__pDatabase->Construct(databaseName, a+) failed with error %s", GetErrorMessage(r)); + + return r; + +CATCH: + + if (__pDatabase != null) + { + delete __pDatabase; + __pDatabase = null; + } + + return r; +} + +result +GenericDatabaseManager::CreateTable(const String& tableName, ArrayList* pColumnNames, ArrayList* pColumnTypes) +{ + result r = E_INVALID_ARG; + + TryReturn((!tableName.IsEmpty() || pColumnNames != null || pColumnTypes != null), r, "Invalid arguments"); + + if (__pDatabase != null) + { + String queryText(CREATE_TABLE); + queryText.Append(tableName); + queryText.Append(L"("); + + for (int paramCount = 0; paramCount < pColumnNames->GetCount(); paramCount++) + { + String* name = static_cast(pColumnNames->GetAt(paramCount)); + String* type = static_cast(pColumnTypes->GetAt(paramCount)); + + queryText.Append(*name); + queryText.Append(L" "); + queryText.Append(*type); + + if (paramCount == pColumnNames->GetCount() - 1) + { + queryText.Append(L")"); + } + else + { + queryText.Append(L","); + } + } + + r = __pDatabase->BeginTransaction(); + + if (r == E_SUCCESS) + { + r = __pDatabase->ExecuteSql(queryText, true); + + if (IsFailed(r)) + { + __pDatabase->RollbackTransaction(); + } + TryReturn(r == E_SUCCESS, r, + "__pDatabase->ExecuteSql(queryStr, true) failed %s", GetErrorMessage(r)); + r = __pDatabase->CommitTransaction(); + TryReturn(r == E_SUCCESS, r, + "__pDatabase->CommitTransaction() failed %s", GetErrorMessage(r)); + } + } + return r; +} + +result +GenericDatabaseManager::DeleteFromTable(const String& tableName, const String& whereCondition) +{ + result r = E_INVALID_ARG; + //sanity test + TryReturn(!tableName.IsEmpty() || !whereCondition.IsEmpty(), r, "Invalid argument passed"); + String query(DELETE_TABLE); + query.Append(tableName); + query.Append(L" "); + query.Append(L"WHERE "); + query.Append(whereCondition); + + if (__pDatabase != null) + { + __pDatabase->BeginTransaction(); + r = __pDatabase->ExecuteSql(query, true); + + if (IsFailed(r)) + { + AppLogException("__pDatabase->ExecuteSql(query,true); returned with %s", GetErrorMessage(r)); + __pDatabase->RollbackTransaction(); + } + else + { + __pDatabase->CommitTransaction(); + } + } + return r; +} + +result +GenericDatabaseManager::GetDataRowFromTable(const String& tableName, const String& whereCondition, Collection::HashMap& rowDataHashMap) +{ + result r = E_SUCCESS; + // Prepare Column info + DbEnumerator* pDbEnumerator = null; + String query = SELECT_TABLE; + + query.Append(tableName); + query.Append(L" "); + query.Append(L"WHERE "); + query.Append(whereCondition); + pDbEnumerator = __pDatabase->QueryN(query); + + if (pDbEnumerator == null) + { + AppLogException("GetDataRowFromTable returning error %s", GetErrorMessage(GetLastResult())); + return GetLastResult(); + } + + pDbEnumerator->MoveNext(); + + for (int paramCount = 0; paramCount < pDbEnumerator->GetColumnCount(); paramCount++) + { + Object* pValue = null; + DbColumnType columnType = pDbEnumerator->GetColumnType(paramCount); + String* pColumnName = null; + + if (columnType == DB_COLUMNTYPE_INT) + { + int tempIntVal = 0; + r = pDbEnumerator->GetIntAt(paramCount, tempIntVal); +// TryContinue(retVal, pValue, +// "pDbEnumerator->GetIntAt failed with error %s",GetErrorMessage(retVal)); + pValue = new (std::nothrow) Integer(tempIntVal); + + if (pValue == null) + { + continue; + } + } + else if (columnType == DB_COLUMNTYPE_INT64) + { + long long tempLongVal = 0; + r = pDbEnumerator->GetInt64At(paramCount, tempLongVal); +// TryContinue(retVal, pLongValue, +// "pDbEnumerator->GetInt64At failed with error %s",GetErrorMessage(retVal)); + pValue = new (std::nothrow) LongLong(tempLongVal); + + if (pValue == null) + { + continue; + } + } + else if (columnType == DB_COLUMNTYPE_DOUBLE) + { + double tempDoubleVal; + r = pDbEnumerator->GetDoubleAt(paramCount, tempDoubleVal); +// TryContinue(retVal, pDoubleValue, +// "pDbEnumerator->GetDoubleAt failed with error %s",GetErrorMessage(retVal)); + pValue = new (std::nothrow) Double(tempDoubleVal); + + if (pValue == null) + { + continue; + } + + } + else if (columnType == DB_COLUMNTYPE_TEXT) + { + String* pTextValue = new (std::nothrow) String(); + + if (pTextValue == null) + { + continue; + } + r = pDbEnumerator->GetStringAt(paramCount, *pTextValue); + + if (IsFailed(r)) + { + delete pTextValue; + pTextValue = null; + continue; + } + pValue = pTextValue; + } + else if (columnType == DB_COLUMNTYPE_BLOB) + { + ByteBuffer* pBlobValue = new (std::nothrow) ByteBuffer(); + + if (pBlobValue == null) + { + continue; + } + + r = pDbEnumerator->GetBlobAt(paramCount, *pBlobValue); + + if (IsFailed(r)) + { + delete pBlobValue; + pBlobValue = null; + continue; + } + + pValue = pBlobValue; + } + + if (pValue != null) + { + pColumnName = new (std::nothrow) String(pDbEnumerator->GetColumnName(paramCount)); + + if (pColumnName == null) + { + delete pValue; + pValue = null; + r = E_OUT_OF_MEMORY; + continue; + } + + r = rowDataHashMap.Add(pColumnName, pValue); + } + } + + delete pDbEnumerator; + pDbEnumerator = null; + + return r; +} + +int +GenericDatabaseManager::GetLastAddedRowID(const String& tableName) +{ + int rowId = -1; + TryReturn(!tableName.IsEmpty(), E_INVALID_ARG, "Invalid arguments"); + + if (__pDatabase != null) + { + String query = GET_LAST_RECORD_ID; + DbEnumerator* pDbEnumerator = null; + query.Append(tableName); + pDbEnumerator = __pDatabase->QueryN(query); + + if (pDbEnumerator != null) + { + while (pDbEnumerator->MoveNext() == E_SUCCESS) + { + for (int paramCount = 0; paramCount < pDbEnumerator->GetColumnCount(); paramCount++) + { + DbColumnType columnType = pDbEnumerator->GetColumnType(paramCount); + + if (columnType == DB_COLUMNTYPE_INT) + { + pDbEnumerator->GetIntAt(paramCount, rowId); + break; + } + } + } + + delete pDbEnumerator; + pDbEnumerator = null; + } + } + + return rowId; +} + +result +GenericDatabaseManager::InsertToTable(const String& tableName, ArrayList* pColumnNames, ArrayList* pColumnTypes, ArrayList* pColumnValues) +{ + result r = E_SUCCESS; + TryReturn((!tableName.IsEmpty() || pColumnNames != null || pColumnValues != null), E_INVALID_ARG, "Invalid arguments"); + + if (__pDatabase != null) + { + DbEnumerator* pDbEnum = null; + DbStatement* pDbStatement = null; + String query(INSERT_TABLE); + query.Append(tableName); + query.Append(L"("); + //Prepare Transaction + r = __pDatabase->BeginTransaction(); + + if (r == E_SUCCESS) + { + for (int paramCount = 0; paramCount < pColumnNames->GetCount(); paramCount++) + { + String* name = static_cast(pColumnNames->GetAt(paramCount)); + query.Append(*name); + + if (paramCount == pColumnNames->GetCount() - 1) + { + query.Append(L")"); + } + else + { + query.Append(L","); + } + } + + query.Append(L" "); + query.Append(L"VALUES"); + query.Append(L" ("); + + for (int paramCount = 0; paramCount < pColumnValues->GetCount(); paramCount++) + { + query.Append(L" ? "); + + if (paramCount == pColumnNames->GetCount() - 1) + { + query.Append(L")"); + } + else + { + query.Append(L","); + } + } + + pDbStatement = __pDatabase->CreateStatementN(query); + + if (pDbStatement != null) + { + for (int colIndex = 0; colIndex < pColumnValues->GetCount(); colIndex++) + { + + Integer* columnInttype = static_cast(pColumnTypes->GetAt(colIndex)); + + DbColumnType columnType = (DbColumnType) columnInttype->ToInt(); + + if (columnType == DB_COLUMNTYPE_INT) + { + Integer* pIntValue = static_cast(pColumnValues->GetAt(colIndex)); + + if (pIntValue != null && pIntValue->ToInt() == -1) + { + pDbStatement->BindNull(colIndex); + } + else + { + pDbStatement->BindInt(colIndex, pIntValue->ToInt()); + } + } + else if (columnType == DB_COLUMNTYPE_INT64) + { + LongLong* pLongValue = static_cast(pColumnValues->GetAt(colIndex)); + pDbStatement->BindInt64(colIndex, pLongValue->ToLong()); + } + else if (columnType == DB_COLUMNTYPE_DOUBLE) + { + Double* pDoubleValue = static_cast(pColumnValues->GetAt(colIndex)); + pDbStatement->BindDouble(colIndex, pDoubleValue->ToDouble()); + } + else if (columnType == DB_COLUMNTYPE_TEXT) + { + String* pTextValue = static_cast(pColumnValues->GetAt(colIndex)); + pDbStatement->BindString(colIndex, *pTextValue); + } + else if (columnType == DB_COLUMNTYPE_BLOB) + { + ByteBuffer* pBlobValue = static_cast(pColumnValues->GetAt(colIndex)); + pDbStatement->BindBlob(colIndex, *pBlobValue); + } + else + { + continue; + } + } + + pDbEnum = __pDatabase->ExecuteStatementN(*pDbStatement); + + if (GetLastResult() == E_SUCCESS) + { + r = __pDatabase->CommitTransaction(); + } + else + { + r = __pDatabase->RollbackTransaction(); + } + + if (IsFailed(r)) + { + AppLogDebug("__pDatabase->CommitTransaction() failed result = %s", GetErrorMessage(r)); + __pDatabase->RollbackTransaction(); + } + + if (pDbStatement != null) + { + delete pDbStatement; + pDbStatement = null; + } + + + if (pDbEnum != null) + { + delete pDbEnum; + pDbEnum = null; + } + } + else + { + r = __pDatabase->RollbackTransaction(); + } + } + else + { + r = __pDatabase->RollbackTransaction(); + } + } + return r; + +} + +result +GenericDatabaseManager::UpdateTable(const String& tableName, ArrayList* pColumnsToModify, ArrayList* pColumnTypes, ArrayList* pColumnsNewData, const String* pWhereCondition) +{ + TryReturn((!tableName.IsEmpty() || pColumnsToModify != null || pColumnsNewData != null || pWhereCondition != null), E_INVALID_ARG, + "Invalid arguments"); + + result r = E_SUCCESS; + String query = UPDATE_TABLE; + query.Append(tableName); + query.Append(L" SET "); + + for (int columnNumber = 0; columnNumber < pColumnsToModify->GetCount(); columnNumber++) + { + String* pColName = static_cast(pColumnsToModify->GetAt(columnNumber)); + query.Append(*pColName); + query.Append(L" = "); + query.Append(L"?"); + + if (columnNumber == pColumnsToModify->GetCount() - 1) + { + query.Append(L" "); + } + else + { + query.Append(L","); + } + } + + query.Append(L"WHERE "); + query.Append(*pWhereCondition); + + if (__pDatabase != null) + { + DbStatement* pDbStatement = null; + + r = __pDatabase->BeginTransaction(); + pDbStatement = __pDatabase->CreateStatementN(query); + + if (pDbStatement != null) + { + DbEnumerator* pDbEnum = null; + + for (int colIndex = 0; colIndex < pColumnsNewData->GetCount(); colIndex++) + { + Integer* columnInttype = static_cast(pColumnTypes->GetAt(colIndex)); + + DbColumnType columnType = (DbColumnType) columnInttype->ToInt(); + + + if (columnType == DB_COLUMNTYPE_INT) + { + Integer* pIntValue = static_cast(pColumnsNewData->GetAt(colIndex)); + pDbStatement->BindInt(colIndex, pIntValue->ToInt()); + } + else if (columnType == DB_COLUMNTYPE_INT64) + { + LongLong* pLongValue = static_cast(pColumnsNewData->GetAt(colIndex)); + pDbStatement->BindInt64(colIndex, pLongValue->ToLong()); + } + else if (columnType == DB_COLUMNTYPE_DOUBLE) + { + Double* pDoubleValue = static_cast(pColumnsNewData->GetAt(colIndex)); + pDbStatement->BindDouble(colIndex, pDoubleValue->ToDouble()); + } + else if (columnType == DB_COLUMNTYPE_TEXT) + { + String* pTextValue = static_cast(pColumnsNewData->GetAt(colIndex)); + if (pTextValue != null) + { + if (pTextValue->IsEmpty()) + { + pDbStatement->BindNull(colIndex); + } + else + { + pDbStatement->BindString(colIndex, *pTextValue); + } + } + } + else if (columnType == DB_COLUMNTYPE_BLOB) + { + ByteBuffer* pBlobValue = static_cast(pColumnsNewData->GetAt(colIndex)); + pDbStatement->BindBlob(colIndex, *pBlobValue); + } + else + { + continue; + } + } + + pDbEnum = __pDatabase->ExecuteStatementN(*pDbStatement); + + if (pDbEnum == null) + { + r = GetLastResult(); + AppLogException("__pDatabase->ExecuteStatementN returned error %s", GetErrorMessage(r)); + } + + if (!IsFailed(r)) + { + r = __pDatabase->CommitTransaction(); + } + + if (pDbEnum != null) + { + if (pDbEnum->GetColumnCount() < 1) + { + r = E_SUCCESS; + } + delete pDbEnum; + pDbEnum = null; + } + if (pDbStatement != null) + { + delete pDbStatement; + pDbStatement = null; + } + } + else + { + r = GetLastResult(); + AppLogException("Create statement failed with error %s", GetErrorMessage(r)); + __pDatabase->RollbackTransaction(); + } + + + } + return r; +} + +GenericDatabaseManager::GenericDatabaseManager(void) + : __pDatabase(null) +{ + //no implementation required +} + +GenericDatabaseManager::~GenericDatabaseManager(void) +{ + if (__pDatabase != null) + { + delete __pDatabase; + } +} + +void +GenericDatabaseManager::CreateInstance(void) +{ + __pDatabaseManager = new (std::nothrow) GenericDatabaseManager(); + + if (__pDatabaseManager != null) + { + std::atexit(DestroyInstance); + } +} + +DbColumnType +GenericDatabaseManager::GetColumnType(DbEnumerator* dbEnumerator, String* pColumnName) +{ + TryReturn(dbEnumerator != null || pColumnName != null, DB_COLUMNTYPE_UNDEFINED, "Invalid parameters passed"); + + for (int columnNumber = 0; columnNumber < dbEnumerator->GetColumnCount(); columnNumber++) + { + String colName = dbEnumerator->GetColumnName(columnNumber); + + if (pColumnName->Equals(colName, false)) + { + return dbEnumerator->GetColumnType(columnNumber); + } + } + + return DB_COLUMNTYPE_UNDEFINED; +} + +int +GenericDatabaseManager::GetColumnIndex(DbEnumerator* dbEnumerator, String* pColumnName) +{ + TryReturn(dbEnumerator != null || pColumnName != null, -1, "Invalid parameters passed"); + + for (int columnNumber = 0; columnNumber < dbEnumerator->GetColumnCount(); columnNumber++) + { + String columnName = dbEnumerator->GetColumnName(columnNumber); + + if (pColumnName->Equals(columnName, false)) + { + return columnNumber; + } + } + + return -1; + +} diff --git a/src/HmHomeApp.cpp b/src/HmHomeApp.cpp new file mode 100644 index 0000000..1fbde71 --- /dev/null +++ b/src/HmHomeApp.cpp @@ -0,0 +1,219 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmHomeApp.cpp + * @brief Keeps implementation of UiApp derived class. + */ + +#include +#include +#include "HmHomeApp.h" +#include "HmHomeForm.h" +#include "HmMainFrame.h" +#include "HmHomePresentationModel.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::System; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + + +HomeApp::HomeApp(void) + : __presentationModelInitialized(false) + , __pHomeForm(null) + , __pPresentationModel(null) +{ + //No implementation needed +} + +HomeApp::~HomeApp(void) +{ + //No implementation needed +} + +UiApp* +HomeApp::CreateInstance(void) +{ + // Create the instance through the constructor. + return new (std::nothrow) HomeApp(); +} + +bool +HomeApp::OnAppInitialized(void) +{ + __pHomeForm = null; + MainFrame* pMainFrame = null; + bool retVal = true; + result r = E_SUCCESS; + // Create a Frame + pMainFrame = new (std::nothrow) MainFrame(); + r = pMainFrame->Construct(); + TryCatch(r == E_SUCCESS, retVal = false, " pHmMainFrame.>Construct() failed with error %s", GetErrorMessage(r)); + r = AddFrame(*pMainFrame); + TryCatch(r == E_SUCCESS, retVal = false; + delete pMainFrame; + pMainFrame = null, "AddFrame(*pHmMainFrame. failed with error %s", GetErrorMessage(r)); + // Create a form + __pHomeForm = new (std::nothrow) HomeForm(); + __pHomeForm->Initialize(); + // Add the form to the frame + r = pMainFrame->AddControl(*__pHomeForm); + TryCatch(r == E_SUCCESS, retVal = false, "pHmMainFrame.>AddControl(*__pHomeForm) failed with error %s", GetErrorMessage(r)); + // Set the current form + pMainFrame->SetCurrentForm(*__pHomeForm); + + // Draw the form + __pHomeForm->Draw(); + + if (__presentationModelInitialized) + { + __pHomeForm->InitializePageControls(__pPresentationModel); + } + + return retVal; + +CATCH: + + if (__pHomeForm != null) + { + delete __pHomeForm; + __pHomeForm = null; + } + + if (pMainFrame != null) + { + delete pMainFrame; + pMainFrame = null; + } + return retVal; + +} + + +bool +HomeApp::OnAppInitializing(AppRegistry& appRegistry) +{ + __pPresentationModel = new (std::nothrow) HomePresentationModel(); + __pPresentationModel->Construct(); + return true; +} + +bool +HomeApp::OnAppWillTerminate(void) +{ + // Comment. + return true; +} + + +bool +HomeApp::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination) +{ + // Deallocate resources allocated by this App for termination. + // The App's permanent data and context can be saved via appRegistry. + return true; +} + +void +HomeApp::OnForeground(void) +{ + if (__pHomeForm != null) + { + __pHomeForm->UpdateAllPages(); + } + + return; +} + +void +HomeApp::OnBackground(void) +{ + // TODO: + // Stop drawing when the application is moved to the background. + return; +} + +void +HomeApp::OnLowMemory(void) +{ + // TODO: + // Free unused resources or close the application. + return; +} + +void +HomeApp::OnBatteryLevelChanged(BatteryLevel batteryLevel) +{ + // TODO: + // Handle any changes in battery level here. + // Stop using multimedia features(camera, mp3 etc.) if the battery level is CRITICAL. + return; +} + +void +HomeApp::OnScreenOn(void) +{ + // TODO: + // Get the released resources or resume the operations that were paused or stopped in OnScreenOff(). + return; +} + +void +HomeApp::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. + return; +} + +void +HomeApp::OnUserEventReceivedN(RequestId requestId, IList* pArgs) +{ + switch (requestId) + { + case MODEL_REQUEST_INITIALIZE: + { + __presentationModelInitialized = true; + + if (__pHomeForm != null) + { + __pHomeForm->InitializePageControls(__pPresentationModel); + } + } + break; + + default: + { + //no implementation required + } + break; + + } + + if (pArgs != null) + { + pArgs->RemoveAll(true); + delete pArgs; + pArgs = null; + } +} diff --git a/src/HmHomeEntry.cpp b/src/HmHomeEntry.cpp new file mode 100644 index 0000000..6275923 --- /dev/null +++ b/src/HmHomeEntry.cpp @@ -0,0 +1,70 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmHomeAppEntry.cpp + * @brief This file contains the Tizen application entry point. + */ + +#include "HmHomeApp.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_OUT_OF_MEMORY; + + AppLogDebug("Application started."); + ArrayList* pArgs = new (std::nothrow) ArrayList(); + + if (pArgs == null) + { + return r; + } + + r = pArgs->Construct(); + + TryCatch(r == E_SUCCESS, , "pArgs->Construct() failed with error %s", GetErrorMessage(r)); + + for (int i = 0; i < argc; i++) + { + pArgs->Add((new (std::nothrow) String(pArgv[i]))); + } + + r = Tizen::App::UiApp::Execute(HomeApp::CreateInstance, pArgs); + + TryCatch(r == E_SUCCESS, r &= 0x0000FFFF, "Application execution failed-[%s].", GetErrorMessage(r)); +CATCH: + pArgs->RemoveAll(true); + delete pArgs; + AppLogDebug("Application finished."); + return static_cast(r); +} +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/src/HmHomeForm.cpp b/src/HmHomeForm.cpp new file mode 100644 index 0000000..abb6e45 --- /dev/null +++ b/src/HmHomeForm.cpp @@ -0,0 +1,659 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmHomeForm.cpp + * @brief Keeps implementation of Main Form of the application + */ + +#include +#include +#include +#include +#include "HmApplicationUtils.h" +#include "HmHomeForm.h" +#include "HmHomeItemInfo.h" +#include "HmProgressPanel.h" +#include "HmTypes.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::System; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Ui::Controls; + +HomeForm::HomeForm(void) + : __isEditEnabled(false) + , __isLanguageChanged(false) + , __pPageControl(null) + , __pPageMarker(null) + , __pHomePresentationModel(null) + , __pProgressPanel(null) + , __pBackgroundBitmap(null) + , __pSettingsBitmap(null) + , __pSettingsPressedBitmap(null) + , __pBackgroundLabel(null) + , __pSettingsPanel(null) +{ +} + +HomeForm::~HomeForm(void) +{ + SettingInfo::RemoveSettingEventListener(*this); + + if (__pHomePresentationModel != null) + { + __pHomePresentationModel->SetHomePackageEventListener(null); + delete __pHomePresentationModel; + } + + if (__pBackgroundBitmap != null) + { + delete __pBackgroundBitmap; + __pBackgroundBitmap = null; + } + + if (__pSettingsBitmap != null) + { + delete __pSettingsBitmap; + } + + if (__pSettingsPressedBitmap != null) + { + delete __pSettingsPressedBitmap; + } +} + +bool +HomeForm::Initialize(void) +{ + Construct(L"IDL_FORM"); + return true; +} + +result +HomeForm::InitializePageControls(HomePresentationModel* pPresentationModel) +{ + result r = E_SUCCESS; + + if (__pHomePresentationModel == null) + { + int pageCount = 0; + IconListView* pIconListView = null; + __pHomePresentationModel = pPresentationModel; + __pHomePresentationModel->SetHomePackageEventListener(this); + + pageCount = __pHomePresentationModel->GetPageCount(); + + while (__pPageControl->GetPageCount() < pageCount) + { + __pPageControl->AddPage(); + } + + for (int iconListCount = 0; iconListCount < __pPageControl->GetIconLists()->GetCount(); iconListCount++) + { + pIconListView = static_cast(__pPageControl->GetIconLists()->GetAt(iconListCount)); + pIconListView->UpdateList(); + } + + + if (__pProgressPanel != null) + { + //return value ignored as this is just for showing wait cursor and should not disturb application flow + __pProgressPanel->StopAnimation(); + } + + Invalidate(true); + } + return r; +} + +void +HomeForm::UpdatePage(ArrayList* pPageList) +{ + ArrayList* pIconLists = __pPageControl->GetIconLists(); + + for (int updateCount = 0; updateCount < pPageList->GetCount(); updateCount++) + { + IconListView* pIconList = null; + int pageNumber = static_cast(pPageList->GetAt(updateCount))->ToInt(); + + if ((pageNumber) == pIconLists->GetCount() + 1) + { + __pPageControl->AddPage(); + } + + pIconList = static_cast(pIconLists->GetAt(pageNumber - 1)); + + if (pIconList != null) + { + pIconList->UpdateList(); + } + } + +} + +result +HomeForm::OnInitializing(void) +{ + result r = E_SUCCESS; + String wallPaperPath; + Rectangle clientRectangle = GetClientAreaBounds(); + Rectangle markerRect = GetBounds(); + Rectangle pageRect = GetBounds(); + Label* pSettingLabel = null; + Label* pDoneLabel = null; + __pSettingsPanel = static_cast(GetControl(L"IDC_SETTING_PANEL")); + __pSettingsPanel->SetBounds(X_SETTING_PANEL, Y_SETTING_PANEL, W_SETTING_PANEL, H_SETTING_PANEL); + __pSettingsPanel->SetBackgroundColor(Color(0, 0, 0, 0)); + + SetControlAlwaysOnTop(*__pSettingsPanel, true); + r = SettingInfo::GetValue(SETTINGS_KEY_WALLPAPER, wallPaperPath); + + if (!wallPaperPath.IsEmpty()) + { + __pBackgroundBitmap = ApplicationUtils::GetBitmapN(wallPaperPath); + } + else + { + __pBackgroundBitmap = ApplicationUtils::GetResourceBitmapN(IDB_BACKGROUND_IMAGE); + } + + SettingInfo::GetValue(SETTINGS_KEY_LANGUAGE, __currentLanguage); + r = SettingInfo::AddSettingEventListener(*this); + + if (__pBackgroundBitmap != null) + { + clientRectangle.x = clientRectangle.y = 0; + __pBackgroundLabel = static_cast(GetControl(L"IDC_BACKGROUND_LABEL")); + __pBackgroundLabel->SetBounds(clientRectangle); + __pBackgroundLabel->SetBackgroundBitmap(*__pBackgroundBitmap); + } + + pDoneLabel = static_cast(__pSettingsPanel->GetControl(L"IDC_DONE_LABEL")); + pDoneLabel->SetShowState(false); + pDoneLabel->AddTouchEventListener(*this); + pSettingLabel = static_cast(__pSettingsPanel->GetControl(L"IDC_SETTING_LABEL")); + pSettingLabel->AddTouchEventListener(*this); + __pSettingsPanel->SetControlAlwaysOnTop(*pSettingLabel, true); + + clientRectangle.x = clientRectangle.y = 0; + __pProgressPanel = new (std::nothrow) ProgressPanel(); + r = __pProgressPanel->Construct(clientRectangle); + r = AddControl(*__pProgressPanel); + //return value egnored as this is just for showing wait curser and should not disturb app flow + __pProgressPanel->StartAnimation(); + + clientRectangle = __pSettingsPanel->GetBounds(); + markerRect = GetClientAreaBounds(); + markerRect.height = H_PAGE_MARKER; + markerRect.y = 0; + markerRect.x = X_MARKER_POSITION; //rect.x + rect.width + 2; + markerRect.width -= (2 * W_MARKER_OFFSET); + __pPageMarker = new (std::nothrow) CustomPageMarker(); + r = __pPageMarker->Construct(markerRect, 1); + TryCatch(r == E_SUCCESS, delete __pPageMarker; + __pPageMarker = null, "__pPageMarker->Construct failed with error %s", GetErrorMessage(r)); + __pPageMarker->SetSelectedBubble(1); + __pPageMarker->SetPageMarkerEventListener(this); + r = AddControl(*__pPageMarker); + TryCatch(r == E_SUCCESS, delete __pPageMarker; + __pPageMarker = null, "AddControl failed"); + + pageRect = GetClientAreaBounds(); + pageRect.y = markerRect.height; + pageRect.x = 0; + pageRect.height -= markerRect.height; + + __pPageControl = new (std::nothrow) CustomPageControl(); + r = __pPageControl->Construct(pageRect, 1, pageRect.width); + TryCatch(r == E_SUCCESS, delete __pPageControl; + __pPageControl = null, "__pPageMarker->Construct failed with error %s", GetErrorMessage(r)); + __pPageControl->SetMaxNumberOfIcons(MAX_ICONS_PER_PAGE); + __pPageControl->SetPageControlEventListener(this); + __pPageControl->SetPageControlItemProvider(this); + r = AddControl(*__pPageControl); + TryCatch(r == E_SUCCESS, delete __pPageControl; + __pPageControl = null, "AddControl failed"); + + return r; + +CATCH: + + if (__pPageControl != null) + { + delete __pPageControl; + __pPageControl = null; + } + + if (__pPageMarker != null) + { + delete __pPageMarker; + __pPageMarker = null; + } + + return r; +} + +result +HomeForm::OnTerminating(void) +{ + __pHomePresentationModel->UpdatePageData(); + return E_SUCCESS; +} + +void +HomeForm::OnSettingChanged(String& key) +{ + + if (key.CompareTo(SETTINGS_KEY_WALLPAPER) == 0) + { + result r = E_SUCCESS; + String wallPaperPath; + + r = SettingInfo::GetValue(SETTINGS_KEY_WALLPAPER, wallPaperPath); + + if (!wallPaperPath.IsEmpty() && r == E_SUCCESS) + { + if (__pBackgroundBitmap != null) + { + delete __pBackgroundBitmap; + __pBackgroundBitmap = null; + } + + __pBackgroundBitmap = ApplicationUtils::GetBitmapN(wallPaperPath); + + if (__pBackgroundBitmap != null) + { + __pBackgroundLabel->SetBackgroundBitmap(*__pBackgroundBitmap); + __pBackgroundLabel->Invalidate(false); + } + } + } + else if (key.CompareTo(SETTINGS_KEY_LANGUAGE) == 0) + { + String selectedLang; + SettingInfo::GetValue(SETTINGS_KEY_LANGUAGE, selectedLang); + + if (selectedLang.CompareTo(__currentLanguage) != 0) + { + __currentLanguage = selectedLang; + __isLanguageChanged = true; + __pHomePresentationModel->LanguageChanged(); + + if (UiApp::GetInstance()->GetAppUiState() != APP_UI_STATE_BACKGROUND) + { + ArrayList* pIconLists = null; + Label* pDoneLabel = static_cast(__pSettingsPanel->GetControl(L"IDC_DONE_LABEL")); + + if (pDoneLabel != null) + { + String doneString; + ApplicationUtils::GetStringResource(L"IDS_COM_POP_DONE", doneString); + pDoneLabel->SetText(doneString); + pDoneLabel->Invalidate(false); + } + + pIconLists = __pPageControl->GetIconLists(); + + if (pIconLists != null) + { + for (int iconListCount = 0; iconListCount < pIconLists->GetCount(); iconListCount++) + { + IconListView* pIconListView = static_cast(pIconLists->GetAt(iconListCount)); + if (pIconListView) + { + pIconListView->UpdateList(); + } + } + } + + } + } + } + + return; +} + +void +HomeForm::OnTouchReleased(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo) +{ + if (source.GetName().CompareTo(L"IDC_SETTING_LABEL") == 0 + || source.GetName().CompareTo(L"IDC_DONE_LABEL") == 0) + { + Label* pDoneLabel = null; + Label* pSettingLabel = null; + ControlAnimator* pDoneAnimator = null; + ControlAnimator* pSettingLabelAnimator = null; + Bitmap* pBitmap = null; + Point settingPosition(0, 0); + + __isEditEnabled = !__isEditEnabled; + __pPageControl->ToggleEditMode(); + pDoneLabel = static_cast(__pSettingsPanel->GetControl(L"IDC_DONE_LABEL")); + pDoneAnimator = pDoneLabel->GetControlAnimator(); + pDoneAnimator->SetShowState(__isEditEnabled); + pSettingLabel = static_cast(__pSettingsPanel->GetControl(L"IDC_SETTING_LABEL")); + pSettingLabelAnimator = pSettingLabel->GetControlAnimator(); + settingPosition = pSettingLabel->GetPosition(); + + if (__isEditEnabled) + { + settingPosition.x = 0; + } + else + { + settingPosition.x = X_SETTING_PANEL_PRESSED_OFFSET; + } + + if (__isEditEnabled) + { + Canvas* pCanvas = null; + Rectangle settingRectangle = __pSettingsPanel->GetBounds(); + int pointOffset = 0; + int sizeOffset = SIZE_SETTING_LABEL_OFFSET; + + if (__pSettingsPressedBitmap == null) + { + __pSettingsPressedBitmap = ApplicationUtils::GetResourceBitmapN(IDB_SETTING_BUTTON_PRESSED); + } + pBitmap = __pSettingsPressedBitmap; + + settingRectangle.x = pointOffset; + settingRectangle.y = pointOffset; + settingRectangle.width -= sizeOffset; + settingRectangle.height -= sizeOffset; + + pCanvas = __pSettingsPanel->GetCanvasN(); + + if (pCanvas != null) + { + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + pCanvas->SetBackgroundColor(Color::GetColor(COLOR_ID_BLACK)); + pCanvas->SetLineWidth(1); + pCanvas->SetForegroundColor(Color::GetColor(COLOR_ID_BLACK)); + pCanvas->DrawRectangle(settingRectangle); + pCanvas->SetForegroundColor(COLOR_SETTING_BOUNDARY_INNER); + + pointOffset = sizeOffset; + sizeOffset = 2 * SIZE_SETTING_LABEL_OFFSET; + settingRectangle.x = pointOffset; + settingRectangle.y = pointOffset; + settingRectangle.width -= sizeOffset; + settingRectangle.height -= sizeOffset; + pCanvas->DrawRectangle(settingRectangle); + + pointOffset = sizeOffset; + settingRectangle.x = pointOffset; + settingRectangle.y = pointOffset; + settingRectangle.width -= sizeOffset; + settingRectangle.height -= sizeOffset; + pCanvas->FillRectangle(Color::GetColor(COLOR_ID_BLACK), settingRectangle); + delete pCanvas; + } + } + else + { + Canvas* pCanvas = null; + + if (__pSettingsBitmap == null) + { + __pSettingsBitmap = ApplicationUtils::GetResourceBitmapN(IDB_SETTING_BUTTON_PRESSED); + } + + pBitmap = __pSettingsBitmap; + pCanvas = __pSettingsPanel->GetCanvasN(); + + if (pCanvas != null) + { + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + delete pCanvas; + } + } + + pSettingLabel->SetBackgroundBitmap(*pBitmap); + pSettingLabel->Invalidate(false); + pSettingLabelAnimator->SetPosition(settingPosition); + settingPosition.x += pSettingLabel->GetSize().width; + pDoneAnimator->SetPosition(settingPosition); + } +} + +void +HomeForm::OnPageSwept(int pageNumber) +{ + if (pageNumber > 0) + { + __pPageMarker->SetSelectedBubble(pageNumber); + } + + return; +} + +void +HomeForm::OnPageAdded(int pageNumber) +{ + // adds a new bubble and sets the newly added page as the current page + if (__pPageMarker != null) + { + __pPageMarker->AddBubble(); + } + + return; +} + +void +HomeForm::OnPageRemoved(int pageNumber) +{ + if (__pPageMarker != null) + { + __pPageMarker->RemoveBubble(pageNumber); + } + + return; +} + +void +HomeForm::OnMarkerBubbleMoved(int bubbleNumber) +{ + if (bubbleNumber > 0) + { + __pPageMarker->SetSelectedBubble(bubbleNumber); + __pPageControl->SetPageSelected(bubbleNumber); + } + + return; +} + +void +HomeForm::OnInstallationCompleted(const HomeItemInfo& pItemInfo) +{ + ArrayList* pIconViews = null; + int pageNumber = 0; + int position = 0; + + if (__pHomePresentationModel->GetPageCount() > __pPageControl->GetPageCount()) + { + //__pPageControl->SetAppInfoList(__pDataModel->GetApplicationsList()); + + if (IsFailed(__pPageControl->AddPage())) + { + return; + } + } + + pIconViews = __pPageControl->GetIconLists(); + + if (pIconViews != null) + { + IconListView* pListView = null; + pItemInfo.GetPositionInHomeScreen(pageNumber, position); + pListView = static_cast(pIconViews->GetAt(pageNumber - 1)); + + if (pListView != null) + { + pListView->UpdateList(); + } + } + + return; +} + +void +HomeForm::OnAppUninstallRequested(HomeItemInfo* pItemInfo) +{ + if (__pProgressPanel != null) + { + __pProgressPanel->StartAnimation(); + } + + return; +} + +void +HomeForm::OnUnInstallationCompleted(const HomeItemInfo& pItemInfo) +{ + if (__pHomePresentationModel != null) + { + int pageNumber = 0; + int appIndex = 0; + IconListView* pIconList = null; + ArrayList* pIconLists = __pPageControl->GetIconLists(); + + if (__pProgressPanel != null) + { + __pProgressPanel->StopAnimation(); + } + + pItemInfo.GetPositionInHomeScreen(pageNumber, appIndex); + pIconList = static_cast(pIconLists->GetAt(pageNumber - 1)); + + if (pIconList != null) + { + pIconList->UpdateList(); + } + } + + return; +} + +void +HomeForm::OnUpdatePageRequestedN(Tizen::Base::Collection::ArrayList* pPageList) +{ + if (pPageList != null) + { + UpdatePage(pPageList); + pPageList->RemoveAll(true); + delete pPageList; + pPageList = null; + } + return; +} + +// from IPageControlItemProvider +int +HomeForm::GetPageCount(void) +{ + int pageCount = 0; + + if (__pHomePresentationModel != null) + { + pageCount = __pHomePresentationModel->GetPageCount(); + } + return pageCount; +} + +int +HomeForm::GetItemCount(int pageNumber) +{ + int itemCount = 0; + + if (__pHomePresentationModel != null) + { + itemCount = __pHomePresentationModel->GetItemCount(pageNumber); + +// if(itemCount == 0) +// { +// if(pageNumber > 1) +// { +// __pPageControl->MarkPageToDelete(pageNumber); +// } +// } + } + + return itemCount; +} + +HomeItemInfo* +HomeForm::GetItem(int pageNumber, int index) +{ + HomeItemInfo* itemInfo = null; + + if (__pHomePresentationModel != null) + { + itemInfo = __pHomePresentationModel->GetItem(pageNumber, index); + } + + return itemInfo; +} + +void +HomeForm::RearrangeItems(HomeItemInfo* pMovedAppInfo, int newPageNumber, int newIndex) +{ + __pHomePresentationModel->RearrangeItems(pMovedAppInfo, newPageNumber, newIndex); + return; +} + +void +HomeForm::UpdateAllPages(void) +{ + if (__isLanguageChanged) + { + Label* pDoneLabel = static_cast(__pSettingsPanel->GetControl(L"IDC_DONE_LABEL")); + + if (pDoneLabel != null) + { + String doneString; + ApplicationUtils::GetStringResource(L"IDS_COM_POP_DONE", doneString); + pDoneLabel->SetText(doneString); + pDoneLabel->Invalidate(false); + } + + if (__pPageControl != null) + { + ArrayList* pIconLists = __pPageControl->GetIconLists(); + + if (pIconLists != null) + { + for (int iconListCount = 0; iconListCount < pIconLists->GetCount(); iconListCount++) + { + IconListView* pIconListView = static_cast(pIconLists->GetAt(iconListCount)); + if (pIconListView) + { + pIconListView->UpdateList(); + } + } + } + } + + __isLanguageChanged = false; + } +} diff --git a/src/HmHomeItemInfo.cpp b/src/HmHomeItemInfo.cpp new file mode 100644 index 0000000..4fd452b --- /dev/null +++ b/src/HmHomeItemInfo.cpp @@ -0,0 +1,187 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmHomeItemInfo.cpp + * @brief Keeps implementation of the HomeItemInfo + * Implements the HomeItemInfo class, it keeps the information of all the applications installed. + */ + +#include +#include +#include "HmHomeItemInfo.h" +#include "HmTypes.h" + +using namespace Tizen::App; +using namespace Tizen::App::Package; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + +HomeItemInfo::HomeItemInfo(void) + : __isVisibleInMainMenu(false) + , __isUninstallable(false) + , __pageNumber(0) + , __position(-1) + , __pAppIcon(null) +{ + // No implementation needed + +} + +HomeItemInfo::~HomeItemInfo(void) +{ + // No implementation needed +} + +String +HomeItemInfo::GetAppId(void) const +{ + // returns application id + return __appId; +} + +Bitmap* +HomeItemInfo::GetApplicationIcon(void) const +{ + // returns the application icon + return __pAppIcon; +} + +String +HomeItemInfo::GetAppName(void) const +{ + // returns the name of the application + return __appName; +} + +String +HomeItemInfo::GetIconPath(void) const +{ + // returns the path of the application icon + return __appIconPath; +} + +String +HomeItemInfo::GetPackageId(void) const +{ + // returns package id + return __packageId; +} + +void +HomeItemInfo::GetPositionInHomeScreen(int& pageNumber, int& position) const +{ + pageNumber = __pageNumber; + position = __position; + return; +} + +result +HomeItemInfo::Initialize(PackageAppInfo* pPackAppInfo, PackageInfo* pPackInfo) +{ + TryReturn(pPackAppInfo != null && pPackInfo != null, E_INVALID_ARG, "Invalid arguments"); + + result r = E_SUCCESS; + + __isVisibleInMainMenu = pPackAppInfo->IsMenuIconVisible(); + + if (__isVisibleInMainMenu) + { + // gets the path of the icon if icon is available + String appIconPath = pPackAppInfo->GetAppMenuIconPath(); + + // sets the icon path if icon path is not empty + if (!appIconPath.IsEmpty() && !appIconPath.Equals(L"(null)", true)) + { + __appIconPath = appIconPath; + } +// // sets the icon path if icon path is empty temporarily. +// else +// { +// __appIconPath = IDB_DEFAULT_APP_ICON; +// } + + // gets the application id + AppId appId = pPackAppInfo->GetAppId(); + // sets the application Id + if (!appId.IsEmpty()) + { + __appId = appId; + } + + // gets the application name + String appName = pPackAppInfo->GetAppDisplayName(); + // sets the application name + if (!appName.IsEmpty()) + { + __appName = appName; + } + } + + __isUninstallable = pPackInfo->IsUninstallable(); + __packageId = pPackInfo->GetId(); + + return r; +} + +bool +HomeItemInfo::IsUnistallable(void) const +{ + // returns true if application is uninstallable else false + return __isUninstallable; +} + +bool +HomeItemInfo::IsVisibleInMainMenu(void) const +{ + // returns true if application icon can be shown in home else false + return __isVisibleInMainMenu; +} + +void +HomeItemInfo::SetApplicationIcon(Bitmap* pAppIconBitmap) +{ + // sets the icon for the application + if (__pAppIcon != null) + { + delete __pAppIcon; + __pAppIcon = null; + } + __pAppIcon = pAppIconBitmap; + return; +} + +void +HomeItemInfo::SetApplicationName(String& newAppName) +{ + __appName = newAppName; +} + +void +HomeItemInfo::SetItemIndex(int newIndex) +{ + __position = newIndex; +} + +void +HomeItemInfo::SetPositionInHomeScreen(int pageNumber, int position) +{ + // sets the position of the application icon + __pageNumber = pageNumber; + __position = position; + return; +} diff --git a/src/HmHomePresentationModel.cpp b/src/HmHomePresentationModel.cpp new file mode 100644 index 0000000..b7274f8 --- /dev/null +++ b/src/HmHomePresentationModel.cpp @@ -0,0 +1,1295 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmHomePresentationModel.cpp + * @brief Keeps implementation of the HmHomePresentationModel + * Implements the HmHomePresentationModel class, it keeps the data required to show the application icons in the home view + */ + +#include +#include +#include +#include "HmHomeItemInfo.h" +#include "HmHomePresentationModel.h" + +using namespace Tizen::App; +using namespace Tizen::App::Package; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Io; + +HomePresentationModel::HomePresentationModel(void) + : __pDataBaseManager(null) + , __pDataListener(null) + , __totalApps(0) + , __totalPages(0) + , __pPackMgr(null) + , __pAppHashMap(null) + , __pPackageInfoRetrieveThread(null) +{ + //empty implementation +} + +HomePresentationModel::~HomePresentationModel(void) +{ + __pPackMgr->RemovePackageInstallationEventListener(*this); + + if (__pPackageInfoRetrieveThread != null) + { + __pPackageInfoRetrieveThread->Join(); + delete __pPackageInfoRetrieveThread; + __pPackageInfoRetrieveThread = null; + } + + if (__pAppHashMap != null) + { + IList* pKeysList = __pAppHashMap->GetKeysN(); + + for (int keyCount = 0; keyCount < pKeysList->GetCount(); keyCount++) + { + ArrayList* pAppList = static_cast(__pAppHashMap->GetValue(*static_cast(pKeysList->GetAt(keyCount)))); + + if (pAppList != null) + { + pAppList->RemoveAll(true); + } + } + + pKeysList->RemoveAll(); + delete pKeysList; + __pAppHashMap->RemoveAll(true); + delete __pAppHashMap; + __pAppHashMap = null; + } + + __pDataListener = null; +} + +result +HomePresentationModel::Construct(void) +{ + result r = E_SUCCESS; + __totalPages = 1; + __pPackageInfoRetrieveThread = new (std::nothrow) PackageInfoListRetrieveThread(this); + r = __pPackageInfoRetrieveThread->Construct(); + TryCatch(r == E_SUCCESS, , "__pPackageInfoRetrieveThread->Construct()", GetErrorMessage(r)); + __pPackMgr = PackageManager::GetInstance(); + __pPackMgr->AddPackageInstallationEventListener(*this); + r = __pPackageInfoRetrieveThread->SetPackageType(); + +CATCH: + + return r; +} + +HomeItemInfo* +HomePresentationModel::GetItem(int pageNumber, int index) const +{ + ArrayList* pAppsList = static_cast(__pAppHashMap->GetValue(Integer(pageNumber))); + if (pAppsList != null) + { + return static_cast(pAppsList->GetAt(index)); + } + return null; +} + +int +HomePresentationModel::GetItemCount(int pageNumber) const +{ + if (__pAppHashMap != null) + { + ArrayList* pAppsList = static_cast(__pAppHashMap->GetValue(Integer(pageNumber))); + + if (pAppsList != null) + { + return pAppsList->GetCount(); + } + } + return 0; +} + +int +HomePresentationModel::GetPageCount(void) const +{ + return __totalPages; +} + +void +HomePresentationModel::LanguageChanged(void) +{ + IList* pAppsValues = null; + IEnumerator* pMapEnum = null; + TryCatch(__pAppHashMap != null, , "__pAppHashMap is null"); + pAppsValues = __pAppHashMap->GetValuesN(); + TryCatch(pAppsValues != null, , "pAppHashMap->GetValuesN returned null"); + pMapEnum = pAppsValues->GetEnumeratorN(); + TryCatch(pMapEnum != null, , "pAppsValues->GetEnumeratorN() returned null"); + __pPackMgr = PackageManager::GetInstance(); + + while (pMapEnum->MoveNext() == E_SUCCESS) + { + ArrayList* pAppsArrayList = static_cast(pMapEnum->GetCurrent()); + + if (pAppsArrayList != null) + { + IEnumerator* pAppsEnum = pAppsArrayList->GetEnumeratorN(); + + if (pAppsEnum) + { + while (pAppsEnum->MoveNext() == E_SUCCESS) + { + HomeItemInfo* pAppInfo = static_cast(pAppsEnum->GetCurrent()); + + if (pAppInfo != null) + { + PackageInfo* pPackInfo = __pPackMgr->GetPackageInfoN(pAppInfo->GetPackageId()); + + if (pPackInfo != null) + { + PackageAppInfo* pPackageAppInfo = pPackInfo->GetPackageAppInfoN(pAppInfo->GetAppId()); + + if (pPackageAppInfo != null) + { + String appNewName = pPackageAppInfo->GetAppDisplayName(); + + if (pAppInfo->GetAppName().CompareTo(appNewName) != 0) + { + pAppInfo->SetApplicationName(appNewName); + pAppInfo->SetApplicationIcon(null); + } + + delete pPackageAppInfo; + pPackageAppInfo = null; + } + + delete pPackInfo; + pPackInfo = null; + } + } + } + + delete pAppsEnum; + pAppsEnum = null; + } + } + } + +CATCH: + if (pMapEnum != null) + { + delete pMapEnum; + pMapEnum = null; + } + if (pAppsValues != null) + { + pAppsValues->RemoveAll(false); + delete pAppsValues; + pAppsValues = null; + } +} + +void +HomePresentationModel::RearrangeItems(HomeItemInfo* pMovedAppInfo, int newPageNumber, int newIndex) +{ + ArrayList* pMovedToAppList = null; + ArrayList* pMovedFromAppList = null; + ArrayList* pPagesToUpdate = null; + Integer* pPageToUpdate = null; + result r = E_SUCCESS; + int movedPageNumber = 0; + int movedAppIndex = 0; + // gets the list of applications for the current page + pMovedToAppList = static_cast(__pAppHashMap->GetValue(Integer(newPageNumber))); + pMovedAppInfo->GetPositionInHomeScreen(movedPageNumber, movedAppIndex); + pMovedFromAppList = static_cast(__pAppHashMap->GetValue(Integer(movedPageNumber))); + + if ((newPageNumber == movedPageNumber) && (newIndex == movedAppIndex)) + { + return; + } + + pPagesToUpdate = new ArrayList(); + pPagesToUpdate->Construct(); + pPageToUpdate = new (std::nothrow) Integer(movedPageNumber); + r = pPagesToUpdate->Add(pPageToUpdate); + + if (r != E_SUCCESS) + { + delete pPageToUpdate; + pPageToUpdate = null; + } + + + if (movedPageNumber != newPageNumber) + { + pPageToUpdate = new (std::nothrow) Integer(newPageNumber); + r = pPagesToUpdate->Add(pPageToUpdate); + + if (r != E_SUCCESS) + { + delete pPageToUpdate; + pPageToUpdate = null; + } + } + + if (pMovedToAppList != null && pMovedFromAppList != null) + { + { + if (movedPageNumber == newPageNumber) + { + + if (newIndex != -1 && movedAppIndex != newIndex) + { + + if (newIndex - movedAppIndex == 1) + { + pMovedToAppList->InsertAt(pMovedAppInfo, newIndex + 1); + } + else + { + pMovedToAppList->InsertAt(pMovedAppInfo, newIndex); + } + + if (newIndex > movedAppIndex) + { + pMovedFromAppList->RemoveAt(movedAppIndex); + } + else + { + pMovedFromAppList->RemoveAt(movedAppIndex + 1); + } + + UpdatePositions(*pMovedFromAppList); + } + } + else + { + int numberOfIconsInPage = pMovedToAppList->GetCount(); + + if (numberOfIconsInPage < MAX_ICONS_PER_PAGE) + { + pMovedAppInfo->SetPositionInHomeScreen(newPageNumber, newIndex); + pMovedToAppList->InsertAt(pMovedAppInfo, newIndex); + pMovedFromAppList->RemoveAt(movedAppIndex, false); + UpdatePositions(*pMovedFromAppList); + UpdatePositions(*pMovedToAppList); + } + else if (numberOfIconsInPage >= MAX_ICONS_PER_PAGE) + { + bool foundLocation = false; + int nextPageNumber = 0; + ArrayList* pNextPageAppList = null; + HomeItemInfo* pItemToGetANewLocationFor = static_cast(pMovedToAppList->GetAt(pMovedToAppList->GetCount() - 1)); + pMovedToAppList->Remove(*pItemToGetANewLocationFor, false); + pMovedAppInfo->SetPositionInHomeScreen(newPageNumber, newIndex); + pMovedToAppList->InsertAt(pMovedAppInfo, newIndex); + pMovedFromAppList->Remove(*pMovedAppInfo, false); + + if (pItemToGetANewLocationFor != null) + { + nextPageNumber = newPageNumber + 1; + // checks for the successor page having the number of icons not exceeding its maximum limit + + while (nextPageNumber <= __totalPages) + { + pNextPageAppList = static_cast(__pAppHashMap->GetValue(Integer(nextPageNumber))); + + if (pNextPageAppList->GetCount() < MAX_ICONS_PER_PAGE /*|| nextPageNumber == pageNumber*/) + { + pItemToGetANewLocationFor->SetPositionInHomeScreen(nextPageNumber, pNextPageAppList->GetCount()); + pNextPageAppList->Add(pItemToGetANewLocationFor); + UpdatePositions(*pNextPageAppList); + foundLocation = true; + pPageToUpdate = new Integer(nextPageNumber); + pPagesToUpdate->Add(pPageToUpdate); + break; + } + + nextPageNumber++; + } + + if (!foundLocation && __totalPages < MAX_PAGE_COUNT) + { + result r = E_SUCCESS; + Integer* pPageNumber = null; + ArrayList* pNewAppList = new (std::nothrow) ArrayList(); + pNewAppList->Construct(); + + __totalPages++; + pItemToGetANewLocationFor->SetPositionInHomeScreen(__totalPages, 0); + pNewAppList->Add(pItemToGetANewLocationFor); + pPageNumber = new (std::nothrow) Integer(__totalPages); + r = __pAppHashMap->Add(pPageNumber, pNewAppList); + pPagesToUpdate->Add(new (std::nothrow) Integer(__totalPages)); + + if (IsFailed(r)) + { + delete pPageNumber; + pPageNumber = null; + delete pNewAppList; + pNewAppList = null; + } + + pPageToUpdate = new Integer(__totalPages); + pPagesToUpdate->Add(pPageToUpdate); + foundLocation = true; + } + + if (pNextPageAppList != null) + { + UpdatePositions(*pNextPageAppList); + } + + UpdatePositions(*pMovedFromAppList); + UpdatePositions(*pMovedToAppList); + } + } + } + } + } + + __pDataListener->OnUpdatePageRequestedN(pPagesToUpdate); + return; +} + +void +HomePresentationModel::SetHomePackageEventListener(IHomePresentationModelEventListener* pListener) +{ + __pDataListener = pListener; +} + +result +HomePresentationModel::UpdatePageData(void) +{ + result r = E_INVALID_ARG; + + if (__pAppHashMap != null) + { + IList* pKeys = __pAppHashMap->GetKeysN(); + + if (pKeys != null) + { + for (int pageCount = 0; pageCount < pKeys->GetCount(); pageCount++) + { + ArrayList* pPageApps = (ArrayList*) __pAppHashMap->GetValue(*pKeys->GetAt(pageCount)); + + if (pPageApps != null) + { + + for (int appsCount = 0; appsCount < pPageApps->GetCount(); appsCount++) + { + HomeItemInfo* pItemInfo = static_cast(pPageApps->GetAt(appsCount)); + + if (pItemInfo != null) + { + r = UpdateDataToDatabase(static_cast(pItemInfo)); + } + } + } + } + + pKeys->RemoveAll(false); + delete pKeys; + pKeys = null; + } + } + + return r; +} + +result +HomePresentationModel::HomeApplicationsComparer::Compare(const Object& obj1, const Object& obj2, int& cmp) const +{ + result r = E_FAILURE; + const HomeItemInfo* pObj1 = static_cast(&obj1); + const HomeItemInfo* pObj2 = static_cast(&obj2); + + if (pObj1 != null && pObj2 != null) + { + int pageIndex1 = 0; + int pageNumber = 0; + int pageIndex2 = 0; + pObj1->GetPositionInHomeScreen(pageNumber, pageIndex1); + pObj2->GetPositionInHomeScreen(pageNumber, pageIndex2); + + cmp = Integer::Compare(pageIndex1, pageIndex2); + r = E_SUCCESS; + } + + return r; +} + +void +HomePresentationModel::OnPackageInstallationCompleted(const PackageId& packageId, PackageInstallationResult installationResult) +{ + if (installationResult == PACKAGE_INSTALLATION_RESULT_SUCCESS) + { + NotifyInstallationEvent(packageId); + } + else + { + //Show error + } + return; +} + +void +HomePresentationModel::OnPackageUninstallationCompleted(const PackageId& packageId, bool uninstallationResult) +{ + ArrayList* pAppsList = null; + HomeItemInfo* pItemInfo = null; + + if (uninstallationResult) + { + if (__pDataListener != null && !packageId.IsEmpty()) + { + + pItemInfo = FindAppObjectInList(packageId); + do + { + if (pItemInfo != null) + { + int pageNumber = 0; + int appIndex = 0; + pItemInfo->GetPositionInHomeScreen(pageNumber, appIndex); + pAppsList = static_cast(__pAppHashMap->GetValue(Integer(pageNumber))); + pAppsList->Remove(*pItemInfo); + UpdatePositions(*pAppsList); + if (pItemInfo->IsVisibleInMainMenu()) + { + __pDataListener->OnUnInstallationCompleted(*pItemInfo); + } + + if (pItemInfo != null) + { + delete pItemInfo; + pItemInfo = null; + } + pItemInfo = FindAppObjectInList(packageId); + } + } + while (pItemInfo != null); + } + } + else + { + //Show error + } + + return; +} + +void +HomePresentationModel::OnPackageInfoRetrievedN(Tizen::Base::Collection::HashMap* pAppsList, int totalApps, int totalPages) +{ + UiApp* pApp = UiApp::GetInstance(); + + if (pAppsList != null && totalApps != 0) + { + result r = E_SUCCESS; + __pAppHashMap = pAppsList; + __totalPages = totalPages; + __totalApps = totalApps; + r = PrepareApplicationsList(); + + if (pApp != null) + { + ArrayList* pListToSend = new (std::nothrow) ArrayList(); + + if (pListToSend != null) + { + r = pListToSend->Construct(); + + if (r == E_SUCCESS) + { + Integer* pResToSend = new (std::nothrow) Integer(r); + r = pListToSend->Add(pResToSend); + + if (r == E_SUCCESS) + { + r = pApp->SendUserEvent(MODEL_REQUEST_INITIALIZE, pListToSend); + return; + } + else + { + delete pResToSend; + delete pListToSend; + } + } + } + } + } + + if (pApp != null) + { + pApp->SendUserEvent(MODEL_REQUEST_INITIALIZE, null); + } + + return; +} + +HomeItemInfo* +HomePresentationModel::FindAppObjectInList(const Tizen::Base::String& packageIdToFind) +{ + IList* pKeysList = __pAppHashMap->GetKeysN(); + + if (pKeysList != null) + { + for (int keysCount = 0; keysCount < pKeysList->GetCount(); keysCount++) + { + ArrayList* pList = static_cast(__pAppHashMap->GetValue(*static_cast(pKeysList->GetAt(keysCount)))); + + for (int itemCount = (pList->GetCount() - 1); itemCount >= 0; itemCount--) + { + HomeItemInfo* pApplicationInfo = static_cast(pList->GetAt(itemCount)); + + if (pApplicationInfo != null) + { + String packageId = pApplicationInfo->GetPackageId(); + + if (packageId.CompareTo(packageIdToFind) == 0) + { + pKeysList->RemoveAll(); + delete pKeysList; + return static_cast(pApplicationInfo); + } + } + } + } + pKeysList->RemoveAll(); + delete pKeysList; + pKeysList = null; + } + + return null; + +} + +result +HomePresentationModel::InitializeDatabase(void) +{ + result r = E_SUCCESS; + + __pDataBaseManager = GenericDatabaseManager::GetInstance(); + + if (__pDataBaseManager != null) + { + ArrayList* pColumnNames = null; + ArrayList* pColumnTypes = null; + String* pTempColumnData = null; + + String databaseName = App::GetInstance()->GetAppRootPath(); + databaseName.Append(HOME_DATABASE_NAME); + + r = __pDataBaseManager->CreateDataBase(databaseName); + TryCatch(r == E_SUCCESS, , + "Home_Exception::failed to create Database"); + pColumnNames = new (std::nothrow) ArrayList(); + pColumnNames->Construct(); + pColumnTypes = new (std::nothrow) ArrayList(); + pColumnTypes->Construct(); + + //Creates table homeapps + pTempColumnData = new (std::nothrow) String(APPS_RECORD_ID); + r = pColumnNames->Add(pTempColumnData); + TryCatch(r == E_SUCCESS, delete pTempColumnData; + pTempColumnData = null, + "pColumnNames->Add(pTempColumnData) failed with error %s", GetErrorMessage(r)); + pTempColumnData = new (std::nothrow) String(DATATYPE_INTEGER_PRIMARY); + r = pColumnTypes->Add(pTempColumnData); + TryCatch(r == E_SUCCESS, delete pTempColumnData; + pTempColumnData = null, + "pColumnTypes->Add(pTempColumnData) failed with error %s", GetErrorMessage(r)); + + pTempColumnData = new (std::nothrow) String(APPS_APP_ID); + r = pColumnNames->Add(pTempColumnData); + TryCatch(r == E_SUCCESS, delete pTempColumnData; + pTempColumnData = null, + "pColumnNames->Add(pTempColumnData) failed with error %s", GetErrorMessage(r)); + pTempColumnData = new (std::nothrow) String(DATATYPE_TEXT); + pTempColumnData->Append(DATATYPE_UNIQUE); + r = pColumnTypes->Add(pTempColumnData); + TryCatch(r == E_SUCCESS, delete pTempColumnData; + pTempColumnData = null, + "pColumnTypes->Add(pTempColumnData) failed with error %s", GetErrorMessage(r)); + + pTempColumnData = new (std::nothrow) String(APPS_APP_NAME); + r = pColumnNames->Add(pTempColumnData); + TryCatch(r == E_SUCCESS, delete pTempColumnData; + pTempColumnData = null, + "pColumnNames->Add(pTempColumnData) failed with error %s", GetErrorMessage(r)); + pTempColumnData = new (std::nothrow) String(DATATYPE_TEXT); + r = pColumnTypes->Add(pTempColumnData); + TryCatch(r == E_SUCCESS, delete pTempColumnData; + pTempColumnData = null, + "pColumnTypes->Add(pTempColumnData) failed with error %s", GetErrorMessage(r)); + + pTempColumnData = new (std::nothrow) String(APPS_APP_ICON); + r = pColumnNames->Add(pTempColumnData); + TryCatch(r == E_SUCCESS, delete pTempColumnData; + pTempColumnData = null, + "pColumnNames->Add(pTempColumnData) failed with error %s", GetErrorMessage(r)); + pTempColumnData = new (std::nothrow) String(DATATYPE_TEXT); + r = pColumnTypes->Add(pTempColumnData); + TryCatch(r == E_SUCCESS, delete pTempColumnData; + pTempColumnData = null, + "pColumnTypes->Add(*pTempColumnData) failed with error %s", GetErrorMessage(r)); + + pTempColumnData = new (std::nothrow) String(APPS_APP_PAGE); + r = pColumnNames->Add(pTempColumnData); + TryCatch(r == E_SUCCESS, delete pTempColumnData; + pTempColumnData = null, + "pColumnNames->Add(pTempColumnData) failed with error %s", GetErrorMessage(r)); + pTempColumnData = new (std::nothrow) String(DATATYPE_INTEGER); + r = pColumnTypes->Add(pTempColumnData); + TryCatch(r == E_SUCCESS, delete pTempColumnData; + pTempColumnData = null, + "pColumnTypes->Add(*pTempColumnData) failed with error %s", GetErrorMessage(r)); + + pTempColumnData = new (std::nothrow) String(APPS_APP_PAGEINDEX); + r = pColumnNames->Add(pTempColumnData); + TryCatch(r == E_SUCCESS, delete pTempColumnData; + pTempColumnData = null, + "pColumnNames->Add(pTempColumnData) failed with error %s", GetErrorMessage(r)); + pTempColumnData = new (std::nothrow) String(DATATYPE_INTEGER); + r = pColumnTypes->Add(pTempColumnData); + TryCatch(r == E_SUCCESS, delete pTempColumnData; + pTempColumnData = null, + "pColumnTypes->Add(pTempColumnData) failed with error %s", GetErrorMessage(r)); + + r = __pDataBaseManager->CreateTable(HOME_APPLICATIONS_TABLE, pColumnNames, pColumnTypes); + TryCatch(r == E_SUCCESS, , "HmDatabaseManager::CreateTable failed with error %s", GetErrorMessage(r)); +CATCH: + if (pColumnNames != null) + { + pColumnNames->RemoveAll(true); + delete pColumnNames; + pColumnNames = null; + } + + if (pColumnTypes != null) + { + pColumnTypes->RemoveAll(true); + delete pColumnTypes; + pColumnTypes = null; + } + } + return r; +} + +result +HomePresentationModel::InsertPageDataInDataBase(const HomeItemInfo* pItemInfo) +{ + + result r = E_INVALID_ARG; + + if (pItemInfo != null) + { + ArrayList* pColumnNames = null; + ArrayList* pColumnTypes = null; + ArrayList* pColumnValues = null; + String* pTempString = null; + Integer* pTempInt = null; + int pageNumber = 0; + int pageIndex = 0; + + //Constructing various array list + pColumnNames = new (std::nothrow) ArrayList(); + pColumnNames->Construct(); + pColumnTypes = new (std::nothrow) ArrayList(); + pColumnTypes->Construct(); + pColumnValues = new (std::nothrow) ArrayList(); + pColumnValues->Construct(); + + pItemInfo->GetPositionInHomeScreen(pageNumber, pageIndex); + + //Application app id + pTempString = new (std::nothrow) String(APPS_APP_ID); + r = pColumnNames->Add(pTempString); + TryCatch(r == E_SUCCESS, delete pTempString; + pTempString = null, + "pColumnNames->Add(pTempString); failed %s", GetErrorMessage(r)); + pTempInt = new (std::nothrow) Integer(DB_COLUMNTYPE_TEXT); + r = pColumnTypes->Add(pTempInt); + TryCatch(r == E_SUCCESS, delete pTempInt; + pTempInt = null, + "pColumnTypes->Add(pTempInt); failed %s", GetErrorMessage(r)); + pTempString = new (std::nothrow) String(pItemInfo->GetAppId()); + r = pColumnValues->Add(pTempString); + TryCatch(r == E_SUCCESS, delete pTempString; + pTempString = null, + "pColumnNames->Add(pTempString); failed %s", GetErrorMessage(r)); + + //Application Name + pTempString = new (std::nothrow) String(APPS_APP_NAME); + r = pColumnNames->Add(pTempString); + TryCatch(r == E_SUCCESS, delete pTempString; + pTempString = null, + "pColumnNames->Add(pTempString); failed %s", GetErrorMessage(r)); + pTempInt = new (std::nothrow) Integer(DB_COLUMNTYPE_TEXT); + r = pColumnTypes->Add(pTempInt); + TryCatch(r == E_SUCCESS, delete pTempInt; + pTempInt = null, + "pColumnTypes->Add(pTempInt); failed %s", GetErrorMessage(r)); + pTempString = new (std::nothrow) String(pItemInfo->GetAppName()); + r = pColumnValues->Add(pTempString); + TryCatch(r == E_SUCCESS, delete pTempString; + pTempString = null, + "pColumnNames->Add(pTempString); failed %s", GetErrorMessage(r)); + + //Application IconPath + pTempString = new (std::nothrow) String(APPS_APP_ICON); + r = pColumnNames->Add(pTempString); + TryCatch(r == E_SUCCESS, delete pTempString; + pTempString = null, + "pColumnNames->Add(pTempString); failed %s", GetErrorMessage(r)); + pTempInt = new (std::nothrow) Integer(DB_COLUMNTYPE_TEXT); + r = pColumnTypes->Add(pTempInt); + TryCatch(r == E_SUCCESS, delete pTempInt; + pTempInt = null, + "pColumnTypes->Add(pTempInt); failed %s", GetErrorMessage(r)); + pTempString = new (std::nothrow) String(pItemInfo->GetIconPath()); + r = pColumnValues->Add(pTempString); + TryCatch(r == E_SUCCESS, delete pTempString; + pTempString = null, + "pColumnNames->Add(pTempString); failed %s", GetErrorMessage(r)); + + //Application pageNumber + pTempString = new (std::nothrow) String(APPS_APP_PAGE); + r = pColumnNames->Add(pTempString); + TryCatch(r == E_SUCCESS, delete pTempString; + pTempString = null, + "pColumnNames->Add(pTempString); failed %s", GetErrorMessage(r)); + pTempInt = new (std::nothrow) Integer(DB_COLUMNTYPE_INT); + r = pColumnTypes->Add(pTempInt); + TryCatch(r == E_SUCCESS, delete pTempInt; + pTempInt = null, + "pColumnTypes->Add(pTempInt); failed %s", GetErrorMessage(r)); + pTempInt = new (std::nothrow) Integer(pageNumber); + r = pColumnValues->Add(pTempInt); + TryCatch(r == E_SUCCESS, delete pTempInt; + pTempInt = null, + "pColumnValues->Add(pTempInt); failed %s", GetErrorMessage(r)); + //Application pageIndex + pTempString = new (std::nothrow) String(APPS_APP_PAGEINDEX); + r = pColumnNames->Add(pTempString); + TryCatch(r == E_SUCCESS, delete pTempString; + pTempString = null, + "pColumnNames->Add(pTempString); failed %s", GetErrorMessage(r)); + pTempInt = new (std::nothrow) Integer(DB_COLUMNTYPE_INT); + r = pColumnTypes->Add(pTempInt); + TryCatch(r == E_SUCCESS, delete pTempInt; + pTempInt = null, + "pColumnTypes->Add(pTempInt); failed %s", GetErrorMessage(r)); + pTempInt = new (std::nothrow) Integer(pageIndex); + r = pColumnValues->Add(pTempInt); + TryCatch(r == E_SUCCESS, delete pTempInt; + pTempInt = null, + "pColumnValues->Add(pTempInt); failed %s", GetErrorMessage(r)); + + //update +// whereCondition = new (std::nothrow)String(APPS_APP_ID); +// whereCondition->Append(L" = "); +// whereCondition->Append(*pItemInfo->GetAppId()); + r = __pDataBaseManager->InsertToTable(HOME_APPLICATIONS_TABLE, pColumnNames, pColumnTypes, pColumnValues); + +CATCH: + + if (pColumnNames != null) + { + pColumnNames->RemoveAll(true); + delete pColumnNames; + pColumnNames = null; + } + + if (pColumnTypes != null) + { + pColumnTypes->RemoveAll(true); + delete pColumnTypes; + pColumnTypes = null; + } + + if (pColumnValues != null) + { + pColumnValues->RemoveAll(true); + delete pColumnValues; + pColumnValues = null; + } + + } + + return r; +} + +result +HomePresentationModel::NotifyInstallationEvent(const PackageId& packageId) +{ + result r = E_SUCCESS; + String replace(APP_ID_REPLACE_STR); + String tempPackageId(packageId); + ArrayList* pNewAppList = null; + Integer* pNewKey = null; + HomeItemInfo* pItemInfo = null; + bool isalreadyExist = false; + int indexOf = 0; + r = tempPackageId.LastIndexOf(replace, 0, indexOf); + + if (!IsFailed(r) && indexOf) + { + tempPackageId.Remove(0, replace.GetLength()); + } + + if (__pPackMgr == null) + { + __pPackMgr = PackageManager::GetInstance(); + } + + if (__pPackMgr != null) + { + PackageInfo* pPackInfo = __pPackMgr->GetPackageInfoN(packageId); + + if (pPackInfo != null) + { + IList* pAppsInPack = pPackInfo->GetPackageAppInfoListN(); + + if (pAppsInPack != null) + { + IEnumerator* pPackageAppInfoEnum = pAppsInPack->GetEnumeratorN(); + + while (pPackageAppInfoEnum != null && pPackageAppInfoEnum->MoveNext() == E_SUCCESS) + { + ArrayList* pAppsList = null; + bool foundPosition = false; + IList* pKeysList = __pAppHashMap->GetKeysN(); + PackageAppInfo* pPackageAppInfo = static_cast(pPackageAppInfoEnum->GetCurrent()); + + if (pKeysList != null && pPackageAppInfo) + { + for (int keysCount = (pKeysList->GetCount() - 1); keysCount >= 0; keysCount--) + { + pItemInfo = FindAppObjectInList(tempPackageId); + + if (pItemInfo != null) + { + pItemInfo->Initialize(pPackageAppInfo, pPackInfo); + pItemInfo->SetApplicationIcon(null); + isalreadyExist = true; + foundPosition = true; + break; + } + } + + if (!isalreadyExist) + { + for (int keysCount = (pKeysList->GetCount() - 1); keysCount >= 0; keysCount--) + { + pAppsList = static_cast(__pAppHashMap->GetValue(*static_cast(pKeysList->GetAt(keysCount)))); + + if (pAppsList != null) + { + if (pAppsList->GetCount() < MAX_ICONS_PER_PAGE) + { + pItemInfo = new (std::nothrow) HomeItemInfo(); + + if (pItemInfo != null) + { + if (pItemInfo->Initialize(pPackageAppInfo, pPackInfo) == E_SUCCESS) + { + if (pItemInfo->IsVisibleInMainMenu()) + { + __totalApps++; + pItemInfo->SetPositionInHomeScreen(keysCount + 1, pAppsList->GetCount()); + pAppsList->Add(pItemInfo); + foundPosition = true; + break; + } + else + { + continue; + } + + } + else + { + delete pItemInfo; + pItemInfo = null; + } + } + } + } + } + } + + if (!foundPosition) + { + pNewAppList = new (std::nothrow) ArrayList(); + + if (pNewAppList != null) + { + r = pNewAppList->Construct(); + + if (pItemInfo == null) + { + pItemInfo = new (std::nothrow) HomeItemInfo(); + r = pItemInfo->Initialize(pPackageAppInfo, pPackInfo); + TryCatch(r == E_SUCCESS, , "failed to construct pNewAppList %s", + GetErrorMessage(r)); + } + if (pItemInfo->IsVisibleInMainMenu()) + { + __totalApps++; + __totalPages++; + pItemInfo->SetPositionInHomeScreen(__totalPages, 0); + r = pNewAppList->Add(pItemInfo); + TryCatch(r == E_SUCCESS, , "failed to construct pNewAppList %s", + GetErrorMessage(r)); + pNewKey = new (std::nothrow) Integer(__totalPages); + r = __pAppHashMap->Add(pNewKey, pNewAppList); + TryCatch(r == E_SUCCESS, , "failed to construct pNewAppList %s", + GetErrorMessage(r)); + } + } + } + } + if (pKeysList != null) + { + pKeysList->RemoveAll(); + delete pKeysList; + pKeysList = null; + } + } + if (pPackageAppInfoEnum != null) + { + delete pPackageAppInfoEnum; + pPackageAppInfoEnum = null; + } + if (pAppsInPack != null) + { + delete pAppsInPack; + pAppsInPack = null; + } + } + + delete pPackInfo; + pPackInfo = null; + } + else + { + r = E_SUCCESS; + } + } + else + { + r = GetLastResult(); + } + + if (__pDataListener != null && pItemInfo != null) + { + __pDataListener->OnInstallationCompleted(*pItemInfo /*, isalreadyExist*/); + } + + return r; + +CATCH: + + if (pItemInfo != null) + { + delete pItemInfo; + pItemInfo = null; + } + + if (pNewAppList != null) + { + delete pNewAppList; + pNewAppList = null; + } + + if (pNewKey != null) + { + delete pNewKey; + pNewKey = null; + } + + return r; +} + +result +HomePresentationModel::PrepareApplicationsList(void) +{ + result r = E_SUCCESS; + r = UpdateWithPositions(); + SortPages(); + return r; +} + +void +HomePresentationModel::SortPages(void) +{ + if (__pAppHashMap != null) + { + IList* pKeys = null; + ArrayList* pValues = null; + IEnumerator* pKeysEnum = null; + + pKeys = __pAppHashMap->GetKeysN(); + + if (pKeys != null) + { + pKeysEnum = pKeys->GetEnumeratorN(); + + if (pKeysEnum != null) + { + while (pKeysEnum != null && pKeysEnum->MoveNext() == E_SUCCESS) + { + Integer* pKeyName = static_cast(pKeysEnum->GetCurrent()); + pValues = static_cast(__pAppHashMap->GetValue(*pKeyName)); + + if (pValues != null) + { + pValues->Sort(__comparerObject); + UpdatePositions(*pValues); + } + } + } + + if (pKeysEnum != null) + { + delete pKeysEnum; + pKeysEnum = null; + } + + pKeys->RemoveAll(false); + delete pKeys; + pKeys = null; + } + } +} + +result +HomePresentationModel::UpdateDataToDatabase(HomeItemInfo* pItemInfo) +{ + result r = E_INVALID_ARG; + + if (pItemInfo != null) + { + ArrayList* pColumnNames = null; + ArrayList* pColumnTypes = null; + ArrayList* pColumnValues = null; + String* whereCondition = null; + String* pTempString = null; + Integer* pTempInt = null; + int pageNumber = 0; + int pageIndex = 0; + + //Constructing various array list + pColumnNames = new (std::nothrow) ArrayList(); + pColumnNames->Construct(); + pColumnTypes = new (std::nothrow) ArrayList(); + pColumnTypes->Construct(); + pColumnValues = new (std::nothrow) ArrayList(); + pColumnValues->Construct(); + + pItemInfo->GetPositionInHomeScreen(pageNumber, pageIndex); + + //Application pageNumber + pTempString = new (std::nothrow) String(APPS_APP_PAGE); + r = pColumnNames->Add(pTempString); + TryCatch(r == E_SUCCESS, delete pTempString; + pTempString = null, + "pColumnNames->Add(pTempString); failed %s", GetErrorMessage(r)); + pTempInt = new (std::nothrow) Integer(DB_COLUMNTYPE_INT); + r = pColumnTypes->Add(pTempInt); + TryCatch(r == E_SUCCESS, delete pTempInt; + pTempInt = null, + "pColumnTypes->Add(pTempInt); failed %s", GetErrorMessage(r)); + pTempInt = new (std::nothrow) Integer(pageNumber); + r = pColumnValues->Add(pTempInt); + TryCatch(r == E_SUCCESS, delete pTempInt; + pTempInt = null, + "pColumnValues->Add(pTempInt); failed %s", GetErrorMessage(r)); + //Application pageIndex + pTempString = new (std::nothrow) String(APPS_APP_PAGEINDEX); + r = pColumnNames->Add(pTempString); + TryCatch(r == E_SUCCESS, delete pTempString; + pTempString = null, + "pColumnNames->Add(pTempString); failed %s", GetErrorMessage(r)); + pTempInt = new (std::nothrow) Integer(DB_COLUMNTYPE_INT); + r = pColumnTypes->Add(pTempInt); + TryCatch(r == E_SUCCESS, delete pTempInt; + pTempInt = null, + "pColumnTypes->Add(pTempInt); failed %s", GetErrorMessage(r)); + pTempInt = new (std::nothrow) Integer(pageIndex); + r = pColumnValues->Add(pTempInt); + TryCatch(r == E_SUCCESS, delete pTempInt; + pTempInt = null, + "pColumnValues->Add(pTempInt); failed %s", GetErrorMessage(r)); + + //update + whereCondition = new (std::nothrow) String(APPS_APP_ID); + whereCondition->Append(L" = "); + whereCondition->Append(L'\"'); + whereCondition->Append(pItemInfo->GetAppId()); + whereCondition->Append(L'\"'); + + r = __pDataBaseManager->UpdateTable(HOME_APPLICATIONS_TABLE, pColumnNames, pColumnTypes, pColumnValues, whereCondition); + +CATCH: + + if (pColumnNames != null) + { + pColumnNames->RemoveAll(true); + delete pColumnNames; + pColumnNames = null; + } + + if (pColumnTypes != null) + { + pColumnTypes->RemoveAll(true); + delete pColumnTypes; + pColumnTypes = null; + } + + if (pColumnValues != null) + { + pColumnValues->RemoveAll(true); + delete pColumnValues; + pColumnValues = null; + } + + if (whereCondition) + { + delete whereCondition; + whereCondition = null; + } + + } + + return r; +} + +void +HomePresentationModel::UpdatePositions(Tizen::Base::Collection::ArrayList& pAppListToUpdate) +{ + for (int appIndex = 0; appIndex < pAppListToUpdate.GetCount(); appIndex++) + { + HomeItemInfo* pItemInfo = static_cast(pAppListToUpdate.GetAt(appIndex)); + pItemInfo->SetItemIndex(appIndex); + } + + pAppListToUpdate.Sort(__comparerObject); +} + +result +HomePresentationModel::UpdateWithPositions(void) +{ + result r = E_INVALID_STATE; + //Sanity test + if (__pDataBaseManager == null) + { + r = InitializeDatabase(); + + if (IsFailed(r)) + { + AppLogException("Home_Exception::InitializeDataBase() failed with error = %s", GetErrorMessage(r)); + return r; + } + } + + if (__pAppHashMap != null) + { + IList* pKeys = null; + ArrayList* pValues = null; + IEnumerator* pKeysEnum = null; + + pKeys = __pAppHashMap->GetKeysN(); + + if (pKeys != null) + { + pKeysEnum = pKeys->GetEnumeratorN(); + + if (pKeysEnum != null) + { + while (pKeysEnum != null && pKeysEnum->MoveNext() == E_SUCCESS) + { + Integer* pKeyName = static_cast(pKeysEnum->GetCurrent()); + pValues = static_cast(__pAppHashMap->GetValue(*pKeyName)); + + if (pValues != null) + { + + for (int appCount = 0; appCount < pValues->GetCount(); appCount++) + { + HomeItemInfo* pItemInfo = dynamic_cast(pValues->GetAt(appCount)); + + if (pItemInfo != null) + { + String whereState(APPS_APP_ID); + String appId = pItemInfo->GetAppId(); + HashMap* pRowData = new (std::nothrow) HashMap(); + whereState.Append(L" = "); + whereState.Append(L'\"'); + whereState.Append(appId); + whereState.Append(L'\"'); + pRowData->Construct(); + r = __pDataBaseManager->GetDataRowFromTable(HOME_APPLICATIONS_TABLE, whereState, *pRowData); + + if (!IsFailed(r) && pRowData->GetCount()) + { + + Integer* pPageIndex = null; + Integer* pPageNumber = static_cast(pRowData->GetValue(String(APPS_APP_PAGE))); + pPageIndex = static_cast(pRowData->GetValue(String(APPS_APP_PAGEINDEX))); + + if (pPageNumber != null && pPageIndex != null) + { + pItemInfo->SetPositionInHomeScreen(pPageNumber->ToInt(), pPageIndex->ToInt()); + } + + } + else + { + r = InsertPageDataInDataBase(pItemInfo); + r = E_SUCCESS; + } + + if (pRowData != null) + { + pRowData->RemoveAll(true); + delete pRowData; + pRowData = null; + } + } + } + } + } + } + //CATCH: + if (pKeysEnum != null) + { + delete pKeysEnum; + pKeysEnum = null; + } + + pKeys->RemoveAll(false); + delete pKeys; + pKeys = null; + } + } + + return r; + +} diff --git a/src/HmMainFrame.cpp b/src/HmMainFrame.cpp new file mode 100644 index 0000000..ca4dd90 --- /dev/null +++ b/src/HmMainFrame.cpp @@ -0,0 +1,48 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmMainFrame.cpp + * @brief Keeps implementation of Main Frame for the application + */ + +#include "HmMainFrame.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +MainFrame::MainFrame(void) +{ + //No implementation needed +} + +MainFrame::~MainFrame(void) +{ + //No implementation needed +} + +result +MainFrame::OnInitializing(void) +{ + return E_SUCCESS; +} + +result +MainFrame::OnTerminating(void) +{ + return E_SUCCESS; +} diff --git a/src/HmPackageInfoListRetrieveThread.cpp b/src/HmPackageInfoListRetrieveThread.cpp new file mode 100644 index 0000000..05d974c --- /dev/null +++ b/src/HmPackageInfoListRetrieveThread.cpp @@ -0,0 +1,241 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file PackageInfoListRetrieveThread.h + * @brief The file contains declaration of PackageInfoListRetrieveThread, + * which is a worker thread and being used to retrieve the list PackageInfos, for the Applications installed on device. + */ + +#include +#include "HmHomeItemInfo.h" +#include "HmPackageInfoListRetrieveThread.h" +#include "HmTypes.h" + +using namespace Tizen::App; +using namespace Tizen::App::Package; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + +PackageInfoListRetrieveThread::PackageInfoListRetrieveThread(IPackageInfoListListener* pPackageListener) + : __pPackageListener(pPackageListener) +{ + // No implementation required + +} + +PackageInfoListRetrieveThread::~PackageInfoListRetrieveThread(void) +{ + // No implementation required +} + +result +PackageInfoListRetrieveThread::SetPackageType(void) +{ + return Start(); +} + +Object* +PackageInfoListRetrieveThread::Run(void) +{ + result r = E_SUCCESS; + PackageManager* pPackMgr = PackageManager::GetInstance(); + String currentAppName = UiApp::GetInstance()->GetAppName(); + int currentPage = 1; + int currentPosition = 0; + int totalApps = 0; + int totalPages = 0; + HashMap* pAppHashMap = null; + IList* pPackList = null; + IEnumerator* pEnum = null; + + if (pAppHashMap == null) + { + ArrayList* pArrayList = null; + Integer* pKey = null; + // constructs hashmap to maintain key(page number) value(list of icons associated to the page) pairs of all pages + pAppHashMap = new (std::nothrow) HashMap(); + r = pAppHashMap->Construct(); + pArrayList = new (std::nothrow) ArrayList(); + r = pArrayList->Construct(); + pKey = new (std::nothrow) Integer(currentPage); + r = pAppHashMap->Add(pKey, pArrayList); //transfers ownership to the hashmap + TryCatch(r == E_SUCCESS, delete pKey; + pKey = null; + delete pArrayList; + pArrayList = null, "pAppHashMap->Add(*pKey, *pArrayList) failed with error = %s", GetErrorMessage(r)); + + } + + if (pPackMgr != null) + { + pPackList = pPackMgr->GetPackageInfoListN(); + + if (pPackList == null) + { + __pPackageListener->OnPackageInfoRetrievedN(pAppHashMap, totalApps, totalPages); + return null; + } + + pEnum = pPackList->GetEnumeratorN(); + + while (pEnum != null && pEnum->MoveNext() == E_SUCCESS) + { +// PackageType type = PACKAGE_TYPE_TPK; + HomeItemInfo* pItemInfo = null; + ArrayList* pAppsList = null; + IList* pPackAppInfoList = null; + IEnumerator* pAppInfoEnumerator = null; + PackageInfo* pInfo = static_cast(pEnum->GetCurrent()); + TryCatch(pInfo != null, r = GetLastResult(), "pInfo is null error %s", GetErrorMessage(GetLastResult())); + pPackAppInfoList = pInfo->GetPackageAppInfoListN(); + + if (pPackAppInfoList != null) + { + pAppInfoEnumerator = pPackAppInfoList->GetEnumeratorN(); + + while (pAppInfoEnumerator != null && pAppInfoEnumerator->MoveNext() == E_SUCCESS) + { + PackageAppInfo* pPackAppInfo = static_cast(pAppInfoEnumerator->GetCurrent()); + pAppsList = static_cast(pAppHashMap->GetValue(Integer(currentPage))); + TryCatch(pAppsList != null, r = GetLastResult(), "pInfo is null error %s", GetErrorMessage(GetLastResult())); + // creates an instance of HomeItemInfo for each application to store the details of the application. + pItemInfo = new (std::nothrow) HomeItemInfo(); + r = pItemInfo->Initialize(pPackAppInfo, pInfo); + + if (!pItemInfo->IsVisibleInMainMenu() || pItemInfo->GetIconPath().IsEmpty()) + { + delete pItemInfo; + pItemInfo = null; + continue; + } + totalApps++; + pItemInfo->SetPositionInHomeScreen(currentPage, currentPosition); + + // adds to the list if not service application + // if (!pItemInfo->GetAppName().Contains(L"service") + // && !pItemInfo->GetAppName().Equals(currentAppName, true)) + { + currentPosition++; + r = pAppsList->Add(pItemInfo); + + if (IsFailed(r)) + { + AppLogException("Failed to pAppsList->Add(pItemInfo) error %s", GetErrorMessage(r)); + delete pItemInfo; + pItemInfo = null; + continue; + } + + if (currentPosition >= MAX_ICONS_PER_PAGE) + { + currentPage++; + currentPosition = 0; + ArrayList* pArrayList = new (std::nothrow) ArrayList(); + pArrayList->Construct(); + Integer* pKey = new (std::nothrow) Integer(currentPage); + pAppHashMap->Add(pKey, pArrayList); //transfers ownership to the hashmap + } + } + // else + // { + // delete pItemInfo; + // pItemInfo = null; + // } + } + if (pAppInfoEnumerator != null) + { + delete pAppInfoEnumerator; + pAppInfoEnumerator = null; + } + } + + pPackAppInfoList->RemoveAll(); + delete pPackAppInfoList; + pPackAppInfoList = null; + } + + if (currentPosition == 0 && currentPage > 1) + { + pAppHashMap->Remove(Integer(currentPage), true); + totalPages = currentPage - 1; + } + else + { + totalPages = currentPage; + } + + __pPackageListener->OnPackageInfoRetrievedN(pAppHashMap, totalApps, totalPages); + pAppHashMap = null; //ownership transferred to the caller + + if (pEnum != null) + { + delete pEnum; + pEnum = null; + } + + if (pPackList != null) + { + pPackList->RemoveAll(true); + delete pPackList; + pPackList = null; + } + } + + return null; + +CATCH: + + if (pEnum != null) + { + delete pEnum; + pEnum = null; + } + + if (pPackList != null) + { + pPackList->RemoveAll(true); + delete pPackList; + pPackList = null; + } + + if (pAppHashMap != null) + { + if (pAppHashMap->GetCount() > 0) + { + IList* pKeysList = pAppHashMap->GetKeysN(); + + for (int keyCount = 0; keyCount < pKeysList->GetCount(); keyCount++) + { + ArrayList* pAppList = static_cast(pAppHashMap->GetValue(*static_cast(pKeysList->GetAt(keyCount)))); + + if (pAppList != null) + { + pAppList->RemoveAll(true); + } + } + + pKeysList->RemoveAll(); + delete pKeysList; + } + + pAppHashMap->RemoveAll(true); + delete pAppHashMap; + pAppHashMap = null; + } + + return null; +} diff --git a/src/HmProgressPanel.cpp b/src/HmProgressPanel.cpp new file mode 100644 index 0000000..38da4b0 --- /dev/null +++ b/src/HmProgressPanel.cpp @@ -0,0 +1,215 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmProgressPanel.cpp + * @brief Keeps implementation of ProgressPanel Implementation + */ +#include +#include +#include +#include +#include "HmApplicationUtils.h" +#include "HmProgressPanel.h" +#include "HmTypes.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Media; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Ui::Controls; + +ProgressPanel::ProgressPanel(void) + : __pAnimationFrameList(null) + , __pAnimation(null) +{ + +} +ProgressPanel::~ProgressPanel(void) +{ + if (__pAnimationFrameList != null) + { + __pAnimationFrameList->RemoveAll(true); + delete __pAnimationFrameList; + } +} + +result +ProgressPanel::Construct(const Tizen::Graphics::Rectangle& controlRectangle) +{ + result r = E_SUCCESS; + long duration = DURATION_FOR_EACH_IMAGE / MAX_BITMAP_COUNT; + r = Panel::Construct(controlRectangle); + TryCatch(r == E_SUCCESS, , "Panel::Construct failed with error = %s", GetErrorMessage(r)); + __pAnimationFrameList = new (std::nothrow) ArrayList(); + __pAnimationFrameList->Construct(); + + // Create Bitmaps + for (int bmpCount = 0; bmpCount < MAX_BITMAP_COUNT; bmpCount++) + { + Bitmap* pProgressBitmap = null; + String bitmapName(WAIT_CURSOR_IMAGE_BASE); + bitmapName.Append(bmpCount); + bitmapName.Append(BITMAP_EXTENSION); + + pProgressBitmap = ApplicationUtils::GetResourceBitmapN(bitmapName); + + if (pProgressBitmap != null) + { + AnimationFrame* pProgressAniFrame = new (std::nothrow) AnimationFrame(*pProgressBitmap, duration); + + if (pProgressAniFrame != null) + { + r = __pAnimationFrameList->Add(pProgressAniFrame); + + if (IsFailed(r)) + { + delete pProgressAniFrame; + pProgressAniFrame = null; + } + } + + delete pProgressBitmap; + pProgressBitmap = null; + } + } + + // Create Animation + __pAnimation = new (std::nothrow) Animation(); + r = __pAnimation->Construct(Rectangle((controlRectangle.width / 2 - WAIT_CURSUR_DIMESION / 2), (controlRectangle.height / 2 - WAIT_CURSUR_DIMESION / 2), + WAIT_CURSUR_DIMESION, WAIT_CURSUR_DIMESION), *__pAnimationFrameList); + TryCatch(r == E_SUCCESS, , "__pAnimation->Construct failed with error = %s", GetErrorMessage(r)); + __pAnimation->SetRepeatCount(REPEAT_COUNT); + r = AddControl(*__pAnimation); + TryCatch(r == E_SUCCESS, , "AddControl(*__pAnimation) failed with error = %s", GetErrorMessage(r)); + + return r; + +CATCH: + + if (__pAnimation != null) + { + delete __pAnimation; + __pAnimation = null; + } + + if (__pAnimationFrameList) + { + __pAnimationFrameList->RemoveAll(true); + delete __pAnimationFrameList; + __pAnimationFrameList = null; + } + + return r; +} + +result +ProgressPanel::StartAnimation(void) +{ + + result r = E_SUCCESS; + bool animatorFailed = false; + ControlAnimator* pAniControlAnimator = null; + + TryReturn(__pAnimation != null, E_INVALID_STATE, "Animation is not yet constructed"); + + pAniControlAnimator = __pAnimation->GetControlAnimator(); + + if (pAniControlAnimator != null) + { + if (pAniControlAnimator->GetStatus() == ANIMATOR_STATUS_PLAYING) + { + r = pAniControlAnimator->StopAllAnimations(); + } + + if (r == E_SUCCESS) + { + r = pAniControlAnimator->SetShowState(true); + + if (IsFailed(r)) + { + animatorFailed = true; + } + } + else + { + animatorFailed = true; + } + + if (animatorFailed) + { + r = __pAnimation->SetShowState(true); + } + + __pAnimation->Play(); + RequestRedraw(true); + } + else + { + return E_FAILURE; + } + return r; +} + +result +ProgressPanel::StopAnimation(void) +{ + + result r = E_SUCCESS; + bool animatorFailed = false; + ControlAnimator* pAniControlAnimator = null; + + TryReturn(__pAnimation != null, E_INVALID_STATE, "Animation is not yet constructed"); + pAniControlAnimator = __pAnimation->GetControlAnimator(); + + if (pAniControlAnimator != null) + { + if (pAniControlAnimator->GetStatus() == ANIMATOR_STATUS_PLAYING) + { + r = pAniControlAnimator->StopAllAnimations(); + } + + if (r == E_SUCCESS) + { + r = pAniControlAnimator->SetShowState(false); + + if (IsFailed(r)) + { + animatorFailed = true; + } + } + else + { + animatorFailed = true; + } + + if (animatorFailed) + { + r = __pAnimation->SetShowState(false); + } + + __pAnimation->Stop(); + } + else + { + r = E_FAILURE; + } + + return r; +} diff --git a/src/HmTypes.cpp b/src/HmTypes.cpp new file mode 100644 index 0000000..fb73f0f --- /dev/null +++ b/src/HmTypes.cpp @@ -0,0 +1,104 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. +// + +/** + * @file HmTypes.cpp + * @brief Keeps all the constants definitions, used throughout the application + */ + +#include +#include "HmTypes.h" + +using namespace Tizen::Graphics; + +const wchar_t* IDB_BACKGROUND_IMAGE = L"BG.png"; +const wchar_t* IDB_CLOSE_ICON = L"Menu_Btn_Uninstall.png"; +const wchar_t* IDB_SELECTED_BUBBLE_TOP = L"Page_indicator_0"; +const wchar_t* IDB_BUBBLE_TOP = L"Page_indicator_002.png"; +const wchar_t* IDB_SETTING_BUTTON = L"Menu_Btn_setting.png"; +const wchar_t* IDB_SETTING_BUTTON_PRESSED = L"Menu_Btn_setting_press.png"; +const wchar_t* SETTINGS_KEY_WALLPAPER = L"http://tizen.org/setting/screen.wallpaper"; +const wchar_t* SETTINGS_KEY_LANGUAGE = L"http://tizen.org/setting/locale.language"; +const wchar_t* WAIT_CURSOR_IMAGE_BASE = L"progressing0"; +const wchar_t* BITMAP_EXTENSION = L".png"; +const wchar_t* IDB_DEFAULT_APP_ICON = L"default_app_icon.png"; +const wchar_t* APP_ID_REPLACE_STR = L"org.tizen."; +const wchar_t* SETTING_ANIMATION_PROPERTY_NAME = L"Opacity"; +const wchar_t* HOME_DATABASE_NAME = L"data/HomeDB.db"; +const wchar_t* HOME_APPLICATIONS_TABLE = L"homeapps"; +const wchar_t* APPS_RECORD_ID = L"appRecordID"; +const wchar_t* APPS_APP_ID = L"appId"; +const wchar_t* APPS_APP_NAME = L"appName"; +const wchar_t* APPS_APP_ICON = L"appIconPath"; +const wchar_t* APPS_APP_PAGE = L"pageNumber"; +const wchar_t* APPS_APP_PAGEINDEX = L"iconIndex"; +//DATATYPES +const wchar_t* DATATYPE_INTEGER_PRIMARY = L"INTEGER PRIMARY KEY"; +const wchar_t* DATATYPE_INTEGER = L"INTEGER"; +const wchar_t* DATATYPE_TEXT = L"TEXT"; +const wchar_t* DATATYPE_UNIQUE = L" UNIQUE"; +const wchar_t* CREATE_TABLE = L"CREATE TABLE IF NOT EXISTS "; +const wchar_t* INSERT_TABLE = L"INSERT INTO "; +const wchar_t* SELECT_TABLE = L"SELECT * FROM "; +const wchar_t* DELETE_TABLE = L"DELETE FROM "; +const wchar_t* UPDATE_TABLE = L"UPDATE "; +const wchar_t* GET_LAST_RECORD_ID = L"SELECT last_insert_rowid() FROM "; + +const unsigned int COLOR_SETTING_BOUNDARY_INNER = Color32<44, 44, 44>::Value; + +const int X_MARKER_LABEL_OFFSET = 10; +const int X_MARKER_POSITION = 156; +const int Y_MARKER_POSITION = 42; +const int W_MARKER_LABEL = 34; +const int H_MARKER_LABEL = 34; +const int W_MARKER_OFFSET = 130; +const int W_APPLICATION_ICON = 170; +const int H_APPLICATION_ICON = 212; +const int X_PAGE_POSITION = 0; +const int X_PAGE_OFFSET = 20; +const int H_EDIT = 60; +const int H_CONTROL_OFFSET = 10; +const int H_APP_CAPTION_TEXT = 68; +const int Y_APP_ICON_IMAGE_START = 24; +const int H_PAGE_MARKER = 104; +const int W_DEFAULT_PAGE = 720; +const int X_SETTING_PANEL = 6; +const int Y_SETTING_PANEL = 42; +const int W_SETTING_PANEL = 138; +const int H_SETTING_PANEL = 48; +const int X_SETTING_PANEL_PRESSED_OFFSET = 14; +const int SIZE_SETTING_LABEL_OFFSET = 2; +const int GAP_ICON_HORIZONTAL = 0; +const int GAP_ICON_VERTICAL = 0; +const int OVERLAY_BITMAP_DIMENSION = 60; +const int WAIT_CURSUR_DIMESION = 96; +const int APP_ICON_IMAGE_SIZE = 96; +const int DURATION_FOR_EACH_IMAGE = 500; +const int DURATION_SETTING_ANIMATION = 500; +const int LONG_TOUCH_GESTURE_DURATION = 300; //miliseconds +const int MOVEMENT_UPDATE_DURATION = 2000; +const int SCROLL_ANIMATION_DURATION = 20; +const int FONT_SIZE_APP_CAPTION = 23; +const unsigned int COLOR_APP_ICON_CAPTION = Color32<249, 249, 249>::Value; +const unsigned int COLOR_APP_CAPTION_SHADOW1 = Color32<100, 100, 100>::Value; +const unsigned int COLOR_APP_CAPTION_SHADOW2 = Color32<40, 40, 40>::Value; +const int IDA_OVERLAYBITMAP_CLOSE = 100; +const int IDA_SETTING_BUTTON = 101; +const int MAX_ICONS_PER_PAGE = 20; +const int MAX_PAGE_COUNT = 9; +const int MAX_BITMAP_COUNT = 8; +const int REPEAT_COUNT = 10000; +const int MOVING_ICON_OPACITY = 120;