2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file StAppSettingForm.cpp
19 * @brief This is the implementation file for AppSettingForm class.
22 #include "StAppSettingForm.h"
23 #include "StResourceManager.h"
24 #include "StSettingScenesList.h"
27 using namespace Tizen::App;
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Collection;
30 using namespace Tizen::Base::Utility;
31 using namespace Tizen::Graphics;
32 using namespace Tizen::Io;
33 using namespace Tizen::Ui;
34 using namespace Tizen::Ui::Controls;
35 using namespace Tizen::Ui::Scenes;
37 static const int APPSETTING_DEFAULT_COUNT = 1;
38 static const int ID_APPSETTTING_ARGUMENT_DEFAULT = 0;
39 static const int ID_APPSETTTING_ARGUMENT_APP_ID = 1;
40 static const int ID_APPSETTTING_ARGUMENT_COUNT = 2;
42 static const wchar_t* DEFAULT_VALUE_STRING = L"1";
43 static const wchar_t* ID_POST_FIX_BUTTON_DONE = L"DONE";
44 static const wchar_t* ID_POST_FIX_BUTTON_CANCEL = L"CANCEL";
46 static const wchar_t* ID_APPSETTING_ITEM_TYPE_BOOL = L"bool";
47 static const wchar_t* ID_APPSETTING_ITEM_TYPE_INTEGER = L"integer";
48 static const wchar_t* ID_APPSETTING_ITEM_TYPE_STRING = L"string";
49 static const wchar_t* ID_APPSETTING_ITEM_TYPE_LABEL = L"label";
50 static const wchar_t* ID_APPSETTING_ITEM_TYPE_EXPAND_LIST = L"expandlist";
51 static const wchar_t* ID_APPSETTING_ITEM_TYPE_EXPAND_ITEM = L"expanditem";
52 static const wchar_t* ID_APPSETTING_ITEM_TYPE_SEPARATOR = L"separator";
54 static const wchar_t* ID_APPSETTING_ATTRIBUTE_TYPE_TITLE = L"title";
55 static const wchar_t* ID_APPSETTING_ATTRIBUTE_TYPE_MIN = L"min";
56 static const wchar_t* ID_APPSETTING_ATTRIBUTE_TYPE_MAX = L"max";
57 static const wchar_t* ID_APPSETTING_ATTRIBUTE_TYPE_VALUE = L"value";
58 static const wchar_t* ID_APPSETTING_ATTRIBUTE_TYPE_MIN_LENGTH = L"minlength";
59 static const wchar_t* ID_APPSETTING_ATTRIBUTE_TYPE_MAX_LENGTH = L"maxlength";
61 static const int ITEM_WIDTH_GAP = 100;
63 AppSettingForm::AppSettingForm(void)
66 , __isNoTitleGroup(true)
67 , __pIOAppSetting(null)
68 , __pGroupItemNodeList(null)
69 , __pTranslateTableIndexToHashCode(null)
70 , __pTranslateTableHashCodeToItemTag(null)
71 , __pItemHashcodeHashMap(null)
75 AppSettingForm::~AppSettingForm(void)
80 AppSettingForm::CreateFooter(void)
82 Footer* pFooter = GetFooter();
85 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
86 pFooter->AddActionEventListener(*this);
87 SetFormBackEventListener(this);
91 AppSettingForm::SetHeaderTitle(void)
93 if (__pGroupItemNodeList == null)
95 AppLogDebug("__pGroupItemNodeList is null");
96 CreateHeader(L"AppSettingDefault");
101 result r = __pGroupItemNodeList->GetAt(0, pNode);
107 AppLogDebug("pNode is null");
111 AppLogDebug("GetAt fail [%s]", GetErrorMessage(r));
113 CreateHeader(L"AppSettingDefault");
117 Node* pParent = pNode->GetParent();
118 if ((pParent == null)
119 || (!pParent->GetType().Equals(L"setting", false)))
123 AppLogDebug("pParent is null");
127 AppLogDebug("pParent is not setting element [%ls]", pParent->GetType().GetPointer());
129 CreateHeader(L"AppSettingDefault");
133 String* pTitle = pParent->GetAttributeN(L"title");
136 AppLogDebug("pTitle is null");
137 CreateHeader(L"AppSettingDefault");
141 CreateHeader(*pTitle);
146 AppSettingForm::OnInitializing(void)
152 AppSettingForm::AppSettingManagerInit(Tizen::Base::String rootId, Tizen::Base::String filePath)
154 __pAppSettingManager = AppSettingManager::GetInstance();
155 if (__pAppSettingManager == null)
157 AppLogDebug("AppSettingManager::GetInstance fail");
161 ElementNode* pRoot = __pAppSettingManager->AddAppSettingRootNode(rootId);
162 result r = __pAppSettingManager->XmlAppSettingFileRead(filePath, pRoot);
165 __pAppSettingManager->RemoveAppSettingRootNode(rootId);
166 AppLogDebug("XmlAppSettingFileRead fail [%s]", GetErrorMessage(r));
174 AppSettingForm::SetGroupItemNodeList(Tizen::Base::String rootId)
176 InitGroupItemNodeList();
178 if (__pAppSettingManager == null)
180 AppLogDebug("__pAppSettingManager is null");
184 ElementNode* pRoot = __pAppSettingManager->GetAppSettingRootNode(rootId);
188 AppLogDebug("AppId is not found");
192 bool isFindSttingElement = false;
194 Enumerator* pEnum = pRoot->CreateEnumerator();
195 while (pEnum->MoveNext() == E_SUCCESS)
197 pNode = static_cast<Node*>(pEnum->GetCurrentObject());
198 if (pNode->GetType().Equals(L"setting", false))
200 isFindSttingElement = true;
206 if ((isFindSttingElement == false)
208 || (pNode->GetNodeType() == Node::NODE_TYPE_LEAF))
210 if (isFindSttingElement == false)
212 AppLogDebug("Setting Element is not found");
216 AppLogDebug("Child is not found");
221 ElementNode* pElementNode = dynamic_cast<ElementNode*>(pNode);
222 if (pElementNode == null)
224 AppLogDebug("dynamic_cast<ElementNode*>(pNode) is null");
227 unsigned int childCount = pElementNode->GetChildCount();
230 AppLogDebug("Child is zero");
234 result r = E_FAILURE;
235 for (unsigned int i = 0; i < childCount; i++)
237 if (pElementNode->GetChild(i)->GetType().Equals(L"navigationbar", false))
242 r = __pGroupItemNodeList->Add(pElementNode->GetChild(i));
245 AppLogDebug("Add fail");
246 RemoveAllGroupItemNodeList();
250 r = AddItemHashCodeMap(pElementNode->GetChild(i)->GetId().GetHashCode(), pElementNode->GetChild(i));
253 AppLogDebug("AddItemHashCodeMap fail");
254 RemoveAllGroupItemNodeList();
263 AppSettingForm::RemoveAllGroupItemNodeList(void)
265 if (__pGroupItemNodeList != null)
267 __pGroupItemNodeList->RemoveAll();
268 delete __pGroupItemNodeList;
269 __pGroupItemNodeList = null;
274 AppSettingForm::InitGroupItemNodeList(void)
276 RemoveAllGroupItemNodeList();
278 __pGroupItemNodeList = new (std::nothrow) LinkedListT<Node*>;
279 if (__pGroupItemNodeList == null)
281 AppLogDebug("__pGroupItemNodeList create fail");
289 AppSettingForm::InitItemHashCodeMap(void)
291 RemoveAllItemHashCodeMap();
293 __pItemHashcodeHashMap = new (std::nothrow) HashMapT<unsigned int, Node*>;
294 if (__pItemHashcodeHashMap == null)
296 AppLogDebug("__pItemHashcodeHashMap create fail");
300 result r = __pItemHashcodeHashMap->Construct();
303 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
304 RemoveAllItemHashCodeMap();
311 AppSettingForm::AddItemHashCodeMap(unsigned int hashCode, Node* pNode)
313 if (__pItemHashcodeHashMap == null)
315 AppLogDebug("__pItemHashcodeHashMap is null");
319 result r = __pItemHashcodeHashMap->Add(hashCode, pNode);
325 AppSettingForm::MakeTranslateTable(void)
327 if ((__pGroupItemNodeList == null)
328 || (__pItemHashcodeHashMap == null))
330 AppLogDebug("__pGroupItemNodeList or __pItemHashcodeHashMap is null");
334 unsigned int groupItemListCount = __pGroupItemNodeList->GetCount();
335 if (groupItemListCount == 0)
337 AppLogDebug("groupItemListCount is zero");
341 result r = E_FAILURE;
343 Enumerator* pEnum = null;
345 for (unsigned int i = 0; i < groupItemListCount; i++)
347 r = __pGroupItemNodeList->GetAt(i, pNode);
353 AppLogDebug("pNode is null");
358 AppLogDebug("GetAt fail [%s]", GetErrorMessage(r));
361 RemoveAllTranslateTableIndexToHashCode();
362 RemoveAllItemHashCodeMap();
367 ArrayListT<unsigned int>* pGroupItemHashCode = new (std::nothrow) ArrayListT<unsigned int>;
368 if (pGroupItemHashCode == null)
370 AppLogDebug("pNode is null");
372 RemoveAllTranslateTableIndexToHashCode();
373 RemoveAllItemHashCodeMap();
378 r = pGroupItemHashCode->Construct();
381 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
382 RemoveAllTranslateTableIndexToHashCode();
383 RemoveAllItemHashCodeMap();
385 pGroupItemHashCode->RemoveAll();
386 delete pGroupItemHashCode;
391 int enumLoopCount = 0;
392 pEnum = pNode->CreateEnumerator();
393 while (pEnum->MoveNext() == E_SUCCESS)
395 Node* pCurrent = static_cast<Node*>(pEnum->GetCurrentObject());
396 if (pCurrent == null)
398 AppLogDebug("pNode is null");
399 RemoveAllTranslateTableIndexToHashCode();
400 RemoveAllItemHashCodeMap();
403 pGroupItemHashCode->RemoveAll();
404 delete pGroupItemHashCode;
409 unsigned int idHashCode = pCurrent->GetId().GetHashCode();
411 r = AddItemHashCodeMap(idHashCode, pCurrent);
414 AppLogDebug("Add fail [%s]", GetErrorMessage(r));
415 RemoveAllTranslateTableIndexToHashCode();
416 RemoveAllItemHashCodeMap();
419 pGroupItemHashCode->RemoveAll();
420 delete pGroupItemHashCode;
425 r = pGroupItemHashCode->Add(idHashCode);
428 AppLogDebug("Add fail [%s]", GetErrorMessage(r));
429 RemoveAllTranslateTableIndexToHashCode();
430 RemoveAllItemHashCodeMap();
433 pGroupItemHashCode->RemoveAll();
434 delete pGroupItemHashCode;
438 SetTranslateTableHashCodeToItemTag(idHashCode, new (std::nothrow) ItemTag(i, enumLoopCount));
439 enumLoopCount = enumLoopCount + APPSETTING_DEFAULT_COUNT;
441 if (enumLoopCount == 0)
445 unsigned int idHashCode = pNode->GetId().GetHashCode();
447 r = pGroupItemHashCode->Add(idHashCode);
450 AppLogDebug("Add fail [%s]", GetErrorMessage(r));
451 RemoveAllTranslateTableIndexToHashCode();
452 RemoveAllItemHashCodeMap();
455 pGroupItemHashCode->RemoveAll();
456 delete pGroupItemHashCode;
460 SetTranslateTableHashCodeToItemTag(idHashCode, new (std::nothrow) ItemTag(i, enumLoopCount));
465 r = SetTranslateTableIndexToHashCode(pGroupItemHashCode);
468 AppLogDebug("SetTranslateTableIndexToHashCode fail [%s]", GetErrorMessage(r));
469 RemoveAllTranslateTableIndexToHashCode();
470 RemoveAllItemHashCodeMap();
472 pGroupItemHashCode->RemoveAll();
473 delete pGroupItemHashCode;
483 AppSettingForm::GetItemHashCodeMap(unsigned int hashCode)
485 if (__pItemHashcodeHashMap == null)
487 AppLogDebug("__pItemHashcodeHashMap is null");
491 bool isFindKey = false;
492 result r = __pItemHashcodeHashMap->ContainsKey(hashCode, isFindKey);
493 if ((isFindKey == false)
496 if (isFindKey == false)
498 AppLogDebug("Key is not found");
502 AppLogDebug("ContainsKey fail [%s]", GetErrorMessage(r));
508 Node* pValueNode = null;
509 r = __pItemHashcodeHashMap->GetValue(hashCode, pValueNode);
510 if ((pValueNode == null)
513 if (pValueNode == null)
515 AppLogDebug("pValueNode is null");
519 AppLogDebug("GetValue fail [%s]", GetErrorMessage(r));
529 AppSettingForm::RemoveAllItemHashCodeMap(void) // must be modify
531 if (__pItemHashcodeHashMap != null)
533 __pItemHashcodeHashMap->RemoveAll();
534 delete __pItemHashcodeHashMap;
535 __pItemHashcodeHashMap = null;
540 AppSettingForm::InitTranslateTableIndexToHashCode(void)
542 if (__pTranslateTableIndexToHashCode != null)
544 AppLogDebug("__pTranslateTableIndexToHashCode is not null");
548 __pTranslateTableIndexToHashCode = new (std::nothrow) ArrayListT<ArrayListT<unsigned int>*>;
549 if (__pTranslateTableIndexToHashCode == null)
551 AppLogDebug("__pTranslateTableIndexToHashCode create fail");
555 result r = __pTranslateTableIndexToHashCode->Construct();
558 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
559 RemoveAllTranslateTableIndexToHashCode();
566 AppSettingForm::InitTranslateTableHashCodeToItemTag(void)
568 if (__pTranslateTableHashCodeToItemTag != null)
570 AppLogDebug("__pTranslateTableIndexToHashCode is not null");
573 __pTranslateTableHashCodeToItemTag = new (std::nothrow) HashMapT<unsigned int, ItemTag*>;
574 if (__pTranslateTableHashCodeToItemTag == null)
576 AppLogDebug("__pTranslateTableHashCodeToItemTag create fail");
579 result r = __pTranslateTableHashCodeToItemTag->Construct();
582 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
583 RemoveAllTranslateTableHashCodeToItemTag();
589 AppSettingForm::SetTranslateTableHashCodeToItemTag(int hashCode, ItemTag* itemTag)
591 InitTranslateTableHashCodeToItemTag();
592 if (__pTranslateTableHashCodeToItemTag == null)
594 AppLogDebug("__pTranslateTableHashCodeToItemTag is null");
597 return __pTranslateTableHashCodeToItemTag->Add(hashCode, itemTag);
601 AppSettingForm::GetTranslateTableHashCodeToItemTag(unsigned int hashCode)
603 if (__pTranslateTableHashCodeToItemTag == null)
605 AppLogDebug("__pTranslateTableHashCodeToItemTag is null");
608 bool isFindKey = false;
609 result r = __pTranslateTableHashCodeToItemTag->ContainsKey(hashCode, isFindKey);
610 if ((isFindKey == false)
613 if (isFindKey == false)
615 AppLogDebug("Key is not found");
619 AppLogDebug("ContainsKey fail [%s]", GetErrorMessage(r));
623 ItemTag* pValueItemTag = null;
624 r = __pTranslateTableHashCodeToItemTag->GetValue(hashCode, pValueItemTag);
625 if ((pValueItemTag == null)
628 if (pValueItemTag == null)
630 AppLogDebug("pValueItemTag is null");
634 AppLogDebug("GetValue fail [%s]", GetErrorMessage(r));
638 return pValueItemTag;
642 AppSettingForm::RemoveAllTranslateTableHashCodeToItemTag(void)
644 if (__pTranslateTableHashCodeToItemTag != null)
646 __pTranslateTableHashCodeToItemTag->RemoveAll();
647 delete __pTranslateTableHashCodeToItemTag;
648 __pTranslateTableHashCodeToItemTag = null;
653 AppSettingForm::SetTranslateTableIndexToHashCode(Tizen::Base::Collection::ArrayListT<unsigned int>* groupItemHashCode)
655 InitTranslateTableIndexToHashCode();
657 if (__pTranslateTableIndexToHashCode == null)
659 AppLogDebug("__pTranslateTableIndexToHashCode is null");
663 result r = __pTranslateTableIndexToHashCode->Add(groupItemHashCode);
666 AppLogDebug("Add fail [%s]", GetErrorMessage(r));
673 AppSettingForm::GetTranslateTableIndexToHashCode(unsigned int groupIndex, unsigned int itemIndex)
675 unsigned int retHashCode = 0;
677 if (__pTranslateTableIndexToHashCode == null)
679 AppLogDebug("__pTranslateTableIndexToHashCode is null");
683 unsigned int groupCount = __pTranslateTableIndexToHashCode->GetCount();
684 if ((groupIndex >= groupCount)
685 || (groupCount == 0))
687 AppLogDebug("groupIndex is not found");
691 ArrayListT<unsigned int>* pItemList = null;
692 result r = __pTranslateTableIndexToHashCode->GetAt(groupIndex, pItemList);
693 if ((pItemList == null)
696 if (pItemList == null)
698 AppLogDebug("pItemList is null");
702 AppLogDebug("GetAt fail [%s]", GetErrorMessage(r));
708 unsigned int itemCount = pItemList->GetCount();
709 if ((itemIndex >= itemCount)
712 AppLogDebug("itemIndex is not found");
716 r = pItemList->GetAt(itemIndex, retHashCode);
719 AppLogDebug("GetAt fail [%s]", GetErrorMessage(r));
729 AppSettingForm::GetItemCountByTranslateTable(unsigned int groupIndex)
731 unsigned int itemCount = 0;
732 if (__pTranslateTableIndexToHashCode == null)
734 AppLogDebug("__pTranslateTableIndexToHashCode is null");
738 unsigned int groupCount = __pTranslateTableIndexToHashCode->GetCount();
739 if ((groupIndex >= groupCount)
740 || (groupCount == 0))
742 AppLogDebug("groupIndex is not found");
746 ArrayListT<unsigned int>* pItemList = null;
747 result r = __pTranslateTableIndexToHashCode->GetAt(groupIndex, pItemList);
748 if ((pItemList == null)
751 if (pItemList == null)
753 AppLogDebug("pItemList is null");
757 AppLogDebug("GetAt fail [%s]", GetErrorMessage(r));
763 itemCount = pItemList->GetCount();
766 itemCount = APPSETTING_DEFAULT_COUNT;
773 AppSettingForm::RemoveAllTranslateTableIndexToHashCode(void)
775 if (__pTranslateTableIndexToHashCode != null)
777 unsigned int groupCount = __pTranslateTableIndexToHashCode->GetCount();
780 for (unsigned int i = 0; i < groupCount; i++)
782 ArrayListT<unsigned int>* itemList = null;
783 __pTranslateTableIndexToHashCode->GetAt(i, itemList);
785 if (itemList != null)
787 itemList->RemoveAll();
793 __pTranslateTableIndexToHashCode->RemoveAll();
794 delete __pTranslateTableIndexToHashCode;
795 __pTranslateTableIndexToHashCode = null;
800 AppSettingForm::IOAppSettingInit(Tizen::Base::String appId)
802 __pIOAppSetting = new (std::nothrow) IOAppSetting();
803 if (__pIOAppSetting == null)
805 AppLogDebug("__pIOAppSetting Create failed");
809 result r = __pIOAppSetting->Constructor(appId);
812 RemoveIOAppSetting();
819 AppSettingForm::RemoveIOAppSetting(void)
821 if (__pIOAppSetting != null)
823 delete __pIOAppSetting;
824 __pIOAppSetting = null;
829 AppSettingForm::OnTerminating(void)
834 __pTableView->SetItemProvider(null);
838 int contorlCount = GetControlCount();
839 for (int i = 0; i < contorlCount; i++)
841 RemoveControl(GetControl(0));
843 // RemoveAllControls();
845 RemoveAllGroupItemNodeList();
846 RemoveAllItemHashCodeMap();
847 RemoveAllTranslateTableIndexToHashCode();
848 RemoveAllTranslateTableHashCodeToItemTag();
849 RemoveIOAppSetting();
851 if (__pAppSettingManager != null)
853 __pAppSettingManager->RemoveAppSettingRootNode(__appId);
854 __pAppSettingManager = null;
857 SceneManager* pSceneManager = SceneManager::GetInstance();
858 AppAssert(pSceneManager);
860 pSceneManager->UnregisterScene(__appId);
862 SetFormBackEventListener(null);
867 AppSettingForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
869 Node* pRootNode = null;
870 Enumerator* pEnum = null;
871 String* pArgsValue[ID_APPSETTTING_ARGUMENT_COUNT] = {null, };
876 AppLogDebug("pArgs is null");
880 argsCount = pArgs->GetCount();
881 if (argsCount != ID_APPSETTTING_ARGUMENT_COUNT)
883 AppLogDebug("Wrong count of pArgs");
888 for (int i = 0; i < argsCount; i++)
890 pArgsValue[i] = static_cast<String*>(pArgs->GetAt(i));
891 if (pArgsValue[i] == null)
893 AppLogDebug("pArgsValue[%d] is null", i);
900 StringTokenizer stringTokenizer(*pArgsValue[ID_APPSETTTING_ARGUMENT_DEFAULT], L":");
901 result r = stringTokenizer.GetNextToken(appId);
902 TryCatch(r == E_SUCCESS, , "GetNextToken fail[%s]", GetErrorMessage(r));
904 r = stringTokenizer.GetNextToken(appId);
906 || (appId.IsEmpty() == true))
912 TryCatch(r == E_SUCCESS, , "GetNextToken fail[%s]", GetErrorMessage(r));
915 if (__appId.IsEmpty() == true)
917 __appId.Append(appId);
920 __filePath = *pArgsValue[ID_APPSETTTING_ARGUMENT_APP_ID];
921 r = AppSettingManagerInit(appId, __filePath);
922 TryCatch(r == E_SUCCESS, , "AppSettingManagerInit fail [%s]", GetErrorMessage(r));
924 InitItemHashCodeMap();
925 r = SetGroupItemNodeList(appId);
926 TryCatch(r == E_SUCCESS, , "SetGroupItemNodeList fail");
928 r = MakeTranslateTable();
929 TryCatch(r == E_SUCCESS, , "MakeTranslateTable fail");
931 IOAppSettingInit(__appId);
936 __pTableView->UpdateTableView();
937 pRootNode = __pAppSettingManager->GetAppSettingRootNode(__appId);
938 pEnum = pRootNode->CreateEnumerator();
939 while (pEnum->MoveNext() == E_SUCCESS)
941 Node* pCurrent = static_cast<Node*>(pEnum->GetCurrentObject());
942 if (pCurrent->GetType().Equals(ID_APPSETTING_ITEM_TYPE_BOOL, false))
944 unsigned int hashCode = pCurrent->GetId().GetHashCode();
945 ItemTag* itemTag = GetTranslateTableHashCodeToItemTag(hashCode);
950 String* pValue = pCurrent->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
951 if ((pValue->Equals(L"true", false))
952 || (pValue->Equals(L"1", false)))
954 __pTableView->SetItemChecked(itemTag->GetGroupIndex(), itemTag->GetItemIndex(), true);
958 else if (pCurrent->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
961 ElementNode* pExpandListItem = dynamic_cast<ElementNode*>(pCurrent);
962 if (pExpandListItem == null)
966 String* pExpandListValue = pExpandListItem->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
967 for (int i = 0; i < pExpandListItem->GetChildCount(); i++)
969 ElementLeaf* pElementLeaf = dynamic_cast<ElementLeaf*>(pExpandListItem->GetChild(i));
970 if (pElementLeaf == null)
974 String* pExpandItemValue = pElementLeaf->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
975 if (!pExpandListValue->Equals(*pExpandItemValue, false))
977 delete pExpandItemValue;
981 unsigned int hashCode = pElementLeaf->GetId().GetHashCode();
982 ItemTag* itemTag = GetTranslateTableHashCodeToItemTag(hashCode);
987 __pTableView->SetItemChecked(itemTag->GetGroupIndex(), itemTag->GetItemIndex(), true);
988 delete pExpandItemValue;
990 delete pExpandListValue;
994 ElementLeaf* pElementLeaf = dynamic_cast<ElementLeaf*>(pExpandListItem->GetChild(0));
995 unsigned int hashCode = pElementLeaf->GetId().GetHashCode();
996 String* value = pElementLeaf->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
998 AppLogDebug("value[%ls]", value->GetPointer());
999 ItemTag* itemTag = GetTranslateTableHashCodeToItemTag(hashCode);
1000 if (itemTag == null)
1002 AppLogDebug("itemTag == null");
1004 __pTableView->SetItemChecked(itemTag->GetGroupIndex(), itemTag->GetItemIndex(), true);
1005 pExpandListItem->SetAttribute(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE, *value);
1006 RefreshExpandListItem(itemTag->GetGroupIndex());
1021 CreateHeader(L"Error");
1023 AppLogDebug("AppSettingForm Initialize fail");
1027 AppSettingForm::CreateNoContents(void)
1029 Rectangle clientRect = GetClientAreaBounds();
1031 String labelText = ResourceManager::GetString(L"IDS_RSSR_BODY_INVALID_FORMAT");
1033 if (labelText.IsEmpty())
1035 labelText = L"Invalid Format.. \ncheck XML file again";
1038 Label* pInvalidFormatLabel = new (std::nothrow) Label();
1039 pInvalidFormatLabel->Construct(clientRect, labelText);
1040 pInvalidFormatLabel->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
1041 pInvalidFormatLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1042 pInvalidFormatLabel->SetTextConfig(GetFontSize(), LABEL_TEXT_STYLE_NORMAL);
1043 pInvalidFormatLabel->SetBackgroundColor(COLOR_BG_GROUP_ITEM_LISTITEM);
1044 pInvalidFormatLabel->SetName(L"InvalidFormat");
1045 AddControl(pInvalidFormatLabel);
1050 AppSettingForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
1055 AppSettingForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
1058 bool errorStatus = false;
1059 int currentLength = 0;
1060 int stringLengthMax = 0;
1061 int stringLengthMin = 0;
1063 if (__pIOAppSetting != null)
1065 Node* pRootNode = null;
1066 Enumerator* pEnum = null;
1067 pRootNode = __pAppSettingManager->GetAppSettingRootNode(__appId);
1070 pEnum = pRootNode->CreateEnumerator();
1073 while (pEnum->MoveNext() == E_SUCCESS)
1075 Node* pCurrent = static_cast<Node*>(pEnum->GetCurrentObject());
1076 if (pCurrent->GetType().Equals(ID_APPSETTING_ITEM_TYPE_STRING, false))
1078 String* itemText = pCurrent->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1079 String* pMinLength = pCurrent->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MIN_LENGTH);
1080 String* pMaxLength = pCurrent->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MAX_LENGTH);
1082 currentLength = itemText->GetLength();
1083 Integer::Parse(*pMinLength, stringLengthMin);
1084 Integer::Parse(*pMaxLength, stringLengthMax);
1090 if ((currentLength > stringLengthMax) || (currentLength < stringLengthMin))
1092 if (currentLength > stringLengthMax)
1094 AppLogDebug("value length(%d) greater than maximum range(%d), show popup", currentLength, stringLengthMax);
1098 AppLogDebug("value length(%d) smaller than minimum range(%d), show popup", currentLength, stringLengthMin);
1101 MessageBox messageBox;
1102 int result = E_SUCCESS;
1104 messageBox.Construct(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_COM_POP_FAILED"), MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIME_2_SEC);
1105 messageBox.ShowAndWait(result);
1116 if (errorStatus == false)
1118 __pIOAppSetting->UpdateChangedValue();
1119 SceneManager* pSceneManager = SceneManager::GetInstance();
1120 AppAssert(pSceneManager);
1122 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
1132 SceneManager* pSceneManager = SceneManager::GetInstance();
1133 AppAssert(pSceneManager);
1134 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
1139 AppSettingForm::GetGroupCount(void)
1141 if (__pGroupItemNodeList != null)
1143 return __pGroupItemNodeList->GetCount();
1146 return APPSETTING_DEFAULT_COUNT;
1150 AppSettingForm::GetItemCount(int groupIndex)
1152 return GetItemCountByTranslateTable(groupIndex);
1156 AppSettingForm::CreateGroupItem(int groupIndex, int itemWidth)
1158 AppLogDebug("ENTER");
1160 int itemHeight = H_GROUP_INDEX_DEFAULT;
1161 int yItemOffset = Y_GROUP_INDEX_DEFAULT;
1162 LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
1163 Rectangle itemMainRectangle;
1164 String* groupText = null;
1166 Label* pLabel = null;
1167 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
1169 __pGroupItemNodeList->GetAt(groupIndex, pNode);
1171 itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
1172 itemMainRectangle.y = yItemOffset;
1173 itemMainRectangle.width = itemWidth;
1174 itemMainRectangle.height = itemHeight;
1176 itemHeight = H_GROUP_INDEX_DEFAULT;
1177 itemMainRectangle.y = H_GROUP_INDEX_TITLE_TEXT;
1178 itemMainRectangle.height = H_GROUP_INDEX_DEFAULT - H_GROUP_INDEX_TITLE_TEXT;
1179 groupText = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
1180 if (groupText == null)
1182 AppLogDebug("grpText null");
1187 if (!pNode->GetType().Equals(L"group", false))
1189 if (__isNoTitleGroup == true)
1191 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
1192 __isNoTitleGroup = false;
1201 __isNoTitleGroup = true;
1204 if (pNode->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1206 ItemTypeOneLine(itemMainRectangle);
1207 itemHeight = itemMainRectangle.height;
1210 if ((pNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1212 String* value = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1215 AppLogDebug("groupText [%ls] value [%ls]", groupText->GetPointer(), value->GetPointer());
1217 pNode->RegisterObserverlistener(__pIOAppSetting);
1219 pItem->Construct(Dimension(itemMainRectangle.width, itemMainRectangle.height));
1220 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1222 expendList.Append(groupText->GetPointer());
1223 expendList.Append(L" : ");
1224 expendList.Append(value->GetPointer());
1228 pLabel = new (std::nothrow) Label();
1229 pLabel->Construct(itemMainRectangle, expendList);
1230 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1231 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1232 pLabel->SetName(pNode->GetId());
1234 pItem->AddControl(pLabel);
1235 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1236 pItem->SetEnabled(true);
1242 pItem->Construct(Dimension(itemWidth, itemHeight));
1243 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
1245 Label* pLabel = new (std::nothrow) Label();
1247 pLabel->Construct(itemMainRectangle, (*groupText).GetPointer());
1248 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1249 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
1251 pItem->AddControl(pLabel);
1253 pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, style);
1254 pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
1256 pItem->SetEnabled(false);
1264 AppSettingForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
1266 Rectangle itemMainRectangle;
1267 Label* pLabel = null;
1269 String* itemText = null;
1271 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
1273 unsigned int hashCode = GetTranslateTableIndexToHashCode(groupIndex, itemIndex);
1275 Node* pItemNode = GetItemHashCodeMap(hashCode);
1276 if (pItemNode == null)
1278 result r = __pGroupItemNodeList->GetAt(groupIndex, pItemNode);
1281 AppLogDebug("pItemNode is null");
1285 pItemNode = GetItemHashCodeMap(pItemNode->GetId().GetHashCode());
1286 if (pItemNode == null)
1288 AppLogDebug("pItemNode is null");
1293 TableViewItem* pItem = new (std::nothrow) TableViewItem();
1295 itemText = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
1296 itemType = pItemNode->GetType();
1297 ItemTypeOneLine(itemMainRectangle);
1299 if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_BOOL, false))
1301 bool toggleValue = false;
1302 String* valueString = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1304 pItemNode->RegisterObserverlistener(__pIOAppSetting);
1306 style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
1308 RelativeLayout relativeLayout;
1309 relativeLayout.Construct();
1311 pItem->Construct(relativeLayout, Dimension(itemWidth, itemMainRectangle.height), style);
1312 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1314 pLabel = new (std::nothrow) Label();
1315 pLabel->Construct(itemMainRectangle, (itemText)->GetPointer());
1316 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1317 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1319 pItem->AddControl(pLabel);
1320 relativeLayout.SetMargin(*pLabel, 0, 150, 0, 0);
1321 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
1322 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
1325 toggleValue = Boolean::Parse((*valueString).GetPointer(), true);
1327 if ((toggleValue != false) || (*valueString == DEFAULT_VALUE_STRING))
1329 __pTableView->SetItemChecked(groupIndex, itemIndex, true);
1333 else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_INTEGER, false))
1335 Slider* pSlider = null;
1340 pItemNode->RegisterObserverlistener(__pIOAppSetting);
1342 itemMainRectangle.width = (itemWidth - ITEM_WIDTH_GAP);
1343 itemMainRectangle.height = H_GROUP_ITEM_DEFAULT_SLIDER;
1345 RelativeLayout relativeLayout;
1346 relativeLayout.Construct();
1347 pItem->Construct(relativeLayout, Dimension(itemWidth, itemMainRectangle.height), style);
1348 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1350 String* minValueString = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MIN);
1351 String* maxValueString = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MAX);
1352 String* setValueString = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1354 Integer::Parse((*minValueString).GetPointer(), minValue);
1355 Integer::Parse((*maxValueString).GetPointer(), maxValue);
1356 Integer::Parse((*setValueString).GetPointer(), setValue);
1358 pSlider = new (std::nothrow) Slider();
1359 result r = pSlider->Construct(itemMainRectangle, BACKGROUND_STYLE_NONE, true, minValue, maxValue);
1362 delete minValueString;
1363 delete maxValueString;
1364 delete setValueString;
1369 pSlider->SetTitleText((*itemText).GetPointer());
1370 pSlider->SetValue(setValue);
1371 pSlider->AddAdjustmentEventListener(*this);
1372 pSlider->AddSliderEventListener(*this);
1373 pSlider->SetName(pItemNode->GetId());
1375 pItem->AddControl(pSlider);
1376 pItem->SetIndividualSelectionEnabled(pSlider, true);
1377 relativeLayout.SetMargin(*pSlider, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
1378 relativeLayout.SetRelation(*pSlider, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
1379 relativeLayout.SetRelation(*pSlider, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
1381 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1382 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1383 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED);
1384 delete minValueString;
1385 delete maxValueString;
1386 delete setValueString;
1388 else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_STRING, false))
1390 itemMainRectangle.x = 0;
1391 int stringLengthMin = 0;
1392 int stringLengthMax = 0;
1394 String* pMinLength = static_cast<String*>(pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MIN_LENGTH));
1395 if (pMinLength != null)
1397 Integer::Parse(*pMinLength, stringLengthMin);
1399 AppLogDebug("max String size [%d]", stringLengthMin);
1402 String* pMaxLength = static_cast<String*>(pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MAX_LENGTH));
1403 if (pMaxLength != null)
1405 Integer::Parse(*pMaxLength, stringLengthMax);
1407 AppLogDebug("max String size [%d]", stringLengthMax);
1410 if (stringLengthMax == 0)
1416 RelativeLayout relativeLayout;
1417 relativeLayout.Construct();
1418 pItem->Construct(relativeLayout, Dimension(itemWidth, itemMainRectangle.height), style);
1419 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1421 pItemNode->RegisterObserverlistener(__pIOAppSetting);
1423 String id = pItemNode->GetId();
1424 String setActionIdDone(id);
1425 String setActionIdCancel(id);
1427 setActionIdDone.Append(ID_POST_FIX_BUTTON_DONE);
1428 setActionIdCancel.Append(ID_POST_FIX_BUTTON_CANCEL);
1430 EditField* pEditField = new (std::nothrow) EditField();
1431 String* secondLine = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1433 itemMainRectangle.x = X_GROUP_DEFAULT;
1434 pEditField->Construct(Rectangle(itemMainRectangle.x, itemMainRectangle.y+H_ITEM_TYPE_GAP, itemMainRectangle.width,itemMainRectangle.height-Y_GROUP_ITEM_DEFAULT), EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY, EDIT_FIELD_TITLE_STYLE_TOP, true, stringLengthMax, GROUP_STYLE_NONE);
1435 pEditField->SetGuideText((*itemText).GetPointer());
1436 pEditField->SetTitleText((*itemText).GetPointer());
1437 pEditField->SetText((*secondLine).GetPointer());
1440 pEditField->SetTextSize(FONT_SIZE_SUB_TEXT);
1441 pEditField->SetTitleTextColor(EDIT_STATUS_NORMAL, COLOR_HELP_TEXT_TYPE_01);
1442 pEditField->SetTitleTextColor(EDIT_STATUS_PRESSED, COLOR_HELP_TEXT_TYPE_01);
1443 pEditField->SetTitleTextColor(EDIT_STATUS_HIGHLIGHTED, COLOR_HELP_TEXT_TYPE_01);
1444 pEditField->SetColor(EDIT_STATUS_NORMAL, COLOR_BG_GROUP_ITEM_DEFAULT);
1445 pEditField->SetColor(EDIT_STATUS_PRESSED, COLOR_BG_GROUP_ITEM_DEFAULT);
1446 pEditField->SetColor(EDIT_STATUS_HIGHLIGHTED, COLOR_BG_GROUP_ITEM_DEFAULT);
1447 pEditField->SetColor(EDIT_STATUS_DISABLED, COLOR_BG_GROUP_ITEM_DEFAULT);
1448 pEditField->AddActionEventListener(*this);
1449 pEditField->AddTextEventListener(*this);
1450 pEditField->SetName(id);
1451 pEditField->AddKeypadEventListener(*this);
1453 pItem->AddControl(pEditField);
1454 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1455 pItem->SetIndividualSelectionEnabled(pEditField, true);
1457 relativeLayout.SetMargin(*pEditField, Y_GROUP_ITEM_DEFAULT, 0, 0, 0);
1458 relativeLayout.SetRelation(*pEditField, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
1459 relativeLayout.SetRelation(*pEditField, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
1461 else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_LABEL, false))
1463 pItem->Construct(Dimension(itemWidth, itemMainRectangle.height), style);
1464 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1466 pLabel = new (std::nothrow) Label();
1467 pLabel->Construct(itemMainRectangle, (itemText)->GetPointer());
1468 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1469 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1470 pLabel->SetName(pItemNode->GetId());
1471 pItem->AddControl(pLabel);
1472 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1474 else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1476 IEnumerator* pCurrentIEnumerator = pItemNode->GetCurrentIEnumerator();
1478 if (!((pCurrentIEnumerator != null)
1479 && (pCurrentIEnumerator->MoveNext() == E_SUCCESS)))
1481 AppLogDebug("Expandlist has no expandItems & remove");
1482 delete pCurrentIEnumerator;
1488 String* value = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1491 pItemNode->RegisterObserverlistener(__pIOAppSetting);
1493 pItem->Construct(Dimension(itemWidth, itemMainRectangle.height), style);
1494 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1496 expendList.Append(itemText->GetPointer());
1497 expendList.Append(L" : ");
1498 expendList.Append(value->GetPointer());
1502 pLabel = new (std::nothrow) Label();
1503 pLabel->Construct(itemMainRectangle, expendList);
1504 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1505 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1506 pLabel->SetName(pItemNode->GetId());
1508 pItem->AddControl(pLabel);
1509 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1511 else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_ITEM, false))
1513 style = TABLE_VIEW_ANNEX_STYLE_RADIO;
1515 RelativeLayout relativeLayout;
1516 relativeLayout.Construct();
1517 pItem->Construct(relativeLayout, Dimension(itemWidth, itemMainRectangle.height), style);
1518 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_LISTITEM);
1520 Node* parent = pItemNode->GetParent();
1522 String* pParentValue = (parent->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE));
1523 String* pCurrentValue = (pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE));
1525 if (pCurrentValue->Equals(*pParentValue, true))
1527 __pTableView->SetItemChecked(groupIndex, itemIndex, true);
1530 pLabel = new (std::nothrow) Label();
1531 pLabel->Construct(itemMainRectangle, (itemText)->GetPointer());
1532 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1533 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1535 pItem->AddControl(pLabel);
1536 delete pParentValue;
1537 delete pCurrentValue;
1538 relativeLayout.SetMargin(*pLabel, RELATIVE_LAYOUT_LEFT_MARGIN, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
1539 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
1540 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
1542 else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_SEPARATOR, false))
1544 Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_SEPARATOR);
1545 itemMainRectangle.height = H_GROUP_INDEX_NO_TITLE_DEFAULT;
1547 if (pBitmap == null)
1549 AppLogDebug("bitmap is null ");
1550 AppLogDebug("separator id [%ls]", pItemNode->GetId().GetPointer());
1553 RelativeLayout relativeLayout;
1554 relativeLayout.Construct();
1555 pItem->Construct(relativeLayout, Dimension(itemWidth, itemMainRectangle.height), TABLE_VIEW_ANNEX_STYLE_NORMAL);
1557 pLabel = new (std::nothrow) Label();
1558 pLabel->Construct(itemMainRectangle, L" ");
1559 pLabel->SetBackgroundBitmap(*pBitmap);
1560 pItem->AddControl(pLabel);
1563 pItem->SetEnabled(false);
1565 relativeLayout.SetMargin(*pLabel, RELATIVE_LAYOUT_RIGHT_MARGIN, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
1566 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
1567 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
1571 AppLogDebug("pItem is null");
1581 AppSettingForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
1590 AppSettingForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
1599 AppSettingForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1601 unsigned int hashCode = GetTranslateTableIndexToHashCode(groupIndex, itemIndex);
1602 AppLogDebug("%d %d", groupIndex, itemIndex);
1603 Node* pItemNode = GetItemHashCodeMap(hashCode);
1604 if (pItemNode == null)
1606 AppLogDebug("pItemNode is null");
1610 if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_ITEM, false))
1612 ElementNode* pParent = dynamic_cast<ElementNode*>(pItemNode->GetParent());
1613 if (pParent == null)
1615 AppLogDebug("pParent is null");
1619 if (!pParent->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1621 AppLogDebug("pParent is not ITEM_TYPE_EXPAND_LIST");
1625 String* pValue = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
1628 AppLogDebug("pValue is null");
1632 pParent->SetAttribute(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE, *pValue);
1635 unsigned int hashCode = pParent->GetId().GetHashCode();
1636 ItemTag* itemTag = GetTranslateTableHashCodeToItemTag(hashCode);
1638 if (itemTag == null)
1640 int itemCount = __pTableView->GetItemCountAt(groupIndex);
1642 for (int count = 0; count < itemCount; count++)
1644 bool itemSelectStatus = false;
1645 if (count == itemIndex)
1647 itemSelectStatus = true;
1649 __pTableView->SetItemChecked(groupIndex, count, itemSelectStatus);
1651 RefreshExpandListItem(groupIndex);
1657 int loopCount = pParent->GetChildCount() + itemTag->GetItemIndex() + APPSETTING_DEFAULT_COUNT;
1659 for (int pos = itemTag->GetItemIndex() + APPSETTING_DEFAULT_COUNT; pos < loopCount; pos++)
1661 if (pos != itemIndex)
1663 __pTableView->SetItemChecked(groupIndex, pos, false);
1667 __pTableView->SetItemChecked(groupIndex, pos, true);
1670 __pTableView->RefreshItem(itemTag->GetGroupIndex(), itemTag->GetItemIndex(), TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1672 if (__pIOAppSetting != null)
1674 __pIOAppSetting->UpdateChangedValue();
1678 //pItem->SetFocus();
1680 else if (pItemNode->GetType().Equals(ID_APPSETTING_ITEM_TYPE_BOOL, false))
1682 bool itemSelectStatus = tableView.IsItemChecked(groupIndex, itemIndex);
1684 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
1686 itemSelectStatus = (!itemSelectStatus);
1688 tableView.SetItemChecked(groupIndex, itemIndex, itemSelectStatus);
1689 pItemNode->SetAttribute(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE, Boolean::ToString(itemSelectStatus));
1691 if (__pIOAppSetting != null)
1693 __pIOAppSetting->UpdateChangedValue();
1695 //pItem->SetFocus();
1699 AppLogDebug("null");
1700 //pItem->SetFocus();
1705 AppSettingForm::OnActionPerformed(const Control& source, int actionId)
1707 String sourceNametmp(source.GetName());
1708 String sourceName(L"");
1710 StringTokenizer stringTokenizer(sourceNametmp, L":");
1711 stringTokenizer.GetNextToken(sourceName);
1713 Node* pNode = GetItemHashCodeMap(sourceName.GetHashCode());
1716 AppLogDebug("pNode is null");
1722 AppSettingForm::GetDefaultGroupItemHeight(void)
1724 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
1728 AppSettingForm::GetDefaultItemHeight(void)
1730 return H_GROUP_ITEM_DEFAULT;
1734 AppSettingForm::RefreshExpandListItem(int groupIndex)
1736 int itemCount = __pTableView->GetItemCountAt(groupIndex);
1738 for (int count = -1; count < itemCount; count++)
1740 __pTableView->RefreshItem(groupIndex, count, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1745 AppSettingForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
1749 __pGroupItemNodeList->GetAt(groupIndex, pNode);
1751 if (pNode->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1753 Label* pLabel = static_cast<Label*>(pItem->GetControl(0));
1756 String* groupText = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
1757 String* value = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1759 expandList.Append(groupText->GetPointer());
1760 expandList.Append(L" : ");
1761 expandList.Append(value->GetPointer());
1763 AppLogDebug("itemChanged [%ls]", expandList.GetPointer());
1764 pLabel->SetText(expandList);
1765 pLabel->Invalidate(false);
1769 pItem->Invalidate(false);
1773 AppSettingForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1776 unsigned int hashCode = GetTranslateTableIndexToHashCode(groupIndex, itemIndex);
1777 Node* pItemNode = GetItemHashCodeMap(hashCode);
1778 if (pItemNode == null)
1780 AppLogDebug("GetItemHashCodeMap is null");
1784 Label* pLabel = static_cast<Label*>(pItem->GetControl(pItemNode->GetId(), false));
1787 pLabel->SetSize(GetClientAreaBounds().width - TWO_LINE_ITEM_WIDTH_GAP,pLabel->GetHeight());
1790 if (!pItemNode->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1792 if (pItemNode->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_ITEM, false))
1794 AppLogDebug("pItemNode->GetType not equal ID_APPSETTING_ITEM_TYPE_EXPAND_LIST [%ls]", pItemNode->GetType().GetPointer());
1795 pItem->Invalidate(false);
1797 else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_INTEGER, false))
1799 Slider* pSlider = static_cast<Slider*>(pItem->GetControl(0));
1800 pItem->SetIndividualSelectionEnabled(pSlider, true);
1805 String* pTitle = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
1806 String* pValue = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1807 if (pValue == null || pTitle == null)
1809 AppLogDebug("GetAttributeN is null");
1817 String expendList(*pTitle);
1818 expendList.Append(L" : ");
1819 expendList.Append(*pValue);
1821 pLabel->SetText(expendList);
1822 pLabel->Invalidate(false);
1825 pItem->Invalidate(false);
1831 AppSettingForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1836 AppSettingForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1841 AppSettingForm::OnAdjustmentValueChanged(const Tizen::Ui::Control& source, int adjustment)
1843 String sourceName = source.GetName();
1845 Node* pNode = GetItemHashCodeMap(sourceName.GetHashCode());
1848 AppLogDebug("pNode is null");
1852 pNode->SetAttribute(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE, Integer::ToString(adjustment));
1854 if (__pIOAppSetting != null)
1856 __pIOAppSetting->UpdateChangedValue();
1861 AppSettingForm::OnSliderBarMoved(Tizen::Ui::Controls::Slider& source, int value)
1863 //source.SetFocus();
1867 AppSettingForm::OnTextValueChanged(const Tizen::Ui::Control& source)
1869 String sourceName = source.GetName();
1871 Node* pNode = GetItemHashCodeMap(sourceName.GetHashCode());
1874 AppLogDebug("pNode is null");
1878 EditField* pEditField = static_cast<EditField*>(&const_cast<Control&>(source));
1882 changedText = pEditField->GetText();
1885 pNode->SetAttribute(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE, changedText);
1887 String* pMin = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MIN_LENGTH);
1888 String* pMax = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MAX_LENGTH);
1892 int currentLength = pEditField->GetTextLength();
1894 Integer::Parse(*pMin, minLength);
1895 Integer::Parse(*pMax, maxLength);
1897 if ((minLength <= currentLength) && (maxLength >= currentLength))
1899 if (__pIOAppSetting != null)
1901 AppLogDebug(" current[%d] min [%d] max[%d]", currentLength, minLength, maxLength);
1902 __pIOAppSetting->UpdateChangedValue();
1911 AppSettingForm::OnKeypadOpened(Tizen::Ui::Control& source)
1913 unsigned int hashCode = source.GetName().GetHashCode();
1914 ItemTag* itemTag = GetTranslateTableHashCodeToItemTag(hashCode);
1917 __pTableView->ScrollToItem(itemTag->GetGroupIndex(), itemTag->GetItemIndex(), TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_BOTTOM);
1922 AppSettingForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
1927 AppSettingForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
1930 if (__pTableView == null)
1932 Label* pLabel = static_cast<Label*>(GetControl(L"InvalidFormat"));
1936 Rectangle clientRect = GetClientAreaBounds();
1937 Rectangle labelRect = pLabel->GetBounds();
1939 labelRect = clientRect;
1942 pLabel->SetBounds(labelRect);
1943 pLabel->Invalidate(false);
1949 __pTableView->RefreshAllItems();
1955 AppSettingForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1958 result r = E_SUCCESS;
1959 Enumerator* pEnum = null;
1960 Node* pRootNode = null;
1962 if (requestId == BACK_GROUND_EVENT)
1964 RemoveAllGroupItemNodeList();
1965 RemoveAllItemHashCodeMap();
1966 RemoveAllTranslateTableIndexToHashCode();
1967 RemoveAllTranslateTableHashCodeToItemTag();
1968 RemoveIOAppSetting();
1970 __pAppSettingManager->RemoveAppSettingRootNode(__appId);
1971 __pAppSettingManager = null;
1973 AppLog("App going to background");
1979 AppLog("__appId = %S __filePath = %S",__appId.GetPointer(), __filePath.GetPointer());
1980 r = AppSettingManagerInit(__appId, __filePath);
1981 TryCatch(r == E_SUCCESS, , "AppSettingManagerInit fail [%s]", GetErrorMessage(r));
1983 InitItemHashCodeMap();
1984 r = SetGroupItemNodeList(__appId);
1985 TryCatch(r == E_SUCCESS, , "SetGroupItemNodeList fail");
1987 r = MakeTranslateTable();
1988 TryCatch(r == E_SUCCESS, , "MakeTranslateTable fail");
1990 IOAppSettingInit(__appId);
1994 __pTableView->UpdateTableView();
1995 __pTableView->SetFocus();
1996 pRootNode = __pAppSettingManager->GetAppSettingRootNode(__appId);
1999 pEnum = pRootNode->CreateEnumerator();
2000 while (pEnum->MoveNext() == E_SUCCESS)
2002 Node* pCurrent = static_cast<Node*>(pEnum->GetCurrentObject());
2003 if (pCurrent->GetType().Equals(ID_APPSETTING_ITEM_TYPE_BOOL, false))
2005 unsigned int hashCode = pCurrent->GetId().GetHashCode();
2006 ItemTag* itemTag = GetTranslateTableHashCodeToItemTag(hashCode);
2007 if (itemTag == null)
2011 String* pValue = pCurrent->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
2012 if ((pValue->Equals(L"true", false))
2013 || (pValue->Equals(L"1", false)))
2015 if(__pTableView->IsItemChecked(itemTag->GetGroupIndex(), itemTag->GetItemIndex()) == false)
2017 AppLog("Toggle buttonToggle button ++ %d %d", itemTag->GetGroupIndex(), itemTag->GetItemIndex());
2018 r = __pTableView->SetItemChecked(itemTag->GetGroupIndex(), itemTag->GetItemIndex(), true);
2019 AppLog("Toggle buttonToggle button ++ result = %s", GetErrorMessage(r));
2024 if(__pTableView->IsItemChecked(itemTag->GetGroupIndex(), itemTag->GetItemIndex()) == true)
2026 __pTableView->SetItemChecked(itemTag->GetGroupIndex(), itemTag->GetItemIndex(), false);
2027 AppLog("Toggle button --%d %d", itemTag->GetGroupIndex(), itemTag->GetItemIndex());
2032 else if (pCurrent->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
2035 ElementNode* pExpandListItem = dynamic_cast<ElementNode*>(pCurrent);
2036 if (pExpandListItem == null)
2040 String* pExpandListValue = pExpandListItem->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
2041 for (int i = 0; i < pExpandListItem->GetChildCount(); i++)
2043 ElementLeaf* pElementLeaf = dynamic_cast<ElementLeaf*>(pExpandListItem->GetChild(i));
2044 if (pElementLeaf == null)
2048 String* pExpandItemValue = pElementLeaf->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
2049 if (!pExpandListValue->Equals(*pExpandItemValue, false))
2051 delete pExpandItemValue;
2055 unsigned int hashCode = pElementLeaf->GetId().GetHashCode();
2056 ItemTag* itemTag = GetTranslateTableHashCodeToItemTag(hashCode);
2057 if (itemTag == null)
2061 int itemCount = __pTableView->GetItemCountAt(itemTag->GetGroupIndex());
2063 for (int count = -1; count < itemCount; count++)
2065 AppLog("Toggle button -- %d %d", itemTag->GetGroupIndex(), count);
2067 __pTableView->SetItemChecked(itemTag->GetGroupIndex(), count, false);
2070 AppLog("Toggle button ++ %d %d", itemTag->GetGroupIndex(), itemTag->GetItemIndex());
2071 __pTableView->SetItemChecked(itemTag->GetGroupIndex(), itemTag->GetItemIndex(), true);
2072 delete pExpandItemValue;
2074 delete pExpandListValue;
2076 if (itemSelect == 0)
2078 ElementLeaf* pElementLeaf = dynamic_cast<ElementLeaf*>(pExpandListItem->GetChild(0));
2079 unsigned int hashCode = pElementLeaf->GetId().GetHashCode();
2080 String* value = pElementLeaf->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
2082 AppLogDebug("value[%ls]", value->GetPointer());
2083 ItemTag* itemTag = GetTranslateTableHashCodeToItemTag(hashCode);
2084 if (itemTag == null)
2086 AppLogDebug("itemTag == null");
2088 __pTableView->SetItemChecked(itemTag->GetGroupIndex(), itemTag->GetItemIndex(), true);
2089 pExpandListItem->SetAttribute(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE, *value);
2090 RefreshExpandListItem(itemTag->GetGroupIndex());
2101 AppLog("Enter Catch");
2102 SceneManager* pSceneManager = SceneManager::GetInstance();
2103 AppAssert(pSceneManager);
2104 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
2113 ItemTag::SetItemTag(int groupIndex, int itemIndex)
2115 __groupIndex = groupIndex;
2116 __itemIndex = itemIndex;
2120 ItemTag::GetItemTag(int& groupIndex, int& itemIndex)
2122 groupIndex = __groupIndex;
2123 itemIndex = __itemIndex;