Fixed Nabi Issues: 53721,53372,53761,53768
[apps/osp/Internet.git] / src / IntEditBookmarkListForm.cpp
index 96a9cf5..ff69d4d 100644 (file)
@@ -2,7 +2,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
 //
@@ -44,7 +44,8 @@ using namespace Tizen::Ui::Scenes;
 
 static const wchar_t* IDB_ICON_FOLDER_OPEN = L"I01_icon_folder_open.png";
 static const wchar_t* IDB_ITEM = L"edit_item.png";
-static const wchar_t* IDB_RIGHT_ARROW = L"I01_right_arrow.png";
+static const wchar_t* IDB_RIGHT_ARROW = L"00_circle_bg_ef.png";
+static const wchar_t* IDB_RIGHT_ARROW_PRESS = L"00_circle_bg_ef_press.png";
 
 
 const int EditBookmarkListForm::IDA_BUTTON_CHECKED = 101;
@@ -73,6 +74,7 @@ EditBookmarkListForm::EditBookmarkListForm(void)
        __pCheckButton = null;
        __pConfirmationPopup = null;
        __pSelectedList = null;
+       __fontSize = 44;
 }
 
 EditBookmarkListForm::~EditBookmarkListForm(void)
@@ -102,7 +104,7 @@ EditBookmarkListForm::OnInitializing(void)
        result r = E_SUCCESS;
 
        Rectangle rc = GetClientAreaBounds();
-       String selected = CommonUtil::GetString(L"IDS_COM_OPT_SELECTED");
+       String selected = CommonUtil::GetString(L"IDS_BR_BODY_PD_ITEM_SELECTED");
 
        // Setup back event listener
        SetFormBackEventListener(this);
@@ -115,6 +117,7 @@ EditBookmarkListForm::OnInitializing(void)
                pSceneManager->AddSceneEventListener(IDSCN_EDIT_BOOKMARK_LIST, *this);
        }
 
+       __fontSize = CommonUtil::GetFontSize();
        Header* pHeader = GetHeader();
 
        if (pHeader == NULL)
@@ -162,7 +165,8 @@ EditBookmarkListForm::OnInitializing(void)
        }
 
 //     __pInfoLabel->SetBounds(Rectangle(0,0,rc.width, 48));
-       selected.Append(L"(0)");
+       //selected.Append(L"(0)");
+       selected.Format(25, selected.GetPointer() , 0);
        __pInfoLabel->SetText(selected);
 
        __pInfoLabel->SetTextConfig(32,LABEL_TEXT_STYLE_BOLD);
