-//\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Flora License, Version 1.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://floralicense.org/license/\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an AS IS BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-//!Internet MainForm class\r
-/*@file: MainForm.cpp\r
- *@brief: The %MainForm provides the common functionalities for the Main View of the Browser including the addressbar,\r
- * loading,handling events etc.\r
- */\r
-\r
-#include <FApp.h>\r
-#include <FGraphics.h>\r
-#include <FMedia.h>\r
-#include <FUi.h>\r
-#include <FContent.h>\r
-\r
-#include "IntBookmarkData.h"\r
-#include "IntBookmarkPresentationModel.h"\r
-#include "IntCommonLib.h"\r
-#include "IntFaviconManager.h"\r
-#include "IntMainForm.h"\r
-#include "IntNotificationPanel.h"\r
-#include "IntSceneRegister.h"\r
-#include "IntSettingPresentationModel.h"\r
-\r
-using namespace Tizen::App;\r
-using namespace Tizen::Base;\r
-using namespace Tizen::Base::Collection;\r
-using namespace Tizen::Base::Runtime;\r
-using namespace Tizen::Base::Utility;\r
-using namespace Tizen::Graphics;\r
-using namespace Tizen::Io;\r
-using namespace Tizen::Locales;\r
-using namespace Tizen::Media;\r
-using namespace Tizen::Ui;\r
-using namespace Tizen::Ui::Controls;\r
-using namespace Tizen::Content;\r
-using namespace Tizen::Ui::Scenes;\r
-using namespace Tizen::System;\r
-using namespace Tizen::Web;\r
-using namespace Tizen::Web::Controls;\r
-\r
-static const wchar_t* IDB_BTN_BACK = L"I01_icon_Back.png";\r
-static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";\r
-static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";\r
-static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";\r
-static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";\r
-static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";\r
-static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";\r
-static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";\r
-static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";\r
-static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";\r
-static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";\r
-static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";\r
-static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";\r
-static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";\r
-static const wchar_t* IDS_APPID = L"AppID";\r
-\r
-const int IDA_BACKBTN_CLICKED = 101;\r
-const int IDA_BOOKMARKBTN_CLICKED = 102;\r
-const int IDA_MOREBTN_CLICKED = 103;\r
-const int IDA_MULTIWINDOWBTN_CLICKED = 104;\r
-const int IDA_NEWWINDOWBTN_CLICKED = 105;\r
-const int IDA_FORWARD_CLICKED = 106;\r
-const int IDA_ADDTOBOOKMARK_CLICKED = 107;\r
-const int IDA_SHARE_CLICKED = 108;\r
-const int IDA_FINDONPAGE_CLICKED = 109;\r
-const int IDA_PRIVATEON_CLICKED = 110;\r
-const int IDA_SETTINGS_CLICKED = 111;\r
-const int IDA_READER_CLOSE_CLICKED = 112;\r
-const int IDA_SMALLFONT_BTN_CLICKED = 113;\r
-const int IDA_LARGEFONT_BTN_CLICKED = 114;\r
-const int IDA_BRIGHTNESS_BTN_CLICKED = 115;\r
-const int IDA_FINDWORD_SEARCH_CLICKED = 201;\r
-const int IDA_FINDWORD_NEXT_CLICKED = 202;\r
-const int IDA_FINDWORD_PREV_CLICKED = 203;\r
-const int IDA_FINDWORD_CLEAR_CLICKED = 204;\r
-const int IDA_FINDWORD_CANCEL_CLICKED = 205;\r
-\r
-const int IDA_COPY_IMAGE_CLICKED = 206;\r
-const int IDA_VIEW_IMAGE_CLICKED = 207;\r
-const int IDA_SAVE_IMAGE_CLICKED = 208;\r
-const int IDA_SHARE_IMAGE_CLICKED = 209;\r
-\r
-const int IDA_COPY_TEXT_CLICKED = 210;\r
-const int IDA_PASTE_TEXT_CLICKED = 211;\r
-const int IDA_FIND_TEXT__CLICKED = 212;\r
-const int IDA_SHARE_TEXT_CLICKED = 213;\r
-const int DEFAULT_PROGRESS_PERCENTAGE = 10;\r
-\r
-const int MainForm::IDA_FORMAT_BITMAP = 500;\r
-const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;\r
-const int MainForm::IDA_FORMAT_TITLE_STRING = 502;\r
-const int MainForm::IDA_FORMAT_URL_STRING = 503;\r
-const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;\r
-\r
-static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;\r
-static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;\r
-static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;\r
-\r
-MainForm::MainForm(void)\r
-{\r
- __pAddressbar = null;\r
- // __pMostVisitedSitesPanel = null;\r
- __pMostVisitedListView = null;\r
- __pFooterPanel = null;\r
- __pHitElementResult = null;\r
- __pWindowInfo = null;\r
- __pWebViewer = null;\r
- __pImageMenu = null;\r
- __pMenu = null;\r
- __pFindWordControl = null;\r
- __pFindWordPanel = null;\r
- __pFindWordBgLabel = null;\r
- __pFindWordEditField = null;\r
- __pFindWordClear = null;\r
- __pFindWordCountLabel = null;\r
- __pFindWordNext = null;\r
- __pFindWordPrev = null;\r
- __previousZoomLevel = 1.0;\r
- __pSaveImage = null;\r
- __currentSearchStr = L"";\r
- __currentSelectedStr = L"";\r
- __maxOccurrances = 0;\r
- __currentWordIndex = 0;\r
- __distanceMoved = 0;\r
- __isLoaded = false;\r
- __inputEventToBeSupressed = false;\r
- __touchPoint1 = Point(-1,-1);\r
- __touchPoint2 = Point(-1,-1);\r
- __pWebReader = null;\r
- // __pReaderPopup = null;\r
- __pReaderData = null;\r
- __pPopUp = null;\r
- __pReaderCloseBtn = null;\r
- __pNewWindowButton = null;\r
- __pMoreButton = null;\r
- __pMultiWindowButton = null;\r
- __pArticleReaderPanel = null;\r
- __pBlankPanel = null;\r
- __pArticleReaderLabel = null;\r
- __webControlHeight = 0;\r
- __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;\r
- __curAddressBarMode = ADDRESSBAR_MODE_INVALID;\r
- __pMostVisitedSites = null;\r
-}\r
-\r
-MainForm::~MainForm(void)\r
-{\r
- SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);\r
-\r
- if(__pAddressbar)\r
- {\r
- __pAddressbar->SetAddressbarEventListener(null);\r
- }\r
- if (__pReaderData != null)\r
- {\r
- delete __pReaderData;\r
- __pReaderData = null;\r
- }\r
-\r
- if (__pPopUp != null)\r
- {\r
- delete __pPopUp;\r
- __pPopUp = null;\r
- }\r
-\r
- if (__pHitElementResult != null)\r
- {\r
- delete __pHitElementResult;\r
- __pHitElementResult = null;\r
- }\r
- String* pSelectedScene = NULL;\r
- Object* pValue = NULL;\r
- MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);\r
- pSelectedScene = (String*) pValue;\r
-\r
- /*if (pSelectedScene != null)\r
- {\r
- delete pSelectedScene;\r
- }\r
- MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/\r
-}\r
-\r
-bool\r
-MainForm::Initialize(void)\r
-{\r
- Construct(L"IDL_FORM");\r
- return true;\r
-}\r
-\r
-result\r
-MainForm::OnInitializing(void)\r
-{\r
- const int WIDTH_CONTEXT_MENU_BUTTON = 336;\r
- const int HEIGHT_CONTEXT_MENU_BUTTON = 72;\r
-\r
- Panel* pFooterPanel = null;\r
-\r
- __pSaveImage = new Image();\r
- __pSaveImage->Construct();\r
-\r
- // Setup back event listener\r
- SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);\r
- SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);\r
- AddOrientationEventListener(*this);\r
- AppLogDebug(" MainForm::OnInitializing ended");\r
- if (__pMostVisitedSites == null)\r
- {\r
- __pMostVisitedSites = new(std::nothrow) ArrayList();\r
- __pMostVisitedSites->Construct();\r
- }\r
- HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);\r
-\r
- __pItemContext= new(std::nothrow) ListContextItem();\r
- __pItemContext->Construct();\r
- Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);\r
- Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);\r
-\r
- if (pBitmapNormal != null && pBitmapPressed != null)\r
- {\r
- __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);\r
- }\r
-\r
- if (pBitmapNormal != null)\r
- {\r
- delete pBitmapNormal;\r
- }\r
-\r
- if (pBitmapPressed != null)\r
- {\r
- delete pBitmapPressed;\r
- }\r
-\r
- return E_SUCCESS;\r
-}\r
-\r
-result\r
-MainForm::InitAddressbar(void)\r
-{\r
- AppLogDebug("MainForm::InitAddressbar entered");\r
-\r
- result r = E_SUCCESS;\r
-\r
- if (__pAddressbar != null)\r
- {\r
- return E_SUCCESS;\r
- }\r
- __pAddressbar = new(std::nothrow) Addressbar();\r
- AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);\r
- r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));\r
- if (r != E_SUCCESS)\r
- {\r
- AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));\r
- return r;\r
- }\r
- __pAddressbar->SetAddressbarEventListener(this);\r
- AddControl(*__pAddressbar);\r
- __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));\r
- SetControlAlwaysOnTop(*__pAddressbar, true);\r
- __adressPanelPosition = __pAddressbar->GetPosition();\r
-\r
- AppLogDebug("MainForm::InitAddressbar exit");\r
-\r
- return E_SUCCESS;\r
-}\r
-\r
-result\r
-MainForm::CreateReaderPanel(void)\r
-{\r
- AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);\r
- result r = E_FAILURE;\r
- WebSetting settings;\r
- Button *pSmallFontBtn = null;\r
- Button *pLargeFontBtn = null;\r
-\r
- __pBlankPanel = new (std::nothrow) Panel();\r
- __pBlankPanel->Construct(L"IDL_BLANK_PANEL");\r
-\r
- __pArticleReaderPanel = new (std::nothrow) Panel();\r
- __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");\r
-\r
- __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));\r
- if (__pReaderCloseBtn)\r
- {\r
- AppLogDebug("CreateReaderPanel() 6");\r
- __pReaderCloseBtn->AddActionEventListener(*this);\r
- __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);\r
- }\r
-\r
- __pWebReader = new (std::nothrow) Web();\r
- __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));\r
-\r
- settings.SetInputStyle(INPUT_STYLE_OVERLAY);\r
- settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());\r
-\r
- r = __pWebReader->SetSetting(settings);\r
- if (IsFailed(r))\r
- AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));\r
-\r
-\r
- __pArticleReaderLabel = new Label();\r
- __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");\r
-\r
- __pBlankPanel->AddControl(*__pArticleReaderLabel);\r
- __pBlankPanel->AddControl(*__pArticleReaderPanel);\r
- AddControl(*__pBlankPanel);\r
-\r
- __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);\r
- __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());\r
- __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());\r
-\r
- __pArticleReaderPanel->AddControl(*__pWebReader);\r
- __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));\r
- Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());\r
- Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());\r
-\r
- if (pBitmap != null && pSrcBitmap != null)\r
- {\r
- pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));\r
- }\r
- __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);\r
-\r
- pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));\r
- if (pSmallFontBtn)\r
- {\r
- pSmallFontBtn->AddActionEventListener(*this);\r
- pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);\r
- }\r
-\r
- pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));\r
- if (pLargeFontBtn)\r
- {\r
- pLargeFontBtn->AddActionEventListener(*this);\r
- pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);\r
- }\r
-\r
-\r
- if (pBitmap != null)\r
- {\r
- delete pBitmap;\r
- pBitmap = null;\r
- }\r
- if (pSrcBitmap != null)\r
- {\r
- delete pSrcBitmap;\r
- pSrcBitmap = null;\r
- }\r
-\r
- SetControlAlwaysOnTop(*__pBlankPanel, true);\r
- //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);\r
- Invalidate(true);\r
-\r
- return E_SUCCESS;\r
-}\r
-\r
-result\r
-MainForm::InitWebControl()\r
-{\r
- AppLogDebug("MainForm::InitWebControl enter");\r
- result r = E_SUCCESS;\r
- AppLogDebug("InitWebControl");\r
-\r
- if (__pAddressbar == null || __pFooterPanel == null)\r
- return E_FAILURE;\r
-\r
- const int Y_WEBCONTROL_POSITION = __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12;\r
- __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();\r
- if (__pMostVisitedListView)\r
- {\r
- __pMostVisitedListView->SetShowState(false);\r
- }\r
- if (__pWebViewer != null)\r
- {\r
- AppLogDebug("Already initialized");\r
- return E_SUCCESS;\r
- }\r
- __pWebViewer = new(std::nothrow) Web();\r
- if(__pWebViewer == NULL)\r
- {\r
- AppLogDebug("Initialization failed");\r
- return E_FAILURE;\r
- }\r
- r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight));\r
-\r
- if (IsFailed(r))\r
- {\r
- AppLogDebug("Web construct failed with %s", GetErrorMessage(r));\r
- return r;\r
- }\r
- else\r
- {\r
- r = AddControl(*__pWebViewer);\r
-\r
- if (IsFailed(r))\r
- {\r
- AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));\r
- return r;\r
- }\r
- __webControlPosition = __pWebViewer->GetPosition();\r
- r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());\r
- if (IsFailed(r))\r
- {\r
- AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));\r
- return r;\r
- }\r
-\r
- __pWebViewer->SetLoadingListener(this);\r
- __pWebViewer->SetWebUiEventListener(this);\r
- __pWebViewer->SetWebKeypadEventListener(this);\r
- __pWebViewer->SetFocus();\r
- __pWebViewer->AddTouchEventListener(*this);\r
-\r
- __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());\r
- __pWebViewer->SetTextSearchListener(this);\r
- }\r
-\r
- __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));\r
- AppLogDebug("MainForm :before return");\r
- Invalidate(true);\r
- AppLogDebug("MainForm::InitWebControl Exit");\r
-\r
- return r;\r
-}\r
-\r
-void\r
-MainForm::SetJavascriptEnabled()\r
-{\r
- WebSetting settings = __pWebViewer->GetSetting();\r
- settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());\r
- __pWebViewer->SetSetting(settings);\r
-}\r
-\r
-void\r
-MainForm::SetImageLoadEnabled()\r
-{\r
- WebSetting settings = __pWebViewer->GetSetting();\r
- settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());\r
- __pWebViewer->SetSetting(settings);\r
-}\r
-\r
-result\r
-MainForm::InitFooter(void)\r
-{\r
- AppLogDebug("MainForm::InitFooter entered");\r
- Button* pBackButton = null;\r
- Button* pBookmarkButton = null;\r
- Button* pMultiWindowButton = null;\r
- Bitmap *pIconBitmap = null;\r
- Bitmap *pBGBitmap = null;\r
- Label *pBGLabel = null;\r
-\r
- if (__pFooterPanel == null)\r
- {\r
- __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));\r
- }\r
-\r
- if (__pFooterPanel == null)\r
- {\r
- return E_FAILURE;\r
- }\r
-\r
- SetControlAlwaysOnTop(*__pFooterPanel, true);\r
-\r
- __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));\r
-\r
- if ( __pMultiWindowButton == NULL )\r
- {\r
- return E_FAILURE;\r
- }\r
-\r
- pBackButton = static_cast< Button* >(GetControl(L"IDC_PAGEBACK_BUTTON", true));\r
-\r
- if ( pBackButton == NULL )\r
- {\r
- return E_FAILURE;\r
- }\r
-\r
- pBookmarkButton = static_cast< Button* >(GetControl(L"IDC_BOOKMARK_BUTTON", true));\r
-\r
- if ( pBookmarkButton == NULL )\r
- {\r
- return E_FAILURE;\r
- }\r
-\r
- __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));\r
-\r
- if ( __pMoreButton == NULL )\r
- {\r
- return E_FAILURE;\r
- }\r
-\r
- __pNewWindowButton = static_cast< Button* >(GetControl(L"IDC_NEW_WINDOW",true));\r
-\r
- if ( __pNewWindowButton == NULL )\r
- {\r
- return E_FAILURE;\r
- }\r
-\r
- if (__pMultiWindowButton != null)\r
- {\r
- Bitmap* pBitmap = null;\r
- Bitmap* pPressedBitmap = null;\r
- String imagePath = "I01_toolbar_icon_windows_manager_0";\r
- String pressedImagePath = "I01_toolbar_icon_windows_manager_0";\r
- int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();\r
- imagePath.Append(totalCount);\r
- imagePath.Append(".png");\r
-\r
- pressedImagePath.Append(totalCount);\r
- pressedImagePath.Append("_press.png");\r
-\r
- pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);\r
- pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);\r
- if ( pBitmap == null )\r
- {\r
- return E_FAILURE;\r
- }\r
-\r
- Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);\r
- if (pBitmap != null)\r
- {\r
- __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);\r
- __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);\r
-\r
- delete pBitmap;\r
- }\r
-\r
- __pMultiWindowButton->AddActionEventListener(*this);\r
- __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);\r
- }\r
-\r
-\r
- if (pBackButton)\r
- {\r
- Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BTN_BACK);\r
- Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BTN_BACK_PRESS);\r
- if (pBitmap != null)\r
- {\r
- // pBitmap->Scale(Dimension(56,56));\r
-\r
- Point startPoint((pBackButton->GetWidth() - pBitmap->GetWidth())/2,(pBackButton->GetHeight() - pBitmap->GetHeight())/2 );\r
- AppLog("startPoint %d,%d pBitmap width height %d %d",startPoint.x,startPoint.y,pBitmap->GetWidth(),pBitmap->GetHeight());\r
- pBackButton->SetNormalBitmap(startPoint, *pBitmap);\r
- pBackButton->SetPressedBitmap(startPoint, *pPressedBitmap);\r
- delete pBitmap;\r
- }\r
- pBackButton->AddActionEventListener(*this);\r
- pBackButton->SetActionId(IDA_BACKBTN_CLICKED);\r
- }\r
-\r
- if (pBookmarkButton)\r
- {\r
- Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_BOOKMARK);\r
- Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_BOOKMARK_PRESS);\r
- if (pBitmap != null)\r
- {\r
- Point startPoint((pBookmarkButton->GetWidth() - pBitmap->GetWidth())/2,(pBookmarkButton->GetHeight() - pBitmap->GetHeight())/2 );\r
- pBookmarkButton->SetNormalBitmap(startPoint, *pBitmap);\r
- pBookmarkButton->SetPressedBitmap(startPoint, *pPressedBitmap);\r
- delete pBitmap;\r
- }\r
- pBookmarkButton->AddActionEventListener(*this);\r
- pBookmarkButton->SetActionId(IDA_BOOKMARKBTN_CLICKED);\r
- }\r
-\r
- if (__pMoreButton)\r
- {\r
- Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);\r
- Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);\r
- if (pBitmap != null)\r
- {\r
- Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );\r
- __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);\r
- __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);\r
-\r
- delete pBitmap;\r
- }\r
- __pMoreButton->AddActionEventListener(*this);\r
- __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);\r
-\r
- }\r
-\r
-\r
- if (__pNewWindowButton)\r
- {\r
- Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_NEW_WINDOW);\r
- Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS);\r
- if (pBitmap != null)\r
- {\r
- Point startPoint((__pNewWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pNewWindowButton->GetHeight() - pBitmap->GetHeight())/2 );\r
- __pNewWindowButton->SetNormalBitmap(startPoint, *pBitmap);\r
- __pNewWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);\r
- delete pBitmap;\r
- }\r
- __pNewWindowButton->AddActionEventListener(*this);\r
- __pNewWindowButton->SetActionId(IDA_NEWWINDOWBTN_CLICKED);\r
- __pNewWindowButton->SetEnabled(true);\r
- // __pNewWindowButton->Invalidate(true);\r
- }\r
-\r
- AppLog("checkingwindow count %d",MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount());\r
-\r
- if (__pNewWindowButton != null && MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount() >= 9)\r
- {\r
- Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTROLBAR_ICON_CREATE_DISABLE);\r
- if (pBitmap != null)\r
- {\r
- Point startPoint = Point((__pNewWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pNewWindowButton->GetHeight() - pBitmap->GetHeight())/2 );\r
- __pNewWindowButton->SetDisabledBitmap(startPoint,*pBitmap);\r
- delete pBitmap;\r
- }\r
- __pNewWindowButton->SetEnabled(false);\r
- }\r
-\r
- // __pFooterPanel->Invalidate(true);\r
- AppLogDebug("MainForm::InitFooter exit");\r
- return E_SUCCESS;\r
-}\r
-\r
-\r
-result\r
-MainForm::InitContextMenu(Point& p)\r
-{\r
- result r = E_SUCCESS;\r
- bool isPrivateBrowsing = false;\r
- Bitmap* pBitmap = null;\r
-\r
- if (__pMenu != null)\r
- {\r
- __pMenu->SetAnchorPosition(p);\r
- __pMenu->Invalidate(true);\r
- return r;\r
- }\r
-\r
- __pMenu = new(std::nothrow) ContextMenu();\r
- r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST);\r
- TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));\r
-\r
- isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();\r
-\r
-\r
- if (isPrivateBrowsing == true)\r
- {\r
- pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);\r
- }\r
- else\r
- {\r
- pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);\r
- }\r
-\r
- if ( pBitmap != NULL)\r
- {\r
- __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"), IDA_PRIVATEON_CLICKED,*pBitmap);\r
- delete pBitmap;\r
- }\r
- r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);\r
- r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);\r
- __pMenu->SetMaxVisibleItemsCount(3);\r
- __pMenu->SetShowState(false);\r
- __pMenu->AddActionEventListener(*this);\r
- SetControlAlwaysOnTop(*__pMenu, true);\r
-\r
- CATCH:\r
- return r;\r
-}\r
-\r
-result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)\r
-{\r
- result r = E_SUCCESS;\r
- ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;\r
-\r
- AppLog("MainForm::InitImageContextMenu clicked on image");\r
- if (__pImageMenu != null)\r
- {\r
- delete __pImageMenu;\r
- __pImageMenu = null;\r
- }\r
-\r
- p.y = p.y + __pAddressbar->GetHeight() + 12;\r
- if(p.y < 100)\r
- {\r
- direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;\r
- }\r
- else\r
- {\r
- direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;\r
- }\r
- __pImageMenu = new (std::nothrow) ContextMenu();\r
- r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);\r
- TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));\r
-\r
- r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);\r
- r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);\r
- r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);\r
- r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_IMAGE_CLICKED);\r
- __pImageMenu->SetMaxVisibleItemsCount(4);\r
- __pImageMenu->AddActionEventListener(*this);\r
- SetControlAlwaysOnTop(*__pImageMenu, true);\r
-\r
- CATCH: return r;\r
-}\r
-\r
-result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)\r
-{\r
- result r = E_SUCCESS;\r
- ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;\r
-\r
- AppLog("MainForm::InitSelectTextContextMenu clicked on text");\r
- if (__pImageMenu != null)\r
- {\r
- delete __pImageMenu;\r
- __pImageMenu = null;\r
- }\r
- p.y = p.y + __pAddressbar->GetHeight() + 12;\r
- if(p.y < 100)\r
- {\r
- direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;\r
- }\r
- else\r
- {\r
- direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;\r
- }\r
- __pImageMenu = new (std::nothrow) ContextMenu();\r
- r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);\r
- TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));\r
-\r
- if(onlyPasteOption == false)\r
- {\r
- r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);\r
- }\r
- if (pasteOption || onlyPasteOption)\r
- {\r
- r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);\r
- }\r
- if(onlyPasteOption == false)\r
- {\r
- r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);\r
- r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);\r
- }\r
-\r
- __pImageMenu->SetMaxVisibleItemsCount(3);\r
- __pImageMenu->AddActionEventListener(*this);\r
- SetControlAlwaysOnTop(*__pImageMenu, true);\r
-\r
- CATCH: return r;\r
-\r
-}\r
-\r
-result\r
-MainForm::InitFindWordPanel(void)\r
-{\r
- result r = E_SUCCESS;\r
- Bitmap *pIconBitmap = null;\r
-\r
- if (__pFindWordPanel != null)\r
- {\r
- AppLogDebug("Findword panel already initialized");\r
- if (__pFindWordBgLabel != null)\r
- {\r
- Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());\r
- if (pBitmap != null)\r
- {\r
- AppLogDebug("InitFindWordPanel: Coming here");\r
- __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);\r
- delete pBitmap;\r
- }\r
- }\r
- return r;\r
- }\r
-\r
- __pFindWordPanel = static_cast<Panel*>(GetControl(L"IDC_FIND_ON_PAGE_PANEL"));\r
- if (__pFindWordPanel == null)\r
- {\r
- AppLogException("There is some problem in the xml file. Please check.");\r
- return E_FAILURE;\r
- }\r
-\r
- __pFindWordControl = new (std::nothrow) Panel();\r
- r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");\r
- if (IsFailed(r))\r
- {\r
- AppLogException("There is some problem in the xml file. Please check.");\r
- return E_FAILURE;\r
- }\r
- __pFindWordPanel->AddControl(*__pFindWordControl);\r
- __pFindWordControl->SetBounds(0,0, __pFindWordPanel->GetWidth(), __pFindWordPanel->GetHeight());\r
- SetControlAlwaysOnTop(*__pFindWordPanel,true);\r
- __pFindWordPanel->SetShowState(false);\r
- __pFindWordPanel->Invalidate(false);\r
-\r
- __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));\r
- if (__pFindWordBgLabel != null)\r
- {\r
- Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));\r
- Rectangle pRect = pPanel1->GetBounds();\r
- pRect.x = pRect.y = 0;\r
- __pFindWordBgLabel->SetBounds(pRect);\r
- Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());\r
- if (pBitmap != null)\r
- {\r
- AppLogDebug("InitFindWordPanel: Coming here");\r
- __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);\r
- delete pBitmap;\r
- }\r
- else\r
- {\r
- AppLogDebug("InitFindWordPanel: shouldn't Come here");\r
- }\r
- }\r
-\r
- Button* pfindWordCancel = null;\r
- pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));\r
- if (pfindWordCancel == null)\r
- {\r
- AppLogException("There is some problem in the xml file. Please check.");\r
- return E_FAILURE;\r
- }\r
- pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);\r
- pfindWordCancel->AddActionEventListener(*this);\r
-\r
- __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));\r
- if (__pFindWordClear == null)\r
- {\r
- AppLogException("There is some problem in the xml file. Please check.");\r
- return E_FAILURE;\r
- }\r
-\r
- __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);\r
- __pFindWordClear->AddActionEventListener(*this);\r
-\r
- __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));\r
- if (__pFindWordNext == null)\r
- {\r
- AppLogException("There is some problem in the xml file. Please check.");\r
- return E_FAILURE;\r
- }\r
-\r
- __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);\r
- __pFindWordNext->AddActionEventListener(*this);\r
-\r
- __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));\r
- if (__pFindWordPrev == null)\r
- {\r
- AppLogException("There is some problem in the xml file. Please check.");\r
- return E_FAILURE;\r
- }\r
-\r
- __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);\r
- __pFindWordPrev->AddActionEventListener(*this);\r
-\r
- __pFindWordNext->SetEnabled(false);\r
- __pFindWordPrev->SetEnabled(false);\r
-\r
- __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));\r
- if (__pFindWordCountLabel == null)\r
- {\r
- AppLogException("There is some problem in the xml file. Please check.");\r
- return E_FAILURE;\r
- }\r
-\r
- __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));\r
- if (__pFindWordEditField == null)\r
- {\r
- AppLogException("There is some problem in the xml file. Please check.");\r
- return E_FAILURE;\r
- }\r
- __pFindWordEditField->AddTextEventListener(*this);\r
- __pFindWordEditField->AddKeypadEventListener(*this);\r
- __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);\r
-\r
- return r;\r
-}\r
-\r
-ListItemBase*\r
-MainForm::CreateItem (int index, int itemWidth)\r
-{\r
- Rectangle listImageRect;\r
- Rectangle pagetTitleRect;\r
- Rectangle pageURLRect;\r
- Rectangle deleteImageRect;\r
- String pageTitle(L"");\r
- String pageURL(L"");\r
- result r = E_SUCCESS;\r
- Bitmap* pListIconImage = null;\r
-\r
-\r
- History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));\r
- if(pHistory == null)\r
- {\r
- return null;\r
- }\r
- AppResource* pAppResource = Application::GetInstance()->GetAppResource();\r
- if ( pAppResource == NULL )\r
- {\r
- return null;\r
- }\r
- ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;\r
-\r
- CustomItem* pItem = new(std::nothrow) CustomItem();\r
- pageTitle = pHistory->GetHistoryTitle();\r
- pageURL = pHistory->GetHistoryUrl();\r
-\r
- if (pageURL.GetLength() == 0)\r
- {\r
- String nourl;\r
- pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);\r
- pageURL = L"<"+ nourl +">";\r
-\r
- }\r
-\r
- Rectangle screenBounds = GetBounds();\r
- if (pItem != null)\r
- {\r
- r = pItem->Construct(Dimension(itemWidth, 128), style);\r
- }\r
- if (IsFailed(r))\r
- {\r
- delete pItem;\r
- return NULL;\r
- }\r
-\r
- if (pHistory->GetFaviconId().GetLength() > 0)\r
- {\r
- String bitmapId = pHistory->GetFaviconId();\r
- Bitmap* pBitmap = FaviconManager::GetInstance()->GetFaviconN(bitmapId);\r
-\r
- if ( pBitmap != NULL)\r
- {\r
- pListIconImage = new Bitmap();\r
- pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));\r
- delete pBitmap;\r
- }\r
- }\r
-\r
- if(pListIconImage == null)\r
- {\r
- pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");\r
- }\r
-\r
- if ( pListIconImage != NULL)\r
- {\r
- listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);\r
- pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);\r
- pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);\r
-\r
-\r
- if (pItem != null && pListIconImage != NULL)\r
- {\r
- pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);\r
- }\r
- }\r
-\r
- if (pageTitle.CompareTo(L"") != 0)\r
- {\r
- if (pItem != null)\r
- {\r
- pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);\r
- }\r
- }\r
-\r
- if (pageURL.CompareTo(L"") != 0)\r
- {\r
- if (pItem != null)\r
- {\r
- pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);\r
- }\r
- }\r
-\r
-\r
- if ( __pItemContext!= NULL)\r
- {\r
- if (pItem != null)\r
- {\r
- pItem->SetContextItem(__pItemContext);\r
- }\r
- }\r
- if( pListIconImage != NULL)\r
- {\r
- delete pListIconImage;\r
- pListIconImage = null;\r
- }\r
-\r
- return pItem;\r
-}\r
-\r
-bool\r
-MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)\r
-{\r
- delete pItem;\r
- return true;\r
-}\r
-\r
-int\r
-MainForm::GetItemCount (void)\r
-{\r
- if(__pMostVisitedSites != null)\r
- {\r
- __pMostVisitedSites->RemoveAll(true);\r
- }\r
- HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);\r
- if(__pMostVisitedSites != null)\r
- {\r
- return __pMostVisitedSites->GetCount();\r
- }\r
- else\r
- return 0;\r
-}\r
-\r
-void\r
-MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)\r
-{\r
- History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));\r
- String url = pHistory->GetHistoryUrl();\r
- HistoryPresentationModel::GetInstance()->DeleteHistory(url);\r
- __pMostVisitedListView->UpdateList();\r
-}\r
-\r
-void\r
-MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)\r
-{\r
- History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));\r
- String url = pHistory->GetHistoryUrl();\r
- if (url != null)\r
- {\r
- LoadUrl(url);\r
- }\r
-}\r
-\r
-void\r
-MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)\r
-{\r
-\r
-}\r
-\r
-result\r
-MainForm::OnTerminating(void)\r
-{\r
- result r = E_SUCCESS;\r
- if(__pItemContext)\r
- {\r
- delete __pItemContext;\r
- }\r
- return r;\r
-}\r
-\r
-void\r
-MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)\r
-{\r
- result r = E_SUCCESS;\r
-\r
- AppLogDebug("Clicked : %d", actionId);\r
- switch (actionId)\r
- {\r
- case IDA_BACKBTN_CLICKED:\r
- {\r
- if (__pWebViewer && __pWebViewer->CanGoBack())\r
- {\r
- __pWebViewer->GoBack();\r
- }\r
- else\r
- {\r
- UiApp* pApp = null;\r
- pApp = UiApp::GetInstance();\r
- if (pApp != null)\r
- {\r
- r = pApp->Terminate();\r
- if (IsFailed(r))\r
- {\r
- AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));\r
- return;\r
- }\r
- }\r
- }\r
- }\r
- break;\r
-\r
- case IDA_FORWARD_CLICKED:\r
- if (__pWebViewer == null)\r
- return;\r
-\r
- if (__pWebViewer->CanGoForward())\r
- {\r
- __pWebViewer->GoForward();\r
- }\r
- __pMenu->SetShowState(false);\r
- __pMenu->Invalidate(false);\r
- break;\r
-\r
- case IDA_FINDONPAGE_CLICKED:\r
- {\r
- AppLogDebug("MainForm::OnActionPerformed findword clicked");\r
- __currentSearchStr.Clear();\r
-\r
- InitFindWordPanel();\r
- __pMenu->SetShowState(false);\r
- __pMenu->Invalidate(false);\r
-\r
- __adressPanelPosition.y = 0;\r
-\r
- if (__pAddressbar != null && __pWebViewer != NULL)\r
- {\r
- __webControlPosition.y = __pAddressbar->GetHeight() - 12;\r
- __pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());\r
- __pAddressbar->Invalidate(true);\r
- __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));\r
- __pWebViewer->Invalidate(true);\r
- }\r
- if (__pWebViewer != null)\r
- {\r
- // releasing the set block\r
- __pWebViewer->ReleaseBlock();\r
- }\r
- ShowFindWordPanel(true);\r
- }\r
- break;\r
- case IDA_PRIVATEON_CLICKED:\r
- {\r
- result r = E_SUCCESS;\r
- int itemIndex = 0;\r
- bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();\r
- Bitmap* pBitmap = null;\r
- if (isPrivateBrowsing == true)\r
- {\r
- pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);\r
- if (IsFailed(r))\r
- {\r
- AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));\r
- return ;\r
- }\r
-\r
- if (__pWebViewer != NULL)\r
- {\r
- __pWebViewer->SetPrivateBrowsingEnabled(false);\r
- }\r
-\r
- SettingPresentationModel::GetInstance()->SetPrivateOn(false);\r
-\r
- if (__pAddressbar != null)\r
- {\r
- __pAddressbar->UpdateFaviconBitmap(false);\r
- }\r
-\r
- }\r
- else\r
- {\r
- pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);\r
- if (IsFailed(r))\r
- {\r
- AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));\r
- return ;\r
- }\r
-\r
- if (__pWebViewer != NULL)\r
- {\r
- __pWebViewer->SetPrivateBrowsingEnabled(true);\r
- }\r
-\r
- SettingPresentationModel::GetInstance()->SetPrivateOn(true);\r
-\r
- if (__pAddressbar != null)\r
- {\r
- __pAddressbar->UpdateFaviconBitmap(true);\r
- }\r
- }\r
-\r
-\r
- itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);\r
- r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);\r
- AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);\r
- __pMenu->Invalidate(true);\r
-\r
- if ( pBitmap != NULL )\r
- {\r
- delete pBitmap;\r
- }\r
-\r
- }\r
- break;\r
- case IDA_SETTINGS_CLICKED:\r
- {\r
-\r
- ArrayList* pArgList = new(std::nothrow) ArrayList();\r
- if (pArgList)\r
- {\r
- pArgList->Construct();\r
- pArgList->Add(*__pWindowInfo);\r
- SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);\r
- }\r
- __pMenu->SetShowState(false);\r
- __pMenu->Invalidate(false);\r
- if (pArgList != null)\r
- {\r
- delete pArgList;\r
- pArgList = null;\r
- }\r
-\r
- }\r
- break;\r
-\r
- case IDA_ADDTOBOOKMARK_CLICKED:\r
- {\r
-\r
- if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)\r
- {\r
- int bookmarkCount=0;\r
- bool exist = false;\r
- String url=L"";\r
- url=__pWindowInfo->pageUrl;\r
- result r = E_SUCCESS;\r
- Bitmap* pBitmap = null;\r
- r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);\r
-\r
- if (IsFailed(r))\r
- {\r
- return;\r
- }\r
- if ( exist == true)\r
- {\r
- String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");\r
- BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);\r
- pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);\r
-\r
- NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);\r
- if (pNotification != null)\r
- {\r
- pNotification->SetText(message);\r
- pNotification->SetPositionDiff(__pFooterPanel->GetHeight());\r
- pNotification->ShowNotification();\r
- }\r
- }\r
- else\r
- {\r
- String title=__pWindowInfo->pageTitle;\r
- String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");\r
- BookmarkData* pBookmark=new (std::nothrow) BookmarkData();\r
-\r
- pBookmark->SetBookmarkTitle(title);\r
- pBookmark->SetUrl(url);\r
- String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);\r
- pBookmark->SetFaviconId(id);\r
- r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);\r
- delete pBookmark;\r
-\r
- NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);\r
- if(pNotification != null)\r
- {\r
- pNotification->SetText(message);\r
- pNotification->SetPositionDiff(__pFooterPanel->GetHeight());\r
- pNotification->ShowNotification();\r
- pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);\r
- }\r
- }\r
- if (pBitmap != null)\r
- {\r
- r = __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);\r
- delete pBitmap;\r
- }\r
- }\r
- __pMenu->Invalidate(true);\r
-\r
- }\r
- break;\r
- case IDA_SHARE_CLICKED:\r
- {\r
- if(__pPopUp != null)\r
- {\r
- delete __pPopUp;\r
- __pPopUp = null;\r
- }\r
- __pPopUp = new(std::nothrow) SharePopup();\r
- __pPopUp->Initialize();\r
- if (__pWindowInfo != null)\r
- {\r
- ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();\r
- pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);\r
- pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);\r
- pShareInfo->SetImageAttached(false);\r
- __pPopUp->RemoveAllShareInfo();\r
- __pPopUp->AddShareInfo(pShareInfo);\r
- }\r
- __pPopUp->SetShowState(true);\r
- __pPopUp->Show();\r
- }\r
- break;\r
- case IDA_BOOKMARKBTN_CLICKED:\r
-\r
- AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");\r
- SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));\r
- break;\r
-\r
- case IDA_MOREBTN_CLICKED:\r
- {\r
- AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");\r
- Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());\r
- AppLog("Anchot pos: %d %d", p.x, p.y);\r
- InitContextMenu(p);\r
- if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)\r
- {\r
- AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");\r
- int bookmarkCount=0;\r
- bool exist = false;\r
- String url=L"";\r
- url=__pWindowInfo->pageUrl;\r
- result r = E_SUCCESS;\r
- Bitmap* pBitmap = null;\r
-\r
- r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);\r
- if (IsFailed(r))\r
- {\r
- AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");\r
- return;\r
- }\r
- if ( exist == true)\r
- {\r
- pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);\r
- }\r
- else\r
- {\r
- pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);\r
- }\r
- AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");\r
-\r
- if (__pMenu->GetItemCount() == 6)\r
- {\r
- r = __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);\r
- }\r
- else\r
- {\r
- r = __pMenu->InsertItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);\r
- }\r
-\r
- if (IsFailed(r))\r
- {\r
- AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));\r
- delete pBitmap;\r
- return ;\r
- }\r
- AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");\r
- if (__pMenu->GetItemCount() != 6)\r
- {\r
- __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);\r
- __pMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);\r
- __pMenu->SetMaxVisibleItemsCount(6);\r
- }\r
- if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)\r
- {\r
- AppLog(" Orientation landscape");\r
- __pMenu->SetMaxVisibleItemsCount(5);\r
- }\r
- else\r
- {\r
- AppLog(" Orientation potrait");\r
- __pMenu->SetMaxVisibleItemsCount(6);\r
- }\r
-\r
- AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");\r
- delete pBitmap;\r
- }\r
- AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");\r
- __pMenu->SetShowState(true);\r
- __pMenu->Invalidate(true);\r
- __pMenu->Show();\r
- }\r
-\r
- break;\r
-\r
- case IDA_MULTIWINDOWBTN_CLICKED:\r
- {\r
- result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));\r
- AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));\r
- }\r
- break;\r
-\r
- case IDA_NEWWINDOWBTN_CLICKED:\r
- {\r
- WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();\r
-\r
- if (pNewWindowInfo == null)\r
- {\r
- return;\r
- }\r
- result r = E_SUCCESS;\r
- SceneManager* pSceneManager = SceneManager::GetInstance();\r
-\r
- if (pSceneManager == NULL)\r
- {\r
- return;\r
- }\r
- ArrayList* pArgList = new(std::nothrow) ArrayList();\r
- if (pArgList == NULL)\r
- {\r
- return;\r
- }\r
- r = pArgList->Construct();\r
- if (r == E_SUCCESS)\r
- {\r
- pArgList->Add(*pNewWindowInfo);\r
- r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);\r
- } \r
- delete pArgList;\r
- pArgList = null;\r
- if (IsFailed(r))\r
- {\r
- AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));\r
- return;\r
- }\r
- }\r
- break;\r
- case IDA_SMALLFONT_BTN_CLICKED:\r
- {\r
- WebSetting setting = __pWebReader->GetSetting();\r
- setting.SetFontSize(15);\r
- __pWebReader->SetSetting(setting);\r
- }\r
- break;\r
- case IDA_LARGEFONT_BTN_CLICKED:\r
- {\r
- WebSetting setting = __pWebReader->GetSetting();\r
- setting.SetFontSize(25);\r
- __pWebReader->SetSetting(setting);\r
- }\r
- break;\r
- case IDA_READER_CLOSE_CLICKED:\r
- {\r
- if (__pArticleReaderPanel != null && __pBlankPanel != null)\r
- {\r
- //__pArticleReaderPanel->SetShowState(false);\r
- //__pArticleReaderPanel->Show();\r
- RemoveControl(*__pBlankPanel);\r
- //RemoveControl(*__pArticleReaderPanel);\r
- __pArticleReaderPanel = null;\r
- __pBlankPanel = null;\r
- __pArticleReaderLabel = null;\r
- }\r
- if (__pAddressbar)\r
- __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);\r
- }\r
- break;\r
- case IDA_FINDWORD_CANCEL_CLICKED:\r
- {\r
- __currentSearchStr = L"";\r
- __currentWordIndex = 0;\r
- __maxOccurrances = 0;\r
- __pFindWordEditField->SetText(L"");\r
- __pFindWordNext->SetEnabled(false);\r
- __pFindWordPrev->SetEnabled(false);\r
- __pFindWordCountLabel->SetText(L"0/0");\r
- __pWebViewer->SearchText(L"aaaabbbbcccc",true);\r
- ShowFindWordPanel(false);\r
- }\r
- break;\r
- case IDA_FINDWORD_SEARCH_CLICKED:\r
- {\r
- __currentSearchStr = __pFindWordEditField->GetText();\r
- if (__currentSearchStr.GetLength() > 0)\r
- {\r
- StartWordSearch();\r
- }\r
- else\r
- {\r
- AppLogDebug("Enter something");\r
- }\r
- }\r
- break;\r
- case IDA_FINDWORD_CLEAR_CLICKED:\r
- {\r
- __pFindWordCountLabel->SetText(L"0/0");\r
- __pFindWordEditField->SetText(L"");\r
- __currentSearchStr = L"aaaaaabbbbbbccccccc";\r
- StartWordSearch();\r
- __pFindWordNext->SetEnabled(false);\r
- __pFindWordPrev->SetEnabled(false);\r
- __pFindWordPanel->Invalidate(true);\r
- }\r
- break;\r
- case IDA_FINDWORD_NEXT_CLICKED:\r
- {\r
- FindNextWord(true);\r
- }\r
- break;\r
- case IDA_FINDWORD_PREV_CLICKED:\r
- {\r
- FindNextWord(false);\r
- }\r
- break;\r
- case IDA_BRIGHTNESS_BTN_CLICKED:\r
- {\r
- AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");\r
- SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));\r
- }\r
- break;\r
- case IDA_COPY_IMAGE_CLICKED:\r
- {\r
- AppLogDebug("IDA_COPY_IMAGE_CLICKED");\r
- AppLogDebug("IDA_COPY_IMAGE_CLICKED");\r
- ClipboardItem item;\r
- const Bitmap* pBitmap = null;\r
- if (__pHitElementResult != null)\r
- {\r
- pBitmap = __pHitElementResult->GetImage();\r
- }\r
-\r
- String resourcePath = App::GetInstance()->GetAppResourcePath();\r
- item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);\r
-\r
- // copying the item to clipboard\r
- Clipboard* pClipboard = Clipboard::GetInstance();\r
- if (pClipboard != null)\r
- {\r
- pClipboard->CopyItem(item);\r
- }\r
- }\r
- break;\r
- case IDA_VIEW_IMAGE_CLICKED:\r
- {\r
- AppLogDebug("IDA_VIEW_IMAGE_CLICKED");\r
- WindowInfo* pNewWindowInfo = null;\r
- if (__pHitElementResult != null)\r
- {\r
- String srcUrl = __pHitElementResult->GetAttributeValue(L"src");\r
- AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());\r
- LoadUrl(srcUrl);\r
-\r
- }\r
- }\r
- break;\r
- case IDA_SAVE_IMAGE_CLICKED:\r
- {\r
- AppLogDebug("IDA_SAVE_IMAGE_CLICKED");\r
- const Bitmap* pSaveBitmap = null;\r
- String imageName = GetImagePath();\r
- AppLog("Content manager image name %ls",imageName.GetPointer());\r
- String imagePath;\r
- imagePath.Clear();\r
- imagePath.Append(imageName);\r
- imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());\r
- AppLog("Content manager image path %ls",imagePath.GetPointer());\r
- if (__pHitElementResult != null)\r
- {\r
- pSaveBitmap = __pHitElementResult->GetImage();\r
- }\r
- ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);\r
-\r
- if(pBuffer)\r
- {\r
- UpdateImageContent(pBuffer, imageName);\r
- delete pBuffer;\r
- NotificationPanel *pNotification = new NotificationPanel(*this);\r
- String msg;\r
- AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);\r
- msg.Append(imagePath);\r
- if (pNotification != null)\r
- {\r
- pNotification->SetText(msg);\r
- pNotification->SetPositionDiff(__pFooterPanel->GetHeight());\r
- pNotification->ShowNotification();\r
- }\r
- }\r
- else\r
- {\r
- int __modalMsgBoxResult;\r
- MessageBox* pMsgBox = new MessageBox();\r
- pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);\r
- pMsgBox->ShowAndWait(__modalMsgBoxResult);\r
- delete pMsgBox;\r
- pMsgBox = null;\r
- __modalMsgBoxResult = 0;\r
- }\r
- }\r
- break;\r
- case IDA_SHARE_IMAGE_CLICKED:\r
- {\r
- AppLogDebug("IDA_SHARE_IMAGE_CLICKED");\r
- if (__pPopUp != null)\r
- {\r
- delete __pPopUp;\r
- __pPopUp = null;\r
- }\r
- __pPopUp = new(std::nothrow) SharePopup();\r
- __pPopUp->Initialize();\r
- if (__pHitElementResult != null)\r
- {\r
- const Bitmap* pSaveBitmap = null;\r
- String imageName = GetImagePath();\r
- AppLog("Content manager image name %ls",imageName.GetPointer());\r
- String imagePath;\r
- imagePath.Clear();\r
- imagePath.Append(imageName);\r
- imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());\r
- AppLog("Content manager image path %ls",imagePath.GetPointer());\r
- if (__pHitElementResult != null)\r
- {\r
- pSaveBitmap = __pHitElementResult->GetImage();\r
- }\r
- __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);\r
-\r
- String srcUrl = __pHitElementResult->GetAttributeValue(L"src");\r
- AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());\r
-\r
- ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();\r
- pShareInfo->SetPageTitle(L"");\r
- pShareInfo->SetPageUrl(srcUrl);\r
- pShareInfo->SetImageAttached(true);\r
- pShareInfo->SetImagePath(imagePath);\r
- __pPopUp->RemoveAllShareInfo();\r
- __pPopUp->AddShareInfo(pShareInfo);\r
- __pPopUp->SetShowState(true);\r
- __pPopUp->Show();\r
- }\r
- }\r
- break;\r
- case IDA_FIND_TEXT__CLICKED:\r
- {\r
- AppLogDebug("MainForm::OnActionPerformed find word clicked");\r
- __currentSearchStr.Clear();\r
- __currentSearchStr.Append(__currentSelectedStr);\r
- InitFindWordPanel();\r
- if(__pMenu != null)\r
- {\r
- __pMenu->SetShowState(false);\r
- __pMenu->Invalidate(false);\r
- }\r
-\r
- __adressPanelPosition.y = 0;\r
-\r
- if (__pAddressbar != null && __pWebViewer != NULL)\r
- {\r
- __webControlPosition.y = __pAddressbar->GetHeight() - 12;\r
- __pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());\r
- __pAddressbar->Invalidate(true);\r
- __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));\r
- __pWebViewer->Invalidate(true);\r
- }\r
-\r
- ShowFindWordPanel(true);\r
- if (__currentSearchStr.GetLength() > 0)\r
- {\r
- StartWordSearch();\r
- }\r
- else\r
- {\r
- AppLogDebug("Enter something");\r
- }\r
-\r
- if (__pWebViewer != null)\r
- {\r
- // releasing the set block\r
- __pWebViewer->ReleaseBlock();\r
- }\r
-\r
- }\r
- break;\r
- case IDA_SHARE_TEXT_CLICKED:\r
- {\r
- AppLogDebug("IDA_SHARE_TEXT_CLICKED");\r
- if(__pPopUp != null)\r
- {\r
- delete __pPopUp;\r
- __pPopUp = null;\r
- }\r
- __pPopUp = new(std::nothrow) SharePopup();\r
- __pPopUp->Initialize();\r
- if (__pHitElementResult != null)\r
- {\r
- ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();\r
- pShareInfo->SetPageTitle(L"");\r
- pShareInfo->SetPageUrl(__currentSelectedStr);\r
- pShareInfo->SetImageAttached(false);\r
- __pPopUp->RemoveAllShareInfo();\r
- __pPopUp->AddShareInfo(pShareInfo);\r
- __pPopUp->SetShowState(true);\r
- __pPopUp->Show();\r
- }\r
- }\r
- break;\r
- case IDA_COPY_TEXT_CLICKED:\r
- {\r
- // need to implement\r
- //__currentSelectedStr\r
- // Sets data to a clip board item\r
- ClipboardItem item;\r
- String resourcePath = App::GetInstance()->GetAppResourcePath();\r
- item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);\r
-\r
- // copying the item to clipboard\r
- Clipboard* pClipboard = Clipboard::GetInstance();\r
- if (pClipboard != null)\r
- {\r
- pClipboard->CopyItem(item);\r
- }\r
- }\r
- break;\r
- case IDA_PASTE_TEXT_CLICKED:\r
- {\r
- Clipboard* pClipboard = Clipboard::GetInstance();\r
-\r
- if(pClipboard == null)\r
- {\r
- return;\r
- }\r
- // Retrieves a latest item\r
- ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);\r
-\r
- if(pItem == null)\r
- {\r
- return;\r
- }\r
- //Gets data from the clipboard item\r
- String* pString = dynamic_cast<String*>(pItem->GetData());\r
-\r
- if (pString != null)\r
- {\r
- String idElement = __pHitElementResult->GetAttributeValue(L"id");\r
- AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());\r
- String script = L"function insertAtCursor(myField, myValue) { if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0'){ var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } insertAtCursor(";\r
- script.Append(idElement);\r
- script.Append(",");\r
- script.Append("\"");\r
- script.Append(*pString);\r
- script.Append("\");");\r
- AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());\r
- String* pStr = __pWebViewer->EvaluateJavascriptN(script);\r
- delete pStr;\r
- }\r
- delete pItem;\r
- }\r
- break;\r
- default:\r
- break;\r
- }\r
-}\r
-\r
-void\r
-MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)\r
-{\r
-\r
- UiApp* pApp = UiApp::GetInstance();\r
- if (pApp == null)\r
- {\r
- return;\r
- }\r
- pApp->Terminate();\r
-}\r
-\r
-void\r
-MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,\r
- const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)\r
-{\r
- String* pSelectedScene = NULL;\r
- Object* pValue = NULL;\r
- String* pUrl = null;\r
- MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);\r
- pSelectedScene = (String*) pValue;\r
-\r
- if (pSelectedScene != null)\r
- {\r
- delete pSelectedScene;\r
- }\r
- MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);\r
- String* selectedSceneID = new(std::nothrow) String(currentSceneId);\r
- AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());\r
- AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());\r
-\r
- // setting the current scene ID\r
- MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);\r
-\r
- MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);\r
-\r
- if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)\r
- {\r
- __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));\r
- if(__pWindowInfo == null)\r
- return;\r
- // if(__pWindowInfo == null)\r
- {\r
- pUrl = dynamic_cast< String* >(pArgs->GetAt(1));\r
- }\r
- }\r
- else if ( pArgs != null && pArgs->GetCount() == 1)\r
- {\r
- __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));\r
- }\r
-\r
- InitFooter();\r
- InitAddressbar();\r
-\r
- if(__pWebViewer != null)\r
- {\r
- __pWebViewer->Resume();\r
- }\r
-\r
- if(pUrl != null && pUrl->GetLength() > 0)\r
- {\r
- LoadUrl(*pUrl);\r
- }\r
- else if(__pWindowInfo != null)\r
- {\r
- if(__pWindowInfo->pageUrl.GetLength() > 0 && previousSceneId != IDSCN_MULTIPLE_WINDOW && previousSceneId != IDSCN_MULTIPLE_WINDOW_GRID && previousSceneId != IDSCN_BOOKMARK_VIEW && previousSceneId != IDSCN_SETTINGS && previousSceneId != IDSCN_MAIN_VIEW)\r
- {\r
- LoadUrl(__pWindowInfo->pageUrl);\r
- }\r
- else if (__pWindowInfo->isJavascriptInitiated == true)\r
- {\r
- AppLog("Called");\r
- InitWebControl();\r
- __pWindowInfo->pCurrentWeb = __pWebViewer;\r
- }\r
- }\r
-\r
- String homePage = SettingPresentationModel::GetInstance()->GetHomepage();\r
- AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());\r
- if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)\r
- {\r
- InitMostVisitedSitesView(GetOrientationStatus());\r
- }\r
-\r
- if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))\r
- {\r
- String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));\r
-\r
- if (pBookmarkUrl == null)\r
- return;\r
- AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());\r
- __pAddressbar->SetUrl(*pBookmarkUrl);\r
-\r
- if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)\r
- __pWebViewer->LoadUrl(*pBookmarkUrl);\r
- delete pBookmarkUrl;\r
- }\r
-\r
- bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();\r
- Bitmap* pBitmap = null;\r
- if (isPrivateBrowsing == true)\r
- {\r
- pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);\r
-\r
- if (__pWebViewer != null)\r
- {\r
- __pWebViewer->SetPrivateBrowsingEnabled(true);\r
- }\r
-\r
- if (__pAddressbar != null)\r
- {\r
- __pAddressbar->UpdateFaviconBitmap(true);\r
- }\r
-\r
- }\r
- else\r
- {\r
- pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);\r
-\r
- if (__pWebViewer != null)\r
- {\r
- __pWebViewer->SetPrivateBrowsingEnabled(false);\r
- }\r
-\r
- if (__pAddressbar != null)\r
- {\r
- __pAddressbar->UpdateFaviconBitmap(false);\r
- }\r
- }\r
-\r
- if (__pMenu != null && __pMenu->GetItemCount() == 3)\r
- {\r
- __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);\r
- }\r
- else if (__pMenu != null )\r
- {\r
- __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);\r
- }\r
-\r
- if (pBitmap != null)\r
- {\r
- delete pBitmap;\r
- }\r
-\r
- AppLog("ABC: OnSceneActivatedN started exit");\r
-\r
-}\r
-\r
-void\r
-MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,\r
- const Tizen::Ui::Scenes::SceneId& nextSceneId)\r
-{\r
- Canvas* pWebCanvas = null;\r
- if (__pWebViewer != null)\r
- {\r
- pWebCanvas = __pWebViewer->GetCanvasN();\r
- __pWebViewer->Pause();\r
-\r
- }\r
- if (pWebCanvas == null)\r
- {\r
- return;\r
- }\r
- if (__pWindowInfo != null)\r
- {\r
- if (__pWindowInfo->pWebCanvasBitmap != null)\r
- {\r
- delete __pWindowInfo->pWebCanvasBitmap;\r
- }\r
- __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();\r
- result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));\r
- AppLog("Bitmap Construction result %s",GetErrorMessage(r));\r
- }\r
- Bitmap* pBitmap = GetCapturedBitmapN();\r
- AppLog("Coming here");\r
- Canvas* pCanvas = new(std::nothrow) Canvas();\r
- pCanvas->Construct(GetClientAreaBounds());\r
- if(pBitmap != null)\r
- {\r
- pCanvas->DrawBitmap(Point(0,0),*pBitmap);\r
- delete pBitmap;\r
- }\r
- if(__pWebViewer != null && __pWindowInfo != null)\r
- pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);\r
-\r
- WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();\r
- WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));\r
- delete pCanvas;\r
- AppLog("Coming here");\r
-}\r
-\r
-bool\r
-MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,\r
- const Tizen::Base::String& realm,\r
- const Tizen::Web::Controls::AuthenticationChallenge& authentication)\r
-{\r
- return false;\r
-}\r
-\r
-void\r
-MainForm::OnHttpAuthenticationCanceled(void)\r
-{\r
-}\r
-\r
-void\r
-MainForm::OnLoadingStarted(void)\r
-{\r
- AppLogDebug("MainForm::OnLoadingStarted entered");\r
- __isLoaded = true;\r
- if(__pAddressbar == NULL)\r
- {\r
- return;\r
- }\r
- String url = __pWebViewer->GetUrl();\r
- if(url.Contains(IDS_TIZEN_SERVICE))\r
- {\r
- String appId;\r
- String delim(L":;");\r
-\r
- // Creates a StringTokenizer instance\r
- StringTokenizer strTok(url, delim);\r
-\r
- int count = strTok.GetTokenCount(); // count == 4\r
-\r
- ArrayList *pArgList = new(std::nothrow) ArrayList();\r
- pArgList->Construct();\r
- String token;\r
- String key;\r
- String value;\r
- while (strTok.HasMoreTokens())\r
- {\r
- AppLog("Token: %ls", token.GetPointer());\r
- strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code\r
- if(token.Contains(IDS_APPID))\r
- {\r
- token.SubString(6, appId);\r
- AppLog("AppID:%ls", appId.GetPointer());\r
- }\r
- else if(token.Contains("="))\r
- {\r
- pArgList->Add(* new(std::nothrow) String(token));\r
- }\r
- }\r
- if(appId != "")\r
- {\r
- AppManager::GetInstance()->LaunchApplication(appId, pArgList);\r
- return;\r
- }\r
- }\r
- Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();\r
- __pAddressbar->SetFaviconBitmap(*pBitmap);\r
- delete pBitmap;\r
- if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))\r
- {\r
- // updating the address bar position with respect to web control\r
- __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label\r
- __distanceMoved = 0;\r
- MoveUiControls();\r
- }\r
-\r
- __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);\r
- if (__pWebViewer)\r
- {\r
- AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());\r
- __pAddressbar->SetUrl(__pWebViewer->GetUrl());\r
- if (__pWindowInfo != NULL)\r
- {\r
- __pWindowInfo->pageUrl = __pWebViewer->GetUrl();\r
- }\r
- __pAddressbar->Invalidate(true);\r
- }\r
-\r
-}\r
-\r
-void\r
-MainForm::OnLoadingCanceled(void)\r
-{\r
-\r
-}\r
-\r
-\r
-void\r
-MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)\r
-{\r
- if(__pAddressbar != null)\r
- {\r
- OnAddressBarKeypadOpened(*__pAddressbar);\r
- }\r
-}\r
-\r
-void\r
-MainForm::OnKeypadClosed(Tizen::Ui::Control& source){\r
- if(__pAddressbar != null)\r
- {\r
- OnAddressBarKeypadClosed(*__pAddressbar);\r
- }\r
-}\r
-\r
-void\r
-MainForm::OnLoadingErrorOccurred(LoadingErrorType error,\r
- const Tizen::Base::String& reason)\r
-{\r
- AppLogDebug("Error: %d, %ls", error, reason.GetPointer());\r
-}\r
-\r
-void\r
-MainForm::OnLoadingCompleted(void)\r
-{\r
- DateTime date;\r
- result r = E_SUCCESS;\r
-\r
- if (__pWebViewer == null)\r
- {\r
- return;\r
- }\r
-\r
- if (__pAddressbar == null)\r
- {\r
- return;\r
- }\r
- if (__pWebViewer->CanGoForward())\r
- {\r
- __pAddressbar->SetForwardButtonEnabled(true);\r
- }\r
- else\r
- {\r
- __pAddressbar->SetForwardButtonEnabled(false);\r
- }\r
-\r
- if (__pWebViewer->CanGoBack())\r
- {\r
- __pAddressbar->SetBackButtonEnabled(true);\r
- }\r
- else\r
- {\r
- __pAddressbar->SetBackButtonEnabled(false);\r
- }\r
- if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)\r
- {\r
- __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);\r
-\r
- __pAddressbar->UpdateProgress(0);\r
- }\r
-\r
- AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());\r
- bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();\r
- if (isPrivateBrowsing == false)\r
- {\r
- History* pHistory = new(std::nothrow) History;\r
-\r
- HistoryPresentationModel::GetCurrentDateTime(date);\r
- if(__pWindowInfo)\r
- {\r
- pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);\r
- AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());\r
-\r
- pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);\r
- AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());\r
- }\r
- pHistory->SetVisitedTime(date);\r
- String id = "";\r
- if(__pWindowInfo)\r
- id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);\r
- pHistory->SetFaviconId(id);\r
- Canvas* pCanvas = __pWebViewer->GetCanvasN();\r
- Bitmap* pBitmap = new(std::nothrow) Bitmap();\r
- if ( pCanvas != null && pCanvas != null && pBitmap != null)\r
- {\r
- pBitmap->Construct(*pCanvas, pCanvas->GetBounds());\r
- pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));\r
- pHistory->SetThumbnail(pBitmap);\r
- }\r
- HistoryPresentationModel::GetInstance()->SaveHistory(*pHistory);\r
- delete pHistory;\r
- }\r
- else\r
- {\r
- return;\r
- }\r
- if (__pWindowInfo && __pWindowInfo->faviconUrl == "")\r
- {\r
- // temperary fixed (webpage can be not loaded)\r
- UpdateFavicon();\r
- }\r
-}\r
-\r
-void\r
-MainForm::OnEstimatedProgress(int progress)\r
-{\r
- AppLogDebug("MainForm::OnEstimatedProgress entered");\r
- if (progress < DEFAULT_PROGRESS_PERCENTAGE)\r
- progress = DEFAULT_PROGRESS_PERCENTAGE;\r
- if(__pAddressbar)\r
- __pAddressbar->UpdateProgress(progress);\r
-}\r
-\r
-void\r
-MainForm::OnUrlSubmitted(Addressbar& addBar)\r
-{\r
- String url = addBar.GetUrl();\r
- LoadUrl(url);\r
- __pFooterPanel->SetShowState(true);\r
- __pFooterPanel->Invalidate(true);\r
- RequestRedraw(true);\r
-}\r
-\r
-void\r
-MainForm::LoadUrl(String& url)\r
-{\r
- AppLogDebug("MainForm::LoadUrl enter");\r
-\r
- if (url.CompareTo(L"") == 0)\r
- {\r
- return;\r
- }\r
- if(__pFooterPanel != null)\r
- {\r
- __pFooterPanel->SetShowState(true);\r
- __pFooterPanel->Invalidate(true);\r
- }\r
- InitWebControl();\r
-\r
- bool ret = false;\r
- bool flag = false;\r
-\r
- String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");\r
- 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)\r
-\r
- RegularExpression firstRegex;\r
- RegularExpression secondRegex;\r
-\r
- firstRegex.Construct(firstPattern, REGEX_CASELESS);\r
- secondRegex.Construct(secondPattern, REGEX_CASELESS);\r
-\r
- // Match\r
- ret = firstRegex.Match(url, false); // This returns true value\r
- flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)\r
-\r
- if (ret == true && __pWebViewer != null)\r
- {\r
- __pWebViewer->LoadUrl(url);\r
- }\r
- else if(__pWebViewer != null)\r
- {\r
- String tempUrl = L"http://";\r
- tempUrl.Append(url);\r
-\r
- if (flag == true)\r
- {\r
- __pWebViewer->LoadUrl(tempUrl);\r
- }\r
- else\r
- {\r
- __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(url));\r
- }\r
- }\r
- if (__pAddressbar != null)\r
- {\r
- __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);\r
- }\r
-\r
- AppLogDebug("MainForm::LoadUrl exit");\r
-\r
- return;\r
-\r
-}\r
-\r
-void\r
-MainForm::OnStopClicked(Addressbar& addBar)\r
-{\r
- AppLogDebug("MainForm::OnStopClicked called");\r
- if (__pWebViewer)\r
- {\r
- __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);\r
- __pWebViewer->StopLoading();\r
- RequestRedraw(true);\r
- }\r
-}\r
-\r
-void\r
-MainForm::OnReaderClicked(const Addressbar& addBar)\r
-{\r
- int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;\r
-\r
- CreateReaderPanel();\r
- AppLogDebug("MainScene::OnReaderClicked entered");\r
-\r
-\r
- /*if (__pArticleReaderPanel)\r
- {\r
- AppLogDebug("showstate true for reader panel");\r
- __pArticleReaderPanel->SetShowState(true);\r
- __pArticleReaderPanel->Show();\r
- }*/\r
- int xPos = __pArticleReaderPanel->GetX();\r
- int yPos = __pArticleReaderPanel->GetY();\r
- AppLog("OnReaderClicked() xPos = %d",xPos);\r
- AppLog("OnReaderClicked() yPos = %d",yPos);\r
-\r
- if (__pReaderData == null)\r
- {\r
- return;\r
- }\r
-\r
- String loadData = L"<html>\\r
- <head>\\r
- <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\\r
- <style>\\r
- h1\\r
- {\\r
- font-weight:bold;\\r
- background-color: transparent;\\r
- }\\r
- div\\r
- {\\r
- display: block;\\r
- }\\r
- p\\r
- {\\r
- display: block; \\r
- }\\r
- img\\r
- {\\r
- margin-left:auto;\\r
- margin-right:auto;\\r
- }\\r
- \\r
- \\r
- </style>\\r
- </head>\\r
- <body style='width:'";\r
- loadData.Append(bodyWidth);\r
- loadData.Append(L"px'>");\r
- AppLogDebug("data->GetLength %d",__pReaderData->GetLength());\r
- loadData.Append(*__pReaderData);\r
- loadData.Append(L"</body></html>");\r
-\r
- ByteBuffer buf ;\r
- buf.Construct(loadData.GetLength());\r
- AppLogDebug("data->GetLength %d",loadData.GetLength());\r
- for (int z=0;z<loadData.GetLength();z++)\r
- {\r
- mchar b;\r
- loadData.GetCharAt(z,b);\r
- buf.SetByte((byte)b);\r
- }\r
-\r
- buf.Flip();\r
- if (__pWebReader != null)\r
- {\r
- __pWebReader->LoadData(L"",buf,L"text/html");\r
- AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));\r
- }\r
- else\r
- {\r
- AppLogDebug("cannot LoadData __pWebReader is null");\r
- }\r
-\r
-}\r
-\r
-void\r
-MainForm::OnBackClicked(const Addressbar& addBar)\r
-{\r
- if (__pWebViewer == null)\r
- return;\r
-\r
- if (__pWebViewer->CanGoBack())\r
- {\r
- __pWebViewer->GoBack();\r
- }\r
-\r
-}\r
-\r
-void\r
-MainForm::OnForwardClicked(const Addressbar& addBar)\r
-{\r
- if (__pWebViewer == null)\r
- return;\r
-\r
- if (__pWebViewer->CanGoForward())\r
- {\r
- __pWebViewer->GoForward();\r
- }\r
-}\r
-\r
-void\r
-MainForm::OnAddressCancelledClicked(const Addressbar& addBar)\r
-{\r
- __pFooterPanel->SetShowState(true);\r
- __pFooterPanel->Invalidate(false);\r
-}\r
-\r
-void\r
-MainForm::OnAddressBarModeChanged(const Addressbar& addBar)\r
-{\r
- __prevAddressBarMode = __curAddressBarMode;\r
-\r
- if (__pAddressbar != null)\r
- {\r
- __curAddressBarMode = __pAddressbar->GetAddressbarMode();\r
- }\r
-\r
- if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)\r
- {\r
- __adressPanelPosition.y = 0;\r
- if (__pAddressbar != null)\r
- {\r
- __webControlPosition.y = __pAddressbar->GetHeight() - 12;\r
- __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));\r
- __pAddressbar->Invalidate(true);\r
- }\r
- if (__pWebViewer != null)\r
- {\r
- __pWebViewer->StopLoading();\r
-\r
- }\r
-\r
- }\r
- if (__pWebViewer != null)\r
- {\r
- if(__pFooterPanel->GetShowState() == false)\r
- __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height));\r
- else\r
- __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));\r
- __pWebViewer->Invalidate(true);\r
- }\r
-}\r
-\r
-void\r
-MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar)\r
-{\r
-\r
- if(__pFooterPanel != null)\r
- {\r
- String homePage = SettingPresentationModel::GetInstance()->GetHomepage();\r
- if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)\r
- {\r
- InitMostVisitedSitesView(GetOrientationStatus());\r
- }\r
- __pFooterPanel->SetShowState(true);\r
- __pFooterPanel->Invalidate(false);\r
- }\r
-\r
-\r
-\r
- //AppLogDebug("MainForm::OnAddressBarKeypadClosed enterd");\r
-\r
- if (__pWebViewer != null && __pFooterPanel != null)\r
- {\r
- AppLog("MainForm::OnAddressBarKeypadClosed GetClientAreaBounds().height %d ", GetClientAreaBounds().height);\r
- __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();\r
-\r
- if(__pFooterPanel->GetShowState() == false)\r
- __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height));\r
- else\r
- __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));\r
- __pWebViewer->Invalidate(false);\r
- //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));\r
- }\r
- if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)\r
- __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));\r
-\r
-}\r
-\r
-void\r
-MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)\r
-{\r
- __pFooterPanel->SetShowState(false);\r
- __pFooterPanel->Invalidate(false);\r
-}\r
-\r
-void\r
-MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)\r
-{\r
- __pFooterPanel->SetShowState(false);\r
- __pFooterPanel->Invalidate(false);\r
-}\r
-\r
-void\r
-MainForm::OnPageTitleReceived(const Tizen::Base::String& title)\r
-{\r
- if (__pWindowInfo)\r
- {\r
- __pWindowInfo->pageTitle = title;\r
- if (__pWebViewer != null)\r
- {\r
- __pWindowInfo->pageUrl = __pWebViewer->GetUrl();\r
- }\r
- }\r
- if (__pAddressbar != null && __pWebViewer != null)\r
- {\r
- __pAddressbar->SetUrl(__pWebViewer->GetUrl());\r
- __pAddressbar->UpdateFaviconBitmap(SettingPresentationModel::GetInstance()->GetPrivateOn());\r
- __pAddressbar->Invalidate(true);\r
- }\r
-\r
-}\r
-\r
-void\r
-MainForm::UpdateFavicon(void)\r
-{\r
- bool urlImageType = false;\r
- String *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();");\r
- Bitmap* pBitmap = null;\r
-\r
- if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)\r
- {\r
- if (__pWindowInfo != null)\r
- {\r
- Uri url;\r
- url.SetUri(*tempPath);\r
- if (url.GetHost().GetLength() == 0)\r
- {\r
- Uri webUrl;\r
- webUrl.SetUri(__pWebViewer->GetUrl());\r
- result r = url.SetHost(webUrl.GetHost());\r
- if(IsFailed(r))\r
- {\r
- delete tempPath;\r
- return;\r
- }\r
- }\r
- if (url.GetScheme().GetLength() == 0)\r
- {\r
- Uri webUrl;\r
- webUrl.SetUri(__pWebViewer->GetUrl());\r
- url.SetScheme(webUrl.GetScheme());\r
- }\r
- __pWindowInfo->faviconUrl = url.ToString();\r
-\r
- pBitmap = __pWebViewer->GetFaviconN();\r
-\r
- if (pBitmap != null)\r
- {\r
- if (__pWindowInfo->pFavicon != NULL)\r
- {\r
- // delete __pWindowInfo->pFavicon;\r
- __pWindowInfo->pFavicon = null;\r
- }\r
- __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();\r
- __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));\r
- //bool isPrivateBrowsing = __pWebViewer->IsPrivateBrowsingEnabled();\r
-\r
- __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);\r
-\r
- FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);\r
- }\r
- else if(__pWindowInfo->pFavicon != null)\r
- {\r
- __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);\r
- }\r
- else\r
- {\r
- __pAddressbar->SetFaviconBitmap(*FaviconManager::GetInstance()->GetDefaultFaviconN());\r
- }\r
-\r
- AppLogDebug("Favicon download requested: url: %ls", url.ToString().GetPointer());\r
- }\r
- delete tempPath;\r
- }\r
- else\r
- {\r
- delete tempPath;\r
- AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));\r
- }\r
-\r
-}\r
-\r
-\r
-bool\r
-MainForm::OnLoadingRequested(const Tizen::Base::String& url,\r
- Tizen::Web::Controls::WebNavigationType type)\r
-{\r
- // when load new page if find word panel is open its show state is false\r
- ShowFindWordPanel(false);\r
-\r
- Uri uriInfo;\r
- uriInfo.SetUri(url);\r
-\r
- if(url.Contains(IDS_TIZEN_SERVICE))\r
- {\r
- String appId;\r
- String delim(L":;");\r
-\r
- // Creates a StringTokenizer instance\r
- StringTokenizer strTok(url, delim);\r
-\r
- int count = strTok.GetTokenCount(); // count == 4\r
-\r
- ArrayList *pArgList = new(std::nothrow) ArrayList();\r
- pArgList->Construct();\r
- String token;\r
- String key;\r
- String value;\r
- while (strTok.HasMoreTokens())\r
- {\r
- AppLog("Token: %ls", token.GetPointer());\r
- strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code\r
- if(token.Contains(IDS_APPID))\r
- {\r
- token.SubString(6, appId);\r
- AppLog("AppID:%ls", appId.GetPointer());\r
- }\r
- else if(token.Contains("="))\r
- {\r
- pArgList->Add(* new(std::nothrow) String(token));\r
- }\r
- }\r
- if(appId != "")\r
- {\r
- DateTime dateTime;\r
- SystemTime::GetCurrentTime(dateTime);\r
- dateTime.AddSeconds(1);\r
- String condition = "DateTime='" + dateTime.ToString() + "'";\r
- result r = AppManager::GetInstance()->LaunchApplication(appId, pArgList, AppManager::LAUNCH_OPTION_DEFAULT);\r
- AppLog("Launch res: %s", GetErrorMessage(r));\r
- return true;\r
- }\r
- }\r
-\r
- if (__pWebViewer && __pAddressbar)\r
- {\r
- AppLog("__pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());\r
- __pAddressbar->SetUrl(__pWebViewer->GetUrl());\r
- __pAddressbar->UpdateProgress(DEFAULT_PROGRESS_PERCENTAGE);\r
-\r
- if (__pWindowInfo)\r
- {\r
- __pWindowInfo->pageTitle = CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK");\r
- __pWindowInfo->pageUrl = __pWebViewer->GetUrl();\r
- __pWindowInfo->faviconUrl = "";\r
- __pWindowInfo->faviconFilePath = "";\r
-\r
- if (__pWindowInfo->pFavicon != NULL)\r
- {\r
- // delete __pWindowInfo->pFavicon;\r
- __pWindowInfo->pFavicon = null ;\r
- }\r
- __pWindowInfo->pFavicon = FaviconManager::GetInstance()->GetDefaultFaviconN();\r
-\r
- }\r
-\r
- __pAddressbar->Invalidate(true);\r
- }\r
- return false;\r
-}\r
-\r
-DecisionPolicy\r
-MainForm::OnWebDataReceived(const Tizen::Base::String& mime,\r
- const Tizen::Net::Http::HttpHeader& httpHeader)\r
-{\r
- return Tizen::Web::Controls::WEB_DECISION_CONTINUE;\r
-}\r
-\r
-\r
-void\r
-MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)\r
-{\r
- AppLog("MainForm::OnWebPageBlockSelected");\r
-\r
- if (__pHitElementResult != null)\r
- {\r
- delete __pHitElementResult;\r
- __pHitElementResult = null;\r
- }\r
-\r
- if (__pWebViewer != null)\r
- {\r
- AppLog("MainForm::OnWebPageBlockSelected web not null");\r
- __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);\r
- }\r
-\r
- if (__pHitElementResult == null)\r
- {\r
- return;\r
- }\r
-\r
- if (__pHitElementResult->HasImage() != true)\r
- {\r
- String tagName = __pHitElementResult->GetTagName();\r
- String type = __pHitElementResult->GetAttributeValue("type");\r
-\r
- __currentSelectedStr.Clear();\r
- __currentSelectedStr = __pWebViewer->GetTextFromBlock();\r
-\r
- if ((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0)\r
- {\r
- AppLog("MainForm::OnWebPageBlockSelected show paste option");\r
-\r
- InitSelectTextContextMenu(startPoint,true);\r
- __pImageMenu->SetShowState(true);\r
- __pImageMenu->Show();\r
- __pImageMenu->Invalidate(true);\r
- }\r
- else if (__pHitElementResult->HasUrl() == true || __currentSelectedStr.GetLength() > 0)\r
- {\r
- AppLog("MainForm::OnWebPageBlockSelected no paste option");\r
-\r
- if(__pHitElementResult->GetUrl().GetLength() > 0)\r
- {\r
- __currentSelectedStr.Clear();\r
- __currentSelectedStr = __pHitElementResult->GetUrl();\r
- }\r
- InitSelectTextContextMenu(startPoint,false);\r
- __pImageMenu->SetShowState(true);\r
- __pImageMenu->Show();\r
- __pImageMenu->Invalidate(true);\r
- }\r
-\r
- AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());\r
- AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());\r
- AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());\r
- }\r
-}\r
-\r
-void\r
-MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)\r
-{\r
-\r
-}\r
-\r
-Web*\r
-MainForm::OnWebWindowCreateRequested(void)\r
-{\r
- WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();\r
-\r
- if (pNewWindowInfo == null)\r
- {\r
- return null;\r
- }\r
- result r = E_SUCCESS;\r
- SceneManager* pSceneManager = SceneManager::GetInstance();\r
- if (pSceneManager == NULL)\r
- {\r
- return null;\r
- }\r
- ArrayList* pArgList = new(std::nothrow) ArrayList();\r
- if (pArgList == NULL)\r
- {\r
- return null;\r
- }\r
- r = pArgList->Construct();\r
- if (r == E_SUCCESS)\r
- {\r
- pNewWindowInfo->isJavascriptInitiated = true;\r
- pArgList->Add(*pNewWindowInfo);\r
- r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);\r
- delete pArgList;\r
- if (IsFailed(r))\r
- {\r
- AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));\r
- return null;\r
- }\r
- } else {\r
- delete pArgList;\r
- }\r
-\r
- return pNewWindowInfo->pCurrentWeb;\r
-}\r
-\r
-void\r
-MainForm::RelayoutControls(bool showAddressbar)\r
-{\r
- if (showAddressbar == false)\r
- {\r
- __pAddressbar->SetShowState(false);\r
- __pWebViewer->SetBounds(__pWebViewer->GetX(), 0, __pWebViewer->GetWidth(), __webControlHeight);\r
- __pFooterPanel->SetBounds(__pFooterPanel->GetX(), GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());\r
- }\r
- else\r
- {\r
- __pAddressbar->SetShowState(true);\r
- __pWebViewer->SetBounds(__pWebViewer->GetX(), __pWebViewer->GetY(), __pWebViewer->GetWidth(), __webControlHeight);\r
- __pFooterPanel->SetBounds(__pFooterPanel->GetX(), GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());\r
- }\r
- RequestRedraw(true);\r
-}\r
-\r
-void MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)\r
-{\r
- if (__pFindWordPanel == null)\r
- {\r
- return;\r
- }\r
- if (show == true)\r
- {\r
- InitFindWordPanel();\r
- __pFindWordEditField->SetText(__currentSearchStr);\r
- //__pFindWordCountLabel->SetText(L"");\r
- __pFindWordCountLabel->SetText(L"0/0");\r
-\r
- }\r
-\r
- AppLog("MainForm::ShowFindWordPanel %d",show);\r
- if (show && !isTouchPressed)\r
- {\r
- if (__pFindWordEditField)\r
- __pFindWordEditField->ShowKeypad();\r
- }\r
- else\r
- {\r
- if (__pFindWordEditField)\r
- __pFindWordEditField->HideKeypad();\r
- }\r
-\r
- if (__pAddressbar != null)\r
- {\r
- __pAddressbar->SetShowState(!show);\r
- __pAddressbar->Invalidate(true);\r
- }\r
- if (__pFindWordPanel != null)\r
- {\r
- __pFindWordPanel->SetShowState(show);\r
- __pFindWordPanel->Invalidate(true);\r
- }\r
- Invalidate(true);\r
-}\r
-\r
-void\r
-MainForm::StartWordSearch()\r
-{\r
- //Get the count of occurances of the word in the current page\r
- __maxOccurrances = 0;\r
- __currentWordIndex = 0;\r
-\r
- __pFindWordPrev->SetEnabled(false);\r
- String *pCountStr = null;\r
- __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);\r
- /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");\r
- if (pCountStr != null)\r
- {\r
- Integer::Parse(*pCountStr, 10, __maxOccurrances);\r
- delete pCountStr;\r
- }\r
-\r
- AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);\r
- */\r
-\r
-}\r
-\r
-void MainForm::OnTextFound(int totalCount, int currentOrdinal)\r
-{\r
- AppLog("MainForm::OnTextFound totalCount %d",totalCount);\r
- AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);\r
-\r
-/* if(totalCount == -1 || totalCount == 0)\r
- {\r
- __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),4,__pFindWordCountLabel->GetHeight());\r
- __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());\r
- return;\r
- }\r
- else if(totalCount > 100)\r
- {\r
- __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());\r
- __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());\r
- }\r
-*/\r
- __maxOccurrances = totalCount;\r
- __currentWordIndex = currentOrdinal;\r
-\r
- //Reset the UI controls as per the maxOccurrance value\r
- if (totalCount <= 0)\r
- {\r
- AppLog("Word not found");\r
- //Show error notification to user\r
- __pFindWordNext->SetEnabled(false);\r
- __pFindWordCountLabel->SetText(L"0/0");\r
- __pFindWordNext->Invalidate(false);\r
- __pFindWordPrev->Invalidate(false);\r
- __pFindWordCountLabel->Invalidate(false);\r
- return;\r
- }\r
-\r
- if (totalCount == 1)\r
- {\r
- __pFindWordNext->SetEnabled(false);\r
- }\r
- else\r
- {\r
- __pFindWordNext->SetEnabled(true);\r
- }\r
-\r
- String countStr = L"";\r
- countStr.Append(__currentWordIndex);\r
- countStr.Append(L"/");\r
- countStr.Append(__maxOccurrances);\r
- __pFindWordCountLabel->SetText(countStr);\r
-// __pFindWordCountLabel->SetShowState(true);\r
- __pFindWordCountLabel->Invalidate(false);\r
-\r
- //FindNextWord(true);\r
- //Update the controls\r
- __pFindWordNext->Invalidate(false);\r
- __pFindWordPrev->Invalidate(false);\r
- __pFindWordCountLabel->Invalidate(false);\r
-}\r
-\r
-void\r
-MainForm::FindNextWord(bool next)\r
-{\r
- if (next == true)\r
- {\r
- if (__pWebViewer->SearchText(__currentSearchStr, true) == true)\r
- {\r
- if(__currentWordIndex < __maxOccurrances)\r
- {\r
- __currentWordIndex++;\r
- }\r
- }\r
- }\r
- else\r
- {\r
- if (__pWebViewer->SearchText(__currentSearchStr, false) == true)\r
- {\r
- if(__currentWordIndex > 1)\r
- {\r
- __currentWordIndex--;\r
- }\r
- }\r
- }\r
-\r
- String countStr = L"";\r
- countStr.Append(__currentWordIndex);\r
- countStr.Append(L"/");\r
- countStr.Append(__maxOccurrances);\r
- __pFindWordCountLabel->SetText(countStr);\r
-// __pFindWordCountLabel->SetShowState(true);\r
- __pFindWordCountLabel->Invalidate(false);\r
- if (__currentWordIndex >= __maxOccurrances)\r
- {\r
- __pFindWordNext->SetEnabled(false);\r
- }\r
- else\r
- {\r
- __pFindWordNext->SetEnabled(true);\r
- }\r
- if (__currentWordIndex <= 1)\r
- {\r
- __pFindWordPrev->SetEnabled(false);\r
- }\r
- else\r
- {\r
- __pFindWordPrev->SetEnabled(true);\r
- }\r
- __pFindWordPrev->Invalidate(false);\r
- __pFindWordNext->Invalidate(false);\r
- __pFindWordCountLabel->Invalidate(false);\r
- __pFindWordPanel->Invalidate(true);\r
-}\r
-void\r
-MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)\r
-{\r
- OnAddressBarKeypadOpened(*__pAddressbar);\r
-}\r
-\r
-void\r
-MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)\r
-{\r
-\r
- if (__pWebViewer != null && __pFooterPanel != null)\r
- {\r
- AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);\r
- __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();\r
-\r
- if(__pFooterPanel->GetShowState() == false)\r
- __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height));\r
- else\r
- __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));\r
-\r
- //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));\r
- }\r
-}\r
-\r
-void\r
-MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)\r
-{\r
- OnAddressBarKeypadClosed(*__pAddressbar);\r
-}\r
-\r
-void\r
-MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)\r
-{\r
- Control* temp = const_cast< Control* >(&source);\r
- Header* pHeader = dynamic_cast< Header* >(temp);\r
- if (pHeader != null)\r
- {\r
- //Header double - clicked\r
- AppLog("Header double clicked");\r
- }\r
- if(__pFindWordPanel)\r
- {\r
- AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());\r
- ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);\r
- }\r
-\r
-\r
- AppLog("MainScene::OnTouchDoublePressed");\r
- bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();\r
- if (isReaderEnabled == true)\r
- {\r
- if (__pReaderData)\r
- {\r
- delete __pReaderData;\r
- __pReaderData = null;\r
- }\r
- String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();\r
- filePath.Append(L"data/reader.js");\r
- File file;\r
- char buffer[10];\r
- char buffer2[5];\r
- int i;\r
- int readCnt;\r
- result r = E_SUCCESS;\r
- FileAttributes attr;\r
-\r
- File::GetAttributes(filePath,attr);\r
- // Creates file\r
- r = file.Construct(filePath, L"r+");\r
- if (IsFailed(r))\r
- {\r
- AppLogDebug("File construct failed with %s", GetErrorMessage(r));\r
- return;\r
- }\r
- char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];\r
- if(pScript == null)\r
- {\r
- AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));\r
- return;\r
- }\r
- file.Read(pScript,attr.GetFileSize());\r
-\r
- AppLogDebug("scipt length %d",strlen(pScript));\r
- String strScript = L"";\r
- strScript.Append(pScript);\r
- __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);\r
- if (!__pReaderData)\r
- {\r
- AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));\r
- return;\r
- }\r
- AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());\r
- if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)\r
- {\r
- __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);\r
- }\r
- delete[] pScript;\r
- }\r
-}\r
-\r
-void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)\r
-{\r
- AppLog("MainForm::OnTouchLongPressed");\r
-\r
- if (__pHitElementResult != null)\r
- {\r
- delete __pHitElementResult;\r
- __pHitElementResult = null;\r
- }\r
-\r
- if (__pWebViewer != null)\r
- {\r
- AppLog("MainForm::OnTouchLongPressed web not null");\r
- __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);\r
- }\r
-\r
- if (__pHitElementResult == null)\r
- {\r
- return;\r
- }\r
-\r
- if (__pHitElementResult->HasImage() == true)\r
- {\r
- InitImageContextMenu(currentPosition);\r
- __pImageMenu->SetShowState(true);\r
- __pImageMenu->Show();\r
- __pImageMenu->Invalidate(true);\r
- }\r
- else\r
- {\r
- String tagName = __pHitElementResult->GetTagName();\r
- String type = __pHitElementResult->GetAttributeValue("type");\r
- String value = __pHitElementResult->GetAttributeValue(L"value");\r
- String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");\r
-\r
- __currentSelectedStr.Clear();\r
- __currentSelectedStr = __pWebViewer->GetTextFromBlock();\r
-\r
- if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0)\r
- {\r
- AppLog("MainForm::OnWebPageBlockSelected show paste option");\r
-\r
- InitSelectTextContextMenu(currentPosition,true, true);\r
- __pImageMenu->SetShowState(true);\r
- __pImageMenu->Show();\r
- __pImageMenu->Invalidate(true);\r
- }\r
- __pWebViewer->SetBlockSelectionPosition(currentPosition);\r
-\r
- }\r
- __inputEventToBeSupressed = true;\r
-}\r
-\r
-void\r
-MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)\r
-{\r
- AppLog("MainForm::OnTouchReleased");\r
-\r
- HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);\r
- if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)\r
- {\r
- __pWebViewer->ConsumeInputEvent();\r
- }\r
- if(pHitElement != null)\r
- {\r
- delete pHitElement;\r
- }\r
- __inputEventToBeSupressed = false;\r
-}\r
-\r
-void\r
-MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)\r
-{\r
- int widthContextItem = 0;\r
-\r
- if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)\r
- {\r
-\r
- widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;\r
- }\r
- else\r
- {\r
- widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;\r
- }\r
-\r
- if( __pItemContext != NULL)\r
- {\r
- delete __pItemContext;\r
- __pItemContext = null;\r
-\r
- }\r
-\r
- __pItemContext= new(std::nothrow) ListContextItem();\r
- __pItemContext->Construct();\r
- Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", widthContextItem,HEIGHT_CONTEXT_MENU_BUTTON);\r
- Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", widthContextItem, HEIGHT_CONTEXT_MENU_BUTTON);\r
-\r
- if (pBitmapNormal != null && pBitmapPressed != null)\r
- {\r
- __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);\r
- }\r
-\r
- if (pBitmapNormal != null)\r
- {\r
- delete pBitmapNormal;\r
- }\r
-\r
- if (pBitmapPressed != null)\r
- {\r
- delete pBitmapPressed;\r
- }\r
-\r
-\r
- if (__pFindWordPanel != null && __pFindWordPanel->GetShowState() == true)\r
- {\r
- __pFindWordPanel->SetBounds(0,0,GetClientAreaBounds().width,__pFindWordPanel->GetHeight());\r
- __pFindWordControl->SetBounds(0,0, __pFindWordPanel->GetWidth(), __pFindWordPanel->GetHeight());\r
- __pFindWordControl->SetShowState(true);\r
- __pFindWordControl->Invalidate(true);\r
- __pFindWordPanel->SetShowState(true);\r
- __pFindWordPanel->Invalidate(true);\r
- }\r
-\r
- if (__pWebViewer != null && __pFooterPanel != null)\r
- {\r
- AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);\r
- __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();\r
-\r
- if(__pFooterPanel->GetShowState() == false)\r
- __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height));\r
- else\r
- __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));\r
- __pWebViewer->Invalidate(true);\r
-\r
- //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));\r
- }\r
- if (__pAddressbar != null)\r
- {\r
- __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));\r
- __pAddressbar->SetAddressbarMode(__pAddressbar->GetAddressbarMode());\r
- __pAddressbar->UpdateFaviconBitmap(SettingPresentationModel::GetInstance()->GetPrivateOn());\r
- }\r
- if (__pFindWordBgLabel != null)\r
- {\r
- // __pFindWordBgLabel->SetSize(GetClientAreaBounds().width,GetClientAreaBounds().height);\r
- Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());\r
- if (pBitmap != null)\r
- {\r
- __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);\r
- delete pBitmap;\r
- }\r
- }\r
- if (__pFooterPanel /*&& __pFooterPanel->GetShowState() == true*/)\r
- {\r
- AppLog("__pFooterPanel->GetShowState() is true");\r
- InitFooter();\r
- }\r
- InitAddressbar();\r
-\r
- if(__pMoreButton && __pMenu)\r
- {\r
- Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());\r
- __pMenu->SetAnchorPosition(p);\r
- __pMenu->Invalidate(true);\r
- }\r
-\r
- if (__pFooterPanel)\r
- {\r
- __pFooterPanel->Invalidate(true);\r
- }\r
- String homePage = SettingPresentationModel::GetInstance()->GetHomepage();\r
- if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)\r
- {\r
- InitMostVisitedSitesView(orientationStatus);\r
- }\r
-\r
- if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)\r
- {\r
- __pMostVisitedListView->SetBounds(__pAddressbar->GetX(),__pAddressbar->GetY()+__pAddressbar->GetHeight(),GetClientAreaBounds().width,GetClientAreaBounds().height - __pAddressbar->GetHeight()- __pFooterPanel->GetHeight());\r
- }\r
-\r
- AppLog("OnOrientationChanged 0");\r
- if (__pArticleReaderPanel != null)\r
- {\r
- if (__pArticleReaderPanel->GetShowState() == true)\r
- {\r
- __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());\r
-\r
- if (__pBlankPanel != null)\r
- __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);\r
-\r
- if (__pWebReader != null)\r
- {\r
- __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));\r
- }\r
- Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());\r
- Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());\r
-\r
- if ( pBitmap != null && pSrcBitmap != null)\r
- {\r
- AppLog("CreateReaderPanel ninepatchbitmap found");\r
- pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));\r
- }\r
-\r
- __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));\r
- __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);\r
- if (pBitmap != null)\r
- {\r
- delete pBitmap;\r
- pBitmap = null;\r
- }\r
- if (pSrcBitmap != null)\r
- {\r
- delete pSrcBitmap;\r
- pSrcBitmap = null;\r
- }\r
- }\r
- }\r
- Invalidate(true);\r
- if(__pAddressbar != null)\r
- {\r
- __pAddressbar->OrientationChanged();\r
- }\r
-}\r
-\r
-void\r
-MainForm::OnSettingsChange(int settingvalue)\r
-{\r
- AppLogDebug("MainForm::OnSettingsChange entered");\r
- if (__pWebViewer == null)\r
- {\r
- AppLogDebug("Webviewer is not initialized yet.");\r
- return;\r
- }\r
- if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)\r
- {\r
- WebSetting settings = __pWebViewer->GetSetting();\r
- if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)\r
- {\r
- settings.SetAutoFittingEnabled(true);\r
- }\r
- else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)\r
- {\r
- settings.SetAutoFittingEnabled(false);\r
- }\r
- __pWebViewer->SetSetting(settings);\r
- }\r
- else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)\r
- {\r
- WebSetting settings = __pWebViewer->GetSetting();\r
- settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());\r
- __pWebViewer->SetSetting(settings);\r
- }\r
- else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)\r
- {\r
- WebSetting settings = __pWebViewer->GetSetting();\r
- settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());\r
- __pWebViewer->SetSetting(settings);\r
- }\r
- else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)\r
- {\r
- WebSetting settings = __pWebViewer->GetSetting();\r
- settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());\r
- __pWebViewer->SetSetting(settings);\r
- }\r
- else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)\r
- {\r
- if (__pWebViewer)\r
- {\r
- __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());\r
- }\r
- }\r
-\r
- else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)\r
- {\r
- WebSetting settings = __pWebViewer->GetSetting();\r
- if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)\r
- {\r
- settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);\r
- }\r
- else\r
- {\r
- settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);\r
- }\r
- __pWebViewer->SetSetting(settings);\r
- }\r
- else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)\r
- {\r
- if (__pWebReader)\r
- {\r
- AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());\r
- WebSetting settings = __pWebReader->GetSetting();\r
- settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());\r
- __pWebReader->SetSetting(settings);\r
- }\r
- }\r
-}\r
-\r
-void\r
-MainForm::OnSettingsReset()\r
-{\r
- if (__pWebViewer)\r
- {\r
- __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());\r
- __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());\r
- }\r
-}\r
-\r
-void\r
-MainForm::OnClearCache()\r
-{\r
- result r = E_SUCCESS;\r
-\r
- if (__pWebViewer != NULL)\r
- {\r
- r = __pWebViewer->ClearCache();\r
- if (r == E_SUCCESS)\r
- {\r
- AppLogDebug("Cache cleared success");\r
- }\r
- else\r
- {\r
- AppLogDebug("Cache cleared fail");\r
- }\r
- }\r
-}\r
-\r
-void\r
-MainForm::OnClearCookie()\r
-{\r
- result r = E_SUCCESS;\r
-\r
- if (__pWebViewer != NULL)\r
- {\r
- __pWebViewer->ClearCookie();\r
- }\r
- if (r == E_SUCCESS)\r
- {\r
- AppLogDebug("Cookie cleared success");\r
- }\r
- else\r
- {\r
- AppLogDebug("Cache cleared fail");\r
- }\r
-}\r
-\r
-double\r
-MainForm::findDistance(int x1,int y1,int x2, int y2)\r
-{\r
- int deltaX = Math::Abs(x2 - x1);\r
- int deltaY = Math::Abs(y2 - y1);\r
- double num = deltaX*deltaX + deltaY*deltaY;\r
-\r
- if (num >= 0)\r
- {\r
- double x = num;\r
- int i;\r
- for (i = 0; i < 20; i++)\r
- {\r
- x = (((x*x)+ num)/(2*x));\r
- }\r
- return num;\r
- }\r
- else\r
- {\r
- return 0.0;\r
- }\r
-}\r
-\r
-void\r
-MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)\r
-{\r
- if(__pFindWordPanel)\r
- {\r
- AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());\r
- ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);\r
- }\r
-\r
- Touch touch;\r
- IList* pList = null;\r
- pList = touch.GetTouchInfoListN(source);\r
-\r
- if (pList != null)\r
- {\r
- int count = pList->GetCount();\r
- if (count == 1)\r
- {\r
- TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));\r
- __touchPoint1 = pTouchInfo->position;\r
-\r
- if (__pAddressbar != null)\r
- {\r
- if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)\r
- {\r
- if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)\r
- {\r
- __pAddressbar->SaveAddressbarEditText();\r
- }\r
- __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);\r
- }\r
-\r
- __pAddressbar->Invalidate(true);\r
- }\r
- }\r
- else if (count == 2)\r
- {\r
- AppLogDebug("MainForm::OnTouchPressed count is two");\r
- TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));\r
- __touchPoint1 = pTouchInfo->position;\r
-\r
- pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));\r
- __touchPoint2 = pTouchInfo->position;\r
- }\r
- }\r
- if( pList != NULL)\r
-\r
- {\r
- pList->RemoveAll(true);\r
- delete pList;\r
- }\r
- return;\r
-}\r
-\r
-void\r
-MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)\r
-{\r
- AppLog("Start MainForm::OnTouchMoved MoveUiControls");\r
- if(__pFindWordPanel)\r
- {\r
- AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());\r
- ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);\r
- }\r
-\r
- if (__pFindWordEditField != null)\r
- {\r
- __pFindWordEditField->HideKeypad();\r
- }\r
-\r
- if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)\r
- {\r
- return;\r
- }\r
- static int Count=0;\r
- Touch touch;\r
- IList* pList = null;\r
- pList = touch.GetTouchInfoListN(source);\r
-\r
- if (pList != null)\r
- {\r
- int count = pList->GetCount();\r
- if (count == 1)\r
- {\r
- AppLogDebug("MainForm::OnTouchMoved count 1");\r
- TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));\r
-\r
- if( pTouchInfo == NULL )\r
- {\r
- return;\r
- }\r
- pTouchInfo->position.y += __pWebViewer->GetY();\r
- AppLog("MainForm::OnTouchMoved MoveUiControls %d,%d",pTouchInfo->position.x,pTouchInfo->position.y);\r
-\r
- if (__isLoaded == false)\r
- return;\r
-\r
- __distanceMoved = pTouchInfo->position.y - __touchPoint1.y;\r
- __touchPoint1 = pTouchInfo->position;\r
-\r
- // move the address bar and web control according to distance moved\r
- MoveUiControls();\r
- }\r
- else if (count == 2)\r
- {\r
- AppLogDebug("MainForm::OnTouchMoved count 2");\r
-\r
- if(Count == 10)\r
- {\r
- TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));\r
-\r
- if( pTouchInfo == NULL )\r
- {\r
- return;\r
- }\r
- Point firstPoint = pTouchInfo->position;\r
-\r
- pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));\r
- if( pTouchInfo == NULL )\r
- {\r
- return;\r
- }\r
- Point secondPoint = pTouchInfo->position;\r
-\r
- if (__touchPoint1 == Point(-1,-1) || __touchPoint2 == Point(-1,-1))\r
- {\r
- __touchPoint1 = firstPoint;\r
- __touchPoint2 = secondPoint;\r
- delete pList;\r
- return;\r
- }\r
-\r
- int currX1 = firstPoint.x;\r
- int currY1 = firstPoint.y;\r
- int currX2 = secondPoint.x;\r
- int currY2 = secondPoint.y;\r
-\r
- double prevDist = findDistance(__touchPoint1.x,__touchPoint1.y,__touchPoint2.x,__touchPoint2.y);\r
- double dist = findDistance(currX1, currY1, currX2, currY2);\r
- __distanceMoved = prevDist - dist;\r
-\r
- __touchPoint1 = firstPoint;\r
- __touchPoint2 = secondPoint;\r
- MoveUiControls();\r
- Count = 0;\r
- }\r
- }\r
- Count++;\r
- delete pList;\r
- }\r
-\r
-}\r
-\r
-void\r
-MainForm::MoveUiControls()\r
-{\r
- __adressPanelPosition.y = __adressPanelPosition.y + __distanceMoved;\r
- if(__pAddressbar == NULL)\r
- {\r
- return;\r
- }\r
-\r
- if (__adressPanelPosition.y > 0)\r
- {\r
- __adressPanelPosition.y = 0;\r
- __webControlPosition.y = __pAddressbar->GetHeight() - 12;\r
- }\r
- else if (__adressPanelPosition.y < (0-(__pAddressbar->GetHeight() - 12))) // -12 is for the progress label\r
- {\r
- __adressPanelPosition.y = 0-(__pAddressbar->GetHeight() - 12);\r
- __webControlPosition.y = 0;\r
- }\r
- else\r
- {\r
- __webControlPosition.y = __adressPanelPosition.y + (__pAddressbar->GetHeight() - 12);\r
- }\r
-\r
- AppLogDebug("__adressPanelPosition.y = %d, __webControlPosition.y = %d", __adressPanelPosition.y, __webControlPosition.y);\r
-\r
- __pAddressbar->SetBounds(0,__adressPanelPosition.y,__pAddressbar->GetWidth(),__pAddressbar->GetHeight());\r
- __pAddressbar->Invalidate(false);\r
-\r
- if (__pWebViewer != NULL)\r
- {\r
- if(__pFooterPanel->GetShowState() == true)\r
- __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();\r
- else\r
- __webControlHeight = GetClientAreaBounds().height;\r
- __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));\r
- __pWebViewer->Invalidate(false);\r
- }\r
-}\r
-\r
-void\r
-MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)\r
-{\r
- if (__pFindWordEditField != null)\r
- {\r
- __currentSearchStr = __pFindWordEditField->GetText();\r
- __pFindWordNext->SetEnabled(false);\r
- __pFindWordPrev->SetEnabled(false);\r
- __pFindWordNext->Invalidate(true);\r
- __pFindWordPrev->Invalidate(true);\r
- __pFindWordCountLabel->SetText(L"0/0");\r
- __pFindWordCountLabel->Invalidate(true);\r
- }\r
- AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());\r
- if (__currentSearchStr.GetLength() > 0)\r
- {\r
- StartWordSearch();\r
- }\r
- else\r
- {\r
- __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";\r
- StartWordSearch();\r
- AppLogDebug("Enter something");\r
- }\r
-}\r
-\r
-result\r
-MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)\r
-{\r
- return E_SUCCESS;\r
-\r
-}\r
-\r
-result\r
-MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)\r
-{\r
- if(__pWebViewer != null)\r
- return E_SUCCESS;\r
-\r
- AppLog("MainForm::InitMostVisitedSitesView");\r
- result r = E_SUCCESS;\r
-\r
-\r
- if (__pWebViewer != null && __pMostVisitedListView != null)\r
- {\r
- return E_SUCCESS;\r
- }\r
-\r
- if (__pMostVisitedListView != null)\r
- {\r
- RemoveControl(*__pMostVisitedListView);\r
- }\r
- if(__pMostVisitedSites != null)\r
- {\r
- __pMostVisitedSites->RemoveAll(true);\r
- }\r
-\r
- HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);\r
-\r
- __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();\r
- __pMostVisitedListView = new(std::nothrow) ListView();\r
- if(__pFooterPanel->GetShowState() == false)\r
- {\r
- r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight() , GetClientAreaBounds().width, GetClientAreaBounds().height),true,false);\r
- }\r
- else\r
- {\r
- r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight() , GetClientAreaBounds().width, __webControlHeight),true,false);\r
- }\r
-\r
- if (r != E_SUCCESS)\r
- {\r
- delete __pMostVisitedListView;\r
- AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));\r
- return r;\r
- }\r
- __pMostVisitedListView->SetItemProvider(*this);\r
- __pMostVisitedListView->AddListViewItemEventListener(*this);\r
- __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));\r
- AddControl(*__pMostVisitedListView);\r
- AppLog("__pMostVisitedSitesPanel addcontrol %s",GetErrorMessage(r));\r
- if(__pFooterPanel->GetShowState() == false)\r
- __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() + 14));\r
- else\r
- __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));\r
-\r
- __pMostVisitedListView->UpdateList();\r
-\r
- return E_SUCCESS;\r
-\r
-}\r
-\r
-String\r
-MainForm::GetImagePath(void)\r
-{\r
-\r
- String str;\r
- String formattedTime;\r
- DateTime currentTime;\r
- LocaleManager localManager;\r
- SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);\r
-\r
- localManager.Construct();\r
- Locale locale = localManager.GetSystemLocale();\r
- //Locale locale(LANGUAGE_ENG, COUNTRY_US);\r
-\r
- // Get date formatter\r
- DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);\r
-\r
- if (pTimeFormatter)\r
- {\r
- pTimeFormatter->Format(currentTime, formattedTime);\r
- }\r
-\r
- AppLog("current time stamp is %ls", formattedTime.GetPointer());\r
- String delim(L" :");\r
- StringTokenizer strTok(formattedTime, delim);\r
- String token;\r
- String imageName;\r
- String str1("GMT+00");\r
- while (strTok.HasMoreTokens())\r
- {\r
- strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code\r
- if(token.Equals(str1))\r
- break;\r
- AppLog("token is %ls", token.GetPointer());\r
- imageName.Append(token);\r
- }\r
- return imageName;\r
-\r
-}\r
-\r
-void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)\r
-{\r
- result r = E_FAILURE;\r
- AppLog("Content manager 1");\r
- ContentId contentId;\r
- ContentManager contentManager;\r
- r = contentManager.Construct();\r
- if(IsFailed(r))\r
- {\r
- AppLog("Content manager update content result %s" ,GetErrorMessage(r));\r
- return;\r
- }\r
- Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";\r
- contentPath.Append(imageName);\r
- contentPath.Append(".jpg");\r
- contentId = contentManager.CreateContent(*aBuffer, contentPath);\r
- AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));\r
-}\r
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.1 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//!Internet MainForm class
+/*@file: MainForm.cpp
+ *@brief: The %MainForm provides the common functionalities for the Main View of the Browser including the addressbar,
+ * loading,handling events etc.
+ */
+
+#include <FApp.h>
+#include <FGraphics.h>
+#include <FMedia.h>
+#include <FUi.h>
+#include <FContent.h>
+#include <FShell.h>
+//#include <FShellNotificationManager.h>
+
+#include "IntBookmarkData.h"
+#include "IntBookmarkPresentationModel.h"
+#include "IntCommonLib.h"
+#include "IntFaviconManager.h"
+#include "IntInternetApp.h"
+#include "IntMainForm.h"
+#include "IntSceneRegister.h"
+#include "IntSettingPresentationModel.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Graphics;
+using namespace Tizen::Io;
+using namespace Tizen::Locales;
+using namespace Tizen::Media;
+using namespace Tizen::Shell;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+using namespace Tizen::Content;
+using namespace Tizen::Ui::Scenes;
+using namespace Tizen::System;
+using namespace Tizen::Web;
+using namespace Tizen::Web::Controls;
+
+static const wchar_t* IDB_SEARCH_INPUT_FIELD_BG = L"I01_toolbar_input_field.#.png";
+static const wchar_t* IDB_FINDWORD_INPUT_FIELD_BG = L"I01_toolbar_input_field_findword.#.png";
+static const wchar_t* IDB_BTN_BACK = L"I01_icon_Back.png";
+static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
+static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
+static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
+static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
+static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
+static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
+static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
+static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
+static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
+static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
+static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP =L"00_icon_favorite_off_74x74.png";
+static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"00_icon_favorite_on_74x74.png";
+static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
+static const wchar_t* IDS_APPID = L"AppID";
+static const wchar_t* IDS_KEY = L"key";
+static const wchar_t* IDS_VALUE = L"value";
+static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
+static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
+//static const wchar_t* IDB_ADDRESS_BAR_BACKGROUND = L"I01_toolbar_bg_02.9.png";
+
+const int IDA_BACKBTN_CLICKED = 101;
+const int IDA_BOOKMARKBTN_CLICKED = 102;
+const int IDA_MOREBTN_CLICKED = 103;
+const int IDA_MULTIWINDOWBTN_CLICKED = 104;
+const int IDA_NEWWINDOWBTN_CLICKED = 105;
+const int IDA_FORWARD_CLICKED = 106;
+const int IDA_ADDTOBOOKMARK_CLICKED = 107;
+const int IDA_SHARE_CLICKED = 108;
+const int IDA_FINDONPAGE_CLICKED = 109;
+const int IDA_PRIVATEON_CLICKED = 110;
+const int IDA_SETTINGS_CLICKED = 111;
+const int IDA_READER_CLOSE_CLICKED = 112;
+const int IDA_SMALLFONT_BTN_CLICKED = 113;
+const int IDA_LARGEFONT_BTN_CLICKED = 114;
+const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
+const int IDA_HISTORY_CLICKED = 116;
+const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
+const int IDA_ADD_TO_HOME_CLICKED = 118;
+const int IDA_SAVED_PAGES_CLICKED = 119;
+const int IDA_DESKTOP_VIEW_CLICKED = 120;
+const int IDA_SAVE_CLICKED = 121;
+const int IDA_PRINT_CLICKED = 122;
+
+const int IDA_FINDWORD_SEARCH_CLICKED = 201;
+const int IDA_FINDWORD_NEXT_CLICKED = 202;
+const int IDA_FINDWORD_PREV_CLICKED = 203;
+const int IDA_FINDWORD_CLEAR_CLICKED = 204;
+const int IDA_FINDWORD_CANCEL_CLICKED = 205;
+
+const int IDA_COPY_IMAGE_CLICKED = 206;
+const int IDA_VIEW_IMAGE_CLICKED = 207;
+const int IDA_SAVE_IMAGE_CLICKED = 208;
+const int IDA_SHARE_IMAGE_CLICKED = 209;
+
+const int IDA_COPY_TEXT_CLICKED = 210;
+const int IDA_PASTE_TEXT_CLICKED = 211;
+const int IDA_FIND_TEXT__CLICKED = 212;
+const int IDA_SHARE_TEXT_CLICKED = 213;
+
+const int IDA_GO_BACK = 214;
+const int IDA_GO_FORWARD = 215;
+const int IDA_REFRESH_BTN_CLICKED = 216;
+const int IDA_STOP_BTN_CLICKED = 217;
+const int IDA_CLEAR_URL = 218;
+const int IDA_READER_BTN_CLICKED = 219;
+
+
+const int IDA_HYPERLINK_OPEN_CLICKED = 220;
+const int IDA_HYPERLINK_COPY_LINK_CLICKED = 221;
+const int IDA_HYPERLINK_SAVE_IMAGE_CLICKED = 222;
+const int IDA_HYPERLINK_SHARE_IMAGE_CLICKED = 223;
+
+const int IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED = 224;
+
+const int DEFAULT_PROGRESS_PERCENTAGE = 10;
+
+const int MainForm::IDA_FORMAT_BITMAP = 500;
+const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
+const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
+const int MainForm::IDA_FORMAT_URL_STRING = 503;
+const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
+
+static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
+static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
+static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
+
+static const wchar_t* APPCONTROL_OPERATION_ID_IMAGE_VIEWER = L"http://tizen.org/appcontrol/operation/view";
+MainForm::MainForm(void)
+{
+ __isLongPressedDone = false;
+ __pHistory = null;
+ __pAddressbar = null;
+ // __pMostVisitedSitesPanel = null;
+ __pMostVisitedListView = null;
+ __pFooterPanel = null;
+ __pHitElementResult = null;
+ __pWindowInfo = null;
+ __pWebViewer = null;
+ __pImageMenu = null;
+ __pOptionMenu = null;
+ __pFindWordControl = null;
+ __pFindWordPanelLeftToRight = null;
+ __pFindWordPanelRightToLeft = null;
+ __pFindWordBgLabel = null;
+ __pFindWordBgLabelRightToLeft = null;
+ __pFindWordEditField = null;
+ __pFindWordEditFieldRightToLeft = null;
+ __pFindWordClear = null;
+ __pFindWordClearRightToLeft = null;
+ __pFindWordCountLabel = null;
+ __pFindWordClearRightToLeft = null;
+ __pFindWordNext = null;
+ __pFindWordPrev = null;
+ __previousZoomLevel = 1.0;
+ __pSaveImage = null;
+ __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
+ __displayUrl = L"";
+ __editTextUrl = L"";
+ __currentSearchStr = L"";
+ __currentSelectedStr = L"";
+ __maxOccurrances = 0;
+ __currentWordIndex = 0;
+ __distanceMoved = 0;
+ __isLoaded = false;
+ //__inputEventToBeSupressed = false;
+ __isLoadingData = false;
+ __isLoadingCompleted = false;
+ __progressPercentage = 0;
+ __touchPoint1 = Point(-1,-1);
+ __touchPoint2 = Point(-1,-1);
+ __longPressPoint = Point(-1,-1);
+ __pWebReader = null;
+ // __pReaderPopup = null;
+ __pReaderData = null;
+ __pPopUp = null;
+ __pReaderCloseBtn = null;
+ //__pNewWindowButton = null;
+ __pMoreButton = null;
+ __pMultiWindowButton = null;
+ __pArticleReaderPanel = null;
+ __pBlankPanel = null;
+ __pArticleReaderLabel = null;
+ __webControlHeight = 0;
+ __webControlHeightF = 0;
+ __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
+ __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
+ __pMostVisitedSites = null;
+ __pFooterUrlField = null;
+ __pGoBackBtn = null;
+ __pGoForwardBtn = null;
+ __pRefreshBtn = null;
+ __pProgressbarLabel = null;
+ __pFooterLabel = null;
+ __pStopBtn = null;
+ __pClearBtn = null;
+ __pReaderBtn = null;
+ __isKeypadOpened = false;
+ __fontSize = 44;
+ __pNotification = null;
+}
+
+MainForm::~MainForm(void)
+{
+ SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
+
+ if(__pAddressbar)
+ {
+ __pAddressbar->SetAddressbarEventListener(null);
+ }
+
+ if(__pHistory != null)
+ {
+ delete __pHistory;
+ __pHistory = null;
+ }
+
+ if (__pReaderData != null)
+ {
+ delete __pReaderData;
+ __pReaderData = null;
+ }
+
+ if (__pPopUp != null)
+ {
+ delete __pPopUp;
+ __pPopUp = null;
+ }
+
+ if (__pHitElementResult != null)
+ {
+ delete __pHitElementResult;
+ __pHitElementResult = null;
+ }
+ if(__pOptionMenu)
+ {
+ delete __pOptionMenu;
+ __pOptionMenu = null;
+ }
+
+ String* pSelectedScene = NULL;
+ Object* pValue = NULL;
+ MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
+ pSelectedScene = (String*) pValue;
+
+ /*if (pSelectedScene != null)
+ {
+ delete pSelectedScene;
+ }
+ MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
+}
+
+bool
+MainForm::Initialize(void)
+{
+ Construct(L"IDL_FORM");
+
+// SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_FOOTER);
+ return true;
+}
+
+result
+MainForm::OnInitializing(void)
+{
+ AppLog("get client area width = %d",GetClientAreaBounds().width);
+ AppLog("get client area height = %d",GetClientAreaBounds().height);
+ const int WIDTH_CONTEXT_MENU_BUTTON = 336;
+ const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
+
+ __fontSize = CommonUtil::GetFontSize();
+ Panel* pFooterPanel = null;
+
+ __pSaveImage = new Image();
+ __pSaveImage->Construct();
+
+ // Setup back event listener
+ SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
+ SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
+ AddOrientationEventListener(*this);
+
+ AppLogDebug(" MainForm::OnInitializing ended");
+ if (__pMostVisitedSites == null)
+ {
+ __pMostVisitedSites = new(std::nothrow) ArrayList();
+ __pMostVisitedSites->Construct();
+ }
+ HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
+
+ __pItemContext= new(std::nothrow) ListContextItem();
+ __pItemContext->Construct();
+
+ __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"),true);
+
+
+ __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
+ __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
+ __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
+
+ __pItemContextLandscape= new(std::nothrow) ListContextItem();
+ __pItemContextLandscape->Construct();
+
+ __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), true);
+ __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
+ __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
+ __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
+ SetFormMenuEventListener(this);
+ AppLog("SetFormMenuEventListener result %s",GetErrorMessage(GetLastResult()));
+ return E_SUCCESS;
+}
+
+result
+MainForm::InitAddressbar(void)
+{
+ AppLogDebug("MainForm::InitAddressbar entered");
+
+ result r = E_SUCCESS;
+
+ if (__pAddressbar != null)
+ {
+ return E_SUCCESS;
+ }
+ __pAddressbar = new(std::nothrow) Addressbar();
+ AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
+ r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
+ if (r != E_SUCCESS)
+ {
+ AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
+ return r;
+ }
+ __pAddressbar->SetAddressbarEventListener(this);
+ AddControl(__pAddressbar);
+ __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
+ SetControlAlwaysOnTop(*__pAddressbar, true);
+ __adressPanelPosition = __pAddressbar->GetPosition();
+
+ AppLogDebug("MainForm::InitAddressbar exit");
+
+ return E_SUCCESS;
+}
+
+result
+MainForm::CreateReaderPanel(void)
+{
+ AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
+ result r = E_FAILURE;
+ WebSetting settings;
+ Button *pSmallFontBtn = null;
+ Button *pLargeFontBtn = null;
+
+ __pBlankPanel = new (std::nothrow) Panel();
+ __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
+
+ __pArticleReaderPanel = new (std::nothrow) Panel();
+ __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
+
+ __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
+ if (__pReaderCloseBtn)
+ {
+ AppLogDebug("CreateReaderPanel() 6");
+ __pReaderCloseBtn->AddActionEventListener(*this);
+ __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
+ }
+
+ __pWebReader = new (std::nothrow) Web();
+ __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
+
+ settings.SetInputStyle(INPUT_STYLE_OVERLAY);
+ settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
+
+ r = __pWebReader->SetSetting(settings);
+ if (IsFailed(r))
+ AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
+
+
+ __pArticleReaderLabel = new Label();
+ __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
+
+ __pBlankPanel->AddControl(__pArticleReaderLabel);
+ __pBlankPanel->AddControl(__pArticleReaderPanel);
+ AddControl(__pBlankPanel);
+
+ __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
+ __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
+ __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
+
+ __pArticleReaderPanel->AddControl(__pWebReader);
+ __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
+ Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
+ Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
+
+ if (pBitmap != null && pSrcBitmap != null)
+ {
+ pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
+ }
+ __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
+
+ pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
+ if (pSmallFontBtn)
+ {
+ pSmallFontBtn->AddActionEventListener(*this);
+ pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
+ }
+
+ pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
+ if (pLargeFontBtn)
+ {
+ pLargeFontBtn->AddActionEventListener(*this);
+ pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
+ }
+
+
+ if (pBitmap != null)
+ {
+ delete pBitmap;
+ pBitmap = null;
+ }
+ if (pSrcBitmap != null)
+ {
+ delete pSrcBitmap;
+ pSrcBitmap = null;
+ }
+
+ SetControlAlwaysOnTop(*__pBlankPanel, true);
+ //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
+ Invalidate(true);
+
+ return E_SUCCESS;
+}
+
+result
+MainForm::InitWebControl()
+{
+ AppLogDebug("MainForm::InitWebControl enter");
+ result r = E_SUCCESS;
+ AppLogDebug("InitWebControl");
+
+ if (__pAddressbar == null || __pFooterPanel == null)
+ return E_FAILURE;
+
+ const int Y_WEBCONTROL_POSITION = 0;
+
+ __webControlHeight = GetHeight() - __pFooterPanel->GetHeight();
+ __webControlHeightF = GetHeightF() - __pFooterPanel->GetHeightF();
+
+ if (__pMostVisitedListView)
+ {
+ __pMostVisitedListView->SetShowState(false);
+ }
+ if (__pWebViewer != null)
+ {
+ AppLogDebug("Already initialized");
+ return E_SUCCESS;
+ }
+ __pWebViewer = new(std::nothrow) Web();
+ if(__pWebViewer == NULL)
+ {
+ AppLogDebug("Initialization failed");
+ return E_FAILURE;
+ }
+ AppLog("GetClientAreaBounds().width %d",GetClientAreaBounds().width);
+ r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
+
+ if (IsFailed(r))
+ {
+ AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
+ delete __pWebViewer;
+ __pWebViewer = null;
+ return r;
+ }
+ else
+ {
+ r = AddControl(__pWebViewer);
+ if (IsFailed(r))
+ {
+ __pWebViewer->Destroy();
+ __pWebViewer = null;
+ AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
+ return r;
+ }
+ __webControlPosition = __pWebViewer->GetPosition();
+ __webControlPositionF = __pWebViewer->GetPositionF();
+ r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
+ if (IsFailed(r))
+ {
+ AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
+ return r;
+ }
+
+ __pWebViewer->SetLoadingListener(this);
+ __pWebViewer->SetWebUiEventListenerF(this);
+ __pWebViewer->SetWebKeypadEventListener(this);
+ __pWebViewer->SetFocus();
+ __pWebViewer->AddTouchEventListener(*this);
+
+ __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
+ __pWebViewer->SetTextSearchListener(this);
+ }
+
+ AppLogDebug("MainForm :before return");
+ Invalidate(true);
+ AppLogDebug("MainForm::InitWebControl Exit");
+
+ return r;
+}
+
+void
+MainForm::SetJavascriptEnabled()
+{
+ WebSetting settings = __pWebViewer->GetSetting();
+ settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
+ __pWebViewer->SetSetting(settings);
+}
+
+void
+MainForm::SetImageLoadEnabled()
+{
+ WebSetting settings = __pWebViewer->GetSetting();
+ settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
+ __pWebViewer->SetSetting(settings);
+}
+
+result
+MainForm::InitFooter(void)
+{
+ AppLogDebug("MainForm::InitFooter entered");
+ Button* pBackButton = null;
+ Button* pBookmarkButton = null;
+ Button* pMultiWindowButton = null;
+ Bitmap *pIconBitmap = null;
+ Bitmap *pBGBitmap = null;
+ Label *pBGLabel = null;
+
+ if (__pFooterPanel == null)
+ {
+ __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
+ }
+
+ if (__pFooterPanel == null)
+ {
+ return E_FAILURE;
+ }
+
+ SetControlAlwaysOnTop(*__pFooterPanel, true);
+
+ __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
+ if ( __pFooterLabel == NULL )
+ {
+ return E_FAILURE;
+ }
+// __pFooterPanel->SetBackgroundColor(Color(255,0,0));
+ //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
+ Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
+ if (pBitmap != null)
+ {
+ __pFooterLabel->SetBackgroundBitmap(*pBitmap);
+ delete pBitmap;
+ }
+
+ __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
+
+ if ( __pMultiWindowButton == NULL )
+ {
+ return E_FAILURE;
+ }
+
+
+ SetFormBackEventListener(this);
+ AppLog("SetFormBackEventListener result %s",GetErrorMessage(GetLastResult()));
+ if (__pMultiWindowButton != null)
+ {
+ Bitmap* pBitmap = null;
+ Bitmap* pPressedBitmap = null;
+ String imagePath = "I01_toolbar_icon_windows_manager_0";
+ String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
+ int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
+ imagePath.Append(totalCount);
+ imagePath.Append(".png");
+
+ pressedImagePath.Append(totalCount);
+ pressedImagePath.Append("_press.png");
+
+ pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
+ pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
+ if ( pBitmap == null )
+ {
+ return E_FAILURE;
+ }
+
+ Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
+ if (pBitmap != null)
+ {
+ __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
+ __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
+
+ delete pBitmap;
+ }
+
+ __pMultiWindowButton->AddActionEventListener(*this);
+ __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
+ if(pPressedBitmap)
+ {
+ delete pPressedBitmap;
+ pPressedBitmap = null;
+ }
+ }
+
+ if (__pMoreButton)
+ {
+ Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
+ Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
+ if (pBitmap != null)
+ {
+ Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
+ __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
+ __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
+
+ delete pBitmap;
+ }
+ __pMoreButton->AddActionEventListener(*this);
+ __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
+ }
+
+ //Add the editfield for url
+ __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
+ if (__pFooterUrlField == NULL)
+ {
+ return E_INVALID_KEY;
+ }
+
+ __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
+ __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
+ __pFooterUrlField->AddKeypadEventListener(*this);
+ __pFooterUrlField->SetPropagatedTouchEventListener(this);
+ __pFooterUrlField->AddFocusEventListener(*this);
+
+ if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
+ {
+ __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
+ }
+ else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
+ {
+ __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_BLANK_PAGE"));
+ }
+ else
+ {
+ //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
+ __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
+ }
+
+
+ //Add the go Back Button
+ __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
+ if (__pGoBackBtn == NULL)
+ {
+ AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
+ return E_INVALID_KEY;
+ }
+ __pGoBackBtn->SetActionId(IDA_GO_BACK);
+ __pGoBackBtn->AddActionEventListener(*this);
+
+ //Add the go forward Button
+ __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
+ if (__pGoForwardBtn == NULL)
+ {
+ AppLogDebug("Control not found returning E_INVALID_KEY");
+ return E_INVALID_KEY;
+ }
+ __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
+ __pGoForwardBtn->AddActionEventListener(*this);
+ if (__pWebViewer && __pWebViewer->CanGoForward())
+ {
+ SetForwardButtonEnabled(true);
+ }
+ else
+ {
+ SetForwardButtonEnabled(false);
+ }
+
+ __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
+ if (__pRefreshBtn == NULL)
+ {
+ AppLogDebug("Control not found returning E_INVALID_KEY");
+ return E_INVALID_KEY;
+ }
+
+ __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
+ __pRefreshBtn->AddActionEventListener(*this);
+ __pRefreshBtn->SetShowState(true);
+
+ //Add the backround label for displaying progressbar
+ __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
+ if (__pProgressbarLabel == NULL)
+ {
+ AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
+ return E_INVALID_KEY;
+ }
+ __pProgressbarLabel->SetShowState(false);
+
+ __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
+ if (__pStopBtn == NULL)
+ {
+ AppLogDebug("Control not found returning E_INVALID_KEY");
+ return E_INVALID_KEY;
+ }
+ __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
+ __pStopBtn->AddActionEventListener(*this);
+ __pStopBtn->SetShowState(false);
+
+ __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
+ if (__pClearBtn == NULL)
+ {
+ AppLogDebug("Control not found returning E_INVALID_KEY");
+ return E_INVALID_KEY;
+ }
+ __pClearBtn->SetActionId(IDA_CLEAR_URL);
+ __pClearBtn->AddActionEventListener(*this);
+ __pClearBtn->SetShowState(false);
+
+ __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
+ if (__pReaderBtn == NULL)
+ {
+ AppLogDebug("Control not found returning E_INVALID_KEY");
+ return E_INVALID_KEY;
+ }
+ __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
+ __pReaderBtn->AddActionEventListener(*this);
+ __pReaderBtn->SetShowState(false);
+
+ // __pFooterPanel->Invalidate(true);
+ if(__isKeypadOpened == false && __pAddressbar && __pAddressbar->GetShowState() == false)
+ {
+// AppLog("asdasdasdasda");
+ __pFooterPanel->SetShowState(true);
+ }
+ else if(__pAddressbar == null)
+ {
+ __pFooterPanel->SetShowState(true);
+ }
+ else
+ __pFooterPanel->SetShowState(false);
+
+ SetAddressbarMode(GetAddressbarMode());
+ AppLogDebug("MainForm::InitFooter exit");
+ return E_SUCCESS;
+}
+
+result
+MainForm::InitOptionMenu()
+{
+ result r = E_SUCCESS;
+ bool isPrivateBrowsing = false;
+ Bitmap* pBitmap = null;
+
+ if (__pOptionMenu != null)
+ {
+ __pOptionMenu->SetFocusable(true);
+ __pOptionMenu->Invalidate(true);
+ return r;
+ }
+
+ __pOptionMenu = new(std::nothrow) OptionMenu();
+ r = __pOptionMenu->Construct();
+ TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
+
+ __pOptionMenu->SetFocusable(true);
+ isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
+
+
+ if (isPrivateBrowsing == true)
+ {
+ pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
+ }
+ else
+ {
+ pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
+ }
+
+ r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
+
+ if ( pBitmap != NULL)
+ {
+ __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
+ delete pBitmap;
+ }
+ r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
+ r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
+ r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
+
+
+ __pOptionMenu->SetMaxVisibleItemsCount(6);
+ __pOptionMenu->SetShowState(false);
+ __pOptionMenu->AddActionEventListener(*this);
+ SetControlAlwaysOnTop(*__pOptionMenu, true);
+
+ CATCH:
+ return r;
+}
+
+result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
+{
+ result r = E_SUCCESS;
+ ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
+ String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
+
+ AppLog("MainForm::InitImageContextMenu clicked on image");
+ if (__pImageMenu != null)
+ {
+ delete __pImageMenu;
+ __pImageMenu = null;
+ }
+ if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
+ {
+ p.y = p.y + 54;
+ }
+
+ __pImageMenu = new (std::nothrow) ContextMenu();
+ r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
+ TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
+
+
+ r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
+ AppLog("srcUrl %ls __pWebViewer->GetUrl() %ls",srcUrl.GetPointer(),__pWebViewer->GetUrl().GetPointer());
+
+ if(__pWebViewer && srcUrl.Equals(__pWebViewer->GetUrl(),false) == false)
+ r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
+ r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
+ r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
+ __pImageMenu->SetMaxVisibleItemsCount(4);
+ __pImageMenu->AddActionEventListener(*this);
+ SetControlAlwaysOnTop(*__pImageMenu, true);
+ __pImageMenu->SetFocusable(true);
+
+ CATCH: return r;
+}
+
+result
+MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
+{
+ result r = E_SUCCESS;
+ ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
+
+ AppLog("MainForm::InitImageContextMenu clicked on image");
+ if (__pImageMenu != null)
+ {
+ delete __pImageMenu;
+ __pImageMenu = null;
+ }
+
+// if(__pAddressbar->GetShowState() == true)
+// p.y = p.y + __pAddressbar->GetHeight();
+ if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
+ {
+ p.y = p.y + 54;
+ }
+
+ __pImageMenu = new (std::nothrow) ContextMenu();
+ r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
+ TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
+
+ r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_OPEN_IN_NEW_WINDOW"),IDA_HYPERLINK_OPEN_CLICKED);
+ r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_LINK_URL"),IDA_HYPERLINK_COPY_LINK_CLICKED);
+ //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
+ r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
+
+ __pImageMenu->SetMaxVisibleItemsCount(3);
+ __pImageMenu->AddActionEventListener(*this);
+ SetControlAlwaysOnTop(*__pImageMenu, true);
+ __pImageMenu->SetFocusable(true);
+
+ CATCH: return r;
+
+}
+
+result
+MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOption = false)
+{
+ result r = E_SUCCESS;
+ bool clipboardAvailable = true;
+ ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
+
+ AppLog("MainForm::InitSelectTextContextMenu clicked on text");
+ if (__pImageMenu != null)
+ {
+ delete __pImageMenu;
+ __pImageMenu = null;
+ }
+// Point q(0,0);
+// __pWebViewer->GetBlockRange(p,q);
+
+ if(p.y < 150)
+ {
+ p.y = p.y + 50;
+ direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
+ }
+ else
+ {
+ direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
+ }
+
+
+ Clipboard* pClipboard = Clipboard::GetInstance();
+
+ if(pClipboard == null)
+ {
+ clipboardAvailable = false;
+ }
+ else
+ {
+ // Retrieves a latest item
+ ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
+
+ if(pItem == null)
+ {
+ clipboardAvailable = false;
+ }
+ else
+ {
+ //Gets data from the clipboard item
+ String* pString = dynamic_cast<String*>(pItem->GetData());
+
+ if(pString == null)
+ {
+ clipboardAvailable = false;
+ }
+ }
+ }
+ if(clipboardAvailable == false && onlyPasteOption == true)
+ {
+ return E_FAILURE;
+ }
+
+ __pImageMenu = new (std::nothrow) ContextMenu();
+ r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
+ TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
+
+ if(onlyPasteOption == false)
+ {
+ r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
+ }
+ if ((pasteOption || onlyPasteOption) && clipboardAvailable == true)
+ {
+ r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
+ }
+ if(onlyPasteOption == false)
+ {
+ r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
+ r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
+ }
+
+ __pImageMenu->SetMaxVisibleItemsCount(3);
+ __pImageMenu->AddActionEventListener(*this);
+ SetControlAlwaysOnTop(*__pImageMenu, true);
+ __pImageMenu->SetFocusable(true);
+
+ CATCH: return r;
+
+}
+
+result
+MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPasteOption = false)
+{
+ result r = E_SUCCESS;
+ bool clipboardAvailable = true;
+ ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
+
+ AppLog("MainForm::InitSelectTextContextMenu clicked on text");
+ if (__pImageMenu != null)
+ {
+ delete __pImageMenu;
+ __pImageMenu = null;
+ }
+// FloatPoint q(0.0,0.0);
+// __pWebViewer->GetBlockRange(p,q);
+ if(p.y < 0)
+ p.y =0;
+ if(p.y < 150)
+ {
+ p.y = p.y + 100;
+ if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE )
+ {
+ p.y = p.y - 50;
+ }
+ direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
+ }
+ else if(__pWebViewer != null && (p.y > (__pWebViewer->GetHeight() + __pWebViewer->GetY())))
+ {
+ p.y = __pWebViewer->GetHeight() + __pWebViewer->GetY();
+ }
+ else
+ {
+ if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE )
+ {
+ AppLog("asdasdafdsfdgfd");
+ p.y = p.y - 50;
+ }
+ direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
+ }
+
+
+ Clipboard* pClipboard = Clipboard::GetInstance();
+
+ if(pClipboard == null)
+ {
+ clipboardAvailable = false;
+ }
+ else
+ {
+ // Retrieves a latest item
+ ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
+
+ if(pItem == null)
+ {
+ clipboardAvailable = false;
+ }
+ else
+ {
+ //Gets data from the clipboard item
+ String* pString = dynamic_cast<String*>(pItem->GetData());
+
+ if(pString == null)
+ {
+ clipboardAvailable = false;
+ }
+ }
+ }
+ if(clipboardAvailable == false && (onlyPasteOption == true || __pHitElementResult->GetAttributeValue("type").Equals(L"password",false) == true))
+ {
+ return E_FAILURE;
+ }
+ __pImageMenu = new (std::nothrow) ContextMenu();
+ r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
+ TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
+
+ if(onlyPasteOption == false && __pHitElementResult->GetAttributeValue("type").Equals(L"password",false) == false)
+ {
+ r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
+ }
+ if ((pasteOption || onlyPasteOption) && clipboardAvailable == true)
+ {
+ r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
+ }
+ if(onlyPasteOption == false && __pHitElementResult->GetAttributeValue("type").Equals(L"password",false) == false)
+ {
+ r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
+ r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
+ }
+
+ __pImageMenu->SetMaxVisibleItemsCount(3);
+ __pImageMenu->AddActionEventListener(*this);
+ SetControlAlwaysOnTop(*__pImageMenu, true);
+ __pImageMenu->SetFocusable(true);
+
+ CATCH: return r;
+
+}
+
+result
+MainForm::InitFindWordPanel(void)
+{
+ result r = E_SUCCESS;
+ Bitmap *pIconBitmap = null;
+
+ if (__pFindWordControl != null)
+ {
+ AppLogDebug("Findword panel already initialized");
+ if (__pFindWordBgLabel != null)
+ {
+ Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
+ if (pBitmap != null)
+ {
+ __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
+ delete pBitmap;
+ }
+ }
+ if (__pFindWordBgLabelRightToLeft != null)
+ {
+ Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
+ if (pBitmap != null)
+ {
+ __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
+ delete pBitmap;
+ }
+ }
+ if(__pAddressbar)
+ __pAddressbar->SetShowState(false);
+
+ if(__isKeypadOpened == false)
+ __pFooterPanel->SetShowState(true);
+ return r;
+ }
+
+ __pFindWordControl = new (std::nothrow) Panel();
+ r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
+ if (IsFailed(r))
+ {
+ AppLogException("There is some problem in the xml file. Please check.");
+ return E_FAILURE;
+ }
+ AddControl(__pFindWordControl);
+ __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
+ SetControlAlwaysOnTop(*__pFindWordControl,true);
+ __pFindWordControl->SetShowState(false);
+ __pFindWordControl->Invalidate(false);
+
+ __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
+ __pFindWordPanelLeftToRight->SetShowState(true);
+
+ __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
+ __pFindWordPanelRightToLeft->SetShowState(false);
+
+ __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
+ if (__pFindWordBgLabel != null)
+ {
+ Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
+ Rectangle pRect = pPanel1->GetBounds();
+ pRect.x = pRect.y = 0;
+ __pFindWordBgLabel->SetBounds(pRect);
+ Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.#.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
+ if (pBitmap != null)
+ {
+ AppLogDebug("InitFindWordPanel: Coming here");
+ __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
+ delete pBitmap;
+ }
+ else
+ {
+ AppLogDebug("InitFindWordPanel: shouldn't Come here");
+ }
+ }
+
+ __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
+ if (__pFindWordBgLabelRightToLeft != null)
+ {
+ Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
+ Rectangle pRect = pPanel1->GetBounds();
+ pRect.x = pRect.y = 0;
+ __pFindWordBgLabelRightToLeft->SetBounds(pRect);
+ Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.#.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
+ if (pBitmap != null)
+ {
+ AppLogDebug("InitFindWordPanel: Coming here");
+ __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
+ delete pBitmap;
+ }
+ else
+ {
+ AppLogDebug("InitFindWordPanel: shouldn't Come here");
+ }
+ }
+
+ Button* pfindWordCancel = null;
+ pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
+ if (pfindWordCancel == null)
+ {
+ AppLogException("There is some problem in the xml file. Please check.");
+ return E_FAILURE;
+ }
+ pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
+ pfindWordCancel->AddActionEventListener(*this);
+
+ __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
+ if (__pFindWordClear == null)
+ {
+ AppLogException("There is some problem in the xml file. Please check.");
+ return E_FAILURE;
+ }
+
+ __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
+ if (__pFindWordClearRightToLeft == null)
+ {
+ AppLogException("There is some problem in the xml file. Please check.");
+ return E_FAILURE;
+ }
+
+ __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
+ __pFindWordClear->AddActionEventListener(*this);
+
+ __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
+ __pFindWordClearRightToLeft->AddActionEventListener(*this);
+
+ __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
+ if (__pFindWordNext == null)
+ {
+ AppLogException("There is some problem in the xml file. Please check.");
+ return E_FAILURE;
+ }
+
+ __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
+ __pFindWordNext->AddActionEventListener(*this);
+
+ __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
+ if (__pFindWordPrev == null)
+ {
+ AppLogException("There is some problem in the xml file. Please check.");
+ return E_FAILURE;
+ }
+
+ __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
+ __pFindWordPrev->AddActionEventListener(*this);
+
+ __pFindWordNext->SetEnabled(false);
+ __pFindWordPrev->SetEnabled(false);
+
+ __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
+ if (__pFindWordCountLabel == null)
+ {
+ AppLogException("There is some problem in the xml file. Please check.");
+ return E_FAILURE;
+ }
+ __pFindWordCountLabel->SetText(L"0/0");
+
+ __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
+ if (__pFindWordCountLabelRightToLeft == null)
+ {
+ AppLogException("There is some problem in the xml file. Please check.");
+ return E_FAILURE;
+ }
+ __pFindWordCountLabelRightToLeft->SetText(L"0/0");
+
+ __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
+ if (__pFindWordEditField == null)
+ {
+ AppLogException("There is some problem in the xml file. Please check.");
+ return E_FAILURE;
+ }
+ __pFindWordEditField->AddTextEventListener(*this);
+ __pFindWordEditField->AddKeypadEventListener(*this);
+ __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
+ __pFindWordEditField->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
+
+ __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
+ if (__pFindWordEditFieldRightToLeft == null)
+ {
+ AppLogException("There is some problem in the xml file. Please check.");
+ return E_FAILURE;
+ }
+ __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
+ __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
+ __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
+ __pFindWordEditFieldRightToLeft->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
+
+ if(__pAddressbar)
+ __pAddressbar->SetShowState(false);
+
+ if(__isKeypadOpened == false)
+ __pFooterPanel->SetShowState(true);
+ return r;
+}
+
+ListItemBase*
+MainForm::CreateItem (int index, int itemWidth)
+{
+ Rectangle listImageRect;
+ Rectangle pagetTitleRect;
+ Rectangle pageURLRect;
+ Rectangle deleteImageRect;
+ String pageTitle(L"");
+ String pageURL(L"");
+ result r = E_SUCCESS;
+ Bitmap* pListIconImage = null;
+
+
+ History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
+ if(pHistory == null)
+ {
+ return null;
+ }
+ AppResource* pAppResource = Application::GetInstance()->GetAppResource();
+ if ( pAppResource == NULL )
+ {
+ return null;
+ }
+ ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
+
+ CustomItem* pItem = new(std::nothrow) CustomItem();
+ pageTitle = pHistory->GetHistoryTitle();
+ pageURL = pHistory->GetHistoryUrl();
+
+ if (pageURL.GetLength() == 0)
+ {
+ String nourl;
+ pAppResource->GetString(L"IDS_BR_BODY_BLANK_PAGE", nourl);
+ pageURL = L"<"+ nourl +">";
+
+ }
+
+ Rectangle screenBounds = GetBounds();
+ if (pItem != null)
+ {
+ r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
+ }
+ if (IsFailed(r))
+ {
+ delete pItem;
+ return NULL;
+ }
+
+
+ Bitmap* pBitmap = pHistory->GetFavIconBitmap();
+
+ if ( pBitmap != NULL)
+ {
+ pListIconImage = new Bitmap();
+ pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
+ delete pBitmap;
+ }
+
+ if(pListIconImage == null)
+ {
+ pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
+ }
+
+ if ( pListIconImage != NULL)
+ {
+ listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2 , 72, 72);
+ pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 72 + (__fontSize - 44));
+ pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
+
+
+ if (pItem != null && pListIconImage != NULL)
+ {
+ pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
+ }
+ }
+
+ if (pageTitle.CompareTo(L"") != 0)
+ {
+ if (pItem != null)
+ {
+ pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
+ }
+ }
+
+ if (pageURL.CompareTo(L"") != 0)
+ {
+ if (pItem != null)
+ {
+ pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_LISTVIEW_TEXT, CUSTOM_COLOR_LISTVIEW_TEXT, true);
+ }
+ }
+
+
+ if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
+ {
+ if ( __pItemContext!= NULL)
+ {
+ if (pItem != null)
+ {
+ pItem->SetContextItem(__pItemContext);
+ }
+ }
+ }
+ else
+ {
+ if ( __pItemContextLandscape!= NULL)
+ {
+ if (pItem != null)
+ {
+ pItem->SetContextItem(__pItemContextLandscape);
+ }
+ }
+ }
+ if( pListIconImage != NULL)
+ {
+ delete pListIconImage;
+ pListIconImage = null;
+ }
+
+ return pItem;
+}
+
+bool
+MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
+{
+ delete pItem;
+ return true;
+}
+
+int
+MainForm::GetItemCount (void)
+{
+ if(__pMostVisitedSites != null)
+ {
+ __pMostVisitedSites->RemoveAll(true);
+ }
+ HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
+ if(__pMostVisitedSites != null)
+ {
+ return __pMostVisitedSites->GetCount();
+ }
+ else
+ return 0;
+}
+
+void
+MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
+{
+ AppLog("MainForm::OnListViewContextItemStateChanged called");
+ if(__pMostVisitedSites != null)
+ {
+ History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
+ if (pHistory != null)
+ {
+ String url = pHistory->GetHistoryUrl();
+
+ HistoryPresentationModel::GetInstance()->DeleteHistory(url);
+ __pMostVisitedListView->UpdateList();
+ }
+ }
+}
+
+void
+MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
+{
+ AppLog("MainForm::OnListViewItemStateChanged called");
+ History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
+ String url = pHistory->GetHistoryUrl();
+ if (url != null)
+ {
+ LoadUrl(url);
+ }
+}
+
+void
+MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
+{
+
+}
+
+result
+MainForm::OnTerminating(void)
+{
+ result r = E_SUCCESS;
+
+ RemoveOrientationEventListener(*this);
+
+ if(__pAddressbar)
+ {
+ __pAddressbar->SetAddressbarEventListener(null);
+ }
+
+ if(__pWebViewer)
+ {
+ __pWebViewer->RemoveTouchEventListener(*this);
+ __pWebViewer->SetWebUiEventListenerF(null);
+ __pWebViewer->SetWebKeypadEventListener(null);
+ __pWebViewer->SetTextSearchListener(null);
+ }
+
+
+ if (__pItemContext)
+ {
+ delete __pItemContext;
+ }
+ if (__pItemContextLandscape)
+ {
+ delete __pItemContextLandscape;
+ }
+ if (__pSaveImage)
+ {
+ delete __pSaveImage;
+ }
+ if (__pMostVisitedSites)
+ {
+ __pMostVisitedSites->RemoveAll(true);
+ delete __pMostVisitedSites;
+ }
+ return r;
+}
+
+void
+MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
+{
+ result r = E_SUCCESS;
+
+ AppLogDebug("Clicked : %d", actionId);
+ switch (actionId)
+ {
+ case IDA_BACKBTN_CLICKED:
+ {
+ if(__pImageMenu && __pImageMenu->GetShowState() == true)
+ {
+ AppLog("Hiding the menu");
+ __pImageMenu->SetShowState(false);
+ }
+ if (__pWebViewer && __pWebViewer->CanGoBack())
+ {
+ __pWebViewer->GoBack();
+ }
+ else if(__pWindowInfo->isJavascriptInitiated == false)
+ {
+ UiApp* pApp = null;
+ pApp = UiApp::GetInstance();
+ if (pApp != null)
+ {
+ r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
+ if (IsFailed(r))
+ {
+ AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
+ return;
+ }
+ }
+ }
+ else
+ {
+ UiApp* pApp = null;
+ WindowInfo* pWindowInfo = null;
+ int totalCount = 0;
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+ if (pSceneManager == null)
+ {
+ return;
+ }
+ ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
+ if (pAllWindowList == NULL)
+ {
+ pApp = UiApp::GetInstance();
+ if (pApp != null)
+ {
+ r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
+ if (IsFailed(r))
+ {
+ AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
+ return;
+ }
+ }
+ }
+ if (pAllWindowList != null)
+ {
+ totalCount = pAllWindowList->GetCount();
+ }
+ for (int count = 0; count < totalCount; count++)
+ {
+ pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
+ if (pWindowInfo == null)
+ {
+ pApp = UiApp::GetInstance();
+ if (pApp != null)
+ {
+ r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
+ if (IsFailed(r))
+ {
+ AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
+ return;
+ }
+ }
+ }
+ else
+ {
+ if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
+ {
+ r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
+ if (IsFailed(r))
+ {
+ AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
+ return;
+ }
+ r = pAllWindowList->RemoveAt(count, true);
+ __pWindowInfo = null;
+ if (IsFailed(r))
+ {
+ AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
+ return;
+ }
+ if(count > 0)
+ {
+ pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
+ }
+ else
+ {
+ pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
+ }
+ if (pWindowInfo == null)
+ {
+ pApp = UiApp::GetInstance();
+ if (pApp != null)
+ {
+ r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
+ return;
+ }
+ }
+ else
+ {
+ r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
+// r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
+ if (IsFailed(r))
+ {
+ AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
+ return;
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case IDA_FORWARD_CLICKED:
+ if (__pWebViewer == null)
+ return;
+
+ if (__pWebViewer->CanGoForward())
+ {
+ __pWebViewer->GoForward();
+ }
+ __pOptionMenu->SetShowState(false);
+ __pOptionMenu->Invalidate(false);
+ break;
+
+ case IDA_FINDONPAGE_CLICKED:
+ {
+ AppLogDebug("MainForm::OnActionPerformed findword clicked");
+ __currentSearchStr.Clear();
+
+ InitFindWordPanel();
+ __pOptionMenu->SetShowState(false);
+ __pOptionMenu->Invalidate(false);
+
+ ShowFindWordPanel(true);
+
+ if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
+ {
+ __pFindWordEditField->SetFocus();
+ }
+ else
+ {
+ __pFindWordEditFieldRightToLeft->SetFocus();
+ }
+ }
+ break;
+ case IDA_PRIVATEON_CLICKED:
+ {
+ result r = E_SUCCESS;
+ int itemIndex = 0;
+ bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
+ Bitmap* pBitmap = null;
+ if (isPrivateBrowsing == true)
+ {
+ pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
+ if (IsFailed(r))
+ {
+ AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
+ return ;
+ }
+
+ if (__pWebViewer != NULL)
+ {
+ __pWebViewer->SetPrivateBrowsingEnabled(false);
+ }
+
+ SettingPresentationModel::GetInstance()->SetPrivateOn(false);
+
+ if (__pAddressbar != null)
+ {
+ __pAddressbar->UpdateFaviconBitmap(false);
+ }
+
+ }
+ else
+ {
+ pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
+ if (IsFailed(r))
+ {
+ AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
+ return ;
+ }
+
+ if (__pWebViewer != NULL)
+ {
+ __pWebViewer->SetPrivateBrowsingEnabled(true);
+ }
+
+ SettingPresentationModel::GetInstance()->SetPrivateOn(true);
+
+ if (__pAddressbar != null)
+ {
+ __pAddressbar->UpdateFaviconBitmap(true);
+ }
+ }
+
+ itemIndex = __pOptionMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
+ r = __pOptionMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
+ AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
+ __pOptionMenu->Invalidate(true);
+ if ( pBitmap != NULL )
+ {
+ delete pBitmap;
+ }
+
+ }
+ break;
+ case IDA_SETTINGS_CLICKED:
+ {
+
+ ArrayList* pArgList = new(std::nothrow) ArrayList();
+ if (pArgList)
+ {
+ pArgList->Construct();
+ pArgList->Add(*__pWindowInfo);
+ SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
+ }
+ __pOptionMenu->SetShowState(false);
+ __pOptionMenu->Invalidate(false);
+
+ if (pArgList != null)
+ {
+ delete pArgList;
+ pArgList = null;
+ }
+
+ }
+ break;
+
+ case IDA_ADDTOBOOKMARK_CLICKED:
+ {
+
+ if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
+ {
+ int bookmarkCount=0;
+ bool exist = false;
+ String url=L"";
+ url=__pWindowInfo->pageUrl;
+ result r = E_SUCCESS;
+ Bitmap* pBitmap = null;
+ r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
+
+ if (IsFailed(r))
+ {
+ return;
+ }
+ if ( exist == true)
+ {
+ String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
+ BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
+ pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
+
+ if(__pNotification != null)
+ {
+ RemoveControl(__pNotification);
+ __pNotification = null;
+ }
+ __pNotification = new (std::nothrow) NotificationPanel(*this);
+ if (__pNotification != null)
+ {
+ __pNotification->SetText(message);
+ __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
+ __pNotification->ShowNotification();
+ }
+ }
+ else
+ {
+ String title=__pWindowInfo->pageTitle;
+ String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
+ BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
+
+ pBookmark->SetBookmarkTitle(title);
+ pBookmark->SetUrl(url);
+ if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
+ {
+ pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
+ }
+ String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
+ pBookmark->SetFaviconId(id);
+ //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
+ r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
+ delete pBookmark;
+ if(__pNotification != null)
+ {
+ RemoveControl(__pNotification);
+ __pNotification = null;
+ }
+ __pNotification = new (std::nothrow) NotificationPanel(*this);
+ if (__pNotification != null)
+ {
+ __pNotification->SetText(message);
+ __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
+ __pNotification->ShowNotification();
+ pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
+ }
+ }
+ if (pBitmap != null)
+ {
+ r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
+ delete pBitmap;
+ }
+
+
+ __pOptionMenu->Invalidate(true);
+ }
+
+ }
+ break;
+ case IDA_PRINT_CLICKED:
+ {
+ r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//shared//data//test.pdf");
+ AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
+
+ AppLog("RequestPrint called!");
+ AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
+ result nResult = E_FAILURE;
+ if (pAc)
+ {
+ AppLog("TestPrint if (pAc) == true");
+
+ HashMap map;
+ map.Construct();
+
+ String fileType = L"service_print_files_type";
+ String typeVal = L"DOC";
+
+ String fileCount = L"service_print_files_count";
+ String countVal = L"1";
+ String fileFolder= L"service_print_files_folder_name";
+ String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//shared//data";
+
+ map.Add(&fileCount, &countVal);
+ map.Add(&fileFolder, &folderVal);
+ map.Add(&fileType, &typeVal);
+
+ String fileName = L"service_print_files_files_name";
+
+ ArrayList fileNameList;
+ fileNameList.Construct();
+ String file1 = L"test.pdf";
+
+ fileNameList.Add(&file1);
+ map.Add(&fileName, &fileNameList);
+
+ nResult = pAc->Start(NULL, NULL, &map, NULL);
+
+ if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
+ else if (nResult == E_MAX_EXCEEDED)
+ AppLog("TestPrint ret == E_MAX_EXCEEDED");
+ else if (nResult == E_OBJ_NOT_FOUND)
+ AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
+ else if (nResult == E_IN_PROGRESS)
+ AppLog("TestPrint ret == E_IN_PROGRESS");
+ else if (nResult == E_PRIVILEGE_DENIED)
+ AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
+ else if(nResult == E_SYSTEM)
+ AppLog("TestPrint ret == E_SYSTEM");
+
+ delete pAc;
+ }
+ else
+ {
+ int __modalMsgBoxResult;
+ MessageBox* pMsgBox = new MessageBox();
+ pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
+ pMsgBox->ShowAndWait(__modalMsgBoxResult);
+ delete pMsgBox;
+ pMsgBox = null;
+ __modalMsgBoxResult = 0;
+ }
+ }
+ break;
+ case IDA_SHARE_CLICKED:
+ {
+ if(__pPopUp != null)
+ {
+ delete __pPopUp;
+ __pPopUp = null;
+ }
+ if(__pAddressbar)
+ {
+ __pAddressbar->HideKeypad();
+ }
+ __pPopUp = new(std::nothrow) SharePopup();
+ __pPopUp->Initialize();
+ if (__pWindowInfo != null)
+ {
+ ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
+ pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
+ pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
+ pShareInfo->SetImageAttached(false);
+ __pPopUp->RemoveAllShareInfo();
+ __pPopUp->AddShareInfo(pShareInfo);
+ }
+ __pPopUp->SetShowState(true);
+ __pPopUp->Show();
+ }
+ break;
+ case IDA_BOOKMARKBTN_CLICKED:
+ {
+ AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
+ SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
+ }
+ break;
+ case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
+ {
+
+ }
+ break;
+ case IDA_MOREBTN_CLICKED:
+ {
+ AppLog("IDA_MOREBTN_CLICKED");
+ InitOptionMenu();
+ if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
+ {
+ int bookmarkCount=0;
+ bool exist = false;
+ String url=L"";
+ url=__pWindowInfo->pageUrl;
+ result r = E_SUCCESS;
+ Bitmap* pBitmap = null;
+
+ r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
+ if (IsFailed(r))
+ {
+ AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
+ return;
+ }
+ if ( exist == true)
+ {
+ pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
+ }
+ else
+ {
+ pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
+ }
+ AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
+
+ if (__pOptionMenu->GetItemCount() == 9)
+ {
+ r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
+ }
+ else
+ {
+ r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
+ }
+
+ if (IsFailed(r))
+ {
+ AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
+ delete pBitmap;
+ return ;
+ }
+ AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
+ if (__pOptionMenu->GetItemCount() != 9)
+ {
+ __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
+ __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
+ // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
+ __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
+ __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
+ __pOptionMenu->SetMaxVisibleItemsCount(6);
+ }
+ if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
+ {
+ AppLog(" Orientation landscape");
+ __pOptionMenu->SetMaxVisibleItemsCount(5);
+ }
+ else
+ {
+ AppLog(" Orientation potrait");
+ __pOptionMenu->SetMaxVisibleItemsCount(6);
+ }
+
+ AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
+ delete pBitmap;
+ }
+ AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
+ __pOptionMenu->SetShowState(true);
+ __pOptionMenu->Invalidate(true);
+ __pOptionMenu->Show();
+
+}
+ break;
+ case IDA_HISTORY_CLICKED:
+ {
+ AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
+ SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
+ }
+ break;
+ case IDA_SAVED_PAGES_CLICKED:
+ {
+
+ }
+ break;
+ case IDA_DESKTOP_VIEW_CLICKED:
+ {
+
+ }
+ break;
+ case IDA_SAVE_CLICKED:
+ {
+
+ }
+ break;
+ case IDA_MULTIWINDOWBTN_CLICKED:
+ {
+ result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
+ AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
+ }
+ break;
+
+ case IDA_NEWWINDOWBTN_CLICKED:
+ {
+ WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
+
+ if (pNewWindowInfo == null)
+ {
+ return;
+ }
+ result r = E_SUCCESS;
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+
+ if (pSceneManager == NULL)
+ {
+ return;
+ }
+ ArrayList* pArgList = new(std::nothrow) ArrayList();
+ if (pArgList == NULL)
+ {
+ return;
+ }
+ r = pArgList->Construct();
+ if (r == E_SUCCESS)
+ {
+ pArgList->Add(*pNewWindowInfo);
+ r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
+ }
+ delete pArgList;
+ pArgList = null;
+ if (IsFailed(r))
+ {
+ AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
+ return;
+ }
+ }
+ break;
+ case IDA_SMALLFONT_BTN_CLICKED:
+ {
+ WebSetting setting = __pWebReader->GetSetting();
+ setting.SetFontSize(15);
+ __pWebReader->SetSetting(setting);
+ }
+ break;
+ case IDA_LARGEFONT_BTN_CLICKED:
+ {
+ WebSetting setting = __pWebReader->GetSetting();
+ setting.SetFontSize(25);
+ __pWebReader->SetSetting(setting);
+ }
+ break;
+ case IDA_READER_CLOSE_CLICKED:
+ {
+ if (__pArticleReaderPanel != null && __pBlankPanel != null)
+ {
+ RemoveControl(__pBlankPanel);
+ __pArticleReaderPanel = null;
+ __pBlankPanel = null;
+ __pArticleReaderLabel = null;
+ }
+ SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
+ }
+ break;
+ case IDA_FINDWORD_CANCEL_CLICKED:
+ {
+ __currentSearchStr = L"";
+ __currentWordIndex = 0;
+ __maxOccurrances = 0;
+
+ if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
+ {
+ __pFindWordEditField->SetText(L"");
+ __pFindWordCountLabel->SetText(L"0/0");
+ }
+ else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
+ {
+ __pFindWordEditFieldRightToLeft->SetText(L"");
+ __pFindWordCountLabelRightToLeft->SetText(L"0/0");
+ }
+
+ __pFindWordNext->SetEnabled(false);
+ __pFindWordPrev->SetEnabled(false);
+ __pFindWordCountLabel->SetText(L"0/0");
+ __pWebViewer->SearchTextAllAsync(L"",true);
+ AppLog("akjshdasd 1");
+ if(__isKeypadOpened == false)
+ __pFooterPanel->SetShowState(true);
+ ShowFindWordPanel(false);
+ }
+ break;
+ case IDA_FINDWORD_SEARCH_CLICKED:
+ {
+ if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
+ {
+ __currentSearchStr = __pFindWordEditField->GetText();
+ }
+ else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
+ {
+ __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
+ }
+
+ if (__currentSearchStr.GetLength() > 0)
+ {
+ StartWordSearch();
+ }
+ else
+ {
+ AppLogDebug("Enter something");
+ }
+ }
+ break;
+ case IDA_FINDWORD_CLEAR_CLICKED:
+ {
+ __pFindWordCountLabel->SetText(L"0/0");
+ __pFindWordEditField->SetText(L"");
+ __currentSearchStr = L"aaaaaabbbbbbccccccc";
+ StartWordSearch();
+ __currentSearchStr = L"";
+ __pFindWordNext->SetEnabled(false);
+ __pFindWordPrev->SetEnabled(false);
+// __pFindWordCountLabel->SetShowState(false);
+ __pFindWordControl->Invalidate(true);
+ }
+ break;
+ case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
+ {
+ __pFindWordCountLabelRightToLeft->SetText(L"0/0");
+ __pFindWordEditFieldRightToLeft->SetText(L"");
+ __currentSearchStr = L"aaaaaabbbbbbccccccc";
+ StartWordSearch();
+ __currentSearchStr = L"";
+ __pFindWordNext->SetEnabled(false);
+ __pFindWordPrev->SetEnabled(false);
+// __pFindWordCountLabelRightToLeft->SetShowState(false);
+ __pFindWordControl->Invalidate(true);
+ }
+ break;
+ case IDA_FINDWORD_NEXT_CLICKED:
+ {
+ FindNextWord(true);
+ }
+ break;
+ case IDA_FINDWORD_PREV_CLICKED:
+ {
+ FindNextWord(false);
+ }
+ break;
+ case IDA_BRIGHTNESS_BTN_CLICKED:
+ {
+ AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
+ SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
+ }
+ break;
+ case IDA_COPY_IMAGE_CLICKED:
+ {
+ AppLogDebug("IDA_COPY_IMAGE_CLICKED");
+ AppLogDebug("IDA_COPY_IMAGE_CLICKED");
+ ClipboardItem item;
+ const Bitmap* pBitmap = null;
+ if (__pHitElementResult != null && __pHitElementResult->HasImage())
+ {
+ pBitmap = __pHitElementResult->GetImage();
+ }
+
+ String resourcePath = App::GetInstance()->GetAppResourcePath();
+ r = item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
+ AppLog("Platofrm construct failed result %s",GetErrorMessage(r));
+ // copying the item to clipboard
+ Clipboard* pClipboard = Clipboard::GetInstance();
+ if (pClipboard != null)
+ {
+ r = pClipboard->CopyItem(item);
+ AppLog("Platofrm copy failed result %s",GetErrorMessage(r));
+ }
+ }
+ break;
+ case IDA_VIEW_IMAGE_CLICKED:
+ {
+ AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
+ WindowInfo* pNewWindowInfo = null;
+ if (__pHitElementResult != null)
+ {
+ String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
+ AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
+
+ Uri currentUri;
+ currentUri.SetUri(__pWebViewer->GetUrl());
+
+ String newUrl;
+ Uri newUri;
+ newUri.SetUri(srcUrl);
+ AppLog("newuri gethost %ls",newUri.GetHost().GetPointer());
+ if(newUri.GetHost().GetLength() == 0)
+ {
+ newUrl = currentUri.GetHost();
+ newUrl.Append(srcUrl);
+ srcUrl = newUrl;
+ }
+
+ LoadUrl(srcUrl);
+ }
+ }
+ break;
+ case IDA_SAVE_IMAGE_CLICKED:
+ {
+ AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
+ const Bitmap* pSaveBitmap = null;
+ String imageName = GetImagePath();
+ AppLog("Content manager image name %ls",imageName.GetPointer());
+ String imagePath;
+ imagePath.Clear();
+ imagePath.Append(imageName);
+ imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
+ AppLog("Content manager image path %ls",imagePath.GetPointer());
+ if (__pHitElementResult != null)
+ {
+ pSaveBitmap = __pHitElementResult->GetImage();
+ }
+ ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
+
+ if(pBuffer)
+ {
+ UpdateImageContent(pBuffer, imageName);
+ delete pBuffer;
+ if(__pNotification != null)
+ {
+ RemoveControl(__pNotification);
+ __pNotification = null;
+ }
+ __pNotification = new NotificationPanel(*this);
+ String msg;
+ AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
+ msg.Append(imagePath);
+ if (__pNotification != null)
+ {
+ __pNotification->SetText(msg);
+ if (__pFooterPanel->GetShowState() == true)
+ {
+ __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
+ }
+ else
+ {
+ __pNotification->SetPositionDiff(0);
+ }
+ __pNotification->ShowNotification();
+ }
+ }
+ else
+ {
+ int __modalMsgBoxResult;
+ MessageBox* pMsgBox = new MessageBox();
+ pMsgBox->Construct(CommonUtil::GetString(L"IDS_IMGE_POP_UNABLE_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_IMGE_POP_UNABLE_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
+ pMsgBox->ShowAndWait(__modalMsgBoxResult);
+ delete pMsgBox;
+ pMsgBox = null;
+ __modalMsgBoxResult = 0;
+ }
+ }
+ break;
+ case IDA_SHARE_IMAGE_CLICKED:
+ {
+ AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
+ if (__pPopUp != null)
+ {
+ delete __pPopUp;
+ __pPopUp = null;
+ }
+ if(__pAddressbar)
+ {
+ __pAddressbar->HideKeypad();
+ }
+ __pPopUp = new(std::nothrow) SharePopup();
+ __pPopUp->Initialize();
+ if (__pHitElementResult != null)
+ {
+ const Bitmap* pSaveBitmap = null;
+ String imageName = GetImagePath();
+ AppLog("Content manager image name %ls",imageName.GetPointer());
+ String imagePath;
+ imagePath.Clear();
+ imagePath.Append(imageName);
+ imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
+ AppLog("Content manager image path %ls",imagePath.GetPointer());
+ if (__pHitElementResult != null)
+ {
+ pSaveBitmap = __pHitElementResult->GetImage();
+ }
+ __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
+
+ String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
+ AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
+
+ ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
+ pShareInfo->SetPageTitle(L"");
+ pShareInfo->SetPageUrl(srcUrl);
+ pShareInfo->SetImageAttached(true);
+ pShareInfo->SetImagePath(imagePath);
+ __pPopUp->RemoveAllShareInfo();
+ __pPopUp->AddShareInfo(pShareInfo);
+ __pPopUp->SetShowState(true);
+ __pPopUp->Show();
+ }
+ }
+ break;
+ case IDA_HYPERLINK_OPEN_CLICKED:
+ {
+ if (__pHitElementResult != null)
+ {
+ String srcUrl = __pHitElementResult->GetUrl();
+
+ WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
+
+ if (pNewWindowInfo == null)
+ {
+ return;
+ }
+ pNewWindowInfo->isJavascriptInitiated = true;
+ result r = E_SUCCESS;
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+ if (pSceneManager == NULL)
+ {
+ return;
+ }
+ ArrayList* pArgList = new(std::nothrow) ArrayList();
+ if (pArgList == NULL)
+ {
+ return;
+ }
+ pArgList->Construct();
+
+ pArgList->Add(*pNewWindowInfo);
+ r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
+ if (pArgList != null)
+ {
+ delete pArgList;
+ pArgList = null;
+ }
+ if(IsFailed(r))
+ {
+ AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
+ return;
+ }
+ }
+ }
+ break;
+ case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
+ {
+ if (__pHitElementResult == null)
+ {
+ return;
+ }
+
+ if(__pPopUp != null)
+ {
+ delete __pPopUp;
+ __pPopUp = null;
+ }
+ if(__pAddressbar)
+ {
+ __pAddressbar->HideKeypad();
+ }
+ __pPopUp = new(std::nothrow) SharePopup();
+ __pPopUp->Initialize();
+
+ ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
+ pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
+ pShareInfo->SetImageAttached(false);
+ __pPopUp->RemoveAllShareInfo();
+ __pPopUp->AddShareInfo(pShareInfo);
+
+ __pPopUp->SetShowState(true);
+ __pPopUp->Show();
+ }
+ break;
+ case IDA_HYPERLINK_COPY_LINK_CLICKED:
+ {
+ ClipboardItem item;
+ String url;
+ if (__pHitElementResult != null)
+ {
+ url = __pHitElementResult->GetUrl();
+ }
+
+ String resourcePath = App::GetInstance()->GetAppResourcePath();
+ item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
+
+ // copying the item to clipboard
+ Clipboard* pClipboard = Clipboard::GetInstance();
+ if (pClipboard != null)
+ {
+ pClipboard->CopyItem(item);
+ }
+ }
+ break;
+ case IDA_FIND_TEXT__CLICKED:
+ {
+// AddressBarCancelledClicked(*__pAddressbar);
+ RelayoutControls(false);
+// __pFooterPanel->SetShowState(false);
+ AppLogDebug("MainForm::OnActionPerformed find word clicked");
+ __currentSearchStr.Clear();
+ __currentSearchStr.Append(__currentSelectedStr);
+ InitFindWordPanel();
+ __pFindWordEditField->SetText(__currentSearchStr);
+
+ if(__pOptionMenu != null)
+ {
+ __pOptionMenu->SetShowState(false);
+ __pOptionMenu->Invalidate(false);
+ }
+ __adressPanelPosition.y = 0;
+
+ if (__pAddressbar != null && __pWebViewer != NULL)
+ {
+ __webControlPosition.y = __pAddressbar->GetHeight() - 12;
+ __webControlPositionF.y = __pAddressbar->GetHeightF() - 12.0f;
+ __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
+ __webControlHeightF = GetClientAreaBoundsF().height - __pFooterPanel->GetHeightF() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeightF() - 12.0f);
+
+ if (__pFooterPanel->GetShowState() == false)
+ __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
+ else
+ __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
+ __pWebViewer->Invalidate(true);
+ }
+
+ ShowFindWordPanel(true);
+ if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
+ {
+ __pFindWordEditField->SetText(__currentSearchStr);
+ __pFindWordEditField->SetFocus();
+ }
+ else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
+ {
+ __pFindWordEditFieldRightToLeft->SetText(__currentSearchStr);
+ __pFindWordEditFieldRightToLeft->SetFocus();
+ }
+
+ if (__currentSearchStr.GetLength() > 0)
+ {
+ StartWordSearch();
+ }
+ else
+ {
+ AppLogDebug("Enter something");
+ }
+
+ if (__pWebViewer != null)
+ {
+ // releasing the set block
+ __pWebViewer->ReleaseBlock();
+ }
+
+ }
+ break;
+ case IDA_SHARE_TEXT_CLICKED:
+ {
+ __pWebViewer->ReleaseBlock();
+ AppLogDebug("IDA_SHARE_TEXT_CLICKED");
+ if(__pPopUp != null)
+ {
+ delete __pPopUp;
+ __pPopUp = null;
+ }
+ if(__pAddressbar)
+ {
+ __pAddressbar->HideKeypad();
+ }
+ __pPopUp = new(std::nothrow) SharePopup();
+ __pPopUp->Initialize();
+ if (__pHitElementResult != null)
+ {
+ ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
+ pShareInfo->SetPageTitle(L"");
+ pShareInfo->SetPageUrl(__currentSelectedStr);
+ pShareInfo->SetImageAttached(false);
+ __pPopUp->RemoveAllShareInfo();
+ __pPopUp->AddShareInfo(pShareInfo);
+ __pPopUp->SetShowState(true);
+ __pPopUp->Show();
+ }
+ }
+ break;
+ case IDA_COPY_TEXT_CLICKED:
+ {
+// __pWebViewer->ReleaseBlock();//as per hyunn lee request for issue 53500
+ // need to implement
+ //__currentSelectedStr
+ // Sets data to a clip board item
+ ClipboardItem item;
+ String resourcePath = App::GetInstance()->GetAppResourcePath();
+ item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
+
+ // copying the item to clipboard
+ Clipboard* pClipboard = Clipboard::GetInstance();
+ if (pClipboard != null)
+ {
+ pClipboard->CopyItem(item);
+ }
+ }
+ break;
+ case IDA_PASTE_TEXT_CLICKED:
+ {
+ Clipboard* pClipboard = Clipboard::GetInstance();
+
+ if(pClipboard == null)
+ {
+ return;
+ }
+ // Retrieves a latest item
+ ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
+
+ if(pItem == null)
+ {
+ return;
+ }
+ //Gets data from the clipboard item
+ String* pString = dynamic_cast<String*>(pItem->GetData());
+
+ if (pString != null)
+ {
+ String idElement = __pHitElementResult->GetAttributeValue(L"id");
+ String nameElement = __pHitElementResult->GetAttributeValue(L"name");
+ String classElement = __pHitElementResult->GetAttributeValue(L"class");
+ String tagElement = __pHitElementResult->GetTagName();
+ String contenteditable = __pHitElementResult->GetAttributeValue("contenteditable");
+ AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
+ String str = L"document.getElementsByName('";
+ str.Append(nameElement);
+ str.Append("').length");
+ String* pNameCount = __pWebViewer->EvaluateJavascriptN(str);
+
+ str.Clear();
+ str = L"document.getElementsByClassName('";
+ str.Append(classElement);
+ str.Append("').length");
+ String* pClassCount = __pWebViewer->EvaluateJavascriptN(str);
+
+ String script;
+ if(contenteditable.Equals(L"true",false) == true)
+ {
+ AppLog("gmail paste need to support");
+
+ script = L"function replaceSelectedText(replacementText) { var sel, range; if (window.getSelection) { sel = window.getSelection(); if (sel.rangeCount) { range = sel.getRangeAt(0); range.deleteContents(); range.insertNode(document.createTextNode(replacementText)); } } else if (document.selection && document.selection.createRange) { range = document.selection.createRange(); range.text = replacementText; } }";
+ script.Append("replaceSelectedText(");
+ script.Append("\"");
+ script.Append(*pString);
+ script.Append("\");");
+ }
+ else if(idElement.GetLength() != 0)
+ {
+ script = L"function insertAtCursor(myField, myValue) { if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0'){ var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } ";
+ script.Append("insertAtCursor(");
+ script.Append(L"document.activeElement");
+ script.Append(",");
+ script.Append("\"");
+ script.Append(*pString);
+ script.Append("\");");
+ }
+ else if (classElement.GetLength() != 0 && pClassCount->Equals("1",false) == true)
+ {
+ script = L"function insertAtCursor(myField, myValue) { if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0'){ var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } ";
+ script.Append("insertAtCursor(document.getElementsByClassName('");
+ script.Append(classElement);
+ script.Append("')[0],");
+ script.Append("\"");
+ script.Append(*pString);
+ script.Append("\");");
+ }
+ else if (nameElement.GetLength() != 0 && pNameCount->Equals("1",false) == true)
+ {
+ script = L"function insertAtCursor(myField, myValue) { if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0'){ var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } ";
+ script.Append("insertAtCursor(document.getElementsByName('");
+ script.Append(nameElement);
+ script.Append("')[0],");
+ script.Append("\"");
+ script.Append(*pString);
+ script.Append("\");");
+ }
+ else if(tagElement.GetLength() != 0) //adding for twitter post page
+ {
+ script = L"function insertAtCursor(myField, myValue) { if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0'){ var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } ";
+
+ script.Append("insertAtCursor(document.activeElement,");
+ script.Append("\"");
+ script.Append(*pString);
+ script.Append("\");");
+ }
+ AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
+ String* pStr = __pWebViewer->EvaluateJavascriptN(script);
+ delete pStr;
+ delete pNameCount;
+ delete pClassCount;
+ }
+ delete pItem;
+ if(__pWebViewer)
+ __pWebViewer->ReleaseBlock();
+ }
+ break;
+ case IDA_GO_BACK:
+ {
+ OnBackClicked();
+ }
+ break;
+ case IDA_GO_FORWARD:
+ {
+ OnForwardClicked();
+ }
+ break;
+ case IDA_REFRESH_BTN_CLICKED:
+ {
+ __isLoadingCompleted = false;
+ __isLoadingData = true;
+ __progressPercentage = 0;
+ __displayUrl = __pFooterUrlField->GetText();
+
+ String url = __pFooterUrlField->GetText();
+ AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
+// LoadUrl(url);
+ if (__pWebViewer != null && __pAddressbar != null)
+ {
+ LoadUrl(url);
+ //__pWebViewer->Reload();
+ SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
+ }
+
+ //OnUrlSubmitted();
+ UpdateProgressBitmap();
+ }
+ break;
+ case IDA_STOP_BTN_CLICKED:
+ {
+ __isLoadingCompleted = false;
+ __isLoadingData = false;
+ __progressPercentage = 0;
+ __pFooterUrlField->HideKeypad();
+ __displayUrl = __pFooterUrlField->GetText();
+
+ if (__pWebViewer)
+ {
+ //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
+ SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
+ __pWebViewer->StopLoading();
+ RequestRedraw(true);
+ }
+
+ UpdateProgressBitmap();
+ }
+ break;
+ case IDA_CLEAR_URL:
+ {
+ if (__pFooterUrlField->GetText().IsEmpty() == false)
+ {
+ //__displayUrl = __pUrlField->GetText();
+ __pFooterUrlField->Clear();
+
+ }
+ }
+ break;
+ case IDA_READER_BTN_CLICKED:
+ {
+ ReaderClicked();
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void
+MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
+{
+ AppLog("MainForm::OnFormBackRequested entered");
+ result r = E_FAILURE;
+ if(__pImageMenu && __pImageMenu->GetShowState() == true)
+ {
+ AppLog("Hiding the menu");
+ __pImageMenu->SetShowState(false);
+ }
+ if (__pWebViewer && __pWebViewer->CanGoBack())
+ {
+ __pWebViewer->GoBack();
+ }
+ else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
+ {
+ UiApp* pApp = null;
+ pApp = UiApp::GetInstance();
+ if (pApp != null)
+ {
+ r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
+ if (IsFailed(r))
+ {
+ AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
+ return;
+ }
+ }
+ }
+ else
+ {
+ UiApp* pApp = null;
+ WindowInfo* pWindowInfo = null;
+ int totalCount = 0;
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+ if (pSceneManager == null)
+ {
+ return;
+ }
+ ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
+ if (pAllWindowList == NULL)
+ {
+ pApp = UiApp::GetInstance();
+ if (pApp != null)
+ {
+ r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
+ if (IsFailed(r))
+ {
+ AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
+ return;
+ }
+ }
+ }
+ if (pAllWindowList != null)
+ {
+ totalCount = pAllWindowList->GetCount();
+ }
+ for (int count = 0; count < totalCount; count++)
+ {
+ pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
+ if (pWindowInfo == null)
+ {
+ pApp = UiApp::GetInstance();
+ if (pApp != null)
+ {
+ r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
+ if (IsFailed(r))
+ {
+ AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
+ return;
+ }
+ }
+ }
+ else
+ {
+ if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
+ {
+ r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
+ if (IsFailed(r))
+ {
+ AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
+ return;
+ }
+ r = pAllWindowList->RemoveAt(count, true);
+ __pWindowInfo = null;
+ if (IsFailed(r))
+ {
+ AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
+ return;
+ }
+ if(count > 0)
+ {
+ pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
+ }
+ else
+ {
+ pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
+ }
+ if (pWindowInfo == null)
+ {
+ pApp = UiApp::GetInstance();
+ if (pApp != null)
+ {
+ r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
+ return;
+ }
+ }
+ else
+ {
+ if(pWindowInfo != null)
+ r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
+ if (IsFailed(r))
+ {
+ AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
+ return;
+ }
+ }
+ break;
+ }
+// else if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == false)
+// {
+// UiApp* pApp = null;
+// pApp = UiApp::GetInstance();
+// if (pApp != null)
+// {
+// r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
+// if (IsFailed(r))
+// {
+// AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
+// return;
+// }
+// }
+// }
+ }
+ }
+ }
+ AppLog("MainForm::OnFormBackRequested exit");
+}
+
+void
+MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
+ const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
+{
+
+ AppLog("MainForm::OnSceneActivatedN called");
+ String* pSelectedScene = NULL;
+ Object* pValue = NULL;
+ String* pUrl = null;
+ MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
+ pSelectedScene = (String*) pValue;
+
+ if (pSelectedScene != null)
+ {
+ delete pSelectedScene;
+ }
+ MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
+ String* selectedSceneID = new(std::nothrow) String(currentSceneId);
+ AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
+ AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
+
+ // setting the current scene ID
+ MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
+
+ MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
+
+ if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
+ {
+ __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
+ if(__pWindowInfo == null)
+ return;
+ // if(__pWindowInfo == null)
+ {
+ pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
+ }
+ }
+ else if ( pArgs != null && pArgs->GetCount() == 1)
+ {
+ __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
+ }
+
+ InitFooter();
+ InitAddressbar();
+
+ FloatRectangle footerPanelBounds = FloatRectangle(0.0f, (GetClientAreaBoundsF().height) - __pFooterPanel->GetHeightF(), GetClientAreaBoundsF().width, __pFooterPanel->GetHeightF());
+ __pFooterPanel->SetBounds(CoordinateSystem::AlignToDevice(footerPanelBounds));
+
+ // hiding the address bar
+ // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
+ __pAddressbar->SetShowState(false);
+// if(__pWebViewer != null)
+// {
+// __pWebViewer->Resume();
+// }
+
+ if(pUrl != null && pUrl->GetLength() > 0)
+ {
+ LoadUrl(*pUrl);
+ }
+ else if(__pWindowInfo != null)
+ {
+ 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)
+ {
+ LoadUrl(__pWindowInfo->pageUrl);
+ }
+ else if(__pWindowInfo->pageUrl.GetLength() > 0 && __pWindowInfo->isAppcontrolTriggered == true)
+ {
+ LoadUrl(__pWindowInfo->pageUrl);
+ __pWindowInfo->isAppcontrolTriggered = false;
+ }
+ else if (__pWindowInfo->isJavascriptInitiated == true && __pWindowInfo->isFirstLaunch == true)
+ {
+ __pWindowInfo->isFirstLaunch = false;
+ AppLog("Called");
+ InitWebControl();
+ __pWindowInfo->pCurrentWeb = __pWebViewer;
+ if(__pWindowInfo->pageUrl.GetLength() > 0)
+ LoadUrl(__pWindowInfo->pageUrl);
+ }
+ }
+
+ String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
+ AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
+ if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
+ {
+ InitMostVisitedSitesView(GetOrientationStatus());
+ }
+ else
+ {
+ if(__pMostVisitedListView != null)
+ {
+ __pMostVisitedListView->SetShowState(false);
+ }
+ }
+
+ if(__pMostVisitedListView && __pMostVisitedListView->GetShowState() == true)
+ {
+ __pMostVisitedListView->UpdateList();
+ }
+ if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
+ {
+ String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
+
+ if (pBookmarkUrl == null)
+ return;
+ AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
+ //__pAddressbar->SetUrl(*pBookmarkUrl);
+ SetUrl(*pBookmarkUrl);
+
+ if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
+ __pWebViewer->LoadUrl(*pBookmarkUrl);
+ delete pBookmarkUrl;
+ }
+
+ bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
+ Bitmap* pBitmap = null;
+ if (isPrivateBrowsing == true)
+ {
+ pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
+
+ if (__pWebViewer != null)
+ {
+ __pWebViewer->SetPrivateBrowsingEnabled(true);
+ }
+
+ if (__pAddressbar != null)
+ {
+ // __pAddressbar->UpdateFaviconBitmap(true);
+ }
+
+ }
+ else
+ {
+ pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
+
+ if (__pWebViewer != null)
+ {
+ __pWebViewer->SetPrivateBrowsingEnabled(false);
+ }
+
+ if (__pAddressbar != null)
+ {
+ // __pAddressbar->UpdateFaviconBitmap(false);
+ }
+ }
+
+ if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
+ {
+ __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
+ }
+ else if (__pOptionMenu != null )
+ {
+ __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
+ }
+
+ if (pBitmap != null)
+ {
+ delete pBitmap;
+ }
+
+ RelayoutControls(false);
+ AppLog("ABC: OnSceneActivatedN started exit");
+ if(__pWebViewer)
+ {
+ AppLog("WebControl's width height %d %d,",__pWebViewer->GetWidth(),__pWebViewer->GetHeight());
+ __pWebViewer->Resume();
+ }
+
+}
+
+void
+MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
+ const Tizen::Ui::Scenes::SceneId& nextSceneId)
+{
+ Canvas* pWebCanvas = null;
+ if (__pWebViewer != null)
+ {
+ pWebCanvas = __pWebViewer->GetCanvasN();
+
+ }
+ if (pWebCanvas == null)
+ {
+ return;
+ }
+ if (__pWindowInfo != null)
+ {
+ if (__pWindowInfo->pWebCanvasBitmap != null)
+ {
+ delete __pWindowInfo->pWebCanvasBitmap;
+ }
+ __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
+ result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
+ AppLog("Bitmap Construction result %s",GetErrorMessage(r));
+ }
+ Bitmap* pBitmap = GetCapturedBitmapN();
+ AppLog("Coming here");
+ Canvas* pCanvas = new(std::nothrow) Canvas();
+ pCanvas->Construct(GetClientAreaBounds());
+ if(pBitmap != null)
+ {
+ pCanvas->DrawBitmap(Point(0,0),*pBitmap);
+ delete pBitmap;
+ }
+ if(__pWebViewer != null && __pWindowInfo != null && __pWindowInfo->pWebCanvasBitmap != null)
+ pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
+
+ WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
+ if (__pFooterPanel)
+ {
+ WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
+ }
+ delete pCanvas;
+ delete pWebCanvas;
+ if(__pAddressbar)
+ __pAddressbar->SetShowState(false);
+ if(__pWebViewer)
+ {
+ __pWebViewer->Pause();
+ }
+ AppLog("Coming here");
+}
+
+bool
+MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
+ const Tizen::Base::String& realm,
+ const Tizen::Web::Controls::AuthenticationChallenge& authentication)
+{
+ return false;
+}
+
+void
+MainForm::OnHttpAuthenticationCanceled(void)
+{
+}
+
+void
+MainForm::OnLoadingStarted(void)
+{
+ AppLogDebug("MainForm::OnLoadingStarted entered");
+ __isLoaded = true;
+ if(__pAddressbar == NULL || __pWebViewer == null)
+ {
+ return;
+ }
+
+ // this is added in case if menu is opened and user load the page
+ if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
+ {
+ __pOptionMenu->SetShowState(false);
+ __pOptionMenu->Invalidate(true);
+ }
+
+
+
+ if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
+ {
+ __pImageMenu->SetShowState(false);
+ __pImageMenu->Invalidate(true);
+ }
+ String url = __pWebViewer->GetUrl();
+ if(url.Contains(IDS_TIZEN_SERVICE))
+ {
+ String appId;
+ String delim(L":;,");
+
+ // Creates a StringTokenizer instance
+ StringTokenizer strTok(url, delim);
+
+ int count = strTok.GetTokenCount(); // count == 4
+
+ HashMap *pMap = new HashMap();
+ pMap->Construct();
+ String token;
+ String key;
+ String value;
+ while (strTok.HasMoreTokens())
+ {
+ AppLog("Token: %ls", token.GetPointer());
+ strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
+ if(token.Contains(IDS_APPID))
+ {
+ token.SubString(6, appId);
+ AppLog("AppID:%ls", appId.GetPointer());
+ }
+ else if(token.Contains(IDS_KEY))
+ {
+ token.SubString(4, key);
+ AppLog("key:%ls", key.GetPointer());
+ }
+ else if(token.Contains(IDS_VALUE))
+ {
+ token.SubString(6, value);
+ AppLog("value:%ls", value.GetPointer());
+ }
+ }
+ pMap->Add(key, value);
+
+ if(appId != "")
+ {
+ AppControl *pAppControl = null;
+ String operationId = L"http://tizen.org/appcontrol/operation/main";
+ pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
+ if(pAppControl)
+ {
+ AppLog("Starting AppControl");
+ result r = pAppControl->Start(null, null, pMap, null);
+ AppLog("Result of Start %s", GetErrorMessage(r));
+ }
+ else
+ {
+ AppLogException("AppControl not found");
+ }
+ return;
+ }
+ }
+ if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
+ {
+ __pAddressbar->SetShowState(false);
+ AddressBarCancelledClicked(*__pAddressbar);
+ __pAddressbar->Invalidate(true);
+ }
+ Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
+ if(pBitmap != null)
+ {
+ __pAddressbar->SetFaviconBitmap(*pBitmap);
+ }
+ delete pBitmap;
+ if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
+ {
+ // updating the address bar position with respect to web control
+ __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
+ __distanceMoved = 0;
+ MoveUiControls();
+ }
+
+ //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
+ SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
+ if (__pWebViewer != null)
+ {
+ AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
+ //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
+ SetUrl(__pWebViewer->GetUrl());
+ if (__pWindowInfo != NULL)
+ {
+ // resetting the page title to blank, it will be received in OnPageTitleReceived()
+// __pWindowInfo->pageTitle = L"";
+ __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
+ }
+ __pAddressbar->Invalidate(true);
+ }
+
+}
+
+void
+MainForm::OnLoadingCanceled(void)
+{
+
+}
+
+void
+MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
+{
+ AppLog("XYZ::MainForm::OnKeypadWillOpen");
+
+}
+
+void
+MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
+{
+ AppLog("XYZ::MainForm::OnKeypadOpened");
+ __isKeypadOpened = true;
+ __pFooterPanel->SetShowState(false);
+ RelayoutControls(false);
+}
+
+void
+MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
+{
+ AppLog("XYZ::MainForm::OnKeypadClosed");
+ __isKeypadOpened = false;
+ __pFooterPanel->SetShowState(true);
+ RelayoutControls(true);
+}
+
+void
+MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
+{
+ AppLog("XYZ::KeypadBoundsChanged");
+ RelayoutControls(false);
+}
+
+void
+MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
+ const Tizen::Base::String& reason)
+{
+ AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
+}
+
+void
+MainForm::OnLoadingCompleted(void)
+{
+ AppLog("MainForm::OnLoadingCompleted start");
+ DateTime date;
+ result r = E_SUCCESS;
+
+ if (__pWebViewer == null)
+ {
+ return;
+ }
+
+ if (__pAddressbar == null)
+ {
+ return;
+ }
+
+ if(__pWindowInfo && __pWebViewer)
+ __pWindowInfo->pageTitle = __pWebViewer->GetTitle();
+ if(__pImageMenu && __pImageMenu->GetShowState())
+ {
+ __pImageMenu->SetShowState(false);
+ __pImageMenu->Invalidate(true);
+ }
+
+ if (__pWebViewer->CanGoForward())
+ {
+ //__pAddressbar->SetForwardButtonEnabled(true);
+ SetForwardButtonEnabled(true);
+ }
+ else
+ {
+ //__pAddressbar->SetForwardButtonEnabled(false);
+ SetForwardButtonEnabled(false);
+ }
+
+ /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
+ {
+ __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
+
+ //__pAddressbar->UpdateProgress(0);
+ UpdateProgress(0);
+ }*/
+
+ if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
+ {
+ SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
+ UpdateProgress(0);
+ }
+
+ AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
+ bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
+ if (isPrivateBrowsing == false)
+ {
+ if(__pHistory != null)
+ {
+ delete __pHistory;
+ __pHistory = null;
+ }
+
+ __pHistory = new(std::nothrow) History;
+ HistoryPresentationModel::GetCurrentDateTime(date);
+ if (__pWindowInfo)
+ {
+ __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
+ AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
+
+ __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
+ AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
+ }
+ __pHistory->SetVisitedTime(date);
+
+ if (__pWebViewer != null)
+ {
+ AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
+
+ Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
+ if (pTempBitmap != null)
+ {
+ AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
+ __pHistory->SetFavIconBitmap(*pTempBitmap);
+ }
+
+ }
+
+ Canvas* pCanvas = __pWebViewer->GetCanvasN();
+ Bitmap* pBitmap = new(std::nothrow) Bitmap();
+ if ( pCanvas != null && pCanvas != null && pBitmap != null)
+ {
+ pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
+ pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
+ __pHistory->SetThumbnail(pBitmap);
+ }
+ Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
+ if (pFavIcon)
+ {
+ Tizen::Graphics::BufferInfo bmpInfo;
+ pFavIcon->Lock(bmpInfo);
+ AppLog("rrrr:: width %d height %d of the faviconbitmap from bufferinfo", bmpInfo.width, bmpInfo.height);
+
+ AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
+
+ AppLog("rrrr:: width %d height %d of the faviconbitmap",pFavIcon->GetWidth(),pFavIcon->GetHeight());
+ __pHistory->SetFavIconBitmap(*pFavIcon);
+ delete pFavIcon;
+ }
+
+ HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
+ //delete pHistory;
+ }
+ else
+ {
+ return;
+ }
+// if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
+ {
+ // temperary fixed (webpage can be not loaded)
+ UpdateFavicon();
+ }
+
+ bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
+ if (isReaderEnabled == true)
+ {
+ if (__pReaderData)
+ {
+ delete __pReaderData;
+ __pReaderData = null;
+ }
+ String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
+ filePath.Append(L"data/reader.js");
+ File file;
+ char buffer[10];
+ char buffer2[5];
+ int i;
+ int readCnt;
+ result r = E_SUCCESS;
+ FileAttributes attr;
+
+ File::GetAttributes(filePath,attr);
+ // Creates file
+ r = file.Construct(filePath, L"r+");
+ if (IsFailed(r))
+ {
+ AppLogDebug("File construct failed with %s", GetErrorMessage(r));
+ return;
+ }
+ char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
+ if(pScript == null)
+ {
+ AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
+ return;
+ }
+// file.Read(pScript,attr.GetFileSize());
+//
+// AppLogDebug("scipt length %d",strlen(pScript));
+ String strScript = L"";
+// strScript.Append(pScript);
+// for(int i=0; i<25; i++)
+ {
+ file.Read(pScript,attr.GetFileSize());
+// AppLog("xyzz tell %d",file.Tell());
+// r = strScript.Append(pScript);
+// AppLog("xyzz append result %s",GetErrorMessage(r));
+// AppLog("xyzz strScript length %d",strScript.GetLength());
+ }
+// AppLog("xyzz final strScript length %d",strScript.GetLength());
+
+ __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
+ if (__pReaderData == null)
+ {
+ AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
+ __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>");
+// return;
+ }
+ AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
+ if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
+ {
+ //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
+ SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
+ }
+ delete[] pScript;
+ }
+
+
+ AppLog("MainForm::OnLoadingCompleted done");
+}
+
+void
+MainForm::OnEstimatedProgress(int progress)
+{
+ AppLogDebug("MainForm::OnEstimatedProgress entered %d",progress);
+
+ if (progress < DEFAULT_PROGRESS_PERCENTAGE)
+ progress = DEFAULT_PROGRESS_PERCENTAGE;
+ //if(__pAddressbar)
+ // __pAddressbar->UpdateProgress(progress);
+ UpdateProgress(progress);
+}
+
+void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
+{
+ AppLog("MainForm::OnFaviconReceived");
+ if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
+ {
+ Bitmap* favIcon = __pWebViewer->GetFaviconN();
+ if(favIcon != null)
+ {
+ HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
+ delete favIcon;
+ }
+ }
+}
+
+void
+MainForm::OnUrlValueChanged(Addressbar&)
+{
+ Invalidate(true);
+}
+
+void
+MainForm::OnUrlSubmitted(Addressbar& addBar)
+{
+ AppLog("MainForm::OnUrlSubmitted");
+ String url = addBar.GetUrl();
+ AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
+
+
+ if(__pFooterUrlField)
+ {
+ AppLog("Position:: %d, %ls",__pFooterUrlField->GetTextLength(),__pFooterUrlField->GetText().GetPointer());
+ __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
+ }
+ AddressBarCancelledClicked(*__pAddressbar);
+ LoadUrl(url);
+}
+
+void
+MainForm::LoadUrl(String& url)
+{
+ url.Trim();
+ String encodedUrl;
+// UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
+ AppLogDebug("MainForm::LoadUrl enter");
+
+ if (__pWebViewer != null)
+ {
+ __pWebViewer->SetShowState(true);
+ __pWebViewer->Invalidate(true);
+ }
+
+ if (url.CompareTo(L"") == 0)
+ {
+ return;
+ }
+ if(__pFooterPanel != null)
+ {
+ __pFooterPanel->SetShowState(true);
+ __pFooterPanel->Invalidate(true);
+ }
+ InitWebControl();
+
+ bool ret = false;
+ bool flag = false;
+
+ String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
+ 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)
+
+ RegularExpression firstRegex;
+ RegularExpression secondRegex;
+
+ firstRegex.Construct(firstPattern, REGEX_CASELESS);
+ secondRegex.Construct(secondPattern, REGEX_CASELESS);
+
+ // Match
+ ret = firstRegex.Match(url, false); // This returns true value
+ flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
+
+
+
+ if (ret == true && __pWebViewer != null)
+ {
+ SetUrl(url);
+ __pWebViewer->LoadUrl(url);
+ }
+ else if(__pWebViewer != null)
+ {
+ String tempUrl = L"http://";
+ tempUrl.Append(url);
+
+ if (flag == true)
+ {
+ __pWebViewer->LoadUrl(tempUrl);
+ }
+ else
+ {
+ UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
+ __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
+ }
+ }
+ if (__pAddressbar != null)
+ {
+ //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
+ SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
+ }
+
+ AppLogDebug("MainForm::LoadUrl exit");
+
+ return;
+
+}
+
+void
+MainForm::OnFocusGained(const Tizen::Ui::Control& source)
+{
+ AppLog("MainForm::OnFocusGained");
+ if(__pFooterPanel)
+ {
+ __pFooterPanel->SetShowState(false);
+ }
+
+ if(__pWebViewer)
+ {
+ __pWebViewer->ReleaseBlock();
+ }
+
+ if(__pAddressbar)
+ {
+ __pAddressbar->SetShowState(true);
+ __pAddressbar->SetAddressbarURLFocus();
+ }
+ if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
+ {
+ __currentSearchStr = L"";
+ __currentWordIndex = 0;
+ __maxOccurrances = 0;
+
+ if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
+ {
+ __pFindWordEditField->SetText(L"");
+ __pFindWordEditField->HideKeypad();
+ __pFindWordControl->SetShowState(false);
+ __pFindWordCountLabel->SetText(L"0/0");
+ }
+ else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
+ {
+ __pFindWordEditFieldRightToLeft->SetText(L"");
+ __pFindWordEditFieldRightToLeft->HideKeypad();
+ __pFindWordControl->SetShowState(false);
+ __pFindWordCountLabelRightToLeft->SetText(L"0/0");
+ }
+
+ __pFindWordNext->SetEnabled(false);
+ __pFindWordPrev->SetEnabled(false);
+
+ if(__pWebViewer)
+ __pWebViewer->SearchTextAllAsync(L"",true);
+ __pFindWordControl->SetShowState(false);
+ }
+ RelayoutControls(false);
+}
+
+void
+MainForm::OnFocusLost(const Tizen::Ui::Control& source)
+{
+ AppLog("MainForm::OnFocusLost called");
+}
+
+void
+MainForm::OnStopClicked(Addressbar& addBar)
+{
+ AppLogDebug("MainForm::OnStopClicked called");
+ if (__pWebViewer)
+ {
+ //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
+ SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
+ __pWebViewer->StopLoading();
+ RequestRedraw(true);
+ }
+}
+
+void
+MainForm::OnBackClicked(/*const Addressbar& addBar*/)
+{
+ // AppLog("MainForm::OnBackClicked");
+ result r = E_FAILURE;
+ if(__pImageMenu && __pImageMenu->GetShowState() == true)
+ {
+ AppLog("Hiding the menu");
+ __pImageMenu->SetShowState(false);
+ }
+
+ if (__pWebViewer && __pWebViewer->CanGoBack())
+ {
+ __pWebViewer->GoBack();
+ }
+ else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
+ {
+ UiApp* pApp = null;
+ pApp = UiApp::GetInstance();
+ if (pApp != null)
+ {
+ r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
+ if (IsFailed(r))
+ {
+ AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
+ return;
+ }
+ }
+ }
+ else
+ {
+ UiApp* pApp = null;
+ WindowInfo* pWindowInfo = null;
+ int totalCount = 0;
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+ if (pSceneManager == null)
+ {
+ return;
+ }
+ ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
+ if (pAllWindowList == NULL)
+ {
+ pApp = UiApp::GetInstance();
+ if (pApp != null)
+ {
+ r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
+ if (IsFailed(r))
+ {
+ AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
+ return;
+ }
+ }
+ }
+ if (pAllWindowList != null)
+ {
+ totalCount = pAllWindowList->GetCount();
+ }
+ for (int count = 0; count < totalCount; count++)
+ {
+ pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
+ if (pWindowInfo == null)
+ {
+ pApp = UiApp::GetInstance();
+ if (pApp != null)
+ {
+ r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
+ if (IsFailed(r))
+ {
+ AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
+ return;
+ }
+ }
+ }
+ if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
+ {
+ r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
+ if (IsFailed(r))
+ {
+ AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
+ return;
+ }
+ r = pAllWindowList->RemoveAt(count, true);
+ __pWindowInfo = null;
+ if (IsFailed(r))
+ {
+ AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
+ return;
+ }
+ if(count > 0)
+ {
+ pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
+ }
+ else if(pAllWindowList->GetCount() > 0)
+ {
+ pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
+ }
+ else
+ {
+ pApp = UiApp::GetInstance();
+ if (pApp != null)
+ {
+ r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
+ return;
+ }
+
+ }
+ if (pWindowInfo == null)
+ {
+ pApp = UiApp::GetInstance();
+ if (pApp != null)
+ {
+ r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
+ return;
+ }
+ }
+ else
+ {
+ r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
+// r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
+ if (IsFailed(r))
+ {
+ AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
+ return;
+ }
+ }
+ break;
+ }
+
+ }
+
+ }
+
+}
+
+void
+MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
+{
+ AppLog("MainForm::OnForwardClicked");
+ if (__pWebViewer == null)
+ return;
+
+ if (__pWebViewer->CanGoForward())
+ {
+ __pWebViewer->GoForward();
+ }
+}
+
+void
+MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
+{
+ AppLog("XYZ::MainForm::OnAddressBarFocusGained");
+ if(__pFooterPanel != null)
+ {
+ __pFooterPanel->SetShowState(false);
+ }
+
+ if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
+ {
+ __pAddressbar->SetShowState(true);
+ __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
+ }
+
+ RelayoutControls(false);
+}
+
+void
+MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
+{
+ AppLog("XYZ::MainForm::OnAddressBarFocusLost");
+
+ int Height = GetClientAreaBounds().height;
+ AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
+
+ RelayoutControls(false);
+}
+
+void
+MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
+{
+ AddressBarCancelledClicked(addBar);
+}
+
+void
+MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
+{
+ __prevAddressBarMode = __curAddressBarMode;
+
+ if (__pAddressbar != null)
+ {
+ __curAddressBarMode = GetAddressbarMode();
+ }
+
+ if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
+ {
+ __adressPanelPosition.y = 0;
+ if (__pAddressbar != null)
+ {
+ __webControlPosition.y = __pAddressbar->GetHeight() - 12;
+ __webControlPositionF.y = __pAddressbar->GetHeightF() - 12.0f;
+ __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
+ __pAddressbar->Invalidate(true);
+ }
+ if (__pWebViewer != null)
+ {
+ __pWebViewer->StopLoading();
+ }
+ }
+ else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
+ {
+ __adressPanelPosition.y = 0;
+ if (__pAddressbar != null)
+ {
+ __webControlPosition.y = 0;
+ __webControlPositionF.y = 0.0f;
+ __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
+ __pAddressbar->Invalidate(true);
+ }
+ }
+}
+
+void
+MainForm::OnClipboardClosed(const Addressbar& addBar)
+{
+ AppLog("XYZ::MainForm::OnClipboardClosed");
+ if (__pFooterPanel && __pAddressbar->GetShowState() == false)
+ {
+ AppLog("akjshdasd 3");
+ __pFooterPanel->SetShowState(true);
+ }
+ __isKeypadOpened = false;
+ RelayoutControls(false);
+}
+
+void
+MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
+{
+ AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
+ if (__pFooterPanel && __pAddressbar->GetShowState() == false)
+ {
+ AppLog("akjshdasd 3");
+ __pFooterPanel->SetShowState(true);
+ }
+ __isKeypadOpened = false;
+ if(__pNotification && __pNotification->GetShowState())
+ {
+ __pNotification->SetPosition(0,GetClientAreaBounds().height - __pNotification->GetHeight());
+ }
+
+ RelayoutControls(false,footerState);
+}
+
+void
+MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
+{
+ AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
+ __isKeypadOpened = true;
+ if(__pNotification && __pNotification->GetShowState())
+ {
+ __pNotification->SetPosition(0,GetClientAreaBounds().height - __pNotification->GetHeight());
+ }
+ RelayoutControls(false);
+}
+
+void
+MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
+{
+ __isKeypadOpened = true;
+ __pFooterPanel->SetShowState(false);
+}
+
+void
+MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
+{
+ AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
+ RelayoutControls(false);
+}
+
+void
+MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
+{
+ AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
+ if (__pWindowInfo)
+ {
+ __pWindowInfo->pageTitle = title;
+ if (__pWebViewer != null)
+ {
+ __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
+ AppLog("MainForm::OnPageTitleReceived url %ls",__pWindowInfo->pageUrl.GetPointer());
+ }
+ }
+ if (__pAddressbar != null && __pWebViewer != null)
+ {
+ SetUrl(__pWebViewer->GetUrl());
+ __pAddressbar->Invalidate(true);
+ }
+}
+
+void
+MainForm::UpdateFavicon(void)
+{
+ AppLog("MainForm::UpdateFavicon called");
+ bool urlImageType = false;
+ String *tempPath = null;
+ if(__pWebViewer)
+ 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();");
+ Bitmap* pBitmap = null;
+
+ if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
+ {
+ if (__pWindowInfo != null)
+ {
+ Uri url;
+ url.SetUri(*tempPath);
+ if (url.GetHost().GetLength() == 0)
+ {
+ Uri webUrl;
+ if(__pWebViewer)
+ webUrl.SetUri(__pWebViewer->GetUrl());
+ result r = url.SetHost(webUrl.GetHost());
+ if(IsFailed(r))
+ {
+ delete tempPath;
+ return;
+ }
+ }
+ if (url.GetScheme().GetLength() == 0)
+ {
+ Uri webUrl;
+ if(__pWebViewer)
+ webUrl.SetUri(__pWebViewer->GetUrl());
+ url.SetScheme(webUrl.GetScheme());
+ }
+ __pWindowInfo->faviconUrl = url.ToString();
+
+ pBitmap = __pWebViewer->GetFaviconN();
+
+ if (pBitmap != null)
+ {
+ AppLog("__pWindowInfo->pFavicon updating favicon");
+ if (__pWindowInfo->pFavicon != NULL)
+ {
+ __pWindowInfo->pFavicon = null;
+ }
+ __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
+ __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
+
+ __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
+
+ FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
+ }
+ else if(__pWindowInfo->pFavicon != null)
+ {
+ __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
+ }
+ else
+ {
+ Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
+ if(pDefaultBmp != null)
+ {
+ __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
+ }
+ }
+ if(pBitmap)
+ {
+ delete pBitmap;
+ pBitmap = null;
+ }
+ }
+ delete tempPath;
+ }
+ else
+ {
+ // do not remove
+ if(tempPath != null)
+ {
+ delete tempPath;
+ }
+ AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
+ }
+
+}
+
+bool
+MainForm::OnLoadingRequested(const Tizen::Base::String& url,
+ Tizen::Web::Controls::WebNavigationType type)
+{
+ AppLog("urlk %ls",url.GetPointer());
+ // when load new page if find word panel is open its show state is false
+ if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
+ {
+ __currentSearchStr = L"";
+ __currentWordIndex = 0;
+ __maxOccurrances = 0;
+ __pFindWordEditField->SetText(L"");
+ __pFindWordNext->SetEnabled(false);
+ __pFindWordPrev->SetEnabled(false);
+ __pFindWordCountLabel->SetText(L"0/0");
+ __pFindWordControl->SetShowState(false);
+ __pFindWordEditField->HideKeypad();
+ RelayoutControls(false);
+ }
+
+ __pFooterPanel->Invalidate(true);
+
+ Uri uriInfo;
+ uriInfo.SetUri(url);
+
+ if(url.Contains(IDS_TIZEN_SERVICE))
+ {
+ String appId;
+ String delim(L":;,");
+
+ // Creates a StringTokenizer instance
+ StringTokenizer strTok(url, delim);
+
+ int count = strTok.GetTokenCount(); // count == 4
+
+ HashMap *pMap = new HashMap();
+ pMap->Construct();
+
+ String token;
+ String key;
+ String value;
+ while (strTok.HasMoreTokens())
+ {
+ AppLog("Token: %ls", token.GetPointer());
+ strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
+ if(token.Contains(IDS_APPID))
+ {
+ token.SubString(6, appId);
+ AppLog("AppID:%ls", appId.GetPointer());
+ }
+ else if(token.Contains(IDS_KEY))
+ {
+ token.SubString(4, key);
+ AppLog("key:%ls", key.GetPointer());
+ }
+ else if(token.Contains(IDS_VALUE))
+ {
+ token.SubString(6, value);
+ AppLog("value:%ls", value.GetPointer());
+ }
+ }
+ pMap->Add(key, value);
+
+ if(appId != "")
+ {
+ AppControl *pAppControl = null;
+ String operationId = L"http://tizen.org/appcontrol/operation/main";
+ pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
+ if(pAppControl)
+ {
+ result r = pAppControl->Start(null, null, pMap, null);
+ }
+ else
+ {
+ AppLogException("AppControl not found");
+ }
+ return true;
+ }
+ }
+
+ return false;
+}
+
+DecisionPolicy
+MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
+ const Tizen::Net::Http::HttpHeader& httpHeader)
+{
+ return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
+}
+
+void
+MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
+{
+ AppLog("LMN::MainForm::OnWebPageBlockSelected");
+// if(__isLongPressedDone == false)
+// return;
+
+ if (__pHitElementResult != null)
+ {
+ delete __pHitElementResult;
+ __pHitElementResult = null;
+ }
+
+ if (__pWebViewer != null)
+ {
+ AppLog("MainForm::OnWebPageBlockSelected web not null");
+ __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
+
+ if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false))
+ {
+ AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
+ __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
+ if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false))
+ {
+ __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
+ if(__pHitElementResult == null)
+ {
+ __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
+ }
+ }
+ AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
+ }
+ }
+
+ if (__pHitElementResult == null)
+ {
+ return;
+ }
+
+ if (__pHitElementResult->HasImage() != true)
+ {
+ String tagName = __pHitElementResult->GetTagName();
+ String type = __pHitElementResult->GetAttributeValue("type");
+ String contenteditable = __pHitElementResult->GetAttributeValue("contenteditable");
+
+
+ AppLog("TagName %ls",tagName.GetPointer());
+ __currentSelectedStr.Clear();
+ AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
+ __currentSelectedStr = __pWebViewer->GetTextFromBlock();
+ AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
+ if(tagName.Equals(L"TEXTAREA",false) == true)
+ {
+ AppLog("Tagnameseemstobe TEXTAREA");
+ }
+ else if(tagName.Equals(L"INPUT",false) == true)
+ {
+ AppLog("Tagnameseemstobe INPUT");
+ }
+
+ if (((tagName.Equals(L"INPUT",false) == true) || tagName.Equals(L"TEXTAREA",false) == true) || contenteditable.Equals(L"true",false) == true/*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0 )
+ {
+ AppLog("MainForm::OnWebPageBlockSelected show paste option");
+
+ InitSelectTextContextMenuF(FloatPoint(startPoint.x,startPoint.y + __pWebViewer->GetY()),true);
+ if(__pImageMenu)
+ {
+ __pImageMenu->SetShowState(true);
+ __pImageMenu->Show();
+ __pImageMenu->Invalidate(true);
+ }
+ }
+ else /*if(__isLongPressedDone == true)*/
+ {
+ AppLog("MainForm::OnWebPageBlockSelected no paste option");
+
+ if(__pHitElementResult->GetUrl().GetLength() > 0)
+ {
+ __currentSelectedStr.Clear();
+ __currentSelectedStr = __pHitElementResult->GetUrl();
+ }
+ InitSelectTextContextMenuF(FloatPoint(startPoint.x,startPoint.y + __pWebViewer->GetY()),false);
+ if(__pImageMenu)
+ {
+ __pImageMenu->SetShowState(true);
+ __pImageMenu->Show();
+ __pImageMenu->Invalidate(true);
+ }
+ }
+
+ AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
+ AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
+ AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
+ }
+
+}
+
+void
+MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
+{
+
+}
+
+Web*
+MainForm::OnWebWindowCreateRequested(void)
+{
+ AppLog("MainForm::OnWebWindowCreateRequested entered");
+ WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
+
+ if (pNewWindowInfo == null)
+ {
+ return null;
+ }
+ result r = E_SUCCESS;
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+ if (pSceneManager == NULL)
+ {
+ return null;
+ }
+ ArrayList* pArgList = new(std::nothrow) ArrayList();
+ if (pArgList == NULL)
+ {
+ return null;
+ }
+ r = pArgList->Construct();
+ if (r == E_SUCCESS)
+ {
+ pNewWindowInfo->isJavascriptInitiated = true;
+ pArgList->Add(*pNewWindowInfo);
+ r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
+ delete pArgList;
+ if (IsFailed(r))
+ {
+ AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
+ return null;
+ }
+ } else {
+ delete pArgList;
+ }
+
+ return pNewWindowInfo->pCurrentWeb;
+}
+
+void
+MainForm::OnWebWindowCloseRequested(Tizen::Web::Controls::Web& source)
+{
+ AppLog("OnWebWindowCloseRequested");
+ ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+ WindowInfo* pWindowInfo = null;
+ WindowInfo* pNewWindowInfo = null;
+ int totalCount = 0;
+ UiApp* pApp = null;
+ result r = E_FAILURE;
+
+ if (pAllWindowList != null)
+ {
+ totalCount = pAllWindowList->GetCount();
+ }
+
+ for (int count = 0; count < totalCount; count++)
+ {
+ pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
+
+ if (__pWindowInfo != null && pWindowInfo != null && __pWindowInfo->sceneID == pWindowInfo->sceneID)
+ {
+ r = SceneRegister::DestroyAndUnRegisterScene(__pWindowInfo->sceneID);
+ r = pAllWindowList->RemoveAt(count, true);
+
+ Form* pCurrentForm = null;
+ if(SceneManager::GetInstance()->GetCurrentScene() != null)
+ pCurrentForm = (SceneManager::GetInstance()->GetCurrentScene()->GetForm());
+ if (pCurrentForm)
+ {
+ pCurrentForm->SendUserEvent(UPDATE_MAINFORM_FOOTER_ON_WINDOWCLOSED, null);
+ }
+
+ if (pAllWindowList->GetCount() > 0)
+ {
+ pNewWindowInfo = null;
+ pNewWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
+ }
+ else
+ {
+ WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
+
+ if (pNewWindowInfo == null)
+ {
+ return;
+ }
+ result r = E_SUCCESS;
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+ if (pSceneManager == NULL)
+ {
+ return;
+ }
+ ArrayList* pArgList = new(std::nothrow) ArrayList();
+ if (pArgList == NULL)
+ {
+ return;
+ }
+ r = pArgList->Construct();
+ if (r == E_SUCCESS)
+ {
+ pArgList->Add(*pNewWindowInfo);
+ result r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
+ if (pArgList != null)
+ {
+ delete pArgList;
+ pArgList = null;
+ }
+ if(IsFailed(r))
+ {
+ AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
+ return;
+ }
+ }
+
+ pApp = UiApp::GetInstance();
+ if (pApp != null)
+ {
+ r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
+ return;
+ }
+ }
+ if(pNewWindowInfo)
+ r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
+
+ break;
+ }
+
+ }
+
+
+}
+
+void
+MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
+{
+ AppLog("xyz:: MainForm::RelayoutControls called");
+ __webControlPosition.y = 0;
+ __webControlPositionF.y = 0.0f;
+ __webControlHeight = GetClientAreaBounds().height;
+ __webControlHeightF = GetClientAreaBoundsF().height;
+ AppLog("Client area height: %d width %d", __webControlHeight,GetClientAreaBounds().width);
+
+ AppLog("Client area height: %d", __webControlHeight);
+ if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
+ {
+ __webControlPosition.y += __pAddressbar->GetHeight();
+ __webControlPositionF.y += __pAddressbar->GetHeightF();
+ __webControlHeight -= __pAddressbar->GetHeight();
+ __webControlHeightF -= __pAddressbar->GetHeightF();
+ __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
+ }
+ else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
+ {
+ __webControlPosition.y += __pFindWordControl->GetHeight();
+ __webControlPositionF.y += __pFindWordControl->GetHeightF();
+ __webControlHeight -= __pFindWordControl->GetHeight();
+ __webControlHeightF -= __pFindWordControl->GetHeightF();
+ __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
+ }
+
+ if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
+ {
+ __webControlHeight -= __pFooterPanel->GetHeight();
+ __webControlHeightF -= __pFooterPanel->GetHeightF();
+
+ __pFooterPanel->SetBounds(CoordinateSystem::AlignToDevice(FloatRectangle(0.0F, __webControlPositionF.y + __webControlHeightF, GetClientAreaBoundsF().width, __pFooterPanel->GetHeightF())));
+ __webControlHeight = __webControlHeight + 12;
+ __webControlHeightF = __webControlHeightF + 12.0f;
+ }
+
+
+
+ if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
+ {
+ if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight )
+ {
+ }
+ else
+ {
+ __pWebViewer->SetBounds(CoordinateSystem::AlignToDevice(FloatRectangle(0.0f, __webControlPositionF.y, GetClientAreaBoundsF().width, __webControlHeightF)));
+ AppLog("xyz:: MainForm::RelayoutControls called __webControlHeight %d",__webControlHeight);
+ __pWebViewer->Invalidate(false);
+ }
+ }
+
+ if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
+ {
+ __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
+ }
+
+ Invalidate(true);
+}
+
+void
+MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
+{
+ if (__pFindWordControl == null)
+ {
+ return;
+ }
+
+ Tizen::Locales::LocaleManager localeManager;
+ Tizen::Locales::Locale local = localeManager.GetSystemLocale();
+
+ String languageCode;
+ result r = SettingInfo::GetValue(L"Language", languageCode);
+ // int languagecode = local.GetLanguageCode();
+ AppLog("rahul language is %S", languageCode.GetPointer());
+
+ if (show == true)
+ {
+ InitFindWordPanel();
+
+ if (languageCode.CompareTo("ara") == 0)
+ {
+ AppLog("rahul language is arabic");
+
+ __pFindWordPanelLeftToRight->SetShowState(false);
+ __pFindWordPanelRightToLeft->SetShowState(true);
+
+ __pFindWordClear->SetShowState(false);
+ __pFindWordCountLabel->SetShowState(false);
+ __pFindWordEditField->SetShowState(false);
+
+ __pFindWordClearRightToLeft->SetShowState(true);
+ __pFindWordCountLabelRightToLeft->SetShowState(true);
+ __pFindWordEditFieldRightToLeft->SetShowState(true);
+ }
+ else
+ {
+ AppLog("rahul language is not arabic");
+
+
+ __pFindWordPanelLeftToRight->SetShowState(true);
+ __pFindWordPanelRightToLeft->SetShowState(false);
+
+ __pFindWordClear->SetShowState(true);
+ __pFindWordCountLabel->SetShowState(true);
+ __pFindWordEditField->SetShowState(true);
+
+ __pFindWordClearRightToLeft->SetShowState(false);
+ __pFindWordCountLabelRightToLeft->SetShowState(false);
+ __pFindWordEditFieldRightToLeft->SetShowState(false);
+ }
+ __pFindWordControl->SetShowState(true);
+ }
+ else
+ {
+ if(__pFindWordControl != null)
+ {
+ __pFindWordControl->SetShowState(false);
+ }
+ }
+
+ AppLog("MainForm::ShowFindWordPanel %d",show);
+ if (show && !isTouchPressed)
+ {
+ if (languageCode.CompareTo("ara") == 0)
+ {
+ if (__pFindWordEditFieldRightToLeft)
+ {
+ __pFindWordEditFieldRightToLeft->SetFocus();
+ __pFindWordEditFieldRightToLeft->ShowKeypad();
+ }
+ }
+ else
+ {
+ if (__pFindWordEditField)
+ {
+ __pFindWordEditField->SetFocus();
+ __pFindWordEditField->ShowKeypad();
+ }
+ }
+ }
+ else
+ {
+ if (languageCode.CompareTo("ara") == 0)
+ {
+ if (__pFindWordEditFieldRightToLeft)
+ __pFindWordEditFieldRightToLeft->HideKeypad();
+ }
+ else
+ {
+ if (__pFindWordEditField)
+ __pFindWordEditField->HideKeypad();
+ }
+ }
+
+ RelayoutControls(false);
+}
+
+void
+MainForm::StartWordSearch()
+{
+ //Get the count of occurances of the word in the current page
+ __maxOccurrances = 0;
+ __currentWordIndex = 0;
+
+ __pFindWordPrev->SetEnabled(false);
+ String *pCountStr = null;
+ if (__pWebViewer)
+ {
+ result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
+ AppLog("Search Result %s",GetErrorMessage(r));
+ }
+
+ /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
+ if (pCountStr != null)
+ {
+ Integer::Parse(*pCountStr, 10, __maxOccurrances);
+ delete pCountStr;
+ }
+
+ AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
+ */
+
+}
+
+void MainForm::OnTextFound(int totalCount, int currentOrdinal)
+{
+ AppLog("MainForm::OnTextFound totalCount %d",totalCount);
+ AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
+
+ if(totalCount <= 9)
+ {
+ if (__pFindWordCountLabel)
+ {
+ __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
+ }
+ if (__pFindWordEditField)
+ {
+ __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
+ }
+ }
+ else if(totalCount >= 100)
+ {
+ if (__pFindWordCountLabel)
+ {
+ __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
+ }
+ if (__pFindWordEditField)
+ {
+ __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
+ }
+ }
+ else
+ {
+ if (__pFindWordCountLabel)
+ {
+ __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
+ }
+ if (__pFindWordEditField)
+ {
+ __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
+ }
+ }
+
+ __maxOccurrances = totalCount;
+ __currentWordIndex = currentOrdinal;
+
+ //Reset the UI controls as per the maxOccurrance value
+ if (totalCount <= 0)
+ {
+ AppLog("Word not found");
+ //Show error notification to user
+ if(__pFindWordNext)
+ __pFindWordNext->SetEnabled(false);
+ if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
+ {
+ __pFindWordCountLabel->SetText(L"0/0");
+ __pFindWordCountLabel->Invalidate(false);
+ }
+ else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
+ {
+ __pFindWordCountLabelRightToLeft->SetText(L"0/0");
+ __pFindWordCountLabelRightToLeft->Invalidate(false);
+ }
+ if(__pFindWordNext)
+ __pFindWordNext->Invalidate(false);
+ __pFindWordPrev->Invalidate(false);
+
+ return;
+ }
+
+ if (totalCount == 1 || totalCount == currentOrdinal)
+ {
+ if(__pFindWordNext)
+ __pFindWordNext->SetEnabled(false);
+ }
+ else
+ {
+ if(__pFindWordNext)
+ __pFindWordNext->SetEnabled(true);
+ }
+
+ String countStr = L"";
+ countStr.Append(__currentWordIndex);
+ countStr.Append(L"/");
+ countStr.Append(__maxOccurrances);
+ if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
+ {
+ __pFindWordCountLabel->SetText(countStr);
+ __pFindWordCountLabel->Invalidate(false);
+ __pFindWordCountLabel->Invalidate(false);
+ }
+ else if (__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
+ {
+ __pFindWordCountLabelRightToLeft->SetText(countStr);
+ __pFindWordCountLabelRightToLeft->Invalidate(false);
+ __pFindWordCountLabelRightToLeft->Invalidate(false);
+ }
+ if (__pFindWordNext)
+ {
+ __pFindWordNext->Invalidate(false);
+ }
+ if (__pFindWordPrev)
+ {
+ __pFindWordPrev->Invalidate(false);
+ }
+
+}
+
+void
+MainForm::FindNextWord(bool next)
+{
+ if (next == true)
+ {
+ //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
+ if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
+ {
+ if (__currentWordIndex < __maxOccurrances)
+ {
+ __currentWordIndex++;
+ }
+ }
+ }
+ else
+ {
+ //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
+ if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
+ {
+ if(__currentWordIndex > 1)
+ {
+ __currentWordIndex--;
+ }
+ }
+ }
+
+ String countStr = L"";
+ countStr.Append(__currentWordIndex);
+ countStr.Append(L"/");
+ countStr.Append(__maxOccurrances);
+
+ if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
+ {
+ __pFindWordCountLabel->SetText(countStr);
+ __pFindWordCountLabel->Invalidate(false);
+ }
+ else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
+ {
+ __pFindWordCountLabelRightToLeft->SetText(countStr);
+ __pFindWordCountLabelRightToLeft->Invalidate(false);
+ }
+
+ if (__currentWordIndex >= __maxOccurrances)
+ {
+ __pFindWordNext->SetEnabled(false);
+ }
+ else
+ {
+ __pFindWordNext->SetEnabled(true);
+ }
+ if (__currentWordIndex <= 1)
+ {
+ __pFindWordPrev->SetEnabled(false);
+ }
+ else
+ {
+ __pFindWordPrev->SetEnabled(true);
+ }
+ __pFindWordPrev->Invalidate(false);
+ __pFindWordNext->Invalidate(false);
+
+ __pFindWordControl->Invalidate(true);
+}
+
+void
+MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
+{
+ AppLog("xyz::MainForm::OnWebKeypadWillOpen");
+ __isKeypadOpened = true;
+ __pFooterPanel->SetShowState(false);
+ // OnAddressBarKeypadOpened(*__pAddressbar);
+}
+
+void
+MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
+{
+ __isKeypadOpened = true;
+ AppLog("xyz::MainForm::OnWebKeypadOpened");
+
+ if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
+ {
+ __currentSearchStr = L"";
+ __currentWordIndex = 0;
+ __maxOccurrances = 0;
+ __pFindWordEditField->SetText(L"");
+ __pFindWordNext->SetEnabled(false);
+ __pFindWordPrev->SetEnabled(false);
+ __pFindWordCountLabel->SetText(L"0/0");
+ __pWebViewer->SearchTextAllAsync(L"",false);
+ __pFindWordControl->SetShowState(false);
+ __pFindWordEditField->HideKeypad();
+ }
+
+
+ if (__pWebViewer != null && __pFooterPanel != null)
+ {
+ AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
+ if(__pAddressbar != null)
+ {
+ __pAddressbar->SetShowState(false);
+ }
+ if(__pFindWordControl != null)
+ {
+ __pFindWordControl->SetShowState(false);
+ }
+ __pFooterPanel->SetShowState(false);
+ __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
+ }
+// if(__pImageMenu && __pImageMenu->GetShowState() == true)
+// {
+// __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
+// AppLog("omgomgomg");
+// }
+ Invalidate(true);
+}
+
+void
+MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
+{
+ AppLog("abcde::MainForm::OnWebKeypadClosed");
+ AppLog("xyz::MainForm::OnWebKeypadClosed");
+ AppLog("akjshdasd 4");
+ __pFooterPanel->SetShowState(true);
+// OnAddressBarKeypadClosed(*__pAddressbar);
+ RelayoutControls(false);
+ __isKeypadOpened = false;
+
+
+ if(__pImageMenu && __pImageMenu->GetShowState() == true)
+ {
+ AppLog("abcde: imagemenu visible.");
+ Point p(0,0);
+ Point q(0,0);
+ __pWebViewer->GetBlockRange(p,q);
+ if (p == Point(0,0) && q == Point(0,0))
+ return;
+ if(p.y < 150)
+ {
+ p.y = p.y + 100;
+
+ }
+
+ __pImageMenu->SetAnchorPosition(p);
+ __pImageMenu->Show();
+ Invalidate(true);
+ }
+}
+
+void
+MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
+{
+ // RelativeLayout(false);
+ if(__pWebViewer != null)
+ {
+ __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
+ }
+}
+
+void
+MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
+{
+ Control* temp = const_cast< Control* >(&source);
+ Header* pHeader = dynamic_cast< Header* >(temp);
+ if (pHeader != null)
+ {
+ //Header double - clicked
+ AppLog("Header double clicked");
+ }
+ if(__pFindWordControl)
+ {
+ AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
+ ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
+ }
+
+
+ AppLog("MainScene::OnTouchDoublePressed");
+
+}
+
+void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
+{
+ AppLog("LMN::abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
+ if(TouchEventManager::GetInstance() && TouchEventManager::GetInstance()->GetTouchInfoListN() && TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1)
+ {
+ AppLog("Returning because of more than one touch point.");
+ return;
+ }
+// if(__pWebViewer)
+// __pWebViewer->ReleaseBlock();
+ if(__pWebViewer)
+ __pWebViewer->SetFocus();
+ __longPressPoint = currentPosition;
+
+ if (__pHitElementResult != null)
+ {
+ delete __pHitElementResult;
+ __pHitElementResult = null;
+ }
+
+ if (__pWebViewer != null)
+ {
+ AppLog("MainForm::OnTouchLongPressed web not null");
+ __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
+ }
+
+ if (__pHitElementResult == null)
+ {
+ return;
+ }
+
+ if (__pHitElementResult->HasImage() == true)
+ {
+ if(__pWebViewer != null)
+ {
+ __pWebViewer->ReleaseBlock();//N_SE-52389
+ InitImageContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
+ }
+ __pImageMenu->SetShowState(true);
+ __pImageMenu->Show();
+ __pImageMenu->Invalidate(true);
+ }
+ else if(__pHitElementResult->HasUrl() == true)
+ {
+ if(__pWebViewer != null)
+ __pWebViewer->ReleaseBlock();//N_SE-52389
+ String tempURl = __pHitElementResult->GetUrl();
+ AppLog("tempURl is %ls", tempURl.GetPointer());
+ const Bitmap* pBitmap = __pHitElementResult->GetImage();
+ if (pBitmap != null)
+ {
+ AppLog("not null");
+ }
+ else
+ {
+ AppLog(null);
+ }
+ InitImageLinkContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
+ __pImageMenu->SetShowState(true);
+ __pImageMenu->Show();
+ __pImageMenu->Invalidate(true);
+ }
+ else
+ {
+ String tagName = __pHitElementResult->GetTagName();
+ String type = __pHitElementResult->GetAttributeValue("type");
+ String value = __pHitElementResult->GetAttributeValue(L"value");
+ String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
+ result r = E_FAILURE;
+ __currentSelectedStr.Clear();
+ __currentSelectedStr = __pWebViewer->GetTextFromBlock();
+
+ AppLog("tag name is %ls", tagName.GetPointer());
+ AppLog("type is %ls", type.GetPointer());
+
+
+
+ __isLongPressedDone = true;
+ if( type.Equals(L"submit",false) !=true && type.Equals(L"checkbox",false) !=true && type.Equals(L"range",false) !=true && type.Equals(L"file",false) !=true)
+ r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
+ if (((tagName.Equals(L"INPUT",false) == true) || tagName.Equals(L"TEXTAREA",false) == true) && innerHtml.GetLength() == 0 && type.Equals(L"submit",false) !=true && type.Equals(L"checkbox",false) !=true && type.Equals(L"range",false) !=true && type.Equals(L"file",false) !=true/*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.Equals(L"",false) == true && r == E_INVALID_ARG)
+ {
+ AppLog("MainForm::OnWebPageBlockSelected show paste option");
+
+ InitSelectTextContextMenu(Point(currentPosition.x , currentPosition.y + __pWebViewer->GetY()),true, true);
+ if(__pImageMenu)
+ {
+ __pImageMenu->SetShowState(true);
+ __pImageMenu->Show();
+ __pImageMenu->Invalidate(true);
+ }
+ }
+ AppLog("setselectionselectedornot %s",GetErrorMessage(r));
+
+ }
+// __inputEventToBeSupressed = true;
+}
+
+void
+MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
+{
+ AppLog("xyz:: MainForm::OnTouchReleased called");
+
+ if (__pAddressbar && __pAddressbar->GetShowState() == true)
+ {
+ __pAddressbar->SetShowState(false);
+ }
+ if(__pFooterPanel && __isKeypadOpened == false)
+ {
+ __pFooterPanel->SetShowState(true);
+ }
+
+ // Not reuired now.
+ /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
+ if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
+ {
+ __pWebViewer->ConsumeInputEvent();
+ }
+ if(pHitElement != null)
+ {
+ delete pHitElement;
+ }
+ __inputEventToBeSupressed = false;*/
+}
+
+bool
+MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
+{
+
+ return true;
+}
+
+bool
+MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
+{
+ if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
+ {
+ __currentSearchStr = L"";
+ __currentWordIndex = 0;
+ __maxOccurrances = 0;
+
+ if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
+ {
+ __pFindWordEditField->SetText(L"");
+ __pFindWordEditField->HideKeypad();
+ __pFindWordControl->SetShowState(false);
+ __pFindWordCountLabel->SetText(L"0/0");
+ }
+ else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
+ {
+ __pFindWordEditFieldRightToLeft->SetText(L"");
+ __pFindWordEditFieldRightToLeft->HideKeypad();
+ __pFindWordControl->SetShowState(false);
+ __pFindWordCountLabelRightToLeft->SetText(L"0/0");
+ }
+
+ __pFindWordNext->SetEnabled(false);
+ __pFindWordPrev->SetEnabled(false);
+
+ __pWebViewer->SearchTextAllAsync(L"",true);
+ __pFindWordControl->SetShowState(false);
+ }
+ AppLog("__pAddressbar->GetShowState() %d",__pAddressbar->GetShowState());
+ if(__pAddressbar->GetShowState() == false)
+ {
+ __pAddressbar->SetAddressbarURLFocus();
+ __pFooterPanel->SetShowState(false);
+ }
+
+ return false;
+}
+
+bool
+MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
+{
+ return true;
+}
+
+bool
+MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
+{
+ return true;
+}
+
+bool
+MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
+{
+ return true;
+}
+
+bool
+MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
+{
+ return true;
+}
+
+bool
+MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
+{
+ return true;
+}
+
+void
+MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
+{
+ AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
+ int widthContextItem = 0;
+ //if(__pFindWordCountLabel)
+ // __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
+ // As per the platform engineer comment removed this line
+ /*if(__pWebViewer != null)
+ {
+ // 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
+ __pWebViewer->ReleaseBlock();
+ }*/
+
+// if(__pFindWordControl != null)
+// ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
+
+ if(__pOptionMenu && __pOptionMenu->GetShowState() == true)
+ {
+ if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
+ {
+ AppLog(" Orientation landscape");
+ __pOptionMenu->SetMaxVisibleItemsCount(5);
+ }
+ else
+ {
+ AppLog(" Orientation potrait");
+ __pOptionMenu->SetMaxVisibleItemsCount(6);
+ }
+ }
+ if(__pNotification && __pNotification->GetShowState() == true)
+ {
+ __pNotification->SetShowState(false);
+ __pNotification->Invalidate(false);
+ }
+ if ( __pFooterLabel != null)
+ {
+ Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
+ if(pBitmap != null)
+ {
+ __pFooterLabel->SetBackgroundBitmap(*pBitmap);
+ delete pBitmap;
+ }
+
+
+ }
+ if (__pFindWordBgLabel != null)
+ {
+ Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
+ if (pBitmap != null)
+ {
+ __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
+ delete pBitmap;
+ }
+ }
+
+ if (__pFindWordBgLabelRightToLeft != null)
+ {
+ Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
+ if (pBitmap != null)
+ {
+ __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
+ delete pBitmap;
+ }
+ }
+
+
+// if(__pOptionMenu != null)
+// __pOptionMenu->SetShowState(false);
+
+ if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
+ {
+ widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
+ }
+ else
+ {
+ widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
+ }
+
+ if (__pFooterPanel)
+ {
+ AppLog("__pFooterPanel->GetShowState() is true");
+ InitFooter();
+ __pFooterPanel->SetBounds(CoordinateSystem::AlignToDevice(FloatRectangle(0, GetClientAreaBoundsF().height - __pFooterPanel->GetHeightF(), __pFooterPanel->GetWidthF(), __pFooterPanel->GetHeightF())));
+ __pFooterPanel->Invalidate(true);
+ }
+ InitAddressbar();
+
+ String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
+ if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
+ {
+ InitMostVisitedSitesView(orientationStatus);
+ }
+
+ RelayoutControls(false);
+ if (__pArticleReaderPanel != null)
+ {
+ if (__pArticleReaderPanel->GetShowState() == true)
+ {
+ __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
+
+ if (__pBlankPanel != null)
+ __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
+
+ if (__pWebReader != null)
+ {
+ __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
+ }
+ Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
+ Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
+
+ if ( pBitmap != null && pSrcBitmap != null)
+ {
+ AppLog("CreateReaderPanel ninepatchbitmap found");
+ pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
+ }
+
+ __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
+ __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
+ if (pBitmap != null)
+ {
+ delete pBitmap;
+ pBitmap = null;
+ }
+ if (pSrcBitmap != null)
+ {
+ delete pSrcBitmap;
+ pSrcBitmap = null;
+ }
+ }
+ }
+ Invalidate(true);
+
+ if (__pAddressbar != null)
+ {
+ int width = GetClientAreaBounds().width;
+ __pAddressbar->OrientationChanged(width);
+ }
+}
+
+void
+MainForm::OnSettingsChange(int settingvalue)
+{
+ AppLogDebug("MainForm::OnSettingsChange entered");
+
+ if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
+ {
+ __pAddressbar->ResetGuideText();
+ }
+ if (__pWebViewer == null)
+ {
+ AppLogDebug("Webviewer is not initialized yet.");
+ return;
+ }
+
+ if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
+ {
+ WebSetting settings = __pWebViewer->GetSetting();
+ if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
+ {
+ settings.SetAutoFittingEnabled(true);
+ }
+ else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
+ {
+ settings.SetAutoFittingEnabled(false);
+ }
+ __pWebViewer->SetSetting(settings);
+
+ }
+ else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
+ {
+ WebSetting settings = __pWebViewer->GetSetting();
+ settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
+ __pWebViewer->SetSetting(settings);
+ }
+ else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
+ {
+ WebSetting settings = __pWebViewer->GetSetting();
+ settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
+ __pWebViewer->SetSetting(settings);
+ __pWebViewer->Reload();
+ }
+ else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
+ {
+ WebSetting settings = __pWebViewer->GetSetting();
+ settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
+ __pWebViewer->SetSetting(settings);
+ }
+ else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
+ {
+ if (__pWebViewer)
+ {
+ __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
+ }
+ }
+ else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
+ {
+ if (__pWebViewer)
+ {
+ WebSetting settings = __pWebViewer->GetSetting();
+ settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
+ __pWebViewer->SetSetting(settings);
+ }
+ }
+ else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
+ {
+ if (__pWebViewer)
+ {
+ WebSetting settings = __pWebViewer->GetSetting();
+ settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
+ __pWebViewer->SetSetting(settings);
+ }
+ }
+ else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
+ {
+ WebSetting settings = __pWebViewer->GetSetting();
+ if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
+ {
+ settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
+ }
+ else
+ {
+ settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
+ }
+ __pWebViewer->SetSetting(settings);
+ }
+ else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
+ {
+ if (__pWebReader)
+ {
+ AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
+ WebSetting settings = __pWebReader->GetSetting();
+ settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
+ __pWebReader->SetSetting(settings);
+ }
+ }
+}
+
+void
+MainForm::OnSettingsReset()
+{
+ if (__pWebViewer)
+ {
+ __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
+ __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
+ }
+}
+
+void
+MainForm::OnClearCache()
+{
+ result r = E_SUCCESS;
+
+ if (__pWebViewer != NULL)
+ {
+ r = __pWebViewer->ClearCache();
+ if (r == E_SUCCESS)
+ {
+ AppLogDebug("Cache cleared success");
+ }
+ else
+ {
+ AppLogDebug("Cache cleared fail");
+ }
+ }
+}
+
+void
+MainForm::OnClearCookie()
+{
+ result r = E_SUCCESS;
+
+ if (__pWebViewer != NULL)
+ {
+ __pWebViewer->ClearCookie();
+ }
+ if (r == E_SUCCESS)
+ {
+ AppLogDebug("Cookie cleared success");
+ }
+ else
+ {
+ AppLogDebug("Cache cleared fail");
+ }
+}
+
+void
+MainForm::OnClearFormData()
+{
+ result r = E_SUCCESS;
+
+ if (__pWebViewer != NULL)
+ {
+ __pWebViewer->ClearFormData();
+ }
+ if (r == E_SUCCESS)
+ {
+ AppLogDebug("Cookie cleared success");
+ }
+ else
+ {
+ AppLogDebug("Cache cleared fail");
+ }
+}
+
+void
+MainForm::OnClearPasswords()
+{
+ result r = E_SUCCESS;
+
+ if (__pWebViewer != NULL)
+ {
+ __pWebViewer->ClearLoginFormData();
+ }
+ if (r == E_SUCCESS)
+ {
+ AppLogDebug("Cookie cleared success");
+ }
+ else
+ {
+ AppLogDebug("Cache cleared fail");
+ }
+}
+
+
+double
+MainForm::findDistance(int x1,int y1,int x2, int y2)
+{
+ int deltaX = Math::Abs(x2 - x1);
+ int deltaY = Math::Abs(y2 - y1);
+ double num = deltaX*deltaX + deltaY*deltaY;
+
+ if (num >= 0)
+ {
+ double x = num;
+ int i;
+ for (i = 0; i < 20; i++)
+ {
+ x = (((x*x)+ num)/(2*x));
+ }
+ return num;
+ }
+ else
+ {
+ return 0.0;
+ }
+}
+
+void
+MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
+{
+ AppLog("xyz:: MainForm::OnTouchPressed called");
+ if(__pFindWordControl)
+ {
+ AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
+// ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
+ }
+ __isLongPressedDone = false;
+
+
+
+ Touch touch;
+ IList* pList = null;
+ pList = touch.GetTouchInfoListN(source);
+
+ if (pList != null)
+ {
+ int count = pList->GetCount();
+ if (count == 1)
+ {
+ TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
+ __touchPoint1 = pTouchInfo->position;
+
+ /*if (__pAddressbar != null)
+ {
+ if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
+ {
+ if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
+ {
+ __pAddressbar->SaveAddressbarEditText();
+ }
+ __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
+ }
+
+ __pAddressbar->Invalidate(true);
+ }*/
+ if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
+ {
+ if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
+ {
+ //__pAddressbar->SaveAddressbarEditText();
+ }
+ SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
+ }
+ }
+ else if (count == 2)
+ {
+ AppLogDebug("MainForm::OnTouchPressed count is two");
+ TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
+ __touchPoint1 = pTouchInfo->position;
+
+ pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
+ __touchPoint2 = pTouchInfo->position;
+ }
+ }
+ if( pList != NULL)
+ {
+ pList->RemoveAll(true);
+ delete pList;
+ }
+ if(__pAddressbar)
+ {
+ __pAddressbar->SetShowState(false);
+ }
+ if(__pFooterPanel && __isKeypadOpened == false)
+ {
+ __pFooterPanel->SetShowState(true);
+ }
+ RelayoutControls(false);
+ return;
+}
+
+void
+MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
+{
+ AppLog("LMN::MainForm::OnTouchMoved entered");
+// __currentWordIndex = 0;
+ __isLongPressedDone = false;
+
+}
+
+void
+MainForm::MoveUiControls()
+{
+}
+
+void
+MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
+{
+ if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
+ {
+ if(__pFooterUrlField->GetTextLength() == 0)
+ {
+ __pFooterUrlField->SetKeypadActionEnabled(false);
+ }
+ else
+ {
+ __pFooterUrlField->SetKeypadActionEnabled(true);
+ }
+ }
+ if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
+ {
+ __currentSearchStr = __pFindWordEditField->GetText();
+ if (__currentSearchStr.GetLength() > 0)
+ {
+ __pFindWordCountLabel->SetShowState(true);
+ }
+ else
+ {
+// __pFindWordCountLabel->SetShowState(false);
+ __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
+ __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
+
+ }
+ __pFindWordNext->SetEnabled(false);
+ __pFindWordPrev->SetEnabled(false);
+ __pFindWordNext->Invalidate(true);
+ __pFindWordPrev->Invalidate(true);
+ __pFindWordCountLabel->SetText(L"0/0");
+ __pFindWordCountLabel->Invalidate(true);
+ }
+ else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
+ {
+ __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
+ if (__currentSearchStr.GetLength() > 0)
+ {
+ __pFindWordCountLabelRightToLeft->SetShowState(true);
+ }
+ else
+ {
+ __pFindWordCountLabelRightToLeft->SetShowState(false);
+ }
+
+ __pFindWordNext->SetEnabled(false);
+ __pFindWordPrev->SetEnabled(false);
+ __pFindWordNext->Invalidate(true);
+ __pFindWordPrev->Invalidate(true);
+ __pFindWordCountLabelRightToLeft->SetText(L"0/0");
+ __pFindWordCountLabelRightToLeft->Invalidate(true);
+ }
+ AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
+ if (__currentSearchStr.GetLength() > 0)
+ {
+ StartWordSearch();
+ }
+ else
+ {
+ __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
+ StartWordSearch();
+ __currentSearchStr = L"";
+ AppLogDebug("Enter something");
+ }
+}
+
+result
+MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
+{
+ return E_SUCCESS;
+
+}
+
+result
+MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
+{
+ if(__pWebViewer != null)
+ return E_SUCCESS;
+
+ AppLog("MainForm::InitMostVisitedSitesView");
+ result r = E_SUCCESS;
+
+
+ if (__pMostVisitedListView != null)
+ {
+ __pMostVisitedListView->SetShowState(true);
+ return E_SUCCESS;
+ }
+
+ if (__pMostVisitedListView != null)
+ {
+ RemoveControl(__pMostVisitedListView);
+ }
+ if(__pMostVisitedSites != null)
+ {
+ __pMostVisitedSites->RemoveAll(true);
+ }
+
+ HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
+
+ __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
+ __webControlHeightF = GetClientAreaBoundsF().height - __pFooterPanel->GetHeightF();
+ __pMostVisitedListView = new(std::nothrow) ListView();
+
+ int height = GetClientAreaBounds().height;
+
+ if(__pFooterPanel->GetShowState() == true)
+ {
+ height = height - __pFooterPanel->GetHeight();
+ }
+ if(__pAddressbar->GetShowState() == true)
+ {
+ height -= __pAddressbar->GetHeight();
+ }
+
+ r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
+
+ if (r != E_SUCCESS)
+ {
+ delete __pMostVisitedListView;
+ AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
+ return r;
+ }
+ __pMostVisitedListView->SetItemProvider(*this);
+ __pMostVisitedListView->AddListViewItemEventListener(*this);
+ __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_VISITED_SITES"));
+ AddControl(__pMostVisitedListView);
+ __pMostVisitedListView->UpdateList();
+
+ return E_SUCCESS;
+
+}
+
+String
+MainForm::GetImagePath(void)
+{
+
+ String str;
+ String formattedTime;
+ DateTime currentTime;
+ LocaleManager localManager;
+ SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
+
+ localManager.Construct();
+ Locale locale = localManager.GetSystemLocale();
+ //Locale locale(LANGUAGE_ENG, COUNTRY_US);
+
+ // Get date formatter
+ DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
+
+ if (pTimeFormatter)
+ {
+ pTimeFormatter->Format(currentTime, formattedTime);
+ }
+
+ AppLog("current time stamp is %ls", formattedTime.GetPointer());
+ String delim(L" :");
+ StringTokenizer strTok(formattedTime, delim);
+ String token;
+ String imageName;
+ String str1("GMT+00");
+ while (strTok.HasMoreTokens())
+ {
+ strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
+ if(token.Equals(str1))
+ break;
+ AppLog("token is %ls", token.GetPointer());
+ imageName.Append(token);
+ }
+ return imageName;
+
+}
+
+void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
+{
+ result r = E_FAILURE;
+ AppLog("Content manager 1");
+ ContentId contentId;
+ ContentManager contentManager;
+ r = contentManager.Construct();
+ if(IsFailed(r))
+ {
+ AppLog("Content manager update content result %s" ,GetErrorMessage(r));
+ return;
+ }
+ Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
+ Tizen::Io::Directory::Create(contentPath,true);
+ if(GetLastResult() == E_FILE_ALREADY_EXIST)
+ {
+ AppLog("Already exists");
+ }
+ else if(GetLastResult() == E_SUCCESS)
+ {
+ AppLog("created success");
+ }
+ contentPath.Append(imageName);
+ contentPath.Append(".jpg");
+ contentId = contentManager.CreateContent(*aBuffer, contentPath);
+ ShowIndicatorNotification(L"Download Complete",contentPath);
+ AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
+}
+
+void
+MainForm::ShowIndicatorNotification(const String& messageText, const String& contentPath)
+{
+ AppLogDebug("ENTER");
+
+ NotificationRequest request;
+ request.SetAlertText(messageText);
+ request.SetTitleText(L"");
+ request.SetAppMessage(contentPath);
+
+ Tizen::App::App* pApp = Tizen::App::App::GetInstance();
+ String homePath = pApp->GetAppRootPath();
+ String iconPath = homePath + L"res/screen-density-xhigh/Notification_download_complete.png";
+ AppLog("The iconPath is : %ls", homePath.GetPointer());
+ request.SetIconFilePath(iconPath);
+
+ Tizen::Shell::NotificationManager notiMgr;
+ notiMgr.Construct();
+ notiMgr.Notify(request);
+ AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));
+ return;
+}
+
+void
+MainForm::SetForwardButtonEnabled(bool isEnabled)
+{
+ __pGoForwardBtn->SetEnabled(isEnabled);
+ __pGoForwardBtn->Invalidate(true);
+}
+
+void
+MainForm::SetBackButtonEnabled(bool isEnabled)
+{
+ __pGoBackBtn->SetEnabled(isEnabled);
+ __pGoBackBtn->Invalidate(true);
+}
+
+void
+MainForm::UpdateProgress(int percentage)
+{
+ __progressPercentage = percentage;
+ if (percentage == 0 || percentage == 100)
+ {
+ __isLoadingData = false;
+ if (percentage == 100)
+ {
+ __isLoadingCompleted = true;
+ __progressPercentage = 0;
+ }
+ else
+ {
+ __isLoadingCompleted = false;
+ }
+ }
+ else
+ {
+ __isLoadingData = true;
+ }
+ UpdateProgressBitmap();
+}
+
+int
+MainForm::GetProgress(void)
+{
+ return __progressPercentage;
+}
+
+void
+MainForm::UpdateProgressBitmap(void)
+{
+ result r = E_SUCCESS;
+ if (__pProgressbarLabel == null)
+ return;
+ int w = __pProgressbarLabel->GetWidth();
+ int h = __pProgressbarLabel->GetHeight();
+ Canvas canvas;
+ int progressWidth = 0;
+ Bitmap* pRetBitmap = null;
+
+ if (__progressPercentage == 0 || __progressPercentage == 100)
+ {
+ __pProgressbarLabel->SetShowState(false);
+ __pProgressbarLabel->Invalidate(false);
+ return;
+ }
+ else
+ {
+ __pProgressbarLabel->SetShowState(true);
+ __pProgressbarLabel->Invalidate(false);
+ }
+
+ r = canvas.Construct(Rectangle(0, 0, w, h));
+
+ if (r != E_SUCCESS)
+ {
+ AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
+ return;
+ }
+
+ canvas.Clear();
+ Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
+
+ if (pBgBmp != null)
+ {
+ pBgBmp->Scale(Dimension(w, h));
+ canvas.DrawBitmap(Point(0,0), *pBgBmp);
+ delete pBgBmp;
+ }
+
+ progressWidth = (double) (w) * __progressPercentage / 100;
+ AppLogDebug("progressWidth: %d", progressWidth);
+ Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
+
+ if (pProgressBmp != null)
+ {
+ pProgressBmp->Scale(Dimension(progressWidth, h));
+ canvas.DrawBitmap(Point(0,0), *pProgressBmp);
+ delete pProgressBmp;
+ }
+
+ pRetBitmap = new (std::nothrow) Bitmap();
+
+ if (pRetBitmap == null)
+ {
+ AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
+ return;
+ }
+
+ pRetBitmap->Construct(canvas, canvas.GetBounds());
+
+ if (__pProgressbarLabel != null && pRetBitmap != null)
+ {
+ __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
+ __pProgressbarLabel->Invalidate(false);
+ }
+
+ if (pRetBitmap != null)
+ {
+ delete pRetBitmap;
+ pRetBitmap = null;
+ }
+ return;
+}
+
+void
+MainForm::ReaderClicked()
+{
+ result r = E_SUCCESS;
+ ArrayList* pArgList = new(std::nothrow) ArrayList();
+ if (pArgList != null)
+ {
+ r = pArgList->Construct();
+ if (IsFailed(r))
+ {
+ delete pArgList;
+ return;
+ }
+
+ r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
+ if (IsFailed(r))
+ {
+ delete pArgList;
+ return;
+ }
+
+ r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
+ if (IsFailed(r))
+ {
+ delete pArgList;
+ return;
+ }
+
+ r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
+ if (IsFailed(r))
+ {
+ delete pArgList;
+ return;
+ }
+ }
+
+ SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
+ return;
+
+
+}
+
+void MainForm::SetAddressbarMode(AddressBarMode addMode)
+{
+ AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
+
+ __currentAddMode = addMode;
+
+ switch(addMode)
+ {
+ case ADDRESSBAR_MODE_INVALID:
+ {
+ // do nothing
+ }
+ break;
+ case ADDRESSBAR_MODE_READER:
+ {
+ __pStopBtn->SetShowState(false);
+ __pRefreshBtn->SetShowState(false);
+ __pClearBtn->SetShowState(false);
+ __pReaderBtn->SetShowState(false);
+ }
+ break;
+ case ADDRESSBAR_MODE_LOADING:
+ {
+ __pRefreshBtn->SetShowState(false);
+ __pStopBtn->SetShowState(true);
+ __pClearBtn->SetShowState(false);
+ __pReaderBtn->SetShowState(false);
+ }
+ break;
+ case ADDRESSBAR_MODE_LOADING_COMPLETE:
+ {
+// SetUrl(__pAddressbar->GetUrl());
+
+ __pRefreshBtn->SetShowState(true);
+ __pStopBtn->SetShowState(false);
+ __pClearBtn->SetShowState(false);
+ __pReaderBtn->SetShowState(false);
+ }
+ break;
+ case ADDRESSBAR_MODE_EDIT:
+ {
+ __pRefreshBtn->SetShowState(false);
+ __pStopBtn->SetShowState(false);
+ __pReaderBtn->SetShowState(false);
+ __pClearBtn->SetShowState(true);
+ }
+ break;
+ }
+
+ Invalidate(true);
+
+ OnAddressBarModeChanged();
+}
+
+AddressBarMode MainForm::GetAddressbarMode(void)
+{
+ return __currentAddMode;
+}
+
+void MainForm::SetUrl(const String& url)
+{
+ __displayUrl = url;
+ if(__displayUrl.GetLength() > 2048)
+ __displayUrl.SubString(0,2048,__displayUrl);
+
+ if (__pFooterUrlField != NULL)
+ {
+ String removedHttpUrl = RemoveHttpTextFromDisplayURL();
+ if (removedHttpUrl.IsEmpty() == false)
+ {
+ __pFooterUrlField->SetText(removedHttpUrl);
+ if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
+ __pAddressbar->SetUrl(__displayUrl);
+ }
+ else
+ {
+ __pFooterUrlField->SetText(__displayUrl);
+ if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
+ __pAddressbar->SetUrl(__displayUrl);
+ }
+ if(__pFooterUrlField)
+ {
+ AppLog("Position:: %d, %ls",__pFooterUrlField->GetTextLength(),__pFooterUrlField->GetText().GetPointer());
+ __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
+ }
+ __pFooterUrlField->Invalidate(false);
+ if(__pAddressbar != NULL && __pAddressbar->HasFocus())
+ __pAddressbar->Invalidate(true);
+// __pFooterUrlField->SetCursorPosition(0);
+ }
+}
+
+String
+MainForm::RemoveHttpTextFromDisplayURL(void)
+{
+ AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
+ int index = -1;
+// bool isHttpText = __displayUrl.Contains(L"http://");
+ String updatedDisplayUrl;
+ updatedDisplayUrl.Clear();
+ if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
+ {
+ __displayUrl.SubString(7,updatedDisplayUrl);
+ }
+ else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
+ {
+ __displayUrl.SubString(8,updatedDisplayUrl);
+ }
+ return updatedDisplayUrl;
+}
+
+void MainForm::OnSharePopupControlStarted(void)
+{
+ __pWebViewer->AddTouchEventListener(*this);
+}
+
+void
+MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
+{
+ if (requestId == UPDATE_MAINFORM_FOOTER_ON_WINDOWCLOSED)
+ {
+ AppLog("OnWebWindowCloseRequested mainform test 1 OnUserEventReceivedN");
+ InitFooter();
+ }
+ else if (requestId == BACK_GROUND_APP_EVENT)
+ {
+ if(__pWebViewer != null)
+ {
+ __pWebViewer->Pause();
+ }
+ if(__pImageMenu)
+ {
+ __pImageMenu->SetShowState(false);
+ }
+ if(__pAddressbar != null)
+ {
+ __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
+ }
+ }
+ else if(requestId == FORE_GROUND_APP_EVENT)
+ {
+ if(__pWebViewer != null)
+ {
+ __pWebViewer->Resume();
+ }
+ if(__pAddressbar != null)
+ {
+ __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
+ }
+ }
+}
+
+void
+MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
+{
+ AppLog("XYZ::MainForm::AddressBarCancelledClicked");
+ result r = E_SUCCESS;
+
+ if (__pAddressbar)
+ __pAddressbar->SetShowState(false);
+
+ AppLog("akjshdasd 5");
+ __pFooterPanel->SetShowState(true);
+
+ if(__pWebViewer)
+ __pWebViewer->SetFocus();
+ else if(__pMostVisitedListView)
+ __pMostVisitedListView->SetFocus();
+ else if(__pMultiWindowButton)
+ __pMultiWindowButton->SetFocus();
+ else if(__pMoreButton)
+ __pMoreButton->SetFocus();
+
+ __pAddressbar->SetShowState(false);
+
+ RelayoutControls(false);
+}
+
+void
+MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
+{
+ AppLog("MainForm::OnFormMenuRequested called");
+ InitOptionMenu();
+ if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer && __pWebViewer->GetShowState() == true)
+ {
+ int bookmarkCount=0;
+ bool exist = false;
+ String url=L"";
+ url=__pWindowInfo->pageUrl;
+ AppLog("MainForm::OnFormMenuRequested url %ls",url.GetPointer());
+ result r = E_SUCCESS;
+ Bitmap* pBitmap = null;
+ String lastChar = L"";
+// if(url.SubString(url.GetLength()-1,lastChar));
+// if(lastChar == L"/")
+// {
+// bool exist1 = false;
+// bool exist2 = false;
+// r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist1);
+// url.SubString(0,url.GetLength() - 1,url);
+// r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist2);
+// exist = exist1 | exist2;
+// }
+// else
+// {
+ r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
+ if (IsFailed(r))
+ {
+ AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
+ return;
+ }
+// }
+ if ( exist == true)
+ {
+ pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
+ }
+ else
+ {
+ pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
+ }
+ AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
+
+ if (__pOptionMenu->GetItemCount() == 9)
+ {
+ r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
+ }
+ else
+ {
+ r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
+ }
+
+ if (IsFailed(r))
+ {
+ AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
+ delete pBitmap;
+ return ;
+ }
+ AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
+ if (__pOptionMenu->GetItemCount() != 9)
+ {
+ __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
+ __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
+// __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
+ __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
+ __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
+ __pOptionMenu->SetMaxVisibleItemsCount(6);
+ }
+ if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
+ {
+ AppLog(" Orientation landscape");
+ __pOptionMenu->SetMaxVisibleItemsCount(5);
+ }
+ else
+ {
+ AppLog(" Orientation potrait");
+ __pOptionMenu->SetMaxVisibleItemsCount(6);
+ }
+
+ AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
+ delete pBitmap;
+ }
+ AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
+ if(__pAddressbar)
+ __pAddressbar->SetShowState(false);
+ SetFocus();
+ __pFooterPanel->SetShowState(true);
+ result r = __pOptionMenu->SetShowState(true);
+ AppLog("ajsghd %s",GetErrorMessage(r));
+ RelayoutControls(false);
+ __pOptionMenu->Invalidate(true);
+ __pOptionMenu->Show();
+
+}