From 2160e14cfba3c8c4c4a6ad19469b35a9e41d56a2 Mon Sep 17 00:00:00 2001 From: Marcin Lapinski Date: Fri, 21 Aug 2015 15:33:02 +0200 Subject: [PATCH 01/16] Refactoring MainUI [Issue#] https://bugs.tizen.org/jira/browse/TT-72 [Problem] MainUI needs refactoring. [Cause] N/A [Sollution] Following actions were taken: -Split humongous show functions into several smaller. -Removed unused functions. -Logically split most visited and bookmark view. -Replace redundant class members with local variables. -Renamed functions and variables to make names more adequate. [Verify] 1. Browser builds 2. Refactor does not change behaviour of browser. Change-Id: I44a5c958ad4e7b0c694434a4cfdb45702c871ec7 --- services/MainUI/MainUI.cpp | 395 +++++++++++++++++++++++------------------ services/MainUI/MainUI.h | 29 +-- services/MainUI/edc/MainUI.edc | 10 +- services/SimpleUI/SimpleUI.cpp | 17 +- 4 files changed, 256 insertions(+), 195 deletions(-) diff --git a/services/MainUI/MainUI.cpp b/services/MainUI/MainUI.cpp index a7ab4a7..6d86e66 100644 --- a/services/MainUI/MainUI.cpp +++ b/services/MainUI/MainUI.cpp @@ -59,178 +59,240 @@ struct ItemData{ MainUI::MainUI() : m_parent(nullptr) , m_layout(nullptr) - , m_layoutTop(nullptr) - , m_gengrid(nullptr) + , m_bookmarksButton(nullptr) + , m_mostVisitedButton(nullptr) + , m_bookmarksView(nullptr) + , m_mostVisitedView(nullptr) + , m_bookmarkGengrid(nullptr) , m_genListLeft(nullptr) , m_genListCenter(nullptr) , m_genListRight(nullptr) - , m_layoutBottom(nullptr) , m_big_item_class(nullptr) , m_small_item_class(nullptr) , m_bookmark_item_class(nullptr) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); edjFilePath = EDJE_DIR; edjFilePath.append("MainUI/MainUI.edj"); + elm_theme_extension_add(nullptr, edjFilePath.c_str()); + MainUI::createItemClasses(); } MainUI::~MainUI() { + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + elm_genlist_item_class_free(m_big_item_class); + elm_genlist_item_class_free(m_small_item_class); + elm_gengrid_item_class_free(m_bookmark_item_class); +} + +void MainUI::createItemClasses() +{ + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + if (!m_big_item_class) { + m_big_item_class = elm_genlist_item_class_new(); + m_big_item_class->item_style = "big_grid_item"; + m_big_item_class->func.text_get = _grid_text_get; + m_big_item_class->func.content_get = _grid_content_get; + m_big_item_class->func.state_get = nullptr; + m_big_item_class->func.del = nullptr; + } + + if (!m_small_item_class) { + m_small_item_class = elm_genlist_item_class_new(); + m_small_item_class->item_style = "small_grid_item"; + m_small_item_class->func.text_get = _grid_text_get; + m_small_item_class->func.content_get = _grid_content_get; + m_small_item_class->func.state_get = nullptr; + m_small_item_class->func.del = nullptr; + } + + if (!m_bookmark_item_class) { + m_bookmark_item_class = elm_gengrid_item_class_new(); + m_bookmark_item_class->item_style = "grid_item"; + m_bookmark_item_class->func.text_get = _grid_bookmark_text_get; + m_bookmark_item_class->func.content_get = _grid_bookmark_content_get; + m_bookmark_item_class->func.state_get = nullptr; + m_bookmark_item_class->func.del = nullptr; + } } void MainUI::show(Evas_Object* parent) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_theme_extension_add(nullptr, edjFilePath.c_str()); - m_layout = elm_layout_add(parent); - elm_layout_file_set(m_layout, edjFilePath.c_str(), "mv_bookmarks"); - evas_object_size_hint_weight_set(m_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + //FIXME: this may be source of memory leak this object is not deleted anywhere + m_layout = createQuickAccessLayout(parent); evas_object_show(m_layout); - m_parent = m_layout; - - m_genListLeft = elm_genlist_add(m_layout); - elm_object_part_content_set(m_layout, "elm.swallow.left", m_genListLeft); - elm_genlist_homogeneous_set(m_genListLeft, EINA_FALSE); - elm_genlist_multi_select_set(m_genListLeft, EINA_FALSE); - elm_genlist_select_mode_set(m_genListLeft, ELM_OBJECT_SELECT_MODE_ALWAYS); - elm_genlist_mode_set(m_genListLeft, ELM_LIST_LIMIT); - evas_object_size_hint_weight_set(m_genListLeft, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - - m_genListCenter = elm_genlist_add(m_layout); - elm_object_part_content_set(m_layout, "elm.swallow.center", m_genListCenter); - elm_genlist_homogeneous_set(m_genListCenter, EINA_FALSE); - elm_genlist_multi_select_set(m_genListCenter, EINA_FALSE); - elm_genlist_select_mode_set(m_genListCenter, ELM_OBJECT_SELECT_MODE_ALWAYS); - elm_genlist_mode_set(m_genListCenter, ELM_LIST_LIMIT); - evas_object_size_hint_weight_set(m_genListCenter, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - - m_genListRight = elm_genlist_add(m_layout); - elm_object_part_content_set(m_layout, "elm.swallow.right", m_genListRight); - elm_genlist_homogeneous_set(m_genListRight, EINA_FALSE); - elm_genlist_multi_select_set(m_genListRight, EINA_FALSE); - elm_genlist_select_mode_set(m_genListRight, ELM_OBJECT_SELECT_MODE_ALWAYS); - elm_genlist_mode_set(m_genListRight, ELM_LIST_LIMIT); - evas_object_size_hint_weight_set(m_genListRight, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - - if (!m_big_item_class) { - m_big_item_class = elm_genlist_item_class_new(); - m_big_item_class->item_style = "big_grid_item"; - m_big_item_class->func.text_get = _grid_text_get; - m_big_item_class->func.content_get = _grid_content_get; - m_big_item_class->func.state_get = nullptr; - m_big_item_class->func.del = nullptr; - } - if (!m_small_item_class) { - m_small_item_class = elm_genlist_item_class_new(); - m_small_item_class->item_style = "small_grid_item"; - m_small_item_class->func.text_get = _grid_text_get; - m_small_item_class->func.content_get = _grid_content_get; - m_small_item_class->func.state_get = nullptr; - m_small_item_class->func.del = nullptr; - } + m_parent = parent; +} - /*evas_object_smart_callback_add(m_genList, "item,focused", focusItem, this); - evas_object_smart_callback_add(m_genList, "item,unfocused", unFocusItem, nullptr);*/ +Evas_Object* MainUI::createQuickAccessLayout(Evas_Object* parent) +{ + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + Evas_Object* layout = elm_layout_add(parent); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set (layout, EVAS_HINT_FILL, EVAS_HINT_FILL); - m_gengrid = elm_gengrid_add(m_layout); - //elm_object_part_content_set(m_layout, "elm.swallow.grid", m_gengrid); + m_mostVisitedView = createMostVisitedView(layout); + m_bookmarksView = createBookmarksView (layout); - evas_object_smart_callback_add(m_gengrid, "item,focused", focusItem, nullptr); - evas_object_smart_callback_add(m_gengrid, "item,unfocused", unFocusItem, nullptr); - evas_object_smart_callback_add(m_gengrid, "activated", _itemSelected, this); + evas_object_show(m_mostVisitedView); + //TODO: uncoment this after cleaning up the mess in whole app window. + //evas_object_show(m_bookmarksView); + showHistory(); - if (!m_bookmark_item_class) { - m_bookmark_item_class = elm_gengrid_item_class_new(); - m_bookmark_item_class->item_style = "grid_item"; - m_bookmark_item_class->func.text_get = _grid_bookmark_text_get; - m_bookmark_item_class->func.content_get = _grid_bookmark_content_get; - m_bookmark_item_class->func.state_get = nullptr; - m_bookmark_item_class->func.del = nullptr; - } + return layout; +} - M_ASSERT(m_parent); - elm_theme_extension_add(nullptr, edjFilePath.c_str()); - elm_gengrid_align_set(m_gengrid, 0, 0); - elm_gengrid_select_mode_set(m_gengrid, ELM_OBJECT_SELECT_MODE_ALWAYS); - elm_gengrid_multi_select_set(m_gengrid, EINA_FALSE); - elm_gengrid_horizontal_set(m_gengrid, EINA_FALSE); - //elm_gengrid_highlight_mode_set(m_gengrid, EINA_TRUE); - elm_scroller_policy_set(m_gengrid, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); - elm_scroller_page_size_set(m_gengrid, 0, 327); - evas_object_size_hint_weight_set(m_gengrid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_gengrid, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_gengrid_item_size_set(m_gengrid, 364 * efl_scale, 320 * efl_scale); +Evas_Object* MainUI::createMostVisitedView (Evas_Object * parent) +{ + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + + Evas_Object* mostVisitedLayout = elm_layout_add(parent); + elm_layout_file_set(mostVisitedLayout, edjFilePath.c_str(), "mv_bookmarks"); + evas_object_size_hint_weight_set(mostVisitedLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set (mostVisitedLayout, EVAS_HINT_FILL, EVAS_HINT_FILL); + + Evas_Object* genListLeft = elm_genlist_add(mostVisitedLayout); + + elm_genlist_homogeneous_set(genListLeft, EINA_FALSE); + elm_genlist_multi_select_set(genListLeft, EINA_FALSE); + elm_genlist_select_mode_set(genListLeft, ELM_OBJECT_SELECT_MODE_ALWAYS); + elm_genlist_mode_set(genListLeft, ELM_LIST_LIMIT); + evas_object_size_hint_weight_set(genListLeft, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + elm_object_part_content_set(mostVisitedLayout, "elm.swallow.left", genListLeft); + m_genListLeft = genListLeft; + + Evas_Object* genListCenter = elm_genlist_add(mostVisitedLayout); + elm_genlist_homogeneous_set(genListCenter, EINA_FALSE); + elm_genlist_multi_select_set(genListCenter, EINA_FALSE); + elm_genlist_select_mode_set(genListCenter, ELM_OBJECT_SELECT_MODE_ALWAYS); + elm_genlist_mode_set(genListCenter, ELM_LIST_LIMIT); + evas_object_size_hint_weight_set(genListCenter, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + elm_object_part_content_set(mostVisitedLayout, "elm.swallow.center", genListCenter); + m_genListCenter = genListCenter; + + Evas_Object* genListRight = elm_genlist_add(mostVisitedLayout); + elm_genlist_homogeneous_set(genListRight, EINA_FALSE); + elm_genlist_multi_select_set(genListRight, EINA_FALSE); + elm_genlist_select_mode_set(genListRight, ELM_OBJECT_SELECT_MODE_ALWAYS); + elm_genlist_mode_set(genListRight, ELM_LIST_LIMIT); + evas_object_size_hint_weight_set(genListRight, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + elm_object_part_content_set(mostVisitedLayout, "elm.swallow.right", genListRight); + m_genListRight=genListRight; - showTopButtons(); - showBottomButton(); + Evas_Object* topButtons = createTopButtons(mostVisitedLayout); + elm_object_part_content_set(mostVisitedLayout, "elm.swallow.layoutTop", topButtons); + + return mostVisitedLayout; } +Evas_Object* MainUI::createBookmarksView (Evas_Object * parent) +{ + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + + Evas_Object *bookmarkViewLayout = elm_layout_add(parent); + elm_layout_file_set(bookmarkViewLayout, edjFilePath.c_str(), "mv_bookmarks"); + evas_object_size_hint_weight_set(bookmarkViewLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bookmarkViewLayout, EVAS_HINT_FILL, EVAS_HINT_FILL); + + Evas_Object *bookmarkGengrid = elm_gengrid_add(bookmarkViewLayout); + + elm_gengrid_align_set(bookmarkGengrid, 0, 0); + elm_gengrid_select_mode_set(bookmarkGengrid, ELM_OBJECT_SELECT_MODE_ALWAYS); + elm_gengrid_multi_select_set(bookmarkGengrid, EINA_FALSE); + elm_gengrid_horizontal_set(bookmarkGengrid, EINA_FALSE); + + elm_scroller_policy_set(bookmarkGengrid, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); + elm_scroller_page_size_set(bookmarkGengrid, 0, 327); + evas_object_size_hint_weight_set(bookmarkGengrid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bookmarkGengrid, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_gengrid_item_size_set(bookmarkGengrid, 364 * efl_scale, 320 * efl_scale); + evas_object_show(bookmarkGengrid); + + elm_object_part_content_set(bookmarkViewLayout, "elm.swallow.grid", bookmarkGengrid); + m_bookmarkGengrid = bookmarkGengrid; + + Evas_Object* topButtons = createTopButtons(bookmarkViewLayout); + elm_object_part_content_set(bookmarkViewLayout, "elm.swallow.layoutTop", topButtons); + + Evas_Object* bottomButton = createBottomButton(bookmarkViewLayout); + elm_object_part_content_set(bookmarkViewLayout, "elm.swallow.layoutBottom", bottomButton); -void MainUI::showTopButtons() + return bookmarkViewLayout; +} + +Evas_Object* MainUI::createTopButtons (Evas_Object *parent) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); - m_layoutTop = elm_layout_add(m_layout); + Evas_Object *layoutTop = elm_layout_add(parent); + elm_layout_file_set(layoutTop, edjFilePath.c_str(), "top_button_item"); + evas_object_size_hint_weight_set(layoutTop, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(layoutTop, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(layoutTop); - elm_layout_file_set(m_layoutTop, edjFilePath.c_str(), "top_button_item"); - evas_object_size_hint_weight_set(m_layoutTop, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_layoutTop, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_show(m_layoutTop); + Evas_Object *mostVisitedButton = elm_button_add(layoutTop); + elm_object_style_set(mostVisitedButton, "invisible_button"); + evas_object_smart_callback_add(mostVisitedButton, "clicked", _mostVisited_clicked, this); + evas_object_show(mostVisitedButton); + elm_layout_content_set(layoutTop, "mostvisited_click", mostVisitedButton); - Evas_Object *mvButton = elm_button_add(m_layoutTop); - elm_object_style_set(mvButton, "invisible_button"); - evas_object_smart_callback_add(mvButton, "clicked", _mostVisited_clicked, this); - elm_layout_content_set(m_layoutTop, "mostvisited_click", mvButton); + m_mostVisitedButton = mostVisitedButton; - Evas_Object *bmButton = elm_button_add(m_layoutTop); - elm_object_style_set(bmButton, "invisible_button"); - evas_object_smart_callback_add(bmButton, "clicked", _bookmark_clicked, this); - elm_layout_content_set(m_layoutTop, "bookmark_click", bmButton); + Evas_Object *bookmarksButton = elm_button_add(layoutTop); + elm_object_style_set(bookmarksButton, "invisible_button"); + evas_object_smart_callback_add(bookmarksButton, "clicked", _bookmark_clicked, this); + evas_object_show(bookmarksButton); + elm_layout_content_set(layoutTop, "bookmark_click", bookmarksButton); - elm_object_part_content_set(m_layout, "elm.swallow.genlistTop", m_layoutTop); + m_bookmarksButton = bookmarksButton; + + return layoutTop; } -void MainUI::showBottomButton() +Evas_Object* MainUI::createBottomButton(Evas_Object *parent) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_theme_extension_add(nullptr, edjFilePath.c_str()); + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); - m_layoutBottom = elm_layout_add(m_layout); - evas_object_size_hint_weight_set(m_layoutBottom, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_layoutBottom, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_layout_file_set(m_layoutBottom, edjFilePath.c_str(), "bottom_button_item"); - //elm_object_part_content_set(m_layout, "elm.swallow.layoutBottom", m_layoutBottom); + Evas_Object *layoutBottom = elm_layout_add(parent); + elm_layout_file_set(layoutBottom, edjFilePath.c_str(), "bottom_button_item"); - Evas_Object * bookmark_manager_button = elm_button_add(m_layoutBottom); + evas_object_size_hint_weight_set(layoutBottom, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(layoutBottom, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(layoutBottom); + + Evas_Object * bookmark_manager_button = elm_button_add(layoutBottom); elm_object_style_set(bookmark_manager_button, "invisible_button"); - elm_object_part_content_set(m_layoutBottom, "bookmarkmanager_click", bookmark_manager_button); evas_object_smart_callback_add(bookmark_manager_button, "clicked", _bookmark_manager_clicked, this); + evas_object_show(bookmark_manager_button); + + elm_object_part_content_set(layoutBottom, "bookmarkmanager_click", bookmark_manager_button); + + return layoutBottom; } void MainUI::_mostVisited_clicked(void * data, Evas_Object * /* obj */, void * event_info) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); MainUI* mainUI = reinterpret_cast(data); - if (elm_object_part_content_get(mainUI->m_layout, "elm.swallow.left")) // check if most visited view is already set - return; mainUI->mostVisitedClicked(std::string()); } void MainUI::_bookmark_clicked(void * data, Evas_Object * /* obj */, void * event_info) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); MainUI* mainUI = reinterpret_cast(data); - if (elm_object_part_content_get(mainUI->m_layout, "elm.swallow.grid")) // check if bookmark view is already set - return; mainUI->bookmarkClicked(std::string()); } void MainUI::_bookmark_manager_clicked(void * data, Evas_Object * /* obj */, void * event_info) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); MainUI* mainUI = static_cast(data); mainUI->bookmarkManagerClicked(std::string()); } @@ -271,6 +333,8 @@ void MainUI::addHistoryItems(std::vector0) + setEmptyView(false); } void MainUI::addBookmarkItem(std::shared_ptr bi) @@ -279,13 +343,11 @@ void MainUI::addBookmarkItem(std::shared_ptritem = bi; itemData->mainUI = std::shared_ptr(this); - Elm_Object_Item* bookmarkView = elm_gengrid_item_append(m_gengrid, m_bookmark_item_class, itemData, nullptr, this); + Elm_Object_Item* bookmarkView = elm_gengrid_item_append(m_bookmarkGengrid, m_bookmark_item_class, itemData, nullptr, this); m_map_bookmark_views.insert(std::pair(bi->getAddress(),bookmarkView)); // unselect by default elm_gengrid_item_selected_set(bookmarkView, EINA_FALSE); - - setEmptyView(false); } void MainUI::addBookmarkItems(std::vector > items) @@ -391,75 +453,86 @@ void MainUI::_thumbSelected(void * data, Evas_Object * /* obj */, void * /* even void MainUI::clearHistoryGenlist() { + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + elm_genlist_clear(m_genListRight); elm_genlist_clear(m_genListLeft); elm_genlist_clear(m_genListCenter); m_map_history_views.clear(); - evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.left")); - evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.right")); - evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.center")); } -void MainUI::showHistoryGenlist() +void MainUI::showHistory() { - evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.grid")); - elm_object_part_content_unset(m_layout, "elm.swallow.grid"); - evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.layoutBottom")); - elm_object_part_content_unset(m_layout, "elm.swallow.layoutBottom"); + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + + if (elm_layout_content_get(m_layout, "elm.swallow.content") == m_mostVisitedView) + return; + + //TODO: remove these "evas_object_hide" and "evas_object_show" after cleaning up the mess in whole app window. + elm_layout_content_unset(m_layout, "elm.swallow.content"); + evas_object_hide(m_bookmarksView); + elm_layout_content_set(m_layout, "elm.swallow.content", m_mostVisitedView); + evas_object_show(m_mostVisitedView); + + elm_object_focus_set(m_mostVisitedButton, true); if (m_map_history_views.empty()) { setEmptyView(true); return; } setEmptyView(false); - elm_object_part_content_set(m_layout, "elm.swallow.left", m_genListLeft); - elm_object_part_content_set(m_layout, "elm.swallow.right", m_genListRight); - elm_object_part_content_set(m_layout, "elm.swallow.center", m_genListCenter); } void MainUI::clearBookmarkGengrid() { - elm_gengrid_clear(m_gengrid); + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + + elm_gengrid_clear(m_bookmarkGengrid); m_map_bookmark_views.clear(); - evas_object_hide(elm_layout_content_get(m_layout, "elm.swallow.grid")); } -void MainUI::showBookmarkGengrid() +void MainUI::showBookmarks() { - evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.left")); - evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.right")); - evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.center")); - elm_object_part_content_unset(m_layout, "elm.swallow.left"); - elm_object_part_content_unset(m_layout, "elm.swallow.right"); - elm_object_part_content_unset(m_layout, "elm.swallow.center"); - elm_object_part_content_set(m_layout, "elm.swallow.grid", m_gengrid); - elm_object_part_content_set(m_layout, "elm.swallow.layoutBottom", m_layoutBottom); + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + + if (elm_layout_content_get(m_layout, "elm.swallow.content") == m_bookmarksView) + return; + + //TODO: remove these "evas_object_hide" and "evas_object_show" after cleaning up the mess in whole app window. + elm_layout_content_unset(m_layout, "elm.swallow.content"); + evas_object_hide(m_mostVisitedView); + elm_layout_content_set(m_layout, "elm.swallow.content", m_bookmarksView); + evas_object_show(m_bookmarksView); + + elm_object_focus_set(m_bookmarksButton, true); } void MainUI::hide() { - BROWSER_LOGD("MainUI Hide"); - evas_object_hide(elm_layout_content_get(m_layout, "elm.swallow.genlistTop")); - evas_object_hide(elm_layout_content_get(m_layout, "elm.swallow.genlistBottom")); - evas_object_hide(m_layout); - clearItems(); + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + + //TODO: remove these "evas_object_hide" after cleaning up the mess in whole app window. + evas_object_hide(m_layout); + evas_object_hide(m_mostVisitedView); + evas_object_hide(m_bookmarksView); + clearItems(); } void MainUI::clearItems() { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); clearHistoryGenlist(); clearBookmarkGengrid(); } void MainUI::showNoHistoryLabel() { - evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.left")); - evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.right")); - evas_object_hide(elm_object_part_content_get(m_layout, "elm.swallow.center")); + evas_object_hide(elm_object_part_content_get(m_mostVisitedView, "elm.swallow.left")); + evas_object_hide(elm_object_part_content_get(m_mostVisitedView, "elm.swallow.right")); + evas_object_hide(elm_object_part_content_get(m_mostVisitedView, "elm.swallow.center")); - elm_layout_text_set(m_layout, "elm.text.empty", "No visited site"); - elm_layout_signal_emit(m_layout, "empty,view", "mainui"); + elm_layout_text_set(m_mostVisitedView, "elm.text.empty", "No visited site"); + elm_layout_signal_emit(m_mostVisitedView, "empty,view", "mainui"); } void MainUI::setEmptyView(bool empty) @@ -468,29 +541,9 @@ void MainUI::setEmptyView(bool empty) if(empty) { showNoHistoryLabel(); } else { - elm_layout_signal_emit(m_layout, "not,empty,view", "mainui"); + elm_layout_signal_emit(m_mostVisitedView, "not,empty,view", "mainui"); } } -void MainUI::focusItem(void* /*data*/, Evas_Object* /*obj*/, void* event_info) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - Elm_Object_Item *item = reinterpret_cast(event_info); - elm_object_item_signal_emit( item, "mouse,in", "over2"); - - // selected manually - elm_gengrid_item_selected_set(item, EINA_TRUE); -} - -void MainUI::unFocusItem(void* /*data*/, Evas_Object* /*obj*/, void* event_info) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - Elm_Object_Item *item = reinterpret_cast(event_info); - elm_object_item_signal_emit( item, "mouse,out", "over2"); - - // unselected manually - elm_gengrid_item_selected_set(item, EINA_FALSE); -} - } } diff --git a/services/MainUI/MainUI.h b/services/MainUI/MainUI.h index a5cefb5..35a3794 100644 --- a/services/MainUI/MainUI.h +++ b/services/MainUI/MainUI.h @@ -30,6 +30,8 @@ namespace tizen_browser{ namespace base_ui{ +//TODO: This class name is not revelant to what this class actually does. +//Rename this class and file to "QuickAccessUI". class BROWSER_EXPORT MainUI : public tizen_browser::interfaces::AbstractUIComponent , public tizen_browser::core::AbstractService @@ -42,10 +44,8 @@ public: virtual std::string getName(); void clearHistoryGenlist(); void clearBookmarkGengrid(); - void showHistoryGenlist(); - void showBookmarkGengrid(); - void showTopButtons(); - void showBottomButton(); + void showHistory(); + void showBookmarks(); void clearItems(); void addHistoryItem(std::shared_ptr); @@ -59,6 +59,14 @@ public: boost::signals2::signal bookmarkManagerClicked; private: + void createItemClasses(); + + Evas_Object* createQuickAccessLayout(Evas_Object *parent); + Evas_Object* createMostVisitedView(Evas_Object *parent); + Evas_Object* createBookmarksView(Evas_Object *parent); + Evas_Object* createBottomButton(Evas_Object *parent); + Evas_Object* createTopButtons(Evas_Object *parent); + static char* _grid_text_get(void *data, Evas_Object *obj, const char *part); static Evas_Object * _grid_content_get(void *data, Evas_Object *obj, const char *part); static char* _grid_bookmark_text_get(void *data, Evas_Object *obj, const char *part); @@ -75,23 +83,24 @@ private: private: Evas_Object *m_parent; Evas_Object *m_layout; - Evas_Object *m_layoutTop; - Evas_Object *m_layoutBottom; - Evas_Object *m_gengrid; + Evas_Object *m_bookmarksView; + Evas_Object *m_mostVisitedView; + Evas_Object *m_bookmarksButton; + Evas_Object *m_mostVisitedButton; + Evas_Object *m_bookmarkGengrid; Evas_Object *m_genListLeft; Evas_Object *m_genListCenter; Evas_Object *m_genListRight; + Elm_Gengrid_Item_Class * m_big_item_class; Elm_Gengrid_Item_Class * m_small_item_class; Elm_Gengrid_Item_Class * m_bookmark_item_class; + std::multimap m_map_history_views; std::map m_map_bookmark_views; bool m_gengridSetup; std::string edjFilePath; void showNoHistoryLabel(); - - static void focusItem(void* data, Evas_Object* obj, void* event_info); - static void unFocusItem(void* data, Evas_Object* obj, void* event_info); }; } diff --git a/services/MainUI/edc/MainUI.edc b/services/MainUI/edc/MainUI.edc index 129d266..de77956 100644 --- a/services/MainUI/edc/MainUI.edc +++ b/services/MainUI/edc/MainUI.edc @@ -133,7 +133,7 @@ group { name: "mv_bookmarks"; } parts { - part { name: "genlistTop_bg"; + part { name: "layoutTop_bg"; type: RECT; mouse_events: 0; description { state: "default" 0.0; @@ -160,7 +160,7 @@ group { name: "mv_bookmarks"; align: 0.0 0.0; fixed: 0 0; rel1 { - to: "genlistTop_bg"; + to: "layoutTop_bg"; relative: 0 1; } rel2{ @@ -280,7 +280,7 @@ group { name: "mv_bookmarks"; } } - part { name: "elm.swallow.genlistTop"; + part { name: "elm.swallow.layoutTop"; type: SWALLOW; description { state: "default" 0.0; min: 1920 181; @@ -288,7 +288,7 @@ group { name: "mv_bookmarks"; align: 0.0 0.0; fixed: 0 0; rel1 { - relative: 0 0; to: "genlistTop_bg"; + relative: 0 0; to: "layoutTop_bg"; } rel2 { relative: 1 1; @@ -308,7 +308,7 @@ group { name: "mv_bookmarks"; min: 1920 14; max: 1920 14; image.normal: "web_shadow.png"; - rel1 { relative: 0.0 0.0; to: "elm.swallow.genlistTop"; } + rel1 { relative: 0.0 0.0; to: "elm.swallow.layoutTop"; } rel2 { relative: 1.0 1.0; } } } diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 965cc3e..f5f18f2 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -612,7 +612,7 @@ void SimpleUI::onClearHistoryClicked(const std::string&) BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); m_historyService->clearAllHistory(); m_mainUI->clearHistoryGenlist(); - m_mainUI->showHistoryGenlist(); + m_mainUI->showHistory(); } void SimpleUI::onMostVisitedClicked(const std::string&) @@ -621,7 +621,7 @@ void SimpleUI::onMostVisitedClicked(const std::string&) m_mainUI->clearHistoryGenlist(); m_mainUI->clearBookmarkGengrid(); m_mainUI->addHistoryItems(getHistory()); - m_mainUI->showHistoryGenlist(); + m_mainUI->showHistory(); } void SimpleUI::onBookmarkButtonClicked(const std::string&) @@ -630,7 +630,7 @@ void SimpleUI::onBookmarkButtonClicked(const std::string&) m_mainUI->clearBookmarkGengrid(); m_mainUI->clearHistoryGenlist(); m_mainUI->addBookmarkItems(getBookmarks()); - m_mainUI->showBookmarkGengrid(); + m_mainUI->showBookmarks(); } void SimpleUI::onBookmarkManagerButtonClicked(const std::string&) @@ -1066,11 +1066,11 @@ void SimpleUI::hideWebView() void SimpleUI::hideMainUI() { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); if(m_mainUI) - m_mainUI->hide(); - m_mainUI = nullptr; - m_isHomePageActive = false; + m_mainUI->hide(); + m_mainUI = nullptr; + m_isHomePageActive = false; } void SimpleUI::showMainUI() @@ -1083,8 +1083,7 @@ void SimpleUI::showMainUI() hideWebView(); m_mainUI->show(m_window.get()); m_mainUI->addHistoryItems(getHistory()); - m_mainUI->showHistoryGenlist(); - + m_mainUI->addBookmarkItems(getBookmarks()); m_isHomePageActive = true; } -- 2.7.4 From dfa047c462421e1c4f23375a620fcc01b6da2a00 Mon Sep 17 00:00:00 2001 From: Albert Malewski Date: Thu, 27 Aug 2015 09:45:37 +0200 Subject: [PATCH 02/16] Fixed crash that occurs after clicking on 'History' button [Issue#] https://bugs.tizen.org/jira/browse/TT-98 [Problem] Browser crashes after clicking on 'History' button. [Cause] There was used normal pointer that pointed to the destroyed object. [Sollution] 1. Changed type of HistoryService::getHistoryItems() and HistoryService::getMostVisitedHistoryItems() functions that the return std::shared_ptr > >. 2. Added HistoryService::getHistoryItem function which returns HistoryItem by id. 3. Added HistoryService::getCurrentTab functions that returns currently observed web page's info. 4. Changed type of h_item pointer in MoreMenuUI.cpp from normal pointer to shared_ptr. 5. Added listItemDel function to avoid memory leaks when genlist is cleared. [Verify] Launch browser > More Menu > History > Obs History should not crash after clicking on 'History' button. Change-Id: I9140c1dedc061b2d014792aa14da92053e7aa27f --- services/HistoryService/HistoryService.cpp | 121 +++++++++++++++++------------ services/HistoryService/HistoryService.h | 6 +- services/HistoryUI/HistoryUI.cpp | 6 +- services/HistoryUI/HistoryUI.h | 4 +- services/MainUI/MainUI.cpp | 6 +- services/MainUI/MainUI.h | 4 +- services/MoreMenuUI/MoreMenuUI.cpp | 21 +++-- services/MoreMenuUI/MoreMenuUI.h | 3 +- services/SimpleUI/SimpleUI.cpp | 23 +++--- services/SimpleUI/SimpleUI.h | 2 +- 10 files changed, 114 insertions(+), 82 deletions(-) diff --git a/services/HistoryService/HistoryService.cpp b/services/HistoryService/HistoryService.cpp index f2ebbfb..2a9db4f 100644 --- a/services/HistoryService/HistoryService.cpp +++ b/services/HistoryService/HistoryService.cpp @@ -134,9 +134,9 @@ bool isDuplicate(const char* title) } -HistoryItemVector& HistoryService::getMostVisitedHistoryItems() +std::shared_ptr HistoryService::getMostVisitedHistoryItems() { - history_list.clear(); + std::shared_ptr ret_history_list(new HistoryItemVector); int *ids=nullptr; int count=-1; @@ -208,10 +208,10 @@ HistoryItemVector& HistoryService::getMostVisitedHistoryItems() memcpy(hi->imageData, (void*)history_info.thumbnail, history_info.thumbnail_length); history->setThumbnail(hi); - history_list.push_back(history); + ret_history_list->push_back(history); } free(ids); - return history_list; + return ret_history_list; } void HistoryService::addHistoryItem(std::shared_ptr his,std::shared_ptr thumbnail){ @@ -317,71 +317,94 @@ void HistoryService::clearURLHistory(const std::string & url) historyDeleted(url); } - -HistoryItemVector& HistoryService::getHistoryItems(int historyDepthInDays, int maxItems) +std::shared_ptr HistoryService::getHistoryItem(int * ids, int idNumber) { - history_list.clear(); + bp_history_offset offset = (BP_HISTORY_O_URL | BP_HISTORY_O_TITLE | BP_HISTORY_O_FAVICON | BP_HISTORY_O_DATE_CREATED); + bp_history_info_fmt history_info; + bp_history_adaptor_get_info(ids[idNumber], offset, &history_info); + + int date; + bp_history_adaptor_get_date_created(ids[idNumber], &date); + + struct tm *item_time_info; + time_t item_time = (time_t) date; + item_time_info = localtime(&item_time); + + int m_year = item_time_info->tm_year; + int m_month = item_time_info->tm_mon + 1; + int m_day = item_time_info->tm_yday; + int m_month_day = item_time_info->tm_mday; + int m_date = date; + int min = item_time_info->tm_min; + int hour = item_time_info->tm_hour; + int sec = item_time_info->tm_sec; + + m_year = 2000 + m_year % 100; + + std::shared_ptr history = std::make_shared (std::string(history_info.url)); + boost::gregorian::date d(m_year, m_month, m_month_day); + boost::posix_time::ptime t(d, boost::posix_time::time_duration(hour, min, sec)); + history->setLastVisit(t); + history->setUrl(std::string(history_info.url ? history_info.url : "")); + history->setTitle(std::string(history_info.title ? history_info.title : "")); + + //thumbail + std::shared_ptr hi = std::make_shared(); + hi->imageType = tizen_browser::tools::BrowserImage::ImageType::ImageTypePNG; + hi->width = history_info.thumbnail_width; + hi->height = history_info.thumbnail_height; + hi->dataSize = history_info.thumbnail_length; + hi->imageData = (void*) malloc(history_info.thumbnail_length); + memcpy(hi->imageData, (void*) history_info.thumbnail, history_info.thumbnail_length); + history->setThumbnail(hi); + + return history; +} +std::shared_ptr HistoryService::getCurrentTab() +{ int *ids=nullptr; - int count=-1; + int count = -1; bp_history_rows_cond_fmt conds; conds.limit = 20; //no of rows to get negative means no limitation conds.offset = -1; //the first row's index - conds.order_offset =BP_HISTORY_O_DATE_CREATED; // property to sort + conds.order_offset = BP_HISTORY_O_DATE_VISITED; // property to sort conds.ordering = 1; //way of ordering 0 asc 1 desc conds.period_offset = BP_HISTORY_O_DATE_CREATED; conds.period_type = BP_HISTORY_DATE_TODAY; - int ret = bp_history_adaptor_get_cond_ids_p(&ids ,&count, &conds, 0, nullptr, 0); + int ret = bp_history_adaptor_get_cond_ids_p(&ids , &count, &conds, 0, nullptr, 0); if (ret<0){ BROWSER_LOGD("Error! Could not get ids!"); } - bp_history_offset offset = (BP_HISTORY_O_URL | BP_HISTORY_O_TITLE | BP_HISTORY_O_FAVICON | BP_HISTORY_O_DATE_CREATED); - - for(int i = 0; i< count; i++){ - bp_history_info_fmt history_info; - bp_history_adaptor_get_info(ids[i],offset,&history_info); - - int date; - bp_history_adaptor_get_date_created(ids[i], &date); - - struct tm *item_time_info; - time_t item_time = (time_t)date; - item_time_info = localtime(&item_time); - - int m_year = item_time_info->tm_year; - int m_month = item_time_info->tm_mon + 1; - int m_day = item_time_info->tm_yday; - int m_month_day = item_time_info->tm_mday; - int m_date = date; - int min = item_time_info->tm_min; - int hour= item_time_info->tm_hour; - int sec = item_time_info->tm_sec; + return getHistoryItem(ids); +} - m_year = 2000 + m_year % 100; +std::shared_ptr HistoryService::getHistoryItems(bp_history_date_defs period, int maxItems) +{ + std::shared_ptr ret_history_list(new HistoryItemVector); - std::shared_ptr history = std::make_shared(std::string(history_info.url)); - boost::gregorian::date d(m_year,m_month,m_month_day); - boost::posix_time::ptime t(d,boost::posix_time::time_duration(hour,min,sec)); - history->setLastVisit(t); - history->setUrl(std::string(history_info.url ? history_info.url : "")); - history->setTitle(std::string(history_info.title ? history_info.title : "")); + int *ids=nullptr; + int count=-1; + bp_history_rows_cond_fmt conds; + conds.limit = 20; //no of rows to get negative means no limitation + conds.offset = -1; //the first row's index + conds.order_offset = BP_HISTORY_O_DATE_VISITED; // property to sort + conds.ordering = 1; //way of ordering 0 asc 1 desc + conds.period_offset = BP_HISTORY_O_DATE_CREATED; + conds.period_type = period; - //thumbail - std::shared_ptr hi = std::make_shared(); - hi->imageType = tizen_browser::tools::BrowserImage::ImageType::ImageTypePNG; - hi->width = history_info.thumbnail_width; - hi->height = history_info.thumbnail_height; - hi->dataSize = history_info.thumbnail_length; - hi->imageData = (void*)malloc(history_info.thumbnail_length); - memcpy(hi->imageData, (void*)history_info.thumbnail, history_info.thumbnail_length); - history->setThumbnail(hi); + int ret = bp_history_adaptor_get_cond_ids_p(&ids ,&count, &conds, 0, nullptr, 0); + if (ret<0) { + BROWSER_LOGD("Error! Could not get ids!"); + } - history_list.push_back(history); + for(int i = 0; i< count; i++) { + ret_history_list->push_back(getHistoryItem(ids, i)); } free(ids); - return history_list; + return ret_history_list; } int HistoryService::getHistoryVisitCounter(const std::string & url) diff --git a/services/HistoryService/HistoryService.h b/services/HistoryService/HistoryService.h index 3f2c44e..966a37b 100644 --- a/services/HistoryService/HistoryService.h +++ b/services/HistoryService/HistoryService.h @@ -76,8 +76,9 @@ public: /** * @throws HistoryException on error */ - HistoryItemVector & getHistoryItems(int historyDepthInDays = 7, int maxItems = 50); - HistoryItemVector & getMostVisitedHistoryItems(); + std::shared_ptr getHistoryItems(bp_history_date_defs period = BP_HISTORY_DATE_TODAY, int maxItems = 50); + std::shared_ptr getCurrentTab(); + std::shared_ptr getMostVisitedHistoryItems(); /** * @throws HistoryException on error @@ -106,6 +107,7 @@ private: */ void initDatabaseBookmark(const std::string & db_str); + std::shared_ptr getHistoryItem(int* ids, int idNumber = 0); std::shared_ptr getStorageManager(); }; diff --git a/services/HistoryUI/HistoryUI.cpp b/services/HistoryUI/HistoryUI.cpp index c4ec024..a2dc558 100644 --- a/services/HistoryUI/HistoryUI.cpp +++ b/services/HistoryUI/HistoryUI.cpp @@ -178,7 +178,7 @@ void HistoryUI::addItems() BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); } -void HistoryUI::addHistoryItem(std::shared_ptr hi) +void HistoryUI::addHistoryItem(std::shared_ptr hi) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); HistoryItemData *itemData = new HistoryItemData(); @@ -188,11 +188,11 @@ void HistoryUI::addHistoryItem(std::shared_ptr > items) +void HistoryUI::addHistoryItems(std::shared_ptr items) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); _history_item_data.clear(); - for (auto it = items.begin(); it != items.end(); ++it) + for (auto it = items->begin(); it != items->end(); ++it) addHistoryItem(*it); } diff --git a/services/HistoryUI/HistoryUI.h b/services/HistoryUI/HistoryUI.h index f6ac0b2..1eb4a24 100644 --- a/services/HistoryUI/HistoryUI.h +++ b/services/HistoryUI/HistoryUI.h @@ -38,8 +38,8 @@ public: ~HistoryUI(); void init(Evas_Object *main_layout); virtual std::string getName(); - void addHistoryItem(std::shared_ptr); - void addHistoryItems(std::vector >); + void addHistoryItem(std::shared_ptr); + void addHistoryItems(std::shared_ptr); void removeHistoryItem(const std::string& uri); void clearItems(); void hide(); diff --git a/services/MainUI/MainUI.cpp b/services/MainUI/MainUI.cpp index 6d86e66..e011d46 100644 --- a/services/MainUI/MainUI.cpp +++ b/services/MainUI/MainUI.cpp @@ -297,7 +297,7 @@ void MainUI::_bookmark_manager_clicked(void * data, Evas_Object * /* obj */, voi mainUI->bookmarkManagerClicked(std::string()); } -void MainUI::addHistoryItem(std::shared_ptr hi) +void MainUI::addHistoryItem(std::shared_ptr hi) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); if (m_map_history_views.size() >= MAX_TILES_NUMBER) @@ -323,11 +323,11 @@ void MainUI::addHistoryItem(std::shared_ptr(hi->getUrl(),historyView)); } -void MainUI::addHistoryItems(std::vector > items) +void MainUI::addHistoryItems(std::shared_ptr items) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); int i = 0; - for (auto it = items.begin(); it != items.end(); ++it) { + for (auto it = items->begin(); it != items->end(); ++it) { i++; if (i > MAX_TILES_NUMBER) break; diff --git a/services/MainUI/MainUI.h b/services/MainUI/MainUI.h index 35a3794..6809fd0 100644 --- a/services/MainUI/MainUI.h +++ b/services/MainUI/MainUI.h @@ -48,8 +48,8 @@ public: void showBookmarks(); void clearItems(); - void addHistoryItem(std::shared_ptr); - void addHistoryItems(std::vector >); + void addHistoryItem(std::shared_ptr); + void addHistoryItems(std::shared_ptr); void addBookmarkItem(std::shared_ptr); void addBookmarkItems(std::vector >); diff --git a/services/MoreMenuUI/MoreMenuUI.cpp b/services/MoreMenuUI/MoreMenuUI.cpp index d28c73c..ed361b6 100644 --- a/services/MoreMenuUI/MoreMenuUI.cpp +++ b/services/MoreMenuUI/MoreMenuUI.cpp @@ -34,7 +34,7 @@ EXPORT_SERVICE(MoreMenuUI, "org.tizen.browser.moremenuui") struct ItemData{ tizen_browser::base_ui::MoreMenuUI * m_moreMenu; - tizen_browser::services::HistoryItem * h_item; + std::shared_ptr h_item; Elm_Object_Item * e_item; }; @@ -98,7 +98,7 @@ void MoreMenuUI::show(Evas_Object* parent) addItems(); } -void MoreMenuUI::showCurrentTab(const std::shared_ptr item) +void MoreMenuUI::showCurrentTab(std::shared_ptr item) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); elm_theme_extension_add(NULL, m_edjFilePath.c_str()); @@ -119,11 +119,11 @@ void MoreMenuUI::showCurrentTab(const std::shared_ptrfunc.text_get = &listItemTextGet; m_itemClass->func.content_get = &listItemContentGet; m_itemClass->func.state_get = 0; - m_itemClass->func.del = 0; + m_itemClass->func.del = &listItemDel; ItemData * id = new ItemData; id->m_moreMenu = this; - id->h_item = item ? item.get() : NULL; + id->h_item = item; Elm_Object_Item* elmItem = elm_genlist_item_append(m_genList, //genlist m_itemClass, //item Class id, @@ -148,7 +148,7 @@ Evas_Object* MoreMenuUI::listItemContentGet(void* data, Evas_Object* obj, const const char *part_name3 = "close_click"; static const int part_name3_len = strlen(part_name3); - if (!strncmp(part_name1, part, part_name1_len) && id->h_item && id->h_item->getFavIcon()) { + if (!strncmp(part_name1, part, part_name1_len) && id->h_item.get() && id->h_item->getFavIcon()) { // Currently favicon is not getting fetched from the engine, // so we are showing Google's favicon by default. Evas_Object *thumb_nail = elm_icon_add(obj); @@ -259,14 +259,14 @@ char* MoreMenuUI::listItemTextGet(void* data, Evas_Object*, const char* part) static const int part_name2_len = strlen(part_name2); if (!strncmp(part_name1, part, part_name1_len)) { - if (!id->h_item) { + if (!id->h_item.get()) { return strdup("New Tab"); } return strdup(id->h_item->getTitle().c_str()); } if (!strncmp(part_name2, part, part_name2_len)) { - if(!id->h_item) + if(!id->h_item.get()) return strdup(""); return strdup(id->h_item->getUrl().c_str()); } @@ -274,6 +274,13 @@ char* MoreMenuUI::listItemTextGet(void* data, Evas_Object*, const char* part) return strdup(""); } +void MoreMenuUI::listItemDel(void* data, Evas_Object* obj) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if(data) + delete (ItemData *)data; +} + void MoreMenuUI::hide() { evas_object_hide(elm_layout_content_get(m_mm_layout, "elm.swallow.grid")); diff --git a/services/MoreMenuUI/MoreMenuUI.h b/services/MoreMenuUI/MoreMenuUI.h index 103b8c7..9d0b4d4 100644 --- a/services/MoreMenuUI/MoreMenuUI.h +++ b/services/MoreMenuUI/MoreMenuUI.h @@ -63,7 +63,7 @@ public: MoreMenuUI(); ~MoreMenuUI(); void show(Evas_Object *main_layout); - void showCurrentTab(const std::shared_ptr item); + void showCurrentTab(std::shared_ptr item); virtual std::string getName(); void addItems(); void hide(); @@ -86,6 +86,7 @@ private: static Evas_Object* listItemContentGet(void *data, Evas_Object *obj, const char *part); static char* listItemTextGet(void *data, Evas_Object *obj, const char *part); + static void listItemDel(void *, Evas_Object *); void newFolderPopup(std::string); void NewFolderCreate(Evas_Object * popup_content); diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index f5f18f2..7d8e1fa 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -108,7 +108,7 @@ std::vector > SimpleUI::g return m_favoriteService->getBookmarks(folder_id); } -std::vector > SimpleUI::getHistory() +std::shared_ptr SimpleUI::getHistory() { return m_historyService->getMostVisitedHistoryItems(); } @@ -1139,25 +1139,24 @@ void SimpleUI::showMoreMenu() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); bool current_tab_as_new_tab = isHomePageActive() || (m_historyService->getHistoryItemsCount() == 0); - if(!m_moreMenuUI){ - m_moreMenuUI = - std::dynamic_pointer_cast - - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.moremenuui")); + if (!m_moreMenuUI) { + m_moreMenuUI = std::dynamic_pointer_cast + (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.moremenuui")); M_ASSERT(m_moreMenuUI); + m_moreMenuUI->bookmarkManagerClicked.connect(boost::bind(&SimpleUI::onBookmarkManagerButtonClicked, this, _1)); - m_moreMenuUI->historyUIClicked.connect(boost::bind(&SimpleUI::showHistoryUI, this,_1)); - m_moreMenuUI->settingsClicked.connect(boost::bind(&SimpleUI::showSettingsUI, this,_1)); + m_moreMenuUI->historyUIClicked.connect(boost::bind(&SimpleUI::showHistoryUI, this, _1)); + m_moreMenuUI->settingsClicked.connect(boost::bind(&SimpleUI::showSettingsUI, this, _1)); m_moreMenuUI->closeMoreMenuClicked.disconnect_all_slots(); - m_moreMenuUI->closeMoreMenuClicked.connect(boost::bind(&SimpleUI::closeMoreMenu, this,_1)); + m_moreMenuUI->closeMoreMenuClicked.connect(boost::bind(&SimpleUI::closeMoreMenu, this, _1)); m_moreMenuUI->addToBookmarkClicked.disconnect_all_slots(); m_moreMenuUI->addToBookmarkClicked.connect(boost::bind(&SimpleUI::addBookmarkFolders, this)); m_moreMenuUI->AddBookmarkInput.disconnect_all_slots(); - m_moreMenuUI->AddBookmarkInput.connect(boost::bind(&SimpleUI::addToBookmarks, this,_1)); + m_moreMenuUI->AddBookmarkInput.connect(boost::bind(&SimpleUI::addToBookmarks, this, _1)); m_moreMenuUI->BookmarkFolderCreated.disconnect_all_slots(); - m_moreMenuUI->BookmarkFolderCreated.connect(boost::bind(&SimpleUI::newFolderMoreMenu, this,_1,_2)); + m_moreMenuUI->BookmarkFolderCreated.connect(boost::bind(&SimpleUI::newFolderMoreMenu, this, _1, _2)); m_moreMenuUI->show(m_window.get()); - m_moreMenuUI->showCurrentTab(current_tab_as_new_tab ? nullptr : m_historyService->getHistoryItems().front()); + m_moreMenuUI->showCurrentTab(current_tab_as_new_tab ? nullptr : m_historyService->getCurrentTab()); BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); } } diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index 06bbe47..e4783dd 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -122,7 +122,7 @@ private: void bookmarkCheck(); std::vector > getBookmarks(int folder_id = -1); std::vector > getBookmarkFolders(int folder_id); - std::vector > getHistory(); + std::shared_ptr getHistory(); void onBookmarkAdded(std::shared_ptr bookmarkItem); void onBookmarkClicked(std::shared_ptr bookmarkItem); -- 2.7.4 From be51d69764718e57d75c943cb1b5c41296d18832 Mon Sep 17 00:00:00 2001 From: "t.dakowicz" Date: Thu, 27 Aug 2015 16:43:15 +0200 Subject: [PATCH 03/16] TT-141 Added current web page info sync [Issue#] https://bugs.tizen.org/jira/browse/TT-141 [Problem] Current web page info wasn't always updated and favicon wasn't loaded [Cause] Lack of proper signals [Solution] Added signals, removed genlist and used single layout instead, resized space for site info, removed pointless image reload from WebView::getFavicon [Verify] Open a new page -> type web url -> MoreMenu Check if the info is properly loaded Change-Id: Ibe3f7cd97279470761eaa9f58c9e40b06c655eeb --- services/MoreMenuUI/MoreMenuUI.cpp | 200 +++++++++---------------------- services/MoreMenuUI/MoreMenuUI.h | 22 ++-- services/MoreMenuUI/edc/MoreMenu.edc | 21 ++-- services/SimpleUI/SimpleUI.cpp | 45 +++---- services/WebKitEngineService/WebView.cpp | 61 ++++------ 5 files changed, 116 insertions(+), 233 deletions(-) diff --git a/services/MoreMenuUI/MoreMenuUI.cpp b/services/MoreMenuUI/MoreMenuUI.cpp index ed361b6..fb1bcb5 100644 --- a/services/MoreMenuUI/MoreMenuUI.cpp +++ b/services/MoreMenuUI/MoreMenuUI.cpp @@ -72,10 +72,6 @@ void MoreMenuUI::show(Evas_Object* parent) m_gengrid = elm_gengrid_add(m_mm_layout); elm_object_part_content_set(m_mm_layout, "elm.swallow.grid", m_gengrid); - /*evas_object_smart_callback_add(m_gengrid, "item,focused", focusItem, NULL); - evas_object_smart_callback_add(m_gengrid, "item,unfocused", unFocusItem, NULL); - evas_object_smart_callback_add(m_gengrid, "activated", _itemSelected, this);*/ - if (!m_item_class) { m_item_class = elm_gengrid_item_class_new(); m_item_class->item_style = "menu_item"; @@ -98,90 +94,75 @@ void MoreMenuUI::show(Evas_Object* parent) addItems(); } -void MoreMenuUI::showCurrentTab(std::shared_ptr item) +void MoreMenuUI::showCurrentTab() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_theme_extension_add(NULL, m_edjFilePath.c_str()); - m_genList = elm_genlist_add(m_mm_layout); - elm_object_part_content_set(m_mm_layout, "elm.swallow.genlist", m_genList); - elm_genlist_homogeneous_set(m_genList, EINA_FALSE); - elm_genlist_multi_select_set(m_genList, EINA_FALSE); - elm_genlist_select_mode_set(m_genList, ELM_OBJECT_SELECT_MODE_ALWAYS); - elm_genlist_mode_set(m_genList, ELM_LIST_LIMIT); - elm_genlist_decorate_mode_set(m_genList, EINA_TRUE); - evas_object_size_hint_weight_set(m_genList, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - - /*evas_object_smart_callback_add(m_genList, "item,focused", focusItem, this); - evas_object_smart_callback_add(m_genList, "item,unfocused", unFocusItem, NULL);*/ - - m_itemClass = elm_genlist_item_class_new(); - m_itemClass->item_style = "current_tab"; - m_itemClass->func.text_get = &listItemTextGet; - m_itemClass->func.content_get = &listItemContentGet; - m_itemClass->func.state_get = 0; - m_itemClass->func.del = &listItemDel; - - ItemData * id = new ItemData; - id->m_moreMenu = this; - id->h_item = item; - Elm_Object_Item* elmItem = elm_genlist_item_append(m_genList, //genlist - m_itemClass, //item Class - id, - NULL, //parent item - ELM_GENLIST_ITEM_NONE, //item type - NULL, - NULL //data passed to above function - ); - id->e_item = elmItem; + m_current_tab_bar = elm_layout_add(m_mm_layout); + elm_layout_file_set(m_current_tab_bar, m_edjFilePath.c_str(), "current_tab_layout"); + evas_object_size_hint_weight_set(m_current_tab_bar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_part_content_set(m_mm_layout, "current_tab_bar", m_current_tab_bar); + + Evas_Object* button = elm_button_add(m_current_tab_bar); + elm_object_style_set(button, "hidden_button"); + evas_object_smart_callback_add(button, "clicked", _star_clicked, this); + elm_object_part_content_set(m_current_tab_bar, "star_click", button); + + button = elm_button_add(m_current_tab_bar); + elm_object_style_set(button, "hidden_button"); + evas_object_smart_callback_add(button, "clicked", _close_clicked, this); + elm_object_part_content_set(m_current_tab_bar, "close_click", button); BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); } -Evas_Object* MoreMenuUI::listItemContentGet(void* data, Evas_Object* obj, const char* part) +void MoreMenuUI::setFavIcon(std::shared_ptr favicon) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data && obj && part) { - ItemData * id = static_cast(data); - const char *part_name1 = "favicon"; - static const int part_name1_len = strlen(part_name1); - const char *part_name2 = "star_click"; - static const int part_name2_len =strlen(part_name2); - const char *part_name3 = "close_click"; - static const int part_name3_len = strlen(part_name3); - - if (!strncmp(part_name1, part, part_name1_len) && id->h_item.get() && id->h_item->getFavIcon()) { - // Currently favicon is not getting fetched from the engine, - // so we are showing Google's favicon by default. - Evas_Object *thumb_nail = elm_icon_add(obj); - const char *file_name = "favicon.png"; - elm_image_file_set(thumb_nail, id->m_moreMenu->m_edjFilePath.c_str(), file_name); - return thumb_nail; - //return tizen_browser::tools::EflTools::getEvasImage(id->h_item->getFavIcon(), obj); + if(favicon && favicon->imageType != tools::BrowserImage::ImageTypeNoImage){ + m_icon = tizen_browser::tools::EflTools::getEvasImage(favicon, m_current_tab_bar); + if(m_icon){ + evas_object_size_hint_weight_set(m_icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_icon, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_part_content_set(m_current_tab_bar, "favicon", m_icon); + evas_object_show(m_icon); } + } +} - if (!strncmp(part_name2, part, part_name2_len)) { - Evas_Object *star_click = elm_button_add(obj); - elm_object_style_set(star_click, "hidden_button"); - evas_object_smart_callback_add(star_click, "clicked", MoreMenuUI::star_clicked_cb, id); - return star_click; - } +void MoreMenuUI::setWebTitle(const std::string& title) +{ + BROWSER_LOGD("[%s:%d] %s", __PRETTY_FUNCTION__, __LINE__, title.c_str()); + if(!title.empty()) + elm_object_part_text_set(m_current_tab_bar, "webpage_title", title.c_str()); + else + elm_object_part_text_set(m_current_tab_bar, "webpage_title", "New Tab"); +} - if (!strncmp(part_name3, part, part_name3_len)) { - Evas_Object *close_click = elm_button_add(obj); - elm_object_style_set(close_click, "hidden_button"); - evas_object_smart_callback_add(close_click, "clicked", MoreMenuUI::close_clicked_cb, id); - return close_click; - } +void MoreMenuUI::setURL(const std::string& url) +{ + BROWSER_LOGD("[%s:%d] %s", __PRETTY_FUNCTION__, __LINE__, url.c_str()); + if(!url.empty()) + elm_object_part_text_set(m_current_tab_bar, "webpage_url", url.c_str()); + else + elm_object_part_text_set(m_current_tab_bar, "webpage_url", ""); +} + +void MoreMenuUI::_star_clicked(void* data, Evas_Object*, void*) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + MoreMenuUI *moreMenuUI = static_cast(data); + moreMenuUI->addToBookmarkClicked(); + moreMenuUI->AddBookmarkPopupCalled(); } - return NULL; } -void MoreMenuUI::star_clicked_cb(void* data, Evas_Object*, void*) +void MoreMenuUI::_close_clicked(void* data, Evas_Object*, void*) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); if (data) { - ItemData * id = static_cast(data); - id->m_moreMenu->addToBookmarkClicked(); - id->m_moreMenu->AddBookmarkPopupCalled(); + MoreMenuUI *moreMenuUI = static_cast(data); + moreMenuUI->closeMoreMenuClicked(std::string()); + moreMenuUI->clearItems(); } } @@ -238,53 +219,11 @@ void MoreMenuUI::addToBookmarks(int folder_id) m_add_bookmark_popup->hide(); m_add_bookmark_popup.reset(); } -void MoreMenuUI::close_clicked_cb(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - ItemData * id = static_cast(data); - id->m_moreMenu->closeMoreMenuClicked(std::string()); - id->m_moreMenu->clearItems(); - } -} - -char* MoreMenuUI::listItemTextGet(void* data, Evas_Object*, const char* part) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data && part) { - ItemData *id = static_cast(data); - const char *part_name1 = "webpage_title"; - static const int part_name1_len = strlen(part_name1); - const char *part_name2 = "webpage_url"; - static const int part_name2_len = strlen(part_name2); - - if (!strncmp(part_name1, part, part_name1_len)) { - if (!id->h_item.get()) { - return strdup("New Tab"); - } - return strdup(id->h_item->getTitle().c_str()); - } - - if (!strncmp(part_name2, part, part_name2_len)) { - if(!id->h_item.get()) - return strdup(""); - return strdup(id->h_item->getUrl().c_str()); - } - } - return strdup(""); -} - -void MoreMenuUI::listItemDel(void* data, Evas_Object* obj) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if(data) - delete (ItemData *)data; -} void MoreMenuUI::hide() { evas_object_hide(elm_layout_content_get(m_mm_layout, "elm.swallow.grid")); - evas_object_hide(elm_layout_content_get(m_mm_layout, "elm.swallow.genlist")); + evas_object_hide(elm_layout_content_get(m_mm_layout, "current_tab_bar")); evas_object_hide(m_mm_layout); } @@ -507,9 +446,9 @@ void MoreMenuUI::clearItems() hide(); BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); elm_gengrid_clear(m_gengrid); - elm_genlist_clear(m_genList); m_map_menu_views.clear(); m_map_bookmark_folder_list.clear(); + evas_object_del(m_current_tab_bar); elm_theme_extension_del(NULL, m_edjFilePath.c_str()); elm_theme_full_flush(); elm_cache_all_flush(); @@ -521,34 +460,5 @@ void MoreMenuUI::_exitClicked() elm_exit(); } -//void MoreMenuUI::focusItem(void*, Evas_Object*, void* event_info) -//{ -// BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); -// if (event_info) { -// Elm_Object_Item *item = static_cast(event_info); -// elm_object_item_signal_emit(item, "mouse,in", "over2"); -// -// // selected manually -// elm_gengrid_item_selected_set(item, EINA_TRUE); -// } -//} -// -//void MoreMenuUI::unFocusItem(void*, Evas_Object*, void* event_info) -//{ -// BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); -// if (event_info) { -// Elm_Object_Item *item = static_cast(event_info); -// elm_object_item_signal_emit( item, "mouse,out", "over2"); -// -// // unselected manually -// elm_gengrid_item_selected_set(item, EINA_FALSE); -// } -//} -// -//void MoreMenuUI::_itemSelected(void*, Evas_Object*, void *) -//{ -// BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); -//} - } } diff --git a/services/MoreMenuUI/MoreMenuUI.h b/services/MoreMenuUI/MoreMenuUI.h index 9d0b4d4..cd3d6c1 100644 --- a/services/MoreMenuUI/MoreMenuUI.h +++ b/services/MoreMenuUI/MoreMenuUI.h @@ -25,7 +25,6 @@ #include "AbstractService.h" #include "ServiceFactory.h" #include "service_macros.h" -//#include "../SimpleUI/SimpleUI.h" #include "BookmarkItem.h" #include "AddBookmarkPopup.h" @@ -63,12 +62,15 @@ public: MoreMenuUI(); ~MoreMenuUI(); void show(Evas_Object *main_layout); - void showCurrentTab(std::shared_ptr item); + void showCurrentTab(); virtual std::string getName(); void addItems(); void hide(); void clearItems(); void getBookmarkFolderList(std::vector > ); + void setFavIcon(std::shared_ptr favicon); + void setWebTitle(const std::string& title); + void setURL(const std::string& url); boost::signals2::signal addToBookmarkClicked; boost::signals2::signal AddBookmarkInput; @@ -84,10 +86,6 @@ private: static void _thumbSelected(void * data, Evas_Object * obj, void * event_info); static void _exitClicked(); - static Evas_Object* listItemContentGet(void *data, Evas_Object *obj, const char *part); - static char* listItemTextGet(void *data, Evas_Object *obj, const char *part); - static void listItemDel(void *, Evas_Object *); - void newFolderPopup(std::string); void NewFolderCreate(Evas_Object * popup_content); void CancelClicked(Evas_Object * popup_content); @@ -95,18 +93,17 @@ private: void AddBookmarkPopupCalled(); void addToBookmarks(int folder_id); - static void star_clicked_cb(void *data, Evas_Object *obj, void *event_info); - static void close_clicked_cb(void *data, Evas_Object *obj, void *event_info); + static void _star_clicked(void *data, Evas_Object *obj, void *event_info); + static void _close_clicked(void *data, Evas_Object *obj, void *event_info); static void __cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info); static void __cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info); private: - Evas_Object *m_genList; + Evas_Object *m_current_tab_bar; std::shared_ptr m_new_folder_popup; Evas_Object *m_mm_layout; std::shared_ptr m_add_bookmark_popup; - Elm_Genlist_Item_Class *m_itemClass; Evas_Object *m_gengrid; Evas_Object *m_parent; Elm_Gengrid_Item_Class * m_item_class; @@ -115,10 +112,7 @@ private: std::string m_edjFilePath; std::string m_folderName; bool m_gengridSetup; - - //static void focusItem(void* data, Evas_Object* obj, void* event_info); - //static void unFocusItem(void* data, Evas_Object* obj, void* event_info); - //static void _itemSelected(void * data, Evas_Object * obj, void * event_info); + Evas_Object *m_icon; }; } diff --git a/services/MoreMenuUI/edc/MoreMenu.edc b/services/MoreMenuUI/edc/MoreMenu.edc index e7b67a7..91dbe04 100644 --- a/services/MoreMenuUI/edc/MoreMenu.edc +++ b/services/MoreMenuUI/edc/MoreMenu.edc @@ -52,14 +52,13 @@ RESOURCE_IMAGE_LOSSY("ic_more_mobileview_foc.png") RESOURCE_IMAGE_LOSSY("ic_more_share_foc.png") RESOURCE_IMAGE_LOSSY("ic_more_setting_foc.png") RESOURCE_IMAGE_LOSSY("ic_more_exit_foc.png") -RESOURCE_IMAGE_LOSSY("favicon.png") #define WIDTH 1920 #define HEIGHT 366 #define ITEM_WIDTH 1200 group { - name: "elm/genlist/item/current_tab/default"; + name: "current_tab_layout"; min: WIDTH HEIGHT; max: WIDTH HEIGHT; images { @@ -332,8 +331,8 @@ RESOURCE_IMAGE_LOSSY("favicon.png") state: "default" 0.0; visible: 1; fixed: 1 1; - min: 216 36; - max: 216 36; + min: 1146 36; + max: 1146 36; align: 0 0.0; rel1 { relative: 0.0 0.0; to: "item_background"; offset: 98 0;} rel2 { relative: 1.0 1.0; to: "item_background";} @@ -362,8 +361,8 @@ RESOURCE_IMAGE_LOSSY("favicon.png") state: "default" 0.0; visible: 1; fixed: 1 1; - min: 765 27; - max: 765 27; + min: 1146 28; + max: 1146 28; align: 0 0; rel1 { relative: 0.0 0.0; to: "item_background"; offset: 98 51;} rel2 { relative: 1.0 1.0; to: "item_background";} @@ -371,7 +370,7 @@ RESOURCE_IMAGE_LOSSY("favicon.png") text { text: "http:/onet.pl"; font: "font_name"; - size: 27; + size: 28; align: 0 0.5; } } @@ -635,7 +634,7 @@ group { image: "web_shadow.png" COMP; } parts { - part { name: "genlist_bg"; + part { name: "current_tab_bar_bg"; type: RECT; mouse_events: 0; description { state: "default" 0.0; @@ -662,14 +661,14 @@ group { max: 1920 714; color: 231 231 231 255; rel1 { - relative: 0 1; to: "genlist_bg"; + relative: 0 1; to: "current_tab_bar_bg"; } rel2{ relative: 1 1; } } } - part { name: "elm.swallow.genlist"; + part { name: "current_tab_bar"; type : SWALLOW; scale: 1; description { @@ -679,7 +678,7 @@ group { max: 1920 366; align: 0.0 0.0; fixed: 0 0; - rel1 { relative: 0.0 0.0; to: "genlist_bg";} + rel1 { relative: 0.0 0.0; to: "current_tab_bar_bg";} rel2 { relative: 1.0 1.0; } } description { diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 7d8e1fa..1bb4e66 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -263,8 +263,6 @@ int SimpleUI::exec(const std::string& _url) m_webEngine->confirmationRequest.connect(boost::bind(&SimpleUI::handleConfirmationRequest, this, _1)); m_webEngine->tabCreated.connect(boost::bind(&SimpleUI::tabCreated, this)); m_webEngine->tabClosed.connect(boost::bind(&SimpleUI::tabClosed,this,_1)); - m_webEngine->favIconChanged.connect(boost::bind(&SimpleURI::setFavIcon, m_simpleURI.get(), _1)); - m_webEngine->favIconChanged.connect(boost::bind(&WebTitleBar::setFavIcon, webTitleBar.get(), _1)); m_webEngine->titleChanged.connect(boost::bind(&WebTitleBar::show, webTitleBar.get(), _1)); m_webEngine->IMEStateChanged.connect(boost::bind(&SimpleUI::setwvIMEStatus, this, _1)); @@ -776,10 +774,6 @@ void SimpleUI::loadFinished() addBookmarkEnable(m_favoriteService->countBookmarksAndSubFolders() < m_favoritesLimit); - if(m_simpleURI->getCurrentIconTyep() != SimpleURI::IconTypeFav){ - m_simpleURI->setFavIcon(m_webEngine->getFavicon()); - webTitleBar->setFavIcon(m_webEngine->getFavicon()); - } if(m_webEngine->isLoadError()){ loadError(); } @@ -1139,32 +1133,39 @@ void SimpleUI::showMoreMenu() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); bool current_tab_as_new_tab = isHomePageActive() || (m_historyService->getHistoryItemsCount() == 0); - if (!m_moreMenuUI) { - m_moreMenuUI = std::dynamic_pointer_cast - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.moremenuui")); + if(!m_moreMenuUI){ + m_moreMenuUI = + std::dynamic_pointer_cast + + (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.moremenuui")); M_ASSERT(m_moreMenuUI); - + m_webEngine->favIconChanged.disconnect_all_slots(); + m_webEngine->favIconChanged.connect(boost::bind(&MoreMenuUI::setFavIcon, m_moreMenuUI.get(), _1)); + m_webEngine->titleChanged.disconnect_all_slots(); + m_webEngine->titleChanged.connect(boost::bind(&MoreMenuUI::setWebTitle, m_moreMenuUI.get(), _1)); + m_webEngine->uriChanged.disconnect_all_slots(); + m_webEngine->uriChanged.connect(boost::bind(&MoreMenuUI::setURL, m_moreMenuUI.get(), _1)); m_moreMenuUI->bookmarkManagerClicked.connect(boost::bind(&SimpleUI::onBookmarkManagerButtonClicked, this, _1)); - m_moreMenuUI->historyUIClicked.connect(boost::bind(&SimpleUI::showHistoryUI, this, _1)); - m_moreMenuUI->settingsClicked.connect(boost::bind(&SimpleUI::showSettingsUI, this, _1)); - m_moreMenuUI->closeMoreMenuClicked.disconnect_all_slots(); - m_moreMenuUI->closeMoreMenuClicked.connect(boost::bind(&SimpleUI::closeMoreMenu, this, _1)); - m_moreMenuUI->addToBookmarkClicked.disconnect_all_slots(); + m_moreMenuUI->historyUIClicked.connect(boost::bind(&SimpleUI::showHistoryUI, this,_1)); + m_moreMenuUI->settingsClicked.connect(boost::bind(&SimpleUI::showSettingsUI, this,_1)); + m_moreMenuUI->closeMoreMenuClicked.connect(boost::bind(&SimpleUI::closeMoreMenu, this,_1)); m_moreMenuUI->addToBookmarkClicked.connect(boost::bind(&SimpleUI::addBookmarkFolders, this)); - m_moreMenuUI->AddBookmarkInput.disconnect_all_slots(); - m_moreMenuUI->AddBookmarkInput.connect(boost::bind(&SimpleUI::addToBookmarks, this, _1)); - m_moreMenuUI->BookmarkFolderCreated.disconnect_all_slots(); - m_moreMenuUI->BookmarkFolderCreated.connect(boost::bind(&SimpleUI::newFolderMoreMenu, this, _1, _2)); + m_moreMenuUI->AddBookmarkInput.connect(boost::bind(&SimpleUI::addToBookmarks, this,_1)); + m_moreMenuUI->BookmarkFolderCreated.connect(boost::bind(&SimpleUI::newFolderMoreMenu, this,_1,_2)); + m_moreMenuUI->show(m_window.get()); - m_moreMenuUI->showCurrentTab(current_tab_as_new_tab ? nullptr : m_historyService->getCurrentTab()); + m_moreMenuUI->showCurrentTab(); + m_moreMenuUI->setFavIcon(m_webEngine->getFavicon()); + m_moreMenuUI->setWebTitle(m_webEngine->getTitle()); + m_moreMenuUI->setURL(m_webEngine->getURI()); BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); } } void SimpleUI::closeMoreMenu(const std::string& str) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_moreMenuUI.reset() ; + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_moreMenuUI.reset(); } void SimpleUI::showBookmarkManagerMenu() diff --git a/services/WebKitEngineService/WebView.cpp b/services/WebKitEngineService/WebView.cpp index 89ef166..f634541 100644 --- a/services/WebKitEngineService/WebView.cpp +++ b/services/WebKitEngineService/WebView.cpp @@ -210,7 +210,7 @@ std::string WebView::getURI(void) { #if defined(USE_EWEBKIT) BROWSER_LOGD("%s:%d %s uri=%s", __FILE__, __LINE__, __func__, ewk_view_url_get(m_ewkView)); - return tizen_browser::tools::fromChar(ewk_view_url_get(m_ewkView)); + return fromChar(ewk_view_url_get(m_ewkView)); #else return std::string(); #endif @@ -427,14 +427,14 @@ void WebView::confirmationResult(WebConfirmationPtr confirmation) #endif } -std::shared_ptr WebView::captureSnapshot(int targetWidth, int targetHeight) +std::shared_ptr WebView::captureSnapshot(int targetWidth, int targetHeight) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); M_ASSERT(m_ewkView); M_ASSERT(targetWidth); M_ASSERT(targetHeight); Evas_Coord vw, vh; - std::shared_ptr noImage = std::make_shared(); + std::shared_ptr noImage = std::make_shared(); evas_object_geometry_get(m_ewkView, nullptr, nullptr, &vw, &vh); if (vw == 0 || vh == 0) return noImage; @@ -465,7 +465,7 @@ std::shared_ptr WebView::captureSnapshot(int Evas_Object *snapshot = ewk_view_screenshot_contents_get( m_ewkView, area, 1.0, evas_object_evas_get(m_ewkView)); BROWSER_LOGD("[%s:%d] Snapshot (screenshot) catched, evas pointer: %p",__func__, __LINE__, snapshot); if (snapshot) - return tizen_browser::tools::EflTools::getBrowserImage(snapshot); + return EflTools::getBrowserImage(snapshot); #endif #endif @@ -594,7 +594,7 @@ void WebView::__titleChanged(void * data, Evas_Object * obj, void * /* event_inf BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); WebView * self = reinterpret_cast(data); - self->m_title = tizen_browser::tools::fromChar(ewk_view_title_get(obj)); + self->m_title = fromChar(ewk_view_title_get(obj)); self->titleChanged(self->m_title); } @@ -609,7 +609,7 @@ void WebView::__urlChanged(void * data, Evas_Object * /* obj */, void * event_in m_webEngine = std::dynamic_pointer_cast, tizen_browser::core::AbstractService>( tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webkitengineservice")); M_ASSERT(m_webEngine); - self->uriChanged(tizen_browser::tools::fromChar(reinterpret_cast(event_info))); + self->uriChanged(fromChar(reinterpret_cast(event_info))); self->tabIdChecker(self->m_tabId); } @@ -630,7 +630,7 @@ void WebView::__faviconChanged(void* data, Evas_Object*, void*) Evas_Object * favicon = ewk_context_icon_database_icon_object_add(ewk_view_context_get(self->m_ewkView), ewk_view_url_get(self->m_ewkView),evas_object_evas_get(self->m_ewkView)); if (favicon) { BROWSER_LOGD("[%s:%d] Favicon received", __PRETTY_FUNCTION__, __LINE__); - self->faviconImage = tizen_browser::tools::EflTools::getBrowserImage(favicon); + self->faviconImage = EflTools::getBrowserImage(favicon); evas_object_unref(favicon); self->favIconChanged(self->faviconImage); } @@ -653,8 +653,8 @@ void WebView::__IMEOpened(void* data, Evas_Object*, void*) std::string WebView::securityOriginToUri(const Ewk_Security_Origin *origin) { - std::string protocol = tizen_browser::tools::fromChar(ewk_security_origin_protocol_get(origin)); - std::string uri = tizen_browser::tools::fromChar(ewk_security_origin_host_get(origin)); + std::string protocol = fromChar(ewk_security_origin_protocol_get(origin)); + std::string uri = fromChar(ewk_security_origin_host_get(origin)); std::string url = (boost::format("%1%://%2%") % protocol % uri).str(); return url; } @@ -831,42 +831,21 @@ const TabId& WebView::getTabId(){ } -std::shared_ptr WebView::getFavicon() { +std::shared_ptr WebView::getFavicon() +{ BROWSER_LOGD("%s:%d, TabId: %s", __PRETTY_FUNCTION__, __LINE__, m_tabId.toString().c_str()); - M_ASSERT(m_ewkView); - -#if defined(USE_EWEBKIT) - if (faviconImage.get() == NULL) { - - if (m_ewkView) - { - Ewk_Context *context = ewk_view_context_get(m_ewkView); - if (context) - { - Evas_Object * favicon = ewk_context_icon_database_icon_object_add(context, ewk_view_url_get(m_ewkView), evas_object_evas_get(m_ewkView)); - -#ifndef NDEBUG - int w = 0, h = 0; - evas_object_image_size_get(favicon, &w, &h); - BROWSER_LOGD("[%s]: Info about favicon: w:%d h:%d, type: %s", __func__, w, h, evas_object_type_get(favicon)); -#endif - if (favicon) { - std::shared_ptr - image = tizen_browser::tools::EflTools::getBrowserImage(favicon); + if(faviconImage.get()) + return faviconImage; - evas_object_unref(favicon); + Evas_Object * favicon = ewk_context_icon_database_icon_object_add(ewk_view_context_get(m_ewkView), ewk_view_url_get(m_ewkView),evas_object_evas_get(m_ewkView)); + faviconImage = EflTools::getBrowserImage(favicon); + evas_object_unref(favicon); - return image; - } - } else { - return faviconImage; - } - } - } -#endif + if(faviconImage.get()) + return faviconImage; - BROWSER_LOGE("[%s:%d]: Returned favicon is empty!", __PRETTY_FUNCTION__, __LINE__); - return std::make_shared(); + BROWSER_LOGD("[%s:%d] Returned favicon is empty!", __PRETTY_FUNCTION__, __LINE__); + return std::make_shared(); } void WebView::clearPrivateData() -- 2.7.4 From 27a095d96a93287ed3a444852d54c0b31b4c9209 Mon Sep 17 00:00:00 2001 From: Albert Malewski Date: Thu, 27 Aug 2015 14:12:36 +0200 Subject: [PATCH 04/16] Fixed creating history list [Issue#] https://bugs.tizen.org/jira/browse/TT-156 [Problem] There is at most 5 items visible in history and the list is not updated. [Cause] There was used getMostVisitedHistoryItems function to generate history list. [Solution] Added several functions in HistoryService to get history list: getHistoryAll, getHistoryToday, getHistoryYesterday, getHistoryLastWeek, getHistoryLastMonth, getHistoryOlder. [Verify] Launch browser > More Menu > History > Obs History should not crash after clicking on 'History' button. Change-Id: I1dde7088555a4cdba01e92be78c3dda5276040c4 --- services/HistoryService/HistoryService.cpp | 37 ++++++++++++++++++++++++++---- services/HistoryService/HistoryService.h | 8 ++++++- services/SimpleUI/SimpleUI.cpp | 11 ++++++--- services/SimpleUI/SimpleUI.h | 1 + 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/services/HistoryService/HistoryService.cpp b/services/HistoryService/HistoryService.cpp index 2a9db4f..abccfc5 100644 --- a/services/HistoryService/HistoryService.cpp +++ b/services/HistoryService/HistoryService.cpp @@ -126,6 +126,7 @@ bool isDuplicate(const char* title) int freq; bp_history_adaptor_get_frequency(ids[i], &freq); bp_history_adaptor_set_frequency(ids[i], freq + 1); + bp_history_adaptor_set_date_visited(ids[i],-1); return true; } } @@ -133,6 +134,34 @@ bool isDuplicate(const char* title) } +std::shared_ptr HistoryService::getHistoryAll() +{ + return getHistoryItems(BP_HISTORY_DATE_ALL); +} + +std::shared_ptr HistoryService::getHistoryToday() +{ + return getHistoryItems(BP_HISTORY_DATE_TODAY); +} + +std::shared_ptr HistoryService::getHistoryYesterday() +{ + return getHistoryItems(BP_HISTORY_DATE_YESTERDAY); +} + +std::shared_ptr HistoryService::getHistoryLastWeek() +{ + return getHistoryItems(BP_HISTORY_DATE_LAST_7_DAYS); +} + +std::shared_ptr HistoryService::getHistoryLastMonth() +{ + return getHistoryItems(BP_HISTORY_DATE_LAST_MONTH); +} +std::shared_ptr HistoryService::getHistoryOlder() +{ + return getHistoryItems(BP_HISTORY_DATE_OLDER); +} std::shared_ptr HistoryService::getMostVisitedHistoryItems() { @@ -319,7 +348,7 @@ void HistoryService::clearURLHistory(const std::string & url) std::shared_ptr HistoryService::getHistoryItem(int * ids, int idNumber) { - bp_history_offset offset = (BP_HISTORY_O_URL | BP_HISTORY_O_TITLE | BP_HISTORY_O_FAVICON | BP_HISTORY_O_DATE_CREATED); + bp_history_offset offset = (BP_HISTORY_O_URL | BP_HISTORY_O_TITLE | BP_HISTORY_O_FAVICON | BP_HISTORY_O_DATE_VISITED); bp_history_info_fmt history_info; bp_history_adaptor_get_info(ids[idNumber], offset, &history_info); @@ -370,7 +399,7 @@ std::shared_ptr HistoryService::getCurrentTab() conds.offset = -1; //the first row's index conds.order_offset = BP_HISTORY_O_DATE_VISITED; // property to sort conds.ordering = 1; //way of ordering 0 asc 1 desc - conds.period_offset = BP_HISTORY_O_DATE_CREATED; + conds.period_offset = BP_HISTORY_O_DATE_VISITED; conds.period_type = BP_HISTORY_DATE_TODAY; int ret = bp_history_adaptor_get_cond_ids_p(&ids , &count, &conds, 0, nullptr, 0); @@ -381,7 +410,7 @@ std::shared_ptr HistoryService::getCurrentTab() return getHistoryItem(ids); } -std::shared_ptr HistoryService::getHistoryItems(bp_history_date_defs period, int maxItems) +std::shared_ptr HistoryService::getHistoryItems(bp_history_date_defs period) { std::shared_ptr ret_history_list(new HistoryItemVector); @@ -392,7 +421,7 @@ std::shared_ptr HistoryService::getHistoryItems(bp_history_da conds.offset = -1; //the first row's index conds.order_offset = BP_HISTORY_O_DATE_VISITED; // property to sort conds.ordering = 1; //way of ordering 0 asc 1 desc - conds.period_offset = BP_HISTORY_O_DATE_CREATED; + conds.period_offset = BP_HISTORY_O_DATE_VISITED; conds.period_type = period; int ret = bp_history_adaptor_get_cond_ids_p(&ids ,&count, &conds, 0, nullptr, 0); diff --git a/services/HistoryService/HistoryService.h b/services/HistoryService/HistoryService.h index 966a37b..eb556ea 100644 --- a/services/HistoryService/HistoryService.h +++ b/services/HistoryService/HistoryService.h @@ -76,7 +76,12 @@ public: /** * @throws HistoryException on error */ - std::shared_ptr getHistoryItems(bp_history_date_defs period = BP_HISTORY_DATE_TODAY, int maxItems = 50); + std::shared_ptr getHistoryAll(); + std::shared_ptr getHistoryToday(); + std::shared_ptr getHistoryYesterday(); + std::shared_ptr getHistoryLastWeek(); + std::shared_ptr getHistoryLastMonth(); + std::shared_ptr getHistoryOlder(); std::shared_ptr getCurrentTab(); std::shared_ptr getMostVisitedHistoryItems(); @@ -108,6 +113,7 @@ private: void initDatabaseBookmark(const std::string & db_str); std::shared_ptr getHistoryItem(int* ids, int idNumber = 0); + std::shared_ptr getHistoryItems(bp_history_date_defs period = BP_HISTORY_DATE_TODAY); std::shared_ptr getStorageManager(); }; diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 1bb4e66..a04a815 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -108,11 +108,16 @@ std::vector > SimpleUI::g return m_favoriteService->getBookmarks(folder_id); } -std::shared_ptr SimpleUI::getHistory() +std::shared_ptr SimpleUI::getMostVisitedItems() { return m_historyService->getMostVisitedHistoryItems(); } +std::shared_ptr SimpleUI::getHistory() +{ + return m_historyService->getHistoryToday(); +} + std::vector > SimpleUI::getBookmarkFolders(int folder_id) { @@ -618,7 +623,7 @@ void SimpleUI::onMostVisitedClicked(const std::string&) BROWSER_LOGD("[%s]", __func__); m_mainUI->clearHistoryGenlist(); m_mainUI->clearBookmarkGengrid(); - m_mainUI->addHistoryItems(getHistory()); + m_mainUI->addHistoryItems(getMostVisitedItems()); m_mainUI->showHistory(); } @@ -1076,7 +1081,7 @@ void SimpleUI::showMainUI() M_ASSERT(m_mainUI); hideWebView(); m_mainUI->show(m_window.get()); - m_mainUI->addHistoryItems(getHistory()); + m_mainUI->addHistoryItems(getMostVisitedItems()); m_mainUI->addBookmarkItems(getBookmarks()); m_isHomePageActive = true; } diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index e4783dd..2f3b261 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -123,6 +123,7 @@ private: std::vector > getBookmarks(int folder_id = -1); std::vector > getBookmarkFolders(int folder_id); std::shared_ptr getHistory(); + std::shared_ptr getMostVisitedItems(); void onBookmarkAdded(std::shared_ptr bookmarkItem); void onBookmarkClicked(std::shared_ptr bookmarkItem); -- 2.7.4 From f1686d110e12a7bd5aa0fb9bc6a6655fc08e6568 Mon Sep 17 00:00:00 2001 From: Maciej Skrzypkowski Date: Fri, 28 Aug 2015 16:23:53 +0200 Subject: [PATCH 05/16] Added detail popup to most visited view. [Issue#] https://bugs.tizen.org/jira/browse/TT-144 [Problem] N/A [Cause] N/A [Solution] Create popup view. [Verify] Open most visited view, click on tile, check if new popup with history appears Change-Id: Ia8ecffbba4d93e7d759780cf49f35a2c03c87fda Signed-off-by: Maciej Skrzypkowski --- core/Tools/GeneralTools.h | 22 +++ services/HistoryService/HistoryService.cpp | 39 +++++ services/HistoryService/HistoryService.h | 1 + services/MainUI/CMakeLists.txt | 18 +- services/MainUI/DetailPopup.cpp | 121 ++++++++++++++ services/MainUI/DetailPopup.h | 79 +++++++++ services/MainUI/MainUI.cpp | 25 ++- services/MainUI/MainUI.h | 6 +- services/MainUI/edc/DetailPopup.edc | 260 +++++++++++++++++++++++++++++ services/SimpleUI/SimpleUI.cpp | 13 +- services/SimpleUI/SimpleUI.h | 3 +- 11 files changed, 564 insertions(+), 23 deletions(-) create mode 100644 services/MainUI/DetailPopup.cpp create mode 100644 services/MainUI/DetailPopup.h create mode 100644 services/MainUI/edc/DetailPopup.edc diff --git a/core/Tools/GeneralTools.h b/core/Tools/GeneralTools.h index 2f131e4..83382b5 100644 --- a/core/Tools/GeneralTools.h +++ b/core/Tools/GeneralTools.h @@ -15,6 +15,7 @@ */ #include +#include #ifndef __GENERALTOOLS_H__ #define __GENERALTOOLS_H__ @@ -23,8 +24,29 @@ namespace tizen_browser { namespace tools { + static const int SUFIX_CHAR_DEL = 1; + static const char * PROTCOL_BEGIN = "://"; + static const char END_SLASH = '/'; + + // declaration using 'unused' attribute because in some modules not all functions are used + static std::string fromChar(const char* c) __attribute__ ((unused)); + static char * clearURL(const std::string & url) __attribute__ ((unused)); + static std::string extractDomain(const std::string & url) __attribute__ ((unused)); + static std::string fromChar(const char* c) { return c ? std::string(c) : std::string(); } + static char * clearURL(const std::string & url) { + size_t beg = url.find(PROTCOL_BEGIN); + beg += strlen(PROTCOL_BEGIN); + return strdup(url.substr(beg, url.size() - beg - SUFIX_CHAR_DEL).c_str()); + } + + static std::string extractDomain(const std::string & url) { + size_t beg = url.find(PROTCOL_BEGIN); + beg += strlen(PROTCOL_BEGIN); + size_t end = url.find(END_SLASH, beg); + return url.substr(beg, end - beg); + } } } diff --git a/services/HistoryService/HistoryService.cpp b/services/HistoryService/HistoryService.cpp index abccfc5..021c1e5 100644 --- a/services/HistoryService/HistoryService.cpp +++ b/services/HistoryService/HistoryService.cpp @@ -26,6 +26,7 @@ #include "HistoryItem.h" #include "AbstractWebEngine.h" #include "EflTools.h" +#include "Tools/GeneralTools.h" @@ -37,6 +38,8 @@ namespace services EXPORT_SERVICE(HistoryService, DOMAIN_HISTORY_SERVICE) +const int SEARCH_LIKE = 1; + HistoryService::HistoryService() : m_testDbMod(false) { BROWSER_LOGD("HistoryService"); @@ -243,6 +246,42 @@ std::shared_ptr HistoryService::getMostVisitedHistoryItems() return ret_history_list; } +std::shared_ptr HistoryService::getHistoryItemsByURL(const std::string& url, int maxItems) +{ + std::string search("%" + tools::extractDomain(url) + "%"); // add SQL 'any character' signs + + std::shared_ptr items(new HistoryItemVector); + int *ids=nullptr; + int count=-1; + bp_history_rows_cond_fmt conds; + conds.limit = maxItems; //no of rows to get negative means no limitation + conds.offset = -1; //the first row's index + conds.order_offset = BP_HISTORY_O_DATE_VISITED; // property to sort + conds.ordering = 1; //way of ordering 0 asc 1 desc + conds.period_offset = BP_HISTORY_O_DATE_VISITED; + conds.period_type = BP_HISTORY_DATE_ALL; + + int ret = bp_history_adaptor_get_cond_ids_p(&ids ,&count, &conds, BP_HISTORY_O_URL, search.c_str(), SEARCH_LIKE); + if (ret < 0) { + BROWSER_LOGD("Error! Could not get ids!"); + return items; + } + + bp_history_offset offset = (BP_HISTORY_O_URL | BP_HISTORY_O_TITLE | BP_HISTORY_O_DATE_VISITED); + for(int i = 0; i < count; i++) { + bp_history_info_fmt history_info; + bp_history_adaptor_get_info(ids[i], offset, &history_info); + + std::shared_ptr history = std::make_shared(std::string(history_info.url)); + history->setTitle(std::string(history_info.title ? history_info.title : "")); + + items->push_back(history); + } + + free(ids); + return items; +} + void HistoryService::addHistoryItem(std::shared_ptr his,std::shared_ptr thumbnail){ BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); his->setFavIcon(his->getFavIcon()); diff --git a/services/HistoryService/HistoryService.h b/services/HistoryService/HistoryService.h index eb556ea..f6fc91c 100644 --- a/services/HistoryService/HistoryService.h +++ b/services/HistoryService/HistoryService.h @@ -84,6 +84,7 @@ public: std::shared_ptr getHistoryOlder(); std::shared_ptr getCurrentTab(); std::shared_ptr getMostVisitedHistoryItems(); + std::shared_ptr getHistoryItemsByURL(const std::string & url, int maxItems); /** * @throws HistoryException on error diff --git a/services/MainUI/CMakeLists.txt b/services/MainUI/CMakeLists.txt index fd1710f..e12fb69 100644 --- a/services/MainUI/CMakeLists.txt +++ b/services/MainUI/CMakeLists.txt @@ -2,10 +2,12 @@ project(MainUI) set(MainUI_SRCS MainUI.cpp + DetailPopup.cpp ) set(MainUI_HEADERS MainUI.h + DetailPopup.h ) include(Coreheaders) @@ -23,7 +25,15 @@ install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION services ARCHIVE DESTINATION services/static) -include(EDCCompile) -EDJ_TARGET(MainUI.edj - ${CMAKE_CURRENT_SOURCE_DIR}/edc/MainUI.edc - ${CMAKE_CURRENT_BINARY_DIR}) +#please do not add edc/ directory +set(edcFiles + MainUI.edc + DetailPopup.edc + ) + +foreach(edec ${edcFiles}) + string(REPLACE ".edc" ".edj" target_name ${edec}) + EDJ_TARGET(${target_name} + ${CMAKE_CURRENT_SOURCE_DIR}/edc/${edec} + ${CMAKE_CURRENT_BINARY_DIR}) +endforeach(edec) diff --git a/services/MainUI/DetailPopup.cpp b/services/MainUI/DetailPopup.cpp new file mode 100644 index 0000000..f3d2ced --- /dev/null +++ b/services/MainUI/DetailPopup.cpp @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include +#include "BrowserAssert.h" +#include "DetailPopup.h" +#include "BrowserLogger.h" +#include "Tools/GeneralTools.h" +#include "MainUI.h" + +namespace tizen_browser{ +namespace base_ui{ + +const int DetailPopup::HISTORY_ITEMS_NO = 5; + +DetailPopup::DetailPopup(MainUI *mainUI) + : m_layout(nullptr) + , m_historyList(nullptr) + , m_mainUI(mainUI) +{ + edjFilePath = EDJE_DIR; + edjFilePath.append("MainUI/DetailPopup.edj"); + elm_theme_extension_add(nullptr, edjFilePath.c_str()); + + m_history_item_class = elm_genlist_item_class_new(); + m_history_item_class->item_style = "history_grid_item"; + m_history_item_class->func.text_get = _get_history_link_text; + m_history_item_class->func.content_get = nullptr; + m_history_item_class->func.state_get = nullptr; + m_history_item_class->func.del = nullptr; +} + +DetailPopup::~DetailPopup() +{ + elm_genlist_item_class_free(m_history_item_class); +} + +void DetailPopup::createLayout(Evas_Object *parent) +{ + m_layout = elm_layout_add(parent); + elm_layout_file_set(m_layout, edjFilePath.c_str(), "popup"); + evas_object_size_hint_weight_set(m_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + // TODO: add following (or simillar) callback for hardware back button when it will be available + //evas_object_event_callback_add(m_layout, EVAS_CALLBACK_KEY_DOWN, _back, this); + edje_object_signal_callback_add(elm_layout_edje_get(m_layout), "mouse,clicked,1", "bg", _bg_click, this); + edje_object_signal_callback_add(elm_layout_edje_get(m_layout), "mouse,clicked,1", "url_over", _url_click, this); + edje_object_signal_callback_add(elm_layout_edje_get(m_layout), "mouse,clicked,1", "thumbnail", _url_click, this); + elm_layout_text_set(m_layout, "history_title", "History"); + elm_layout_text_set(m_layout, "url", tools::clearURL(m_item->getUrl())); + m_historyList = elm_genlist_add(m_layout); + evas_object_size_hint_weight_set(m_historyList, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_historyList, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(m_historyList); + elm_object_part_content_set(m_layout, "history_list", m_historyList); + + for (auto it = m_prevItems->begin(); it != m_prevItems->end(); ++it) { + elm_genlist_item_append(m_historyList, m_history_item_class, it->get(), nullptr, ELM_GENLIST_ITEM_NONE, nullptr, this); + } + + evas_object_show(m_layout); +} + + +void DetailPopup::show(Evas_Object *parent, std::shared_ptr currItem, std::shared_ptr prevItems) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_item = currItem; + m_prevItems = prevItems; + createLayout(parent); +} + +void DetailPopup::hide() +{ + evas_object_hide(m_layout); +} + +void DetailPopup::_bg_click(void* data, Evas_Object* obj, const char* emission, const char* source) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + DetailPopup *dp = reinterpret_cast(data); + dp->hide(); +} + +void DetailPopup::_url_click(void* data, Evas_Object* obj, const char* emission, const char* source) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + DetailPopup *dp = reinterpret_cast(data); + dp->hide(); + dp->m_mainUI->openURLInNewTab(dp->m_item); +} + +char* DetailPopup::_get_history_link_text(void* data, Evas_Object* obj, const char* part) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + services::HistoryItem *item = reinterpret_cast(data); + if (!strcmp(part, "page_dsc")) { + if (item != nullptr) { + return strdup(tools::clearURL(item->getUrl())); + } + } + return strdup(""); +} + +} +} \ No newline at end of file diff --git a/services/MainUI/DetailPopup.h b/services/MainUI/DetailPopup.h new file mode 100644 index 0000000..8d24a51 --- /dev/null +++ b/services/MainUI/DetailPopup.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __DETAIL_POPUP_H__ +#define __DETAIL_POPUP_H__ + +#include +#include +#include +#include +#include "services/HistoryService/HistoryItem.h" + +namespace tizen_browser{ +namespace base_ui{ + + class MainUI; + + class DetailPopup { + public: + DetailPopup(MainUI *mainUI); + ~DetailPopup(); + + /** + * @brief Show popup window + */ + void show(Evas_Object *parent, std::shared_ptr currItem, std::shared_ptr prevItems); + + boost::signals2::signal)> openURLInNewTab; + + static const int HISTORY_ITEMS_NO; + private: + /** + * @brief Mouse background click callback + */ + static void _bg_click(void *data, Evas_Object *obj, const char *emission, const char *source); + + /** + * @brief URL rectangle click callback + */ + static void _url_click(void *data, Evas_Object *obj, const char *emission, const char *source); + + /** + * @brief Hide popup + */ + void hide(); + + void createLayout(Evas_Object *parent); + + /** + * @brief Provide texts for history genlist + */ + static char* _get_history_link_text(void *data, Evas_Object *obj, const char *part); + + Evas_Object *m_layout; + Evas_Object *m_historyList; + Elm_Gengrid_Item_Class * m_history_item_class; + MainUI *m_mainUI; + std::string edjFilePath; + std::shared_ptr m_item; + std::shared_ptr m_prevItems; + }; + +} +} + +#endif // __DETAIL_POPUP_H__ diff --git a/services/MainUI/MainUI.cpp b/services/MainUI/MainUI.cpp index e011d46..1657295 100644 --- a/services/MainUI/MainUI.cpp +++ b/services/MainUI/MainUI.cpp @@ -24,6 +24,7 @@ #include "BrowserLogger.h" #include "Tools/EflTools.h" #include "../Tools/BrowserImage.h" +#include "Tools/GeneralTools.h" #define efl_scale (elm_config_scale_get() / elm_app_base_scale_get()) @@ -32,9 +33,6 @@ namespace base_ui{ const int SMALL_TILES_ROWS = 2; const int MAX_TILES_NUMBER = 5; -const int SUFIX_CHAR_DEL = 1; -const char * HTTP_PREFIX = "http://"; -const char * HTTPS_PREFIX = "https://"; EXPORT_SERVICE(MainUI, "org.tizen.browser.mainui") @@ -70,6 +68,7 @@ MainUI::MainUI() , m_big_item_class(nullptr) , m_small_item_class(nullptr) , m_bookmark_item_class(nullptr) + , m_detailPopup(this) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); edjFilePath = EDJE_DIR; @@ -365,14 +364,7 @@ char* MainUI::_grid_text_get(void *data, Evas_Object *obj, const char *part) return strdup(itemData->item->getTitle().c_str()); } if (!strcmp(part, "page_url")) { - if (itemData->item->getUrl().find(HTTPS_PREFIX) == 0) { - size_t len = strlen(HTTPS_PREFIX); - return strdup(itemData->item->getUrl().substr(len, itemData->item->getUrl().size() - len - SUFIX_CHAR_DEL).c_str()); // remove https prefix - } else if (itemData->item->getUrl().find(HTTP_PREFIX) == 0) { - size_t len = strlen(HTTP_PREFIX); - return strdup(itemData->item->getUrl().substr(len, itemData->item->getUrl().size() - len - SUFIX_CHAR_DEL).c_str()); // remove http prefix - } - return strdup(itemData->item->getUrl().c_str()); + return tools::clearURL(itemData->item->getUrl()); } return strdup(""); } @@ -442,13 +434,13 @@ void MainUI::_itemSelected(void * data, Evas_Object * /* obj */, void * event_in HistoryItemData * itemData = reinterpret_cast(elm_object_item_data_get(selected)); MainUI * self = reinterpret_cast(data); - self->historyClicked(itemData->item); + self->openURLInNewTab(itemData->item); } void MainUI::_thumbSelected(void * data, Evas_Object * /* obj */, void * /* event_info */) { - HistoryItemData * itemData = reinterpret_cast(data); - itemData->mainUI->historyClicked(itemData->item); + HistoryItemData * itemData = reinterpret_cast(data); + itemData->mainUI->mostVisitedTileClicked(itemData->item, DetailPopup::HISTORY_ITEMS_NO); } void MainUI::clearHistoryGenlist() @@ -525,6 +517,11 @@ void MainUI::clearItems() clearBookmarkGengrid(); } +void MainUI::openDetailPopup(std::shared_ptr currItem, std::shared_ptr prevItems) +{ + m_detailPopup.show(m_layout, currItem, prevItems); +} + void MainUI::showNoHistoryLabel() { evas_object_hide(elm_object_part_content_get(m_mostVisitedView, "elm.swallow.left")); diff --git a/services/MainUI/MainUI.h b/services/MainUI/MainUI.h index 6809fd0..4ec341a 100644 --- a/services/MainUI/MainUI.h +++ b/services/MainUI/MainUI.h @@ -26,6 +26,7 @@ #include "service_macros.h" #include "services/HistoryService/HistoryItem.h" #include "BookmarkItem.h" +#include "DetailPopup.h" namespace tizen_browser{ namespace base_ui{ @@ -47,13 +48,15 @@ public: void showHistory(); void showBookmarks(); void clearItems(); + void openDetailPopup(std::shared_ptr currItem, std::shared_ptr prevItems); void addHistoryItem(std::shared_ptr); void addHistoryItems(std::shared_ptr); void addBookmarkItem(std::shared_ptr); void addBookmarkItems(std::vector >); - boost::signals2::signal)> historyClicked; + boost::signals2::signal)> openURLInNewTab; + boost::signals2::signal, int)> mostVisitedTileClicked; boost::signals2::signal mostVisitedClicked; boost::signals2::signal bookmarkClicked; boost::signals2::signal bookmarkManagerClicked; @@ -96,6 +99,7 @@ private: Elm_Gengrid_Item_Class * m_small_item_class; Elm_Gengrid_Item_Class * m_bookmark_item_class; + DetailPopup m_detailPopup; std::multimap m_map_history_views; std::map m_map_bookmark_views; bool m_gengridSetup; diff --git a/services/MainUI/edc/DetailPopup.edc b/services/MainUI/edc/DetailPopup.edc new file mode 100644 index 0000000..5a2ea1b --- /dev/null +++ b/services/MainUI/edc/DetailPopup.edc @@ -0,0 +1,260 @@ +collections { + + group { + name: "popup"; + + parts { + part { name: "bg"; + type: RECT; + mouse_events: 1; + description { state: "default" 0.0; + color: 0 0 0 102; + visible: 1; + min: 1920 1080; + max: -1 -1; + align: 0.0 0.0; + rel1 { + relative: 0.0 0.0; + } + rel2 { + relative: 1.0 1.0; + } + } + } + + part { name: "main_rect"; + type: RECT; + mouse_events: 1; + description { state: "default" 0.0; + color: 255 255 255 255; + min: 1336 648; + max: 1336 648; + visible: 1; + align: 0.5 0.0; + rel1 { + to: "bg"; + offset: 0 264; + relative: 0.0 0.0; + } + rel2 { + to: "bg"; + relative: 1.0 1.0; + } + } + } + + part { name: "thumbnail"; + //type: SWALLOW; TODO: change to swallow while adding thumbnail to Detail popup + type: RECT; + description { + color: 113 128 147 255; + min: 840 648; + max: 840 648; + visible: 1; + align: 0.0 0.0; + rel1 { + to: "main_rect"; + relative: 0.0 0.0; + } + rel2 { + to: "main_rect"; + relative: 1.0 1.0; + } + } + } + + part { name: "url_bg"; + type: RECT; + description { state: "default" 0.0; + color: 255 255 255 255; + min: 496 122; + max: 496 122; + visible: 1; + align: 0.0 0.0; + rel1 { + to: "thumbnail"; + relative: 1.0 0.0; + } + rel2 { + to: "main_rect"; + relative: 1.0 1.0; + } + } + description { state: "selected" 0.0; + inherit: "default" 0.0; + color: 0 119 246 255; + } + } + + part { name: "url"; + type: TEXT; + description { + visible: 1; + min: 428 122; + max: 428 122; + align: 0.0 0.0; + fixed: 1 1; + color: 51 51 51 255; + rel1 { + to: "url_bg"; + relative: 0.0 0.0; + offset: 34 0; + } + rel2 { + to: "url_bg"; + relative: 1.0 1.0; + } + text { + text: "Web page title"; + font: "Sans"; + size: 32; + align: 0 0.5; + } + } + description { state: "selected" 0.0; + inherit: "default" 0.0; + color: 255 255 255 255; + } + } + + part { name: "url_over"; + type: RECT; + mouse_events: 1; + repeat_events: 1; + description { state: "default" 0.0; + visible: 1; + color: 0 0 0 0; + rel1.to: "url_bg"; + rel2.to: "url_bg"; + } + } + + part { name: "history_title_bg"; + type: RECT; + description { + color: 244 244 244 255; + min: 496 44; + max: 496 44; + visible: 1; + align: 0.0 0.0; + rel1 { + to: "url_bg"; + relative: 0.0 1.0; + } + rel2 { + to: "main_rect"; + relative: 1.0 1.0; + } + } + } + + part { name: "history_title"; + type: TEXT; + description { + visible: 1; + min: 428 44; + max: 428 44; + align: 0.0 0.0; + fixed: 1 1; + color: 51 51 51 255; + rel1 { + to: "history_title_bg"; + relative: 0.0 0.0; + offset: 34 0; + } + rel2 { + to: "history_title_bg"; + relative: 1.0 1.0; + } + text { + text: "Web page title"; + font: "Sans"; + size: 22; + align: 0 0.5; + } + } + } + + part { name: "history_list"; + type: SWALLOW; + description { + color: 255 255 255 255; + min: 496 460; + max: 496 460; + visible: 1; + align: 0.0 0.0; + rel1 { + to: "history_title_bg"; + relative: 0.0 1.0; + offset: 0 22; + } + rel2 { + to: "main_rect"; + relative: 1.0 1.0; + } + } + } + } + + programs { + program { + name: "mouse_in_url"; + signal: "mouse,in"; + source: "url_over"; + action: STATE_SET "selected" 0.0; + target: "url_bg"; + target: "url"; + } + program { + name: "mouse_out_url"; + signal: "mouse,out"; + source: "url_over"; + action: STATE_SET "default" 0.0; + target: "url_bg"; + target: "url"; + } + } + } + + group { name: "elm/genlist/item/history_grid_item/default"; + data.item: "texts" "page_dsc"; + parts { + part { name: "bg"; + type: RECT; + mouse_events: 1; + description { state: "default" 0.0; + min: 496 86; + max: 496 86; + visible: 1; + color: 255 255 255 255; + align: 0.0 0.0; + } + } + + part { name: "page_dsc"; + type: TEXT; + description { state: "default" 0.0; + min: 428 86; + max: 428 86; + align: 0.0 0.0; + color: 0 0 0 255; + rel1 { + to: "bg"; + relative: 0.0 0.0; + offset: 34 0; + } + rel2 { + to: "bg"; + relative: 1.0 1.0; + } + text { + font: "Sans"; + size: 24; + align: 0 0.5; + } + } + } + + } + } +} \ No newline at end of file diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index a04a815..add69f3 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -308,7 +308,8 @@ int SimpleUI::exec(const std::string& _url) M_ASSERT(m_mainUI.get()); m_historyService->historyAllDeleted.connect(boost::bind(&tizen_browser::base_ui::MainUI::clearHistoryGenlist, m_mainUI.get())); - m_mainUI->historyClicked.connect(boost::bind(&SimpleUI::onHistoryClicked, this,_1)); + m_mainUI->openURLInNewTab.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this,_1)); + m_mainUI->mostVisitedTileClicked.connect(boost::bind(&SimpleUI::onMostVisitedTileClicked, this, _1, _2)); m_mainUI->mostVisitedClicked.connect(boost::bind(&SimpleUI::onMostVisitedClicked, this,_1)); m_mainUI->bookmarkClicked.connect(boost::bind(&SimpleUI::onBookmarkButtonClicked, this,_1)); m_mainUI->bookmarkManagerClicked.connect(boost::bind(&SimpleUI::onBookmarkManagerButtonClicked, this,_1)); @@ -595,7 +596,7 @@ void SimpleUI::onHistoryAdded(std::shared_ptr historyItem) +void SimpleUI::onOpenURLInNewTab(std::shared_ptr historyItem) { std::string historyAddress = historyItem->getUrl(); if(m_historyUI) { // TODO: remove this section when naviframes will be available @@ -610,6 +611,12 @@ void SimpleUI::onHistoryClicked(std::shared_ptr historyItem, int itemsNumber) +{ + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + m_mainUI->openDetailPopup(historyItem, m_historyService->getHistoryItemsByURL(historyItem->getUrl(), itemsNumber)); +} + void SimpleUI::onClearHistoryClicked(const std::string&) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); @@ -1095,7 +1102,7 @@ void SimpleUI::showHistoryUI(const std::string& str) M_ASSERT(m_historyUI); m_historyUI->clearHistoryClicked.connect(boost::bind(&SimpleUI::onClearHistoryClicked, this,_1)); m_historyUI->closeHistoryUIClicked.connect(boost::bind(&SimpleUI::closeHistoryUI, this,_1)); - m_historyUI->historyItemClicked.connect(boost::bind(&SimpleUI::onHistoryClicked, this,_1)); + m_historyUI->historyItemClicked.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this,_1)); m_historyUI->addHistoryItems(getHistory()); m_historyUI->show(m_window.get()); } diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index 2f3b261..82d03ee 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -132,7 +132,8 @@ private: void onHistoryAdded(std::shared_ptr historyItem); void onHistoryRemoved(const std::string& uri); - void onHistoryClicked(std::shared_ptr historyItem); + void onOpenURLInNewTab(std::shared_ptr historyItem); + void onMostVisitedTileClicked(std::shared_ptr historyItem, int itemsNumber); void onClearHistoryClicked(const std::string&); void onMostVisitedClicked(const std::string&); -- 2.7.4 From 9268130c9fd37150b47b7dc030917757928c0093 Mon Sep 17 00:00:00 2001 From: Maciej Skrzypkowski Date: Tue, 1 Sep 2015 09:28:14 +0200 Subject: [PATCH 06/16] Fixed not displaying thumbnails on Most visited screen. [Issue#] https://bugs.tizen.org/jira/browse/TT-73 [Problem] There was no thumbnails on main screen. [Cause] Website thumbnail was not saved and not fetched. [Solution] Added saving thumbnail on page finish loading and fetching it for Most visited screen. [Verify] Visit few different sites (wait until page is fully loaded) > open the Most visited screen, check if there are thumbnails. Change-Id: I8d8e648df0d1314fa772e5519ee07a06e795bc63 Signed-off-by: Maciej Skrzypkowski --- services/HistoryService/HistoryService.cpp | 7 ++----- services/MainUI/MainUI.cpp | 2 ++ services/MainUI/MainUI.h | 3 +++ services/SimpleUI/SimpleUI.cpp | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/services/HistoryService/HistoryService.cpp b/services/HistoryService/HistoryService.cpp index 021c1e5..e3d2a82 100644 --- a/services/HistoryService/HistoryService.cpp +++ b/services/HistoryService/HistoryService.cpp @@ -185,13 +185,10 @@ std::shared_ptr HistoryService::getMostVisitedHistoryItems() BROWSER_LOGD("Error! Could not get ids!"); } - bp_history_offset offset = (BP_HISTORY_O_URL | BP_HISTORY_O_TITLE | BP_HISTORY_O_FAVICON | BP_HISTORY_O_DATE_CREATED); + bp_history_offset offset = (BP_HISTORY_O_URL | BP_HISTORY_O_TITLE | BP_HISTORY_O_FAVICON | BP_HISTORY_O_DATE_CREATED | BP_HISTORY_O_THUMBNAIL); int freq_arr[1000]; for(int i = 0; i< count; i++){ - bp_history_info_fmt history_info; - bp_history_adaptor_get_info(ids[i],offset,&history_info); - int freq; if (0 == bp_history_adaptor_get_frequency(ids[i], &freq)) { @@ -232,7 +229,7 @@ std::shared_ptr HistoryService::getMostVisitedHistoryItems() //thumbail std::shared_ptr hi = std::make_shared(); - hi->imageType = tizen_browser::tools::BrowserImage::ImageType::ImageTypePNG; + hi->imageType = tools::BrowserImage::ImageTypePNG; hi->width = history_info.thumbnail_width; hi->height = history_info.thumbnail_height; hi->dataSize = history_info.thumbnail_length; diff --git a/services/MainUI/MainUI.cpp b/services/MainUI/MainUI.cpp index 1657295..74a2c52 100644 --- a/services/MainUI/MainUI.cpp +++ b/services/MainUI/MainUI.cpp @@ -33,6 +33,8 @@ namespace base_ui{ const int SMALL_TILES_ROWS = 2; const int MAX_TILES_NUMBER = 5; +const int MainUI::MAX_TILE_WIDTH = 784; +const int MainUI::MAX_TILE_HEIGHT = 498; EXPORT_SERVICE(MainUI, "org.tizen.browser.mainui") diff --git a/services/MainUI/MainUI.h b/services/MainUI/MainUI.h index 4ec341a..352051d 100644 --- a/services/MainUI/MainUI.h +++ b/services/MainUI/MainUI.h @@ -60,6 +60,9 @@ public: boost::signals2::signal mostVisitedClicked; boost::signals2::signal bookmarkClicked; boost::signals2::signal bookmarkManagerClicked; + + static const int MAX_TILE_WIDTH; + static const int MAX_TILE_HEIGHT; private: void createItemClasses(); diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index add69f3..6f0abe5 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -793,7 +793,7 @@ void SimpleUI::loadFinished() if(!m_webEngine->isPrivateMode()){ m_historyService->addHistoryItem(std::make_shared (m_webEngine->getURI(), m_webEngine->getTitle(), - m_webEngine->getFavicon())); + m_webEngine->getFavicon()), m_webEngine->getSnapshotData(MainUI::MAX_TILE_WIDTH, MainUI::MAX_TILE_HEIGHT)); } #if 0 if(!m_platformInputManager->getPointerModeEnabled()) -- 2.7.4 From 0e8109ef523ac8983822515d94c5119f73c0ca30 Mon Sep 17 00:00:00 2001 From: "t.dakowicz" Date: Thu, 27 Aug 2015 18:32:57 +0200 Subject: [PATCH 07/16] TT-106 Removed MoreMenu's tiles from BookmarkManager screen [Issue#] https://bugs.tizen.org/jira/browse/TT-106 [Problem] Tiles from MoreMenu was visible and accessible from BookmarkManager screen [Caused] Items were not cleared/hidden [Solution] This solution just clear those problematic items from MoreMenu - it should be removed after the new correct displaying design will be done [Verify] MoreMenu->BookmarkManager or MainUI->Bookmarks->BookmarkManager Check if any invisible tile is accessible or visible Change-Id: I371496d9befb64095721354f76fbb56d5fd18fc9 --- services/SimpleUI/SimpleUI.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 6f0abe5..14ce4b8 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -646,6 +646,14 @@ void SimpleUI::onBookmarkButtonClicked(const std::string&) void SimpleUI::onBookmarkManagerButtonClicked(const std::string&) { BROWSER_LOGD("[%s]", __func__); + if(m_mainUI) { // TODO: remove this section when naviframes will be available + m_mainUI->clearBookmarkGengrid(); + } + + if(m_moreMenuUI) { // TODO: remove this section when naviframes will be available + m_moreMenuUI->clearItems(); + } + showBookmarkManagerMenu(); } @@ -1217,6 +1225,16 @@ void SimpleUI::closeBookmarkManagerMenu(std::string& str) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); m_bookmarkManagerUI.reset(); + + if(m_moreMenuUI) { + m_moreMenuUI.reset(); + showMoreMenu(); + } + + if(m_mainUI) { + m_mainUI->addBookmarkItems(getBookmarks()); + m_mainUI->showBookmarks(); + } } void SimpleUI::openLinkFromPopup(const std::string &uri) -- 2.7.4 From bbeb9ac34df2c2e5afcbf395c3977be8fb4b6b95 Mon Sep 17 00:00:00 2001 From: Maciej Skrzypkowski Date: Thu, 3 Sep 2015 12:28:26 +0200 Subject: [PATCH 08/16] User agent set depending on browsing mode (desktop/mobile). [Issue#] https://bugs.tizen.org/jira/browse/TT-132 [Problem] Browising mode switching was not implemented. [Cause] N/A [Solution]Added changing user agent by using EWK API method: ewk_view_user_agent_set. [Verify] Open new page, go to google.com then settings > view mobile web then close settings, type in new URL google.com, it should appear in mobile mode. Change-Id: I8a6888d09b94f97eb51b9d2440f04bf8e2ba544c Signed-off-by: Maciej Skrzypkowski --- core/AbstractWebEngine/AbstractWebEngine.h | 10 +++++++ services/MoreMenuUI/MoreMenuUI.cpp | 34 ++++++++++++++++++++-- services/MoreMenuUI/MoreMenuUI.h | 9 ++++-- services/MoreMenuUI/edc/MoreMenu.edc | 2 ++ services/SimpleUI/SimpleUI.cpp | 11 +++++++ services/SimpleUI/SimpleUI.h | 2 ++ .../WebKitEngineService/WebKitEngineService.cpp | 21 +++++++++++-- services/WebKitEngineService/WebKitEngineService.h | 5 ++++ services/WebKitEngineService/WebView.cpp | 20 +++++++++++-- services/WebKitEngineService/WebView.h | 13 +++++++-- 10 files changed, 117 insertions(+), 10 deletions(-) diff --git a/core/AbstractWebEngine/AbstractWebEngine.h b/core/AbstractWebEngine/AbstractWebEngine.h index bfe4199..8416229 100644 --- a/core/AbstractWebEngine/AbstractWebEngine.h +++ b/core/AbstractWebEngine/AbstractWebEngine.h @@ -257,6 +257,16 @@ public: virtual void backButtonClicked() const = 0; /** + * @brief Switch view to mobile + */ + virtual void switchToMobileView() = 0; + + /** + * @brief Switch view to desktop + */ + virtual void switchToDesktopView() = 0; + + /** * FavIcon of current page changed */ boost::signals2::signal)> favIconChanged; diff --git a/services/MoreMenuUI/MoreMenuUI.cpp b/services/MoreMenuUI/MoreMenuUI.cpp index fb1bcb5..8279289 100644 --- a/services/MoreMenuUI/MoreMenuUI.cpp +++ b/services/MoreMenuUI/MoreMenuUI.cpp @@ -48,6 +48,7 @@ MoreMenuUI::MoreMenuUI() : m_gengrid(NULL) , m_parent(NULL) , m_item_class(NULL) + , m_desktopView(true) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); m_edjFilePath = EDJE_DIR; @@ -230,9 +231,16 @@ void MoreMenuUI::hide() void MoreMenuUI::addItems() { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); - for (size_t i = 0; i < static_cast(END_OF_RANGE); i++) { + for (int i = 0; i <= EXIT_BROWSER; i++) { + ItemType type = static_cast(i); + // take proper image for desktop/mobile view + if (type == ItemType::VIEW_DESKTOP_WEB && m_desktopView) + continue; + if (type == ItemType::VIEW_MOBILE_WEB && !m_desktopView) + continue; + MoreMenuItemData *itemData = new MoreMenuItemData(); - itemData->item = static_cast(i);; + itemData->item = type; itemData->moreMenuUI = std::shared_ptr(this); Elm_Object_Item* bookmarkView = elm_gengrid_item_append(m_gengrid, m_item_class, itemData, NULL, this); m_map_menu_views.insert(std::pair(itemData->item, bookmarkView)); @@ -277,6 +285,9 @@ char* MoreMenuUI::_grid_text_get(void* data, Evas_Object*, const char* part) case VIEW_MOBILE_WEB: item_name = "View mobile web"; break; + case VIEW_DESKTOP_WEB: + item_name = "View desktop web"; + break; case SHARE: item_name = "Share"; break; @@ -324,6 +335,9 @@ static const char* getImageFileNameForType(ItemType type, bool focused) case VIEW_MOBILE_WEB: file_name = focused ? "ic_more_mobileview_foc.png" : "ic_more_mobileview_nor.png"; break; + case VIEW_DESKTOP_WEB: + file_name = focused ? "ic_more_desktopview_foc.png" : "ic_more_desktopview_nor.png"; + break; case SHARE: file_name = focused ? "ic_more_share_foc.png" : "ic_more_share_nor.png"; break; @@ -401,6 +415,7 @@ void MoreMenuUI::_thumbSelected(void* data, Evas_Object*, void*) BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); if (data) { MoreMenuItemData *itemData = static_cast(data); + BROWSER_LOGD("type: %d", itemData->item); switch (itemData->item) { case HISTORY: itemData->moreMenuUI->historyUIClicked(std::string()); @@ -426,6 +441,14 @@ void MoreMenuUI::_thumbSelected(void* data, Evas_Object*, void*) case FOCUS_MODE: break; case VIEW_MOBILE_WEB: + itemData->moreMenuUI->switchToMobileView(); + itemData->moreMenuUI->m_desktopView = false; + itemData->moreMenuUI->refreshGengrid(); + break; + case VIEW_DESKTOP_WEB: + itemData->moreMenuUI->switchToDesktopView(); + itemData->moreMenuUI->m_desktopView = true; + itemData->moreMenuUI->refreshGengrid(); break; case SHARE: break; @@ -454,6 +477,13 @@ void MoreMenuUI::clearItems() elm_cache_all_flush(); } +void MoreMenuUI::refreshGengrid() +{ + elm_gengrid_clear(m_gengrid); + m_map_menu_views.clear(); + addItems(); +} + void MoreMenuUI::_exitClicked() { BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); diff --git a/services/MoreMenuUI/MoreMenuUI.h b/services/MoreMenuUI/MoreMenuUI.h index cd3d6c1..a6df318 100644 --- a/services/MoreMenuUI/MoreMenuUI.h +++ b/services/MoreMenuUI/MoreMenuUI.h @@ -48,10 +48,10 @@ enum ItemType { #endif FOCUS_MODE, VIEW_MOBILE_WEB, + VIEW_DESKTOP_WEB, SHARE, SETTINGS, - EXIT_BROWSER, - END_OF_RANGE + EXIT_BROWSER } item; class BROWSER_EXPORT MoreMenuUI @@ -80,6 +80,8 @@ public: boost::signals2::signal historyUIClicked; boost::signals2::signal settingsClicked; boost::signals2::signal closeMoreMenuClicked; + boost::signals2::signal switchToMobileView; + boost::signals2::signal switchToDesktopView; private: static char* _grid_text_get(void *data, Evas_Object *obj, const char *part); static Evas_Object * _grid_content_get(void *data, Evas_Object *obj, const char *part); @@ -93,6 +95,8 @@ private: void AddBookmarkPopupCalled(); void addToBookmarks(int folder_id); + void refreshGengrid(); + static void _star_clicked(void *data, Evas_Object *obj, void *event_info); static void _close_clicked(void *data, Evas_Object *obj, void *event_info); @@ -113,6 +117,7 @@ private: std::string m_folderName; bool m_gengridSetup; Evas_Object *m_icon; + bool m_desktopView; }; } diff --git a/services/MoreMenuUI/edc/MoreMenu.edc b/services/MoreMenuUI/edc/MoreMenu.edc index 91dbe04..553416b 100644 --- a/services/MoreMenuUI/edc/MoreMenu.edc +++ b/services/MoreMenuUI/edc/MoreMenu.edc @@ -38,6 +38,7 @@ RESOURCE_IMAGE_LOSSY("ic_more_zoom_nor.png") RESOURCE_IMAGE_LOSSY("ic_more_minibrowser_nor.png") RESOURCE_IMAGE_LOSSY("ic_more_focusmode_nor.png") RESOURCE_IMAGE_LOSSY("ic_more_mobileview_nor.png") +RESOURCE_IMAGE_LOSSY("ic_more_desktopview_nor.png") RESOURCE_IMAGE_LOSSY("ic_more_share_nor.png") RESOURCE_IMAGE_LOSSY("ic_more_setting_nor.png") RESOURCE_IMAGE_LOSSY("ic_more_exit_nor.png") @@ -49,6 +50,7 @@ RESOURCE_IMAGE_LOSSY("ic_more_zoom_foc.png") RESOURCE_IMAGE_LOSSY("ic_more_minibrowser_foc.png") RESOURCE_IMAGE_LOSSY("ic_more_focusmode_foc.png") RESOURCE_IMAGE_LOSSY("ic_more_mobileview_foc.png") +RESOURCE_IMAGE_LOSSY("ic_more_desktopview_foc.png") RESOURCE_IMAGE_LOSSY("ic_more_share_foc.png") RESOURCE_IMAGE_LOSSY("ic_more_setting_foc.png") RESOURCE_IMAGE_LOSSY("ic_more_exit_foc.png") diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 14ce4b8..951e86d 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -1169,6 +1169,8 @@ void SimpleUI::showMoreMenu() m_moreMenuUI->historyUIClicked.connect(boost::bind(&SimpleUI::showHistoryUI, this,_1)); m_moreMenuUI->settingsClicked.connect(boost::bind(&SimpleUI::showSettingsUI, this,_1)); m_moreMenuUI->closeMoreMenuClicked.connect(boost::bind(&SimpleUI::closeMoreMenu, this,_1)); + m_moreMenuUI->switchToMobileView.connect(boost::bind(&SimpleUI::switchToMobileView, this)); + m_moreMenuUI->switchToDesktopView.connect(boost::bind(&SimpleUI::switchToDesktopView, this)); m_moreMenuUI->addToBookmarkClicked.connect(boost::bind(&SimpleUI::addBookmarkFolders, this)); m_moreMenuUI->AddBookmarkInput.connect(boost::bind(&SimpleUI::addToBookmarks, this,_1)); m_moreMenuUI->BookmarkFolderCreated.connect(boost::bind(&SimpleUI::newFolderMoreMenu, this,_1,_2)); @@ -1188,6 +1190,15 @@ void SimpleUI::closeMoreMenu(const std::string& str) m_moreMenuUI.reset(); } +void SimpleUI::switchToMobileView() +{ + m_webEngine->switchToMobileView(); +} + +void SimpleUI::switchToDesktopView() { + m_webEngine->switchToDesktopView(); +} + void SimpleUI::showBookmarkManagerMenu() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index 82d03ee..e760b6f 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -229,6 +229,8 @@ private: void closeTabUI(const std::string& str); void showMoreMenu(); void closeMoreMenu(const std::string& str); + void switchToMobileView(); + void switchToDesktopView(); void showHistoryUI(const std::string& str); void closeHistoryUI(const std::string&); void showMainUI(); diff --git a/services/WebKitEngineService/WebKitEngineService.cpp b/services/WebKitEngineService/WebKitEngineService.cpp index 5d8f076..2506a63 100644 --- a/services/WebKitEngineService/WebKitEngineService.cpp +++ b/services/WebKitEngineService/WebKitEngineService.cpp @@ -45,6 +45,7 @@ WebKitEngineService::WebKitEngineService() , m_privateMode(false) , m_guiParent(nullptr) , m_currentTabId(TabId::NONE) + , m_desktopView(true) { m_mostRecentTab.clear(); m_tabs.clear(); @@ -286,9 +287,9 @@ TabId WebKitEngineService::addTab(const std::string & uri, const TabId * openerI TabId newTabId; WebViewPtr p = std::make_shared(reinterpret_cast(m_guiParent), newTabId); if (openerId) - p->init(getTabView(*openerId)); + p->init(m_desktopView, getTabView(*openerId)); else - p->init(); + p->init(m_desktopView); m_tabs[newTabId] = p; @@ -507,6 +508,22 @@ void WebKitEngineService::backButtonClicked() const } } +void WebKitEngineService::switchToDesktopView() +{ + m_desktopView = true; + for (auto it = m_tabs.begin(); it != m_tabs.end(); ++it) { + it->second->switchToDesktopView(); + } +} + +void WebKitEngineService::switchToMobileView() +{ + m_desktopView = false; + for (auto it = m_tabs.begin(); it != m_tabs.end(); ++it) { + it->second->switchToMobileView(); + } +} + } /* end of webkitengine_service */ } /* end of basic_webengine */ } /* end of tizen_browser */ diff --git a/services/WebKitEngineService/WebKitEngineService.h b/services/WebKitEngineService/WebKitEngineService.h index 6f47216..5c0f47d 100644 --- a/services/WebKitEngineService/WebKitEngineService.h +++ b/services/WebKitEngineService/WebKitEngineService.h @@ -159,6 +159,9 @@ public: */ void backButtonClicked() const; + void switchToMobileView(); + void switchToDesktopView(); + private: // callbacks from WebView void _favIconChanged(std::shared_ptr bi); @@ -206,6 +209,8 @@ private: std::list m_mostRecentTab; // recently added tabs first std::list m_chronoTabs; + // true if desktop view is enabled, false if mobile + bool m_desktopView; }; } /* end of webkitengine_service */ diff --git a/services/WebKitEngineService/WebView.cpp b/services/WebKitEngineService/WebView.cpp index f634541..603543c 100644 --- a/services/WebKitEngineService/WebView.cpp +++ b/services/WebKitEngineService/WebView.cpp @@ -51,6 +51,9 @@ #define APPLICATION_NAME_FOR_USER_AGENT "Mozilla/5.0 (X11; SMART-TV; Linux) AppleWebkit/538.1 (KHTML, like Gecko) Safari/538.1" #endif +//TODO: temporary user agent for mobile display, change to proper one +#define APPLICATION_NAME_FOR_USER_AGENT_MOBILE "Mozilla/5.0 (Linux; Tizen 3.0; SAMSUNG SM-Z130H) AppleWebKit/538.1 (KHTML, like Gecko) SamsungBrowser/1.0 Mobile Safari/538.1" + using namespace tizen_browser::tools; namespace tizen_browser { @@ -80,7 +83,7 @@ WebView::~WebView() ewk_context_delete(m_ewkContext); } -void WebView::init(Evas_Object * opener) +void WebView::init(bool desktopView, Evas_Object * opener) { #if defined(USE_EWEBKIT) m_ewkView = ewk_view_add_with_context(evas_object_evas_get(m_parent), m_ewkContext); @@ -91,7 +94,10 @@ void WebView::init(Evas_Object * opener) evas_object_color_set(m_ewkView, 255, 255, 255, 255); evas_object_size_hint_weight_set(m_ewkView, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(m_ewkView, EVAS_HINT_FILL, EVAS_HINT_FILL); - ewk_view_application_name_for_user_agent_set(m_ewkView, APPLICATION_NAME_FOR_USER_AGENT); + if (desktopView) + switchToDesktopView(); + else + switchToMobileView(); //\todo: when value is other than 1.0, scroller is located improperly // ewk_view_device_pixel_ratio_set(m_ewkView, 1.0f); @@ -871,6 +877,16 @@ void WebView::searchOnWebsite(const std::string & searchString, int flags) BROWSER_LOGD("Ewk search; word: %s, result: %d", searchString.c_str(), result); } +void WebView::switchToDesktopView() { + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + int res = ewk_view_user_agent_set(m_ewkView, APPLICATION_NAME_FOR_USER_AGENT); +} + +void WebView::switchToMobileView() { + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + int res = ewk_view_user_agent_set(m_ewkView, APPLICATION_NAME_FOR_USER_AGENT_MOBILE); +} + } /* namespace webkitengine_service */ } /* end of basic_webengine */ } /* end of tizen_browser */ diff --git a/services/WebKitEngineService/WebView.h b/services/WebKitEngineService/WebView.h index 9dd26dc..846af9c 100644 --- a/services/WebKitEngineService/WebView.h +++ b/services/WebKitEngineService/WebView.h @@ -41,7 +41,7 @@ class WebView public: WebView(Evas_Object *, TabId); virtual ~WebView(); - void init(Evas_Object * opener = NULL); + void init(bool desktopView = true, Evas_Object * opener = NULL); void setURI(const std::string &); @@ -110,9 +110,18 @@ public: void searchOnWebsite(const std::string &, int); /** - * @brief Get favicon of URL + * @brief Change user agent to desktop type + */ + void switchToDesktopView(); + + /** + * @brief Change user agent to mobile type */ + void switchToMobileView(); + /** + * @brief Get favicon of URL + */ std::shared_ptr getFavicon(); // signals -- 2.7.4 From 622feb619af062b48570575d21c99f299ccddff4 Mon Sep 17 00:00:00 2001 From: Dariusz Frankiewicz Date: Mon, 31 Aug 2015 09:13:00 +0200 Subject: [PATCH 09/16] Refactor SettingsUI [Issue#] https://bugs.tizen.org/jira/browse/TT-153 [Problem] Check boxes in settings menu can't be clicked. [Cause] Invisible platform rectangle covers this screen area. [Solution] Refactoring settings UI code by replacing unneded genlist, with layout inside scrooler. Also added possibility to click check box labels as a complementary fix for platform issue with invisible rectangle. [Verify] Open More menu -> Settings and check if check boxes: Cache, Cookies and History can be changed by clicking their labels. Change-Id: I49e2ea04054cb1efdecd3fed02d26914b1ecac48 Signed-off-by: Dariusz Frankiewicz --- services/SettingsUI/SettingsUI.cpp | 217 ++++++++++++++++------------------- services/SettingsUI/SettingsUI.h | 10 +- services/SettingsUI/edc/Settings.edc | 4 +- 3 files changed, 110 insertions(+), 121 deletions(-) diff --git a/services/SettingsUI/SettingsUI.cpp b/services/SettingsUI/SettingsUI.cpp index 9b897a2..2b68784 100644 --- a/services/SettingsUI/SettingsUI.cpp +++ b/services/SettingsUI/SettingsUI.cpp @@ -43,6 +43,8 @@ SettingsUI::SettingsUI() , m_itemClassActionBar(nullptr) , m_parent(nullptr) , m_item_class(nullptr) + , m_scroller(nullptr) + , m_items_layout(nullptr) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); m_edjFilePath = EDJE_DIR; @@ -65,7 +67,7 @@ void SettingsUI::show(Evas_Object* parent) evas_object_show(m_settings_layout); showActionBar(); - showSettingsGenlist(); + showSettingsPage(); } void SettingsUI::showActionBar() @@ -98,45 +100,91 @@ void SettingsUI::showActionBar() nullptr, nullptr //data passed to above function ); - id->e_item = elmItem; + id->e_item = elmItem; BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); } -void SettingsUI::showSettingsGenlist() +void SettingsUI::showSettingsPage() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); - m_genList = elm_genlist_add(m_settings_layout); - elm_object_part_content_set(m_settings_layout, "settings_genlist_swallow", m_genList); - elm_genlist_homogeneous_set(m_genList, EINA_FALSE); - elm_genlist_multi_select_set(m_genList, EINA_FALSE); - elm_genlist_select_mode_set(m_genList, ELM_OBJECT_SELECT_MODE_ALWAYS); - elm_genlist_mode_set(m_genList, ELM_LIST_SCROLL); - elm_genlist_decorate_mode_set(m_genList, EINA_TRUE); - evas_object_size_hint_weight_set(m_genList, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_scroller_policy_set(m_genList, ELM_SCROLLER_POLICY_ON, ELM_SCROLLER_POLICY_AUTO); - - m_item_class = elm_genlist_item_class_new(); - m_item_class->item_style = "settings_items"; - m_item_class->func.text_get = nullptr; - m_item_class->func.content_get = &listSettingsGenlistContentGet; - m_item_class->func.state_get = nullptr; - m_item_class->func.del = nullptr; ItemData *id = new ItemData; id->settingsUI = this; - Elm_Object_Item *elmItem = elm_genlist_item_append(m_genList, //genlist - m_item_class, //item Class - id, - nullptr, //parent item - ELM_GENLIST_ITEM_NONE, //item type - nullptr, - nullptr //data passed to above function - ); - id->e_item = elmItem; - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_scroller = elm_scroller_add(m_settings_layout); + m_items_layout = elm_layout_add(m_scroller); + elm_object_content_set(m_scroller, m_items_layout); + elm_layout_file_set(m_items_layout, m_edjFilePath.c_str(), "settings_items"); + elm_object_part_content_set(m_settings_layout, "settings_scroller_swallow", m_scroller); + evas_object_size_hint_weight_set(m_scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_scroller, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_scroller_policy_set(m_items_layout, ELM_SCROLLER_POLICY_ON, ELM_SCROLLER_POLICY_AUTO); + elm_scroller_bounce_set(m_scroller, EINA_TRUE, EINA_FALSE); + elm_scroller_propagate_events_set(m_scroller, EINA_TRUE); + evas_object_show(m_scroller); + evas_object_show(m_items_layout); + + Evas_Object *del_selected_data_button = elm_button_add(m_items_layout); + elm_object_style_set(del_selected_data_button, "basic_button"); + evas_object_smart_callback_add(del_selected_data_button, "clicked", _del_selected_data_clicked_cb, (void*)id); + elm_layout_content_set(m_items_layout, "del_selected_data_click", del_selected_data_button); + + Evas_Object *reset_mv_button = elm_button_add(m_items_layout); + elm_object_style_set(reset_mv_button, "basic_button"); + evas_object_smart_callback_add(reset_mv_button, "clicked", _reset_mv_clicked_cb, (void*)id); + elm_layout_content_set(m_items_layout, "reset_mv_click", reset_mv_button); + + Evas_Object *reset_browser_button = elm_button_add(m_items_layout); + elm_object_style_set(reset_browser_button, "basic_button"); + evas_object_smart_callback_add(reset_browser_button, "clicked", _reset_browser_clicked_cb, (void*)id); + elm_layout_content_set(m_items_layout, "reset_browser_click", reset_browser_button); + + + Evas_Object *cache_checkbox = elm_check_add(m_items_layout); + elm_layout_content_set(m_items_layout, "cache_cb", cache_checkbox); + elm_check_state_set(cache_checkbox, EINA_TRUE); + edje_object_signal_callback_add(elm_layout_edje_get(m_items_layout), "mouse,clicked,1", "cache_cb_text", __checkbox_label_click_cb, (void*)id); + + Evas_Object *cookies_checkbox = elm_check_add(m_items_layout); + elm_layout_content_set(m_items_layout, "cookies_cb", cookies_checkbox); + elm_check_state_set(cookies_checkbox, EINA_TRUE); + edje_object_signal_callback_add(elm_layout_edje_get(m_items_layout), "mouse,clicked,1", "cookies_cb_text", __checkbox_label_click_cb, (void*)id); + + Evas_Object *history_checkbox = elm_check_add(m_items_layout); + elm_layout_content_set(m_items_layout, "history_cb", history_checkbox); + elm_check_state_set(history_checkbox, EINA_TRUE); + edje_object_signal_callback_add(elm_layout_edje_get(m_items_layout), "mouse,clicked,1", "history_cb_text", __checkbox_label_click_cb, (void*)id); + + + Evas_Object *accept_all_rb = elm_radio_add(m_items_layout); + elm_object_style_set(accept_all_rb, "settings_radio"); + elm_layout_content_set(m_items_layout, "accept_all_rb", accept_all_rb); + + Evas_Object *ask_rb = elm_radio_add(m_items_layout); + elm_object_style_set(ask_rb, "settings_radio"); + elm_layout_content_set(m_items_layout, "ask_rb", ask_rb); + + Evas_Object *sr_disable_rb = elm_radio_add(m_items_layout); + elm_object_style_set(sr_disable_rb, "settings_radio"); + elm_layout_content_set(m_items_layout, "sr_disable_rb", sr_disable_rb); + + Evas_Object *bs_enable_rb = elm_radio_add(m_items_layout); + elm_object_style_set(bs_enable_rb, "settings_radio"); + elm_layout_content_set(m_items_layout, "bs_enable_rb", bs_enable_rb); + + Evas_Object *bs_disable_rb = elm_radio_add(m_items_layout); + elm_object_style_set(bs_disable_rb, "settings_radio"); + elm_layout_content_set(m_items_layout, "bs_disable_rb", bs_disable_rb); + + Evas_Object *ts_enable_rb = elm_radio_add(m_items_layout); + elm_object_style_set(ts_enable_rb, "settings_radio"); + elm_layout_content_set(m_items_layout, "ts_enable_rb", ts_enable_rb); + + Evas_Object *ts_disable_rb = elm_radio_add(m_items_layout); + elm_object_style_set(ts_disable_rb, "settings_radio"); + elm_layout_content_set(m_items_layout, "ts_disable_rb", ts_disable_rb); + } Evas_Object* SettingsUI::listActionBarContentGet(void* data, Evas_Object* obj , const char* part) @@ -155,88 +203,28 @@ Evas_Object* SettingsUI::listActionBarContentGet(void* data, Evas_Object* obj , return nullptr; } -Evas_Object* SettingsUI::listSettingsGenlistContentGet(void* data, Evas_Object* obj , const char* part) +void SettingsUI::__checkbox_label_click_cb(void *data, Evas_Object *obj, const char *emission, const char *source) { - BROWSER_LOGD("[%s:%d] Part %s", __PRETTY_FUNCTION__, __LINE__, part); - if (obj && part) { - const char * part_name1 = "del_selected_data_click"; - static const int part_name1_len = strlen(part_name1); - if (!strncmp(part_name1, part, part_name1_len)) { - Evas_Object *button = elm_button_add(obj); - elm_object_style_set(button, "basic_button"); - evas_object_smart_callback_add(button, "clicked", SettingsUI::_del_selected_data_clicked_cb, data); - return button; - } + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + ItemData *id = static_cast(data); - const char * part_name2 = "reset_mv_click"; - static const int part_name2_len = strlen(part_name2); - if (!strncmp(part_name2, part, part_name2_len)) { - Evas_Object *button = elm_button_add(obj); - elm_object_style_set(button, "basic_button"); - evas_object_smart_callback_add(button, "clicked", SettingsUI::_reset_mv_clicked_cb, data); - return button; + if(strcmp(source, "cache_cb_text") == 0 ){ + Evas_Object *cache_check = elm_layout_content_get(id->settingsUI->m_items_layout, "cache_cb"); + elm_check_state_set(cache_check, !elm_check_state_get(cache_check)); } - - const char * part_name3 = "reset_browser_click"; - static const int part_name3_len = strlen(part_name3); - if (!strncmp(part_name3, part, part_name3_len)) { - Evas_Object *button = elm_button_add(obj); - elm_object_style_set(button, "basic_button"); - evas_object_smart_callback_add(button, "clicked", SettingsUI::_reset_browser_clicked_cb, data); - return button; + else if (strcmp(source, "cookies_cb_text") == 0 ){ + Evas_Object *cookies_check = elm_layout_content_get(id->settingsUI->m_items_layout, "cookies_cb"); + elm_check_state_set(cookies_check, !elm_check_state_get(cookies_check)); } - - const char * part_name4 = "cache_cb"; - static const int part_name4_len = strlen(part_name4); - const char * part_name5 = "cookies_cb"; - static const int part_name5_len = strlen(part_name5); - const char * part_name6 = "history_cb"; - static const int part_name6_len = strlen(part_name6); - if (!strncmp(part_name4, part, part_name4_len) || - !strncmp(part_name5, part, part_name5_len) || - !strncmp(part_name6, part, part_name6_len)) - { - Evas_Object *checkbox = elm_check_add(obj); - elm_object_style_set(checkbox, "on&off"); - evas_object_smart_callback_add(checkbox, "changed", __check_changed_cb, data); - elm_check_state_set(checkbox, EINA_TRUE); - return checkbox; + else if (strcmp(source, "history_cb_text") == 0 ){ + Evas_Object *history_check = elm_layout_content_get(id->settingsUI->m_items_layout, "history_cb"); + elm_check_state_set(history_check, !elm_check_state_get(history_check)); } - - const char * part_name7 = "accept_all_rb"; - static const int part_name7_len = strlen(part_name7); - const char * part_name8 = "ask_rb"; - static const int part_name8_len = strlen(part_name8); - const char * part_name9 = "sr_disable_rb"; - static const int part_name9_len = strlen(part_name9); - const char * part_name10 = "bs_enable_rb"; - static const int part_name10_len = strlen(part_name10); - const char * part_name11 = "bs_disable_rb"; - static const int part_name11_len = strlen(part_name11); - const char * part_name12 = "ts_enable_rb"; - static const int part_name12_len = strlen(part_name12); - const char * part_name13 = "ts_disable_rb"; - static const int part_name13_len = strlen(part_name13); - if (!strncmp(part_name7, part, part_name7_len) || - !strncmp(part_name8, part, part_name8_len) || - !strncmp(part_name9, part, part_name9_len) || - !strncmp(part_name10, part, part_name10_len) || - !strncmp(part_name11, part, part_name11_len) || - !strncmp(part_name12, part, part_name12_len) || - !strncmp(part_name13, part, part_name13_len)) - { - Evas_Object *rb = elm_radio_add(obj); - elm_object_style_set(rb, "on&off"); - //evas_object_smart_callback_add(rb, "changed", __radio_changed_cb, data); - return rb; + else{ + BROWSER_LOGD("[%s:%d] - no matched source", __PRETTY_FUNCTION__, __LINE__); } } - return nullptr; -} - -void SettingsUI::__check_changed_cb(void*, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); } void SettingsUI::close_clicked_cb(void* data, Evas_Object*, void*) @@ -252,7 +240,7 @@ void SettingsUI::close_clicked_cb(void* data, Evas_Object*, void*) void SettingsUI::hide() { evas_object_hide(elm_layout_content_get(m_settings_layout, "action_bar_swallow")); - evas_object_hide(elm_layout_content_get(m_settings_layout, "settings_genlist_swallow")); + evas_object_hide(elm_layout_content_get(m_settings_layout, "settings_scroller_swallow")); evas_object_hide(m_settings_layout); } @@ -260,15 +248,15 @@ void SettingsUI::_del_selected_data_clicked_cb(void *data, Evas_Object*, void*) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); if (data) { - ItemData *itemData = static_cast(data); - Evas_Object *cb1 = elm_object_item_part_content_get(itemData->e_item, "cache_cb"); - Evas_Object *cb2 = elm_object_item_part_content_get(itemData->e_item, "cookies_cb"); - Evas_Object *cb3 = elm_object_item_part_content_get(itemData->e_item, "history_cb"); + ItemData *id = static_cast(data); + Evas_Object *cache_check = elm_layout_content_get(id->settingsUI->m_items_layout, "cache_cb"); + Evas_Object *cookies_check = elm_layout_content_get(id->settingsUI->m_items_layout, "cookies_cb"); + Evas_Object *history_check = elm_layout_content_get(id->settingsUI->m_items_layout, "history_cb"); std::string type; - elm_check_state_get(cb1) ? type += "_CACHE" : ""; - elm_check_state_get(cb2) ? type += "_COOKIES" : ""; - elm_check_state_get(cb3) ? type += "_HISTORY" : ""; - itemData->settingsUI->deleteSelectedDataClicked(type); + elm_check_state_get(cache_check) ? type += "_CACHE" : ""; + elm_check_state_get(cookies_check) ? type += "_COOKIES" : ""; + elm_check_state_get(history_check) ? type += "_HISTORY" : ""; + id->settingsUI->deleteSelectedDataClicked(type); } } @@ -295,7 +283,6 @@ void SettingsUI::clearItems() BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); hide(); elm_genlist_clear(m_genListActionBar); - elm_genlist_clear(m_genList); } } diff --git a/services/SettingsUI/SettingsUI.h b/services/SettingsUI/SettingsUI.h index c7e8e9f..8adbf4d 100644 --- a/services/SettingsUI/SettingsUI.h +++ b/services/SettingsUI/SettingsUI.h @@ -38,7 +38,7 @@ public: void show(Evas_Object *main_layout); virtual std::string getName(); void showActionBar(); - void showSettingsGenlist(); + void showSettingsPage(); void clearItems(); void hide(); @@ -55,7 +55,7 @@ private: static Evas_Object * _tab_grid_content_get(void *data, Evas_Object *obj, const char *part); static void _itemSelected(void * data, Evas_Object * obj, void * event_info); static void close_clicked_cb(void *data, Evas_Object *obj, void *event_info); - static void __check_changed_cb(void *data, Evas_Object *obj, void *event_info); + static void __checkbox_label_click_cb(void *data, Evas_Object *obj, const char *emission, const char *source); static void _del_selected_data_clicked_cb(void * data, Evas_Object * obj, void * event_info); static void _reset_mv_clicked_cb(void * data, Evas_Object * obj, void * event_info); @@ -66,12 +66,14 @@ private: private: Evas_Object *m_settings_layout; Evas_Object *m_genListActionBar; - Evas_Object *m_genList; + Evas_Object *m_scroller; + Evas_Object *m_items_layout; Elm_Genlist_Item_Class *m_itemClassActionBar; Evas_Object *m_parent; - + Elm_Gengrid_Item_Class * m_item_class; std::string m_edjFilePath; + }; } diff --git a/services/SettingsUI/edc/Settings.edc b/services/SettingsUI/edc/Settings.edc index 76e5dc2..603c8d0 100644 --- a/services/SettingsUI/edc/Settings.edc +++ b/services/SettingsUI/edc/Settings.edc @@ -161,7 +161,7 @@ group { name: "settings-layout"; rel2 { relative: 1.0 1.0; } } } - part { name: "settings_genlist_swallow"; + part { name: "settings_scroller_swallow"; type: SWALLOW; description { state: "default" 0.0; align: 0.0 0.0; @@ -179,7 +179,7 @@ group { name: "settings-layout"; } } -group { name: "elm/genlist/item/settings_items/default"; +group { name: "settings_items"; data.item: "contents" "del_selected_data_click reset_mv_click reset_browser_click cache_cb cookies_cb history_cb accept_all_rb ask_rb sr_disable_rb bs_enable_rb bs_disable_rb ts_enable_rb ts_disable_rb"; images { image: "web_frame_selected.png" COMP; -- 2.7.4 From 7e7c470d20cf96de850dccf6b415a6d460ad386c Mon Sep 17 00:00:00 2001 From: Albert Malewski Date: Thu, 3 Sep 2015 08:16:11 +0200 Subject: [PATCH 10/16] Fixed creating history list [Issue#] https://bugs.tizen.org/jira/browse/TT-159 [Problem] "Close Tabs" function is not implemented in Tab Manager. [Cause] N/A [Solution] Added closeAllTabs, closeTabsClicked functions. Added boolean 'editMode' variable that conditions action in _thumbSelected function. Added callback to make 'X' icon and '[OK] to close' visible. [Verify] Launch browser > Add tabs > Tab manager > Close Tabs Check if 'Close all' button works properly Check if closing selected item works properly Change-Id: I98453027ad3ccfa797ab94e1e2c3ffa67f65d28f --- services/SimpleUI/SimpleUI.cpp | 7 ++++ services/SimpleUI/SimpleUI.h | 1 + services/TabUI/TabUI.cpp | 69 ++++++++++++++++++++++++++---------- services/TabUI/TabUI.h | 6 ++-- services/TabUI/edc/TabUI.edc | 79 +++++++++++++++++++++++++++++++++++------- 5 files changed, 130 insertions(+), 32 deletions(-) diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 951e86d..91bcecb 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -938,6 +938,7 @@ void SimpleUI::showTabUI() m_tabUI->closeTabUIClicked.connect(boost::bind(&SimpleUI::closeTabUI, this,_1)); m_tabUI->newTabClicked.connect(boost::bind(&SimpleUI::newTabClicked, this,_1)); m_tabUI->tabClicked.connect(boost::bind(&SimpleUI::tabClicked, this,_1)); + m_tabUI->closeTabsClicked.connect(boost::bind(&SimpleUI::closeTabsClicked, this,_1)); m_tabUI->newIncognitoTabClicked.connect(boost::bind(&SimpleUI::newTabClicked, this,_1)); m_tabUI->show(m_window.get()); m_tabUI->addTabItems(m_webEngine->getTabContents()); @@ -961,6 +962,12 @@ void SimpleUI::tabClicked(const tizen_browser::basic_webengine::TabId& tabId) switchToTab(tabId); } +void SimpleUI::closeTabsClicked(const tizen_browser::basic_webengine::TabId& tabId) +{ + BROWSER_LOGD("%s", __func__); + m_webEngine->closeTab(tabId); +} + void SimpleUI::handleConfirmationRequest(basic_webengine::WebConfirmationPtr webConfirmation) { BROWSER_LOGD("%s", __func__); diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index e760b6f..b8df3a1 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -116,6 +116,7 @@ private: void switchToTab(const tizen_browser::basic_webengine::TabId& tabId); void newTabClicked(const std::string &); void tabClicked(const tizen_browser::basic_webengine::TabId& tabId); + void closeTabsClicked(const tizen_browser::basic_webengine::TabId& tabId); void tabCreated(); void tabClosed(const tizen_browser::basic_webengine::TabId& id); diff --git a/services/TabUI/TabUI.cpp b/services/TabUI/TabUI.cpp index d92dd18..cfb9e36 100644 --- a/services/TabUI/TabUI.cpp +++ b/services/TabUI/TabUI.cpp @@ -50,6 +50,7 @@ TabUI::TabUI() m_edjFilePath.append("TabUI/TabUI.edj"); elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); createTabItemClass(); + editMode = false; } TabUI::~TabUI() @@ -105,9 +106,9 @@ Evas_Object* TabUI::createTabUILayout(Evas_Object* parent) elm_gengrid_align_set(m_gengrid, 0, 0); elm_gengrid_select_mode_set(m_gengrid, ELM_OBJECT_SELECT_MODE_ALWAYS); elm_gengrid_multi_select_set(m_gengrid, EINA_FALSE); - elm_gengrid_horizontal_set(m_gengrid, EINA_FALSE); + elm_gengrid_horizontal_set(m_gengrid, EINA_TRUE); elm_gengrid_highlight_mode_set(m_gengrid, EINA_TRUE); - elm_scroller_policy_set(m_gengrid, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); + elm_scroller_policy_set(m_gengrid, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF); elm_scroller_page_size_set(m_gengrid, 0, 327); evas_object_size_hint_weight_set(m_gengrid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); @@ -115,6 +116,8 @@ Evas_Object* TabUI::createTabUILayout(Evas_Object* parent) double efl_scale = elm_config_scale_get() / elm_app_base_scale_get(); elm_gengrid_item_size_set(m_gengrid, 364 * efl_scale, 320 * efl_scale); + evas_object_event_callback_add(m_gengrid, EVAS_CALLBACK_MOUSE_IN, _focus_in, this); + return tab_layout; } @@ -160,6 +163,7 @@ void TabUI::_close_clicked(void* data, Evas_Object*, void*) TabUI * tabUI = static_cast(data); tabUI->closeTabUIClicked(std::string()); tabUI->clearItems(); + tabUI->editMode = false; } } @@ -203,6 +207,7 @@ void TabUI::_newtab_clicked(void * data, Evas_Object*, void*) TabUI* tabUI = static_cast(data); tabUI->clearItems(); tabUI->newTabClicked(std::string()); + tabUI->editMode = false; } } @@ -223,27 +228,34 @@ void TabUI::_newincognitotab_clicked(void* data, Evas_Object*, void*) TabUI* tabUI = static_cast(data); tabUI->clearItems(); tabUI->newIncognitoTabClicked(std::string()); + tabUI->editMode = false; } } -void TabUI::_closetabs_clicked(void* data, Evas_Object*, void*) +void TabUI::_closetabs_clicked(void* data, Evas_Object* obj, void*) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); if (data) { TabUI* tabUI = static_cast(data); - tabUI->closeTabsClicked(std::string()); + if (!tabUI->editMode) { + tabUI->editMode = true; + BROWSER_LOGD("[%s:%d] --------> edit mode: %d ", __PRETTY_FUNCTION__, __LINE__, tabUI->editMode); + elm_layout_text_set(elm_layout_content_get(tabUI->m_tab_layout, "action_bar"), "closetabs_text", "Close all"); + } else { + tabUI->closeAllTabs(); + elm_gengrid_realized_items_update(tabUI->m_gengrid); + } } + } void TabUI::addTabItem(std::shared_ptr hi) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); - if (m_map_tab_views.size() >= 10) - return; TabItemData *itemData = new TabItemData(); itemData->item = hi; itemData->tabUI = std::shared_ptr(this); - Elm_Object_Item* tabView = elm_gengrid_item_append(m_gengrid, m_item_class, itemData, nullptr, this); + Elm_Object_Item* tabView = elm_gengrid_item_append(m_gengrid, m_item_class, itemData, _thumbSelected, itemData); m_map_tab_views.insert(std::pair(hi->getTitle(),tabView)); // unselect by default @@ -254,9 +266,7 @@ void TabUI::addTabItem(std::shared_ptr>items) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); - //limiting number of added items to 10 - auto eit = std::min(items.end(), items.begin() + 10); - for (auto it = items.begin(); it != eit; ++it) { + for (auto it = items.begin(); it < items.end(); it++) { addTabItem(*it); } } @@ -292,12 +302,6 @@ Evas_Object * TabUI::_tab_grid_content_get(void *data, Evas_Object *obj, const c const char *part_name2 = "tab_thumbButton"; static const int part_name2_len = strlen(part_name2); - if (!strncmp(part_name2, part, part_name2_len)) { - Evas_Object *thumbButton = elm_button_add(obj); - elm_object_style_set(thumbButton, "tab_thumbButton"); - evas_object_smart_callback_add(thumbButton, "clicked", tizen_browser::base_ui::TabUI::_thumbSelected, data); - return thumbButton; - } if (!strncmp(part_name1, part, part_name1_len)) { if (itemData->item->getThumbnail()) { return tizen_browser::tools::EflTools::getEvasImage(itemData->item->getThumbnail(), itemData->tabUI->m_parent); @@ -317,8 +321,15 @@ void TabUI::_thumbSelected(void *data, Evas_Object*, void*) BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); if (data) { TabItemData *itemData = static_cast(data); - itemData->tabUI->clearItems(); - itemData->tabUI->tabClicked(itemData->item->getId()); + if (!itemData->tabUI->editMode) { + itemData->tabUI->clearItems(); + itemData->tabUI->tabClicked(itemData->item->getId()); + } else { + itemData->tabUI->closeTabsClicked(itemData->item->getId()); + Elm_Object_Item* it = elm_gengrid_selected_item_get(itemData->tabUI->m_gengrid); + elm_object_item_del(it); + elm_gengrid_realized_items_update(itemData->tabUI->m_gengrid); + } } } @@ -339,6 +350,18 @@ Evas_Object* TabUI::createNoHistoryLabel() return label; } +void TabUI::closeAllTabs() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + Elm_Object_Item* it = elm_gengrid_first_item_get(m_gengrid); + while (it) { + TabItemData *item = (TabItemData *)elm_object_item_data_get(it); + item->tabUI->closeTabsClicked(item->item->getId()); + it = elm_gengrid_item_next_get(it); + } + hide(); +} + void TabUI::setEmptyGengrid(bool setEmpty) { if (setEmpty) { @@ -348,6 +371,16 @@ void TabUI::setEmptyGengrid(bool setEmpty) } } +void TabUI::_focus_in(void * data, Evas*, Evas_Object * obj, void * event_info) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + Evas_Event_Mouse_In* ee = (Evas_Event_Mouse_In*)event_info; + int x, y; + TabUI* tabUI = static_cast(data); + Elm_Object_Item* it = elm_gengrid_at_xy_item_get(tabUI->m_gengrid, ee->canvas.x, ee->canvas.y, &x, &y); + if(it && tabUI->editMode) + elm_object_item_signal_emit(it, "selected", "over3"); +} } } diff --git a/services/TabUI/TabUI.h b/services/TabUI/TabUI.h index 19d5507..b83f118 100644 --- a/services/TabUI/TabUI.h +++ b/services/TabUI/TabUI.h @@ -47,7 +47,7 @@ public: boost::signals2::signal tabClicked; boost::signals2::signal newTabClicked; boost::signals2::signal newIncognitoTabClicked; - boost::signals2::signal closeTabsClicked; + boost::signals2::signal closeTabsClicked; boost::signals2::signal openedTabsClicked; boost::signals2::signal onOtherDevicesClicked; boost::signals2::signal closeTabUIClicked; @@ -67,17 +67,19 @@ private: static void _newincognitotab_clicked(void * data, Evas_Object * obj, void * event_info); static void _closetabs_clicked(void * data, Evas_Object * obj, void * event_info); static void _onotherdevices_clicked(void * data, Evas_Object * obj, void * event_info); + static void _focus_in(void * data, Evas*, Evas_Object * obj, void * event_info); Evas_Object* createTabUILayout(Evas_Object* parent); Evas_Object* createActionBar(Evas_Object* parent); Evas_Object* createTopButtons(Evas_Object* parent); Evas_Object* createNoHistoryLabel(); void createTabItemClass(); + void closeAllTabs(); -private: Evas_Object *m_tab_layout; Evas_Object *m_gengrid; Evas_Object *m_parent; + bool editMode; Elm_Gengrid_Item_Class * m_item_class; std::map m_map_tab_views; diff --git a/services/TabUI/edc/TabUI.edc b/services/TabUI/edc/TabUI.edc index 0094215..07f5192 100644 --- a/services/TabUI/edc/TabUI.edc +++ b/services/TabUI/edc/TabUI.edc @@ -63,12 +63,12 @@ group { name: "elm/button/base/tab_thumbButton"; } parts { part { name: "elm.swallow.content"; - type: RECT; + type: RECT; mouse_events: 1; repeat_events: 1; description { state: "default" 0.0; color: 0 0 0 0; - visible: 1; + visible: 0; rel1.relative: 0.0 0.0; rel2.relative: 1.0 1.0; align: 0.0 0.0; @@ -536,14 +536,62 @@ group { name: "elm/gengrid/item/tab_item/default"; //color: highlightTextColor; } } + part { name: "click_ok_to_close_text"; + type: TEXT; + description { state: "default" 0.0; + color: 0 119 246 204; + min: 300 48; + max: 300 48; + align: 0 0.5; + rel1 { + to: "tab_thumbnail"; + offset: 10 150; + relative: 0.0 0.0; + } + rel2 { + to: "tab_thumbnail"; + relative: 1.0 1.0; + } + text { + text: "[OK] to close"; + font: "Sans"; + size: 20; + align: 0.5 0.8; + } + visible: 0; + } + description { state: "selected" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + part { name: "tab_thumbButton"; - type: SWALLOW; - description { state: "default" 0.0; - rel1.to: "tab_thumbnail"; - rel2.to: "tab_thumbnail"; + type: IMAGE; + mouse_events: 1; + repeat_events: 1; + description { state: "default" 0.0; + color: 0 119 246 204; + visible: 0; + rel1 { + to: "bg"; + offset: 274 14; + relative: 0.0 0.0; + } + rel2 { + to: "bg"; + offset: 324 64; + relative: 0.0 0.0; + } + align: 0.0 0.0; + image.normal: "ico_delete.png"; + } + description { state: "selected"; + inherit: "default" 0.0; + visible: 1; + } } - } part { name: "over2"; type: RECT; @@ -561,7 +609,7 @@ group { name: "elm/gengrid/item/tab_item/default"; repeat_events: 1; description { state: "default" 0.0; color: 0 0 0 0; - rel1.to: "background"; + rel1.to: "bg"; rel2.to: "background"; } } @@ -583,6 +631,15 @@ group { name: "elm/gengrid/item/tab_item/default"; target: "background"; target: "focus_highlight"; target: "bg"; + target: "tab_thumbButton"; + target: "click_ok_to_close_text"; + } + program { name: "close_icon_show"; + signal: "selected"; + source: "over3"; + action: STATE_SET "selected" 0.0; + target: "tab_thumbButton"; + target: "click_ok_to_close_text"; } } } @@ -900,7 +957,7 @@ group { name: "action_bar_layout"; visible: 1; } } - part{ + part { name: "closetabs_text"; type: TEXT; scale: 1; @@ -911,7 +968,7 @@ group { name: "action_bar_layout"; rel2 { relative: 1.0 1.0;to: "closetabs_button";} color: 0 0 0 255; text { - text: "Close all"; + text: "Close Tabs"; font: "Sans"; size: 27; align: 0.5 0.5; @@ -1108,7 +1165,6 @@ group { name: "action_bar_layout"; action: STATE_SET "highlight" 0.0; target: "closetabs_button"; target: "closetabs_over"; - target: "closetabs_text"; } program { name: "mouse_out_closetabs_click"; @@ -1117,7 +1173,6 @@ group { name: "action_bar_layout"; action: STATE_SET "default" 0.0; target: "closetabs_button"; target: "closetabs_over"; - target: "closetabs_text"; } program { name: "mouse_in_close_click"; -- 2.7.4 From 8bd8096777051f3025fff83bd36ac1ea092e2550 Mon Sep 17 00:00:00 2001 From: "t.dakowicz" Date: Thu, 3 Sep 2015 16:25:39 +0200 Subject: [PATCH 11/16] TT-158 Fixed 'Clear History' bug [Issue#] https://bugs.tizen.org/jira/browse/TT-158 [Problem] Browser's crash after clicking on 'clear history' button [Cause] 'm_historyUI' object was not freed after closing the HistoryUI, which caused multiple sending of the clearHistory signal [Solution] Provided proper object management and prevented multiple creation of the 'm_historyUI'. In addition, there is a problem with displaying NoHistoryLabel from the HistoryUI - currently, it is not available from there [Verify] Do some browsing -> MoreMenu -> History Manager -> Clear Check if this action causes browser's crash Change-Id: I8be4b31c67b901d241d0bafdd621b72d5ea4c5f4 --- services/HistoryUI/HistoryUI.cpp | 25 +------------------------ services/HistoryUI/HistoryUI.h | 3 --- services/SimpleUI/SimpleUI.cpp | 27 ++++++++++++++------------- 3 files changed, 15 insertions(+), 40 deletions(-) diff --git a/services/HistoryUI/HistoryUI.cpp b/services/HistoryUI/HistoryUI.cpp index a2dc558..f9c3a12 100644 --- a/services/HistoryUI/HistoryUI.cpp +++ b/services/HistoryUI/HistoryUI.cpp @@ -185,7 +185,6 @@ void HistoryUI::addHistoryItem(std::shared_ptr hi) itemData->item = hi; itemData->historyUI = std::shared_ptr(this); _history_item_data.push_back(itemData); - setEmptyGengrid(false); } void HistoryUI::addHistoryItems(std::shared_ptr items) @@ -253,33 +252,12 @@ void HistoryUI::removeHistoryItem(const std::string& uri) Elm_Object_Item* historyView = m_map_history_views.at(uri); elm_object_item_del(historyView); m_map_history_views.erase(uri); - - setEmptyGengrid(0 == m_map_history_views.size()); -} - -Evas_Object* HistoryUI::createNoHistoryLabel() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - Evas_Object *label = elm_label_add(m_parent); - elm_object_text_set(label, "No favorite websites."); - evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL); - return label; -} - -void HistoryUI::setEmptyGengrid(bool setEmpty) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - Evas_Object *obj = (setEmpty ? createNoHistoryLabel() : nullptr); - elm_object_part_content_set(m_gengrid, "elm.swallow.empty", obj); } void HistoryUI::hide() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - evas_object_hide(elm_layout_content_get(m_history_layout, "m_genListToday")); - evas_object_hide(elm_layout_content_get(m_history_layout, "m_gengrid")); - evas_object_hide(elm_layout_content_get(m_history_layout, "m_ActionBar")); + evas_object_hide(elm_layout_content_get(m_history_layout, "action_bar_history")); evas_object_hide(m_history_layout); } @@ -291,7 +269,6 @@ void HistoryUI::clearItems() elm_gengrid_clear(m_gengrid); m_map_history_views.clear(); _history_item_data.clear(); - setEmptyGengrid(true); } void HistoryUI::_history_item_clicked_cb(void *data, Evas_Object *obj, void *event_info) diff --git a/services/HistoryUI/HistoryUI.h b/services/HistoryUI/HistoryUI.h index 1eb4a24..83bd6f6 100644 --- a/services/HistoryUI/HistoryUI.h +++ b/services/HistoryUI/HistoryUI.h @@ -60,8 +60,6 @@ private: static void _close_clicked_cb(void *data, Evas_Object *obj, void *event_info); static void _history_item_clicked_cb(void *data, Evas_Object *obj, void *event_info); - void setEmptyGengrid(bool setEmpty); - Evas_Object *m_history_layout; Evas_Object *m_actionBar; Evas_Object *m_genListToday; @@ -71,7 +69,6 @@ private: Elm_Gengrid_Item_Class * m_item_class; std::map m_map_history_views; std::string m_edjFilePath; - Evas_Object *createNoHistoryLabel(); }; } diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 91bcecb..de0e0d6 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -313,7 +313,6 @@ int SimpleUI::exec(const std::string& _url) m_mainUI->mostVisitedClicked.connect(boost::bind(&SimpleUI::onMostVisitedClicked, this,_1)); m_mainUI->bookmarkClicked.connect(boost::bind(&SimpleUI::onBookmarkButtonClicked, this,_1)); m_mainUI->bookmarkManagerClicked.connect(boost::bind(&SimpleUI::onBookmarkManagerButtonClicked, this,_1)); - } if (url.empty()) { @@ -621,8 +620,7 @@ void SimpleUI::onClearHistoryClicked(const std::string&) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); m_historyService->clearAllHistory(); - m_mainUI->clearHistoryGenlist(); - m_mainUI->showHistory(); + m_historyUI.reset(); } void SimpleUI::onMostVisitedClicked(const std::string&) @@ -1111,21 +1109,24 @@ void SimpleUI::showMainUI() void SimpleUI::showHistoryUI(const std::string& str) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_historyUI = - std::dynamic_pointer_cast - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.historyui")); - M_ASSERT(m_historyUI); - m_historyUI->clearHistoryClicked.connect(boost::bind(&SimpleUI::onClearHistoryClicked, this,_1)); - m_historyUI->closeHistoryUIClicked.connect(boost::bind(&SimpleUI::closeHistoryUI, this,_1)); - m_historyUI->historyItemClicked.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this,_1)); - m_historyUI->addHistoryItems(getHistory()); - m_historyUI->show(m_window.get()); + if(!m_historyUI) + { + m_historyUI = + std::dynamic_pointer_cast + (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.historyui")); + M_ASSERT(m_historyUI); + m_historyUI->clearHistoryClicked.connect(boost::bind(&SimpleUI::onClearHistoryClicked, this,_1)); + m_historyUI->closeHistoryUIClicked.connect(boost::bind(&SimpleUI::closeHistoryUI, this,_1)); + m_historyUI->historyItemClicked.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this,_1)); + m_historyUI->addHistoryItems(getHistory()); + m_historyUI->show(m_window.get()); + } } void SimpleUI::closeHistoryUI(const std::string& str) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_historyUI = nullptr; + m_historyUI.reset(); } void SimpleUI::showSettingsUI(const std::string& str) -- 2.7.4 From f0d3a9e9e6a6a06069ed4b1b3d15e7103e336637 Mon Sep 17 00:00:00 2001 From: Albert Malewski Date: Fri, 4 Sep 2015 13:23:47 +0200 Subject: [PATCH 12/16] Added switching between 'Open Tabs' and 'On Other Devices' [Issue] https://bugs.tizen.org/jira/browse/TT-149 [Problem] "Opened Tabs" is not toggle with "On Other Devices" in Tab Manager. [Cause] Lack of implementation. [Solution] Added boolean onOtherDevicesSwitch variable, which allows to switch between 'Open Tabs' and 'On Other Devices' correctly. Changed type of onotherdevices_click and openedtabs_click from RECT to SWALLOW. Additionally, changed 'tab_gengird' to 'tab_gengrid'. [Verify] Launch browser > Open new tab > Tabs > On Other Devices > Obs Tabs should be hidden when 'On Other Devices' is clicked. Change-Id: I18529df81e274dcbc658e8db7ef038b4080e907d --- services/SimpleUI/SimpleUI.cpp | 6 +++++ services/SimpleUI/SimpleUI.h | 1 + services/TabUI/TabUI.cpp | 51 +++++++++++++++++++++++++++++++----------- services/TabUI/TabUI.h | 2 ++ services/TabUI/edc/TabUI.edc | 18 +++++---------- 5 files changed, 53 insertions(+), 25 deletions(-) diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index de0e0d6..1b0e8d5 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -938,6 +938,7 @@ void SimpleUI::showTabUI() m_tabUI->tabClicked.connect(boost::bind(&SimpleUI::tabClicked, this,_1)); m_tabUI->closeTabsClicked.connect(boost::bind(&SimpleUI::closeTabsClicked, this,_1)); m_tabUI->newIncognitoTabClicked.connect(boost::bind(&SimpleUI::newTabClicked, this,_1)); + m_tabUI->tabsCount.connect(boost::bind(&SimpleUI::tabsCount, this)); m_tabUI->show(m_window.get()); m_tabUI->addTabItems(m_webEngine->getTabContents()); } @@ -966,6 +967,11 @@ void SimpleUI::closeTabsClicked(const tizen_browser::basic_webengine::TabId& tab m_webEngine->closeTab(tabId); } +int SimpleUI::tabsCount() +{ + return m_webEngine->tabsCount(); +} + void SimpleUI::handleConfirmationRequest(basic_webengine::WebConfirmationPtr webConfirmation) { BROWSER_LOGD("%s", __func__); diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index b8df3a1..f8faab1 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -270,6 +270,7 @@ private: void tabLimitPopupButtonClicked(PopupButtons button, std::shared_ptr< PopupData > /*popupData*/); void openLinkFromPopup(const std::string &); void disableHistoryButton(bool flag); + int tabsCount(); void onNetworkError(); void onNetworkConnected(); diff --git a/services/TabUI/TabUI.cpp b/services/TabUI/TabUI.cpp index cfb9e36..e93f03e 100644 --- a/services/TabUI/TabUI.cpp +++ b/services/TabUI/TabUI.cpp @@ -51,6 +51,7 @@ TabUI::TabUI() elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); createTabItemClass(); editMode = false; + onOtherDevicesSwitch = false; } TabUI::~TabUI() @@ -100,7 +101,7 @@ Evas_Object* TabUI::createTabUILayout(Evas_Object* parent) //create gengrid containing tabs m_gengrid = elm_gengrid_add(tab_layout); - elm_object_part_content_set(tab_layout, "tab_gengird", m_gengrid); + elm_object_part_content_set(tab_layout, "tab_gengrid", m_gengrid); M_ASSERT(m_parent); elm_gengrid_align_set(m_gengrid, 0, 0); @@ -155,7 +156,6 @@ Evas_Object* TabUI::createActionBar(Evas_Object* parent) return actionBarLayout; } - void TabUI::_close_clicked(void* data, Evas_Object*, void*) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -164,6 +164,7 @@ void TabUI::_close_clicked(void* data, Evas_Object*, void*) tabUI->closeTabUIClicked(std::string()); tabUI->clearItems(); tabUI->editMode = false; + tabUI->onOtherDevicesSwitch = false; } } @@ -171,7 +172,7 @@ void TabUI::hide() { evas_object_hide(elm_layout_content_get(m_tab_layout, "action_bar")); evas_object_hide(elm_layout_content_get(m_tab_layout, "top_bar")); - evas_object_hide(elm_layout_content_get(m_tab_layout, "tab_gengird")); + evas_object_hide(elm_layout_content_get(m_tab_layout, "tab_gengrid")); evas_object_hide(m_tab_layout); } @@ -188,14 +189,14 @@ Evas_Object* TabUI::createTopButtons(Evas_Object* parent) Evas_Object *button = elm_button_add(topLayout); elm_object_style_set(button, "tab_button"); evas_object_smart_callback_add(button, "clicked", _openedtabs_clicked, this); - //TODO: "openedtabs_button" is not swallow, change it when implementing callbacks - elm_object_part_content_set(topLayout, "openedtabs_button", button); + evas_object_show(button); + elm_layout_content_set(topLayout, "openedtabs_click", button); button = elm_button_add(topLayout); elm_object_style_set(button, "tab_button"); - //TODO: "onotherdevices_button" is not swallow, change it when implementing callbacks evas_object_smart_callback_add(button, "clicked", _onotherdevices_clicked, this); - elm_object_part_content_set(topLayout, "onotherdevices_button", button); + evas_object_show(button); + elm_layout_content_set(topLayout, "onotherdevices_click", button); return topLayout; } @@ -208,17 +209,36 @@ void TabUI::_newtab_clicked(void * data, Evas_Object*, void*) tabUI->clearItems(); tabUI->newTabClicked(std::string()); tabUI->editMode = false; + tabUI->onOtherDevicesSwitch = false; } } -void TabUI::_openedtabs_clicked(void*, Evas_Object*, void*) +void TabUI::_openedtabs_clicked(void* data, Evas_Object*, void*) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + TabUI* tabUI = static_cast(data); + if(tabUI->onOtherDevicesSwitch) { + tabUI->onOtherDevicesSwitch = false; + evas_object_show(tabUI->m_gengrid); + elm_layout_text_set(elm_layout_content_get(tabUI->m_tab_layout, "action_bar"), "closetabs_text", "Close Tabs"); + tabUI->editMode = false; + } + } } -void TabUI::_onotherdevices_clicked(void*, Evas_Object*, void*) +void TabUI::_onotherdevices_clicked(void* data, Evas_Object*, void*) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + TabUI* tabUI = static_cast(data); + if(!tabUI->onOtherDevicesSwitch) { + tabUI->onOtherDevicesSwitch = true; + evas_object_hide(tabUI->m_gengrid); + elm_layout_text_set(elm_layout_content_get(tabUI->m_tab_layout, "action_bar"), "closetabs_text", "Close Tabs"); + tabUI->editMode = false; + } + } } void TabUI::_newincognitotab_clicked(void* data, Evas_Object*, void*) @@ -229,6 +249,7 @@ void TabUI::_newincognitotab_clicked(void* data, Evas_Object*, void*) tabUI->clearItems(); tabUI->newIncognitoTabClicked(std::string()); tabUI->editMode = false; + tabUI->onOtherDevicesSwitch = false; } } @@ -237,11 +258,11 @@ void TabUI::_closetabs_clicked(void* data, Evas_Object* obj, void*) BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); if (data) { TabUI* tabUI = static_cast(data); - if (!tabUI->editMode) { + if (!tabUI->editMode && !tabUI->onOtherDevicesSwitch) { tabUI->editMode = true; BROWSER_LOGD("[%s:%d] --------> edit mode: %d ", __PRETTY_FUNCTION__, __LINE__, tabUI->editMode); elm_layout_text_set(elm_layout_content_get(tabUI->m_tab_layout, "action_bar"), "closetabs_text", "Close all"); - } else { + } else if (tabUI->editMode && !tabUI->onOtherDevicesSwitch) { tabUI->closeAllTabs(); elm_gengrid_realized_items_update(tabUI->m_gengrid); } @@ -329,6 +350,10 @@ void TabUI::_thumbSelected(void *data, Evas_Object*, void*) Elm_Object_Item* it = elm_gengrid_selected_item_get(itemData->tabUI->m_gengrid); elm_object_item_del(it); elm_gengrid_realized_items_update(itemData->tabUI->m_gengrid); + int tabsNumber = *(itemData->tabUI->tabsCount()); + BROWSER_LOGD("%s:%d %s, items: %d", __FILE__, __LINE__, __func__, tabsNumber); + if (!tabsNumber) + itemData->tabUI->hide(); } } } diff --git a/services/TabUI/TabUI.h b/services/TabUI/TabUI.h index b83f118..21cd5b2 100644 --- a/services/TabUI/TabUI.h +++ b/services/TabUI/TabUI.h @@ -51,6 +51,7 @@ public: boost::signals2::signal openedTabsClicked; boost::signals2::signal onOtherDevicesClicked; boost::signals2::signal closeTabUIClicked; + boost::signals2::signal tabsCount; private: static char* _grid_text_get(void *data, Evas_Object *obj, const char *part); @@ -80,6 +81,7 @@ private: Evas_Object *m_gengrid; Evas_Object *m_parent; bool editMode; + bool onOtherDevicesSwitch; Elm_Gengrid_Item_Class * m_item_class; std::map m_map_tab_views; diff --git a/services/TabUI/edc/TabUI.edc b/services/TabUI/edc/TabUI.edc index 07f5192..faa4dac 100644 --- a/services/TabUI/edc/TabUI.edc +++ b/services/TabUI/edc/TabUI.edc @@ -256,7 +256,7 @@ group { visible: 1; } } - part { name: "tab_gengird"; + part { name: "tab_gengrid"; type : SWALLOW; scale: 1; description { @@ -1317,11 +1317,8 @@ group { name: "top_buttons_layout"; visible: 1; align: 0 0; fixed: 1 1; - min: 348 65; - max: 348 65; - rel1 { relative: 0.0 0.0; to: "openedtabs_over";} - rel2 { relative: 1.0 1.0; to: "openedtabs_over";} - color_class: transparent; + rel1 { relative: 0.0 0.0; to: "openedtabs_button";} + rel2 { relative: 1.0 1.0; to: "openedtabs_button";} } } part { @@ -1400,7 +1397,7 @@ group { name: "top_buttons_layout"; } part { - name: "onotherdevicess_click"; + name: "onotherdevices_click"; scale:1; type: SWALLOW; description { @@ -1408,11 +1405,8 @@ group { name: "top_buttons_layout"; visible: 1; align: 0 0; fixed: 1 1; - min: 348 65; - max: 348 65; - rel1 { relative: 0.0 0.0; to: "onotherdevices_over";} - rel2 { relative: 1.0 1.0; to: "onotherdevices_over";} - color_class: transparent; + rel1 { relative: 0.0 0.0; to: "onotherdevices_button";} + rel2 { relative: 1.0 1.0; to: "onotherdevices_button";} } } } -- 2.7.4 From 22ed25f1896905d77d85e43726e7bebf932ff70d Mon Sep 17 00:00:00 2001 From: Maciej Skrzypkowski Date: Tue, 8 Sep 2015 10:39:46 +0200 Subject: [PATCH 13/16] Refactoring - deleted unused history SQLite classes. [Issue#] N/A [Problem] These history classes were not used. [Cause] N/A [Solution] Removed dead code. [Verify] Open few pages, check if they appeared in history. Change-Id: Ia996b2259a7cc8c6e5506eb707a4f0a89c494aae Signed-off-by: Maciej Skrzypkowski --- services/HistoryService/HistoryService.cpp | 7 - services/HistoryService/HistoryService.h | 37 -- services/StorageService/CMakeLists.txt | 6 - services/StorageService/HistoryException.h | 44 -- services/StorageService/HistorySQLite.h | 134 ---- services/StorageService/HistoryStorage.h | 92 --- services/StorageService/StorageService.h | 56 -- services/StorageService/src/HistoryException.cpp | 39 -- services/StorageService/src/HistorySQLite.cpp | 752 ----------------------- services/StorageService/src/HistoryStorage.cpp | 35 -- services/StorageService/src/StorageService.cpp | 99 --- 11 files changed, 1301 deletions(-) delete mode 100644 services/StorageService/HistoryException.h delete mode 100644 services/StorageService/HistorySQLite.h delete mode 100644 services/StorageService/HistoryStorage.h delete mode 100644 services/StorageService/src/HistoryException.cpp delete mode 100644 services/StorageService/src/HistorySQLite.cpp delete mode 100644 services/StorageService/src/HistoryStorage.cpp diff --git a/services/HistoryService/HistoryService.cpp b/services/HistoryService/HistoryService.cpp index e3d2a82..b5826ef 100644 --- a/services/HistoryService/HistoryService.cpp +++ b/services/HistoryService/HistoryService.cpp @@ -338,9 +338,6 @@ void HistoryService::insertOrRefresh(std::shared_ptr hi) { //getStorageManager()->insertOrRefresh(hi); } -/** - * @throws HistoryException on error - */ void HistoryService::clearAllHistory() { bp_history_adaptor_reset(); @@ -368,10 +365,6 @@ int HistoryService::getHistoryId(const std::string & url) return 0; } - -/** - * @throws HistoryException on error - */ void HistoryService::clearURLHistory(const std::string & url) { int id = getHistoryId(url); diff --git a/services/HistoryService/HistoryService.h b/services/HistoryService/HistoryService.h index f6fc91c..f8e10e1 100644 --- a/services/HistoryService/HistoryService.h +++ b/services/HistoryService/HistoryService.h @@ -26,7 +26,6 @@ #include "service_macros.h" #include "BrowserImage.h" #include "HistoryItem.h" -#include "HistoryStorage.h" #include "StorageService.h" #include #define DOMAIN_HISTORY_SERVICE "org.tizen.browser.historyservice" @@ -42,40 +41,13 @@ public: HistoryService(); virtual ~HistoryService(); virtual std::string getName(); - int getHistoryId(const std::string & url); - - /** - * @throws HistoryException on error - */ void addHistoryItem(std::shared_ptr hi, std::shared_ptr thumbnail=std::shared_ptr()); - - /** - * If hi->getUrl() exists on a table HISTORY update visit_counter and visit_date, unless insert hi to database. - * - * @throws HistoryException on error - */ void insertOrRefresh(std::shared_ptr hi); - - /** - * @throws HistoryException on error - */ void clearAllHistory(); - - /** - * @throws HistoryException on error - */ void clearURLHistory(const std::string & url); - - /** - * @throws HistoryException on error - */ std::shared_ptr getHistoryItem(const std::string & url); - - /** - * @throws HistoryException on error - */ std::shared_ptr getHistoryAll(); std::shared_ptr getHistoryToday(); std::shared_ptr getHistoryYesterday(); @@ -85,17 +57,8 @@ public: std::shared_ptr getCurrentTab(); std::shared_ptr getMostVisitedHistoryItems(); std::shared_ptr getHistoryItemsByURL(const std::string & url, int maxItems); - - /** - * @throws HistoryException on error - */ int getHistoryItemsCount(); - - /** - * @throws HistoryException on error - */ int getHistoryVisitCounter(const std::string & url); - void setStorageServiceTestMode(bool testmode = true); boost::signals2::signalhistoryEmpty; diff --git a/services/StorageService/CMakeLists.txt b/services/StorageService/CMakeLists.txt index bfd5488..0b6aaf3 100644 --- a/services/StorageService/CMakeLists.txt +++ b/services/StorageService/CMakeLists.txt @@ -8,9 +8,6 @@ set(StorageServiceSOURCES Storage/SQLDatabase.cpp src/BookmarksSorage.cpp src/BookmarksSQLite.cpp - src/HistoryException.cpp - src/HistorySQLite.cpp - src/HistoryStorage.cpp src/StorageService.cpp ) @@ -20,9 +17,6 @@ set(StorageService_HEADERS StorageService.h BookmarksStorage.h BookmarksSQLite.h - HistoryStorage.h - HistorySQLite.h - HistoryException.h Storage/include/Field.h Storage/include/DriverManager.h Storage/include/SQLDatabase.h diff --git a/services/StorageService/HistoryException.h b/services/StorageService/HistoryException.h deleted file mode 100644 index d6a5849..0000000 --- a/services/StorageService/HistoryException.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __HISTORY_EXCEPTION_H -#define __HISTORY_EXCEPTION_H - -#include -#include - -#include "ServiceFactory.h" -#include "service_macros.h" - -namespace tizen_browser -{ -namespace services -{ - -class BROWSER_EXPORT HistoryException : public std::exception -{ -public: - HistoryException(const std::string & message); - virtual ~HistoryException() throw (); - virtual const char * getMessage() const throw (); -protected: - std::string m_message; -}; - -} -} - -#endif diff --git a/services/StorageService/HistorySQLite.h b/services/StorageService/HistorySQLite.h deleted file mode 100644 index 451e2cd..0000000 --- a/services/StorageService/HistorySQLite.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __HISTORY_H -#define __HISTORY_H - -#include -#include -#include -#include - -#include "BrowserImage.h" -#include "Config.h" -#include "HistoryStorage.h" -#include "SQLDatabase.h" - -///\todo temporary dirty include -#include "../HistoryService/HistoryItem.h" - -namespace tizen_browser -{ -namespace services -{ - -class HistorySQLite: virtual public HistoryStorage -{ -public: - HistorySQLite(); - ~HistorySQLite(); - - /** - * @throws HistoryException on error - */ - void addHistoryItem(std::shared_ptr hi, storage::SQLTransactionScope * transactionScope); - - void addHistoryItem(std::shared_ptr hi); - - /** - * If hi->getUrl() exists on a table HISTORY update visit_counter and visit_date, unless insert hi to database. - * - * @throws HistoryException on error - */ - void insertOrRefresh(std::shared_ptr hi, storage::SQLTransactionScope * transactionScope); - - void insertOrRefresh(std::shared_ptr hi); - - /** - * @throws HistoryException on error - */ - std::shared_ptr getFavicon(const std::string & url, storage::SQLTransactionScope * transactionScope); - - std::shared_ptr getFavicon(const std::string & url); - - /** - * @throws HistoryException on error - */ - void deleteHistory(storage::SQLTransactionScope * transactionScope); - - void deleteHistory(); - - /** - * @throws HistoryException on error - */ - void deleteHistory(const std::string & url, storage::SQLTransactionScope * transactionScope); - - void deleteHistory(const std::string & url); - - /** - * @throws HistoryException on error - */ - std::shared_ptr getHistoryItem(const std::string & url, storage::SQLTransactionScope * transactionScope); - - std::shared_ptr getHistoryItem(const std::string & url); - - /** - * @throws HistoryException on error - */ - HistoryItemVector & getHistoryItems(storage::SQLTransactionScope * transactionScope, int historyDepthInDays, int maxItems); - - HistoryItemVector & getHistoryItems(int historyDepthInDays, int maxItems); - - /** - * @throws HistoryException on error - */ - int getHistoryItemsCount(storage::SQLTransactionScope * transactionScope); - - int getHistoryItemsCount(); - - /** - * @throws HistoryException on error - */ - int getHistoryVisitCounter(const std::string & url, storage::SQLTransactionScope * transactionScope); - - int getHistoryVisitCounter(const std::string & url); - - void init(bool testmode = false); - -private: - config::DefaultConfig config; - std::string DB_HISTORY; - bool m_dbHistoryInitialised; - - HistoryItemVector m_histItems; - /** - * @throws StorageExceptionInitialization on error - */ - void initDatabaseHistory(const std::string & db_str); - - /** - * @throws StorageException on error - */ - std::shared_ptr createHistoryItem(const storage::SQLQuery & query); - - bool m_isInitialized; - -}; - -} -} - -#endif diff --git a/services/StorageService/HistoryStorage.h b/services/StorageService/HistoryStorage.h deleted file mode 100644 index 0e55ff6..0000000 --- a/services/StorageService/HistoryStorage.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __HISTORYSTORAGE_H -#define __HISTORYSTORAGE_H - -#include -#include -#include - -#include "BrowserImage.h" - -///\todo temporary dirty include -#include "../HistoryService/HistoryItem.h" - -namespace tizen_browser -{ -namespace services -{ - -class HistoryStorage -{ -public: - HistoryStorage(); - virtual ~HistoryStorage(); - - /** - * @throws HistoryException on error - */ - virtual void addHistoryItem(std::shared_ptr hi) = 0; - - /** - * If hi->getUrl() exists on a table HISTORY update visit_counter and visit_date, unless insert hi to database. - * - * @throws HistoryException on error - */ - virtual void insertOrRefresh(std::shared_ptr hi) = 0; - - /** - * @throws HistoryException on error - */ - virtual std::shared_ptr getFavicon(const std::string & url) = 0; - - /** - * @throws HistoryException on error - */ - virtual void deleteHistory() = 0; - - /** - * @throws HistoryException on error - */ - virtual void deleteHistory(const std::string & url) = 0; - - /** - * @throws HistoryException on error - */ - virtual std::shared_ptr getHistoryItem(const std::string & url) = 0; - - /** - * @throws HistoryException on error - */ - virtual HistoryItemVector & getHistoryItems(int historyDepthInDays, int maxItems) = 0; - - /** - * @throws HistoryException on error - */ - virtual int getHistoryItemsCount() = 0; - - /** - * @throws HistoryException on error - */ - virtual int getHistoryVisitCounter(const std::string & url) = 0; - -}; - -} -} - -#endif diff --git a/services/StorageService/StorageService.h b/services/StorageService/StorageService.h index 96c2145..ad67a65 100644 --- a/services/StorageService/StorageService.h +++ b/services/StorageService/StorageService.h @@ -23,12 +23,8 @@ #include "service_macros.h" #include "BrowserImage.h" #include "Config.h" -#include "HistorySQLite.h" #include "BookmarksStorage.h" #include "BookmarksSQLite.h" -///\todo temporary dirty include -//#include "HistoryItem.h" -#include "../HistoryService/HistoryItem.h" #define DOMAIN_STORAGE_SERVICE "org.tizen.browser.storageservice" @@ -84,54 +80,6 @@ public: */ static void checkAndCreateTable(storage::SQLTransactionScope * transactionScope, const std::string & tablename, const std::string & ddl); - /** - * @throws HistoryException on error - */ - void addHistoryItem(std::shared_ptr hi); - - /** - * If hi->getUrl() exists on a table HISTORY update visit_counter and visit_date, unless insert hi to database. - * - * @throws HistoryException on error - */ - void insertOrRefresh(std::shared_ptr hi); - - /** - * @throws HistoryException on error - */ - std::shared_ptr getFavicon(const std::string & url); - - /** - * @throws HistoryException on error - */ - void deleteHistory(); - - /** - * @throws HistoryException on error - */ - void deleteHistory(const std::string & url); - - /** - * @throws HistoryException on error - */ - std::shared_ptr getHistoryItem(const std::string & url); - - /** - * @throws HistoryException on error - */ - HistoryItemVector & getHistoryItems(int historyDepthInDays, int maxItems); - - /** - * @throws HistoryException on error - */ - int getHistoryItemsCount(); - - /** - * @throws HistoryException on error - */ - int getHistoryVisitCounter(const std::string & url); - - void init(bool testmode = false); /** @@ -147,9 +95,6 @@ private: */ void initDatabaseSettings(const std::string & db_str); - - void initHistoryService(const std::string & storage, bool testmode); - /** * @throws StorageExceptionInitialization on error */ @@ -159,7 +104,6 @@ private: config::DefaultConfig config; std::string DB_SETTINGS; - std::shared_ptr m_history; // std::shared_ptr m_rssStorage; std::shared_ptr m_bookmarks; diff --git a/services/StorageService/src/HistoryException.cpp b/services/StorageService/src/HistoryException.cpp deleted file mode 100644 index 929fce7..0000000 --- a/services/StorageService/src/HistoryException.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "HistoryException.h" - -namespace tizen_browser -{ -namespace services -{ - -HistoryException::HistoryException(const std::string & message) -{ - this->m_message = message; -} - -HistoryException::~HistoryException() throw () -{ -} - -const char * HistoryException::getMessage() const throw () -{ - return m_message.c_str(); -} - -} -} diff --git a/services/StorageService/src/HistorySQLite.cpp b/services/StorageService/src/HistorySQLite.cpp deleted file mode 100644 index 1b232c9..0000000 --- a/services/StorageService/src/HistorySQLite.cpp +++ /dev/null @@ -1,752 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "HistorySQLite.h" - -#include - -#include "BrowserLogger.h" -#include "DriverManager.h" -#include "Blob.h" -#include "StorageException.h" -#include "StorageExceptionInitialization.h" -#include "HistoryException.h" -#include "EflTools.h" -#include "StorageService.h" - -namespace -{ -// ------ Database FAVICON ------ -const std::string TABLE_FAVICON = "FAVICON"; -//const std::string COL_FAVICON_ID = "id"; -const std::string COL_FAVICON_IMAGE_TYPE = "image_type"; -const std::string COL_FAVICON_WIDTH = "width"; -const std::string COL_FAVICON_HEIGHT = "height"; -const std::string COL_FAVICON_URI_PK = "uri"; - -const std::string COL_FAVICON_FAVICON = "fav_icon"; - -const std::string FAVICON_MODIFIERS = "DEFERRABLE INITIALLY DEFERRED"; - -const std::string DDL_CREATE_TABLE_FAVICON = "CREATE TABLE " + TABLE_FAVICON - + "(" + COL_FAVICON_URI_PK + " TEXT PRIMARY KEY, " - + COL_FAVICON_WIDTH + " INTEGER DEFAULT 0, " - + COL_FAVICON_HEIGHT + " INTEGER DEFAULT 0, " - + COL_FAVICON_IMAGE_TYPE + " INTEGER DEFAULT 0, " - + COL_FAVICON_FAVICON + " BLOB " - + ")"; - -const std::string INSERT_TABLE_FAVICON = "insert into " + TABLE_FAVICON + " (" - + COL_FAVICON_URI_PK + ", " - + COL_FAVICON_WIDTH + ", " - + COL_FAVICON_HEIGHT + ", " - + COL_FAVICON_IMAGE_TYPE + ", " - + COL_FAVICON_FAVICON - + ") values (?, ?, ?, ?, ?)"; - -//const std::string VIRTUAL_COL_FAVICON_ROWID = "rowid"; -//const std::string SELECT_FAVICON_LAST_ID = "SELECT last_insert_rowid() AS " + VIRTUAL_COL_FAVICON_ROWID + " FROM " + TABLE_FAVICON + " LIMIT 1"; -const std::string SELECT_FAVICON_EXISTS = - "select " + COL_FAVICON_URI_PK + " from " + TABLE_FAVICON - + " where " + COL_FAVICON_URI_PK + "=?"; - -const std::string DELETE_ALL_FAVICON = "delete from " + TABLE_FAVICON; -// ------ (end) Database FAVICON ------ - -// ------ Database HISTORY ------ -const std::string TABLE_HISTORY = "HISTORY"; -const std::string COL_HISTORY_URL = "url"; -const std::string COL_HISTORY_TITLE = "title"; -const std::string COL_HISTORY_VISIT_DATE = "visit_date"; -const std::string COL_HISTORY_VISIT_COUNTER = "visit_counter"; -const std::string COL_HISTORY_URI_FK = "uri_fk"; - -// foreign key -//const std::string COL_HISTORY_FAVICON_ID_FK = "favicon_id_fk"; - - -const std::string DDL_CREATE_TABLE_HISTORY = "CREATE TABLE " + TABLE_HISTORY - + "(" + COL_HISTORY_URL + " TEXT PRIMARY KEY, " - + COL_HISTORY_TITLE + " TEXT, " - + COL_HISTORY_VISIT_DATE + " DATETIME DEFAULT (datetime('now', 'localtime')), " - + COL_HISTORY_VISIT_COUNTER + " INTEGER DEFAULT 1, " - + COL_HISTORY_URI_FK + " TEXT REFERENCES " + TABLE_FAVICON + "(" + COL_FAVICON_URI_PK + ") " - + FAVICON_MODIFIERS - + ")"; - -const std::string INSERT_TABLE_HISTORY = "insert or replace into " + TABLE_HISTORY + " (" - + COL_HISTORY_URL + ", " - + COL_HISTORY_TITLE + ", " - + COL_HISTORY_VISIT_DATE + ", " - + COL_HISTORY_VISIT_COUNTER + ", " - + COL_HISTORY_URI_FK - + ") values (?,?,?,?,?)"; - -const std::string INSERT_TABLE_HISTORY_DEFAULT_VALUES = "insert or replace into " + TABLE_HISTORY + " (" - + COL_HISTORY_URL + ", " - + COL_HISTORY_TITLE + ", " - + COL_HISTORY_URI_FK - + ") values (?,?,?)"; - -const std::string VIRTUAL_COL_HISTORY_AMOUNT = "amount"; -const std::string SELECT_HISTORY_COUNT_ID = "select count(*) as " + VIRTUAL_COL_HISTORY_AMOUNT + " from " + TABLE_HISTORY; -const std::string SELECT_HISTORY_VISIT_COUNTER = "select " + COL_HISTORY_VISIT_COUNTER + " from " + TABLE_HISTORY + " where " + COL_HISTORY_URL + "=?"; - -const std::string DELETE_HISTORY_ITEM = "delete from " + TABLE_HISTORY + " where " + COL_HISTORY_URL + "=?"; -const std::string DELETE_ALL_HISTORY = "delete from " + TABLE_HISTORY; - -const std::string UPDATE_HISTORY_ITEM_COUNTER_DATE = - "update HISTORY set visit_counter=visit_counter+1, visit_date=(datetime('now', 'localtime')) where url=?"; - -// ------ (end) Database HISTORY ------ - -const std::string SELECT_FAVICON = - "select f." + COL_FAVICON_FAVICON + " as " + COL_FAVICON_FAVICON + "," - + "f." + COL_FAVICON_WIDTH + " as " + COL_FAVICON_WIDTH + "," - + "f." + COL_FAVICON_HEIGHT + " as " + COL_FAVICON_HEIGHT + "," - + "f." + COL_FAVICON_IMAGE_TYPE + " as " + COL_FAVICON_IMAGE_TYPE - + " from " - + TABLE_FAVICON + " f, " + TABLE_HISTORY + " h" - + " where f." + COL_FAVICON_URI_PK + "=h." + COL_HISTORY_URI_FK - + " and " + COL_HISTORY_URL + "=?"; - -const int SELECT_FAVICON_FAVICON = 0; -const int SELECT_FAVICON_WIDTH = 1; -const int SELECT_FAVICON_HEIGHT = 2; -const int SELECT_FAVICON_IMAGE_TYPE = 3; - -const std::string SELECT_FULL_HISTORY_ALL_ROW = - "select f." + COL_FAVICON_FAVICON + " as " + COL_FAVICON_FAVICON - + ", f." + COL_FAVICON_WIDTH + " as " + COL_FAVICON_WIDTH - + ", f." + COL_FAVICON_HEIGHT + " as " + COL_FAVICON_HEIGHT - + ", f." + COL_FAVICON_IMAGE_TYPE + " as " + COL_FAVICON_IMAGE_TYPE - + ", h." + COL_HISTORY_URL + " as " + COL_HISTORY_URL - + ", h." + COL_HISTORY_TITLE + " as " + COL_HISTORY_TITLE - + ", h." + COL_HISTORY_VISIT_DATE + " as " + COL_HISTORY_VISIT_DATE - + ", h." + COL_HISTORY_VISIT_COUNTER + " as " + COL_HISTORY_VISIT_COUNTER - + ", h." + COL_HISTORY_URI_FK + " as " + COL_HISTORY_URI_FK - + " from " - + TABLE_HISTORY + " h left outer join " + TABLE_FAVICON + " f" - + " on f." + COL_FAVICON_URI_PK + "=h." + COL_HISTORY_URI_FK; - -const int SELECT_FULL_HISTORY_ALL_ROW_URL = 4; -const int SELECT_FULL_HISTORY_FAVICON = 0; -const int SELECT_FULL_HISTORY_FAVICON_IMAGE_TYPE = 3; -const int SELECT_FULL_HISTORY_FAVICON_WIDTH = 1; -const int SELECT_FULL_HISTORY_FAVICON_HEIGHT = 2; -const int SELECT_FULL_HISTORY_TITLE = 5; -const int SELECT_FULL_HISTORY_VISIT_DATE = 6; -const int SELECT_FULL_HISTORY_VISIT_COUNTER = 7; -const int SELECT_FULL_HISTORY_URI_FK = 8; - -const std::string SELECT_HISTORY_BY_URL = - SELECT_FULL_HISTORY_ALL_ROW - + " where " + COL_HISTORY_URL + "=?"; - -} - - -namespace tizen_browser -{ -namespace services -{ - -HistorySQLite::HistorySQLite() - : m_dbHistoryInitialised(false) - , m_histItems() - , m_isInitialized(false) -{ -} - - -HistorySQLite::~HistorySQLite() -{ -} - -void HistorySQLite::init(bool testmode) -{ - if (m_isInitialized) { - return; - } - - config.load("whatever"); - - std::string resourceDbDir; - std::string dbHistory; - - if (!testmode) { - resourceDbDir = boost::any_cast < std::string > (config.get("resourcedb/dir")); - dbHistory = boost::any_cast < std::string > (config.get("DB_HISTORY")); - } else { - resourceDbDir = boost::any_cast < std::string > (config.get("resourcedb/dir")); - dbHistory = "history_test.db"; - } - - DB_HISTORY = resourceDbDir + dbHistory; - - try { - initDatabaseHistory(DB_HISTORY); - m_isInitialized = true; - } catch (storage::StorageExceptionInitialization & e) { - BROWSER_LOGE("Cannot initialize database: %s!", DB_HISTORY.c_str()); - } - -} - -std::string message(const std::string & text, int errcode, const std::string & errMsg) -{ - return text + std::to_string(errcode) + "; " + errMsg; -} - - -//void History::addHistoryItem( -// const std::string & url, -// const std::string & title, -// std::shared_ptr image, -// tizen_browser::tools::BrowserImage::ImageType outputImageType) -//{ -//} - -void HistorySQLite::addHistoryItem(std::shared_ptr hi) -{ - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(DB_HISTORY)); - addHistoryItem(hi, &scope); -} - -/** - * @throws HistoryException on error - */ -void HistorySQLite::addHistoryItem(std::shared_ptr hi, storage::SQLTransactionScope * transactionScope) -{ - BROWSER_LOGI("History::addHistoryItem begin"); - - std::unique_ptr blob; - if (hi->getFavIcon()) { - if (tizen_browser::tools::BrowserImage::ImageTypePNG == hi->getFavIcon()->imageType) { - blob = tizen_browser::tools::EflTools::getBlobPNG(hi->getFavIcon()); - } else { - std::vector < uint8_t > rawImageData = tizen_browser::tools::EflTools::rawEvasImageData(hi->getFavIcon()); - blob = std::unique_ptr(new tizen_browser::tools::Blob(rawImageData.data(), rawImageData.size())); - } - } - std::shared_ptr conIns = transactionScope->database(); - try { - storage::SQLQuery select(conIns->prepare(SELECT_FAVICON_EXISTS)); - select.bindText(1, hi->getUrl()); - select.exec(); - - if (!select.hasNext() && blob) { - BROWSER_LOGI("Favicon URI=%s - not found. Adding to database...", hi->getUriFavicon().c_str()); - storage::SQLQuery insertFavIcon(conIns->prepare(INSERT_TABLE_FAVICON)); - insertFavIcon.bindText(1, hi->getUrl()); - insertFavIcon.bindInt(2, hi->getFavIcon()->width); - insertFavIcon.bindInt(3, hi->getFavIcon()->height); - insertFavIcon.bindInt(4, hi->getFavIcon()->imageType); - insertFavIcon.bindBlob(5, std::move(blob)); - insertFavIcon.exec(); - BROWSER_LOGI("Favicon added"); - BROWSER_LOGI("History item: url: %s", hi->getUriFavicon().c_str()); - } else { - BROWSER_LOGI("Favicon URI=%s was found.", hi->getUriFavicon().c_str()); - } - - BROWSER_LOGI("A new record will be added to a table %s", TABLE_HISTORY.c_str()); - - storage::SQLQuery insertHist(conIns->prepare(INSERT_TABLE_HISTORY_DEFAULT_VALUES)); - insertHist.bindText(1, hi->getUrl()); - insertHist.bindText(2, hi->getTitle()); - insertHist.bindText(3, hi->getUrl()); - insertHist.exec(); - - BROWSER_LOGI("History::addHistoryItem - commited"); - } catch (storage::StorageException & e) { - BROWSER_LOGE("Cannot add a history item (url='%s', title='%s'): %s", - hi->getUrl().c_str(), hi->getTitle().c_str(), e.getMessage()); - - std::string msg = message("SQLite error (code = ", e.getErrorCode(), e.getMessage()); - - throw HistoryException(msg); - } - - BROWSER_LOGI("History::addHistoryItem end"); -} - - -/** - * If hi->getUrl() exists on a table HISTORY update visit_counter and visit_date, unless insert hi to database. - * - * @throws HistoryException on error - */ - -void HistorySQLite::insertOrRefresh(std::shared_ptr hi) -{ - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(DB_HISTORY)); - insertOrRefresh(hi, &scope); -} - -void HistorySQLite::insertOrRefresh(std::shared_ptr hi, storage::SQLTransactionScope * transactionScope) -{ - BROWSER_LOGI("History::insertOrRefresh begin"); - - - M_ASSERT(hi); - - std::shared_ptr con = transactionScope->database(); - - bool isUpdate = false; - - try { - storage::SQLQuery select(con->prepare(SELECT_HISTORY_VISIT_COUNTER)); - select.bindText(1, hi->getUrl()); - select.exec(); - - if (select.hasNext()) { - storage::SQLQuery update(con->prepare(UPDATE_HISTORY_ITEM_COUNTER_DATE)); - update.bindText(1, hi->getUrl()); - update.exec(); - isUpdate = true; - BROWSER_LOGI("visit_counter and visit_date has been updated"); - - } - - BROWSER_LOGI("[%s] - commited", __func__); - } catch (storage::StorageException & e) { - std::string msg = message("SQLite error (code = ", e.getErrorCode(), e.getMessage()); - - BROWSER_LOGE("%s - exception: %s", __PRETTY_FUNCTION__, msg.c_str()); - - throw HistoryException(msg); - } - - if (!isUpdate) { - addHistoryItem(hi, transactionScope); - BROWSER_LOGI("New HistoryItem object has been added."); - - } - - BROWSER_LOGI("History::insertOrRefresh end"); -} - -/** - * ... or just (better) use getHistoryItem method - * @throws HistoryException on error - */ -std::shared_ptr HistorySQLite::getFavicon(const std::string & url) -{ - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(DB_HISTORY)); - return getFavicon(url, &scope); -} - -std::shared_ptr HistorySQLite::getFavicon(const std::string & url, storage::SQLTransactionScope * transactionScope) -{ - BROWSER_LOGI("History::getFavicon begin"); - - std::shared_ptr rsBlob = std::make_shared(); - std::shared_ptr bi - = std::make_shared(); - - auto imageType = tizen_browser::tools::BrowserImage::ImageTypeNoImage; - - auto con = transactionScope->database(); - - try { - storage::SQLQuery select(con->prepare(SELECT_FAVICON)); - select.bindText(1, url); - select.exec(); - - if (select.hasNext()) { - rsBlob = select.getBlob(SELECT_FAVICON_FAVICON); - if (rsBlob.get()) { - bi->width = select.getInt(SELECT_FAVICON_WIDTH); - bi->height = select.getInt(SELECT_FAVICON_HEIGHT); - const auto autoimageType = select.getInt(SELECT_FAVICON_IMAGE_TYPE); - bi->imageType = static_cast(autoimageType); - if(rsBlob->getLength() > 0 ){ - bi->dataSize = rsBlob->transferData(&bi->imageData); - } else { - bi->dataSize = 0; - bi->imageData = 0; - } - BROWSER_LOGI("History::getFavicon - commited"); - } else { - BROWSER_LOGW("History::getFavicon - empty blob"); - } - } else { - BROWSER_LOGW("Can't find a favicon (url=%s)", url.c_str()); - } - - BROWSER_LOGI("History::getFavicon - commited"); - } catch (storage::StorageException & e) { - std::string msg = message("SQLite error (code = ", e.getErrorCode(), e.getMessage()); - - BROWSER_LOGE("%s - exception: %s", __PRETTY_FUNCTION__, msg.c_str()); - - throw HistoryException(msg.c_str()); - } - - BROWSER_LOGI("History::getFavicon end"); - - return bi; -} - -/** - * @throws HistoryException on error - */ -void HistorySQLite::deleteHistory() -{ - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(DB_HISTORY)); - deleteHistory(&scope); -} - -void HistorySQLite::deleteHistory(storage::SQLTransactionScope * transactionScope) -{ - BROWSER_LOGI("History::deleteHistory begin"); - - std::shared_ptr con = transactionScope->database(); - - try { - con->exec(DELETE_ALL_HISTORY); - con->exec(DELETE_ALL_FAVICON); - - BROWSER_LOGI("History::deleteHistory - commited"); - } catch (storage::StorageException & e) { - std::string msg = message("SQLite error (code = ", e.getErrorCode(), e.getMessage()); - - throw HistoryException(msg.c_str()); - } - m_histItems.clear(); - - BROWSER_LOGI("History::deleteHistory end"); -} - -/** - * @throws HistoryException on error - */ -void HistorySQLite::deleteHistory(const std::string & url) -{ - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(DB_HISTORY)); - deleteHistory(url, &scope); -} - -void HistorySQLite::deleteHistory(const std::string & url, storage::SQLTransactionScope * transactionScope) -{ - BROWSER_LOGI("History::deleteHistory (url: %s) - begin", url.c_str()); - - std::shared_ptr con = transactionScope->database(); - - try { - storage::SQLQuery deleteQuery(con->prepare(DELETE_HISTORY_ITEM)); - - deleteQuery.bindText(1, url); - deleteQuery.exec(); - - // consider delete a corresponding record from a table FAVICON if dangling - - BROWSER_LOGI("History::deleteHistory (url: %s) - commited", url.c_str()); - } catch (storage::StorageException & e) { - std::string msg = message("SQLite error (code = ", e.getErrorCode(), e.getMessage()); - - BROWSER_LOGE("%s - exception: %s", __PRETTY_FUNCTION__, msg.c_str()); - - throw HistoryException(msg.c_str()); - } - - for (HistoryItemVector::iterator it(m_histItems.begin()), end(m_histItems.end()); it != end; ++it) { - if ((*it)->getUrl() == url) { - m_histItems.erase(it); - break; - } - } - - BROWSER_LOGI("History::deleteHistory (url: %s) - end", url.c_str()); -} - -/** - * @throws StorageException on error - */ -/*private*/ std::shared_ptr HistorySQLite::createHistoryItem(const storage::SQLQuery & query) -{ - BROWSER_LOGI("History::createHistoryItem begin"); - - std::shared_ptr hi; - - try { - int len = 0; - std::shared_ptr rsBlob = std::make_shared(); - auto imageType = tizen_browser::tools::BrowserImage::ImageTypeNoImage; - - std::shared_ptr bi = std::make_shared(); - - std::string url = query.getString(SELECT_FULL_HISTORY_ALL_ROW_URL); - - hi = std::make_shared(url); - hi->setUrl(url); - hi->setTitle(query.getString(SELECT_FULL_HISTORY_TITLE)); - - std::string strVisitDate = query.getString(SELECT_FULL_HISTORY_VISIT_DATE); - BROWSER_LOGD("[%s:%d] VD!!!! %s", __PRETTY_FUNCTION__, __LINE__, strVisitDate.c_str()); - boost::posix_time::ptime visitDate = boost::posix_time::time_from_string(strVisitDate); - - BROWSER_LOGD("%s:%d\n", __FILE__, __LINE__); - - hi->setLastVisit(visitDate); - hi->setVisitCounter(query.getInt(SELECT_FULL_HISTORY_VISIT_COUNTER)); - hi->setUriFavicon(query.getString(SELECT_FULL_HISTORY_URI_FK)); - - rsBlob = query.getBlob(SELECT_FULL_HISTORY_FAVICON); - if (rsBlob.get()) { - const auto autoimageType = query.getInt(SELECT_FULL_HISTORY_FAVICON_IMAGE_TYPE); - imageType = static_cast(autoimageType); - - bi->imageType = imageType; - bi->width = query.getInt(SELECT_FULL_HISTORY_FAVICON_WIDTH); - bi->height = query.getInt(SELECT_FULL_HISTORY_FAVICON_HEIGHT); - bi->url = url; - - len = rsBlob->getLength(); - BROWSER_LOGI("History::createHistoryItem. I've got an icon. Length = %d, url = %s", len, url.c_str()); - } - - if (len > 0) { - bi->dataSize = rsBlob->transferData(&bi->imageData); - } else { - bi = std::make_shared(); - bi->imageData = NULL; - bi->dataSize = 0; - } - - if (bi.get()) { - hi->setFavIcon(bi); - } - - BROWSER_LOGI("Favicon uri: %s, visit_date: %s, title: %s", hi->getUriFavicon().c_str(), strVisitDate.c_str(), query.getString(SELECT_FULL_HISTORY_TITLE).c_str()); - } catch (storage::StorageException & e) { - std::string msg = message("SQLite error (code = ", e.getErrorCode(), e.getMessage()); - - BROWSER_LOGE("%s - exception: %s", __PRETTY_FUNCTION__, msg.c_str()); - - throw; - } - - BROWSER_LOGI("History::createHistoryItem end"); - - return hi; -} - -/** - * @throws HistoryException on error - */ -std::shared_ptr HistorySQLite::getHistoryItem(const std::string & url) -{ - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(DB_HISTORY)); - return getHistoryItem(url, &scope); -} - -std::shared_ptr HistorySQLite::getHistoryItem(const std::string & url, storage::SQLTransactionScope * transactionScope) -{ - BROWSER_LOGI("History::getHistoryItem begin"); - - std::shared_ptr hi; - - std::shared_ptr con = transactionScope->database(); - - try { - storage::SQLQuery select(con->prepare(SELECT_HISTORY_BY_URL)); - select.bindText(1, url); - select.exec(); - - if (select.hasNext()) { - hi = createHistoryItem(select); - } else { - BROWSER_LOGI("No records found for url %s.\n%s\n", url.c_str(), SELECT_HISTORY_BY_URL.c_str()); - hi = std::shared_ptr(new HistoryItem(url)); - } - - BROWSER_LOGI("History::getHistoryItem - commited"); - } catch (storage::StorageException & e) { - std::string msg = message("SQLite error (code = ", e.getErrorCode(), e.getMessage()); - - BROWSER_LOGE("%s - exception: %s", __PRETTY_FUNCTION__, msg.c_str()); - - throw HistoryException(msg.c_str()); - } - - BROWSER_LOGI("History::getHistoryItem end"); - return hi; -} - -/** - * @throws HistoryException on error - */ -HistoryItemVector & HistorySQLite::getHistoryItems(int historyDepthInDays, int maxItems) -{ - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(DB_HISTORY)); - return getHistoryItems(&scope, historyDepthInDays, maxItems); -} - -HistoryItemVector & HistorySQLite::getHistoryItems(storage::SQLTransactionScope * transactionScope, int historyDepthInDays, int maxItems) -{ - BROWSER_LOGI("History::getHistoryItems begin"); - m_histItems.clear(); - std::shared_ptr con = transactionScope->database(); - - const std::string historyNotOlderThan = COL_HISTORY_VISIT_DATE + ">=date('now','-" + std::to_string(historyDepthInDays) + " day')"; - const std::string historyItemsLimit = std::to_string(maxItems); - - const std::string SQL = SELECT_FULL_HISTORY_ALL_ROW + - " and " + historyNotOlderThan + - " order by " + COL_HISTORY_VISIT_DATE + - " desc limit " + historyItemsLimit; - - try { - storage::SQLQuery select(con->prepare(SQL)); - select.exec(); - - while (select.hasNext()) { - std::shared_ptr hi = createHistoryItem(select); - m_histItems.push_back(hi); - select.next(); - - } - BROWSER_LOGI("History::getHistoryItems - commited"); - } catch (storage::StorageException & e) { - std::string msg = message("SQLite error (code = ", e.getErrorCode(), e.getMessage()); - - BROWSER_LOGE("%s - exception: %s", __PRETTY_FUNCTION__, msg.c_str()); - - throw HistoryException(msg.c_str()); - } - - BROWSER_LOGI("History::getHistoryItems end"); - return m_histItems; -} - -/** - * @throws HistoryException on error - */ -int HistorySQLite::getHistoryItemsCount() -{ - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(DB_HISTORY)); - return getHistoryItemsCount(&scope); -} - -int HistorySQLite::getHistoryItemsCount(storage::SQLTransactionScope * transactionScope) -{ - BROWSER_LOGI("History::getHistoryItemsAmount begin"); - - int res = 0; - - std::shared_ptr con = transactionScope->database(); - - try { - storage::SQLQuery select(con->prepare(SELECT_HISTORY_COUNT_ID)); - select.exec(); - - bool isRecord = select.hasNext(); - - (void)isRecord; - M_ASSERT(isRecord); - - res = select.getInt(0); - - BROWSER_LOGI("History::getHistoryItemsAmount - commited"); - } catch (storage::StorageException & e) { - std::string msg = message("SQLite error (code = ", e.getErrorCode(), e.getMessage()); - - BROWSER_LOGE("%s - exception: %s", __PRETTY_FUNCTION__, msg.c_str()); - - throw HistoryException(msg.c_str()); - } - - BROWSER_LOGI("History::getHistoryItemsAmount end"); - - return res; -} - -/** - * @throws HistoryException on error - */ -int HistorySQLite::getHistoryVisitCounter(const std::string & url) -{ - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(DB_HISTORY)); - return getHistoryVisitCounter(url, &scope); -} - -int HistorySQLite::getHistoryVisitCounter(const std::string & url, storage::SQLTransactionScope * transactionScope) -{ - BROWSER_LOGI("History::getHistoryVisitCounter begin"); - - int res = 0; - - std::shared_ptr con = transactionScope->database(); - - try { - storage::SQLQuery select(con->prepare(SELECT_HISTORY_VISIT_COUNTER)); - select.bindText(1, url); - select.exec(); - - if (select.hasNext()) { - res = select.getInt(0); - } else { - res = -1; // no record was found - } - - BROWSER_LOGI("History::getHistoryVisitCounter - commited"); - } catch (storage::StorageException & e) { - std::string msg = message("SQLite error (code = ", e.getErrorCode(), e.getMessage()); - - BROWSER_LOGE("%s - exception: %s", __PRETTY_FUNCTION__, msg.c_str()); - - throw HistoryException(msg.c_str()); - } - - BROWSER_LOGI("History::getHistoryVisitCounter end"); - - return res; -} - -/** - * @throws StorageExceptionInitialization on error - */ -void HistorySQLite::initDatabaseHistory(const std::string & db_str) -{ - BROWSER_LOGI("History::initDatabaseHistory begin"); - - if (!m_dbHistoryInitialised) { - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(db_str)); - - try { - StorageService::checkAndCreateTable(&scope, TABLE_FAVICON, DDL_CREATE_TABLE_FAVICON); - StorageService::checkAndCreateTable(&scope, TABLE_HISTORY, DDL_CREATE_TABLE_HISTORY); - - BROWSER_LOGI("History::initDatabaseHistory - done"); - } catch (storage::StorageException & e) { - BROWSER_LOGE("[ERROR] History::initDatabaseHistory (error code - %d): %s", e.getErrorCode(), e.getMessage()); - throw storage::StorageExceptionInitialization(e.getMessage(), - e.getErrorCode()); - } - - m_dbHistoryInitialised = true; - } - - M_ASSERT(m_dbHistoryInitialised); - - BROWSER_LOGI("History::initDatabaseHistory end"); -} - -} -} - diff --git a/services/StorageService/src/HistoryStorage.cpp b/services/StorageService/src/HistoryStorage.cpp deleted file mode 100644 index 88983b6..0000000 --- a/services/StorageService/src/HistoryStorage.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "HistoryStorage.h" - -namespace tizen_browser -{ -namespace services -{ - -HistoryStorage::HistoryStorage() -{ -} - - -HistoryStorage::~HistoryStorage() -{ -} - - -} -} diff --git a/services/StorageService/src/StorageService.cpp b/services/StorageService/src/StorageService.cpp index e5ba582..45930d4 100644 --- a/services/StorageService/src/StorageService.cpp +++ b/services/StorageService/src/StorageService.cpp @@ -114,8 +114,6 @@ void StorageService::init(bool testmode) BROWSER_LOGE("Cannot initialize database %s!", DB_SETTINGS.c_str()); } - initHistoryService("SQLITE", testmode); - m_isInitialized = true; } @@ -290,102 +288,5 @@ void StorageService::setSettingsString(const std::string & key, std::string valu setSettingsValue(key, field); } -/** - * @throws HistoryException on error - */ -void StorageService::addHistoryItem(std::shared_ptr hi) -{ - M_ASSERT(m_history); - m_history->addHistoryItem(hi); -} - -/** - * If hi->getUrl() exists on a table HISTORY update visit_counter and visit_date, unless insert hi to database. - * - * @throws HistoryException on error - */ -void StorageService::insertOrRefresh(std::shared_ptr hi) -{ - M_ASSERT(m_history); - m_history->insertOrRefresh(hi); -} - -/** - * @throws HistoryException on error - */ -std::shared_ptr StorageService::getFavicon(const std::string & url) -{ - M_ASSERT(m_history); - return m_history->getFavicon(url); -} - -/** - * @throws HistoryException on error - */ -void StorageService::deleteHistory() -{ - M_ASSERT(m_history); - m_history->deleteHistory(); -} - -/** - * @throws HistoryException on error - */ -void StorageService::deleteHistory(const std::string & url) -{ - M_ASSERT(m_history); - m_history->deleteHistory(url); -} - -/** - * @throws HistoryException on error - */ -std::shared_ptr StorageService::getHistoryItem(const std::string & url) -{ - M_ASSERT(m_history); - return m_history->getHistoryItem(url); -} - -/** - * @throws HistoryException on error - */ -HistoryItemVector & StorageService::getHistoryItems(int historyDepthInDays, int maxItems) -{ - M_ASSERT(m_history); - return m_history->getHistoryItems(historyDepthInDays, maxItems); -} - -/** - * @throws HistoryException on error - */ -int StorageService::getHistoryItemsCount() -{ - M_ASSERT(m_history); - return m_history->getHistoryItemsCount(); -} - -/** - * @throws HistoryException on error - */ -int StorageService::getHistoryVisitCounter(const std::string & url) -{ - M_ASSERT(m_history); - return m_history->getHistoryVisitCounter(url); -} - -void StorageService::initHistoryService(const std::string & storage, bool testmode) -{ - // Depend on "storage" variable use an appropriate class as a storage. By default it's a HistorySQLite class. - if (m_history.get() == NULL) { - if (storage.compare("SQLITE") == 0) { - m_history = std::make_shared(); - m_history->init(testmode); - } - } -} - - - - } } -- 2.7.4 From a86c19d6af72a1abdb05a2ca61e19e18a485d1d2 Mon Sep 17 00:00:00 2001 From: Maciej Skrzypkowski Date: Tue, 8 Sep 2015 10:27:34 +0200 Subject: [PATCH 14/16] Switching between mobile/desktop mode per tab. [Issue#] https://bugs.tizen.org/jira/browse/TT-132 [Problem] View mode was set as global flag. [Cause] N/A [Solution] Added flag for each tab to remeber current mode. [Verify] Open new tab (google.com), open settings, switch to mobile mode, page should reload in mobile view. Change-Id: I19a6f1965938930b45f46b076ce030f2fe9c10ed Signed-off-by: Maciej Skrzypkowski --- core/AbstractWebEngine/AbstractWebEngine.h | 18 ++++++--- services/MainUI/DetailPopup.cpp | 7 +++- services/MainUI/DetailPopup.h | 2 +- services/MainUI/MainUI.cpp | 26 ++++++++----- services/MainUI/MainUI.h | 11 ++++-- services/MoreMenuUI/MoreMenuUI.cpp | 30 +++++++-------- services/MoreMenuUI/MoreMenuUI.h | 10 ++--- services/SimpleUI/SimpleUI.cpp | 44 ++++++++++++++-------- services/SimpleUI/SimpleUI.h | 8 ++-- .../WebKitEngineService/WebKitEngineService.cpp | 29 +++++++------- services/WebKitEngineService/WebKitEngineService.h | 9 ++--- services/WebKitEngineService/WebView.cpp | 21 +++++++---- services/WebKitEngineService/WebView.h | 17 ++++++--- 13 files changed, 137 insertions(+), 95 deletions(-) diff --git a/core/AbstractWebEngine/AbstractWebEngine.h b/core/AbstractWebEngine/AbstractWebEngine.h index 8416229..ea0e663 100644 --- a/core/AbstractWebEngine/AbstractWebEngine.h +++ b/core/AbstractWebEngine/AbstractWebEngine.h @@ -132,9 +132,10 @@ public: /** * Adds new tab * @param uri if not empty opens specified uri + * @param desktopMode true if desktop mode, false if mobile mode * @return TabId of created tab */ - virtual TabId addTab(const std::string & uri = std::string(), const TabId * openerId = NULL) = 0; + virtual TabId addTab(const std::string & uri = std::string(), const TabId * openerId = NULL, bool desktopMode = true) = 0; /** * @param tab id @@ -257,14 +258,21 @@ public: virtual void backButtonClicked() const = 0; /** - * @brief Switch view to mobile + * @brief Switch current view to mobile mode */ - virtual void switchToMobileView() = 0; + virtual void switchToMobileMode() = 0; /** - * @brief Switch view to desktop + * @brief Switch current view to desktop mode */ - virtual void switchToDesktopView() = 0; + virtual void switchToDesktopMode() = 0; + + /** + * @brief Check if desktop mode is enabled for current view + * + * @return true if desktop mode is enabled + */ + virtual bool isDesktopMode() const = 0; /** * FavIcon of current page changed diff --git a/services/MainUI/DetailPopup.cpp b/services/MainUI/DetailPopup.cpp index f3d2ced..4aa5604 100644 --- a/services/MainUI/DetailPopup.cpp +++ b/services/MainUI/DetailPopup.cpp @@ -75,7 +75,6 @@ void DetailPopup::createLayout(Evas_Object *parent) evas_object_show(m_layout); } - void DetailPopup::show(Evas_Object *parent, std::shared_ptr currItem, std::shared_ptr prevItems) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -86,6 +85,10 @@ void DetailPopup::show(Evas_Object *parent, std::shared_ptr(data); dp->hide(); - dp->m_mainUI->openURLInNewTab(dp->m_item); + dp->openURLInNewTab(dp->m_item, dp->m_mainUI->isDesktopMode()); } char* DetailPopup::_get_history_link_text(void* data, Evas_Object* obj, const char* part) diff --git a/services/MainUI/DetailPopup.h b/services/MainUI/DetailPopup.h index 8d24a51..1ad8a02 100644 --- a/services/MainUI/DetailPopup.h +++ b/services/MainUI/DetailPopup.h @@ -38,7 +38,7 @@ namespace base_ui{ */ void show(Evas_Object *parent, std::shared_ptr currItem, std::shared_ptr prevItems); - boost::signals2::signal)> openURLInNewTab; + boost::signals2::signal, bool)> openURLInNewTab; static const int HISTORY_ITEMS_NO; private: diff --git a/services/MainUI/MainUI.cpp b/services/MainUI/MainUI.cpp index 74a2c52..6dbdbbc 100644 --- a/services/MainUI/MainUI.cpp +++ b/services/MainUI/MainUI.cpp @@ -130,6 +130,7 @@ void MainUI::show(Evas_Object* parent) Evas_Object* MainUI::createQuickAccessLayout(Evas_Object* parent) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + m_desktopMode = true; Evas_Object* layout = elm_layout_add(parent); evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); @@ -429,16 +430,6 @@ Evas_Object * MainUI::_grid_bookmark_content_get(void *data, Evas_Object *obj, c return nullptr; } - -void MainUI::_itemSelected(void * data, Evas_Object * /* obj */, void * event_info) -{ - Elm_Object_Item * selected = reinterpret_cast(event_info); - HistoryItemData * itemData = reinterpret_cast(elm_object_item_data_get(selected)); - MainUI * self = reinterpret_cast(data); - - self->openURLInNewTab(itemData->item); -} - void MainUI::_thumbSelected(void * data, Evas_Object * /* obj */, void * /* event_info */) { HistoryItemData * itemData = reinterpret_cast(data); @@ -544,5 +535,20 @@ void MainUI::setEmptyView(bool empty) } } +bool MainUI::isDesktopMode() const +{ + return m_desktopMode; +} + +void MainUI::setDesktopMode(bool mode) +{ + m_desktopMode = mode; +} + +DetailPopup& MainUI::getDetailPopup() +{ + return m_detailPopup; +} + } } diff --git a/services/MainUI/MainUI.h b/services/MainUI/MainUI.h index 352051d..667a844 100644 --- a/services/MainUI/MainUI.h +++ b/services/MainUI/MainUI.h @@ -49,13 +49,15 @@ public: void showBookmarks(); void clearItems(); void openDetailPopup(std::shared_ptr currItem, std::shared_ptr prevItems); + bool isDesktopMode() const; + void setDesktopMode(bool mode); + DetailPopup & getDetailPopup(); void addHistoryItem(std::shared_ptr); void addHistoryItems(std::shared_ptr); void addBookmarkItem(std::shared_ptr); void addBookmarkItems(std::vector >); - boost::signals2::signal)> openURLInNewTab; boost::signals2::signal, int)> mostVisitedTileClicked; boost::signals2::signal mostVisitedClicked; boost::signals2::signal bookmarkClicked; @@ -63,8 +65,8 @@ public: static const int MAX_TILE_WIDTH; static const int MAX_TILE_HEIGHT; -private: +private: void createItemClasses(); Evas_Object* createQuickAccessLayout(Evas_Object *parent); @@ -82,11 +84,12 @@ private: static void _thumbSelected(void * data, Evas_Object * obj, void * event_info); static void _deleteBookmark(void *data, Evas_Object *obj, void *event_info); void setEmptyView(bool empty); + void showNoHistoryLabel(); static void _mostVisited_clicked(void * data, Evas_Object * obj, void * event_info); static void _bookmark_clicked(void * data, Evas_Object * obj, void * event_info); static void _bookmark_manager_clicked(void * data, Evas_Object * obj, void * event_info); -private: + Evas_Object *m_parent; Evas_Object *m_layout; Evas_Object *m_bookmarksView; @@ -107,7 +110,7 @@ private: std::map m_map_bookmark_views; bool m_gengridSetup; std::string edjFilePath; - void showNoHistoryLabel(); + bool m_desktopMode; }; } diff --git a/services/MoreMenuUI/MoreMenuUI.cpp b/services/MoreMenuUI/MoreMenuUI.cpp index 8279289..088ae44 100644 --- a/services/MoreMenuUI/MoreMenuUI.cpp +++ b/services/MoreMenuUI/MoreMenuUI.cpp @@ -48,7 +48,7 @@ MoreMenuUI::MoreMenuUI() : m_gengrid(NULL) , m_parent(NULL) , m_item_class(NULL) - , m_desktopView(true) + , m_desktopMode(true) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); m_edjFilePath = EDJE_DIR; @@ -59,10 +59,11 @@ MoreMenuUI::~MoreMenuUI() { } -void MoreMenuUI::show(Evas_Object* parent) +void MoreMenuUI::show(Evas_Object* parent, bool desktopMode) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); m_parent = parent; + m_desktopMode = desktopMode; elm_theme_extension_add(NULL, m_edjFilePath.c_str()); m_mm_layout = elm_layout_add(parent); elm_layout_file_set(m_mm_layout, m_edjFilePath.c_str(), "moremenu-layout"); @@ -234,9 +235,9 @@ void MoreMenuUI::addItems() for (int i = 0; i <= EXIT_BROWSER; i++) { ItemType type = static_cast(i); // take proper image for desktop/mobile view - if (type == ItemType::VIEW_DESKTOP_WEB && m_desktopView) + if (type == ItemType::VIEW_DESKTOP_WEB && m_desktopMode) continue; - if (type == ItemType::VIEW_MOBILE_WEB && !m_desktopView) + if (type == ItemType::VIEW_MOBILE_WEB && !m_desktopMode) continue; MoreMenuItemData *itemData = new MoreMenuItemData(); @@ -441,14 +442,16 @@ void MoreMenuUI::_thumbSelected(void* data, Evas_Object*, void*) case FOCUS_MODE: break; case VIEW_MOBILE_WEB: - itemData->moreMenuUI->switchToMobileView(); - itemData->moreMenuUI->m_desktopView = false; - itemData->moreMenuUI->refreshGengrid(); + itemData->moreMenuUI->switchToMobileMode(); + itemData->moreMenuUI->m_desktopMode = false; + itemData->moreMenuUI->closeMoreMenuClicked(std::string()); + itemData->moreMenuUI->clearItems(); break; case VIEW_DESKTOP_WEB: - itemData->moreMenuUI->switchToDesktopView(); - itemData->moreMenuUI->m_desktopView = true; - itemData->moreMenuUI->refreshGengrid(); + itemData->moreMenuUI->switchToDesktopMode(); + itemData->moreMenuUI->m_desktopMode = true; + itemData->moreMenuUI->closeMoreMenuClicked(std::string()); + itemData->moreMenuUI->clearItems(); break; case SHARE: break; @@ -477,13 +480,6 @@ void MoreMenuUI::clearItems() elm_cache_all_flush(); } -void MoreMenuUI::refreshGengrid() -{ - elm_gengrid_clear(m_gengrid); - m_map_menu_views.clear(); - addItems(); -} - void MoreMenuUI::_exitClicked() { BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); diff --git a/services/MoreMenuUI/MoreMenuUI.h b/services/MoreMenuUI/MoreMenuUI.h index a6df318..4bbf489 100644 --- a/services/MoreMenuUI/MoreMenuUI.h +++ b/services/MoreMenuUI/MoreMenuUI.h @@ -61,7 +61,7 @@ class BROWSER_EXPORT MoreMenuUI public: MoreMenuUI(); ~MoreMenuUI(); - void show(Evas_Object *main_layout); + void show(Evas_Object *main_layout, bool desktopMode); void showCurrentTab(); virtual std::string getName(); void addItems(); @@ -80,8 +80,8 @@ public: boost::signals2::signal historyUIClicked; boost::signals2::signal settingsClicked; boost::signals2::signal closeMoreMenuClicked; - boost::signals2::signal switchToMobileView; - boost::signals2::signal switchToDesktopView; + boost::signals2::signal switchToMobileMode; + boost::signals2::signal switchToDesktopMode; private: static char* _grid_text_get(void *data, Evas_Object *obj, const char *part); static Evas_Object * _grid_content_get(void *data, Evas_Object *obj, const char *part); @@ -95,8 +95,6 @@ private: void AddBookmarkPopupCalled(); void addToBookmarks(int folder_id); - void refreshGengrid(); - static void _star_clicked(void *data, Evas_Object *obj, void *event_info); static void _close_clicked(void *data, Evas_Object *obj, void *event_info); @@ -117,7 +115,7 @@ private: std::string m_folderName; bool m_gengridSetup; Evas_Object *m_icon; - bool m_desktopView; + bool m_desktopMode; }; } diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 1b0e8d5..d2f532e 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -48,6 +48,7 @@ #include "boost/date_time/posix_time/posix_time.hpp" #include "NetworkErrorHandler.h" #include "SqlStorage.h" +#include "DetailPopup.h" namespace tizen_browser{ @@ -308,7 +309,7 @@ int SimpleUI::exec(const std::string& _url) M_ASSERT(m_mainUI.get()); m_historyService->historyAllDeleted.connect(boost::bind(&tizen_browser::base_ui::MainUI::clearHistoryGenlist, m_mainUI.get())); - m_mainUI->openURLInNewTab.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this,_1)); + m_mainUI->getDetailPopup().openURLInNewTab.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1, _2)); m_mainUI->mostVisitedTileClicked.connect(boost::bind(&SimpleUI::onMostVisitedTileClicked, this, _1, _2)); m_mainUI->mostVisitedClicked.connect(boost::bind(&SimpleUI::onMostVisitedClicked, this,_1)); m_mainUI->bookmarkClicked.connect(boost::bind(&SimpleUI::onBookmarkButtonClicked, this,_1)); @@ -486,7 +487,6 @@ void SimpleUI::switchToTab(const tizen_browser::basic_webengine::TabId& tabId) bool SimpleUI::isHomePageActive() { - BROWSER_LOGD("[%s:%d] isHomePageActive : %d", __PRETTY_FUNCTION__, __LINE__, m_isHomePageActive); return m_isHomePageActive; } @@ -540,9 +540,9 @@ void SimpleUI::checkTabId(const tizen_browser::basic_webengine::TabId& id){ } } -void SimpleUI::openNewTab(const std::string &uri) +void SimpleUI::openNewTab(const std::string &uri, bool desktopMode) { - switchToTab(m_webEngine->addTab(uri)); + switchToTab(m_webEngine->addTab(uri, nullptr, desktopMode)); } void SimpleUI::closeTab(){ @@ -595,8 +595,9 @@ void SimpleUI::onHistoryAdded(std::shared_ptr historyItem) +void SimpleUI::onOpenURLInNewTab(std::shared_ptr historyItem, bool desktopMode) { + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); std::string historyAddress = historyItem->getUrl(); if(m_historyUI) { // TODO: remove this section when naviframes will be available m_historyUI->clearItems(); @@ -607,7 +608,7 @@ void SimpleUI::onOpenURLInNewTab(std::shared_ptrclearItems(); m_moreMenuUI = nullptr; } - openNewTab(historyAddress); + openNewTab(historyAddress, desktopMode); } void SimpleUI::onMostVisitedTileClicked(std::shared_ptr< services::HistoryItem > historyItem, int itemsNumber) @@ -1123,7 +1124,7 @@ void SimpleUI::showHistoryUI(const std::string& str) M_ASSERT(m_historyUI); m_historyUI->clearHistoryClicked.connect(boost::bind(&SimpleUI::onClearHistoryClicked, this,_1)); m_historyUI->closeHistoryUIClicked.connect(boost::bind(&SimpleUI::closeHistoryUI, this,_1)); - m_historyUI->historyItemClicked.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this,_1)); + m_historyUI->historyItemClicked.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1, true)); // desktop mode as default m_historyUI->addHistoryItems(getHistory()); m_historyUI->show(m_window.get()); } @@ -1166,7 +1167,7 @@ void SimpleUI::closeSettingsUI(const std::string& str) void SimpleUI::showMoreMenu() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - bool current_tab_as_new_tab = isHomePageActive() || (m_historyService->getHistoryItemsCount() == 0); + bool desktopMode = isHomePageActive() ? m_mainUI->isDesktopMode() : m_webEngine->isDesktopMode(); if(!m_moreMenuUI){ m_moreMenuUI = std::dynamic_pointer_cast @@ -1183,13 +1184,13 @@ void SimpleUI::showMoreMenu() m_moreMenuUI->historyUIClicked.connect(boost::bind(&SimpleUI::showHistoryUI, this,_1)); m_moreMenuUI->settingsClicked.connect(boost::bind(&SimpleUI::showSettingsUI, this,_1)); m_moreMenuUI->closeMoreMenuClicked.connect(boost::bind(&SimpleUI::closeMoreMenu, this,_1)); - m_moreMenuUI->switchToMobileView.connect(boost::bind(&SimpleUI::switchToMobileView, this)); - m_moreMenuUI->switchToDesktopView.connect(boost::bind(&SimpleUI::switchToDesktopView, this)); + m_moreMenuUI->switchToMobileMode.connect(boost::bind(&SimpleUI::switchToMobileMode, this)); + m_moreMenuUI->switchToDesktopMode.connect(boost::bind(&SimpleUI::switchToDesktopMode, this)); m_moreMenuUI->addToBookmarkClicked.connect(boost::bind(&SimpleUI::addBookmarkFolders, this)); m_moreMenuUI->AddBookmarkInput.connect(boost::bind(&SimpleUI::addToBookmarks, this,_1)); m_moreMenuUI->BookmarkFolderCreated.connect(boost::bind(&SimpleUI::newFolderMoreMenu, this,_1,_2)); - m_moreMenuUI->show(m_window.get()); + m_moreMenuUI->show(m_window.get(), desktopMode); m_moreMenuUI->showCurrentTab(); m_moreMenuUI->setFavIcon(m_webEngine->getFavicon()); m_moreMenuUI->setWebTitle(m_webEngine->getTitle()); @@ -1204,13 +1205,26 @@ void SimpleUI::closeMoreMenu(const std::string& str) m_moreMenuUI.reset(); } -void SimpleUI::switchToMobileView() +void SimpleUI::switchToMobileMode() { - m_webEngine->switchToMobileView(); + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (!isHomePageActive()) { + m_webEngine->switchToMobileMode(); + m_webEngine->reload(); + } else { + m_mainUI->setDesktopMode(false); + } } -void SimpleUI::switchToDesktopView() { - m_webEngine->switchToDesktopView(); +void SimpleUI::switchToDesktopMode() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (!isHomePageActive()) { + m_webEngine->switchToDesktopMode(); + m_webEngine->reload(); + } else { + m_mainUI->setDesktopMode(true); + } } void SimpleUI::showBookmarkManagerMenu() diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index f8faab1..8c13280 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -112,7 +112,7 @@ private: void updateURIBarView(); void updateView(); - void openNewTab(const std::string &uri); + void openNewTab(const std::string &uri, bool desktopMode = true); void switchToTab(const tizen_browser::basic_webengine::TabId& tabId); void newTabClicked(const std::string &); void tabClicked(const tizen_browser::basic_webengine::TabId& tabId); @@ -133,7 +133,7 @@ private: void onHistoryAdded(std::shared_ptr historyItem); void onHistoryRemoved(const std::string& uri); - void onOpenURLInNewTab(std::shared_ptr historyItem); + void onOpenURLInNewTab(std::shared_ptr historyItem, bool desktopMode); void onMostVisitedTileClicked(std::shared_ptr historyItem, int itemsNumber); void onClearHistoryClicked(const std::string&); @@ -230,8 +230,8 @@ private: void closeTabUI(const std::string& str); void showMoreMenu(); void closeMoreMenu(const std::string& str); - void switchToMobileView(); - void switchToDesktopView(); + void switchToMobileMode(); + void switchToDesktopMode(); void showHistoryUI(const std::string& str); void closeHistoryUI(const std::string&); void showMainUI(); diff --git a/services/WebKitEngineService/WebKitEngineService.cpp b/services/WebKitEngineService/WebKitEngineService.cpp index 2506a63..f88b5da 100644 --- a/services/WebKitEngineService/WebKitEngineService.cpp +++ b/services/WebKitEngineService/WebKitEngineService.cpp @@ -45,7 +45,6 @@ WebKitEngineService::WebKitEngineService() , m_privateMode(false) , m_guiParent(nullptr) , m_currentTabId(TabId::NONE) - , m_desktopView(true) { m_mostRecentTab.clear(); m_tabs.clear(); @@ -279,7 +278,7 @@ std::vector > WebKitEngineService::getTabContents() return result; } -TabId WebKitEngineService::addTab(const std::string & uri, const TabId * openerId) +TabId WebKitEngineService::addTab(const std::string & uri, const TabId * openerId, bool desktopMode) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -287,9 +286,9 @@ TabId WebKitEngineService::addTab(const std::string & uri, const TabId * openerI TabId newTabId; WebViewPtr p = std::make_shared(reinterpret_cast(m_guiParent), newTabId); if (openerId) - p->init(m_desktopView, getTabView(*openerId)); + p->init(desktopMode, getTabView(*openerId)); else - p->init(m_desktopView); + p->init(desktopMode); m_tabs[newTabId] = p; @@ -508,20 +507,22 @@ void WebKitEngineService::backButtonClicked() const } } -void WebKitEngineService::switchToDesktopView() +void WebKitEngineService::switchToDesktopMode() { - m_desktopView = true; - for (auto it = m_tabs.begin(); it != m_tabs.end(); ++it) { - it->second->switchToDesktopView(); - } + M_ASSERT(m_currentWebView); + m_currentWebView->switchToDesktopMode(); } -void WebKitEngineService::switchToMobileView() +void WebKitEngineService::switchToMobileMode() { - m_desktopView = false; - for (auto it = m_tabs.begin(); it != m_tabs.end(); ++it) { - it->second->switchToMobileView(); - } + M_ASSERT(m_currentWebView); + m_currentWebView->switchToMobileMode(); +} + +bool WebKitEngineService::isDesktopMode() const +{ + M_ASSERT(m_currentWebView); + return m_currentWebView->isDesktopMode(); } } /* end of webkitengine_service */ diff --git a/services/WebKitEngineService/WebKitEngineService.h b/services/WebKitEngineService/WebKitEngineService.h index 5c0f47d..4f586cb 100644 --- a/services/WebKitEngineService/WebKitEngineService.h +++ b/services/WebKitEngineService/WebKitEngineService.h @@ -77,7 +77,7 @@ public: * @param uri * @return TabId of created tab */ - TabId addTab(const std::string & uri = std::string(), const TabId * openerId = NULL); + TabId addTab(const std::string & uri = std::string(), const TabId * openerId = NULL, bool desktopMode = true); Evas_Object* getTabView(TabId id); bool switchToTab(TabId); bool closeTab(); @@ -159,8 +159,9 @@ public: */ void backButtonClicked() const; - void switchToMobileView(); - void switchToDesktopView(); + void switchToMobileMode(); + void switchToDesktopMode(); + bool isDesktopMode() const; private: // callbacks from WebView @@ -209,8 +210,6 @@ private: std::list m_mostRecentTab; // recently added tabs first std::list m_chronoTabs; - // true if desktop view is enabled, false if mobile - bool m_desktopView; }; } /* end of webkitengine_service */ diff --git a/services/WebKitEngineService/WebView.cpp b/services/WebKitEngineService/WebView.cpp index 603543c..3c5c5d4 100644 --- a/services/WebKitEngineService/WebView.cpp +++ b/services/WebKitEngineService/WebView.cpp @@ -83,7 +83,7 @@ WebView::~WebView() ewk_context_delete(m_ewkContext); } -void WebView::init(bool desktopView, Evas_Object * opener) +void WebView::init(bool desktopMode, Evas_Object * opener) { #if defined(USE_EWEBKIT) m_ewkView = ewk_view_add_with_context(evas_object_evas_get(m_parent), m_ewkContext); @@ -94,10 +94,11 @@ void WebView::init(bool desktopView, Evas_Object * opener) evas_object_color_set(m_ewkView, 255, 255, 255, 255); evas_object_size_hint_weight_set(m_ewkView, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(m_ewkView, EVAS_HINT_FILL, EVAS_HINT_FILL); - if (desktopView) - switchToDesktopView(); - else - switchToMobileView(); + if (desktopMode) { + switchToDesktopMode(); + } else { + switchToMobileMode(); + } //\todo: when value is other than 1.0, scroller is located improperly // ewk_view_device_pixel_ratio_set(m_ewkView, 1.0f); @@ -877,14 +878,20 @@ void WebView::searchOnWebsite(const std::string & searchString, int flags) BROWSER_LOGD("Ewk search; word: %s, result: %d", searchString.c_str(), result); } -void WebView::switchToDesktopView() { +void WebView::switchToDesktopMode() { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); int res = ewk_view_user_agent_set(m_ewkView, APPLICATION_NAME_FOR_USER_AGENT); + m_desktopMode = true; } -void WebView::switchToMobileView() { +void WebView::switchToMobileMode() { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); int res = ewk_view_user_agent_set(m_ewkView, APPLICATION_NAME_FOR_USER_AGENT_MOBILE); + m_desktopMode = false; +} + +bool WebView::isDesktopMode() const { + return m_desktopMode; } } /* namespace webkitengine_service */ diff --git a/services/WebKitEngineService/WebView.h b/services/WebKitEngineService/WebView.h index 846af9c..98b3e65 100644 --- a/services/WebKitEngineService/WebView.h +++ b/services/WebKitEngineService/WebView.h @@ -41,7 +41,7 @@ class WebView public: WebView(Evas_Object *, TabId); virtual ~WebView(); - void init(bool desktopView = true, Evas_Object * opener = NULL); + void init(bool desktopMode, Evas_Object * opener = NULL); void setURI(const std::string &); @@ -112,12 +112,19 @@ public: /** * @brief Change user agent to desktop type */ - void switchToDesktopView(); + void switchToDesktopMode(); /** * @brief Change user agent to mobile type */ - void switchToMobileView(); + void switchToMobileMode(); + + /** + * @brief Check if desktop mode is enabled + * + * @return true if desktop mode is enabled + */ + bool isDesktopMode() const; /** * @brief Get favicon of URL @@ -194,8 +201,8 @@ private: bool m_isLoading; double m_loadProgress; bool m_loadError; - - + // true if desktop view is enabled, false if mobile + bool m_desktopMode; config::DefaultConfig config; -- 2.7.4 From 24206804e050da8f6e007a7a84ec48bea1f70492 Mon Sep 17 00:00:00 2001 From: Albert Malewski Date: Tue, 8 Sep 2015 09:44:29 +0200 Subject: [PATCH 15/16] Fixed radio selection in settings [Issue] https://bugs.tizen.org/jira/browse/TT-154 [Problem] Cannot select any item in radio list at Web contents Sharing section. [Cause] Every radio was set to one group. Missing state valuesof radios. [Solution] Added enums with state values and separate radio buttons within 3 lists. [Verify] Launch browser > More Menu > Settings > Obs You should be able to select any radio in settings. Change-Id: I894d6527770c51066be60372cc3e69646c21ff82 --- services/SettingsUI/SettingsUI.cpp | 16 ++++++++++++++-- services/SettingsUI/SettingsUI.h | 15 +++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/services/SettingsUI/SettingsUI.cpp b/services/SettingsUI/SettingsUI.cpp index 2b68784..0799958 100644 --- a/services/SettingsUI/SettingsUI.cpp +++ b/services/SettingsUI/SettingsUI.cpp @@ -156,35 +156,47 @@ void SettingsUI::showSettingsPage() elm_check_state_set(history_checkbox, EINA_TRUE); edje_object_signal_callback_add(elm_layout_edje_get(m_items_layout), "mouse,clicked,1", "history_cb_text", __checkbox_label_click_cb, (void*)id); - Evas_Object *accept_all_rb = elm_radio_add(m_items_layout); elm_object_style_set(accept_all_rb, "settings_radio"); elm_layout_content_set(m_items_layout, "accept_all_rb", accept_all_rb); + Evas_Object *sharingRequestGroup = accept_all_rb; + elm_radio_state_value_set(accept_all_rb, SR_ACCEPT_ALL); Evas_Object *ask_rb = elm_radio_add(m_items_layout); elm_object_style_set(ask_rb, "settings_radio"); elm_layout_content_set(m_items_layout, "ask_rb", ask_rb); + elm_radio_group_add(ask_rb, sharingRequestGroup); + elm_radio_state_value_set(ask_rb, SR_ASK); Evas_Object *sr_disable_rb = elm_radio_add(m_items_layout); elm_object_style_set(sr_disable_rb, "settings_radio"); elm_layout_content_set(m_items_layout, "sr_disable_rb", sr_disable_rb); + elm_radio_group_add(sr_disable_rb, sharingRequestGroup); + elm_radio_state_value_set(sr_disable_rb, SR_DISABLE); Evas_Object *bs_enable_rb = elm_radio_add(m_items_layout); elm_object_style_set(bs_enable_rb, "settings_radio"); elm_layout_content_set(m_items_layout, "bs_enable_rb", bs_enable_rb); + Evas_Object *bookmarkSyncGroup = bs_enable_rb; + elm_radio_state_value_set(bs_enable_rb, BS_ENABLE); Evas_Object *bs_disable_rb = elm_radio_add(m_items_layout); elm_object_style_set(bs_disable_rb, "settings_radio"); elm_layout_content_set(m_items_layout, "bs_disable_rb", bs_disable_rb); + elm_radio_group_add(bs_disable_rb, bookmarkSyncGroup); + elm_radio_state_value_set(bs_disable_rb, BS_DISABLE); Evas_Object *ts_enable_rb = elm_radio_add(m_items_layout); elm_object_style_set(ts_enable_rb, "settings_radio"); elm_layout_content_set(m_items_layout, "ts_enable_rb", ts_enable_rb); + Evas_Object *tabSyncGroup = ts_enable_rb; + elm_radio_state_value_set(ts_enable_rb, TS_ENABLE); Evas_Object *ts_disable_rb = elm_radio_add(m_items_layout); elm_object_style_set(ts_disable_rb, "settings_radio"); elm_layout_content_set(m_items_layout, "ts_disable_rb", ts_disable_rb); - + elm_radio_group_add(ts_disable_rb, tabSyncGroup); + elm_radio_state_value_set(ts_disable_rb, TS_DISABLE); } Evas_Object* SettingsUI::listActionBarContentGet(void* data, Evas_Object* obj , const char* part) diff --git a/services/SettingsUI/SettingsUI.h b/services/SettingsUI/SettingsUI.h index 8adbf4d..70ffab2 100644 --- a/services/SettingsUI/SettingsUI.h +++ b/services/SettingsUI/SettingsUI.h @@ -63,7 +63,6 @@ private: static void _closetabs_clicked(void * data, Evas_Object * obj, void * event_info); static void _onotherdevices_clicked(void * data, Evas_Object * obj, void * event_info); -private: Evas_Object *m_settings_layout; Evas_Object *m_genListActionBar; Evas_Object *m_scroller; @@ -73,7 +72,19 @@ private: Elm_Gengrid_Item_Class * m_item_class; std::string m_edjFilePath; - + enum SharingRequest { + SR_DISABLE = 0, + SR_ASK, + SR_ACCEPT_ALL, + }; + enum BookmarkSync { + BS_DISABLE = 0, + BS_ENABLE + }; + enum TabSync { + TS_DISABLE = 0, + TS_ENABLE + }; }; } -- 2.7.4 From 7d65e7f2db89b41bec2a6d89283921bf3515a95e Mon Sep 17 00:00:00 2001 From: Maciej Skrzypkowski Date: Tue, 8 Sep 2015 16:04:20 +0200 Subject: [PATCH 16/16] Fixed crash while loading page without title. [Issue] https://bugs.tizen.org/jira/browse/TT-162 [Problem] Browser crashed while loading page. [Cause] There was no check if page title is empty while comparing. [Solution] Changed compering to URL, added check if it's empty. [Verify] Launch browser > go to: http://jmajnert.github.io/tests/localStorage_test/localStoragePersistance.html refresh page > close browser > open again > go to previous site. Browser shouldn't crash. Change-Id: Icc19ad7a327d97fe6ff79777b0fc819189cf660a Signed-off-by: Maciej Skrzypkowski --- services/HistoryService/HistoryService.cpp | 64 ++++++++---------------------- services/HistoryService/HistoryService.h | 4 +- 2 files changed, 18 insertions(+), 50 deletions(-) diff --git a/services/HistoryService/HistoryService.cpp b/services/HistoryService/HistoryService.cpp index b5826ef..1d93507 100644 --- a/services/HistoryService/HistoryService.cpp +++ b/services/HistoryService/HistoryService.cpp @@ -88,24 +88,9 @@ int HistoryService::getHistoryItemsCount(){ return count; } -static int __get_duplicated_ids_p(int **ids, int *count, const int limit, const int offset, - const bp_history_offset order_column_offset, const int ordering, - const bp_history_offset check_column_offset, - const char *keyword, const int is_like) -{ - bp_history_rows_cond_fmt conds; - conds.limit = limit; - conds.offset = offset; - conds.ordering = ordering; - conds.order_offset = order_column_offset; - conds.period_offset = BP_HISTORY_O_DATE_CREATED; - conds.period_type = BP_HISTORY_DATE_ALL; - - return bp_history_adaptor_get_cond_ids_p(ids, count, &conds, check_column_offset, keyword, is_like); -} - -bool isDuplicate(const char* title) +bool HistoryService::isDuplicate(const char* url) const { + M_ASSERT(url); int *ids=nullptr; int count=0; bp_history_rows_cond_fmt conds; @@ -120,21 +105,22 @@ bool isDuplicate(const char* title) BROWSER_LOGD("Error! Could not get ids!"); } - bp_history_offset offset = (BP_HISTORY_O_URL | BP_HISTORY_O_TITLE | BP_HISTORY_O_FAVICON | BP_HISTORY_O_DATE_CREATED); + bp_history_offset offset = (BP_HISTORY_O_URL | BP_HISTORY_O_DATE_CREATED); - for(int i = 0; i< count; i++){ + for (int i = 0; i < count; i++) { bp_history_info_fmt history_info; - bp_history_adaptor_get_info(ids[i],offset,&history_info); - if(!strcmp(history_info.title, title)) { - int freq; - bp_history_adaptor_get_frequency(ids[i], &freq); - bp_history_adaptor_set_frequency(ids[i], freq + 1); - bp_history_adaptor_set_date_visited(ids[i],-1); - return true; + bp_history_adaptor_get_info(ids[i], offset, &history_info); + if (!history_info.url) { + BROWSER_LOGD("Warning: history entry without url!"); + } else if (!strcmp(history_info.url, url)) { + int freq; + bp_history_adaptor_get_frequency(ids[i], &freq); + bp_history_adaptor_set_frequency(ids[i], freq + 1); + bp_history_adaptor_set_date_visited(ids[i],-1); + return true; } } return false; - } std::shared_ptr HistoryService::getHistoryAll() @@ -284,7 +270,7 @@ void HistoryService::addHistoryItem(std::shared_ptr his,std::shared his->setFavIcon(his->getFavIcon()); his->setThumbnail(thumbnail); - if(isDuplicate(his->getTitle().c_str())) + if (isDuplicate(his->getUrl().c_str())) return; int id = -1; @@ -330,14 +316,6 @@ void HistoryService::addHistoryItem(std::shared_ptr his,std::shared historyAdded(his); } - -void HistoryService::insertOrRefresh(std::shared_ptr hi) { - /** - * No browser- provider implementation till now. Needs to be done - */ - //getStorageManager()->insertOrRefresh(hi); -} - void HistoryService::clearAllHistory() { bp_history_adaptor_reset(); @@ -357,7 +335,9 @@ int HistoryService::getHistoryId(const std::string & url) int *ids = nullptr; int ids_count = 0; int ret = bp_history_adaptor_get_cond_ids_p(&ids ,&ids_count, &conds, BP_HISTORY_O_URL, url.c_str(), 0); - if (ids_count!=0){ + if (ret < 0) { + BROWSER_LOGD("Error! Could not get ids!"); + } else if (ids_count != 0) { int i = *ids; free(ids); return i; @@ -390,9 +370,7 @@ std::shared_ptr HistoryService::getHistoryItem(int * ids, int idNum int m_year = item_time_info->tm_year; int m_month = item_time_info->tm_mon + 1; - int m_day = item_time_info->tm_yday; int m_month_day = item_time_info->tm_mday; - int m_date = date; int min = item_time_info->tm_min; int hour = item_time_info->tm_hour; int sec = item_time_info->tm_sec; @@ -465,13 +443,5 @@ std::shared_ptr HistoryService::getHistoryItems(bp_history_da return ret_history_list; } -int HistoryService::getHistoryVisitCounter(const std::string & url) -{ /** - * No browser- provider implementation till now. Needs to be done - */ -// return getStorageManager()->getHistoryVisitCounter(url); - -} - } } diff --git a/services/HistoryService/HistoryService.h b/services/HistoryService/HistoryService.h index f8e10e1..7764bd3 100644 --- a/services/HistoryService/HistoryService.h +++ b/services/HistoryService/HistoryService.h @@ -44,7 +44,6 @@ public: int getHistoryId(const std::string & url); void addHistoryItem(std::shared_ptr hi, std::shared_ptr thumbnail=std::shared_ptr()); - void insertOrRefresh(std::shared_ptr hi); void clearAllHistory(); void clearURLHistory(const std::string & url); std::shared_ptr getHistoryItem(const std::string & url); @@ -58,7 +57,6 @@ public: std::shared_ptr getMostVisitedHistoryItems(); std::shared_ptr getHistoryItemsByURL(const std::string & url, int maxItems); int getHistoryItemsCount(); - int getHistoryVisitCounter(const std::string & url); void setStorageServiceTestMode(bool testmode = true); boost::signals2::signalhistoryEmpty; @@ -79,7 +77,7 @@ private: std::shared_ptr getHistoryItem(int* ids, int idNumber = 0); std::shared_ptr getHistoryItems(bp_history_date_defs period = BP_HISTORY_DATE_TODAY); std::shared_ptr getStorageManager(); - + bool isDuplicate(const char* url) const; }; } -- 2.7.4