mirror of
https://github.com/NecroticBamboo/QRBee.git
synced 2025-12-21 12:11:53 +00:00
Fingerprint authentication added.
This commit is contained in:
parent
4092564222
commit
978cb50603
@ -6,6 +6,7 @@ using Android.Runtime;
|
||||
using Android.OS;
|
||||
using Android.Support.V4.Content;
|
||||
using AndroidX.Core.App;
|
||||
using Plugin.Fingerprint;
|
||||
|
||||
namespace QRBee.Droid
|
||||
{
|
||||
@ -18,9 +19,13 @@ namespace QRBee.Droid
|
||||
base.OnCreate(savedInstanceState);
|
||||
|
||||
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
|
||||
|
||||
CrossFingerprint.SetCurrentActivityResolver(()=>Xamarin.Essentials.Platform.CurrentActivity);
|
||||
|
||||
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
|
||||
LoadApplication(new App());
|
||||
ZXing.Mobile.MobileBarcodeScanner.Initialize(Application);
|
||||
|
||||
if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.Camera) == (int) Permission.Granted)
|
||||
{
|
||||
|
||||
@ -28,6 +33,7 @@ namespace QRBee.Droid
|
||||
else
|
||||
{
|
||||
ActivityCompat.RequestPermissions(this, new String[] { Manifest.Permission.Camera }, 0);
|
||||
// ActivityCompat.RequestPermissions(this, new String[] { Manifest.Permission.UseFingerprint }, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4,4 +4,5 @@
|
||||
<application android:label="QRBee.Android" android:theme="@style/MainTheme"></application>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
|
||||
</manifest>
|
||||
@ -59,6 +59,9 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Plugin.Fingerprint">
|
||||
<Version>2.1.4</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Xamarin.Android.Support.Compat">
|
||||
<Version>28.0.0.3</Version>
|
||||
</PackageReference>
|
||||
|
||||
17258
QRBee/QRBee.Android/Resources/Resource.designer.cs
generated
17258
QRBee/QRBee.Android/Resources/Resource.designer.cs
generated
File diff suppressed because it is too large
Load Diff
@ -132,6 +132,9 @@
|
||||
<Reference Include="System.Numerics.Vectors" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Plugin.Fingerprint">
|
||||
<Version>2.1.4</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2244" />
|
||||
<PackageReference Include="Xamarin.Essentials" Version="1.7.0" />
|
||||
<PackageReference Include="ZXing.Net.Mobile">
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Plugin.Fingerprint" Version="2.1.4" />
|
||||
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2244" />
|
||||
<PackageReference Include="Xamarin.Essentials" Version="1.7.0" />
|
||||
<PackageReference Include="ZXing.Net.Mobile" Version="2.4.1" />
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Plugin.Fingerprint;
|
||||
using Plugin.Fingerprint.Abstractions;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace QRBee.ViewModels
|
||||
@ -28,8 +30,27 @@ namespace QRBee.ViewModels
|
||||
/// <param name="obj"></param>
|
||||
private async void OnLoginClicked(object obj)
|
||||
{
|
||||
// Prefixing with `//` switches to a different navigation stack instead of pushing to the active one
|
||||
await Shell.Current.GoToAsync($"//{nameof(MainPage)}");
|
||||
bool isFingerprintAvailable = await CrossFingerprint.Current.IsAvailableAsync(false);
|
||||
if (!isFingerprintAvailable)
|
||||
{
|
||||
//Insert PIN
|
||||
return;
|
||||
}
|
||||
|
||||
var conf = new AuthenticationRequestConfiguration("Authentication", "Authenticate access to your personal data");
|
||||
|
||||
var authResult = await CrossFingerprint.Current.AuthenticateAsync(conf);
|
||||
if (authResult.Authenticated)
|
||||
{
|
||||
//Success
|
||||
// Prefixing with `//` switches to a different navigation stack instead of pushing to the active one
|
||||
await Shell.Current.GoToAsync($"//{nameof(MainPage)}");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Failure
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -10,13 +10,13 @@
|
||||
<ContentPage.Content>
|
||||
|
||||
<StackLayout Padding="10,0,10,0" VerticalOptions="Center">
|
||||
<StackLayout Orientation="Vertical">
|
||||
<Label Text="Login: " Padding="5,10,0,0"/>
|
||||
<Entry HorizontalOptions="FillAndExpand" Keyboard="Text"/>
|
||||
|
||||
<Label Text="Password: " Padding="5,0,0,0" />
|
||||
<Entry HorizontalOptions="FillAndExpand" IsPassword="True"/>
|
||||
</StackLayout>
|
||||
<!-- <StackLayout Orientation="Vertical"> -->
|
||||
<!-- <Label Text="Login: " Padding="5,10,0,0"/> -->
|
||||
<!-- <Entry HorizontalOptions="FillAndExpand" Keyboard="Text"/> -->
|
||||
<!-- -->
|
||||
<!-- <Label Text="Password: " Padding="5,0,0,0" /> -->
|
||||
<!-- <Entry HorizontalOptions="FillAndExpand" IsPassword="True"/> -->
|
||||
<!-- </StackLayout> -->
|
||||
|
||||
<Button VerticalOptions="Center" Text="Login" Command="{Binding LoginCommand}"/>
|
||||
<Button VerticalOptions="Center" Text="Register new user" Command="{Binding RegisterCommand}"/>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user