[Application.Common][TCSACR-260][Add] Add SuspendedState Event (#971)
authorHyunho Kang <hhstark.kang@samsung.com>
Mon, 19 Aug 2019 07:18:18 +0000 (16:18 +0900)
committerGitHub <noreply@github.com>
Mon, 19 Aug 2019 07:18:18 +0000 (16:18 +0900)
* Add suspended state

Signed-off-by: hyunho <hhstark.kang@samsung.com>
* Modify a SuspendedStateChanged event type description

Signed-off-by: hyunho <hhstark.kang@samsung.com>
src/Tizen.Applications.Common/Interop/Interop.AppCommon.cs [changed mode: 0755->0644]
src/Tizen.Applications.Common/Tizen.Applications.CoreBackend/DefaultCoreBackend.cs
src/Tizen.Applications.Common/Tizen.Applications.CoreBackend/EventType.cs [changed mode: 0755->0644]
src/Tizen.Applications.Common/Tizen.Applications/SuspendedState.cs [new file with mode: 0644]
src/Tizen.Applications.Common/Tizen.Applications/SuspendedStateEventArgs.cs [new file with mode: 0644]

old mode 100755 (executable)
new mode 100644 (file)
index 5ad41f5..7d0362e
@@ -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);
     }
 }
 
index 2b9963c..9602688 100644 (file)
@@ -239,7 +239,7 @@ namespace Tizen.Applications.CoreBackend
         }
 
         /// <summary>
-        /// Default implementation for the suspended state changed event.
+        /// Default implementation for the device orientation changed event.
         /// </summary>
         /// <param name="infoHandle"></param>
         /// <param name="data"></param>
@@ -259,5 +259,27 @@ namespace Tizen.Applications.CoreBackend
                 handler?.Invoke(new DeviceOrientationEventArgs(orientation));
             }
         }
+
+        /// <summary>
+        /// Default implementation for the device orientation changed event.
+        /// </summary>
+        /// <param name="infoHandle"></param>
+        /// <param name="data"></param>
+        /// <since_tizen> 6 </since_tizen>
+        [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<SuspendedStateEventArgs>;
+                handler?.Invoke(new SuspendedStateEventArgs(state));
+            }
+        }
     }
 }
old mode 100755 (executable)
new mode 100644 (file)
index 278a639..0165eb5
@@ -87,6 +87,13 @@ namespace Tizen.Applications.CoreBackend
         /// <since_tizen> 3 </since_tizen>
         public static readonly EventType DeviceOrientationChanged = "DeviceOrientationChanged";
 
+        /// <summary>
+        /// Pre-defined event type "SuspendedStateChanged".
+        /// The SuspendedStateEventArgs class is an event argument class for this EventType.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        public static readonly EventType SuspendedStateChanged = "SuspendedStateChanged";
+
         private string _typeName;
 
         /// <summary>
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/SuspendedState.cs b/src/Tizen.Applications.Common/Tizen.Applications/SuspendedState.cs
new file mode 100644 (file)
index 0000000..77f11a6
--- /dev/null
@@ -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
+{
+    /// <summary>
+    /// Enumeration for suspended state.
+    /// </summary>
+    /// <since_tizen> 6 </since_tizen>
+    public enum SuspendedState
+    {
+        /// <summary>
+        /// Application will enter the suspended state
+        /// </summary>
+        WillEnter = 0,
+
+        /// <summary>
+        /// Application did exit from the suspended state
+        /// </summary>
+        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 (file)
index 0000000..35bd311
--- /dev/null
@@ -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
+{
+    /// <summary>
+    /// The class for the argument of the SuspendedState EventHandler
+    /// </summary>
+    /// <since_tizen> 6 </since_tizen>
+    public class SuspendedStateEventArgs : EventArgs
+    {
+        /// <summary>
+        /// Initializes SuspendedStateEventArgs class
+        /// </summary>
+        /// <param name="state">The information of the SuspendedState</param>
+        /// <since_tizen> 6 </since_tizen>
+        public SuspendedStateEventArgs(SuspendedState state)
+        {
+            SuspendedState = state;
+        }
+
+        /// <summary>
+        /// The property to get the information of the SuspendedState
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        public SuspendedState SuspendedState { get; private set; }
+    }
+}