<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"/>
<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""/>
<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"/>
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;
};
#include "Ui/Window.h"
#include "Utils/Logger.h"
+#include "CommonPath.h"
#include "DaySelectorPath.h"
#include "ListPath.h"
#include "OperationDefaultController.h"
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);
*/
#include "Input/DaySelector.h"
+#include "Common/Format.h"
#include "Utils/Callback.h"
-#include <app_i18n.h>
-
using namespace Input;
DaySelector::DaySelector()
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)
* 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;
{
}
+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 };
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;
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);
}
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);
}
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)
<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"/>
#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"
#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 */
+++ /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 "WidgetLayout.h"
-
-collections {
- base_scale: 1.3;
-
- group { "elm/check/base/"STYLE_CHECK_ALARM_ON_OFF;
- images {
- image: PATH_ALARM_ICON_BG COMP;
- image: PATH_ALARM_ICON COMP;
- }
- parts {
- image { "image.bg";
- desc { "default";
- image.normal: PATH_ALARM_ICON_BG;
- color: 77 207 255 255;
- }
- desc { "checked";
- inherit: "default";
- color: 77 207 255 102;
- }
- }
- image { "image.alarm";
- desc { "default";
- image.normal: PATH_ALARM_ICON;
- color: 77 207 255 255;
- }
- desc { "checked";
- inherit: "default";
- color: 77 207 255 102;
- }
- }
- }
- programs {
- program {
- signal: "elm,state,check,on";
- source: "elm";
- action: STATE_SET "default";
- target: "image.alarm";
- target: "image.bg";
- }
- program {
- signal: "elm,state,check,off";
- source: "elm";
- action: STATE_SET "checked";
- target: "image.alarm";
- target: "image.bg";
- }
- program {
- signal: "mouse,clicked,*";
- source: "*";
- action: SIGNAL_EMIT "elm,action,check,toggle" "";
- }
- }
- }
-}
\ No newline at end of file
#include "Ui/Window.h"
#include "Utils/Callback.h"
#include "Utils/Logger.h"
+
+#include "CommonPath.h"
#include "WidgetLayout.h"
#define TAG_PREFIX "<match>"
<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""/>
<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""/>
<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>
--- /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 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 */
--- /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 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 */
--- /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 "CommonPath.h"
+
+collections {
+ base_scale: 1.3;
+
+ group { "elm/check/base/"STYLE_CHECK_ALARM_ON_OFF;
+ images {
+ image: PATH_ALARM_ICON_BG COMP;
+ image: PATH_ALARM_ICON COMP;
+ }
+ parts {
+ image { "image.bg";
+ desc { "default";
+ aspect: 1 1;
+ aspect_preference: HORIZONTAL;
+ image.normal: PATH_ALARM_ICON_BG;
+ color: 77 207 255 255;
+ }
+ desc { "checked";
+ inherit: "default";
+ color: 77 207 255 102;
+ }
+ }
+ image { "image.alarm";
+ desc { "default";
+ aspect: 1 1;
+ aspect_preference: HORIZONTAL;
+ image.normal: PATH_ALARM_ICON;
+ color: 77 207 255 255;
+ }
+ desc { "checked";
+ inherit: "default";
+ color: 77 207 255 102;
+ }
+ }
+ }
+ programs {
+ program {
+ signal: "elm,state,check,on";
+ source: "elm";
+ action: STATE_SET "default";
+ target: "image.alarm";
+ target: "image.bg";
+ }
+ program {
+ signal: "elm,state,check,off";
+ source: "elm";
+ action: STATE_SET "checked";
+ target: "image.alarm";
+ target: "image.bg";
+ }
+ program {
+ signal: "mouse,clicked,*";
+ source: "*";
+ action: SIGNAL_EMIT "elm,action,check,toggle" "";
+ }
+ }
+ }
+}
\ No newline at end of file
--- /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/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();
+}