| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 | 
							- 
 
- using System;
 
- using System.Diagnostics;
 
- using System.IO;
 
- using System.Threading.Tasks;
 
- using Android;
 
- using Android.App;
 
- using Android.Content.PM;
 
- using Android.OS;
 
- using Android.Runtime;
 
- using InABox.Mobile.Android;
 
- using Xamarin.Forms;
 
- using Plugin.LocalNotification;
 
- using Android.Content;
 
- using Environment = System.Environment;
 
- using Android.Support.V4.App;
 
- using Xamarin.Essentials;
 
- using System.Linq;
 
- using Android.Annotation;
 
- using InABox.Mobile;
 
- namespace comal.timesheets.Droid
 
- {
 
-     
 
-     [Activity(
 
-         Name = "PRS.Mobile.Droid.MainActivity",
 
-         Label = "TimeBench", Icon = "@mipmap/icon",
 
-         Theme = "@style/MainTheme", MainLauncher = true,
 
-         ConfigurationChanges = ConfigChanges.ScreenSize,
 
-         ScreenOrientation = Android.Content.PM.ScreenOrientation.Portrait
 
-         )]
 
-     
 
-     [IntentFilter(new[] { Android.Content.Intent.ActionView },
 
-                        AutoVerify = true,
 
-                        Categories = new[]
 
-                        {
 
-                             Android.Content.Intent.CategoryDefault,
 
-                             Android.Content.Intent.CategoryBrowsable,
 
-                        },
 
-                        DataScheme = "http",
 
-                        DataPathPrefix = "/open",
 
-                        DataHost = "www.prsmobile.com")
 
-         ]
 
-     public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
 
-     {
 
-         private readonly string[] Permissions =
 
-         {
 
-             Manifest.Permission.Bluetooth,
 
-             Manifest.Permission.BluetoothAdmin,
 
-             Manifest.Permission.AccessCoarseLocation,
 
-             Manifest.Permission.AccessFineLocation,
 
-             Manifest.Permission.BluetoothScan,
 
-             Manifest.Permission.BluetoothAdvertise,
 
-             Manifest.Permission.BluetoothConnect,
 
-             Manifest.Permission.ReadMediaVideo,
 
-             Manifest.Permission.ReadMediaAudio,
 
-             Manifest.Permission.ReadMediaImages,
 
-         };
 
-         protected override void OnCreate(Bundle savedInstanceState)
 
-         {
 
-             global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
 
-             MobileLogging.Log("============================================");
 
-             // ===
 
-             
 
-             MobileLogging.Log("Checking Launch via Intent");
 
-             var data = Intent?.Data?.EncodedAuthority;
 
-             if (!string.IsNullOrWhiteSpace(data))
 
-             {
 
-                 try
 
-                 {
 
-                     string s = Intent?.Data?.Path;
 
-                     if (!String.IsNullOrWhiteSpace(s) && (s.Length > 6))
 
-                         App.LaunchParameters = s.Remove(0, 6);
 
-                 }
 
-                 catch { }
 
-             }
 
-             
 
-             
 
-             MobileLogging.Log("Checking Permissions");
 
-             CheckPermissions();
 
-             MobileLogging.Log("Registering Version_Android");
 
-             DependencyService.Register<Version_Android>();
 
-             
 
-             MobileLogging.Log("Checking Resources");
 
-             TabLayoutResource = Resource.Layout.Tabbar;
 
-             ToolbarResource = Resource.Layout.Toolbar;
 
-             MobileLogging.Log("base.OnCreate");
 
-             base.OnCreate(savedInstanceState);
 
-             AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
 
-             TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException;
 
-             MobileLogging.Log("Checking NotificationsChannel");
 
-             LocalNotificationCenter.CreateNotificationChannel(new Plugin.LocalNotification.AndroidOption.NotificationChannelRequest
 
-             {
 
-                 Importance = Plugin.LocalNotification.AndroidOption.AndroidImportance.Max,
 
-                 LockScreenVisibility = Plugin.LocalNotification.AndroidOption.AndroidVisibilityType.Public,
 
-                 ShowBadge = true,
 
-                 EnableVibration = true,
 
-                 Sound = "requiitemadded.mp3"
 
-             });
 
-             MobileLogging.Log("Checking NotificationTapped");
 
-             LocalNotificationCenter.NotifyNotificationTapped(Intent);
 
-             
 
-             // ===
 
-             
 
-             MobileLogging.Log("Checking CrossCurrentActivity");
 
-             Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this, savedInstanceState);
 
-             MobileLogging.Log("Platform.Init");
 
-             Xamarin.Essentials.Platform.Init(this, savedInstanceState);
 
-             MobileLogging.Log("Checking PopupLayoutRenderer");
 
-             Syncfusion.XForms.Android.PopupLayout.SfPopupLayoutRenderer.Init();
 
-             MobileLogging.Log("Checking Maps");
 
-             Xamarin.FormsMaps.Init(this, savedInstanceState);
 
-             MobileLogging.Log("Checking XZing");
 
-             ZXing.Net.Mobile.Forms.Android.Platform.Init();
 
-             MobileLogging.Log("Checking Material");
 
-             XF.Material.Droid.Material.Init(this, savedInstanceState);
 
-             MobileLogging.Log("Loading Application");
 
-             LoadApplication(new App());
 
-             
 
-             MobileLogging.Log("Checking SetSoftInputMode");
 
-             Window.SetSoftInputMode(Android.Views.SoftInput.AdjustResize);
 
-             
 
-             MobileLogging.Log("OnCreate Done");
 
-             
 
-         }
 
-         protected override void OnNewIntent(Intent intent)
 
-         {
 
-             MobileLogging.Log("OnNewIntent");
 
-             LocalNotificationCenter.NotifyNotificationTapped(intent);
 
-             base.OnNewIntent(intent);
 
-         }
 
-         public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Android.Content.PM.Permission[] grantResults)
 
