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)
747 // AppLog("asdasdasdasda");
748 __pFooterPanel->SetShowState(true);
751 __pFooterPanel->SetShowState(false);
752 AppLogDebug("MainForm::InitFooter exit");
757 MainForm::InitOptionMenu()
759 result r = E_SUCCESS;
760 bool isPrivateBrowsing = false;
761 Bitmap* pBitmap = null;
763 if (__pOptionMenu != null)
765 __pOptionMenu->SetFocusable(true);
766 __pOptionMenu->Invalidate(true);
770 __pOptionMenu = new(std::nothrow) OptionMenu();
771 r = __pOptionMenu->Construct();
772 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
774 __pOptionMenu->SetFocusable(true);
775 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
778 if (isPrivateBrowsing == true)
780 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
784 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
787 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
789 if ( pBitmap != NULL)
791 __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
794 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
795 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
796 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
799 __pOptionMenu->SetMaxVisibleItemsCount(6);
800 __pOptionMenu->SetShowState(false);
801 __pOptionMenu->AddActionEventListener(*this);
802 SetControlAlwaysOnTop(*__pOptionMenu, true);
808 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
810 result r = E_SUCCESS;
811 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
813 AppLog("MainForm::InitImageContextMenu clicked on image");
814 if (__pImageMenu != null)
819 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
824 __pImageMenu = new (std::nothrow) ContextMenu();
825 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
826 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
828 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
829 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
830 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
831 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
832 __pImageMenu->SetMaxVisibleItemsCount(4);
833 __pImageMenu->AddActionEventListener(*this);
834 SetControlAlwaysOnTop(*__pImageMenu, true);
835 __pImageMenu->SetFocusable(true);
841 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
843 result r = E_SUCCESS;
844 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
846 AppLog("MainForm::InitImageContextMenu clicked on image");
847 if (__pImageMenu != null)
853 // if(__pAddressbar->GetShowState() == true)
854 // p.y = p.y + __pAddressbar->GetHeight();
855 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
860 __pImageMenu = new (std::nothrow) ContextMenu();
861 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
862 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
864 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_OPEN_IN_NEW_WINDOW"),IDA_HYPERLINK_OPEN_CLICKED);
865 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_LINK_URL"),IDA_HYPERLINK_COPY_LINK_CLICKED);
866 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
867 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
869 __pImageMenu->SetMaxVisibleItemsCount(3);
870 __pImageMenu->AddActionEventListener(*this);
871 SetControlAlwaysOnTop(*__pImageMenu, true);
872 __pImageMenu->SetFocusable(true);
879 MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOption = false)
881 result r = E_SUCCESS;
882 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
884 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
885 if (__pImageMenu != null)
894 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
898 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
900 __pImageMenu = new (std::nothrow) ContextMenu();
901 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
902 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
904 if(onlyPasteOption == false)
906 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
908 if (pasteOption || onlyPasteOption)
910 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
912 if(onlyPasteOption == false)
914 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
915 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
918 __pImageMenu->SetMaxVisibleItemsCount(3);
919 __pImageMenu->AddActionEventListener(*this);
920 SetControlAlwaysOnTop(*__pImageMenu, true);
921 __pImageMenu->SetFocusable(true);
928 MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPasteOption = false)
930 result r = E_SUCCESS;
931 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
933 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
934 if (__pImageMenu != null)
943 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
947 if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE )
949 AppLog("asdasdafdsfdgfd");
952 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
955 __pImageMenu = new (std::nothrow) ContextMenu();
956 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
957 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
959 if(onlyPasteOption == false)
961 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
963 if (pasteOption || onlyPasteOption)
965 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
967 if(onlyPasteOption == false)
969 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
970 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
973 __pImageMenu->SetMaxVisibleItemsCount(3);
974 __pImageMenu->AddActionEventListener(*this);
975 SetControlAlwaysOnTop(*__pImageMenu, true);
976 __pImageMenu->SetFocusable(true);
983 MainForm::InitFindWordPanel(void)
985 result r = E_SUCCESS;
986 Bitmap *pIconBitmap = null;
988 if (__pFindWordControl != null)
990 AppLogDebug("Findword panel already initialized");
991 if (__pFindWordBgLabel != null)
993 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
996 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1000 if (__pFindWordBgLabelRightToLeft != null)
1002 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
1003 if (pBitmap != null)
1005 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1010 __pAddressbar->SetShowState(false);
1012 if(__isKeypadOpened == false)
1013 __pFooterPanel->SetShowState(true);
1017 __pFindWordControl = new (std::nothrow) Panel();
1018 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
1021 AppLogException("There is some problem in the xml file. Please check.");
1024 AddControl(__pFindWordControl);
1025 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
1026 SetControlAlwaysOnTop(*__pFindWordControl,true);
1027 __pFindWordControl->SetShowState(false);
1028 __pFindWordControl->Invalidate(false);
1030 __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1031 __pFindWordPanelLeftToRight->SetShowState(true);
1033 __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
1034 __pFindWordPanelRightToLeft->SetShowState(false);
1036 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
1037 if (__pFindWordBgLabel != null)
1039 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1040 Rectangle pRect = pPanel1->GetBounds();
1041 pRect.x = pRect.y = 0;
1042 __pFindWordBgLabel->SetBounds(pRect);
1043 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1044 if (pBitmap != null)
1046 AppLogDebug("InitFindWordPanel: Coming here");
1047 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1052 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1056 __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
1057 if (__pFindWordBgLabelRightToLeft != null)
1059 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1060 Rectangle pRect = pPanel1->GetBounds();
1061 pRect.x = pRect.y = 0;
1062 __pFindWordBgLabelRightToLeft->SetBounds(pRect);
1063 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1064 if (pBitmap != null)
1066 AppLogDebug("InitFindWordPanel: Coming here");
1067 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1072 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1076 Button* pfindWordCancel = null;
1077 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1078 if (pfindWordCancel == null)
1080 AppLogException("There is some problem in the xml file. Please check.");
1083 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1084 pfindWordCancel->AddActionEventListener(*this);
1086 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1087 if (__pFindWordClear == null)
1089 AppLogException("There is some problem in the xml file. Please check.");
1093 __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1094 if (__pFindWordClearRightToLeft == null)
1096 AppLogException("There is some problem in the xml file. Please check.");
1100 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1101 __pFindWordClear->AddActionEventListener(*this);
1103 __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1104 __pFindWordClearRightToLeft->AddActionEventListener(*this);
1106 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1107 if (__pFindWordNext == null)
1109 AppLogException("There is some problem in the xml file. Please check.");
1113 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1114 __pFindWordNext->AddActionEventListener(*this);
1116 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1117 if (__pFindWordPrev == null)
1119 AppLogException("There is some problem in the xml file. Please check.");
1123 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1124 __pFindWordPrev->AddActionEventListener(*this);
1126 __pFindWordNext->SetEnabled(false);
1127 __pFindWordPrev->SetEnabled(false);
1129 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1130 if (__pFindWordCountLabel == null)
1132 AppLogException("There is some problem in the xml file. Please check.");
1136 __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1137 if (__pFindWordCountLabelRightToLeft == null)
1139 AppLogException("There is some problem in the xml file. Please check.");
1143 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1144 if (__pFindWordEditField == null)
1146 AppLogException("There is some problem in the xml file. Please check.");
1149 __pFindWordEditField->AddTextEventListener(*this);
1150 __pFindWordEditField->AddKeypadEventListener(*this);
1151 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1152 __pFindWordEditField->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1154 __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1155 if (__pFindWordEditFieldRightToLeft == null)
1157 AppLogException("There is some problem in the xml file. Please check.");
1160 __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1161 __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1162 __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1163 __pFindWordEditFieldRightToLeft->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1166 __pAddressbar->SetShowState(false);
1168 if(__isKeypadOpened == false)
1169 __pFooterPanel->SetShowState(true);
1174 MainForm::CreateItem (int index, int itemWidth)
1176 Rectangle listImageRect;
1177 Rectangle pagetTitleRect;
1178 Rectangle pageURLRect;
1179 Rectangle deleteImageRect;
1180 String pageTitle(L"");
1181 String pageURL(L"");
1182 result r = E_SUCCESS;
1183 Bitmap* pListIconImage = null;
1186 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1187 if(pHistory == null)
1191 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1192 if ( pAppResource == NULL )
1196 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1198 CustomItem* pItem = new(std::nothrow) CustomItem();
1199 pageTitle = pHistory->GetHistoryTitle();
1200 pageURL = pHistory->GetHistoryUrl();
1202 if (pageURL.GetLength() == 0)
1205 pAppResource->GetString(L"IDS_BR_BODY_BLANK_PAGE", nourl);
1206 pageURL = L"<"+ nourl +">";
1210 Rectangle screenBounds = GetBounds();
1213 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1222 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1224 if ( pBitmap != NULL)
1226 pListIconImage = new Bitmap();
1227 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1231 if(pListIconImage == null)
1233 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1236 if ( pListIconImage != NULL)
1238 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2 , 72, 72);
1239 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 72 + (__fontSize - 44));
1240 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1243 if (pItem != null && pListIconImage != NULL)
1245 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1249 if (pageTitle.CompareTo(L"") != 0)
1253 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1257 if (pageURL.CompareTo(L"") != 0)
1261 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1266 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1268 if ( __pItemContext!= NULL)
1272 pItem->SetContextItem(__pItemContext);
1278 if ( __pItemContextLandscape!= NULL)
1282 pItem->SetContextItem(__pItemContextLandscape);
1286 if( pListIconImage != NULL)
1288 delete pListIconImage;
1289 pListIconImage = null;
1296 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1303 MainForm::GetItemCount (void)
1305 if(__pMostVisitedSites != null)
1307 __pMostVisitedSites->RemoveAll(true);
1309 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1310 if(__pMostVisitedSites != null)
1312 return __pMostVisitedSites->GetCount();
1319 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1321 AppLog("MainForm::OnListViewContextItemStateChanged called");
1322 if(__pMostVisitedSites != null)
1324 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1325 if (pHistory != null)
1327 String url = pHistory->GetHistoryUrl();
1329 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1330 __pMostVisitedListView->UpdateList();
1336 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1338 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1339 String url = pHistory->GetHistoryUrl();
1347 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1353 MainForm::OnTerminating(void)
1355 result r = E_SUCCESS;
1357 RemoveOrientationEventListener(*this);
1361 __pAddressbar->SetAddressbarEventListener(null);
1366 __pWebViewer->RemoveTouchEventListener(*this);
1367 __pWebViewer->SetWebUiEventListenerF(null);
1368 __pWebViewer->SetWebKeypadEventListener(null);
1369 __pWebViewer->SetTextSearchListener(null);
1375 delete __pItemContext;
1377 if (__pItemContextLandscape)
1379 delete __pItemContextLandscape;
1383 delete __pSaveImage;
1385 if (__pMostVisitedSites)
1387 __pMostVisitedSites->RemoveAll(true);
1388 delete __pMostVisitedSites;
1394 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1396 result r = E_SUCCESS;
1398 AppLogDebug("Clicked : %d", actionId);
1401 case IDA_BACKBTN_CLICKED:
1403 if(__pImageMenu && __pImageMenu->GetShowState() == true)
1405 AppLog("Hiding the menu");
1406 __pImageMenu->SetShowState(false);
1408 if (__pWebViewer && __pWebViewer->CanGoBack())
1410 __pWebViewer->GoBack();
1412 else if(__pWindowInfo->isJavascriptInitiated == false)
1415 pApp = UiApp::GetInstance();
1418 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1421 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1429 WindowInfo* pWindowInfo = null;
1431 SceneManager* pSceneManager = SceneManager::GetInstance();
1432 if (pSceneManager == null)
1436 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1437 if (pAllWindowList == NULL)
1439 pApp = UiApp::GetInstance();
1442 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1445 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1450 if (pAllWindowList != null)
1452 totalCount = pAllWindowList->GetCount();
1454 for (int count = 0; count < totalCount; count++)
1456 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1457 if (pWindowInfo == null)
1459 pApp = UiApp::GetInstance();
1462 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1465 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1472 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1474 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1477 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1480 r = pAllWindowList->RemoveAt(count, true);
1481 __pWindowInfo = null;
1484 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1489 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1493 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1495 if (pWindowInfo == null)
1497 pApp = UiApp::GetInstance();
1500 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1506 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1509 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1521 case IDA_FORWARD_CLICKED:
1522 if (__pWebViewer == null)
1525 if (__pWebViewer->CanGoForward())
1527 __pWebViewer->GoForward();
1529 __pOptionMenu->SetShowState(false);
1530 __pOptionMenu->Invalidate(false);
1533 case IDA_FINDONPAGE_CLICKED:
1535 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1536 __currentSearchStr.Clear();
1538 InitFindWordPanel();
1539 __pOptionMenu->SetShowState(false);
1540 __pOptionMenu->Invalidate(false);
1542 ShowFindWordPanel(true);
1544 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1546 __pFindWordEditField->SetFocus();
1547 // __pFindWordCountLabel->SetShowState(false);
1551 __pFindWordEditFieldRightToLeft->SetFocus();
1552 __pFindWordCountLabelRightToLeft->SetShowState(false);
1556 case IDA_PRIVATEON_CLICKED:
1558 result r = E_SUCCESS;
1560 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1561 Bitmap* pBitmap = null;
1562 if (isPrivateBrowsing == true)
1564 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1567 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1571 if (__pWebViewer != NULL)
1573 __pWebViewer->SetPrivateBrowsingEnabled(false);
1576 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1578 if (__pAddressbar != null)
1580 __pAddressbar->UpdateFaviconBitmap(false);
1586 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1589 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1593 if (__pWebViewer != NULL)
1595 __pWebViewer->SetPrivateBrowsingEnabled(true);
1598 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1600 if (__pAddressbar != null)
1602 __pAddressbar->UpdateFaviconBitmap(true);
1606 itemIndex = __pOptionMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1607 r = __pOptionMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1608 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1609 __pOptionMenu->Invalidate(true);
1610 if ( pBitmap != NULL )
1617 case IDA_SETTINGS_CLICKED:
1620 ArrayList* pArgList = new(std::nothrow) ArrayList();
1623 pArgList->Construct();
1624 pArgList->Add(*__pWindowInfo);
1625 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1627 __pOptionMenu->SetShowState(false);
1628 __pOptionMenu->Invalidate(false);
1630 if (pArgList != null)
1639 case IDA_ADDTOBOOKMARK_CLICKED:
1642 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1644 int bookmarkCount=0;
1647 url=__pWindowInfo->pageUrl;
1648 result r = E_SUCCESS;
1649 Bitmap* pBitmap = null;
1650 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1658 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1659 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1660 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1662 if(__pNotification != null)
1664 RemoveControl(__pNotification);
1665 __pNotification = null;
1667 __pNotification = new (std::nothrow) NotificationPanel(*this);
1668 if (__pNotification != null)
1670 __pNotification->SetText(message);
1671 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1672 __pNotification->ShowNotification();
1677 String title=__pWindowInfo->pageTitle;
1678 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1679 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1681 pBookmark->SetBookmarkTitle(title);
1682 pBookmark->SetUrl(url);
1683 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1685 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1687 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1688 pBookmark->SetFaviconId(id);
1689 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1690 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1692 if(__pNotification != null)
1694 RemoveControl(__pNotification);
1695 __pNotification = null;
1697 __pNotification = new (std::nothrow) NotificationPanel(*this);
1698 if (__pNotification != null)
1700 __pNotification->SetText(message);
1701 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1702 __pNotification->ShowNotification();
1703 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1706 if (pBitmap != null)
1708 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1713 __pOptionMenu->Invalidate(true);
1718 case IDA_PRINT_CLICKED:
1720 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//shared//data//test.pdf");
1721 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1723 AppLog("RequestPrint called!");
1724 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1725 result nResult = E_FAILURE;
1728 AppLog("TestPrint if (pAc) == true");
1733 String fileType = L"service_print_files_type";
1734 String typeVal = L"DOC";
1736 String fileCount = L"service_print_files_count";
1737 String countVal = L"1";
1738 String fileFolder= L"service_print_files_folder_name";
1739 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//shared//data";
1741 map.Add(&fileCount, &countVal);
1742 map.Add(&fileFolder, &folderVal);
1743 map.Add(&fileType, &typeVal);
1745 String fileName = L"service_print_files_files_name";
1747 ArrayList fileNameList;
1748 fileNameList.Construct();
1749 String file1 = L"test.pdf";
1751 fileNameList.Add(&file1);
1752 map.Add(&fileName, &fileNameList);
1754 nResult = pAc->Start(NULL, NULL, &map, NULL);
1756 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1757 else if (nResult == E_MAX_EXCEEDED)
1758 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1759 else if (nResult == E_OBJ_NOT_FOUND)
1760 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1761 else if (nResult == E_IN_PROGRESS)
1762 AppLog("TestPrint ret == E_IN_PROGRESS");
1763 else if (nResult == E_PRIVILEGE_DENIED)
1764 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1765 else if(nResult == E_SYSTEM)
1766 AppLog("TestPrint ret == E_SYSTEM");
1772 int __modalMsgBoxResult;
1773 MessageBox* pMsgBox = new MessageBox();
1774 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1775 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1778 __modalMsgBoxResult = 0;
1782 case IDA_SHARE_CLICKED:
1784 if(__pPopUp != null)
1791 __pAddressbar->HideKeypad();
1793 __pPopUp = new(std::nothrow) SharePopup();
1794 __pPopUp->Initialize();
1795 if (__pWindowInfo != null)
1797 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1798 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1799 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1800 pShareInfo->SetImageAttached(false);
1801 __pPopUp->RemoveAllShareInfo();
1802 __pPopUp->AddShareInfo(pShareInfo);
1804 __pPopUp->SetShowState(true);
1808 case IDA_BOOKMARKBTN_CLICKED:
1810 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1811 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1814 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1819 case IDA_MOREBTN_CLICKED:
1821 AppLog("IDA_MOREBTN_CLICKED");
1823 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1825 int bookmarkCount=0;
1828 url=__pWindowInfo->pageUrl;
1829 result r = E_SUCCESS;
1830 Bitmap* pBitmap = null;
1832 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1835 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1840 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1844 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1846 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1848 if (__pOptionMenu->GetItemCount() == 9)
1850 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1854 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1859 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1863 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1864 if (__pOptionMenu->GetItemCount() != 9)
1866 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1867 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1868 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1869 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1870 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1871 __pOptionMenu->SetMaxVisibleItemsCount(6);
1873 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1875 AppLog(" Orientation landscape");
1876 __pOptionMenu->SetMaxVisibleItemsCount(5);
1880 AppLog(" Orientation potrait");
1881 __pOptionMenu->SetMaxVisibleItemsCount(6);
1884 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1887 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1888 __pOptionMenu->SetShowState(true);
1889 __pOptionMenu->Invalidate(true);
1890 __pOptionMenu->Show();
1894 case IDA_HISTORY_CLICKED:
1896 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1897 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1900 case IDA_SAVED_PAGES_CLICKED:
1905 case IDA_DESKTOP_VIEW_CLICKED:
1910 case IDA_SAVE_CLICKED:
1915 case IDA_MULTIWINDOWBTN_CLICKED:
1917 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1918 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1922 case IDA_NEWWINDOWBTN_CLICKED:
1924 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
1926 if (pNewWindowInfo == null)
1930 result r = E_SUCCESS;
1931 SceneManager* pSceneManager = SceneManager::GetInstance();
1933 if (pSceneManager == NULL)
1937 ArrayList* pArgList = new(std::nothrow) ArrayList();
1938 if (pArgList == NULL)
1942 r = pArgList->Construct();
1945 pArgList->Add(*pNewWindowInfo);
1946 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1952 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1957 case IDA_SMALLFONT_BTN_CLICKED:
1959 WebSetting setting = __pWebReader->GetSetting();
1960 setting.SetFontSize(15);
1961 __pWebReader->SetSetting(setting);
1964 case IDA_LARGEFONT_BTN_CLICKED:
1966 WebSetting setting = __pWebReader->GetSetting();
1967 setting.SetFontSize(25);
1968 __pWebReader->SetSetting(setting);
1971 case IDA_READER_CLOSE_CLICKED:
1973 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1975 RemoveControl(__pBlankPanel);
1976 __pArticleReaderPanel = null;
1977 __pBlankPanel = null;
1978 __pArticleReaderLabel = null;
1980 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1983 case IDA_FINDWORD_CANCEL_CLICKED:
1985 __currentSearchStr = L"";
1986 __currentWordIndex = 0;
1987 __maxOccurrances = 0;
1989 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1991 __pFindWordEditField->SetText(L"");
1992 __pFindWordCountLabel->SetText(L"0/0");
1994 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
1996 __pFindWordEditFieldRightToLeft->SetText(L"");
1997 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2000 __pFindWordNext->SetEnabled(false);
2001 __pFindWordPrev->SetEnabled(false);
2002 __pFindWordCountLabel->SetText(L"0/0");
2003 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
2004 AppLog("akjshdasd 1");
2005 if(__isKeypadOpened == false)
2006 __pFooterPanel->SetShowState(true);
2007 ShowFindWordPanel(false);
2010 case IDA_FINDWORD_SEARCH_CLICKED:
2012 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2014 __currentSearchStr = __pFindWordEditField->GetText();
2016 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2018 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
2021 if (__currentSearchStr.GetLength() > 0)
2027 AppLogDebug("Enter something");
2031 case IDA_FINDWORD_CLEAR_CLICKED:
2033 __pFindWordCountLabel->SetText(L"0/0");
2034 __pFindWordEditField->SetText(L"");
2035 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2037 __currentSearchStr = L"";
2038 __pFindWordNext->SetEnabled(false);
2039 __pFindWordPrev->SetEnabled(false);
2040 // __pFindWordCountLabel->SetShowState(false);
2041 __pFindWordControl->Invalidate(true);
2044 case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
2046 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2047 __pFindWordEditFieldRightToLeft->SetText(L"");
2048 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2050 __currentSearchStr = L"";
2051 __pFindWordNext->SetEnabled(false);
2052 __pFindWordPrev->SetEnabled(false);
2053 // __pFindWordCountLabelRightToLeft->SetShowState(false);
2054 __pFindWordControl->Invalidate(true);
2057 case IDA_FINDWORD_NEXT_CLICKED:
2062 case IDA_FINDWORD_PREV_CLICKED:
2064 FindNextWord(false);
2067 case IDA_BRIGHTNESS_BTN_CLICKED:
2069 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
2070 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2073 case IDA_COPY_IMAGE_CLICKED:
2075 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2076 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2078 const Bitmap* pBitmap = null;
2079 if (__pHitElementResult != null && __pHitElementResult->HasImage())
2081 pBitmap = __pHitElementResult->GetImage();
2084 String resourcePath = App::GetInstance()->GetAppResourcePath();
2085 r = item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
2086 AppLog("Platofrm construct failed result %s",GetErrorMessage(r));
2087 // copying the item to clipboard
2088 Clipboard* pClipboard = Clipboard::GetInstance();
2089 if (pClipboard != null)
2091 r = pClipboard->CopyItem(item);
2092 AppLog("Platofrm copy failed result %s",GetErrorMessage(r));
2096 case IDA_VIEW_IMAGE_CLICKED:
2098 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
2099 WindowInfo* pNewWindowInfo = null;
2100 if (__pHitElementResult != null)
2102 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2103 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2109 case IDA_SAVE_IMAGE_CLICKED:
2111 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
2112 const Bitmap* pSaveBitmap = null;
2113 String imageName = GetImagePath();
2114 AppLog("Content manager image name %ls",imageName.GetPointer());
2117 imagePath.Append(imageName);
2118 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2119 AppLog("Content manager image path %ls",imagePath.GetPointer());
2120 if (__pHitElementResult != null)
2122 pSaveBitmap = __pHitElementResult->GetImage();
2124 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2128 UpdateImageContent(pBuffer, imageName);
2130 if(__pNotification != null)
2132 RemoveControl(__pNotification);
2133 __pNotification = null;
2135 __pNotification = new NotificationPanel(*this);
2137 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2138 msg.Append(imagePath);
2139 if (__pNotification != null)
2141 __pNotification->SetText(msg);
2142 if (__pFooterPanel->GetShowState() == true)
2144 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2148 __pNotification->SetPositionDiff(0);
2151 __pNotification->ShowNotification();
2156 int __modalMsgBoxResult;
2157 MessageBox* pMsgBox = new MessageBox();
2158 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
2159 pMsgBox->ShowAndWait(__modalMsgBoxResult);
2162 __modalMsgBoxResult = 0;
2166 case IDA_SHARE_IMAGE_CLICKED:
2168 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2169 if (__pPopUp != null)
2176 __pAddressbar->HideKeypad();
2178 __pPopUp = new(std::nothrow) SharePopup();
2179 __pPopUp->Initialize();
2180 if (__pHitElementResult != null)
2182 const Bitmap* pSaveBitmap = null;
2183 String imageName = GetImagePath();
2184 AppLog("Content manager image name %ls",imageName.GetPointer());
2187 imagePath.Append(imageName);
2188 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2189 AppLog("Content manager image path %ls",imagePath.GetPointer());
2190 if (__pHitElementResult != null)
2192 pSaveBitmap = __pHitElementResult->GetImage();
2194 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2196 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2197 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2199 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2200 pShareInfo->SetPageTitle(L"");
2201 pShareInfo->SetPageUrl(srcUrl);
2202 pShareInfo->SetImageAttached(true);
2203 pShareInfo->SetImagePath(imagePath);
2204 __pPopUp->RemoveAllShareInfo();
2205 __pPopUp->AddShareInfo(pShareInfo);
2206 __pPopUp->SetShowState(true);
2211 case IDA_HYPERLINK_OPEN_CLICKED:
2213 if (__pHitElementResult != null)
2215 String srcUrl = __pHitElementResult->GetUrl();
2217 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2219 if (pNewWindowInfo == null)
2223 pNewWindowInfo->isJavascriptInitiated = true;
2224 result r = E_SUCCESS;
2225 SceneManager* pSceneManager = SceneManager::GetInstance();
2226 if (pSceneManager == NULL)
2230 ArrayList* pArgList = new(std::nothrow) ArrayList();
2231 if (pArgList == NULL)
2235 pArgList->Construct();
2237 pArgList->Add(*pNewWindowInfo);
2238 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2239 if (pArgList != null)
2246 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2252 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2254 if (__pHitElementResult == null)
2259 if(__pPopUp != null)
2266 __pAddressbar->HideKeypad();
2268 __pPopUp = new(std::nothrow) SharePopup();
2269 __pPopUp->Initialize();
2271 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2272 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2273 pShareInfo->SetImageAttached(false);
2274 __pPopUp->RemoveAllShareInfo();
2275 __pPopUp->AddShareInfo(pShareInfo);
2277 __pPopUp->SetShowState(true);
2281 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2285 if (__pHitElementResult != null)
2287 url = __pHitElementResult->GetUrl();
2290 String resourcePath = App::GetInstance()->GetAppResourcePath();
2291 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2293 // copying the item to clipboard
2294 Clipboard* pClipboard = Clipboard::GetInstance();
2295 if (pClipboard != null)
2297 pClipboard->CopyItem(item);
2301 case IDA_FIND_TEXT__CLICKED:
2303 // AddressBarCancelledClicked(*__pAddressbar);
2304 RelayoutControls(false);
2305 // __pFooterPanel->SetShowState(false);
2306 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2307 __currentSearchStr.Clear();
2308 __currentSearchStr.Append(__currentSelectedStr);
2309 InitFindWordPanel();
2310 __pFindWordEditField->SetText(__currentSearchStr);
2312 if(__pOptionMenu != null)
2314 __pOptionMenu->SetShowState(false);
2315 __pOptionMenu->Invalidate(false);
2317 __adressPanelPosition.y = 0;
2319 if (__pAddressbar != null && __pWebViewer != NULL)
2321 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2322 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2324 if (__pFooterPanel->GetShowState() == false)
2325 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2327 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2328 __pWebViewer->Invalidate(true);
2331 ShowFindWordPanel(true);
2332 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2334 __pFindWordEditField->SetText(__currentSearchStr);
2335 __pFindWordEditField->SetFocus();
2337 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2339 __pFindWordEditFieldRightToLeft->SetText(__currentSearchStr);
2340 __pFindWordEditFieldRightToLeft->SetFocus();
2343 if (__currentSearchStr.GetLength() > 0)
2349 AppLogDebug("Enter something");
2352 if (__pWebViewer != null)
2354 // releasing the set block
2355 __pWebViewer->ReleaseBlock();
2360 case IDA_SHARE_TEXT_CLICKED:
2362 __pWebViewer->ReleaseBlock();
2363 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2364 if(__pPopUp != null)
2371 __pAddressbar->HideKeypad();
2373 __pPopUp = new(std::nothrow) SharePopup();
2374 __pPopUp->Initialize();
2375 if (__pHitElementResult != null)
2377 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2378 pShareInfo->SetPageTitle(L"");
2379 pShareInfo->SetPageUrl(__currentSelectedStr);
2380 pShareInfo->SetImageAttached(false);
2381 __pPopUp->RemoveAllShareInfo();
2382 __pPopUp->AddShareInfo(pShareInfo);
2383 __pPopUp->SetShowState(true);
2388 case IDA_COPY_TEXT_CLICKED:
2390 __pWebViewer->ReleaseBlock();
2391 // need to implement
2392 //__currentSelectedStr
2393 // Sets data to a clip board item
2395 String resourcePath = App::GetInstance()->GetAppResourcePath();
2396 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2398 // copying the item to clipboard
2399 Clipboard* pClipboard = Clipboard::GetInstance();
2400 if (pClipboard != null)
2402 pClipboard->CopyItem(item);
2406 case IDA_PASTE_TEXT_CLICKED:
2408 Clipboard* pClipboard = Clipboard::GetInstance();
2410 if(pClipboard == null)
2414 // Retrieves a latest item
2415 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2421 //Gets data from the clipboard item
2422 String* pString = dynamic_cast<String*>(pItem->GetData());
2424 if (pString != null)
2426 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2427 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2428 String tagElement = __pHitElementResult->GetTagName();
2429 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2432 if(idElement.GetLength() != 0)
2434 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; } } ";
2435 script.Append("insertAtCursor('");
2436 script.Append(idElement);
2437 script.Append("',");
2438 script.Append("\"");
2439 script.Append(*pString);
2440 script.Append("\");");
2442 else if (nameElement.GetLength() != 0)
2444 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; } } ";
2445 script.Append("insertAtCursor(document.getElementsByName('");
2446 script.Append(nameElement);
2447 script.Append("')[0],");
2448 script.Append("\"");
2449 script.Append(*pString);
2450 script.Append("\");");
2452 else//adding for twitter post page
2454 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; } } ";
2455 script.Append("insertAtCursor(document.getElementsByTagName('");
2456 script.Append(tagElement);
2457 script.Append("')[0],");
2458 script.Append("\"");
2459 script.Append(*pString);
2460 script.Append("\");");
2462 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2463 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2474 case IDA_GO_FORWARD:
2479 case IDA_REFRESH_BTN_CLICKED:
2481 __isLoadingCompleted = false;
2482 __isLoadingData = true;
2483 __progressPercentage = 0;
2484 __displayUrl = __pFooterUrlField->GetText();
2486 String url = __pFooterUrlField->GetText();
2487 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2489 if (__pWebViewer != null && __pAddressbar != null)
2491 __pWebViewer->Reload();
2492 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2496 UpdateProgressBitmap();
2499 case IDA_STOP_BTN_CLICKED:
2501 __isLoadingCompleted = false;
2502 __isLoadingData = false;
2503 __progressPercentage = 0;
2504 __pFooterUrlField->HideKeypad();
2505 __displayUrl = __pFooterUrlField->GetText();
2509 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2510 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2511 __pWebViewer->StopLoading();
2512 RequestRedraw(true);
2515 UpdateProgressBitmap();
2520 if (__pFooterUrlField->GetText().IsEmpty() == false)
2522 //__displayUrl = __pUrlField->GetText();
2523 __pFooterUrlField->Clear();
2528 case IDA_READER_BTN_CLICKED:
2539 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2541 AppLog("MainForm::OnFormBackRequested entered");
2542 result r = E_FAILURE;
2543 if(__pImageMenu && __pImageMenu->GetShowState() == true)
2545 AppLog("Hiding the menu");
2546 __pImageMenu->SetShowState(false);
2548 if (__pWebViewer && __pWebViewer->CanGoBack())
2550 __pWebViewer->GoBack();
2552 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
2555 pApp = UiApp::GetInstance();
2558 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2561 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2569 WindowInfo* pWindowInfo = null;
2571 SceneManager* pSceneManager = SceneManager::GetInstance();
2572 if (pSceneManager == null)
2576 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2577 if (pAllWindowList == NULL)
2579 pApp = UiApp::GetInstance();
2582 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2585 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2590 if (pAllWindowList != null)
2592 totalCount = pAllWindowList->GetCount();
2594 for (int count = 0; count < totalCount; count++)
2596 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2597 if (pWindowInfo == null)
2599 pApp = UiApp::GetInstance();
2602 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2605 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2612 if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2614 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2617 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2620 r = pAllWindowList->RemoveAt(count, true);
2621 __pWindowInfo = null;
2624 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2629 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2633 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2635 if (pWindowInfo == null)
2637 pApp = UiApp::GetInstance();
2640 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2646 if(pWindowInfo != null)
2647 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2650 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2659 AppLog("MainForm::OnFormBackRequested exit");
2663 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2664 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2667 AppLog("MainForm::OnSceneActivatedN called");
2668 String* pSelectedScene = NULL;
2669 Object* pValue = NULL;
2670 String* pUrl = null;
2671 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2672 pSelectedScene = (String*) pValue;
2674 if (pSelectedScene != null)
2676 delete pSelectedScene;
2678 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2679 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2680 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2681 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2683 // setting the current scene ID
2684 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2686 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2688 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2690 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2691 if(__pWindowInfo == null)
2693 // if(__pWindowInfo == null)
2695 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2698 else if ( pArgs != null && pArgs->GetCount() == 1)
2700 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2706 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2708 // hiding the address bar
2709 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2710 __pAddressbar->SetShowState(false);
2711 // if(__pWebViewer != null)
2713 // __pWebViewer->Resume();
2716 if(pUrl != null && pUrl->GetLength() > 0)
2720 else if(__pWindowInfo != null)
2722 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)
2724 LoadUrl(__pWindowInfo->pageUrl);
2726 else if(__pWindowInfo->pageUrl.GetLength() > 0 && __pWindowInfo->isAppcontrolTriggered == true)
2728 LoadUrl(__pWindowInfo->pageUrl);
2729 __pWindowInfo->isAppcontrolTriggered = false;
2731 else if (__pWindowInfo->isJavascriptInitiated == true)
2735 __pWindowInfo->pCurrentWeb = __pWebViewer;
2736 if(__pWindowInfo->pageUrl.GetLength() > 0)
2737 LoadUrl(__pWindowInfo->pageUrl);
2741 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2742 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2743 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2745 InitMostVisitedSitesView(GetOrientationStatus());
2747 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2749 if(__pMostVisitedListView != null)
2751 __pMostVisitedListView->SetShowState(false);
2755 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2757 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2759 if (pBookmarkUrl == null)
2761 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2762 //__pAddressbar->SetUrl(*pBookmarkUrl);
2763 SetUrl(*pBookmarkUrl);
2765 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2766 __pWebViewer->LoadUrl(*pBookmarkUrl);
2767 delete pBookmarkUrl;
2770 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2771 Bitmap* pBitmap = null;
2772 if (isPrivateBrowsing == true)
2774 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2776 if (__pWebViewer != null)
2778 __pWebViewer->SetPrivateBrowsingEnabled(true);
2781 if (__pAddressbar != null)
2783 // __pAddressbar->UpdateFaviconBitmap(true);
2789 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2791 if (__pWebViewer != null)
2793 __pWebViewer->SetPrivateBrowsingEnabled(false);
2796 if (__pAddressbar != null)
2798 // __pAddressbar->UpdateFaviconBitmap(false);
2802 if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
2804 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2806 else if (__pOptionMenu != null )
2808 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2811 if (pBitmap != null)
2816 RelayoutControls(false);
2817 AppLog("ABC: OnSceneActivatedN started exit");
2822 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2823 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2825 Canvas* pWebCanvas = null;
2826 if (__pWebViewer != null)
2828 pWebCanvas = __pWebViewer->GetCanvasN();
2831 if (pWebCanvas == null)
2835 if (__pWindowInfo != null)
2837 if (__pWindowInfo->pWebCanvasBitmap != null)
2839 delete __pWindowInfo->pWebCanvasBitmap;
2841 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2842 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2843 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2845 Bitmap* pBitmap = GetCapturedBitmapN();
2846 AppLog("Coming here");
2847 Canvas* pCanvas = new(std::nothrow) Canvas();
2848 pCanvas->Construct(GetClientAreaBounds());
2851 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2854 if(__pWebViewer != null && __pWindowInfo != null)
2855 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2857 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2858 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2862 __pAddressbar->SetShowState(false);
2863 AppLog("Coming here");
2867 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2868 const Tizen::Base::String& realm,
2869 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2875 MainForm::OnHttpAuthenticationCanceled(void)
2880 MainForm::OnLoadingStarted(void)
2882 AppLogDebug("MainForm::OnLoadingStarted entered");
2884 if(__pAddressbar == NULL || __pWebViewer == null)
2889 // this is added in case if menu is opened and user load the page
2890 if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
2892 __pOptionMenu->SetShowState(false);
2893 __pOptionMenu->Invalidate(true);
2898 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2900 __pImageMenu->SetShowState(false);
2901 __pImageMenu->Invalidate(true);
2903 String url = __pWebViewer->GetUrl();
2904 if(url.Contains(IDS_TIZEN_SERVICE))
2907 String delim(L":;,");
2909 // Creates a StringTokenizer instance
2910 StringTokenizer strTok(url, delim);
2912 int count = strTok.GetTokenCount(); // count == 4
2914 HashMap *pMap = new HashMap();
2919 while (strTok.HasMoreTokens())
2921 AppLog("Token: %ls", token.GetPointer());
2922 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2923 if(token.Contains(IDS_APPID))
2925 token.SubString(6, appId);
2926 AppLog("AppID:%ls", appId.GetPointer());
2928 else if(token.Contains(IDS_KEY))
2930 token.SubString(4, key);
2931 AppLog("key:%ls", key.GetPointer());
2933 else if(token.Contains(IDS_VALUE))
2935 token.SubString(6, value);
2936 AppLog("value:%ls", value.GetPointer());
2939 pMap->Add(key, value);
2943 AppControl *pAppControl = null;
2944 String operationId = L"http://tizen.org/appcontrol/operation/main";
2945 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2948 AppLog("Starting AppControl");
2949 result r = pAppControl->Start(null, null, pMap, null);
2950 AppLog("Result of Start %s", GetErrorMessage(r));
2954 AppLogException("AppControl not found");
2959 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
2961 __pAddressbar->SetShowState(false);
2962 AddressBarCancelledClicked(*__pAddressbar);
2963 __pAddressbar->Invalidate(true);
2965 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2968 __pAddressbar->SetFaviconBitmap(*pBitmap);
2971 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2973 // updating the address bar position with respect to web control
2974 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2975 __distanceMoved = 0;
2979 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2980 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2981 if (__pWebViewer != null)
2983 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2984 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2985 SetUrl(__pWebViewer->GetUrl());
2986 if (__pWindowInfo != NULL)
2988 // resetting the page title to blank, it will be received in OnPageTitleReceived()
2989 __pWindowInfo->pageTitle = L"";
2990 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2992 __pAddressbar->Invalidate(true);
2998 MainForm::OnLoadingCanceled(void)
3005 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
3007 AppLog("XYZ::MainForm::OnKeypadWillOpen");
3012 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
3014 AppLog("XYZ::MainForm::OnKeypadOpened");
3015 __isKeypadOpened = true;
3016 __pFooterPanel->SetShowState(false);
3021 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
3023 AppLog("XYZ::MainForm::OnKeypadClosed");
3024 __isKeypadOpened = false;
3025 __pFooterPanel->SetShowState(true);
3026 RelayoutControls(true);
3030 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
3032 AppLog("XYZ::KeypadBoundsChanged");
3033 RelayoutControls(false);
3037 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
3038 const Tizen::Base::String& reason)
3040 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
3044 MainForm::OnLoadingCompleted(void)
3046 AppLog("MainForm::OnLoadingCompleted start");
3048 result r = E_SUCCESS;
3050 if (__pWebViewer == null)
3055 if (__pAddressbar == null)
3060 if(__pImageMenu && __pImageMenu->GetShowState())
3062 __pImageMenu->SetShowState(false);
3063 __pImageMenu->Invalidate(true);
3066 if (__pWebViewer->CanGoForward())
3068 //__pAddressbar->SetForwardButtonEnabled(true);
3069 SetForwardButtonEnabled(true);
3073 //__pAddressbar->SetForwardButtonEnabled(false);
3074 SetForwardButtonEnabled(false);
3077 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3079 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3081 //__pAddressbar->UpdateProgress(0);
3085 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3087 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3091 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
3092 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
3093 if (isPrivateBrowsing == false)
3095 if(__pHistory != null)
3101 __pHistory = new(std::nothrow) History;
3102 HistoryPresentationModel::GetCurrentDateTime(date);
3105 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
3106 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
3108 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
3109 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3111 __pHistory->SetVisitedTime(date);
3113 if (__pWebViewer != null)
3115 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3117 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3118 if (pTempBitmap != null)
3120 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3121 __pHistory->SetFavIconBitmap(*pTempBitmap);
3124 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3127 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3128 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3129 if ( pCanvas != null && pCanvas != null && pBitmap != null)
3131 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3132 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3133 __pHistory->SetThumbnail(pBitmap);
3135 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3138 __pHistory->SetFavIconBitmap(*pFavIcon);
3142 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3149 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3151 // temperary fixed (webpage can be not loaded)
3155 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3156 if (isReaderEnabled == true)
3160 delete __pReaderData;
3161 __pReaderData = null;
3163 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3164 filePath.Append(L"data/reader.js");
3170 result r = E_SUCCESS;
3171 FileAttributes attr;
3173 File::GetAttributes(filePath,attr);
3175 r = file.Construct(filePath, L"r+");
3178 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3181 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3184 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3187 // file.Read(pScript,attr.GetFileSize());
3189 // AppLogDebug("scipt length %d",strlen(pScript));
3190 String strScript = L"";
3191 // strScript.Append(pScript);
3192 // for(int i=0; i<25; i++)
3194 file.Read(pScript,attr.GetFileSize());
3195 // AppLog("xyzz tell %d",file.Tell());
3196 // r = strScript.Append(pScript);
3197 // AppLog("xyzz append result %s",GetErrorMessage(r));
3198 // AppLog("xyzz strScript length %d",strScript.GetLength());
3200 // AppLog("xyzz final strScript length %d",strScript.GetLength());
3202 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3203 if (__pReaderData == null)
3205 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3206 __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>");
3209 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3210 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3212 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3213 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3219 AppLog("MainForm::OnLoadingCompleted done");
3223 MainForm::OnEstimatedProgress(int progress)
3225 AppLogDebug("MainForm::OnEstimatedProgress entered %d",progress);
3227 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3228 progress = DEFAULT_PROGRESS_PERCENTAGE;
3230 // __pAddressbar->UpdateProgress(progress);
3231 UpdateProgress(progress);
3234 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3236 AppLog("MainForm::OnFaviconReceived");
3237 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3239 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3242 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3249 MainForm::OnUrlValueChanged(Addressbar&)
3255 MainForm::OnUrlSubmitted(Addressbar& addBar)
3257 AppLog("MainForm::OnUrlSubmitted");
3258 String url = addBar.GetUrl();
3259 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3261 if(__pFooterUrlField)
3262 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3263 AddressBarCancelledClicked(*__pAddressbar);
3268 MainForm::LoadUrl(String& url)
3272 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3273 AppLogDebug("MainForm::LoadUrl enter");
3275 if (__pWebViewer != null)
3277 __pWebViewer->SetShowState(true);
3278 __pWebViewer->Invalidate(true);
3281 if (url.CompareTo(L"") == 0)
3285 if(__pFooterPanel != null)
3287 __pFooterPanel->SetShowState(true);
3288 __pFooterPanel->Invalidate(true);
3295 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3296 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)
3298 RegularExpression firstRegex;
3299 RegularExpression secondRegex;
3301 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3302 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3305 ret = firstRegex.Match(url, false); // This returns true value
3306 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3308 if (ret == true && __pWebViewer != null)
3311 __pWebViewer->LoadUrl(url);
3313 else if(__pWebViewer != null)
3315 String tempUrl = L"http://";
3316 tempUrl.Append(url);
3320 __pWebViewer->LoadUrl(tempUrl);
3324 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3325 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3328 if (__pAddressbar != null)
3330 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3331 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3334 AppLogDebug("MainForm::LoadUrl exit");
3341 MainForm::OnFocusGained(const Tizen::Ui::Control& source)
3343 AppLog("MainForm::OnFocusGained");
3346 __pFooterPanel->SetShowState(false);
3351 __pAddressbar->SetShowState(true);
3352 __pAddressbar->SetAddressbarURLFocus();
3354 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3356 __currentSearchStr = L"";
3357 __currentWordIndex = 0;
3358 __maxOccurrances = 0;
3360 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
3362 __pFindWordEditField->SetText(L"");
3363 __pFindWordEditField->HideKeypad();
3364 __pFindWordControl->SetShowState(false);
3365 __pFindWordCountLabel->SetText(L"0/0");
3367 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
3369 __pFindWordEditFieldRightToLeft->SetText(L"");
3370 __pFindWordEditFieldRightToLeft->HideKeypad();
3371 __pFindWordControl->SetShowState(false);
3372 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
3375 __pFindWordNext->SetEnabled(false);
3376 __pFindWordPrev->SetEnabled(false);
3378 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
3379 __pFindWordControl->SetShowState(false);
3381 RelayoutControls(false);
3385 MainForm::OnFocusLost(const Tizen::Ui::Control& source)
3387 AppLog("MainForm::OnFocusLost called");
3391 MainForm::OnStopClicked(Addressbar& addBar)
3393 AppLogDebug("MainForm::OnStopClicked called");
3396 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3397 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3398 __pWebViewer->StopLoading();
3399 RequestRedraw(true);
3404 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3406 // AppLog("MainForm::OnBackClicked");
3407 result r = E_FAILURE;
3408 if(__pImageMenu && __pImageMenu->GetShowState() == true)
3410 AppLog("Hiding the menu");
3411 __pImageMenu->SetShowState(false);
3414 if (__pWebViewer && __pWebViewer->CanGoBack())
3416 __pWebViewer->GoBack();
3418 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3421 pApp = UiApp::GetInstance();
3424 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3427 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3435 WindowInfo* pWindowInfo = null;
3437 SceneManager* pSceneManager = SceneManager::GetInstance();
3438 if (pSceneManager == null)
3442 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3443 if (pAllWindowList == NULL)
3445 pApp = UiApp::GetInstance();
3448 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3451 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3456 if (pAllWindowList != null)
3458 totalCount = pAllWindowList->GetCount();
3460 for (int count = 0; count < totalCount; count++)
3462 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3463 if (pWindowInfo == null)
3465 pApp = UiApp::GetInstance();
3468 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3471 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3476 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3478 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3481 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3484 r = pAllWindowList->RemoveAt(count, true);
3485 __pWindowInfo = null;
3488 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3493 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3495 else if(pAllWindowList->GetCount() > 0)
3497 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3501 pApp = UiApp::GetInstance();
3504 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3509 if (pWindowInfo == null)
3511 pApp = UiApp::GetInstance();
3514 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3520 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3523 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3537 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3539 AppLog("MainForm::OnForwardClicked");
3540 if (__pWebViewer == null)
3543 if (__pWebViewer->CanGoForward())
3545 __pWebViewer->GoForward();
3550 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3552 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3553 if(__pFooterPanel != null)
3555 __pFooterPanel->SetShowState(false);
3558 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3560 __pAddressbar->SetShowState(true);
3561 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3564 RelayoutControls(false);
3568 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3570 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3572 int Height = GetClientAreaBounds().height;
3573 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3575 RelayoutControls(false);
3579 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3581 AddressBarCancelledClicked(addBar);
3585 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3587 __prevAddressBarMode = __curAddressBarMode;
3589 if (__pAddressbar != null)
3591 __curAddressBarMode = GetAddressbarMode();
3594 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3596 __adressPanelPosition.y = 0;
3597 if (__pAddressbar != null)
3599 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3600 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3601 __pAddressbar->Invalidate(true);
3603 if (__pWebViewer != null)
3605 __pWebViewer->StopLoading();
3608 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3610 __adressPanelPosition.y = 0;
3611 if (__pAddressbar != null)
3613 __webControlPosition.y = 0;
3614 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3615 __pAddressbar->Invalidate(true);
3621 MainForm::OnClipboardClosed(const Addressbar& addBar)
3623 AppLog("XYZ::MainForm::OnClipboardClosed");
3624 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3626 AppLog("akjshdasd 3");
3627 __pFooterPanel->SetShowState(true);
3629 __isKeypadOpened = false;
3630 RelayoutControls(false);
3634 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3636 AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3637 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3639 AppLog("akjshdasd 3");
3640 __pFooterPanel->SetShowState(true);
3642 __isKeypadOpened = false;
3644 RelayoutControls(false,footerState);
3648 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3650 AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3651 __isKeypadOpened = true;
3652 RelayoutControls(false);
3656 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3658 __isKeypadOpened = true;
3659 __pFooterPanel->SetShowState(false);
3663 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3665 AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3666 RelayoutControls(false);
3670 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3672 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3675 __pWindowInfo->pageTitle = title;
3676 if (__pWebViewer != null)
3678 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3681 if (__pAddressbar != null && __pWebViewer != null)
3683 SetUrl(__pWebViewer->GetUrl());
3684 __pAddressbar->Invalidate(true);
3689 MainForm::UpdateFavicon(void)
3691 bool urlImageType = false;
3692 String *tempPath = null;
3694 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();");
3695 Bitmap* pBitmap = null;
3697 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3699 if (__pWindowInfo != null)
3702 url.SetUri(*tempPath);
3703 if (url.GetHost().GetLength() == 0)
3706 webUrl.SetUri(__pWebViewer->GetUrl());
3707 result r = url.SetHost(webUrl.GetHost());
3714 if (url.GetScheme().GetLength() == 0)
3717 webUrl.SetUri(__pWebViewer->GetUrl());
3718 url.SetScheme(webUrl.GetScheme());
3720 __pWindowInfo->faviconUrl = url.ToString();
3722 pBitmap = __pWebViewer->GetFaviconN();
3724 if (pBitmap != null)
3726 if (__pWindowInfo->pFavicon != NULL)
3728 __pWindowInfo->pFavicon = null;
3730 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3731 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3733 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3735 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3737 else if(__pWindowInfo->pFavicon != null)
3739 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3743 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3744 if(pDefaultBmp != null)
3746 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3760 if(tempPath != null)
3764 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3770 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3771 Tizen::Web::Controls::WebNavigationType type)
3773 AppLog("urlk %ls",url.GetPointer());
3774 // when load new page if find word panel is open its show state is false
3775 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3777 __currentSearchStr = L"";
3778 __currentWordIndex = 0;
3779 __maxOccurrances = 0;
3780 __pFindWordEditField->SetText(L"");
3781 __pFindWordNext->SetEnabled(false);
3782 __pFindWordPrev->SetEnabled(false);
3783 __pFindWordCountLabel->SetText(L"0/0");
3784 __pFindWordControl->SetShowState(false);
3785 __pFindWordEditField->HideKeypad();
3786 RelayoutControls(false);
3789 __pFooterPanel->Invalidate(true);
3792 uriInfo.SetUri(url);
3794 if(url.Contains(IDS_TIZEN_SERVICE))
3797 String delim(L":;,");
3799 // Creates a StringTokenizer instance
3800 StringTokenizer strTok(url, delim);
3802 int count = strTok.GetTokenCount(); // count == 4
3804 HashMap *pMap = new HashMap();
3810 while (strTok.HasMoreTokens())
3812 AppLog("Token: %ls", token.GetPointer());
3813 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3814 if(token.Contains(IDS_APPID))
3816 token.SubString(6, appId);
3817 AppLog("AppID:%ls", appId.GetPointer());
3819 else if(token.Contains(IDS_KEY))
3821 token.SubString(4, key);
3822 AppLog("key:%ls", key.GetPointer());
3824 else if(token.Contains(IDS_VALUE))
3826 token.SubString(6, value);
3827 AppLog("value:%ls", value.GetPointer());
3830 pMap->Add(key, value);
3834 AppControl *pAppControl = null;
3835 String operationId = L"http://tizen.org/appcontrol/operation/main";
3836 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3839 result r = pAppControl->Start(null, null, pMap, null);
3843 AppLogException("AppControl not found");
3853 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3854 const Tizen::Net::Http::HttpHeader& httpHeader)
3856 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3860 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
3862 if(__isLongPressedDone == false)
3864 AppLog("MainForm::OnWebPageBlockSelected");
3865 if (__pHitElementResult != null)
3867 delete __pHitElementResult;
3868 __pHitElementResult = null;
3871 if (__pWebViewer != null)
3873 AppLog("MainForm::OnWebPageBlockSelected web not null");
3874 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3876 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
3878 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
3879 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3880 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
3882 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
3884 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
3888 if (__pHitElementResult == null)
3893 if (__pHitElementResult->HasImage() != true)
3895 String tagName = __pHitElementResult->GetTagName();
3896 String type = __pHitElementResult->GetAttributeValue("type");
3899 AppLog("TagName %ls",tagName.GetPointer());
3900 __currentSelectedStr.Clear();
3901 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3902 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3903 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3905 if (((tagName.Equals(L"INPUT",false) == 0) || tagName.Equals(L"TEXTAREA",false) == 0) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
3907 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3909 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),true);
3910 __pImageMenu->SetShowState(true);
3911 __pImageMenu->Show();
3912 __pImageMenu->Invalidate(true);
3914 else /*if(__isLongPressedDone == true)*/
3916 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3918 if(__pHitElementResult->GetUrl().GetLength() > 0)
3920 __currentSelectedStr.Clear();
3921 __currentSelectedStr = __pHitElementResult->GetUrl();
3923 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),false);
3924 __pImageMenu->SetShowState(true);
3925 __pImageMenu->Show();
3926 __pImageMenu->Invalidate(true);
3929 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3930 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3931 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3937 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3943 MainForm::OnWebWindowCreateRequested(void)
3945 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
3947 if (pNewWindowInfo == null)
3951 result r = E_SUCCESS;
3952 SceneManager* pSceneManager = SceneManager::GetInstance();
3953 if (pSceneManager == NULL)
3957 ArrayList* pArgList = new(std::nothrow) ArrayList();
3958 if (pArgList == NULL)
3962 r = pArgList->Construct();
3965 pNewWindowInfo->isJavascriptInitiated = true;
3966 pArgList->Add(*pNewWindowInfo);
3967 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3971 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3978 return pNewWindowInfo->pCurrentWeb;
3982 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
3984 AppLog("xyz:: MainForm::RelayoutControls called");
3985 __webControlPosition.y = 0;
3986 __webControlHeight = GetClientAreaBounds().height;
3987 AppLog("Client area height: %d", __webControlHeight);
3989 AppLog("Client area height: %d", __webControlHeight);
3990 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3992 __webControlPosition.y += __pAddressbar->GetHeight();
3993 __webControlHeight -= __pAddressbar->GetHeight();
3994 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3996 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3998 __webControlPosition.y += __pFindWordControl->GetHeight();
3999 __webControlHeight -= __pFindWordControl->GetHeight();
4000 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
4003 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
4005 __webControlHeight -= __pFooterPanel->GetHeight();
4007 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
4009 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
4011 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight + 12 )
4016 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12);
4017 AppLog("xyz:: MainForm::RelayoutControls called __webControlHeight %d",__webControlHeight);
4018 __pWebViewer->Invalidate(false);
4021 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
4023 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
4030 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
4032 if (__pFindWordControl == null)
4037 Tizen::Locales::LocaleManager localeManager;
4038 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
4040 String languageCode;
4041 result r = SettingInfo::GetValue(L"Language", languageCode);
4042 // int languagecode = local.GetLanguageCode();
4043 AppLog("rahul language is %S", languageCode.GetPointer());
4047 InitFindWordPanel();
4049 if (languageCode.CompareTo("ara") == 0)
4051 AppLog("rahul language is arabic");
4053 __pFindWordPanelLeftToRight->SetShowState(false);
4054 __pFindWordPanelRightToLeft->SetShowState(true);
4056 __pFindWordClear->SetShowState(false);
4057 // __pFindWordCountLabel->SetShowState(false);
4058 __pFindWordEditField->SetShowState(false);
4060 __pFindWordClearRightToLeft->SetShowState(true);
4061 __pFindWordCountLabelRightToLeft->SetShowState(true);
4062 __pFindWordEditFieldRightToLeft->SetShowState(true);
4066 AppLog("rahul language is not arabic");
4069 __pFindWordPanelLeftToRight->SetShowState(true);
4070 __pFindWordPanelRightToLeft->SetShowState(false);
4072 __pFindWordClear->SetShowState(true);
4073 __pFindWordCountLabel->SetShowState(true);
4074 __pFindWordEditField->SetShowState(true);
4076 __pFindWordClearRightToLeft->SetShowState(false);
4077 __pFindWordCountLabelRightToLeft->SetShowState(false);
4078 __pFindWordEditFieldRightToLeft->SetShowState(false);
4080 __pFindWordControl->SetShowState(true);
4084 if(__pFindWordControl != null)
4086 __pFindWordControl->SetShowState(false);
4090 AppLog("MainForm::ShowFindWordPanel %d",show);
4091 if (show && !isTouchPressed)
4093 if (languageCode.CompareTo("ara") == 0)
4095 if (__pFindWordEditFieldRightToLeft)
4097 __pFindWordEditFieldRightToLeft->SetFocus();
4098 __pFindWordEditFieldRightToLeft->ShowKeypad();
4103 if (__pFindWordEditField)
4105 __pFindWordEditField->SetFocus();
4106 __pFindWordEditField->ShowKeypad();
4112 if (languageCode.CompareTo("ara") == 0)
4114 if (__pFindWordEditFieldRightToLeft)
4115 __pFindWordEditFieldRightToLeft->HideKeypad();
4119 if (__pFindWordEditField)
4120 __pFindWordEditField->HideKeypad();
4124 RelayoutControls(false);
4128 MainForm::StartWordSearch()
4130 //Get the count of occurances of the word in the current page
4131 __maxOccurrances = 0;
4132 __currentWordIndex = 0;
4134 __pFindWordPrev->SetEnabled(false);
4135 String *pCountStr = null;
4136 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
4137 AppLog("Search Result %s",GetErrorMessage(r));
4138 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
4139 if (pCountStr != null)
4141 Integer::Parse(*pCountStr, 10, __maxOccurrances);
4145 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
4150 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
4152 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
4153 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
4155 if(totalCount == -1 || totalCount == 0)
4157 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
4158 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
4161 else if(totalCount > 100)
4163 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4164 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4168 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4169 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4172 __maxOccurrances = totalCount;
4173 __currentWordIndex = currentOrdinal;
4175 //Reset the UI controls as per the maxOccurrance value
4176 if (totalCount <= 0)
4178 AppLog("Word not found");
4179 //Show error notification to user
4180 __pFindWordNext->SetEnabled(false);
4181 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4183 __pFindWordCountLabel->SetText(L"0/0");
4184 __pFindWordCountLabel->Invalidate(false);
4186 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4188 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4189 __pFindWordCountLabelRightToLeft->Invalidate(false);
4191 __pFindWordNext->Invalidate(false);
4192 __pFindWordPrev->Invalidate(false);
4197 if (totalCount == 1)
4199 __pFindWordNext->SetEnabled(false);
4203 __pFindWordNext->SetEnabled(true);
4206 String countStr = L"";
4207 countStr.Append(__currentWordIndex);
4208 countStr.Append(L"/");
4209 countStr.Append(__maxOccurrances);
4210 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4212 __pFindWordCountLabel->SetText(countStr);
4213 __pFindWordCountLabel->Invalidate(false);
4214 __pFindWordCountLabel->Invalidate(false);
4216 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4218 __pFindWordCountLabelRightToLeft->SetText(countStr);
4219 __pFindWordCountLabelRightToLeft->Invalidate(false);
4220 __pFindWordCountLabelRightToLeft->Invalidate(false);
4222 //FindNextWord(true);
4223 //Update the controls
4224 __pFindWordNext->Invalidate(false);
4225 __pFindWordPrev->Invalidate(false);
4230 MainForm::FindNextWord(bool next)
4234 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4235 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4237 if (__currentWordIndex < __maxOccurrances)
4239 __currentWordIndex++;
4245 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4246 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4248 if(__currentWordIndex > 1)
4250 __currentWordIndex--;
4255 String countStr = L"";
4256 countStr.Append(__currentWordIndex);
4257 countStr.Append(L"/");
4258 countStr.Append(__maxOccurrances);
4260 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4262 __pFindWordCountLabel->SetText(countStr);
4263 __pFindWordCountLabel->Invalidate(false);
4265 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4267 __pFindWordCountLabelRightToLeft->SetText(countStr);
4268 __pFindWordCountLabelRightToLeft->Invalidate(false);
4271 if (__currentWordIndex >= __maxOccurrances)
4273 __pFindWordNext->SetEnabled(false);
4277 __pFindWordNext->SetEnabled(true);
4279 if (__currentWordIndex <= 1)
4281 __pFindWordPrev->SetEnabled(false);
4285 __pFindWordPrev->SetEnabled(true);
4287 __pFindWordPrev->Invalidate(false);
4288 __pFindWordNext->Invalidate(false);
4290 __pFindWordControl->Invalidate(true);
4294 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4296 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4297 __isKeypadOpened = true;
4298 __pFooterPanel->SetShowState(false);
4299 // OnAddressBarKeypadOpened(*__pAddressbar);
4303 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4305 __isKeypadOpened = true;
4306 AppLog("xyz::MainForm::OnWebKeypadOpened");
4308 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4310 __currentSearchStr = L"";
4311 __currentWordIndex = 0;
4312 __maxOccurrances = 0;
4313 __pFindWordEditField->SetText(L"");
4314 __pFindWordNext->SetEnabled(false);
4315 __pFindWordPrev->SetEnabled(false);
4316 __pFindWordCountLabel->SetText(L"0/0");
4317 __pWebViewer->SearchTextAllAsync(L"",false);
4318 __pFindWordControl->SetShowState(false);
4319 __pFindWordEditField->HideKeypad();
4323 if (__pWebViewer != null && __pFooterPanel != null)
4325 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4326 if(__pAddressbar != null)
4328 __pAddressbar->SetShowState(false);
4330 if(__pFindWordControl != null)
4332 __pFindWordControl->SetShowState(false);
4334 __pFooterPanel->SetShowState(false);
4335 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4337 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4339 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4340 // AppLog("omgomgomg");
4346 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4348 AppLog("xyz::MainForm::OnWebKeypadClosed");
4349 AppLog("akjshdasd 4");
4350 __pFooterPanel->SetShowState(true);
4351 // OnAddressBarKeypadClosed(*__pAddressbar);
4352 RelayoutControls(false);
4353 __isKeypadOpened = false;
4357 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4359 // RelativeLayout(false);
4360 if(__pWebViewer != null)
4362 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4367 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4369 Control* temp = const_cast< Control* >(&source);
4370 Header* pHeader = dynamic_cast< Header* >(temp);
4371 if (pHeader != null)
4373 //Header double - clicked
4374 AppLog("Header double clicked");
4376 if(__pFindWordControl)
4378 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4379 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4383 AppLog("MainScene::OnTouchDoublePressed");
4387 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4389 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4390 if(TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1)
4392 AppLog("Returning because of more than one touch point.");
4395 __longPressPoint = currentPosition;
4397 if (__pHitElementResult != null)
4399 delete __pHitElementResult;
4400 __pHitElementResult = null;
4403 if (__pWebViewer != null)
4405 AppLog("MainForm::OnTouchLongPressed web not null");
4406 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4409 if (__pHitElementResult == null)
4414 if (__pHitElementResult->HasImage() == true)
4416 if(__pWebViewer != null)
4417 InitImageContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4418 __pImageMenu->SetShowState(true);
4419 __pImageMenu->Show();
4420 __pImageMenu->Invalidate(true);
4422 else if(__pHitElementResult->HasUrl() == true)
4424 String tempURl = __pHitElementResult->GetUrl();
4425 AppLog("tempURl is %ls", tempURl.GetPointer());
4426 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4427 if (pBitmap != null)
4435 InitImageLinkContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4436 __pImageMenu->SetShowState(true);
4437 __pImageMenu->Show();
4438 __pImageMenu->Invalidate(true);
4442 String tagName = __pHitElementResult->GetTagName();
4443 String type = __pHitElementResult->GetAttributeValue("type");
4444 String value = __pHitElementResult->GetAttributeValue(L"value");
4445 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4447 __currentSelectedStr.Clear();
4448 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4450 AppLog("tag name is %ls", tagName.GetPointer());
4451 AppLog("type is %ls", type.GetPointer());
4455 __isLongPressedDone = true;
4456 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4457 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)
4459 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4461 InitSelectTextContextMenu(Point(currentPosition.x , currentPosition.y + __pWebViewer->GetY()),true, true);
4464 __pImageMenu->SetShowState(true);
4465 __pImageMenu->Show();
4466 __pImageMenu->Invalidate(true);
4469 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4472 // __inputEventToBeSupressed = true;
4476 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4478 AppLog("xyz:: MainForm::OnTouchReleased called");
4480 if (__pAddressbar && __pAddressbar->GetShowState() == true)
4482 __pAddressbar->SetShowState(false);
4484 if(__pFooterPanel && __isKeypadOpened == false)
4486 __pFooterPanel->SetShowState(true);
4490 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4491 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4493 __pWebViewer->ConsumeInputEvent();
4495 if(pHitElement != null)
4499 __inputEventToBeSupressed = false;*/
4503 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4510 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4512 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4514 __currentSearchStr = L"";
4515 __currentWordIndex = 0;
4516 __maxOccurrances = 0;
4518 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4520 __pFindWordEditField->SetText(L"");
4521 __pFindWordEditField->HideKeypad();
4522 __pFindWordControl->SetShowState(false);
4523 __pFindWordCountLabel->SetText(L"0/0");
4525 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4527 __pFindWordEditFieldRightToLeft->SetText(L"");
4528 __pFindWordEditFieldRightToLeft->HideKeypad();
4529 __pFindWordControl->SetShowState(false);
4530 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4533 __pFindWordNext->SetEnabled(false);
4534 __pFindWordPrev->SetEnabled(false);
4536 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
4537 __pFindWordControl->SetShowState(false);
4539 AppLog("__pAddressbar->GetShowState() %d",__pAddressbar->GetShowState());
4540 if(__pAddressbar->GetShowState() == false)
4542 __pAddressbar->SetAddressbarURLFocus();
4543 __pFooterPanel->SetShowState(false);
4550 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4556 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4562 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4568 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4574 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4580 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4582 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4583 int widthContextItem = 0;
4584 if(__pFindWordCountLabel)
4585 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4586 // As per the platform engineer comment removed this line
4587 /*if(__pWebViewer != null)
4589 // 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
4590 __pWebViewer->ReleaseBlock();
4593 // if(__pFindWordControl != null)
4594 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4596 if(__pOptionMenu && __pOptionMenu->GetShowState() == true)
4598 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
4600 AppLog(" Orientation landscape");
4601 __pOptionMenu->SetMaxVisibleItemsCount(5);
4605 AppLog(" Orientation potrait");
4606 __pOptionMenu->SetMaxVisibleItemsCount(6);
4609 if(__pNotification && __pNotification->GetShowState() == true)
4611 __pNotification->SetShowState(false);
4612 __pNotification->Invalidate(false);
4614 if ( __pFooterLabel != null)
4616 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4619 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4625 if (__pFindWordBgLabel != null)
4627 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4628 if (pBitmap != null)
4630 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4635 if (__pFindWordBgLabelRightToLeft != null)
4637 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4638 if (pBitmap != null)
4640 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4646 // if(__pOptionMenu != null)
4647 // __pOptionMenu->SetShowState(false);
4649 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4651 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4655 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4660 AppLog("__pFooterPanel->GetShowState() is true");
4662 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4663 __pFooterPanel->Invalidate(true);
4667 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4668 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4670 InitMostVisitedSitesView(orientationStatus);
4673 RelayoutControls(false);
4674 if (__pArticleReaderPanel != null)
4676 if (__pArticleReaderPanel->GetShowState() == true)
4678 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4680 if (__pBlankPanel != null)
4681 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4683 if (__pWebReader != null)
4685 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4687 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4688 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4690 if ( pBitmap != null && pSrcBitmap != null)
4692 AppLog("CreateReaderPanel ninepatchbitmap found");
4693 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4696 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4697 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4698 if (pBitmap != null)
4703 if (pSrcBitmap != null)
4712 if (__pAddressbar != null)
4714 int width = GetClientAreaBounds().width;
4715 __pAddressbar->OrientationChanged(width);
4720 MainForm::OnSettingsChange(int settingvalue)
4722 AppLogDebug("MainForm::OnSettingsChange entered");
4724 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4726 __pAddressbar->ResetGuideText();
4728 if (__pWebViewer == null)
4730 AppLogDebug("Webviewer is not initialized yet.");
4734 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4736 WebSetting settings = __pWebViewer->GetSetting();
4737 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4739 settings.SetAutoFittingEnabled(true);
4741 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
4743 settings.SetAutoFittingEnabled(false);
4745 __pWebViewer->SetSetting(settings);
4747 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4749 WebSetting settings = __pWebViewer->GetSetting();
4750 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4751 __pWebViewer->SetSetting(settings);
4753 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4755 WebSetting settings = __pWebViewer->GetSetting();
4756 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4757 __pWebViewer->SetSetting(settings);
4758 __pWebViewer->Reload();
4760 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4762 WebSetting settings = __pWebViewer->GetSetting();
4763 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4764 __pWebViewer->SetSetting(settings);
4766 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4770 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4773 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
4777 WebSetting settings = __pWebViewer->GetSetting();
4778 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
4779 __pWebViewer->SetSetting(settings);
4782 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
4786 WebSetting settings = __pWebViewer->GetSetting();
4787 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
4788 __pWebViewer->SetSetting(settings);
4791 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4793 WebSetting settings = __pWebViewer->GetSetting();
4794 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4796 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4800 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4802 __pWebViewer->SetSetting(settings);
4804 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4808 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4809 WebSetting settings = __pWebReader->GetSetting();
4810 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4811 __pWebReader->SetSetting(settings);
4817 MainForm::OnSettingsReset()
4821 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4822 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4827 MainForm::OnClearCache()
4829 result r = E_SUCCESS;
4831 if (__pWebViewer != NULL)
4833 r = __pWebViewer->ClearCache();
4836 AppLogDebug("Cache cleared success");
4840 AppLogDebug("Cache cleared fail");
4846 MainForm::OnClearCookie()
4848 result r = E_SUCCESS;
4850 if (__pWebViewer != NULL)
4852 __pWebViewer->ClearCookie();
4856 AppLogDebug("Cookie cleared success");
4860 AppLogDebug("Cache cleared fail");
4865 MainForm::OnClearFormData()
4867 result r = E_SUCCESS;
4869 if (__pWebViewer != NULL)
4871 __pWebViewer->ClearFormData();
4875 AppLogDebug("Cookie cleared success");
4879 AppLogDebug("Cache cleared fail");
4884 MainForm::OnClearPasswords()
4886 result r = E_SUCCESS;
4888 if (__pWebViewer != NULL)
4890 __pWebViewer->ClearLoginFormData();
4894 AppLogDebug("Cookie cleared success");
4898 AppLogDebug("Cache cleared fail");
4904 MainForm::findDistance(int x1,int y1,int x2, int y2)
4906 int deltaX = Math::Abs(x2 - x1);
4907 int deltaY = Math::Abs(y2 - y1);
4908 double num = deltaX*deltaX + deltaY*deltaY;
4914 for (i = 0; i < 20; i++)
4916 x = (((x*x)+ num)/(2*x));
4927 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4929 AppLog("xyz:: MainForm::OnTouchPressed called");
4930 if(__pFindWordControl)
4932 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4933 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4935 __isLongPressedDone = false;
4940 IList* pList = null;
4941 pList = touch.GetTouchInfoListN(source);
4945 int count = pList->GetCount();
4948 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4949 __touchPoint1 = pTouchInfo->position;
4951 /*if (__pAddressbar != null)
4953 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4955 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4957 __pAddressbar->SaveAddressbarEditText();
4959 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4962 __pAddressbar->Invalidate(true);
4964 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4966 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4968 //__pAddressbar->SaveAddressbarEditText();
4970 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4973 else if (count == 2)
4975 AppLogDebug("MainForm::OnTouchPressed count is two");
4976 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4977 __touchPoint1 = pTouchInfo->position;
4979 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4980 __touchPoint2 = pTouchInfo->position;
4985 pList->RemoveAll(true);
4990 __pAddressbar->SetShowState(false);
4992 if(__pFooterPanel && __isKeypadOpened == false)
4994 __pFooterPanel->SetShowState(true);
4996 RelayoutControls(false);
5001 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5003 // __currentWordIndex = 0;
5004 __isLongPressedDone = false;
5009 MainForm::MoveUiControls()
5014 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
5016 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
5018 if(__pFooterUrlField->GetTextLength() == 0)
5020 __pFooterUrlField->SetKeypadActionEnabled(false);
5024 __pFooterUrlField->SetKeypadActionEnabled(true);
5027 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
5029 __currentSearchStr = __pFindWordEditField->GetText();
5030 if (__currentSearchStr.GetLength() > 0)
5032 __pFindWordCountLabel->SetShowState(true);
5036 // __pFindWordCountLabel->SetShowState(false);
5037 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
5038 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
5041 __pFindWordNext->SetEnabled(false);
5042 __pFindWordPrev->SetEnabled(false);
5043 __pFindWordNext->Invalidate(true);
5044 __pFindWordPrev->Invalidate(true);
5045 __pFindWordCountLabel->SetText(L"0/0");
5046 __pFindWordCountLabel->Invalidate(true);
5048 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
5050 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
5051 if (__currentSearchStr.GetLength() > 0)
5053 __pFindWordCountLabelRightToLeft->SetShowState(true);
5057 __pFindWordCountLabelRightToLeft->SetShowState(false);
5060 __pFindWordNext->SetEnabled(false);
5061 __pFindWordPrev->SetEnabled(false);
5062 __pFindWordNext->Invalidate(true);
5063 __pFindWordPrev->Invalidate(true);
5064 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
5065 __pFindWordCountLabelRightToLeft->Invalidate(true);
5067 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
5068 if (__currentSearchStr.GetLength() > 0)
5074 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
5076 __currentSearchStr = L"";
5077 AppLogDebug("Enter something");
5082 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
5089 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
5091 if(__pWebViewer != null)
5094 AppLog("MainForm::InitMostVisitedSitesView");
5095 result r = E_SUCCESS;
5098 if (__pWebViewer != null && __pMostVisitedListView != null)
5103 if (__pMostVisitedListView != null)
5105 RemoveControl(__pMostVisitedListView);
5107 if(__pMostVisitedSites != null)
5109 __pMostVisitedSites->RemoveAll(true);
5112 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
5114 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
5115 __pMostVisitedListView = new(std::nothrow) ListView();
5117 int height = GetClientAreaBounds().height;
5119 if(__pFooterPanel->GetShowState() == true)
5121 height = height - __pFooterPanel->GetHeight();
5123 if(__pAddressbar->GetShowState() == true)
5125 height -= __pAddressbar->GetHeight();
5128 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
5132 delete __pMostVisitedListView;
5133 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
5136 __pMostVisitedListView->SetItemProvider(*this);
5137 __pMostVisitedListView->AddListViewItemEventListener(*this);
5138 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_VISITED_SITES"));
5139 AddControl(__pMostVisitedListView);
5140 __pMostVisitedListView->UpdateList();
5147 MainForm::GetImagePath(void)
5151 String formattedTime;
5152 DateTime currentTime;
5153 LocaleManager localManager;
5154 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
5156 localManager.Construct();
5157 Locale locale = localManager.GetSystemLocale();
5158 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
5160 // Get date formatter
5161 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
5165 pTimeFormatter->Format(currentTime, formattedTime);
5168 AppLog("current time stamp is %ls", formattedTime.GetPointer());
5169 String delim(L" :");
5170 StringTokenizer strTok(formattedTime, delim);
5173 String str1("GMT+00");
5174 while (strTok.HasMoreTokens())
5176 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
5177 if(token.Equals(str1))
5179 AppLog("token is %ls", token.GetPointer());
5180 imageName.Append(token);
5186 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
5188 result r = E_FAILURE;
5189 AppLog("Content manager 1");
5190 ContentId contentId;
5191 ContentManager contentManager;
5192 r = contentManager.Construct();
5195 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
5198 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
5199 Tizen::Io::Directory::Create(contentPath,true);
5200 if(GetLastResult() == E_FILE_ALREADY_EXIST)
5202 AppLog("Already exists");
5204 else if(GetLastResult() == E_SUCCESS)
5206 AppLog("created success");
5208 contentPath.Append(imageName);
5209 contentPath.Append(".jpg");
5210 contentId = contentManager.CreateContent(*aBuffer, contentPath);
5211 ShowIndicatorNotification(L"Download Complete",contentPath);
5212 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5216 MainForm::ShowIndicatorNotification(const String& messageText, const String& contentPath)
5218 AppLogDebug("ENTER");
5220 NotificationRequest request;
5221 request.SetAlertText(messageText);
5222 request.SetTitleText(L"");
5223 request.SetAppMessage(contentPath);
5224 request.SetOngoingActivityType(ONGOING_ACTIVITY_TYPE_TEXT);
5225 request.SetNotificationStyle(NOTIFICATION_STYLE_THUMBNAIL);
5226 Tizen::App::App* pApp = Tizen::App::App::GetInstance();
5227 String homePath = pApp->GetAppRootPath();
5228 String iconPath = homePath + L"res/screen-density-xhigh/Notification_download_complete.png";
5229 AppLog("The iconPath is : %ls", homePath.GetPointer());
5230 request.SetIconFilePath(iconPath);
5232 Tizen::Shell::NotificationManager notiMgr;
5233 notiMgr.Construct();
5234 notiMgr.NotifyOngoingActivity(request);
5235 AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));
5240 MainForm::SetForwardButtonEnabled(bool isEnabled)
5242 __pGoForwardBtn->SetEnabled(isEnabled);
5243 __pGoForwardBtn->Invalidate(true);
5247 MainForm::SetBackButtonEnabled(bool isEnabled)
5249 __pGoBackBtn->SetEnabled(isEnabled);
5250 __pGoBackBtn->Invalidate(true);
5254 MainForm::UpdateProgress(int percentage)
5256 __progressPercentage = percentage;
5257 if (percentage == 0 || percentage == 100)
5259 __isLoadingData = false;
5260 if (percentage == 100)
5262 __isLoadingCompleted = true;
5263 __progressPercentage = 0;
5267 __isLoadingCompleted = false;
5272 __isLoadingData = true;
5274 UpdateProgressBitmap();
5278 MainForm::GetProgress(void)
5280 return __progressPercentage;
5284 MainForm::UpdateProgressBitmap(void)
5286 result r = E_SUCCESS;
5287 if (__pProgressbarLabel == null)
5289 int w = __pProgressbarLabel->GetWidth();
5290 int h = __pProgressbarLabel->GetHeight();
5292 int progressWidth = 0;
5293 Bitmap* pRetBitmap = null;
5295 if (__progressPercentage == 0 || __progressPercentage == 100)
5297 __pProgressbarLabel->SetShowState(false);
5298 __pProgressbarLabel->Invalidate(false);
5303 __pProgressbarLabel->SetShowState(true);
5304 __pProgressbarLabel->Invalidate(false);
5307 r = canvas.Construct(Rectangle(0, 0, w, h));
5311 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5316 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5320 pBgBmp->Scale(Dimension(w, h));
5321 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5325 progressWidth = (double) (w) * __progressPercentage / 100;
5326 AppLogDebug("progressWidth: %d", progressWidth);
5327 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5329 if (pProgressBmp != null)
5331 pProgressBmp->Scale(Dimension(progressWidth, h));
5332 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5333 delete pProgressBmp;
5336 pRetBitmap = new (std::nothrow) Bitmap();
5338 if (pRetBitmap == null)
5340 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5344 pRetBitmap->Construct(canvas, canvas.GetBounds());
5346 if (__pProgressbarLabel != null && pRetBitmap != null)
5348 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5349 __pProgressbarLabel->Invalidate(false);
5352 if (pRetBitmap != null)
5361 MainForm::ReaderClicked()
5363 result r = E_SUCCESS;
5364 ArrayList* pArgList = new(std::nothrow) ArrayList();
5365 if (pArgList != null)
5367 r = pArgList->Construct();
5374 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5381 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5388 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5396 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5402 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5404 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5406 __currentAddMode = addMode;
5410 case ADDRESSBAR_MODE_INVALID:
5415 case ADDRESSBAR_MODE_READER:
5417 __pStopBtn->SetShowState(false);
5418 __pRefreshBtn->SetShowState(false);
5419 __pClearBtn->SetShowState(false);
5420 __pReaderBtn->SetShowState(false);
5423 case ADDRESSBAR_MODE_LOADING:
5425 __pRefreshBtn->SetShowState(false);
5426 __pStopBtn->SetShowState(true);
5427 __pClearBtn->SetShowState(false);
5428 __pReaderBtn->SetShowState(false);
5431 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5433 // SetUrl(__pAddressbar->GetUrl());
5435 __pRefreshBtn->SetShowState(true);
5436 __pStopBtn->SetShowState(false);
5437 __pClearBtn->SetShowState(false);
5438 __pReaderBtn->SetShowState(false);
5441 case ADDRESSBAR_MODE_EDIT:
5443 __pRefreshBtn->SetShowState(false);
5444 __pStopBtn->SetShowState(false);
5445 __pReaderBtn->SetShowState(false);
5446 __pClearBtn->SetShowState(true);
5453 OnAddressBarModeChanged();
5456 AddressBarMode MainForm::GetAddressbarMode(void)
5458 return __currentAddMode;
5461 void MainForm::SetUrl(const String& url)
5464 if(__displayUrl.GetLength() > 2048)
5465 __displayUrl.SubString(0,2048,__displayUrl);
5467 if (__pFooterUrlField != NULL)
5469 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5470 if (removedHttpUrl.IsEmpty() == false)
5472 __pFooterUrlField->SetText(removedHttpUrl);
5473 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5474 __pAddressbar->SetUrl(__displayUrl);
5478 __pFooterUrlField->SetText(__displayUrl);
5479 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5480 __pAddressbar->SetUrl(__displayUrl);
5482 if(__pFooterUrlField)
5483 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5484 __pFooterUrlField->Invalidate(false);
5485 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5486 __pAddressbar->Invalidate(true);
5487 // __pFooterUrlField->SetCursorPosition(0);
5492 MainForm::RemoveHttpTextFromDisplayURL(void)
5494 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5496 // bool isHttpText = __displayUrl.Contains(L"http://");
5497 String updatedDisplayUrl;
5498 updatedDisplayUrl.Clear();
5499 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5501 __displayUrl.SubString(7,updatedDisplayUrl);
5503 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5505 __displayUrl.SubString(8,updatedDisplayUrl);
5507 return updatedDisplayUrl;
5510 void MainForm::OnSharePopupControlStarted(void)
5512 __pWebViewer->AddTouchEventListener(*this);
5516 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5518 if (requestId == BACK_GROUND_APP_EVENT)
5520 if(__pWebViewer != null)
5522 __pWebViewer->Pause();
5526 __pImageMenu->SetShowState(false);
5528 if(__pAddressbar != null)
5530 __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5533 else if(requestId == FORE_GROUND_APP_EVENT)
5535 if(__pWebViewer != null)
5537 __pWebViewer->Resume();
5539 if(__pAddressbar != null)
5541 __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5547 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5549 AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5550 result r = E_SUCCESS;
5553 __pAddressbar->SetShowState(false);
5555 AppLog("akjshdasd 5");
5556 __pFooterPanel->SetShowState(true);
5559 __pWebViewer->SetFocus();
5560 else if(__pMostVisitedListView)
5561 __pMostVisitedListView->SetFocus();
5562 else if(__pMultiWindowButton)
5563 __pMultiWindowButton->SetFocus();
5564 else if(__pMoreButton)
5565 __pMoreButton->SetFocus();
5567 __pAddressbar->SetShowState(false);
5569 RelayoutControls(false);
5573 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5575 AppLog("MainForm::OnFormMenuRequested called");
5577 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer && __pWebViewer->GetShowState() == true)
5579 int bookmarkCount=0;
5582 url=__pWindowInfo->pageUrl;
5583 AppLog("MainForm::OnFormMenuRequested url %ls",url.GetPointer());
5584 result r = E_SUCCESS;
5585 Bitmap* pBitmap = null;
5586 String lastChar = L"";
5587 // if(url.SubString(url.GetLength()-1,lastChar));
5588 // if(lastChar == L"/")
5590 // bool exist1 = false;
5591 // bool exist2 = false;
5592 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist1);
5593 // url.SubString(0,url.GetLength() - 1,url);
5594 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist2);
5595 // exist = exist1 | exist2;
5599 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5602 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5608 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5612 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5614 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5616 if (__pOptionMenu->GetItemCount() == 9)
5618 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5622 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5627 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
5631 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
5632 if (__pOptionMenu->GetItemCount() != 9)
5634 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
5635 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
5636 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
5637 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
5638 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
5639 __pOptionMenu->SetMaxVisibleItemsCount(6);
5641 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
5643 AppLog(" Orientation landscape");
5644 __pOptionMenu->SetMaxVisibleItemsCount(5);
5648 AppLog(" Orientation potrait");
5649 __pOptionMenu->SetMaxVisibleItemsCount(6);
5652 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
5655 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
5657 __pAddressbar->SetShowState(false);
5659 __pFooterPanel->SetShowState(true);
5660 result r = __pOptionMenu->SetShowState(true);
5661 AppLog("ajsghd %s",GetErrorMessage(r));
5662 __pOptionMenu->Invalidate(true);
5663 __pOptionMenu->Show();