--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 LIST_ADD_ALARM_ITEM_H
+#define LIST_ADD_ALARM_ITEM_H
+
+#include "Ui/GenItem.h"
+
+namespace List
+{
+ class AddAlarmItem: public Ui::GenItem
+ {
+ protected:
+ /**
+ * @see GenItem::getItemClass()
+ */
+ virtual Elm_Gen_Item_Class *getItemClass() const override;
+
+ /**
+ * @see GenItem::getContent()
+ */
+ virtual Evas_Object *getContent(Evas_Object *parent, const char *part) override;
+
+ private:
+ void onClicked(Evas_Object *obj, void *eventInfo);
+ };
+}
+
+#endif /* LIST_ADD_ALARM_ITEM_H */
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 LIST_ALARM_ITEM_H
+#define LIST_ALARM_ITEM_H
+
+#include "Ux/SelectItem.h"
+
+namespace Common
+{
+ namespace Model
+ {
+ class Alarm;
+ }
+}
+
+namespace List
+{
+ class AlarmItem: public Ux::SelectItem
+ {
+ public:
+ explicit AlarmItem(Common::Model::Alarm *alarm);
+
+ protected:
+ /**
+ * @see SelectItem::getDefaultResult()
+ */
+ virtual Ux::SelectResult getDefaultResult() const override;
+
+ /**
+ * @see GenItem::getItemClass()
+ */
+ virtual Elm_Gen_Item_Class *getItemClass() const override;
+
+ /**
+ * @see GenItem::getText()
+ */
+ virtual char *getText(Evas_Object *parent, const char *part) override;
+
+ /**
+ * @see GenItem::getContent()
+ */
+ virtual Evas_Object *getContent(Evas_Object *parent, const char *part) override;
+
+ private:
+ bool is24HourFormat() const;
+
+ Common::Model::Alarm *m_Alarm;
+ };
+}
+
+#endif /* LIST_ALARM_ITEM_H */
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 LIST_ALARMS_VIEW_H
+#define LIST_ALARMS_VIEW_H
+
+#include "Ux/SelectView.h"
+#include <system_settings.h>
+
+namespace Ui
+{
+ class Genlist;
+}
+
+namespace List
+{
+ class AlarmsView: public Ux::SelectView
+ {
+ public:
+ AlarmsView();
+ virtual ~AlarmsView() override;
+
+ virtual Evas_Object *onCreate(Evas_Object *parent) override;
+ virtual void onCreated() override;
+ virtual void onPageAttached(Ui::NavigatorPage *page) override;
+ virtual void onNavigation(bool isCurrent) override;
+
+ Evas_Object *createGenlist(Evas_Object *parent);
+
+ private:
+ void onFormatChanged(system_settings_key_e key);
+
+ Ui::Genlist *m_Genlist;
+ };
+}
+
+#endif /* LIST_ALARMS_VIEW_H */
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 UI_TITLE_ITEM_H
+#define UI_TITLE_ITEM_H
+
+#include "Ui/GenItem.h"
+
+namespace List
+{
+ class TitleItem: public Ui::GenItem
+ {
+ protected:
+ /**
+ * @see GenItem::getItemClass()
+ */
+ virtual Elm_Gen_Item_Class *getItemClass() const override;
+
+ /**
+ * @see GenItem::getText()
+ */
+ virtual char *getText(Evas_Object *parent, const char *part) override;
+ };
+}
+
+#endif /* UI_TITLE_ITEM_H */
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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.
+ */
+
+#include "List/AddAlarmItem.h"
+#include "Input/InputView.h"
+#include "Ui/Genlist.h"
+#include "Ui/Navigator.h"
+#include "Utils/Callback.h"
+
+using namespace List;
+
+Elm_Gen_Item_Class *AddAlarmItem::getItemClass() const
+{
+ static Elm_Gen_Item_Class itc = createItemClass("full");
+ return &itc;
+}
+
+Evas_Object *AddAlarmItem::getContent(Evas_Object *parent, const char *part)
+{
+ Evas_Object *button = elm_button_add(parent);
+ elm_object_style_set(button, "bottom");
+ elm_object_translatable_text_set(button, "WDS_ALM_OPT_ADD_ALARM_ABB");
+
+ evas_object_smart_callback_add(button, "clicked",
+ makeCallback(&AddAlarmItem::onClicked), this);
+
+ return button;
+}
+
+void AddAlarmItem::onClicked(Evas_Object *obj, void *eventInfo)
+{
+ if (auto navigator = getParent()->findParent<Ui::Navigator>()) {
+ navigator->navigateTo(new Input::InputView({ }));
+ }
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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.
+ */
+
+#include "Common/Model/Alarm.h"
+#include "List/AlarmItem.h"
+
+#include <system_settings.h>
+
+#define BUF_SIZE 16
+
+using namespace Common::Model;
+using namespace List;
+
+AlarmItem::AlarmItem(Alarm *alarm)
+ : m_Alarm(alarm)
+{
+}
+
+Ux::SelectResult AlarmItem::getDefaultResult() const
+{
+ return { 0, m_Alarm };
+}
+
+Elm_Gen_Item_Class *AlarmItem::getItemClass() const
+{
+ static Elm_Gen_Item_Class itc = createItemClass("2text.1icon.1");
+ return &itc;
+}
+
+char *AlarmItem::getText(Evas_Object *parent, const char *part)
+{
+ if (strcmp(part, "elm.text") == 0) {
+ char buf[BUF_SIZE];
+ strftime(buf, sizeof(buf), is24HourFormat() ? "%H:%M" : "%I:%M %p", &m_Alarm->getDate());
+
+ return strdup(buf);
+ } else if (strcmp(part, "elm.text.1") == 0) {
+ //TODO Get here alarm subtext
+ }
+
+ return nullptr;
+}
+
+Evas_Object *AlarmItem::getContent(Evas_Object *parent, const char *part)
+{
+ if (strcmp(part, "elm.icon") == 0) {
+ //TODO Make on/off alarm icon
+ } else if (strcmp(part, "elm.swallow.center_check") == 0) {
+ SelectItem::getContent(parent, part);
+ }
+
+ return nullptr;
+}
+
+bool AlarmItem::is24HourFormat() const
+{
+ bool is24hour = true;
+ system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, &is24hour);
+ return is24hour;
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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.
+ */
+
+#include "Common/Model/Alarm.h"
+#include "List/AddAlarmItem.h"
+#include "List/AlarmItem.h"
+#include "List/AlarmsView.h"
+#include "List/TitleItem.h"
+
+#include "System/Settings.h"
+#include "Ui/Genlist.h"
+#include "Ui/GenGroupItem.h"
+#include "Ui/Window.h"
+
+using namespace Common::Model;
+using namespace List;
+using namespace std::placeholders;
+
+AlarmsView::AlarmsView()
+ : m_Genlist(nullptr)
+{
+ System::Settings::addCallback(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR,
+ { std::bind(&AlarmsView::onFormatChanged, this, _1), this });
+}
+
+AlarmsView::~AlarmsView()
+{
+ System::Settings::removeCallback(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, this);
+}
+
+Evas_Object *AlarmsView::onCreate(Evas_Object *parent)
+{
+ return createGenlist(parent);
+}
+
+void AlarmsView::onCreated()
+{
+ m_Genlist->insert(new TitleItem());
+ // TODO Here should be filled alarms from model
+ m_Genlist->insert(new AddAlarmItem());
+}
+
+void AlarmsView::onPageAttached(Ui::NavigatorPage *page)
+{
+ page->setStyle("empty");
+}
+
+void AlarmsView::onNavigation(bool isCurrent)
+{
+ eext_rotary_object_event_activated_set(m_Genlist->getEvasObject(), isCurrent);
+}
+
+Evas_Object *AlarmsView::createGenlist(Evas_Object *parent)
+{
+ auto surface = findParent<Ui::Window>(parent)->getCircleConformant();
+
+ m_Genlist = new Ui::Genlist();
+ m_Genlist->create(parent);
+ eext_circle_object_genlist_add(m_Genlist->getEvasObject(), surface);
+
+ return m_Genlist->getEvasObject();
+}
+
+void AlarmsView::onFormatChanged(system_settings_key_e key)
+{
+ m_Genlist->update("elm.text", ELM_GENLIST_ITEM_FIELD_TEXT);
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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.
+ */
+
+#include "List/TitleItem.h"
+#include <app_i18n.h>
+
+using namespace List;
+
+Elm_Gen_Item_Class *TitleItem::getItemClass() const
+{
+ static Elm_Gen_Item_Class itc = createItemClass("title");
+ return &itc;
+}
+
+char *TitleItem::getText(Evas_Object *parent, const char *part)
+{
+ if (strcmp(part, "elm.text") == 0) {
+ return strdup(_("WDS_ALM_HEADER_ALARM_ABB"));
+ }
+
+ return nullptr;
+}
*/
#include "OperationDefaultController.h"
+#include "List/AlarmsView.h"
#include "Ui/Navigator.h"
OperationDefaultController::OperationDefaultController()
void OperationDefaultController::onCreate()
{
- /* TODO: getNavigator()->navigateTo(new List::AlarmsView()); */
+ getNavigator()->navigateTo(new List::AlarmsView());
}