mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Fetch OsuGameActivity through DI instead.
This commit is contained in:
parent
9cd595800a
commit
371aecfca0
@ -13,6 +13,9 @@ namespace osu.Android
|
||||
{
|
||||
private Bindable<bool> localUserPlaying;
|
||||
|
||||
[Resolved]
|
||||
private OsuGameActivity gameActivity { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuGame game)
|
||||
{
|
||||
@ -22,9 +25,9 @@ namespace osu.Android
|
||||
|
||||
private void updateLock(ValueChangedEvent<bool> userPlaying)
|
||||
{
|
||||
OsuGameActivity.Activity.RunOnUiThread(() =>
|
||||
gameActivity.RunOnUiThread(() =>
|
||||
{
|
||||
OsuGameActivity.Activity.RequestedOrientation = userPlaying.NewValue ? ScreenOrientation.Locked : ScreenOrientation.FullUser;
|
||||
gameActivity.RequestedOrientation = userPlaying.NewValue ? ScreenOrientation.Locked : ScreenOrientation.FullUser;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -12,14 +12,10 @@ namespace osu.Android
|
||||
[Activity(Theme = "@android:style/Theme.NoTitleBar", MainLauncher = true, ScreenOrientation = ScreenOrientation.FullUser, SupportsPictureInPicture = false, ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize, HardwareAccelerated = false)]
|
||||
public class OsuGameActivity : AndroidGameActivity
|
||||
{
|
||||
internal static Activity Activity { get; private set; }
|
||||
|
||||
protected override Framework.Game CreateGame() => new OsuGameAndroid();
|
||||
protected override Framework.Game CreateGame() => new OsuGameAndroid(this);
|
||||
|
||||
protected override void OnCreate(Bundle savedInstanceState)
|
||||
{
|
||||
Activity = this;
|
||||
|
||||
// The default current directory on android is '/'.
|
||||
// On some devices '/' maps to the app data directory. On others it maps to the root of the internal storage.
|
||||
// In order to have a consistent current directory on all devices the full path of the app data directory is set as the current directory.
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using Android.App;
|
||||
using Android.OS;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game;
|
||||
using osu.Game.Updater;
|
||||
|
||||
@ -11,6 +12,15 @@ namespace osu.Android
|
||||
{
|
||||
public class OsuGameAndroid : OsuGame
|
||||
{
|
||||
[Cached]
|
||||
private readonly OsuGameActivity gameActivity;
|
||||
|
||||
public OsuGameAndroid(OsuGameActivity activity)
|
||||
: base(null)
|
||||
{
|
||||
gameActivity = activity;
|
||||
}
|
||||
|
||||
public override Version AssemblyVersion
|
||||
{
|
||||
get
|
||||
|
Loading…
Reference in New Issue
Block a user