--- /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 OPERATION_PICK_CONTROLLER_H
+#define OPERATION_PICK_CONTROLLER_H
+
+#include "App/OperationController.h"
+#include "Ux/SelectTypes.h"
+
+class OperationPickController : public App::OperationController
+{
+private:
+ virtual void onRequest(const char *operation, app_control_h request) override;
+ bool onSelected(Ux::SelectResults results);
+};
+
+#endif /* OPERATION_PICK_CONTROLLER_H */
#include "DaySelectorPath.h"
#include "ListPath.h"
#include "OperationDefaultController.h"
+#include "OperationPickController.h"
App::OperationController *AlarmApp::createController(const char *operation)
{
- if (strcmp(operation, APP_CONTROL_OPERATION_DEFAULT) == 0
- || strcmp(operation, APP_CONTROL_OPERATION_MAIN) == 0) {
+ if (strcmp(operation, APP_CONTROL_OPERATION_DEFAULT) == 0) {
return new OperationDefaultController();
+ } else if (strcmp(operation, APP_CONTROL_OPERATION_PICK) == 0) {
+ return new OperationPickController();
}
return nullptr;
void AlarmItem::onSelected()
{
+ if (getSelectMode() != Ux::SelectNone) {
+ SelectItem::onSelected();
+ return;
+ }
+
if (auto navigator = getParent()->findParent<Ui::Navigator>()) {
navigator->navigateTo(new Input::InputView(m_Alarm));
}
auto item = new AlarmItem(static_cast<Alarm &>(dataItem));
dataItem.onUpdated() += { std::bind(&AlarmsView::onAlarmUpdated, this, item, _1), item };
dataItem.onDeleted() += { std::bind(&AlarmsView::onAlarmDeleted, this, item), item };
+ addSelectItem(item);
return item;
}
void AlarmsView::onAlarmDeleted(AlarmItem *item)
{
+ removeSelectItem(item);
delete item;
}
--- /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 "OperationPickController.h"
+#include "App/AppControl.h"
+#include "Common/Model/Alarm.h"
+#include "List/AlarmsView.h"
+#include "Ui/Navigator.h"
+#include <string>
+
+using namespace Common::Model;
+using namespace std::placeholders;
+
+void OperationPickController::onRequest(const char *operation, app_control_h request)
+{
+ List::AlarmsView *view = new List::AlarmsView();
+ view->setSelectMode(Ux::SelectSingle);
+ view->setSelectCallback(std::bind(&OperationPickController::onSelected, this, _1));
+ getNavigator()->navigateTo(view);
+}
+
+bool OperationPickController::onSelected(Ux::SelectResults results)
+{
+ auto alarm = (Alarm *)results.begin()->value.data;
+
+ app_control_h reply = nullptr;
+ app_control_create(&reply);
+ app_control_add_extra_data(reply, APP_CONTROL_DATA_SELECTED, std::to_string(alarm->getId()).c_str());
+ app_control_reply_to_launch_request(reply, getRequest(), APP_CONTROL_RESULT_SUCCEEDED);
+ app_control_destroy(reply);
+
+ return true;
+}
<label xml:lang="zh-tw">鬧鐘</label>
<icon>org.tizen.alarm.png</icon>
</ui-application>
+ <ui-application appid="org.tizen.alarm.app-control" exec="alarm-app" multiple="true" nodisplay="true" taskmanage="false" type="capp">
+ <label>Alarm</label>
+ <label xml:lang="ar-ae">تنبيه</label>
+ <label xml:lang="az-az">Siqnal</label>
+ <label xml:lang="bg-bg">Аларма</label>
+ <label xml:lang="ca-es">Alarma</label>
+ <label xml:lang="cs-cz">Upozornění</label>
+ <label xml:lang="da-dk">Alarm</label>
+ <label xml:lang="de-de">Alarm</label>
+ <label xml:lang="el-gr">Ξυπνητήρι</label>
+ <label xml:lang="en-gb">Alarm</label>
+ <label xml:lang="en-ph">Alarm</label>
+ <label xml:lang="en-us">Alarm</label>
+ <label xml:lang="es-es">Alarma</label>
+ <label xml:lang="es-mx">Alarma</label>
+ <label xml:lang="et-ee">Märguanne</label>
+ <label xml:lang="eu-es">Alarma</label>
+ <label xml:lang="fi-fi">Hälytys</label>
+ <label xml:lang="fr-ca">Alarme</label>
+ <label xml:lang="fr-fr">Alarme</label>
+ <label xml:lang="ga-ie">Aláram</label>
+ <label xml:lang="gl-es">Alarma</label>
+ <label xml:lang="hr-hr">Alarm</label>
+ <label xml:lang="hu-hu">Jelzés</label>
+ <label xml:lang="hy-am">Տագնապ</label>
+ <label xml:lang="is-is">Vekjari</label>
+ <label xml:lang="it-it">Sveglia</label>
+ <label xml:lang="ja-jp">アラーム</label>
+ <label xml:lang="ka-ge">სიგნალი</label>
+ <label xml:lang="kk-kz">Оятар</label>
+ <label xml:lang="ko-kr">알람</label>
+ <label xml:lang="lt-lt">Signalas</label>
+ <label xml:lang="lv-lv">Signāls</label>
+ <label xml:lang="mk-mk">Аларм</label>
+ <label xml:lang="nb-no">Alarm</label>
+ <label xml:lang="nl-nl">Alarm</label>
+ <label xml:lang="pl-pl">Alarm</label>
+ <label xml:lang="pt-br">Alarme</label>
+ <label xml:lang="pt-pt">Alarme</label>
+ <label xml:lang="ro-ro">Alarmă</label>
+ <label xml:lang="ru-ru">Будильник</label>
+ <label xml:lang="sk-sk">Budík</label>
+ <label xml:lang="sl-si">Alarm</label>
+ <label xml:lang="sr-rs">Beleška</label>
+ <label xml:lang="sv-se">Alarm</label>
+ <label xml:lang="tr-tr">Alarm</label>
+ <label xml:lang="uk-ua">Будильник</label>
+ <label xml:lang="uz-uz">Uyg‘otgich</label>
+ <label xml:lang="zh-cn">闹钟</label>
+ <label xml:lang="zh-hk">鬧鐘</label>
+ <label xml:lang="zh-tw">鬧鐘</label>
+ <icon>org.tizen.alarm.png</icon>
+ <app-control>
+ <operation name="http://tizen.org/appcontrol/operation/pick"/>
+ <mime name="application/vnd.tizen.alarm"/>
+ </app-control>
+ </ui-application>
<privileges>
<privilege>http://tizen.org/privilege/datasharing</privilege>
</privileges>
Evas_Object *createContentLayout(Evas_Object *parent);
Evas_Object *createEmptyLayout(Evas_Object *parent);
void updateEmptyState();
+ void onCheckedPressed(Evas_Object *obj, void *eventInfo);
void onCreatePressed(Evas_Object *obj, void *eventInfo);
+ void onPickReply(app_control_h request, app_control_h reply, app_control_result_e result);
+
Evas_Object *m_Layout;
Common::Model::Alarm *m_Alarm;
};
#define TEXT_NO_ALARM_H 42
#define TEXT_NO_ALARM_T 16
-#define TIME_L 62
#define TIME_T 59
-#define TIME_W 244
#define TIME_H 95
#define REPEAT_T 8
-#define REPEAT_L 90
-#define REPEAT_W 180
#define REPEAT_H 41
#define ON_OFF_T 221
style {
name: "time_style";
base: "font=Tizen:style=Thin font_size=79 align=center color=#ffffff ellipsis=-1.0";
- tag: "match" "+font_size=40 font=Tizen:style=Regular";
}
style {
name: "time_disabled_style";
base: "font=Tizen:style=Thin font_size=79 align=center color=#ffffff4C ellipsis=-1.0";
- tag: "match" "+font_size=40 font=Tizen:style=Regular";
}
style {
name: "repeat_style";
group { LAYOUT_ALARM;
parts {
- spacer { "spacer.time.left_top"; scale;
+ spacer { "spacer.time.top"; scale;
desc { "default";
- fixed: 1 1;
- min: TIME_L TIME_T;
- align: 0.0 0.0;
- rel2.relative: 0.0 0.0;
+ fixed: 0 1;
+ min: 0 TIME_T;
+ align: 0.5 0.0;
+ rel2.relative: 1.0 0.0;
}
}
textblock { PART_TIME; scale;
desc { "default";
- fixed: 1 1;
- min: TIME_W TIME_H;
- align: 0.0 0.0;
- rel1 { relative: 1.0 1.0; to: "spacer.time.left_top"; }
- rel2 { relative: 1.0 1.0; to: "spacer.time.left_top"; }
+ fixed: 0 1;
+ min: 0 TIME_H;
+ align: 0.5 0.0;
+ rel1 { relative: 0.0 1.0; to_y: "spacer.time.top"; }
+ rel2 { relative: 1.0 1.0; to_y: "spacer.time.top"; }
text.style: "time_style";
}
desc { "disabled";
text.style: "time_disabled_style";
}
}
- spacer { "spacer.repeat.left_top"; scale;
+ spacer { "spacer.repeat.top"; scale;
desc { "default";
- fixed: 1 1;
- min: REPEAT_L REPEAT_T;
- align: 0.0 1.0;
+ fixed: 0 1;
+ min: 0 REPEAT_T;
+ align: 0.5 1.0;
rel1 { relative: 0.0 1.0; to_y: PART_TIME; }
- rel2 { relative: 0.0 1.0; to_y: PART_TIME; }
+ rel2 { relative: 1.0 1.0; to_y: PART_TIME; }
}
}
textblock { PART_REPEAT; scale;
desc { "default";
- fixed: 1 1;
- min: REPEAT_W REPEAT_H;
- align: 0.0 0.0;
- rel1 { relative: 1.0 0.0; to: "spacer.repeat.left_top"; }
- rel2 { relative: 1.0 0.0; to: "spacer.repeat.left_top"; }
+ fixed: 0 1;
+ min: 0 REPEAT_H;
+ align: 0.5 0.0;
+ rel1 { relative: 0.0 1.0; to_y: "spacer.repeat.top"; }
+ rel2 { relative: 1.0 1.0; to_y: "spacer.repeat.top"; }
text.style: "repeat_style";
}
desc { "disabled";
*/
#include "AlarmWidget.h"
+#include "App/AppControl.h"
+#include "App/AppControlUtils.h"
#include "App/Path.h"
+#include "Common/Format.h"
#include "Common/Model/Alarm.h"
+#include "Common/Model/AlarmConsumer.h"
#include "Ui/Window.h"
#include "Utils/Callback.h"
#include "Utils/Logger.h"
#include "CommonPath.h"
#include "WidgetLayout.h"
-
-#define TAG_PREFIX "<match>"
-#define TAG_SUFFIX "</match>"
+#include <stdlib.h>
using namespace Model;
using namespace Common;
using namespace Common::Model;
+#define TIME_SIZE 40
+#define APP_CONTROL_MIME_ALARM "application/vnd.tizen.alarm"
+
AlarmWidget::AlarmWidget()
: m_Layout(nullptr), m_Alarm(nullptr)
{
Evas_Object *layout = elm_layout_add(parent);
elm_layout_file_set(layout, App::getResourcePath(PATH_WIDGET_LAYOUT).c_str(), LAYOUT_ALARM);
+ elm_object_part_text_set(layout, PART_TIME, formatTime(m_Alarm->getDate(), TIME_SIZE));
+ elm_object_part_text_set(layout, PART_REPEAT, formatRepeat(m_Alarm->getRepeat()));
+
+ Evas_Object *check = elm_check_add(layout);
+ elm_check_state_set(check, m_Alarm->isEnabled());
+ elm_object_style_set(check, STYLE_CHECK_ALARM_ON_OFF);
+ elm_object_part_content_set(layout, PART_ON_OFF, check);
+ evas_object_smart_callback_add(check, "changed", makeCallback(&AlarmWidget::onCheckedPressed), this);
+
return layout;
}
elm_object_part_content_set(parent, "elm.swallow.content", m_Layout);
}
+void AlarmWidget::onCheckedPressed(Evas_Object *obj, void *eventInfo)
+{
+ /* TODO add implementation */
+}
+
void AlarmWidget::onCreatePressed(Evas_Object *obj, void *eventInfo)
{
+ App::AppControl request(APP_CONTROL_OPERATION_PICK, APP_CONTROL_MIME_ALARM);
+ request.launch(makeCallbackWithLastParam(&AlarmWidget::onPickReply), this);
+ request.detach();
+}
+
+void AlarmWidget::onPickReply(app_control_h request, app_control_h reply, app_control_result_e result)
+{
+ std::string path = App::getStringExtraData(reply, APP_CONTROL_DATA_SELECTED);
+ AlarmConsumer::getInstance().getAlarm(atoi(path.c_str()), [this](::Model::DataProvider::DataList dataList) {
+ m_Alarm = static_cast<Alarm *>(dataList.front());
+ updateEmptyState();
+ });
}
* @brief Create string representation for given time.
* @param[in] time Time to format
* @param[in] fontSize Font size for AM/PM representation
+ * @param[in] fontStyle Font style for AM/PM representation
* @return Formatted time.
*/
- EXPORT_API const char *formatTime(const tm &time, int fontSize);
+ EXPORT_API const char *formatTime(const tm &time, int fontSize, const char *fontStyle = "Regular");
/**
* @brief Create string representation for given date.
return is24hour;
}
-const char *Common::formatTime(const tm &time, int fontSize)
+const char *Common::formatTime(const tm &time, int fontSize, const char *fontStyle)
{
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);
+ snprintf(format, sizeof(format), "%%I:%%M<font=Tizen:style=%s font_size=%d> %%p</font>", fontStyle, fontSize);
strftime(buffer, sizeof(buffer), format, &time);
}