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 __isKeypadOpened = 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->SetFocusable(true);
758 __pOptionMenu->Invalidate(true);
762 __pOptionMenu = new(std::nothrow) OptionMenu();
763 r = __pOptionMenu->Construct();
764 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
766 __pOptionMenu->SetFocusable(true);
767 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
770 if (isPrivateBrowsing == true)
772 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
776 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
779 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
781 if ( pBitmap != NULL)
783 __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
786 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
787 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
788 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
791 __pOptionMenu->SetMaxVisibleItemsCount(6);
792 __pOptionMenu->SetShowState(false);
793 __pOptionMenu->AddActionEventListener(*this);
794 SetControlAlwaysOnTop(*__pOptionMenu, true);
800 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
802 result r = E_SUCCESS;
803 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
805 AppLog("MainForm::InitImageContextMenu clicked on image");
806 if (__pImageMenu != null)
811 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
816 __pImageMenu = new (std::nothrow) ContextMenu();
817 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
818 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
820 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
821 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
822 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
823 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
824 __pImageMenu->SetMaxVisibleItemsCount(4);
825 __pImageMenu->AddActionEventListener(*this);
826 SetControlAlwaysOnTop(*__pImageMenu, true);
832 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
834 result r = E_SUCCESS;
835 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
837 AppLog("MainForm::InitImageContextMenu clicked on image");
838 if (__pImageMenu != null)
844 // if(__pAddressbar->GetShowState() == true)
845 // p.y = p.y + __pAddressbar->GetHeight();
846 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
851 __pImageMenu = new (std::nothrow) ContextMenu();
852 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
853 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
855 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_OPEN_IN_NEW_WINDOW"),IDA_HYPERLINK_OPEN_CLICKED);
856 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_LINK_URL"),IDA_HYPERLINK_COPY_LINK_CLICKED);
857 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
858 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
860 __pImageMenu->SetMaxVisibleItemsCount(3);
861 __pImageMenu->AddActionEventListener(*this);
862 SetControlAlwaysOnTop(*__pImageMenu, true);
869 MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOption = false)
871 result r = E_SUCCESS;
872 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
874 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
875 if (__pImageMenu != null)
884 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
888 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
890 __pImageMenu = new (std::nothrow) ContextMenu();
891 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
892 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
894 if(onlyPasteOption == false)
896 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
898 if (pasteOption || onlyPasteOption)
900 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
902 if(onlyPasteOption == false)
904 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
905 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
908 __pImageMenu->SetMaxVisibleItemsCount(3);
909 __pImageMenu->AddActionEventListener(*this);
910 SetControlAlwaysOnTop(*__pImageMenu, true);
917 MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPasteOption = false)
919 result r = E_SUCCESS;
920 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
922 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
923 if (__pImageMenu != null)
932 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
936 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
938 __pImageMenu = new (std::nothrow) ContextMenu();
939 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
940 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
942 if(onlyPasteOption == false)
944 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
946 if (pasteOption || onlyPasteOption)
948 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
950 if(onlyPasteOption == false)
952 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
953 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
956 __pImageMenu->SetMaxVisibleItemsCount(3);
957 __pImageMenu->AddActionEventListener(*this);
958 SetControlAlwaysOnTop(*__pImageMenu, true);
965 MainForm::InitFindWordPanel(void)
967 result r = E_SUCCESS;
968 Bitmap *pIconBitmap = null;
970 if (__pFindWordControl != null)
972 AppLogDebug("Findword panel already initialized");
973 if (__pFindWordBgLabel != null)
975 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
978 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
982 if (__pFindWordBgLabelRightToLeft != null)
984 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
987 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
994 __pFindWordControl = new (std::nothrow) Panel();
995 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
998 AppLogException("There is some problem in the xml file. Please check.");
1001 AddControl(__pFindWordControl);
1002 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
1003 SetControlAlwaysOnTop(*__pFindWordControl,true);
1004 __pFindWordControl->SetShowState(false);
1005 __pFindWordControl->Invalidate(false);
1007 __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1008 __pFindWordPanelLeftToRight->SetShowState(true);
1010 __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
1011 __pFindWordPanelRightToLeft->SetShowState(false);
1013 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
1014 if (__pFindWordBgLabel != null)
1016 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1017 Rectangle pRect = pPanel1->GetBounds();
1018 pRect.x = pRect.y = 0;
1019 __pFindWordBgLabel->SetBounds(pRect);
1020 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1021 if (pBitmap != null)
1023 AppLogDebug("InitFindWordPanel: Coming here");
1024 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1029 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1033 __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
1034 if (__pFindWordBgLabelRightToLeft != null)
1036 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1037 Rectangle pRect = pPanel1->GetBounds();
1038 pRect.x = pRect.y = 0;
1039 __pFindWordBgLabelRightToLeft->SetBounds(pRect);
1040 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1041 if (pBitmap != null)
1043 AppLogDebug("InitFindWordPanel: Coming here");
1044 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1049 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1053 Button* pfindWordCancel = null;
1054 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1055 if (pfindWordCancel == null)
1057 AppLogException("There is some problem in the xml file. Please check.");
1060 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1061 pfindWordCancel->AddActionEventListener(*this);
1063 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1064 if (__pFindWordClear == null)
1066 AppLogException("There is some problem in the xml file. Please check.");
1070 __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1071 if (__pFindWordClearRightToLeft == null)
1073 AppLogException("There is some problem in the xml file. Please check.");
1077 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1078 __pFindWordClear->AddActionEventListener(*this);
1080 __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1081 __pFindWordClearRightToLeft->AddActionEventListener(*this);
1083 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1084 if (__pFindWordNext == null)
1086 AppLogException("There is some problem in the xml file. Please check.");
1090 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1091 __pFindWordNext->AddActionEventListener(*this);
1093 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1094 if (__pFindWordPrev == null)
1096 AppLogException("There is some problem in the xml file. Please check.");
1100 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1101 __pFindWordPrev->AddActionEventListener(*this);
1103 __pFindWordNext->SetEnabled(false);
1104 __pFindWordPrev->SetEnabled(false);
1106 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1107 if (__pFindWordCountLabel == null)
1109 AppLogException("There is some problem in the xml file. Please check.");
1113 __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1114 if (__pFindWordCountLabel == null)
1116 AppLogException("There is some problem in the xml file. Please check.");
1120 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1121 if (__pFindWordEditField == null)
1123 AppLogException("There is some problem in the xml file. Please check.");
1126 __pFindWordEditField->AddTextEventListener(*this);
1127 __pFindWordEditField->AddKeypadEventListener(*this);
1128 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1129 __pFindWordEditField->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1131 __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1132 if (__pFindWordEditFieldRightToLeft == null)
1134 AppLogException("There is some problem in the xml file. Please check.");
1137 __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1138 __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1139 __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1140 __pFindWordEditFieldRightToLeft->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1143 __pAddressbar->SetShowState(false);
1145 if(__isKeypadOpened == false)
1146 __pFooterPanel->SetShowState(true);
1151 MainForm::CreateItem (int index, int itemWidth)
1153 Rectangle listImageRect;
1154 Rectangle pagetTitleRect;
1155 Rectangle pageURLRect;
1156 Rectangle deleteImageRect;
1157 String pageTitle(L"");
1158 String pageURL(L"");
1159 result r = E_SUCCESS;
1160 Bitmap* pListIconImage = null;
1163 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1164 if(pHistory == null)
1168 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1169 if ( pAppResource == NULL )
1173 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1175 CustomItem* pItem = new(std::nothrow) CustomItem();
1176 pageTitle = pHistory->GetHistoryTitle();
1177 pageURL = pHistory->GetHistoryUrl();
1179 if (pageURL.GetLength() == 0)
1182 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1183 pageURL = L"<"+ nourl +">";
1187 Rectangle screenBounds = GetBounds();
1190 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1199 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1201 if ( pBitmap != NULL)
1203 pListIconImage = new Bitmap();
1204 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1208 if(pListIconImage == null)
1210 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1213 if ( pListIconImage != NULL)
1215 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2 , 72, 72);
1216 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 72 + (__fontSize - 44));
1217 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1220 if (pItem != null && pListIconImage != NULL)
1222 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1226 if (pageTitle.CompareTo(L"") != 0)
1230 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1234 if (pageURL.CompareTo(L"") != 0)
1238 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1243 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1245 if ( __pItemContext!= NULL)
1249 pItem->SetContextItem(__pItemContext);
1255 if ( __pItemContextLandscape!= NULL)
1259 pItem->SetContextItem(__pItemContextLandscape);
1263 if( pListIconImage != NULL)
1265 delete pListIconImage;
1266 pListIconImage = null;
1273 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1280 MainForm::GetItemCount (void)
1282 if(__pMostVisitedSites != null)
1284 __pMostVisitedSites->RemoveAll(true);
1286 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1287 if(__pMostVisitedSites != null)
1289 return __pMostVisitedSites->GetCount();
1296 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1298 AppLog("MainForm::OnListViewContextItemStateChanged called");
1299 if(__pMostVisitedSites != null)
1301 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1302 if (pHistory != null)
1304 String url = pHistory->GetHistoryUrl();
1306 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1307 __pMostVisitedListView->UpdateList();
1313 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1315 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1316 String url = pHistory->GetHistoryUrl();
1324 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1330 MainForm::OnTerminating(void)
1332 result r = E_SUCCESS;
1334 RemoveOrientationEventListener(*this);
1338 __pAddressbar->SetAddressbarEventListener(null);
1343 __pWebViewer->RemoveTouchEventListener(*this);
1344 __pWebViewer->SetWebUiEventListenerF(null);
1345 __pWebViewer->SetWebKeypadEventListener(null);
1346 __pWebViewer->SetTextSearchListener(null);
1352 delete __pItemContext;
1354 if (__pItemContextLandscape)
1356 delete __pItemContextLandscape;
1360 delete __pSaveImage;
1362 if (__pMostVisitedSites)
1364 __pMostVisitedSites->RemoveAll(true);
1365 delete __pMostVisitedSites;
1371 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1373 result r = E_SUCCESS;
1375 AppLogDebug("Clicked : %d", actionId);
1378 case IDA_BACKBTN_CLICKED:
1380 if(__pImageMenu && __pImageMenu->GetShowState() == true)
1382 AppLog("Hiding the menu");
1383 __pImageMenu->SetShowState(false);
1385 if (__pWebViewer && __pWebViewer->CanGoBack())
1387 __pWebViewer->GoBack();
1389 else if(__pWindowInfo->isJavascriptInitiated == false)
1392 pApp = UiApp::GetInstance();
1395 RemoveOrientationEventListener(*this);
1399 __pAddressbar->SetAddressbarEventListener(null);
1404 __pWebViewer->RemoveTouchEventListener(*this);
1405 __pWebViewer->SetWebUiEventListenerF(null);
1406 __pWebViewer->SetWebKeypadEventListener(null);
1407 __pWebViewer->SetTextSearchListener(null);
1408 __pWebViewer->SetLoadingListener(null);
1410 r = pApp->Terminate();
1413 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1421 WindowInfo* pWindowInfo = null;
1423 SceneManager* pSceneManager = SceneManager::GetInstance();
1424 if (pSceneManager == null)
1428 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1429 if (pAllWindowList == NULL)
1431 pApp = UiApp::GetInstance();
1434 RemoveOrientationEventListener(*this);
1438 __pAddressbar->SetAddressbarEventListener(null);
1443 __pWebViewer->RemoveTouchEventListener(*this);
1444 __pWebViewer->SetWebUiEventListenerF(null);
1445 __pWebViewer->SetWebKeypadEventListener(null);
1446 __pWebViewer->SetTextSearchListener(null);
1447 __pWebViewer->SetLoadingListener(null);
1449 r = pApp->Terminate();
1452 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1457 if (pAllWindowList != null)
1459 totalCount = pAllWindowList->GetCount();
1461 for (int count = 0; count < totalCount; count++)
1463 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1464 if (pWindowInfo == null)
1466 pApp = UiApp::GetInstance();
1469 RemoveOrientationEventListener(*this);
1473 __pAddressbar->SetAddressbarEventListener(null);
1478 __pWebViewer->RemoveTouchEventListener(*this);
1479 __pWebViewer->SetWebUiEventListenerF(null);
1480 __pWebViewer->SetWebKeypadEventListener(null);
1481 __pWebViewer->SetTextSearchListener(null);
1482 __pWebViewer->SetLoadingListener(null);
1484 r = pApp->Terminate();
1487 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1494 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1496 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1499 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1502 r = pAllWindowList->RemoveAt(count, true);
1503 __pWindowInfo = null;
1506 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1511 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1515 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1517 if (pWindowInfo == null)
1519 pApp = UiApp::GetInstance();
1523 RemoveOrientationEventListener(*this);
1527 __pAddressbar->SetAddressbarEventListener(null);
1532 __pWebViewer->RemoveTouchEventListener(*this);
1533 __pWebViewer->SetWebUiEventListenerF(null);
1534 __pWebViewer->SetWebKeypadEventListener(null);
1535 __pWebViewer->SetTextSearchListener(null);
1536 __pWebViewer->SetLoadingListener(null);
1538 r = pApp->Terminate();
1544 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1547 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1559 case IDA_FORWARD_CLICKED:
1560 if (__pWebViewer == null)
1563 if (__pWebViewer->CanGoForward())
1565 __pWebViewer->GoForward();
1567 __pOptionMenu->SetShowState(false);
1568 __pOptionMenu->Invalidate(false);
1571 case IDA_FINDONPAGE_CLICKED:
1573 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1574 __currentSearchStr.Clear();
1576 InitFindWordPanel();
1577 __pOptionMenu->SetShowState(false);
1578 __pOptionMenu->Invalidate(false);
1580 ShowFindWordPanel(true);
1582 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1584 __pFindWordEditField->SetFocus();
1585 __pFindWordCountLabel->SetShowState(false);
1589 __pFindWordEditFieldRightToLeft->SetFocus();
1590 __pFindWordCountLabelRightToLeft->SetShowState(false);
1594 case IDA_PRIVATEON_CLICKED:
1596 result r = E_SUCCESS;
1598 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1599 Bitmap* pBitmap = null;
1600 if (isPrivateBrowsing == true)
1602 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1605 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1609 if (__pWebViewer != NULL)
1611 __pWebViewer->SetPrivateBrowsingEnabled(false);
1614 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1616 if (__pAddressbar != null)
1618 __pAddressbar->UpdateFaviconBitmap(false);
1624 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1627 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1631 if (__pWebViewer != NULL)
1633 __pWebViewer->SetPrivateBrowsingEnabled(true);
1636 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1638 if (__pAddressbar != null)
1640 __pAddressbar->UpdateFaviconBitmap(true);
1644 itemIndex = __pOptionMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1645 r = __pOptionMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1646 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1647 __pOptionMenu->Invalidate(true);
1648 if ( pBitmap != NULL )
1655 case IDA_SETTINGS_CLICKED:
1658 ArrayList* pArgList = new(std::nothrow) ArrayList();
1661 pArgList->Construct();
1662 pArgList->Add(*__pWindowInfo);
1663 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1665 __pOptionMenu->SetShowState(false);
1666 __pOptionMenu->Invalidate(false);
1668 if (pArgList != null)
1677 case IDA_ADDTOBOOKMARK_CLICKED:
1680 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1682 int bookmarkCount=0;
1685 url=__pWindowInfo->pageUrl;
1686 result r = E_SUCCESS;
1687 Bitmap* pBitmap = null;
1688 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1696 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1697 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1698 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1700 if(__pNotification != null)
1702 RemoveControl(__pNotification);
1703 __pNotification = null;
1705 __pNotification = new (std::nothrow) NotificationPanel(*this);
1706 if (__pNotification != null)
1708 __pNotification->SetText(message);
1709 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1710 __pNotification->ShowNotification();
1715 String title=__pWindowInfo->pageTitle;
1716 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1717 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1719 pBookmark->SetBookmarkTitle(title);
1720 pBookmark->SetUrl(url);
1721 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1723 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1725 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1726 pBookmark->SetFaviconId(id);
1727 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1728 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1730 if(__pNotification != null)
1732 RemoveControl(__pNotification);
1733 __pNotification = null;
1735 __pNotification = new (std::nothrow) NotificationPanel(*this);
1736 if (__pNotification != null)
1738 __pNotification->SetText(message);
1739 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1740 __pNotification->ShowNotification();
1741 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1744 if (pBitmap != null)
1746 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1751 __pOptionMenu->Invalidate(true);
1756 case IDA_PRINT_CLICKED:
1758 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//shared//data//test.pdf");
1759 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1761 AppLog("RequestPrint called!");
1762 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1763 result nResult = E_FAILURE;
1766 AppLog("TestPrint if (pAc) == true");
1771 String fileType = L"service_print_files_type";
1772 String typeVal = L"DOC";
1774 String fileCount = L"service_print_files_count";
1775 String countVal = L"1";
1776 String fileFolder= L"service_print_files_folder_name";
1777 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//shared//data";
1779 map.Add(&fileCount, &countVal);
1780 map.Add(&fileFolder, &folderVal);
1781 map.Add(&fileType, &typeVal);
1783 String fileName = L"service_print_files_files_name";
1785 ArrayList fileNameList;
1786 fileNameList.Construct();
1787 String file1 = L"test.pdf";
1789 fileNameList.Add(&file1);
1790 map.Add(&fileName, &fileNameList);
1792 nResult = pAc->Start(NULL, NULL, &map, NULL);
1794 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1795 else if (nResult == E_MAX_EXCEEDED)
1796 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1797 else if (nResult == E_OBJ_NOT_FOUND)
1798 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1799 else if (nResult == E_IN_PROGRESS)
1800 AppLog("TestPrint ret == E_IN_PROGRESS");
1801 else if (nResult == E_PRIVILEGE_DENIED)
1802 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1803 else if(nResult == E_SYSTEM)
1804 AppLog("TestPrint ret == E_SYSTEM");
1810 int __modalMsgBoxResult;
1811 MessageBox* pMsgBox = new MessageBox();
1812 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1813 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1816 __modalMsgBoxResult = 0;
1820 case IDA_SHARE_CLICKED:
1822 if(__pPopUp != null)
1829 __pAddressbar->HideKeypad();
1831 __pPopUp = new(std::nothrow) SharePopup();
1832 __pPopUp->Initialize();
1833 if (__pWindowInfo != null)
1835 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1836 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1837 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1838 pShareInfo->SetImageAttached(false);
1839 __pPopUp->RemoveAllShareInfo();
1840 __pPopUp->AddShareInfo(pShareInfo);
1842 __pPopUp->SetShowState(true);
1846 case IDA_BOOKMARKBTN_CLICKED:
1848 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1849 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1852 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1857 case IDA_MOREBTN_CLICKED:
1859 AppLog("IDA_MOREBTN_CLICKED");
1861 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1863 int bookmarkCount=0;
1866 url=__pWindowInfo->pageUrl;
1867 result r = E_SUCCESS;
1868 Bitmap* pBitmap = null;
1870 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1873 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1878 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1882 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1884 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1886 if (__pOptionMenu->GetItemCount() == 9)
1888 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1892 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1897 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1901 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1902 if (__pOptionMenu->GetItemCount() != 9)
1904 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1905 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1906 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1907 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1908 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1909 __pOptionMenu->SetMaxVisibleItemsCount(6);
1911 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1913 AppLog(" Orientation landscape");
1914 __pOptionMenu->SetMaxVisibleItemsCount(5);
1918 AppLog(" Orientation potrait");
1919 __pOptionMenu->SetMaxVisibleItemsCount(6);
1922 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1925 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1926 __pOptionMenu->SetShowState(true);
1927 __pOptionMenu->Invalidate(true);
1928 __pOptionMenu->Show();
1932 case IDA_HISTORY_CLICKED:
1934 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1935 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1938 case IDA_SAVED_PAGES_CLICKED:
1943 case IDA_DESKTOP_VIEW_CLICKED:
1948 case IDA_SAVE_CLICKED:
1953 case IDA_MULTIWINDOWBTN_CLICKED:
1955 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1956 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1960 case IDA_NEWWINDOWBTN_CLICKED:
1962 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
1964 if (pNewWindowInfo == null)
1968 result r = E_SUCCESS;
1969 SceneManager* pSceneManager = SceneManager::GetInstance();
1971 if (pSceneManager == NULL)
1975 ArrayList* pArgList = new(std::nothrow) ArrayList();
1976 if (pArgList == NULL)
1980 r = pArgList->Construct();
1983 pArgList->Add(*pNewWindowInfo);
1984 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1990 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1995 case IDA_SMALLFONT_BTN_CLICKED:
1997 WebSetting setting = __pWebReader->GetSetting();
1998 setting.SetFontSize(15);
1999 __pWebReader->SetSetting(setting);
2002 case IDA_LARGEFONT_BTN_CLICKED:
2004 WebSetting setting = __pWebReader->GetSetting();
2005 setting.SetFontSize(25);
2006 __pWebReader->SetSetting(setting);
2009 case IDA_READER_CLOSE_CLICKED:
2011 if (__pArticleReaderPanel != null && __pBlankPanel != null)
2013 RemoveControl(__pBlankPanel);
2014 __pArticleReaderPanel = null;
2015 __pBlankPanel = null;
2016 __pArticleReaderLabel = null;
2018 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2021 case IDA_FINDWORD_CANCEL_CLICKED:
2023 __currentSearchStr = L"";
2024 __currentWordIndex = 0;
2025 __maxOccurrances = 0;
2027 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2029 __pFindWordEditField->SetText(L"");
2030 __pFindWordCountLabel->SetText(L"0/0");
2032 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2034 __pFindWordEditFieldRightToLeft->SetText(L"");
2035 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2038 __pFindWordNext->SetEnabled(false);
2039 __pFindWordPrev->SetEnabled(false);
2040 __pFindWordCountLabel->SetText(L"0/0");
2041 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
2042 AppLog("akjshdasd 1");
2043 if(__isKeypadOpened == false)
2044 __pFooterPanel->SetShowState(true);
2045 ShowFindWordPanel(false);
2048 case IDA_FINDWORD_SEARCH_CLICKED:
2050 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2052 __currentSearchStr = __pFindWordEditField->GetText();
2054 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2056 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
2059 if (__currentSearchStr.GetLength() > 0)
2065 AppLogDebug("Enter something");
2069 case IDA_FINDWORD_CLEAR_CLICKED:
2071 __pFindWordCountLabel->SetText(L"0/0");
2072 __pFindWordEditField->SetText(L"");
2073 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2075 __currentSearchStr = L"";
2076 __pFindWordNext->SetEnabled(false);
2077 __pFindWordPrev->SetEnabled(false);
2078 __pFindWordCountLabel->SetShowState(false);
2079 __pFindWordControl->Invalidate(true);
2082 case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
2084 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2085 __pFindWordEditFieldRightToLeft->SetText(L"");
2086 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2088 __currentSearchStr = L"";
2089 __pFindWordNext->SetEnabled(false);
2090 __pFindWordPrev->SetEnabled(false);
2091 __pFindWordCountLabelRightToLeft->SetShowState(false);
2092 __pFindWordControl->Invalidate(true);
2095 case IDA_FINDWORD_NEXT_CLICKED:
2100 case IDA_FINDWORD_PREV_CLICKED:
2102 FindNextWord(false);
2105 case IDA_BRIGHTNESS_BTN_CLICKED:
2107 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
2108 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2111 case IDA_COPY_IMAGE_CLICKED:
2113 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2114 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2116 const Bitmap* pBitmap = null;
2117 if (__pHitElementResult != null && __pHitElementResult->HasImage())
2119 pBitmap = __pHitElementResult->GetImage();
2122 String resourcePath = App::GetInstance()->GetAppResourcePath();
2123 r = item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
2124 AppLog("Platofrm construct failed result %s",GetErrorMessage(r));
2125 // copying the item to clipboard
2126 Clipboard* pClipboard = Clipboard::GetInstance();
2127 if (pClipboard != null)
2129 r = pClipboard->CopyItem(item);
2130 AppLog("Platofrm copy failed result %s",GetErrorMessage(r));
2134 case IDA_VIEW_IMAGE_CLICKED:
2136 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
2137 WindowInfo* pNewWindowInfo = null;
2138 if (__pHitElementResult != null)
2140 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2141 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2147 case IDA_SAVE_IMAGE_CLICKED:
2149 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
2150 const Bitmap* pSaveBitmap = null;
2151 String imageName = GetImagePath();
2152 AppLog("Content manager image name %ls",imageName.GetPointer());
2155 imagePath.Append(imageName);
2156 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2157 AppLog("Content manager image path %ls",imagePath.GetPointer());
2158 if (__pHitElementResult != null)
2160 pSaveBitmap = __pHitElementResult->GetImage();
2162 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2166 UpdateImageContent(pBuffer, imageName);
2168 if(__pNotification != null)
2170 RemoveControl(__pNotification);
2171 __pNotification = null;
2173 __pNotification = new NotificationPanel(*this);
2175 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2176 msg.Append(imagePath);
2177 if (__pNotification != null)
2179 __pNotification->SetText(msg);
2180 if (__pFooterPanel->GetShowState() == true)
2182 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2186 __pNotification->SetPositionDiff(0);
2189 __pNotification->ShowNotification();
2194 int __modalMsgBoxResult;
2195 MessageBox* pMsgBox = new MessageBox();
2196 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
2197 pMsgBox->ShowAndWait(__modalMsgBoxResult);
2200 __modalMsgBoxResult = 0;
2204 case IDA_SHARE_IMAGE_CLICKED:
2206 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2207 if (__pPopUp != null)
2214 __pAddressbar->HideKeypad();
2216 __pPopUp = new(std::nothrow) SharePopup();
2217 __pPopUp->Initialize();
2218 if (__pHitElementResult != null)
2220 const Bitmap* pSaveBitmap = null;
2221 String imageName = GetImagePath();
2222 AppLog("Content manager image name %ls",imageName.GetPointer());
2225 imagePath.Append(imageName);
2226 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2227 AppLog("Content manager image path %ls",imagePath.GetPointer());
2228 if (__pHitElementResult != null)
2230 pSaveBitmap = __pHitElementResult->GetImage();
2232 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2234 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2235 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2237 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2238 pShareInfo->SetPageTitle(L"");
2239 pShareInfo->SetPageUrl(srcUrl);
2240 pShareInfo->SetImageAttached(true);
2241 pShareInfo->SetImagePath(imagePath);
2242 __pPopUp->RemoveAllShareInfo();
2243 __pPopUp->AddShareInfo(pShareInfo);
2244 __pPopUp->SetShowState(true);
2249 case IDA_HYPERLINK_OPEN_CLICKED:
2251 if (__pHitElementResult != null)
2253 String srcUrl = __pHitElementResult->GetUrl();
2255 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2257 if (pNewWindowInfo == null)
2261 result r = E_SUCCESS;
2262 SceneManager* pSceneManager = SceneManager::GetInstance();
2263 if (pSceneManager == NULL)
2267 ArrayList* pArgList = new(std::nothrow) ArrayList();
2268 if (pArgList == NULL)
2272 pArgList->Construct();
2274 pArgList->Add(*pNewWindowInfo);
2275 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2276 if (pArgList != null)
2283 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2289 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2291 if (__pHitElementResult == null)
2296 if(__pPopUp != null)
2303 __pAddressbar->HideKeypad();
2305 __pPopUp = new(std::nothrow) SharePopup();
2306 __pPopUp->Initialize();
2308 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2309 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2310 pShareInfo->SetImageAttached(false);
2311 __pPopUp->RemoveAllShareInfo();
2312 __pPopUp->AddShareInfo(pShareInfo);
2314 __pPopUp->SetShowState(true);
2318 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2322 if (__pHitElementResult != null)
2324 url = __pHitElementResult->GetUrl();
2327 String resourcePath = App::GetInstance()->GetAppResourcePath();
2328 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2330 // copying the item to clipboard
2331 Clipboard* pClipboard = Clipboard::GetInstance();
2332 if (pClipboard != null)
2334 pClipboard->CopyItem(item);
2338 case IDA_FIND_TEXT__CLICKED:
2340 // AddressBarCancelledClicked(*__pAddressbar);
2341 RelayoutControls(false);
2342 // __pFooterPanel->SetShowState(false);
2343 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2344 __currentSearchStr.Clear();
2345 __currentSearchStr.Append(__currentSelectedStr);
2346 InitFindWordPanel();
2347 __pFindWordEditField->SetText(__currentSearchStr);
2349 if(__pOptionMenu != null)
2351 __pOptionMenu->SetShowState(false);
2352 __pOptionMenu->Invalidate(false);
2354 __adressPanelPosition.y = 0;
2356 if (__pAddressbar != null && __pWebViewer != NULL)
2358 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2359 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2361 if (__pFooterPanel->GetShowState() == false)
2362 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2364 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2365 __pWebViewer->Invalidate(true);
2368 ShowFindWordPanel(true);
2369 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2371 __pFindWordEditField->SetText(__currentSearchStr);
2372 __pFindWordEditField->SetFocus();
2374 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2376 __pFindWordEditFieldRightToLeft->SetText(__currentSearchStr);
2377 __pFindWordEditFieldRightToLeft->SetFocus();
2380 if (__currentSearchStr.GetLength() > 0)
2386 AppLogDebug("Enter something");
2389 if (__pWebViewer != null)
2391 // releasing the set block
2392 __pWebViewer->ReleaseBlock();
2397 case IDA_SHARE_TEXT_CLICKED:
2399 __pWebViewer->ReleaseBlock();
2400 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2401 if(__pPopUp != null)
2408 __pAddressbar->HideKeypad();
2410 __pPopUp = new(std::nothrow) SharePopup();
2411 __pPopUp->Initialize();
2412 if (__pHitElementResult != null)
2414 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2415 pShareInfo->SetPageTitle(L"");
2416 pShareInfo->SetPageUrl(__currentSelectedStr);
2417 pShareInfo->SetImageAttached(false);
2418 __pPopUp->RemoveAllShareInfo();
2419 __pPopUp->AddShareInfo(pShareInfo);
2420 __pPopUp->SetShowState(true);
2425 case IDA_COPY_TEXT_CLICKED:
2427 __pWebViewer->ReleaseBlock();
2428 // need to implement
2429 //__currentSelectedStr
2430 // Sets data to a clip board item
2432 String resourcePath = App::GetInstance()->GetAppResourcePath();
2433 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2435 // copying the item to clipboard
2436 Clipboard* pClipboard = Clipboard::GetInstance();
2437 if (pClipboard != null)
2439 pClipboard->CopyItem(item);
2443 case IDA_PASTE_TEXT_CLICKED:
2445 Clipboard* pClipboard = Clipboard::GetInstance();
2447 if(pClipboard == null)
2451 // Retrieves a latest item
2452 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2458 //Gets data from the clipboard item
2459 String* pString = dynamic_cast<String*>(pItem->GetData());
2461 if (pString != null)
2463 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2464 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2465 String tagElement = __pHitElementResult->GetTagName();
2466 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2469 if(idElement.GetLength() != 0)
2471 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; } } ";
2472 script.Append("insertAtCursor('");
2473 script.Append(idElement);
2474 script.Append("',");
2475 script.Append("\"");
2476 script.Append(*pString);
2477 script.Append("\");");
2479 else if (nameElement.GetLength() != 0)
2481 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; } } ";
2482 script.Append("insertAtCursor(document.getElementsByName('");
2483 script.Append(nameElement);
2484 script.Append("')[0],");
2485 script.Append("\"");
2486 script.Append(*pString);
2487 script.Append("\");");
2489 else//adding for twitter post page
2491 script = L"function insertAtCursor(myField, myValue) { if (document.selection) { document.getElementsByTagName(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.getElementsByTagName(myField)[0].value += myValue; } } ";
2492 script.Append("insertAtCursor(document.getElementsByTagName('");
2493 script.Append(tagElement);
2494 script.Append("')[0],");
2495 script.Append("\"");
2496 script.Append(*pString);
2497 script.Append("\");");
2499 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2500 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2511 case IDA_GO_FORWARD:
2516 case IDA_REFRESH_BTN_CLICKED:
2518 __isLoadingCompleted = false;
2519 __isLoadingData = true;
2520 __progressPercentage = 0;
2521 __displayUrl = __pFooterUrlField->GetText();
2523 String url = __pFooterUrlField->GetText();
2524 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2526 if (__pWebViewer != null && __pAddressbar != null)
2528 __pWebViewer->Reload();
2529 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2533 UpdateProgressBitmap();
2536 case IDA_STOP_BTN_CLICKED:
2538 __isLoadingCompleted = false;
2539 __isLoadingData = false;
2540 __progressPercentage = 0;
2541 __pFooterUrlField->HideKeypad();
2542 __displayUrl = __pFooterUrlField->GetText();
2546 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2547 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2548 __pWebViewer->StopLoading();
2549 RequestRedraw(true);
2552 UpdateProgressBitmap();
2557 if (__pFooterUrlField->GetText().IsEmpty() == false)
2559 //__displayUrl = __pUrlField->GetText();
2560 __pFooterUrlField->Clear();
2565 case IDA_READER_BTN_CLICKED:
2576 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2578 result r = E_FAILURE;
2579 if(__pImageMenu && __pImageMenu->GetShowState() == true)
2581 AppLog("Hiding the menu");
2582 __pImageMenu->SetShowState(false);
2584 if (__pWebViewer && __pWebViewer->CanGoBack())
2586 __pWebViewer->GoBack();
2588 else if(__pWindowInfo->isJavascriptInitiated == false)
2591 pApp = UiApp::GetInstance();
2594 RemoveOrientationEventListener(*this);
2598 __pAddressbar->SetAddressbarEventListener(null);
2603 __pWebViewer->RemoveTouchEventListener(*this);
2604 __pWebViewer->SetWebUiEventListenerF(null);
2605 __pWebViewer->SetWebKeypadEventListener(null);
2606 __pWebViewer->SetTextSearchListener(null);
2607 __pWebViewer->SetLoadingListener(null);
2609 r = pApp->Terminate();
2612 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2620 WindowInfo* pWindowInfo = null;
2622 SceneManager* pSceneManager = SceneManager::GetInstance();
2623 if (pSceneManager == null)
2627 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2628 if (pAllWindowList == NULL)
2630 pApp = UiApp::GetInstance();
2633 RemoveOrientationEventListener(*this);
2637 __pAddressbar->SetAddressbarEventListener(null);
2642 __pWebViewer->RemoveTouchEventListener(*this);
2643 __pWebViewer->SetWebUiEventListenerF(null);
2644 __pWebViewer->SetWebKeypadEventListener(null);
2645 __pWebViewer->SetTextSearchListener(null);
2646 __pWebViewer->SetLoadingListener(null);
2648 r = pApp->Terminate();
2651 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2656 if (pAllWindowList != null)
2658 totalCount = pAllWindowList->GetCount();
2660 for (int count = 0; count < totalCount; count++)
2662 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2663 if (pWindowInfo == null)
2665 pApp = UiApp::GetInstance();
2668 RemoveOrientationEventListener(*this);
2672 __pAddressbar->SetAddressbarEventListener(null);
2677 __pWebViewer->RemoveTouchEventListener(*this);
2678 __pWebViewer->SetWebUiEventListenerF(null);
2679 __pWebViewer->SetWebKeypadEventListener(null);
2680 __pWebViewer->SetTextSearchListener(null);
2681 __pWebViewer->SetLoadingListener(null);
2683 r = pApp->Terminate();
2686 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2693 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2695 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2698 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2701 r = pAllWindowList->RemoveAt(count, true);
2702 __pWindowInfo = null;
2705 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2710 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2714 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2716 if (pWindowInfo == null)
2718 pApp = UiApp::GetInstance();
2721 RemoveOrientationEventListener(*this);
2725 __pAddressbar->SetAddressbarEventListener(null);
2730 __pWebViewer->RemoveTouchEventListener(*this);
2731 __pWebViewer->SetWebUiEventListenerF(null);
2732 __pWebViewer->SetWebKeypadEventListener(null);
2733 __pWebViewer->SetTextSearchListener(null);
2734 __pWebViewer->SetLoadingListener(null);
2736 r = pApp->Terminate();
2742 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2745 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2757 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2758 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2761 AppLog("MainForm::OnSceneActivatedN called");
2762 String* pSelectedScene = NULL;
2763 Object* pValue = NULL;
2764 String* pUrl = null;
2765 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2766 pSelectedScene = (String*) pValue;
2768 if (pSelectedScene != null)
2770 delete pSelectedScene;
2772 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2773 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2774 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2775 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2777 // setting the current scene ID
2778 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2780 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2782 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2784 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2785 if(__pWindowInfo == null)
2787 // if(__pWindowInfo == null)
2789 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2792 else if ( pArgs != null && pArgs->GetCount() == 1)
2794 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2800 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2802 // hiding the address bar
2803 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2804 __pAddressbar->SetShowState(false);
2805 // if(__pWebViewer != null)
2807 // __pWebViewer->Resume();
2810 if(pUrl != null && pUrl->GetLength() > 0)
2814 else if(__pWindowInfo != null)
2816 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)
2818 LoadUrl(__pWindowInfo->pageUrl);
2820 else if(__pWindowInfo->pageUrl.GetLength() > 0 && __pWindowInfo->isAppcontrolTriggered == true)
2822 LoadUrl(__pWindowInfo->pageUrl);
2824 else if (__pWindowInfo->isJavascriptInitiated == true)
2828 __pWindowInfo->pCurrentWeb = __pWebViewer;
2832 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2833 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2834 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2836 InitMostVisitedSitesView(GetOrientationStatus());
2838 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2840 if(__pMostVisitedListView != null)
2842 __pMostVisitedListView->SetShowState(false);
2846 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2848 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2850 if (pBookmarkUrl == null)
2852 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2853 //__pAddressbar->SetUrl(*pBookmarkUrl);
2854 SetUrl(*pBookmarkUrl);
2856 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2857 __pWebViewer->LoadUrl(*pBookmarkUrl);
2858 delete pBookmarkUrl;
2861 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2862 Bitmap* pBitmap = null;
2863 if (isPrivateBrowsing == true)
2865 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2867 if (__pWebViewer != null)
2869 __pWebViewer->SetPrivateBrowsingEnabled(true);
2872 if (__pAddressbar != null)
2874 // __pAddressbar->UpdateFaviconBitmap(true);
2880 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2882 if (__pWebViewer != null)
2884 __pWebViewer->SetPrivateBrowsingEnabled(false);
2887 if (__pAddressbar != null)
2889 // __pAddressbar->UpdateFaviconBitmap(false);
2893 if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
2895 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2897 else if (__pOptionMenu != null )
2899 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2902 if (pBitmap != null)
2907 RelayoutControls(false);
2908 AppLog("ABC: OnSceneActivatedN started exit");
2913 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2914 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2916 Canvas* pWebCanvas = null;
2917 if (__pWebViewer != null)
2919 pWebCanvas = __pWebViewer->GetCanvasN();
2922 if (pWebCanvas == null)
2926 if (__pWindowInfo != null)
2928 if (__pWindowInfo->pWebCanvasBitmap != null)
2930 delete __pWindowInfo->pWebCanvasBitmap;
2932 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2933 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2934 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2936 Bitmap* pBitmap = GetCapturedBitmapN();
2937 AppLog("Coming here");
2938 Canvas* pCanvas = new(std::nothrow) Canvas();
2939 pCanvas->Construct(GetClientAreaBounds());
2942 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2945 if(__pWebViewer != null && __pWindowInfo != null)
2946 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2948 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2949 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2952 AppLog("Coming here");
2956 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2957 const Tizen::Base::String& realm,
2958 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2964 MainForm::OnHttpAuthenticationCanceled(void)
2969 MainForm::OnLoadingStarted(void)
2971 AppLogDebug("MainForm::OnLoadingStarted entered");
2973 if(__pAddressbar == NULL || __pWebViewer == null)
2978 // this is added in case if menu is opened and user load the page
2979 if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
2981 __pOptionMenu->SetShowState(false);
2982 __pOptionMenu->Invalidate(true);
2987 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2989 __pImageMenu->SetShowState(false);
2990 __pImageMenu->Invalidate(true);
2992 String url = __pWebViewer->GetUrl();
2993 if(url.Contains(IDS_TIZEN_SERVICE))
2996 String delim(L":;,");
2998 // Creates a StringTokenizer instance
2999 StringTokenizer strTok(url, delim);
3001 int count = strTok.GetTokenCount(); // count == 4
3003 HashMap *pMap = new HashMap();
3008 while (strTok.HasMoreTokens())
3010 AppLog("Token: %ls", token.GetPointer());
3011 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3012 if(token.Contains(IDS_APPID))
3014 token.SubString(6, appId);
3015 AppLog("AppID:%ls", appId.GetPointer());
3017 else if(token.Contains(IDS_KEY))
3019 token.SubString(4, key);
3020 AppLog("key:%ls", key.GetPointer());
3022 else if(token.Contains(IDS_VALUE))
3024 token.SubString(6, value);
3025 AppLog("value:%ls", value.GetPointer());
3028 pMap->Add(key, value);
3032 AppControl *pAppControl = null;
3033 String operationId = L"http://tizen.org/appcontrol/operation/main";
3034 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3037 AppLog("Starting AppControl");
3038 result r = pAppControl->Start(null, null, pMap, null);
3039 AppLog("Result of Start %s", GetErrorMessage(r));
3043 AppLogException("AppControl not found");
3048 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
3050 __pAddressbar->SetShowState(false);
3051 AddressBarCancelledClicked(*__pAddressbar);
3052 __pAddressbar->Invalidate(true);
3054 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
3057 __pAddressbar->SetFaviconBitmap(*pBitmap);
3060 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
3062 // updating the address bar position with respect to web control
3063 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
3064 __distanceMoved = 0;
3068 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3069 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3070 if (__pWebViewer != null)
3072 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
3073 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
3074 SetUrl(__pWebViewer->GetUrl());
3075 if (__pWindowInfo != NULL)
3077 // resetting the page title to blank, it will be received in OnPageTitleReceived()
3078 __pWindowInfo->pageTitle = L"";
3079 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3081 __pAddressbar->Invalidate(true);
3087 MainForm::OnLoadingCanceled(void)
3094 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
3096 AppLog("XYZ::MainForm::OnKeypadWillOpen");
3101 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
3103 AppLog("XYZ::MainForm::OnKeypadOpened");
3104 __isKeypadOpened = true;
3105 __pFooterPanel->SetShowState(false);
3110 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
3112 AppLog("XYZ::MainForm::OnKeypadClosed");
3113 __isKeypadOpened = false;
3114 __pFooterPanel->SetShowState(true);
3115 RelayoutControls(true);
3119 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
3121 AppLog("XYZ::KeypadBoundsChanged");
3122 RelayoutControls(false);
3126 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
3127 const Tizen::Base::String& reason)
3129 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
3133 MainForm::OnLoadingCompleted(void)
3135 AppLog("MainForm::OnLoadingCompleted start");
3137 result r = E_SUCCESS;
3139 if (__pWebViewer == null)
3144 if (__pAddressbar == null)
3149 if(__pImageMenu && __pImageMenu->GetShowState())
3151 __pImageMenu->SetShowState(false);
3152 __pImageMenu->Invalidate(true);
3155 if (__pWebViewer->CanGoForward())
3157 //__pAddressbar->SetForwardButtonEnabled(true);
3158 SetForwardButtonEnabled(true);
3162 //__pAddressbar->SetForwardButtonEnabled(false);
3163 SetForwardButtonEnabled(false);
3166 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3168 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3170 //__pAddressbar->UpdateProgress(0);
3174 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3176 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3180 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
3181 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
3182 if (isPrivateBrowsing == false)
3184 if(__pHistory != null)
3190 __pHistory = new(std::nothrow) History;
3191 HistoryPresentationModel::GetCurrentDateTime(date);
3194 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
3195 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
3197 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
3198 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3200 __pHistory->SetVisitedTime(date);
3202 if (__pWebViewer != null)
3204 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3206 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3207 if (pTempBitmap != null)
3209 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3210 __pHistory->SetFavIconBitmap(*pTempBitmap);
3213 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3216 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3217 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3218 if ( pCanvas != null && pCanvas != null && pBitmap != null)
3220 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3221 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3222 __pHistory->SetThumbnail(pBitmap);
3224 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3227 __pHistory->SetFavIconBitmap(*pFavIcon);
3231 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3238 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3240 // temperary fixed (webpage can be not loaded)
3244 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3245 if (isReaderEnabled == true)
3249 delete __pReaderData;
3250 __pReaderData = null;
3252 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3253 filePath.Append(L"data/reader.js");
3259 result r = E_SUCCESS;
3260 FileAttributes attr;
3262 File::GetAttributes(filePath,attr);
3264 r = file.Construct(filePath, L"r+");
3267 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3270 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3273 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3276 // file.Read(pScript,attr.GetFileSize());
3278 // AppLogDebug("scipt length %d",strlen(pScript));
3279 String strScript = L"";
3280 // strScript.Append(pScript);
3281 // for(int i=0; i<25; i++)
3283 file.Read(pScript,attr.GetFileSize());
3284 // AppLog("xyzz tell %d",file.Tell());
3285 // r = strScript.Append(pScript);
3286 // AppLog("xyzz append result %s",GetErrorMessage(r));
3287 // AppLog("xyzz strScript length %d",strScript.GetLength());
3289 // AppLog("xyzz final strScript length %d",strScript.GetLength());
3291 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3292 if (__pReaderData == null)
3294 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3295 __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>");
3298 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3299 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3301 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3302 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3308 AppLog("MainForm::OnLoadingCompleted done");
3312 MainForm::OnEstimatedProgress(int progress)
3314 AppLogDebug("MainForm::OnEstimatedProgress entered");
3316 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3317 progress = DEFAULT_PROGRESS_PERCENTAGE;
3319 // __pAddressbar->UpdateProgress(progress);
3320 UpdateProgress(progress);
3323 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3325 AppLog("MainForm::OnFaviconReceived");
3326 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3328 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3331 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3338 MainForm::OnUrlValueChanged(Addressbar&)
3344 MainForm::OnUrlSubmitted(Addressbar& addBar)
3346 AppLog("MainForm::OnUrlSubmitted");
3347 String url = addBar.GetUrl();
3348 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3350 if(__pFooterUrlField)
3351 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3352 AddressBarCancelledClicked(*__pAddressbar);
3357 MainForm::LoadUrl(String& url)
3361 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3362 AppLogDebug("MainForm::LoadUrl enter");
3364 if (__pWebViewer != null)
3366 __pWebViewer->SetShowState(true);
3367 __pWebViewer->Invalidate(true);
3370 if (url.CompareTo(L"") == 0)
3374 if(__pFooterPanel != null)
3376 __pFooterPanel->SetShowState(true);
3377 __pFooterPanel->Invalidate(true);
3384 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3385 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)
3387 RegularExpression firstRegex;
3388 RegularExpression secondRegex;
3390 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3391 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3394 ret = firstRegex.Match(url, false); // This returns true value
3395 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3397 if (ret == true && __pWebViewer != null)
3400 __pWebViewer->LoadUrl(url);
3402 else if(__pWebViewer != null)
3404 String tempUrl = L"http://";
3405 tempUrl.Append(url);
3409 __pWebViewer->LoadUrl(tempUrl);
3413 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3414 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3417 if (__pAddressbar != null)
3419 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3420 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3423 AppLogDebug("MainForm::LoadUrl exit");
3430 MainForm::OnFocusGained(const Tizen::Ui::Control& source)
3432 AppLog("MainForm::OnFocusGained");
3435 __pFooterPanel->SetShowState(false);
3440 __pAddressbar->SetShowState(true);
3441 __pAddressbar->SetAddressbarURLFocus();
3443 RelayoutControls(false);
3447 MainForm::OnFocusLost(const Tizen::Ui::Control& source)
3449 AppLog("MainForm::OnFocusLost called");
3453 MainForm::OnStopClicked(Addressbar& addBar)
3455 AppLogDebug("MainForm::OnStopClicked called");
3458 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3459 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3460 __pWebViewer->StopLoading();
3461 RequestRedraw(true);
3466 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3468 // AppLog("MainForm::OnBackClicked");
3469 result r = E_FAILURE;
3470 if(__pImageMenu && __pImageMenu->GetShowState() == true)
3472 AppLog("Hiding the menu");
3473 __pImageMenu->SetShowState(false);
3476 if (__pWebViewer && __pWebViewer->CanGoBack())
3478 __pWebViewer->GoBack();
3480 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3483 pApp = UiApp::GetInstance();
3487 RemoveOrientationEventListener(*this);
3491 __pAddressbar->SetAddressbarEventListener(null);
3496 __pWebViewer->RemoveTouchEventListener(*this);
3497 __pWebViewer->SetWebUiEventListenerF(null);
3498 __pWebViewer->SetWebKeypadEventListener(null);
3499 __pWebViewer->SetTextSearchListener(null);
3500 __pWebViewer->SetLoadingListener(null);
3504 r = pApp->Terminate();
3507 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3515 WindowInfo* pWindowInfo = null;
3517 SceneManager* pSceneManager = SceneManager::GetInstance();
3518 if (pSceneManager == null)
3522 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3523 if (pAllWindowList == NULL)
3525 pApp = UiApp::GetInstance();
3528 RemoveOrientationEventListener(*this);
3532 __pAddressbar->SetAddressbarEventListener(null);
3537 __pWebViewer->RemoveTouchEventListener(*this);
3538 __pWebViewer->SetWebUiEventListenerF(null);
3539 __pWebViewer->SetWebKeypadEventListener(null);
3540 __pWebViewer->SetTextSearchListener(null);
3541 __pWebViewer->SetLoadingListener(null);
3545 r = pApp->Terminate();
3548 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3553 if (pAllWindowList != null)
3555 totalCount = pAllWindowList->GetCount();
3557 for (int count = 0; count < totalCount; count++)
3559 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3560 if (pWindowInfo == null)
3562 pApp = UiApp::GetInstance();
3565 RemoveOrientationEventListener(*this);
3569 __pAddressbar->SetAddressbarEventListener(null);
3574 __pWebViewer->RemoveTouchEventListener(*this);
3575 __pWebViewer->SetWebUiEventListenerF(null);
3576 __pWebViewer->SetWebKeypadEventListener(null);
3577 __pWebViewer->SetTextSearchListener(null);
3578 __pWebViewer->SetLoadingListener(null);
3582 r = pApp->Terminate();
3585 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3590 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3592 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3595 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3598 r = pAllWindowList->RemoveAt(count, true);
3599 __pWindowInfo = null;
3602 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3607 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3609 else if(pAllWindowList->GetCount() > 0)
3611 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3615 pApp = UiApp::GetInstance();
3618 RemoveOrientationEventListener(*this);
3622 __pAddressbar->SetAddressbarEventListener(null);
3627 __pWebViewer->RemoveTouchEventListener(*this);
3628 __pWebViewer->SetWebUiEventListenerF(null);
3629 __pWebViewer->SetWebKeypadEventListener(null);
3630 __pWebViewer->SetTextSearchListener(null);
3631 __pWebViewer->SetLoadingListener(null);
3635 r = pApp->Terminate();
3640 if (pWindowInfo == null)
3642 pApp = UiApp::GetInstance();
3645 RemoveOrientationEventListener(*this);
3649 __pAddressbar->SetAddressbarEventListener(null);
3654 __pWebViewer->RemoveTouchEventListener(*this);
3655 __pWebViewer->SetWebUiEventListenerF(null);
3656 __pWebViewer->SetWebKeypadEventListener(null);
3657 __pWebViewer->SetTextSearchListener(null);
3658 __pWebViewer->SetLoadingListener(null);
3662 r = pApp->Terminate();
3668 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3671 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3685 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3687 AppLog("MainForm::OnForwardClicked");
3688 if (__pWebViewer == null)
3691 if (__pWebViewer->CanGoForward())
3693 __pWebViewer->GoForward();
3698 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3700 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3701 if(__pFooterPanel != null)
3703 __pFooterPanel->SetShowState(false);
3706 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3708 __pAddressbar->SetShowState(true);
3709 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3712 RelayoutControls(false);
3716 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3718 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3720 int Height = GetClientAreaBounds().height;
3721 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3723 RelayoutControls(false);
3727 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3729 AddressBarCancelledClicked(addBar);
3733 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3735 __prevAddressBarMode = __curAddressBarMode;
3737 if (__pAddressbar != null)
3739 __curAddressBarMode = GetAddressbarMode();
3742 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3744 __adressPanelPosition.y = 0;
3745 if (__pAddressbar != null)
3747 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3748 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3749 __pAddressbar->Invalidate(true);
3751 if (__pWebViewer != null)
3753 __pWebViewer->StopLoading();
3756 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3758 __adressPanelPosition.y = 0;
3759 if (__pAddressbar != null)
3761 __webControlPosition.y = 0;
3762 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3763 __pAddressbar->Invalidate(true);
3769 MainForm::OnClipboardClosed(const Addressbar& addBar)
3771 AppLog("XYZ::MainForm::OnClipboardClosed");
3772 RelayoutControls(false);
3776 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3778 AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3779 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3781 AppLog("akjshdasd 3");
3782 __pFooterPanel->SetShowState(true);
3785 RelayoutControls(false,footerState);
3789 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3791 AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3792 RelayoutControls(false);
3796 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3798 __pFooterPanel->SetShowState(false);
3802 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3804 AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3805 RelayoutControls(false);
3809 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3811 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3814 __pWindowInfo->pageTitle = title;
3815 if (__pWebViewer != null)
3817 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3820 if (__pAddressbar != null && __pWebViewer != null)
3822 SetUrl(__pWebViewer->GetUrl());
3823 __pAddressbar->Invalidate(true);
3828 MainForm::UpdateFavicon(void)
3830 bool urlImageType = false;
3831 String *tempPath = null;
3833 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();");
3834 Bitmap* pBitmap = null;
3836 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3838 if (__pWindowInfo != null)
3841 url.SetUri(*tempPath);
3842 if (url.GetHost().GetLength() == 0)
3845 webUrl.SetUri(__pWebViewer->GetUrl());
3846 result r = url.SetHost(webUrl.GetHost());
3853 if (url.GetScheme().GetLength() == 0)
3856 webUrl.SetUri(__pWebViewer->GetUrl());
3857 url.SetScheme(webUrl.GetScheme());
3859 __pWindowInfo->faviconUrl = url.ToString();
3861 pBitmap = __pWebViewer->GetFaviconN();
3863 if (pBitmap != null)
3865 if (__pWindowInfo->pFavicon != NULL)
3867 __pWindowInfo->pFavicon = null;
3869 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3870 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3872 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3874 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3876 else if(__pWindowInfo->pFavicon != null)
3878 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3882 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3883 if(pDefaultBmp != null)
3885 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3899 if(tempPath != null)
3903 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3909 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3910 Tizen::Web::Controls::WebNavigationType type)
3912 AppLog("urlk %ls",url.GetPointer());
3913 // when load new page if find word panel is open its show state is false
3914 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3916 __currentSearchStr = L"";
3917 __currentWordIndex = 0;
3918 __maxOccurrances = 0;
3919 __pFindWordEditField->SetText(L"");
3920 __pFindWordNext->SetEnabled(false);
3921 __pFindWordPrev->SetEnabled(false);
3922 __pFindWordCountLabel->SetText(L"0/0");
3923 __pFindWordControl->SetShowState(false);
3924 __pFindWordEditField->HideKeypad();
3925 RelayoutControls(false);
3928 __pFooterPanel->Invalidate(true);
3931 uriInfo.SetUri(url);
3933 if(url.Contains(IDS_TIZEN_SERVICE))
3936 String delim(L":;,");
3938 // Creates a StringTokenizer instance
3939 StringTokenizer strTok(url, delim);
3941 int count = strTok.GetTokenCount(); // count == 4
3943 HashMap *pMap = new HashMap();
3949 while (strTok.HasMoreTokens())
3951 AppLog("Token: %ls", token.GetPointer());
3952 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3953 if(token.Contains(IDS_APPID))
3955 token.SubString(6, appId);
3956 AppLog("AppID:%ls", appId.GetPointer());
3958 else if(token.Contains(IDS_KEY))
3960 token.SubString(4, key);
3961 AppLog("key:%ls", key.GetPointer());
3963 else if(token.Contains(IDS_VALUE))
3965 token.SubString(6, value);
3966 AppLog("value:%ls", value.GetPointer());
3969 pMap->Add(key, value);
3973 AppControl *pAppControl = null;
3974 String operationId = L"http://tizen.org/appcontrol/operation/main";
3975 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3978 result r = pAppControl->Start(null, null, pMap, null);
3982 AppLogException("AppControl not found");
3992 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3993 const Tizen::Net::Http::HttpHeader& httpHeader)
3995 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3999 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
4001 if(__isLongPressedDone == false)
4003 AppLog("MainForm::OnWebPageBlockSelected");
4004 if (__pHitElementResult != null)
4006 delete __pHitElementResult;
4007 __pHitElementResult = null;
4010 if (__pWebViewer != null)
4012 AppLog("MainForm::OnWebPageBlockSelected web not null");
4013 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
4015 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
4017 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
4018 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
4019 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
4021 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
4023 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
4027 if (__pHitElementResult == null)
4032 if (__pHitElementResult->HasImage() != true)
4034 String tagName = __pHitElementResult->GetTagName();
4035 String type = __pHitElementResult->GetAttributeValue("type");
4038 AppLog("TagName %ls",tagName.GetPointer());
4039 __currentSelectedStr.Clear();
4040 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
4041 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4042 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
4044 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
4046 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4048 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),true);
4049 __pImageMenu->SetShowState(true);
4050 __pImageMenu->Show();
4051 __pImageMenu->Invalidate(true);
4053 else /*if(__isLongPressedDone == true)*/
4055 AppLog("MainForm::OnWebPageBlockSelected no paste option");
4057 if(__pHitElementResult->GetUrl().GetLength() > 0)
4059 __currentSelectedStr.Clear();
4060 __currentSelectedStr = __pHitElementResult->GetUrl();
4062 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),false);
4063 __pImageMenu->SetShowState(true);
4064 __pImageMenu->Show();
4065 __pImageMenu->Invalidate(true);
4068 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
4069 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
4070 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
4076 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
4082 MainForm::OnWebWindowCreateRequested(void)
4084 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
4086 if (pNewWindowInfo == null)
4090 result r = E_SUCCESS;
4091 SceneManager* pSceneManager = SceneManager::GetInstance();
4092 if (pSceneManager == NULL)
4096 ArrayList* pArgList = new(std::nothrow) ArrayList();
4097 if (pArgList == NULL)
4101 r = pArgList->Construct();
4104 pNewWindowInfo->isJavascriptInitiated = true;
4105 pArgList->Add(*pNewWindowInfo);
4106 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4110 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
4117 return pNewWindowInfo->pCurrentWeb;
4121 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
4123 AppLog("xyz:: MainForm::RelayoutControls called");
4124 __webControlPosition.y = 0;
4125 __webControlHeight = GetClientAreaBounds().height;
4126 AppLog("Client area height: %d", __webControlHeight);
4128 AppLog("Client area height: %d", __webControlHeight);
4129 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
4131 __webControlPosition.y += __pAddressbar->GetHeight();
4132 __webControlHeight -= __pAddressbar->GetHeight();
4133 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
4135 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
4137 __webControlPosition.y += __pFindWordControl->GetHeight();
4138 __webControlHeight -= __pFindWordControl->GetHeight();
4139 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
4142 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
4144 __webControlHeight -= __pFooterPanel->GetHeight();
4146 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
4148 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
4150 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight + 12 )
4155 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12);
4156 AppLog("xyz:: MainForm::RelayoutControls called __webControlHeight %d",__webControlHeight);
4157 __pWebViewer->Invalidate(false);
4160 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
4162 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
4169 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
4171 if (__pFindWordControl == null)
4176 Tizen::Locales::LocaleManager localeManager;
4177 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
4179 String languageCode;
4180 result r = SettingInfo::GetValue(L"Language", languageCode);
4181 // int languagecode = local.GetLanguageCode();
4182 AppLog("rahul language is %S", languageCode.GetPointer());
4186 InitFindWordPanel();
4188 if (languageCode.CompareTo("ara") == 0)
4190 AppLog("rahul language is arabic");
4192 __pFindWordPanelLeftToRight->SetShowState(false);
4193 __pFindWordPanelRightToLeft->SetShowState(true);
4195 __pFindWordClear->SetShowState(false);
4196 __pFindWordCountLabel->SetShowState(false);
4197 __pFindWordEditField->SetShowState(false);
4199 __pFindWordClearRightToLeft->SetShowState(true);
4200 __pFindWordCountLabelRightToLeft->SetShowState(true);
4201 __pFindWordEditFieldRightToLeft->SetShowState(true);
4205 AppLog("rahul language is not arabic");
4208 __pFindWordPanelLeftToRight->SetShowState(true);
4209 __pFindWordPanelRightToLeft->SetShowState(false);
4211 __pFindWordClear->SetShowState(true);
4212 __pFindWordCountLabel->SetShowState(true);
4213 __pFindWordEditField->SetShowState(true);
4215 __pFindWordClearRightToLeft->SetShowState(false);
4216 __pFindWordCountLabelRightToLeft->SetShowState(false);
4217 __pFindWordEditFieldRightToLeft->SetShowState(false);
4219 __pFindWordControl->SetShowState(true);
4223 if(__pFindWordControl != null)
4225 __pFindWordControl->SetShowState(false);
4229 AppLog("MainForm::ShowFindWordPanel %d",show);
4230 if (show && !isTouchPressed)
4232 if (languageCode.CompareTo("ara") == 0)
4234 if (__pFindWordEditFieldRightToLeft)
4236 __pFindWordEditFieldRightToLeft->SetFocus();
4237 __pFindWordEditFieldRightToLeft->ShowKeypad();
4242 if (__pFindWordEditField)
4244 __pFindWordEditField->SetFocus();
4245 __pFindWordEditField->ShowKeypad();
4251 if (languageCode.CompareTo("ara") == 0)
4253 if (__pFindWordEditFieldRightToLeft)
4254 __pFindWordEditFieldRightToLeft->HideKeypad();
4258 if (__pFindWordEditField)
4259 __pFindWordEditField->HideKeypad();
4263 RelayoutControls(false);
4267 MainForm::StartWordSearch()
4269 //Get the count of occurances of the word in the current page
4270 __maxOccurrances = 0;
4271 __currentWordIndex = 0;
4273 __pFindWordPrev->SetEnabled(false);
4274 String *pCountStr = null;
4275 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
4276 AppLog("Search Result %s",GetErrorMessage(r));
4277 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
4278 if (pCountStr != null)
4280 Integer::Parse(*pCountStr, 10, __maxOccurrances);
4284 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
4289 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
4291 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
4292 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
4294 if(totalCount == -1 || totalCount == 0)
4296 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
4297 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
4300 else if(totalCount > 100)
4302 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4303 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4307 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4308 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4311 __maxOccurrances = totalCount;
4312 __currentWordIndex = currentOrdinal;
4314 //Reset the UI controls as per the maxOccurrance value
4315 if (totalCount <= 0)
4317 AppLog("Word not found");
4318 //Show error notification to user
4319 __pFindWordNext->SetEnabled(false);
4320 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4322 __pFindWordCountLabel->SetText(L"0/0");
4323 __pFindWordCountLabel->Invalidate(false);
4325 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4327 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4328 __pFindWordCountLabelRightToLeft->Invalidate(false);
4330 __pFindWordNext->Invalidate(false);
4331 __pFindWordPrev->Invalidate(false);
4336 if (totalCount == 1)
4338 __pFindWordNext->SetEnabled(false);
4342 __pFindWordNext->SetEnabled(true);
4345 String countStr = L"";
4346 countStr.Append(__currentWordIndex);
4347 countStr.Append(L"/");
4348 countStr.Append(__maxOccurrances);
4349 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4351 __pFindWordCountLabel->SetText(countStr);
4352 __pFindWordCountLabel->Invalidate(false);
4353 __pFindWordCountLabel->Invalidate(false);
4355 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4357 __pFindWordCountLabelRightToLeft->SetText(countStr);
4358 __pFindWordCountLabelRightToLeft->Invalidate(false);
4359 __pFindWordCountLabelRightToLeft->Invalidate(false);
4361 //FindNextWord(true);
4362 //Update the controls
4363 __pFindWordNext->Invalidate(false);
4364 __pFindWordPrev->Invalidate(false);
4369 MainForm::FindNextWord(bool next)
4373 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4374 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4376 if (__currentWordIndex < __maxOccurrances)
4378 __currentWordIndex++;
4384 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4385 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4387 if(__currentWordIndex > 1)
4389 __currentWordIndex--;
4394 String countStr = L"";
4395 countStr.Append(__currentWordIndex);
4396 countStr.Append(L"/");
4397 countStr.Append(__maxOccurrances);
4399 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4401 __pFindWordCountLabel->SetText(countStr);
4402 __pFindWordCountLabel->Invalidate(false);
4404 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4406 __pFindWordCountLabelRightToLeft->SetText(countStr);
4407 __pFindWordCountLabelRightToLeft->Invalidate(false);
4410 if (__currentWordIndex >= __maxOccurrances)
4412 __pFindWordNext->SetEnabled(false);
4416 __pFindWordNext->SetEnabled(true);
4418 if (__currentWordIndex <= 1)
4420 __pFindWordPrev->SetEnabled(false);
4424 __pFindWordPrev->SetEnabled(true);
4426 __pFindWordPrev->Invalidate(false);
4427 __pFindWordNext->Invalidate(false);
4429 __pFindWordControl->Invalidate(true);
4433 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4435 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4436 __isKeypadOpened = true;
4437 __pFooterPanel->SetShowState(false);
4438 // OnAddressBarKeypadOpened(*__pAddressbar);
4442 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4444 __isKeypadOpened = true;
4445 AppLog("xyz::MainForm::OnWebKeypadOpened");
4447 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4449 __currentSearchStr = L"";
4450 __currentWordIndex = 0;
4451 __maxOccurrances = 0;
4452 __pFindWordEditField->SetText(L"");
4453 __pFindWordNext->SetEnabled(false);
4454 __pFindWordPrev->SetEnabled(false);
4455 __pFindWordCountLabel->SetText(L"0/0");
4456 __pWebViewer->SearchTextAllAsync(L"",false);
4457 __pFindWordControl->SetShowState(false);
4458 __pFindWordEditField->HideKeypad();
4462 if (__pWebViewer != null && __pFooterPanel != null)
4464 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4465 if(__pAddressbar != null)
4467 __pAddressbar->SetShowState(false);
4469 if(__pFindWordControl != null)
4471 __pFindWordControl->SetShowState(false);
4473 __pFooterPanel->SetShowState(false);
4474 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4476 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4478 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4479 // AppLog("omgomgomg");
4485 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4487 AppLog("xyz::MainForm::OnWebKeypadClosed");
4488 AppLog("akjshdasd 4");
4489 __pFooterPanel->SetShowState(true);
4490 // OnAddressBarKeypadClosed(*__pAddressbar);
4491 RelayoutControls(false);
4492 __isKeypadOpened = false;
4496 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4498 // RelativeLayout(false);
4499 if(__pWebViewer != null)
4501 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4506 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4508 Control* temp = const_cast< Control* >(&source);
4509 Header* pHeader = dynamic_cast< Header* >(temp);
4510 if (pHeader != null)
4512 //Header double - clicked
4513 AppLog("Header double clicked");
4515 if(__pFindWordControl)
4517 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4518 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4522 AppLog("MainScene::OnTouchDoublePressed");
4526 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4528 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4529 if(TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1)
4531 AppLog("Returning because of more than one touch point.");
4534 __longPressPoint = currentPosition;
4536 if (__pHitElementResult != null)
4538 delete __pHitElementResult;
4539 __pHitElementResult = null;
4542 if (__pWebViewer != null)
4544 AppLog("MainForm::OnTouchLongPressed web not null");
4545 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4548 if (__pHitElementResult == null)
4553 if (__pHitElementResult->HasImage() == true)
4555 if(__pWebViewer != null)
4556 InitImageContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4557 __pImageMenu->SetShowState(true);
4558 __pImageMenu->Show();
4559 __pImageMenu->Invalidate(true);
4561 else if(__pHitElementResult->HasUrl() == true)
4563 String tempURl = __pHitElementResult->GetUrl();
4564 AppLog("tempURl is %ls", tempURl.GetPointer());
4565 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4566 if (pBitmap != null)
4574 InitImageLinkContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4575 __pImageMenu->SetShowState(true);
4576 __pImageMenu->Show();
4577 __pImageMenu->Invalidate(true);
4581 String tagName = __pHitElementResult->GetTagName();
4582 String type = __pHitElementResult->GetAttributeValue("type");
4583 String value = __pHitElementResult->GetAttributeValue(L"value");
4584 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4586 __currentSelectedStr.Clear();
4587 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4589 AppLog("tag name is %ls", tagName.GetPointer());
4590 AppLog("type is %ls", type.GetPointer());
4594 __isLongPressedDone = true;
4595 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4596 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && innerHtml.GetLength() == 0 && type.CompareTo(L"submit") !=0/*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.CompareTo(L"") == 0 && r == E_INVALID_ARG)
4598 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4600 InitSelectTextContextMenu(Point(currentPosition.x , currentPosition.y + __pWebViewer->GetY()),true, true);
4603 __pImageMenu->SetShowState(true);
4604 __pImageMenu->Show();
4605 __pImageMenu->Invalidate(true);
4608 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4611 // __inputEventToBeSupressed = true;
4615 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4617 AppLog("xyz:: MainForm::OnTouchReleased called");
4619 if (__pAddressbar && __pAddressbar->GetShowState() == true)
4621 __pAddressbar->SetShowState(false);
4623 if(__pFooterPanel && __isKeypadOpened == false)
4625 __pFooterPanel->SetShowState(true);
4629 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4630 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4632 __pWebViewer->ConsumeInputEvent();
4634 if(pHitElement != null)
4638 __inputEventToBeSupressed = false;*/
4642 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4649 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4651 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4653 __currentSearchStr = L"";
4654 __currentWordIndex = 0;
4655 __maxOccurrances = 0;
4657 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4659 __pFindWordEditField->SetText(L"");
4660 __pFindWordEditField->HideKeypad();
4661 __pFindWordControl->SetShowState(false);
4662 __pFindWordCountLabel->SetText(L"0/0");
4664 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4666 __pFindWordEditFieldRightToLeft->SetText(L"");
4667 __pFindWordEditFieldRightToLeft->HideKeypad();
4668 __pFindWordControl->SetShowState(false);
4669 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4672 __pFindWordNext->SetEnabled(false);
4673 __pFindWordPrev->SetEnabled(false);
4675 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
4676 __pFindWordControl->SetShowState(false);
4678 AppLog("__pAddressbar->GetShowState() %d",__pAddressbar->GetShowState());
4679 if(__pAddressbar->GetShowState() == false)
4681 __pAddressbar->SetAddressbarURLFocus();
4682 __pFooterPanel->SetShowState(false);
4689 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4695 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4701 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4707 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4713 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4719 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4721 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4722 int widthContextItem = 0;
4723 if(__pFindWordCountLabel)
4724 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4725 // As per the platform engineer comment removed this line
4726 /*if(__pWebViewer != null)
4728 // 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
4729 __pWebViewer->ReleaseBlock();
4732 // if(__pFindWordControl != null)
4733 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4735 if(__pOptionMenu && __pOptionMenu->GetShowState() == true)
4737 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
4739 AppLog(" Orientation landscape");
4740 __pOptionMenu->SetMaxVisibleItemsCount(5);
4744 AppLog(" Orientation potrait");
4745 __pOptionMenu->SetMaxVisibleItemsCount(6);
4748 if(__pNotification && __pNotification->GetShowState() == true)
4750 __pNotification->SetShowState(false);
4751 __pNotification->Invalidate(false);
4753 if ( __pFooterLabel != null)
4755 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4758 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4764 if (__pFindWordBgLabel != null)
4766 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4767 if (pBitmap != null)
4769 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4774 if (__pFindWordBgLabelRightToLeft != null)
4776 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4777 if (pBitmap != null)
4779 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4785 // if(__pOptionMenu != null)
4786 // __pOptionMenu->SetShowState(false);
4788 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4790 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4794 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4799 AppLog("__pFooterPanel->GetShowState() is true");
4801 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4802 __pFooterPanel->Invalidate(true);
4806 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4807 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4809 InitMostVisitedSitesView(orientationStatus);
4812 RelayoutControls(false);
4813 if (__pArticleReaderPanel != null)
4815 if (__pArticleReaderPanel->GetShowState() == true)
4817 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4819 if (__pBlankPanel != null)
4820 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4822 if (__pWebReader != null)
4824 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4826 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4827 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4829 if ( pBitmap != null && pSrcBitmap != null)
4831 AppLog("CreateReaderPanel ninepatchbitmap found");
4832 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4835 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4836 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4837 if (pBitmap != null)
4842 if (pSrcBitmap != null)
4851 if (__pAddressbar != null)
4853 int width = GetClientAreaBounds().width;
4854 __pAddressbar->OrientationChanged(width);
4859 MainForm::OnSettingsChange(int settingvalue)
4861 AppLogDebug("MainForm::OnSettingsChange entered");
4863 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4865 __pAddressbar->ResetGuideText();
4867 if (__pWebViewer == null)
4869 AppLogDebug("Webviewer is not initialized yet.");
4873 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4875 WebSetting settings = __pWebViewer->GetSetting();
4876 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4878 settings.SetAutoFittingEnabled(true);
4880 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
4882 settings.SetAutoFittingEnabled(false);
4884 __pWebViewer->SetSetting(settings);
4886 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4888 WebSetting settings = __pWebViewer->GetSetting();
4889 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4890 __pWebViewer->SetSetting(settings);
4892 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4894 WebSetting settings = __pWebViewer->GetSetting();
4895 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4896 __pWebViewer->SetSetting(settings);
4897 __pWebViewer->Reload();
4899 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4901 WebSetting settings = __pWebViewer->GetSetting();
4902 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4903 __pWebViewer->SetSetting(settings);
4905 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4909 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4912 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
4916 WebSetting settings = __pWebViewer->GetSetting();
4917 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
4918 __pWebViewer->SetSetting(settings);
4921 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
4925 WebSetting settings = __pWebViewer->GetSetting();
4926 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
4927 __pWebViewer->SetSetting(settings);
4930 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4932 WebSetting settings = __pWebViewer->GetSetting();
4933 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4935 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4939 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4941 __pWebViewer->SetSetting(settings);
4943 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4947 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4948 WebSetting settings = __pWebReader->GetSetting();
4949 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4950 __pWebReader->SetSetting(settings);
4956 MainForm::OnSettingsReset()
4960 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4961 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4966 MainForm::OnClearCache()
4968 result r = E_SUCCESS;
4970 if (__pWebViewer != NULL)
4972 r = __pWebViewer->ClearCache();
4975 AppLogDebug("Cache cleared success");
4979 AppLogDebug("Cache cleared fail");
4985 MainForm::OnClearCookie()
4987 result r = E_SUCCESS;
4989 if (__pWebViewer != NULL)
4991 __pWebViewer->ClearCookie();
4995 AppLogDebug("Cookie cleared success");
4999 AppLogDebug("Cache cleared fail");
5004 MainForm::OnClearFormData()
5006 result r = E_SUCCESS;
5008 if (__pWebViewer != NULL)
5010 __pWebViewer->ClearFormData();
5014 AppLogDebug("Cookie cleared success");
5018 AppLogDebug("Cache cleared fail");
5023 MainForm::OnClearPasswords()
5025 result r = E_SUCCESS;
5027 if (__pWebViewer != NULL)
5029 __pWebViewer->ClearLoginFormData();
5033 AppLogDebug("Cookie cleared success");
5037 AppLogDebug("Cache cleared fail");
5043 MainForm::findDistance(int x1,int y1,int x2, int y2)
5045 int deltaX = Math::Abs(x2 - x1);
5046 int deltaY = Math::Abs(y2 - y1);
5047 double num = deltaX*deltaX + deltaY*deltaY;
5053 for (i = 0; i < 20; i++)
5055 x = (((x*x)+ num)/(2*x));
5066 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5068 AppLog("xyz:: MainForm::OnTouchPressed called");
5069 if(__pFindWordControl)
5071 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
5072 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
5074 __isLongPressedDone = false;
5079 IList* pList = null;
5080 pList = touch.GetTouchInfoListN(source);
5084 int count = pList->GetCount();
5087 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5088 __touchPoint1 = pTouchInfo->position;
5090 /*if (__pAddressbar != null)
5092 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5094 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5096 __pAddressbar->SaveAddressbarEditText();
5098 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5101 __pAddressbar->Invalidate(true);
5103 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5105 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5107 //__pAddressbar->SaveAddressbarEditText();
5109 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5112 else if (count == 2)
5114 AppLogDebug("MainForm::OnTouchPressed count is two");
5115 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5116 __touchPoint1 = pTouchInfo->position;
5118 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
5119 __touchPoint2 = pTouchInfo->position;
5124 pList->RemoveAll(true);
5129 __pAddressbar->SetShowState(false);
5131 if(__pFooterPanel && __isKeypadOpened == false)
5133 __pFooterPanel->SetShowState(true);
5135 RelayoutControls(false);
5140 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5142 // __currentWordIndex = 0;
5143 __isLongPressedDone = false;
5148 MainForm::MoveUiControls()
5153 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
5155 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
5157 if(__pFooterUrlField->GetTextLength() == 0)
5159 __pFooterUrlField->SetKeypadActionEnabled(false);
5163 __pFooterUrlField->SetKeypadActionEnabled(true);
5166 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
5168 __currentSearchStr = __pFindWordEditField->GetText();
5169 if (__currentSearchStr.GetLength() > 0)
5171 __pFindWordCountLabel->SetShowState(true);
5175 __pFindWordCountLabel->SetShowState(false);
5176 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
5177 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
5180 __pFindWordNext->SetEnabled(false);
5181 __pFindWordPrev->SetEnabled(false);
5182 __pFindWordNext->Invalidate(true);
5183 __pFindWordPrev->Invalidate(true);
5184 __pFindWordCountLabel->SetText(L"0/0");
5185 __pFindWordCountLabel->Invalidate(true);
5187 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
5189 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
5190 if (__currentSearchStr.GetLength() > 0)
5192 __pFindWordCountLabelRightToLeft->SetShowState(true);
5196 __pFindWordCountLabelRightToLeft->SetShowState(false);
5199 __pFindWordNext->SetEnabled(false);
5200 __pFindWordPrev->SetEnabled(false);
5201 __pFindWordNext->Invalidate(true);
5202 __pFindWordPrev->Invalidate(true);
5203 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
5204 __pFindWordCountLabelRightToLeft->Invalidate(true);
5206 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
5207 if (__currentSearchStr.GetLength() > 0)
5213 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
5215 __currentSearchStr = L"";
5216 AppLogDebug("Enter something");
5221 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
5228 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
5230 if(__pWebViewer != null)
5233 AppLog("MainForm::InitMostVisitedSitesView");
5234 result r = E_SUCCESS;
5237 if (__pWebViewer != null && __pMostVisitedListView != null)
5242 if (__pMostVisitedListView != null)
5244 RemoveControl(__pMostVisitedListView);
5246 if(__pMostVisitedSites != null)
5248 __pMostVisitedSites->RemoveAll(true);
5251 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
5253 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
5254 __pMostVisitedListView = new(std::nothrow) ListView();
5256 int height = GetClientAreaBounds().height;
5258 if(__pFooterPanel->GetShowState() == true)
5260 height = height - __pFooterPanel->GetHeight();
5262 if(__pAddressbar->GetShowState() == true)
5264 height -= __pAddressbar->GetHeight();
5267 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
5271 delete __pMostVisitedListView;
5272 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
5275 __pMostVisitedListView->SetItemProvider(*this);
5276 __pMostVisitedListView->AddListViewItemEventListener(*this);
5277 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_VISITED_SITES"));
5278 AddControl(__pMostVisitedListView);
5279 __pMostVisitedListView->UpdateList();
5286 MainForm::GetImagePath(void)
5290 String formattedTime;
5291 DateTime currentTime;
5292 LocaleManager localManager;
5293 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
5295 localManager.Construct();
5296 Locale locale = localManager.GetSystemLocale();
5297 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
5299 // Get date formatter
5300 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
5304 pTimeFormatter->Format(currentTime, formattedTime);
5307 AppLog("current time stamp is %ls", formattedTime.GetPointer());
5308 String delim(L" :");
5309 StringTokenizer strTok(formattedTime, delim);
5312 String str1("GMT+00");
5313 while (strTok.HasMoreTokens())
5315 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
5316 if(token.Equals(str1))
5318 AppLog("token is %ls", token.GetPointer());
5319 imageName.Append(token);
5325 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
5327 result r = E_FAILURE;
5328 AppLog("Content manager 1");
5329 ContentId contentId;
5330 ContentManager contentManager;
5331 r = contentManager.Construct();
5334 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
5337 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
5338 Tizen::Io::Directory::Create(contentPath,true);
5339 if(GetLastResult() == E_FILE_ALREADY_EXIST)
5341 AppLog("Already exists");
5343 else if(GetLastResult() == E_SUCCESS)
5345 AppLog("created success");
5347 contentPath.Append(imageName);
5348 contentPath.Append(".jpg");
5349 contentId = contentManager.CreateContent(*aBuffer, contentPath);
5350 ShowIndicatorNotification(L"Download Complete",contentPath);
5351 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5355 MainForm::ShowIndicatorNotification(const String& messageText, const String& contentPath)
5357 AppLogDebug("ENTER");
5359 NotificationRequest request;
5360 request.SetAlertText(messageText);
5361 request.SetTitleText(L"");
5362 request.SetAppMessage(contentPath);
5363 request.SetOngoingActivityType(ONGOING_ACTIVITY_TYPE_TEXT);
5364 request.SetNotificationStyle(NOTIFICATION_STYLE_THUMBNAIL);
5365 Tizen::App::App* pApp = Tizen::App::App::GetInstance();
5366 String homePath = pApp->GetAppRootPath();
5367 String iconPath = homePath + L"res/screen-density-xhigh/Notification_download_complete.png";
5368 AppLog("The iconPath is : %ls", homePath.GetPointer());
5369 request.SetIconFilePath(iconPath);
5371 Tizen::Shell::NotificationManager notiMgr;
5372 notiMgr.Construct();
5373 notiMgr.NotifyOngoingActivity(request);
5375 AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));
5380 MainForm::SetForwardButtonEnabled(bool isEnabled)
5382 __pGoForwardBtn->SetEnabled(isEnabled);
5383 __pGoForwardBtn->Invalidate(true);
5387 MainForm::SetBackButtonEnabled(bool isEnabled)
5389 __pGoBackBtn->SetEnabled(isEnabled);
5390 __pGoBackBtn->Invalidate(true);
5394 MainForm::UpdateProgress(int percentage)
5396 __progressPercentage = percentage;
5397 if (percentage == 0 || percentage == 100)
5399 __isLoadingData = false;
5400 if (percentage == 100)
5402 __isLoadingCompleted = true;
5403 __progressPercentage = 0;
5407 __isLoadingCompleted = false;
5412 __isLoadingData = true;
5414 UpdateProgressBitmap();
5418 MainForm::GetProgress(void)
5420 return __progressPercentage;
5424 MainForm::UpdateProgressBitmap(void)
5426 result r = E_SUCCESS;
5427 if (__pProgressbarLabel == null)
5429 int w = __pProgressbarLabel->GetWidth();
5430 int h = __pProgressbarLabel->GetHeight();
5432 int progressWidth = 0;
5433 Bitmap* pRetBitmap = null;
5435 if (__progressPercentage == 0 || __progressPercentage == 100)
5437 __pProgressbarLabel->SetShowState(false);
5438 __pProgressbarLabel->Invalidate(false);
5443 __pProgressbarLabel->SetShowState(true);
5444 __pProgressbarLabel->Invalidate(false);
5447 r = canvas.Construct(Rectangle(0, 0, w, h));
5451 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5456 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5460 pBgBmp->Scale(Dimension(w, h));
5461 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5465 progressWidth = (double) (w) * __progressPercentage / 100;
5466 AppLogDebug("progressWidth: %d", progressWidth);
5467 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5469 if (pProgressBmp != null)
5471 pProgressBmp->Scale(Dimension(progressWidth, h));
5472 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5473 delete pProgressBmp;
5476 pRetBitmap = new (std::nothrow) Bitmap();
5478 if (pRetBitmap == null)
5480 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5484 pRetBitmap->Construct(canvas, canvas.GetBounds());
5486 if (__pProgressbarLabel != null && pRetBitmap != null)
5488 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5489 __pProgressbarLabel->Invalidate(false);
5492 if (pRetBitmap != null)
5501 MainForm::ReaderClicked()
5503 result r = E_SUCCESS;
5504 ArrayList* pArgList = new(std::nothrow) ArrayList();
5505 if (pArgList != null)
5507 r = pArgList->Construct();
5514 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5521 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5528 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5536 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5542 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5544 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5546 __currentAddMode = addMode;
5550 case ADDRESSBAR_MODE_INVALID:
5555 case ADDRESSBAR_MODE_READER:
5557 __pStopBtn->SetShowState(false);
5558 __pRefreshBtn->SetShowState(false);
5559 __pClearBtn->SetShowState(false);
5560 __pReaderBtn->SetShowState(false);
5563 case ADDRESSBAR_MODE_LOADING:
5565 __pRefreshBtn->SetShowState(false);
5566 __pStopBtn->SetShowState(true);
5567 __pClearBtn->SetShowState(false);
5568 __pReaderBtn->SetShowState(false);
5571 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5573 // SetUrl(__pAddressbar->GetUrl());
5575 __pRefreshBtn->SetShowState(true);
5576 __pStopBtn->SetShowState(false);
5577 __pClearBtn->SetShowState(false);
5578 __pReaderBtn->SetShowState(false);
5581 case ADDRESSBAR_MODE_EDIT:
5583 __pRefreshBtn->SetShowState(false);
5584 __pStopBtn->SetShowState(false);
5585 __pReaderBtn->SetShowState(false);
5586 __pClearBtn->SetShowState(true);
5593 OnAddressBarModeChanged();
5596 AddressBarMode MainForm::GetAddressbarMode(void)
5598 return __currentAddMode;
5601 void MainForm::SetUrl(const String& url)
5604 if(__displayUrl.GetLength() > 2048)
5605 __displayUrl.SubString(0,2048,__displayUrl);
5607 if (__pFooterUrlField != NULL)
5609 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5610 if (removedHttpUrl.IsEmpty() == false)
5612 __pFooterUrlField->SetText(removedHttpUrl);
5613 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5614 __pAddressbar->SetUrl(__displayUrl);
5618 __pFooterUrlField->SetText(__displayUrl);
5619 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5620 __pAddressbar->SetUrl(__displayUrl);
5622 if(__pFooterUrlField)
5623 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5624 __pFooterUrlField->Invalidate(false);
5625 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5626 __pAddressbar->Invalidate(true);
5627 // __pFooterUrlField->SetCursorPosition(0);
5632 MainForm::RemoveHttpTextFromDisplayURL(void)
5634 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5636 // bool isHttpText = __displayUrl.Contains(L"http://");
5637 String updatedDisplayUrl;
5638 updatedDisplayUrl.Clear();
5639 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5641 __displayUrl.SubString(7,updatedDisplayUrl);
5643 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5645 __displayUrl.SubString(8,updatedDisplayUrl);
5647 return updatedDisplayUrl;
5650 void MainForm::OnSharePopupControlStarted(void)
5652 __pWebViewer->AddTouchEventListener(*this);
5656 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5658 if (requestId == BACK_GROUND_APP_EVENT)
5660 if(__pWebViewer != null)
5662 __pWebViewer->Pause();
5666 __pImageMenu->SetShowState(false);
5668 if(__pAddressbar != null)
5670 __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5673 else if(requestId == FORE_GROUND_APP_EVENT)
5675 if(__pWebViewer != null)
5677 __pWebViewer->Resume();
5679 if(__pAddressbar != null)
5681 __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5687 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5689 AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5690 result r = E_SUCCESS;
5693 __pAddressbar->SetShowState(false);
5695 AppLog("akjshdasd 5");
5696 __pFooterPanel->SetShowState(true);
5699 __pWebViewer->SetFocus();
5700 else if(__pMostVisitedListView)
5701 __pMostVisitedListView->SetFocus();
5702 else if(__pMultiWindowButton)
5703 __pMultiWindowButton->SetFocus();
5704 else if(__pMoreButton)
5705 __pMoreButton->SetFocus();
5707 __pAddressbar->SetShowState(false);
5709 RelayoutControls(false);
5713 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5715 AppLog("MainForm::OnFormMenuRequested called");
5717 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer && __pWebViewer->GetShowState() == true)
5719 int bookmarkCount=0;
5722 url=__pWindowInfo->pageUrl;
5723 AppLog("MainForm::OnFormMenuRequested url %ls",url.GetPointer());
5724 result r = E_SUCCESS;
5725 Bitmap* pBitmap = null;
5726 String lastChar = L"";
5727 // if(url.SubString(url.GetLength()-1,lastChar));
5728 // if(lastChar == L"/")
5730 // bool exist1 = false;
5731 // bool exist2 = false;
5732 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist1);
5733 // url.SubString(0,url.GetLength() - 1,url);
5734 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist2);
5735 // exist = exist1 | exist2;
5739 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5742 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5748 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5752 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5754 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5756 if (__pOptionMenu->GetItemCount() == 9)
5758 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5762 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5767 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
5771 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
5772 if (__pOptionMenu->GetItemCount() != 9)
5774 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
5775 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
5776 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
5777 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
5778 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
5779 __pOptionMenu->SetMaxVisibleItemsCount(6);
5781 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
5783 AppLog(" Orientation landscape");
5784 __pOptionMenu->SetMaxVisibleItemsCount(5);
5788 AppLog(" Orientation potrait");
5789 __pOptionMenu->SetMaxVisibleItemsCount(6);
5792 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
5795 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
5796 result r = __pOptionMenu->SetShowState(true);
5797 AppLog("ajsghd %s",GetErrorMessage(r));
5798 __pOptionMenu->Invalidate(true);
5799 __pOptionMenu->Show();