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 )
593 if ( pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER )
595 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth,112), LIST_ANNEX_STYLE_DETAILED);
596 TryCatch(!IsFailed(r),,"BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
598 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_FOLDER_OPEN);
601 pItem->AddElement(Rectangle(x_Margin_Icon, 20, width_Icon, height_Icon), IDA_FORMAT_ICON, *pBitmap, null);
605 pItem->AddElement(Rectangle(x_Margin_Title, 26, width_Title, 60), IDA_FORMAT_FOLDER, pBookMark->GetBookmarkTitle(), true);
607 if ( __pItemContextFolder != NULL)
609 pItem->SetContextItem(__pItemContextFolder);
614 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth, itemHeight), style);
615 TryCatch( !IsFailed(r),,"BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
617 AppLogDebug("BookmarkListForm::faviconid %ls",pBookMark->GetFaviconId().GetPointer());
618 bitmapId = pBookMark->GetFaviconId();
620 dim = Dimension(pBookMark->GetFavIconWidth(), pBookMark->GetFavIconHeight());
622 AppLog("BookmarkListForm::CreateItem check 0");
624 // get fav icon bitmap
625 ByteBuffer* pFavIconBuffer = null;
626 pFavIconBuffer = pBookMark->GetFavIconBuffer();
628 AppLog("BookmarkListForm::CreateItem check 0");
630 if (pFavIconBuffer != null)
632 AppLog("BookmarkListForm::CreateItem pFavIconBuffer is not null");
636 AppLog("BookmarkListForm::CreateItem pFavIconBuffer is null");
639 pBitmap = pImage->DecodeN(*pFavIconBuffer, IMG_FORMAT_PNG, BITMAP_PIXEL_FORMAT_ARGB8888);
641 AppLog("BookmarkListForm::CreateItem check 1");
645 AppLog("rahul bitmap is not null");
646 int width = pBitmap->GetWidth();
647 int height = pBitmap->GetHeight();
648 AppLog("rahul bitmap width is %d", width);
649 AppLog("rahul bitmap height is %d", height);
650 AppLog("rahul favicon width is %d", pBookMark->GetFavIconWidth());
651 AppLog("rahul favicon height is %d", pBookMark->GetFavIconHeight());
655 AppLog("rahul bitmap is null");
660 AppLogDebug("BookmarkListForm::CreateItem bitmap is null");
661 pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
663 pItem->AddElement(Rectangle(x_Margin_Icon, y_Margin_Icon, width_Icon, height_Icon), IDA_FORMAT_ICON, *pBitmap, null);
664 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);
665 // if(__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
666 // 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);
668 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);
674 if ( __pItemContextSite != NULL)
676 pItem->SetContextItem(__pItemContextSite);
693 BookmarkListForm::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
701 BookmarkListForm::GetItemCount(void)
705 if (__pData != NULL )
707 __pData->RemoveAll(true);
711 __pData = new(std::nothrow) Collection::ArrayList();
712 __pData->Construct();
714 if (__searchBookmark == false)
716 BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID, count);
717 BookmarkPresentationModel::GetInstance()->GetFoldersBookmarks(__parentID, 0, count, *__pData);
721 BookmarkPresentationModel::GetInstance()->GetSearchFolderBookmarkCount(count,__searchText);
722 BookmarkPresentationModel::GetInstance()->GetSearchFoldersBookmarks(0, count, *__pData, __searchText);
725 AppLogDebug("Count = %d parentId = %ls", count, __parentID.GetPointer());
729 __noBookmarks = true;
730 GetFooter()->SetItemEnabled(1,false);
734 __noBookmarks = false;
735 GetFooter()->SetItemEnabled(1,true);
738 AppLogDebug("Result: %s", GetErrorMessage(GetLastResult()));
739 GetFooter()->Invalidate(true);
740 if (__pData != null && __pData->GetCount() >= 1)
742 // __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
743 __pSearchBar->SetShowState(true);
744 __pSearchBar->Invalidate(true);
746 else if (__searchBookmark == false)
748 __pSearchBar->SetShowState(false);
749 __pSearchBar->Invalidate(true);
752 if (__parentID.CompareTo(L"0") != 0)
754 __pSearchBar->SetShowState(false);
755 __pSearchBar->Invalidate(true);
757 if (__noBookmarks == true)
759 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
760 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_NO_CONTENT_BOOKMARK);
762 if ( pBitmap != NULL)
764 __pListview->SetBitmapOfEmptyList(pBitmap);
770 if (__parentID.CompareTo(L"0") == 0)
772 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetHeight(),GetClientAreaBounds().width ,GetClientAreaBounds().height - __pSearchBar->GetY() - __pSearchBar->GetHeight());
776 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
781 __pListview->Invalidate(true);
787 BookmarkListForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
789 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged int index %d, int elementId %d, Tizen::Ui::Controls::ListContextItemStatus status %d",index,elementId,status);
791 String deleteText = CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB");
792 deleteText.Append(L"? ");
794 result r = E_SUCCESS;
798 case IDA_CONTEXT_ITEM_FOLDER_EDIT:
800 ArrayList* pArgList = null;
801 String* pEdit = null;
803 SceneManager* pSceneManager = SceneManager::GetInstance();
804 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
805 if (pBookMark != null && pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
807 pArgList = new(std::nothrow) ArrayList();
808 if (pArgList != null)
810 pEdit= new(std::nothrow) String(CommonUtil::GetString(L"IDS_BR_HEADER_EDIT_FOLDER"));
811 pArgList->Construct();
812 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
813 pArgList->Add(*pEdit);
814 if ( pSceneManager != null)
817 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_BOOKMARK_FOLDER), pArgList);
820 if (pArgList != null)
827 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged GoForward failed %s",GetErrorMessage(r));
836 case IDA_CONTEXT_ITEM_FOLDER_DELETE:
837 case IDA_CONTEXT_ITEM_DELETE:
839 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
840 __pConfirmationPopup->Initialize();
841 __pConfirmationPopup->RemoveActionListener(*this);
842 __pConfirmationPopup->AddActionListener(*this);
843 __pConfirmationPopup->setMessage(deleteText);
844 __pConfirmationPopup->Show();
845 __selectedindex = index;
849 case IDA_CONTEXT_ITEM_EDIT:
851 ArrayList* pArgList = null;
852 SceneManager* pSceneManager = SceneManager::GetInstance();
853 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
854 if (pBookMark!= null && pBookMark->GetBookmarkType() == BOOKMARK_TYPE_URL)
856 AppLogDebug("ID_CONTEXT_ITEM_SITE_1 BOOKMARK_TYPE_URL");
857 pArgList = new(std::nothrow) ArrayList();
858 if (pArgList != null)
860 pArgList->Construct();
861 pArgList->Add(*new(std::nothrow) String(L"1"));
862 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
863 if ( pSceneManager != null)
866 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ADD_BOOKMARK), pArgList);
867 if (pArgList != null)
874 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged GoForward failed %s",GetErrorMessage(r));
882 case IDA_CONTEXT_ITEM_SHARE:
884 AppLogDebug("OnListViewContextItemStateChanged Share");
886 BookmarkData* pBookmark = dynamic_cast<BookmarkData*>(__pData->GetAt(index));
887 if (pBookmark != null)
889 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
890 pShareInfo->SetPageTitle(pBookmark->GetBookmarkTitle());
891 pShareInfo->SetPageUrl(pBookmark->GetUrl());
892 pShareInfo->SetImageAttached(false);
893 __pPopUp->RemoveAllShareInfo();
894 __pPopUp->AddShareInfo(pShareInfo);
897 if (__pPopUp != null)
899 __pPopUp->SetShowState(true);
911 BookmarkListForm::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
917 BookmarkListForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
919 AppLogDebug("BookmarkListForm::OnListViewItemStateChanged");
921 result r = E_FAILURE;
922 ArrayList *pArgList = null;
923 SceneManager* pSceneManager = SceneManager::GetInstance();
924 BookmarkData* pBookmark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
926 if ( pBookmark == NULL )
931 switch (pBookmark->GetBookmarkType())
933 case BOOKMARK_TYPE_FOLDER:
935 __parentID = pBookmark->GetBookmarkId();
936 AppLogDebug("BOOKMARK_TYPE_FOLDER parent ID is %ls",__parentID.GetPointer());
938 listView.UpdateList();
939 if (listView.GetItemCount() == 0)
941 GetFooter()->SetItemEnabled(1,false);
945 GetFooter()->SetItemEnabled(1,true);
947 GetFooter()->SetItemEnabled(2,false);
948 GetFooter()->Invalidate(true);
949 __pSearchBar->HideKeypad();
950 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
951 __pSearchBar->SetShowState(false);
952 __pSearchBar->Invalidate(true);
953 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pListview->GetWidth() ,GetClientAreaBounds().height);
956 case BOOKMARK_TYPE_URL:
958 pArgList = new(std::nothrow) ArrayList();
959 if (pArgList != null)
961 r = pArgList->Construct();
962 TryCatch(!IsFailed(r), L"BookmarkListForm::OnListViewItemStateChanged pArgList Construct failed %s", GetErrorMessage(r));
964 AppLogDebug("bookmark url = %ls",pBookmark->GetUrl().GetPointer());
965 r = pArgList->Add(*MultipleWindowPresentationModel::GetInstance()->GetActiveWindowInfo());
966 pArgList->Add(*new(std::nothrow) String(pBookmark->GetUrl()));
968 if (pSceneManager != null)
970 AppLogDebug("pSceneManager exists");
972 MultipleWindowPresentationModel::GetInstance()->GetCurrentSceneId(prevSceneId);
973 r = pSceneManager->GoBackward(BackwardSceneTransition(prevSceneId), pArgList);
974 TryCatch(!IsFailed(r), L"BookmarkListForm::OnListViewItemStateChanged pArgList Construct failed %s", GetErrorMessage(r));
988 pArgList->RemoveAll(true);
995 BookmarkListForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1002 BookmarkListForm::OnFastScrollIndexSelected(Tizen::Ui::Control& source, Tizen::Base::String& index)
1008 BookmarkListForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
1010 result r = E_FAILURE;
1011 AppLog("ABCD::BookmarkListForm::OnSearchBarModeChanged");
1013 if (mode == SEARCH_BAR_MODE_NORMAL)
1015 __pSearchListView->SetShowState(false);
1016 __pSearchListView->UpdateList();
1017 __pListview->SetShowState(true);
1019 __searchBookmark = false;
1020 r = __pListview->UpdateList();
1021 // __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1022 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1023 TryCatch( !IsFailed(r),,"BookmarkListForm::OnSearchBarModeChanged Update list failed %s",GetErrorMessage(r));
1028 __pSearchListView->SetShowState(true);
1029 __pSearchListView->SetEnabled(false);
1030 __pListview->SetShowState(false);
1034 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1035 __pSearchBar->SetText(L"");
1037 AppLog("OnSearchBarModeChanged SetContentAreaSize heihgt %d",__pSearchListView->GetHeight());
1038 __pListview->UpdateList();
1039 __pSearchListView->UpdateList();
1044 BookmarkListForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
1046 AppLog("ABCD::BookmarkListForm::OnKeypadWillOpen");
1048 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight());
1049 __pSearchListView->SetEnabled(false);
1050 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1055 BookmarkListForm::OnKeypadOpened(Tizen::Ui::Control& source)
1057 AppLog("ABCD::BookmarkListForm::OnKeypadOpened");
1058 GetFooter()->SetShowState(false);
1059 AppLog("ABCD::BookmarkListForm::OnKeypadOpened");
1060 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1061 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1066 BookmarkListForm::OnKeypadClosed(Tizen::Ui::Control& source)
1068 AppLog("ABCD::BookmarkListForm::OnKeypadClosed");
1069 AppLog("jahsjkdad %d",Clipboard::GetInstance()->IsPopupVisible());
1070 if(Clipboard::GetInstance()->IsPopupVisible() == true)
1074 GetFooter()->SetShowState(true);
1075 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1076 __pSearchListView->Invalidate(false);
1077 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1078 __pListview->SetBounds(0, __pSearchBar->GetY() + __pSearchBar->GetHeight(), GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight());
1083 BookmarkListForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
1085 AppLog("BookmarkListForm::OnKeypadActionPerformed %d",keypadAction);
1087 if (__pSearchBar != null)
1089 __pSearchBar->HideKeypad();
1091 if ( __pSearchBar != null && keypadAction == KEYPAD_ACTION_SEARCH)
1093 // if (__pSearchBar->GetText().GetLength() == 0)
1098 if (__pSearchBar != null)
1100 __pSearchBar->HideKeypad();
1103 __searchText = __pSearchBar->GetText();
1104 __searchBookmark = true;
1105 __pListview->SetShowState(false);
1106 __pSearchListView->SetEnabled(true);
1107 __pSearchListView->SetShowState(true);
1108 __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1109 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1110 __pSearchListView->UpdateList();
1117 BookmarkListForm::OnKeypadBoundsChanged(Tizen::Ui::Control& source)
1119 FloatRectangle clientRect;
1120 clientRect = GetClientAreaBoundsF();
1121 AppLogDebug("SearchBarForm::OnKeypadBoundsChanged ClientBounds(%f, %f, %f, %f)",clientRect.x, clientRect.y, clientRect.width, clientRect.height);
1122 __pSearchBar->SetContentAreaSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1123 __pSearchListView->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1124 __pListview->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1125 // __pListview->SetEnabled(false);
1130 BookmarkListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
1132 AppLogDebug("BookmarkListForm::OnSceneActivatedN called");
1133 ArrayListT<String> * pList = dynamic_cast<ArrayListT<String>* >(SceneManager::GetInstance()->GetSceneHistoryN());
1136 pList->GetAt(pList->GetCount()-1,__previousSceneId);
1139 __searchBookmark = false;
1140 GetFooter()->SetShowState(true);
1141 GetFooter()->Invalidate(true);
1142 GetHeader()->SetItemSelected(0);
1143 GetHeader()->Invalidate(true);
1145 /* if (previousSceneId != IDSCN_HISTORY_LIST && previousSceneId != IDSCN_CREATE_BOOKMARK_FOLDER && previousSceneId != IDSCN_EDIT_BOOKMARK_LIST)
1147 __previousSceneId = previousSceneId;
1150 if (__pListview != null)
1152 __pListview->UpdateList();
1159 BookmarkListForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
1161 AppLog("BookmarkListForm::OnOrientationChanged start");
1162 __pListview->SetBackgroundColor(GetBackgroundColor());
1163 __pSearchListView->SetBackgroundColor(GetBackgroundColor());
1166 if(__pSearchBar->GetShowState())
1168 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetHeight(),GetClientAreaBounds().width ,GetClientAreaBounds().height - __pSearchBar->GetY() - __pSearchBar->GetHeight());
1172 __pListview->SetBounds(__pListview->GetX(),0,GetClientAreaBounds().width ,GetClientAreaBounds().height);
1174 __pListview->UpdateList();
1177 if (__pSearchListView && __pListview)
1179 AppLog("__pListview->GetBounds() %d, %d, %d, %d",__pListview->GetBounds().x,__pListview->GetBounds().y,__pListview->GetBounds().width,__pListview->GetBounds().height);
1180 __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1182 __pSearchListView->UpdateList();
1185 if (__pSearchListView && __pData != null )
1187 if (__parentID != DEFAULT_VALUE_PARENTID)
1189 AppLog("BookmarkListForm::OnOrientationChanged parent id true");
1190 __pSearchBar->SetShowState(false);
1191 __pSearchBar->Invalidate(true);
1194 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1200 // FloatRectangle clientRect;
1201 // clientRect = GetClientAreaBoundsF();
1203 // __pSearchBar->SetContentAreaSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1204 // __pListview->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1205 // __pSearchListView->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1206 // Invalidate(true);
1213 BookmarkListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
1215 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);