Fixed Nabi Issues 49466,55718,55225,52332
[apps/osp/Internet.git] / src / IntHistoryListForm.cpp
index f6d597e..1869630 100644 (file)
@@ -44,10 +44,10 @@ using namespace Tizen::Ui::Controls;
 using namespace Tizen::Ui::Scenes;
 using namespace Tizen::System;
 
-static const wchar_t* IDB_TAB_ICON_BOOKMARKS = L"I01_tab_icon_bookmarks.png";
-static const wchar_t* IDB_TAB_ICON_HISTORY = L"I01_tab_icon_history.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"I01_icon_bookmark_off_temp.png";
+static const wchar_t* IDB_TAB_ICON_BOOKMARKS =  L"I01_search_list_icon_favorite.png";
+static const wchar_t* IDB_TAB_ICON_HISTORY =L"I01_search_list_icon_history.png";
+static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"00_icon_favorite_on_74x74.png";
+static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"00_icon_favorite_off_74x74.png";
 
 
 const int HistoryListForm::IDA_TABBAR_ITEM_1 = 101;
@@ -293,20 +293,14 @@ HistoryListForm::OnActionPerformed(const Control& source, int actionId)
                        }
                        else
                        {
-
                                if(pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT))!= E_SUCCESS)
                                {
                                        AppLogDebug("BookmarkListForm::OnActionPerformed GoBackward failed");
                                        return;
                                }
-
                        }
                }
-//             r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
-               if (IsFailed(r))
-               {
-                       return;
-               }
+
        }
        break;
        default:
@@ -381,6 +375,7 @@ HistoryListForm::CreateGroupItem(int groupIndex, int itemWidth)
        {
                AppLog("CreateGroupItem :: if history is null");
                r = pItem->Construct(Dimension(itemWidth, 0));
+               __pGroupedListView->SetItemEnabled(groupIndex, -1, false);
                return pItem;
        }
        else
@@ -468,7 +463,7 @@ HistoryListForm::CreateGroupItem(int groupIndex, int itemWidth)
                if (pGroupItemClass->GetTitleText() != CommonUtil::GetString(L"IDS_BR_BODY_OLDER"))
                {
                        text.Append(pGroupItemClass->GetStartTime().GetDay());
-                       text.Append(L". ");
+                       text.Append(L" ");
                        strMonth = pGroupItemClass->GetStartTime().GetMonth();
                        month = GetMonth(strMonth);
                        text.Append(month);
@@ -485,7 +480,7 @@ HistoryListForm::CreateGroupItem(int groupIndex, int itemWidth)
                {
                        text.Append(L" - ");
                        text.Append(pGroupItemClass->GetEndTime().GetDay());
-                       text.Append(L". ");
+                       text.Append(L" ");
                        strMonth = pGroupItemClass->GetEndTime().GetMonth();
                        month = GetMonth(strMonth);
                        text.Append(month);
@@ -506,6 +501,7 @@ HistoryListForm::CreateGroupItem(int groupIndex, int itemWidth)
                delete pItem;
                return null;
        }
+       __pGroupedListView->SetItemEnabled(groupIndex, -1, false);
 
        return pItem;
 }
@@ -530,34 +526,40 @@ HistoryListForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
        if(__pGroupData == null)
        {
                delete pItem;
+               delete pImage;
                return null;
        }
 
        if (pItem == null)
        {
+               delete pImage;
                return null;
        }
        pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
        if (pGroupItemClass == null)
        {
                delete pItem;
+               delete pImage;
                return null;
        }
        if (pGroupItemClass->GetHistoryData() == null)
        {
                delete pItem;
+               delete pImage;
                return null;
        }
        pHistory = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(itemIndex));
        if (pHistory == null)
        {
                delete pItem;
+               delete pImage;
                return null;
        }
        r = pItem->Construct(Dimension(itemWidth, 128 - 44 + __fontSize), LIST_ANNEX_STYLE_NORMAL);
        if (IsFailed(r))
        {
                delete pItem;
+               delete pImage;
                return null;
        }
 
@@ -588,29 +590,32 @@ HistoryListForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
        }
        if (pBitmap != null)
        {
+               AppLog("rrrr:: width %d height %d of the faviconbitmap",pBitmap->GetWidth(),pBitmap->GetHeight());
                r = pItem->AddElement(Rectangle(16, 28 + (__fontSize - 44)/2,72, 72), IDA_FORMAT_ICON, *pBitmap, null);
                delete pBitmap;
                if (IsFailed(r))
                {
                        delete pItem;
+                       delete pImage;
                        AppLogException("CreateItem failed with %s", GetErrorMessage(r));
                        return null;
                }
        }
        bool urlFoundInBookmark = false;
