mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-03-12 06:41:54 +01:00
Fixed: Intent on Android
This commit is contained in:
parent
c8c07e502b
commit
825879a043
@ -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)
|
||||
{
|
||||
|
@ -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<IAPIService>();
|
||||
IAPI api = apiService.GetAPI();
|
||||
|
||||
// TODO Preferred Account
|
||||
//if (!api.IsConnected)
|
||||
//{
|
||||
// ILoginStorageService loginStorageService = Container.Resolve<ILoginStorageService>();
|
||||
// List<ConnectionData> list = (List<ConnectionData>)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<Machine> 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);
|
||||
//});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,6 +233,15 @@ namespace Borepin.Resources.Text {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die ID is invalid. ähnelt.
|
||||
/// </summary>
|
||||
internal static string ALERT_ID {
|
||||
get {
|
||||
return ResourceManager.GetString("ALERT_ID", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Password is invalid. ähnelt.
|
||||
/// </summary>
|
||||
|
@ -185,6 +185,9 @@ You can also put down several servers and then connect to the desired server.</v
|
||||
<value>Connection already exist. Please delete old Connection before adding the new Connection.</value>
|
||||
<comment>Message Content</comment>
|
||||
</data>
|
||||
<data name="ALERT_ID" xml:space="preserve">
|
||||
<value>ID is invalid.</value>
|
||||
</data>
|
||||
<data name="ALERT_PasswordInvalid" xml:space="preserve">
|
||||
<value>Password is invalid.</value>
|
||||
<comment>Message Content</comment>
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user