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 && __pWindowInfo->isFirstLaunch == true)
2750 __pWindowInfo->isFirstLaunch = false;
2753 __pWindowInfo->pCurrentWeb = __pWebViewer;
2754 if(__pWindowInfo->pageUrl.GetLength() > 0)
2755 LoadUrl(__pWindowInfo->pageUrl);
2759 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2760 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2761 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2763 InitMostVisitedSitesView(GetOrientationStatus());
2765 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2767 if(__pMostVisitedListView != null)
2769 __pMostVisitedListView->SetShowState(false);
2773 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2775 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2777 if (pBookmarkUrl == null)
2779 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2780 //__pAddressbar->SetUrl(*pBookmarkUrl);
2781 SetUrl(*pBookmarkUrl);
2783 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2784 __pWebViewer->LoadUrl(*pBookmarkUrl);
2785 delete pBookmarkUrl;
2788 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2789 Bitmap* pBitmap = null;
2790 if (isPrivateBrowsing == true)
2792 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2794 if (__pWebViewer != null)
2796 __pWebViewer->SetPrivateBrowsingEnabled(true);
2799 if (__pAddressbar != null)
2801 // __pAddressbar->UpdateFaviconBitmap(true);
2807 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2809 if (__pWebViewer != null)
2811 __pWebViewer->SetPrivateBrowsingEnabled(false);
2814 if (__pAddressbar != null)
2816 // __pAddressbar->UpdateFaviconBitmap(false);
2820 if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
2822 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2824 else if (__pOptionMenu != null )
2826 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2829 if (pBitmap != null)
2834 RelayoutControls(false);
2835 AppLog("ABC: OnSceneActivatedN started exit");
2840 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2841 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2843 Canvas* pWebCanvas = null;
2844 if (__pWebViewer != null)
2846 pWebCanvas = __pWebViewer->GetCanvasN();
2849 if (pWebCanvas == null)
2853 if (__pWindowInfo != null)
2855 if (__pWindowInfo->pWebCanvasBitmap != null)
2857 delete __pWindowInfo->pWebCanvasBitmap;
2859 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2860 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2861 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2863 Bitmap* pBitmap = GetCapturedBitmapN();
2864 AppLog("Coming here");
2865 Canvas* pCanvas = new(std::nothrow) Canvas();
2866 pCanvas->Construct(GetClientAreaBounds());
2869 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2872 if(__pWebViewer != null && __pWindowInfo != null)
2873 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2875 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2876 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2880 __pAddressbar->SetShowState(false);
2881 AppLog("Coming here");
2885 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2886 const Tizen::Base::String& realm,
2887 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2893 MainForm::OnHttpAuthenticationCanceled(void)
2898 MainForm::OnLoadingStarted(void)
2900 AppLogDebug("MainForm::OnLoadingStarted entered");
2902 if(__pAddressbar == NULL || __pWebViewer == null)
2907 // this is added in case if menu is opened and user load the page
2908 if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
2910 __pOptionMenu->SetShowState(false);
2911 __pOptionMenu->Invalidate(true);
2916 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2918 __pImageMenu->SetShowState(false);
2919 __pImageMenu->Invalidate(true);
2921 String url = __pWebViewer->GetUrl();
2922 if(url.Contains(IDS_TIZEN_SERVICE))
2925 String delim(L":;,");
2927 // Creates a StringTokenizer instance
2928 StringTokenizer strTok(url, delim);
2930 int count = strTok.GetTokenCount(); // count == 4
2932 HashMap *pMap = new HashMap();
2937 while (strTok.HasMoreTokens())
2939 AppLog("Token: %ls", token.GetPointer());
2940 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2941 if(token.Contains(IDS_APPID))
2943 token.SubString(6, appId);
2944 AppLog("AppID:%ls", appId.GetPointer());
2946 else if(token.Contains(IDS_KEY))
2948 token.SubString(4, key);
2949 AppLog("key:%ls", key.GetPointer());
2951 else if(token.Contains(IDS_VALUE))
2953 token.SubString(6, value);
2954 AppLog("value:%ls", value.GetPointer());
2957 pMap->Add(key, value);
2961 AppControl *pAppControl = null;
2962 String operationId = L"http://tizen.org/appcontrol/operation/main";
2963 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2966 AppLog("Starting AppControl");
2967 result r = pAppControl->Start(null, null, pMap, null);
2968 AppLog("Result of Start %s", GetErrorMessage(r));
2972 AppLogException("AppControl not found");
2977 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
2979 __pAddressbar->SetShowState(false);
2980 AddressBarCancelledClicked(*__pAddressbar);
2981 __pAddressbar->Invalidate(true);
2983 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2986 __pAddressbar->SetFaviconBitmap(*pBitmap);
2989 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2991 // updating the address bar position with respect to web control
2992 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2993 __distanceMoved = 0;
2997 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2998 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2999 if (__pWebViewer != null)
3001 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
3002 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
3003 SetUrl(__pWebViewer->GetUrl());
3004 if (__pWindowInfo != NULL)
3006 // resetting the page title to blank, it will be received in OnPageTitleReceived()
3007 __pWindowInfo->pageTitle = L"";
3008 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3010 __pAddressbar->Invalidate(true);
3016 MainForm::OnLoadingCanceled(void)
3023 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
3025 AppLog("XYZ::MainForm::OnKeypadWillOpen");
3030 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
3032 AppLog("XYZ::MainForm::OnKeypadOpened");
3033 __isKeypadOpened = true;
3034 __pFooterPanel->SetShowState(false);
3039 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
3041 AppLog("XYZ::MainForm::OnKeypadClosed");
3042 __isKeypadOpened = false;
3043 __pFooterPanel->SetShowState(true);
3044 RelayoutControls(true);
3048 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
3050 AppLog("XYZ::KeypadBoundsChanged");
3051 RelayoutControls(false);
3055 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
3056 const Tizen::Base::String& reason)
3058 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
3062 MainForm::OnLoadingCompleted(void)
3064 AppLog("MainForm::OnLoadingCompleted start");
3066 result r = E_SUCCESS;
3068 if (__pWebViewer == null)
3073 if (__pAddressbar == null)
3078 if(__pImageMenu && __pImageMenu->GetShowState())
3080 __pImageMenu->SetShowState(false);
3081 __pImageMenu->Invalidate(true);
3084 if (__pWebViewer->CanGoForward())
3086 //__pAddressbar->SetForwardButtonEnabled(true);
3087 SetForwardButtonEnabled(true);
3091 //__pAddressbar->SetForwardButtonEnabled(false);
3092 SetForwardButtonEnabled(false);
3095 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3097 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3099 //__pAddressbar->UpdateProgress(0);
3103 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3105 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3109 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
3110 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
3111 if (isPrivateBrowsing == false)
3113 if(__pHistory != null)
3119 __pHistory = new(std::nothrow) History;
3120 HistoryPresentationModel::GetCurrentDateTime(date);
3123 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
3124 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
3126 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
3127 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3129 __pHistory->SetVisitedTime(date);
3131 if (__pWebViewer != null)
3133 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3135 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3136 if (pTempBitmap != null)
3138 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3139 __pHistory->SetFavIconBitmap(*pTempBitmap);
3142 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3145 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3146 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3147 if ( pCanvas != null && pCanvas != null && pBitmap != null)
3149 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3150 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3151 __pHistory->SetThumbnail(pBitmap);
3153 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3156 __pHistory->SetFavIconBitmap(*pFavIcon);
3160 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3167 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3169 // temperary fixed (webpage can be not loaded)
3173 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3174 if (isReaderEnabled == true)
3178 delete __pReaderData;
3179 __pReaderData = null;
3181 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3182 filePath.Append(L"data/reader.js");
3188 result r = E_SUCCESS;
3189 FileAttributes attr;
3191 File::GetAttributes(filePath,attr);
3193 r = file.Construct(filePath, L"r+");
3196 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3199 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3202 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3205 // file.Read(pScript,attr.GetFileSize());
3207 // AppLogDebug("scipt length %d",strlen(pScript));
3208 String strScript = L"";
3209 // strScript.Append(pScript);
3210 // for(int i=0; i<25; i++)
3212 file.Read(pScript,attr.GetFileSize());
3213 // AppLog("xyzz tell %d",file.Tell());
3214 // r = strScript.Append(pScript);
3215 // AppLog("xyzz append result %s",GetErrorMessage(r));
3216 // AppLog("xyzz strScript length %d",strScript.GetLength());
3218 // AppLog("xyzz final strScript length %d",strScript.GetLength());
3220 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3221 if (__pReaderData == null)
3223 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3224 __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>");
3227 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3228 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3230 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3231 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3237 AppLog("MainForm::OnLoadingCompleted done");
3241 MainForm::OnEstimatedProgress(int progress)
3243 AppLogDebug("MainForm::OnEstimatedProgress entered %d",progress);
3245 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3246 progress = DEFAULT_PROGRESS_PERCENTAGE;
3248 // __pAddressbar->UpdateProgress(progress);
3249 UpdateProgress(progress);
3252 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3254 AppLog("MainForm::OnFaviconReceived");
3255 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3257 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3260 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3267 MainForm::OnUrlValueChanged(Addressbar&)
3273 MainForm::OnUrlSubmitted(Addressbar& addBar)
3275 AppLog("MainForm::OnUrlSubmitted");
3276 String url = addBar.GetUrl();
3277 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3279 if(__pFooterUrlField)
3280 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3281 AddressBarCancelledClicked(*__pAddressbar);
3286 MainForm::LoadUrl(String& url)
3290 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3291 AppLogDebug("MainForm::LoadUrl enter");
3293 if (__pWebViewer != null)
3295 __pWebViewer->SetShowState(true);
3296 __pWebViewer->Invalidate(true);
3299 if (url.CompareTo(L"") == 0)
3303 if(__pFooterPanel != null)
3305 __pFooterPanel->SetShowState(true);
3306 __pFooterPanel->Invalidate(true);
3313 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3314 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)
3316 RegularExpression firstRegex;
3317 RegularExpression secondRegex;
3319 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3320 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3323 ret = firstRegex.Match(url, false); // This returns true value
3324 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3326 if (ret == true && __pWebViewer != null)
3329 __pWebViewer->LoadUrl(url);
3331 else if(__pWebViewer != null)
3333 String tempUrl = L"http://";
3334 tempUrl.Append(url);
3338 __pWebViewer->LoadUrl(tempUrl);
3342 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3343 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3346 if (__pAddressbar != null)
3348 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3349 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3352 AppLogDebug("MainForm::LoadUrl exit");
3359 MainForm::OnFocusGained(const Tizen::Ui::Control& source)
3361 AppLog("MainForm::OnFocusGained");
3364 __pFooterPanel->SetShowState(false);
3369 __pAddressbar->SetShowState(true);
3370 __pAddressbar->SetAddressbarURLFocus();
3372 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3374 __currentSearchStr = L"";
3375 __currentWordIndex = 0;
3376 __maxOccurrances = 0;
3378 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
3380 __pFindWordEditField->SetText(L"");
3381 __pFindWordEditField->HideKeypad();
3382 __pFindWordControl->SetShowState(false);
3383 __pFindWordCountLabel->SetText(L"0/0");
3385 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
3387 __pFindWordEditFieldRightToLeft->SetText(L"");
3388 __pFindWordEditFieldRightToLeft->HideKeypad();
3389 __pFindWordControl->SetShowState(false);
3390 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
3393 __pFindWordNext->SetEnabled(false);
3394 __pFindWordPrev->SetEnabled(false);
3396 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
3397 __pFindWordControl->SetShowState(false);
3399 RelayoutControls(false);
3403 MainForm::OnFocusLost(const Tizen::Ui::Control& source)
3405 AppLog("MainForm::OnFocusLost called");
3409 MainForm::OnStopClicked(Addressbar& addBar)
3411 AppLogDebug("MainForm::OnStopClicked called");
3414 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3415 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3416 __pWebViewer->StopLoading();
3417 RequestRedraw(true);
3422 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3424 // AppLog("MainForm::OnBackClicked");
3425 result r = E_FAILURE;
3426 if(__pImageMenu && __pImageMenu->GetShowState() == true)
3428 AppLog("Hiding the menu");
3429 __pImageMenu->SetShowState(false);
3432 if (__pWebViewer && __pWebViewer->CanGoBack())
3434 __pWebViewer->GoBack();
3436 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3439 pApp = UiApp::GetInstance();
3442 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3445 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3453 WindowInfo* pWindowInfo = null;
3455 SceneManager* pSceneManager = SceneManager::GetInstance();
3456 if (pSceneManager == null)
3460 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3461 if (pAllWindowList == NULL)
3463 pApp = UiApp::GetInstance();
3466 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3469 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3474 if (pAllWindowList != null)
3476 totalCount = pAllWindowList->GetCount();
3478 for (int count = 0; count < totalCount; count++)
3480 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3481 if (pWindowInfo == null)
3483 pApp = UiApp::GetInstance();
3486 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3489 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3494 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3496 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3499 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3502 r = pAllWindowList->RemoveAt(count, true);
3503 __pWindowInfo = null;
3506 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3511 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3513 else if(pAllWindowList->GetCount() > 0)
3515 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3519 pApp = UiApp::GetInstance();
3522 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3527 if (pWindowInfo == null)
3529 pApp = UiApp::GetInstance();
3532 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3538 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3541 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3555 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3557 AppLog("MainForm::OnForwardClicked");
3558 if (__pWebViewer == null)
3561 if (__pWebViewer->CanGoForward())
3563 __pWebViewer->GoForward();
3568 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3570 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3571 if(__pFooterPanel != null)
3573 __pFooterPanel->SetShowState(false);
3576 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3578 __pAddressbar->SetShowState(true);
3579 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3582 RelayoutControls(false);
3586 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3588 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3590 int Height = GetClientAreaBounds().height;
3591 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3593 RelayoutControls(false);
3597 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3599 AddressBarCancelledClicked(addBar);
3603 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3605 __prevAddressBarMode = __curAddressBarMode;
3607 if (__pAddressbar != null)
3609 __curAddressBarMode = GetAddressbarMode();
3612 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3614 __adressPanelPosition.y = 0;
3615 if (__pAddressbar != null)
3617 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3618 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3619 __pAddressbar->Invalidate(true);
3621 if (__pWebViewer != null)
3623 __pWebViewer->StopLoading();
3626 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3628 __adressPanelPosition.y = 0;
3629 if (__pAddressbar != null)
3631 __webControlPosition.y = 0;
3632 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3633 __pAddressbar->Invalidate(true);
3639 MainForm::OnClipboardClosed(const Addressbar& addBar)
3641 AppLog("XYZ::MainForm::OnClipboardClosed");
3642 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3644 AppLog("akjshdasd 3");
3645 __pFooterPanel->SetShowState(true);
3647 __isKeypadOpened = false;
3648 RelayoutControls(false);
3652 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3654 AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3655 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3657 AppLog("akjshdasd 3");
3658 __pFooterPanel->SetShowState(true);
3660 __isKeypadOpened = false;
3662 RelayoutControls(false,footerState);
3666 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3668 AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3669 __isKeypadOpened = true;
3670 RelayoutControls(false);
3674 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3676 __isKeypadOpened = true;
3677 __pFooterPanel->SetShowState(false);
3681 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3683 AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3684 RelayoutControls(false);
3688 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3690 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3693 __pWindowInfo->pageTitle = title;
3694 if (__pWebViewer != null)
3696 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3697 AppLog("MainForm::OnPageTitleReceived url %ls",__pWindowInfo->pageUrl.GetPointer());
3700 if (__pAddressbar != null && __pWebViewer != null)
3702 SetUrl(__pWebViewer->GetUrl());
3703 __pAddressbar->Invalidate(true);
3708 MainForm::UpdateFavicon(void)
3710 bool urlImageType = false;
3711 String *tempPath = null;
3713 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();");
3714 Bitmap* pBitmap = null;
3716 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3718 if (__pWindowInfo != null)
3721 url.SetUri(*tempPath);
3722 if (url.GetHost().GetLength() == 0)
3725 webUrl.SetUri(__pWebViewer->GetUrl());
3726 result r = url.SetHost(webUrl.GetHost());
3733 if (url.GetScheme().GetLength() == 0)
3736 webUrl.SetUri(__pWebViewer->GetUrl());
3737 url.SetScheme(webUrl.GetScheme());
3739 __pWindowInfo->faviconUrl = url.ToString();
3741 pBitmap = __pWebViewer->GetFaviconN();
3743 if (pBitmap != null)
3745 if (__pWindowInfo->pFavicon != NULL)
3747 __pWindowInfo->pFavicon = null;
3749 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3750 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3752 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3754 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3756 else if(__pWindowInfo->pFavicon != null)
3758 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3762 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3763 if(pDefaultBmp != null)
3765 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3779 if(tempPath != null)
3783 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3789 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3790 Tizen::Web::Controls::WebNavigationType type)
3792 AppLog("urlk %ls",url.GetPointer());
3793 // when load new page if find word panel is open its show state is false
3794 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3796 __currentSearchStr = L"";
3797 __currentWordIndex = 0;
3798 __maxOccurrances = 0;
3799 __pFindWordEditField->SetText(L"");
3800 __pFindWordNext->SetEnabled(false);
3801 __pFindWordPrev->SetEnabled(false);
3802 __pFindWordCountLabel->SetText(L"0/0");
3803 __pFindWordControl->SetShowState(false);
3804 __pFindWordEditField->HideKeypad();
3805 RelayoutControls(false);
3808 __pFooterPanel->Invalidate(true);
3811 uriInfo.SetUri(url);
3813 if(url.Contains(IDS_TIZEN_SERVICE))
3816 String delim(L":;,");
3818 // Creates a StringTokenizer instance
3819 StringTokenizer strTok(url, delim);
3821 int count = strTok.GetTokenCount(); // count == 4
3823 HashMap *pMap = new HashMap();
3829 while (strTok.HasMoreTokens())
3831 AppLog("Token: %ls", token.GetPointer());
3832 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3833 if(token.Contains(IDS_APPID))
3835 token.SubString(6, appId);
3836 AppLog("AppID:%ls", appId.GetPointer());
3838 else if(token.Contains(IDS_KEY))
3840 token.SubString(4, key);
3841 AppLog("key:%ls", key.GetPointer());
3843 else if(token.Contains(IDS_VALUE))
3845 token.SubString(6, value);
3846 AppLog("value:%ls", value.GetPointer());
3849 pMap->Add(key, value);
3853 AppControl *pAppControl = null;
3854 String operationId = L"http://tizen.org/appcontrol/operation/main";
3855 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3858 result r = pAppControl->Start(null, null, pMap, null);
3862 AppLogException("AppControl not found");
3872 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3873 const Tizen::Net::Http::HttpHeader& httpHeader)
3875 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3879 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
3881 if(__isLongPressedDone == false)
3883 AppLog("MainForm::OnWebPageBlockSelected");
3884 if (__pHitElementResult != null)
3886 delete __pHitElementResult;
3887 __pHitElementResult = null;
3890 if (__pWebViewer != null)
3892 AppLog("MainForm::OnWebPageBlockSelected web not null");
3893 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3895 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
3897 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
3898 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3899 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
3901 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
3903 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
3907 if (__pHitElementResult == null)
3912 if (__pHitElementResult->HasImage() != true)
3914 String tagName = __pHitElementResult->GetTagName();
3915 String type = __pHitElementResult->GetAttributeValue("type");
3918 AppLog("TagName %ls",tagName.GetPointer());
3919 __currentSelectedStr.Clear();
3920 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3921 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3922 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3923 if(tagName.Equals(L"TEXTAREA",false) == true)
3925 AppLog("Tagnameseemstobe TEXTAREA");
3927 else if(tagName.Equals(L"INPUT",false) == true)
3929 AppLog("Tagnameseemstobe INPUT");
3932 if (((tagName.Equals(L"INPUT",false) == true) || tagName.Equals(L"TEXTAREA",false) == true) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
3934 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3936 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),true);
3937 __pImageMenu->SetShowState(true);
3938 __pImageMenu->Show();
3939 __pImageMenu->Invalidate(true);
3941 else /*if(__isLongPressedDone == true)*/
3943 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3945 if(__pHitElementResult->GetUrl().GetLength() > 0)
3947 __currentSelectedStr.Clear();
3948 __currentSelectedStr = __pHitElementResult->GetUrl();
3950 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),false);
3951 __pImageMenu->SetShowState(true);
3952 __pImageMenu->Show();
3953 __pImageMenu->Invalidate(true);
3956 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3957 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3958 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3964 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3970 MainForm::OnWebWindowCreateRequested(void)
3972 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
3974 if (pNewWindowInfo == null)
3978 result r = E_SUCCESS;
3979 SceneManager* pSceneManager = SceneManager::GetInstance();
3980 if (pSceneManager == NULL)
3984 ArrayList* pArgList = new(std::nothrow) ArrayList();
3985 if (pArgList == NULL)
3989 r = pArgList->Construct();
3992 pNewWindowInfo->isJavascriptInitiated = true;
3993 pArgList->Add(*pNewWindowInfo);
3994 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3998 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
4005 return pNewWindowInfo->pCurrentWeb;
4009 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
4011 AppLog("xyz:: MainForm::RelayoutControls called");
4012 __webControlPosition.y = 0;
4013 __webControlHeight = GetClientAreaBounds().height;
4014 AppLog("Client area height: %d", __webControlHeight);
4016 AppLog("Client area height: %d", __webControlHeight);
4017 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
4019 __webControlPosition.y += __pAddressbar->GetHeight();
4020 __webControlHeight -= __pAddressbar->GetHeight();
4021 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
4023 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
4025 __webControlPosition.y += __pFindWordControl->GetHeight();
4026 __webControlHeight -= __pFindWordControl->GetHeight();
4027 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
4030 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
4032 __webControlHeight -= __pFooterPanel->GetHeight();
4034 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
4036 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
4038 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight + 12 )
4043 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12);
4044 AppLog("xyz:: MainForm::RelayoutControls called __webControlHeight %d",__webControlHeight);
4045 __pWebViewer->Invalidate(false);
4048 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
4050 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
4057 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
4059 if (__pFindWordControl == null)
4064 Tizen::Locales::LocaleManager localeManager;
4065 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
4067 String languageCode;
4068 result r = SettingInfo::GetValue(L"Language", languageCode);
4069 // int languagecode = local.GetLanguageCode();
4070 AppLog("rahul language is %S", languageCode.GetPointer());
4074 InitFindWordPanel();
4076 if (languageCode.CompareTo("ara") == 0)
4078 AppLog("rahul language is arabic");
4080 __pFindWordPanelLeftToRight->SetShowState(false);
4081 __pFindWordPanelRightToLeft->SetShowState(true);
4083 __pFindWordClear->SetShowState(false);
4084 __pFindWordCountLabel->SetShowState(false);
4085 __pFindWordEditField->SetShowState(false);
4087 __pFindWordClearRightToLeft->SetShowState(true);
4088 __pFindWordCountLabelRightToLeft->SetShowState(true);
4089 __pFindWordEditFieldRightToLeft->SetShowState(true);
4093 AppLog("rahul language is not arabic");
4096 __pFindWordPanelLeftToRight->SetShowState(true);
4097 __pFindWordPanelRightToLeft->SetShowState(false);
4099 __pFindWordClear->SetShowState(true);
4100 __pFindWordCountLabel->SetShowState(true);
4101 __pFindWordEditField->SetShowState(true);
4103 __pFindWordClearRightToLeft->SetShowState(false);
4104 __pFindWordCountLabelRightToLeft->SetShowState(false);
4105 __pFindWordEditFieldRightToLeft->SetShowState(false);
4107 __pFindWordControl->SetShowState(true);
4111 if(__pFindWordControl != null)
4113 __pFindWordControl->SetShowState(false);
4117 AppLog("MainForm::ShowFindWordPanel %d",show);
4118 if (show && !isTouchPressed)
4120 if (languageCode.CompareTo("ara") == 0)
4122 if (__pFindWordEditFieldRightToLeft)
4124 __pFindWordEditFieldRightToLeft->SetFocus();
4125 __pFindWordEditFieldRightToLeft->ShowKeypad();
4130 if (__pFindWordEditField)
4132 __pFindWordEditField->SetFocus();
4133 __pFindWordEditField->ShowKeypad();
4139 if (languageCode.CompareTo("ara") == 0)
4141 if (__pFindWordEditFieldRightToLeft)
4142 __pFindWordEditFieldRightToLeft->HideKeypad();
4146 if (__pFindWordEditField)
4147 __pFindWordEditField->HideKeypad();
4151 RelayoutControls(false);
4155 MainForm::StartWordSearch()
4157 //Get the count of occurances of the word in the current page
4158 __maxOccurrances = 0;
4159 __currentWordIndex = 0;
4161 __pFindWordPrev->SetEnabled(false);
4162 String *pCountStr = null;
4163 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
4164 AppLog("Search Result %s",GetErrorMessage(r));
4165 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
4166 if (pCountStr != null)
4168 Integer::Parse(*pCountStr, 10, __maxOccurrances);
4172 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
4177 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
4179 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
4180 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
4182 if(totalCount == -1 || totalCount == 0)
4184 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
4185 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
4188 else if(totalCount > 100)
4190 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4191 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4195 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4196 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4199 __maxOccurrances = totalCount;
4200 __currentWordIndex = currentOrdinal;
4202 //Reset the UI controls as per the maxOccurrance value
4203 if (totalCount <= 0)
4205 AppLog("Word not found");
4206 //Show error notification to user
4207 __pFindWordNext->SetEnabled(false);
4208 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4210 __pFindWordCountLabel->SetText(L"0/0");
4211 __pFindWordCountLabel->Invalidate(false);
4213 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4215 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4216 __pFindWordCountLabelRightToLeft->Invalidate(false);
4218 __pFindWordNext->Invalidate(false);
4219 __pFindWordPrev->Invalidate(false);
4224 if (totalCount == 1)
4226 __pFindWordNext->SetEnabled(false);
4230 __pFindWordNext->SetEnabled(true);
4233 String countStr = L"";
4234 countStr.Append(__currentWordIndex);
4235 countStr.Append(L"/");
4236 countStr.Append(__maxOccurrances);
4237 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4239 __pFindWordCountLabel->SetText(countStr);
4240 __pFindWordCountLabel->Invalidate(false);
4241 __pFindWordCountLabel->Invalidate(false);
4243 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4245 __pFindWordCountLabelRightToLeft->SetText(countStr);
4246 __pFindWordCountLabelRightToLeft->Invalidate(false);
4247 __pFindWordCountLabelRightToLeft->Invalidate(false);
4249 //FindNextWord(true);
4250 //Update the controls
4251 __pFindWordNext->Invalidate(false);
4252 __pFindWordPrev->Invalidate(false);
4257 MainForm::FindNextWord(bool next)
4261 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4262 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4264 if (__currentWordIndex < __maxOccurrances)
4266 __currentWordIndex++;
4272 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4273 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4275 if(__currentWordIndex > 1)
4277 __currentWordIndex--;
4282 String countStr = L"";
4283 countStr.Append(__currentWordIndex);
4284 countStr.Append(L"/");
4285 countStr.Append(__maxOccurrances);
4287 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4289 __pFindWordCountLabel->SetText(countStr);
4290 __pFindWordCountLabel->Invalidate(false);
4292 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4294 __pFindWordCountLabelRightToLeft->SetText(countStr);
4295 __pFindWordCountLabelRightToLeft->Invalidate(false);
4298 if (__currentWordIndex >= __maxOccurrances)
4300 __pFindWordNext->SetEnabled(false);
4304 __pFindWordNext->SetEnabled(true);
4306 if (__currentWordIndex <= 1)
4308 __pFindWordPrev->SetEnabled(false);
4312 __pFindWordPrev->SetEnabled(true);
4314 __pFindWordPrev->Invalidate(false);
4315 __pFindWordNext->Invalidate(false);
4317 __pFindWordControl->Invalidate(true);
4321 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4323 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4324 __isKeypadOpened = true;
4325 __pFooterPanel->SetShowState(false);
4326 // OnAddressBarKeypadOpened(*__pAddressbar);
4330 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4332 __isKeypadOpened = true;
4333 AppLog("xyz::MainForm::OnWebKeypadOpened");
4335 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4337 __currentSearchStr = L"";
4338 __currentWordIndex = 0;
4339 __maxOccurrances = 0;
4340 __pFindWordEditField->SetText(L"");
4341 __pFindWordNext->SetEnabled(false);
4342 __pFindWordPrev->SetEnabled(false);
4343 __pFindWordCountLabel->SetText(L"0/0");
4344 __pWebViewer->SearchTextAllAsync(L"",false);
4345 __pFindWordControl->SetShowState(false);
4346 __pFindWordEditField->HideKeypad();
4350 if (__pWebViewer != null && __pFooterPanel != null)
4352 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4353 if(__pAddressbar != null)
4355 __pAddressbar->SetShowState(false);
4357 if(__pFindWordControl != null)
4359 __pFindWordControl->SetShowState(false);
4361 __pFooterPanel->SetShowState(false);
4362 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4364 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4366 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4367 // AppLog("omgomgomg");
4373 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4375 AppLog("xyz::MainForm::OnWebKeypadClosed");
4376 AppLog("akjshdasd 4");
4377 __pFooterPanel->SetShowState(true);
4378 // OnAddressBarKeypadClosed(*__pAddressbar);
4379 RelayoutControls(false);
4380 __isKeypadOpened = false;
4384 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4386 // RelativeLayout(false);
4387 if(__pWebViewer != null)
4389 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4394 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4396 Control* temp = const_cast< Control* >(&source);
4397 Header* pHeader = dynamic_cast< Header* >(temp);
4398 if (pHeader != null)
4400 //Header double - clicked
4401 AppLog("Header double clicked");
4403 if(__pFindWordControl)
4405 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4406 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4410 AppLog("MainScene::OnTouchDoublePressed");
4414 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4416 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4417 if(TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1)
4419 AppLog("Returning because of more than one touch point.");
4422 __longPressPoint = currentPosition;
4424 if (__pHitElementResult != null)
4426 delete __pHitElementResult;
4427 __pHitElementResult = null;
4430 if (__pWebViewer != null)
4432 AppLog("MainForm::OnTouchLongPressed web not null");
4433 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4436 if (__pHitElementResult == null)
4441 if (__pHitElementResult->HasImage() == true)
4443 if(__pWebViewer != null)
4444 InitImageContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4445 __pImageMenu->SetShowState(true);
4446 __pImageMenu->Show();
4447 __pImageMenu->Invalidate(true);
4449 else if(__pHitElementResult->HasUrl() == true)
4451 String tempURl = __pHitElementResult->GetUrl();
4452 AppLog("tempURl is %ls", tempURl.GetPointer());
4453 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4454 if (pBitmap != null)
4462 InitImageLinkContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4463 __pImageMenu->SetShowState(true);
4464 __pImageMenu->Show();
4465 __pImageMenu->Invalidate(true);
4469 String tagName = __pHitElementResult->GetTagName();
4470 String type = __pHitElementResult->GetAttributeValue("type");
4471 String value = __pHitElementResult->GetAttributeValue(L"value");
4472 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4474 __currentSelectedStr.Clear();
4475 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4477 AppLog("tag name is %ls", tagName.GetPointer());
4478 AppLog("type is %ls", type.GetPointer());
4482 __isLongPressedDone = true;
4483 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4484 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)
4486 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4488 InitSelectTextContextMenu(Point(currentPosition.x , currentPosition.y + __pWebViewer->GetY()),true, true);
4491 __pImageMenu->SetShowState(true);
4492 __pImageMenu->Show();
4493 __pImageMenu->Invalidate(true);
4496 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4499 // __inputEventToBeSupressed = true;
4503 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4505 AppLog("xyz:: MainForm::OnTouchReleased called");
4507 if (__pAddressbar && __pAddressbar->GetShowState() == true)
4509 __pAddressbar->SetShowState(false);
4511 if(__pFooterPanel && __isKeypadOpened == false)
4513 __pFooterPanel->SetShowState(true);
4517 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4518 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4520 __pWebViewer->ConsumeInputEvent();
4522 if(pHitElement != null)
4526 __inputEventToBeSupressed = false;*/
4530 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4537 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4539 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4541 __currentSearchStr = L"";
4542 __currentWordIndex = 0;
4543 __maxOccurrances = 0;
4545 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4547 __pFindWordEditField->SetText(L"");
4548 __pFindWordEditField->HideKeypad();
4549 __pFindWordControl->SetShowState(false);
4550 __pFindWordCountLabel->SetText(L"0/0");
4552 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4554 __pFindWordEditFieldRightToLeft->SetText(L"");
4555 __pFindWordEditFieldRightToLeft->HideKeypad();
4556 __pFindWordControl->SetShowState(false);
4557 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4560 __pFindWordNext->SetEnabled(false);
4561 __pFindWordPrev->SetEnabled(false);
4563 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
4564 __pFindWordControl->SetShowState(false);
4566 AppLog("__pAddressbar->GetShowState() %d",__pAddressbar->GetShowState());
4567 if(__pAddressbar->GetShowState() == false)
4569 __pAddressbar->SetAddressbarURLFocus();
4570 __pFooterPanel->SetShowState(false);
4577 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4583 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4589 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4595 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4601 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4607 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4609 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4610 int widthContextItem = 0;
4611 if(__pFindWordCountLabel)
4612 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4613 // As per the platform engineer comment removed this line
4614 /*if(__pWebViewer != null)
4616 // 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
4617 __pWebViewer->ReleaseBlock();
4620 // if(__pFindWordControl != null)
4621 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4623 if(__pOptionMenu && __pOptionMenu->GetShowState() == true)
4625 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
4627 AppLog(" Orientation landscape");
4628 __pOptionMenu->SetMaxVisibleItemsCount(5);
4632 AppLog(" Orientation potrait");
4633 __pOptionMenu->SetMaxVisibleItemsCount(6);
4636 if(__pNotification && __pNotification->GetShowState() == true)
4638 __pNotification->SetShowState(false);
4639 __pNotification->Invalidate(false);
4641 if ( __pFooterLabel != null)
4643 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4646 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4652 if (__pFindWordBgLabel != null)
4654 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4655 if (pBitmap != null)
4657 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4662 if (__pFindWordBgLabelRightToLeft != null)
4664 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4665 if (pBitmap != null)
4667 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4673 // if(__pOptionMenu != null)
4674 // __pOptionMenu->SetShowState(false);
4676 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4678 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4682 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4687 AppLog("__pFooterPanel->GetShowState() is true");
4689 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4690 __pFooterPanel->Invalidate(true);
4694 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4695 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4697 InitMostVisitedSitesView(orientationStatus);
4700 RelayoutControls(false);
4701 if (__pArticleReaderPanel != null)
4703 if (__pArticleReaderPanel->GetShowState() == true)
4705 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4707 if (__pBlankPanel != null)
4708 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4710 if (__pWebReader != null)
4712 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4714 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4715 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4717 if ( pBitmap != null && pSrcBitmap != null)
4719 AppLog("CreateReaderPanel ninepatchbitmap found");
4720 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4723 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4724 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4725 if (pBitmap != null)
4730 if (pSrcBitmap != null)
4739 if (__pAddressbar != null)
4741 int width = GetClientAreaBounds().width;
4742 __pAddressbar->OrientationChanged(width);
4747 MainForm::OnSettingsChange(int settingvalue)
4749 AppLogDebug("MainForm::OnSettingsChange entered");
4751 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4753 __pAddressbar->ResetGuideText();
4755 if (__pWebViewer == null)
4757 AppLogDebug("Webviewer is not initialized yet.");
4761 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4763 WebSetting settings = __pWebViewer->GetSetting();
4764 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4766 settings.SetAutoFittingEnabled(true);
4768 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
4770 settings.SetAutoFittingEnabled(false);
4772 __pWebViewer->SetSetting(settings);
4774 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4776 WebSetting settings = __pWebViewer->GetSetting();
4777 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4778 __pWebViewer->SetSetting(settings);
4780 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4782 WebSetting settings = __pWebViewer->GetSetting();
4783 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4784 __pWebViewer->SetSetting(settings);
4785 __pWebViewer->Reload();
4787 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4789 WebSetting settings = __pWebViewer->GetSetting();
4790 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4791 __pWebViewer->SetSetting(settings);
4793 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4797 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4800 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
4804 WebSetting settings = __pWebViewer->GetSetting();
4805 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
4806 __pWebViewer->SetSetting(settings);
4809 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
4813 WebSetting settings = __pWebViewer->GetSetting();
4814 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
4815 __pWebViewer->SetSetting(settings);
4818 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4820 WebSetting settings = __pWebViewer->GetSetting();
4821 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4823 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4827 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4829 __pWebViewer->SetSetting(settings);
4831 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4835 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4836 WebSetting settings = __pWebReader->GetSetting();
4837 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4838 __pWebReader->SetSetting(settings);
4844 MainForm::OnSettingsReset()
4848 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4849 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4854 MainForm::OnClearCache()
4856 result r = E_SUCCESS;
4858 if (__pWebViewer != NULL)
4860 r = __pWebViewer->ClearCache();
4863 AppLogDebug("Cache cleared success");
4867 AppLogDebug("Cache cleared fail");
4873 MainForm::OnClearCookie()
4875 result r = E_SUCCESS;
4877 if (__pWebViewer != NULL)
4879 __pWebViewer->ClearCookie();
4883 AppLogDebug("Cookie cleared success");
4887 AppLogDebug("Cache cleared fail");
4892 MainForm::OnClearFormData()
4894 result r = E_SUCCESS;
4896 if (__pWebViewer != NULL)
4898 __pWebViewer->ClearFormData();
4902 AppLogDebug("Cookie cleared success");
4906 AppLogDebug("Cache cleared fail");
4911 MainForm::OnClearPasswords()
4913 result r = E_SUCCESS;
4915 if (__pWebViewer != NULL)
4917 __pWebViewer->ClearLoginFormData();
4921 AppLogDebug("Cookie cleared success");
4925 AppLogDebug("Cache cleared fail");
4931 MainForm::findDistance(int x1,int y1,int x2, int y2)
4933 int deltaX = Math::Abs(x2 - x1);
4934 int deltaY = Math::Abs(y2 - y1);
4935 double num = deltaX*deltaX + deltaY*deltaY;
4941 for (i = 0; i < 20; i++)
4943 x = (((x*x)+ num)/(2*x));
4954 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4956 AppLog("xyz:: MainForm::OnTouchPressed called");
4957 if(__pFindWordControl)
4959 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4960 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4962 __isLongPressedDone = false;
4967 IList* pList = null;
4968 pList = touch.GetTouchInfoListN(source);
4972 int count = pList->GetCount();
4975 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4976 __touchPoint1 = pTouchInfo->position;
4978 /*if (__pAddressbar != null)
4980 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4982 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4984 __pAddressbar->SaveAddressbarEditText();
4986 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4989 __pAddressbar->Invalidate(true);
4991 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4993 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4995 //__pAddressbar->SaveAddressbarEditText();
4997 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5000 else if (count == 2)
5002 AppLogDebug("MainForm::OnTouchPressed count is two");
5003 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5004 __touchPoint1 = pTouchInfo->position;
5006 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
5007 __touchPoint2 = pTouchInfo->position;
5012 pList->RemoveAll(true);
5017 __pAddressbar->SetShowState(false);
5019 if(__pFooterPanel && __isKeypadOpened == false)
5021 __pFooterPanel->SetShowState(true);
5023 RelayoutControls(false);
5028 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5030 // __currentWordIndex = 0;
5031 __isLongPressedDone = false;
5036 MainForm::MoveUiControls()
5041 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
5043 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
5045 if(__pFooterUrlField->GetTextLength() == 0)
5047 __pFooterUrlField->SetKeypadActionEnabled(false);
5051 __pFooterUrlField->SetKeypadActionEnabled(true);
5054 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
5056 __currentSearchStr = __pFindWordEditField->GetText();
5057 if (__currentSearchStr.GetLength() > 0)
5059 __pFindWordCountLabel->SetShowState(true);
5063 // __pFindWordCountLabel->SetShowState(false);
5064 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
5065 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
5068 __pFindWordNext->SetEnabled(false);
5069 __pFindWordPrev->SetEnabled(false);
5070 __pFindWordNext->Invalidate(true);
5071 __pFindWordPrev->Invalidate(true);
5072 __pFindWordCountLabel->SetText(L"0/0");
5073 __pFindWordCountLabel->Invalidate(true);
5075 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
5077 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
5078 if (__currentSearchStr.GetLength() > 0)
5080 __pFindWordCountLabelRightToLeft->SetShowState(true);
5084 __pFindWordCountLabelRightToLeft->SetShowState(false);
5087 __pFindWordNext->SetEnabled(false);
5088 __pFindWordPrev->SetEnabled(false);
5089 __pFindWordNext->Invalidate(true);
5090 __pFindWordPrev->Invalidate(true);
5091 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
5092 __pFindWordCountLabelRightToLeft->Invalidate(true);
5094 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
5095 if (__currentSearchStr.GetLength() > 0)
5101 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
5103 __currentSearchStr = L"";
5104 AppLogDebug("Enter something");
5109 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
5116 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
5118 if(__pWebViewer != null)
5121 AppLog("MainForm::InitMostVisitedSitesView");
5122 result r = E_SUCCESS;
5125 if (__pWebViewer != null && __pMostVisitedListView != null)
5130 if (__pMostVisitedListView != null)
5132 RemoveControl(__pMostVisitedListView);
5134 if(__pMostVisitedSites != null)
5136 __pMostVisitedSites->RemoveAll(true);
5139 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
5141 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
5142 __pMostVisitedListView = new(std::nothrow) ListView();
5144 int height = GetClientAreaBounds().height;
5146 if(__pFooterPanel->GetShowState() == true)
5148 height = height - __pFooterPanel->GetHeight();
5150 if(__pAddressbar->GetShowState() == true)
5152 height -= __pAddressbar->GetHeight();
5155 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
5159 delete __pMostVisitedListView;
5160 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
5163 __pMostVisitedListView->SetItemProvider(*this);
5164 __pMostVisitedListView->AddListViewItemEventListener(*this);
5165 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_VISITED_SITES"));
5166 AddControl(__pMostVisitedListView);
5167 __pMostVisitedListView->UpdateList();
5174 MainForm::GetImagePath(void)
5178 String formattedTime;
5179 DateTime currentTime;
5180 LocaleManager localManager;
5181 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
5183 localManager.Construct();
5184 Locale locale = localManager.GetSystemLocale();
5185 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
5187 // Get date formatter
5188 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
5192 pTimeFormatter->Format(currentTime, formattedTime);
5195 AppLog("current time stamp is %ls", formattedTime.GetPointer());
5196 String delim(L" :");
5197 StringTokenizer strTok(formattedTime, delim);
5200 String str1("GMT+00");
5201 while (strTok.HasMoreTokens())
5203 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
5204 if(token.Equals(str1))
5206 AppLog("token is %ls", token.GetPointer());
5207 imageName.Append(token);
5213 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
5215 result r = E_FAILURE;
5216 AppLog("Content manager 1");
5217 ContentId contentId;
5218 ContentManager contentManager;
5219 r = contentManager.Construct();
5222 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
5225 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
5226 Tizen::Io::Directory::Create(contentPath,true);
5227 if(GetLastResult() == E_FILE_ALREADY_EXIST)
5229 AppLog("Already exists");
5231 else if(GetLastResult() == E_SUCCESS)
5233 AppLog("created success");
5235 contentPath.Append(imageName);
5236 contentPath.Append(".jpg");
5237 contentId = contentManager.CreateContent(*aBuffer, contentPath);
5238 ShowIndicatorNotification(L"Download Complete",contentPath);
5239 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5243 MainForm::ShowIndicatorNotification(const String& messageText, const String& contentPath)
5245 AppLogDebug("ENTER");
5247 NotificationRequest request;
5248 request.SetAlertText(messageText);
5249 request.SetTitleText(L"");
5250 request.SetAppMessage(contentPath);
5251 request.SetOngoingActivityType(ONGOING_ACTIVITY_TYPE_TEXT);
5252 request.SetNotificationStyle(NOTIFICATION_STYLE_THUMBNAIL);
5253 Tizen::App::App* pApp = Tizen::App::App::GetInstance();
5254 String homePath = pApp->GetAppRootPath();
5255 String iconPath = homePath + L"res/screen-density-xhigh/Notification_download_complete.png";
5256 AppLog("The iconPath is : %ls", homePath.GetPointer());
5257 request.SetIconFilePath(iconPath);
5259 Tizen::Shell::NotificationManager notiMgr;
5260 notiMgr.Construct();
5261 notiMgr.NotifyOngoingActivity(request);
5262 AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));
5267 MainForm::SetForwardButtonEnabled(bool isEnabled)
5269 __pGoForwardBtn->SetEnabled(isEnabled);
5270 __pGoForwardBtn->Invalidate(true);
5274 MainForm::SetBackButtonEnabled(bool isEnabled)
5276 __pGoBackBtn->SetEnabled(isEnabled);
5277 __pGoBackBtn->Invalidate(true);
5281 MainForm::UpdateProgress(int percentage)
5283 __progressPercentage = percentage;
5284 if (percentage == 0 || percentage == 100)
5286 __isLoadingData = false;
5287 if (percentage == 100)
5289 __isLoadingCompleted = true;
5290 __progressPercentage = 0;
5294 __isLoadingCompleted = false;
5299 __isLoadingData = true;
5301 UpdateProgressBitmap();
5305 MainForm::GetProgress(void)
5307 return __progressPercentage;
5311 MainForm::UpdateProgressBitmap(void)
5313 result r = E_SUCCESS;
5314 if (__pProgressbarLabel == null)
5316 int w = __pProgressbarLabel->GetWidth();
5317 int h = __pProgressbarLabel->GetHeight();
5319 int progressWidth = 0;
5320 Bitmap* pRetBitmap = null;
5322 if (__progressPercentage == 0 || __progressPercentage == 100)
5324 __pProgressbarLabel->SetShowState(false);
5325 __pProgressbarLabel->Invalidate(false);
5330 __pProgressbarLabel->SetShowState(true);
5331 __pProgressbarLabel->Invalidate(false);
5334 r = canvas.Construct(Rectangle(0, 0, w, h));
5338 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5343 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5347 pBgBmp->Scale(Dimension(w, h));
5348 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5352 progressWidth = (double) (w) * __progressPercentage / 100;
5353 AppLogDebug("progressWidth: %d", progressWidth);
5354 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5356 if (pProgressBmp != null)
5358 pProgressBmp->Scale(Dimension(progressWidth, h));
5359 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5360 delete pProgressBmp;
5363 pRetBitmap = new (std::nothrow) Bitmap();
5365 if (pRetBitmap == null)
5367 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5371 pRetBitmap->Construct(canvas, canvas.GetBounds());
5373 if (__pProgressbarLabel != null && pRetBitmap != null)
5375 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5376 __pProgressbarLabel->Invalidate(false);
5379 if (pRetBitmap != null)
5388 MainForm::ReaderClicked()
5390 result r = E_SUCCESS;
5391 ArrayList* pArgList = new(std::nothrow) ArrayList();
5392 if (pArgList != null)
5394 r = pArgList->Construct();
5401 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5408 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5415 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5423 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5429 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5431 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5433 __currentAddMode = addMode;
5437 case ADDRESSBAR_MODE_INVALID:
5442 case ADDRESSBAR_MODE_READER:
5444 __pStopBtn->SetShowState(false);
5445 __pRefreshBtn->SetShowState(false);
5446 __pClearBtn->SetShowState(false);
5447 __pReaderBtn->SetShowState(false);
5450 case ADDRESSBAR_MODE_LOADING:
5452 __pRefreshBtn->SetShowState(false);
5453 __pStopBtn->SetShowState(true);
5454 __pClearBtn->SetShowState(false);
5455 __pReaderBtn->SetShowState(false);
5458 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5460 // SetUrl(__pAddressbar->GetUrl());
5462 __pRefreshBtn->SetShowState(true);
5463 __pStopBtn->SetShowState(false);
5464 __pClearBtn->SetShowState(false);
5465 __pReaderBtn->SetShowState(false);
5468 case ADDRESSBAR_MODE_EDIT:
5470 __pRefreshBtn->SetShowState(false);
5471 __pStopBtn->SetShowState(false);
5472 __pReaderBtn->SetShowState(false);
5473 __pClearBtn->SetShowState(true);
5480 OnAddressBarModeChanged();
5483 AddressBarMode MainForm::GetAddressbarMode(void)
5485 return __currentAddMode;
5488 void MainForm::SetUrl(const String& url)
5491 if(__displayUrl.GetLength() > 2048)
5492 __displayUrl.SubString(0,2048,__displayUrl);
5494 if (__pFooterUrlField != NULL)
5496 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5497 if (removedHttpUrl.IsEmpty() == false)
5499 __pFooterUrlField->SetText(removedHttpUrl);
5500 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5501 __pAddressbar->SetUrl(__displayUrl);
5505 __pFooterUrlField->SetText(__displayUrl);
5506 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5507 __pAddressbar->SetUrl(__displayUrl);
5509 if(__pFooterUrlField)
5510 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5511 __pFooterUrlField->Invalidate(false);
5512 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5513 __pAddressbar->Invalidate(true);
5514 // __pFooterUrlField->SetCursorPosition(0);
5519 MainForm::RemoveHttpTextFromDisplayURL(void)
5521 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5523 // bool isHttpText = __displayUrl.Contains(L"http://");
5524 String updatedDisplayUrl;
5525 updatedDisplayUrl.Clear();
5526 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5528 __displayUrl.SubString(7,updatedDisplayUrl);
5530 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5532 __displayUrl.SubString(8,updatedDisplayUrl);
5534 return updatedDisplayUrl;
5537 void MainForm::OnSharePopupControlStarted(void)
5539 __pWebViewer->AddTouchEventListener(*this);
5543 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5545 if (requestId == BACK_GROUND_APP_EVENT)
5547 if(__pWebViewer != null)
5549 __pWebViewer->Pause();
5553 __pImageMenu->SetShowState(false);
5555 if(__pAddressbar != null)
5557 __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5560 else if(requestId == FORE_GROUND_APP_EVENT)
5562 if(__pWebViewer != null)
5564 __pWebViewer->Resume();
5566 if(__pAddressbar != null)
5568 __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5574 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5576 AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5577 result r = E_SUCCESS;
5580 __pAddressbar->SetShowState(false);
5582 AppLog("akjshdasd 5");
5583 __pFooterPanel->SetShowState(true);
5586 __pWebViewer->SetFocus();
5587 else if(__pMostVisitedListView)
5588 __pMostVisitedListView->SetFocus();
5589 else if(__pMultiWindowButton)
5590 __pMultiWindowButton->SetFocus();
5591 else if(__pMoreButton)
5592 __pMoreButton->SetFocus();
5594 __pAddressbar->SetShowState(false);
5596 RelayoutControls(false);
5600 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5602 AppLog("MainForm::OnFormMenuRequested called");
5604 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer && __pWebViewer->GetShowState() == true)
5606 int bookmarkCount=0;
5609 url=__pWindowInfo->pageUrl;
5610 AppLog("MainForm::OnFormMenuRequested url %ls",url.GetPointer());
5611 result r = E_SUCCESS;
5612 Bitmap* pBitmap = null;
5613 String lastChar = L"";
5614 // if(url.SubString(url.GetLength()-1,lastChar));
5615 // if(lastChar == L"/")
5617 // bool exist1 = false;
5618 // bool exist2 = false;
5619 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist1);
5620 // url.SubString(0,url.GetLength() - 1,url);
5621 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist2);
5622 // exist = exist1 | exist2;
5626 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5629 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5635 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5639 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5641 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5643 if (__pOptionMenu->GetItemCount() == 9)
5645 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5649 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5654 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
5658 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
5659 if (__pOptionMenu->GetItemCount() != 9)
5661 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
5662 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
5663 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
5664 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
5665 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
5666 __pOptionMenu->SetMaxVisibleItemsCount(6);
5668 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
5670 AppLog(" Orientation landscape");
5671 __pOptionMenu->SetMaxVisibleItemsCount(5);
5675 AppLog(" Orientation potrait");
5676 __pOptionMenu->SetMaxVisibleItemsCount(6);
5679 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
5682 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
5684 __pAddressbar->SetShowState(false);
5686 __pFooterPanel->SetShowState(true);
5687 result r = __pOptionMenu->SetShowState(true);
5688 AppLog("ajsghd %s",GetErrorMessage(r));
5689 RelayoutControls(false);
5690 __pOptionMenu->Invalidate(true);
5691 __pOptionMenu->Show();