Fixed Nabi Issues and Hardware Key Implementation
[apps/osp/Internet.git] / src / IntHistoryListForm.cpp
index 07d3a18..5fe41f4 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
 //
@@ -38,9 +38,11 @@ using namespace Tizen::Base::Collection;
 using namespace Tizen::Base::Runtime;
 using namespace Tizen::Graphics;
 using namespace Tizen::Locales;
+using namespace Tizen::Media;
 using namespace Tizen::Ui;
 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";
@@ -59,6 +61,7 @@ const int HistoryListForm::IDA_FORMAT_BOOKMARK = 107;
 
 HistoryListForm::HistoryListForm(void)
 {
+       __pBookmarkList = null;
        __pGroupedListView =null;
        __pSearchListView = null;
        __pSearchBar = null;
@@ -67,15 +70,26 @@ HistoryListForm::HistoryListForm(void)
        __searchHistory = false;
        __isNoHistoryPresent = true;
        __searchText = L"";
+       __previousSceneId = L"";
 }
 
 HistoryListForm::~HistoryListForm(void)
 {
        if (__pGroupData != null)
        {
-               __pGroupData->RemoveAll(true);
+               __pGroupData->RemoveAll(false);
                delete __pGroupData;
        }
+       if(__pBookmarkList != null)
+       {
+               __pBookmarkList->RemoveAll(false);
+               delete __pBookmarkList;
+       }
+       if (__pSearchListView)
+       {
+               delete __pSearchListView;
+               __pSearchListView = null;
+       }
 }
 
 bool
@@ -98,20 +112,30 @@ HistoryListForm::OnInitializing(void)
        Bitmap *pIconBitmap = null;
        AppResource* pAppResource = UiApp::GetInstance()->GetAppResource();
        const Color brown = Color(32, 32, 32, 0xFF);
-
+//     bool isHwBackButtonExist = false;
+//     Tizen::System::SystemInfo::GetValue(L"http:://tizen.org/feature/input.back.key",isHwBackButtonExist);
+//
+//     SetFormStyle(FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
        // Setup back event listener
        SetFormBackEventListener(this);
 
        GetHeader()->AddActionEventListener(*this);
        GetFooter()->AddActionEventListener(*this);
 
+//     if(isHwBackButtonExist)
+//     {
+//             GetFooter()->SetBackButtonEnabled(false);
+//     }
        AddOrientationEventListener(*this);
+       SettingInfo::AddSettingEventListener(*this);
+
        pSceneManager = SceneManager::GetInstance();
        if (pSceneManager != null)
        {
                pSceneManager->AddSceneEventListener(IDSCN_HISTORY_LIST, *this);
        }
 
+       __fontSize = CommonUtil::GetFontSize();
        if (pAppResource == null)
        {
                return E_FAILURE;
@@ -140,6 +164,7 @@ HistoryListForm::OnInitializing(void)
        {
                return E_FAILURE;
        }
+
        __pGroupedListView->AddGroupedListViewItemEventListener(*this);
        r = __pGroupedListView->SetBounds(Rectangle(0,__pGroupedListView->GetY(),GetClientAreaBounds().width,GetClientAreaBounds().height  - __pSearchBar->GetHeight() - __pSearchBar->GetY()));
        if (IsFailed(r))
@@ -163,6 +188,7 @@ HistoryListForm::OnInitializing(void)
                return r;
        }
 
+       __pSearchListView->SetBackgroundColor(GetBackgroundColor());
        __pSearchListView->SetTextColorOfEmptyList(Color::GetColor(COLOR_ID_BLACK));
        __pSearchListView->AddGroupedListViewItemEventListener(*this);
        r = __pSearchListView->SetShowState(false);
@@ -203,6 +229,7 @@ HistoryListForm::OnInitializing(void)
                history.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
                pHeader->AddItem(history);
                pHeader->SetItemSelected(1);
+               pHeader->SetTabEditModeEnabled(false);
 
                if (pIconBitmap != NULL)
                {
@@ -210,6 +237,9 @@ HistoryListForm::OnInitializing(void)
                }
        }
 
