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"";
86 BookmarkListForm::~BookmarkListForm(void)
91 __pData->RemoveAll(true);
96 if (__pItemContextFolder != null)
98 delete __pItemContextFolder;
99 __pItemContextFolder = null;
102 if (__pItemContextSite != null)
104 delete __pItemContextSite;
105 __pItemContextSite = null;
110 BookmarkListForm::OnTerminating(void)
112 result r = E_SUCCESS;
116 __pData->RemoveAll(true);
126 BookmarkListForm::Initialize(void)
128 Construct(L"IDL_BOOKMARK_LIST");
133 BookmarkListForm::OnInitializing(void)
135 result r = E_SUCCESS;
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 __fontSize = CommonUtil::GetFontSize();
161 __pItemContextFolder = new(std::nothrow) ListContextItem();
162 __pItemContextFolder->Construct();
163 __pItemContextFolder->AddElement(IDA_CONTEXT_ITEM_FOLDER_EDIT, CommonUtil::GetString(L"IDS_BR_SK_EDIT"));
165 __pItemContextFolder->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
166 __pItemContextFolder->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
167 __pItemContextFolder->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
168 __pItemContextFolder->AddElement(IDA_CONTEXT_ITEM_FOLDER_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), true);
170 __pItemContextSite = new(std::nothrow) ListContextItem();
171 __pItemContextSite->Construct();
172 __pItemContextSite->AddElement(IDA_CONTEXT_ITEM_EDIT, CommonUtil::GetString(L"IDS_BR_SK_EDIT"));
173 __pItemContextSite->AddElement(IDA_CONTEXT_ITEM_SHARE, CommonUtil::GetString(L"IDS_BR_OPT_SHARE"));
175 __pItemContextSite->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), true);
176 __pItemContextSite->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
177 __pItemContextSite->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
178 __pItemContextSite->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
180 __pListview = static_cast< ListView* >(GetControl("IDC_LISTVIEW1"));
182 if (__pListview == null)
186 __pSearchBar = static_cast< SearchBar* >(GetControl(L"IDC_SEARCHBAR1"));
188 if (__pSearchBar == null)
193 if (__pListview != null)
195 // __pListview->SetBounds(__pListview->GetX(), __pListview->GetY(), GetClientAreaBounds().width, GetClientAreaBounds().height);
196 __pListview->AddFastScrollListener(*this);
197 __pListview->AddListViewItemEventListener(*this);
198 __pListview->SetItemProvider(*this);
199 __pListview->UpdateList();
202 __pPopUp = new(std::nothrow) SharePopup();
204 if (__pPopUp != null)
206 __pPopUp->Initialize();
207 AddControl(__pPopUp);
210 __pSearchListView = new(std::nothrow) ListView();
212 if (__pSearchListView == null)
217 r = __pSearchListView->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height -72), true, false);
218 TryCatch( !IsFailed(r),,"BookmarkListForm::OnSearchBarModeChanged Update list failed %s",GetErrorMessage(r));
220 __pSearchListView->SetBackgroundColor(GetBackgroundColor());
221 __pSearchListView->SetItemProvider(*this);
222 __pSearchListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RESULTS_FOUND"));
223 __pSearchListView->SetTextColorOfEmptyList(Color::GetColor(COLOR_ID_BLACK));
224 __pSearchListView->SetShowState(false);
225 __pSearchListView->AddListViewItemEventListener(*this);
227 __pSearchBar->AddSearchBarEventListener(*this);
228 __pSearchBar->AddKeypadEventListener(*this);
229 __pSearchBar->SetContent(__pSearchListView);
231 BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID, bookmarkCount);
232 if(bookmarkCount <= 0)
234 __pSearchBar->SetShowState(false);
235 //__pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pSearchBar->GetWidth(),GetClientAreaBounds().height - __pSearchBar->GetPosition().y);
236 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pListview->GetWidth(),GetClientAreaBounds().height);
240 __pSearchBar->SetShowState(true);
246 pHeader->SetStyle(HEADER_STYLE_TAB);
247 bookmark.Construct(IDA_TABBAR_ITEM_1);
249 pAppResource->GetString(L"IDS_BR_TAB_BOOKMARKS", strbookmark);
250 bookmark.SetText(strbookmark);
251 pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_BOOKMARK);
252 bookmark.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);
253 bookmark.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
254 pHeader->AddItem(bookmark);
256 if (pIconBitmap != NULL)
261 history.Construct(IDA_TABBAR_ITEM_2);
263 pAppResource->GetString(L"IDS_BR_TAB_HISTORY", strhistory);
264 history.SetText(strhistory);
265 pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_HISTORY);
266 history.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);
267 history.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
268 pHeader->AddItem(history);
269 pHeader->SetItemSelected(0);
270 pHeader->SetTabEditModeEnabled(false);
272 if (pIconBitmap != NULL)
283 BookmarkListForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
285 AppLogDebug("BookmarkListForm::OnActionPerformed actionId = %d",actionId);
288 BookmarkData* pBookMark = null;
292 case IDA_FOOTER_ITEM1:
294 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
295 GetHeader()->SetItemSelected(0);
296 GetHeader()->Invalidate(true);
297 SceneManager* pSceneManager = SceneManager::GetInstance();
298 pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(__selectedindex));
300 if ( pBookMark == NULL )
305 ArrayList* pArgList = null;
306 pArgList = new(std::nothrow) ArrayList();
307 if (pArgList != null)
309 pArgList->Construct();
310 pArgList->Add(*new(std::nothrow) String(pBookMark->GetParentId()));
312 //pArgList->Add(*new(std::nothrow) String(pBookmark->);
313 if (pSceneManager != null)
315 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_EDIT_BOOKMARK_LIST),pArgList) != E_SUCCESS)
317 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
318 pArgList->RemoveAll(true);
325 if ( pArgList != NULL)
327 pArgList->RemoveAll(true);
333 case IDA_TABBAR_ITEM_2:
335 // GetHeader()->SetItemSelected(0);
336 // GetHeader()->Invalidate(true);
338 SceneManager* pSceneManager = SceneManager::GetInstance();
340 if (pSceneManager != null)
342 if(__previousSceneId.CompareTo(IDSCN_HISTORY_LIST) != 0)
344 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT)) != E_SUCCESS)
346 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
353 if(pSceneManager->GoBackward(BackwardSceneTransition())!= E_SUCCESS)
355 AppLogDebug("BookmarkListForm::OnActionPerformed GoBackward failed");
363 case IDA_FOOTER_ITEM2:
365 SceneManager* pSceneManager = SceneManager::GetInstance();
369 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_BOOKMARK_FOLDER)) != E_SUCCESS)
371 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
377 case IDA_FOOTER_ITEM_ADDBOOKMARK:
379 SceneManager* pSceneManager = SceneManager::GetInstance();
381 // send array list 0-for add, 1 for edit with parent ID
382 ArrayList* pArgList = null;
383 pArgList = new(std::nothrow) ArrayList();
384 if (pArgList != null)
386 pArgList->Construct();
387 pArgList->Add(*new(std::nothrow) String(L"0"));
388 pArgList->Add(*new(std::nothrow) String(__parentID));
393 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ADD_BOOKMARK),pArgList) != E_SUCCESS)
395 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
396 pArgList->RemoveAll(true);
402 if (pArgList != null)
404 pArgList->RemoveAll(true);
411 __pConfirmationPopup->SetShowState(false);
412 __pConfirmationPopup->Show();
415 pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(__selectedindex));
416 if ( pBookMark== null)
418 bookmarkId=pBookMark->GetBookmarkId();
419 Integer::Parse(bookmarkId,id);
420 if (pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
421 BookmarkPresentationModel::GetInstance()->DeleteFolder(id);
423 BookmarkPresentationModel::GetInstance()->DeleteBookmark(id);
424 if (__pListview == null)
428 AppLogDebug("__pListview GetBounds %d,%d,%d,%d",__pListview->GetBounds().x,__pListview->GetBounds().y,__pListview->GetBounds().width,__pListview->GetBounds().height);
429 __pSearchListView->UpdateList();
430 __pListview->UpdateList();
432 if (__pListview->GetItemCount() == 0)
434 GetFooter()->SetItemEnabled(1,false);
435 __pSearchBar->SetShowState(false);
436 __pSearchBar->Invalidate(true);
439 if (__noBookmarks == true)
441 Bitmap* emptyListBmp = AppResource::GetInstance()->GetBitmapN(IDB_NO_CONTENT_BOOKMARK);
442 GetFooter()->SetItemEnabled(1,false);
443 __pSearchBar->SetShowState(false);
444 __pSearchBar->Invalidate(true);
445 // __pListview->SetBounds(__pSearchBar->GetPosition().x,__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
446 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
447 __pListview->SetBitmapOfEmptyList(emptyListBmp);
453 __pListview->UpdateList();
458 GetFooter()->SetItemEnabled(1,true);
460 if (__parentID.CompareTo(L"0") == 0)
462 __pSearchBar->SetShowState(true);
463 __pSearchBar->Invalidate(true);
467 GetFooter()->Invalidate(true);
468 __pConfirmationPopup->SetShowState(false);
469 __pConfirmationPopup->Show();
479 BookmarkListForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
481 AppLogDebug("BrowserApplicationForm::OnFormBackRequested");
483 UiApp* pApp = UiApp::GetInstance();
489 if (__parentID != DEFAULT_VALUE_PARENTID)
491 __parentID = DEFAULT_VALUE_PARENTID;
492 __pSearchBar->SetShowState(true);
493 __pListview->SetBounds(__pListview->GetX() ,__pSearchBar->GetPosition().y + __pSearchBar->GetHeight(),__pListview->GetWidth(),GetClientAreaBounds().height - (__pSearchBar->GetY() + __pSearchBar->GetHeight()));
494 __pListview->UpdateList();
495 __pFooter = GetFooter();
496 GetFooter()->SetItemEnabled(2,true);
497 GetFooter()->Invalidate(true);
501 SceneManager* pSceneManager = SceneManager::GetInstance();
502 if (pSceneManager != null)
504 if(__previousSceneId.CompareTo(IDSCN_HISTORY_LIST) != 0)
506 pSceneManager->GoBackward(BackwardSceneTransition());
510 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
515 if (__noBookmarks == true)
517 GetFooter()->SetItemEnabled(1,false);
521 GetFooter()->SetItemEnabled(1,true);
525 Tizen::Ui::Controls::ListItemBase*
526 BookmarkListForm::CreateItem(int index, int itemWidth)
529 AppLog("BookmarkListForm::CreateItem index %d , itemWidth %d",index, itemWidth);
530 AppLog("listviewwidth %d",__pListview->GetWidth());
531 result r = E_FAILURE;
532 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
537 CustomItem* pItem = new(std::nothrow) CustomItem();
539 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
540 Bitmap* pBitmap = null;
543 Image* pImage = null;
544 pImage = new Image();
547 const int x_Margin_Icon = 16; // local as there used only in this function
548 const int y_Margin_Icon = 28;
549 const int height_Icon = 72;
550 const int width_Icon = 72 ;
551 const int x_Margin_Title = 104 ;
552 const int y_Margin_Title = 10;
553 const int width_Title = GetClientAreaBounds().width - 108 - 52 - 30;
554 const int x_Margin_Url = 104 ;
555 const int y_Margin_Url = 70 ;
556 const int width_Url = GetClientAreaBounds().width - 108 - 52 ;
557 const int height_Url = 48;
558 const int itemHeight = 128;
559 const int textSize = 32;
562 if( pBookMark == NULL )
570 if ( pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER )
572 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth,112 - 44 + __fontSize), LIST_ANNEX_STYLE_DETAILED);
573 TryCatch(!IsFailed(r),,"BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
575 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_FOLDER_OPEN);
578 pItem->AddElement(Rectangle(x_Margin_Icon, 20+(__fontSize - 44)/2, width_Icon, height_Icon), IDA_FORMAT_ICON, *pBitmap, null);
582 pItem->AddElement(Rectangle(x_Margin_Title, 26, width_Title, 60 + (__fontSize - 44) ), IDA_FORMAT_FOLDER, pBookMark->GetBookmarkTitle(),__fontSize, CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,true);
584 if ( __pItemContextFolder != NULL)
586 pItem->SetContextItem(__pItemContextFolder);
591 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth, itemHeight - 44 + __fontSize), style);
592 TryCatch( !IsFailed(r),,"BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
594 AppLogDebug("BookmarkListForm::faviconid %ls",pBookMark->GetFaviconId().GetPointer());
595 bitmapId = pBookMark->GetFaviconId();
597 dim = Dimension(pBookMark->GetFavIconWidth(), pBookMark->GetFavIconHeight());
599 AppLog("BookmarkListForm::CreateItem check 0");
601 // get fav icon bitmap
602 ByteBuffer* pFavIconBuffer = null;
603 pFavIconBuffer = pBookMark->GetFavIconBuffer();
605 AppLog("BookmarkListForm::CreateItem check 0");
607 if (pFavIconBuffer != null)
609 AppLog("BookmarkListForm::CreateItem pFavIconBuffer is not null");
613 AppLog("BookmarkListForm::CreateItem pFavIconBuffer is null");
616 pBitmap = pImage->DecodeN(*pFavIconBuffer, IMG_FORMAT_PNG, BITMAP_PIXEL_FORMAT_ARGB8888);
618 AppLog("BookmarkListForm::CreateItem check 1");
622 AppLog("rahul bitmap is not null");
623 int width = pBitmap->GetWidth();
624 int height = pBitmap->GetHeight();
625 AppLog("rahul bitmap width is %d", width);
626 AppLog("rahul bitmap height is %d", height);
627 AppLog("rahul favicon width is %d", pBookMark->GetFavIconWidth());
628 AppLog("rahul favicon height is %d", pBookMark->GetFavIconHeight());
632 AppLog("rahul bitmap is null");
637 AppLogDebug("BookmarkListForm::CreateItem bitmap is null");
638 pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
640 pItem->AddElement(Rectangle(x_Margin_Icon, y_Margin_Icon +(__fontSize - 44)/2, width_Icon, height_Icon), IDA_FORMAT_ICON, *pBitmap, null);
641 pItem->AddElement(Rectangle(x_Margin_Title, 0, width_Title, itemHeight - height_Url - 44 + __fontSize), IDA_FORMAT_SITE, pBookMark->GetBookmarkTitle(),__fontSize,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,true);
642 // if(__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
643 // 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);
645 pItem->AddElement(Rectangle(x_Margin_Url, y_Margin_Url - 44 + __fontSize, width_Url, height_Url), IDA_FORMAT_URL, pBookMark->GetUrl(),textSize,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,true);
651 if ( __pItemContextSite != NULL)
653 pItem->SetContextItem(__pItemContextSite);
670 BookmarkListForm::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
678 BookmarkListForm::GetItemCount(void)
682 if (__pData != NULL )
684 __pData->RemoveAll(true);
688 __pData = new(std::nothrow) Collection::ArrayList();
689 __pData->Construct();
691 if (__searchBookmark == false)
693 BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID, count);
694 BookmarkPresentationModel::GetInstance()->GetFoldersBookmarks(__parentID, 0, count, *__pData);
698 if (__searchText.GetLength() > 0)
700 __searchText.Replace(L"%", L"/%");
701 __searchText.Replace(L"_", L"/_");
703 BookmarkPresentationModel::GetInstance()->GetSearchFolderBookmarkCount(count,__searchText);
704 BookmarkPresentationModel::GetInstance()->GetSearchFoldersBookmarks(0, count, *__pData, __searchText);
707 AppLogDebug("Count = %d parentId = %ls __searchText %ls", count, __parentID.GetPointer() , __searchText.GetPointer());
711 __noBookmarks = true;
712 GetFooter()->SetItemEnabled(1,false);
716 __noBookmarks = false;
717 GetFooter()->SetItemEnabled(1,true);
720 AppLogDebug("Result: %s", GetErrorMessage(GetLastResult()));
721 GetFooter()->Invalidate(true);
722 if (__pData != null && __pData->GetCount() >= 1)
724 // __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
725 __pSearchBar->SetShowState(true);
726 __pSearchBar->Invalidate(true);
728 else if (__searchBookmark == false)
730 __pSearchBar->SetShowState(false);
731 __pSearchBar->Invalidate(true);
734 if (__parentID.CompareTo(L"0") != 0)
736 __pSearchBar->SetShowState(false);
737 __pSearchBar->Invalidate(true);
739 if (__noBookmarks == true)
741 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
742 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_NO_CONTENT_BOOKMARK);
744 if ( pBitmap != NULL)
746 __pListview->SetBitmapOfEmptyList(pBitmap);
752 if (__parentID.CompareTo(L"0") == 0)
754 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetHeight(),GetClientAreaBounds().width ,GetClientAreaBounds().height - __pSearchBar->GetY() - __pSearchBar->GetHeight());
758 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
763 __pListview->Invalidate(true);
769 BookmarkListForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
771 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged int index %d, int elementId %d, Tizen::Ui::Controls::ListContextItemStatus status %d",index,elementId,status);
773 String deleteText = CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB");
774 deleteText.Append(L"? ");
776 result r = E_SUCCESS;
780 case IDA_CONTEXT_ITEM_FOLDER_EDIT:
782 ArrayList* pArgList = null;
783 String* pEdit = null;
785 SceneManager* pSceneManager = SceneManager::GetInstance();
786 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
787 if (pBookMark != null && pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
789 pArgList = new(std::nothrow) ArrayList();
790 if (pArgList != null)
792 pEdit= new(std::nothrow) String(CommonUtil::GetString(L"IDS_BR_SK_EDIT"));
793 pArgList->Construct();
794 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
795 pArgList->Add(*pEdit);
796 if ( pSceneManager != null)
799 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_BOOKMARK_FOLDER), pArgList);
802 if (pArgList != null)
809 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged GoForward failed %s",GetErrorMessage(r));
818 case IDA_CONTEXT_ITEM_FOLDER_DELETE:
819 case IDA_CONTEXT_ITEM_DELETE:
821 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
822 __pConfirmationPopup->Initialize();
823 __pConfirmationPopup->RemoveActionListener(*this);
824 __pConfirmationPopup->AddActionListener(*this);
825 __pConfirmationPopup->setMessage(deleteText);
826 __pConfirmationPopup->Show();
827 __selectedindex = index;
831 case IDA_CONTEXT_ITEM_EDIT:
833 ArrayList* pArgList = null;
834 SceneManager* pSceneManager = SceneManager::GetInstance();
835 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
836 if (pBookMark!= null && pBookMark->GetBookmarkType() == BOOKMARK_TYPE_URL)
838 AppLogDebug("ID_CONTEXT_ITEM_SITE_1 BOOKMARK_TYPE_URL");
839 pArgList = new(std::nothrow) ArrayList();
840 if (pArgList != null)
842 pArgList->Construct();
843 pArgList->Add(*new(std::nothrow) String(L"1"));
844 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
845 if ( pSceneManager != null)
848 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ADD_BOOKMARK), pArgList);
849 if (pArgList != null)
856 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged GoForward failed %s",GetErrorMessage(r));
864 case IDA_CONTEXT_ITEM_SHARE:
866 AppLogDebug("OnListViewContextItemStateChanged Share");
868 BookmarkData* pBookmark = dynamic_cast<BookmarkData*>(__pData->GetAt(index));
869 if (pBookmark != null)
871 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
872 pShareInfo->SetPageTitle(pBookmark->GetBookmarkTitle());
873 pShareInfo->SetPageUrl(pBookmark->GetUrl());
874 pShareInfo->SetImageAttached(false);
875 __pPopUp->RemoveAllShareInfo();
876 __pPopUp->AddShareInfo(pShareInfo);
879 if (__pPopUp != null)
881 __pPopUp->SetShowState(true);
893 BookmarkListForm::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
899 BookmarkListForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
901 AppLogDebug("BookmarkListForm::OnListViewItemStateChanged");
903 result r = E_FAILURE;
904 ArrayList *pArgList = null;
905 SceneManager* pSceneManager = SceneManager::GetInstance();
906 BookmarkData* pBookmark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
908 if ( pBookmark == NULL )
913 switch (pBookmark->GetBookmarkType())
915 case BOOKMARK_TYPE_FOLDER:
917 __parentID = pBookmark->GetBookmarkId();
918 AppLogDebug("BOOKMARK_TYPE_FOLDER parent ID is %ls",__parentID.GetPointer());
920 listView.UpdateList();
921 if (listView.GetItemCount() == 0)
923 GetFooter()->SetItemEnabled(1,false);
927 GetFooter()->SetItemEnabled(1,true);
929 GetFooter()->SetItemEnabled(2,false);
930 GetFooter()->Invalidate(true);
931 __pSearchBar->HideKeypad();
932 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
933 __pSearchBar->SetShowState(false);
934 __pSearchBar->Invalidate(true);
935 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pListview->GetWidth() ,GetClientAreaBounds().height);
938 case BOOKMARK_TYPE_URL:
940 pArgList = new(std::nothrow) ArrayList();
941 if (pArgList != null)
943 r = pArgList->Construct();
944 TryCatch(!IsFailed(r), L"BookmarkListForm::OnListViewItemStateChanged pArgList Construct failed %s", GetErrorMessage(r));
946 AppLogDebug("bookmark url = %ls",pBookmark->GetUrl().GetPointer());
947 r = pArgList->Add(*MultipleWindowPresentationModel::GetInstance()->GetActiveWindowInfo());
948 pArgList->Add(*new(std::nothrow) String(pBookmark->GetUrl()));
950 if (pSceneManager != null)
952 AppLogDebug("pSceneManager exists");
954 MultipleWindowPresentationModel::GetInstance()->GetCurrentSceneId(prevSceneId);
955 r = pSceneManager->GoBackward(BackwardSceneTransition(prevSceneId), pArgList);
956 TryCatch(!IsFailed(r), L"BookmarkListForm::OnListViewItemStateChanged pArgList Construct failed %s", GetErrorMessage(r));
970 pArgList->RemoveAll(true);
977 BookmarkListForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
984 BookmarkListForm::OnFastScrollIndexSelected(Tizen::Ui::Control& source, Tizen::Base::String& index)
990 BookmarkListForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
992 result r = E_FAILURE;
993 AppLog("ABCD::BookmarkListForm::OnSearchBarModeChanged");
995 if (mode == SEARCH_BAR_MODE_NORMAL)
997 __pSearchListView->SetShowState(false);
998 __pSearchListView->UpdateList();
999 __pListview->SetShowState(true);
1001 __searchBookmark = false;
1002 r = __pListview->UpdateList();
1003 // __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1004 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1005 TryCatch( !IsFailed(r),,"BookmarkListForm::OnSearchBarModeChanged Update list failed %s",GetErrorMessage(r));
1010 __pSearchListView->SetShowState(true);
1011 __pSearchListView->SetEnabled(false);
1012 __pListview->SetShowState(false);
1016 r = __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1017 __pSearchBar->SetText(L"");
1019 AppLog("OnSearchBarModeChanged SetContentAreaSize heihgt %d, %d",__pSearchListView->GetHeight() , GetClientAreaBounds().height - __pSearchBar->GetHeight());
1020 __pListview->UpdateList();
1021 __pSearchListView->UpdateList();
1026 BookmarkListForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
1028 AppLog("ABCD::BookmarkListForm::OnKeypadWillOpen");
1029 GetFooter()->SetShowState(false);
1030 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight());
1031 __pSearchListView->SetEnabled(false);
1032 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1037 BookmarkListForm::OnKeypadOpened(Tizen::Ui::Control& source)
1039 AppLog("ABCD::BookmarkListForm::OnKeypadOpened");
1040 GetFooter()->SetShowState(false);
1041 AppLog("ABCD::BookmarkListForm::OnKeypadOpened");
1042 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1043 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1048 BookmarkListForm::OnKeypadClosed(Tizen::Ui::Control& source)
1050 AppLog("ABCD::BookmarkListForm::OnKeypadClosed");
1051 AppLog("jahsjkdad %d",Clipboard::GetInstance()->IsPopupVisible());
1052 if(Clipboard::GetInstance()->IsPopupVisible() == true)
1056 GetFooter()->SetShowState(true);
1057 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1058 __pSearchListView->Invalidate(false);
1059 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1060 __pListview->SetBounds(0, __pSearchBar->GetY() + __pSearchBar->GetHeight(), GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight());
1065 BookmarkListForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
1067 AppLog("BookmarkListForm::OnKeypadActionPerformed %d",keypadAction);
1069 if (__pSearchBar != null)
1071 __pSearchBar->HideKeypad();
1073 if ( __pSearchBar != null && keypadAction == KEYPAD_ACTION_SEARCH)
1075 // if (__pSearchBar->GetText().GetLength() == 0)
1080 if (__pSearchBar != null)
1082 __pSearchBar->HideKeypad();
1085 __searchText = __pSearchBar->GetText();
1086 AppLog("SearchbarGettext result %s %ls",GetErrorMessage(GetLastResult()),__searchText.GetPointer());
1087 __searchBookmark = true;
1088 __pListview->SetShowState(false);
1089 __pSearchListView->SetEnabled(true);
1090 __pSearchListView->SetShowState(true);
1091 __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1092 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1093 __pSearchListView->UpdateList();
1100 BookmarkListForm::OnKeypadBoundsChanged(Tizen::Ui::Control& source)
1102 FloatRectangle clientRect;
1103 clientRect = GetClientAreaBoundsF();
1104 AppLogDebug("SearchBarForm::OnKeypadBoundsChanged ClientBounds(%f, %f, %f, %f)",clientRect.x, clientRect.y, clientRect.width, clientRect.height);
1105 __pSearchBar->SetContentAreaSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1106 __pSearchListView->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1107 __pListview->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1108 // __pListview->SetEnabled(false);
1113 BookmarkListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
1115 AppLogDebug("BookmarkListForm::OnSceneActivatedN called");
1116 ArrayListT<String> * pList = dynamic_cast<ArrayListT<String>* >(SceneManager::GetInstance()->GetSceneHistoryN());
1119 pList->GetAt(pList->GetCount()-1,__previousSceneId);
1122 __searchBookmark = false;
1123 GetFooter()->SetShowState(true);
1124 GetFooter()->Invalidate(true);
1125 GetHeader()->SetItemSelected(0);
1126 GetHeader()->Invalidate(true);
1128 /* if (previousSceneId != IDSCN_HISTORY_LIST && previousSceneId != IDSCN_CREATE_BOOKMARK_FOLDER && previousSceneId != IDSCN_EDIT_BOOKMARK_LIST)
1130 __previousSceneId = previousSceneId;
1133 if (__pListview != null)
1135 __pListview->UpdateList();
1142 BookmarkListForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
1144 AppLog("BookmarkListForm::OnOrientationChanged start");
1145 __pListview->SetBackgroundColor(GetBackgroundColor());
1146 __pSearchListView->SetBackgroundColor(GetBackgroundColor());
1149 if(__pSearchBar->GetShowState())
1151 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetHeight(),GetClientAreaBounds().width ,GetClientAreaBounds().height - __pSearchBar->GetY() - __pSearchBar->GetHeight());
1155 __pListview->SetBounds(__pListview->GetX(),0,GetClientAreaBounds().width ,GetClientAreaBounds().height);
1157 __pListview->UpdateList();
1160 if (__pSearchListView && __pListview)
1162 AppLog("__pListview->GetBounds() %d, %d, %d, %d",__pListview->GetBounds().x,__pListview->GetBounds().y,__pListview->GetBounds().width,__pListview->GetBounds().height);
1163 __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1165 __pSearchListView->UpdateList();
1168 if (__pSearchListView && __pData != null )
1170 if (__parentID != DEFAULT_VALUE_PARENTID)
1172 AppLog("BookmarkListForm::OnOrientationChanged parent id true");
1173 __pSearchBar->SetShowState(false);
1174 __pSearchBar->Invalidate(true);
1177 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1183 // FloatRectangle clientRect;
1184 // clientRect = GetClientAreaBoundsF();
1186 // __pSearchBar->SetContentAreaSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1187 // __pListview->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1188 // __pSearchListView->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1189 // Invalidate(true);
1196 BookmarkListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
1198 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);