2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (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 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
318 GetHeader()->SetItemSelected(0);
319 GetHeader()->Invalidate(true);
320 SceneManager* pSceneManager = SceneManager::GetInstance();
321 pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(__selectedindex));
323 if ( pBookMark == NULL )
328 ArrayList* pArgList = null;
329 pArgList = new(std::nothrow) ArrayList();
330 if (pArgList != null)
332 pArgList->Construct();
333 pArgList->Add(*new(std::nothrow) String(pBookMark->GetParentId()));
335 //pArgList->Add(*new(std::nothrow) String(pBookmark->);
336 if (pSceneManager != null)
338 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_EDIT_BOOKMARK_LIST),pArgList) != E_SUCCESS)
340 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
341 pArgList->RemoveAll(true);
348 if ( pArgList != NULL)
350 pArgList->RemoveAll(true);
356 case IDA_TABBAR_ITEM_2:
358 GetHeader()->SetItemSelected(0);
359 GetHeader()->Invalidate(true);
361 SceneManager* pSceneManager = SceneManager::GetInstance();
363 if (pSceneManager != null)
365 if(__previousSceneId.CompareTo(IDSCN_HISTORY_LIST) != 0)
367 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT)) != E_SUCCESS)
369 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
376 if(pSceneManager->GoBackward(BackwardSceneTransition())!= E_SUCCESS)
378 AppLogDebug("BookmarkListForm::OnActionPerformed GoBackward failed");
386 case IDA_FOOTER_ITEM2:
388 SceneManager* pSceneManager = SceneManager::GetInstance();
392 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_BOOKMARK_FOLDER)) != E_SUCCESS)
394 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
400 case IDA_FOOTER_ITEM_ADDBOOKMARK:
402 SceneManager* pSceneManager = SceneManager::GetInstance();
404 // send array list 0-for add, 1 for edit with parent ID
405 ArrayList* pArgList = null;
406 pArgList = new(std::nothrow) ArrayList();
407 if (pArgList != null)
409 pArgList->Construct();
410 pArgList->Add(*new(std::nothrow) String(L"0"));
411 pArgList->Add(*new(std::nothrow) String(__parentID));
416 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ADD_BOOKMARK),pArgList) != E_SUCCESS)
418 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
419 pArgList->RemoveAll(true);
425 if (pArgList != null)
427 pArgList->RemoveAll(true);
434 __pConfirmationPopup->SetShowState(false);
435 __pConfirmationPopup->Show();
438 pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(__selectedindex));
439 if ( pBookMark== null)
441 bookmarkId=pBookMark->GetBookmarkId();
442 Integer::Parse(bookmarkId,id);
443 if (pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
444 BookmarkPresentationModel::GetInstance()->DeleteFolder(id);
446 BookmarkPresentationModel::GetInstance()->DeleteBookmark(id);
447 if (__pListview == null)
451 AppLogDebug("__pListview GetBounds %d,%d,%d,%d",__pListview->GetBounds().x,__pListview->GetBounds().y,__pListview->GetBounds().width,__pListview->GetBounds().height);
452 __pSearchListView->UpdateList();
453 __pListview->UpdateList();
455 if (__pListview->GetItemCount() == 0)
457 GetFooter()->SetItemEnabled(1,false);
458 __pSearchBar->SetShowState(false);
459 __pSearchBar->Invalidate(true);
462 if (__noBookmarks == true)
464 Bitmap* emptyListBmp = AppResource::GetInstance()->GetBitmapN(IDB_NO_CONTENT_BOOKMARK);
465 GetFooter()->SetItemEnabled(1,false);
466 __pSearchBar->SetShowState(false);
467 __pSearchBar->Invalidate(true);
468 // __pListview->SetBounds(__pSearchBar->GetPosition().x,__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
469 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
470 __pListview->SetBitmapOfEmptyList(emptyListBmp);
476 __pListview->UpdateList();
481 GetFooter()->SetItemEnabled(1,true);
483 if (__parentID.CompareTo(L"0") == 0)
485 __pSearchBar->SetShowState(true);
486 __pSearchBar->Invalidate(true);
490 GetFooter()->Invalidate(true);
491 __pConfirmationPopup->SetShowState(false);
492 __pConfirmationPopup->Show();
502 BookmarkListForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
504 AppLogDebug("BrowserApplicationForm::OnFormBackRequested");
506 UiApp* pApp = UiApp::GetInstance();
512 if (__parentID != DEFAULT_VALUE_PARENTID)
514 __parentID = DEFAULT_VALUE_PARENTID;
515 __pSearchBar->SetShowState(true);
516 __pListview->SetBounds(__pListview->GetX() ,__pSearchBar->GetPosition().y + __pSearchBar->GetHeight(),__pListview->GetWidth(),GetClientAreaBounds().height - (__pSearchBar->GetY() + __pSearchBar->GetHeight()));
517 __pListview->UpdateList();
518 __pFooter = GetFooter();
519 GetFooter()->SetItemEnabled(2,true);
520 GetFooter()->Invalidate(true);
524 SceneManager* pSceneManager = SceneManager::GetInstance();
525 if (pSceneManager != null)
527 if(__previousSceneId.CompareTo(IDSCN_HISTORY_LIST) != 0)
529 pSceneManager->GoBackward(BackwardSceneTransition());
533 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
538 if (__noBookmarks == true)
540 GetFooter()->SetItemEnabled(1,false);
544 GetFooter()->SetItemEnabled(1,true);
548 Tizen::Ui::Controls::ListItemBase*
549 BookmarkListForm::CreateItem(int index, int itemWidth)
552 AppLog("BookmarkListForm::CreateItem index %d , itemWidth %d",index, itemWidth);
553 AppLog("listviewwidth %d",__pListview->GetWidth());
554 result r = E_FAILURE;
555 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
560 CustomItem* pItem = new(std::nothrow) CustomItem();
562 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
563 Bitmap* pBitmap = null;
566 Image* pImage = null;
567 pImage = new Image();
570 const int x_Margin_Icon = 16; // local as there used only in this function
571 const int y_Margin_Icon = 28;
572 const int height_Icon = 72;
573 const int width_Icon = 72 ;
574 const int x_Margin_Title = 104 ;
575 const int y_Margin_Title = 10;
576 const int width_Title = GetClientAreaBounds().width - 108 - 52 - 30;
577 const int x_Margin_Url = 104 ;
578 const int y_Margin_Url = 70 ;
579 const int width_Url = GetClientAreaBounds().width - 108 - 52 ;
580 const int height_Url = 48;
581 const int itemHeight = 128;
582 const int textSize = 32;
585 if( pBookMark == NULL )
591 if ( pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER )
593 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth,112), LIST_ANNEX_STYLE_DETAILED);
594 TryCatch(!IsFailed(r),,"BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
596 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_FOLDER_OPEN);
599 pItem->AddElement(Rectangle(x_Margin_Icon, 20, width_Icon, height_Icon), IDA_FORMAT_ICON, *pBitmap, null);
603 pItem->AddElement(Rectangle(x_Margin_Title, 26, width_Title, 60), IDA_FORMAT_FOLDER, pBookMark->GetBookmarkTitle(), true);
605 if ( __pItemContextFolder != NULL)
607 pItem->SetContextItem(__pItemContextFolder);
612 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth, itemHeight), style);
613 TryCatch( !IsFailed(r),,"BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
615 AppLogDebug("BookmarkListForm::faviconid %ls",pBookMark->GetFaviconId().GetPointer());
616 bitmapId = pBookMark->GetFaviconId();
618 dim = Dimension(pBookMark->GetFavIconWidth(), pBookMark->GetFavIconHeight());
620 AppLog("BookmarkListForm::CreateItem check 0");
622 // get fav icon bitmap
623 ByteBuffer* pFavIconBuffer = null;
624 pFavIconBuffer = pBookMark->GetFavIconBuffer();
626 AppLog("BookmarkListForm::CreateItem check 0");
628 if (pFavIconBuffer != null)
630 AppLog("BookmarkListForm::CreateItem pFavIconBuffer is not null");
634 AppLog("BookmarkListForm::CreateItem pFavIconBuffer is null");
637 pBitmap = pImage->DecodeN(*pFavIconBuffer, IMG_FORMAT_PNG, BITMAP_PIXEL_FORMAT_ARGB8888);
639 AppLog("BookmarkListForm::CreateItem check 1");
643 AppLog("rahul bitmap is not null");
644 int width = pBitmap->GetWidth();
645 int height = pBitmap->GetHeight();
646 AppLog("rahul bitmap width is %d", width);
647 AppLog("rahul bitmap height is %d", height);
648 AppLog("rahul favicon width is %d", pBookMark->GetFavIconWidth());
649 AppLog("rahul favicon height is %d", pBookMark->GetFavIconHeight());
653 AppLog("rahul bitmap is null");
658 AppLogDebug("BookmarkListForm::CreateItem bitmap is null");
659 pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
661 pItem->AddElement(Rectangle(x_Margin_Icon, y_Margin_Icon, width_Icon, height_Icon), IDA_FORMAT_ICON, *pBitmap, null);
662 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);
663 if(__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
664 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);
666 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);
672 if ( __pItemContextSite != NULL)
674 pItem->SetContextItem(__pItemContextSite);
691 BookmarkListForm::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
699 BookmarkListForm::GetItemCount(void)
703 if (__pData != NULL )
705 __pData->RemoveAll(true);
709 __pData = new(std::nothrow) Collection::ArrayList();
710 __pData->Construct();
712 if (__searchBookmark == false)
714 BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID, count);
715 BookmarkPresentationModel::GetInstance()->GetFoldersBookmarks(__parentID, 0, count, *__pData);
719 BookmarkPresentationModel::GetInstance()->GetSearchFolderBookmarkCount(count,__searchText);
720 BookmarkPresentationModel::GetInstance()->GetSearchFoldersBookmarks(0, count, *__pData, __searchText);
723 AppLogDebug("Count = %d parentId = %ls", count, __parentID.GetPointer());
727 __noBookmarks = true;
728 GetFooter()->SetItemEnabled(1,false);
732 __noBookmarks = false;
733 GetFooter()->SetItemEnabled(1,true);
736 AppLogDebug("Result: %s", GetErrorMessage(GetLastResult()));
737 GetFooter()->Invalidate(true);
738 if (__pData != null && __pData->GetCount() >= 1)
740 // __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
741 __pSearchBar->SetShowState(true);
742 __pSearchBar->Invalidate(true);
744 else if (__searchBookmark == false)
746 __pSearchBar->SetShowState(false);
747 __pSearchBar->Invalidate(true);
750 if (__parentID.CompareTo(L"0") != 0)
752 __pSearchBar->SetShowState(false);
753 __pSearchBar->Invalidate(true);
755 if (__noBookmarks == true)
757 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
758 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_NO_CONTENT_BOOKMARK);
760 if ( pBitmap != NULL)
762 __pListview->SetBitmapOfEmptyList(pBitmap);
768 if (__parentID.CompareTo(L"0") == 0)
770 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetHeight(),GetClientAreaBounds().width ,GetClientAreaBounds().height - __pSearchBar->GetY() - __pSearchBar->GetHeight());
774 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
779 __pListview->Invalidate(true);
785 BookmarkListForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
787 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged int index %d, int elementId %d, Tizen::Ui::Controls::ListContextItemStatus status %d",index,elementId,status);
789 String deleteText = CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB");
790 deleteText.Append(L"? ");
792 result r = E_SUCCESS;
796 case IDA_CONTEXT_ITEM_FOLDER_EDIT:
798 ArrayList* pArgList = null;
799 String* pEdit = null;
801 SceneManager* pSceneManager = SceneManager::GetInstance();
802 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
803 if (pBookMark != null && pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
805 pArgList = new(std::nothrow) ArrayList();
806 if (pArgList != null)
808 pEdit= new(std::nothrow) String(CommonUtil::GetString(L"IDS_BR_HEADER_EDIT_FOLDER"));
809 pArgList->Construct();
810 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
811 pArgList->Add(*pEdit);
812 if ( pSceneManager != null)
815 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_BOOKMARK_FOLDER), pArgList);
818 if (pArgList != null)
825 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged GoForward failed %s",GetErrorMessage(r));
834 case IDA_CONTEXT_ITEM_FOLDER_DELETE:
835 case IDA_CONTEXT_ITEM_DELETE:
837 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
838 __pConfirmationPopup->Initialize();
839 __pConfirmationPopup->RemoveActionListener(*this);
840 __pConfirmationPopup->AddActionListener(*this);
841 __pConfirmationPopup->setMessage(deleteText);
842 __pConfirmationPopup->Show();
843 __selectedindex = index;
847 case IDA_CONTEXT_ITEM_EDIT:
849 ArrayList* pArgList = null;
850 SceneManager* pSceneManager = SceneManager::GetInstance();
851 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
852 if (pBookMark!= null && pBookMark->GetBookmarkType() == BOOKMARK_TYPE_URL)
854 AppLogDebug("ID_CONTEXT_ITEM_SITE_1 BOOKMARK_TYPE_URL");
855 pArgList = new(std::nothrow) ArrayList();
856 if (pArgList != null)
858 pArgList->Construct();
859 pArgList->Add(*new(std::nothrow) String(L"1"));
860 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
861 if ( pSceneManager != null)
864 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ADD_BOOKMARK), pArgList);
865 if (pArgList != null)
872 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged GoForward failed %s",GetErrorMessage(r));
880 case IDA_CONTEXT_ITEM_SHARE:
882 AppLogDebug("OnListViewContextItemStateChanged Share");
884 BookmarkData* pBookmark = dynamic_cast<BookmarkData*>(__pData->GetAt(index));
885 if (pBookmark != null)
887 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
888 pShareInfo->SetPageTitle(pBookmark->GetBookmarkTitle());
889 pShareInfo->SetPageUrl(pBookmark->GetUrl());
890 pShareInfo->SetImageAttached(false);
891 __pPopUp->RemoveAllShareInfo();
892 __pPopUp->AddShareInfo(pShareInfo);
895 if (__pPopUp != null)
897 __pPopUp->SetShowState(true);
909 BookmarkListForm::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
915 BookmarkListForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
917 AppLogDebug("BookmarkListForm::OnListViewItemStateChanged");
919 result r = E_FAILURE;
920 ArrayList *pArgList = null;
921 SceneManager* pSceneManager = SceneManager::GetInstance();
922 BookmarkData* pBookmark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
924 if ( pBookmark == NULL )
929 switch (pBookmark->GetBookmarkType())
931 case BOOKMARK_TYPE_FOLDER:
933 __parentID = pBookmark->GetBookmarkId();
934 AppLogDebug("BOOKMARK_TYPE_FOLDER parent ID is %ls",__parentID.GetPointer());
936 listView.UpdateList();
937 if (listView.GetItemCount() == 0)
939 GetFooter()->SetItemEnabled(1,false);
943 GetFooter()->SetItemEnabled(1,true);
945 GetFooter()->SetItemEnabled(2,false);
946 GetFooter()->Invalidate(true);
947 __pSearchBar->HideKeypad();
948 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
949 __pSearchBar->SetShowState(false);
950 __pSearchBar->Invalidate(true);
951 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pListview->GetWidth() ,GetClientAreaBounds().height);
954 case BOOKMARK_TYPE_URL:
956 pArgList = new(std::nothrow) ArrayList();
957 if (pArgList != null)
959 r = pArgList->Construct();
960 TryCatch(!IsFailed(r), L"BookmarkListForm::OnListViewItemStateChanged pArgList Construct failed %s", GetErrorMessage(r));
962 AppLogDebug("bookmark url = %ls",pBookmark->GetUrl().GetPointer());
963 r = pArgList->Add(*MultipleWindowPresentationModel::GetInstance()->GetActiveWindowInfo());
964 pArgList->Add(*new(std::nothrow) String(pBookmark->GetUrl()));
966 if (pSceneManager != null)
968 AppLogDebug("pSceneManager exists");
970 MultipleWindowPresentationModel::GetInstance()->GetCurrentSceneId(prevSceneId);
971 r = pSceneManager->GoBackward(BackwardSceneTransition(prevSceneId), pArgList);
972 TryCatch(!IsFailed(r), L"BookmarkListForm::OnListViewItemStateChanged pArgList Construct failed %s", GetErrorMessage(r));
986 pArgList->RemoveAll(true);
993 BookmarkListForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1000 BookmarkListForm::OnFastScrollIndexSelected(Tizen::Ui::Control& source, Tizen::Base::String& index)
1006 BookmarkListForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
1008 result r = E_FAILURE;
1010 if (mode == SEARCH_BAR_MODE_NORMAL)
1012 __pSearchListView->SetShowState(false);
1013 __pSearchListView->UpdateList();
1014 __pListview->SetShowState(true);
1016 __searchBookmark = false;
1017 r = __pListview->UpdateList();
1018 // __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1019 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1020 TryCatch( !IsFailed(r),,"BookmarkListForm::OnSearchBarModeChanged Update list failed %s",GetErrorMessage(r));
1025 __pSearchListView->SetShowState(true);
1026 __pSearchListView->SetEnabled(false);
1027 __pListview->SetShowState(false);
1031 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1032 __pSearchBar->SetText(L"");
1034 AppLog("OnSearchBarModeChanged SetContentAreaSize heihgt %d",__pSearchListView->GetHeight());
1035 __pListview->UpdateList();
1036 __pSearchListView->UpdateList();
1041 BookmarkListForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
1043 // GetFooter()->SetShowState(false);
1044 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), __pSearchListView->GetHeight() + GetFooter()->GetHeight());
1045 __pSearchListView->SetEnabled(false);
1046 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1048 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), __pSearchListView->GetHeight() - GetFooter()->GetHeight());
1052 BookmarkListForm::OnKeypadOpened(Tizen::Ui::Control& source)
1054 GetFooter()->SetShowState(false);
1055 // __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1056 __pSearchListView->UpdateList();
1061 BookmarkListForm::OnKeypadClosed(Tizen::Ui::Control& source)
1063 AppLog("jahsjkdad %d",Clipboard::GetInstance()->IsPopupVisible());
1064 if(Clipboard::GetInstance()->IsPopupVisible() == true)
1068 GetFooter()->SetShowState(true);
1069 GetFooter()->Invalidate(true);
1070 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1071 __pListview->SetBounds(__pSearchListView->GetX(), __pSearchBar->GetY() + __pSearchBar->GetHeight(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1072 __pSearchListView->Invalidate(false);
1073 //__pSearchListView->SetEnabled(true);
1074 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1079 BookmarkListForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
1081 AppLog("BookmarkListForm::OnKeypadActionPerformed %d",keypadAction);
1083 if ( __pSearchBar != null && keypadAction == KEYPAD_ACTION_SEARCH)
1085 if (__pSearchBar->GetText().GetLength() == 0)
1090 if (__pSearchBar != null)
1092 __pSearchBar->HideKeypad();
1095 __searchText = __pSearchBar->GetText();
1096 __searchBookmark = true;
1097 __pListview->SetShowState(false);
1098 __pSearchListView->SetEnabled(true);
1099 __pSearchListView->SetShowState(true);
1100 __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1101 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1102 __pSearchListView->UpdateList();
1109 BookmarkListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
1111 AppLogDebug("BookmarkListForm::OnSceneActivatedN called");
1112 ArrayListT<String> * pList = dynamic_cast<ArrayListT<String>* >(SceneManager::GetInstance()->GetSceneHistoryN());
1115 pList->GetAt(pList->GetCount()-1,__previousSceneId);
1118 __searchBookmark = false;
1119 GetFooter()->SetShowState(true);
1120 GetFooter()->Invalidate(true);
1121 GetHeader()->SetItemSelected(0);
1122 GetHeader()->Invalidate(true);
1124 /* if (previousSceneId != IDSCN_HISTORY_LIST && previousSceneId != IDSCN_CREATE_BOOKMARK_FOLDER && previousSceneId != IDSCN_EDIT_BOOKMARK_LIST)
1126 __previousSceneId = previousSceneId;
1129 if (__pListview != null)
1131 __pListview->UpdateList();
1138 BookmarkListForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
1140 AppLog("BookmarkListForm::OnOrientationChanged start");
1144 if(__pSearchBar->GetShowState())
1146 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetHeight(),GetClientAreaBounds().width ,GetClientAreaBounds().height - __pSearchBar->GetY() - __pSearchBar->GetHeight());
1150 __pListview->SetBounds(__pListview->GetX(),0,GetClientAreaBounds().width ,GetClientAreaBounds().height);
1152 __pListview->UpdateList();
1155 if (__pSearchListView && __pListview)
1157 AppLog("__pListview->GetBounds() %d, %d, %d, %d",__pListview->GetBounds().x,__pListview->GetBounds().y,__pListview->GetBounds().width,__pListview->GetBounds().height);
1158 __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1160 __pSearchListView->UpdateList();
1163 if (__pSearchListView && __pData != null )
1165 if (__parentID != DEFAULT_VALUE_PARENTID)
1167 AppLog("BookmarkListForm::OnOrientationChanged parent id true");
1168 __pSearchBar->SetShowState(false);
1169 __pSearchBar->Invalidate(true);
1172 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height));
1180 BookmarkListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
1182 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);