Skip to content

Commit 005e596

Browse files
Merge pull request #116 from CodebreakerApp/113-uno-platform
113 uno platform
2 parents e273d26 + c034a9f commit 005e596

122 files changed

Lines changed: 4912 additions & 0 deletions

File tree

Some content is hidden

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

src/Codebreaker.Uno.sln

Lines changed: 271 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
<application android:allowBackup="true" android:supportsRtl="true"></application>
4+
</manifest>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
To add cross-platform image assets for your Uno Platform app, use the Assets folder
2+
in the shared project instead. Assets in this folder are Android-only assets.
3+
4+
Any raw assets you want to be deployed with your application can be placed in
5+
this directory (and child directories) and given a Build Action of "AndroidAsset".
6+
7+
These files will be deployed with you package and will be accessible using Android's
8+
AssetManager, like this:
9+
10+
public class ReadAsset : Activity
11+
{
12+
protected override void OnCreate (Bundle bundle)
13+
{
14+
base.OnCreate (bundle);
15+
16+
InputStream input = Assets.Open ("my_asset.txt");
17+
}
18+
}
19+
20+
Additionally, some Android functions will automatically load asset files:
21+
22+
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
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+
using Android.App;
6+
using Android.Content;
7+
using Android.OS;
8+
using Android.Runtime;
9+
using Android.Views;
10+
using Android.Widget;
11+
using Com.Nostra13.Universalimageloader.Core;
12+
using Microsoft.UI.Xaml.Media;
13+
14+
namespace CodeBreaker.Uno.Droid;
15+
16+
[global::Android.App.ApplicationAttribute(
17+
Label = "@string/ApplicationName",
18+
Icon = "@mipmap/icon",
19+
LargeHeap = true,
20+
HardwareAccelerated = true,
21+
Theme = "@style/AppTheme"
22+
)]
23+
public class Application : Microsoft.UI.Xaml.NativeApplication
24+
{
25+
public Application(IntPtr javaReference, JniHandleOwnership transfer)
26+
: base(() => new AppHead(), javaReference, transfer)
27+
{
28+
ConfigureUniversalImageLoader();
29+
}
30+
31+
private static 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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Android.App;
2+
using Android.Content.PM;
3+
using Android.OS;
4+
using Android.Views;
5+
using Android.Widget;
6+
7+
namespace CodeBreaker.Uno.Droid;
8+
9+
[Activity(
10+
MainLauncher = true,
11+
ConfigurationChanges = global::Uno.UI.ActivityHelper.AllConfigChanges,
12+
WindowSoftInputMode = SoftInput.AdjustNothing | SoftInput.StateHidden
13+
)]
14+
public class MainActivity : Microsoft.UI.Xaml.ApplicationActivity
15+
{
16+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
To add cross-platform image assets for your Uno Platform app, use the Assets folder
2+
in the shared project instead. Resources in this folder are Android-only.
3+
4+
Images, layout descriptions, binary blobs and string dictionaries can be included
5+
in your application as resource files. Various Android APIs are designed to
6+
operate on the resource IDs instead of dealing with images, strings or binary blobs
7+
directly.
8+
9+
For example, a sample Android app that contains a user interface layout (main.axml),
10+
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
11+
would keep its resources in the "Resources" directory of the application:
12+
13+
Resources/
14+
drawable/
15+
icon.png
16+
17+
layout/
18+
main.axml
19+
20+
values/
21+
strings.xml
22+
23+
In order to get the build system to recognize Android resources, set the build action to
24+
"AndroidResource". The native Android APIs do not operate directly with filenames, but
25+
instead operate on resource IDs. When you compile an Android application that uses resources,
26+
the build system will package the resources for distribution and generate a class called "R"
27+
(this is an Android convention) that contains the tokens for each one of the resources
28+
included. For example, for the above Resources layout, this is what the R class would expose:
29+
30+
public class R {
31+
public class drawable {
32+
public const int icon = 0x123;
33+
}
34+
35+
public class layout {
36+
public const int main = 0x456;
37+
}
38+
39+
public class strings {
40+
public const int first_string = 0xabc;
41+
public const int second_string = 0xbcd;
42+
}
43+
}
44+
45+
You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
46+
to reference the layout/main.axml file, or R.strings.first_string to reference the first
47+
string in the dictionary file values/strings.xml.
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">CodebreakerUno</string>
5+
</resources>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<resources>
3+
<style name="AppTheme" parent="Theme.MaterialComponents.Light">
4+
5+
<!-- This removes the ActionBar -->
6+
<item name="windowActionBar">false</item>
7+
<item name="android:windowActionBar">false</item>
8+
<item name="windowNoTitle">true</item>
9+
<item name="android:windowNoTitle">true</item>
10+
11+
<!-- uno_splash_color and uno_splash_image are generated by Uno.Resizetizer -->
12+
<!-- This property is used for the splash screen -->
13+
<item name="android:windowSplashScreenBackground">@color/uno_splash_color</item>
14+
<item name="android:windowBackground">@drawable/uno_splash_image</item>
15+
<item name="android:windowSplashScreenAnimatedIcon">@drawable/uno_splash_image</item>
16+
</style>
17+
<style name="Theme.AppCompat.Translucent">
18+
<item name="android:windowIsTranslucent">true</item>
19+
<item name="android:windowAnimationStyle">@android:style/Animation</item>
20+
</style>
21+
22+
</resources>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# See this for more details: http://developer.xamarin.com/guides/android/advanced_topics/garbage_collection/
2+
MONO_GC_PARAMS=bridge-implementation=tarjan,nursery-size=32m,soft-heap-limit=256m
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFrameworks>$(DotNetVersion)-android;$(DotNetVersion)-ios;$(DotNetVersion)-maccatalyst</TargetFrameworks>
4+
<TargetFrameworks Condition="'$(OverrideTargetFramework)'!=''">$(OverrideTargetFramework)</TargetFrameworks>
5+
<SingleProject>true</SingleProject>
6+
<OutputType>Exe</OutputType>
7+
<!-- Display name -->
8+
<ApplicationTitle>CodebreakerUno</ApplicationTitle>
9+
<!-- App Identifier -->
10+
<ApplicationId>com.cninnovation.CodebreakerUno</ApplicationId>
11+
<ApplicationIdGuid>8B465814-C9D8-4154-8207-D6CF4BA728F5</ApplicationIdGuid>
12+
<!-- Versions -->
13+
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
14+
<ApplicationVersion>1</ApplicationVersion>
15+
16+
<AndroidManifest>Android\AndroidManifest.xml</AndroidManifest>
17+
18+
<!-- Debugger workaround https://github.com/dotnet/maui-samples/blob/8aa6b8780b12e97b157514c3bdc54bb4a13001cd/HelloMacCatalyst/HelloMacCatalyst.csproj#L7 -->
19+
<!-- <MtouchExtraArgs Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">$(MtouchExtraArgs) -setenv:MONO_THREADS_SUSPEND=preemptive</MtouchExtraArgs> -->
20+
<!-- Required for C# Hot Reload -->
21+
<UseInterpreter Condition="'$(Configuration)' == 'Debug' and $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'maccatalyst'">True</UseInterpreter>
22+
<IsUnoHead>true</IsUnoHead>
23+
</PropertyGroup>
24+
25+
<ItemGroup>
26+
<PackageReference Include="Uno.WinUI" />
27+
<PackageReference Include="CommunityToolkit.Mvvm" />
28+
<PackageReference Include="Uno.Extensions.Configuration" />
29+
<PackageReference Include="Uno.Extensions.Http" />
30+
<PackageReference Include="Uno.Extensions.Http.Refit" />
31+
<PackageReference Include="Uno.Extensions.Logging.WinUI" />
32+
<PackageReference Include="Uno.Extensions.Serialization.Http" />
33+
<PackageReference Include="Uno.Extensions.Serialization.Refit" />
34+
<PackageReference Include="Uno.Toolkit.WinUI" />
35+
<PackageReference Include="Uno.Extensions.Hosting.WinUI" />
36+
<PackageReference Include="Uno.Extensions.Localization.WinUI" />
37+
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
38+
<PackageReference Include="Uno.Extensions.Logging.OSLog" />
39+
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" />
40+
<PackageReference Include="Uno.WinUI.DevServer" Condition="'$(Configuration)'=='Debug'" />
41+
</ItemGroup>
42+
<Choose>
43+
<When Condition="$(IsAndroid)">
44+
<ItemGroup>
45+
46+
<PackageReference Include="Xamarin.Google.Android.Material" />
47+
<PackageReference Include="Uno.UniversalImageLoader" />
48+
</ItemGroup>
49+
<ItemGroup>
50+
<AndroidEnvironment Include="Android/environment.conf" />
51+
</ItemGroup>
52+
</When>
53+
<When Condition="$(IsIOS)">
54+
<PropertyGroup>
55+
<MtouchExtraArgs>$(MtouchExtraArgs) --setenv=MONO_GC_PARAMS=soft-heap-limit=512m,nursery-size=64m,evacuation-threshold=66,major=marksweep,concurrent-sweep</MtouchExtraArgs>
56+
<!-- See https://github.com/unoplatform/uno/issues/9430 for more details. -->
57+
<MtouchExtraArgs>$(MtouchExtraArgs) --registrar:static</MtouchExtraArgs>
58+
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)'==''">iossimulator-x64</RuntimeIdentifier>
59+
</PropertyGroup>
60+
<PropertyGroup Condition="'$(Configuration)'=='Release'">
61+
<!-- https://github.com/xamarin/xamarin-macios/issues/14812 -->
62+
<MtouchExtraArgs>$(MtouchExtraArgs) --marshal-objectivec-exceptions:disable</MtouchExtraArgs>
63+
</PropertyGroup>
64+
</When>
65+
<When Condition="$(IsMacCatalyst)">
66+
<PropertyGroup>
67+
<!-- Configure the GC -->
68+
<MtouchExtraArgs>$(MtouchExtraArgs) --setenv=MONO_GC_PARAMS=soft-heap-limit=512m,nursery-size=64m,evacuation-threshold=66,major=marksweep,concurrent-sweep</MtouchExtraArgs>
69+
<!-- Required for unknown crash as of .NET 6 Mobile Preview 13 -->
70+
<MtouchExtraArgs>$(MtouchExtraArgs) --registrar:static</MtouchExtraArgs>
71+
<!-- Full globalization is required for Uno -->
72+
<InvariantGlobalization>false</InvariantGlobalization>
73+
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)'==''">maccatalyst-x64</RuntimeIdentifier>
74+
</PropertyGroup>
75+
<PropertyGroup Condition="'$(Configuration)'=='Release'">
76+
<!-- https://github.com/xamarin/xamarin-macios/issues/14812 -->
77+
<MtouchExtraArgs>$(MtouchExtraArgs) --marshal-objectivec-exceptions:disable</MtouchExtraArgs>
78+
</PropertyGroup>
79+
</When>
80+
</Choose>
81+
<ItemGroup>
82+
<ProjectReference Include="..\CodebreakerUno\CodebreakerUno.csproj" />
83+
</ItemGroup>
84+
<Import Project="..\CodebreakerUno.Shared\base.props" />
85+
86+
<Target Name="ValidateOverrides" BeforeTargets="Restore;_CheckForUnsupportedTargetFramework" Condition="'$(OverrideTargetFramework)' != ''">
87+
<Error Text="OverrideTargetFramework set to '$(OverrideTargetFramework)' is missing valid target. Set OverrideTargetFramework to one of the TargetFrameworks for this project or skip building this project (eg unload the project in Visual Studio)" Condition="$(OverrideTargetFramework.Contains('windows10')) or !$(OverrideTargetFrameork.Contains('-'))" />
88+
</Target>
89+
</Project>

0 commit comments

Comments
 (0)