Fixed Nabi Issues: 53721,53372,53761,53768
[apps/osp/Internet.git] / src / IntBookmarkListForm.cpp
index a78af94..cd13765 100644 (file)
@@ -43,8 +43,8 @@ using namespace Tizen::Ui::Scenes;
 using namespace Tizen::Media;
 
 const wchar_t* DEFAULT_VALUE_PARENTID = L"0";
-static const wchar_t* IDB_TAB_ICON_BOOKMARK = 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_TAB_ICON_BOOKMARK = 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_NO_CONTENT_BOOKMARK = L"I01_Nocontents_Bookmarks.png";
 static const wchar_t* IDB_ICON_FOLDER_OPEN = L"I01_icon_folder_open.png";
 
@@ -135,8 +135,6 @@ BookmarkListForm::OnInitializing(void)
        result r = E_SUCCESS;
        HeaderItem bookmark;
        HeaderItem history;
-       Bitmap *pBitmapNormal = null;
-       Bitmap *pBitmapPressed = null;
        Header *pHeader = GetHeader();
        Bitmap *pIconBitmap = null;
        AppResource* pAppResource = UiApp::GetInstance()->GetAppResource();
@@ -163,45 +161,22 @@ BookmarkListForm::OnInitializing(void)
        __pItemContextFolder = new(std::nothrow) ListContextItem();
        __pItemContextFolder->Construct();
        __pItemContextFolder->AddElement(IDA_CONTEXT_ITEM_FOLDER_EDIT, CommonUtil::GetString(L"IDS_BR_SK_EDIT"));
-       pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_TWO_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
-       pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_TWO_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
 
-       if (pBitmapNormal != null && pBitmapPressed != null)
-       {
-               __pItemContextFolder->AddElement(IDA_CONTEXT_ITEM_FOLDER_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"),  *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
-       }
-
-       if (pBitmapNormal != null)
-       {
-               delete pBitmapNormal;
-       }
-
-       if (pBitmapPressed != null)
-       {
-               delete pBitmapPressed;
-       }
+       __pItemContextFolder->AddElement(IDA_CONTEXT_ITEM_FOLDER_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), true);
+       __pItemContextFolder->SetElementBackgroundColor(IDA_CONTEXT_ITEM_FOLDER_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
+       __pItemContextFolder->SetElementBackgroundColor(IDA_CONTEXT_ITEM_FOLDER_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
+       __pItemContextFolder->SetElementBackgroundColor(IDA_CONTEXT_ITEM_FOLDER_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
 
        __pItemContextSite = new(std::nothrow) ListContextItem();
        __pItemContextSite->Construct();
        __pItemContextSite->AddElement(IDA_CONTEXT_ITEM_EDIT, CommonUtil::GetString(L"IDS_BR_SK_EDIT"));
        __pItemContextSite->AddElement(IDA_CONTEXT_ITEM_SHARE, CommonUtil::GetString(L"IDS_BR_OPT_SHARE"));
-       pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_THREE_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
-       pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_THREE_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
 
-       if (pBitmapNormal != null && pBitmapPressed != null)
-       {
-               __pItemContextSite->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
-       }
+       __pItemContextSite->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), true);
+       __pItemContextSite->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
+       __pItemContextSite->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
+       __pItemContextSite->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
 
-       if (pBitmapNormal != null)
-       {
-               delete pBitmapNormal;
-       }
-
-       if (pBitmapPressed != null)
-       {
-               delete pBitmapPressed;
-       }
        __pListview = static_cast< ListView* >(GetControl("IDC_LISTVIEW1"));
 
        if (__pListview == null)
@@ -215,8 +190,10 @@ BookmarkListForm::OnInitializing(void)
                return E_FAILURE;
        }
 
