X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FIntMainForm.cpp;h=47908fd3ea6aa2aeb1cea6e0000d0c243003b82c;hb=5a2ca0d204f5a5fffc4cd04f16f9571fecd5d8dd;hp=c37f428784c3b415344beb26374f8d98cef855fd;hpb=4a3e6678c95b89e2846febef84c9074fdbd623a3;p=apps%2Fosp%2FInternet.git diff --git a/src/IntMainForm.cpp b/src/IntMainForm.cpp index c37f428..47908fd 100644 --- a/src/IntMainForm.cpp +++ b/src/IntMainForm.cpp @@ -1,7 +1,7 @@ // // Copyright (c) 2012 Samsung Electronics Co., Ltd. // -// Licensed under the Flora License, Version 1.0 (the License); +// 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 // @@ -25,13 +25,15 @@ #include #include #include +#include +//#include #include "IntBookmarkData.h" #include "IntBookmarkPresentationModel.h" #include "IntCommonLib.h" #include "IntFaviconManager.h" +#include "IntInternetApp.h" #include "IntMainForm.h" -#include "IntNotificationPanel.h" #include "IntSceneRegister.h" #include "IntSettingPresentationModel.h" @@ -44,6 +46,7 @@ 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; @@ -69,8 +72,11 @@ static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp. static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.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; @@ -93,6 +99,7 @@ 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; @@ -115,12 +122,16 @@ 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 = 219; -const int IDA_HYPERLINK_COPY_LINK_CLICKED = 220; + +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; @@ -133,9 +144,11 @@ 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; @@ -144,13 +157,18 @@ MainForm::MainForm(void) __pWindowInfo = null; __pWebViewer = null; __pImageMenu = null; - __pMenu = 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; @@ -164,12 +182,13 @@ MainForm::MainForm(void) __currentWordIndex = 0; __distanceMoved = 0; __isLoaded = false; - __inputEventToBeSupressed = 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; @@ -193,7 +212,10 @@ MainForm::MainForm(void) __pFooterLabel = null; __pStopBtn = null; __pClearBtn = null; - __isWebKeypadOpened = false; + __pReaderBtn = null; + __isKeypadOpened = false; + __fontSize = 44; + __pNotification = null; } MainForm::~MainForm(void) @@ -204,6 +226,13 @@ MainForm::~MainForm(void) { __pAddressbar->SetAddressbarEventListener(null); } + + if(__pHistory != null) + { + delete __pHistory; + __pHistory = null; + } + if (__pReaderData != null) { delete __pReaderData; @@ -221,6 +250,11 @@ MainForm::~MainForm(void) delete __pHitElementResult; __pHitElementResult = null; } + if(__pOptionMenu) + { + delete __pOptionMenu; + __pOptionMenu = null; + } String* pSelectedScene = NULL; Object* pValue = NULL; @@ -238,6 +272,8 @@ bool MainForm::Initialize(void) { Construct(L"IDL_FORM"); + +// SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_FOOTER); return true; } @@ -249,6 +285,7 @@ MainForm::OnInitializing(void) const int WIDTH_CONTEXT_MENU_BUTTON = 336; const int HEIGHT_CONTEXT_MENU_BUTTON = 72; + __fontSize = CommonUtil::GetFontSize(); Panel* pFooterPanel = null; __pSaveImage = new Image(); @@ -258,6 +295,7 @@ MainForm::OnInitializing(void) SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this); SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this); AddOrientationEventListener(*this); + AppLogDebug(" MainForm::OnInitializing ended"); if (__pMostVisitedSites == null) { @@ -268,44 +306,23 @@ MainForm::OnInitializing(void) __pItemContext= new(std::nothrow) ListContextItem(); __pItemContext->Construct(); - Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON); - Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON); - if (pBitmapNormal != null && pBitmapPressed != null) - { - __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed); - } + __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"),true); - if (pBitmapNormal != null) - { - delete pBitmapNormal; - } - if (pBitmapPressed != null) - { - delete pBitmapPressed; - } + __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(); - pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON); - pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON); - - if (pBitmapNormal != null && pBitmapPressed != null) - { - __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed); - } - - if (pBitmapNormal != null) - { - delete pBitmapNormal; - } - - if (pBitmapPressed != null) - { - delete pBitmapPressed; - } + __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; } @@ -329,7 +346,7 @@ MainForm::InitAddressbar(void) return r; } __pAddressbar->SetAddressbarEventListener(this); - AddControl(*__pAddressbar); + AddControl(__pAddressbar); __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight())); SetControlAlwaysOnTop(*__pAddressbar, true); __adressPanelPosition = __pAddressbar->GetPosition(); @@ -376,15 +393,15 @@ MainForm::CreateReaderPanel(void) __pArticleReaderLabel = new Label(); __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L""); - __pBlankPanel->AddControl(*__pArticleReaderLabel); - __pBlankPanel->AddControl(*__pArticleReaderPanel); - AddControl(*__pBlankPanel); + __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); + __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()); @@ -439,7 +456,9 @@ MainForm::InitWebControl() return E_FAILURE; const int Y_WEBCONTROL_POSITION = 0; - __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight(); + + __webControlHeight = GetHeight() - __pFooterPanel->GetHeight(); + if (__pMostVisitedListView) { __pMostVisitedListView->SetShowState(false); @@ -455,7 +474,7 @@ MainForm::InitWebControl() AppLogDebug("Initialization failed"); return E_FAILURE; } - r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight)); + r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12)); if (IsFailed(r)) { @@ -466,10 +485,12 @@ MainForm::InitWebControl() } else { - r = AddControl(*__pWebViewer); + r = AddControl(__pWebViewer); if (IsFailed(r)) { + delete __pWebViewer; + __pWebViewer = null; AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r)); return r; } @@ -482,7 +503,7 @@ MainForm::InitWebControl() } __pWebViewer->SetLoadingListener(this); - __pWebViewer->SetWebUiEventListener(this); + __pWebViewer->SetWebUiEventListenerF(this); __pWebViewer->SetWebKeypadEventListener(this); __pWebViewer->SetFocus(); __pWebViewer->AddTouchEventListener(*this); @@ -499,18 +520,6 @@ MainForm::InitWebControl() } void -MainForm::OnFocusGained(const Control& source) -{ - AppLog("MainForm::OnFocusGained"); -} - -void -MainForm::OnFocusLost(const Control& source) -{ - AppLog("MainForm::OnFocusLost"); -} - -void MainForm::SetJavascriptEnabled() { WebSetting settings = __pWebViewer->GetSetting(); @@ -569,13 +578,9 @@ MainForm::InitFooter(void) return E_FAILURE; } - __pMoreButton = static_cast(GetControl(L"IDC_MORE_BUTTON",true)); - - if ( __pMoreButton == NULL ) - { - return E_FAILURE; - } + SetFormBackEventListener(this); + AppLog("SetFormBackEventListener result %s",GetErrorMessage(GetLastResult())); if (__pMultiWindowButton != null) { Bitmap* pBitmap = null; @@ -607,6 +612,11 @@ MainForm::InitFooter(void) __pMultiWindowButton->AddActionEventListener(*this); __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED); + if(pPressedBitmap) + { + delete pPressedBitmap; + pPressedBitmap = null; + } } if (__pMoreButton) @@ -634,10 +644,9 @@ MainForm::InitFooter(void) __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false); __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO); - //__pFooterUrlField->AddFocusEventListener(*this); __pFooterUrlField->AddKeypadEventListener(*this); - //__pFooterUrlField->AddFocusEventListener(*this); __pFooterUrlField->SetPropagatedTouchEventListener(this); + __pFooterUrlField->AddFocusEventListener(*this); if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0) { @@ -645,7 +654,7 @@ MainForm::InitFooter(void) } else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0) { - __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK")); + __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_BLANK_PAGE")); } else { @@ -673,7 +682,14 @@ MainForm::InitFooter(void) } __pGoForwardBtn->SetActionId(IDA_GO_FORWARD); __pGoForwardBtn->AddActionEventListener(*this); - __pGoForwardBtn->SetEnabled(false); + if (__pWebViewer && __pWebViewer->CanGoForward()) + { + SetForwardButtonEnabled(true); + } + else + { + SetForwardButtonEnabled(false); + } __pRefreshBtn = static_cast (GetControl(L"IDC_REFRESH_BUTTON",true)); if (__pRefreshBtn == NULL) @@ -715,30 +731,40 @@ MainForm::InitFooter(void) __pClearBtn->AddActionEventListener(*this); __pClearBtn->SetShowState(false); + __pReaderBtn = static_cast (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); AppLogDebug("MainForm::InitFooter exit"); return E_SUCCESS; } - result -MainForm::InitContextMenu(Point& p) +MainForm::InitOptionMenu() { result r = E_SUCCESS; bool isPrivateBrowsing = false; Bitmap* pBitmap = null; - if (__pMenu != null) + if (__pOptionMenu != null) { - __pMenu->SetAnchorPosition(p); - __pMenu->Invalidate(true); + __pOptionMenu->SetFocusable(true); + __pOptionMenu->Invalidate(true); return r; } - __pMenu = new(std::nothrow) ContextMenu(); - r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST); + __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(); @@ -751,22 +777,22 @@ MainForm::InitContextMenu(Point& p) pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF); } - r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED); + r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED); if ( pBitmap != NULL) { - __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"), IDA_PRIVATEON_CLICKED,*pBitmap); + __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap); delete pBitmap; } - r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED); - r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED); - r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED); + 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); - __pMenu->SetMaxVisibleItemsCount(6); - __pMenu->SetShowState(false); - __pMenu->AddActionEventListener(*this); - SetControlAlwaysOnTop(*__pMenu, true); + __pOptionMenu->SetMaxVisibleItemsCount(6); + __pOptionMenu->SetShowState(false); + __pOptionMenu->AddActionEventListener(*this); + SetControlAlwaysOnTop(*__pOptionMenu, true); CATCH: return r; @@ -783,16 +809,11 @@ result MainForm::InitImageContextMenu(Tizen::Graphics::Point p) delete __pImageMenu; __pImageMenu = null; } - - p.y = p.y + __pAddressbar->GetHeight() + 12; - if(p.y < 100) - { - direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD; - } - else + if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE) { - direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD; + 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)); @@ -800,10 +821,11 @@ result MainForm::InitImageContextMenu(Tizen::Graphics::Point p) r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED); 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_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_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; } @@ -821,9 +843,47 @@ MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p) __pImageMenu = null; } - p.y = p.y + __pAddressbar->GetHeight() + 12; - if (p.y < 100) +// 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; + ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO; + + AppLog("MainForm::InitSelectTextContextMenu clicked on text"); + if (__pImageMenu != null) + { + delete __pImageMenu; + __pImageMenu = null; + } + + if(p.y < 150) { + p.y = p.y + 50; direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD; } else @@ -831,23 +891,34 @@ MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p) direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD; } __pImageMenu = new (std::nothrow) ContextMenu(); - r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction); + r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction); TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r)); - r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED); - r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,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); + if(onlyPasteOption == false) + { + r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED); + } + if (pasteOption || onlyPasteOption) + { + 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::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false) +result +MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPasteOption = false) { result r = E_SUCCESS; ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO; @@ -858,9 +929,10 @@ result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteO delete __pImageMenu; __pImageMenu = null; } - p.y = p.y + __pAddressbar->GetHeight() + 12; - if(p.y < 100) + + if(p.y < 150) { + p.y = p.y + 50; direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD; } else @@ -888,6 +960,7 @@ result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteO __pImageMenu->SetMaxVisibleItemsCount(3); __pImageMenu->AddActionEventListener(*this); SetControlAlwaysOnTop(*__pImageMenu, true); + __pImageMenu->SetFocusable(true); CATCH: return r; @@ -911,6 +984,20 @@ MainForm::InitFindWordPanel(void) 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; } @@ -921,12 +1008,18 @@ MainForm::InitFindWordPanel(void) AppLogException("There is some problem in the xml file. Please check."); return E_FAILURE; } - AddControl(*__pFindWordControl); + AddControl(__pFindWordControl); __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight()); SetControlAlwaysOnTop(*__pFindWordControl,true); __pFindWordControl->SetShowState(false); __pFindWordControl->Invalidate(false); + __pFindWordPanelLeftToRight = static_cast(__pFindWordControl->GetControl(L"IDC_PANEL1", true)); + __pFindWordPanelLeftToRight->SetShowState(true); + + __pFindWordPanelRightToLeft = static_cast(__pFindWordControl->GetControl(L"IDC_PANEL2", true)); + __pFindWordPanelRightToLeft->SetShowState(false); + __pFindWordBgLabel = static_cast(__pFindWordControl->GetControl(L"IDC_LABEL1", true)); if (__pFindWordBgLabel != null) { @@ -947,6 +1040,26 @@ MainForm::InitFindWordPanel(void) } } + __pFindWordBgLabelRightToLeft = static_cast(__pFindWordControl->GetControl(L"IDC_LABEL2", true)); + if (__pFindWordBgLabelRightToLeft != null) + { + Panel* pPanel1 = static_cast(__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.9.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(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true)); if (pfindWordCancel == null) @@ -964,9 +1077,19 @@ MainForm::InitFindWordPanel(void) return E_FAILURE; } + __pFindWordClearRightToLeft = static_cast(__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(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true)); if (__pFindWordNext == null) { @@ -997,6 +1120,13 @@ MainForm::InitFindWordPanel(void) return E_FAILURE; } + __pFindWordCountLabelRightToLeft = static_cast(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true)); + if (__pFindWordCountLabel == null) + { + AppLogException("There is some problem in the xml file. Please check."); + return E_FAILURE; + } + __pFindWordEditField = static_cast(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true)); if (__pFindWordEditField == null) { @@ -1006,7 +1136,24 @@ MainForm::InitFindWordPanel(void) __pFindWordEditField->AddTextEventListener(*this); __pFindWordEditField->AddKeypadEventListener(*this); __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false); + __pFindWordEditField->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00)); + + __pFindWordEditFieldRightToLeft = static_cast(__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; } @@ -1042,7 +1189,7 @@ MainForm::CreateItem (int index, int itemWidth) if (pageURL.GetLength() == 0) { String nourl; - pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl); + pAppResource->GetString(L"IDS_BR_BODY_BLANK_PAGE", nourl); pageURL = L"<"+ nourl +">"; } @@ -1050,7 +1197,7 @@ MainForm::CreateItem (int index, int itemWidth) Rectangle screenBounds = GetBounds(); if (pItem != null) { - r = pItem->Construct(Dimension(itemWidth, 128), style); + r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style); } if (IsFailed(r)) { @@ -1075,8 +1222,8 @@ MainForm::CreateItem (int index, int itemWidth) if ( pListIconImage != NULL) { - listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72); - pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60); + 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); @@ -1090,7 +1237,7 @@ MainForm::CreateItem (int index, int itemWidth) { if (pItem != null) { - pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true); + pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true); } } @@ -1158,10 +1305,18 @@ MainForm::GetItemCount (void) void MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state) { - History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index)); - String url = pHistory->GetHistoryUrl(); - HistoryPresentationModel::GetInstance()->DeleteHistory(url); - __pMostVisitedListView->UpdateList(); + 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 @@ -1185,14 +1340,40 @@ result MainForm::OnTerminating(void) { result r = E_SUCCESS; - if(__pItemContext) + + 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) + if (__pItemContextLandscape) { delete __pItemContextLandscape; } + if (__pSaveImage) + { + delete __pSaveImage; + } + if (__pMostVisitedSites) + { + __pMostVisitedSites->RemoveAll(true); + delete __pMostVisitedSites; + } return r; } @@ -1204,41 +1385,77 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) AppLogDebug("Clicked : %d", actionId); switch (actionId) { -// case IDA_BACKBTN_CLICKED: -// { -// if (__pWebViewer && __pWebViewer->CanGoBack()) -// { -// __pWebViewer->GoBack(); -// } -// else -// { -// UiApp* pApp = null; -// pApp = UiApp::GetInstance(); -// if (pApp != null) -// { -// r = pApp->Terminate(); -// if (IsFailed(r)) -// { -// AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r)); -// return; -// } -// } -// } -// } -// break; - case IDA_BACKBTN_CLICKED: + { + if(__pImageMenu && __pImageMenu->GetShowState() == true) + { + AppLog("Hiding the menu"); + __pImageMenu->SetShowState(false); + } + if (__pWebViewer && __pWebViewer->CanGoBack()) { - if (__pWebViewer && __pWebViewer->CanGoBack()) + __pWebViewer->GoBack(); + } + else if(__pWindowInfo->isJavascriptInitiated == false) + { + UiApp* pApp = null; + pApp = UiApp::GetInstance(); + if (pApp != null) + { + RemoveOrientationEventListener(*this); + + if(__pAddressbar) + { + __pAddressbar->SetAddressbarEventListener(null); + } + + if(__pWebViewer) + { + __pWebViewer->RemoveTouchEventListener(*this); + __pWebViewer->SetWebUiEventListenerF(null); + __pWebViewer->SetWebKeypadEventListener(null); + __pWebViewer->SetTextSearchListener(null); + __pWebViewer->SetLoadingListener(null); + } + r = pApp->Terminate(); + 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) { - __pWebViewer->GoBack(); + return; } - else if(__pWindowInfo->isJavascriptInitiated == false) + ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList(); + if (pAllWindowList == NULL) { - UiApp* pApp = null; pApp = UiApp::GetInstance(); if (pApp != null) { + RemoveOrientationEventListener(*this); + + if(__pAddressbar) + { + __pAddressbar->SetAddressbarEventListener(null); + } + + if(__pWebViewer) + { + __pWebViewer->RemoveTouchEventListener(*this); + __pWebViewer->SetWebUiEventListenerF(null); + __pWebViewer->SetWebKeypadEventListener(null); + __pWebViewer->SetTextSearchListener(null); + __pWebViewer->SetLoadingListener(null); + } r = pApp->Terminate(); if (IsFailed(r)) { @@ -1247,22 +1464,33 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) } } } - else + if (pAllWindowList != null) { - 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) + 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) { + RemoveOrientationEventListener(*this); + + if(__pAddressbar) + { + __pAddressbar->SetAddressbarEventListener(null); + } + + if(__pWebViewer) + { + __pWebViewer->RemoveTouchEventListener(*this); + __pWebViewer->SetWebUiEventListenerF(null); + __pWebViewer->SetWebKeypadEventListener(null); + __pWebViewer->SetTextSearchListener(null); + __pWebViewer->SetLoadingListener(null); + } r = pApp->Terminate(); if (IsFailed(r)) { @@ -1271,24 +1499,8 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) } } } - totalCount = pAllWindowList->GetCount(); - - for (int count = 0; count < totalCount; count++) + else { - pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count)); - if (pWindowInfo == null) - { - pApp = UiApp::GetInstance(); - if (pApp != null) - { - r = pApp->Terminate(); - if (IsFailed(r)) - { - AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r)); - return; - } - } - } if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true) { r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID); @@ -1317,6 +1529,22 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) pApp = UiApp::GetInstance(); if (pApp != null) { + + RemoveOrientationEventListener(*this); + + if(__pAddressbar) + { + __pAddressbar->SetAddressbarEventListener(null); + } + + if(__pWebViewer) + { + __pWebViewer->RemoveTouchEventListener(*this); + __pWebViewer->SetWebUiEventListenerF(null); + __pWebViewer->SetWebKeypadEventListener(null); + __pWebViewer->SetTextSearchListener(null); + __pWebViewer->SetLoadingListener(null); + } r = pApp->Terminate(); return; } @@ -1332,11 +1560,10 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) } break; } - } - } } + } break; case IDA_FORWARD_CLICKED: @@ -1347,8 +1574,8 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) { __pWebViewer->GoForward(); } - __pMenu->SetShowState(false); - __pMenu->Invalidate(false); + __pOptionMenu->SetShowState(false); + __pOptionMenu->Invalidate(false); break; case IDA_FINDONPAGE_CLICKED: @@ -1357,18 +1584,21 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) __currentSearchStr.Clear(); InitFindWordPanel(); - __pMenu->SetShowState(false); - __pMenu->Invalidate(false); + __pOptionMenu->SetShowState(false); + __pOptionMenu->Invalidate(false); - __pFindWordEditField->SetFocus(); - /* - if (__pWebViewer != null) - { - // releasing the set block - __pWebViewer->ReleaseBlock(); - } - */ ShowFindWordPanel(true); + + if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true) + { + __pFindWordEditField->SetFocus(); +// __pFindWordCountLabel->SetShowState(false); + } + else + { + __pFindWordEditFieldRightToLeft->SetFocus(); + __pFindWordCountLabelRightToLeft->SetShowState(false); + } } break; case IDA_PRIVATEON_CLICKED: @@ -1421,12 +1651,10 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) } } - - itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED); - r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap); + 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); - __pMenu->Invalidate(true); - + __pOptionMenu->Invalidate(true); if ( pBitmap != NULL ) { delete pBitmap; @@ -1444,8 +1672,9 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) pArgList->Add(*__pWindowInfo); SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList); } - __pMenu->SetShowState(false); - __pMenu->Invalidate(false); + __pOptionMenu->SetShowState(false); + __pOptionMenu->Invalidate(false); + if (pArgList != null) { delete pArgList; @@ -1478,12 +1707,17 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) BookmarkPresentationModel::GetInstance()->DeleteBookmark(url); pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP); - NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this); - if (pNotification != null) + if(__pNotification != null) + { + RemoveControl(__pNotification); + __pNotification = null; + } + __pNotification = new (std::nothrow) NotificationPanel(*this); + if (__pNotification != null) { - pNotification->SetText(message); - pNotification->SetPositionDiff(__pFooterPanel->GetHeight()); - pNotification->ShowNotification(); + __pNotification->SetText(message); + __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12); + __pNotification->ShowNotification(); } } else @@ -1503,26 +1737,96 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark); r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark); delete pBookmark; - - NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this); - if (pNotification != null) + if(__pNotification != null) { - pNotification->SetText(message); - pNotification->SetPositionDiff(__pFooterPanel->GetHeight()); - pNotification->ShowNotification(); + 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 = __pMenu->SetItemAt(0,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap); + r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap); delete pBitmap; } + + + __pOptionMenu->Invalidate(true); } - __pMenu->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) @@ -1530,6 +1834,10 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) delete __pPopUp; __pPopUp = null; } + if(__pAddressbar) + { + __pAddressbar->HideKeypad(); + } __pPopUp = new(std::nothrow) SharePopup(); __pPopUp->Initialize(); if (__pWindowInfo != null) @@ -1558,13 +1866,10 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) break; case IDA_MOREBTN_CLICKED: { - AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1"); - Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight()); - AppLog("Anchot pos: %d %d", p.x, p.y); - InitContextMenu(p); + AppLog("IDA_MOREBTN_CLICKED"); + InitOptionMenu(); if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true) { - AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2"); int bookmarkCount=0; bool exist = false; String url=L""; @@ -1588,13 +1893,13 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) } AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3"); - if (__pMenu->GetItemCount() == 8) + if (__pOptionMenu->GetItemCount() == 9) { - r = __pMenu->SetItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap); + r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap); } else { - r = __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap); + r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap); } if (IsFailed(r)) @@ -1604,34 +1909,35 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) return ; } AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4"); - if (__pMenu->GetItemCount() != 8) + if (__pOptionMenu->GetItemCount() != 9) { - __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADDTOBOOKMARK_CLICKED); - -// __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED); - __pMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED); - __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED); - __pMenu->SetMaxVisibleItemsCount(6); + __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) { AppLog(" Orientation landscape"); - __pMenu->SetMaxVisibleItemsCount(5); + __pOptionMenu->SetMaxVisibleItemsCount(5); } else { AppLog(" Orientation potrait"); - __pMenu->SetMaxVisibleItemsCount(6); + __pOptionMenu->SetMaxVisibleItemsCount(6); } AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5"); delete pBitmap; } AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end"); - __pMenu->SetShowState(true); - __pMenu->Invalidate(true); - __pMenu->Show(); - } + __pOptionMenu->SetShowState(true); + __pOptionMenu->Invalidate(true); + __pOptionMenu->Show(); + +} break; case IDA_HISTORY_CLICKED: { @@ -1663,7 +1969,7 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) case IDA_NEWWINDOWBTN_CLICKED: { - WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene(); + WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(); if (pNewWindowInfo == null) { @@ -1714,16 +2020,11 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) { if (__pArticleReaderPanel != null && __pBlankPanel != null) { - //__pArticleReaderPanel->SetShowState(false); - //__pArticleReaderPanel->Show(); - RemoveControl(*__pBlankPanel); - //RemoveControl(*__pArticleReaderPanel); + RemoveControl(__pBlankPanel); __pArticleReaderPanel = null; __pBlankPanel = null; __pArticleReaderLabel = null; } - //if (__pAddressbar) - // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE); SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE); } break; @@ -1732,17 +2033,39 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) __currentSearchStr = L""; __currentWordIndex = 0; __maxOccurrances = 0; - __pFindWordEditField->SetText(L""); + + 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->SearchText(L"aaaabbbbcccc",true); + AppLog("akjshdasd 1"); + if(__isKeypadOpened == false) + __pFooterPanel->SetShowState(true); ShowFindWordPanel(false); } break; case IDA_FINDWORD_SEARCH_CLICKED: { - __currentSearchStr = __pFindWordEditField->GetText(); + if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true) + { + __currentSearchStr = __pFindWordEditField->GetText(); + } + else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true) + { + __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText(); + } + if (__currentSearchStr.GetLength() > 0) { StartWordSearch(); @@ -1762,6 +2085,20 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) __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; @@ -1787,19 +2124,20 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) AppLogDebug("IDA_COPY_IMAGE_CLICKED"); ClipboardItem item; const Bitmap* pBitmap = null; - if (__pHitElementResult != null) + if (__pHitElementResult != null && __pHitElementResult->HasImage()) { pBitmap = __pHitElementResult->GetImage(); } String resourcePath = App::GetInstance()->GetAppResourcePath(); - item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap); - + 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) { - pClipboard->CopyItem(item); + r = pClipboard->CopyItem(item); + AppLog("Platofrm copy failed result %s",GetErrorMessage(r)); } } break; @@ -1837,15 +2175,28 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) { UpdateImageContent(pBuffer, imageName); delete pBuffer; - NotificationPanel *pNotification = new NotificationPanel(*this); + 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) + if (__pNotification != null) { - pNotification->SetText(msg); - pNotification->SetPositionDiff(__pFooterPanel->GetHeight()); - pNotification->ShowNotification(); + __pNotification->SetText(msg); + if (__pFooterPanel->GetShowState() == true) + { + __pNotification->SetPositionDiff(__pFooterPanel->GetHeight()); + } + else + { + __pNotification->SetPositionDiff(0); + } + + __pNotification->ShowNotification(); } } else @@ -1868,6 +2219,10 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) delete __pPopUp; __pPopUp = null; } + if(__pAddressbar) + { + __pAddressbar->HideKeypad(); + } __pPopUp = new(std::nothrow) SharePopup(); __pPopUp->Initialize(); if (__pHitElementResult != null) @@ -1903,33 +2258,64 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) break; case IDA_HYPERLINK_OPEN_CLICKED: { - AppLogDebug("IDA_VIEW_IMAGE_CLICKED"); - WindowInfo* pNewWindowInfo = null; if (__pHitElementResult != null) { String srcUrl = __pHitElementResult->GetUrl(); - AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer()); - LoadUrl(srcUrl); + + WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl); + + 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; + } + 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(); - - if(__pHitElementResult == null) - { - return; - } - pShareInfo->SetPageUrl(__pHitElementResult->GetUrl()); pShareInfo->SetImageAttached(false); __pPopUp->RemoveAllShareInfo(); @@ -1961,35 +2347,46 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) 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(); - if(__pMenu != null) + __pFindWordEditField->SetText(__currentSearchStr); + + if(__pOptionMenu != null) { - __pMenu->SetShowState(false); - __pMenu->Invalidate(false); + __pOptionMenu->SetShowState(false); + __pOptionMenu->Invalidate(false); } - __adressPanelPosition.y = 0; if (__pAddressbar != null && __pWebViewer != NULL) { __webControlPosition.y = __pAddressbar->GetHeight() - 12; - //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight()); - //__pAddressbar->Invalidate(true); __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12); 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->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight)); __pWebViewer->Invalidate(true); } ShowFindWordPanel(true); - __pFindWordEditField->SetFocus(); + 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(); @@ -2009,12 +2406,17 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) 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) @@ -2032,6 +2434,7 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) break; case IDA_COPY_TEXT_CLICKED: { + __pWebViewer->ReleaseBlock(); // need to implement //__currentSelectedStr // Sets data to a clip board item @@ -2069,19 +2472,23 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) { String idElement = __pHitElementResult->GetAttributeValue(L"id"); String nameElement = __pHitElementResult->GetAttributeValue(L"name"); + String tagElement = __pHitElementResult->GetTagName(); AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer()); - 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; } } "; + + String script; if(idElement.GetLength() != 0) { - script.Append("insertAtCursor("); + script = L"function insertAtCursor(myField, myValue) { if (document.selection) { document.getElementById(myField).focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (document.getElementById(myField).selectionStart || document.getElementById(myField).selectionStart == '0'){ var startPos = document.getElementById(myField).selectionStart; var endPos = document.getElementById(myField).selectionEnd; document.getElementById(myField).value = document.getElementById(myField).value.substring(0, startPos)+ myValue + document.getElementById(myField).value.substring(endPos, document.getElementById(myField).value.length); } else { document.getElementById(myField).value += myValue; } } "; + script.Append("insertAtCursor('"); script.Append(idElement); - script.Append(","); + script.Append("',"); script.Append("\""); script.Append(*pString); script.Append("\");"); } else if (nameElement.GetLength() != 0) { + script = L"function insertAtCursor(myField, myValue) { if (document.selection) { document.getElementByName(myField)[0].focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0'){ var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length); } else { document.getElementByName(myField)[0].value += myValue; } } "; script.Append("insertAtCursor(document.getElementsByName('"); script.Append(nameElement); script.Append("')[0],"); @@ -2089,6 +2496,16 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) script.Append(*pString); script.Append("\");"); } + else//adding for twitter post page + { + script = L"function insertAtCursor(myField, myValue) { if (document.selection) { document.getElementsByTagName(myField)[0].focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0'){ var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length); } else { document.getElementsByTagName(myField)[0].value += myValue; } } "; + script.Append("insertAtCursor(document.getElementsByTagName('"); + script.Append(tagElement); + script.Append("')[0],"); + script.Append("\""); + script.Append(*pString); + script.Append("\");"); + } AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer()); String* pStr = __pWebViewer->EvaluateJavascriptN(script); delete pStr; @@ -2115,7 +2532,12 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) String url = __pFooterUrlField->GetText(); AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer()); - LoadUrl(url); +// LoadUrl(url); + if (__pWebViewer != null && __pAddressbar != null) + { + __pWebViewer->Reload(); + SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING); + } //OnUrlSubmitted(); UpdateProgressBitmap(); @@ -2146,9 +2568,15 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) { //__displayUrl = __pUrlField->GetText(); __pFooterUrlField->Clear(); + } } break; + case IDA_READER_BTN_CLICKED: + { + ReaderClicked(); + } + break; default: break; } @@ -2157,104 +2585,288 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) void MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source) { - - UiApp* pApp = UiApp::GetInstance(); - if (pApp == null) + result r = E_FAILURE; + if(__pImageMenu && __pImageMenu->GetShowState() == true) { - return; + AppLog("Hiding the menu"); + __pImageMenu->SetShowState(false); } - pApp->Terminate(); -} - -void -MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, - const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs) -{ - String* pSelectedScene = NULL; - Object* pValue = NULL; - String* pUrl = null; - MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue); - pSelectedScene = (String*) pValue; - - if (pSelectedScene != null) + if (__pWebViewer && __pWebViewer->CanGoBack()) { - delete pSelectedScene; + __pWebViewer->GoBack(); } - 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) + else if(__pWindowInfo->isJavascriptInitiated == false) { - __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0)); - if(__pWindowInfo == null) - return; - // if(__pWindowInfo == null) + UiApp* pApp = null; + pApp = UiApp::GetInstance(); + if (pApp != null) { - pUrl = dynamic_cast< String* >(pArgs->GetAt(1)); - } - } - else if ( pArgs != null && pArgs->GetCount() == 1) - { - __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0)); - } - - InitFooter(); - InitAddressbar(); + RemoveOrientationEventListener(*this); - // 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(__pAddressbar) + { + __pAddressbar->SetAddressbarEventListener(null); + } - if(pUrl != null && pUrl->GetLength() > 0) - { - LoadUrl(*pUrl); + if(__pWebViewer) + { + __pWebViewer->RemoveTouchEventListener(*this); + __pWebViewer->SetWebUiEventListenerF(null); + __pWebViewer->SetWebKeypadEventListener(null); + __pWebViewer->SetTextSearchListener(null); + __pWebViewer->SetLoadingListener(null); + } + r = pApp->Terminate(); + if (IsFailed(r)) + { + AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r)); + return; + } + } } - else if(__pWindowInfo != null) + else { - 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) + UiApp* pApp = null; + WindowInfo* pWindowInfo = null; + int totalCount = 0; + SceneManager* pSceneManager = SceneManager::GetInstance(); + if (pSceneManager == null) { - LoadUrl(__pWindowInfo->pageUrl); + return; } - else if (__pWindowInfo->isJavascriptInitiated == true) + ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList(); + if (pAllWindowList == NULL) { - AppLog("Called"); - InitWebControl(); - __pWindowInfo->pCurrentWeb = __pWebViewer; - } - } - - 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()); - } - - 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); + pApp = UiApp::GetInstance(); + if (pApp != null) + { + RemoveOrientationEventListener(*this); - if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0) - __pWebViewer->LoadUrl(*pBookmarkUrl); - delete pBookmarkUrl; - } + if(__pAddressbar) + { + __pAddressbar->SetAddressbarEventListener(null); + } + + if(__pWebViewer) + { + __pWebViewer->RemoveTouchEventListener(*this); + __pWebViewer->SetWebUiEventListenerF(null); + __pWebViewer->SetWebKeypadEventListener(null); + __pWebViewer->SetTextSearchListener(null); + __pWebViewer->SetLoadingListener(null); + } + r = pApp->Terminate(); + 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) + { + RemoveOrientationEventListener(*this); + + if(__pAddressbar) + { + __pAddressbar->SetAddressbarEventListener(null); + } + + if(__pWebViewer) + { + __pWebViewer->RemoveTouchEventListener(*this); + __pWebViewer->SetWebUiEventListenerF(null); + __pWebViewer->SetWebKeypadEventListener(null); + __pWebViewer->SetTextSearchListener(null); + __pWebViewer->SetLoadingListener(null); + } + r = pApp->Terminate(); + if (IsFailed(r)) + { + AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r)); + return; + } + } + } + else + { + if (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) + { + RemoveOrientationEventListener(*this); + + if(__pAddressbar) + { + __pAddressbar->SetAddressbarEventListener(null); + } + + if(__pWebViewer) + { + __pWebViewer->RemoveTouchEventListener(*this); + __pWebViewer->SetWebUiEventListenerF(null); + __pWebViewer->SetWebKeypadEventListener(null); + __pWebViewer->SetTextSearchListener(null); + __pWebViewer->SetLoadingListener(null); + } + r = pApp->Terminate(); + return; + } + } + else + { + r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE)); + if (IsFailed(r)) + { + AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r)); + return; + } + } + break; + } + } + } + } +} + +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(); + + __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight()); + + // 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); + } + else if (__pWindowInfo->isJavascriptInitiated == true) + { + AppLog("Called"); + InitWebControl(); + __pWindowInfo->pCurrentWeb = __pWebViewer; + } + } + + 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 (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0) + { + if(__pMostVisitedListView != null) + { + __pMostVisitedListView->SetShowState(false); + } + } + + 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; @@ -2288,13 +2900,13 @@ MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, } } - if (__pMenu != null && __pMenu->GetItemCount() == 3) + if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9) { - __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap); + __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap); } - else if (__pMenu != null ) + else if (__pOptionMenu != null ) { - __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap); + __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap); } if (pBitmap != null) @@ -2302,6 +2914,7 @@ MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, delete pBitmap; } + RelayoutControls(false); AppLog("ABC: OnSceneActivatedN started exit"); } @@ -2314,7 +2927,6 @@ MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, if (__pWebViewer != null) { pWebCanvas = __pWebViewer->GetCanvasN(); - __pWebViewer->Pause(); } if (pWebCanvas == null) @@ -2346,6 +2958,9 @@ MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap(); WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight())); delete pCanvas; + delete pWebCanvas; + if(__pAddressbar) + __pAddressbar->SetShowState(false); AppLog("Coming here"); } @@ -2371,11 +2986,26 @@ MainForm::OnLoadingStarted(void) { 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":;"); + String delim(L":;,"); // Creates a StringTokenizer instance StringTokenizer strTok(url, delim); @@ -2396,20 +3026,19 @@ MainForm::OnLoadingStarted(void) token.SubString(6, appId); AppLog("AppID:%ls", appId.GetPointer()); } - else if(token.Contains("=")) + else if(token.Contains(IDS_KEY)) { - String *pKey = new String(); - String *pValue = new String(); - int index = -1; - token.IndexOf("=", 0, index); - if(index != -1) - { - token.SubString(0, index, *pKey); - token.SubString(index + 1, *pValue); - pMap->Add(pKey, pValue); - } + 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; @@ -2428,6 +3057,12 @@ MainForm::OnLoadingStarted(void) return; } } + if ( __pAddressbar != null && __pAddressbar->GetShowState() == true) + { + __pAddressbar->SetShowState(false); + AddressBarCancelledClicked(*__pAddressbar); + __pAddressbar->Invalidate(true); + } Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN(); if(pBitmap != null) { @@ -2451,6 +3086,8 @@ MainForm::OnLoadingStarted(void) 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); @@ -2468,37 +3105,32 @@ MainForm::OnLoadingCanceled(void) void MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source) { - AppLog("MainForm::OnKeypadWillOpen"); - if (__pAddressbar != null) - { - OnAddressBarKeypadWillOpen(*__pAddressbar); - } + AppLog("XYZ::MainForm::OnKeypadWillOpen"); } void MainForm::OnKeypadOpened(Tizen::Ui::Control& source) { - if(__pAddressbar != null) - { - OnAddressBarKeypadOpened(*__pAddressbar); - } -} + AppLog("XYZ::MainForm::OnKeypadOpened"); + __isKeypadOpened = true; + __pFooterPanel->SetShowState(false); +} void MainForm::OnKeypadClosed(Tizen::Ui::Control& source) { - if (__pAddressbar != null) - { - OnAddressBarKeypadClosed(*__pAddressbar); - } + AppLog("XYZ::MainForm::OnKeypadClosed"); + __isKeypadOpened = false; + __pFooterPanel->SetShowState(true); + RelayoutControls(true); } void MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source) { - AppLog("KeypadBoundsChanged"); + AppLog("XYZ::KeypadBoundsChanged"); RelayoutControls(false); } @@ -2525,6 +3157,13 @@ MainForm::OnLoadingCompleted(void) { return; } + + if(__pImageMenu && __pImageMenu->GetShowState()) + { + __pImageMenu->SetShowState(false); + __pImageMenu->Invalidate(true); + } + if (__pWebViewer->CanGoForward()) { //__pAddressbar->SetForwardButtonEnabled(true); @@ -2554,22 +3193,23 @@ MainForm::OnLoadingCompleted(void) bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn(); if (isPrivateBrowsing == false) { - History* pHistory = new(std::nothrow) History; + if(__pHistory != null) + { + delete __pHistory; + __pHistory = null; + } + __pHistory = new(std::nothrow) History; HistoryPresentationModel::GetCurrentDateTime(date); - if(__pWindowInfo) + if (__pWindowInfo) { - pHistory->SetHistoryTitle(__pWindowInfo->pageTitle); + __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle); AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer()); - pHistory->SetHistoryUrl(__pWindowInfo->pageUrl); + __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl); AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer()); } - pHistory->SetVisitedTime(date); - /*String id = ""; - if(__pWindowInfo) - id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl); - pHistory->SetFaviconId(id);*/ + __pHistory->SetVisitedTime(date); if (__pWebViewer != null) { @@ -2579,7 +3219,7 @@ MainForm::OnLoadingCompleted(void) if (pTempBitmap != null) { AppLog("MainForm::OnLoadingCompleted setting the fav icon 1"); - pHistory->SetFavIconBitmap(*pTempBitmap); + __pHistory->SetFavIconBitmap(*pTempBitmap); } AppLog("MainForm::OnLoadingCompleted setting the fav icon 2"); @@ -2591,27 +3231,92 @@ MainForm::OnLoadingCompleted(void) { pBitmap->Construct(*pCanvas, pCanvas->GetBounds()); pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4)); - pHistory->SetThumbnail(pBitmap); + __pHistory->SetThumbnail(pBitmap); } Bitmap *pFavIcon = __pWebViewer->GetFaviconN(); - if(pFavIcon) + if (pFavIcon) { - pHistory->SetFavIconBitmap(*pFavIcon); + __pHistory->SetFavIconBitmap(*pFavIcon); delete pFavIcon; } - HistoryPresentationModel::GetInstance()->SaveTempHistory(*pHistory); - delete pHistory; + HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory); + //delete pHistory; } else { return; } - if (__pWindowInfo && __pWindowInfo->faviconUrl == "") +// 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"