@@ -189,6 +193,33 @@ EditBookmarkListForm::OnActionPerformed(const Tizen::Ui::Control& source, int ac
        switch (actionId)
        {
        case IDA_DELETEITEM_CLICKED:
+               if(__pConfirmationPopup)
+               {
+                       delete __pConfirmationPopup;
+                       __pConfirmationPopup = null;
+               }
+               if (!__pConfirmationPopup)
+               {
+                       String closeWarning = CommonUtil::GetString(L"IDS_BR_SK3_DELETE");
+                       __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
+                       __pConfirmationPopup->Initialize();
+
+                       __pConfirmationPopup->RemoveActionListener(*this);
+                       __pConfirmationPopup->AddActionListener(*this);
+                       __pConfirmationPopup->setMessage(closeWarning);
+                       __pConfirmationPopup->Show();
+               }
+               break;
+       case IDA_BUTTON_NO:
+               if(__pConfirmationPopup)
+               {
+                       __pConfirmationPopup->SetShowState(false);
+                       __pConfirmationPopup->Show();
+                       delete __pConfirmationPopup;
+                       __pConfirmationPopup = null;
+               }
+               break;
+       case IDA_BUTTON_YES:
        {
                String labelString;
                int count = 0;
@@ -260,9 +291,12 @@ EditBookmarkListForm::OnActionPerformed(const Tizen::Ui::Control& source, int ac
                GetFooter()->Invalidate(true);
                // removing all the element from selected list
                __pSelectedList->RemoveAll(false);
-               labelString.Append(CommonUtil::GetString(L"IDS_COM_OPT_SELECTED"));
+
+               labelString.Format(25, CommonUtil::GetString(L"IDS_BR_BODY_PD_ITEM_SELECTED").GetPointer() , 0);
+
+               /*labelString.Append(CommonUtil::GetString(L"IDS_BR_BODY_PD_ITEM_SELECTED"));
                labelString.Append(L"\x200E"); // LEFT-TO-RIGHT MARK
-               labelString.Append(L"(0)");
+               labelString.Append(L"(0)");*/
 
                if (__pInfoPanel != null)
                {
@@ -276,7 +310,11 @@ EditBookmarkListForm::OnActionPerformed(const Tizen::Ui::Control& source, int ac
                pNotification->SetText(notification);
                pNotification->ShowNotification();
 
-
+               if(__pConfirmationPopup)
+               {
+                       delete __pConfirmationPopup;
+                       __pConfirmationPopup = null;
+               }
                if( __pListview->GetItemCount() == 0)
                {
                        __pTimer->Start(1000);
@@ -313,11 +351,15 @@ EditBookmarkListForm::OnActionPerformed(const Tizen::Ui::Control& source, int ac
                GetFooter()->SetItemEnabled(0,true);
                GetFooter()->Invalidate(true);
 
-               labelString.Append(CommonUtil::GetString(L"IDS_COM_OPT_SELECTED"));
-               labelString.Append(L"\x200E"); // LEFT-TO-RIGHT MARK
-               labelString.Append(L"(");
-               labelString.Append(__pListview->GetItemCount());
-               labelString.Append(L")");
+               if(__pListview->GetItemCount() >1)
+               {
+                       labelString.Format(25, CommonUtil::GetString(L"IDS_BR_POP_PD_ITEMS_SELECTED").GetPointer() , __pListview->GetItemCount());
+               }
+               else
+               {
+                       labelString.Format(25, CommonUtil::GetString(L"IDS_BR_BODY_PD_ITEM_SELECTED").GetPointer() , __pListview->GetItemCount());
+               }
+
                __selectedItemCount = 0;
 
                __pInfoLabel->SetText(labelString);
@@ -359,9 +401,12 @@ EditBookmarkListForm::OnActionPerformed(const Tizen::Ui::Control& source, int ac
                        __pListview->SetItemChecked(count,false);
                }
 
-               labelString.Append(CommonUtil::GetString(L"IDS_COM_OPT_SELECTED"));
+               /*labelString.Append(CommonUtil::GetString(L"IDS_BR_BODY_PD_ITEM_SELECTED"));
                labelString.Append(L"\x200E"); // LEFT-TO-RIGHT MARK
-               labelString.Append(L"(0)");
+               labelString.Append(L"(0)");*/
+
+               labelString.Format(25, CommonUtil::GetString(L"IDS_BR_BODY_PD_ITEM_SELECTED").GetPointer() , 0);
+
                __pInfoLabel->SetText(labelString);
                __pInfoPanel->Draw();
                __pInfoPanel->Show();
@@ -410,32 +455,31 @@ EditBookmarkListForm::CreateItem(int index, int itemWidth)
        }
        if (pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
        {
-               r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth, 112), style);
+               r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth, 112 - 44 + __fontSize), style);
                TryCatch( r == E_SUCCESS,,"EditBookmarkListForm::CreateItem contruct item failed  %s",GetErrorMessage(r));
 
                pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_FOLDER_OPEN);
 
                if (pBitmap != null)
                {
-                       pItem->AddElement(Rectangle(16, 26, 60, 60), IDA_FORMAT_ICON, *pBitmap, null);
+                       pItem->AddElement(Rectangle(16, 26+(__fontSize - 44)/2, 60, 60), IDA_FORMAT_ICON, *pBitmap, null);
                        delete pBitmap;
                }
 
-               pItem->AddElement(Rectangle(92, 8, width_Title/*__pListview->GetWidth() - 92 - 80*/, 112), IDA_FORMAT_FOLDER, pBookMark->GetBookmarkTitle(), true);
-
+               pItem->AddElement(Rectangle(92, 8, width_Title/*__pListview->GetWidth() - 92 - 80*/, 112 + (__fontSize - 44)), IDA_FORMAT_FOLDER, pBookMark->GetBookmarkTitle(),__fontSize, CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,true);
 
                pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ITEM);
 
                if (pBitmap != null)
                {
-                       pItem->AddElement(Rectangle(GetClientAreaBounds().width - 92 - 80, 20, 60, 60), IDA_FORMAT_BITMAP, *pBitmap, null, null);
+                       pItem->AddElement(Rectangle(GetClientAreaBounds().width - 92 - 80, 20 + (__fontSize - 44)/2, 60, 60), IDA_FORMAT_BITMAP, *pBitmap, null, null);
                        pItem->SetElementSelectionEnabled(IDA_FORMAT_BITMAP, true);
                        delete pBitmap;
                }
        }
        else
        {
-               r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth, 128), style);
+               r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth, 128 + (__fontSize - 44)), style);
                TryCatch( r == E_SUCCESS,,"EditBookmarkListForm::CreateItem contruct item failed  %s",GetErrorMessage(r));
 
                pBitmap = pBookMark->GetFavIconBitmap();
