Files
Djagor 7b824b6f0c Layout fixes and Push fixes
- Layout und Kalender angepasst
- Push status meldung angepasst für Android
2026-03-27 11:58:53 +01:00

65 lines
2.3 KiB
C#

using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.OS;
using cfs_tracker.Services;
namespace cfs_tracker;
[Activity(
Theme = "@style/Maui.SplashTheme",
MainLauncher = true,
LaunchMode = LaunchMode.SingleTop,
ConfigurationChanges = ConfigChanges.ScreenSize
| ConfigChanges.Orientation
| ConfigChanges.UiMode
| ConfigChanges.ScreenLayout
| ConfigChanges.SmallestScreenSize
| ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity
{
protected override void OnCreate(Bundle? savedInstanceState)
{
base.OnCreate(savedInstanceState);
HandleNotificationIntent(Intent);
}
protected override void OnNewIntent(Intent? intent)
{
base.OnNewIntent(intent);
if (intent is not null)
HandleNotificationIntent(intent);
}
private static void HandleNotificationIntent(Intent? intent)
{
if (intent is null)
return;
if (!string.Equals(intent.Action, Platforms.Android.AndroidNotificationScheduler.ActionOpenQuickEntry, StringComparison.OrdinalIgnoreCase))
return;
var route = intent.GetStringExtra(Platforms.Android.AndroidNotificationScheduler.ExtraRoute);
if (!string.Equals(route, "quickentry", StringComparison.OrdinalIgnoreCase))
return;
var dateText = intent.GetStringExtra(Platforms.Android.AndroidNotificationScheduler.ExtraDate);
if (!DateTime.TryParse(dateText, out var date))
date = DateTime.Today;
var services = IPlatformApplication.Current?.Services;
var navigator = services?.GetService(typeof(NotificationNavigationService)) as NotificationNavigationService;
if (navigator is null)
return;
navigator.QueueQuickEntry(date);
_ = navigator.FlushAsync();
intent.SetAction(string.Empty);
intent.RemoveExtra(Platforms.Android.AndroidNotificationScheduler.ExtraRoute);
intent.RemoveExtra(Platforms.Android.AndroidNotificationScheduler.ExtraDate);
intent.RemoveExtra(Platforms.Android.AndroidNotificationScheduler.ExtraStatus);
intent.RemoveExtra(Platforms.Android.AndroidNotificationScheduler.ExtraCommit);
}
}