+       __pBookmarkList = new(std::nothrow) Collection::ArrayList();
+       __pBookmarkList->Construct();
+       BookmarkPresentationModel::GetInstance()->GetBookmarkForHistory(0,*__pBookmarkList);
        return r;
 }
 
@@ -218,6 +248,7 @@ HistoryListForm::OnTerminating(void)
 {
        result r = E_SUCCESS;
 
+       SettingInfo::RemoveSettingEventListener(*this);
        return r;
 }
 
@@ -248,7 +279,29 @@ HistoryListForm::OnActionPerformed(const Control& source, int actionId)
                result r = GetHeader()->SetItemSelected(1);
                AppLog("SetItemSelected result %s",GetErrorMessage(r));
                GetHeader()->Invalidate(true);
-               r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
+
+               if (pSceneManager != null)
+               {
+                       if(__previousSceneId.CompareTo(IDSCN_BOOKMARK_VIEW) != 0)
+                       {
+                               if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_LEFT)) != E_SUCCESS)
+                               {
+                                       AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
+                                       return;
+                               }
+                       }
+                       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;
@@ -268,7 +321,15 @@ HistoryListForm::OnFormBackRequested(Form& source)
        {
                return;
        }
-       result r = pSceneManager->GoBackward(BackwardSceneTransition());
+       result r = E_FAILURE;
+       if(__previousSceneId.CompareTo(IDSCN_BOOKMARK_VIEW) != 0)
+       {
+                       r = pSceneManager->GoBackward(BackwardSceneTransition());
+       }
+       else
+       {
+               r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
+       }
        if(IsFailed(r))
        {
                AppLogDebug("HistoryListForm::OnFormBackRequested GoForward failed %s",GetErrorMessage(r));
@@ -288,13 +349,13 @@ HistoryListForm::CreateGroupItem(int groupIndex, int itemWidth)
        GroupItemClass* pGroupItemClass = null;
 
        String weeksAgo2 = L"";
-       weeksAgo2.Format(25,CommonUtil::GetString(L"IDS_BR_BODY_PD_WEEKS_AGO").GetPointer(),2);
+       weeksAgo2.Format(25,CommonUtil::GetString(L"IDS_EMAIL_BODY_PD_WEEKS_AGO").GetPointer(),2);
 
        String weeksAgo3 = L"";
-       weeksAgo3.Format(25,CommonUtil::GetString(L"IDS_BR_BODY_PD_WEEKS_AGO").GetPointer(),3);
+       weeksAgo3.Format(25,CommonUtil::GetString(L"IDS_EMAIL_BODY_PD_WEEKS_AGO").GetPointer(),3);
 
        String weeksAgo4 = L"";
-       weeksAgo4.Format(25,CommonUtil::GetString(L"IDS_BR_BODY_PD_WEEKS_AGO").GetPointer(),4);
+       weeksAgo4.Format(25,CommonUtil::GetString(L"IDS_EMAIL_BODY_PD_WEEKS_AGO").GetPointer(),4);
 
        pItem = new(std::nothrow) GroupItem();
        if (pItem == null)
@@ -356,8 +417,10 @@ HistoryListForm::CreateGroupItem(int groupIndex, int itemWidth)
                                        return null;
                                }
                                dayOfWeek = pGregorianCalendar->GetTimeField(TIME_FIELD_DAY_OF_WEEK);
-
-                               delete pGregorianCalendar;
+                               if (pGregorianCalendar != NULL)
+                               {
+                                       delete pGregorianCalendar;
+                               }
 
                        }
                        switch(dayOfWeek)
@@ -404,7 +467,7 @@ HistoryListForm::CreateGroupItem(int groupIndex, int itemWidth)
 
 
 
