From 8085f7314fdc6f07f5f756db980a0f950c514998 Mon Sep 17 00:00:00 2001 From: "m.kawonczyk" Date: Mon, 12 Oct 2015 15:11:53 +0200 Subject: [PATCH 01/16] Limit number of opened tabs in brower [Issue] https://bugs.tizen.org/jira/browse/TT-174 [Problem] When more than 30 tabs are opened the browser crashes. [Solution] Limit the number of simultaneously opened tabs to 10. If user wants to add another tab, popup is shown. WebCore Part must check, if sending out=NULL in __newWindowRequest doesn't create another bug. [Verification] Please open 10 tabs and try to add another one, with either + in tab manager or "Open link in new tab" in popup. Change-Id: I342fe4dda10e6ae11e2199893ce3a8412c01227e --- core/AbstractWebEngine/AbstractWebEngine.h | 7 +++++- core/Config/Config.cpp | 2 +- services/SimpleUI/SimpleUI.cpp | 25 ++++++++++++++++------ services/SimpleUI/SimpleUI.h | 1 + .../WebKitEngineService/WebKitEngineService.cpp | 8 +++++++ services/WebKitEngineService/WebView.cpp | 20 ++++++++--------- 6 files changed, 44 insertions(+), 19 deletions(-) diff --git a/core/AbstractWebEngine/AbstractWebEngine.h b/core/AbstractWebEngine/AbstractWebEngine.h index 99f19c9..22e9c55 100644 --- a/core/AbstractWebEngine/AbstractWebEngine.h +++ b/core/AbstractWebEngine/AbstractWebEngine.h @@ -352,11 +352,16 @@ public: boost::signals2::signal currentTabChanged; /** - * New tab was creted. It could be explicit call (by user) or tab could be opened from JavaScript. + * New tab was created. It could be explicit call (by user) or tab could be opened from JavaScript. */ boost::signals2::signal tabCreated; /** + * Checks if tab can be created. + */ + boost::signals2::signal checkIfCreate; + + /** * Tab closed * \param TabId of closed tab */ diff --git a/core/Config/Config.cpp b/core/Config/Config.cpp index dae7cd3..73e387e 100644 --- a/core/Config/Config.cpp +++ b/core/Config/Config.cpp @@ -38,7 +38,7 @@ void DefaultConfig::load(const std::string &) m_data["TOOLTIP_DELAY"] = 0.05; // time from mouse in to tooltip show m_data["TOOLTIP_HIDE_TIMEOUT"] = 2.0; // time from tooltip show to tooltip hide - m_data["TAB_LIMIT"] = 20; // max number of open tabs + m_data["TAB_LIMIT"] = 10; // max number of open tabs m_data["FAVORITES_LIMIT"] = 40; // max number of added favorites # include "ConfigValues.h" diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index a0d577a..bf02679 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -391,6 +391,7 @@ void SimpleUI::connectModelSignals() m_webEngine->loadError.connect(boost::bind(&SimpleUI::loadError, this)); m_webEngine->confirmationRequest.connect(boost::bind(&SimpleUI::handleConfirmationRequest, this, _1)); m_webEngine->tabCreated.connect(boost::bind(&SimpleUI::tabCreated, this)); + m_webEngine->checkIfCreate.connect(boost::bind(&SimpleUI::checkIfCreate, this)); m_webEngine->tabClosed.connect(boost::bind(&SimpleUI::tabClosed,this,_1)); m_webEngine->IMEStateChanged.connect(boost::bind(&SimpleUI::setwvIMEStatus, this, _1)); m_webEngine->favIconChanged.connect(boost::bind(&MoreMenuUI::setFavIcon, m_moreMenuUI.get(), _1)); @@ -662,6 +663,7 @@ void SimpleUI::filterURL(const std::string& url) //check if url is in blocked //no filtering + if (m_webPageUI->isHomePageActive()) openNewTab(url); else @@ -725,6 +727,9 @@ void SimpleUI::closeTabUI() void SimpleUI::newTabClicked() { + if (!checkIfCreate()) + return; + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); switchViewToQuickAccess(); } @@ -1026,18 +1031,24 @@ void SimpleUI::tabLimitPopupButtonClicked(PopupButtons button, std::shared_ptr< void SimpleUI::tabCreated() { int tabs = m_webEngine->tabsCount(); + m_webPageUI->setTabsNumber(tabs); +} - if (tabs > m_tabLimit) - { +bool SimpleUI::checkIfCreate() +{ + int tabs = m_webEngine->tabsCount(); + + if (tabs >= m_tabLimit) { SimplePopup *popup = SimplePopup::createPopup(); - popup->setTitle("Too many tabs open"); - popup->addButton(CONTINUE); - popup->addButton(CLOSE_TAB); - popup->setMessage("Browser might slow down. Are you sure you want to continue?"); + popup->setTitle("Maximum tab count reached."); + popup->addButton(OK); + popup->setMessage("Close other tabs to open another new tab"); popup->buttonClicked.connect(boost::bind(&SimpleUI::tabLimitPopupButtonClicked, this, _1, _2)); popup->show(); + return false; } - m_webPageUI->setTabsNumber(tabs); + else + return true; } void SimpleUI::updateView() { diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index 443eff9..74c425a 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -113,6 +113,7 @@ private: void tabClicked(const tizen_browser::basic_webengine::TabId& tabId); void closeTabsClicked(const tizen_browser::basic_webengine::TabId& tabId); void tabCreated(); + bool checkIfCreate(); void tabClosed(const tizen_browser::basic_webengine::TabId& id); std::vector > getBookmarks(int folder_id = -1); diff --git a/services/WebKitEngineService/WebKitEngineService.cpp b/services/WebKitEngineService/WebKitEngineService.cpp index 59a01e7..923ddf3 100644 --- a/services/WebKitEngineService/WebKitEngineService.cpp +++ b/services/WebKitEngineService/WebKitEngineService.cpp @@ -280,6 +280,14 @@ std::vector > WebKitEngineService::getTabContents() TabId WebKitEngineService::addTab(const std::string & uri, const TabId * openerId, bool desktopMode) { + AbstractWebEngine::checkIfCreate(); + + config::DefaultConfig config; + config.load(""); + + if (tabsCount() >= boost::any_cast(config.get("TAB_LIMIT"))) + return currentTabId(); + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); // searching for next available tabId diff --git a/services/WebKitEngineService/WebView.cpp b/services/WebKitEngineService/WebView.cpp index 1d03786..33170c5 100644 --- a/services/WebKitEngineService/WebView.cpp +++ b/services/WebKitEngineService/WebView.cpp @@ -501,11 +501,12 @@ void WebView::__newWindowRequest(void *data, Evas_Object *, void *out) M_ASSERT(m_webEngine); /// \todo: Choose newly created tab. - TabId id = m_webEngine->addTab(std::string(), &self->getTabId()); - BROWSER_LOGD("Created tab: %s", id.toString().c_str()); - - Evas_Object* tab_ewk_view = m_webEngine->getTabView(id); - *static_cast(out) = tab_ewk_view; + TabId id; + if (m_webEngine->currentTabId() != (id = m_webEngine->addTab(std::string(), &self->getTabId()))) { + BROWSER_LOGD("Created tab: %s", id.toString().c_str()); + Evas_Object* tab_ewk_view = m_webEngine->getTabView(id); + *static_cast(out) = tab_ewk_view; + } } void WebView::__closeWindowRequest(void *data, Evas_Object *, void *) @@ -546,6 +547,7 @@ void WebView::__loadFinished(void * data, Evas_Object * /* obj */, void * /* eve BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); WebView * self = reinterpret_cast(data); + self->m_isLoading = false; self->m_loadProgress = 1; @@ -561,7 +563,6 @@ void WebView::__loadProgress(void * data, Evas_Object * /* obj */, void * event_ WebView * self = reinterpret_cast(data); self->m_loadProgress = *(double *)event_info; - self->loadProgress(self->m_loadProgress); } @@ -597,7 +598,6 @@ void WebView::__titleChanged(void * data, Evas_Object * obj, void * /* event_inf WebView * self = reinterpret_cast(data); self->m_title = fromChar(ewk_view_title_get(obj)); - self->titleChanged(self->m_title); } @@ -801,7 +801,7 @@ bool WebView::hasFocus() const double WebView::getZoomFactor() const { - if(EINA_UNLIKELY(m_ewkView == nullptr)){ + if(EINA_UNLIKELY(m_ewkView == nullptr)) { return 1.0; } @@ -815,7 +815,7 @@ double WebView::getZoomFactor() const void WebView::setZoomFactor(double zoomFactor) { #if defined(USE_EWEBKIT) - if(m_ewkView){ + if(m_ewkView) { //using zoomFactor = 0 sets zoom "fit to screen" if(zoomFactor != getZoomFactor()) @@ -829,7 +829,7 @@ void WebView::scrollView(const int& dx, const int& dy) ewk_view_scroll_by(m_ewkView, dx, dy); } -const TabId& WebView::getTabId(){ +const TabId& WebView::getTabId() { return m_tabId; } -- 2.7.4 From 1d91ae2e88875534a821d4c773a078f36b68f0ca Mon Sep 17 00:00:00 2001 From: sungwon2han Date: Tue, 20 Oct 2015 15:01:09 +0900 Subject: [PATCH 02/16] Add "XF86Back" key name to process back key event from remote controller. Change-Id: I65ffa278a3a903ca42e192f3a99c7a5ae0842fe2 Signed-off-by: sungwon2han --- services/PlatformInputManager/PlatformInputManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/PlatformInputManager/PlatformInputManager.cpp b/services/PlatformInputManager/PlatformInputManager.cpp index c163b32..fddb242 100644 --- a/services/PlatformInputManager/PlatformInputManager.cpp +++ b/services/PlatformInputManager/PlatformInputManager.cpp @@ -81,7 +81,7 @@ Eina_Bool PlatformInputManager::__filter(void *data, void */*loop_data*/, int ty else if(!keyName.compare("KEY_ENTER")) self->enterPressed(); // MERGE_ME dont know if should be commented out - else if(!keyName.compare("BackSpace")) + else if(!keyName.compare("BackSpace") || !keyName.compare("XF86Back")) self->backPressed(); } else if(type == ECORE_EVENT_KEY_UP) { M_ASSERT(event); -- 2.7.4 From 0faeda4443c973339e07e41bafbb61ce32bb48e2 Mon Sep 17 00:00:00 2001 From: Kamil Nowac Date: Thu, 15 Oct 2015 13:03:20 +0200 Subject: [PATCH 03/16] Add incognito screen and icon to the url bar [Issue] https://bugs.tizen.org/jira/browse/TT-185 [Problem] Incognito screen and icons are not implemented [Solution] Added screen and icons [Verification] 1. Open incognito tab Incognito start screen and incognito icon should be visible in the url bar Change-Id: I18cf592433ebedd5e6a85b1b5d7809f1e4802562 --- core/AbstractWebEngine/AbstractWebEngine.h | 22 ++ services/SimpleUI/SimpleUI.cpp | 35 +- services/SimpleUI/SimpleUI.h | 3 + .../WebKitEngineService/WebKitEngineService.cpp | 12 + services/WebKitEngineService/WebKitEngineService.h | 12 + services/WebKitEngineService/WebView.cpp | 33 +- services/WebKitEngineService/WebView.h | 11 + services/WebPageUI/CMakeLists.txt | 1 + services/WebPageUI/WebPageUI.cpp | 50 +++ services/WebPageUI/WebPageUI.h | 9 + services/WebPageUI/edc/PrivateMode.edc | 374 +++++++++++++++++++++ services/WebPageUI/edc/URIEntry.edc | 1 + services/WebPageUI/edc/WebPageUI.edc | 42 +++ services/WebPageUI/images/btn_bar_incognito.png | Bin 0 -> 1305 bytes services/WebPageUI/images/ic_text_form.png | Bin 0 -> 1092 bytes 15 files changed, 586 insertions(+), 19 deletions(-) create mode 100644 services/WebPageUI/edc/PrivateMode.edc create mode 100644 services/WebPageUI/images/btn_bar_incognito.png create mode 100644 services/WebPageUI/images/ic_text_form.png diff --git a/core/AbstractWebEngine/AbstractWebEngine.h b/core/AbstractWebEngine/AbstractWebEngine.h index 22e9c55..554c115 100644 --- a/core/AbstractWebEngine/AbstractWebEngine.h +++ b/core/AbstractWebEngine/AbstractWebEngine.h @@ -198,8 +198,30 @@ public: */ virtual void setPrivateMode(bool) = 0; + /** + * Set the state of private mode for a specific tab + * + * \param id of snapshot + * \param state to set + */ + virtual void setPrivateMode(const TabId&, bool) = 0; + + /** + * Get the state of private mode + */ virtual bool isPrivateMode() const = 0; + /** + * Get the state of private mode for a specific tab + * + * /param id of snapshot + * /return state of private mode where: + * -1 is "Not set" + * 0 is "False" + * 1 is "True" + */ + virtual int isPrivateMode(const TabId&) = 0; + virtual bool isLoadError() const = 0; /** diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index bf02679..084de51 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -71,6 +71,7 @@ SimpleUI::SimpleUI() , m_initialised(false) , m_wvIMEStatus(false) , m_ewkContext(ewk_context_new()) + , m_incognito(false) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); elm_init(0, nullptr); @@ -245,6 +246,7 @@ void SimpleUI::connectUISignals() m_webPageUI->reloadPage.connect(boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine::reload, m_webEngine.get())); m_webPageUI->showQuickAccess.connect(boost::bind(&SimpleUI::showQuickAccess, this)); m_webPageUI->hideQuickAccess.connect(boost::bind(&QuickAccess::hideUI, m_quickAccess)); + m_webPageUI->bookmarkManagerClicked.connect(boost::bind(&SimpleUI::showBookmarkManagerUI, this)); M_ASSERT(m_quickAccess.get()); @@ -258,9 +260,11 @@ void SimpleUI::connectUISignals() M_ASSERT(m_tabUI.get()); m_tabUI->closeTabUIClicked.connect(boost::bind(&SimpleUI::closeTabUI, this)); m_tabUI->newTabClicked.connect(boost::bind(&SimpleUI::newTabClicked, this)); + m_tabUI->newTabClicked.connect(boost::bind(&SimpleUI::settingsPrivateModeSwitch, this, false)); 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)); + m_tabUI->newIncognitoTabClicked.connect(boost::bind(&SimpleUI::settingsPrivateModeSwitch, this, true)); + m_tabUI->newIncognitoTabClicked.connect(boost::bind(&SimpleUI::switchViewToIncognitoPage, this)); m_tabUI->tabsCount.connect(boost::bind(&SimpleUI::tabsCount, this)); M_ASSERT(m_historyUI.get()); @@ -471,6 +475,16 @@ void SimpleUI::switchViewToQuickAccess() m_viewManager->popStackTo(m_webPageUI.get()); } +void SimpleUI::switchViewToIncognitoPage() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_viewManager); + m_webPageUI->toIncognito(m_incognito); + m_webPageUI->switchViewToIncognitoPage(); + m_webEngine->disconnectCurrentWebViewSignals(); + m_viewManager->popStackTo(m_webPageUI.get()); +} + void SimpleUI::checkTabId(const tizen_browser::basic_webengine::TabId& id){ BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); if(m_webEngine->currentTabId() != id || isErrorPageActive()){ @@ -482,7 +496,9 @@ void SimpleUI::checkTabId(const tizen_browser::basic_webengine::TabId& id){ void SimpleUI::openNewTab(const std::string &uri, bool desktopMode) { BROWSER_LOGD("[%s:%d] uri =%s", __PRETTY_FUNCTION__, __LINE__, uri.c_str()); - switchToTab(m_webEngine->addTab(uri, nullptr, desktopMode)); + tizen_browser::basic_webengine::TabId tab = m_webEngine->addTab(uri, nullptr, desktopMode); + applyPrivateModeToTab(tab); + switchToTab(tab); } void SimpleUI::closeTab() @@ -738,6 +754,7 @@ void SimpleUI::tabClicked(const tizen_browser::basic_webengine::TabId& tabId) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); m_viewManager->popStackTo(m_webPageUI.get()); + applyPrivateModeToTab(tabId); switchToTab(tabId); } @@ -940,8 +957,18 @@ void SimpleUI::closeBookmarkManagerUI() void SimpleUI::settingsPrivateModeSwitch(bool newState) { BROWSER_LOGD("%s: Setting Private mode to: %s", __func__, (newState ? "true" : "false")); - m_webEngine->setPrivateMode(newState); - BROWSER_LOGD("[%s:%d] webEngine private mode: %s", __PRETTY_FUNCTION__, __LINE__, (m_webEngine->isPrivateMode() ? "true" : "false")); + m_incognito = newState; +} + +void SimpleUI::applyPrivateModeToTab(const tizen_browser::basic_webengine::TabId& tabId) +{ + if (m_webEngine->isPrivateMode(tabId) < 0) { + m_webEngine->setPrivateMode(tabId, m_incognito); + m_webPageUI->toIncognito(m_incognito); + } else { + m_webEngine->setPrivateMode(tabId, m_webEngine->isPrivateMode(tabId)); + m_webPageUI->toIncognito(m_webEngine->isPrivateMode(tabId)); + } } void SimpleUI::settingsDeleteSelectedData(const std::string& str) diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index 74c425a..5e4ecd4 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -104,6 +104,7 @@ private: void showQuickAccess(); void switchViewToQuickAccess(); + void switchViewToIncognitoPage(); void switchViewToWebPage(); void updateView(); @@ -211,6 +212,7 @@ private: void closeTab(const tizen_browser::basic_webengine::TabId& id); void settingsPrivateModeSwitch(bool newState); + void applyPrivateModeToTab(const tizen_browser::basic_webengine::TabId& id); void settingsDeleteSelectedData(const std::string& str); void settingsResetMostVisited(); void settingsResetBrowser(); @@ -248,6 +250,7 @@ private: int m_tabLimit; int m_favoritesLimit; bool m_wvIMEStatus; + bool m_incognito; //helper object used to view management ViewManager* m_viewManager; diff --git a/services/WebKitEngineService/WebKitEngineService.cpp b/services/WebKitEngineService/WebKitEngineService.cpp index 923ddf3..11cd07a 100644 --- a/services/WebKitEngineService/WebKitEngineService.cpp +++ b/services/WebKitEngineService/WebKitEngineService.cpp @@ -414,6 +414,18 @@ void WebKitEngineService::setPrivateMode(bool state) it->second->setPrivateMode(state); } +void WebKitEngineService::setPrivateMode(const TabId& id, bool state) +{ + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + m_tabs[id]->setPrivateMode(state); +} + +int WebKitEngineService::isPrivateMode(const TabId& id) +{ + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + return m_tabs[id]->isPrivateMode(); +} + bool WebKitEngineService::isPrivateMode() const { return m_privateMode; diff --git a/services/WebKitEngineService/WebKitEngineService.h b/services/WebKitEngineService/WebKitEngineService.h index ed1fc6d..00ec6c7 100644 --- a/services/WebKitEngineService/WebKitEngineService.h +++ b/services/WebKitEngineService/WebKitEngineService.h @@ -108,8 +108,20 @@ public: std::shared_ptr getSnapshotData(TabId id, int width, int height); void setPrivateMode(bool); + void setPrivateMode(const TabId& id, bool state); bool isPrivateMode() const; + /** + * @brief Get the state of private mode for a specific tab + * + * @param id of snapshot + * @return state of private mode where: + * -1 is "Not set" + * 0 is "False" + * 1 is "True" + */ + int isPrivateMode(const TabId& id); + /** * @brief Check if current tab has load error. diff --git a/services/WebKitEngineService/WebView.cpp b/services/WebKitEngineService/WebView.cpp index 33170c5..bb42ec7 100644 --- a/services/WebKitEngineService/WebView.cpp +++ b/services/WebKitEngineService/WebView.cpp @@ -71,6 +71,7 @@ WebView::WebView(Evas_Object * obj, TabId tabId) , m_ewkView(nullptr) , m_isLoading(false) , m_loadError(false) + , m_private(-1) { config.load("whatever"); } @@ -292,30 +293,32 @@ void WebView::setPrivateMode(bool state) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); M_ASSERT(m_ewkView); - + if(m_private < 0){ #if defined(USE_EWEBKIT) #if PLATFORM(TIZEN) - Ewk_Settings * settings = ewk_view_settings_get(m_ewkView); + Ewk_Settings * settings = ewk_view_settings_get(m_ewkView); #else - Ewk_Settings * settings = ewk_page_group_settings_get(ewk_view_page_group_get(m_ewkView)); + Ewk_Settings * settings = ewk_page_group_settings_get(ewk_view_page_group_get(m_ewkView)); #endif - ewk_settings_private_browsing_enabled_set(settings, state); - if (m_ewkView) - { - Ewk_Context *context = ewk_view_context_get(m_ewkView); - if (context) + ewk_settings_private_browsing_enabled_set(settings, state); + if (m_ewkView) { - if(state) - { - ewk_cookie_manager_accept_policy_set(ewk_context_cookie_manager_get(context), EWK_COOKIE_ACCEPT_POLICY_NEVER); - } - else + Ewk_Context *context = ewk_view_context_get(m_ewkView); + if (context) { - ewk_cookie_manager_accept_policy_set(ewk_context_cookie_manager_get(context), EWK_COOKIE_ACCEPT_POLICY_ALWAYS); + if(state) + { + ewk_cookie_manager_accept_policy_set(ewk_context_cookie_manager_get(context), EWK_COOKIE_ACCEPT_POLICY_NEVER); + } + else + { + ewk_cookie_manager_accept_policy_set(ewk_context_cookie_manager_get(context), EWK_COOKIE_ACCEPT_POLICY_ALWAYS); + } } } - } #endif + m_private = static_cast(state); + } } void WebView::confirmationResult(WebConfirmationPtr confirmation) diff --git a/services/WebKitEngineService/WebView.h b/services/WebKitEngineService/WebView.h index 07fdcdc..61f6c68 100644 --- a/services/WebKitEngineService/WebView.h +++ b/services/WebKitEngineService/WebView.h @@ -66,6 +66,16 @@ public: void setPrivateMode(bool); + /** + * @brief Get the state of private mode + * + * @return state of private mode where: + * -1 is "Not set" + * 0 is "False" + * 1 is "True" + */ + int isPrivateMode() {return m_private;} + std::shared_ptr captureSnapshot(int width, int height); /** * \brief Sets Focus to URI entry. @@ -213,6 +223,7 @@ private: bool m_loadError; // true if desktop view is enabled, false if mobile bool m_desktopMode; + int m_private; config::DefaultConfig config; diff --git a/services/WebPageUI/CMakeLists.txt b/services/WebPageUI/CMakeLists.txt index e410517..ddcb2e9 100644 --- a/services/WebPageUI/CMakeLists.txt +++ b/services/WebPageUI/CMakeLists.txt @@ -58,6 +58,7 @@ set(edcFiles LeftButtonBar.edc RightButtonBar.edc URIEntry.edc + PrivateMode.edc ) foreach(edec ${edcFiles}) diff --git a/services/WebPageUI/WebPageUI.cpp b/services/WebPageUI/WebPageUI.cpp index a1456d2..43649b3 100644 --- a/services/WebPageUI/WebPageUI.cpp +++ b/services/WebPageUI/WebPageUI.cpp @@ -31,9 +31,11 @@ WebPageUI::WebPageUI() : m_parent(nullptr) , m_mainLayout(nullptr) , m_errorLayout(nullptr) + , m_privateLayout(nullptr) , m_progressBar(nullptr) , m_URIEntry(new URIEntry()) , m_homePageActive(false) + , m_bookmarkManagerButton(nullptr) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); } @@ -131,6 +133,20 @@ void WebPageUI::setPageTitle(const std::string& title) m_URIEntry->setPageTitle(title); } +bool WebPageUI::isIncognitoPageActive() +{ + return elm_object_part_content_get(m_mainLayout, "web_view") == m_privateLayout; +} + +void WebPageUI::toIncognito(bool incognito) +{ + BROWSER_LOGD("[%s:%d,%d] ", __PRETTY_FUNCTION__, __LINE__, incognito); + if(incognito) + elm_object_signal_emit(m_mainLayout, "incognito,true", "ui"); + else + elm_object_signal_emit(m_mainLayout, "incognito,false", "ui"); +} + void WebPageUI::setMainContent(Evas_Object* content) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -150,6 +166,15 @@ void WebPageUI::switchViewToErrorPage() refreshFocusChain(); } +void WebPageUI::switchViewToIncognitoPage() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_homePageActive = false; + setMainContent(m_privateLayout); + evas_object_show(m_leftButtonBar->getContent()); + refreshFocusChain(); +} + void WebPageUI::switchViewToWebPage(Evas_Object* content, const std::string uri, const std::string title) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -212,6 +237,7 @@ void WebPageUI::createLayout() elm_layout_file_set(m_mainLayout, edjePath("WebPageUI/WebPageUI.edj").c_str(), "main_layout"); createErrorLayout(); + createPrivateLayout(); createActions(); // left buttons @@ -252,6 +278,29 @@ void WebPageUI::createErrorLayout() elm_layout_file_set(m_errorLayout, edjePath("WebPageUI/ErrorMessage.edj").c_str(), "error_message"); } +void WebPageUI::createPrivateLayout() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_privateLayout = elm_layout_add(m_mainLayout); + evas_object_size_hint_weight_set(m_privateLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_privateLayout, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_layout_file_set(m_privateLayout, edjePath("WebPageUI/PrivateMode.edj").c_str(), "inco_message"); + + m_bookmarkManagerButton = elm_button_add(m_privateLayout); + elm_object_style_set(m_bookmarkManagerButton, "invisible_button"); + evas_object_smart_callback_add(m_bookmarkManagerButton, "clicked", _bookmark_manager_clicked, this); + evas_object_show(m_bookmarkManagerButton); + + elm_object_part_content_set(m_privateLayout, "bookmarkmanager_click", m_bookmarkManagerButton); +} + +void WebPageUI::_bookmark_manager_clicked(void * data, Evas_Object *, void *) +{ + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + WebPageUI* webpageUI = static_cast(data); + webpageUI->bookmarkManagerClicked(); +} + void WebPageUI::createActions() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -362,6 +411,7 @@ void WebPageUI::refreshFocusChain() elm_object_focus_custom_chain_append(m_mainLayout, m_rightButtonBar->getContent(), NULL); if (!m_homePageActive) { elm_object_focus_custom_chain_append(m_mainLayout, m_leftButtonBar->getContent(), NULL); + elm_object_focus_custom_chain_append(m_mainLayout, m_bookmarkManagerButton, NULL); } else { m_reload->setEnabled(false); } diff --git a/services/WebPageUI/WebPageUI.h b/services/WebPageUI/WebPageUI.h index de0612f..07a3672 100644 --- a/services/WebPageUI/WebPageUI.h +++ b/services/WebPageUI/WebPageUI.h @@ -42,9 +42,12 @@ public: void progressChanged(double progress); void loadFinished(); bool isErrorPageActive(); + bool isIncognitoPageActive(); bool isHomePageActive() { return m_homePageActive; } + void toIncognito(bool); void switchViewToErrorPage(); void switchViewToWebPage(Evas_Object* content, const std::string uri, const std::string title); + void switchViewToIncognitoPage(); void switchViewToQuickAccess(Evas_Object* content); URIEntry& getURIEntry() const { return *m_URIEntry.get(); } void setPageTitle(const std::string& title); @@ -63,12 +66,14 @@ public: boost::signals2::signal showMoreMenu; boost::signals2::signal hideQuickAccess; boost::signals2::signal showQuickAccess; + boost::signals2::signal bookmarkManagerClicked; static void faviconClicked(void* data, Evas_Object* obj, const char* emission, const char* source); private: void createLayout(); void createErrorLayout(); + void createPrivateLayout(); void createActions(); void connectActions(); void showProgressBar(); @@ -80,6 +85,8 @@ private: std::string edjePath(const std::string& file); void refreshFocusChain(); + static void _bookmark_manager_clicked(void * data, Evas_Object *, void *); + // wrappers to call singal as a reaction to other signal void backPageConnect() { backPage(); } void forwardPageConnect() { forwardPage(); } @@ -91,7 +98,9 @@ private: Evas_Object* m_parent; Evas_Object* m_mainLayout; Evas_Object* m_errorLayout; + Evas_Object* m_privateLayout; Evas_Object* m_progressBar; + Evas_Object* m_bookmarkManagerButton; std::unique_ptr m_leftButtonBar; std::unique_ptr m_rightButtonBar; std::unique_ptr m_URIEntry; diff --git a/services/WebPageUI/edc/PrivateMode.edc b/services/WebPageUI/edc/PrivateMode.edc new file mode 100644 index 0000000..d00fb30 --- /dev/null +++ b/services/WebPageUI/edc/PrivateMode.edc @@ -0,0 +1,374 @@ + +collections { + styles { + style { + name: "message_style"; + base: "font=Sans font_size=36 color=#676767 wrap=word align=0.5"; + } + style { + name: "message_hint_style"; + base: "font=Sans font_size=28 color=#676767 wrap=word align=0.0"; + } + } + group { + name: "inco_message"; + parts { + part { + name: "message_background"; + type: RECT; + mouse_events: 1; + description{ + state: "default" 0.0; + visible: 1; + rel1.relative: 0 0; + rel2.relative: 1 1; + } + } + part { + name: "inco_message_background"; + type:RECT; + description{ + state: "default" 0.0; + visible: 1; + min: 920 356; + max: 920 356; + fixed: 1 1; + align: 0.5 0.5; + } + } + part { + name: "inco_dot"; + images { + image: "ic_text_form.png" COMP; + } + type: "IMAGE"; + description { + state: "default" 0.0; + visible: 1; + min: 20 28; + max: 20 28; + align: 0 0; + image.normal: "ic_text_form.png"; + rel1 { + offset: 0 100; + relative: 0 0; + to: "inco_message_background"; + } + rel2 { + relative: 1 1; + to: "inco_message_background"; + } + } + } + part { + name: "inco_dot2"; + images { + image: "ic_text_form.png" COMP; + } + type: "IMAGE"; + description { + state: "default" 0.0; + visible: 1; + min: 20 28; + max: 20 28; + align: 0 0; + image.normal: "ic_text_form.png"; + rel1 { + offset: 0 216; + relative: 0 0; + to: "inco_message_background"; + } + rel2 { + relative: 1 1; + to: "inco_message_background"; + } + } + } + part { + name: "inco_dot3"; + images { + image: "ic_text_form.png" COMP; + } + type: "IMAGE"; + description { + state: "default" 0.0; + visible: 1; + min: 20 28; + max: 20 28; + align: 0 0; + image.normal: "ic_text_form.png"; + rel1 { + offset: 0 298; + relative: 0 0; + to: "inco_message_background"; + } + rel2 { + relative: 1 1; + to: "inco_message_background"; + } + } + } + part { + name: "inco_text"; + type: TEXTBLOCK; + description { + state: "default" 0.0; + visible: 1; + fixed: 1 1; + min: 864 36; + max: 864 36; + align: 0.5 0; + color: 103 103 103 255; + rel1 { + relative: 0 0; + to: "inco_message_background"; + } + rel2 { + relative: 1 1; + to: "inco_message_background"; + } + text { + min: 0 1; + max: 0 1; + style: "message_style"; + text: "Start Incognito Browsing"; + } + } + } + part { + name: "inco_hint"; + type: TEXTBLOCK; + description { + state: "default" 0.0; + visible: 1; + fixed: 0 1; + min: 864 68; + max: 864 68; + color: 103 103 103 179; + align: 0 0; + rel1 { + relative: 0 0; + offset: 28 90; + to_y: "inco_message_background"; + to_x: "inco_dot"; + } + rel2 { + relative: 1 1; + to_y: "inco_message_background"; + } + text { + min: 0 1; + max: 0 1; + style: "message_hint_style"; + text: "You can browse internet in incognito tabs without any traces including browsing history, cookie or search history."; + } + } + } + part { + name: "inco_hint2"; + type: TEXTBLOCK; + description { + state: "default" 0.0; + visible: 1; + fixed: 1 1; + min: 864 28; + max: 864 28; + color: 103 103 103 179; + align: 0.0 0; + rel1 { + relative: 0 0; + offset: 28 206; + to_y: "inco_message_background"; + to_x: "inco_dot2"; + } + rel2 { + relative: 1 1; + to_y: "inco_message_background"; + } + text { + min: 0 1; + max: 0 1; + style: "message_hint_style"; + text: "Bookmarks or downloaded files will not be removed."; + } + } + } + part { + name: "inco_hint3"; + type: TEXTBLOCK; + description { + state: "default" 0.0; + visible: 1; + fixed: 1 1; + min: 864 68; + max: 864 68; + color: 103 103 103 179; + align: 0.0 0; + rel1 { + relative: 0 0; + offset: 28 288; + to_y: "inco_message_background"; + to_x: "inco_dot3"; + } + rel2 { + relative: 1 1; + to_y: "inco_message_background"; + } + text { + min: 0 1; + max: 0 1; + style: "message_hint_style"; + text: "You can not remove traces from your employer, internet service provider or websites you visit even you go incognito."; + } + } + } + part { + name: "bookmarkmanager_button"; + scale:1; + mouse_events: 1; + type: RECT; + description { + state: "default" 0.0; + visible: 1; + fixed: 1 1; + align: 0.5 1.0; + min: 348 65; + max: 348 65; + color: 192 192 192 255; + rel1 { relative: 0.0 0.0; to: "message_background";} + rel2 { relative: 1.0 1.0; to: "message_background"; offset: 0 -60;} + } + description { + state: "highlight" 0.0; + inherit: "default" 0.0; + color_class: focusBgColor; + visible: 1; + } + description { + state: "focus" 0.0; + inherit: "default" 0.0; + color_class: focusbtBgColor; + visible: 1; + } + } + part { + name: "bookmarkmanager_text"; + type: TEXT; + scale: 1; + description { + state: "default" 0.0; + visible: 1; + fixed: 1 1; + rel1 { relative: 0.0 0.0;to: "bookmarkmanager_button";} + rel2 { relative: 1.0 1.0;to: "bookmarkmanager_button";} + color: 0 0 0 255; + text { + text: "Bookmark Manager"; + font: "Sans"; + size: 27; + align: 0.5 0.5; + } + } + } + part { + name: "bookmarkmanager_over"; + scale:1; + type: SWALLOW; + mouse_events: 1; + description { + state: "default" 0.0; + visible: 1; + align: 0 0; + fixed: 1 1; + min: 348 65; + max: 348 65; + rel1 { relative: 0.0 0.0; to: "bookmarkmanager_button";} + rel2 { relative: 1.0 1.0; to: "bookmarkmanager_button";} + color_class: transparent; + } + } + part { + name: "bookmarkmanager_click"; + scale:1; + type: SWALLOW; + mouse_events: 1; + description { + state: "default" 0.0; + visible: 1; + align: 0 0; + fixed: 1 1; + min: 348 65; + max: 348 65; + rel1 { relative: 0.0 0.0; to: "bookmarkmanager_over";} + rel2 { relative: 1.0 1.0; to: "bookmarkmanager_over";} + } + } + }//parts + programs{ + program { + name: "mouse_click_bookmarkmanager"; + signal: "mouse,clicked,1"; + source: "bookmarkmanager_over"; + script { + emit("elm,action,click", ""); + } + } + program { + name: "mouse_in_bookmarkmanager_click"; + signal: "mouse,in"; + source: "bookmarkmanager_*"; + action: STATE_SET "highlight" 0.0; + target: "bookmarkmanager_button"; + target: "bookmarkmanager_over"; + target: "bookmarkmanager_text"; + } + program { + name: "mouse_out_bookmarkmanager_click"; + signal: "mouse,out"; + source: "bookmarkmanager_*"; + action: STATE_SET "default" 0.0; + target: "bookmarkmanager_button"; + target: "bookmarkmanager_over"; + target: "bookmarkmanager_text"; + } + } +} + +group { + name: "elm/button/base/invisible_button"; + parts { + part { + name: "button"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + visible: 1; + fixed: 1 1; + color: 0 0 0 0; + } + } + part { + name: "over"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + visible: 1; + fixed: 1 1; + rel1 { relative: 0.0 0.0;to: "button";} + rel2 { relative: 1.0 1.0;to: "button";} + color: 0 0 0 0; + } + } + } + programs { + program { + name: "mouse_click"; + signal: "mouse,clicked,1"; + source: "over"; + script { + emit("elm,action,click", ""); + } + } + } +} + diff --git a/services/WebPageUI/edc/URIEntry.edc b/services/WebPageUI/edc/URIEntry.edc index f3f1da0..0eae949 100644 --- a/services/WebPageUI/edc/URIEntry.edc +++ b/services/WebPageUI/edc/URIEntry.edc @@ -125,6 +125,7 @@ collections { source: "elm/entry/selection/browser_entry"; source4: "elm/entry/cursor/browser_entry"; description { + max: 1378 82; state: "default" 0.0; rel1.relative: 0.0 0.0; rel2.relative: 1.0 1.0; diff --git a/services/WebPageUI/edc/WebPageUI.edc b/services/WebPageUI/edc/WebPageUI.edc index 13983f4..ae1edaf 100644 --- a/services/WebPageUI/edc/WebPageUI.edc +++ b/services/WebPageUI/edc/WebPageUI.edc @@ -21,6 +21,7 @@ collections { name: "main_layout"; images { image: "web_shadow.png" COMP; + image: "btn_bar_incognito.png" COMP; } parts { part { @@ -168,6 +169,33 @@ collections { } } part { + name: "incognito"; + type: IMAGE; + repeat_events: 1; + scale: 1; + description { + state: "default" 0.0; + visible: 0; + rel1 { + relative: 0.0 0.0; + to: "uri_bar_bg"; + offset: 1623 0; + } + rel2 { + relative: 0.0 0.0; + to: "uri_bar_bg"; + offset: 1623+82 0+102; + } + align: 0.5 0.5; + image.normal: "btn_bar_incognito.png"; + } + description { + state: "visible" 1.0; + inherit: "default" 0.0; + visible: 1; + } + } + part { name: "progress_bar"; type: SWALLOW; scale: 1; @@ -296,6 +324,20 @@ collections { target: "progress_bar_light_bg"; } program { + name: "show_incognito_ico"; + signal: "incognito,true"; + source: "ui"; + action: STATE_SET "visible" 1.0; + target: "incognito"; + } + program { + name: "hide_incognito_ico"; + signal: "incognito,false"; + source: "ui"; + action: STATE_SET "default" 0.0; + target: "incognito"; + } + program { name: "show_popup"; signal: "elm,state,show"; source: "elm"; diff --git a/services/WebPageUI/images/btn_bar_incognito.png b/services/WebPageUI/images/btn_bar_incognito.png new file mode 100644 index 0000000000000000000000000000000000000000..1f5d11c44bd4650b16fcaf3dfb8aebc842c99ecf GIT binary patch literal 1305 zcmbVMTWs4@7la zX$2a~0~3OcqKQbTnh-a^Zk+&W(uNQcu(gx6?rAGx6}%uOQEmbOLWs+8niL+YJz&|N z&pH0T@4uY?__>knBU}2m_E8kIB{eMP$lH60w{Ip`Shxtt>t3uB@TgtHHPu0ssN3TR zq)fGha!A#upS*+yDQZ*E$QN)SlNL1F45*$>pl((Po1zAX>Qz-MBMin-$*|(|4uLU6l92bBQmgArggn}@{1j)_$VMJg#AruAeizeP2y(r}5 zWZM^+#pwx*s{+H+YPCQu9I%}d19_hJG(sUivGBXo7FO$i%iZ2lkddo7Mim>j1w2J{ z+@8d7nnb#mf?3UE)`cy%T_{pArmj{Q7zi?^>E+e3c5x2<8^(s#ZhpFom>hELNk=35 zQQY1kliJn;X0( zS4cQW#kP~T?MkNuMkZ`*yAyU5Bt|)~bIh=GyXNllwr4F{89Bxj(vyyDf>wP6V*~#r zbY6+kPmRr#(RFE`KL%%)GI zjvg)D7#q40$=uU>_3p0WSH6V`$A%MaFe7U$s7eE9f{ zSJSy%>5b*h(@RT5|DmfVX|d703y6(VzD(fnKi>c8+^=8EKdQ`>S1aA^z>ghXN-Ez} zF!#%jOHqIG+Pgp3xYy3?duhs?JN!&{Z~vPFat}Awz>{j}wP0Wth|ObfQ=2GmYdZEB R^WyW~&nl&4<#}m;;~)2?bdE>n4?=ex8Q(`DT^n%_Kj6&Uuhq%5E7jy zJeY`ynt0HI7fzl{IEYaXdhp`Ka55&ug9q{CK_kBI4|*URY}&rp*YEfHzVG*a-|d;H zi~YUBy#zt@=dwxxuY>qG+ueoV+U}EiyqrO53C+R^s%b7DWCNA~nX|M7Pym{-y8IT5 z6GUglES69ye@W7zMQec#?OP5;6U2DZcQkzwAhHY=Oglk++kQcjrjelL_Isv zT8*wnXy`65tSE{B2gil5MaWyVk>-bNZ?w&z08e*K2bs_&14gY3S5Sh&kv3DXoP7R} z*!EgNVaXU@a~PHmGnN(P)v)$Z0sIZ)NNcaS>HwwyJhAM zg?WXQSzHN~7Zo*=<}w1OsA*M}xi&Uudq}f&(DrKvew*0zu~;eX0u4d82;ow@17@la zL9YrOGCeDhV{@i$z?ye1C{Ht61-RyQU}Riqkqvz%^C*V{kA`&>a6XOZy0SV6Z)Gef)7aJix{i;hl`}sc4_@90<~pZNDbG^#xBdWD5Lfm9 literal 0 HcmV?d00001 -- 2.7.4 From 8beed17e9e6dfd776fb91a8150645dd95cb3263b Mon Sep 17 00:00:00 2001 From: posial Date: Tue, 20 Oct 2015 12:31:16 +0200 Subject: [PATCH 04/16] Cannot link boost libraries when building unit tests [issue] https://bugs.tizen.org/jira/browse/TT-166 [problem] Cannot link boost libraries when building unit tests [solution] Remove cmake variables names shadowing [verification] build browser Change-Id: I79e4619860ad1234d36e96240279c311086eb55d --- CMakeLists.txt | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94aed0c..312cc7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,16 +46,11 @@ else() message(FATAL_ERROR "The Compiler ${CMAKE_CXX_COMPILER} doesn't support C++11") endif() - -find_package(Boost 1.49.0 REQUIRED COMPONENTS - regex - filesystem - system - date_time - ) +set(BOOST_LIBS regex filesystem system date_time) if(BUILD_UT) -find_package(Boost 1.49.0 REQUIRED COMPONENTS unit_test_framework) + set(BOOST_LIBS ${BOOST_LIBS} unit_test_framework) ENDIF(BUILD_UT) +find_package(Boost 1.49.9 REQUIRED COMPONENTS ${BOOST_LIBS}) #RPATH settings set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) -- 2.7.4 From 4f92c462a506c6bce90826336169f0dd499f0f4c Mon Sep 17 00:00:00 2001 From: Adam Skobodzinski Date: Tue, 20 Oct 2015 10:50:07 +0200 Subject: [PATCH 05/16] Using UrlHistoryList do display history list (on urientry edition). [Issue] https://bugs.tizen.org/jira/browse/TT-161 [Problem] 'Display URL from browser history that matches to given keyword.' [Solution] UrlHistoryList is receiving list of matched entries and creates a genlist. List is hidden, when list item is selected (with cursor only for now) or focus changes from the uri entry. Created genlist is not added to a focus chain yet (this will be delivered soon). [Verify] Typing words in uri entry should display list with matched entries. Choosing item shoud load page in a new tab. Loading page or focusing out from urientry should hide the list. Signed-off-by: Adam Skobodzinski Change-Id: Icb67a9b5c47556788d256613c832cdacb7620bf3 --- services/HistoryService/HistoryService.cpp | 13 ++- services/HistoryService/HistoryService.h | 11 +- .../PlatformInputManager/PlatformInputManager.cpp | 2 + .../PlatformInputManager/PlatformInputManager.h | 1 + services/QuickAccess/CMakeLists.txt | 1 - services/QuickAccess/QuickAccess.cpp | 29 ++++- services/QuickAccess/QuickAccess.h | 9 ++ .../QuickAccess/UrlHistoryList/GenlistManager.cpp | 75 +++++++------ .../QuickAccess/UrlHistoryList/GenlistManager.h | 53 +++++---- .../UrlHistoryList/GenlistManagerCallbacks.cpp | 123 +++++++++------------ .../UrlHistoryList/GenlistManagerCallbacks.h | 66 +++++------ .../QuickAccess/UrlHistoryList/UrlHistoryList.cpp | 93 ++++++++++------ .../QuickAccess/UrlHistoryList/UrlHistoryList.h | 102 +++++++++++++---- .../UrlHistoryList/UrlMatchesStyler.cpp | 4 +- .../QuickAccess/UrlHistoryList/UrlMatchesStyler.h | 4 +- .../QuickAccess/UrlHistoryList/WidgetListManager.h | 51 --------- services/QuickAccess/edc/QuickAccess.edc | 32 ++++++ services/SimpleUI/SimpleUI.cpp | 29 +++++ services/SimpleUI/SimpleUI.h | 6 + services/WebPageUI/URIEntry.cpp | 27 +++-- services/WebPageUI/URIEntry.h | 14 ++- 21 files changed, 441 insertions(+), 304 deletions(-) delete mode 100644 services/QuickAccess/UrlHistoryList/WidgetListManager.h diff --git a/services/HistoryService/HistoryService.cpp b/services/HistoryService/HistoryService.cpp index a346c71..1287c1c 100644 --- a/services/HistoryService/HistoryService.cpp +++ b/services/HistoryService/HistoryService.cpp @@ -485,7 +485,8 @@ std::shared_ptr HistoryService::getHistoryItemsByURL( } std::shared_ptr HistoryService::getHistoryItemsByKeywordsString( - const std::string& keywordsString, int maxItems) + const std::string& keywordsString, const int maxItems, + const int minKeywordLength) { if (keywordsString.empty()) return std::make_shared(); @@ -500,7 +501,7 @@ std::shared_ptr HistoryService::getHistoryItemsByKeywordsStri boost::algorithm::to_lower(longestKeyword); // assumption: search starts when longest keyword is at least 3 characters long - if (longestKeyword.length() < 3) { + if (longestKeyword.length() < minKeywordLength) { return std::make_shared(); } @@ -515,9 +516,11 @@ std::shared_ptr HistoryService::getHistoryItemsByKeywordsStri m_historyMatchFinder->removeMismatches(historyItems, keywords); } - if (historyItems->size() > maxItems) { - historyItems->erase(historyItems->begin() + maxItems, - historyItems->end()); + if (maxItems != -1) { + if (historyItems->size() > maxItems) { + historyItems->erase(historyItems->begin() + maxItems, + historyItems->end()); + } } return historyItems; } diff --git a/services/HistoryService/HistoryService.h b/services/HistoryService/HistoryService.h index 3eda793..fe23f8e 100644 --- a/services/HistoryService/HistoryService.h +++ b/services/HistoryService/HistoryService.h @@ -68,13 +68,18 @@ public: * Splits pattern into words by removing spaces. History item matches * pattern, when its url contains all words (order not considered). * - * @param keywords - * @param maxItems + * @param keywords string containing keywords separated by spaces + * @param maxItems searched items number will be shortened to this maxItems. + * if -1: no shortening. + * @param minKeywordLength minimum length of the longest keyword picked, + * from which searching will start. If longest keyword is shorter than + * #minKeywordLength, then search will not start. * @return vector of shared pointers to history items matching given * pattern */ std::shared_ptr getHistoryItemsByKeywordsString( - const std::string& keywordsString, int maxItems); + const std::string& keywordsString, const int maxItems, + const int minKeywordLength); int getHistoryItemsCount(); void setStorageServiceTestMode(bool testmode = true); diff --git a/services/PlatformInputManager/PlatformInputManager.cpp b/services/PlatformInputManager/PlatformInputManager.cpp index fddb242..3d3d85c 100644 --- a/services/PlatformInputManager/PlatformInputManager.cpp +++ b/services/PlatformInputManager/PlatformInputManager.cpp @@ -91,6 +91,8 @@ Eina_Bool PlatformInputManager::__filter(void *data, void */*loop_data*/, int ty return EINA_TRUE; BROWSER_LOGD("Released key: %s", ev->keyname); + } else if (type == ECORE_EVENT_MOUSE_BUTTON_DOWN) { + self->mouseClicked(); } return EINA_TRUE; } diff --git a/services/PlatformInputManager/PlatformInputManager.h b/services/PlatformInputManager/PlatformInputManager.h index 0dc980e..781a418 100644 --- a/services/PlatformInputManager/PlatformInputManager.h +++ b/services/PlatformInputManager/PlatformInputManager.h @@ -54,6 +54,7 @@ public: boost::signals2::signal leftPressed; boost::signals2::signal rightPressed; boost::signals2::signal backPressed; + boost::signals2::signal mouseClicked; /** * @brief Returns current service's name. diff --git a/services/QuickAccess/CMakeLists.txt b/services/QuickAccess/CMakeLists.txt index 9d794bd..2b76470 100644 --- a/services/QuickAccess/CMakeLists.txt +++ b/services/QuickAccess/CMakeLists.txt @@ -13,7 +13,6 @@ set(QuickAccess_HEADERS QuickAccess.h DetailPopup.h UrlHistoryList/UrlHistoryList.h - UrlHistoryList/WidgetListManager.h UrlHistoryList/GenlistManager.h UrlHistoryList/GenlistManagerCallbacks.h UrlHistoryList/UrlMatchesStyler.h diff --git a/services/QuickAccess/QuickAccess.cpp b/services/QuickAccess/QuickAccess.cpp index 5db57b6..0624b26 100644 --- a/services/QuickAccess/QuickAccess.cpp +++ b/services/QuickAccess/QuickAccess.cpp @@ -25,6 +25,7 @@ #include "Tools/EflTools.h" #include "../Tools/BrowserImage.h" #include "Tools/GeneralTools.h" +#include "UrlHistoryList/UrlHistoryList.h" #define efl_scale (elm_config_scale_get() / elm_app_base_scale_get()) @@ -75,10 +76,14 @@ QuickAccess::QuickAccess() , m_after_history_thumb(false) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); - edjFilePath = EDJE_DIR; + edjFilePath = edjFilePathUrlHistoryList = EDJE_DIR; edjFilePath.append("QuickAccess/QuickAccess.edj"); + edjFilePathUrlHistoryList.append("QuickAccess/UrlHistoryList.edj"); elm_theme_extension_add(nullptr, edjFilePath.c_str()); + elm_theme_extension_add(nullptr, edjFilePathUrlHistoryList.c_str()); QuickAccess::createItemClasses(); + + m_urlHistoryList = std::make_shared(this); } QuickAccess::~QuickAccess() @@ -100,6 +105,7 @@ Evas_Object* QuickAccess::getContent() M_ASSERT(m_parent); if (!m_layout) { m_layout = createQuickAccessLayout(m_parent); + m_urlHistoryListLayout = createUrlHistoryListLayout(m_layout); } return m_layout; } @@ -249,6 +255,21 @@ Evas_Object* QuickAccess::createBottomButton(Evas_Object *parent) return layoutBottom; } +Evas_Object* QuickAccess::createUrlHistoryListLayout(Evas_Object* parent) +{ + Evas_Object* urlHistoryListLayout = elm_layout_add(parent); + elm_layout_file_set(urlHistoryListLayout, edjFilePath.c_str(), "url_history_list_layout"); + evas_object_size_hint_weight_set(urlHistoryListLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set (urlHistoryListLayout, EVAS_HINT_FILL, EVAS_HINT_FILL); + + m_urlHistoryList->createLayout(urlHistoryListLayout); + if(m_urlHistoryList->getLayout()) + { + elm_object_part_content_set(urlHistoryListLayout, "url_history_list_swallow", m_urlHistoryList->getLayout()); + } + return urlHistoryListLayout; +} + void QuickAccess::_mostVisited_clicked(void * data, Evas_Object *, void *) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); @@ -440,6 +461,7 @@ void QuickAccess::showUI() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); evas_object_show(m_layout); + evas_object_show(m_urlHistoryListLayout); if (elm_layout_content_get(m_layout, "elm.swallow.content") == m_bookmarksView) { evas_object_show(m_bookmarksView); } else { @@ -493,6 +515,11 @@ DetailPopup& QuickAccess::getDetailPopup() return m_detailPopup; } +UrlHistoryPtr QuickAccess::getUrlHistoryList() +{ + return m_urlHistoryList; +} + void QuickAccess::backButtonClicked() { if (m_detailPopup.isVisible()) { diff --git a/services/QuickAccess/QuickAccess.h b/services/QuickAccess/QuickAccess.h index 5418b38..9dd5155 100644 --- a/services/QuickAccess/QuickAccess.h +++ b/services/QuickAccess/QuickAccess.h @@ -31,6 +31,9 @@ namespace tizen_browser{ namespace base_ui{ +class UrlHistoryList; +typedef std::shared_ptr UrlHistoryPtr; + //TODO: This class name is not revelant to what this class actually does. //Rename this class and file to "QuickAccessUI". class BROWSER_EXPORT QuickAccess @@ -50,6 +53,7 @@ public: bool isDesktopMode() const; void setDesktopMode(bool mode); DetailPopup & getDetailPopup(); + UrlHistoryPtr getUrlHistoryList(); void backButtonClicked(); inline bool isMostVisitedActive() const; void refreshFocusChain(); @@ -80,6 +84,7 @@ private: Evas_Object* createBookmarksView(Evas_Object *parent); Evas_Object* createBottomButton(Evas_Object *parent); Evas_Object* createTopButtons(Evas_Object *parent); + Evas_Object* createUrlHistoryListLayout(Evas_Object *parent); static char* _grid_bookmark_text_get(void *data, Evas_Object *obj, const char *part); static Evas_Object * _grid_bookmark_content_get(void *data, Evas_Object *obj, const char *part); @@ -104,11 +109,15 @@ private: std::vector m_tiles; Eina_List* m_parentFocusChain; + UrlHistoryPtr m_urlHistoryList; + Evas_Object* m_urlHistoryListLayout; + Elm_Gengrid_Item_Class * m_bookmark_item_class; DetailPopup m_detailPopup; services::HistoryItemVector m_historyItems; bool m_gengridSetup; std::string edjFilePath; + std::string edjFilePathUrlHistoryList; bool m_desktopMode; static const int MAX_TILES_NUMBER; diff --git a/services/QuickAccess/UrlHistoryList/GenlistManager.cpp b/services/QuickAccess/UrlHistoryList/GenlistManager.cpp index c29dfc5..fda4254 100644 --- a/services/QuickAccess/UrlHistoryList/GenlistManager.cpp +++ b/services/QuickAccess/UrlHistoryList/GenlistManager.cpp @@ -19,7 +19,7 @@ #include "UrlMatchesStyler.h" namespace tizen_browser { -namespace services { +namespace base_ui { GenlistManager::GenlistManager() { @@ -38,6 +38,8 @@ GenlistManager::GenlistManager() m_historyItemSpaceClass->func.content_get = nullptr; m_historyItemSpaceClass->func.state_get = nullptr; m_historyItemSpaceClass->func.del = nullptr; + + GenlistManagerCallbacks::setGenlistManager(this); } GenlistManager::~GenlistManager() @@ -47,10 +49,8 @@ GenlistManager::~GenlistManager() void GenlistManager::clearWidget() { - elm_genlist_clear(m_genlist); - elm_genlist_clear(m_genlist); - elm_genlist_clear(m_genlist); - elm_genlist_clear(m_genlist); + if(m_genlist && elm_genlist_items_count(m_genlist)) + elm_genlist_clear(m_genlist); } void GenlistManager::onMouseFocusChange(bool mouseInsideWidget) @@ -72,28 +72,22 @@ Evas_Object* GenlistManager::createWidget(Evas_Object* parentLayout) ELM_SCROLLER_POLICY_OFF); } - evas_object_smart_callback_add(m_genlist, "scroll,anim,stop", - GenlistManagerCallbacks::cb_genlistAnimStop, this); evas_object_smart_callback_add(m_genlist, "edge,top", - GenlistManagerCallbacks::cb_genlistEdgeTop, this); + GenlistManagerCallbacks::_genlist_edge_top, this); evas_object_smart_callback_add(m_genlist, "edge,bottom", - GenlistManagerCallbacks::cb_genlistEdgeBottom, this); - - evas_object_smart_callback_add(m_genlist, "activated", - GenlistManagerCallbacks::cb_genlistActivated, this); - evas_object_smart_callback_add(m_genlist, "pressed", - GenlistManagerCallbacks::cb_genlistPressed, this); - evas_object_smart_callback_add(m_genlist, "selected", - GenlistManagerCallbacks::cb_genlistSelected, this); + GenlistManagerCallbacks::_genlist_edge_bottom, this); evas_object_event_callback_add(m_genlist, EVAS_CALLBACK_MOUSE_IN, - GenlistManagerCallbacks::cb_genlistMouseIn, this); + GenlistManagerCallbacks::_genlist_mouse_in, this); evas_object_event_callback_add(m_genlist, EVAS_CALLBACK_MOUSE_OUT, - GenlistManagerCallbacks::cb_genlistMouseOut, this); - evas_object_smart_callback_add(m_genlist, "unselected", - GenlistManagerCallbacks::cb_genlistUnselected, this); + GenlistManagerCallbacks::_genlist_mouse_out, this); + evas_object_smart_callback_add(m_genlist, "focused", - GenlistManagerCallbacks::cb_genlistFocused, this); + GenlistManagerCallbacks::_genlist_focused, this); + evas_object_smart_callback_add(m_genlist, "unfocused", + GenlistManagerCallbacks::_genlist_unfocused, this); + + } return m_genlist; } @@ -113,9 +107,9 @@ void GenlistManager::showWidget(const string& editedUrl, m_itemUrlFirst = m_itemUrlLast = nullptr; Elm_Object_Item* itemAppended; - for (auto it : m_readyUrls) { + for(auto it : m_readyUrlPairs) { itemAppended = elm_genlist_item_append(m_genlist, m_historyItemClass, - it.get(), nullptr, ELM_GENLIST_ITEM_NONE, nullptr, this); + it.get(), nullptr, ELM_GENLIST_ITEM_NONE, GenlistManagerCallbacks::_item_selected, it.get()); if (!m_itemUrlFirst) m_itemUrlFirst = itemAppended; } @@ -127,14 +121,22 @@ void GenlistManager::showWidget(const string& editedUrl, } } -void GenlistManager::hideWidget() +void GenlistManager::hideWidgetPretty() { - if (widgetPreviouslyHidden) + if (widgetPreviouslyHidden) { + hideWidgetInstant(); return; + } startScrollOut(); widgetPreviouslyHidden = true; } +void GenlistManager::hideWidgetInstant() +{ + if(m_genlist) + evas_object_hide(m_genlist); +} + bool GenlistManager::isWidgetHidden() { return widgetPreviouslyHidden; @@ -143,7 +145,7 @@ bool GenlistManager::isWidgetHidden() void GenlistManager::onMouseClick() { if (!mouseInsideWidget) { - hideWidget(); + hideWidgetPretty(); } } @@ -181,7 +183,7 @@ void GenlistManager::addSpaces() if (m_itemUrlLast) { m_itemSpaceFirst = m_itemSpaceLast = nullptr; Elm_Object_Item* itemAppended; - for (auto i = 0; i < historyItemsVisibleMax; ++i) { + for (auto i = 0; i < HISTORY_ITEMS_VISIBLE_MAX; ++i) { // append spaces to the last url item, so they can be easily cleared itemAppended = elm_genlist_item_append(m_genlist, m_historyItemSpaceClass, nullptr, m_itemUrlLast, @@ -201,14 +203,14 @@ void GenlistManager::removeSpaces() m_itemSpaceFirst = m_itemSpaceLast = nullptr; } -Evas_Object* GenlistManager::m_contentGet(void *data, Evas_Object *obj, - const char *part) +Evas_Object* GenlistManager::m_contentGet(void* data, Evas_Object* obj, + const char* part) { Evas_Object* label = elm_label_add(obj); if (strcmp(part, "matched_url") == 0) { - const string * const item = reinterpret_cast(data); + const UrlPair* const item = reinterpret_cast(data); if (item) { - elm_object_text_set(label, item->c_str()); + elm_object_text_set(label, item->urlHighlighted.c_str()); evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(label, EVAS_HINT_FILL, @@ -224,13 +226,14 @@ void GenlistManager::prepareUrlsVector(const string& editedUrl, // free previously used urls. IMPORTANT: it has to be assured that previous // genlist items are not using these pointers. m_readyUrls.clear(); + m_readyUrlPairs.clear(); for (auto it : *matchedEntries) { - m_readyUrls.push_back( - make_shared < string - > (m_urlMatchesStyler->getUrlHighlightedMatches( - it->getUrl(), editedUrl))); + UrlPair newUrlPair(it->getUrl(), + m_urlMatchesStyler->getUrlHighlightedMatches(it->getUrl(), + editedUrl)); + m_readyUrlPairs.push_back(make_shared < UrlPair > (newUrlPair)); } } -} /* namespace services */ +} /* namespace base_ui */ } /* namespace tizen_browser */ diff --git a/services/QuickAccess/UrlHistoryList/GenlistManager.h b/services/QuickAccess/UrlHistoryList/GenlistManager.h index 05d5cd3..b1e91e1 100644 --- a/services/QuickAccess/UrlHistoryList/GenlistManager.h +++ b/services/QuickAccess/UrlHistoryList/GenlistManager.h @@ -18,46 +18,54 @@ #define GENLISTMANAGER_H_ #include - +#include "services/HistoryService/HistoryItem.h" +#include #include "BrowserLogger.h" -#include "WidgetListManager.h" using namespace std; namespace tizen_browser { -namespace services { +namespace base_ui { class GenlistManagerCallbacks; class UrlMatchesStyler; typedef shared_ptr UrlMatchesStylerPtr; -class GenlistManager: public WidgetListManager +typedef struct UrlPair_s { + UrlPair_s(string a, string b) : urlOriginal(a), urlHighlighted(b) {} + string urlOriginal; + string urlHighlighted; +} UrlPair; + +class GenlistManager { friend class GenlistManagerCallbacks; public: GenlistManager(); - virtual ~GenlistManager(); + ~GenlistManager(); - virtual Evas_Object* createWidget(Evas_Object* parentLayout); - virtual Evas_Object* getWidget(); + Evas_Object* createWidget(Evas_Object* parentLayout); + Evas_Object* getWidget(); - virtual void showWidget(const string& editedUrl, + void showWidget(const string& editedUrl, shared_ptr matchedEntries); - virtual void hideWidget(); - void onMouseClick(); - + void hideWidgetPretty(); + void hideWidgetInstant(); bool isWidgetHidden(); + void onMouseClick(); /** * Add empty list elements to allow scroll in effect. */ void addSpaces(); void removeSpaces(); - void clearWidget(); -private: + boost::signals2::signal signalItemSelected; + boost::signals2::signal signalWidgetFocused; + boost::signals2::signal signalWidgetUnfocused; +private: static Evas_Object* m_contentGet(void *data, Evas_Object *obj, const char *part); bool widgetExists() @@ -66,21 +74,23 @@ private: } void prepareUrlsVector(const string& editedUrl, shared_ptr matchedEntries); - void startScrollIn(); - void startScrollOut(); + void setLastEdgeTop(bool edgeTop); bool getLastEdgeTop(); void onMouseFocusChange(bool mouseInsideWidget); + void startScrollIn(); + void startScrollOut(); + Evas_Object* m_parentLayout = nullptr; Evas_Object* m_genlist = nullptr; const bool genlistShowScrollbar = false; // don't know how to get from edc: - const int historyItemH = 82; - const int historyItemsVisibleMax = 5; + const int HISTORY_ITEM_H = 82; + const int HISTORY_ITEMS_VISIBLE_MAX = 5; // don't know how to calculate: - const int genlistH = historyItemH * historyItemsVisibleMax; + const int GENLIST_H = HISTORY_ITEM_H * HISTORY_ITEMS_VISIBLE_MAX; /* * Set to true, whenever hide request occurs. Set to false, whenever show @@ -96,8 +106,8 @@ private: */ bool lastEdgeTop = true; - Elm_Gengrid_Item_Class * m_historyItemClass; - Elm_Gengrid_Item_Class * m_historyItemSpaceClass; + Elm_Gengrid_Item_Class* m_historyItemClass; + Elm_Gengrid_Item_Class* m_historyItemSpaceClass; Elm_Object_Item* m_itemUrlFirst = nullptr; Elm_Object_Item* m_itemUrlLast = nullptr; Elm_Object_Item* m_itemSpaceFirst = nullptr; @@ -111,11 +121,12 @@ private: * manually in m_contentGet(). */ vector> m_readyUrls; + vector> m_readyUrlPairs; UrlMatchesStylerPtr m_urlMatchesStyler; }; -} /* namespace services */ +} /* namespace base_ui */ } /* namespace tizen_browser */ #endif /* GENLISTMANAGER_H_ */ diff --git a/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.cpp b/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.cpp index 25c3868..17d1cf3 100644 --- a/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.cpp +++ b/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.cpp @@ -15,13 +15,12 @@ */ #include "BrowserLogger.h" -#include "GenlistManagerCallbacks.h" -#include "GenlistManager.h" +#include -namespace tizen_browser -{ -namespace services -{ +namespace tizen_browser { +namespace base_ui { + +GenlistManager* GenlistManagerCallbacks::genlistManager = nullptr; GenlistManagerCallbacks::GenlistManagerCallbacks() { @@ -31,89 +30,69 @@ GenlistManagerCallbacks::~GenlistManagerCallbacks() { } -void GenlistManagerCallbacks::cb_genlistAnimStop(void *data, Evas_Object *obj, - void *event_info) -{ -} - -void GenlistManagerCallbacks::cb_genlistEdgeTop(void *data, Evas_Object *obj, - void *event_info) +void GenlistManagerCallbacks::_genlist_edge_top(void *data, Evas_Object* /*obj*/, + void* /*event_info*/) { - BROWSER_LOGD("@@ %s", __FUNCTION__); - auto manager = static_cast(data); - manager->setLastEdgeTop(false); - // spaces added for 'slide in' effect are not longer needed - manager->removeSpaces(); + auto manager = static_cast(data); + manager->setLastEdgeTop(false); + // spaces added for 'slide in' effect are not longer needed + manager->removeSpaces(); } -void GenlistManagerCallbacks::cb_genlistEdgeBottom(void *data, Evas_Object *obj, - void *event_info) +void GenlistManagerCallbacks::_genlist_edge_bottom(void *data, Evas_Object* /*obj*/, + void* /*event_info*/) { - auto manager = static_cast(data); - manager->setLastEdgeTop(true); - if (manager->isWidgetHidden()) - { - manager->clearWidget(); - evas_object_hide(manager->getWidget()); - } + auto manager = static_cast(data); + manager->setLastEdgeTop(true); + if (manager->isWidgetHidden()) { + manager->clearWidget(); + evas_object_hide(manager->getWidget()); + } } -void GenlistManagerCallbacks::cb_genlistActivated(void *data, Evas_Object *obj, - void *event_info) -{ -} -void GenlistManagerCallbacks::cb_genlistPressed(void *data, Evas_Object *obj, - void *event_info) -{ -} -void GenlistManagerCallbacks::cb_genlistSelected(void *data, Evas_Object *obj, - void *event_info) -{ -} -void GenlistManagerCallbacks::cb_genlistUnselected(void *data, Evas_Object *obj, - void *event_info) +void GenlistManagerCallbacks::_genlist_mouse_in(void* data, Evas* /*e*/, + Evas_Object* /*obj*/, void* /*event_info*/) { + auto manager = static_cast(data); + manager->onMouseFocusChange(true); } - -void GenlistManagerCallbacks::cb_genlistFocused(void *data, Evas_Object *obj, - void *event_info) +void GenlistManagerCallbacks::_genlist_mouse_out(void* data, Evas* /*e*/, + Evas_Object* /*obj*/, void* /*event_info*/) { + auto manager = static_cast(data); + manager->onMouseFocusChange(false); } -void GenlistManagerCallbacks::cb_genlistUnfocused(void *data, Evas_Object *obj, - void *event_info) +void GenlistManagerCallbacks::_genlist_focused(void* /*data*/, Evas_Object* /*obj*/, + void* /*event_info*/) { + if(genlistManager) + { + genlistManager->signalWidgetFocused(); + } } -void GenlistManagerCallbacks::cb_genlistMouseIn(void *data, Evas *e, - Evas_Object *obj, void *event_info) -{ - auto manager = static_cast(data); - manager->onMouseFocusChange(true); -} -void GenlistManagerCallbacks::cb_genlistMouseOut(void *data, Evas *e, - Evas_Object *obj, void *event_info) +void GenlistManagerCallbacks::_genlist_unfocused(void* /*data*/, Evas_Object* /*obj*/, + void* /*event_info*/) { - auto manager = static_cast(data); - manager->onMouseFocusChange(false); + if(genlistManager) + { + genlistManager->signalWidgetUnfocused(); + } } -void GenlistManagerCallbacks::cb_itemFocused(void *data, Evas_Object *obj, - void *event_info) -{ -} -void GenlistManagerCallbacks::cb_itemUnfocused(void *data, Evas_Object *obj, - void *event_info) -{ -} -void GenlistManagerCallbacks::cb_itemMouseIn(void *data, Elm_Object_Item *it, - const char *emission, const char *source) -{ -} -void GenlistManagerCallbacks::cb_itemMouseOut(void *data, Evas *e, - Evas_Object *obj, void *event_info) -{ +void GenlistManagerCallbacks::_item_selected(void* data, Evas_Object* /*obj*/, + void* /*event_info*/) +{ + const UrlPair* const item = reinterpret_cast(data); + if (item) { + if(genlistManager) + { + genlistManager->signalItemSelected(item->urlOriginal); + genlistManager->hideWidgetPretty(); + } + } } -} /* namespace services */ +} /* namespace base_ui */ } /* namespace tizen_browser */ diff --git a/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.h b/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.h index 25ff418..228108d 100644 --- a/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.h +++ b/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.h @@ -17,57 +17,47 @@ #ifndef GENLISTMANAGERCALLBACKS_H_ #define GENLISTMANAGERCALLBACKS_H_ +#include #include #include -class GenlistManager; - -namespace tizen_browser -{ -namespace services -{ +namespace tizen_browser { +namespace base_ui { class GenlistManagerCallbacks { public: - GenlistManagerCallbacks(); - virtual ~GenlistManagerCallbacks(); + GenlistManagerCallbacks(); + virtual ~GenlistManagerCallbacks(); + + static void _genlist_edge_top(void* data, Evas_Object* obj, + void* event_info); + static void _genlist_edge_bottom(void* data, Evas_Object* obj, + void* event_info); + + static void _genlist_mouse_in(void* data, Evas* e, Evas_Object* obj, + void* event_info); + static void _genlist_mouse_out(void* data, Evas* e, Evas_Object* obj, + void* event_info); + + static void _genlist_focused(void* data, Evas_Object* obj, + void* event_info); + static void _genlist_unfocused(void* data, Evas_Object* obj, + void* event_info); - static void cb_genlistAnimStop(void *data, Evas_Object *obj, - void *event_info); - static void cb_genlistEdgeTop(void *data, Evas_Object *obj, - void *event_info); - static void cb_genlistEdgeBottom(void *data, Evas_Object *obj, - void *event_info); + static void _item_selected(void* data, Evas_Object* obj, void* event_info); - static void cb_genlistActivated(void *data, Evas_Object *obj, - void *event_info); - static void cb_genlistPressed(void *data, Evas_Object *obj, - void *event_info); - static void cb_genlistSelected(void *data, Evas_Object *obj, - void *event_info); - static void cb_genlistUnselected(void *data, Evas_Object *obj, - void *event_info); + static void setGenlistManager(GenlistManager* genlistManager) + { + GenlistManagerCallbacks::genlistManager = genlistManager; + } - static void cb_genlistFocused(void *data, Evas_Object *obj, - void *event_info); - static void cb_genlistUnfocused(void *data, Evas_Object *obj, - void *event_info); - static void cb_genlistMouseIn(void *data, Evas *e, Evas_Object *obj, - void *event_info); - static void cb_genlistMouseOut(void *data, Evas *e, Evas_Object *obj, - void *event_info); +private: + static GenlistManager* genlistManager; - static void cb_itemFocused(void *data, Evas_Object *obj, void *event_info); - static void cb_itemUnfocused(void *data, Evas_Object *obj, - void *event_info); - static void cb_itemMouseIn(void *data, Elm_Object_Item *it, - const char *emission, const char *source); - static void cb_itemMouseOut(void *data, Evas *e, Evas_Object *obj, - void *event_info); }; -} /* namespace services */ +} /* namespace base_ui */ } /* namespace tizen_browser */ #endif /* GENLISTMANAGERCALLBACKS_H_ */ diff --git a/services/QuickAccess/UrlHistoryList/UrlHistoryList.cpp b/services/QuickAccess/UrlHistoryList/UrlHistoryList.cpp index fd76489..c6530bc 100644 --- a/services/QuickAccess/UrlHistoryList/UrlHistoryList.cpp +++ b/services/QuickAccess/UrlHistoryList/UrlHistoryList.cpp @@ -17,66 +17,89 @@ #include #include "UrlHistoryList.h" #include "GenlistManager.h" - #include "BrowserLogger.h" +#include "../QuickAccess.h" -namespace tizen_browser -{ -namespace base_ui -{ +namespace tizen_browser { +namespace base_ui { -UrlHistoryList::UrlHistoryList() : - m_layout(nullptr) +UrlHistoryList::UrlHistoryList(QuickAccess* quickAccess) : + m_layout(nullptr), m_quickAccess(quickAccess) { - m_edjFilePath = EDJE_DIR; - m_edjFilePath.append("MainUI/UrlHistoryList.edj"); - m_widgetListManager = make_shared(); + m_edjFilePath = EDJE_DIR; + m_edjFilePath.append("QuickAccess/UrlHistoryList.edj"); + m_genlistListManager = make_shared(); + m_genlistListManager->signalItemSelected.connect( + boost::bind(&UrlHistoryList::onListItemSelect, this, _1)); + m_genlistListManager->signalWidgetFocused.connect( + boost::bind(&UrlHistoryList::onListWidgetFocused, this)); + m_genlistListManager->signalWidgetUnfocused.connect( + boost::bind(&UrlHistoryList::onListWidgetUnfocused, this)); } UrlHistoryList::~UrlHistoryList() { } -void UrlHistoryList::show() +Evas_Object* UrlHistoryList::getLayout() { - if (m_layout) - { - evas_object_show(m_layout); - } + return m_layout; } -Evas_Object* UrlHistoryList::getLayout() +void UrlHistoryList::createLayout(Evas_Object* parentLayout) { - return m_layout; + m_layout = elm_layout_add(parentLayout); + elm_layout_file_set(m_layout, m_edjFilePath.c_str(), "url_history_list"); + + Evas_Object* widgetList = m_genlistListManager->createWidget(m_layout); } -void UrlHistoryList::createLayout(Evas_Object* parentLayout) +void UrlHistoryList::onURLEntryEditedByUser(const string& editedUrl, + shared_ptr matchedEntries) { - m_layout = elm_layout_add(parentLayout); - elm_layout_file_set(m_layout, m_edjFilePath.c_str(), "url_history_list"); + editedUrlStatesHelper.changeState(true); - Evas_Object* widgetList = m_widgetListManager->createWidget(m_layout); + if (matchedEntries->size() == 0) { + m_genlistListManager->hideWidgetPretty(); + } else { + Evas_Object* widgetList = m_genlistListManager->getWidget(); + elm_object_part_content_set(m_layout, "list_swallow", widgetList); + m_genlistListManager->showWidget(editedUrl, matchedEntries); + evas_object_show(widgetList); + } } -void UrlHistoryList::onURLEntryEdit(const string& editedUrl, - shared_ptr matchedEntries) +void UrlHistoryList::onURLEntryEdited() { - Evas_Object* widgetList = m_widgetListManager->getWidget(); - if (matchedEntries->size() == 0) - { - m_widgetListManager->hideWidget(); - } - else - { - elm_object_part_content_set(m_layout, "list_swallow", widgetList); - m_widgetListManager->showWidget(editedUrl, matchedEntries); - evas_object_show(widgetList); - } + editedUrlStatesHelper.changeState(false); + if (editedUrlStatesHelper.getCurrentState() + == EditedUrlState::EDITED_OTHER_FIRST) { + m_genlistListManager->hideWidgetPretty(); + } else { + // in this situation scroll will not work, it has to be hidden instantly + m_genlistListManager->hideWidgetInstant(); + } } void UrlHistoryList::onMouseClick() { - m_widgetListManager->onMouseClick(); + m_genlistListManager->onMouseClick(); +} + +void UrlHistoryList::onListItemSelect(std::string content) +{ + openURLInNewTab(make_shared < services::HistoryItem > (content), + m_quickAccess->isDesktopMode()); +} + +void UrlHistoryList::onListWidgetFocused() +{ + // will be used soon: in a proper focus-chain solution +} + +void UrlHistoryList::onListWidgetUnfocused() +{ + // will be used soon: in a proper focus-chain solution } }/* namespace base_ui */ diff --git a/services/QuickAccess/UrlHistoryList/UrlHistoryList.h b/services/QuickAccess/UrlHistoryList/UrlHistoryList.h index fa9934a..f42a425 100644 --- a/services/QuickAccess/UrlHistoryList/UrlHistoryList.h +++ b/services/QuickAccess/UrlHistoryList/UrlHistoryList.h @@ -21,20 +21,56 @@ #include #include "services/HistoryService/HistoryItem.h" +#include using namespace std; -namespace tizen_browser -{ +namespace tizen_browser { +namespace base_ui { + +class QuickAccess; +class GenlistManager; +typedef shared_ptr GenlistManagerPtr; -namespace services +enum class EditedUrlState { -class WidgetListManager; -typedef shared_ptr WidgetListManagerPtr; -} + // url was edited by a user (by typing) + EDITED_BY_USER, + // url was edited in other way than typing (but for the first time after previous user edition) + EDITED_OTHER_FIRST, + // url was edited in other way than typing (and previously was not edited by the user) + EDITED_OTHER_MANY_TIMES +}; -namespace base_ui +/** + * Needed to indicate who did the last url entry edition (user/other/other many times). Used + * to indicate when widget can be hidden in a pretty way or an instant way. + */ +class EditedUrlStatesHelper { +public: + EditedUrlStatesHelper() + { + } + void changeState(bool editedByUser) + { + if (editedByUser) { + currentState = EditedUrlState::EDITED_BY_USER; + } else { + if (currentState == EditedUrlState::EDITED_BY_USER) { + currentState = EditedUrlState::EDITED_OTHER_FIRST; + } else { + currentState = EditedUrlState::EDITED_OTHER_MANY_TIMES; + } + } + } + EditedUrlState getCurrentState() + { + return currentState; + } +private: + EditedUrlState currentState = EditedUrlState::EDITED_BY_USER; +}; /** * Manages list of url matches (URL from history). Manages top layout, creates @@ -43,25 +79,47 @@ namespace base_ui class UrlHistoryList { public: - UrlHistoryList(); - virtual ~UrlHistoryList(); - void show(); - void createLayout(Evas_Object* parentLayout); - Evas_Object *getLayout(); - - /** - * \brief entered url is edited (edited before acceptation) - */ - void onURLEntryEdit(const string& editedUrl, - shared_ptr matchedEntries); - void onMouseClick(); + UrlHistoryList(QuickAccess* quickAccess); + virtual ~UrlHistoryList(); + void createLayout(Evas_Object* parentLayout); + Evas_Object* getLayout(); + + // // on uri entry widget "changed,user" signal + void onURLEntryEditedByUser(const string& editedUrl, + shared_ptr matchedEntries); + // on uri entry widget "changed" signal + void onURLEntryEdited(); + + void onMouseClick(); + + boost::signals2::signal, bool)> openURLInNewTab; + + int getVisibleItemsMax() const + { + return VISIBLE_ITEMS_MAX; + } + + int getMinKeywordLength() const + { + return MIN_KEYWORD_LENGTH; + } private: + void onListItemSelect(std::string content); + void onListWidgetFocused(); + void onListWidgetUnfocused(); + + EditedUrlStatesHelper editedUrlStatesHelper; - Evas_Object* m_layout; - string m_edjFilePath; + // the maximum items number on a list + const int VISIBLE_ITEMS_MAX = 12; + // the minimum length of the keyword used to search matches + const int MIN_KEYWORD_LENGTH = 3; + Evas_Object* m_layout; + string m_edjFilePath; - services::WidgetListManagerPtr m_widgetListManager; + GenlistManagerPtr m_genlistListManager = nullptr; + QuickAccess* m_quickAccess; }; diff --git a/services/QuickAccess/UrlHistoryList/UrlMatchesStyler.cpp b/services/QuickAccess/UrlHistoryList/UrlMatchesStyler.cpp index c97758b..b03af5a 100644 --- a/services/QuickAccess/UrlHistoryList/UrlMatchesStyler.cpp +++ b/services/QuickAccess/UrlHistoryList/UrlMatchesStyler.cpp @@ -17,7 +17,7 @@ #include "UrlMatchesStyler.h" namespace tizen_browser { -namespace services { +namespace base_ui { UrlMatchesStyler::UrlMatchesStyler() : TAG_WHOLE_URL(""), @@ -127,5 +127,5 @@ string UrlMatchesStyler::getTaggedString(const string& strToHighlight, return strResult; } -} /* namespace services */ +} /* namespace base_ui */ } /* namespace tizen_browser */ diff --git a/services/QuickAccess/UrlHistoryList/UrlMatchesStyler.h b/services/QuickAccess/UrlHistoryList/UrlMatchesStyler.h index d100b29..75c5432 100644 --- a/services/QuickAccess/UrlHistoryList/UrlMatchesStyler.h +++ b/services/QuickAccess/UrlHistoryList/UrlMatchesStyler.h @@ -26,7 +26,7 @@ using namespace std; namespace tizen_browser { -namespace services { +namespace base_ui { class UrlMatchesStyler { public: @@ -103,7 +103,7 @@ private: }; -} /* namespace services */ +} /* namespace base_ui */ } /* namespace tizen_browser */ #endif /* URLMATCHESSTYLER_H_ */ diff --git a/services/QuickAccess/UrlHistoryList/WidgetListManager.h b/services/QuickAccess/UrlHistoryList/WidgetListManager.h deleted file mode 100644 index 18c22b5..0000000 --- a/services/QuickAccess/UrlHistoryList/WidgetListManager.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 WIDGETLISTMANAGER_H_ -#define WIDGETLISTMANAGER_H_ - -#include -#include -#include "services/HistoryService/HistoryItem.h" - -namespace tizen_browser -{ -namespace services -{ - -/** - * Interface for classes managing list-like widgets. - * TODO: consider if it could be used in whole application, not only for URL - * list. - */ -class WidgetListManager -{ -public: - virtual ~WidgetListManager() - { - } - virtual Evas_Object* createWidget(Evas_Object* parentLayout) = 0; - virtual Evas_Object* getWidget() = 0; - virtual void hideWidget() = 0; - virtual void showWidget(const std::string& editedUrl, - std::shared_ptr matchedEntries) = 0; - virtual void onMouseClick() = 0; -}; - -} /* namespace services */ -} /* namespace tizen_browser */ - -#endif /* WIDGETLISTMANAGER_H_ */ diff --git a/services/QuickAccess/edc/QuickAccess.edc b/services/QuickAccess/edc/QuickAccess.edc index c87299b..ef1881b 100644 --- a/services/QuickAccess/edc/QuickAccess.edc +++ b/services/QuickAccess/edc/QuickAccess.edc @@ -20,6 +20,11 @@ collections { #define ITEM_WIDTH 374 #define PARENT_ITEM_HEIGHT 36 +#define URI_INPUTBOX_LENGTH 1720 +#define URL_HISTORY_ITEM_H 82 +#define URL_HISTORY_ITEMS_VISIBLE_MAX 5 +#define URL_HISTORY_LIST_MAX_H HISTORY_ITEM_H*HISTORY_ITEMS_VISIBLE_MAX + group{ name: "elm/button/base/invisible_button"; parts{ @@ -1383,6 +1388,33 @@ group { name: "top_button_item"; } } +group { + name: "url_history_list_layout"; + parts + { + part + { + name: "url_history_list_swallow"; + type: SWALLOW; + description { + state: "default" 0.0; + min: URI_INPUTBOX_LENGTH URL_HISTORY_LIST_MAX_H; + max: -1 -1; + align: 0.0 0.0; + fixed: 1 1; + visible: 1; + rel1 { + relative: 0 0; + offset: 10 106; + } + rel2 { + relative: 1.0 1.0; + } + } + } + } +} + group { name: "bottom_button_item"; min: 1920 181; max: 1920 181; diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 084de51..8697e7e 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -46,6 +46,7 @@ #include "boost/date_time/posix_time/posix_time.hpp" #include "SqlStorage.h" #include "DetailPopup.h" +#include "UrlHistoryList/UrlHistoryList.h" #include "NotificationPopup.h" @@ -236,6 +237,8 @@ void SimpleUI::connectUISignals() M_ASSERT(m_webPageUI.get()); m_webPageUI->getURIEntry().uriChanged.connect(boost::bind(&SimpleUI::filterURL, this, _1)); + m_webPageUI->getURIEntry().uriEntryEditingChangedByUser.connect(boost::bind(&SimpleUI::onURLEntryEditedByUser, this, _1)); + m_webPageUI->getURIEntry().uriEntryEditingChanged.connect(boost::bind(&SimpleUI::onURLEntryEdited, this)); m_webPageUI->backPage.connect(boost::bind(&SimpleUI::switchViewToWebPage, this)); m_webPageUI->backPage.connect(boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine::back, m_webEngine.get())); m_webPageUI->reloadPage.connect(boost::bind(&SimpleUI::switchViewToWebPage, this)); @@ -251,6 +254,7 @@ void SimpleUI::connectUISignals() M_ASSERT(m_quickAccess.get()); m_quickAccess->getDetailPopup().openURLInNewTab.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1, _2)); + m_quickAccess->getUrlHistoryList()->openURLInNewTab.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1, _2)); m_quickAccess->openURLInNewTab.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1, _2)); m_quickAccess->mostVisitedTileClicked.connect(boost::bind(&SimpleUI::onMostVisitedTileClicked, this, _1, _2)); m_quickAccess->mostVisitedClicked.connect(boost::bind(&SimpleUI::onMostVisitedClicked, this)); @@ -409,6 +413,8 @@ void SimpleUI::connectModelSignals() m_platformInputManager->returnPressed.connect(boost::bind(&elm_exit)); m_platformInputManager->backPressed.connect(boost::bind(&SimpleUI::onBackPressed, this)); + m_platformInputManager->mouseClicked.connect( + boost::bind(&SimpleUI::onMouseClick, this)); } @@ -688,6 +694,29 @@ void SimpleUI::filterURL(const std::string& url) m_webPageUI->getURIEntry().clearFocus(); } +void SimpleUI::onURLEntryEditedByUser(const std::shared_ptr editedUrlPtr) +{ + string editedUrl(*editedUrlPtr); + int historyItemsVisibleMax = + m_quickAccess->getUrlHistoryList()->getVisibleItemsMax(); + int minKeywordLength = + m_quickAccess->getUrlHistoryList()->getMinKeywordLength(); + std::shared_ptr result = + m_historyService->getHistoryItemsByKeywordsString(editedUrl, + historyItemsVisibleMax, minKeywordLength); + m_quickAccess->getUrlHistoryList()->onURLEntryEditedByUser(editedUrl, result); +} + +void SimpleUI::onURLEntryEdited() +{ + m_quickAccess->getUrlHistoryList()->onURLEntryEdited(); +} + +void SimpleUI::onMouseClick() +{ + m_quickAccess->getUrlHistoryList()->onMouseClick(); +} + void SimpleUI::webEngineURLChanged(const std::string url) { BROWSER_LOGD("webEngineURLChanged:%s", url.c_str()); diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index 5e4ecd4..f4d41b1 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -139,6 +139,7 @@ private: void authPopupButtonClicked(PopupButtons button, std::shared_ptr popupData); void onActionTriggered(const Action& action); + void onMouseClick(); void setwvIMEStatus(bool status); sharedAction m_showBookmarkManagerUI; @@ -153,6 +154,11 @@ private: */ void filterURL(const std::string& url); + // // on uri entry widget "changed,user" signal + void onURLEntryEditedByUser(const std::shared_ptr editedUrlPtr); + // on uri entry widget "changed" signal + void onURLEntryEdited(); + /** * Checks if correct tab is visible to user, and if not, it update browser view * @param id of tab that should be visible to user diff --git a/services/WebPageUI/URIEntry.cpp b/services/WebPageUI/URIEntry.cpp index 39bdbb2..9200abb 100644 --- a/services/WebPageUI/URIEntry.cpp +++ b/services/WebPageUI/URIEntry.cpp @@ -80,11 +80,12 @@ Evas_Object* URIEntry::getContent() evas_object_smart_callback_add(m_entry, "activated", URIEntry::activated, this); evas_object_smart_callback_add(m_entry, "aborted", URIEntry::aborted, this); evas_object_smart_callback_add(m_entry, "preedit,changed", URIEntry::preeditChange, this); - evas_object_smart_callback_add(m_entry, "changed,user", URIEntry::changedUser, this); + evas_object_smart_callback_add(m_entry, "changed", URIEntry::_uri_entry_editing_changed, this); + evas_object_smart_callback_add(m_entry, "changed,user", URIEntry::_uri_entry_editing_changed_user, this); evas_object_smart_callback_add(m_entry, "focused", URIEntry::focused, this); evas_object_smart_callback_add(m_entry, "unfocused", URIEntry::unfocused, this); - evas_object_smart_callback_add(m_entry, "clicked", _uriEntryClicked, this); - evas_object_event_callback_priority_add(m_entry, EVAS_CALLBACK_KEY_DOWN, 2 * EVAS_CALLBACK_PRIORITY_BEFORE, URIEntry::fixed_entry_key_down_handler, this); + evas_object_smart_callback_add(m_entry, "clicked", _uri_entry_clicked, this); + evas_object_event_callback_priority_add(m_entry, EVAS_CALLBACK_KEY_DOWN, 2 * EVAS_CALLBACK_PRIORITY_BEFORE, URIEntry::_fixed_entry_key_down_handler, this); elm_object_part_content_set(m_entry_layout, "uri_entry_swallow", m_entry); @@ -94,7 +95,7 @@ Evas_Object* URIEntry::getContent() evas_object_smart_callback_add(m_entryBtn, "unfocused", URIEntry::unfocusedBtn, this); elm_object_style_set(m_entryBtn, "entry_btn"); - evas_object_smart_callback_add(m_entryBtn, "clicked", _uriEntryBtnClicked, this); + evas_object_smart_callback_add(m_entryBtn, "clicked", _uri_entry_btn_clicked, this); elm_object_part_content_set(m_entry_layout, "uri_entry_btn", m_entryBtn); } @@ -182,14 +183,13 @@ void URIEntry::selectWholeText() } } -void URIEntry::_uriEntryClicked(void* data, Evas_Object* /* obj */, void* /* event_info */) +void URIEntry::_uri_entry_clicked(void* data, Evas_Object* /* obj */, void* /* event_info */) { - BROWSER_LOGD("%s", __func__); URIEntry* self = static_cast(data); self->selectWholeText(); } -void URIEntry::_uriEntryBtnClicked(void* data, Evas_Object* /*obj*/, void* /*event_info*/) +void URIEntry::_uri_entry_btn_clicked(void* data, Evas_Object* /*obj*/, void* /*event_info*/) { URIEntry* self = static_cast(data); elm_object_focus_set(self->m_entry, EINA_TRUE); @@ -215,7 +215,7 @@ void URIEntry::preeditChange(void* /* data */, Evas_Object* /* obj */, void* /*e BROWSER_LOGD("%s", __func__); } -void URIEntry::changedUser(void* data, Evas_Object* /* obj */, void* /*event_info*/) +void URIEntry::_uri_entry_editing_changed_user(void* data, Evas_Object* /* obj */, void* /*event_info*/) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); URIEntry* self = reinterpret_cast(data); @@ -227,6 +227,13 @@ void URIEntry::changedUser(void* data, Evas_Object* /* obj */, void* /*event_inf } else {//if(entry.find(" ") != std::string::npos){ self->setSearchIcon(); } + self->uriEntryEditingChangedByUser(std::make_shared(entry)); +} + +void URIEntry::_uri_entry_editing_changed(void* data, Evas_Object* /* obj */, void* /* event_info */) +{ + URIEntry* self = static_cast(data); + self->uriEntryEditingChanged(); } void URIEntry::setUrlGuideText(const char* txt) const @@ -257,7 +264,7 @@ void URIEntry::focused(void* data, Evas_Object* /* obj */, void* /* event_info * BROWSER_LOGD("%s, URI: %s", __func__, self->m_URI.c_str()); } -void URIEntry::fixed_entry_key_down_handler(void* data, Evas* /*e*/, Evas_Object* /*obj*/, void* event_info) +void URIEntry::_fixed_entry_key_down_handler(void* data, Evas* /*e*/, Evas_Object* /*obj*/, void* event_info) { BROWSER_LOGD("%s", __func__); Evas_Event_Key_Down* ev = static_cast(event_info); @@ -284,8 +291,6 @@ void URIEntry::fixed_entry_key_down_handler(void* data, Evas* /*e*/, Evas_Object void URIEntry::editingCompleted() { - BROWSER_LOGD("%s", __func__); - char* text = elm_entry_markup_to_utf8(elm_entry_entry_get(m_entry)); std::string userString(text); free(text); diff --git a/services/WebPageUI/URIEntry.h b/services/WebPageUI/URIEntry.h index 20b1774..c23a0c4 100644 --- a/services/WebPageUI/URIEntry.h +++ b/services/WebPageUI/URIEntry.h @@ -45,6 +45,11 @@ public: void changeUri(const std::string&); boost::signals2::signal uriChanged; + // uri edition change + boost::signals2::signal uriEntryEditingChanged; + // uri edition change (by a user) + boost::signals2::signal)> uriEntryEditingChangedByUser; + void setFavIcon(std::shared_ptr favicon); void setCurrentFavIcon(); void setSearchIcon(); @@ -87,11 +92,8 @@ private: static void activated(void* data, Evas_Object* obj, void* event_info); static void aborted(void* data, Evas_Object* obj, void* event_info); static void preeditChange(void* data, Evas_Object* obj, void* event_info); - static void changedUser(void* data, Evas_Object* obj, void* event_info); static void focused(void* data, Evas_Object* obj, void* event_info); static void unfocused(void* data, Evas_Object* obj, void* event_info); - static void fixed_entry_key_down_handler(void* data, Evas* e, Evas_Object* obj, void* event_info); - static void _uriEntryBtnClicked(void* data, Evas_Object* obj, void* event_info); void editingCompleted(); void selectWholeText(); @@ -102,7 +104,11 @@ private: */ std::string rewriteURI(const std::string& url); - static void _uriEntryClicked(void* data, Evas_Object* obj, void* event_info); + static void _fixed_entry_key_down_handler(void* data, Evas* e, Evas_Object* obj, void* event_info); + static void _uri_entry_btn_clicked(void* data, Evas_Object* obj, void* event_info); + static void _uri_entry_clicked(void* data, Evas_Object* obj, void* event_info); + static void _uri_entry_editing_changed(void* data, Evas_Object* obj, void* event_info); + static void _uri_entry_editing_changed_user(void* data, Evas_Object* obj, void* event_info); static void focusedBtn(void* data, Evas_Object* obj, void* event_info); static void unfocusedBtn(void* data, Evas_Object* obj, void* event_info); -- 2.7.4 From 7403a038ac13de073bb2ea559e47f247ab6d57bb Mon Sep 17 00:00:00 2001 From: posial Date: Tue, 20 Oct 2015 15:28:08 +0200 Subject: [PATCH 06/16] Set-up unit test infrastructure [Issue] https://bugs.tizen.org/jira/browse/TT-166 [Problem] Outdated unit tests caused build errors [Solution] Update unit tests to current browser structure [Verification] Build browser unit tests Change-Id: I0d65b28b47c7b0e44153ffed6d143b2e5de2aeb0 --- unit_tests/CMakeLists.txt | 7 ++- unit_tests/ut_FavoriteService.cpp | 16 ++--- unit_tests/ut_PlatformInputManager.cpp | 24 ++++---- unit_tests/ut_StorageService.cpp | 104 +++++++++++++++++---------------- 4 files changed, 77 insertions(+), 74 deletions(-) diff --git a/unit_tests/CMakeLists.txt b/unit_tests/CMakeLists.txt index 7900886..2f95cd9 100644 --- a/unit_tests/CMakeLists.txt +++ b/unit_tests/CMakeLists.txt @@ -8,8 +8,9 @@ include(Coreheaders) include(EFLHelpers) include(EWebKitHelpers) include_directories( ${CMAKE_SOURCE_DIR}) -include_directories( ${CMAKE_SOURCE_DIR}/services/FavoriteService) include_directories( ${CMAKE_SOURCE_DIR}/services/SimpleUI) +include_directories( ${CMAKE_SOURCE_DIR}/services/BookmarkService) +include_directories( ${CMAKE_SOURCE_DIR}/services/HistoryService) include_directories( ${CMAKE_SOURCE_DIR}/services/WebPageUI) include_directories( ${CMAKE_SOURCE_DIR}/services/WebKitEngineService) include_directories( ${CMAKE_SOURCE_DIR}/services/StorageService) @@ -47,8 +48,8 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if(TIZEN_BUILD) TARGET_LINK_LIBRARIES(${PROJECT_NAME} - BookmarksUI - FavoriteService +# BookmarksUI + BookmarkService HistoryService PlatformInputManager SimpleUI diff --git a/unit_tests/ut_FavoriteService.cpp b/unit_tests/ut_FavoriteService.cpp index 4d70ece..fbaa74b 100644 --- a/unit_tests/ut_FavoriteService.cpp +++ b/unit_tests/ut_FavoriteService.cpp @@ -27,7 +27,7 @@ #include "ServiceManager.h" #include "BrowserLogger.h" -#include "FavoriteService.h" +#include "BookmarkService.h" #include "BookmarkItem.h" @@ -40,15 +40,15 @@ BOOST_AUTO_TEST_CASE(bookmark_add_remove) BROWSER_LOGI("BOOKMARKS_TEST_CASE START --> "); /// \todo: clean casts, depends on ServiceManager - std::shared_ptr fs = + std::shared_ptr fs = std::dynamic_pointer_cast < - tizen_browser::services::FavoriteService, + tizen_browser::services::BookmarkService, tizen_browser::core::AbstractService > (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.favoriteservice")); - fs->setStorageServiceTestMode(); +// fs->setStorageServiceTestMode(); int bookcount = -1; int bookcount2 = -1; @@ -73,9 +73,9 @@ BOOST_AUTO_TEST_CASE(bookmark_add_remove) BROWSER_LOGI("Above - current stored bookmarks after deleteAll, deleting resultflag: %d", resultflag); // Empty bookmark test - bookcount = fs->countBookmarksAndSubFolders(); + bookcount = fs->countBookmarks(); BOOST_CHECK(item_is_empty(fs->addToBookmarks("",""))); - bookcount2 = fs->countBookmarksAndSubFolders(); + bookcount2 = fs->countBookmarks(); BOOST_CHECK_EQUAL(bookcount, bookcount2); BROWSER_LOGI("Add empty bookmark test summary - number of bookmarks before: %d, after: %d", bookcount ,bookcount2); fs->getBookmarks(); @@ -108,10 +108,10 @@ BOOST_AUTO_TEST_CASE(bookmark_add_remove) BOOST_AUTO_TEST_CASE(bookmark_synchro) { /// \todo: clean casts, depends on ServiceManager - std::shared_ptr fs = + std::shared_ptr fs = std::dynamic_pointer_cast < - tizen_browser::services::FavoriteService, + tizen_browser::services::BookmarkService, tizen_browser::core::AbstractService > (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.favoriteservice")); diff --git a/unit_tests/ut_PlatformInputManager.cpp b/unit_tests/ut_PlatformInputManager.cpp index 04e4a60..520c96e 100644 --- a/unit_tests/ut_PlatformInputManager.cpp +++ b/unit_tests/ut_PlatformInputManager.cpp @@ -27,20 +27,20 @@ BOOST_AUTO_TEST_CASE(PointerModeSetting) { std::shared_ptr platformInputManager = std::dynamic_pointer_cast - + (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.platforminputmanager")); BOOST_REQUIRE(platformInputManager); - - BOOST_CHECK(platformInputManager->getPointerModeEnabled()); - - platformInputManager->setPointerModeEnabled(false); - - BOOST_CHECK(!(platformInputManager->getPointerModeEnabled())); - - platformInputManager->setPointerModeEnabled(true); - - BOOST_CHECK(platformInputManager->getPointerModeEnabled()); +// +// BOOST_CHECK(platformInputManager->getPointerModeEnabled()); +// +// platformInputManager->setPointerModeEnabled(false); +// +// BOOST_CHECK(!(platformInputManager->getPointerModeEnabled())); +// +// platformInputManager->setPointerModeEnabled(true); +// +// BOOST_CHECK(platformInputManager->getPointerModeEnabled()); } -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/unit_tests/ut_StorageService.cpp b/unit_tests/ut_StorageService.cpp index f253a73..29987f0 100644 --- a/unit_tests/ut_StorageService.cpp +++ b/unit_tests/ut_StorageService.cpp @@ -24,6 +24,7 @@ #include "BrowserLogger.h" #include "StorageService.h" #include "StorageException.h" +//#include "HistoryItem.h" #define CHANNEL_AUTH01 "Gall Anonim 1" #define CHANNEL_DESCR01 "Test channel - description 1" @@ -139,57 +140,58 @@ BOOST_AUTO_TEST_CASE(storage_bookmark) BROWSER_LOGI("<-- StorageService - bookmark - END"); } -BOOST_AUTO_TEST_CASE(storage_history) -{ - BROWSER_LOGI("StorageService - history - START --> "); - - std::shared_ptr storageManager = std::dynamic_pointer_cast < - tizen_browser::services::StorageService, - tizen_browser::core::AbstractService > ( - tizen_browser::core::ServiceManager::getInstance().getService( - DOMAIN_STORAGE_SERVICE)); - - storageManager->init(true); - - std::shared_ptr bi = std::make_shared(); - std::shared_ptr hi = std::make_shared("URL", "Title", bi); - storageManager->addHistoryItem(hi); - - std::shared_ptr hi2 = std::make_shared("URL2", "Title2", bi); - storageManager->addHistoryItem(hi2); - - auto countItems_2 = storageManager->getHistoryItems(100, 2); - auto countItems_1 = storageManager->getHistoryItems(100, 1); - BOOST_CHECK(countItems_2.size() == 2); - BOOST_CHECK(countItems_1.size() == 1); - storageManager->deleteHistory(hi2->getUrl()); - - auto hiauto = storageManager->getHistoryItem("URL"); - BOOST_CHECK(hiauto->getTitle() == "Title"); - - auto iHistCount = storageManager->getHistoryItemsCount(); - BROWSER_LOGD("iHistCount = %d", iHistCount); - BOOST_CHECK(iHistCount == 1); - - auto iVisitCounter = storageManager->getHistoryVisitCounter(hiauto->getUrl()); - BROWSER_LOGD("iVisitCounter = %d", iVisitCounter); - BOOST_CHECK(iVisitCounter == 1); - - hi->setTitle("New Title"); - storageManager->insertOrRefresh(hi); - auto newHistItem = storageManager->getHistoryItem("URL"); - BOOST_CHECK(hi->getTitle() == "New Title"); - auto iNewVisitCounter = storageManager->getHistoryVisitCounter(hi->getUrl()); - BROWSER_LOGD("iVisitCounter = %d", iNewVisitCounter); - BOOST_CHECK(iNewVisitCounter == 2); - - storageManager->deleteHistory(); - iHistCount = storageManager->getHistoryItemsCount(); - BROWSER_LOGD("iHistCount = %d", iHistCount); - BOOST_CHECK(iHistCount == 0); - - BROWSER_LOGI("<-- StorageService - history - END"); -} +// Should it be moved to ut_historyService ???? +//BOOST_AUTO_TEST_CASE(storage_history) +//{ +// BROWSER_LOGI("StorageService - history - START --> "); +// +// std::shared_ptr storageManager = std::dynamic_pointer_cast < +// tizen_browser::services::StorageService, +// tizen_browser::core::AbstractService > ( +// tizen_browser::core::ServiceManager::getInstance().getService( +// DOMAIN_STORAGE_SERVICE)); +// +// storageManager->init(true); +// +// std::shared_ptr bi = std::make_shared(); +// std::shared_ptr hi = std::make_shared("URL", "Title", bi); +// storageManager->addHistoryItem(hi); +// +// std::shared_ptr hi2 = std::make_shared("URL2", "Title2", bi); +// storageManager->addHistoryItem(hi2); +// +// auto countItems_2 = storageManager->getHistoryItems(100, 2); +// auto countItems_1 = storageManager->getHistoryItems(100, 1); +// BOOST_CHECK(countItems_2.size() == 2); +// BOOST_CHECK(countItems_1.size() == 1); +// storageManager->deleteHistory(hi2->getUrl()); +// +// auto hiauto = storageManager->getHistoryItem("URL"); +// BOOST_CHECK(hiauto->getTitle() == "Title"); +// +// auto iHistCount = storageManager->getHistoryItemsCount(); +// BROWSER_LOGD("iHistCount = %d", iHistCount); +// BOOST_CHECK(iHistCount == 1); +// +// auto iVisitCounter = storageManager->getHistoryVisitCounter(hiauto->getUrl()); +// BROWSER_LOGD("iVisitCounter = %d", iVisitCounter); +// BOOST_CHECK(iVisitCounter == 1); +// +// hi->setTitle("New Title"); +// storageManager->insertOrRefresh(hi); +// auto newHistItem = storageManager->getHistoryItem("URL"); +// BOOST_CHECK(hi->getTitle() == "New Title"); +// auto iNewVisitCounter = storageManager->getHistoryVisitCounter(hi->getUrl()); +// BROWSER_LOGD("iVisitCounter = %d", iNewVisitCounter); +// BOOST_CHECK(iNewVisitCounter == 2); +// +// storageManager->deleteHistory(); +// iHistCount = storageManager->getHistoryItemsCount(); +// BROWSER_LOGD("iHistCount = %d", iHistCount); +// BOOST_CHECK(iHistCount == 0); +// +// BROWSER_LOGI("<-- StorageService - history - END"); +//} BOOST_AUTO_TEST_SUITE_END() -- 2.7.4 From 5f802293f16374c9589a12764e343bd6ca1dd3d5 Mon Sep 17 00:00:00 2001 From: Janusz Majnert Date: Tue, 20 Oct 2015 15:34:45 +0200 Subject: [PATCH 07/16] Fix compiler warning in PlatformInputManager [Issue] N/A [Problem] Compilation warning about unused variable [Solution] Suppress the warning [Verification] Build the project and verify that there are no warnings from PlatformInputManager.cpp Change-Id: I0d8e9d669785cd220c28ea14d8e0d8d8f5c57d9f --- services/PlatformInputManager/PlatformInputManager.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/PlatformInputManager/PlatformInputManager.cpp b/services/PlatformInputManager/PlatformInputManager.cpp index 3d3d85c..4d6cd8f 100644 --- a/services/PlatformInputManager/PlatformInputManager.cpp +++ b/services/PlatformInputManager/PlatformInputManager.cpp @@ -46,6 +46,8 @@ PlatformInputManager::PlatformInputManager() void PlatformInputManager::init(Evas_Object* mainWindow) { M_ASSERT(mainWindow); + //Suppress compilation warning + (void) mainWindow; ecore_event_filter_add(NULL, __filter, NULL, this); } -- 2.7.4 From 22f08a4b98948f4e54476a2b333441d1fdb66d96 Mon Sep 17 00:00:00 2001 From: Janusz Majnert Date: Mon, 19 Oct 2015 12:20:18 +0200 Subject: [PATCH 08/16] Fixed compilation warnings in SqlStorage modules [Issue] N/A [Problem] Compilation warnings about: 1. Unused variable newName 2. Ignored type qualifier [Solution] 1. Suppress the warning temporarily, submit a bug to fix the method 2. Remove the redundant const qualifier [Verification] Build the project. Check if there are warnings generated from SqlStorage.* files Change-Id: I6a94a92faffa37047fd93498dfc207cc42be78bb --- services/SessionStorage/SqlStorage.cpp | 5 ++++- services/SessionStorage/SqlStorage.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/services/SessionStorage/SqlStorage.cpp b/services/SessionStorage/SqlStorage.cpp index 3de63cb..95e477f 100644 --- a/services/SessionStorage/SqlStorage.cpp +++ b/services/SessionStorage/SqlStorage.cpp @@ -101,7 +101,7 @@ bool SqlStorage::init() return false; } -SqlStorage* const SqlStorage::getInstance() +SqlStorage* SqlStorage::getInstance() { static SqlStorage instance; if( instance.init() ){ @@ -306,6 +306,9 @@ void SqlStorage::clearSession(const Session& session, void SqlStorage::updateSessionName(Session& session, std::string newName) { + //FIXME - newName not used! The sql query creation below should be fixed. + // submitted bug: https://bugs.tizen.org/jira/browse/TT-218 + (void)newName; if(session.isValid()){ boost::format updateSessionNameString("UPDATE %1% SET %2% = ? WHERE %3% = ?" ); updateSessionNameString % TABLE_SESSION % COL_SESSION_NAME % COL_SESSION_ID; diff --git a/services/SessionStorage/SqlStorage.h b/services/SessionStorage/SqlStorage.h index da5e220..cdef84c 100644 --- a/services/SessionStorage/SqlStorage.h +++ b/services/SessionStorage/SqlStorage.h @@ -51,7 +51,7 @@ class SqlStorage bool init(); public: ~SqlStorage(); - static SqlStorage* const getInstance(); + static SqlStorage* getInstance(); Session createSession(const std::string& name = ""); /** * Return newes session in storage. -- 2.7.4 From 53eb8d01a3f4d2dfff9aab6be443ac46e538babe Mon Sep 17 00:00:00 2001 From: Janusz Majnert Date: Mon, 19 Oct 2015 12:50:45 +0200 Subject: [PATCH 09/16] Fix compiler warning in FocusManager.cpp [Issue] N/A [Problem] Compilation warnings about unused variable [Solution] Remove unneeded variable [Verification] Build the project and verify that there are no warnings from FocusManager.cpp Change-Id: Iefda280361a6ff12dbe40179d1bfe67a39aab533 --- core/Tools/FocusManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Tools/FocusManager.cpp b/core/Tools/FocusManager.cpp index 90e5b3b..aed8ab9 100644 --- a/core/Tools/FocusManager.cpp +++ b/core/Tools/FocusManager.cpp @@ -43,7 +43,7 @@ void FocusManager::stopFocusManager() verticalFocusVector.clear(); ecore_event_handler_del(handlerDown); } -Eina_Bool FocusManager::_key_down_cb(void* data, int type, void* event) +Eina_Bool FocusManager::_key_down_cb(void* data, int, void* event) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); FocusManager* fm = static_cast(data); -- 2.7.4 From 822bee9e00525aee678276eaf321e550e93a5bbf Mon Sep 17 00:00:00 2001 From: Janusz Majnert Date: Mon, 19 Oct 2015 16:04:50 +0200 Subject: [PATCH 10/16] Fix an unused variable compilation warning in BookmarkManagerUI [Issue] N/A [Problem] Compilation warning about unused variable [Solution] Remove the unused variable declaration [Verification] Build the project and verify that there are no warnings from BookmarkManagerUI.cpp Change-Id: I1093b838cbe8afcea424abe404d96cb65cd95402 --- services/BookmarkManagerUI/BookmarkManagerUI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/BookmarkManagerUI/BookmarkManagerUI.cpp b/services/BookmarkManagerUI/BookmarkManagerUI.cpp index 3e0e58c..16b4978 100644 --- a/services/BookmarkManagerUI/BookmarkManagerUI.cpp +++ b/services/BookmarkManagerUI/BookmarkManagerUI.cpp @@ -282,7 +282,7 @@ Evas_Object * BookmarkManagerUI::_grid_bookmark_content_get(void *data, Evas_Obj return nullptr; } -void BookmarkManagerUI::_bookmarkItemClicked(void * data, Evas_Object *, void * event_info) +void BookmarkManagerUI::_bookmarkItemClicked(void * data, Evas_Object *, void *) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); if (data != nullptr) -- 2.7.4 From f5dffc86312f75da3772d6fc0edf8268cbe64194 Mon Sep 17 00:00:00 2001 From: Janusz Majnert Date: Mon, 19 Oct 2015 16:07:21 +0200 Subject: [PATCH 11/16] Fix for unused variable copilation warning in BookmarkService [Issue] N/A [Problem] Compilation warning about unused variable [Solution] Remove the unneeded variable [Verification] Build the project and verify that there are no warnings from BookmarkService.cpp Change-Id: Id663552f0be06ce1c009c51864e9f06e23a485a5 --- services/BookmarkService/BookmarkService.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/BookmarkService/BookmarkService.cpp b/services/BookmarkService/BookmarkService.cpp index 68d1586..15dce85 100644 --- a/services/BookmarkService/BookmarkService.cpp +++ b/services/BookmarkService/BookmarkService.cpp @@ -181,7 +181,7 @@ int BookmarkService::getBookmarkId(const std::string & url) int *ids = nullptr; int ids_count = 0; int i = 0; - int ret = bp_bookmark_adaptor_get_cond_ids_p(&ids, &ids_count, &properties, &conds, BP_BOOKMARK_O_URL, url.c_str(), 0); + bp_bookmark_adaptor_get_cond_ids_p(&ids, &ids_count, &properties, &conds, BP_BOOKMARK_O_URL, url.c_str(), 0); if (ids_count > 0){ i = *ids; } -- 2.7.4 From 03f0c2edb5be3952b22091fd1dca71e138d0ec71 Mon Sep 17 00:00:00 2001 From: Janusz Majnert Date: Tue, 20 Oct 2015 15:32:22 +0200 Subject: [PATCH 12/16] Fix compiler warning in MoreMenuUI [Issue] N/A [Problem] Compilation warning about unused variable [Solution] Use the defined variable [Verification] Build the project and verify that there are no warnings from MoreMenuUI.cpp Change-Id: I35891dd6c18e64bcd4b0003d4ac47fe25e641eb7 --- services/MoreMenuUI/MoreMenuUI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/MoreMenuUI/MoreMenuUI.cpp b/services/MoreMenuUI/MoreMenuUI.cpp index f623118..0376c03 100644 --- a/services/MoreMenuUI/MoreMenuUI.cpp +++ b/services/MoreMenuUI/MoreMenuUI.cpp @@ -344,7 +344,7 @@ void MoreMenuUI::clearItems() BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); for (auto it = m_map_menu_views.begin(); it != m_map_menu_views.end(); ++it) { Elm_Object_Item* bookmarkView = it->second; - Evas_Object *button = elm_object_item_part_content_get(it->second, "thumbbutton_item"); + Evas_Object *button = elm_object_item_part_content_get(bookmarkView, "thumbbutton_item"); evas_object_event_callback_del(button, EVAS_CALLBACK_MOUSE_IN, __cb_mouse_in); evas_object_event_callback_del(button, EVAS_CALLBACK_MOUSE_OUT, __cb_mouse_out); } -- 2.7.4 From e9e23a704e6c8d5f6bea567d10466f968dec9ed8 Mon Sep 17 00:00:00 2001 From: Maciej Skrzypkowski Date: Tue, 20 Oct 2015 10:56:32 +0200 Subject: [PATCH 13/16] Mobile profile build [Issue] https://bugs.tizen.org/jira/browse/TM-34 [Problem] There was no build for mobile profile. [Solution] Added new profile and build option [Verify] Run build_mobile.sh script, check if it works. Signed-off-by: Maciej Skrzypkowski Change-Id: Ic3057435427df0d8e4bc90e769b8e2ab78de1e46 --- CMakeLists.txt | 1 + build_mobile.sh | 2 ++ packaging/org.tizen.browser.spec | 1 + 3 files changed, 4 insertions(+) create mode 100755 build_mobile.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 312cc7e..1e94aba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,4 +144,5 @@ message(STATUS "Build for Tizen (TIZEN_BUILD) :" ${TIZEN_BUILD}) message(STATUS "Interal libs are dynamic (DYN_INT_LIBS) :" ${DYN_INT_LIBS}) message(STATUS "Building Unit tests (BUILD_UT) :" ${BUILD_UT}) message(STATUS "Code Coverage statistics (COVERAGE_STATS) :" ${COVERAGE_STATS}) +message(STATUS "Device profile (PROFILE) :" ${PROFILE}) message(STATUS "------------------------------------------") diff --git a/build_mobile.sh b/build_mobile.sh new file mode 100755 index 0000000..f9abe55 --- /dev/null +++ b/build_mobile.sh @@ -0,0 +1,2 @@ +#!/bin/bash +gbs -c .gbs.conf build -P profile.tzmo_v3.0_arm-wayland -A armv7l --include-all diff --git a/packaging/org.tizen.browser.spec b/packaging/org.tizen.browser.spec index 44c7454..7fd35cf 100644 --- a/packaging/org.tizen.browser.spec +++ b/packaging/org.tizen.browser.spec @@ -84,6 +84,7 @@ cmake .. \ -DICONDIR=%{_icondir} \ -DBUILD_UT=%{BUILD_UT} \ -DCOVERAGE_STATS=%{COVERAGE_STATS} \ + -DPROFILE=%{profile} \ %if "%{?_with_wayland}" == "1" -DWAYLAND_SUPPORT=On %else -- 2.7.4 From 598be1c935bea99eea9162bf4762059ce76bea93 Mon Sep 17 00:00:00 2001 From: Dariusz Frankiewicz Date: Tue, 13 Oct 2015 12:16:10 +0200 Subject: [PATCH 14/16] Add webview suspend and resume functions. [Issue] https://bugs.tizen.org/jira/browse/TT-208 [Problem] ewk_view_suspend and ewk_view_resume are not called in required moments. [Cause] Not implemented function calls. [Solution] Implement required functions and it's calls. [Verify] Open few tabs, try to switch between them. Suspend and resume browser. Change-Id: I9f292a0c316056e3d2c928332bd47a58e9eba23a Signed-off-by: Dariusz Frankiewicz --- core/AbstractWebEngine/AbstractWebEngine.h | 15 ++++++++++++++ core/BasicUI/AbstractMainWindow.h | 6 +++++- core/main.cpp | 18 ++++++++++++++++ services/SimpleUI/SimpleUI.cpp | 2 ++ services/SimpleUI/SimpleUI.h | 2 ++ .../WebKitEngineService/WebKitEngineService.cpp | 24 ++++++++++++++++++++++ services/WebKitEngineService/WebKitEngineService.h | 4 ++++ services/WebKitEngineService/WebView.cpp | 20 ++++++++++++++++++ services/WebKitEngineService/WebView.h | 5 +++++ 9 files changed, 95 insertions(+), 1 deletion(-) diff --git a/core/AbstractWebEngine/AbstractWebEngine.h b/core/AbstractWebEngine/AbstractWebEngine.h index 554c115..39c23c7 100644 --- a/core/AbstractWebEngine/AbstractWebEngine.h +++ b/core/AbstractWebEngine/AbstractWebEngine.h @@ -74,6 +74,21 @@ public: virtual std::string getTitle(void) const = 0; /** + * Suspend current webview. + */ + virtual void suspend(void) = 0; + + /** + * Resume current webview. + */ + virtual void resume(void) = 0; + + /** + * @return true if current webview is suspended, false otherwise + */ + virtual bool isSuspended(void) const = 0; + + /** * Stop loading current page. */ virtual void stopLoading(void) = 0; diff --git a/core/BasicUI/AbstractMainWindow.h b/core/BasicUI/AbstractMainWindow.h index 4c1a13a..146ad8f 100644 --- a/core/BasicUI/AbstractMainWindow.h +++ b/core/BasicUI/AbstractMainWindow.h @@ -47,7 +47,7 @@ public: : m_window() {} - virtual int exec(const std::string& url)=0; + virtual int exec(const std::string& url) = 0; std::shared_ptr getMainWindow(){return m_window;}; /** @@ -56,6 +56,10 @@ public: */ void setMainWindow(T *rawPtr){ m_window=std::shared_ptr(rawPtr);} virtual void destroyUI() { } + + virtual void suspend() = 0; + virtual void resume() = 0; + protected: std::shared_ptr m_window; }; diff --git a/core/main.cpp b/core/main.cpp index 83d48f0..30f5a94 100755 --- a/core/main.cpp +++ b/core/main.cpp @@ -120,10 +120,28 @@ static void app_service(service_h service, void */*app_data*/){ static void app_pause(void *){ BROWSER_LOGD("%s", __PRETTY_FUNCTION__); + + std::shared_ptr> mainUi = + std::dynamic_pointer_cast + < + tizen_browser::base_ui::AbstractMainWindow, + tizen_browser::core::AbstractService + > + (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.simpleui")); + mainUi->suspend(); } static void app_resume(void *){ BROWSER_LOGD("%s", __PRETTY_FUNCTION__); + + std::shared_ptr> mainUi = + std::dynamic_pointer_cast + < + tizen_browser::base_ui::AbstractMainWindow, + tizen_browser::core::AbstractService + > + (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.simpleui")); + mainUi->resume(); } int main(int argc, char* argv[])try diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 8697e7e..eb15d85 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -440,6 +440,8 @@ void SimpleUI::switchViewToWebPage() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); M_ASSERT(m_viewManager); + if(m_webEngine->isSuspended()) + m_webEngine->resume(); m_webPageUI->switchViewToWebPage(m_webEngine->getLayout(), m_webEngine->getURI(), m_webEngine->getTitle()); } diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index f4d41b1..5f59329 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -71,6 +71,8 @@ public: virtual ~SimpleUI(); virtual int exec(const std::string& url); virtual std::string getName(); + void suspend() {m_webEngine->suspend();} + void resume() {m_webEngine->resume();} void destroyUI(); private: diff --git a/services/WebKitEngineService/WebKitEngineService.cpp b/services/WebKitEngineService/WebKitEngineService.cpp index 11cd07a..0841342 100644 --- a/services/WebKitEngineService/WebKitEngineService.cpp +++ b/services/WebKitEngineService/WebKitEngineService.cpp @@ -143,6 +143,28 @@ std::string WebKitEngineService::getTitle() const return std::string(""); } +void WebKitEngineService::suspend() +{ + if(tabsCount()>0) { + M_ASSERT(m_currentWebView); + m_currentWebView->suspend(); + } +} + +void WebKitEngineService::resume() +{ + if(tabsCount()>0) { + M_ASSERT(m_currentWebView); + m_currentWebView->resume(); + } +} + +bool WebKitEngineService::isSuspended() const +{ + M_ASSERT(m_currentWebView); + return m_currentWebView->isSuspended(); +} + void WebKitEngineService::stopLoading(void) { M_ASSERT(m_currentWebView); @@ -323,6 +345,7 @@ bool WebKitEngineService::switchToTab(tizen_browser::basic_webengine::TabId newT // if there was any running WebView if (m_currentWebView) { disconnectSignals(m_currentWebView); + suspend(); } m_currentWebView = m_tabs[newTabId]; @@ -331,6 +354,7 @@ bool WebKitEngineService::switchToTab(tizen_browser::basic_webengine::TabId newT m_mostRecentTab.push_back(newTabId); connectSignals(m_currentWebView); + resume(); titleChanged(m_currentWebView->getTitle()); uriChanged(m_currentWebView->getURI()); diff --git a/services/WebKitEngineService/WebKitEngineService.h b/services/WebKitEngineService/WebKitEngineService.h index 00ec6c7..be37eac 100644 --- a/services/WebKitEngineService/WebKitEngineService.h +++ b/services/WebKitEngineService/WebKitEngineService.h @@ -53,6 +53,10 @@ public: std::string getTitle(void) const; + void suspend(void); + void resume(void); + bool isSuspended(void) const; + void stopLoading(void); void reload(void); diff --git a/services/WebKitEngineService/WebView.cpp b/services/WebKitEngineService/WebView.cpp index bb42ec7..cef552e 100644 --- a/services/WebKitEngineService/WebView.cpp +++ b/services/WebKitEngineService/WebView.cpp @@ -71,6 +71,7 @@ WebView::WebView(Evas_Object * obj, TabId tabId) , m_ewkView(nullptr) , m_isLoading(false) , m_loadError(false) + , m_suspended(false) , m_private(-1) { config.load("whatever"); @@ -117,6 +118,7 @@ void WebView::init(bool desktopMode, Evas_Object * opener) setupEwkSettings(); registerCallbacks(); + resume(); #else m_ewkView = evas_object_rectangle_add(evas_object_evas_get(m_parent)); #endif @@ -224,6 +226,24 @@ std::string WebView::getTitle(void) return m_title; } +void WebView::suspend() +{ + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + M_ASSERT(m_ewkView); + + ewk_view_suspend(m_ewkView); + m_suspended = true; +} + +void WebView::resume() +{ + BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + M_ASSERT(m_ewkView); + + ewk_view_resume(m_ewkView); + m_suspended = false; +} + void WebView::stopLoading(void) { #if defined(USE_EWEBKIT) diff --git a/services/WebKitEngineService/WebView.h b/services/WebKitEngineService/WebView.h index 61f6c68..2243c19 100644 --- a/services/WebKitEngineService/WebView.h +++ b/services/WebKitEngineService/WebView.h @@ -48,6 +48,10 @@ public: std::string getTitle(void); + void suspend(void); + void resume(void); + bool isSuspended(void) const { return m_suspended; } + void stopLoading(void); void reload(void); @@ -223,6 +227,7 @@ private: bool m_loadError; // true if desktop view is enabled, false if mobile bool m_desktopMode; + bool m_suspended; int m_private; config::DefaultConfig config; -- 2.7.4 From aff513564ea89bf8c3a665d328fd3a2bd6a7b027 Mon Sep 17 00:00:00 2001 From: Albert Malewski Date: Tue, 20 Oct 2015 14:06:28 +0200 Subject: [PATCH 15/16] Navigation in Screen Zoom [Issue] https://bugs.tizen.org/jira/browse/TT-213 [Problem] User cannot control screen zoom by D-Pad navigation. [Cause] Lack of implementation. [Solution] Refactored screen zoom. Added focus on slider. [Verify] Launch browser > Open web page > More Menu > Screen zoom Select zoom ratio by left/right arrows > Press OK (enter) to confirm. Change-Id: I4b8bed8bf9f00e76140d9ee020d8d9838e38cbcd --- services/SimpleUI/SimpleUI.cpp | 22 ++++- services/SimpleUI/SimpleUI.h | 1 + services/WebPageUI/WebPageUI.h | 1 + services/ZoomUI/ZoomUI.cpp | 188 +++++++++++++++++++++++++++++++++-------- services/ZoomUI/ZoomUI.h | 13 +++ services/ZoomUI/edc/ZoomUI.edc | 105 +++++++++++++++++------ 6 files changed, 261 insertions(+), 69 deletions(-) diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index eb15d85..1113a3c 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -241,16 +241,20 @@ void SimpleUI::connectUISignals() m_webPageUI->getURIEntry().uriEntryEditingChanged.connect(boost::bind(&SimpleUI::onURLEntryEdited, this)); m_webPageUI->backPage.connect(boost::bind(&SimpleUI::switchViewToWebPage, this)); m_webPageUI->backPage.connect(boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine::back, m_webEngine.get())); + m_webPageUI->backPage.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get())); m_webPageUI->reloadPage.connect(boost::bind(&SimpleUI::switchViewToWebPage, this)); m_webPageUI->showTabUI.connect(boost::bind(&SimpleUI::showTabUI, this)); m_webPageUI->showMoreMenu.connect(boost::bind(&SimpleUI::showMoreMenu, this)); m_webPageUI->forwardPage.connect(boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine::forward, m_webEngine.get())); + m_webPageUI->forwardPage.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get())); m_webPageUI->stopLoadingPage.connect(boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine::stopLoading, m_webEngine.get())); + m_webPageUI->stopLoadingPage.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get())); m_webPageUI->reloadPage.connect(boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine::reload, m_webEngine.get())); + m_webPageUI->reloadPage.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get())); m_webPageUI->showQuickAccess.connect(boost::bind(&SimpleUI::showQuickAccess, this)); m_webPageUI->hideQuickAccess.connect(boost::bind(&QuickAccess::hideUI, m_quickAccess)); m_webPageUI->bookmarkManagerClicked.connect(boost::bind(&SimpleUI::showBookmarkManagerUI, this)); - + m_webPageUI->showZoomNavigation.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get())); M_ASSERT(m_quickAccess.get()); m_quickAccess->getDetailPopup().openURLInNewTab.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1, _2)); @@ -263,6 +267,7 @@ void SimpleUI::connectUISignals() M_ASSERT(m_tabUI.get()); m_tabUI->closeTabUIClicked.connect(boost::bind(&SimpleUI::closeTabUI, this)); + m_tabUI->closeTabUIClicked.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get())); m_tabUI->newTabClicked.connect(boost::bind(&SimpleUI::newTabClicked, this)); m_tabUI->newTabClicked.connect(boost::bind(&SimpleUI::settingsPrivateModeSwitch, this, false)); m_tabUI->tabClicked.connect(boost::bind(&SimpleUI::tabClicked, this,_1)); @@ -274,6 +279,7 @@ void SimpleUI::connectUISignals() M_ASSERT(m_historyUI.get()); m_historyUI->clearHistoryClicked.connect(boost::bind(&SimpleUI::onClearHistoryClicked, this)); m_historyUI->closeHistoryUIClicked.connect(boost::bind(&SimpleUI::closeHistoryUI, this)); + m_historyUI->closeHistoryUIClicked.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get())); // desktop mode as default m_historyUI->historyItemClicked.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1, true)); @@ -288,6 +294,7 @@ void SimpleUI::connectUISignals() m_moreMenuUI->historyUIClicked.connect(boost::bind(&SimpleUI::showHistoryUI, this)); m_moreMenuUI->settingsClicked.connect(boost::bind(&SimpleUI::showSettingsUI, this)); m_moreMenuUI->closeMoreMenuClicked.connect(boost::bind(&SimpleUI::closeMoreMenu, this)); + m_moreMenuUI->closeMoreMenuClicked.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get())); 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::addToBookmarks, this, _1)); @@ -297,10 +304,12 @@ void SimpleUI::connectUISignals() M_ASSERT(m_bookmarkManagerUI.get()); m_bookmarkManagerUI->closeBookmarkManagerClicked.connect(boost::bind(&SimpleUI::closeBookmarkManagerUI, this)); + m_bookmarkManagerUI->closeBookmarkManagerClicked.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get())); m_bookmarkManagerUI->bookmarkItemClicked.connect(boost::bind(&SimpleUI::onBookmarkClicked, this, _1)); M_ASSERT(m_zoomUI.get()); m_zoomUI->setZoom.connect(boost::bind(&SimpleUI::setZoomFactor, this, _1)); + m_zoomUI->getZoom.connect(boost::bind(&SimpleUI::getZoomFactor, this)); m_zoomUI->scrollView.connect(boost::bind(&SimpleUI::scrollView, this, _1, _2)); } @@ -388,7 +397,6 @@ void SimpleUI::connectModelSignals() m_webEngine->uriChanged.connect(boost::bind(&URIEntry::changeUri, &m_webPageUI->getURIEntry(), _1)); m_webEngine->uriChanged.connect(boost::bind(&MoreMenuUI::setURL, m_moreMenuUI.get(), _1)); m_webEngine->uriOnTabChanged.connect(boost::bind(&SimpleUI::checkTabId,this,_1)); - m_webEngine->uriOnTabChanged.connect(boost::bind(&SimpleUI::closeZoomUI, this)); m_webEngine->webViewClicked.connect(boost::bind(&URIEntry::clearFocus, &m_webPageUI->getURIEntry())); m_webEngine->backwardEnableChanged.connect(boost::bind(&WebPageUI::setBackButtonEnabled, m_webPageUI.get(), _1)); m_webEngine->forwardEnableChanged.connect(boost::bind(&WebPageUI::setForwardButtonEnabled, m_webPageUI.get(), _1)); @@ -459,6 +467,7 @@ void SimpleUI::switchToTab(const tizen_browser::basic_webengine::TabId& tabId) } BROWSER_LOGD("[%s:%d] swiching to web_view ", __PRETTY_FUNCTION__, __LINE__); switchViewToWebPage(); + m_zoomUI->showNavigation(); } bool SimpleUI::isErrorPageActive() @@ -741,16 +750,21 @@ void SimpleUI::closeZoomUI() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); M_ASSERT(m_zoomUI); - m_webPageUI->showTabUI.disconnect(boost::bind(&SimpleUI::closeZoomUI, this)); - m_webPageUI->showMoreMenu.disconnect(boost::bind(&SimpleUI::closeZoomUI, this)); m_zoomUI->hideUI(); } void SimpleUI::setZoomFactor(int level) { + BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); m_webEngine->setZoomFactor(level); } +int SimpleUI::getZoomFactor() +{ + BROWSER_LOGD("[%s:%d] %d", __PRETTY_FUNCTION__, __LINE__, m_webEngine->getZoomFactor()); + return m_webEngine->getZoomFactor(); +} + void SimpleUI::scrollView(const int& dx, const int& dy) { m_webEngine->scrollView(dx, dy); diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index 5f59329..91d03fe 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -200,6 +200,7 @@ private: void showZoomUI(); void closeZoomUI(); void setZoomFactor(int level); + int getZoomFactor(); void scrollView(const int& dx, const int& dy); void showTabUI(); diff --git a/services/WebPageUI/WebPageUI.h b/services/WebPageUI/WebPageUI.h index 07a3672..34b3717 100644 --- a/services/WebPageUI/WebPageUI.h +++ b/services/WebPageUI/WebPageUI.h @@ -67,6 +67,7 @@ public: boost::signals2::signal hideQuickAccess; boost::signals2::signal showQuickAccess; boost::signals2::signal bookmarkManagerClicked; + boost::signals2::signal showZoomNavigation; static void faviconClicked(void* data, Evas_Object* obj, const char* emission, const char* source); diff --git a/services/ZoomUI/ZoomUI.cpp b/services/ZoomUI/ZoomUI.cpp index dcbe068..b5e9596 100644 --- a/services/ZoomUI/ZoomUI.cpp +++ b/services/ZoomUI/ZoomUI.cpp @@ -66,23 +66,41 @@ Evas_Object* ZoomUI::getContent() void ZoomUI::showUI() { evas_object_show(m_layout); - evas_object_show(m_nav_layout); + evas_object_show(m_zoom_menu); evas_object_show(m_zoom_slider); + m_keyDownHandler = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _key_down_cb, this); + m_keyUpHandler = ecore_event_handler_add(ECORE_EVENT_KEY_UP, _key_up_cb, this); + int zoomFactor = *(getZoom()); + elm_slider_value_set(m_zoom_slider, calculateSliderValue(zoomFactor)); } void ZoomUI::hideUI() { evas_object_hide(m_zoom_slider); evas_object_hide(m_nav_layout); + evas_object_hide(m_zoom_menu); evas_object_hide(m_layout); + ecore_event_handler_del(m_keyDownHandler); + ecore_event_handler_del(m_keyUpHandler); } void ZoomUI::show(Evas_Object* parent) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); init(parent); - createLayout(parent); + if (!m_layout) + createLayout(parent); showUI(); + elm_object_focus_set(m_zoom_slider, EINA_TRUE); +} + +void ZoomUI::showNavigation() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_nav_layout); + int zoomFactor = *(getZoom()); + if (zoomFactor > ZOOM_DEFAULT) + evas_object_show(m_nav_layout); } void ZoomUI::createLayout(Evas_Object *parent) @@ -93,25 +111,31 @@ void ZoomUI::createLayout(Evas_Object *parent) elm_layout_file_set(m_layout, m_edjFilePath.c_str(), "zoom-layout"); 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); - createZoomSlider(); createNavigationButtons(); } void ZoomUI::createZoomSlider() { - m_zoom_slider = elm_slider_add(m_layout); + m_zoom_menu = elm_layout_add(m_layout); + elm_layout_file_set(m_zoom_menu, m_edjFilePath.c_str(), "zoom-menu"); + evas_object_size_hint_weight_set(m_zoom_menu, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_zoom_menu, EVAS_HINT_FILL, EVAS_HINT_FILL); + + m_zoom_slider = elm_slider_add(m_zoom_menu); evas_object_size_hint_weight_set(m_zoom_slider, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(m_zoom_slider, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_smart_callback_add(m_zoom_slider, "changed", _zoom_slider_changed, this); elm_object_style_set(m_zoom_slider, "default"); elm_slider_horizontal_set(m_zoom_slider, EINA_TRUE); elm_slider_min_max_set(m_zoom_slider, 1, 6); - elm_slider_step_set(m_zoom_slider, 1); - elm_slider_value_set(m_zoom_slider, 3); - elm_slider_indicator_format_set(m_zoom_slider, "%1.0f"); + elm_slider_step_set(m_zoom_slider, 0.2); + int zoomFactor = *(getZoom()); + elm_slider_value_set(m_zoom_slider, calculateSliderValue(zoomFactor)); + elm_slider_indicator_show_set(m_zoom_slider, EINA_FALSE); - elm_object_part_content_set(m_layout, "slider_swallow", m_zoom_slider); + elm_object_part_content_set(m_zoom_menu, "slider_swallow", m_zoom_slider); + evas_object_event_callback_add(m_zoom_slider, EVAS_CALLBACK_KEY_DOWN, _zoom_value_confirmed, this); } void ZoomUI::createNavigationButtons() @@ -120,35 +144,34 @@ void ZoomUI::createNavigationButtons() elm_layout_file_set(m_nav_layout, m_edjFilePath.c_str(), "nav-layout"); evas_object_size_hint_weight_set(m_nav_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(m_nav_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_object_part_content_set(m_layout, "nav_buttons", m_nav_layout); - - Evas_Object* icon = elm_icon_add(m_nav_layout); - setImageFile(icon, LEFT, false); - evas_object_smart_callback_add(icon, "clicked", _left_button_clicked, this); - evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_IN, _cb_focus_in_left_button, this); - evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_OUT, _cb_focus_out_left_button, this); - elm_object_part_content_set(m_nav_layout, "left_button", icon); - - icon = elm_icon_add(m_nav_layout); - setImageFile(icon, RIGHT, false); - evas_object_smart_callback_add(icon, "clicked", _right_button_clicked, this); - evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_IN, _cb_focus_in_right_button, this); - evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_OUT, _cb_focus_out_right_button, this); - elm_object_part_content_set(m_nav_layout, "right_button", icon); - - icon = elm_icon_add(m_nav_layout); - setImageFile(icon, DOWN, false); - evas_object_smart_callback_add(icon, "clicked", _down_button_clicked, this); - evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_IN, _cb_focus_in_down_button, this); - evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_OUT, _cb_focus_out_down_button, this); - elm_object_part_content_set(m_nav_layout, "down_button", icon); - - icon = elm_icon_add(m_nav_layout); - setImageFile(icon, UP, false); - evas_object_smart_callback_add(icon, "clicked", _up_button_clicked, this); - evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_IN, _cb_focus_in_up_button, this); - evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_OUT, _cb_focus_out_up_button, this); - elm_object_part_content_set(m_nav_layout, "up_button", icon); + + m_leftArrow = elm_icon_add(m_nav_layout); + setImageFile(m_leftArrow, LEFT, false); + evas_object_smart_callback_add(m_leftArrow, "clicked", _left_button_clicked, this); + evas_object_event_callback_add(m_leftArrow, EVAS_CALLBACK_MOUSE_IN, _cb_focus_in_left_button, this); + evas_object_event_callback_add(m_leftArrow, EVAS_CALLBACK_MOUSE_OUT, _cb_focus_out_left_button, this); + elm_object_part_content_set(m_nav_layout, "left_button", m_leftArrow); + + m_rightArrow = elm_icon_add(m_nav_layout); + setImageFile(m_rightArrow, RIGHT, false); + evas_object_smart_callback_add(m_rightArrow, "clicked", _right_button_clicked, this); + evas_object_event_callback_add(m_rightArrow, EVAS_CALLBACK_MOUSE_IN, _cb_focus_in_right_button, this); + evas_object_event_callback_add(m_rightArrow, EVAS_CALLBACK_MOUSE_OUT, _cb_focus_out_right_button, this); + elm_object_part_content_set(m_nav_layout, "right_button", m_rightArrow); + + m_downArrow = elm_icon_add(m_nav_layout); + setImageFile(m_downArrow, DOWN, false); + evas_object_smart_callback_add(m_downArrow, "clicked", _down_button_clicked, this); + evas_object_event_callback_add(m_downArrow, EVAS_CALLBACK_MOUSE_IN, _cb_focus_in_down_button, this); + evas_object_event_callback_add(m_downArrow, EVAS_CALLBACK_MOUSE_OUT, _cb_focus_out_down_button, this); + elm_object_part_content_set(m_nav_layout, "down_button", m_downArrow); + + m_upArrow = elm_icon_add(m_nav_layout); + setImageFile(m_upArrow, UP, false); + evas_object_smart_callback_add(m_upArrow, "clicked", _up_button_clicked, this); + evas_object_event_callback_add(m_upArrow, EVAS_CALLBACK_MOUSE_IN, _cb_focus_in_up_button, this); + evas_object_event_callback_add(m_upArrow, EVAS_CALLBACK_MOUSE_OUT, _cb_focus_out_up_button, this); + elm_object_part_content_set(m_nav_layout, "up_button", m_upArrow); } void ZoomUI::clearItems() @@ -159,6 +182,7 @@ void ZoomUI::clearItems() void ZoomUI::setImageFile(Evas_Object* obj, int direction, bool focused) { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); switch (direction) { case LEFT: elm_image_file_set(obj, m_edjFilePath.c_str(), focused ? "ic_zoom_indicator_left_foc.png" : "ic_zoom_indicator_left_nor.png"); break; @@ -201,6 +225,79 @@ void ZoomUI::_zoom_slider_changed(void *data, Evas_Object *obj, void *event_info } } +void ZoomUI::_zoom_value_confirmed(void* data, Evas*, Evas_Object* obj, void* event_info) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + Evas_Event_Key_Down* ev = static_cast(event_info); + + if (!data || !ev || !ev->keyname) + return; + + ZoomUI* self = static_cast(data); + if (std::string(ev->keyname) == "Return") { + int val = (int)elm_slider_value_get(self->m_zoom_slider); + BROWSER_LOGD("[%s:%d] val: %d", __PRETTY_FUNCTION__, __LINE__, val); + if (val > 3) { + BROWSER_LOGD("[%s:%d] value is greater than 3", __PRETTY_FUNCTION__, __LINE__); + evas_object_show(self->m_nav_layout); + } else { + BROWSER_LOGD("[%s:%d] value is smaller or equal to 3", __PRETTY_FUNCTION__, __LINE__); + evas_object_hide(self->m_nav_layout); + } + evas_object_hide(self->m_zoom_menu); + } +} + +Eina_Bool ZoomUI::_key_down_cb(void* data, int type, void* event_info) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + Ecore_Event_Key* ev = static_cast(event_info); + + if (!data || !ev || !ev->keyname) + return EINA_FALSE; + + ZoomUI* self = static_cast(data); + if (std::string(ev->keyname) == "Left") { + _left_button_clicked(data, self->m_leftArrow, event_info); + _cb_focus_in_left_button(data, nullptr, self->m_leftArrow, event_info); + } else if (std::string(ev->keyname) == "Right") { + _right_button_clicked(data, self->m_rightArrow, event_info); + _cb_focus_in_right_button(data, nullptr, self->m_rightArrow, event_info); + } else if (std::string(ev->keyname) == "Up") { + _up_button_clicked(data, self->m_upArrow, event_info); + _cb_focus_in_up_button(data, nullptr, self->m_upArrow, event_info); + } else if (std::string(ev->keyname) == "Down") { + _down_button_clicked(data, self->m_downArrow, event_info); + _cb_focus_in_down_button(data, nullptr, self->m_downArrow, event_info); + } else + return EINA_FALSE; + + return EINA_TRUE; +} + +Eina_Bool ZoomUI::_key_up_cb(void* data, int type, void* event_info) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + Ecore_Event_Key* ev = static_cast(event_info); + + if (!data || !ev || !ev->keyname) + return EINA_FALSE; + + ZoomUI* self = static_cast(data); + if (std::string(ev->keyname) == "Left") { + _cb_focus_out_left_button(data, nullptr, self->m_leftArrow, event_info); + } else if (std::string(ev->keyname) == "Right") { + _cb_focus_out_right_button(data, nullptr, self->m_rightArrow, event_info); + } else if (std::string(ev->keyname) == "Up") { + _cb_focus_out_up_button(data, nullptr, self->m_upArrow, event_info); + } else if (std::string(ev->keyname) == "Down") { + _cb_focus_out_down_button(data, nullptr, self->m_downArrow, event_info); + } else + return EINA_FALSE; + + return EINA_TRUE; +} + void ZoomUI::_left_button_clicked(void * data, Evas_Object * obj, void * event_info) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -317,6 +414,23 @@ void ZoomUI::_cb_focus_out_down_button(void * data, Evas *, Evas_Object *obj, vo } } +int ZoomUI::calculateSliderValue(int zoom) +{ + BROWSER_LOGD("[%s:%d] zoom factor: %d", __PRETTY_FUNCTION__, __LINE__, zoom); + if (zoom >= ZOOM_300) + return 6; + else if (zoom >= ZOOM_200) + return 5; + else if (zoom >= ZOOM_150) + return 4; + else if (zoom >= ZOOM_100) + return 3; + else if (zoom >= ZOOM_75) + return 2; + else if (zoom < ZOOM_75) + return 1; +} + } } diff --git a/services/ZoomUI/ZoomUI.h b/services/ZoomUI/ZoomUI.h index e6206a8..a2966f2 100644 --- a/services/ZoomUI/ZoomUI.h +++ b/services/ZoomUI/ZoomUI.h @@ -44,16 +44,19 @@ public: std::string getName(); void show(Evas_Object* parent); + void showNavigation(); void clearItems(); boost::signals2::signal closeZoomUI; boost::signals2::signal setZoom; + boost::signals2::signal getZoom; boost::signals2::signal scrollView; private: void createLayout(Evas_Object* parent); void createZoomSlider(); void createNavigationButtons(); void setImageFile(Evas_Object* obj, int direction, bool focused); + int calculateSliderValue(int zoom); static void _zoom_slider_changed(void * data, Evas_Object * obj, void * event_info); static void _left_button_clicked(void * data, Evas_Object * obj, void * event_info); @@ -69,12 +72,22 @@ private: static void _cb_focus_out_up_button(void * data, Evas *, Evas_Object *obj, void *); static void _cb_focus_in_down_button(void * data, Evas *, Evas_Object *obj, void *); static void _cb_focus_out_down_button(void * data, Evas *, Evas_Object *obj, void *); + static Eina_Bool _key_down_cb(void* data, int type, void* event_info); + static Eina_Bool _key_up_cb(void* data, int type, void* event_info); + static void _zoom_value_confirmed(void* data, Evas* e, Evas_Object* obj, void* event_info); std::string m_edjFilePath; Evas_Object* m_layout; Evas_Object* m_zoom_slider; + Evas_Object* m_zoom_menu; Evas_Object* m_nav_layout; Evas_Object* m_parent; + Evas_Object* m_leftArrow; + Evas_Object* m_rightArrow; + Evas_Object* m_upArrow; + Evas_Object* m_downArrow; + Ecore_Event_Handler* m_keyDownHandler; + Ecore_Event_Handler* m_keyUpHandler; int m_current_translation_x; int m_current_translation_y; diff --git a/services/ZoomUI/edc/ZoomUI.edc b/services/ZoomUI/edc/ZoomUI.edc index e3da119..07edd64 100644 --- a/services/ZoomUI/edc/ZoomUI.edc +++ b/services/ZoomUI/edc/ZoomUI.edc @@ -31,7 +31,6 @@ RESOURCE_IMAGE_LOSSY("ic_zoom_indicator_up_nor.png"); group { name: "zoom-layout"; - data.item: "contents" "close_button"; parts { @@ -39,7 +38,61 @@ RESOURCE_IMAGE_LOSSY("ic_zoom_indicator_up_nor.png"); type: RECT; mouse_events: 1; description { state: "default" 0.0; - color: 0 0 0 50; + color: 0 0 0 0; + visible: 0; + min: WIDTH HEIGHT; + max: WIDTH HEIGHT; + align: 0.0 0.0; + rel1 {relative: 0.0 0.0; offset: 0 104;} + rel2 {relative: 1.0 1.0;} + } + } + + part { + name: "zoom_menu"; + type : SWALLOW; + scale: 1; + description { + state: "default" 0.0; + visible: 1; + min: 700 300; + max: 700 300; + align: 0.0 0.0; + fixed: 1 1; + rel1 { relative: 0.0 0.0; to: "bg"; } + rel2 { relative: 1.0 1.0; to: "bg"; } + } + } + + part { + name: "nav_buttons"; + type : SWALLOW; + scale: 1; + description { + state: "default" 0.0; + visible: 1; + min: WIDTH HEIGHT; + max: WIDTH HEIGHT; + align: 0.0 0.0; + fixed: 0 0; + rel1 { relative: 0.0 0.0; to: "bg"; } + rel2 { relative: 1.0 1.0; to: "bg"; } + } + } + + } + } + + group { + name: "zoom-menu"; + + parts { + + part { name: "bg"; + type: RECT; + mouse_events: 1; + description { state: "default" 0.0; + color: 0 0 0 0; visible: 1; min: WIDTH HEIGHT; max: WIDTH HEIGHT; @@ -171,24 +224,6 @@ RESOURCE_IMAGE_LOSSY("ic_zoom_indicator_up_nor.png"); } } } - - - part { - name: "nav_buttons"; - type : SWALLOW; - scale: 1; - description { - state: "default" 0.0; - visible: 1; - min: WIDTH HEIGHT; - max: WIDTH HEIGHT; - align: 0.0 0.0; - fixed: 0 0; - rel1 { relative: 0.0 0.0; to: "bg"; } - rel2 { relative: 1.0 1.0; to: "bg"; } - } - } - } } @@ -198,6 +233,20 @@ RESOURCE_IMAGE_LOSSY("ic_zoom_indicator_up_nor.png"); max: WIDTH HEIGHT; data.item: "contents" "left_button right_button up_button down_button"; parts { + + part { name: "bg"; + type: RECT; + mouse_events: 1; + description { state: "default" 0.0; + visible: 0; + min: WIDTH HEIGHT; + max: WIDTH HEIGHT; + align: 0.0 0.0; + rel1 {relative: 0.0 0.0; offset: 0 104;} + rel2 {relative: 1.0 1.0;} + } + } + part { name: "left_button"; type: SWALLOW; @@ -210,8 +259,8 @@ RESOURCE_IMAGE_LOSSY("ic_zoom_indicator_up_nor.png"); fixed: 1 1; min: 90 90; max: 90 90; - rel1 { relative: 0.0 0.0; offset: 38 0;} - rel2 { relative: 1.0 1.0;} + rel1 {to: "bg"; relative: 0.0 0.0; offset: 38 0;} + rel2 {to: "bg"; relative: 1.0 1.0;} } } part { @@ -226,8 +275,8 @@ RESOURCE_IMAGE_LOSSY("ic_zoom_indicator_up_nor.png"); fixed: 1 1; min: 90 90; max: 90 90; - rel1 { relative: 0.0 0.0; } - rel2 { relative: 1.0 1.0; offset: -38 0; } + rel1 {to: "bg"; relative: 0.0 0.0; } + rel2 {to: "bg"; relative: 1.0 1.0; offset: -38 0; } } } part { @@ -242,8 +291,8 @@ RESOURCE_IMAGE_LOSSY("ic_zoom_indicator_up_nor.png"); fixed: 1 1; min: 90 90; max: 90 90; - rel1 { relative: 0.0 0.0; offset: 0 38; } - rel2 { relative: 1.0 1.0; } + rel1 {to: "bg"; relative: 0.0 0.0; offset: 0 38; } + rel2 {to: "bg"; relative: 1.0 1.0; } } } part { @@ -258,8 +307,8 @@ RESOURCE_IMAGE_LOSSY("ic_zoom_indicator_up_nor.png"); fixed: 1 1; min: 90 90; max: 90 90; - rel1 { relative: 0.0 0.0; } - rel2 { relative: 1.0 1.0; offset: 0 -38; } + rel1 {to: "bg"; relative: 0.0 0.0; } + rel2 {to: "bg"; relative: 1.0 1.0; offset: 0 -38; } } } } -- 2.7.4 From 6b9af567fd14941172b26fa6317622173e2cde90 Mon Sep 17 00:00:00 2001 From: "m.kawonczyk" Date: Tue, 20 Oct 2015 14:57:09 +0200 Subject: [PATCH 16/16] Close Tabs button in Tab Manager [Issue] https://bugs.tizen.org/jira/browse/TT-219 [Problem] "Close Tabs" button in Tab Manager does not return to "Close Tabs" from "Close all" [Solution] Found that signals created in TabUI arent called, while signals from SimpleUI are. Copied code that is responsible for text change to right location. [Verification] Open tabs manager. Click "Close Tabs" button. Either close a tab, click "Close All" or exit from Tab Manager. Reopen Tab Manager. Change-Id: Iba4ab9aa916cf39a6d3e919a7215c5c265e597aa --- services/TabUI/TabUI.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/TabUI/TabUI.cpp b/services/TabUI/TabUI.cpp index 401c6d8..c258959 100644 --- a/services/TabUI/TabUI.cpp +++ b/services/TabUI/TabUI.cpp @@ -246,6 +246,7 @@ void TabUI::_newtab_clicked(void * data, Evas_Object*, void*) } } + void TabUI::_openedtabs_clicked(void* data, Evas_Object*, void*) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -295,6 +296,7 @@ void TabUI::_closetabs_clicked(void* data, Evas_Object*, void*) 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 if (tabUI->editMode && !tabUI->onOtherDevicesSwitch) { + tabUI->editMode = false; tabUI->closeAllTabs(); elm_gengrid_realized_items_update(tabUI->m_gengrid); } @@ -319,6 +321,8 @@ void TabUI::addTabItem(std::shared_ptr>items) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); + elm_layout_text_set(elm_layout_content_get(m_tab_layout, "action_bar"), "closetabs_text", "Close Tabs"); + editMode = false; for (auto it = items.begin(); it < items.end(); it++) { addTabItem(*it); } -- 2.7.4