diff --git a/Avalonia.sln b/Avalonia.sln index 35b6b2108a..68335c672c 100644 --- a/Avalonia.sln +++ b/Avalonia.sln @@ -214,6 +214,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.DesignerSupport.Te EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DevGenerators", "src\tools\DevGenerators\DevGenerators.csproj", "{1BBFAD42-B99E-47E0-B00A-A4BC6B6BB4BB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MobileSandbox", "samples\MobileSandbox\MobileSandbox.csproj", "{3B8519C1-2F51-4F12-A348-120AB91D4532}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MobileSandbox.Android", "samples\MobileSandbox.Android\MobileSandbox.Android.csproj", "{C90FE60B-B01E-4F35-91D6-379D6966030F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MobileSandbox.iOS", "samples\MobileSandbox.iOS\MobileSandbox.iOS.csproj", "{FED9A71D-00D7-4F40-A9E4-1229EEA28EEB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MobileSandbox.Desktop", "samples\MobileSandbox.Desktop\MobileSandbox.Desktop.csproj", "{62D392C9-81CF-487F-92E8-598B2AF3FDCE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -502,6 +510,22 @@ Global {1BBFAD42-B99E-47E0-B00A-A4BC6B6BB4BB}.Debug|Any CPU.Build.0 = Debug|Any CPU {1BBFAD42-B99E-47E0-B00A-A4BC6B6BB4BB}.Release|Any CPU.ActiveCfg = Release|Any CPU {1BBFAD42-B99E-47E0-B00A-A4BC6B6BB4BB}.Release|Any CPU.Build.0 = Release|Any CPU + {3B8519C1-2F51-4F12-A348-120AB91D4532}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3B8519C1-2F51-4F12-A348-120AB91D4532}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3B8519C1-2F51-4F12-A348-120AB91D4532}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3B8519C1-2F51-4F12-A348-120AB91D4532}.Release|Any CPU.Build.0 = Release|Any CPU + {C90FE60B-B01E-4F35-91D6-379D6966030F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C90FE60B-B01E-4F35-91D6-379D6966030F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C90FE60B-B01E-4F35-91D6-379D6966030F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C90FE60B-B01E-4F35-91D6-379D6966030F}.Release|Any CPU.Build.0 = Release|Any CPU + {FED9A71D-00D7-4F40-A9E4-1229EEA28EEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FED9A71D-00D7-4F40-A9E4-1229EEA28EEB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FED9A71D-00D7-4F40-A9E4-1229EEA28EEB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FED9A71D-00D7-4F40-A9E4-1229EEA28EEB}.Release|Any CPU.Build.0 = Release|Any CPU + {62D392C9-81CF-487F-92E8-598B2AF3FDCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {62D392C9-81CF-487F-92E8-598B2AF3FDCE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {62D392C9-81CF-487F-92E8-598B2AF3FDCE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {62D392C9-81CF-487F-92E8-598B2AF3FDCE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -560,6 +584,10 @@ Global {EABE2161-989B-42BF-BD8D-1E34B20C21F1} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B} {1BBFAD42-B99E-47E0-B00A-A4BC6B6BB4BB} = {4ED8B739-6F4E-4CD4-B993-545E6B5CE637} {4D36CEC8-53F2-40A5-9A37-79AAE356E2DA} = {86C53C40-57AA-45B8-AD42-FAE0EFDF0F2B} + {3B8519C1-2F51-4F12-A348-120AB91D4532} = {9B9E3891-2366-4253-A952-D08BCEB71098} + {C90FE60B-B01E-4F35-91D6-379D6966030F} = {9B9E3891-2366-4253-A952-D08BCEB71098} + {FED9A71D-00D7-4F40-A9E4-1229EEA28EEB} = {9B9E3891-2366-4253-A952-D08BCEB71098} + {62D392C9-81CF-487F-92E8-598B2AF3FDCE} = {9B9E3891-2366-4253-A952-D08BCEB71098} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {87366D66-1391-4D90-8999-95A620AD786A} diff --git a/samples/MobileSandbox.Android/MainActivity.cs b/samples/MobileSandbox.Android/MainActivity.cs new file mode 100644 index 0000000000..ac9242dd52 --- /dev/null +++ b/samples/MobileSandbox.Android/MainActivity.cs @@ -0,0 +1,12 @@ +using Android.App; +using Android.Content.PM; +using Avalonia; +using Avalonia.Android; + +namespace MobileSandbox.Android +{ + [Activity(Label = "MobileSandbox.Android", Theme = "@style/MyTheme.NoActionBar", Icon = "@drawable/icon", LaunchMode = LaunchMode.SingleInstance, ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize)] + public class MainActivity : AvaloniaActivity + { + } +} diff --git a/samples/MobileSandbox.Android/MobileSandbox.Android.csproj b/samples/MobileSandbox.Android/MobileSandbox.Android.csproj new file mode 100644 index 0000000000..94f0d31e4d --- /dev/null +++ b/samples/MobileSandbox.Android/MobileSandbox.Android.csproj @@ -0,0 +1,44 @@ + + + net6.0-android + 21 + Exe + enable + com.Avalonia.MobileSandbox + 1 + 1.0 + apk + true + + + + Resources\drawable\Icon.png + + + + + True + + + + + + True + True + + + + + + + + + + + + diff --git a/samples/MobileSandbox.Android/Properties/AndroidManifest.xml b/samples/MobileSandbox.Android/Properties/AndroidManifest.xml new file mode 100644 index 0000000000..6f551d2b01 --- /dev/null +++ b/samples/MobileSandbox.Android/Properties/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/samples/MobileSandbox.Android/Resources/AboutResources.txt b/samples/MobileSandbox.Android/Resources/AboutResources.txt new file mode 100644 index 0000000000..c2bca974c4 --- /dev/null +++ b/samples/MobileSandbox.Android/Resources/AboutResources.txt @@ -0,0 +1,44 @@ +Images, layout descriptions, binary blobs and string dictionaries can be included +in your application as resource files. Various Android APIs are designed to +operate on the resource IDs instead of dealing with images, strings or binary blobs +directly. + +For example, a sample Android app that contains a user interface layout (main.axml), +an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) +would keep its resources in the "Resources" directory of the application: + +Resources/ + drawable/ + icon.png + + layout/ + main.axml + + values/ + strings.xml + +In order to get the build system to recognize Android resources, set the build action to +"AndroidResource". The native Android APIs do not operate directly with filenames, but +instead operate on resource IDs. When you compile an Android application that uses resources, +the build system will package the resources for distribution and generate a class called "R" +(this is an Android convention) that contains the tokens for each one of the resources +included. For example, for the above Resources layout, this is what the R class would expose: + +public class R { + public class drawable { + public const int icon = 0x123; + } + + public class layout { + public const int main = 0x456; + } + + public class strings { + public const int first_string = 0xabc; + public const int second_string = 0xbcd; + } +} + +You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main +to reference the layout/main.axml file, or R.strings.first_string to reference the first +string in the dictionary file values/strings.xml. \ No newline at end of file diff --git a/samples/MobileSandbox.Android/Resources/drawable/splash_screen.xml b/samples/MobileSandbox.Android/Resources/drawable/splash_screen.xml new file mode 100644 index 0000000000..2e920b4b3b --- /dev/null +++ b/samples/MobileSandbox.Android/Resources/drawable/splash_screen.xml @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/samples/MobileSandbox.Android/Resources/values/colors.xml b/samples/MobileSandbox.Android/Resources/values/colors.xml new file mode 100644 index 0000000000..59279d5d32 --- /dev/null +++ b/samples/MobileSandbox.Android/Resources/values/colors.xml @@ -0,0 +1,4 @@ + + + #FFFFFF + diff --git a/samples/MobileSandbox.Android/Resources/values/styles.xml b/samples/MobileSandbox.Android/Resources/values/styles.xml new file mode 100644 index 0000000000..2759d2904a --- /dev/null +++ b/samples/MobileSandbox.Android/Resources/values/styles.xml @@ -0,0 +1,17 @@ + + + + + + + + + + diff --git a/samples/MobileSandbox.Android/SplashActivity.cs b/samples/MobileSandbox.Android/SplashActivity.cs new file mode 100644 index 0000000000..c26371d6fe --- /dev/null +++ b/samples/MobileSandbox.Android/SplashActivity.cs @@ -0,0 +1,17 @@ +using Android.App; +using Android.Content; +using Android.OS; + +namespace MobileSandbox.Android +{ + [Activity(Theme = "@style/MyTheme.Splash", MainLauncher = true, NoHistory = true)] + public class SplashActivity : Activity + { + protected override void OnResume() + { + base.OnResume(); + + StartActivity(new Intent(Application.Context, typeof(MainActivity))); + } + } +} diff --git a/samples/MobileSandbox.Android/environment.device.txt b/samples/MobileSandbox.Android/environment.device.txt new file mode 100644 index 0000000000..107d68ca1b --- /dev/null +++ b/samples/MobileSandbox.Android/environment.device.txt @@ -0,0 +1 @@ +DOTNET_DiagnosticPorts=127.0.0.1:9000,suspend diff --git a/samples/MobileSandbox.Android/environment.emulator.txt b/samples/MobileSandbox.Android/environment.emulator.txt new file mode 100644 index 0000000000..299a0ec30b --- /dev/null +++ b/samples/MobileSandbox.Android/environment.emulator.txt @@ -0,0 +1 @@ +DOTNET_DiagnosticPorts=10.0.2.2:9001,suspend diff --git a/samples/MobileSandbox.Desktop/MobileSandbox.Desktop.csproj b/samples/MobileSandbox.Desktop/MobileSandbox.Desktop.csproj new file mode 100644 index 0000000000..1b83a3e567 --- /dev/null +++ b/samples/MobileSandbox.Desktop/MobileSandbox.Desktop.csproj @@ -0,0 +1,47 @@ + + + + WinExe + net6.0 + true + true + + + + true + https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json + 7.0.0-* + + + + + + + + + + + + + + + + + + + + + + + + + + + + en + app.manifest + + + + + diff --git a/samples/MobileSandbox.Desktop/Program.cs b/samples/MobileSandbox.Desktop/Program.cs new file mode 100644 index 0000000000..4d49a65994 --- /dev/null +++ b/samples/MobileSandbox.Desktop/Program.cs @@ -0,0 +1,21 @@ +using System; +using Avalonia; + +namespace MobileSandbox.Desktop +{ + static class Program + { + [STAThread] + static int Main(string[] args) => + BuildAvaloniaApp() + .StartWithClassicDesktopLifetime(args); + + /// + /// This method is needed for IDE previewer infrastructure + /// + public static AppBuilder BuildAvaloniaApp() + => AppBuilder.Configure() + .UsePlatformDetect() + .LogToTrace(); + } +} diff --git a/samples/MobileSandbox.Desktop/app.manifest b/samples/MobileSandbox.Desktop/app.manifest new file mode 100644 index 0000000000..db90057191 --- /dev/null +++ b/samples/MobileSandbox.Desktop/app.manifest @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/MobileSandbox.iOS/AppDelegate.cs b/samples/MobileSandbox.iOS/AppDelegate.cs new file mode 100644 index 0000000000..da472be877 --- /dev/null +++ b/samples/MobileSandbox.iOS/AppDelegate.cs @@ -0,0 +1,17 @@ +using Foundation; +using UIKit; +using Avalonia; +using Avalonia.Controls; +using Avalonia.iOS; +using Avalonia.Media; + +namespace MobileSandbox +{ + // The UIApplicationDelegate for the application. This class is responsible for launching the + // User Interface of the application, as well as listening (and optionally responding) to + // application events from iOS. + [Register("AppDelegate")] + public partial class AppDelegate : AvaloniaAppDelegate + { + } +} diff --git a/samples/MobileSandbox.iOS/Entitlements.plist b/samples/MobileSandbox.iOS/Entitlements.plist new file mode 100644 index 0000000000..0c67376eba --- /dev/null +++ b/samples/MobileSandbox.iOS/Entitlements.plist @@ -0,0 +1,5 @@ + + + + + diff --git a/samples/MobileSandbox.iOS/Info.plist b/samples/MobileSandbox.iOS/Info.plist new file mode 100644 index 0000000000..6ffe3ba662 --- /dev/null +++ b/samples/MobileSandbox.iOS/Info.plist @@ -0,0 +1,47 @@ + + + + + CFBundleDisplayName + ControlCatalog.iOS + CFBundleIdentifier + Avalonia.ControlCatalog + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + MinimumOSVersion + 10.0 + UIDeviceFamily + + 1 + 2 + + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIStatusBarHidden + + UIViewControllerBasedStatusBarAppearance + + + diff --git a/samples/MobileSandbox.iOS/Main.cs b/samples/MobileSandbox.iOS/Main.cs new file mode 100644 index 0000000000..fdd78bbb11 --- /dev/null +++ b/samples/MobileSandbox.iOS/Main.cs @@ -0,0 +1,15 @@ +using UIKit; + +namespace MobileSandbox.iOS +{ + public class Application + { + // This is the main entry point of the application. + static void Main(string[] args) + { + // if you want to use a different Application Delegate class from "AppDelegate" + // you can specify it here. + UIApplication.Main(args, null, typeof(AppDelegate)); + } + } +} diff --git a/samples/MobileSandbox.iOS/MobileSandbox.iOS.csproj b/samples/MobileSandbox.iOS/MobileSandbox.iOS.csproj new file mode 100644 index 0000000000..6d24fea1cf --- /dev/null +++ b/samples/MobileSandbox.iOS/MobileSandbox.iOS.csproj @@ -0,0 +1,16 @@ + + + Exe + manual + net6.0-ios + 10.0 + + True + iossimulator-x64 + + + + + + + diff --git a/samples/MobileSandbox.iOS/Resources/LaunchScreen.xib b/samples/MobileSandbox.iOS/Resources/LaunchScreen.xib new file mode 100644 index 0000000000..5d3ccc97db --- /dev/null +++ b/samples/MobileSandbox.iOS/Resources/LaunchScreen.xib @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/MobileSandbox/App.xaml b/samples/MobileSandbox/App.xaml new file mode 100644 index 0000000000..f3210e8941 --- /dev/null +++ b/samples/MobileSandbox/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/samples/MobileSandbox/App.xaml.cs b/samples/MobileSandbox/App.xaml.cs new file mode 100644 index 0000000000..d32d9bb5a7 --- /dev/null +++ b/samples/MobileSandbox/App.xaml.cs @@ -0,0 +1,28 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Markup.Xaml; + +namespace MobileSandbox +{ + public class App : Application + { + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } + + public override void OnFrameworkInitializationCompleted() + { + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktopLifetime) + { + desktopLifetime.MainWindow = new MainWindow(); + } + else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewLifetime) + { + singleViewLifetime.MainView = new MainView(); + } + + base.OnFrameworkInitializationCompleted(); + } + } +} diff --git a/samples/MobileSandbox/Assets/Fonts/SourceSansPro-Bold.ttf b/samples/MobileSandbox/Assets/Fonts/SourceSansPro-Bold.ttf new file mode 100644 index 0000000000..f6986468bd Binary files /dev/null and b/samples/MobileSandbox/Assets/Fonts/SourceSansPro-Bold.ttf differ diff --git a/samples/MobileSandbox/Assets/Fonts/SourceSansPro-BoldItalic.ttf b/samples/MobileSandbox/Assets/Fonts/SourceSansPro-BoldItalic.ttf new file mode 100644 index 0000000000..5c00b64faf Binary files /dev/null and b/samples/MobileSandbox/Assets/Fonts/SourceSansPro-BoldItalic.ttf differ diff --git a/samples/MobileSandbox/Assets/Fonts/SourceSansPro-Italic.ttf b/samples/MobileSandbox/Assets/Fonts/SourceSansPro-Italic.ttf new file mode 100644 index 0000000000..82e8762011 Binary files /dev/null and b/samples/MobileSandbox/Assets/Fonts/SourceSansPro-Italic.ttf differ diff --git a/samples/MobileSandbox/Assets/Fonts/SourceSansPro-Regular.ttf b/samples/MobileSandbox/Assets/Fonts/SourceSansPro-Regular.ttf new file mode 100644 index 0000000000..278ad8aa0a Binary files /dev/null and b/samples/MobileSandbox/Assets/Fonts/SourceSansPro-Regular.ttf differ diff --git a/samples/MobileSandbox/Assets/Fonts/WenQuanYiMicroHei-01.ttf b/samples/MobileSandbox/Assets/Fonts/WenQuanYiMicroHei-01.ttf new file mode 100644 index 0000000000..61e2583a6c Binary files /dev/null and b/samples/MobileSandbox/Assets/Fonts/WenQuanYiMicroHei-01.ttf differ diff --git a/samples/MobileSandbox/Assets/avalonia-32.png b/samples/MobileSandbox/Assets/avalonia-32.png new file mode 100644 index 0000000000..7b443e7a25 Binary files /dev/null and b/samples/MobileSandbox/Assets/avalonia-32.png differ diff --git a/samples/MobileSandbox/Assets/delicate-arch-896885_640.jpg b/samples/MobileSandbox/Assets/delicate-arch-896885_640.jpg new file mode 100644 index 0000000000..90894abe97 Binary files /dev/null and b/samples/MobileSandbox/Assets/delicate-arch-896885_640.jpg differ diff --git a/samples/MobileSandbox/Assets/github_icon.png b/samples/MobileSandbox/Assets/github_icon.png new file mode 100644 index 0000000000..ed4f82f847 Binary files /dev/null and b/samples/MobileSandbox/Assets/github_icon.png differ diff --git a/samples/MobileSandbox/Assets/hirsch-899118_640.jpg b/samples/MobileSandbox/Assets/hirsch-899118_640.jpg new file mode 100644 index 0000000000..af0eff6b47 Binary files /dev/null and b/samples/MobileSandbox/Assets/hirsch-899118_640.jpg differ diff --git a/samples/MobileSandbox/Assets/maple-leaf-888807_640.jpg b/samples/MobileSandbox/Assets/maple-leaf-888807_640.jpg new file mode 100644 index 0000000000..72bf0a61ae Binary files /dev/null and b/samples/MobileSandbox/Assets/maple-leaf-888807_640.jpg differ diff --git a/samples/MobileSandbox/Assets/test_icon.ico b/samples/MobileSandbox/Assets/test_icon.ico new file mode 100644 index 0000000000..da8d49ff9b Binary files /dev/null and b/samples/MobileSandbox/Assets/test_icon.ico differ diff --git a/samples/MobileSandbox/MainView.xaml b/samples/MobileSandbox/MainView.xaml new file mode 100644 index 0000000000..c7bd0fe61f --- /dev/null +++ b/samples/MobileSandbox/MainView.xaml @@ -0,0 +1,11 @@ + + + + + + +