Browse Source

Fix Android obsolete warnings (#20412)

pull/20455/head
Julien Lebosquain 4 weeks ago
committed by GitHub
parent
commit
6faf702e2d
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      samples/ControlCatalog.Android/ControlCatalog.Android.csproj
  2. 2
      src/Android/Avalonia.Android/Avalonia.Android.csproj
  3. 7
      src/Android/Avalonia.Android/AvaloniaAccessHelper.cs
  4. 13
      src/Android/Avalonia.Android/Platform/AndroidInsetsManager.cs

2
samples/ControlCatalog.Android/ControlCatalog.Android.csproj

@ -25,7 +25,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Xamarin.AndroidX.Core.SplashScreen" Version="1.0.1.17" /> <PackageReference Include="Xamarin.AndroidX.Core.SplashScreen" Version="1.2.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

2
src/Android/Avalonia.Android/Avalonia.Android.csproj

@ -11,7 +11,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\packages\Avalonia\Avalonia.csproj" /> <ProjectReference Include="..\..\..\packages\Avalonia\Avalonia.csproj" />
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.7.1.1" /> <PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.7.1.1" />
<PackageReference Include="Xamarin.AndroidX.Window" Version="1.5.0" /> <PackageReference Include="Xamarin.AndroidX.Window" Version="1.5.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\Avalonia.Base\Avalonia.Base.csproj" /> <ProjectReference Include="..\..\Avalonia.Base\Avalonia.Base.csproj" />

7
src/Android/Avalonia.Android/AvaloniaAccessHelper.cs

@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using Android.OS; using Android.OS;
using AndroidX.Core.View.Accessibility; using AndroidX.Core.View.Accessibility;
@ -157,7 +158,7 @@ namespace Avalonia.Android
if (labeledBy is not null) if (labeledBy is not null)
{ {
GetOrCreateNodeInfoProvidersFromPeer(labeledBy, out int labeledById); GetOrCreateNodeInfoProvidersFromPeer(labeledBy, out int labeledById);
nodeInfo.SetLabeledBy(_view, labeledById); nodeInfo.AddLabeledBy(_view, labeledById);
} }
// UI debug metadata // UI debug metadata
@ -181,7 +182,7 @@ namespace Avalonia.Android
_view.TopLevelImpl.PointToScreen(bounds.TopLeft), _view.TopLevelImpl.PointToScreen(bounds.TopLeft),
_view.TopLevelImpl.PointToScreen(bounds.BottomRight) _view.TopLevelImpl.PointToScreen(bounds.BottomRight)
); );
nodeInfo.SetBoundsInParent(new( nodeInfo.SetBoundsInScreen(new(
screenRect.X, screenRect.Y, screenRect.X, screenRect.Y,
screenRect.Right, screenRect.Bottom screenRect.Right, screenRect.Bottom
)); ));

13
src/Android/Avalonia.Android/Platform/AndroidInsetsManager.cs

@ -302,12 +302,17 @@ namespace Avalonia.Android.Platform
_activity.Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); _activity.Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
var androidColor = global::Android.Graphics.Color.Argb(color.A, color.R, color.G, color.B); var androidColor = global::Android.Graphics.Color.Argb(color.A, color.R, color.G, color.B);
_activity.Window.SetStatusBarColor(androidColor);
if (Build.VERSION.SdkInt >= BuildVersionCodes.O) // Status and navigation bar colors can't be changed at all with API level >= 35
if (!OperatingSystem.IsAndroidVersionAtLeast(35))
{ {
// As we can only change the navigation bar's foreground api 26 and newer, we only change the background color if running on those versions _activity.Window.SetStatusBarColor(androidColor);
_activity.Window.SetNavigationBarColor(androidColor);
if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
{
// As we can only change the navigation bar's foreground api 26 and newer, we only change the background color if running on those versions
_activity.Window.SetNavigationBarColor(androidColor);
}
} }
} }
} }

Loading…
Cancel
Save