X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FIntMainForm.cpp;h=c8b8d66d0577d03799f062751abba38ce044ca44;hb=f4e169173559668928f50ef5afeafbed0143a77e;hp=9c3e0435bbf4cf4ca9b71e4ac9d210ee8ad50434;hpb=6707a4fc53c517add5b022ff106f35857263ebf7;p=apps%2Fosp%2FInternet.git diff --git a/src/IntMainForm.cpp b/src/IntMainForm.cpp index 9c3e043..c8b8d66 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; @@ -52,6 +55,8 @@ using namespace Tizen::System; using namespace Tizen::Web; using namespace Tizen::Web::Controls; +static const wchar_t* IDB_SEARCH_INPUT_FIELD_BG = L"I01_toolbar_input_field.#.png"; +static const wchar_t* IDB_FINDWORD_INPUT_FIELD_BG = L"I01_toolbar_input_field_findword.#.png"; static const wchar_t* IDB_BTN_BACK = L"I01_icon_Back.png"; static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png"; static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png"; @@ -63,10 +68,15 @@ static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_pres static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png"; static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png"; static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png"; -static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png"; -static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png"; +static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP =L"00_icon_favorite_off_74x74.png"; +static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"00_icon_favorite_on_74x74.png"; static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service"; static const wchar_t* IDS_APPID = L"AppID"; +static const wchar_t* IDS_KEY = L"key"; +static const wchar_t* IDS_VALUE = L"value"; +static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png"; +static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png"; +//static const wchar_t* IDB_ADDRESS_BAR_BACKGROUND = L"I01_toolbar_bg_02.9.png"; const int IDA_BACKBTN_CLICKED = 101; const int IDA_BOOKMARKBTN_CLICKED = 102; @@ -83,6 +93,14 @@ const int IDA_READER_CLOSE_CLICKED = 112; const int IDA_SMALLFONT_BTN_CLICKED = 113; const int IDA_LARGEFONT_BTN_CLICKED = 114; const int IDA_BRIGHTNESS_BTN_CLICKED = 115; +const int IDA_HISTORY_CLICKED = 116; +const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117; +const int IDA_ADD_TO_HOME_CLICKED = 118; +const int IDA_SAVED_PAGES_CLICKED = 119; +const int IDA_DESKTOP_VIEW_CLICKED = 120; +const int IDA_SAVE_CLICKED = 121; +const int IDA_PRINT_CLICKED = 122; + const int IDA_FINDWORD_SEARCH_CLICKED = 201; const int IDA_FINDWORD_NEXT_CLICKED = 202; const int IDA_FINDWORD_PREV_CLICKED = 203; @@ -98,6 +116,22 @@ const int IDA_COPY_TEXT_CLICKED = 210; const int IDA_PASTE_TEXT_CLICKED = 211; const int IDA_FIND_TEXT__CLICKED = 212; const int IDA_SHARE_TEXT_CLICKED = 213; + +const int IDA_GO_BACK = 214; +const int IDA_GO_FORWARD = 215; +const int IDA_REFRESH_BTN_CLICKED = 216; +const int IDA_STOP_BTN_CLICKED = 217; +const int IDA_CLEAR_URL = 218; +const int IDA_READER_BTN_CLICKED = 219; + + +const int IDA_HYPERLINK_OPEN_CLICKED = 220; +const int IDA_HYPERLINK_COPY_LINK_CLICKED = 221; +const int IDA_HYPERLINK_SAVE_IMAGE_CLICKED = 222; +const int IDA_HYPERLINK_SHARE_IMAGE_CLICKED = 223; + +const int IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED = 224; + const int DEFAULT_PROGRESS_PERCENTAGE = 10; const int MainForm::IDA_FORMAT_BITMAP = 500; @@ -110,8 +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; @@ -120,41 +157,66 @@ MainForm::MainForm(void) __pWindowInfo = null; __pWebViewer = null; __pImageMenu = null; - __pMenu = null; + __pOptionMenu = null; __pFindWordControl = null; - __pFindWordPanel = null; + __pFindWordPanelLeftToRight = null; + __pFindWordPanelRightToLeft = null; __pFindWordBgLabel = null; + __pFindWordBgLabelRightToLeft = null; __pFindWordEditField = null; + __pFindWordEditFieldRightToLeft = null; __pFindWordClear = null; + __pFindWordClearRightToLeft = null; __pFindWordCountLabel = null; + __pFindWordClearRightToLeft = null; __pFindWordNext = null; __pFindWordPrev = null; __previousZoomLevel = 1.0; __pSaveImage = null; + __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE; + __displayUrl = L""; + __editTextUrl = L""; __currentSearchStr = L""; __currentSelectedStr = L""; __maxOccurrances = 0; __currentWordIndex = 0; __distanceMoved = 0; __isLoaded = false; - __inputEventToBeSupressed = false; + //__inputEventToBeSupressed = false; + __isLoadingData = false; + __isLoadingCompleted = false; + __progressPercentage = 0; __touchPoint1 = Point(-1,-1); __touchPoint2 = Point(-1,-1); + __longPressPoint = Point(-1,-1); __pWebReader = null; // __pReaderPopup = null; __pReaderData = null; __pPopUp = null; __pReaderCloseBtn = null; - __pNewWindowButton = null; + //__pNewWindowButton = null; __pMoreButton = null; __pMultiWindowButton = null; __pArticleReaderPanel = null; __pBlankPanel = null; __pArticleReaderLabel = null; __webControlHeight = 0; + __webControlHeightF = 0; __prevAddressBarMode = ADDRESSBAR_MODE_INVALID; __curAddressBarMode = ADDRESSBAR_MODE_INVALID; __pMostVisitedSites = null; + __pFooterUrlField = null; + __pGoBackBtn = null; + __pGoForwardBtn = null; + __pRefreshBtn = null; + __pProgressbarLabel = null; + __pFooterLabel = null; + __pStopBtn = null; + __pClearBtn = null; + __pReaderBtn = null; + __isKeypadOpened = false; + __fontSize = 44; + __pNotification = null; } MainForm::~MainForm(void) @@ -165,6 +227,13 @@ MainForm::~MainForm(void) { __pAddressbar->SetAddressbarEventListener(null); } + + if(__pHistory != null) + { + delete __pHistory; + __pHistory = null; + } + if (__pReaderData != null) { delete __pReaderData; @@ -182,6 +251,12 @@ MainForm::~MainForm(void) delete __pHitElementResult; __pHitElementResult = null; } + if(__pOptionMenu) + { + delete __pOptionMenu; + __pOptionMenu = null; + } + String* pSelectedScene = NULL; Object* pValue = NULL; MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue); @@ -198,15 +273,20 @@ bool MainForm::Initialize(void) { Construct(L"IDL_FORM"); + +// SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_FOOTER); return true; } result MainForm::OnInitializing(void) { + AppLog("get client area width = %d",GetClientAreaBounds().width); + AppLog("get client area height = %d",GetClientAreaBounds().height); const int WIDTH_CONTEXT_MENU_BUTTON = 336; const int HEIGHT_CONTEXT_MENU_BUTTON = 72; + __fontSize = CommonUtil::GetFontSize(); Panel* pFooterPanel = null; __pSaveImage = new Image(); @@ -216,6 +296,7 @@ MainForm::OnInitializing(void) SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this); SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this); AddOrientationEventListener(*this); + AppLogDebug(" MainForm::OnInitializing ended"); if (__pMostVisitedSites == null) { @@ -226,24 +307,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(); + __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; } @@ -267,7 +347,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(); @@ -314,15 +394,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()); @@ -376,8 +456,11 @@ MainForm::InitWebControl() if (__pAddressbar == null || __pFooterPanel == null) return E_FAILURE; - const int Y_WEBCONTROL_POSITION = __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12; - __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - Y_WEBCONTROL_POSITION; + const int Y_WEBCONTROL_POSITION = 0; + + __webControlHeight = GetHeight() - __pFooterPanel->GetHeight(); + __webControlHeightF = GetHeightF() - __pFooterPanel->GetHeightF(); + if (__pMostVisitedListView) { __pMostVisitedListView->SetShowState(false); @@ -393,23 +476,28 @@ MainForm::InitWebControl() AppLogDebug("Initialization failed"); return E_FAILURE; } - r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight)); + AppLog("GetClientAreaBounds().width %d",GetClientAreaBounds().width); + r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12)); if (IsFailed(r)) { AppLogDebug("Web construct failed with %s", GetErrorMessage(r)); + delete __pWebViewer; + __pWebViewer = null; return r; } else { - r = AddControl(*__pWebViewer); - + r = AddControl(__pWebViewer); if (IsFailed(r)) { + __pWebViewer->Destroy(); + __pWebViewer = null; AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r)); return r; } __webControlPosition = __pWebViewer->GetPosition(); + __webControlPositionF = __pWebViewer->GetPositionF(); r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings()); if (IsFailed(r)) { @@ -418,7 +506,7 @@ MainForm::InitWebControl() } __pWebViewer->SetLoadingListener(this); - __pWebViewer->SetWebUiEventListener(this); + __pWebViewer->SetWebUiEventListenerF(this); __pWebViewer->SetWebKeypadEventListener(this); __pWebViewer->SetFocus(); __pWebViewer->AddTouchEventListener(*this); @@ -427,7 +515,6 @@ MainForm::InitWebControl() __pWebViewer->SetTextSearchListener(this); } - __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight)); AppLogDebug("MainForm :before return"); Invalidate(true); AppLogDebug("MainForm::InitWebControl Exit"); @@ -474,41 +561,30 @@ MainForm::InitFooter(void) SetControlAlwaysOnTop(*__pFooterPanel, true); - __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true)); - - if ( __pMultiWindowButton == NULL ) - { - return E_FAILURE; - } - - pBackButton = static_cast< Button* >(GetControl(L"IDC_PAGEBACK_BUTTON", true)); - - if ( pBackButton == NULL ) + __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true)); + if ( __pFooterLabel == NULL ) { return E_FAILURE; } - - pBookmarkButton = static_cast< Button* >(GetControl(L"IDC_BOOKMARK_BUTTON", true)); - - if ( pBookmarkButton == NULL ) +// __pFooterPanel->SetBackgroundColor(Color(255,0,0)); + //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT); + Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight()); + if (pBitmap != null) { - return E_FAILURE; + __pFooterLabel->SetBackgroundBitmap(*pBitmap); + delete pBitmap; } - __pMoreButton = static_cast(GetControl(L"IDC_MORE_BUTTON",true)); + __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true)); - if ( __pMoreButton == NULL ) + if ( __pMultiWindowButton == NULL ) { return E_FAILURE; } - __pNewWindowButton = static_cast< Button* >(GetControl(L"IDC_NEW_WINDOW",true)); - - if ( __pNewWindowButton == NULL ) - { - return E_FAILURE; - } + SetFormBackEventListener(this); + AppLog("SetFormBackEventListener result %s",GetErrorMessage(GetLastResult())); if (__pMultiWindowButton != null) { Bitmap* pBitmap = null; @@ -540,40 +616,11 @@ MainForm::InitFooter(void) __pMultiWindowButton->AddActionEventListener(*this); __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED); - } - - - if (pBackButton) - { - Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BTN_BACK); - Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BTN_BACK_PRESS); - if (pBitmap != null) - { - // pBitmap->Scale(Dimension(56,56)); - - Point startPoint((pBackButton->GetWidth() - pBitmap->GetWidth())/2,(pBackButton->GetHeight() - pBitmap->GetHeight())/2 ); - AppLog("startPoint %d,%d pBitmap width height %d %d",startPoint.x,startPoint.y,pBitmap->GetWidth(),pBitmap->GetHeight()); - pBackButton->SetNormalBitmap(startPoint, *pBitmap); - pBackButton->SetPressedBitmap(startPoint, *pPressedBitmap); - delete pBitmap; - } - pBackButton->AddActionEventListener(*this); - pBackButton->SetActionId(IDA_BACKBTN_CLICKED); - } - - if (pBookmarkButton) - { - Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_BOOKMARK); - Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_BOOKMARK_PRESS); - if (pBitmap != null) + if(pPressedBitmap) { - Point startPoint((pBookmarkButton->GetWidth() - pBitmap->GetWidth())/2,(pBookmarkButton->GetHeight() - pBitmap->GetHeight())/2 ); - pBookmarkButton->SetNormalBitmap(startPoint, *pBitmap); - pBookmarkButton->SetPressedBitmap(startPoint, *pPressedBitmap); - delete pBitmap; + delete pPressedBitmap; + pPressedBitmap = null; } - pBookmarkButton->AddActionEventListener(*this); - pBookmarkButton->SetActionId(IDA_BOOKMARKBTN_CLICKED); } if (__pMoreButton) @@ -590,65 +637,151 @@ MainForm::InitFooter(void) } __pMoreButton->AddActionEventListener(*this); __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED); + } + //Add the editfield for url + __pFooterUrlField = static_cast (GetControl(L"IDC_URL_EDIT_FIELD",true)); + if (__pFooterUrlField == NULL) + { + return E_INVALID_KEY; } + __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false); + __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO); + __pFooterUrlField->AddKeypadEventListener(*this); + __pFooterUrlField->SetPropagatedTouchEventListener(this); + __pFooterUrlField->AddFocusEventListener(*this); - if (__pNewWindowButton) + if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0) { - Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_NEW_WINDOW); - Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS); - if (pBitmap != null) - { - Point startPoint((__pNewWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pNewWindowButton->GetHeight() - pBitmap->GetHeight())/2 ); - __pNewWindowButton->SetNormalBitmap(startPoint, *pBitmap); - __pNewWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap); - delete pBitmap; - } - __pNewWindowButton->AddActionEventListener(*this); - __pNewWindowButton->SetActionId(IDA_NEWWINDOWBTN_CLICKED); - __pNewWindowButton->SetEnabled(true); - // __pNewWindowButton->Invalidate(true); + __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL")); + } + else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0) + { + __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_BLANK_PAGE")); + } + else + { + //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL()); + __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL")); } - AppLog("checkingwindow count %d",MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount()); - if (__pNewWindowButton != null && MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount() >= 9) + //Add the go Back Button + __pGoBackBtn = static_cast (GetControl(L"IDC_PAGEBACK_BUTTON",true)); + if (__pGoBackBtn == NULL) { - Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTROLBAR_ICON_CREATE_DISABLE); - if (pBitmap != null) - { - Point startPoint = Point((__pNewWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pNewWindowButton->GetHeight() - pBitmap->GetHeight())/2 ); - __pNewWindowButton->SetDisabledBitmap(startPoint,*pBitmap); - delete pBitmap; - } - __pNewWindowButton->SetEnabled(false); + AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY"); + return E_INVALID_KEY; + } + __pGoBackBtn->SetActionId(IDA_GO_BACK); + __pGoBackBtn->AddActionEventListener(*this); + + //Add the go forward Button + __pGoForwardBtn = static_cast (GetControl(L"IDC_PAGEFORWARD_BUTTON",true)); + if (__pGoForwardBtn == NULL) + { + AppLogDebug("Control not found returning E_INVALID_KEY"); + return E_INVALID_KEY; + } + __pGoForwardBtn->SetActionId(IDA_GO_FORWARD); + __pGoForwardBtn->AddActionEventListener(*this); + if (__pWebViewer && __pWebViewer->CanGoForward()) + { + SetForwardButtonEnabled(true); + } + else + { + SetForwardButtonEnabled(false); + } + + __pRefreshBtn = static_cast (GetControl(L"IDC_REFRESH_BUTTON",true)); + if (__pRefreshBtn == NULL) + { + AppLogDebug("Control not found returning E_INVALID_KEY"); + return E_INVALID_KEY; + } + + __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED); + __pRefreshBtn->AddActionEventListener(*this); + __pRefreshBtn->SetShowState(true); + + //Add the backround label for displaying progressbar + __pProgressbarLabel = static_cast (GetControl(L"IDC_PROGRESS_BAR_LABEL",true)); + if (__pProgressbarLabel == NULL) + { + AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY"); + return E_INVALID_KEY; + } + __pProgressbarLabel->SetShowState(false); + + __pStopBtn = static_cast (GetControl(L"IDC_STOP_BUTTON",true)); + if (__pStopBtn == NULL) + { + AppLogDebug("Control not found returning E_INVALID_KEY"); + return E_INVALID_KEY; + } + __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED); + __pStopBtn->AddActionEventListener(*this); + __pStopBtn->SetShowState(false); + + __pClearBtn = static_cast (GetControl(L"IDC_CLEAR_BUTTON",true)); + if (__pClearBtn == NULL) + { + AppLogDebug("Control not found returning E_INVALID_KEY"); + return E_INVALID_KEY; + } + __pClearBtn->SetActionId(IDA_CLEAR_URL); + __pClearBtn->AddActionEventListener(*this); + __pClearBtn->SetShowState(false); + + __pReaderBtn = static_cast (GetControl(L"IDC_READER_BUTTON",true)); + if (__pReaderBtn == NULL) + { + AppLogDebug("Control not found returning E_INVALID_KEY"); + return E_INVALID_KEY; } + __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED); + __pReaderBtn->AddActionEventListener(*this); + __pReaderBtn->SetShowState(false); // __pFooterPanel->Invalidate(true); + if(__isKeypadOpened == false && __pAddressbar && __pAddressbar->GetShowState() == false) + { +// AppLog("asdasdasdasda"); + __pFooterPanel->SetShowState(true); + } + else if(__pAddressbar == null) + { + __pFooterPanel->SetShowState(true); + } + else + __pFooterPanel->SetShowState(false); + + SetAddressbarMode(GetAddressbarMode()); AppLogDebug("MainForm::InitFooter exit"); return E_SUCCESS; } - result -MainForm::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(); @@ -661,17 +794,22 @@ MainForm::InitContextMenu(Point& p) pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF); } + 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_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED); - r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED); - __pMenu->SetMaxVisibleItemsCount(3); - __pMenu->SetShowState(false); - __pMenu->AddActionEventListener(*this); - SetControlAlwaysOnTop(*__pMenu, true); + r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED); + r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED); + r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED); + + + __pOptionMenu->SetMaxVisibleItemsCount(6); + __pOptionMenu->SetShowState(false); + __pOptionMenu->AddActionEventListener(*this); + SetControlAlwaysOnTop(*__pOptionMenu, true); CATCH: return r; @@ -688,16 +826,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)); @@ -705,17 +838,58 @@ 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; +} + +result +MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p) +{ + result r = E_SUCCESS; + ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO; + + AppLog("MainForm::InitImageContextMenu clicked on image"); + if (__pImageMenu != null) + { + delete __pImageMenu; + __pImageMenu = null; + } + +// if(__pAddressbar->GetShowState() == true) +// p.y = p.y + __pAddressbar->GetHeight(); + if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE) + { + p.y = p.y + 54; + } + + __pImageMenu = new (std::nothrow) ContextMenu(); + r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction); + TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r)); + + r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_OPEN_IN_NEW_WINDOW"),IDA_HYPERLINK_OPEN_CLICKED); + r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_LINK_URL"),IDA_HYPERLINK_COPY_LINK_CLICKED); + //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED); + r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED); + + __pImageMenu->SetMaxVisibleItemsCount(3); + __pImageMenu->AddActionEventListener(*this); + SetControlAlwaysOnTop(*__pImageMenu, true); + __pImageMenu->SetFocusable(true); CATCH: return r; + } -result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false) +result +MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOption = false) { result r = E_SUCCESS; + bool clipboardAvailable = true; ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO; AppLog("MainForm::InitSelectTextContextMenu clicked on text"); @@ -724,15 +898,51 @@ result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteO delete __pImageMenu; __pImageMenu = null; } - p.y = p.y + __pAddressbar->GetHeight() + 12; - if(p.y < 100) +// Point q(0,0); +// __pWebViewer->GetBlockRange(p,q); + + if(p.y < 150) { + p.y = p.y + 50; direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD; } else { direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD; } + + + Clipboard* pClipboard = Clipboard::GetInstance(); + + if(pClipboard == null) + { + clipboardAvailable = false; + } + else + { + // Retrieves a latest item + ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML); + + if(pItem == null) + { + clipboardAvailable = false; + } + else + { + //Gets data from the clipboard item + String* pString = dynamic_cast(pItem->GetData()); + + if(pString == null) + { + clipboardAvailable = false; + } + } + } + if(clipboardAvailable == false && onlyPasteOption == true) + { + return E_FAILURE; + } + __pImageMenu = new (std::nothrow) ContextMenu(); r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction); TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r)); @@ -741,7 +951,7 @@ result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteO { r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED); } - if (pasteOption || onlyPasteOption) + if ((pasteOption || onlyPasteOption) && clipboardAvailable == true) { r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED); } @@ -754,107 +964,246 @@ result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteO __pImageMenu->SetMaxVisibleItemsCount(3); __pImageMenu->AddActionEventListener(*this); SetControlAlwaysOnTop(*__pImageMenu, true); + __pImageMenu->SetFocusable(true); CATCH: return r; } result -MainForm::InitFindWordPanel(void) +MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPasteOption = false) { result r = E_SUCCESS; - Bitmap *pIconBitmap = null; + bool clipboardAvailable = true; + ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO; - if (__pFindWordPanel != null) + AppLog("MainForm::InitSelectTextContextMenu clicked on text"); + if (__pImageMenu != null) { - AppLogDebug("Findword panel already initialized"); - if (__pFindWordBgLabel != null) + delete __pImageMenu; + __pImageMenu = null; + } +// FloatPoint q(0.0,0.0); +// __pWebViewer->GetBlockRange(p,q); + if(p.y < 150) + { + p.y = p.y + 50; + direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD; + } + else if(__pWebViewer != null && (p.y > (__pWebViewer->GetHeight() + __pWebViewer->GetY()))) + { + p.y = __pWebViewer->GetHeight() + __pWebViewer->GetY(); + } + else + { + if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE ) { - Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight()); - if (pBitmap != null) - { - AppLogDebug("InitFindWordPanel: Coming here"); - __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap); - delete pBitmap; - } + AppLog("asdasdafdsfdgfd"); + p.y = p.y - 50; } - return r; + direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD; } - __pFindWordPanel = static_cast(GetControl(L"IDC_FIND_ON_PAGE_PANEL")); - if (__pFindWordPanel == null) - { - AppLogException("There is some problem in the xml file. Please check."); - return E_FAILURE; - } - __pFindWordControl = new (std::nothrow) Panel(); - r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE"); - if (IsFailed(r)) + Clipboard* pClipboard = Clipboard::GetInstance(); + + if(pClipboard == null) { - AppLogException("There is some problem in the xml file. Please check."); - return E_FAILURE; + clipboardAvailable = false; } - __pFindWordPanel->AddControl(*__pFindWordControl); - __pFindWordControl->SetBounds(0,0, __pFindWordPanel->GetWidth(), __pFindWordPanel->GetHeight()); - SetControlAlwaysOnTop(*__pFindWordPanel,true); - __pFindWordPanel->SetShowState(false); - __pFindWordPanel->Invalidate(false); - - __pFindWordBgLabel = static_cast(__pFindWordControl->GetControl(L"IDC_LABEL1", true)); - if (__pFindWordBgLabel != null) + else { - Panel* pPanel1 = static_cast(__pFindWordControl->GetControl(L"IDC_PANEL1", true)); - Rectangle pRect = pPanel1->GetBounds(); - pRect.x = pRect.y = 0; - __pFindWordBgLabel->SetBounds(pRect); - Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight()); - if (pBitmap != null) + // Retrieves a latest item + ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML); + + if(pItem == null) { - AppLogDebug("InitFindWordPanel: Coming here"); - __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap); - delete pBitmap; + clipboardAvailable = false; } else { - AppLogDebug("InitFindWordPanel: shouldn't Come here"); + //Gets data from the clipboard item + String* pString = dynamic_cast(pItem->GetData()); + + if(pString == null) + { + clipboardAvailable = false; + } } } - - Button* pfindWordCancel = null; - pfindWordCancel = static_cast(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true)); - if (pfindWordCancel == null) + if(clipboardAvailable == false && onlyPasteOption == true) { - AppLogException("There is some problem in the xml file. Please check."); return E_FAILURE; } - pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED); - pfindWordCancel->AddActionEventListener(*this); + __pImageMenu = new (std::nothrow) ContextMenu(); + r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction); + TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r)); - __pFindWordClear = static_cast(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true)); - if (__pFindWordClear == null) - { - AppLogException("There is some problem in the xml file. Please check."); - return E_FAILURE; - } - __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED); - __pFindWordClear->AddActionEventListener(*this); - __pFindWordNext = static_cast(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true)); - if (__pFindWordNext == null) - { - AppLogException("There is some problem in the xml file. Please check."); - return E_FAILURE; - } - __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED); - __pFindWordNext->AddActionEventListener(*this); - __pFindWordPrev = static_cast(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true)); - if (__pFindWordPrev == null) + if(onlyPasteOption == false && __pHitElementResult->GetAttributeValue("type").Equals(L"password",false) == false) { - AppLogException("There is some problem in the xml file. Please check."); + r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED); + } + if ((pasteOption || onlyPasteOption) && clipboardAvailable == true) + { + r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED); + } + if(onlyPasteOption == false && __pHitElementResult->GetAttributeValue("type").Equals(L"password",false) == false) + { + r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED); + r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED); + } + + __pImageMenu->SetMaxVisibleItemsCount(3); + __pImageMenu->AddActionEventListener(*this); + SetControlAlwaysOnTop(*__pImageMenu, true); + __pImageMenu->SetFocusable(true); + + CATCH: return r; + +} + +result +MainForm::InitFindWordPanel(void) +{ + result r = E_SUCCESS; + Bitmap *pIconBitmap = null; + + if (__pFindWordControl != null) + { + AppLogDebug("Findword panel already initialized"); + if (__pFindWordBgLabel != null) + { + Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight()); + if (pBitmap != null) + { + __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap); + delete pBitmap; + } + } + if (__pFindWordBgLabelRightToLeft != null) + { + Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight()); + if (pBitmap != null) + { + __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap); + delete pBitmap; + } + } + if(__pAddressbar) + __pAddressbar->SetShowState(false); + + if(__isKeypadOpened == false) + __pFooterPanel->SetShowState(true); + return r; + } + + __pFindWordControl = new (std::nothrow) Panel(); + r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE"); + if (IsFailed(r)) + { + AppLogException("There is some problem in the xml file. Please check."); + return E_FAILURE; + } + AddControl(__pFindWordControl); + __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight()); + SetControlAlwaysOnTop(*__pFindWordControl,true); + __pFindWordControl->SetShowState(false); + __pFindWordControl->Invalidate(false); + + __pFindWordPanelLeftToRight = static_cast(__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) + { + Panel* pPanel1 = static_cast(__pFindWordControl->GetControl(L"IDC_PANEL1", true)); + Rectangle pRect = pPanel1->GetBounds(); + pRect.x = pRect.y = 0; + __pFindWordBgLabel->SetBounds(pRect); + Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight()); + if (pBitmap != null) + { + AppLogDebug("InitFindWordPanel: Coming here"); + __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap); + delete pBitmap; + } + else + { + AppLogDebug("InitFindWordPanel: shouldn't Come here"); + } + } + + __pFindWordBgLabelRightToLeft = static_cast(__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) + { + AppLogException("There is some problem in the xml file. Please check."); + return E_FAILURE; + } + pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED); + pfindWordCancel->AddActionEventListener(*this); + + __pFindWordClear = static_cast(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true)); + if (__pFindWordClear == null) + { + AppLogException("There is some problem in the xml file. Please check."); + return E_FAILURE; + } + + __pFindWordClearRightToLeft = static_cast(__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) + { + AppLogException("There is some problem in the xml file. Please check."); + return E_FAILURE; + } + + __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED); + __pFindWordNext->AddActionEventListener(*this); + + __pFindWordPrev = static_cast(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true)); + if (__pFindWordPrev == null) + { + AppLogException("There is some problem in the xml file. Please check."); return E_FAILURE; } @@ -871,6 +1220,13 @@ MainForm::InitFindWordPanel(void) return E_FAILURE; } + __pFindWordCountLabelRightToLeft = static_cast(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true)); + if (__pFindWordCountLabelRightToLeft == null) + { + AppLogException("There is some problem in the xml file. Please check."); + return E_FAILURE; + } + __pFindWordEditField = static_cast(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true)); if (__pFindWordEditField == null) { @@ -880,7 +1236,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; } @@ -916,7 +1289,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 +">"; } @@ -924,7 +1297,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)) { @@ -932,17 +1305,14 @@ MainForm::CreateItem (int index, int itemWidth) return NULL; } - if (pHistory->GetFaviconId().GetLength() > 0) - { - String bitmapId = pHistory->GetFaviconId(); - Bitmap* pBitmap = FaviconManager::GetInstance()->GetFaviconN(bitmapId); - if ( pBitmap != NULL) - { - pListIconImage = new Bitmap(); - pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight())); - delete pBitmap; - } + Bitmap* pBitmap = pHistory->GetFavIconBitmap(); + + if ( pBitmap != NULL) + { + pListIconImage = new Bitmap(); + pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight())); + delete pBitmap; } if(pListIconImage == null) @@ -952,8 +1322,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); @@ -967,7 +1337,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); } } @@ -975,16 +1345,29 @@ MainForm::CreateItem (int index, int itemWidth) { if (pItem != null) { - pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true); + pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_LISTVIEW_TEXT, CUSTOM_COLOR_LISTVIEW_TEXT, true); } } - if ( __pItemContext!= NULL) + if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE) { - if (pItem != null) + if ( __pItemContext!= NULL) + { + if (pItem != null) + { + pItem->SetContextItem(__pItemContext); + } + } + } + else + { + if ( __pItemContextLandscape!= NULL) { - pItem->SetContextItem(__pItemContext); + if (pItem != null) + { + pItem->SetContextItem(__pItemContextLandscape); + } } } if( pListIconImage != NULL) @@ -1022,15 +1405,24 @@ 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 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status) { + AppLog("MainForm::OnListViewItemStateChanged called"); History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index)); String url = pHistory->GetHistoryUrl(); if (url != null) @@ -1049,10 +1441,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) + { + delete __pItemContextLandscape; + } + if (__pSaveImage) + { + delete __pSaveImage; + } + if (__pMostVisitedSites) + { + __pMostVisitedSites->RemoveAll(true); + delete __pMostVisitedSites; + } return r; } @@ -1066,17 +1488,22 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) { case IDA_BACKBTN_CLICKED: { + if(__pImageMenu && __pImageMenu->GetShowState() == true) + { + AppLog("Hiding the menu"); + __pImageMenu->SetShowState(false); + } if (__pWebViewer && __pWebViewer->CanGoBack()) { __pWebViewer->GoBack(); } - else + else if(__pWindowInfo->isJavascriptInitiated == false) { UiApp* pApp = null; pApp = UiApp::GetInstance(); if (pApp != null) { - r = pApp->Terminate(); + r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED); if (IsFailed(r)) { AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r)); @@ -1084,8 +1511,101 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) } } } + else + { + UiApp* pApp = null; + WindowInfo* pWindowInfo = null; + int totalCount = 0; + SceneManager* pSceneManager = SceneManager::GetInstance(); + if (pSceneManager == null) + { + return; + } + ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList(); + if (pAllWindowList == NULL) + { + pApp = UiApp::GetInstance(); + if (pApp != null) + { + r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED); + if (IsFailed(r)) + { + AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r)); + return; + } + } + } + if (pAllWindowList != null) + { + totalCount = pAllWindowList->GetCount(); + } + for (int count = 0; count < totalCount; count++) + { + pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count)); + if (pWindowInfo == null) + { + pApp = UiApp::GetInstance(); + if (pApp != null) + { + r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED); + if (IsFailed(r)) + { + AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r)); + return; + } + } + } + else + { + if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true) + { + r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID); + if (IsFailed(r)) + { + AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r)); + return; + } + r = pAllWindowList->RemoveAt(count, true); + __pWindowInfo = null; + if (IsFailed(r)) + { + AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r)); + return; + } + if(count > 0) + { + pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1)); + } + else + { + pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1)); + } + if (pWindowInfo == null) + { + pApp = UiApp::GetInstance(); + if (pApp != null) + { + r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED); + return; + } + } + else + { + r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY)); +// r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE)); + if (IsFailed(r)) + { + AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r)); + return; + } + } + break; + } + } + } + } } - break; + break; case IDA_FORWARD_CLICKED: if (__pWebViewer == null) @@ -1095,8 +1615,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: @@ -1105,25 +1625,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); - __adressPanelPosition.y = 0; + ShowFindWordPanel(true); - if (__pAddressbar != null && __pWebViewer != NULL) + if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true) { - __webControlPosition.y = __pAddressbar->GetHeight() - 12; - __pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight()); - __pAddressbar->Invalidate(true); - __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight)); - __pWebViewer->Invalidate(true); + __pFindWordEditField->SetFocus(); +// __pFindWordCountLabel->SetShowState(false); } - if (__pWebViewer != null) + else { - // releasing the set block - __pWebViewer->ReleaseBlock(); + __pFindWordEditFieldRightToLeft->SetFocus(); + __pFindWordCountLabelRightToLeft->SetShowState(false); } - ShowFindWordPanel(true); } break; case IDA_PRIVATEON_CLICKED: @@ -1176,12 +1692,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; @@ -1199,8 +1713,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; @@ -1233,12 +1748,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) { - 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(); } } else @@ -1249,40 +1769,119 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) pBookmark->SetBookmarkTitle(title); pBookmark->SetUrl(url); + if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null) + { + pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN())); + } String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl); pBookmark->SetFaviconId(id); - r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark); + //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark); + r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark); delete pBookmark; - - 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(); pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP); } } if (pBitmap != null) { - r = __pMenu->SetItemAt(0,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_SHARE_CLICKED: + case IDA_PRINT_CLICKED: { - if(__pPopUp != null) + 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) { - delete __pPopUp; - __pPopUp = null; + 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; } - __pPopUp = new(std::nothrow) SharePopup(); - __pPopUp->Initialize(); - if (__pWindowInfo != null) + else + { + int __modalMsgBoxResult; + MessageBox* pMsgBox = new MessageBox(); + pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000); + pMsgBox->ShowAndWait(__modalMsgBoxResult); + delete pMsgBox; + pMsgBox = null; + __modalMsgBoxResult = 0; + } + } + break; + case IDA_SHARE_CLICKED: + { + if(__pPopUp != null) + { + delete __pPopUp; + __pPopUp = null; + } + if(__pAddressbar) + { + __pAddressbar->HideKeypad(); + } + __pPopUp = new(std::nothrow) SharePopup(); + __pPopUp->Initialize(); + if (__pWindowInfo != null) { ShareInfo* pShareInfo = new(std::nothrow) ShareInfo(); pShareInfo->SetPageTitle(__pWindowInfo->pageTitle); @@ -1296,20 +1895,22 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) } break; case IDA_BOOKMARKBTN_CLICKED: - + { AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED"); SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE)); - break; + } + break; + case IDA_ADD_TO_BOOKMARKBTN_CLICKED: + { + } + 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); - if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL) + 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""; @@ -1333,13 +1934,13 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) } AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3"); - if (__pMenu->GetItemCount() == 6) + if (__pOptionMenu->GetItemCount() == 9) { - r = __pMenu->SetItemAt(0,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(0,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)) @@ -1349,34 +1950,57 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) return ; } AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4"); - if (__pMenu->GetItemCount() != 6) + if (__pOptionMenu->GetItemCount() != 9) { - __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED); - __pMenu->InsertItemAt(2,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) + if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE) { 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: + { + AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED"); + SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE)); + } + break; + case IDA_SAVED_PAGES_CLICKED: + { + } + break; + case IDA_DESKTOP_VIEW_CLICKED: + { + } break; + case IDA_SAVE_CLICKED: + { + } + break; case IDA_MULTIWINDOWBTN_CLICKED: { result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE)); @@ -1386,7 +2010,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) { @@ -1437,16 +2061,12 @@ 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; case IDA_FINDWORD_CANCEL_CLICKED: @@ -1454,17 +2074,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); + __pWebViewer->SearchTextAllAsync(L"",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(); @@ -1481,9 +2123,24 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) __pFindWordEditField->SetText(L""); __currentSearchStr = L"aaaaaabbbbbbccccccc"; StartWordSearch(); + __currentSearchStr = L""; + __pFindWordNext->SetEnabled(false); + __pFindWordPrev->SetEnabled(false); +// __pFindWordCountLabel->SetShowState(false); + __pFindWordControl->Invalidate(true); + } + break; + case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED: + { + __pFindWordCountLabelRightToLeft->SetText(L"0/0"); + __pFindWordEditFieldRightToLeft->SetText(L""); + __currentSearchStr = L"aaaaaabbbbbbccccccc"; + StartWordSearch(); + __currentSearchStr = L""; __pFindWordNext->SetEnabled(false); __pFindWordPrev->SetEnabled(false); - __pFindWordPanel->Invalidate(true); +// __pFindWordCountLabelRightToLeft->SetShowState(false); + __pFindWordControl->Invalidate(true); } break; case IDA_FINDWORD_NEXT_CLICKED: @@ -1508,19 +2165,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; @@ -1558,22 +2216,34 @@ 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 { int __modalMsgBoxResult; MessageBox* pMsgBox = new MessageBox(); - pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000); + pMsgBox->Construct(CommonUtil::GetString(L"IDS_IMGE_POP_UNABLE_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_IMGE_POP_UNABLE_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000); pMsgBox->ShowAndWait(__modalMsgBoxResult); delete pMsgBox; pMsgBox = null; @@ -1589,6 +2259,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) @@ -1622,30 +2296,140 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) } } break; + case IDA_HYPERLINK_OPEN_CLICKED: + { + if (__pHitElementResult != null) + { + String srcUrl = __pHitElementResult->GetUrl(); + + WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl); + + if (pNewWindowInfo == null) + { + return; + } + pNewWindowInfo->isJavascriptInitiated = true; + result r = E_SUCCESS; + SceneManager* pSceneManager = SceneManager::GetInstance(); + if (pSceneManager == NULL) + { + return; + } + ArrayList* pArgList = new(std::nothrow) ArrayList(); + if (pArgList == NULL) + { + return; + } + pArgList->Construct(); + + pArgList->Add(*pNewWindowInfo); + r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList); + if (pArgList != null) + { + delete pArgList; + pArgList = null; + } + if(IsFailed(r)) + { + AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r)); + return; + } + } + } + break; + case IDA_HYPERLINK_SHARE_IMAGE_CLICKED: + { + if (__pHitElementResult == null) + { + return; + } + + if(__pPopUp != null) + { + delete __pPopUp; + __pPopUp = null; + } + if(__pAddressbar) + { + __pAddressbar->HideKeypad(); + } + __pPopUp = new(std::nothrow) SharePopup(); + __pPopUp->Initialize(); + + ShareInfo* pShareInfo = new(std::nothrow) ShareInfo(); + pShareInfo->SetPageUrl(__pHitElementResult->GetUrl()); + pShareInfo->SetImageAttached(false); + __pPopUp->RemoveAllShareInfo(); + __pPopUp->AddShareInfo(pShareInfo); + + __pPopUp->SetShowState(true); + __pPopUp->Show(); + } + break; + case IDA_HYPERLINK_COPY_LINK_CLICKED: + { + ClipboardItem item; + String url; + if (__pHitElementResult != null) + { + url = __pHitElementResult->GetUrl(); + } + + String resourcePath = App::GetInstance()->GetAppResourcePath(); + item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url); + + // copying the item to clipboard + Clipboard* pClipboard = Clipboard::GetInstance(); + if (pClipboard != null) + { + pClipboard->CopyItem(item); + } + } + break; case IDA_FIND_TEXT__CLICKED: { +// AddressBarCancelledClicked(*__pAddressbar); + RelayoutControls(false); +// __pFooterPanel->SetShowState(false); AppLogDebug("MainForm::OnActionPerformed find word clicked"); __currentSearchStr.Clear(); __currentSearchStr.Append(__currentSelectedStr); InitFindWordPanel(); - 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); - __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight)); + __webControlPositionF.y = __pAddressbar->GetHeightF() - 12.0f; + __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12); + __webControlHeightF = GetClientAreaBoundsF().height - __pFooterPanel->GetHeightF() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeightF() - 12.0f); + + if (__pFooterPanel->GetShowState() == false) + __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12))); + else + __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight)); __pWebViewer->Invalidate(true); } ShowFindWordPanel(true); + if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true) + { + __pFindWordEditField->SetText(__currentSearchStr); + __pFindWordEditField->SetFocus(); + } + else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true) + { + __pFindWordEditFieldRightToLeft->SetText(__currentSearchStr); + __pFindWordEditFieldRightToLeft->SetFocus(); + } + if (__currentSearchStr.GetLength() > 0) { StartWordSearch(); @@ -1665,12 +2449,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) @@ -1688,6 +2477,7 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) break; case IDA_COPY_TEXT_CLICKED: { +// __pWebViewer->ReleaseBlock();//as per hyunn lee request for issue 53500 // need to implement //__currentSelectedStr // Sets data to a clip board item @@ -1724,109 +2514,390 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) if (pString != null) { String idElement = __pHitElementResult->GetAttributeValue(L"id"); + String nameElement = __pHitElementResult->GetAttributeValue(L"name"); + String classElement = __pHitElementResult->GetAttributeValue(L"class"); + String tagElement = __pHitElementResult->GetTagName(); + String contenteditable = __pHitElementResult->GetAttributeValue("contenteditable"); AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer()); - String script = L"function insertAtCursor(myField, myValue) { if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0'){ var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } insertAtCursor("; - script.Append(idElement); - script.Append(","); - script.Append("\""); - script.Append(*pString); - script.Append("\");"); + String str = L"document.getElementsByName('"; + str.Append(nameElement); + str.Append("').length"); + String* pNameCount = __pWebViewer->EvaluateJavascriptN(str); + + str.Clear(); + str = L"document.getElementsByClassName('"; + str.Append(classElement); + str.Append("').length"); + String* pClassCount = __pWebViewer->EvaluateJavascriptN(str); + + String script; + if(contenteditable.Equals(L"true",false) == true) + { + AppLog("gmail paste need to support"); + + script = L"function replaceSelectedText(replacementText) { var sel, range; if (window.getSelection) { sel = window.getSelection(); if (sel.rangeCount) { range = sel.getRangeAt(0); range.deleteContents(); range.insertNode(document.createTextNode(replacementText)); } } else if (document.selection && document.selection.createRange) { range = document.selection.createRange(); range.text = replacementText; } }"; + script.Append("replaceSelectedText("); + script.Append("\""); + script.Append(*pString); + script.Append("\");"); + } + else if(idElement.GetLength() != 0) + { + script = L"function insertAtCursor(myField, myValue) { if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0'){ var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } "; + script.Append("insertAtCursor("); + script.Append(L"document.activeElement"); + script.Append(","); + script.Append("\""); + script.Append(*pString); + script.Append("\");"); + } + else if (classElement.GetLength() != 0 && pClassCount->Equals("1",false) == true) + { + script = L"function insertAtCursor(myField, myValue) { if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0'){ var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } "; + script.Append("insertAtCursor(document.getElementsByClassName('"); + script.Append(classElement); + script.Append("')[0],"); + script.Append("\""); + script.Append(*pString); + script.Append("\");"); + } + else if (nameElement.GetLength() != 0 && pNameCount->Equals("1",false) == true) + { + script = L"function insertAtCursor(myField, myValue) { if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0'){ var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } "; + script.Append("insertAtCursor(document.getElementsByName('"); + script.Append(nameElement); + script.Append("')[0],"); + script.Append("\""); + script.Append(*pString); + script.Append("\");"); + } + else if(tagElement.GetLength() != 0) //adding for twitter post page + { + script = L"function insertAtCursor(myField, myValue) { if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0'){ var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } "; + + script.Append("insertAtCursor(document.activeElement,"); + script.Append("\""); + script.Append(*pString); + script.Append("\");"); + } AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer()); String* pStr = __pWebViewer->EvaluateJavascriptN(script); delete pStr; + delete pNameCount; + delete pClassCount; } delete pItem; + if(__pWebViewer) + __pWebViewer->ReleaseBlock(); } break; - default: - break; + case IDA_GO_BACK: + { + OnBackClicked(); } -} - -void -MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source) -{ - - UiApp* pApp = UiApp::GetInstance(); - if (pApp == null) + break; + case IDA_GO_FORWARD: { - return; + OnForwardClicked(); } - pApp->Terminate(); -} + break; + case IDA_REFRESH_BTN_CLICKED: + { + __isLoadingCompleted = false; + __isLoadingData = true; + __progressPercentage = 0; + __displayUrl = __pFooterUrlField->GetText(); -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; + String url = __pFooterUrlField->GetText(); + AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer()); +// LoadUrl(url); + if (__pWebViewer != null && __pAddressbar != null) + { + LoadUrl(url); + //__pWebViewer->Reload(); + SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING); + } - if (pSelectedScene != null) - { - delete pSelectedScene; + //OnUrlSubmitted(); + UpdateProgressBitmap(); } - 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); + break; + case IDA_STOP_BTN_CLICKED: + { + __isLoadingCompleted = false; + __isLoadingData = false; + __progressPercentage = 0; + __pFooterUrlField->HideKeypad(); + __displayUrl = __pFooterUrlField->GetText(); - MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID); + if (__pWebViewer) + { + //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE); + SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE); + __pWebViewer->StopLoading(); + RequestRedraw(true); + } - if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2) + UpdateProgressBitmap(); + } + break; + case IDA_CLEAR_URL: { - __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0)); - if(__pWindowInfo == null) - return; - // if(__pWindowInfo == null) + if (__pFooterUrlField->GetText().IsEmpty() == false) { - pUrl = dynamic_cast< String* >(pArgs->GetAt(1)); + //__displayUrl = __pUrlField->GetText(); + __pFooterUrlField->Clear(); + } } - else if ( pArgs != null && pArgs->GetCount() == 1) + break; + case IDA_READER_BTN_CLICKED: { - __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0)); + ReaderClicked(); } + break; + default: + break; + } +} - InitFooter(); - InitAddressbar(); - - if(__pWebViewer != null) +void +MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source) +{ + AppLog("MainForm::OnFormBackRequested entered"); + result r = E_FAILURE; + if(__pImageMenu && __pImageMenu->GetShowState() == true) { - __pWebViewer->Resume(); + AppLog("Hiding the menu"); + __pImageMenu->SetShowState(false); } - - if(pUrl != null && pUrl->GetLength() > 0) + if (__pWebViewer && __pWebViewer->CanGoBack()) { - LoadUrl(*pUrl); + __pWebViewer->GoBack(); } - else if(__pWindowInfo != null) + else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false) { - 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) - { - LoadUrl(__pWindowInfo->pageUrl); - } - else if (__pWindowInfo->isJavascriptInitiated == true) + UiApp* pApp = null; + pApp = UiApp::GetInstance(); + if (pApp != null) { - AppLog("Called"); - InitWebControl(); - __pWindowInfo->pCurrentWeb = __pWebViewer; + r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED); + if (IsFailed(r)) + { + AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r)); + return; + } } } - - 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) + else + { + UiApp* pApp = null; + WindowInfo* pWindowInfo = null; + int totalCount = 0; + SceneManager* pSceneManager = SceneManager::GetInstance(); + if (pSceneManager == null) + { + return; + } + ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList(); + if (pAllWindowList == NULL) + { + pApp = UiApp::GetInstance(); + if (pApp != null) + { + r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED); + if (IsFailed(r)) + { + AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r)); + return; + } + } + } + if (pAllWindowList != null) + { + totalCount = pAllWindowList->GetCount(); + } + for (int count = 0; count < totalCount; count++) + { + pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count)); + if (pWindowInfo == null) + { + pApp = UiApp::GetInstance(); + if (pApp != null) + { + r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED); + if (IsFailed(r)) + { + AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r)); + return; + } + } + } + else + { + if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true) + { + r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID); + if (IsFailed(r)) + { + AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r)); + return; + } + r = pAllWindowList->RemoveAt(count, true); + __pWindowInfo = null; + if (IsFailed(r)) + { + AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r)); + return; + } + if(count > 0) + { + pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1)); + } + else + { + pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1)); + } + if (pWindowInfo == null) + { + pApp = UiApp::GetInstance(); + if (pApp != null) + { + r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED); + return; + } + } + else + { + if(pWindowInfo != null) + r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY)); + if (IsFailed(r)) + { + AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r)); + return; + } + } + break; + } +// else if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == false) +// { +// UiApp* pApp = null; +// pApp = UiApp::GetInstance(); +// if (pApp != null) +// { +// r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED); +// if (IsFailed(r)) +// { +// AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r)); +// return; +// } +// } +// } + } + } + } + AppLog("MainForm::OnFormBackRequested exit"); +} + +void +MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, + const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs) +{ + + AppLog("MainForm::OnSceneActivatedN called"); + String* pSelectedScene = NULL; + Object* pValue = NULL; + String* pUrl = null; + MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue); + pSelectedScene = (String*) pValue; + + if (pSelectedScene != null) + { + delete pSelectedScene; + } + MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null); + String* selectedSceneID = new(std::nothrow) String(currentSceneId); + AppLogDebug("current scene id is %ls", currentSceneId.GetPointer()); + AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer()); + + // setting the current scene ID + MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId); + + MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID); + + if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2) + { + __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0)); + if(__pWindowInfo == null) + return; + // if(__pWindowInfo == null) + { + pUrl = dynamic_cast< String* >(pArgs->GetAt(1)); + } + } + else if ( pArgs != null && pArgs->GetCount() == 1) + { + __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0)); + } + + InitFooter(); + InitAddressbar(); + + FloatRectangle footerPanelBounds = FloatRectangle(0.0f, (GetClientAreaBoundsF().height) - __pFooterPanel->GetHeightF(), GetClientAreaBoundsF().width, __pFooterPanel->GetHeightF()); + __pFooterPanel->SetBounds(CoordinateSystem::AlignToDevice(footerPanelBounds)); + + // hiding the address bar + // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight()); + __pAddressbar->SetShowState(false); +// if(__pWebViewer != null) +// { +// __pWebViewer->Resume(); +// } + + if(pUrl != null && pUrl->GetLength() > 0) + { + LoadUrl(*pUrl); + } + else if(__pWindowInfo != null) + { + if(__pWindowInfo->pageUrl.GetLength() > 0 &&previousSceneId != IDSCN_BRIGHTNESS && previousSceneId != IDSCN_HISTORY_LIST && previousSceneId != IDSCN_MULTIPLE_WINDOW && previousSceneId != IDSCN_MULTIPLE_WINDOW_GRID && previousSceneId != IDSCN_BOOKMARK_VIEW && previousSceneId != IDSCN_SETTINGS && previousSceneId.Contains(IDSCN_MAIN_VIEW) == false) + { + LoadUrl(__pWindowInfo->pageUrl); + } + else if(__pWindowInfo->pageUrl.GetLength() > 0 && __pWindowInfo->isAppcontrolTriggered == true) + { + LoadUrl(__pWindowInfo->pageUrl); + __pWindowInfo->isAppcontrolTriggered = false; + } + else if (__pWindowInfo->isJavascriptInitiated == true && __pWindowInfo->isFirstLaunch == true) + { + __pWindowInfo->isFirstLaunch = false; + AppLog("Called"); + InitWebControl(); + __pWindowInfo->pCurrentWeb = __pWebViewer; + if(__pWindowInfo->pageUrl.GetLength() > 0) + LoadUrl(__pWindowInfo->pageUrl); + } + } + + String homePage = SettingPresentationModel::GetInstance()->GetHomepage(); + AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer()); + if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0) { InitMostVisitedSitesView(GetOrientationStatus()); } + else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0) + { + if(__pMostVisitedListView != null) + { + __pMostVisitedListView->SetShowState(false); + } + } + if(__pMostVisitedListView && __pMostVisitedListView->GetShowState() == true) + { + __pMostVisitedListView->UpdateList(); + } if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST)) { String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0)); @@ -1834,7 +2905,8 @@ MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, if (pBookmarkUrl == null) return; AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer()); - __pAddressbar->SetUrl(*pBookmarkUrl); + //__pAddressbar->SetUrl(*pBookmarkUrl); + SetUrl(*pBookmarkUrl); if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0) __pWebViewer->LoadUrl(*pBookmarkUrl); @@ -1854,7 +2926,7 @@ MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, if (__pAddressbar != null) { - __pAddressbar->UpdateFaviconBitmap(true); + // __pAddressbar->UpdateFaviconBitmap(true); } } @@ -1869,17 +2941,17 @@ MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, if (__pAddressbar != null) { - __pAddressbar->UpdateFaviconBitmap(false); + // __pAddressbar->UpdateFaviconBitmap(false); } } - 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) @@ -1887,7 +2959,10 @@ MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, delete pBitmap; } + RelayoutControls(false); AppLog("ABC: OnSceneActivatedN started exit"); + if(__pWebViewer) + AppLog("WebControl's width height %d %d,",__pWebViewer->GetWidth(),__pWebViewer->GetHeight()); } @@ -1899,7 +2974,6 @@ MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, if (__pWebViewer != null) { pWebCanvas = __pWebViewer->GetCanvasN(); - __pWebViewer->Pause(); } if (pWebCanvas == null) @@ -1925,12 +2999,18 @@ MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, pCanvas->DrawBitmap(Point(0,0),*pBitmap); delete pBitmap; } - if(__pWebViewer != null && __pWindowInfo != null) + if(__pWebViewer != null && __pWindowInfo != null && __pWindowInfo->pWebCanvasBitmap != null) pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap); WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap(); - WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight())); + if (__pFooterPanel) + { + 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"); } @@ -1952,15 +3032,30 @@ MainForm::OnLoadingStarted(void) { AppLogDebug("MainForm::OnLoadingStarted entered"); __isLoaded = true; - if(__pAddressbar == NULL) + if(__pAddressbar == NULL || __pWebViewer == null) { return; } + + // this is added in case if menu is opened and user load the page + if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true) + { + __pOptionMenu->SetShowState(false); + __pOptionMenu->Invalidate(true); + } + + + + if(__pImageMenu != null && __pImageMenu->GetShowState() == true) + { + __pImageMenu->SetShowState(false); + __pImageMenu->Invalidate(true); + } String url = __pWebViewer->GetUrl(); if(url.Contains(IDS_TIZEN_SERVICE)) { String appId; - String delim(L":;"); + String delim(L":;,"); // Creates a StringTokenizer instance StringTokenizer strTok(url, delim); @@ -1981,40 +3076,48 @@ 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(4, key); + AppLog("key:%ls", key.GetPointer()); + } + else if(token.Contains(IDS_VALUE)) { - token.SubString(0, index, *pKey); - token.SubString(index + 1, *pValue); - pMap->Add(pKey, pValue); + token.SubString(6, value); + AppLog("value:%ls", value.GetPointer()); } } - } - if(appId != "") - { - AppControl *pAppControl = null; - String operationId = L"http://tizen.org/appcontrol/operation/main"; - pAppControl = dynamic_cast(AppManager::FindAppControlN(appId, operationId)); - if(pAppControl) - { - AppLog("Starting AppControl"); - result r = pAppControl->Start(null, null, pMap, null); - AppLog("Result of Start %s", GetErrorMessage(r)); - } - else + pMap->Add(key, value); + + if(appId != "") { - AppLogException("AppControl not found"); + AppControl *pAppControl = null; + String operationId = L"http://tizen.org/appcontrol/operation/main"; + pAppControl = dynamic_cast(AppManager::FindAppControlN(appId, operationId)); + if(pAppControl) + { + AppLog("Starting AppControl"); + result r = pAppControl->Start(null, null, pMap, null); + AppLog("Result of Start %s", GetErrorMessage(r)); + } + else + { + AppLogException("AppControl not found"); + } + return; } - return; } + if ( __pAddressbar != null && __pAddressbar->GetShowState() == true) + { + __pAddressbar->SetShowState(false); + AddressBarCancelledClicked(*__pAddressbar); + __pAddressbar->Invalidate(true); } Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN(); - __pAddressbar->SetFaviconBitmap(*pBitmap); + if(pBitmap != null) + { + __pAddressbar->SetFaviconBitmap(*pBitmap); + } delete pBitmap; if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12)) { @@ -2024,13 +3127,17 @@ MainForm::OnLoadingStarted(void) MoveUiControls(); } - __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING); - if (__pWebViewer) + //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING); + SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING); + if (__pWebViewer != null) { AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer()); - __pAddressbar->SetUrl(__pWebViewer->GetUrl()); + //__pAddressbar->SetUrl(__pWebViewer->GetUrl()); + SetUrl(__pWebViewer->GetUrl()); if (__pWindowInfo != NULL) { + // resetting the page title to blank, it will be received in OnPageTitleReceived() +// __pWindowInfo->pageTitle = L""; __pWindowInfo->pageUrl = __pWebViewer->GetUrl(); } __pAddressbar->Invalidate(true); @@ -2044,22 +3151,36 @@ MainForm::OnLoadingCanceled(void) } - void MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source) { - if(__pAddressbar != null) - { - OnAddressBarKeypadOpened(*__pAddressbar); - } + AppLog("XYZ::MainForm::OnKeypadWillOpen"); + } void -MainForm::OnKeypadClosed(Tizen::Ui::Control& source){ - if(__pAddressbar != null) - { - OnAddressBarKeypadClosed(*__pAddressbar); - } +MainForm::OnKeypadOpened(Tizen::Ui::Control& source) +{ + AppLog("XYZ::MainForm::OnKeypadOpened"); + __isKeypadOpened = true; + __pFooterPanel->SetShowState(false); + RelayoutControls(false); +} + +void +MainForm::OnKeypadClosed(Tizen::Ui::Control& source) +{ + AppLog("XYZ::MainForm::OnKeypadClosed"); + __isKeypadOpened = false; + __pFooterPanel->SetShowState(true); + RelayoutControls(true); +} + +void +MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source) +{ + AppLog("XYZ::KeypadBoundsChanged"); + RelayoutControls(false); } void @@ -2072,6 +3193,7 @@ MainForm::OnLoadingErrorOccurred(LoadingErrorType error, void MainForm::OnLoadingCompleted(void) { + AppLog("MainForm::OnLoadingCompleted start"); DateTime date; result r = E_SUCCESS; @@ -2084,113 +3206,252 @@ MainForm::OnLoadingCompleted(void) { return; } - if (__pWebViewer->CanGoForward()) - { - __pAddressbar->SetForwardButtonEnabled(true); - } - else + + if(__pWindowInfo && __pWebViewer) + __pWindowInfo->pageTitle = __pWebViewer->GetTitle(); + if(__pImageMenu && __pImageMenu->GetShowState()) { - __pAddressbar->SetForwardButtonEnabled(false); + __pImageMenu->SetShowState(false); + __pImageMenu->Invalidate(true); } - if (__pWebViewer->CanGoBack()) + if (__pWebViewer->CanGoForward()) { - __pAddressbar->SetBackButtonEnabled(true); + //__pAddressbar->SetForwardButtonEnabled(true); + SetForwardButtonEnabled(true); } else { - __pAddressbar->SetBackButtonEnabled(false); + //__pAddressbar->SetForwardButtonEnabled(false); + SetForwardButtonEnabled(false); } - if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT) + + /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT) { __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE); - __pAddressbar->UpdateProgress(0); + //__pAddressbar->UpdateProgress(0); + UpdateProgress(0); + }*/ + + if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT) + { + SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE); + UpdateProgress(0); } AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled()); bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn(); if (isPrivateBrowsing == false) { - 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) + { + AppLog("MainForm::OnLoadingCompleted setting the fav icon 0"); + + Bitmap* pTempBitmap = __pWebViewer->GetFaviconN(); + if (pTempBitmap != null) + { + AppLog("MainForm::OnLoadingCompleted setting the fav icon 1"); + __pHistory->SetFavIconBitmap(*pTempBitmap); + } + + } + Canvas* pCanvas = __pWebViewer->GetCanvasN(); Bitmap* pBitmap = new(std::nothrow) Bitmap(); if ( pCanvas != null && pCanvas != null && pBitmap != null) { pBitmap->Construct(*pCanvas, pCanvas->GetBounds()); pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4)); - pHistory->SetThumbnail(pBitmap); + __pHistory->SetThumbnail(pBitmap); + } + Bitmap *pFavIcon = __pWebViewer->GetFaviconN(); + if (pFavIcon) + { + Tizen::Graphics::BufferInfo bmpInfo; + pFavIcon->Lock(bmpInfo); + AppLog("rrrr:: width %d height %d of the faviconbitmap from bufferinfo", bmpInfo.width, bmpInfo.height); + + AppLog("MainForm::OnLoadingCompleted setting the fav icon 2"); + + AppLog("rrrr:: width %d height %d of the faviconbitmap",pFavIcon->GetWidth(),pFavIcon->GetHeight()); + __pHistory->SetFavIconBitmap(*pFavIcon); + delete pFavIcon; } - HistoryPresentationModel::GetInstance()->SaveHistory(*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(); } -} - -void -MainForm::OnEstimatedProgress(int progress) -{ - AppLogDebug("MainForm::OnEstimatedProgress entered"); - if (progress < DEFAULT_PROGRESS_PERCENTAGE) - progress = DEFAULT_PROGRESS_PERCENTAGE; - if(__pAddressbar) - __pAddressbar->UpdateProgress(progress); -} - -void -MainForm::OnUrlSubmitted(Addressbar& addBar) -{ - String url = addBar.GetUrl(); - LoadUrl(url); - __pFooterPanel->SetShowState(true); - __pFooterPanel->Invalidate(true); - RequestRedraw(true); -} - -void -MainForm::LoadUrl(String& url) -{ - AppLogDebug("MainForm::LoadUrl enter"); - if (url.CompareTo(L"") == 0) - { - return; - } - if(__pFooterPanel != null) + bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled(); + if (isReaderEnabled == true) { - __pFooterPanel->SetShowState(true); - __pFooterPanel->Invalidate(true); - } - InitWebControl(); + 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"); +} + +void +MainForm::OnEstimatedProgress(int progress) +{ + AppLogDebug("MainForm::OnEstimatedProgress entered %d",progress); + + if (progress < DEFAULT_PROGRESS_PERCENTAGE) + progress = DEFAULT_PROGRESS_PERCENTAGE; + //if(__pAddressbar) + // __pAddressbar->UpdateProgress(progress); + UpdateProgress(progress); +} + +void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon) +{ + AppLog("MainForm::OnFaviconReceived"); + if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0)) + { + Bitmap* favIcon = __pWebViewer->GetFaviconN(); + if(favIcon != null) + { + HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon); + delete favIcon; + } + } +} + +void +MainForm::OnUrlValueChanged(Addressbar&) +{ + Invalidate(true); +} + +void +MainForm::OnUrlSubmitted(Addressbar& addBar) +{ + AppLog("MainForm::OnUrlSubmitted"); + String url = addBar.GetUrl(); + AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer()); + + if(__pFooterUrlField) + __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength()); + AddressBarCancelledClicked(*__pAddressbar); + LoadUrl(url); +} + +void +MainForm::LoadUrl(String& url) +{ + url.Trim(); + String encodedUrl; +// UrlEncoder::Encode(url, L"UTF-8", encodedUrl); + AppLogDebug("MainForm::LoadUrl enter"); + + if (__pWebViewer != null) + { + __pWebViewer->SetShowState(true); + __pWebViewer->Invalidate(true); + } + + if (url.CompareTo(L"") == 0) + { + return; + } + if(__pFooterPanel != null) + { + __pFooterPanel->SetShowState(true); + __pFooterPanel->Invalidate(true); + } + InitWebControl(); bool ret = false; bool flag = false; String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)"); - String secondPattern(L"^[A-Za-z0-9\.\+-:#@%/;$~?]+\\.[A-Za-z0-9\+-=:#@%/;$~()_?\\\.&]{2,}$"); // URL of type abc.com (i.e without protocol in front of it) + String secondPattern(L"^[A-Za-z0-9\.\+-:#@%/;$~?]+\\.[A-Za-z0-9!\+-=:#@%/;$~()_?\\\.&]{2,}$"); // URL of type abc.com (i.e without protocol in front of it) RegularExpression firstRegex; RegularExpression secondRegex; @@ -2204,6 +3465,7 @@ MainForm::LoadUrl(String& url) if (ret == true && __pWebViewer != null) { + SetUrl(url); __pWebViewer->LoadUrl(url); } else if(__pWebViewer != null) @@ -2217,12 +3479,14 @@ MainForm::LoadUrl(String& url) } else { - __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(url)); + UrlEncoder::Encode(url, L"UTF-8", encodedUrl); + __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl)); } } if (__pAddressbar != null) { - __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING); + //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING); + SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING); } AppLogDebug("MainForm::LoadUrl exit"); @@ -2232,138 +3496,263 @@ MainForm::LoadUrl(String& url) } void +MainForm::OnFocusGained(const Tizen::Ui::Control& source) +{ + AppLog("MainForm::OnFocusGained"); + if(__pFooterPanel) + { + __pFooterPanel->SetShowState(false); + } + + if(__pWebViewer) + { + __pWebViewer->ReleaseBlock(); + } + + if(__pAddressbar) + { + __pAddressbar->SetShowState(true); + __pAddressbar->SetAddressbarURLFocus(); + } + if(__pFindWordControl && __pFindWordControl->GetShowState() == true) + { + __currentSearchStr = L""; + __currentWordIndex = 0; + __maxOccurrances = 0; + + if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true) + { + __pFindWordEditField->SetText(L""); + __pFindWordEditField->HideKeypad(); + __pFindWordControl->SetShowState(false); + __pFindWordCountLabel->SetText(L"0/0"); + } + else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true) + { + __pFindWordEditFieldRightToLeft->SetText(L""); + __pFindWordEditFieldRightToLeft->HideKeypad(); + __pFindWordControl->SetShowState(false); + __pFindWordCountLabelRightToLeft->SetText(L"0/0"); + } + + __pFindWordNext->SetEnabled(false); + __pFindWordPrev->SetEnabled(false); + + __pWebViewer->SearchTextAllAsync(L"",true); + __pFindWordControl->SetShowState(false); + } + RelayoutControls(false); +} + +void +MainForm::OnFocusLost(const Tizen::Ui::Control& source) +{ + AppLog("MainForm::OnFocusLost called"); +} + +void MainForm::OnStopClicked(Addressbar& addBar) { AppLogDebug("MainForm::OnStopClicked called"); if (__pWebViewer) { - __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE); + //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE); + SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE); __pWebViewer->StopLoading(); RequestRedraw(true); } } void -MainForm::OnReaderClicked(const Addressbar& addBar) +MainForm::OnBackClicked(/*const Addressbar& addBar*/) { - int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73; - - CreateReaderPanel(); - AppLogDebug("MainScene::OnReaderClicked entered"); - - - /*if (__pArticleReaderPanel) + // AppLog("MainForm::OnBackClicked"); + result r = E_FAILURE; + if(__pImageMenu && __pImageMenu->GetShowState() == true) { - 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); + AppLog("Hiding the menu"); + __pImageMenu->SetShowState(false); + } - if (__pReaderData == null) + if (__pWebViewer && __pWebViewer->CanGoBack()) { - return; + __pWebViewer->GoBack(); } - - 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 if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false) + { + UiApp* pApp = null; + pApp = UiApp::GetInstance(); + if (pApp != null) + { + r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED); + if (IsFailed(r)) + { + AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r)); + return; + } + } } else { - AppLogDebug("cannot LoadData __pWebReader is 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) + { + pApp = UiApp::GetInstance(); + if (pApp != null) + { + r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED); + if (IsFailed(r)) + { + AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r)); + return; + } + } + } + if (pAllWindowList != null) + { + totalCount = pAllWindowList->GetCount(); + } + for (int count = 0; count < totalCount; count++) + { + pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count)); + if (pWindowInfo == null) + { + pApp = UiApp::GetInstance(); + if (pApp != null) + { + r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED); + if (IsFailed(r)) + { + AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r)); + return; + } + } + } + if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true) + { + r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID); + if (IsFailed(r)) + { + AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r)); + return; + } + r = pAllWindowList->RemoveAt(count, true); + __pWindowInfo = null; + if (IsFailed(r)) + { + AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r)); + return; + } + if(count > 0) + { + pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1)); + } + else if(pAllWindowList->GetCount() > 0) + { + pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1)); + } + else + { + pApp = UiApp::GetInstance(); + if (pApp != null) + { + r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED); + return; + } + + } + if (pWindowInfo == null) + { + pApp = UiApp::GetInstance(); + if (pApp != null) + { + r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED); + return; + } + } + else + { + r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY)); +// r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE)); + if (IsFailed(r)) + { + AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r)); + return; + } + } + break; + } + + } + } } void -MainForm::OnBackClicked(const Addressbar& addBar) +MainForm::OnForwardClicked(/*const Addressbar& addBar*/) { + AppLog("MainForm::OnForwardClicked"); if (__pWebViewer == null) return; - if (__pWebViewer->CanGoBack()) + if (__pWebViewer->CanGoForward()) { - __pWebViewer->GoBack(); + __pWebViewer->GoForward(); } - } void -MainForm::OnForwardClicked(const Addressbar& addBar) +MainForm::OnAddressBarFocusGained(const Addressbar& addBar) { - if (__pWebViewer == null) - return; + AppLog("XYZ::MainForm::OnAddressBarFocusGained"); + if(__pFooterPanel != null) + { + __pFooterPanel->SetShowState(false); + } - if (__pWebViewer->CanGoForward()) + if (__pAddressbar != null && __pAddressbar->GetShowState() == false) { - __pWebViewer->GoForward(); + __pAddressbar->SetShowState(true); + __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight())); } + + RelayoutControls(false); +} + +void +MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState) +{ + AppLog("XYZ::MainForm::OnAddressBarFocusLost"); + + int Height = GetClientAreaBounds().height; + AppLog("MainForm::OnAddressBarFocusLost height is %d",Height); + + RelayoutControls(false); } void MainForm::OnAddressCancelledClicked(const Addressbar& addBar) { - __pFooterPanel->SetShowState(true); - __pFooterPanel->Invalidate(false); + AddressBarCancelledClicked(addBar); } void -MainForm::OnAddressBarModeChanged(const Addressbar& addBar) +MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/) { __prevAddressBarMode = __curAddressBarMode; if (__pAddressbar != null) { - __curAddressBarMode = __pAddressbar->GetAddressbarMode(); + __curAddressBarMode = GetAddressbarMode(); } if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT) @@ -2372,101 +3761,112 @@ MainForm::OnAddressBarModeChanged(const Addressbar& addBar) if (__pAddressbar != null) { __webControlPosition.y = __pAddressbar->GetHeight() - 12; + __webControlPositionF.y = __pAddressbar->GetHeightF() - 12.0f; __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight())); __pAddressbar->Invalidate(true); } if (__pWebViewer != null) { __pWebViewer->StopLoading(); - } - } - if (__pWebViewer != null) + else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING) { - if(__pFooterPanel->GetShowState() == false) - __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12))); - else - __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight)); - __pWebViewer->Invalidate(true); + __adressPanelPosition.y = 0; + if (__pAddressbar != null) + { + __webControlPosition.y = 0; + __webControlPositionF.y = 0.0f; + __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight())); + __pAddressbar->Invalidate(true); + } } } void -MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar) +MainForm::OnClipboardClosed(const Addressbar& addBar) { - - if(__pFooterPanel != null) + AppLog("XYZ::MainForm::OnClipboardClosed"); + if (__pFooterPanel && __pAddressbar->GetShowState() == false) { - String homePage = SettingPresentationModel::GetInstance()->GetHomepage(); - if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0) - { - InitMostVisitedSitesView(GetOrientationStatus()); - } + AppLog("akjshdasd 3"); __pFooterPanel->SetShowState(true); - __pFooterPanel->Invalidate(false); } + __isKeypadOpened = false; + RelayoutControls(false); +} - - - //AppLogDebug("MainForm::OnAddressBarKeypadClosed enterd"); - - if (__pWebViewer != null && __pFooterPanel != null) +void +MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState) +{ + AppLog("XYZ::MainForm::OnAddressBarKeypadClosed"); + if (__pFooterPanel && __pAddressbar->GetShowState() == false) { - AppLog("MainForm::OnAddressBarKeypadClosed GetClientAreaBounds().height %d ", GetClientAreaBounds().height); - __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->Invalidate(false); - //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight)); + AppLog("akjshdasd 3"); + __pFooterPanel->SetShowState(true); + } + __isKeypadOpened = false; + if(__pNotification && __pNotification->GetShowState()) + { + __pNotification->SetPosition(0,GetClientAreaBounds().height - __pNotification->GetHeight()); } - if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null) - __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14)); + RelayoutControls(false,footerState); } void MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar) { - __pFooterPanel->SetShowState(false); - __pFooterPanel->Invalidate(false); + AppLog("XYZ::MainForm::OnAddressBarKeypadOpened"); + __isKeypadOpened = true; + if(__pNotification && __pNotification->GetShowState()) + { + __pNotification->SetPosition(0,GetClientAreaBounds().height - __pNotification->GetHeight()); + } + RelayoutControls(false); } void MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar) { + __isKeypadOpened = true; __pFooterPanel->SetShowState(false); - __pFooterPanel->Invalidate(false); +} + +void +MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar) +{ + AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged"); + RelayoutControls(false); } void MainForm::OnPageTitleReceived(const Tizen::Base::String& title) { + AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer()); if (__pWindowInfo) { __pWindowInfo->pageTitle = title; if (__pWebViewer != null) { __pWindowInfo->pageUrl = __pWebViewer->GetUrl(); + AppLog("MainForm::OnPageTitleReceived url %ls",__pWindowInfo->pageUrl.GetPointer()); } } if (__pAddressbar != null && __pWebViewer != null) { - __pAddressbar->SetUrl(__pWebViewer->GetUrl()); - __pAddressbar->UpdateFaviconBitmap(SettingPresentationModel::GetInstance()->GetPrivateOn()); + SetUrl(__pWebViewer->GetUrl()); __pAddressbar->Invalidate(true); } - } 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) @@ -2478,7 +3878,8 @@ MainForm::UpdateFavicon(void) if (url.GetHost().GetLength() == 0) { Uri webUrl; - webUrl.SetUri(__pWebViewer->GetUrl()); + if(__pWebViewer) + webUrl.SetUri(__pWebViewer->GetUrl()); result r = url.SetHost(webUrl.GetHost()); if(IsFailed(r)) { @@ -2489,7 +3890,8 @@ MainForm::UpdateFavicon(void) if (url.GetScheme().GetLength() == 0) { Uri webUrl; - webUrl.SetUri(__pWebViewer->GetUrl()); + if(__pWebViewer) + webUrl.SetUri(__pWebViewer->GetUrl()); url.SetScheme(webUrl.GetScheme()); } __pWindowInfo->faviconUrl = url.ToString(); @@ -2500,12 +3902,10 @@ MainForm::UpdateFavicon(void) { if (__pWindowInfo->pFavicon != NULL) { - // delete __pWindowInfo->pFavicon; __pWindowInfo->pFavicon = null; } __pWindowInfo->pFavicon = new(std::nothrow) Bitmap(); __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight())); - //bool isPrivateBrowsing = __pWebViewer->IsPrivateBrowsingEnabled(); __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon); @@ -2517,36 +3917,61 @@ MainForm::UpdateFavicon(void) } else { - __pAddressbar->SetFaviconBitmap(*FaviconManager::GetInstance()->GetDefaultFaviconN()); + Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN(); + if(pDefaultBmp != null) + { + __pAddressbar->SetFaviconBitmap(*pDefaultBmp); + } + } + if(pBitmap) + { + delete pBitmap; + pBitmap = null; } - - AppLogDebug("Favicon download requested: url: %ls", url.ToString().GetPointer()); } 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); - - Uri uriInfo; + if(__pFindWordControl && __pFindWordControl->GetShowState() == true) + { + __currentSearchStr = L""; + __currentWordIndex = 0; + __maxOccurrances = 0; + __pFindWordEditField->SetText(L""); + __pFindWordNext->SetEnabled(false); + __pFindWordPrev->SetEnabled(false); + __pFindWordCountLabel->SetText(L"0/0"); + __pFindWordControl->SetShowState(false); + __pFindWordEditField->HideKeypad(); + RelayoutControls(false); + } + + __pFooterPanel->Invalidate(true); + + Uri uriInfo; uriInfo.SetUri(url); if(url.Contains(IDS_TIZEN_SERVICE)) { String appId; - String delim(L":;"); + String delim(L":;,"); // Creates a StringTokenizer instance StringTokenizer strTok(url, delim); @@ -2568,20 +3993,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; @@ -2589,9 +4013,7 @@ MainForm::OnLoadingRequested(const Tizen::Base::String& url, pAppControl = dynamic_cast(AppManager::FindAppControlN(appId, operationId)); if(pAppControl) { - AppLog("Starting AppControl"); result r = pAppControl->Start(null, null, pMap, null); - AppLog("Result of Start %s", GetErrorMessage(r)); } else { @@ -2601,30 +4023,6 @@ MainForm::OnLoadingRequested(const Tizen::Base::String& url, } } - if (__pWebViewer && __pAddressbar) - { - AppLog("__pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer()); - __pAddressbar->SetUrl(__pWebViewer->GetUrl()); - __pAddressbar->UpdateProgress(DEFAULT_PROGRESS_PERCENTAGE); - - if (__pWindowInfo) - { - __pWindowInfo->pageTitle = CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"); - __pWindowInfo->pageUrl = __pWebViewer->GetUrl(); - __pWindowInfo->faviconUrl = ""; - __pWindowInfo->faviconFilePath = ""; - - if (__pWindowInfo->pFavicon != NULL) - { - // delete __pWindowInfo->pFavicon; - __pWindowInfo->pFavicon = null ; - } - __pWindowInfo->pFavicon = FaviconManager::GetInstance()->GetDefaultFaviconN(); - - } - - __pAddressbar->Invalidate(true); - } return false; } @@ -2635,11 +4033,12 @@ 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) { - AppLog("MainForm::OnWebPageBlockSelected"); + AppLog("LMN::MainForm::OnWebPageBlockSelected"); +// if(__isLongPressedDone == false) +// return; if (__pHitElementResult != null) { @@ -2651,6 +4050,21 @@ MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graph { AppLog("MainForm::OnWebPageBlockSelected web not null"); __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint); + + if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false)) + { + AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult())); + __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint); + if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false)) + { + __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint); + if(__pHitElementResult == null) + { + __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint); + } + } + AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult())); + } } if (__pHitElementResult == null) @@ -2662,20 +4076,36 @@ MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graph { String tagName = __pHitElementResult->GetTagName(); String type = __pHitElementResult->GetAttributeValue("type"); + String contenteditable = __pHitElementResult->GetAttributeValue("contenteditable"); + + AppLog("TagName %ls",tagName.GetPointer()); __currentSelectedStr.Clear(); + AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer()); __currentSelectedStr = __pWebViewer->GetTextFromBlock(); + AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer()); + if(tagName.Equals(L"TEXTAREA",false) == true) + { + AppLog("Tagnameseemstobe TEXTAREA"); + } + else if(tagName.Equals(L"INPUT",false) == true) + { + AppLog("Tagnameseemstobe INPUT"); + } - if ((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) + if (((tagName.Equals(L"INPUT",false) == true) || tagName.Equals(L"TEXTAREA",false) == true) || contenteditable.Equals(L"true",false) == true/*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0 ) { AppLog("MainForm::OnWebPageBlockSelected show paste option"); - InitSelectTextContextMenu(startPoint,true); - __pImageMenu->SetShowState(true); - __pImageMenu->Show(); - __pImageMenu->Invalidate(true); + InitSelectTextContextMenuF(FloatPoint(startPoint.x,startPoint.y + __pWebViewer->GetY()),true); + if(__pImageMenu) + { + __pImageMenu->SetShowState(true); + __pImageMenu->Show(); + __pImageMenu->Invalidate(true); + } } - else if (__pHitElementResult->HasUrl() == true || __currentSelectedStr.GetLength() > 0) + else /*if(__isLongPressedDone == true)*/ { AppLog("MainForm::OnWebPageBlockSelected no paste option"); @@ -2684,16 +4114,20 @@ MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graph __currentSelectedStr.Clear(); __currentSelectedStr = __pHitElementResult->GetUrl(); } - InitSelectTextContextMenu(startPoint,false); - __pImageMenu->SetShowState(true); - __pImageMenu->Show(); - __pImageMenu->Invalidate(true); + InitSelectTextContextMenuF(FloatPoint(startPoint.x,startPoint.y + __pWebViewer->GetY()),false); + if(__pImageMenu) + { + __pImageMenu->SetShowState(true); + __pImageMenu->Show(); + __pImageMenu->Invalidate(true); + } } AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer()); AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer()); AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer()); } + } void @@ -2705,7 +4139,8 @@ MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source) Web* MainForm::OnWebWindowCreateRequested(void) { - WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene(); + AppLog("MainForm::OnWebWindowCreateRequested entered"); + WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(); if (pNewWindowInfo == null) { @@ -2742,61 +4177,250 @@ MainForm::OnWebWindowCreateRequested(void) } void -MainForm::RelayoutControls(bool showAddressbar) +MainForm::OnWebWindowCloseRequested(Tizen::Web::Controls::Web& source) { - if (showAddressbar == false) + AppLog("OnWebWindowCloseRequested"); + ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList(); + SceneManager* pSceneManager = SceneManager::GetInstance(); + WindowInfo* pWindowInfo = null; + WindowInfo* pNewWindowInfo = null; + int totalCount = 0; + UiApp* pApp = null; + result r = E_FAILURE; + + if (pAllWindowList != null) { - __pAddressbar->SetShowState(false); - __pWebViewer->SetBounds(__pWebViewer->GetX(), 0, __pWebViewer->GetWidth(), __webControlHeight); - __pFooterPanel->SetBounds(__pFooterPanel->GetX(), GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight()); + totalCount = pAllWindowList->GetCount(); } - else + + for (int count = 0; count < totalCount; count++) { - __pAddressbar->SetShowState(true); - __pWebViewer->SetBounds(__pWebViewer->GetX(), __pWebViewer->GetY(), __pWebViewer->GetWidth(), __webControlHeight); - __pFooterPanel->SetBounds(__pFooterPanel->GetX(), GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight()); + pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count)); + + if (__pWindowInfo != null && pWindowInfo != null && __pWindowInfo->sceneID == pWindowInfo->sceneID) + { + r = SceneRegister::DestroyAndUnRegisterScene(__pWindowInfo->sceneID); + r = pAllWindowList->RemoveAt(count, true); + + Form* pCurrentForm = null; + if(SceneManager::GetInstance()->GetCurrentScene() != null) + pCurrentForm = (SceneManager::GetInstance()->GetCurrentScene()->GetForm()); + if (pCurrentForm) + { + pCurrentForm->SendUserEvent(UPDATE_MAINFORM_FOOTER_ON_WINDOWCLOSED, null); + } + + if (pAllWindowList->GetCount() > 0) + { + pNewWindowInfo = null; + pNewWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1)); + } + else + { + WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(); + + if (pNewWindowInfo == null) + { + return; + } + result r = E_SUCCESS; + SceneManager* pSceneManager = SceneManager::GetInstance(); + if (pSceneManager == NULL) + { + return; + } + ArrayList* pArgList = new(std::nothrow) ArrayList(); + if (pArgList == NULL) + { + return; + } + r = pArgList->Construct(); + if (r == E_SUCCESS) + { + pArgList->Add(*pNewWindowInfo); + result r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList); + if (pArgList != null) + { + delete pArgList; + pArgList = null; + } + if(IsFailed(r)) + { + AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r)); + return; + } + } + + pApp = UiApp::GetInstance(); + if (pApp != null) + { + r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED); + return; + } + } + r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY)); + + break; + } + + } + + +} + +void +MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter) +{ + AppLog("xyz:: MainForm::RelayoutControls called"); + __webControlPosition.y = 0; + __webControlPositionF.y = 0.0f; + __webControlHeight = GetClientAreaBounds().height; + __webControlHeightF = GetClientAreaBoundsF().height; + AppLog("Client area height: %d width %d", __webControlHeight,GetClientAreaBounds().width); + + AppLog("Client area height: %d", __webControlHeight); + if(__pAddressbar != null && __pAddressbar->GetShowState() == true) + { + __webControlPosition.y += __pAddressbar->GetHeight(); + __webControlPositionF.y += __pAddressbar->GetHeightF(); + __webControlHeight -= __pAddressbar->GetHeight(); + __webControlHeightF -= __pAddressbar->GetHeightF(); + __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight()); + } + else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true) + { + __webControlPosition.y += __pFindWordControl->GetHeight(); + __webControlPositionF.y += __pFindWordControl->GetHeightF(); + __webControlHeight -= __pFindWordControl->GetHeight(); + __webControlHeightF -= __pFindWordControl->GetHeightF(); + __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight()); + } + + if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true) + { + __webControlHeight -= __pFooterPanel->GetHeight(); + __webControlHeightF -= __pFooterPanel->GetHeightF(); + + __pFooterPanel->SetBounds(CoordinateSystem::AlignToDevice(FloatRectangle(0.0F, __webControlPositionF.y + __webControlHeightF, GetClientAreaBoundsF().width, __pFooterPanel->GetHeightF()))); + __webControlHeight = __webControlHeight + 12; + __webControlHeightF = __webControlHeightF + 12.0f; + } + if (__pWebViewer != null && __pWebViewer->GetShowState() == true) + { + if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight ) + { + } + else + { + __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight ); + AppLog("xyz:: MainForm::RelayoutControls called __webControlHeight %d",__webControlHeight); + __pWebViewer->Invalidate(false); + } } - RequestRedraw(true); + if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null) + { + __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight)); + } + + Invalidate(true); } -void MainForm::ShowFindWordPanel(bool show , bool isTouchPressed) +void +MainForm::ShowFindWordPanel(bool show , bool isTouchPressed) { - if (__pFindWordPanel == null) + if (__pFindWordControl == null) { return; } + + Tizen::Locales::LocaleManager localeManager; + Tizen::Locales::Locale local = localeManager.GetSystemLocale(); + + String languageCode; + result r = SettingInfo::GetValue(L"Language", languageCode); + // int languagecode = local.GetLanguageCode(); + AppLog("rahul language is %S", languageCode.GetPointer()); + if (show == true) { InitFindWordPanel(); - __pFindWordEditField->SetText(__currentSearchStr); - //__pFindWordCountLabel->SetText(L""); - __pFindWordCountLabel->SetText(L"0/0"); - } + if (languageCode.CompareTo("ara") == 0) + { + AppLog("rahul language is arabic"); - AppLog("MainForm::ShowFindWordPanel %d",show); - if (show && !isTouchPressed) - { - if (__pFindWordEditField) - __pFindWordEditField->ShowKeypad(); + __pFindWordPanelLeftToRight->SetShowState(false); + __pFindWordPanelRightToLeft->SetShowState(true); + + __pFindWordClear->SetShowState(false); + __pFindWordCountLabel->SetShowState(false); + __pFindWordEditField->SetShowState(false); + + __pFindWordClearRightToLeft->SetShowState(true); + __pFindWordCountLabelRightToLeft->SetShowState(true); + __pFindWordEditFieldRightToLeft->SetShowState(true); + } + else + { + AppLog("rahul language is not arabic"); + + + __pFindWordPanelLeftToRight->SetShowState(true); + __pFindWordPanelRightToLeft->SetShowState(false); + + __pFindWordClear->SetShowState(true); + __pFindWordCountLabel->SetShowState(true); + __pFindWordEditField->SetShowState(true); + + __pFindWordClearRightToLeft->SetShowState(false); + __pFindWordCountLabelRightToLeft->SetShowState(false); + __pFindWordEditFieldRightToLeft->SetShowState(false); + } + __pFindWordControl->SetShowState(true); } else { - if (__pFindWordEditField) - __pFindWordEditField->HideKeypad(); + if(__pFindWordControl != null) + { + __pFindWordControl->SetShowState(false); + } } - if (__pAddressbar != null) + AppLog("MainForm::ShowFindWordPanel %d",show); + if (show && !isTouchPressed) { - __pAddressbar->SetShowState(!show); - __pAddressbar->Invalidate(true); + if (languageCode.CompareTo("ara") == 0) + { + if (__pFindWordEditFieldRightToLeft) + { + __pFindWordEditFieldRightToLeft->SetFocus(); + __pFindWordEditFieldRightToLeft->ShowKeypad(); + } + } + else + { + if (__pFindWordEditField) + { + __pFindWordEditField->SetFocus(); + __pFindWordEditField->ShowKeypad(); + } + } } - if (__pFindWordPanel != null) + else { - __pFindWordPanel->SetShowState(show); - __pFindWordPanel->Invalidate(true); + if (languageCode.CompareTo("ara") == 0) + { + if (__pFindWordEditFieldRightToLeft) + __pFindWordEditFieldRightToLeft->HideKeypad(); + } + else + { + if (__pFindWordEditField) + __pFindWordEditField->HideKeypad(); + } } - Invalidate(true); + + RelayoutControls(false); } void @@ -2808,7 +4432,12 @@ MainForm::StartWordSearch() __pFindWordPrev->SetEnabled(false); String *pCountStr = null; - __pWebViewer->SearchTextAllAsync(__currentSearchStr, false); + if (__pWebViewer) + { + result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false); + AppLog("Search Result %s",GetErrorMessage(r)); + } + /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;"); if (pCountStr != null) { @@ -2826,18 +4455,40 @@ void MainForm::OnTextFound(int totalCount, int currentOrdinal) AppLog("MainForm::OnTextFound totalCount %d",totalCount); AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal); -/* if(totalCount == -1 || totalCount == 0) + if(totalCount <= 9) { - __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),4,__pFindWordCountLabel->GetHeight()); - __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight()); - return; + if (__pFindWordCountLabel) + { + __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight()); + } + if (__pFindWordEditField) + { + __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight()); + } + } + else if(totalCount >= 100) + { + if (__pFindWordCountLabel) + { + __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight()); + } + if (__pFindWordEditField) + { + __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight()); + } } - else if(totalCount > 100) + else { - __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight()); - __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight()); + if (__pFindWordCountLabel) + { + __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight()); + } + if (__pFindWordEditField) + { + __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight()); + } } -*/ + __maxOccurrances = totalCount; __currentWordIndex = currentOrdinal; @@ -2847,14 +4498,23 @@ 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; } - if (totalCount == 1) + if (totalCount == 1 || totalCount == currentOrdinal) { __pFindWordNext->SetEnabled(false); } @@ -2867,15 +4527,27 @@ 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); - - //FindNextWord(true); - //Update the controls - __pFindWordNext->Invalidate(false); - __pFindWordPrev->Invalidate(false); __pFindWordCountLabel->Invalidate(false); + } + else if (__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true) + { + __pFindWordCountLabelRightToLeft->SetText(countStr); + __pFindWordCountLabelRightToLeft->Invalidate(false); + __pFindWordCountLabelRightToLeft->Invalidate(false); + } + if (__pFindWordNext) + { + __pFindWordNext->Invalidate(false); + } + if (__pFindWordPrev) + { + __pFindWordPrev->Invalidate(false); + } + } void @@ -2883,17 +4555,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) { @@ -2906,9 +4580,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); @@ -2927,112 +4610,138 @@ MainForm::FindNextWord(bool next) } __pFindWordPrev->Invalidate(false); __pFindWordNext->Invalidate(false); - __pFindWordCountLabel->Invalidate(false); - __pFindWordPanel->Invalidate(true); + + __pFindWordControl->Invalidate(true); } + void MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source) { - OnAddressBarKeypadOpened(*__pAddressbar); + 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 (__pWebViewer != null && __pFooterPanel != null) + if(__pFindWordControl && __pFindWordControl->GetShowState() == true) { - AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height); - __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12); + __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(__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, 82, GetClientAreaBounds().width,webControlHeight)); - } + if (__pWebViewer != null && __pFooterPanel != null) + { + AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height); + if(__pAddressbar != null) + { + __pAddressbar->SetShowState(false); + } + if(__pFindWordControl != null) + { + __pFindWordControl->SetShowState(false); + } + __pFooterPanel->SetShowState(false); + __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height)); + } +// if(__pImageMenu && __pImageMenu->GetShowState() == true) +// { +// __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2)); +// AppLog("omgomgomg"); +// } + Invalidate(true); } void MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source) { - OnAddressBarKeypadClosed(*__pAddressbar); -} + AppLog("abcde::MainForm::OnWebKeypadClosed"); + AppLog("xyz::MainForm::OnWebKeypadClosed"); + AppLog("akjshdasd 4"); + __pFooterPanel->SetShowState(true); +// OnAddressBarKeypadClosed(*__pAddressbar); + RelayoutControls(false); + __isKeypadOpened = false; -void -MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo) -{ - Control* temp = const_cast< Control* >(&source); - Header* pHeader = dynamic_cast< Header* >(temp); - if (pHeader != null) + + if(__pImageMenu && __pImageMenu->GetShowState() == true) { - //Header double - clicked + AppLog("abcde: imagemenu visible."); + Point p(0,0); + Point q(0,0); + __pWebViewer->GetBlockRange(p,q); + if (p == Point(0,0) && q == Point(0,0)) + return; + if(p.y < 150) + { + p.y = p.y + 100; + + } + + __pImageMenu->SetAnchorPosition(p); + __pImageMenu->Show(); + Invalidate(true); + } +} + +void +MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source) +{ + // RelativeLayout(false); + if(__pWebViewer != null) + { + __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height)); + } +} + +void +MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo) +{ + Control* temp = const_cast< Control* >(&source); + Header* pHeader = dynamic_cast< Header* >(temp); + if (pHeader != null) + { + //Header double - clicked AppLog("Header double clicked"); } - if(__pFindWordPanel) + if(__pFindWordControl) { - AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState()); - ShowFindWordPanel(__pFindWordPanel->GetShowState(), true); + AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState()); + ShowFindWordPanel(__pFindWordControl->GetShowState(), true); } 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); - } - delete[] pScript; - } } void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) { - AppLog("MainForm::OnTouchLongPressed"); + AppLog("LMN::abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y); + if(TouchEventManager::GetInstance() && TouchEventManager::GetInstance()->GetTouchInfoListN() && TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1) + { + AppLog("Returning because of more than one touch point."); + return; + } +// if(__pWebViewer) +// __pWebViewer->ReleaseBlock(); + if(__pWebViewer) + __pWebViewer->SetFocus(); + __longPressPoint = currentPosition; if (__pHitElementResult != null) { @@ -3053,7 +4762,31 @@ void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen: if (__pHitElementResult->HasImage() == true) { - InitImageContextMenu(currentPosition); + if(__pWebViewer != null) + { + __pWebViewer->ReleaseBlock();//N_SE-52389 + InitImageContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY())); + } + __pImageMenu->SetShowState(true); + __pImageMenu->Show(); + __pImageMenu->Invalidate(true); + } + else if(__pHitElementResult->HasUrl() == true) + { + if(__pWebViewer != null) + __pWebViewer->ReleaseBlock();//N_SE-52389 + String tempURl = __pHitElementResult->GetUrl(); + AppLog("tempURl is %ls", tempURl.GetPointer()); + const Bitmap* pBitmap = __pHitElementResult->GetImage(); + if (pBitmap != null) + { + AppLog("not null"); + } + else + { + AppLog(null); + } + InitImageLinkContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY())); __pImageMenu->SetShowState(true); __pImageMenu->Show(); __pImageMenu->Invalidate(true); @@ -3064,31 +4797,52 @@ void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen: String type = __pHitElementResult->GetAttributeValue("type"); String value = __pHitElementResult->GetAttributeValue(L"value"); String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML"); - + result r = E_FAILURE; __currentSelectedStr.Clear(); __currentSelectedStr = __pWebViewer->GetTextFromBlock(); - if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0) + AppLog("tag name is %ls", tagName.GetPointer()); + AppLog("type is %ls", type.GetPointer()); + + + + __isLongPressedDone = true; + if( type.Equals(L"submit",false) !=true && type.Equals(L"checkbox",false) !=true && type.Equals(L"range",false) !=true && type.Equals(L"file",false) !=true) + r =__pWebViewer->SetBlockSelectionPosition(currentPosition); + if (((tagName.Equals(L"INPUT",false) == true) || tagName.Equals(L"TEXTAREA",false) == true) && innerHtml.GetLength() == 0 && type.Equals(L"submit",false) !=true && type.Equals(L"checkbox",false) !=true && type.Equals(L"range",false) !=true && type.Equals(L"file",false) !=true/*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.Equals(L"",false) == true && r == E_INVALID_ARG) { AppLog("MainForm::OnWebPageBlockSelected show paste option"); - InitSelectTextContextMenu(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); + } } - __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(); @@ -3097,121 +4851,181 @@ MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphic { delete pHitElement; } - __inputEventToBeSupressed = false; + __inputEventToBeSupressed = false;*/ } -void -MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus) +bool +MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo) { - int widthContextItem = 0; - if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE) - { - - widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE; - } - else - { - widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT; - } + return true; +} - if( __pItemContext != NULL) +bool +MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo) +{ + if(__pFindWordControl && __pFindWordControl->GetShowState() == true) { - delete __pItemContext; - __pItemContext = null; + __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"); + } - __pItemContext= new(std::nothrow) ListContextItem(); - __pItemContext->Construct(); - Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", widthContextItem,HEIGHT_CONTEXT_MENU_BUTTON); - Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", widthContextItem, HEIGHT_CONTEXT_MENU_BUTTON); + __pFindWordNext->SetEnabled(false); + __pFindWordPrev->SetEnabled(false); - if (pBitmapNormal != null && pBitmapPressed != null) - { - __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed); + __pWebViewer->SearchTextAllAsync(L"",true); + __pFindWordControl->SetShowState(false); } - - if (pBitmapNormal != null) + AppLog("__pAddressbar->GetShowState() %d",__pAddressbar->GetShowState()); + if(__pAddressbar->GetShowState() == false) { - delete pBitmapNormal; + __pAddressbar->SetAddressbarURLFocus(); + __pFooterPanel->SetShowState(false); } - if (pBitmapPressed != null) - { - delete pBitmapPressed; - } + return false; +} + +bool +MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo) +{ + return true; +} +bool +MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo) +{ + return true; +} - if (__pFindWordPanel != null && __pFindWordPanel->GetShowState() == true) - { - __pFindWordPanel->SetBounds(0,0,GetClientAreaBounds().width,__pFindWordPanel->GetHeight()); - __pFindWordControl->SetBounds(0,0, __pFindWordPanel->GetWidth(), __pFindWordPanel->GetHeight()); - __pFindWordControl->SetShowState(true); - __pFindWordControl->Invalidate(true); - __pFindWordPanel->SetShowState(true); - __pFindWordPanel->Invalidate(true); - } +bool +MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo) +{ + return true; +} - if (__pWebViewer != null && __pFooterPanel != null) - { - AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height); - __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12); +bool +MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo) +{ + return true; +} - if(__pFooterPanel->GetShowState() == false) - __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12))); - else - __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight)); - __pWebViewer->Invalidate(true); +bool +MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo) +{ + return true; +} + +void +MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus) +{ + AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height); + int widthContextItem = 0; + //if(__pFindWordCountLabel) + // __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight()); + // As per the platform engineer comment removed this line + /*if(__pWebViewer != null) + { + // this is added because if any text is selected on long press followed by on rotation we are hiding the context menu therefore we should release the text block also + __pWebViewer->ReleaseBlock(); + }*/ + +// if(__pFindWordControl != null) +// ShowFindWordPanel(__pFindWordControl->GetShowState(), false); - //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight)); + if(__pOptionMenu && __pOptionMenu->GetShowState() == true) + { + if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE) + { + AppLog(" Orientation landscape"); + __pOptionMenu->SetMaxVisibleItemsCount(5); + } + else + { + AppLog(" Orientation potrait"); + __pOptionMenu->SetMaxVisibleItemsCount(6); + } } - if (__pAddressbar != null) + if(__pNotification && __pNotification->GetShowState() == true) { - __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight())); - __pAddressbar->SetAddressbarMode(__pAddressbar->GetAddressbarMode()); - __pAddressbar->UpdateFaviconBitmap(SettingPresentationModel::GetInstance()->GetPrivateOn()); + __pNotification->SetShowState(false); + __pNotification->Invalidate(false); + } + if ( __pFooterLabel != null) + { + Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight()); + if(pBitmap != null) + { + __pFooterLabel->SetBackgroundBitmap(*pBitmap); + delete pBitmap; + } + + } if (__pFindWordBgLabel != null) { - // __pFindWordBgLabel->SetSize(GetClientAreaBounds().width,GetClientAreaBounds().height); - Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight()); + Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight()); if (pBitmap != null) { __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap); delete pBitmap; } } - if (__pFooterPanel /*&& __pFooterPanel->GetShowState() == true*/) + + if (__pFindWordBgLabelRightToLeft != null) { - AppLog("__pFooterPanel->GetShowState() is true"); - InitFooter(); + Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight()); + if (pBitmap != null) + { + __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap); + delete pBitmap; + } } - InitAddressbar(); - if(__pMoreButton && __pMenu) + +// if(__pOptionMenu != null) +// __pOptionMenu->SetShowState(false); + + if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE) + { + widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE; + } + else { - Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight()); - __pMenu->SetAnchorPosition(p); - __pMenu->Invalidate(true); + widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT; } if (__pFooterPanel) { + AppLog("__pFooterPanel->GetShowState() is true"); + InitFooter(); + __pFooterPanel->SetBounds(CoordinateSystem::AlignToDevice(FloatRectangle(0, GetClientAreaBoundsF().height - __pFooterPanel->GetHeightF(), __pFooterPanel->GetWidthF(), __pFooterPanel->GetHeightF()))); __pFooterPanel->Invalidate(true); } + InitAddressbar(); + String homePage = SettingPresentationModel::GetInstance()->GetHomepage(); if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0) { InitMostVisitedSitesView(orientationStatus); } - if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null) - { - __pMostVisitedListView->SetBounds(__pAddressbar->GetX(),__pAddressbar->GetY()+__pAddressbar->GetHeight(),GetClientAreaBounds().width,GetClientAreaBounds().height - __pAddressbar->GetHeight()- __pFooterPanel->GetHeight()); - } - - AppLog("OnOrientationChanged 0"); + RelayoutControls(false); if (__pArticleReaderPanel != null) { if (__pArticleReaderPanel->GetShowState() == true) @@ -3249,9 +5063,11 @@ MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::Ori } } Invalidate(true); - if(__pAddressbar != null) + + if (__pAddressbar != null) { - __pAddressbar->OrientationChanged(); + int width = GetClientAreaBounds().width; + __pAddressbar->OrientationChanged(width); } } @@ -3259,23 +5075,30 @@ void MainForm::OnSettingsChange(int settingvalue) { AppLogDebug("MainForm::OnSettingsChange entered"); + + if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE) + { + __pAddressbar->ResetGuideText(); + } if (__pWebViewer == null) { AppLogDebug("Webviewer is not initialized yet."); return; } + if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW) { WebSetting settings = __pWebViewer->GetSetting(); - if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(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); } __pWebViewer->SetSetting(settings); + } else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT) { @@ -3288,6 +5111,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) { @@ -3302,7 +5126,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(); @@ -3376,6 +5217,45 @@ MainForm::OnClearCookie() } } +void +MainForm::OnClearFormData() +{ + result r = E_SUCCESS; + + if (__pWebViewer != NULL) + { + __pWebViewer->ClearFormData(); + } + if (r == E_SUCCESS) + { + AppLogDebug("Cookie cleared success"); + } + else + { + AppLogDebug("Cache cleared fail"); + } +} + +void +MainForm::OnClearPasswords() +{ + result r = E_SUCCESS; + + if (__pWebViewer != NULL) + { + __pWebViewer->ClearLoginFormData(); + } + if (r == E_SUCCESS) + { + AppLogDebug("Cookie cleared success"); + } + else + { + AppLogDebug("Cache cleared fail"); + } +} + + double MainForm::findDistance(int x1,int y1,int x2, int y2) { @@ -3402,11 +5282,15 @@ 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) { - if(__pFindWordPanel) + AppLog("xyz:: MainForm::OnTouchPressed called"); + if(__pFindWordControl) { - AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState()); - ShowFindWordPanel(__pFindWordPanel->GetShowState(), true); + AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState()); +// ShowFindWordPanel(__pFindWordControl->GetShowState(), true); } + __isLongPressedDone = false; + + Touch touch; IList* pList = null; @@ -3420,7 +5304,7 @@ MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics TouchInfo* pTouchInfo = static_cast(pList->GetAt(0)); __touchPoint1 = pTouchInfo->position; - if (__pAddressbar != null) + /*if (__pAddressbar != null) { if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING) { @@ -3432,6 +5316,14 @@ MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics } __pAddressbar->Invalidate(true); + }*/ + if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING) + { + if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT) + { + //__pAddressbar->SaveAddressbarEditText(); + } + SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE); } } else if (count == 2) @@ -3445,158 +5337,64 @@ MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics } } if( pList != NULL) - { pList->RemoveAll(true); delete pList; } - return; -} - -void -MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) -{ - AppLog("Start MainForm::OnTouchMoved MoveUiControls"); - if(__pFindWordPanel) - { - AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState()); - ShowFindWordPanel(__pFindWordPanel->GetShowState(), true); - } - - if (__pFindWordEditField != null) + if(__pAddressbar) { - __pFindWordEditField->HideKeypad(); + __pAddressbar->SetShowState(false); } - - if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT) + if(__pFooterPanel && __isKeypadOpened == false) { - return; + __pFooterPanel->SetShowState(true); } - static int Count=0; - Touch touch; - IList* pList = null; - pList = touch.GetTouchInfoListN(source); - - if (pList != null) - { - int count = pList->GetCount(); - if (count == 1) - { - AppLogDebug("MainForm::OnTouchMoved count 1"); - TouchInfo* pTouchInfo = static_cast(pList->GetAt(0)); - - if( pTouchInfo == NULL ) - { - return; - } - pTouchInfo->position.y += __pWebViewer->GetY(); - AppLog("MainForm::OnTouchMoved MoveUiControls %d,%d",pTouchInfo->position.x,pTouchInfo->position.y); - - if (__isLoaded == false) - return; - - __distanceMoved = pTouchInfo->position.y - __touchPoint1.y; - __touchPoint1 = pTouchInfo->position; - - // move the address bar and web control according to distance moved - MoveUiControls(); - } - else if (count == 2) - { - AppLogDebug("MainForm::OnTouchMoved count 2"); - - if(Count == 10) - { - TouchInfo* pTouchInfo = static_cast(pList->GetAt(0)); - - if( pTouchInfo == NULL ) - { - return; - } - Point firstPoint = pTouchInfo->position; - - pTouchInfo = static_cast(pList->GetAt(1)); - if( pTouchInfo == NULL ) - { - return; - } - Point secondPoint = pTouchInfo->position; - - if (__touchPoint1 == Point(-1,-1) || __touchPoint2 == Point(-1,-1)) - { - __touchPoint1 = firstPoint; - __touchPoint2 = secondPoint; - delete pList; - return; - } - - int currX1 = firstPoint.x; - int currY1 = firstPoint.y; - int currX2 = secondPoint.x; - int currY2 = secondPoint.y; - - double prevDist = findDistance(__touchPoint1.x,__touchPoint1.y,__touchPoint2.x,__touchPoint2.y); - double dist = findDistance(currX1, currY1, currX2, currY2); - __distanceMoved = prevDist - dist; + RelayoutControls(false); + return; +} - __touchPoint1 = firstPoint; - __touchPoint2 = secondPoint; - MoveUiControls(); - Count = 0; - } - } - Count++; - delete pList; - } +void +MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) +{ + AppLog("LMN::MainForm::OnTouchMoved entered"); +// __currentWordIndex = 0; + __isLongPressedDone = false; } void MainForm::MoveUiControls() { - __adressPanelPosition.y = __adressPanelPosition.y + __distanceMoved; - if(__pAddressbar == NULL) - { - return; - } - - if (__adressPanelPosition.y > 0) - { - __adressPanelPosition.y = 0; - __webControlPosition.y = __pAddressbar->GetHeight() - 12; - } - else if (__adressPanelPosition.y < (0-(__pAddressbar->GetHeight() - 12))) // -12 is for the progress label - { - __adressPanelPosition.y = 0-(__pAddressbar->GetHeight() - 12); - __webControlPosition.y = 0; - } - else - { - __webControlPosition.y = __adressPanelPosition.y + (__pAddressbar->GetHeight() - 12); - } - - AppLogDebug("__adressPanelPosition.y = %d, __webControlPosition.y = %d", __adressPanelPosition.y, __webControlPosition.y); - - __pAddressbar->SetBounds(0,__adressPanelPosition.y,__pAddressbar->GetWidth(),__pAddressbar->GetHeight()); - __pAddressbar->Invalidate(false); - - if (__pWebViewer != NULL) - { - if(__pFooterPanel->GetShowState() == true) - __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12); - else - __webControlHeight = GetClientAreaBounds().height - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12); - __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight)); - __pWebViewer->Invalidate(false); - } } void MainForm::OnTextValueChanged (const Tizen::Ui::Control &source) { - if (__pFindWordEditField != null) + if(&source == dynamic_cast(__pFooterUrlField) && __pFooterUrlField != null) + { + if(__pFooterUrlField->GetTextLength() == 0) + { + __pFooterUrlField->SetKeypadActionEnabled(false); + } + else + { + __pFooterUrlField->SetKeypadActionEnabled(true); + } + } + if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true) { __currentSearchStr = __pFindWordEditField->GetText(); + if (__currentSearchStr.GetLength() > 0) + { + __pFindWordCountLabel->SetShowState(true); + } + else + { +// __pFindWordCountLabel->SetShowState(false); + __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight()); + __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight()); + + } __pFindWordNext->SetEnabled(false); __pFindWordPrev->SetEnabled(false); __pFindWordNext->Invalidate(true); @@ -3604,6 +5402,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) { @@ -3612,7 +5429,8 @@ MainForm::OnTextValueChanged (const Tizen::Ui::Control &source) else { __currentSearchStr = L"aaaaaaaabbbbbbbccccccc"; - StartWordSearch(); + StartWordSearch(); + __currentSearchStr = L""; AppLogDebug("Enter something"); } } @@ -3634,14 +5452,14 @@ MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatu result r = E_SUCCESS; - if (__pWebViewer != null && __pMostVisitedListView != null) + if (__pMostVisitedListView != null) { return E_SUCCESS; } if (__pMostVisitedListView != null) { - RemoveControl(*__pMostVisitedListView); + RemoveControl(__pMostVisitedListView); } if(__pMostVisitedSites != null) { @@ -3650,17 +5468,23 @@ MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatu HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites); - __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12); + __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight(); + __webControlHeightF = GetClientAreaBoundsF().height - __pFooterPanel->GetHeightF(); __pMostVisitedListView = new(std::nothrow) ListView(); - if(__pFooterPanel->GetShowState() == false) + + int height = GetClientAreaBounds().height; + + if(__pFooterPanel->GetShowState() == true) { - r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight() , GetClientAreaBounds().width, GetClientAreaBounds().height),true,false); + height = height - __pFooterPanel->GetHeight(); } - else + if(__pAddressbar->GetShowState() == true) { - r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight() , GetClientAreaBounds().width, __webControlHeight),true,false); + height -= __pAddressbar->GetHeight(); } + r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false); + if (r != E_SUCCESS) { delete __pMostVisitedListView; @@ -3669,14 +5493,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); - AppLog("__pMostVisitedSitesPanel addcontrol %s",GetErrorMessage(r)); - if(__pFooterPanel->GetShowState() == false) - __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() + 14)); - else - __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14)); - + __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_VISITED_SITES")); + AddControl(__pMostVisitedListView); __pMostVisitedListView->UpdateList(); return E_SUCCESS; @@ -3736,8 +5554,476 @@ 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.NotifyOngoingActivity(request); + AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult())); + return; +} + +void +MainForm::SetForwardButtonEnabled(bool isEnabled) +{ + __pGoForwardBtn->SetEnabled(isEnabled); + __pGoForwardBtn->Invalidate(true); +} + +void +MainForm::SetBackButtonEnabled(bool isEnabled) +{ + __pGoBackBtn->SetEnabled(isEnabled); + __pGoBackBtn->Invalidate(true); +} + +void +MainForm::UpdateProgress(int percentage) +{ + __progressPercentage = percentage; + if (percentage == 0 || percentage == 100) + { + __isLoadingData = false; + if (percentage == 100) + { + __isLoadingCompleted = true; + __progressPercentage = 0; + } + else + { + __isLoadingCompleted = false; + } + } + else + { + __isLoadingData = true; + } + UpdateProgressBitmap(); +} + +int +MainForm::GetProgress(void) +{ + return __progressPercentage; +} + +void +MainForm::UpdateProgressBitmap(void) +{ + result r = E_SUCCESS; + if (__pProgressbarLabel == null) + return; + int w = __pProgressbarLabel->GetWidth(); + int h = __pProgressbarLabel->GetHeight(); + Canvas canvas; + int progressWidth = 0; + Bitmap* pRetBitmap = null; + + if (__progressPercentage == 0 || __progressPercentage == 100) + { + __pProgressbarLabel->SetShowState(false); + __pProgressbarLabel->Invalidate(false); + return; + } + else + { + __pProgressbarLabel->SetShowState(true); + __pProgressbarLabel->Invalidate(false); + } + + r = canvas.Construct(Rectangle(0, 0, w, h)); + + if (r != E_SUCCESS) + { + AppLogException("Canvas construction failed with %s", GetErrorMessage(r)); + return; + } + + canvas.Clear(); + Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG); + + if (pBgBmp != null) + { + pBgBmp->Scale(Dimension(w, h)); + canvas.DrawBitmap(Point(0,0), *pBgBmp); + delete pBgBmp; + } + + progressWidth = (double) (w) * __progressPercentage / 100; + AppLogDebug("progressWidth: %d", progressWidth); + Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR); + + if (pProgressBmp != null) + { + pProgressBmp->Scale(Dimension(progressWidth, h)); + canvas.DrawBitmap(Point(0,0), *pProgressBmp); + delete pProgressBmp; + } + + pRetBitmap = new (std::nothrow) Bitmap(); + + if (pRetBitmap == null) + { + AppLogException("Bitmap creation failed with %s", GetErrorMessage(r)); + return; + } + + pRetBitmap->Construct(canvas, canvas.GetBounds()); + + if (__pProgressbarLabel != null && pRetBitmap != null) + { + __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap); + __pProgressbarLabel->Invalidate(false); + } + + if (pRetBitmap != null) + { + delete pRetBitmap; + pRetBitmap = null; + } + return; +} + +void +MainForm::ReaderClicked() +{ + result r = E_SUCCESS; + ArrayList* pArgList = new(std::nothrow) ArrayList(); + if (pArgList != null) + { + r = pArgList->Construct(); + if (IsFailed(r)) + { + delete pArgList; + return; + } + + r = pArgList->Add(*new(std::nothrow) String(*__pReaderData)); + if (IsFailed(r)) + { + delete pArgList; + return; + } + + r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl())); + if (IsFailed(r)) + { + delete pArgList; + return; + } + + r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle)); + if (IsFailed(r)) + { + delete pArgList; + return; + } + } + + SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList); + return; + + +} + +void MainForm::SetAddressbarMode(AddressBarMode addMode) +{ + AppLogDebug("AddressBar::setAddressbarMode to %d",addMode); + + __currentAddMode = addMode; + + switch(addMode) + { + case ADDRESSBAR_MODE_INVALID: + { + // do nothing + } + break; + case ADDRESSBAR_MODE_READER: + { + __pStopBtn->SetShowState(false); + __pRefreshBtn->SetShowState(false); + __pClearBtn->SetShowState(false); + __pReaderBtn->SetShowState(false); + } + break; + case ADDRESSBAR_MODE_LOADING: + { + __pRefreshBtn->SetShowState(false); + __pStopBtn->SetShowState(true); + __pClearBtn->SetShowState(false); + __pReaderBtn->SetShowState(false); + } + break; + case ADDRESSBAR_MODE_LOADING_COMPLETE: + { +// SetUrl(__pAddressbar->GetUrl()); + + __pRefreshBtn->SetShowState(true); + __pStopBtn->SetShowState(false); + __pClearBtn->SetShowState(false); + __pReaderBtn->SetShowState(false); + } + break; + case ADDRESSBAR_MODE_EDIT: + { + __pRefreshBtn->SetShowState(false); + __pStopBtn->SetShowState(false); + __pReaderBtn->SetShowState(false); + __pClearBtn->SetShowState(true); + } + break; + } + + Invalidate(true); + + OnAddressBarModeChanged(); +} + +AddressBarMode MainForm::GetAddressbarMode(void) +{ + return __currentAddMode; +} + +void MainForm::SetUrl(const String& url) +{ + __displayUrl = url; + if(__displayUrl.GetLength() > 2048) + __displayUrl.SubString(0,2048,__displayUrl); + + if (__pFooterUrlField != NULL) + { + String removedHttpUrl = RemoveHttpTextFromDisplayURL(); + if (removedHttpUrl.IsEmpty() == false) + { + __pFooterUrlField->SetText(removedHttpUrl); + if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false) + __pAddressbar->SetUrl(__displayUrl); + } + else + { + __pFooterUrlField->SetText(__displayUrl); + if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false) + __pAddressbar->SetUrl(__displayUrl); + } + if(__pFooterUrlField) + __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength()); + __pFooterUrlField->Invalidate(false); + if(__pAddressbar != NULL && __pAddressbar->HasFocus()) + __pAddressbar->Invalidate(true); +// __pFooterUrlField->SetCursorPosition(0); + } +} + +String +MainForm::RemoveHttpTextFromDisplayURL(void) +{ + AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer()); + int index = -1; +// bool isHttpText = __displayUrl.Contains(L"http://"); + String updatedDisplayUrl; + updatedDisplayUrl.Clear(); + if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0) + { + __displayUrl.SubString(7,updatedDisplayUrl); + } + else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0) + { + __displayUrl.SubString(8,updatedDisplayUrl); + } + return updatedDisplayUrl; +} + +void MainForm::OnSharePopupControlStarted(void) +{ + __pWebViewer->AddTouchEventListener(*this); +} + +void +MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs) +{ + if (requestId == UPDATE_MAINFORM_FOOTER_ON_WINDOWCLOSED) + { + AppLog("OnWebWindowCloseRequested mainform test 1 OnUserEventReceivedN"); + InitFooter(); + } + else if (requestId == BACK_GROUND_APP_EVENT) + { + if(__pWebViewer != null) + { + __pWebViewer->Pause(); + } + if(__pImageMenu) + { + __pImageMenu->SetShowState(false); + } + if(__pAddressbar != null) + { + __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL); + } + } + else if(requestId == FORE_GROUND_APP_EVENT) + { + if(__pWebViewer != null) + { + __pWebViewer->Resume(); + } + if(__pAddressbar != null) + { + __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL); + } + } +} + +void +MainForm::AddressBarCancelledClicked(const Addressbar& addBar) +{ + AppLog("XYZ::MainForm::AddressBarCancelledClicked"); + result r = E_SUCCESS; + + if (__pAddressbar) + __pAddressbar->SetShowState(false); + + AppLog("akjshdasd 5"); + __pFooterPanel->SetShowState(true); + + if(__pWebViewer) + __pWebViewer->SetFocus(); + else if(__pMostVisitedListView) + __pMostVisitedListView->SetFocus(); + else if(__pMultiWindowButton) + __pMultiWindowButton->SetFocus(); + else if(__pMoreButton) + __pMoreButton->SetFocus(); + + __pAddressbar->SetShowState(false); + + RelayoutControls(false); +} + +void +MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source) +{ + AppLog("MainForm::OnFormMenuRequested called"); + InitOptionMenu(); + if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer && __pWebViewer->GetShowState() == true) + { + int bookmarkCount=0; + bool exist = false; + String url=L""; + url=__pWindowInfo->pageUrl; + AppLog("MainForm::OnFormMenuRequested url %ls",url.GetPointer()); + result r = E_SUCCESS; + Bitmap* pBitmap = null; + String lastChar = L""; +// if(url.SubString(url.GetLength()-1,lastChar)); +// if(lastChar == L"/") +// { +// bool exist1 = false; +// bool exist2 = false; +// r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist1); +// url.SubString(0,url.GetLength() - 1,url); +// r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist2); +// exist = exist1 | exist2; +// } +// else +// { + r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist); + if (IsFailed(r)) + { + AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed"); + return; + } +// } + if ( exist == true) + { + pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP); + } + else + { + pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP); + } + AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3"); + + if (__pOptionMenu->GetItemCount() == 9) + { + r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap); + } + else + { + r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap); + } + + if (IsFailed(r)) + { + AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r)); + delete pBitmap; + return ; + } + AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4"); + if (__pOptionMenu->GetItemCount() != 9) + { + __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED); + __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED); +// __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED); + __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED); + __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED); + __pOptionMenu->SetMaxVisibleItemsCount(6); + } + if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE) + { + AppLog(" Orientation landscape"); + __pOptionMenu->SetMaxVisibleItemsCount(5); + } + else + { + AppLog(" Orientation potrait"); + __pOptionMenu->SetMaxVisibleItemsCount(6); + } + + AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5"); + delete pBitmap; + } + AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end"); + if(__pAddressbar) + __pAddressbar->SetShowState(false); + SetFocus(); + __pFooterPanel->SetShowState(true); + result r = __pOptionMenu->SetShowState(true); + AppLog("ajsghd %s",GetErrorMessage(r)); + RelayoutControls(false); + __pOptionMenu->Invalidate(true); + __pOptionMenu->Show(); + +}