TizenRefApp-9359 No unread message badge when opening messages from several new messa... 88/151188/2 submit/tizen_4.0/20170920.140520 submit/tizen_4.0/20170921.080245 submit/tizen_4.0/20170922.131417 submit/tizen_4.0/20170925.065901
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Wed, 20 Sep 2017 07:27:25 +0000 (10:27 +0300)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Wed, 20 Sep 2017 13:04:41 +0000 (13:04 +0000)
Change-Id: I528b3d3f9531bf2d34beca51827f34e339ea07fc
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
src/Common/MsgEngine/inc/Message.h
src/Common/MsgEngine/src/private/MessagePrivate.cpp
src/Common/MsgEngine/src/private/MessagePrivate.h
src/Conversation/ConvList/Controller/inc/ConvList.h
src/Conversation/ConvList/Controller/inc/ConvListItem.h
src/Conversation/ConvList/Controller/src/ConvList.cpp
src/Conversation/ConvList/Controller/src/ConvListItem.cpp
src/Conversation/Main/Controller/inc/Conversation.h
src/Conversation/Main/Controller/src/Conversation.cpp

index d1d24ad..5823479 100644 (file)
@@ -191,6 +191,12 @@ namespace Msg {
                         * @return true in case of restriction, false otherwise.
                         */
                        virtual bool isRestrictedByDpm() const = 0;
+
+                       /**
+                        * @brief Get read status
+                        * @return true if message is read, false otherwise
+                        */
+                       virtual bool isRead() const = 0;
        };
 }
 
index 0ee5644..10a21da 100644 (file)
@@ -184,3 +184,10 @@ bool MessagePrivate::isRestrictedByDpm() const
        msg_get_bool_value(m_MsgStruct, MSG_MESSAGE_DPM_RESTRICTED_BOOL, &restricted);
        return restricted;
 }
