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_search_list_icon_favorite.png";
47 static const wchar_t* IDB_TAB_ICON_HISTORY = L"I01_search_list_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->AddElement(IDA_CONTEXT_ITEM_FOLDER_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), true);
166 __pItemContextFolder->SetElementBackgroundColor(IDA_CONTEXT_ITEM_FOLDER_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
167 __pItemContextFolder->SetElementBackgroundColor(IDA_CONTEXT_ITEM_FOLDER_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
168 __pItemContextFolder->SetElementBackgroundColor(IDA_CONTEXT_ITEM_FOLDER_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
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 __pSearchBar->AddFocusEventListener(*this);
194 if (__pListview != null)
196 __pListview->SetBackgroundColor(GetBackgroundColor());
197 // __pListview->SetBounds(__pListview->GetX(), __pListview->GetY(), GetClientAreaBounds().width, GetClientAreaBounds().height);
198 __pListview->AddFastScrollListener(*this);
199 __pListview->AddListViewItemEventListener(*this);
200 __pListview->SetItemProvider(*this);
201 __pListview->UpdateList();
204 __pPopUp = new(std::nothrow) SharePopup();
206 if (__pPopUp != null)
208 __pPopUp->Initialize();
209 // AddControl(__pPopUp);
212 __pSearchListView = new(std::nothrow) ListView();
214 if (__pSearchListView == null)
219 r = __pSearchListView->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height -72), true, false);
220 TryCatch( !IsFailed(r),,"BookmarkListForm::OnSearchBarModeChanged Update list failed %s",GetErrorMessage(r));
222 __pSearchListView->SetBackgroundColor(GetBackgroundColor());
223 __pSearchListView->SetItemProvider(*this);
224 __pSearchListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RESULTS_FOUND"));
225 __pSearchListView->SetTextColorOfEmptyList(Color::GetColor(COLOR_ID_BLACK));
226 __pSearchListView->SetShowState(false);
227 __pSearchListView->AddListViewItemEventListener(*this);
229 __pSearchBar->AddSearchBarEventListener(*this);
230 __pSearchBar->AddKeypadEventListener(*this);
231 __pSearchBar->SetContent(__pSearchListView);
233 BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID, bookmarkCount);
234 if(bookmarkCount <= 0)
236 __pSearchBar->SetShowState(false);
237 //__pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pSearchBar->GetWidth(),GetClientAreaBounds().height - __pSearchBar->GetPosition().y);
238 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pListview->GetWidth(),GetClientAreaBounds().height);
242 __pSearchBar->SetShowState(true);
248 pHeader->SetStyle(HEADER_STYLE_TAB);
249 bookmark.Construct(IDA_TABBAR_ITEM_1);
251 pAppResource->GetString(L"IDS_BR_TAB_BOOKMARKS", strbookmark);
252 bookmark.SetText(strbookmark);
253 pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_BOOKMARK);
254 bookmark.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);
255 bookmark.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
256 pHeader->AddItem(bookmark);
258 if (pIconBitmap != NULL)
263 history.Construct(IDA_TABBAR_ITEM_2);
265 pAppResource->GetString(L"IDS_BR_TAB_HISTORY", strhistory);
266 history.SetText(strhistory);
267 pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_HISTORY);
268 history.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);
269 history.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
270 pHeader->AddItem(history);
271 pHeader->SetItemSelected(0);
272 pHeader->SetTabEditModeEnabled(false);
274 if (pIconBitmap != NULL)
285 BookmarkListForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
287 AppLogDebug("BookmarkListForm::OnActionPerformed actionId = %d",actionId);
290 BookmarkData* pBookMark = null;
294 case IDA_FOOTER_ITEM1:
296 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
297 // GetHeader()->SetItemSelected(0);
298 // GetHeader()->Invalidate(true);
299 SceneManager* pSceneManager = SceneManager::GetInstance();
300 pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(__selectedindex));
302 if ( pBookMark == NULL )
307 ArrayList* pArgList = null;
308 pArgList = new(std::nothrow) ArrayList();
309 if (pArgList != null)
311 pArgList->Construct();
312 pArgList->Add(*new(std::nothrow) String(pBookMark->GetParentId()));
314 //pArgList->Add(*new(std::nothrow) String(pBookmark->);
315 if (pSceneManager != null)
317 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_EDIT_BOOKMARK_LIST),pArgList) != E_SUCCESS)
319 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
320 pArgList->RemoveAll(true);
327 if ( pArgList != NULL)
329 pArgList->RemoveAll(true);
335 case IDA_TABBAR_ITEM_2:
337 // GetHeader()->SetItemSelected(0);
338 // GetHeader()->Invalidate(true);
340 SceneManager* pSceneManager = SceneManager::GetInstance();
342 if (pSceneManager != null)
344 if(__previousSceneId.CompareTo(IDSCN_HISTORY_LIST) != 0)
346 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT)) != E_SUCCESS)
348 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
355 if(pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT))!= E_SUCCESS)
357 AppLogDebug("BookmarkListForm::OnActionPerformed GoBackward failed");
365 case IDA_FOOTER_ITEM2:
367 SceneManager* pSceneManager = SceneManager::GetInstance();
371 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_BOOKMARK_FOLDER)) != E_SUCCESS)
373 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
379 case IDA_FOOTER_ITEM_ADDBOOKMARK:
381 SceneManager* pSceneManager = SceneManager::GetInstance();
383 // send array list 0-for add, 1 for edit with parent ID
384 ArrayList* pArgList = null;
385 pArgList = new(std::nothrow) ArrayList();
386 if (pArgList != null)
388 pArgList->Construct();
389 pArgList->Add(*new(std::nothrow) String(L"0"));
390 pArgList->Add(*new(std::nothrow) String(__parentID));
395 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ADD_BOOKMARK),pArgList) != E_SUCCESS)
397 AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
398 pArgList->RemoveAll(true);
404 if (pArgList != null)
406 pArgList->RemoveAll(true);
413 __pConfirmationPopup->SetShowState(false);
414 __pConfirmationPopup->Show();
417 pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(__selectedindex));
418 if ( pBookMark== null)
420 bookmarkId=pBookMark->GetBookmarkId();
421 Integer::Parse(bookmarkId,id);
422 if (pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
423 BookmarkPresentationModel::GetInstance()->DeleteFolder(id);
425 BookmarkPresentationModel::GetInstance()->DeleteBookmark(id);
426 if (__pListview == null)
430 AppLogDebug("__pListview GetBounds %d,%d,%d,%d",__pListview->GetBounds().x,__pListview->GetBounds().y,__pListview->GetBounds().width,__pListview->GetBounds().height);
431 __pSearchListView->UpdateList();
432 __pListview->UpdateList();
434 if (__pListview->GetItemCount() == 0)
436 GetFooter()->SetItemEnabled(1,false);
437 __pSearchBar->SetShowState(false);
438 __pSearchBar->Invalidate(true);
441 if (__noBookmarks == true)
443 Bitmap* emptyListBmp = AppResource::GetInstance()->GetBitmapN(IDB_NO_CONTENT_BOOKMARK);
444 GetFooter()->SetItemEnabled(1,false);
445 __pSearchBar->SetShowState(false);
446 __pSearchBar->Invalidate(true);
447 // __pListview->SetBounds(__pSearchBar->GetPosition().x,__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
448 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
449 __pListview->SetBitmapOfEmptyList(emptyListBmp);
455 __pListview->UpdateList();
460 GetFooter()->SetItemEnabled(1,true);
462 if (__parentID.CompareTo(L"0") == 0)
464 __pSearchBar->SetShowState(true);
465 __pSearchBar->Invalidate(true);
469 GetFooter()->Invalidate(true);
470 __pConfirmationPopup->SetShowState(false);
471 __pConfirmationPopup->Show();
481 BookmarkListForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
483 AppLogDebug("BrowserApplicationForm::OnFormBackRequested");
485 UiApp* pApp = UiApp::GetInstance();
491 if (__parentID != DEFAULT_VALUE_PARENTID)
493 __parentID = DEFAULT_VALUE_PARENTID;
494 __pSearchBar->SetShowState(true);
495 __pListview->SetBounds(__pListview->GetX() ,__pSearchBar->GetPosition().y + __pSearchBar->GetHeight(),__pListview->GetWidth(),GetClientAreaBounds().height - (__pSearchBar->GetY() + __pSearchBar->GetHeight()));
496 __pListview->UpdateList();
497 __pFooter = GetFooter();
498 GetFooter()->SetItemEnabled(2,true);
499 GetFooter()->Invalidate(true);
503 SceneManager* pSceneManager = SceneManager::GetInstance();
504 if (pSceneManager != null)
506 if(__previousSceneId.CompareTo(IDSCN_HISTORY_LIST) != 0)
508 pSceneManager->GoBackward(BackwardSceneTransition());
512 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
517 if (__noBookmarks == true)
519 GetFooter()->SetItemEnabled(1,false);
523 GetFooter()->SetItemEnabled(1,true);
527 Tizen::Ui::Controls::ListItemBase*
528 BookmarkListForm::CreateItem(int index, int itemWidth)
531 AppLog("BookmarkListForm::CreateItem index %d , itemWidth %d",index, itemWidth);
532 AppLog("listviewwidth %d",__pListview->GetWidth());
533 result r = E_FAILURE;
534 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
539 CustomItem* pItem = new(std::nothrow) CustomItem();
541 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
542 Bitmap* pBitmap = null;
545 Image* pImage = null;
546 pImage = new Image();
549 const int x_Margin_Icon = 16; // local as there used only in this function
550 const int y_Margin_Icon = 28;
551 const int height_Icon = 72;
552 const int width_Icon = 72 ;
553 const int x_Margin_Title = 104 ;
554 const int y_Margin_Title = 10;
555 const int width_Title = GetClientAreaBounds().width - 108 - 52 - 40;
556 const int x_Margin_Url = 104 ;
557 const int y_Margin_Url = 70 ;
558 const int width_Url = GetClientAreaBounds().width - 108 - 52 ;
559 const int height_Url = 48;
560 const int itemHeight = 128;
561 const int textSize = 32;
564 if( pBookMark == NULL )
572 if ( pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER )
574 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth,112 - 44 + __fontSize), LIST_ANNEX_STYLE_DETAILED);
575 TryCatch(!IsFailed(r),,"BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
577 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_FOLDER_OPEN);
580 pItem->AddElement(Rectangle(x_Margin_Icon, 20+(__fontSize - 44)/2, width_Icon, height_Icon), IDA_FORMAT_ICON, *pBitmap, null);
584 pItem->AddElement(Rectangle(x_Margin_Title, 26, width_Title, 72 + (__fontSize - 44) ), IDA_FORMAT_FOLDER, pBookMark->GetBookmarkTitle(),__fontSize, CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,true);
586 if ( __pItemContextFolder != NULL)
588 pItem->SetContextItem(__pItemContextFolder);
593 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth, itemHeight - 44 + __fontSize), style);
594 TryCatch( !IsFailed(r),,"BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
596 AppLogDebug("BookmarkListForm::faviconid %ls",pBookMark->GetFaviconId().GetPointer());
597 bitmapId = pBookMark->GetFaviconId();
599 dim = Dimension(pBookMark->GetFavIconWidth(), pBookMark->GetFavIconHeight());
601 AppLog("BookmarkListForm::CreateItem check 0");
603 // get fav icon bitmap
604 ByteBuffer* pFavIconBuffer = null;
605 pFavIconBuffer = pBookMark->GetFavIconBuffer();
607 AppLog("BookmarkListForm::CreateItem check 0");
609 if (pFavIconBuffer != null)
611 AppLog("BookmarkListForm::CreateItem pFavIconBuffer is not null");
615 AppLog("BookmarkListForm::CreateItem pFavIconBuffer is null");
618 pBitmap = pImage->DecodeN(*pFavIconBuffer, IMG_FORMAT_PNG, BITMAP_PIXEL_FORMAT_ARGB8888);
620 AppLog("BookmarkListForm::CreateItem check 1");
624 AppLog("rahul bitmap is not null");
625 int width = pBitmap->GetWidth();
626 int height = pBitmap->GetHeight();
627 AppLog("rahul bitmap width is %d", width);
628 AppLog("rahul bitmap height is %d", height);
629 AppLog("rahul favicon width is %d", pBookMark->GetFavIconWidth());
630 AppLog("rahul favicon height is %d", pBookMark->GetFavIconHeight());
634 AppLog("rahul bitmap is null");
639 AppLogDebug("BookmarkListForm::CreateItem bitmap is null");
640 pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
642 pItem->AddElement(Rectangle(x_Margin_Icon, y_Margin_Icon +(__fontSize - 44)/2, width_Icon, height_Icon), IDA_FORMAT_ICON, *pBitmap, null);
643 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);
644 // if(__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
645 // 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);
647 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_LISTVIEW_TEXT,CUSTOM_COLOR_LISTVIEW_TEXT,true);
653 if ( __pItemContextSite != NULL)
655 pItem->SetContextItem(__pItemContextSite);
672 BookmarkListForm::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
680 BookmarkListForm::GetItemCount(void)
684 if (__pData != NULL )
686 __pData->RemoveAll(true);
690 __pData = new(std::nothrow) Collection::ArrayList();
691 __pData->Construct();
693 if (__searchBookmark == false)
695 BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID, count);
696 BookmarkPresentationModel::GetInstance()->GetFoldersBookmarks(__parentID, 0, count, *__pData);
700 if (__searchText.GetLength() > 0)
702 __searchText.Replace(L"%", L"/%");
703 __searchText.Replace(L"_", L"/_");
705 BookmarkPresentationModel::GetInstance()->GetSearchFolderBookmarkCount(count,__searchText);
706 BookmarkPresentationModel::GetInstance()->GetSearchFoldersBookmarks(0, count, *__pData, __searchText);
709 AppLogDebug("Count = %d parentId = %ls __searchText %ls", count, __parentID.GetPointer() , __searchText.GetPointer());
713 __noBookmarks = true;
714 GetFooter()->SetItemEnabled(1,false);
718 __noBookmarks = false;
719 GetFooter()->SetItemEnabled(1,true);
722 AppLogDebug("Result: %s", GetErrorMessage(GetLastResult()));
723 GetFooter()->Invalidate(true);
724 if (__pData != null && __pData->GetCount() >= 1)
726 // __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
727 __pSearchBar->SetShowState(true);
728 __pSearchBar->Invalidate(true);
730 else if (__searchBookmark == false)
732 __pSearchBar->SetShowState(false);
733 __pSearchBar->Invalidate(true);
736 if (__parentID.CompareTo(L"0") != 0)
738 __pSearchBar->SetShowState(false);
739 __pSearchBar->Invalidate(true);
741 if (__noBookmarks == true)
743 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetPosition().y,__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
744 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_NO_CONTENT_BOOKMARK);
746 if ( pBitmap != NULL)
748 __pListview->SetBitmapOfEmptyList(pBitmap);
754 if (__parentID.CompareTo(L"0") == 0)
756 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetHeight(),GetClientAreaBounds().width ,GetClientAreaBounds().height - __pSearchBar->GetY() - __pSearchBar->GetHeight());
760 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pSearchBar->GetWidth() ,GetClientAreaBounds().height);
765 __pListview->Invalidate(true);
771 BookmarkListForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
773 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged int index %d, int elementId %d, Tizen::Ui::Controls::ListContextItemStatus status %d",index,elementId,status);
775 String deleteText = CommonUtil::GetString(L"IDS_BR_SK3_DELETE");
777 result r = E_SUCCESS;
781 case IDA_CONTEXT_ITEM_FOLDER_EDIT:
783 ArrayList* pArgList = null;
784 String* pEdit = null;
786 SceneManager* pSceneManager = SceneManager::GetInstance();
787 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
788 if (pBookMark != null && pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
790 pArgList = new(std::nothrow) ArrayList();
791 if (pArgList != null)
793 pEdit= new(std::nothrow) String(CommonUtil::GetString(L"IDS_BR_SK_EDIT"));
794 pArgList->Construct();
795 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
796 pArgList->Add(*pEdit);
797 if ( pSceneManager != null)
800 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_BOOKMARK_FOLDER), pArgList);
803 if (pArgList != null)
810 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged GoForward failed %s",GetErrorMessage(r));
819 case IDA_CONTEXT_ITEM_FOLDER_DELETE:
820 case IDA_CONTEXT_ITEM_DELETE:
822 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
823 __pConfirmationPopup->Initialize();
824 __pConfirmationPopup->RemoveActionListener(*this);
825 __pConfirmationPopup->AddActionListener(*this);
826 __pConfirmationPopup->setMessage(deleteText);
827 __pConfirmationPopup->Show();
828 __selectedindex = index;
832 case IDA_CONTEXT_ITEM_EDIT:
834 ArrayList* pArgList = null;
835 SceneManager* pSceneManager = SceneManager::GetInstance();
836 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
837 if (pBookMark!= null && pBookMark->GetBookmarkType() == BOOKMARK_TYPE_URL)
839 AppLogDebug("ID_CONTEXT_ITEM_SITE_1 BOOKMARK_TYPE_URL");
840 pArgList = new(std::nothrow) ArrayList();
841 if (pArgList != null)
843 pArgList->Construct();
844 pArgList->Add(*new(std::nothrow) String(L"1"));
845 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
846 if ( pSceneManager != null)
849 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ADD_BOOKMARK), pArgList);
850 if (pArgList != null)
857 AppLogDebug("BookmarkListForm::OnListViewContextItemStateChanged GoForward failed %s",GetErrorMessage(r));
865 case IDA_CONTEXT_ITEM_SHARE:
867 AppLogDebug("OnListViewContextItemStateChanged Share");
868 if (__pPopUp != null)
873 __pPopUp = new(std::nothrow) SharePopup();
874 __pPopUp->Initialize();
875 BookmarkData* pBookmark = dynamic_cast<BookmarkData*>(__pData->GetAt(index));
876 if (pBookmark != null)
878 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
879 pShareInfo->SetPageTitle(pBookmark->GetBookmarkTitle());
880 pShareInfo->SetPageUrl(pBookmark->GetUrl());
881 pShareInfo->SetImageAttached(false);
882 __pPopUp->RemoveAllShareInfo();
883 __pPopUp->AddShareInfo(pShareInfo);
886 __pPopUp->SetShowState(true);
898 BookmarkListForm::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
904 BookmarkListForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
906 AppLogDebug("BookmarkListForm::OnListViewItemStateChanged");
908 result r = E_FAILURE;
909 ArrayList *pArgList = null;
910 SceneManager* pSceneManager = SceneManager::GetInstance();
911 BookmarkData* pBookmark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
913 if ( pBookmark == NULL )
918 switch (pBookmark->GetBookmarkType())
920 case BOOKMARK_TYPE_FOLDER:
922 __parentID = pBookmark->GetBookmarkId();
923 AppLogDebug("BOOKMARK_TYPE_FOLDER parent ID is %ls",__parentID.GetPointer());
925 listView.UpdateList();
926 if (listView.GetItemCount() == 0)
928 GetFooter()->SetItemEnabled(1,false);
932 GetFooter()->SetItemEnabled(1,true);
934 GetFooter()->SetItemEnabled(2,false);
935 GetFooter()->Invalidate(true);
936 __pSearchBar->HideKeypad();
937 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
938 __pSearchBar->SetShowState(false);
939 __pSearchBar->Invalidate(true);
940 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetY(),__pListview->GetWidth() ,GetClientAreaBounds().height);
943 case BOOKMARK_TYPE_URL:
945 pArgList = new(std::nothrow) ArrayList();
946 if (pArgList != null)
948 r = pArgList->Construct();
949 TryCatch(!IsFailed(r), L"BookmarkListForm::OnListViewItemStateChanged pArgList Construct failed %s", GetErrorMessage(r));
951 AppLogDebug("bookmark url = %ls",pBookmark->GetUrl().GetPointer());
952 r = pArgList->Add(*MultipleWindowPresentationModel::GetInstance()->GetActiveWindowInfo());
953 pArgList->Add(*new(std::nothrow) String(pBookmark->GetUrl()));
955 if (pSceneManager != null)
957 AppLogDebug("pSceneManager exists");
959 MultipleWindowPresentationModel::GetInstance()->GetCurrentSceneId(prevSceneId);
960 r = pSceneManager->GoBackward(BackwardSceneTransition(prevSceneId), pArgList);
961 TryCatch(!IsFailed(r), L"BookmarkListForm::OnListViewItemStateChanged pArgList Construct failed %s", GetErrorMessage(r));
975 pArgList->RemoveAll(true);
982 BookmarkListForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
989 BookmarkListForm::OnFastScrollIndexSelected(Tizen::Ui::Control& source, Tizen::Base::String& index)
995 BookmarkListForm::OnFocusGained(const Tizen::Ui::Control& source)
997 __pSearchListView->SetEnabled(false);
1001 BookmarkListForm::OnFocusLost(const Tizen::Ui::Control& source)
1003 __pSearchListView->SetEnabled(true);
1004 __searchBookmark = false;
1008 BookmarkListForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
1010 result r = E_FAILURE;
1011 AppLog("ABCD::BookmarkListForm::OnSearchBarModeChanged %d",GetClientAreaBounds().height);
1014 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1015 __pSearchListView->Invalidate(false);
1017 if (mode == SEARCH_BAR_MODE_NORMAL)
1019 __pSearchListView->SetShowState(false);
1020 __pSearchListView->UpdateList();
1021 __pListview->SetShowState(true);
1023 __searchBookmark = false;
1024 r = __pListview->UpdateList();
1025 // __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1027 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1028 TryCatch( !IsFailed(r),,"BookmarkListForm::OnSearchBarModeChanged Update list failed %s",GetErrorMessage(r));
1033 __pSearchListView->SetShowState(true);
1034 __pSearchListView->SetEnabled(false);
1035 __pListview->SetShowState(false);
1039 AppLog("heightarea %d",GetClientAreaBounds().height - __pSearchBar->GetHeight());
1040 r = __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1041 __pSearchBar->SetText(L"");
1043 __pListview->UpdateList();
1044 __pSearchListView->UpdateList();
1049 BookmarkListForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
1051 AppLog("ABCD::BookmarkListForm::OnKeypadWillOpen");
1052 // GetFooter()->SetShowState(false);
1053 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight());
1054 __pSearchListView->SetEnabled(false);
1055 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1060 BookmarkListForm::OnKeypadOpened(Tizen::Ui::Control& source)
1062 AppLog("ABCD::BookmarkListForm::OnKeypadOpened");
1063 GetFooter()->SetShowState(false);
1064 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1065 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1070 BookmarkListForm::OnKeypadClosed(Tizen::Ui::Control& source)
1072 AppLog("ABCD::BookmarkListForm::OnKeypadClosed");
1073 AppLog("jahsjkdad %d",Clipboard::GetInstance()->IsPopupVisible());
1074 // if(Clipboard::GetInstance()->IsPopupVisible() == true)
1078 GetFooter()->SetShowState(true);
1079 __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1080 __pSearchListView->Invalidate(false);
1081 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1082 __pListview->SetBounds(0, __pSearchBar->GetY() + __pSearchBar->GetHeight(), GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight());
1087 BookmarkListForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
1089 AppLog("BookmarkListForm::OnKeypadActionPerformed %d",keypadAction);
1091 if (__pSearchBar != null)
1093 __pSearchBar->HideKeypad();
1095 if ( __pSearchBar != null && keypadAction == KEYPAD_ACTION_SEARCH)
1097 // if (__pSearchBar->GetText().GetLength() == 0)
1102 if (__pSearchBar != null)
1104 __pSearchBar->HideKeypad();
1107 __searchText = __pSearchBar->GetText();
1108 AppLog("SearchbarGettext result %s %ls",GetErrorMessage(GetLastResult()),__searchText.GetPointer());
1109 __searchBookmark = true;
1110 __pListview->SetShowState(false);
1111 __pSearchListView->SetEnabled(true);
1112 __pSearchListView->SetShowState(true);
1113 __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1114 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1115 __pSearchListView->UpdateList();
1122 BookmarkListForm::OnKeypadBoundsChanged(Tizen::Ui::Control& source)
1124 AppLog("ABCD::BookmarkListForm::OnKeypadBoundsChanged");
1125 FloatRectangle clientRect;
1126 clientRect = GetClientAreaBoundsF();
1127 AppLogDebug("ABCD::SearchBarForm::OnKeypadBoundsChanged ClientBounds(%f, %f, %f, %f)",clientRect.x, clientRect.y, clientRect.width, clientRect.height);
1128 __pSearchBar->SetContentAreaSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1129 __pSearchListView->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1130 __pListview->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1131 // __pListview->SetEnabled(false);
1136 BookmarkListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
1138 AppLogDebug("BookmarkListForm::OnSceneActivatedN called");
1139 ArrayListT<String> * pList = dynamic_cast<ArrayListT<String>* >(SceneManager::GetInstance()->GetSceneHistoryN());
1142 pList->GetAt(pList->GetCount()-1,__previousSceneId);
1145 __searchBookmark = false;
1146 GetFooter()->SetShowState(true);
1147 GetFooter()->Invalidate(true);
1148 GetHeader()->SetItemSelected(0);
1149 GetHeader()->Invalidate(true);
1151 /* if (previousSceneId != IDSCN_HISTORY_LIST && previousSceneId != IDSCN_CREATE_BOOKMARK_FOLDER && previousSceneId != IDSCN_EDIT_BOOKMARK_LIST)
1153 __previousSceneId = previousSceneId;
1162 if (__pListview != null)
1164 __pListview->UpdateList();
1171 BookmarkListForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
1173 AppLog("BookmarkListForm::OnOrientationChanged start");
1176 __pListview->SetBackgroundColor(GetBackgroundColor());
1178 if (__pSearchListView)
1180 __pSearchListView->SetBackgroundColor(GetBackgroundColor());
1184 if(__pSearchBar->GetShowState())
1186 __pListview->SetBounds(__pListview->GetX(),__pSearchBar->GetHeight(),GetClientAreaBounds().width ,GetClientAreaBounds().height - __pSearchBar->GetY() - __pSearchBar->GetHeight());
1190 __pListview->SetBounds(__pListview->GetX(),0,GetClientAreaBounds().width ,GetClientAreaBounds().height);
1195 if (__pSearchListView && __pListview)
1197 AppLog("__pListview->GetBounds() %d, %d, %d, %d",__pListview->GetBounds().x,__pListview->GetBounds().y,__pListview->GetBounds().width,__pListview->GetBounds().height);
1198 __pSearchListView->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height -__pSearchBar->GetHeight());
1200 __pSearchListView->UpdateList();
1203 if (__pSearchListView && __pData != null )
1205 if (__parentID != DEFAULT_VALUE_PARENTID)
1207 AppLog("BookmarkListForm::OnOrientationChanged parent id true");
1208 __pSearchBar->SetShowState(false);
1209 __pSearchBar->Invalidate(true);
1212 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1218 // FloatRectangle clientRect;
1219 // clientRect = GetClientAreaBoundsF();
1221 // __pSearchBar->SetContentAreaSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1222 // __pListview->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1223 // __pSearchListView->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
1224 // Invalidate(true);
1231 BookmarkListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
1233 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
1238 BookmarkListForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
1240 AppLog("receiving userevent for appcontrol %d",requestId);
1241 if (requestId == APPCONTROL_LAUNCH_MAX_LIMIT_REACHED)
1243 AppLog("receiving userevent for appcontrol %d ",requestId);
1244 if(__pConfirmationPopup)
1246 __pConfirmationPopup->SetShowState(false);
1247 delete __pConfirmationPopup;
1248 __pConfirmationPopup = null;