From f35f002bd6433ab9ba841886b3b52814fdc38de9 Mon Sep 17 00:00:00 2001 From: Eugene Kurzberg Date: Fri, 24 Jun 2016 14:57:37 +0300 Subject: [PATCH] TizenRefApp-6535 Missed Calls Badge Displayed after Opening Logs Change-Id: Id668050acdb32899a437136bfc72389ea3935321 Signed-off-by: Eugene Kurzberg --- contacts-app/tizen-manifest.xml | 1 + contacts-app/tizen-manifest.xml.in | 1 + lib-logs/inc/Logs/List/LogsView.h | 2 ++ lib-logs/inc/Logs/Model/LogProvider.h | 5 +++++ lib-logs/src/Logs/List/LogsView.cpp | 24 ++++++++++++++++++++++++ lib-logs/src/Logs/Model/LogProvider.cpp | 24 ++++++++++++++++++++++++ 6 files changed, 57 insertions(+) diff --git a/contacts-app/tizen-manifest.xml b/contacts-app/tizen-manifest.xml index 4201732..bf49a19 100644 --- a/contacts-app/tizen-manifest.xml +++ b/contacts-app/tizen-manifest.xml @@ -56,6 +56,7 @@ org.tizen.contacts.png + diff --git a/contacts-app/tizen-manifest.xml.in b/contacts-app/tizen-manifest.xml.in index be9380c..008f7ed 100644 --- a/contacts-app/tizen-manifest.xml.in +++ b/contacts-app/tizen-manifest.xml.in @@ -56,6 +56,7 @@ org.tizen.contacts.png + diff --git a/lib-logs/inc/Logs/List/LogsView.h b/lib-logs/inc/Logs/List/LogsView.h index 6fe41a8..c95b832 100644 --- a/lib-logs/inc/Logs/List/LogsView.h +++ b/lib-logs/inc/Logs/List/LogsView.h @@ -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); diff --git a/lib-logs/inc/Logs/Model/LogProvider.h b/lib-logs/inc/Logs/Model/LogProvider.h index aeda679..2f07886 100644 --- a/lib-logs/inc/Logs/Model/LogProvider.h +++ b/lib-logs/inc/Logs/Model/LogProvider.h @@ -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 diff --git a/lib-logs/src/Logs/List/LogsView.cpp b/lib-logs/src/Logs/List/LogsView.cpp index 1519b8e..9017f3f 100644 --- a/lib-logs/src/Logs/List/LogsView.cpp +++ b/lib-logs/src/Logs/List/LogsView.cpp @@ -28,6 +28,11 @@ #include "Utils/Logger.h" #include "Utils/Callback.h" +#include +#include + +#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) { diff --git a/lib-logs/src/Logs/Model/LogProvider.cpp b/lib-logs/src/Logs/Model/LogProvider.cpp index 148934f..7e3f5ec 100644 --- a/lib-logs/src/Logs/Model/LogProvider.cpp +++ b/lib-logs/src/Logs/Model/LogProvider.cpp @@ -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 && -- 2.7.4