-               if (pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK") || pGroupItemClass->GetTitleText() == weeksAgo2
+               if (pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK") || pGroupItemClass->GetTitleText() == weeksAgo2
                                || pGroupItemClass->GetTitleText() == weeksAgo3 || pGroupItemClass->GetTitleText() == weeksAgo4 || pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_BR_EARLIER_THIS_MONTH") || pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_MONTH") || pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_BR_BODY_OLDER"))
                {
                        text.Append(L" - ");
@@ -414,7 +477,7 @@ HistoryListForm::CreateGroupItem(int groupIndex, int itemWidth)
                        month = GetMonth(strMonth);
                        text.Append(month);
                }
-               text.Append(L".)");
+               text.Append(L")");
        }
 
        r = pItem->SetElement(text, null);
@@ -441,12 +504,22 @@ HistoryListForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
        result r = E_FAILURE;
        History* pHistory = null;
        Bitmap* pBitmap = null;
+       Bitmap* pBookmarkBitmap = null;
        GroupItemClass* pGroupItemClass = null;
        CustomItem* pItem = new(std::nothrow) CustomItem();
        int bookmarkBtnWidth = 0;
-       Bitmap* pBookmarkBitmap = null;
        String bitmapId;
 
+       Image* pImage = null;
+       pImage = new Image();
+       pImage->Construct();
+
+       if(__pGroupData == null)
+       {
+               delete pItem;
+               return null;
+       }
+
        if (pItem == null)
        {
                return null;
@@ -457,22 +530,44 @@ HistoryListForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
                delete pItem;
                return null;
        }
+       if (pGroupItemClass->GetHistoryData() == null)
+       {
+               delete pItem;
+               return null;
+       }
        pHistory = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(itemIndex));
        if (pHistory == null)
        {
                delete pItem;
                return null;
        }
-       r = pItem->Construct(Dimension(itemWidth, 128), LIST_ANNEX_STYLE_NORMAL);
+       r = pItem->Construct(Dimension(itemWidth, 128 - 44 + __fontSize), LIST_ANNEX_STYLE_NORMAL);
        if (IsFailed(r))
        {
                delete pItem;
                return null;
        }
 
-       bitmapId = pHistory->GetFaviconId() ;
+       ByteBuffer* pFavIconBuffer = null;
+       pFavIconBuffer = pHistory->GetFavIconBuffer();
+
+       AppLog("BookmarkListForm::CreateItem check 0");
+
+       if (pFavIconBuffer != null)
+       {
+               AppLog("BookmarkListForm::CreateItem pFavIconBuffer is not null");
+       }
+       else
+       {
+               AppLog("BookmarkListForm::CreateItem pFavIconBuffer is null");
+       }
+
+       pBitmap = pImage->DecodeN(*pFavIconBuffer, IMG_FORMAT_PNG, BITMAP_PIXEL_FORMAT_ARGB8888);
+
+       AppLog("BookmarkListForm::CreateItem check 1");
 
-       pBitmap = FaviconManager::GetInstance()->GetFaviconN(bitmapId);
+       //bitmapId = pHistory->GetFaviconId() ;
+       //pBitmap = pHistory->GetFavIconBitmap();
 
        if (pBitmap == null)
        {
@@ -480,7 +575,7 @@ HistoryListForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
        }
        if (pBitmap != null)
        {
-               r = pItem->AddElement(Rectangle(16, 2872, 72), IDA_FORMAT_ICON, *pBitmap, null);
+               r = pItem->AddElement(Rectangle(16, 28 + (__fontSize - 44)/2,72, 72), IDA_FORMAT_ICON, *pBitmap, null);
                delete pBitmap;
                if (IsFailed(r))
                {
@@ -489,36 +584,50 @@ HistoryListForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
                        return null;
                }
        }
-//     if (pHistory->GetBookmarkId().GetLength()>0)
-//     {
-//             pBookmarkBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
-//     }
-//     else
-//     {
-//             pBookmarkBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
-//     }
+       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 (urlFoundInBookmark == true)
+       {
+               pBookmarkBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
+       }
+       else
+       {
+               pBookmarkBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
+       }
        bookmarkBtnWidth = 64;
 
 
