AlarmView implementation
authorLukasz Stanislawski <l.stanislaws@samsung.com>
Wed, 17 Aug 2016 06:38:54 +0000 (08:38 +0200)
committerLukasz Stanislawski <l.stanislaws@samsung.com>
Thu, 25 Aug 2016 13:36:16 +0000 (15:36 +0200)
Change-Id: Ib8c84aa7664c53f0aaf67f6b8b881944f8c1180e

19 files changed:
WORKSPACE
clock/inc/Presenters/AlarmPresenter.h [new file with mode: 0644]
clock/inc/View/AlarmView.h
clock/inc/View/MainView.h
clock/inc/View/PageView.h
clock/inc/View/StopWatchView.h
clock/inc/View/TimerView.h
clock/inc/View/WorldClockView.h
clock/project_def.prop
clock/res/edje/alarm.edc [new file with mode: 0644]
clock/src/Presenters/AlarmPresenter.cpp [new file with mode: 0644]
clock/src/View/AlarmView.cpp
clock/src/View/MainView.cpp
common/inc/Model/Alarm.h
common/inc/UI/View.h [new file with mode: 0644]
common/inc/Utils/Time.h
common/src/Model/Alarm.cpp
common/src/Model/AlarmProvider.cpp
common/src/Utils/Time.cpp

index b86c2e0..2a6d519 100644 (file)
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -1,3 +1,2 @@
 common
-ring
 clock
diff --git a/clock/inc/Presenters/AlarmPresenter.h b/clock/inc/Presenters/AlarmPresenter.h
new file mode 100644 (file)
index 0000000..bf974da
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ALARM_PRESENTER_H_
+#define _ALARM_PRESENTER_H_
+
+#include "View/AlarmView.h"
+#include "Model/AlarmProvider.h"
+
+namespace worldclock {
+       namespace presenters {
+               class AlarmPresenter {
+                       public:
+                               AlarmPresenter(view::AlarmView *view, common::model::AlarmProvider *model);
+                       private:
+                               view::AlarmView *view;
+                               common::model::AlarmProvider *model;
+                               void ShowAll();
+                               void OnItemSelected(int idx);
+                               void OnItemActiveStatusChanged(int idx);
+               };
+       } /* presenters */
+} /* worldclock */
+
+#endif
index 956817d..b9c3966 100644 (file)
 #ifndef ALARMVIEW_H_
 #define ALARMVIEW_H_
 