+
+bool MessagePrivate::isRead() const
+{
+       bool value = false;
+       msg_get_bool_value(m_MsgStruct, MSG_MESSAGE_READ_BOOL, &value);
+       return value;
+}
index 44f71a1..7fd35b3 100644 (file)
@@ -50,6 +50,7 @@ namespace Msg {
                        virtual Message::MessageStorageType getMessageStorageType() const;
                        virtual bool isMms() const;
                        virtual bool isRestrictedByDpm() const;
+                       virtual bool isRead() const;
 
                        void setId(MsgId id);
                        void set(msg_struct_t msgStruct);
index 1fcf112..1f2b147 100644 (file)
@@ -218,6 +218,7 @@ namespace Msg {
                         * @brief called when all messages has been deleted from current thread
                         */
                        virtual void onAllConvItemsDeleted(ConvList &list) {};
+                       virtual void onItemInserted(ConvListItem &item) {};
                        virtual void onSlideShow(MsgId id) {};
                        virtual void onEditDraftMsg(MsgId id) {};
                        virtual void onForwardMsg(MsgId id) {};
index e6e5c99..d432aa3 100644 (file)
@@ -70,6 +70,12 @@ namespace Msg {
                         * @brief Returns message's time
                         */
                        time_t getRawTime() const;
+
+                       /**
+                        * @brief Returns message read status
+                        */
+                       bool isRead() const;
+
                        void showPopup();
                        void setListener(IConvListItemListener *l);
 
@@ -149,6 +155,7 @@ namespace Msg {
                        BubbleEntityFactory &m_BubbleEntityFactory;
                        bool m_IsRestrictedByDpm;
                        bool m_IsNeededReadReport;
+                       bool m_IsRead;
                        const std::string m_SearchWord;
        };
 
index ce75b20..8adc0e9 100644 (file)
@@ -217,7 +217,11 @@ void ConvList::insertItem(ConvListItem *item)
                m_pList->insertBeforeItem(*item, *m_pComposeItem);
        else
                m_pList->appendItem(*item);
+
        updateSelectAllItem();
+
+       if (m_pListener)
+               m_pListener->onItemInserted(*item);
 }
 
 void ConvList::deleteItem(ConvListItem *item)
index e4cdb6d..4428c3e 100644 (file)
@@ -65,6 +65,7 @@ ConvListItem::ConvListItem(const MsgConversationItem &item,
        , m_BubbleEntityFactory(bubbleEntityFactory)
        , m_IsRestrictedByDpm(false)
        , m_IsNeededReadReport(false)
+       , m_IsRead(item.isRead())
        , m_SearchWord(searchWord)
 {
        update(item);
@@ -192,6 +193,7 @@ void ConvListItem::update()
 
        updateTime();
        m_Time = msg->getTime();
+       m_IsRead = msg->isRead();
        m_NetworkStatus = msg->getNetworkStatus();
        m_IsRestrictedByDpm = msg->isRestrictedByDpm();
 
@@ -223,6 +225,7 @@ void ConvListItem::update(const MsgConversationItem &item)
        clearEntityList();
 
        BubbleBgViewItem::BgType bgType = getBubbleBgType(item);
+       m_IsRead = item.isRead();
        m_MsgId = item.getMsgId();
        m_IsDraft = item.isDraft();
        m_Direction = item.getDirection();
@@ -340,6 +343,11 @@ time_t ConvListItem::getRawTime() const
        return m_Time;
 }
 
+bool ConvListItem::isRead() const
+{
+       return m_IsRead;
+}
+
 void ConvListItem::setListener(IConvListItemListener *l)
 {
        m_pListener = l;
index 3c7e17e..6609710 100644 (file)
@@ -133,6 +133,7 @@ namespace Msg {
 
                        // IConvListListener:
                        virtual void onAllConvItemsDeleted(ConvList &list);
+                       virtual void onItemInserted(ConvListItem &item);
                        virtual void onEditDraftMsg(MsgId id);
                        virtual void onForwardMsg(MsgId id);
                        virtual void onResendMsg(MsgId id);
@@ -149,6 +150,9 @@ namespace Msg {
                        // ISystemSettingsManager:
                        virtual void onLanguageChanged();
 
+                       // Timer:
+                       Eina_Bool onDeferredMarkAsRead();
+
                private:
                        void create();
                        void setMode(Mode mode);
@@ -167,6 +171,7 @@ namespace Msg {
                        void updateRecipientArea();
                        void createMainLayout();
                        void markAsRead();
+                       void deferredMarkAsRead();
                        void recipientClickHandler(const std::string &address);
                        void contactChangedHandler();
                        MsgAddressListRef getAddressList();
@@ -231,6 +236,7 @@ namespace Msg {
                        SettingsNetwork m_SettingsNetwork;
                        IConversationListener *m_pListener;
                        std::function<void()> m_TransFinishedFunc;
+                       Ecore_Timer *m_pMarkAsReadTimer;
        };
 
        class IConversationListener {
index b629b58..b18cfb0 100644 (file)
@@ -62,6 +62,7 @@ Conversation::Conversation(NaviFrameController &parent)
        , m_pConvList(nullptr)
        , m_AttachPanel(getApp())
        , m_pListener(nullptr)
+       , m_pMarkAsReadTimer(nullptr)
 {
        create();
 }
@@ -87,7 +88,10 @@ Conversation::~Conversation()
                ecore_idler_del(m_NnotifyConvertMsgTypeIdler);
                m_NnotifyConvertMsgTypeIdler = nullptr;
        }
-       markAsRead();
+       if (m_pMarkAsReadTimer) {
+               ecore_timer_del(m_pMarkAsReadTimer);
+               m_pMarkAsReadTimer = nullptr;
+       }
 }
 
 void Conversation::execCmd(const AppControlComposeRef &cmd)
@@ -166,9 +170,20 @@ void Conversation::create()
 
 void Conversation::markAsRead()
 {
+       MSG_LOG("");
        // Warning thread and messages marks as read only for ConversationMode.
-       if (m_ThreadId.isValid() && m_Mode == ConversationMode)
+       if (m_ThreadId.isValid() && m_Mode == ConversationMode) {
+               MSG_LOG("", m_ThreadId);
                getMsgEngine().getStorage().setReadStatus(m_ThreadId);
+       }
+}
+
+void Conversation::deferredMarkAsRead()
+{
+       if (!isPause() && !m_pMarkAsReadTimer) {
+               const double minTimeForRead = 1 / 10.0;
+               ecore_timer_add(minTimeForRead, ECORE_TACK_CALLBACK(Conversation, onDeferredMarkAsRead), this);
+       }
 }
 
 void Conversation::recipientClickHandler(const std::string &address)
@@ -273,7 +288,7 @@ void Conversation::setThreadId(ThreadId id, const char *searchWord, bool updateC
        if (m_pConvList && updateConvList)
                m_pConvList->setThreadId(m_ThreadId, searchWord);
 
-       markAsRead();
+       deferredMarkAsRead();
        updateNavibar();
        updateActiveNotifPolicy();
        checkAndSetMsgType(true);
@@ -413,8 +428,7 @@ void Conversation::showConvList(bool show)
                        m_pLayout->setConvList(*m_pConvList);
                }
        } else {
-               if (m_pConvList)
-               {
+               if (m_pConvList) {
                        m_pConvList->setListener(nullptr);
                        m_pConvList->destroy();
                        m_pConvList = nullptr;
@@ -433,8 +447,7 @@ void Conversation::showRecipPanel(bool show)
                        m_pLayout->setRecipientRect(m_pRecipPanel->getAreaRect());
                }
        } else {
-               if (m_pRecipPanel)
-               {
+               if (m_pRecipPanel) {
                        m_pRecipPanel->destroy();
                        m_pRecipPanel = nullptr;
                }
@@ -1097,6 +1110,7 @@ void Conversation::onResume()
 {
        MSG_LOG("");
        updateActiveNotifPolicy();
+       deferredMarkAsRead();
 }
 
 void Conversation::onHwBackButtonClicked()
@@ -1348,6 +1362,13 @@ void Conversation::onAllConvItemsDeleted(ConvList &list)
        }
 }
 
+void Conversation::onItemInserted(ConvListItem &item)
+{
+       MSG_LOG("", item.isRead());
+       if (!item.isRead())
+               deferredMarkAsRead();
+}
+
 void Conversation::onEditDraftMsg(MsgId id)
 {
        MSG_LOG("");
@@ -1404,3 +1425,11 @@ void Conversation::onLanguageChanged()
        updateMsgInputPanel();
        updateSelectMsgTitle();
 }
+
+Eina_Bool Conversation::onDeferredMarkAsRead()
+{
+       if (!isPause())
+               markAsRead();
+       m_pMarkAsReadTimer = nullptr;
+       return false; // Delete Timer
+}