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.Content.PM;
|
||||||
using Android.OS;
|
using Android.OS;
|
||||||
using AndroidX.AppCompat.App;
|
using AndroidX.AppCompat.App;
|
||||||
using Java.Interop;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Borepin.Droid
|
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(
|
[IntentFilter(
|
||||||
new[]
|
new[]
|
||||||
{
|
{
|
||||||
"android.nfc.action.NDEF_DISCOVERED",
|
"android.nfc.action.NDEF_DISCOVERED",
|
||||||
"android.intent.action.VIEW",
|
|
||||||
},
|
},
|
||||||
Categories = new[]
|
Categories = new[]
|
||||||
{
|
{
|
||||||
Intent.CategoryDefault,
|
Intent.CategoryDefault
|
||||||
Intent.CategoryBrowsable
|
|
||||||
},
|
},
|
||||||
DataScheme = "fabaccess"
|
DataScheme = "fabaccess"
|
||||||
)]
|
)]
|
||||||
@ -37,14 +33,7 @@ namespace Borepin.Droid
|
|||||||
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
|
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
|
||||||
|
|
||||||
Xamarin.Forms.Forms.Init(this, savedInstanceState);
|
Xamarin.Forms.Forms.Init(this, savedInstanceState);
|
||||||
|
LoadApplication(new App(new PlatformInitializer()));
|
||||||
Android.Net.Uri intentdata = Intent.Data;
|
|
||||||
Uri uri = null;
|
|
||||||
if (intentdata != null)
|
|
||||||
{
|
|
||||||
uri = new Uri(intentdata.ToString());
|
|
||||||
}
|
|
||||||
LoadApplication(new App(new PlatformInitializer(), uri));
|
|
||||||
}
|
}
|
||||||
protected override void OnNewIntent(Intent intent)
|
protected override void OnNewIntent(Intent intent)
|
||||||
{
|
{
|
||||||
|
@ -26,32 +26,18 @@ namespace Borepin
|
|||||||
{
|
{
|
||||||
public partial class App
|
public partial class App
|
||||||
{
|
{
|
||||||
private readonly Uri _Intent;
|
public App(IPlatformInitializer platformInitializer) : base(platformInitializer)
|
||||||
public App(IPlatformInitializer platformInitializer, Uri intent = null) : base(platformInitializer)
|
|
||||||
{
|
{
|
||||||
NLog.Config.LoggingConfiguration config = new NLog.Config.LoggingConfiguration();
|
NLog.Config.LoggingConfiguration config = new NLog.Config.LoggingConfiguration();
|
||||||
NLog.Targets.ConsoleTarget logconsole = new NLog.Targets.ConsoleTarget("logconsole");
|
NLog.Targets.ConsoleTarget logconsole = new NLog.Targets.ConsoleTarget("logconsole");
|
||||||
config.AddRule(LogLevel.Trace, LogLevel.Fatal, logconsole);
|
config.AddRule(LogLevel.Trace, LogLevel.Fatal, logconsole);
|
||||||
LogManager.Configuration = config;
|
LogManager.Configuration = config;
|
||||||
|
|
||||||
_Intent = intent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async void OnInitialized()
|
protected override async void OnInitialized()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
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);
|
await NavigationService.NavigateAsync(new Uri("https://borepin.fab-access.org/StartPage")).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,49 +55,15 @@ namespace Borepin
|
|||||||
IAPIService apiService = Container.Resolve<IAPIService>();
|
IAPIService apiService = Container.Resolve<IAPIService>();
|
||||||
IAPI api = apiService.GetAPI();
|
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)
|
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)
|
if (optional.Just == null)
|
||||||
{
|
{
|
||||||
Device.BeginInvokeOnMainThread(async () =>
|
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;
|
return;
|
||||||
}
|
}
|
||||||
@ -130,10 +82,6 @@ namespace Borepin
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
return;
|
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>
|
/// <summary>
|
||||||
/// Sucht eine lokalisierte Zeichenfolge, die Password is invalid. ähnelt.
|
/// Sucht eine lokalisierte Zeichenfolge, die Password is invalid. ähnelt.
|
||||||
/// </summary>
|
/// </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>
|
<value>Connection already exist. Please delete old Connection before adding the new Connection.</value>
|
||||||
<comment>Message Content</comment>
|
<comment>Message Content</comment>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ALERT_ID" xml:space="preserve">
|
||||||
|
<value>ID is invalid.</value>
|
||||||
|
</data>
|
||||||
<data name="ALERT_PasswordInvalid" xml:space="preserve">
|
<data name="ALERT_PasswordInvalid" xml:space="preserve">
|
||||||
<value>Password is invalid.</value>
|
<value>Password is invalid.</value>
|
||||||
<comment>Message Content</comment>
|
<comment>Message Content</comment>
|
||||||
|
@ -323,7 +323,14 @@ namespace FabAccessAPI
|
|||||||
{
|
{
|
||||||
if(!IsConnected && CanConnect)
|
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