mirror of
https://github.com/bitwarden/android.git
synced 2025-01-11 18:57:39 +03:00
Modified Permissions Flow (#1005)
Permissions flow for Android was causing the white screen on initial permission grant on occasion. Moved permission grant to pre-TOTP page load.
This commit is contained in:
parent
1a96d3c38e
commit
ff322cd2dd
3 changed files with 31 additions and 2 deletions
|
@ -18,6 +18,7 @@ using Android.Nfc;
|
||||||
using Bit.App.Utilities;
|
using Bit.App.Utilities;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AndroidX.Core.Content;
|
using AndroidX.Core.Content;
|
||||||
|
using ZXing.Net.Mobile.Android;
|
||||||
|
|
||||||
namespace Bit.Droid
|
namespace Bit.Droid
|
||||||
{
|
{
|
||||||
|
@ -193,8 +194,7 @@ namespace Bit.Droid
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
|
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
ZXing.Net.Mobile.Forms.Android.PermissionsHandler.OnRequestPermissionsResult(
|
PermissionsHandler.OnRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
requestCode, permissions, grantResults);
|
|
||||||
}
|
}
|
||||||
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
|
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
using Bit.App.Abstractions;
|
using Bit.App.Abstractions;
|
||||||
using Bit.App.Models;
|
using Bit.App.Models;
|
||||||
using Bit.App.Resources;
|
using Bit.App.Resources;
|
||||||
|
using Bit.App.Utilities;
|
||||||
using Bit.Core;
|
using Bit.Core;
|
||||||
using Bit.Core.Abstractions;
|
using Bit.Core.Abstractions;
|
||||||
using Bit.Core.Enums;
|
using Bit.Core.Enums;
|
||||||
using Bit.Core.Utilities;
|
using Bit.Core.Utilities;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Xamarin.Essentials;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
using Xamarin.Forms.PlatformConfiguration;
|
using Xamarin.Forms.PlatformConfiguration;
|
||||||
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
|
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
|
||||||
|
@ -243,6 +245,12 @@ namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
if (DoOnce())
|
if (DoOnce())
|
||||||
{
|
{
|
||||||
|
var cameraPermission = await PermissionManager.CheckAndRequestPermissionAsync(new Permissions.Camera());
|
||||||
|
if (cameraPermission != PermissionStatus.Granted)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var page = new ScanPage(key =>
|
var page = new ScanPage(key =>
|
||||||
{
|
{
|
||||||
Device.BeginInvokeOnMainThread(async () =>
|
Device.BeginInvokeOnMainThread(async () =>
|
||||||
|
|
21
src/App/Utilities/PermissionManager.cs
Normal file
21
src/App/Utilities/PermissionManager.cs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Xamarin.Essentials;
|
||||||
|
using static Xamarin.Essentials.Permissions;
|
||||||
|
|
||||||
|
namespace Bit.App.Utilities
|
||||||
|
{
|
||||||
|
public static class PermissionManager
|
||||||
|
{
|
||||||
|
public static async Task<PermissionStatus> CheckAndRequestPermissionAsync<T>(T permission)
|
||||||
|
where T : BasePermission
|
||||||
|
{
|
||||||
|
var status = await permission.CheckStatusAsync();
|
||||||
|
if (status != PermissionStatus.Granted)
|
||||||
|
{
|
||||||
|
status = await permission.RequestAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue