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;
213 MainForm::~MainForm(void)
215 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
219 __pAddressbar->SetAddressbarEventListener(null);
222 if(__pHistory != null)
228 if (__pReaderData != null)
230 delete __pReaderData;
231 __pReaderData = null;
234 if (__pPopUp != null)
240 if (__pHitElementResult != null)
242 delete __pHitElementResult;
243 __pHitElementResult = null;
246 String* pSelectedScene = NULL;
247 Object* pValue = NULL;
248 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
249 pSelectedScene = (String*) pValue;
251 /*if (pSelectedScene != null)
253 delete pSelectedScene;
255 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
259 MainForm::Initialize(void)
261 Construct(L"IDL_FORM");
266 MainForm::OnInitializing(void)
268 AppLog("get client area width = %d",GetClientAreaBounds().width);
269 AppLog("get client area height = %d",GetClientAreaBounds().height);
270 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
271 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
273 Panel* pFooterPanel = null;
275 __pSaveImage = new Image();
276 __pSaveImage->Construct();
278 // Setup back event listener
279 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
280 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
281 AddOrientationEventListener(*this);
282 AppLogDebug(" MainForm::OnInitializing ended");
283 if (__pMostVisitedSites == null)
285 __pMostVisitedSites = new(std::nothrow) ArrayList();
286 __pMostVisitedSites->Construct();
288 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
290 __pItemContext= new(std::nothrow) ListContextItem();
291 __pItemContext->Construct();
292 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
293 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
295 if (pBitmapNormal != null && pBitmapPressed != null)
297 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
300 if (pBitmapNormal != null)
302 delete pBitmapNormal;
305 if (pBitmapPressed != null)
307 delete pBitmapPressed;
310 __pItemContextLandscape= new(std::nothrow) ListContextItem();
311 __pItemContextLandscape->Construct();
312 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
313 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
315 if (pBitmapNormal != null && pBitmapPressed != null)
317 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
320 if (pBitmapNormal != null)
322 delete pBitmapNormal;
325 if (pBitmapPressed != null)
327 delete pBitmapPressed;
334 MainForm::InitAddressbar(void)
336 AppLogDebug("MainForm::InitAddressbar entered");
338 result r = E_SUCCESS;
340 if (__pAddressbar != null)
344 __pAddressbar = new(std::nothrow) Addressbar();
345 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
346 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
349 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
352 __pAddressbar->SetAddressbarEventListener(this);
353 AddControl(__pAddressbar);
354 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
355 SetControlAlwaysOnTop(*__pAddressbar, true);
356 __adressPanelPosition = __pAddressbar->GetPosition();
358 AppLogDebug("MainForm::InitAddressbar exit");
364 MainForm::CreateReaderPanel(void)
366 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
367 result r = E_FAILURE;
369 Button *pSmallFontBtn = null;
370 Button *pLargeFontBtn = null;
372 __pBlankPanel = new (std::nothrow) Panel();
373 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
375 __pArticleReaderPanel = new (std::nothrow) Panel();
376 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
378 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
379 if (__pReaderCloseBtn)
381 AppLogDebug("CreateReaderPanel() 6");
382 __pReaderCloseBtn->AddActionEventListener(*this);
383 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
386 __pWebReader = new (std::nothrow) Web();
387 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
389 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
390 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
392 r = __pWebReader->SetSetting(settings);
394 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
397 __pArticleReaderLabel = new Label();
398 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
400 __pBlankPanel->AddControl(__pArticleReaderLabel);
401 __pBlankPanel->AddControl(__pArticleReaderPanel);
402 AddControl(__pBlankPanel);
404 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
405 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
406 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
408 __pArticleReaderPanel->AddControl(__pWebReader);
409 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
410 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
411 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
413 if (pBitmap != null && pSrcBitmap != null)
415 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
417 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
419 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
422 pSmallFontBtn->AddActionEventListener(*this);
423 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
426 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
429 pLargeFontBtn->AddActionEventListener(*this);
430 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
439 if (pSrcBitmap != null)
445 SetControlAlwaysOnTop(*__pBlankPanel, true);
446 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
453 MainForm::InitWebControl()
455 AppLogDebug("MainForm::InitWebControl enter");
456 result r = E_SUCCESS;
457 AppLogDebug("InitWebControl");
459 if (__pAddressbar == null || __pFooterPanel == null)
462 const int Y_WEBCONTROL_POSITION = 0;
463 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
464 if (__pMostVisitedListView)
466 __pMostVisitedListView->SetShowState(false);
468 if (__pWebViewer != null)
470 AppLogDebug("Already initialized");
473 __pWebViewer = new(std::nothrow) Web();
474 if(__pWebViewer == NULL)
476 AppLogDebug("Initialization failed");
479 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
483 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
490 r = AddControl(__pWebViewer);
496 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
499 __webControlPosition = __pWebViewer->GetPosition();
500 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
503 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
507 __pWebViewer->SetLoadingListener(this);
508 __pWebViewer->SetWebUiEventListener(this);
509 __pWebViewer->SetWebKeypadEventListener(this);
510 __pWebViewer->SetFocus();
511 __pWebViewer->AddTouchEventListener(*this);
513 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
514 __pWebViewer->SetTextSearchListener(this);
517 AppLogDebug("MainForm :before return");
519 AppLogDebug("MainForm::InitWebControl Exit");
525 MainForm::OnFocusGained(const Control& source)
527 AppLog("MainForm::OnFocusGained");
531 MainForm::OnFocusLost(const Control& source)
533 AppLog("MainForm::OnFocusLost");
537 MainForm::SetJavascriptEnabled()
539 WebSetting settings = __pWebViewer->GetSetting();
540 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
541 __pWebViewer->SetSetting(settings);
545 MainForm::SetImageLoadEnabled()
547 WebSetting settings = __pWebViewer->GetSetting();
548 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
549 __pWebViewer->SetSetting(settings);
553 MainForm::InitFooter(void)
555 AppLogDebug("MainForm::InitFooter entered");
556 Button* pBackButton = null;
557 Button* pBookmarkButton = null;
558 Button* pMultiWindowButton = null;
559 Bitmap *pIconBitmap = null;
560 Bitmap *pBGBitmap = null;
561 Label *pBGLabel = null;
563 if (__pFooterPanel == null)
565 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
568 if (__pFooterPanel == null)
573 SetControlAlwaysOnTop(*__pFooterPanel, true);
575 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
576 if ( __pFooterLabel == NULL )
580 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
581 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
584 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
588 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
590 if ( __pMultiWindowButton == NULL )
595 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
597 if ( __pMoreButton == NULL )
602 if (__pMultiWindowButton != null)
604 Bitmap* pBitmap = null;
605 Bitmap* pPressedBitmap = null;
606 String imagePath = "I01_toolbar_icon_windows_manager_0";
607 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
608 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
609 imagePath.Append(totalCount);
610 imagePath.Append(".png");
612 pressedImagePath.Append(totalCount);
613 pressedImagePath.Append("_press.png");
615 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
616 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
617 if ( pBitmap == null )
622 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
625 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
626 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
631 __pMultiWindowButton->AddActionEventListener(*this);
632 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
637 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
638 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
641 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
642 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
643 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
647 __pMoreButton->AddActionEventListener(*this);
648 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
651 //Add the editfield for url
652 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
653 if (__pFooterUrlField == NULL)
655 return E_INVALID_KEY;
658 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
659 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
660 __pFooterUrlField->AddKeypadEventListener(*this);
661 __pFooterUrlField->SetPropagatedTouchEventListener(this);
663 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
665 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
667 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
669 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
673 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
674 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
678 //Add the go Back Button
679 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
680 if (__pGoBackBtn == NULL)
682 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
683 return E_INVALID_KEY;
685 __pGoBackBtn->SetActionId(IDA_GO_BACK);
686 __pGoBackBtn->AddActionEventListener(*this);
688 //Add the go forward Button
689 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
690 if (__pGoForwardBtn == NULL)
692 AppLogDebug("Control not found returning E_INVALID_KEY");
693 return E_INVALID_KEY;
695 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
696 __pGoForwardBtn->AddActionEventListener(*this);
697 if (__pWebViewer && __pWebViewer->CanGoForward())
699 SetForwardButtonEnabled(true);
703 SetForwardButtonEnabled(false);
706 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
707 if (__pRefreshBtn == NULL)
709 AppLogDebug("Control not found returning E_INVALID_KEY");
710 return E_INVALID_KEY;
713 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
714 __pRefreshBtn->AddActionEventListener(*this);
715 __pRefreshBtn->SetShowState(true);
717 //Add the backround label for displaying progressbar
718 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
719 if (__pProgressbarLabel == NULL)
721 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
722 return E_INVALID_KEY;
724 __pProgressbarLabel->SetShowState(false);
726 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
727 if (__pStopBtn == NULL)
729 AppLogDebug("Control not found returning E_INVALID_KEY");
730 return E_INVALID_KEY;
732 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
733 __pStopBtn->AddActionEventListener(*this);
734 __pStopBtn->SetShowState(false);
736 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
737 if (__pClearBtn == NULL)
739 AppLogDebug("Control not found returning E_INVALID_KEY");
740 return E_INVALID_KEY;
742 __pClearBtn->SetActionId(IDA_CLEAR_URL);
743 __pClearBtn->AddActionEventListener(*this);
744 __pClearBtn->SetShowState(false);
746 __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
747 if (__pReaderBtn == NULL)
749 AppLogDebug("Control not found returning E_INVALID_KEY");
750 return E_INVALID_KEY;
752 __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
753 __pReaderBtn->AddActionEventListener(*this);
754 __pReaderBtn->SetShowState(false);
756 // __pFooterPanel->Invalidate(true);
757 AppLogDebug("MainForm::InitFooter exit");
763 MainForm::InitContextMenu(Point& p)
765 result r = E_SUCCESS;
766 bool isPrivateBrowsing = false;
767 Bitmap* pBitmap = null;
771 __pMenu->SetAnchorPosition(p);
772 __pMenu->Invalidate(true);
776 __pMenu = new(std::nothrow) ContextMenu();
777 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
778 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
780 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
783 if (isPrivateBrowsing == true)
785 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
789 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
792 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
794 if ( pBitmap != NULL)
796 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
799 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
800 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
801 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
804 __pMenu->SetMaxVisibleItemsCount(6);
805 __pMenu->SetShowState(false);
806 __pMenu->AddActionEventListener(*this);
807 SetControlAlwaysOnTop(*__pMenu, true);
813 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
815 result r = E_SUCCESS;
816 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
818 AppLog("MainForm::InitImageContextMenu clicked on image");
819 if (__pImageMenu != null)
825 __pImageMenu = new (std::nothrow) ContextMenu();
826 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
827 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
829 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
830 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
831 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
832 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
833 __pImageMenu->SetMaxVisibleItemsCount(4);
834 __pImageMenu->AddActionEventListener(*this);
835 SetControlAlwaysOnTop(*__pImageMenu, true);
841 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
843 result r = E_SUCCESS;
844 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
846 AppLog("MainForm::InitImageContextMenu clicked on image");
847 if (__pImageMenu != null)
853 if(__pAddressbar->GetShowState() == true)
854 p.y = p.y + __pAddressbar->GetHeight();
856 __pImageMenu = new (std::nothrow) ContextMenu();
857 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
858 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
860 r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED);
861 r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,IDA_HYPERLINK_COPY_LINK_CLICKED);
862 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
863 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
865 __pImageMenu->SetMaxVisibleItemsCount(3);
866 __pImageMenu->AddActionEventListener(*this);
867 SetControlAlwaysOnTop(*__pImageMenu, true);
874 MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
876 result r = E_SUCCESS;
877 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
879 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
880 if (__pImageMenu != null)
889 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
893 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
895 __pImageMenu = new (std::nothrow) ContextMenu();
896 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
897 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
899 if(onlyPasteOption == false)
901 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
903 if (pasteOption || onlyPasteOption)
905 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
907 if(onlyPasteOption == false)
909 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
910 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
913 __pImageMenu->SetMaxVisibleItemsCount(3);
914 __pImageMenu->AddActionEventListener(*this);
915 SetControlAlwaysOnTop(*__pImageMenu, true);
922 MainForm::InitFindWordPanel(void)
924 result r = E_SUCCESS;
925 Bitmap *pIconBitmap = null;
927 if (__pFindWordControl != null)
929 AppLogDebug("Findword panel already initialized");
930 if (__pFindWordBgLabel != null)
932 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
935 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
939 if (__pFindWordBgLabelRightToLeft != null)
941 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
944 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
951 __pFindWordControl = new (std::nothrow) Panel();
952 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
955 AppLogException("There is some problem in the xml file. Please check.");
958 AddControl(__pFindWordControl);
959 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
960 SetControlAlwaysOnTop(*__pFindWordControl,true);
961 __pFindWordControl->SetShowState(false);
962 __pFindWordControl->Invalidate(false);
964 __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
965 __pFindWordPanelLeftToRight->SetShowState(true);
967 __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
968 __pFindWordPanelRightToLeft->SetShowState(false);
970 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
971 if (__pFindWordBgLabel != null)
973 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
974 Rectangle pRect = pPanel1->GetBounds();
975 pRect.x = pRect.y = 0;
976 __pFindWordBgLabel->SetBounds(pRect);
977 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
980 AppLogDebug("InitFindWordPanel: Coming here");
981 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
986 AppLogDebug("InitFindWordPanel: shouldn't Come here");
990 __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
991 if (__pFindWordBgLabelRightToLeft != null)
993 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
994 Rectangle pRect = pPanel1->GetBounds();
995 pRect.x = pRect.y = 0;
996 __pFindWordBgLabelRightToLeft->SetBounds(pRect);
997 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1000 AppLogDebug("InitFindWordPanel: Coming here");
1001 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1006 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1010 Button* pfindWordCancel = null;
1011 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1012 if (pfindWordCancel == null)
1014 AppLogException("There is some problem in the xml file. Please check.");
1017 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1018 pfindWordCancel->AddActionEventListener(*this);
1020 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1021 if (__pFindWordClear == null)
1023 AppLogException("There is some problem in the xml file. Please check.");
1027 __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1028 if (__pFindWordClearRightToLeft == null)
1030 AppLogException("There is some problem in the xml file. Please check.");
1034 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1035 __pFindWordClear->AddActionEventListener(*this);
1037 __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1038 __pFindWordClearRightToLeft->AddActionEventListener(*this);
1040 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1041 if (__pFindWordNext == null)
1043 AppLogException("There is some problem in the xml file. Please check.");
1047 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1048 __pFindWordNext->AddActionEventListener(*this);
1050 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1051 if (__pFindWordPrev == null)
1053 AppLogException("There is some problem in the xml file. Please check.");
1057 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1058 __pFindWordPrev->AddActionEventListener(*this);
1060 __pFindWordNext->SetEnabled(false);
1061 __pFindWordPrev->SetEnabled(false);
1063 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1064 if (__pFindWordCountLabel == null)
1066 AppLogException("There is some problem in the xml file. Please check.");
1070 __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1071 if (__pFindWordCountLabel == null)
1073 AppLogException("There is some problem in the xml file. Please check.");
1077 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1078 if (__pFindWordEditField == null)
1080 AppLogException("There is some problem in the xml file. Please check.");
1083 __pFindWordEditField->AddTextEventListener(*this);
1084 __pFindWordEditField->AddKeypadEventListener(*this);
1085 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1087 __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1088 if (__pFindWordEditFieldRightToLeft == null)
1090 AppLogException("There is some problem in the xml file. Please check.");
1093 __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1094 __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1095 __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1101 MainForm::CreateItem (int index, int itemWidth)
1103 Rectangle listImageRect;
1104 Rectangle pagetTitleRect;
1105 Rectangle pageURLRect;
1106 Rectangle deleteImageRect;
1107 String pageTitle(L"");
1108 String pageURL(L"");
1109 result r = E_SUCCESS;
1110 Bitmap* pListIconImage = null;
1113 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1114 if(pHistory == null)
1118 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1119 if ( pAppResource == NULL )
1123 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1125 CustomItem* pItem = new(std::nothrow) CustomItem();
1126 pageTitle = pHistory->GetHistoryTitle();
1127 pageURL = pHistory->GetHistoryUrl();
1129 if (pageURL.GetLength() == 0)
1132 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1133 pageURL = L"<"+ nourl +">";
1137 Rectangle screenBounds = GetBounds();
1140 r = pItem->Construct(Dimension(itemWidth, 128), style);
1149 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1151 if ( pBitmap != NULL)
1153 pListIconImage = new Bitmap();
1154 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1158 if(pListIconImage == null)
1160 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1163 if ( pListIconImage != NULL)
1165 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1166 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1167 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1170 if (pItem != null && pListIconImage != NULL)
1172 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1176 if (pageTitle.CompareTo(L"") != 0)
1180 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1184 if (pageURL.CompareTo(L"") != 0)
1188 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1193 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1195 if ( __pItemContext!= NULL)
1199 pItem->SetContextItem(__pItemContext);
1205 if ( __pItemContextLandscape!= NULL)
1209 pItem->SetContextItem(__pItemContextLandscape);
1213 if( pListIconImage != NULL)
1215 delete pListIconImage;
1216 pListIconImage = null;
1223 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1230 MainForm::GetItemCount (void)
1232 if(__pMostVisitedSites != null)
1234 __pMostVisitedSites->RemoveAll(true);
1236 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1237 if(__pMostVisitedSites != null)
1239 return __pMostVisitedSites->GetCount();
1246 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1248 if(__pMostVisitedSites != null)
1250 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1251 if (pHistory != null)
1253 String url = pHistory->GetHistoryUrl();
1255 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1256 __pMostVisitedListView->UpdateList();
1262 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1264 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1265 String url = pHistory->GetHistoryUrl();
1273 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1279 MainForm::OnTerminating(void)
1281 result r = E_SUCCESS;
1283 RemoveOrientationEventListener(*this);
1287 __pAddressbar->SetAddressbarEventListener(null);
1292 __pWebViewer->RemoveTouchEventListener(*this);
1297 delete __pItemContext;
1299 if(__pItemContextLandscape)
1301 delete __pItemContextLandscape;
1307 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1309 result r = E_SUCCESS;
1311 AppLogDebug("Clicked : %d", actionId);
1314 case IDA_BACKBTN_CLICKED:
1316 if (__pWebViewer && __pWebViewer->CanGoBack())
1318 __pWebViewer->GoBack();
1320 else if(__pWindowInfo->isJavascriptInitiated == false)
1323 pApp = UiApp::GetInstance();
1326 r = pApp->Terminate();
1329 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1337 WindowInfo* pWindowInfo = null;
1339 SceneManager* pSceneManager = SceneManager::GetInstance();
1340 if (pSceneManager == null)
1344 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1345 if (pAllWindowList == NULL)
1347 pApp = UiApp::GetInstance();
1350 r = pApp->Terminate();
1353 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1358 if (pAllWindowList != null)
1360 totalCount = pAllWindowList->GetCount();
1362 for (int count = 0; count < totalCount; count++)
1364 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1365 if (pWindowInfo == null)
1367 pApp = UiApp::GetInstance();
1370 r = pApp->Terminate();
1373 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1380 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1382 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1385 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1388 r = pAllWindowList->RemoveAt(count, true);
1389 __pWindowInfo = null;
1392 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1397 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1401 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1403 if (pWindowInfo == null)
1405 pApp = UiApp::GetInstance();
1408 r = pApp->Terminate();
1414 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1417 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1429 case IDA_FORWARD_CLICKED:
1430 if (__pWebViewer == null)
1433 if (__pWebViewer->CanGoForward())
1435 __pWebViewer->GoForward();
1437 __pMenu->SetShowState(false);
1438 __pMenu->Invalidate(false);
1441 case IDA_FINDONPAGE_CLICKED:
1443 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1444 __currentSearchStr.Clear();
1446 InitFindWordPanel();
1447 __pMenu->SetShowState(false);
1448 __pMenu->Invalidate(false);
1450 ShowFindWordPanel(true);
1452 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1454 __pFindWordEditField->SetFocus();
1455 __pFindWordCountLabel->SetShowState(false);
1459 __pFindWordEditFieldRightToLeft->SetFocus();
1460 __pFindWordCountLabelRightToLeft->SetShowState(false);
1464 case IDA_PRIVATEON_CLICKED:
1466 result r = E_SUCCESS;
1468 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1469 Bitmap* pBitmap = null;
1470 if (isPrivateBrowsing == true)
1472 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1475 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1479 if (__pWebViewer != NULL)
1481 __pWebViewer->SetPrivateBrowsingEnabled(false);
1484 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1486 if (__pAddressbar != null)
1488 __pAddressbar->UpdateFaviconBitmap(false);
1494 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1497 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1501 if (__pWebViewer != NULL)
1503 __pWebViewer->SetPrivateBrowsingEnabled(true);
1506 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1508 if (__pAddressbar != null)
1510 __pAddressbar->UpdateFaviconBitmap(true);
1515 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1516 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1517 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1518 __pMenu->Invalidate(true);
1520 if ( pBitmap != NULL )
1527 case IDA_SETTINGS_CLICKED:
1530 ArrayList* pArgList = new(std::nothrow) ArrayList();
1533 pArgList->Construct();
1534 pArgList->Add(*__pWindowInfo);
1535 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1537 __pMenu->SetShowState(false);
1538 __pMenu->Invalidate(false);
1539 if (pArgList != null)
1548 case IDA_ADDTOBOOKMARK_CLICKED:
1551 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1553 int bookmarkCount=0;
1556 url=__pWindowInfo->pageUrl;
1557 result r = E_SUCCESS;
1558 Bitmap* pBitmap = null;
1559 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1567 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1568 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1569 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1571 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1572 if (pNotification != null)
1574 pNotification->SetText(message);
1575 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1576 pNotification->ShowNotification();
1581 String title=__pWindowInfo->pageTitle;
1582 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1583 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1585 pBookmark->SetBookmarkTitle(title);
1586 pBookmark->SetUrl(url);
1587 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1589 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1591 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1592 pBookmark->SetFaviconId(id);
1593 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1594 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1597 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1598 if (pNotification != null)
1600 pNotification->SetText(message);
1601 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1602 pNotification->ShowNotification();
1603 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1606 if (pBitmap != null)
1608 r = __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1612 __pMenu->Invalidate(true);
1616 case IDA_PRINT_CLICKED:
1618 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//data//test.pdf");
1619 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1621 AppLog("RequestPrint called!");
1622 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1623 result nResult = E_FAILURE;
1626 AppLog("TestPrint if (pAc) == true");
1631 String fileType = L"service_print_files_type";
1632 String typeVal = L"DOC";
1634 String fileCount = L"service_print_files_count";
1635 String countVal = L"1";
1636 String fileFolder= L"service_print_files_folder_name";
1637 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//data";
1639 map.Add(&fileCount, &countVal);
1640 map.Add(&fileFolder, &folderVal);
1641 map.Add(&fileType, &typeVal);
1643 String fileName = L"service_print_files_files_name";
1645 ArrayList fileNameList;
1646 fileNameList.Construct();
1647 String file1 = L"test.pdf";
1649 fileNameList.Add(&file1);
1650 map.Add(&fileName, &fileNameList);
1652 nResult = pAc->Start(NULL, NULL, &map, NULL);
1654 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1655 else if (nResult == E_MAX_EXCEEDED)
1656 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1657 else if (nResult == E_OBJ_NOT_FOUND)
1658 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1659 else if (nResult == E_IN_PROGRESS)
1660 AppLog("TestPrint ret == E_IN_PROGRESS");
1661 else if (nResult == E_PRIVILEGE_DENIED)
1662 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1663 else if(nResult == E_SYSTEM)
1664 AppLog("TestPrint ret == E_SYSTEM");
1670 int __modalMsgBoxResult;
1671 MessageBox* pMsgBox = new MessageBox();
1672 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1673 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1676 __modalMsgBoxResult = 0;
1680 case IDA_SHARE_CLICKED:
1682 if(__pPopUp != null)
1687 __pPopUp = new(std::nothrow) SharePopup();
1688 __pPopUp->Initialize();
1689 if (__pWindowInfo != null)
1691 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1692 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1693 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1694 pShareInfo->SetImageAttached(false);
1695 __pPopUp->RemoveAllShareInfo();
1696 __pPopUp->AddShareInfo(pShareInfo);
1698 __pPopUp->SetShowState(true);
1702 case IDA_BOOKMARKBTN_CLICKED:
1704 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1705 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1708 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1713 case IDA_MOREBTN_CLICKED:
1715 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1716 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1717 AppLog("Anchot pos: %d %d", p.x, p.y);
1719 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1721 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1722 int bookmarkCount=0;
1725 url=__pWindowInfo->pageUrl;
1726 result r = E_SUCCESS;
1727 Bitmap* pBitmap = null;
1729 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1732 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1737 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1741 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1743 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1745 if (__pMenu->GetItemCount() == 9)
1747 r = __pMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1751 r = __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1756 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1760 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1761 if (__pMenu->GetItemCount() != 9)
1763 __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1764 __pMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1765 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1766 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1767 __pMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1768 __pMenu->SetMaxVisibleItemsCount(6);
1770 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1772 AppLog(" Orientation landscape");
1773 __pMenu->SetMaxVisibleItemsCount(5);
1777 AppLog(" Orientation potrait");
1778 __pMenu->SetMaxVisibleItemsCount(6);
1781 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1784 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1785 __pMenu->SetShowState(true);
1786 __pMenu->Invalidate(true);
1790 case IDA_HISTORY_CLICKED:
1792 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1793 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1796 case IDA_SAVED_PAGES_CLICKED:
1801 case IDA_DESKTOP_VIEW_CLICKED:
1806 case IDA_SAVE_CLICKED:
1811 case IDA_MULTIWINDOWBTN_CLICKED:
1813 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1814 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1818 case IDA_NEWWINDOWBTN_CLICKED:
1820 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1822 if (pNewWindowInfo == null)
1826 result r = E_SUCCESS;
1827 SceneManager* pSceneManager = SceneManager::GetInstance();
1829 if (pSceneManager == NULL)
1833 ArrayList* pArgList = new(std::nothrow) ArrayList();
1834 if (pArgList == NULL)
1838 r = pArgList->Construct();
1841 pArgList->Add(*pNewWindowInfo);
1842 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1848 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1853 case IDA_SMALLFONT_BTN_CLICKED:
1855 WebSetting setting = __pWebReader->GetSetting();
1856 setting.SetFontSize(15);
1857 __pWebReader->SetSetting(setting);
1860 case IDA_LARGEFONT_BTN_CLICKED:
1862 WebSetting setting = __pWebReader->GetSetting();
1863 setting.SetFontSize(25);
1864 __pWebReader->SetSetting(setting);
1867 case IDA_READER_CLOSE_CLICKED:
1869 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1871 RemoveControl(__pBlankPanel);
1872 __pArticleReaderPanel = null;
1873 __pBlankPanel = null;
1874 __pArticleReaderLabel = null;
1876 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1879 case IDA_FINDWORD_CANCEL_CLICKED:
1881 __currentSearchStr = L"";
1882 __currentWordIndex = 0;
1883 __maxOccurrances = 0;
1884 __pFindWordEditField->SetText(L"");
1885 __pFindWordNext->SetEnabled(false);
1886 __pFindWordPrev->SetEnabled(false);
1887 __pFindWordCountLabel->SetText(L"0/0");
1888 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1889 AppLog("akjshdasd 1");
1890 __pFooterPanel->SetShowState(true);
1891 ShowFindWordPanel(false);
1894 case IDA_FINDWORD_SEARCH_CLICKED:
1896 __currentSearchStr = __pFindWordEditField->GetText();
1897 if (__currentSearchStr.GetLength() > 0)
1903 AppLogDebug("Enter something");
1907 case IDA_FINDWORD_CLEAR_CLICKED:
1909 __pFindWordCountLabel->SetText(L"0/0");
1910 __pFindWordEditField->SetText(L"");
1911 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1913 __currentSearchStr = L"";
1914 __pFindWordNext->SetEnabled(false);
1915 __pFindWordPrev->SetEnabled(false);
1916 __pFindWordCountLabel->SetShowState(false);
1917 __pFindWordControl->Invalidate(true);
1920 case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
1922 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
1923 __pFindWordEditFieldRightToLeft->SetText(L"");
1924 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1926 __currentSearchStr = L"";
1927 __pFindWordNext->SetEnabled(false);
1928 __pFindWordPrev->SetEnabled(false);
1929 __pFindWordCountLabelRightToLeft->SetShowState(false);
1930 __pFindWordControl->Invalidate(true);
1933 case IDA_FINDWORD_NEXT_CLICKED:
1938 case IDA_FINDWORD_PREV_CLICKED:
1940 FindNextWord(false);
1943 case IDA_BRIGHTNESS_BTN_CLICKED:
1945 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1946 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1949 case IDA_COPY_IMAGE_CLICKED:
1951 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1952 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1954 const Bitmap* pBitmap = null;
1955 if (__pHitElementResult != null)
1957 pBitmap = __pHitElementResult->GetImage();
1960 String resourcePath = App::GetInstance()->GetAppResourcePath();
1961 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1963 // copying the item to clipboard
1964 Clipboard* pClipboard = Clipboard::GetInstance();
1965 if (pClipboard != null)
1967 pClipboard->CopyItem(item);
1971 case IDA_VIEW_IMAGE_CLICKED:
1973 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1974 WindowInfo* pNewWindowInfo = null;
1975 if (__pHitElementResult != null)
1977 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1978 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1984 case IDA_SAVE_IMAGE_CLICKED:
1986 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1987 const Bitmap* pSaveBitmap = null;
1988 String imageName = GetImagePath();
1989 AppLog("Content manager image name %ls",imageName.GetPointer());
1992 imagePath.Append(imageName);
1993 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1994 AppLog("Content manager image path %ls",imagePath.GetPointer());
1995 if (__pHitElementResult != null)
1997 pSaveBitmap = __pHitElementResult->GetImage();
1999 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2003 UpdateImageContent(pBuffer, imageName);
2005 NotificationPanel *pNotification = new NotificationPanel(*this);
2007 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2008 msg.Append(imagePath);
2009 if (pNotification != null)
2011 pNotification->SetText(msg);
2012 if (__pFooterPanel->GetShowState() == true)
2014 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2018 pNotification->SetPositionDiff(0);
2021 pNotification->ShowNotification();
2026 int __modalMsgBoxResult;
2027 MessageBox* pMsgBox = new MessageBox();
2028 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
2029 pMsgBox->ShowAndWait(__modalMsgBoxResult);
2032 __modalMsgBoxResult = 0;
2036 case IDA_SHARE_IMAGE_CLICKED:
2038 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2039 if (__pPopUp != null)
2044 __pPopUp = new(std::nothrow) SharePopup();
2045 __pPopUp->Initialize();
2046 if (__pHitElementResult != null)
2048 const Bitmap* pSaveBitmap = null;
2049 String imageName = GetImagePath();
2050 AppLog("Content manager image name %ls",imageName.GetPointer());
2053 imagePath.Append(imageName);
2054 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2055 AppLog("Content manager image path %ls",imagePath.GetPointer());
2056 if (__pHitElementResult != null)
2058 pSaveBitmap = __pHitElementResult->GetImage();
2060 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2062 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2063 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2065 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2066 pShareInfo->SetPageTitle(L"");
2067 pShareInfo->SetPageUrl(srcUrl);
2068 pShareInfo->SetImageAttached(true);
2069 pShareInfo->SetImagePath(imagePath);
2070 __pPopUp->RemoveAllShareInfo();
2071 __pPopUp->AddShareInfo(pShareInfo);
2072 __pPopUp->SetShowState(true);
2077 case IDA_HYPERLINK_OPEN_CLICKED:
2079 if (__pHitElementResult != null)
2081 String srcUrl = __pHitElementResult->GetUrl();
2083 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene(srcUrl);
2085 if (pNewWindowInfo == null)
2089 result r = E_SUCCESS;
2090 SceneManager* pSceneManager = SceneManager::GetInstance();
2091 if (pSceneManager == NULL)
2095 ArrayList* pArgList = new(std::nothrow) ArrayList();
2096 if (pArgList == NULL)
2100 pArgList->Construct();
2102 pArgList->Add(*pNewWindowInfo);
2103 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2104 if (pArgList != null)
2111 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2117 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2119 if (__pHitElementResult == null)
2124 if(__pPopUp != null)
2129 __pPopUp = new(std::nothrow) SharePopup();
2130 __pPopUp->Initialize();
2132 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2133 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2134 pShareInfo->SetImageAttached(false);
2135 __pPopUp->RemoveAllShareInfo();
2136 __pPopUp->AddShareInfo(pShareInfo);
2138 __pPopUp->SetShowState(true);
2142 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2146 if (__pHitElementResult != null)
2148 url = __pHitElementResult->GetUrl();
2151 String resourcePath = App::GetInstance()->GetAppResourcePath();
2152 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2154 // copying the item to clipboard
2155 Clipboard* pClipboard = Clipboard::GetInstance();
2156 if (pClipboard != null)
2158 pClipboard->CopyItem(item);
2162 case IDA_FIND_TEXT__CLICKED:
2164 // AddressBarCancelledClicked(*__pAddressbar);
2165 RelayoutControls(false);
2166 // __pFooterPanel->SetShowState(false);
2167 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2168 __currentSearchStr.Clear();
2169 __currentSearchStr.Append(__currentSelectedStr);
2170 InitFindWordPanel();
2171 __pFindWordEditField->SetText(__currentSearchStr);
2174 __pMenu->SetShowState(false);
2175 __pMenu->Invalidate(false);
2178 __adressPanelPosition.y = 0;
2180 if (__pAddressbar != null && __pWebViewer != NULL)
2182 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2183 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2185 if (__pFooterPanel->GetShowState() == false)
2186 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2188 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2189 __pWebViewer->Invalidate(true);
2192 ShowFindWordPanel(true);
2193 __pFindWordEditField->SetFocus();
2194 if (__currentSearchStr.GetLength() > 0)
2200 AppLogDebug("Enter something");
2203 if (__pWebViewer != null)
2205 // releasing the set block
2206 __pWebViewer->ReleaseBlock();
2211 case IDA_SHARE_TEXT_CLICKED:
2213 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2214 if(__pPopUp != null)
2219 __pPopUp = new(std::nothrow) SharePopup();
2220 __pPopUp->Initialize();
2221 if (__pHitElementResult != null)
2223 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2224 pShareInfo->SetPageTitle(L"");
2225 pShareInfo->SetPageUrl(__currentSelectedStr);
2226 pShareInfo->SetImageAttached(false);
2227 __pPopUp->RemoveAllShareInfo();
2228 __pPopUp->AddShareInfo(pShareInfo);
2229 __pPopUp->SetShowState(true);
2234 case IDA_COPY_TEXT_CLICKED:
2236 __pWebViewer->ReleaseBlock();
2237 // need to implement
2238 //__currentSelectedStr
2239 // Sets data to a clip board item
2241 String resourcePath = App::GetInstance()->GetAppResourcePath();
2242 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2244 // copying the item to clipboard
2245 Clipboard* pClipboard = Clipboard::GetInstance();
2246 if (pClipboard != null)
2248 pClipboard->CopyItem(item);
2252 case IDA_PASTE_TEXT_CLICKED:
2254 Clipboard* pClipboard = Clipboard::GetInstance();
2256 if(pClipboard == null)
2260 // Retrieves a latest item
2261 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2267 //Gets data from the clipboard item
2268 String* pString = dynamic_cast<String*>(pItem->GetData());
2270 if (pString != null)
2272 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2273 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2274 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2277 if(idElement.GetLength() != 0)
2279 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; } } ";
2280 script.Append("insertAtCursor('");
2281 script.Append(idElement);
2282 script.Append("',");
2283 script.Append("\"");
2284 script.Append(*pString);
2285 script.Append("\");");
2287 else if (nameElement.GetLength() != 0)
2289 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; } } ";
2290 script.Append("insertAtCursor(document.getElementsByName('");
2291 script.Append(nameElement);
2292 script.Append("')[0],");
2293 script.Append("\"");
2294 script.Append(*pString);
2295 script.Append("\");");
2297 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2298 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2309 case IDA_GO_FORWARD:
2314 case IDA_REFRESH_BTN_CLICKED:
2316 __isLoadingCompleted = false;
2317 __isLoadingData = true;
2318 __progressPercentage = 0;
2319 __displayUrl = __pFooterUrlField->GetText();
2321 String url = __pFooterUrlField->GetText();
2322 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2326 UpdateProgressBitmap();
2329 case IDA_STOP_BTN_CLICKED:
2331 __isLoadingCompleted = false;
2332 __isLoadingData = false;
2333 __progressPercentage = 0;
2334 __pFooterUrlField->HideKeypad();
2335 __displayUrl = __pFooterUrlField->GetText();
2339 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2340 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2341 __pWebViewer->StopLoading();
2342 RequestRedraw(true);
2345 UpdateProgressBitmap();
2350 if (__pFooterUrlField->GetText().IsEmpty() == false)
2352 //__displayUrl = __pUrlField->GetText();
2353 __pFooterUrlField->Clear();
2358 case IDA_READER_BTN_CLICKED:
2369 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2372 UiApp* pApp = UiApp::GetInstance();
2381 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2382 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2384 AppLog("MainForm::OnSceneActivatedN called");
2385 String* pSelectedScene = NULL;
2386 Object* pValue = NULL;
2387 String* pUrl = null;
2388 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2389 pSelectedScene = (String*) pValue;
2391 if (pSelectedScene != null)
2393 delete pSelectedScene;
2395 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2396 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2397 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2398 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2400 // setting the current scene ID
2401 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2403 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2405 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2407 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2408 if(__pWindowInfo == null)
2410 // if(__pWindowInfo == null)
2412 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2415 else if ( pArgs != null && pArgs->GetCount() == 1)
2417 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2423 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2425 // hiding the address bar
2426 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2427 __pAddressbar->SetShowState(false);
2428 if(__pWebViewer != null)
2430 __pWebViewer->Resume();
2433 if(pUrl != null && pUrl->GetLength() > 0)
2437 else if(__pWindowInfo != null)
2439 if(__pWindowInfo->pageUrl.GetLength() > 0 && previousSceneId != IDSCN_MULTIPLE_WINDOW && previousSceneId != IDSCN_MULTIPLE_WINDOW_GRID && previousSceneId != IDSCN_BOOKMARK_VIEW && previousSceneId != IDSCN_SETTINGS && previousSceneId != IDSCN_MAIN_VIEW)
2441 LoadUrl(__pWindowInfo->pageUrl);
2443 else if (__pWindowInfo->isJavascriptInitiated == true)
2447 __pWindowInfo->pCurrentWeb = __pWebViewer;
2451 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2452 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2453 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2455 InitMostVisitedSitesView(GetOrientationStatus());
2457 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2459 if(__pMostVisitedListView != null)
2461 __pMostVisitedListView->SetShowState(false);
2465 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2467 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2469 if (pBookmarkUrl == null)
2471 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2472 //__pAddressbar->SetUrl(*pBookmarkUrl);
2473 SetUrl(*pBookmarkUrl);
2475 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2476 __pWebViewer->LoadUrl(*pBookmarkUrl);
2477 delete pBookmarkUrl;
2480 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2481 Bitmap* pBitmap = null;
2482 if (isPrivateBrowsing == true)
2484 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2486 if (__pWebViewer != null)
2488 __pWebViewer->SetPrivateBrowsingEnabled(true);
2491 if (__pAddressbar != null)
2493 // __pAddressbar->UpdateFaviconBitmap(true);
2499 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2501 if (__pWebViewer != null)
2503 __pWebViewer->SetPrivateBrowsingEnabled(false);
2506 if (__pAddressbar != null)
2508 // __pAddressbar->UpdateFaviconBitmap(false);
2512 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2514 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2516 else if (__pMenu != null )
2518 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2521 if (pBitmap != null)
2526 AppLog("ABC: OnSceneActivatedN started exit");
2531 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2532 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2534 Canvas* pWebCanvas = null;
2535 if (__pWebViewer != null)
2537 pWebCanvas = __pWebViewer->GetCanvasN();
2539 if (pWebCanvas == null)
2543 if (__pWindowInfo != null)
2545 if (__pWindowInfo->pWebCanvasBitmap != null)
2547 delete __pWindowInfo->pWebCanvasBitmap;
2549 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2550 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2551 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2553 Bitmap* pBitmap = GetCapturedBitmapN();
2554 AppLog("Coming here");
2555 Canvas* pCanvas = new(std::nothrow) Canvas();
2556 pCanvas->Construct(GetClientAreaBounds());
2559 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2562 if(__pWebViewer != null && __pWindowInfo != null)
2563 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2565 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2566 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2568 AppLog("Coming here");
2572 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2573 const Tizen::Base::String& realm,
2574 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2580 MainForm::OnHttpAuthenticationCanceled(void)
2585 MainForm::OnLoadingStarted(void)
2587 AppLogDebug("MainForm::OnLoadingStarted entered");
2589 if(__pAddressbar == NULL || __pWebViewer == null)
2593 // this is added in case if menu is opened and user load the page
2594 if(__pMenu != null && __pMenu->GetShowState() == true)
2596 __pMenu->SetShowState(false);
2597 __pMenu->Invalidate(true);
2599 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2601 __pImageMenu->SetShowState(false);
2602 __pImageMenu->Invalidate(true);
2604 String url = __pWebViewer->GetUrl();
2605 if(url.Contains(IDS_TIZEN_SERVICE))
2608 String delim(L":;");
2610 // Creates a StringTokenizer instance
2611 StringTokenizer strTok(url, delim);
2613 int count = strTok.GetTokenCount(); // count == 4
2615 HashMap *pMap = new HashMap();
2620 while (strTok.HasMoreTokens())
2622 AppLog("Token: %ls", token.GetPointer());
2623 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2624 if(token.Contains(IDS_APPID))
2626 token.SubString(6, appId);
2627 AppLog("AppID:%ls", appId.GetPointer());
2629 else if(token.Contains("="))
2631 String *pKey = new String();
2632 String *pValue = new String();
2634 token.IndexOf("=", 0, index);
2637 token.SubString(0, index, *pKey);
2638 token.SubString(index + 1, *pValue);
2639 pMap->Add(pKey, pValue);
2645 AppControl *pAppControl = null;
2646 String operationId = L"http://tizen.org/appcontrol/operation/main";
2647 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2650 AppLog("Starting AppControl");
2651 result r = pAppControl->Start(null, null, pMap, null);
2652 AppLog("Result of Start %s", GetErrorMessage(r));
2656 AppLogException("AppControl not found");
2661 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
2663 __pAddressbar->SetShowState(false);
2664 AddressBarCancelledClicked(*__pAddressbar);
2665 __pAddressbar->Invalidate(true);
2667 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2670 __pAddressbar->SetFaviconBitmap(*pBitmap);
2673 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2675 // updating the address bar position with respect to web control
2676 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2677 __distanceMoved = 0;
2681 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2682 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2683 if (__pWebViewer != null)
2685 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2686 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2687 SetUrl(__pWebViewer->GetUrl());
2688 if (__pWindowInfo != NULL)
2690 // resetting the page title to blank, it will be received in OnPageTitleReceived()
2691 __pWindowInfo->pageTitle = L"";
2692 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2694 __pAddressbar->Invalidate(true);
2700 MainForm::OnLoadingCanceled(void)
2707 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2709 AppLog("XYZ::MainForm::OnKeypadWillOpen");
2714 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2716 AppLog("XYZ::MainForm::OnKeypadOpened");
2717 __pFooterPanel->SetShowState(false);
2722 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2724 AppLog("XYZ::MainForm::OnKeypadClosed");
2725 __pFooterPanel->SetShowState(true);
2726 RelayoutControls(true);
2730 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2732 AppLog("KeypadBoundsChanged");
2733 RelayoutControls(false);
2737 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2738 const Tizen::Base::String& reason)
2740 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2744 MainForm::OnLoadingCompleted(void)
2746 AppLog("MainForm::OnLoadingCompleted start");
2748 result r = E_SUCCESS;
2750 if (__pWebViewer == null)
2755 if (__pAddressbar == null)
2759 if (__pWebViewer->CanGoForward())
2761 //__pAddressbar->SetForwardButtonEnabled(true);
2762 SetForwardButtonEnabled(true);
2766 //__pAddressbar->SetForwardButtonEnabled(false);
2767 SetForwardButtonEnabled(false);
2770 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2772 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2774 //__pAddressbar->UpdateProgress(0);
2778 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2780 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2784 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2785 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2786 if (isPrivateBrowsing == false)
2788 if(__pHistory != null)
2794 __pHistory = new(std::nothrow) History;
2795 HistoryPresentationModel::GetCurrentDateTime(date);
2798 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2799 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2801 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2802 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2804 __pHistory->SetVisitedTime(date);
2806 if (__pWebViewer != null)
2808 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2810 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2811 if (pTempBitmap != null)
2813 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2814 __pHistory->SetFavIconBitmap(*pTempBitmap);
2817 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2820 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2821 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2822 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2824 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2825 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2826 __pHistory->SetThumbnail(pBitmap);
2828 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2831 __pHistory->SetFavIconBitmap(*pFavIcon);
2835 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
2842 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2844 // temperary fixed (webpage can be not loaded)
2848 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
2849 if (isReaderEnabled == true)
2853 delete __pReaderData;
2854 __pReaderData = null;
2856 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
2857 filePath.Append(L"data/reader.js");
2863 result r = E_SUCCESS;
2864 FileAttributes attr;
2866 File::GetAttributes(filePath,attr);
2868 r = file.Construct(filePath, L"r+");
2871 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
2874 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
2877 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
2880 // file.Read(pScript,attr.GetFileSize());
2882 // AppLogDebug("scipt length %d",strlen(pScript));
2883 String strScript = L"";
2884 // strScript.Append(pScript);
2885 // for(int i=0; i<25; i++)
2887 file.Read(pScript,attr.GetFileSize());
2888 // AppLog("xyzz tell %d",file.Tell());
2889 // r = strScript.Append(pScript);
2890 // AppLog("xyzz append result %s",GetErrorMessage(r));
2891 // AppLog("xyzz strScript length %d",strScript.GetLength());
2893 // AppLog("xyzz final strScript length %d",strScript.GetLength());
2895 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
2896 if (__pReaderData == null)
2898 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
2899 __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>");
2902 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
2903 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
2905 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
2906 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
2912 AppLog("MainForm::OnLoadingCompleted done");
2916 MainForm::OnEstimatedProgress(int progress)
2918 AppLogDebug("MainForm::OnEstimatedProgress entered");
2919 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2920 progress = DEFAULT_PROGRESS_PERCENTAGE;
2922 // __pAddressbar->UpdateProgress(progress);
2923 UpdateProgress(progress);
2926 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2928 AppLog("MainForm::OnFaviconReceived");
2929 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
2931 Bitmap* favIcon = __pWebViewer->GetFaviconN();
2934 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
2941 MainForm::OnUrlValueChanged(Addressbar&)
2947 MainForm::OnUrlSubmitted(Addressbar& addBar)
2949 AppLog("MainForm::OnUrlSubmitted");
2950 String url = addBar.GetUrl();
2951 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2953 if(__pFooterUrlField)
2954 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
2955 AddressBarCancelledClicked(*__pAddressbar);
2960 MainForm::LoadUrl(String& url)
2964 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2965 AppLogDebug("MainForm::LoadUrl enter");
2967 if (__pWebViewer != null)
2969 __pWebViewer->SetShowState(true);
2970 __pWebViewer->Invalidate(true);
2973 if (url.CompareTo(L"") == 0)
2977 if(__pFooterPanel != null)
2979 __pFooterPanel->SetShowState(true);
2980 __pFooterPanel->Invalidate(true);
2987 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2988 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)
2990 RegularExpression firstRegex;
2991 RegularExpression secondRegex;
2993 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2994 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2997 ret = firstRegex.Match(url, false); // This returns true value
2998 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3000 if (ret == true && __pWebViewer != null)
3003 __pWebViewer->LoadUrl(url);
3005 else if(__pWebViewer != null)
3007 String tempUrl = L"http://";
3008 tempUrl.Append(url);
3012 __pWebViewer->LoadUrl(tempUrl);
3016 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3017 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3020 if (__pAddressbar != null)
3022 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3023 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3026 AppLogDebug("MainForm::LoadUrl exit");
3033 MainForm::OnStopClicked(Addressbar& addBar)
3035 AppLogDebug("MainForm::OnStopClicked called");
3038 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3039 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3040 __pWebViewer->StopLoading();
3041 RequestRedraw(true);
3046 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3048 // AppLog("MainForm::OnBackClicked");
3049 result r = E_FAILURE;
3051 if (__pWebViewer && __pWebViewer->CanGoBack())
3053 __pWebViewer->GoBack();
3055 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3058 pApp = UiApp::GetInstance();
3061 r = pApp->Terminate();
3064 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3072 WindowInfo* pWindowInfo = null;
3074 SceneManager* pSceneManager = SceneManager::GetInstance();
3075 if (pSceneManager == null)
3079 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3080 if (pAllWindowList == NULL)
3082 pApp = UiApp::GetInstance();
3085 r = pApp->Terminate();
3088 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3093 if (pAllWindowList != null)
3095 totalCount = pAllWindowList->GetCount();
3097 for (int count = 0; count < totalCount; count++)
3099 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3100 if (pWindowInfo == null)
3102 pApp = UiApp::GetInstance();
3105 r = pApp->Terminate();
3108 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3113 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3115 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3118 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3121 r = pAllWindowList->RemoveAt(count, true);
3122 __pWindowInfo = null;
3125 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3130 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3134 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3136 if (pWindowInfo == null)
3138 pApp = UiApp::GetInstance();
3141 r = pApp->Terminate();
3147 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3150 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3164 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3166 AppLog("MainForm::OnForwardClicked");
3167 if (__pWebViewer == null)
3170 if (__pWebViewer->CanGoForward())
3172 __pWebViewer->GoForward();
3177 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3179 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3180 if(__pFooterPanel != null)
3182 __pFooterPanel->SetShowState(false);
3185 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3187 __pAddressbar->SetShowState(true);
3188 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3191 RelayoutControls(false);
3195 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3197 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3199 int Height = GetClientAreaBounds().height;
3200 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3203 // __pAddressbar->SetShowState(false);
3205 if (__pFooterPanel != null && addressbarKeyPadState == false)
3207 AppLog("akjshdasd 3");
3208 __pFooterPanel->SetShowState(true);
3211 RelayoutControls(false);
3215 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3217 AddressBarCancelledClicked(addBar);
3221 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3223 __prevAddressBarMode = __curAddressBarMode;
3225 if (__pAddressbar != null)
3227 __curAddressBarMode = GetAddressbarMode();
3230 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3232 __adressPanelPosition.y = 0;
3233 if (__pAddressbar != null)
3235 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3236 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3237 __pAddressbar->Invalidate(true);
3239 if (__pWebViewer != null)
3241 __pWebViewer->StopLoading();
3244 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3246 __adressPanelPosition.y = 0;
3247 if (__pAddressbar != null)
3249 __webControlPosition.y = 0;
3250 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3251 __pAddressbar->Invalidate(true);
3257 MainForm::OnClipboardClosed(const Addressbar& addBar)
3259 RelayoutControls(false);
3263 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3265 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3267 AppLog("akjshdasd 3");
3268 __pFooterPanel->SetShowState(true);
3271 RelayoutControls(false,footerState);
3275 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3277 RelayoutControls(false);
3281 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3283 __pFooterPanel->SetShowState(false);
3287 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3289 AppLog("KeypadBoundsChanged");
3290 RelayoutControls(false);
3294 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3298 __pWindowInfo->pageTitle = title;
3299 if (__pWebViewer != null)
3301 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3304 if (__pAddressbar != null && __pWebViewer != null)
3306 SetUrl(__pWebViewer->GetUrl());
3307 __pAddressbar->Invalidate(true);
3312 MainForm::UpdateFavicon(void)
3314 bool urlImageType = false;
3315 String *tempPath = null;
3317 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();");
3318 Bitmap* pBitmap = null;
3320 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3322 if (__pWindowInfo != null)
3325 url.SetUri(*tempPath);
3326 if (url.GetHost().GetLength() == 0)
3329 webUrl.SetUri(__pWebViewer->GetUrl());
3330 result r = url.SetHost(webUrl.GetHost());
3337 if (url.GetScheme().GetLength() == 0)
3340 webUrl.SetUri(__pWebViewer->GetUrl());
3341 url.SetScheme(webUrl.GetScheme());
3343 __pWindowInfo->faviconUrl = url.ToString();
3345 pBitmap = __pWebViewer->GetFaviconN();
3347 if (pBitmap != null)
3349 if (__pWindowInfo->pFavicon != NULL)
3351 __pWindowInfo->pFavicon = null;
3353 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3354 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3356 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3358 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3360 else if(__pWindowInfo->pFavicon != null)
3362 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3366 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3367 if(pDefaultBmp != null)
3369 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3378 if(tempPath != null)
3382 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3389 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3390 Tizen::Web::Controls::WebNavigationType type)
3392 // when load new page if find word panel is open its show state is false
3393 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3395 __currentSearchStr = L"";
3396 __currentWordIndex = 0;
3397 __maxOccurrances = 0;
3398 __pFindWordEditField->SetText(L"");
3399 __pFindWordNext->SetEnabled(false);
3400 __pFindWordPrev->SetEnabled(false);
3401 __pFindWordCountLabel->SetText(L"0/0");
3402 __pFindWordControl->SetShowState(false);
3403 __pFindWordEditField->HideKeypad();
3404 RelayoutControls(false);
3409 __pFooterPanel->Invalidate(true);
3412 uriInfo.SetUri(url);
3414 if(url.Contains(IDS_TIZEN_SERVICE))
3417 String delim(L":;,");
3419 // Creates a StringTokenizer instance
3420 StringTokenizer strTok(url, delim);
3422 int count = strTok.GetTokenCount(); // count == 4
3424 HashMap *pMap = new HashMap();
3430 while (strTok.HasMoreTokens())
3432 AppLog("Token: %ls", token.GetPointer());
3433 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3434 if(token.Contains(IDS_APPID))
3436 token.SubString(6, appId);
3437 AppLog("AppID:%ls", appId.GetPointer());
3439 else if(token.Contains("="))
3441 String *pKey = new String();
3442 String *pValue = new String();
3444 token.IndexOf("=", 0, index);
3447 token.SubString(0, index, *pKey);
3448 token.SubString(index + 1, *pValue);
3449 pMap->Add(pKey, pValue);
3455 AppControl *pAppControl = null;
3456 String operationId = L"http://tizen.org/appcontrol/operation/main";
3457 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3460 result r = pAppControl->Start(null, null, pMap, null);
3464 AppLogException("AppControl not found");
3474 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3475 const Tizen::Net::Http::HttpHeader& httpHeader)
3477 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3482 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3484 AppLog("MainForm::OnWebPageBlockSelected");
3485 if (__pHitElementResult != null)
3487 delete __pHitElementResult;
3488 __pHitElementResult = null;
3491 if (__pWebViewer != null)
3493 AppLog("MainForm::OnWebPageBlockSelected web not null");
3494 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3496 if(GetLastResult() == E_INVALID_ARG)
3498 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
3499 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3500 if(GetLastResult() == E_INVALID_ARG)
3502 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
3504 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
3508 if (__pHitElementResult == null)
3513 if (__pHitElementResult->HasImage() != true)
3515 String tagName = __pHitElementResult->GetTagName();
3516 String type = __pHitElementResult->GetAttributeValue("type");
3518 __currentSelectedStr.Clear();
3519 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3520 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3521 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3523 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) /*&& __isLongPressedDone == true*/)
3525 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3527 InitSelectTextContextMenu(endPoint,true);
3528 __pImageMenu->SetShowState(true);
3529 __pImageMenu->Show();
3530 __pImageMenu->Invalidate(true);
3532 else /*if(__isLongPressedDone == true)*/
3534 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3536 if(__pHitElementResult->GetUrl().GetLength() > 0)
3538 __currentSelectedStr.Clear();
3539 __currentSelectedStr = __pHitElementResult->GetUrl();
3541 InitSelectTextContextMenu(endPoint,false);
3542 __pImageMenu->SetShowState(true);
3543 __pImageMenu->Show();
3544 __pImageMenu->Invalidate(true);
3547 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3548 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3549 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3555 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3561 MainForm::OnWebWindowCreateRequested(void)
3563 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
3565 if (pNewWindowInfo == null)
3569 result r = E_SUCCESS;
3570 SceneManager* pSceneManager = SceneManager::GetInstance();
3571 if (pSceneManager == NULL)
3575 ArrayList* pArgList = new(std::nothrow) ArrayList();
3576 if (pArgList == NULL)
3580 r = pArgList->Construct();
3583 pNewWindowInfo->isJavascriptInitiated = true;
3584 pArgList->Add(*pNewWindowInfo);
3585 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3589 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3596 return pNewWindowInfo->pCurrentWeb;
3600 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
3602 __webControlPosition.y = 0;
3603 __webControlHeight = GetClientAreaBounds().height;
3604 AppLog("Client area height: %d", __webControlHeight);
3606 AppLog("Client area height: %d", __webControlHeight);
3607 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3609 __webControlPosition.y += __pAddressbar->GetHeight();
3610 __webControlHeight -= __pAddressbar->GetHeight();
3611 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3613 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3615 __webControlPosition.y += __pFindWordControl->GetHeight();
3616 __webControlHeight -= __pFindWordControl->GetHeight();
3617 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3620 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
3622 __webControlHeight -= __pFooterPanel->GetHeight();
3624 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3626 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3628 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12);
3629 __pWebViewer->Invalidate(false);
3631 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3633 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3640 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3642 if (__pFindWordControl == null)
3647 Tizen::Locales::LocaleManager localeManager;
3648 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
3650 String languageCode;
3651 result r = SettingInfo::GetValue(L"Language", languageCode);
3652 // int languagecode = local.GetLanguageCode();
3653 AppLog("rahul language is %S", languageCode.GetPointer());
3657 InitFindWordPanel();
3659 if (languageCode.CompareTo("ara") == 0)
3661 AppLog("rahul language is arabic");
3663 __pFindWordPanelLeftToRight->SetShowState(false);
3664 __pFindWordPanelRightToLeft->SetShowState(true);
3666 __pFindWordClear->SetShowState(false);
3667 __pFindWordCountLabel->SetShowState(false);
3668 __pFindWordEditField->SetShowState(false);
3670 __pFindWordClearRightToLeft->SetShowState(true);
3671 __pFindWordCountLabelRightToLeft->SetShowState(true);
3672 __pFindWordEditFieldRightToLeft->SetShowState(true);
3676 AppLog("rahul language is not arabic");
3679 __pFindWordPanelLeftToRight->SetShowState(true);
3680 __pFindWordPanelRightToLeft->SetShowState(false);
3682 __pFindWordClear->SetShowState(true);
3683 __pFindWordCountLabel->SetShowState(true);
3684 __pFindWordEditField->SetShowState(true);
3686 __pFindWordClearRightToLeft->SetShowState(false);
3687 __pFindWordCountLabelRightToLeft->SetShowState(false);
3688 __pFindWordEditFieldRightToLeft->SetShowState(false);
3690 __pFindWordControl->SetShowState(true);
3694 if(__pFindWordControl != null)
3696 __pFindWordControl->SetShowState(false);
3700 AppLog("MainForm::ShowFindWordPanel %d",show);
3701 if (show && !isTouchPressed)
3703 if (languageCode.CompareTo("ara") == 0)
3705 if (__pFindWordEditFieldRightToLeft)
3707 __pFindWordEditFieldRightToLeft->SetFocus();
3708 __pFindWordEditFieldRightToLeft->ShowKeypad();
3713 if (__pFindWordEditField)
3715 __pFindWordEditField->SetFocus();
3716 __pFindWordEditField->ShowKeypad();
3722 if (languageCode.CompareTo("ara") == 0)
3724 if (__pFindWordEditFieldRightToLeft)
3725 __pFindWordEditFieldRightToLeft->HideKeypad();
3729 if (__pFindWordEditField)
3730 __pFindWordEditField->HideKeypad();
3734 RelayoutControls(false);
3738 MainForm::StartWordSearch()
3740 //Get the count of occurances of the word in the current page
3741 __maxOccurrances = 0;
3742 __currentWordIndex = 0;
3744 __pFindWordPrev->SetEnabled(false);
3745 String *pCountStr = null;
3746 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3747 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3748 if (pCountStr != null)
3750 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3754 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3759 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3761 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3762 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3764 if(totalCount == -1 || totalCount == 0)
3766 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
3767 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3770 else if(totalCount > 100)
3772 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3773 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3777 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3778 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3781 __maxOccurrances = totalCount;
3782 __currentWordIndex = currentOrdinal;
3784 //Reset the UI controls as per the maxOccurrance value
3785 if (totalCount <= 0)
3787 AppLog("Word not found");
3788 //Show error notification to user
3789 __pFindWordNext->SetEnabled(false);
3790 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
3792 __pFindWordCountLabel->SetText(L"0/0");
3793 __pFindWordCountLabel->Invalidate(false);
3795 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
3797 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
3798 __pFindWordCountLabelRightToLeft->Invalidate(false);
3800 __pFindWordNext->Invalidate(false);
3801 __pFindWordPrev->Invalidate(false);
3806 if (totalCount == 1)
3808 __pFindWordNext->SetEnabled(false);
3812 __pFindWordNext->SetEnabled(true);
3815 String countStr = L"";
3816 countStr.Append(__currentWordIndex);
3817 countStr.Append(L"/");
3818 countStr.Append(__maxOccurrances);
3819 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
3821 __pFindWordCountLabel->SetText(countStr);
3822 __pFindWordCountLabel->Invalidate(false);
3823 __pFindWordCountLabel->Invalidate(false);
3825 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
3827 __pFindWordCountLabelRightToLeft->SetText(countStr);
3828 __pFindWordCountLabelRightToLeft->Invalidate(false);
3829 __pFindWordCountLabelRightToLeft->Invalidate(false);
3831 //FindNextWord(true);
3832 //Update the controls
3833 __pFindWordNext->Invalidate(false);
3834 __pFindWordPrev->Invalidate(false);
3839 MainForm::FindNextWord(bool next)
3843 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3844 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
3846 if (__currentWordIndex < __maxOccurrances)
3848 __currentWordIndex++;
3854 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3855 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
3857 if(__currentWordIndex > 1)
3859 __currentWordIndex--;
3864 String countStr = L"";
3865 countStr.Append(__currentWordIndex);
3866 countStr.Append(L"/");
3867 countStr.Append(__maxOccurrances);
3869 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
3871 __pFindWordCountLabel->SetText(countStr);
3872 __pFindWordCountLabel->Invalidate(false);
3874 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
3876 __pFindWordCountLabelRightToLeft->SetText(countStr);
3877 __pFindWordCountLabelRightToLeft->Invalidate(false);
3880 if (__currentWordIndex >= __maxOccurrances)
3882 __pFindWordNext->SetEnabled(false);
3886 __pFindWordNext->SetEnabled(true);
3888 if (__currentWordIndex <= 1)
3890 __pFindWordPrev->SetEnabled(false);
3894 __pFindWordPrev->SetEnabled(true);
3896 __pFindWordPrev->Invalidate(false);
3897 __pFindWordNext->Invalidate(false);
3899 __pFindWordControl->Invalidate(true);
3903 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3905 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
3906 __isWebKeypadOpened = true;
3907 __pFooterPanel->SetShowState(false);
3908 // OnAddressBarKeypadOpened(*__pAddressbar);
3912 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3914 AppLog("xyz::MainForm::OnWebKeypadOpened");
3916 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3918 __currentSearchStr = L"";
3919 __currentWordIndex = 0;
3920 __maxOccurrances = 0;
3921 __pFindWordEditField->SetText(L"");
3922 __pFindWordNext->SetEnabled(false);
3923 __pFindWordPrev->SetEnabled(false);
3924 __pFindWordCountLabel->SetText(L"0/0");
3925 __pWebViewer->SearchTextAllAsync(L"",false);
3926 __pFindWordControl->SetShowState(false);
3927 __pFindWordEditField->HideKeypad();
3931 if (__pWebViewer != null && __pFooterPanel != null)
3933 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3934 if(__pAddressbar != null)
3936 __pAddressbar->SetShowState(false);
3938 if(__pFindWordControl != null)
3940 __pFindWordControl->SetShowState(false);
3942 __pFooterPanel->SetShowState(false);
3943 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
3945 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
3947 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
3948 // AppLog("omgomgomg");
3954 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3956 AppLog("xyz::MainForm::OnWebKeypadClosed");
3957 AppLog("akjshdasd 4");
3958 __pFooterPanel->SetShowState(true);
3959 // OnAddressBarKeypadClosed(*__pAddressbar);
3960 RelayoutControls(false);
3961 __isWebKeypadOpened = false;
3965 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3967 Control* temp = const_cast< Control* >(&source);
3968 Header* pHeader = dynamic_cast< Header* >(temp);
3969 if (pHeader != null)
3971 //Header double - clicked
3972 AppLog("Header double clicked");
3974 if(__pFindWordControl)
3976 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
3977 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
3981 AppLog("MainScene::OnTouchDoublePressed");
3985 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3987 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
3988 __longPressPoint = currentPosition;
3990 if (__pHitElementResult != null)
3992 delete __pHitElementResult;
3993 __pHitElementResult = null;
3996 if (__pWebViewer != null)
3998 AppLog("MainForm::OnTouchLongPressed web not null");
3999 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4002 if (__pHitElementResult == null)
4007 if (__pHitElementResult->HasImage() == true)
4009 InitImageContextMenu(currentPosition);
4010 __pImageMenu->SetShowState(true);
4011 __pImageMenu->Show();
4012 __pImageMenu->Invalidate(true);
4014 else if(__pHitElementResult->HasUrl() == true)
4016 String tempURl = __pHitElementResult->GetUrl();
4017 AppLog("tempURl is %ls", tempURl.GetPointer());
4018 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4019 if (pBitmap != null)
4027 InitImageLinkContextMenu(currentPosition);
4028 __pImageMenu->SetShowState(true);
4029 __pImageMenu->Show();
4030 __pImageMenu->Invalidate(true);
4034 String tagName = __pHitElementResult->GetTagName();
4035 String type = __pHitElementResult->GetAttributeValue("type");
4036 String value = __pHitElementResult->GetAttributeValue(L"value");
4037 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4039 __currentSelectedStr.Clear();
4040 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4042 AppLog("tag name is %ls", tagName.GetPointer());
4043 AppLog("type is %ls", type.GetPointer());
4044 AppLog("innerHtml is %ls", innerHtml.GetPointer());
4046 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && innerHtml.GetLength() == 0 && __isWebKeypadOpened == true)
4048 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4050 InitSelectTextContextMenu(currentPosition,true, true);
4053 __pImageMenu->SetShowState(true);
4054 __pImageMenu->Show();
4055 __pImageMenu->Invalidate(true);
4058 //__isLongPressedDone = true;
4059 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4060 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4063 // __inputEventToBeSupressed = true;
4067 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4069 AppLog("MainForm::OnTouchReleased");
4072 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4073 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4075 __pWebViewer->ConsumeInputEvent();
4077 if(pHitElement != null)
4081 __inputEventToBeSupressed = false;*/
4085 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4092 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4094 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4096 __currentSearchStr = L"";
4097 __currentWordIndex = 0;
4098 __maxOccurrances = 0;
4100 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4102 __pFindWordEditField->SetText(L"");
4103 __pFindWordEditField->HideKeypad();
4104 __pFindWordControl->SetShowState(false);
4105 __pFindWordCountLabel->SetText(L"0/0");
4107 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4109 __pFindWordEditFieldRightToLeft->SetText(L"");
4110 __pFindWordEditFieldRightToLeft->HideKeypad();
4111 __pFindWordControl->SetShowState(false);
4112 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4115 __pFindWordNext->SetEnabled(false);
4116 __pFindWordPrev->SetEnabled(false);
4118 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
4119 __pFindWordControl->SetShowState(false);
4121 if(__pAddressbar->GetShowState() == false)
4123 __pAddressbar->SetAddressbarURLFocus();
4124 __pFooterPanel->SetShowState(false);
4131 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4137 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4143 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4149 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4155 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4161 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4163 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4164 int widthContextItem = 0;
4166 // As per the platform engineer comment removed this line
4167 /*if(__pWebViewer != null)
4169 // 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
4170 __pWebViewer->ReleaseBlock();
4173 if(__pFindWordControl != null)
4174 ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4175 if ( __pFooterLabel != null)
4177 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4180 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4186 if (__pFindWordBgLabel != null)
4188 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4189 if (pBitmap != null)
4191 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4196 if (__pFindWordBgLabelRightToLeft != null)
4198 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4199 if (pBitmap != null)
4201 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4207 __pMenu->SetShowState(false);
4208 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4210 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4214 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4219 AppLog("__pFooterPanel->GetShowState() is true");
4221 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4222 __pFooterPanel->Invalidate(true);
4226 if(__pMoreButton && __pMenu)
4228 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
4229 __pMenu->SetAnchorPosition(p);
4230 __pMenu->Invalidate(true);
4233 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4234 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4236 InitMostVisitedSitesView(orientationStatus);
4239 RelayoutControls(false);
4240 if (__pArticleReaderPanel != null)
4242 if (__pArticleReaderPanel->GetShowState() == true)
4244 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4246 if (__pBlankPanel != null)
4247 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4249 if (__pWebReader != null)
4251 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4253 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4254 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4256 if ( pBitmap != null && pSrcBitmap != null)
4258 AppLog("CreateReaderPanel ninepatchbitmap found");
4259 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4262 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4263 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4264 if (pBitmap != null)
4269 if (pSrcBitmap != null)
4278 if (__pAddressbar != null)
4280 int width = GetClientAreaBounds().width;
4281 __pAddressbar->OrientationChanged(width);
4286 MainForm::OnSettingsChange(int settingvalue)
4288 AppLogDebug("MainForm::OnSettingsChange entered");
4290 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4292 __pAddressbar->ResetGuideText();
4294 if (__pWebViewer == null)
4296 AppLogDebug("Webviewer is not initialized yet.");
4300 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4302 WebSetting settings = __pWebViewer->GetSetting();
4303 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4305 settings.SetAutoFittingEnabled(true);
4307 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
4309 settings.SetAutoFittingEnabled(false);
4311 __pWebViewer->SetSetting(settings);
4313 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4315 WebSetting settings = __pWebViewer->GetSetting();
4316 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4317 __pWebViewer->SetSetting(settings);
4319 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4321 WebSetting settings = __pWebViewer->GetSetting();
4322 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4323 __pWebViewer->SetSetting(settings);
4325 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4327 WebSetting settings = __pWebViewer->GetSetting();
4328 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4329 __pWebViewer->SetSetting(settings);
4331 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4335 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4338 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
4342 WebSetting settings = __pWebViewer->GetSetting();
4343 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
4344 __pWebViewer->SetSetting(settings);
4347 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
4351 WebSetting settings = __pWebViewer->GetSetting();
4352 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
4353 __pWebViewer->SetSetting(settings);
4356 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4358 WebSetting settings = __pWebViewer->GetSetting();
4359 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4361 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4365 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4367 __pWebViewer->SetSetting(settings);
4369 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4373 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4374 WebSetting settings = __pWebReader->GetSetting();
4375 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4376 __pWebReader->SetSetting(settings);
4382 MainForm::OnSettingsReset()
4386 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4387 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4392 MainForm::OnClearCache()
4394 result r = E_SUCCESS;
4396 if (__pWebViewer != NULL)
4398 r = __pWebViewer->ClearCache();
4401 AppLogDebug("Cache cleared success");
4405 AppLogDebug("Cache cleared fail");
4411 MainForm::OnClearCookie()
4413 result r = E_SUCCESS;
4415 if (__pWebViewer != NULL)
4417 __pWebViewer->ClearCookie();
4421 AppLogDebug("Cookie cleared success");
4425 AppLogDebug("Cache cleared fail");
4430 MainForm::OnClearFormData()
4432 result r = E_SUCCESS;
4434 if (__pWebViewer != NULL)
4436 __pWebViewer->ClearFormData();
4440 AppLogDebug("Cookie cleared success");
4444 AppLogDebug("Cache cleared fail");
4449 MainForm::OnClearPasswords()
4451 result r = E_SUCCESS;
4453 if (__pWebViewer != NULL)
4455 __pWebViewer->ClearLoginFormData();
4459 AppLogDebug("Cookie cleared success");
4463 AppLogDebug("Cache cleared fail");
4469 MainForm::findDistance(int x1,int y1,int x2, int y2)
4471 int deltaX = Math::Abs(x2 - x1);
4472 int deltaY = Math::Abs(y2 - y1);
4473 double num = deltaX*deltaX + deltaY*deltaY;
4479 for (i = 0; i < 20; i++)
4481 x = (((x*x)+ num)/(2*x));
4492 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4494 if(__pFindWordControl)
4496 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4497 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4499 //__isLongPressedDone = false;
4501 __pAddressbar->SetShowState(false);
4504 IList* pList = null;
4505 pList = touch.GetTouchInfoListN(source);
4509 int count = pList->GetCount();
4512 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4513 __touchPoint1 = pTouchInfo->position;
4515 /*if (__pAddressbar != null)
4517 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4519 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4521 __pAddressbar->SaveAddressbarEditText();
4523 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4526 __pAddressbar->Invalidate(true);
4528 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4530 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4532 //__pAddressbar->SaveAddressbarEditText();
4534 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4537 else if (count == 2)
4539 AppLogDebug("MainForm::OnTouchPressed count is two");
4540 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4541 __touchPoint1 = pTouchInfo->position;
4543 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4544 __touchPoint2 = pTouchInfo->position;
4550 pList->RemoveAll(true);
4557 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4559 // __currentWordIndex = 0;
4560 //__isLongPressedDone = false;
4565 MainForm::MoveUiControls()
4570 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4572 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4574 if(__pFooterUrlField->GetTextLength() == 0)
4576 __pFooterUrlField->SetKeypadActionEnabled(false);
4580 __pFooterUrlField->SetKeypadActionEnabled(true);
4583 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
4585 __currentSearchStr = __pFindWordEditField->GetText();
4586 if (__currentSearchStr.GetLength() > 0)
4588 __pFindWordCountLabel->SetShowState(true);
4592 __pFindWordCountLabel->SetShowState(false);
4594 __pFindWordNext->SetEnabled(false);
4595 __pFindWordPrev->SetEnabled(false);
4596 __pFindWordNext->Invalidate(true);
4597 __pFindWordPrev->Invalidate(true);
4598 __pFindWordCountLabel->SetText(L"0/0");
4599 __pFindWordCountLabel->Invalidate(true);
4601 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
4603 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
4604 if (__currentSearchStr.GetLength() > 0)
4606 __pFindWordCountLabelRightToLeft->SetShowState(true);
4610 __pFindWordCountLabelRightToLeft->SetShowState(false);
4613 __pFindWordNext->SetEnabled(false);
4614 __pFindWordPrev->SetEnabled(false);
4615 __pFindWordNext->Invalidate(true);
4616 __pFindWordPrev->Invalidate(true);
4617 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4618 __pFindWordCountLabelRightToLeft->Invalidate(true);
4620 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4621 if (__currentSearchStr.GetLength() > 0)
4627 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4629 __currentSearchStr = L"";
4630 AppLogDebug("Enter something");
4635 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4642 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4644 if(__pWebViewer != null)
4647 AppLog("MainForm::InitMostVisitedSitesView");
4648 result r = E_SUCCESS;
4651 if (__pWebViewer != null && __pMostVisitedListView != null)
4656 if (__pMostVisitedListView != null)
4658 RemoveControl(__pMostVisitedListView);
4660 if(__pMostVisitedSites != null)
4662 __pMostVisitedSites->RemoveAll(true);
4665 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4667 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4668 __pMostVisitedListView = new(std::nothrow) ListView();
4670 int height = GetClientAreaBounds().height;
4672 if(__pFooterPanel->GetShowState() == true)
4674 height = height - __pFooterPanel->GetHeight();
4676 if(__pAddressbar->GetShowState() == true)
4678 height -= __pAddressbar->GetHeight();
4681 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4685 delete __pMostVisitedListView;
4686 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4689 __pMostVisitedListView->SetItemProvider(*this);
4690 __pMostVisitedListView->AddListViewItemEventListener(*this);
4691 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4692 AddControl(__pMostVisitedListView);
4693 __pMostVisitedListView->UpdateList();
4700 MainForm::GetImagePath(void)
4704 String formattedTime;
4705 DateTime currentTime;
4706 LocaleManager localManager;
4707 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4709 localManager.Construct();
4710 Locale locale = localManager.GetSystemLocale();
4711 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4713 // Get date formatter
4714 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4718 pTimeFormatter->Format(currentTime, formattedTime);
4721 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4722 String delim(L" :");
4723 StringTokenizer strTok(formattedTime, delim);
4726 String str1("GMT+00");
4727 while (strTok.HasMoreTokens())
4729 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4730 if(token.Equals(str1))
4732 AppLog("token is %ls", token.GetPointer());
4733 imageName.Append(token);
4739 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4741 result r = E_FAILURE;
4742 AppLog("Content manager 1");
4743 ContentId contentId;
4744 ContentManager contentManager;
4745 r = contentManager.Construct();
4748 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4751 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4752 Tizen::Io::Directory::Create(contentPath,true);
4753 if(GetLastResult() == E_FILE_ALREADY_EXIST)
4755 AppLog("Already exists");
4757 else if(GetLastResult() == E_SUCCESS)
4759 AppLog("created success");
4761 contentPath.Append(imageName);
4762 contentPath.Append(".jpg");
4763 contentId = contentManager.CreateContent(*aBuffer, contentPath);
4764 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
4768 MainForm::SetForwardButtonEnabled(bool isEnabled)
4770 __pGoForwardBtn->SetEnabled(isEnabled);
4771 __pGoForwardBtn->Invalidate(true);
4775 MainForm::SetBackButtonEnabled(bool isEnabled)
4777 __pGoBackBtn->SetEnabled(isEnabled);
4778 __pGoBackBtn->Invalidate(true);
4782 MainForm::UpdateProgress(int percentage)
4784 __progressPercentage = percentage;
4785 if (percentage == 0 || percentage == 100)
4787 __isLoadingData = false;
4788 if (percentage == 100)
4790 __isLoadingCompleted = true;
4791 __progressPercentage = 0;
4795 __isLoadingCompleted = false;
4800 __isLoadingData = true;
4802 UpdateProgressBitmap();
4806 MainForm::GetProgress(void)
4808 return __progressPercentage;
4812 MainForm::UpdateProgressBitmap(void)
4814 result r = E_SUCCESS;
4815 if (__pProgressbarLabel == null)
4817 int w = __pProgressbarLabel->GetWidth();
4818 int h = __pProgressbarLabel->GetHeight();
4820 int progressWidth = 0;
4821 Bitmap* pRetBitmap = null;
4823 if (__progressPercentage == 0 || __progressPercentage == 100)
4825 __pProgressbarLabel->SetShowState(false);
4826 __pProgressbarLabel->Invalidate(false);
4831 __pProgressbarLabel->SetShowState(true);
4832 __pProgressbarLabel->Invalidate(false);
4835 r = canvas.Construct(Rectangle(0, 0, w, h));
4839 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
4844 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
4848 pBgBmp->Scale(Dimension(w, h));
4849 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4853 progressWidth = (double) (w) * __progressPercentage / 100;
4854 AppLogDebug("progressWidth: %d", progressWidth);
4855 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4857 if (pProgressBmp != null)
4859 pProgressBmp->Scale(Dimension(progressWidth, h));
4860 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4861 delete pProgressBmp;
4864 pRetBitmap = new (std::nothrow) Bitmap();
4866 if (pRetBitmap == null)
4868 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4872 pRetBitmap->Construct(canvas, canvas.GetBounds());
4874 if (__pProgressbarLabel != null && pRetBitmap != null)
4876 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4877 __pProgressbarLabel->Invalidate(false);
4880 if (pRetBitmap != null)
4889 MainForm::ReaderClicked()
4891 result r = E_SUCCESS;
4892 ArrayList* pArgList = new(std::nothrow) ArrayList();
4893 if (pArgList != null)
4895 r = pArgList->Construct();
4902 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
4909 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
4916 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
4924 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4928 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
4930 CreateReaderPanel();
4931 AppLogDebug("MainScene::ReaderClicked entered");
4934 /*if (__pArticleReaderPanel)
4936 AppLogDebug("showstate true for reader panel");
4937 __pArticleReaderPanel->SetShowState(true);
4938 __pArticleReaderPanel->Show();
4940 int xPos = __pArticleReaderPanel->GetX();
4941 int yPos = __pArticleReaderPanel->GetY();
4942 AppLog("ReaderClicked() xPos = %d",xPos);
4943 AppLog("ReaderClicked() yPos = %d",yPos);
4945 if (__pReaderData == null)
4950 String loadData = L"<html>\
4952 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
4957 background-color: transparent;\
4976 <body style='width:'";
4977 loadData.Append(bodyWidth);
4978 loadData.Append(L"px'>");
4979 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
4980 loadData.Append(*__pReaderData);
4981 loadData.Append(L"</body></html>");
4984 buf.Construct(loadData.GetLength());
4985 AppLogDebug("data->GetLength %d",loadData.GetLength());
4986 for (int z=0;z<loadData.GetLength();z++)
4989 loadData.GetCharAt(z,b);
4990 buf.SetByte((byte)b);
4994 if (__pWebReader != null)
4996 __pWebReader->LoadData(L"",buf,L"text/html");
4997 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
5001 AppLogDebug("cannot LoadData __pWebReader is null");
5006 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5008 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5010 __currentAddMode = addMode;
5014 case ADDRESSBAR_MODE_INVALID:
5019 case ADDRESSBAR_MODE_READER:
5021 __pStopBtn->SetShowState(false);
5022 __pRefreshBtn->SetShowState(false);
5023 __pClearBtn->SetShowState(false);
5024 __pReaderBtn->SetShowState(false);
5027 case ADDRESSBAR_MODE_LOADING:
5029 __pRefreshBtn->SetShowState(false);
5030 __pStopBtn->SetShowState(true);
5031 __pClearBtn->SetShowState(false);
5032 __pReaderBtn->SetShowState(false);
5035 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5037 // SetUrl(__pAddressbar->GetUrl());
5039 __pRefreshBtn->SetShowState(true);
5040 __pStopBtn->SetShowState(false);
5041 __pClearBtn->SetShowState(false);
5042 __pReaderBtn->SetShowState(false);
5045 case ADDRESSBAR_MODE_EDIT:
5047 __pRefreshBtn->SetShowState(false);
5048 __pStopBtn->SetShowState(false);
5049 __pReaderBtn->SetShowState(false);
5050 __pClearBtn->SetShowState(true);
5057 OnAddressBarModeChanged();
5060 AddressBarMode MainForm::GetAddressbarMode(void)
5062 return __currentAddMode;
5065 void MainForm::SetUrl(const String& url)
5069 if (__pFooterUrlField != NULL)
5071 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5072 if (removedHttpUrl.IsEmpty() == false)
5074 __pFooterUrlField->SetText(removedHttpUrl);
5075 if(__pAddressbar != NULL)
5076 __pAddressbar->SetUrl(__displayUrl);
5080 __pFooterUrlField->SetText(__displayUrl);
5081 if(__pAddressbar != NULL)
5082 __pAddressbar->SetUrl(__displayUrl);
5084 if(__pFooterUrlField)
5085 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5086 __pFooterUrlField->Invalidate(false);
5087 if(__pAddressbar != NULL)
5088 __pAddressbar->Invalidate(true);
5089 // __pFooterUrlField->SetCursorPosition(0);
5094 MainForm::RemoveHttpTextFromDisplayURL(void)
5096 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5098 // bool isHttpText = __displayUrl.Contains(L"http://");
5099 String updatedDisplayUrl;
5100 updatedDisplayUrl.Clear();
5101 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5103 __displayUrl.SubString(7,updatedDisplayUrl);
5105 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5107 __displayUrl.SubString(8,updatedDisplayUrl);
5109 return updatedDisplayUrl;
5112 void MainForm::OnSharePopupControlStarted(void)
5114 __pWebViewer->AddTouchEventListener(*this);
5117 void MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5119 if (requestId == BACK_GROUND_APP_EVENT)
5121 if(__pWebViewer != null)
5123 __pWebViewer->Pause();
5126 else if(requestId == FORE_GROUND_APP_EVENT)
5128 if(__pWebViewer != null)
5130 __pWebViewer->Resume();
5136 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5138 result r = E_SUCCESS;
5141 __pAddressbar->SetShowState(false);
5143 //AppLog("akjshdasd 5");
5144 //__pFooterPanel->SetShowState(true);
5147 __pWebViewer->SetFocus();
5148 else if(__pMostVisitedListView)
5149 __pMostVisitedListView->SetFocus();
5150 else if(__pMultiWindowButton)
5151 __pMultiWindowButton->SetFocus();
5152 __pMoreButton->SetFocus();
5154 __pAddressbar->SetShowState(false);
5156 RelayoutControls(false);