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"-1";
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->SetItemProvider(*this);
244 __pSearchListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RESULTS_FOUND"));
245 __pSearchListView->SetTextColorOfEmptyList(Color::GetColor(COLOR_ID_BLACK));
246 __pSearchListView->SetShowState(false);
247 __pSearchListView->AddListViewItemEventListener(*this);
249 __pSearchBar->AddSearchBarEventListener(*this);
250 __pSearchBar->AddKeypadEventListener(*this);
251 __pSearchBar->SetContent(__pSearchListView);
253 BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID, bookmarkCount);
254 if(bookmarkCount <= 0)
256 __pSearchBar->SetShowState(false);
257 //__pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pSearchBar->GetWidth(),GetClientAreaBounds().height - __pSearchBar->GetPosition().y);
258 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pListview->GetWidth(),GetClientAreaBounds().height);
262 __pSearchBar->SetShowState(true);
268 pHeader->SetStyle(HEADER_STYLE_TAB);
269 bookmark.Construct(IDA_TABBAR_ITEM_1);
271 pAppResource->GetString(L"IDS_BR_TAB_BOOKMARKS", strbookmark);
272 bookmark.SetText(strbookmark);
273 pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_BOOKMARK);
274 bookmark.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);
275 bookmark.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
276 pHeader->AddItem(bookmark);
278 if (pIconBitmap != NULL)
283 history.Construct(IDA_TABBAR_ITEM_2);
285 pAppResource->GetString(L"IDS_BR_TAB_HISTORY", strhistory);
286 history.SetText(strhistory);
287 pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_HISTORY);
288 history.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);
289 history.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
290 pHeader->AddItem(history);
291 pHeader->SetItemSelected(0);
293 if (pIconBitmap != NULL)
304 BookmarkListForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
306 AppLogDebug("BookmarkListForm::OnActionPerformed actionId = %d",actionId);
309 BookmarkData* pBookMark = null;
313 case IDA_FOOTER_ITEM1:
315 GetHeader()->SetItemSelected(0);
316 GetHeader()->Invalidate(true);
317 SceneManager* pSceneManager = SceneManager::GetInstance();
318 pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(__selectedindex));
320 if ( pBookMark == NULL )
325 ArrayList* pArgList = null;
326 pArgList = new(std::nothrow) ArrayList();
327 if (pArgList != null)
329 pArgList->Construct();
330 pArgList->Add(*new(std::nothrow) String(pBookMark->GetParentId()));
332 //pArgList->Add(*new(std::nothrow) String(pBookmark->);
333 if (pSceneManager != null)
335 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_EDIT_BOOKMARK_LIST),pArgList) != E_SUCCESS)
337 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
338 pArgList->RemoveAll(true);
345 if ( pArgList != NULL)
347 pArgList->RemoveAll(true);
353 case IDA_TABBAR_ITEM_2:
355 GetHeader()->SetItemSelected(0);
356 GetHeader()->Invalidate(true);
358 SceneManager* pSceneManager = SceneManager::GetInstance();
360 if (pSceneManager != null)
362 if(__previousSceneId.CompareTo(IDSCN_HISTORY_LIST) != 0)
364 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT)) != E_SUCCESS)
366 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
373 if(pSceneManager->GoBackward(BackwardSceneTransition())!= E_SUCCESS)
375 AppLogDebug("BookmarkListForm::OnActionPerformed GoBackward failed");
383 case IDA_FOOTER_ITEM2:
385 SceneManager* pSceneManager = SceneManager::GetInstance();
389 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_BOOKMARK_FOLDER)) != E_SUCCESS)
391 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
397 case IDA_FOOTER_ITEM_ADDBOOKMARK:
399 SceneManager* pSceneManager = SceneManager::GetInstance();
401 // send array list 0-for add, 1 for edit with parent ID
402 ArrayList* pArgList = null;
403 pArgList = new(std::nothrow) ArrayList();
404 if (pArgList != null)
406 pArgList->Construct();
407 pArgList->Add(*new(std::nothrow) String(L"0"));
408 pArgList->Add(*new(std::nothrow) String(__parentID));
413 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ADD_BOOKMARK),pArgList) != E_SUCCESS)
415 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
416 pArgList->RemoveAll(true);
422 if (pArgList != null)
424 pArgList->RemoveAll(true);
431 __pConfirmationPopup->SetShowState(false);
432 __pConfirmationPopup->Show();
435 pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(__selectedindex));
436 if ( pBookMark== null)
438 bookmarkId=pBookMark->GetBookmarkId();
439 Integer::Parse(bookmarkId,id);
440 if (pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
441 BookmarkPresentationModel::GetInstance()->DeleteFolder(id);
443 BookmarkPresentationModel::GetInstance()->DeleteBookmark(id);
444 if (__pListview == null)
448 AppLogDebug("__pListview GetBounds %d,%d,%d,%d",__pListview->GetBounds().x,__pListview->GetBounds().y,__pListview->GetBounds().width,__pListview->GetBounds().height);
449 __pSearchListView->UpdateList();
450 __pListview->UpdateList();
452 if (__pListview->GetItemCount() == 0)
454 GetFooter()->SetItemEnabled(1,false);
455 __pSearchBar->SetShowState(false);
456 __pSearchBar->Invalidate(true);
459 if (__noBookmarks == true)
461 Bitmap* emptyListBmp = AppResource::GetInstance()->GetBitmapN(IDB_NO_CONTENT_BOOKMARK);
462 GetFooter()->SetItemEnabled(1,false);
463 __pSearchBar->SetShowState(false);
464 __pSearchBar->Invalidate(true);
465 // __pListview->SetBounds(__pSearchBar->GetPosition().x,__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
466 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
467 __pListview->SetBitmapOfEmptyList(emptyListBmp);
473 __pListview->UpdateList();
478 GetFooter()->SetItemEnabled(1,true);
480 if (__parentID.CompareTo(L"-1") == 0)
482 __pSearchBar->SetShowState(true);
483 __pSearchBar->Invalidate(true);
487 GetFooter()->Invalidate(true);
488 __pConfirmationPopup->SetShowState(false);
489 __pConfirmationPopup->Show();
499 BookmarkListForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
501 AppLogDebug("BrowserApplicationForm::OnFormBackRequested");
503 UiApp* pApp = UiApp::GetInstance();
509 if (__parentID != DEFAULT_VALUE_PARENTID)
511 __parentID = DEFAULT_VALUE_PARENTID;
512 __pSearchBar->SetShowState(true);
513 __pListview->SetBounds(__pListview->GetX() ,__pSearchBar->GetPosition().y + __pSearchBar->GetHeight(),__pListview->GetWidth(),GetClientAreaBounds().height - (__pSearchBar->GetY() + __pSearchBar->GetHeight()));
514 __pListview->UpdateList();
515 __pFooter = GetFooter();
516 GetFooter()->SetItemEnabled(2,true);
517 GetFooter()->Invalidate(true);
521 SceneManager* pSceneManager = SceneManager::GetInstance();
522 if (pSceneManager != null)
524 if(__previousSceneId.CompareTo(IDSCN_HISTORY_LIST) != 0)
526 pSceneManager->GoBackward(BackwardSceneTransition());
530 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
535 if (__noBookmarks == true)
537 GetFooter()->SetItemEnabled(1,false);
541 GetFooter()->SetItemEnabled(1,true);
545 Tizen::Ui::Controls::ListItemBase*
546 BookmarkListForm::CreateItem(int index, int itemWidth)
549 AppLog("BookmarkListForm::CreateItem index %d , itemWidth %d",index, itemWidth);
550 AppLog("listviewwidth %d",__pListview->GetWidth());
551 result r = E_FAILURE;
552 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
557 CustomItem* pItem = new(std::nothrow) CustomItem();
559 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
560 Bitmap* pBitmap = null;
563 Image* pImage = null;
564 pImage = new Image();
567 const int x_Margin_Icon = 16; // local as there used only in this function
568 const int y_Margin_Icon = 28;
569 const int height_Icon = 72;
570 const int width_Icon = 72 ;
571 const int x_Margin_Title = 104 ;
572 const int y_Margin_Title = 10;
573 const int width_Title = GetClientAreaBounds().width - 108 - 52 - 30;
574 const int x_Margin_Url = 104 ;
575 const int y_Margin_Url = 70 ;
576 const int width_Url = GetClientAreaBounds().width - 108 - 52 ;
577 const int height_Url = 48;
578 const int itemHeight = 128;
579 const int textSize = 32;
582 if( pBookMark == NULL )
588 if ( pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER )
590 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth,112), LIST_ANNEX_STYLE_DETAILED);
591 TryCatch(!IsFailed(r),,"BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
593 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_FOLDER_OPEN);
596 pItem->AddElement(Rectangle(x_Margin_Icon, 20, width_Icon, height_Icon), IDA_FORMAT_ICON, *pBitmap, null);
600 pItem->AddElement(Rectangle(x_Margin_Title, 26, width_Title, 60), IDA_FORMAT_FOLDER, pBookMark->GetBookmarkTitle(), true);
602 if ( __pItemContextFolder != NULL)
604 pItem->SetContextItem(__pItemContextFolder);
609 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth, itemHeight), style);
610 TryCatch( !IsFailed(r),,"BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
612 AppLogDebug("BookmarkListForm::faviconid %ls",pBookMark->GetFaviconId().GetPointer());
613 bitmapId = pBookMark->GetFaviconId();
615 dim = Dimension(pBookMark->GetFavIconWidth(), pBookMark->GetFavIconHeight());
617 AppLog("BookmarkListForm::CreateItem check 0");
619 // get fav icon bitmap
620 ByteBuffer* pFavIconBuffer = null;
621 pFavIconBuffer = pBookMark->GetFavIconBuffer();
623 AppLog("BookmarkListForm::CreateItem check 0");
625 if (pFavIconBuffer != null)
627 AppLog("BookmarkListForm::CreateItem pFavIconBuffer is not null");
631 AppLog("BookmarkListForm::CreateItem pFavIconBuffer is null");
634 pBitmap = pImage->DecodeN(*pFavIconBuffer, IMG_FORMAT_PNG, BITMAP_PIXEL_FORMAT_ARGB8888);
636 AppLog("BookmarkListForm::CreateItem check 1");
640 AppLog("rahul bitmap is not null");
641 int width = pBitmap->GetWidth();
642 int height = pBitmap->GetHeight();
643 AppLog("rahul bitmap width is %d", width);
644 AppLog("rahul bitmap height is %d", height);
645 AppLog("rahul favicon width is %d", pBookMark->GetFavIconWidth());
646 AppLog("rahul favicon height is %d", pBookMark->GetFavIconHeight());
650 AppLog("rahul bitmap is null");
655 AppLogDebug("BookmarkListForm::CreateItem bitmap is null");
656 pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
658 pItem->AddElement(Rectangle(x_Margin_Icon, y_Margin_Icon, width_Icon, height_Icon), IDA_FORMAT_ICON, *pBitmap, null);
659 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);
660 if(__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
661 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);
663 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);
669 if ( __pItemContextSite != NULL)
671 pItem->SetContextItem(__pItemContextSite);
685 BookmarkListForm::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
693 BookmarkListForm::GetItemCount(void)
697 if (__pData != NULL )
699 __pData->RemoveAll(true);
703 __pData = new(std::nothrow) Collection::ArrayList();
704 __pData->Construct();
706 if (__searchBookmark == false)
708 BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID, count);
709 BookmarkPresentationModel::GetInstance()->GetFoldersBookmarks(__parentID, 0, count, *__pData);
713 BookmarkPresentationModel::GetInstance()->GetSearchFolderBookmarkCount(count,__searchText);
714 BookmarkPresentationModel::GetInstance()->GetSearchFoldersBookmarks(0, count, *__pData, __searchText);
717 AppLogDebug("Count = %d parentId = %ls", count, __parentID.GetPointer());
721 __noBookmarks = true;
722 GetFooter()->SetItemEnabled(1,false);
726 __noBookmarks = false;
727 GetFooter()->SetItemEnabled(1,true);
730 AppLogDebug("Result: %s", GetErrorMessage(GetLastResult()));
731 GetFooter()->Invalidate(true);
732 if (__pData != null && __pData->GetCount() >= 1)
734 // __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
735 __pSearchBar->SetShowState(true);
736 __pSearchBar->Invalidate(true);
738 else if (__searchBookmark == false)
740 __pSearchBar->SetShowState(false);
741 __pSearchBar->Invalidate(true);
744 if (__parentID.CompareTo(L"-1") != 0)
746 __pSearchBar->SetShowState(false);
747 __pSearchBar->Invalidate(true);
749 if (__noBookmarks == true)
751 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
752 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_NO_CONTENT_BOOKMARK);
754 if ( pBitmap != NULL)
756 __pListview->SetBitmapOfEmptyList(pBitmap);
762 if (__parentID.CompareTo(L"-1") == 0)
764 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetHeight(),GetClientAreaBounds().width ,GetClientAreaBounds().height - __pSearchBar->GetY() - __pSearchBar->GetHeight());
768 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
773 __pListview->Invalidate(true);
779 BookmarkListForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
781 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged int index %d, int elementId %d, Tizen::Ui::Controls::ListContextItemStatus status %d",index,elementId,status);
783 String deleteText = CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB");
784 deleteText.Append(L"? ");
786 result r = E_SUCCESS;
790 case IDA_CONTEXT_ITEM_FOLDER_EDIT:
792 ArrayList* pArgList = null;
793 String* pEdit = null;
795 SceneManager* pSceneManager = SceneManager::GetInstance();
796 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
797 if (pBookMark != null && pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
799 pArgList = new(std::nothrow) ArrayList();
800 if (pArgList != null)
802 pEdit= new(std::nothrow) String(CommonUtil::GetString(L"IDS_BR_HEADER_EDIT_FOLDER"));
803 pArgList->Construct();
804 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
805 pArgList->Add(*pEdit);
806 if ( pSceneManager != null)
809 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_BOOKMARK_FOLDER), pArgList);
812 if (pArgList != null)
819 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged GoForward failed %s",GetErrorMessage(r));
828 case IDA_CONTEXT_ITEM_FOLDER_DELETE:
829 case IDA_CONTEXT_ITEM_DELETE:
831 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
832 __pConfirmationPopup->Initialize();
833 __pConfirmationPopup->RemoveActionListener(*this);
834 __pConfirmationPopup->AddActionListener(*this);
835 __pConfirmationPopup->setMessage(deleteText);
836 __pConfirmationPopup->Show();
837 __selectedindex = index;
841 case IDA_CONTEXT_ITEM_EDIT:
843 ArrayList* pArgList = null;
844 SceneManager* pSceneManager = SceneManager::GetInstance();
845 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
846 if (pBookMark!= null && pBookMark->GetBookmarkType() == BOOKMARK_TYPE_URL)
848 AppLogDebug("ID_CONTEXT_ITEM_SITE_1 BOOKMARK_TYPE_URL");
849 pArgList = new(std::nothrow) ArrayList();
850 if (pArgList != null)
852 pArgList->Construct();
853 pArgList->Add(*new(std::nothrow) String(L"1"));
854 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
855 if ( pSceneManager != null)
858 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ADD_BOOKMARK), pArgList);
859 if (pArgList != null)
866 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged GoForward failed %s",GetErrorMessage(r));
874 case IDA_CONTEXT_ITEM_SHARE:
876 AppLogDebug("OnListViewContextItemStateChanged Share");
878 BookmarkData* pBookmark = dynamic_cast<BookmarkData*>(__pData->GetAt(index));
879 if (pBookmark != null)
881 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
882 pShareInfo->SetPageTitle(pBookmark->GetBookmarkTitle());
883 pShareInfo->SetPageUrl(pBookmark->GetUrl());
884 pShareInfo->SetImageAttached(false);
885 __pPopUp->RemoveAllShareInfo();
886 __pPopUp->AddShareInfo(pShareInfo);
889 if (__pPopUp != null)
891 __pPopUp->SetShowState(true);
903 BookmarkListForm::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
909 BookmarkListForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
911 AppLogDebug("BookmarkListForm::OnListViewItemStateChanged");
913 result r = E_FAILURE;
914 ArrayList *pArgList = null;
915 SceneManager* pSceneManager = SceneManager::GetInstance();
916 BookmarkData* pBookmark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
918 if ( pBookmark == NULL )
923 switch (pBookmark->GetBookmarkType())
925 case BOOKMARK_TYPE_FOLDER:
927 __parentID = pBookmark->GetBookmarkId();
928 AppLogDebug("BOOKMARK_TYPE_FOLDER parent ID is %ls",__parentID.GetPointer());
930 listView.UpdateList();
931 if (listView.GetItemCount() == 0)
933 GetFooter()->SetItemEnabled(1,false);
937 GetFooter()->SetItemEnabled(1,true);
939 GetFooter()->SetItemEnabled(2,false);
940 GetFooter()->Invalidate(true);
941 __pSearchBar->HideKeypad();
942 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
943 __pSearchBar->SetShowState(false);
944 __pSearchBar->Invalidate(true);
945 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pListview->GetWidth() ,GetClientAreaBounds().height);
948 case BOOKMARK_TYPE_URL:
950 pArgList = new(std::nothrow) ArrayList();
951 if (pArgList != null)
953 r = pArgList->Construct();
954 TryCatch(!IsFailed(r), L"BookmarkListForm::OnListViewItemStateChanged pArgList Construct failed %s", GetErrorMessage(r));
956 AppLogDebug("bookmark url = %ls",pBookmark->GetUrl().GetPointer());
957 r = pArgList->Add(*MultipleWindowPresentationModel::GetInstance()->GetActiveWindowInfo());
958 pArgList->Add(*new(std::nothrow) String(pBookmark->GetUrl()));
960 if (pSceneManager != null)
962 AppLogDebug("pSceneManager exists");
964 MultipleWindowPresentationModel::GetInstance()->GetCurrentSceneId(prevSceneId);
965 r = pSceneManager->GoBackward(BackwardSceneTransition(prevSceneId), pArgList);
966 TryCatch(!IsFailed(r), L"BookmarkListForm::OnListViewItemStateChanged pArgList Construct failed %s", GetErrorMessage(r));
980 pArgList->RemoveAll(true);
987 BookmarkListForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
994 BookmarkListForm::OnFastScrollIndexSelected(Tizen::Ui::Control& source, Tizen::Base::String& index)
1000 BookmarkListForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
1002 result r = E_FAILURE;
1004 if (mode == SEARCH_BAR_MODE_NORMAL)
1006 __pSearchListView->SetShowState(false);
1007 __pSearchListView->UpdateList();
1008 __pListview->SetShowState(true);
1010 __searchBookmark = false;
1011 r = __pListview->UpdateList();
1012 __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1013 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1014 TryCatch( !IsFailed(r),,"BookmarkListForm::OnSearchBarModeChanged Update list failed %s",GetErrorMessage(r));
1019 __pSearchListView->SetShowState(true);
1020 __pSearchListView->SetEnabled(false);
1021 __pListview->SetShowState(false);
1025 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1026 __pSearchBar->SetText(L"");
1028 AppLog("OnSearchBarModeChanged SetContentAreaSize heihgt %d",__pSearchListView->GetHeight());
1029 __pListview->UpdateList();
1030 __pSearchListView->UpdateList();
1035 BookmarkListForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
1037 GetFooter()->SetShowState(false);
1038 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), __pSearchListView->GetHeight() + GetFooter()->GetHeight());
1039 __pSearchListView->SetEnabled(false);
1040 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1042 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), __pSearchListView->GetHeight() - GetFooter()->GetHeight());
1046 BookmarkListForm::OnKeypadOpened(Tizen::Ui::Control& source)
1049 __pSearchListView->UpdateList();
1053 BookmarkListForm::OnKeypadClosed(Tizen::Ui::Control& source)
1056 GetFooter()->SetShowState(true);
1057 GetFooter()->Invalidate(true);
1058 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1059 __pListview->SetBounds(__pSearchListView->GetX(), __pSearchBar->GetY() + __pSearchBar->GetHeight(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1060 __pSearchListView->Invalidate(false);
1061 __pSearchListView->SetEnabled(true);
1062 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1067 BookmarkListForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
1069 AppLog("BookmarkListForm::OnKeypadActionPerformed %d",keypadAction);
1071 if (__pSearchBar != null)
1073 __pSearchBar->HideKeypad();
1076 if ( __pSearchBar != null && keypadAction == KEYPAD_ACTION_SEARCH)
1078 if (__pSearchBar->GetText().GetLength() == 0)
1083 __searchText = __pSearchBar->GetText();
1084 __searchBookmark = true;
1085 __pListview->SetShowState(false);
1086 __pSearchListView->SetEnabled(true);
1087 __pSearchListView->SetShowState(true);
1088 __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1089 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1090 __pSearchListView->UpdateList();
1097 BookmarkListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
1099 AppLogDebug("BookmarkListForm::OnSceneActivatedN called");
1100 ArrayListT<String> * pList = dynamic_cast<ArrayListT<String>* >(SceneManager::GetInstance()->GetSceneHistoryN());
1102 pList->GetAt(pList->GetCount()-1,__previousSceneId);
1104 __searchBookmark = false;
1105 GetFooter()->SetShowState(true);
1106 GetFooter()->Invalidate(true);
1107 GetHeader()->SetItemSelected(0);
1108 GetHeader()->Invalidate(true);
1110 /* if (previousSceneId != IDSCN_HISTORY_LIST && previousSceneId != IDSCN_CREATE_BOOKMARK_FOLDER && previousSceneId != IDSCN_EDIT_BOOKMARK_LIST)
1112 __previousSceneId = previousSceneId;
1115 if (__pListview != null)
1117 __pListview->UpdateList();
1124 BookmarkListForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
1126 AppLog("BookmarkListForm::OnOrientationChanged start");
1130 if(__pSearchBar->GetShowState())
1132 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetHeight(),GetClientAreaBounds().width ,GetClientAreaBounds().height - __pSearchBar->GetY() - __pSearchBar->GetHeight());
1136 __pListview->SetBounds(__pListview->GetX(),0,GetClientAreaBounds().width ,GetClientAreaBounds().height);
1138 __pListview->UpdateList();
1141 if (__pSearchListView && __pListview)
1143 AppLog("__pListview->GetBounds() %d, %d, %d, %d",__pListview->GetBounds().x,__pListview->GetBounds().y,__pListview->GetBounds().width,__pListview->GetBounds().height);
1144 __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1146 __pSearchListView->UpdateList();
1149 if (__pSearchListView && __pData != null )
1151 if (__parentID != DEFAULT_VALUE_PARENTID)
1153 AppLog("BookmarkListForm::OnOrientationChanged parent id true");
1154 __pSearchBar->SetShowState(false);
1155 __pSearchBar->Invalidate(true);
1158 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height));
1166 BookmarkListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
1168 if (__pData != null)
1170 __pData->RemoveAll(true);
1174 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);