Skip to content

Commit 52bf59f

Browse files
committed
test: Add Uno Platform example project
1 parent ca8a7d1 commit 52bf59f

File tree

76 files changed

+3268
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+3268
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Any raw assets you want to be deployed with your application can be placed in
2+
this directory (and child directories) and given a Build Action of "AndroidAsset".
3+
4+
These files will be deployed with you package and will be accessible using Android's
5+
AssetManager, like this:
6+
7+
public class ReadAsset : Activity
8+
{
9+
protected override void OnCreate (Bundle bundle)
10+
{
11+
base.OnCreate (bundle);
12+
13+
InputStream input = Assets.Open ("my_asset.txt");
14+
}
15+
}
16+
17+
Additionally, some Android functions will automatically load asset files:
18+
19+
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{A3518BE3-CCA9-4822-ACE9-84961DF0D1EE}</ProjectGuid>
9+
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
10+
<OutputType>Library</OutputType>
11+
<AppDesignerFolder>Properties</AppDesignerFolder>
12+
<RootNamespace>CSharpMath.Uno.Example.Droid</RootNamespace>
13+
<AssemblyName>CSharpMath.Uno.Example.Droid</AssemblyName>
14+
<FileAlignment>512</FileAlignment>
15+
<AndroidApplication>true</AndroidApplication>
16+
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
17+
<!-- AndroidUseAapt2 is disabled until https://github.com/unoplatform/uno/issues/1382 is resolved -->
18+
<AndroidUseAapt2>false</AndroidUseAapt2>
19+
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
20+
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk>
21+
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
22+
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
23+
<AndroidUseIntermediateDesignerFile>True</AndroidUseIntermediateDesignerFile>
24+
<ResourcesDirectory>..\CSharpMath.Uno.Example.Shared\Strings</ResourcesDirectory>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
27+
<DebugSymbols>true</DebugSymbols>
28+
<DebugType>portable</DebugType>
29+
<Optimize>false</Optimize>
30+
<OutputPath>bin\Debug\</OutputPath>
31+
<DefineConstants>DEBUG;TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
35+
<AndroidLinkMode>None</AndroidLinkMode>
36+
</PropertyGroup>
37+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
38+
<DebugType>portable</DebugType>
39+
<DebugSymbols>true</DebugSymbols>
40+
<AndroidManagedSymbols>true</AndroidManagedSymbols>
41+
<Optimize>true</Optimize>
42+
<OutputPath>bin\Release\</OutputPath>
43+
<DefineConstants>TRACE</DefineConstants>
44+
<ErrorReport>prompt</ErrorReport>
45+
<WarningLevel>4</WarningLevel>
46+
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
47+
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
48+
<AndroidCreatePackagePerAbi>true</AndroidCreatePackagePerAbi>
49+
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
50+
<AotAssemblies>true</AotAssemblies>
51+
<EnableLLVM>true</EnableLLVM>
52+
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
53+
</PropertyGroup>
54+
<ItemGroup>
55+
<Reference Include="Mono.Android" />
56+
<Reference Include="Mono.Android.Export" />
57+
<Reference Include="mscorlib" />
58+
<Reference Include="System" />
59+
<Reference Include="System.Core" />
60+
<Reference Include="System.Xml.Linq" />
61+
<Reference Include="System.Xml" />
62+
</ItemGroup>
63+
<ItemGroup>
64+
<PackageReference Include="Uno.UI" Version="2.4.0" />
65+
<PackageReference Include="Uno.UI.RemoteControl" Version="2.4.0" Condition="'$(Configuration)'=='Debug'" />
66+
<PackageReference Include="Uno.UniversalImageLoader" Version="1.9.32" />
67+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" />
68+
<PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.1" />
69+
</ItemGroup>
70+
<ItemGroup>
71+
<Compile Include="MainActivity.cs" />
72+
<Compile Include="Properties\AssemblyInfo.cs" />
73+
<Compile Include="Main.cs" />
74+
</ItemGroup>
75+
<ItemGroup>
76+
<AndroidAsset Include="Assets\Fonts\winjs-symbols.ttf" />
77+
<None Include="Resources\AboutResources.txt" />
78+
<None Include="Assets\AboutAssets.txt" />
79+
</ItemGroup>
80+
<ItemGroup>
81+
<AndroidResource Include="Resources\values\Strings.xml" />
82+
</ItemGroup>
83+
<ItemGroup>
84+
<AndroidResource Include="Resources\drawable\Icon.png" />
85+
</ItemGroup>
86+
<ItemGroup>
87+
<None Include="Properties\AndroidManifest.xml" />
88+
</ItemGroup>
89+
<ItemGroup>
90+
<AndroidResource Include="Resources\values\Styles.xml" />
91+
</ItemGroup>
92+
<ItemGroup>
93+
<ProjectReference Include="..\..\CSharpMath.Rendering\CSharpMath.Rendering.csproj">
94+
<Project>{65016a61-2125-4e0c-90e8-a915230c7826}</Project>
95+
<Name>CSharpMath.Rendering</Name>
96+
</ProjectReference>
97+
<ProjectReference Include="..\..\CSharpMath.SkiaSharp\CSharpMath.SkiaSharp.csproj">
98+
<Project>{35b4bb5b-2202-436e-9afe-00997ca2cc65}</Project>
99+
<Name>CSharpMath.SkiaSharp</Name>
100+
</ProjectReference>
101+
<ProjectReference Include="..\..\CSharpMath.Uno\CSharpMath.Uno.csproj">
102+
<Project>{cbfa75c9-5b10-4df9-bc52-1559f9a664d5}</Project>
103+
<Name>CSharpMath.Uno</Name>
104+
</ProjectReference>
105+
<ProjectReference Include="..\..\CSharpMath\CSharpMath.csproj">
106+
<Project>{5157367b-f03e-4acb-83a1-0de414a3bfca}</Project>
107+
<Name>CSharpMath</Name>
108+
</ProjectReference>
109+
</ItemGroup>
110+
<Import Project="..\CSharpMath.Uno.Example.Shared\CSharpMath.Uno.Example.Shared.projitems" Label="Shared" Condition="Exists('..\CSharpMath.Uno.Example.Shared\CSharpMath.Uno.Example.Shared.projitems')" />
111+
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
112+
<!-- This will force the generation of the APK when not building inside visual studio -->
113+
<Target Name="GenerateBuild" DependsOnTargets="SignAndroidPackage" AfterTargets="Build" Condition="'$(BuildingInsideVisualStudio)'==''" />
114+
</Project>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
using Android.App;
7+
using Android.Content;
8+
using Android.OS;
9+
using Android.Runtime;
10+
using Android.Views;
11+
using Android.Widget;
12+
using Com.Nostra13.Universalimageloader.Core;
13+
using Windows.UI.Xaml.Media;
14+
15+
namespace CSharpMath.Uno.Example.Droid
16+
{
17+
[global::Android.App.ApplicationAttribute(
18+
Label = "@string/ApplicationName",
19+
LargeHeap = true,
20+
HardwareAccelerated = true,
21+
Theme = "@style/AppTheme"
22+
)]
23+
public class Application : Windows.UI.Xaml.NativeApplication
24+
{
25+
public Application(IntPtr javaReference, JniHandleOwnership transfer)
26+
: base(() => new App(), javaReference, transfer)
27+
{
28+
ConfigureUniversalImageLoader();
29+
}
30+
31+
private void ConfigureUniversalImageLoader()
32+
{
33+
// Create global configuration and initialize ImageLoader with this config
34+
ImageLoaderConfiguration config = new ImageLoaderConfiguration
35+
.Builder(Context)
36+
.Build();
37+
38+
ImageLoader.Instance.Init(config);
39+
40+
ImageSource.DefaultImageLoader = ImageLoader.Instance.LoadImageAsync;
41+
}
42+
}
43+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Android.App;
2+
using Android.Widget;
3+
using Android.OS;
4+
using Android.Content.PM;
5+
using Android.Views;
6+
7+
namespace CSharpMath.Uno.Example.Droid
8+
{
9+
[Activity(
10+
MainLauncher = true,
11+
ConfigurationChanges = global::Uno.UI.ActivityHelper.AllConfigChanges,
12+
WindowSoftInputMode = SoftInput.AdjustPan | SoftInput.StateHidden
13+
)]
14+
public class MainActivity : Windows.UI.Xaml.ApplicationActivity
15+
{
16+
}
17+
}
18+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="CSharpMath.Uno.Example" android:versionCode="1" android:versionName="1.0">
3+
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />
4+
<application android:label="CSharpMath.Uno.Example"></application>
5+
</manifest>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
using Android.App;
5+
6+
// General Information about an assembly is controlled through the following
7+
// set of attributes. Change these attribute values to modify the information
8+
// associated with an assembly.
9+
[assembly: AssemblyTitle("CSharpMath.Uno.Example.Droid")]
10+
[assembly: AssemblyDescription("")]
11+
[assembly: AssemblyConfiguration("")]
12+
[assembly: AssemblyCompany("")]
13+
[assembly: AssemblyProduct("CSharpMath.Uno.Example.Droid")]
14+
[assembly: AssemblyCopyright("Copyright © 2020")]
15+
[assembly: AssemblyTrademark("")]
16+
[assembly: AssemblyCulture("")]
17+
[assembly: ComVisible(false)]
18+
19+
// Version information for an assembly consists of the following four values:
20+
//
21+
// Major Version
22+
// Minor Version
23+
// Build Number
24+
// Revision
25+
//
26+
// You can specify all the values or you can default the Build and Revision Numbers
27+
// by using the '*' as shown below:
28+
// [assembly: AssemblyVersion("1.0.*")]
29+
[assembly: AssemblyVersion("1.0.0.0")]
30+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Images, layout descriptions, binary blobs and string dictionaries can be included
2+
in your application as resource files. Various Android APIs are designed to
3+
operate on the resource IDs instead of dealing with images, strings or binary blobs
4+
directly.
5+
6+
For example, a sample Android app that contains a user interface layout (main.axml),
7+
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8+
would keep its resources in the "Resources" directory of the application:
9+
10+
Resources/
11+
drawable/
12+
icon.png
13+
14+
layout/
15+
main.axml
16+
17+
values/
18+
strings.xml
19+
20+
In order to get the build system to recognize Android resources, set the build action to
21+
"AndroidResource". The native Android APIs do not operate directly with filenames, but
22+
instead operate on resource IDs. When you compile an Android application that uses resources,
23+
the build system will package the resources for distribution and generate a class called "R"
24+
(this is an Android convention) that contains the tokens for each one of the resources
25+
included. For example, for the above Resources layout, this is what the R class would expose:
26+
27+
public class R {
28+
public class drawable {
29+
public const int icon = 0x123;
30+
}
31+
32+
public class layout {
33+
public const int main = 0x456;
34+
}
35+
36+
public class strings {
37+
public const int first_string = 0xabc;
38+
public const int second_string = 0xbcd;
39+
}
40+
}
41+
42+
You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
43+
to reference the layout/main.axml file, or R.strings.first_string to reference the first
44+
string in the dictionary file values/strings.xml.
Loading
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string name="Hello">Hello World, Click Me!</string>
4+
<string name="ApplicationName">CSharpMath.Uno.Example</string>
5+
</resources>

0 commit comments

Comments
 (0)