TouchyTickets/Android/AndroidPlatform.cs

36 lines
1.1 KiB
C#
Raw Permalink Normal View History

using Android.App;
2020-06-30 19:06:35 +02:00
using Android.Content;
using Android.OS;
using Android.Views;
using TouchyTickets;
2020-07-21 20:26:52 +02:00
using Uri = Android.Net.Uri;
namespace Android;
2023-02-11 10:16:42 +01:00
public class AndroidPlatform : Platform {
2023-02-11 10:16:42 +01:00
private readonly Activity activity;
2023-03-04 10:50:45 +01:00
public AndroidPlatform(Activity activity) {
2023-02-11 10:16:42 +01:00
this.activity = activity;
}
public override void SetKeepScreenOn(bool keep) {
if (keep) {
this.activity.Window.AddFlags(WindowManagerFlags.KeepScreenOn);
} else {
this.activity.Window.ClearFlags(WindowManagerFlags.KeepScreenOn);
2020-07-21 21:51:30 +02:00
}
2023-02-11 10:16:42 +01:00
}
2020-07-21 21:51:30 +02:00
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;
}
2023-02-11 10:16:42 +01:00
public override void OpenRateLink() {
this.activity.StartActivity(new Intent(Intent.ActionView, Uri.Parse("https://play.google.com/store/apps/details?id=de.ellpeck.touchytickets")));
}
}