2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (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.
17 //!Internet SettingForm class
18 /*@file: IntSettingForm.cpp
19 *@brief: The SettingForm
23 #include <FGraphics.h>
26 #include "IntCommonLib.h"
27 #include "IntConfirmationPopup.h"
28 #include "IntDefaultCustomItem.h"
29 #include "IntDropDownCustomItem.h"
30 #include "IntHistoryPresentationModel.h"
31 #include "IntMultipleWindowPresentationModel.h"
32 #include "IntNotificationPanel.h"
33 #include "IntRadioCustomItem.h"
34 #include "IntSceneRegister.h"
35 #include "IntSettingForm.h"
36 #include "IntSettingPresentationModel.h"
37 #include "IntSettingToggleCustomItem.h"
40 using namespace Tizen::App;
41 using namespace Tizen::Base;
42 using namespace Tizen::Base::Collection;
43 using namespace Tizen::Graphics;
44 using namespace Tizen::Ui;
45 using namespace Tizen::Ui::Controls;
46 using namespace Tizen::Ui::Scenes;
48 //static const int IDA_CONFIRMATION_NO = 1000;
49 //static const int IDA_CONFIRMATION_YES = 1001;
51 static const wchar_t* IDB_EDIT_BACKGROUND = L"EditBackground.png";
53 SettingForm::SettingForm(void)
54 : __fontValue(0),__pResetPopup(null),__pWindowInfo(null) , __pConfirmationPopup(null)
58 InitializeSettingValues();
61 SettingForm::~SettingForm(void)
65 delete[] pGroupItemCount;
66 pGroupItemCount = null;
71 SettingForm::InitializeSettingValues(void)
73 AppLog("SettingForm::InitializeSettingValues homepage %ls",SettingPresentationModel::GetInstance()->GetHomepage().GetPointer());
75 pGroupItemCount = new(std::nothrow) int[5];
76 pGroupItemCount[0] = 5; //Homepage
77 pGroupItemCount[1] = 6; //Page content settings
78 pGroupItemCount[2] = 5; //Private and Security
79 pGroupItemCount[3] = 4; //Search
80 pGroupItemCount[4] = 1; //Website settings and Reset
82 for (int iter = (int) SETTING_INVALID + 1; iter < (int) SETTING_MAX; iter++)
84 settingInfo[iter].isSelected = false;
87 AppLogDebug("image display %d", (int) SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
88 settingInfo[SETTING_HOMEPAGE_TITLE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_HOMEPAGE");
89 settingInfo[SETTING_HOMEPAGE_TITLE].subText = SettingPresentationModel::GetInstance()->GetHomepage();
90 settingInfo[SETTING_HOMEPAGE_TITLE].itemType = ITEM_TYPE_DROPDOWN;
92 settingInfo[SETTING_CURRENT_PAGE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_CURRENT_PAGE");
93 settingInfo[SETTING_CURRENT_PAGE].subText = L"";
94 settingInfo[SETTING_CURRENT_PAGE].itemType = ITEM_TYPE_RADIO;
96 settingInfo[SETTING_BLANK_PAGE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_BLANK_PAGE");
97 settingInfo[SETTING_BLANK_PAGE].subText = L"";
98 settingInfo[SETTING_BLANK_PAGE].itemType = ITEM_TYPE_RADIO;
99 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_BLANK_PAGE")) == 0)
101 settingInfo[SETTING_BLANK_PAGE].isSelected = true;
104 settingInfo[SETTING_MOST_VISITED_SITE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_MOST_VISITED_SITES");
105 settingInfo[SETTING_MOST_VISITED_SITE].subText = L"";
106 settingInfo[SETTING_MOST_VISITED_SITE].itemType = ITEM_TYPE_RADIO;
107 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
109 settingInfo[SETTING_MOST_VISITED_SITE].isSelected = true;
111 WindowInfo* pWindowInfo = null;
112 String curUrl = SettingPresentationModel::GetInstance()->GetFavoriteUrl();
113 AppLog("SettingForm::OnSceneActivatedN check1");
115 settingInfo[SETTING_FAVORITE_URL].titleText = L"http://www.tizen.org";
116 if (SettingPresentationModel::GetInstance()->GetFavoriteUrl().CompareTo(L"") == 0)
118 SettingPresentationModel::GetInstance()->SetFavoriteValue(L"http://www.tizen.org");
120 settingInfo[SETTING_FAVORITE_URL].subText = L"";
121 settingInfo[SETTING_FAVORITE_URL].itemType = ITEM_TYPE_RADIO;
123 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_USER_HOMEPAGE")) == 0)
125 settingInfo[SETTING_FAVORITE_URL].isSelected = true;
128 settingInfo[SETTING_DEFAULT_VIEW_TITLE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_DEFAULT_VIEW");
129 settingInfo[SETTING_DEFAULT_VIEW_TITLE].subText = SettingPresentationModel::GetInstance()->GetDefaultView();
130 settingInfo[SETTING_DEFAULT_VIEW_TITLE].itemType = ITEM_TYPE_DROPDOWN;
132 settingInfo[SETTING_FIT_TO_WIDTH].titleText = CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH");
133 settingInfo[SETTING_FIT_TO_WIDTH].subText = L"";
134 settingInfo[SETTING_FIT_TO_WIDTH].itemType = ITEM_TYPE_RADIO;
135 settingInfo[SETTING_FIT_TO_WIDTH].isSelected = !(String::Compare(settingInfo[SETTING_FIT_TO_WIDTH].titleText, settingInfo[SETTING_DEFAULT_VIEW_TITLE].subText));
137 settingInfo[SETTING_READABLE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_READABLE");
138 settingInfo[SETTING_READABLE].subText = L"";
139 settingInfo[SETTING_READABLE].itemType = ITEM_TYPE_RADIO;
140 settingInfo[SETTING_READABLE].isSelected = !(String::Compare(settingInfo[SETTING_READABLE].titleText, settingInfo[SETTING_DEFAULT_VIEW_TITLE].subText));
142 settingInfo[SETTING_RUN_JAVASCRIPT].titleText = CommonUtil::GetString(L"IDS_BR_BODY_RUN_JAVASCRIPT");
143 settingInfo[SETTING_RUN_JAVASCRIPT].subText = L"";
144 settingInfo[SETTING_RUN_JAVASCRIPT].itemType = ITEM_TYPE_TOGGLE;
145 settingInfo[SETTING_RUN_JAVASCRIPT].isSelected = SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled();
147 settingInfo[SETTING_DISPLAY_IMAGES].titleText = CommonUtil::GetString(L"IDS_BR_BODY_DISPLAY_IMAGES");
148 settingInfo[SETTING_DISPLAY_IMAGES].subText = L"";
149 settingInfo[SETTING_DISPLAY_IMAGES].itemType = ITEM_TYPE_TOGGLE;
150 settingInfo[SETTING_DISPLAY_IMAGES].isSelected = SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled();
152 settingInfo[SETTING_BLOCK_POPUP].titleText = CommonUtil::GetString(L"IDS_BR_BODY_BLOCK_POP_UPS_ABB");
153 settingInfo[SETTING_BLOCK_POPUP].subText = L"";
154 settingInfo[SETTING_BLOCK_POPUP].itemType = ITEM_TYPE_TOGGLE;
155 settingInfo[SETTING_BLOCK_POPUP].isSelected = !SettingPresentationModel::GetInstance()->IsBlockPopUp();
157 settingInfo[SETTING_CLEAR_CACHE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_CLEAR_CACHE");
158 settingInfo[SETTING_CLEAR_CACHE].subText = L"";
159 settingInfo[SETTING_CLEAR_CACHE].itemType = ITEM_TYPE_NORMAL;
161 settingInfo[SETTING_CLEAR_HISTORY].titleText = CommonUtil::GetString(L"IDS_BR_BODY_CLEAR_HISTORY");
162 settingInfo[SETTING_CLEAR_HISTORY].subText = L"";
163 settingInfo[SETTING_CLEAR_HISTORY].itemType = ITEM_TYPE_NORMAL;
165 settingInfo[SETTING_SHOW_SECURITY_WARNINGS].titleText = CommonUtil::GetString(L"IDS_BR_BODY_SHOW_SECURITY_WARNINGS");
166 settingInfo[SETTING_SHOW_SECURITY_WARNINGS].subText = L"";
167 settingInfo[SETTING_SHOW_SECURITY_WARNINGS].itemType = ITEM_TYPE_TOGGLE;
168 settingInfo[SETTING_SHOW_SECURITY_WARNINGS].isSelected = SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled();
170 settingInfo[SETTING_ACCEPT_COOKIES].titleText = CommonUtil::GetString(L"IDS_BR_BODY_ACCEPT_COOKIES");
171 settingInfo[SETTING_ACCEPT_COOKIES].subText = L"";
172 settingInfo[SETTING_ACCEPT_COOKIES].itemType = ITEM_TYPE_TOGGLE;
173 settingInfo[SETTING_ACCEPT_COOKIES].isSelected = SettingPresentationModel::GetInstance()->IsCookiesEnabled();
175 settingInfo[SETTING_CLEAR_COOKIE_DATA].titleText = CommonUtil::GetString(L"IDS_BR_BODY_CLEAR_ALL_COOKIE_DATA");
176 settingInfo[SETTING_CLEAR_COOKIE_DATA].subText = CommonUtil::GetString(L"IDS_BR_HEADER_COOKIES");
177 settingInfo[SETTING_CLEAR_COOKIE_DATA].itemType = ITEM_TYPE_NORMAL;
179 settingInfo[SETTING_SEARCH_ENGINE_TITLE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_ENGINE");
180 settingInfo[SETTING_SEARCH_ENGINE_TITLE].subText = SettingPresentationModel::GetInstance()->GetSearchEngine();
181 settingInfo[SETTING_SEARCH_ENGINE_TITLE].itemType = ITEM_TYPE_DROPDOWN;
183 settingInfo[SETTING_SEARCH_ENGINE_YAHOO].titleText = CommonUtil::GetString(L"IDS_BR_BODY_YAHOO");
184 settingInfo[SETTING_SEARCH_ENGINE_YAHOO].subText = L"";
185 settingInfo[SETTING_SEARCH_ENGINE_YAHOO].itemType = ITEM_TYPE_RADIO;
186 settingInfo[SETTING_SEARCH_ENGINE_YAHOO].isSelected = !(String::Compare(settingInfo[SETTING_SEARCH_ENGINE_YAHOO].titleText, settingInfo[SETTING_SEARCH_ENGINE_TITLE].subText));
188 settingInfo[SETTING_SEARCH_ENGINE_NAVER].titleText = CommonUtil::GetString(L"IDS_BR_BODY_NAVER");
189 settingInfo[SETTING_SEARCH_ENGINE_NAVER].subText = L"";
190 settingInfo[SETTING_SEARCH_ENGINE_NAVER].itemType = ITEM_TYPE_RADIO;
191 settingInfo[SETTING_SEARCH_ENGINE_NAVER].isSelected = !(String::Compare(settingInfo[SETTING_SEARCH_ENGINE_NAVER].titleText, settingInfo[SETTING_SEARCH_ENGINE_TITLE].subText));
193 settingInfo[SETTING_SEARCH_ENGINE_GOOGLE].titleText = CommonUtil::GetString(L"IDS_COM_BODY_GOOGLE");
194 settingInfo[SETTING_SEARCH_ENGINE_GOOGLE].subText = L"";
195 settingInfo[SETTING_SEARCH_ENGINE_GOOGLE].itemType = ITEM_TYPE_RADIO;
196 settingInfo[SETTING_SEARCH_ENGINE_GOOGLE].isSelected = !(String::Compare(settingInfo[SETTING_SEARCH_ENGINE_GOOGLE].titleText, settingInfo[SETTING_SEARCH_ENGINE_TITLE].subText));
198 settingInfo[SETTING_RESET_TO_DEFAULT].titleText = CommonUtil::GetString(L"IDS_BR_BODY_RESET_TO_DEFAULT");
199 settingInfo[SETTING_RESET_TO_DEFAULT].subText = L"";
200 settingInfo[SETTING_RESET_TO_DEFAULT].itemType = ITEM_TYPE_NORMAL;
204 SettingForm::Initialize(void)
206 result r = E_FAILURE;
208 r = Construct(L"IDL_SETTING_FORM");
217 SettingForm::OnInitializing(void)
219 result r = E_FAILURE;
220 Footer* pFooter = NULL;
221 SceneManager* pSceneManager = NULL;
223 __pList = static_cast< GroupedListView* >(GetControl(L"IDC_SETTING_LIST"));
224 if ( __pList != NULL )
227 r = __pList->SetItemProvider(*this);
228 TryCatch(!IsFailed(r),,"setItemProvider failed with error %s",GetErrorMessage(r));
229 __pList->AddGroupedListViewItemEventListener(*this);
232 pFooter = GetFooter();
235 AppLogDebug("setting back button");
236 pFooter->SetBackButtonEnabled(true);
237 SetFormBackEventListener(this);
239 pSceneManager = SceneManager::GetInstance();
240 if (pSceneManager != null)
242 r = pSceneManager->AddSceneEventListener(IDSCN_SETTINGS, *this);
243 TryCatch(!IsFailed(r),,"AddSceneEventListener failed with error %s",GetErrorMessage(r));
245 AddOrientationEventListener(*this);
252 SettingForm::OnGroupedListViewContextItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListContextItemStatus status)
258 SettingForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListItemStatus status)
260 int effectiveIndex = 0;
261 SettingPresentationModel* pSettingMgr = SettingPresentationModel::GetInstance();
263 if (pSettingMgr == null)
266 for (int i = 0; i < groupIndex; i++)
267 effectiveIndex = effectiveIndex + pGroupItemCount[i];
268 effectiveIndex = effectiveIndex + itemIndex;
270 if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_DROPDOWN)
272 AppLogDebug("refreshing data child count is %d", settingInfo[effectiveIndex].childCount);
273 if (settingInfo[effectiveIndex].isOpen == false)
275 settingInfo[effectiveIndex].isOpen = true;
276 settingInfo[effectiveIndex].childCount = 0;
277 for (int iter = effectiveIndex + 1; iter < SETTING_MAX; iter++)
279 if (settingInfo[iter].itemType == ITEM_TYPE_RADIO)
280 settingInfo[effectiveIndex].childCount++;
284 listView.UpdateList();
288 settingInfo[effectiveIndex].isOpen = false;
289 listView.UpdateList();
292 else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_RADIO)
295 for (parentIndex = effectiveIndex; parentIndex > SETTING_INVALID; parentIndex--)
297 if (settingInfo[parentIndex].itemType == ITEM_TYPE_DROPDOWN)
300 settingInfo[parentIndex].subText = settingInfo[effectiveIndex].titleText;
302 for (int iter = 0; iter < settingInfo[parentIndex].childCount; iter++)
304 if (parentIndex + iter + 1 != effectiveIndex)
306 AppLogDebug("long effectiveIndex %d set to false", itemIndex - (effectiveIndex - parentIndex) + iter + 1);
307 settingInfo[parentIndex + iter + 1].isSelected = false;
311 AppLogDebug("effectiveIndex %d set to true", effectiveIndex);
312 settingInfo[effectiveIndex].isSelected = true;
314 if (effectiveIndex == SETTING_CURRENT_PAGE)
316 settingInfo[SETTING_CURRENT_PAGE].isSelected = false;
317 settingInfo[SETTING_FAVORITE_URL].isSelected = true;
319 //listView.RefreshList(groupIndex, itemIndex - (effectiveIndex - parentIndex) + iter + 1, LIST_REFRESH_TYPE_ITEM_MODIFY);
321 // listView.UpdateList();
322 //listView.ScrollToItem(groupIndex, itemIndex, LIST_SCROLL_ITEM_ALIGNMENT_TOP);
325 else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_TOGGLE)
327 if (settingInfo[effectiveIndex].isSelected == true)
329 settingInfo[effectiveIndex].isSelected = false;
333 settingInfo[effectiveIndex].isSelected = true;
335 // listView.RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
338 __pList->SetItemChecked(groupIndex, itemIndex, settingInfo[effectiveIndex].isSelected);
342 switch (effectiveIndex)
344 case SETTING_CURRENT_PAGE:
345 //SettingPresentationModel::GetInstance()->SetHomepage(settingInfo[SETTING_FAVORITE_URL].titleText);
346 AppLog("setting current page currentURL is =%ls",__currentURL.GetPointer());
347 if (__currentURL.CompareTo(L"") != 0)
349 AppLog("setting current page currentURL is =%ls",__currentURL.GetPointer());
350 SettingPresentationModel::GetInstance()->SetHomepage(CommonUtil::GetString(L"IDS_BR_BODY_USER_HOMEPAGE"));
351 SettingPresentationModel::GetInstance()->SetFavoriteValue(__currentURL);
352 settingInfo[SETTING_FAVORITE_URL].titleText = __currentURL;
353 // listView.RefreshList(groupIndex, effectiveIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
354 listView.UpdateList();
357 case SETTING_BLANK_PAGE:
358 //SettingPresentationModel::GetInstance()->SetHomepage(settingInfo[SETTING_BLANK_PAGE].titleText);
359 SettingPresentationModel::GetInstance()->SetHomepage(CommonUtil::GetString(L"IDS_BR_BODY_BLANK_PAGE"));
360 AppLog("GetHomepage() %ls",SettingPresentationModel::GetInstance()->GetHomepage().GetPointer());
361 listView.UpdateList();
364 case SETTING_MOST_VISITED_SITE:
365 SettingPresentationModel::GetInstance()->SetHomepage(settingInfo[SETTING_MOST_VISITED_SITE].titleText);
366 listView.UpdateList();
369 case SETTING_FAVORITE_URL:
370 //SettingPresentationModel::GetInstance()->SetHomepage(settingInfo[SETTING_FAVORITE_URL].titleText);
371 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_EDIT_HOMEPAGE_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
374 case SETTING_FIT_TO_WIDTH:
375 SettingPresentationModel::GetInstance()->SetDefaultView(settingInfo[SETTING_FIT_TO_WIDTH].titleText);
376 listView.UpdateList();
379 case SETTING_READABLE:
380 SettingPresentationModel::GetInstance()->SetDefaultView(settingInfo[SETTING_READABLE].titleText);
381 listView.UpdateList();
384 case SETTING_RUN_JAVASCRIPT:
385 SettingPresentationModel::GetInstance()->SetRunJavascriptEnabled(settingInfo[SETTING_RUN_JAVASCRIPT].isSelected);
388 case SETTING_DISPLAY_IMAGES:
389 SettingPresentationModel::GetInstance()->SetDisplayImagesEnabled(settingInfo[SETTING_DISPLAY_IMAGES].isSelected);
392 case SETTING_BLOCK_POPUP:
393 SettingPresentationModel::GetInstance()->SetBlockPopUp(!settingInfo[SETTING_BLOCK_POPUP].isSelected);
396 case SETTING_CLEAR_CACHE:
400 case SETTING_CLEAR_HISTORY:
404 case SETTING_SHOW_SECURITY_WARNINGS:
405 SettingPresentationModel::GetInstance()->SetSecurityWarningsEnabled(settingInfo[SETTING_SHOW_SECURITY_WARNINGS].isSelected);
408 case SETTING_ACCEPT_COOKIES:
409 SettingPresentationModel::GetInstance()->SetCookiesEnabled(settingInfo[SETTING_ACCEPT_COOKIES].isSelected);
412 case SETTING_CLEAR_COOKIE_DATA:
416 case SETTING_SEARCH_ENGINE_YAHOO:
417 SettingPresentationModel::GetInstance()->SetSearchEngine(settingInfo[SETTING_SEARCH_ENGINE_YAHOO].titleText);
418 listView.UpdateList();
421 case SETTING_SEARCH_ENGINE_NAVER:
422 SettingPresentationModel::GetInstance()->SetSearchEngine(settingInfo[SETTING_SEARCH_ENGINE_NAVER].titleText);
423 listView.UpdateList();
426 case SETTING_SEARCH_ENGINE_GOOGLE:
427 SettingPresentationModel::GetInstance()->SetSearchEngine(settingInfo[SETTING_SEARCH_ENGINE_GOOGLE].titleText);
428 listView.UpdateList();
431 case SETTING_RESET_TO_DEFAULT:
442 SettingForm::OnGroupedListViewItemSwept(GroupedListView& listView, int groupIndex, int itemIndex, SweepDirection direction)
448 SettingForm::CreateGroupItem(int groupIndex, int itemWidth)
450 result r = E_FAILURE;
452 GroupItem* pItem = null;
453 const Color ITEM_TEXT_COLOR = CUSTOM_COLOR_SETTINGS_GROUPTITLE;
455 pItem = new(std::nothrow) GroupItem();
460 r = pItem->Construct(Dimension(itemWidth, 46));
470 text = CommonUtil::GetString(L"IDS_BR_BODY_HOMEPAGE"); // IDS_HOMEPAGE
471 settingInfo[SETTING_HOMEPAGE_TITLE].subText = SettingPresentationModel::GetInstance()->GetHomepage();
475 text = CommonUtil::GetString(L"IDS_BR_MBODY_PAGE_CONTENT_SETTINGS"); // IDS_BR_MBODY_PAGE_CONTENT_SETTINGS
479 text = CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"); // IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB
483 text = CommonUtil::GetString(L"IDS_BR_BODY_SEARCH"); // IDS_BR_BODY_SEARCH
494 pItem->SetElement(text, null);
496 AppLogDebug("background color set result %s", GetErrorMessage(r));
498 pItem->SetTextColor(ITEM_TEXT_COLOR);
503 SettingForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
505 AppLog("SettingForm::CreateItem --> groupIndex : %d, itemIndex: %d itemWidth: %d ", groupIndex, itemIndex, itemWidth);
507 result r = E_SUCCESS;
508 int effectiveIndex = 0;
509 const Color ITEM_BACKGROUND_COLOR = CUSTOM_COLOR_SETTINGS_LISTITEM_BACKGROUND;
510 const Color ITEM_RADIO_ITEM_BACKGROUND_COLOR = CUSTOM_COLOR_SETTINGS_LISTITEM_RADIO_BACKGROUND;
512 for (int i = 0; i < groupIndex; i++)
513 effectiveIndex = effectiveIndex + pGroupItemCount[i];
514 effectiveIndex = effectiveIndex + itemIndex;
515 AppLogDebug("SettingForm::CreateItem --> groupIndex : %d, itemIndex: %d itemWidth: %d effectiveIndex %d", groupIndex, itemIndex, itemWidth, effectiveIndex);
517 if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_TOGGLE)
519 SettingToggleCustomItem* pItem = new(std::nothrow) SettingToggleCustomItem();
520 r = pItem->Construct(itemWidth, 112);
527 Bitmap* pNormalBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG9,itemWidth,112);
528 Bitmap* pPressedBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG_PRESS9,itemWidth,112);
530 if (pNormalBackgroundBitmap != NULL)
532 pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_NORMAL,pNormalBackgroundBitmap);
533 delete pNormalBackgroundBitmap;
536 if (pPressedBackgroundBitmap != NULL)
538 pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_PRESSED,pPressedBackgroundBitmap);
539 delete pPressedBackgroundBitmap;
542 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL,ITEM_BACKGROUND_COLOR);
543 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,ITEM_BACKGROUND_COLOR);
546 __pList->SetItemChecked(groupIndex, itemIndex, settingInfo[effectiveIndex].isSelected);
549 pItem->SetText(settingInfo[effectiveIndex].titleText);
551 //if (pBitmap != null)
552 // pItem->AddElement(Rectangle(0, 0, 10, 112), IDA_LIST_LEFT_SIDE_MARGIN, *pBitmap, null);
557 // __pList->SetItemChecked(groupIndex, itemIndex, settingInfo[effectiveIndex].isSelected);
558 // AppLog("asdasda %s %d,%d-> %d",GetErrorMessage(r),groupIndex, itemIndex, settingInfo[effectiveIndex].isSelected);
563 else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_DROPDOWN)
565 DropDownCustomItem* pItem = new(std::nothrow) DropDownCustomItem();
566 r = pItem->Construct(itemWidth);
573 /* Bitmap* pNormalBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG9,itemWidth,128);
574 Bitmap* pPressedBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG_PRESS9,itemWidth,112);
576 if (pNormalBackgroundBitmap != NULL)
578 pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_NORMAL,pNormalBackgroundBitmap);
579 delete pNormalBackgroundBitmap;
582 if (pPressedBackgroundBitmap != NULL)
584 pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_PRESSED,pPressedBackgroundBitmap);
585 delete pPressedBackgroundBitmap;
588 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL,ITEM_BACKGROUND_COLOR);
589 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,ITEM_BACKGROUND_COLOR);
591 pItem->SetMainText(settingInfo[effectiveIndex].titleText);
592 pItem->SetSubText(settingInfo[effectiveIndex].subText);
593 if (settingInfo[effectiveIndex].isOpen)
595 pItem->SetCurState(DROP_DOWN_ITEM_STATE_OPENED);
599 pItem->SetCurState(DROP_DOWN__ITEM_STATE_CLOSED);
602 // if (pBitmap != null)
603 // pItem->AddElement(Rectangle(0, 0, 10, 128), IDA_LIST_LEFT_SIDE_MARGIN_DROPDOWN, *pBitmap, null);
613 else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_RADIO)
617 RadioCustomItem* pItem = new(std::nothrow) RadioCustomItem();
619 for (parentIndex = effectiveIndex; parentIndex > SETTING_INVALID; parentIndex--)
621 if (settingInfo[parentIndex].itemType == ITEM_TYPE_DROPDOWN)
624 if (settingInfo[parentIndex].isOpen == false || (__isCurrentPageDisable == true && groupIndex == 0 && itemIndex == 1))
626 r = pItem->Construct(itemWidth, 0);
627 AppLogDebug("construct with height 0 %s", GetErrorMessage(r));
632 pItem->Construct(itemWidth, 112);
635 Bitmap* pNormalBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG9,itemWidth,112);
636 Bitmap* pPressedBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG_PRESS9,itemWidth,112);
638 if (pNormalBackgroundBitmap != NULL)
640 pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_NORMAL,pNormalBackgroundBitmap);
641 delete pNormalBackgroundBitmap;
644 if (pPressedBackgroundBitmap != NULL)
646 pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_PRESSED,pPressedBackgroundBitmap);
647 delete pPressedBackgroundBitmap;
650 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL,ITEM_RADIO_ITEM_BACKGROUND_COLOR);
651 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,ITEM_RADIO_ITEM_BACKGROUND_COLOR);
654 pItem->SetText(settingInfo[effectiveIndex].titleText);
655 AppLogDebug("effectiveIndex %d SettingInfo[effectiveIndex].isSelected %d", effectiveIndex, settingInfo[effectiveIndex].isSelected);
657 //if (pBitmap != null)
658 // pItem->AddElement(Rectangle(0, 0, 10, 112), IDA_LIST_LEFT_SIDE_MARGIN, *pBitmap, null);
660 pItem->SetSelected(settingInfo[effectiveIndex].isSelected);
665 else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_NORMAL)
667 DefaultCustomItem* pItem = new(std::nothrow) DefaultCustomItem();
669 r = pItem->Construct(itemWidth, 112);
677 Bitmap* pNormalBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG9,itemWidth,112);
678 Bitmap* pPressedBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG_PRESS9,itemWidth,112);
680 if (pNormalBackgroundBitmap != NULL)
682 pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_NORMAL,pNormalBackgroundBitmap);
683 delete pNormalBackgroundBitmap;
686 if (pPressedBackgroundBitmap != NULL)
688 pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_PRESSED,pPressedBackgroundBitmap);
689 delete pPressedBackgroundBitmap;
692 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL,ITEM_BACKGROUND_COLOR);
693 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,ITEM_BACKGROUND_COLOR);
695 pItem->SetText(settingInfo[effectiveIndex].titleText);
697 //if (pBitmap != null)
698 // pItem->AddElement(Rectangle(0, 0, 10, 112), IDA_LIST_LEFT_SIDE_MARGIN, *pBitmap, null);
715 SettingForm::DeleteGroupItem(int groupIndex, GroupItem* pItem, int itemWidth)
723 SettingForm::DeleteItem(int groupIndex, int itemIndex, ListItemBase* pItem, int itemWidth)
731 SettingForm::GetGroupCount(void)
737 SettingForm::GetItemCount(int groupIndex)
739 AppLog(" SettingForm::GetItemCount --> groupIndex : %d,", groupIndex);
740 return pGroupItemCount[groupIndex];
744 SettingForm::OnFormBackRequested(Form& source)
746 String* pSelectedScene = NULL;
747 Object* value = NULL;
748 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &value);
749 pSelectedScene = (String*) value;
752 SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(*pSelectedScene, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
753 // delete pSelectedScene;
754 // pSelectedScene = null;
759 SettingForm::OnActionPerformed(const Control& source, int actionId)
764 if(__pConfirmationPopup)
766 __pConfirmationPopup->SetShowState(false);
767 __pConfirmationPopup->Show();
768 delete __pConfirmationPopup;
769 __pConfirmationPopup = null;
774 if(__pConfirmationPopup)
776 String message = L"";
777 __pConfirmationPopup->SetShowState(false);
778 __pConfirmationPopup->Show();
779 if (__pConfirmationPopup->GetMessage() == CommonUtil::GetString(L"IDS_BR_POP_EMPTY_COOKIE_POPUP_BNO"))
781 message = CommonUtil::GetString(L"IDS_BR_POP_DELETED");
782 SettingPresentationModel::GetInstance()->ClearCookie();
784 else if (__pConfirmationPopup->GetMessage() == CommonUtil::GetString(L"IDS_BR_POP_DELETE_LOCALLY_CACHED_CONTENT_AND_DATABASES_Q"))
786 message = CommonUtil::GetString(L"IDS_BR_POP_DELETED");
787 SettingPresentationModel::GetInstance()->ClearCache();
789 else if (__pConfirmationPopup->GetMessage() == CommonUtil::GetString(L"IDS_BR_BODY_DELETE_BROWSER_HISTORY_Q"))
791 message = CommonUtil::GetString(L"IDS_BR_POP_DELETED");
792 HistoryPresentationModel::GetInstance()->ClearHistory();
794 else if (__pConfirmationPopup->GetMessage() == CommonUtil::GetString(L"IDS_BR_POP_RESET_ALL_SETTINGS_TO_DEFAULT_Q"))
796 message = CommonUtil::GetString(L"IDS_BR_SK_DONE");
797 SettingPresentationModel::GetInstance()->ResetRegistry();
798 InitializeSettingValues();
801 __pList->UpdateList();
804 delete __pConfirmationPopup;
805 __pConfirmationPopup = null;
807 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
808 pNotification->SetText(message);
809 pNotification->SetPositionDiff(0);
810 pNotification->ShowNotification();
820 SettingForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
822 Rectangle rect = GetClientAreaBounds();
827 __pList->SetBounds(rect);
828 __pList->UpdateList();
831 SettingForm::SettingItemInfo::SettingItemInfo(void)
840 SettingForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
842 WindowInfo* pWindowInfo = null;
843 String curUrl = SettingPresentationModel::GetInstance()->GetFavoriteUrl();
845 pWindowInfo = MultipleWindowPresentationModel::GetInstance()->GetActiveWindowInfo();
847 if (previousSceneId == IDSCN_EDIT_HOMEPAGE_VIEW)
851 String* pValue = NULL;
852 pValue = dynamic_cast<String*>(pArgs->GetAt(0));
855 if (pValue->CompareTo(L"Done") == 0)
857 SettingPresentationModel::GetInstance()->SetHomepage(CommonUtil::GetString(L"IDS_BR_BODY_USER_HOMEPAGE"));
859 else if (pValue->CompareTo(L"Cancel") == 0)
861 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
862 if (homePage.CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
864 settingInfo[SETTING_MOST_VISITED_SITE].isSelected = true;
865 settingInfo[SETTING_BLANK_PAGE].isSelected = false;
866 settingInfo[SETTING_CURRENT_PAGE].isSelected = false;
867 settingInfo[SETTING_FAVORITE_URL].isSelected = false;
870 else if (homePage.CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_BLANK_PAGE")) == 0)
872 settingInfo[SETTING_MOST_VISITED_SITE].isSelected = false;
873 settingInfo[SETTING_BLANK_PAGE].isSelected = true;
874 settingInfo[SETTING_CURRENT_PAGE].isSelected = false;
875 settingInfo[SETTING_FAVORITE_URL].isSelected = false;
882 if (pWindowInfo != null)
884 __currentURL.Clear();
885 __currentURL.Append(pWindowInfo->pageUrl);
886 AppLog("current url is %ls",__currentURL.GetPointer());
888 if (SettingPresentationModel::GetInstance()->GetFavoriteUrl().CompareTo(L"") == 0)
890 if (pWindowInfo->pageUrl.CompareTo(L"") == 0)
892 //settingInfo[SETTING_FAVORITE_URL].titleText = CommonUtil::GetString(L"IDS_SET_HOMEPAGE");
893 settingInfo[SETTING_FAVORITE_URL].titleText = L"http://www.tizen.org";
897 settingInfo[SETTING_FAVORITE_URL].titleText = pWindowInfo->pageUrl;
902 settingInfo[SETTING_FAVORITE_URL].titleText = SettingPresentationModel::GetInstance()->GetFavoriteUrl();
908 __pList->UpdateList();
909 if (pWindowInfo && pWindowInfo->pageUrl.CompareTo(L"") == 0)
911 __isCurrentPageDisable = true;
912 AppLog("set item enabled is false");
913 __pList->SetItemEnabled(0, 1, false);
917 __isCurrentPageDisable = false;
918 AppLog("set item enabled is true");
919 __pList->SetItemEnabled(0, 1, true);
921 for(int grpindex = 0; grpindex < groupCount; grpindex++)
923 for(int index = 0; index < *(pGroupItemCount+groupCount); index++)
925 int effectiveIndex = 0;
926 for (int i = 0; i < grpindex; i++)
927 effectiveIndex = effectiveIndex + pGroupItemCount[i];
928 effectiveIndex = effectiveIndex + index;
930 if(effectiveIndex >= SETTING_MAX)
934 if(settingInfo[effectiveIndex].itemType == ITEM_TYPE_TOGGLE || settingInfo[effectiveIndex].itemType == ITEM_TYPE_RADIO )
936 __pList->SetItemChecked(grpindex, index, settingInfo[effectiveIndex].isSelected);
945 SettingForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
951 SettingForm::ClearHistory(void)
953 String message = CommonUtil::GetString(L"IDS_BR_BODY_DELETE_BROWSER_HISTORY_Q");
954 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
955 __pConfirmationPopup->Initialize();
956 __pConfirmationPopup->RemoveActionListener(*this);
957 __pConfirmationPopup->AddActionListener(*this);
958 __pConfirmationPopup->setMessage(message);
959 __pConfirmationPopup->Show();
963 SettingForm::ClearCache(void)
965 String message = CommonUtil::GetString(L"IDS_BR_POP_DELETE_LOCALLY_CACHED_CONTENT_AND_DATABASES_Q");
966 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
967 __pConfirmationPopup->Initialize();
968 __pConfirmationPopup->RemoveActionListener(*this);
969 __pConfirmationPopup->AddActionListener(*this);
970 __pConfirmationPopup->setMessage(message);
971 __pConfirmationPopup->Show();
975 SettingForm::ClearCookie(void)
977 String message = CommonUtil::GetString(L"IDS_BR_POP_EMPTY_COOKIE_POPUP_BNO");
978 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
979 __pConfirmationPopup->Initialize();
980 __pConfirmationPopup->RemoveActionListener(*this);
981 __pConfirmationPopup->AddActionListener(*this);
982 __pConfirmationPopup->setMessage(message);
983 __pConfirmationPopup->Show();
987 SettingForm::ResetToDefault()
989 String message = CommonUtil::GetString(L"IDS_BR_POP_RESET_ALL_SETTINGS_TO_DEFAULT_Q");
990 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
991 __pConfirmationPopup->Initialize();
992 __pConfirmationPopup->RemoveActionListener(*this);
993 __pConfirmationPopup->AddActionListener(*this);
994 __pConfirmationPopup->setMessage(message);
995 __pConfirmationPopup->Show();