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.
17 //!Internet MainForm class
19 *@brief: The %MainForm provides the common functionalities for the Main View of the Browser including the addressbar,
20 * loading,handling events etc.
24 #include <FGraphics.h>
29 #include "IntBookmarkData.h"
30 #include "IntBookmarkPresentationModel.h"
31 #include "IntCommonLib.h"
32 #include "IntFaviconManager.h"
33 #include "IntMainForm.h"
34 #include "IntNotificationPanel.h"
35 #include "IntSceneRegister.h"
36 #include "IntSettingPresentationModel.h"
38 using namespace Tizen::App;
39 using namespace Tizen::Base;
40 using namespace Tizen::Base::Collection;
41 using namespace Tizen::Base::Runtime;
42 using namespace Tizen::Base::Utility;
43 using namespace Tizen::Graphics;
44 using namespace Tizen::Io;
45 using namespace Tizen::Locales;
46 using namespace Tizen::Media;
47 using namespace Tizen::Ui;
48 using namespace Tizen::Ui::Controls;
49 using namespace Tizen::Content;
50 using namespace Tizen::Ui::Scenes;
51 using namespace Tizen::System;
52 using namespace Tizen::Web;
53 using namespace Tizen::Web::Controls;
55 static const wchar_t* IDB_SEARCH_INPUT_FIELD_BG = L"I01_toolbar_input_field.9.png";
56 static const wchar_t* IDB_FINDWORD_INPUT_FIELD_BG = L"I01_toolbar_input_field_findword.9.png";
57 static const wchar_t* IDB_BTN_BACK = L"I01_icon_Back.png";
58 static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
59 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
60 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
61 static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
62 static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
63 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
64 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
65 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
66 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
67 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
68 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
69 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
70 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
71 static const wchar_t* IDS_APPID = L"AppID";
72 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
73 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
74 //static const wchar_t* IDB_ADDRESS_BAR_BACKGROUND = L"I01_toolbar_bg_02.9.png";
76 const int IDA_BACKBTN_CLICKED = 101;
77 const int IDA_BOOKMARKBTN_CLICKED = 102;
78 const int IDA_MOREBTN_CLICKED = 103;
79 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
80 const int IDA_NEWWINDOWBTN_CLICKED = 105;
81 const int IDA_FORWARD_CLICKED = 106;
82 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
83 const int IDA_SHARE_CLICKED = 108;
84 const int IDA_FINDONPAGE_CLICKED = 109;
85 const int IDA_PRIVATEON_CLICKED = 110;
86 const int IDA_SETTINGS_CLICKED = 111;
87 const int IDA_READER_CLOSE_CLICKED = 112;
88 const int IDA_SMALLFONT_BTN_CLICKED = 113;
89 const int IDA_LARGEFONT_BTN_CLICKED = 114;
90 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
91 const int IDA_HISTORY_CLICKED = 116;
92 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
93 const int IDA_ADD_TO_HOME_CLICKED = 118;
94 const int IDA_SAVED_PAGES_CLICKED = 119;
95 const int IDA_DESKTOP_VIEW_CLICKED = 120;
96 const int IDA_SAVE_CLICKED = 121;
97 const int IDA_PRINT_CLICKED = 122;
99 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
100 const int IDA_FINDWORD_NEXT_CLICKED = 202;
101 const int IDA_FINDWORD_PREV_CLICKED = 203;
102 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
103 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
105 const int IDA_COPY_IMAGE_CLICKED = 206;
106 const int IDA_VIEW_IMAGE_CLICKED = 207;
107 const int IDA_SAVE_IMAGE_CLICKED = 208;
108 const int IDA_SHARE_IMAGE_CLICKED = 209;
110 const int IDA_COPY_TEXT_CLICKED = 210;
111 const int IDA_PASTE_TEXT_CLICKED = 211;
112 const int IDA_FIND_TEXT__CLICKED = 212;
113 const int IDA_SHARE_TEXT_CLICKED = 213;
115 const int IDA_GO_BACK = 214;
116 const int IDA_GO_FORWARD = 215;
117 const int IDA_REFRESH_BTN_CLICKED = 216;
118 const int IDA_STOP_BTN_CLICKED = 217;
119 const int IDA_CLEAR_URL = 218;
120 const int IDA_READER_BTN_CLICKED = 219;
123 const int IDA_HYPERLINK_OPEN_CLICKED = 220;
124 const int IDA_HYPERLINK_COPY_LINK_CLICKED = 221;
125 const int IDA_HYPERLINK_SAVE_IMAGE_CLICKED = 222;
126 const int IDA_HYPERLINK_SHARE_IMAGE_CLICKED = 223;
128 const int IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED = 224;
130 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
132 const int MainForm::IDA_FORMAT_BITMAP = 500;
133 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
134 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
135 const int MainForm::IDA_FORMAT_URL_STRING = 503;
136 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
138 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
139 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
140 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
142 MainForm::MainForm(void)
144 //__isLongPressedDone = false;
146 __pAddressbar = null;
147 // __pMostVisitedSitesPanel = null;
148 __pMostVisitedListView = null;
149 __pFooterPanel = null;
150 __pHitElementResult = null;
151 __pWindowInfo = null;
155 __pFindWordControl = null;
156 __pFindWordPanelLeftToRight = null;
157 __pFindWordPanelRightToLeft = null;
158 __pFindWordBgLabel = null;
159 __pFindWordBgLabelRightToLeft = null;
160 __pFindWordEditField = null;
161 __pFindWordEditFieldRightToLeft = null;
162 __pFindWordClear = null;
163 __pFindWordClearRightToLeft = null;
164 __pFindWordCountLabel = null;
165 __pFindWordClearRightToLeft = null;
166 __pFindWordNext = null;
167 __pFindWordPrev = null;
168 __previousZoomLevel = 1.0;
170 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
173 __currentSearchStr = L"";
174 __currentSelectedStr = L"";
175 __maxOccurrances = 0;
176 __currentWordIndex = 0;
179 //__inputEventToBeSupressed = false;
180 __isLoadingData = false;
181 __isLoadingCompleted = false;
182 __progressPercentage = 0;
183 __touchPoint1 = Point(-1,-1);
184 __touchPoint2 = Point(-1,-1);
185 __longPressPoint = Point(-1,-1);
187 // __pReaderPopup = null;
188 __pReaderData = null;
190 __pReaderCloseBtn = null;
191 //__pNewWindowButton = null;
192 __pMoreButton = null;
193 __pMultiWindowButton = null;
194 __pArticleReaderPanel = null;
195 __pBlankPanel = null;
196 __pArticleReaderLabel = null;
197 __webControlHeight = 0;
198 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
199 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
200 __pMostVisitedSites = null;
201 __pFooterUrlField = null;
203 __pGoForwardBtn = null;
204 __pRefreshBtn = null;
205 __pProgressbarLabel = null;
206 __pFooterLabel = null;
210 __isWebKeypadOpened = false;
214 MainForm::~MainForm(void)
216 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
220 __pAddressbar->SetAddressbarEventListener(null);
223 if(__pHistory != null)
229 if (__pReaderData != null)
231 delete __pReaderData;
232 __pReaderData = null;
235 if (__pPopUp != null)
241 if (__pHitElementResult != null)
243 delete __pHitElementResult;
244 __pHitElementResult = null;
247 String* pSelectedScene = NULL;
248 Object* pValue = NULL;
249 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
250 pSelectedScene = (String*) pValue;
252 /*if (pSelectedScene != null)
254 delete pSelectedScene;
256 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
260 MainForm::Initialize(void)
262 Construct(L"IDL_FORM");
267 MainForm::OnInitializing(void)
269 AppLog("get client area width = %d",GetClientAreaBounds().width);
270 AppLog("get client area height = %d",GetClientAreaBounds().height);
271 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
272 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
274 __fontSize = CommonUtil::GetFontSize();
275 Panel* pFooterPanel = null;
277 __pSaveImage = new Image();
278 __pSaveImage->Construct();
280 // Setup back event listener
281 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
282 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
283 AddOrientationEventListener(*this);
284 AppLogDebug(" MainForm::OnInitializing ended");
285 if (__pMostVisitedSites == null)
287 __pMostVisitedSites = new(std::nothrow) ArrayList();
288 __pMostVisitedSites->Construct();
290 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
292 __pItemContext= new(std::nothrow) ListContextItem();
293 __pItemContext->Construct();
294 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
295 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
297 if (pBitmapNormal != null && pBitmapPressed != null)
299 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
302 if (pBitmapNormal != null)
304 delete pBitmapNormal;
307 if (pBitmapPressed != null)
309 delete pBitmapPressed;
312 __pItemContextLandscape= new(std::nothrow) ListContextItem();
313 __pItemContextLandscape->Construct();
314 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
315 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
317 if (pBitmapNormal != null && pBitmapPressed != null)
319 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
322 if (pBitmapNormal != null)
324 delete pBitmapNormal;
327 if (pBitmapPressed != null)
329 delete pBitmapPressed;
336 MainForm::InitAddressbar(void)
338 AppLogDebug("MainForm::InitAddressbar entered");
340 result r = E_SUCCESS;
342 if (__pAddressbar != null)
346 __pAddressbar = new(std::nothrow) Addressbar();
347 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
348 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
351 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
354 __pAddressbar->SetAddressbarEventListener(this);
355 AddControl(__pAddressbar);
356 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
357 SetControlAlwaysOnTop(*__pAddressbar, true);
358 __adressPanelPosition = __pAddressbar->GetPosition();
360 AppLogDebug("MainForm::InitAddressbar exit");
366 MainForm::CreateReaderPanel(void)
368 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
369 result r = E_FAILURE;
371 Button *pSmallFontBtn = null;
372 Button *pLargeFontBtn = null;
374 __pBlankPanel = new (std::nothrow) Panel();
375 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
377 __pArticleReaderPanel = new (std::nothrow) Panel();
378 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
380 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
381 if (__pReaderCloseBtn)
383 AppLogDebug("CreateReaderPanel() 6");
384 __pReaderCloseBtn->AddActionEventListener(*this);
385 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
388 __pWebReader = new (std::nothrow) Web();
389 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
391 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
392 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
394 r = __pWebReader->SetSetting(settings);
396 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
399 __pArticleReaderLabel = new Label();
400 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
402 __pBlankPanel->AddControl(__pArticleReaderLabel);
403 __pBlankPanel->AddControl(__pArticleReaderPanel);
404 AddControl(__pBlankPanel);
406 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
407 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
408 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
410 __pArticleReaderPanel->AddControl(__pWebReader);
411 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
412 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
413 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
415 if (pBitmap != null && pSrcBitmap != null)
417 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
419 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
421 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
424 pSmallFontBtn->AddActionEventListener(*this);
425 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
428 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
431 pLargeFontBtn->AddActionEventListener(*this);
432 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
441 if (pSrcBitmap != null)
447 SetControlAlwaysOnTop(*__pBlankPanel, true);
448 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
455 MainForm::InitWebControl()
457 AppLogDebug("MainForm::InitWebControl enter");
458 result r = E_SUCCESS;
459 AppLogDebug("InitWebControl");
461 if (__pAddressbar == null || __pFooterPanel == null)
464 const int Y_WEBCONTROL_POSITION = 0;
465 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
466 if (__pMostVisitedListView)
468 __pMostVisitedListView->SetShowState(false);
470 if (__pWebViewer != null)
472 AppLogDebug("Already initialized");
475 __pWebViewer = new(std::nothrow) Web();
476 if(__pWebViewer == NULL)
478 AppLogDebug("Initialization failed");
481 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
485 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
492 r = AddControl(__pWebViewer);
498 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
501 __webControlPosition = __pWebViewer->GetPosition();
502 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
505 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
509 __pWebViewer->SetLoadingListener(this);
510 __pWebViewer->SetWebUiEventListener(this);
511 __pWebViewer->SetWebKeypadEventListener(this);
512 __pWebViewer->SetFocus();
513 __pWebViewer->AddTouchEventListener(*this);
515 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
516 __pWebViewer->SetTextSearchListener(this);
519 AppLogDebug("MainForm :before return");
521 AppLogDebug("MainForm::InitWebControl Exit");
527 MainForm::OnFocusGained(const Control& source)
529 AppLog("MainForm::OnFocusGained");
533 MainForm::OnFocusLost(const Control& source)
535 AppLog("MainForm::OnFocusLost");
539 MainForm::SetJavascriptEnabled()
541 WebSetting settings = __pWebViewer->GetSetting();
542 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
543 __pWebViewer->SetSetting(settings);
547 MainForm::SetImageLoadEnabled()
549 WebSetting settings = __pWebViewer->GetSetting();
550 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
551 __pWebViewer->SetSetting(settings);
555 MainForm::InitFooter(void)
557 AppLogDebug("MainForm::InitFooter entered");
558 Button* pBackButton = null;
559 Button* pBookmarkButton = null;
560 Button* pMultiWindowButton = null;
561 Bitmap *pIconBitmap = null;
562 Bitmap *pBGBitmap = null;
563 Label *pBGLabel = null;
565 if (__pFooterPanel == null)
567 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
570 if (__pFooterPanel == null)
575 SetControlAlwaysOnTop(*__pFooterPanel, true);
577 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
578 if ( __pFooterLabel == NULL )
582 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
583 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
586 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
590 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
592 if ( __pMultiWindowButton == NULL )
597 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
599 if ( __pMoreButton == NULL )
604 if (__pMultiWindowButton != null)
606 Bitmap* pBitmap = null;
607 Bitmap* pPressedBitmap = null;
608 String imagePath = "I01_toolbar_icon_windows_manager_0";
609 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
610 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
611 imagePath.Append(totalCount);
612 imagePath.Append(".png");
614 pressedImagePath.Append(totalCount);
615 pressedImagePath.Append("_press.png");
617 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
618 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
619 if ( pBitmap == null )
624 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
627 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
628 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
633 __pMultiWindowButton->AddActionEventListener(*this);
634 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
639 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
640 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
643 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
644 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
645 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
649 __pMoreButton->AddActionEventListener(*this);
650 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
653 //Add the editfield for url
654 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
655 if (__pFooterUrlField == NULL)
657 return E_INVALID_KEY;
660 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
661 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
662 __pFooterUrlField->AddKeypadEventListener(*this);
663 __pFooterUrlField->SetPropagatedTouchEventListener(this);
665 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
667 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
669 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
671 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
675 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
676 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
680 //Add the go Back Button
681 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
682 if (__pGoBackBtn == NULL)
684 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
685 return E_INVALID_KEY;
687 __pGoBackBtn->SetActionId(IDA_GO_BACK);
688 __pGoBackBtn->AddActionEventListener(*this);
690 //Add the go forward Button
691 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
692 if (__pGoForwardBtn == NULL)
694 AppLogDebug("Control not found returning E_INVALID_KEY");
695 return E_INVALID_KEY;
697 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
698 __pGoForwardBtn->AddActionEventListener(*this);
699 if (__pWebViewer && __pWebViewer->CanGoForward())
701 SetForwardButtonEnabled(true);
705 SetForwardButtonEnabled(false);
708 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
709 if (__pRefreshBtn == NULL)
711 AppLogDebug("Control not found returning E_INVALID_KEY");
712 return E_INVALID_KEY;
715 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
716 __pRefreshBtn->AddActionEventListener(*this);
717 __pRefreshBtn->SetShowState(true);
719 //Add the backround label for displaying progressbar
720 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
721 if (__pProgressbarLabel == NULL)
723 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
724 return E_INVALID_KEY;
726 __pProgressbarLabel->SetShowState(false);
728 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
729 if (__pStopBtn == NULL)
731 AppLogDebug("Control not found returning E_INVALID_KEY");
732 return E_INVALID_KEY;
734 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
735 __pStopBtn->AddActionEventListener(*this);
736 __pStopBtn->SetShowState(false);
738 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
739 if (__pClearBtn == NULL)
741 AppLogDebug("Control not found returning E_INVALID_KEY");
742 return E_INVALID_KEY;
744 __pClearBtn->SetActionId(IDA_CLEAR_URL);
745 __pClearBtn->AddActionEventListener(*this);
746 __pClearBtn->SetShowState(false);
748 __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
749 if (__pReaderBtn == NULL)
751 AppLogDebug("Control not found returning E_INVALID_KEY");
752 return E_INVALID_KEY;
754 __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
755 __pReaderBtn->AddActionEventListener(*this);
756 __pReaderBtn->SetShowState(false);
758 // __pFooterPanel->Invalidate(true);
759 AppLogDebug("MainForm::InitFooter exit");
765 MainForm::InitContextMenu(Point& p)
767 result r = E_SUCCESS;
768 bool isPrivateBrowsing = false;
769 Bitmap* pBitmap = null;
773 __pMenu->SetAnchorPosition(p);
774 __pMenu->Invalidate(true);
778 __pMenu = new(std::nothrow) ContextMenu();
779 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
780 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
782 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
785 if (isPrivateBrowsing == true)
787 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
791 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
794 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
796 if ( pBitmap != NULL)
798 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
801 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
802 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
803 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
806 __pMenu->SetMaxVisibleItemsCount(6);
807 __pMenu->SetShowState(false);
808 __pMenu->AddActionEventListener(*this);
809 SetControlAlwaysOnTop(*__pMenu, true);
815 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
817 result r = E_SUCCESS;
818 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
820 AppLog("MainForm::InitImageContextMenu clicked on image");
821 if (__pImageMenu != null)
827 __pImageMenu = new (std::nothrow) ContextMenu();
828 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
829 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
831 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
832 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
833 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
834 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
835 __pImageMenu->SetMaxVisibleItemsCount(4);
836 __pImageMenu->AddActionEventListener(*this);
837 SetControlAlwaysOnTop(*__pImageMenu, true);
843 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
845 result r = E_SUCCESS;
846 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
848 AppLog("MainForm::InitImageContextMenu clicked on image");
849 if (__pImageMenu != null)
855 if(__pAddressbar->GetShowState() == true)
856 p.y = p.y + __pAddressbar->GetHeight();
858 __pImageMenu = new (std::nothrow) ContextMenu();
859 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
860 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
862 r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED);
863 r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,IDA_HYPERLINK_COPY_LINK_CLICKED);
864 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
865 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
867 __pImageMenu->SetMaxVisibleItemsCount(3);
868 __pImageMenu->AddActionEventListener(*this);
869 SetControlAlwaysOnTop(*__pImageMenu, true);
876 MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
878 result r = E_SUCCESS;
879 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
881 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
882 if (__pImageMenu != null)
891 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
895 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
897 __pImageMenu = new (std::nothrow) ContextMenu();
898 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
899 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
901 if(onlyPasteOption == false)
903 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
905 if (pasteOption || onlyPasteOption)
907 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
909 if(onlyPasteOption == false)
911 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
912 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
915 __pImageMenu->SetMaxVisibleItemsCount(3);
916 __pImageMenu->AddActionEventListener(*this);
917 SetControlAlwaysOnTop(*__pImageMenu, true);
924 MainForm::InitFindWordPanel(void)
926 result r = E_SUCCESS;
927 Bitmap *pIconBitmap = null;
929 if (__pFindWordControl != null)
931 AppLogDebug("Findword panel already initialized");
932 if (__pFindWordBgLabel != null)
934 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
937 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
941 if (__pFindWordBgLabelRightToLeft != null)
943 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
946 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
953 __pFindWordControl = new (std::nothrow) Panel();
954 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
957 AppLogException("There is some problem in the xml file. Please check.");
960 AddControl(__pFindWordControl);
961 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
962 SetControlAlwaysOnTop(*__pFindWordControl,true);
963 __pFindWordControl->SetShowState(false);
964 __pFindWordControl->Invalidate(false);
966 __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
967 __pFindWordPanelLeftToRight->SetShowState(true);
969 __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
970 __pFindWordPanelRightToLeft->SetShowState(false);
972 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
973 if (__pFindWordBgLabel != null)
975 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
976 Rectangle pRect = pPanel1->GetBounds();
977 pRect.x = pRect.y = 0;
978 __pFindWordBgLabel->SetBounds(pRect);
979 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
982 AppLogDebug("InitFindWordPanel: Coming here");
983 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
988 AppLogDebug("InitFindWordPanel: shouldn't Come here");
992 __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
993 if (__pFindWordBgLabelRightToLeft != null)
995 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
996 Rectangle pRect = pPanel1->GetBounds();
997 pRect.x = pRect.y = 0;
998 __pFindWordBgLabelRightToLeft->SetBounds(pRect);
999 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1000 if (pBitmap != null)
1002 AppLogDebug("InitFindWordPanel: Coming here");
1003 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1008 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1012 Button* pfindWordCancel = null;
1013 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1014 if (pfindWordCancel == null)
1016 AppLogException("There is some problem in the xml file. Please check.");
1019 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1020 pfindWordCancel->AddActionEventListener(*this);
1022 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1023 if (__pFindWordClear == null)
1025 AppLogException("There is some problem in the xml file. Please check.");
1029 __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1030 if (__pFindWordClearRightToLeft == null)
1032 AppLogException("There is some problem in the xml file. Please check.");
1036 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1037 __pFindWordClear->AddActionEventListener(*this);
1039 __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1040 __pFindWordClearRightToLeft->AddActionEventListener(*this);
1042 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1043 if (__pFindWordNext == null)
1045 AppLogException("There is some problem in the xml file. Please check.");
1049 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1050 __pFindWordNext->AddActionEventListener(*this);
1052 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1053 if (__pFindWordPrev == null)
1055 AppLogException("There is some problem in the xml file. Please check.");
1059 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1060 __pFindWordPrev->AddActionEventListener(*this);
1062 __pFindWordNext->SetEnabled(false);
1063 __pFindWordPrev->SetEnabled(false);
1065 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1066 if (__pFindWordCountLabel == null)
1068 AppLogException("There is some problem in the xml file. Please check.");
1072 __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1073 if (__pFindWordCountLabel == null)
1075 AppLogException("There is some problem in the xml file. Please check.");
1079 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1080 if (__pFindWordEditField == null)
1082 AppLogException("There is some problem in the xml file. Please check.");
1085 __pFindWordEditField->AddTextEventListener(*this);
1086 __pFindWordEditField->AddKeypadEventListener(*this);
1087 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1089 __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1090 if (__pFindWordEditFieldRightToLeft == null)
1092 AppLogException("There is some problem in the xml file. Please check.");
1095 __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1096 __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1097 __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1103 MainForm::CreateItem (int index, int itemWidth)
1105 Rectangle listImageRect;
1106 Rectangle pagetTitleRect;
1107 Rectangle pageURLRect;
1108 Rectangle deleteImageRect;
1109 String pageTitle(L"");
1110 String pageURL(L"");
1111 result r = E_SUCCESS;
1112 Bitmap* pListIconImage = null;
1115 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1116 if(pHistory == null)
1120 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1121 if ( pAppResource == NULL )
1125 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1127 CustomItem* pItem = new(std::nothrow) CustomItem();
1128 pageTitle = pHistory->GetHistoryTitle();
1129 pageURL = pHistory->GetHistoryUrl();
1131 if (pageURL.GetLength() == 0)
1134 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1135 pageURL = L"<"+ nourl +">";
1139 Rectangle screenBounds = GetBounds();
1142 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1151 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1153 if ( pBitmap != NULL)
1155 pListIconImage = new Bitmap();
1156 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1160 if(pListIconImage == null)
1162 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1165 if ( pListIconImage != NULL)
1167 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2 , 72, 72);
1168 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60 + (__fontSize - 44));
1169 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1172 if (pItem != null && pListIconImage != NULL)
1174 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1178 if (pageTitle.CompareTo(L"") != 0)
1182 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1186 if (pageURL.CompareTo(L"") != 0)
1190 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1195 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1197 if ( __pItemContext!= NULL)
1201 pItem->SetContextItem(__pItemContext);
1207 if ( __pItemContextLandscape!= NULL)
1211 pItem->SetContextItem(__pItemContextLandscape);
1215 if( pListIconImage != NULL)
1217 delete pListIconImage;
1218 pListIconImage = null;
1225 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1232 MainForm::GetItemCount (void)
1234 if(__pMostVisitedSites != null)
1236 __pMostVisitedSites->RemoveAll(true);
1238 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1239 if(__pMostVisitedSites != null)
1241 return __pMostVisitedSites->GetCount();
1248 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1250 if(__pMostVisitedSites != null)
1252 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1253 if (pHistory != null)
1255 String url = pHistory->GetHistoryUrl();
1257 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1258 __pMostVisitedListView->UpdateList();
1264 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1266 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1267 String url = pHistory->GetHistoryUrl();
1275 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1281 MainForm::OnTerminating(void)
1283 result r = E_SUCCESS;
1285 RemoveOrientationEventListener(*this);
1289 __pAddressbar->SetAddressbarEventListener(null);
1294 __pWebViewer->RemoveTouchEventListener(*this);
1299 delete __pItemContext;
1301 if(__pItemContextLandscape)
1303 delete __pItemContextLandscape;
1309 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1311 result r = E_SUCCESS;
1313 AppLogDebug("Clicked : %d", actionId);
1316 case IDA_BACKBTN_CLICKED:
1318 if (__pWebViewer && __pWebViewer->CanGoBack())
1320 __pWebViewer->GoBack();
1322 else if(__pWindowInfo->isJavascriptInitiated == false)
1325 pApp = UiApp::GetInstance();
1328 r = pApp->Terminate();
1331 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1339 WindowInfo* pWindowInfo = null;
1341 SceneManager* pSceneManager = SceneManager::GetInstance();
1342 if (pSceneManager == null)
1346 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1347 if (pAllWindowList == NULL)
1349 pApp = UiApp::GetInstance();
1352 r = pApp->Terminate();
1355 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1360 if (pAllWindowList != null)
1362 totalCount = pAllWindowList->GetCount();
1364 for (int count = 0; count < totalCount; count++)
1366 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1367 if (pWindowInfo == null)
1369 pApp = UiApp::GetInstance();
1372 r = pApp->Terminate();
1375 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1382 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1384 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1387 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1390 r = pAllWindowList->RemoveAt(count, true);
1391 __pWindowInfo = null;
1394 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1399 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1403 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1405 if (pWindowInfo == null)
1407 pApp = UiApp::GetInstance();
1410 r = pApp->Terminate();
1416 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1419 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1431 case IDA_FORWARD_CLICKED:
1432 if (__pWebViewer == null)
1435 if (__pWebViewer->CanGoForward())
1437 __pWebViewer->GoForward();
1439 __pMenu->SetShowState(false);
1440 __pMenu->Invalidate(false);
1443 case IDA_FINDONPAGE_CLICKED:
1445 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1446 __currentSearchStr.Clear();
1448 InitFindWordPanel();
1449 __pMenu->SetShowState(false);
1450 __pMenu->Invalidate(false);
1452 ShowFindWordPanel(true);
1454 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1456 __pFindWordEditField->SetFocus();
1457 __pFindWordCountLabel->SetShowState(false);
1461 __pFindWordEditFieldRightToLeft->SetFocus();
1462 __pFindWordCountLabelRightToLeft->SetShowState(false);
1466 case IDA_PRIVATEON_CLICKED:
1468 result r = E_SUCCESS;
1470 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1471 Bitmap* pBitmap = null;
1472 if (isPrivateBrowsing == true)
1474 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1477 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1481 if (__pWebViewer != NULL)
1483 __pWebViewer->SetPrivateBrowsingEnabled(false);
1486 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1488 if (__pAddressbar != null)
1490 __pAddressbar->UpdateFaviconBitmap(false);
1496 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1499 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1503 if (__pWebViewer != NULL)
1505 __pWebViewer->SetPrivateBrowsingEnabled(true);
1508 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1510 if (__pAddressbar != null)
1512 __pAddressbar->UpdateFaviconBitmap(true);
1517 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1518 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1519 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1520 __pMenu->Invalidate(true);
1522 if ( pBitmap != NULL )
1529 case IDA_SETTINGS_CLICKED:
1532 ArrayList* pArgList = new(std::nothrow) ArrayList();
1535 pArgList->Construct();
1536 pArgList->Add(*__pWindowInfo);
1537 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1539 __pMenu->SetShowState(false);
1540 __pMenu->Invalidate(false);
1541 if (pArgList != null)
1550 case IDA_ADDTOBOOKMARK_CLICKED:
1553 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1555 int bookmarkCount=0;
1558 url=__pWindowInfo->pageUrl;
1559 result r = E_SUCCESS;
1560 Bitmap* pBitmap = null;
1561 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1569 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1570 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1571 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1573 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1574 if (pNotification != null)
1576 pNotification->SetText(message);
1577 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1578 pNotification->ShowNotification();
1583 String title=__pWindowInfo->pageTitle;
1584 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1585 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1587 pBookmark->SetBookmarkTitle(title);
1588 pBookmark->SetUrl(url);
1589 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1591 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1593 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1594 pBookmark->SetFaviconId(id);
1595 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1596 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1599 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1600 if (pNotification != null)
1602 pNotification->SetText(message);
1603 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1604 pNotification->ShowNotification();
1605 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1608 if (pBitmap != null)
1610 r = __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1614 __pMenu->Invalidate(true);
1618 case IDA_PRINT_CLICKED:
1620 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//data//test.pdf");
1621 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1623 AppLog("RequestPrint called!");
1624 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1625 result nResult = E_FAILURE;
1628 AppLog("TestPrint if (pAc) == true");
1633 String fileType = L"service_print_files_type";
1634 String typeVal = L"DOC";
1636 String fileCount = L"service_print_files_count";
1637 String countVal = L"1";
1638 String fileFolder= L"service_print_files_folder_name";
1639 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//data";
1641 map.Add(&fileCount, &countVal);
1642 map.Add(&fileFolder, &folderVal);
1643 map.Add(&fileType, &typeVal);
1645 String fileName = L"service_print_files_files_name";
1647 ArrayList fileNameList;
1648 fileNameList.Construct();
1649 String file1 = L"test.pdf";
1651 fileNameList.Add(&file1);
1652 map.Add(&fileName, &fileNameList);
1654 nResult = pAc->Start(NULL, NULL, &map, NULL);
1656 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1657 else if (nResult == E_MAX_EXCEEDED)
1658 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1659 else if (nResult == E_OBJ_NOT_FOUND)
1660 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1661 else if (nResult == E_IN_PROGRESS)
1662 AppLog("TestPrint ret == E_IN_PROGRESS");
1663 else if (nResult == E_PRIVILEGE_DENIED)
1664 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1665 else if(nResult == E_SYSTEM)
1666 AppLog("TestPrint ret == E_SYSTEM");
1672 int __modalMsgBoxResult;
1673 MessageBox* pMsgBox = new MessageBox();
1674 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1675 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1678 __modalMsgBoxResult = 0;
1682 case IDA_SHARE_CLICKED:
1684 if(__pPopUp != null)
1689 __pPopUp = new(std::nothrow) SharePopup();
1690 __pPopUp->Initialize();
1691 if (__pWindowInfo != null)
1693 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1694 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1695 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1696 pShareInfo->SetImageAttached(false);
1697 __pPopUp->RemoveAllShareInfo();
1698 __pPopUp->AddShareInfo(pShareInfo);
1700 __pPopUp->SetShowState(true);
1704 case IDA_BOOKMARKBTN_CLICKED:
1706 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1707 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1710 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1715 case IDA_MOREBTN_CLICKED:
1717 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1718 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1719 AppLog("Anchot pos: %d %d", p.x, p.y);
1721 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1723 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1724 int bookmarkCount=0;
1727 url=__pWindowInfo->pageUrl;
1728 result r = E_SUCCESS;
1729 Bitmap* pBitmap = null;
1731 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1734 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1739 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1743 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1745 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1747 if (__pMenu->GetItemCount() == 9)
1749 r = __pMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1753 r = __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1758 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1762 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1763 if (__pMenu->GetItemCount() != 9)
1765 __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1766 __pMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1767 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1768 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1769 __pMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1770 __pMenu->SetMaxVisibleItemsCount(6);
1772 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1774 AppLog(" Orientation landscape");
1775 __pMenu->SetMaxVisibleItemsCount(5);
1779 AppLog(" Orientation potrait");
1780 __pMenu->SetMaxVisibleItemsCount(6);
1783 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1786 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1787 __pMenu->SetShowState(true);
1788 __pMenu->Invalidate(true);
1792 case IDA_HISTORY_CLICKED:
1794 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1795 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1798 case IDA_SAVED_PAGES_CLICKED:
1803 case IDA_DESKTOP_VIEW_CLICKED:
1808 case IDA_SAVE_CLICKED:
1813 case IDA_MULTIWINDOWBTN_CLICKED:
1815 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1816 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1820 case IDA_NEWWINDOWBTN_CLICKED:
1822 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
1824 if (pNewWindowInfo == null)
1828 result r = E_SUCCESS;
1829 SceneManager* pSceneManager = SceneManager::GetInstance();
1831 if (pSceneManager == NULL)
1835 ArrayList* pArgList = new(std::nothrow) ArrayList();
1836 if (pArgList == NULL)
1840 r = pArgList->Construct();
1843 pArgList->Add(*pNewWindowInfo);
1844 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1850 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1855 case IDA_SMALLFONT_BTN_CLICKED:
1857 WebSetting setting = __pWebReader->GetSetting();
1858 setting.SetFontSize(15);
1859 __pWebReader->SetSetting(setting);
1862 case IDA_LARGEFONT_BTN_CLICKED:
1864 WebSetting setting = __pWebReader->GetSetting();
1865 setting.SetFontSize(25);
1866 __pWebReader->SetSetting(setting);
1869 case IDA_READER_CLOSE_CLICKED:
1871 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1873 RemoveControl(__pBlankPanel);
1874 __pArticleReaderPanel = null;
1875 __pBlankPanel = null;
1876 __pArticleReaderLabel = null;
1878 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1881 case IDA_FINDWORD_CANCEL_CLICKED:
1883 __currentSearchStr = L"";
1884 __currentWordIndex = 0;
1885 __maxOccurrances = 0;
1886 __pFindWordEditField->SetText(L"");
1887 __pFindWordNext->SetEnabled(false);
1888 __pFindWordPrev->SetEnabled(false);
1889 __pFindWordCountLabel->SetText(L"0/0");
1890 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1891 AppLog("akjshdasd 1");
1892 __pFooterPanel->SetShowState(true);
1893 ShowFindWordPanel(false);
1896 case IDA_FINDWORD_SEARCH_CLICKED:
1898 __currentSearchStr = __pFindWordEditField->GetText();
1899 if (__currentSearchStr.GetLength() > 0)
1905 AppLogDebug("Enter something");
1909 case IDA_FINDWORD_CLEAR_CLICKED:
1911 __pFindWordCountLabel->SetText(L"0/0");
1912 __pFindWordEditField->SetText(L"");
1913 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1915 __currentSearchStr = L"";
1916 __pFindWordNext->SetEnabled(false);
1917 __pFindWordPrev->SetEnabled(false);
1918 __pFindWordCountLabel->SetShowState(false);
1919 __pFindWordControl->Invalidate(true);
1922 case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
1924 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
1925 __pFindWordEditFieldRightToLeft->SetText(L"");
1926 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1928 __currentSearchStr = L"";
1929 __pFindWordNext->SetEnabled(false);
1930 __pFindWordPrev->SetEnabled(false);
1931 __pFindWordCountLabelRightToLeft->SetShowState(false);
1932 __pFindWordControl->Invalidate(true);
1935 case IDA_FINDWORD_NEXT_CLICKED:
1940 case IDA_FINDWORD_PREV_CLICKED:
1942 FindNextWord(false);
1945 case IDA_BRIGHTNESS_BTN_CLICKED:
1947 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1948 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1951 case IDA_COPY_IMAGE_CLICKED:
1953 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1954 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1956 const Bitmap* pBitmap = null;
1957 if (__pHitElementResult != null)
1959 pBitmap = __pHitElementResult->GetImage();
1962 String resourcePath = App::GetInstance()->GetAppResourcePath();
1963 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1965 // copying the item to clipboard
1966 Clipboard* pClipboard = Clipboard::GetInstance();
1967 if (pClipboard != null)
1969 pClipboard->CopyItem(item);
1973 case IDA_VIEW_IMAGE_CLICKED:
1975 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1976 WindowInfo* pNewWindowInfo = null;
1977 if (__pHitElementResult != null)
1979 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1980 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1986 case IDA_SAVE_IMAGE_CLICKED:
1988 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1989 const Bitmap* pSaveBitmap = null;
1990 String imageName = GetImagePath();
1991 AppLog("Content manager image name %ls",imageName.GetPointer());
1994 imagePath.Append(imageName);
1995 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1996 AppLog("Content manager image path %ls",imagePath.GetPointer());
1997 if (__pHitElementResult != null)
1999 pSaveBitmap = __pHitElementResult->GetImage();
2001 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2005 UpdateImageContent(pBuffer, imageName);
2007 NotificationPanel *pNotification = new NotificationPanel(*this);
2009 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2010 msg.Append(imagePath);
2011 if (pNotification != null)
2013 pNotification->SetText(msg);
2014 if (__pFooterPanel->GetShowState() == true)
2016 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2020 pNotification->SetPositionDiff(0);
2023 pNotification->ShowNotification();
2028 int __modalMsgBoxResult;
2029 MessageBox* pMsgBox = new MessageBox();
2030 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
2031 pMsgBox->ShowAndWait(__modalMsgBoxResult);
2034 __modalMsgBoxResult = 0;
2038 case IDA_SHARE_IMAGE_CLICKED:
2040 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2041 if (__pPopUp != null)
2046 __pPopUp = new(std::nothrow) SharePopup();
2047 __pPopUp->Initialize();
2048 if (__pHitElementResult != null)
2050 const Bitmap* pSaveBitmap = null;
2051 String imageName = GetImagePath();
2052 AppLog("Content manager image name %ls",imageName.GetPointer());
2055 imagePath.Append(imageName);
2056 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2057 AppLog("Content manager image path %ls",imagePath.GetPointer());
2058 if (__pHitElementResult != null)
2060 pSaveBitmap = __pHitElementResult->GetImage();
2062 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2064 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2065 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2067 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2068 pShareInfo->SetPageTitle(L"");
2069 pShareInfo->SetPageUrl(srcUrl);
2070 pShareInfo->SetImageAttached(true);
2071 pShareInfo->SetImagePath(imagePath);
2072 __pPopUp->RemoveAllShareInfo();
2073 __pPopUp->AddShareInfo(pShareInfo);
2074 __pPopUp->SetShowState(true);
2079 case IDA_HYPERLINK_OPEN_CLICKED:
2081 if (__pHitElementResult != null)
2083 String srcUrl = __pHitElementResult->GetUrl();
2085 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2087 if (pNewWindowInfo == null)
2091 result r = E_SUCCESS;
2092 SceneManager* pSceneManager = SceneManager::GetInstance();
2093 if (pSceneManager == NULL)
2097 ArrayList* pArgList = new(std::nothrow) ArrayList();
2098 if (pArgList == NULL)
2102 pArgList->Construct();
2104 pArgList->Add(*pNewWindowInfo);
2105 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2106 if (pArgList != null)
2113 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2119 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2121 if (__pHitElementResult == null)
2126 if(__pPopUp != null)
2131 __pPopUp = new(std::nothrow) SharePopup();
2132 __pPopUp->Initialize();
2134 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2135 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2136 pShareInfo->SetImageAttached(false);
2137 __pPopUp->RemoveAllShareInfo();
2138 __pPopUp->AddShareInfo(pShareInfo);
2140 __pPopUp->SetShowState(true);
2144 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2148 if (__pHitElementResult != null)
2150 url = __pHitElementResult->GetUrl();
2153 String resourcePath = App::GetInstance()->GetAppResourcePath();
2154 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2156 // copying the item to clipboard
2157 Clipboard* pClipboard = Clipboard::GetInstance();
2158 if (pClipboard != null)
2160 pClipboard->CopyItem(item);
2164 case IDA_FIND_TEXT__CLICKED:
2166 // AddressBarCancelledClicked(*__pAddressbar);
2167 RelayoutControls(false);
2168 // __pFooterPanel->SetShowState(false);
2169 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2170 __currentSearchStr.Clear();
2171 __currentSearchStr.Append(__currentSelectedStr);
2172 InitFindWordPanel();
2173 __pFindWordEditField->SetText(__currentSearchStr);
2176 __pMenu->SetShowState(false);
2177 __pMenu->Invalidate(false);
2180 __adressPanelPosition.y = 0;
2182 if (__pAddressbar != null && __pWebViewer != NULL)
2184 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2185 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2187 if (__pFooterPanel->GetShowState() == false)
2188 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2190 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2191 __pWebViewer->Invalidate(true);
2194 ShowFindWordPanel(true);
2195 __pFindWordEditField->SetFocus();
2196 if (__currentSearchStr.GetLength() > 0)
2202 AppLogDebug("Enter something");
2205 if (__pWebViewer != null)
2207 // releasing the set block
2208 __pWebViewer->ReleaseBlock();
2213 case IDA_SHARE_TEXT_CLICKED:
2215 __pWebViewer->ReleaseBlock();
2216 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2217 if(__pPopUp != null)
2222 __pPopUp = new(std::nothrow) SharePopup();
2223 __pPopUp->Initialize();
2224 if (__pHitElementResult != null)
2226 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2227 pShareInfo->SetPageTitle(L"");
2228 pShareInfo->SetPageUrl(__currentSelectedStr);
2229 pShareInfo->SetImageAttached(false);
2230 __pPopUp->RemoveAllShareInfo();
2231 __pPopUp->AddShareInfo(pShareInfo);
2232 __pPopUp->SetShowState(true);
2237 case IDA_COPY_TEXT_CLICKED:
2239 __pWebViewer->ReleaseBlock();
2240 // need to implement
2241 //__currentSelectedStr
2242 // Sets data to a clip board item
2244 String resourcePath = App::GetInstance()->GetAppResourcePath();
2245 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2247 // copying the item to clipboard
2248 Clipboard* pClipboard = Clipboard::GetInstance();
2249 if (pClipboard != null)
2251 pClipboard->CopyItem(item);
2255 case IDA_PASTE_TEXT_CLICKED:
2257 Clipboard* pClipboard = Clipboard::GetInstance();
2259 if(pClipboard == null)
2263 // Retrieves a latest item
2264 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2270 //Gets data from the clipboard item
2271 String* pString = dynamic_cast<String*>(pItem->GetData());
2273 if (pString != null)
2275 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2276 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2277 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2280 if(idElement.GetLength() != 0)
2282 script = L"function insertAtCursor(myField, myValue) { if (document.selection) { document.getElementById(myField).focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (document.getElementById(myField).selectionStart || document.getElementById(myField).selectionStart == '0'){ var startPos = document.getElementById(myField).selectionStart; var endPos = document.getElementById(myField).selectionEnd; document.getElementById(myField).value = document.getElementById(myField).value.substring(0, startPos)+ myValue + document.getElementById(myField).value.substring(endPos, document.getElementById(myField).value.length); } else { document.getElementById(myField).value += myValue; } } ";
2283 script.Append("insertAtCursor('");
2284 script.Append(idElement);
2285 script.Append("',");
2286 script.Append("\"");
2287 script.Append(*pString);
2288 script.Append("\");");
2290 else if (nameElement.GetLength() != 0)
2292 script = L"function insertAtCursor(myField, myValue) { if (document.selection) { document.getElementByName(myField)[0].focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0'){ var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length); } else { document.getElementByName(myField)[0].value += myValue; } } ";
2293 script.Append("insertAtCursor(document.getElementsByName('");
2294 script.Append(nameElement);
2295 script.Append("')[0],");
2296 script.Append("\"");
2297 script.Append(*pString);
2298 script.Append("\");");
2300 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2301 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2312 case IDA_GO_FORWARD:
2317 case IDA_REFRESH_BTN_CLICKED:
2319 __isLoadingCompleted = false;
2320 __isLoadingData = true;
2321 __progressPercentage = 0;
2322 __displayUrl = __pFooterUrlField->GetText();
2324 String url = __pFooterUrlField->GetText();
2325 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2327 __pWebViewer->Reload();
2328 if (__pAddressbar != null)
2330 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2331 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2335 UpdateProgressBitmap();
2338 case IDA_STOP_BTN_CLICKED:
2340 __isLoadingCompleted = false;
2341 __isLoadingData = false;
2342 __progressPercentage = 0;
2343 __pFooterUrlField->HideKeypad();
2344 __displayUrl = __pFooterUrlField->GetText();
2348 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2349 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2350 __pWebViewer->StopLoading();
2351 RequestRedraw(true);
2354 UpdateProgressBitmap();
2359 if (__pFooterUrlField->GetText().IsEmpty() == false)
2361 //__displayUrl = __pUrlField->GetText();
2362 __pFooterUrlField->Clear();
2367 case IDA_READER_BTN_CLICKED:
2378 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2381 UiApp* pApp = UiApp::GetInstance();
2390 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2391 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2393 AppLog("MainForm::OnSceneActivatedN called");
2394 String* pSelectedScene = NULL;
2395 Object* pValue = NULL;
2396 String* pUrl = null;
2397 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2398 pSelectedScene = (String*) pValue;
2400 if (pSelectedScene != null)
2402 delete pSelectedScene;
2404 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2405 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2406 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2407 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2409 // setting the current scene ID
2410 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2412 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2414 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2416 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2417 if(__pWindowInfo == null)
2419 // if(__pWindowInfo == null)
2421 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2424 else if ( pArgs != null && pArgs->GetCount() == 1)
2426 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2432 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2434 // hiding the address bar
2435 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2436 __pAddressbar->SetShowState(false);
2437 // if(__pWebViewer != null)
2439 // __pWebViewer->Resume();
2442 if(pUrl != null && pUrl->GetLength() > 0)
2446 else if(__pWindowInfo != null)
2448 if(__pWindowInfo->pageUrl.GetLength() > 0 &&previousSceneId != IDSCN_BRIGHTNESS && previousSceneId != IDSCN_HISTORY_LIST && previousSceneId != IDSCN_MULTIPLE_WINDOW && previousSceneId != IDSCN_MULTIPLE_WINDOW_GRID && previousSceneId != IDSCN_BOOKMARK_VIEW && previousSceneId != IDSCN_SETTINGS && previousSceneId != IDSCN_MAIN_VIEW)
2450 LoadUrl(__pWindowInfo->pageUrl);
2452 else if (__pWindowInfo->isJavascriptInitiated == true)
2456 __pWindowInfo->pCurrentWeb = __pWebViewer;
2460 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2461 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2462 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2464 InitMostVisitedSitesView(GetOrientationStatus());
2466 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2468 if(__pMostVisitedListView != null)
2470 __pMostVisitedListView->SetShowState(false);
2474 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2476 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2478 if (pBookmarkUrl == null)
2480 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2481 //__pAddressbar->SetUrl(*pBookmarkUrl);
2482 SetUrl(*pBookmarkUrl);
2484 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2485 __pWebViewer->LoadUrl(*pBookmarkUrl);
2486 delete pBookmarkUrl;
2489 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2490 Bitmap* pBitmap = null;
2491 if (isPrivateBrowsing == true)
2493 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2495 if (__pWebViewer != null)
2497 __pWebViewer->SetPrivateBrowsingEnabled(true);
2500 if (__pAddressbar != null)
2502 // __pAddressbar->UpdateFaviconBitmap(true);
2508 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2510 if (__pWebViewer != null)
2512 __pWebViewer->SetPrivateBrowsingEnabled(false);
2515 if (__pAddressbar != null)
2517 // __pAddressbar->UpdateFaviconBitmap(false);
2521 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2523 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2525 else if (__pMenu != null )
2527 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2530 if (pBitmap != null)
2535 AppLog("ABC: OnSceneActivatedN started exit");
2540 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2541 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2543 Canvas* pWebCanvas = null;
2544 if (__pWebViewer != null)
2546 pWebCanvas = __pWebViewer->GetCanvasN();
2549 if (pWebCanvas == null)
2553 if (__pWindowInfo != null)
2555 if (__pWindowInfo->pWebCanvasBitmap != null)
2557 delete __pWindowInfo->pWebCanvasBitmap;
2559 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2560 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2561 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2563 Bitmap* pBitmap = GetCapturedBitmapN();
2564 AppLog("Coming here");
2565 Canvas* pCanvas = new(std::nothrow) Canvas();
2566 pCanvas->Construct(GetClientAreaBounds());
2569 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2572 if(__pWebViewer != null && __pWindowInfo != null)
2573 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2575 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2576 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2578 AppLog("Coming here");
2582 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2583 const Tizen::Base::String& realm,
2584 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2590 MainForm::OnHttpAuthenticationCanceled(void)
2595 MainForm::OnLoadingStarted(void)
2597 AppLogDebug("MainForm::OnLoadingStarted entered");
2599 if(__pAddressbar == NULL || __pWebViewer == null)
2603 // this is added in case if menu is opened and user load the page
2604 if(__pMenu != null && __pMenu->GetShowState() == true)
2606 __pMenu->SetShowState(false);
2607 __pMenu->Invalidate(true);
2609 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2611 __pImageMenu->SetShowState(false);
2612 __pImageMenu->Invalidate(true);
2614 String url = __pWebViewer->GetUrl();
2615 if(url.Contains(IDS_TIZEN_SERVICE))
2618 String delim(L":;");
2620 // Creates a StringTokenizer instance
2621 StringTokenizer strTok(url, delim);
2623 int count = strTok.GetTokenCount(); // count == 4
2625 HashMap *pMap = new HashMap();
2630 while (strTok.HasMoreTokens())
2632 AppLog("Token: %ls", token.GetPointer());
2633 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2634 if(token.Contains(IDS_APPID))
2636 token.SubString(6, appId);
2637 AppLog("AppID:%ls", appId.GetPointer());
2639 else if(token.Contains("="))
2641 String *pKey = new String();
2642 String *pValue = new String();
2644 token.IndexOf("=", 0, index);
2647 token.SubString(0, index, *pKey);
2648 token.SubString(index + 1, *pValue);
2649 pMap->Add(pKey, pValue);
2655 AppControl *pAppControl = null;
2656 String operationId = L"http://tizen.org/appcontrol/operation/main";
2657 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2660 AppLog("Starting AppControl");
2661 result r = pAppControl->Start(null, null, pMap, null);
2662 AppLog("Result of Start %s", GetErrorMessage(r));
2666 AppLogException("AppControl not found");
2671 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
2673 __pAddressbar->SetShowState(false);
2674 AddressBarCancelledClicked(*__pAddressbar);
2675 __pAddressbar->Invalidate(true);
2677 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2680 __pAddressbar->SetFaviconBitmap(*pBitmap);
2683 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2685 // updating the address bar position with respect to web control
2686 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2687 __distanceMoved = 0;
2691 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2692 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2693 if (__pWebViewer != null)
2695 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2696 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2697 SetUrl(__pWebViewer->GetUrl());
2698 if (__pWindowInfo != NULL)
2700 // resetting the page title to blank, it will be received in OnPageTitleReceived()
2701 __pWindowInfo->pageTitle = L"";
2702 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2704 __pAddressbar->Invalidate(true);
2710 MainForm::OnLoadingCanceled(void)
2717 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2719 AppLog("XYZ::MainForm::OnKeypadWillOpen");
2724 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2726 AppLog("XYZ::MainForm::OnKeypadOpened");
2727 __pFooterPanel->SetShowState(false);
2732 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2734 AppLog("XYZ::MainForm::OnKeypadClosed");
2735 __pFooterPanel->SetShowState(true);
2736 RelayoutControls(true);
2740 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2742 AppLog("KeypadBoundsChanged");
2743 RelayoutControls(false);
2747 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2748 const Tizen::Base::String& reason)
2750 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2754 MainForm::OnLoadingCompleted(void)
2756 AppLog("MainForm::OnLoadingCompleted start");
2758 result r = E_SUCCESS;
2760 if (__pWebViewer == null)
2765 if (__pAddressbar == null)
2769 if (__pWebViewer->CanGoForward())
2771 //__pAddressbar->SetForwardButtonEnabled(true);
2772 SetForwardButtonEnabled(true);
2776 //__pAddressbar->SetForwardButtonEnabled(false);
2777 SetForwardButtonEnabled(false);
2780 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2782 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2784 //__pAddressbar->UpdateProgress(0);
2788 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2790 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2794 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2795 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2796 if (isPrivateBrowsing == false)
2798 if(__pHistory != null)
2804 __pHistory = new(std::nothrow) History;
2805 HistoryPresentationModel::GetCurrentDateTime(date);
2808 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2809 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2811 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2812 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2814 __pHistory->SetVisitedTime(date);
2816 if (__pWebViewer != null)
2818 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2820 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2821 if (pTempBitmap != null)
2823 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2824 __pHistory->SetFavIconBitmap(*pTempBitmap);
2827 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2830 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2831 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2832 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2834 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2835 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2836 __pHistory->SetThumbnail(pBitmap);
2838 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2841 __pHistory->SetFavIconBitmap(*pFavIcon);
2845 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
2852 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2854 // temperary fixed (webpage can be not loaded)
2858 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
2859 if (isReaderEnabled == true)
2863 delete __pReaderData;
2864 __pReaderData = null;
2866 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
2867 filePath.Append(L"data/reader.js");
2873 result r = E_SUCCESS;
2874 FileAttributes attr;
2876 File::GetAttributes(filePath,attr);
2878 r = file.Construct(filePath, L"r+");
2881 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
2884 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
2887 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
2890 // file.Read(pScript,attr.GetFileSize());
2892 // AppLogDebug("scipt length %d",strlen(pScript));
2893 String strScript = L"";
2894 // strScript.Append(pScript);
2895 // for(int i=0; i<25; i++)
2897 file.Read(pScript,attr.GetFileSize());
2898 // AppLog("xyzz tell %d",file.Tell());
2899 // r = strScript.Append(pScript);
2900 // AppLog("xyzz append result %s",GetErrorMessage(r));
2901 // AppLog("xyzz strScript length %d",strScript.GetLength());
2903 // AppLog("xyzz final strScript length %d",strScript.GetLength());
2905 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
2906 if (__pReaderData == null)
2908 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
2909 __pReaderData = new String(L"<meta name=\"viewport\" content=\"width=0, initial-scale=1.0, maximum-scale=2.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=medium-dpi\"> <h1>Chinese PM Li Keqiang vows to open up markets to India</h1><div><span class=\"arttle\"><h1>Chinese PM Li Keqiang vows to open up markets to India</h1></span></div>");
2912 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
2913 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
2915 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
2916 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
2922 AppLog("MainForm::OnLoadingCompleted done");
2926 MainForm::OnEstimatedProgress(int progress)
2928 AppLogDebug("MainForm::OnEstimatedProgress entered");
2929 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2930 progress = DEFAULT_PROGRESS_PERCENTAGE;
2932 // __pAddressbar->UpdateProgress(progress);
2933 UpdateProgress(progress);
2936 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2938 AppLog("MainForm::OnFaviconReceived");
2939 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
2941 Bitmap* favIcon = __pWebViewer->GetFaviconN();
2944 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
2951 MainForm::OnUrlValueChanged(Addressbar&)
2957 MainForm::OnUrlSubmitted(Addressbar& addBar)
2959 AppLog("MainForm::OnUrlSubmitted");
2960 String url = addBar.GetUrl();
2961 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2963 if(__pFooterUrlField)
2964 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
2965 AddressBarCancelledClicked(*__pAddressbar);
2970 MainForm::LoadUrl(String& url)
2974 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2975 AppLogDebug("MainForm::LoadUrl enter");
2977 if (__pWebViewer != null)
2979 __pWebViewer->SetShowState(true);
2980 __pWebViewer->Invalidate(true);
2983 if (url.CompareTo(L"") == 0)
2987 if(__pFooterPanel != null)
2989 __pFooterPanel->SetShowState(true);
2990 __pFooterPanel->Invalidate(true);
2997 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2998 String secondPattern(L"^[A-Za-z0-9\.\+-:#@%/;$~?]+\\.[A-Za-z0-9!\+-=:#@%/;$~()_?\\\.&]{2,}$"); // URL of type abc.com (i.e without protocol in front of it)
3000 RegularExpression firstRegex;
3001 RegularExpression secondRegex;
3003 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3004 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3007 ret = firstRegex.Match(url, false); // This returns true value
3008 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3010 if (ret == true && __pWebViewer != null)
3013 __pWebViewer->LoadUrl(url);
3015 else if(__pWebViewer != null)
3017 String tempUrl = L"http://";
3018 tempUrl.Append(url);
3022 __pWebViewer->LoadUrl(tempUrl);
3026 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3027 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3030 if (__pAddressbar != null)
3032 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3033 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3036 AppLogDebug("MainForm::LoadUrl exit");
3043 MainForm::OnStopClicked(Addressbar& addBar)
3045 AppLogDebug("MainForm::OnStopClicked called");
3048 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3049 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3050 __pWebViewer->StopLoading();
3051 RequestRedraw(true);
3056 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3058 // AppLog("MainForm::OnBackClicked");
3059 result r = E_FAILURE;
3061 if (__pWebViewer && __pWebViewer->CanGoBack())
3063 __pWebViewer->GoBack();
3065 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3068 pApp = UiApp::GetInstance();
3071 r = pApp->Terminate();
3074 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3082 WindowInfo* pWindowInfo = null;
3084 SceneManager* pSceneManager = SceneManager::GetInstance();
3085 if (pSceneManager == null)
3089 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3090 if (pAllWindowList == NULL)
3092 pApp = UiApp::GetInstance();
3095 r = pApp->Terminate();
3098 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3103 if (pAllWindowList != null)
3105 totalCount = pAllWindowList->GetCount();
3107 for (int count = 0; count < totalCount; count++)
3109 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3110 if (pWindowInfo == null)
3112 pApp = UiApp::GetInstance();
3115 r = pApp->Terminate();
3118 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3123 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3125 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3128 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3131 r = pAllWindowList->RemoveAt(count, true);
3132 __pWindowInfo = null;
3135 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3140 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3144 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3146 if (pWindowInfo == null)
3148 pApp = UiApp::GetInstance();
3151 r = pApp->Terminate();
3157 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3160 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3174 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3176 AppLog("MainForm::OnForwardClicked");
3177 if (__pWebViewer == null)
3180 if (__pWebViewer->CanGoForward())
3182 __pWebViewer->GoForward();
3187 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3189 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3190 if(__pFooterPanel != null)
3192 __pFooterPanel->SetShowState(false);
3195 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3197 __pAddressbar->SetShowState(true);
3198 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3201 RelayoutControls(false);
3205 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3207 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3209 int Height = GetClientAreaBounds().height;
3210 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3213 // __pAddressbar->SetShowState(false);
3215 if (__pFooterPanel != null && addressbarKeyPadState == false)
3217 AppLog("akjshdasd 3");
3218 __pFooterPanel->SetShowState(true);
3221 RelayoutControls(false);
3225 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3227 AddressBarCancelledClicked(addBar);
3231 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3233 __prevAddressBarMode = __curAddressBarMode;
3235 if (__pAddressbar != null)
3237 __curAddressBarMode = GetAddressbarMode();
3240 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3242 __adressPanelPosition.y = 0;
3243 if (__pAddressbar != null)
3245 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3246 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3247 __pAddressbar->Invalidate(true);
3249 if (__pWebViewer != null)
3251 __pWebViewer->StopLoading();
3254 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3256 __adressPanelPosition.y = 0;
3257 if (__pAddressbar != null)
3259 __webControlPosition.y = 0;
3260 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3261 __pAddressbar->Invalidate(true);
3267 MainForm::OnClipboardClosed(const Addressbar& addBar)
3269 RelayoutControls(false);
3273 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3275 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3277 AppLog("akjshdasd 3");
3278 __pFooterPanel->SetShowState(true);
3281 RelayoutControls(false,footerState);
3285 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3287 RelayoutControls(false);
3291 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3293 __pFooterPanel->SetShowState(false);
3297 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3299 AppLog("KeypadBoundsChanged");
3300 RelayoutControls(false);
3304 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3306 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3309 __pWindowInfo->pageTitle = title;
3310 if (__pWebViewer != null)
3312 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3315 if (__pAddressbar != null && __pWebViewer != null)
3317 SetUrl(__pWebViewer->GetUrl());
3318 __pAddressbar->Invalidate(true);
3323 MainForm::UpdateFavicon(void)
3325 bool urlImageType = false;
3326 String *tempPath = null;
3328 tempPath = __pWebViewer->EvaluateJavascriptN(L"var getFavicon = function() { var favicon = '/favicon.ico'; var nodeList = document.getElementsByTagName('link'); if(nodeList) { for (var i = 0; i < nodeList.length; i++) { if ((nodeList[i].getAttribute('rel') == 'icon')||(nodeList[i].getAttribute('rel') == 'shortcut icon')) { favicon = nodeList[i].getAttribute('href'); } } } return favicon; }; getFavicon();");
3329 Bitmap* pBitmap = null;
3331 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3333 if (__pWindowInfo != null)
3336 url.SetUri(*tempPath);
3337 if (url.GetHost().GetLength() == 0)
3340 webUrl.SetUri(__pWebViewer->GetUrl());
3341 result r = url.SetHost(webUrl.GetHost());
3348 if (url.GetScheme().GetLength() == 0)
3351 webUrl.SetUri(__pWebViewer->GetUrl());
3352 url.SetScheme(webUrl.GetScheme());
3354 __pWindowInfo->faviconUrl = url.ToString();
3356 pBitmap = __pWebViewer->GetFaviconN();
3358 if (pBitmap != null)
3360 if (__pWindowInfo->pFavicon != NULL)
3362 __pWindowInfo->pFavicon = null;
3364 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3365 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3367 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3369 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3371 else if(__pWindowInfo->pFavicon != null)
3373 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3377 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3378 if(pDefaultBmp != null)
3380 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3389 if(tempPath != null)
3393 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3400 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3401 Tizen::Web::Controls::WebNavigationType type)
3403 // when load new page if find word panel is open its show state is false
3404 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3406 __currentSearchStr = L"";
3407 __currentWordIndex = 0;
3408 __maxOccurrances = 0;
3409 __pFindWordEditField->SetText(L"");
3410 __pFindWordNext->SetEnabled(false);
3411 __pFindWordPrev->SetEnabled(false);
3412 __pFindWordCountLabel->SetText(L"0/0");
3413 __pFindWordControl->SetShowState(false);
3414 __pFindWordEditField->HideKeypad();
3415 RelayoutControls(false);
3420 __pFooterPanel->Invalidate(true);
3423 uriInfo.SetUri(url);
3425 if(url.Contains(IDS_TIZEN_SERVICE))
3428 String delim(L":;,");
3430 // Creates a StringTokenizer instance
3431 StringTokenizer strTok(url, delim);
3433 int count = strTok.GetTokenCount(); // count == 4
3435 HashMap *pMap = new HashMap();
3441 while (strTok.HasMoreTokens())
3443 AppLog("Token: %ls", token.GetPointer());
3444 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3445 if(token.Contains(IDS_APPID))
3447 token.SubString(6, appId);
3448 AppLog("AppID:%ls", appId.GetPointer());
3450 else if(token.Contains("="))
3452 String *pKey = new String();
3453 String *pValue = new String();
3455 token.IndexOf("=", 0, index);
3458 token.SubString(0, index, *pKey);
3459 token.SubString(index + 1, *pValue);
3460 pMap->Add(pKey, pValue);
3466 AppControl *pAppControl = null;
3467 String operationId = L"http://tizen.org/appcontrol/operation/main";
3468 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3471 result r = pAppControl->Start(null, null, pMap, null);
3475 AppLogException("AppControl not found");
3485 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3486 const Tizen::Net::Http::HttpHeader& httpHeader)
3488 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3493 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3495 AppLog("MainForm::OnWebPageBlockSelected");
3496 if (__pHitElementResult != null)
3498 delete __pHitElementResult;
3499 __pHitElementResult = null;
3502 if (__pWebViewer != null)
3504 AppLog("MainForm::OnWebPageBlockSelected web not null");
3505 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3507 if(GetLastResult() == E_INVALID_ARG)
3509 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
3510 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3511 if(GetLastResult() == E_INVALID_ARG)
3513 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
3515 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
3519 if (__pHitElementResult == null)
3524 if (__pHitElementResult->HasImage() != true)
3526 String tagName = __pHitElementResult->GetTagName();
3527 String type = __pHitElementResult->GetAttributeValue("type");
3530 __currentSelectedStr.Clear();
3531 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3532 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3533 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3535 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
3537 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3539 InitSelectTextContextMenu(endPoint,true);
3540 __pImageMenu->SetShowState(true);
3541 __pImageMenu->Show();
3542 __pImageMenu->Invalidate(true);
3544 else /*if(__isLongPressedDone == true)*/
3546 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3548 if(__pHitElementResult->GetUrl().GetLength() > 0)
3550 __currentSelectedStr.Clear();
3551 __currentSelectedStr = __pHitElementResult->GetUrl();
3553 InitSelectTextContextMenu(endPoint,false);
3554 __pImageMenu->SetShowState(true);
3555 __pImageMenu->Show();
3556 __pImageMenu->Invalidate(true);
3559 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3560 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3561 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3567 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3573 MainForm::OnWebWindowCreateRequested(void)
3575 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
3577 if (pNewWindowInfo == null)
3581 result r = E_SUCCESS;
3582 SceneManager* pSceneManager = SceneManager::GetInstance();
3583 if (pSceneManager == NULL)
3587 ArrayList* pArgList = new(std::nothrow) ArrayList();
3588 if (pArgList == NULL)
3592 r = pArgList->Construct();
3595 pNewWindowInfo->isJavascriptInitiated = true;
3596 pArgList->Add(*pNewWindowInfo);
3597 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3601 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3608 return pNewWindowInfo->pCurrentWeb;
3612 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
3614 __webControlPosition.y = 0;
3615 __webControlHeight = GetClientAreaBounds().height;
3616 AppLog("Client area height: %d", __webControlHeight);
3618 AppLog("Client area height: %d", __webControlHeight);
3619 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3621 __webControlPosition.y += __pAddressbar->GetHeight();
3622 __webControlHeight -= __pAddressbar->GetHeight();
3623 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3625 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3627 __webControlPosition.y += __pFindWordControl->GetHeight();
3628 __webControlHeight -= __pFindWordControl->GetHeight();
3629 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3632 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
3634 __webControlHeight -= __pFooterPanel->GetHeight();
3636 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3638 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3640 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12);
3641 __pWebViewer->Invalidate(false);
3643 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3645 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3652 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3654 if (__pFindWordControl == null)
3659 Tizen::Locales::LocaleManager localeManager;
3660 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
3662 String languageCode;
3663 result r = SettingInfo::GetValue(L"Language", languageCode);
3664 // int languagecode = local.GetLanguageCode();
3665 AppLog("rahul language is %S", languageCode.GetPointer());
3669 InitFindWordPanel();
3671 if (languageCode.CompareTo("ara") == 0)
3673 AppLog("rahul language is arabic");
3675 __pFindWordPanelLeftToRight->SetShowState(false);
3676 __pFindWordPanelRightToLeft->SetShowState(true);
3678 __pFindWordClear->SetShowState(false);
3679 __pFindWordCountLabel->SetShowState(false);
3680 __pFindWordEditField->SetShowState(false);
3682 __pFindWordClearRightToLeft->SetShowState(true);
3683 __pFindWordCountLabelRightToLeft->SetShowState(true);
3684 __pFindWordEditFieldRightToLeft->SetShowState(true);
3688 AppLog("rahul language is not arabic");
3691 __pFindWordPanelLeftToRight->SetShowState(true);
3692 __pFindWordPanelRightToLeft->SetShowState(false);
3694 __pFindWordClear->SetShowState(true);
3695 __pFindWordCountLabel->SetShowState(true);
3696 __pFindWordEditField->SetShowState(true);
3698 __pFindWordClearRightToLeft->SetShowState(false);
3699 __pFindWordCountLabelRightToLeft->SetShowState(false);
3700 __pFindWordEditFieldRightToLeft->SetShowState(false);
3702 __pFindWordControl->SetShowState(true);
3706 if(__pFindWordControl != null)
3708 __pFindWordControl->SetShowState(false);
3712 AppLog("MainForm::ShowFindWordPanel %d",show);
3713 if (show && !isTouchPressed)
3715 if (languageCode.CompareTo("ara") == 0)
3717 if (__pFindWordEditFieldRightToLeft)
3719 __pFindWordEditFieldRightToLeft->SetFocus();
3720 __pFindWordEditFieldRightToLeft->ShowKeypad();
3725 if (__pFindWordEditField)
3727 __pFindWordEditField->SetFocus();
3728 __pFindWordEditField->ShowKeypad();
3734 if (languageCode.CompareTo("ara") == 0)
3736 if (__pFindWordEditFieldRightToLeft)
3737 __pFindWordEditFieldRightToLeft->HideKeypad();
3741 if (__pFindWordEditField)
3742 __pFindWordEditField->HideKeypad();
3746 RelayoutControls(false);
3750 MainForm::StartWordSearch()
3752 //Get the count of occurances of the word in the current page
3753 __maxOccurrances = 0;
3754 __currentWordIndex = 0;
3756 __pFindWordPrev->SetEnabled(false);
3757 String *pCountStr = null;
3758 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3759 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3760 if (pCountStr != null)
3762 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3766 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3771 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3773 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3774 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3776 if(totalCount == -1 || totalCount == 0)
3778 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
3779 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3782 else if(totalCount > 100)
3784 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3785 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3789 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3790 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3793 __maxOccurrances = totalCount;
3794 __currentWordIndex = currentOrdinal;
3796 //Reset the UI controls as per the maxOccurrance value
3797 if (totalCount <= 0)
3799 AppLog("Word not found");
3800 //Show error notification to user
3801 __pFindWordNext->SetEnabled(false);
3802 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
3804 __pFindWordCountLabel->SetText(L"0/0");
3805 __pFindWordCountLabel->Invalidate(false);
3807 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
3809 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
3810 __pFindWordCountLabelRightToLeft->Invalidate(false);
3812 __pFindWordNext->Invalidate(false);
3813 __pFindWordPrev->Invalidate(false);
3818 if (totalCount == 1)
3820 __pFindWordNext->SetEnabled(false);
3824 __pFindWordNext->SetEnabled(true);
3827 String countStr = L"";
3828 countStr.Append(__currentWordIndex);
3829 countStr.Append(L"/");
3830 countStr.Append(__maxOccurrances);
3831 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
3833 __pFindWordCountLabel->SetText(countStr);
3834 __pFindWordCountLabel->Invalidate(false);
3835 __pFindWordCountLabel->Invalidate(false);
3837 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
3839 __pFindWordCountLabelRightToLeft->SetText(countStr);
3840 __pFindWordCountLabelRightToLeft->Invalidate(false);
3841 __pFindWordCountLabelRightToLeft->Invalidate(false);
3843 //FindNextWord(true);
3844 //Update the controls
3845 __pFindWordNext->Invalidate(false);
3846 __pFindWordPrev->Invalidate(false);
3851 MainForm::FindNextWord(bool next)
3855 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3856 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
3858 if (__currentWordIndex < __maxOccurrances)
3860 __currentWordIndex++;
3866 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3867 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
3869 if(__currentWordIndex > 1)
3871 __currentWordIndex--;
3876 String countStr = L"";
3877 countStr.Append(__currentWordIndex);
3878 countStr.Append(L"/");
3879 countStr.Append(__maxOccurrances);
3881 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
3883 __pFindWordCountLabel->SetText(countStr);
3884 __pFindWordCountLabel->Invalidate(false);
3886 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
3888 __pFindWordCountLabelRightToLeft->SetText(countStr);
3889 __pFindWordCountLabelRightToLeft->Invalidate(false);
3892 if (__currentWordIndex >= __maxOccurrances)
3894 __pFindWordNext->SetEnabled(false);
3898 __pFindWordNext->SetEnabled(true);
3900 if (__currentWordIndex <= 1)
3902 __pFindWordPrev->SetEnabled(false);
3906 __pFindWordPrev->SetEnabled(true);
3908 __pFindWordPrev->Invalidate(false);
3909 __pFindWordNext->Invalidate(false);
3911 __pFindWordControl->Invalidate(true);
3915 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3917 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
3918 __isWebKeypadOpened = true;
3919 __pFooterPanel->SetShowState(false);
3920 // OnAddressBarKeypadOpened(*__pAddressbar);
3924 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3926 AppLog("xyz::MainForm::OnWebKeypadOpened");
3928 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3930 __currentSearchStr = L"";
3931 __currentWordIndex = 0;
3932 __maxOccurrances = 0;
3933 __pFindWordEditField->SetText(L"");
3934 __pFindWordNext->SetEnabled(false);
3935 __pFindWordPrev->SetEnabled(false);
3936 __pFindWordCountLabel->SetText(L"0/0");
3937 __pWebViewer->SearchTextAllAsync(L"",false);
3938 __pFindWordControl->SetShowState(false);
3939 __pFindWordEditField->HideKeypad();
3943 if (__pWebViewer != null && __pFooterPanel != null)
3945 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3946 if(__pAddressbar != null)
3948 __pAddressbar->SetShowState(false);
3950 if(__pFindWordControl != null)
3952 __pFindWordControl->SetShowState(false);
3954 __pFooterPanel->SetShowState(false);
3955 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
3957 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
3959 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
3960 // AppLog("omgomgomg");
3966 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3968 AppLog("xyz::MainForm::OnWebKeypadClosed");
3969 AppLog("akjshdasd 4");
3970 __pFooterPanel->SetShowState(true);
3971 // OnAddressBarKeypadClosed(*__pAddressbar);
3972 RelayoutControls(false);
3973 __isWebKeypadOpened = false;
3977 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
3979 // RelativeLayout(false);
3983 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3985 Control* temp = const_cast< Control* >(&source);
3986 Header* pHeader = dynamic_cast< Header* >(temp);
3987 if (pHeader != null)
3989 //Header double - clicked
3990 AppLog("Header double clicked");
3992 if(__pFindWordControl)
3994 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
3995 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
3999 AppLog("MainScene::OnTouchDoublePressed");
4003 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4005 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4006 __longPressPoint = currentPosition;
4008 if (__pHitElementResult != null)
4010 delete __pHitElementResult;
4011 __pHitElementResult = null;
4014 if (__pWebViewer != null)
4016 AppLog("MainForm::OnTouchLongPressed web not null");
4017 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4020 if (__pHitElementResult == null)
4025 if (__pHitElementResult->HasImage() == true)
4027 InitImageContextMenu(currentPosition);
4028 __pImageMenu->SetShowState(true);
4029 __pImageMenu->Show();
4030 __pImageMenu->Invalidate(true);
4032 else if(__pHitElementResult->HasUrl() == true)
4034 String tempURl = __pHitElementResult->GetUrl();
4035 AppLog("tempURl is %ls", tempURl.GetPointer());
4036 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4037 if (pBitmap != null)
4045 InitImageLinkContextMenu(currentPosition);
4046 __pImageMenu->SetShowState(true);
4047 __pImageMenu->Show();
4048 __pImageMenu->Invalidate(true);
4052 String tagName = __pHitElementResult->GetTagName();
4053 String type = __pHitElementResult->GetAttributeValue("type");
4054 String value = __pHitElementResult->GetAttributeValue(L"value");
4055 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4057 __currentSelectedStr.Clear();
4058 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4060 AppLog("tag name is %ls", tagName.GetPointer());
4061 AppLog("type is %ls", type.GetPointer());
4065 //__isLongPressedDone = true;
4066 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4067 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && innerHtml.GetLength() == 0 /*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.CompareTo(L"") == 0 && r == E_INVALID_ARG)
4069 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4071 InitSelectTextContextMenu(currentPosition,true, true);
4074 __pImageMenu->SetShowState(true);
4075 __pImageMenu->Show();
4076 __pImageMenu->Invalidate(true);
4079 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4082 // __inputEventToBeSupressed = true;
4086 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4088 AppLog("MainForm::OnTouchReleased");
4091 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4092 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4094 __pWebViewer->ConsumeInputEvent();
4096 if(pHitElement != null)
4100 __inputEventToBeSupressed = false;*/
4104 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4111 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4113 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4115 __currentSearchStr = L"";
4116 __currentWordIndex = 0;
4117 __maxOccurrances = 0;
4119 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4121 __pFindWordEditField->SetText(L"");
4122 __pFindWordEditField->HideKeypad();
4123 __pFindWordControl->SetShowState(false);
4124 __pFindWordCountLabel->SetText(L"0/0");
4126 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4128 __pFindWordEditFieldRightToLeft->SetText(L"");
4129 __pFindWordEditFieldRightToLeft->HideKeypad();
4130 __pFindWordControl->SetShowState(false);
4131 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4134 __pFindWordNext->SetEnabled(false);
4135 __pFindWordPrev->SetEnabled(false);
4137 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
4138 __pFindWordControl->SetShowState(false);
4140 if(__pAddressbar->GetShowState() == false)
4142 __pAddressbar->SetAddressbarURLFocus();
4143 __pFooterPanel->SetShowState(false);
4150 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4156 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4162 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4168 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4174 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4180 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4182 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4183 int widthContextItem = 0;
4185 // As per the platform engineer comment removed this line
4186 /*if(__pWebViewer != null)
4188 // this is added because if any text is selected on long press followed by on rotation we are hiding the context menu therefore we should release the text block also
4189 __pWebViewer->ReleaseBlock();
4192 if(__pFindWordControl != null)
4193 ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4194 if ( __pFooterLabel != null)
4196 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4199 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4205 if (__pFindWordBgLabel != null)
4207 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4208 if (pBitmap != null)
4210 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4215 if (__pFindWordBgLabelRightToLeft != null)
4217 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4218 if (pBitmap != null)
4220 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4226 __pMenu->SetShowState(false);
4227 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4229 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4233 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4238 AppLog("__pFooterPanel->GetShowState() is true");
4240 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4241 __pFooterPanel->Invalidate(true);
4245 if(__pMoreButton && __pMenu)
4247 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
4248 __pMenu->SetAnchorPosition(p);
4249 __pMenu->Invalidate(true);
4252 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4253 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4255 InitMostVisitedSitesView(orientationStatus);
4258 RelayoutControls(false);
4259 if (__pArticleReaderPanel != null)
4261 if (__pArticleReaderPanel->GetShowState() == true)
4263 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4265 if (__pBlankPanel != null)
4266 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4268 if (__pWebReader != null)
4270 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4272 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4273 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4275 if ( pBitmap != null && pSrcBitmap != null)
4277 AppLog("CreateReaderPanel ninepatchbitmap found");
4278 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4281 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4282 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4283 if (pBitmap != null)
4288 if (pSrcBitmap != null)
4297 if (__pAddressbar != null)
4299 int width = GetClientAreaBounds().width;
4300 __pAddressbar->OrientationChanged(width);
4305 MainForm::OnSettingsChange(int settingvalue)
4307 AppLogDebug("MainForm::OnSettingsChange entered");
4309 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4311 __pAddressbar->ResetGuideText();
4313 if (__pWebViewer == null)
4315 AppLogDebug("Webviewer is not initialized yet.");
4319 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4321 WebSetting settings = __pWebViewer->GetSetting();
4322 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4324 settings.SetAutoFittingEnabled(true);
4326 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
4328 settings.SetAutoFittingEnabled(false);
4330 __pWebViewer->SetSetting(settings);
4332 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4334 WebSetting settings = __pWebViewer->GetSetting();
4335 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4336 __pWebViewer->SetSetting(settings);
4338 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4340 WebSetting settings = __pWebViewer->GetSetting();
4341 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4342 __pWebViewer->SetSetting(settings);
4343 __pWebViewer->Reload();
4345 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4347 WebSetting settings = __pWebViewer->GetSetting();
4348 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4349 __pWebViewer->SetSetting(settings);
4351 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4355 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4358 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
4362 WebSetting settings = __pWebViewer->GetSetting();
4363 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
4364 __pWebViewer->SetSetting(settings);
4367 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
4371 WebSetting settings = __pWebViewer->GetSetting();
4372 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
4373 __pWebViewer->SetSetting(settings);
4376 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4378 WebSetting settings = __pWebViewer->GetSetting();
4379 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4381 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4385 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4387 __pWebViewer->SetSetting(settings);
4389 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4393 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4394 WebSetting settings = __pWebReader->GetSetting();
4395 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4396 __pWebReader->SetSetting(settings);
4402 MainForm::OnSettingsReset()
4406 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4407 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4412 MainForm::OnClearCache()
4414 result r = E_SUCCESS;
4416 if (__pWebViewer != NULL)
4418 r = __pWebViewer->ClearCache();
4421 AppLogDebug("Cache cleared success");
4425 AppLogDebug("Cache cleared fail");
4431 MainForm::OnClearCookie()
4433 result r = E_SUCCESS;
4435 if (__pWebViewer != NULL)
4437 __pWebViewer->ClearCookie();
4441 AppLogDebug("Cookie cleared success");
4445 AppLogDebug("Cache cleared fail");
4450 MainForm::OnClearFormData()
4452 result r = E_SUCCESS;
4454 if (__pWebViewer != NULL)
4456 __pWebViewer->ClearFormData();
4460 AppLogDebug("Cookie cleared success");
4464 AppLogDebug("Cache cleared fail");
4469 MainForm::OnClearPasswords()
4471 result r = E_SUCCESS;
4473 if (__pWebViewer != NULL)
4475 __pWebViewer->ClearLoginFormData();
4479 AppLogDebug("Cookie cleared success");
4483 AppLogDebug("Cache cleared fail");
4489 MainForm::findDistance(int x1,int y1,int x2, int y2)
4491 int deltaX = Math::Abs(x2 - x1);
4492 int deltaY = Math::Abs(y2 - y1);
4493 double num = deltaX*deltaX + deltaY*deltaY;
4499 for (i = 0; i < 20; i++)
4501 x = (((x*x)+ num)/(2*x));
4512 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4514 if(__pFindWordControl)
4516 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4517 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4519 //__isLongPressedDone = false;
4521 __pAddressbar->SetShowState(false);
4524 IList* pList = null;
4525 pList = touch.GetTouchInfoListN(source);
4529 int count = pList->GetCount();
4532 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4533 __touchPoint1 = pTouchInfo->position;
4535 /*if (__pAddressbar != null)
4537 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4539 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4541 __pAddressbar->SaveAddressbarEditText();
4543 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4546 __pAddressbar->Invalidate(true);
4548 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4550 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4552 //__pAddressbar->SaveAddressbarEditText();
4554 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4557 else if (count == 2)
4559 AppLogDebug("MainForm::OnTouchPressed count is two");
4560 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4561 __touchPoint1 = pTouchInfo->position;
4563 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4564 __touchPoint2 = pTouchInfo->position;
4570 pList->RemoveAll(true);
4577 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4579 // __currentWordIndex = 0;
4580 //__isLongPressedDone = false;
4585 MainForm::MoveUiControls()
4590 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4592 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4594 if(__pFooterUrlField->GetTextLength() == 0)
4596 __pFooterUrlField->SetKeypadActionEnabled(false);
4600 __pFooterUrlField->SetKeypadActionEnabled(true);
4603 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
4605 __currentSearchStr = __pFindWordEditField->GetText();
4606 if (__currentSearchStr.GetLength() > 0)
4608 __pFindWordCountLabel->SetShowState(true);
4612 __pFindWordCountLabel->SetShowState(false);
4614 __pFindWordNext->SetEnabled(false);
4615 __pFindWordPrev->SetEnabled(false);
4616 __pFindWordNext->Invalidate(true);
4617 __pFindWordPrev->Invalidate(true);
4618 __pFindWordCountLabel->SetText(L"0/0");
4619 __pFindWordCountLabel->Invalidate(true);
4621 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
4623 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
4624 if (__currentSearchStr.GetLength() > 0)
4626 __pFindWordCountLabelRightToLeft->SetShowState(true);
4630 __pFindWordCountLabelRightToLeft->SetShowState(false);
4633 __pFindWordNext->SetEnabled(false);
4634 __pFindWordPrev->SetEnabled(false);
4635 __pFindWordNext->Invalidate(true);
4636 __pFindWordPrev->Invalidate(true);
4637 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4638 __pFindWordCountLabelRightToLeft->Invalidate(true);
4640 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4641 if (__currentSearchStr.GetLength() > 0)
4647 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4649 __currentSearchStr = L"";
4650 AppLogDebug("Enter something");
4655 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4662 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4664 if(__pWebViewer != null)
4667 AppLog("MainForm::InitMostVisitedSitesView");
4668 result r = E_SUCCESS;
4671 if (__pWebViewer != null && __pMostVisitedListView != null)
4676 if (__pMostVisitedListView != null)
4678 RemoveControl(__pMostVisitedListView);
4680 if(__pMostVisitedSites != null)
4682 __pMostVisitedSites->RemoveAll(true);
4685 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4687 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4688 __pMostVisitedListView = new(std::nothrow) ListView();
4690 int height = GetClientAreaBounds().height;
4692 if(__pFooterPanel->GetShowState() == true)
4694 height = height - __pFooterPanel->GetHeight();
4696 if(__pAddressbar->GetShowState() == true)
4698 height -= __pAddressbar->GetHeight();
4701 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4705 delete __pMostVisitedListView;
4706 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4709 __pMostVisitedListView->SetItemProvider(*this);
4710 __pMostVisitedListView->AddListViewItemEventListener(*this);
4711 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4712 AddControl(__pMostVisitedListView);
4713 __pMostVisitedListView->UpdateList();
4720 MainForm::GetImagePath(void)
4724 String formattedTime;
4725 DateTime currentTime;
4726 LocaleManager localManager;
4727 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4729 localManager.Construct();
4730 Locale locale = localManager.GetSystemLocale();
4731 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4733 // Get date formatter
4734 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4738 pTimeFormatter->Format(currentTime, formattedTime);
4741 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4742 String delim(L" :");
4743 StringTokenizer strTok(formattedTime, delim);
4746 String str1("GMT+00");
4747 while (strTok.HasMoreTokens())
4749 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4750 if(token.Equals(str1))
4752 AppLog("token is %ls", token.GetPointer());
4753 imageName.Append(token);
4759 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4761 result r = E_FAILURE;
4762 AppLog("Content manager 1");
4763 ContentId contentId;
4764 ContentManager contentManager;
4765 r = contentManager.Construct();
4768 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4771 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4772 Tizen::Io::Directory::Create(contentPath,true);
4773 if(GetLastResult() == E_FILE_ALREADY_EXIST)
4775 AppLog("Already exists");
4777 else if(GetLastResult() == E_SUCCESS)
4779 AppLog("created success");
4781 contentPath.Append(imageName);
4782 contentPath.Append(".jpg");
4783 contentId = contentManager.CreateContent(*aBuffer, contentPath);
4784 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
4788 MainForm::SetForwardButtonEnabled(bool isEnabled)
4790 __pGoForwardBtn->SetEnabled(isEnabled);
4791 __pGoForwardBtn->Invalidate(true);
4795 MainForm::SetBackButtonEnabled(bool isEnabled)
4797 __pGoBackBtn->SetEnabled(isEnabled);
4798 __pGoBackBtn->Invalidate(true);
4802 MainForm::UpdateProgress(int percentage)
4804 __progressPercentage = percentage;
4805 if (percentage == 0 || percentage == 100)
4807 __isLoadingData = false;
4808 if (percentage == 100)
4810 __isLoadingCompleted = true;
4811 __progressPercentage = 0;
4815 __isLoadingCompleted = false;
4820 __isLoadingData = true;
4822 UpdateProgressBitmap();
4826 MainForm::GetProgress(void)
4828 return __progressPercentage;
4832 MainForm::UpdateProgressBitmap(void)
4834 result r = E_SUCCESS;
4835 if (__pProgressbarLabel == null)
4837 int w = __pProgressbarLabel->GetWidth();
4838 int h = __pProgressbarLabel->GetHeight();
4840 int progressWidth = 0;
4841 Bitmap* pRetBitmap = null;
4843 if (__progressPercentage == 0 || __progressPercentage == 100)
4845 __pProgressbarLabel->SetShowState(false);
4846 __pProgressbarLabel->Invalidate(false);
4851 __pProgressbarLabel->SetShowState(true);
4852 __pProgressbarLabel->Invalidate(false);
4855 r = canvas.Construct(Rectangle(0, 0, w, h));
4859 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
4864 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
4868 pBgBmp->Scale(Dimension(w, h));
4869 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4873 progressWidth = (double) (w) * __progressPercentage / 100;
4874 AppLogDebug("progressWidth: %d", progressWidth);
4875 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4877 if (pProgressBmp != null)
4879 pProgressBmp->Scale(Dimension(progressWidth, h));
4880 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4881 delete pProgressBmp;
4884 pRetBitmap = new (std::nothrow) Bitmap();
4886 if (pRetBitmap == null)
4888 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4892 pRetBitmap->Construct(canvas, canvas.GetBounds());
4894 if (__pProgressbarLabel != null && pRetBitmap != null)
4896 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4897 __pProgressbarLabel->Invalidate(false);
4900 if (pRetBitmap != null)
4909 MainForm::ReaderClicked()
4911 result r = E_SUCCESS;
4912 ArrayList* pArgList = new(std::nothrow) ArrayList();
4913 if (pArgList != null)
4915 r = pArgList->Construct();
4922 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
4929 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
4936 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
4944 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4948 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
4950 CreateReaderPanel();
4951 AppLogDebug("MainScene::ReaderClicked entered");
4954 /*if (__pArticleReaderPanel)
4956 AppLogDebug("showstate true for reader panel");
4957 __pArticleReaderPanel->SetShowState(true);
4958 __pArticleReaderPanel->Show();
4960 int xPos = __pArticleReaderPanel->GetX();
4961 int yPos = __pArticleReaderPanel->GetY();
4962 AppLog("ReaderClicked() xPos = %d",xPos);
4963 AppLog("ReaderClicked() yPos = %d",yPos);
4965 if (__pReaderData == null)
4970 String loadData = L"<html>\
4972 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
4977 background-color: transparent;\
4996 <body style='width:'";
4997 loadData.Append(bodyWidth);
4998 loadData.Append(L"px'>");
4999 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
5000 loadData.Append(*__pReaderData);
5001 loadData.Append(L"</body></html>");
5004 buf.Construct(loadData.GetLength());
5005 AppLogDebug("data->GetLength %d",loadData.GetLength());
5006 for (int z=0;z<loadData.GetLength();z++)
5009 loadData.GetCharAt(z,b);
5010 buf.SetByte((byte)b);
5014 if (__pWebReader != null)
5016 __pWebReader->LoadData(L"",buf,L"text/html");
5017 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
5021 AppLogDebug("cannot LoadData __pWebReader is null");
5026 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5028 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5030 __currentAddMode = addMode;
5034 case ADDRESSBAR_MODE_INVALID:
5039 case ADDRESSBAR_MODE_READER:
5041 __pStopBtn->SetShowState(false);
5042 __pRefreshBtn->SetShowState(false);
5043 __pClearBtn->SetShowState(false);
5044 __pReaderBtn->SetShowState(false);
5047 case ADDRESSBAR_MODE_LOADING:
5049 __pRefreshBtn->SetShowState(false);
5050 __pStopBtn->SetShowState(true);
5051 __pClearBtn->SetShowState(false);
5052 __pReaderBtn->SetShowState(false);
5055 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5057 // SetUrl(__pAddressbar->GetUrl());
5059 __pRefreshBtn->SetShowState(true);
5060 __pStopBtn->SetShowState(false);
5061 __pClearBtn->SetShowState(false);
5062 __pReaderBtn->SetShowState(false);
5065 case ADDRESSBAR_MODE_EDIT:
5067 __pRefreshBtn->SetShowState(false);
5068 __pStopBtn->SetShowState(false);
5069 __pReaderBtn->SetShowState(false);
5070 __pClearBtn->SetShowState(true);
5077 OnAddressBarModeChanged();
5080 AddressBarMode MainForm::GetAddressbarMode(void)
5082 return __currentAddMode;
5085 void MainForm::SetUrl(const String& url)
5088 if(__displayUrl.GetLength() > 2048)
5089 __displayUrl.SubString(0,2048,__displayUrl);
5091 if (__pFooterUrlField != NULL)
5093 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5094 if (removedHttpUrl.IsEmpty() == false)
5096 __pFooterUrlField->SetText(removedHttpUrl);
5097 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5098 __pAddressbar->SetUrl(__displayUrl);
5102 __pFooterUrlField->SetText(__displayUrl);
5103 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5104 __pAddressbar->SetUrl(__displayUrl);
5106 if(__pFooterUrlField)
5107 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5108 __pFooterUrlField->Invalidate(false);
5109 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5110 __pAddressbar->Invalidate(true);
5111 // __pFooterUrlField->SetCursorPosition(0);
5116 MainForm::RemoveHttpTextFromDisplayURL(void)
5118 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5120 // bool isHttpText = __displayUrl.Contains(L"http://");
5121 String updatedDisplayUrl;
5122 updatedDisplayUrl.Clear();
5123 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5125 __displayUrl.SubString(7,updatedDisplayUrl);
5127 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5129 __displayUrl.SubString(8,updatedDisplayUrl);
5131 return updatedDisplayUrl;
5134 void MainForm::OnSharePopupControlStarted(void)
5136 __pWebViewer->AddTouchEventListener(*this);
5139 void MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5141 if (requestId == BACK_GROUND_APP_EVENT)
5143 if(__pWebViewer != null)
5145 __pWebViewer->Pause();
5148 else if(requestId == FORE_GROUND_APP_EVENT)
5150 if(__pWebViewer != null)
5152 __pWebViewer->Resume();
5158 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5160 result r = E_SUCCESS;
5163 __pAddressbar->SetShowState(false);
5165 //AppLog("akjshdasd 5");
5166 //__pFooterPanel->SetShowState(true);
5169 __pWebViewer->SetFocus();
5170 else if(__pMostVisitedListView)
5171 __pMostVisitedListView->SetFocus();
5172 else if(__pMultiWindowButton)
5173 __pMultiWindowButton->SetFocus();
5174 __pMoreButton->SetFocus();
5176 __pAddressbar->SetShowState(false);
5178 RelayoutControls(false);