summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSukHyung, Kang <shine.kang@samsung.com>2017-03-06 15:45:08 +0900
committerSukHyung, Kang <shine.kang@samsung.com>2017-03-16 10:38:51 +0900
commit63c03d6665a955b276c2163eb407adf44048640e (patch)
tree0655d2ecbd314ae1b13b82a34ab390e036b189f2
parent65d0ebdb2e9c56d53349da7b5f08b50f24d63e27 (diff)
downloadapplication-63c03d6665a955b276c2163eb407adf44048640e.tar.gz
application-63c03d6665a955b276c2163eb407adf44048640e.tar.bz2
application-63c03d6665a955b276c2163eb407adf44048640e.zip
Add to get orientation event
Change-Id: I128730161613d28ac3e2cdb9d392dad0feee1041 Signed-off-by: SukHyung, Kang <shine.kang@samsung.com>
-rwxr-xr-xTizen.Applications.Common/Interop/Interop.AppCommon.cs3
-rwxr-xr-xTizen.Applications.Common/Tizen.Applications.Common.csproj2
-rwxr-xr-xTizen.Applications.Common/Tizen.Applications.CoreBackend/DefaultCoreBackend.cs15
-rwxr-xr-xTizen.Applications.Common/Tizen.Applications.CoreBackend/EventType.cs5
-rwxr-xr-x[-rw-r--r--]Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs15
-rwxr-xr-xTizen.Applications.Common/Tizen.Applications/DeviceOrientation.cs44
-rwxr-xr-xTizen.Applications.Common/Tizen.Applications/DeviceOrientationEventArgs.cs40
-rwxr-xr-xTizen.Applications.Service/Tizen.Applications.CoreBackend/ServiceCoreBackend.cs19
-rwxr-xr-xTizen.Applications.UI/Tizen.Applications.CoreBackend/UICoreBackend.cs18
9 files changed, 161 insertions, 0 deletions
diff --git a/Tizen.Applications.Common/Interop/Interop.AppCommon.cs b/Tizen.Applications.Common/Interop/Interop.AppCommon.cs
index a221828..41603d2 100755
--- a/Tizen.Applications.Common/Interop/Interop.AppCommon.cs
+++ b/Tizen.Applications.Common/Interop/Interop.AppCommon.cs
@@ -85,6 +85,9 @@ internal static partial class Interop
[DllImport(Libraries.AppCommon, EntryPoint = "app_resource_manager_get")]
internal static extern ErrorCode AppResourceManagerGet(ResourceCategory category, string id, out string path);
+
+ [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_device_orientation")]
+ internal static extern ErrorCode AppEventGetDeviceOrientation(IntPtr handle, out DeviceOrientation orientation);
}
}
diff --git a/Tizen.Applications.Common/Tizen.Applications.Common.csproj b/Tizen.Applications.Common/Tizen.Applications.Common.csproj
index 5b0bd9e..2278de1 100755
--- a/Tizen.Applications.Common/Tizen.Applications.Common.csproj
+++ b/Tizen.Applications.Common/Tizen.Applications.Common.csproj
@@ -66,6 +66,8 @@
<Compile Include="Tizen.Applications\AppControlReplyCallback.cs" />
<Compile Include="Tizen.Applications\ApplicationType.cs" />
<Compile Include="Tizen.Applications\CoreApplication.cs" />
+ <Compile Include="Tizen.Applications\DeviceOrientation.cs" />
+ <Compile Include="Tizen.Applications\DeviceOrientationEventArgs.cs" />
<Compile Include="Tizen.Applications\DirectoryInfo.cs" />
<Compile Include="Tizen.Applications\ResourceManager.cs" />
<Compile Include="Tizen.Applications\LocaleChangedEventArgs.cs" />
diff --git a/Tizen.Applications.Common/Tizen.Applications.CoreBackend/DefaultCoreBackend.cs b/Tizen.Applications.Common/Tizen.Applications.CoreBackend/DefaultCoreBackend.cs
index 32918a1..aabbbeb 100755
--- a/Tizen.Applications.Common/Tizen.Applications.CoreBackend/DefaultCoreBackend.cs
+++ b/Tizen.Applications.Common/Tizen.Applications.CoreBackend/DefaultCoreBackend.cs
@@ -136,5 +136,20 @@ namespace Tizen.Applications.CoreBackend
handler?.Invoke(new RegionFormatChangedEventArgs(region));
}
}
+
+ protected virtual void OnDeviceOrientationChangedNative(IntPtr infoHandle, IntPtr data)
+ {
+ DeviceOrientation orientation;
+ ErrorCode err = Interop.AppCommon.AppEventGetDeviceOrientation(infoHandle, out orientation);
+ if (err != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Failed to get deivce orientation. Err = " + err);
+ }
+ if (Handlers.ContainsKey(EventType.DeviceOrientationChanged))
+ {
+ var handler = Handlers[EventType.DeviceOrientationChanged] as Action<DeviceOrientationEventArgs>;
+ handler?.Invoke(new DeviceOrientationEventArgs(orientation));
+ }
+ }
}
}
diff --git a/Tizen.Applications.Common/Tizen.Applications.CoreBackend/EventType.cs b/Tizen.Applications.Common/Tizen.Applications.CoreBackend/EventType.cs
index 6985ae8..e24cddf 100755
--- a/Tizen.Applications.Common/Tizen.Applications.CoreBackend/EventType.cs
+++ b/Tizen.Applications.Common/Tizen.Applications.CoreBackend/EventType.cs
@@ -70,6 +70,11 @@ namespace Tizen.Applications.CoreBackend
/// </summary>
public static readonly EventType RegionFormatChanged = "RegionFormatChanged";
+ /// <summary>
+ /// Pre-defined event type. "DeviceOrientationChanged"
+ /// </summary>
+ public static readonly EventType DeviceOrientationChanged = "DeviceOrientationChanged";
+
private string _typeName;
/// <summary>
diff --git a/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs b/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs
index f37b310..5bf6e39 100644..100755
--- a/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs
+++ b/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs
@@ -73,6 +73,11 @@ namespace Tizen.Applications
public event EventHandler<RegionFormatChangedEventArgs> RegionFormatChanged;
/// <summary>
+ /// Occurs when the device orientation is changed.
+ /// </summary>
+ public event EventHandler<DeviceOrientationEventArgs> DeviceOrientationChanged;
+
+ /// <summary>
/// The backend instance.
/// </summary>
protected ICoreBackend Backend { get { return _backend; } }
@@ -92,6 +97,7 @@ namespace Tizen.Applications
_backend.AddEventHandler<LowBatteryEventArgs>(EventType.LowBattery, OnLowBattery);
_backend.AddEventHandler<LocaleChangedEventArgs>(EventType.LocaleChanged, OnLocaleChanged);
_backend.AddEventHandler<RegionFormatChangedEventArgs>(EventType.RegionFormatChanged, OnRegionFormatChanged);
+ _backend.AddEventHandler<DeviceOrientationEventArgs>(EventType.DeviceOrientationChanged, OnDeviceOrientationChanged);
string[] argsClone = null;
@@ -182,6 +188,15 @@ namespace Tizen.Applications
}
/// <summary>
+ /// Overrides this method if want to handle behavior when the device orientation is changed.
+ /// If base.OnRegionFormatChanged() is not called, the event 'RegionFormatChanged' will not be emitted.
+ /// </summary>
+ protected virtual void OnDeviceOrientationChanged(DeviceOrientationEventArgs e)
+ {
+ DeviceOrientationChanged?.Invoke(this, e);
+ }
+
+ /// <summary>
/// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
/// </summary>
/// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
diff --git a/Tizen.Applications.Common/Tizen.Applications/DeviceOrientation.cs b/Tizen.Applications.Common/Tizen.Applications/DeviceOrientation.cs
new file mode 100755
index 0000000..5b41aea
--- /dev/null
+++ b/Tizen.Applications.Common/Tizen.Applications/DeviceOrientation.cs
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2016 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 device orientation.
+ /// </summary>
+ public enum DeviceOrientation
+ {
+ /// <summary>
+ /// The device orientation is 0
+ /// </summary>
+ Orientation_0 = 0,
+
+ /// <summary>
+ /// The device orientation is 90
+ /// </summary>
+ Orientation_90 = 90,
+
+ /// <summary>
+ /// The device orientation is 180
+ /// </summary>
+ Orientation_180 = 180,
+
+ /// <summary>
+ /// The device orientation is 270
+ /// </summary>
+ Orientation_270 = 270,
+ }
+} \ No newline at end of file
diff --git a/Tizen.Applications.Common/Tizen.Applications/DeviceOrientationEventArgs.cs b/Tizen.Applications.Common/Tizen.Applications/DeviceOrientationEventArgs.cs
new file mode 100755
index 0000000..e042e32
--- /dev/null
+++ b/Tizen.Applications.Common/Tizen.Applications/DeviceOrientationEventArgs.cs
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2016 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 event arguments of the DeviceOrientationChanged
+ /// </summary>
+ public class DeviceOrientationEventArgs : EventArgs
+ {
+ /// <summary>
+ /// Initializes DeviceOrientationEventArgs class
+ /// </summary>
+ /// <param name="orientation"></param>
+ public DeviceOrientationEventArgs(DeviceOrientation orientation)
+ {
+ DeviceOrientation = orientation;
+ }
+
+ /// <summary>
+ /// The received DeviceOrientation
+ /// </summary>
+ public DeviceOrientation DeviceOrientation { get; private set; }
+ }
+} \ No newline at end of file
diff --git a/Tizen.Applications.Service/Tizen.Applications.CoreBackend/ServiceCoreBackend.cs b/Tizen.Applications.Service/Tizen.Applications.CoreBackend/ServiceCoreBackend.cs
index bf6746c..bc1a096 100755
--- a/Tizen.Applications.Service/Tizen.Applications.CoreBackend/ServiceCoreBackend.cs
+++ b/Tizen.Applications.Service/Tizen.Applications.CoreBackend/ServiceCoreBackend.cs
@@ -27,11 +27,13 @@ namespace Tizen.Applications.CoreBackend
private IntPtr _lowBatteryEventHandle = IntPtr.Zero;
private IntPtr _localeChangedEventHandle = IntPtr.Zero;
private IntPtr _regionChangedEventHandle = IntPtr.Zero;
+ private IntPtr _deviceOrientationChangedEventHandle = IntPtr.Zero;
private bool _disposedValue = false;
private Interop.Service.AppEventCallback _onLowMemoryNative;
private Interop.Service.AppEventCallback _onLowBatteryNative;
private Interop.Service.AppEventCallback _onLocaleChangedNative;
private Interop.Service.AppEventCallback _onRegionChangedNative;
+ private Interop.Service.AppEventCallback _onDeviceOrientationChangedNative;
public ServiceCoreBackend()
{
@@ -43,6 +45,7 @@ namespace Tizen.Applications.CoreBackend
_onLowBatteryNative = new Interop.Service.AppEventCallback(OnLowBatteryNative);
_onLocaleChangedNative = new Interop.Service.AppEventCallback(OnLocaleChangedNative);
_onRegionChangedNative = new Interop.Service.AppEventCallback(OnRegionChangedNative);
+ _onDeviceOrientationChangedNative = new Interop.Service.AppEventCallback(OnDeviceOrientationChangedNative);
}
public override void Exit()
@@ -78,6 +81,12 @@ namespace Tizen.Applications.CoreBackend
Log.Error(LogTag, "Failed to add event handler for RegionFormatChanged event. Err = " + err);
}
+ err = Interop.Service.AddEventHandler(out _deviceOrientationChangedEventHandle, AppEventType.DeviceOrientationChanged, _onDeviceOrientationChangedNative, IntPtr.Zero);
+ if (err != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Failed to add event handler for DeviceOrientationChanged event. Err = " + err);
+ }
+
err = Interop.Service.Main(args.Length, args, ref _callbacks, IntPtr.Zero);
if (err != ErrorCode.None)
{
@@ -111,6 +120,11 @@ namespace Tizen.Applications.CoreBackend
Interop.Service.RemoveEventHandler(_regionChangedEventHandle);
}
+ if (_deviceOrientationChangedEventHandle != IntPtr.Zero)
+ {
+ Interop.Service.RemoveEventHandler(_deviceOrientationChangedEventHandle);
+ }
+
_disposedValue = true;
}
}
@@ -167,5 +181,10 @@ namespace Tizen.Applications.CoreBackend
base.OnRegionChangedNative(infoHandle, data);
}
+ protected override void OnDeviceOrientationChangedNative(IntPtr infoHandle, IntPtr data)
+ {
+ base.OnDeviceOrientationChangedNative(infoHandle, data);
+ }
+
}
}
diff --git a/Tizen.Applications.UI/Tizen.Applications.CoreBackend/UICoreBackend.cs b/Tizen.Applications.UI/Tizen.Applications.CoreBackend/UICoreBackend.cs
index 50af98b..933a4e0 100755
--- a/Tizen.Applications.UI/Tizen.Applications.CoreBackend/UICoreBackend.cs
+++ b/Tizen.Applications.UI/Tizen.Applications.CoreBackend/UICoreBackend.cs
@@ -27,11 +27,13 @@ namespace Tizen.Applications.CoreBackend
private IntPtr _lowBatteryEventHandle = IntPtr.Zero;
private IntPtr _localeChangedEventHandle = IntPtr.Zero;
private IntPtr _regionChangedEventHandle = IntPtr.Zero;
+ private IntPtr _deviceOrientationChangedEventHandle = 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;
public UICoreBackend()
{
@@ -45,6 +47,7 @@ namespace Tizen.Applications.CoreBackend
_onLowBatteryNative = new Interop.Application.AppEventCallback(OnLowBatteryNative);
_onLocaleChangedNative = new Interop.Application.AppEventCallback(OnLocaleChangedNative);
_onRegionChangedNative = new Interop.Application.AppEventCallback(OnRegionChangedNative);
+ _onDeviceOrientationChangedNative = new Interop.Application.AppEventCallback(OnDeviceOrientationChangedNative);
}
public override void Exit()
@@ -80,6 +83,12 @@ namespace Tizen.Applications.CoreBackend
Log.Error(LogTag, "Failed to add event handler for RegionFormatChanged event. Err = " + err);
}
+ err = Interop.Application.AddEventHandler(out _deviceOrientationChangedEventHandle, AppEventType.DeviceOrientationChanged, _onDeviceOrientationChangedNative, IntPtr.Zero);
+ if (err != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Failed to add event handler for DeviceOrientationChanged event. Err = " + err);
+ }
+
err = Interop.Application.Main(args.Length, args, ref _callbacks, IntPtr.Zero);
if (err != ErrorCode.None)
{
@@ -112,6 +121,10 @@ namespace Tizen.Applications.CoreBackend
{
Interop.Application.RemoveEventHandler(_regionChangedEventHandle);
}
+ if (_deviceOrientationChangedEventHandle != IntPtr.Zero)
+ {
+ Interop.Application.RemoveEventHandler(_deviceOrientationChangedEventHandle);
+ }
_disposedValue = true;
}
@@ -192,5 +205,10 @@ namespace Tizen.Applications.CoreBackend
{
base.OnRegionChangedNative(infoHandle, data);
}
+
+ protected override void OnDeviceOrientationChangedNative(IntPtr infoHandle, IntPtr data)
+ {
+ base.OnDeviceOrientationChangedNative(infoHandle, data);
+ }
}
}