--- /dev/null
+/*
+* Copyright 2016 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 _CLOCK_SYSTEM_SETTINGS_H_
+#define _CLOCK_SYSTEM_SETTINGS_H_
+
+#include <string>
+#include <system_settings.h>
+
+#include "Utils/EventBus.h"
+
+namespace utils {
+
+class SystemSettings {
+public:
+ /**
+ * @brief Event indicate that system language setting
+ * has changed.
+ */
+ class LanguageChanged : public Event {
+ };
+
+ /**
+ * @brief Event indicate that system-wide time fromat setting
+ * has changed.
+ */
+ class TimeFormatChanged : public Event {
+ };
+
+ /**
+ * @brief Returns current locale string
+ *
+ * @return string with currently set locale
+ */
+ static const char *GetLocale();
+
+ /**
+ * @brief Indicates whether the 24-hour clock is system-prefered.
+ *
+ * @return true if system prefers 24-hour clock, false if 12-hour.
+ */
+ static bool Is24HourFormatPrefered();
+
+ /**
+ * @brief Registers callbacks on system configuration change
+ *
+ * @return true on success, otherwise false
+ *
+ * @see Unregister()
+ */
+ static bool Register();
+
+ /**
+ * @brief Unregisters callbacks on system configuration change
+ *
+ * @see Register()
+ */
+ static void Unregister();
+
+ SystemSettings() = delete;
+ SystemSettings(const SystemSettings &) = delete;
+ SystemSettings &operator=(const SystemSettings &) = delete;
+ ~SystemSettings();
+
+private:
+ static void OnLanguageChanged(system_settings_key_e key, void *user_data);
+ static void OnTimeFormatChanged(system_settings_key_e key, void *user_data);
+
+ static char *locale_;
+ static bool is_24hour_format_prefered_;
+ static bool is_registered;
+};
+
+}
+
+#endif //_CLOCK_SYSTEM_SETTINGS_H_
#include "Common/Defines.h"
#include "Utils/EventBus.h"
#include "Utils/Serialization.h"
+#include "Utils/SystemSettings.h"
#include <map>
#include <ctime>
*/
class Time : public utils::ISerializable {
public:
- /**
- * @brief Event indicate that system-wide time fromat setting
- * has changed. The current prefered time format
- * can be obtained with Is24HourFormat function.
- */
- class PreferedTimeFormatChanged : public utils::Event {
- };
/** @brief Predefined string for 12-hour format */
static const char *FORMAT_TIME_12H;// = "h:mm";
/** @brief Predefined string for 32-hour format */
*/
static const std::string &GetCurrentTimezone();
- /**
- * @brief Indicates whether the 24-hour clock is system-prefered.
- *
- * @return true if system prefers 24-hour clock, false if 12-hour.
- */
- static bool Is24HourFormatPrefered();
-
private:
Time(double milliseconds, const std::string &tz);
int GetItemsCount();
private:
+
+ /**
+ * @brief Genlist item data model
+ */
+ struct LocationItemData {
+ /** container view */
+ WorldClockView *wc_view;
+ /** elm_time table */
+ Evas_Object *time;
+
+ /** location pointer */
+ const model::Location *location;
+
+ /** date to be displayed */
+ char *date;
+ /** city to be displayed */
+ char *city_country;
+ /** time offset to be displayed */
+ char *gmt_offset_relative;
+ /** time offset from GMT+0 in minutes */
+ int gmt_offset;
+ /** elm_genlist item handle */
+ Elm_Object_Item *it;
+ };
+
void CreateTimezoneDetails();
void CreateCustomLocationsList(Evas_Object *parent);
void CreateTimezoneCitiesList();
void UpdateTimezoneRelativeToLocal(int timezone_offset);
void UpdateTimezoneCitiesList(const model::Timezone *timezone);
+ void UpdateLocationItemLanguage(LocationItemData *data);
+ void UpdateCustomList();
+
static void ChangeTimezoneCb(void *data, Evas_Object *obj,
const char *emission, const char *source);
static void ItemClicked(void *data, Evas_Object *obj, void *event_info);
WorldClockMap *map_;
utils::Connection time_format_change_listener_;
+ utils::Connection language_change_listener_;
void TimeFormatChanged();
+ void LanguageChanged();
model::Timezone current_timezone_; /* Currently displayed timezone */
};
#include "app.h"
#include "Clock.h"
#include "Utils/TizenApp.h"
+#include "Utils/SystemSettings.h"
bool ClockApp::OnCreate()
{
+ if (!utils::SystemSettings::Register()) {
+ ERR("Could not register SystemSettings callbacks");
+ return false;
+ }
+
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
provider_ = new model::AlarmProvider();
main_ctrl_ = new controller::MainController(provider_);
ring_ctrl_ = new controller::RingController(provider_->GetAlarms());
+
return true;
}
if (language != NULL) {
elm_language_set(language);
free(language);
+
+ utils::SystemSettings::LanguageChanged languageChangedEvent;
+ utils::EventBus::FireEvent(languageChangedEvent);
}
}
delete provider_;
delete main_ctrl_;
delete ring_ctrl_;
+
+ utils::SystemSettings::Unregister();
}
void ClockApp::OnResume()
view_->SetTitle(alarm->GetName().c_str());
utils::Time time = alarm->GetTime();
- if (utils::Time::Is24HourFormatPrefered()) {
+ if (utils::SystemSettings::Is24HourFormatPrefered()) {
view_->SetTimeLabel(nullptr, time.Format("HH:mm").c_str(),
time.Format("EEE, d MMMM").c_str());
} else {
--- /dev/null
+/*
+* Copyright 2016 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 "Utils/SystemSettings.h"
+#include "Utils/Log.h"
+
+namespace utils {
+
+char *SystemSettings::locale_;
+bool SystemSettings::is_24hour_format_prefered_;
+bool SystemSettings::is_registered;
+
+
+void SystemSettings::Unregister()
+{
+ system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR);
+ system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE);
+
+ free(locale_);
+ locale_ = nullptr;
+ is_24hour_format_prefered_ = true;
+ is_registered = false;
+}
+
+bool SystemSettings::Register()
+{
+ if (is_registered)
+ return true;
+
+ int err = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR,
+ OnTimeFormatChanged, NULL);
+ if (err != SYSTEM_SETTINGS_ERROR_NONE) {
+ ERR("system_settings_set_changed_cb failed: %s", get_error_message(err));
+ return false;
+ }
+
+ err = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE,
+ OnLanguageChanged, NULL);
+ if (err != SYSTEM_SETTINGS_ERROR_NONE) {
+ ERR("system_settings_set_changed_cb failed: %s", get_error_message(err));
+ system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR);
+ return false;
+ }
+
+ err = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale_);
+ if (err != SYSTEM_SETTINGS_ERROR_NONE) {
+ ERR("system_settings_get_value_string failed[%d]: %s", err, get_error_message(err));
+ locale_ = getenv("LOCALE") ? strdup(getenv("LOCALE")) : strdup("");
+ }
+
+ err = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR,
+ &is_24hour_format_prefered_);
+ if (err != SYSTEM_SETTINGS_ERROR_NONE) {
+ ERR("system_settings_get_value_string failed[%d]: %s", err, get_error_message(err));
+ is_24hour_format_prefered_ = true;
+ }
+
+ is_registered = true;
+
+ return is_registered;
+}
+
+
+void SystemSettings::OnLanguageChanged(system_settings_key_e key, void *user_data)
+{
+ free(locale_);
+
+ int ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale_);
+ if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
+ ERR("system_settings_get_value_string failed: %s", get_error_message(ret));
+ locale_ = getenv("LOCALE") ? strdup(getenv("LOCALE")) : strdup("");
+ }
+
+ LanguageChanged event;
+ EventBus::FireEvent(event);
+}
+
+void SystemSettings::OnTimeFormatChanged(system_settings_key_e key, void *user_data)
+{
+ int err = system_settings_get_value_bool(
+ SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, &is_24hour_format_prefered_);
+ if (err != SYSTEM_SETTINGS_ERROR_NONE) {
+ ERR("system_settings_get_value_string failed[%d]: %s", err, get_error_message(err));
+ is_24hour_format_prefered_ = true;
+ }
+
+ TimeFormatChanged event;
+ EventBus::FireEvent(event);
+}
+
+const char *SystemSettings::GetLocale()
+{
+ return locale_;
+}
+
+bool SystemSettings::Is24HourFormatPrefered()
+{
+ return is_24hour_format_prefered_;
+}
+
+} //namespace utils
#include <cmath>
#include <ctime>
#include <Elementary.h>
-#include <system_settings.h>
using namespace utils;
{
if (!format) return "";
- const std::string *pattern = GetBestPattern(GetLocale(), format);
+ const std::string *pattern = GetBestPattern(SystemSettings::GetLocale(), format);
if (!pattern) {
ERR("Unable to get localized format.");
return "";
}
- return FormatInternal(milliseconds_, timezone_, GetLocale(), pattern->c_str());
+ return FormatInternal(milliseconds_, timezone_, SystemSettings::GetLocale(), pattern->c_str());
}
std::string Time::Format(const char *format) const
{
if (!format) return "";
- return FormatInternal(milliseconds_, timezone_, GetLocale(), format);
+ return FormatInternal(milliseconds_, timezone_, SystemSettings::GetLocale(), format);
}
std::string Time::FormatInternal(double time, const std::string &timezone,
return Time(double(handle), GetCurrentTimezone());
}
-static void TimeSystemSettingsLocaleLanguageChanged(system_settings_key_e key, void *user_data)
-{
- char **locale = static_cast<char**>(user_data);
- free(*locale); *locale = nullptr;
- int ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, locale);
- if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
- ERR("system_settings_get_value_string failed: %s", get_error_message(ret));
- }
-}
-
-const char *Time::GetLocale()
-{
- static const char *locale;
-
- if (!locale) {
- char *l;
- int ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, TimeSystemSettingsLocaleLanguageChanged, &locale);
- if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
- ERR("system_settings_set_changed_cb failed: %s", get_error_message(ret));
- }
- ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &l);
- if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
- ERR("system_settings_get_value_string failed: %s", get_error_message(ret));
- system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE);
- locale = getenv("LOCALE") ? strdup(getenv("LOCALE")) : "";
- } else {
- locale = l;
- }
- if (!locale)
- FAT("Unable to get current locale.");
- }
- return locale;
-}
-
Time Time::Local() const
{
return Time(milliseconds_, GetCurrentTimezone());
unsigned int Time::GetYear() const
{
- return GetCalendarField(milliseconds_, timezone_.c_str(), GetLocale(), I18N_UCALENDAR_YEAR);
+ return GetCalendarField(milliseconds_, timezone_.c_str(), SystemSettings::GetLocale(), I18N_UCALENDAR_YEAR);
}
Time::Month Time::GetMonth() const
{
- return (Time::Month)GetCalendarField(milliseconds_, timezone_.c_str(), GetLocale(), I18N_UCALENDAR_MONTH);
+ return (Time::Month)GetCalendarField(milliseconds_, timezone_.c_str(), SystemSettings::GetLocale(), I18N_UCALENDAR_MONTH);
}
unsigned int Time::GetDay() const
{
- return GetCalendarField(milliseconds_, timezone_.c_str(), GetLocale(), I18N_UCALENDAR_DAY_OF_MONTH);
+ return GetCalendarField(milliseconds_, timezone_.c_str(), SystemSettings::GetLocale(), I18N_UCALENDAR_DAY_OF_MONTH);
}
unsigned int Time::GetHour() const
{
- return GetCalendarField(milliseconds_, timezone_.c_str(), GetLocale(), I18N_UCALENDAR_HOUR_OF_DAY);
+ return GetCalendarField(milliseconds_, timezone_.c_str(), SystemSettings::GetLocale(), I18N_UCALENDAR_HOUR_OF_DAY);
}
unsigned int Time::GetMinute() const
{
- return GetCalendarField(milliseconds_, timezone_.c_str(), GetLocale(), I18N_UCALENDAR_MINUTE);
+ return GetCalendarField(milliseconds_, timezone_.c_str(), SystemSettings::GetLocale(), I18N_UCALENDAR_MINUTE);
}
unsigned int Time::GetSecond() const
{
- return GetCalendarField(milliseconds_, timezone_.c_str(), GetLocale(), I18N_UCALENDAR_SECOND);
+ return GetCalendarField(milliseconds_, timezone_.c_str(), SystemSettings::GetLocale(), I18N_UCALENDAR_SECOND);
}
unsigned int Time::GetMilliSec() const
I18nString u_zone(timezone_);
int32_t value;
- int err = i18n_ucalendar_create(u_zone.i18n_str(), -1, GetLocale(),
+ int err = i18n_ucalendar_create(u_zone.i18n_str(), -1, SystemSettings::GetLocale(),
I18N_UCALENDAR_GREGORIAN, &calendar);
if (err != I18N_ERROR_NONE) {
ERR("i18n_ucalendar_create failed: %s", get_error_message(err));
return *this;
return Time(std::trunc(milliseconds_ / milliseconds) * milliseconds, timezone_);
}
-
-static void time_system_default_timeformat_changed(system_settings_key_e key, void *user_data)
-{
- bool *prefer_24h_format = static_cast<bool*>(user_data);
- int err = system_settings_get_value_bool(
- SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, prefer_24h_format);
- if (err != SYSTEM_SETTINGS_ERROR_NONE) {
- ERR("system_settings_get_value_string failed[%d]: %s", err, get_error_message(err));
- } else {
- Time::PreferedTimeFormatChanged event;
- EventBus::FireEvent(event);
- }
-}
-
-bool Time::Is24HourFormatPrefered()
-{
- static bool prefer_24h_format;
- static bool init;
-
- if (!init) {
- int err = system_settings_get_value_bool(
- SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, &prefer_24h_format);
- if (err != SYSTEM_SETTINGS_ERROR_NONE) {
- ERR("system_settings_get_value_string failed[%d]: %s", err, get_error_message(err));
- prefer_24h_format = true;
- }
- err = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR,
- time_system_default_timeformat_changed, &prefer_24h_format);
- if (err != SYSTEM_SETTINGS_ERROR_NONE) {
- ERR("system_settings_set_changed_cb failed[%d]: %s", err, get_error_message(err));
- } else {
- init = true;
- }
- }
-
- return prefer_24h_format;
-}
#include "Utils/ThemeExtension.h"
#include "Utils/Translate.h"
#include "Utils/Accessibility.h"
+#include "Utils/SystemSettings.h"
using namespace view;
using namespace model;
{
std::stringstream formatted_time;
- if (Time::Is24HourFormatPrefered()) {
+ if (SystemSettings::Is24HourFormatPrefered()) {
formatted_time << time.Format(Time::FORMAT_TIME_24H);
} else {
formatted_time << time.Format(Time::FORMAT_TIME_12H);
eext_object_event_callback_add(content_, EEXT_CALLBACK_MORE,
AlarmView::MoreButtonClicked, this);
- time_format_change_listener_ = EventBus::AddListener<Time::PreferedTimeFormatChanged>(
+ time_format_change_listener_ = EventBus::AddListener<SystemSettings::TimeFormatChanged>(
std::bind(&AlarmView::TimeFormatChanged, this));
}
#include "View/DeleteAlarmView.h"
#include "Utils/Log.h"
#include "Utils/Translate.h"
+#include "Utils/SystemSettings.h"
#include <sstream>
{
std::stringstream formatted_time;
- if (time.Is24HourFormatPrefered()) {
+ if (SystemSettings::Is24HourFormatPrefered()) {
formatted_time << time.Format(Time::FORMAT_TIME_24H);
} else {
formatted_time << time.Format(Time::FORMAT_TIME_12H);
DeleteAlarmView::DeleteAlarmView(view::MainView &main)
: PageView(main), all_selected_(false)
{
- time_format_change_listener_ = EventBus::AddListener<Time::PreferedTimeFormatChanged>(
+ time_format_change_listener_ = EventBus::AddListener<SystemSettings::TimeFormatChanged>(
std::bind(&DeleteAlarmView::TimeFormatChanged, this));
}
#include "Utils/Translate.h"
#include "Utils/PopupManager.h"
#include "Utils/Accessibility.h"
+#include "Utils/SystemSettings.h"
#include <efl_extension.h>
#include <Elementary.h>
std::bind(&EditAlarmView::OnWeekFlagsPagePopped, this));
picker_conn_ = picker_.OnPathUpdated.Connect(
std::bind(&EditAlarmView::RingtonePathUpdateCallback, this));
- time_format_change_listener_ = EventBus::AddListener<Time::PreferedTimeFormatChanged>(
+ time_format_change_listener_ = EventBus::AddListener<SystemSettings::TimeFormatChanged>(
std::bind(&EditAlarmView::TimeFormatChanged, this));
}
itc->func.content_get = [](void *data, Evas_Object *o, const char *part) -> Evas_Object* {
EditAlarmView *view = static_cast<EditAlarmView*>(data);
Evas_Object *dt = elm_datetime_add(o);
- elm_datetime_format_set(dt, Time::Is24HourFormatPrefered() ? "%k %M" : "%l %M %p");
+ elm_datetime_format_set(dt, SystemSettings::Is24HourFormatPrefered() ? "%k %M" : "%l %M %p");
elm_object_style_set(dt, "time_layout"); // from tizen-theme
evas_object_smart_callback_add(dt, "changed"
, EditAlarmView::DateTimeChangedCallback, view);
#include "Utils/Log.h"
#include "Utils/WorldClock.h"
#include "Utils/ThemeExtension.h"
+#include "Utils/SystemSettings.h"
using namespace view;
using namespace utils;
Time t = Time::Now().InTimezone(ldid->location->tzpath.c_str());
std::string timezone_time;
- if (Time::Is24HourFormatPrefered())
+ if (SystemSettings::Is24HourFormatPrefered())
timezone_time = t.Format("HH:mm");
else
timezone_time = t.Format("h:mm");
return strdup(time_formatted);
}
if (!strcmp(part, "ampm")) {
- if (Time::Is24HourFormatPrefered())
+ if (SystemSettings::Is24HourFormatPrefered())
return NULL;
char ampm_formatted[MAX_STYLE_LEN] = { 0, };
WorldClockDeleteItemsView::WorldClockDeleteItemsView(view::MainView &main):
PageView(main), all_selected_(false)
{
- time_format_change_listener_ = EventBus::AddListener<Time::PreferedTimeFormatChanged>(
+ time_format_change_listener_ = EventBus::AddListener<SystemSettings::TimeFormatChanged>(
std::bind(&WorldClockDeleteItemsView::TimeFormatChanged, this));
}
#include "Utils/Time.h"
#include "Utils/Log.h"
#include "Utils/TizenAppUtils.h"
+#include "Utils/SystemSettings.h"
namespace view {
WorldClockReorderView::WorldClockReorderView(view::MainView &main) :
PageView(main)
{
- time_format_change_listener_ = EventBus::AddListener<Time::PreferedTimeFormatChanged>(
+ time_format_change_listener_ = EventBus::AddListener<SystemSettings::TimeFormatChanged>(
std::bind(&WorldClockReorderView::TimeFormatChanged, this));
}
Time t = Time::Now().InTimezone(lrid->location->tzpath.c_str());
std::string timezone_time;
- if (Time::Is24HourFormatPrefered())
+ if (SystemSettings::Is24HourFormatPrefered())
timezone_time = t.Format("HH:mm");
else
timezone_time = t.Format("h:mm");
return strdup(time_formatted);
}
if (!strcmp(part, "ampm")) {
- if (Time::Is24HourFormatPrefered())
+ if (SystemSettings::Is24HourFormatPrefered())
return NULL;
char ampm_formatted[MAX_STYLE_LEN] = { 0, };
#include "Utils/ThemeExtension.h"
#include "Utils/Translate.h"
#include "Utils/Accessibility.h"
+#include "Utils/SystemSettings.h"
using namespace view;
using namespace utils;
-/**
- * @brief Genlist item data model
- */
-struct LocationItemData {
- /** container view */
- WorldClockView *wc_view;
- /** elm_time table */
- Evas_Object *time;
-
- /** location pointer */
- const model::Location *location;
-
- /** date to be displayed */
- char *date;
- /** city to be displayed */
- char *city_country;
- /** time offset to be displayed */
- char *gmt_offset_relative;
- /** time offset from GMT+0 in minutes */
- int gmt_offset;
- /** elm_genlist item handle */
- Elm_Object_Item *it;
-};
-
/* Custom list View */
elm_layout_content_set(world_clock_, TIMEZONE_CUSTOM_LOCATIONS_LIST_PART, custom_locations_list_);
}
+void WorldClockView::UpdateLocationItemLanguage(LocationItemData *data)
+{
+ const model::Location *location = data->location;
+ Time t = Time::Now().InTimezone(location->tzpath.c_str());
+ int local_timezone_offset = Time::GetTimezoneOffset(Time::GetCurrentTimezone().c_str());
+
+ free(data->gmt_offset_relative);
+ free(data->date);
+
+ data->gmt_offset_relative = strdup(
+ GetTimezoneDiffDescription(local_timezone_offset, location->gmt_offset_).c_str());
+ data->date = strdup(t.Format("E d MMM").c_str());
+}
+
void WorldClockView::AppendItemToCustomList(const model::Location *location)
{
LocationItemData *data = new LocationItemData;
-
Time t = Time::Now().InTimezone(location->tzpath.c_str());
int local_timezone_offset = Time::GetTimezoneOffset(Time::GetCurrentTimezone().c_str());
std::stringstream ss;
std::string timezone_time;
char time_formatted[MAX_STYLE_LEN] = { 0, };
- if (Time::Is24HourFormatPrefered())
+ if (SystemSettings::Is24HourFormatPrefered())
timezone_time = t.Format("HH:mm");
else
timezone_time = t.Format("h:mm");
return strdup(time_formatted);
}
if (!strcmp(part, "ampm")) {
- if (Time::Is24HourFormatPrefered())
+ if (SystemSettings::Is24HourFormatPrefered())
return NULL;
char ampm_formatted[MAX_STYLE_LEN] = { 0, };
map_ = new WorldClockMap(*this);
elm_object_part_content_set(world_clock_map_, "map", map_->GetEvasObject());
- time_format_change_listener_ = EventBus::AddListener<Time::PreferedTimeFormatChanged>(
+ time_format_change_listener_ = EventBus::AddListener<SystemSettings::TimeFormatChanged>(
std::bind(&WorldClockView::TimeFormatChanged, this));
+ language_change_listener_ = EventBus::AddListener<SystemSettings::LanguageChanged>(
+ std::bind(&WorldClockView::LanguageChanged, this));
+
elm_object_translatable_part_text_set(world_clock_, "main.locations.list:emptylist.label",
"IDS_CLOCK_BODY_AFTER_YOU_ADD_CITIES_THEY_WILL_BE_SHOWN_HERE");
}
UpdateMapAndTimezoneDetails(¤t_timezone_);
}
+void WorldClockView::UpdateCustomList()
+{
+ unsigned count = elm_genlist_items_count(custom_locations_list_);
+ if (count == 0)
+ return;
+
+ Elm_Object_Item *item = nullptr;
+ void *data = nullptr;
+
+ for (int i = 0; i < count; ++i) {
+ item = elm_genlist_nth_item_get(custom_locations_list_, i);
+ data = elm_object_item_data_get(item);
+ if (!data) {
+ ERR("Item data is not set");
+ continue;
+ }
+ UpdateLocationItemLanguage(static_cast<LocationItemData *>(data));
+ }
+}
+
+void WorldClockView::LanguageChanged()
+{
+ UpdateCustomList();
+
+ elm_genlist_realized_items_update(custom_locations_list_);
+ UpdateMapAndTimezoneDetails(¤t_timezone_);
+}
+
WorldClockView::~WorldClockView()
{
ecore_timer_del(timer_);
timezone_offset).c_str());
std::string timezone_time;
- if (Time::Is24HourFormatPrefered())
+ if (SystemSettings::Is24HourFormatPrefered())
timezone_time = t.Format("HH:mm");
else
timezone_time = t.Format("h:mm");
char ampm_formatted[MAX_STYLE_LEN] = { 0, };
Time t = Time::Now().InTimezone(Time::GetTimezoneNameByOffset(timezone_offset).c_str());
- if (!Time::Is24HourFormatPrefered()) {
+ if (!SystemSettings::Is24HourFormatPrefered()) {
std::string meridiem = t.Format(Time::FORMAT_TIME_AMPM);
snprintf(ampm_formatted, sizeof(ampm_formatted),
TIMEZONE_DETAILS_FIRST_LINE_AMPM_STYLE("%s"), meridiem.c_str());