Implement showing PWA popup when site is visited over 3 times. 69/93969/28 newux_tizen
authorLim DoHyung <delight.lim@samsung.com>
Wed, 26 Oct 2016 10:55:57 +0000 (19:55 +0900)
committerHye Kyoung Hwang <cookie@samsung.com>
Mon, 31 Oct 2016 01:08:09 +0000 (18:08 -0700)
[Issue]    N/A
[Problem]  For popup could show condition that connecting over 3 count.
           manifest have not site case, next patch I will update.
[Solution] I have extract frequency value in history DB,
           and when value over 3 count, I could show popup.
[Verify]   When 3 count connect, popup show and normal create shortcut.

Change-Id: I21ab0e32144207fe93c1a35d6dc2381d903c97a0
Signed-off-by: Lim DoHyung <delight.lim@samsung.com>
CMakeLists.txt
services/HistoryService/HistoryService.cpp
services/HistoryService/HistoryService.h
services/SimpleUI/SimpleUI.cpp
services/SimpleUI/SimpleUI.h
services/WebPageUI/WebPageUI.cpp
services/WebPageUI/WebPageUI.h

index 5537c0d502705b11f9325059165e53983cc419eb..b9b21475be16e95aec5607509860bfd3121d22cf 100755 (executable)
@@ -120,7 +120,7 @@ if(TIZEN_BUILD)
 
     if (${PROFILE} MATCHES "mobile")
         ADD_DEFINITIONS(-DPROFILE_MOBILE=1)
-        ADD_DEFINITIONS(-DPWA=1)
+        ADD_DEFINITIONS(-DPWA=0)
         ADD_DEFINITIONS(-DDUMMY_BUTTON=1)
     endif (${PROFILE} MATCHES "mobile")
 
index f33113f1d06cbe76645892cb10bd1bacffec0b1d..19a348334c2be41c90eee9c5742129e75f7277fb 100755 (executable)
@@ -151,6 +151,18 @@ std::shared_ptr<HistoryItemVector> HistoryService::getHistoryOlder()
     return getHistoryItems(BP_HISTORY_DATE_OLDER);
 }
 
