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->SetBackButton();
91 pFooter->AddActionEventListener(*this);
92 SetFormBackEventListener(this);
96 AppSettingForm::SetHeaderTitle(void)
98 if (__pGroupItemNodeList == null)
100 AppLogDebug("__pGroupItemNodeList is null");
101 CreateHeader(L"AppSettingDefault");
106 result r = __pGroupItemNodeList->GetAt(0, pNode);
112 AppLogDebug("pNode is null");
116 AppLogDebug("GetAt fail [%s]", GetErrorMessage(r));
118 CreateHeader(L"AppSettingDefault");
122 Node* pParent = pNode->GetParent();
123 if ((pParent == null)
124 || (!pParent->GetType().Equals(L"setting", false)))
128 AppLogDebug("pParent is null");
132 AppLogDebug("pParent is not setting element [%ls]", pParent->GetType().GetPointer());
134 CreateHeader(L"AppSettingDefault");
138 String* pTitle = pParent->GetAttributeN(L"title");
141 AppLogDebug("pTitle is null");
142 CreateHeader(L"AppSettingDefault");
146 CreateHeader(*pTitle);
151 AppSettingForm::OnInitializing(void)
157 AppSettingForm::AppSettingManagerInit(Tizen::Base::String rootId, Tizen::Base::String filePath)
159 __pAppSettingManager = AppSettingManager::GetInstance();
160 if (__pAppSettingManager == null)
162 AppLogDebug("AppSettingManager::GetInstance fail");
166 ElementNode* pRoot = __pAppSettingManager->AddAppSettingRootNode(rootId);
167 result r = __pAppSettingManager->XmlAppSettingFileRead(filePath, pRoot);
170 __pAppSettingManager->RemoveAppSettingRootNode(rootId);
171 AppLogDebug("XmlAppSettingFileRead fail [%s]", GetErrorMessage(r));
179 AppSettingForm::SetGroupItemNodeList(Tizen::Base::String rootId)
181 InitGroupItemNodeList();
183 if (__pAppSettingManager == null)
185 AppLogDebug("__pAppSettingManager is null");
189 ElementNode* pRoot = __pAppSettingManager->GetAppSettingRootNode(rootId);
193 AppLogDebug("AppId is not found");
197 bool isFindSttingElement = false;
199 Enumerator* pEnum = pRoot->CreateEnumerator();
200 while (pEnum->MoveNext() == E_SUCCESS)
202 pNode = static_cast<Node*>(pEnum->GetCurrentObject());
203 if (pNode->GetType().Equals(L"setting", false))
205 isFindSttingElement = true;
211 if ((isFindSttingElement == false)
213 || (pNode->GetNodeType() == Node::NODE_TYPE_LEAF))
215 if (isFindSttingElement == false)
217 AppLogDebug("Setting Element is not found");
221 AppLogDebug("Child is not found");
226 ElementNode* pElementNode = dynamic_cast<ElementNode*>(pNode);
227 if (pElementNode == null)
229 AppLogDebug("dynamic_cast<ElementNode*>(pNode) is null");
232 unsigned int childCount = pElementNode->GetChildCount();
235 AppLogDebug("Child is zero");
239 result r = E_FAILURE;
240 for (unsigned int i = 0; i < childCount; i++)
242 if (pElementNode->GetChild(i)->GetType().Equals(L"navigationbar", false))
247 r = __pGroupItemNodeList->Add(pElementNode->GetChild(i));
250 AppLogDebug("Add fail");
251 RemoveAllGroupItemNodeList();
255 r = AddItemHashCodeMap(pElementNode->GetChild(i)->GetId().GetHashCode(), pElementNode->GetChild(i));
258 AppLogDebug("AddItemHashCodeMap fail");
259 RemoveAllGroupItemNodeList();
268 AppSettingForm::RemoveAllGroupItemNodeList(void)
270 if (__pGroupItemNodeList != null)
272 __pGroupItemNodeList->RemoveAll();
273 delete __pGroupItemNodeList;
274 __pGroupItemNodeList = null;
279 AppSettingForm::InitGroupItemNodeList(void)
281 RemoveAllGroupItemNodeList();
283 __pGroupItemNodeList = new (std::nothrow) LinkedListT<Node*>;
284 if (__pGroupItemNodeList == null)
286 AppLogDebug("__pGroupItemNodeList create fail");
294 AppSettingForm::InitItemHashCodeMap(void)
296 RemoveAllItemHashCodeMap();
298 __pItemHashcodeHashMap = new (std::nothrow) HashMapT<unsigned int, Node*>;
299 if (__pItemHashcodeHashMap == null)
301 AppLogDebug("__pItemHashcodeHashMap create fail");
305 result r = __pItemHashcodeHashMap->Construct();
308 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
309 RemoveAllItemHashCodeMap();
316 AppSettingForm::AddItemHashCodeMap(unsigned int hashCode, Node* pNode)
318 if (__pItemHashcodeHashMap == null)
320 AppLogDebug("__pItemHashcodeHashMap is null");
324 result r = __pItemHashcodeHashMap->Add(hashCode, pNode);
330 AppSettingForm::MakeTranslateTable(void)
332 if ((__pGroupItemNodeList == null)
333 || (__pItemHashcodeHashMap == null))
335 AppLogDebug("__pGroupItemNodeList or __pItemHashcodeHashMap is null");
339 unsigned int groupItemListCount = __pGroupItemNodeList->GetCount();
340 if (groupItemListCount == 0)
342 AppLogDebug("groupItemListCount is zero");
346 result r = E_FAILURE;
348 Enumerator* pEnum = null;
350 for (unsigned int i = 0; i < groupItemListCount; i++)
352 r = __pGroupItemNodeList->GetAt(i, pNode);
358 AppLogDebug("pNode is null");
363 AppLogDebug("GetAt fail [%s]", GetErrorMessage(r));
366 RemoveAllTranslateTableIndexToHashCode();
367 RemoveAllItemHashCodeMap();
372 ArrayListT<unsigned int>* pGroupItemHashCode = new (std::nothrow) ArrayListT<unsigned int>;
373 if (pGroupItemHashCode == null)
375 AppLogDebug("pNode is null");
377 RemoveAllTranslateTableIndexToHashCode();
378 RemoveAllItemHashCodeMap();
383 r = pGroupItemHashCode->Construct();
386 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
387 RemoveAllTranslateTableIndexToHashCode();
388 RemoveAllItemHashCodeMap();
390 pGroupItemHashCode->RemoveAll();
391 delete pGroupItemHashCode;
396 int enumLoopCount = 0;
397 pEnum = pNode->CreateEnumerator();
398 while (pEnum->MoveNext() == E_SUCCESS)
400 Node* pCurrent = static_cast<Node*>(pEnum->GetCurrentObject());
401 if (pCurrent == null)
403 AppLogDebug("pNode is null");
404 RemoveAllTranslateTableIndexToHashCode();
405 RemoveAllItemHashCodeMap();
408 pGroupItemHashCode->RemoveAll();
409 delete pGroupItemHashCode;
414 unsigned int idHashCode = pCurrent->GetId().GetHashCode();
416 r = AddItemHashCodeMap(idHashCode, pCurrent);
419 AppLogDebug("Add fail [%s]", GetErrorMessage(r));
420 RemoveAllTranslateTableIndexToHashCode();
421 RemoveAllItemHashCodeMap();
424 pGroupItemHashCode->RemoveAll();
425 delete pGroupItemHashCode;
430 r = pGroupItemHashCode->Add(idHashCode);
433 AppLogDebug("Add fail [%s]", GetErrorMessage(r));
434 RemoveAllTranslateTableIndexToHashCode();
435 RemoveAllItemHashCodeMap();
438 pGroupItemHashCode->RemoveAll();
439 delete pGroupItemHashCode;
443 SetTranslateTableHashCodeToItemTag(idHashCode, new (std::nothrow) ItemTag(i, enumLoopCount));
444 enumLoopCount = enumLoopCount + APPSETTING_DEFAULT_COUNT;
446 if (enumLoopCount == 0)
450 unsigned int idHashCode = pNode->GetId().GetHashCode();
452 r = pGroupItemHashCode->Add(idHashCode);
455 AppLogDebug("Add fail [%s]", GetErrorMessage(r));
456 RemoveAllTranslateTableIndexToHashCode();
457 RemoveAllItemHashCodeMap();
460 pGroupItemHashCode->RemoveAll();
461 delete pGroupItemHashCode;
465 SetTranslateTableHashCodeToItemTag(idHashCode, new (std::nothrow) ItemTag(i, enumLoopCount));
470 r = SetTranslateTableIndexToHashCode(pGroupItemHashCode);
473 AppLogDebug("SetTranslateTableIndexToHashCode fail [%s]", GetErrorMessage(r));
474 RemoveAllTranslateTableIndexToHashCode();
475 RemoveAllItemHashCodeMap();
477 pGroupItemHashCode->RemoveAll();
478 delete pGroupItemHashCode;
488 AppSettingForm::GetItemHashCodeMap(unsigned int hashCode)
490 if (__pItemHashcodeHashMap == null)
492 AppLogDebug("__pItemHashcodeHashMap is null");
496 bool isFindKey = false;
497 result r = __pItemHashcodeHashMap->ContainsKey(hashCode, isFindKey);
498 if ((isFindKey == false)
501 if (isFindKey == false)
503 AppLogDebug("Key is not found");
507 AppLogDebug("ContainsKey fail [%s]", GetErrorMessage(r));
513 Node* pValueNode = null;
514 r = __pItemHashcodeHashMap->GetValue(hashCode, pValueNode);
515 if ((pValueNode == null)
518 if (pValueNode == null)
520 AppLogDebug("pValueNode is null");
524 AppLogDebug("GetValue fail [%s]", GetErrorMessage(r));
534 AppSettingForm::RemoveAllItemHashCodeMap(void) // must be modify
536 if (__pItemHashcodeHashMap != null)
538 __pItemHashcodeHashMap->RemoveAll();
539 delete __pItemHashcodeHashMap;
540 __pItemHashcodeHashMap = null;
545 AppSettingForm::InitTranslateTableIndexToHashCode(void)
547 if (__pTranslateTableIndexToHashCode != null)
549 AppLogDebug("__pTranslateTableIndexToHashCode is not null");
553 __pTranslateTableIndexToHashCode = new (std::nothrow) ArrayListT<ArrayListT<unsigned int>*>;
554 if (__pTranslateTableIndexToHashCode == null)
556 AppLogDebug("__pTranslateTableIndexToHashCode create fail");
560 result r = __pTranslateTableIndexToHashCode->Construct();
563 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
564 RemoveAllTranslateTableIndexToHashCode();
571 AppSettingForm::InitTranslateTableHashCodeToItemTag(void)
573 if (__pTranslateTableHashCodeToItemTag != null)
575 AppLogDebug("__pTranslateTableIndexToHashCode is not null");
578 __pTranslateTableHashCodeToItemTag = new (std::nothrow) HashMapT<unsigned int, ItemTag*>;
579 if (__pTranslateTableHashCodeToItemTag == null)
581 AppLogDebug("__pTranslateTableHashCodeToItemTag create fail");
584 result r = __pTranslateTableHashCodeToItemTag->Construct();
587 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
588 RemoveAllTranslateTableHashCodeToItemTag();
594 AppSettingForm::SetTranslateTableHashCodeToItemTag(int hashCode, ItemTag* itemTag)
596 InitTranslateTableHashCodeToItemTag();
597 if (__pTranslateTableHashCodeToItemTag == null)
599 AppLogDebug("__pTranslateTableHashCodeToItemTag is null");
602 return __pTranslateTableHashCodeToItemTag->Add(hashCode, itemTag);
606 AppSettingForm::GetTranslateTableHashCodeToItemTag(unsigned int hashCode)
608 if (__pTranslateTableHashCodeToItemTag == null)
610 AppLogDebug("__pTranslateTableHashCodeToItemTag is null");
613 bool isFindKey = false;
614 result r = __pTranslateTableHashCodeToItemTag->ContainsKey(hashCode, isFindKey);
615 if ((isFindKey == false)
618 if (isFindKey == false)
620 AppLogDebug("Key is not found");
624 AppLogDebug("ContainsKey fail [%s]", GetErrorMessage(r));
628 ItemTag* pValueItemTag = null;
629 r = __pTranslateTableHashCodeToItemTag->GetValue(hashCode, pValueItemTag);
630 if ((pValueItemTag == null)
633 if (pValueItemTag == null)
635 AppLogDebug("pValueItemTag is null");
639 AppLogDebug("GetValue fail [%s]", GetErrorMessage(r));
643 return pValueItemTag;
647 AppSettingForm::RemoveAllTranslateTableHashCodeToItemTag(void)
649 if (__pTranslateTableHashCodeToItemTag != null)
651 __pTranslateTableHashCodeToItemTag->RemoveAll();
652 delete __pTranslateTableHashCodeToItemTag;
653 __pTranslateTableHashCodeToItemTag = null;
658 AppSettingForm::SetTranslateTableIndexToHashCode(Tizen::Base::Collection::ArrayListT<unsigned int>* groupItemHashCode)
660 InitTranslateTableIndexToHashCode();
662 if (__pTranslateTableIndexToHashCode == null)
664 AppLogDebug("__pTranslateTableIndexToHashCode is null");
668 result r = __pTranslateTableIndexToHashCode->Add(groupItemHashCode);
671 AppLogDebug("Add fail [%s]", GetErrorMessage(r));
678 AppSettingForm::GetTranslateTableIndexToHashCode(unsigned int groupIndex, unsigned int itemIndex)
680 unsigned int retHashCode = 0;
682 if (__pTranslateTableIndexToHashCode == null)
684 AppLogDebug("__pTranslateTableIndexToHashCode is null");
688 unsigned int groupCount = __pTranslateTableIndexToHashCode->GetCount();
689 if ((groupIndex >= groupCount)
690 || (groupCount == 0))
692 AppLogDebug("groupIndex is not found");
696 ArrayListT<unsigned int>* pItemList = null;
697 result r = __pTranslateTableIndexToHashCode->GetAt(groupIndex, pItemList);
698 if ((pItemList == null)
701 if (pItemList == null)
703 AppLogDebug("pItemList is null");
707 AppLogDebug("GetAt fail [%s]", GetErrorMessage(r));
713 unsigned int itemCount = pItemList->GetCount();
714 if ((itemIndex >= itemCount)
717 AppLogDebug("itemIndex is not found");
721 r = pItemList->GetAt(itemIndex, retHashCode);
724 AppLogDebug("GetAt fail [%s]", GetErrorMessage(r));
734 AppSettingForm::GetItemCountByTranslateTable(unsigned int groupIndex)
736 unsigned int itemCount = 0;
737 if (__pTranslateTableIndexToHashCode == null)
739 AppLogDebug("__pTranslateTableIndexToHashCode is null");
743 unsigned int groupCount = __pTranslateTableIndexToHashCode->GetCount();
744 if ((groupIndex >= groupCount)
745 || (groupCount == 0))
747 AppLogDebug("groupIndex is not found");
751 ArrayListT<unsigned int>* pItemList = null;
752 result r = __pTranslateTableIndexToHashCode->GetAt(groupIndex, pItemList);
753 if ((pItemList == null)
756 if (pItemList == null)
758 AppLogDebug("pItemList is null");
762 AppLogDebug("GetAt fail [%s]", GetErrorMessage(r));
768 itemCount = pItemList->GetCount();
771 itemCount = APPSETTING_DEFAULT_COUNT;
778 AppSettingForm::RemoveAllTranslateTableIndexToHashCode(void)
780 if (__pTranslateTableIndexToHashCode != null)
782 unsigned int groupCount = __pTranslateTableIndexToHashCode->GetCount();
785 for (unsigned int i = 0; i < groupCount; i++)
787 ArrayListT<unsigned int>* itemList = null;
788 __pTranslateTableIndexToHashCode->GetAt(i, itemList);
790 if (itemList != null)
792 itemList->RemoveAll();
798 __pTranslateTableIndexToHashCode->RemoveAll();
799 delete __pTranslateTableIndexToHashCode;
800 __pTranslateTableIndexToHashCode = null;
805 AppSettingForm::IOAppSettingInit(Tizen::Base::String appId)
807 __pIOAppSetting = new (std::nothrow) IOAppSetting();
808 if (__pIOAppSetting == null)
810 AppLogDebug("__pIOAppSetting Create failed");
814 result r = __pIOAppSetting->Constructor(appId);
817 RemoveIOAppSetting();
824 AppSettingForm::RemoveIOAppSetting(void)
826 if (__pIOAppSetting != null)
828 delete __pIOAppSetting;
829 __pIOAppSetting = null;
834 AppSettingForm::OnTerminating(void)
838 __pTableView->SetItemProvider(null);
842 int contorlCount = GetControlCount();
843 for (int i = 0; i < contorlCount; i++)
845 RemoveControl(GetControl(0));
847 // RemoveAllControls();
849 RemoveAllGroupItemNodeList();
850 RemoveAllItemHashCodeMap();
851 RemoveAllTranslateTableIndexToHashCode();
852 RemoveAllTranslateTableHashCodeToItemTag();
853 RemoveIOAppSetting();
855 __pAppSettingManager->RemoveAppSettingRootNode(__appId);
856 __pAppSettingManager = null;
858 SceneManager* pSceneManager = SceneManager::GetInstance();
859 AppAssert(pSceneManager);
861 pSceneManager->UnregisterScene(__appId);
863 SetFormBackEventListener(null);
868 AppSettingForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
870 Node* pRootNode = null;
871 Enumerator* pEnum = null;
872 String* pArgsValue[ID_APPSETTTING_ARGUMENT_COUNT] = {null, };
877 AppLogDebug("pArgs is null");
881 argsCount = pArgs->GetCount();
882 if (argsCount != ID_APPSETTTING_ARGUMENT_COUNT)
884 AppLogDebug("Wrong count of pArgs");
889 for (int i = 0; i < argsCount; i++)
891 pArgsValue[i] = static_cast<String*>(pArgs->GetAt(i));
892 if (pArgsValue[i] == null)
894 AppLogDebug("pArgsValue[%d] is null", i);
901 StringTokenizer stringTokenizer(*pArgsValue[ID_APPSETTTING_ARGUMENT_DEFAULT], L":");
902 result r = stringTokenizer.GetNextToken(appId);
903 TryCatch(r == E_SUCCESS, , "GetNextToken fail[%s]", GetErrorMessage(r));
905 r = stringTokenizer.GetNextToken(appId);
907 || (appId.IsEmpty() == true))
913 TryCatch(r == E_SUCCESS, , "GetNextToken fail[%s]", GetErrorMessage(r));
916 r = AppSettingManagerInit(appId, *pArgsValue[ID_APPSETTTING_ARGUMENT_APP_ID]);
917 TryCatch(r == E_SUCCESS, , "AppSettingManagerInit fail [%s]", GetErrorMessage(r));
919 InitItemHashCodeMap();
920 r = SetGroupItemNodeList(appId);
921 TryCatch(r == E_SUCCESS, , "SetGroupItemNodeList fail");
923 r = MakeTranslateTable();
924 TryCatch(r == E_SUCCESS, , "MakeTranslateTable fail");
925 if (__appId.IsEmpty() == true)
927 __appId.Append(appId);
930 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)
1057 bool errorStatus = false;
1058 int currentLength = 0;
1059 int stringLengthMax = 0;
1060 int stringLengthMin = 0;
1062 if (__pIOAppSetting != null)
1064 Node* pRootNode = null;
1065 Enumerator* pEnum = null;
1066 pRootNode = __pAppSettingManager->GetAppSettingRootNode(__appId);
1067 pEnum = pRootNode->CreateEnumerator();
1068 while (pEnum->MoveNext() == E_SUCCESS)
1070 Node* pCurrent = static_cast<Node*>(pEnum->GetCurrentObject());
1071 if (pCurrent->GetType().Equals(ID_APPSETTING_ITEM_TYPE_STRING, false))
1073 String* itemText = pCurrent->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1074 String* pMinLength = pCurrent->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MIN_LENGTH);
1075 String* pMaxLength = pCurrent->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MAX_LENGTH);
1077 currentLength = itemText->GetLength();
1078 Integer::Parse(*pMinLength, stringLengthMin);
1079 Integer::Parse(*pMaxLength, stringLengthMax);
1085 if ((currentLength > stringLengthMax) || (currentLength < stringLengthMin))
1087 if (currentLength > stringLengthMax)
1089 AppLogDebug("value length(%d) greater than maximum range(%d), show popup", currentLength, stringLengthMax);
1093 AppLogDebug("value length(%d) smaller than minimum range(%d), show popup", currentLength, stringLengthMin);
1096 MessageBox messageBox;
1097 int result = E_SUCCESS;
1099 messageBox.Construct(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_COM_POP_FAILED"), MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIME_2_SEC);
1100 messageBox.ShowAndWait(result);
1109 if (errorStatus == false)
1111 __pIOAppSetting->UpdateChangedValue();
1118 SceneManager* pSceneManager = SceneManager::GetInstance();
1119 AppAssert(pSceneManager);
1121 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
1125 AppSettingForm::GetGroupCount(void)
1127 if (__pGroupItemNodeList != null)
1129 return __pGroupItemNodeList->GetCount();
1132 return APPSETTING_DEFAULT_COUNT;
1136 AppSettingForm::GetItemCount(int groupIndex)
1138 return GetItemCountByTranslateTable(groupIndex);
1142 AppSettingForm::CreateGroupItem(int groupIndex, int itemWidth)
1144 AppLogDebug("ENTER");
1146 int itemHeight = H_GROUP_INDEX_DEFAULT;
1147 int yItemOffset = Y_GROUP_INDEX_DEFAULT;
1148 LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
1149 Rectangle itemMainRectangle;
1150 String* groupText = null;
1152 Label* pLabel = null;
1153 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
1155 __pGroupItemNodeList->GetAt(groupIndex, pNode);
1157 itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
1158 itemMainRectangle.y = yItemOffset;
1159 itemMainRectangle.width = itemWidth;
1160 itemMainRectangle.height = itemHeight;
1162 itemHeight = H_GROUP_INDEX_DEFAULT;
1163 itemMainRectangle.y = H_GROUP_INDEX_TITLE_TEXT;
1164 itemMainRectangle.height = H_GROUP_INDEX_DEFAULT - H_GROUP_INDEX_TITLE_TEXT;
1165 groupText = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
1166 if (groupText == null)
1168 AppLogDebug("grpText null");
1173 if (!pNode->GetType().Equals(L"group", false))
1175 if (__isNoTitleGroup == true)
1177 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
1178 __isNoTitleGroup = false;
1187 __isNoTitleGroup = true;
1190 if (pNode->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1192 ItemTypeOneLine(itemMainRectangle);
1193 itemHeight = itemMainRectangle.height;
1196 if ((pNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1198 String* value = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1201 AppLogDebug("groupText [%ls] value [%ls]", groupText->GetPointer(), value->GetPointer());
1203 pNode->RegisterObserverlistener(__pIOAppSetting);
1205 pItem->Construct(Dimension(itemMainRectangle.width, itemMainRectangle.height));
1206 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1208 expendList.Append(groupText->GetPointer());
1209 expendList.Append(L" : ");
1210 expendList.Append(value->GetPointer());
1214 pLabel = new (std::nothrow) Label();
1215 pLabel->Construct(itemMainRectangle, expendList);
1216 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1217 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1218 pLabel->SetName(pNode->GetId());
1220 pItem->AddControl(pLabel);
1221 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1222 pItem->SetEnabled(true);
1228 pItem->Construct(Dimension(itemWidth, itemHeight));
1229 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
1231 Label* pLabel = new (std::nothrow) Label();
1233 pLabel->Construct(itemMainRectangle, (*groupText).GetPointer());
1234 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1235 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
1237 pItem->AddControl(pLabel);
1239 pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, style);
1240 pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
1242 pItem->SetEnabled(false);
1250 AppSettingForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
1252 Rectangle itemMainRectangle;
1253 Label* pLabel = null;
1255 String* itemText = null;
1257 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
1259 unsigned int hashCode = GetTranslateTableIndexToHashCode(groupIndex, itemIndex);
1261 Node* pItemNode = GetItemHashCodeMap(hashCode);
1262 if (pItemNode == null)
1264 result r = __pGroupItemNodeList->GetAt(groupIndex, pItemNode);
1267 AppLogDebug("pItemNode is null");
1271 pItemNode = GetItemHashCodeMap(pItemNode->GetId().GetHashCode());
1272 if (pItemNode == null)
1274 AppLogDebug("pItemNode is null");
1279 TableViewItem* pItem = new (std::nothrow) TableViewItem();
1281 itemText = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
1282 itemType = pItemNode->GetType();
1283 ItemTypeOneLine(itemMainRectangle);
1285 if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_BOOL, false))
1287 bool toggleValue = false;
1288 String* valueString = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1290 pItemNode->RegisterObserverlistener(__pIOAppSetting);
1292 style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
1294 RelativeLayout relativeLayout;
1295 relativeLayout.Construct();
1297 pItem->Construct(relativeLayout, Dimension(itemWidth, itemMainRectangle.height), style);
1298 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1300 pLabel = new (std::nothrow) Label();
1301 pLabel->Construct(itemMainRectangle, (itemText)->GetPointer());
1302 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1303 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1305 pItem->AddControl(pLabel);
1306 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
1307 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
1308 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
1310 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1312 toggleValue = Boolean::Parse((*valueString).GetPointer(), true);
1314 if ((toggleValue != false) || (*valueString == DEFAULT_VALUE_STRING))
1316 __pTableView->SetItemChecked(groupIndex, itemIndex, true);
1320 else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_INTEGER, false))
1322 Slider* pSlider = null;
1327 pItemNode->RegisterObserverlistener(__pIOAppSetting);
1329 itemMainRectangle.width = (itemWidth - ITEM_WIDTH_GAP);
1330 itemMainRectangle.height = H_GROUP_ITEM_DEFAULT_SLIDER;
1332 RelativeLayout relativeLayout;
1333 relativeLayout.Construct();
1334 pItem->Construct(relativeLayout, Dimension(itemWidth, itemMainRectangle.height), style);
1335 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1337 String* minValueString = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MIN);
1338 String* maxValueString = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MAX);
1339 String* setValueString = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1341 Integer::Parse((*minValueString).GetPointer(), minValue);
1342 Integer::Parse((*maxValueString).GetPointer(), maxValue);
1343 Integer::Parse((*setValueString).GetPointer(), setValue);
1345 pSlider = new (std::nothrow) Slider();
1346 result r = pSlider->Construct(itemMainRectangle, BACKGROUND_STYLE_NONE, true, minValue, maxValue);
1349 delete minValueString;
1350 delete maxValueString;
1351 delete setValueString;
1355 pSlider->SetTitleText((*itemText).GetPointer());
1356 pSlider->SetValue(setValue);
1357 pSlider->AddAdjustmentEventListener(*this);
1358 pSlider->AddSliderEventListener(*this);
1359 pSlider->SetName(pItemNode->GetId());
1361 pItem->AddControl(pSlider);
1362 relativeLayout.SetMargin(*pSlider, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
1363 relativeLayout.SetRelation(*pSlider, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
1364 relativeLayout.SetRelation(*pSlider, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
1366 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1367 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1368 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED);
1369 delete minValueString;
1370 delete maxValueString;
1371 delete setValueString;
1373 else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_STRING, false))
1375 itemMainRectangle.x = 0;
1376 int stringLengthMin = 0;
1377 int stringLengthMax = 0;
1379 String* pMinLength = static_cast<String*>(pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MIN_LENGTH));
1380 if (pMinLength != null)
1382 Integer::Parse(*pMinLength, stringLengthMin);
1384 AppLogDebug("max String size [%d]", stringLengthMin);
1387 String* pMaxLength = static_cast<String*>(pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MAX_LENGTH));
1388 if (pMaxLength != null)
1390 Integer::Parse(*pMaxLength, stringLengthMax);
1392 AppLogDebug("max String size [%d]", stringLengthMax);
1395 RelativeLayout relativeLayout;
1396 relativeLayout.Construct();
1397 pItem->Construct(relativeLayout, Dimension(itemWidth, itemMainRectangle.height), style);
1398 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1400 pItemNode->RegisterObserverlistener(__pIOAppSetting);
1402 String id = pItemNode->GetId();
1403 String setActionIdDone(id);
1404 String setActionIdCancel(id);
1406 setActionIdDone.Append(ID_POST_FIX_BUTTON_DONE);
1407 setActionIdCancel.Append(ID_POST_FIX_BUTTON_CANCEL);
1409 EditField* pEditField = new (std::nothrow) EditField();
1410 String* secondLine = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1412 itemMainRectangle.x = X_GROUP_DEFAULT;
1413 pEditField->Construct(itemMainRectangle, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY, EDIT_FIELD_TITLE_STYLE_TOP, true, stringLengthMax, GROUP_STYLE_NONE);
1414 pEditField->SetGuideText((*itemText).GetPointer());
1415 pEditField->SetTitleText((*itemText).GetPointer());
1416 pEditField->SetText((*secondLine).GetPointer());
1419 pEditField->SetTextSize(FONT_SIZE_SUB_TEXT);
1420 pEditField->SetTitleTextColor(EDIT_STATUS_NORMAL, COLOR_HELP_TEXT_TYPE_01);
1421 pEditField->SetColor(EDIT_STATUS_NORMAL, COLOR_BG_GROUP_ITEM_DEFAULT);
1422 pEditField->SetColor(EDIT_STATUS_PRESSED, COLOR_BG_GROUP_ITEM_DEFAULT);
1423 pEditField->SetColor(EDIT_STATUS_HIGHLIGHTED, COLOR_BG_GROUP_ITEM_DEFAULT);
1424 pEditField->SetColor(EDIT_STATUS_DISABLED, COLOR_BG_GROUP_ITEM_DEFAULT);
1425 pEditField->AddActionEventListener(*this);
1426 pEditField->AddTextEventListener(*this);
1427 pEditField->SetName(id);
1428 pEditField->AddKeypadEventListener(*this);
1430 pItem->AddControl(pEditField);
1431 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1432 pItem->SetIndividualSelectionEnabled(pEditField, true);
1434 relativeLayout.SetMargin(*pEditField, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
1435 relativeLayout.SetRelation(*pEditField, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
1436 relativeLayout.SetRelation(*pEditField, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
1438 else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_LABEL, false))
1440 pItem->Construct(Dimension(itemWidth, itemMainRectangle.height), style);
1441 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1443 pLabel = new (std::nothrow) Label();
1444 pLabel->Construct(itemMainRectangle, (itemText)->GetPointer());
1445 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1446 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1448 pItem->AddControl(pLabel);
1449 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1451 else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1453 IEnumerator* pCurrentIEnumerator = pItemNode->GetCurrentIEnumerator();
1455 if (!((pCurrentIEnumerator != null)
1456 && (pCurrentIEnumerator->MoveNext() == E_SUCCESS)))
1458 AppLogDebug("Expandlist has no expandItems & remove");
1459 delete pCurrentIEnumerator;
1465 String* value = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1468 pItemNode->RegisterObserverlistener(__pIOAppSetting);
1470 pItem->Construct(Dimension(itemWidth, itemMainRectangle.height), style);
1471 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1473 expendList.Append(itemText->GetPointer());
1474 expendList.Append(L" : ");
1475 expendList.Append(value->GetPointer());
1479 pLabel = new (std::nothrow) Label();
1480 pLabel->Construct(itemMainRectangle, expendList);
1481 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1482 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1483 pLabel->SetName(pItemNode->GetId());
1485 pItem->AddControl(pLabel);
1486 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1488 else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_ITEM, false))
1490 style = TABLE_VIEW_ANNEX_STYLE_RADIO;
1492 RelativeLayout relativeLayout;
1493 relativeLayout.Construct();
1494 pItem->Construct(relativeLayout, Dimension(itemWidth, itemMainRectangle.height), style);
1495 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_LISTITEM);
1497 Node* parent = pItemNode->GetParent();
1499 String* pParentValue = (parent->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE));
1500 String* pCurrentValue = (pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE));
1502 if (pCurrentValue->Equals(*pParentValue, true))
1504 __pTableView->SetItemChecked(groupIndex, itemIndex, true);
1507 pLabel = new (std::nothrow) Label();
1508 pLabel->Construct(itemMainRectangle, (itemText)->GetPointer());
1509 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1510 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1512 pItem->AddControl(pLabel);
1513 delete pParentValue;
1514 delete pCurrentValue;
1515 relativeLayout.SetMargin(*pLabel, RELATIVE_LAYOUT_LEFT_MARGIN, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
1516 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
1517 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
1519 else if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_SEPARATOR, false))
1521 Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_SEPARATOR);
1522 itemMainRectangle.height = H_GROUP_INDEX_NO_TITLE_DEFAULT;
1524 if (pBitmap == null)
1526 AppLogDebug("bitmap is null ");
1527 AppLogDebug("separator id [%ls]", pItemNode->GetId().GetPointer());
1530 RelativeLayout relativeLayout;
1531 relativeLayout.Construct();
1532 pItem->Construct(relativeLayout, Dimension(itemWidth, itemMainRectangle.height), TABLE_VIEW_ANNEX_STYLE_NORMAL);
1534 pLabel = new (std::nothrow) Label();
1535 pLabel->Construct(itemMainRectangle, L" ");
1536 pLabel->SetBackgroundBitmap(*pBitmap);
1537 pItem->AddControl(pLabel);
1540 pItem->SetEnabled(false);
1542 relativeLayout.SetMargin(*pLabel, RELATIVE_LAYOUT_RIGHT_MARGIN, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
1543 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
1544 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
1548 AppLogDebug("pItem is null");
1558 AppSettingForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
1567 AppSettingForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
1576 AppSettingForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1578 unsigned int hashCode = GetTranslateTableIndexToHashCode(groupIndex, itemIndex);
1579 AppLogDebug("%d %d", groupIndex, itemIndex);
1580 Node* pItemNode = GetItemHashCodeMap(hashCode);
1581 if (pItemNode == null)
1583 AppLogDebug("pItemNode is null");
1587 if ((pItemNode->GetType()).Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_ITEM, false))
1589 ElementNode* pParent = dynamic_cast<ElementNode*>(pItemNode->GetParent());
1590 if (pParent == null)
1592 AppLogDebug("pParent is null");
1596 if (!pParent->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1598 AppLogDebug("pParent is not ITEM_TYPE_EXPAND_LIST");
1602 String* pValue = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
1605 AppLogDebug("pValue is null");
1609 pParent->SetAttribute(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE, *pValue);
1612 unsigned int hashCode = pParent->GetId().GetHashCode();
1613 ItemTag* itemTag = GetTranslateTableHashCodeToItemTag(hashCode);
1615 if (itemTag == null)
1617 int itemCount = __pTableView->GetItemCountAt(groupIndex);
1619 for (int count = 0; count < itemCount; count++)
1621 bool itemSelectStatus = false;
1622 if (count == itemIndex)
1624 itemSelectStatus = true;
1626 __pTableView->SetItemChecked(groupIndex, count, itemSelectStatus);
1628 RefreshExpandListItem(groupIndex);
1634 int loopCount = pParent->GetChildCount() + itemTag->GetItemIndex() + APPSETTING_DEFAULT_COUNT;
1636 for (int pos = itemTag->GetItemIndex() + APPSETTING_DEFAULT_COUNT; pos < loopCount; pos++)
1638 if (pos != itemIndex)
1640 __pTableView->SetItemChecked(groupIndex, pos, false);
1644 __pTableView->SetItemChecked(groupIndex, pos, true);
1647 __pTableView->RefreshItem(itemTag->GetGroupIndex(), itemTag->GetItemIndex(), TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1649 if (__pIOAppSetting != null)
1651 __pIOAppSetting->UpdateChangedValue();
1656 else if (pItemNode->GetType().Equals(ID_APPSETTING_ITEM_TYPE_BOOL, false))
1658 bool itemSelectStatus = tableView.IsItemChecked(groupIndex, itemIndex);
1660 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
1662 itemSelectStatus = (!itemSelectStatus);
1664 tableView.SetItemChecked(groupIndex, itemIndex, itemSelectStatus);
1665 pItemNode->SetAttribute(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE, Boolean::ToString(itemSelectStatus));
1667 if (__pIOAppSetting != null)
1669 __pIOAppSetting->UpdateChangedValue();
1674 AppLogDebug("null");
1680 AppSettingForm::OnActionPerformed(const Control& source, int actionId)
1682 String sourceNametmp(source.GetName());
1683 String sourceName(L"");
1685 StringTokenizer stringTokenizer(sourceNametmp, L":");
1686 stringTokenizer.GetNextToken(sourceName);
1688 Node* pNode = GetItemHashCodeMap(sourceName.GetHashCode());
1691 AppLogDebug("pNode is null");
1697 AppSettingForm::GetDefaultGroupItemHeight(void)
1699 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
1703 AppSettingForm::GetDefaultItemHeight(void)
1705 return H_GROUP_ITEM_DEFAULT;
1709 AppSettingForm::RefreshExpandListItem(int groupIndex)
1711 int itemCount = __pTableView->GetItemCountAt(groupIndex);
1713 for (int count = -1; count < itemCount; count++)
1715 __pTableView->RefreshItem(groupIndex, count, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1720 AppSettingForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
1723 __pGroupItemNodeList->GetAt(groupIndex, pNode);
1725 if (pNode->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1727 Label* pLabel = static_cast<Label*>(pItem->GetControl(0));
1730 String* groupText = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
1731 String* value = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1733 expandList.Append(groupText->GetPointer());
1734 expandList.Append(L" : ");
1735 expandList.Append(value->GetPointer());
1737 AppLogDebug("itemChanged [%ls]", expandList.GetPointer());
1738 pLabel->SetText(expandList);
1739 pLabel->Invalidate(false);
1746 AppSettingForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1748 unsigned int hashCode = GetTranslateTableIndexToHashCode(groupIndex, itemIndex);
1749 Node* pItemNode = GetItemHashCodeMap(hashCode);
1750 if (pItemNode == null)
1752 AppLogDebug("GetItemHashCodeMap is null");
1756 if (!pItemNode->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_LIST, false))
1758 if (pItemNode->GetType().Equals(ID_APPSETTING_ITEM_TYPE_EXPAND_ITEM, false))
1760 AppLogDebug("pItemNode->GetType not equal ID_APPSETTING_ITEM_TYPE_EXPAND_LIST [%ls]", pItemNode->GetType().GetPointer());
1761 pItem->Invalidate(false);
1766 Label* pLabel = static_cast<Label*>(pItem->GetControl(pItemNode->GetId(), false));
1769 AppLogDebug("pItem->GetControl is null");
1773 String* pTitle = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_TITLE);
1774 String* pValue = pItemNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE);
1775 if (pValue == null || pTitle == null)
1777 AppLogDebug("GetAttributeN is null");
1783 String expendList(*pTitle);
1784 expendList.Append(L" : ");
1785 expendList.Append(*pValue);
1787 pLabel->SetText(expendList);
1788 pLabel->Invalidate(false);
1795 AppSettingForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1800 AppSettingForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1805 AppSettingForm::OnAdjustmentValueChanged(const Tizen::Ui::Control& source, int adjustment)
1807 String sourceName = source.GetName();
1809 Node* pNode = GetItemHashCodeMap(sourceName.GetHashCode());
1812 AppLogDebug("pNode is null");
1816 pNode->SetAttribute(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE, Integer::ToString(adjustment));
1819 if (__pIOAppSetting != null)
1821 __pIOAppSetting->UpdateChangedValue();
1826 AppSettingForm::OnSliderBarMoved(Tizen::Ui::Controls::Slider& source, int value)
1831 AppSettingForm::OnTextValueChanged(const Tizen::Ui::Control& source)
1833 String sourceName = source.GetName();
1835 Node* pNode = GetItemHashCodeMap(sourceName.GetHashCode());
1838 AppLogDebug("pNode is null");
1842 EditField* pEditField = static_cast<EditField*>(&const_cast<Control&>(source));
1846 changedText = pEditField->GetText();
1849 pNode->SetAttribute(ID_APPSETTING_ATTRIBUTE_TYPE_VALUE, changedText);
1851 String* pMin = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MIN_LENGTH);
1852 String* pMax = pNode->GetAttributeN(ID_APPSETTING_ATTRIBUTE_TYPE_MAX_LENGTH);
1856 int currentLength = pEditField->GetTextLength();
1858 Integer::Parse(*pMin, minLength);
1859 Integer::Parse(*pMax, maxLength);
1861 if ((minLength <= currentLength) && (maxLength >= currentLength))
1863 if (__pIOAppSetting != null)
1865 AppLogDebug(" current[%d] min [%d] max[%d]", currentLength, minLength, maxLength);
1866 __pIOAppSetting->UpdateChangedValue();
1875 AppSettingForm::OnKeypadOpened(Tizen::Ui::Control& source)
1877 unsigned int hashCode = source.GetName().GetHashCode();
1878 ItemTag* itemTag = GetTranslateTableHashCodeToItemTag(hashCode);
1881 __pTableView->ScrollToItem(itemTag->GetGroupIndex(), itemTag->GetItemIndex(), TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_BOTTOM);
1886 AppSettingForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
1891 AppSettingForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
1893 if (__pTableView == null)
1895 Label* pLabel = static_cast<Label*>(GetControl(L"InvalidFormat"));
1899 Rectangle clientRect = GetClientAreaBounds();
1900 Rectangle labelRect = pLabel->GetBounds();
1902 labelRect = clientRect;
1905 pLabel->SetBounds(labelRect);
1906 pLabel->Invalidate(false);
1913 ItemTag::SetItemTag(int groupIndex, int itemIndex)
1915 __groupIndex = groupIndex;
1916 __itemIndex = itemIndex;
1920 ItemTag::GetItemTag(int& groupIndex, int& itemIndex)
1922 groupIndex = __groupIndex;
1923 itemIndex = __itemIndex;