-       r = pItem->AddElement(Rectangle(104, 10, GetClientAreaBounds().width - 108 - 32 - bookmarkBtnWidth - 32, 60), IDA_FORMAT_TITLE, pHistory->GetHistoryTitle(), 44,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,true);
+       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);
        TryCatch(!IsFailed(r), "CreateItem failed with %s",GetErrorMessage(r));
 
-       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, GetClientAreaBounds().width - 108 - 32 - bookmarkBtnWidth - 32, 48), IDA_FORMAT_URL, pHistory->GetHistoryUrl(),32,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,true);
+//     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);
        TryCatch(!IsFailed(r), "CreateItem failed with %s",GetErrorMessage(r));
-//     if ( pBookmarkBitmap != null)
-//     {
-//             r = pItem->AddElement(Rectangle(GetClientAreaBounds().width - bookmarkBtnWidth - 16, (128 - pBookmarkBitmap->GetHeight())/2, bookmarkBtnWidth, bookmarkBtnWidth), IDA_FORMAT_BOOKMARK, *pBookmarkBitmap);
-//             TryCatch(!IsFailed(r), "CreateItem failed with %s",GetErrorMessage(r));
-//             delete pBookmarkBitmap;
-//     }
+       if ( pBookmarkBitmap != null)
+       {
+               r = pItem->AddElement(Rectangle(GetClientAreaBounds().width - bookmarkBtnWidth - 16, (128 - pBookmarkBitmap->GetHeight())/2 +(__fontSize - 44)/2, bookmarkBtnWidth, bookmarkBtnWidth), IDA_FORMAT_BOOKMARK, *pBookmarkBitmap);
+               TryCatch(!IsFailed(r), "CreateItem failed with %s",GetErrorMessage(r));
+               delete pBookmarkBitmap;
+       }
+       delete pImage;
        return pItem;
 
        CATCH:
        delete pItem;
-       delete pBookmarkBitmap;
        return null;
 }
 
