mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
Use DI to implement battery detection, add BatteryCutoff property
- Removed the Xamarin.Essentials package from osu.Game and added it to osu.iOS and osu.Android only. - iOS and Android implementations use Xamarin.Essentials.Battery, while the Desktop implementation only returns 100% battery for now. - Added a BatteryCutoff property to PowerStatus so it can be different for each platform (default 20%, 25% on iOS)
This commit is contained in:
@ -7,6 +7,8 @@ using Android.OS;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game;
|
||||
using osu.Game.Updater;
|
||||
using osu.Game.Utils;
|
||||
using Xamarin.Essentials;
|
||||
|
||||
namespace osu.Android
|
||||
{
|
||||
@ -19,6 +21,7 @@ namespace osu.Android
|
||||
: base(null)
|
||||
{
|
||||
gameActivity = activity;
|
||||
powerStatus = new AndroidPowerStatus();
|
||||
}
|
||||
|
||||
public override Version AssemblyVersion
|
||||
@ -72,5 +75,11 @@ namespace osu.Android
|
||||
}
|
||||
|
||||
protected override UpdateManager CreateUpdateManager() => new SimpleUpdateManager();
|
||||
public class AndroidPowerStatus : PowerStatus
|
||||
{
|
||||
public override double ChargeLevel => Battery.ChargeLevel;
|
||||
|
||||
public override bool IsCharging => Battery.PowerSource != BatteryPowerSource.Battery;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user