diff options
Diffstat (limited to 'Tizen.WebView.Test')
-rw-r--r-- | Tizen.WebView.Test/Properties/AssemblyInfo.cs | 36 | ||||
-rw-r--r-- | Tizen.WebView.Test/SimpleWebviewApp.cs | 278 | ||||
-rwxr-xr-x | Tizen.WebView.Test/Tizen.WebView.Test.csproj | 98 | ||||
-rw-r--r-- | Tizen.WebView.Test/Tizen.WebView.Test.project.json | 14 | ||||
-rw-r--r-- | Tizen.WebView.Test/shared/res/Tizen.WebView.Test.png | bin | 0 -> 57662 bytes | |||
-rw-r--r-- | Tizen.WebView.Test/tizen-manifest.xml | 19 |
6 files changed, 445 insertions, 0 deletions
diff --git a/Tizen.WebView.Test/Properties/AssemblyInfo.cs b/Tizen.WebView.Test/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..6200996 --- /dev/null +++ b/Tizen.WebView.Test/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Tizen.WebView.Test")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Samsung Electronics")]
+[assembly: AssemblyProduct("Tizen.WebView.Test")]
+[assembly: AssemblyCopyright("Copyright © Samsung Electronics 2017")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("b57dafa3-b566-4ebf-a6f0-ecd2224a748d")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Tizen.WebView.Test/SimpleWebviewApp.cs b/Tizen.WebView.Test/SimpleWebviewApp.cs new file mode 100644 index 0000000..ffa3eeb --- /dev/null +++ b/Tizen.WebView.Test/SimpleWebviewApp.cs @@ -0,0 +1,278 @@ +/* + * 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 ElmSharp; +using Tizen.Applications; +using Tizen.WebView; + + +namespace Tizen.WebView.Test +{ + public class SimpleWebviewApp : CoreUIApplication + { + private const string LogTag = "WebViewApp"; + + private const string _windowName = "Simple WebView App"; + private const string _defaultUrl = "http://www.google.com"; + private WebView _webview; + private Entry _addressEntry; + private Button _reloadButton; + + public SimpleWebviewApp() + { + + } + + protected override void OnCreate() + { + base.OnCreate(); + Chromium.Initialize(); + // Create webview and toolbox + CreateUI(); + } + + protected override void OnTerminate() + { + Chromium.Shutdown(); + base.OnTerminate(); + } + + private void CreateUI() + { + // Create Window + Window window = new Window(_windowName); + window.Show(); + + // Create Box for main window + Box mainBox = CreateBaseUI(window); + + // Create top bar + Box topBar = CreateTopBar(window); + + // Create Webview + _webview = new WebView(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + _webview.Show(); + + // Create bottom bar + Box bottomBar = CreateBottomBar(window); + + mainBox.PackEnd(topBar); + mainBox.PackEnd(_webview); + mainBox.PackEnd(bottomBar); + + InitializeWebView(); + + // Load default URL + _webview.LoadUrl(_defaultUrl); + } + + private Box CreateBaseUI(Window window) + { + // Create Background + Background background = new Background(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + Color = Color.White + }; + background.Show(); + window.AddResizeObject(background); + + // Create Conformant + Conformant conformant = new Conformant(window); + conformant.Show(); + + // Create Box for all contents + Box box = new Box(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + box.Show(); + conformant.SetContent(box); + + return box; + } + + private Box CreateTopBar(Window window) + { + // Create Box for address bar + Box topBar = new Box(window) + { + AlignmentX = -1, + AlignmentY = 0, + WeightX = 1, + WeightY = 0, + IsHorizontal = true + }; + topBar.Show(); + + // Create address entry + _addressEntry = new Entry(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + IsSingleLine = true, + Scrollable = true, + Text = _defaultUrl + }; + _addressEntry.SetInputPanelLayout(InputPanelLayout.Url); + _addressEntry.Activated += (s, e) => + { + _webview.LoadUrl(((Entry)s).Text); + }; + _addressEntry.Show(); + + // Create reload button + _reloadButton = new Button(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 0.3, + WeightY = 1, + Text = "Reload" + }; + _reloadButton.Clicked += (s, e) => + { + if (_reloadButton.Text.Equals("Reload")) + { + _webview.Reload(); + } + else if (_reloadButton.Text.Equals("Stop")) + { + _webview.StopLoading(); + } + }; + _reloadButton.Show(); + + topBar.PackEnd(_addressEntry); + topBar.PackEnd(_reloadButton); + + return topBar; + } + + private Box CreateBottomBar(Window window) + { + // Create Box for bottom bar + Box bottomBar = new Box(window) + { + AlignmentX = -1, + AlignmentY = 1, + WeightX = 1, + WeightY = 0, + IsHorizontal = true + }; + bottomBar.Show(); + + // Create back/forward buttons + Button backButton = new Button(window) + { + AlignmentX = -1, + AlignmentY = 0.5, + WeightX = 1, + WeightY = 1, + Text = "Back" + + }; + backButton.Clicked += (s, e) => + { + if (_webview.CanGoBack()) + _webview.GoBack(); + }; + backButton.Show(); + + Button forwardButton = new Button(window) + { + AlignmentX = -1, + AlignmentY = 0.5, + WeightX = 1, + WeightY = 1, + Text = "Forward" + + }; + forwardButton.Clicked += (s, e) => + { + if (_webview.CanGoForward()) + _webview.GoForward(); + }; + forwardButton.Show(); + + bottomBar.PackEnd(backButton); + bottomBar.PackEnd(forwardButton); + + return bottomBar; + } + + private void InitializeWebView() + { + _webview.LoadStarted += (s, e) => + { + Log.Info(LogTag, "Load started"); + _reloadButton.Text = "Stop"; + }; + + _webview.LoadFinished += (s, e) => + { + Log.Info(LogTag, "Load finished"); + _reloadButton.Text = "Reload"; + }; + + _webview.LoadError += (s, e) => + { + Log.Info(LogTag, "Load error(" + e.Code + "): " + e.Description); + }; + + _webview.UrlChanged += (s, e) => + { + Log.Info(LogTag, "Url changed: " + e.GetAsString()); + _addressEntry.Text = e.GetAsString(); + }; + + CookieManager cookieManager = _webview.GetContext().GetCookieManager(); + if (cookieManager != null) + { + cookieManager.SetCookieAcceptPolicy(CookieAcceptPolicy.Always); + cookieManager.SetPersistentStorage(DirectoryInfo.Data, CookiePersistentStorage.SqlLite); + } + } + + static void Main(string[] args) + { + Elementary.Initialize(); + Elementary.ThemeOverlay(); + + SimpleWebviewApp app = new Test.SimpleWebviewApp(); + app.Run(args); + } + } +} diff --git a/Tizen.WebView.Test/Tizen.WebView.Test.csproj b/Tizen.WebView.Test/Tizen.WebView.Test.csproj new file mode 100755 index 0000000..9a6ebb1 --- /dev/null +++ b/Tizen.WebView.Test/Tizen.WebView.Test.csproj @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.30703</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectTypeGuids>{2F98DAC9-6F16-457B-AED7-D43CAC379341};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ProjectGuid>{B57DAFA3-B566-4EBF-A6F0-ECD2224A748D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Tizen.WebView.Test</RootNamespace> + <AssemblyName>Tizen.WebView.Test</AssemblyName> + <FileAlignment>512</FileAlignment> + <DefaultLanguage>en-US</DefaultLanguage> + </PropertyGroup> + <PropertyGroup> + <TargetFrameworkIdentifier>DNXCore</TargetFrameworkIdentifier> + <TargetFrameworkVersion>v5.0</TargetFrameworkVersion> + <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences> + <NuGetTargetMoniker>.NETCoreApp,Version=v1.0</NuGetTargetMoniker> + <NoStdLib>true</NoStdLib> + <NoWarn>$(NoWarn);1701</NoWarn> + <UseVSHostingProcess>false</UseVSHostingProcess> + </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> + <NoWarn>;1701;1702</NoWarn> + <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> + <NoWarn>;1701;1702</NoWarn> + <DebugSymbols>true</DebugSymbols> + </PropertyGroup> + <ItemGroup> + <None Include="Tizen.WebView.Test.project.json" /> + <None Include="tizen-manifest.xml" /> + <None Include="shared\res\Tizen.WebView.Test.png" /> + </ItemGroup> + <ItemGroup> + <Compile Include="SimpleWebviewApp.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <Folder Include="lib\" /> + <Folder Include="res\" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Tizen.WebView\Tizen.WebView.csproj"> + <Project>{8405e84f-b920-4aac-9ad5-001b9debc9ca}</Project> + <Name>Tizen.WebView</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> + <ProjectExtensions> + <VisualStudio> + <FlavorProperties GUID="{2F98DAC9-6F16-457B-AED7-D43CAC379341}" Configuration="Debug|Any CPU"> + <ProjectCorporateFlavorCfg /> + </FlavorProperties> + <FlavorProperties GUID="{2F98DAC9-6F16-457B-AED7-D43CAC379341}" Configuration="Release|Any CPU"> + <ProjectCorporateFlavorCfg /> + </FlavorProperties> + </VisualStudio> + </ProjectExtensions> +</Project> diff --git a/Tizen.WebView.Test/Tizen.WebView.Test.project.json b/Tizen.WebView.Test/Tizen.WebView.Test.project.json new file mode 100644 index 0000000..8de2d93 --- /dev/null +++ b/Tizen.WebView.Test/Tizen.WebView.Test.project.json @@ -0,0 +1,14 @@ +{ + "dependencies": { + "ElmSharp": "1.1.0-*", + "Microsoft.NETCore.App": "1.0.0", + "Tizen": "1.0.2", + "Tizen.Applications": "1.2.0" + }, + "frameworks": { + "netcoreapp1.0": {} + }, + "runtimes": { + "win": {} + } +} diff --git a/Tizen.WebView.Test/shared/res/Tizen.WebView.Test.png b/Tizen.WebView.Test/shared/res/Tizen.WebView.Test.png Binary files differnew file mode 100644 index 0000000..9765b1b --- /dev/null +++ b/Tizen.WebView.Test/shared/res/Tizen.WebView.Test.png diff --git a/Tizen.WebView.Test/tizen-manifest.xml b/Tizen.WebView.Test/tizen-manifest.xml new file mode 100644 index 0000000..513985e --- /dev/null +++ b/Tizen.WebView.Test/tizen-manifest.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns="http://tizen.org/ns/packages" api-version="3.0" package="Tizen.WebView.Test" version="1.0.0"> + <profile name="common" /> + <ui-application appid="org.tizen.Tizen.WebView.Test" + exec="Tizen.WebView.Test.exe" + type="dotnet" + multiple="false" + taskmanage="true" + launch_mode="single"> + <icon>Tizen.WebView.Test.png</icon> + <label>Tizen.WebView.Test</label> + </ui-application> + <privileges> + <privilege>http://tizen.org/privilege/mediastorage</privilege> + <privilege>http://tizen.org/privilege/externalstorage</privilege> + <privilege>http://tizen.org/privilege/network.get</privilege> + <privilege>http://tizen.org/privilege/internet</privilege> + </privileges> +</manifest> |