Fixed Nabi Issues N_SE-56966,56735
[apps/osp/Internet.git] / src / IntMainForm.cpp
index c8b8d66..0005ffc 100644 (file)
@@ -819,6 +819,7 @@ result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
 {
        result r = E_SUCCESS;
        ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
+       String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
 
        AppLog("MainForm::InitImageContextMenu clicked on image");
        if (__pImageMenu != null)
@@ -835,8 +836,12 @@ result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
        r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
        TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
 
+
        r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
-       r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
+       AppLog("srcUrl %ls __pWebViewer->GetUrl() %ls",srcUrl.GetPointer(),__pWebViewer->GetUrl().GetPointer());
+
+       if(__pWebViewer && srcUrl.Equals(__pWebViewer->GetUrl(),false) == false)
+               r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
        r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
        r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
        __pImageMenu->SetMaxVisibleItemsCount(4);
@@ -985,9 +990,15 @@ MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPa
        }
 //     FloatPoint q(0.0,0.0);
 //             __pWebViewer->GetBlockRange(p,q);
+       if(p.y < 0)
+               p.y =0;
        if(p.y < 150)
        {
-               p.y = p.y + 50;
+               p.y = p.y + 100;
+               if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE )
+               {
+                       p.y = p.y - 50;
+               }
                direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
        }
        else if(__pWebViewer != null && (p.y > (__pWebViewer->GetHeight() + __pWebViewer->GetY())))
@@ -1031,7 +1042,7 @@ MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPa
                        }
                }
        }
-       if(clipboardAvailable == false && onlyPasteOption == true)
+       if(clipboardAvailable == false && (onlyPasteOption == true ||  __pHitElementResult->GetAttributeValue("type").Equals(L"password",false) == true))
        {
                return E_FAILURE;
        }
@@ -1039,10 +1050,6 @@ MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPa
        r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
        TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
 
-
-
-
-
        if(onlyPasteOption == false && __pHitElementResult->GetAttributeValue("type").Equals(L"password",false) == false)
        {
                r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
@@ -1127,7 +1134,7 @@ MainForm::InitFindWordPanel(void)
                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());
+               Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.#.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
                if (pBitmap != null)
                {
                        AppLogDebug("InitFindWordPanel: Coming here");
@@ -1147,7 +1154,7 @@ MainForm::InitFindWordPanel(void)
                        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());
+                       Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.#.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
                        if (pBitmap != null)
                        {
                                AppLogDebug("InitFindWordPanel: Coming here");
@@ -1219,6 +1226,7 @@ MainForm::InitFindWordPanel(void)
                AppLogException("There is some problem in the xml file. Please check.");
                return E_FAILURE;
        }
+       __pFindWordCountLabel->SetText(L"0/0");
 
        __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
        if (__pFindWordCountLabelRightToLeft == null)
@@ -1226,6 +1234,7 @@ MainForm::InitFindWordPanel(void)
                AppLogException("There is some problem in the xml file. Please check.");
                return E_FAILURE;
        }
+       __pFindWordCountLabelRightToLeft->SetText(L"0/0");
 
        __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
        if (__pFindWordEditField == null)
@@ -1633,12 +1642,10 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
                if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
                {
                        __pFindWordEditField->SetFocus();
-//                     __pFindWordCountLabel->SetShowState(false);
                }
                else
                {
                        __pFindWordEditFieldRightToLeft->SetFocus();
-                       __pFindWordCountLabelRightToLeft->SetShowState(false);
                }
        }
        break;
@@ -2190,8 +2197,22 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
                {
                        String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
                        AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
-                       LoadUrl(srcUrl);
 
+                       Uri currentUri;
+                       currentUri.SetUri(__pWebViewer->GetUrl());
+
+                       String newUrl;
+                       Uri newUri;
+                       newUri.SetUri(srcUrl);
+                       AppLog("newuri gethost %ls",newUri.GetHost().GetPointer());
+                       if(newUri.GetHost().GetLength() == 0)
+                       {
+                               newUrl = currentUri.GetHost();
+                               newUrl.Append(srcUrl);
+                               srcUrl = newUrl;
+                       }
+
+                       LoadUrl(srcUrl);
                }
        }
        break;
@@ -2886,7 +2907,7 @@ MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
        {
                InitMostVisitedSitesView(GetOrientationStatus());
        }
-       else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
+       else
        {
                if(__pMostVisitedListView != null)
                {
@@ -2962,7 +2983,10 @@ MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
        RelayoutControls(false);
        AppLog("ABC: OnSceneActivatedN started exit");
        if(__pWebViewer)
+       {
                AppLog("WebControl's width height %d %d,",__pWebViewer->GetWidth(),__pWebViewer->GetHeight());
+               __pWebViewer->Resume();
+       }
 
 }
 
@@ -3011,6 +3035,10 @@ MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
        delete pWebCanvas;
        if(__pAddressbar)
                __pAddressbar->SetShowState(false);
+       if(__pWebViewer)
+       {
+               __pWebViewer->Pause();
+       }
        AppLog("Coming here");
 }
 
@@ -3416,8 +3444,12 @@ MainForm::OnUrlSubmitted(Addressbar& addBar)
        String url = addBar.GetUrl();
        AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
 
