added a toggle for displaying under the notch

This commit is contained in:
Ell 2023-03-04 12:28:05 +01:00
parent def208809c
commit c9e0ff8ec2
6 changed files with 33 additions and 11 deletions

View file

@ -46,10 +46,6 @@ public class Activity1 : AndroidGameActivity {
this.game.GraphicsDeviceManager.ApplyChanges(); this.game.GraphicsDeviceManager.ApplyChanges();
}; };
// don't render under notches
if (Build.VERSION.SdkInt >= BuildVersionCodes.P)
this.Window.Attributes.LayoutInDisplayCutoutMode = LayoutInDisplayCutoutMode.Never;
this.view = this.game.Services.GetService(typeof(View)) as View; this.view = this.game.Services.GetService(typeof(View)) as View;
this.SetContentView(this.view); this.SetContentView(this.view);

View file

@ -1,5 +1,6 @@
using Android.App; using Android.App;
using Android.Content; using Android.Content;
using Android.OS;
using Android.Views; using Android.Views;
using TouchyTickets; using TouchyTickets;
using Uri = Android.Net.Uri; using Uri = Android.Net.Uri;
@ -22,6 +23,12 @@ public class AndroidPlatform : Platform {
} }
} }
public override void SetRenderUnderNotch(bool value) {
// don't render under notches by default
if (Build.VERSION.SdkInt >= BuildVersionCodes.P)
this.activity.Window.Attributes.LayoutInDisplayCutoutMode = value ? LayoutInDisplayCutoutMode.ShortEdges : LayoutInDisplayCutoutMode.Never;
}
public override void OpenRateLink() { public override void OpenRateLink() {
this.activity.StartActivity(new Intent(Intent.ActionView, Uri.Parse("https://play.google.com/store/apps/details?id=de.ellpeck.touchytickets"))); this.activity.StartActivity(new Intent(Intent.ActionView, Uri.Parse("https://play.google.com/store/apps/details?id=de.ellpeck.touchytickets")));
} }

View file

@ -30,6 +30,7 @@ public class GameImpl : MlemGame {
public GameImpl(Platform platform) { public GameImpl(Platform platform) {
this.Platform = platform; this.Platform = platform;
this.Platform.SetRenderUnderNotch(false);
GameImpl.Instance = this; GameImpl.Instance = this;
} }
@ -106,7 +107,7 @@ public class GameImpl : MlemGame {
#if DEBUG #if DEBUG
return 3; return 3;
#else #else
return (int) BigInteger.Min(3, this.Tickets / this.GetStarPrice()); return (int) BigInteger.Min(3, this.Tickets / this.GetStarPrice());
#endif #endif
} }

View file

@ -24,6 +24,14 @@ public class Options {
[DataMember] [DataMember]
public bool WhileYouWereAwayMessage = true; public bool WhileYouWereAwayMessage = true;
[DataMember] [DataMember]
public bool RenderUnderNotch {
get => this.renderUnderNotch;
set {
this.renderUnderNotch = value;
GameImpl.Instance.Platform.SetRenderUnderNotch(value);
}
}
[DataMember]
public bool KeepScreenOn { public bool KeepScreenOn {
get => this.keepScreenOn; get => this.keepScreenOn;
set { set {
@ -31,12 +39,14 @@ public class Options {
GameImpl.Instance.Platform.SetKeepScreenOn(value); GameImpl.Instance.Platform.SetKeepScreenOn(value);
} }
} }
private bool keepScreenOn;
[DataMember] [DataMember]
public bool AutoBuyEnabled = true; public bool AutoBuyEnabled = true;
[DataMember] [DataMember]
public int MinTicketsForAutoBuy = 50000; public int MinTicketsForAutoBuy = 50000;
private bool renderUnderNotch;
private bool keepScreenOn;
public static void Save() { public static void Save() {
var file = Options.GetOptionsFile(true); var file = Options.GetOptionsFile(true);
using var stream = new JsonTextWriter(file.CreateText()); using var stream = new JsonTextWriter(file.CreateText());

View file

@ -4,7 +4,8 @@ public abstract class Platform {
public abstract void SetKeepScreenOn(bool keep); public abstract void SetKeepScreenOn(bool keep);
public abstract void SetRenderUnderNotch(bool value);
public abstract void OpenRateLink(); public abstract void OpenRateLink();
} }

View file

@ -415,6 +415,13 @@ public class Ui {
Options.Save(); Options.Save();
} }
}); });
optionList.AddChild(new Checkbox(Anchor.AutoLeft, new Vector2(1, 24), Localization.Get("RenderUnderNotch"), Options.Instance.RenderUnderNotch) {
PositionOffset = new Vector2(0, 2),
OnCheckStateChange = (_, value) => {
Options.Instance.RenderUnderNotch = value;
Options.Save();
}
});
optionList.AddChild(new Checkbox(Anchor.AutoLeft, new Vector2(1, 24), Localization.Get("KeepScreenOn"), Options.Instance.KeepScreenOn) { optionList.AddChild(new Checkbox(Anchor.AutoLeft, new Vector2(1, 24), Localization.Get("KeepScreenOn"), Options.Instance.KeepScreenOn) {
PositionOffset = new Vector2(0, 2), PositionOffset = new Vector2(0, 2),
OnCheckStateChange = (_, value) => { OnCheckStateChange = (_, value) => {