2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 /*@file: IntBookmarkListForm
19 *@brief: This class defines BookmarkListForm
24 #include "IntBookmarkData.h"
25 #include "IntBookmarkListForm.h"
26 #include "IntBookmarkPresentationModel.h"
27 #include "IntCommonLib.h"
28 #include "IntConfirmationPopup.h"
29 #include "IntFaviconManager.h"
30 #include "IntMultipleWindowPresentationModel.h"
31 #include "IntSceneRegister.h"
35 using namespace Tizen::App;
36 using namespace Tizen::Base;
37 using namespace Tizen::Base::Collection;
38 using namespace Tizen::Base::Runtime;
39 using namespace Tizen::Graphics;
40 using namespace Tizen::Ui;
41 using namespace Tizen::Ui::Controls;
42 using namespace Tizen::Ui::Scenes;
43 using namespace Tizen::Media;
45 const wchar_t* DEFAULT_VALUE_PARENTID = L"0";
46 static const wchar_t* IDB_TAB_ICON_BOOKMARK = L"I01_tab_icon_bookmarks.png";
47 static const wchar_t* IDB_TAB_ICON_HISTORY = L"I01_tab_icon_history.png";
48 static const wchar_t* IDB_NO_CONTENT_BOOKMARK = L"I01_Nocontents_Bookmarks.png";
49 static const wchar_t* IDB_ICON_FOLDER_OPEN = L"I01_icon_folder_open.png";
51 const int BookmarkListForm::IDA_TABBAR_ITEM_1 = 101;
52 const int BookmarkListForm::IDA_TABBAR_ITEM_2 = 102;
53 const int BookmarkListForm::IDA_FOOTER_ITEM1 = 103;
54 const int BookmarkListForm::IDA_FOOTER_ITEM2 = 104;
55 const int BookmarkListForm::IDA_FOOTER_ITEM_ADDBOOKMARK = 105;
56 const int BookmarkListForm::IDA_FORMAT_FOLDER = 106;
57 const int BookmarkListForm::IDA_FORMAT_SITE = 107;
58 const int BookmarkListForm::IDA_CONTEXT_ITEM_FOLDER_EDIT = 108;
59 const int BookmarkListForm::IDA_CONTEXT_ITEM_FOLDER_DELETE = 109;
60 const int BookmarkListForm::IDA_CONTEXT_ITEM_EDIT = 110;
61 const int BookmarkListForm::IDA_CONTEXT_ITEM_SHARE = 111;
62 const int BookmarkListForm::IDA_CONTEXT_ITEM_DELETE = 112;
63 const int BookmarkListForm::IDA_FORMAT_ICON = 113;
64 const int BookmarkListForm::IDA_FORMAT_URL = 114;
66 //const int BookmarkListForm::IDA_CONFIRMATION_NO = 1000;
67 //const int BookmarkListForm::IDA_CONFIRMATION_YES = 1001;
69 BookmarkListForm::BookmarkListForm(void)
71 __pItemContextFolder = null ;
72 __pItemContextSite = null ;
75 __pSearchListView = null;
77 __searchBookmark = false;
78 __parentID = DEFAULT_VALUE_PARENTID;
82 __previousSceneId = L"";
85 BookmarkListForm::~BookmarkListForm(void)
90 __pData->RemoveAll(true);
95 if (__pItemContextFolder != null)
97 delete __pItemContextFolder;
98 __pItemContextFolder = null;
101 if (__pItemContextSite != null)
103 delete __pItemContextSite;
104 __pItemContextSite = null;
109 BookmarkListForm::OnTerminating(void)
111 result r = E_SUCCESS;
115 __pData->RemoveAll(true);
125 BookmarkListForm::Initialize(void)
127 Construct(L"IDL_BOOKMARK_LIST");
132 BookmarkListForm::OnInitializing(void)
134 result r = E_SUCCESS;
137 Bitmap *pBitmapNormal = null;
138 Bitmap *pBitmapPressed = null;
139 Header *pHeader = GetHeader();
140 Bitmap *pIconBitmap = null;
141 AppResource* pAppResource = UiApp::GetInstance()->GetAppResource();
142 int bookmarkCount = 0;
143 const int WIDTH_CONTEXT_MENU_TWO_BUTTON = 336;
144 const int WIDTH_CONTEXT_MENU_THREE_BUTTON = 160;
145 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
148 // Setup back event listener
149 SetFormBackEventListener(this);
150 AddOrientationEventListener(*this);
152 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_BOOKMARK_VIEW, *this);
153 GetHeader()->AddActionEventListener(*this);
154 GetFooter()->AddActionEventListener(*this);
156 if ( pAppResource == NULL )
161 __pItemContextFolder = new(std::nothrow) ListContextItem();
162 __pItemContextFolder->Construct();
163 __pItemContextFolder->AddElement(IDA_CONTEXT_ITEM_FOLDER_EDIT, CommonUtil::GetString(L"IDS_BR_SK_EDIT"));
164 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_TWO_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
165 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_TWO_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
167 if (pBitmapNormal != null && pBitmapPressed != null)
169 __pItemContextFolder->AddElement(IDA_CONTEXT_ITEM_FOLDER_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
172 if (pBitmapNormal != null)
174 delete pBitmapNormal;
177 if (pBitmapPressed != null)
179 delete pBitmapPressed;
182 __pItemContextSite = new(std::nothrow) ListContextItem();
183 __pItemContextSite->Construct();
184 __pItemContextSite->AddElement(IDA_CONTEXT_ITEM_EDIT, CommonUtil::GetString(L"IDS_BR_SK_EDIT"));
185 __pItemContextSite->AddElement(IDA_CONTEXT_ITEM_SHARE, CommonUtil::GetString(L"IDS_BR_OPT_SHARE"));
186 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_THREE_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
187 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_THREE_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
189 if (pBitmapNormal != null && pBitmapPressed != null)
191 __pItemContextSite->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
194 if (pBitmapNormal != null)
196 delete pBitmapNormal;
199 if (pBitmapPressed != null)
201 delete pBitmapPressed;
203 __pListview = static_cast< ListView* >(GetControl("IDC_LISTVIEW1"));
205 if (__pListview == null)
209 __pSearchBar = static_cast< SearchBar* >(GetControl(L"IDC_SEARCHBAR1"));
211 if (__pSearchBar == null)
216 if (__pListview != null)
218 // __pListview->SetBounds(__pListview->GetX(), __pListview->GetY(), GetClientAreaBounds().width, GetClientAreaBounds().height);
219 __pListview->AddFastScrollListener(*this);
220 __pListview->AddListViewItemEventListener(*this);
221 __pListview->SetItemProvider(*this);
222 __pListview->UpdateList();
225 __pPopUp = new(std::nothrow) SharePopup();
227 if (__pPopUp != null)
229 __pPopUp->Initialize();
230 AddControl(*__pPopUp);
233 __pSearchListView = new(std::nothrow) ListView();
235 if (__pSearchListView == null)
240 r = __pSearchListView->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height -72 - 30), true, false);
241 TryCatch( !IsFailed(r),,"BookmarkListForm::OnSearchBarModeChanged Update list failed %s",GetErrorMessage(r));
243 __pSearchListView->SetBackgroundColor(GetBackgroundColor());
244 __pSearchListView->SetItemProvider(*this);
245 __pSearchListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RESULTS_FOUND"));
246 __pSearchListView->SetTextColorOfEmptyList(Color::GetColor(COLOR_ID_BLACK));
247 __pSearchListView->SetShowState(false);
248 __pSearchListView->AddListViewItemEventListener(*this);
250 __pSearchBar->AddSearchBarEventListener(*this);
251 __pSearchBar->AddKeypadEventListener(*this);
252 __pSearchBar->SetContent(__pSearchListView);
254 BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID, bookmarkCount);
255 if(bookmarkCount <= 0)
257 __pSearchBar->SetShowState(false);
258 //__pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pSearchBar->GetWidth(),GetClientAreaBounds().height - __pSearchBar->GetPosition().y);
259 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pListview->GetWidth(),GetClientAreaBounds().height);
263 __pSearchBar->SetShowState(true);
269 pHeader->SetStyle(HEADER_STYLE_TAB);
270 bookmark.Construct(IDA_TABBAR_ITEM_1);
272 pAppResource->GetString(L"IDS_BR_TAB_BOOKMARKS", strbookmark);
273 bookmark.SetText(strbookmark);
274 pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_BOOKMARK);
275 bookmark.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);
276 bookmark.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
277 pHeader->AddItem(bookmark);
279 if (pIconBitmap != NULL)
284 history.Construct(IDA_TABBAR_ITEM_2);
286 pAppResource->GetString(L"IDS_BR_TAB_HISTORY", strhistory);
287 history.SetText(strhistory);
288 pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_HISTORY);
289 history.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);
290 history.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
291 pHeader->AddItem(history);
292 pHeader->SetItemSelected(0);
293 pHeader->SetTabEditModeEnabled(false);
295 if (pIconBitmap != NULL)
306 BookmarkListForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
308 AppLogDebug("BookmarkListForm::OnActionPerformed actionId = %d",actionId);
311 BookmarkData* pBookMark = null;
315 case IDA_FOOTER_ITEM1:
317 GetHeader()->SetItemSelected(0);
318 GetHeader()->Invalidate(true);
319 SceneManager* pSceneManager = SceneManager::GetInstance();
320 pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(__selectedindex));
322 if ( pBookMark == NULL )
327 ArrayList* pArgList = null;
328 pArgList = new(std::nothrow) ArrayList();
329 if (pArgList != null)
331 pArgList->Construct();
332 pArgList->Add(*new(std::nothrow) String(pBookMark->GetParentId()));
334 //pArgList->Add(*new(std::nothrow) String(pBookmark->);
335 if (pSceneManager != null)
337 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_EDIT_BOOKMARK_LIST),pArgList) != E_SUCCESS)
339 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
340 pArgList->RemoveAll(true);
347 if ( pArgList != NULL)
349 pArgList->RemoveAll(true);
355 case IDA_TABBAR_ITEM_2:
357 GetHeader()->SetItemSelected(0);
358 GetHeader()->Invalidate(true);
360 SceneManager* pSceneManager = SceneManager::GetInstance();
362 if (pSceneManager != null)
364 if(__previousSceneId.CompareTo(IDSCN_HISTORY_LIST) != 0)
366 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT)) != E_SUCCESS)
368 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
375 if(pSceneManager->GoBackward(BackwardSceneTransition())!= E_SUCCESS)
377 AppLogDebug("BookmarkListForm::OnActionPerformed GoBackward failed");
385 case IDA_FOOTER_ITEM2:
387 SceneManager* pSceneManager = SceneManager::GetInstance();
391 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_BOOKMARK_FOLDER)) != E_SUCCESS)
393 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
399 case IDA_FOOTER_ITEM_ADDBOOKMARK:
401 SceneManager* pSceneManager = SceneManager::GetInstance();
403 // send array list 0-for add, 1 for edit with parent ID
404 ArrayList* pArgList = null;
405 pArgList = new(std::nothrow) ArrayList();
406 if (pArgList != null)
408 pArgList->Construct();
409 pArgList->Add(*new(std::nothrow) String(L"0"));
410 pArgList->Add(*new(std::nothrow) String(__parentID));
415 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ADD_BOOKMARK),pArgList) != E_SUCCESS)
417 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
418 pArgList->RemoveAll(true);
424 if (pArgList != null)
426 pArgList->RemoveAll(true);
433 __pConfirmationPopup->SetShowState(false);
434 __pConfirmationPopup->Show();
437 pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(__selectedindex));
438 if ( pBookMark== null)
440 bookmarkId=pBookMark->GetBookmarkId();
441 Integer::Parse(bookmarkId,id);
442 if (pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
443 BookmarkPresentationModel::GetInstance()->DeleteFolder(id);
445 BookmarkPresentationModel::GetInstance()->DeleteBookmark(id);
446 if (__pListview == null)
450 AppLogDebug("__pListview GetBounds %d,%d,%d,%d",__pListview->GetBounds().x,__pListview->GetBounds().y,__pListview->GetBounds().width,__pListview->GetBounds().height);
451 __pSearchListView->UpdateList();
452 __pListview->UpdateList();
454 if (__pListview->GetItemCount() == 0)
456 GetFooter()->SetItemEnabled(1,false);
457 __pSearchBar->SetShowState(false);
458 __pSearchBar->Invalidate(true);
461 if (__noBookmarks == true)
463 Bitmap* emptyListBmp = AppResource::GetInstance()->GetBitmapN(IDB_NO_CONTENT_BOOKMARK);
464 GetFooter()->SetItemEnabled(1,false);
465 __pSearchBar->SetShowState(false);
466 __pSearchBar->Invalidate(true);
467 // __pListview->SetBounds(__pSearchBar->GetPosition().x,__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
468 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
469 __pListview->SetBitmapOfEmptyList(emptyListBmp);
475 __pListview->UpdateList();
480 GetFooter()->SetItemEnabled(1,true);
482 if (__parentID.CompareTo(L"0") == 0)
484 __pSearchBar->SetShowState(true);
485 __pSearchBar->Invalidate(true);
489 GetFooter()->Invalidate(true);
490 __pConfirmationPopup->SetShowState(false);
491 __pConfirmationPopup->Show();
501 BookmarkListForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
503 AppLogDebug("BrowserApplicationForm::OnFormBackRequested");
505 UiApp* pApp = UiApp::GetInstance();
511 if (__parentID != DEFAULT_VALUE_PARENTID)
513 __parentID = DEFAULT_VALUE_PARENTID;
514 __pSearchBar->SetShowState(true);
515 __pListview->SetBounds(__pListview->GetX() ,__pSearchBar->GetPosition().y + __pSearchBar->GetHeight(),__pListview->GetWidth(),GetClientAreaBounds().height - (__pSearchBar->GetY() + __pSearchBar->GetHeight()));
516 __pListview->UpdateList();
517 __pFooter = GetFooter();
518 GetFooter()->SetItemEnabled(2,true);
519 GetFooter()->Invalidate(true);
523 SceneManager* pSceneManager = SceneManager::GetInstance();
524 if (pSceneManager != null)
526 if(__previousSceneId.CompareTo(IDSCN_HISTORY_LIST) != 0)
528 pSceneManager->GoBackward(BackwardSceneTransition());
532 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
537 if (__noBookmarks == true)
539 GetFooter()->SetItemEnabled(1,false);
543 GetFooter()->SetItemEnabled(1,true);
547 Tizen::Ui::Controls::ListItemBase*
548 BookmarkListForm::CreateItem(int index, int itemWidth)
551 AppLog("BookmarkListForm::CreateItem index %d , itemWidth %d",index, itemWidth);
552 AppLog("listviewwidth %d",__pListview->GetWidth());
553 result r = E_FAILURE;
554 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
559 CustomItem* pItem = new(std::nothrow) CustomItem();
561 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
562 Bitmap* pBitmap = null;
565 Image* pImage = null;
566 pImage = new Image();
569 const int x_Margin_Icon = 16; // local as there used only in this function
570 const int y_Margin_Icon = 28;
571 const int height_Icon = 72;
572 const int width_Icon = 72 ;
573 const int x_Margin_Title = 104 ;
574 const int y_Margin_Title = 10;
575 const int width_Title = GetClientAreaBounds().width - 108 - 52 - 30;
576 const int x_Margin_Url = 104 ;
577 const int y_Margin_Url = 70 ;
578 const int width_Url = GetClientAreaBounds().width - 108 - 52 ;
579 const int height_Url = 48;
580 const int itemHeight = 128;
581 const int textSize = 32;
584 if( pBookMark == NULL )
590 if ( pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER )
592 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth,112), LIST_ANNEX_STYLE_DETAILED);
593 TryCatch(!IsFailed(r),,"BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
595 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_FOLDER_OPEN);
598 pItem->AddElement(Rectangle(x_Margin_Icon, 20, width_Icon, height_Icon), IDA_FORMAT_ICON, *pBitmap, null);
602 pItem->AddElement(Rectangle(x_Margin_Title, 26, width_Title, 60), IDA_FORMAT_FOLDER, pBookMark->GetBookmarkTitle(), true);
604 if ( __pItemContextFolder != NULL)
606 pItem->SetContextItem(__pItemContextFolder);
611 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth, itemHeight), style);
612 TryCatch( !IsFailed(r),,"BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
614 AppLogDebug("BookmarkListForm::faviconid %ls",pBookMark->GetFaviconId().GetPointer());
615 bitmapId = pBookMark->GetFaviconId();
617 dim = Dimension(pBookMark->GetFavIconWidth(), pBookMark->GetFavIconHeight());
619 AppLog("BookmarkListForm::CreateItem check 0");
621 // get fav icon bitmap
622 ByteBuffer* pFavIconBuffer = null;
623 pFavIconBuffer = pBookMark->GetFavIconBuffer();
625 AppLog("BookmarkListForm::CreateItem check 0");
627 if (pFavIconBuffer != null)
629 AppLog("BookmarkListForm::CreateItem pFavIconBuffer is not null");
633 AppLog("BookmarkListForm::CreateItem pFavIconBuffer is null");
636 pBitmap = pImage->DecodeN(*pFavIconBuffer, IMG_FORMAT_PNG, BITMAP_PIXEL_FORMAT_ARGB8888);
638 AppLog("BookmarkListForm::CreateItem check 1");
642 AppLog("rahul bitmap is not null");
643 int width = pBitmap->GetWidth();
644 int height = pBitmap->GetHeight();
645 AppLog("rahul bitmap width is %d", width);
646 AppLog("rahul bitmap height is %d", height);
647 AppLog("rahul favicon width is %d", pBookMark->GetFavIconWidth());
648 AppLog("rahul favicon height is %d", pBookMark->GetFavIconHeight());
652 AppLog("rahul bitmap is null");
657 AppLogDebug("BookmarkListForm::CreateItem bitmap is null");
658 pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
660 pItem->AddElement(Rectangle(x_Margin_Icon, y_Margin_Icon, width_Icon, height_Icon), IDA_FORMAT_ICON, *pBitmap, null);
661 pItem->AddElement(Rectangle(x_Margin_Title, 0, width_Title, itemHeight - height_Url), IDA_FORMAT_SITE, pBookMark->GetBookmarkTitle(),44,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,true);
662 if(__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
663 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);
665 pItem->AddElement(Rectangle(x_Margin_Url, y_Margin_Url, width_Url, height_Url), IDA_FORMAT_URL, pBookMark->GetUrl(),textSize,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,true);
671 if ( __pItemContextSite != NULL)
673 pItem->SetContextItem(__pItemContextSite);
690 BookmarkListForm::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
698 BookmarkListForm::GetItemCount(void)
702 if (__pData != NULL )
704 __pData->RemoveAll(true);
708 __pData = new(std::nothrow) Collection::ArrayList();
709 __pData->Construct();
711 if (__searchBookmark == false)
713 BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID, count);
714 BookmarkPresentationModel::GetInstance()->GetFoldersBookmarks(__parentID, 0, count, *__pData);
718 BookmarkPresentationModel::GetInstance()->GetSearchFolderBookmarkCount(count,__searchText);
719 BookmarkPresentationModel::GetInstance()->GetSearchFoldersBookmarks(0, count, *__pData, __searchText);
722 AppLogDebug("Count = %d parentId = %ls", count, __parentID.GetPointer());
726 __noBookmarks = true;
727 GetFooter()->SetItemEnabled(1,false);
731 __noBookmarks = false;
732 GetFooter()->SetItemEnabled(1,true);
735 AppLogDebug("Result: %s", GetErrorMessage(GetLastResult()));
736 GetFooter()->Invalidate(true);
737 if (__pData != null && __pData->GetCount() >= 1)
739 // __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
740 __pSearchBar->SetShowState(true);
741 __pSearchBar->Invalidate(true);
743 else if (__searchBookmark == false)
745 __pSearchBar->SetShowState(false);
746 __pSearchBar->Invalidate(true);
749 if (__parentID.CompareTo(L"0") != 0)
751 __pSearchBar->SetShowState(false);
752 __pSearchBar->Invalidate(true);
754 if (__noBookmarks == true)
756 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
757 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_NO_CONTENT_BOOKMARK);
759 if ( pBitmap != NULL)
761 __pListview->SetBitmapOfEmptyList(pBitmap);
767 if (__parentID.CompareTo(L"0") == 0)
769 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetHeight(),GetClientAreaBounds().width ,GetClientAreaBounds().height - __pSearchBar->GetY() - __pSearchBar->GetHeight());
773 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
778 __pListview->Invalidate(true);
784 BookmarkListForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
786 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged int index %d, int elementId %d, Tizen::Ui::Controls::ListContextItemStatus status %d",index,elementId,status);
788 String deleteText = CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB");
789 deleteText.Append(L"? ");
791 result r = E_SUCCESS;
795 case IDA_CONTEXT_ITEM_FOLDER_EDIT:
797 ArrayList* pArgList = null;
798 String* pEdit = null;
800 SceneManager* pSceneManager = SceneManager::GetInstance();
801 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
802 if (pBookMark != null && pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
804 pArgList = new(std::nothrow) ArrayList();
805 if (pArgList != null)
807 pEdit= new(std::nothrow) String(CommonUtil::GetString(L"IDS_BR_HEADER_EDIT_FOLDER"));
808 pArgList->Construct();
809 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
810 pArgList->Add(*pEdit);
811 if ( pSceneManager != null)
814 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_BOOKMARK_FOLDER), pArgList);
817 if (pArgList != null)
824 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged GoForward failed %s",GetErrorMessage(r));
833 case IDA_CONTEXT_ITEM_FOLDER_DELETE:
834 case IDA_CONTEXT_ITEM_DELETE:
836 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
837 __pConfirmationPopup->Initialize();
838 __pConfirmationPopup->RemoveActionListener(*this);
839 __pConfirmationPopup->AddActionListener(*this);
840 __pConfirmationPopup->setMessage(deleteText);
841 __pConfirmationPopup->Show();
842 __selectedindex = index;
846 case IDA_CONTEXT_ITEM_EDIT:
848 ArrayList* pArgList = null;
849 SceneManager* pSceneManager = SceneManager::GetInstance();
850 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
851 if (pBookMark!= null && pBookMark->GetBookmarkType() == BOOKMARK_TYPE_URL)
853 AppLogDebug("ID_CONTEXT_ITEM_SITE_1 BOOKMARK_TYPE_URL");
854 pArgList = new(std::nothrow) ArrayList();
855 if (pArgList != null)
857 pArgList->Construct();
858 pArgList->Add(*new(std::nothrow) String(L"1"));
859 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
860 if ( pSceneManager != null)
863 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ADD_BOOKMARK), pArgList);
864 if (pArgList != null)
871 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged GoForward failed %s",GetErrorMessage(r));
879 case IDA_CONTEXT_ITEM_SHARE:
881 AppLogDebug("OnListViewContextItemStateChanged Share");
883 BookmarkData* pBookmark = dynamic_cast<BookmarkData*>(__pData->GetAt(index));
884 if (pBookmark != null)
886 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
887 pShareInfo->SetPageTitle(pBookmark->GetBookmarkTitle());
888 pShareInfo->SetPageUrl(pBookmark->GetUrl());
889 pShareInfo->SetImageAttached(false);
890 __pPopUp->RemoveAllShareInfo();
891 __pPopUp->AddShareInfo(pShareInfo);
894 if (__pPopUp != null)
896 __pPopUp->SetShowState(true);
908 BookmarkListForm::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
914 BookmarkListForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
916 AppLogDebug("BookmarkListForm::OnListViewItemStateChanged");
918 result r = E_FAILURE;
919 ArrayList *pArgList = null;
920 SceneManager* pSceneManager = SceneManager::GetInstance();
921 BookmarkData* pBookmark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
923 if ( pBookmark == NULL )
928 switch (pBookmark->GetBookmarkType())
930 case BOOKMARK_TYPE_FOLDER:
932 __parentID = pBookmark->GetBookmarkId();
933 AppLogDebug("BOOKMARK_TYPE_FOLDER parent ID is %ls",__parentID.GetPointer());
935 listView.UpdateList();
936 if (listView.GetItemCount() == 0)
938 GetFooter()->SetItemEnabled(1,false);
942 GetFooter()->SetItemEnabled(1,true);
944 GetFooter()->SetItemEnabled(2,false);
945 GetFooter()->Invalidate(true);
946 __pSearchBar->HideKeypad();
947 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
948 __pSearchBar->SetShowState(false);
949 __pSearchBar->Invalidate(true);
950 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pListview->GetWidth() ,GetClientAreaBounds().height);
953 case BOOKMARK_TYPE_URL:
955 pArgList = new(std::nothrow) ArrayList();
956 if (pArgList != null)
958 r = pArgList->Construct();
959 TryCatch(!IsFailed(r), L"BookmarkListForm::OnListViewItemStateChanged pArgList Construct failed %s", GetErrorMessage(r));
961 AppLogDebug("bookmark url = %ls",pBookmark->GetUrl().GetPointer());
962 r = pArgList->Add(*MultipleWindowPresentationModel::GetInstance()->GetActiveWindowInfo());
963 pArgList->Add(*new(std::nothrow) String(pBookmark->GetUrl()));
965 if (pSceneManager != null)
967 AppLogDebug("pSceneManager exists");
969 MultipleWindowPresentationModel::GetInstance()->GetCurrentSceneId(prevSceneId);
970 r = pSceneManager->GoBackward(BackwardSceneTransition(prevSceneId), pArgList);
971 TryCatch(!IsFailed(r), L"BookmarkListForm::OnListViewItemStateChanged pArgList Construct failed %s", GetErrorMessage(r));
985 pArgList->RemoveAll(true);
992 BookmarkListForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
999 BookmarkListForm::OnFastScrollIndexSelected(Tizen::Ui::Control& source, Tizen::Base::String& index)
1005 BookmarkListForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
1007 result r = E_FAILURE;
1009 if (mode == SEARCH_BAR_MODE_NORMAL)
1011 __pSearchListView->SetShowState(false);
1012 __pSearchListView->UpdateList();
1013 __pListview->SetShowState(true);
1015 __searchBookmark = false;
1016 r = __pListview->UpdateList();
1017 // __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1018 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1019 TryCatch( !IsFailed(r),,"BookmarkListForm::OnSearchBarModeChanged Update list failed %s",GetErrorMessage(r));
1024 __pSearchListView->SetShowState(true);
1025 __pSearchListView->SetEnabled(false);
1026 __pListview->SetShowState(false);
1030 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1031 __pSearchBar->SetText(L"");
1033 AppLog("OnSearchBarModeChanged SetContentAreaSize heihgt %d",__pSearchListView->GetHeight());
1034 __pListview->UpdateList();
1035 __pSearchListView->UpdateList();
1040 BookmarkListForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
1042 GetFooter()->SetShowState(false);
1043 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), __pSearchListView->GetHeight() + GetFooter()->GetHeight());
1044 __pSearchListView->SetEnabled(false);
1045 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1047 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), __pSearchListView->GetHeight() - GetFooter()->GetHeight());
1051 BookmarkListForm::OnKeypadOpened(Tizen::Ui::Control& source)
1053 GetFooter()->SetShowState(false);
1054 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1055 __pSearchListView->UpdateList();
1060 BookmarkListForm::OnKeypadClosed(Tizen::Ui::Control& source)
1063 GetFooter()->SetShowState(true);
1064 GetFooter()->Invalidate(true);
1065 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1066 __pListview->SetBounds(__pSearchListView->GetX(), __pSearchBar->GetY() + __pSearchBar->GetHeight(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1067 __pSearchListView->Invalidate(false);
1068 //__pSearchListView->SetEnabled(true);
1069 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1074 BookmarkListForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
1076 AppLog("BookmarkListForm::OnKeypadActionPerformed %d",keypadAction);
1078 if (__pSearchBar != null)
1080 __pSearchBar->HideKeypad();
1083 if ( __pSearchBar != null && keypadAction == KEYPAD_ACTION_SEARCH)
1085 if (__pSearchBar->GetText().GetLength() == 0)
1090 __searchText = __pSearchBar->GetText();
1091 __searchBookmark = true;
1092 __pListview->SetShowState(false);
1093 __pSearchListView->SetEnabled(true);
1094 __pSearchListView->SetShowState(true);
1095 __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1096 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1097 __pSearchListView->UpdateList();
1104 BookmarkListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
1106 AppLogDebug("BookmarkListForm::OnSceneActivatedN called");
1107 ArrayListT<String> * pList = dynamic_cast<ArrayListT<String>* >(SceneManager::GetInstance()->GetSceneHistoryN());
1110 pList->GetAt(pList->GetCount()-1,__previousSceneId);
1113 __searchBookmark = false;
1114 GetFooter()->SetShowState(true);
1115 GetFooter()->Invalidate(true);
1116 GetHeader()->SetItemSelected(0);
1117 GetHeader()->Invalidate(true);
1119 /* if (previousSceneId != IDSCN_HISTORY_LIST && previousSceneId != IDSCN_CREATE_BOOKMARK_FOLDER && previousSceneId != IDSCN_EDIT_BOOKMARK_LIST)
1121 __previousSceneId = previousSceneId;
1124 if (__pListview != null)
1126 __pListview->UpdateList();
1133 BookmarkListForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
1135 AppLog("BookmarkListForm::OnOrientationChanged start");
1139 if(__pSearchBar->GetShowState())
1141 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetHeight(),GetClientAreaBounds().width ,GetClientAreaBounds().height - __pSearchBar->GetY() - __pSearchBar->GetHeight());
1145 __pListview->SetBounds(__pListview->GetX(),0,GetClientAreaBounds().width ,GetClientAreaBounds().height);
1147 __pListview->UpdateList();
1150 if (__pSearchListView && __pListview)
1152 AppLog("__pListview->GetBounds() %d, %d, %d, %d",__pListview->GetBounds().x,__pListview->GetBounds().y,__pListview->GetBounds().width,__pListview->GetBounds().height);
1153 __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1155 __pSearchListView->UpdateList();
1158 if (__pSearchListView && __pData != null )
1160 if (__parentID != DEFAULT_VALUE_PARENTID)
1162 AppLog("BookmarkListForm::OnOrientationChanged parent id true");
1163 __pSearchBar->SetShowState(false);
1164 __pSearchBar->Invalidate(true);
1167 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height));
1175 BookmarkListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
1177 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);