diff --git a/Borepin/Borepin.Android/MainActivity.cs b/Borepin/Borepin.Android/MainActivity.cs index 26a6f98..f81587e 100644 --- a/Borepin/Borepin.Android/MainActivity.cs +++ b/Borepin/Borepin.Android/MainActivity.cs @@ -3,22 +3,18 @@ using Android.Content; using Android.Content.PM; using Android.OS; using AndroidX.AppCompat.App; -using Java.Interop; -using System; namespace Borepin.Droid { - [Activity(MainLauncher = true, Exported = true, Theme = "@style/MainTheme", LaunchMode = LaunchMode.SingleTask, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)] + [Activity(Theme = "@style/MainTheme", LaunchMode = LaunchMode.SingleTask, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, Exported = true)] [IntentFilter( new[] { "android.nfc.action.NDEF_DISCOVERED", - "android.intent.action.VIEW", }, Categories = new[] { - Intent.CategoryDefault, - Intent.CategoryBrowsable + Intent.CategoryDefault }, DataScheme = "fabaccess" )] @@ -37,14 +33,7 @@ namespace Borepin.Droid Xamarin.Essentials.Platform.Init(this, savedInstanceState); Xamarin.Forms.Forms.Init(this, savedInstanceState); - - Android.Net.Uri intentdata = Intent.Data; - Uri uri = null; - if (intentdata != null) - { - uri = new Uri(intentdata.ToString()); - } - LoadApplication(new App(new PlatformInitializer(), uri)); + LoadApplication(new App(new PlatformInitializer())); } protected override void OnNewIntent(Intent intent) { diff --git a/Borepin/Borepin/App.xaml.cs b/Borepin/Borepin/App.xaml.cs index 8db5e7b..6adb105 100644 --- a/Borepin/Borepin/App.xaml.cs +++ b/Borepin/Borepin/App.xaml.cs @@ -26,32 +26,18 @@ namespace Borepin { public partial class App { - private readonly Uri _Intent; - public App(IPlatformInitializer platformInitializer, Uri intent = null) : base(platformInitializer) + public App(IPlatformInitializer platformInitializer) : base(platformInitializer) { NLog.Config.LoggingConfiguration config = new NLog.Config.LoggingConfiguration(); NLog.Targets.ConsoleTarget logconsole = new NLog.Targets.ConsoleTarget("logconsole"); config.AddRule(LogLevel.Trace, LogLevel.Fatal, logconsole); LogManager.Configuration = config; - - _Intent = intent; } protected override async void OnInitialized() { InitializeComponent(); - if(_Intent!= null) - { - Prism.Navigation.NavigationParameters parameters = new Prism.Navigation.NavigationParameters - { - { "intent", _Intent }, - }; - - await NavigationService.NavigateAsync(new Uri("https://borepin.fab-access.org/StartPage"), parameters).ConfigureAwait(false); - return; - } - await NavigationService.NavigateAsync(new Uri("https://borepin.fab-access.org/StartPage")).ConfigureAwait(false); } @@ -69,49 +55,15 @@ namespace Borepin IAPIService apiService = Container.Resolve(); IAPI api = apiService.GetAPI(); - // TODO Preferred Account - //if (!api.IsConnected) - //{ - // ILoginStorageService loginStorageService = Container.Resolve(); - // List list = (List)await loginStorageService.GetList().ConfigureAwait(false); - - // ConnectionData connectionData = list.Find(x => string.Equals(x.Host.Host, uri.Host, StringComparison.OrdinalIgnoreCase)); - - // if(connectionData == null) - // { - // Device.BeginInvokeOnMainThread(async () => - // { - // await pageDialogService.DisplayAlertAsync("NFC connect failed", "No ConnectionData", "Ok").ConfigureAwait(false); - // }); - - // return; - // } - - // try - // { - // await api.Connect(connectionData).ConfigureAwait(false); - // } - // catch (Exception ex) - // { - // // TODO - // Device.BeginInvokeOnMainThread(async () => - // { - // await pageDialogService.DisplayAlertAsync("NFC connect failed", ex.ToString(), "Ok").ConfigureAwait(false); - // }); - - // return; - // } - //} - if (api.IsConnected) { - Optional < Machine> optional = await api.Session.MachineSystem.Info.GetMachine(resource_id).ConfigureAwait(false); + Optional optional = await api.Session.MachineSystem.Info.GetMachine(resource_id).ConfigureAwait(false); if (optional.Just == null) { Device.BeginInvokeOnMainThread(async () => { - await pageDialogService.DisplayAlertAsync("NFC Error", "Unknown ID" + resource_id, "Ok").ConfigureAwait(false); + await pageDialogService.DisplayAlertAsync(Borepin.Resources.Text.TextResource.ALERT, Borepin.Resources.Text.TextResource.ALERT_ID, Borepin.Resources.Text.TextResource.OK).ConfigureAwait(false); }); return; } @@ -130,10 +82,6 @@ namespace Borepin else { return; - //Device.BeginInvokeOnMainThread(async () => - //{ - // INavigationResult result = await NavigationService.NavigateAsync(new Uri("https://borepin.fab-access.org/StartPage")).ConfigureAwait(false); - //}); } } diff --git a/Borepin/Borepin/Resources/Text/TextResource.Designer.cs b/Borepin/Borepin/Resources/Text/TextResource.Designer.cs index 60a9afa..b0cee63 100644 --- a/Borepin/Borepin/Resources/Text/TextResource.Designer.cs +++ b/Borepin/Borepin/Resources/Text/TextResource.Designer.cs @@ -233,6 +233,15 @@ namespace Borepin.Resources.Text { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die ID is invalid. ähnelt. + /// + internal static string ALERT_ID { + get { + return ResourceManager.GetString("ALERT_ID", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Password is invalid. ähnelt. /// diff --git a/Borepin/Borepin/Resources/Text/TextResource.resx b/Borepin/Borepin/Resources/Text/TextResource.resx index 1b7a9cf..1767594 100644 --- a/Borepin/Borepin/Resources/Text/TextResource.resx +++ b/Borepin/Borepin/Resources/Text/TextResource.resx @@ -185,6 +185,9 @@ You can also put down several servers and then connect to the desired server.Connection already exist. Please delete old Connection before adding the new Connection. Message Content + + ID is invalid. + Password is invalid. Message Content diff --git a/FabAccessAPI/API.cs b/FabAccessAPI/API.cs index 929f6e1..5d215ba 100644 --- a/FabAccessAPI/API.cs +++ b/FabAccessAPI/API.cs @@ -323,7 +323,14 @@ namespace FabAccessAPI { if(!IsConnected && CanConnect) { - await Connect(ConnectionData).ConfigureAwait(false); + try + { + await Connect(ConnectionData).ConfigureAwait(false); + } + catch(AuthenticationException) + { + await Disconnect().ConfigureAwait(false); + } } }