summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergii Kyryliuk <s.kyryliuk@partner.samsung.com>2017-03-16 18:33:40 +0200
committerSergii Kyryliuk <s.kyryliuk@partner.samsung.com>2017-03-20 13:05:38 +0200
commit064eaf5da72bc90edd3d61d3094820c6bb647f44 (patch)
tree3d7fcdcab97237f3dc903772305b61182e3da43d
parent8b0e91b71ad94a0971a04a8df0eecc180e998494 (diff)
downloadalarm-064eaf5da72bc90edd3d61d3094820c6bb647f44.tar.gz
alarm-064eaf5da72bc90edd3d61d3094820c6bb647f44.tar.bz2
alarm-064eaf5da72bc90edd3d61d3094820c6bb647f44.zip
TizenRefApp-8157 Implement restoring of widget information after reboot
Change-Id: I2d8fd87262f2a539a2aa0cf2535eec4900649d66 Signed-off-by: Sergii Kyryliuk <s.kyryliuk@partner.samsung.com>
-rw-r--r--alarm-widget/inc/AlarmWidget.h2
-rw-r--r--alarm-widget/src/AlarmWidget.cpp40
2 files changed, 34 insertions, 8 deletions
diff --git a/alarm-widget/inc/AlarmWidget.h b/alarm-widget/inc/AlarmWidget.h
index 00408ff..3cd9e66 100644
--- a/alarm-widget/inc/AlarmWidget.h
+++ b/alarm-widget/inc/AlarmWidget.h
@@ -36,6 +36,7 @@ class AlarmWidget : public App::Widget
{
public:
AlarmWidget();
+ virtual ~AlarmWidget() override;
private:
virtual void onCreate(bundle *content) override;
@@ -50,6 +51,7 @@ private:
void onPickReply(app_control_h request, app_control_h reply, app_control_result_e result);
void onCreateReply(app_control_h request, app_control_h reply, app_control_result_e result);
+ void onReply(const std::string &id);
void setAlarm(Common::Model::Alarm *alarm);
Evas_Object *m_Layout;
diff --git a/alarm-widget/src/AlarmWidget.cpp b/alarm-widget/src/AlarmWidget.cpp
index 97f0d27..3bcb691 100644
--- a/alarm-widget/src/AlarmWidget.cpp
+++ b/alarm-widget/src/AlarmWidget.cpp
@@ -22,8 +22,8 @@
#include "Common/Model/Alarm.h"
#include "Common/Model/AlarmConsumer.h"
#include "Ui/Window.h"
+#include "Utils/Bundle.h"
#include "Utils/Callback.h"
-#include "Utils/Logger.h"
#include "CommonPath.h"
#include "WidgetLayout.h"
@@ -34,6 +34,7 @@ using namespace Model;
using namespace Common;
using namespace Common::Model;
+#define ALARM_ID_KEY "alarm_id"
#define TIME_SIZE 40
#define APP_CONTROL_MIME_ALARM "application/vnd.tizen.alarm"
@@ -42,10 +43,24 @@ AlarmWidget::AlarmWidget()
{
}
+AlarmWidget::~AlarmWidget()
+{
+ delete m_Alarm;
+}
+
void AlarmWidget::onCreate(bundle *content)
{
elm_theme_extension_add(nullptr, App::getResourcePath(PATH_ALARM_CHECK_STYLE).c_str());
+ if (content) {
+ if (int alarmId = Utils::Bundle(content).getInt(ALARM_ID_KEY)) {
+ AlarmConsumer::getInstance().getDataItem(alarmId, [this](AlarmConsumer::DataList dataList) {
+ setAlarm(static_cast<Alarm *>(dataList.front()));
+ });
+ return;
+ }
+ }
+
updateEmptyState();
}
@@ -144,19 +159,22 @@ void AlarmWidget::onContentPressed(Evas_Object *obj, void *eventInfo)
void AlarmWidget::onPickReply(app_control_h request, app_control_h reply, app_control_result_e result)
{
- std::string id = App::getStringExtraData(reply, APP_CONTROL_DATA_SELECTED);
- AlarmConsumer::getInstance().getDataItem(atoi(id.c_str()), [this](AlarmConsumer::DataList dataList) {
- setAlarm(static_cast<Alarm *>(dataList.front()));
- updateEmptyState();
- });
+ onReply(App::getStringExtraData(reply, APP_CONTROL_DATA_SELECTED));
}
void AlarmWidget::onCreateReply(app_control_h request, app_control_h reply, app_control_result_e result)
{
- std::string id = App::getStringExtraData(reply, APP_CONTROL_DATA_ID);
+ onReply(App::getStringExtraData(reply, APP_CONTROL_DATA_ID));
+}
+
+void AlarmWidget::onReply(const std::string &id)
+{
AlarmConsumer::getInstance().getDataItem(atoi(id.c_str()), [this](AlarmConsumer::DataList dataList) {
setAlarm(static_cast<Alarm *>(dataList.front()));
- updateEmptyState();
+
+ Utils::Bundle bundle;
+ bundle.addInt(ALARM_ID_KEY, m_Alarm->getId());
+ saveContent(bundle.getBundle());
});
}
@@ -170,9 +188,15 @@ void AlarmWidget::setAlarm(Alarm *alarm)
delete widget->m_Alarm;
widget->m_Alarm = nullptr;
widget->updateEmptyState();
+
+ Utils::Bundle bundle;
+ bundle.addInt(ALARM_ID_KEY, 0);
+ widget->saveContent(bundle.getBundle());
}, this);
}, this };
m_Alarm->onUpdated() += { [this](int changes) {
updateContentLayout(changes);
}, this };
+
+ updateEmptyState();
}