Skip to content

Commit 2875a82

Browse files
committed
✨ Avalonia.WebView2.Sample.Mobile & Impl Source/HtmlSource in iOS/Android
1 parent 3c7757b commit 2875a82

39 files changed

+771
-23
lines changed

Avalonia.WebView2.slnx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
<Solution>
22
<Folder Name="/Avalonia.Ref/">
3-
<Project Path="src/Avalonia.Ref/Avalonia.Desktop/Avalonia.Desktop.csproj">
4-
</Project>
5-
<Project Path="src/Avalonia.Ref/Avalonia.Native/Avalonia.Native.csproj">
6-
</Project>
7-
<Project Path="src/Avalonia.Ref/Avalonia.X11/Avalonia.X11.csproj">
8-
</Project>
3+
<Project Path="src/Avalonia.Ref/Avalonia.Desktop/Avalonia.Desktop.csproj" />
4+
<Project Path="src/Avalonia.Ref/Avalonia.Native/Avalonia.Native.csproj" />
5+
<Project Path="src/Avalonia.Ref/Avalonia.X11/Avalonia.X11.csproj" />
96
</Folder>
107
<Folder Name="/_Root/">
118
<File Path=".github/workflows/CI.yml" />
@@ -18,8 +15,13 @@
1815
<File Path="src/Version.props" />
1916
<File Path="src/WebView2.NativeAssets.Win32/WebView2.NativeAssets.Win32.nuspec" />
2017
</Folder>
21-
<Project Path="src/Avalonia.WebView2.Sample/Avalonia.WebView2.Sample.csproj">
18+
<Project Path="src/Avalonia.WebView2.Sample.Mobile.Android/Avalonia.WebView2.Sample.Mobile.Android.csproj" Id="45116d16-398e-44b9-98c3-a3209895d854">
19+
<Deploy />
2220
</Project>
23-
<Project Path="src/Avalonia.WebView2/Avalonia.WebView2.csproj">
21+
<Project Path="src/Avalonia.WebView2.Sample.Mobile.iOS/Avalonia.WebView2.Sample.Mobile.iOS.csproj" Id="b3219812-d74f-4a6a-9834-29913a191cc7">
22+
<Deploy />
2423
</Project>
24+
<Project Path="src/Avalonia.WebView2.Sample.Mobile/Avalonia.WebView2.Sample.Mobile.csproj" Id="f0af89b3-208b-43ba-b56d-8fc270a1b252" />
25+
<Project Path="src/Avalonia.WebView2.Sample/Avalonia.WebView2.Sample.csproj" />
26+
<Project Path="src/Avalonia.WebView2/Avalonia.WebView2.csproj" />
2527
</Solution>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0-android</TargetFramework>
6+
<ApplicationId>com.github.beyonddimension.avalonia.webview2.sample</ApplicationId>
7+
<ApplicationVersion>1</ApplicationVersion>
8+
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
9+
<AndroidPackageFormat>apk</AndroidPackageFormat>
10+
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
11+
<RootNamespace>Avalonia.WebView2.Sample</RootNamespace>
12+
</PropertyGroup>
13+
14+
<ItemGroup>
15+
<AndroidResource Include="Icon.png">
16+
<Link>Resources\drawable\Icon.png</Link>
17+
</AndroidResource>
18+
</ItemGroup>
19+
20+
<ItemGroup>
21+
<PackageReference Include="Avalonia.Android" />
22+
<PackageReference Include="Xamarin.AndroidX.Core.SplashScreen" />
23+
</ItemGroup>
24+
25+
<ItemGroup>
26+
<ProjectReference Include="..\Avalonia.WebView2.Sample.Mobile\Avalonia.WebView2.Sample.Mobile.csproj" />
27+
</ItemGroup>
28+
</Project>
14 KB
Loading
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Android.App;
2+
using Android.Content.PM;
3+
using Avalonia;
4+
using Avalonia.Android;
5+
using Avalonia.ReactiveUI;
6+
7+
namespace Avalonia.WebView2.Sample;
8+
9+
[Activity(
10+
Label = "Avalonia.WebView2.Sample",
11+
Theme = "@style/MyTheme.NoActionBar",
12+
Icon = "@drawable/icon",
13+
MainLauncher = true,
14+
ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.UiMode)]
15+
public class MainActivity : AvaloniaMainActivity<App>
16+
{
17+
protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
18+
{
19+
return base.CustomizeAppBuilder(builder)
20+
.WithInterFont()
21+
.UseReactiveUI();
22+
}
23+
}
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="Avalonia.WebView2.Sample" android:icon="@drawable/Icon" />
5+
</manifest>
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.
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>
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+
<resources>
3+
<color name="splash_background">#212121</color>
4+
</resources>

0 commit comments

Comments
 (0)