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 "IntBookmarkData.h"
30 #include "IntBookmarkPresentationModel.h"
31 #include "IntCommonLib.h"
32 #include "IntFaviconManager.h"
33 #include "IntInternetApp.h"
34 #include "IntMainForm.h"
35 #include "IntNotificationPanel.h"
36 #include "IntSceneRegister.h"
37 #include "IntSettingPresentationModel.h"
39 using namespace Tizen::App;
40 using namespace Tizen::Base;
41 using namespace Tizen::Base::Collection;
42 using namespace Tizen::Base::Runtime;
43 using namespace Tizen::Base::Utility;
44 using namespace Tizen::Graphics;
45 using namespace Tizen::Io;
46 using namespace Tizen::Locales;
47 using namespace Tizen::Media;
48 using namespace Tizen::Ui;
49 using namespace Tizen::Ui::Controls;
50 using namespace Tizen::Content;
51 using namespace Tizen::Ui::Scenes;
52 using namespace Tizen::System;
53 using namespace Tizen::Web;
54 using namespace Tizen::Web::Controls;
56 static const wchar_t* IDB_SEARCH_INPUT_FIELD_BG = L"I01_toolbar_input_field.9.png";
57 static const wchar_t* IDB_FINDWORD_INPUT_FIELD_BG = L"I01_toolbar_input_field_findword.9.png";
58 static const wchar_t* IDB_BTN_BACK = L"I01_icon_Back.png";
59 static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
60 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
61 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
62 static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
63 static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
64 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
65 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
66 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
67 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
68 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
69 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
70 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
71 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
72 static const wchar_t* IDS_APPID = L"AppID";
73 static const wchar_t* IDS_KEY = L"key";
74 static const wchar_t* IDS_VALUE = L"value";
75 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
76 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
77 //static const wchar_t* IDB_ADDRESS_BAR_BACKGROUND = L"I01_toolbar_bg_02.9.png";
79 const int IDA_BACKBTN_CLICKED = 101;
80 const int IDA_BOOKMARKBTN_CLICKED = 102;
81 const int IDA_MOREBTN_CLICKED = 103;
82 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
83 const int IDA_NEWWINDOWBTN_CLICKED = 105;
84 const int IDA_FORWARD_CLICKED = 106;
85 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
86 const int IDA_SHARE_CLICKED = 108;
87 const int IDA_FINDONPAGE_CLICKED = 109;
88 const int IDA_PRIVATEON_CLICKED = 110;
89 const int IDA_SETTINGS_CLICKED = 111;
90 const int IDA_READER_CLOSE_CLICKED = 112;
91 const int IDA_SMALLFONT_BTN_CLICKED = 113;
92 const int IDA_LARGEFONT_BTN_CLICKED = 114;
93 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
94 const int IDA_HISTORY_CLICKED = 116;
95 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
96 const int IDA_ADD_TO_HOME_CLICKED = 118;
97 const int IDA_SAVED_PAGES_CLICKED = 119;
98 const int IDA_DESKTOP_VIEW_CLICKED = 120;
99 const int IDA_SAVE_CLICKED = 121;
100 const int IDA_PRINT_CLICKED = 122;
102 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
103 const int IDA_FINDWORD_NEXT_CLICKED = 202;
104 const int IDA_FINDWORD_PREV_CLICKED = 203;
105 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
106 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
108 const int IDA_COPY_IMAGE_CLICKED = 206;
109 const int IDA_VIEW_IMAGE_CLICKED = 207;
110 const int IDA_SAVE_IMAGE_CLICKED = 208;
111 const int IDA_SHARE_IMAGE_CLICKED = 209;
113 const int IDA_COPY_TEXT_CLICKED = 210;
114 const int IDA_PASTE_TEXT_CLICKED = 211;
115 const int IDA_FIND_TEXT__CLICKED = 212;
116 const int IDA_SHARE_TEXT_CLICKED = 213;
118 const int IDA_GO_BACK = 214;
119 const int IDA_GO_FORWARD = 215;
120 const int IDA_REFRESH_BTN_CLICKED = 216;
121 const int IDA_STOP_BTN_CLICKED = 217;
122 const int IDA_CLEAR_URL = 218;
123 const int IDA_READER_BTN_CLICKED = 219;
126 const int IDA_HYPERLINK_OPEN_CLICKED = 220;
127 const int IDA_HYPERLINK_COPY_LINK_CLICKED = 221;
128 const int IDA_HYPERLINK_SAVE_IMAGE_CLICKED = 222;
129 const int IDA_HYPERLINK_SHARE_IMAGE_CLICKED = 223;
131 const int IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED = 224;
133 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
135 const int MainForm::IDA_FORMAT_BITMAP = 500;
136 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
137 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
138 const int MainForm::IDA_FORMAT_URL_STRING = 503;
139 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
141 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
142 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
143 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
145 MainForm::MainForm(void)
147 //__isLongPressedDone = false;
149 __pAddressbar = null;
150 // __pMostVisitedSitesPanel = null;
151 __pMostVisitedListView = null;
152 __pFooterPanel = null;
153 __pHitElementResult = null;
154 __pWindowInfo = null;
157 __pOptionMenu = null;
158 __pFindWordControl = null;
159 __pFindWordPanelLeftToRight = null;
160 __pFindWordPanelRightToLeft = null;
161 __pFindWordBgLabel = null;
162 __pFindWordBgLabelRightToLeft = null;
163 __pFindWordEditField = null;
164 __pFindWordEditFieldRightToLeft = null;
165 __pFindWordClear = null;
166 __pFindWordClearRightToLeft = null;
167 __pFindWordCountLabel = null;
168 __pFindWordClearRightToLeft = null;
169 __pFindWordNext = null;
170 __pFindWordPrev = null;
171 __previousZoomLevel = 1.0;
173 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
176 __currentSearchStr = L"";
177 __currentSelectedStr = L"";
178 __maxOccurrances = 0;
179 __currentWordIndex = 0;
182 //__inputEventToBeSupressed = false;
183 __isLoadingData = false;
184 __isLoadingCompleted = false;
185 __progressPercentage = 0;
186 __touchPoint1 = Point(-1,-1);
187 __touchPoint2 = Point(-1,-1);
188 __longPressPoint = Point(-1,-1);
190 // __pReaderPopup = null;
191 __pReaderData = null;
193 __pReaderCloseBtn = null;
194 //__pNewWindowButton = null;
195 __pMoreButton = null;
196 __pMultiWindowButton = null;
197 __pArticleReaderPanel = null;
198 __pBlankPanel = null;
199 __pArticleReaderLabel = null;
200 __webControlHeight = 0;
201 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
202 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
203 __pMostVisitedSites = null;
204 __pFooterUrlField = null;
206 __pGoForwardBtn = null;
207 __pRefreshBtn = null;
208 __pProgressbarLabel = null;
209 __pFooterLabel = null;
213 __isWebKeypadOpened = false;
215 __isHwKeySupported = false;
219 MainForm::~MainForm(void)
221 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
225 __pAddressbar->SetAddressbarEventListener(null);
228 if(__pHistory != null)
234 if (__pReaderData != null)
236 delete __pReaderData;
237 __pReaderData = null;
240 if (__pPopUp != null)
246 if (__pHitElementResult != null)
248 delete __pHitElementResult;
249 __pHitElementResult = null;
252 String* pSelectedScene = NULL;
253 Object* pValue = NULL;
254 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
255 pSelectedScene = (String*) pValue;
257 /*if (pSelectedScene != null)
259 delete pSelectedScene;
261 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
265 MainForm::Initialize(void)
267 InternetApp* pInternet = static_cast<InternetApp*> (Application::GetInstance());
272 __isHwKeySupported = pInternet->IsHwBackKeyExists();
274 if(__isHwKeySupported)
276 Construct(L"IDL_FORM_HW_KEY");
280 Construct(L"IDL_FORM");
282 // SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER);
287 MainForm::OnInitializing(void)
289 AppLog("get client area width = %d",GetClientAreaBounds().width);
290 AppLog("get client area height = %d",GetClientAreaBounds().height);
291 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
292 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
294 __fontSize = CommonUtil::GetFontSize();
295 Panel* pFooterPanel = null;
297 __pSaveImage = new Image();
298 __pSaveImage->Construct();
300 // Setup back event listener
301 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
302 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
303 AddOrientationEventListener(*this);
305 AppLogDebug(" MainForm::OnInitializing ended");
306 if (__pMostVisitedSites == null)
308 __pMostVisitedSites = new(std::nothrow) ArrayList();
309 __pMostVisitedSites->Construct();
311 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
313 __pItemContext= new(std::nothrow) ListContextItem();
314 __pItemContext->Construct();
315 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
316 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
318 if (pBitmapNormal != null && pBitmapPressed != null)
320 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
323 if (pBitmapNormal != null)
325 delete pBitmapNormal;
328 if (pBitmapPressed != null)
330 delete pBitmapPressed;
333 __pItemContextLandscape= new(std::nothrow) ListContextItem();
334 __pItemContextLandscape->Construct();
335 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
336 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
338 if (pBitmapNormal != null && pBitmapPressed != null)
340 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
343 if (pBitmapNormal != null)
345 delete pBitmapNormal;
348 if (pBitmapPressed != null)
350 delete pBitmapPressed;
352 SetFormMenuEventListener(this);
357 MainForm::InitAddressbar(void)
359 AppLogDebug("MainForm::InitAddressbar entered");
361 result r = E_SUCCESS;
363 if (__pAddressbar != null)
367 __pAddressbar = new(std::nothrow) Addressbar();
368 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
369 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
372 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
375 __pAddressbar->SetAddressbarEventListener(this);
376 AddControl(__pAddressbar);
377 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
378 SetControlAlwaysOnTop(*__pAddressbar, true);
379 __adressPanelPosition = __pAddressbar->GetPosition();
381 AppLogDebug("MainForm::InitAddressbar exit");
387 MainForm::CreateReaderPanel(void)
389 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
390 result r = E_FAILURE;
392 Button *pSmallFontBtn = null;
393 Button *pLargeFontBtn = null;
395 __pBlankPanel = new (std::nothrow) Panel();
396 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
398 __pArticleReaderPanel = new (std::nothrow) Panel();
399 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
401 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
402 if (__pReaderCloseBtn)
404 AppLogDebug("CreateReaderPanel() 6");
405 __pReaderCloseBtn->AddActionEventListener(*this);
406 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
409 __pWebReader = new (std::nothrow) Web();
410 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
412 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
413 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
415 r = __pWebReader->SetSetting(settings);
417 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
420 __pArticleReaderLabel = new Label();
421 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
423 __pBlankPanel->AddControl(__pArticleReaderLabel);
424 __pBlankPanel->AddControl(__pArticleReaderPanel);
425 AddControl(__pBlankPanel);
427 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
428 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
429 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
431 __pArticleReaderPanel->AddControl(__pWebReader);
432 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
433 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
434 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
436 if (pBitmap != null && pSrcBitmap != null)
438 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
440 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
442 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
445 pSmallFontBtn->AddActionEventListener(*this);
446 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
449 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
452 pLargeFontBtn->AddActionEventListener(*this);
453 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
462 if (pSrcBitmap != null)
468 SetControlAlwaysOnTop(*__pBlankPanel, true);
469 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
476 MainForm::InitWebControl()
478 AppLogDebug("MainForm::InitWebControl enter");
479 result r = E_SUCCESS;
480 AppLogDebug("InitWebControl");
482 if (__pAddressbar == null || __pFooterPanel == null)
485 const int Y_WEBCONTROL_POSITION = 0;
486 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
487 if (__pMostVisitedListView)
489 __pMostVisitedListView->SetShowState(false);
491 if (__pWebViewer != null)
493 AppLogDebug("Already initialized");
496 __pWebViewer = new(std::nothrow) Web();
497 if(__pWebViewer == NULL)
499 AppLogDebug("Initialization failed");
502 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
506 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
513 r = AddControl(__pWebViewer);
519 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
522 __webControlPosition = __pWebViewer->GetPosition();
523 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
526 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
530 __pWebViewer->SetLoadingListener(this);
531 __pWebViewer->SetWebUiEventListener(this);
532 __pWebViewer->SetWebKeypadEventListener(this);
533 __pWebViewer->SetFocus();
534 __pWebViewer->AddTouchEventListener(*this);
535 __pWebViewer->AddFocusEventListener(*this);
536 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
537 __pWebViewer->SetTextSearchListener(this);
540 AppLogDebug("MainForm :before return");
542 AppLogDebug("MainForm::InitWebControl Exit");
548 MainForm::OnFocusGained(const Control& source)
550 AppLog("MainForm::OnFocusGained");
551 RelayoutControls(false);
555 MainForm::OnFocusLost(const Control& source)
557 AppLog("MainForm::OnFocusLost");
561 MainForm::SetJavascriptEnabled()
563 WebSetting settings = __pWebViewer->GetSetting();
564 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
565 __pWebViewer->SetSetting(settings);
569 MainForm::SetImageLoadEnabled()
571 WebSetting settings = __pWebViewer->GetSetting();
572 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
573 __pWebViewer->SetSetting(settings);
577 MainForm::InitFooter(void)
579 AppLogDebug("MainForm::InitFooter entered");
580 Button* pBackButton = null;
581 Button* pBookmarkButton = null;
582 Button* pMultiWindowButton = null;
583 Bitmap *pIconBitmap = null;
584 Bitmap *pBGBitmap = null;
585 Label *pBGLabel = null;
587 if (__pFooterPanel == null)
589 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
592 if (__pFooterPanel == null)
597 SetControlAlwaysOnTop(*__pFooterPanel, true);
599 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
600 if ( __pFooterLabel == NULL )
604 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
605 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
608 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
612 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
614 if ( __pMultiWindowButton == NULL )
619 if(__isHwKeySupported == false)
621 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
623 if ( __pMoreButton == NULL )
630 SetFormBackEventListener(this);
633 if (__pMultiWindowButton != null)
635 Bitmap* pBitmap = null;
636 Bitmap* pPressedBitmap = null;
637 String imagePath = "I01_toolbar_icon_windows_manager_0";
638 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
639 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
640 imagePath.Append(totalCount);
641 imagePath.Append(".png");
643 pressedImagePath.Append(totalCount);
644 pressedImagePath.Append("_press.png");
646 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
647 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
648 if ( pBitmap == null )
653 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
656 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
657 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
662 __pMultiWindowButton->AddActionEventListener(*this);
663 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
668 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
669 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
672 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
673 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
674 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
678 __pMoreButton->AddActionEventListener(*this);
679 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
682 //Add the editfield for url
683 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
684 if (__pFooterUrlField == NULL)
686 return E_INVALID_KEY;
689 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
690 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
691 __pFooterUrlField->AddKeypadEventListener(*this);
692 __pFooterUrlField->SetPropagatedTouchEventListener(this);
694 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
696 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
698 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
700 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
704 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
705 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
709 //Add the go Back Button
710 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
711 if (__pGoBackBtn == NULL)
713 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
714 return E_INVALID_KEY;
716 __pGoBackBtn->SetActionId(IDA_GO_BACK);
717 __pGoBackBtn->AddActionEventListener(*this);
719 //Add the go forward Button
720 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
721 if (__pGoForwardBtn == NULL)
723 AppLogDebug("Control not found returning E_INVALID_KEY");
724 return E_INVALID_KEY;
726 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
727 __pGoForwardBtn->AddActionEventListener(*this);
728 if (__pWebViewer && __pWebViewer->CanGoForward())
730 SetForwardButtonEnabled(true);
734 SetForwardButtonEnabled(false);
737 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
738 if (__pRefreshBtn == NULL)
740 AppLogDebug("Control not found returning E_INVALID_KEY");
741 return E_INVALID_KEY;
744 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
745 __pRefreshBtn->AddActionEventListener(*this);
746 __pRefreshBtn->SetShowState(true);
748 //Add the backround label for displaying progressbar
749 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
750 if (__pProgressbarLabel == NULL)
752 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
753 return E_INVALID_KEY;
755 __pProgressbarLabel->SetShowState(false);
757 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
758 if (__pStopBtn == NULL)
760 AppLogDebug("Control not found returning E_INVALID_KEY");
761 return E_INVALID_KEY;
763 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
764 __pStopBtn->AddActionEventListener(*this);
765 __pStopBtn->SetShowState(false);
767 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
768 if (__pClearBtn == NULL)
770 AppLogDebug("Control not found returning E_INVALID_KEY");
771 return E_INVALID_KEY;
773 __pClearBtn->SetActionId(IDA_CLEAR_URL);
774 __pClearBtn->AddActionEventListener(*this);
775 __pClearBtn->SetShowState(false);
777 __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
778 if (__pReaderBtn == NULL)
780 AppLogDebug("Control not found returning E_INVALID_KEY");
781 return E_INVALID_KEY;
783 __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
784 __pReaderBtn->AddActionEventListener(*this);
785 __pReaderBtn->SetShowState(false);
787 // __pFooterPanel->Invalidate(true);
788 AppLogDebug("MainForm::InitFooter exit");
793 MainForm::InitOptionMenu()
795 result r = E_SUCCESS;
796 bool isPrivateBrowsing = false;
797 Bitmap* pBitmap = null;
799 if (__pOptionMenu != null)
801 __pOptionMenu->Invalidate(true);
805 __pOptionMenu = new(std::nothrow) OptionMenu();
806 r = __pOptionMenu->Construct();
807 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
809 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
812 if (isPrivateBrowsing == true)
814 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
818 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
821 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
823 if ( pBitmap != NULL)
825 __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
828 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
829 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
830 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
833 __pOptionMenu->SetMaxVisibleItemsCount(6);
834 __pOptionMenu->SetShowState(false);
835 __pOptionMenu->AddActionEventListener(*this);
836 SetControlAlwaysOnTop(*__pOptionMenu, true);
842 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
844 result r = E_SUCCESS;
845 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
847 AppLog("MainForm::InitImageContextMenu clicked on image");
848 if (__pImageMenu != null)
854 __pImageMenu = new (std::nothrow) ContextMenu();
855 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
856 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
858 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
859 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
860 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
861 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
862 __pImageMenu->SetMaxVisibleItemsCount(4);
863 __pImageMenu->AddActionEventListener(*this);
864 SetControlAlwaysOnTop(*__pImageMenu, true);
870 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
872 result r = E_SUCCESS;
873 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
875 AppLog("MainForm::InitImageContextMenu clicked on image");
876 if (__pImageMenu != null)
882 if(__pAddressbar->GetShowState() == true)
883 p.y = p.y + __pAddressbar->GetHeight();
885 __pImageMenu = new (std::nothrow) ContextMenu();
886 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
887 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
889 r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED);
890 r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,IDA_HYPERLINK_COPY_LINK_CLICKED);
891 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
892 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
894 __pImageMenu->SetMaxVisibleItemsCount(3);
895 __pImageMenu->AddActionEventListener(*this);
896 SetControlAlwaysOnTop(*__pImageMenu, true);
903 MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
905 result r = E_SUCCESS;
906 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
908 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
909 if (__pImageMenu != null)
918 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
922 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
924 __pImageMenu = new (std::nothrow) ContextMenu();
925 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
926 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
928 if(onlyPasteOption == false)
930 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
932 if (pasteOption || onlyPasteOption)
934 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
936 if(onlyPasteOption == false)
938 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
939 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
942 __pImageMenu->SetMaxVisibleItemsCount(3);
943 __pImageMenu->AddActionEventListener(*this);
944 SetControlAlwaysOnTop(*__pImageMenu, true);
951 MainForm::InitFindWordPanel(void)
953 result r = E_SUCCESS;
954 Bitmap *pIconBitmap = null;
956 if (__pFindWordControl != null)
958 AppLogDebug("Findword panel already initialized");
959 if (__pFindWordBgLabel != null)
961 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
964 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
968 if (__pFindWordBgLabelRightToLeft != null)
970 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
973 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
980 __pFindWordControl = new (std::nothrow) Panel();
981 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
984 AppLogException("There is some problem in the xml file. Please check.");
987 AddControl(__pFindWordControl);
988 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
989 SetControlAlwaysOnTop(*__pFindWordControl,true);
990 __pFindWordControl->SetShowState(false);
991 __pFindWordControl->Invalidate(false);
993 __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
994 __pFindWordPanelLeftToRight->SetShowState(true);
996 __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
997 __pFindWordPanelRightToLeft->SetShowState(false);
999 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
1000 if (__pFindWordBgLabel != null)
1002 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1003 Rectangle pRect = pPanel1->GetBounds();
1004 pRect.x = pRect.y = 0;
1005 __pFindWordBgLabel->SetBounds(pRect);
1006 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1007 if (pBitmap != null)
1009 AppLogDebug("InitFindWordPanel: Coming here");
1010 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1015 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1019 __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
1020 if (__pFindWordBgLabelRightToLeft != null)
1022 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1023 Rectangle pRect = pPanel1->GetBounds();
1024 pRect.x = pRect.y = 0;
1025 __pFindWordBgLabelRightToLeft->SetBounds(pRect);
1026 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1027 if (pBitmap != null)
1029 AppLogDebug("InitFindWordPanel: Coming here");
1030 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1035 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1039 Button* pfindWordCancel = null;
1040 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1041 if (pfindWordCancel == null)
1043 AppLogException("There is some problem in the xml file. Please check.");
1046 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1047 pfindWordCancel->AddActionEventListener(*this);
1049 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1050 if (__pFindWordClear == null)
1052 AppLogException("There is some problem in the xml file. Please check.");
1056 __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1057 if (__pFindWordClearRightToLeft == null)
1059 AppLogException("There is some problem in the xml file. Please check.");
1063 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1064 __pFindWordClear->AddActionEventListener(*this);
1066 __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1067 __pFindWordClearRightToLeft->AddActionEventListener(*this);
1069 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1070 if (__pFindWordNext == null)
1072 AppLogException("There is some problem in the xml file. Please check.");
1076 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1077 __pFindWordNext->AddActionEventListener(*this);
1079 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1080 if (__pFindWordPrev == null)
1082 AppLogException("There is some problem in the xml file. Please check.");
1086 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1087 __pFindWordPrev->AddActionEventListener(*this);
1089 __pFindWordNext->SetEnabled(false);
1090 __pFindWordPrev->SetEnabled(false);
1092 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1093 if (__pFindWordCountLabel == null)
1095 AppLogException("There is some problem in the xml file. Please check.");
1099 __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1100 if (__pFindWordCountLabel == null)
1102 AppLogException("There is some problem in the xml file. Please check.");
1106 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1107 if (__pFindWordEditField == null)
1109 AppLogException("There is some problem in the xml file. Please check.");
1112 __pFindWordEditField->AddTextEventListener(*this);
1113 __pFindWordEditField->AddKeypadEventListener(*this);
1114 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1116 __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1117 if (__pFindWordEditFieldRightToLeft == null)
1119 AppLogException("There is some problem in the xml file. Please check.");
1122 __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1123 __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1124 __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1130 MainForm::CreateItem (int index, int itemWidth)
1132 Rectangle listImageRect;
1133 Rectangle pagetTitleRect;
1134 Rectangle pageURLRect;
1135 Rectangle deleteImageRect;
1136 String pageTitle(L"");
1137 String pageURL(L"");
1138 result r = E_SUCCESS;
1139 Bitmap* pListIconImage = null;
1142 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1143 if(pHistory == null)
1147 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1148 if ( pAppResource == NULL )
1152 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1154 CustomItem* pItem = new(std::nothrow) CustomItem();
1155 pageTitle = pHistory->GetHistoryTitle();
1156 pageURL = pHistory->GetHistoryUrl();
1158 if (pageURL.GetLength() == 0)
1161 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1162 pageURL = L"<"+ nourl +">";
1166 Rectangle screenBounds = GetBounds();
1169 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1178 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1180 if ( pBitmap != NULL)
1182 pListIconImage = new Bitmap();
1183 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1187 if(pListIconImage == null)
1189 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1192 if ( pListIconImage != NULL)
1194 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2 , 72, 72);
1195 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60 + (__fontSize - 44));
1196 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1199 if (pItem != null && pListIconImage != NULL)
1201 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1205 if (pageTitle.CompareTo(L"") != 0)
1209 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1213 if (pageURL.CompareTo(L"") != 0)
1217 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1222 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1224 if ( __pItemContext!= NULL)
1228 pItem->SetContextItem(__pItemContext);
1234 if ( __pItemContextLandscape!= NULL)
1238 pItem->SetContextItem(__pItemContextLandscape);
1242 if( pListIconImage != NULL)
1244 delete pListIconImage;
1245 pListIconImage = null;
1252 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1259 MainForm::GetItemCount (void)
1261 if(__pMostVisitedSites != null)
1263 __pMostVisitedSites->RemoveAll(true);
1265 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1266 if(__pMostVisitedSites != null)
1268 return __pMostVisitedSites->GetCount();
1275 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1277 if(__pMostVisitedSites != null)
1279 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1280 if (pHistory != null)
1282 String url = pHistory->GetHistoryUrl();
1284 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1285 __pMostVisitedListView->UpdateList();
1291 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1293 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1294 String url = pHistory->GetHistoryUrl();
1302 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1308 MainForm::OnTerminating(void)
1310 result r = E_SUCCESS;
1312 RemoveOrientationEventListener(*this);
1316 __pAddressbar->SetAddressbarEventListener(null);
1321 __pWebViewer->RemoveTouchEventListener(*this);
1326 delete __pItemContext;
1328 if(__pItemContextLandscape)
1330 delete __pItemContextLandscape;
1336 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1338 result r = E_SUCCESS;
1340 AppLogDebug("Clicked : %d", actionId);
1343 case IDA_BACKBTN_CLICKED:
1345 if (__pWebViewer && __pWebViewer->CanGoBack())
1347 __pWebViewer->GoBack();
1349 else if(__pWindowInfo->isJavascriptInitiated == false)
1352 pApp = UiApp::GetInstance();
1355 r = pApp->Terminate();
1358 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1366 WindowInfo* pWindowInfo = null;
1368 SceneManager* pSceneManager = SceneManager::GetInstance();
1369 if (pSceneManager == null)
1373 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1374 if (pAllWindowList == NULL)
1376 pApp = UiApp::GetInstance();
1379 r = pApp->Terminate();
1382 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1387 if (pAllWindowList != null)
1389 totalCount = pAllWindowList->GetCount();
1391 for (int count = 0; count < totalCount; count++)
1393 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1394 if (pWindowInfo == null)
1396 pApp = UiApp::GetInstance();
1399 r = pApp->Terminate();
1402 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1409 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1411 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1414 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1417 r = pAllWindowList->RemoveAt(count, true);
1418 __pWindowInfo = null;
1421 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1426 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1430 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1432 if (pWindowInfo == null)
1434 pApp = UiApp::GetInstance();
1437 r = pApp->Terminate();
1443 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1446 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1458 case IDA_FORWARD_CLICKED:
1459 if (__pWebViewer == null)
1462 if (__pWebViewer->CanGoForward())
1464 __pWebViewer->GoForward();
1466 __pOptionMenu->SetShowState(false);
\r
1467 __pOptionMenu->Invalidate(false);
\r
1470 case IDA_FINDONPAGE_CLICKED:
1472 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1473 __currentSearchStr.Clear();
1475 InitFindWordPanel();
1476 __pOptionMenu->SetShowState(false);
\r
1477 __pOptionMenu->Invalidate(false);
\r
1479 ShowFindWordPanel(true);
1481 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1483 __pFindWordEditField->SetFocus();
1484 __pFindWordCountLabel->SetShowState(false);
1488 __pFindWordEditFieldRightToLeft->SetFocus();
1489 __pFindWordCountLabelRightToLeft->SetShowState(false);
1493 case IDA_PRIVATEON_CLICKED:
1495 result r = E_SUCCESS;
1497 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1498 Bitmap* pBitmap = null;
1499 if (isPrivateBrowsing == true)
1501 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1504 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1508 if (__pWebViewer != NULL)
1510 __pWebViewer->SetPrivateBrowsingEnabled(false);
1513 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1515 if (__pAddressbar != null)
1517 __pAddressbar->UpdateFaviconBitmap(false);
1523 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1526 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1530 if (__pWebViewer != NULL)
1532 __pWebViewer->SetPrivateBrowsingEnabled(true);
1535 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1537 if (__pAddressbar != null)
1539 __pAddressbar->UpdateFaviconBitmap(true);
1543 itemIndex = __pOptionMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
\r
1544 r = __pOptionMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
\r
1545 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
\r
1546 __pOptionMenu->Invalidate(true);
\r
1547 if ( pBitmap != NULL )
1554 case IDA_SETTINGS_CLICKED:
1557 ArrayList* pArgList = new(std::nothrow) ArrayList();
1560 pArgList->Construct();
1561 pArgList->Add(*__pWindowInfo);
1562 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1564 __pOptionMenu->SetShowState(false);
\r
1565 __pOptionMenu->Invalidate(false);
\r
1567 if (pArgList != null)
1576 case IDA_ADDTOBOOKMARK_CLICKED:
1579 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1581 int bookmarkCount=0;
1584 url=__pWindowInfo->pageUrl;
1585 result r = E_SUCCESS;
1586 Bitmap* pBitmap = null;
1587 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1595 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1596 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1597 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1599 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1600 if (pNotification != null)
1602 pNotification->SetText(message);
1603 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1604 pNotification->ShowNotification();
1609 String title=__pWindowInfo->pageTitle;
1610 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1611 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1613 pBookmark->SetBookmarkTitle(title);
1614 pBookmark->SetUrl(url);
1615 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1617 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1619 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1620 pBookmark->SetFaviconId(id);
1621 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1622 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1625 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1626 if (pNotification != null)
1628 pNotification->SetText(message);
1629 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1630 pNotification->ShowNotification();
1631 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1634 if (pBitmap != null)
\r
1636 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
\r
1641 __pOptionMenu->Invalidate(true);
\r
1646 case IDA_PRINT_CLICKED:
1648 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//data//test.pdf");
1649 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1651 AppLog("RequestPrint called!");
1652 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1653 result nResult = E_FAILURE;
1656 AppLog("TestPrint if (pAc) == true");
1661 String fileType = L"service_print_files_type";
1662 String typeVal = L"DOC";
1664 String fileCount = L"service_print_files_count";
1665 String countVal = L"1";
1666 String fileFolder= L"service_print_files_folder_name";
1667 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//data";
1669 map.Add(&fileCount, &countVal);
1670 map.Add(&fileFolder, &folderVal);
1671 map.Add(&fileType, &typeVal);
1673 String fileName = L"service_print_files_files_name";
1675 ArrayList fileNameList;
1676 fileNameList.Construct();
1677 String file1 = L"test.pdf";
1679 fileNameList.Add(&file1);
1680 map.Add(&fileName, &fileNameList);
1682 nResult = pAc->Start(NULL, NULL, &map, NULL);
1684 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1685 else if (nResult == E_MAX_EXCEEDED)
1686 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1687 else if (nResult == E_OBJ_NOT_FOUND)
1688 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1689 else if (nResult == E_IN_PROGRESS)
1690 AppLog("TestPrint ret == E_IN_PROGRESS");
1691 else if (nResult == E_PRIVILEGE_DENIED)
1692 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1693 else if(nResult == E_SYSTEM)
1694 AppLog("TestPrint ret == E_SYSTEM");
1700 int __modalMsgBoxResult;
1701 MessageBox* pMsgBox = new MessageBox();
1702 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1703 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1706 __modalMsgBoxResult = 0;
1710 case IDA_SHARE_CLICKED:
1712 if(__pPopUp != null)
1717 __pPopUp = new(std::nothrow) SharePopup();
1718 __pPopUp->Initialize();
1719 if (__pWindowInfo != null)
1721 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1722 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1723 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1724 pShareInfo->SetImageAttached(false);
1725 __pPopUp->RemoveAllShareInfo();
1726 __pPopUp->AddShareInfo(pShareInfo);
1728 __pPopUp->SetShowState(true);
1732 case IDA_BOOKMARKBTN_CLICKED:
1734 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1735 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1738 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1743 case IDA_MOREBTN_CLICKED:
1745 AppLog("IDA_MOREBTN_CLICKED");
\r
1747 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1749 int bookmarkCount=0;
1752 url=__pWindowInfo->pageUrl;
1753 result r = E_SUCCESS;
1754 Bitmap* pBitmap = null;
1756 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1759 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1764 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1768 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1770 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1772 if (__pOptionMenu->GetItemCount() == 9)
\r
1774 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
\r
1778 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
\r
1783 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1787 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1788 if (__pOptionMenu->GetItemCount() != 9)
\r
1790 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
\r
1791 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
\r
1792 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
\r
1793 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
\r
1794 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
\r
1795 __pOptionMenu->SetMaxVisibleItemsCount(6);
\r
1797 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1799 AppLog(" Orientation landscape");
1800 __pOptionMenu->SetMaxVisibleItemsCount(5);
\r
1804 AppLog(" Orientation potrait");
1805 __pOptionMenu->SetMaxVisibleItemsCount(6);
\r
1808 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1811 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1812 __pOptionMenu->SetShowState(true);
\r
1813 __pOptionMenu->Invalidate(true);
\r
1814 __pOptionMenu->Show();
\r
1818 case IDA_HISTORY_CLICKED:
1820 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1821 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1824 case IDA_SAVED_PAGES_CLICKED:
1829 case IDA_DESKTOP_VIEW_CLICKED:
1834 case IDA_SAVE_CLICKED:
1839 case IDA_MULTIWINDOWBTN_CLICKED:
1841 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1842 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1846 case IDA_NEWWINDOWBTN_CLICKED:
1848 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
1850 if (pNewWindowInfo == null)
1854 result r = E_SUCCESS;
1855 SceneManager* pSceneManager = SceneManager::GetInstance();
1857 if (pSceneManager == NULL)
1861 ArrayList* pArgList = new(std::nothrow) ArrayList();
1862 if (pArgList == NULL)
1866 r = pArgList->Construct();
1869 pArgList->Add(*pNewWindowInfo);
1870 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1876 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1881 case IDA_SMALLFONT_BTN_CLICKED:
1883 WebSetting setting = __pWebReader->GetSetting();
1884 setting.SetFontSize(15);
1885 __pWebReader->SetSetting(setting);
1888 case IDA_LARGEFONT_BTN_CLICKED:
1890 WebSetting setting = __pWebReader->GetSetting();
1891 setting.SetFontSize(25);
1892 __pWebReader->SetSetting(setting);
1895 case IDA_READER_CLOSE_CLICKED:
1897 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1899 RemoveControl(__pBlankPanel);
1900 __pArticleReaderPanel = null;
1901 __pBlankPanel = null;
1902 __pArticleReaderLabel = null;
1904 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1907 case IDA_FINDWORD_CANCEL_CLICKED:
1909 __currentSearchStr = L"";
1910 __currentWordIndex = 0;
1911 __maxOccurrances = 0;
1913 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1915 __pFindWordEditField->SetText(L"");
1916 __pFindWordCountLabel->SetText(L"0/0");
1918 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
1920 __pFindWordEditFieldRightToLeft->SetText(L"");
1921 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
1924 __pFindWordNext->SetEnabled(false);
1925 __pFindWordPrev->SetEnabled(false);
1927 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1928 AppLog("akjshdasd 1");
1929 __pFooterPanel->SetShowState(true);
1930 ShowFindWordPanel(false);
1933 case IDA_FINDWORD_SEARCH_CLICKED:
1935 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1937 __currentSearchStr = __pFindWordEditField->GetText();
1939 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
1941 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
1944 if (__currentSearchStr.GetLength() > 0)
1950 AppLogDebug("Enter something");
1954 case IDA_FINDWORD_CLEAR_CLICKED:
1956 __pFindWordCountLabel->SetText(L"0/0");
1957 __pFindWordEditField->SetText(L"");
1958 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1960 __currentSearchStr = L"";
1961 __pFindWordNext->SetEnabled(false);
1962 __pFindWordPrev->SetEnabled(false);
1963 __pFindWordCountLabel->SetShowState(false);
1964 __pFindWordControl->Invalidate(true);
1967 case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
1969 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
1970 __pFindWordEditFieldRightToLeft->SetText(L"");
1971 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1973 __currentSearchStr = L"";
1974 __pFindWordNext->SetEnabled(false);
1975 __pFindWordPrev->SetEnabled(false);
1976 __pFindWordCountLabelRightToLeft->SetShowState(false);
1977 __pFindWordControl->Invalidate(true);
1980 case IDA_FINDWORD_NEXT_CLICKED:
1985 case IDA_FINDWORD_PREV_CLICKED:
1987 FindNextWord(false);
1990 case IDA_BRIGHTNESS_BTN_CLICKED:
1992 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1993 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1996 case IDA_COPY_IMAGE_CLICKED:
1998 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1999 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2001 const Bitmap* pBitmap = null;
2002 if (__pHitElementResult != null && __pHitElementResult->HasImage())
\r
2004 pBitmap = __pHitElementResult->GetImage();
2007 String resourcePath = App::GetInstance()->GetAppResourcePath();
2008 r = item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
\r
2009 AppLog("Platofrm construct failed result %s",GetErrorMessage(r));
\r
2010 // copying the item to clipboard
2011 Clipboard* pClipboard = Clipboard::GetInstance();
2012 if (pClipboard != null)
2014 r = pClipboard->CopyItem(item);
\r
2015 AppLog("Platofrm copy failed result %s",GetErrorMessage(r));
\r
2019 case IDA_VIEW_IMAGE_CLICKED:
2021 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
2022 WindowInfo* pNewWindowInfo = null;
2023 if (__pHitElementResult != null)
2025 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2026 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2032 case IDA_SAVE_IMAGE_CLICKED:
2034 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
2035 const Bitmap* pSaveBitmap = null;
2036 String imageName = GetImagePath();
2037 AppLog("Content manager image name %ls",imageName.GetPointer());
2040 imagePath.Append(imageName);
2041 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2042 AppLog("Content manager image path %ls",imagePath.GetPointer());
2043 if (__pHitElementResult != null)
2045 pSaveBitmap = __pHitElementResult->GetImage();
2047 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2051 UpdateImageContent(pBuffer, imageName);
2053 NotificationPanel *pNotification = new NotificationPanel(*this);
2055 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2056 msg.Append(imagePath);
2057 if (pNotification != null)
2059 pNotification->SetText(msg);
2060 if (__pFooterPanel->GetShowState() == true)
2062 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2066 pNotification->SetPositionDiff(0);
2069 pNotification->ShowNotification();
2074 int __modalMsgBoxResult;
2075 MessageBox* pMsgBox = new MessageBox();
2076 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
2077 pMsgBox->ShowAndWait(__modalMsgBoxResult);
2080 __modalMsgBoxResult = 0;
2084 case IDA_SHARE_IMAGE_CLICKED:
2086 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2087 if (__pPopUp != null)
2092 __pPopUp = new(std::nothrow) SharePopup();
2093 __pPopUp->Initialize();
2094 if (__pHitElementResult != null)
2096 const Bitmap* pSaveBitmap = null;
2097 String imageName = GetImagePath();
2098 AppLog("Content manager image name %ls",imageName.GetPointer());
2101 imagePath.Append(imageName);
2102 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2103 AppLog("Content manager image path %ls",imagePath.GetPointer());
2104 if (__pHitElementResult != null)
2106 pSaveBitmap = __pHitElementResult->GetImage();
2108 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2110 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2111 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2113 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2114 pShareInfo->SetPageTitle(L"");
2115 pShareInfo->SetPageUrl(srcUrl);
2116 pShareInfo->SetImageAttached(true);
2117 pShareInfo->SetImagePath(imagePath);
2118 __pPopUp->RemoveAllShareInfo();
2119 __pPopUp->AddShareInfo(pShareInfo);
2120 __pPopUp->SetShowState(true);
2125 case IDA_HYPERLINK_OPEN_CLICKED:
2127 if (__pHitElementResult != null)
2129 String srcUrl = __pHitElementResult->GetUrl();
2131 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2133 if (pNewWindowInfo == null)
2137 result r = E_SUCCESS;
2138 SceneManager* pSceneManager = SceneManager::GetInstance();
2139 if (pSceneManager == NULL)
2143 ArrayList* pArgList = new(std::nothrow) ArrayList();
2144 if (pArgList == NULL)
2148 pArgList->Construct();
2150 pArgList->Add(*pNewWindowInfo);
2151 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2152 if (pArgList != null)
2159 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2165 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2167 if (__pHitElementResult == null)
2172 if(__pPopUp != null)
2177 __pPopUp = new(std::nothrow) SharePopup();
2178 __pPopUp->Initialize();
2180 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2181 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2182 pShareInfo->SetImageAttached(false);
2183 __pPopUp->RemoveAllShareInfo();
2184 __pPopUp->AddShareInfo(pShareInfo);
2186 __pPopUp->SetShowState(true);
2190 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2194 if (__pHitElementResult != null)
2196 url = __pHitElementResult->GetUrl();
2199 String resourcePath = App::GetInstance()->GetAppResourcePath();
2200 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2202 // copying the item to clipboard
2203 Clipboard* pClipboard = Clipboard::GetInstance();
2204 if (pClipboard != null)
2206 pClipboard->CopyItem(item);
2210 case IDA_FIND_TEXT__CLICKED:
2212 // AddressBarCancelledClicked(*__pAddressbar);
2213 RelayoutControls(false);
2214 // __pFooterPanel->SetShowState(false);
2215 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2216 __currentSearchStr.Clear();
2217 __currentSearchStr.Append(__currentSelectedStr);
2218 InitFindWordPanel();
2220 if(__pOptionMenu != null)
\r
2222 __pOptionMenu->SetShowState(false);
\r
2223 __pOptionMenu->Invalidate(false);
\r
2226 __adressPanelPosition.y = 0;
2228 if (__pAddressbar != null && __pWebViewer != NULL)
2230 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2231 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2233 if (__pFooterPanel->GetShowState() == false)
2234 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2236 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2237 __pWebViewer->Invalidate(true);
2240 ShowFindWordPanel(true);
2241 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2243 __pFindWordEditField->SetText(__currentSearchStr);
2244 __pFindWordEditField->SetFocus();
2246 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2248 __pFindWordEditFieldRightToLeft->SetText(__currentSearchStr);
2249 __pFindWordEditFieldRightToLeft->SetFocus();
2252 if (__currentSearchStr.GetLength() > 0)
2258 AppLogDebug("Enter something");
2261 if (__pWebViewer != null)
2263 // releasing the set block
2264 __pWebViewer->ReleaseBlock();
2269 case IDA_SHARE_TEXT_CLICKED:
2271 __pWebViewer->ReleaseBlock();
2272 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2273 if(__pPopUp != null)
2278 __pPopUp = new(std::nothrow) SharePopup();
2279 __pPopUp->Initialize();
2280 if (__pHitElementResult != null)
2282 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2283 pShareInfo->SetPageTitle(L"");
2284 pShareInfo->SetPageUrl(__currentSelectedStr);
2285 pShareInfo->SetImageAttached(false);
2286 __pPopUp->RemoveAllShareInfo();
2287 __pPopUp->AddShareInfo(pShareInfo);
2288 __pPopUp->SetShowState(true);
2293 case IDA_COPY_TEXT_CLICKED:
2295 __pWebViewer->ReleaseBlock();
2296 // need to implement
2297 //__currentSelectedStr
2298 // Sets data to a clip board item
2300 String resourcePath = App::GetInstance()->GetAppResourcePath();
2301 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2303 // copying the item to clipboard
2304 Clipboard* pClipboard = Clipboard::GetInstance();
2305 if (pClipboard != null)
2307 pClipboard->CopyItem(item);
2311 case IDA_PASTE_TEXT_CLICKED:
2313 Clipboard* pClipboard = Clipboard::GetInstance();
2315 if(pClipboard == null)
2319 // Retrieves a latest item
2320 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2326 //Gets data from the clipboard item
2327 String* pString = dynamic_cast<String*>(pItem->GetData());
2329 if (pString != null)
2331 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2332 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2333 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2336 if(idElement.GetLength() != 0)
2338 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; } } ";
2339 script.Append("insertAtCursor('");
2340 script.Append(idElement);
2341 script.Append("',");
2342 script.Append("\"");
2343 script.Append(*pString);
2344 script.Append("\");");
2346 else if (nameElement.GetLength() != 0)
2348 script = L"function insertAtCursor(myField, myValue) { if (document.selection) { document.getElementByName(myField)[0].focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0'){ var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length); } else { document.getElementByName(myField)[0].value += myValue; } } ";
2349 script.Append("insertAtCursor(document.getElementsByName('");
2350 script.Append(nameElement);
2351 script.Append("')[0],");
2352 script.Append("\"");
2353 script.Append(*pString);
2354 script.Append("\");");
2356 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2357 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2368 case IDA_GO_FORWARD:
2373 case IDA_REFRESH_BTN_CLICKED:
2375 __isLoadingCompleted = false;
2376 __isLoadingData = true;
2377 __progressPercentage = 0;
2378 __displayUrl = __pFooterUrlField->GetText();
2380 String url = __pFooterUrlField->GetText();
2381 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2383 if (__pWebViewer != null && __pAddressbar != null)
2385 __pWebViewer->Reload();
2386 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2390 UpdateProgressBitmap();
2393 case IDA_STOP_BTN_CLICKED:
2395 __isLoadingCompleted = false;
2396 __isLoadingData = false;
2397 __progressPercentage = 0;
2398 __pFooterUrlField->HideKeypad();
2399 __displayUrl = __pFooterUrlField->GetText();
2403 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2404 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2405 __pWebViewer->StopLoading();
2406 RequestRedraw(true);
2409 UpdateProgressBitmap();
2414 if (__pFooterUrlField->GetText().IsEmpty() == false)
2416 //__displayUrl = __pUrlField->GetText();
2417 __pFooterUrlField->Clear();
2422 case IDA_READER_BTN_CLICKED:
2433 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2435 result r = E_FAILURE;
2436 if (__pWebViewer && __pWebViewer->CanGoBack())
2438 __pWebViewer->GoBack();
2440 else if(__pWindowInfo->isJavascriptInitiated == false)
2443 pApp = UiApp::GetInstance();
2446 r = pApp->Terminate();
2449 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2457 WindowInfo* pWindowInfo = null;
2459 SceneManager* pSceneManager = SceneManager::GetInstance();
2460 if (pSceneManager == null)
2464 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2465 if (pAllWindowList == NULL)
2467 pApp = UiApp::GetInstance();
2470 r = pApp->Terminate();
2473 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2478 if (pAllWindowList != null)
2480 totalCount = pAllWindowList->GetCount();
2482 for (int count = 0; count < totalCount; count++)
2484 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2485 if (pWindowInfo == null)
2487 pApp = UiApp::GetInstance();
2490 r = pApp->Terminate();
2493 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2500 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2502 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2505 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2508 r = pAllWindowList->RemoveAt(count, true);
2509 __pWindowInfo = null;
2512 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2517 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2521 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2523 if (pWindowInfo == null)
2525 pApp = UiApp::GetInstance();
2528 r = pApp->Terminate();
2534 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2537 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2549 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2550 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2552 AppLog("MainForm::OnSceneActivatedN called");
2553 String* pSelectedScene = NULL;
2554 Object* pValue = NULL;
2555 String* pUrl = null;
2556 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2557 pSelectedScene = (String*) pValue;
2559 if (pSelectedScene != null)
2561 delete pSelectedScene;
2563 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2564 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2565 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2566 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2568 // setting the current scene ID
2569 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2571 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2573 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2575 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2576 if(__pWindowInfo == null)
2578 // if(__pWindowInfo == null)
2580 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2583 else if ( pArgs != null && pArgs->GetCount() == 1)
2585 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2591 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2593 // hiding the address bar
2594 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2595 __pAddressbar->SetShowState(false);
2596 // if(__pWebViewer != null)
2598 // __pWebViewer->Resume();
2601 if(pUrl != null && pUrl->GetLength() > 0)
2605 else if(__pWindowInfo != null)
2607 if(__pWindowInfo->pageUrl.GetLength() > 0 &&previousSceneId != IDSCN_BRIGHTNESS && previousSceneId != IDSCN_HISTORY_LIST && previousSceneId != IDSCN_MULTIPLE_WINDOW && previousSceneId != IDSCN_MULTIPLE_WINDOW_GRID && previousSceneId != IDSCN_BOOKMARK_VIEW && previousSceneId != IDSCN_SETTINGS && previousSceneId != IDSCN_MAIN_VIEW)
2609 LoadUrl(__pWindowInfo->pageUrl);
2611 else if (__pWindowInfo->isJavascriptInitiated == true)
2615 __pWindowInfo->pCurrentWeb = __pWebViewer;
2619 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2620 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2621 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2623 InitMostVisitedSitesView(GetOrientationStatus());
2625 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2627 if(__pMostVisitedListView != null)
2629 __pMostVisitedListView->SetShowState(false);
2633 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2635 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2637 if (pBookmarkUrl == null)
2639 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2640 //__pAddressbar->SetUrl(*pBookmarkUrl);
2641 SetUrl(*pBookmarkUrl);
2643 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2644 __pWebViewer->LoadUrl(*pBookmarkUrl);
2645 delete pBookmarkUrl;
2648 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2649 Bitmap* pBitmap = null;
2650 if (isPrivateBrowsing == true)
2652 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2654 if (__pWebViewer != null)
2656 __pWebViewer->SetPrivateBrowsingEnabled(true);
2659 if (__pAddressbar != null)
2661 // __pAddressbar->UpdateFaviconBitmap(true);
2667 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2669 if (__pWebViewer != null)
2671 __pWebViewer->SetPrivateBrowsingEnabled(false);
2674 if (__pAddressbar != null)
2676 // __pAddressbar->UpdateFaviconBitmap(false);
2680 if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
\r
2682 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
\r
2684 else if (__pOptionMenu != null )
\r
2686 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
\r
2689 if (pBitmap != null)
2694 AppLog("ABC: OnSceneActivatedN started exit");
2699 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2700 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2702 Canvas* pWebCanvas = null;
2703 if (__pWebViewer != null)
2705 pWebCanvas = __pWebViewer->GetCanvasN();
2708 if (pWebCanvas == null)
2712 if (__pWindowInfo != null)
2714 if (__pWindowInfo->pWebCanvasBitmap != null)
2716 delete __pWindowInfo->pWebCanvasBitmap;
2718 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2719 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2720 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2722 Bitmap* pBitmap = GetCapturedBitmapN();
2723 AppLog("Coming here");
2724 Canvas* pCanvas = new(std::nothrow) Canvas();
2725 pCanvas->Construct(GetClientAreaBounds());
2728 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2731 if(__pWebViewer != null && __pWindowInfo != null)
2732 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2734 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2735 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2737 AppLog("Coming here");
2741 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2742 const Tizen::Base::String& realm,
2743 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2749 MainForm::OnHttpAuthenticationCanceled(void)
2754 MainForm::OnLoadingStarted(void)
2756 AppLogDebug("MainForm::OnLoadingStarted entered");
2758 if(__pAddressbar == NULL || __pWebViewer == null)
2763 // this is added in case if menu is opened and user load the page
2764 if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
\r
2766 __pOptionMenu->SetShowState(false);
\r
2767 __pOptionMenu->Invalidate(true);
\r
2772 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2774 __pImageMenu->SetShowState(false);
2775 __pImageMenu->Invalidate(true);
2777 String url = __pWebViewer->GetUrl();
2778 if(url.Contains(IDS_TIZEN_SERVICE))
2781 String delim(L":;,");
2783 // Creates a StringTokenizer instance
2784 StringTokenizer strTok(url, delim);
2786 int count = strTok.GetTokenCount(); // count == 4
2788 HashMap *pMap = new HashMap();
2793 while (strTok.HasMoreTokens())
2795 AppLog("Token: %ls", token.GetPointer());
2796 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2797 if(token.Contains(IDS_APPID))
2799 token.SubString(6, appId);
2800 AppLog("AppID:%ls", appId.GetPointer());
2802 else if(token.Contains(IDS_KEY))
2804 token.SubString(4, key);
2805 AppLog("key:%ls", key.GetPointer());
2807 else if(token.Contains(IDS_VALUE))
2809 token.SubString(6, value);
2810 AppLog("value:%ls", value.GetPointer());
2813 pMap->Add(key, value);
2817 AppControl *pAppControl = null;
2818 String operationId = L"http://tizen.org/appcontrol/operation/main";
2819 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2822 AppLog("Starting AppControl");
2823 result r = pAppControl->Start(null, null, pMap, null);
2824 AppLog("Result of Start %s", GetErrorMessage(r));
2828 AppLogException("AppControl not found");
2833 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
2835 __pAddressbar->SetShowState(false);
2836 AddressBarCancelledClicked(*__pAddressbar);
2837 __pAddressbar->Invalidate(true);
2839 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2842 __pAddressbar->SetFaviconBitmap(*pBitmap);
2845 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2847 // updating the address bar position with respect to web control
2848 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2849 __distanceMoved = 0;
2853 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2854 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2855 if (__pWebViewer != null)
2857 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2858 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2859 SetUrl(__pWebViewer->GetUrl());
2860 if (__pWindowInfo != NULL)
2862 // resetting the page title to blank, it will be received in OnPageTitleReceived()
2863 __pWindowInfo->pageTitle = L"";
2864 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2866 __pAddressbar->Invalidate(true);
2872 MainForm::OnLoadingCanceled(void)
2879 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2881 AppLog("XYZ::MainForm::OnKeypadWillOpen");
2886 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2888 AppLog("XYZ::MainForm::OnKeypadOpened");
2889 __pFooterPanel->SetShowState(false);
2894 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2896 AppLog("XYZ::MainForm::OnKeypadClosed");
2897 __pFooterPanel->SetShowState(true);
2898 RelayoutControls(true);
2902 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2904 AppLog("KeypadBoundsChanged");
2905 RelayoutControls(false);
2909 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2910 const Tizen::Base::String& reason)
2912 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2916 MainForm::OnLoadingCompleted(void)
2918 AppLog("MainForm::OnLoadingCompleted start");
2920 result r = E_SUCCESS;
2922 if (__pWebViewer == null)
2927 if (__pAddressbar == null)
2931 if (__pWebViewer->CanGoForward())
2933 //__pAddressbar->SetForwardButtonEnabled(true);
2934 SetForwardButtonEnabled(true);
2938 //__pAddressbar->SetForwardButtonEnabled(false);
2939 SetForwardButtonEnabled(false);
2942 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2944 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2946 //__pAddressbar->UpdateProgress(0);
2950 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2952 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2956 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2957 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2958 if (isPrivateBrowsing == false)
2960 if(__pHistory != null)
2966 __pHistory = new(std::nothrow) History;
2967 HistoryPresentationModel::GetCurrentDateTime(date);
2970 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2971 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2973 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2974 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2976 __pHistory->SetVisitedTime(date);
2978 if (__pWebViewer != null)
2980 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2982 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2983 if (pTempBitmap != null)
2985 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2986 __pHistory->SetFavIconBitmap(*pTempBitmap);
2989 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2992 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2993 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2994 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2996 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2997 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2998 __pHistory->SetThumbnail(pBitmap);
3000 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3003 __pHistory->SetFavIconBitmap(*pFavIcon);
3007 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3014 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3016 // temperary fixed (webpage can be not loaded)
3020 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3021 if (isReaderEnabled == true)
3025 delete __pReaderData;
3026 __pReaderData = null;
3028 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3029 filePath.Append(L"data/reader.js");
3035 result r = E_SUCCESS;
3036 FileAttributes attr;
3038 File::GetAttributes(filePath,attr);
3040 r = file.Construct(filePath, L"r+");
3043 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3046 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3049 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3052 // file.Read(pScript,attr.GetFileSize());
3054 // AppLogDebug("scipt length %d",strlen(pScript));
3055 String strScript = L"";
3056 // strScript.Append(pScript);
3057 // for(int i=0; i<25; i++)
3059 file.Read(pScript,attr.GetFileSize());
3060 // AppLog("xyzz tell %d",file.Tell());
3061 // r = strScript.Append(pScript);
3062 // AppLog("xyzz append result %s",GetErrorMessage(r));
3063 // AppLog("xyzz strScript length %d",strScript.GetLength());
3065 // AppLog("xyzz final strScript length %d",strScript.GetLength());
3067 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3068 if (__pReaderData == null)
3070 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3071 __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>");
3074 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3075 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3077 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3078 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3084 AppLog("MainForm::OnLoadingCompleted done");
3088 MainForm::OnEstimatedProgress(int progress)
3090 AppLogDebug("MainForm::OnEstimatedProgress entered");
3091 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3092 progress = DEFAULT_PROGRESS_PERCENTAGE;
3094 // __pAddressbar->UpdateProgress(progress);
3095 UpdateProgress(progress);
3098 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3100 AppLog("MainForm::OnFaviconReceived");
3101 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3103 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3106 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3113 MainForm::OnUrlValueChanged(Addressbar&)
3119 MainForm::OnUrlSubmitted(Addressbar& addBar)
3121 AppLog("MainForm::OnUrlSubmitted");
3122 String url = addBar.GetUrl();
3123 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3125 if(__pFooterUrlField)
3126 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3127 AddressBarCancelledClicked(*__pAddressbar);
3132 MainForm::LoadUrl(String& url)
3136 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3137 AppLogDebug("MainForm::LoadUrl enter");
3139 if (__pWebViewer != null)
3141 __pWebViewer->SetShowState(true);
3142 __pWebViewer->Invalidate(true);
3145 if (url.CompareTo(L"") == 0)
3149 if(__pFooterPanel != null)
3151 __pFooterPanel->SetShowState(true);
3152 __pFooterPanel->Invalidate(true);
3159 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3160 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)
3162 RegularExpression firstRegex;
3163 RegularExpression secondRegex;
3165 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3166 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3169 ret = firstRegex.Match(url, false); // This returns true value
3170 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3172 if (ret == true && __pWebViewer != null)
3175 __pWebViewer->LoadUrl(url);
3177 else if(__pWebViewer != null)
3179 String tempUrl = L"http://";
3180 tempUrl.Append(url);
3184 __pWebViewer->LoadUrl(tempUrl);
3188 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3189 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3192 if (__pAddressbar != null)
3194 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3195 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3198 AppLogDebug("MainForm::LoadUrl exit");
3205 MainForm::OnStopClicked(Addressbar& addBar)
3207 AppLogDebug("MainForm::OnStopClicked called");
3210 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3211 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3212 __pWebViewer->StopLoading();
3213 RequestRedraw(true);
3218 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3220 // AppLog("MainForm::OnBackClicked");
3221 result r = E_FAILURE;
3223 if (__pWebViewer && __pWebViewer->CanGoBack())
3225 __pWebViewer->GoBack();
3227 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3230 pApp = UiApp::GetInstance();
3233 r = pApp->Terminate();
3236 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3244 WindowInfo* pWindowInfo = null;
3246 SceneManager* pSceneManager = SceneManager::GetInstance();
3247 if (pSceneManager == null)
3251 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3252 if (pAllWindowList == NULL)
3254 pApp = UiApp::GetInstance();
3257 r = pApp->Terminate();
3260 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3265 if (pAllWindowList != null)
3267 totalCount = pAllWindowList->GetCount();
3269 for (int count = 0; count < totalCount; count++)
3271 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3272 if (pWindowInfo == null)
3274 pApp = UiApp::GetInstance();
3277 r = pApp->Terminate();
3280 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3285 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3287 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3290 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3293 r = pAllWindowList->RemoveAt(count, true);
3294 __pWindowInfo = null;
3297 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3302 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3306 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3308 if (pWindowInfo == null)
3310 pApp = UiApp::GetInstance();
3313 r = pApp->Terminate();
3319 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3322 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3336 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3338 AppLog("MainForm::OnForwardClicked");
3339 if (__pWebViewer == null)
3342 if (__pWebViewer->CanGoForward())
3344 __pWebViewer->GoForward();
3349 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3351 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3352 if(__pFooterPanel != null)
3354 __pFooterPanel->SetShowState(false);
3357 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3359 __pAddressbar->SetShowState(true);
3360 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3363 RelayoutControls(false);
3367 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3369 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3371 int Height = GetClientAreaBounds().height;
3372 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3375 // __pAddressbar->SetShowState(false);
3377 if (__pFooterPanel != null && addressbarKeyPadState == false)
3379 AppLog("akjshdasd 3");
3380 __pFooterPanel->SetShowState(true);
3383 //RelayoutControls(false);
3387 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3389 AddressBarCancelledClicked(addBar);
3393 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3395 __prevAddressBarMode = __curAddressBarMode;
3397 if (__pAddressbar != null)
3399 __curAddressBarMode = GetAddressbarMode();
3402 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3404 __adressPanelPosition.y = 0;
3405 if (__pAddressbar != null)
3407 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3408 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3409 __pAddressbar->Invalidate(true);
3411 if (__pWebViewer != null)
3413 __pWebViewer->StopLoading();
3416 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3418 __adressPanelPosition.y = 0;
3419 if (__pAddressbar != null)
3421 __webControlPosition.y = 0;
3422 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3423 __pAddressbar->Invalidate(true);
3429 MainForm::OnClipboardClosed(const Addressbar& addBar)
3431 RelayoutControls(false);
3435 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3437 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3439 AppLog("akjshdasd 3");
3440 __pFooterPanel->SetShowState(true);
3443 RelayoutControls(false,footerState);
3447 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3449 RelayoutControls(false);
3453 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3455 __pFooterPanel->SetShowState(false);
3459 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3461 AppLog("KeypadBoundsChanged");
3462 RelayoutControls(false);
3466 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3468 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3471 __pWindowInfo->pageTitle = title;
3472 if (__pWebViewer != null)
3474 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3477 if (__pAddressbar != null && __pWebViewer != null)
3479 SetUrl(__pWebViewer->GetUrl());
3480 __pAddressbar->Invalidate(true);
3485 MainForm::UpdateFavicon(void)
3487 bool urlImageType = false;
3488 String *tempPath = null;
3490 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();");
3491 Bitmap* pBitmap = null;
3493 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3495 if (__pWindowInfo != null)
3498 url.SetUri(*tempPath);
3499 if (url.GetHost().GetLength() == 0)
3502 webUrl.SetUri(__pWebViewer->GetUrl());
3503 result r = url.SetHost(webUrl.GetHost());
3510 if (url.GetScheme().GetLength() == 0)
3513 webUrl.SetUri(__pWebViewer->GetUrl());
3514 url.SetScheme(webUrl.GetScheme());
3516 __pWindowInfo->faviconUrl = url.ToString();
3518 pBitmap = __pWebViewer->GetFaviconN();
3520 if (pBitmap != null)
3522 if (__pWindowInfo->pFavicon != NULL)
3524 __pWindowInfo->pFavicon = null;
3526 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3527 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3529 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3531 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3533 else if(__pWindowInfo->pFavicon != null)
3535 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3539 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3540 if(pDefaultBmp != null)
3542 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3551 if(tempPath != null)
3555 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3562 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3563 Tizen::Web::Controls::WebNavigationType type)
3565 // when load new page if find word panel is open its show state is false
3566 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3568 __currentSearchStr = L"";
3569 __currentWordIndex = 0;
3570 __maxOccurrances = 0;
3571 __pFindWordEditField->SetText(L"");
3572 __pFindWordNext->SetEnabled(false);
3573 __pFindWordPrev->SetEnabled(false);
3574 __pFindWordCountLabel->SetText(L"0/0");
3575 __pFindWordControl->SetShowState(false);
3576 __pFindWordEditField->HideKeypad();
3577 RelayoutControls(false);
3582 __pFooterPanel->Invalidate(true);
3585 uriInfo.SetUri(url);
3587 if(url.Contains(IDS_TIZEN_SERVICE))
3590 String delim(L":;,");
3592 // Creates a StringTokenizer instance
3593 StringTokenizer strTok(url, delim);
3595 int count = strTok.GetTokenCount(); // count == 4
3597 HashMap *pMap = new HashMap();
3603 while (strTok.HasMoreTokens())
3605 AppLog("Token: %ls", token.GetPointer());
3606 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3607 if(token.Contains(IDS_APPID))
3609 token.SubString(6, appId);
3610 AppLog("AppID:%ls", appId.GetPointer());
3612 else if(token.Contains(IDS_KEY))
3614 token.SubString(4, key);
3615 AppLog("key:%ls", key.GetPointer());
3617 else if(token.Contains(IDS_VALUE))
3619 token.SubString(6, value);
3620 AppLog("value:%ls", value.GetPointer());
3623 pMap->Add(key, value);
3627 AppControl *pAppControl = null;
3628 String operationId = L"http://tizen.org/appcontrol/operation/main";
3629 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3632 result r = pAppControl->Start(null, null, pMap, null);
3636 AppLogException("AppControl not found");
3646 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3647 const Tizen::Net::Http::HttpHeader& httpHeader)
3649 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3654 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3656 AppLog("MainForm::OnWebPageBlockSelected");
3657 if (__pHitElementResult != null)
3659 delete __pHitElementResult;
3660 __pHitElementResult = null;
3663 if (__pWebViewer != null)
3665 AppLog("MainForm::OnWebPageBlockSelected web not null");
3666 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3668 if(GetLastResult() == E_INVALID_ARG)
3670 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
3671 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3672 if(GetLastResult() == E_INVALID_ARG)
3674 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
3676 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
3680 if (__pHitElementResult == null)
3685 if (__pHitElementResult->HasImage() != true)
3687 String tagName = __pHitElementResult->GetTagName();
3688 String type = __pHitElementResult->GetAttributeValue("type");
3691 __currentSelectedStr.Clear();
3692 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3693 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3694 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3696 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
3698 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3700 InitSelectTextContextMenu(endPoint,true);
3701 __pImageMenu->SetShowState(true);
3702 __pImageMenu->Show();
3703 __pImageMenu->Invalidate(true);
3705 else /*if(__isLongPressedDone == true)*/
3707 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3709 if(__pHitElementResult->GetUrl().GetLength() > 0)
3711 __currentSelectedStr.Clear();
3712 __currentSelectedStr = __pHitElementResult->GetUrl();
3714 InitSelectTextContextMenu(endPoint,false);
3715 __pImageMenu->SetShowState(true);
3716 __pImageMenu->Show();
3717 __pImageMenu->Invalidate(true);
3720 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3721 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3722 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3728 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3734 MainForm::OnWebWindowCreateRequested(void)
3736 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
3738 if (pNewWindowInfo == null)
3742 result r = E_SUCCESS;
3743 SceneManager* pSceneManager = SceneManager::GetInstance();
3744 if (pSceneManager == NULL)
3748 ArrayList* pArgList = new(std::nothrow) ArrayList();
3749 if (pArgList == NULL)
3753 r = pArgList->Construct();
3756 pNewWindowInfo->isJavascriptInitiated = true;
3757 pArgList->Add(*pNewWindowInfo);
3758 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3762 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3769 return pNewWindowInfo->pCurrentWeb;
3773 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
3775 __webControlPosition.y = 0;
3776 __webControlHeight = GetClientAreaBounds().height;
3777 AppLog("Client area height: %d", __webControlHeight);
3779 AppLog("Client area height: %d", __webControlHeight);
3780 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3782 __webControlPosition.y += __pAddressbar->GetHeight();
3783 __webControlHeight -= __pAddressbar->GetHeight();
3784 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3786 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3788 __webControlPosition.y += __pFindWordControl->GetHeight();
3789 __webControlHeight -= __pFindWordControl->GetHeight();
3790 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3793 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
3795 __webControlHeight -= __pFooterPanel->GetHeight();
3797 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3799 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3801 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight + 12 )
\r
3806 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12);
\r
3807 __pWebViewer->Invalidate(false);
\r
3810 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3812 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3819 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3821 if (__pFindWordControl == null)
3826 Tizen::Locales::LocaleManager localeManager;
3827 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
3829 String languageCode;
3830 result r = SettingInfo::GetValue(L"Language", languageCode);
3831 // int languagecode = local.GetLanguageCode();
3832 AppLog("rahul language is %S", languageCode.GetPointer());
3836 InitFindWordPanel();
3838 if (languageCode.CompareTo("ara") == 0)
3840 AppLog("rahul language is arabic");
3842 __pFindWordPanelLeftToRight->SetShowState(false);
3843 __pFindWordPanelRightToLeft->SetShowState(true);
3845 __pFindWordClear->SetShowState(false);
3846 __pFindWordCountLabel->SetShowState(false);
3847 __pFindWordEditField->SetShowState(false);
3849 __pFindWordClearRightToLeft->SetShowState(true);
3850 __pFindWordCountLabelRightToLeft->SetShowState(true);
3851 __pFindWordEditFieldRightToLeft->SetShowState(true);
3855 AppLog("rahul language is not arabic");
3858 __pFindWordPanelLeftToRight->SetShowState(true);
3859 __pFindWordPanelRightToLeft->SetShowState(false);
3861 __pFindWordClear->SetShowState(true);
3862 __pFindWordCountLabel->SetShowState(true);
3863 __pFindWordEditField->SetShowState(true);
3865 __pFindWordClearRightToLeft->SetShowState(false);
3866 __pFindWordCountLabelRightToLeft->SetShowState(false);
3867 __pFindWordEditFieldRightToLeft->SetShowState(false);
3869 __pFindWordControl->SetShowState(true);
3873 if(__pFindWordControl != null)
3875 __pFindWordControl->SetShowState(false);
3879 AppLog("MainForm::ShowFindWordPanel %d",show);
3880 if (show && !isTouchPressed)
3882 if (languageCode.CompareTo("ara") == 0)
3884 if (__pFindWordEditFieldRightToLeft)
3886 __pFindWordEditFieldRightToLeft->SetFocus();
3887 __pFindWordEditFieldRightToLeft->ShowKeypad();
3892 if (__pFindWordEditField)
3894 __pFindWordEditField->SetFocus();
3895 __pFindWordEditField->ShowKeypad();
3901 if (languageCode.CompareTo("ara") == 0)
3903 if (__pFindWordEditFieldRightToLeft)
3904 __pFindWordEditFieldRightToLeft->HideKeypad();
3908 if (__pFindWordEditField)
3909 __pFindWordEditField->HideKeypad();
3913 RelayoutControls(false);
3917 MainForm::StartWordSearch()
3919 //Get the count of occurances of the word in the current page
3920 __maxOccurrances = 0;
3921 __currentWordIndex = 0;
3923 __pFindWordPrev->SetEnabled(false);
3924 String *pCountStr = null;
3925 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3926 AppLog("Search Result %s",GetErrorMessage(r));
3927 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3928 if (pCountStr != null)
3930 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3934 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3939 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3941 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3942 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3944 if(totalCount == -1 || totalCount == 0)
3946 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
3947 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3950 else if(totalCount > 100)
3952 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3953 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3957 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3958 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3961 __maxOccurrances = totalCount;
3962 __currentWordIndex = currentOrdinal;
3964 //Reset the UI controls as per the maxOccurrance value
3965 if (totalCount <= 0)
3967 AppLog("Word not found");
3968 //Show error notification to user
3969 __pFindWordNext->SetEnabled(false);
3970 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
3972 __pFindWordCountLabel->SetText(L"0/0");
3973 __pFindWordCountLabel->Invalidate(false);
3975 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
3977 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
3978 __pFindWordCountLabelRightToLeft->Invalidate(false);
3980 __pFindWordNext->Invalidate(false);
3981 __pFindWordPrev->Invalidate(false);
3986 if (totalCount == 1)
3988 __pFindWordNext->SetEnabled(false);
3992 __pFindWordNext->SetEnabled(true);
3995 String countStr = L"";
3996 countStr.Append(__currentWordIndex);
3997 countStr.Append(L"/");
3998 countStr.Append(__maxOccurrances);
3999 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4001 __pFindWordCountLabel->SetText(countStr);
4002 __pFindWordCountLabel->Invalidate(false);
4003 __pFindWordCountLabel->Invalidate(false);
4005 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4007 __pFindWordCountLabelRightToLeft->SetText(countStr);
4008 __pFindWordCountLabelRightToLeft->Invalidate(false);
4009 __pFindWordCountLabelRightToLeft->Invalidate(false);
4011 //FindNextWord(true);
4012 //Update the controls
4013 __pFindWordNext->Invalidate(false);
4014 __pFindWordPrev->Invalidate(false);
4019 MainForm::FindNextWord(bool next)
4023 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4024 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4026 if (__currentWordIndex < __maxOccurrances)
4028 __currentWordIndex++;
4034 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4035 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4037 if(__currentWordIndex > 1)
4039 __currentWordIndex--;
4044 String countStr = L"";
4045 countStr.Append(__currentWordIndex);
4046 countStr.Append(L"/");
4047 countStr.Append(__maxOccurrances);
4049 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4051 __pFindWordCountLabel->SetText(countStr);
4052 __pFindWordCountLabel->Invalidate(false);
4054 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4056 __pFindWordCountLabelRightToLeft->SetText(countStr);
4057 __pFindWordCountLabelRightToLeft->Invalidate(false);
4060 if (__currentWordIndex >= __maxOccurrances)
4062 __pFindWordNext->SetEnabled(false);
4066 __pFindWordNext->SetEnabled(true);
4068 if (__currentWordIndex <= 1)
4070 __pFindWordPrev->SetEnabled(false);
4074 __pFindWordPrev->SetEnabled(true);
4076 __pFindWordPrev->Invalidate(false);
4077 __pFindWordNext->Invalidate(false);
4079 __pFindWordControl->Invalidate(true);
4083 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4085 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4086 __isWebKeypadOpened = true;
4087 __pFooterPanel->SetShowState(false);
4088 // OnAddressBarKeypadOpened(*__pAddressbar);
4092 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4094 AppLog("xyz::MainForm::OnWebKeypadOpened");
4096 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4098 __currentSearchStr = L"";
4099 __currentWordIndex = 0;
4100 __maxOccurrances = 0;
4101 __pFindWordEditField->SetText(L"");
4102 __pFindWordNext->SetEnabled(false);
4103 __pFindWordPrev->SetEnabled(false);
4104 __pFindWordCountLabel->SetText(L"0/0");
4105 __pWebViewer->SearchTextAllAsync(L"",false);
4106 __pFindWordControl->SetShowState(false);
4107 __pFindWordEditField->HideKeypad();
4111 if (__pWebViewer != null && __pFooterPanel != null)
4113 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4114 if(__pAddressbar != null)
4116 __pAddressbar->SetShowState(false);
4118 if(__pFindWordControl != null)
4120 __pFindWordControl->SetShowState(false);
4122 __pFooterPanel->SetShowState(false);
4123 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4125 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4127 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4128 // AppLog("omgomgomg");
4134 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4136 AppLog("xyz::MainForm::OnWebKeypadClosed");
4137 AppLog("akjshdasd 4");
4138 __pFooterPanel->SetShowState(true);
4139 // OnAddressBarKeypadClosed(*__pAddressbar);
4140 RelayoutControls(false);
4141 __isWebKeypadOpened = false;
4145 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4147 // RelativeLayout(false);
\r
4148 if(__pWebViewer != null)
\r
4150 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
\r
4155 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4157 Control* temp = const_cast< Control* >(&source);
4158 Header* pHeader = dynamic_cast< Header* >(temp);
4159 if (pHeader != null)
4161 //Header double - clicked
4162 AppLog("Header double clicked");
4164 if(__pFindWordControl)
4166 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4167 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4171 AppLog("MainScene::OnTouchDoublePressed");
4175 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4177 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4178 __longPressPoint = currentPosition;
4180 if (__pHitElementResult != null)
4182 delete __pHitElementResult;
4183 __pHitElementResult = null;
4186 if (__pWebViewer != null)
4188 AppLog("MainForm::OnTouchLongPressed web not null");
4189 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4192 if (__pHitElementResult == null)
4197 if (__pHitElementResult->HasImage() == true)
4199 InitImageContextMenu(currentPosition);
4200 __pImageMenu->SetShowState(true);
4201 __pImageMenu->Show();
4202 __pImageMenu->Invalidate(true);
4204 else if(__pHitElementResult->HasUrl() == true)
4206 String tempURl = __pHitElementResult->GetUrl();
4207 AppLog("tempURl is %ls", tempURl.GetPointer());
4208 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4209 if (pBitmap != null)
4217 InitImageLinkContextMenu(currentPosition);
4218 __pImageMenu->SetShowState(true);
4219 __pImageMenu->Show();
4220 __pImageMenu->Invalidate(true);
4224 String tagName = __pHitElementResult->GetTagName();
4225 String type = __pHitElementResult->GetAttributeValue("type");
4226 String value = __pHitElementResult->GetAttributeValue(L"value");
4227 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4229 __currentSelectedStr.Clear();
4230 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4232 AppLog("tag name is %ls", tagName.GetPointer());
4233 AppLog("type is %ls", type.GetPointer());
4237 //__isLongPressedDone = true;
4238 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4239 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && innerHtml.GetLength() == 0 /*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.CompareTo(L"") == 0 && r == E_INVALID_ARG)
4241 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4243 InitSelectTextContextMenu(currentPosition,true, true);
4246 __pImageMenu->SetShowState(true);
4247 __pImageMenu->Show();
4248 __pImageMenu->Invalidate(true);
4251 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4254 // __inputEventToBeSupressed = true;
4258 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4260 AppLog("MainForm::OnTouchReleased");
4262 if (__pAddressbar && __pAddressbar->GetShowState() == true)
4264 __pAddressbar->SetShowState(false);
4268 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4269 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4271 __pWebViewer->ConsumeInputEvent();
4273 if(pHitElement != null)
4277 __inputEventToBeSupressed = false;*/
4281 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4288 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4290 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4292 __currentSearchStr = L"";
4293 __currentWordIndex = 0;
4294 __maxOccurrances = 0;
4296 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4298 __pFindWordEditField->SetText(L"");
4299 __pFindWordEditField->HideKeypad();
4300 __pFindWordControl->SetShowState(false);
4301 __pFindWordCountLabel->SetText(L"0/0");
4303 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4305 __pFindWordEditFieldRightToLeft->SetText(L"");
4306 __pFindWordEditFieldRightToLeft->HideKeypad();
4307 __pFindWordControl->SetShowState(false);
4308 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4311 __pFindWordNext->SetEnabled(false);
4312 __pFindWordPrev->SetEnabled(false);
4314 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
4315 __pFindWordControl->SetShowState(false);
4317 if(__pAddressbar->GetShowState() == false)
4319 __pAddressbar->SetAddressbarURLFocus();
4320 __pFooterPanel->SetShowState(false);
4327 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4333 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4339 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4345 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4351 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4357 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4359 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4360 int widthContextItem = 0;
4362 // As per the platform engineer comment removed this line
4363 /*if(__pWebViewer != null)
4365 // 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
4366 __pWebViewer->ReleaseBlock();
4369 // if(__pFindWordControl != null)
4370 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4371 if ( __pFooterLabel != null)
4373 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4376 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4382 if (__pFindWordBgLabel != null)
4384 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4385 if (pBitmap != null)
4387 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4392 if (__pFindWordBgLabelRightToLeft != null)
4394 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4395 if (pBitmap != null)
4397 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4403 if(__pOptionMenu != null)
\r
4404 __pOptionMenu->SetShowState(false);
\r
4406 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4408 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4412 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4417 AppLog("__pFooterPanel->GetShowState() is true");
4419 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4420 __pFooterPanel->Invalidate(true);
4424 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4425 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4427 InitMostVisitedSitesView(orientationStatus);
4430 RelayoutControls(false);
4431 if (__pArticleReaderPanel != null)
4433 if (__pArticleReaderPanel->GetShowState() == true)
4435 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4437 if (__pBlankPanel != null)
4438 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4440 if (__pWebReader != null)
4442 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4444 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4445 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4447 if ( pBitmap != null && pSrcBitmap != null)
4449 AppLog("CreateReaderPanel ninepatchbitmap found");
4450 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4453 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4454 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4455 if (pBitmap != null)
4460 if (pSrcBitmap != null)
4469 if (__pAddressbar != null)
4471 int width = GetClientAreaBounds().width;
4472 __pAddressbar->OrientationChanged(width);
4477 MainForm::OnSettingsChange(int settingvalue)
4479 AppLogDebug("MainForm::OnSettingsChange entered");
4481 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4483 __pAddressbar->ResetGuideText();
4485 if (__pWebViewer == null)
4487 AppLogDebug("Webviewer is not initialized yet.");
4491 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4493 WebSetting settings = __pWebViewer->GetSetting();
4494 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4496 settings.SetAutoFittingEnabled(true);
4498 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
4500 settings.SetAutoFittingEnabled(false);
4502 __pWebViewer->SetSetting(settings);
4504 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4506 WebSetting settings = __pWebViewer->GetSetting();
4507 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4508 __pWebViewer->SetSetting(settings);
4510 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4512 WebSetting settings = __pWebViewer->GetSetting();
4513 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4514 __pWebViewer->SetSetting(settings);
4515 __pWebViewer->Reload();
4517 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4519 WebSetting settings = __pWebViewer->GetSetting();
4520 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4521 __pWebViewer->SetSetting(settings);
4523 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4527 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4530 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
4534 WebSetting settings = __pWebViewer->GetSetting();
4535 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
4536 __pWebViewer->SetSetting(settings);
4539 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
4543 WebSetting settings = __pWebViewer->GetSetting();
4544 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
4545 __pWebViewer->SetSetting(settings);
4548 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4550 WebSetting settings = __pWebViewer->GetSetting();
4551 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4553 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4557 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4559 __pWebViewer->SetSetting(settings);
4561 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4565 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4566 WebSetting settings = __pWebReader->GetSetting();
4567 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4568 __pWebReader->SetSetting(settings);
4574 MainForm::OnSettingsReset()
4578 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4579 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4584 MainForm::OnClearCache()
4586 result r = E_SUCCESS;
4588 if (__pWebViewer != NULL)
4590 r = __pWebViewer->ClearCache();
4593 AppLogDebug("Cache cleared success");
4597 AppLogDebug("Cache cleared fail");
4603 MainForm::OnClearCookie()
4605 result r = E_SUCCESS;
4607 if (__pWebViewer != NULL)
4609 __pWebViewer->ClearCookie();
4613 AppLogDebug("Cookie cleared success");
4617 AppLogDebug("Cache cleared fail");
4622 MainForm::OnClearFormData()
4624 result r = E_SUCCESS;
4626 if (__pWebViewer != NULL)
4628 __pWebViewer->ClearFormData();
4632 AppLogDebug("Cookie cleared success");
4636 AppLogDebug("Cache cleared fail");
4641 MainForm::OnClearPasswords()
4643 result r = E_SUCCESS;
4645 if (__pWebViewer != NULL)
4647 __pWebViewer->ClearLoginFormData();
4651 AppLogDebug("Cookie cleared success");
4655 AppLogDebug("Cache cleared fail");
4661 MainForm::findDistance(int x1,int y1,int x2, int y2)
4663 int deltaX = Math::Abs(x2 - x1);
4664 int deltaY = Math::Abs(y2 - y1);
4665 double num = deltaX*deltaX + deltaY*deltaY;
4671 for (i = 0; i < 20; i++)
4673 x = (((x*x)+ num)/(2*x));
4684 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4686 if(__pFindWordControl)
4688 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4689 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4693 IList* pList = null;
4694 pList = touch.GetTouchInfoListN(source);
4698 int count = pList->GetCount();
4701 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4702 __touchPoint1 = pTouchInfo->position;
4704 /*if (__pAddressbar != null)
4706 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4708 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4710 __pAddressbar->SaveAddressbarEditText();
4712 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4715 __pAddressbar->Invalidate(true);
4717 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4719 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4721 //__pAddressbar->SaveAddressbarEditText();
4723 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4726 else if (count == 2)
4728 AppLogDebug("MainForm::OnTouchPressed count is two");
4729 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4730 __touchPoint1 = pTouchInfo->position;
4732 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4733 __touchPoint2 = pTouchInfo->position;
4738 pList->RemoveAll(true);
4741 // RelayoutControls(false);
4746 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4748 // __currentWordIndex = 0;
4749 //__isLongPressedDone = false;
4754 MainForm::MoveUiControls()
4759 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4761 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4763 if(__pFooterUrlField->GetTextLength() == 0)
4765 __pFooterUrlField->SetKeypadActionEnabled(false);
4769 __pFooterUrlField->SetKeypadActionEnabled(true);
4772 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
4774 __currentSearchStr = __pFindWordEditField->GetText();
4775 if (__currentSearchStr.GetLength() > 0)
4777 __pFindWordCountLabel->SetShowState(true);
4781 __pFindWordCountLabel->SetShowState(false);
4783 __pFindWordNext->SetEnabled(false);
4784 __pFindWordPrev->SetEnabled(false);
4785 __pFindWordNext->Invalidate(true);
4786 __pFindWordPrev->Invalidate(true);
4787 __pFindWordCountLabel->SetText(L"0/0");
4788 __pFindWordCountLabel->Invalidate(true);
4790 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
4792 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
4793 if (__currentSearchStr.GetLength() > 0)
4795 __pFindWordCountLabelRightToLeft->SetShowState(true);
4799 __pFindWordCountLabelRightToLeft->SetShowState(false);
4802 __pFindWordNext->SetEnabled(false);
4803 __pFindWordPrev->SetEnabled(false);
4804 __pFindWordNext->Invalidate(true);
4805 __pFindWordPrev->Invalidate(true);
4806 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4807 __pFindWordCountLabelRightToLeft->Invalidate(true);
4809 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4810 if (__currentSearchStr.GetLength() > 0)
4816 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4818 __currentSearchStr = L"";
4819 AppLogDebug("Enter something");
4824 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4831 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4833 if(__pWebViewer != null)
4836 AppLog("MainForm::InitMostVisitedSitesView");
4837 result r = E_SUCCESS;
4840 if (__pWebViewer != null && __pMostVisitedListView != null)
4845 if (__pMostVisitedListView != null)
4847 RemoveControl(__pMostVisitedListView);
4849 if(__pMostVisitedSites != null)
4851 __pMostVisitedSites->RemoveAll(true);
4854 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4856 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4857 __pMostVisitedListView = new(std::nothrow) ListView();
4859 int height = GetClientAreaBounds().height;
4861 if(__pFooterPanel->GetShowState() == true)
4863 height = height - __pFooterPanel->GetHeight();
4865 if(__pAddressbar->GetShowState() == true)
4867 height -= __pAddressbar->GetHeight();
4870 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4874 delete __pMostVisitedListView;
4875 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4878 __pMostVisitedListView->SetItemProvider(*this);
4879 __pMostVisitedListView->AddListViewItemEventListener(*this);
4880 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4881 AddControl(__pMostVisitedListView);
4882 __pMostVisitedListView->UpdateList();
4889 MainForm::GetImagePath(void)
4893 String formattedTime;
4894 DateTime currentTime;
4895 LocaleManager localManager;
4896 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4898 localManager.Construct();
4899 Locale locale = localManager.GetSystemLocale();
4900 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4902 // Get date formatter
4903 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4907 pTimeFormatter->Format(currentTime, formattedTime);
4910 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4911 String delim(L" :");
4912 StringTokenizer strTok(formattedTime, delim);
4915 String str1("GMT+00");
4916 while (strTok.HasMoreTokens())
4918 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4919 if(token.Equals(str1))
4921 AppLog("token is %ls", token.GetPointer());
4922 imageName.Append(token);
4928 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4930 result r = E_FAILURE;
4931 AppLog("Content manager 1");
4932 ContentId contentId;
4933 ContentManager contentManager;
4934 r = contentManager.Construct();
4937 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4940 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4941 Tizen::Io::Directory::Create(contentPath,true);
4942 if(GetLastResult() == E_FILE_ALREADY_EXIST)
4944 AppLog("Already exists");
4946 else if(GetLastResult() == E_SUCCESS)
4948 AppLog("created success");
4950 contentPath.Append(imageName);
4951 contentPath.Append(".jpg");
4952 contentId = contentManager.CreateContent(*aBuffer, contentPath);
4953 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
4957 MainForm::SetForwardButtonEnabled(bool isEnabled)
4959 __pGoForwardBtn->SetEnabled(isEnabled);
4960 __pGoForwardBtn->Invalidate(true);
4964 MainForm::SetBackButtonEnabled(bool isEnabled)
4966 __pGoBackBtn->SetEnabled(isEnabled);
4967 __pGoBackBtn->Invalidate(true);
4971 MainForm::UpdateProgress(int percentage)
4973 __progressPercentage = percentage;
4974 if (percentage == 0 || percentage == 100)
4976 __isLoadingData = false;
4977 if (percentage == 100)
4979 __isLoadingCompleted = true;
4980 __progressPercentage = 0;
4984 __isLoadingCompleted = false;
4989 __isLoadingData = true;
4991 UpdateProgressBitmap();
4995 MainForm::GetProgress(void)
4997 return __progressPercentage;
5001 MainForm::UpdateProgressBitmap(void)
5003 result r = E_SUCCESS;
5004 if (__pProgressbarLabel == null)
5006 int w = __pProgressbarLabel->GetWidth();
5007 int h = __pProgressbarLabel->GetHeight();
5009 int progressWidth = 0;
5010 Bitmap* pRetBitmap = null;
5012 if (__progressPercentage == 0 || __progressPercentage == 100)
5014 __pProgressbarLabel->SetShowState(false);
5015 __pProgressbarLabel->Invalidate(false);
5020 __pProgressbarLabel->SetShowState(true);
5021 __pProgressbarLabel->Invalidate(false);
5024 r = canvas.Construct(Rectangle(0, 0, w, h));
5028 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5033 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5037 pBgBmp->Scale(Dimension(w, h));
5038 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5042 progressWidth = (double) (w) * __progressPercentage / 100;
5043 AppLogDebug("progressWidth: %d", progressWidth);
5044 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5046 if (pProgressBmp != null)
5048 pProgressBmp->Scale(Dimension(progressWidth, h));
5049 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5050 delete pProgressBmp;
5053 pRetBitmap = new (std::nothrow) Bitmap();
5055 if (pRetBitmap == null)
5057 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5061 pRetBitmap->Construct(canvas, canvas.GetBounds());
5063 if (__pProgressbarLabel != null && pRetBitmap != null)
5065 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5066 __pProgressbarLabel->Invalidate(false);
5069 if (pRetBitmap != null)
5078 MainForm::ReaderClicked()
5080 result r = E_SUCCESS;
5081 ArrayList* pArgList = new(std::nothrow) ArrayList();
5082 if (pArgList != null)
5084 r = pArgList->Construct();
5091 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5098 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5105 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5113 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5117 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
5119 CreateReaderPanel();
5120 AppLogDebug("MainScene::ReaderClicked entered");
5123 /*if (__pArticleReaderPanel)
5125 AppLogDebug("showstate true for reader panel");
5126 __pArticleReaderPanel->SetShowState(true);
5127 __pArticleReaderPanel->Show();
5129 int xPos = __pArticleReaderPanel->GetX();
5130 int yPos = __pArticleReaderPanel->GetY();
5131 AppLog("ReaderClicked() xPos = %d",xPos);
5132 AppLog("ReaderClicked() yPos = %d",yPos);
5134 if (__pReaderData == null)
5139 String loadData = L"<html>\
5141 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
5146 background-color: transparent;\
5165 <body style='width:'";
5166 loadData.Append(bodyWidth);
5167 loadData.Append(L"px'>");
5168 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
5169 loadData.Append(*__pReaderData);
5170 loadData.Append(L"</body></html>");
5173 buf.Construct(loadData.GetLength());
5174 AppLogDebug("data->GetLength %d",loadData.GetLength());
5175 for (int z=0;z<loadData.GetLength();z++)
5178 loadData.GetCharAt(z,b);
5179 buf.SetByte((byte)b);
5183 if (__pWebReader != null)
5185 __pWebReader->LoadData(L"",buf,L"text/html");
5186 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
5190 AppLogDebug("cannot LoadData __pWebReader is null");
5195 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5197 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5199 __currentAddMode = addMode;
5203 case ADDRESSBAR_MODE_INVALID:
5208 case ADDRESSBAR_MODE_READER:
5210 __pStopBtn->SetShowState(false);
5211 __pRefreshBtn->SetShowState(false);
5212 __pClearBtn->SetShowState(false);
5213 __pReaderBtn->SetShowState(false);
5216 case ADDRESSBAR_MODE_LOADING:
5218 __pRefreshBtn->SetShowState(false);
5219 __pStopBtn->SetShowState(true);
5220 __pClearBtn->SetShowState(false);
5221 __pReaderBtn->SetShowState(false);
5224 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5226 // SetUrl(__pAddressbar->GetUrl());
5228 __pRefreshBtn->SetShowState(true);
5229 __pStopBtn->SetShowState(false);
5230 __pClearBtn->SetShowState(false);
5231 __pReaderBtn->SetShowState(false);
5234 case ADDRESSBAR_MODE_EDIT:
5236 __pRefreshBtn->SetShowState(false);
5237 __pStopBtn->SetShowState(false);
5238 __pReaderBtn->SetShowState(false);
5239 __pClearBtn->SetShowState(true);
5246 OnAddressBarModeChanged();
5249 AddressBarMode MainForm::GetAddressbarMode(void)
5251 return __currentAddMode;
5254 void MainForm::SetUrl(const String& url)
5257 if(__displayUrl.GetLength() > 2048)
5258 __displayUrl.SubString(0,2048,__displayUrl);
5260 if (__pFooterUrlField != NULL)
5262 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5263 if (removedHttpUrl.IsEmpty() == false)
5265 __pFooterUrlField->SetText(removedHttpUrl);
5266 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5267 __pAddressbar->SetUrl(__displayUrl);
5271 __pFooterUrlField->SetText(__displayUrl);
5272 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5273 __pAddressbar->SetUrl(__displayUrl);
5275 if(__pFooterUrlField)
5276 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5277 __pFooterUrlField->Invalidate(false);
5278 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5279 __pAddressbar->Invalidate(true);
5280 // __pFooterUrlField->SetCursorPosition(0);
5285 MainForm::RemoveHttpTextFromDisplayURL(void)
5287 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5289 // bool isHttpText = __displayUrl.Contains(L"http://");
5290 String updatedDisplayUrl;
5291 updatedDisplayUrl.Clear();
5292 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5294 __displayUrl.SubString(7,updatedDisplayUrl);
5296 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5298 __displayUrl.SubString(8,updatedDisplayUrl);
5300 return updatedDisplayUrl;
5303 void MainForm::OnSharePopupControlStarted(void)
5305 __pWebViewer->AddTouchEventListener(*this);
5309 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
\r
5311 if (requestId == BACK_GROUND_APP_EVENT)
5313 if(__pWebViewer != null)
5315 __pWebViewer->Pause();
5317 if(__pAddressbar != null)
\r
5319 __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
\r
5322 else if(requestId == FORE_GROUND_APP_EVENT)
5324 if(__pWebViewer != null)
5326 __pWebViewer->Resume();
5328 if(__pAddressbar != null)
\r
5330 __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
\r
5336 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5338 result r = E_SUCCESS;
5341 __pAddressbar->SetShowState(false);
5343 //AppLog("akjshdasd 5");
5344 //__pFooterPanel->SetShowState(true);
5347 __pWebViewer->SetFocus();
5348 else if(__pMostVisitedListView)
5349 __pMostVisitedListView->SetFocus();
5350 else if(__pMultiWindowButton)
5351 __pMultiWindowButton->SetFocus();
5352 else if(__pMoreButton)
5353 __pMoreButton->SetFocus();
5355 __pAddressbar->SetShowState(false);
5357 RelayoutControls(false);
5361 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5363 AppLog("MainForm::OnFormMenuRequested called");
5365 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
5367 int bookmarkCount=0;
5370 url=__pWindowInfo->pageUrl;
5371 result r = E_SUCCESS;
5372 Bitmap* pBitmap = null;
5374 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5377 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5382 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5386 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5388 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5390 if (__pOptionMenu->GetItemCount() == 9)
5392 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5396 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5401 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
5405 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
5406 if (__pOptionMenu->GetItemCount() != 9)
5408 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
5409 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
5410 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
5411 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
5412 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
5413 __pOptionMenu->SetMaxVisibleItemsCount(6);
5415 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
5417 AppLog(" Orientation landscape");
5418 __pOptionMenu->SetMaxVisibleItemsCount(5);
5422 AppLog(" Orientation potrait");
5423 __pOptionMenu->SetMaxVisibleItemsCount(6);
5426 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
5429 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
5430 __pOptionMenu->SetShowState(true);
5431 __pOptionMenu->Invalidate(true);
5432 __pOptionMenu->Show();