+#if PWA
+int HistoryService::getHistoryCnt(const int& id)
+{
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+    int freq, retVal = 0;
+
+    if (!bp_history_adaptor_get_frequency(id, &freq))
+        retVal = freq;
+    return retVal;
+}
+#endif
+
 std::shared_ptr<HistoryItemVector> HistoryService::getMostVisitedHistoryItems()
 {
     std::shared_ptr<HistoryItemVector> ret_history_list(new HistoryItemVector);
index 4fb491aa67dfe851353f5b8f348725330474153e..59c711cccd72a69e79e7ef9ab91592bbaf399c58 100644 (file)
@@ -65,6 +65,9 @@ public:
     void cleanMostVisitedHistoryItems();
     std::shared_ptr<HistoryItemVector> getHistoryItemsByKeyword(const std::string & keyword, int maxItems);
     std::shared_ptr<HistoryItemVector> getHistoryItemsByURL(const std::string & url, int maxItems);
+#if PWA
+    int getHistoryCnt(const int& id);
+#endif
 
     /**
      * @brief Searches for history items matching given pattern.
index 08e460a9ddeeb9576ce28240529c1cfbd5703dac..c8ffe31b9dc5511e1a948d8d52d59419b2dc3a47 100755 (executable)
@@ -284,6 +284,23 @@ int SimpleUI::exec(const std::string& _url, const std::string& _caller, const st
     return 0;
 }
 
+#if PWA
+void SimpleUI::countCheckUrl()
+{
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+    int id, ret = 0;
+    id = m_historyService->getHistoryId(m_webEngine->getURI());
+
+    if (id)
+        ret = m_historyService->getHistoryCnt(id);
+
+    if (ret == CONNECT_COUNT)
+        pwaPopupRequest();
+    else
+        BROWSER_LOGD("[%s:%d] url count : %d", __PRETTY_FUNCTION__, __LINE__, ret);
+}
+#endif
+
 void SimpleUI::faviconChanged(tools::BrowserImagePtr favicon)
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
@@ -455,10 +472,10 @@ void SimpleUI::connectWebPageSignals()
     m_webPageUI->addToQuickAccess.connect(boost::bind(&SimpleUI::addQuickAccessItem, this, _1, _2));
     m_webPageUI->getTitle.connect(boost::bind(&basic_webengine::AbstractWebEngine::getTitle, m_webEngine.get()));
     m_webPageUI->getEngineState.connect(boost::bind(&basic_webengine::AbstractWebEngine::getState, m_webEngine.get()));
-    // WPA
     m_webPageUI->requestCurrentPageForWebPageUI.connect(boost::bind(&SimpleUI::requestSettingsCurrentPage, this));
 #if PWA
     m_webPageUI->pwaRequestManifest.connect(boost::bind(&basic_webengine::AbstractWebEngine::requestManifest, m_webEngine.get()));
+    m_webPageUI->getCountCheckSignal.connect(boost::bind(&SimpleUI::countCheckUrl, this));
 #endif
     m_webPageUI->isMostVisited.connect(boost::bind(&QuickAccess::isMostVisitedActive, m_quickAccess.get()));
 }
@@ -1576,6 +1593,38 @@ int SimpleUI::tabsCount()
     return m_webEngine->tabsCount();
 }
 
+#if PWA
+void SimpleUI::pwaPopupRequest()
+{
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+    TextPopup* popup = TextPopup::createPopup(m_viewManager.getContent());
+    popup->addButton(OK);
+    popup->addButton(CANCEL);
+    popup->buttonClicked.connect(boost::bind(&SimpleUI::pwaPopupButtonClicked, this, _1));
+    popup->setTitle(m_webEngine->getTitle());
+    popup->setMessage(_("IDS_BR_OPT_ADD_TO_HOME_SCREEN_ABB"));
+    popup->popupShown.connect(boost::bind(&SimpleUI::showPopup, this, _1));
+    popup->popupDismissed.connect(boost::bind(&SimpleUI::dismissPopup, this, _1));
+    popup->show();
+}
+
+void SimpleUI::pwaPopupButtonClicked(const PopupButtons& button)
+{
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+    switch (button) {
+        case OK:
+            BROWSER_LOGD("[%s:%d] pwaPopup create !", __PRETTY_FUNCTION__, __LINE__);
+            m_webEngine->requestManifest();
+            break;
+        case CANCEL:
+            BROWSER_LOGD("[%s:%d] pwaPopup deny !", __PRETTY_FUNCTION__, __LINE__);
+            break;
+        default:
+            BROWSER_LOGW("[%s:%d] Unknown button type!", __PRETTY_FUNCTION__, __LINE__);
+    }
+}
+#endif
+
 void SimpleUI::handleConfirmationRequest(basic_webengine::WebConfirmationPtr webConfirmation)
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
index d98e8860cbe231310328d8b128f17aed2353ae52..c05684f49842c6100dfc6342bb9fdd9c043d6bba 100644 (file)
@@ -71,6 +71,8 @@
 #include <functional>
 #include <future>
 
+#define CONNECT_COUNT 2
+
 namespace tizen_browser{
 namespace base_ui{
 
@@ -105,6 +107,7 @@ private:
     void prepareServices();
 #if PWA
     std::string preparePWA(const std::string& url);
+    void countCheckUrl();
 #endif
     void loadUIServices();
     void connectUISignals();
@@ -206,6 +209,10 @@ private:
     void onMenuButtonPressed();
     void handleConfirmationRequest(basic_webengine::WebConfirmationPtr webConfirmation);
     void setwvIMEStatus(bool status);
+#if PWA
+    void pwaPopupRequest();
+    void pwaPopupButtonClicked(const PopupButtons& button);
+#endif
 
     sharedAction m_showBookmarkManagerUI;
 
index d8cc45a2defdec576713ffdb11b28da88350baca..fdc44858446d5931191d801b1cda231b98b07f5e 100755 (executable)
@@ -213,6 +213,10 @@ void WebPageUI::loadFinished()
 #if DUMMY_BUTTON
     elm_object_focus_set(m_dummy_button, EINA_TRUE);
 #endif
+
+#if PWA
+    getCountCheckSignal();
+#endif
 }
 
 void WebPageUI::setMainContent(Evas_Object* content)
index 103850ea109de1e8f48687cabbec962ec28039a0..cd8389db4e62e96f443c35e9b73904ad1646a937 100755 (executable)
@@ -172,6 +172,7 @@ public:
     boost::signals2::signal<basic_webengine::State ()> getEngineState;
 #if PWA
     boost::signals2::signal<void ()> pwaRequestManifest;
+    boost::signals2::signal<void ()> getCountCheckSignal;
 #endif
 
 private: