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;
44 const wchar_t* DEFAULT_VALUE_PARENTID = L"-1";
45 static const wchar_t* IDB_TAB_ICON_BOOKMARK = L"I01_tab_icon_bookmarks.png";
46 static const wchar_t* IDB_TAB_ICON_HISTORY = L"I01_tab_icon_history.png";
47 static const wchar_t* IDB_NO_CONTENT_BOOKMARK = L"I01_Nocontents_Bookmarks.png";
48 static const wchar_t* IDB_ICON_FOLDER_OPEN = L"I01_icon_folder_open.png";
50 const int BookmarkListForm::IDA_TABBAR_ITEM_1 = 101;
51 const int BookmarkListForm::IDA_TABBAR_ITEM_2 = 102;
52 const int BookmarkListForm::IDA_FOOTER_ITEM1 = 103;
53 const int BookmarkListForm::IDA_FOOTER_ITEM2 = 104;
54 const int BookmarkListForm::IDA_FOOTER_ITEM_ADDBOOKMARK = 105;
55 const int BookmarkListForm::IDA_FORMAT_FOLDER = 106;
56 const int BookmarkListForm::IDA_FORMAT_SITE = 107;
57 const int BookmarkListForm::IDA_CONTEXT_ITEM_FOLDER_EDIT = 108;
58 const int BookmarkListForm::IDA_CONTEXT_ITEM_FOLDER_DELETE = 109;
59 const int BookmarkListForm::IDA_CONTEXT_ITEM_EDIT = 110;
60 const int BookmarkListForm::IDA_CONTEXT_ITEM_SHARE = 111;
61 const int BookmarkListForm::IDA_CONTEXT_ITEM_DELETE = 112;
62 const int BookmarkListForm::IDA_FORMAT_ICON = 113;
63 const int BookmarkListForm::IDA_FORMAT_URL = 114;
65 //const int BookmarkListForm::IDA_CONFIRMATION_NO = 1000;
66 //const int BookmarkListForm::IDA_CONFIRMATION_YES = 1001;
68 BookmarkListForm::BookmarkListForm(void)
70 __pItemContextFolder = null ;
71 __pItemContextSite = null ;
74 __pSearchListView = null;
76 __searchBookmark = false;
77 __parentID = DEFAULT_VALUE_PARENTID;
83 BookmarkListForm::~BookmarkListForm(void)
88 __pData->RemoveAll(true);
93 if (__pItemContextFolder != null)
95 delete __pItemContextFolder;
96 __pItemContextFolder = null;
99 if (__pItemContextSite != null)
101 delete __pItemContextSite;
102 __pItemContextSite = null;
107 BookmarkListForm::OnTerminating(void)
109 result r = E_SUCCESS;
113 __pData->RemoveAll(true);
123 BookmarkListForm::Initialize(void)
125 Construct(L"IDL_BOOKMARK_LIST");
130 BookmarkListForm::OnInitializing(void)
132 result r = E_SUCCESS;
135 Bitmap *pBitmapNormal = null;
136 Bitmap *pBitmapPressed = null;
137 Header *pHeader = GetHeader();
138 Bitmap *pIconBitmap = null;
139 AppResource* pAppResource = UiApp::GetInstance()->GetAppResource();
140 int bookmarkCount = 0;
141 const int WIDTH_CONTEXT_MENU_TWO_BUTTON = 336;
142 const int WIDTH_CONTEXT_MENU_THREE_BUTTON = 160;
143 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
146 // Setup back event listener
147 SetFormBackEventListener(this);
148 AddOrientationEventListener(*this);
150 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_BOOKMARK_VIEW, *this);
151 GetHeader()->AddActionEventListener(*this);
152 GetFooter()->AddActionEventListener(*this);
154 if ( pAppResource == NULL )
159 __pItemContextFolder = new(std::nothrow) ListContextItem();
160 __pItemContextFolder->Construct();
161 __pItemContextFolder->AddElement(IDA_CONTEXT_ITEM_FOLDER_EDIT, CommonUtil::GetString(L"IDS_BR_SK_EDIT"));
162 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_TWO_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
163 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_TWO_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
165 if (pBitmapNormal != null && pBitmapPressed != null)
167 __pItemContextFolder->AddElement(IDA_CONTEXT_ITEM_FOLDER_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
170 if (pBitmapNormal != null)
172 delete pBitmapNormal;
175 if (pBitmapPressed != null)
177 delete pBitmapPressed;
180 __pItemContextSite = new(std::nothrow) ListContextItem();
181 __pItemContextSite->Construct();
182 __pItemContextSite->AddElement(IDA_CONTEXT_ITEM_EDIT, CommonUtil::GetString(L"IDS_BR_SK_EDIT"));
183 __pItemContextSite->AddElement(IDA_CONTEXT_ITEM_SHARE, CommonUtil::GetString(L"IDS_BR_OPT_SHARE"));
184 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_THREE_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
185 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_THREE_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
187 if (pBitmapNormal != null && pBitmapPressed != null)
189 __pItemContextSite->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
192 if (pBitmapNormal != null)
194 delete pBitmapNormal;
197 if (pBitmapPressed != null)
199 delete pBitmapPressed;
201 __pListview = static_cast< ListView* >(GetControl("IDC_LISTVIEW1"));
203 if (__pListview == null)
207 __pSearchBar = static_cast< SearchBar* >(GetControl(L"IDC_SEARCHBAR1"));
209 if (__pSearchBar == null)
214 if (__pListview != null)
216 // __pListview->SetBounds(__pListview->GetX(), __pListview->GetY(), GetClientAreaBounds().width, GetClientAreaBounds().height);
217 __pListview->AddFastScrollListener(*this);
218 __pListview->AddListViewItemEventListener(*this);
219 __pListview->SetItemProvider(*this);
220 __pListview->UpdateList();
223 __pPopUp = new(std::nothrow) SharePopup();
225 if (__pPopUp != null)
227 __pPopUp->Initialize();
228 AddControl(*__pPopUp);
231 __pSearchListView = new(std::nothrow) ListView();
233 if (__pSearchListView == null)
238 r = __pSearchListView->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height -72 - 30), true, false);
239 TryCatch( !IsFailed(r),,"BookmarkListForm::OnSearchBarModeChanged Update list failed %s",GetErrorMessage(r));
241 __pSearchListView->SetItemProvider(*this);
242 __pSearchListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RESULTS_FOUND"));
243 __pSearchListView->SetTextColorOfEmptyList(Color::GetColor(COLOR_ID_BLACK));
244 __pSearchListView->SetShowState(false);
245 __pSearchListView->AddListViewItemEventListener(*this);
247 __pSearchBar->AddSearchBarEventListener(*this);
248 __pSearchBar->AddKeypadEventListener(*this);
249 __pSearchBar->SetContent(__pSearchListView);
251 BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID, bookmarkCount);
252 if(bookmarkCount <= 0)
254 __pSearchBar->SetShowState(false);
255 //__pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pSearchBar->GetWidth(),GetClientAreaBounds().height - __pSearchBar->GetPosition().y);
256 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pListview->GetWidth(),GetClientAreaBounds().height);
260 __pSearchBar->SetShowState(true);
266 pHeader->SetStyle(HEADER_STYLE_TAB);
267 bookmark.Construct(IDA_TABBAR_ITEM_1);
269 pAppResource->GetString(L"IDS_BR_TAB_BOOKMARKS", strbookmark);
270 bookmark.SetText(strbookmark);
271 pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_BOOKMARK);
272 bookmark.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);
273 bookmark.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
274 pHeader->AddItem(bookmark);
276 if (pIconBitmap != NULL)
281 history.Construct(IDA_TABBAR_ITEM_2);
283 pAppResource->GetString(L"IDS_BR_TAB_HISTORY", strhistory);
284 history.SetText(strhistory);
285 pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_HISTORY);
286 history.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);
287 history.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
288 pHeader->AddItem(history);
289 pHeader->SetItemSelected(0);
291 if (pIconBitmap != NULL)
302 BookmarkListForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
304 AppLogDebug("BookmarkListForm::OnActionPerformed actionId = %d",actionId);
307 BookmarkData* pBookMark = null;
311 case IDA_FOOTER_ITEM1:
313 GetHeader()->SetItemSelected(0);
314 GetHeader()->Invalidate(true);
315 SceneManager* pSceneManager = SceneManager::GetInstance();
316 pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(__selectedindex));
318 if ( pBookMark == NULL )
323 ArrayList* pArgList = null;
324 pArgList = new(std::nothrow) ArrayList();
325 if (pArgList != null)
327 pArgList->Construct();
328 pArgList->Add(*new(std::nothrow) String(pBookMark->GetParentId()));
330 //pArgList->Add(*new(std::nothrow) String(pBookmark->);
331 if (pSceneManager != null)
333 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_EDIT_BOOKMARK_LIST),pArgList) != E_SUCCESS)
335 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
336 pArgList->RemoveAll(true);
343 if ( pArgList != NULL)
345 pArgList->RemoveAll(true);
351 case IDA_TABBAR_ITEM_2:
353 GetHeader()->SetItemSelected(0);
354 GetHeader()->Invalidate(true);
356 SceneManager* pSceneManager = SceneManager::GetInstance();
358 if (pSceneManager != null)
360 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT)) != E_SUCCESS)
362 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
368 case IDA_FOOTER_ITEM2:
370 SceneManager* pSceneManager = SceneManager::GetInstance();
374 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_BOOKMARK_FOLDER)) != E_SUCCESS)
376 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
382 case IDA_FOOTER_ITEM_ADDBOOKMARK:
384 SceneManager* pSceneManager = SceneManager::GetInstance();
386 // send array list 0-for add, 1 for edit with parent ID
387 ArrayList* pArgList = null;
388 pArgList = new(std::nothrow) ArrayList();
389 if (pArgList != null)
391 pArgList->Construct();
392 pArgList->Add(*new(std::nothrow) String(L"0"));
393 pArgList->Add(*new(std::nothrow) String(__parentID));
398 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ADD_BOOKMARK),pArgList) != E_SUCCESS)
400 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
401 pArgList->RemoveAll(true);
407 if (pArgList != null)
409 pArgList->RemoveAll(true);
416 __pConfirmationPopup->SetShowState(false);
417 __pConfirmationPopup->Show();
420 pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(__selectedindex));
421 if ( pBookMark== null)
423 bookmarkId=pBookMark->GetBookmarkId();
424 Integer::Parse(bookmarkId,id);
425 if (pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
426 BookmarkPresentationModel::GetInstance()->DeleteFolder(id);
428 BookmarkPresentationModel::GetInstance()->DeleteBookmark(id);
429 if (__pListview == null)
433 AppLogDebug("__pListview GetBounds %d,%d,%d,%d",__pListview->GetBounds().x,__pListview->GetBounds().y,__pListview->GetBounds().width,__pListview->GetBounds().height);
434 __pSearchListView->UpdateList();
435 __pListview->UpdateList();
437 if (__pListview->GetItemCount() == 0)
439 GetFooter()->SetItemEnabled(1,false);
440 __pSearchBar->SetShowState(false);
441 __pSearchBar->Invalidate(true);
444 if (__noBookmarks == true)
446 Bitmap* emptyListBmp = AppResource::GetInstance()->GetBitmapN(IDB_NO_CONTENT_BOOKMARK);
447 GetFooter()->SetItemEnabled(1,false);
448 __pSearchBar->SetShowState(false);
449 __pSearchBar->Invalidate(true);
450 // __pListview->SetBounds(__pSearchBar->GetPosition().x,__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
451 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
452 __pListview->SetBitmapOfEmptyList(emptyListBmp);
458 __pListview->UpdateList();
463 GetFooter()->SetItemEnabled(1,true);
465 if (__parentID.CompareTo(L"-1") == 0)
467 __pSearchBar->SetShowState(true);
468 __pSearchBar->Invalidate(true);
472 GetFooter()->Invalidate(true);
473 __pConfirmationPopup->SetShowState(false);
474 __pConfirmationPopup->Show();
484 BookmarkListForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
486 AppLogDebug("BrowserApplicationForm::OnFormBackRequested");
488 UiApp* pApp = UiApp::GetInstance();
494 if (__parentID != DEFAULT_VALUE_PARENTID)
496 __parentID = DEFAULT_VALUE_PARENTID;
497 __pSearchBar->SetShowState(true);
498 __pListview->SetBounds(__pListview->GetX() ,__pSearchBar->GetPosition().y + __pSearchBar->GetHeight(),__pListview->GetWidth(),GetClientAreaBounds().height - (__pSearchBar->GetY() + __pSearchBar->GetHeight()));
499 __pListview->UpdateList();
500 __pFooter = GetFooter();
501 GetFooter()->SetItemEnabled(2,true);
502 GetFooter()->Invalidate(true);
506 SceneManager* pSceneManager = SceneManager::GetInstance();
507 if (pSceneManager != null)
509 pSceneManager->GoBackward(BackwardSceneTransition());
513 if (__noBookmarks == true)
515 GetFooter()->SetItemEnabled(1,false);
519 GetFooter()->SetItemEnabled(1,true);
523 Tizen::Ui::Controls::ListItemBase*
524 BookmarkListForm::CreateItem(int index, int itemWidth)
526 AppLog("BookmarkListForm::CreateItem index %d , itemWidth %d",index, itemWidth);
527 AppLog("listviewwidth %d",__pListview->GetWidth());
528 result r = E_FAILURE;
529 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
530 CustomItem* pItem = new(std::nothrow) CustomItem();
531 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
532 Bitmap* pBitmap = null;
534 const int x_Margin_Icon = 16; // local as there used only in this function
535 const int y_Margin_Icon = 28;
536 const int height_Icon = 72;
537 const int width_Icon = 72 ;
538 const int x_Margin_Title = 104 ;
539 const int y_Margin_Title = 10;
540 const int width_Title = GetClientAreaBounds().width - 108 - 52 - 30;
541 const int x_Margin_Url = 104 ;
542 const int y_Margin_Url = 70 ;
543 const int width_Url = GetClientAreaBounds().width - 108 - 52 ;
544 const int height_Url = 48;
545 const int itemHeight = 128;
546 const int textSize = 32;
549 if( pBookMark == NULL )
555 if ( pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER )
557 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth,112), LIST_ANNEX_STYLE_DETAILED);
558 TryCatch(!IsFailed(r),,"BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
560 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_FOLDER_OPEN);
563 pItem->AddElement(Rectangle(x_Margin_Icon, 20, width_Icon, height_Icon), IDA_FORMAT_ICON, *pBitmap, null);
567 pItem->AddElement(Rectangle(x_Margin_Title, 26, width_Title, 60), IDA_FORMAT_FOLDER, pBookMark->GetBookmarkTitle(), true);
569 if ( __pItemContextFolder != NULL)
571 pItem->SetContextItem(__pItemContextFolder);
576 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth, itemHeight), style);
577 TryCatch( !IsFailed(r),,"BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
579 AppLogDebug("BookmarkListForm::faviconid %ls",pBookMark->GetFaviconId().GetPointer());
580 bitmapId = pBookMark->GetFaviconId();
582 pBitmap = FaviconManager::GetInstance()->GetFaviconN(bitmapId);
585 AppLogDebug("BookmarkListForm::CreateItem bitmap is null");
586 pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
588 pItem->AddElement(Rectangle(x_Margin_Icon, y_Margin_Icon, width_Icon, height_Icon), IDA_FORMAT_ICON, *pBitmap, null);
589 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);
590 if(__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
591 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);
593 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);
599 if ( __pItemContextSite != NULL)
601 pItem->SetContextItem(__pItemContextSite);
615 BookmarkListForm::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
623 BookmarkListForm::GetItemCount(void)
627 if (__pData != NULL )
629 __pData->RemoveAll(true);
633 __pData = new(std::nothrow) Collection::ArrayList();
634 __pData->Construct();
636 if (__searchBookmark == false)
638 BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID, count);
639 BookmarkPresentationModel::GetInstance()->GetFoldersBookmarks(__parentID, 0, count, *__pData);
643 BookmarkPresentationModel::GetInstance()->GetSearchFolderBookmarkCount(count,__searchText);
644 BookmarkPresentationModel::GetInstance()->GetSearchFoldersBookmarks(0, count, *__pData, __searchText);
647 AppLogDebug("Count = %d parentId = %ls", count, __parentID.GetPointer());
651 __noBookmarks = true;
652 GetFooter()->SetItemEnabled(1,false);
656 __noBookmarks = false;
657 GetFooter()->SetItemEnabled(1,true);
660 AppLogDebug("Result: %s", GetErrorMessage(GetLastResult()));
661 GetFooter()->Invalidate(true);
662 if (__pData != null && __pData->GetCount() >= 1)
664 // __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
665 __pSearchBar->SetShowState(true);
666 __pSearchBar->Invalidate(true);
668 else if (__searchBookmark == false)
670 __pSearchBar->SetShowState(false);
671 __pSearchBar->Invalidate(true);
674 if (__parentID.CompareTo(L"-1") != 0)
676 __pSearchBar->SetShowState(false);
677 __pSearchBar->Invalidate(true);
679 if (__noBookmarks == true)
681 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
682 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_NO_CONTENT_BOOKMARK);
684 if ( pBitmap != NULL)
686 __pListview->SetBitmapOfEmptyList(pBitmap);
692 if (__parentID.CompareTo(L"-1") == 0)
694 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetHeight(),GetClientAreaBounds().width ,GetClientAreaBounds().height - __pSearchBar->GetY() - __pSearchBar->GetHeight());
698 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
703 __pListview->Invalidate(true);
709 BookmarkListForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
711 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged int index %d, int elementId %d, Tizen::Ui::Controls::ListContextItemStatus status %d",index,elementId,status);
713 String deleteText = CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB");
714 deleteText.Append(L"? ");
716 result r = E_SUCCESS;
720 case IDA_CONTEXT_ITEM_FOLDER_EDIT:
722 ArrayList* pArgList = null;
723 String* pEdit = null;
725 SceneManager* pSceneManager = SceneManager::GetInstance();
726 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
727 if (pBookMark != null && pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
729 pArgList = new(std::nothrow) ArrayList();
730 if (pArgList != null)
732 pEdit= new(std::nothrow) String(CommonUtil::GetString(L"IDS_BR_HEADER_EDIT_FOLDER"));
733 pArgList->Construct();
734 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
735 pArgList->Add(*pEdit);
736 if ( pSceneManager != null)
739 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_BOOKMARK_FOLDER), pArgList);
742 if (pArgList != null)
749 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged GoForward failed %s",GetErrorMessage(r));
758 case IDA_CONTEXT_ITEM_FOLDER_DELETE:
759 case IDA_CONTEXT_ITEM_DELETE:
761 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
762 __pConfirmationPopup->Initialize();
763 __pConfirmationPopup->RemoveActionListener(*this);
764 __pConfirmationPopup->AddActionListener(*this);
765 __pConfirmationPopup->setMessage(deleteText);
766 __pConfirmationPopup->Show();
767 __selectedindex = index;
771 case IDA_CONTEXT_ITEM_EDIT:
773 ArrayList* pArgList = null;
774 SceneManager* pSceneManager = SceneManager::GetInstance();
775 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
776 if (pBookMark!= null && pBookMark->GetBookmarkType() == BOOKMARK_TYPE_URL)
778 AppLogDebug("ID_CONTEXT_ITEM_SITE_1 BOOKMARK_TYPE_URL");
779 pArgList = new(std::nothrow) ArrayList();
780 if (pArgList != null)
782 pArgList->Construct();
783 pArgList->Add(*new(std::nothrow) String(L"1"));
784 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
785 if ( pSceneManager != null)
788 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ADD_BOOKMARK), pArgList);
789 if (pArgList != null)
796 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged GoForward failed %s",GetErrorMessage(r));
804 case IDA_CONTEXT_ITEM_SHARE:
806 AppLogDebug("OnListViewContextItemStateChanged Share");
808 BookmarkData* pBookmark = dynamic_cast<BookmarkData*>(__pData->GetAt(index));
809 if (pBookmark != null)
811 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
812 pShareInfo->SetPageTitle(pBookmark->GetBookmarkTitle());
813 pShareInfo->SetPageUrl(pBookmark->GetUrl());
814 pShareInfo->SetImageAttached(false);
815 __pPopUp->RemoveAllShareInfo();
816 __pPopUp->AddShareInfo(pShareInfo);
819 if (__pPopUp != null)
821 __pPopUp->SetShowState(true);
833 BookmarkListForm::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
839 BookmarkListForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
841 AppLogDebug("BookmarkListForm::OnListViewItemStateChanged");
843 result r = E_FAILURE;
844 ArrayList *pArgList = null;
845 SceneManager* pSceneManager = SceneManager::GetInstance();
846 BookmarkData* pBookmark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
848 if ( pBookmark == NULL )
853 switch (pBookmark->GetBookmarkType())
855 case BOOKMARK_TYPE_FOLDER:
857 __parentID = pBookmark->GetBookmarkId();
858 AppLogDebug("BOOKMARK_TYPE_FOLDER parent ID is %ls",__parentID.GetPointer());
860 listView.UpdateList();
861 if (listView.GetItemCount() == 0)
863 GetFooter()->SetItemEnabled(1,false);
867 GetFooter()->SetItemEnabled(1,true);
869 GetFooter()->SetItemEnabled(2,false);
870 GetFooter()->Invalidate(true);
871 __pSearchBar->HideKeypad();
872 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
873 __pSearchBar->SetShowState(false);
874 __pSearchBar->Invalidate(true);
875 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pListview->GetWidth() ,GetClientAreaBounds().height);
878 case BOOKMARK_TYPE_URL:
880 pArgList = new(std::nothrow) ArrayList();
881 if (pArgList != null)
883 r = pArgList->Construct();
884 TryCatch(!IsFailed(r), L"BookmarkListForm::OnListViewItemStateChanged pArgList Construct failed %s", GetErrorMessage(r));
886 AppLogDebug("bookmark url = %ls",pBookmark->GetUrl().GetPointer());
887 r = pArgList->Add(*MultipleWindowPresentationModel::GetInstance()->GetActiveWindowInfo());
888 pArgList->Add(*new(std::nothrow) String(pBookmark->GetUrl()));
890 if (pSceneManager != null)
892 AppLogDebug("pSceneManager exists");
894 MultipleWindowPresentationModel::GetInstance()->GetCurrentSceneId(prevSceneId);
895 r = pSceneManager->GoBackward(BackwardSceneTransition(prevSceneId), pArgList);
896 TryCatch(!IsFailed(r), L"BookmarkListForm::OnListViewItemStateChanged pArgList Construct failed %s", GetErrorMessage(r));
910 pArgList->RemoveAll(true);
917 BookmarkListForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
924 BookmarkListForm::OnFastScrollIndexSelected(Tizen::Ui::Control& source, Tizen::Base::String& index)
930 BookmarkListForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
932 result r = E_FAILURE;
934 if (mode == SEARCH_BAR_MODE_NORMAL)
936 __pSearchListView->SetShowState(false);
937 __pSearchListView->UpdateList();
938 __pListview->SetShowState(true);
940 __searchBookmark = false;
941 r = __pListview->UpdateList();
942 __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
943 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
944 TryCatch( !IsFailed(r),,"BookmarkListForm::OnSearchBarModeChanged Update list failed %s",GetErrorMessage(r));
949 __pSearchListView->SetShowState(true);
950 __pSearchListView->SetEnabled(false);
951 __pListview->SetShowState(false);
955 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
956 __pSearchBar->SetText(L"");
958 AppLog("OnSearchBarModeChanged SetContentAreaSize heihgt %d",__pSearchListView->GetHeight());
959 __pListview->UpdateList();
960 __pSearchListView->UpdateList();
965 BookmarkListForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
967 GetFooter()->SetShowState(false);
968 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), __pSearchListView->GetHeight() + GetFooter()->GetHeight());
969 __pSearchListView->SetEnabled(false);
970 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
972 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), __pSearchListView->GetHeight() - GetFooter()->GetHeight());
976 BookmarkListForm::OnKeypadOpened(Tizen::Ui::Control& source)
979 __pSearchListView->UpdateList();
983 BookmarkListForm::OnKeypadClosed(Tizen::Ui::Control& source)
986 GetFooter()->SetShowState(true);
987 GetFooter()->Invalidate(true);
988 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
989 __pSearchListView->Invalidate(false);
990 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
994 BookmarkListForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
996 AppLog("BookmarkListForm::OnKeypadActionPerformed %d",keypadAction);
998 if (__pSearchBar != null)
1000 __pSearchBar->HideKeypad();
1003 if ( __pSearchBar != null && keypadAction == KEYPAD_ACTION_SEARCH)
1005 if (__pSearchBar->GetText().GetLength() == 0)
1010 __searchText = __pSearchBar->GetText();
1011 __searchBookmark = true;
1012 __pListview->SetShowState(false);
1013 __pSearchListView->SetEnabled(true);
1014 __pSearchListView->SetShowState(true);
1015 __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1016 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1017 __pSearchListView->UpdateList();
1024 BookmarkListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
1026 AppLogDebug("BookmarkListForm::OnSceneActivatedN called");
1028 __searchBookmark = false;
1029 GetFooter()->SetShowState(true);
1030 GetFooter()->Invalidate(true);
1031 GetHeader()->SetItemSelected(0);
1032 GetHeader()->Invalidate(true);
1034 /* if (previousSceneId != IDSCN_HISTORY_LIST && previousSceneId != IDSCN_CREATE_BOOKMARK_FOLDER && previousSceneId != IDSCN_EDIT_BOOKMARK_LIST)
1036 __previousSceneId = previousSceneId;
1039 if (__pListview != null)
1041 __pListview->UpdateList();
1048 BookmarkListForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
1050 AppLog("BookmarkListForm::OnOrientationChanged start");
1054 if(__pSearchBar->GetShowState())
1056 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetHeight(),GetClientAreaBounds().width ,GetClientAreaBounds().height - __pSearchBar->GetY() - __pSearchBar->GetHeight());
1060 __pListview->SetBounds(__pListview->GetX(),0,GetClientAreaBounds().width ,GetClientAreaBounds().height);
1062 __pListview->UpdateList();
1065 if (__pSearchListView && __pListview)
1067 AppLog("__pListview->GetBounds() %d, %d, %d, %d",__pListview->GetBounds().x,__pListview->GetBounds().y,__pListview->GetBounds().width,__pListview->GetBounds().height);
1068 __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1070 __pSearchListView->UpdateList();
1073 if (__pSearchListView && __pData != null )
1075 if (__parentID != DEFAULT_VALUE_PARENTID)
1077 AppLog("BookmarkListForm::OnOrientationChanged parent id true");
1078 __pSearchBar->SetShowState(false);
1079 __pSearchBar->Invalidate(true);
1082 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1090 BookmarkListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
1092 if (__pData != null)
1094 __pData->RemoveAll(true);
1098 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);