[DllImport(Libraries.AppCommon, EntryPoint = "app_get_res_control_global_resource_path")]
internal static extern AppCommonErrorCode AppGetResControlGlobalResourcePath(string applicationId, out string path);
+
+ [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_time_zone")]
+ internal static extern ErrorCode AppEventGetTimeZone(IntPtr handle, out string timeZone, out string timeZoneId);
}
}
/// <summary>
/// The suspended state changed event of the application.
/// </summary>
- SuspendedStateChanged
+ SuspendedStateChanged,
+
+ /// <summary>
+ /// The time zone changed event of the application.
+ /// </summary>
+ /// <since_tizen> 11 </since_tizen>
+ TimeZoneChanged = 7,
}
/// <summary>
handler?.Invoke(new SuspendedStateEventArgs(state));
}
}
+
+ /// <summary>
+ /// Default implementation for the time zone changed event.
+ /// </summary>
+ /// <param name="infoHandle"></param>
+ /// <param name="data"></param>
+ /// <since_tizen> 11 </since_tizen>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void OnTimeZoneChangedNative(IntPtr infoHandle, IntPtr data)
+ {
+ ErrorCode err = Interop.AppCommon.AppEventGetTimeZone(infoHandle, out string timeZone, out string timeZoneId);
+ if (err != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Failed to get time zone. Err = " + err);
+ }
+ if (Handlers.ContainsKey(EventType.TimeZoneChanged))
+ {
+ var handler = Handlers[EventType.TimeZoneChanged] as Action<TimeZoneChangedEventArgs>;
+ handler?.Invoke(new TimeZoneChangedEventArgs(timeZone, timeZoneId));
+ }
+ }
}
}
/// <since_tizen> 6 </since_tizen>
public static readonly EventType SuspendedStateChanged = "SuspendedStateChanged";
+ /// <summary>
+ /// Pre-defined event type "TimeZoneChanged".
+ /// The <see cref="TimeZoneChangedEventArgs"/> class is an event argument class for this EventType.
+ /// </summary>
+ /// <since_tizen> 11 </since_tizen>
+ public static readonly EventType TimeZoneChanged = "TimeZoneChanged";
+
private string _typeName;
/// <summary>
public event EventHandler<DeviceOrientationEventArgs> DeviceOrientationChanged;
/// <summary>
+ /// Occurs when the time zone is changed.
+ /// </summary>
+ /// <since_tizen> 11 </since_tizen>
+ public event EventHandler<TimeZoneChangedEventArgs> TimeZoneChanged;
+
+ /// <summary>
/// The backend instance.
/// </summary>
/// <since_tizen> 3 </since_tizen>
_backend.AddEventHandler<LocaleChangedEventArgs>(EventType.LocaleChanged, OnLocaleChanged);
_backend.AddEventHandler<RegionFormatChangedEventArgs>(EventType.RegionFormatChanged, OnRegionFormatChanged);
_backend.AddEventHandler<DeviceOrientationEventArgs>(EventType.DeviceOrientationChanged, OnDeviceOrientationChanged);
+ _backend.AddEventHandler<TimeZoneChangedEventArgs>(EventType.TimeZoneChanged, OnTimeZoneChanged);
string[] argsClone = new string[args == null ? 1 : args.Length + 1];
if (args != null && args.Length > 1)
}
/// <summary>
+ /// Override this method if you want to handle behavior when the time zone is changed.
+ /// If base.OnTimeZoneChanged() is not called, the event "TimeZoneChanged" will not be emitted.
+ /// </summary>
+ /// <param name="e">The time zone changed event argument</param>
+ /// <since_tizen> 11 </since_tizen>
+ protected virtual void OnTimeZoneChanged(TimeZoneChangedEventArgs e)
+ {
+ TimeZoneChanged?.Invoke(this, e);
+ }
+
+ /// <summary>
/// Dispatches an asynchronous message to a main loop of the CoreApplication.
/// </summary>
/// <remarks>
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+using System;
+
+namespace Tizen.Applications
+{
+ /// <summary>
+ /// The class for the argument of the TimeZoneChanged EventHandler.
+ /// </summary>
+ /// <since_tizen> 11 </since_tizen>
+ public class TimeZoneChangedEventArgs : EventArgs
+ {
+
+ /// <summary>
+ /// Initializes TimeZoneChangedEventArgs class
+ /// </summary>
+ /// <param name="timeZone">The information of the TimeZone</param>
+ /// <param name="timeZoneId">The information of the TimeZone ID</param>
+ /// <since_tizen> 11 </since_tizen>
+ public TimeZoneChangedEventArgs(string timeZone, string timeZoneId)
+ {
+ TimeZone = timeZone;
+ TimeZoneId = timeZoneId;
+ }
+
+ /// <summary>
+ /// The property to get the information of the TimeZone.
+ /// </summary>
+ /// <value> The time zone. (e.g. "+9:00") </value>
+ /// <since_tizen> 11 </since_tizen>
+ public string TimeZone { get; private set; }
+
+ /// <summary>
+ /// The property to get the information of the TimeZone ID.
+ /// </summary>
+ /// <value> The time zone ID. (e.g. "Asia/Seoul") </value>
+ /// <since_tizen> 11 </since_tizen>
+ public string TimeZoneId { get; private set; }
+ }
+}