Fixed Nabi Issues
[apps/osp/Internet.git] / src / IntMultipleWindowForm.cpp
index 133968c..b95ae84 100644 (file)
@@ -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
 //
@@ -29,6 +29,7 @@
 #include "IntMultipleWindowForm.h"
 #include "IntMultipleWindowPresentationModel.h"
 #include "IntSceneRegister.h"
+#include "IntSettingPresentationModel.h"
 
 using namespace Tizen::App;
 using namespace Tizen::Base;
@@ -38,12 +39,17 @@ using namespace Tizen::Ui;
 using namespace Tizen::Ui::Controls;
 using namespace Tizen::Ui::Scenes;
 
+static const int W_ICON_IMAGE_WIDTH = 72;
 
 MultipleWindowForm::MultipleWindowForm(void)
 : __pList(null)
 , __pListIconImage(null)
 , __pListDeleteImage(null)
+,__pConfirmationPopup(null)
 {
+       __startPosition.x = -1;
+       __startPosition.y = -1;
+       __fontSize = 44;
 }
 
 MultipleWindowForm::~MultipleWindowForm(void)
@@ -83,6 +89,7 @@ MultipleWindowForm::OnInitializing(void)
        FooterItem closeButton;
        FooterItem newButton;
 
+       __fontSize = CommonUtil::GetFontSize();
        SceneManager* pSceneManager = SceneManager::GetInstance();
 
        if (pSceneManager == null)
@@ -97,7 +104,7 @@ MultipleWindowForm::OnInitializing(void)
                return E_FAILURE;
        }
 
-       SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
+//     SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
 
        r = pSceneManager->AddSceneEventListener(IDSCN_MULTIPLE_WINDOW, *this);
 
@@ -119,15 +126,16 @@ MultipleWindowForm::OnInitializing(void)
        {
                __pList->SetItemProvider(*this);
                __pList->AddListViewItemEventListener(*this);
+
        }
 
        AddOrientationEventListener(*this);
 //     r = pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
        r = closeButton.Construct(IDA_BUTTON_CLOSEALL);
-       r = closeButton.SetText(CommonUtil::GetString(L"IDS_BR_CLOSE_ALL"));
+       r = closeButton.SetText(CommonUtil::GetString(L"IDS_BR_OPT_CLOSE_ALL"));
        r = pFooter->AddItem(closeButton);
        r = newButton.Construct(IDA_BUTTON_NEW);
-       r = newButton.SetText(CommonUtil::GetString(L"IDS_BR_SK1_NEW_WINDOW"));
+       r = newButton.SetText(CommonUtil::GetString(L"IDS_BR_OPT_NEW_WINDOW"));
        r = pFooter->AddItem(newButton);
 
        return r;
@@ -192,13 +200,13 @@ MultipleWindowForm::OnActionPerformed(const Control& source, int actionId)
                return;
        }
 
