2022-09-20 13:51:55 +02:00
|
|
|
|
|
2022-11-17 10:05:05 +01:00
|
|
|
|
using System.Collections.Generic;
|
2021-11-07 19:42:59 +01:00
|
|
|
|
using Android.App;
|
2022-08-30 15:42:25 +02:00
|
|
|
|
using Android.Content;
|
2021-11-07 19:42:59 +01:00
|
|
|
|
using Android.Content.PM;
|
2022-08-30 15:42:25 +02:00
|
|
|
|
using Android.Content.Res;
|
2021-11-07 19:42:59 +01:00
|
|
|
|
using Android.OS;
|
2022-11-17 10:05:05 +01:00
|
|
|
|
using Android.Runtime;
|
2022-08-30 15:42:25 +02:00
|
|
|
|
using Android.Util;
|
|
|
|
|
using Firebase;
|
2021-11-07 19:42:59 +01:00
|
|
|
|
using Java.Interop;
|
2021-12-08 17:57:30 +01:00
|
|
|
|
using Plugin.Permissions;
|
2022-04-10 17:38:34 +02:00
|
|
|
|
using TINK.Model;
|
2022-11-17 10:05:05 +01:00
|
|
|
|
using Xamarin.Essentials;
|
2022-08-30 15:42:25 +02:00
|
|
|
|
using Xamarin.Forms.Platform.Android.AppLinks;
|
2022-11-17 10:05:05 +01:00
|
|
|
|
using static Xamarin.Essentials.Permissions;
|
2021-11-07 19:42:59 +01:00
|
|
|
|
|
|
|
|
|
namespace TINK.Droid
|
|
|
|
|
{
|
2022-11-17 10:05:05 +01:00
|
|
|
|
[Activity(
|
|
|
|
|
Label = "LastenradBayern",
|
|
|
|
|
Icon = "@drawable/sharee",
|
|
|
|
|
Theme = "@style/MainTheme",
|
|
|
|
|
MainLauncher = true,
|
|
|
|
|
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
|
2022-09-06 16:08:19 +02:00
|
|
|
|
|
|
|
|
|
[IntentFilter(new[] { Intent.ActionView },
|
|
|
|
|
Categories = new[] { Intent.ActionView, Intent.CategoryBrowsable, Intent.CategoryDefault },
|
|
|
|
|
DataScheme = "https",
|
2022-09-20 13:51:55 +02:00
|
|
|
|
DataHost = "app.sharee.bike",
|
|
|
|
|
DataPathPrefix = "/App-LastenradBayern",
|
2022-09-06 16:08:19 +02:00
|
|
|
|
AutoVerify = true)]
|
|
|
|
|
|
|
|
|
|
[IntentFilter(new[] { Intent.ActionView },
|
|
|
|
|
Categories = new[] { Intent.ActionView, Intent.CategoryBrowsable, Intent.CategoryDefault },
|
|
|
|
|
DataScheme = "http",
|
2022-09-20 13:51:55 +02:00
|
|
|
|
DataHost = "app.sharee.bike",
|
|
|
|
|
DataPathPrefix = "/App-LastenradBayern",
|
2022-09-06 16:08:19 +02:00
|
|
|
|
AutoVerify = true)]
|
|
|
|
|
|
|
|
|
|
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
|
|
|
|
|
{
|
|
|
|
|
private void initFontScale()
|
|
|
|
|
{
|
|
|
|
|
Configuration configuration = Resources.Configuration;
|
|
|
|
|
configuration.FontScale = (float)1;
|
|
|
|
|
//0.85 small, 1 standard, 1.15 big,1.3 more bigger ,1.45 supper big
|
|
|
|
|
DisplayMetrics metrics = new DisplayMetrics();
|
|
|
|
|
WindowManager.DefaultDisplay.GetMetrics(metrics);
|
|
|
|
|
metrics.ScaledDensity = configuration.FontScale * metrics.Density;
|
|
|
|
|
BaseContext.Resources.UpdateConfiguration(configuration, metrics);
|
|
|
|
|
}
|
2022-11-17 10:05:05 +01:00
|
|
|
|
protected override async void OnCreate(Bundle bundle)
|
2022-09-06 16:08:19 +02:00
|
|
|
|
{
|
|
|
|
|
initFontScale();
|
|
|
|
|
|
|
|
|
|
TabLayoutResource = Resource.Layout.Tabbar;
|
|
|
|
|
ToolbarResource = Resource.Layout.Toolbar;
|
|
|
|
|
|
|
|
|
|
base.OnCreate(bundle);
|
|
|
|
|
|
|
|
|
|
global::Xamarin.Forms.Forms.Init(this, bundle);
|
|
|
|
|
|
|
|
|
|
FirebaseApp.InitializeApp(this);
|
|
|
|
|
AndroidAppLinks.Init(this);
|
|
|
|
|
|
|
|
|
|
// Initialize xamarin.essentials, see https://docs.microsoft.com/en-us/xamarin/essentials/get-started?tabs=macos%2Candroid.
|
|
|
|
|
Xamarin.Essentials.Platform.Init(this, bundle);
|
|
|
|
|
|
|
|
|
|
// Required for initialization of Maps, see https://developer.xamarin.com/guides/xamarin-forms/user-interface/map/
|
|
|
|
|
Xamarin.FormsGoogleMaps.Init(this, bundle);
|
|
|
|
|
|
|
|
|
|
// Required for initialization of binding package, see https://github.com/nuitsjp/Xamarin.Forms.GoogleMaps.Bindings.
|
|
|
|
|
Xamarin.FormsGoogleMapsBindings.Init();
|
|
|
|
|
|
|
|
|
|
// Get version name of app.
|
|
|
|
|
Context context = ApplicationContext;
|
|
|
|
|
new Model.Device.AppInfo(context.PackageManager.GetPackageInfo(context.PackageName, 0).VersionName);
|
|
|
|
|
|
|
|
|
|
Xamarin.Forms.Forms.ViewInitialized += (object sender, Xamarin.Forms.ViewInitializedEventArgs e) =>
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(e.View.AutomationId))
|
|
|
|
|
{
|
|
|
|
|
e.NativeView.ContentDescription = e.View.AutomationId;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2022-12-07 16:54:52 +01:00
|
|
|
|
await Permissions.RequestAsync<BLEPermissions>();
|
|
|
|
|
await Permissions.RequestAsync<Permissions.LocationWhenInUse>();
|
2022-12-13 10:53:08 +01:00
|
|
|
|
|
|
|
|
|
LoadApplication(new App());
|
2022-11-17 10:05:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Bluetooth Permission on Android 12 "Detect Devices nearby"
|
|
|
|
|
// https://stackoverflow.com/questions/71028853/xamarin-forms-ble-plugin-scan-issue-android-12
|
2022-12-07 16:54:52 +01:00
|
|
|
|
public class BLEPermissions : BasePlatformPermission
|
2022-11-17 10:05:05 +01:00
|
|
|
|
{
|
|
|
|
|
public override (string androidPermission, bool isRuntime)[] RequiredPermissions => new List<(string androidPermission, bool isRuntime)>
|
|
|
|
|
{
|
|
|
|
|
(Android.Manifest.Permission.BluetoothScan, true),
|
|
|
|
|
(Android.Manifest.Permission.BluetoothConnect, true),
|
2022-12-07 16:54:52 +01:00
|
|
|
|
//(Android.Manifest.Permission.AccessFineLocation, true)
|
2022-11-17 10:05:05 +01:00
|
|
|
|
}.ToArray();
|
2022-09-06 16:08:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Handles opening the dialog to request for permissions.
|
|
|
|
|
/// </summary>
|
2022-11-17 10:05:05 +01:00
|
|
|
|
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
|
2022-09-06 16:08:19 +02:00
|
|
|
|
{
|
2022-11-17 10:05:05 +01:00
|
|
|
|
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
|
|
|
PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
|
2022-09-06 16:08:19 +02:00
|
|
|
|
|
|
|
|
|
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-17 10:05:05 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Handles opening the dialog to request for permissions.
|
|
|
|
|
/// </summary>
|
|
|
|
|
//public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Android.Content.PM.Permission[] grantResults)
|
|
|
|
|
//{
|
|
|
|
|
// if (App.PermissionsService.GetType() == typeof(TINK.Services.Permissions.Essentials.Permissions))
|
|
|
|
|
// {
|
|
|
|
|
// Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
|
|
|
// }
|
|
|
|
|
// else if (App.PermissionsService.GetType() == typeof(TINK.Services.Permissions.Plugin.Permissions))
|
|
|
|
|
// {
|
|
|
|
|
// // Bug in 3.0.244 and earlier versions of sharee.bike app: Call of PermissionsImplementation.Current.OnRequestedPermission result was missing.
|
|
|
|
|
// // see https://dev.azure.com/TeilRad/sharee.bike%20Buchungsplattform/_workitems/edit/136 for further details.
|
|
|
|
|
// PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
|
|
|
//}
|
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
[Export("TapStation")]
|
|
|
|
|
public void TapStation(string stationNr)
|
|
|
|
|
{
|
|
|
|
|
BackdoorMethodHelpers.DoTapPage(stationNr);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-11-07 19:42:59 +01:00
|
|
|
|
}
|
|
|
|
|
|