-#include "View/PageView.h"
-#include "View/View.h"
+#include "UI/View.h"
+#include "Model/WeekFlags.h"
+#include "Utils/Time.h"
+
+#include <functional>
 
 namespace worldclock {
        namespace view {
-               class AlarmView : public IView{
+               class AlarmView : public common::ui::IView {
                        public:
+                               typedef std::function<void(int)> SelectCallback;
+                               typedef std::function<void(int)> ToggleCallback;
+                               typedef std::function<void(void)> ButtonClickedCallback;
+
                                AlarmView();
-                               Evas_Object *GetEvasObject(){return alarm_;};
+                               void Clear();
+                               int ItemAppend(common::utils::Time time, const char *name,
+                                               const  common::model::WeekFlags flags, bool active);
+                               void RemoveItem(int idx);
+                               void ItemUpdate(int idx, common::utils::Time time, const char *name,
+                                               const common::model::WeekFlags flags, bool active);
+                               void ItemEnable(int idx);
+                               void ItemDisable(int idx);
 
+                               void SetItemToggleCallback(ToggleCallback func);
+                               void SetItemSelectCallback(SelectCallback func);;
+                               void SetButtonClickedCallback(ButtonClickedCallback func);
+                               Evas_Object *GetEvasObject();
                        private:
-                               Evas_Object *alarm_;
+                               static Elm_Genlist_Item_Class alarm_itc;
+                               static Evas_Object *ContentGet(void *data, Evas_Object *obj, const char *part);
+                               static char *TextGet(void *data, Evas_Object *obj, const char *part);
+                               static void ItemClicked(void *data, Evas_Object *obj, void *info);
+                               static void ItemRealized(void *data, Evas_Object *obj, void *info);
+                               Evas_Object *genlist;
+                               SelectCallback onSelected;
+                               ToggleCallback onToggled;
+                               ButtonClickedCallback onClicked;;
                };
        }
 }
index 50f1b0e..5177089 100644 (file)
@@ -20,7 +20,7 @@
 #include <Evas.h>
 
 #include "View/PageView.h"
-#include "View/View.h"
+#include "UI/View.h"
 
 /**
  * @file MainView.h
@@ -43,7 +43,7 @@ namespace worldclock {
                 * @brief Application main view class
                 * @remarks This is singleton class.
                 */
-               class MainView : public IView {
+               class MainView : public common::ui::IView {
                        public:
 
                                /**
index 2a3135a..fae0215 100644 (file)
@@ -19,7 +19,7 @@
 #define NAVIFRAME_PAGE_VIEW_H_
 
 #include <Elementary.h>
-#include "View/View.h"
+#include "UI/View.h"
 
 /**
  * @file pageView.h
@@ -36,7 +36,7 @@ namespace worldclock {
                /*
                 * @brief Base class for pages(Alarm, World Clock, StopWatch and Timer)
                 */
-               class PageView : public view::IView {
+               class PageView : public common::ui::IView {
                        public:
 
                                /**
@@ -51,7 +51,7 @@ namespace worldclock {
                                /**
                                 * @brief Gets object of the page.
                                 */
-                               Evas_Object *GetEvasObject();
+                               virtual Evas_Object *GetEvasObject();
 
                                /**
                                 * @brief Creates page content.
index 4c2b372..4bd1fad 100644 (file)
 #define STOPWATCHVIEW_H_
 
 #include "View/PageView.h"
-#include "View/View.h"
+#include "UI/View.h"
 
 namespace worldclock {
        namespace view {
 
-               class StopWatchView : public IView{
+               class StopWatchView : public common::ui::IView {
                        public:
                        StopWatchView();
                        Evas_Object *GetEvasObject(){return stopwatch_;};
index 164a629..a32a5fa 100644 (file)
 #define TIMERVIEW_H_
 
 #include "View/PageView.h"
-#include "View/View.h"
+#include "UI/View.h"
 
 namespace worldclock {
        namespace view {
-               class TimerView : public IView{
+               class TimerView : public common::ui::IView {
                        public:
                                TimerView();
                                Evas_Object *GetEvasObject(){return timer_;};
index 95b1fc9..183bcad 100644 (file)
 #define WORLDCLOCKVIEW_H_
 
 #include "View/PageView.h"
-#include "View/View.h"
+#include "UI/View.h"
 
 namespace worldclock {
        namespace view {
-               class WorldClockView : public IView{
+               class WorldClockView : public common::ui::IView {
                        public:
                        WorldClockView();
                        Evas_Object *GetEvasObject(){return world_clock_;};
index 225bbf4..48dbc10 100644 (file)
@@ -9,7 +9,7 @@ type = app
 profile = mobile-3.0
 
 # C Sources
-USER_SRCS = src/*.cpp src/Controller/*.cpp src/View/*.cpp
+USER_SRCS = src/*.cpp src/Controller/*.cpp src/View/*.cpp src/Presenters/*.cpp
 USER_SRCS_ABS =
 
 # EDC Sources
@@ -27,7 +27,7 @@ USER_UNDEFS =
 USER_CPP_UNDEFS = 
 
 # User Libraries
-USER_LIBS = 
+USER_LIBS = org.tizen.clock
 
 # User Objects
 USER_OBJS =
@@ -35,7 +35,7 @@ USER_OBJS_ABS =
 
 # User Includes
 ## C Compiler
-USER_INC_DIRS = inc/
+USER_INC_DIRS = inc/ $(workspace_loc)/common/inc
 USER_INC_DIRS_ABS =
 USER_INC_FILES = 
 USER_INC_FILES_ABS = 
@@ -60,7 +60,7 @@ USER_EDCS_FONT_DIRS_ABS =
 # EDC Flags
 USER_EXT_EDC_KEYS = EDC0 
 
-USER_EXT_EDC0_EDCS = res/edje/clock.edc 
+USER_EXT_EDC0_EDCS = res/edje/clock.edc res/edje/alarm.edc
 USER_EXT_EDC0_EDCS_IMAGE_DIRS = edje/images 
 USER_EXT_EDC0_EDCS_IMAGE_DIRS_ABS = 
 USER_EXT_EDC0_EDCS_SOUND_DIRS = edje/sounds 
diff --git a/clock/res/edje/alarm.edc b/clock/res/edje/alarm.edc
new file mode 100644 (file)
index 0000000..425d2e9
--- /dev/null
@@ -0,0 +1,156 @@
+collections {
+       base_scale: 2.6;
+       group { name: "elm/genlist/item/alarm/default";
+               styles {
+                       style { name: "font1_normal";
+                               base: "font=Tizen:style=Light color=#000000FF font_size=70 ellipsis=1.0";
+                               tag: "meridiem" "+ font_size=45";
+                       }
+                       style {
+                               name: "font1_dim";
+                               base: "font=Tizen:style=Light color=#00000028 font_size=70 ellipsis=1.0";
+                       }
+                       style {
+                               name: "font3_normal";
+                               base: "font=Tizen:style=Regular color=#000000FF font_size=36 ellipsis=1.0";
+                       }
+                       style {
+                               name: "font3_dim";
+                               base: "font=Tizen:style=Regular color=#00000028 font_size=36 ellipsis=1.0";
+                       }
+                       style {
+                               name: "font4_normal";
+                               base: "font=Tizen:style=Regular color=#59AF3AFF font_size=32
+                                                 ellipsis=1.0";
+                               tag: "off" "+ color=#B2B2B2FF";
+                       }
+                       style {
+                               name: "font4_dim";
+                               base: "font=Tizen:style=Regular color=#23461766 font_size=32  ellipsis=1.0";
+                               tag: "off" "+ color=#47474766";
+                       }
+               }
+               data.item: "texts" "time meridiem name weekflags";
+               data.item: "contents" "onoff";
+               parts {
+                       rect { "base"; scale;
+                               desc { "default";
+                                       fixed: 0 0;
+                                       min: 0 (22+93+29);
+                                       max: -1 (22+93+29);
+                               }
+                       }
+                       spacer { "padding.top"; scale;
+                               desc { "default";
+                                       fixed: 0 1;
+                                       min: 0 22;
+                                       max: -1 22;
+                                       align: 0.0 0.0;
+                                       rel1.to: "base";
+                                       rel2.to: "base";
+                               }
+                       }
+                       spacer { "padding.left"; scale;
+                               desc { "default";
+                                       fixed: 1 0;
+                                       min: 32 0;
+                                       max: 32 -1;
+                                       align: 0.0 0.5;
+                                       rel1.to: "base";
+                                       rel2.to: "base";
+                               }
+                       }
+                       textblock { "time"; scale;
+                               desc { "default";
+                                       fixed: 0 1;
+                                       min: 0 93;
+                                       max: -1 93;
+                                       align: 0.0 0.0;
+                                       rel1 { relative: 1.0 1.0; to_x: "padding.left"; to_y: "padding.top"; }
+                                       rel2.to: "base";
+                                       text.style: "font1_normal";
+                               }
+                               desc { "disabled";
+                                       inherit: "default";
+                                       text.style: "font1_dim";
+                               }
+                       }
+                       spacer { "padding.right"; scale;
+                               desc { "default";
+                                       fixed: 1 0;
+                                       min: 32 0;
+                                       max: 32 -1;
+                                       align: 1.0 0.5;
+                                       rel1.to: "base";
+                                       rel2.to: "base";
+                               }
+                       }
+                       swallow { "onoff"; scale;
+                               desc { "default";
+                                       fixed: 1 1;
+                                       align: 1.0 0.5;
+                                       min: 80 80;
+                                       max: 80 80;
+                                       rel1.to: "base";
+                                       rel2 { relative: 0.0 1.0; to: "padding.right"; }
+                               }
+                       }
+                       spacer { "spacer.name.week"; scale;
+                               desc { "default";
+                                       fixed: 1 1;
+                                       min: (268+32) 86;
+                                       max: (268+32) 86;
+                                       align: 1.0 1.0;
+                                       rel1.to: "base";
+                                       rel2 { relative: 0.0 1.0; to: "onoff"; }
+                               }
+                       }
+                       textblock { "weekflags"; scale;
+                               desc { "default";
+                                       fixed: 1 1;
+                                       min: 268 43;
+                                       max: 268 43;
+                                       align: 0.0 1.0;
+                                       rel1.to: "spacer.name.week";
+                                       rel2.to: "spacer.name.week";
+                                       text.style: "font4_normal";
+                               }
+                               desc { "disabled";
+                                       inherit: "default";
+                                       text.style: "font4_dim";
+                               }
+                       }
+                       textblock { "name"; scale;
+                               desc { "default";
+                                       fixed: 1 1;
+                                       min: 268 43;
+                                       max: 268 43;
+                                       align: 0.0 0.0;
+                                       rel1.to: "spacer.name.week";
+                                       rel2.to: "spacer.name.week";
+                                       text.style: "font3_normal";
+                               }
+                               desc { "disabled";
+                                       inherit: "default";
+                                       text.style: "font3_dim";
+                               }
+                       }
+               }
+               program { "enabled";
+                       signal: "alarm,state,enabled";
+                       source: "clock";
+                       action: STATE_SET "default" 0.0;
+                       target: "name";
+                       target: "weekflags";
+                       target: "time";
+               }
+               program { "disabled";
+                       signal: "alarm,state,disabled";
+                       source: "clock";
+                       action: STATE_SET "disabled" 0.0;
+                       target: "name";
+                       target: "weekflags";
+                       target: "time";
+               }
+       }
+}
diff --git a/clock/src/Presenters/AlarmPresenter.cpp b/clock/src/Presenters/AlarmPresenter.cpp
new file mode 100644 (file)
index 0000000..b3a26fc
--- /dev/null
@@ -0,0 +1,56 @@
+#include "Presenters/AlarmPresenter.h"
+#include "log.h"
+
+using namespace worldclock::presenters;
+using namespace worldclock::view;
+using namespace common::model;
+
+AlarmPresenter::AlarmPresenter(AlarmView *v, AlarmProvider *m) : model(m), view(v)
+{
+       //view.RegisterOnItemStatusChange(std::function<>());
+       //view.RegisterOnItemSelected(std::function<>());
+       //view.RegisterOnAlarmAddClicked(std::function<>());
+
+       ShowAll();
+}
+
+void AlarmPresenter::ShowAll()
+{
+       std::vector<std::reference_wrapper<Alarm>> alarms = model->GetAlarms();
+       DBG("ShowAll()");
+
+       view->Clear();
+
+       for (auto a: alarms) {
+               DBG("ItemAppend()");
+               view->ItemAppend(
+                               a.get().GetTime(),
+                               a.get().GetName().c_str(),
+                               a.get().GetWeekFlags(),
+                               a.get().IsActivated());
+       }
+}
+
+void AlarmPresenter::OnItemSelected(int idx)
+{
+       // Get model for given index
+       // emit new event AlarmEditRequest event
+}
+
+void AlarmPresenter::OnItemActiveStatusChanged(int idx)
+{
+       // get Alarm reference
+       /*
+       Alarm *alarm;
+       bool active = false;
+
+       if (!active)
+               alarm->Activate();
+       else
+               alarm->Deactivate();
+       */
+
+       //view.ItemUpdate(idx, a.GetTime(), a.GetName(), a.GetFlags(), a.IsActivated());
+
+       //AlarmProvider::Sync();
+}
index 8fb6f09..6ff2d2b 100644 (file)
 
 #include "View/AlarmView.h"
 #include "View/MainView.h"
-#include "Utils.h"
+#include "Utils/Utils.h"
+#include <Elementary.h>
+#include <cstdlib>
+#include <sstream>
+
+#include "log.h"
 
 using namespace worldclock::view;
+using namespace common::model;
 using namespace common::utils;
 
+struct ItemData {
+       AlarmView *instance;
+       char *name;
+       bool active;
+       WeekFlags flags;
+       Time time;
+       Elm_Object_Item *it;
+};
+
+Elm_Genlist_Item_Class AlarmView::alarm_itc = {
+       .item_style = "alarm",
+       .func.content_get = AlarmView::ContentGet,
+       .func.text_get = AlarmView::TextGet,
+};
+
+void AlarmView::ItemClicked(void *data, Evas_Object *obj, void *info)
+{
+       ItemData *id = static_cast<ItemData*>(data);
+
+       if (elm_check_state_get(obj))
+               elm_object_item_signal_emit(id->it, "alarm,state,enabled", "clock");
+       else
+               elm_object_item_signal_emit(id->it, "alarm,state,disabled", "clock");
+}
+
+void AlarmView::ItemRealized(void *data, Evas_Object *obj, void *info)
+{
+       Elm_Object_Item *it = static_cast<Elm_Object_Item*>(info);
+
+       ItemData *id = static_cast<ItemData*>(elm_object_item_data_get(it));
+
+       if (id->active)
+               elm_object_item_signal_emit(id->it, "alarm,state,enabled", "clock");
+       else
+               elm_object_item_signal_emit(id->it, "alarm,state,disabled", "clock");
+}
+
+Evas_Object *AlarmView::ContentGet(void *data, Evas_Object *obj, const char *part)
+{
+       ItemData *id = static_cast<ItemData*>(data);
+
+       if (!strcmp(part, "onoff")) {
+               Evas_Object *toggle = elm_check_add(obj);
+               elm_object_style_set(toggle, "on&off");
+               elm_check_state_set(toggle, id->active ? EINA_TRUE : EINA_FALSE);
+               evas_object_smart_callback_add(toggle, "changed", AlarmView::ItemClicked, id);
+               evas_object_show(toggle);
+               return toggle;
+       }
+       return nullptr;
+}
+
+static char *WeekFlag2FormattedString(WeekFlags flags)
+{
+       std::stringstream weekflags;
+
+       weekflags << (flags.IsOn(WeekDay::MONDAY) ? "M" : "<off>M</off>");
+       weekflags << (flags.IsOn(WeekDay::TUESDAY) ? "T" : "<off>T</off>");
+       weekflags << (flags.IsOn(WeekDay::WEDNESDAY) ? "W" : "<off>W</off>");
+       weekflags << (flags.IsOn(WeekDay::THURSDAY) ? "T" : "<off>T</off>");
+       weekflags << (flags.IsOn(WeekDay::FRIDAY) ? "F" : "<off>F</off>");
+       weekflags << (flags.IsOn(WeekDay::SATURDAY) ? "S" : "<off>S</off>");
+       weekflags << (flags.IsOn(WeekDay::SUNDAY) ? "S" : "<off>S</off>");
+
+       return strdup(weekflags.str().c_str());
+}
+
+static char *Time2FormattedString(const Time &time)
+{
+       std::stringstream formatted_time;
+
+       formatted_time << time.Format(FORMAT_12H);
+       formatted_time << " <meridiem>";
+       formatted_time << time.Meridiem();
+       formatted_time << "</meridiem>";
+
+       return strdup(formatted_time.str().c_str());
+}
+
+char *AlarmView::TextGet(void *data, Evas_Object *obj, const char *part)
+{
+       ItemData *id = static_cast<ItemData*>(data);
+
+       if (!strcmp(part, "name"))
+               return strdup(id->name);
+       if (!strcmp(part, "time"))
+               return Time2FormattedString(id->time);
+       if (!strcmp(part, "weekflags"))
+               return WeekFlag2FormattedString(id->flags);
+
+       return NULL;
+}
+
 AlarmView::AlarmView()
 {
-       /*Create content here and use main_layout_ as a parent*/
+       genlist = elm_genlist_add(MainView::GetInstance().GetEvasObject());
+
+       elm_genlist_homogeneous_set(genlist, EINA_TRUE);
+       evas_object_size_hint_expand_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       evas_object_smart_callback_add(genlist, "realized", AlarmView::ItemRealized, this);
+       evas_object_show(genlist);
+
+       elm_theme_extension_add(NULL, Utils::GetAppResourcePath(Utils::APP_DIR_RESOURCE, "edje/alarm.edj"));
+}
 
-       /*Temporary Code*/
-       alarm_ = elm_layout_add(MainView::GetInstance().GetEvasObject());
+void AlarmView::Clear()
+{
+       elm_genlist_clear(genlist);
+}
 
-       elm_layout_file_set(alarm_, Utils::GetAppResourcePath(Utils::APP_DIR_RESOURCE, "edje/clock.edj"), "main");
+int AlarmView::ItemAppend(Time time, const char *name, const  WeekFlags flags, bool active)
+{
+       ItemData *data = new ItemData;
 
-       evas_object_size_hint_align_set(alarm_, EVAS_HINT_FILL, EVAS_HINT_FILL);
-       evas_object_size_hint_weight_set(alarm_, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       data->instance = this;
+       data->name = name ? strdup(name) : nullptr;
+       data->flags = flags;
+       data->active = active;
+       data->time = time;
 
-       Evas_Object *label = elm_label_add(alarm_);
+       data->it = elm_genlist_item_append(genlist,
+                       &alarm_itc,
+                       data,
+                       NULL,
+                       ELM_GENLIST_ITEM_NONE,
+                       NULL, NULL);
 
-       elm_object_text_set(label, "Alarm");
-       elm_layout_content_set(alarm_, "bg", label);
+       return elm_genlist_item_index_get(data->it);
+}
+
+void AlarmView::ItemUpdate(int idx, Time time, const char *name,
+               const WeekFlags flags, bool active)
+{
+       Elm_Object_Item *it = elm_genlist_nth_item_get(genlist, idx);
+       if (!it) return;
+
+       ItemData *data = static_cast<ItemData*>(elm_object_item_data_get(it));
+
+       if (data->name) free(data->name);
+       data->name = name ? strdup(name) : nullptr;
+       data->flags = flags;
+       data->active = active;
+       data->time = time;
+
+       elm_genlist_item_update(it);
+}
+
+void AlarmView::RemoveItem(int idx)
+{
+       //Elm_Object_Item *it = elm_genlist_item_nth_get(idx);
+       //if (it) elm_object_item_del(it);
+}
+
+void AlarmView::SetItemToggleCallback(ToggleCallback func)
+{
+       onToggled = std::move(func);
+}
+
+void AlarmView::SetItemSelectCallback(SelectCallback func)
+{
+       onSelected = std::move(func);
+}
+
+void AlarmView::SetButtonClickedCallback(ButtonClickedCallback func)
+{
+       onClicked = std::move(func);
+}
+
+Evas_Object *AlarmView::GetEvasObject()
+{
+       return genlist;
 }
index e0866dc..2b1dd43 100644 (file)
 #include "View/TimerView.h"
 #include "View/WorldClockView.h"
 
+#include "Presenters/AlarmPresenter.h"
+
 #include "View/MainView.h"
 #include "Clock.h"
 #include "Utils.h"
 #include "log.h"
 
+#include "Presenters/AlarmPresenter.h"
+#include "Model/AlarmProvider.h"
+
 using namespace worldclock::view;
+using namespace worldclock::presenters;
 using namespace common::utils;
+using namespace common::model;
 
 
 static void WinDeleteRequestCb(void *data, Evas_Object *obj, void *event_info)
@@ -109,7 +116,6 @@ void MainView::ConformantAdd()
        elm_win_resize_object_add(window_, conformant_);
 
        evas_object_show(conformant_);
-
 }
 
 
@@ -138,7 +144,9 @@ void MainView::NaviframeAdd()
 
 void MainView::CreatePages()
 {
-       alarm_ = new AlarmView();
+       AlarmView *alarm = new AlarmView();
+       new AlarmPresenter(alarm, AlarmProvider::GetInstance());
+       alarm_ = alarm;
        world_clock_ = new WorldClockView();
        stop_watch_ = new StopWatchView();
        timer_ = new TimerView();
index 0503fed..065294b 100644 (file)
@@ -7,6 +7,7 @@
 #include "Common/Defines.h"
 #include "Model/WeekFlags.h"
 #include "Utils/Serialization.h"
+#include "Utils/Time.h"
 
 namespace common {
        namespace model {
@@ -16,16 +17,6 @@ namespace common {
                        VIBRATION,
                        VIBRATION_AND_SOUND
                };
-               class CLOCK_EXPORT_API Time : public utils::ISerializable {
-                       public:
-                               unsigned int Hour, Min, Sec;
-                               Time() : Hour(0), Min(0), Sec(0) {}
-                               Time(unsigned int h, unsigned int m, unsigned int s) : Hour(h), Min(m), Sec(s) {}
-                               Time(utils::IReader &);
-                               void Serialize(utils::IWriter &w) const;
-                               inline bool operator==(const Time &a) { return (a.Hour == Hour ) &&
-                                       (a.Min == Min) && (a.Sec == Sec); }
-               };
                void Serialize(utils::IWriter &w, AlarmType type);
                void Deserialize(utils::IReader &w, AlarmType &type);
                class CLOCK_EXPORT_API Alarm : public utils::ISerializable {
@@ -45,8 +36,8 @@ namespace common {
                                unsigned int GetSnoozeMaxAttempts() const;
                                std::string GetName() const;
                                void SetName(std::string name);
-                               Time GetTime() const;
-                               void SetTime(Time time);
+                               utils::Time GetTime() const;
+                               void SetTime(utils::Time time);
                                std::string GetMelody() const;
                                void SetMelody(std::string path);
                                AlarmType GetType() const;
@@ -78,7 +69,7 @@ namespace common {
                                        unsigned int attempt;
                                        unsigned int attempts_max;
                                } snooze;
-                               Time time;
+                               utils::Time time;
                };
        } /* model */
 } /* common */
diff --git a/common/inc/UI/View.h b/common/inc/UI/View.h
new file mode 100644 (file)
index 0000000..432aa08
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef _CLOCK_UI_VIEW_H_
+#define _CLOCK_UI_VIEW_H_
+
+#include <Elementary.h>
+
+namespace common {
+namespace ui {
+       class IView {
+               public:
+                       virtual Evas_Object *GetEvasObject() = 0;
+       };
+};
+};
+
+#endif
index 6000d80..06b5af5 100644 (file)
@@ -1,13 +1,29 @@
 #ifndef _CLOCK_TIME_H_
 #define _CLOCK_TIME_H_
 
-#include <time.h>
+#include "Common/Defines.h"
+#include "Utils/Serialization.h"
 
 namespace common {
        namespace utils {
-                       time_t MakeTime(int day, int month, int year, int hour, int min);
+               enum Format {
+                       FORMAT_12H,
+                       FORMAT_24H
+               };
+               class CLOCK_EXPORT_API Time : public utils::ISerializable {
+                       public:
+                               unsigned int Hour, Min, Sec;
+                               Time() : Hour(0), Min(0), Sec(0) {}
+                               Time(unsigned int h, unsigned int m, unsigned int s) : Hour(h), Min(m), Sec(s) {}
+                               Time(utils::IReader &);
+                               void Serialize(utils::IWriter &w) const;
+                               inline bool operator==(const Time &a) { return (a.Hour == Hour ) &&
+                                       (a.Min == Min) && (a.Sec == Sec); }
+                               std::string Format(enum Format format) const;
+                               std::string Meridiem() const;
+                               std::string getFormattedTime(const char *icu_format) const;
+               };
        } /* utils */
-       
 } /* common */
 
 #endif
index 754727a..f00210c 100644 (file)
@@ -259,17 +259,3 @@ void Alarm::SetVolume(unsigned int volume)
 {
        sound.volume = volume;
 }
-
-Time::Time(utils::IReader &r)
-{
-       utils::Deserialize(r, Hour);
-       utils::Deserialize(r, Min);
-       utils::Deserialize(r, Sec);
-}
-
-void Time::Serialize(utils::IWriter &w) const
-{
-       utils::Serialize(w, Hour);
-       utils::Serialize(w, Min);
-       utils::Serialize(w, Sec);
-}
index 762df5b..da0409b 100644 (file)
@@ -1,5 +1,6 @@
 #include "Model/AlarmProvider.h"
 #include "Internal/AlarmProviderFile.h"
+#include "Internal/AlarmProviderStub.h"
 #include "Utils/BinaryFileReader.h"
 #include "Utils/BinaryFileWriter.h"
 #include "Utils/Utils.h"
@@ -15,7 +16,7 @@ AlarmProvider *AlarmProvider::GetInstance()
        static AlarmProvider *instance;
        if (!instance) {
                BinaryFileReader reader(Utils::APP_DIR_DATA, DATABASE_FILE);
-               instance = new AlarmProviderFile(reader);
+               instance = new AlarmProviderStub(reader);
        }
        return instance;
 }
index e093533..55c6cbf 100644 (file)
@@ -1,13 +1,40 @@
 #include "Utils/Time.h"
+#include <utils_i18n.h>
 
-time_t common::utils::MakeTime(int day, int month, int year, int hour, int min)
+using namespace common::utils;
+
+Time::Time(utils::IReader &r)
+{
+       utils::Deserialize(r, Hour);
+       utils::Deserialize(r, Min);
+       utils::Deserialize(r, Sec);
+}
+
+void Time::Serialize(utils::IWriter &w) const
+{
+       utils::Serialize(w, Hour);
+       utils::Serialize(w, Min);
+       utils::Serialize(w, Sec);
+}
+
+std::string Time::Format(enum Format format) const
+{
+       switch (format) {
+               case FORMAT_12H:
+                       return getFormattedTime("HH:mm");
+               case FORMAT_24H:
+                       return getFormattedTime("h:mm");
+       }
+       abort();
+       return "";
+}
+
+std::string Time::Meridiem() const
 {
-       struct tm date = {0, };
-       date.tm_mday = day;
-       date.tm_mon = month;
-       date.tm_year = year - 1970;
-       date.tm_hour = hour;
-       date.tm_min = min;
+       return "AM";
+}
 
-       return mktime(&date);
+std::string Time::getFormattedTime(const char *icu_format) const
+{
+       return "12:01";
 }