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 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
481 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
488 r = AddControl(__pWebViewer);
491 __pWebViewer->Destroy();
493 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
496 __webControlPosition = __pWebViewer->GetPosition();
497 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
500 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
504 __pWebViewer->SetLoadingListener(this);
505 __pWebViewer->SetWebUiEventListenerF(this);
506 __pWebViewer->SetWebKeypadEventListener(this);
507 __pWebViewer->SetFocus();
508 __pWebViewer->AddTouchEventListener(*this);
510 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
511 __pWebViewer->SetTextSearchListener(this);
514 AppLogDebug("MainForm :before return");
516 AppLogDebug("MainForm::InitWebControl Exit");
522 MainForm::SetJavascriptEnabled()
524 WebSetting settings = __pWebViewer->GetSetting();
525 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
526 __pWebViewer->SetSetting(settings);
530 MainForm::SetImageLoadEnabled()
532 WebSetting settings = __pWebViewer->GetSetting();
533 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
534 __pWebViewer->SetSetting(settings);
538 MainForm::InitFooter(void)
540 AppLogDebug("MainForm::InitFooter entered");
541 Button* pBackButton = null;
542 Button* pBookmarkButton = null;
543 Button* pMultiWindowButton = null;
544 Bitmap *pIconBitmap = null;
545 Bitmap *pBGBitmap = null;
546 Label *pBGLabel = null;
548 if (__pFooterPanel == null)
550 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
553 if (__pFooterPanel == null)
558 SetControlAlwaysOnTop(*__pFooterPanel, true);
560 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
561 if ( __pFooterLabel == NULL )
565 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
566 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
569 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
573 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
575 if ( __pMultiWindowButton == NULL )
581 SetFormBackEventListener(this);
582 AppLog("SetFormBackEventListener result %s",GetErrorMessage(GetLastResult()));
583 if (__pMultiWindowButton != null)
585 Bitmap* pBitmap = null;
586 Bitmap* pPressedBitmap = null;
587 String imagePath = "I01_toolbar_icon_windows_manager_0";
588 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
589 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
590 imagePath.Append(totalCount);
591 imagePath.Append(".png");
593 pressedImagePath.Append(totalCount);
594 pressedImagePath.Append("_press.png");
596 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
597 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
598 if ( pBitmap == null )
603 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
606 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
607 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
612 __pMultiWindowButton->AddActionEventListener(*this);
613 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
616 delete pPressedBitmap;
617 pPressedBitmap = null;
623 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
624 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
627 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
628 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
629 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
633 __pMoreButton->AddActionEventListener(*this);
634 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
637 //Add the editfield for url
638 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
639 if (__pFooterUrlField == NULL)
641 return E_INVALID_KEY;
644 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
645 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
646 __pFooterUrlField->AddKeypadEventListener(*this);
647 __pFooterUrlField->SetPropagatedTouchEventListener(this);
648 __pFooterUrlField->AddFocusEventListener(*this);
650 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
652 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
654 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
656 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_BLANK_PAGE"));
660 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
661 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
665 //Add the go Back Button
666 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
667 if (__pGoBackBtn == NULL)
669 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
670 return E_INVALID_KEY;
672 __pGoBackBtn->SetActionId(IDA_GO_BACK);
673 __pGoBackBtn->AddActionEventListener(*this);
675 //Add the go forward Button
676 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
677 if (__pGoForwardBtn == NULL)
679 AppLogDebug("Control not found returning E_INVALID_KEY");
680 return E_INVALID_KEY;
682 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
683 __pGoForwardBtn->AddActionEventListener(*this);
684 if (__pWebViewer && __pWebViewer->CanGoForward())
686 SetForwardButtonEnabled(true);
690 SetForwardButtonEnabled(false);
693 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
694 if (__pRefreshBtn == NULL)
696 AppLogDebug("Control not found returning E_INVALID_KEY");
697 return E_INVALID_KEY;
700 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
701 __pRefreshBtn->AddActionEventListener(*this);
702 __pRefreshBtn->SetShowState(true);
704 //Add the backround label for displaying progressbar
705 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
706 if (__pProgressbarLabel == NULL)
708 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
709 return E_INVALID_KEY;
711 __pProgressbarLabel->SetShowState(false);
713 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
714 if (__pStopBtn == NULL)
716 AppLogDebug("Control not found returning E_INVALID_KEY");
717 return E_INVALID_KEY;
719 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
720 __pStopBtn->AddActionEventListener(*this);
721 __pStopBtn->SetShowState(false);
723 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
724 if (__pClearBtn == NULL)
726 AppLogDebug("Control not found returning E_INVALID_KEY");
727 return E_INVALID_KEY;
729 __pClearBtn->SetActionId(IDA_CLEAR_URL);
730 __pClearBtn->AddActionEventListener(*this);
731 __pClearBtn->SetShowState(false);
733 __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
734 if (__pReaderBtn == NULL)
736 AppLogDebug("Control not found returning E_INVALID_KEY");
737 return E_INVALID_KEY;
739 __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
740 __pReaderBtn->AddActionEventListener(*this);
741 __pReaderBtn->SetShowState(false);
743 // __pFooterPanel->Invalidate(true);
744 if(__isKeypadOpened == false && __pAddressbar && __pAddressbar->GetShowState() == false)
746 // AppLog("asdasdasdasda");
747 __pFooterPanel->SetShowState(true);
749 else if(__pAddressbar == null)
751 __pFooterPanel->SetShowState(true);
754 __pFooterPanel->SetShowState(false);
756 SetAddressbarMode(GetAddressbarMode());
757 AppLogDebug("MainForm::InitFooter exit");
762 MainForm::InitOptionMenu()
764 result r = E_SUCCESS;
765 bool isPrivateBrowsing = false;
766 Bitmap* pBitmap = null;
768 if (__pOptionMenu != null)
770 __pOptionMenu->SetFocusable(true);
771 __pOptionMenu->Invalidate(true);
775 __pOptionMenu = new(std::nothrow) OptionMenu();
776 r = __pOptionMenu->Construct();
777 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
779 __pOptionMenu->SetFocusable(true);
780 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
783 if (isPrivateBrowsing == true)
785 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
789 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
792 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
794 if ( pBitmap != NULL)
796 __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
799 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
800 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
801 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
804 __pOptionMenu->SetMaxVisibleItemsCount(6);
805 __pOptionMenu->SetShowState(false);
806 __pOptionMenu->AddActionEventListener(*this);
807 SetControlAlwaysOnTop(*__pOptionMenu, true);
813 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
815 result r = E_SUCCESS;
816 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
818 AppLog("MainForm::InitImageContextMenu clicked on image");
819 if (__pImageMenu != null)
824 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
829 __pImageMenu = new (std::nothrow) ContextMenu();
830 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
831 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
833 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
834 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
835 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
836 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
837 __pImageMenu->SetMaxVisibleItemsCount(4);
838 __pImageMenu->AddActionEventListener(*this);
839 SetControlAlwaysOnTop(*__pImageMenu, true);
840 __pImageMenu->SetFocusable(true);
846 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
848 result r = E_SUCCESS;
849 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
851 AppLog("MainForm::InitImageContextMenu clicked on image");
852 if (__pImageMenu != null)
858 // if(__pAddressbar->GetShowState() == true)
859 // p.y = p.y + __pAddressbar->GetHeight();
860 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
865 __pImageMenu = new (std::nothrow) ContextMenu();
866 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
867 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
869 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_OPEN_IN_NEW_WINDOW"),IDA_HYPERLINK_OPEN_CLICKED);
870 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_LINK_URL"),IDA_HYPERLINK_COPY_LINK_CLICKED);
871 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
872 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
874 __pImageMenu->SetMaxVisibleItemsCount(3);
875 __pImageMenu->AddActionEventListener(*this);
876 SetControlAlwaysOnTop(*__pImageMenu, true);
877 __pImageMenu->SetFocusable(true);
884 MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOption = false)
886 result r = E_SUCCESS;
887 bool clipboardAvailable = true;
888 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
890 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
891 if (__pImageMenu != null)
897 // __pWebViewer->GetBlockRange(p,q);
902 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
906 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
910 Clipboard* pClipboard = Clipboard::GetInstance();
912 if(pClipboard == null)
914 clipboardAvailable = false;
918 // Retrieves a latest item
919 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
923 clipboardAvailable = false;
927 //Gets data from the clipboard item
928 String* pString = dynamic_cast<String*>(pItem->GetData());
932 clipboardAvailable = false;
936 if(clipboardAvailable == false && onlyPasteOption == true)
941 __pImageMenu = new (std::nothrow) ContextMenu();
942 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
943 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
945 if(onlyPasteOption == false)
947 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
949 if ((pasteOption || onlyPasteOption) && clipboardAvailable == true)
951 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
953 if(onlyPasteOption == false)
955 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
956 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
959 __pImageMenu->SetMaxVisibleItemsCount(3);
960 __pImageMenu->AddActionEventListener(*this);
961 SetControlAlwaysOnTop(*__pImageMenu, true);
962 __pImageMenu->SetFocusable(true);
969 MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPasteOption = false)
971 result r = E_SUCCESS;
972 bool clipboardAvailable = true;
973 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
975 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
976 if (__pImageMenu != null)
981 // FloatPoint q(0.0,0.0);
982 // __pWebViewer->GetBlockRange(p,q);
986 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
988 else if(__pWebViewer != null && (p.y > (__pWebViewer->GetHeight() + __pWebViewer->GetY())))
990 p.y = __pWebViewer->GetHeight() + __pWebViewer->GetY();
994 if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE )
996 AppLog("asdasdafdsfdgfd");
999 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
1003 Clipboard* pClipboard = Clipboard::GetInstance();
1005 if(pClipboard == null)
1007 clipboardAvailable = false;
1011 // Retrieves a latest item
1012 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
1016 clipboardAvailable = false;
1020 //Gets data from the clipboard item
1021 String* pString = dynamic_cast<String*>(pItem->GetData());
1025 clipboardAvailable = false;
1029 if(clipboardAvailable == false && onlyPasteOption == true)
1033 __pImageMenu = new (std::nothrow) ContextMenu();
1034 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
1035 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
1041 if(onlyPasteOption == false)
1043 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
1045 if ((pasteOption || onlyPasteOption) && clipboardAvailable == true)
1047 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
1049 if(onlyPasteOption == false)
1051 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
1052 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
1055 __pImageMenu->SetMaxVisibleItemsCount(3);
1056 __pImageMenu->AddActionEventListener(*this);
1057 SetControlAlwaysOnTop(*__pImageMenu, true);
1058 __pImageMenu->SetFocusable(true);
1065 MainForm::InitFindWordPanel(void)
1067 result r = E_SUCCESS;
1068 Bitmap *pIconBitmap = null;
1070 if (__pFindWordControl != null)
1072 AppLogDebug("Findword panel already initialized");
1073 if (__pFindWordBgLabel != null)
1075 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1076 if (pBitmap != null)
1078 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1082 if (__pFindWordBgLabelRightToLeft != null)
1084 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
1085 if (pBitmap != null)
1087 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1092 __pAddressbar->SetShowState(false);
1094 if(__isKeypadOpened == false)
1095 __pFooterPanel->SetShowState(true);
1099 __pFindWordControl = new (std::nothrow) Panel();
1100 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
1103 AppLogException("There is some problem in the xml file. Please check.");
1106 AddControl(__pFindWordControl);
1107 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
1108 SetControlAlwaysOnTop(*__pFindWordControl,true);
1109 __pFindWordControl->SetShowState(false);
1110 __pFindWordControl->Invalidate(false);
1112 __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1113 __pFindWordPanelLeftToRight->SetShowState(true);
1115 __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
1116 __pFindWordPanelRightToLeft->SetShowState(false);
1118 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
1119 if (__pFindWordBgLabel != null)
1121 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1122 Rectangle pRect = pPanel1->GetBounds();
1123 pRect.x = pRect.y = 0;
1124 __pFindWordBgLabel->SetBounds(pRect);
1125 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1126 if (pBitmap != null)
1128 AppLogDebug("InitFindWordPanel: Coming here");
1129 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1134 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1138 __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
1139 if (__pFindWordBgLabelRightToLeft != null)
1141 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1142 Rectangle pRect = pPanel1->GetBounds();
1143 pRect.x = pRect.y = 0;
1144 __pFindWordBgLabelRightToLeft->SetBounds(pRect);
1145 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1146 if (pBitmap != null)
1148 AppLogDebug("InitFindWordPanel: Coming here");
1149 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1154 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1158 Button* pfindWordCancel = null;
1159 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1160 if (pfindWordCancel == null)
1162 AppLogException("There is some problem in the xml file. Please check.");
1165 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1166 pfindWordCancel->AddActionEventListener(*this);
1168 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1169 if (__pFindWordClear == null)
1171 AppLogException("There is some problem in the xml file. Please check.");
1175 __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1176 if (__pFindWordClearRightToLeft == null)
1178 AppLogException("There is some problem in the xml file. Please check.");
1182 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1183 __pFindWordClear->AddActionEventListener(*this);
1185 __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1186 __pFindWordClearRightToLeft->AddActionEventListener(*this);
1188 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1189 if (__pFindWordNext == null)
1191 AppLogException("There is some problem in the xml file. Please check.");
1195 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1196 __pFindWordNext->AddActionEventListener(*this);
1198 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1199 if (__pFindWordPrev == null)
1201 AppLogException("There is some problem in the xml file. Please check.");
1205 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1206 __pFindWordPrev->AddActionEventListener(*this);
1208 __pFindWordNext->SetEnabled(false);
1209 __pFindWordPrev->SetEnabled(false);
1211 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1212 if (__pFindWordCountLabel == null)
1214 AppLogException("There is some problem in the xml file. Please check.");
1218 __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1219 if (__pFindWordCountLabelRightToLeft == null)
1221 AppLogException("There is some problem in the xml file. Please check.");
1225 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1226 if (__pFindWordEditField == null)
1228 AppLogException("There is some problem in the xml file. Please check.");
1231 __pFindWordEditField->AddTextEventListener(*this);
1232 __pFindWordEditField->AddKeypadEventListener(*this);
1233 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1234 __pFindWordEditField->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1236 __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1237 if (__pFindWordEditFieldRightToLeft == null)
1239 AppLogException("There is some problem in the xml file. Please check.");
1242 __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1243 __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1244 __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1245 __pFindWordEditFieldRightToLeft->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1248 __pAddressbar->SetShowState(false);
1250 if(__isKeypadOpened == false)
1251 __pFooterPanel->SetShowState(true);
1256 MainForm::CreateItem (int index, int itemWidth)
1258 Rectangle listImageRect;
1259 Rectangle pagetTitleRect;
1260 Rectangle pageURLRect;
1261 Rectangle deleteImageRect;
1262 String pageTitle(L"");
1263 String pageURL(L"");
1264 result r = E_SUCCESS;
1265 Bitmap* pListIconImage = null;
1268 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1269 if(pHistory == null)
1273 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1274 if ( pAppResource == NULL )
1278 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1280 CustomItem* pItem = new(std::nothrow) CustomItem();
1281 pageTitle = pHistory->GetHistoryTitle();
1282 pageURL = pHistory->GetHistoryUrl();
1284 if (pageURL.GetLength() == 0)
1287 pAppResource->GetString(L"IDS_BR_BODY_BLANK_PAGE", nourl);
1288 pageURL = L"<"+ nourl +">";
1292 Rectangle screenBounds = GetBounds();
1295 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1304 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1306 if ( pBitmap != NULL)
1308 pListIconImage = new Bitmap();
1309 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1313 if(pListIconImage == null)
1315 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1318 if ( pListIconImage != NULL)
1320 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2 , 72, 72);
1321 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 72 + (__fontSize - 44));
1322 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1325 if (pItem != null && pListIconImage != NULL)
1327 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1331 if (pageTitle.CompareTo(L"") != 0)
1335 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1339 if (pageURL.CompareTo(L"") != 0)
1343 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_LISTVIEW_TEXT, CUSTOM_COLOR_LISTVIEW_TEXT, true);
1348 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1350 if ( __pItemContext!= NULL)
1354 pItem->SetContextItem(__pItemContext);
1360 if ( __pItemContextLandscape!= NULL)
1364 pItem->SetContextItem(__pItemContextLandscape);
1368 if( pListIconImage != NULL)
1370 delete pListIconImage;
1371 pListIconImage = null;
1378 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1385 MainForm::GetItemCount (void)
1387 if(__pMostVisitedSites != null)
1389 __pMostVisitedSites->RemoveAll(true);
1391 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1392 if(__pMostVisitedSites != null)
1394 return __pMostVisitedSites->GetCount();
1401 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1403 AppLog("MainForm::OnListViewContextItemStateChanged called");
1404 if(__pMostVisitedSites != null)
1406 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1407 if (pHistory != null)
1409 String url = pHistory->GetHistoryUrl();
1411 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1412 __pMostVisitedListView->UpdateList();
1418 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1420 AppLog("MainForm::OnListViewItemStateChanged called");
1421 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1422 String url = pHistory->GetHistoryUrl();
1430 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1436 MainForm::OnTerminating(void)
1438 result r = E_SUCCESS;
1440 RemoveOrientationEventListener(*this);
1444 __pAddressbar->SetAddressbarEventListener(null);
1449 __pWebViewer->RemoveTouchEventListener(*this);
1450 __pWebViewer->SetWebUiEventListenerF(null);
1451 __pWebViewer->SetWebKeypadEventListener(null);
1452 __pWebViewer->SetTextSearchListener(null);
1458 delete __pItemContext;
1460 if (__pItemContextLandscape)
1462 delete __pItemContextLandscape;
1466 delete __pSaveImage;
1468 if (__pMostVisitedSites)
1470 __pMostVisitedSites->RemoveAll(true);
1471 delete __pMostVisitedSites;
1477 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1479 result r = E_SUCCESS;
1481 AppLogDebug("Clicked : %d", actionId);
1484 case IDA_BACKBTN_CLICKED:
1486 if(__pImageMenu && __pImageMenu->GetShowState() == true)
1488 AppLog("Hiding the menu");
1489 __pImageMenu->SetShowState(false);
1491 if (__pWebViewer && __pWebViewer->CanGoBack())
1493 __pWebViewer->GoBack();
1495 else if(__pWindowInfo->isJavascriptInitiated == false)
1498 pApp = UiApp::GetInstance();
1501 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1504 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1512 WindowInfo* pWindowInfo = null;
1514 SceneManager* pSceneManager = SceneManager::GetInstance();
1515 if (pSceneManager == null)
1519 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1520 if (pAllWindowList == NULL)
1522 pApp = UiApp::GetInstance();
1525 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1528 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1533 if (pAllWindowList != null)
1535 totalCount = pAllWindowList->GetCount();
1537 for (int count = 0; count < totalCount; count++)
1539 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1540 if (pWindowInfo == null)
1542 pApp = UiApp::GetInstance();
1545 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1548 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1555 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1557 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1560 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1563 r = pAllWindowList->RemoveAt(count, true);
1564 __pWindowInfo = null;
1567 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1572 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1576 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1578 if (pWindowInfo == null)
1580 pApp = UiApp::GetInstance();
1583 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1589 r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
1590 // r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1593 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1605 case IDA_FORWARD_CLICKED:
1606 if (__pWebViewer == null)
1609 if (__pWebViewer->CanGoForward())
1611 __pWebViewer->GoForward();
1613 __pOptionMenu->SetShowState(false);
1614 __pOptionMenu->Invalidate(false);
1617 case IDA_FINDONPAGE_CLICKED:
1619 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1620 __currentSearchStr.Clear();
1622 InitFindWordPanel();
1623 __pOptionMenu->SetShowState(false);
1624 __pOptionMenu->Invalidate(false);
1626 ShowFindWordPanel(true);
1628 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1630 __pFindWordEditField->SetFocus();
1631 // __pFindWordCountLabel->SetShowState(false);
1635 __pFindWordEditFieldRightToLeft->SetFocus();
1636 __pFindWordCountLabelRightToLeft->SetShowState(false);
1640 case IDA_PRIVATEON_CLICKED:
1642 result r = E_SUCCESS;
1644 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1645 Bitmap* pBitmap = null;
1646 if (isPrivateBrowsing == true)
1648 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1651 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1655 if (__pWebViewer != NULL)
1657 __pWebViewer->SetPrivateBrowsingEnabled(false);
1660 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1662 if (__pAddressbar != null)
1664 __pAddressbar->UpdateFaviconBitmap(false);
1670 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1673 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1677 if (__pWebViewer != NULL)
1679 __pWebViewer->SetPrivateBrowsingEnabled(true);
1682 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1684 if (__pAddressbar != null)
1686 __pAddressbar->UpdateFaviconBitmap(true);
1690 itemIndex = __pOptionMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1691 r = __pOptionMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1692 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1693 __pOptionMenu->Invalidate(true);
1694 if ( pBitmap != NULL )
1701 case IDA_SETTINGS_CLICKED:
1704 ArrayList* pArgList = new(std::nothrow) ArrayList();
1707 pArgList->Construct();
1708 pArgList->Add(*__pWindowInfo);
1709 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1711 __pOptionMenu->SetShowState(false);
1712 __pOptionMenu->Invalidate(false);
1714 if (pArgList != null)
1723 case IDA_ADDTOBOOKMARK_CLICKED:
1726 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1728 int bookmarkCount=0;
1731 url=__pWindowInfo->pageUrl;
1732 result r = E_SUCCESS;
1733 Bitmap* pBitmap = null;
1734 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1742 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1743 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1744 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1746 if(__pNotification != null)
1748 RemoveControl(__pNotification);
1749 __pNotification = null;
1751 __pNotification = new (std::nothrow) NotificationPanel(*this);
1752 if (__pNotification != null)
1754 __pNotification->SetText(message);
1755 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1756 __pNotification->ShowNotification();
1761 String title=__pWindowInfo->pageTitle;
1762 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1763 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1765 pBookmark->SetBookmarkTitle(title);
1766 pBookmark->SetUrl(url);
1767 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1769 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1771 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1772 pBookmark->SetFaviconId(id);
1773 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1774 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1776 if(__pNotification != null)
1778 RemoveControl(__pNotification);
1779 __pNotification = null;
1781 __pNotification = new (std::nothrow) NotificationPanel(*this);
1782 if (__pNotification != null)
1784 __pNotification->SetText(message);
1785 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1786 __pNotification->ShowNotification();
1787 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1790 if (pBitmap != null)
1792 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1797 __pOptionMenu->Invalidate(true);
1802 case IDA_PRINT_CLICKED:
1804 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//shared//data//test.pdf");
1805 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1807 AppLog("RequestPrint called!");
1808 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1809 result nResult = E_FAILURE;
1812 AppLog("TestPrint if (pAc) == true");
1817 String fileType = L"service_print_files_type";
1818 String typeVal = L"DOC";
1820 String fileCount = L"service_print_files_count";
1821 String countVal = L"1";
1822 String fileFolder= L"service_print_files_folder_name";
1823 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//shared//data";
1825 map.Add(&fileCount, &countVal);
1826 map.Add(&fileFolder, &folderVal);
1827 map.Add(&fileType, &typeVal);
1829 String fileName = L"service_print_files_files_name";
1831 ArrayList fileNameList;
1832 fileNameList.Construct();
1833 String file1 = L"test.pdf";
1835 fileNameList.Add(&file1);
1836 map.Add(&fileName, &fileNameList);
1838 nResult = pAc->Start(NULL, NULL, &map, NULL);
1840 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1841 else if (nResult == E_MAX_EXCEEDED)
1842 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1843 else if (nResult == E_OBJ_NOT_FOUND)
1844 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1845 else if (nResult == E_IN_PROGRESS)
1846 AppLog("TestPrint ret == E_IN_PROGRESS");
1847 else if (nResult == E_PRIVILEGE_DENIED)
1848 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1849 else if(nResult == E_SYSTEM)
1850 AppLog("TestPrint ret == E_SYSTEM");
1856 int __modalMsgBoxResult;
1857 MessageBox* pMsgBox = new MessageBox();
1858 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1859 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1862 __modalMsgBoxResult = 0;
1866 case IDA_SHARE_CLICKED:
1868 if(__pPopUp != null)
1875 __pAddressbar->HideKeypad();
1877 __pPopUp = new(std::nothrow) SharePopup();
1878 __pPopUp->Initialize();
1879 if (__pWindowInfo != null)
1881 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1882 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1883 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1884 pShareInfo->SetImageAttached(false);
1885 __pPopUp->RemoveAllShareInfo();
1886 __pPopUp->AddShareInfo(pShareInfo);
1888 __pPopUp->SetShowState(true);
1892 case IDA_BOOKMARKBTN_CLICKED:
1894 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1895 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1898 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1903 case IDA_MOREBTN_CLICKED:
1905 AppLog("IDA_MOREBTN_CLICKED");
1907 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1909 int bookmarkCount=0;
1912 url=__pWindowInfo->pageUrl;
1913 result r = E_SUCCESS;
1914 Bitmap* pBitmap = null;
1916 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1919 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1924 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1928 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1930 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1932 if (__pOptionMenu->GetItemCount() == 9)
1934 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1938 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1943 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1947 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1948 if (__pOptionMenu->GetItemCount() != 9)
1950 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1951 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1952 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1953 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1954 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1955 __pOptionMenu->SetMaxVisibleItemsCount(6);
1957 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
1959 AppLog(" Orientation landscape");
1960 __pOptionMenu->SetMaxVisibleItemsCount(5);
1964 AppLog(" Orientation potrait");
1965 __pOptionMenu->SetMaxVisibleItemsCount(6);
1968 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1971 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1972 __pOptionMenu->SetShowState(true);
1973 __pOptionMenu->Invalidate(true);
1974 __pOptionMenu->Show();
1978 case IDA_HISTORY_CLICKED:
1980 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1981 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1984 case IDA_SAVED_PAGES_CLICKED:
1989 case IDA_DESKTOP_VIEW_CLICKED:
1994 case IDA_SAVE_CLICKED:
1999 case IDA_MULTIWINDOWBTN_CLICKED:
2001 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2002 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
2006 case IDA_NEWWINDOWBTN_CLICKED:
2008 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
2010 if (pNewWindowInfo == null)
2014 result r = E_SUCCESS;
2015 SceneManager* pSceneManager = SceneManager::GetInstance();
2017 if (pSceneManager == NULL)
2021 ArrayList* pArgList = new(std::nothrow) ArrayList();
2022 if (pArgList == NULL)
2026 r = pArgList->Construct();
2029 pArgList->Add(*pNewWindowInfo);
2030 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2036 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
2041 case IDA_SMALLFONT_BTN_CLICKED:
2043 WebSetting setting = __pWebReader->GetSetting();
2044 setting.SetFontSize(15);
2045 __pWebReader->SetSetting(setting);
2048 case IDA_LARGEFONT_BTN_CLICKED:
2050 WebSetting setting = __pWebReader->GetSetting();
2051 setting.SetFontSize(25);
2052 __pWebReader->SetSetting(setting);
2055 case IDA_READER_CLOSE_CLICKED:
2057 if (__pArticleReaderPanel != null && __pBlankPanel != null)
2059 RemoveControl(__pBlankPanel);
2060 __pArticleReaderPanel = null;
2061 __pBlankPanel = null;
2062 __pArticleReaderLabel = null;
2064 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2067 case IDA_FINDWORD_CANCEL_CLICKED:
2069 __currentSearchStr = L"";
2070 __currentWordIndex = 0;
2071 __maxOccurrances = 0;
2073 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2075 __pFindWordEditField->SetText(L"");
2076 __pFindWordCountLabel->SetText(L"0/0");
2078 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2080 __pFindWordEditFieldRightToLeft->SetText(L"");
2081 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2084 __pFindWordNext->SetEnabled(false);
2085 __pFindWordPrev->SetEnabled(false);
2086 __pFindWordCountLabel->SetText(L"0/0");
2087 __pWebViewer->SearchTextAllAsync(L"",true);
2088 AppLog("akjshdasd 1");
2089 if(__isKeypadOpened == false)
2090 __pFooterPanel->SetShowState(true);
2091 ShowFindWordPanel(false);
2094 case IDA_FINDWORD_SEARCH_CLICKED:
2096 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2098 __currentSearchStr = __pFindWordEditField->GetText();
2100 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2102 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
2105 if (__currentSearchStr.GetLength() > 0)
2111 AppLogDebug("Enter something");
2115 case IDA_FINDWORD_CLEAR_CLICKED:
2117 __pFindWordCountLabel->SetText(L"0/0");
2118 __pFindWordEditField->SetText(L"");
2119 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2121 __currentSearchStr = L"";
2122 __pFindWordNext->SetEnabled(false);
2123 __pFindWordPrev->SetEnabled(false);
2124 // __pFindWordCountLabel->SetShowState(false);
2125 __pFindWordControl->Invalidate(true);
2128 case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
2130 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2131 __pFindWordEditFieldRightToLeft->SetText(L"");
2132 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2134 __currentSearchStr = L"";
2135 __pFindWordNext->SetEnabled(false);
2136 __pFindWordPrev->SetEnabled(false);
2137 // __pFindWordCountLabelRightToLeft->SetShowState(false);
2138 __pFindWordControl->Invalidate(true);
2141 case IDA_FINDWORD_NEXT_CLICKED:
2146 case IDA_FINDWORD_PREV_CLICKED:
2148 FindNextWord(false);
2151 case IDA_BRIGHTNESS_BTN_CLICKED:
2153 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
2154 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2157 case IDA_COPY_IMAGE_CLICKED:
2159 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2160 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2162 const Bitmap* pBitmap = null;
2163 if (__pHitElementResult != null && __pHitElementResult->HasImage())
2165 pBitmap = __pHitElementResult->GetImage();
2168 String resourcePath = App::GetInstance()->GetAppResourcePath();
2169 r = item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
2170 AppLog("Platofrm construct failed result %s",GetErrorMessage(r));
2171 // copying the item to clipboard
2172 Clipboard* pClipboard = Clipboard::GetInstance();
2173 if (pClipboard != null)
2175 r = pClipboard->CopyItem(item);
2176 AppLog("Platofrm copy failed result %s",GetErrorMessage(r));
2180 case IDA_VIEW_IMAGE_CLICKED:
2182 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
2183 WindowInfo* pNewWindowInfo = null;
2184 if (__pHitElementResult != null)
2186 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2187 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2193 case IDA_SAVE_IMAGE_CLICKED:
2195 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
2196 const Bitmap* pSaveBitmap = null;
2197 String imageName = GetImagePath();
2198 AppLog("Content manager image name %ls",imageName.GetPointer());
2201 imagePath.Append(imageName);
2202 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2203 AppLog("Content manager image path %ls",imagePath.GetPointer());
2204 if (__pHitElementResult != null)
2206 pSaveBitmap = __pHitElementResult->GetImage();
2208 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2212 UpdateImageContent(pBuffer, imageName);
2214 if(__pNotification != null)
2216 RemoveControl(__pNotification);
2217 __pNotification = null;
2219 __pNotification = new NotificationPanel(*this);
2221 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2222 msg.Append(imagePath);
2223 if (__pNotification != null)
2225 __pNotification->SetText(msg);
2226 if (__pFooterPanel->GetShowState() == true)
2228 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2232 __pNotification->SetPositionDiff(0);
2234 __pNotification->ShowNotification();
2239 int __modalMsgBoxResult;
2240 MessageBox* pMsgBox = new MessageBox();
2241 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);
2242 pMsgBox->ShowAndWait(__modalMsgBoxResult);
2245 __modalMsgBoxResult = 0;
2249 case IDA_SHARE_IMAGE_CLICKED:
2251 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2252 if (__pPopUp != null)
2259 __pAddressbar->HideKeypad();
2261 __pPopUp = new(std::nothrow) SharePopup();
2262 __pPopUp->Initialize();
2263 if (__pHitElementResult != null)
2265 const Bitmap* pSaveBitmap = null;
2266 String imageName = GetImagePath();
2267 AppLog("Content manager image name %ls",imageName.GetPointer());
2270 imagePath.Append(imageName);
2271 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2272 AppLog("Content manager image path %ls",imagePath.GetPointer());
2273 if (__pHitElementResult != null)
2275 pSaveBitmap = __pHitElementResult->GetImage();
2277 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2279 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2280 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2282 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2283 pShareInfo->SetPageTitle(L"");
2284 pShareInfo->SetPageUrl(srcUrl);
2285 pShareInfo->SetImageAttached(true);
2286 pShareInfo->SetImagePath(imagePath);
2287 __pPopUp->RemoveAllShareInfo();
2288 __pPopUp->AddShareInfo(pShareInfo);
2289 __pPopUp->SetShowState(true);
2294 case IDA_HYPERLINK_OPEN_CLICKED:
2296 if (__pHitElementResult != null)
2298 String srcUrl = __pHitElementResult->GetUrl();
2300 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2302 if (pNewWindowInfo == null)
2306 pNewWindowInfo->isJavascriptInitiated = true;
2307 result r = E_SUCCESS;
2308 SceneManager* pSceneManager = SceneManager::GetInstance();
2309 if (pSceneManager == NULL)
2313 ArrayList* pArgList = new(std::nothrow) ArrayList();
2314 if (pArgList == NULL)
2318 pArgList->Construct();
2320 pArgList->Add(*pNewWindowInfo);
2321 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2322 if (pArgList != null)
2329 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2335 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2337 if (__pHitElementResult == null)
2342 if(__pPopUp != null)
2349 __pAddressbar->HideKeypad();
2351 __pPopUp = new(std::nothrow) SharePopup();
2352 __pPopUp->Initialize();
2354 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2355 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2356 pShareInfo->SetImageAttached(false);
2357 __pPopUp->RemoveAllShareInfo();
2358 __pPopUp->AddShareInfo(pShareInfo);
2360 __pPopUp->SetShowState(true);
2364 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2368 if (__pHitElementResult != null)
2370 url = __pHitElementResult->GetUrl();
2373 String resourcePath = App::GetInstance()->GetAppResourcePath();
2374 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2376 // copying the item to clipboard
2377 Clipboard* pClipboard = Clipboard::GetInstance();
2378 if (pClipboard != null)
2380 pClipboard->CopyItem(item);
2384 case IDA_FIND_TEXT__CLICKED:
2386 // AddressBarCancelledClicked(*__pAddressbar);
2387 RelayoutControls(false);
2388 // __pFooterPanel->SetShowState(false);
2389 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2390 __currentSearchStr.Clear();
2391 __currentSearchStr.Append(__currentSelectedStr);
2392 InitFindWordPanel();
2393 __pFindWordEditField->SetText(__currentSearchStr);
2395 if(__pOptionMenu != null)
2397 __pOptionMenu->SetShowState(false);
2398 __pOptionMenu->Invalidate(false);
2400 __adressPanelPosition.y = 0;
2402 if (__pAddressbar != null && __pWebViewer != NULL)
2404 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2405 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2407 if (__pFooterPanel->GetShowState() == false)
2408 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2410 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2411 __pWebViewer->Invalidate(true);
2414 ShowFindWordPanel(true);
2415 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2417 __pFindWordEditField->SetText(__currentSearchStr);
2418 __pFindWordEditField->SetFocus();
2420 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2422 __pFindWordEditFieldRightToLeft->SetText(__currentSearchStr);
2423 __pFindWordEditFieldRightToLeft->SetFocus();
2426 if (__currentSearchStr.GetLength() > 0)
2432 AppLogDebug("Enter something");
2435 if (__pWebViewer != null)
2437 // releasing the set block
2438 __pWebViewer->ReleaseBlock();
2443 case IDA_SHARE_TEXT_CLICKED:
2445 __pWebViewer->ReleaseBlock();
2446 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2447 if(__pPopUp != null)
2454 __pAddressbar->HideKeypad();
2456 __pPopUp = new(std::nothrow) SharePopup();
2457 __pPopUp->Initialize();
2458 if (__pHitElementResult != null)
2460 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2461 pShareInfo->SetPageTitle(L"");
2462 pShareInfo->SetPageUrl(__currentSelectedStr);
2463 pShareInfo->SetImageAttached(false);
2464 __pPopUp->RemoveAllShareInfo();
2465 __pPopUp->AddShareInfo(pShareInfo);
2466 __pPopUp->SetShowState(true);
2471 case IDA_COPY_TEXT_CLICKED:
2473 __pWebViewer->ReleaseBlock();
2474 // need to implement
2475 //__currentSelectedStr
2476 // Sets data to a clip board item
2478 String resourcePath = App::GetInstance()->GetAppResourcePath();
2479 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2481 // copying the item to clipboard
2482 Clipboard* pClipboard = Clipboard::GetInstance();
2483 if (pClipboard != null)
2485 pClipboard->CopyItem(item);
2489 case IDA_PASTE_TEXT_CLICKED:
2491 Clipboard* pClipboard = Clipboard::GetInstance();
2493 if(pClipboard == null)
2497 // Retrieves a latest item
2498 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2504 //Gets data from the clipboard item
2505 String* pString = dynamic_cast<String*>(pItem->GetData());
2507 if (pString != null)
2509 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2510 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2511 String tagElement = __pHitElementResult->GetTagName();
2512 String contenteditable = __pHitElementResult->GetAttributeValue("contenteditable");
2513 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2514 String str = L"document.getElementsByName('";
2515 str.Append(nameElement);
2516 str.Append("').length");
2517 String* pCount = __pWebViewer->EvaluateJavascriptN(str);
2520 if(contenteditable.Equals(L"true",false) == true)
2522 AppLog("gmail paste need to support");
2524 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; } }";
2525 script.Append("replaceSelectedText(");
2526 script.Append("\"");
2527 script.Append(*pString);
2528 script.Append("\");");
2530 else if(idElement.GetLength() != 0)
2532 script = L"function insertAtCursor(myField, myValue) { if (document.selection) { document.getElementById(myField).focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (document.getElementById(myField).selectionStart || document.getElementById(myField).selectionStart == '0'){ var startPos = document.getElementById(myField).selectionStart; var endPos = document.getElementById(myField).selectionEnd; document.getElementById(myField).value = document.getElementById(myField).value.substring(0, startPos)+ myValue + document.getElementById(myField).value.substring(endPos, document.getElementById(myField).value.length); } else { document.getElementById(myField).value += myValue; } } ";
2533 script.Append("insertAtCursor('");
2534 script.Append(idElement);
2535 script.Append("',");
2536 script.Append("\"");
2537 script.Append(*pString);
2538 script.Append("\");");
2540 else if (nameElement.GetLength() != 0 && pCount->Equals("1",false) == true)
2542 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; } } ";
2543 script.Append("insertAtCursor(document.getElementsByName('");
2544 script.Append(nameElement);
2545 script.Append("')[0],");
2546 script.Append("\"");
2547 script.Append(*pString);
2548 script.Append("\");");
2550 else if(tagElement.GetLength() != 0) //adding for twitter post page
2552 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; } } ";
2554 script.Append("insertAtCursor(document.activeElement,");
2555 script.Append("\"");
2556 script.Append(*pString);
2557 script.Append("\");");
2559 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2560 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2566 __pWebViewer->ReleaseBlock();
2574 case IDA_GO_FORWARD:
2579 case IDA_REFRESH_BTN_CLICKED:
2581 __isLoadingCompleted = false;
2582 __isLoadingData = true;
2583 __progressPercentage = 0;
2584 __displayUrl = __pFooterUrlField->GetText();
2586 String url = __pFooterUrlField->GetText();
2587 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2589 if (__pWebViewer != null && __pAddressbar != null)
2592 //__pWebViewer->Reload();
2593 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2597 UpdateProgressBitmap();
2600 case IDA_STOP_BTN_CLICKED:
2602 __isLoadingCompleted = false;
2603 __isLoadingData = false;
2604 __progressPercentage = 0;
2605 __pFooterUrlField->HideKeypad();
2606 __displayUrl = __pFooterUrlField->GetText();
2610 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2611 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2612 __pWebViewer->StopLoading();
2613 RequestRedraw(true);
2616 UpdateProgressBitmap();
2621 if (__pFooterUrlField->GetText().IsEmpty() == false)
2623 //__displayUrl = __pUrlField->GetText();
2624 __pFooterUrlField->Clear();
2629 case IDA_READER_BTN_CLICKED:
2640 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2642 AppLog("MainForm::OnFormBackRequested entered");
2643 result r = E_FAILURE;
2644 if(__pImageMenu && __pImageMenu->GetShowState() == true)
2646 AppLog("Hiding the menu");
2647 __pImageMenu->SetShowState(false);
2649 if (__pWebViewer && __pWebViewer->CanGoBack())
2651 __pWebViewer->GoBack();
2653 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
2656 pApp = UiApp::GetInstance();
2659 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2662 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2670 WindowInfo* pWindowInfo = null;
2672 SceneManager* pSceneManager = SceneManager::GetInstance();
2673 if (pSceneManager == null)
2677 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2678 if (pAllWindowList == NULL)
2680 pApp = UiApp::GetInstance();
2683 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2686 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2691 if (pAllWindowList != null)
2693 totalCount = pAllWindowList->GetCount();
2695 for (int count = 0; count < totalCount; count++)
2697 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2698 if (pWindowInfo == null)
2700 pApp = UiApp::GetInstance();
2703 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2706 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2713 if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2715 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2718 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2721 r = pAllWindowList->RemoveAt(count, true);
2722 __pWindowInfo = null;
2725 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2730 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2734 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2736 if (pWindowInfo == null)
2738 pApp = UiApp::GetInstance();
2741 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2747 if(pWindowInfo != null)
2748 r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
2751 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2757 // else if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == false)
2759 // UiApp* pApp = null;
2760 // pApp = UiApp::GetInstance();
2761 // if (pApp != null)
2763 // r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2766 // AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2774 AppLog("MainForm::OnFormBackRequested exit");
2778 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2779 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2782 AppLog("MainForm::OnSceneActivatedN called");
2783 String* pSelectedScene = NULL;
2784 Object* pValue = NULL;
2785 String* pUrl = null;
2786 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2787 pSelectedScene = (String*) pValue;
2789 if (pSelectedScene != null)
2791 delete pSelectedScene;
2793 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2794 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2795 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2796 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2798 // setting the current scene ID
2799 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2801 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2803 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2805 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2806 if(__pWindowInfo == null)
2808 // if(__pWindowInfo == null)
2810 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2813 else if ( pArgs != null && pArgs->GetCount() == 1)
2815 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2821 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2823 // hiding the address bar
2824 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2825 __pAddressbar->SetShowState(false);
2826 // if(__pWebViewer != null)
2828 // __pWebViewer->Resume();
2831 if(pUrl != null && pUrl->GetLength() > 0)
2835 else if(__pWindowInfo != null)
2837 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)
2839 LoadUrl(__pWindowInfo->pageUrl);
2841 else if(__pWindowInfo->pageUrl.GetLength() > 0 && __pWindowInfo->isAppcontrolTriggered == true)
2843 LoadUrl(__pWindowInfo->pageUrl);
2844 __pWindowInfo->isAppcontrolTriggered = false;
2846 else if (__pWindowInfo->isJavascriptInitiated == true && __pWindowInfo->isFirstLaunch == true)
2848 __pWindowInfo->isFirstLaunch = false;
2851 __pWindowInfo->pCurrentWeb = __pWebViewer;
2852 if(__pWindowInfo->pageUrl.GetLength() > 0)
2853 LoadUrl(__pWindowInfo->pageUrl);
2857 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2858 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2859 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2861 InitMostVisitedSitesView(GetOrientationStatus());
2863 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2865 if(__pMostVisitedListView != null)
2867 __pMostVisitedListView->SetShowState(false);
2871 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2873 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2875 if (pBookmarkUrl == null)
2877 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2878 //__pAddressbar->SetUrl(*pBookmarkUrl);
2879 SetUrl(*pBookmarkUrl);
2881 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2882 __pWebViewer->LoadUrl(*pBookmarkUrl);
2883 delete pBookmarkUrl;
2886 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2887 Bitmap* pBitmap = null;
2888 if (isPrivateBrowsing == true)
2890 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2892 if (__pWebViewer != null)
2894 __pWebViewer->SetPrivateBrowsingEnabled(true);
2897 if (__pAddressbar != null)
2899 // __pAddressbar->UpdateFaviconBitmap(true);
2905 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2907 if (__pWebViewer != null)
2909 __pWebViewer->SetPrivateBrowsingEnabled(false);
2912 if (__pAddressbar != null)
2914 // __pAddressbar->UpdateFaviconBitmap(false);
2918 if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
2920 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2922 else if (__pOptionMenu != null )
2924 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2927 if (pBitmap != null)
2932 RelayoutControls(false);
2933 AppLog("ABC: OnSceneActivatedN started exit");
2938 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2939 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2941 Canvas* pWebCanvas = null;
2942 if (__pWebViewer != null)
2944 pWebCanvas = __pWebViewer->GetCanvasN();
2947 if (pWebCanvas == null)
2951 if (__pWindowInfo != null)
2953 if (__pWindowInfo->pWebCanvasBitmap != null)
2955 delete __pWindowInfo->pWebCanvasBitmap;
2957 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2958 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2959 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2961 Bitmap* pBitmap = GetCapturedBitmapN();
2962 AppLog("Coming here");
2963 Canvas* pCanvas = new(std::nothrow) Canvas();
2964 pCanvas->Construct(GetClientAreaBounds());
2967 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2970 if(__pWebViewer != null && __pWindowInfo != null && __pWindowInfo->pWebCanvasBitmap != null)
2971 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2973 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2976 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2981 __pAddressbar->SetShowState(false);
2982 AppLog("Coming here");
2986 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2987 const Tizen::Base::String& realm,
2988 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2994 MainForm::OnHttpAuthenticationCanceled(void)
2999 MainForm::OnLoadingStarted(void)
3001 AppLogDebug("MainForm::OnLoadingStarted entered");
3003 if(__pAddressbar == NULL || __pWebViewer == null)
3008 // this is added in case if menu is opened and user load the page
3009 if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
3011 __pOptionMenu->SetShowState(false);
3012 __pOptionMenu->Invalidate(true);
3017 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
3019 __pImageMenu->SetShowState(false);
3020 __pImageMenu->Invalidate(true);
3022 String url = __pWebViewer->GetUrl();
3023 if(url.Contains(IDS_TIZEN_SERVICE))
3026 String delim(L":;,");
3028 // Creates a StringTokenizer instance
3029 StringTokenizer strTok(url, delim);
3031 int count = strTok.GetTokenCount(); // count == 4
3033 HashMap *pMap = new HashMap();
3038 while (strTok.HasMoreTokens())
3040 AppLog("Token: %ls", token.GetPointer());
3041 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3042 if(token.Contains(IDS_APPID))
3044 token.SubString(6, appId);
3045 AppLog("AppID:%ls", appId.GetPointer());
3047 else if(token.Contains(IDS_KEY))
3049 token.SubString(4, key);
3050 AppLog("key:%ls", key.GetPointer());
3052 else if(token.Contains(IDS_VALUE))
3054 token.SubString(6, value);
3055 AppLog("value:%ls", value.GetPointer());
3058 pMap->Add(key, value);
3062 AppControl *pAppControl = null;
3063 String operationId = L"http://tizen.org/appcontrol/operation/main";
3064 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3067 AppLog("Starting AppControl");
3068 result r = pAppControl->Start(null, null, pMap, null);
3069 AppLog("Result of Start %s", GetErrorMessage(r));
3073 AppLogException("AppControl not found");
3078 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
3080 __pAddressbar->SetShowState(false);
3081 AddressBarCancelledClicked(*__pAddressbar);
3082 __pAddressbar->Invalidate(true);
3084 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
3087 __pAddressbar->SetFaviconBitmap(*pBitmap);
3090 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
3092 // updating the address bar position with respect to web control
3093 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
3094 __distanceMoved = 0;
3098 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3099 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3100 if (__pWebViewer != null)
3102 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
3103 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
3104 SetUrl(__pWebViewer->GetUrl());
3105 if (__pWindowInfo != NULL)
3107 // resetting the page title to blank, it will be received in OnPageTitleReceived()
3108 // __pWindowInfo->pageTitle = L"";
3109 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3111 __pAddressbar->Invalidate(true);
3117 MainForm::OnLoadingCanceled(void)
3123 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
3125 AppLog("XYZ::MainForm::OnKeypadWillOpen");
3130 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
3132 AppLog("XYZ::MainForm::OnKeypadOpened");
3133 __isKeypadOpened = true;
3134 __pFooterPanel->SetShowState(false);
3135 RelayoutControls(false);
3139 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
3141 AppLog("XYZ::MainForm::OnKeypadClosed");
3142 __isKeypadOpened = false;
3143 __pFooterPanel->SetShowState(true);
3144 RelayoutControls(true);
3148 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
3150 AppLog("XYZ::KeypadBoundsChanged");
3151 RelayoutControls(false);
3155 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
3156 const Tizen::Base::String& reason)
3158 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
3162 MainForm::OnLoadingCompleted(void)
3164 AppLog("MainForm::OnLoadingCompleted start");
3166 result r = E_SUCCESS;
3168 if (__pWebViewer == null)
3173 if (__pAddressbar == null)
3178 if(__pWindowInfo && __pWebViewer)
3179 __pWindowInfo->pageTitle = __pWebViewer->GetTitle();
3180 if(__pImageMenu && __pImageMenu->GetShowState())
3182 __pImageMenu->SetShowState(false);
3183 __pImageMenu->Invalidate(true);
3186 if (__pWebViewer->CanGoForward())
3188 //__pAddressbar->SetForwardButtonEnabled(true);
3189 SetForwardButtonEnabled(true);
3193 //__pAddressbar->SetForwardButtonEnabled(false);
3194 SetForwardButtonEnabled(false);
3197 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3199 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3201 //__pAddressbar->UpdateProgress(0);
3205 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3207 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3211 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
3212 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
3213 if (isPrivateBrowsing == false)
3215 if(__pHistory != null)
3221 __pHistory = new(std::nothrow) History;
3222 HistoryPresentationModel::GetCurrentDateTime(date);
3225 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
3226 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
3228 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
3229 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3231 __pHistory->SetVisitedTime(date);
3233 if (__pWebViewer != null)
3235 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3237 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3238 if (pTempBitmap != null)
3240 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3241 __pHistory->SetFavIconBitmap(*pTempBitmap);
3246 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3247 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3248 if ( pCanvas != null && pCanvas != null && pBitmap != null)
3250 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3251 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3252 __pHistory->SetThumbnail(pBitmap);
3254 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3257 Tizen::Graphics::BufferInfo bmpInfo;
3258 pFavIcon->Lock(bmpInfo);
3259 AppLog("rrrr:: width %d height %d of the faviconbitmap from bufferinfo", bmpInfo.width, bmpInfo.height);
3261 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3263 AppLog("rrrr:: width %d height %d of the faviconbitmap",pFavIcon->GetWidth(),pFavIcon->GetHeight());
3264 __pHistory->SetFavIconBitmap(*pFavIcon);
3268 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3275 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3277 // temperary fixed (webpage can be not loaded)
3281 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3282 if (isReaderEnabled == true)
3286 delete __pReaderData;
3287 __pReaderData = null;
3289 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3290 filePath.Append(L"data/reader.js");
3296 result r = E_SUCCESS;
3297 FileAttributes attr;
3299 File::GetAttributes(filePath,attr);
3301 r = file.Construct(filePath, L"r+");
3304 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3307 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3310 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3313 // file.Read(pScript,attr.GetFileSize());
3315 // AppLogDebug("scipt length %d",strlen(pScript));
3316 String strScript = L"";
3317 // strScript.Append(pScript);
3318 // for(int i=0; i<25; i++)
3320 file.Read(pScript,attr.GetFileSize());
3321 // AppLog("xyzz tell %d",file.Tell());
3322 // r = strScript.Append(pScript);
3323 // AppLog("xyzz append result %s",GetErrorMessage(r));
3324 // AppLog("xyzz strScript length %d",strScript.GetLength());
3326 // AppLog("xyzz final strScript length %d",strScript.GetLength());
3328 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3329 if (__pReaderData == null)
3331 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3332 __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>");
3335 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3336 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3338 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3339 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3345 AppLog("MainForm::OnLoadingCompleted done");
3349 MainForm::OnEstimatedProgress(int progress)
3351 AppLogDebug("MainForm::OnEstimatedProgress entered %d",progress);
3353 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3354 progress = DEFAULT_PROGRESS_PERCENTAGE;
3356 // __pAddressbar->UpdateProgress(progress);
3357 UpdateProgress(progress);
3360 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3362 AppLog("MainForm::OnFaviconReceived");
3363 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3365 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3368 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3375 MainForm::OnUrlValueChanged(Addressbar&)
3381 MainForm::OnUrlSubmitted(Addressbar& addBar)
3383 AppLog("MainForm::OnUrlSubmitted");
3384 String url = addBar.GetUrl();
3385 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3387 if(__pFooterUrlField)
3388 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3389 AddressBarCancelledClicked(*__pAddressbar);
3394 MainForm::LoadUrl(String& url)
3398 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3399 AppLogDebug("MainForm::LoadUrl enter");
3401 if (__pWebViewer != null)
3403 __pWebViewer->SetShowState(true);
3404 __pWebViewer->Invalidate(true);
3407 if (url.CompareTo(L"") == 0)
3411 if(__pFooterPanel != null)
3413 __pFooterPanel->SetShowState(true);
3414 __pFooterPanel->Invalidate(true);
3421 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3422 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)
3424 RegularExpression firstRegex;
3425 RegularExpression secondRegex;
3427 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3428 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3431 ret = firstRegex.Match(url, false); // This returns true value
3432 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3434 if (ret == true && __pWebViewer != null)
3437 __pWebViewer->LoadUrl(url);
3439 else if(__pWebViewer != null)
3441 String tempUrl = L"http://";
3442 tempUrl.Append(url);
3446 __pWebViewer->LoadUrl(tempUrl);
3450 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3451 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3454 if (__pAddressbar != null)
3456 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3457 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3460 AppLogDebug("MainForm::LoadUrl exit");
3467 MainForm::OnFocusGained(const Tizen::Ui::Control& source)
3469 AppLog("MainForm::OnFocusGained");
3472 __pFooterPanel->SetShowState(false);
3477 __pAddressbar->SetShowState(true);
3478 __pAddressbar->SetAddressbarURLFocus();
3480 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3482 __currentSearchStr = L"";
3483 __currentWordIndex = 0;
3484 __maxOccurrances = 0;
3486 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
3488 __pFindWordEditField->SetText(L"");
3489 __pFindWordEditField->HideKeypad();
3490 __pFindWordControl->SetShowState(false);
3491 __pFindWordCountLabel->SetText(L"0/0");
3493 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
3495 __pFindWordEditFieldRightToLeft->SetText(L"");
3496 __pFindWordEditFieldRightToLeft->HideKeypad();
3497 __pFindWordControl->SetShowState(false);
3498 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
3501 __pFindWordNext->SetEnabled(false);
3502 __pFindWordPrev->SetEnabled(false);
3504 __pWebViewer->SearchTextAllAsync(L"",true);
3505 __pFindWordControl->SetShowState(false);
3507 RelayoutControls(false);
3511 MainForm::OnFocusLost(const Tizen::Ui::Control& source)
3513 AppLog("MainForm::OnFocusLost called");
3517 MainForm::OnStopClicked(Addressbar& addBar)
3519 AppLogDebug("MainForm::OnStopClicked called");
3522 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3523 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3524 __pWebViewer->StopLoading();
3525 RequestRedraw(true);
3530 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3532 // AppLog("MainForm::OnBackClicked");
3533 result r = E_FAILURE;
3534 if(__pImageMenu && __pImageMenu->GetShowState() == true)
3536 AppLog("Hiding the menu");
3537 __pImageMenu->SetShowState(false);
3540 if (__pWebViewer && __pWebViewer->CanGoBack())
3542 __pWebViewer->GoBack();
3544 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3547 pApp = UiApp::GetInstance();
3550 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3553 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3561 WindowInfo* pWindowInfo = null;
3563 SceneManager* pSceneManager = SceneManager::GetInstance();
3564 if (pSceneManager == null)
3568 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3569 if (pAllWindowList == NULL)
3571 pApp = UiApp::GetInstance();
3574 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3577 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3582 if (pAllWindowList != null)
3584 totalCount = pAllWindowList->GetCount();
3586 for (int count = 0; count < totalCount; count++)
3588 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3589 if (pWindowInfo == null)
3591 pApp = UiApp::GetInstance();
3594 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3597 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3602 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3604 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3607 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3610 r = pAllWindowList->RemoveAt(count, true);
3611 __pWindowInfo = null;
3614 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3619 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3621 else if(pAllWindowList->GetCount() > 0)
3623 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3627 pApp = UiApp::GetInstance();
3630 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3635 if (pWindowInfo == null)
3637 pApp = UiApp::GetInstance();
3640 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3646 r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
3647 // r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3650 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3664 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3666 AppLog("MainForm::OnForwardClicked");
3667 if (__pWebViewer == null)
3670 if (__pWebViewer->CanGoForward())
3672 __pWebViewer->GoForward();
3677 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3679 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3680 if(__pFooterPanel != null)
3682 __pFooterPanel->SetShowState(false);
3685 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3687 __pAddressbar->SetShowState(true);
3688 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3691 RelayoutControls(false);
3695 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3697 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3699 int Height = GetClientAreaBounds().height;
3700 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3702 RelayoutControls(false);
3706 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3708 AddressBarCancelledClicked(addBar);
3712 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3714 __prevAddressBarMode = __curAddressBarMode;
3716 if (__pAddressbar != null)
3718 __curAddressBarMode = GetAddressbarMode();
3721 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3723 __adressPanelPosition.y = 0;
3724 if (__pAddressbar != null)
3726 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3727 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3728 __pAddressbar->Invalidate(true);
3730 if (__pWebViewer != null)
3732 __pWebViewer->StopLoading();
3735 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3737 __adressPanelPosition.y = 0;
3738 if (__pAddressbar != null)
3740 __webControlPosition.y = 0;
3741 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3742 __pAddressbar->Invalidate(true);
3748 MainForm::OnClipboardClosed(const Addressbar& addBar)
3750 AppLog("XYZ::MainForm::OnClipboardClosed");
3751 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3753 AppLog("akjshdasd 3");
3754 __pFooterPanel->SetShowState(true);
3756 __isKeypadOpened = false;
3757 RelayoutControls(false);
3761 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3763 AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3764 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3766 AppLog("akjshdasd 3");
3767 __pFooterPanel->SetShowState(true);
3769 __isKeypadOpened = false;
3770 if(__pNotification && __pNotification->GetShowState())
3772 __pNotification->SetPosition(0,GetClientAreaBounds().height - __pNotification->GetHeight());
3775 RelayoutControls(false,footerState);
3779 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3781 AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3782 __isKeypadOpened = true;
3783 if(__pNotification && __pNotification->GetShowState())
3785 __pNotification->SetPosition(0,GetClientAreaBounds().height - __pNotification->GetHeight());
3787 RelayoutControls(false);
3791 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3793 __isKeypadOpened = true;
3794 __pFooterPanel->SetShowState(false);
3798 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3800 AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3801 RelayoutControls(false);
3805 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3807 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3810 __pWindowInfo->pageTitle = title;
3811 if (__pWebViewer != null)
3813 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3814 AppLog("MainForm::OnPageTitleReceived url %ls",__pWindowInfo->pageUrl.GetPointer());
3817 if (__pAddressbar != null && __pWebViewer != null)
3819 SetUrl(__pWebViewer->GetUrl());
3820 __pAddressbar->Invalidate(true);
3825 MainForm::UpdateFavicon(void)
3827 bool urlImageType = false;
3828 String *tempPath = null;
3830 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();");
3831 Bitmap* pBitmap = null;
3833 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3835 if (__pWindowInfo != null)
3838 url.SetUri(*tempPath);
3839 if (url.GetHost().GetLength() == 0)
3843 webUrl.SetUri(__pWebViewer->GetUrl());
3844 result r = url.SetHost(webUrl.GetHost());
3851 if (url.GetScheme().GetLength() == 0)
3855 webUrl.SetUri(__pWebViewer->GetUrl());
3856 url.SetScheme(webUrl.GetScheme());
3858 __pWindowInfo->faviconUrl = url.ToString();
3860 pBitmap = __pWebViewer->GetFaviconN();
3862 if (pBitmap != null)
3864 if (__pWindowInfo->pFavicon != NULL)
3866 __pWindowInfo->pFavicon = null;
3868 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3869 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3871 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3873 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3875 else if(__pWindowInfo->pFavicon != null)
3877 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3881 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3882 if(pDefaultBmp != null)
3884 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3898 if(tempPath != null)
3902 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3908 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3909 Tizen::Web::Controls::WebNavigationType type)
3911 AppLog("urlk %ls",url.GetPointer());
3912 // when load new page if find word panel is open its show state is false
3913 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3915 __currentSearchStr = L"";
3916 __currentWordIndex = 0;
3917 __maxOccurrances = 0;
3918 __pFindWordEditField->SetText(L"");
3919 __pFindWordNext->SetEnabled(false);
3920 __pFindWordPrev->SetEnabled(false);
3921 __pFindWordCountLabel->SetText(L"0/0");
3922 __pFindWordControl->SetShowState(false);
3923 __pFindWordEditField->HideKeypad();
3924 RelayoutControls(false);
3927 __pFooterPanel->Invalidate(true);
3930 uriInfo.SetUri(url);
3932 if(url.Contains(IDS_TIZEN_SERVICE))
3935 String delim(L":;,");
3937 // Creates a StringTokenizer instance
3938 StringTokenizer strTok(url, delim);
3940 int count = strTok.GetTokenCount(); // count == 4
3942 HashMap *pMap = new HashMap();
3948 while (strTok.HasMoreTokens())
3950 AppLog("Token: %ls", token.GetPointer());
3951 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3952 if(token.Contains(IDS_APPID))
3954 token.SubString(6, appId);
3955 AppLog("AppID:%ls", appId.GetPointer());
3957 else if(token.Contains(IDS_KEY))
3959 token.SubString(4, key);
3960 AppLog("key:%ls", key.GetPointer());
3962 else if(token.Contains(IDS_VALUE))
3964 token.SubString(6, value);
3965 AppLog("value:%ls", value.GetPointer());
3968 pMap->Add(key, value);
3972 AppControl *pAppControl = null;
3973 String operationId = L"http://tizen.org/appcontrol/operation/main";
3974 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3977 result r = pAppControl->Start(null, null, pMap, null);
3981 AppLogException("AppControl not found");
3991 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3992 const Tizen::Net::Http::HttpHeader& httpHeader)
3994 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3998 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
4000 AppLog("LMN::MainForm::OnWebPageBlockSelected");
4001 // if(__isLongPressedDone == false)
4004 if (__pHitElementResult != null)
4006 delete __pHitElementResult;
4007 __pHitElementResult = null;
4010 if (__pWebViewer != null)
4012 AppLog("MainForm::OnWebPageBlockSelected web not null");
4013 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
4015 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false))
4017 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
4018 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
4019 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false))
4021 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
4023 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
4027 if (__pHitElementResult == null)
4032 if (__pHitElementResult->HasImage() != true)
4034 String tagName = __pHitElementResult->GetTagName();
4035 String type = __pHitElementResult->GetAttributeValue("type");
4036 String contenteditable = __pHitElementResult->GetAttributeValue("contenteditable");
4039 AppLog("TagName %ls",tagName.GetPointer());
4040 __currentSelectedStr.Clear();
4041 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
4042 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4043 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
4044 if(tagName.Equals(L"TEXTAREA",false) == true)
4046 AppLog("Tagnameseemstobe TEXTAREA");
4048 else if(tagName.Equals(L"INPUT",false) == true)
4050 AppLog("Tagnameseemstobe INPUT");
4053 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 )
4055 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4057 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),true);
4060 __pImageMenu->SetShowState(true);
4061 __pImageMenu->Show();
4062 __pImageMenu->Invalidate(true);
4065 else /*if(__isLongPressedDone == true)*/
4067 AppLog("MainForm::OnWebPageBlockSelected no paste option");
4069 if(__pHitElementResult->GetUrl().GetLength() > 0)
4071 __currentSelectedStr.Clear();
4072 __currentSelectedStr = __pHitElementResult->GetUrl();
4074 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),false);
4077 __pImageMenu->SetShowState(true);
4078 __pImageMenu->Show();
4079 __pImageMenu->Invalidate(true);
4083 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
4084 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
4085 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
4091 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
4097 MainForm::OnWebWindowCreateRequested(void)
4099 AppLog("MainForm::OnWebWindowCreateRequested entered");
4100 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
4102 if (pNewWindowInfo == null)
4106 result r = E_SUCCESS;
4107 SceneManager* pSceneManager = SceneManager::GetInstance();
4108 if (pSceneManager == NULL)
4112 ArrayList* pArgList = new(std::nothrow) ArrayList();
4113 if (pArgList == NULL)
4117 r = pArgList->Construct();
4120 pNewWindowInfo->isJavascriptInitiated = true;
4121 pArgList->Add(*pNewWindowInfo);
4122 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4126 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
4133 return pNewWindowInfo->pCurrentWeb;
4136 void MainForm::OnWebWindowCloseRequested(Tizen::Web::Controls::Web& source)
4138 AppLog("OnWebWindowCloseRequested");
4139 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
4140 SceneManager* pSceneManager = SceneManager::GetInstance();
4141 WindowInfo* pWindowInfo = null;
4142 WindowInfo* pNewWindowInfo = null;
4145 result r = E_FAILURE;
4147 if (pAllWindowList != null)
4149 totalCount = pAllWindowList->GetCount();
4152 for (int count = 0; count < totalCount; count++)
4154 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
4155 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID)
4157 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
4160 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
4164 r = pAllWindowList->RemoveAt(count, true);
4168 pNewWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
4170 else if(pAllWindowList->GetCount() > 0)
4172 pNewWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
4176 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
4178 if (pNewWindowInfo == null)
4182 result r = E_SUCCESS;
4183 SceneManager* pSceneManager = SceneManager::GetInstance();
4184 if (pSceneManager == NULL)
4188 ArrayList* pArgList = new(std::nothrow) ArrayList();
4189 if (pArgList == NULL)
4193 r = pArgList->Construct();
4196 pArgList->Add(*pNewWindowInfo);
4197 result r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4198 if (pArgList != null)
4205 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
4210 pApp = UiApp::GetInstance();
4213 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
4218 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
4220 __pWindowInfo = null;
4228 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
4230 AppLog("xyz:: MainForm::RelayoutControls called");
4231 __webControlPosition.y = 0;
4232 __webControlHeight = GetClientAreaBounds().height;
4233 AppLog("Client area height: %d width %d", __webControlHeight,GetClientAreaBounds().width);
4235 AppLog("Client area height: %d", __webControlHeight);
4236 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
4238 __webControlPosition.y += __pAddressbar->GetHeight();
4239 __webControlHeight -= __pAddressbar->GetHeight();
4240 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
4242 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
4244 __webControlPosition.y += __pFindWordControl->GetHeight();
4245 __webControlHeight -= __pFindWordControl->GetHeight();
4246 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
4249 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
4251 __webControlHeight -= __pFooterPanel->GetHeight();
4253 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
4254 __webControlHeight = __webControlHeight + 12;
4256 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
4258 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight )
4263 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight );
4264 AppLog("xyz:: MainForm::RelayoutControls called __webControlHeight %d",__webControlHeight);
4265 __pWebViewer->Invalidate(false);
4268 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
4270 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
4277 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
4279 if (__pFindWordControl == null)
4284 Tizen::Locales::LocaleManager localeManager;
4285 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
4287 String languageCode;
4288 result r = SettingInfo::GetValue(L"Language", languageCode);
4289 // int languagecode = local.GetLanguageCode();
4290 AppLog("rahul language is %S", languageCode.GetPointer());
4294 InitFindWordPanel();
4296 if (languageCode.CompareTo("ara") == 0)
4298 AppLog("rahul language is arabic");
4300 __pFindWordPanelLeftToRight->SetShowState(false);
4301 __pFindWordPanelRightToLeft->SetShowState(true);
4303 __pFindWordClear->SetShowState(false);
4304 __pFindWordCountLabel->SetShowState(false);
4305 __pFindWordEditField->SetShowState(false);
4307 __pFindWordClearRightToLeft->SetShowState(true);
4308 __pFindWordCountLabelRightToLeft->SetShowState(true);
4309 __pFindWordEditFieldRightToLeft->SetShowState(true);
4313 AppLog("rahul language is not arabic");
4316 __pFindWordPanelLeftToRight->SetShowState(true);
4317 __pFindWordPanelRightToLeft->SetShowState(false);
4319 __pFindWordClear->SetShowState(true);
4320 __pFindWordCountLabel->SetShowState(true);
4321 __pFindWordEditField->SetShowState(true);
4323 __pFindWordClearRightToLeft->SetShowState(false);
4324 __pFindWordCountLabelRightToLeft->SetShowState(false);
4325 __pFindWordEditFieldRightToLeft->SetShowState(false);
4327 __pFindWordControl->SetShowState(true);
4331 if(__pFindWordControl != null)
4333 __pFindWordControl->SetShowState(false);
4337 AppLog("MainForm::ShowFindWordPanel %d",show);
4338 if (show && !isTouchPressed)
4340 if (languageCode.CompareTo("ara") == 0)
4342 if (__pFindWordEditFieldRightToLeft)
4344 __pFindWordEditFieldRightToLeft->SetFocus();
4345 __pFindWordEditFieldRightToLeft->ShowKeypad();
4350 if (__pFindWordEditField)
4352 __pFindWordEditField->SetFocus();
4353 __pFindWordEditField->ShowKeypad();
4359 if (languageCode.CompareTo("ara") == 0)
4361 if (__pFindWordEditFieldRightToLeft)
4362 __pFindWordEditFieldRightToLeft->HideKeypad();
4366 if (__pFindWordEditField)
4367 __pFindWordEditField->HideKeypad();
4371 RelayoutControls(false);
4375 MainForm::StartWordSearch()
4377 //Get the count of occurances of the word in the current page
4378 __maxOccurrances = 0;
4379 __currentWordIndex = 0;
4381 __pFindWordPrev->SetEnabled(false);
4382 String *pCountStr = null;
4385 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
4386 AppLog("Search Result %s",GetErrorMessage(r));
4389 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
4390 if (pCountStr != null)
4392 Integer::Parse(*pCountStr, 10, __maxOccurrances);
4396 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
4401 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
4403 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
4404 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
4408 if (__pFindWordCountLabel)
4410 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
4412 if (__pFindWordEditField)
4414 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
4417 else if(totalCount >= 100)
4419 if (__pFindWordCountLabel)
4421 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4423 if (__pFindWordEditField)
4425 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4430 if (__pFindWordCountLabel)
4432 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4434 if (__pFindWordEditField)
4436 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4440 __maxOccurrances = totalCount;
4441 __currentWordIndex = currentOrdinal;
4443 //Reset the UI controls as per the maxOccurrance value
4444 if (totalCount <= 0)
4446 AppLog("Word not found");
4447 //Show error notification to user
4448 __pFindWordNext->SetEnabled(false);
4449 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4451 __pFindWordCountLabel->SetText(L"0/0");
4452 __pFindWordCountLabel->Invalidate(false);
4454 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4456 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4457 __pFindWordCountLabelRightToLeft->Invalidate(false);
4459 __pFindWordNext->Invalidate(false);
4460 __pFindWordPrev->Invalidate(false);
4465 if (totalCount == 1 || totalCount == currentOrdinal)
4467 __pFindWordNext->SetEnabled(false);
4471 __pFindWordNext->SetEnabled(true);
4474 String countStr = L"";
4475 countStr.Append(__currentWordIndex);
4476 countStr.Append(L"/");
4477 countStr.Append(__maxOccurrances);
4478 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4480 __pFindWordCountLabel->SetText(countStr);
4481 __pFindWordCountLabel->Invalidate(false);
4482 __pFindWordCountLabel->Invalidate(false);
4484 else if (__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4486 __pFindWordCountLabelRightToLeft->SetText(countStr);
4487 __pFindWordCountLabelRightToLeft->Invalidate(false);
4488 __pFindWordCountLabelRightToLeft->Invalidate(false);
4490 if (__pFindWordNext)
4492 __pFindWordNext->Invalidate(false);
4494 if (__pFindWordPrev)
4496 __pFindWordPrev->Invalidate(false);
4502 MainForm::FindNextWord(bool next)
4506 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4507 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4509 if (__currentWordIndex < __maxOccurrances)
4511 __currentWordIndex++;
4517 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4518 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4520 if(__currentWordIndex > 1)
4522 __currentWordIndex--;
4527 String countStr = L"";
4528 countStr.Append(__currentWordIndex);
4529 countStr.Append(L"/");
4530 countStr.Append(__maxOccurrances);
4532 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4534 __pFindWordCountLabel->SetText(countStr);
4535 __pFindWordCountLabel->Invalidate(false);
4537 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4539 __pFindWordCountLabelRightToLeft->SetText(countStr);
4540 __pFindWordCountLabelRightToLeft->Invalidate(false);
4543 if (__currentWordIndex >= __maxOccurrances)
4545 __pFindWordNext->SetEnabled(false);
4549 __pFindWordNext->SetEnabled(true);
4551 if (__currentWordIndex <= 1)
4553 __pFindWordPrev->SetEnabled(false);
4557 __pFindWordPrev->SetEnabled(true);
4559 __pFindWordPrev->Invalidate(false);
4560 __pFindWordNext->Invalidate(false);
4562 __pFindWordControl->Invalidate(true);
4566 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4568 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4569 __isKeypadOpened = true;
4570 __pFooterPanel->SetShowState(false);
4571 // OnAddressBarKeypadOpened(*__pAddressbar);
4575 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4577 __isKeypadOpened = true;
4578 AppLog("xyz::MainForm::OnWebKeypadOpened");
4580 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4582 __currentSearchStr = L"";
4583 __currentWordIndex = 0;
4584 __maxOccurrances = 0;
4585 __pFindWordEditField->SetText(L"");
4586 __pFindWordNext->SetEnabled(false);
4587 __pFindWordPrev->SetEnabled(false);
4588 __pFindWordCountLabel->SetText(L"0/0");
4589 __pWebViewer->SearchTextAllAsync(L"",false);
4590 __pFindWordControl->SetShowState(false);
4591 __pFindWordEditField->HideKeypad();
4595 if (__pWebViewer != null && __pFooterPanel != null)
4597 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4598 if(__pAddressbar != null)
4600 __pAddressbar->SetShowState(false);
4602 if(__pFindWordControl != null)
4604 __pFindWordControl->SetShowState(false);
4606 __pFooterPanel->SetShowState(false);
4607 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4609 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4611 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4612 // AppLog("omgomgomg");
4618 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4620 AppLog("abcde::MainForm::OnWebKeypadClosed");
4621 AppLog("xyz::MainForm::OnWebKeypadClosed");
4622 AppLog("akjshdasd 4");
4623 __pFooterPanel->SetShowState(true);
4624 // OnAddressBarKeypadClosed(*__pAddressbar);
4625 RelayoutControls(false);
4626 __isKeypadOpened = false;
4629 if(__pImageMenu && __pImageMenu->GetShowState() == true)
4631 AppLog("abcde: imagemenu visible.");
4634 __pWebViewer->GetBlockRange(p,q);
4635 if (p == Point(0,0) && q == Point(0,0))
4643 __pImageMenu->SetAnchorPosition(p);
4644 __pImageMenu->Show();
4650 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4652 // RelativeLayout(false);
4653 if(__pWebViewer != null)
4655 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4660 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4662 Control* temp = const_cast< Control* >(&source);
4663 Header* pHeader = dynamic_cast< Header* >(temp);
4664 if (pHeader != null)
4666 //Header double - clicked
4667 AppLog("Header double clicked");
4669 if(__pFindWordControl)
4671 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4672 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4676 AppLog("MainScene::OnTouchDoublePressed");
4680 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4682 AppLog("LMN::abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4683 if(TouchEventManager::GetInstance() && TouchEventManager::GetInstance()->GetTouchInfoListN() && TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1)
4685 AppLog("Returning because of more than one touch point.");
4689 // __pWebViewer->ReleaseBlock();
4691 __pWebViewer->SetFocus();
4692 __longPressPoint = currentPosition;
4694 if (__pHitElementResult != null)
4696 delete __pHitElementResult;
4697 __pHitElementResult = null;
4700 if (__pWebViewer != null)
4702 AppLog("MainForm::OnTouchLongPressed web not null");
4703 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4706 if (__pHitElementResult == null)
4711 if (__pHitElementResult->HasImage() == true)
4713 if(__pWebViewer != null)
4715 __pWebViewer->ReleaseBlock();//N_SE-52389
4716 InitImageContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4718 __pImageMenu->SetShowState(true);
4719 __pImageMenu->Show();
4720 __pImageMenu->Invalidate(true);
4722 else if(__pHitElementResult->HasUrl() == true)
4724 if(__pWebViewer != null)
4725 __pWebViewer->ReleaseBlock();//N_SE-52389
4726 String tempURl = __pHitElementResult->GetUrl();
4727 AppLog("tempURl is %ls", tempURl.GetPointer());
4728 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4729 if (pBitmap != null)
4737 InitImageLinkContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4738 __pImageMenu->SetShowState(true);
4739 __pImageMenu->Show();
4740 __pImageMenu->Invalidate(true);
4744 String tagName = __pHitElementResult->GetTagName();
4745 String type = __pHitElementResult->GetAttributeValue("type");
4746 String value = __pHitElementResult->GetAttributeValue(L"value");
4747 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4748 result r = E_FAILURE;
4749 __currentSelectedStr.Clear();
4750 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4752 AppLog("tag name is %ls", tagName.GetPointer());
4753 AppLog("type is %ls", type.GetPointer());
4757 __isLongPressedDone = true;
4758 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)
4759 r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4760 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)
4762 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4764 InitSelectTextContextMenu(Point(currentPosition.x , currentPosition.y + __pWebViewer->GetY()),true, true);
4767 __pImageMenu->SetShowState(true);
4768 __pImageMenu->Show();
4769 __pImageMenu->Invalidate(true);
4772 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4775 // __inputEventToBeSupressed = true;
4779 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4781 AppLog("xyz:: MainForm::OnTouchReleased called");
4783 if (__pAddressbar && __pAddressbar->GetShowState() == true)
4785 __pAddressbar->SetShowState(false);
4787 if(__pFooterPanel && __isKeypadOpened == false)
4789 __pFooterPanel->SetShowState(true);
4793 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4794 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4796 __pWebViewer->ConsumeInputEvent();
4798 if(pHitElement != null)
4802 __inputEventToBeSupressed = false;*/
4806 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4813 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4815 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4817 __currentSearchStr = L"";
4818 __currentWordIndex = 0;
4819 __maxOccurrances = 0;
4821 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4823 __pFindWordEditField->SetText(L"");
4824 __pFindWordEditField->HideKeypad();
4825 __pFindWordControl->SetShowState(false);
4826 __pFindWordCountLabel->SetText(L"0/0");
4828 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4830 __pFindWordEditFieldRightToLeft->SetText(L"");
4831 __pFindWordEditFieldRightToLeft->HideKeypad();
4832 __pFindWordControl->SetShowState(false);
4833 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4836 __pFindWordNext->SetEnabled(false);
4837 __pFindWordPrev->SetEnabled(false);
4839 __pWebViewer->SearchTextAllAsync(L"",true);
4840 __pFindWordControl->SetShowState(false);
4842 AppLog("__pAddressbar->GetShowState() %d",__pAddressbar->GetShowState());
4843 if(__pAddressbar->GetShowState() == false)
4845 __pAddressbar->SetAddressbarURLFocus();
4846 __pFooterPanel->SetShowState(false);
4853 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4859 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4865 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4871 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4877 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4883 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4885 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4886 int widthContextItem = 0;
4887 if(__pFindWordCountLabel)
4888 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4889 // As per the platform engineer comment removed this line
4890 /*if(__pWebViewer != null)
4892 // 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
4893 __pWebViewer->ReleaseBlock();
4896 // if(__pFindWordControl != null)
4897 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4899 if(__pOptionMenu && __pOptionMenu->GetShowState() == true)
4901 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4903 AppLog(" Orientation landscape");
4904 __pOptionMenu->SetMaxVisibleItemsCount(5);
4908 AppLog(" Orientation potrait");
4909 __pOptionMenu->SetMaxVisibleItemsCount(6);
4912 if(__pNotification && __pNotification->GetShowState() == true)
4914 __pNotification->SetShowState(false);
4915 __pNotification->Invalidate(false);
4917 if ( __pFooterLabel != null)
4919 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4922 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4928 if (__pFindWordBgLabel != null)
4930 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4931 if (pBitmap != null)
4933 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4938 if (__pFindWordBgLabelRightToLeft != null)
4940 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4941 if (pBitmap != null)
4943 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4949 // if(__pOptionMenu != null)
4950 // __pOptionMenu->SetShowState(false);
4952 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4954 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4958 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4963 AppLog("__pFooterPanel->GetShowState() is true");
4965 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4966 __pFooterPanel->Invalidate(true);
4970 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4971 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4973 InitMostVisitedSitesView(orientationStatus);
4976 RelayoutControls(false);
4977 if (__pArticleReaderPanel != null)
4979 if (__pArticleReaderPanel->GetShowState() == true)
4981 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4983 if (__pBlankPanel != null)
4984 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4986 if (__pWebReader != null)
4988 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4990 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4991 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4993 if ( pBitmap != null && pSrcBitmap != null)
4995 AppLog("CreateReaderPanel ninepatchbitmap found");
4996 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4999 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
5000 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
5001 if (pBitmap != null)
5006 if (pSrcBitmap != null)
5015 if (__pAddressbar != null)
5017 int width = GetClientAreaBounds().width;
5018 __pAddressbar->OrientationChanged(width);
5023 MainForm::OnSettingsChange(int settingvalue)
5025 AppLogDebug("MainForm::OnSettingsChange entered");
5027 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
5029 __pAddressbar->ResetGuideText();
5031 if (__pWebViewer == null)
5033 AppLogDebug("Webviewer is not initialized yet.");
5037 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
5039 WebSetting settings = __pWebViewer->GetSetting();
5040 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
5042 settings.SetAutoFittingEnabled(true);
5044 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
5046 settings.SetAutoFittingEnabled(false);
5048 __pWebViewer->SetSetting(settings);
5051 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
5053 WebSetting settings = __pWebViewer->GetSetting();
5054 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
5055 __pWebViewer->SetSetting(settings);
5057 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
5059 WebSetting settings = __pWebViewer->GetSetting();
5060 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
5061 __pWebViewer->SetSetting(settings);
5062 __pWebViewer->Reload();
5064 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
5066 WebSetting settings = __pWebViewer->GetSetting();
5067 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
5068 __pWebViewer->SetSetting(settings);
5070 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
5074 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
5077 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
5081 WebSetting settings = __pWebViewer->GetSetting();
5082 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
5083 __pWebViewer->SetSetting(settings);
5086 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
5090 WebSetting settings = __pWebViewer->GetSetting();
5091 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
5092 __pWebViewer->SetSetting(settings);
5095 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
5097 WebSetting settings = __pWebViewer->GetSetting();
5098 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
5100 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
5104 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
5106 __pWebViewer->SetSetting(settings);
5108 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
5112 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
5113 WebSetting settings = __pWebReader->GetSetting();
5114 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
5115 __pWebReader->SetSetting(settings);
5121 MainForm::OnSettingsReset()
5125 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
5126 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
5131 MainForm::OnClearCache()
5133 result r = E_SUCCESS;
5135 if (__pWebViewer != NULL)
5137 r = __pWebViewer->ClearCache();
5140 AppLogDebug("Cache cleared success");
5144 AppLogDebug("Cache cleared fail");
5150 MainForm::OnClearCookie()
5152 result r = E_SUCCESS;
5154 if (__pWebViewer != NULL)
5156 __pWebViewer->ClearCookie();
5160 AppLogDebug("Cookie cleared success");
5164 AppLogDebug("Cache cleared fail");
5169 MainForm::OnClearFormData()
5171 result r = E_SUCCESS;
5173 if (__pWebViewer != NULL)
5175 __pWebViewer->ClearFormData();
5179 AppLogDebug("Cookie cleared success");
5183 AppLogDebug("Cache cleared fail");
5188 MainForm::OnClearPasswords()
5190 result r = E_SUCCESS;
5192 if (__pWebViewer != NULL)
5194 __pWebViewer->ClearLoginFormData();
5198 AppLogDebug("Cookie cleared success");
5202 AppLogDebug("Cache cleared fail");
5208 MainForm::findDistance(int x1,int y1,int x2, int y2)
5210 int deltaX = Math::Abs(x2 - x1);
5211 int deltaY = Math::Abs(y2 - y1);
5212 double num = deltaX*deltaX + deltaY*deltaY;
5218 for (i = 0; i < 20; i++)
5220 x = (((x*x)+ num)/(2*x));
5231 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5233 AppLog("xyz:: MainForm::OnTouchPressed called");
5234 if(__pFindWordControl)
5236 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
5237 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
5239 __isLongPressedDone = false;
5244 IList* pList = null;
5245 pList = touch.GetTouchInfoListN(source);
5249 int count = pList->GetCount();
5252 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5253 __touchPoint1 = pTouchInfo->position;
5255 /*if (__pAddressbar != null)
5257 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5259 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5261 __pAddressbar->SaveAddressbarEditText();
5263 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5266 __pAddressbar->Invalidate(true);
5268 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5270 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5272 //__pAddressbar->SaveAddressbarEditText();
5274 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5277 else if (count == 2)
5279 AppLogDebug("MainForm::OnTouchPressed count is two");
5280 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5281 __touchPoint1 = pTouchInfo->position;
5283 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
5284 __touchPoint2 = pTouchInfo->position;
5289 pList->RemoveAll(true);
5294 __pAddressbar->SetShowState(false);
5296 if(__pFooterPanel && __isKeypadOpened == false)
5298 __pFooterPanel->SetShowState(true);
5300 RelayoutControls(false);
5305 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5307 AppLog("LMN::MainForm::OnTouchMoved entered");
5308 // __currentWordIndex = 0;
5309 __isLongPressedDone = false;
5314 MainForm::MoveUiControls()
5319 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
5321 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
5323 if(__pFooterUrlField->GetTextLength() == 0)
5325 __pFooterUrlField->SetKeypadActionEnabled(false);
5329 __pFooterUrlField->SetKeypadActionEnabled(true);
5332 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
5334 __currentSearchStr = __pFindWordEditField->GetText();
5335 if (__currentSearchStr.GetLength() > 0)
5337 __pFindWordCountLabel->SetShowState(true);
5341 // __pFindWordCountLabel->SetShowState(false);
5342 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
5343 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
5346 __pFindWordNext->SetEnabled(false);
5347 __pFindWordPrev->SetEnabled(false);
5348 __pFindWordNext->Invalidate(true);
5349 __pFindWordPrev->Invalidate(true);
5350 __pFindWordCountLabel->SetText(L"0/0");
5351 __pFindWordCountLabel->Invalidate(true);
5353 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
5355 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
5356 if (__currentSearchStr.GetLength() > 0)
5358 __pFindWordCountLabelRightToLeft->SetShowState(true);
5362 __pFindWordCountLabelRightToLeft->SetShowState(false);
5365 __pFindWordNext->SetEnabled(false);
5366 __pFindWordPrev->SetEnabled(false);
5367 __pFindWordNext->Invalidate(true);
5368 __pFindWordPrev->Invalidate(true);
5369 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
5370 __pFindWordCountLabelRightToLeft->Invalidate(true);
5372 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
5373 if (__currentSearchStr.GetLength() > 0)
5379 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
5381 __currentSearchStr = L"";
5382 AppLogDebug("Enter something");
5387 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
5394 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
5396 if(__pWebViewer != null)
5399 AppLog("MainForm::InitMostVisitedSitesView");
5400 result r = E_SUCCESS;
5403 if (__pMostVisitedListView != null)
5408 if (__pMostVisitedListView != null)
5410 RemoveControl(__pMostVisitedListView);
5412 if(__pMostVisitedSites != null)
5414 __pMostVisitedSites->RemoveAll(true);
5417 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
5419 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
5420 __pMostVisitedListView = new(std::nothrow) ListView();
5422 int height = GetClientAreaBounds().height;
5424 if(__pFooterPanel->GetShowState() == true)
5426 height = height - __pFooterPanel->GetHeight();
5428 if(__pAddressbar->GetShowState() == true)
5430 height -= __pAddressbar->GetHeight();
5433 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
5437 delete __pMostVisitedListView;
5438 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
5441 __pMostVisitedListView->SetItemProvider(*this);
5442 __pMostVisitedListView->AddListViewItemEventListener(*this);
5443 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_VISITED_SITES"));
5444 AddControl(__pMostVisitedListView);
5445 __pMostVisitedListView->UpdateList();
5452 MainForm::GetImagePath(void)
5456 String formattedTime;
5457 DateTime currentTime;
5458 LocaleManager localManager;
5459 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
5461 localManager.Construct();
5462 Locale locale = localManager.GetSystemLocale();
5463 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
5465 // Get date formatter
5466 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
5470 pTimeFormatter->Format(currentTime, formattedTime);
5473 AppLog("current time stamp is %ls", formattedTime.GetPointer());
5474 String delim(L" :");
5475 StringTokenizer strTok(formattedTime, delim);
5478 String str1("GMT+00");
5479 while (strTok.HasMoreTokens())
5481 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
5482 if(token.Equals(str1))
5484 AppLog("token is %ls", token.GetPointer());
5485 imageName.Append(token);
5491 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
5493 result r = E_FAILURE;
5494 AppLog("Content manager 1");
5495 ContentId contentId;
5496 ContentManager contentManager;
5497 r = contentManager.Construct();
5500 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
5503 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
5504 Tizen::Io::Directory::Create(contentPath,true);
5505 if(GetLastResult() == E_FILE_ALREADY_EXIST)
5507 AppLog("Already exists");
5509 else if(GetLastResult() == E_SUCCESS)
5511 AppLog("created success");
5513 contentPath.Append(imageName);
5514 contentPath.Append(".jpg");
5515 contentId = contentManager.CreateContent(*aBuffer, contentPath);
5516 ShowIndicatorNotification(L"Download Complete",contentPath);
5517 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5521 MainForm::ShowIndicatorNotification(const String& messageText, const String& contentPath)
5523 AppLogDebug("ENTER");
5525 NotificationRequest request;
5526 request.SetAlertText(messageText);
5527 request.SetTitleText(L"");
5528 request.SetAppMessage(contentPath);
5529 request.SetOngoingActivityType(ONGOING_ACTIVITY_TYPE_TEXT);
5530 request.SetNotificationStyle(NOTIFICATION_STYLE_THUMBNAIL);
5531 Tizen::App::App* pApp = Tizen::App::App::GetInstance();
5532 String homePath = pApp->GetAppRootPath();
5533 String iconPath = homePath + L"res/screen-density-xhigh/Notification_download_complete.png";
5534 AppLog("The iconPath is : %ls", homePath.GetPointer());
5535 request.SetIconFilePath(iconPath);
5537 Tizen::Shell::NotificationManager notiMgr;
5538 notiMgr.Construct();
5539 notiMgr.NotifyOngoingActivity(request);
5540 AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));
5545 MainForm::SetForwardButtonEnabled(bool isEnabled)
5547 __pGoForwardBtn->SetEnabled(isEnabled);
5548 __pGoForwardBtn->Invalidate(true);
5552 MainForm::SetBackButtonEnabled(bool isEnabled)
5554 __pGoBackBtn->SetEnabled(isEnabled);
5555 __pGoBackBtn->Invalidate(true);
5559 MainForm::UpdateProgress(int percentage)
5561 __progressPercentage = percentage;
5562 if (percentage == 0 || percentage == 100)
5564 __isLoadingData = false;
5565 if (percentage == 100)
5567 __isLoadingCompleted = true;
5568 __progressPercentage = 0;
5572 __isLoadingCompleted = false;
5577 __isLoadingData = true;
5579 UpdateProgressBitmap();
5583 MainForm::GetProgress(void)
5585 return __progressPercentage;
5589 MainForm::UpdateProgressBitmap(void)
5591 result r = E_SUCCESS;
5592 if (__pProgressbarLabel == null)
5594 int w = __pProgressbarLabel->GetWidth();
5595 int h = __pProgressbarLabel->GetHeight();
5597 int progressWidth = 0;
5598 Bitmap* pRetBitmap = null;
5600 if (__progressPercentage == 0 || __progressPercentage == 100)
5602 __pProgressbarLabel->SetShowState(false);
5603 __pProgressbarLabel->Invalidate(false);
5608 __pProgressbarLabel->SetShowState(true);
5609 __pProgressbarLabel->Invalidate(false);
5612 r = canvas.Construct(Rectangle(0, 0, w, h));
5616 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5621 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5625 pBgBmp->Scale(Dimension(w, h));
5626 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5630 progressWidth = (double) (w) * __progressPercentage / 100;
5631 AppLogDebug("progressWidth: %d", progressWidth);
5632 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5634 if (pProgressBmp != null)
5636 pProgressBmp->Scale(Dimension(progressWidth, h));
5637 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5638 delete pProgressBmp;
5641 pRetBitmap = new (std::nothrow) Bitmap();
5643 if (pRetBitmap == null)
5645 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5649 pRetBitmap->Construct(canvas, canvas.GetBounds());
5651 if (__pProgressbarLabel != null && pRetBitmap != null)
5653 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5654 __pProgressbarLabel->Invalidate(false);
5657 if (pRetBitmap != null)
5666 MainForm::ReaderClicked()
5668 result r = E_SUCCESS;
5669 ArrayList* pArgList = new(std::nothrow) ArrayList();
5670 if (pArgList != null)
5672 r = pArgList->Construct();
5679 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5686 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5693 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5701 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5707 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5709 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5711 __currentAddMode = addMode;
5715 case ADDRESSBAR_MODE_INVALID:
5720 case ADDRESSBAR_MODE_READER:
5722 __pStopBtn->SetShowState(false);
5723 __pRefreshBtn->SetShowState(false);
5724 __pClearBtn->SetShowState(false);
5725 __pReaderBtn->SetShowState(false);
5728 case ADDRESSBAR_MODE_LOADING:
5730 __pRefreshBtn->SetShowState(false);
5731 __pStopBtn->SetShowState(true);
5732 __pClearBtn->SetShowState(false);
5733 __pReaderBtn->SetShowState(false);
5736 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5738 // SetUrl(__pAddressbar->GetUrl());
5740 __pRefreshBtn->SetShowState(true);
5741 __pStopBtn->SetShowState(false);
5742 __pClearBtn->SetShowState(false);
5743 __pReaderBtn->SetShowState(false);
5746 case ADDRESSBAR_MODE_EDIT:
5748 __pRefreshBtn->SetShowState(false);
5749 __pStopBtn->SetShowState(false);
5750 __pReaderBtn->SetShowState(false);
5751 __pClearBtn->SetShowState(true);
5758 OnAddressBarModeChanged();
5761 AddressBarMode MainForm::GetAddressbarMode(void)
5763 return __currentAddMode;
5766 void MainForm::SetUrl(const String& url)
5769 if(__displayUrl.GetLength() > 2048)
5770 __displayUrl.SubString(0,2048,__displayUrl);
5772 if (__pFooterUrlField != NULL)
5774 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5775 if (removedHttpUrl.IsEmpty() == false)
5777 __pFooterUrlField->SetText(removedHttpUrl);
5778 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5779 __pAddressbar->SetUrl(__displayUrl);
5783 __pFooterUrlField->SetText(__displayUrl);
5784 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5785 __pAddressbar->SetUrl(__displayUrl);
5787 if(__pFooterUrlField)
5788 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5789 __pFooterUrlField->Invalidate(false);
5790 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5791 __pAddressbar->Invalidate(true);
5792 // __pFooterUrlField->SetCursorPosition(0);
5797 MainForm::RemoveHttpTextFromDisplayURL(void)
5799 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5801 // bool isHttpText = __displayUrl.Contains(L"http://");
5802 String updatedDisplayUrl;
5803 updatedDisplayUrl.Clear();
5804 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5806 __displayUrl.SubString(7,updatedDisplayUrl);
5808 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5810 __displayUrl.SubString(8,updatedDisplayUrl);
5812 return updatedDisplayUrl;
5815 void MainForm::OnSharePopupControlStarted(void)
5817 __pWebViewer->AddTouchEventListener(*this);
5821 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5823 if (requestId == BACK_GROUND_APP_EVENT)
5825 if(__pWebViewer != null)
5827 __pWebViewer->Pause();
5831 __pImageMenu->SetShowState(false);
5833 if(__pAddressbar != null)
5835 __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5838 else if(requestId == FORE_GROUND_APP_EVENT)
5840 if(__pWebViewer != null)
5842 __pWebViewer->Resume();
5844 if(__pAddressbar != null)
5846 __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5852 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5854 AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5855 result r = E_SUCCESS;
5858 __pAddressbar->SetShowState(false);
5860 AppLog("akjshdasd 5");
5861 __pFooterPanel->SetShowState(true);
5864 __pWebViewer->SetFocus();
5865 else if(__pMostVisitedListView)
5866 __pMostVisitedListView->SetFocus();
5867 else if(__pMultiWindowButton)
5868 __pMultiWindowButton->SetFocus();
5869 else if(__pMoreButton)
5870 __pMoreButton->SetFocus();
5872 __pAddressbar->SetShowState(false);
5874 RelayoutControls(false);
5878 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5880 AppLog("MainForm::OnFormMenuRequested called");
5882 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer && __pWebViewer->GetShowState() == true)
5884 int bookmarkCount=0;
5887 url=__pWindowInfo->pageUrl;
5888 AppLog("MainForm::OnFormMenuRequested url %ls",url.GetPointer());
5889 result r = E_SUCCESS;
5890 Bitmap* pBitmap = null;
5891 String lastChar = L"";
5892 // if(url.SubString(url.GetLength()-1,lastChar));
5893 // if(lastChar == L"/")
5895 // bool exist1 = false;
5896 // bool exist2 = false;
5897 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist1);
5898 // url.SubString(0,url.GetLength() - 1,url);
5899 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist2);
5900 // exist = exist1 | exist2;
5904 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5907 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5913 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5917 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5919 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5921 if (__pOptionMenu->GetItemCount() == 9)
5923 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5927 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5932 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
5936 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
5937 if (__pOptionMenu->GetItemCount() != 9)
5939 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
5940 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
5941 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
5942 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
5943 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
5944 __pOptionMenu->SetMaxVisibleItemsCount(6);
5946 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
5948 AppLog(" Orientation landscape");
5949 __pOptionMenu->SetMaxVisibleItemsCount(5);
5953 AppLog(" Orientation potrait");
5954 __pOptionMenu->SetMaxVisibleItemsCount(6);
5957 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
5960 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
5962 __pAddressbar->SetShowState(false);
5964 __pFooterPanel->SetShowState(true);
5965 result r = __pOptionMenu->SetShowState(true);
5966 AppLog("ajsghd %s",GetErrorMessage(r));
5967 RelayoutControls(false);
5968 __pOptionMenu->Invalidate(true);
5969 __pOptionMenu->Show();