@@ -566,7 +675,13 @@ HistoryListForm::GetGroupCount(void)
                if (__searchHistory == false)
                {
                        int count = 0;
-                       HistoryPresentationModel::GetInstance()->GetHistoryCount(count);
+                       DateTime startTime;
+                       DateTime endTime;
+                       HistoryPresentationModel::GetCurrentDateTime(endTime);;
+
+                       startTime.SetValue(0,0,0);
+
+                       HistoryPresentationModel::GetInstance()->GetHistoryCountWithTimeRange(startTime,endTime,count);
                        if (count == 0)
                        {
                                return 0;
@@ -685,6 +800,19 @@ HistoryListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId
 {
 
        GetHeader()->SetItemSelected(1);
+//     __previousSceneId = previousSceneId;
+       ArrayListT<String> * pList = dynamic_cast<ArrayListT<String>* >(SceneManager::GetInstance()->GetSceneHistoryN());
+       if(pList != null)
+       {
+               pList->GetAt(pList->GetCount()-1,__previousSceneId);
+       }
+
+       if(__pBookmarkList != null)
+       {
+               __pBookmarkList->RemoveAll(false);
+       }
+
+       BookmarkPresentationModel::GetInstance()->GetBookmarkForHistory(0,*__pBookmarkList);
 
        AppLog("HistoryListForm::OnSceneActivatedN called");
        //GetHeader()->Invalidate(true);
@@ -732,6 +860,8 @@ HistoryListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId
                return;
        }
 
+
+
        Invalidate(true);
 
 }
@@ -772,122 +902,52 @@ HistoryListForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, in
                toggledUrl = pHistory->GetHistoryUrl();
 
                AppLog("History's Bookmark ID %ls ToggledUrl %ls",pHistory->GetBookmarkId().GetPointer(),toggledUrl.GetPointer());
-               if (pHistory->GetBookmarkId().GetLength() > 0)
-               {
-                       AppLog("Already added to bookmark so will be removed");
-                       String bookmarkId = L"";
-                       int id = 0;
 
-                       bookmarkId = pHistory->GetBookmarkId();
-                       Integer::Parse(bookmarkId,id);
-                       BookmarkPresentationModel::GetInstance()->DeleteBookmark(id);
-                       pHistory->SetBookmarkId(L"");
-                       //listView.RefreshList(groupIndex,itemIndex,LIST_REFRESH_TYPE_ITEM_MODIFY);
-
-                       for(int grindex = 0 ; grindex < __pGroupData->GetCount() ; grindex++)
+               bool bookmarkFound = false;
+               BookmarkData* pBookMark = null;
+               if(__pBookmarkList != null)
+               {
+                       for (int i = 0; i < __pBookmarkList->GetCount(); i++)
                        {
-                               pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(grindex));
-                               if (pGroupItemClass == null)
-                               {
-                                       continue;
-                               }
-                               for(int index = 0 ; index < pGroupItemClass->GetHistoryData()->GetCount() ; index++)
+                               pBookMark = dynamic_cast< BookmarkData* >(__pBookmarkList->GetAt(i));
+                               if (pBookMark != null && toggledUrl.CompareTo(pBookMark->GetUrl()) == 0)
                                {
-                                       pHistory = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(index));
-                                       if (pHistory == null)
-                                       {
-                                               continue;
-                                       }
-                                       if (toggledUrl.CompareTo(pHistory->GetHistoryUrl()) == 0)
-                                       {
-                                               pHistory->SetBookmarkId(L"");
-                                               AppLog("Already added to bookmark so will be removed");
-                                               String bookmarkId = L"";
-                                               int id = 0;
-
-                                               bookmarkId = pHistory->GetBookmarkId();
-                                               Integer::Parse(bookmarkId,id);
-                                               BookmarkPresentationModel::GetInstance()->DeleteBookmark(id);
-                                               pHistory->SetBookmarkId(L"");
-                                               //listView.RefreshList(groupIndex,itemIndex,LIST_REFRESH_TYPE_ITEM_MODIFY);
-
-                                               for(int grindex = 0 ; grindex < __pGroupData->GetCount() ; grindex++)
-                                               {
-                                                       pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(grindex));
-                                                       if (pGroupItemClass == null)
-                                                       {
-                                                               continue;
-                                                       }
-                                                       for(int index = 0 ; index < pGroupItemClass->GetHistoryData()->GetCount() ; index++)
-                                                       {
-                                                               pHistory = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(index));
-                                                               if (pHistory == null)
-                                                               {
-                                                                       continue;
-                                                               }
-                                                               if (toggledUrl.CompareTo(pHistory->GetHistoryUrl()) == 0)
-                                                               {
-                                                                       pHistory->SetBookmarkId(L"");
-                                                                       //listView.RefreshList(grindex,index,LIST_REFRESH_TYPE_ITEM_MODIFY);
-                                                               }
-                                                       }
-                                               }
-
-                                               //listView.RefreshList(grindex,index,LIST_REFRESH_TYPE_ITEM_MODIFY);
-                                       }
+                                       bookmarkFound = true;
+                                       break;
                                }
                        }
-                       listView.UpdateList();
-
                }
-               else
+               if(bookmarkFound == false)
                {
-                       AppLog("Adding history to bookmark");
+                       // Add the history in bookmark database
                        result r = E_FAILURE;
-                       BookmarkData pBookmark;
+                       BookmarkData bookmark;
 
                        String bookmarkTitle = pHistory->GetHistoryTitle();
 
-                       pBookmark.SetBookmarkTitle(bookmarkTitle);
-                       pBookmark.SetUrl(pHistory->GetHistoryUrl());
-                       pBookmark.SetFaviconId(pHistory->GetFaviconId());
-
-                       r = BookmarkPresentationModel::GetInstance()->SaveBookmark(pBookmark);
-                       if (!IsFailed(r))
-                       {
-                               AppLog("History added to bookmark with ID %ls",pBookmark.GetBookmarkId().GetPointer());
-                               pHistory->SetBookmarkId(pBookmark.GetBookmarkId());
-                       }
-
-                       listView.RefreshList(groupIndex,itemIndex,LIST_REFRESH_TYPE_ITEM_MODIFY);
+                       bookmark.SetBookmarkTitle(bookmarkTitle);
+                       bookmark.SetUrl(pHistory->GetHistoryUrl());
+                       bookmark.SetFaviconId(pHistory->GetFaviconId());
+                       bookmark.SetFavIconBuffer(*pHistory->GetFavIconBuffer());
+                       //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(pBookmark);
+                       r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(bookmark);
+               }
+               else
+               {
+                       // remove the history from bookmark database
+                       BookmarkPresentationModel::GetInstance()->DeleteBookmark(toggledUrl);
+               }
 
