From 291c4c62544e549075dbfb3e29d02faf18bd4fdc Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Mon, 19 Aug 2019 16:18:18 +0900 Subject: [PATCH] [Application.Common][TCSACR-260][Add] Add SuspendedState Event (#971) * Add suspended state Signed-off-by: hyunho * Modify a SuspendedStateChanged event type description Signed-off-by: hyunho --- .../Interop/Interop.AppCommon.cs | 3 ++ .../DefaultCoreBackend.cs | 24 +++++++++++- .../Tizen.Applications.CoreBackend/EventType.cs | 7 ++++ .../Tizen.Applications/SuspendedState.cs | 35 ++++++++++++++++++ .../Tizen.Applications/SuspendedStateEventArgs.cs | 43 ++++++++++++++++++++++ 5 files changed, 111 insertions(+), 1 deletion(-) mode change 100755 => 100644 src/Tizen.Applications.Common/Interop/Interop.AppCommon.cs mode change 100755 => 100644 src/Tizen.Applications.Common/Tizen.Applications.CoreBackend/EventType.cs create mode 100644 src/Tizen.Applications.Common/Tizen.Applications/SuspendedState.cs create mode 100644 src/Tizen.Applications.Common/Tizen.Applications/SuspendedStateEventArgs.cs diff --git a/src/Tizen.Applications.Common/Interop/Interop.AppCommon.cs b/src/Tizen.Applications.Common/Interop/Interop.AppCommon.cs old mode 100755 new mode 100644 index 5ad41f5..7d0362e --- a/src/Tizen.Applications.Common/Interop/Interop.AppCommon.cs +++ b/src/Tizen.Applications.Common/Interop/Interop.AppCommon.cs @@ -91,6 +91,9 @@ internal static partial class Interop [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_device_orientation")] internal static extern ErrorCode AppEventGetDeviceOrientation(IntPtr handle, out DeviceOrientation orientation); + + [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_suspended_state")] + internal static extern ErrorCode AppEventGetSuspendedState(IntPtr handle, out SuspendedState state); } } diff --git a/src/Tizen.Applications.Common/Tizen.Applications.CoreBackend/DefaultCoreBackend.cs b/src/Tizen.Applications.Common/Tizen.Applications.CoreBackend/DefaultCoreBackend.cs index 2b9963c..9602688 100644 --- a/src/Tizen.Applications.Common/Tizen.Applications.CoreBackend/DefaultCoreBackend.cs +++ b/src/Tizen.Applications.Common/Tizen.Applications.CoreBackend/DefaultCoreBackend.cs @@ -239,7 +239,7 @@ namespace Tizen.Applications.CoreBackend } /// - /// Default implementation for the suspended state changed event. + /// Default implementation for the device orientation changed event. /// /// /// @@ -259,5 +259,27 @@ namespace Tizen.Applications.CoreBackend handler?.Invoke(new DeviceOrientationEventArgs(orientation)); } } + + /// + /// Default implementation for the device orientation changed event. + /// + /// + /// + /// 6 + [EditorBrowsable(EditorBrowsableState.Never)] + protected virtual void OnSuspendedStateChangedNative(IntPtr infoHandle, IntPtr data) + { + SuspendedState state; + ErrorCode err = Interop.AppCommon.AppEventGetSuspendedState(infoHandle, out state); + if (err != ErrorCode.None) + { + Log.Error(LogTag, "Failed to get deivce orientation. Err = " + err); + } + if (Handlers.ContainsKey(EventType.SuspendedStateChanged)) + { + var handler = Handlers[EventType.SuspendedStateChanged] as Action; + handler?.Invoke(new SuspendedStateEventArgs(state)); + } + } } } diff --git a/src/Tizen.Applications.Common/Tizen.Applications.CoreBackend/EventType.cs b/src/Tizen.Applications.Common/Tizen.Applications.CoreBackend/EventType.cs old mode 100755 new mode 100644 index 278a639..0165eb5 --- a/src/Tizen.Applications.Common/Tizen.Applications.CoreBackend/EventType.cs +++ b/src/Tizen.Applications.Common/Tizen.Applications.CoreBackend/EventType.cs @@ -87,6 +87,13 @@ namespace Tizen.Applications.CoreBackend /// 3 public static readonly EventType DeviceOrientationChanged = "DeviceOrientationChanged"; + /// + /// Pre-defined event type "SuspendedStateChanged". + /// The SuspendedStateEventArgs class is an event argument class for this EventType. + /// + /// 6 + public static readonly EventType SuspendedStateChanged = "SuspendedStateChanged"; + private string _typeName; /// diff --git a/src/Tizen.Applications.Common/Tizen.Applications/SuspendedState.cs b/src/Tizen.Applications.Common/Tizen.Applications/SuspendedState.cs new file mode 100644 index 0000000..77f11a6 --- /dev/null +++ b/src/Tizen.Applications.Common/Tizen.Applications/SuspendedState.cs @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019 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. + */ + +namespace Tizen.Applications +{ + /// + /// Enumeration for suspended state. + /// + /// 6 + public enum SuspendedState + { + /// + /// Application will enter the suspended state + /// + WillEnter = 0, + + /// + /// Application did exit from the suspended state + /// + DidExit = 1 + } +} diff --git a/src/Tizen.Applications.Common/Tizen.Applications/SuspendedStateEventArgs.cs b/src/Tizen.Applications.Common/Tizen.Applications/SuspendedStateEventArgs.cs new file mode 100644 index 0000000..35bd311 --- /dev/null +++ b/src/Tizen.Applications.Common/Tizen.Applications/SuspendedStateEventArgs.cs @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2019 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 +{ + /// + /// The class for the argument of the SuspendedState EventHandler + /// + /// 6 + public class SuspendedStateEventArgs : EventArgs + { + /// + /// Initializes SuspendedStateEventArgs class + /// + /// The information of the SuspendedState + /// 6 + public SuspendedStateEventArgs(SuspendedState state) + { + SuspendedState = state; + } + + /// + /// The property to get the information of the SuspendedState + /// + /// 6 + public SuspendedState SuspendedState { get; private set; } + } +} -- 2.7.4