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.#.png";
59 static const wchar_t* IDB_FINDWORD_INPUT_FIELD_BG = L"I01_toolbar_input_field_findword.#.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"00_icon_favorite_off_74x74.png";
72 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"00_icon_favorite_on_74x74.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 static const wchar_t* APPCONTROL_OPERATION_ID_IMAGE_VIEWER = L"http://tizen.org/appcontrol/operation/view";
148 MainForm::MainForm(void)
150 __isLongPressedDone = false;
152 __pAddressbar = null;
153 // __pMostVisitedSitesPanel = null;
154 __pMostVisitedListView = null;
155 __pFooterPanel = null;
156 __pHitElementResult = null;
157 __pWindowInfo = null;
160 __pOptionMenu = null;
161 __pFindWordControl = null;
162 __pFindWordPanelLeftToRight = null;
163 __pFindWordPanelRightToLeft = null;
164 __pFindWordBgLabel = null;
165 __pFindWordBgLabelRightToLeft = null;
166 __pFindWordEditField = null;
167 __pFindWordEditFieldRightToLeft = null;
168 __pFindWordClear = null;
169 __pFindWordClearRightToLeft = null;
170 __pFindWordCountLabel = null;
171 __pFindWordClearRightToLeft = null;
172 __pFindWordNext = null;
173 __pFindWordPrev = null;
174 __previousZoomLevel = 1.0;
176 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
179 __currentSearchStr = L"";
180 __currentSelectedStr = L"";
181 __maxOccurrances = 0;
182 __currentWordIndex = 0;
185 //__inputEventToBeSupressed = false;
186 __isLoadingData = false;
187 __isLoadingCompleted = false;
188 __progressPercentage = 0;
189 __touchPoint1 = Point(-1,-1);
190 __touchPoint2 = Point(-1,-1);
191 __longPressPoint = Point(-1,-1);
193 // __pReaderPopup = null;
194 __pReaderData = null;
196 __pReaderCloseBtn = null;
197 //__pNewWindowButton = null;
198 __pMoreButton = null;
199 __pMultiWindowButton = null;
200 __pArticleReaderPanel = null;
201 __pBlankPanel = null;
202 __pArticleReaderLabel = null;
203 __webControlHeight = 0;
204 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
205 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
206 __pMostVisitedSites = null;
207 __pFooterUrlField = null;
209 __pGoForwardBtn = null;
210 __pRefreshBtn = null;
211 __pProgressbarLabel = null;
212 __pFooterLabel = null;
216 __isKeypadOpened = false;
218 __pNotification = null;
221 MainForm::~MainForm(void)
223 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
227 __pAddressbar->SetAddressbarEventListener(null);
230 if(__pHistory != null)
236 if (__pReaderData != null)
238 delete __pReaderData;
239 __pReaderData = null;
242 if (__pPopUp != null)
248 if (__pHitElementResult != null)
250 delete __pHitElementResult;
251 __pHitElementResult = null;
255 delete __pOptionMenu;
256 __pOptionMenu = null;
259 String* pSelectedScene = NULL;
260 Object* pValue = NULL;
261 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
262 pSelectedScene = (String*) pValue;
264 /*if (pSelectedScene != null)
266 delete pSelectedScene;
268 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
272 MainForm::Initialize(void)
274 Construct(L"IDL_FORM");
276 // SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_FOOTER);
281 MainForm::OnInitializing(void)
283 AppLog("get client area width = %d",GetClientAreaBounds().width);
284 AppLog("get client area height = %d",GetClientAreaBounds().height);
285 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
286 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
288 __fontSize = CommonUtil::GetFontSize();
289 Panel* pFooterPanel = null;
291 __pSaveImage = new Image();
292 __pSaveImage->Construct();
294 // Setup back event listener
295 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
296 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
297 AddOrientationEventListener(*this);
299 AppLogDebug(" MainForm::OnInitializing ended");
300 if (__pMostVisitedSites == null)
302 __pMostVisitedSites = new(std::nothrow) ArrayList();
303 __pMostVisitedSites->Construct();
305 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
307 __pItemContext= new(std::nothrow) ListContextItem();
308 __pItemContext->Construct();
310 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"),true);
313 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
314 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
315 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
317 __pItemContextLandscape= new(std::nothrow) ListContextItem();
318 __pItemContextLandscape->Construct();
320 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), true);
321 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
322 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
323 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
324 SetFormMenuEventListener(this);
325 AppLog("SetFormMenuEventListener result %s",GetErrorMessage(GetLastResult()));
330 MainForm::InitAddressbar(void)
332 AppLogDebug("MainForm::InitAddressbar entered");
334 result r = E_SUCCESS;
336 if (__pAddressbar != null)
340 __pAddressbar = new(std::nothrow) Addressbar();
341 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
342 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
345 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
348 __pAddressbar->SetAddressbarEventListener(this);
349 AddControl(__pAddressbar);
350 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
351 SetControlAlwaysOnTop(*__pAddressbar, true);
352 __adressPanelPosition = __pAddressbar->GetPosition();
354 AppLogDebug("MainForm::InitAddressbar exit");
360 MainForm::CreateReaderPanel(void)
362 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
363 result r = E_FAILURE;
365 Button *pSmallFontBtn = null;
366 Button *pLargeFontBtn = null;
368 __pBlankPanel = new (std::nothrow) Panel();
369 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
371 __pArticleReaderPanel = new (std::nothrow) Panel();
372 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
374 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
375 if (__pReaderCloseBtn)
377 AppLogDebug("CreateReaderPanel() 6");
378 __pReaderCloseBtn->AddActionEventListener(*this);
379 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
382 __pWebReader = new (std::nothrow) Web();
383 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
385 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
386 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
388 r = __pWebReader->SetSetting(settings);
390 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
393 __pArticleReaderLabel = new Label();
394 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
396 __pBlankPanel->AddControl(__pArticleReaderLabel);
397 __pBlankPanel->AddControl(__pArticleReaderPanel);
398 AddControl(__pBlankPanel);
400 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
401 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
402 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
404 __pArticleReaderPanel->AddControl(__pWebReader);
405 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
406 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
407 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
409 if (pBitmap != null && pSrcBitmap != null)
411 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
413 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
415 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
418 pSmallFontBtn->AddActionEventListener(*this);
419 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
422 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
425 pLargeFontBtn->AddActionEventListener(*this);
426 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
435 if (pSrcBitmap != null)
441 SetControlAlwaysOnTop(*__pBlankPanel, true);
442 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
449 MainForm::InitWebControl()
451 AppLogDebug("MainForm::InitWebControl enter");
452 result r = E_SUCCESS;
453 AppLogDebug("InitWebControl");
455 if (__pAddressbar == null || __pFooterPanel == null)
458 const int Y_WEBCONTROL_POSITION = 0;
460 __webControlHeight = GetHeight() - __pFooterPanel->GetHeight();
462 if (__pMostVisitedListView)
464 __pMostVisitedListView->SetShowState(false);
466 if (__pWebViewer != null)
468 AppLogDebug("Already initialized");
471 __pWebViewer = new(std::nothrow) Web();
472 if(__pWebViewer == NULL)
474 AppLogDebug("Initialization failed");
477 AppLog("GetClientAreaBounds().width %d",GetClientAreaBounds().width);
478 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
482 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
489 r = AddControl(__pWebViewer);
492 __pWebViewer->Destroy();
494 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
497 __webControlPosition = __pWebViewer->GetPosition();
498 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
501 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
505 __pWebViewer->SetLoadingListener(this);
506 __pWebViewer->SetWebUiEventListenerF(this);
507 __pWebViewer->SetWebKeypadEventListener(this);
508 __pWebViewer->SetFocus();
509 __pWebViewer->AddTouchEventListener(*this);
511 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
512 __pWebViewer->SetTextSearchListener(this);
515 AppLogDebug("MainForm :before return");
517 AppLogDebug("MainForm::InitWebControl Exit");
523 MainForm::SetJavascriptEnabled()
525 WebSetting settings = __pWebViewer->GetSetting();
526 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
527 __pWebViewer->SetSetting(settings);
531 MainForm::SetImageLoadEnabled()
533 WebSetting settings = __pWebViewer->GetSetting();
534 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
535 __pWebViewer->SetSetting(settings);
539 MainForm::InitFooter(void)
541 AppLogDebug("MainForm::InitFooter entered");
542 Button* pBackButton = null;
543 Button* pBookmarkButton = null;
544 Button* pMultiWindowButton = null;
545 Bitmap *pIconBitmap = null;
546 Bitmap *pBGBitmap = null;
547 Label *pBGLabel = null;
549 if (__pFooterPanel == null)
551 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
554 if (__pFooterPanel == null)
559 SetControlAlwaysOnTop(*__pFooterPanel, true);
561 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
562 if ( __pFooterLabel == NULL )
566 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
567 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
570 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
574 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
576 if ( __pMultiWindowButton == NULL )
582 SetFormBackEventListener(this);
583 AppLog("SetFormBackEventListener result %s",GetErrorMessage(GetLastResult()));
584 if (__pMultiWindowButton != null)
586 Bitmap* pBitmap = null;
587 Bitmap* pPressedBitmap = null;
588 String imagePath = "I01_toolbar_icon_windows_manager_0";
589 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
590 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
591 imagePath.Append(totalCount);
592 imagePath.Append(".png");
594 pressedImagePath.Append(totalCount);
595 pressedImagePath.Append("_press.png");
597 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
598 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
599 if ( pBitmap == null )
604 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
607 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
608 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
613 __pMultiWindowButton->AddActionEventListener(*this);
614 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
617 delete pPressedBitmap;
618 pPressedBitmap = null;
624 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
625 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
628 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
629 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
630 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
634 __pMoreButton->AddActionEventListener(*this);
635 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
638 //Add the editfield for url
639 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
640 if (__pFooterUrlField == NULL)
642 return E_INVALID_KEY;
645 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
646 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
647 __pFooterUrlField->AddKeypadEventListener(*this);
648 __pFooterUrlField->SetPropagatedTouchEventListener(this);
649 __pFooterUrlField->AddFocusEventListener(*this);
651 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
653 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
655 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
657 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_BLANK_PAGE"));
661 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
662 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
666 //Add the go Back Button
667 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
668 if (__pGoBackBtn == NULL)
670 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
671 return E_INVALID_KEY;
673 __pGoBackBtn->SetActionId(IDA_GO_BACK);
674 __pGoBackBtn->AddActionEventListener(*this);
676 //Add the go forward Button
677 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
678 if (__pGoForwardBtn == NULL)
680 AppLogDebug("Control not found returning E_INVALID_KEY");
681 return E_INVALID_KEY;
683 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
684 __pGoForwardBtn->AddActionEventListener(*this);
685 if (__pWebViewer && __pWebViewer->CanGoForward())
687 SetForwardButtonEnabled(true);
691 SetForwardButtonEnabled(false);
694 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
695 if (__pRefreshBtn == NULL)
697 AppLogDebug("Control not found returning E_INVALID_KEY");
698 return E_INVALID_KEY;
701 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
702 __pRefreshBtn->AddActionEventListener(*this);
703 __pRefreshBtn->SetShowState(true);
705 //Add the backround label for displaying progressbar
706 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
707 if (__pProgressbarLabel == NULL)
709 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
710 return E_INVALID_KEY;
712 __pProgressbarLabel->SetShowState(false);
714 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
715 if (__pStopBtn == NULL)
717 AppLogDebug("Control not found returning E_INVALID_KEY");
718 return E_INVALID_KEY;
720 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
721 __pStopBtn->AddActionEventListener(*this);
722 __pStopBtn->SetShowState(false);
724 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
725 if (__pClearBtn == NULL)
727 AppLogDebug("Control not found returning E_INVALID_KEY");
728 return E_INVALID_KEY;
730 __pClearBtn->SetActionId(IDA_CLEAR_URL);
731 __pClearBtn->AddActionEventListener(*this);
732 __pClearBtn->SetShowState(false);
734 __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
735 if (__pReaderBtn == NULL)
737 AppLogDebug("Control not found returning E_INVALID_KEY");
738 return E_INVALID_KEY;
740 __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
741 __pReaderBtn->AddActionEventListener(*this);
742 __pReaderBtn->SetShowState(false);
744 // __pFooterPanel->Invalidate(true);
745 if(__isKeypadOpened == false && __pAddressbar && __pAddressbar->GetShowState() == false)
747 // AppLog("asdasdasdasda");
748 __pFooterPanel->SetShowState(true);
750 else if(__pAddressbar == null)
752 __pFooterPanel->SetShowState(true);
755 __pFooterPanel->SetShowState(false);
757 SetAddressbarMode(GetAddressbarMode());
758 AppLogDebug("MainForm::InitFooter exit");
763 MainForm::InitOptionMenu()
765 result r = E_SUCCESS;
766 bool isPrivateBrowsing = false;
767 Bitmap* pBitmap = null;
769 if (__pOptionMenu != null)
771 __pOptionMenu->SetFocusable(true);
772 __pOptionMenu->Invalidate(true);
776 __pOptionMenu = new(std::nothrow) OptionMenu();
777 r = __pOptionMenu->Construct();
778 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
780 __pOptionMenu->SetFocusable(true);
781 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
784 if (isPrivateBrowsing == true)
786 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
790 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
793 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
795 if ( pBitmap != NULL)
797 __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
800 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
801 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
802 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
805 __pOptionMenu->SetMaxVisibleItemsCount(6);
806 __pOptionMenu->SetShowState(false);
807 __pOptionMenu->AddActionEventListener(*this);
808 SetControlAlwaysOnTop(*__pOptionMenu, true);
814 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
816 result r = E_SUCCESS;
817 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
819 AppLog("MainForm::InitImageContextMenu clicked on image");
820 if (__pImageMenu != null)
825 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
830 __pImageMenu = new (std::nothrow) ContextMenu();
831 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
832 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
834 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
835 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
836 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
837 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
838 __pImageMenu->SetMaxVisibleItemsCount(4);
839 __pImageMenu->AddActionEventListener(*this);
840 SetControlAlwaysOnTop(*__pImageMenu, true);
841 __pImageMenu->SetFocusable(true);
847 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
849 result r = E_SUCCESS;
850 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
852 AppLog("MainForm::InitImageContextMenu clicked on image");
853 if (__pImageMenu != null)
859 // if(__pAddressbar->GetShowState() == true)
860 // p.y = p.y + __pAddressbar->GetHeight();
861 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
866 __pImageMenu = new (std::nothrow) ContextMenu();
867 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
868 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
870 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_OPEN_IN_NEW_WINDOW"),IDA_HYPERLINK_OPEN_CLICKED);
871 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_LINK_URL"),IDA_HYPERLINK_COPY_LINK_CLICKED);
872 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
873 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
875 __pImageMenu->SetMaxVisibleItemsCount(3);
876 __pImageMenu->AddActionEventListener(*this);
877 SetControlAlwaysOnTop(*__pImageMenu, true);
878 __pImageMenu->SetFocusable(true);
885 MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOption = false)
887 result r = E_SUCCESS;
888 bool clipboardAvailable = true;
889 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
891 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
892 if (__pImageMenu != null)
898 // __pWebViewer->GetBlockRange(p,q);
903 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
907 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
911 Clipboard* pClipboard = Clipboard::GetInstance();
913 if(pClipboard == null)
915 clipboardAvailable = false;
919 // Retrieves a latest item
920 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
924 clipboardAvailable = false;
928 //Gets data from the clipboard item
929 String* pString = dynamic_cast<String*>(pItem->GetData());
933 clipboardAvailable = false;
937 if(clipboardAvailable == false && onlyPasteOption == true)
942 __pImageMenu = new (std::nothrow) ContextMenu();
943 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
944 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
946 if(onlyPasteOption == false)
948 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
950 if ((pasteOption || onlyPasteOption) && clipboardAvailable == true)
952 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
954 if(onlyPasteOption == false)
956 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
957 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
960 __pImageMenu->SetMaxVisibleItemsCount(3);
961 __pImageMenu->AddActionEventListener(*this);
962 SetControlAlwaysOnTop(*__pImageMenu, true);
963 __pImageMenu->SetFocusable(true);
970 MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPasteOption = false)
972 result r = E_SUCCESS;
973 bool clipboardAvailable = true;
974 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
976 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
977 if (__pImageMenu != null)
982 // FloatPoint q(0.0,0.0);
983 // __pWebViewer->GetBlockRange(p,q);
987 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
989 else if(__pWebViewer != null && (p.y > (__pWebViewer->GetHeight() + __pWebViewer->GetY())))
991 p.y = __pWebViewer->GetHeight() + __pWebViewer->GetY();
995 if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE )
997 AppLog("asdasdafdsfdgfd");
1000 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
1004 Clipboard* pClipboard = Clipboard::GetInstance();
1006 if(pClipboard == null)
1008 clipboardAvailable = false;
1012 // Retrieves a latest item
1013 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
1017 clipboardAvailable = false;
1021 //Gets data from the clipboard item
1022 String* pString = dynamic_cast<String*>(pItem->GetData());
1026 clipboardAvailable = false;
1030 if(clipboardAvailable == false && onlyPasteOption == true)
1034 __pImageMenu = new (std::nothrow) ContextMenu();
1035 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
1036 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
1042 if(onlyPasteOption == false && __pHitElementResult->GetAttributeValue("type").Equals(L"password",false) == false)
1044 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
1046 if ((pasteOption || onlyPasteOption) && clipboardAvailable == true)
1048 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
1050 if(onlyPasteOption == false && __pHitElementResult->GetAttributeValue("type").Equals(L"password",false) == false)
1052 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
1053 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
1056 __pImageMenu->SetMaxVisibleItemsCount(3);
1057 __pImageMenu->AddActionEventListener(*this);
1058 SetControlAlwaysOnTop(*__pImageMenu, true);
1059 __pImageMenu->SetFocusable(true);
1066 MainForm::InitFindWordPanel(void)
1068 result r = E_SUCCESS;
1069 Bitmap *pIconBitmap = null;
1071 if (__pFindWordControl != null)
1073 AppLogDebug("Findword panel already initialized");
1074 if (__pFindWordBgLabel != null)
1076 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1077 if (pBitmap != null)
1079 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1083 if (__pFindWordBgLabelRightToLeft != null)
1085 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
1086 if (pBitmap != null)
1088 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1093 __pAddressbar->SetShowState(false);
1095 if(__isKeypadOpened == false)
1096 __pFooterPanel->SetShowState(true);
1100 __pFindWordControl = new (std::nothrow) Panel();
1101 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
1104 AppLogException("There is some problem in the xml file. Please check.");
1107 AddControl(__pFindWordControl);
1108 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
1109 SetControlAlwaysOnTop(*__pFindWordControl,true);
1110 __pFindWordControl->SetShowState(false);
1111 __pFindWordControl->Invalidate(false);
1113 __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1114 __pFindWordPanelLeftToRight->SetShowState(true);
1116 __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
1117 __pFindWordPanelRightToLeft->SetShowState(false);
1119 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
1120 if (__pFindWordBgLabel != null)
1122 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1123 Rectangle pRect = pPanel1->GetBounds();
1124 pRect.x = pRect.y = 0;
1125 __pFindWordBgLabel->SetBounds(pRect);
1126 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1127 if (pBitmap != null)
1129 AppLogDebug("InitFindWordPanel: Coming here");
1130 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1135 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1139 __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
1140 if (__pFindWordBgLabelRightToLeft != null)
1142 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1143 Rectangle pRect = pPanel1->GetBounds();
1144 pRect.x = pRect.y = 0;
1145 __pFindWordBgLabelRightToLeft->SetBounds(pRect);
1146 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1147 if (pBitmap != null)
1149 AppLogDebug("InitFindWordPanel: Coming here");
1150 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1155 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1159 Button* pfindWordCancel = null;
1160 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1161 if (pfindWordCancel == null)
1163 AppLogException("There is some problem in the xml file. Please check.");
1166 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1167 pfindWordCancel->AddActionEventListener(*this);
1169 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1170 if (__pFindWordClear == null)
1172 AppLogException("There is some problem in the xml file. Please check.");
1176 __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1177 if (__pFindWordClearRightToLeft == null)
1179 AppLogException("There is some problem in the xml file. Please check.");
1183 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1184 __pFindWordClear->AddActionEventListener(*this);
1186 __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1187 __pFindWordClearRightToLeft->AddActionEventListener(*this);
1189 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1190 if (__pFindWordNext == null)
1192 AppLogException("There is some problem in the xml file. Please check.");
1196 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1197 __pFindWordNext->AddActionEventListener(*this);
1199 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1200 if (__pFindWordPrev == null)
1202 AppLogException("There is some problem in the xml file. Please check.");
1206 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1207 __pFindWordPrev->AddActionEventListener(*this);
1209 __pFindWordNext->SetEnabled(false);
1210 __pFindWordPrev->SetEnabled(false);
1212 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1213 if (__pFindWordCountLabel == null)
1215 AppLogException("There is some problem in the xml file. Please check.");
1219 __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1220 if (__pFindWordCountLabelRightToLeft == null)
1222 AppLogException("There is some problem in the xml file. Please check.");
1226 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1227 if (__pFindWordEditField == null)
1229 AppLogException("There is some problem in the xml file. Please check.");
1232 __pFindWordEditField->AddTextEventListener(*this);
1233 __pFindWordEditField->AddKeypadEventListener(*this);
1234 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1235 __pFindWordEditField->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1237 __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1238 if (__pFindWordEditFieldRightToLeft == null)
1240 AppLogException("There is some problem in the xml file. Please check.");
1243 __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1244 __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1245 __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1246 __pFindWordEditFieldRightToLeft->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1249 __pAddressbar->SetShowState(false);
1251 if(__isKeypadOpened == false)
1252 __pFooterPanel->SetShowState(true);
1257 MainForm::CreateItem (int index, int itemWidth)
1259 Rectangle listImageRect;
1260 Rectangle pagetTitleRect;
1261 Rectangle pageURLRect;
1262 Rectangle deleteImageRect;
1263 String pageTitle(L"");
1264 String pageURL(L"");
1265 result r = E_SUCCESS;
1266 Bitmap* pListIconImage = null;
1269 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1270 if(pHistory == null)
1274 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1275 if ( pAppResource == NULL )
1279 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1281 CustomItem* pItem = new(std::nothrow) CustomItem();
1282 pageTitle = pHistory->GetHistoryTitle();
1283 pageURL = pHistory->GetHistoryUrl();
1285 if (pageURL.GetLength() == 0)
1288 pAppResource->GetString(L"IDS_BR_BODY_BLANK_PAGE", nourl);
1289 pageURL = L"<"+ nourl +">";
1293 Rectangle screenBounds = GetBounds();
1296 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1305 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1307 if ( pBitmap != NULL)
1309 pListIconImage = new Bitmap();
1310 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1314 if(pListIconImage == null)
1316 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1319 if ( pListIconImage != NULL)
1321 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2 , 72, 72);
1322 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 72 + (__fontSize - 44));
1323 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1326 if (pItem != null && pListIconImage != NULL)
1328 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1332 if (pageTitle.CompareTo(L"") != 0)
1336 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1340 if (pageURL.CompareTo(L"") != 0)
1344 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_LISTVIEW_TEXT, CUSTOM_COLOR_LISTVIEW_TEXT, true);
1349 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1351 if ( __pItemContext!= NULL)
1355 pItem->SetContextItem(__pItemContext);
1361 if ( __pItemContextLandscape!= NULL)
1365 pItem->SetContextItem(__pItemContextLandscape);
1369 if( pListIconImage != NULL)
1371 delete pListIconImage;
1372 pListIconImage = null;
1379 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1386 MainForm::GetItemCount (void)
1388 if(__pMostVisitedSites != null)
1390 __pMostVisitedSites->RemoveAll(true);
1392 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1393 if(__pMostVisitedSites != null)
1395 return __pMostVisitedSites->GetCount();
1402 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1404 AppLog("MainForm::OnListViewContextItemStateChanged called");
1405 if(__pMostVisitedSites != null)
1407 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1408 if (pHistory != null)
1410 String url = pHistory->GetHistoryUrl();
1412 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1413 __pMostVisitedListView->UpdateList();
1419 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1421 AppLog("MainForm::OnListViewItemStateChanged called");
1422 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1423 String url = pHistory->GetHistoryUrl();
1431 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1437 MainForm::OnTerminating(void)
1439 result r = E_SUCCESS;
1441 RemoveOrientationEventListener(*this);
1445 __pAddressbar->SetAddressbarEventListener(null);
1450 __pWebViewer->RemoveTouchEventListener(*this);
1451 __pWebViewer->SetWebUiEventListenerF(null);
1452 __pWebViewer->SetWebKeypadEventListener(null);
1453 __pWebViewer->SetTextSearchListener(null);
1459 delete __pItemContext;
1461 if (__pItemContextLandscape)
1463 delete __pItemContextLandscape;
1467 delete __pSaveImage;
1469 if (__pMostVisitedSites)
1471 __pMostVisitedSites->RemoveAll(true);
1472 delete __pMostVisitedSites;
1478 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1480 result r = E_SUCCESS;
1482 AppLogDebug("Clicked : %d", actionId);
1485 case IDA_BACKBTN_CLICKED:
1487 if(__pImageMenu && __pImageMenu->GetShowState() == true)
1489 AppLog("Hiding the menu");
1490 __pImageMenu->SetShowState(false);
1492 if (__pWebViewer && __pWebViewer->CanGoBack())
1494 __pWebViewer->GoBack();
1496 else if(__pWindowInfo->isJavascriptInitiated == false)
1499 pApp = UiApp::GetInstance();
1502 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1505 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1513 WindowInfo* pWindowInfo = null;
1515 SceneManager* pSceneManager = SceneManager::GetInstance();
1516 if (pSceneManager == null)
1520 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1521 if (pAllWindowList == NULL)
1523 pApp = UiApp::GetInstance();
1526 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1529 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1534 if (pAllWindowList != null)
1536 totalCount = pAllWindowList->GetCount();
1538 for (int count = 0; count < totalCount; count++)
1540 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1541 if (pWindowInfo == null)
1543 pApp = UiApp::GetInstance();
1546 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1549 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1556 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1558 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1561 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1564 r = pAllWindowList->RemoveAt(count, true);
1565 __pWindowInfo = null;
1568 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1573 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1577 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1579 if (pWindowInfo == null)
1581 pApp = UiApp::GetInstance();
1584 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1590 r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
1591 // r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1594 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1606 case IDA_FORWARD_CLICKED:
1607 if (__pWebViewer == null)
1610 if (__pWebViewer->CanGoForward())
1612 __pWebViewer->GoForward();
1614 __pOptionMenu->SetShowState(false);
1615 __pOptionMenu->Invalidate(false);
1618 case IDA_FINDONPAGE_CLICKED:
1620 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1621 __currentSearchStr.Clear();
1623 InitFindWordPanel();
1624 __pOptionMenu->SetShowState(false);
1625 __pOptionMenu->Invalidate(false);
1627 ShowFindWordPanel(true);
1629 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1631 __pFindWordEditField->SetFocus();
1632 // __pFindWordCountLabel->SetShowState(false);
1636 __pFindWordEditFieldRightToLeft->SetFocus();
1637 __pFindWordCountLabelRightToLeft->SetShowState(false);
1641 case IDA_PRIVATEON_CLICKED:
1643 result r = E_SUCCESS;
1645 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1646 Bitmap* pBitmap = null;
1647 if (isPrivateBrowsing == true)
1649 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1652 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1656 if (__pWebViewer != NULL)
1658 __pWebViewer->SetPrivateBrowsingEnabled(false);
1661 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1663 if (__pAddressbar != null)
1665 __pAddressbar->UpdateFaviconBitmap(false);
1671 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1674 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1678 if (__pWebViewer != NULL)
1680 __pWebViewer->SetPrivateBrowsingEnabled(true);
1683 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1685 if (__pAddressbar != null)
1687 __pAddressbar->UpdateFaviconBitmap(true);
1691 itemIndex = __pOptionMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1692 r = __pOptionMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1693 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1694 __pOptionMenu->Invalidate(true);
1695 if ( pBitmap != NULL )
1702 case IDA_SETTINGS_CLICKED:
1705 ArrayList* pArgList = new(std::nothrow) ArrayList();
1708 pArgList->Construct();
1709 pArgList->Add(*__pWindowInfo);
1710 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1712 __pOptionMenu->SetShowState(false);
1713 __pOptionMenu->Invalidate(false);
1715 if (pArgList != null)
1724 case IDA_ADDTOBOOKMARK_CLICKED:
1727 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1729 int bookmarkCount=0;
1732 url=__pWindowInfo->pageUrl;
1733 result r = E_SUCCESS;
1734 Bitmap* pBitmap = null;
1735 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1743 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1744 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1745 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1747 if(__pNotification != null)
1749 RemoveControl(__pNotification);
1750 __pNotification = null;
1752 __pNotification = new (std::nothrow) NotificationPanel(*this);
1753 if (__pNotification != null)
1755 __pNotification->SetText(message);
1756 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1757 __pNotification->ShowNotification();
1762 String title=__pWindowInfo->pageTitle;
1763 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1764 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1766 pBookmark->SetBookmarkTitle(title);
1767 pBookmark->SetUrl(url);
1768 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1770 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1772 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1773 pBookmark->SetFaviconId(id);
1774 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1775 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1777 if(__pNotification != null)
1779 RemoveControl(__pNotification);
1780 __pNotification = null;
1782 __pNotification = new (std::nothrow) NotificationPanel(*this);
1783 if (__pNotification != null)
1785 __pNotification->SetText(message);
1786 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1787 __pNotification->ShowNotification();
1788 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1791 if (pBitmap != null)
1793 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1798 __pOptionMenu->Invalidate(true);
1803 case IDA_PRINT_CLICKED:
1805 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//shared//data//test.pdf");
1806 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1808 AppLog("RequestPrint called!");
1809 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1810 result nResult = E_FAILURE;
1813 AppLog("TestPrint if (pAc) == true");
1818 String fileType = L"service_print_files_type";
1819 String typeVal = L"DOC";
1821 String fileCount = L"service_print_files_count";
1822 String countVal = L"1";
1823 String fileFolder= L"service_print_files_folder_name";
1824 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//shared//data";
1826 map.Add(&fileCount, &countVal);
1827 map.Add(&fileFolder, &folderVal);
1828 map.Add(&fileType, &typeVal);
1830 String fileName = L"service_print_files_files_name";
1832 ArrayList fileNameList;
1833 fileNameList.Construct();
1834 String file1 = L"test.pdf";
1836 fileNameList.Add(&file1);
1837 map.Add(&fileName, &fileNameList);
1839 nResult = pAc->Start(NULL, NULL, &map, NULL);
1841 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1842 else if (nResult == E_MAX_EXCEEDED)
1843 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1844 else if (nResult == E_OBJ_NOT_FOUND)
1845 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1846 else if (nResult == E_IN_PROGRESS)
1847 AppLog("TestPrint ret == E_IN_PROGRESS");
1848 else if (nResult == E_PRIVILEGE_DENIED)
1849 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1850 else if(nResult == E_SYSTEM)
1851 AppLog("TestPrint ret == E_SYSTEM");
1857 int __modalMsgBoxResult;
1858 MessageBox* pMsgBox = new MessageBox();
1859 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1860 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1863 __modalMsgBoxResult = 0;
1867 case IDA_SHARE_CLICKED:
1869 if(__pPopUp != null)
1876 __pAddressbar->HideKeypad();
1878 __pPopUp = new(std::nothrow) SharePopup();
1879 __pPopUp->Initialize();
1880 if (__pWindowInfo != null)
1882 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1883 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1884 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1885 pShareInfo->SetImageAttached(false);
1886 __pPopUp->RemoveAllShareInfo();
1887 __pPopUp->AddShareInfo(pShareInfo);
1889 __pPopUp->SetShowState(true);
1893 case IDA_BOOKMARKBTN_CLICKED:
1895 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1896 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1899 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1904 case IDA_MOREBTN_CLICKED:
1906 AppLog("IDA_MOREBTN_CLICKED");
1908 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1910 int bookmarkCount=0;
1913 url=__pWindowInfo->pageUrl;
1914 result r = E_SUCCESS;
1915 Bitmap* pBitmap = null;
1917 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1920 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1925 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1929 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1931 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1933 if (__pOptionMenu->GetItemCount() == 9)
1935 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1939 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1944 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1948 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1949 if (__pOptionMenu->GetItemCount() != 9)
1951 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1952 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1953 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1954 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1955 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1956 __pOptionMenu->SetMaxVisibleItemsCount(6);
1958 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
1960 AppLog(" Orientation landscape");
1961 __pOptionMenu->SetMaxVisibleItemsCount(5);
1965 AppLog(" Orientation potrait");
1966 __pOptionMenu->SetMaxVisibleItemsCount(6);
1969 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1972 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1973 __pOptionMenu->SetShowState(true);
1974 __pOptionMenu->Invalidate(true);
1975 __pOptionMenu->Show();
1979 case IDA_HISTORY_CLICKED:
1981 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1982 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1985 case IDA_SAVED_PAGES_CLICKED:
1990 case IDA_DESKTOP_VIEW_CLICKED:
1995 case IDA_SAVE_CLICKED:
2000 case IDA_MULTIWINDOWBTN_CLICKED:
2002 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2003 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
2007 case IDA_NEWWINDOWBTN_CLICKED:
2009 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
2011 if (pNewWindowInfo == null)
2015 result r = E_SUCCESS;
2016 SceneManager* pSceneManager = SceneManager::GetInstance();
2018 if (pSceneManager == NULL)
2022 ArrayList* pArgList = new(std::nothrow) ArrayList();
2023 if (pArgList == NULL)
2027 r = pArgList->Construct();
2030 pArgList->Add(*pNewWindowInfo);
2031 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2037 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
2042 case IDA_SMALLFONT_BTN_CLICKED:
2044 WebSetting setting = __pWebReader->GetSetting();
2045 setting.SetFontSize(15);
2046 __pWebReader->SetSetting(setting);
2049 case IDA_LARGEFONT_BTN_CLICKED:
2051 WebSetting setting = __pWebReader->GetSetting();
2052 setting.SetFontSize(25);
2053 __pWebReader->SetSetting(setting);
2056 case IDA_READER_CLOSE_CLICKED:
2058 if (__pArticleReaderPanel != null && __pBlankPanel != null)
2060 RemoveControl(__pBlankPanel);
2061 __pArticleReaderPanel = null;
2062 __pBlankPanel = null;
2063 __pArticleReaderLabel = null;
2065 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2068 case IDA_FINDWORD_CANCEL_CLICKED:
2070 __currentSearchStr = L"";
2071 __currentWordIndex = 0;
2072 __maxOccurrances = 0;
2074 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2076 __pFindWordEditField->SetText(L"");
2077 __pFindWordCountLabel->SetText(L"0/0");
2079 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2081 __pFindWordEditFieldRightToLeft->SetText(L"");
2082 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2085 __pFindWordNext->SetEnabled(false);
2086 __pFindWordPrev->SetEnabled(false);
2087 __pFindWordCountLabel->SetText(L"0/0");
2088 __pWebViewer->SearchTextAllAsync(L"",true);
2089 AppLog("akjshdasd 1");
2090 if(__isKeypadOpened == false)
2091 __pFooterPanel->SetShowState(true);
2092 ShowFindWordPanel(false);
2095 case IDA_FINDWORD_SEARCH_CLICKED:
2097 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2099 __currentSearchStr = __pFindWordEditField->GetText();
2101 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2103 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
2106 if (__currentSearchStr.GetLength() > 0)
2112 AppLogDebug("Enter something");
2116 case IDA_FINDWORD_CLEAR_CLICKED:
2118 __pFindWordCountLabel->SetText(L"0/0");
2119 __pFindWordEditField->SetText(L"");
2120 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2122 __currentSearchStr = L"";
2123 __pFindWordNext->SetEnabled(false);
2124 __pFindWordPrev->SetEnabled(false);
2125 // __pFindWordCountLabel->SetShowState(false);
2126 __pFindWordControl->Invalidate(true);
2129 case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
2131 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2132 __pFindWordEditFieldRightToLeft->SetText(L"");
2133 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2135 __currentSearchStr = L"";
2136 __pFindWordNext->SetEnabled(false);
2137 __pFindWordPrev->SetEnabled(false);
2138 // __pFindWordCountLabelRightToLeft->SetShowState(false);
2139 __pFindWordControl->Invalidate(true);
2142 case IDA_FINDWORD_NEXT_CLICKED:
2147 case IDA_FINDWORD_PREV_CLICKED:
2149 FindNextWord(false);
2152 case IDA_BRIGHTNESS_BTN_CLICKED:
2154 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
2155 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2158 case IDA_COPY_IMAGE_CLICKED:
2160 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2161 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2163 const Bitmap* pBitmap = null;
2164 if (__pHitElementResult != null && __pHitElementResult->HasImage())
2166 pBitmap = __pHitElementResult->GetImage();
2169 String resourcePath = App::GetInstance()->GetAppResourcePath();
2170 r = item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
2171 AppLog("Platofrm construct failed result %s",GetErrorMessage(r));
2172 // copying the item to clipboard
2173 Clipboard* pClipboard = Clipboard::GetInstance();
2174 if (pClipboard != null)
2176 r = pClipboard->CopyItem(item);
2177 AppLog("Platofrm copy failed result %s",GetErrorMessage(r));
2181 case IDA_VIEW_IMAGE_CLICKED:
2183 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
2184 WindowInfo* pNewWindowInfo = null;
2185 if (__pHitElementResult != null)
2187 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2188 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2194 case IDA_SAVE_IMAGE_CLICKED:
2196 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
2197 const Bitmap* pSaveBitmap = null;
2198 String imageName = GetImagePath();
2199 AppLog("Content manager image name %ls",imageName.GetPointer());
2202 imagePath.Append(imageName);
2203 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2204 AppLog("Content manager image path %ls",imagePath.GetPointer());
2205 if (__pHitElementResult != null)
2207 pSaveBitmap = __pHitElementResult->GetImage();
2209 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2213 UpdateImageContent(pBuffer, imageName);
2215 if(__pNotification != null)
2217 RemoveControl(__pNotification);
2218 __pNotification = null;
2220 __pNotification = new NotificationPanel(*this);
2222 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2223 msg.Append(imagePath);
2224 if (__pNotification != null)
2226 __pNotification->SetText(msg);
2227 if (__pFooterPanel->GetShowState() == true)
2229 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2233 __pNotification->SetPositionDiff(0);
2235 __pNotification->ShowNotification();
2240 int __modalMsgBoxResult;
2241 MessageBox* pMsgBox = new MessageBox();
2242 pMsgBox->Construct(CommonUtil::GetString(L"IDS_IMGE_POP_UNABLE_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_IMGE_POP_UNABLE_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
2243 pMsgBox->ShowAndWait(__modalMsgBoxResult);
2246 __modalMsgBoxResult = 0;
2250 case IDA_SHARE_IMAGE_CLICKED:
2252 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2253 if (__pPopUp != null)
2260 __pAddressbar->HideKeypad();
2262 __pPopUp = new(std::nothrow) SharePopup();
2263 __pPopUp->Initialize();
2264 if (__pHitElementResult != null)
2266 const Bitmap* pSaveBitmap = null;
2267 String imageName = GetImagePath();
2268 AppLog("Content manager image name %ls",imageName.GetPointer());
2271 imagePath.Append(imageName);
2272 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2273 AppLog("Content manager image path %ls",imagePath.GetPointer());
2274 if (__pHitElementResult != null)
2276 pSaveBitmap = __pHitElementResult->GetImage();
2278 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2280 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2281 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2283 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2284 pShareInfo->SetPageTitle(L"");
2285 pShareInfo->SetPageUrl(srcUrl);
2286 pShareInfo->SetImageAttached(true);
2287 pShareInfo->SetImagePath(imagePath);
2288 __pPopUp->RemoveAllShareInfo();
2289 __pPopUp->AddShareInfo(pShareInfo);
2290 __pPopUp->SetShowState(true);
2295 case IDA_HYPERLINK_OPEN_CLICKED:
2297 if (__pHitElementResult != null)
2299 String srcUrl = __pHitElementResult->GetUrl();
2301 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2303 if (pNewWindowInfo == null)
2307 pNewWindowInfo->isJavascriptInitiated = true;
2308 result r = E_SUCCESS;
2309 SceneManager* pSceneManager = SceneManager::GetInstance();
2310 if (pSceneManager == NULL)
2314 ArrayList* pArgList = new(std::nothrow) ArrayList();
2315 if (pArgList == NULL)
2319 pArgList->Construct();
2321 pArgList->Add(*pNewWindowInfo);
2322 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2323 if (pArgList != null)
2330 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2336 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2338 if (__pHitElementResult == null)
2343 if(__pPopUp != null)
2350 __pAddressbar->HideKeypad();
2352 __pPopUp = new(std::nothrow) SharePopup();
2353 __pPopUp->Initialize();
2355 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2356 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2357 pShareInfo->SetImageAttached(false);
2358 __pPopUp->RemoveAllShareInfo();
2359 __pPopUp->AddShareInfo(pShareInfo);
2361 __pPopUp->SetShowState(true);
2365 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2369 if (__pHitElementResult != null)
2371 url = __pHitElementResult->GetUrl();
2374 String resourcePath = App::GetInstance()->GetAppResourcePath();
2375 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2377 // copying the item to clipboard
2378 Clipboard* pClipboard = Clipboard::GetInstance();
2379 if (pClipboard != null)
2381 pClipboard->CopyItem(item);
2385 case IDA_FIND_TEXT__CLICKED:
2387 // AddressBarCancelledClicked(*__pAddressbar);
2388 RelayoutControls(false);
2389 // __pFooterPanel->SetShowState(false);
2390 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2391 __currentSearchStr.Clear();
2392 __currentSearchStr.Append(__currentSelectedStr);
2393 InitFindWordPanel();
2394 __pFindWordEditField->SetText(__currentSearchStr);
2396 if(__pOptionMenu != null)
2398 __pOptionMenu->SetShowState(false);
2399 __pOptionMenu->Invalidate(false);
2401 __adressPanelPosition.y = 0;
2403 if (__pAddressbar != null && __pWebViewer != NULL)
2405 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2406 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2408 if (__pFooterPanel->GetShowState() == false)
2409 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2411 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2412 __pWebViewer->Invalidate(true);
2415 ShowFindWordPanel(true);
2416 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2418 __pFindWordEditField->SetText(__currentSearchStr);
2419 __pFindWordEditField->SetFocus();
2421 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2423 __pFindWordEditFieldRightToLeft->SetText(__currentSearchStr);
2424 __pFindWordEditFieldRightToLeft->SetFocus();
2427 if (__currentSearchStr.GetLength() > 0)
2433 AppLogDebug("Enter something");
2436 if (__pWebViewer != null)
2438 // releasing the set block
2439 __pWebViewer->ReleaseBlock();
2444 case IDA_SHARE_TEXT_CLICKED:
2446 __pWebViewer->ReleaseBlock();
2447 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2448 if(__pPopUp != null)
2455 __pAddressbar->HideKeypad();
2457 __pPopUp = new(std::nothrow) SharePopup();
2458 __pPopUp->Initialize();
2459 if (__pHitElementResult != null)
2461 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2462 pShareInfo->SetPageTitle(L"");
2463 pShareInfo->SetPageUrl(__currentSelectedStr);
2464 pShareInfo->SetImageAttached(false);
2465 __pPopUp->RemoveAllShareInfo();
2466 __pPopUp->AddShareInfo(pShareInfo);
2467 __pPopUp->SetShowState(true);
2472 case IDA_COPY_TEXT_CLICKED:
2474 // __pWebViewer->ReleaseBlock();//as per hyunn lee request for issue 53500
2475 // need to implement
2476 //__currentSelectedStr
2477 // Sets data to a clip board item
2479 String resourcePath = App::GetInstance()->GetAppResourcePath();
2480 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2482 // copying the item to clipboard
2483 Clipboard* pClipboard = Clipboard::GetInstance();
2484 if (pClipboard != null)
2486 pClipboard->CopyItem(item);
2490 case IDA_PASTE_TEXT_CLICKED:
2492 Clipboard* pClipboard = Clipboard::GetInstance();
2494 if(pClipboard == null)
2498 // Retrieves a latest item
2499 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2505 //Gets data from the clipboard item
2506 String* pString = dynamic_cast<String*>(pItem->GetData());
2508 if (pString != null)
2510 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2511 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2512 String classElement = __pHitElementResult->GetAttributeValue(L"class");
2513 String tagElement = __pHitElementResult->GetTagName();
2514 String contenteditable = __pHitElementResult->GetAttributeValue("contenteditable");
2515 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2516 String str = L"document.getElementsByName('";
2517 str.Append(nameElement);
2518 str.Append("').length");
2519 String* pNameCount = __pWebViewer->EvaluateJavascriptN(str);
2522 str = L"document.getElementsByClassName('";
2523 str.Append(classElement);
2524 str.Append("').length");
2525 String* pClassCount = __pWebViewer->EvaluateJavascriptN(str);
2528 if(contenteditable.Equals(L"true",false) == true)
2530 AppLog("gmail paste need to support");
2532 script = L"function replaceSelectedText(replacementText) { var sel, range; if (window.getSelection) { sel = window.getSelection(); if (sel.rangeCount) { range = sel.getRangeAt(0); range.deleteContents(); range.insertNode(document.createTextNode(replacementText)); } } else if (document.selection && document.selection.createRange) { range = document.selection.createRange(); range.text = replacementText; } }";
2533 script.Append("replaceSelectedText(");
2534 script.Append("\"");
2535 script.Append(*pString);
2536 script.Append("\");");
2538 else if(idElement.GetLength() != 0)
2540 script = L"function insertAtCursor(myField, myValue) { if (document.selection) { myField.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 { myField.value += myValue; } } ";
2541 script.Append("insertAtCursor(");
2542 script.Append(L"document.activeElement");
2544 script.Append("\"");
2545 script.Append(*pString);
2546 script.Append("\");");
2548 else if (classElement.GetLength() != 0 && pClassCount->Equals("1",false) == true)
2550 script = L"function insertAtCursor(myField, myValue) { if (document.selection) { myField.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 { myField.value += myValue; } } ";
2551 script.Append("insertAtCursor(document.getElementsByClassName('");
2552 script.Append(classElement);
2553 script.Append("')[0],");
2554 script.Append("\"");
2555 script.Append(*pString);
2556 script.Append("\");");
2558 else if (nameElement.GetLength() != 0 && pNameCount->Equals("1",false) == true)
2560 script = L"function insertAtCursor(myField, myValue) { if (document.selection) { myField.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 { myField.value += myValue; } } ";
2561 script.Append("insertAtCursor(document.getElementsByName('");
2562 script.Append(nameElement);
2563 script.Append("')[0],");
2564 script.Append("\"");
2565 script.Append(*pString);
2566 script.Append("\");");
2568 else if(tagElement.GetLength() != 0) //adding for twitter post page
2570 script = L"function insertAtCursor(myField, myValue) { if (document.selection) { myField.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 { myField.value += myValue; } } ";
2572 script.Append("insertAtCursor(document.activeElement,");
2573 script.Append("\"");
2574 script.Append(*pString);
2575 script.Append("\");");
2577 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2578 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2585 __pWebViewer->ReleaseBlock();
2593 case IDA_GO_FORWARD:
2598 case IDA_REFRESH_BTN_CLICKED:
2600 __isLoadingCompleted = false;
2601 __isLoadingData = true;
2602 __progressPercentage = 0;
2603 __displayUrl = __pFooterUrlField->GetText();
2605 String url = __pFooterUrlField->GetText();
2606 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2608 if (__pWebViewer != null && __pAddressbar != null)
2611 //__pWebViewer->Reload();
2612 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2616 UpdateProgressBitmap();
2619 case IDA_STOP_BTN_CLICKED:
2621 __isLoadingCompleted = false;
2622 __isLoadingData = false;
2623 __progressPercentage = 0;
2624 __pFooterUrlField->HideKeypad();
2625 __displayUrl = __pFooterUrlField->GetText();
2629 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2630 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2631 __pWebViewer->StopLoading();
2632 RequestRedraw(true);
2635 UpdateProgressBitmap();
2640 if (__pFooterUrlField->GetText().IsEmpty() == false)
2642 //__displayUrl = __pUrlField->GetText();
2643 __pFooterUrlField->Clear();
2648 case IDA_READER_BTN_CLICKED:
2659 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2661 AppLog("MainForm::OnFormBackRequested entered");
2662 result r = E_FAILURE;
2663 if(__pImageMenu && __pImageMenu->GetShowState() == true)
2665 AppLog("Hiding the menu");
2666 __pImageMenu->SetShowState(false);
2668 if (__pWebViewer && __pWebViewer->CanGoBack())
2670 __pWebViewer->GoBack();
2672 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
2675 pApp = UiApp::GetInstance();
2678 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2681 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2689 WindowInfo* pWindowInfo = null;
2691 SceneManager* pSceneManager = SceneManager::GetInstance();
2692 if (pSceneManager == null)
2696 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2697 if (pAllWindowList == NULL)
2699 pApp = UiApp::GetInstance();
2702 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2705 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2710 if (pAllWindowList != null)
2712 totalCount = pAllWindowList->GetCount();
2714 for (int count = 0; count < totalCount; count++)
2716 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2717 if (pWindowInfo == null)
2719 pApp = UiApp::GetInstance();
2722 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2725 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2732 if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2734 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2737 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2740 r = pAllWindowList->RemoveAt(count, true);
2741 __pWindowInfo = null;
2744 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2749 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2753 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2755 if (pWindowInfo == null)
2757 pApp = UiApp::GetInstance();
2760 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2766 if(pWindowInfo != null)
2767 r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
2770 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2776 // else if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == false)
2778 // UiApp* pApp = null;
2779 // pApp = UiApp::GetInstance();
2780 // if (pApp != null)
2782 // r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2785 // AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2793 AppLog("MainForm::OnFormBackRequested exit");
2797 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2798 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2801 AppLog("MainForm::OnSceneActivatedN called");
2802 String* pSelectedScene = NULL;
2803 Object* pValue = NULL;
2804 String* pUrl = null;
2805 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2806 pSelectedScene = (String*) pValue;
2808 if (pSelectedScene != null)
2810 delete pSelectedScene;
2812 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2813 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2814 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2815 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2817 // setting the current scene ID
2818 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2820 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2822 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2824 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2825 if(__pWindowInfo == null)
2827 // if(__pWindowInfo == null)
2829 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2832 else if ( pArgs != null && pArgs->GetCount() == 1)
2834 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2840 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2842 // hiding the address bar
2843 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2844 __pAddressbar->SetShowState(false);
2845 // if(__pWebViewer != null)
2847 // __pWebViewer->Resume();
2850 if(pUrl != null && pUrl->GetLength() > 0)
2854 else if(__pWindowInfo != null)
2856 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.Contains(IDSCN_MAIN_VIEW) == false)
2858 LoadUrl(__pWindowInfo->pageUrl);
2860 else if(__pWindowInfo->pageUrl.GetLength() > 0 && __pWindowInfo->isAppcontrolTriggered == true)
2862 LoadUrl(__pWindowInfo->pageUrl);
2863 __pWindowInfo->isAppcontrolTriggered = false;
2865 else if (__pWindowInfo->isJavascriptInitiated == true && __pWindowInfo->isFirstLaunch == true)
2867 __pWindowInfo->isFirstLaunch = false;
2870 __pWindowInfo->pCurrentWeb = __pWebViewer;
2871 if(__pWindowInfo->pageUrl.GetLength() > 0)
2872 LoadUrl(__pWindowInfo->pageUrl);
2876 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2877 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2878 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2880 InitMostVisitedSitesView(GetOrientationStatus());
2882 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2884 if(__pMostVisitedListView != null)
2886 __pMostVisitedListView->SetShowState(false);
2890 if(__pMostVisitedListView && __pMostVisitedListView->GetShowState() == true)
2892 __pMostVisitedListView->UpdateList();
2894 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2896 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2898 if (pBookmarkUrl == null)
2900 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2901 //__pAddressbar->SetUrl(*pBookmarkUrl);
2902 SetUrl(*pBookmarkUrl);
2904 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2905 __pWebViewer->LoadUrl(*pBookmarkUrl);
2906 delete pBookmarkUrl;
2909 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2910 Bitmap* pBitmap = null;
2911 if (isPrivateBrowsing == true)
2913 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2915 if (__pWebViewer != null)
2917 __pWebViewer->SetPrivateBrowsingEnabled(true);
2920 if (__pAddressbar != null)
2922 // __pAddressbar->UpdateFaviconBitmap(true);
2928 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2930 if (__pWebViewer != null)
2932 __pWebViewer->SetPrivateBrowsingEnabled(false);
2935 if (__pAddressbar != null)
2937 // __pAddressbar->UpdateFaviconBitmap(false);
2941 if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
2943 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2945 else if (__pOptionMenu != null )
2947 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2950 if (pBitmap != null)
2955 RelayoutControls(false);
2956 AppLog("ABC: OnSceneActivatedN started exit");
2958 AppLog("WebControl's width height %d %d,",__pWebViewer->GetWidth(),__pWebViewer->GetHeight());
2963 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2964 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2966 Canvas* pWebCanvas = null;
2967 if (__pWebViewer != null)
2969 pWebCanvas = __pWebViewer->GetCanvasN();
2972 if (pWebCanvas == null)
2976 if (__pWindowInfo != null)
2978 if (__pWindowInfo->pWebCanvasBitmap != null)
2980 delete __pWindowInfo->pWebCanvasBitmap;
2982 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2983 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2984 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2986 Bitmap* pBitmap = GetCapturedBitmapN();
2987 AppLog("Coming here");
2988 Canvas* pCanvas = new(std::nothrow) Canvas();
2989 pCanvas->Construct(GetClientAreaBounds());
2992 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2995 if(__pWebViewer != null && __pWindowInfo != null && __pWindowInfo->pWebCanvasBitmap != null)
2996 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2998 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
3001 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
3006 __pAddressbar->SetShowState(false);
3007 AppLog("Coming here");
3011 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
3012 const Tizen::Base::String& realm,
3013 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
3019 MainForm::OnHttpAuthenticationCanceled(void)
3024 MainForm::OnLoadingStarted(void)
3026 AppLogDebug("MainForm::OnLoadingStarted entered");
3028 if(__pAddressbar == NULL || __pWebViewer == null)
3033 // this is added in case if menu is opened and user load the page
3034 if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
3036 __pOptionMenu->SetShowState(false);
3037 __pOptionMenu->Invalidate(true);
3042 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
3044 __pImageMenu->SetShowState(false);
3045 __pImageMenu->Invalidate(true);
3047 String url = __pWebViewer->GetUrl();
3048 if(url.Contains(IDS_TIZEN_SERVICE))
3051 String delim(L":;,");
3053 // Creates a StringTokenizer instance
3054 StringTokenizer strTok(url, delim);
3056 int count = strTok.GetTokenCount(); // count == 4
3058 HashMap *pMap = new HashMap();
3063 while (strTok.HasMoreTokens())
3065 AppLog("Token: %ls", token.GetPointer());
3066 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3067 if(token.Contains(IDS_APPID))
3069 token.SubString(6, appId);
3070 AppLog("AppID:%ls", appId.GetPointer());
3072 else if(token.Contains(IDS_KEY))
3074 token.SubString(4, key);
3075 AppLog("key:%ls", key.GetPointer());
3077 else if(token.Contains(IDS_VALUE))
3079 token.SubString(6, value);
3080 AppLog("value:%ls", value.GetPointer());
3083 pMap->Add(key, value);
3087 AppControl *pAppControl = null;
3088 String operationId = L"http://tizen.org/appcontrol/operation/main";
3089 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3092 AppLog("Starting AppControl");
3093 result r = pAppControl->Start(null, null, pMap, null);
3094 AppLog("Result of Start %s", GetErrorMessage(r));
3098 AppLogException("AppControl not found");
3103 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
3105 __pAddressbar->SetShowState(false);
3106 AddressBarCancelledClicked(*__pAddressbar);
3107 __pAddressbar->Invalidate(true);
3109 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
3112 __pAddressbar->SetFaviconBitmap(*pBitmap);
3115 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
3117 // updating the address bar position with respect to web control
3118 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
3119 __distanceMoved = 0;
3123 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3124 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3125 if (__pWebViewer != null)
3127 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
3128 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
3129 SetUrl(__pWebViewer->GetUrl());
3130 if (__pWindowInfo != NULL)
3132 // resetting the page title to blank, it will be received in OnPageTitleReceived()
3133 // __pWindowInfo->pageTitle = L"";
3134 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3136 __pAddressbar->Invalidate(true);
3142 MainForm::OnLoadingCanceled(void)
3148 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
3150 AppLog("XYZ::MainForm::OnKeypadWillOpen");
3155 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
3157 AppLog("XYZ::MainForm::OnKeypadOpened");
3158 __isKeypadOpened = true;
3159 __pFooterPanel->SetShowState(false);
3160 RelayoutControls(false);
3164 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
3166 AppLog("XYZ::MainForm::OnKeypadClosed");
3167 __isKeypadOpened = false;
3168 __pFooterPanel->SetShowState(true);
3169 RelayoutControls(true);
3173 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
3175 AppLog("XYZ::KeypadBoundsChanged");
3176 RelayoutControls(false);
3180 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
3181 const Tizen::Base::String& reason)
3183 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
3187 MainForm::OnLoadingCompleted(void)
3189 AppLog("MainForm::OnLoadingCompleted start");
3191 result r = E_SUCCESS;
3193 if (__pWebViewer == null)
3198 if (__pAddressbar == null)
3203 if(__pWindowInfo && __pWebViewer)
3204 __pWindowInfo->pageTitle = __pWebViewer->GetTitle();
3205 if(__pImageMenu && __pImageMenu->GetShowState())
3207 __pImageMenu->SetShowState(false);
3208 __pImageMenu->Invalidate(true);
3211 if (__pWebViewer->CanGoForward())
3213 //__pAddressbar->SetForwardButtonEnabled(true);
3214 SetForwardButtonEnabled(true);
3218 //__pAddressbar->SetForwardButtonEnabled(false);
3219 SetForwardButtonEnabled(false);
3222 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3224 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3226 //__pAddressbar->UpdateProgress(0);
3230 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3232 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3236 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
3237 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
3238 if (isPrivateBrowsing == false)
3240 if(__pHistory != null)
3246 __pHistory = new(std::nothrow) History;
3247 HistoryPresentationModel::GetCurrentDateTime(date);
3250 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
3251 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
3253 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
3254 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3256 __pHistory->SetVisitedTime(date);
3258 if (__pWebViewer != null)
3260 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3262 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3263 if (pTempBitmap != null)
3265 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3266 __pHistory->SetFavIconBitmap(*pTempBitmap);
3271 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3272 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3273 if ( pCanvas != null && pCanvas != null && pBitmap != null)
3275 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3276 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3277 __pHistory->SetThumbnail(pBitmap);
3279 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3282 Tizen::Graphics::BufferInfo bmpInfo;
3283 pFavIcon->Lock(bmpInfo);
3284 AppLog("rrrr:: width %d height %d of the faviconbitmap from bufferinfo", bmpInfo.width, bmpInfo.height);
3286 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3288 AppLog("rrrr:: width %d height %d of the faviconbitmap",pFavIcon->GetWidth(),pFavIcon->GetHeight());
3289 __pHistory->SetFavIconBitmap(*pFavIcon);
3293 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3300 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3302 // temperary fixed (webpage can be not loaded)
3306 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3307 if (isReaderEnabled == true)
3311 delete __pReaderData;
3312 __pReaderData = null;
3314 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3315 filePath.Append(L"data/reader.js");
3321 result r = E_SUCCESS;
3322 FileAttributes attr;
3324 File::GetAttributes(filePath,attr);
3326 r = file.Construct(filePath, L"r+");
3329 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3332 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3335 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3338 // file.Read(pScript,attr.GetFileSize());
3340 // AppLogDebug("scipt length %d",strlen(pScript));
3341 String strScript = L"";
3342 // strScript.Append(pScript);
3343 // for(int i=0; i<25; i++)
3345 file.Read(pScript,attr.GetFileSize());
3346 // AppLog("xyzz tell %d",file.Tell());
3347 // r = strScript.Append(pScript);
3348 // AppLog("xyzz append result %s",GetErrorMessage(r));
3349 // AppLog("xyzz strScript length %d",strScript.GetLength());
3351 // AppLog("xyzz final strScript length %d",strScript.GetLength());
3353 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3354 if (__pReaderData == null)
3356 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3357 __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>");
3360 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3361 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3363 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3364 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3370 AppLog("MainForm::OnLoadingCompleted done");
3374 MainForm::OnEstimatedProgress(int progress)
3376 AppLogDebug("MainForm::OnEstimatedProgress entered %d",progress);
3378 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3379 progress = DEFAULT_PROGRESS_PERCENTAGE;
3381 // __pAddressbar->UpdateProgress(progress);
3382 UpdateProgress(progress);
3385 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3387 AppLog("MainForm::OnFaviconReceived");
3388 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3390 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3393 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3400 MainForm::OnUrlValueChanged(Addressbar&)
3406 MainForm::OnUrlSubmitted(Addressbar& addBar)
3408 AppLog("MainForm::OnUrlSubmitted");
3409 String url = addBar.GetUrl();
3410 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3412 if(__pFooterUrlField)
3413 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3414 AddressBarCancelledClicked(*__pAddressbar);
3419 MainForm::LoadUrl(String& url)
3423 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3424 AppLogDebug("MainForm::LoadUrl enter");
3426 if (__pWebViewer != null)
3428 __pWebViewer->SetShowState(true);
3429 __pWebViewer->Invalidate(true);
3432 if (url.CompareTo(L"") == 0)
3436 if(__pFooterPanel != null)
3438 __pFooterPanel->SetShowState(true);
3439 __pFooterPanel->Invalidate(true);
3446 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3447 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)
3449 RegularExpression firstRegex;
3450 RegularExpression secondRegex;
3452 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3453 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3456 ret = firstRegex.Match(url, false); // This returns true value
3457 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3459 if (ret == true && __pWebViewer != null)
3462 __pWebViewer->LoadUrl(url);
3464 else if(__pWebViewer != null)
3466 String tempUrl = L"http://";
3467 tempUrl.Append(url);
3471 __pWebViewer->LoadUrl(tempUrl);
3475 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3476 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3479 if (__pAddressbar != null)
3481 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3482 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3485 AppLogDebug("MainForm::LoadUrl exit");
3492 MainForm::OnFocusGained(const Tizen::Ui::Control& source)
3494 AppLog("MainForm::OnFocusGained");
3497 __pFooterPanel->SetShowState(false);
3502 __pWebViewer->ReleaseBlock();
3507 __pAddressbar->SetShowState(true);
3508 __pAddressbar->SetAddressbarURLFocus();
3510 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3512 __currentSearchStr = L"";
3513 __currentWordIndex = 0;
3514 __maxOccurrances = 0;
3516 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
3518 __pFindWordEditField->SetText(L"");
3519 __pFindWordEditField->HideKeypad();
3520 __pFindWordControl->SetShowState(false);
3521 __pFindWordCountLabel->SetText(L"0/0");
3523 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
3525 __pFindWordEditFieldRightToLeft->SetText(L"");
3526 __pFindWordEditFieldRightToLeft->HideKeypad();
3527 __pFindWordControl->SetShowState(false);
3528 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
3531 __pFindWordNext->SetEnabled(false);
3532 __pFindWordPrev->SetEnabled(false);
3534 __pWebViewer->SearchTextAllAsync(L"",true);
3535 __pFindWordControl->SetShowState(false);
3537 RelayoutControls(false);
3541 MainForm::OnFocusLost(const Tizen::Ui::Control& source)
3543 AppLog("MainForm::OnFocusLost called");
3547 MainForm::OnStopClicked(Addressbar& addBar)
3549 AppLogDebug("MainForm::OnStopClicked called");
3552 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3553 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3554 __pWebViewer->StopLoading();
3555 RequestRedraw(true);
3560 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3562 // AppLog("MainForm::OnBackClicked");
3563 result r = E_FAILURE;
3564 if(__pImageMenu && __pImageMenu->GetShowState() == true)
3566 AppLog("Hiding the menu");
3567 __pImageMenu->SetShowState(false);
3570 if (__pWebViewer && __pWebViewer->CanGoBack())
3572 __pWebViewer->GoBack();
3574 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3577 pApp = UiApp::GetInstance();
3580 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3583 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3591 WindowInfo* pWindowInfo = null;
3593 SceneManager* pSceneManager = SceneManager::GetInstance();
3594 if (pSceneManager == null)
3598 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3599 if (pAllWindowList == NULL)
3601 pApp = UiApp::GetInstance();
3604 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3607 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3612 if (pAllWindowList != null)
3614 totalCount = pAllWindowList->GetCount();
3616 for (int count = 0; count < totalCount; count++)
3618 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3619 if (pWindowInfo == null)
3621 pApp = UiApp::GetInstance();
3624 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3627 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3632 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3634 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3637 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3640 r = pAllWindowList->RemoveAt(count, true);
3641 __pWindowInfo = null;
3644 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3649 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3651 else if(pAllWindowList->GetCount() > 0)
3653 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3657 pApp = UiApp::GetInstance();
3660 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3665 if (pWindowInfo == null)
3667 pApp = UiApp::GetInstance();
3670 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3676 r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
3677 // r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3680 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3694 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3696 AppLog("MainForm::OnForwardClicked");
3697 if (__pWebViewer == null)
3700 if (__pWebViewer->CanGoForward())
3702 __pWebViewer->GoForward();
3707 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3709 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3710 if(__pFooterPanel != null)
3712 __pFooterPanel->SetShowState(false);
3715 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3717 __pAddressbar->SetShowState(true);
3718 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3721 RelayoutControls(false);
3725 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3727 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3729 int Height = GetClientAreaBounds().height;
3730 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3732 RelayoutControls(false);
3736 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3738 AddressBarCancelledClicked(addBar);
3742 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3744 __prevAddressBarMode = __curAddressBarMode;
3746 if (__pAddressbar != null)
3748 __curAddressBarMode = GetAddressbarMode();
3751 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3753 __adressPanelPosition.y = 0;
3754 if (__pAddressbar != null)
3756 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3757 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3758 __pAddressbar->Invalidate(true);
3760 if (__pWebViewer != null)
3762 __pWebViewer->StopLoading();
3765 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3767 __adressPanelPosition.y = 0;
3768 if (__pAddressbar != null)
3770 __webControlPosition.y = 0;
3771 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3772 __pAddressbar->Invalidate(true);
3778 MainForm::OnClipboardClosed(const Addressbar& addBar)
3780 AppLog("XYZ::MainForm::OnClipboardClosed");
3781 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3783 AppLog("akjshdasd 3");
3784 __pFooterPanel->SetShowState(true);
3786 __isKeypadOpened = false;
3787 RelayoutControls(false);
3791 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3793 AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3794 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3796 AppLog("akjshdasd 3");
3797 __pFooterPanel->SetShowState(true);
3799 __isKeypadOpened = false;
3800 if(__pNotification && __pNotification->GetShowState())
3802 __pNotification->SetPosition(0,GetClientAreaBounds().height - __pNotification->GetHeight());
3805 RelayoutControls(false,footerState);
3809 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3811 AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3812 __isKeypadOpened = true;
3813 if(__pNotification && __pNotification->GetShowState())
3815 __pNotification->SetPosition(0,GetClientAreaBounds().height - __pNotification->GetHeight());
3817 RelayoutControls(false);
3821 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3823 __isKeypadOpened = true;
3824 __pFooterPanel->SetShowState(false);
3828 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3830 AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3831 RelayoutControls(false);
3835 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3837 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3840 __pWindowInfo->pageTitle = title;
3841 if (__pWebViewer != null)
3843 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3844 AppLog("MainForm::OnPageTitleReceived url %ls",__pWindowInfo->pageUrl.GetPointer());
3847 if (__pAddressbar != null && __pWebViewer != null)
3849 SetUrl(__pWebViewer->GetUrl());
3850 __pAddressbar->Invalidate(true);
3855 MainForm::UpdateFavicon(void)
3857 bool urlImageType = false;
3858 String *tempPath = null;
3860 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();");
3861 Bitmap* pBitmap = null;
3863 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3865 if (__pWindowInfo != null)
3868 url.SetUri(*tempPath);
3869 if (url.GetHost().GetLength() == 0)
3873 webUrl.SetUri(__pWebViewer->GetUrl());
3874 result r = url.SetHost(webUrl.GetHost());
3881 if (url.GetScheme().GetLength() == 0)
3885 webUrl.SetUri(__pWebViewer->GetUrl());
3886 url.SetScheme(webUrl.GetScheme());
3888 __pWindowInfo->faviconUrl = url.ToString();
3890 pBitmap = __pWebViewer->GetFaviconN();
3892 if (pBitmap != null)
3894 if (__pWindowInfo->pFavicon != NULL)
3896 __pWindowInfo->pFavicon = null;
3898 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3899 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3901 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3903 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3905 else if(__pWindowInfo->pFavicon != null)
3907 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3911 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3912 if(pDefaultBmp != null)
3914 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3928 if(tempPath != null)
3932 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3938 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3939 Tizen::Web::Controls::WebNavigationType type)
3941 AppLog("urlk %ls",url.GetPointer());
3942 // when load new page if find word panel is open its show state is false
3943 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3945 __currentSearchStr = L"";
3946 __currentWordIndex = 0;
3947 __maxOccurrances = 0;
3948 __pFindWordEditField->SetText(L"");
3949 __pFindWordNext->SetEnabled(false);
3950 __pFindWordPrev->SetEnabled(false);
3951 __pFindWordCountLabel->SetText(L"0/0");
3952 __pFindWordControl->SetShowState(false);
3953 __pFindWordEditField->HideKeypad();
3954 RelayoutControls(false);
3957 __pFooterPanel->Invalidate(true);
3960 uriInfo.SetUri(url);
3962 if(url.Contains(IDS_TIZEN_SERVICE))
3965 String delim(L":;,");
3967 // Creates a StringTokenizer instance
3968 StringTokenizer strTok(url, delim);
3970 int count = strTok.GetTokenCount(); // count == 4
3972 HashMap *pMap = new HashMap();
3978 while (strTok.HasMoreTokens())
3980 AppLog("Token: %ls", token.GetPointer());
3981 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3982 if(token.Contains(IDS_APPID))
3984 token.SubString(6, appId);
3985 AppLog("AppID:%ls", appId.GetPointer());
3987 else if(token.Contains(IDS_KEY))
3989 token.SubString(4, key);
3990 AppLog("key:%ls", key.GetPointer());
3992 else if(token.Contains(IDS_VALUE))
3994 token.SubString(6, value);
3995 AppLog("value:%ls", value.GetPointer());
3998 pMap->Add(key, value);
4002 AppControl *pAppControl = null;
4003 String operationId = L"http://tizen.org/appcontrol/operation/main";
4004 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
4007 result r = pAppControl->Start(null, null, pMap, null);
4011 AppLogException("AppControl not found");
4021 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
4022 const Tizen::Net::Http::HttpHeader& httpHeader)
4024 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
4028 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
4030 AppLog("LMN::MainForm::OnWebPageBlockSelected");
4031 // if(__isLongPressedDone == false)
4034 if (__pHitElementResult != null)
4036 delete __pHitElementResult;
4037 __pHitElementResult = null;
4040 if (__pWebViewer != null)
4042 AppLog("MainForm::OnWebPageBlockSelected web not null");
4043 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
4045 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false))
4047 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
4048 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
4049 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false))
4051 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
4053 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
4057 if (__pHitElementResult == null)
4062 if (__pHitElementResult->HasImage() != true)
4064 String tagName = __pHitElementResult->GetTagName();
4065 String type = __pHitElementResult->GetAttributeValue("type");
4066 String contenteditable = __pHitElementResult->GetAttributeValue("contenteditable");
4069 AppLog("TagName %ls",tagName.GetPointer());
4070 __currentSelectedStr.Clear();
4071 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
4072 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4073 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
4074 if(tagName.Equals(L"TEXTAREA",false) == true)
4076 AppLog("Tagnameseemstobe TEXTAREA");
4078 else if(tagName.Equals(L"INPUT",false) == true)
4080 AppLog("Tagnameseemstobe INPUT");
4083 if (((tagName.Equals(L"INPUT",false) == true) || tagName.Equals(L"TEXTAREA",false) == true) || contenteditable.Equals(L"true",false) == true/*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0 )
4085 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4087 InitSelectTextContextMenuF(FloatPoint(startPoint.x,startPoint.y + __pWebViewer->GetY()),true);
4090 __pImageMenu->SetShowState(true);
4091 __pImageMenu->Show();
4092 __pImageMenu->Invalidate(true);
4095 else /*if(__isLongPressedDone == true)*/
4097 AppLog("MainForm::OnWebPageBlockSelected no paste option");
4099 if(__pHitElementResult->GetUrl().GetLength() > 0)
4101 __currentSelectedStr.Clear();
4102 __currentSelectedStr = __pHitElementResult->GetUrl();
4104 InitSelectTextContextMenuF(FloatPoint(startPoint.x,startPoint.y + __pWebViewer->GetY()),false);
4107 __pImageMenu->SetShowState(true);
4108 __pImageMenu->Show();
4109 __pImageMenu->Invalidate(true);
4113 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
4114 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
4115 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
4121 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
4127 MainForm::OnWebWindowCreateRequested(void)
4129 AppLog("MainForm::OnWebWindowCreateRequested entered");
4130 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
4132 if (pNewWindowInfo == null)
4136 result r = E_SUCCESS;
4137 SceneManager* pSceneManager = SceneManager::GetInstance();
4138 if (pSceneManager == NULL)
4142 ArrayList* pArgList = new(std::nothrow) ArrayList();
4143 if (pArgList == NULL)
4147 r = pArgList->Construct();
4150 pNewWindowInfo->isJavascriptInitiated = true;
4151 pArgList->Add(*pNewWindowInfo);
4152 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4156 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
4163 return pNewWindowInfo->pCurrentWeb;
4167 MainForm::OnWebWindowCloseRequested(Tizen::Web::Controls::Web& source)
4169 AppLog("OnWebWindowCloseRequested");
4170 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
4171 SceneManager* pSceneManager = SceneManager::GetInstance();
4172 WindowInfo* pWindowInfo = null;
4173 WindowInfo* pNewWindowInfo = null;
4176 result r = E_FAILURE;
4178 if (pAllWindowList != null)
4180 totalCount = pAllWindowList->GetCount();
4183 for (int count = 0; count < totalCount; count++)
4185 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
4187 if (__pWindowInfo != null && pWindowInfo != null && __pWindowInfo->sceneID == pWindowInfo->sceneID)
4189 r = SceneRegister::DestroyAndUnRegisterScene(__pWindowInfo->sceneID);
4190 r = pAllWindowList->RemoveAt(count, true);
4192 Form* pCurrentForm = null;
4193 if(SceneManager::GetInstance()->GetCurrentScene() != null)
4194 pCurrentForm = (SceneManager::GetInstance()->GetCurrentScene()->GetForm());
4197 pCurrentForm->SendUserEvent(UPDATE_MAINFORM_FOOTER_ON_WINDOWCLOSED, null);
4200 if (pAllWindowList->GetCount() > 0)
4202 pNewWindowInfo = null;
4203 pNewWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
4207 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
4209 if (pNewWindowInfo == null)
4213 result r = E_SUCCESS;
4214 SceneManager* pSceneManager = SceneManager::GetInstance();
4215 if (pSceneManager == NULL)
4219 ArrayList* pArgList = new(std::nothrow) ArrayList();
4220 if (pArgList == NULL)
4224 r = pArgList->Construct();
4227 pArgList->Add(*pNewWindowInfo);
4228 result r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4229 if (pArgList != null)
4236 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
4241 pApp = UiApp::GetInstance();
4244 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
4248 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
4259 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
4261 AppLog("xyz:: MainForm::RelayoutControls called");
4262 __webControlPosition.y = 0;
4263 __webControlHeight = GetClientAreaBounds().height;
4264 AppLog("Client area height: %d width %d", __webControlHeight,GetClientAreaBounds().width);
4266 AppLog("Client area height: %d", __webControlHeight);
4267 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
4269 __webControlPosition.y += __pAddressbar->GetHeight();
4270 __webControlHeight -= __pAddressbar->GetHeight();
4271 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
4273 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
4275 __webControlPosition.y += __pFindWordControl->GetHeight();
4276 __webControlHeight -= __pFindWordControl->GetHeight();
4277 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
4280 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
4282 __webControlHeight -= __pFooterPanel->GetHeight();
4284 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
4285 __webControlHeight = __webControlHeight + 12;
4287 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
4289 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight )
4294 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight );
4295 AppLog("xyz:: MainForm::RelayoutControls called __webControlHeight %d",__webControlHeight);
4296 __pWebViewer->Invalidate(false);
4299 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
4301 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
4308 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
4310 if (__pFindWordControl == null)
4315 Tizen::Locales::LocaleManager localeManager;
4316 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
4318 String languageCode;
4319 result r = SettingInfo::GetValue(L"Language", languageCode);
4320 // int languagecode = local.GetLanguageCode();
4321 AppLog("rahul language is %S", languageCode.GetPointer());
4325 InitFindWordPanel();
4327 if (languageCode.CompareTo("ara") == 0)
4329 AppLog("rahul language is arabic");
4331 __pFindWordPanelLeftToRight->SetShowState(false);
4332 __pFindWordPanelRightToLeft->SetShowState(true);
4334 __pFindWordClear->SetShowState(false);
4335 __pFindWordCountLabel->SetShowState(false);
4336 __pFindWordEditField->SetShowState(false);
4338 __pFindWordClearRightToLeft->SetShowState(true);
4339 __pFindWordCountLabelRightToLeft->SetShowState(true);
4340 __pFindWordEditFieldRightToLeft->SetShowState(true);
4344 AppLog("rahul language is not arabic");
4347 __pFindWordPanelLeftToRight->SetShowState(true);
4348 __pFindWordPanelRightToLeft->SetShowState(false);
4350 __pFindWordClear->SetShowState(true);
4351 __pFindWordCountLabel->SetShowState(true);
4352 __pFindWordEditField->SetShowState(true);
4354 __pFindWordClearRightToLeft->SetShowState(false);
4355 __pFindWordCountLabelRightToLeft->SetShowState(false);
4356 __pFindWordEditFieldRightToLeft->SetShowState(false);
4358 __pFindWordControl->SetShowState(true);
4362 if(__pFindWordControl != null)
4364 __pFindWordControl->SetShowState(false);
4368 AppLog("MainForm::ShowFindWordPanel %d",show);
4369 if (show && !isTouchPressed)
4371 if (languageCode.CompareTo("ara") == 0)
4373 if (__pFindWordEditFieldRightToLeft)
4375 __pFindWordEditFieldRightToLeft->SetFocus();
4376 __pFindWordEditFieldRightToLeft->ShowKeypad();
4381 if (__pFindWordEditField)
4383 __pFindWordEditField->SetFocus();
4384 __pFindWordEditField->ShowKeypad();
4390 if (languageCode.CompareTo("ara") == 0)
4392 if (__pFindWordEditFieldRightToLeft)
4393 __pFindWordEditFieldRightToLeft->HideKeypad();
4397 if (__pFindWordEditField)
4398 __pFindWordEditField->HideKeypad();
4402 RelayoutControls(false);
4406 MainForm::StartWordSearch()
4408 //Get the count of occurances of the word in the current page
4409 __maxOccurrances = 0;
4410 __currentWordIndex = 0;
4412 __pFindWordPrev->SetEnabled(false);
4413 String *pCountStr = null;
4416 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
4417 AppLog("Search Result %s",GetErrorMessage(r));
4420 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
4421 if (pCountStr != null)
4423 Integer::Parse(*pCountStr, 10, __maxOccurrances);
4427 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
4432 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
4434 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
4435 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
4439 if (__pFindWordCountLabel)
4441 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
4443 if (__pFindWordEditField)
4445 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
4448 else if(totalCount >= 100)
4450 if (__pFindWordCountLabel)
4452 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4454 if (__pFindWordEditField)
4456 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4461 if (__pFindWordCountLabel)
4463 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4465 if (__pFindWordEditField)
4467 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4471 __maxOccurrances = totalCount;
4472 __currentWordIndex = currentOrdinal;
4474 //Reset the UI controls as per the maxOccurrance value
4475 if (totalCount <= 0)
4477 AppLog("Word not found");
4478 //Show error notification to user
4479 __pFindWordNext->SetEnabled(false);
4480 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4482 __pFindWordCountLabel->SetText(L"0/0");
4483 __pFindWordCountLabel->Invalidate(false);
4485 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4487 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4488 __pFindWordCountLabelRightToLeft->Invalidate(false);
4490 __pFindWordNext->Invalidate(false);
4491 __pFindWordPrev->Invalidate(false);
4496 if (totalCount == 1 || totalCount == currentOrdinal)
4498 __pFindWordNext->SetEnabled(false);
4502 __pFindWordNext->SetEnabled(true);
4505 String countStr = L"";
4506 countStr.Append(__currentWordIndex);
4507 countStr.Append(L"/");
4508 countStr.Append(__maxOccurrances);
4509 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4511 __pFindWordCountLabel->SetText(countStr);
4512 __pFindWordCountLabel->Invalidate(false);
4513 __pFindWordCountLabel->Invalidate(false);
4515 else if (__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4517 __pFindWordCountLabelRightToLeft->SetText(countStr);
4518 __pFindWordCountLabelRightToLeft->Invalidate(false);
4519 __pFindWordCountLabelRightToLeft->Invalidate(false);
4521 if (__pFindWordNext)
4523 __pFindWordNext->Invalidate(false);
4525 if (__pFindWordPrev)
4527 __pFindWordPrev->Invalidate(false);
4533 MainForm::FindNextWord(bool next)
4537 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4538 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4540 if (__currentWordIndex < __maxOccurrances)
4542 __currentWordIndex++;
4548 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4549 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4551 if(__currentWordIndex > 1)
4553 __currentWordIndex--;
4558 String countStr = L"";
4559 countStr.Append(__currentWordIndex);
4560 countStr.Append(L"/");
4561 countStr.Append(__maxOccurrances);
4563 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4565 __pFindWordCountLabel->SetText(countStr);
4566 __pFindWordCountLabel->Invalidate(false);
4568 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4570 __pFindWordCountLabelRightToLeft->SetText(countStr);
4571 __pFindWordCountLabelRightToLeft->Invalidate(false);
4574 if (__currentWordIndex >= __maxOccurrances)
4576 __pFindWordNext->SetEnabled(false);
4580 __pFindWordNext->SetEnabled(true);
4582 if (__currentWordIndex <= 1)
4584 __pFindWordPrev->SetEnabled(false);
4588 __pFindWordPrev->SetEnabled(true);
4590 __pFindWordPrev->Invalidate(false);
4591 __pFindWordNext->Invalidate(false);
4593 __pFindWordControl->Invalidate(true);
4597 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4599 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4600 __isKeypadOpened = true;
4601 __pFooterPanel->SetShowState(false);
4602 // OnAddressBarKeypadOpened(*__pAddressbar);
4606 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4608 __isKeypadOpened = true;
4609 AppLog("xyz::MainForm::OnWebKeypadOpened");
4611 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4613 __currentSearchStr = L"";
4614 __currentWordIndex = 0;
4615 __maxOccurrances = 0;
4616 __pFindWordEditField->SetText(L"");
4617 __pFindWordNext->SetEnabled(false);
4618 __pFindWordPrev->SetEnabled(false);
4619 __pFindWordCountLabel->SetText(L"0/0");
4620 __pWebViewer->SearchTextAllAsync(L"",false);
4621 __pFindWordControl->SetShowState(false);
4622 __pFindWordEditField->HideKeypad();
4626 if (__pWebViewer != null && __pFooterPanel != null)
4628 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4629 if(__pAddressbar != null)
4631 __pAddressbar->SetShowState(false);
4633 if(__pFindWordControl != null)
4635 __pFindWordControl->SetShowState(false);
4637 __pFooterPanel->SetShowState(false);
4638 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4640 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4642 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4643 // AppLog("omgomgomg");
4649 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4651 AppLog("abcde::MainForm::OnWebKeypadClosed");
4652 AppLog("xyz::MainForm::OnWebKeypadClosed");
4653 AppLog("akjshdasd 4");
4654 __pFooterPanel->SetShowState(true);
4655 // OnAddressBarKeypadClosed(*__pAddressbar);
4656 RelayoutControls(false);
4657 __isKeypadOpened = false;
4660 if(__pImageMenu && __pImageMenu->GetShowState() == true)
4662 AppLog("abcde: imagemenu visible.");
4665 __pWebViewer->GetBlockRange(p,q);
4666 if (p == Point(0,0) && q == Point(0,0))
4674 __pImageMenu->SetAnchorPosition(p);
4675 __pImageMenu->Show();
4681 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4683 // RelativeLayout(false);
4684 if(__pWebViewer != null)
4686 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4691 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4693 Control* temp = const_cast< Control* >(&source);
4694 Header* pHeader = dynamic_cast< Header* >(temp);
4695 if (pHeader != null)
4697 //Header double - clicked
4698 AppLog("Header double clicked");
4700 if(__pFindWordControl)
4702 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4703 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4707 AppLog("MainScene::OnTouchDoublePressed");
4711 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4713 AppLog("LMN::abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4714 if(TouchEventManager::GetInstance() && TouchEventManager::GetInstance()->GetTouchInfoListN() && TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1)
4716 AppLog("Returning because of more than one touch point.");
4720 // __pWebViewer->ReleaseBlock();
4722 __pWebViewer->SetFocus();
4723 __longPressPoint = currentPosition;
4725 if (__pHitElementResult != null)
4727 delete __pHitElementResult;
4728 __pHitElementResult = null;
4731 if (__pWebViewer != null)
4733 AppLog("MainForm::OnTouchLongPressed web not null");
4734 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4737 if (__pHitElementResult == null)
4742 if (__pHitElementResult->HasImage() == true)
4744 if(__pWebViewer != null)
4746 __pWebViewer->ReleaseBlock();//N_SE-52389
4747 InitImageContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4749 __pImageMenu->SetShowState(true);
4750 __pImageMenu->Show();
4751 __pImageMenu->Invalidate(true);
4753 else if(__pHitElementResult->HasUrl() == true)
4755 if(__pWebViewer != null)
4756 __pWebViewer->ReleaseBlock();//N_SE-52389
4757 String tempURl = __pHitElementResult->GetUrl();
4758 AppLog("tempURl is %ls", tempURl.GetPointer());
4759 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4760 if (pBitmap != null)
4768 InitImageLinkContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4769 __pImageMenu->SetShowState(true);
4770 __pImageMenu->Show();
4771 __pImageMenu->Invalidate(true);
4775 String tagName = __pHitElementResult->GetTagName();
4776 String type = __pHitElementResult->GetAttributeValue("type");
4777 String value = __pHitElementResult->GetAttributeValue(L"value");
4778 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4779 result r = E_FAILURE;
4780 __currentSelectedStr.Clear();
4781 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4783 AppLog("tag name is %ls", tagName.GetPointer());
4784 AppLog("type is %ls", type.GetPointer());
4788 __isLongPressedDone = true;
4789 if( type.Equals(L"submit",false) !=true && type.Equals(L"checkbox",false) !=true && type.Equals(L"range",false) !=true && type.Equals(L"file",false) !=true)
4790 r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4791 if (((tagName.Equals(L"INPUT",false) == true) || tagName.Equals(L"TEXTAREA",false) == true) && innerHtml.GetLength() == 0 && type.Equals(L"submit",false) !=true && type.Equals(L"checkbox",false) !=true && type.Equals(L"range",false) !=true && type.Equals(L"file",false) !=true/*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.Equals(L"",false) == true && r == E_INVALID_ARG)
4793 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4795 InitSelectTextContextMenu(Point(currentPosition.x , currentPosition.y + __pWebViewer->GetY()),true, true);
4798 __pImageMenu->SetShowState(true);
4799 __pImageMenu->Show();
4800 __pImageMenu->Invalidate(true);
4803 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4806 // __inputEventToBeSupressed = true;
4810 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4812 AppLog("xyz:: MainForm::OnTouchReleased called");
4814 if (__pAddressbar && __pAddressbar->GetShowState() == true)
4816 __pAddressbar->SetShowState(false);
4818 if(__pFooterPanel && __isKeypadOpened == false)
4820 __pFooterPanel->SetShowState(true);
4824 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4825 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4827 __pWebViewer->ConsumeInputEvent();
4829 if(pHitElement != null)
4833 __inputEventToBeSupressed = false;*/
4837 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4844 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4846 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4848 __currentSearchStr = L"";
4849 __currentWordIndex = 0;
4850 __maxOccurrances = 0;
4852 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4854 __pFindWordEditField->SetText(L"");
4855 __pFindWordEditField->HideKeypad();
4856 __pFindWordControl->SetShowState(false);
4857 __pFindWordCountLabel->SetText(L"0/0");
4859 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4861 __pFindWordEditFieldRightToLeft->SetText(L"");
4862 __pFindWordEditFieldRightToLeft->HideKeypad();
4863 __pFindWordControl->SetShowState(false);
4864 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4867 __pFindWordNext->SetEnabled(false);
4868 __pFindWordPrev->SetEnabled(false);
4870 __pWebViewer->SearchTextAllAsync(L"",true);
4871 __pFindWordControl->SetShowState(false);
4873 AppLog("__pAddressbar->GetShowState() %d",__pAddressbar->GetShowState());
4874 if(__pAddressbar->GetShowState() == false)
4876 __pAddressbar->SetAddressbarURLFocus();
4877 __pFooterPanel->SetShowState(false);
4884 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4890 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4896 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4902 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4908 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4914 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4916 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4917 int widthContextItem = 0;
4918 if(__pFindWordCountLabel)
4919 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4920 // As per the platform engineer comment removed this line
4921 /*if(__pWebViewer != null)
4923 // 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
4924 __pWebViewer->ReleaseBlock();
4927 // if(__pFindWordControl != null)
4928 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4930 if(__pOptionMenu && __pOptionMenu->GetShowState() == true)
4932 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4934 AppLog(" Orientation landscape");
4935 __pOptionMenu->SetMaxVisibleItemsCount(5);
4939 AppLog(" Orientation potrait");
4940 __pOptionMenu->SetMaxVisibleItemsCount(6);
4943 if(__pNotification && __pNotification->GetShowState() == true)
4945 __pNotification->SetShowState(false);
4946 __pNotification->Invalidate(false);
4948 if ( __pFooterLabel != null)
4950 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4953 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4959 if (__pFindWordBgLabel != null)
4961 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4962 if (pBitmap != null)
4964 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4969 if (__pFindWordBgLabelRightToLeft != null)
4971 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4972 if (pBitmap != null)
4974 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4980 // if(__pOptionMenu != null)
4981 // __pOptionMenu->SetShowState(false);
4983 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4985 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4989 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4994 AppLog("__pFooterPanel->GetShowState() is true");
4996 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4997 __pFooterPanel->Invalidate(true);
5001 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
5002 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
5004 InitMostVisitedSitesView(orientationStatus);
5007 RelayoutControls(false);
5008 if (__pArticleReaderPanel != null)
5010 if (__pArticleReaderPanel->GetShowState() == true)
5012 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
5014 if (__pBlankPanel != null)
5015 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
5017 if (__pWebReader != null)
5019 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
5021 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
5022 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
5024 if ( pBitmap != null && pSrcBitmap != null)
5026 AppLog("CreateReaderPanel ninepatchbitmap found");
5027 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
5030 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
5031 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
5032 if (pBitmap != null)
5037 if (pSrcBitmap != null)
5046 if (__pAddressbar != null)
5048 int width = GetClientAreaBounds().width;
5049 __pAddressbar->OrientationChanged(width);
5054 MainForm::OnSettingsChange(int settingvalue)
5056 AppLogDebug("MainForm::OnSettingsChange entered");
5058 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
5060 __pAddressbar->ResetGuideText();
5062 if (__pWebViewer == null)
5064 AppLogDebug("Webviewer is not initialized yet.");
5068 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
5070 WebSetting settings = __pWebViewer->GetSetting();
5071 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
5073 settings.SetAutoFittingEnabled(true);
5075 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
5077 settings.SetAutoFittingEnabled(false);
5079 __pWebViewer->SetSetting(settings);
5082 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
5084 WebSetting settings = __pWebViewer->GetSetting();
5085 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
5086 __pWebViewer->SetSetting(settings);
5088 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
5090 WebSetting settings = __pWebViewer->GetSetting();
5091 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
5092 __pWebViewer->SetSetting(settings);
5093 __pWebViewer->Reload();
5095 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
5097 WebSetting settings = __pWebViewer->GetSetting();
5098 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
5099 __pWebViewer->SetSetting(settings);
5101 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
5105 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
5108 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
5112 WebSetting settings = __pWebViewer->GetSetting();
5113 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
5114 __pWebViewer->SetSetting(settings);
5117 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
5121 WebSetting settings = __pWebViewer->GetSetting();
5122 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
5123 __pWebViewer->SetSetting(settings);
5126 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
5128 WebSetting settings = __pWebViewer->GetSetting();
5129 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
5131 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
5135 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
5137 __pWebViewer->SetSetting(settings);
5139 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
5143 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
5144 WebSetting settings = __pWebReader->GetSetting();
5145 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
5146 __pWebReader->SetSetting(settings);
5152 MainForm::OnSettingsReset()
5156 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
5157 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
5162 MainForm::OnClearCache()
5164 result r = E_SUCCESS;
5166 if (__pWebViewer != NULL)
5168 r = __pWebViewer->ClearCache();
5171 AppLogDebug("Cache cleared success");
5175 AppLogDebug("Cache cleared fail");
5181 MainForm::OnClearCookie()
5183 result r = E_SUCCESS;
5185 if (__pWebViewer != NULL)
5187 __pWebViewer->ClearCookie();
5191 AppLogDebug("Cookie cleared success");
5195 AppLogDebug("Cache cleared fail");
5200 MainForm::OnClearFormData()
5202 result r = E_SUCCESS;
5204 if (__pWebViewer != NULL)
5206 __pWebViewer->ClearFormData();
5210 AppLogDebug("Cookie cleared success");
5214 AppLogDebug("Cache cleared fail");
5219 MainForm::OnClearPasswords()
5221 result r = E_SUCCESS;
5223 if (__pWebViewer != NULL)
5225 __pWebViewer->ClearLoginFormData();
5229 AppLogDebug("Cookie cleared success");
5233 AppLogDebug("Cache cleared fail");
5239 MainForm::findDistance(int x1,int y1,int x2, int y2)
5241 int deltaX = Math::Abs(x2 - x1);
5242 int deltaY = Math::Abs(y2 - y1);
5243 double num = deltaX*deltaX + deltaY*deltaY;
5249 for (i = 0; i < 20; i++)
5251 x = (((x*x)+ num)/(2*x));
5262 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5264 AppLog("xyz:: MainForm::OnTouchPressed called");
5265 if(__pFindWordControl)
5267 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
5268 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
5270 __isLongPressedDone = false;
5275 IList* pList = null;
5276 pList = touch.GetTouchInfoListN(source);
5280 int count = pList->GetCount();
5283 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5284 __touchPoint1 = pTouchInfo->position;
5286 /*if (__pAddressbar != null)
5288 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5290 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5292 __pAddressbar->SaveAddressbarEditText();
5294 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5297 __pAddressbar->Invalidate(true);
5299 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5301 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5303 //__pAddressbar->SaveAddressbarEditText();
5305 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5308 else if (count == 2)
5310 AppLogDebug("MainForm::OnTouchPressed count is two");
5311 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5312 __touchPoint1 = pTouchInfo->position;
5314 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
5315 __touchPoint2 = pTouchInfo->position;
5320 pList->RemoveAll(true);
5325 __pAddressbar->SetShowState(false);
5327 if(__pFooterPanel && __isKeypadOpened == false)
5329 __pFooterPanel->SetShowState(true);
5331 RelayoutControls(false);
5336 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5338 AppLog("LMN::MainForm::OnTouchMoved entered");
5339 // __currentWordIndex = 0;
5340 __isLongPressedDone = false;
5345 MainForm::MoveUiControls()
5350 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
5352 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
5354 if(__pFooterUrlField->GetTextLength() == 0)
5356 __pFooterUrlField->SetKeypadActionEnabled(false);
5360 __pFooterUrlField->SetKeypadActionEnabled(true);
5363 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
5365 __currentSearchStr = __pFindWordEditField->GetText();
5366 if (__currentSearchStr.GetLength() > 0)
5368 __pFindWordCountLabel->SetShowState(true);
5372 // __pFindWordCountLabel->SetShowState(false);
5373 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
5374 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
5377 __pFindWordNext->SetEnabled(false);
5378 __pFindWordPrev->SetEnabled(false);
5379 __pFindWordNext->Invalidate(true);
5380 __pFindWordPrev->Invalidate(true);
5381 __pFindWordCountLabel->SetText(L"0/0");
5382 __pFindWordCountLabel->Invalidate(true);
5384 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
5386 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
5387 if (__currentSearchStr.GetLength() > 0)
5389 __pFindWordCountLabelRightToLeft->SetShowState(true);
5393 __pFindWordCountLabelRightToLeft->SetShowState(false);
5396 __pFindWordNext->SetEnabled(false);
5397 __pFindWordPrev->SetEnabled(false);
5398 __pFindWordNext->Invalidate(true);
5399 __pFindWordPrev->Invalidate(true);
5400 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
5401 __pFindWordCountLabelRightToLeft->Invalidate(true);
5403 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
5404 if (__currentSearchStr.GetLength() > 0)
5410 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
5412 __currentSearchStr = L"";
5413 AppLogDebug("Enter something");
5418 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
5425 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
5427 if(__pWebViewer != null)
5430 AppLog("MainForm::InitMostVisitedSitesView");
5431 result r = E_SUCCESS;
5434 if (__pMostVisitedListView != null)
5439 if (__pMostVisitedListView != null)
5441 RemoveControl(__pMostVisitedListView);
5443 if(__pMostVisitedSites != null)
5445 __pMostVisitedSites->RemoveAll(true);
5448 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
5450 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
5451 __pMostVisitedListView = new(std::nothrow) ListView();
5453 int height = GetClientAreaBounds().height;
5455 if(__pFooterPanel->GetShowState() == true)
5457 height = height - __pFooterPanel->GetHeight();
5459 if(__pAddressbar->GetShowState() == true)
5461 height -= __pAddressbar->GetHeight();
5464 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
5468 delete __pMostVisitedListView;
5469 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
5472 __pMostVisitedListView->SetItemProvider(*this);
5473 __pMostVisitedListView->AddListViewItemEventListener(*this);
5474 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_VISITED_SITES"));
5475 AddControl(__pMostVisitedListView);
5476 __pMostVisitedListView->UpdateList();
5483 MainForm::GetImagePath(void)
5487 String formattedTime;
5488 DateTime currentTime;
5489 LocaleManager localManager;
5490 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
5492 localManager.Construct();
5493 Locale locale = localManager.GetSystemLocale();
5494 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
5496 // Get date formatter
5497 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
5501 pTimeFormatter->Format(currentTime, formattedTime);
5504 AppLog("current time stamp is %ls", formattedTime.GetPointer());
5505 String delim(L" :");
5506 StringTokenizer strTok(formattedTime, delim);
5509 String str1("GMT+00");
5510 while (strTok.HasMoreTokens())
5512 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
5513 if(token.Equals(str1))
5515 AppLog("token is %ls", token.GetPointer());
5516 imageName.Append(token);
5522 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
5524 result r = E_FAILURE;
5525 AppLog("Content manager 1");
5526 ContentId contentId;
5527 ContentManager contentManager;
5528 r = contentManager.Construct();
5531 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
5534 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
5535 Tizen::Io::Directory::Create(contentPath,true);
5536 if(GetLastResult() == E_FILE_ALREADY_EXIST)
5538 AppLog("Already exists");
5540 else if(GetLastResult() == E_SUCCESS)
5542 AppLog("created success");
5544 contentPath.Append(imageName);
5545 contentPath.Append(".jpg");
5546 contentId = contentManager.CreateContent(*aBuffer, contentPath);
5547 ShowIndicatorNotification(L"Download Complete",contentPath);
5548 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5552 MainForm::ShowIndicatorNotification(const String& messageText, const String& contentPath)
5554 AppLogDebug("ENTER");
5556 NotificationRequest request;
5557 request.SetAlertText(messageText);
5558 request.SetTitleText(L"");
5559 request.SetAppMessage(contentPath);
5560 request.SetOngoingActivityType(ONGOING_ACTIVITY_TYPE_TEXT);
5561 request.SetNotificationStyle(NOTIFICATION_STYLE_THUMBNAIL);
5562 Tizen::App::App* pApp = Tizen::App::App::GetInstance();
5563 String homePath = pApp->GetAppRootPath();
5564 String iconPath = homePath + L"res/screen-density-xhigh/Notification_download_complete.png";
5565 AppLog("The iconPath is : %ls", homePath.GetPointer());
5566 request.SetIconFilePath(iconPath);
5568 Tizen::Shell::NotificationManager notiMgr;
5569 notiMgr.Construct();
5570 notiMgr.NotifyOngoingActivity(request);
5571 AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));
5576 MainForm::SetForwardButtonEnabled(bool isEnabled)
5578 __pGoForwardBtn->SetEnabled(isEnabled);
5579 __pGoForwardBtn->Invalidate(true);
5583 MainForm::SetBackButtonEnabled(bool isEnabled)
5585 __pGoBackBtn->SetEnabled(isEnabled);
5586 __pGoBackBtn->Invalidate(true);
5590 MainForm::UpdateProgress(int percentage)
5592 __progressPercentage = percentage;
5593 if (percentage == 0 || percentage == 100)
5595 __isLoadingData = false;
5596 if (percentage == 100)
5598 __isLoadingCompleted = true;
5599 __progressPercentage = 0;
5603 __isLoadingCompleted = false;
5608 __isLoadingData = true;
5610 UpdateProgressBitmap();
5614 MainForm::GetProgress(void)
5616 return __progressPercentage;
5620 MainForm::UpdateProgressBitmap(void)
5622 result r = E_SUCCESS;
5623 if (__pProgressbarLabel == null)
5625 int w = __pProgressbarLabel->GetWidth();
5626 int h = __pProgressbarLabel->GetHeight();
5628 int progressWidth = 0;
5629 Bitmap* pRetBitmap = null;
5631 if (__progressPercentage == 0 || __progressPercentage == 100)
5633 __pProgressbarLabel->SetShowState(false);
5634 __pProgressbarLabel->Invalidate(false);
5639 __pProgressbarLabel->SetShowState(true);
5640 __pProgressbarLabel->Invalidate(false);
5643 r = canvas.Construct(Rectangle(0, 0, w, h));
5647 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5652 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5656 pBgBmp->Scale(Dimension(w, h));
5657 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5661 progressWidth = (double) (w) * __progressPercentage / 100;
5662 AppLogDebug("progressWidth: %d", progressWidth);
5663 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5665 if (pProgressBmp != null)
5667 pProgressBmp->Scale(Dimension(progressWidth, h));
5668 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5669 delete pProgressBmp;
5672 pRetBitmap = new (std::nothrow) Bitmap();
5674 if (pRetBitmap == null)
5676 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5680 pRetBitmap->Construct(canvas, canvas.GetBounds());
5682 if (__pProgressbarLabel != null && pRetBitmap != null)
5684 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5685 __pProgressbarLabel->Invalidate(false);
5688 if (pRetBitmap != null)
5697 MainForm::ReaderClicked()
5699 result r = E_SUCCESS;
5700 ArrayList* pArgList = new(std::nothrow) ArrayList();
5701 if (pArgList != null)
5703 r = pArgList->Construct();
5710 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5717 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5724 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5732 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5738 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5740 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5742 __currentAddMode = addMode;
5746 case ADDRESSBAR_MODE_INVALID:
5751 case ADDRESSBAR_MODE_READER:
5753 __pStopBtn->SetShowState(false);
5754 __pRefreshBtn->SetShowState(false);
5755 __pClearBtn->SetShowState(false);
5756 __pReaderBtn->SetShowState(false);
5759 case ADDRESSBAR_MODE_LOADING:
5761 __pRefreshBtn->SetShowState(false);
5762 __pStopBtn->SetShowState(true);
5763 __pClearBtn->SetShowState(false);
5764 __pReaderBtn->SetShowState(false);
5767 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5769 // SetUrl(__pAddressbar->GetUrl());
5771 __pRefreshBtn->SetShowState(true);
5772 __pStopBtn->SetShowState(false);
5773 __pClearBtn->SetShowState(false);
5774 __pReaderBtn->SetShowState(false);
5777 case ADDRESSBAR_MODE_EDIT:
5779 __pRefreshBtn->SetShowState(false);
5780 __pStopBtn->SetShowState(false);
5781 __pReaderBtn->SetShowState(false);
5782 __pClearBtn->SetShowState(true);
5789 OnAddressBarModeChanged();
5792 AddressBarMode MainForm::GetAddressbarMode(void)
5794 return __currentAddMode;
5797 void MainForm::SetUrl(const String& url)
5800 if(__displayUrl.GetLength() > 2048)
5801 __displayUrl.SubString(0,2048,__displayUrl);
5803 if (__pFooterUrlField != NULL)
5805 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5806 if (removedHttpUrl.IsEmpty() == false)
5808 __pFooterUrlField->SetText(removedHttpUrl);
5809 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5810 __pAddressbar->SetUrl(__displayUrl);
5814 __pFooterUrlField->SetText(__displayUrl);
5815 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5816 __pAddressbar->SetUrl(__displayUrl);
5818 if(__pFooterUrlField)
5819 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5820 __pFooterUrlField->Invalidate(false);
5821 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5822 __pAddressbar->Invalidate(true);
5823 // __pFooterUrlField->SetCursorPosition(0);
5828 MainForm::RemoveHttpTextFromDisplayURL(void)
5830 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5832 // bool isHttpText = __displayUrl.Contains(L"http://");
5833 String updatedDisplayUrl;
5834 updatedDisplayUrl.Clear();
5835 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5837 __displayUrl.SubString(7,updatedDisplayUrl);
5839 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5841 __displayUrl.SubString(8,updatedDisplayUrl);
5843 return updatedDisplayUrl;
5846 void MainForm::OnSharePopupControlStarted(void)
5848 __pWebViewer->AddTouchEventListener(*this);
5852 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5854 if (requestId == UPDATE_MAINFORM_FOOTER_ON_WINDOWCLOSED)
5856 AppLog("OnWebWindowCloseRequested mainform test 1 OnUserEventReceivedN");
5859 else if (requestId == BACK_GROUND_APP_EVENT)
5861 if(__pWebViewer != null)
5863 __pWebViewer->Pause();
5867 __pImageMenu->SetShowState(false);
5869 if(__pAddressbar != null)
5871 __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5874 else if(requestId == FORE_GROUND_APP_EVENT)
5876 if(__pWebViewer != null)
5878 __pWebViewer->Resume();
5880 if(__pAddressbar != null)
5882 __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5888 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5890 AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5891 result r = E_SUCCESS;
5894 __pAddressbar->SetShowState(false);
5896 AppLog("akjshdasd 5");
5897 __pFooterPanel->SetShowState(true);
5900 __pWebViewer->SetFocus();
5901 else if(__pMostVisitedListView)
5902 __pMostVisitedListView->SetFocus();
5903 else if(__pMultiWindowButton)
5904 __pMultiWindowButton->SetFocus();
5905 else if(__pMoreButton)
5906 __pMoreButton->SetFocus();
5908 __pAddressbar->SetShowState(false);
5910 RelayoutControls(false);
5914 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5916 AppLog("MainForm::OnFormMenuRequested called");
5918 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer && __pWebViewer->GetShowState() == true)
5920 int bookmarkCount=0;
5923 url=__pWindowInfo->pageUrl;
5924 AppLog("MainForm::OnFormMenuRequested url %ls",url.GetPointer());
5925 result r = E_SUCCESS;
5926 Bitmap* pBitmap = null;
5927 String lastChar = L"";
5928 // if(url.SubString(url.GetLength()-1,lastChar));
5929 // if(lastChar == L"/")
5931 // bool exist1 = false;
5932 // bool exist2 = false;
5933 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist1);
5934 // url.SubString(0,url.GetLength() - 1,url);
5935 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist2);
5936 // exist = exist1 | exist2;
5940 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5943 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5949 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5953 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5955 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5957 if (__pOptionMenu->GetItemCount() == 9)
5959 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5963 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5968 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
5972 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
5973 if (__pOptionMenu->GetItemCount() != 9)
5975 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
5976 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
5977 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
5978 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
5979 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
5980 __pOptionMenu->SetMaxVisibleItemsCount(6);
5982 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
5984 AppLog(" Orientation landscape");
5985 __pOptionMenu->SetMaxVisibleItemsCount(5);
5989 AppLog(" Orientation potrait");
5990 __pOptionMenu->SetMaxVisibleItemsCount(6);
5993 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
5996 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
5998 __pAddressbar->SetShowState(false);
6000 __pFooterPanel->SetShowState(true);
6001 result r = __pOptionMenu->SetShowState(true);
6002 AppLog("ajsghd %s",GetErrorMessage(r));
6003 RelayoutControls(false);
6004 __pOptionMenu->Invalidate(true);
6005 __pOptionMenu->Show();