+       __pSearchBar->AddFocusEventListener(*this);
        if (__pListview != null)
        {
+               __pListview->SetBackgroundColor(GetBackgroundColor());
                //              __pListview->SetBounds(__pListview->GetX(), __pListview->GetY(), GetClientAreaBounds().width, GetClientAreaBounds().height);
                __pListview->AddFastScrollListener(*this);
                __pListview->AddListViewItemEventListener(*this);
@@ -229,7 +206,7 @@ BookmarkListForm::OnInitializing(void)
        if (__pPopUp != null)
        {
                __pPopUp->Initialize();
-               AddControl(__pPopUp);
+//             AddControl(__pPopUp);
        }
 
        __pSearchListView = new(std::nothrow) ListView();
@@ -357,8 +334,8 @@ BookmarkListForm::OnActionPerformed(const Tizen::Ui::Control& source, int action
        break;
        case IDA_TABBAR_ITEM_2:
        {
-               GetHeader()->SetItemSelected(0);
-               GetHeader()->Invalidate(true);
+       //      GetHeader()->SetItemSelected(0);
+       //      GetHeader()->Invalidate(true);
 
                SceneManager* pSceneManager = SceneManager::GetInstance();
 
@@ -375,7 +352,7 @@ BookmarkListForm::OnActionPerformed(const Tizen::Ui::Control& source, int action
                        else
                        {
 
-                               if(pSceneManager->GoBackward(BackwardSceneTransition())!= E_SUCCESS)
+                               if(pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT))!= E_SUCCESS)
                                {
                                        AppLogDebug("BookmarkListForm::OnActionPerformed GoBackward failed");
                                        return;
@@ -575,7 +552,7 @@ BookmarkListForm::CreateItem(int index, int itemWidth)
        const int width_Icon = 72 ;
        const int x_Margin_Title = 104 ;
        const int y_Margin_Title = 10;
-       const int width_Title = GetClientAreaBounds().width - 108 - 52 - 30;
+       const int width_Title = GetClientAreaBounds().width - 108 - 52 - 40;
        const int x_Margin_Url = 104 ;
        const int y_Margin_Url = 70 ;
        const int width_Url = GetClientAreaBounds().width - 108 - 52 ;
@@ -604,7 +581,7 @@ BookmarkListForm::CreateItem(int index, int itemWidth)
                        delete pBitmap;
                }
 
-               pItem->AddElement(Rectangle(x_Margin_Title, 26, width_Title, 60 + (__fontSize - 44) ), IDA_FORMAT_FOLDER, pBookMark->GetBookmarkTitle(),__fontSize, CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,true);
+               pItem->AddElement(Rectangle(x_Margin_Title, 26, width_Title, 72 + (__fontSize - 44) ), IDA_FORMAT_FOLDER, pBookMark->GetBookmarkTitle(),__fontSize, CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,true);
 
                if ( __pItemContextFolder != NULL)
                {
@@ -667,7 +644,7 @@ BookmarkListForm::CreateItem(int index, int itemWidth)
 //             if(__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
 //                     pItem->AddElement(Rectangle(x_Margin_Url, y_Margin_Url, width_Url, height_Url), IDA_FORMAT_URL, pBookMark->GetUrl(),textSize,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,true);
 //             else
-                       pItem->AddElement(Rectangle(x_Margin_Url, y_Margin_Url - 44 + __fontSize, width_Url, height_Url), IDA_FORMAT_URL, pBookMark->GetUrl(),textSize,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,true);
+                       pItem->AddElement(Rectangle(x_Margin_Url, y_Margin_Url - 44 + __fontSize, width_Url, height_Url), IDA_FORMAT_URL, pBookMark->GetUrl(),textSize,CUSTOM_COLOR_GREY,CUSTOM_COLOR_LISTVIEW_TEXT,CUSTOM_COLOR_LISTVIEW_TEXT,true);
 
                if (pBitmap != null)
                {
@@ -720,11 +697,16 @@ BookmarkListForm::GetItemCount(void)
        }
        else
        {
+               if (__searchText.GetLength() > 0)
+               {
+                       __searchText.Replace(L"%", L"/%");
+                       __searchText.Replace(L"_", L"/_");
+               }
                BookmarkPresentationModel::GetInstance()->GetSearchFolderBookmarkCount(count,__searchText);
                BookmarkPresentationModel::GetInstance()->GetSearchFoldersBookmarks(0, count, *__pData, __searchText);
        }
 
-       AppLogDebug("Count = %d parentId = %ls", count, __parentID.GetPointer());
+       AppLogDebug("Count = %d parentId = %ls __searchText %ls", count, __parentID.GetPointer() , __searchText.GetPointer());
 
        if (count <= 0)
        {
@@ -884,7 +866,13 @@ BookmarkListForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListVie
        case IDA_CONTEXT_ITEM_SHARE:
        {
                AppLogDebug("OnListViewContextItemStateChanged Share");
-
+               if (__pPopUp != null)
+               {
+                       delete __pPopUp;
+                       __pPopUp = null;
+               }
+               __pPopUp = new(std::nothrow) SharePopup();
+               __pPopUp->Initialize();
                BookmarkData* pBookmark = dynamic_cast<BookmarkData*>(__pData->GetAt(index));
                if (pBookmark != null)
                {
@@ -896,11 +884,9 @@ BookmarkListForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListVie
                        __pPopUp->AddShareInfo(pShareInfo);
                }
 
-               if (__pPopUp != null)
-               {
-                       __pPopUp->SetShowState(true);
-                       __pPopUp->Show();
-               }
+               __pPopUp->SetShowState(true);
+               __pPopUp->Show();
+
        }
        break;
        default:
@@ -1007,6 +993,19 @@ BookmarkListForm::OnFastScrollIndexSelected(Tizen::Ui::Control& source, Tizen::B
 }
 
 void
+BookmarkListForm::OnFocusGained(const Tizen::Ui::Control& source)
+{
+       __pSearchListView->SetEnabled(false);
+}
+
+void
+BookmarkListForm::OnFocusLost(const Tizen::Ui::Control& source)
+{
+       __pSearchListView->SetEnabled(true);
+       __searchBookmark = false;
+}
+
+void
 BookmarkListForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
 {
        result r = E_FAILURE;
@@ -1036,7 +1035,6 @@ BookmarkListForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source,
                        r = __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
                        __pSearchBar->SetText(L"");
                }
-               AppLog("OnSearchBarModeChanged SetContentAreaSize heihgt %d, %d",__pSearchListView->GetHeight() , GetClientAreaBounds().height - __pSearchBar->GetHeight());
                 __pListview->UpdateList();
                __pSearchListView->UpdateList();
        }
@@ -1058,7 +1056,6 @@ BookmarkListForm::OnKeypadOpened(Tizen::Ui::Control& source)
 {
        AppLog("ABCD::BookmarkListForm::OnKeypadOpened");
        GetFooter()->SetShowState(false);
-       AppLog("ABCD::BookmarkListForm::OnKeypadOpened");
        __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
        __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
        Invalidate(true);
@@ -1103,7 +1100,7 @@ BookmarkListForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui:
                }
 
                __searchText = __pSearchBar->GetText();
-               AppLog("SearchbarGettext result %s",GetErrorMessage(GetLastResult()));
+               AppLog("SearchbarGettext result %s %ls",GetErrorMessage(GetLastResult()),__searchText.GetPointer());
                __searchBookmark = true;
                __pListview->SetShowState(false);
                __pSearchListView->SetEnabled(true);
@@ -1119,9 +1116,10 @@ BookmarkListForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui:
 void
 BookmarkListForm::OnKeypadBoundsChanged(Tizen::Ui::Control& source)
 {
+       AppLog("ABCD::BookmarkListForm::OnKeypadBoundsChanged");
        FloatRectangle clientRect;
        clientRect = GetClientAreaBoundsF();
-       AppLogDebug("SearchBarForm::OnKeypadBoundsChanged ClientBounds(%f, %f, %f, %f)",clientRect.x, clientRect.y, clientRect.width, clientRect.height);
+       AppLogDebug("ABCD::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()));
        __pListview->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
@@ -1150,6 +1148,12 @@ BookmarkListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneI
                __previousSceneId = previousSceneId;
        }*/
 
+       if (pList)
+       {
+               delete pList;
+               pList = null;
+       }
+
        if (__pListview != null)
        {
                __pListview->UpdateList();
@@ -1162,8 +1166,14 @@ void
 BookmarkListForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
 {
        AppLog("BookmarkListForm::OnOrientationChanged start");
-       __pListview->SetBackgroundColor(GetBackgroundColor());
-       __pSearchListView->SetBackgroundColor(GetBackgroundColor());
+       if (__pListview)
+       {
+               __pListview->SetBackgroundColor(GetBackgroundColor());
+       }
+       if (__pSearchListView)
+       {
+               __pSearchListView->SetBackgroundColor(GetBackgroundColor());
+       }
        if (__pListview)
        {
                if(__pSearchBar->GetShowState())
@@ -1174,7 +1184,7 @@ BookmarkListForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen:
                {
                        __pListview->SetBounds(__pListview->GetX(),0,GetClientAreaBounds().width ,GetClientAreaBounds().height);
                }
-               __pListview->UpdateList();
+
        }
 
        if (__pSearchListView && __pListview)
@@ -1219,3 +1229,18 @@ BookmarkListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneI
        return;
 }
 
+void
+BookmarkListForm::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;
+               }
+       }
+}