TizenRefApp-6535 Missed Calls Badge Displayed after Opening Logs 18/76618/2
authorEugene Kurzberg <i.kurtsberg@samsung.com>
Fri, 24 Jun 2016 11:57:37 +0000 (14:57 +0300)
committerEugene Kurzberg <i.kurtsberg@samsung.com>
Fri, 24 Jun 2016 11:57:37 +0000 (14:57 +0300)
Change-Id: Id668050acdb32899a437136bfc72389ea3935321
Signed-off-by: Eugene Kurzberg <i.kurtsberg@samsung.com>
contacts-app/tizen-manifest.xml
contacts-app/tizen-manifest.xml.in
lib-logs/inc/Logs/List/LogsView.h
lib-logs/inc/Logs/Model/LogProvider.h
lib-logs/src/Logs/List/LogsView.cpp
lib-logs/src/Logs/Model/LogProvider.cpp

index 4201732..bf49a19 100644 (file)
@@ -56,6 +56,7 @@
         <icon>org.tizen.contacts.png</icon>
     </ui-application>
     <ui-application appid="org.tizen.phone" exec="contacts-app" hw-acceleration="on" multiple="false" nodisplay="false" process-pool="true" taskmanage="true" type="capp">
+        <metadata key="http://tizen.org/metadata/effective-appid" value="org.tizen.contacts"/>
         <label>Phone</label>
         <label xml:lang="ar-ae">الهاتف</label>
         <label xml:lang="az-az">Telefon</label>
index be9380c..008f7ed 100644 (file)
@@ -56,6 +56,7 @@
                <icon>org.tizen.contacts.png</icon>
        </ui-application>
        <ui-application appid="org.tizen.phone" exec="contacts-app" hw-acceleration="on" multiple="false" nodisplay="false" process-pool="true" taskmanage="true" type="capp">
+               <metadata key="http://tizen.org/metadata/effective-appid" value="org.tizen.contacts"/>
                <label>Phone</label>
                <label xml:lang="ar-ae">الهاتف</label>
                <label xml:lang="az-az">Telefon</label>
index 6fe41a8..c95b832 100644 (file)
@@ -62,9 +62,11 @@ namespace Logs
                private:
                        virtual Evas_Object *onCreate(Evas_Object *parent) override;
                        virtual void onCreated() override;
+                       virtual void onNavigation(bool isCurrentView) override;
                        virtual void onMenuPressed() override;
                        virtual void onSelectAllInsert(Ui::GenlistItem *item) override;
 
+                       void resetMissedCalls();
                        void fillLayout();
                        void updateLayout(bool isEmpty);
                        Evas_Object *createNoContentsLayout(Evas_Object *parent);
index aeda679..2f07886 100644 (file)
@@ -111,6 +111,11 @@ namespace Logs
                        void unsetInsertCallback();
 
                        /**
+                        * @brief Mark all unseen missed calls as seen in database.
+                        */
+                       static void resetMissedCalls();
+
+                       /**
                         * @brief Compare dates
                         * @param[in]    firstDate        First date
                         * @param[in]    secondDate       Second date
index 1519b8e..9017f3f 100644 (file)
 #include "Utils/Logger.h"
 #include "Utils/Callback.h"
 
+#include <badge.h>
+#include <notification.h>
+
+#define PHONE_APPID "org.tizen.phone"
+
 using namespace Ux;
 using namespace Logs::Model;
 using namespace Logs::List;
@@ -67,6 +72,13 @@ void LogsView::onCreated()
        fillLayout();
 }
 
+void LogsView::onNavigation(bool isCurrentView)
+{
+       if (isCurrentView) {
+               resetMissedCalls();
+       }
+}
+
 void LogsView::onMenuPressed()
 {
        if (getSelectMode() != SelectNone) {
@@ -116,6 +128,18 @@ void LogsView::onSelectAllInsert(Ui::GenlistItem *item)
        m_Genlist->insert(item, nullptr, nullptr, Ui::Genlist::After);
 }
 
+void LogsView::resetMissedCalls()
+{
+       unsigned count = 0;
+       badge_get_count(PHONE_APPID, &count);
+
+       if (count > 0) {
+               badge_set_count(PHONE_APPID, 0);
+               notification_delete_all(NOTIFICATION_TYPE_NOTI);
+               LogProvider::resetMissedCalls();
+       }
+}
+
 void LogsView::fillLayout()
 {
        if (m_Genlist) {
index 148934f..7e3f5ec 100644 (file)
@@ -81,6 +81,30 @@ void LogProvider::unsetInsertCallback()
        m_InsertCallback = nullptr;
 }
 
+void LogProvider::resetMissedCalls()
+{
+       contacts_filter_h filter = nullptr;
+       contacts_filter_create(_contacts_phone_log._uri, &filter);
+       contacts_filter_add_int(filter, _contacts_phone_log.log_type,
+                       CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMING_UNSEEN);
+
+       contacts_query_h query = nullptr;
+       contacts_query_create(_contacts_phone_log._uri, &query);
+       contacts_query_set_filter(query, filter);
+
+       contacts_list_h list = nullptr;
+       contacts_db_get_records_with_query(query, 0, 0, &list);
+       for (auto &&record : makeRange(list)) {
+               contacts_record_set_int(record, _contacts_phone_log.log_type,
+                               CONTACTS_PLOG_TYPE_VOICE_INCOMING_SEEN);
+       }
+
+       contacts_db_update_records(list);
+       contacts_list_destroy(list, true);
+       contacts_query_destroy(query);
+       contacts_filter_destroy(filter);
+}
+
 bool LogProvider::compareDate(const tm &firstDate, const tm &secondDate)
 {
        if (firstDate.tm_year == secondDate.tm_year &&