@@ -445,19 +489,21 @@ EditBookmarkListForm::CreateItem(int index, int itemWidth)
                        pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
                }
 
-               pItem->AddElement(Rectangle(16, 28, 72, 72), IDA_FORMAT_ICON, *pBitmap, null);
+               pItem->AddElement(Rectangle(16, 28 + (__fontSize - 44)/2, 72, 72), IDA_FORMAT_ICON, *pBitmap, null);
                delete pBitmap;
 
-               pItem->AddElement(Rectangle(104, 10, width_Title, itemHeight - height_Url), IDA_FORMAT_SITE, pBookMark->GetBookmarkTitle(), true);
-               pItem->AddElement(Rectangle(x_Margin_Url, y_Margin_Url, width_Url, height_Url), IDA_FORMAT_URL, pBookMark->GetUrl(),textSize,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,true);
+               pItem->AddElement(Rectangle(104, 10, width_Title, itemHeight - height_Url + (__fontSize - 44)), IDA_FORMAT_SITE, pBookMark->GetBookmarkTitle(),__fontSize,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,true);
+               pItem->AddElement(Rectangle(x_Margin_Url, y_Margin_Url + (__fontSize - 44), width_Url, height_Url), IDA_FORMAT_URL, pBookMark->GetUrl(),textSize,CUSTOM_COLOR_GREY,CUSTOM_COLOR_LISTVIEW_TEXT,CUSTOM_COLOR_LISTVIEW_TEXT,true);
 
                //pBitmap = AppResource::GetInstance()->GetBitmapN("I01_picker_arrow_right.png");
                pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_RIGHT_ARROW);
-               if (pBitmap != null)
+               Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_RIGHT_ARROW_PRESS);
+               if (pBitmap != null && pPressedBitmap != null)
                {
-                       pItem->AddElement(Rectangle(GetClientAreaBounds().width - 92 - 84, 32, 64, 64), IDA_FORMAT_BITMAP, *pBitmap, null, null);
+                       pItem->AddElement(Rectangle(GetClientAreaBounds().width - 92 - 84-4, 32 + (__fontSize - 44)/2-4, 72, 72), IDA_FORMAT_BITMAP, *pBitmap, pPressedBitmap, null);
                        pItem->SetElementSelectionEnabled(IDA_FORMAT_BITMAP, true);
                        delete pBitmap;
+                       delete pPressedBitmap;
                }
        }
        return pItem;
@@ -679,11 +725,21 @@ EditBookmarkListForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView&
                }
 
                //labelString.Append(__selectedItemCount);
