Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,13 @@ dotnet_diagnostic.CA1826.severity = none
dotnet_diagnostic.CA2008.severity = none
dotnet_diagnostic.CA1829.severity = none
dotnet_diagnostic.CA2213.severity = none

[{src/LageBuch.App.Android/*.cs,src/LageBuch.App.Android/**/*.cs}]
# Java-managed objects (Intent, Java.IO.File, ActivityResultLauncher, ActivityResultContracts.*)
# have their lifetime owned by the Android runtime: they must survive past the C# call that hands
# them to the platform (StartActivity / RegisterForActivityResult), so "dispose" here would break
# the OS callbacks. MimeTypeOf likewise deliberately produces lowercase MIME values, which
# Intent.SetDataAndType expects — ToUpperInvariant (CA1308) would violate that contract.
dotnet_diagnostic.CA1308.severity = none
dotnet_diagnostic.CA2000.severity = none
dotnet_diagnostic.CA2213.severity = none
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AnalysisMode>All</AnalysisMode>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<!-- Required so IDE0005 (unused usings) runs during build; suppress the
XML-doc-comment warnings that GenerateDocumentationFile turns on. -->
Expand Down
8 changes: 6 additions & 2 deletions src/LageBuch.App.Android/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ namespace LageBuch.App.Android;
ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.UiMode)]
public class MainActivity : AvaloniaMainActivity<SharedApp>
{
// OpenDocument (rather than GetContent) accepts multiple MIME types on Launch, needed
// since an attachment can be any of several image types or a PDF.
private static readonly string[] AttachmentMimeTypes =
["image/jpeg", "image/png", "image/gif", "image/webp", "application/pdf"];

private ActivityResultLauncher? _importLauncher;
private ActivityResultLauncher? _attachmentLauncher;
private AndroidFileDialogService? _dialogs;
Expand Down Expand Up @@ -51,8 +56,7 @@ protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
{
_dialogs = new AndroidFileDialogService(this);
_dialogs.OnLaunchImportPicker = () => _importLauncher!.Launch("application/json");
_dialogs.OnLaunchAttachmentPicker = () => _attachmentLauncher!.Launch(
new[] { "image/jpeg", "image/png", "image/gif", "image/webp", "application/pdf" });
_dialogs.OnLaunchAttachmentPicker = () => _attachmentLauncher!.Launch(AttachmentMimeTypes);
SharedApp.CreateMainViewModel = () => CompositionRoot.CreateMainWindowViewModel(
new IncidentStore(),
new MasterDataProvider(AndroidAppPaths.MasterDataDbPath(this)),
Expand Down
Loading