From: Sergei Kobec Date: Mon, 30 Jan 2017 13:10:14 +0000 (+0200) Subject: Create base alarms list view X-Git-Tag: submit/tizen/20170327.131711~61^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1df61619d2b2003dbc4ba79e38adaa4974cf7b6f;p=profile%2Fwearable%2Fapps%2Fnative%2Falarm.git Create base alarms list view Change-Id: If0b941169171aec330d8eb058ee68ee932ecbf45 Signed-off-by: Sergei Kobec --- diff --git a/alarm-app/inc/List/AddAlarmItem.h b/alarm-app/inc/List/AddAlarmItem.h new file mode 100644 index 0000000..6a273a8 --- /dev/null +++ b/alarm-app/inc/List/AddAlarmItem.h @@ -0,0 +1,42 @@ +/* + * 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 */ diff --git a/alarm-app/inc/List/AlarmItem.h b/alarm-app/inc/List/AlarmItem.h new file mode 100644 index 0000000..af1f2dc --- /dev/null +++ b/alarm-app/inc/List/AlarmItem.h @@ -0,0 +1,65 @@ +/* + * 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 */ diff --git a/alarm-app/inc/List/AlarmsView.h b/alarm-app/inc/List/AlarmsView.h new file mode 100644 index 0000000..e751145 --- /dev/null +++ b/alarm-app/inc/List/AlarmsView.h @@ -0,0 +1,50 @@ +/* + * 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 + +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 */ diff --git a/alarm-app/inc/List/TitleItem.h b/alarm-app/inc/List/TitleItem.h new file mode 100644 index 0000000..0bd8df0 --- /dev/null +++ b/alarm-app/inc/List/TitleItem.h @@ -0,0 +1,39 @@ +/* + * 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 */ diff --git a/alarm-app/src/List/AddAlarmItem.cpp b/alarm-app/src/List/AddAlarmItem.cpp new file mode 100644 index 0000000..af24b0b --- /dev/null +++ b/alarm-app/src/List/AddAlarmItem.cpp @@ -0,0 +1,48 @@ +/* + * 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()) { + navigator->navigateTo(new Input::InputView({ })); + } +} diff --git a/alarm-app/src/List/AlarmItem.cpp b/alarm-app/src/List/AlarmItem.cpp new file mode 100644 index 0000000..8974c88 --- /dev/null +++ b/alarm-app/src/List/AlarmItem.cpp @@ -0,0 +1,73 @@ +/* + * 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 + +#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; +} diff --git a/alarm-app/src/List/AlarmsView.cpp b/alarm-app/src/List/AlarmsView.cpp new file mode 100644 index 0000000..1cd0364 --- /dev/null +++ b/alarm-app/src/List/AlarmsView.cpp @@ -0,0 +1,80 @@ +/* + * 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(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); +} diff --git a/alarm-app/src/List/TitleItem.cpp b/alarm-app/src/List/TitleItem.cpp new file mode 100644 index 0000000..90372b2 --- /dev/null +++ b/alarm-app/src/List/TitleItem.cpp @@ -0,0 +1,35 @@ +/* + * 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 + +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; +} diff --git a/alarm-app/src/OperationDefaultController.cpp b/alarm-app/src/OperationDefaultController.cpp index 11f8020..530592e 100644 --- a/alarm-app/src/OperationDefaultController.cpp +++ b/alarm-app/src/OperationDefaultController.cpp @@ -15,6 +15,7 @@ */ #include "OperationDefaultController.h" +#include "List/AlarmsView.h" #include "Ui/Navigator.h" OperationDefaultController::OperationDefaultController() @@ -24,5 +25,5 @@ OperationDefaultController::OperationDefaultController() void OperationDefaultController::onCreate() { - /* TODO: getNavigator()->navigateTo(new List::AlarmsView()); */ + getNavigator()->navigateTo(new List::AlarmsView()); }