2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 //!Internet MainForm class
19 *@brief: The %MainForm provides the common functionalities for the Main View of the Browser including the addressbar,
20 * loading,handling events etc.
24 #include <FGraphics.h>
29 //#include <FShellNotificationManager.h>
31 #include "IntBookmarkData.h"
32 #include "IntBookmarkPresentationModel.h"
33 #include "IntCommonLib.h"
34 #include "IntFaviconManager.h"
35 #include "IntInternetApp.h"
36 #include "IntMainForm.h"
37 #include "IntSceneRegister.h"
38 #include "IntSettingPresentationModel.h"
40 using namespace Tizen::App;
41 using namespace Tizen::Base;
42 using namespace Tizen::Base::Collection;
43 using namespace Tizen::Base::Runtime;
44 using namespace Tizen::Base::Utility;
45 using namespace Tizen::Graphics;
46 using namespace Tizen::Io;
47 using namespace Tizen::Locales;
48 using namespace Tizen::Media;
49 using namespace Tizen::Shell;
50 using namespace Tizen::Ui;
51 using namespace Tizen::Ui::Controls;
52 using namespace Tizen::Content;
53 using namespace Tizen::Ui::Scenes;
54 using namespace Tizen::System;
55 using namespace Tizen::Web;
56 using namespace Tizen::Web::Controls;
58 static const wchar_t* IDB_SEARCH_INPUT_FIELD_BG = L"I01_toolbar_input_field.9.png";
59 static const wchar_t* IDB_FINDWORD_INPUT_FIELD_BG = L"I01_toolbar_input_field_findword.9.png";
60 static const wchar_t* IDB_BTN_BACK = L"I01_icon_Back.png";
61 static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
62 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
63 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
64 static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
65 static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
66 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
67 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
68 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
69 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
70 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
71 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
72 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
73 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
74 static const wchar_t* IDS_APPID = L"AppID";
75 static const wchar_t* IDS_KEY = L"key";
76 static const wchar_t* IDS_VALUE = L"value";
77 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
78 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
79 //static const wchar_t* IDB_ADDRESS_BAR_BACKGROUND = L"I01_toolbar_bg_02.9.png";
81 const int IDA_BACKBTN_CLICKED = 101;
82 const int IDA_BOOKMARKBTN_CLICKED = 102;
83 const int IDA_MOREBTN_CLICKED = 103;
84 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
85 const int IDA_NEWWINDOWBTN_CLICKED = 105;
86 const int IDA_FORWARD_CLICKED = 106;
87 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
88 const int IDA_SHARE_CLICKED = 108;
89 const int IDA_FINDONPAGE_CLICKED = 109;
90 const int IDA_PRIVATEON_CLICKED = 110;
91 const int IDA_SETTINGS_CLICKED = 111;
92 const int IDA_READER_CLOSE_CLICKED = 112;
93 const int IDA_SMALLFONT_BTN_CLICKED = 113;
94 const int IDA_LARGEFONT_BTN_CLICKED = 114;
95 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
96 const int IDA_HISTORY_CLICKED = 116;
97 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
98 const int IDA_ADD_TO_HOME_CLICKED = 118;
99 const int IDA_SAVED_PAGES_CLICKED = 119;
100 const int IDA_DESKTOP_VIEW_CLICKED = 120;
101 const int IDA_SAVE_CLICKED = 121;
102 const int IDA_PRINT_CLICKED = 122;
104 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
105 const int IDA_FINDWORD_NEXT_CLICKED = 202;
106 const int IDA_FINDWORD_PREV_CLICKED = 203;
107 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
108 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
110 const int IDA_COPY_IMAGE_CLICKED = 206;
111 const int IDA_VIEW_IMAGE_CLICKED = 207;
112 const int IDA_SAVE_IMAGE_CLICKED = 208;
113 const int IDA_SHARE_IMAGE_CLICKED = 209;
115 const int IDA_COPY_TEXT_CLICKED = 210;
116 const int IDA_PASTE_TEXT_CLICKED = 211;
117 const int IDA_FIND_TEXT__CLICKED = 212;
118 const int IDA_SHARE_TEXT_CLICKED = 213;
120 const int IDA_GO_BACK = 214;
121 const int IDA_GO_FORWARD = 215;
122 const int IDA_REFRESH_BTN_CLICKED = 216;
123 const int IDA_STOP_BTN_CLICKED = 217;
124 const int IDA_CLEAR_URL = 218;
125 const int IDA_READER_BTN_CLICKED = 219;
128 const int IDA_HYPERLINK_OPEN_CLICKED = 220;
129 const int IDA_HYPERLINK_COPY_LINK_CLICKED = 221;
130 const int IDA_HYPERLINK_SAVE_IMAGE_CLICKED = 222;
131 const int IDA_HYPERLINK_SHARE_IMAGE_CLICKED = 223;
133 const int IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED = 224;
135 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
137 const int MainForm::IDA_FORMAT_BITMAP = 500;
138 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
139 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
140 const int MainForm::IDA_FORMAT_URL_STRING = 503;
141 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
143 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
144 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
145 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
147 static const wchar_t* APPCONTROL_OPERATION_ID_IMAGE_VIEWER = L"http://tizen.org/appcontrol/operation/view";
148 MainForm::MainForm(void)
150 __isLongPressedDone = false;
152 __pAddressbar = null;
153 // __pMostVisitedSitesPanel = null;
154 __pMostVisitedListView = null;
155 __pFooterPanel = null;
156 __pHitElementResult = null;
157 __pWindowInfo = null;
160 __pOptionMenu = null;
161 __pFindWordControl = null;
162 __pFindWordPanelLeftToRight = null;
163 __pFindWordPanelRightToLeft = null;
164 __pFindWordBgLabel = null;
165 __pFindWordBgLabelRightToLeft = null;
166 __pFindWordEditField = null;
167 __pFindWordEditFieldRightToLeft = null;
168 __pFindWordClear = null;
169 __pFindWordClearRightToLeft = null;
170 __pFindWordCountLabel = null;
171 __pFindWordClearRightToLeft = null;
172 __pFindWordNext = null;
173 __pFindWordPrev = null;
174 __previousZoomLevel = 1.0;
176 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
179 __currentSearchStr = L"";
180 __currentSelectedStr = L"";
181 __maxOccurrances = 0;
182 __currentWordIndex = 0;
185 //__inputEventToBeSupressed = false;
186 __isLoadingData = false;
187 __isLoadingCompleted = false;
188 __progressPercentage = 0;
189 __touchPoint1 = Point(-1,-1);
190 __touchPoint2 = Point(-1,-1);
191 __longPressPoint = Point(-1,-1);
193 // __pReaderPopup = null;
194 __pReaderData = null;
196 __pReaderCloseBtn = null;
197 //__pNewWindowButton = null;
198 __pMoreButton = null;
199 __pMultiWindowButton = null;
200 __pArticleReaderPanel = null;
201 __pBlankPanel = null;
202 __pArticleReaderLabel = null;
203 __webControlHeight = 0;
204 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
205 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
206 __pMostVisitedSites = null;
207 __pFooterUrlField = null;
209 __pGoForwardBtn = null;
210 __pRefreshBtn = null;
211 __pProgressbarLabel = null;
212 __pFooterLabel = null;
216 __isKeypadOpened = false;
218 __pNotification = null;
221 MainForm::~MainForm(void)
223 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
227 __pAddressbar->SetAddressbarEventListener(null);
230 if(__pHistory != null)
236 if (__pReaderData != null)
238 delete __pReaderData;
239 __pReaderData = null;
242 if (__pPopUp != null)
248 if (__pHitElementResult != null)
250 delete __pHitElementResult;
251 __pHitElementResult = null;
255 delete __pOptionMenu;
256 __pOptionMenu = null;
259 String* pSelectedScene = NULL;
260 Object* pValue = NULL;
261 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
262 pSelectedScene = (String*) pValue;
264 /*if (pSelectedScene != null)
266 delete pSelectedScene;
268 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
272 MainForm::Initialize(void)
274 Construct(L"IDL_FORM");
276 // SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_FOOTER);
281 MainForm::OnInitializing(void)
283 AppLog("get client area width = %d",GetClientAreaBounds().width);
284 AppLog("get client area height = %d",GetClientAreaBounds().height);
285 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
286 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
288 __fontSize = CommonUtil::GetFontSize();
289 Panel* pFooterPanel = null;
291 __pSaveImage = new Image();
292 __pSaveImage->Construct();
294 // Setup back event listener
295 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
296 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
297 AddOrientationEventListener(*this);
299 AppLogDebug(" MainForm::OnInitializing ended");
300 if (__pMostVisitedSites == null)
302 __pMostVisitedSites = new(std::nothrow) ArrayList();
303 __pMostVisitedSites->Construct();
305 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
307 __pItemContext= new(std::nothrow) ListContextItem();
308 __pItemContext->Construct();
310 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"),true);
313 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
314 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
315 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
317 __pItemContextLandscape= new(std::nothrow) ListContextItem();
318 __pItemContextLandscape->Construct();
320 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), true);
321 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
322 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
323 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
324 SetFormMenuEventListener(this);
325 AppLog("SetFormMenuEventListener result %s",GetErrorMessage(GetLastResult()));
330 MainForm::InitAddressbar(void)
332 AppLogDebug("MainForm::InitAddressbar entered");
334 result r = E_SUCCESS;
336 if (__pAddressbar != null)
340 __pAddressbar = new(std::nothrow) Addressbar();
341 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
342 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
345 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
348 __pAddressbar->SetAddressbarEventListener(this);
349 AddControl(__pAddressbar);
350 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
351 SetControlAlwaysOnTop(*__pAddressbar, true);
352 __adressPanelPosition = __pAddressbar->GetPosition();
354 AppLogDebug("MainForm::InitAddressbar exit");
360 MainForm::CreateReaderPanel(void)
362 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
363 result r = E_FAILURE;
365 Button *pSmallFontBtn = null;
366 Button *pLargeFontBtn = null;
368 __pBlankPanel = new (std::nothrow) Panel();
369 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
371 __pArticleReaderPanel = new (std::nothrow) Panel();
372 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
374 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
375 if (__pReaderCloseBtn)
377 AppLogDebug("CreateReaderPanel() 6");
378 __pReaderCloseBtn->AddActionEventListener(*this);
379 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
382 __pWebReader = new (std::nothrow) Web();
383 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
385 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
386 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
388 r = __pWebReader->SetSetting(settings);
390 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
393 __pArticleReaderLabel = new Label();
394 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
396 __pBlankPanel->AddControl(__pArticleReaderLabel);
397 __pBlankPanel->AddControl(__pArticleReaderPanel);
398 AddControl(__pBlankPanel);
400 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
401 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
402 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
404 __pArticleReaderPanel->AddControl(__pWebReader);
405 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
406 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
407 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
409 if (pBitmap != null && pSrcBitmap != null)
411 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
413 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
415 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
418 pSmallFontBtn->AddActionEventListener(*this);
419 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
422 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
425 pLargeFontBtn->AddActionEventListener(*this);
426 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
435 if (pSrcBitmap != null)
441 SetControlAlwaysOnTop(*__pBlankPanel, true);
442 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
449 MainForm::InitWebControl()
451 AppLogDebug("MainForm::InitWebControl enter");
452 result r = E_SUCCESS;
453 AppLogDebug("InitWebControl");
455 if (__pAddressbar == null || __pFooterPanel == null)
458 const int Y_WEBCONTROL_POSITION = 0;
460 __webControlHeight = GetHeight() - __pFooterPanel->GetHeight();
462 if (__pMostVisitedListView)
464 __pMostVisitedListView->SetShowState(false);
466 if (__pWebViewer != null)
468 AppLogDebug("Already initialized");
471 __pWebViewer = new(std::nothrow) Web();
472 if(__pWebViewer == NULL)
474 AppLogDebug("Initialization failed");
477 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
481 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
488 r = AddControl(__pWebViewer);
494 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
497 __webControlPosition = __pWebViewer->GetPosition();
498 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
501 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
505 __pWebViewer->SetLoadingListener(this);
506 __pWebViewer->SetWebUiEventListenerF(this);
507 __pWebViewer->SetWebKeypadEventListener(this);
508 __pWebViewer->SetFocus();
509 __pWebViewer->AddTouchEventListener(*this);
511 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
512 __pWebViewer->SetTextSearchListener(this);
515 AppLogDebug("MainForm :before return");
517 AppLogDebug("MainForm::InitWebControl Exit");
523 MainForm::SetJavascriptEnabled()
525 WebSetting settings = __pWebViewer->GetSetting();
526 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
527 __pWebViewer->SetSetting(settings);
531 MainForm::SetImageLoadEnabled()
533 WebSetting settings = __pWebViewer->GetSetting();
534 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
535 __pWebViewer->SetSetting(settings);
539 MainForm::InitFooter(void)
541 AppLogDebug("MainForm::InitFooter entered");
542 Button* pBackButton = null;
543 Button* pBookmarkButton = null;
544 Button* pMultiWindowButton = null;
545 Bitmap *pIconBitmap = null;
546 Bitmap *pBGBitmap = null;
547 Label *pBGLabel = null;
549 if (__pFooterPanel == null)
551 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
554 if (__pFooterPanel == null)
559 SetControlAlwaysOnTop(*__pFooterPanel, true);
561 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
562 if ( __pFooterLabel == NULL )
566 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
567 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
570 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
574 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
576 if ( __pMultiWindowButton == NULL )
582 SetFormBackEventListener(this);
583 AppLog("SetFormBackEventListener result %s",GetErrorMessage(GetLastResult()));
584 if (__pMultiWindowButton != null)
586 Bitmap* pBitmap = null;
587 Bitmap* pPressedBitmap = null;
588 String imagePath = "I01_toolbar_icon_windows_manager_0";
589 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
590 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
591 imagePath.Append(totalCount);
592 imagePath.Append(".png");
594 pressedImagePath.Append(totalCount);
595 pressedImagePath.Append("_press.png");
597 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
598 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
599 if ( pBitmap == null )
604 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
607 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
608 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
613 __pMultiWindowButton->AddActionEventListener(*this);
614 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
617 delete pPressedBitmap;
618 pPressedBitmap = null;
624 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
625 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
628 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
629 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
630 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
634 __pMoreButton->AddActionEventListener(*this);
635 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
638 //Add the editfield for url
639 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
640 if (__pFooterUrlField == NULL)
642 return E_INVALID_KEY;
645 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
646 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
647 __pFooterUrlField->AddKeypadEventListener(*this);
648 __pFooterUrlField->SetPropagatedTouchEventListener(this);
649 __pFooterUrlField->AddFocusEventListener(*this);
651 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
653 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
655 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
657 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_BLANK_PAGE"));
661 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
662 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
666 //Add the go Back Button
667 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
668 if (__pGoBackBtn == NULL)
670 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
671 return E_INVALID_KEY;
673 __pGoBackBtn->SetActionId(IDA_GO_BACK);
674 __pGoBackBtn->AddActionEventListener(*this);
676 //Add the go forward Button
677 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
678 if (__pGoForwardBtn == NULL)
680 AppLogDebug("Control not found returning E_INVALID_KEY");
681 return E_INVALID_KEY;
683 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
684 __pGoForwardBtn->AddActionEventListener(*this);
685 if (__pWebViewer && __pWebViewer->CanGoForward())
687 SetForwardButtonEnabled(true);
691 SetForwardButtonEnabled(false);
694 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
695 if (__pRefreshBtn == NULL)
697 AppLogDebug("Control not found returning E_INVALID_KEY");
698 return E_INVALID_KEY;
701 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
702 __pRefreshBtn->AddActionEventListener(*this);
703 __pRefreshBtn->SetShowState(true);
705 //Add the backround label for displaying progressbar
706 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
707 if (__pProgressbarLabel == NULL)
709 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
710 return E_INVALID_KEY;
712 __pProgressbarLabel->SetShowState(false);
714 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
715 if (__pStopBtn == NULL)
717 AppLogDebug("Control not found returning E_INVALID_KEY");
718 return E_INVALID_KEY;
720 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
721 __pStopBtn->AddActionEventListener(*this);
722 __pStopBtn->SetShowState(false);
724 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
725 if (__pClearBtn == NULL)
727 AppLogDebug("Control not found returning E_INVALID_KEY");
728 return E_INVALID_KEY;
730 __pClearBtn->SetActionId(IDA_CLEAR_URL);
731 __pClearBtn->AddActionEventListener(*this);
732 __pClearBtn->SetShowState(false);
734 __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
735 if (__pReaderBtn == NULL)
737 AppLogDebug("Control not found returning E_INVALID_KEY");
738 return E_INVALID_KEY;
740 __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
741 __pReaderBtn->AddActionEventListener(*this);
742 __pReaderBtn->SetShowState(false);
744 // __pFooterPanel->Invalidate(true);
745 if(__isKeypadOpened == false && __pAddressbar && __pAddressbar->GetShowState() == false)
747 // AppLog("asdasdasdasda");
748 __pFooterPanel->SetShowState(true);
750 else if(__pAddressbar == null)
752 __pFooterPanel->SetShowState(true);
755 __pFooterPanel->SetShowState(false);
756 AppLogDebug("MainForm::InitFooter exit");
761 MainForm::InitOptionMenu()
763 result r = E_SUCCESS;
764 bool isPrivateBrowsing = false;
765 Bitmap* pBitmap = null;
767 if (__pOptionMenu != null)
769 __pOptionMenu->SetFocusable(true);
770 __pOptionMenu->Invalidate(true);
774 __pOptionMenu = new(std::nothrow) OptionMenu();
775 r = __pOptionMenu->Construct();
776 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
778 __pOptionMenu->SetFocusable(true);
779 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
782 if (isPrivateBrowsing == true)
784 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
788 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
791 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
793 if ( pBitmap != NULL)
795 __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
798 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
799 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
800 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
803 __pOptionMenu->SetMaxVisibleItemsCount(6);
804 __pOptionMenu->SetShowState(false);
805 __pOptionMenu->AddActionEventListener(*this);
806 SetControlAlwaysOnTop(*__pOptionMenu, true);
812 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
814 result r = E_SUCCESS;
815 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
817 AppLog("MainForm::InitImageContextMenu clicked on image");
818 if (__pImageMenu != null)
823 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
828 __pImageMenu = new (std::nothrow) ContextMenu();
829 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
830 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
832 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
833 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
834 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
835 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
836 __pImageMenu->SetMaxVisibleItemsCount(4);
837 __pImageMenu->AddActionEventListener(*this);
838 SetControlAlwaysOnTop(*__pImageMenu, true);
839 __pImageMenu->SetFocusable(true);
845 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
847 result r = E_SUCCESS;
848 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
850 AppLog("MainForm::InitImageContextMenu clicked on image");
851 if (__pImageMenu != null)
857 // if(__pAddressbar->GetShowState() == true)
858 // p.y = p.y + __pAddressbar->GetHeight();
859 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
864 __pImageMenu = new (std::nothrow) ContextMenu();
865 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
866 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
868 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_OPEN_IN_NEW_WINDOW"),IDA_HYPERLINK_OPEN_CLICKED);
869 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_LINK_URL"),IDA_HYPERLINK_COPY_LINK_CLICKED);
870 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
871 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
873 __pImageMenu->SetMaxVisibleItemsCount(3);
874 __pImageMenu->AddActionEventListener(*this);
875 SetControlAlwaysOnTop(*__pImageMenu, true);
876 __pImageMenu->SetFocusable(true);
883 MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOption = false)
885 result r = E_SUCCESS;
886 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
888 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
889 if (__pImageMenu != null)
898 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
902 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
904 __pImageMenu = new (std::nothrow) ContextMenu();
905 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
906 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
908 if(onlyPasteOption == false)
910 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
912 if (pasteOption || onlyPasteOption)
914 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
916 if(onlyPasteOption == false)
918 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
919 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
922 __pImageMenu->SetMaxVisibleItemsCount(3);
923 __pImageMenu->AddActionEventListener(*this);
924 SetControlAlwaysOnTop(*__pImageMenu, true);
925 __pImageMenu->SetFocusable(true);
932 MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPasteOption = false)
934 result r = E_SUCCESS;
935 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
937 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
938 if (__pImageMenu != null)
947 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
951 if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE )
953 AppLog("asdasdafdsfdgfd");
956 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
959 __pImageMenu = new (std::nothrow) ContextMenu();
960 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
961 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
963 if(onlyPasteOption == false)
965 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
967 if (pasteOption || onlyPasteOption)
969 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
971 if(onlyPasteOption == false)
973 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
974 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
977 __pImageMenu->SetMaxVisibleItemsCount(3);
978 __pImageMenu->AddActionEventListener(*this);
979 SetControlAlwaysOnTop(*__pImageMenu, true);
980 __pImageMenu->SetFocusable(true);
987 MainForm::InitFindWordPanel(void)
989 result r = E_SUCCESS;
990 Bitmap *pIconBitmap = null;
992 if (__pFindWordControl != null)
994 AppLogDebug("Findword panel already initialized");
995 if (__pFindWordBgLabel != null)
997 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1000 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1004 if (__pFindWordBgLabelRightToLeft != null)
1006 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
1007 if (pBitmap != null)
1009 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1014 __pAddressbar->SetShowState(false);
1016 if(__isKeypadOpened == false)
1017 __pFooterPanel->SetShowState(true);
1021 __pFindWordControl = new (std::nothrow) Panel();
1022 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
1025 AppLogException("There is some problem in the xml file. Please check.");
1028 AddControl(__pFindWordControl);
1029 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
1030 SetControlAlwaysOnTop(*__pFindWordControl,true);
1031 __pFindWordControl->SetShowState(false);
1032 __pFindWordControl->Invalidate(false);
1034 __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1035 __pFindWordPanelLeftToRight->SetShowState(true);
1037 __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
1038 __pFindWordPanelRightToLeft->SetShowState(false);
1040 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
1041 if (__pFindWordBgLabel != null)
1043 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1044 Rectangle pRect = pPanel1->GetBounds();
1045 pRect.x = pRect.y = 0;
1046 __pFindWordBgLabel->SetBounds(pRect);
1047 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1048 if (pBitmap != null)
1050 AppLogDebug("InitFindWordPanel: Coming here");
1051 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1056 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1060 __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
1061 if (__pFindWordBgLabelRightToLeft != null)
1063 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1064 Rectangle pRect = pPanel1->GetBounds();
1065 pRect.x = pRect.y = 0;
1066 __pFindWordBgLabelRightToLeft->SetBounds(pRect);
1067 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1068 if (pBitmap != null)
1070 AppLogDebug("InitFindWordPanel: Coming here");
1071 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1076 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1080 Button* pfindWordCancel = null;
1081 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1082 if (pfindWordCancel == null)
1084 AppLogException("There is some problem in the xml file. Please check.");
1087 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1088 pfindWordCancel->AddActionEventListener(*this);
1090 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1091 if (__pFindWordClear == null)
1093 AppLogException("There is some problem in the xml file. Please check.");
1097 __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1098 if (__pFindWordClearRightToLeft == null)
1100 AppLogException("There is some problem in the xml file. Please check.");
1104 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1105 __pFindWordClear->AddActionEventListener(*this);
1107 __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1108 __pFindWordClearRightToLeft->AddActionEventListener(*this);
1110 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1111 if (__pFindWordNext == null)
1113 AppLogException("There is some problem in the xml file. Please check.");
1117 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1118 __pFindWordNext->AddActionEventListener(*this);
1120 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1121 if (__pFindWordPrev == null)
1123 AppLogException("There is some problem in the xml file. Please check.");
1127 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1128 __pFindWordPrev->AddActionEventListener(*this);
1130 __pFindWordNext->SetEnabled(false);
1131 __pFindWordPrev->SetEnabled(false);
1133 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1134 if (__pFindWordCountLabel == null)
1136 AppLogException("There is some problem in the xml file. Please check.");
1140 __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1141 if (__pFindWordCountLabelRightToLeft == null)
1143 AppLogException("There is some problem in the xml file. Please check.");
1147 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1148 if (__pFindWordEditField == null)
1150 AppLogException("There is some problem in the xml file. Please check.");
1153 __pFindWordEditField->AddTextEventListener(*this);
1154 __pFindWordEditField->AddKeypadEventListener(*this);
1155 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1156 __pFindWordEditField->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1158 __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1159 if (__pFindWordEditFieldRightToLeft == null)
1161 AppLogException("There is some problem in the xml file. Please check.");
1164 __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1165 __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1166 __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1167 __pFindWordEditFieldRightToLeft->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1170 __pAddressbar->SetShowState(false);
1172 if(__isKeypadOpened == false)
1173 __pFooterPanel->SetShowState(true);
1178 MainForm::CreateItem (int index, int itemWidth)
1180 Rectangle listImageRect;
1181 Rectangle pagetTitleRect;
1182 Rectangle pageURLRect;
1183 Rectangle deleteImageRect;
1184 String pageTitle(L"");
1185 String pageURL(L"");
1186 result r = E_SUCCESS;
1187 Bitmap* pListIconImage = null;
1190 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1191 if(pHistory == null)
1195 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1196 if ( pAppResource == NULL )
1200 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1202 CustomItem* pItem = new(std::nothrow) CustomItem();
1203 pageTitle = pHistory->GetHistoryTitle();
1204 pageURL = pHistory->GetHistoryUrl();
1206 if (pageURL.GetLength() == 0)
1209 pAppResource->GetString(L"IDS_BR_BODY_BLANK_PAGE", nourl);
1210 pageURL = L"<"+ nourl +">";
1214 Rectangle screenBounds = GetBounds();
1217 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1226 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1228 if ( pBitmap != NULL)
1230 pListIconImage = new Bitmap();
1231 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1235 if(pListIconImage == null)
1237 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1240 if ( pListIconImage != NULL)
1242 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2 , 72, 72);
1243 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 72 + (__fontSize - 44));
1244 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1247 if (pItem != null && pListIconImage != NULL)
1249 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1253 if (pageTitle.CompareTo(L"") != 0)
1257 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1261 if (pageURL.CompareTo(L"") != 0)
1265 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1270 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1272 if ( __pItemContext!= NULL)
1276 pItem->SetContextItem(__pItemContext);
1282 if ( __pItemContextLandscape!= NULL)
1286 pItem->SetContextItem(__pItemContextLandscape);
1290 if( pListIconImage != NULL)
1292 delete pListIconImage;
1293 pListIconImage = null;
1300 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1307 MainForm::GetItemCount (void)
1309 if(__pMostVisitedSites != null)
1311 __pMostVisitedSites->RemoveAll(true);
1313 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1314 if(__pMostVisitedSites != null)
1316 return __pMostVisitedSites->GetCount();
1323 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1325 AppLog("MainForm::OnListViewContextItemStateChanged called");
1326 if(__pMostVisitedSites != null)
1328 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1329 if (pHistory != null)
1331 String url = pHistory->GetHistoryUrl();
1333 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1334 __pMostVisitedListView->UpdateList();
1340 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1342 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1343 String url = pHistory->GetHistoryUrl();
1351 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1357 MainForm::OnTerminating(void)
1359 result r = E_SUCCESS;
1361 RemoveOrientationEventListener(*this);
1365 __pAddressbar->SetAddressbarEventListener(null);
1370 __pWebViewer->RemoveTouchEventListener(*this);
1371 __pWebViewer->SetWebUiEventListenerF(null);
1372 __pWebViewer->SetWebKeypadEventListener(null);
1373 __pWebViewer->SetTextSearchListener(null);
1379 delete __pItemContext;
1381 if (__pItemContextLandscape)
1383 delete __pItemContextLandscape;
1387 delete __pSaveImage;
1389 if (__pMostVisitedSites)
1391 __pMostVisitedSites->RemoveAll(true);
1392 delete __pMostVisitedSites;
1398 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1400 result r = E_SUCCESS;
1402 AppLogDebug("Clicked : %d", actionId);
1405 case IDA_BACKBTN_CLICKED:
1407 if(__pImageMenu && __pImageMenu->GetShowState() == true)
1409 AppLog("Hiding the menu");
1410 __pImageMenu->SetShowState(false);
1412 if (__pWebViewer && __pWebViewer->CanGoBack())
1414 __pWebViewer->GoBack();
1416 else if(__pWindowInfo->isJavascriptInitiated == false)
1419 pApp = UiApp::GetInstance();
1422 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1425 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1433 WindowInfo* pWindowInfo = null;
1435 SceneManager* pSceneManager = SceneManager::GetInstance();
1436 if (pSceneManager == null)
1440 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1441 if (pAllWindowList == NULL)
1443 pApp = UiApp::GetInstance();
1446 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1449 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1454 if (pAllWindowList != null)
1456 totalCount = pAllWindowList->GetCount();
1458 for (int count = 0; count < totalCount; count++)
1460 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1461 if (pWindowInfo == null)
1463 pApp = UiApp::GetInstance();
1466 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1469 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1476 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1478 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1481 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1484 r = pAllWindowList->RemoveAt(count, true);
1485 __pWindowInfo = null;
1488 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1493 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1497 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1499 if (pWindowInfo == null)
1501 pApp = UiApp::GetInstance();
1504 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1510 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1513 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1525 case IDA_FORWARD_CLICKED:
1526 if (__pWebViewer == null)
1529 if (__pWebViewer->CanGoForward())
1531 __pWebViewer->GoForward();
1533 __pOptionMenu->SetShowState(false);
1534 __pOptionMenu->Invalidate(false);
1537 case IDA_FINDONPAGE_CLICKED:
1539 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1540 __currentSearchStr.Clear();
1542 InitFindWordPanel();
1543 __pOptionMenu->SetShowState(false);
1544 __pOptionMenu->Invalidate(false);
1546 ShowFindWordPanel(true);
1548 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1550 __pFindWordEditField->SetFocus();
1551 // __pFindWordCountLabel->SetShowState(false);
1555 __pFindWordEditFieldRightToLeft->SetFocus();
1556 __pFindWordCountLabelRightToLeft->SetShowState(false);
1560 case IDA_PRIVATEON_CLICKED:
1562 result r = E_SUCCESS;
1564 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1565 Bitmap* pBitmap = null;
1566 if (isPrivateBrowsing == true)
1568 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1571 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1575 if (__pWebViewer != NULL)
1577 __pWebViewer->SetPrivateBrowsingEnabled(false);
1580 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1582 if (__pAddressbar != null)
1584 __pAddressbar->UpdateFaviconBitmap(false);
1590 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1593 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1597 if (__pWebViewer != NULL)
1599 __pWebViewer->SetPrivateBrowsingEnabled(true);
1602 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1604 if (__pAddressbar != null)
1606 __pAddressbar->UpdateFaviconBitmap(true);
1610 itemIndex = __pOptionMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1611 r = __pOptionMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1612 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1613 __pOptionMenu->Invalidate(true);
1614 if ( pBitmap != NULL )
1621 case IDA_SETTINGS_CLICKED:
1624 ArrayList* pArgList = new(std::nothrow) ArrayList();
1627 pArgList->Construct();
1628 pArgList->Add(*__pWindowInfo);
1629 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1631 __pOptionMenu->SetShowState(false);
1632 __pOptionMenu->Invalidate(false);
1634 if (pArgList != null)
1643 case IDA_ADDTOBOOKMARK_CLICKED:
1646 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1648 int bookmarkCount=0;
1651 url=__pWindowInfo->pageUrl;
1652 result r = E_SUCCESS;
1653 Bitmap* pBitmap = null;
1654 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1662 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1663 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1664 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1666 if(__pNotification != null)
1668 RemoveControl(__pNotification);
1669 __pNotification = null;
1671 __pNotification = new (std::nothrow) NotificationPanel(*this);
1672 if (__pNotification != null)
1674 __pNotification->SetText(message);
1675 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1676 __pNotification->ShowNotification();
1681 String title=__pWindowInfo->pageTitle;
1682 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1683 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1685 pBookmark->SetBookmarkTitle(title);
1686 pBookmark->SetUrl(url);
1687 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1689 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1691 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1692 pBookmark->SetFaviconId(id);
1693 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1694 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1696 if(__pNotification != null)
1698 RemoveControl(__pNotification);
1699 __pNotification = null;
1701 __pNotification = new (std::nothrow) NotificationPanel(*this);
1702 if (__pNotification != null)
1704 __pNotification->SetText(message);
1705 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1706 __pNotification->ShowNotification();
1707 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1710 if (pBitmap != null)
1712 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1717 __pOptionMenu->Invalidate(true);
1722 case IDA_PRINT_CLICKED:
1724 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//shared//data//test.pdf");
1725 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1727 AppLog("RequestPrint called!");
1728 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1729 result nResult = E_FAILURE;
1732 AppLog("TestPrint if (pAc) == true");
1737 String fileType = L"service_print_files_type";
1738 String typeVal = L"DOC";
1740 String fileCount = L"service_print_files_count";
1741 String countVal = L"1";
1742 String fileFolder= L"service_print_files_folder_name";
1743 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//shared//data";
1745 map.Add(&fileCount, &countVal);
1746 map.Add(&fileFolder, &folderVal);
1747 map.Add(&fileType, &typeVal);
1749 String fileName = L"service_print_files_files_name";
1751 ArrayList fileNameList;
1752 fileNameList.Construct();
1753 String file1 = L"test.pdf";
1755 fileNameList.Add(&file1);
1756 map.Add(&fileName, &fileNameList);
1758 nResult = pAc->Start(NULL, NULL, &map, NULL);
1760 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1761 else if (nResult == E_MAX_EXCEEDED)
1762 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1763 else if (nResult == E_OBJ_NOT_FOUND)
1764 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1765 else if (nResult == E_IN_PROGRESS)
1766 AppLog("TestPrint ret == E_IN_PROGRESS");
1767 else if (nResult == E_PRIVILEGE_DENIED)
1768 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1769 else if(nResult == E_SYSTEM)
1770 AppLog("TestPrint ret == E_SYSTEM");
1776 int __modalMsgBoxResult;
1777 MessageBox* pMsgBox = new MessageBox();
1778 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1779 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1782 __modalMsgBoxResult = 0;
1786 case IDA_SHARE_CLICKED:
1788 if(__pPopUp != null)
1795 __pAddressbar->HideKeypad();
1797 __pPopUp = new(std::nothrow) SharePopup();
1798 __pPopUp->Initialize();
1799 if (__pWindowInfo != null)
1801 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1802 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1803 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1804 pShareInfo->SetImageAttached(false);
1805 __pPopUp->RemoveAllShareInfo();
1806 __pPopUp->AddShareInfo(pShareInfo);
1808 __pPopUp->SetShowState(true);
1812 case IDA_BOOKMARKBTN_CLICKED:
1814 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1815 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1818 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1823 case IDA_MOREBTN_CLICKED:
1825 AppLog("IDA_MOREBTN_CLICKED");
1827 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1829 int bookmarkCount=0;
1832 url=__pWindowInfo->pageUrl;
1833 result r = E_SUCCESS;
1834 Bitmap* pBitmap = null;
1836 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1839 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1844 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1848 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1850 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1852 if (__pOptionMenu->GetItemCount() == 9)
1854 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1858 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1863 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1867 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1868 if (__pOptionMenu->GetItemCount() != 9)
1870 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1871 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1872 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1873 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1874 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1875 __pOptionMenu->SetMaxVisibleItemsCount(6);
1877 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1879 AppLog(" Orientation landscape");
1880 __pOptionMenu->SetMaxVisibleItemsCount(5);
1884 AppLog(" Orientation potrait");
1885 __pOptionMenu->SetMaxVisibleItemsCount(6);
1888 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1891 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1892 __pOptionMenu->SetShowState(true);
1893 __pOptionMenu->Invalidate(true);
1894 __pOptionMenu->Show();
1898 case IDA_HISTORY_CLICKED:
1900 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1901 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1904 case IDA_SAVED_PAGES_CLICKED:
1909 case IDA_DESKTOP_VIEW_CLICKED:
1914 case IDA_SAVE_CLICKED:
1919 case IDA_MULTIWINDOWBTN_CLICKED:
1921 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1922 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1926 case IDA_NEWWINDOWBTN_CLICKED:
1928 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
1930 if (pNewWindowInfo == null)
1934 result r = E_SUCCESS;
1935 SceneManager* pSceneManager = SceneManager::GetInstance();
1937 if (pSceneManager == NULL)
1941 ArrayList* pArgList = new(std::nothrow) ArrayList();
1942 if (pArgList == NULL)
1946 r = pArgList->Construct();
1949 pArgList->Add(*pNewWindowInfo);
1950 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1956 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1961 case IDA_SMALLFONT_BTN_CLICKED:
1963 WebSetting setting = __pWebReader->GetSetting();
1964 setting.SetFontSize(15);
1965 __pWebReader->SetSetting(setting);
1968 case IDA_LARGEFONT_BTN_CLICKED:
1970 WebSetting setting = __pWebReader->GetSetting();
1971 setting.SetFontSize(25);
1972 __pWebReader->SetSetting(setting);
1975 case IDA_READER_CLOSE_CLICKED:
1977 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1979 RemoveControl(__pBlankPanel);
1980 __pArticleReaderPanel = null;
1981 __pBlankPanel = null;
1982 __pArticleReaderLabel = null;
1984 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1987 case IDA_FINDWORD_CANCEL_CLICKED:
1989 __currentSearchStr = L"";
1990 __currentWordIndex = 0;
1991 __maxOccurrances = 0;
1993 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1995 __pFindWordEditField->SetText(L"");
1996 __pFindWordCountLabel->SetText(L"0/0");
1998 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2000 __pFindWordEditFieldRightToLeft->SetText(L"");
2001 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2004 __pFindWordNext->SetEnabled(false);
2005 __pFindWordPrev->SetEnabled(false);
2006 __pFindWordCountLabel->SetText(L"0/0");
2007 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
2008 AppLog("akjshdasd 1");
2009 if(__isKeypadOpened == false)
2010 __pFooterPanel->SetShowState(true);
2011 ShowFindWordPanel(false);
2014 case IDA_FINDWORD_SEARCH_CLICKED:
2016 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2018 __currentSearchStr = __pFindWordEditField->GetText();
2020 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2022 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
2025 if (__currentSearchStr.GetLength() > 0)
2031 AppLogDebug("Enter something");
2035 case IDA_FINDWORD_CLEAR_CLICKED:
2037 __pFindWordCountLabel->SetText(L"0/0");
2038 __pFindWordEditField->SetText(L"");
2039 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2041 __currentSearchStr = L"";
2042 __pFindWordNext->SetEnabled(false);
2043 __pFindWordPrev->SetEnabled(false);
2044 // __pFindWordCountLabel->SetShowState(false);
2045 __pFindWordControl->Invalidate(true);
2048 case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
2050 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2051 __pFindWordEditFieldRightToLeft->SetText(L"");
2052 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2054 __currentSearchStr = L"";
2055 __pFindWordNext->SetEnabled(false);
2056 __pFindWordPrev->SetEnabled(false);
2057 // __pFindWordCountLabelRightToLeft->SetShowState(false);
2058 __pFindWordControl->Invalidate(true);
2061 case IDA_FINDWORD_NEXT_CLICKED:
2066 case IDA_FINDWORD_PREV_CLICKED:
2068 FindNextWord(false);
2071 case IDA_BRIGHTNESS_BTN_CLICKED:
2073 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
2074 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2077 case IDA_COPY_IMAGE_CLICKED:
2079 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2080 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2082 const Bitmap* pBitmap = null;
2083 if (__pHitElementResult != null && __pHitElementResult->HasImage())
2085 pBitmap = __pHitElementResult->GetImage();
2088 String resourcePath = App::GetInstance()->GetAppResourcePath();
2089 r = item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
2090 AppLog("Platofrm construct failed result %s",GetErrorMessage(r));
2091 // copying the item to clipboard
2092 Clipboard* pClipboard = Clipboard::GetInstance();
2093 if (pClipboard != null)
2095 r = pClipboard->CopyItem(item);
2096 AppLog("Platofrm copy failed result %s",GetErrorMessage(r));
2100 case IDA_VIEW_IMAGE_CLICKED:
2102 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
2103 WindowInfo* pNewWindowInfo = null;
2104 if (__pHitElementResult != null)
2106 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2107 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2113 case IDA_SAVE_IMAGE_CLICKED:
2115 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
2116 const Bitmap* pSaveBitmap = null;
2117 String imageName = GetImagePath();
2118 AppLog("Content manager image name %ls",imageName.GetPointer());
2121 imagePath.Append(imageName);
2122 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2123 AppLog("Content manager image path %ls",imagePath.GetPointer());
2124 if (__pHitElementResult != null)
2126 pSaveBitmap = __pHitElementResult->GetImage();
2128 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2132 UpdateImageContent(pBuffer, imageName);
2134 if(__pNotification != null)
2136 RemoveControl(__pNotification);
2137 __pNotification = null;
2139 __pNotification = new NotificationPanel(*this);
2141 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2142 msg.Append(imagePath);
2143 if (__pNotification != null)
2145 __pNotification->SetText(msg);
2146 if (__pFooterPanel->GetShowState() == true)
2148 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2152 __pNotification->SetPositionDiff(0);
2154 __pNotification->ShowNotification();
2159 int __modalMsgBoxResult;
2160 MessageBox* pMsgBox = new MessageBox();
2161 pMsgBox->Construct(CommonUtil::GetString(L"IDS_IMGE_POP_UNABLE_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_IMGE_POP_UNABLE_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
2162 pMsgBox->ShowAndWait(__modalMsgBoxResult);
2165 __modalMsgBoxResult = 0;
2169 case IDA_SHARE_IMAGE_CLICKED:
2171 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2172 if (__pPopUp != null)
2179 __pAddressbar->HideKeypad();
2181 __pPopUp = new(std::nothrow) SharePopup();
2182 __pPopUp->Initialize();
2183 if (__pHitElementResult != null)
2185 const Bitmap* pSaveBitmap = null;
2186 String imageName = GetImagePath();
2187 AppLog("Content manager image name %ls",imageName.GetPointer());
2190 imagePath.Append(imageName);
2191 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2192 AppLog("Content manager image path %ls",imagePath.GetPointer());
2193 if (__pHitElementResult != null)
2195 pSaveBitmap = __pHitElementResult->GetImage();
2197 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2199 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2200 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2202 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2203 pShareInfo->SetPageTitle(L"");
2204 pShareInfo->SetPageUrl(srcUrl);
2205 pShareInfo->SetImageAttached(true);
2206 pShareInfo->SetImagePath(imagePath);
2207 __pPopUp->RemoveAllShareInfo();
2208 __pPopUp->AddShareInfo(pShareInfo);
2209 __pPopUp->SetShowState(true);
2214 case IDA_HYPERLINK_OPEN_CLICKED:
2216 if (__pHitElementResult != null)
2218 String srcUrl = __pHitElementResult->GetUrl();
2220 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2222 if (pNewWindowInfo == null)
2226 pNewWindowInfo->isJavascriptInitiated = true;
2227 result r = E_SUCCESS;
2228 SceneManager* pSceneManager = SceneManager::GetInstance();
2229 if (pSceneManager == NULL)
2233 ArrayList* pArgList = new(std::nothrow) ArrayList();
2234 if (pArgList == NULL)
2238 pArgList->Construct();
2240 pArgList->Add(*pNewWindowInfo);
2241 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2242 if (pArgList != null)
2249 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2255 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2257 if (__pHitElementResult == null)
2262 if(__pPopUp != null)
2269 __pAddressbar->HideKeypad();
2271 __pPopUp = new(std::nothrow) SharePopup();
2272 __pPopUp->Initialize();
2274 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2275 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2276 pShareInfo->SetImageAttached(false);
2277 __pPopUp->RemoveAllShareInfo();
2278 __pPopUp->AddShareInfo(pShareInfo);
2280 __pPopUp->SetShowState(true);
2284 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2288 if (__pHitElementResult != null)
2290 url = __pHitElementResult->GetUrl();
2293 String resourcePath = App::GetInstance()->GetAppResourcePath();
2294 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2296 // copying the item to clipboard
2297 Clipboard* pClipboard = Clipboard::GetInstance();
2298 if (pClipboard != null)
2300 pClipboard->CopyItem(item);
2304 case IDA_FIND_TEXT__CLICKED:
2306 // AddressBarCancelledClicked(*__pAddressbar);
2307 RelayoutControls(false);
2308 // __pFooterPanel->SetShowState(false);
2309 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2310 __currentSearchStr.Clear();
2311 __currentSearchStr.Append(__currentSelectedStr);
2312 InitFindWordPanel();
2313 __pFindWordEditField->SetText(__currentSearchStr);
2315 if(__pOptionMenu != null)
2317 __pOptionMenu->SetShowState(false);
2318 __pOptionMenu->Invalidate(false);
2320 __adressPanelPosition.y = 0;
2322 if (__pAddressbar != null && __pWebViewer != NULL)
2324 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2325 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2327 if (__pFooterPanel->GetShowState() == false)
2328 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2330 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2331 __pWebViewer->Invalidate(true);
2334 ShowFindWordPanel(true);
2335 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2337 __pFindWordEditField->SetText(__currentSearchStr);
2338 __pFindWordEditField->SetFocus();
2340 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2342 __pFindWordEditFieldRightToLeft->SetText(__currentSearchStr);
2343 __pFindWordEditFieldRightToLeft->SetFocus();
2346 if (__currentSearchStr.GetLength() > 0)
2352 AppLogDebug("Enter something");
2355 if (__pWebViewer != null)
2357 // releasing the set block
2358 __pWebViewer->ReleaseBlock();
2363 case IDA_SHARE_TEXT_CLICKED:
2365 __pWebViewer->ReleaseBlock();
2366 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2367 if(__pPopUp != null)
2374 __pAddressbar->HideKeypad();
2376 __pPopUp = new(std::nothrow) SharePopup();
2377 __pPopUp->Initialize();
2378 if (__pHitElementResult != null)
2380 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2381 pShareInfo->SetPageTitle(L"");
2382 pShareInfo->SetPageUrl(__currentSelectedStr);
2383 pShareInfo->SetImageAttached(false);
2384 __pPopUp->RemoveAllShareInfo();
2385 __pPopUp->AddShareInfo(pShareInfo);
2386 __pPopUp->SetShowState(true);
2391 case IDA_COPY_TEXT_CLICKED:
2393 __pWebViewer->ReleaseBlock();
2394 // need to implement
2395 //__currentSelectedStr
2396 // Sets data to a clip board item
2398 String resourcePath = App::GetInstance()->GetAppResourcePath();
2399 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2401 // copying the item to clipboard
2402 Clipboard* pClipboard = Clipboard::GetInstance();
2403 if (pClipboard != null)
2405 pClipboard->CopyItem(item);
2409 case IDA_PASTE_TEXT_CLICKED:
2411 Clipboard* pClipboard = Clipboard::GetInstance();
2413 if(pClipboard == null)
2417 // Retrieves a latest item
2418 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2424 //Gets data from the clipboard item
2425 String* pString = dynamic_cast<String*>(pItem->GetData());
2427 if (pString != null)
2429 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2430 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2431 String tagElement = __pHitElementResult->GetTagName();
2432 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2435 if(idElement.GetLength() != 0)
2437 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; } } ";
2438 script.Append("insertAtCursor('");
2439 script.Append(idElement);
2440 script.Append("',");
2441 script.Append("\"");
2442 script.Append(*pString);
2443 script.Append("\");");
2445 else if (nameElement.GetLength() != 0)
2447 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; } } ";
2448 script.Append("insertAtCursor(document.getElementsByName('");
2449 script.Append(nameElement);
2450 script.Append("')[0],");
2451 script.Append("\"");
2452 script.Append(*pString);
2453 script.Append("\");");
2455 else//adding for twitter post page
2457 script = L"function insertAtCursor(myField, myValue) { if (document.selection) { document.getElementsByTagName(myField)[0].focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0'){ var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length); } else { document.getElementsByTagName(myField)[0].value += myValue; } } ";
2458 script.Append("insertAtCursor(document.getElementsByTagName('");
2459 script.Append(tagElement);
2460 script.Append("')[0],");
2461 script.Append("\"");
2462 script.Append(*pString);
2463 script.Append("\");");
2465 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2466 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2477 case IDA_GO_FORWARD:
2482 case IDA_REFRESH_BTN_CLICKED:
2484 __isLoadingCompleted = false;
2485 __isLoadingData = true;
2486 __progressPercentage = 0;
2487 __displayUrl = __pFooterUrlField->GetText();
2489 String url = __pFooterUrlField->GetText();
2490 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2492 if (__pWebViewer != null && __pAddressbar != null)
2494 __pWebViewer->Reload();
2495 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2499 UpdateProgressBitmap();
2502 case IDA_STOP_BTN_CLICKED:
2504 __isLoadingCompleted = false;
2505 __isLoadingData = false;
2506 __progressPercentage = 0;
2507 __pFooterUrlField->HideKeypad();
2508 __displayUrl = __pFooterUrlField->GetText();
2512 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2513 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2514 __pWebViewer->StopLoading();
2515 RequestRedraw(true);
2518 UpdateProgressBitmap();
2523 if (__pFooterUrlField->GetText().IsEmpty() == false)
2525 //__displayUrl = __pUrlField->GetText();
2526 __pFooterUrlField->Clear();
2531 case IDA_READER_BTN_CLICKED:
2542 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2544 AppLog("MainForm::OnFormBackRequested entered");
2545 result r = E_FAILURE;
2546 if(__pImageMenu && __pImageMenu->GetShowState() == true)
2548 AppLog("Hiding the menu");
2549 __pImageMenu->SetShowState(false);
2551 if (__pWebViewer && __pWebViewer->CanGoBack())
2553 __pWebViewer->GoBack();
2555 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
2558 pApp = UiApp::GetInstance();
2561 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2564 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2572 WindowInfo* pWindowInfo = null;
2574 SceneManager* pSceneManager = SceneManager::GetInstance();
2575 if (pSceneManager == null)
2579 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2580 if (pAllWindowList == NULL)
2582 pApp = UiApp::GetInstance();
2585 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2588 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2593 if (pAllWindowList != null)
2595 totalCount = pAllWindowList->GetCount();
2597 for (int count = 0; count < totalCount; count++)
2599 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2600 if (pWindowInfo == null)
2602 pApp = UiApp::GetInstance();
2605 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2608 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2615 if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2617 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2620 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2623 r = pAllWindowList->RemoveAt(count, true);
2624 __pWindowInfo = null;
2627 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2632 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2636 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2638 if (pWindowInfo == null)
2640 pApp = UiApp::GetInstance();
2643 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2649 if(pWindowInfo != null)
2650 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2653 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2659 // else if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == false)
2661 // UiApp* pApp = null;
2662 // pApp = UiApp::GetInstance();
2663 // if (pApp != null)
2665 // r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2668 // AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2676 AppLog("MainForm::OnFormBackRequested exit");
2680 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2681 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2684 AppLog("MainForm::OnSceneActivatedN called");
2685 String* pSelectedScene = NULL;
2686 Object* pValue = NULL;
2687 String* pUrl = null;
2688 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2689 pSelectedScene = (String*) pValue;
2691 if (pSelectedScene != null)
2693 delete pSelectedScene;
2695 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2696 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2697 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2698 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2700 // setting the current scene ID
2701 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2703 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2705 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2707 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2708 if(__pWindowInfo == null)
2710 // if(__pWindowInfo == null)
2712 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2715 else if ( pArgs != null && pArgs->GetCount() == 1)
2717 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2723 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2725 // hiding the address bar
2726 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2727 __pAddressbar->SetShowState(false);
2728 // if(__pWebViewer != null)
2730 // __pWebViewer->Resume();
2733 if(pUrl != null && pUrl->GetLength() > 0)
2737 else if(__pWindowInfo != null)
2739 if(__pWindowInfo->pageUrl.GetLength() > 0 &&previousSceneId != IDSCN_BRIGHTNESS && previousSceneId != IDSCN_HISTORY_LIST && previousSceneId != IDSCN_MULTIPLE_WINDOW && previousSceneId != IDSCN_MULTIPLE_WINDOW_GRID && previousSceneId != IDSCN_BOOKMARK_VIEW && previousSceneId != IDSCN_SETTINGS && previousSceneId.Contains(IDSCN_MAIN_VIEW) == false)
2741 LoadUrl(__pWindowInfo->pageUrl);
2743 else if(__pWindowInfo->pageUrl.GetLength() > 0 && __pWindowInfo->isAppcontrolTriggered == true)
2745 LoadUrl(__pWindowInfo->pageUrl);
2746 __pWindowInfo->isAppcontrolTriggered = false;
2748 else if (__pWindowInfo->isJavascriptInitiated == true)
2752 __pWindowInfo->pCurrentWeb = __pWebViewer;
2753 if(__pWindowInfo->pageUrl.GetLength() > 0)
2754 LoadUrl(__pWindowInfo->pageUrl);
2758 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2759 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2760 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2762 InitMostVisitedSitesView(GetOrientationStatus());
2764 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2766 if(__pMostVisitedListView != null)
2768 __pMostVisitedListView->SetShowState(false);
2772 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2774 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2776 if (pBookmarkUrl == null)
2778 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2779 //__pAddressbar->SetUrl(*pBookmarkUrl);
2780 SetUrl(*pBookmarkUrl);
2782 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2783 __pWebViewer->LoadUrl(*pBookmarkUrl);
2784 delete pBookmarkUrl;
2787 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2788 Bitmap* pBitmap = null;
2789 if (isPrivateBrowsing == true)
2791 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2793 if (__pWebViewer != null)
2795 __pWebViewer->SetPrivateBrowsingEnabled(true);
2798 if (__pAddressbar != null)
2800 // __pAddressbar->UpdateFaviconBitmap(true);
2806 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2808 if (__pWebViewer != null)
2810 __pWebViewer->SetPrivateBrowsingEnabled(false);
2813 if (__pAddressbar != null)
2815 // __pAddressbar->UpdateFaviconBitmap(false);
2819 if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
2821 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2823 else if (__pOptionMenu != null )
2825 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2828 if (pBitmap != null)
2833 RelayoutControls(false);
2834 AppLog("ABC: OnSceneActivatedN started exit");
2839 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2840 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2842 Canvas* pWebCanvas = null;
2843 if (__pWebViewer != null)
2845 pWebCanvas = __pWebViewer->GetCanvasN();
2848 if (pWebCanvas == null)
2852 if (__pWindowInfo != null)
2854 if (__pWindowInfo->pWebCanvasBitmap != null)
2856 delete __pWindowInfo->pWebCanvasBitmap;
2858 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2859 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2860 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2862 Bitmap* pBitmap = GetCapturedBitmapN();
2863 AppLog("Coming here");
2864 Canvas* pCanvas = new(std::nothrow) Canvas();
2865 pCanvas->Construct(GetClientAreaBounds());
2868 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2871 if(__pWebViewer != null && __pWindowInfo != null)
2872 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2874 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2875 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2879 __pAddressbar->SetShowState(false);
2880 AppLog("Coming here");
2884 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2885 const Tizen::Base::String& realm,
2886 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2892 MainForm::OnHttpAuthenticationCanceled(void)
2897 MainForm::OnLoadingStarted(void)
2899 AppLogDebug("MainForm::OnLoadingStarted entered");
2901 if(__pAddressbar == NULL || __pWebViewer == null)
2906 // this is added in case if menu is opened and user load the page
2907 if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
2909 __pOptionMenu->SetShowState(false);
2910 __pOptionMenu->Invalidate(true);
2915 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2917 __pImageMenu->SetShowState(false);
2918 __pImageMenu->Invalidate(true);
2920 String url = __pWebViewer->GetUrl();
2921 if(url.Contains(IDS_TIZEN_SERVICE))
2924 String delim(L":;,");
2926 // Creates a StringTokenizer instance
2927 StringTokenizer strTok(url, delim);
2929 int count = strTok.GetTokenCount(); // count == 4
2931 HashMap *pMap = new HashMap();
2936 while (strTok.HasMoreTokens())
2938 AppLog("Token: %ls", token.GetPointer());
2939 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2940 if(token.Contains(IDS_APPID))
2942 token.SubString(6, appId);
2943 AppLog("AppID:%ls", appId.GetPointer());
2945 else if(token.Contains(IDS_KEY))
2947 token.SubString(4, key);
2948 AppLog("key:%ls", key.GetPointer());
2950 else if(token.Contains(IDS_VALUE))
2952 token.SubString(6, value);
2953 AppLog("value:%ls", value.GetPointer());
2956 pMap->Add(key, value);
2960 AppControl *pAppControl = null;
2961 String operationId = L"http://tizen.org/appcontrol/operation/main";
2962 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2965 AppLog("Starting AppControl");
2966 result r = pAppControl->Start(null, null, pMap, null);
2967 AppLog("Result of Start %s", GetErrorMessage(r));
2971 AppLogException("AppControl not found");
2976 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
2978 __pAddressbar->SetShowState(false);
2979 AddressBarCancelledClicked(*__pAddressbar);
2980 __pAddressbar->Invalidate(true);
2982 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2985 __pAddressbar->SetFaviconBitmap(*pBitmap);
2988 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2990 // updating the address bar position with respect to web control
2991 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2992 __distanceMoved = 0;
2996 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2997 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2998 if (__pWebViewer != null)
3000 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
3001 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
3002 SetUrl(__pWebViewer->GetUrl());
3003 if (__pWindowInfo != NULL)
3005 // resetting the page title to blank, it will be received in OnPageTitleReceived()
3006 __pWindowInfo->pageTitle = L"";
3007 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3009 __pAddressbar->Invalidate(true);
3015 MainForm::OnLoadingCanceled(void)
3022 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
3024 AppLog("XYZ::MainForm::OnKeypadWillOpen");
3029 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
3031 AppLog("XYZ::MainForm::OnKeypadOpened");
3032 __isKeypadOpened = true;
3033 __pFooterPanel->SetShowState(false);
3038 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
3040 AppLog("XYZ::MainForm::OnKeypadClosed");
3041 __isKeypadOpened = false;
3042 __pFooterPanel->SetShowState(true);
3043 RelayoutControls(true);
3047 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
3049 AppLog("XYZ::KeypadBoundsChanged");
3050 RelayoutControls(false);
3054 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
3055 const Tizen::Base::String& reason)
3057 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
3061 MainForm::OnLoadingCompleted(void)
3063 AppLog("MainForm::OnLoadingCompleted start");
3065 result r = E_SUCCESS;
3067 if (__pWebViewer == null)
3072 if (__pAddressbar == null)
3077 if(__pImageMenu && __pImageMenu->GetShowState())
3079 __pImageMenu->SetShowState(false);
3080 __pImageMenu->Invalidate(true);
3083 if (__pWebViewer->CanGoForward())
3085 //__pAddressbar->SetForwardButtonEnabled(true);
3086 SetForwardButtonEnabled(true);
3090 //__pAddressbar->SetForwardButtonEnabled(false);
3091 SetForwardButtonEnabled(false);
3094 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3096 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3098 //__pAddressbar->UpdateProgress(0);
3102 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3104 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3108 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
3109 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
3110 if (isPrivateBrowsing == false)
3112 if(__pHistory != null)
3118 __pHistory = new(std::nothrow) History;
3119 HistoryPresentationModel::GetCurrentDateTime(date);
3122 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
3123 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
3125 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
3126 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3128 __pHistory->SetVisitedTime(date);
3130 if (__pWebViewer != null)
3132 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3134 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3135 if (pTempBitmap != null)
3137 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3138 __pHistory->SetFavIconBitmap(*pTempBitmap);
3141 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3144 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3145 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3146 if ( pCanvas != null && pCanvas != null && pBitmap != null)
3148 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3149 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3150 __pHistory->SetThumbnail(pBitmap);
3152 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3155 __pHistory->SetFavIconBitmap(*pFavIcon);
3159 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3166 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3168 // temperary fixed (webpage can be not loaded)
3172 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3173 if (isReaderEnabled == true)
3177 delete __pReaderData;
3178 __pReaderData = null;
3180 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3181 filePath.Append(L"data/reader.js");
3187 result r = E_SUCCESS;
3188 FileAttributes attr;
3190 File::GetAttributes(filePath,attr);
3192 r = file.Construct(filePath, L"r+");
3195 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3198 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3201 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3204 // file.Read(pScript,attr.GetFileSize());
3206 // AppLogDebug("scipt length %d",strlen(pScript));
3207 String strScript = L"";
3208 // strScript.Append(pScript);
3209 // for(int i=0; i<25; i++)
3211 file.Read(pScript,attr.GetFileSize());
3212 // AppLog("xyzz tell %d",file.Tell());
3213 // r = strScript.Append(pScript);
3214 // AppLog("xyzz append result %s",GetErrorMessage(r));
3215 // AppLog("xyzz strScript length %d",strScript.GetLength());
3217 // AppLog("xyzz final strScript length %d",strScript.GetLength());
3219 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3220 if (__pReaderData == null)
3222 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3223 __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>");
3226 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3227 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3229 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3230 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3236 AppLog("MainForm::OnLoadingCompleted done");
3240 MainForm::OnEstimatedProgress(int progress)
3242 AppLogDebug("MainForm::OnEstimatedProgress entered %d",progress);
3244 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3245 progress = DEFAULT_PROGRESS_PERCENTAGE;
3247 // __pAddressbar->UpdateProgress(progress);
3248 UpdateProgress(progress);
3251 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3253 AppLog("MainForm::OnFaviconReceived");
3254 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3256 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3259 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3266 MainForm::OnUrlValueChanged(Addressbar&)
3272 MainForm::OnUrlSubmitted(Addressbar& addBar)
3274 AppLog("MainForm::OnUrlSubmitted");
3275 String url = addBar.GetUrl();
3276 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3278 if(__pFooterUrlField)
3279 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3280 AddressBarCancelledClicked(*__pAddressbar);
3285 MainForm::LoadUrl(String& url)
3289 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3290 AppLogDebug("MainForm::LoadUrl enter");
3292 if (__pWebViewer != null)
3294 __pWebViewer->SetShowState(true);
3295 __pWebViewer->Invalidate(true);
3298 if (url.CompareTo(L"") == 0)
3302 if(__pFooterPanel != null)
3304 __pFooterPanel->SetShowState(true);
3305 __pFooterPanel->Invalidate(true);
3312 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3313 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)
3315 RegularExpression firstRegex;
3316 RegularExpression secondRegex;
3318 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3319 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3322 ret = firstRegex.Match(url, false); // This returns true value
3323 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3325 if (ret == true && __pWebViewer != null)
3328 __pWebViewer->LoadUrl(url);
3330 else if(__pWebViewer != null)
3332 String tempUrl = L"http://";
3333 tempUrl.Append(url);
3337 __pWebViewer->LoadUrl(tempUrl);
3341 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3342 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3345 if (__pAddressbar != null)
3347 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3348 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3351 AppLogDebug("MainForm::LoadUrl exit");
3358 MainForm::OnFocusGained(const Tizen::Ui::Control& source)
3360 AppLog("MainForm::OnFocusGained");
3363 __pFooterPanel->SetShowState(false);
3368 __pAddressbar->SetShowState(true);
3369 __pAddressbar->SetAddressbarURLFocus();
3371 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3373 __currentSearchStr = L"";
3374 __currentWordIndex = 0;
3375 __maxOccurrances = 0;
3377 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
3379 __pFindWordEditField->SetText(L"");
3380 __pFindWordEditField->HideKeypad();
3381 __pFindWordControl->SetShowState(false);
3382 __pFindWordCountLabel->SetText(L"0/0");
3384 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
3386 __pFindWordEditFieldRightToLeft->SetText(L"");
3387 __pFindWordEditFieldRightToLeft->HideKeypad();
3388 __pFindWordControl->SetShowState(false);
3389 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
3392 __pFindWordNext->SetEnabled(false);
3393 __pFindWordPrev->SetEnabled(false);
3395 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
3396 __pFindWordControl->SetShowState(false);
3398 RelayoutControls(false);
3402 MainForm::OnFocusLost(const Tizen::Ui::Control& source)
3404 AppLog("MainForm::OnFocusLost called");
3408 MainForm::OnStopClicked(Addressbar& addBar)
3410 AppLogDebug("MainForm::OnStopClicked called");
3413 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3414 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3415 __pWebViewer->StopLoading();
3416 RequestRedraw(true);
3421 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3423 // AppLog("MainForm::OnBackClicked");
3424 result r = E_FAILURE;
3425 if(__pImageMenu && __pImageMenu->GetShowState() == true)
3427 AppLog("Hiding the menu");
3428 __pImageMenu->SetShowState(false);
3431 if (__pWebViewer && __pWebViewer->CanGoBack())
3433 __pWebViewer->GoBack();
3435 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3438 pApp = UiApp::GetInstance();
3441 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3444 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3452 WindowInfo* pWindowInfo = null;
3454 SceneManager* pSceneManager = SceneManager::GetInstance();
3455 if (pSceneManager == null)
3459 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3460 if (pAllWindowList == NULL)
3462 pApp = UiApp::GetInstance();
3465 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3468 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3473 if (pAllWindowList != null)
3475 totalCount = pAllWindowList->GetCount();
3477 for (int count = 0; count < totalCount; count++)
3479 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3480 if (pWindowInfo == null)
3482 pApp = UiApp::GetInstance();
3485 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3488 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3493 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3495 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3498 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3501 r = pAllWindowList->RemoveAt(count, true);
3502 __pWindowInfo = null;
3505 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3510 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3512 else if(pAllWindowList->GetCount() > 0)
3514 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3518 pApp = UiApp::GetInstance();
3521 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3526 if (pWindowInfo == null)
3528 pApp = UiApp::GetInstance();
3531 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3537 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3540 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3554 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3556 AppLog("MainForm::OnForwardClicked");
3557 if (__pWebViewer == null)
3560 if (__pWebViewer->CanGoForward())
3562 __pWebViewer->GoForward();
3567 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3569 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3570 if(__pFooterPanel != null)
3572 __pFooterPanel->SetShowState(false);
3575 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3577 __pAddressbar->SetShowState(true);
3578 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3581 RelayoutControls(false);
3585 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3587 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3589 int Height = GetClientAreaBounds().height;
3590 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3592 RelayoutControls(false);
3596 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3598 AddressBarCancelledClicked(addBar);
3602 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3604 __prevAddressBarMode = __curAddressBarMode;
3606 if (__pAddressbar != null)
3608 __curAddressBarMode = GetAddressbarMode();
3611 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3613 __adressPanelPosition.y = 0;
3614 if (__pAddressbar != null)
3616 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3617 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3618 __pAddressbar->Invalidate(true);
3620 if (__pWebViewer != null)
3622 __pWebViewer->StopLoading();
3625 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3627 __adressPanelPosition.y = 0;
3628 if (__pAddressbar != null)
3630 __webControlPosition.y = 0;
3631 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3632 __pAddressbar->Invalidate(true);
3638 MainForm::OnClipboardClosed(const Addressbar& addBar)
3640 AppLog("XYZ::MainForm::OnClipboardClosed");
3641 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3643 AppLog("akjshdasd 3");
3644 __pFooterPanel->SetShowState(true);
3646 __isKeypadOpened = false;
3647 RelayoutControls(false);
3651 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3653 AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3654 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3656 AppLog("akjshdasd 3");
3657 __pFooterPanel->SetShowState(true);
3659 __isKeypadOpened = false;
3661 RelayoutControls(false,footerState);
3665 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3667 AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3668 __isKeypadOpened = true;
3669 RelayoutControls(false);
3673 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3675 __isKeypadOpened = true;
3676 __pFooterPanel->SetShowState(false);
3680 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3682 AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3683 RelayoutControls(false);
3687 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3689 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3692 __pWindowInfo->pageTitle = title;
3693 if (__pWebViewer != null)
3695 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3696 AppLog("MainForm::OnPageTitleReceived url %ls",__pWindowInfo->pageUrl.GetPointer());
3699 if (__pAddressbar != null && __pWebViewer != null)
3701 SetUrl(__pWebViewer->GetUrl());
3702 __pAddressbar->Invalidate(true);
3707 MainForm::UpdateFavicon(void)
3709 bool urlImageType = false;
3710 String *tempPath = null;
3712 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();");
3713 Bitmap* pBitmap = null;
3715 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3717 if (__pWindowInfo != null)
3720 url.SetUri(*tempPath);
3721 if (url.GetHost().GetLength() == 0)
3724 webUrl.SetUri(__pWebViewer->GetUrl());
3725 result r = url.SetHost(webUrl.GetHost());
3732 if (url.GetScheme().GetLength() == 0)
3735 webUrl.SetUri(__pWebViewer->GetUrl());
3736 url.SetScheme(webUrl.GetScheme());
3738 __pWindowInfo->faviconUrl = url.ToString();
3740 pBitmap = __pWebViewer->GetFaviconN();
3742 if (pBitmap != null)
3744 if (__pWindowInfo->pFavicon != NULL)
3746 __pWindowInfo->pFavicon = null;
3748 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3749 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3751 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3753 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3755 else if(__pWindowInfo->pFavicon != null)
3757 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3761 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3762 if(pDefaultBmp != null)
3764 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3778 if(tempPath != null)
3782 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3788 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3789 Tizen::Web::Controls::WebNavigationType type)
3791 AppLog("urlk %ls",url.GetPointer());
3792 // when load new page if find word panel is open its show state is false
3793 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3795 __currentSearchStr = L"";
3796 __currentWordIndex = 0;
3797 __maxOccurrances = 0;
3798 __pFindWordEditField->SetText(L"");
3799 __pFindWordNext->SetEnabled(false);
3800 __pFindWordPrev->SetEnabled(false);
3801 __pFindWordCountLabel->SetText(L"0/0");
3802 __pFindWordControl->SetShowState(false);
3803 __pFindWordEditField->HideKeypad();
3804 RelayoutControls(false);
3807 __pFooterPanel->Invalidate(true);
3810 uriInfo.SetUri(url);
3812 if(url.Contains(IDS_TIZEN_SERVICE))
3815 String delim(L":;,");
3817 // Creates a StringTokenizer instance
3818 StringTokenizer strTok(url, delim);
3820 int count = strTok.GetTokenCount(); // count == 4
3822 HashMap *pMap = new HashMap();
3828 while (strTok.HasMoreTokens())
3830 AppLog("Token: %ls", token.GetPointer());
3831 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3832 if(token.Contains(IDS_APPID))
3834 token.SubString(6, appId);
3835 AppLog("AppID:%ls", appId.GetPointer());
3837 else if(token.Contains(IDS_KEY))
3839 token.SubString(4, key);
3840 AppLog("key:%ls", key.GetPointer());
3842 else if(token.Contains(IDS_VALUE))
3844 token.SubString(6, value);
3845 AppLog("value:%ls", value.GetPointer());
3848 pMap->Add(key, value);
3852 AppControl *pAppControl = null;
3853 String operationId = L"http://tizen.org/appcontrol/operation/main";
3854 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3857 result r = pAppControl->Start(null, null, pMap, null);
3861 AppLogException("AppControl not found");
3871 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3872 const Tizen::Net::Http::HttpHeader& httpHeader)
3874 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3878 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
3880 if(__isLongPressedDone == false)
3882 AppLog("MainForm::OnWebPageBlockSelected");
3883 if (__pHitElementResult != null)
3885 delete __pHitElementResult;
3886 __pHitElementResult = null;
3889 if (__pWebViewer != null)
3891 AppLog("MainForm::OnWebPageBlockSelected web not null");
3892 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3894 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
3896 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
3897 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3898 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
3900 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
3902 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
3906 if (__pHitElementResult == null)
3911 if (__pHitElementResult->HasImage() != true)
3913 String tagName = __pHitElementResult->GetTagName();
3914 String type = __pHitElementResult->GetAttributeValue("type");
3917 AppLog("TagName %ls",tagName.GetPointer());
3918 __currentSelectedStr.Clear();
3919 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3920 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3921 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3922 if(tagName.Equals(L"TEXTAREA",false) == true)
3924 AppLog("Tagnameseemstobe TEXTAREA");
3926 else if(tagName.Equals(L"INPUT",false) == true)
3928 AppLog("Tagnameseemstobe INPUT");
3931 if (((tagName.Equals(L"INPUT",false) == true) || tagName.Equals(L"TEXTAREA",false) == true) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
3933 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3935 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),true);
3936 __pImageMenu->SetShowState(true);
3937 __pImageMenu->Show();
3938 __pImageMenu->Invalidate(true);
3940 else /*if(__isLongPressedDone == true)*/
3942 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3944 if(__pHitElementResult->GetUrl().GetLength() > 0)
3946 __currentSelectedStr.Clear();
3947 __currentSelectedStr = __pHitElementResult->GetUrl();
3949 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),false);
3950 __pImageMenu->SetShowState(true);
3951 __pImageMenu->Show();
3952 __pImageMenu->Invalidate(true);
3955 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3956 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3957 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3963 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3969 MainForm::OnWebWindowCreateRequested(void)
3971 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
3973 if (pNewWindowInfo == null)
3977 result r = E_SUCCESS;
3978 SceneManager* pSceneManager = SceneManager::GetInstance();
3979 if (pSceneManager == NULL)
3983 ArrayList* pArgList = new(std::nothrow) ArrayList();
3984 if (pArgList == NULL)
3988 r = pArgList->Construct();
3991 pNewWindowInfo->isJavascriptInitiated = true;
3992 pArgList->Add(*pNewWindowInfo);
3993 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3997 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
4004 return pNewWindowInfo->pCurrentWeb;
4008 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
4010 AppLog("xyz:: MainForm::RelayoutControls called");
4011 __webControlPosition.y = 0;
4012 __webControlHeight = GetClientAreaBounds().height;
4013 AppLog("Client area height: %d", __webControlHeight);
4015 AppLog("Client area height: %d", __webControlHeight);
4016 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
4018 __webControlPosition.y += __pAddressbar->GetHeight();
4019 __webControlHeight -= __pAddressbar->GetHeight();
4020 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
4022 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
4024 __webControlPosition.y += __pFindWordControl->GetHeight();
4025 __webControlHeight -= __pFindWordControl->GetHeight();
4026 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
4029 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
4031 __webControlHeight -= __pFooterPanel->GetHeight();
4033 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
4035 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
4037 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight + 12 )
4042 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12);
4043 AppLog("xyz:: MainForm::RelayoutControls called __webControlHeight %d",__webControlHeight);
4044 __pWebViewer->Invalidate(false);
4047 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
4049 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
4056 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
4058 if (__pFindWordControl == null)
4063 Tizen::Locales::LocaleManager localeManager;
4064 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
4066 String languageCode;
4067 result r = SettingInfo::GetValue(L"Language", languageCode);
4068 // int languagecode = local.GetLanguageCode();
4069 AppLog("rahul language is %S", languageCode.GetPointer());
4073 InitFindWordPanel();
4075 if (languageCode.CompareTo("ara") == 0)
4077 AppLog("rahul language is arabic");
4079 __pFindWordPanelLeftToRight->SetShowState(false);
4080 __pFindWordPanelRightToLeft->SetShowState(true);
4082 __pFindWordClear->SetShowState(false);
4083 __pFindWordCountLabel->SetShowState(false);
4084 __pFindWordEditField->SetShowState(false);
4086 __pFindWordClearRightToLeft->SetShowState(true);
4087 __pFindWordCountLabelRightToLeft->SetShowState(true);
4088 __pFindWordEditFieldRightToLeft->SetShowState(true);
4092 AppLog("rahul language is not arabic");
4095 __pFindWordPanelLeftToRight->SetShowState(true);
4096 __pFindWordPanelRightToLeft->SetShowState(false);
4098 __pFindWordClear->SetShowState(true);
4099 __pFindWordCountLabel->SetShowState(true);
4100 __pFindWordEditField->SetShowState(true);
4102 __pFindWordClearRightToLeft->SetShowState(false);
4103 __pFindWordCountLabelRightToLeft->SetShowState(false);
4104 __pFindWordEditFieldRightToLeft->SetShowState(false);
4106 __pFindWordControl->SetShowState(true);
4110 if(__pFindWordControl != null)
4112 __pFindWordControl->SetShowState(false);
4116 AppLog("MainForm::ShowFindWordPanel %d",show);
4117 if (show && !isTouchPressed)
4119 if (languageCode.CompareTo("ara") == 0)
4121 if (__pFindWordEditFieldRightToLeft)
4123 __pFindWordEditFieldRightToLeft->SetFocus();
4124 __pFindWordEditFieldRightToLeft->ShowKeypad();
4129 if (__pFindWordEditField)
4131 __pFindWordEditField->SetFocus();
4132 __pFindWordEditField->ShowKeypad();
4138 if (languageCode.CompareTo("ara") == 0)
4140 if (__pFindWordEditFieldRightToLeft)
4141 __pFindWordEditFieldRightToLeft->HideKeypad();
4145 if (__pFindWordEditField)
4146 __pFindWordEditField->HideKeypad();
4150 RelayoutControls(false);
4154 MainForm::StartWordSearch()
4156 //Get the count of occurances of the word in the current page
4157 __maxOccurrances = 0;
4158 __currentWordIndex = 0;
4160 __pFindWordPrev->SetEnabled(false);
4161 String *pCountStr = null;
4162 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
4163 AppLog("Search Result %s",GetErrorMessage(r));
4164 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
4165 if (pCountStr != null)
4167 Integer::Parse(*pCountStr, 10, __maxOccurrances);
4171 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
4176 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
4178 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
4179 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
4181 if(totalCount == -1 || totalCount == 0)
4183 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
4184 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
4187 else if(totalCount > 100)
4189 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4190 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4194 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4195 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4198 __maxOccurrances = totalCount;
4199 __currentWordIndex = currentOrdinal;
4201 //Reset the UI controls as per the maxOccurrance value
4202 if (totalCount <= 0)
4204 AppLog("Word not found");
4205 //Show error notification to user
4206 __pFindWordNext->SetEnabled(false);
4207 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4209 __pFindWordCountLabel->SetText(L"0/0");
4210 __pFindWordCountLabel->Invalidate(false);
4212 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4214 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4215 __pFindWordCountLabelRightToLeft->Invalidate(false);
4217 __pFindWordNext->Invalidate(false);
4218 __pFindWordPrev->Invalidate(false);
4223 if (totalCount == 1)
4225 __pFindWordNext->SetEnabled(false);
4229 __pFindWordNext->SetEnabled(true);
4232 String countStr = L"";
4233 countStr.Append(__currentWordIndex);
4234 countStr.Append(L"/");
4235 countStr.Append(__maxOccurrances);
4236 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4238 __pFindWordCountLabel->SetText(countStr);
4239 __pFindWordCountLabel->Invalidate(false);
4240 __pFindWordCountLabel->Invalidate(false);
4242 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4244 __pFindWordCountLabelRightToLeft->SetText(countStr);
4245 __pFindWordCountLabelRightToLeft->Invalidate(false);
4246 __pFindWordCountLabelRightToLeft->Invalidate(false);
4248 //FindNextWord(true);
4249 //Update the controls
4250 __pFindWordNext->Invalidate(false);
4251 __pFindWordPrev->Invalidate(false);
4256 MainForm::FindNextWord(bool next)
4260 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4261 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4263 if (__currentWordIndex < __maxOccurrances)
4265 __currentWordIndex++;
4271 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4272 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4274 if(__currentWordIndex > 1)
4276 __currentWordIndex--;
4281 String countStr = L"";
4282 countStr.Append(__currentWordIndex);
4283 countStr.Append(L"/");
4284 countStr.Append(__maxOccurrances);
4286 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4288 __pFindWordCountLabel->SetText(countStr);
4289 __pFindWordCountLabel->Invalidate(false);
4291 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4293 __pFindWordCountLabelRightToLeft->SetText(countStr);
4294 __pFindWordCountLabelRightToLeft->Invalidate(false);
4297 if (__currentWordIndex >= __maxOccurrances)
4299 __pFindWordNext->SetEnabled(false);
4303 __pFindWordNext->SetEnabled(true);
4305 if (__currentWordIndex <= 1)
4307 __pFindWordPrev->SetEnabled(false);
4311 __pFindWordPrev->SetEnabled(true);
4313 __pFindWordPrev->Invalidate(false);
4314 __pFindWordNext->Invalidate(false);
4316 __pFindWordControl->Invalidate(true);
4320 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4322 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4323 __isKeypadOpened = true;
4324 __pFooterPanel->SetShowState(false);
4325 // OnAddressBarKeypadOpened(*__pAddressbar);
4329 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4331 __isKeypadOpened = true;
4332 AppLog("xyz::MainForm::OnWebKeypadOpened");
4334 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4336 __currentSearchStr = L"";
4337 __currentWordIndex = 0;
4338 __maxOccurrances = 0;
4339 __pFindWordEditField->SetText(L"");
4340 __pFindWordNext->SetEnabled(false);
4341 __pFindWordPrev->SetEnabled(false);
4342 __pFindWordCountLabel->SetText(L"0/0");
4343 __pWebViewer->SearchTextAllAsync(L"",false);
4344 __pFindWordControl->SetShowState(false);
4345 __pFindWordEditField->HideKeypad();
4349 if (__pWebViewer != null && __pFooterPanel != null)
4351 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4352 if(__pAddressbar != null)
4354 __pAddressbar->SetShowState(false);
4356 if(__pFindWordControl != null)
4358 __pFindWordControl->SetShowState(false);
4360 __pFooterPanel->SetShowState(false);
4361 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4363 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4365 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4366 // AppLog("omgomgomg");
4372 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4374 AppLog("xyz::MainForm::OnWebKeypadClosed");
4375 AppLog("akjshdasd 4");
4376 __pFooterPanel->SetShowState(true);
4377 // OnAddressBarKeypadClosed(*__pAddressbar);
4378 RelayoutControls(false);
4379 __isKeypadOpened = false;
4383 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4385 // RelativeLayout(false);
4386 if(__pWebViewer != null)
4388 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4393 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4395 Control* temp = const_cast< Control* >(&source);
4396 Header* pHeader = dynamic_cast< Header* >(temp);
4397 if (pHeader != null)
4399 //Header double - clicked
4400 AppLog("Header double clicked");
4402 if(__pFindWordControl)
4404 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4405 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4409 AppLog("MainScene::OnTouchDoublePressed");
4413 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4415 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4416 if(TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1)
4418 AppLog("Returning because of more than one touch point.");
4421 __longPressPoint = currentPosition;
4423 if (__pHitElementResult != null)
4425 delete __pHitElementResult;
4426 __pHitElementResult = null;
4429 if (__pWebViewer != null)
4431 AppLog("MainForm::OnTouchLongPressed web not null");
4432 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4435 if (__pHitElementResult == null)
4440 if (__pHitElementResult->HasImage() == true)
4442 if(__pWebViewer != null)
4443 InitImageContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4444 __pImageMenu->SetShowState(true);
4445 __pImageMenu->Show();
4446 __pImageMenu->Invalidate(true);
4448 else if(__pHitElementResult->HasUrl() == true)
4450 String tempURl = __pHitElementResult->GetUrl();
4451 AppLog("tempURl is %ls", tempURl.GetPointer());
4452 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4453 if (pBitmap != null)
4461 InitImageLinkContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4462 __pImageMenu->SetShowState(true);
4463 __pImageMenu->Show();
4464 __pImageMenu->Invalidate(true);
4468 String tagName = __pHitElementResult->GetTagName();
4469 String type = __pHitElementResult->GetAttributeValue("type");
4470 String value = __pHitElementResult->GetAttributeValue(L"value");
4471 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4473 __currentSelectedStr.Clear();
4474 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4476 AppLog("tag name is %ls", tagName.GetPointer());
4477 AppLog("type is %ls", type.GetPointer());
4481 __isLongPressedDone = true;
4482 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4483 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && innerHtml.GetLength() == 0 && type.CompareTo(L"submit") !=0 && type.CompareTo(L"range") !=0/*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.CompareTo(L"") == 0 && r == E_INVALID_ARG)
4485 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4487 InitSelectTextContextMenu(Point(currentPosition.x , currentPosition.y + __pWebViewer->GetY()),true, true);
4490 __pImageMenu->SetShowState(true);
4491 __pImageMenu->Show();
4492 __pImageMenu->Invalidate(true);
4495 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4498 // __inputEventToBeSupressed = true;
4502 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4504 AppLog("xyz:: MainForm::OnTouchReleased called");
4506 if (__pAddressbar && __pAddressbar->GetShowState() == true)
4508 __pAddressbar->SetShowState(false);
4510 if(__pFooterPanel && __isKeypadOpened == false)
4512 __pFooterPanel->SetShowState(true);
4516 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4517 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4519 __pWebViewer->ConsumeInputEvent();
4521 if(pHitElement != null)
4525 __inputEventToBeSupressed = false;*/
4529 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4536 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4538 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4540 __currentSearchStr = L"";
4541 __currentWordIndex = 0;
4542 __maxOccurrances = 0;
4544 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4546 __pFindWordEditField->SetText(L"");
4547 __pFindWordEditField->HideKeypad();
4548 __pFindWordControl->SetShowState(false);
4549 __pFindWordCountLabel->SetText(L"0/0");
4551 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4553 __pFindWordEditFieldRightToLeft->SetText(L"");
4554 __pFindWordEditFieldRightToLeft->HideKeypad();
4555 __pFindWordControl->SetShowState(false);
4556 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4559 __pFindWordNext->SetEnabled(false);
4560 __pFindWordPrev->SetEnabled(false);
4562 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
4563 __pFindWordControl->SetShowState(false);
4565 AppLog("__pAddressbar->GetShowState() %d",__pAddressbar->GetShowState());
4566 if(__pAddressbar->GetShowState() == false)
4568 __pAddressbar->SetAddressbarURLFocus();
4569 __pFooterPanel->SetShowState(false);
4576 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4582 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4588 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4594 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4600 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4606 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4608 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4609 int widthContextItem = 0;
4610 if(__pFindWordCountLabel)
4611 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4612 // As per the platform engineer comment removed this line
4613 /*if(__pWebViewer != null)
4615 // 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
4616 __pWebViewer->ReleaseBlock();
4619 // if(__pFindWordControl != null)
4620 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4622 if(__pOptionMenu && __pOptionMenu->GetShowState() == true)
4624 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
4626 AppLog(" Orientation landscape");
4627 __pOptionMenu->SetMaxVisibleItemsCount(5);
4631 AppLog(" Orientation potrait");
4632 __pOptionMenu->SetMaxVisibleItemsCount(6);
4635 if(__pNotification && __pNotification->GetShowState() == true)
4637 __pNotification->SetShowState(false);
4638 __pNotification->Invalidate(false);
4640 if ( __pFooterLabel != null)
4642 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4645 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4651 if (__pFindWordBgLabel != null)
4653 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4654 if (pBitmap != null)
4656 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4661 if (__pFindWordBgLabelRightToLeft != null)
4663 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4664 if (pBitmap != null)
4666 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4672 // if(__pOptionMenu != null)
4673 // __pOptionMenu->SetShowState(false);
4675 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4677 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4681 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4686 AppLog("__pFooterPanel->GetShowState() is true");
4688 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4689 __pFooterPanel->Invalidate(true);
4693 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4694 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4696 InitMostVisitedSitesView(orientationStatus);
4699 RelayoutControls(false);
4700 if (__pArticleReaderPanel != null)
4702 if (__pArticleReaderPanel->GetShowState() == true)
4704 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4706 if (__pBlankPanel != null)
4707 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4709 if (__pWebReader != null)
4711 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4713 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4714 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4716 if ( pBitmap != null && pSrcBitmap != null)
4718 AppLog("CreateReaderPanel ninepatchbitmap found");
4719 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4722 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4723 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4724 if (pBitmap != null)
4729 if (pSrcBitmap != null)
4738 if (__pAddressbar != null)
4740 int width = GetClientAreaBounds().width;
4741 __pAddressbar->OrientationChanged(width);
4746 MainForm::OnSettingsChange(int settingvalue)
4748 AppLogDebug("MainForm::OnSettingsChange entered");
4750 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4752 __pAddressbar->ResetGuideText();
4754 if (__pWebViewer == null)
4756 AppLogDebug("Webviewer is not initialized yet.");
4760 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4762 WebSetting settings = __pWebViewer->GetSetting();
4763 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4765 settings.SetAutoFittingEnabled(true);
4767 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
4769 settings.SetAutoFittingEnabled(false);
4771 __pWebViewer->SetSetting(settings);
4773 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4775 WebSetting settings = __pWebViewer->GetSetting();
4776 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4777 __pWebViewer->SetSetting(settings);
4779 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4781 WebSetting settings = __pWebViewer->GetSetting();
4782 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4783 __pWebViewer->SetSetting(settings);
4784 __pWebViewer->Reload();
4786 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4788 WebSetting settings = __pWebViewer->GetSetting();
4789 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4790 __pWebViewer->SetSetting(settings);
4792 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4796 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4799 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
4803 WebSetting settings = __pWebViewer->GetSetting();
4804 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
4805 __pWebViewer->SetSetting(settings);
4808 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
4812 WebSetting settings = __pWebViewer->GetSetting();
4813 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
4814 __pWebViewer->SetSetting(settings);
4817 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4819 WebSetting settings = __pWebViewer->GetSetting();
4820 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4822 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4826 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4828 __pWebViewer->SetSetting(settings);
4830 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4834 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4835 WebSetting settings = __pWebReader->GetSetting();
4836 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4837 __pWebReader->SetSetting(settings);
4843 MainForm::OnSettingsReset()
4847 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4848 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4853 MainForm::OnClearCache()
4855 result r = E_SUCCESS;
4857 if (__pWebViewer != NULL)
4859 r = __pWebViewer->ClearCache();
4862 AppLogDebug("Cache cleared success");
4866 AppLogDebug("Cache cleared fail");
4872 MainForm::OnClearCookie()
4874 result r = E_SUCCESS;
4876 if (__pWebViewer != NULL)
4878 __pWebViewer->ClearCookie();
4882 AppLogDebug("Cookie cleared success");
4886 AppLogDebug("Cache cleared fail");
4891 MainForm::OnClearFormData()
4893 result r = E_SUCCESS;
4895 if (__pWebViewer != NULL)
4897 __pWebViewer->ClearFormData();
4901 AppLogDebug("Cookie cleared success");
4905 AppLogDebug("Cache cleared fail");
4910 MainForm::OnClearPasswords()
4912 result r = E_SUCCESS;
4914 if (__pWebViewer != NULL)
4916 __pWebViewer->ClearLoginFormData();
4920 AppLogDebug("Cookie cleared success");
4924 AppLogDebug("Cache cleared fail");
4930 MainForm::findDistance(int x1,int y1,int x2, int y2)
4932 int deltaX = Math::Abs(x2 - x1);
4933 int deltaY = Math::Abs(y2 - y1);
4934 double num = deltaX*deltaX + deltaY*deltaY;
4940 for (i = 0; i < 20; i++)
4942 x = (((x*x)+ num)/(2*x));
4953 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4955 AppLog("xyz:: MainForm::OnTouchPressed called");
4956 if(__pFindWordControl)
4958 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4959 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4961 __isLongPressedDone = false;
4966 IList* pList = null;
4967 pList = touch.GetTouchInfoListN(source);
4971 int count = pList->GetCount();
4974 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4975 __touchPoint1 = pTouchInfo->position;
4977 /*if (__pAddressbar != null)
4979 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4981 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4983 __pAddressbar->SaveAddressbarEditText();
4985 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4988 __pAddressbar->Invalidate(true);
4990 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4992 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4994 //__pAddressbar->SaveAddressbarEditText();
4996 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4999 else if (count == 2)
5001 AppLogDebug("MainForm::OnTouchPressed count is two");
5002 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5003 __touchPoint1 = pTouchInfo->position;
5005 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
5006 __touchPoint2 = pTouchInfo->position;
5011 pList->RemoveAll(true);
5016 __pAddressbar->SetShowState(false);
5018 if(__pFooterPanel && __isKeypadOpened == false)
5020 __pFooterPanel->SetShowState(true);
5022 RelayoutControls(false);
5027 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5029 // __currentWordIndex = 0;
5030 __isLongPressedDone = false;
5035 MainForm::MoveUiControls()
5040 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
5042 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
5044 if(__pFooterUrlField->GetTextLength() == 0)
5046 __pFooterUrlField->SetKeypadActionEnabled(false);
5050 __pFooterUrlField->SetKeypadActionEnabled(true);
5053 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
5055 __currentSearchStr = __pFindWordEditField->GetText();
5056 if (__currentSearchStr.GetLength() > 0)
5058 __pFindWordCountLabel->SetShowState(true);
5062 // __pFindWordCountLabel->SetShowState(false);
5063 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
5064 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
5067 __pFindWordNext->SetEnabled(false);
5068 __pFindWordPrev->SetEnabled(false);
5069 __pFindWordNext->Invalidate(true);
5070 __pFindWordPrev->Invalidate(true);
5071 __pFindWordCountLabel->SetText(L"0/0");
5072 __pFindWordCountLabel->Invalidate(true);
5074 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
5076 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
5077 if (__currentSearchStr.GetLength() > 0)
5079 __pFindWordCountLabelRightToLeft->SetShowState(true);
5083 __pFindWordCountLabelRightToLeft->SetShowState(false);
5086 __pFindWordNext->SetEnabled(false);
5087 __pFindWordPrev->SetEnabled(false);
5088 __pFindWordNext->Invalidate(true);
5089 __pFindWordPrev->Invalidate(true);
5090 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
5091 __pFindWordCountLabelRightToLeft->Invalidate(true);
5093 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
5094 if (__currentSearchStr.GetLength() > 0)
5100 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
5102 __currentSearchStr = L"";
5103 AppLogDebug("Enter something");
5108 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
5115 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
5117 if(__pWebViewer != null)
5120 AppLog("MainForm::InitMostVisitedSitesView");
5121 result r = E_SUCCESS;
5124 if (__pWebViewer != null && __pMostVisitedListView != null)
5129 if (__pMostVisitedListView != null)
5131 RemoveControl(__pMostVisitedListView);
5133 if(__pMostVisitedSites != null)
5135 __pMostVisitedSites->RemoveAll(true);
5138 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
5140 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
5141 __pMostVisitedListView = new(std::nothrow) ListView();
5143 int height = GetClientAreaBounds().height;
5145 if(__pFooterPanel->GetShowState() == true)
5147 height = height - __pFooterPanel->GetHeight();
5149 if(__pAddressbar->GetShowState() == true)
5151 height -= __pAddressbar->GetHeight();
5154 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
5158 delete __pMostVisitedListView;
5159 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
5162 __pMostVisitedListView->SetItemProvider(*this);
5163 __pMostVisitedListView->AddListViewItemEventListener(*this);
5164 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_VISITED_SITES"));
5165 AddControl(__pMostVisitedListView);
5166 __pMostVisitedListView->UpdateList();
5173 MainForm::GetImagePath(void)
5177 String formattedTime;
5178 DateTime currentTime;
5179 LocaleManager localManager;
5180 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
5182 localManager.Construct();
5183 Locale locale = localManager.GetSystemLocale();
5184 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
5186 // Get date formatter
5187 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
5191 pTimeFormatter->Format(currentTime, formattedTime);
5194 AppLog("current time stamp is %ls", formattedTime.GetPointer());
5195 String delim(L" :");
5196 StringTokenizer strTok(formattedTime, delim);
5199 String str1("GMT+00");
5200 while (strTok.HasMoreTokens())
5202 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
5203 if(token.Equals(str1))
5205 AppLog("token is %ls", token.GetPointer());
5206 imageName.Append(token);
5212 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
5214 result r = E_FAILURE;
5215 AppLog("Content manager 1");
5216 ContentId contentId;
5217 ContentManager contentManager;
5218 r = contentManager.Construct();
5221 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
5224 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
5225 Tizen::Io::Directory::Create(contentPath,true);
5226 if(GetLastResult() == E_FILE_ALREADY_EXIST)
5228 AppLog("Already exists");
5230 else if(GetLastResult() == E_SUCCESS)
5232 AppLog("created success");
5234 contentPath.Append(imageName);
5235 contentPath.Append(".jpg");
5236 contentId = contentManager.CreateContent(*aBuffer, contentPath);
5237 ShowIndicatorNotification(L"Download Complete",contentPath);
5238 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5242 MainForm::ShowIndicatorNotification(const String& messageText, const String& contentPath)
5244 AppLogDebug("ENTER");
5246 NotificationRequest request;
5247 request.SetAlertText(messageText);
5248 request.SetTitleText(L"");
5249 request.SetAppMessage(contentPath);
5250 request.SetOngoingActivityType(ONGOING_ACTIVITY_TYPE_TEXT);
5251 request.SetNotificationStyle(NOTIFICATION_STYLE_THUMBNAIL);
5252 Tizen::App::App* pApp = Tizen::App::App::GetInstance();
5253 String homePath = pApp->GetAppRootPath();
5254 String iconPath = homePath + L"res/screen-density-xhigh/Notification_download_complete.png";
5255 AppLog("The iconPath is : %ls", homePath.GetPointer());
5256 request.SetIconFilePath(iconPath);
5258 Tizen::Shell::NotificationManager notiMgr;
5259 notiMgr.Construct();
5260 notiMgr.NotifyOngoingActivity(request);
5261 AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));
5266 MainForm::SetForwardButtonEnabled(bool isEnabled)
5268 __pGoForwardBtn->SetEnabled(isEnabled);
5269 __pGoForwardBtn->Invalidate(true);
5273 MainForm::SetBackButtonEnabled(bool isEnabled)
5275 __pGoBackBtn->SetEnabled(isEnabled);
5276 __pGoBackBtn->Invalidate(true);
5280 MainForm::UpdateProgress(int percentage)
5282 __progressPercentage = percentage;
5283 if (percentage == 0 || percentage == 100)
5285 __isLoadingData = false;
5286 if (percentage == 100)
5288 __isLoadingCompleted = true;
5289 __progressPercentage = 0;
5293 __isLoadingCompleted = false;
5298 __isLoadingData = true;
5300 UpdateProgressBitmap();
5304 MainForm::GetProgress(void)
5306 return __progressPercentage;
5310 MainForm::UpdateProgressBitmap(void)
5312 result r = E_SUCCESS;
5313 if (__pProgressbarLabel == null)
5315 int w = __pProgressbarLabel->GetWidth();
5316 int h = __pProgressbarLabel->GetHeight();
5318 int progressWidth = 0;
5319 Bitmap* pRetBitmap = null;
5321 if (__progressPercentage == 0 || __progressPercentage == 100)
5323 __pProgressbarLabel->SetShowState(false);
5324 __pProgressbarLabel->Invalidate(false);
5329 __pProgressbarLabel->SetShowState(true);
5330 __pProgressbarLabel->Invalidate(false);
5333 r = canvas.Construct(Rectangle(0, 0, w, h));
5337 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5342 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5346 pBgBmp->Scale(Dimension(w, h));
5347 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5351 progressWidth = (double) (w) * __progressPercentage / 100;
5352 AppLogDebug("progressWidth: %d", progressWidth);
5353 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5355 if (pProgressBmp != null)
5357 pProgressBmp->Scale(Dimension(progressWidth, h));
5358 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5359 delete pProgressBmp;
5362 pRetBitmap = new (std::nothrow) Bitmap();
5364 if (pRetBitmap == null)
5366 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5370 pRetBitmap->Construct(canvas, canvas.GetBounds());
5372 if (__pProgressbarLabel != null && pRetBitmap != null)
5374 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5375 __pProgressbarLabel->Invalidate(false);
5378 if (pRetBitmap != null)
5387 MainForm::ReaderClicked()
5389 result r = E_SUCCESS;
5390 ArrayList* pArgList = new(std::nothrow) ArrayList();
5391 if (pArgList != null)
5393 r = pArgList->Construct();
5400 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5407 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5414 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5422 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5428 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5430 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5432 __currentAddMode = addMode;
5436 case ADDRESSBAR_MODE_INVALID:
5441 case ADDRESSBAR_MODE_READER:
5443 __pStopBtn->SetShowState(false);
5444 __pRefreshBtn->SetShowState(false);
5445 __pClearBtn->SetShowState(false);
5446 __pReaderBtn->SetShowState(false);
5449 case ADDRESSBAR_MODE_LOADING:
5451 __pRefreshBtn->SetShowState(false);
5452 __pStopBtn->SetShowState(true);
5453 __pClearBtn->SetShowState(false);
5454 __pReaderBtn->SetShowState(false);
5457 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5459 // SetUrl(__pAddressbar->GetUrl());
5461 __pRefreshBtn->SetShowState(true);
5462 __pStopBtn->SetShowState(false);
5463 __pClearBtn->SetShowState(false);
5464 __pReaderBtn->SetShowState(false);
5467 case ADDRESSBAR_MODE_EDIT:
5469 __pRefreshBtn->SetShowState(false);
5470 __pStopBtn->SetShowState(false);
5471 __pReaderBtn->SetShowState(false);
5472 __pClearBtn->SetShowState(true);
5479 OnAddressBarModeChanged();
5482 AddressBarMode MainForm::GetAddressbarMode(void)
5484 return __currentAddMode;
5487 void MainForm::SetUrl(const String& url)
5490 if(__displayUrl.GetLength() > 2048)
5491 __displayUrl.SubString(0,2048,__displayUrl);
5493 if (__pFooterUrlField != NULL)
5495 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5496 if (removedHttpUrl.IsEmpty() == false)
5498 __pFooterUrlField->SetText(removedHttpUrl);
5499 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5500 __pAddressbar->SetUrl(__displayUrl);
5504 __pFooterUrlField->SetText(__displayUrl);
5505 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5506 __pAddressbar->SetUrl(__displayUrl);
5508 if(__pFooterUrlField)
5509 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5510 __pFooterUrlField->Invalidate(false);
5511 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5512 __pAddressbar->Invalidate(true);
5513 // __pFooterUrlField->SetCursorPosition(0);
5518 MainForm::RemoveHttpTextFromDisplayURL(void)
5520 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5522 // bool isHttpText = __displayUrl.Contains(L"http://");
5523 String updatedDisplayUrl;
5524 updatedDisplayUrl.Clear();
5525 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5527 __displayUrl.SubString(7,updatedDisplayUrl);
5529 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5531 __displayUrl.SubString(8,updatedDisplayUrl);
5533 return updatedDisplayUrl;
5536 void MainForm::OnSharePopupControlStarted(void)
5538 __pWebViewer->AddTouchEventListener(*this);
5542 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5544 if (requestId == BACK_GROUND_APP_EVENT)
5546 if(__pWebViewer != null)
5548 __pWebViewer->Pause();
5552 __pImageMenu->SetShowState(false);
5554 if(__pAddressbar != null)
5556 __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5559 else if(requestId == FORE_GROUND_APP_EVENT)
5561 if(__pWebViewer != null)
5563 __pWebViewer->Resume();
5565 if(__pAddressbar != null)
5567 __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5573 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5575 AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5576 result r = E_SUCCESS;
5579 __pAddressbar->SetShowState(false);
5581 AppLog("akjshdasd 5");
5582 __pFooterPanel->SetShowState(true);
5585 __pWebViewer->SetFocus();
5586 else if(__pMostVisitedListView)
5587 __pMostVisitedListView->SetFocus();
5588 else if(__pMultiWindowButton)
5589 __pMultiWindowButton->SetFocus();
5590 else if(__pMoreButton)
5591 __pMoreButton->SetFocus();
5593 __pAddressbar->SetShowState(false);
5595 RelayoutControls(false);
5599 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5601 AppLog("MainForm::OnFormMenuRequested called");
5603 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer && __pWebViewer->GetShowState() == true)
5605 int bookmarkCount=0;
5608 url=__pWindowInfo->pageUrl;
5609 AppLog("MainForm::OnFormMenuRequested url %ls",url.GetPointer());
5610 result r = E_SUCCESS;
5611 Bitmap* pBitmap = null;
5612 String lastChar = L"";
5613 // if(url.SubString(url.GetLength()-1,lastChar));
5614 // if(lastChar == L"/")
5616 // bool exist1 = false;
5617 // bool exist2 = false;
5618 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist1);
5619 // url.SubString(0,url.GetLength() - 1,url);
5620 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist2);
5621 // exist = exist1 | exist2;
5625 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5628 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5634 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5638 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5640 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5642 if (__pOptionMenu->GetItemCount() == 9)
5644 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5648 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5653 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
5657 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
5658 if (__pOptionMenu->GetItemCount() != 9)
5660 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
5661 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
5662 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
5663 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
5664 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
5665 __pOptionMenu->SetMaxVisibleItemsCount(6);
5667 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
5669 AppLog(" Orientation landscape");
5670 __pOptionMenu->SetMaxVisibleItemsCount(5);
5674 AppLog(" Orientation potrait");
5675 __pOptionMenu->SetMaxVisibleItemsCount(6);
5678 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
5681 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
5683 __pAddressbar->SetShowState(false);
5685 __pFooterPanel->SetShowState(true);
5686 result r = __pOptionMenu->SetShowState(true);
5687 AppLog("ajsghd %s",GetErrorMessage(r));
5688 RelayoutControls(false);
5689 __pOptionMenu->Invalidate(true);
5690 __pOptionMenu->Show();