TizenRefApp-7460 Wrong event displayed on Alert screen after one was snoozed 82/104182/4
authorSergei Kobec <s.kobec@samsung.com>
Tue, 13 Dec 2016 14:39:28 +0000 (16:39 +0200)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Thu, 15 Dec 2016 11:37:27 +0000 (03:37 -0800)
Change-Id: I0f65d7c079ec54d2be9620e2ef23111ec54bf4d1
Signed-off-by: Sergei Kobec <s.kobec@samsung.com>
app-control/alert/CalAlertApp.cpp
app-control/alert/CalAlertData.cpp
app-control/alert/CalAlertData.h
app-control/alert/CalAlertModel.cpp
app-control/alert/CalAlertModel.h
app-control/alert/CalAlertView.cpp

index f8b08f8..8b54d2b 100644 (file)
@@ -248,6 +248,7 @@ CalAlertApp::Mode CalAlertApp::__getMode(const app_control_h request)
                free(caller);
        } else {
                __alertData = std::make_shared<CalAlertData>(request);
+               __model = std::make_shared<CalAlertModel>(__alertData);
                if (__alertData->getCount()) {
                        mode = CalAlertModel::isDeviceLocked() ? CALALERT_VIEW :
                                        CALALERT_ACTIVE_NOTIFICATION;
index e5366c9..0b4001b 100644 (file)
@@ -47,12 +47,14 @@ CalAlertData::CalAlertData(app_control_h request) :
        WDEBUG("len(%d)", len);
        if (ids && len > 0) {
                // calendar-service
+               int recordIndex = -1;
                for (int i = 0; i < len; i++) {
-                       int recordIndex = atoi(ids[i]);
+                       recordIndex = atoi(ids[i]);
                        __addRecord(recordIndex, false);
                        WDEBUG("alert index[%d]", recordIndex);
                        free(ids[i]);
                }
+               __currentIndex = recordIndex;
 
                free(ids);
                return;
@@ -157,6 +159,17 @@ int CalAlertData::getCount(void)
        return __alerts.size();
 }
 
+size_t CalAlertData::getCurrentIndex() const
+{
+       for (size_t i = 0; i < __alerts.size(); ++i) {
+               if (__alerts[i]->getRecordIndex() == __currentIndex) {
+                       return i;
+               }
+       }
+
+       return 0;
+}
+
 std::shared_ptr<CalAlertNotificationItem> CalAlertData::getAt(int nth)
 {
        WENTER();
index a8a2a39..e942e2b 100644 (file)
@@ -59,6 +59,14 @@ public:
        int getCount(void);
 
        /**
+        * @brief Get current index of alert notification
+        * @see getAt()
+        * @detail Used to get index of current alert list
+        * @return Index of alert notification
+        */
+       size_t getCurrentIndex() const;
+
+       /**
         * @brief Get element by number.
         *
         * @param nth    number of item.
@@ -126,6 +134,7 @@ private:
        int __tick;
        int __unit;
        std::vector<std::shared_ptr<CalAlertNotificationItem>> __alerts;
+       int __currentIndex;
 };
 
 #endif
index b2332a9..799efae 100644 (file)
@@ -56,6 +56,11 @@ int CalAlertModel::getCount(void)
        return __alertData->getCount();
 }
 
+const std::shared_ptr<CalAlertData> &CalAlertModel::getAlertData() const
+{
+       return __alertData;
+}
+
 std::shared_ptr<CalAlertNotificationItem> CalAlertModel::getAt(int nth)
 {
        WENTER();
index c8de62d..4a0f107 100644 (file)
@@ -55,6 +55,11 @@ public:
        int getCount(void);
 
        /**
+        * @return Alert data
+        */
+       const std::shared_ptr<CalAlertData> &getAlertData() const;
+
+       /**
         * @brief Get alert notification item by index.
         *
         * @param nth    index of item.
index a0f8b3e..14514e5 100644 (file)
@@ -50,7 +50,9 @@ Evas_Object *CalAlertView::onCreate(Evas_Object *parent, void *viewParam)
        Evas_Object *layout = elm_layout_add(parent);
        elm_layout_file_set(layout, CalPath::getPath(CAL_EDJE).c_str(), "CalAlertView");
 
-       auto schedule = __model.getAt(0)->getSchedule();
+       auto &alertData = __model.getAlertData();
+       const auto &alertItem = alertData->getAt(alertData->getCurrentIndex());
+       auto schedule = alertItem->getSchedule();
        std::string str;
 
        ////  add title
@@ -83,7 +85,7 @@ Evas_Object *CalAlertView::onCreate(Evas_Object *parent, void *viewParam)
        edje_object_signal_callback_add(dismiss, EMIT_ACTIVATED, "",
                [](void *data, Evas_Object *, const char *, const char *) {
                        CalAlertView *self = (CalAlertView *)data;
-                       self->__model.dismiss(0);
+                       self->__model.dismiss(self->__model.getAlertData()->getCurrentIndex());
                        ui_app_exit();
                }, this);
 
@@ -91,7 +93,7 @@ Evas_Object *CalAlertView::onCreate(Evas_Object *parent, void *viewParam)
        edje_object_signal_callback_add(snooze, EMIT_ACTIVATED, "",
                [](void *data, Evas_Object *, const char *, const char *) {
                        CalAlertView *self = (CalAlertView *)data;
-                       self->__model.snooze(0);
+                       self->__model.snooze(self->__model.getAlertData()->getCurrentIndex());
                        ui_app_exit();
                }, this);
 
@@ -100,9 +102,9 @@ Evas_Object *CalAlertView::onCreate(Evas_Object *parent, void *viewParam)
 
        __timer = ecore_timer_add(ALERT_TIMER, [](void *data) {
                        CalAlertView *self = (CalAlertView *)data;
-                       self->__model.snooze(0);
+                       self->__model.snooze(self->__model.getAlertData()->getCurrentIndex());
                        self->__timer = NULL;
-                       elm_exit();
+                       ui_app_exit();
                        return ECORE_CALLBACK_CANCEL;
                }, this);