+++ /dev/null
-//
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.
-//
-// 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
-//
-// http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-//!Internet
-/*@file: IntBookmarkListForm
- *@brief: This class defines BookmarkListForm
- *
- */
-
-#include <FApp.h>
-#include "IntBookmarkData.h"
-#include "IntBookmarkListForm.h"
-#include "IntBookmarkPresentationModel.h"
-#include "IntCommonLib.h"
-#include "IntConfirmationPopup.h"
-#include "IntFaviconManager.h"
-#include "IntMultipleWindowPresentationModel.h"
-#include "IntSceneRegister.h"
-#include "IntTypes.h"
-
-
-using namespace Tizen::App;
-using namespace Tizen::Base;
-using namespace Tizen::Base::Collection;
-using namespace Tizen::Base::Runtime;
-using namespace Tizen::Graphics;
-using namespace Tizen::Ui;
-using namespace Tizen::Ui::Controls;
-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_NO_CONTENT_BOOKMARK = L"I01_Nocontents_Bookmarks.png";
-static const wchar_t* IDB_ICON_FOLDER_OPEN = L"I01_icon_folder_open.png";
-
-const int BookmarkListForm::IDA_TABBAR_ITEM_1 = 101;
-const int BookmarkListForm::IDA_TABBAR_ITEM_2 = 102;
-const int BookmarkListForm::IDA_FOOTER_ITEM1 = 103;
-const int BookmarkListForm::IDA_FOOTER_ITEM2 = 104;
-const int BookmarkListForm::IDA_FOOTER_ITEM_ADDBOOKMARK = 105;
-const int BookmarkListForm::IDA_FORMAT_FOLDER = 106;
-const int BookmarkListForm::IDA_FORMAT_SITE = 107;
-const int BookmarkListForm::IDA_CONTEXT_ITEM_FOLDER_EDIT = 108;
-const int BookmarkListForm::IDA_CONTEXT_ITEM_FOLDER_DELETE = 109;
-const int BookmarkListForm::IDA_CONTEXT_ITEM_EDIT = 110;
-const int BookmarkListForm::IDA_CONTEXT_ITEM_SHARE = 111;
-const int BookmarkListForm::IDA_CONTEXT_ITEM_DELETE = 112;
-const int BookmarkListForm::IDA_FORMAT_ICON = 113;
-const int BookmarkListForm::IDA_FORMAT_URL = 114;
-
-//const int BookmarkListForm::IDA_CONFIRMATION_NO = 1000;
-//const int BookmarkListForm::IDA_CONFIRMATION_YES = 1001;
-
-BookmarkListForm::BookmarkListForm(void)
-{
- __pItemContextFolder = null ;
- __pItemContextSite = null ;
- __pListview = null;
- __pData = null;
- __pSearchListView = null;
- __pSearchBar = null;
- __searchBookmark = false;
- __parentID = DEFAULT_VALUE_PARENTID;
- __noBookmarks = true;
- __selectedindex = 0;
- __searchText = L"";
- __previousSceneId = L"";
- __fontSize = 44;
-}
-
-BookmarkListForm::~BookmarkListForm(void)
-{
-
- if (__pData != null)
- {
- __pData->RemoveAll(true);
- delete __pData;
- __pData = NULL;
- }
-
- if (__pItemContextFolder != null)
- {
- delete __pItemContextFolder;
- __pItemContextFolder = null;
- }
-
- if (__pItemContextSite != null)
- {
- delete __pItemContextSite;
- __pItemContextSite = null;
- }
-}
-
-result
-BookmarkListForm::OnTerminating(void)
-{
- result r = E_SUCCESS;
-
- if (__pData != null)
- {
- __pData->RemoveAll(true);
- delete __pData;
- __pData = NULL;
- }
-
- return r;
-}
-
-
-bool
-BookmarkListForm::Initialize(void)
-{
- Construct(L"IDL_BOOKMARK_LIST");
- return true;
-}
-
-result
-BookmarkListForm::OnInitializing(void)
-{
- result r = E_SUCCESS;
- HeaderItem bookmark;
- HeaderItem history;
- Header *pHeader = GetHeader();
- Bitmap *pIconBitmap = null;
- AppResource* pAppResource = UiApp::GetInstance()->GetAppResource();
- int bookmarkCount = 0;
- const int WIDTH_CONTEXT_MENU_TWO_BUTTON = 336;
- const int WIDTH_CONTEXT_MENU_THREE_BUTTON = 160;
- const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
-
-
- // Setup back event listener
- SetFormBackEventListener(this);
- AddOrientationEventListener(*this);
-
- SceneManager::GetInstance()->AddSceneEventListener(IDSCN_BOOKMARK_VIEW, *this);
- GetHeader()->AddActionEventListener(*this);
- GetFooter()->AddActionEventListener(*this);
-
- if ( pAppResource == NULL )
- {
- return E_FAILURE;
- }
-
- __fontSize = CommonUtil::GetFontSize();
- __pItemContextFolder = new(std::nothrow) ListContextItem();
- __pItemContextFolder->Construct();
- __pItemContextFolder->AddElement(IDA_CONTEXT_ITEM_FOLDER_EDIT, CommonUtil::GetString(L"IDS_BR_SK_EDIT"));
-
- __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"));
-
- __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);
-
- __pListview = static_cast< ListView* >(GetControl("IDC_LISTVIEW1"));
-
- if (__pListview == null)
- {
- return E_FAILURE;
- }
- __pSearchBar = static_cast< SearchBar* >(GetControl(L"IDC_SEARCHBAR1"));
-
- if (__pSearchBar == null)
- {
- 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);
- __pListview->SetItemProvider(*this);
- __pListview->UpdateList();
- }
-
- __pPopUp = new(std::nothrow) SharePopup();
-
- if (__pPopUp != null)
- {
- __pPopUp->Initialize();
-// AddControl(__pPopUp);
- }
-
- __pSearchListView = new(std::nothrow) ListView();
-
- if (__pSearchListView == null)
- {
- return E_FAILURE;
- }
-
- r = __pSearchListView->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height -72), true, false);
- TryCatch( !IsFailed(r),,"BookmarkListForm::OnSearchBarModeChanged Update list failed %s",GetErrorMessage(r));
-
- __pSearchListView->SetBackgroundColor(GetBackgroundColor());
- __pSearchListView->SetItemProvider(*this);
- __pSearchListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RESULTS_FOUND"));
- __pSearchListView->SetTextColorOfEmptyList(Color::GetColor(COLOR_ID_BLACK));
- __pSearchListView->SetShowState(false);
- __pSearchListView->AddListViewItemEventListener(*this);
-
- __pSearchBar->AddSearchBarEventListener(*this);
- __pSearchBar->AddKeypadEventListener(*this);
- __pSearchBar->SetContent(__pSearchListView);
-
- BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID, bookmarkCount);
- if(bookmarkCount <= 0)
- {
- __pSearchBar->SetShowState(false);
- //__pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pSearchBar->GetWidth(),GetClientAreaBounds().height - __pSearchBar->GetPosition().y);
- __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pListview->GetWidth(),GetClientAreaBounds().height);
- }
- else
- {
- __pSearchBar->SetShowState(true);
- }
-
-
- if (pHeader != null)
- {
- pHeader->SetStyle(HEADER_STYLE_TAB);
- bookmark.Construct(IDA_TABBAR_ITEM_1);
- String strbookmark;
- pAppResource->GetString(L"IDS_BR_TAB_BOOKMARKS", strbookmark);
- bookmark.SetText(strbookmark);
- pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_BOOKMARK);
- bookmark.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);
- bookmark.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
- pHeader->AddItem(bookmark);
-
- if (pIconBitmap != NULL)
- {
- delete pIconBitmap;
- }
-
- history.Construct(IDA_TABBAR_ITEM_2);
- String strhistory;
- pAppResource->GetString(L"IDS_BR_TAB_HISTORY", strhistory);
- history.SetText(strhistory);
- pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_HISTORY);
- history.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);
- history.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
- pHeader->AddItem(history);
- pHeader->SetItemSelected(0);
- pHeader->SetTabEditModeEnabled(false);
-
- if (pIconBitmap != NULL)
- {
- delete pIconBitmap;
- }
- }
-
-
- CATCH:return r;
-}
-
-void
-BookmarkListForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
-{
- AppLogDebug("BookmarkListForm::OnActionPerformed actionId = %d",actionId);
- String bookmarkId;
- int id = 0;
- BookmarkData* pBookMark = null;
-
- switch (actionId)
- {
- case IDA_FOOTER_ITEM1:
- {
- __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
- GetHeader()->SetItemSelected(0);
- GetHeader()->Invalidate(true);
- SceneManager* pSceneManager = SceneManager::GetInstance();
- pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(__selectedindex));
-
- if ( pBookMark == NULL )
- {
- return;
- }
-
- ArrayList* pArgList = null;
- pArgList = new(std::nothrow) ArrayList();
- if (pArgList != null)
- {
- pArgList->Construct();
- pArgList->Add(*new(std::nothrow) String(pBookMark->GetParentId()));
- }
- //pArgList->Add(*new(std::nothrow) String(pBookmark->);
- if (pSceneManager != null)
- {
- if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_EDIT_BOOKMARK_LIST),pArgList) != E_SUCCESS)
- {
- AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
- pArgList->RemoveAll(true);
- delete pArgList;
- pArgList = null;
- return;
- }
- }
-
- if ( pArgList != NULL)
- {
- pArgList->RemoveAll(true);
- delete pArgList;
- }
- }
-
- break;
- case IDA_TABBAR_ITEM_2:
- {
- // GetHeader()->SetItemSelected(0);
- // GetHeader()->Invalidate(true);
-
- SceneManager* pSceneManager = SceneManager::GetInstance();
-
- if (pSceneManager != null)
- {
- if(__previousSceneId.CompareTo(IDSCN_HISTORY_LIST) != 0)
- {
- if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, 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;
- }
-
- }
- }
- }
- break;
- case IDA_FOOTER_ITEM2:
- {
- SceneManager* pSceneManager = SceneManager::GetInstance();
-
- if (pSceneManager)
- {
- if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_BOOKMARK_FOLDER)) != E_SUCCESS)
- {
- AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
- return;
- }
- }
- }
- break;
- case IDA_FOOTER_ITEM_ADDBOOKMARK:
- {
- SceneManager* pSceneManager = SceneManager::GetInstance();
-
- // send array list 0-for add, 1 for edit with parent ID
- ArrayList* pArgList = null;
- pArgList = new(std::nothrow) ArrayList();
- if (pArgList != null)
- {
- pArgList->Construct();
- pArgList->Add(*new(std::nothrow) String(L"0"));
- pArgList->Add(*new(std::nothrow) String(__parentID));
- }
-
- if (pSceneManager)
- {
- if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ADD_BOOKMARK),pArgList) != E_SUCCESS)
- {
- AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
- pArgList->RemoveAll(true);
- delete pArgList;
- return;
- }
- }
-
- if (pArgList != null)
- {
- pArgList->RemoveAll(true);
- delete pArgList;
- }
-
- }
- break;
- case IDA_BUTTON_NO:
- __pConfirmationPopup->SetShowState(false);
- __pConfirmationPopup->Show();
- break;
- case IDA_BUTTON_YES:
- pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(__selectedindex));
- if ( pBookMark== null)
- return;
- bookmarkId=pBookMark->GetBookmarkId();
- Integer::Parse(bookmarkId,id);
- if (pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
- BookmarkPresentationModel::GetInstance()->DeleteFolder(id);
- else
- BookmarkPresentationModel::GetInstance()->DeleteBookmark(id);
- if (__pListview == null)
- {
- return;
- }
- AppLogDebug("__pListview GetBounds %d,%d,%d,%d",__pListview->GetBounds().x,__pListview->GetBounds().y,__pListview->GetBounds().width,__pListview->GetBounds().height);
- __pSearchListView->UpdateList();
- __pListview->UpdateList();
-
- if (__pListview->GetItemCount() == 0)
- {
- GetFooter()->SetItemEnabled(1,false);
- __pSearchBar->SetShowState(false);
- __pSearchBar->Invalidate(true);
- }
-
- if (__noBookmarks == true)
- {
- Bitmap* emptyListBmp = AppResource::GetInstance()->GetBitmapN(IDB_NO_CONTENT_BOOKMARK);
- GetFooter()->SetItemEnabled(1,false);
- __pSearchBar->SetShowState(false);
- __pSearchBar->Invalidate(true);
- // __pListview->SetBounds(__pSearchBar->GetPosition().x,__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
- __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
- __pListview->SetBitmapOfEmptyList(emptyListBmp);
- if (emptyListBmp)
- {
- delete emptyListBmp;
- emptyListBmp = null;
- }
- __pListview->UpdateList();
-
- }
- else
- {
- GetFooter()->SetItemEnabled(1,true);
-
- if (__parentID.CompareTo(L"0") == 0)
- {
- __pSearchBar->SetShowState(true);
- __pSearchBar->Invalidate(true);
- }
- }
-
- GetFooter()->Invalidate(true);
- __pConfirmationPopup->SetShowState(false);
- __pConfirmationPopup->Show();
- __selectedindex = 0;
-
- break;
- default:
- break;
- }
-}
-
-void
-BookmarkListForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
-{
- AppLogDebug("BrowserApplicationForm::OnFormBackRequested");
-
- UiApp* pApp = UiApp::GetInstance();
- if (pApp == null)
- {
- return;
- }
-
- if (__parentID != DEFAULT_VALUE_PARENTID)
- {
- __parentID = DEFAULT_VALUE_PARENTID;
- __pSearchBar->SetShowState(true);
- __pListview->SetBounds(__pListview->GetX() ,__pSearchBar->GetPosition().y + __pSearchBar->GetHeight(),__pListview->GetWidth(),GetClientAreaBounds().height - (__pSearchBar->GetY() + __pSearchBar->GetHeight()));
- __pListview->UpdateList();
- __pFooter = GetFooter();
- GetFooter()->SetItemEnabled(2,true);
- GetFooter()->Invalidate(true);
- }
- else
- {
- SceneManager* pSceneManager = SceneManager::GetInstance();
- if (pSceneManager != null)
- {
- if(__previousSceneId.CompareTo(IDSCN_HISTORY_LIST) != 0)
- {
- pSceneManager->GoBackward(BackwardSceneTransition());
- }
- else
- {
- pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
- }
- }
- }
-
- if (__noBookmarks == true)
- {
- GetFooter()->SetItemEnabled(1,false);
- }
- else
- {
- GetFooter()->SetItemEnabled(1,true);
- }
-}
-
-Tizen::Ui::Controls::ListItemBase*
-BookmarkListForm::CreateItem(int index, int itemWidth)
-{
-
- AppLog("BookmarkListForm::CreateItem index %d , itemWidth %d",index, itemWidth);
- AppLog("listviewwidth %d",__pListview->GetWidth());
- result r = E_FAILURE;
- ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
- if(__pData == null)
- {
- return null;
- }
- CustomItem* pItem = new(std::nothrow) CustomItem();
-
- BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
- Bitmap* pBitmap = null;
- Dimension dim;
-
- Image* pImage = null;
- pImage = new Image();
- pImage->Construct();
-
- const int x_Margin_Icon = 16; // local as there used only in this function
- const int y_Margin_Icon = 28;
- const int height_Icon = 72;
- 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 - 40;
- const int x_Margin_Url = 104 ;
- const int y_Margin_Url = 70 ;
- const int width_Url = GetClientAreaBounds().width - 108 - 52 ;
- const int height_Url = 48;
- const int itemHeight = 128;
- const int textSize = 32;
- String bitmapId;
-
- if( pBookMark == NULL )
- {
- delete pItem;
- pItem = null;
- delete pImage;
- pImage = null;
- return NULL;
- }
- if ( pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER )
- {
- r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth,112 - 44 + __fontSize), LIST_ANNEX_STYLE_DETAILED);
- TryCatch(!IsFailed(r),,"BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
-
- pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_FOLDER_OPEN);
- if (pBitmap != null)
- {
- pItem->AddElement(Rectangle(x_Margin_Icon, 20+(__fontSize - 44)/2, width_Icon, height_Icon), IDA_FORMAT_ICON, *pBitmap, null);
- delete pBitmap;
- }
-
- 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)
- {
- pItem->SetContextItem(__pItemContextFolder);
- }
- }
- else
- {
- r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth, itemHeight - 44 + __fontSize), style);
- TryCatch( !IsFailed(r),,"BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
-
- AppLogDebug("BookmarkListForm::faviconid %ls",pBookMark->GetFaviconId().GetPointer());
- bitmapId = pBookMark->GetFaviconId();
-
- dim = Dimension(pBookMark->GetFavIconWidth(), pBookMark->GetFavIconHeight());
-
- AppLog("BookmarkListForm::CreateItem check 0");
-
- // get fav icon bitmap
- ByteBuffer* pFavIconBuffer = null;
- pFavIconBuffer = pBookMark->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");
-
- if (pBitmap != null)
- {
- AppLog("rahul bitmap is not null");
- int width = pBitmap->GetWidth();
- int height = pBitmap->GetHeight();
- AppLog("rahul bitmap width is %d", width);
- AppLog("rahul bitmap height is %d", height);
- AppLog("rahul favicon width is %d", pBookMark->GetFavIconWidth());
- AppLog("rahul favicon height is %d", pBookMark->GetFavIconHeight());
- }
- else
- {
- AppLog("rahul bitmap is null");
- }
-
- if (pBitmap == null)
- {
- AppLogDebug("BookmarkListForm::CreateItem bitmap is null");
- pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
- }
- pItem->AddElement(Rectangle(x_Margin_Icon, y_Margin_Icon +(__fontSize - 44)/2, width_Icon, height_Icon), IDA_FORMAT_ICON, *pBitmap, null);
- pItem->AddElement(Rectangle(x_Margin_Title, 0, width_Title, itemHeight - height_Url - 44 + __fontSize), IDA_FORMAT_SITE, pBookMark->GetBookmarkTitle(),__fontSize,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,true);
-// 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);
-
- if (pBitmap != null)
- {
- delete pBitmap;
- }
- if ( __pItemContextSite != NULL)
- {
- pItem->SetContextItem(__pItemContextSite);
- }
- }
-
- delete pImage;
- return pItem;
-
- CATCH:
-
- delete pImage;
- delete pItem;
- pItem = null;
- return null;
-
-}
-
-bool
-BookmarkListForm::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
-{
- delete pItem;
- pItem = null;
- return true;
-}
-
-int
-BookmarkListForm::GetItemCount(void)
-{
- int count = 0;
-
- if (__pData != NULL )
- {
- __pData->RemoveAll(true);
- delete __pData;
- __pData = null;
- }
- __pData = new(std::nothrow) Collection::ArrayList();
- __pData->Construct();
-
- if (__searchBookmark == false)
- {
- BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID, count);
- BookmarkPresentationModel::GetInstance()->GetFoldersBookmarks(__parentID, 0, count, *__pData);
- }
- 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 __searchText %ls", count, __parentID.GetPointer() , __searchText.GetPointer());
-
- if (count <= 0)
- {
- __noBookmarks = true;
- GetFooter()->SetItemEnabled(1,false);
- }
- else
- {
- __noBookmarks = false;
- GetFooter()->SetItemEnabled(1,true);
- }
-
- AppLogDebug("Result: %s", GetErrorMessage(GetLastResult()));
- GetFooter()->Invalidate(true);
- if (__pData != null && __pData->GetCount() >= 1)
- {
- // __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
- __pSearchBar->SetShowState(true);
- __pSearchBar->Invalidate(true);
- }
- else if (__searchBookmark == false)
- {
- __pSearchBar->SetShowState(false);
- __pSearchBar->Invalidate(true);
- }
-
- if (__parentID.CompareTo(L"0") != 0)
- {
- __pSearchBar->SetShowState(false);
- __pSearchBar->Invalidate(true);
- }
- if (__noBookmarks == true)
- {
- __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
- Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_NO_CONTENT_BOOKMARK);
-
- if ( pBitmap != NULL)
- {
- __pListview->SetBitmapOfEmptyList(pBitmap);
- delete pBitmap;
- }
- }
- else
- {
- if (__parentID.CompareTo(L"0") == 0)
- {
- __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetHeight(),GetClientAreaBounds().width ,GetClientAreaBounds().height - __pSearchBar->GetY() - __pSearchBar->GetHeight());
- }
- else
- {
- __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
-
- }
-
- }
- __pListview->Invalidate(true);
- return count;
-
-}
-
-void
-BookmarkListForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
-{
- AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged int index %d, int elementId %d, Tizen::Ui::Controls::ListContextItemStatus status %d",index,elementId,status);
-
- String deleteText = CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB");
- deleteText.Append(L"? ");
- int timeOut = 25000;
- result r = E_SUCCESS;
-
- switch(elementId)
- {
- case IDA_CONTEXT_ITEM_FOLDER_EDIT:
- {
- ArrayList* pArgList = null;
- String* pEdit = null;
-
- SceneManager* pSceneManager = SceneManager::GetInstance();
- BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
- if (pBookMark != null && pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
- {
- pArgList = new(std::nothrow) ArrayList();
- if (pArgList != null)
- {
- pEdit= new(std::nothrow) String(CommonUtil::GetString(L"IDS_BR_SK_EDIT"));
- pArgList->Construct();
- pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
- pArgList->Add(*pEdit);
- if ( pSceneManager != null)
- {
- result r;
- r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_BOOKMARK_FOLDER), pArgList);
- }
-
- if (pArgList != null)
- {
- delete pArgList;
- pArgList = null;
- }
- if(IsFailed(r))
- {
- AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged GoForward failed %s",GetErrorMessage(r));
- return;
- }
- }
- }
-
- }
- break;
-
- case IDA_CONTEXT_ITEM_FOLDER_DELETE:
- case IDA_CONTEXT_ITEM_DELETE:
- {
- __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
- __pConfirmationPopup->Initialize();
- __pConfirmationPopup->RemoveActionListener(*this);
- __pConfirmationPopup->AddActionListener(*this);
- __pConfirmationPopup->setMessage(deleteText);
- __pConfirmationPopup->Show();
- __selectedindex = index;
- }
- break;
-
- case IDA_CONTEXT_ITEM_EDIT:
- {
- ArrayList* pArgList = null;
- SceneManager* pSceneManager = SceneManager::GetInstance();
- BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
- if (pBookMark!= null && pBookMark->GetBookmarkType() == BOOKMARK_TYPE_URL)
- {
- AppLogDebug("ID_CONTEXT_ITEM_SITE_1 BOOKMARK_TYPE_URL");
- pArgList = new(std::nothrow) ArrayList();
- if (pArgList != null)
- {
- pArgList->Construct();
- pArgList->Add(*new(std::nothrow) String(L"1"));
- pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
- if ( pSceneManager != null)
- {
- result r;
- r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ADD_BOOKMARK), pArgList);
- if (pArgList != null)
- {
- delete pArgList;
- pArgList = null;
- }
- if(IsFailed(r))
- {
- AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged GoForward failed %s",GetErrorMessage(r));
- return;
- }
- }
- }
- }
- }
- break;
- 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)
- {
- ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
- pShareInfo->SetPageTitle(pBookmark->GetBookmarkTitle());
- pShareInfo->SetPageUrl(pBookmark->GetUrl());
- pShareInfo->SetImageAttached(false);
- __pPopUp->RemoveAllShareInfo();
- __pPopUp->AddShareInfo(pShareInfo);
- }
-
- if (__pPopUp != null)
- {
- __pPopUp->SetShowState(true);
- __pPopUp->Show();
- }
- }
- break;
- default:
- break;
- }
-
-}
-
-void
-BookmarkListForm::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
-{
-
-}
-
-void
-BookmarkListForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
-{
- AppLogDebug("BookmarkListForm::OnListViewItemStateChanged");
-
- result r = E_FAILURE;
- ArrayList *pArgList = null;
- SceneManager* pSceneManager = SceneManager::GetInstance();
- BookmarkData* pBookmark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
-
- if ( pBookmark == NULL )
- {
- return;
- }
-
- switch (pBookmark->GetBookmarkType())
- {
- case BOOKMARK_TYPE_FOLDER:
-
- __parentID = pBookmark->GetBookmarkId();
- AppLogDebug("BOOKMARK_TYPE_FOLDER parent ID is %ls",__parentID.GetPointer());
-
- listView.UpdateList();
- if (listView.GetItemCount() == 0)
- {
- GetFooter()->SetItemEnabled(1,false);
- }
- else
- {
- GetFooter()->SetItemEnabled(1,true);
- }
- GetFooter()->SetItemEnabled(2,false);
- GetFooter()->Invalidate(true);
- __pSearchBar->HideKeypad();
- __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
- __pSearchBar->SetShowState(false);
- __pSearchBar->Invalidate(true);
- __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pListview->GetWidth() ,GetClientAreaBounds().height);
- break;
-
- case BOOKMARK_TYPE_URL:
-
- pArgList = new(std::nothrow) ArrayList();
- if (pArgList != null)
- {
- r = pArgList->Construct();
- TryCatch(!IsFailed(r), L"BookmarkListForm::OnListViewItemStateChanged pArgList Construct failed %s", GetErrorMessage(r));
-
- AppLogDebug("bookmark url = %ls",pBookmark->GetUrl().GetPointer());
- r = pArgList->Add(*MultipleWindowPresentationModel::GetInstance()->GetActiveWindowInfo());
- pArgList->Add(*new(std::nothrow) String(pBookmark->GetUrl()));
-
- if (pSceneManager != null)
- {
- AppLogDebug("pSceneManager exists");
- String prevSceneId;
- MultipleWindowPresentationModel::GetInstance()->GetCurrentSceneId(prevSceneId);
- r = pSceneManager->GoBackward(BackwardSceneTransition(prevSceneId), pArgList);
- TryCatch(!IsFailed(r), L"BookmarkListForm::OnListViewItemStateChanged pArgList Construct failed %s", GetErrorMessage(r));
- }
- delete pArgList;
- }
- break;
-
- default:
- break;
- }
-
- return;
- CATCH:
- if(pArgList)
- {
- pArgList->RemoveAll(true);
- delete pArgList;
- }
-
-}
-
-void
-BookmarkListForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
-{
-
-
-}
-
-void
-BookmarkListForm::OnFastScrollIndexSelected(Tizen::Ui::Control& source, Tizen::Base::String& index)
-{
-
-}
-
-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;
- AppLog("ABCD::BookmarkListForm::OnSearchBarModeChanged");
-
- if (mode == SEARCH_BAR_MODE_NORMAL)
- {
- __pSearchListView->SetShowState(false);
- __pSearchListView->UpdateList();
- __pListview->SetShowState(true);
- Invalidate(true);
- __searchBookmark = false;
- r = __pListview->UpdateList();
-// __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
- __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
- TryCatch( !IsFailed(r),,"BookmarkListForm::OnSearchBarModeChanged Update list failed %s",GetErrorMessage(r));
- CATCH:return;
- }
- else
- {
- __pSearchListView->SetShowState(true);
- __pSearchListView->SetEnabled(false);
- __pListview->SetShowState(false);
-
- if(__pSearchBar)
- {
- 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();
- }
-}
-
-void
-BookmarkListForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
-{
- AppLog("ABCD::BookmarkListForm::OnKeypadWillOpen");
- GetFooter()->SetShowState(false);
- __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight());
- __pSearchListView->SetEnabled(false);
- __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
- Invalidate(true);
-}
-
-void
-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);
-}
-
-void
-BookmarkListForm::OnKeypadClosed(Tizen::Ui::Control& source)
-{
- AppLog("ABCD::BookmarkListForm::OnKeypadClosed");
- AppLog("jahsjkdad %d",Clipboard::GetInstance()->IsPopupVisible());
- if(Clipboard::GetInstance()->IsPopupVisible() == 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()));
- __pListview->SetBounds(0, __pSearchBar->GetY() + __pSearchBar->GetHeight(), GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight());
- Invalidate(true);
-}
-
-void
-BookmarkListForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
-{
- AppLog("BookmarkListForm::OnKeypadActionPerformed %d",keypadAction);
-
- if (__pSearchBar != null)
- {
- __pSearchBar->HideKeypad();
- }
- if ( __pSearchBar != null && keypadAction == KEYPAD_ACTION_SEARCH)
- {
-// if (__pSearchBar->GetText().GetLength() == 0)
-// {
-// return;
-// }
-
- if (__pSearchBar != null)
- {
- __pSearchBar->HideKeypad();
- }
-
- __searchText = __pSearchBar->GetText();
- AppLog("SearchbarGettext result %s %ls",GetErrorMessage(GetLastResult()),__searchText.GetPointer());
- __searchBookmark = true;
- __pListview->SetShowState(false);
- __pSearchListView->SetEnabled(true);
- __pSearchListView->SetShowState(true);
- __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
- __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
- __pSearchListView->UpdateList();
-
- }
- Invalidate(true);
-}
-
-void
-BookmarkListForm::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()));
- __pListview->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
-// __pListview->SetEnabled(false);
- Invalidate(true);
-}
-
-void
-BookmarkListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
-{
- AppLogDebug("BookmarkListForm::OnSceneActivatedN called");
- ArrayListT<String> * pList = dynamic_cast<ArrayListT<String>* >(SceneManager::GetInstance()->GetSceneHistoryN());
- if(pList != null)
- {
- pList->GetAt(pList->GetCount()-1,__previousSceneId);
- }
-
- __searchBookmark = false;
- GetFooter()->SetShowState(true);
- GetFooter()->Invalidate(true);
- GetHeader()->SetItemSelected(0);
- GetHeader()->Invalidate(true);
-
- /* if (previousSceneId != IDSCN_HISTORY_LIST && previousSceneId != IDSCN_CREATE_BOOKMARK_FOLDER && previousSceneId != IDSCN_EDIT_BOOKMARK_LIST)
- {
- __previousSceneId = previousSceneId;
- }*/
-
- if (pList)
- {
- delete pList;
- pList = null;
- }
-
- if (__pListview != null)
- {
- __pListview->UpdateList();
- }
-
- return;
-}
-
-void
-BookmarkListForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
-{
- AppLog("BookmarkListForm::OnOrientationChanged start");
- __pListview->SetBackgroundColor(GetBackgroundColor());
- __pSearchListView->SetBackgroundColor(GetBackgroundColor());
- if (__pListview)
- {
- if(__pSearchBar->GetShowState())
- {
- __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetHeight(),GetClientAreaBounds().width ,GetClientAreaBounds().height - __pSearchBar->GetY() - __pSearchBar->GetHeight());
- }
- else
- {
- __pListview->SetBounds(__pListview->GetX(),0,GetClientAreaBounds().width ,GetClientAreaBounds().height);
- }
- __pListview->UpdateList();
- }
-
- if (__pSearchListView && __pListview)
- {
- AppLog("__pListview->GetBounds() %d, %d, %d, %d",__pListview->GetBounds().x,__pListview->GetBounds().y,__pListview->GetBounds().width,__pListview->GetBounds().height);
- __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
-
- __pSearchListView->UpdateList();
- }
-
- if (__pSearchListView && __pData != null )
- {
- if (__parentID != DEFAULT_VALUE_PARENTID)
- {
- AppLog("BookmarkListForm::OnOrientationChanged parent id true");
- __pSearchBar->SetShowState(false);
- __pSearchBar->Invalidate(true);
- }
-
- __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
- }
-
-//
-//
-//
-// FloatRectangle clientRect;
-// clientRect = GetClientAreaBoundsF();
-//
-// __pSearchBar->SetContentAreaSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
-// __pListview->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
-// __pSearchListView->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
-// Invalidate(true);
-//
-
- Invalidate(true);
-}
-
-void
-BookmarkListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
-{
- __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
- return;
-}
-