feature: support db import on Android
This commit is contained in:
@@ -24,8 +24,11 @@ namespace Billing
|
||||
private static List<Account> accounts;
|
||||
private static List<Category> categories;
|
||||
|
||||
public App()
|
||||
private string initialUrl;
|
||||
|
||||
public App(string url = null)
|
||||
{
|
||||
initialUrl = url;
|
||||
CurrentCulture = new PlatformCulture();
|
||||
InitResources();
|
||||
|
||||
@@ -36,6 +39,13 @@ namespace Billing
|
||||
{
|
||||
Helper.Debug($"personal folder: {StoreHelper.PersonalFolder}");
|
||||
Helper.Debug($"cache folder: {StoreHelper.CacheFolder}");
|
||||
|
||||
if (initialUrl != null)
|
||||
{
|
||||
var url = initialUrl;
|
||||
initialUrl = null;
|
||||
_ = OpenUrl(url);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task InitializeData()
|
||||
@@ -83,17 +93,25 @@ namespace Billing
|
||||
Resources = instance;
|
||||
}
|
||||
|
||||
public static bool OpenUrl(Uri uri)
|
||||
public static async Task<bool> OpenUrl(string url)
|
||||
{
|
||||
if (uri == null || !uri.IsFile)
|
||||
if (string.IsNullOrEmpty(url))
|
||||
{
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
var absolute = uri.AbsolutePath;
|
||||
var url = System.Net.WebUtility.UrlDecode(absolute);
|
||||
if (File.Exists(url))
|
||||
{
|
||||
Task.Run(async () =>
|
||||
var status = await Permissions.CheckStatusAsync<Permissions.StorageRead>();
|
||||
if (status != PermissionStatus.Disabled &&
|
||||
status != PermissionStatus.Granted)
|
||||
{
|
||||
status = await Permissions.RequestAsync<Permissions.StorageRead>();
|
||||
}
|
||||
if (status != PermissionStatus.Granted)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
var result = await StoreHelper.ReloadDatabase(url);
|
||||
if (result)
|
||||
|
Reference in New Issue
Block a user