From 6ea8d543ad8da6030461cfe1d1b06c1ac82ea965 Mon Sep 17 00:00:00 2001 From: hjhun <36876573+hjhun@users.noreply.github.com> Date: Fri, 8 Sep 2023 17:09:54 +0900 Subject: [PATCH] [Applications.UI] Modify UICoreBackend for time zone event (#5542) This patch registers and unregister the time zone changed event. Signed-off-by: Hwankyu Jhun --- .../UICoreBackend.cs | 21 +++++++++++++++++-- .../Tizen.Applications/CoreUIApplication.cs | 2 ++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Tizen.Applications.UI/Tizen.Applications.CoreBackend/UICoreBackend.cs b/src/Tizen.Applications.UI/Tizen.Applications.CoreBackend/UICoreBackend.cs index 933a4e058..c8f02bd25 100755 --- a/src/Tizen.Applications.UI/Tizen.Applications.CoreBackend/UICoreBackend.cs +++ b/src/Tizen.Applications.UI/Tizen.Applications.CoreBackend/UICoreBackend.cs @@ -28,12 +28,14 @@ namespace Tizen.Applications.CoreBackend private IntPtr _localeChangedEventHandle = IntPtr.Zero; private IntPtr _regionChangedEventHandle = IntPtr.Zero; private IntPtr _deviceOrientationChangedEventHandle = IntPtr.Zero; + private IntPtr _timeZoneChangedEventHandle = IntPtr.Zero; private bool _disposedValue = false; private Interop.Application.AppEventCallback _onLowMemoryNative; private Interop.Application.AppEventCallback _onLowBatteryNative; private Interop.Application.AppEventCallback _onLocaleChangedNative; private Interop.Application.AppEventCallback _onRegionChangedNative; private Interop.Application.AppEventCallback _onDeviceOrientationChangedNative; + private Interop.Application.AppEventCallback _onTimeZoneChangedNative; public UICoreBackend() { @@ -48,6 +50,7 @@ namespace Tizen.Applications.CoreBackend _onLocaleChangedNative = new Interop.Application.AppEventCallback(OnLocaleChangedNative); _onRegionChangedNative = new Interop.Application.AppEventCallback(OnRegionChangedNative); _onDeviceOrientationChangedNative = new Interop.Application.AppEventCallback(OnDeviceOrientationChangedNative); + _onTimeZoneChangedNative = new Interop.Application.AppEventCallback(OnTimeZoneChangedNative); } public override void Exit() @@ -89,6 +92,12 @@ namespace Tizen.Applications.CoreBackend Log.Error(LogTag, "Failed to add event handler for DeviceOrientationChanged event. Err = " + err); } + err = Interop.Application.AddEventHandler(out _timeZoneChangedEventHandle, AppEventType.TimeZoneChanged, _onTimeZoneChangedNative, IntPtr.Zero); + if (err != ErrorCode.None) + { + Log.Error(LogTag, "Failed to add event handler for TimeZoneChanged event. Err = " + err); + } + err = Interop.Application.Main(args.Length, args, ref _callbacks, IntPtr.Zero); if (err != ErrorCode.None) { @@ -125,6 +134,10 @@ namespace Tizen.Applications.CoreBackend { Interop.Application.RemoveEventHandler(_deviceOrientationChangedEventHandle); } + if (_timeZoneChangedEventHandle != IntPtr.Zero) + { + Interop.Application.RemoveEventHandler(_timeZoneChangedEventHandle); + } _disposedValue = true; } @@ -161,8 +174,7 @@ namespace Tizen.Applications.CoreBackend { // Create a SafeAppControlHandle but the ownsHandle is false, // because the appControlHandle will be closed by native appfw after this method automatically. - SafeAppControlHandle safeHandle = new SafeAppControlHandle(appControlHandle, false); - + using SafeAppControlHandle safeHandle = new SafeAppControlHandle(appControlHandle, false); var handler = Handlers[EventType.AppControlReceived] as Action; handler?.Invoke(new AppControlReceivedEventArgs(new ReceivedAppControl(safeHandle))); } @@ -210,5 +222,10 @@ namespace Tizen.Applications.CoreBackend { base.OnDeviceOrientationChangedNative(infoHandle, data); } + + protected override void OnTimeZoneChangedNative(IntPtr infoHandle, IntPtr data) + { + base.OnTimeZoneChangedNative(infoHandle, data); + } } } diff --git a/src/Tizen.Applications.UI/Tizen.Applications/CoreUIApplication.cs b/src/Tizen.Applications.UI/Tizen.Applications/CoreUIApplication.cs index 6002da26a..7fb0608a9 100755 --- a/src/Tizen.Applications.UI/Tizen.Applications/CoreUIApplication.cs +++ b/src/Tizen.Applications.UI/Tizen.Applications/CoreUIApplication.cs @@ -35,7 +35,9 @@ namespace Tizen.Applications /// The default backend for the UI application will be used. /// /// 3 +#pragma warning disable CA2000 public CoreUIApplication() : base(new UICoreBackend()) +#pragma warning restore CA2000 { } -- 2.34.1