Skip to content

Commit 73e9290

Browse files
authored
add Android project for Mafia (#145)
* feat: add Android project. * refactor: restructure project to use GeneralUpdate.Samples. * refactor: update application label and restructure project identifiers. * feat: support multiple application lifetimes with MainView initialization. * refactor: remove Semi.Avalonia package reference from Ursa.Desktop project. * chore: add apk file.
1 parent 41f2056 commit 73e9290

71 files changed

Lines changed: 416 additions & 107 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.

UI/SemiUrsaMafia/Client.Avalonia/ViewModels/MainWindowViewModel.cs

Lines changed: 0 additions & 3 deletions
This file was deleted.

UI/SemiUrsaMafia/Directory.Packages.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
</PropertyGroup>
66
<ItemGroup>
77
<PackageVersion Include="Avalonia" Version="$(AvaloniaVersion)"/>
8+
<PackageVersion Include="Avalonia.Android" Version="$(AvaloniaVersion)"/>
89
<PackageVersion Include="Avalonia.Desktop" Version="$(AvaloniaVersion)"/>
910
<PackageVersion Include="AvaloniaUI.DiagnosticsSupport" Version="2.2.3"/>
1011

@@ -16,5 +17,6 @@
1617

1718
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.4.2"/>
1819
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.11"/>
20+
<PackageVersion Include="Xamarin.AndroidX.Core.SplashScreen" Version="1.2.0.2"/>
1921
</ItemGroup>
2022
</Project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Android.Runtime;
2+
using Avalonia;
3+
using Avalonia.Android;
4+
5+
namespace GeneralUpdate.Samples.Mafia.Android;
6+
7+
[Application]
8+
public class Application : AvaloniaAndroidApplication<App>
9+
{
10+
protected Application(nint javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
11+
{
12+
}
13+
14+
protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
15+
{
16+
return base.CustomizeAppBuilder(builder);
17+
}
18+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>net10.0-android</TargetFramework>
5+
<SupportedOSPlatformVersion>23</SupportedOSPlatformVersion>
6+
<Nullable>enable</Nullable>
7+
<ApplicationId>tech.irihi.GeneralUpdate.Samples</ApplicationId>
8+
<ApplicationVersion>1</ApplicationVersion>
9+
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
10+
<AndroidPackageFormat>apk</AndroidPackageFormat>
11+
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
12+
<UseCoreCLR>true</UseCoreCLR>
13+
</PropertyGroup>
14+
15+
<ItemGroup>
16+
<AndroidResource Include="Icon.png">
17+
<Link>Resources\drawable\Icon.png</Link>
18+
</AndroidResource>
19+
</ItemGroup>
20+
21+
<ItemGroup>
22+
<PackageReference Include="Avalonia.Android"/>
23+
<PackageReference Include="Xamarin.AndroidX.Core.SplashScreen"/>
24+
</ItemGroup>
25+
26+
<ItemGroup>
27+
<ProjectReference Include="..\GeneralUpdate.Samples.Mafia\GeneralUpdate.Samples.Mafia.csproj"/>
28+
</ItemGroup>
29+
</Project>
717 Bytes
Loading
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Android.Content.PM;
2+
using Avalonia.Android;
3+
4+
namespace GeneralUpdate.Samples.Mafia.Android;
5+
6+
[Activity(
7+
Label = "GeneralUpdate.Samples.Mafia.Android",
8+
Theme = "@style/MyTheme.NoActionBar",
9+
Icon = "@drawable/icon",
10+
MainLauncher = true,
11+
ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.UiMode)]
12+
public class MainActivity : AvaloniaMainActivity
13+
{
14+
public override void OnBackPressed()
15+
{
16+
base.OnBackPressed();
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" android:installLocation="auto">
3+
<uses-permission android:name="android.permission.INTERNET" />
4+
<application android:label="GeneralUpdate" android:icon="@drawable/Icon" />
5+
</manifest>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<animated-vector
2+
xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:aapt="http://schemas.android.com/aapt">
4+
<aapt:attr name="android:drawable">
5+
<vector
6+
android:name="vector"
7+
android:width="128dp"
8+
android:height="128dp"
9+
android:viewportWidth="128"
10+
android:viewportHeight="128">
11+
<group
12+
android:name="wrapper"
13+
android:translateX="21"
14+
android:translateY="21">
15+
<group android:name="group">
16+
<path
17+
android:name="path"
18+
android:pathData="M 74.853 85.823 L 75.368 85.823 C 80.735 85.823 85.144 81.803 85.761 76.602 L 85.836 41.76 C 85.225 18.593 66.254 0 42.939 0 C 19.24 0 0.028 19.212 0.028 42.912 C 0.028 66.357 18.831 85.418 42.18 85.823 L 74.853 85.823 Z"
19+
android:strokeWidth="1"/>
20+
<path
21+
android:name="path_1"
22+
android:pathData="M 43.059 14.614 C 29.551 14.614 18.256 24.082 15.445 36.743 C 18.136 37.498 20.109 39.968 20.109 42.899 C 20.109 45.831 18.136 48.301 15.445 49.055 C 18.256 61.716 29.551 71.184 43.059 71.184 C 47.975 71.184 52.599 69.93 56.628 67.723 L 56.628 70.993 L 71.344 70.993 L 71.344 44.072 C 71.357 43.714 71.344 43.26 71.344 42.899 C 71.344 27.278 58.68 14.614 43.059 14.614 Z M 29.51 42.899 C 29.51 35.416 35.576 29.35 43.059 29.35 C 50.541 29.35 56.607 35.416 56.607 42.899 C 56.607 50.382 50.541 56.448 43.059 56.448 C 35.576 56.448 29.51 50.382 29.51 42.899 Z"
23+
android:strokeWidth="1"
24+
android:fillType="evenOdd"/>
25+
<path
26+
android:name="path_2"
27+
android:pathData="M 18.105 42.88 C 18.105 45.38 16.078 47.407 13.579 47.407 C 11.079 47.407 9.052 45.38 9.052 42.88 C 9.052 40.381 11.079 38.354 13.579 38.354 C 16.078 38.354 18.105 40.381 18.105 42.88 Z"
28+
android:strokeWidth="1"/>
29+
</group>
30+
</group>
31+
</vector>
32+
</aapt:attr>
33+
<target android:name="path">
34+
<aapt:attr name="android:animation">
35+
<objectAnimator
36+
android:propertyName="fillColor"
37+
android:duration="1000"
38+
android:valueFrom="#00ffffff"
39+
android:valueTo="#161c2d"
40+
android:valueType="colorType"
41+
android:interpolator="@android:interpolator/fast_out_slow_in"/>
42+
</aapt:attr>
43+
</target>
44+
<target android:name="path_1">
45+
<aapt:attr name="android:animation">
46+
<objectAnimator
47+
android:propertyName="fillColor"
48+
android:duration="1000"
49+
android:valueFrom="#00ffffff"
50+
android:valueTo="#f9f9fb"
51+
android:valueType="colorType"
52+
android:interpolator="@android:interpolator/fast_out_slow_in"/>
53+
</aapt:attr>
54+
</target>
55+
<target android:name="path_2">
56+
<aapt:attr name="android:animation">
57+
<objectAnimator
58+
android:propertyName="fillColor"
59+
android:duration="1000"
60+
android:valueFrom="#00ffffff"
61+
android:valueTo="#f9f9fb"
62+
android:valueType="colorType"
63+
android:interpolator="@android:interpolator/fast_out_slow_in"/>
64+
</aapt:attr>
65+
</target>
66+
</animated-vector>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<animated-vector
2+
xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:aapt="http://schemas.android.com/aapt">
4+
<aapt:attr name="android:drawable">
5+
<vector
6+
android:name="vector"
7+
android:width="128dp"
8+
android:height="128dp"
9+
android:viewportWidth="128"
10+
android:viewportHeight="128">
11+
<group
12+
android:name="wrapper"
13+
android:translateX="21"
14+
android:translateY="21">
15+
<group android:name="group">
16+
<path
17+
android:name="path"
18+
android:pathData="M 74.853 85.823 L 75.368 85.823 C 80.735 85.823 85.144 81.803 85.761 76.602 L 85.836 41.76 C 85.225 18.593 66.254 0 42.939 0 C 19.24 0 0.028 19.212 0.028 42.912 C 0.028 66.357 18.831 85.418 42.18 85.823 L 74.853 85.823 Z"
19+
android:fillColor="#00ffffff"
20+
android:strokeWidth="1"/>
21+
<path
22+
android:name="path_1"
23+
android:pathData="M 43.059 14.614 C 29.551 14.614 18.256 24.082 15.445 36.743 C 18.136 37.498 20.109 39.968 20.109 42.899 C 20.109 45.831 18.136 48.301 15.445 49.055 C 18.256 61.716 29.551 71.184 43.059 71.184 C 47.975 71.184 52.599 69.93 56.628 67.723 L 56.628 70.993 L 71.344 70.993 L 71.344 44.072 C 71.357 43.714 71.344 43.26 71.344 42.899 C 71.344 27.278 58.68 14.614 43.059 14.614 Z M 29.51 42.899 C 29.51 35.416 35.576 29.35 43.059 29.35 C 50.541 29.35 56.607 35.416 56.607 42.899 C 56.607 50.382 50.541 56.448 43.059 56.448 C 35.576 56.448 29.51 50.382 29.51 42.899 Z"
24+
android:fillColor="#00ffffff"
25+
android:strokeWidth="1"
26+
android:fillType="evenOdd"/>
27+
<path
28+
android:name="path_2"
29+
android:pathData="M 18.105 42.88 C 18.105 45.38 16.078 47.407 13.579 47.407 C 11.079 47.407 9.052 45.38 9.052 42.88 C 9.052 40.381 11.079 38.354 13.579 38.354 C 16.078 38.354 18.105 40.381 18.105 42.88 Z"
30+
android:fillColor="#00ffffff"
31+
android:strokeWidth="1"/>
32+
</group>
33+
</group>
34+
</vector>
35+
</aapt:attr>
36+
<target android:name="path_2">
37+
<aapt:attr name="android:animation">
38+
<objectAnimator
39+
android:propertyName="fillColor"
40+
android:startOffset="100"
41+
android:duration="900"
42+
android:valueFrom="#00ffffff"
43+
android:valueTo="#161c2d"
44+
android:valueType="colorType"
45+
android:interpolator="@android:interpolator/fast_out_slow_in"/>
46+
</aapt:attr>
47+
</target>
48+
<target android:name="path">
49+
<aapt:attr name="android:animation">
50+
<objectAnimator
51+
android:propertyName="fillColor"
52+
android:duration="500"
53+
android:valueFrom="#00ffffff"
54+
android:valueTo="#f9f9fb"
55+
android:valueType="colorType"
56+
android:interpolator="@android:interpolator/fast_out_slow_in"/>
57+
</aapt:attr>
58+
</target>
59+
<target android:name="path_1">
60+
<aapt:attr name="android:animation">
61+
<objectAnimator
62+
android:propertyName="fillColor"
63+
android:startOffset="100"
64+
android:duration="900"
65+
android:valueFrom="#00ffffff"
66+
android:valueTo="#161c2d"
67+
android:valueType="colorType"
68+
android:interpolator="@android:interpolator/fast_out_slow_in"/>
69+
</aapt:attr>
70+
</target>
71+
</animated-vector>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<item>
5+
<color android:color="@color/splash_background"/>
6+
</item>
7+
8+
<item android:drawable="@drawable/icon"
9+
android:width="120dp"
10+
android:height="120dp"
11+
android:gravity="center" />
12+
13+
</layer-list>

0 commit comments

Comments
 (0)