Fixed Nabi Issues
[apps/osp/Internet.git] / src / IntMainForm.cpp
index ad12dd8..6426ba5 100644 (file)
@@ -137,6 +137,7 @@ static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
 MainForm::MainForm(void)
 {
        __isLongPressedDone = false;
+       __pHistory = null;
        __pAddressbar = null;
        //      __pMostVisitedSitesPanel = null;
        __pMostVisitedListView = null;
@@ -205,6 +206,13 @@ MainForm::~MainForm(void)
        {
                __pAddressbar->SetAddressbarEventListener(null);
        }
+
+       if(__pHistory != null)
+       {
+               delete __pHistory;
+               __pHistory = null;
+       }
+
        if (__pReaderData != null)
        {
                delete __pReaderData;
@@ -330,7 +338,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();
@@ -377,15 +385,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());
@@ -467,7 +475,7 @@ MainForm::InitWebControl()
        }
        else
        {
-               r = AddControl(*__pWebViewer);
+               r = AddControl(__pWebViewer);
 
                if (IsFailed(r))
                {
@@ -941,7 +949,7 @@ MainForm::InitFindWordPanel(void)
                AppLogException("There is some problem in the xml file. Please check.");
                return E_FAILURE;
        }
-       AddControl(*__pFindWordControl);
+       AddControl(__pFindWordControl);
        __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
        SetControlAlwaysOnTop(*__pFindWordControl,true);
        __pFindWordControl->SetShowState(false);
@@ -1811,7 +1819,7 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
                {
                        //__pArticleReaderPanel->SetShowState(false);
                        //__pArticleReaderPanel->Show();
-                       RemoveControl(*__pBlankPanel);
+                       RemoveControl(__pBlankPanel);
                        //RemoveControl(*__pArticleReaderPanel);
                        __pArticleReaderPanel = null;
                        __pBlankPanel = null;
@@ -2345,6 +2353,8 @@ MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
        InitFooter();
        InitAddressbar();
 
+       __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
+
        // hiding the address bar
        //      __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
        __pAddressbar->SetShowState(false);
@@ -2377,6 +2387,13 @@ MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
        {
                InitMostVisitedSitesView(GetOrientationStatus());
        }
+       else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
+       {
+               if(__pMostVisitedListView != null)
+               {
+                       __pMostVisitedListView->SetShowState(false);
+               }
+       }
 
        if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
        {
@@ -2693,22 +2710,23 @@ MainForm::OnLoadingCompleted(void)
        bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
        if (isPrivateBrowsing == false)
        {
-               History* pHistory = new(std::nothrow) History;
+               if(__pHistory != null)
+               {
+                       delete __pHistory;
+                       __pHistory = null;
+               }
 
+               __pHistory = new(std::nothrow) History;
                HistoryPresentationModel::GetCurrentDateTime(date);
-               if(__pWindowInfo)
+               if (__pWindowInfo)
                {
-                       pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
+                       __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
                        AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
 
-                       pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
+                       __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
                        AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
                }
-               pHistory->SetVisitedTime(date);
-               /*String id = "";
-               if(__pWindowInfo)
-                       id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
-               pHistory->SetFaviconId(id);*/
+               __pHistory->SetVisitedTime(date);
 
                if (__pWebViewer != null)
                {
@@ -2718,7 +2736,7 @@ MainForm::OnLoadingCompleted(void)
                        if (pTempBitmap != null)
                        {
                                AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
-                               pHistory->SetFavIconBitmap(*pTempBitmap);
+                               __pHistory->SetFavIconBitmap(*pTempBitmap);
                        }
 
                        AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
@@ -2730,17 +2748,17 @@ MainForm::OnLoadingCompleted(void)
                {
                        pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
                        pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
-                       pHistory->SetThumbnail(pBitmap);
+                       __pHistory->SetThumbnail(pBitmap);
                }
                Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
-               if(pFavIcon)
+               if (pFavIcon)
                {
-                       pHistory->SetFavIconBitmap(*pFavIcon);
+                       __pHistory->SetFavIconBitmap(*pFavIcon);
                        delete pFavIcon;
                }
 
-               HistoryPresentationModel::GetInstance()->SaveTempHistory(*pHistory);
-               delete pHistory;
+               HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
+               //delete pHistory;
        }
        else
        {
@@ -2768,12 +2786,11 @@ MainForm::OnEstimatedProgress(int progress)
 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
 {
        AppLog("MainForm::OnFaviconReceived");
-       Bitmap* pFavIconBitmap = __pWebViewer->GetFaviconN();
-
-       if (pFavIconBitmap != null)
+       if (__pWebViewer != null && __pHistory != null)
        {
-               pFavIconBitmap->GetWidth();
-               pFavIconBitmap->GetHeight();
+               Bitmap* pFavIconBitmap = __pWebViewer->GetFaviconN();
+
+               HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *(__pWebViewer->GetFaviconN()));
        }
 }
 
@@ -3115,7 +3132,7 @@ MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
 
        __pAddressbar->SetShowState(false);
 
-       RelayoutControls(false);
+       RelayoutControls(false,false);
 
 }
 
@@ -3174,7 +3191,7 @@ MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
        {
                __pFooterUrlField->SetFocusable(true);
        }
-       RelayoutControls(false);
+       RelayoutControls(false,footerState);
 }
 
 void
@@ -3492,7 +3509,7 @@ MainForm::OnWebWindowCreateRequested(void)
 }
 
 void
-MainForm::RelayoutControls(bool showAddressbar)
+MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
 {
        __webControlPosition.y = 0;
        __webControlHeight = GetClientAreaBounds().height;
@@ -3512,9 +3529,10 @@ MainForm::RelayoutControls(bool showAddressbar)
                __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
        }
 
-       if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true)
+       if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
        {
                __webControlHeight -= __pFooterPanel->GetHeight();
+
                __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
        }
        if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
@@ -4437,7 +4455,7 @@ MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatu
 
        if (__pMostVisitedListView != null)
        {
-               RemoveControl(*__pMostVisitedListView);
+               RemoveControl(__pMostVisitedListView);
        }
        if(__pMostVisitedSites != null)
        {
@@ -4471,7 +4489,7 @@ 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);
+       AddControl(__pMostVisitedListView);
        __pMostVisitedListView->UpdateList();
 
        return E_SUCCESS;