Chinese PM Li Keqiang vows to open up markets to India

Chinese PM Li Keqiang vows to open up markets to India

"); +// 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"); } @@ -2619,6 +3324,7 @@ void MainForm::OnEstimatedProgress(int progress) { AppLogDebug("MainForm::OnEstimatedProgress entered"); + if (progress < DEFAULT_PROGRESS_PERCENTAGE) progress = DEFAULT_PROGRESS_PERCENTAGE; //if(__pAddressbar) @@ -2629,12 +3335,14 @@ MainForm::OnEstimatedProgress(int progress) void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon) { AppLog("MainForm::OnFaviconReceived"); - Bitmap* pFavIconBitmap = __pWebViewer->GetFaviconN(); - - if (pFavIconBitmap != null) + if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0)) { - pFavIconBitmap->GetWidth(); - pFavIconBitmap->GetHeight(); + Bitmap* favIcon = __pWebViewer->GetFaviconN(); + if(favIcon != null) + { + HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon); + delete favIcon; + } } } @@ -2651,12 +3359,9 @@ MainForm::OnUrlSubmitted(Addressbar& addBar) String url = addBar.GetUrl(); AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer()); -// __pFooterPanel->SetShowState(true); if(__pFooterUrlField) __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength()); - OnAddressCancelledClicked(*__pAddressbar); -// __pAddressbar->SetShowState(false); -// RelayoutControls(false); + AddressBarCancelledClicked(*__pAddressbar); LoadUrl(url); } @@ -2703,6 +3408,7 @@ MainForm::LoadUrl(String& url) if (ret == true && __pWebViewer != null) { + SetUrl(url); __pWebViewer->LoadUrl(url); } else if(__pWebViewer != null) @@ -2733,140 +3439,107 @@ MainForm::LoadUrl(String& url) } void -MainForm::OnStopClicked(Addressbar& addBar) +MainForm::OnFocusGained(const Tizen::Ui::Control& source) { - AppLogDebug("MainForm::OnStopClicked called"); - if (__pWebViewer) + AppLog("MainForm::OnFocusGained"); + if(__pFooterPanel) { - //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE); - SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE); - __pWebViewer->StopLoading(); - RequestRedraw(true); + __pFooterPanel->SetShowState(false); } -} -void -MainForm::OnReaderClicked(const Addressbar& addBar) -{ - int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73; - - CreateReaderPanel(); - AppLogDebug("MainScene::OnReaderClicked entered"); + 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"); + } - /*if (__pArticleReaderPanel) - { - AppLogDebug("showstate true for reader panel"); - __pArticleReaderPanel->SetShowState(true); - __pArticleReaderPanel->Show(); - }*/ - int xPos = __pArticleReaderPanel->GetX(); - int yPos = __pArticleReaderPanel->GetY(); - AppLog("OnReaderClicked() xPos = %d",xPos); - AppLog("OnReaderClicked() yPos = %d",yPos); + __pFindWordNext->SetEnabled(false); + __pFindWordPrev->SetEnabled(false); - if (__pReaderData == null) - { - return; + __pWebViewer->SearchText(L"aaaabbbbcccc",true); + __pFindWordControl->SetShowState(false); } + RelayoutControls(false); +} - String loadData = L"\ - \ - \ - \ - \ - "); - AppLogDebug("data->GetLength %d",__pReaderData->GetLength()); - loadData.Append(*__pReaderData); - loadData.Append(L""); - - ByteBuffer buf ; - buf.Construct(loadData.GetLength()); - AppLogDebug("data->GetLength %d",loadData.GetLength()); - for (int z=0;zLoadData(L"",buf,L"text/html"); - AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult())); - } - else +void +MainForm::OnFocusLost(const Tizen::Ui::Control& source) +{ + AppLog("MainForm::OnFocusLost called"); +} + +void +MainForm::OnStopClicked(Addressbar& addBar) +{ + AppLogDebug("MainForm::OnStopClicked called"); + if (__pWebViewer) { - AppLogDebug("cannot LoadData __pWebReader is null"); + //__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"); + // AppLog("MainForm::OnBackClicked"); result r = E_FAILURE; -// -// if (__pWebViewer != null && __pWebViewer->CanGoBack()) -// { -// __pWebViewer->GoBack(); -// } -// else -// { -// UiApp* pApp = null; -// pApp = UiApp::GetInstance(); -// if(pApp != null) -// { -// r = pApp->Terminate(); -// if (IsFailed(r)) -// { -// return; -// } -// } -// } - - - - - - - + if(__pImageMenu && __pImageMenu->GetShowState() == true) + { + AppLog("Hiding the menu"); + __pImageMenu->SetShowState(false); + } if (__pWebViewer && __pWebViewer->CanGoBack()) { __pWebViewer->GoBack(); } - else if(__pWindowInfo->isJavascriptInitiated == false) + else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false) { UiApp* pApp = null; pApp = UiApp::GetInstance(); if (pApp != null) { + + RemoveOrientationEventListener(*this); + + if(__pAddressbar) + { + __pAddressbar->SetAddressbarEventListener(null); + } + + if(__pWebViewer) + { + __pWebViewer->RemoveTouchEventListener(*this); + __pWebViewer->SetWebUiEventListenerF(null); + __pWebViewer->SetWebKeypadEventListener(null); + __pWebViewer->SetTextSearchListener(null); + __pWebViewer->SetLoadingListener(null); + } + + r = pApp->Terminate(); if (IsFailed(r)) { @@ -2891,6 +3564,23 @@ MainForm::OnBackClicked(/*const Addressbar& addBar*/) pApp = UiApp::GetInstance(); if (pApp != null) { + RemoveOrientationEventListener(*this); + + if(__pAddressbar) + { + __pAddressbar->SetAddressbarEventListener(null); + } + + if(__pWebViewer) + { + __pWebViewer->RemoveTouchEventListener(*this); + __pWebViewer->SetWebUiEventListenerF(null); + __pWebViewer->SetWebKeypadEventListener(null); + __pWebViewer->SetTextSearchListener(null); + __pWebViewer->SetLoadingListener(null); + } + + r = pApp->Terminate(); if (IsFailed(r)) { @@ -2899,8 +3589,10 @@ MainForm::OnBackClicked(/*const Addressbar& addBar*/) } } } - totalCount = pAllWindowList->GetCount(); - + if (pAllWindowList != null) + { + totalCount = pAllWindowList->GetCount(); + } for (int count = 0; count < totalCount; count++) { pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count)); @@ -2909,6 +3601,23 @@ MainForm::OnBackClicked(/*const Addressbar& addBar*/) pApp = UiApp::GetInstance(); if (pApp != null) { + RemoveOrientationEventListener(*this); + + if(__pAddressbar) + { + __pAddressbar->SetAddressbarEventListener(null); + } + + if(__pWebViewer) + { + __pWebViewer->RemoveTouchEventListener(*this); + __pWebViewer->SetWebUiEventListenerF(null); + __pWebViewer->SetWebKeypadEventListener(null); + __pWebViewer->SetTextSearchListener(null); + __pWebViewer->SetLoadingListener(null); + } + + r = pApp->Terminate(); if (IsFailed(r)) { @@ -2917,7 +3626,7 @@ MainForm::OnBackClicked(/*const Addressbar& addBar*/) } } } - if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true) + if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true) { r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID); if (IsFailed(r)) @@ -2936,15 +3645,59 @@ MainForm::OnBackClicked(/*const Addressbar& addBar*/) { pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1)); } - else + else if(pAllWindowList->GetCount() > 0) { pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1)); } + else + { + pApp = UiApp::GetInstance(); + if (pApp != null) + { + RemoveOrientationEventListener(*this); + + if(__pAddressbar) + { + __pAddressbar->SetAddressbarEventListener(null); + } + + if(__pWebViewer) + { + __pWebViewer->RemoveTouchEventListener(*this); + __pWebViewer->SetWebUiEventListenerF(null); + __pWebViewer->SetWebKeypadEventListener(null); + __pWebViewer->SetTextSearchListener(null); + __pWebViewer->SetLoadingListener(null); + } + + + r = pApp->Terminate(); + return; + } + + } if (pWindowInfo == null) { pApp = UiApp::GetInstance(); if (pApp != null) { + RemoveOrientationEventListener(*this); + + if(__pAddressbar) + { + __pAddressbar->SetAddressbarEventListener(null); + } + + if(__pWebViewer) + { + __pWebViewer->RemoveTouchEventListener(*this); + __pWebViewer->SetWebUiEventListenerF(null); + __pWebViewer->SetWebKeypadEventListener(null); + __pWebViewer->SetTextSearchListener(null); + __pWebViewer->SetLoadingListener(null); + } + + r = pApp->Terminate(); return; } @@ -2981,25 +3734,38 @@ MainForm::OnForwardClicked(/*const Addressbar& addBar*/) } void -MainForm::OnAddressCancelledClicked(const Addressbar& addBar) +MainForm::OnAddressBarFocusGained(const Addressbar& addBar) { - result r = E_SUCCESS; + AppLog("XYZ::MainForm::OnAddressBarFocusGained"); + if(__pFooterPanel != null) + { + __pFooterPanel->SetShowState(false); + } - __pFooterPanel->SetShowState(true); - __pFooterUrlField->SetFocusable(true); + if (__pAddressbar != null && __pAddressbar->GetShowState() == false) + { + __pAddressbar->SetShowState(true); + __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight())); + } - if(__pWebViewer) - __pWebViewer->SetFocus(); - else if(__pMostVisitedListView) - __pMostVisitedListView->SetFocus(); - else if(__pMultiWindowButton) - __pMultiWindowButton->SetFocus(); - __pMoreButton->SetFocus(); + RelayoutControls(false); +} - __pAddressbar->SetShowState(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 @@ -3041,42 +3807,27 @@ MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/) void MainForm::OnClipboardClosed(const Addressbar& addBar) { + AppLog("XYZ::MainForm::OnClipboardClosed"); RelayoutControls(false); } void MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState) { - if(__pAddressbar) - __pAddressbar->SetShowState(false); - if(__pFooterPanel) - __pFooterPanel->SetShowState(true); - if(__pWebViewer) - __pWebViewer->SetFocus(); - if(__pFooterUrlField) + AppLog("XYZ::MainForm::OnAddressBarKeypadClosed"); + if (__pFooterPanel && __pAddressbar->GetShowState() == false) { - __pFooterUrlField->SetFocusable(true); + AppLog("akjshdasd 3"); + __pFooterPanel->SetShowState(true); } - RelayoutControls(false); + + RelayoutControls(false,footerState); } void MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar) { - if (__pFindWordControl && __pFindWordControl->GetShowState() == true) - { - __pAddressbar->SetShowState(false); - } - else - { - if (__pAddressbar != null && __pAddressbar->GetShowState() == false) - { - __pAddressbar->SetShowState(true); - __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight())); - __pAddressbar->SetAddressbarURLFocus(); - } - } - + AppLog("XYZ::MainForm::OnAddressBarKeypadOpened"); RelayoutControls(false); } @@ -3089,13 +3840,14 @@ MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar) void MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar) { - AppLog("KeypadBoundsChanged"); + 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; @@ -3115,7 +3867,9 @@ void MainForm::UpdateFavicon(void) { bool urlImageType = false; - 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();"); + 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) @@ -3170,24 +3924,45 @@ MainForm::UpdateFavicon(void) __pAddressbar->SetFaviconBitmap(*pDefaultBmp); } } + if(pBitmap) + { + delete pBitmap; + pBitmap = null; + } } delete tempPath; } else { - delete tempPath; + // 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 - ShowFindWordPanel(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); @@ -3219,20 +3994,19 @@ MainForm::OnLoadingRequested(const Tizen::Base::String& url, token.SubString(6, appId); AppLog("AppID:%ls", appId.GetPointer()); } - else if(token.Contains("=")) + else if(token.Contains(IDS_KEY)) { - String *pKey = new String(); - String *pValue = new String(); - int index = -1; - token.IndexOf("=", 0, index); - if(index != -1) - { - token.SubString(0, index, *pKey); - token.SubString(index + 1, *pValue); - pMap->Add(pKey, pValue); - } + 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; @@ -3250,11 +4024,6 @@ MainForm::OnLoadingRequested(const Tizen::Base::String& url, } } - if ( __pAddressbar != null) - { - __pAddressbar->SetShowState(false); - __pAddressbar->Invalidate(true); - } return false; } @@ -3265,10 +4034,11 @@ MainForm::OnWebDataReceived(const Tizen::Base::String& mime, return Tizen::Web::Controls::WEB_DECISION_CONTINUE; } - void -MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint) +MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint) { + if(__isLongPressedDone == false) + return; AppLog("MainForm::OnWebPageBlockSelected"); if (__pHitElementResult != null) { @@ -3279,7 +4049,18 @@ MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graph if (__pWebViewer != null) { AppLog("MainForm::OnWebPageBlockSelected web not null"); - __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint); + __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint); + + if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0)) + { + AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult())); + __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint); + if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0)) + { + __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint); + } + AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult())); + } } if (__pHitElementResult == null) @@ -3292,21 +4073,23 @@ MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graph String tagName = __pHitElementResult->GetTagName(); String type = __pHitElementResult->GetAttributeValue("type"); + + 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.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && __isLongPressedDone == true) + if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0) { AppLog("MainForm::OnWebPageBlockSelected show paste option"); - InitSelectTextContextMenu(endPoint,true); + InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),true); __pImageMenu->SetShowState(true); __pImageMenu->Show(); __pImageMenu->Invalidate(true); } - else if(__isLongPressedDone == true) + else /*if(__isLongPressedDone == true)*/ { AppLog("MainForm::OnWebPageBlockSelected no paste option"); @@ -3315,7 +4098,7 @@ MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graph __currentSelectedStr.Clear(); __currentSelectedStr = __pHitElementResult->GetUrl(); } - InitSelectTextContextMenu(endPoint,false); + InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),false); __pImageMenu->SetShowState(true); __pImageMenu->Show(); __pImageMenu->Invalidate(true); @@ -3337,7 +4120,7 @@ MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source) Web* MainForm::OnWebWindowCreateRequested(void) { - WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene(); + WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(); if (pNewWindowInfo == null) { @@ -3374,8 +4157,9 @@ MainForm::OnWebWindowCreateRequested(void) } void -MainForm::RelayoutControls(bool showAddressbar) +MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter) { + AppLog("xyz:: MainForm::RelayoutControls called"); __webControlPosition.y = 0; __webControlHeight = GetClientAreaBounds().height; AppLog("Client area height: %d", __webControlHeight); @@ -3394,15 +4178,23 @@ MainForm::RelayoutControls(bool showAddressbar) __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight()); } - if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true) + if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true) { __webControlHeight -= __pFooterPanel->GetHeight(); + __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight()); } if (__pWebViewer != null && __pWebViewer->GetShowState() == true) { - __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight); - __pWebViewer->Invalidate(false); + if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight + 12 ) + { + } + else + { + __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12); + AppLog("xyz:: MainForm::RelayoutControls called __webControlHeight %d",__webControlHeight); + __pWebViewer->Invalidate(false); + } } if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null) { @@ -3419,12 +4211,50 @@ MainForm::ShowFindWordPanel(bool show , bool isTouchPressed) { 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(); -// __pFindWordEditField->SetText(__currentSearchStr); - //__pFindWordCountLabel->SetText(L""); -// __pFindWordCountLabel->SetText(L"0/0"); + + 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 @@ -3438,16 +4268,35 @@ MainForm::ShowFindWordPanel(bool show , bool isTouchPressed) AppLog("MainForm::ShowFindWordPanel %d",show); if (show && !isTouchPressed) { - if (__pFindWordEditField) + if (languageCode.CompareTo("ara") == 0) { - __pFindWordEditField->SetFocus(); - __pFindWordEditField->ShowKeypad(); + if (__pFindWordEditFieldRightToLeft) + { + __pFindWordEditFieldRightToLeft->SetFocus(); + __pFindWordEditFieldRightToLeft->ShowKeypad(); + } + } + else + { + if (__pFindWordEditField) + { + __pFindWordEditField->SetFocus(); + __pFindWordEditField->ShowKeypad(); + } } } else { - if (__pFindWordEditField) - __pFindWordEditField->HideKeypad(); + if (languageCode.CompareTo("ara") == 0) + { + if (__pFindWordEditFieldRightToLeft) + __pFindWordEditFieldRightToLeft->HideKeypad(); + } + else + { + if (__pFindWordEditField) + __pFindWordEditField->HideKeypad(); + } } RelayoutControls(false); @@ -3462,7 +4311,8 @@ MainForm::StartWordSearch() __pFindWordPrev->SetEnabled(false); String *pCountStr = null; - __pWebViewer->SearchTextAllAsync(__currentSearchStr, false); + 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) { @@ -3482,7 +4332,7 @@ void MainForm::OnTextFound(int totalCount, int currentOrdinal) if(totalCount == -1 || totalCount == 0) { - __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),64,__pFindWordCountLabel->GetHeight()); + __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight()); __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight()); // return; } @@ -3506,10 +4356,19 @@ void MainForm::OnTextFound(int totalCount, int currentOrdinal) AppLog("Word not found"); //Show error notification to user __pFindWordNext->SetEnabled(false); - __pFindWordCountLabel->SetText(L"0/0"); + 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); + } __pFindWordNext->Invalidate(false); __pFindWordPrev->Invalidate(false); - __pFindWordCountLabel->Invalidate(false); + return; } @@ -3526,15 +4385,23 @@ void MainForm::OnTextFound(int totalCount, int currentOrdinal) countStr.Append(__currentWordIndex); countStr.Append(L"/"); countStr.Append(__maxOccurrances); + if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true) + { __pFindWordCountLabel->SetText(countStr); - // __pFindWordCountLabel->SetShowState(true); __pFindWordCountLabel->Invalidate(false); - + __pFindWordCountLabel->Invalidate(false); + } + else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true) + { + __pFindWordCountLabelRightToLeft->SetText(countStr); + __pFindWordCountLabelRightToLeft->Invalidate(false); + __pFindWordCountLabelRightToLeft->Invalidate(false); + } //FindNextWord(true); //Update the controls __pFindWordNext->Invalidate(false); __pFindWordPrev->Invalidate(false); - __pFindWordCountLabel->Invalidate(false); + } void @@ -3542,17 +4409,19 @@ MainForm::FindNextWord(bool next) { if (next == true) { - if (__pWebViewer->SearchText(__currentSearchStr, true) == true) - { - if(__currentWordIndex < __maxOccurrances) + //if (__pWebViewer->SearchText(__currentSearchStr, true) == true) + if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS) { - __currentWordIndex++; + if (__currentWordIndex < __maxOccurrances) + { + __currentWordIndex++; + } } - } } else { - if (__pWebViewer->SearchText(__currentSearchStr, false) == true) + //if (__pWebViewer->SearchText(__currentSearchStr, false) == true) + if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS) { if(__currentWordIndex > 1) { @@ -3565,9 +4434,18 @@ MainForm::FindNextWord(bool next) countStr.Append(__currentWordIndex); countStr.Append(L"/"); countStr.Append(__maxOccurrances); + + if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true) + { __pFindWordCountLabel->SetText(countStr); - // __pFindWordCountLabel->SetShowState(true); __pFindWordCountLabel->Invalidate(false); + } + else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true) + { + __pFindWordCountLabelRightToLeft->SetText(countStr); + __pFindWordCountLabelRightToLeft->Invalidate(false); + } + if (__currentWordIndex >= __maxOccurrances) { __pFindWordNext->SetEnabled(false); @@ -3586,24 +4464,43 @@ MainForm::FindNextWord(bool next) } __pFindWordPrev->Invalidate(false); __pFindWordNext->Invalidate(false); - __pFindWordCountLabel->Invalidate(false); + __pFindWordControl->Invalidate(true); } + void MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source) { - AppLog("MainForm::OnWebKeypadWillOpen"); - __isWebKeypadOpened = true; + 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::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height); + AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height); if(__pAddressbar != null) { __pAddressbar->SetShowState(false); @@ -3615,15 +4512,33 @@ MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source) __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("xyz::MainForm::OnWebKeypadClosed"); + AppLog("akjshdasd 4"); __pFooterPanel->SetShowState(true); - OnAddressBarKeypadClosed(*__pAddressbar); - __isWebKeypadOpened = false; +// OnAddressBarKeypadClosed(*__pAddressbar); + RelayoutControls(false); + __isKeypadOpened = false; +} + +void +MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source) +{ + // RelativeLayout(false); + if(__pWebViewer != null) + { + __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height)); + } } void @@ -3644,62 +4559,18 @@ MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPositi AppLog("MainScene::OnTouchDoublePressed"); - 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); - __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript); - if (!__pReaderData) - { - AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult())); - 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; - } + } void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) { - AppLog("MainForm::OnTouchLongPressed"); + AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y); + if(TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1) + { + AppLog("Returning because of more than one touch point."); + return; + } + __longPressPoint = currentPosition; if (__pHitElementResult != null) { @@ -3720,7 +4591,8 @@ void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen: if (__pHitElementResult->HasImage() == true) { - InitImageContextMenu(currentPosition); + if(__pWebViewer != null) + InitImageContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY())); __pImageMenu->SetShowState(true); __pImageMenu->Show(); __pImageMenu->Invalidate(true); @@ -3738,7 +4610,7 @@ void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen: { AppLog(null); } - InitImageLinkContextMenu(currentPosition); + InitImageLinkContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY())); __pImageMenu->SetShowState(true); __pImageMenu->Show(); __pImageMenu->Invalidate(true); @@ -3755,30 +4627,45 @@ void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen: AppLog("tag name is %ls", tagName.GetPointer()); AppLog("type is %ls", type.GetPointer()); - AppLog("innerHtml is %ls", innerHtml.GetPointer()); - if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0 && __isWebKeypadOpened == true) + + + __isLongPressedDone = true; + result r =__pWebViewer->SetBlockSelectionPosition(currentPosition); + if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && innerHtml.GetLength() == 0 && type.CompareTo(L"submit") !=0/*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.CompareTo(L"") == 0 && r == E_INVALID_ARG) { AppLog("MainForm::OnWebPageBlockSelected show paste option"); - InitSelectTextContextMenu(currentPosition,true, true); - __pImageMenu->SetShowState(true); - __pImageMenu->Show(); - __pImageMenu->Invalidate(true); + InitSelectTextContextMenu(Point(currentPosition.x , currentPosition.y + __pWebViewer->GetY()),true, true); + if(__pImageMenu) + { + __pImageMenu->SetShowState(true); + __pImageMenu->Show(); + __pImageMenu->Invalidate(true); + } } - __isLongPressedDone = true; - __pWebViewer->SetBlockSelectionPosition(currentPosition); + AppLog("setselectionselectedornot %s",GetErrorMessage(r)); } - __inputEventToBeSupressed = true; +// __inputEventToBeSupressed = true; } void MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) { - AppLog("MainForm::OnTouchReleased"); + AppLog("xyz:: MainForm::OnTouchReleased called"); + + if (__pAddressbar && __pAddressbar->GetShowState() == true) + { + __pAddressbar->SetShowState(false); + } + if(__pFooterPanel && __isKeypadOpened == false) + { + __pFooterPanel->SetShowState(true); + } - HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition); + // Not reuired now. + /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition); if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true) { __pWebViewer->ConsumeInputEvent(); @@ -3787,7 +4674,7 @@ MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphic { delete pHitElement; } - __inputEventToBeSupressed = false; + __inputEventToBeSupressed = false;*/ } bool @@ -3800,15 +4687,41 @@ MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEvent 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->SearchText(L"aaaabbbbcccc",true); + __pFindWordControl->SetShowState(false); + } + AppLog("__pAddressbar->GetShowState() %d",__pAddressbar->GetShowState()); if(__pAddressbar->GetShowState() == false) { - __pAddressbar->SetShowState(true); __pAddressbar->SetAddressbarURLFocus(); - __pFooterUrlField->SetFocusable(false); __pFooterPanel->SetShowState(false); } - return true; + return false; } bool @@ -3846,8 +4759,36 @@ MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::Ori { AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height); int widthContextItem = 0; - if(__pFindWordControl != null) - ShowFindWordPanel(__pFindWordControl->GetShowState(), false); + 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) + { + 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()); @@ -3856,8 +4797,9 @@ MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::Ori __pFooterLabel->SetBackgroundBitmap(*pBitmap); delete pBitmap; } - } + + } if (__pFindWordBgLabel != null) { Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight()); @@ -3868,8 +4810,20 @@ MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::Ori } } - if(__pMenu != null) - __pMenu->SetShowState(false); + 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; @@ -3888,13 +4842,6 @@ MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::Ori } InitAddressbar(); - if(__pMoreButton && __pMenu) - { - Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight()); - __pMenu->SetAnchorPosition(p); - __pMenu->Invalidate(true); - } - String homePage = SettingPresentationModel::GetInstance()->GetHomepage(); if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0) { @@ -3965,11 +4912,11 @@ MainForm::OnSettingsChange(int settingvalue) if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW) { WebSetting settings = __pWebViewer->GetSetting(); - if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0) + if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0) { settings.SetAutoFittingEnabled(true); } - else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0) + else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0) { settings.SetAutoFittingEnabled(false); } @@ -3986,6 +4933,7 @@ MainForm::OnSettingsChange(int settingvalue) WebSetting settings = __pWebViewer->GetSetting(); settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled()); __pWebViewer->SetSetting(settings); + __pWebViewer->Reload(); } else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP) { @@ -4000,7 +4948,24 @@ MainForm::OnSettingsChange(int settingvalue) __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(); @@ -4139,13 +5104,16 @@ MainForm::findDistance(int x1,int y1,int x2, int y2) 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); +// ShowFindWordPanel(__pFindWordControl->GetShowState(), true); } __isLongPressedDone = false; + + Touch touch; IList* pList = null; pList = touch.GetTouchInfoListN(source); @@ -4191,18 +5159,26 @@ MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics } } 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) { - __currentWordIndex = 0; +// __currentWordIndex = 0; __isLongPressedDone = false; } @@ -4226,9 +5202,20 @@ MainForm::OnTextValueChanged (const Tizen::Ui::Control &source) __pFooterUrlField->SetKeypadActionEnabled(true); } } - if (__pFindWordEditField != null) + 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); @@ -4236,6 +5223,25 @@ MainForm::OnTextValueChanged (const Tizen::Ui::Control &source) __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) { @@ -4274,7 +5280,7 @@ MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatu if (__pMostVisitedListView != null) { - RemoveControl(*__pMostVisitedListView); + RemoveControl(__pMostVisitedListView); } if(__pMostVisitedSites != null) { @@ -4307,8 +5313,8 @@ MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatu } __pMostVisitedListView->SetItemProvider(*this); __pMostVisitedListView->AddListViewItemEventListener(*this); - __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES")); - AddControl(*__pMostVisitedListView); + __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_VISITED_SITES")); + AddControl(__pMostVisitedListView); __pMostVisitedListView->UpdateList(); return E_SUCCESS; @@ -4368,17 +5374,51 @@ void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName) 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); + request.SetOngoingActivityType(ONGOING_ACTIVITY_TYPE_TEXT); + request.SetNotificationStyle(NOTIFICATION_STYLE_THUMBNAIL); + 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); - __pGoBackBtn->Invalidate(true); + __pGoForwardBtn->Invalidate(true); } void @@ -4495,6 +5535,48 @@ MainForm::UpdateProgressBitmap(void) 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); @@ -4511,7 +5593,9 @@ void MainForm::SetAddressbarMode(AddressBarMode addMode) case ADDRESSBAR_MODE_READER: { __pStopBtn->SetShowState(false); + __pRefreshBtn->SetShowState(false); __pClearBtn->SetShowState(false); + __pReaderBtn->SetShowState(false); } break; case ADDRESSBAR_MODE_LOADING: @@ -4519,6 +5603,7 @@ void MainForm::SetAddressbarMode(AddressBarMode addMode) __pRefreshBtn->SetShowState(false); __pStopBtn->SetShowState(true); __pClearBtn->SetShowState(false); + __pReaderBtn->SetShowState(false); } break; case ADDRESSBAR_MODE_LOADING_COMPLETE: @@ -4528,12 +5613,14 @@ void MainForm::SetAddressbarMode(AddressBarMode addMode) __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; @@ -4552,6 +5639,8 @@ AddressBarMode MainForm::GetAddressbarMode(void) void MainForm::SetUrl(const String& url) { __displayUrl = url; + if(__displayUrl.GetLength() > 2048) + __displayUrl.SubString(0,2048,__displayUrl); if (__pFooterUrlField != NULL) { @@ -4559,17 +5648,20 @@ void MainForm::SetUrl(const String& url) if (removedHttpUrl.IsEmpty() == false) { __pFooterUrlField->SetText(removedHttpUrl); - __pAddressbar->SetUrl(__displayUrl); + if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false) + __pAddressbar->SetUrl(__displayUrl); } else { __pFooterUrlField->SetText(__displayUrl); - __pAddressbar->SetUrl(__displayUrl); + if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false) + __pAddressbar->SetUrl(__displayUrl); } if(__pFooterUrlField) __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength()); __pFooterUrlField->Invalidate(false); - __pAddressbar->Invalidate(true); + if(__pAddressbar != NULL && __pAddressbar->HasFocus()) + __pAddressbar->Invalidate(true); // __pFooterUrlField->SetCursorPosition(0); } } @@ -4577,13 +5669,175 @@ void MainForm::SetUrl(const String& url) String MainForm::RemoveHttpTextFromDisplayURL(void) { - bool isHttpText = __displayUrl.Contains(L"http://"); + AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer()); + int index = -1; +// bool isHttpText = __displayUrl.Contains(L"http://"); String updatedDisplayUrl; updatedDisplayUrl.Clear(); - - if (isHttpText == true) + 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 == 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) + { + 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)); + __pOptionMenu->Invalidate(true); + __pOptionMenu->Show(); + +}