Skip to content

Commit cb747a0

Browse files
committed
Add base UWPUno example
1 parent b21c91c commit cb747a0

File tree

81 files changed

+3398
-3
lines changed

Some content is hidden

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

81 files changed

+3398
-3
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: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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>{B7759D42-229D-47CB-96A2-E99DB18AA316}</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.UWPUno.Example.Droid</RootNamespace>
13+
<AssemblyName>CSharpMath.UWPUno.Example.Droid</AssemblyName>
14+
<FileAlignment>512</FileAlignment>
15+
<AndroidApplication>true</AndroidApplication>
16+
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
17+
<AndroidUseAapt2>true</AndroidUseAapt2>
18+
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
19+
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk>
20+
<TargetFrameworkVersion>v10.0</TargetFrameworkVersion>
21+
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
22+
<AndroidUseIntermediateDesignerFile>True</AndroidUseIntermediateDesignerFile>
23+
<ResourcesDirectory>..\CSharpMath.UWPUno.Example.Shared\Strings</ResourcesDirectory>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
26+
<DebugSymbols>true</DebugSymbols>
27+
<DebugType>portable</DebugType>
28+
<Optimize>false</Optimize>
29+
<OutputPath>bin\Debug\</OutputPath>
30+
<DefineConstants>DEBUG;TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
34+
<AndroidLinkMode>None</AndroidLinkMode>
35+
</PropertyGroup>
36+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
37+
<DebugType>portable</DebugType>
38+
<DebugSymbols>true</DebugSymbols>
39+
<AndroidManagedSymbols>true</AndroidManagedSymbols>
40+
<Optimize>true</Optimize>
41+
<OutputPath>bin\Release\</OutputPath>
42+
<DefineConstants>TRACE</DefineConstants>
43+
<ErrorReport>prompt</ErrorReport>
44+
<WarningLevel>4</WarningLevel>
45+
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
46+
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
47+
<AndroidCreatePackagePerAbi>true</AndroidCreatePackagePerAbi>
48+
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
49+
<AotAssemblies>true</AotAssemblies>
50+
<EnableLLVM>true</EnableLLVM>
51+
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
52+
</PropertyGroup>
53+
<ItemGroup>
54+
<Reference Include="Mono.Android" />
55+
<Reference Include="Mono.Android.Export" />
56+
<Reference Include="mscorlib" />
57+
<Reference Include="System" />
58+
<Reference Include="System.Core" />
59+
<Reference Include="System.Xml.Linq" />
60+
<Reference Include="System.Xml" />
61+
</ItemGroup>
62+
<ItemGroup>
63+
<PackageReference Include="Uno.UI" Version="3.4.0" />
64+
<PackageReference Include="Uno.UI.RemoteControl" Version="3.4.0" Condition="'$(Configuration)'=='Debug'" />
65+
<PackageReference Include="Uno.UniversalImageLoader" Version="1.9.33" />
66+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" />
67+
<PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.1" />
68+
</ItemGroup>
69+
<ItemGroup>
70+
<Compile Include="MainActivity.cs" />
71+
<Compile Include="Properties\AssemblyInfo.cs" />
72+
<Compile Include="Main.cs" />
73+
</ItemGroup>
74+
<ItemGroup>
75+
<AndroidAsset Include="Assets\Fonts\uno-fluentui-assets.ttf" />
76+
<None Include="Resources\AboutResources.txt" />
77+
<None Include="Assets\AboutAssets.txt" />
78+
</ItemGroup>
79+
<ItemGroup>
80+
<AndroidResource Include="Resources\values\Strings.xml" />
81+
</ItemGroup>
82+
<ItemGroup>
83+
<AndroidResource Include="Resources\drawable\Icon.png" />
84+
</ItemGroup>
85+
<ItemGroup>
86+
<None Include="Properties\AndroidManifest.xml" />
87+
</ItemGroup>
88+
<ItemGroup>
89+
<AndroidResource Include="Resources\values\Styles.xml" />
90+
</ItemGroup>
91+
<ItemGroup>
92+
<ProjectReference Include="..\..\CSharpMath.UWPUno\CSharpMath.UWPUno.csproj">
93+
<Project>{5c46ca75-fa31-4281-80eb-a07750e1fecb}</Project>
94+
<Name>CSharpMath.UWPUno</Name>
95+
</ProjectReference>
96+
</ItemGroup>
97+
<Import Project="..\CSharpMath.UWPUno.Example.Shared\CSharpMath.UWPUno.Example.Shared.projitems" Label="Shared" Condition="Exists('..\CSharpMath.UWPUno.Example.Shared\CSharpMath.UWPUno.Example.Shared.projitems')" />
98+
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
99+
<!-- This will force the generation of the APK when not building inside visual studio -->
100+
<Target Name="GenerateBuild" DependsOnTargets="SignAndroidPackage" AfterTargets="Build" Condition="'$(BuildingInsideVisualStudio)'==''" />
101+
<Target Name="Issue3897Workaround" Condition=" '$(ManagedDesignTimeBuild)' == 'True' " AfterTargets="_RemoveLegacyDesigner">
102+
<!-- See https://github.com/unoplatform/uno/issues/3897 and https://github.com/xamarin/xamarin-android/issues/5069 for more details -->
103+
<ItemGroup>
104+
<Compile Remove="$(_AndroidResourceDesignerFile)" />
105+
</ItemGroup>
106+
</Target>
107+
</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.UWPUno.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.UWPUno.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.UWPUno.Example" android:versionCode="1" android:versionName="1.0">
3+
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="29" />
4+
<application android:label="CSharpMath.UWPUno.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.UWPUno.Example.Droid")]
10+
[assembly: AssemblyDescription("")]
11+
[assembly: AssemblyConfiguration("")]
12+
[assembly: AssemblyCompany("")]
13+
[assembly: AssemblyProduct("CSharpMath.UWPUno.Example.Droid")]
14+
[assembly: AssemblyCopyright("Copyright © 2021")]
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.UWPUno.Example</string>
5+
</resources>

0 commit comments

Comments
 (0)