Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop' into gh-1112
Browse files Browse the repository at this point in the history
  • Loading branch information
Redth authored Mar 11, 2020
2 parents bc3c859 + 21a0a46 commit 852e563
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Xamarin.Essentials/Permissions/Permissions.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ public override (string androidPermission, bool isRuntime)[] RequiredPermissions
{
var permissions = new List<(string, bool)>();
#if __ANDROID_29__
if (Platform.HasApiLevelQ)
// Check if running and targeting Q
if (Platform.HasApiLevelQ && Platform.AppContext.ApplicationInfo.TargetSdkVersion >= BuildVersionCodes.Q)
permissions.Add((Manifest.Permission.AccessBackgroundLocation, true));
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public override async Task<PermissionStatus> RequestAsync()
EnsureDeclared();

var status = GetLocationStatus(true);
if (status == PermissionStatus.Granted)
if (status == PermissionStatus.Granted || status == PermissionStatus.Disabled)
return status;

EnsureMainThread();
Expand Down
10 changes: 5 additions & 5 deletions Xamarin.Essentials/Platform/Platform.ios.tvos.watchos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ internal static UIViewController GetCurrentViewController(bool throwIfNull = tru

var window = UIApplication.SharedApplication.KeyWindow;

if (window.WindowLevel == UIWindowLevel.Normal)
if (window != null && window.WindowLevel == UIWindowLevel.Normal)
viewController = window.RootViewController;

if (viewController == null)
Expand All @@ -76,13 +76,13 @@ internal static UIViewController GetCurrentViewController(bool throwIfNull = tru
.OrderByDescending(w => w.WindowLevel)
.FirstOrDefault(w => w.RootViewController != null && w.WindowLevel == UIWindowLevel.Normal);

if (window == null)
if (window == null && throwIfNull)
throw new InvalidOperationException("Could not find current view controller.");
else
viewController = window.RootViewController;
viewController = window?.RootViewController;
}

while (viewController.PresentedViewController != null)
while (viewController?.PresentedViewController != null)
viewController = viewController.PresentedViewController;

if (throwIfNull && viewController == null)
Expand All @@ -95,7 +95,7 @@ internal static UIWindow GetCurrentWindow(bool throwIfNull = true)
{
var window = UIApplication.SharedApplication.KeyWindow;

if (window.WindowLevel == UIWindowLevel.Normal)
if (window != null && window.WindowLevel == UIWindowLevel.Normal)
return window;

if (window == null)
Expand Down

0 comments on commit 852e563

Please sign in to comment.