mirror of
https://github.com/ppy/osu
synced 2024-12-22 06:50:42 +00:00
Fix nullability-related warnings in Android project
This commit is contained in:
parent
e3a89a6273
commit
34e2540331
@ -11,7 +11,7 @@ namespace osu.Android
|
||||
{
|
||||
public partial class GameplayScreenRotationLocker : Component
|
||||
{
|
||||
private Bindable<bool> localUserPlaying;
|
||||
private Bindable<bool> localUserPlaying = null!;
|
||||
|
||||
[Resolved]
|
||||
private OsuGameActivity gameActivity { get; set; } = null!;
|
||||
|
@ -13,6 +13,7 @@ using Android.Graphics;
|
||||
using Android.OS;
|
||||
using Android.Views;
|
||||
using osu.Framework.Android;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Game.Database;
|
||||
using Debug = System.Diagnostics.Debug;
|
||||
using Uri = Android.Net.Uri;
|
||||
@ -49,11 +50,11 @@ namespace osu.Android
|
||||
/// <remarks>Adjusted on startup to match expected UX for the current device type (phone/tablet).</remarks>
|
||||
public ScreenOrientation DefaultOrientation = ScreenOrientation.Unspecified;
|
||||
|
||||
private OsuGameAndroid game;
|
||||
private OsuGameAndroid game = null!;
|
||||
|
||||
protected override Framework.Game CreateGame() => game = new OsuGameAndroid(this);
|
||||
|
||||
protected override void OnCreate(Bundle savedInstanceState)
|
||||
protected override void OnCreate(Bundle? savedInstanceState)
|
||||
{
|
||||
base.OnCreate(savedInstanceState);
|
||||
|
||||
@ -90,15 +91,15 @@ namespace osu.Android
|
||||
Assembly.Load("osu.Game.Rulesets.Mania");
|
||||
}
|
||||
|
||||
protected override void OnNewIntent(Intent intent) => handleIntent(intent);
|
||||
protected override void OnNewIntent(Intent? intent) => handleIntent(intent);
|
||||
|
||||
private void handleIntent(Intent intent)
|
||||
private void handleIntent(Intent? intent)
|
||||
{
|
||||
switch (intent.Action)
|
||||
switch (intent?.Action)
|
||||
{
|
||||
case Intent.ActionDefault:
|
||||
if (intent.Scheme == ContentResolver.SchemeContent)
|
||||
handleImportFromUris(intent.Data);
|
||||
handleImportFromUris(intent.Data.AsNonNull());
|
||||
else if (osu_url_schemes.Contains(intent.Scheme))
|
||||
game.HandleLink(intent.DataString);
|
||||
break;
|
||||
@ -112,7 +113,7 @@ namespace osu.Android
|
||||
{
|
||||
var content = intent.ClipData?.GetItemAt(i);
|
||||
if (content != null)
|
||||
uris.Add(content.Uri);
|
||||
uris.Add(content.Uri.AsNonNull());
|
||||
}
|
||||
|
||||
handleImportFromUris(uris.ToArray());
|
||||
|
@ -6,6 +6,7 @@ using Android.App;
|
||||
using Microsoft.Maui.Devices;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Android.Input;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Input.Handlers;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game;
|
||||
@ -30,7 +31,7 @@ namespace osu.Android
|
||||
{
|
||||
get
|
||||
{
|
||||
var packageInfo = Application.Context.ApplicationContext.PackageManager.GetPackageInfo(Application.Context.ApplicationContext.PackageName, 0);
|
||||
var packageInfo = Application.Context.ApplicationContext!.PackageManager!.GetPackageInfo(Application.Context.ApplicationContext.PackageName!, 0).AsNonNull();
|
||||
|
||||
try
|
||||
{
|
||||
@ -43,7 +44,7 @@ namespace osu.Android
|
||||
// Basic conversion format (as done in Fastfile): 2020.606.0 -> 202006060
|
||||
|
||||
// https://stackoverflow.com/questions/52977079/android-sdk-28-versioncode-in-packageinfo-has-been-deprecated
|
||||
string versionName = string.Empty;
|
||||
string versionName;
|
||||
|
||||
if (OperatingSystem.IsAndroidVersionAtLeast(28))
|
||||
{
|
||||
@ -66,7 +67,7 @@ namespace osu.Android
|
||||
{
|
||||
}
|
||||
|
||||
return new Version(packageInfo.VersionName);
|
||||
return new Version(packageInfo.VersionName.AsNonNull());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Tests.Android
|
||||
{
|
||||
protected override Framework.Game CreateGame() => new OsuTestBrowser();
|
||||
|
||||
protected override void OnCreate(Bundle savedInstanceState)
|
||||
protected override void OnCreate(Bundle? savedInstanceState)
|
||||
{
|
||||
base.OnCreate(savedInstanceState);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user