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->isJavascriptInitiated == true)
2804 __pWindowInfo->pCurrentWeb = __pWebViewer;
2808 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2809 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2810 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2812 InitMostVisitedSitesView(GetOrientationStatus());
2814 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2816 if(__pMostVisitedListView != null)
2818 __pMostVisitedListView->SetShowState(false);
2822 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2824 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2826 if (pBookmarkUrl == null)
2828 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2829 //__pAddressbar->SetUrl(*pBookmarkUrl);
2830 SetUrl(*pBookmarkUrl);
2832 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2833 __pWebViewer->LoadUrl(*pBookmarkUrl);
2834 delete pBookmarkUrl;
2837 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2838 Bitmap* pBitmap = null;
2839 if (isPrivateBrowsing == true)
2841 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2843 if (__pWebViewer != null)
2845 __pWebViewer->SetPrivateBrowsingEnabled(true);
2848 if (__pAddressbar != null)
2850 // __pAddressbar->UpdateFaviconBitmap(true);
2856 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2858 if (__pWebViewer != null)
2860 __pWebViewer->SetPrivateBrowsingEnabled(false);
2863 if (__pAddressbar != null)
2865 // __pAddressbar->UpdateFaviconBitmap(false);
2869 if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
2871 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2873 else if (__pOptionMenu != null )
2875 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2878 if (pBitmap != null)
2883 AppLog("ABC: OnSceneActivatedN started exit");
2888 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2889 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2891 Canvas* pWebCanvas = null;
2892 if (__pWebViewer != null)
2894 pWebCanvas = __pWebViewer->GetCanvasN();
2897 if (pWebCanvas == null)
2901 if (__pWindowInfo != null)
2903 if (__pWindowInfo->pWebCanvasBitmap != null)
2905 delete __pWindowInfo->pWebCanvasBitmap;
2907 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2908 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2909 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2911 Bitmap* pBitmap = GetCapturedBitmapN();
2912 AppLog("Coming here");
2913 Canvas* pCanvas = new(std::nothrow) Canvas();
2914 pCanvas->Construct(GetClientAreaBounds());
2917 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2920 if(__pWebViewer != null && __pWindowInfo != null)
2921 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2923 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2924 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2927 AppLog("Coming here");
2931 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2932 const Tizen::Base::String& realm,
2933 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2939 MainForm::OnHttpAuthenticationCanceled(void)
2944 MainForm::OnLoadingStarted(void)
2946 AppLogDebug("MainForm::OnLoadingStarted entered");
2948 if(__pAddressbar == NULL || __pWebViewer == null)
2953 // this is added in case if menu is opened and user load the page
2954 if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
2956 __pOptionMenu->SetShowState(false);
2957 __pOptionMenu->Invalidate(true);
2962 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2964 __pImageMenu->SetShowState(false);
2965 __pImageMenu->Invalidate(true);
2967 String url = __pWebViewer->GetUrl();
2968 if(url.Contains(IDS_TIZEN_SERVICE))
2971 String delim(L":;,");
2973 // Creates a StringTokenizer instance
2974 StringTokenizer strTok(url, delim);
2976 int count = strTok.GetTokenCount(); // count == 4
2978 HashMap *pMap = new HashMap();
2983 while (strTok.HasMoreTokens())
2985 AppLog("Token: %ls", token.GetPointer());
2986 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2987 if(token.Contains(IDS_APPID))
2989 token.SubString(6, appId);
2990 AppLog("AppID:%ls", appId.GetPointer());
2992 else if(token.Contains(IDS_KEY))
2994 token.SubString(4, key);
2995 AppLog("key:%ls", key.GetPointer());
2997 else if(token.Contains(IDS_VALUE))
2999 token.SubString(6, value);
3000 AppLog("value:%ls", value.GetPointer());
3003 pMap->Add(key, value);
3007 AppControl *pAppControl = null;
3008 String operationId = L"http://tizen.org/appcontrol/operation/main";
3009 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3012 AppLog("Starting AppControl");
3013 result r = pAppControl->Start(null, null, pMap, null);
3014 AppLog("Result of Start %s", GetErrorMessage(r));
3018 AppLogException("AppControl not found");
3023 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
3025 __pAddressbar->SetShowState(false);
3026 AddressBarCancelledClicked(*__pAddressbar);
3027 __pAddressbar->Invalidate(true);
3029 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
3032 __pAddressbar->SetFaviconBitmap(*pBitmap);
3035 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
3037 // updating the address bar position with respect to web control
3038 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
3039 __distanceMoved = 0;
3043 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3044 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3045 if (__pWebViewer != null)
3047 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
3048 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
3049 SetUrl(__pWebViewer->GetUrl());
3050 if (__pWindowInfo != NULL)
3052 // resetting the page title to blank, it will be received in OnPageTitleReceived()
3053 __pWindowInfo->pageTitle = L"";
3054 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3056 __pAddressbar->Invalidate(true);
3062 MainForm::OnLoadingCanceled(void)
3069 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
3071 AppLog("XYZ::MainForm::OnKeypadWillOpen");
3076 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
3078 AppLog("XYZ::MainForm::OnKeypadOpened");
3079 __pFooterPanel->SetShowState(false);
3084 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
3086 AppLog("XYZ::MainForm::OnKeypadClosed");
3087 __pFooterPanel->SetShowState(true);
3088 RelayoutControls(true);
3092 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
3094 AppLog("XYZ::KeypadBoundsChanged");
3095 RelayoutControls(false);
3099 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
3100 const Tizen::Base::String& reason)
3102 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
3106 MainForm::OnLoadingCompleted(void)
3108 AppLog("MainForm::OnLoadingCompleted start");
3110 result r = E_SUCCESS;
3112 if (__pWebViewer == null)
3117 if (__pAddressbar == null)
3122 if(__pImageMenu && __pImageMenu->GetShowState())
3124 __pImageMenu->SetShowState(false);
3125 __pImageMenu->Invalidate(true);
3128 if (__pWebViewer->CanGoForward())
3130 //__pAddressbar->SetForwardButtonEnabled(true);
3131 SetForwardButtonEnabled(true);
3135 //__pAddressbar->SetForwardButtonEnabled(false);
3136 SetForwardButtonEnabled(false);
3139 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3141 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3143 //__pAddressbar->UpdateProgress(0);
3147 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3149 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3153 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
3154 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
3155 if (isPrivateBrowsing == false)
3157 if(__pHistory != null)
3163 __pHistory = new(std::nothrow) History;
3164 HistoryPresentationModel::GetCurrentDateTime(date);
3167 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
3168 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
3170 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
3171 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3173 __pHistory->SetVisitedTime(date);
3175 if (__pWebViewer != null)
3177 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3179 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3180 if (pTempBitmap != null)
3182 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3183 __pHistory->SetFavIconBitmap(*pTempBitmap);
3186 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3189 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3190 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3191 if ( pCanvas != null && pCanvas != null && pBitmap != null)
3193 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3194 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3195 __pHistory->SetThumbnail(pBitmap);
3197 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3200 __pHistory->SetFavIconBitmap(*pFavIcon);
3204 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3211 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3213 // temperary fixed (webpage can be not loaded)
3217 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3218 if (isReaderEnabled == true)
3222 delete __pReaderData;
3223 __pReaderData = null;
3225 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3226 filePath.Append(L"data/reader.js");
3232 result r = E_SUCCESS;
3233 FileAttributes attr;
3235 File::GetAttributes(filePath,attr);
3237 r = file.Construct(filePath, L"r+");
3240 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3243 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3246 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3249 // file.Read(pScript,attr.GetFileSize());
3251 // AppLogDebug("scipt length %d",strlen(pScript));
3252 String strScript = L"";
3253 // strScript.Append(pScript);
3254 // for(int i=0; i<25; i++)
3256 file.Read(pScript,attr.GetFileSize());
3257 // AppLog("xyzz tell %d",file.Tell());
3258 // r = strScript.Append(pScript);
3259 // AppLog("xyzz append result %s",GetErrorMessage(r));
3260 // AppLog("xyzz strScript length %d",strScript.GetLength());
3262 // AppLog("xyzz final strScript length %d",strScript.GetLength());
3264 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3265 if (__pReaderData == null)
3267 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3268 __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>");
3271 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3272 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3274 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3275 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3281 AppLog("MainForm::OnLoadingCompleted done");
3285 MainForm::OnEstimatedProgress(int progress)
3287 AppLogDebug("MainForm::OnEstimatedProgress entered");
3289 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3290 progress = DEFAULT_PROGRESS_PERCENTAGE;
3292 // __pAddressbar->UpdateProgress(progress);
3293 UpdateProgress(progress);
3296 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3298 AppLog("MainForm::OnFaviconReceived");
3299 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3301 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3304 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3311 MainForm::OnUrlValueChanged(Addressbar&)
3317 MainForm::OnUrlSubmitted(Addressbar& addBar)
3319 AppLog("MainForm::OnUrlSubmitted");
3320 String url = addBar.GetUrl();
3321 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3323 if(__pFooterUrlField)
3324 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3325 AddressBarCancelledClicked(*__pAddressbar);
3330 MainForm::LoadUrl(String& url)
3334 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3335 AppLogDebug("MainForm::LoadUrl enter");
3337 if (__pWebViewer != null)
3339 __pWebViewer->SetShowState(true);
3340 __pWebViewer->Invalidate(true);
3343 if (url.CompareTo(L"") == 0)
3347 if(__pFooterPanel != null)
3349 __pFooterPanel->SetShowState(true);
3350 __pFooterPanel->Invalidate(true);
3357 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3358 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)
3360 RegularExpression firstRegex;
3361 RegularExpression secondRegex;
3363 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3364 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3367 ret = firstRegex.Match(url, false); // This returns true value
3368 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3370 if (ret == true && __pWebViewer != null)
3373 __pWebViewer->LoadUrl(url);
3375 else if(__pWebViewer != null)
3377 String tempUrl = L"http://";
3378 tempUrl.Append(url);
3382 __pWebViewer->LoadUrl(tempUrl);
3386 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3387 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3390 if (__pAddressbar != null)
3392 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3393 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3396 AppLogDebug("MainForm::LoadUrl exit");
3403 MainForm::OnFocusGained(const Tizen::Ui::Control& source)
3407 __pFooterPanel->SetShowState(false);
3412 __pAddressbar->SetShowState(true);
3413 __pAddressbar->SetAddressbarURLFocus();
3415 RelayoutControls(false);
3419 MainForm::OnFocusLost(const Tizen::Ui::Control& source)
3425 MainForm::OnStopClicked(Addressbar& addBar)
3427 AppLogDebug("MainForm::OnStopClicked called");
3430 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3431 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3432 __pWebViewer->StopLoading();
3433 RequestRedraw(true);
3438 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3440 // AppLog("MainForm::OnBackClicked");
3441 result r = E_FAILURE;
3442 if(__pImageMenu && __pImageMenu->GetShowState() == true)
3444 AppLog("Hiding the menu");
3445 __pImageMenu->SetShowState(false);
3448 if (__pWebViewer && __pWebViewer->CanGoBack())
3450 __pWebViewer->GoBack();
3452 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3455 pApp = UiApp::GetInstance();
3459 RemoveOrientationEventListener(*this);
3463 __pAddressbar->SetAddressbarEventListener(null);
3468 __pWebViewer->RemoveTouchEventListener(*this);
3469 __pWebViewer->SetWebUiEventListenerF(null);
3470 __pWebViewer->SetWebKeypadEventListener(null);
3471 __pWebViewer->SetTextSearchListener(null);
3472 __pWebViewer->SetLoadingListener(null);
3476 r = pApp->Terminate();
3479 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3487 WindowInfo* pWindowInfo = null;
3489 SceneManager* pSceneManager = SceneManager::GetInstance();
3490 if (pSceneManager == null)
3494 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3495 if (pAllWindowList == NULL)
3497 pApp = UiApp::GetInstance();
3500 RemoveOrientationEventListener(*this);
3504 __pAddressbar->SetAddressbarEventListener(null);
3509 __pWebViewer->RemoveTouchEventListener(*this);
3510 __pWebViewer->SetWebUiEventListenerF(null);
3511 __pWebViewer->SetWebKeypadEventListener(null);
3512 __pWebViewer->SetTextSearchListener(null);
3513 __pWebViewer->SetLoadingListener(null);
3517 r = pApp->Terminate();
3520 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3525 if (pAllWindowList != null)
3527 totalCount = pAllWindowList->GetCount();
3529 for (int count = 0; count < totalCount; count++)
3531 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3532 if (pWindowInfo == null)
3534 pApp = UiApp::GetInstance();
3537 RemoveOrientationEventListener(*this);
3541 __pAddressbar->SetAddressbarEventListener(null);
3546 __pWebViewer->RemoveTouchEventListener(*this);
3547 __pWebViewer->SetWebUiEventListenerF(null);
3548 __pWebViewer->SetWebKeypadEventListener(null);
3549 __pWebViewer->SetTextSearchListener(null);
3550 __pWebViewer->SetLoadingListener(null);
3554 r = pApp->Terminate();
3557 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3562 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3564 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3567 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3570 r = pAllWindowList->RemoveAt(count, true);
3571 __pWindowInfo = null;
3574 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3579 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3581 else if(pAllWindowList->GetCount() > 0)
3583 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3587 pApp = UiApp::GetInstance();
3590 RemoveOrientationEventListener(*this);
3594 __pAddressbar->SetAddressbarEventListener(null);
3599 __pWebViewer->RemoveTouchEventListener(*this);
3600 __pWebViewer->SetWebUiEventListenerF(null);
3601 __pWebViewer->SetWebKeypadEventListener(null);
3602 __pWebViewer->SetTextSearchListener(null);
3603 __pWebViewer->SetLoadingListener(null);
3607 r = pApp->Terminate();
3612 if (pWindowInfo == null)
3614 pApp = UiApp::GetInstance();
3617 RemoveOrientationEventListener(*this);
3621 __pAddressbar->SetAddressbarEventListener(null);
3626 __pWebViewer->RemoveTouchEventListener(*this);
3627 __pWebViewer->SetWebUiEventListenerF(null);
3628 __pWebViewer->SetWebKeypadEventListener(null);
3629 __pWebViewer->SetTextSearchListener(null);
3630 __pWebViewer->SetLoadingListener(null);
3634 r = pApp->Terminate();
3640 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3643 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3657 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3659 AppLog("MainForm::OnForwardClicked");
3660 if (__pWebViewer == null)
3663 if (__pWebViewer->CanGoForward())
3665 __pWebViewer->GoForward();
3670 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3672 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3673 if(__pFooterPanel != null)
3675 __pFooterPanel->SetShowState(false);
3678 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3680 __pAddressbar->SetShowState(true);
3681 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3684 RelayoutControls(false);
3688 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3690 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3692 int Height = GetClientAreaBounds().height;
3693 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3695 RelayoutControls(false);
3699 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3701 AddressBarCancelledClicked(addBar);
3705 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3707 __prevAddressBarMode = __curAddressBarMode;
3709 if (__pAddressbar != null)
3711 __curAddressBarMode = GetAddressbarMode();
3714 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3716 __adressPanelPosition.y = 0;
3717 if (__pAddressbar != null)
3719 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3720 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3721 __pAddressbar->Invalidate(true);
3723 if (__pWebViewer != null)
3725 __pWebViewer->StopLoading();
3728 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3730 __adressPanelPosition.y = 0;
3731 if (__pAddressbar != null)
3733 __webControlPosition.y = 0;
3734 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3735 __pAddressbar->Invalidate(true);
3741 MainForm::OnClipboardClosed(const Addressbar& addBar)
3743 AppLog("XYZ::MainForm::OnClipboardClosed");
3744 RelayoutControls(false);
3748 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3750 AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3751 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3753 AppLog("akjshdasd 3");
3754 __pFooterPanel->SetShowState(true);
3757 RelayoutControls(false,footerState);
3761 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3763 AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3764 RelayoutControls(false);
3768 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3770 __pFooterPanel->SetShowState(false);
3774 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3776 AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3777 RelayoutControls(false);
3781 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3783 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3786 __pWindowInfo->pageTitle = title;
3787 if (__pWebViewer != null)
3789 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3792 if (__pAddressbar != null && __pWebViewer != null)
3794 SetUrl(__pWebViewer->GetUrl());
3795 __pAddressbar->Invalidate(true);
3800 MainForm::UpdateFavicon(void)
3802 bool urlImageType = false;
3803 String *tempPath = null;
3805 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();");
3806 Bitmap* pBitmap = null;
3808 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3810 if (__pWindowInfo != null)
3813 url.SetUri(*tempPath);
3814 if (url.GetHost().GetLength() == 0)
3817 webUrl.SetUri(__pWebViewer->GetUrl());
3818 result r = url.SetHost(webUrl.GetHost());
3825 if (url.GetScheme().GetLength() == 0)
3828 webUrl.SetUri(__pWebViewer->GetUrl());
3829 url.SetScheme(webUrl.GetScheme());
3831 __pWindowInfo->faviconUrl = url.ToString();
3833 pBitmap = __pWebViewer->GetFaviconN();
3835 if (pBitmap != null)
3837 if (__pWindowInfo->pFavicon != NULL)
3839 __pWindowInfo->pFavicon = null;
3841 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3842 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3844 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3846 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3848 else if(__pWindowInfo->pFavicon != null)
3850 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3854 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3855 if(pDefaultBmp != null)
3857 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3871 if(tempPath != null)
3875 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3881 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3882 Tizen::Web::Controls::WebNavigationType type)
3884 AppLog("urlk %ls",url.GetPointer());
3885 // when load new page if find word panel is open its show state is false
3886 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3888 __currentSearchStr = L"";
3889 __currentWordIndex = 0;
3890 __maxOccurrances = 0;
3891 __pFindWordEditField->SetText(L"");
3892 __pFindWordNext->SetEnabled(false);
3893 __pFindWordPrev->SetEnabled(false);
3894 __pFindWordCountLabel->SetText(L"0/0");
3895 __pFindWordControl->SetShowState(false);
3896 __pFindWordEditField->HideKeypad();
3897 RelayoutControls(false);
3900 __pFooterPanel->Invalidate(true);
3903 uriInfo.SetUri(url);
3905 if(url.Contains(IDS_TIZEN_SERVICE))
3908 String delim(L":;,");
3910 // Creates a StringTokenizer instance
3911 StringTokenizer strTok(url, delim);
3913 int count = strTok.GetTokenCount(); // count == 4
3915 HashMap *pMap = new HashMap();
3921 while (strTok.HasMoreTokens())
3923 AppLog("Token: %ls", token.GetPointer());
3924 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3925 if(token.Contains(IDS_APPID))
3927 token.SubString(6, appId);
3928 AppLog("AppID:%ls", appId.GetPointer());
3930 else if(token.Contains(IDS_KEY))
3932 token.SubString(4, key);
3933 AppLog("key:%ls", key.GetPointer());
3935 else if(token.Contains(IDS_VALUE))
3937 token.SubString(6, value);
3938 AppLog("value:%ls", value.GetPointer());
3941 pMap->Add(key, value);
3945 AppControl *pAppControl = null;
3946 String operationId = L"http://tizen.org/appcontrol/operation/main";
3947 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3950 result r = pAppControl->Start(null, null, pMap, null);
3954 AppLogException("AppControl not found");
3964 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3965 const Tizen::Net::Http::HttpHeader& httpHeader)
3967 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3971 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
3973 if(__isLongPressedDone == false)
3975 AppLog("MainForm::OnWebPageBlockSelected");
3976 if (__pHitElementResult != null)
3978 delete __pHitElementResult;
3979 __pHitElementResult = null;
3982 if (__pWebViewer != null)
3984 AppLog("MainForm::OnWebPageBlockSelected web not null");
3985 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3987 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
3989 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
3990 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3991 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
3993 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
3995 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
3999 if (__pHitElementResult == null)
4004 if (__pHitElementResult->HasImage() != true)
4006 String tagName = __pHitElementResult->GetTagName();
4007 String type = __pHitElementResult->GetAttributeValue("type");
4010 AppLog("TagName %ls",tagName.GetPointer());
4011 __currentSelectedStr.Clear();
4012 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
4013 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4014 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
4016 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
4018 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4020 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),true);
4021 __pImageMenu->SetShowState(true);
4022 __pImageMenu->Show();
4023 __pImageMenu->Invalidate(true);
4025 else /*if(__isLongPressedDone == true)*/
4027 AppLog("MainForm::OnWebPageBlockSelected no paste option");
4029 if(__pHitElementResult->GetUrl().GetLength() > 0)
4031 __currentSelectedStr.Clear();
4032 __currentSelectedStr = __pHitElementResult->GetUrl();
4034 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),false);
4035 __pImageMenu->SetShowState(true);
4036 __pImageMenu->Show();
4037 __pImageMenu->Invalidate(true);
4040 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
4041 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
4042 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
4048 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
4054 MainForm::OnWebWindowCreateRequested(void)
4056 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
4058 if (pNewWindowInfo == null)
4062 result r = E_SUCCESS;
4063 SceneManager* pSceneManager = SceneManager::GetInstance();
4064 if (pSceneManager == NULL)
4068 ArrayList* pArgList = new(std::nothrow) ArrayList();
4069 if (pArgList == NULL)
4073 r = pArgList->Construct();
4076 pNewWindowInfo->isJavascriptInitiated = true;
4077 pArgList->Add(*pNewWindowInfo);
4078 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4082 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
4089 return pNewWindowInfo->pCurrentWeb;
4093 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
4095 AppLog("xyz:: MainForm::RelayoutControls called");
4096 __webControlPosition.y = 0;
4097 __webControlHeight = GetClientAreaBounds().height;
4098 AppLog("Client area height: %d", __webControlHeight);
4100 AppLog("Client area height: %d", __webControlHeight);
4101 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
4103 __webControlPosition.y += __pAddressbar->GetHeight();
4104 __webControlHeight -= __pAddressbar->GetHeight();
4105 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
4107 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
4109 __webControlPosition.y += __pFindWordControl->GetHeight();
4110 __webControlHeight -= __pFindWordControl->GetHeight();
4111 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
4114 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
4116 __webControlHeight -= __pFooterPanel->GetHeight();
4118 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
4120 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
4122 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight + 12 )
4127 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12);
4128 __pWebViewer->Invalidate(false);
4131 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
4133 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
4140 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
4142 if (__pFindWordControl == null)
4147 Tizen::Locales::LocaleManager localeManager;
4148 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
4150 String languageCode;
4151 result r = SettingInfo::GetValue(L"Language", languageCode);
4152 // int languagecode = local.GetLanguageCode();
4153 AppLog("rahul language is %S", languageCode.GetPointer());
4157 InitFindWordPanel();
4159 if (languageCode.CompareTo("ara") == 0)
4161 AppLog("rahul language is arabic");
4163 __pFindWordPanelLeftToRight->SetShowState(false);
4164 __pFindWordPanelRightToLeft->SetShowState(true);
4166 __pFindWordClear->SetShowState(false);
4167 __pFindWordCountLabel->SetShowState(false);
4168 __pFindWordEditField->SetShowState(false);
4170 __pFindWordClearRightToLeft->SetShowState(true);
4171 __pFindWordCountLabelRightToLeft->SetShowState(true);
4172 __pFindWordEditFieldRightToLeft->SetShowState(true);
4176 AppLog("rahul language is not arabic");
4179 __pFindWordPanelLeftToRight->SetShowState(true);
4180 __pFindWordPanelRightToLeft->SetShowState(false);
4182 __pFindWordClear->SetShowState(true);
4183 __pFindWordCountLabel->SetShowState(true);
4184 __pFindWordEditField->SetShowState(true);
4186 __pFindWordClearRightToLeft->SetShowState(false);
4187 __pFindWordCountLabelRightToLeft->SetShowState(false);
4188 __pFindWordEditFieldRightToLeft->SetShowState(false);
4190 __pFindWordControl->SetShowState(true);
4194 if(__pFindWordControl != null)
4196 __pFindWordControl->SetShowState(false);
4200 AppLog("MainForm::ShowFindWordPanel %d",show);
4201 if (show && !isTouchPressed)
4203 if (languageCode.CompareTo("ara") == 0)
4205 if (__pFindWordEditFieldRightToLeft)
4207 __pFindWordEditFieldRightToLeft->SetFocus();
4208 __pFindWordEditFieldRightToLeft->ShowKeypad();
4213 if (__pFindWordEditField)
4215 __pFindWordEditField->SetFocus();
4216 __pFindWordEditField->ShowKeypad();
4222 if (languageCode.CompareTo("ara") == 0)
4224 if (__pFindWordEditFieldRightToLeft)
4225 __pFindWordEditFieldRightToLeft->HideKeypad();
4229 if (__pFindWordEditField)
4230 __pFindWordEditField->HideKeypad();
4234 RelayoutControls(false);
4238 MainForm::StartWordSearch()
4240 //Get the count of occurances of the word in the current page
4241 __maxOccurrances = 0;
4242 __currentWordIndex = 0;
4244 __pFindWordPrev->SetEnabled(false);
4245 String *pCountStr = null;
4246 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
4247 AppLog("Search Result %s",GetErrorMessage(r));
4248 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
4249 if (pCountStr != null)
4251 Integer::Parse(*pCountStr, 10, __maxOccurrances);
4255 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
4260 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
4262 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
4263 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
4265 if(totalCount == -1 || totalCount == 0)
4267 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
4268 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
4271 else if(totalCount > 100)
4273 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4274 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4278 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4279 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4282 __maxOccurrances = totalCount;
4283 __currentWordIndex = currentOrdinal;
4285 //Reset the UI controls as per the maxOccurrance value
4286 if (totalCount <= 0)
4288 AppLog("Word not found");
4289 //Show error notification to user
4290 __pFindWordNext->SetEnabled(false);
4291 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4293 __pFindWordCountLabel->SetText(L"0/0");
4294 __pFindWordCountLabel->Invalidate(false);
4296 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4298 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4299 __pFindWordCountLabelRightToLeft->Invalidate(false);
4301 __pFindWordNext->Invalidate(false);
4302 __pFindWordPrev->Invalidate(false);
4307 if (totalCount == 1)
4309 __pFindWordNext->SetEnabled(false);
4313 __pFindWordNext->SetEnabled(true);
4316 String countStr = L"";
4317 countStr.Append(__currentWordIndex);
4318 countStr.Append(L"/");
4319 countStr.Append(__maxOccurrances);
4320 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4322 __pFindWordCountLabel->SetText(countStr);
4323 __pFindWordCountLabel->Invalidate(false);
4324 __pFindWordCountLabel->Invalidate(false);
4326 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4328 __pFindWordCountLabelRightToLeft->SetText(countStr);
4329 __pFindWordCountLabelRightToLeft->Invalidate(false);
4330 __pFindWordCountLabelRightToLeft->Invalidate(false);
4332 //FindNextWord(true);
4333 //Update the controls
4334 __pFindWordNext->Invalidate(false);
4335 __pFindWordPrev->Invalidate(false);
4340 MainForm::FindNextWord(bool next)
4344 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4345 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4347 if (__currentWordIndex < __maxOccurrances)
4349 __currentWordIndex++;
4355 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4356 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4358 if(__currentWordIndex > 1)
4360 __currentWordIndex--;
4365 String countStr = L"";
4366 countStr.Append(__currentWordIndex);
4367 countStr.Append(L"/");
4368 countStr.Append(__maxOccurrances);
4370 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4372 __pFindWordCountLabel->SetText(countStr);
4373 __pFindWordCountLabel->Invalidate(false);
4375 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4377 __pFindWordCountLabelRightToLeft->SetText(countStr);
4378 __pFindWordCountLabelRightToLeft->Invalidate(false);
4381 if (__currentWordIndex >= __maxOccurrances)
4383 __pFindWordNext->SetEnabled(false);
4387 __pFindWordNext->SetEnabled(true);
4389 if (__currentWordIndex <= 1)
4391 __pFindWordPrev->SetEnabled(false);
4395 __pFindWordPrev->SetEnabled(true);
4397 __pFindWordPrev->Invalidate(false);
4398 __pFindWordNext->Invalidate(false);
4400 __pFindWordControl->Invalidate(true);
4404 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4406 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4407 __isWebKeypadOpened = true;
4408 __pFooterPanel->SetShowState(false);
4409 // OnAddressBarKeypadOpened(*__pAddressbar);
4413 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4415 __isWebKeypadOpened = true;
4416 AppLog("xyz::MainForm::OnWebKeypadOpened");
4418 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4420 __currentSearchStr = L"";
4421 __currentWordIndex = 0;
4422 __maxOccurrances = 0;
4423 __pFindWordEditField->SetText(L"");
4424 __pFindWordNext->SetEnabled(false);
4425 __pFindWordPrev->SetEnabled(false);
4426 __pFindWordCountLabel->SetText(L"0/0");
4427 __pWebViewer->SearchTextAllAsync(L"",false);
4428 __pFindWordControl->SetShowState(false);
4429 __pFindWordEditField->HideKeypad();
4433 if (__pWebViewer != null && __pFooterPanel != null)
4435 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4436 if(__pAddressbar != null)
4438 __pAddressbar->SetShowState(false);
4440 if(__pFindWordControl != null)
4442 __pFindWordControl->SetShowState(false);
4444 __pFooterPanel->SetShowState(false);
4445 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4447 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4449 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4450 // AppLog("omgomgomg");
4456 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4458 AppLog("xyz::MainForm::OnWebKeypadClosed");
4459 AppLog("akjshdasd 4");
4460 __pFooterPanel->SetShowState(true);
4461 // OnAddressBarKeypadClosed(*__pAddressbar);
4462 RelayoutControls(false);
4463 __isWebKeypadOpened = false;
4467 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4469 // RelativeLayout(false);
4470 if(__pWebViewer != null)
4472 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4477 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4479 Control* temp = const_cast< Control* >(&source);
4480 Header* pHeader = dynamic_cast< Header* >(temp);
4481 if (pHeader != null)
4483 //Header double - clicked
4484 AppLog("Header double clicked");
4486 if(__pFindWordControl)
4488 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4489 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4493 AppLog("MainScene::OnTouchDoublePressed");
4497 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4499 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4500 if(TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1)
4502 AppLog("Returning because of more than one touch point.");
4505 __longPressPoint = currentPosition;
4507 if (__pHitElementResult != null)
4509 delete __pHitElementResult;
4510 __pHitElementResult = null;
4513 if (__pWebViewer != null)
4515 AppLog("MainForm::OnTouchLongPressed web not null");
4516 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4519 if (__pHitElementResult == null)
4524 if (__pHitElementResult->HasImage() == true)
4526 if(__pWebViewer != null)
4527 InitImageContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4528 __pImageMenu->SetShowState(true);
4529 __pImageMenu->Show();
4530 __pImageMenu->Invalidate(true);
4532 else if(__pHitElementResult->HasUrl() == true)
4534 String tempURl = __pHitElementResult->GetUrl();
4535 AppLog("tempURl is %ls", tempURl.GetPointer());
4536 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4537 if (pBitmap != null)
4545 InitImageLinkContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4546 __pImageMenu->SetShowState(true);
4547 __pImageMenu->Show();
4548 __pImageMenu->Invalidate(true);
4552 String tagName = __pHitElementResult->GetTagName();
4553 String type = __pHitElementResult->GetAttributeValue("type");
4554 String value = __pHitElementResult->GetAttributeValue(L"value");
4555 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4557 __currentSelectedStr.Clear();
4558 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4560 AppLog("tag name is %ls", tagName.GetPointer());
4561 AppLog("type is %ls", type.GetPointer());
4565 __isLongPressedDone = true;
4566 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4567 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && innerHtml.GetLength() == 0 /*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.CompareTo(L"") == 0 && r == E_INVALID_ARG)
4569 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4571 InitSelectTextContextMenu(Point(currentPosition.x , currentPosition.y + __pWebViewer->GetY()),true, true);
4574 __pImageMenu->SetShowState(true);
4575 __pImageMenu->Show();
4576 __pImageMenu->Invalidate(true);
4579 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4582 // __inputEventToBeSupressed = true;
4586 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4588 AppLog("xyz:: MainForm::OnTouchReleased called");
4590 if (__pAddressbar && __pAddressbar->GetShowState() == true)
4592 __pAddressbar->SetShowState(false);
4594 if(__pFooterPanel && __isWebKeypadOpened == false)
4596 __pFooterPanel->SetShowState(true);
4600 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4601 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4603 __pWebViewer->ConsumeInputEvent();
4605 if(pHitElement != null)
4609 __inputEventToBeSupressed = false;*/
4613 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4620 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4622 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4624 __currentSearchStr = L"";
4625 __currentWordIndex = 0;
4626 __maxOccurrances = 0;
4628 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4630 __pFindWordEditField->SetText(L"");
4631 __pFindWordEditField->HideKeypad();
4632 __pFindWordControl->SetShowState(false);
4633 __pFindWordCountLabel->SetText(L"0/0");
4635 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4637 __pFindWordEditFieldRightToLeft->SetText(L"");
4638 __pFindWordEditFieldRightToLeft->HideKeypad();
4639 __pFindWordControl->SetShowState(false);
4640 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4643 __pFindWordNext->SetEnabled(false);
4644 __pFindWordPrev->SetEnabled(false);
4646 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
4647 __pFindWordControl->SetShowState(false);
4649 if(__pAddressbar->GetShowState() == false)
4651 __pAddressbar->SetAddressbarURLFocus();
4652 __pFooterPanel->SetShowState(false);
4659 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4665 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4671 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4677 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4683 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4689 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4691 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4692 int widthContextItem = 0;
4693 if(__pFindWordCountLabel)
4694 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4695 // As per the platform engineer comment removed this line
4696 /*if(__pWebViewer != null)
4698 // 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
4699 __pWebViewer->ReleaseBlock();
4702 // if(__pFindWordControl != null)
4703 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4704 if(__pNotification && __pNotification->GetShowState() == true)
4706 __pNotification->SetShowState(false);
4707 __pNotification->Invalidate(false);
4709 if ( __pFooterLabel != null)
4711 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4714 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4720 if (__pFindWordBgLabel != null)
4722 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4723 if (pBitmap != null)
4725 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4730 if (__pFindWordBgLabelRightToLeft != null)
4732 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4733 if (pBitmap != null)
4735 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4741 // if(__pOptionMenu != null)
4742 // __pOptionMenu->SetShowState(false);
4744 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4746 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4750 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4755 AppLog("__pFooterPanel->GetShowState() is true");
4757 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4758 __pFooterPanel->Invalidate(true);
4762 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4763 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4765 InitMostVisitedSitesView(orientationStatus);
4768 RelayoutControls(false);
4769 if (__pArticleReaderPanel != null)
4771 if (__pArticleReaderPanel->GetShowState() == true)
4773 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4775 if (__pBlankPanel != null)
4776 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4778 if (__pWebReader != null)
4780 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4782 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4783 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4785 if ( pBitmap != null && pSrcBitmap != null)
4787 AppLog("CreateReaderPanel ninepatchbitmap found");
4788 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4791 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4792 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4793 if (pBitmap != null)
4798 if (pSrcBitmap != null)
4807 if (__pAddressbar != null)
4809 int width = GetClientAreaBounds().width;
4810 __pAddressbar->OrientationChanged(width);
4815 MainForm::OnSettingsChange(int settingvalue)
4817 AppLogDebug("MainForm::OnSettingsChange entered");
4819 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4821 __pAddressbar->ResetGuideText();
4823 if (__pWebViewer == null)
4825 AppLogDebug("Webviewer is not initialized yet.");
4829 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4831 WebSetting settings = __pWebViewer->GetSetting();
4832 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4834 settings.SetAutoFittingEnabled(true);
4836 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
4838 settings.SetAutoFittingEnabled(false);
4840 __pWebViewer->SetSetting(settings);
4842 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4844 WebSetting settings = __pWebViewer->GetSetting();
4845 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4846 __pWebViewer->SetSetting(settings);
4848 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4850 WebSetting settings = __pWebViewer->GetSetting();
4851 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4852 __pWebViewer->SetSetting(settings);
4853 __pWebViewer->Reload();
4855 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4857 WebSetting settings = __pWebViewer->GetSetting();
4858 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4859 __pWebViewer->SetSetting(settings);
4861 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4865 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4868 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
4872 WebSetting settings = __pWebViewer->GetSetting();
4873 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
4874 __pWebViewer->SetSetting(settings);
4877 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
4881 WebSetting settings = __pWebViewer->GetSetting();
4882 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
4883 __pWebViewer->SetSetting(settings);
4886 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4888 WebSetting settings = __pWebViewer->GetSetting();
4889 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4891 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4895 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4897 __pWebViewer->SetSetting(settings);
4899 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4903 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4904 WebSetting settings = __pWebReader->GetSetting();
4905 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4906 __pWebReader->SetSetting(settings);
4912 MainForm::OnSettingsReset()
4916 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4917 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4922 MainForm::OnClearCache()
4924 result r = E_SUCCESS;
4926 if (__pWebViewer != NULL)
4928 r = __pWebViewer->ClearCache();
4931 AppLogDebug("Cache cleared success");
4935 AppLogDebug("Cache cleared fail");
4941 MainForm::OnClearCookie()
4943 result r = E_SUCCESS;
4945 if (__pWebViewer != NULL)
4947 __pWebViewer->ClearCookie();
4951 AppLogDebug("Cookie cleared success");
4955 AppLogDebug("Cache cleared fail");
4960 MainForm::OnClearFormData()
4962 result r = E_SUCCESS;
4964 if (__pWebViewer != NULL)
4966 __pWebViewer->ClearFormData();
4970 AppLogDebug("Cookie cleared success");
4974 AppLogDebug("Cache cleared fail");
4979 MainForm::OnClearPasswords()
4981 result r = E_SUCCESS;
4983 if (__pWebViewer != NULL)
4985 __pWebViewer->ClearLoginFormData();
4989 AppLogDebug("Cookie cleared success");
4993 AppLogDebug("Cache cleared fail");
4999 MainForm::findDistance(int x1,int y1,int x2, int y2)
5001 int deltaX = Math::Abs(x2 - x1);
5002 int deltaY = Math::Abs(y2 - y1);
5003 double num = deltaX*deltaX + deltaY*deltaY;
5009 for (i = 0; i < 20; i++)
5011 x = (((x*x)+ num)/(2*x));
5022 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5024 AppLog("xyz:: MainForm::OnTouchPressed called");
5025 if(__pFindWordControl)
5027 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
5028 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
5030 __isLongPressedDone = false;
5035 IList* pList = null;
5036 pList = touch.GetTouchInfoListN(source);
5040 int count = pList->GetCount();
5043 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5044 __touchPoint1 = pTouchInfo->position;
5046 /*if (__pAddressbar != null)
5048 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5050 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5052 __pAddressbar->SaveAddressbarEditText();
5054 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5057 __pAddressbar->Invalidate(true);
5059 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5061 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5063 //__pAddressbar->SaveAddressbarEditText();
5065 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5068 else if (count == 2)
5070 AppLogDebug("MainForm::OnTouchPressed count is two");
5071 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5072 __touchPoint1 = pTouchInfo->position;
5074 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
5075 __touchPoint2 = pTouchInfo->position;
5080 pList->RemoveAll(true);
5085 __pAddressbar->SetShowState(false);
5087 if(__pFooterPanel && __isWebKeypadOpened == false)
5089 __pFooterPanel->SetShowState(true);
5091 RelayoutControls(false);
5096 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5098 // __currentWordIndex = 0;
5099 __isLongPressedDone = false;
5104 MainForm::MoveUiControls()
5109 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
5111 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
5113 if(__pFooterUrlField->GetTextLength() == 0)
5115 __pFooterUrlField->SetKeypadActionEnabled(false);
5119 __pFooterUrlField->SetKeypadActionEnabled(true);
5122 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
5124 __currentSearchStr = __pFindWordEditField->GetText();
5125 if (__currentSearchStr.GetLength() > 0)
5127 __pFindWordCountLabel->SetShowState(true);
5131 __pFindWordCountLabel->SetShowState(false);
5133 __pFindWordNext->SetEnabled(false);
5134 __pFindWordPrev->SetEnabled(false);
5135 __pFindWordNext->Invalidate(true);
5136 __pFindWordPrev->Invalidate(true);
5137 __pFindWordCountLabel->SetText(L"0/0");
5138 __pFindWordCountLabel->Invalidate(true);
5140 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
5142 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
5143 if (__currentSearchStr.GetLength() > 0)
5145 __pFindWordCountLabelRightToLeft->SetShowState(true);
5149 __pFindWordCountLabelRightToLeft->SetShowState(false);
5152 __pFindWordNext->SetEnabled(false);
5153 __pFindWordPrev->SetEnabled(false);
5154 __pFindWordNext->Invalidate(true);
5155 __pFindWordPrev->Invalidate(true);
5156 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
5157 __pFindWordCountLabelRightToLeft->Invalidate(true);
5159 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
5160 if (__currentSearchStr.GetLength() > 0)
5166 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
5168 __currentSearchStr = L"";
5169 AppLogDebug("Enter something");
5174 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
5181 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
5183 if(__pWebViewer != null)
5186 AppLog("MainForm::InitMostVisitedSitesView");
5187 result r = E_SUCCESS;
5190 if (__pWebViewer != null && __pMostVisitedListView != null)
5195 if (__pMostVisitedListView != null)
5197 RemoveControl(__pMostVisitedListView);
5199 if(__pMostVisitedSites != null)
5201 __pMostVisitedSites->RemoveAll(true);
5204 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
5206 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
5207 __pMostVisitedListView = new(std::nothrow) ListView();
5209 int height = GetClientAreaBounds().height;
5211 if(__pFooterPanel->GetShowState() == true)
5213 height = height - __pFooterPanel->GetHeight();
5215 if(__pAddressbar->GetShowState() == true)
5217 height -= __pAddressbar->GetHeight();
5220 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
5224 delete __pMostVisitedListView;
5225 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
5228 __pMostVisitedListView->SetItemProvider(*this);
5229 __pMostVisitedListView->AddListViewItemEventListener(*this);
5230 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_VISITED_SITES"));
5231 AddControl(__pMostVisitedListView);
5232 __pMostVisitedListView->UpdateList();
5239 MainForm::GetImagePath(void)
5243 String formattedTime;
5244 DateTime currentTime;
5245 LocaleManager localManager;
5246 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
5248 localManager.Construct();
5249 Locale locale = localManager.GetSystemLocale();
5250 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
5252 // Get date formatter
5253 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
5257 pTimeFormatter->Format(currentTime, formattedTime);
5260 AppLog("current time stamp is %ls", formattedTime.GetPointer());
5261 String delim(L" :");
5262 StringTokenizer strTok(formattedTime, delim);
5265 String str1("GMT+00");
5266 while (strTok.HasMoreTokens())
5268 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
5269 if(token.Equals(str1))
5271 AppLog("token is %ls", token.GetPointer());
5272 imageName.Append(token);
5278 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
5280 result r = E_FAILURE;
5281 AppLog("Content manager 1");
5282 ContentId contentId;
5283 ContentManager contentManager;
5284 r = contentManager.Construct();
5287 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
5290 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
5291 Tizen::Io::Directory::Create(contentPath,true);
5292 if(GetLastResult() == E_FILE_ALREADY_EXIST)
5294 AppLog("Already exists");
5296 else if(GetLastResult() == E_SUCCESS)
5298 AppLog("created success");
5300 contentPath.Append(imageName);
5301 contentPath.Append(".jpg");
5302 contentId = contentManager.CreateContent(*aBuffer, contentPath);
5303 ShowIndicatorNotification(L"Download Complete");
5304 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5308 MainForm::ShowIndicatorNotification(const String& messageText)
5310 AppLogDebug("ENTER");
5312 NotificationRequest request;
5313 request.SetAlertText(messageText);
5314 request.SetTitleText(L"");
5315 request.SetAppMessage(L"AppMessage");
5317 Tizen::App::App* pApp = Tizen::App::App::GetInstance();
5318 String homePath = pApp->GetAppRootPath();
5319 String iconPath = homePath + L"res/screen-density-xhigh/Notification_download_complete.png";
5320 AppLog("The iconPath is : %ls", homePath.GetPointer());
5321 request.SetIconFilePath(iconPath);
5323 Tizen::Shell::NotificationManager notiMgr;
5324 notiMgr.Construct();
5325 notiMgr.Notify(request);
5327 AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));
5332 MainForm::SetForwardButtonEnabled(bool isEnabled)
5334 __pGoForwardBtn->SetEnabled(isEnabled);
5335 __pGoForwardBtn->Invalidate(true);
5339 MainForm::SetBackButtonEnabled(bool isEnabled)
5341 __pGoBackBtn->SetEnabled(isEnabled);
5342 __pGoBackBtn->Invalidate(true);
5346 MainForm::UpdateProgress(int percentage)
5348 __progressPercentage = percentage;
5349 if (percentage == 0 || percentage == 100)
5351 __isLoadingData = false;
5352 if (percentage == 100)
5354 __isLoadingCompleted = true;
5355 __progressPercentage = 0;
5359 __isLoadingCompleted = false;
5364 __isLoadingData = true;
5366 UpdateProgressBitmap();
5370 MainForm::GetProgress(void)
5372 return __progressPercentage;
5376 MainForm::UpdateProgressBitmap(void)
5378 result r = E_SUCCESS;
5379 if (__pProgressbarLabel == null)
5381 int w = __pProgressbarLabel->GetWidth();
5382 int h = __pProgressbarLabel->GetHeight();
5384 int progressWidth = 0;
5385 Bitmap* pRetBitmap = null;
5387 if (__progressPercentage == 0 || __progressPercentage == 100)
5389 __pProgressbarLabel->SetShowState(false);
5390 __pProgressbarLabel->Invalidate(false);
5395 __pProgressbarLabel->SetShowState(true);
5396 __pProgressbarLabel->Invalidate(false);
5399 r = canvas.Construct(Rectangle(0, 0, w, h));
5403 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5408 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5412 pBgBmp->Scale(Dimension(w, h));
5413 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5417 progressWidth = (double) (w) * __progressPercentage / 100;
5418 AppLogDebug("progressWidth: %d", progressWidth);
5419 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5421 if (pProgressBmp != null)
5423 pProgressBmp->Scale(Dimension(progressWidth, h));
5424 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5425 delete pProgressBmp;
5428 pRetBitmap = new (std::nothrow) Bitmap();
5430 if (pRetBitmap == null)
5432 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5436 pRetBitmap->Construct(canvas, canvas.GetBounds());
5438 if (__pProgressbarLabel != null && pRetBitmap != null)
5440 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5441 __pProgressbarLabel->Invalidate(false);
5444 if (pRetBitmap != null)
5453 MainForm::ReaderClicked()
5455 result r = E_SUCCESS;
5456 ArrayList* pArgList = new(std::nothrow) ArrayList();
5457 if (pArgList != null)
5459 r = pArgList->Construct();
5466 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5473 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5480 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5488 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5494 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5496 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5498 __currentAddMode = addMode;
5502 case ADDRESSBAR_MODE_INVALID:
5507 case ADDRESSBAR_MODE_READER:
5509 __pStopBtn->SetShowState(false);
5510 __pRefreshBtn->SetShowState(false);
5511 __pClearBtn->SetShowState(false);
5512 __pReaderBtn->SetShowState(false);
5515 case ADDRESSBAR_MODE_LOADING:
5517 __pRefreshBtn->SetShowState(false);
5518 __pStopBtn->SetShowState(true);
5519 __pClearBtn->SetShowState(false);
5520 __pReaderBtn->SetShowState(false);
5523 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5525 // SetUrl(__pAddressbar->GetUrl());
5527 __pRefreshBtn->SetShowState(true);
5528 __pStopBtn->SetShowState(false);
5529 __pClearBtn->SetShowState(false);
5530 __pReaderBtn->SetShowState(false);
5533 case ADDRESSBAR_MODE_EDIT:
5535 __pRefreshBtn->SetShowState(false);
5536 __pStopBtn->SetShowState(false);
5537 __pReaderBtn->SetShowState(false);
5538 __pClearBtn->SetShowState(true);
5545 OnAddressBarModeChanged();
5548 AddressBarMode MainForm::GetAddressbarMode(void)
5550 return __currentAddMode;
5553 void MainForm::SetUrl(const String& url)
5556 if(__displayUrl.GetLength() > 2048)
5557 __displayUrl.SubString(0,2048,__displayUrl);
5559 if (__pFooterUrlField != NULL)
5561 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5562 if (removedHttpUrl.IsEmpty() == false)
5564 __pFooterUrlField->SetText(removedHttpUrl);
5565 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5566 __pAddressbar->SetUrl(__displayUrl);
5570 __pFooterUrlField->SetText(__displayUrl);
5571 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5572 __pAddressbar->SetUrl(__displayUrl);
5574 if(__pFooterUrlField)
5575 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5576 __pFooterUrlField->Invalidate(false);
5577 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5578 __pAddressbar->Invalidate(true);
5579 // __pFooterUrlField->SetCursorPosition(0);
5584 MainForm::RemoveHttpTextFromDisplayURL(void)
5586 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5588 // bool isHttpText = __displayUrl.Contains(L"http://");
5589 String updatedDisplayUrl;
5590 updatedDisplayUrl.Clear();
5591 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5593 __displayUrl.SubString(7,updatedDisplayUrl);
5595 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5597 __displayUrl.SubString(8,updatedDisplayUrl);
5599 return updatedDisplayUrl;
5602 void MainForm::OnSharePopupControlStarted(void)
5604 __pWebViewer->AddTouchEventListener(*this);
5608 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5610 if (requestId == BACK_GROUND_APP_EVENT)
5612 if(__pWebViewer != null)
5614 __pWebViewer->Pause();
5616 if(__pAddressbar != null)
5618 __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5621 else if(requestId == FORE_GROUND_APP_EVENT)
5623 if(__pWebViewer != null)
5625 __pWebViewer->Resume();
5627 if(__pAddressbar != null)
5629 __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5635 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5637 AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5638 result r = E_SUCCESS;
5641 __pAddressbar->SetShowState(false);
5643 AppLog("akjshdasd 5");
5644 __pFooterPanel->SetShowState(true);
5647 __pWebViewer->SetFocus();
5648 else if(__pMostVisitedListView)
5649 __pMostVisitedListView->SetFocus();
5650 else if(__pMultiWindowButton)
5651 __pMultiWindowButton->SetFocus();
5652 else if(__pMoreButton)
5653 __pMoreButton->SetFocus();
5655 __pAddressbar->SetShowState(false);
5657 RelayoutControls(false);
5661 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5663 AppLog("MainForm::OnFormMenuRequested called");
5665 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
5667 int bookmarkCount=0;
5670 url=__pWindowInfo->pageUrl;
5671 AppLog("MainForm::OnFormMenuRequested url %ls",url.GetPointer());
5672 result r = E_SUCCESS;
5673 Bitmap* pBitmap = null;
5674 String lastChar = L"";
5675 if(url.SubString(url.GetLength()-1,lastChar));
5676 // if(lastChar == L"/")
5678 // bool exist1 = false;
5679 // bool exist2 = false;
5680 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist1);
5681 // url.SubString(0,url.GetLength() - 1,url);
5682 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist2);
5683 // exist = exist1 | exist2;
5687 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5690 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5696 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5700 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5702 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5704 if (__pOptionMenu->GetItemCount() == 9)
5706 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5710 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5715 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
5719 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
5720 if (__pOptionMenu->GetItemCount() != 9)
5722 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
5723 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
5724 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
5725 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
5726 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
5727 __pOptionMenu->SetMaxVisibleItemsCount(6);
5729 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
5731 AppLog(" Orientation landscape");
5732 __pOptionMenu->SetMaxVisibleItemsCount(5);
5736 AppLog(" Orientation potrait");
5737 __pOptionMenu->SetMaxVisibleItemsCount(6);
5740 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
5743 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
5744 __pOptionMenu->SetShowState(true);
5745 __pOptionMenu->Invalidate(true);
5746 __pOptionMenu->Show();