2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
\r
4 // Licensed under the Flora License, Version 1.0 (the License);
\r
5 // you may not use this file except in compliance with the License.
\r
6 // You may obtain a copy of the License at
\r
8 // http://floralicense.org/license/
\r
10 // Unless required by applicable law or agreed to in writing, software
\r
11 // distributed under the License is distributed on an AS IS BASIS,
\r
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 // See the License for the specific language governing permissions and
\r
14 // limitations under the License.
\r
17 //!Internet SettingForm class
\r
18 /*@file: IntSettingForm.cpp
\r
19 *@brief: The SettingForm
\r
23 #include <FGraphics.h>
\r
26 #include "IntCommonLib.h"
\r
27 #include "IntConfirmationPopup.h"
\r
28 #include "IntDefaultCustomItem.h"
\r
29 #include "IntDropDownCustomItem.h"
\r
30 #include "IntHistoryPresentationModel.h"
\r
31 #include "IntMultipleWindowPresentationModel.h"
\r
32 #include "IntNotificationPanel.h"
\r
33 #include "IntRadioCustomItem.h"
\r
34 #include "IntSceneRegister.h"
\r
35 #include "IntSettingForm.h"
\r
36 #include "IntSettingPresentationModel.h"
\r
37 #include "IntSettingToggleCustomItem.h"
\r
40 using namespace Tizen::App;
\r
41 using namespace Tizen::Base;
\r
42 using namespace Tizen::Base::Collection;
\r
43 using namespace Tizen::Graphics;
\r
44 using namespace Tizen::Ui;
\r
45 using namespace Tizen::Ui::Controls;
\r
46 using namespace Tizen::Ui::Scenes;
\r
49 SettingForm::SettingForm(void)
\r
50 : __fontValue(0),__pResetPopup(null),__pWindowInfo(null) , __pConfirmationPopup(null)
\r
54 InitializeSettingValues();
\r
57 SettingForm::~SettingForm(void)
\r
59 if (pGroupItemCount)
\r
61 delete[] pGroupItemCount;
\r
62 pGroupItemCount = null;
\r
67 SettingForm::InitializeSettingValues(void)
\r
69 AppLog("SettingForm::InitializeSettingValues homepage %ls",SettingPresentationModel::GetInstance()->GetHomepage().GetPointer());
\r
71 pGroupItemCount = new(std::nothrow) int[5];
\r
72 pGroupItemCount[0] = 5; //Homepage
\r
73 pGroupItemCount[1] = 6; //Page content settings
\r
74 pGroupItemCount[2] = 5; //Private and Security
\r
75 pGroupItemCount[3] = 4; //Search
\r
76 pGroupItemCount[4] = 1; //Website settings and Reset
\r
78 for (int iter = (int) SETTING_INVALID + 1; iter < (int) SETTING_MAX; iter++)
\r
80 settingInfo[iter].isSelected = false;
\r
83 AppLogDebug("image display %d", (int) SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
\r
84 settingInfo[SETTING_HOMEPAGE_TITLE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_HOMEPAGE");
\r
85 settingInfo[SETTING_HOMEPAGE_TITLE].subText = SettingPresentationModel::GetInstance()->GetHomepage();
\r
86 settingInfo[SETTING_HOMEPAGE_TITLE].itemType = ITEM_TYPE_DROPDOWN;
\r
88 settingInfo[SETTING_CURRENT_PAGE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_CURRENT_PAGE");
\r
89 settingInfo[SETTING_CURRENT_PAGE].subText = L"";
\r
90 settingInfo[SETTING_CURRENT_PAGE].itemType = ITEM_TYPE_RADIO;
\r
92 settingInfo[SETTING_BLANK_PAGE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_BLANK_PAGE");
\r
93 settingInfo[SETTING_BLANK_PAGE].subText = L"";
\r
94 settingInfo[SETTING_BLANK_PAGE].itemType = ITEM_TYPE_RADIO;
\r
95 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
\r
97 settingInfo[SETTING_BLANK_PAGE].isSelected = true;
\r
100 settingInfo[SETTING_MOST_VISITED_SITE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_MOST_VISITED_SITES");
\r
101 settingInfo[SETTING_MOST_VISITED_SITE].subText = L"";
\r
102 settingInfo[SETTING_MOST_VISITED_SITE].itemType = ITEM_TYPE_RADIO;
\r
103 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
\r
105 settingInfo[SETTING_MOST_VISITED_SITE].isSelected = true;
\r
107 WindowInfo* pWindowInfo = null;
\r
108 String curUrl = SettingPresentationModel::GetInstance()->GetFavoriteUrl();
\r
109 AppLog("SettingForm::OnSceneActivatedN check1");
\r
111 settingInfo[SETTING_FAVORITE_URL].titleText = L"http://www.tizen.org";
\r
112 if (SettingPresentationModel::GetInstance()->GetFavoriteUrl().CompareTo(L"") == 0)
\r
114 SettingPresentationModel::GetInstance()->SetFavoriteValue(L"http://www.tizen.org");
\r
116 settingInfo[SETTING_FAVORITE_URL].subText = L"";
\r
117 settingInfo[SETTING_FAVORITE_URL].itemType = ITEM_TYPE_RADIO;
\r
119 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_USER_HOMEPAGE")) == 0)
\r
121 settingInfo[SETTING_FAVORITE_URL].isSelected = true;
\r
124 settingInfo[SETTING_DEFAULT_VIEW_TITLE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_DEFAULT_VIEW");
\r
125 settingInfo[SETTING_DEFAULT_VIEW_TITLE].subText = CommonUtil::GetString(SettingPresentationModel::GetInstance()->GetDefaultView());
\r
126 settingInfo[SETTING_DEFAULT_VIEW_TITLE].itemType = ITEM_TYPE_DROPDOWN;
\r
128 settingInfo[SETTING_FIT_TO_WIDTH].titleText = CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH");
\r
129 settingInfo[SETTING_FIT_TO_WIDTH].subText = L"";
\r
130 settingInfo[SETTING_FIT_TO_WIDTH].itemType = ITEM_TYPE_RADIO;
\r
131 settingInfo[SETTING_FIT_TO_WIDTH].isSelected = !(String::Compare(settingInfo[SETTING_FIT_TO_WIDTH].titleText, settingInfo[SETTING_DEFAULT_VIEW_TITLE].subText));
\r
133 settingInfo[SETTING_READABLE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_READABLE");
\r
134 settingInfo[SETTING_READABLE].subText = L"";
\r
135 settingInfo[SETTING_READABLE].itemType = ITEM_TYPE_RADIO;
\r
136 settingInfo[SETTING_READABLE].isSelected = !(String::Compare(settingInfo[SETTING_READABLE].titleText, settingInfo[SETTING_DEFAULT_VIEW_TITLE].subText));
\r
138 settingInfo[SETTING_RUN_JAVASCRIPT].titleText = CommonUtil::GetString(L"IDS_BR_BODY_RUN_JAVASCRIPT");
\r
139 settingInfo[SETTING_RUN_JAVASCRIPT].subText = L"";
\r
140 settingInfo[SETTING_RUN_JAVASCRIPT].itemType = ITEM_TYPE_TOGGLE;
\r
141 settingInfo[SETTING_RUN_JAVASCRIPT].isSelected = SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled();
\r
143 settingInfo[SETTING_DISPLAY_IMAGES].titleText = CommonUtil::GetString(L"IDS_BR_BODY_DISPLAY_IMAGES");
\r
144 settingInfo[SETTING_DISPLAY_IMAGES].subText = L"";
\r
145 settingInfo[SETTING_DISPLAY_IMAGES].itemType = ITEM_TYPE_TOGGLE;
\r
146 settingInfo[SETTING_DISPLAY_IMAGES].isSelected = SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled();
\r
148 settingInfo[SETTING_BLOCK_POPUP].titleText = CommonUtil::GetString(L"IDS_BR_BODY_BLOCK_POP_UPS_ABB");
\r
149 settingInfo[SETTING_BLOCK_POPUP].subText = L"";
\r
150 settingInfo[SETTING_BLOCK_POPUP].itemType = ITEM_TYPE_TOGGLE;
\r
151 settingInfo[SETTING_BLOCK_POPUP].isSelected = !SettingPresentationModel::GetInstance()->IsBlockPopUp();
\r
153 settingInfo[SETTING_CLEAR_CACHE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_CLEAR_CACHE");
\r
154 settingInfo[SETTING_CLEAR_CACHE].subText = L"";
\r
155 settingInfo[SETTING_CLEAR_CACHE].itemType = ITEM_TYPE_NORMAL;
\r
157 settingInfo[SETTING_CLEAR_HISTORY].titleText = CommonUtil::GetString(L"IDS_BR_BODY_CLEAR_HISTORY");
\r
158 settingInfo[SETTING_CLEAR_HISTORY].subText = L"";
\r
159 settingInfo[SETTING_CLEAR_HISTORY].itemType = ITEM_TYPE_NORMAL;
\r
161 settingInfo[SETTING_SHOW_SECURITY_WARNINGS].titleText = CommonUtil::GetString(L"IDS_BR_BODY_SHOW_SECURITY_WARNINGS");
\r
162 settingInfo[SETTING_SHOW_SECURITY_WARNINGS].subText = L"";
\r
163 settingInfo[SETTING_SHOW_SECURITY_WARNINGS].itemType = ITEM_TYPE_TOGGLE;
\r
164 settingInfo[SETTING_SHOW_SECURITY_WARNINGS].isSelected = SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled();
\r
166 settingInfo[SETTING_ACCEPT_COOKIES].titleText = CommonUtil::GetString(L"IDS_BR_BODY_ACCEPT_COOKIES");
\r
167 settingInfo[SETTING_ACCEPT_COOKIES].subText = L"";
\r
168 settingInfo[SETTING_ACCEPT_COOKIES].itemType = ITEM_TYPE_TOGGLE;
\r
169 settingInfo[SETTING_ACCEPT_COOKIES].isSelected = SettingPresentationModel::GetInstance()->IsCookiesEnabled();
\r
171 settingInfo[SETTING_CLEAR_COOKIE_DATA].titleText = CommonUtil::GetString(L"IDS_BR_BODY_CLEAR_ALL_COOKIE_DATA");
\r
172 settingInfo[SETTING_CLEAR_COOKIE_DATA].subText = CommonUtil::GetString(L"IDS_BR_HEADER_COOKIES");
\r
173 settingInfo[SETTING_CLEAR_COOKIE_DATA].itemType = ITEM_TYPE_NORMAL;
\r
175 settingInfo[SETTING_SEARCH_ENGINE_TITLE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_ENGINE");
\r
176 settingInfo[SETTING_SEARCH_ENGINE_TITLE].subText = SettingPresentationModel::GetInstance()->GetSearchEngine();
\r
177 settingInfo[SETTING_SEARCH_ENGINE_TITLE].itemType = ITEM_TYPE_DROPDOWN;
\r
179 settingInfo[SETTING_SEARCH_ENGINE_YAHOO].titleText = CommonUtil::GetString(L"IDS_BR_BODY_YAHOO");
\r
180 settingInfo[SETTING_SEARCH_ENGINE_YAHOO].subText = L"";
\r
181 settingInfo[SETTING_SEARCH_ENGINE_YAHOO].itemType = ITEM_TYPE_RADIO;
\r
182 settingInfo[SETTING_SEARCH_ENGINE_YAHOO].isSelected = !(String::Compare(settingInfo[SETTING_SEARCH_ENGINE_YAHOO].titleText, settingInfo[SETTING_SEARCH_ENGINE_TITLE].subText));
\r
184 settingInfo[SETTING_SEARCH_ENGINE_NAVER].titleText = CommonUtil::GetString(L"IDS_BR_BODY_NAVER");
\r
185 settingInfo[SETTING_SEARCH_ENGINE_NAVER].subText = L"";
\r
186 settingInfo[SETTING_SEARCH_ENGINE_NAVER].itemType = ITEM_TYPE_RADIO;
\r
187 settingInfo[SETTING_SEARCH_ENGINE_NAVER].isSelected = !(String::Compare(settingInfo[SETTING_SEARCH_ENGINE_NAVER].titleText, settingInfo[SETTING_SEARCH_ENGINE_TITLE].subText));
\r
189 settingInfo[SETTING_SEARCH_ENGINE_GOOGLE].titleText = CommonUtil::GetString(L"IDS_COM_BODY_GOOGLE");
\r
190 settingInfo[SETTING_SEARCH_ENGINE_GOOGLE].subText = L"";
\r
191 settingInfo[SETTING_SEARCH_ENGINE_GOOGLE].itemType = ITEM_TYPE_RADIO;
\r
192 settingInfo[SETTING_SEARCH_ENGINE_GOOGLE].isSelected = !(String::Compare(settingInfo[SETTING_SEARCH_ENGINE_GOOGLE].titleText, settingInfo[SETTING_SEARCH_ENGINE_TITLE].subText));
\r
194 settingInfo[SETTING_RESET_TO_DEFAULT].titleText = CommonUtil::GetString(L"IDS_BR_BODY_RESET_TO_DEFAULT");
\r
195 settingInfo[SETTING_RESET_TO_DEFAULT].subText = L"";
\r
196 settingInfo[SETTING_RESET_TO_DEFAULT].itemType = ITEM_TYPE_NORMAL;
\r
200 SettingForm::Initialize(void)
\r
202 result r = E_FAILURE;
\r
204 r = Construct(L"IDL_SETTING_FORM");
\r
213 SettingForm::OnInitializing(void)
\r
215 result r = E_FAILURE;
\r
216 Footer* pFooter = NULL;
\r
217 SceneManager* pSceneManager = NULL;
\r
219 __pList = static_cast< GroupedListView* >(GetControl(L"IDC_SETTING_LIST"));
\r
220 if ( __pList != NULL )
\r
223 r = __pList->SetItemProvider(*this);
\r
224 TryCatch(!IsFailed(r),,"setItemProvider failed with error %s",GetErrorMessage(r));
\r
225 __pList->AddGroupedListViewItemEventListener(*this);
\r
228 pFooter = GetFooter();
\r
231 AppLogDebug("setting back button");
\r
232 pFooter->SetBackButtonEnabled(true);
\r
233 SetFormBackEventListener(this);
\r
235 pSceneManager = SceneManager::GetInstance();
\r
236 if (pSceneManager != null)
\r
238 r = pSceneManager->AddSceneEventListener(IDSCN_SETTINGS, *this);
\r
239 TryCatch(!IsFailed(r),,"AddSceneEventListener failed with error %s",GetErrorMessage(r));
\r
241 AddOrientationEventListener(*this);
\r
248 SettingForm::OnGroupedListViewContextItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListContextItemStatus status)
\r
254 SettingForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListItemStatus status)
\r
256 int effectiveIndex = 0;
\r
257 SettingPresentationModel* pSettingMgr = SettingPresentationModel::GetInstance();
\r
259 if (pSettingMgr == null)
\r
262 for (int i = 0; i < groupIndex; i++)
\r
263 effectiveIndex = effectiveIndex + pGroupItemCount[i];
\r
264 effectiveIndex = effectiveIndex + itemIndex;
\r
266 if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_DROPDOWN)
\r
268 AppLogDebug("refreshing data child count is %d", settingInfo[effectiveIndex].childCount);
\r
269 if (settingInfo[effectiveIndex].isOpen == false)
\r
271 settingInfo[effectiveIndex].isOpen = true;
\r
272 settingInfo[effectiveIndex].childCount = 0;
\r
273 for (int iter = effectiveIndex + 1; iter < SETTING_MAX; iter++)
\r
275 if (settingInfo[iter].itemType == ITEM_TYPE_RADIO)
\r
276 settingInfo[effectiveIndex].childCount++;
\r
280 listView.UpdateList();
\r
284 settingInfo[effectiveIndex].isOpen = false;
\r
285 listView.UpdateList();
\r
288 else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_RADIO)
\r
290 int parentIndex = 0;
\r
291 for (parentIndex = effectiveIndex; parentIndex > SETTING_INVALID; parentIndex--)
\r
293 if (settingInfo[parentIndex].itemType == ITEM_TYPE_DROPDOWN)
\r
296 settingInfo[parentIndex].subText = settingInfo[effectiveIndex].titleText;
\r
298 for (int iter = 0; iter < settingInfo[parentIndex].childCount; iter++)
\r
300 if (parentIndex + iter + 1 != effectiveIndex)
\r
302 AppLogDebug("long effectiveIndex %d set to false", itemIndex - (effectiveIndex - parentIndex) + iter + 1);
\r
303 settingInfo[parentIndex + iter + 1].isSelected = false;
\r
307 AppLogDebug("effectiveIndex %d set to true", effectiveIndex);
\r
308 settingInfo[effectiveIndex].isSelected = true;
\r
310 if (effectiveIndex == SETTING_CURRENT_PAGE)
\r
312 settingInfo[SETTING_CURRENT_PAGE].isSelected = false;
\r
313 settingInfo[SETTING_FAVORITE_URL].isSelected = true;
\r
315 //listView.RefreshList(groupIndex, itemIndex - (effectiveIndex - parentIndex) + iter + 1, LIST_REFRESH_TYPE_ITEM_MODIFY);
\r
317 // listView.UpdateList();
\r
318 //listView.ScrollToItem(groupIndex, itemIndex, LIST_SCROLL_ITEM_ALIGNMENT_TOP);
\r
321 else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_TOGGLE)
\r
323 if (settingInfo[effectiveIndex].isSelected == true)
\r
325 settingInfo[effectiveIndex].isSelected = false;
\r
329 settingInfo[effectiveIndex].isSelected = true;
\r
331 // listView.RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
\r
332 if(__pList != null)
\r
334 __pList->SetItemChecked(groupIndex, itemIndex, settingInfo[effectiveIndex].isSelected);
\r
338 switch (effectiveIndex)
\r
340 case SETTING_CURRENT_PAGE:
\r
341 //SettingPresentationModel::GetInstance()->SetHomepage(settingInfo[SETTING_FAVORITE_URL].titleText);
\r
342 AppLog("setting current page currentURL is =%ls",__currentURL.GetPointer());
\r
343 if (__currentURL.CompareTo(L"") != 0)
\r
345 AppLog("setting current page currentURL is =%ls",__currentURL.GetPointer());
\r
346 SettingPresentationModel::GetInstance()->SetHomepage(CommonUtil::GetString(L"IDS_BR_BODY_USER_HOMEPAGE"));
\r
347 SettingPresentationModel::GetInstance()->SetFavoriteValue(__currentURL);
\r
348 settingInfo[SETTING_FAVORITE_URL].titleText = __currentURL;
\r
349 // listView.RefreshList(groupIndex, effectiveIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
\r
350 listView.UpdateList();
\r
353 case SETTING_BLANK_PAGE:
\r
354 //SettingPresentationModel::GetInstance()->SetHomepage(settingInfo[SETTING_BLANK_PAGE].titleText);
\r
355 SettingPresentationModel::GetInstance()->SetHomepage((L"IDS_BR_BODY_BLANK_PAGE"));
\r
356 AppLog("GetHomepage() %ls",SettingPresentationModel::GetInstance()->GetHomepage().GetPointer());
\r
357 listView.UpdateList();
\r
360 case SETTING_MOST_VISITED_SITE:
\r
361 SettingPresentationModel::GetInstance()->SetHomepage(L"IDS_BR_BODY_MOST_VISITED_SITES");
\r
362 listView.UpdateList();
\r
365 case SETTING_FAVORITE_URL:
\r
366 //SettingPresentationModel::GetInstance()->SetHomepage(settingInfo[SETTING_FAVORITE_URL].titleText);
\r
367 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_EDIT_HOMEPAGE_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
\r
370 case SETTING_FIT_TO_WIDTH:
\r
371 SettingPresentationModel::GetInstance()->SetDefaultView(L"IDS_BR_BODY_FIT_TO_WIDTH");
\r
372 listView.UpdateList();
\r
375 case SETTING_READABLE:
\r
376 SettingPresentationModel::GetInstance()->SetDefaultView(L"IDS_BR_BODY_READABLE");
\r
377 listView.UpdateList();
\r
380 case SETTING_RUN_JAVASCRIPT:
\r
381 SettingPresentationModel::GetInstance()->SetRunJavascriptEnabled(settingInfo[SETTING_RUN_JAVASCRIPT].isSelected);
\r
384 case SETTING_DISPLAY_IMAGES:
\r
385 SettingPresentationModel::GetInstance()->SetDisplayImagesEnabled(settingInfo[SETTING_DISPLAY_IMAGES].isSelected);
\r
388 case SETTING_BLOCK_POPUP:
\r
389 SettingPresentationModel::GetInstance()->SetBlockPopUp(!settingInfo[SETTING_BLOCK_POPUP].isSelected);
\r
392 case SETTING_CLEAR_CACHE:
\r
396 case SETTING_CLEAR_HISTORY:
\r
400 case SETTING_SHOW_SECURITY_WARNINGS:
\r
401 SettingPresentationModel::GetInstance()->SetSecurityWarningsEnabled(settingInfo[SETTING_SHOW_SECURITY_WARNINGS].isSelected);
\r
404 case SETTING_ACCEPT_COOKIES:
\r
405 SettingPresentationModel::GetInstance()->SetCookiesEnabled(settingInfo[SETTING_ACCEPT_COOKIES].isSelected);
\r
408 case SETTING_CLEAR_COOKIE_DATA:
\r
412 case SETTING_SEARCH_ENGINE_YAHOO:
\r
413 SettingPresentationModel::GetInstance()->SetSearchEngine(settingInfo[SETTING_SEARCH_ENGINE_YAHOO].titleText);
\r
414 listView.UpdateList();
\r
417 case SETTING_SEARCH_ENGINE_NAVER:
\r
418 SettingPresentationModel::GetInstance()->SetSearchEngine(settingInfo[SETTING_SEARCH_ENGINE_NAVER].titleText);
\r
419 listView.UpdateList();
\r
422 case SETTING_SEARCH_ENGINE_GOOGLE:
\r
423 SettingPresentationModel::GetInstance()->SetSearchEngine(settingInfo[SETTING_SEARCH_ENGINE_GOOGLE].titleText);
\r
424 listView.UpdateList();
\r
427 case SETTING_RESET_TO_DEFAULT:
\r
428 //OpenResetPopup();
\r
438 SettingForm::OnGroupedListViewItemSwept(GroupedListView& listView, int groupIndex, int itemIndex, SweepDirection direction)
\r
444 SettingForm::CreateGroupItem(int groupIndex, int itemWidth)
\r
446 result r = E_FAILURE;
\r
448 GroupItem* pItem = null;
\r
449 const Color ITEM_TEXT_COLOR = CUSTOM_COLOR_SETTINGS_GROUPTITLE;
\r
451 pItem = new(std::nothrow) GroupItem();
\r
456 r = pItem->Construct(Dimension(itemWidth, 46));
\r
463 switch (groupIndex)
\r
466 text = CommonUtil::GetString(L"IDS_BR_BODY_HOMEPAGE"); // IDS_HOMEPAGE
\r
467 settingInfo[SETTING_HOMEPAGE_TITLE].subText = SettingPresentationModel::GetInstance()->GetHomepage();
\r
471 text = CommonUtil::GetString(L"IDS_BR_MBODY_PAGE_CONTENT_SETTINGS"); // IDS_BR_MBODY_PAGE_CONTENT_SETTINGS
\r
475 text = CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"); // IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB
\r
479 text = CommonUtil::GetString(L"IDS_BR_BODY_SEARCH"); // IDS_BR_BODY_SEARCH
\r
490 pItem->SetElement(text, null);
\r
492 AppLogDebug("background color set result %s", GetErrorMessage(r));
\r
494 pItem->SetTextColor(ITEM_TEXT_COLOR);
\r
499 SettingForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
\r
501 AppLog("SettingForm::CreateItem --> groupIndex : %d, itemIndex: %d itemWidth: %d ", groupIndex, itemIndex, itemWidth);
\r
503 result r = E_SUCCESS;
\r
504 int effectiveIndex = 0;
\r
505 const Color ITEM_BACKGROUND_COLOR = CUSTOM_COLOR_SETTINGS_LISTITEM_BACKGROUND;
\r
506 const Color ITEM_RADIO_ITEM_BACKGROUND_COLOR = CUSTOM_COLOR_SETTINGS_LISTITEM_RADIO_BACKGROUND;
\r
508 for (int i = 0; i < groupIndex; i++)
\r
509 effectiveIndex = effectiveIndex + pGroupItemCount[i];
\r
510 effectiveIndex = effectiveIndex + itemIndex;
\r
511 AppLogDebug("SettingForm::CreateItem --> groupIndex : %d, itemIndex: %d itemWidth: %d effectiveIndex %d", groupIndex, itemIndex, itemWidth, effectiveIndex);
\r
513 if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_TOGGLE)
\r
515 SettingToggleCustomItem* pItem = new(std::nothrow) SettingToggleCustomItem();
\r
516 r = pItem->Construct(itemWidth, 112);
\r
523 Bitmap* pNormalBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG9,itemWidth,112);
\r
524 Bitmap* pPressedBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG_PRESS9,itemWidth,112);
\r
526 if (pNormalBackgroundBitmap != NULL)
\r
528 pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_NORMAL,pNormalBackgroundBitmap);
\r
529 delete pNormalBackgroundBitmap;
\r
532 if (pPressedBackgroundBitmap != NULL)
\r
534 pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_PRESSED,pPressedBackgroundBitmap);
\r
535 delete pPressedBackgroundBitmap;
\r
538 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL,ITEM_BACKGROUND_COLOR);
\r
539 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,ITEM_BACKGROUND_COLOR);
\r
540 if(__pList != null)
\r
542 __pList->SetItemChecked(groupIndex, itemIndex, settingInfo[effectiveIndex].isSelected);
\r
545 pItem->SetText(settingInfo[effectiveIndex].titleText);
\r
547 //if (pBitmap != null)
\r
548 // pItem->AddElement(Rectangle(0, 0, 10, 112), IDA_LIST_LEFT_SIDE_MARGIN, *pBitmap, null);
\r
553 // __pList->SetItemChecked(groupIndex, itemIndex, settingInfo[effectiveIndex].isSelected);
\r
554 // AppLog("asdasda %s %d,%d-> %d",GetErrorMessage(r),groupIndex, itemIndex, settingInfo[effectiveIndex].isSelected);
\r
559 else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_DROPDOWN)
\r
561 DropDownCustomItem* pItem = new(std::nothrow) DropDownCustomItem();
\r
562 r = pItem->Construct(itemWidth);
\r
569 /* Bitmap* pNormalBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG9,itemWidth,128);
\r
570 Bitmap* pPressedBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG_PRESS9,itemWidth,112);
\r
572 if (pNormalBackgroundBitmap != NULL)
\r
574 pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_NORMAL,pNormalBackgroundBitmap);
\r
575 delete pNormalBackgroundBitmap;
\r
578 if (pPressedBackgroundBitmap != NULL)
\r
580 pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_PRESSED,pPressedBackgroundBitmap);
\r
581 delete pPressedBackgroundBitmap;
\r
584 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL,ITEM_BACKGROUND_COLOR);
\r
585 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,ITEM_BACKGROUND_COLOR);
\r
587 pItem->SetMainText(settingInfo[effectiveIndex].titleText);
\r
588 if(settingInfo[effectiveIndex].subText.CompareTo(L"IDS_BR_BODY_BLANK_PAGE") == 0 || settingInfo[effectiveIndex].subText.CompareTo(L"IDS_BR_BODY_MOST_VISITED_SITES") == 0 || settingInfo[effectiveIndex].subText.CompareTo(L"IDS_BR_BODY_FIT_TO_WIDTH") == 0 || settingInfo[effectiveIndex].subText.CompareTo(L"IDS_BR_BODY_READABLE") == 0)
\r
590 pItem->SetSubText(CommonUtil::GetString(settingInfo[effectiveIndex].subText));
\r
594 pItem->SetSubText(settingInfo[effectiveIndex].subText);
\r
596 if (settingInfo[effectiveIndex].isOpen)
\r
598 pItem->SetCurState(DROP_DOWN_ITEM_STATE_OPENED);
\r
602 pItem->SetCurState(DROP_DOWN__ITEM_STATE_CLOSED);
\r
605 // if (pBitmap != null)
\r
606 // pItem->AddElement(Rectangle(0, 0, 10, 128), IDA_LIST_LEFT_SIDE_MARGIN_DROPDOWN, *pBitmap, null);
\r
616 else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_RADIO)
\r
620 RadioCustomItem* pItem = new(std::nothrow) RadioCustomItem();
\r
621 int parentIndex = 0;
\r
622 for (parentIndex = effectiveIndex; parentIndex > SETTING_INVALID; parentIndex--)
\r
624 if (settingInfo[parentIndex].itemType == ITEM_TYPE_DROPDOWN)
\r
627 if (settingInfo[parentIndex].isOpen == false || (__isCurrentPageDisable == true && groupIndex == 0 && itemIndex == 1))
\r
629 r = pItem->Construct(itemWidth, 0);
\r
630 AppLogDebug("construct with height 0 %s", GetErrorMessage(r));
\r
635 pItem->Construct(itemWidth, 112);
\r
638 Bitmap* pNormalBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG9,itemWidth,112);
\r
639 Bitmap* pPressedBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG_PRESS9,itemWidth,112);
\r
641 if (pNormalBackgroundBitmap != NULL)
\r
643 pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_NORMAL,pNormalBackgroundBitmap);
\r
644 delete pNormalBackgroundBitmap;
\r
647 if (pPressedBackgroundBitmap != NULL)
\r
649 pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_PRESSED,pPressedBackgroundBitmap);
\r
650 delete pPressedBackgroundBitmap;
\r
653 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL,ITEM_RADIO_ITEM_BACKGROUND_COLOR);
\r
654 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,ITEM_RADIO_ITEM_BACKGROUND_COLOR);
\r
657 pItem->SetText(settingInfo[effectiveIndex].titleText);
\r
658 AppLogDebug("effectiveIndex %d SettingInfo[effectiveIndex].isSelected %d", effectiveIndex, settingInfo[effectiveIndex].isSelected);
\r
660 //if (pBitmap != null)
\r
661 // pItem->AddElement(Rectangle(0, 0, 10, 112), IDA_LIST_LEFT_SIDE_MARGIN, *pBitmap, null);
\r
663 pItem->SetSelected(settingInfo[effectiveIndex].isSelected);
\r
668 else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_NORMAL)
\r
670 DefaultCustomItem* pItem = new(std::nothrow) DefaultCustomItem();
\r
672 r = pItem->Construct(itemWidth, 112);
\r
680 // Bitmap* pNormalBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG9,itemWidth,112);
\r
681 // Bitmap* pPressedBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG_PRESS9,itemWidth,112);
\r
683 // if (pNormalBackgroundBitmap != NULL)
\r
685 // pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_NORMAL,pNormalBackgroundBitmap);
\r
686 // delete pNormalBackgroundBitmap;
\r
689 // if (pPressedBackgroundBitmap != NULL)
\r
691 // pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_PRESSED,pPressedBackgroundBitmap);
\r
692 // delete pPressedBackgroundBitmap;
\r
695 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL,ITEM_BACKGROUND_COLOR);
\r
696 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,ITEM_BACKGROUND_COLOR);
\r
698 pItem->SetText(settingInfo[effectiveIndex].titleText);
\r
700 //if (pBitmap != null)
\r
701 // pItem->AddElement(Rectangle(0, 0, 10, 112), IDA_LIST_LEFT_SIDE_MARGIN, *pBitmap, null);
\r
718 SettingForm::DeleteGroupItem(int groupIndex, GroupItem* pItem, int itemWidth)
\r
726 SettingForm::DeleteItem(int groupIndex, int itemIndex, ListItemBase* pItem, int itemWidth)
\r
734 SettingForm::GetGroupCount(void)
\r
740 SettingForm::GetItemCount(int groupIndex)
\r
742 AppLog(" SettingForm::GetItemCount --> groupIndex : %d,", groupIndex);
\r
743 return pGroupItemCount[groupIndex];
\r
747 SettingForm::OnFormBackRequested(Form& source)
\r
749 String* pSelectedScene = NULL;
\r
750 Object* value = NULL;
\r
751 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &value);
\r
752 pSelectedScene = (String*) value;
\r
753 if (pSelectedScene)
\r
755 SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(*pSelectedScene, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
\r
756 // delete pSelectedScene;
\r
757 // pSelectedScene = null;
\r
762 SettingForm::OnActionPerformed(const Control& source, int actionId)
\r
766 case IDA_BUTTON_NO:
\r
767 if(__pConfirmationPopup)
\r
769 __pConfirmationPopup->SetShowState(false);
\r
770 __pConfirmationPopup->Show();
\r
771 delete __pConfirmationPopup;
\r
772 __pConfirmationPopup = null;
\r
776 case IDA_BUTTON_YES:
\r
777 if(__pConfirmationPopup)
\r
779 String message = L"";
\r
780 __pConfirmationPopup->SetShowState(false);
\r
781 __pConfirmationPopup->Show();
\r
782 if (__pConfirmationPopup->GetMessage() == CommonUtil::GetString(L"IDS_BR_POP_EMPTY_COOKIE_POPUP_BNO"))
\r
784 message = CommonUtil::GetString(L"IDS_BR_POP_DELETED");
\r
785 SettingPresentationModel::GetInstance()->ClearCookie();
\r
787 else if (__pConfirmationPopup->GetMessage() == CommonUtil::GetString(L"IDS_BR_POP_DELETE_LOCALLY_CACHED_CONTENT_AND_DATABASES_Q"))
\r
789 message = CommonUtil::GetString(L"IDS_BR_POP_DELETED");
\r
790 SettingPresentationModel::GetInstance()->ClearCache();
\r
792 else if (__pConfirmationPopup->GetMessage() == CommonUtil::GetString(L"IDS_BR_BODY_DELETE_BROWSER_HISTORY_Q"))
\r
794 message = CommonUtil::GetString(L"IDS_BR_POP_DELETED");
\r
795 HistoryPresentationModel::GetInstance()->ClearHistory();
\r
797 else if (__pConfirmationPopup->GetMessage() == CommonUtil::GetString(L"IDS_BR_POP_RESET_ALL_SETTINGS_TO_DEFAULT_Q"))
\r
799 message = CommonUtil::GetString(L"IDS_BR_SK_DONE");
\r
800 SettingPresentationModel::GetInstance()->ResetRegistry();
\r
801 InitializeSettingValues();
\r
802 if(__pList != null)
\r
804 __pList->UpdateList();
\r
807 delete __pConfirmationPopup;
\r
808 __pConfirmationPopup = null;
\r
810 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
\r
811 pNotification->SetText(message);
\r
812 pNotification->SetPositionDiff(0);
\r
813 pNotification->ShowNotification();
\r
823 SettingForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
\r
825 Rectangle rect = GetClientAreaBounds();
\r
826 if(__pList == null)
\r
830 __pList->SetBounds(rect.x,rect.y,rect.width-16,rect.height);
\r
831 __pList->UpdateList();
\r
834 SettingForm::SettingItemInfo::SettingItemInfo(void)
\r
840 isSelected = false ;
\r
843 SettingForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
\r
845 WindowInfo* pWindowInfo = null;
\r
846 String curUrl = SettingPresentationModel::GetInstance()->GetFavoriteUrl();
\r
848 pWindowInfo = MultipleWindowPresentationModel::GetInstance()->GetActiveWindowInfo();
\r
850 if (previousSceneId == IDSCN_EDIT_HOMEPAGE_VIEW)
\r
854 String* pValue = NULL;
\r
855 pValue = dynamic_cast<String*>(pArgs->GetAt(0));
\r
856 if( pValue != NULL )
\r
858 if (pValue->CompareTo(L"Done") == 0)
\r
860 SettingPresentationModel::GetInstance()->SetHomepage(CommonUtil::GetString(L"IDS_BR_BODY_USER_HOMEPAGE"));
\r
862 else if (pValue->CompareTo(L"Cancel") == 0)
\r
864 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
\r
865 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
\r
867 settingInfo[SETTING_MOST_VISITED_SITE].isSelected = true;
\r
868 settingInfo[SETTING_BLANK_PAGE].isSelected = false;
\r
869 settingInfo[SETTING_CURRENT_PAGE].isSelected = false;
\r
870 settingInfo[SETTING_FAVORITE_URL].isSelected = false;
\r
873 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
\r
875 settingInfo[SETTING_MOST_VISITED_SITE].isSelected = false;
\r
876 settingInfo[SETTING_BLANK_PAGE].isSelected = true;
\r
877 settingInfo[SETTING_CURRENT_PAGE].isSelected = false;
\r
878 settingInfo[SETTING_FAVORITE_URL].isSelected = false;
\r
885 if (pWindowInfo != null)
\r
887 __currentURL.Clear();
\r
888 __currentURL.Append(pWindowInfo->pageUrl);
\r
889 AppLog("current url is %ls",__currentURL.GetPointer());
\r
891 if (SettingPresentationModel::GetInstance()->GetFavoriteUrl().CompareTo(L"") == 0)
\r
893 if (pWindowInfo->pageUrl.CompareTo(L"") == 0)
\r
895 //settingInfo[SETTING_FAVORITE_URL].titleText = CommonUtil::GetString(L"IDS_SET_HOMEPAGE");
\r
896 settingInfo[SETTING_FAVORITE_URL].titleText = L"http://www.tizen.org";
\r
900 settingInfo[SETTING_FAVORITE_URL].titleText = pWindowInfo->pageUrl;
\r
905 settingInfo[SETTING_FAVORITE_URL].titleText = SettingPresentationModel::GetInstance()->GetFavoriteUrl();
\r
909 if (__pList != null)
\r
911 __pList->UpdateList();
\r
912 if (pWindowInfo && pWindowInfo->pageUrl.CompareTo(L"") == 0)
\r
914 __isCurrentPageDisable = true;
\r
915 AppLog("set item enabled is false");
\r
916 __pList->SetItemEnabled(0, 1, false);
\r
920 __isCurrentPageDisable = false;
\r
921 AppLog("set item enabled is true");
\r
922 __pList->SetItemEnabled(0, 1, true);
\r
924 for(int grpindex = 0; grpindex < groupCount; grpindex++)
\r
926 for(int index = 0; index < *(pGroupItemCount+groupCount); index++)
\r
928 int effectiveIndex = 0;
\r
929 for (int i = 0; i < grpindex; i++)
\r
930 effectiveIndex = effectiveIndex + pGroupItemCount[i];
\r
931 effectiveIndex = effectiveIndex + index;
\r
933 if(effectiveIndex >= SETTING_MAX)
\r
937 if(settingInfo[effectiveIndex].itemType == ITEM_TYPE_TOGGLE || settingInfo[effectiveIndex].itemType == ITEM_TYPE_RADIO )
\r
939 __pList->SetItemChecked(grpindex, index, settingInfo[effectiveIndex].isSelected);
\r
948 SettingForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
\r
954 SettingForm::ClearHistory(void)
\r
956 String message = CommonUtil::GetString(L"IDS_BR_BODY_DELETE_BROWSER_HISTORY_Q");
\r
957 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
\r
958 __pConfirmationPopup->Initialize();
\r
959 __pConfirmationPopup->RemoveActionListener(*this);
\r
960 __pConfirmationPopup->AddActionListener(*this);
\r
961 __pConfirmationPopup->setMessage(message);
\r
962 __pConfirmationPopup->Show();
\r
966 SettingForm::ClearCache(void)
\r
968 String message = CommonUtil::GetString(L"IDS_BR_POP_DELETE_LOCALLY_CACHED_CONTENT_AND_DATABASES_Q");
\r
969 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
\r
970 __pConfirmationPopup->Initialize();
\r
971 __pConfirmationPopup->RemoveActionListener(*this);
\r
972 __pConfirmationPopup->AddActionListener(*this);
\r
973 __pConfirmationPopup->setMessage(message);
\r
974 __pConfirmationPopup->Show();
\r
978 SettingForm::ClearCookie(void)
\r
980 String message = CommonUtil::GetString(L"IDS_BR_POP_EMPTY_COOKIE_POPUP_BNO");
\r
981 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
\r
982 __pConfirmationPopup->Initialize();
\r
983 __pConfirmationPopup->RemoveActionListener(*this);
\r
984 __pConfirmationPopup->AddActionListener(*this);
\r
985 __pConfirmationPopup->setMessage(message);
\r
986 __pConfirmationPopup->Show();
\r
990 SettingForm::ResetToDefault()
\r
992 String message = CommonUtil::GetString(L"IDS_BR_POP_RESET_ALL_SETTINGS_TO_DEFAULT_Q");
\r
993 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
\r
994 __pConfirmationPopup->Initialize();
\r
995 __pConfirmationPopup->RemoveActionListener(*this);
\r
996 __pConfirmationPopup->AddActionListener(*this);
\r
997 __pConfirmationPopup->setMessage(message);
\r
998 __pConfirmationPopup->Show();
\r