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;
84 BookmarkListForm::~BookmarkListForm(void)
89 __pData->RemoveAll(true);
94 if (__pItemContextFolder != null)
96 delete __pItemContextFolder;
97 __pItemContextFolder = null;
100 if (__pItemContextSite != null)
102 delete __pItemContextSite;
103 __pItemContextSite = null;
108 BookmarkListForm::OnTerminating(void)
110 result r = E_SUCCESS;
114 __pData->RemoveAll(true);
124 BookmarkListForm::Initialize(void)
126 Construct(L"IDL_BOOKMARK_LIST");
131 BookmarkListForm::OnInitializing(void)
133 result r = E_SUCCESS;
136 Bitmap *pBitmapNormal = null;
137 Bitmap *pBitmapPressed = null;
138 Header *pHeader = GetHeader();
139 Bitmap *pIconBitmap = null;
140 AppResource* pAppResource = UiApp::GetInstance()->GetAppResource();
141 int bookmarkCount = 0;
142 const int WIDTH_CONTEXT_MENU_TWO_BUTTON = 336;
143 const int WIDTH_CONTEXT_MENU_THREE_BUTTON = 160;
144 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
147 // Setup back event listener
148 SetFormBackEventListener(this);
149 AddOrientationEventListener(*this);
151 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_BOOKMARK_VIEW, *this);
152 GetHeader()->AddActionEventListener(*this);
153 GetFooter()->AddActionEventListener(*this);
155 if ( pAppResource == NULL )
160 __pItemContextFolder = new(std::nothrow) ListContextItem();
161 __pItemContextFolder->Construct();
162 __pItemContextFolder->AddElement(IDA_CONTEXT_ITEM_FOLDER_EDIT, CommonUtil::GetString(L"IDS_BR_SK_EDIT"));
163 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_TWO_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
164 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_TWO_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
166 if (pBitmapNormal != null && pBitmapPressed != null)
168 __pItemContextFolder->AddElement(IDA_CONTEXT_ITEM_FOLDER_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
171 if (pBitmapNormal != null)
173 delete pBitmapNormal;
176 if (pBitmapPressed != null)
178 delete pBitmapPressed;
181 __pItemContextSite = new(std::nothrow) ListContextItem();
182 __pItemContextSite->Construct();
183 __pItemContextSite->AddElement(IDA_CONTEXT_ITEM_EDIT, CommonUtil::GetString(L"IDS_BR_SK_EDIT"));
184 __pItemContextSite->AddElement(IDA_CONTEXT_ITEM_SHARE, CommonUtil::GetString(L"IDS_BR_OPT_SHARE"));
185 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_THREE_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
186 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_THREE_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
188 if (pBitmapNormal != null && pBitmapPressed != null)
190 __pItemContextSite->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
193 if (pBitmapNormal != null)
195 delete pBitmapNormal;
198 if (pBitmapPressed != null)
200 delete pBitmapPressed;
202 __pListview = static_cast< ListView* >(GetControl("IDC_LISTVIEW1"));
204 if (__pListview == null)
208 __pSearchBar = static_cast< SearchBar* >(GetControl(L"IDC_SEARCHBAR1"));
210 if (__pSearchBar == null)
215 if (__pListview != null)
217 // __pListview->SetBounds(__pListview->GetX(), __pListview->GetY(), GetClientAreaBounds().width, GetClientAreaBounds().height);
218 __pListview->AddFastScrollListener(*this);
219 __pListview->AddListViewItemEventListener(*this);
220 __pListview->SetItemProvider(*this);
221 __pListview->UpdateList();
224 __pPopUp = new(std::nothrow) SharePopup();
226 if (__pPopUp != null)
228 __pPopUp->Initialize();
229 AddControl(*__pPopUp);
232 __pSearchListView = new(std::nothrow) ListView();
234 if (__pSearchListView == null)
239 r = __pSearchListView->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height -72 - 30), true, false);
240 TryCatch( !IsFailed(r),,"BookmarkListForm::OnSearchBarModeChanged Update list failed %s",GetErrorMessage(r));
242 __pSearchListView->SetItemProvider(*this);
243 __pSearchListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RESULTS_FOUND"));
244 __pSearchListView->SetTextColorOfEmptyList(Color::GetColor(COLOR_ID_BLACK));
245 __pSearchListView->SetShowState(false);
246 __pSearchListView->AddListViewItemEventListener(*this);
248 __pSearchBar->AddSearchBarEventListener(*this);
249 __pSearchBar->AddKeypadEventListener(*this);
250 __pSearchBar->SetContent(__pSearchListView);
252 BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID, bookmarkCount);
253 if(bookmarkCount <= 0)
255 __pSearchBar->SetShowState(false);
256 //__pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pSearchBar->GetWidth(),GetClientAreaBounds().height - __pSearchBar->GetPosition().y);
257 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pListview->GetWidth(),GetClientAreaBounds().height);
261 __pSearchBar->SetShowState(true);
267 pHeader->SetStyle(HEADER_STYLE_TAB);
268 bookmark.Construct(IDA_TABBAR_ITEM_1);
270 pAppResource->GetString(L"IDS_BR_TAB_BOOKMARKS", strbookmark);
271 bookmark.SetText(strbookmark);
272 pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_BOOKMARK);
273 bookmark.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);
274 bookmark.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
275 pHeader->AddItem(bookmark);
277 if (pIconBitmap != NULL)
282 history.Construct(IDA_TABBAR_ITEM_2);
284 pAppResource->GetString(L"IDS_BR_TAB_HISTORY", strhistory);
285 history.SetText(strhistory);
286 pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_HISTORY);
287 history.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);
288 history.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
289 pHeader->AddItem(history);
290 pHeader->SetItemSelected(0);
292 if (pIconBitmap != NULL)
303 BookmarkListForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
305 AppLogDebug("BookmarkListForm::OnActionPerformed actionId = %d",actionId);
308 BookmarkData* pBookMark = null;
312 case IDA_FOOTER_ITEM1:
314 GetHeader()->SetItemSelected(0);
315 GetHeader()->Invalidate(true);
316 SceneManager* pSceneManager = SceneManager::GetInstance();
317 pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(__selectedindex));
319 if ( pBookMark == NULL )
324 ArrayList* pArgList = null;
325 pArgList = new(std::nothrow) ArrayList();
326 if (pArgList != null)
328 pArgList->Construct();
329 pArgList->Add(*new(std::nothrow) String(pBookMark->GetParentId()));
331 //pArgList->Add(*new(std::nothrow) String(pBookmark->);
332 if (pSceneManager != null)
334 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_EDIT_BOOKMARK_LIST),pArgList) != E_SUCCESS)
336 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
337 pArgList->RemoveAll(true);
344 if ( pArgList != NULL)
346 pArgList->RemoveAll(true);
352 case IDA_TABBAR_ITEM_2:
354 GetHeader()->SetItemSelected(0);
355 GetHeader()->Invalidate(true);
357 SceneManager* pSceneManager = SceneManager::GetInstance();
359 if (pSceneManager != null)
361 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT)) != E_SUCCESS)
363 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
369 case IDA_FOOTER_ITEM2:
371 SceneManager* pSceneManager = SceneManager::GetInstance();
375 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_BOOKMARK_FOLDER)) != E_SUCCESS)
377 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
383 case IDA_FOOTER_ITEM_ADDBOOKMARK:
385 SceneManager* pSceneManager = SceneManager::GetInstance();
387 // send array list 0-for add, 1 for edit with parent ID
388 ArrayList* pArgList = null;
389 pArgList = new(std::nothrow) ArrayList();
390 if (pArgList != null)
392 pArgList->Construct();
393 pArgList->Add(*new(std::nothrow) String(L"0"));
394 pArgList->Add(*new(std::nothrow) String(__parentID));
399 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ADD_BOOKMARK),pArgList) != E_SUCCESS)
401 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
402 pArgList->RemoveAll(true);
408 if (pArgList != null)
410 pArgList->RemoveAll(true);
417 __pConfirmationPopup->SetShowState(false);
418 __pConfirmationPopup->Show();
421 pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(__selectedindex));
422 if ( pBookMark== null)
424 bookmarkId=pBookMark->GetBookmarkId();
425 Integer::Parse(bookmarkId,id);
426 if (pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
427 BookmarkPresentationModel::GetInstance()->DeleteFolder(id);
429 BookmarkPresentationModel::GetInstance()->DeleteBookmark(id);
430 if (__pListview == null)
434 AppLogDebug("__pListview GetBounds %d,%d,%d,%d",__pListview->GetBounds().x,__pListview->GetBounds().y,__pListview->GetBounds().width,__pListview->GetBounds().height);
435 __pSearchListView->UpdateList();
436 __pListview->UpdateList();
438 if (__pListview->GetItemCount() == 0)
440 GetFooter()->SetItemEnabled(1,false);
441 __pSearchBar->SetShowState(false);
442 __pSearchBar->Invalidate(true);
445 if (__noBookmarks == true)
447 Bitmap* emptyListBmp = AppResource::GetInstance()->GetBitmapN(IDB_NO_CONTENT_BOOKMARK);
448 GetFooter()->SetItemEnabled(1,false);
449 __pSearchBar->SetShowState(false);
450 __pSearchBar->Invalidate(true);
451 // __pListview->SetBounds(__pSearchBar->GetPosition().x,__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
452 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
453 __pListview->SetBitmapOfEmptyList(emptyListBmp);
459 __pListview->UpdateList();
464 GetFooter()->SetItemEnabled(1,true);
466 if (__parentID.CompareTo(L"-1") == 0)
468 __pSearchBar->SetShowState(true);
469 __pSearchBar->Invalidate(true);
473 GetFooter()->Invalidate(true);
474 __pConfirmationPopup->SetShowState(false);
475 __pConfirmationPopup->Show();
485 BookmarkListForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
487 AppLogDebug("BrowserApplicationForm::OnFormBackRequested");
489 UiApp* pApp = UiApp::GetInstance();
495 if (__parentID != DEFAULT_VALUE_PARENTID)
497 __parentID = DEFAULT_VALUE_PARENTID;
498 __pSearchBar->SetShowState(true);
499 __pListview->SetBounds(__pListview->GetX() ,__pSearchBar->GetPosition().y + __pSearchBar->GetHeight(),__pListview->GetWidth(),GetClientAreaBounds().height - (__pSearchBar->GetY() + __pSearchBar->GetHeight()));
500 __pListview->UpdateList();
501 __pFooter = GetFooter();
502 GetFooter()->SetItemEnabled(2,true);
503 GetFooter()->Invalidate(true);
507 SceneManager* pSceneManager = SceneManager::GetInstance();
508 if (pSceneManager != null)
510 pSceneManager->GoBackward(BackwardSceneTransition());
514 if (__noBookmarks == true)
516 GetFooter()->SetItemEnabled(1,false);
520 GetFooter()->SetItemEnabled(1,true);
524 Tizen::Ui::Controls::ListItemBase*
525 BookmarkListForm::CreateItem(int index, int itemWidth)
528 AppLog("BookmarkListForm::CreateItem index %d , itemWidth %d",index, itemWidth);
529 AppLog("listviewwidth %d",__pListview->GetWidth());
530 result r = E_FAILURE;
531 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
536 CustomItem* pItem = new(std::nothrow) CustomItem();
538 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
539 Bitmap* pBitmap = null;
542 Image* pImage = null;
543 pImage = new Image();
546 const int x_Margin_Icon = 16; // local as there used only in this function
547 const int y_Margin_Icon = 28;
548 const int height_Icon = 72;
549 const int width_Icon = 72 ;
550 const int x_Margin_Title = 104 ;
551 const int y_Margin_Title = 10;
552 const int width_Title = GetClientAreaBounds().width - 108 - 52 - 30;
553 const int x_Margin_Url = 104 ;
554 const int y_Margin_Url = 70 ;
555 const int width_Url = GetClientAreaBounds().width - 108 - 52 ;
556 const int height_Url = 48;
557 const int itemHeight = 128;
558 const int textSize = 32;
561 if( pBookMark == NULL )
567 if ( pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER )
569 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth,112), LIST_ANNEX_STYLE_DETAILED);
570 TryCatch(!IsFailed(r),,"BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
572 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_FOLDER_OPEN);
575 pItem->AddElement(Rectangle(x_Margin_Icon, 20, width_Icon, height_Icon), IDA_FORMAT_ICON, *pBitmap, null);
579 pItem->AddElement(Rectangle(x_Margin_Title, 26, width_Title, 60), IDA_FORMAT_FOLDER, pBookMark->GetBookmarkTitle(), true);
581 if ( __pItemContextFolder != NULL)
583 pItem->SetContextItem(__pItemContextFolder);
588 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth, itemHeight), style);
589 TryCatch( !IsFailed(r),,"BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
591 AppLogDebug("BookmarkListForm::faviconid %ls",pBookMark->GetFaviconId().GetPointer());
592 bitmapId = pBookMark->GetFaviconId();
594 dim = Dimension(pBookMark->GetFavIconWidth(), pBookMark->GetFavIconHeight());
596 AppLog("BookmarkListForm::CreateItem check 0");
598 // get fav icon bitmap
599 ByteBuffer* pFavIconBuffer = null;
600 pFavIconBuffer = pBookMark->GetFavIconBuffer();
602 AppLog("BookmarkListForm::CreateItem check 0");
604 if (pFavIconBuffer != null)
606 AppLog("BookmarkListForm::CreateItem pFavIconBuffer is not null");
610 AppLog("BookmarkListForm::CreateItem pFavIconBuffer is null");
613 pBitmap = pImage->DecodeN(*pFavIconBuffer, IMG_FORMAT_PNG, BITMAP_PIXEL_FORMAT_ARGB8888);
615 AppLog("BookmarkListForm::CreateItem check 1");
619 AppLog("rahul bitmap is not null");
620 int width = pBitmap->GetWidth();
621 int height = pBitmap->GetHeight();
622 AppLog("rahul bitmap width is %d", width);
623 AppLog("rahul bitmap height is %d", height);
624 AppLog("rahul favicon width is %d", pBookMark->GetFavIconWidth());
625 AppLog("rahul favicon height is %d", pBookMark->GetFavIconHeight());
629 AppLog("rahul bitmap is null");
632 //pBitmap = FaviconManager::GetInstance()->GetFaviconN(bitmapId);
633 /*if (pBitmap == null)
635 AppLogDebug("BookmarkListForm::CreateItem bitmap is null");
636 pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
638 pItem->AddElement(Rectangle(x_Margin_Icon, y_Margin_Icon, width_Icon, height_Icon), IDA_FORMAT_ICON, *pBitmap, null);
639 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);
640 if(__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
641 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);
643 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);
649 if ( __pItemContextSite != NULL)
651 pItem->SetContextItem(__pItemContextSite);
665 BookmarkListForm::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
673 BookmarkListForm::GetItemCount(void)
677 if (__pData != NULL )
679 __pData->RemoveAll(true);
683 __pData = new(std::nothrow) Collection::ArrayList();
684 __pData->Construct();
686 if (__searchBookmark == false)
688 BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID, count);
689 BookmarkPresentationModel::GetInstance()->GetFoldersBookmarks(__parentID, 0, count, *__pData);
693 BookmarkPresentationModel::GetInstance()->GetSearchFolderBookmarkCount(count,__searchText);
694 BookmarkPresentationModel::GetInstance()->GetSearchFoldersBookmarks(0, count, *__pData, __searchText);
697 AppLogDebug("Count = %d parentId = %ls", count, __parentID.GetPointer());
701 __noBookmarks = true;
702 GetFooter()->SetItemEnabled(1,false);
706 __noBookmarks = false;
707 GetFooter()->SetItemEnabled(1,true);
710 AppLogDebug("Result: %s", GetErrorMessage(GetLastResult()));
711 GetFooter()->Invalidate(true);
712 if (__pData != null && __pData->GetCount() >= 1)
714 // __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
715 __pSearchBar->SetShowState(true);
716 __pSearchBar->Invalidate(true);
718 else if (__searchBookmark == false)
720 __pSearchBar->SetShowState(false);
721 __pSearchBar->Invalidate(true);
724 if (__parentID.CompareTo(L"-1") != 0)
726 __pSearchBar->SetShowState(false);
727 __pSearchBar->Invalidate(true);
729 if (__noBookmarks == true)
731 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
732 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_NO_CONTENT_BOOKMARK);
734 if ( pBitmap != NULL)
736 __pListview->SetBitmapOfEmptyList(pBitmap);
742 if (__parentID.CompareTo(L"-1") == 0)
744 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetHeight(),GetClientAreaBounds().width ,GetClientAreaBounds().height - __pSearchBar->GetY() - __pSearchBar->GetHeight());
748 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
753 __pListview->Invalidate(true);
759 BookmarkListForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
761 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged int index %d, int elementId %d, Tizen::Ui::Controls::ListContextItemStatus status %d",index,elementId,status);
763 String deleteText = CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB");
764 deleteText.Append(L"? ");
766 result r = E_SUCCESS;
770 case IDA_CONTEXT_ITEM_FOLDER_EDIT:
772 ArrayList* pArgList = null;
773 String* pEdit = null;
775 SceneManager* pSceneManager = SceneManager::GetInstance();
776 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
777 if (pBookMark != null && pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
779 pArgList = new(std::nothrow) ArrayList();
780 if (pArgList != null)
782 pEdit= new(std::nothrow) String(CommonUtil::GetString(L"IDS_BR_HEADER_EDIT_FOLDER"));
783 pArgList->Construct();
784 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
785 pArgList->Add(*pEdit);
786 if ( pSceneManager != null)
789 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_BOOKMARK_FOLDER), pArgList);
792 if (pArgList != null)
799 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged GoForward failed %s",GetErrorMessage(r));
808 case IDA_CONTEXT_ITEM_FOLDER_DELETE:
809 case IDA_CONTEXT_ITEM_DELETE:
811 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
812 __pConfirmationPopup->Initialize();
813 __pConfirmationPopup->RemoveActionListener(*this);
814 __pConfirmationPopup->AddActionListener(*this);
815 __pConfirmationPopup->setMessage(deleteText);
816 __pConfirmationPopup->Show();
817 __selectedindex = index;
821 case IDA_CONTEXT_ITEM_EDIT:
823 ArrayList* pArgList = null;
824 SceneManager* pSceneManager = SceneManager::GetInstance();
825 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
826 if (pBookMark!= null && pBookMark->GetBookmarkType() == BOOKMARK_TYPE_URL)
828 AppLogDebug("ID_CONTEXT_ITEM_SITE_1 BOOKMARK_TYPE_URL");
829 pArgList = new(std::nothrow) ArrayList();
830 if (pArgList != null)
832 pArgList->Construct();
833 pArgList->Add(*new(std::nothrow) String(L"1"));
834 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
835 if ( pSceneManager != null)
838 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ADD_BOOKMARK), pArgList);
839 if (pArgList != null)
846 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged GoForward failed %s",GetErrorMessage(r));
854 case IDA_CONTEXT_ITEM_SHARE:
856 AppLogDebug("OnListViewContextItemStateChanged Share");
858 BookmarkData* pBookmark = dynamic_cast<BookmarkData*>(__pData->GetAt(index));
859 if (pBookmark != null)
861 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
862 pShareInfo->SetPageTitle(pBookmark->GetBookmarkTitle());
863 pShareInfo->SetPageUrl(pBookmark->GetUrl());
864 pShareInfo->SetImageAttached(false);
865 __pPopUp->RemoveAllShareInfo();
866 __pPopUp->AddShareInfo(pShareInfo);
869 if (__pPopUp != null)
871 __pPopUp->SetShowState(true);
883 BookmarkListForm::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
889 BookmarkListForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
891 AppLogDebug("BookmarkListForm::OnListViewItemStateChanged");
893 result r = E_FAILURE;
894 ArrayList *pArgList = null;
895 SceneManager* pSceneManager = SceneManager::GetInstance();
896 BookmarkData* pBookmark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
898 if ( pBookmark == NULL )
903 switch (pBookmark->GetBookmarkType())
905 case BOOKMARK_TYPE_FOLDER:
907 __parentID = pBookmark->GetBookmarkId();
908 AppLogDebug("BOOKMARK_TYPE_FOLDER parent ID is %ls",__parentID.GetPointer());
910 listView.UpdateList();
911 if (listView.GetItemCount() == 0)
913 GetFooter()->SetItemEnabled(1,false);
917 GetFooter()->SetItemEnabled(1,true);
919 GetFooter()->SetItemEnabled(2,false);
920 GetFooter()->Invalidate(true);
921 __pSearchBar->HideKeypad();
922 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
923 __pSearchBar->SetShowState(false);
924 __pSearchBar->Invalidate(true);
925 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pListview->GetWidth() ,GetClientAreaBounds().height);
928 case BOOKMARK_TYPE_URL:
930 pArgList = new(std::nothrow) ArrayList();
931 if (pArgList != null)
933 r = pArgList->Construct();
934 TryCatch(!IsFailed(r), L"BookmarkListForm::OnListViewItemStateChanged pArgList Construct failed %s", GetErrorMessage(r));
936 AppLogDebug("bookmark url = %ls",pBookmark->GetUrl().GetPointer());
937 r = pArgList->Add(*MultipleWindowPresentationModel::GetInstance()->GetActiveWindowInfo());
938 pArgList->Add(*new(std::nothrow) String(pBookmark->GetUrl()));
940 if (pSceneManager != null)
942 AppLogDebug("pSceneManager exists");
944 MultipleWindowPresentationModel::GetInstance()->GetCurrentSceneId(prevSceneId);
945 r = pSceneManager->GoBackward(BackwardSceneTransition(prevSceneId), pArgList);
946 TryCatch(!IsFailed(r), L"BookmarkListForm::OnListViewItemStateChanged pArgList Construct failed %s", GetErrorMessage(r));
960 pArgList->RemoveAll(true);
967 BookmarkListForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
974 BookmarkListForm::OnFastScrollIndexSelected(Tizen::Ui::Control& source, Tizen::Base::String& index)
980 BookmarkListForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
982 result r = E_FAILURE;
984 if (mode == SEARCH_BAR_MODE_NORMAL)
986 __pSearchListView->SetShowState(false);
987 __pSearchListView->UpdateList();
988 __pListview->SetShowState(true);
990 __searchBookmark = false;
991 r = __pListview->UpdateList();
992 __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
993 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
994 TryCatch( !IsFailed(r),,"BookmarkListForm::OnSearchBarModeChanged Update list failed %s",GetErrorMessage(r));
999 __pSearchListView->SetShowState(true);
1000 __pSearchListView->SetEnabled(false);
1001 __pListview->SetShowState(false);
1005 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1006 __pSearchBar->SetText(L"");
1008 AppLog("OnSearchBarModeChanged SetContentAreaSize heihgt %d",__pSearchListView->GetHeight());
1009 __pListview->UpdateList();
1010 __pSearchListView->UpdateList();
1015 BookmarkListForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
1017 GetFooter()->SetShowState(false);
1018 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), __pSearchListView->GetHeight() + GetFooter()->GetHeight());
1019 __pSearchListView->SetEnabled(false);
1020 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1022 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), __pSearchListView->GetHeight() - GetFooter()->GetHeight());
1026 BookmarkListForm::OnKeypadOpened(Tizen::Ui::Control& source)
1029 __pSearchListView->UpdateList();
1033 BookmarkListForm::OnKeypadClosed(Tizen::Ui::Control& source)
1036 GetFooter()->SetShowState(true);
1037 GetFooter()->Invalidate(true);
1038 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1039 __pListview->SetBounds(__pSearchListView->GetX(), __pSearchBar->GetY() + __pSearchBar->GetHeight(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1040 __pSearchListView->Invalidate(false);
1041 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1046 BookmarkListForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
1048 AppLog("BookmarkListForm::OnKeypadActionPerformed %d",keypadAction);
1050 if (__pSearchBar != null)
1052 __pSearchBar->HideKeypad();
1055 if ( __pSearchBar != null && keypadAction == KEYPAD_ACTION_SEARCH)
1057 if (__pSearchBar->GetText().GetLength() == 0)
1062 __searchText = __pSearchBar->GetText();
1063 __searchBookmark = true;
1064 __pListview->SetShowState(false);
1065 __pSearchListView->SetEnabled(true);
1066 __pSearchListView->SetShowState(true);
1067 __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1068 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1069 __pSearchListView->UpdateList();
1076 BookmarkListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
1078 AppLogDebug("BookmarkListForm::OnSceneActivatedN called");
1080 __searchBookmark = false;
1081 GetFooter()->SetShowState(true);
1082 GetFooter()->Invalidate(true);
1083 GetHeader()->SetItemSelected(0);
1084 GetHeader()->Invalidate(true);
1086 /* if (previousSceneId != IDSCN_HISTORY_LIST && previousSceneId != IDSCN_CREATE_BOOKMARK_FOLDER && previousSceneId != IDSCN_EDIT_BOOKMARK_LIST)
1088 __previousSceneId = previousSceneId;
1091 if (__pListview != null)
1093 __pListview->UpdateList();
1100 BookmarkListForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
1102 AppLog("BookmarkListForm::OnOrientationChanged start");
1106 if(__pSearchBar->GetShowState())
1108 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetHeight(),GetClientAreaBounds().width ,GetClientAreaBounds().height - __pSearchBar->GetY() - __pSearchBar->GetHeight());
1112 __pListview->SetBounds(__pListview->GetX(),0,GetClientAreaBounds().width ,GetClientAreaBounds().height);
1114 __pListview->UpdateList();
1117 if (__pSearchListView && __pListview)
1119 AppLog("__pListview->GetBounds() %d, %d, %d, %d",__pListview->GetBounds().x,__pListview->GetBounds().y,__pListview->GetBounds().width,__pListview->GetBounds().height);
1120 __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1122 __pSearchListView->UpdateList();
1125 if (__pSearchListView && __pData != null )
1127 if (__parentID != DEFAULT_VALUE_PARENTID)
1129 AppLog("BookmarkListForm::OnOrientationChanged parent id true");
1130 __pSearchBar->SetShowState(false);
1131 __pSearchBar->Invalidate(true);
1134 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().width));
1142 BookmarkListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
1144 if (__pData != null)
1146 __pData->RemoveAll(true);
1150 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);