mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +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:
22
osu.Game/Utils/PowerStatus.cs
Normal file
22
osu.Game/Utils/PowerStatus.cs
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
namespace osu.Game.Utils
|
||||
{
|
||||
public abstract class PowerStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// The maximum battery level before a warning notification
|
||||
/// is sent.
|
||||
/// </summary>
|
||||
public virtual double BatteryCutoff { get; } = 0.2;
|
||||
public virtual double ChargeLevel { get; set; }
|
||||
public virtual bool IsCharging { get; set; }
|
||||
}
|
||||
|
||||
public class DefaultPowerStatus : PowerStatus
|
||||
{
|
||||
public override double ChargeLevel { get; set; } = 1;
|
||||
public override bool IsCharging { get; set; } = true;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user