-               labelString.Append(CommonUtil::GetString(L"IDS_COM_OPT_SELECTED"));
+               /*labelString.Append(CommonUtil::GetString(L"IDS_BR_BODY_PD_ITEM_SELECTED"));
                labelString.Append(L"\x200E"); // LEFT-TO-RIGHT MARK
                labelString.Append(L"(");
                labelString.Append(__selectedItemCount);
-               labelString.Append(L")");
+               labelString.Append(L")");*/
+
+               if(__selectedItemCount >1)
+               {
+                       labelString.Format(25, CommonUtil::GetString(L"IDS_BR_POP_PD_ITEMS_SELECTED").GetPointer() , __selectedItemCount);
+               }
+               else
+               {
+                       labelString.Format(25, CommonUtil::GetString(L"IDS_BR_BODY_PD_ITEM_SELECTED").GetPointer() , __selectedItemCount);
+               }
+
                __pInfoLabel->SetText(labelString);
                __pInfoPanel->Draw();
                __pInfoPanel->Show();
@@ -761,15 +817,14 @@ EditBookmarkListForm::OnSceneActivatedN(const SceneId& previousSceneId, const Sc
 
        __selectedItemCount = 0;
 
-       labelString.Append(CommonUtil::GetString(L"IDS_COM_OPT_SELECTED"));
-       labelString.Append(L"\x200E"); // LEFT-TO-RIGHT MARK
-       labelString.Append(L"(");
-       labelString.Append(__pSelectedList->GetCount());
-       labelString.Append(L")");
-       __pInfoLabel->SetText(labelString);
+
        __pListview->UpdateList();
 
        count = __pListview->GetItemCount();
+       if(count == 0)
+       {
+               __pTimer->Start(1000);
+       }
 
        for(int index = 0 ; index < count ; index++)
        {
@@ -790,8 +845,6 @@ EditBookmarkListForm::OnSceneActivatedN(const SceneId& previousSceneId, const Sc
                }
                pBookmarkId->Append(pBookMark->GetBookmarkId());
 
-               AppLog("BookmarkId: %ls", pBookmarkId->GetPointer());
-
                if(__pSelectedList->Contains(*pBookmarkId))
                {
                        __pListview->SetItemChecked(index,true);
@@ -801,7 +854,28 @@ EditBookmarkListForm::OnSceneActivatedN(const SceneId& previousSceneId, const Sc
                {
                        __pListview->SetItemChecked(index,false);
                }
+               if (pBookmarkId)
+               {
+                       delete pBookmarkId;
+                       pBookmarkId = null;
+               }
+       }
+
+       //if(previousSceneId == IDSCN_ADD_BOOKMARK)
+       //      return;
+
+       if(__selectedItemCount >1)
+       {
+               labelString.Format(25, CommonUtil::GetString(L"IDS_BR_POP_PD_ITEMS_SELECTED").GetPointer() , __selectedItemCount);
+       }
+       else
+       {
+               labelString.Format(25, CommonUtil::GetString(L"IDS_BR_BODY_PD_ITEM_SELECTED").GetPointer() , __selectedItemCount);
        }
+
+       __pInfoLabel->SetText(labelString);
+
+
        if(__selectedItemCount == 0)
        {
                GetFooter()->SetItemEnabled(0, false);
@@ -820,11 +894,8 @@ EditBookmarkListForm::OnSceneActivatedN(const SceneId& previousSceneId, const Sc
        {
                __pCheckButton->SetSelected(true);
        }
-       __pInfoPanel->Draw();
-       __pInfoPanel->Show();
-
+       
        Invalidate(true);
-
 }
 
 void
@@ -841,6 +912,7 @@ EditBookmarkListForm::OnFormBackRequested(Form& source)
        if ( __pTimer != NULL)
        {
                __pTimer->Cancel();
+               delete __pTimer;
        }
 
        if (pSceneManager != null)
@@ -929,3 +1001,19 @@ EditBookmarkListForm::OnTimerExpired(Timer&  timer)
                }
        }
 }
+
+void
+EditBookmarkListForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
+{
+       AppLog("receiving userevent for appcontrol %d",requestId);
+       if (requestId == APPCONTROL_LAUNCH_MAX_LIMIT_REACHED)
+       {
+               AppLog("receiving userevent for appcontrol %d ",requestId);
+               if(__pConfirmationPopup)
+               {
+                       __pConfirmationPopup->SetShowState(false);
+                       delete __pConfirmationPopup;
+                       __pConfirmationPopup = null;
+               }
+       }
+}