diff options
17 files changed, 298 insertions, 67 deletions
diff --git a/alarm-app/.cproject b/alarm-app/.cproject index d71adaf..0ffd340 100644 --- a/alarm-app/.cproject +++ b/alarm-app/.cproject @@ -129,6 +129,7 @@ <listOptionValue builtIn="false" value=""${workspace_loc:/lib-common/inc}""/> <listOptionValue builtIn="false" value=""${workspace_loc:/alarm-app/res/input/edje}""/> <listOptionValue builtIn="false" value=""${workspace_loc:/alarm-app/res/list/edje}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/lib-common/res/common/edje}""/> </option> <option id="sbi.gnu.cpp.compiler.option.frameworks.core.208729733" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs"> <listOptionValue builtIn="false" value="Native_API"/> @@ -432,7 +433,15 @@ <option id="sbi.gnu.cpp.compiler.option.570702224" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs"> <listOptionValue builtIn="false" value="wearable-3.0-emulator.core_llvm37.i386.core.app"/> </option> - <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.1612390694" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath"> + <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.1612390694" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath"/> + <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.705336083" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.core" valueType="stringList"> + <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/> + <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/> + <listOptionValue builtIn="false" value=" -fPIE"/> + <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/> + </option> + <option id="gnu.cpp.compiler.option.include.paths.389112477" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/EGL""/> @@ -520,15 +529,7 @@ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/yaca""/> <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> - </option> - <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.705336083" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.core" valueType="stringList"> - <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/> - <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/> - <listOptionValue builtIn="false" value=" -fPIE"/> - <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/> - </option> - <option id="gnu.cpp.compiler.option.include.paths.389112477" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> - <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/lib-common/res/common/edje}""/> </option> <option id="sbi.gnu.cpp.compiler.option.frameworks.core.697230212" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs"> <listOptionValue builtIn="false" value="Native_API"/> diff --git a/alarm-app/inc/List/AlarmItem.h b/alarm-app/inc/List/AlarmItem.h index 5260f5f..88831c0 100644 --- a/alarm-app/inc/List/AlarmItem.h +++ b/alarm-app/inc/List/AlarmItem.h @@ -32,31 +32,25 @@ namespace List class AlarmItem: public Ux::SelectItem { public: - explicit AlarmItem(Common::Model::Alarm &alarm); - - protected: /** - * @see SelectItem::getDefaultResult() + * @brief Create alarm item. + * @param[in] alarm Alarm associated with the item */ - virtual Ux::SelectResult getDefaultResult() const override; + explicit AlarmItem(Common::Model::Alarm &alarm); /** - * @see GenItem::getItemClass() + * @brief Update the item according to the changes. + * @param[in] changes Mask specifying which data has changed */ - virtual Elm_Gen_Item_Class *getItemClass() const override; + void update(int changes); - /** - * @see GenItem::getText() - */ + private: + virtual Ux::SelectResult getDefaultResult() const override; + virtual Elm_Gen_Item_Class *getItemClass() const override; 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; + virtual void onSelected() override; + void onAlarmEnabled(Evas_Object *check, void *eventInfo); Common::Model::Alarm &m_Alarm; }; diff --git a/alarm-app/src/AlarmApp.cpp b/alarm-app/src/AlarmApp.cpp index 6f6e8ea..6e935cc 100644 --- a/alarm-app/src/AlarmApp.cpp +++ b/alarm-app/src/AlarmApp.cpp @@ -19,6 +19,7 @@ #include "Ui/Window.h" #include "Utils/Logger.h" +#include "CommonPath.h" #include "DaySelectorPath.h" #include "ListPath.h" #include "OperationDefaultController.h" @@ -40,6 +41,7 @@ bool AlarmApp::onCreate() elm_theme_overlay_add(nullptr, App::getResourcePath(PATH_DAY_SELECTOR_LAYOUT).c_str()); elm_theme_extension_add(nullptr, App::getResourcePath(PATH_LIST_ITEM_STYLE).c_str()); + elm_theme_extension_add(nullptr, App::getResourcePath(PATH_ALARM_CHECK_STYLE).c_str()); Application::onCreate(); getWindow()->setRotationEnabled(true); diff --git a/alarm-app/src/Input/DaySelector.cpp b/alarm-app/src/Input/DaySelector.cpp index 9d2f791..52fbba2 100644 --- a/alarm-app/src/Input/DaySelector.cpp +++ b/alarm-app/src/Input/DaySelector.cpp @@ -15,10 +15,9 @@ */ #include "Input/DaySelector.h" +#include "Common/Format.h" #include "Utils/Callback.h" -#include <app_i18n.h> - using namespace Input; DaySelector::DaySelector() @@ -82,17 +81,7 @@ void DaySelector::updateLocale() void DaySelector::updateNames() { - const char *names[] = { - _("WDS_ALM_BUTTON_S_M_SUNDAY_ABB"), - _("WDS_ALM_BUTTON_M_M_MONDAY_ABB"), - _("WDS_ALM_BUTTON_T_M_TUESDAY_ABB"), - _("WDS_ALM_BUTTON_W_M_WEDNESDAY_ABB"), - _("WDS_ALM_BUTTON_T_M_THURSDAY_ABB"), - _("WDS_ALM_BUTTON_F_M_FRIDAY_ABB"), - _("WDS_ALM_BUTTON_S_M_SATURDAY_ABB") - }; - - elm_dayselector_weekdays_names_set(getEvasObject(), names); + elm_dayselector_weekdays_names_set(getEvasObject(), Common::getWeekdayLetters().begin()); } void DaySelector::updateWeekStart(i18n_ucalendar_h calendar) diff --git a/alarm-app/src/List/AlarmItem.cpp b/alarm-app/src/List/AlarmItem.cpp index ab6ab73..e2a8e76 100644 --- a/alarm-app/src/List/AlarmItem.cpp +++ b/alarm-app/src/List/AlarmItem.cpp @@ -14,12 +14,25 @@ * limitations under the License. */ -#include "Common/Model/Alarm.h" #include "List/AlarmItem.h" +#include "Input/InputView.h" + +#include "Common/Format.h" +#include "Common/Model/Alarm.h" +#include "Common/Model/AlarmConsumer.h" + +#include "Ui/Genlist.h" +#include "Ui/Navigator.h" +#include "Utils/Callback.h" + +#include "CommonPath.h" -#include <system_settings.h> +#define PART_TIME "elm.text" +#define PART_DATE "elm.text.1" +#define PART_ON_OFF "elm.icon" -#define BUF_SIZE 16 +#define AM_PM_FONT_SIZE 26 +#define ON_OFF_WH 76 using namespace Common::Model; using namespace List; @@ -29,6 +42,23 @@ AlarmItem::AlarmItem(Alarm &alarm) { } +void AlarmItem::update(int changes) +{ + if (changes & Alarm::ChangedDate) { + GenItem::update(PART_TIME, ELM_GENLIST_ITEM_FIELD_TEXT); + if (!m_Alarm.getRepeat()) { + GenItem::update(PART_DATE, ELM_GENLIST_ITEM_FIELD_TEXT); + } + } + if (changes & Alarm::ChangedRepeat) { + GenItem::update(PART_DATE, ELM_GENLIST_ITEM_FIELD_TEXT); + } + if (changes & Alarm::ChangedEnabled) { + Evas_Object *check = elm_object_item_part_content_get(getObjectItem(), PART_ON_OFF); + elm_check_state_set(check, m_Alarm.isEnabled()); + } +} + Ux::SelectResult AlarmItem::getDefaultResult() const { return { 0, &m_Alarm }; @@ -42,13 +72,14 @@ Elm_Gen_Item_Class *AlarmItem::getItemClass() const 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 + if (strcmp(part, PART_TIME) == 0) { + return strdup(Common::formatTime(m_Alarm.getDate(), AM_PM_FONT_SIZE)); + } else if (strcmp(part, PART_DATE) == 0) { + if (m_Alarm.getRepeat()) { + return strdup(Common::formatRepeat(m_Alarm.getRepeat())); + } else { + return strdup(Common::formatDate(m_Alarm.getDate())); + } } return nullptr; @@ -56,8 +87,17 @@ char *AlarmItem::getText(Evas_Object *parent, const char *part) Evas_Object *AlarmItem::getContent(Evas_Object *parent, const char *part) { - if (strcmp(part, "elm.icon") == 0) { - //TODO Make on/off alarm icon + if (strcmp(part, PART_ON_OFF) == 0) { + Evas_Object *check = elm_check_add(parent); + elm_object_style_set(check, STYLE_CHECK_ALARM_ON_OFF); + elm_check_state_set(check, m_Alarm.isEnabled()); + + evas_object_propagate_events_set(check, EINA_FALSE); + evas_object_size_hint_min_set(check, ON_OFF_WH, ON_OFF_WH); + evas_object_smart_callback_add(check, "changed", + makeCallback(&AlarmItem::onAlarmEnabled), this); + + return check; } else if (strcmp(part, "elm.swallow.center_check") == 0) { SelectItem::getContent(parent, part); } @@ -65,9 +105,15 @@ Evas_Object *AlarmItem::getContent(Evas_Object *parent, const char *part) return nullptr; } -bool AlarmItem::is24HourFormat() const +void AlarmItem::onSelected() +{ + if (auto navigator = getParent()->findParent<Ui::Navigator>()) { + navigator->navigateTo(new Input::InputView(m_Alarm)); + } +} + +void AlarmItem::onAlarmEnabled(Evas_Object *check, void *eventInfo) { - bool is24hour = true; - system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, &is24hour); - return is24hour; + m_Alarm.setEnabled(elm_check_state_get(check)); + AlarmConsumer::getInstance().updateAlarm(m_Alarm, nullptr); } diff --git a/alarm-app/src/List/AlarmsView.cpp b/alarm-app/src/List/AlarmsView.cpp index c65fead..2dbf59e 100644 --- a/alarm-app/src/List/AlarmsView.cpp +++ b/alarm-app/src/List/AlarmsView.cpp @@ -94,8 +94,7 @@ void AlarmsView::onAlarmInserted(::Model::DataItem &dataItem) void AlarmsView::onAlarmUpdated(AlarmItem *item, int changes) { - /* TODO: Use changes to update specific parts */ - item->update("*", ELM_GENLIST_ITEM_FIELD_ALL); + item->update(changes); } void AlarmsView::onAlarmDeleted(AlarmItem *item) diff --git a/alarm-widget/.cproject b/alarm-widget/.cproject index 2c0118d..8bec9d2 100644 --- a/alarm-widget/.cproject +++ b/alarm-widget/.cproject @@ -128,6 +128,7 @@ <listOptionValue builtIn="false" value=""${workspace_loc:/lib-apps-common/inc}""/> <listOptionValue builtIn="false" value=""${workspace_loc:/lib-common/inc}""/> <listOptionValue builtIn="false" value=""${workspace_loc:/alarm-widget/res/widget/edje}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/lib-common/res/common/edje}""/> </option> <option id="sbi.gnu.cpp.compiler.option.frameworks.core.1604887711" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs"> <listOptionValue builtIn="false" value="Native_API"/> diff --git a/alarm-widget/res/widget/edje/WidgetLayout.h b/alarm-widget/res/widget/edje/WidgetLayout.h index 16170bf..fce3a17 100644 --- a/alarm-widget/res/widget/edje/WidgetLayout.h +++ b/alarm-widget/res/widget/edje/WidgetLayout.h @@ -21,7 +21,6 @@ #define LAYOUT_NO_ALARM "no_alarm" #define LAYOUT_ALARM "alarm" -#define STYLE_CHECK_ALARM_ON_OFF "alarm_on_off" #define PART_NO_ALARM_TEXT "text.no_alarm" #define PART_AM_PM "text.am_pm" diff --git a/alarm-widget/res/widget/edje/WidgetPath.h b/alarm-widget/res/widget/edje/WidgetPath.h index d0d2c67..30c11b9 100644 --- a/alarm-widget/res/widget/edje/WidgetPath.h +++ b/alarm-widget/res/widget/edje/WidgetPath.h @@ -21,10 +21,6 @@ #define WIDGET_EDJ_DIR "widget/edje/" #define PATH_WIDGET_LAYOUT WIDGET_EDJ_DIR"widget-layout.edj" -#define PATH_ALARM_CHECK_STYLE WIDGET_EDJ_DIR"alarm-check-style.edj" - #define PATH_NO_ALARM WIDGET_IMG_DIR"alarm_widget_no_alarm.png" -#define PATH_ALARM_ICON WIDGET_IMG_DIR"alarm_widget_icon.png" -#define PATH_ALARM_ICON_BG WIDGET_IMG_DIR"alarm_widget_icon_bg.png" #endif /* WIDGET_PATH_H */ diff --git a/alarm-widget/src/AlarmWidget.cpp b/alarm-widget/src/AlarmWidget.cpp index 2a456c6..21edd9a 100644 --- a/alarm-widget/src/AlarmWidget.cpp +++ b/alarm-widget/src/AlarmWidget.cpp @@ -20,6 +20,8 @@ #include "Ui/Window.h" #include "Utils/Callback.h" #include "Utils/Logger.h" + +#include "CommonPath.h" #include "WidgetLayout.h" #define TAG_PREFIX "<match>" diff --git a/lib-common/.cproject b/lib-common/.cproject index 960d153..7f4056a 100644 --- a/lib-common/.cproject +++ b/lib-common/.cproject @@ -26,7 +26,7 @@ <option id="gnu.cpp.compiler.option.optimization.level.1398093091" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/> <option defaultValue="gnu.cpp.compiler.debugging.level.max" id="sbi.gnu.cpp.compiler.option.debugging.level.core.512256296" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" valueType="enumerated"/> <option id="sbi.gnu.cpp.compiler.option.1379021540" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs"> - <listOptionValue builtIn="false" value="wearable-3.0-emulator.core_llvm37.i386.core.app"/> + <listOptionValue builtIn="false" value="wearable-3.0-emulator.core_llvm37.i386.core.sharedLib"/> </option> <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.1812812065" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath"> <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> @@ -225,7 +225,7 @@ <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.676051183" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/> <option defaultValue="gnu.c.debugging.level.max" id="sbi.gnu.c.compiler.option.debugging.level.core.202562662" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" valueType="enumerated"/> <option id="sbi.gnu.c.compiler.option.682801576" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs"> - <listOptionValue builtIn="false" value="wearable-3.0-emulator.core_llvm37.i386.core.app"/> + <listOptionValue builtIn="false" value="wearable-3.0-emulator.core_llvm37.i386.core.sharedLib"/> </option> <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.925347047" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath"> <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> @@ -361,11 +361,22 @@ <tool id="org.tizen.nativecore.tool.ast.cpp.1727772058" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/> <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.mergelib.178013541" name="Archive Generator" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver.mergelib"/> <tool id="org.tizen.nativecore.tool.sbi.po.compiler.284142865" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/> - <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.2065305140" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/> + <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.2065305140" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"> + <option id="sbi.gnu.edc.compiler.option.misc.id.1235266472" superClass="sbi.gnu.edc.compiler.option.misc.id" valueType="stringList"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}}/edje""/> + </option> + <option id="sbi.gnu.edc.compiler.option.misc.sd.259343775" superClass="sbi.gnu.edc.compiler.option.misc.sd" valueType="stringList"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}}/edje""/> + </option> + <option id="sbi.gnu.edc.compiler.option.misc.fd.114004466" superClass="sbi.gnu.edc.compiler.option.misc.fd" valueType="stringList"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}}/edje""/> + </option> + </tool> </toolChain> </folderInfo> <sourceEntries> <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/> + <entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="res"/> <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/> </sourceEntries> </configuration> diff --git a/alarm-widget/edje/widget/images/alarm_widget_icon.png b/lib-common/edje/common/images/alarm_widget_icon.png Binary files differindex 3bbe63d..3bbe63d 100644 --- a/alarm-widget/edje/widget/images/alarm_widget_icon.png +++ b/lib-common/edje/common/images/alarm_widget_icon.png diff --git a/alarm-widget/edje/widget/images/alarm_widget_icon_bg.png b/lib-common/edje/common/images/alarm_widget_icon_bg.png Binary files differindex b70b6d0..b70b6d0 100644 --- a/alarm-widget/edje/widget/images/alarm_widget_icon_bg.png +++ b/lib-common/edje/common/images/alarm_widget_icon_bg.png diff --git a/lib-common/inc/Common/Format.h b/lib-common/inc/Common/Format.h new file mode 100644 index 0000000..137f022 --- /dev/null +++ b/lib-common/inc/Common/Format.h @@ -0,0 +1,59 @@ +/* + * 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 COMMON_FORMAT_H +#define COMMON_FORMAT_H + +#include <ctime> +#include <tizen.h> +#include "Utils/Range.h" + +namespace Common +{ + /** + * @return Localized first letters of weekday names. + */ + EXPORT_API Utils::Range<const char **> getWeekdayLetters(); + + /** + * @return Whether 24-hour time format is set. + */ + EXPORT_API bool is24HourFormat(); + + /** + * @brief Create string representation for given time. + * @param[in] time Time to format + * @param[in] fontSize Font size for AM/PM representation + * @return Formatted time. + */ + EXPORT_API const char *formatTime(const tm &time, int fontSize); + + /** + * @brief Create string representation for given date. + * @param[in] date Time to format + * @return Formatted date. + */ + EXPORT_API const char *formatDate(const tm &date); + + /** + * @brief Create string representation for weekly repeat mask. + * @param[in] repeat Repeat mask to format + * @return Formatted weekday letters with highlighted repeat. + */ + EXPORT_API const char *formatRepeat(int repeat); +} + +#endif /* COMMON_FORMAT_H */ diff --git a/lib-common/res/common/edje/CommonPath.h b/lib-common/res/common/edje/CommonPath.h new file mode 100644 index 0000000..be24b8f --- /dev/null +++ b/lib-common/res/common/edje/CommonPath.h @@ -0,0 +1,30 @@ +/* + * 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 COMMON_PATH_H +#define COMMON_PATH_H + +#define COMMON_EDJ_DIR "common/edje/" +#define COMMON_IMG_DIR "common/images/" + +#define PATH_ALARM_CHECK_STYLE COMMON_EDJ_DIR"alarm-check-style.edj" + +#define PATH_ALARM_ICON COMMON_IMG_DIR"alarm_widget_icon.png" +#define PATH_ALARM_ICON_BG COMMON_IMG_DIR"alarm_widget_icon_bg.png" + +#define STYLE_CHECK_ALARM_ON_OFF "alarm_on_off" + +#endif /* COMMON_PATH_H */ diff --git a/alarm-widget/res/widget/edje/alarm-check-style.edc b/lib-common/res/common/edje/alarm-check-style.edc index 7a32e29..3765803 100644 --- a/alarm-widget/res/widget/edje/alarm-check-style.edc +++ b/lib-common/res/common/edje/alarm-check-style.edc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "WidgetLayout.h" +#include "CommonPath.h" collections { base_scale: 1.3; @@ -27,6 +27,8 @@ collections { parts { image { "image.bg"; desc { "default"; + aspect: 1 1; + aspect_preference: HORIZONTAL; image.normal: PATH_ALARM_ICON_BG; color: 77 207 255 255; } @@ -37,6 +39,8 @@ collections { } image { "image.alarm"; desc { "default"; + aspect: 1 1; + aspect_preference: HORIZONTAL; image.normal: PATH_ALARM_ICON; color: 77 207 255 255; } diff --git a/lib-common/src/Common/Format.cpp b/lib-common/src/Common/Format.cpp new file mode 100644 index 0000000..84a52cc --- /dev/null +++ b/lib-common/src/Common/Format.cpp @@ -0,0 +1,98 @@ +/* + * 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/Format.h" + +#include <app_i18n.h> +#include <string> +#include <system_settings.h> + +#define DAY_COUNT 7 +#define TIME_BUFFER_SIZE 64 +#define DATE_BUFFER_SIZE 32 +#define REPEAT_BUFFER_SIZE 256 + +namespace +{ + const char *weekdays[DAY_COUNT] = { + "WDS_ALM_BUTTON_S_M_SUNDAY_ABB", + "WDS_ALM_BUTTON_M_M_MONDAY_ABB", + "WDS_ALM_BUTTON_T_M_TUESDAY_ABB", + "WDS_ALM_BUTTON_W_M_WEDNESDAY_ABB", + "WDS_ALM_BUTTON_T_M_THURSDAY_ABB", + "WDS_ALM_BUTTON_F_M_FRIDAY_ABB", + "WDS_ALM_BUTTON_S_M_SATURDAY_ABB" + }; +} + +Utils::Range<const char **> Common::getWeekdayLetters() +{ + static const char *days[DAY_COUNT]; + for (size_t i = 0; i < Utils::count(days); ++i) { + days[i] = _(weekdays[i]); + } + return days; +} + +bool Common::is24HourFormat() +{ + bool is24hour = true; + system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, &is24hour); + return is24hour; +} + +const char *Common::formatTime(const tm &time, int fontSize) +{ + static char buffer[TIME_BUFFER_SIZE]; + if (is24HourFormat()) { + strftime(buffer, sizeof(buffer), "%H:%M", &time); + } else { + char format[TIME_BUFFER_SIZE]; + snprintf(format, sizeof(format), "%%I:%%M <font_size=%d>%%p</font_size>", fontSize); + strftime(buffer, sizeof(buffer), format, &time); + } + + return buffer; +} + +const char *Common::formatDate(const tm &date) +{ + static char buffer[DATE_BUFFER_SIZE]; + /* TODO: Use i18n for locale-dependent pattern generation */ + strftime(buffer, sizeof(buffer), "%a, %d %b", &date); + return buffer; +} + +const char *Common::formatRepeat(int repeat) +{ + static std::string buffer; + auto days = getWeekdayLetters(); + + buffer.clear(); + for (int i = 0; i < DAY_COUNT; ++i) { + if (!buffer.empty()) { + buffer += " "; + } + if (repeat & (1 << i)) { + buffer += "<match>"; + buffer += days[i]; + buffer += "</match>"; + } else { + buffer += days[i]; + } + } + return buffer.c_str(); +} |