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 <FShellNotificationManager.h>
31 #include "IntBookmarkData.h"
32 #include "IntBookmarkPresentationModel.h"
33 #include "IntCommonLib.h"
34 #include "IntFaviconManager.h"
35 #include "IntInternetApp.h"
36 #include "IntMainForm.h"
37 #include "IntSceneRegister.h"
38 #include "IntSettingPresentationModel.h"
40 using namespace Tizen::App;
41 using namespace Tizen::Base;
42 using namespace Tizen::Base::Collection;
43 using namespace Tizen::Base::Runtime;
44 using namespace Tizen::Base::Utility;
45 using namespace Tizen::Graphics;
46 using namespace Tizen::Io;
47 using namespace Tizen::Locales;
48 using namespace Tizen::Media;
49 using namespace Tizen::Shell;
50 using namespace Tizen::Ui;
51 using namespace Tizen::Ui::Controls;
52 using namespace Tizen::Content;
53 using namespace Tizen::Ui::Scenes;
54 using namespace Tizen::System;
55 using namespace Tizen::Web;
56 using namespace Tizen::Web::Controls;
58 static const wchar_t* IDB_SEARCH_INPUT_FIELD_BG = L"I01_toolbar_input_field.9.png";
59 static const wchar_t* IDB_FINDWORD_INPUT_FIELD_BG = L"I01_toolbar_input_field_findword.9.png";
60 static const wchar_t* IDB_BTN_BACK = L"I01_icon_Back.png";
61 static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
62 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
63 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
64 static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
65 static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
66 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
67 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
68 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
69 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
70 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
71 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
72 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
73 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
74 static const wchar_t* IDS_APPID = L"AppID";
75 static const wchar_t* IDS_KEY = L"key";
76 static const wchar_t* IDS_VALUE = L"value";
77 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
78 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
79 //static const wchar_t* IDB_ADDRESS_BAR_BACKGROUND = L"I01_toolbar_bg_02.9.png";
81 const int IDA_BACKBTN_CLICKED = 101;
82 const int IDA_BOOKMARKBTN_CLICKED = 102;
83 const int IDA_MOREBTN_CLICKED = 103;
84 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
85 const int IDA_NEWWINDOWBTN_CLICKED = 105;
86 const int IDA_FORWARD_CLICKED = 106;
87 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
88 const int IDA_SHARE_CLICKED = 108;
89 const int IDA_FINDONPAGE_CLICKED = 109;
90 const int IDA_PRIVATEON_CLICKED = 110;
91 const int IDA_SETTINGS_CLICKED = 111;
92 const int IDA_READER_CLOSE_CLICKED = 112;
93 const int IDA_SMALLFONT_BTN_CLICKED = 113;
94 const int IDA_LARGEFONT_BTN_CLICKED = 114;
95 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
96 const int IDA_HISTORY_CLICKED = 116;
97 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
98 const int IDA_ADD_TO_HOME_CLICKED = 118;
99 const int IDA_SAVED_PAGES_CLICKED = 119;
100 const int IDA_DESKTOP_VIEW_CLICKED = 120;
101 const int IDA_SAVE_CLICKED = 121;
102 const int IDA_PRINT_CLICKED = 122;
104 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
105 const int IDA_FINDWORD_NEXT_CLICKED = 202;
106 const int IDA_FINDWORD_PREV_CLICKED = 203;
107 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
108 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
110 const int IDA_COPY_IMAGE_CLICKED = 206;
111 const int IDA_VIEW_IMAGE_CLICKED = 207;
112 const int IDA_SAVE_IMAGE_CLICKED = 208;
113 const int IDA_SHARE_IMAGE_CLICKED = 209;
115 const int IDA_COPY_TEXT_CLICKED = 210;
116 const int IDA_PASTE_TEXT_CLICKED = 211;
117 const int IDA_FIND_TEXT__CLICKED = 212;
118 const int IDA_SHARE_TEXT_CLICKED = 213;
120 const int IDA_GO_BACK = 214;
121 const int IDA_GO_FORWARD = 215;
122 const int IDA_REFRESH_BTN_CLICKED = 216;
123 const int IDA_STOP_BTN_CLICKED = 217;
124 const int IDA_CLEAR_URL = 218;
125 const int IDA_READER_BTN_CLICKED = 219;
128 const int IDA_HYPERLINK_OPEN_CLICKED = 220;
129 const int IDA_HYPERLINK_COPY_LINK_CLICKED = 221;
130 const int IDA_HYPERLINK_SAVE_IMAGE_CLICKED = 222;
131 const int IDA_HYPERLINK_SHARE_IMAGE_CLICKED = 223;
133 const int IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED = 224;
135 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
137 const int MainForm::IDA_FORMAT_BITMAP = 500;
138 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
139 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
140 const int MainForm::IDA_FORMAT_URL_STRING = 503;
141 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
143 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
144 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
145 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
147 MainForm::MainForm(void)
149 __isLongPressedDone = false;
151 __pAddressbar = null;
152 // __pMostVisitedSitesPanel = null;
153 __pMostVisitedListView = null;
154 __pFooterPanel = null;
155 __pHitElementResult = null;
156 __pWindowInfo = null;
159 __pOptionMenu = null;
160 __pFindWordControl = null;
161 __pFindWordPanelLeftToRight = null;
162 __pFindWordPanelRightToLeft = null;
163 __pFindWordBgLabel = null;
164 __pFindWordBgLabelRightToLeft = null;
165 __pFindWordEditField = null;
166 __pFindWordEditFieldRightToLeft = null;
167 __pFindWordClear = null;
168 __pFindWordClearRightToLeft = null;
169 __pFindWordCountLabel = null;
170 __pFindWordClearRightToLeft = null;
171 __pFindWordNext = null;
172 __pFindWordPrev = null;
173 __previousZoomLevel = 1.0;
175 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
178 __currentSearchStr = L"";
179 __currentSelectedStr = L"";
180 __maxOccurrances = 0;
181 __currentWordIndex = 0;
184 //__inputEventToBeSupressed = false;
185 __isLoadingData = false;
186 __isLoadingCompleted = false;
187 __progressPercentage = 0;
188 __touchPoint1 = Point(-1,-1);
189 __touchPoint2 = Point(-1,-1);
190 __longPressPoint = Point(-1,-1);
192 // __pReaderPopup = null;
193 __pReaderData = null;
195 __pReaderCloseBtn = null;
196 //__pNewWindowButton = null;
197 __pMoreButton = null;
198 __pMultiWindowButton = null;
199 __pArticleReaderPanel = null;
200 __pBlankPanel = null;
201 __pArticleReaderLabel = null;
202 __webControlHeight = 0;
203 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
204 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
205 __pMostVisitedSites = null;
206 __pFooterUrlField = null;
208 __pGoForwardBtn = null;
209 __pRefreshBtn = null;
210 __pProgressbarLabel = null;
211 __pFooterLabel = null;
215 __isWebKeypadOpened = false;
217 __pNotification = null;
220 MainForm::~MainForm(void)
222 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
226 __pAddressbar->SetAddressbarEventListener(null);
229 if(__pHistory != null)
235 if (__pReaderData != null)
237 delete __pReaderData;
238 __pReaderData = null;
241 if (__pPopUp != null)
247 if (__pHitElementResult != null)
249 delete __pHitElementResult;
250 __pHitElementResult = null;
254 delete __pOptionMenu;
255 __pOptionMenu = null;
258 String* pSelectedScene = NULL;
259 Object* pValue = NULL;
260 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
261 pSelectedScene = (String*) pValue;
263 /*if (pSelectedScene != null)
265 delete pSelectedScene;
267 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
271 MainForm::Initialize(void)
273 Construct(L"IDL_FORM");
275 // SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_FOOTER);
280 MainForm::OnInitializing(void)
282 AppLog("get client area width = %d",GetClientAreaBounds().width);
283 AppLog("get client area height = %d",GetClientAreaBounds().height);
284 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
285 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
287 __fontSize = CommonUtil::GetFontSize();
288 Panel* pFooterPanel = null;
290 __pSaveImage = new Image();
291 __pSaveImage->Construct();
293 // Setup back event listener
294 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
295 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
296 AddOrientationEventListener(*this);
298 AppLogDebug(" MainForm::OnInitializing ended");
299 if (__pMostVisitedSites == null)
301 __pMostVisitedSites = new(std::nothrow) ArrayList();
302 __pMostVisitedSites->Construct();
304 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
306 __pItemContext= new(std::nothrow) ListContextItem();
307 __pItemContext->Construct();
309 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"),true);
312 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
313 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
314 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
316 __pItemContextLandscape= new(std::nothrow) ListContextItem();
317 __pItemContextLandscape->Construct();
319 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), true);
320 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
321 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
322 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
323 SetFormMenuEventListener(this);
324 AppLog("SetFormMenuEventListener result %s",GetErrorMessage(GetLastResult()));
329 MainForm::InitAddressbar(void)
331 AppLogDebug("MainForm::InitAddressbar entered");
333 result r = E_SUCCESS;
335 if (__pAddressbar != null)
339 __pAddressbar = new(std::nothrow) Addressbar();
340 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
341 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
344 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
347 __pAddressbar->SetAddressbarEventListener(this);
348 AddControl(__pAddressbar);
349 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
350 SetControlAlwaysOnTop(*__pAddressbar, true);
351 __adressPanelPosition = __pAddressbar->GetPosition();
353 AppLogDebug("MainForm::InitAddressbar exit");
359 MainForm::CreateReaderPanel(void)
361 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
362 result r = E_FAILURE;
364 Button *pSmallFontBtn = null;
365 Button *pLargeFontBtn = null;
367 __pBlankPanel = new (std::nothrow) Panel();
368 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
370 __pArticleReaderPanel = new (std::nothrow) Panel();
371 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
373 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
374 if (__pReaderCloseBtn)
376 AppLogDebug("CreateReaderPanel() 6");
377 __pReaderCloseBtn->AddActionEventListener(*this);
378 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
381 __pWebReader = new (std::nothrow) Web();
382 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
384 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
385 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
387 r = __pWebReader->SetSetting(settings);
389 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
392 __pArticleReaderLabel = new Label();
393 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
395 __pBlankPanel->AddControl(__pArticleReaderLabel);
396 __pBlankPanel->AddControl(__pArticleReaderPanel);
397 AddControl(__pBlankPanel);
399 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
400 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
401 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
403 __pArticleReaderPanel->AddControl(__pWebReader);
404 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
405 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
406 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
408 if (pBitmap != null && pSrcBitmap != null)
410 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
412 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
414 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
417 pSmallFontBtn->AddActionEventListener(*this);
418 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
421 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
424 pLargeFontBtn->AddActionEventListener(*this);
425 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
434 if (pSrcBitmap != null)
440 SetControlAlwaysOnTop(*__pBlankPanel, true);
441 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
448 MainForm::InitWebControl()
450 AppLogDebug("MainForm::InitWebControl enter");
451 result r = E_SUCCESS;
452 AppLogDebug("InitWebControl");
454 if (__pAddressbar == null || __pFooterPanel == null)
457 const int Y_WEBCONTROL_POSITION = 0;
459 __webControlHeight = GetHeight() - __pFooterPanel->GetHeight();
461 if (__pMostVisitedListView)
463 __pMostVisitedListView->SetShowState(false);
465 if (__pWebViewer != null)
467 AppLogDebug("Already initialized");
470 __pWebViewer = new(std::nothrow) Web();
471 if(__pWebViewer == NULL)
473 AppLogDebug("Initialization failed");
476 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
480 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
487 r = AddControl(__pWebViewer);
493 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
496 __webControlPosition = __pWebViewer->GetPosition();
497 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
500 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
504 __pWebViewer->SetLoadingListener(this);
505 __pWebViewer->SetWebUiEventListenerF(this);
506 __pWebViewer->SetWebKeypadEventListener(this);
507 __pWebViewer->SetFocus();
508 __pWebViewer->AddTouchEventListener(*this);
510 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
511 __pWebViewer->SetTextSearchListener(this);
514 AppLogDebug("MainForm :before return");
516 AppLogDebug("MainForm::InitWebControl Exit");
522 MainForm::SetJavascriptEnabled()
524 WebSetting settings = __pWebViewer->GetSetting();
525 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
526 __pWebViewer->SetSetting(settings);
530 MainForm::SetImageLoadEnabled()
532 WebSetting settings = __pWebViewer->GetSetting();
533 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
534 __pWebViewer->SetSetting(settings);
538 MainForm::InitFooter(void)
540 AppLogDebug("MainForm::InitFooter entered");
541 Button* pBackButton = null;
542 Button* pBookmarkButton = null;
543 Button* pMultiWindowButton = null;
544 Bitmap *pIconBitmap = null;
545 Bitmap *pBGBitmap = null;
546 Label *pBGLabel = null;
548 if (__pFooterPanel == null)
550 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
553 if (__pFooterPanel == null)
558 SetControlAlwaysOnTop(*__pFooterPanel, true);
560 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
561 if ( __pFooterLabel == NULL )
565 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
566 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
569 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
573 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
575 if ( __pMultiWindowButton == NULL )
581 SetFormBackEventListener(this);
582 AppLog("SetFormBackEventListener result %s",GetErrorMessage(GetLastResult()));
583 if (__pMultiWindowButton != null)
585 Bitmap* pBitmap = null;
586 Bitmap* pPressedBitmap = null;
587 String imagePath = "I01_toolbar_icon_windows_manager_0";
588 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
589 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
590 imagePath.Append(totalCount);
591 imagePath.Append(".png");
593 pressedImagePath.Append(totalCount);
594 pressedImagePath.Append("_press.png");
596 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
597 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
598 if ( pBitmap == null )
603 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
606 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
607 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
612 __pMultiWindowButton->AddActionEventListener(*this);
613 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
616 delete pPressedBitmap;
617 pPressedBitmap = null;
623 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
624 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
627 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
628 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
629 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
633 __pMoreButton->AddActionEventListener(*this);
634 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
637 //Add the editfield for url
638 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
639 if (__pFooterUrlField == NULL)
641 return E_INVALID_KEY;
644 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
645 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
646 __pFooterUrlField->AddKeypadEventListener(*this);
647 __pFooterUrlField->SetPropagatedTouchEventListener(this);
648 __pFooterUrlField->AddFocusEventListener(*this);
650 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
652 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
654 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
656 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
660 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
661 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
665 //Add the go Back Button
666 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
667 if (__pGoBackBtn == NULL)
669 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
670 return E_INVALID_KEY;
672 __pGoBackBtn->SetActionId(IDA_GO_BACK);
673 __pGoBackBtn->AddActionEventListener(*this);
675 //Add the go forward Button
676 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
677 if (__pGoForwardBtn == NULL)
679 AppLogDebug("Control not found returning E_INVALID_KEY");
680 return E_INVALID_KEY;
682 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
683 __pGoForwardBtn->AddActionEventListener(*this);
684 if (__pWebViewer && __pWebViewer->CanGoForward())
686 SetForwardButtonEnabled(true);
690 SetForwardButtonEnabled(false);
693 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
694 if (__pRefreshBtn == NULL)
696 AppLogDebug("Control not found returning E_INVALID_KEY");
697 return E_INVALID_KEY;
700 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
701 __pRefreshBtn->AddActionEventListener(*this);
702 __pRefreshBtn->SetShowState(true);
704 //Add the backround label for displaying progressbar
705 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
706 if (__pProgressbarLabel == NULL)
708 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
709 return E_INVALID_KEY;
711 __pProgressbarLabel->SetShowState(false);
713 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
714 if (__pStopBtn == NULL)
716 AppLogDebug("Control not found returning E_INVALID_KEY");
717 return E_INVALID_KEY;
719 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
720 __pStopBtn->AddActionEventListener(*this);
721 __pStopBtn->SetShowState(false);
723 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
724 if (__pClearBtn == NULL)
726 AppLogDebug("Control not found returning E_INVALID_KEY");
727 return E_INVALID_KEY;
729 __pClearBtn->SetActionId(IDA_CLEAR_URL);
730 __pClearBtn->AddActionEventListener(*this);
731 __pClearBtn->SetShowState(false);
733 __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
734 if (__pReaderBtn == NULL)
736 AppLogDebug("Control not found returning E_INVALID_KEY");
737 return E_INVALID_KEY;
739 __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
740 __pReaderBtn->AddActionEventListener(*this);
741 __pReaderBtn->SetShowState(false);
743 // __pFooterPanel->Invalidate(true);
744 AppLogDebug("MainForm::InitFooter exit");
749 MainForm::InitOptionMenu()
751 result r = E_SUCCESS;
752 bool isPrivateBrowsing = false;
753 Bitmap* pBitmap = null;
755 if (__pOptionMenu != null)
757 __pOptionMenu->Invalidate(true);
761 __pOptionMenu = new(std::nothrow) OptionMenu();
762 r = __pOptionMenu->Construct();
763 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
765 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
768 if (isPrivateBrowsing == true)
770 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
774 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
777 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
779 if ( pBitmap != NULL)
781 __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
784 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
785 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
786 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
789 __pOptionMenu->SetMaxVisibleItemsCount(6);
790 __pOptionMenu->SetShowState(false);
791 __pOptionMenu->AddActionEventListener(*this);
792 SetControlAlwaysOnTop(*__pOptionMenu, true);
798 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
800 result r = E_SUCCESS;
801 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
803 AppLog("MainForm::InitImageContextMenu clicked on image");
804 if (__pImageMenu != null)
809 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
814 __pImageMenu = new (std::nothrow) ContextMenu();
815 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
816 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
818 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
819 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
820 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
821 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
822 __pImageMenu->SetMaxVisibleItemsCount(4);
823 __pImageMenu->AddActionEventListener(*this);
824 SetControlAlwaysOnTop(*__pImageMenu, true);
830 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
832 result r = E_SUCCESS;
833 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
835 AppLog("MainForm::InitImageContextMenu clicked on image");
836 if (__pImageMenu != null)
842 // if(__pAddressbar->GetShowState() == true)
843 // p.y = p.y + __pAddressbar->GetHeight();
844 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
849 __pImageMenu = new (std::nothrow) ContextMenu();
850 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
851 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
853 r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED);
854 r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,IDA_HYPERLINK_COPY_LINK_CLICKED);
855 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
856 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
858 __pImageMenu->SetMaxVisibleItemsCount(3);
859 __pImageMenu->AddActionEventListener(*this);
860 SetControlAlwaysOnTop(*__pImageMenu, true);
867 MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOption = false)
869 result r = E_SUCCESS;
870 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
872 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
873 if (__pImageMenu != null)
882 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
886 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
888 __pImageMenu = new (std::nothrow) ContextMenu();
889 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
890 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
892 if(onlyPasteOption == false)
894 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
896 if (pasteOption || onlyPasteOption)
898 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
900 if(onlyPasteOption == false)
902 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
903 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
906 __pImageMenu->SetMaxVisibleItemsCount(3);
907 __pImageMenu->AddActionEventListener(*this);
908 SetControlAlwaysOnTop(*__pImageMenu, true);
915 MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPasteOption = false)
917 result r = E_SUCCESS;
918 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
920 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
921 if (__pImageMenu != null)
930 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
934 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
936 __pImageMenu = new (std::nothrow) ContextMenu();
937 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
938 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
940 if(onlyPasteOption == false)
942 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
944 if (pasteOption || onlyPasteOption)
946 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
948 if(onlyPasteOption == false)
950 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
951 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
954 __pImageMenu->SetMaxVisibleItemsCount(3);
955 __pImageMenu->AddActionEventListener(*this);
956 SetControlAlwaysOnTop(*__pImageMenu, true);
963 MainForm::InitFindWordPanel(void)
965 result r = E_SUCCESS;
966 Bitmap *pIconBitmap = null;
968 if (__pFindWordControl != null)
970 AppLogDebug("Findword panel already initialized");
971 if (__pFindWordBgLabel != null)
973 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
976 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
980 if (__pFindWordBgLabelRightToLeft != null)
982 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
985 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
992 __pFindWordControl = new (std::nothrow) Panel();
993 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
996 AppLogException("There is some problem in the xml file. Please check.");
999 AddControl(__pFindWordControl);
1000 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
1001 SetControlAlwaysOnTop(*__pFindWordControl,true);
1002 __pFindWordControl->SetShowState(false);
1003 __pFindWordControl->Invalidate(false);
1005 __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1006 __pFindWordPanelLeftToRight->SetShowState(true);
1008 __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
1009 __pFindWordPanelRightToLeft->SetShowState(false);
1011 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
1012 if (__pFindWordBgLabel != null)
1014 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1015 Rectangle pRect = pPanel1->GetBounds();
1016 pRect.x = pRect.y = 0;
1017 __pFindWordBgLabel->SetBounds(pRect);
1018 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1019 if (pBitmap != null)
1021 AppLogDebug("InitFindWordPanel: Coming here");
1022 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1027 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1031 __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
1032 if (__pFindWordBgLabelRightToLeft != null)
1034 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1035 Rectangle pRect = pPanel1->GetBounds();
1036 pRect.x = pRect.y = 0;
1037 __pFindWordBgLabelRightToLeft->SetBounds(pRect);
1038 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1039 if (pBitmap != null)
1041 AppLogDebug("InitFindWordPanel: Coming here");
1042 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1047 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1051 Button* pfindWordCancel = null;
1052 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1053 if (pfindWordCancel == null)
1055 AppLogException("There is some problem in the xml file. Please check.");
1058 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1059 pfindWordCancel->AddActionEventListener(*this);
1061 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1062 if (__pFindWordClear == null)
1064 AppLogException("There is some problem in the xml file. Please check.");
1068 __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1069 if (__pFindWordClearRightToLeft == null)
1071 AppLogException("There is some problem in the xml file. Please check.");
1075 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1076 __pFindWordClear->AddActionEventListener(*this);
1078 __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1079 __pFindWordClearRightToLeft->AddActionEventListener(*this);
1081 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1082 if (__pFindWordNext == null)
1084 AppLogException("There is some problem in the xml file. Please check.");
1088 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1089 __pFindWordNext->AddActionEventListener(*this);
1091 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1092 if (__pFindWordPrev == null)
1094 AppLogException("There is some problem in the xml file. Please check.");
1098 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1099 __pFindWordPrev->AddActionEventListener(*this);
1101 __pFindWordNext->SetEnabled(false);
1102 __pFindWordPrev->SetEnabled(false);
1104 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1105 if (__pFindWordCountLabel == null)
1107 AppLogException("There is some problem in the xml file. Please check.");
1111 __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1112 if (__pFindWordCountLabel == null)
1114 AppLogException("There is some problem in the xml file. Please check.");
1118 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1119 if (__pFindWordEditField == null)
1121 AppLogException("There is some problem in the xml file. Please check.");
1124 __pFindWordEditField->AddTextEventListener(*this);
1125 __pFindWordEditField->AddKeypadEventListener(*this);
1126 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1127 __pFindWordEditField->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1129 __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1130 if (__pFindWordEditFieldRightToLeft == null)
1132 AppLogException("There is some problem in the xml file. Please check.");
1135 __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1136 __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1137 __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1138 __pFindWordEditFieldRightToLeft->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1143 MainForm::CreateItem (int index, int itemWidth)
1145 Rectangle listImageRect;
1146 Rectangle pagetTitleRect;
1147 Rectangle pageURLRect;
1148 Rectangle deleteImageRect;
1149 String pageTitle(L"");
1150 String pageURL(L"");
1151 result r = E_SUCCESS;
1152 Bitmap* pListIconImage = null;
1155 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1156 if(pHistory == null)
1160 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1161 if ( pAppResource == NULL )
1165 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1167 CustomItem* pItem = new(std::nothrow) CustomItem();
1168 pageTitle = pHistory->GetHistoryTitle();
1169 pageURL = pHistory->GetHistoryUrl();
1171 if (pageURL.GetLength() == 0)
1174 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1175 pageURL = L"<"+ nourl +">";
1179 Rectangle screenBounds = GetBounds();
1182 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1191 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1193 if ( pBitmap != NULL)
1195 pListIconImage = new Bitmap();
1196 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1200 if(pListIconImage == null)
1202 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1205 if ( pListIconImage != NULL)
1207 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2 , 72, 72);
1208 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60 + (__fontSize - 44));
1209 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1212 if (pItem != null && pListIconImage != NULL)
1214 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1218 if (pageTitle.CompareTo(L"") != 0)
1222 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1226 if (pageURL.CompareTo(L"") != 0)
1230 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1235 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1237 if ( __pItemContext!= NULL)
1241 pItem->SetContextItem(__pItemContext);
1247 if ( __pItemContextLandscape!= NULL)
1251 pItem->SetContextItem(__pItemContextLandscape);
1255 if( pListIconImage != NULL)
1257 delete pListIconImage;
1258 pListIconImage = null;
1265 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1272 MainForm::GetItemCount (void)
1274 if(__pMostVisitedSites != null)
1276 __pMostVisitedSites->RemoveAll(true);
1278 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1279 if(__pMostVisitedSites != null)
1281 return __pMostVisitedSites->GetCount();
1288 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1290 if(__pMostVisitedSites != null)
1292 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1293 if (pHistory != null)
1295 String url = pHistory->GetHistoryUrl();
1297 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1298 __pMostVisitedListView->UpdateList();
1304 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1306 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1307 String url = pHistory->GetHistoryUrl();
1315 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1321 MainForm::OnTerminating(void)
1323 result r = E_SUCCESS;
1325 RemoveOrientationEventListener(*this);
1329 __pAddressbar->SetAddressbarEventListener(null);
1334 __pWebViewer->RemoveTouchEventListener(*this);
1335 __pWebViewer->SetWebUiEventListenerF(null);
1336 __pWebViewer->SetWebKeypadEventListener(null);
1337 __pWebViewer->SetTextSearchListener(null);
1343 delete __pItemContext;
1345 if (__pItemContextLandscape)
1347 delete __pItemContextLandscape;
1351 delete __pSaveImage;
1353 if (__pMostVisitedSites)
1355 __pMostVisitedSites->RemoveAll(true);
1356 delete __pMostVisitedSites;
1362 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1364 result r = E_SUCCESS;
1366 AppLogDebug("Clicked : %d", actionId);
1369 case IDA_BACKBTN_CLICKED:
1371 if(__pImageMenu && __pImageMenu->GetShowState() == true)
1373 AppLog("Hiding the menu");
1374 __pImageMenu->SetShowState(false);
1376 if (__pWebViewer && __pWebViewer->CanGoBack())
1378 __pWebViewer->GoBack();
1380 else if(__pWindowInfo->isJavascriptInitiated == false)
1383 pApp = UiApp::GetInstance();
1386 RemoveOrientationEventListener(*this);
1390 __pAddressbar->SetAddressbarEventListener(null);
1395 __pWebViewer->RemoveTouchEventListener(*this);
1396 __pWebViewer->SetWebUiEventListenerF(null);
1397 __pWebViewer->SetWebKeypadEventListener(null);
1398 __pWebViewer->SetTextSearchListener(null);
1399 __pWebViewer->SetLoadingListener(null);
1401 r = pApp->Terminate();
1404 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1412 WindowInfo* pWindowInfo = null;
1414 SceneManager* pSceneManager = SceneManager::GetInstance();
1415 if (pSceneManager == null)
1419 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1420 if (pAllWindowList == NULL)
1422 pApp = UiApp::GetInstance();
1425 RemoveOrientationEventListener(*this);
1429 __pAddressbar->SetAddressbarEventListener(null);
1434 __pWebViewer->RemoveTouchEventListener(*this);
1435 __pWebViewer->SetWebUiEventListenerF(null);
1436 __pWebViewer->SetWebKeypadEventListener(null);
1437 __pWebViewer->SetTextSearchListener(null);
1438 __pWebViewer->SetLoadingListener(null);
1440 r = pApp->Terminate();
1443 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1448 if (pAllWindowList != null)
1450 totalCount = pAllWindowList->GetCount();
1452 for (int count = 0; count < totalCount; count++)
1454 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1455 if (pWindowInfo == null)
1457 pApp = UiApp::GetInstance();
1460 RemoveOrientationEventListener(*this);
1464 __pAddressbar->SetAddressbarEventListener(null);
1469 __pWebViewer->RemoveTouchEventListener(*this);
1470 __pWebViewer->SetWebUiEventListenerF(null);
1471 __pWebViewer->SetWebKeypadEventListener(null);
1472 __pWebViewer->SetTextSearchListener(null);
1473 __pWebViewer->SetLoadingListener(null);
1475 r = pApp->Terminate();
1478 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1485 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1487 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1490 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1493 r = pAllWindowList->RemoveAt(count, true);
1494 __pWindowInfo = null;
1497 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1502 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1506 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1508 if (pWindowInfo == null)
1510 pApp = UiApp::GetInstance();
1514 RemoveOrientationEventListener(*this);
1518 __pAddressbar->SetAddressbarEventListener(null);
1523 __pWebViewer->RemoveTouchEventListener(*this);
1524 __pWebViewer->SetWebUiEventListenerF(null);
1525 __pWebViewer->SetWebKeypadEventListener(null);
1526 __pWebViewer->SetTextSearchListener(null);
1527 __pWebViewer->SetLoadingListener(null);
1529 r = pApp->Terminate();
1535 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1538 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1550 case IDA_FORWARD_CLICKED:
1551 if (__pWebViewer == null)
1554 if (__pWebViewer->CanGoForward())
1556 __pWebViewer->GoForward();
1558 __pOptionMenu->SetShowState(false);
1559 __pOptionMenu->Invalidate(false);
1562 case IDA_FINDONPAGE_CLICKED:
1564 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1565 __currentSearchStr.Clear();
1567 InitFindWordPanel();
1568 __pOptionMenu->SetShowState(false);
1569 __pOptionMenu->Invalidate(false);
1571 ShowFindWordPanel(true);
1573 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1575 __pFindWordEditField->SetFocus();
1576 __pFindWordCountLabel->SetShowState(false);
1580 __pFindWordEditFieldRightToLeft->SetFocus();
1581 __pFindWordCountLabelRightToLeft->SetShowState(false);
1585 case IDA_PRIVATEON_CLICKED:
1587 result r = E_SUCCESS;
1589 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1590 Bitmap* pBitmap = null;
1591 if (isPrivateBrowsing == true)
1593 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1596 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1600 if (__pWebViewer != NULL)
1602 __pWebViewer->SetPrivateBrowsingEnabled(false);
1605 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1607 if (__pAddressbar != null)
1609 __pAddressbar->UpdateFaviconBitmap(false);
1615 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1618 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1622 if (__pWebViewer != NULL)
1624 __pWebViewer->SetPrivateBrowsingEnabled(true);
1627 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1629 if (__pAddressbar != null)
1631 __pAddressbar->UpdateFaviconBitmap(true);
1635 itemIndex = __pOptionMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1636 r = __pOptionMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1637 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1638 __pOptionMenu->Invalidate(true);
1639 if ( pBitmap != NULL )
1646 case IDA_SETTINGS_CLICKED:
1649 ArrayList* pArgList = new(std::nothrow) ArrayList();
1652 pArgList->Construct();
1653 pArgList->Add(*__pWindowInfo);
1654 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1656 __pOptionMenu->SetShowState(false);
1657 __pOptionMenu->Invalidate(false);
1659 if (pArgList != null)
1668 case IDA_ADDTOBOOKMARK_CLICKED:
1671 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1673 int bookmarkCount=0;
1676 url=__pWindowInfo->pageUrl;
1677 result r = E_SUCCESS;
1678 Bitmap* pBitmap = null;
1679 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1687 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1688 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1689 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1691 if(__pNotification != null)
1693 RemoveControl(__pNotification);
1694 __pNotification = null;
1696 __pNotification = new (std::nothrow) NotificationPanel(*this);
1697 if (__pNotification != null)
1699 __pNotification->SetText(message);
1700 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1701 __pNotification->ShowNotification();
1706 String title=__pWindowInfo->pageTitle;
1707 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1708 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1710 pBookmark->SetBookmarkTitle(title);
1711 pBookmark->SetUrl(url);
1712 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1714 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1716 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1717 pBookmark->SetFaviconId(id);
1718 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1719 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1721 if(__pNotification != null)
1723 RemoveControl(__pNotification);
1724 __pNotification = null;
1726 __pNotification = new (std::nothrow) NotificationPanel(*this);
1727 if (__pNotification != null)
1729 __pNotification->SetText(message);
1730 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1731 __pNotification->ShowNotification();
1732 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1735 if (pBitmap != null)
1737 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1742 __pOptionMenu->Invalidate(true);
1747 case IDA_PRINT_CLICKED:
1749 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//shared//data//test.pdf");
1750 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1752 AppLog("RequestPrint called!");
1753 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1754 result nResult = E_FAILURE;
1757 AppLog("TestPrint if (pAc) == true");
1762 String fileType = L"service_print_files_type";
1763 String typeVal = L"DOC";
1765 String fileCount = L"service_print_files_count";
1766 String countVal = L"1";
1767 String fileFolder= L"service_print_files_folder_name";
1768 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//shared//data";
1770 map.Add(&fileCount, &countVal);
1771 map.Add(&fileFolder, &folderVal);
1772 map.Add(&fileType, &typeVal);
1774 String fileName = L"service_print_files_files_name";
1776 ArrayList fileNameList;
1777 fileNameList.Construct();
1778 String file1 = L"test.pdf";
1780 fileNameList.Add(&file1);
1781 map.Add(&fileName, &fileNameList);
1783 nResult = pAc->Start(NULL, NULL, &map, NULL);
1785 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1786 else if (nResult == E_MAX_EXCEEDED)
1787 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1788 else if (nResult == E_OBJ_NOT_FOUND)
1789 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1790 else if (nResult == E_IN_PROGRESS)
1791 AppLog("TestPrint ret == E_IN_PROGRESS");
1792 else if (nResult == E_PRIVILEGE_DENIED)
1793 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1794 else if(nResult == E_SYSTEM)
1795 AppLog("TestPrint ret == E_SYSTEM");
1801 int __modalMsgBoxResult;
1802 MessageBox* pMsgBox = new MessageBox();
1803 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1804 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1807 __modalMsgBoxResult = 0;
1811 case IDA_SHARE_CLICKED:
1813 if(__pPopUp != null)
1820 __pAddressbar->HideKeypad();
1822 __pPopUp = new(std::nothrow) SharePopup();
1823 __pPopUp->Initialize();
1824 if (__pWindowInfo != null)
1826 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1827 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1828 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1829 pShareInfo->SetImageAttached(false);
1830 __pPopUp->RemoveAllShareInfo();
1831 __pPopUp->AddShareInfo(pShareInfo);
1833 __pPopUp->SetShowState(true);
1837 case IDA_BOOKMARKBTN_CLICKED:
1839 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1840 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1843 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1848 case IDA_MOREBTN_CLICKED:
1850 AppLog("IDA_MOREBTN_CLICKED");
1852 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1854 int bookmarkCount=0;
1857 url=__pWindowInfo->pageUrl;
1858 result r = E_SUCCESS;
1859 Bitmap* pBitmap = null;
1861 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1864 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1869 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1873 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1875 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1877 if (__pOptionMenu->GetItemCount() == 9)
1879 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1883 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1888 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1892 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1893 if (__pOptionMenu->GetItemCount() != 9)
1895 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1896 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1897 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1898 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1899 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1900 __pOptionMenu->SetMaxVisibleItemsCount(6);
1902 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1904 AppLog(" Orientation landscape");
1905 __pOptionMenu->SetMaxVisibleItemsCount(5);
1909 AppLog(" Orientation potrait");
1910 __pOptionMenu->SetMaxVisibleItemsCount(6);
1913 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1916 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1917 __pOptionMenu->SetShowState(true);
1918 __pOptionMenu->Invalidate(true);
1919 __pOptionMenu->Show();
1923 case IDA_HISTORY_CLICKED:
1925 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1926 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1929 case IDA_SAVED_PAGES_CLICKED:
1934 case IDA_DESKTOP_VIEW_CLICKED:
1939 case IDA_SAVE_CLICKED:
1944 case IDA_MULTIWINDOWBTN_CLICKED:
1946 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1947 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1951 case IDA_NEWWINDOWBTN_CLICKED:
1953 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
1955 if (pNewWindowInfo == null)
1959 result r = E_SUCCESS;
1960 SceneManager* pSceneManager = SceneManager::GetInstance();
1962 if (pSceneManager == NULL)
1966 ArrayList* pArgList = new(std::nothrow) ArrayList();
1967 if (pArgList == NULL)
1971 r = pArgList->Construct();
1974 pArgList->Add(*pNewWindowInfo);
1975 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1981 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1986 case IDA_SMALLFONT_BTN_CLICKED:
1988 WebSetting setting = __pWebReader->GetSetting();
1989 setting.SetFontSize(15);
1990 __pWebReader->SetSetting(setting);
1993 case IDA_LARGEFONT_BTN_CLICKED:
1995 WebSetting setting = __pWebReader->GetSetting();
1996 setting.SetFontSize(25);
1997 __pWebReader->SetSetting(setting);
2000 case IDA_READER_CLOSE_CLICKED:
2002 if (__pArticleReaderPanel != null && __pBlankPanel != null)
2004 RemoveControl(__pBlankPanel);
2005 __pArticleReaderPanel = null;
2006 __pBlankPanel = null;
2007 __pArticleReaderLabel = null;
2009 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2012 case IDA_FINDWORD_CANCEL_CLICKED:
2014 __currentSearchStr = L"";
2015 __currentWordIndex = 0;
2016 __maxOccurrances = 0;
2018 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2020 __pFindWordEditField->SetText(L"");
2021 __pFindWordCountLabel->SetText(L"0/0");
2023 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2025 __pFindWordEditFieldRightToLeft->SetText(L"");
2026 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2029 __pFindWordNext->SetEnabled(false);
2030 __pFindWordPrev->SetEnabled(false);
2031 __pFindWordCountLabel->SetText(L"0/0");
2032 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
2033 AppLog("akjshdasd 1");
2034 if(__isWebKeypadOpened == false)
2035 __pFooterPanel->SetShowState(true);
2036 ShowFindWordPanel(false);
2039 case IDA_FINDWORD_SEARCH_CLICKED:
2041 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2043 __currentSearchStr = __pFindWordEditField->GetText();
2045 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2047 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
2050 if (__currentSearchStr.GetLength() > 0)
2056 AppLogDebug("Enter something");
2060 case IDA_FINDWORD_CLEAR_CLICKED:
2062 __pFindWordCountLabel->SetText(L"0/0");
2063 __pFindWordEditField->SetText(L"");
2064 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2066 __currentSearchStr = L"";
2067 __pFindWordNext->SetEnabled(false);
2068 __pFindWordPrev->SetEnabled(false);
2069 __pFindWordCountLabel->SetShowState(false);
2070 __pFindWordControl->Invalidate(true);
2073 case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
2075 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2076 __pFindWordEditFieldRightToLeft->SetText(L"");
2077 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2079 __currentSearchStr = L"";
2080 __pFindWordNext->SetEnabled(false);
2081 __pFindWordPrev->SetEnabled(false);
2082 __pFindWordCountLabelRightToLeft->SetShowState(false);
2083 __pFindWordControl->Invalidate(true);
2086 case IDA_FINDWORD_NEXT_CLICKED:
2091 case IDA_FINDWORD_PREV_CLICKED:
2093 FindNextWord(false);
2096 case IDA_BRIGHTNESS_BTN_CLICKED:
2098 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
2099 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2102 case IDA_COPY_IMAGE_CLICKED:
2104 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2105 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2107 const Bitmap* pBitmap = null;
2108 if (__pHitElementResult != null && __pHitElementResult->HasImage())
2110 pBitmap = __pHitElementResult->GetImage();
2113 String resourcePath = App::GetInstance()->GetAppResourcePath();
2114 r = item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
2115 AppLog("Platofrm construct failed result %s",GetErrorMessage(r));
2116 // copying the item to clipboard
2117 Clipboard* pClipboard = Clipboard::GetInstance();
2118 if (pClipboard != null)
2120 r = pClipboard->CopyItem(item);
2121 AppLog("Platofrm copy failed result %s",GetErrorMessage(r));
2125 case IDA_VIEW_IMAGE_CLICKED:
2127 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
2128 WindowInfo* pNewWindowInfo = null;
2129 if (__pHitElementResult != null)
2131 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2132 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2138 case IDA_SAVE_IMAGE_CLICKED:
2140 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
2141 const Bitmap* pSaveBitmap = null;
2142 String imageName = GetImagePath();
2143 AppLog("Content manager image name %ls",imageName.GetPointer());
2146 imagePath.Append(imageName);
2147 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2148 AppLog("Content manager image path %ls",imagePath.GetPointer());
2149 if (__pHitElementResult != null)
2151 pSaveBitmap = __pHitElementResult->GetImage();
2153 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2157 UpdateImageContent(pBuffer, imageName);
2159 if(__pNotification != null)
2161 RemoveControl(__pNotification);
2162 __pNotification = null;
2164 __pNotification = new NotificationPanel(*this);
2166 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2167 msg.Append(imagePath);
2168 if (__pNotification != null)
2170 __pNotification->SetText(msg);
2171 if (__pFooterPanel->GetShowState() == true)
2173 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2177 __pNotification->SetPositionDiff(0);
2180 __pNotification->ShowNotification();
2185 int __modalMsgBoxResult;
2186 MessageBox* pMsgBox = new MessageBox();
2187 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
2188 pMsgBox->ShowAndWait(__modalMsgBoxResult);
2191 __modalMsgBoxResult = 0;
2195 case IDA_SHARE_IMAGE_CLICKED:
2197 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2198 if (__pPopUp != null)
2205 __pAddressbar->HideKeypad();
2207 __pPopUp = new(std::nothrow) SharePopup();
2208 __pPopUp->Initialize();
2209 if (__pHitElementResult != null)
2211 const Bitmap* pSaveBitmap = null;
2212 String imageName = GetImagePath();
2213 AppLog("Content manager image name %ls",imageName.GetPointer());
2216 imagePath.Append(imageName);
2217 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2218 AppLog("Content manager image path %ls",imagePath.GetPointer());
2219 if (__pHitElementResult != null)
2221 pSaveBitmap = __pHitElementResult->GetImage();
2223 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2225 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2226 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2228 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2229 pShareInfo->SetPageTitle(L"");
2230 pShareInfo->SetPageUrl(srcUrl);
2231 pShareInfo->SetImageAttached(true);
2232 pShareInfo->SetImagePath(imagePath);
2233 __pPopUp->RemoveAllShareInfo();
2234 __pPopUp->AddShareInfo(pShareInfo);
2235 __pPopUp->SetShowState(true);
2240 case IDA_HYPERLINK_OPEN_CLICKED:
2242 if (__pHitElementResult != null)
2244 String srcUrl = __pHitElementResult->GetUrl();
2246 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2248 if (pNewWindowInfo == null)
2252 result r = E_SUCCESS;
2253 SceneManager* pSceneManager = SceneManager::GetInstance();
2254 if (pSceneManager == NULL)
2258 ArrayList* pArgList = new(std::nothrow) ArrayList();
2259 if (pArgList == NULL)
2263 pArgList->Construct();
2265 pArgList->Add(*pNewWindowInfo);
2266 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2267 if (pArgList != null)
2274 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2280 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2282 if (__pHitElementResult == null)
2287 if(__pPopUp != null)
2294 __pAddressbar->HideKeypad();
2296 __pPopUp = new(std::nothrow) SharePopup();
2297 __pPopUp->Initialize();
2299 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2300 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2301 pShareInfo->SetImageAttached(false);
2302 __pPopUp->RemoveAllShareInfo();
2303 __pPopUp->AddShareInfo(pShareInfo);
2305 __pPopUp->SetShowState(true);
2309 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2313 if (__pHitElementResult != null)
2315 url = __pHitElementResult->GetUrl();
2318 String resourcePath = App::GetInstance()->GetAppResourcePath();
2319 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2321 // copying the item to clipboard
2322 Clipboard* pClipboard = Clipboard::GetInstance();
2323 if (pClipboard != null)
2325 pClipboard->CopyItem(item);
2329 case IDA_FIND_TEXT__CLICKED:
2331 // AddressBarCancelledClicked(*__pAddressbar);
2332 RelayoutControls(false);
2333 // __pFooterPanel->SetShowState(false);
2334 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2335 __currentSearchStr.Clear();
2336 __currentSearchStr.Append(__currentSelectedStr);
2337 InitFindWordPanel();
2338 __pFindWordEditField->SetText(__currentSearchStr);
2340 if(__pOptionMenu != null)
2342 __pOptionMenu->SetShowState(false);
2343 __pOptionMenu->Invalidate(false);
2345 __adressPanelPosition.y = 0;
2347 if (__pAddressbar != null && __pWebViewer != NULL)
2349 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2350 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2352 if (__pFooterPanel->GetShowState() == false)
2353 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2355 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2356 __pWebViewer->Invalidate(true);
2359 ShowFindWordPanel(true);
2360 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2362 __pFindWordEditField->SetText(__currentSearchStr);
2363 __pFindWordEditField->SetFocus();
2365 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2367 __pFindWordEditFieldRightToLeft->SetText(__currentSearchStr);
2368 __pFindWordEditFieldRightToLeft->SetFocus();
2371 if (__currentSearchStr.GetLength() > 0)
2377 AppLogDebug("Enter something");
2380 if (__pWebViewer != null)
2382 // releasing the set block
2383 __pWebViewer->ReleaseBlock();
2388 case IDA_SHARE_TEXT_CLICKED:
2390 __pWebViewer->ReleaseBlock();
2391 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2392 if(__pPopUp != null)
2399 __pAddressbar->HideKeypad();
2401 __pPopUp = new(std::nothrow) SharePopup();
2402 __pPopUp->Initialize();
2403 if (__pHitElementResult != null)
2405 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2406 pShareInfo->SetPageTitle(L"");
2407 pShareInfo->SetPageUrl(__currentSelectedStr);
2408 pShareInfo->SetImageAttached(false);
2409 __pPopUp->RemoveAllShareInfo();
2410 __pPopUp->AddShareInfo(pShareInfo);
2411 __pPopUp->SetShowState(true);
2416 case IDA_COPY_TEXT_CLICKED:
2418 __pWebViewer->ReleaseBlock();
2419 // need to implement
2420 //__currentSelectedStr
2421 // Sets data to a clip board item
2423 String resourcePath = App::GetInstance()->GetAppResourcePath();
2424 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2426 // copying the item to clipboard
2427 Clipboard* pClipboard = Clipboard::GetInstance();
2428 if (pClipboard != null)
2430 pClipboard->CopyItem(item);
2434 case IDA_PASTE_TEXT_CLICKED:
2436 Clipboard* pClipboard = Clipboard::GetInstance();
2438 if(pClipboard == null)
2442 // Retrieves a latest item
2443 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2449 //Gets data from the clipboard item
2450 String* pString = dynamic_cast<String*>(pItem->GetData());
2452 if (pString != null)
2454 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2455 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2456 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2459 if(idElement.GetLength() != 0)
2461 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; } } ";
2462 script.Append("insertAtCursor('");
2463 script.Append(idElement);
2464 script.Append("',");
2465 script.Append("\"");
2466 script.Append(*pString);
2467 script.Append("\");");
2469 else if (nameElement.GetLength() != 0)
2471 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; } } ";
2472 script.Append("insertAtCursor(document.getElementsByName('");
2473 script.Append(nameElement);
2474 script.Append("')[0],");
2475 script.Append("\"");
2476 script.Append(*pString);
2477 script.Append("\");");
2479 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2480 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2491 case IDA_GO_FORWARD:
2496 case IDA_REFRESH_BTN_CLICKED:
2498 __isLoadingCompleted = false;
2499 __isLoadingData = true;
2500 __progressPercentage = 0;
2501 __displayUrl = __pFooterUrlField->GetText();
2503 String url = __pFooterUrlField->GetText();
2504 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2506 if (__pWebViewer != null && __pAddressbar != null)
2508 __pWebViewer->Reload();
2509 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2513 UpdateProgressBitmap();
2516 case IDA_STOP_BTN_CLICKED:
2518 __isLoadingCompleted = false;
2519 __isLoadingData = false;
2520 __progressPercentage = 0;
2521 __pFooterUrlField->HideKeypad();
2522 __displayUrl = __pFooterUrlField->GetText();
2526 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2527 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2528 __pWebViewer->StopLoading();
2529 RequestRedraw(true);
2532 UpdateProgressBitmap();
2537 if (__pFooterUrlField->GetText().IsEmpty() == false)
2539 //__displayUrl = __pUrlField->GetText();
2540 __pFooterUrlField->Clear();
2545 case IDA_READER_BTN_CLICKED:
2556 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2558 result r = E_FAILURE;
2559 if(__pImageMenu && __pImageMenu->GetShowState() == true)
2561 AppLog("Hiding the menu");
2562 __pImageMenu->SetShowState(false);
2564 if (__pWebViewer && __pWebViewer->CanGoBack())
2566 __pWebViewer->GoBack();
2568 else if(__pWindowInfo->isJavascriptInitiated == false)
2571 pApp = UiApp::GetInstance();
2574 RemoveOrientationEventListener(*this);
2578 __pAddressbar->SetAddressbarEventListener(null);
2583 __pWebViewer->RemoveTouchEventListener(*this);
2584 __pWebViewer->SetWebUiEventListenerF(null);
2585 __pWebViewer->SetWebKeypadEventListener(null);
2586 __pWebViewer->SetTextSearchListener(null);
2587 __pWebViewer->SetLoadingListener(null);
2589 r = pApp->Terminate();
2592 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2600 WindowInfo* pWindowInfo = null;
2602 SceneManager* pSceneManager = SceneManager::GetInstance();
2603 if (pSceneManager == null)
2607 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2608 if (pAllWindowList == NULL)
2610 pApp = UiApp::GetInstance();
2613 RemoveOrientationEventListener(*this);
2617 __pAddressbar->SetAddressbarEventListener(null);
2622 __pWebViewer->RemoveTouchEventListener(*this);
2623 __pWebViewer->SetWebUiEventListenerF(null);
2624 __pWebViewer->SetWebKeypadEventListener(null);
2625 __pWebViewer->SetTextSearchListener(null);
2626 __pWebViewer->SetLoadingListener(null);
2628 r = pApp->Terminate();
2631 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2636 if (pAllWindowList != null)
2638 totalCount = pAllWindowList->GetCount();
2640 for (int count = 0; count < totalCount; count++)
2642 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2643 if (pWindowInfo == null)
2645 pApp = UiApp::GetInstance();
2648 RemoveOrientationEventListener(*this);
2652 __pAddressbar->SetAddressbarEventListener(null);
2657 __pWebViewer->RemoveTouchEventListener(*this);
2658 __pWebViewer->SetWebUiEventListenerF(null);
2659 __pWebViewer->SetWebKeypadEventListener(null);
2660 __pWebViewer->SetTextSearchListener(null);
2661 __pWebViewer->SetLoadingListener(null);
2663 r = pApp->Terminate();
2666 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2673 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2675 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2678 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2681 r = pAllWindowList->RemoveAt(count, true);
2682 __pWindowInfo = null;
2685 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2690 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2694 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2696 if (pWindowInfo == null)
2698 pApp = UiApp::GetInstance();
2701 RemoveOrientationEventListener(*this);
2705 __pAddressbar->SetAddressbarEventListener(null);
2710 __pWebViewer->RemoveTouchEventListener(*this);
2711 __pWebViewer->SetWebUiEventListenerF(null);
2712 __pWebViewer->SetWebKeypadEventListener(null);
2713 __pWebViewer->SetTextSearchListener(null);
2714 __pWebViewer->SetLoadingListener(null);
2716 r = pApp->Terminate();
2722 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2725 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2737 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2738 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2741 AppLog("MainForm::OnSceneActivatedN called");
2742 String* pSelectedScene = NULL;
2743 Object* pValue = NULL;
2744 String* pUrl = null;
2745 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2746 pSelectedScene = (String*) pValue;
2748 if (pSelectedScene != null)
2750 delete pSelectedScene;
2752 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2753 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2754 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2755 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2757 // setting the current scene ID
2758 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2760 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2762 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2764 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2765 if(__pWindowInfo == null)
2767 // if(__pWindowInfo == null)
2769 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2772 else if ( pArgs != null && pArgs->GetCount() == 1)
2774 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2780 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2782 // hiding the address bar
2783 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2784 __pAddressbar->SetShowState(false);
2785 // if(__pWebViewer != null)
2787 // __pWebViewer->Resume();
2790 if(pUrl != null && pUrl->GetLength() > 0)
2794 else if(__pWindowInfo != null)
2796 if(__pWindowInfo->pageUrl.GetLength() > 0 &&previousSceneId != IDSCN_BRIGHTNESS && previousSceneId != IDSCN_HISTORY_LIST && previousSceneId != IDSCN_MULTIPLE_WINDOW && previousSceneId != IDSCN_MULTIPLE_WINDOW_GRID && previousSceneId != IDSCN_BOOKMARK_VIEW && previousSceneId != IDSCN_SETTINGS && previousSceneId != IDSCN_MAIN_VIEW)
2798 LoadUrl(__pWindowInfo->pageUrl);
2800 else if(__pWindowInfo->pageUrl.GetLength() > 0 && __pWindowInfo->isAppcontrolTriggered == true)
2802 LoadUrl(__pWindowInfo->pageUrl);
2804 else if (__pWindowInfo->isJavascriptInitiated == true)
2808 __pWindowInfo->pCurrentWeb = __pWebViewer;
2812 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2813 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2814 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2816 InitMostVisitedSitesView(GetOrientationStatus());
2818 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2820 if(__pMostVisitedListView != null)
2822 __pMostVisitedListView->SetShowState(false);
2826 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2828 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2830 if (pBookmarkUrl == null)
2832 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2833 //__pAddressbar->SetUrl(*pBookmarkUrl);
2834 SetUrl(*pBookmarkUrl);
2836 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2837 __pWebViewer->LoadUrl(*pBookmarkUrl);
2838 delete pBookmarkUrl;
2841 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2842 Bitmap* pBitmap = null;
2843 if (isPrivateBrowsing == true)
2845 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2847 if (__pWebViewer != null)
2849 __pWebViewer->SetPrivateBrowsingEnabled(true);
2852 if (__pAddressbar != null)
2854 // __pAddressbar->UpdateFaviconBitmap(true);
2860 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2862 if (__pWebViewer != null)
2864 __pWebViewer->SetPrivateBrowsingEnabled(false);
2867 if (__pAddressbar != null)
2869 // __pAddressbar->UpdateFaviconBitmap(false);
2873 if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
2875 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2877 else if (__pOptionMenu != null )
2879 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2882 if (pBitmap != null)
2887 AppLog("ABC: OnSceneActivatedN started exit");
2892 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2893 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2895 Canvas* pWebCanvas = null;
2896 if (__pWebViewer != null)
2898 pWebCanvas = __pWebViewer->GetCanvasN();
2901 if (pWebCanvas == null)
2905 if (__pWindowInfo != null)
2907 if (__pWindowInfo->pWebCanvasBitmap != null)
2909 delete __pWindowInfo->pWebCanvasBitmap;
2911 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2912 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2913 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2915 Bitmap* pBitmap = GetCapturedBitmapN();
2916 AppLog("Coming here");
2917 Canvas* pCanvas = new(std::nothrow) Canvas();
2918 pCanvas->Construct(GetClientAreaBounds());
2921 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2924 if(__pWebViewer != null && __pWindowInfo != null)
2925 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2927 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2928 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2931 AppLog("Coming here");
2935 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2936 const Tizen::Base::String& realm,
2937 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2943 MainForm::OnHttpAuthenticationCanceled(void)
2948 MainForm::OnLoadingStarted(void)
2950 AppLogDebug("MainForm::OnLoadingStarted entered");
2952 if(__pAddressbar == NULL || __pWebViewer == null)
2957 // this is added in case if menu is opened and user load the page
2958 if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
2960 __pOptionMenu->SetShowState(false);
2961 __pOptionMenu->Invalidate(true);
2966 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2968 __pImageMenu->SetShowState(false);
2969 __pImageMenu->Invalidate(true);
2971 String url = __pWebViewer->GetUrl();
2972 if(url.Contains(IDS_TIZEN_SERVICE))
2975 String delim(L":;,");
2977 // Creates a StringTokenizer instance
2978 StringTokenizer strTok(url, delim);
2980 int count = strTok.GetTokenCount(); // count == 4
2982 HashMap *pMap = new HashMap();
2987 while (strTok.HasMoreTokens())
2989 AppLog("Token: %ls", token.GetPointer());
2990 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2991 if(token.Contains(IDS_APPID))
2993 token.SubString(6, appId);
2994 AppLog("AppID:%ls", appId.GetPointer());
2996 else if(token.Contains(IDS_KEY))
2998 token.SubString(4, key);
2999 AppLog("key:%ls", key.GetPointer());
3001 else if(token.Contains(IDS_VALUE))
3003 token.SubString(6, value);
3004 AppLog("value:%ls", value.GetPointer());
3007 pMap->Add(key, value);
3011 AppControl *pAppControl = null;
3012 String operationId = L"http://tizen.org/appcontrol/operation/main";
3013 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3016 AppLog("Starting AppControl");
3017 result r = pAppControl->Start(null, null, pMap, null);
3018 AppLog("Result of Start %s", GetErrorMessage(r));
3022 AppLogException("AppControl not found");
3027 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
3029 __pAddressbar->SetShowState(false);
3030 AddressBarCancelledClicked(*__pAddressbar);
3031 __pAddressbar->Invalidate(true);
3033 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
3036 __pAddressbar->SetFaviconBitmap(*pBitmap);
3039 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
3041 // updating the address bar position with respect to web control
3042 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
3043 __distanceMoved = 0;
3047 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3048 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3049 if (__pWebViewer != null)
3051 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
3052 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
3053 SetUrl(__pWebViewer->GetUrl());
3054 if (__pWindowInfo != NULL)
3056 // resetting the page title to blank, it will be received in OnPageTitleReceived()
3057 __pWindowInfo->pageTitle = L"";
3058 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3060 __pAddressbar->Invalidate(true);
3066 MainForm::OnLoadingCanceled(void)
3073 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
3075 AppLog("XYZ::MainForm::OnKeypadWillOpen");
3080 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
3082 AppLog("XYZ::MainForm::OnKeypadOpened");
3083 __pFooterPanel->SetShowState(false);
3088 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
3090 AppLog("XYZ::MainForm::OnKeypadClosed");
3091 __pFooterPanel->SetShowState(true);
3092 RelayoutControls(true);
3096 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
3098 AppLog("XYZ::KeypadBoundsChanged");
3099 RelayoutControls(false);
3103 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
3104 const Tizen::Base::String& reason)
3106 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
3110 MainForm::OnLoadingCompleted(void)
3112 AppLog("MainForm::OnLoadingCompleted start");
3114 result r = E_SUCCESS;
3116 if (__pWebViewer == null)
3121 if (__pAddressbar == null)
3126 if(__pImageMenu && __pImageMenu->GetShowState())
3128 __pImageMenu->SetShowState(false);
3129 __pImageMenu->Invalidate(true);
3132 if (__pWebViewer->CanGoForward())
3134 //__pAddressbar->SetForwardButtonEnabled(true);
3135 SetForwardButtonEnabled(true);
3139 //__pAddressbar->SetForwardButtonEnabled(false);
3140 SetForwardButtonEnabled(false);
3143 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3145 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3147 //__pAddressbar->UpdateProgress(0);
3151 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3153 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3157 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
3158 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
3159 if (isPrivateBrowsing == false)
3161 if(__pHistory != null)
3167 __pHistory = new(std::nothrow) History;
3168 HistoryPresentationModel::GetCurrentDateTime(date);
3171 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
3172 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
3174 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
3175 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3177 __pHistory->SetVisitedTime(date);
3179 if (__pWebViewer != null)
3181 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3183 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3184 if (pTempBitmap != null)
3186 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3187 __pHistory->SetFavIconBitmap(*pTempBitmap);
3190 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3193 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3194 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3195 if ( pCanvas != null && pCanvas != null && pBitmap != null)
3197 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3198 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3199 __pHistory->SetThumbnail(pBitmap);
3201 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3204 __pHistory->SetFavIconBitmap(*pFavIcon);
3208 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3215 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3217 // temperary fixed (webpage can be not loaded)
3221 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3222 if (isReaderEnabled == true)
3226 delete __pReaderData;
3227 __pReaderData = null;
3229 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3230 filePath.Append(L"data/reader.js");
3236 result r = E_SUCCESS;
3237 FileAttributes attr;
3239 File::GetAttributes(filePath,attr);
3241 r = file.Construct(filePath, L"r+");
3244 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3247 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3250 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3253 // file.Read(pScript,attr.GetFileSize());
3255 // AppLogDebug("scipt length %d",strlen(pScript));
3256 String strScript = L"";
3257 // strScript.Append(pScript);
3258 // for(int i=0; i<25; i++)
3260 file.Read(pScript,attr.GetFileSize());
3261 // AppLog("xyzz tell %d",file.Tell());
3262 // r = strScript.Append(pScript);
3263 // AppLog("xyzz append result %s",GetErrorMessage(r));
3264 // AppLog("xyzz strScript length %d",strScript.GetLength());
3266 // AppLog("xyzz final strScript length %d",strScript.GetLength());
3268 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3269 if (__pReaderData == null)
3271 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3272 __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>");
3275 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3276 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3278 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3279 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3285 AppLog("MainForm::OnLoadingCompleted done");
3289 MainForm::OnEstimatedProgress(int progress)
3291 AppLogDebug("MainForm::OnEstimatedProgress entered");
3293 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3294 progress = DEFAULT_PROGRESS_PERCENTAGE;
3296 // __pAddressbar->UpdateProgress(progress);
3297 UpdateProgress(progress);
3300 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3302 AppLog("MainForm::OnFaviconReceived");
3303 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3305 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3308 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3315 MainForm::OnUrlValueChanged(Addressbar&)
3321 MainForm::OnUrlSubmitted(Addressbar& addBar)
3323 AppLog("MainForm::OnUrlSubmitted");
3324 String url = addBar.GetUrl();
3325 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3327 if(__pFooterUrlField)
3328 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3329 AddressBarCancelledClicked(*__pAddressbar);
3334 MainForm::LoadUrl(String& url)
3338 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3339 AppLogDebug("MainForm::LoadUrl enter");
3341 if (__pWebViewer != null)
3343 __pWebViewer->SetShowState(true);
3344 __pWebViewer->Invalidate(true);
3347 if (url.CompareTo(L"") == 0)
3351 if(__pFooterPanel != null)
3353 __pFooterPanel->SetShowState(true);
3354 __pFooterPanel->Invalidate(true);
3361 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3362 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)
3364 RegularExpression firstRegex;
3365 RegularExpression secondRegex;
3367 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3368 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3371 ret = firstRegex.Match(url, false); // This returns true value
3372 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3374 if (ret == true && __pWebViewer != null)
3377 __pWebViewer->LoadUrl(url);
3379 else if(__pWebViewer != null)
3381 String tempUrl = L"http://";
3382 tempUrl.Append(url);
3386 __pWebViewer->LoadUrl(tempUrl);
3390 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3391 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3394 if (__pAddressbar != null)
3396 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3397 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3400 AppLogDebug("MainForm::LoadUrl exit");
3407 MainForm::OnFocusGained(const Tizen::Ui::Control& source)
3411 __pFooterPanel->SetShowState(false);
3416 __pAddressbar->SetShowState(true);
3417 __pAddressbar->SetAddressbarURLFocus();
3419 RelayoutControls(false);
3423 MainForm::OnFocusLost(const Tizen::Ui::Control& source)
3429 MainForm::OnStopClicked(Addressbar& addBar)
3431 AppLogDebug("MainForm::OnStopClicked called");
3434 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3435 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3436 __pWebViewer->StopLoading();
3437 RequestRedraw(true);
3442 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3444 // AppLog("MainForm::OnBackClicked");
3445 result r = E_FAILURE;
3446 if(__pImageMenu && __pImageMenu->GetShowState() == true)
3448 AppLog("Hiding the menu");
3449 __pImageMenu->SetShowState(false);
3452 if (__pWebViewer && __pWebViewer->CanGoBack())
3454 __pWebViewer->GoBack();
3456 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3459 pApp = UiApp::GetInstance();
3463 RemoveOrientationEventListener(*this);
3467 __pAddressbar->SetAddressbarEventListener(null);
3472 __pWebViewer->RemoveTouchEventListener(*this);
3473 __pWebViewer->SetWebUiEventListenerF(null);
3474 __pWebViewer->SetWebKeypadEventListener(null);
3475 __pWebViewer->SetTextSearchListener(null);
3476 __pWebViewer->SetLoadingListener(null);
3480 r = pApp->Terminate();
3483 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3491 WindowInfo* pWindowInfo = null;
3493 SceneManager* pSceneManager = SceneManager::GetInstance();
3494 if (pSceneManager == null)
3498 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3499 if (pAllWindowList == NULL)
3501 pApp = UiApp::GetInstance();
3504 RemoveOrientationEventListener(*this);
3508 __pAddressbar->SetAddressbarEventListener(null);
3513 __pWebViewer->RemoveTouchEventListener(*this);
3514 __pWebViewer->SetWebUiEventListenerF(null);
3515 __pWebViewer->SetWebKeypadEventListener(null);
3516 __pWebViewer->SetTextSearchListener(null);
3517 __pWebViewer->SetLoadingListener(null);
3521 r = pApp->Terminate();
3524 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3529 if (pAllWindowList != null)
3531 totalCount = pAllWindowList->GetCount();
3533 for (int count = 0; count < totalCount; count++)
3535 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3536 if (pWindowInfo == null)
3538 pApp = UiApp::GetInstance();
3541 RemoveOrientationEventListener(*this);
3545 __pAddressbar->SetAddressbarEventListener(null);
3550 __pWebViewer->RemoveTouchEventListener(*this);
3551 __pWebViewer->SetWebUiEventListenerF(null);
3552 __pWebViewer->SetWebKeypadEventListener(null);
3553 __pWebViewer->SetTextSearchListener(null);
3554 __pWebViewer->SetLoadingListener(null);
3558 r = pApp->Terminate();
3561 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3566 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3568 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3571 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3574 r = pAllWindowList->RemoveAt(count, true);
3575 __pWindowInfo = null;
3578 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3583 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3585 else if(pAllWindowList->GetCount() > 0)
3587 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3591 pApp = UiApp::GetInstance();
3594 RemoveOrientationEventListener(*this);
3598 __pAddressbar->SetAddressbarEventListener(null);
3603 __pWebViewer->RemoveTouchEventListener(*this);
3604 __pWebViewer->SetWebUiEventListenerF(null);
3605 __pWebViewer->SetWebKeypadEventListener(null);
3606 __pWebViewer->SetTextSearchListener(null);
3607 __pWebViewer->SetLoadingListener(null);
3611 r = pApp->Terminate();
3616 if (pWindowInfo == null)
3618 pApp = UiApp::GetInstance();
3621 RemoveOrientationEventListener(*this);
3625 __pAddressbar->SetAddressbarEventListener(null);
3630 __pWebViewer->RemoveTouchEventListener(*this);
3631 __pWebViewer->SetWebUiEventListenerF(null);
3632 __pWebViewer->SetWebKeypadEventListener(null);
3633 __pWebViewer->SetTextSearchListener(null);
3634 __pWebViewer->SetLoadingListener(null);
3638 r = pApp->Terminate();
3644 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3647 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3661 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3663 AppLog("MainForm::OnForwardClicked");
3664 if (__pWebViewer == null)
3667 if (__pWebViewer->CanGoForward())
3669 __pWebViewer->GoForward();
3674 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3676 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3677 if(__pFooterPanel != null)
3679 __pFooterPanel->SetShowState(false);
3682 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3684 __pAddressbar->SetShowState(true);
3685 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3688 RelayoutControls(false);
3692 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3694 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3696 int Height = GetClientAreaBounds().height;
3697 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3699 RelayoutControls(false);
3703 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3705 AddressBarCancelledClicked(addBar);
3709 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3711 __prevAddressBarMode = __curAddressBarMode;
3713 if (__pAddressbar != null)
3715 __curAddressBarMode = GetAddressbarMode();
3718 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3720 __adressPanelPosition.y = 0;
3721 if (__pAddressbar != null)
3723 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3724 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3725 __pAddressbar->Invalidate(true);
3727 if (__pWebViewer != null)
3729 __pWebViewer->StopLoading();
3732 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3734 __adressPanelPosition.y = 0;
3735 if (__pAddressbar != null)
3737 __webControlPosition.y = 0;
3738 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3739 __pAddressbar->Invalidate(true);
3745 MainForm::OnClipboardClosed(const Addressbar& addBar)
3747 AppLog("XYZ::MainForm::OnClipboardClosed");
3748 RelayoutControls(false);
3752 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3754 AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3755 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3757 AppLog("akjshdasd 3");
3758 __pFooterPanel->SetShowState(true);
3761 RelayoutControls(false,footerState);
3765 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3767 AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3768 RelayoutControls(false);
3772 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3774 __pFooterPanel->SetShowState(false);
3778 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3780 AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3781 RelayoutControls(false);
3785 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3787 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3790 __pWindowInfo->pageTitle = title;
3791 if (__pWebViewer != null)
3793 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3796 if (__pAddressbar != null && __pWebViewer != null)
3798 SetUrl(__pWebViewer->GetUrl());
3799 __pAddressbar->Invalidate(true);
3804 MainForm::UpdateFavicon(void)
3806 bool urlImageType = false;
3807 String *tempPath = null;
3809 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();");
3810 Bitmap* pBitmap = null;
3812 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3814 if (__pWindowInfo != null)
3817 url.SetUri(*tempPath);
3818 if (url.GetHost().GetLength() == 0)
3821 webUrl.SetUri(__pWebViewer->GetUrl());
3822 result r = url.SetHost(webUrl.GetHost());
3829 if (url.GetScheme().GetLength() == 0)
3832 webUrl.SetUri(__pWebViewer->GetUrl());
3833 url.SetScheme(webUrl.GetScheme());
3835 __pWindowInfo->faviconUrl = url.ToString();
3837 pBitmap = __pWebViewer->GetFaviconN();
3839 if (pBitmap != null)
3841 if (__pWindowInfo->pFavicon != NULL)
3843 __pWindowInfo->pFavicon = null;
3845 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3846 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3848 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3850 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3852 else if(__pWindowInfo->pFavicon != null)
3854 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3858 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3859 if(pDefaultBmp != null)
3861 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3875 if(tempPath != null)
3879 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3885 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3886 Tizen::Web::Controls::WebNavigationType type)
3888 AppLog("urlk %ls",url.GetPointer());
3889 // when load new page if find word panel is open its show state is false
3890 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3892 __currentSearchStr = L"";
3893 __currentWordIndex = 0;
3894 __maxOccurrances = 0;
3895 __pFindWordEditField->SetText(L"");
3896 __pFindWordNext->SetEnabled(false);
3897 __pFindWordPrev->SetEnabled(false);
3898 __pFindWordCountLabel->SetText(L"0/0");
3899 __pFindWordControl->SetShowState(false);
3900 __pFindWordEditField->HideKeypad();
3901 RelayoutControls(false);
3904 __pFooterPanel->Invalidate(true);
3907 uriInfo.SetUri(url);
3909 if(url.Contains(IDS_TIZEN_SERVICE))
3912 String delim(L":;,");
3914 // Creates a StringTokenizer instance
3915 StringTokenizer strTok(url, delim);
3917 int count = strTok.GetTokenCount(); // count == 4
3919 HashMap *pMap = new HashMap();
3925 while (strTok.HasMoreTokens())
3927 AppLog("Token: %ls", token.GetPointer());
3928 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3929 if(token.Contains(IDS_APPID))
3931 token.SubString(6, appId);
3932 AppLog("AppID:%ls", appId.GetPointer());
3934 else if(token.Contains(IDS_KEY))
3936 token.SubString(4, key);
3937 AppLog("key:%ls", key.GetPointer());
3939 else if(token.Contains(IDS_VALUE))
3941 token.SubString(6, value);
3942 AppLog("value:%ls", value.GetPointer());
3945 pMap->Add(key, value);
3949 AppControl *pAppControl = null;
3950 String operationId = L"http://tizen.org/appcontrol/operation/main";
3951 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3954 result r = pAppControl->Start(null, null, pMap, null);
3958 AppLogException("AppControl not found");
3968 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3969 const Tizen::Net::Http::HttpHeader& httpHeader)
3971 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3975 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
3977 if(__isLongPressedDone == false)
3979 AppLog("MainForm::OnWebPageBlockSelected");
3980 if (__pHitElementResult != null)
3982 delete __pHitElementResult;
3983 __pHitElementResult = null;
3986 if (__pWebViewer != null)
3988 AppLog("MainForm::OnWebPageBlockSelected web not null");
3989 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3991 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
3993 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
3994 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3995 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
3997 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
3999 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
4003 if (__pHitElementResult == null)
4008 if (__pHitElementResult->HasImage() != true)
4010 String tagName = __pHitElementResult->GetTagName();
4011 String type = __pHitElementResult->GetAttributeValue("type");
4014 AppLog("TagName %ls",tagName.GetPointer());
4015 __currentSelectedStr.Clear();
4016 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
4017 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4018 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
4020 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
4022 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4024 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),true);
4025 __pImageMenu->SetShowState(true);
4026 __pImageMenu->Show();
4027 __pImageMenu->Invalidate(true);
4029 else /*if(__isLongPressedDone == true)*/
4031 AppLog("MainForm::OnWebPageBlockSelected no paste option");
4033 if(__pHitElementResult->GetUrl().GetLength() > 0)
4035 __currentSelectedStr.Clear();
4036 __currentSelectedStr = __pHitElementResult->GetUrl();
4038 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),false);
4039 __pImageMenu->SetShowState(true);
4040 __pImageMenu->Show();
4041 __pImageMenu->Invalidate(true);
4044 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
4045 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
4046 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
4052 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
4058 MainForm::OnWebWindowCreateRequested(void)
4060 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
4062 if (pNewWindowInfo == null)
4066 result r = E_SUCCESS;
4067 SceneManager* pSceneManager = SceneManager::GetInstance();
4068 if (pSceneManager == NULL)
4072 ArrayList* pArgList = new(std::nothrow) ArrayList();
4073 if (pArgList == NULL)
4077 r = pArgList->Construct();
4080 pNewWindowInfo->isJavascriptInitiated = true;
4081 pArgList->Add(*pNewWindowInfo);
4082 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4086 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
4093 return pNewWindowInfo->pCurrentWeb;
4097 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
4099 AppLog("xyz:: MainForm::RelayoutControls called");
4100 __webControlPosition.y = 0;
4101 __webControlHeight = GetClientAreaBounds().height;
4102 AppLog("Client area height: %d", __webControlHeight);
4104 AppLog("Client area height: %d", __webControlHeight);
4105 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
4107 __webControlPosition.y += __pAddressbar->GetHeight();
4108 __webControlHeight -= __pAddressbar->GetHeight();
4109 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
4111 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
4113 __webControlPosition.y += __pFindWordControl->GetHeight();
4114 __webControlHeight -= __pFindWordControl->GetHeight();
4115 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
4118 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
4120 __webControlHeight -= __pFooterPanel->GetHeight();
4122 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
4124 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
4126 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight + 12 )
4131 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12);
4132 __pWebViewer->Invalidate(false);
4135 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
4137 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
4144 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
4146 if (__pFindWordControl == null)
4151 Tizen::Locales::LocaleManager localeManager;
4152 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
4154 String languageCode;
4155 result r = SettingInfo::GetValue(L"Language", languageCode);
4156 // int languagecode = local.GetLanguageCode();
4157 AppLog("rahul language is %S", languageCode.GetPointer());
4161 InitFindWordPanel();
4163 if (languageCode.CompareTo("ara") == 0)
4165 AppLog("rahul language is arabic");
4167 __pFindWordPanelLeftToRight->SetShowState(false);
4168 __pFindWordPanelRightToLeft->SetShowState(true);
4170 __pFindWordClear->SetShowState(false);
4171 __pFindWordCountLabel->SetShowState(false);
4172 __pFindWordEditField->SetShowState(false);
4174 __pFindWordClearRightToLeft->SetShowState(true);
4175 __pFindWordCountLabelRightToLeft->SetShowState(true);
4176 __pFindWordEditFieldRightToLeft->SetShowState(true);
4180 AppLog("rahul language is not arabic");
4183 __pFindWordPanelLeftToRight->SetShowState(true);
4184 __pFindWordPanelRightToLeft->SetShowState(false);
4186 __pFindWordClear->SetShowState(true);
4187 __pFindWordCountLabel->SetShowState(true);
4188 __pFindWordEditField->SetShowState(true);
4190 __pFindWordClearRightToLeft->SetShowState(false);
4191 __pFindWordCountLabelRightToLeft->SetShowState(false);
4192 __pFindWordEditFieldRightToLeft->SetShowState(false);
4194 __pFindWordControl->SetShowState(true);
4198 if(__pFindWordControl != null)
4200 __pFindWordControl->SetShowState(false);
4204 AppLog("MainForm::ShowFindWordPanel %d",show);
4205 if (show && !isTouchPressed)
4207 if (languageCode.CompareTo("ara") == 0)
4209 if (__pFindWordEditFieldRightToLeft)
4211 __pFindWordEditFieldRightToLeft->SetFocus();
4212 __pFindWordEditFieldRightToLeft->ShowKeypad();
4217 if (__pFindWordEditField)
4219 __pFindWordEditField->SetFocus();
4220 __pFindWordEditField->ShowKeypad();
4226 if (languageCode.CompareTo("ara") == 0)
4228 if (__pFindWordEditFieldRightToLeft)
4229 __pFindWordEditFieldRightToLeft->HideKeypad();
4233 if (__pFindWordEditField)
4234 __pFindWordEditField->HideKeypad();
4238 RelayoutControls(false);
4242 MainForm::StartWordSearch()
4244 //Get the count of occurances of the word in the current page
4245 __maxOccurrances = 0;
4246 __currentWordIndex = 0;
4248 __pFindWordPrev->SetEnabled(false);
4249 String *pCountStr = null;
4250 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
4251 AppLog("Search Result %s",GetErrorMessage(r));
4252 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
4253 if (pCountStr != null)
4255 Integer::Parse(*pCountStr, 10, __maxOccurrances);
4259 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
4264 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
4266 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
4267 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
4269 if(totalCount == -1 || totalCount == 0)
4271 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
4272 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
4275 else if(totalCount > 100)
4277 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4278 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4282 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4283 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4286 __maxOccurrances = totalCount;
4287 __currentWordIndex = currentOrdinal;
4289 //Reset the UI controls as per the maxOccurrance value
4290 if (totalCount <= 0)
4292 AppLog("Word not found");
4293 //Show error notification to user
4294 __pFindWordNext->SetEnabled(false);
4295 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4297 __pFindWordCountLabel->SetText(L"0/0");
4298 __pFindWordCountLabel->Invalidate(false);
4300 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4302 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4303 __pFindWordCountLabelRightToLeft->Invalidate(false);
4305 __pFindWordNext->Invalidate(false);
4306 __pFindWordPrev->Invalidate(false);
4311 if (totalCount == 1)
4313 __pFindWordNext->SetEnabled(false);
4317 __pFindWordNext->SetEnabled(true);
4320 String countStr = L"";
4321 countStr.Append(__currentWordIndex);
4322 countStr.Append(L"/");
4323 countStr.Append(__maxOccurrances);
4324 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4326 __pFindWordCountLabel->SetText(countStr);
4327 __pFindWordCountLabel->Invalidate(false);
4328 __pFindWordCountLabel->Invalidate(false);
4330 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4332 __pFindWordCountLabelRightToLeft->SetText(countStr);
4333 __pFindWordCountLabelRightToLeft->Invalidate(false);
4334 __pFindWordCountLabelRightToLeft->Invalidate(false);
4336 //FindNextWord(true);
4337 //Update the controls
4338 __pFindWordNext->Invalidate(false);
4339 __pFindWordPrev->Invalidate(false);
4344 MainForm::FindNextWord(bool next)
4348 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4349 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4351 if (__currentWordIndex < __maxOccurrances)
4353 __currentWordIndex++;
4359 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4360 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4362 if(__currentWordIndex > 1)
4364 __currentWordIndex--;
4369 String countStr = L"";
4370 countStr.Append(__currentWordIndex);
4371 countStr.Append(L"/");
4372 countStr.Append(__maxOccurrances);
4374 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4376 __pFindWordCountLabel->SetText(countStr);
4377 __pFindWordCountLabel->Invalidate(false);
4379 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4381 __pFindWordCountLabelRightToLeft->SetText(countStr);
4382 __pFindWordCountLabelRightToLeft->Invalidate(false);
4385 if (__currentWordIndex >= __maxOccurrances)
4387 __pFindWordNext->SetEnabled(false);
4391 __pFindWordNext->SetEnabled(true);
4393 if (__currentWordIndex <= 1)
4395 __pFindWordPrev->SetEnabled(false);
4399 __pFindWordPrev->SetEnabled(true);
4401 __pFindWordPrev->Invalidate(false);
4402 __pFindWordNext->Invalidate(false);
4404 __pFindWordControl->Invalidate(true);
4408 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4410 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4411 __isWebKeypadOpened = true;
4412 __pFooterPanel->SetShowState(false);
4413 // OnAddressBarKeypadOpened(*__pAddressbar);
4417 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4419 __isWebKeypadOpened = true;
4420 AppLog("xyz::MainForm::OnWebKeypadOpened");
4422 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4424 __currentSearchStr = L"";
4425 __currentWordIndex = 0;
4426 __maxOccurrances = 0;
4427 __pFindWordEditField->SetText(L"");
4428 __pFindWordNext->SetEnabled(false);
4429 __pFindWordPrev->SetEnabled(false);
4430 __pFindWordCountLabel->SetText(L"0/0");
4431 __pWebViewer->SearchTextAllAsync(L"",false);
4432 __pFindWordControl->SetShowState(false);
4433 __pFindWordEditField->HideKeypad();
4437 if (__pWebViewer != null && __pFooterPanel != null)
4439 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4440 if(__pAddressbar != null)
4442 __pAddressbar->SetShowState(false);
4444 if(__pFindWordControl != null)
4446 __pFindWordControl->SetShowState(false);
4448 __pFooterPanel->SetShowState(false);
4449 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4451 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4453 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4454 // AppLog("omgomgomg");
4460 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4462 AppLog("xyz::MainForm::OnWebKeypadClosed");
4463 AppLog("akjshdasd 4");
4464 __pFooterPanel->SetShowState(true);
4465 // OnAddressBarKeypadClosed(*__pAddressbar);
4466 RelayoutControls(false);
4467 __isWebKeypadOpened = false;
4471 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4473 // RelativeLayout(false);
4474 if(__pWebViewer != null)
4476 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4481 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4483 Control* temp = const_cast< Control* >(&source);
4484 Header* pHeader = dynamic_cast< Header* >(temp);
4485 if (pHeader != null)
4487 //Header double - clicked
4488 AppLog("Header double clicked");
4490 if(__pFindWordControl)
4492 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4493 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4497 AppLog("MainScene::OnTouchDoublePressed");
4501 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4503 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4504 if(TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1)
4506 AppLog("Returning because of more than one touch point.");
4509 __longPressPoint = currentPosition;
4511 if (__pHitElementResult != null)
4513 delete __pHitElementResult;
4514 __pHitElementResult = null;
4517 if (__pWebViewer != null)
4519 AppLog("MainForm::OnTouchLongPressed web not null");
4520 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4523 if (__pHitElementResult == null)
4528 if (__pHitElementResult->HasImage() == true)
4530 if(__pWebViewer != null)
4531 InitImageContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4532 __pImageMenu->SetShowState(true);
4533 __pImageMenu->Show();
4534 __pImageMenu->Invalidate(true);
4536 else if(__pHitElementResult->HasUrl() == true)
4538 String tempURl = __pHitElementResult->GetUrl();
4539 AppLog("tempURl is %ls", tempURl.GetPointer());
4540 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4541 if (pBitmap != null)
4549 InitImageLinkContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4550 __pImageMenu->SetShowState(true);
4551 __pImageMenu->Show();
4552 __pImageMenu->Invalidate(true);
4556 String tagName = __pHitElementResult->GetTagName();
4557 String type = __pHitElementResult->GetAttributeValue("type");
4558 String value = __pHitElementResult->GetAttributeValue(L"value");
4559 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4561 __currentSelectedStr.Clear();
4562 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4564 AppLog("tag name is %ls", tagName.GetPointer());
4565 AppLog("type is %ls", type.GetPointer());
4569 __isLongPressedDone = true;
4570 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4571 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && innerHtml.GetLength() == 0 /*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.CompareTo(L"") == 0 && r == E_INVALID_ARG)
4573 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4575 InitSelectTextContextMenu(Point(currentPosition.x , currentPosition.y + __pWebViewer->GetY()),true, true);
4578 __pImageMenu->SetShowState(true);
4579 __pImageMenu->Show();
4580 __pImageMenu->Invalidate(true);
4583 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4586 // __inputEventToBeSupressed = true;
4590 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4592 AppLog("xyz:: MainForm::OnTouchReleased called");
4594 if (__pAddressbar && __pAddressbar->GetShowState() == true)
4596 __pAddressbar->SetShowState(false);
4598 if(__pFooterPanel && __isWebKeypadOpened == false)
4600 __pFooterPanel->SetShowState(true);
4604 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4605 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4607 __pWebViewer->ConsumeInputEvent();
4609 if(pHitElement != null)
4613 __inputEventToBeSupressed = false;*/
4617 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4624 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4626 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4628 __currentSearchStr = L"";
4629 __currentWordIndex = 0;
4630 __maxOccurrances = 0;
4632 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4634 __pFindWordEditField->SetText(L"");
4635 __pFindWordEditField->HideKeypad();
4636 __pFindWordControl->SetShowState(false);
4637 __pFindWordCountLabel->SetText(L"0/0");
4639 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4641 __pFindWordEditFieldRightToLeft->SetText(L"");
4642 __pFindWordEditFieldRightToLeft->HideKeypad();
4643 __pFindWordControl->SetShowState(false);
4644 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4647 __pFindWordNext->SetEnabled(false);
4648 __pFindWordPrev->SetEnabled(false);
4650 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
4651 __pFindWordControl->SetShowState(false);
4653 if(__pAddressbar->GetShowState() == false)
4655 __pAddressbar->SetAddressbarURLFocus();
4656 __pFooterPanel->SetShowState(false);
4663 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4669 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4675 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4681 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4687 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4693 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4695 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4696 int widthContextItem = 0;
4697 if(__pFindWordCountLabel)
4698 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4699 // As per the platform engineer comment removed this line
4700 /*if(__pWebViewer != null)
4702 // 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
4703 __pWebViewer->ReleaseBlock();
4706 // if(__pFindWordControl != null)
4707 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4708 if(__pNotification && __pNotification->GetShowState() == true)
4710 __pNotification->SetShowState(false);
4711 __pNotification->Invalidate(false);
4713 if ( __pFooterLabel != null)
4715 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4718 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4724 if (__pFindWordBgLabel != null)
4726 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4727 if (pBitmap != null)
4729 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4734 if (__pFindWordBgLabelRightToLeft != null)
4736 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4737 if (pBitmap != null)
4739 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4745 // if(__pOptionMenu != null)
4746 // __pOptionMenu->SetShowState(false);
4748 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4750 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4754 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4759 AppLog("__pFooterPanel->GetShowState() is true");
4761 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4762 __pFooterPanel->Invalidate(true);
4766 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4767 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4769 InitMostVisitedSitesView(orientationStatus);
4772 RelayoutControls(false);
4773 if (__pArticleReaderPanel != null)
4775 if (__pArticleReaderPanel->GetShowState() == true)
4777 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4779 if (__pBlankPanel != null)
4780 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4782 if (__pWebReader != null)
4784 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4786 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4787 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4789 if ( pBitmap != null && pSrcBitmap != null)
4791 AppLog("CreateReaderPanel ninepatchbitmap found");
4792 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4795 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4796 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4797 if (pBitmap != null)
4802 if (pSrcBitmap != null)
4811 if (__pAddressbar != null)
4813 int width = GetClientAreaBounds().width;
4814 __pAddressbar->OrientationChanged(width);
4819 MainForm::OnSettingsChange(int settingvalue)
4821 AppLogDebug("MainForm::OnSettingsChange entered");
4823 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4825 __pAddressbar->ResetGuideText();
4827 if (__pWebViewer == null)
4829 AppLogDebug("Webviewer is not initialized yet.");
4833 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4835 WebSetting settings = __pWebViewer->GetSetting();
4836 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4838 settings.SetAutoFittingEnabled(true);
4840 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
4842 settings.SetAutoFittingEnabled(false);
4844 __pWebViewer->SetSetting(settings);
4846 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4848 WebSetting settings = __pWebViewer->GetSetting();
4849 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4850 __pWebViewer->SetSetting(settings);
4852 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4854 WebSetting settings = __pWebViewer->GetSetting();
4855 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4856 __pWebViewer->SetSetting(settings);
4857 __pWebViewer->Reload();
4859 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4861 WebSetting settings = __pWebViewer->GetSetting();
4862 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4863 __pWebViewer->SetSetting(settings);
4865 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4869 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4872 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
4876 WebSetting settings = __pWebViewer->GetSetting();
4877 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
4878 __pWebViewer->SetSetting(settings);
4881 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
4885 WebSetting settings = __pWebViewer->GetSetting();
4886 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
4887 __pWebViewer->SetSetting(settings);
4890 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4892 WebSetting settings = __pWebViewer->GetSetting();
4893 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4895 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4899 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4901 __pWebViewer->SetSetting(settings);
4903 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4907 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4908 WebSetting settings = __pWebReader->GetSetting();
4909 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4910 __pWebReader->SetSetting(settings);
4916 MainForm::OnSettingsReset()
4920 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4921 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4926 MainForm::OnClearCache()
4928 result r = E_SUCCESS;
4930 if (__pWebViewer != NULL)
4932 r = __pWebViewer->ClearCache();
4935 AppLogDebug("Cache cleared success");
4939 AppLogDebug("Cache cleared fail");
4945 MainForm::OnClearCookie()
4947 result r = E_SUCCESS;
4949 if (__pWebViewer != NULL)
4951 __pWebViewer->ClearCookie();
4955 AppLogDebug("Cookie cleared success");
4959 AppLogDebug("Cache cleared fail");
4964 MainForm::OnClearFormData()
4966 result r = E_SUCCESS;
4968 if (__pWebViewer != NULL)
4970 __pWebViewer->ClearFormData();
4974 AppLogDebug("Cookie cleared success");
4978 AppLogDebug("Cache cleared fail");
4983 MainForm::OnClearPasswords()
4985 result r = E_SUCCESS;
4987 if (__pWebViewer != NULL)
4989 __pWebViewer->ClearLoginFormData();
4993 AppLogDebug("Cookie cleared success");
4997 AppLogDebug("Cache cleared fail");
5003 MainForm::findDistance(int x1,int y1,int x2, int y2)
5005 int deltaX = Math::Abs(x2 - x1);
5006 int deltaY = Math::Abs(y2 - y1);
5007 double num = deltaX*deltaX + deltaY*deltaY;
5013 for (i = 0; i < 20; i++)
5015 x = (((x*x)+ num)/(2*x));
5026 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5028 AppLog("xyz:: MainForm::OnTouchPressed called");
5029 if(__pFindWordControl)
5031 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
5032 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
5034 __isLongPressedDone = false;
5039 IList* pList = null;
5040 pList = touch.GetTouchInfoListN(source);
5044 int count = pList->GetCount();
5047 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5048 __touchPoint1 = pTouchInfo->position;
5050 /*if (__pAddressbar != null)
5052 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5054 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5056 __pAddressbar->SaveAddressbarEditText();
5058 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5061 __pAddressbar->Invalidate(true);
5063 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5065 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5067 //__pAddressbar->SaveAddressbarEditText();
5069 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5072 else if (count == 2)
5074 AppLogDebug("MainForm::OnTouchPressed count is two");
5075 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5076 __touchPoint1 = pTouchInfo->position;
5078 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
5079 __touchPoint2 = pTouchInfo->position;
5084 pList->RemoveAll(true);
5089 __pAddressbar->SetShowState(false);
5091 if(__pFooterPanel && __isWebKeypadOpened == false)
5093 __pFooterPanel->SetShowState(true);
5095 RelayoutControls(false);
5100 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5102 // __currentWordIndex = 0;
5103 __isLongPressedDone = false;
5108 MainForm::MoveUiControls()
5113 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
5115 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
5117 if(__pFooterUrlField->GetTextLength() == 0)
5119 __pFooterUrlField->SetKeypadActionEnabled(false);
5123 __pFooterUrlField->SetKeypadActionEnabled(true);
5126 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
5128 __currentSearchStr = __pFindWordEditField->GetText();
5129 if (__currentSearchStr.GetLength() > 0)
5131 __pFindWordCountLabel->SetShowState(true);
5135 __pFindWordCountLabel->SetShowState(false);
5137 __pFindWordNext->SetEnabled(false);
5138 __pFindWordPrev->SetEnabled(false);
5139 __pFindWordNext->Invalidate(true);
5140 __pFindWordPrev->Invalidate(true);
5141 __pFindWordCountLabel->SetText(L"0/0");
5142 __pFindWordCountLabel->Invalidate(true);
5144 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
5146 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
5147 if (__currentSearchStr.GetLength() > 0)
5149 __pFindWordCountLabelRightToLeft->SetShowState(true);
5153 __pFindWordCountLabelRightToLeft->SetShowState(false);
5156 __pFindWordNext->SetEnabled(false);
5157 __pFindWordPrev->SetEnabled(false);
5158 __pFindWordNext->Invalidate(true);
5159 __pFindWordPrev->Invalidate(true);
5160 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
5161 __pFindWordCountLabelRightToLeft->Invalidate(true);
5163 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
5164 if (__currentSearchStr.GetLength() > 0)
5170 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
5172 __currentSearchStr = L"";
5173 AppLogDebug("Enter something");
5178 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
5185 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
5187 if(__pWebViewer != null)
5190 AppLog("MainForm::InitMostVisitedSitesView");
5191 result r = E_SUCCESS;
5194 if (__pWebViewer != null && __pMostVisitedListView != null)
5199 if (__pMostVisitedListView != null)
5201 RemoveControl(__pMostVisitedListView);
5203 if(__pMostVisitedSites != null)
5205 __pMostVisitedSites->RemoveAll(true);
5208 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
5210 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
5211 __pMostVisitedListView = new(std::nothrow) ListView();
5213 int height = GetClientAreaBounds().height;
5215 if(__pFooterPanel->GetShowState() == true)
5217 height = height - __pFooterPanel->GetHeight();
5219 if(__pAddressbar->GetShowState() == true)
5221 height -= __pAddressbar->GetHeight();
5224 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
5228 delete __pMostVisitedListView;
5229 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
5232 __pMostVisitedListView->SetItemProvider(*this);
5233 __pMostVisitedListView->AddListViewItemEventListener(*this);
5234 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_VISITED_SITES"));
5235 AddControl(__pMostVisitedListView);
5236 __pMostVisitedListView->UpdateList();
5243 MainForm::GetImagePath(void)
5247 String formattedTime;
5248 DateTime currentTime;
5249 LocaleManager localManager;
5250 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
5252 localManager.Construct();
5253 Locale locale = localManager.GetSystemLocale();
5254 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
5256 // Get date formatter
5257 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
5261 pTimeFormatter->Format(currentTime, formattedTime);
5264 AppLog("current time stamp is %ls", formattedTime.GetPointer());
5265 String delim(L" :");
5266 StringTokenizer strTok(formattedTime, delim);
5269 String str1("GMT+00");
5270 while (strTok.HasMoreTokens())
5272 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
5273 if(token.Equals(str1))
5275 AppLog("token is %ls", token.GetPointer());
5276 imageName.Append(token);
5282 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
5284 result r = E_FAILURE;
5285 AppLog("Content manager 1");
5286 ContentId contentId;
5287 ContentManager contentManager;
5288 r = contentManager.Construct();
5291 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
5294 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
5295 Tizen::Io::Directory::Create(contentPath,true);
5296 if(GetLastResult() == E_FILE_ALREADY_EXIST)
5298 AppLog("Already exists");
5300 else if(GetLastResult() == E_SUCCESS)
5302 AppLog("created success");
5304 contentPath.Append(imageName);
5305 contentPath.Append(".jpg");
5306 contentId = contentManager.CreateContent(*aBuffer, contentPath);
5307 ShowIndicatorNotification(L"Download Complete",contentPath);
5308 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5312 MainForm::ShowIndicatorNotification(const String& messageText, const String& contentPath)
5314 AppLogDebug("ENTER");
5316 NotificationRequest request;
5317 request.SetAlertText(messageText);
5318 request.SetTitleText(L"");
5319 request.SetAppMessage(contentPath);
5320 request.SetOngoingActivityType(ONGOING_ACTIVITY_TYPE_TEXT);
5321 request.SetNotificationStyle(NOTIFICATION_STYLE_THUMBNAIL);
5322 Tizen::App::App* pApp = Tizen::App::App::GetInstance();
5323 String homePath = pApp->GetAppRootPath();
5324 String iconPath = homePath + L"res/screen-density-xhigh/Notification_download_complete.png";
5325 AppLog("The iconPath is : %ls", homePath.GetPointer());
5326 request.SetIconFilePath(iconPath);
5328 Tizen::Shell::NotificationManager notiMgr;
5329 notiMgr.Construct();
5330 notiMgr.NotifyOngoingActivity(request);
5332 AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));
5337 MainForm::SetForwardButtonEnabled(bool isEnabled)
5339 __pGoForwardBtn->SetEnabled(isEnabled);
5340 __pGoForwardBtn->Invalidate(true);
5344 MainForm::SetBackButtonEnabled(bool isEnabled)
5346 __pGoBackBtn->SetEnabled(isEnabled);
5347 __pGoBackBtn->Invalidate(true);
5351 MainForm::UpdateProgress(int percentage)
5353 __progressPercentage = percentage;
5354 if (percentage == 0 || percentage == 100)
5356 __isLoadingData = false;
5357 if (percentage == 100)
5359 __isLoadingCompleted = true;
5360 __progressPercentage = 0;
5364 __isLoadingCompleted = false;
5369 __isLoadingData = true;
5371 UpdateProgressBitmap();
5375 MainForm::GetProgress(void)
5377 return __progressPercentage;
5381 MainForm::UpdateProgressBitmap(void)
5383 result r = E_SUCCESS;
5384 if (__pProgressbarLabel == null)
5386 int w = __pProgressbarLabel->GetWidth();
5387 int h = __pProgressbarLabel->GetHeight();
5389 int progressWidth = 0;
5390 Bitmap* pRetBitmap = null;
5392 if (__progressPercentage == 0 || __progressPercentage == 100)
5394 __pProgressbarLabel->SetShowState(false);
5395 __pProgressbarLabel->Invalidate(false);
5400 __pProgressbarLabel->SetShowState(true);
5401 __pProgressbarLabel->Invalidate(false);
5404 r = canvas.Construct(Rectangle(0, 0, w, h));
5408 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5413 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5417 pBgBmp->Scale(Dimension(w, h));
5418 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5422 progressWidth = (double) (w) * __progressPercentage / 100;
5423 AppLogDebug("progressWidth: %d", progressWidth);
5424 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5426 if (pProgressBmp != null)
5428 pProgressBmp->Scale(Dimension(progressWidth, h));
5429 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5430 delete pProgressBmp;
5433 pRetBitmap = new (std::nothrow) Bitmap();
5435 if (pRetBitmap == null)
5437 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5441 pRetBitmap->Construct(canvas, canvas.GetBounds());
5443 if (__pProgressbarLabel != null && pRetBitmap != null)
5445 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5446 __pProgressbarLabel->Invalidate(false);
5449 if (pRetBitmap != null)
5458 MainForm::ReaderClicked()
5460 result r = E_SUCCESS;
5461 ArrayList* pArgList = new(std::nothrow) ArrayList();
5462 if (pArgList != null)
5464 r = pArgList->Construct();
5471 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5478 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5485 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5493 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5499 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5501 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5503 __currentAddMode = addMode;
5507 case ADDRESSBAR_MODE_INVALID:
5512 case ADDRESSBAR_MODE_READER:
5514 __pStopBtn->SetShowState(false);
5515 __pRefreshBtn->SetShowState(false);
5516 __pClearBtn->SetShowState(false);
5517 __pReaderBtn->SetShowState(false);
5520 case ADDRESSBAR_MODE_LOADING:
5522 __pRefreshBtn->SetShowState(false);
5523 __pStopBtn->SetShowState(true);
5524 __pClearBtn->SetShowState(false);
5525 __pReaderBtn->SetShowState(false);
5528 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5530 // SetUrl(__pAddressbar->GetUrl());
5532 __pRefreshBtn->SetShowState(true);
5533 __pStopBtn->SetShowState(false);
5534 __pClearBtn->SetShowState(false);
5535 __pReaderBtn->SetShowState(false);
5538 case ADDRESSBAR_MODE_EDIT:
5540 __pRefreshBtn->SetShowState(false);
5541 __pStopBtn->SetShowState(false);
5542 __pReaderBtn->SetShowState(false);
5543 __pClearBtn->SetShowState(true);
5550 OnAddressBarModeChanged();
5553 AddressBarMode MainForm::GetAddressbarMode(void)
5555 return __currentAddMode;
5558 void MainForm::SetUrl(const String& url)
5561 if(__displayUrl.GetLength() > 2048)
5562 __displayUrl.SubString(0,2048,__displayUrl);
5564 if (__pFooterUrlField != NULL)
5566 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5567 if (removedHttpUrl.IsEmpty() == false)
5569 __pFooterUrlField->SetText(removedHttpUrl);
5570 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5571 __pAddressbar->SetUrl(__displayUrl);
5575 __pFooterUrlField->SetText(__displayUrl);
5576 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5577 __pAddressbar->SetUrl(__displayUrl);
5579 if(__pFooterUrlField)
5580 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5581 __pFooterUrlField->Invalidate(false);
5582 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5583 __pAddressbar->Invalidate(true);
5584 // __pFooterUrlField->SetCursorPosition(0);
5589 MainForm::RemoveHttpTextFromDisplayURL(void)
5591 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5593 // bool isHttpText = __displayUrl.Contains(L"http://");
5594 String updatedDisplayUrl;
5595 updatedDisplayUrl.Clear();
5596 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5598 __displayUrl.SubString(7,updatedDisplayUrl);
5600 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5602 __displayUrl.SubString(8,updatedDisplayUrl);
5604 return updatedDisplayUrl;
5607 void MainForm::OnSharePopupControlStarted(void)
5609 __pWebViewer->AddTouchEventListener(*this);
5613 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5615 if (requestId == BACK_GROUND_APP_EVENT)
5617 if(__pWebViewer != null)
5619 __pWebViewer->Pause();
5621 if(__pAddressbar != null)
5623 __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5626 else if(requestId == FORE_GROUND_APP_EVENT)
5628 if(__pWebViewer != null)
5630 __pWebViewer->Resume();
5632 if(__pAddressbar != null)
5634 __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5640 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5642 AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5643 result r = E_SUCCESS;
5646 __pAddressbar->SetShowState(false);
5648 AppLog("akjshdasd 5");
5649 __pFooterPanel->SetShowState(true);
5652 __pWebViewer->SetFocus();
5653 else if(__pMostVisitedListView)
5654 __pMostVisitedListView->SetFocus();
5655 else if(__pMultiWindowButton)
5656 __pMultiWindowButton->SetFocus();
5657 else if(__pMoreButton)
5658 __pMoreButton->SetFocus();
5660 __pAddressbar->SetShowState(false);
5662 RelayoutControls(false);
5666 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5668 AppLog("MainForm::OnFormMenuRequested called");
5670 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer && __pWebViewer->GetShowState() == true)
5672 int bookmarkCount=0;
5675 url=__pWindowInfo->pageUrl;
5676 AppLog("MainForm::OnFormMenuRequested url %ls",url.GetPointer());
5677 result r = E_SUCCESS;
5678 Bitmap* pBitmap = null;
5679 String lastChar = L"";
5680 // if(url.SubString(url.GetLength()-1,lastChar));
5681 // if(lastChar == L"/")
5683 // bool exist1 = false;
5684 // bool exist2 = false;
5685 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist1);
5686 // url.SubString(0,url.GetLength() - 1,url);
5687 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist2);
5688 // exist = exist1 | exist2;
5692 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5695 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5701 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5705 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5707 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5709 if (__pOptionMenu->GetItemCount() == 9)
5711 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5715 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5720 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
5724 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
5725 if (__pOptionMenu->GetItemCount() != 9)
5727 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
5728 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
5729 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
5730 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
5731 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
5732 __pOptionMenu->SetMaxVisibleItemsCount(6);
5734 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
5736 AppLog(" Orientation landscape");
5737 __pOptionMenu->SetMaxVisibleItemsCount(5);
5741 AppLog(" Orientation potrait");
5742 __pOptionMenu->SetMaxVisibleItemsCount(6);
5745 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
5748 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
5749 __pOptionMenu->SetShowState(true);
5750 __pOptionMenu->Invalidate(true);
5751 __pOptionMenu->Show();