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 Bitmap *pBitmapNormal = null;
139 Bitmap *pBitmapPressed = null;
140 Header *pHeader = GetHeader();
141 Bitmap *pIconBitmap = null;
142 AppResource* pAppResource = UiApp::GetInstance()->GetAppResource();
143 int bookmarkCount = 0;
144 const int WIDTH_CONTEXT_MENU_TWO_BUTTON = 336;
145 const int WIDTH_CONTEXT_MENU_THREE_BUTTON = 160;
146 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
149 // Setup back event listener
150 SetFormBackEventListener(this);
151 AddOrientationEventListener(*this);
153 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_BOOKMARK_VIEW, *this);
154 GetHeader()->AddActionEventListener(*this);
155 GetFooter()->AddActionEventListener(*this);
157 if ( pAppResource == NULL )
162 __fontSize = CommonUtil::GetFontSize();
163 __pItemContextFolder = new(std::nothrow) ListContextItem();
164 __pItemContextFolder->Construct();
165 __pItemContextFolder->AddElement(IDA_CONTEXT_ITEM_FOLDER_EDIT, CommonUtil::GetString(L"IDS_BR_SK_EDIT"));
166 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_TWO_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
167 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_TWO_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
169 if (pBitmapNormal != null && pBitmapPressed != null)
171 __pItemContextFolder->AddElement(IDA_CONTEXT_ITEM_FOLDER_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
174 if (pBitmapNormal != null)
176 delete pBitmapNormal;
179 if (pBitmapPressed != null)
181 delete pBitmapPressed;
184 __pItemContextSite = new(std::nothrow) ListContextItem();
185 __pItemContextSite->Construct();
186 __pItemContextSite->AddElement(IDA_CONTEXT_ITEM_EDIT, CommonUtil::GetString(L"IDS_BR_SK_EDIT"));
187 __pItemContextSite->AddElement(IDA_CONTEXT_ITEM_SHARE, CommonUtil::GetString(L"IDS_BR_OPT_SHARE"));
188 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_THREE_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
189 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_THREE_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
191 if (pBitmapNormal != null && pBitmapPressed != null)
193 __pItemContextSite->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
196 if (pBitmapNormal != null)
198 delete pBitmapNormal;
201 if (pBitmapPressed != null)
203 delete pBitmapPressed;
205 __pListview = static_cast< ListView* >(GetControl("IDC_LISTVIEW1"));
207 if (__pListview == null)
211 __pSearchBar = static_cast< SearchBar* >(GetControl(L"IDC_SEARCHBAR1"));
213 if (__pSearchBar == null)
218 if (__pListview != null)
220 // __pListview->SetBounds(__pListview->GetX(), __pListview->GetY(), GetClientAreaBounds().width, GetClientAreaBounds().height);
221 __pListview->AddFastScrollListener(*this);
222 __pListview->AddListViewItemEventListener(*this);
223 __pListview->SetItemProvider(*this);
224 __pListview->UpdateList();
227 __pPopUp = new(std::nothrow) SharePopup();
229 if (__pPopUp != null)
231 __pPopUp->Initialize();
232 AddControl(__pPopUp);
235 __pSearchListView = new(std::nothrow) ListView();
237 if (__pSearchListView == null)
242 r = __pSearchListView->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height -72 - 30), true, false);
243 TryCatch( !IsFailed(r),,"BookmarkListForm::OnSearchBarModeChanged Update list failed %s",GetErrorMessage(r));
245 __pSearchListView->SetBackgroundColor(GetBackgroundColor());
246 __pSearchListView->SetItemProvider(*this);
247 __pSearchListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RESULTS_FOUND"));
248 __pSearchListView->SetTextColorOfEmptyList(Color::GetColor(COLOR_ID_BLACK));
249 __pSearchListView->SetShowState(false);
250 __pSearchListView->AddListViewItemEventListener(*this);
252 __pSearchBar->AddSearchBarEventListener(*this);
253 __pSearchBar->AddKeypadEventListener(*this);
254 __pSearchBar->SetContent(__pSearchListView);
256 BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID, bookmarkCount);
257 if(bookmarkCount <= 0)
259 __pSearchBar->SetShowState(false);
260 //__pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pSearchBar->GetWidth(),GetClientAreaBounds().height - __pSearchBar->GetPosition().y);
261 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pListview->GetWidth(),GetClientAreaBounds().height);
265 __pSearchBar->SetShowState(true);
271 pHeader->SetStyle(HEADER_STYLE_TAB);
272 bookmark.Construct(IDA_TABBAR_ITEM_1);
274 pAppResource->GetString(L"IDS_BR_TAB_BOOKMARKS", strbookmark);
275 bookmark.SetText(strbookmark);
276 pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_BOOKMARK);
277 bookmark.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);
278 bookmark.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
279 pHeader->AddItem(bookmark);
281 if (pIconBitmap != NULL)
286 history.Construct(IDA_TABBAR_ITEM_2);
288 pAppResource->GetString(L"IDS_BR_TAB_HISTORY", strhistory);
289 history.SetText(strhistory);
290 pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_HISTORY);
291 history.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);
292 history.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
293 pHeader->AddItem(history);
294 pHeader->SetItemSelected(0);
295 pHeader->SetTabEditModeEnabled(false);
297 if (pIconBitmap != NULL)
308 BookmarkListForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
310 AppLogDebug("BookmarkListForm::OnActionPerformed actionId = %d",actionId);
313 BookmarkData* pBookMark = null;
317 case IDA_FOOTER_ITEM1:
319 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
320 GetHeader()->SetItemSelected(0);
321 GetHeader()->Invalidate(true);
322 SceneManager* pSceneManager = SceneManager::GetInstance();
323 pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(__selectedindex));
325 if ( pBookMark == NULL )
330 ArrayList* pArgList = null;
331 pArgList = new(std::nothrow) ArrayList();
332 if (pArgList != null)
334 pArgList->Construct();
335 pArgList->Add(*new(std::nothrow) String(pBookMark->GetParentId()));
337 //pArgList->Add(*new(std::nothrow) String(pBookmark->);
338 if (pSceneManager != null)
340 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_EDIT_BOOKMARK_LIST),pArgList) != E_SUCCESS)
342 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
343 pArgList->RemoveAll(true);
350 if ( pArgList != NULL)
352 pArgList->RemoveAll(true);
358 case IDA_TABBAR_ITEM_2:
360 GetHeader()->SetItemSelected(0);
361 GetHeader()->Invalidate(true);
363 SceneManager* pSceneManager = SceneManager::GetInstance();
365 if (pSceneManager != null)
367 if(__previousSceneId.CompareTo(IDSCN_HISTORY_LIST) != 0)
369 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT)) != E_SUCCESS)
371 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
378 if(pSceneManager->GoBackward(BackwardSceneTransition())!= E_SUCCESS)
380 AppLogDebug("BookmarkListForm::OnActionPerformed GoBackward failed");
388 case IDA_FOOTER_ITEM2:
390 SceneManager* pSceneManager = SceneManager::GetInstance();
394 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_BOOKMARK_FOLDER)) != E_SUCCESS)
396 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
402 case IDA_FOOTER_ITEM_ADDBOOKMARK:
404 SceneManager* pSceneManager = SceneManager::GetInstance();
406 // send array list 0-for add, 1 for edit with parent ID
407 ArrayList* pArgList = null;
408 pArgList = new(std::nothrow) ArrayList();
409 if (pArgList != null)
411 pArgList->Construct();
412 pArgList->Add(*new(std::nothrow) String(L"0"));
413 pArgList->Add(*new(std::nothrow) String(__parentID));
418 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ADD_BOOKMARK),pArgList) != E_SUCCESS)
420 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
421 pArgList->RemoveAll(true);
427 if (pArgList != null)
429 pArgList->RemoveAll(true);
436 __pConfirmationPopup->SetShowState(false);
437 __pConfirmationPopup->Show();
440 pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(__selectedindex));
441 if ( pBookMark== null)
443 bookmarkId=pBookMark->GetBookmarkId();
444 Integer::Parse(bookmarkId,id);
445 if (pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
446 BookmarkPresentationModel::GetInstance()->DeleteFolder(id);
448 BookmarkPresentationModel::GetInstance()->DeleteBookmark(id);
449 if (__pListview == null)
453 AppLogDebug("__pListview GetBounds %d,%d,%d,%d",__pListview->GetBounds().x,__pListview->GetBounds().y,__pListview->GetBounds().width,__pListview->GetBounds().height);
454 __pSearchListView->UpdateList();
455 __pListview->UpdateList();
457 if (__pListview->GetItemCount() == 0)
459 GetFooter()->SetItemEnabled(1,false);
460 __pSearchBar->SetShowState(false);
461 __pSearchBar->Invalidate(true);
464 if (__noBookmarks == true)
466 Bitmap* emptyListBmp = AppResource::GetInstance()->GetBitmapN(IDB_NO_CONTENT_BOOKMARK);
467 GetFooter()->SetItemEnabled(1,false);
468 __pSearchBar->SetShowState(false);
469 __pSearchBar->Invalidate(true);
470 // __pListview->SetBounds(__pSearchBar->GetPosition().x,__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
471 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
472 __pListview->SetBitmapOfEmptyList(emptyListBmp);
478 __pListview->UpdateList();
483 GetFooter()->SetItemEnabled(1,true);
485 if (__parentID.CompareTo(L"0") == 0)
487 __pSearchBar->SetShowState(true);
488 __pSearchBar->Invalidate(true);
492 GetFooter()->Invalidate(true);
493 __pConfirmationPopup->SetShowState(false);
494 __pConfirmationPopup->Show();
504 BookmarkListForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
506 AppLogDebug("BrowserApplicationForm::OnFormBackRequested");
508 UiApp* pApp = UiApp::GetInstance();
514 if (__parentID != DEFAULT_VALUE_PARENTID)
516 __parentID = DEFAULT_VALUE_PARENTID;
517 __pSearchBar->SetShowState(true);
518 __pListview->SetBounds(__pListview->GetX() ,__pSearchBar->GetPosition().y + __pSearchBar->GetHeight(),__pListview->GetWidth(),GetClientAreaBounds().height - (__pSearchBar->GetY() + __pSearchBar->GetHeight()));
519 __pListview->UpdateList();
520 __pFooter = GetFooter();
521 GetFooter()->SetItemEnabled(2,true);
522 GetFooter()->Invalidate(true);
526 SceneManager* pSceneManager = SceneManager::GetInstance();
527 if (pSceneManager != null)
529 if(__previousSceneId.CompareTo(IDSCN_HISTORY_LIST) != 0)
531 pSceneManager->GoBackward(BackwardSceneTransition());
535 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
540 if (__noBookmarks == true)
542 GetFooter()->SetItemEnabled(1,false);
546 GetFooter()->SetItemEnabled(1,true);
550 Tizen::Ui::Controls::ListItemBase*
551 BookmarkListForm::CreateItem(int index, int itemWidth)
554 AppLog("BookmarkListForm::CreateItem index %d , itemWidth %d",index, itemWidth);
555 AppLog("listviewwidth %d",__pListview->GetWidth());
556 result r = E_FAILURE;
557 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
562 CustomItem* pItem = new(std::nothrow) CustomItem();
564 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
565 Bitmap* pBitmap = null;
568 Image* pImage = null;
569 pImage = new Image();
572 const int x_Margin_Icon = 16; // local as there used only in this function
573 const int y_Margin_Icon = 28;
574 const int height_Icon = 72;
575 const int width_Icon = 72 ;
576 const int x_Margin_Title = 104 ;
577 const int y_Margin_Title = 10;
578 const int width_Title = GetClientAreaBounds().width - 108 - 52 - 30;
579 const int x_Margin_Url = 104 ;
580 const int y_Margin_Url = 70 ;
581 const int width_Url = GetClientAreaBounds().width - 108 - 52 ;
582 const int height_Url = 48;
583 const int itemHeight = 128;
584 const int textSize = 32;
587 if( pBookMark == NULL )
595 if ( pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER )
597 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth,112 - 44 + __fontSize), LIST_ANNEX_STYLE_DETAILED);
598 TryCatch(!IsFailed(r),,"BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
600 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_FOLDER_OPEN);
603 pItem->AddElement(Rectangle(x_Margin_Icon, 20+(__fontSize - 44)/2, width_Icon, height_Icon), IDA_FORMAT_ICON, *pBitmap, null);
607 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);
609 if ( __pItemContextFolder != NULL)
611 pItem->SetContextItem(__pItemContextFolder);
616 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth, itemHeight - 44 + __fontSize), style);
617 TryCatch( !IsFailed(r),,"BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
619 AppLogDebug("BookmarkListForm::faviconid %ls",pBookMark->GetFaviconId().GetPointer());
620 bitmapId = pBookMark->GetFaviconId();
622 dim = Dimension(pBookMark->GetFavIconWidth(), pBookMark->GetFavIconHeight());
624 AppLog("BookmarkListForm::CreateItem check 0");
626 // get fav icon bitmap
627 ByteBuffer* pFavIconBuffer = null;
628 pFavIconBuffer = pBookMark->GetFavIconBuffer();
630 AppLog("BookmarkListForm::CreateItem check 0");
632 if (pFavIconBuffer != null)
634 AppLog("BookmarkListForm::CreateItem pFavIconBuffer is not null");
638 AppLog("BookmarkListForm::CreateItem pFavIconBuffer is null");
641 pBitmap = pImage->DecodeN(*pFavIconBuffer, IMG_FORMAT_PNG, BITMAP_PIXEL_FORMAT_ARGB8888);
643 AppLog("BookmarkListForm::CreateItem check 1");
647 AppLog("rahul bitmap is not null");
648 int width = pBitmap->GetWidth();
649 int height = pBitmap->GetHeight();
650 AppLog("rahul bitmap width is %d", width);
651 AppLog("rahul bitmap height is %d", height);
652 AppLog("rahul favicon width is %d", pBookMark->GetFavIconWidth());
653 AppLog("rahul favicon height is %d", pBookMark->GetFavIconHeight());
657 AppLog("rahul bitmap is null");
662 AppLogDebug("BookmarkListForm::CreateItem bitmap is null");
663 pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
665 pItem->AddElement(Rectangle(x_Margin_Icon, y_Margin_Icon +(__fontSize - 44)/2, width_Icon, height_Icon), IDA_FORMAT_ICON, *pBitmap, null);
666 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);
667 // if(__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
668 // 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);
670 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);
676 if ( __pItemContextSite != NULL)
678 pItem->SetContextItem(__pItemContextSite);
695 BookmarkListForm::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
703 BookmarkListForm::GetItemCount(void)
707 if (__pData != NULL )
709 __pData->RemoveAll(true);
713 __pData = new(std::nothrow) Collection::ArrayList();
714 __pData->Construct();
716 if (__searchBookmark == false)
718 BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID, count);
719 BookmarkPresentationModel::GetInstance()->GetFoldersBookmarks(__parentID, 0, count, *__pData);
723 BookmarkPresentationModel::GetInstance()->GetSearchFolderBookmarkCount(count,__searchText);
724 BookmarkPresentationModel::GetInstance()->GetSearchFoldersBookmarks(0, count, *__pData, __searchText);
727 AppLogDebug("Count = %d parentId = %ls", count, __parentID.GetPointer());
731 __noBookmarks = true;
732 GetFooter()->SetItemEnabled(1,false);
736 __noBookmarks = false;
737 GetFooter()->SetItemEnabled(1,true);
740 AppLogDebug("Result: %s", GetErrorMessage(GetLastResult()));
741 GetFooter()->Invalidate(true);
742 if (__pData != null && __pData->GetCount() >= 1)
744 // __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
745 __pSearchBar->SetShowState(true);
746 __pSearchBar->Invalidate(true);
748 else if (__searchBookmark == false)
750 __pSearchBar->SetShowState(false);
751 __pSearchBar->Invalidate(true);
754 if (__parentID.CompareTo(L"0") != 0)
756 __pSearchBar->SetShowState(false);
757 __pSearchBar->Invalidate(true);
759 if (__noBookmarks == true)
761 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
762 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_NO_CONTENT_BOOKMARK);
764 if ( pBitmap != NULL)
766 __pListview->SetBitmapOfEmptyList(pBitmap);
772 if (__parentID.CompareTo(L"0") == 0)
774 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetHeight(),GetClientAreaBounds().width ,GetClientAreaBounds().height - __pSearchBar->GetY() - __pSearchBar->GetHeight());
778 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
783 __pListview->Invalidate(true);
789 BookmarkListForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
791 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged int index %d, int elementId %d, Tizen::Ui::Controls::ListContextItemStatus status %d",index,elementId,status);
793 String deleteText = CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB");
794 deleteText.Append(L"? ");
796 result r = E_SUCCESS;
800 case IDA_CONTEXT_ITEM_FOLDER_EDIT:
802 ArrayList* pArgList = null;
803 String* pEdit = null;
805 SceneManager* pSceneManager = SceneManager::GetInstance();
806 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
807 if (pBookMark != null && pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
809 pArgList = new(std::nothrow) ArrayList();
810 if (pArgList != null)
812 pEdit= new(std::nothrow) String(CommonUtil::GetString(L"IDS_BR_SK_EDIT"));
813 pArgList->Construct();
814 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
815 pArgList->Add(*pEdit);
816 if ( pSceneManager != null)
819 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_BOOKMARK_FOLDER), pArgList);
822 if (pArgList != null)
829 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged GoForward failed %s",GetErrorMessage(r));
838 case IDA_CONTEXT_ITEM_FOLDER_DELETE:
839 case IDA_CONTEXT_ITEM_DELETE:
841 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
842 __pConfirmationPopup->Initialize();
843 __pConfirmationPopup->RemoveActionListener(*this);
844 __pConfirmationPopup->AddActionListener(*this);
845 __pConfirmationPopup->setMessage(deleteText);
846 __pConfirmationPopup->Show();
847 __selectedindex = index;
851 case IDA_CONTEXT_ITEM_EDIT:
853 ArrayList* pArgList = null;
854 SceneManager* pSceneManager = SceneManager::GetInstance();
855 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
856 if (pBookMark!= null && pBookMark->GetBookmarkType() == BOOKMARK_TYPE_URL)
858 AppLogDebug("ID_CONTEXT_ITEM_SITE_1 BOOKMARK_TYPE_URL");
859 pArgList = new(std::nothrow) ArrayList();
860 if (pArgList != null)
862 pArgList->Construct();
863 pArgList->Add(*new(std::nothrow) String(L"1"));
864 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
865 if ( pSceneManager != null)
868 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ADD_BOOKMARK), pArgList);
869 if (pArgList != null)
876 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged GoForward failed %s",GetErrorMessage(r));
884 case IDA_CONTEXT_ITEM_SHARE:
886 AppLogDebug("OnListViewContextItemStateChanged Share");
888 BookmarkData* pBookmark = dynamic_cast<BookmarkData*>(__pData->GetAt(index));
889 if (pBookmark != null)
891 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
892 pShareInfo->SetPageTitle(pBookmark->GetBookmarkTitle());
893 pShareInfo->SetPageUrl(pBookmark->GetUrl());
894 pShareInfo->SetImageAttached(false);
895 __pPopUp->RemoveAllShareInfo();
896 __pPopUp->AddShareInfo(pShareInfo);
899 if (__pPopUp != null)
901 __pPopUp->SetShowState(true);
913 BookmarkListForm::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
919 BookmarkListForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
921 AppLogDebug("BookmarkListForm::OnListViewItemStateChanged");
923 result r = E_FAILURE;
924 ArrayList *pArgList = null;
925 SceneManager* pSceneManager = SceneManager::GetInstance();
926 BookmarkData* pBookmark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
928 if ( pBookmark == NULL )
933 switch (pBookmark->GetBookmarkType())
935 case BOOKMARK_TYPE_FOLDER:
937 __parentID = pBookmark->GetBookmarkId();
938 AppLogDebug("BOOKMARK_TYPE_FOLDER parent ID is %ls",__parentID.GetPointer());
940 listView.UpdateList();
941 if (listView.GetItemCount() == 0)
943 GetFooter()->SetItemEnabled(1,false);
947 GetFooter()->SetItemEnabled(1,true);
949 GetFooter()->SetItemEnabled(2,false);
950 GetFooter()->Invalidate(true);
951 __pSearchBar->HideKeypad();
952 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
953 __pSearchBar->SetShowState(false);
954 __pSearchBar->Invalidate(true);
955 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pListview->GetWidth() ,GetClientAreaBounds().height);
958 case BOOKMARK_TYPE_URL:
960 pArgList = new(std::nothrow) ArrayList();
961 if (pArgList != null)
963 r = pArgList->Construct();
964 TryCatch(!IsFailed(r), L"BookmarkListForm::OnListViewItemStateChanged pArgList Construct failed %s", GetErrorMessage(r));
966 AppLogDebug("bookmark url = %ls",pBookmark->GetUrl().GetPointer());
967 r = pArgList->Add(*MultipleWindowPresentationModel::GetInstance()->GetActiveWindowInfo());
968 pArgList->Add(*new(std::nothrow) String(pBookmark->GetUrl()));
970 if (pSceneManager != null)
972 AppLogDebug("pSceneManager exists");
974 MultipleWindowPresentationModel::GetInstance()->GetCurrentSceneId(prevSceneId);
975 r = pSceneManager->GoBackward(BackwardSceneTransition(prevSceneId), pArgList);
976 TryCatch(!IsFailed(r), L"BookmarkListForm::OnListViewItemStateChanged pArgList Construct failed %s", GetErrorMessage(r));
990 pArgList->RemoveAll(true);
997 BookmarkListForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1004 BookmarkListForm::OnFastScrollIndexSelected(Tizen::Ui::Control& source, Tizen::Base::String& index)
1010 BookmarkListForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
1012 result r = E_FAILURE;
1013 AppLog("ABCD::BookmarkListForm::OnSearchBarModeChanged");
1015 if (mode == SEARCH_BAR_MODE_NORMAL)
1017 __pSearchListView->SetShowState(false);
1018 __pSearchListView->UpdateList();
1019 __pListview->SetShowState(true);
1021 __searchBookmark = false;
1022 r = __pListview->UpdateList();
1023 // __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1024 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1025 TryCatch( !IsFailed(r),,"BookmarkListForm::OnSearchBarModeChanged Update list failed %s",GetErrorMessage(r));
1030 __pSearchListView->SetShowState(true);
1031 __pSearchListView->SetEnabled(false);
1032 __pListview->SetShowState(false);
1036 r = __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1037 __pSearchBar->SetText(L"");
1039 AppLog("OnSearchBarModeChanged SetContentAreaSize heihgt %d, %d",__pSearchListView->GetHeight() , GetClientAreaBounds().height - __pSearchBar->GetHeight());
1040 __pListview->UpdateList();
1041 __pSearchListView->UpdateList();
1046 BookmarkListForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
1048 AppLog("ABCD::BookmarkListForm::OnKeypadWillOpen");
1049 GetFooter()->SetShowState(false);
1050 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight());
1051 __pSearchListView->SetEnabled(false);
1052 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1057 BookmarkListForm::OnKeypadOpened(Tizen::Ui::Control& source)
1059 AppLog("ABCD::BookmarkListForm::OnKeypadOpened");
1060 GetFooter()->SetShowState(false);
1061 AppLog("ABCD::BookmarkListForm::OnKeypadOpened");
1062 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1063 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1068 BookmarkListForm::OnKeypadClosed(Tizen::Ui::Control& source)
1070 AppLog("ABCD::BookmarkListForm::OnKeypadClosed");
1071 AppLog("jahsjkdad %d",Clipboard::GetInstance()->IsPopupVisible());
1072 if(Clipboard::GetInstance()->IsPopupVisible() == true)
1076 GetFooter()->SetShowState(true);
1077 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1078 __pSearchListView->Invalidate(false);
1079 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1080 __pListview->SetBounds(0, __pSearchBar->GetY() + __pSearchBar->GetHeight(), GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight());
1085 BookmarkListForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
1087 AppLog("BookmarkListForm::OnKeypadActionPerformed %d",keypadAction);
1089 if (__pSearchBar != null)
1091 __pSearchBar->HideKeypad();
1093 if ( __pSearchBar != null && keypadAction == KEYPAD_ACTION_SEARCH)
1095 // if (__pSearchBar->GetText().GetLength() == 0)
1100 if (__pSearchBar != null)
1102 __pSearchBar->HideKeypad();
1105 __searchText = __pSearchBar->GetText();
1106 AppLog("SearchbarGettext result %s",GetErrorMessage(GetLastResult()));
1107 __searchBookmark = true;
1108 __pListview->SetShowState(false);
1109 __pSearchListView->SetEnabled(true);
1110 __pSearchListView->SetShowState(true);
1111 __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1112 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1113 __pSearchListView->UpdateList();
1120 BookmarkListForm::OnKeypadBoundsChanged(Tizen::Ui::Control& source)
1122 FloatRectangle clientRect;
1123 clientRect = GetClientAreaBoundsF();
1124 AppLogDebug("SearchBarForm::OnKeypadBoundsChanged ClientBounds(%f, %f, %f, %f)",clientRect.x, clientRect.y, clientRect.width, clientRect.height);
1125 __pSearchBar->SetContentAreaSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1126 __pSearchListView->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1127 __pListview->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1128 // __pListview->SetEnabled(false);
1133 BookmarkListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
1135 AppLogDebug("BookmarkListForm::OnSceneActivatedN called");
1136 ArrayListT<String> * pList = dynamic_cast<ArrayListT<String>* >(SceneManager::GetInstance()->GetSceneHistoryN());
1139 pList->GetAt(pList->GetCount()-1,__previousSceneId);
1142 __searchBookmark = false;
1143 GetFooter()->SetShowState(true);
1144 GetFooter()->Invalidate(true);
1145 GetHeader()->SetItemSelected(0);
1146 GetHeader()->Invalidate(true);
1148 /* if (previousSceneId != IDSCN_HISTORY_LIST && previousSceneId != IDSCN_CREATE_BOOKMARK_FOLDER && previousSceneId != IDSCN_EDIT_BOOKMARK_LIST)
1150 __previousSceneId = previousSceneId;
1153 if (__pListview != null)
1155 __pListview->UpdateList();
1162 BookmarkListForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
1164 AppLog("BookmarkListForm::OnOrientationChanged start");
1165 __pListview->SetBackgroundColor(GetBackgroundColor());
1166 __pSearchListView->SetBackgroundColor(GetBackgroundColor());
1169 if(__pSearchBar->GetShowState())
1171 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetHeight(),GetClientAreaBounds().width ,GetClientAreaBounds().height - __pSearchBar->GetY() - __pSearchBar->GetHeight());
1175 __pListview->SetBounds(__pListview->GetX(),0,GetClientAreaBounds().width ,GetClientAreaBounds().height);
1177 __pListview->UpdateList();
1180 if (__pSearchListView && __pListview)
1182 AppLog("__pListview->GetBounds() %d, %d, %d, %d",__pListview->GetBounds().x,__pListview->GetBounds().y,__pListview->GetBounds().width,__pListview->GetBounds().height);
1183 __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1185 __pSearchListView->UpdateList();
1188 if (__pSearchListView && __pData != null )
1190 if (__parentID != DEFAULT_VALUE_PARENTID)
1192 AppLog("BookmarkListForm::OnOrientationChanged parent id true");
1193 __pSearchBar->SetShowState(false);
1194 __pSearchBar->Invalidate(true);
1197 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1203 // FloatRectangle clientRect;
1204 // clientRect = GetClientAreaBoundsF();
1206 // __pSearchBar->SetContentAreaSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1207 // __pListview->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1208 // __pSearchListView->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1209 // Invalidate(true);
1216 BookmarkListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
1218 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);