diff options
author | seungha.son <seungha.son@samsung.com> | 2017-02-17 16:44:12 +0900 |
---|---|---|
committer | seungha.son <seungha.son@samsung.com> | 2017-03-20 07:29:41 +0900 |
commit | 1824590de7863fe2c32334fd7579f4080d7dfd03 (patch) | |
tree | 2de9f32f75cf1c2b9cf5c898bda613129bbe073e | |
parent | 3eb70a00300008cc8d36ae59cd55a5c13282ff3a (diff) | |
download | application-1824590de7863fe2c32334fd7579f4080d7dfd03.tar.gz application-1824590de7863fe2c32334fd7579f4080d7dfd03.tar.bz2 application-1824590de7863fe2c32334fd7579f4080d7dfd03.zip |
Initialize Tizen.Applications.ToastMessage
Signed-off-by: seungha.son <seungha.son@samsung.com>
Change-Id: I9a8ed7dc5f20b7fbae5fe6224d1592b982209a51
15 files changed, 322 insertions, 25 deletions
diff --git a/Tizen.Applications.Notification/Interop/Interop.Notification.cs b/Tizen.Applications.Notification/Interop/Interop.Notification.cs index 7ddb1d4..5252adb 100755 --- a/Tizen.Applications.Notification/Interop/Interop.Notification.cs +++ b/Tizen.Applications.Notification/Interop/Interop.Notification.cs @@ -146,9 +146,6 @@ internal static partial class Interop [DllImport(Libraries.Notification, EntryPoint = "notification_get_tag")] internal static extern int GetTag(SafeNotificationHandle handle, out IntPtr tag); - [DllImport(Libraries.Notification, EntryPoint = "notification_status_message_post")] - internal static extern int PostMessage(string text); - [DllImport(Libraries.Notification, EntryPoint = "notification_load_by_tag")] internal static extern SafeNotificationHandle Load(string text); diff --git a/Tizen.Applications.Notification/Tizen.Applications/NotificationManager.cs b/Tizen.Applications.Notification/Tizen.Applications/NotificationManager.cs index 3e43764..c9abb3b 100755 --- a/Tizen.Applications.Notification/Tizen.Applications/NotificationManager.cs +++ b/Tizen.Applications.Notification/Tizen.Applications/NotificationManager.cs @@ -160,26 +160,6 @@ namespace Tizen.Applications.Notifications } /// <summary> - /// Posts a message on a toast popup - /// </summary> - /// <param name="text">Text to display on popup</param> - /// <exception cref="ArgumentNullException">Thrown when argument is null</exception> - /// <example> - /// <code> - /// string msg = "hey there!!"; - /// NotificationManager.PostToastMessage(msg); - /// </code> - /// </example> - public static void PostToastMessage(string text) - { - int ret = Interop.Notification.PostMessage(text); - if(ret != (int)NotificationError.None) - { - throw NotificationErrorFactory.GetException((NotificationError)ret, "post toast message failed"); - } - } - - /// <summary> /// Searches for a posted notification which has the inputted tag /// </summary> /// <remarks> diff --git a/Tizen.Applications.ToastMessage/Interop/Interop.Libraries.cs b/Tizen.Applications.ToastMessage/Interop/Interop.Libraries.cs new file mode 100755 index 0000000..c284ac5 --- /dev/null +++ b/Tizen.Applications.ToastMessage/Interop/Interop.Libraries.cs @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2017 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. + */ + +internal static partial class Interop +{ + internal static partial class Libraries + { + public const string ToastMessage = "libnotification.so.0"; + } +} diff --git a/Tizen.Applications.ToastMessage/Interop/Interop.ToastMessage.cs b/Tizen.Applications.ToastMessage/Interop/Interop.ToastMessage.cs new file mode 100755 index 0000000..69e49db --- /dev/null +++ b/Tizen.Applications.ToastMessage/Interop/Interop.ToastMessage.cs @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2017 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; +using System.Runtime.InteropServices; +using Tizen.Applications; + +internal static partial class Interop +{ + internal static class ToastMessage + { + [DllImport(Libraries.ToastMessage, EntryPoint = "notification_status_message_post")] + internal static extern int ToastMessagePost(string message); + } +} diff --git a/Tizen.Applications.ToastMessage/Properties/AssemblyInfo.cs b/Tizen.Applications.ToastMessage/Properties/AssemblyInfo.cs new file mode 100755 index 0000000..46f164d --- /dev/null +++ b/Tizen.Applications.ToastMessage/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Tizen.Applications.ToastMessage")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Samsung Electronics")] +[assembly: AssemblyProduct("Tizen.Applications")] +[assembly: AssemblyCopyright("Copyright (c) 2017 Samsung Electronics Co., Ltd")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] +[assembly: CLSCompliant(true)] + +[assembly: Guid("d2d1a3ce-000e-4ab3-81c4-a8a44a008989")] + +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.csproj b/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.csproj new file mode 100755 index 0000000..2c7f346 --- /dev/null +++ b/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.csproj @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{C35F85FC-A095-4356-8F17-DD248FB1C9AA}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace> + </RootNamespace> + <AssemblyName>Tizen.Applications.ToastMessage</AssemblyName> + <FileAlignment>512</FileAlignment> + </PropertyGroup> + <PropertyGroup> + <TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier> + <TargetFrameworkVersion>v1.3</TargetFrameworkVersion> + <NuGetTargetMoniker>.NETStandard,Version=v1.3</NuGetTargetMoniker> + <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences> + <NoStdLib>true</NoStdLib> + <NoWarn>$(NoWarn);1701;1702</NoWarn> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + </PropertyGroup> + <PropertyGroup> + <SignAssembly>true</SignAssembly> + </PropertyGroup> + <PropertyGroup> + <AssemblyOriginatorKeyFile>Tizen.Applications.ToastMessage.snk</AssemblyOriginatorKeyFile> + </PropertyGroup> + <ItemGroup> + <Compile Include="Interop\Interop.Libraries.cs" /> + <Compile Include="Interop\Interop.ToastMessage.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Tizen.Applications\ToastMessage.cs" /> + <Compile Include="Tizen.Applications\ToastMessageErrorFactory.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="Tizen.Applications.ToastMessage.project.json" /> + <None Include="Tizen.Applications.ToastMessage.snk" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Tizen.Applications.Common\Tizen.Applications.Common.csproj"> + <Project>{663c5a3d-e631-4987-aee7-f498c56a40fc}</Project> + <Name>Tizen.Applications.Common</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> + <PropertyGroup> + <!-- https://github.com/dotnet/corefxlab/tree/master/samples/NetCoreSample and + https://docs.microsoft.com/en-us/dotnet/articles/core/tutorials/target-dotnetcore-with-msbuild + --> + <!-- We don't use any of MSBuild's resolution logic for resolving the framework, so just set these two + properties to any folder that exists to skip the GetReferenceAssemblyPaths task (not target) and + to prevent it from outputting a warning (MSB3644). + --> + <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory)</_TargetFrameworkDirectories> + <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths> + <AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences> + </PropertyGroup> +</Project> diff --git a/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.nuspec b/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.nuspec new file mode 100755 index 0000000..1c1760f --- /dev/null +++ b/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.nuspec @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<package> + <metadata> + <id>Tizen.Applications.ToastMessage</id> + <version>$version$</version> + <authors>Samsung Electronics</authors> + <requireLicenseAcceptance>false</requireLicenseAcceptance> + <licenseUrl>https://www.apache.org/licenses/LICENSE-2.0</licenseUrl> + <projectUrl>https://www.tizen.org/</projectUrl> + <iconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</iconUrl> + <copyright>© Samsung Electronics Co., Ltd All Rights Reserved</copyright> + <description>Provides the Application Frameworks API for Tizen.Net</description> + <dependencies> + <dependency id="Tizen" version="1.0.2" /> + <dependency id="Tizen.Applications.Common" version="1.2.0" /> + </dependencies> + </metadata> + <files> + <file src="bin/$Configuration$/Tizen.Applications.ToastMessage.dll" target="lib/netstandard1.3" /> + </files> +</package> diff --git a/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.project.json b/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.project.json new file mode 100755 index 0000000..55ec093 --- /dev/null +++ b/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.project.json @@ -0,0 +1,9 @@ +{ + "dependencies": { + "NETStandard.Library": "1.6.0", + "Tizen": "1.0.2" + }, + "frameworks": { + "netstandard1.3": {} + } +} diff --git a/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.snk b/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.snk Binary files differnew file mode 100755 index 0000000..7ac1b00 --- /dev/null +++ b/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.snk diff --git a/Tizen.Applications.ToastMessage/Tizen.Applications/ToastMessage.cs b/Tizen.Applications.ToastMessage/Tizen.Applications/ToastMessage.cs new file mode 100755 index 0000000..9b85824 --- /dev/null +++ b/Tizen.Applications.ToastMessage/Tizen.Applications/ToastMessage.cs @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2017 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; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tizen.Applications +{ + public sealed class ToastMessage + { + + /// <summary> + /// Gets and sets message to post ToastMessage + /// </summary> + public string Message { get; set; } + + /// <summary> + /// Posts a message on a toast popup + /// </summary> + /// <exception cref="ArgumentNullException">Thrown when Message is null</exception> + /// <example> + /// <code> + /// ToastMessage toast = new ToastMessage + /// { + /// Message = "Hello TIzen" + /// }; + /// toast.Post(); + /// </code> + /// </example> + public void Post() + { + int ret = Interop.ToastMessage.ToastMessagePost(Message); + if (ret != (int)ToastMessageError.None) + { + throw ToastMessageErrorFactory.GetException((ToastMessageError)ret, "post toast message failed"); + } + } + } + +} diff --git a/Tizen.Applications.ToastMessage/Tizen.Applications/ToastMessageErrorFactory.cs b/Tizen.Applications.ToastMessage/Tizen.Applications/ToastMessageErrorFactory.cs new file mode 100755 index 0000000..cd2eebc --- /dev/null +++ b/Tizen.Applications.ToastMessage/Tizen.Applications/ToastMessageErrorFactory.cs @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2017 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 +{ + internal enum ToastMessageError + { + None = Tizen.Internals.Errors.ErrorCode.None, + InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter, + DBusError = -0x01140000 | 0x03, + } + + internal class ToastMessageErrorFactory + { + private const string _logTag = "Tizen.Applications.ToastMessage"; + + internal static Exception GetException(ToastMessageError ret, string msg) + { + switch (ret) + { + case ToastMessageError.InvalidParameter: + Log.Error(_logTag, msg); + return new ArgumentException(ret + " error occurred."); + default: + Log.Error(_logTag, msg); + return new InvalidOperationException(ret + " error occurred."); + } + } + } +} diff --git a/Tizen.Applications.sln b/Tizen.Applications.sln index a270b3b..33c3708 100755 --- a/Tizen.Applications.sln +++ b/Tizen.Applications.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.25420.1 @@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Applications.UI", "Ti EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Applications", "Tizen.Applications\Tizen.Applications.csproj", "{6209641F-4B03-4DAD-84D8-4775AD72AD75}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Applications.ToastMessage", "Tizen.Applications.ToastMessage\Tizen.Applications.ToastMessage.csproj", "{C35F85FC-A095-4356-8F17-DD248FB1C9AA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -63,6 +65,10 @@ Global {6209641F-4B03-4DAD-84D8-4775AD72AD75}.Debug|Any CPU.Build.0 = Debug|Any CPU {6209641F-4B03-4DAD-84D8-4775AD72AD75}.Release|Any CPU.ActiveCfg = Release|Any CPU {6209641F-4B03-4DAD-84D8-4775AD72AD75}.Release|Any CPU.Build.0 = Release|Any CPU + {C35F85FC-A095-4356-8F17-DD248FB1C9AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C35F85FC-A095-4356-8F17-DD248FB1C9AA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C35F85FC-A095-4356-8F17-DD248FB1C9AA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C35F85FC-A095-4356-8F17-DD248FB1C9AA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Tizen.Applications/Interop/Interop.Libraries.cs b/Tizen.Applications/Interop/Interop.Libraries.cs index 9f909be..ecf4b10 100755 --- a/Tizen.Applications/Interop/Interop.Libraries.cs +++ b/Tizen.Applications/Interop/Interop.Libraries.cs @@ -32,5 +32,6 @@ internal static partial class Interop public const string Notification = "libnotification.so.0"; public const string Preference = "libcapi-appfw-preference.so.0"; public const string Alarm = "libcapi-appfw-alarm.so.0"; + public const string ToastMessage = "libnotification.so.0"; } } diff --git a/Tizen.Applications/Tizen.Applications.csproj b/Tizen.Applications/Tizen.Applications.csproj index 2600bae..f74d4a0 100755 --- a/Tizen.Applications/Tizen.Applications.csproj +++ b/Tizen.Applications/Tizen.Applications.csproj @@ -92,6 +92,7 @@ <Compile Include="../Tizen.Applications.PackageManager/Interop/Interop.PackageManager.cs" /> <Compile Include="../Tizen.Applications.Preference/Interop/Interop.Preference.cs" /> <Compile Include="../Tizen.Applications.Service/Interop/Interop.Service.cs" /> + <Compile Include="../Tizen.Applications.ToastMessage/Interop/Interop.ToastMessage.cs" /> <Compile Include="../Tizen.Applications.Common/Tizen.Applications/LocaleChangedEventArgs.cs" /> <Compile Include="../Tizen.Applications.Common/Tizen.Applications/LowBatteryEventArgs.cs" /> <Compile Include="../Tizen.Applications.Common/Tizen.Applications/LowBatteryStatus.cs" /> @@ -134,6 +135,8 @@ <Compile Include="../Tizen.Applications.UI/Tizen.Applications.CoreBackend/UICoreBackend.cs" /> <Compile Include="../Tizen.Applications.Common/Tizen.Applications/DeviceOrientationEventArgs.cs" /> <Compile Include="../Tizen.Applications.Common/Tizen.Applications/DeviceOrientation.cs" /> + <Compile Include="../Tizen.Applications.ToastMessage/Tizen.Applications/ToastMessage.cs" /> + <Compile Include="../Tizen.Applications.ToastMessage/Tizen.Applications/ToastMessageErrorFactory.cs" /> </ItemGroup> <ItemGroup> <None Include="Tizen.Applications.project.json" /> diff --git a/packaging/csapi-application.spec b/packaging/csapi-application.spec index fb034de..1e41090 100755 --- a/packaging/csapi-application.spec +++ b/packaging/csapi-application.spec @@ -16,7 +16,7 @@ BuildRequires: dotnet-build-tools # C# API Requires BuildRequires: csapi-tizen-nuget -%define Assemblies Tizen.Applications.Common Tizen.Applications.MessagePort Tizen.Applications.Service Tizen.Applications.PackageManager Tizen.Applications.Notification Tizen.Applications.Preference Tizen.Applications.Alarm Tizen.Applications.UI Tizen.Applications +%define Assemblies Tizen.Applications.Common Tizen.Applications.MessagePort Tizen.Applications.Service Tizen.Applications.PackageManager Tizen.Applications.Notification Tizen.Applications.Preference Tizen.Applications.Alarm Tizen.Applications.UI Tizen.Applications Tizen.Applications.ToastMessage %description %{summary} @@ -92,6 +92,22 @@ Group: Development/Libraries %description -n csapi-application-notification-nuget A notification library in Tizen C# API package. +%package -n csapi-application-toastmessage +Summary: A toastmessage library in Tizen C# API +Group: Development/Libraries +AutoReqProv: no +ExcludeArch: aarch64 + +%description -n csapi-application-toastmessage +A toastmessage library in Tizen C# API package. + +%package -n csapi-application-toastmessage-nuget +Summary: A toastmessage library in Tizen C# API +Group: Development/Libraries + +%description -n csapi-application-toastmessage-nuget +A toastmessage library in Tizen C# API package. + %package -n csapi-application-preference Summary: A preference library in Tizen C# API Group: Development/Libraries @@ -210,6 +226,14 @@ done %files -n csapi-application-notification-nuget /nuget/Tizen.Applications.Notification.%{version}.nupkg +%files -n csapi-application-toastmessage +%manifest %{name}.manifest +%license LICENSE +%attr(644,root,root) %{_dotnet_assembly_path}/Tizen.Applications.ToastMessage.dll + +%files -n csapi-application-toastmessage-nuget +/nuget/Tizen.Applications.ToastMessage.%{version}.nupkg + %files -n csapi-application-preference %manifest %{name}.manifest %license LICENSE |