diff --git a/shell/platform/tizen/BUILD.gn b/shell/platform/tizen/BUILD.gn index 1e1ef8e344f29..e80a7911fdf41 100644 --- a/shell/platform/tizen/BUILD.gn +++ b/shell/platform/tizen/BUILD.gn @@ -109,7 +109,6 @@ template("embedder") { "channels/platform_channel_tizen.cc", "channels/platform_view_channel.cc", "channels/settings_channel.cc", - "channels/settings_channel_tizen.cc", "channels/text_input_channel.cc", "channels/window_channel.cc", "external_texture_pixel_gl.cc", diff --git a/shell/platform/tizen/channels/encodable_value_holder.h b/shell/platform/tizen/channels/encodable_value_holder.h index 352f30abf5e0c..c7f25c2f8103e 100644 --- a/shell/platform/tizen/channels/encodable_value_holder.h +++ b/shell/platform/tizen/channels/encodable_value_holder.h @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#ifndef EMBEDDER_ENCODABLE_VALUE_HOLDER_H_ +#define EMBEDDER_ENCODABLE_VALUE_HOLDER_H_ + #include "flutter/shell/platform/common/client_wrapper/include/flutter/encodable_value.h" namespace flutter { @@ -28,3 +31,5 @@ struct EncodableValueHolder { }; } // namespace flutter + +#endif // EMBEDDER_ENCODABLE_VALUE_HOLDER_H_ diff --git a/shell/platform/tizen/channels/settings_channel.cc b/shell/platform/tizen/channels/settings_channel.cc index 28377a5a3070b..d5751ea65d844 100644 --- a/shell/platform/tizen/channels/settings_channel.cc +++ b/shell/platform/tizen/channels/settings_channel.cc @@ -4,6 +4,8 @@ #include "settings_channel.h" +#include + #include "flutter/shell/platform/common/json_message_codec.h" namespace flutter { @@ -23,21 +25,38 @@ SettingsChannel::SettingsChannel(BinaryMessenger* messenger) messenger, kChannelName, &JsonMessageCodec::GetInstance())) { - Init(); + system_settings_set_changed_cb( + SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, + [](system_settings_key_e key, void* user_data) -> void { + auto* self = reinterpret_cast(user_data); + self->SendSettingsEvent(); + }, + this); SendSettingsEvent(); } SettingsChannel::~SettingsChannel() { - Dispose(); + system_settings_unset_changed_cb( + SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR); } void SettingsChannel::SendSettingsEvent() { rapidjson::Document event(rapidjson::kObjectType); auto& allocator = event.GetAllocator(); event.AddMember(kTextScaleFactorKey, 1.0, allocator); - event.AddMember(kPlatformBrightnessKey, "light", allocator); event.AddMember(kAlwaysUse24HourFormatKey, Prefer24HourTime(), allocator); + event.AddMember(kPlatformBrightnessKey, "light", allocator); channel_->Send(event); } +bool SettingsChannel::Prefer24HourTime() { + bool value = false; + if (system_settings_get_value_bool( + SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, &value) == + SYSTEM_SETTINGS_ERROR_NONE) { + return value; + } + return false; +} + } // namespace flutter diff --git a/shell/platform/tizen/channels/settings_channel.h b/shell/platform/tizen/channels/settings_channel.h index 0b864c98fed40..ae9585778caa4 100644 --- a/shell/platform/tizen/channels/settings_channel.h +++ b/shell/platform/tizen/channels/settings_channel.h @@ -17,12 +17,10 @@ class SettingsChannel { public: explicit SettingsChannel(BinaryMessenger* messenger); virtual ~SettingsChannel(); - void SendSettingsEvent(); private: + void SendSettingsEvent(); bool Prefer24HourTime(); - void Init(); - void Dispose(); std::unique_ptr> channel_; }; diff --git a/shell/platform/tizen/channels/settings_channel_tizen.cc b/shell/platform/tizen/channels/settings_channel_tizen.cc deleted file mode 100644 index f5343d6c3bdf1..0000000000000 --- a/shell/platform/tizen/channels/settings_channel_tizen.cc +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "settings_channel.h" - -#include - -namespace flutter { - -static void OnSettingsChangedCallback(system_settings_key_e key, - void* user_data) { - auto settings_channel = reinterpret_cast(user_data); - settings_channel->SendSettingsEvent(); -} - -void SettingsChannel::Init() { - system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, - OnSettingsChangedCallback, this); -} - -void SettingsChannel::Dispose() { - system_settings_unset_changed_cb( - SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR); -} - -bool SettingsChannel::Prefer24HourTime() { - bool value = false; - if (system_settings_get_value_bool( - SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, &value) == - SYSTEM_SETTINGS_ERROR_NONE) { - return value; - } - return false; -} - -} // namespace flutter