-         {
 
-             MobileLogging.Log("OnRequestPermission");
 
-             global::ZXing.Net.Mobile.Android.PermissionsHandler.OnRequestPermissionsResult(requestCode, permissions, grantResults);
 
-             //at this point in time, xamarin essentials is unable to ask for WRITE_MEDIA_STORAGE from the user, so it never gets granted
 
-             //has to be set manually when asked for, in order for API 33 on Android 13 to work
 
-             //https://github.com/xamarin/Essentials/issues/2041
 
-             if (permissions.Any(x => x == "WRITE_MEDIA_STORAGE"))
 
-             {
 
-                 var grants = new Permission[] { Permission.Granted };
 
-                 Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grants);
 
-             }
 
-             else
 
-             {
 
-                 Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
 
-             }
 
-             base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
 
-         }
 
-         private async void CheckPermissions()
 
-         {
 
-             MobileLogging.Log("CheckPermissions");
 
-             
 
-             bool minimumPermissionsGranted = true;
 
-             foreach (string permission in Permissions)
 
-             {
 
-                 if (CheckSelfPermission(permission) != Permission.Granted)
 
-                 {
 
-                     minimumPermissionsGranted = false;
 
-                 }
 
-             }
 
-             // If any of the minimum permissions aren't granted, we request them from the user
 
-             if (!minimumPermissionsGranted)
 
-             {
 
-                 RequestPermissions(Permissions, 0);
 
-             }
 
-         }
 
-         #region Error handling
 
-         
 
-         private static void TaskSchedulerOnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs args)
 
-         {
 
-             LogUnhandledException("TaskScheduler", args.Exception?.GetType(), args.Exception);
 
-         }
 
-         private static void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs args)
 
-         {
 
-             LogUnhandledException("CurrentDomain", args.ExceptionObject?.GetType(), args.ExceptionObject);
 
-         }
 
-         private static void LogUnhandledException(String source, Type type, object exceptionobject)
 
-         {
 
-             if (exceptionobject is Exception exception)
 
-                 MobileLogging.Log(exception, source);
 
-             else
 
-                 MobileLogging.Log($"{source}: {type?.Name ?? "NULL"} -> {exceptionobject}");
 
-         }
 
-         #endregion
 
-     }
 
- }
 
 
  |