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"
26 using namespace Tizen::App;
27 using namespace Tizen::Base;
28 using namespace Tizen::Base::Collection;
29 using namespace Tizen::Base::Utility;
30 using namespace Tizen::Graphics;
31 using namespace Tizen::Io;
32 using namespace Tizen::Ui;
33 using namespace Tizen::Ui::Controls;
34 using namespace Tizen::Ui::Scenes;
36 static const int APPSETTING_DEFAULT_COUNT = 1;
37 static const int ID_APPSETTTING_ARGUMENT_DEFAULT = 0;
38 static const int ID_APPSETTTING_ARGUMENT_APP_ID = 1;
39 static const int ID_APPSETTTING_ARGUMENT_COUNT = 2;
41 static const wchar_t* DEFAULT_VALUE_STRING = L"1";
42 static const wchar_t* ID_POST_FIX_BUTTON_DONE = L"DONE";
43 static const wchar_t* ID_POST_FIX_BUTTON_CANCEL = L"CANCEL";
45 static const wchar_t* ID_APPSETTING_ITEM_TYPE_BOOL = L"bool";
46 static const wchar_t* ID_APPSETTING_ITEM_TYPE_INTEGER = L"integer";
47 static const wchar_t* ID_APPSETTING_ITEM_TYPE_STRING = L"string";
48 static const wchar_t* ID_APPSETTING_ITEM_TYPE_LABEL = L"label";
49 static const wchar_t* ID_APPSETTING_ITEM_TYPE_EXPAND_LIST = L"expandlist";
50 static const wchar_t* ID_APPSETTING_ITEM_TYPE_EXPAND_ITEM = L"expanditem";
51 static const wchar_t* ID_APPSETTING_ITEM_TYPE_SEPARATOR = L"separator";
53 static const wchar_t* ID_APPSETTING_ATTRIBUTE_TYPE_TITLE = L"title";
54 static const wchar_t* ID_APPSETTING_ATTRIBUTE_TYPE_MIN = L"min";
55 static const wchar_t* ID_APPSETTING_ATTRIBUTE_TYPE_MAX = L"max";
56 static const wchar_t* ID_APPSETTING_ATTRIBUTE_TYPE_VALUE = L"value";
57 static const wchar_t* ID_APPSETTING_ATTRIBUTE_TYPE_MIN_LENGTH = L"minlength";
58 static const wchar_t* ID_APPSETTING_ATTRIBUTE_TYPE_MAX_LENGTH = L"maxlength";
60 static const int ITEM_WIDTH_GAP = 100;
61 static const int H_RESIZE_LANDSCAPE_CLIPBOARD = 292;
62 static const int H_RESIZE_PORTRAIT_CLIPBOARD = 614;
64 static const int APP_SETTING_DEFAULT_COUNT = 1;
65 static const int IDA_HEADER_BACK_BUTTON = 500;
67 AppSettingForm::AppSettingForm(void)
70 , __isNoTitleGroup(true)
71 , __pIOAppSetting(null)
72 , __pGroupItemNodeList(null)
73 , __pTranslateTableIndexToHashCode(null)
74 , __pTranslateTableHashCodeToItemTag(null)
75 , __pItemHashcodeHashMap(null)
79 AppSettingForm::~AppSettingForm(void)
84 AppSettingForm::CreateFooter(void)
86 Footer* pFooter = GetFooter();
89 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
90 pFooter->AddActionEventListener(*this);
91 SetFormBackEventListener(this);
95 AppSettingForm::SetHeaderTitle(void)
97 if (__pGroupItemNodeList == null)
99 AppLogDebug("__pGroupItemNodeList is null");
100 CreateHeader(L"AppSettingDefault");
105 result r = __pGroupItemNodeList->GetAt(0, pNode);
111 AppLogDebug("pNode is null");
115 AppLogDebug("GetAt fail [%s]", GetErrorMessage(r));
117 CreateHeader(L"AppSettingDefault");
121 Node* pParent = pNode->GetParent();
122 if ((pParent == null)
123 || (!pParent->GetType().Equals(L"setting", false)))
127 AppLogDebug("pParent is null");
131 AppLogDebug("pParent is not setting element [%ls]", pParent->GetType().GetPointer());
133 CreateHeader(L"AppSettingDefault");
137 String* pTitle = pParent->GetAttributeN(L"title");
140 AppLogDebug("pTitle is null");
141 CreateHeader(L"AppSettingDefault");
145 CreateHeader(*pTitle);
150 AppSettingForm::OnInitializing(void)
156 AppSettingForm::AppSettingManagerInit(Tizen::Base::String rootId, Tizen::Base::String filePath)
158 __pAppSettingManager = AppSettingManager::GetInstance();
159 if (__pAppSettingManager == null)
161 AppLogDebug("AppSettingManager::GetInstance fail");
165 ElementNode* pRoot = __pAppSettingManager->AddAppSettingRootNode(rootId);
166 result r = __pAppSettingManager->XmlAppSettingFileRead(filePath, pRoot);
169 __pAppSettingManager->RemoveAppSettingRootNode(rootId);
170 AppLogDebug("XmlAppSettingFileRead fail [%s]", GetErrorMessage(r));
178 AppSettingForm::SetGroupItemNodeList(Tizen::Base::String rootId)
180 InitGroupItemNodeList();
182 if (__pAppSettingManager == null)
184 AppLogDebug("__pAppSettingManager is null");
188 ElementNode* pRoot = __pAppSettingManager->GetAppSettingRootNode(rootId);
192 AppLogDebug("AppId is not found");
196 bool isFindSttingElement = false;
198 Enumerator* pEnum = pRoot->CreateEnumerator();
199 while (pEnum->MoveNext() == E_SUCCESS)
201 pNode = static_cast<Node*>(pEnum->GetCurrentObject());
202 if (pNode->GetType().Equals(L"setting", false))
204 isFindSttingElement = true;
210 if ((isFindSttingElement == false)
212 || (pNode->GetNodeType() == Node::NODE_TYPE_LEAF))
214 if (isFindSttingElement == false)
216 AppLogDebug("Setting Element is not found");
220 AppLogDebug("Child is not found");
225 ElementNode* pElementNode = dynamic_cast<ElementNode*>(pNode);
226 if (pElementNode == null)
228 AppLogDebug("dynamic_cast<ElementNode*>(pNode) is null");
231 unsigned int childCount = pElementNode->GetChildCount();
234 AppLogDebug("Child is zero");
238 result r = E_FAILURE;
239 for (unsigned int i = 0; i < childCount; i++)
241 if (pElementNode->GetChild(i)->GetType().Equals(L"navigationbar", false))
246 r = __pGroupItemNodeList->Add(pElementNode->GetChild(i));
249 AppLogDebug("Add fail");
250 RemoveAllGroupItemNodeList();
254 r = AddItemHashCodeMap(pElementNode->GetChild(i)->GetId().GetHashCode(), pElementNode->GetChild(i));
257 AppLogDebug("AddItemHashCodeMap fail");
258 RemoveAllGroupItemNodeList();
267 AppSettingForm::RemoveAllGroupItemNodeList(void)
269 if (__pGroupItemNodeList != null)
271 __pGroupItemNodeList->RemoveAll();
272 delete __pGroupItemNodeList;
273 __pGroupItemNodeList = null;
278 AppSettingForm::InitGroupItemNodeList(void)
280 RemoveAllGroupItemNodeList();
282 __pGroupItemNodeList = new (std::nothrow) LinkedListT<Node*>;
283 if (__pGroupItemNodeList == null)
285 AppLogDebug("__pGroupItemNodeList create fail");
293 AppSettingForm::InitItemHashCodeMap(void)
295 RemoveAllItemHashCodeMap();
297 __pItemHashcodeHashMap = new (std::nothrow) HashMapT<unsigned int, Node*>;
298 if (__pItemHashcodeHashMap == null)
300 AppLogDebug("__pItemHashcodeHashMap create fail");
304 result r = __pItemHashcodeHashMap->Construct();
307 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
308 RemoveAllItemHashCodeMap();
315 AppSettingForm::AddItemHashCodeMap(unsigned int hashCode, Node* pNode)
317 if (__pItemHashcodeHashMap == null)
319 AppLogDebug("__pItemHashcodeHashMap is null");
323 result r = __pItemHashcodeHashMap->Add(hashCode, pNode);
329 AppSettingForm::MakeTranslateTable(void)
331 if ((__pGroupItemNodeList == null)
332 || (__pItemHashcodeHashMap == null))
334 AppLogDebug("__pGroupItemNodeList or __pItemHashcodeHashMap is null");
338 unsigned int groupItemListCount = __pGroupItemNodeList->GetCount();
339 if (groupItemListCount == 0)
341 AppLogDebug("groupItemListCount is zero");
345 result r = E_FAILURE;
347 Enumerator* pEnum = null;
349 for (unsigned int i = 0; i < groupItemListCount; i++)
351 r = __pGroupItemNodeList->GetAt(i, pNode);
357 AppLogDebug("pNode is null");
362 AppLogDebug("GetAt fail [%s]", GetErrorMessage(r));
365 RemoveAllTranslateTableIndexToHashCode();
366 RemoveAllItemHashCodeMap();
371 ArrayListT<unsigned int>* pGroupItemHashCode = new (std::nothrow) ArrayListT<unsigned int>;
372 if (pGroupItemHashCode == null)
374 AppLogDebug("pNode is null");
376 RemoveAllTranslateTableIndexToHashCode();
377 RemoveAllItemHashCodeMap();
382 r = pGroupItemHashCode->Construct();
385 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
386 RemoveAllTranslateTableIndexToHashCode();
387 RemoveAllItemHashCodeMap();
389 pGroupItemHashCode->RemoveAll();
390 delete pGroupItemHashCode;
395 int enumLoopCount = 0;
396 pEnum = pNode->CreateEnumerator();
397 while (pEnum->MoveNext() == E_SUCCESS)
399 Node* pCurrent = static_cast<Node*>(pEnum->GetCurrentObject());
400 if (pCurrent == null)
402 AppLogDebug("pNode is null");
403 RemoveAllTranslateTableIndexToHashCode();
404 RemoveAllItemHashCodeMap();
407 pGroupItemHashCode->RemoveAll();
408 delete pGroupItemHashCode;
413 unsigned int idHashCode = pCurrent->GetId().GetHashCode();
415 r = AddItemHashCodeMap(idHashCode, pCurrent);
418 AppLogDebug("Add fail [%s]", GetErrorMessage(r));
419 RemoveAllTranslateTableIndexToHashCode();
420 RemoveAllItemHashCodeMap();
423 pGroupItemHashCode->RemoveAll();
424 delete pGroupItemHashCode;
429 r = pGroupItemHashCode->Add(idHashCode);
432 AppLogDebug("Add fail [%s]", GetErrorMessage(r));
433 RemoveAllTranslateTableIndexToHashCode();
434 RemoveAllItemHashCodeMap();
437 pGroupItemHashCode->RemoveAll();
438 delete pGroupItemHashCode;
442 SetTranslateTableHashCodeToItemTag(idHashCode, new (std::nothrow) ItemTag(i, enumLoopCount));
443 enumLoopCount = enumLoopCount + APPSETTING_DEFAULT_COUNT;
445 if (enumLoopCount == 0)
449 unsigned int idHashCode = pNode->GetId().GetHashCode();
451 r = pGroupItemHashCode->Add(idHashCode);
454 AppLogDebug("Add fail [%s]", GetErrorMessage(r));
455 RemoveAllTranslateTableIndexToHashCode();
456 RemoveAllItemHashCodeMap();
459 pGroupItemHashCode->RemoveAll();
460 delete pGroupItemHashCode;
464 SetTranslateTableHashCodeToItemTag(idHashCode, new (std::nothrow) ItemTag(i, enumLoopCount));
469 r = SetTranslateTableIndexToHashCode(pGroupItemHashCode);
472 AppLogDebug("SetTranslateTableIndexToHashCode fail [%s]", GetErrorMessage(r));
473 RemoveAllTranslateTableIndexToHashCode();
474 RemoveAllItemHashCodeMap();
476 pGroupItemHashCode->RemoveAll();
477 delete pGroupItemHashCode;
487 AppSettingForm::GetItemHashCodeMap(unsigned int hashCode)
489 if (__pItemHashcodeHashMap == null)
491 AppLogDebug("__pItemHashcodeHashMap is null");
495 bool isFindKey = false;
496 result r = __pItemHashcodeHashMap->ContainsKey(hashCode, isFindKey);
497 if ((isFindKey == false)
500 if (isFindKey == false)
502 AppLogDebug("Key is not found");
506 AppLogDebug("ContainsKey fail [%s]", GetErrorMessage(r));
512 Node* pValueNode = null;
513 r = __pItemHashcodeHashMap->GetValue(hashCode, pValueNode);
514 if ((pValueNode == null)
517 if (pValueNode == null)
519 AppLogDebug("pValueNode is null");
523 AppLogDebug("GetValue fail [%s]", GetErrorMessage(r));
533 AppSettingForm::RemoveAllItemHashCodeMap(void) // must be modify
535 if (__pItemHashcodeHashMap != null)
537 __pItemHashcodeHashMap->RemoveAll();
538 delete __pItemHashcodeHashMap;
539 __pItemHashcodeHashMap = null;
544 AppSettingForm::InitTranslateTableIndexToHashCode(void)
546 if (__pTranslateTableIndexToHashCode != null)
548 AppLogDebug("__pTranslateTableIndexToHashCode is not null");
552 __pTranslateTableIndexToHashCode = new (std::nothrow) ArrayListT<ArrayListT<unsigned int>*>;
553 if (__pTranslateTableIndexToHashCode == null)
555 AppLogDebug("__pTranslateTableIndexToHashCode create fail");
559 result r = __pTranslateTableIndexToHashCode->Construct();
562 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
563 RemoveAllTranslateTableIndexToHashCode();
570 AppSettingForm::InitTranslateTableHashCodeToItemTag(void)
572 if (__pTranslateTableHashCodeToItemTag != null)
574 AppLogDebug("__pTranslateTableIndexToHashCode is not null");
577 __pTranslateTableHashCodeToItemTag = new (std::nothrow) HashMapT<unsigned int, ItemTag*>;
578 if (__pTranslateTableHashCodeToItemTag == null)
580 AppLogDebug("__pTranslateTableHashCodeToItemTag create fail");
583 result r = __pTranslateTableHashCodeToItemTag->Construct();
586 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
587 RemoveAllTranslateTableHashCodeToItemTag();
593 AppSettingForm::SetTranslateTableHashCodeToItemTag(int hashCode, ItemTag* itemTag)
595 InitTranslateTableHashCodeToItemTag();
596 if (__pTranslateTableHashCodeToItemTag == null)
598 AppLogDebug("__pTranslateTableHashCodeToItemTag is null");
601 return __pTranslateTableHashCodeToItemTag->Add(hashCode, itemTag);
605 AppSettingForm::GetTranslateTableHashCodeToItemTag(unsigned int hashCode)
607 if (__pTranslateTableHashCodeToItemTag == null)
609 AppLogDebug("__pTranslateTableHashCodeToItemTag is null");
612 bool isFindKey = false;
613 result r = __pTranslateTableHashCodeToItemTag->ContainsKey(hashCode, isFindKey);
614 if ((isFindKey == false)
617 if (isFindKey == false)
619 AppLogDebug("Key is not found");
623 AppLogDebug("ContainsKey fail [%s]", GetErrorMessage(r));
627 ItemTag* pValueItemTag = null;
628 r = __pTranslateTableHashCodeToItemTag->GetValue(hashCode, pValueItemTag);
629 if ((pValueItemTag == null)
632 if (pValueItemTag == null)
634 AppLogDebug("pValueItemTag is null");
638 AppLogDebug("GetValue fail [%s]", GetErrorMessage(r));
642 return pValueItemTag;
646 AppSettingForm::RemoveAllTranslateTableHashCodeToItemTag(void)
648 if (__pTranslateTableHashCodeToItemTag != null)
650 __pTranslateTableHashCodeToItemTag->RemoveAll();
651 delete __pTranslateTableHashCodeToItemTag;
652 __pTranslateTableHashCodeToItemTag = null;
657 AppSettingForm::SetTranslateTableIndexToHashCode(Tizen::Base::Collection::ArrayListT<unsigned int>* groupItemHashCode)
659 InitTranslateTableIndexToHashCode();
661 if (__pTranslateTableIndexToHashCode == null)
663 AppLogDebug("__pTranslateTableIndexToHashCode is null");
667 result r = __pTranslateTableIndexToHashCode->Add(groupItemHashCode);
670 AppLogDebug("Add fail [%s]", GetErrorMessage(r));
677 AppSettingForm::GetTranslateTableIndexToHashCode(unsigned int groupIndex, unsigned int itemIndex)
679 unsigned int retHashCode = 0;
681 if (__pTranslateTableIndexToHashCode == null)
683 AppLogDebug("__pTranslateTableIndexToHashCode is null");
687 unsigned int groupCount = __pTranslateTableIndexToHashCode->GetCount();
688 if ((groupIndex >= groupCount)
689 || (groupCount == 0))
691 AppLogDebug("groupIndex is not found");
695 ArrayListT<unsigned int>* pItemList = null;
696 result r = __pTranslateTableIndexToHashCode->GetAt(groupIndex, pItemList);
697 if ((pItemList == null)
700 if (pItemList == null)
702 AppLogDebug("pItemList is null");
706 AppLogDebug("GetAt fail [%s]", GetErrorMessage(r));
712 unsigned int itemCount = pItemList->GetCount();
713 if ((itemIndex >= itemCount)
716 AppLogDebug("itemIndex is not found");
720 r = pItemList->GetAt(itemIndex, retHashCode);
723 AppLogDebug("GetAt fail [%s]", GetErrorMessage(r));
733 AppSettingForm::GetItemCountByTranslateTable(unsigned int groupIndex)
735 unsigned int itemCount = 0;
736 if (__pTranslateTableIndexToHashCode == null)
738 AppLogDebug("__pTranslateTableIndexToHashCode is null");
742 unsigned int groupCount = __pTranslateTableIndexToHashCode->GetCount();
743 if ((groupIndex >= groupCount)
744 || (groupCount == 0))
746 AppLogDebug("groupIndex is not found");
750 ArrayListT<unsigned int>* pItemList = null;
751 result r = __pTranslateTableIndexToHashCode->GetAt(groupIndex, pItemList);
752 if ((pItemList == null)
755 if (pItemList == null)
757 AppLogDebug("pItemList is null");
761 AppLogDebug("GetAt fail [%s]", GetErrorMessage(r));
767 itemCount = pItemList->GetCount();
770 itemCount = APPSETTING_DEFAULT_COUNT;
777 AppSettingForm::RemoveAllTranslateTableIndexToHashCode(void)
779 if (__pTranslateTableIndexToHashCode != null)
781 unsigned int groupCount = __pTranslateTableIndexToHashCode->GetCount();
784 for (unsigned int i = 0; i < groupCount; i++)
786 ArrayListT<unsigned int>* itemList = null;
787 __pTranslateTableIndexToHashCode->GetAt(i, itemList);
789 if (itemList != null)
791 itemList->RemoveAll();
797 __pTranslateTableIndexToHashCode->RemoveAll();
798 delete __pTranslateTableIndexToHashCode;
799 __pTranslateTableIndexToHashCode = null;
804 AppSettingForm::IOAppSettingInit(Tizen::Base::String appId)
806 __pIOAppSetting = new (std::nothrow) IOAppSetting();
807 if (__pIOAppSetting == null)
809 AppLogDebug("__pIOAppSetting Create failed");
813 result r = __pIOAppSetting->Constructor(appId);
816 RemoveIOAppSetting();
823 AppSettingForm::RemoveIOAppSetting(void)
825 if (__pIOAppSetting != null)
827 delete __pIOAppSetting;
828 __pIOAppSetting = null;
833 AppSettingForm::OnTerminating(void)
837 __pTableView->SetItemProvider(null);
841 int contorlCount = GetControlCount();
842 for (int i = 0; i < contorlCount; i++)
844 RemoveControl(GetControl(0));
846 // RemoveAllControls();
848 RemoveAllGroupItemNodeList();
849 RemoveAllItemHashCodeMap();
850 RemoveAllTranslateTableIndexToHashCode();
851 RemoveAllTranslateTableHashCodeToItemTag();
852 RemoveIOAppSetting();
854 __pAppSettingManager->RemoveAppSettingRootNode(__appId);
855 __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 r = AppSettingManagerInit(appId, *pArgsValue[ID_APPSETTTING_ARGUMENT_APP_ID]);
916 TryCatch(r == E_SUCCESS, , "AppSettingManagerInit fail [%s]", GetErrorMessage(r));
918 InitItemHashCodeMap();
919 r = SetGroupItemNodeList(appId);
920 TryCatch(r == E_SUCCESS, , "SetGroupItemNodeList fail");
922 r = MakeTranslateTable();
923 TryCatch(r == E_SUCCESS, , "MakeTranslateTable fail");
924 if (__appId.IsEmpty() == true)
926 __appId.Append(appId);
929 IOAppSettingInit(__appId);
934 __pTableView->UpdateTableView();
935 pRootNode = __pAppSettingManager->GetAppSettingRootNode(__appId);
936 pEnum = pRootNode->CreateEnumerator();
937 while (pEnum->MoveNext() == E_SUCCESS)
939 Node* pCurrent = static_cast<Node*>(pEnum->GetCurrentObject());
940 if (pCurrent->GetType().Equals(ID_APPSETTING_ITEM_TYPE_BOOL, false))
942 unsigned int hashCode = pCurrent->GetId().GetHashCode();
943 ItemTag* itemTag = GetTranslateTableHashCodeToItemTag(hashCode);
948 String* pValue = pCurrent->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
949 if ((pValue->Equals(L"true", false))
950 || (pValue->Equals(L"1", false)))
952 __pTableView->SetItemChecked(itemTag->GetGroupIndex(), itemTag->GetItemIndex(), true);
956 else if (pCurrent->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
959 ElementNode* pExpandListItem = dynamic_cast<ElementNode*>(pCurrent);
960 if (pExpandListItem == null)
964 String* pExpandListValue = pExpandListItem->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
965 for (int i = 0; i < pExpandListItem->GetChildCount(); i++)
967 ElementLeaf* pElementLeaf = dynamic_cast<ElementLeaf*>(pExpandListItem->GetChild(i));
968 if (pElementLeaf == null)
972 String* pExpandItemValue = pElementLeaf->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
973 if (!pExpandListValue->Equals(*pExpandItemValue, false))
975 delete pExpandItemValue;
979 unsigned int hashCode = pElementLeaf->GetId().GetHashCode();
980 ItemTag* itemTag = GetTranslateTableHashCodeToItemTag(hashCode);
985 __pTableView->SetItemChecked(itemTag->GetGroupIndex(), itemTag->GetItemIndex(), true);
986 delete pExpandItemValue;
988 delete pExpandListValue;
992 ElementLeaf* pElementLeaf = dynamic_cast<ElementLeaf*>(pExpandListItem->GetChild(0));
993 unsigned int hashCode = pElementLeaf->GetId().GetHashCode();
994 String* value = pElementLeaf->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
996 AppLogDebug("value[%ls]", value->GetPointer());
997 ItemTag* itemTag = GetTranslateTableHashCodeToItemTag(hashCode);
1000 AppLogDebug("itemTag == null");
1002 __pTableView->SetItemChecked(itemTag->GetGroupIndex(), itemTag->GetItemIndex(), true);
1003 pExpandListItem->SetAttribute(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE, *value);
1004 RefreshExpandListItem(itemTag->GetGroupIndex());
1019 CreateHeader(L"Error");
1021 AppLogDebug("AppSettingForm Initialize fail");
1025 AppSettingForm::CreateNoContents(void)
1027 Rectangle clientRect = GetClientAreaBounds();
1029 String labelText = ResourceManager::GetString(L"IDS_RSSR_BODY_INVALID_FORMAT");
1031 if (labelText.IsEmpty())
1033 labelText = L"Invalid Format.. \ncheck XML file again";
1036 Label* pInvalidFormatLabel = new (std::nothrow) Label();
1037 pInvalidFormatLabel->Construct(clientRect, labelText);
1038 pInvalidFormatLabel->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
1039 pInvalidFormatLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1040 pInvalidFormatLabel->SetTextConfig(GetFontSize(), LABEL_TEXT_STYLE_NORMAL);
1041 pInvalidFormatLabel->SetBackgroundColor(COLOR_BG_GROUP_ITEM_LISTITEM);
1042 pInvalidFormatLabel->SetName(L"InvalidFormat");
1043 AddControl(pInvalidFormatLabel);
1048 AppSettingForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
1053 AppSettingForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
1055 bool errorStatus = false;
1056 int currentLength = 0;
1057 int stringLengthMax = 0;
1058 int stringLengthMin = 0;
1060 if (__pIOAppSetting != null)
1062 Node* pRootNode = null;
1063 Enumerator* pEnum = null;
1064 pRootNode = __pAppSettingManager->GetAppSettingRootNode(__appId);
1065 pEnum = pRootNode->CreateEnumerator();
1066 while (pEnum->MoveNext() == E_SUCCESS)
1068 Node* pCurrent = static_cast<Node*>(pEnum->GetCurrentObject());
1069 if (pCurrent->GetType().Equals(ID_APPSETTING_ITEM_TYPE_STRING, false))
1071 String* itemText = pCurrent->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1072 String* pMinLength = pCurrent->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MIN_LENGTH);
1073 String* pMaxLength = pCurrent->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MAX_LENGTH);
1075 currentLength = itemText->GetLength();
1076 Integer::Parse(*pMinLength, stringLengthMin);
1077 Integer::Parse(*pMaxLength, stringLengthMax);
1083 if ((currentLength > stringLengthMax) || (currentLength < stringLengthMin))
1085 if (currentLength > stringLengthMax)
1087 AppLogDebug("value length(%d) greater than maximum range(%d), show popup", currentLength, stringLengthMax);
1091 AppLogDebug("value length(%d) smaller than minimum range(%d), show popup", currentLength, stringLengthMin);
1094 MessageBox messageBox;
1095 int result = E_SUCCESS;
1097 messageBox.Construct(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_COM_POP_FAILED"), MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIME_2_SEC);
1098 messageBox.ShowAndWait(result);
1107 if (errorStatus == false)
1109 __pIOAppSetting->UpdateChangedValue();
1116 SceneManager* pSceneManager = SceneManager::GetInstance();
1117 AppAssert(pSceneManager);
1119 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
1123 AppSettingForm::GetGroupCount(void)
1125 if (__pGroupItemNodeList != null)
1127 return __pGroupItemNodeList->GetCount();
1130 return APPSETTING_DEFAULT_COUNT;
1134 AppSettingForm::GetItemCount(int groupIndex)
1136 return GetItemCountByTranslateTable(groupIndex);
1140 AppSettingForm::CreateGroupItem(int groupIndex, int itemWidth)
1142 AppLogDebug("ENTER");
1144 int itemHeight = H_GROUP_INDEX_DEFAULT;
1145 int yItemOffset = Y_GROUP_INDEX_DEFAULT;
1146 LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
1147 Rectangle itemMainRectangle;
1148 String* groupText = null;
1150 Label* pLabel = null;
1151 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
1153 __pGroupItemNodeList->GetAt(groupIndex, pNode);
1155 itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
1156 itemMainRectangle.y = yItemOffset;
1157 itemMainRectangle.width = itemWidth;
1158 itemMainRectangle.height = itemHeight;
1160 itemHeight = H_GROUP_INDEX_DEFAULT;
1161 itemMainRectangle.y = H_GROUP_INDEX_TITLE_TEXT;
1162 itemMainRectangle.height = H_GROUP_INDEX_DEFAULT - H_GROUP_INDEX_TITLE_TEXT;
1163 groupText = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
1164 if (groupText == null)
1166 AppLogDebug("grpText null");
1171 if (!pNode->GetType().Equals(L"group", false))
1173 if (__isNoTitleGroup == true)
1175 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
1176 __isNoTitleGroup = false;
1185 __isNoTitleGroup = true;
1188 if (pNode->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1190 ItemTypeOneLine(itemMainRectangle);
1191 itemHeight = itemMainRectangle.height;
1194 if ((pNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1196 String* value = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1199 AppLogDebug("groupText [%ls] value [%ls]", groupText->GetPointer(), value->GetPointer());
1201 pNode->RegisterObserverlistener(__pIOAppSetting);
1203 pItem->Construct(Dimension(itemMainRectangle.width, itemMainRectangle.height));
1204 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1206 expendList.Append(groupText->GetPointer());
1207 expendList.Append(L" : ");
1208 expendList.Append(value->GetPointer());
1212 pLabel = new (std::nothrow) Label();
1213 pLabel->Construct(itemMainRectangle, expendList);
1214 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1215 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1216 pLabel->SetName(pNode->GetId());
1218 pItem->AddControl(pLabel);
1219 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1220 pItem->SetEnabled(true);
1226 pItem->Construct(Dimension(itemWidth, itemHeight));
1227 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
1229 Label* pLabel = new (std::nothrow) Label();
1231 pLabel->Construct(itemMainRectangle, (*groupText).GetPointer());
1232 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1233 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
1235 pItem->AddControl(pLabel);
1237 pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, style);
1238 pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
1240 pItem->SetEnabled(false);
1248 AppSettingForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
1250 Rectangle itemMainRectangle;
1251 Label* pLabel = null;
1253 String* itemText = null;
1255 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
1257 unsigned int hashCode = GetTranslateTableIndexToHashCode(groupIndex, itemIndex);
1259 Node* pItemNode = GetItemHashCodeMap(hashCode);
1260 if (pItemNode == null)
1262 result r = __pGroupItemNodeList->GetAt(groupIndex, pItemNode);
1265 AppLogDebug("pItemNode is null");
1269 pItemNode = GetItemHashCodeMap(pItemNode->GetId().GetHashCode());
1270 if (pItemNode == null)
1272 AppLogDebug("pItemNode is null");
1277 TableViewItem* pItem = new (std::nothrow) TableViewItem();
1279 itemText = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
1280 itemType = pItemNode->GetType();
1281 ItemTypeOneLine(itemMainRectangle);
1283 if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_BOOL, false))
1285 bool toggleValue = false;
1286 String* valueString = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1288 pItemNode->RegisterObserverlistener(__pIOAppSetting);
1290 style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
1292 RelativeLayout relativeLayout;
1293 relativeLayout.Construct();
1295 pItem->Construct(relativeLayout, Dimension(itemWidth, itemMainRectangle.height), style);
1296 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1298 pLabel = new (std::nothrow) Label();
1299 pLabel->Construct(itemMainRectangle, (itemText)->GetPointer());
1300 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1301 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1303 pItem->AddControl(pLabel);
1304 relativeLayout.SetMargin(*pLabel, 0, 150, 0, 0);
1305 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
1306 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
1308 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1310 toggleValue = Boolean::Parse((*valueString).GetPointer(), true);
1312 if ((toggleValue != false) || (*valueString == DEFAULT_VALUE_STRING))
1314 __pTableView->SetItemChecked(groupIndex, itemIndex, true);
1318 else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_INTEGER, false))
1320 Slider* pSlider = null;
1325 pItemNode->RegisterObserverlistener(__pIOAppSetting);
1327 itemMainRectangle.width = (itemWidth - ITEM_WIDTH_GAP);
1328 itemMainRectangle.height = H_GROUP_ITEM_DEFAULT_SLIDER;
1330 RelativeLayout relativeLayout;
1331 relativeLayout.Construct();
1332 pItem->Construct(relativeLayout, Dimension(itemWidth, itemMainRectangle.height), style);
1333 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1335 String* minValueString = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MIN);
1336 String* maxValueString = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MAX);
1337 String* setValueString = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1339 Integer::Parse((*minValueString).GetPointer(), minValue);
1340 Integer::Parse((*maxValueString).GetPointer(), maxValue);
1341 Integer::Parse((*setValueString).GetPointer(), setValue);
1343 pSlider = new (std::nothrow) Slider();
1344 result r = pSlider->Construct(itemMainRectangle, BACKGROUND_STYLE_NONE, true, minValue, maxValue);
1347 delete minValueString;
1348 delete maxValueString;
1349 delete setValueString;
1353 pSlider->SetTitleText((*itemText).GetPointer());
1354 pSlider->SetValue(setValue);
1355 pSlider->AddAdjustmentEventListener(*this);
1356 pSlider->AddSliderEventListener(*this);
1357 pSlider->SetName(pItemNode->GetId());
1359 pItem->AddControl(pSlider);
1360 pItem->SetIndividualSelectionEnabled(pSlider, true);
1361 relativeLayout.SetMargin(*pSlider, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
1362 relativeLayout.SetRelation(*pSlider, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
1363 relativeLayout.SetRelation(*pSlider, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
1365 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1366 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1367 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED);
1368 delete minValueString;
1369 delete maxValueString;
1370 delete setValueString;
1372 else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_STRING, false))
1374 itemMainRectangle.x = 0;
1375 int stringLengthMin = 0;
1376 int stringLengthMax = 0;
1378 String* pMinLength = static_cast<String*>(pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MIN_LENGTH));
1379 if (pMinLength != null)
1381 Integer::Parse(*pMinLength, stringLengthMin);
1383 AppLogDebug("max String size [%d]", stringLengthMin);
1386 String* pMaxLength = static_cast<String*>(pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MAX_LENGTH));
1387 if (pMaxLength != null)
1389 Integer::Parse(*pMaxLength, stringLengthMax);
1391 AppLogDebug("max String size [%d]", stringLengthMax);
1394 RelativeLayout relativeLayout;
1395 relativeLayout.Construct();
1396 pItem->Construct(relativeLayout, Dimension(itemWidth, itemMainRectangle.height), style);
1397 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1399 pItemNode->RegisterObserverlistener(__pIOAppSetting);
1401 String id = pItemNode->GetId();
1402 String setActionIdDone(id);
1403 String setActionIdCancel(id);
1405 setActionIdDone.Append(ID_POST_FIX_BUTTON_DONE);
1406 setActionIdCancel.Append(ID_POST_FIX_BUTTON_CANCEL);
1408 EditField* pEditField = new (std::nothrow) EditField();
1409 String* secondLine = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1411 itemMainRectangle.x = X_GROUP_DEFAULT;
1412 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);
1413 pEditField->SetGuideText((*itemText).GetPointer());
1414 pEditField->SetTitleText((*itemText).GetPointer());
1415 pEditField->SetText((*secondLine).GetPointer());
1418 pEditField->SetTextSize(FONT_SIZE_SUB_TEXT);
1419 pEditField->SetTitleTextColor(EDIT_STATUS_NORMAL, COLOR_HELP_TEXT_TYPE_01);
1420 pEditField->SetColor(EDIT_STATUS_NORMAL, COLOR_BG_GROUP_ITEM_DEFAULT);
1421 pEditField->SetColor(EDIT_STATUS_PRESSED, COLOR_BG_GROUP_ITEM_DEFAULT);
1422 pEditField->SetColor(EDIT_STATUS_HIGHLIGHTED, COLOR_BG_GROUP_ITEM_DEFAULT);
1423 pEditField->SetColor(EDIT_STATUS_DISABLED, COLOR_BG_GROUP_ITEM_DEFAULT);
1424 pEditField->AddActionEventListener(*this);
1425 pEditField->AddTextEventListener(*this);
1426 pEditField->SetName(id);
1427 pEditField->AddKeypadEventListener(*this);
1429 pItem->AddControl(pEditField);
1430 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1431 pItem->SetIndividualSelectionEnabled(pEditField, true);
1433 relativeLayout.SetMargin(*pEditField, Y_GROUP_ITEM_DEFAULT, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
1434 relativeLayout.SetRelation(*pEditField, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
1435 relativeLayout.SetRelation(*pEditField, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
1437 else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_LABEL, false))
1439 pItem->Construct(Dimension(itemWidth, itemMainRectangle.height), style);
1440 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1442 pLabel = new (std::nothrow) Label();
1443 pLabel->Construct(itemMainRectangle, (itemText)->GetPointer());
1444 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1445 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1446 pLabel->SetName(pItemNode->GetId());
1447 pItem->AddControl(pLabel);
1448 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1450 else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1452 IEnumerator* pCurrentIEnumerator = pItemNode->GetCurrentIEnumerator();
1454 if (!((pCurrentIEnumerator != null)
1455 && (pCurrentIEnumerator->MoveNext() == E_SUCCESS)))
1457 AppLogDebug("Expandlist has no expandItems & remove");
1458 delete pCurrentIEnumerator;
1464 String* value = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1467 pItemNode->RegisterObserverlistener(__pIOAppSetting);
1469 pItem->Construct(Dimension(itemWidth, itemMainRectangle.height), style);
1470 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1472 expendList.Append(itemText->GetPointer());
1473 expendList.Append(L" : ");
1474 expendList.Append(value->GetPointer());
1478 pLabel = new (std::nothrow) Label();
1479 pLabel->Construct(itemMainRectangle, expendList);
1480 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1481 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1482 pLabel->SetName(pItemNode->GetId());
1484 pItem->AddControl(pLabel);
1485 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1487 else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_ITEM, false))
1489 style = TABLE_VIEW_ANNEX_STYLE_RADIO;
1491 RelativeLayout relativeLayout;
1492 relativeLayout.Construct();
1493 pItem->Construct(relativeLayout, Dimension(itemWidth, itemMainRectangle.height), style);
1494 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_LISTITEM);
1496 Node* parent = pItemNode->GetParent();
1498 String* pParentValue = (parent->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE));
1499 String* pCurrentValue = (pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE));
1501 if (pCurrentValue->Equals(*pParentValue, true))
1503 __pTableView->SetItemChecked(groupIndex, itemIndex, true);
1506 pLabel = new (std::nothrow) Label();
1507 pLabel->Construct(itemMainRectangle, (itemText)->GetPointer());
1508 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1509 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1511 pItem->AddControl(pLabel);
1512 delete pParentValue;
1513 delete pCurrentValue;
1514 relativeLayout.SetMargin(*pLabel, RELATIVE_LAYOUT_LEFT_MARGIN, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
1515 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
1516 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
1518 else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_SEPARATOR, false))
1520 Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_SEPARATOR);
1521 itemMainRectangle.height = H_GROUP_INDEX_NO_TITLE_DEFAULT;
1523 if (pBitmap == null)
1525 AppLogDebug("bitmap is null ");
1526 AppLogDebug("separator id [%ls]", pItemNode->GetId().GetPointer());
1529 RelativeLayout relativeLayout;
1530 relativeLayout.Construct();
1531 pItem->Construct(relativeLayout, Dimension(itemWidth, itemMainRectangle.height), TABLE_VIEW_ANNEX_STYLE_NORMAL);
1533 pLabel = new (std::nothrow) Label();
1534 pLabel->Construct(itemMainRectangle, L" ");
1535 pLabel->SetBackgroundBitmap(*pBitmap);
1536 pItem->AddControl(pLabel);
1539 pItem->SetEnabled(false);
1541 relativeLayout.SetMargin(*pLabel, RELATIVE_LAYOUT_RIGHT_MARGIN, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
1542 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
1543 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
1547 AppLogDebug("pItem is null");
1557 AppSettingForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
1566 AppSettingForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
1575 AppSettingForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1577 unsigned int hashCode = GetTranslateTableIndexToHashCode(groupIndex, itemIndex);
1578 AppLogDebug("%d %d", groupIndex, itemIndex);
1579 Node* pItemNode = GetItemHashCodeMap(hashCode);
1580 if (pItemNode == null)
1582 AppLogDebug("pItemNode is null");
1586 if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_ITEM, false))
1588 ElementNode* pParent = dynamic_cast<ElementNode*>(pItemNode->GetParent());
1589 if (pParent == null)
1591 AppLogDebug("pParent is null");
1595 if (!pParent->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1597 AppLogDebug("pParent is not ITEM_TYPE_EXPAND_LIST");
1601 String* pValue = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
1604 AppLogDebug("pValue is null");
1608 pParent->SetAttribute(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE, *pValue);
1611 unsigned int hashCode = pParent->GetId().GetHashCode();
1612 ItemTag* itemTag = GetTranslateTableHashCodeToItemTag(hashCode);
1614 if (itemTag == null)
1616 int itemCount = __pTableView->GetItemCountAt(groupIndex);
1618 for (int count = 0; count < itemCount; count++)
1620 bool itemSelectStatus = false;
1621 if (count == itemIndex)
1623 itemSelectStatus = true;
1625 __pTableView->SetItemChecked(groupIndex, count, itemSelectStatus);
1627 RefreshExpandListItem(groupIndex);
1633 int loopCount = pParent->GetChildCount() + itemTag->GetItemIndex() + APPSETTING_DEFAULT_COUNT;
1635 for (int pos = itemTag->GetItemIndex() + APPSETTING_DEFAULT_COUNT; pos < loopCount; pos++)
1637 if (pos != itemIndex)
1639 __pTableView->SetItemChecked(groupIndex, pos, false);
1643 __pTableView->SetItemChecked(groupIndex, pos, true);
1646 __pTableView->RefreshItem(itemTag->GetGroupIndex(), itemTag->GetItemIndex(), TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1648 if (__pIOAppSetting != null)
1650 __pIOAppSetting->UpdateChangedValue();
1655 else if (pItemNode->GetType().Equals(ID_APPSETTING_ITEM_TYPE_BOOL, false))
1657 bool itemSelectStatus = tableView.IsItemChecked(groupIndex, itemIndex);
1659 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
1661 itemSelectStatus = (!itemSelectStatus);
1663 tableView.SetItemChecked(groupIndex, itemIndex, itemSelectStatus);
1664 pItemNode->SetAttribute(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE, Boolean::ToString(itemSelectStatus));
1666 if (__pIOAppSetting != null)
1668 __pIOAppSetting->UpdateChangedValue();
1673 AppLogDebug("null");
1678 AppSettingForm::OnActionPerformed(const Control& source, int actionId)
1680 String sourceNametmp(source.GetName());
1681 String sourceName(L"");
1683 StringTokenizer stringTokenizer(sourceNametmp, L":");
1684 stringTokenizer.GetNextToken(sourceName);
1686 Node* pNode = GetItemHashCodeMap(sourceName.GetHashCode());
1689 AppLogDebug("pNode is null");
1695 AppSettingForm::GetDefaultGroupItemHeight(void)
1697 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
1701 AppSettingForm::GetDefaultItemHeight(void)
1703 return H_GROUP_ITEM_DEFAULT;
1707 AppSettingForm::RefreshExpandListItem(int groupIndex)
1709 int itemCount = __pTableView->GetItemCountAt(groupIndex);
1711 for (int count = -1; count < itemCount; count++)
1713 __pTableView->RefreshItem(groupIndex, count, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1718 AppSettingForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
1721 __pGroupItemNodeList->GetAt(groupIndex, pNode);
1723 if (pNode->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1725 Label* pLabel = static_cast<Label*>(pItem->GetControl(0));
1728 String* groupText = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
1729 String* value = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1731 expandList.Append(groupText->GetPointer());
1732 expandList.Append(L" : ");
1733 expandList.Append(value->GetPointer());
1735 AppLogDebug("itemChanged [%ls]", expandList.GetPointer());
1736 pLabel->SetText(expandList);
1737 pLabel->Invalidate(false);
1744 AppSettingForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1746 unsigned int hashCode = GetTranslateTableIndexToHashCode(groupIndex, itemIndex);
1747 Node* pItemNode = GetItemHashCodeMap(hashCode);
1748 if (pItemNode == null)
1750 AppLogDebug("GetItemHashCodeMap is null");
1754 Label* pLabel = static_cast<Label*>(pItem->GetControl(pItemNode->GetId(), false));
1757 pLabel->SetSize(GetClientAreaBounds().width - TWO_LINE_ITEM_WIDTH_GAP,pLabel->GetHeight());
1760 if (!pItemNode->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1762 if (pItemNode->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_ITEM, false))
1764 AppLogDebug("pItemNode->GetType not equal ID_APPSETTING_ITEM_TYPE_EXPAND_LIST [%ls]", pItemNode->GetType().GetPointer());
1765 pItem->Invalidate(false);
1767 else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_INTEGER, false))
1769 Slider* pSlider = static_cast<Slider*>(pItem->GetControl(0));
1770 pItem->SetIndividualSelectionEnabled(pSlider, true);
1775 String* pTitle = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
1776 String* pValue = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1777 if (pValue == null || pTitle == null)
1779 AppLogDebug("GetAttributeN is null");
1787 String expendList(*pTitle);
1788 expendList.Append(L" : ");
1789 expendList.Append(*pValue);
1791 pLabel->SetText(expendList);
1792 pLabel->Invalidate(false);
1800 AppSettingForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1805 AppSettingForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1810 AppSettingForm::OnAdjustmentValueChanged(const Tizen::Ui::Control& source, int adjustment)
1812 String sourceName = source.GetName();
1814 Node* pNode = GetItemHashCodeMap(sourceName.GetHashCode());
1817 AppLogDebug("pNode is null");
1821 pNode->SetAttribute(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE, Integer::ToString(adjustment));
1823 if (__pIOAppSetting != null)
1825 __pIOAppSetting->UpdateChangedValue();
1830 AppSettingForm::OnSliderBarMoved(Tizen::Ui::Controls::Slider& source, int value)
1835 AppSettingForm::OnTextValueChanged(const Tizen::Ui::Control& source)
1837 String sourceName = source.GetName();
1839 Node* pNode = GetItemHashCodeMap(sourceName.GetHashCode());
1842 AppLogDebug("pNode is null");
1846 EditField* pEditField = static_cast<EditField*>(&const_cast<Control&>(source));
1850 changedText = pEditField->GetText();
1853 pNode->SetAttribute(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE, changedText);
1855 String* pMin = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MIN_LENGTH);
1856 String* pMax = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MAX_LENGTH);
1860 int currentLength = pEditField->GetTextLength();
1862 Integer::Parse(*pMin, minLength);
1863 Integer::Parse(*pMax, maxLength);
1865 if ((minLength <= currentLength) && (maxLength >= currentLength))
1867 if (__pIOAppSetting != null)
1869 AppLogDebug(" current[%d] min [%d] max[%d]", currentLength, minLength, maxLength);
1870 __pIOAppSetting->UpdateChangedValue();
1879 AppSettingForm::OnKeypadOpened(Tizen::Ui::Control& source)
1881 unsigned int hashCode = source.GetName().GetHashCode();
1882 ItemTag* itemTag = GetTranslateTableHashCodeToItemTag(hashCode);
1885 __pTableView->ScrollToItem(itemTag->GetGroupIndex(), itemTag->GetItemIndex(), TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_BOTTOM);
1890 AppSettingForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
1895 AppSettingForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
1897 if (__pTableView == null)
1899 Label* pLabel = static_cast<Label*>(GetControl(L"InvalidFormat"));
1903 Rectangle clientRect = GetClientAreaBounds();
1904 Rectangle labelRect = pLabel->GetBounds();
1906 labelRect = clientRect;
1909 pLabel->SetBounds(labelRect);
1910 pLabel->Invalidate(false);
1915 __pTableView->RefreshAllItems();
1921 ItemTag::SetItemTag(int groupIndex, int itemIndex)
1923 __groupIndex = groupIndex;
1924 __itemIndex = itemIndex;
1928 ItemTag::GetItemTag(int& groupIndex, int& itemIndex)
1930 groupIndex = __groupIndex;
1931 itemIndex = __itemIndex;