-
-       if(__pBookmarkList != null)
-       {
-               for (int i = 0; i < __pBookmarkList->GetCount();i++)
-               {
-                       BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pBookmarkList->GetAt(i));
-                       if(pBookMark != null && pHistory->GetHistoryUrl().CompareTo(pBookMark->GetUrl()) == 0)
-                       {
-                               urlFoundInBookmark = true;
-                               break;
-                       }
-               }
-       }
+//
+//     if(__pBookmarkList != null)
+//     {
+//             for (int i = 0; i < __pBookmarkList->GetCount();i++)
+//             {
+//                     BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pBookmarkList->GetAt(i));
+//                     if(pBookMark != null && pHistory->GetHistoryUrl().CompareTo(pBookMark->GetUrl()) == 0)
+//                     {
+//                             urlFoundInBookmark = true;
+//                             break;
+//                     }
+//             }
+//     }
+       BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(pHistory->GetHistoryUrl(),urlFoundInBookmark);
        if (urlFoundInBookmark == true)
        {
                pBookmarkBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
@@ -619,7 +624,7 @@ HistoryListForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
        {
                pBookmarkBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
        }
-       bookmarkBtnWidth = 64;
+       bookmarkBtnWidth = 74;
 
 
        r = pItem->AddElement(Rectangle(104, 10, GetClientAreaBounds().width - 108 - 32 - bookmarkBtnWidth - 32, 60 - 44 + __fontSize), IDA_FORMAT_TITLE, pHistory->GetHistoryTitle(), __fontSize,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,true);
@@ -628,7 +633,7 @@ HistoryListForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
 //     if(__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
 //             r = pItem->AddElement(Rectangle(104, 70, GetClientAreaBounds().width - 108 - 32 - bookmarkBtnWidth - 32, 48), IDA_FORMAT_URL, pHistory->GetHistoryUrl(),32,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,true);
 //     else
-               r = pItem->AddElement(Rectangle(104, 70 - 44 +__fontSize, GetClientAreaBounds().width - 108 - 32 - bookmarkBtnWidth - 32, 48), IDA_FORMAT_URL, pHistory->GetHistoryUrl(),32,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,true);
+               r = pItem->AddElement(Rectangle(104, 70 - 44 +__fontSize, GetClientAreaBounds().width - 108 - 32 - bookmarkBtnWidth - 32, 48), IDA_FORMAT_URL, pHistory->GetHistoryUrl(),32,CUSTOM_COLOR_GREY,CUSTOM_COLOR_LISTVIEW_TEXT,CUSTOM_COLOR_LISTVIEW_TEXT,true);
        TryCatch(!IsFailed(r), "CreateItem failed with %s",GetErrorMessage(r));
        if ( pBookmarkBitmap != null)
        {
@@ -641,6 +646,7 @@ HistoryListForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
 
        CATCH:
        delete pItem;
+       delete pImage;
        return null;
 }
 
@@ -704,6 +710,11 @@ HistoryListForm::GetGroupCount(void)
                else
                {
                        int count = 0;
+                       if (__searchText.GetLength() > 0)
+                       {
+                               __searchText.Replace(L"%", L"/%");
+                               __searchText.Replace(L"_", L"/_");
+                       }
                //      String searchText = __pSearchBar->GetText();
                        result r = HistoryPresentationModel::GetInstance()->GetSearchHistoryCount(count, __searchText);
                        if(count)
@@ -811,6 +822,7 @@ HistoryListForm::GetItemCount(int groupIndex)
 void
 HistoryListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
 {
+       AppLog("HistoryListForm::OnSceneActivatedN called");
 
        GetHeader()->SetItemSelected(1);
 //     __previousSceneId = previousSceneId;
@@ -871,10 +883,10 @@ HistoryListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId
        //              __pGroupedListView->UpdateList();
        //      }
 
-       result r = GetHeader()->SetItemSelected(2);
+       result r = GetHeader()->SetItemSelected(1);
        if (IsFailed(r))
        {
-               AppLog("HistoryListForm::OnSceneActivatedN header failed %ls", GetErrorMessage(r));
+               AppLog("HistoryListForm::OnSceneActivatedN header failed %s", GetErrorMessage(r));
                return;
        }
 
@@ -923,18 +935,19 @@ HistoryListForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, in
 
                bool bookmarkFound = false;
                BookmarkData* pBookMark = null;
-               if(__pBookmarkList != null)
-               {
-                       for (int i = 0; i < __pBookmarkList->GetCount(); i++)
-                       {
-                               pBookMark = dynamic_cast< BookmarkData* >(__pBookmarkList->GetAt(i));
-                               if (pBookMark != null && toggledUrl.CompareTo(pBookMark->GetUrl()) == 0)
-                               {
-                                       bookmarkFound = true;
-                                       break;
-                               }
-                       }
-               }
+//             if(__pBookmarkList != null)
+//             {
+//                     for (int i = 0; i < __pBookmarkList->GetCount(); i++)
+//                     {
+//                             pBookMark = dynamic_cast< BookmarkData* >(__pBookmarkList->GetAt(i));
+//                             if (pBookMark != null && toggledUrl.CompareTo(pBookMark->GetUrl()) == 0)
+//                             {
+//                                     bookmarkFound = true;
+//                                     break;
+//                             }
+//                     }
+//             }
+               BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(toggledUrl,bookmarkFound);
                if(bookmarkFound == false)
                {
                        // Add the history in bookmark database
@@ -946,7 +959,13 @@ HistoryListForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, in
                        bookmark.SetBookmarkTitle(bookmarkTitle);
                        bookmark.SetUrl(pHistory->GetHistoryUrl());
                        bookmark.SetFaviconId(pHistory->GetFaviconId());
-                       bookmark.SetFavIconBuffer(*pHistory->GetFavIconBuffer());
+                       if(pHistory->GetFavIconBuffer())
+                       {
+                               ByteBuffer *pBuffer = new ByteBuffer();
+
+                               pBuffer->Construct(*pHistory->GetFavIconBuffer());
+                               bookmark.SetFavIconBuffer(*pBuffer);
+                       }
                        //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(pBookmark);
                        r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(bookmark);
                }
@@ -1032,6 +1051,10 @@ void
 HistoryListForm::OnSearchBarModeChanged(SearchBar& source, SearchBarMode mode)
 {
        result r = E_FAILURE;
+       if(__pSearchBar)
+               __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
+       __pSearchListView->Invalidate(false);
+
        if (mode == SEARCH_BAR_MODE_NORMAL)
        {
                if ( Clipboard::GetInstance()->IsPopupVisible() == false && __searchHistory == false)
@@ -1116,7 +1139,7 @@ HistoryListForm::GetMonth(int month)
                monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_MAR"));
                break;
        case APRIL:
-               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_APR"));
+               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_APRIL"));
                break;
        case MAY:
                monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_MAY"));
@@ -1226,8 +1249,7 @@ HistoryListForm::OnOrientationChanged(const Control& source, OrientationStatus o
                {
                        return;
                }
-               __pGroupedListView->UpdateList();
-
+               //__pGroupedListView->UpdateList();
                if (__pSearchListView != null)
                {
                        r = __pSearchListView->SetBounds(Rectangle(0,  0, GetClientAreaBounds().width, __pGroupedListView->GetHeight()));
@@ -1242,6 +1264,17 @@ HistoryListForm::OnOrientationChanged(const Control& source, OrientationStatus o
                                __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
                }
 
+               __pGroupedListView->UpdateList();//this change is as suggested by platform team for issue N_SE-52111
+//             if(__pGroupData != NULL)
+//             {
+//                     for (int groupIndex = 0; groupIndex < __pGroupData->GetCount(); groupIndex++)
+//                     {
+//                             for (int itemIndex = 0; itemIndex < __pGroupedListView->GetItemCountAt(groupIndex); itemIndex++)
+//                             {
+//                                     __pGroupedListView->RefreshList(groupIndex, itemIndex,LIST_REFRESH_TYPE_ITEM_MODIFY);
+//                             }
+//                     }
+//             }
        }
 
        if (__isNoHistoryPresent == true)
@@ -1277,10 +1310,10 @@ HistoryListForm::OnKeypadOpened(Control& source)
 void
 HistoryListForm::OnKeypadClosed(Control& source)
 {
-       if(Clipboard::GetInstance()->IsPopupVisible() == true)
-       {
-               return;
-       }
+//     if(Clipboard::GetInstance()->IsPopupVisible() == true)
+//     {
+//             return;
+//     }
        GetFooter()->SetShowState(true);
        __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
        __pSearchListView->Invalidate(false);
@@ -1329,7 +1362,7 @@ HistoryListForm::CreateGroupItems()
                {
                        return;
                }
-               titleText = CommonUtil::GetString(L"IDS_BR_BODY_SEARCHED_ITEMS");
+               titleText = CommonUtil::GetString(L"IDS_BR_BODY_SEARCH");
                pGroupItemClass->SetTitleText(titleText);
                r = __pGroupData->Add(*pGroupItemClass);
                if (IsFailed(r))
@@ -1954,4 +1987,17 @@ HistoryListForm::OnSettingChanged(Tizen::Base::String& key)
        {
                __pGroupedListView->UpdateList();
        }
+       if (__isNoHistoryPresent == true )
+       {
+               if(__pSearchBar)
+                       __pSearchBar->SetShowState(false);
+               GetFooter()->SetItemEnabled(0, false);
+       }
+       else
+       {
+               if(__pSearchBar)
+                       __pSearchBar->SetShowState(true);
+               GetFooter()->SetItemEnabled(0, true);
+       }
+       GetFooter()->Invalidate(true);
 }