-       String closeWarning = CommonUtil::GetString(L"IDS_BR_CLOSE_ALL_WINDOWS_Q");
+       String closeWarning = CommonUtil::GetString(L"IDS_BR_POP_CLOSE_ALL_OPENED_WINDOWS_AND_GO_TO_THE_HOMEPAGE");
 
        switch (actionId)
        {
        case IDA_BUTTON_NEW:
        {
-               WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
+               WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
 
                if (pNewWindowInfo == null)
                {
@@ -255,19 +263,31 @@ MultipleWindowForm::OnActionPerformed(const Control& source, int actionId)
 
        case IDA_BUTTON_CLOSEALL:
        {
-               __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
-               __pConfirmationPopup->Initialize();
-               __pConfirmationPopup->RemoveActionListener(*this);
-               __pConfirmationPopup->AddActionListener(*this);
-               __pConfirmationPopup->setMessage(closeWarning);
-               __pConfirmationPopup->Show();
+               if(__pConfirmationPopup)
+               {
+                       delete __pConfirmationPopup;
+                       __pConfirmationPopup = null;
+               }
+               if (!__pConfirmationPopup)
+               {
+                       __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
+                       __pConfirmationPopup->Initialize();
 
+                       __pConfirmationPopup->RemoveActionListener(*this);
+                       __pConfirmationPopup->AddActionListener(*this);
+                       __pConfirmationPopup->setMessage(closeWarning);
+                       __pConfirmationPopup->Show();
+               }
        }
        break;
        case IDA_CONFIRMATION_NO:
        {
                __pConfirmationPopup->SetShowState(false);
                __pConfirmationPopup->Show();
+
+               delete __pConfirmationPopup;
+               __pConfirmationPopup = null;
+
        }
        break;
        case IDA_CONFIRMATION_YES:
@@ -285,12 +305,25 @@ MultipleWindowForm::OnActionPerformed(const Control& source, int actionId)
                        SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
                }
                pAllWindowList->RemoveAll(true);
-               WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
+               String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
+               if (homePage == (L"IDS_BR_BODY_MOST_VISITED_SITES") || homePage == (L"IDS_BR_BODY_BLANK_PAGE"))
+               {
+                       homePage = L"";
+               }
+               else if (homePage == CommonUtil::GetString(L"IDS_BR_BODY_USER_HOMEPAGE"))
+               {
+                       AppLog("InternetApp::OnAppInitialized homaepage = userhomepage");
+                       homePage = SettingPresentationModel::GetInstance()->GetFavoriteUrl();
+                       AppLog("InternetApp::OnAppInitialized fav URL = %ls ",homePage.GetPointer());
+               }
+
+               WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(homePage);
 
                if (pNewWindowInfo == null)
                {
                        return;
                }
+               pNewWindowInfo->isAppcontrolTriggered = true;
                result r = E_SUCCESS;
                SceneManager* pSceneManager = SceneManager::GetInstance();
                if (pSceneManager == NULL)
@@ -320,6 +353,10 @@ MultipleWindowForm::OnActionPerformed(const Control& source, int actionId)
                }
                __pConfirmationPopup->SetShowState(false);
                __pConfirmationPopup->Show();
+
+               delete __pConfirmationPopup;
+               __pConfirmationPopup = null;
+
        }
        break;
        default:
@@ -488,7 +525,7 @@ MultipleWindowForm::CreateItem(int index, int itemWidth)
        String pageTitle(L"");
        String pageURL(L"");
        result r = E_SUCCESS;
-       int width = 72;
+       int width = W_ICON_IMAGE_WIDTH;
 
        AppResource* pAppResource = Application::GetInstance()->GetAppResource();
        ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
@@ -509,12 +546,18 @@ MultipleWindowForm::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 +">";
        }
 
+       if (pageTitle.GetLength() == 0)
+       {
+               String nourl;
+               pAppResource->GetString(L"IDS_BR_BODY_BLANK_PAGE", pageTitle);
+       }
+
        Rectangle screenBounds = GetBounds();
-       r = pItem->Construct(Dimension(itemWidth, 128), style);
+       r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
        if (IsFailed(r))
        {
                return NULL;
@@ -542,17 +585,20 @@ MultipleWindowForm::CreateItem(int index, int itemWidth)
 
                __pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
        }
-       AppLog("deleteimg %d %d",__pListDeleteImage->GetWidth(),__pListDeleteImage->GetHeight());
 
-       listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,width, 72);
-       pagetTitleRect.SetBounds(listImageRect.x + width + 16,10, screenBounds.width - 2 * width - 64, 60);
+
+       listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2,width, 72  );
+       pagetTitleRect.SetBounds(listImageRect.x + width + 16,10, screenBounds.width - 2 * width - 24 - 64, 72 + (__fontSize - 44));
        pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * width - 120, 48);
-       deleteImageRect.SetBounds(screenBounds.width - __pListDeleteImage->GetWidth() - 24, (128 - __pListDeleteImage->GetHeight() - 8)/2, __pListDeleteImage->GetWidth() + 8, __pListDeleteImage->GetHeight() + 8);
+       if(__pListDeleteImage != null)
+       {
+               deleteImageRect.SetBounds(screenBounds.width - __pListDeleteImage->GetWidth() - 24, (128 + (__fontSize - 44) - __pListDeleteImage->GetHeight() - 8)/2, __pListDeleteImage->GetWidth() + 8, __pListDeleteImage->GetHeight() + 8);
+       }
        pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *__pListIconImage, null, null);
 
        if (pageTitle.CompareTo(L"") != 0)
        {
-               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);
        }
 
        if (pageURL.CompareTo(L"") != 0)