+
        if(__pFooterUrlField)
+       {
+               AppLog("Position:: %d, %ls",__pFooterUrlField->GetTextLength(),__pFooterUrlField->GetText().GetPointer());
                __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
+       }
        AddressBarCancelledClicked(*__pAddressbar);
        LoadUrl(url);
 }
@@ -3463,6 +3495,8 @@ MainForm::LoadUrl(String& url)
        ret = firstRegex.Match(url, false); // This returns true value
        flag = secondRegex.Match(url, false);  // Checks whether URL typed is of type  abc.com (i.e without protocol in front of it)
 
+
+
        if (ret == true && __pWebViewer != null)
        {
                SetUrl(url);
@@ -3538,7 +3572,8 @@ MainForm::OnFocusGained(const Tizen::Ui::Control& source)
                __pFindWordNext->SetEnabled(false);
                __pFindWordPrev->SetEnabled(false);
 
-               __pWebViewer->SearchTextAllAsync(L"",true);
+               if(__pWebViewer)
+                       __pWebViewer->SearchTextAllAsync(L"",true);
                __pFindWordControl->SetShowState(false);
        }
        RelayoutControls(false);
@@ -3863,6 +3898,7 @@ MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
 void
 MainForm::UpdateFavicon(void)
 {
+       AppLog("MainForm::UpdateFavicon called");
        bool urlImageType = false;
        String *tempPath = null;
        if(__pWebViewer)
@@ -3900,6 +3936,7 @@ MainForm::UpdateFavicon(void)
 
                        if (pBitmap != null)
                        {
+                               AppLog("__pWindowInfo->pFavicon updating favicon");
                                if (__pWindowInfo->pFavicon != NULL)
                                {
                                        __pWindowInfo->pFavicon = null;
@@ -4258,7 +4295,8 @@ MainForm::OnWebWindowCloseRequested(Tizen::Web::Controls::Web& source)
                                        return;
                                }
                        }
-                       r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
+                       if(pNewWindowInfo)
+                               r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
 
                        break;
                }
@@ -4305,6 +4343,9 @@ MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
                __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 )
@@ -4312,11 +4353,12 @@ MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
                }
                else
                {
-                       __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight );
+                       __pWebViewer->SetBounds(CoordinateSystem::AlignToDevice(FloatRectangle(0.0f, __webControlPositionF.y, GetClientAreaBoundsF().width, __webControlHeightF)));
                        AppLog("xyz:: MainForm::RelayoutControls called __webControlHeight %d",__webControlHeight);
                        __pWebViewer->Invalidate(false);
                }
        }
+
        if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
        {
                __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
@@ -4497,7 +4539,8 @@ void MainForm::OnTextFound(int totalCount, int currentOrdinal)
        {
                AppLog("Word not found");
                //Show error notification to user
-               __pFindWordNext->SetEnabled(false);
+               if(__pFindWordNext)
+                       __pFindWordNext->SetEnabled(false);
                if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
                {
                        __pFindWordCountLabel->SetText(L"0/0");
@@ -4508,7 +4551,8 @@ void MainForm::OnTextFound(int totalCount, int currentOrdinal)
                        __pFindWordCountLabelRightToLeft->SetText(L"0/0");
                        __pFindWordCountLabelRightToLeft->Invalidate(false);
                }
-               __pFindWordNext->Invalidate(false);
+               if(__pFindWordNext)
+                       __pFindWordNext->Invalidate(false);
                __pFindWordPrev->Invalidate(false);
 
                return;
@@ -4516,11 +4560,13 @@ void MainForm::OnTextFound(int totalCount, int currentOrdinal)
 
        if (totalCount == 1 || totalCount == currentOrdinal)
        {
-               __pFindWordNext->SetEnabled(false);
+               if(__pFindWordNext)
+                       __pFindWordNext->SetEnabled(false);
        }
        else
        {
-               __pFindWordNext->SetEnabled(true);
+               if(__pFindWordNext)
+                       __pFindWordNext->SetEnabled(true);
        }
 
        String countStr = L"";
@@ -5454,6 +5500,7 @@ MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatu
 
        if (__pMostVisitedListView != null)
        {
+               __pMostVisitedListView->SetShowState(true);
                return E_SUCCESS;
        }
 
@@ -5579,8 +5626,7 @@ MainForm::ShowIndicatorNotification(const String& messageText, const String& con
        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";
@@ -5589,7 +5635,7 @@ MainForm::ShowIndicatorNotification(const String& messageText, const String& con
 
        Tizen::Shell::NotificationManager notiMgr;
        notiMgr.Construct();
-       notiMgr.NotifyOngoingActivity(request);
+       notiMgr.Notify(request);
        AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));
        return;
 }
@@ -5838,7 +5884,10 @@ void MainForm::SetUrl(const String& url)
                                __pAddressbar->SetUrl(__displayUrl);
                }
                if(__pFooterUrlField)
+               {
+                       AppLog("Position:: %d, %ls",__pFooterUrlField->GetTextLength(),__pFooterUrlField->GetText().GetPointer());
                        __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
+               }
                __pFooterUrlField->Invalidate(false);
                if(__pAddressbar != NULL && __pAddressbar->HasFocus())
                        __pAddressbar->Invalidate(true);