-                       for(int grindex = 0 ; grindex < __pGroupData->GetCount() ; grindex++)
-                       {
-                               pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(grindex));
-                               if (pGroupItemClass == null)
-                               {
-                                       continue;
-                               }
-                               for(int index = 0 ; index < pGroupItemClass->GetHistoryData()->GetCount() ; index++)
-                               {
-                                       pHistory = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(index));
-                                       if (pHistory == null)
-                                       {
-                                               continue;
-                                       }
-                                       if (toggledUrl.CompareTo(pHistory->GetHistoryUrl()) == 0)
-                                       {
-                                               pHistory->SetBookmarkId(pBookmark.GetBookmarkId());
-                                               //listView.RefreshList(grindex,index,LIST_REFRESH_TYPE_ITEM_MODIFY);
-                                       }
-                               }
-                       }
-                       listView.UpdateList();
+               if(__pBookmarkList != null)
+               {
+                       __pBookmarkList->RemoveAll(false);
+                       BookmarkPresentationModel::GetInstance()->GetBookmarkForHistory(0,*__pBookmarkList);
                }
+               listView.RefreshList(groupIndex,itemIndex,LIST_REFRESH_TYPE_ITEM_MODIFY);
+               listView.UpdateList();
        }
        else
        {
-
                pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
                if (pGroupItemClass == null)
                {
@@ -956,7 +1016,11 @@ HistoryListForm::OnSearchBarModeChanged(SearchBar& source, SearchBarMode mode)
        result r = E_FAILURE;
        if (mode == SEARCH_BAR_MODE_NORMAL)
        {
-               //              __pSearchBar->SetMode(SEARCH_BAR_MODE_INPUT);
+               if ( Clipboard::GetInstance()->IsPopupVisible() == false && __searchHistory == false)
+               {
+                       __pSearchListView->SetEnabled(true);
+               }
+
                r = __pSearchListView->SetShowState(false);
                if (IsFailed(r))
                {
@@ -967,7 +1031,10 @@ HistoryListForm::OnSearchBarModeChanged(SearchBar& source, SearchBarMode mode)
                {
                        return;
                }
+
                __pSearchListView->SetEnabled(true);
+               if(__pSearchBar != null)
+                       __pGroupedListView->SetBounds(0, __pSearchBar->GetY() + __pSearchBar->GetHeight(), GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight());
                Invalidate(true);
                __searchHistory = false;
                r = __pGroupedListView->UpdateList();
@@ -990,6 +1057,7 @@ HistoryListForm::OnSearchBarModeChanged(SearchBar& source, SearchBarMode mode)
        }
        else
        {
+
                //              __pSearchListView->SetEnabled(false);
                r = __pSearchListView->SetShowState(true);
                if (IsFailed(r))
@@ -1036,13 +1104,13 @@ HistoryListForm::GetMonth(int month)
                monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_MAY"));
                break;
        case JUNE:
-               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_JUN"));
+               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_JUNE"));
                break;
        case JULY:
                monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_JUL"));
                break;
        case AUGUST:
-               monthValue.Append(CommonUtil::GetString(L"DS_COM_BODY_AUG"));
+               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_AUG"));
                break;
        case SEPTEMBER:
                monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_SEP"));
@@ -1078,6 +1146,7 @@ HistoryListForm::OnKeypadActionPerformed(Control &source, KeypadAction keypadAct
                __pSearchListView->SetEnabled(true);
                __searchHistory = true;
                __searchText =__pSearchBar->GetText();
+               AppLog("SearchTextHistory %S errormsg %s",__searchText.GetPointer(),GetErrorMessage(GetLastResult()));
 
                r = __pGroupedListView->SetShowState(false);
                if (IsFailed(r))
@@ -1113,19 +1182,30 @@ HistoryListForm::OnKeypadActionPerformed(Control &source, KeypadAction keypadAct
 }
 
 void
+HistoryListForm::OnKeypadBoundsChanged(Tizen::Ui::Control& source)
+{
+       FloatRectangle clientRect;
+       clientRect = GetClientAreaBoundsF();
+       AppLogDebug("SearchBarForm::OnKeypadBoundsChanged ClientBounds(%f, %f, %f, %f)",clientRect.x, clientRect.y, clientRect.width, clientRect.height);
+       __pSearchBar->SetContentAreaSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
+       __pSearchListView->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
+       __pGroupedListView->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
+//     __pGroupedListView->SetEnabled(false);
+       Invalidate(true);
+}
+
+void
 HistoryListForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
 {
        result r = E_FAILURE;
        if (__pGroupedListView != null)
        {
-               AppLog("groupedlistview bounds %d,%d,%d",GetClientAreaBounds().height,__pSearchBar->GetHeight(),__pSearchBar->GetY());
                if(__pSearchBar != null &&__pSearchBar->GetShowState())
                        r = __pGroupedListView->SetBounds(Rectangle(0,__pSearchBar->GetY() + __pSearchBar->GetHeight()/*72 + 30*/,GetClientAreaBounds().width,GetClientAreaBounds().height - __pSearchBar->GetHeight() - __pSearchBar->GetY()));
                else if(__pSearchBar != null)
                        r = __pGroupedListView->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pSearchBar->GetHeight() - __pSearchBar->GetY()));
                if (IsFailed(r))
                {
-                       AppLog("Error in OnOrientationChanged SetBounds %s values %d,%d,%d,%d",GetErrorMessage(r),0,__pSearchBar->GetY() + __pSearchBar->GetHeight()/*72 + 30*/,GetClientAreaBounds().width,GetClientAreaBounds().height - __pSearchBar->GetHeight() - __pSearchBar->GetY());
                        return;
                }
                __pGroupedListView->UpdateList();
@@ -1160,7 +1240,7 @@ void
 HistoryListForm::OnKeypadWillOpen(Control& source)
 {
        GetFooter()->SetShowState(false);
-       __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
+       __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight());
        __pSearchListView->SetEnabled(false);
        __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
        Invalidate(true);
@@ -1170,22 +1250,24 @@ HistoryListForm::OnKeypadWillOpen(Control& source)
 void
 HistoryListForm::OnKeypadOpened(Control& source)
 {
+       // this is added because some time footer is shown when key pad is opened, do not remove
+       GetFooter()->SetShowState(false);
+       GetFooter()->Invalidate(true);
        __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
 }
 
 void
 HistoryListForm::OnKeypadClosed(Control& source)
 {
-       if ( Clipboard::GetInstance()->IsPopupVisible() == false && __searchHistory == false)
+       if(Clipboard::GetInstance()->IsPopupVisible() == true)
        {
-               //              __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
-               __pSearchListView->SetEnabled(true);
-
+               return;
        }
+       GetFooter()->SetShowState(true);
        __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
        __pSearchListView->Invalidate(false);
        __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
-       GetFooter()->SetShowState(true);
+       __pGroupedListView->SetBounds(0, __pSearchBar->GetY() + __pSearchBar->GetHeight(), GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight());
        Invalidate(true);
 }
 
@@ -1199,14 +1281,14 @@ HistoryListForm::CreateGroupItems()
        String titleText;
 
        String weeksAgo2 = L"";
-       weeksAgo2.Format(25,CommonUtil::GetString(L"IDS_BR_BODY_PD_WEEKS_AGO").GetPointer(),2);
+       weeksAgo2.Format(25,CommonUtil::GetString(L"IDS_EMAIL_BODY_PD_WEEKS_AGO").GetPointer(),2);
 
        String weeksAgo3 = L"";
-       weeksAgo3.Format(25,CommonUtil::GetString(L"IDS_BR_BODY_PD_WEEKS_AGO").GetPointer(),3);
+       weeksAgo3.Format(25,CommonUtil::GetString(L"IDS_EMAIL_BODY_PD_WEEKS_AGO").GetPointer(),3);
 
        if (__pGroupData != null)
        {
-               __pGroupData->RemoveAll(true);
+               __pGroupData->RemoveAll(false);
                delete __pGroupData;
                __pGroupData = null;
        }
@@ -1273,7 +1355,7 @@ HistoryListForm::CreateGroupItems()
                        {
                                return;
                        }
-                       titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");
+                       titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
                        pGroupItemClass->SetTitleText(titleText);
                        dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
                        pGroupItemClass->SetEndTime(dateTime);
@@ -1288,7 +1370,7 @@ HistoryListForm::CreateGroupItems()
                        {
                                return;
                        }
-                       titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");
+                       titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
                        pGroupItemClass->SetTitleText(titleText);
                        dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
                        pGroupItemClass->SetEndTime(dateTime);
@@ -1317,7 +1399,7 @@ HistoryListForm::CreateGroupItems()
                        {
                                return;
                        }
-                       titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");
+                       titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
                        pGroupItemClass->SetTitleText(titleText);
                        dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
                        dateTime.AddDays(currentTime.GetDay() - 1 - 1);
@@ -1362,7 +1444,7 @@ HistoryListForm::CreateGroupItems()
                        {
                                return;
                        }
-                       titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");
+                       titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
                        pGroupItemClass->SetTitleText(titleText);
                        dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
                        dateTime.AddDays(currentTime.GetDay() - 2 - 1);
@@ -1422,7 +1504,7 @@ HistoryListForm::CreateGroupItems()
                        {
                                return;
                        }
-                       titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");
+                       titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
                        pGroupItemClass->SetTitleText(titleText);
                        dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
                        dateTime.AddDays(currentTime.GetDay() - 3 - 1);
@@ -1497,7 +1579,7 @@ HistoryListForm::CreateGroupItems()
                        {
                                return;
                        }
-                       titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");
+                       titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
                        pGroupItemClass->SetTitleText(titleText);
                        dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
                        dateTime.AddDays(currentTime.GetDay() - 4 - 1);
@@ -1587,7 +1669,7 @@ HistoryListForm::CreateGroupItems()
                        {
                                return;
                        }
-                       titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");
+                       titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
                        pGroupItemClass->SetTitleText(titleText);
                        dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
                        dateTime.AddDays(currentTime.GetDay() - 5 - 1);
@@ -1628,7 +1710,7 @@ HistoryListForm::CreateGroupItems()
                                        return;
                                }
                                String weeksAgo3 = L"";
-                               weeksAgo3.Format(25,CommonUtil::GetString(L"IDS_BR_BODY_PD_WEEKS_AGO").GetPointer(),3);
+                               weeksAgo3.Format(25,CommonUtil::GetString(L"IDS_EMAIL_BODY_PD_WEEKS_AGO").GetPointer(),3);
                                pGroupItemClass->SetTitleText(weeksAgo3);
                                dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
                                dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
@@ -1846,3 +1928,12 @@ GroupItemClass::GetHistoryData(void)
 {
        return __pData;
 }
+
+void
+HistoryListForm::OnSettingChanged(Tizen::Base::String& key)
+{
+       if (__pGroupedListView)
+       {
+               __pGroupedListView->UpdateList();
+       }
+}