// See the note at the top of MainActivity for why the platform namespaces are reached through `global::`. using Avalonia; using Avalonia.Android; using Avalonia.Media; using DodoSSH.Client.Android.Platform; using global::Android.App; using global::Android.Runtime; namespace DodoSSH.Client.Android; /// /// The Android Application object, and where Avalonia is configured. /// /// /// /// Avalonia 12 moved the hooks here from the activity, which is a better fit than /// it first looks: an activity is destroyed and recreated, and the application object is not. The desktop /// head's equivalent is Program.BuildAvaloniaApp. /// /// /// Any Avalonia 11 sample will show this on AvaloniaMainActivity<App> instead. That type is /// still here and is still what the launcher activity derives from — it simply no longer takes the /// application as a type argument. /// /// [Application(Label = "DodoSSH")] public sealed class DodoSshAndroidApplication : AvaloniaAndroidApplication { /// /// The JNI constructor, and the only one Android calls. It exists to hand the managed object its Java /// peer; there is nothing to do in it and nothing may be done in it, because the application context is /// not usable until . /// public DodoSshAndroidApplication(nint javaReference, JniHandleOwnership transfer) : base(javaReference, transfer) { } /// public override void OnCreate() { // Before Avalonia, and from the application rather than the activity: this is the context whose // lifetime matches the composition root's, and reading filesDir is the first thing startup does. PhoneEnvironment.Attach(this); base.OnCreate(); } /// /// /// This used to be the one place the two heads disagreed on purpose: the recorded v2 decision was /// "Android recolours with the shared palette and keeps its own default sans", on the reasoning that a /// phone's system font is a phone's own business. The user has reversed that, this pass — the phone now /// takes the desktop's face as well as its colours, and docs/design-import-gaps.md is corrected /// to say so rather than left asserting a decision that no longer holds. /// /// WithInterFont still registers Inter, for the same reason Program.cs keeps it on the /// desktop: it is what the layout suite pins and what a glyph Montserrat does not cover falls back to. /// What changes is which face answers first. Montserrat ships embedded in /// DodoSSH.Client.Shell/Assets/Fonts already — this project references that assembly for /// Theme/Phone.axaml's own MonoFont, so no csproj or asset work was needed to reach it /// from here, only the same block the desktop's /// Program.BuildAvaloniaApp sets. /// protected override AppBuilder CustomizeAppBuilder(AppBuilder builder) => base.CustomizeAppBuilder(builder) .WithInterFont() .With(new FontManagerOptions { DefaultFamilyName = "avares://DodoSSH.Client.Shell/Assets/Fonts#Montserrat", FontFallbacks = [ new FontFallback { FontFamily = new FontFamily("avares://Avalonia.Fonts.Inter/Assets#Inter") }, ], }); }