WIP: app as share target fixes
This commit is contained in:
Родитель
e5f321e0b3
Коммит
8700b3d5a6
|
@ -96,6 +96,12 @@ namespace NextcloudApp
|
|||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
// Ignore exceptions comming from multithreading (cast exceptions)
|
||||
if (args.Exception.GetType() == typeof(System.Runtime.InteropServices.COMException) || args.Exception.GetType() == typeof(InvalidCastException))
|
||||
{
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
if (args.Exception.GetType() == typeof(ResponseError))
|
||||
{
|
||||
args.Handled = true;
|
||||
|
@ -156,6 +162,9 @@ namespace NextcloudApp
|
|||
|
||||
protected override void OnShareTargetActivated(ShareTargetActivatedEventArgs args)
|
||||
{
|
||||
Window.Current.Content = null;
|
||||
SettingsService.Default.Value.Disposed();
|
||||
|
||||
base.OnShareTargetActivated(args);
|
||||
|
||||
OnShareTargetActivatedsyncAsync(args);
|
||||
|
@ -175,7 +184,6 @@ namespace NextcloudApp
|
|||
// get the shared items and create a token for later access
|
||||
var sorageItems = await args.ShareOperation.Data.GetStorageItemsAsync();
|
||||
StorageApplicationPermissions.FutureAccessList.Clear();
|
||||
args.ShareOperation.ReportDataRetrieved();
|
||||
|
||||
// show a simple loading page without any dependencies, to avoid te system killing our app
|
||||
var frame = new Frame();
|
||||
|
@ -190,12 +198,17 @@ namespace NextcloudApp
|
|||
DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseNone
|
||||
};
|
||||
|
||||
var storageFiles = sorageItems.Where(storageItem => storageItem.IsOfType(StorageItemTypes.File));
|
||||
|
||||
var inputData = new ValueSet
|
||||
{
|
||||
{ "FileTokens", (from storageItem in sorageItems where storageItem.IsOfType(StorageItemTypes.File) select StorageApplicationPermissions.FutureAccessList.Add(storageItem)).ToArray() }
|
||||
{ "FileTokens", storageFiles.Select(storageFile => StorageApplicationPermissions.FutureAccessList.Add(storageFile)).ToArray() }
|
||||
};
|
||||
var uri = new Uri("nextcloud:///share");
|
||||
|
||||
// we processed all files, so we are redy to release them
|
||||
args.ShareOperation.ReportDataRetrieved();
|
||||
|
||||
await Launcher.LaunchUriAsync(uri, options, inputData);
|
||||
|
||||
// we are done, report back
|
||||
|
@ -324,19 +337,19 @@ namespace NextcloudApp
|
|||
var task = base.OnInitializeAsync(args);
|
||||
DeviceGestureService.GoBackRequested += DeviceGestureServiceOnGoBackRequested;
|
||||
// Just count total app starts
|
||||
SettingsService.Instance.LocalSettings.AppTotalRuns = SettingsService.Instance.LocalSettings.AppTotalRuns + 1;
|
||||
SettingsService.Default.Value.LocalSettings.AppTotalRuns = SettingsService.Default.Value.LocalSettings.AppTotalRuns + 1;
|
||||
// Count app starts after last update
|
||||
var currentVersion =
|
||||
$"{Package.Current.Id.Version.Major}.{Package.Current.Id.Version.Minor}.{Package.Current.Id.Version.Build}.{Package.Current.Id.Version.Revision}";
|
||||
if (currentVersion == SettingsService.Instance.LocalSettings.AppRunsAfterLastUpdateVersion)
|
||||
if (currentVersion == SettingsService.Default.Value.LocalSettings.AppRunsAfterLastUpdateVersion)
|
||||
{
|
||||
SettingsService.Instance.LocalSettings.AppRunsAfterLastUpdate = SettingsService.Instance.LocalSettings.AppRunsAfterLastUpdate + 1;
|
||||
SettingsService.Default.Value.LocalSettings.AppRunsAfterLastUpdate = SettingsService.Default.Value.LocalSettings.AppRunsAfterLastUpdate + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
SettingsService.Instance.LocalSettings.AppRunsAfterLastUpdateVersion = currentVersion;
|
||||
SettingsService.Instance.LocalSettings.AppRunsAfterLastUpdate = 1;
|
||||
SettingsService.Instance.LocalSettings.ShowUpdateMessage = true;
|
||||
SettingsService.Default.Value.LocalSettings.AppRunsAfterLastUpdateVersion = currentVersion;
|
||||
SettingsService.Default.Value.LocalSettings.AppRunsAfterLastUpdate = 1;
|
||||
SettingsService.Default.Value.LocalSettings.ShowUpdateMessage = true;
|
||||
}
|
||||
MigrationService.Instance.StartMigration();
|
||||
return task;
|
||||
|
@ -361,7 +374,7 @@ namespace NextcloudApp
|
|||
};
|
||||
}
|
||||
}
|
||||
if (SettingsService.Instance.LocalSettings.UseWindowsHello)
|
||||
if (SettingsService.Default.Value.LocalSettings.UseWindowsHello)
|
||||
{
|
||||
CheckSettingsAndContinue(PageToken.Verification, pageParameters);
|
||||
}
|
||||
|
@ -375,8 +388,8 @@ namespace NextcloudApp
|
|||
private void CheckSettingsAndContinue(PageToken requestedPage, IPageParameters pageParameters)
|
||||
{
|
||||
if (
|
||||
string.IsNullOrEmpty(SettingsService.Instance.LocalSettings.ServerAddress) ||
|
||||
string.IsNullOrEmpty(SettingsService.Instance.LocalSettings.Username)
|
||||
string.IsNullOrEmpty(SettingsService.Default.Value.LocalSettings.ServerAddress) ||
|
||||
string.IsNullOrEmpty(SettingsService.Default.Value.LocalSettings.Username)
|
||||
)
|
||||
{
|
||||
NavigationService.Navigate(PageToken.Login.ToString(), null);
|
||||
|
@ -387,13 +400,13 @@ namespace NextcloudApp
|
|||
IReadOnlyList<PasswordCredential> credentialList = null;
|
||||
try
|
||||
{
|
||||
credentialList = vault.FindAllByResource(SettingsService.Instance.LocalSettings.ServerAddress);
|
||||
credentialList = vault.FindAllByResource(SettingsService.Default.Value.LocalSettings.ServerAddress);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
var credential = credentialList?.FirstOrDefault(item => item.UserName.Equals(SettingsService.Instance.LocalSettings.Username));
|
||||
var credential = credentialList?.FirstOrDefault(item => item.UserName.Equals(SettingsService.Default.Value.LocalSettings.Username));
|
||||
if (credential != null)
|
||||
{
|
||||
credential.RetrievePassword();
|
||||
|
|
|
@ -14,15 +14,15 @@ namespace NextcloudApp
|
|||
|
||||
private void ShowUpdateMessage()
|
||||
{
|
||||
if (SettingsService.Instance.LocalSettings.ShowUpdateMessage)
|
||||
if (SettingsService.Default.Value.LocalSettings.ShowUpdateMessage)
|
||||
{
|
||||
UpdateNotificationService.NotifyUser(UpdateDialogContainer, UpdateDialogTitle, UpdateDialogContent, UpdateDialogButton1, UpdateDialogButton2);
|
||||
}
|
||||
else
|
||||
{
|
||||
SettingsService.Instance.LocalSettings.PropertyChanged += (sender, args) =>
|
||||
SettingsService.Default.Value.LocalSettings.PropertyChanged += (sender, args) =>
|
||||
{
|
||||
if (args.PropertyName.Equals("ShowUpdateMessage") && SettingsService.Instance.LocalSettings.ShowUpdateMessage)
|
||||
if (args.PropertyName.Equals("ShowUpdateMessage") && SettingsService.Default.Value.LocalSettings.ShowUpdateMessage)
|
||||
{
|
||||
UpdateNotificationService.NotifyUser(UpdateDialogContainer, UpdateDialogTitle, UpdateDialogContent, UpdateDialogButton1, UpdateDialogButton2);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace NextcloudApp.Controls
|
|||
{
|
||||
public ThemeablePage()
|
||||
{
|
||||
var theme = SettingsService.Instance.RoamingSettings.Theme;
|
||||
var theme = SettingsService.Default.Value.RoamingSettings.Theme;
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.System:
|
||||
|
@ -24,14 +24,14 @@ namespace NextcloudApp.Controls
|
|||
break;
|
||||
}
|
||||
|
||||
SettingsService.Instance.RoamingSettings.PropertyChanged += RoamingSettingsOnPropertyChanged;
|
||||
SettingsService.Default.Value.RoamingSettings.PropertyChanged += RoamingSettingsOnPropertyChanged;
|
||||
}
|
||||
|
||||
private void RoamingSettingsOnPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName.Equals("Theme"))
|
||||
{
|
||||
var theme = SettingsService.Instance.RoamingSettings.Theme;
|
||||
var theme = SettingsService.Default.Value.RoamingSettings.Theme;
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.System:
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace NextcloudApp.Converter
|
|||
{
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
return SettingsService.Instance.LocalSettings.ExpertMode ? Visibility.Visible : Visibility.Collapsed;
|
||||
return SettingsService.Default.Value.LocalSettings.ExpertMode ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Newtonsoft.Json;
|
||||
using NextcloudApp.Utils;
|
||||
using Windows.Storage;
|
||||
|
||||
|
@ -11,7 +13,7 @@ namespace NextcloudApp.Models
|
|||
{
|
||||
private const string DefaultValueEmptyString = "";
|
||||
|
||||
public static LocalSettings Default { get; } = new LocalSettings();
|
||||
public static Lazy<LocalSettings> Default = new Lazy<LocalSettings>(() => new LocalSettings(), LazyThreadSafetyMode.ExecutionAndPublication);
|
||||
|
||||
public LocalSettings()
|
||||
: base(ApplicationData.Current.LocalSettings)
|
||||
|
@ -137,5 +139,16 @@ namespace NextcloudApp.Models
|
|||
|
||||
EnableRaisePropertyChanged = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases unmanaged and - optionally - managed resources.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (Default.IsValueCreated)
|
||||
{
|
||||
Default = new Lazy<LocalSettings>(() => new LocalSettings(), LazyThreadSafetyMode.ExecutionAndPublication);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Newtonsoft.Json;
|
||||
using NextcloudApp.Utils;
|
||||
using Windows.Storage;
|
||||
|
||||
|
@ -9,7 +11,7 @@ namespace NextcloudApp.Models
|
|||
/// </summary>
|
||||
public class RoamingSettings : ObservableSettings
|
||||
{
|
||||
public static RoamingSettings Default { get; } = new RoamingSettings();
|
||||
public static Lazy<RoamingSettings> Default = new Lazy<RoamingSettings>(() => new RoamingSettings(), LazyThreadSafetyMode.ExecutionAndPublication);
|
||||
|
||||
public RoamingSettings()
|
||||
: base(ApplicationData.Current.RoamingSettings)
|
||||
|
@ -43,5 +45,16 @@ namespace NextcloudApp.Models
|
|||
|
||||
EnableRaisePropertyChanged = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases unmanaged and - optionally - managed resources.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (Default.IsValueCreated)
|
||||
{
|
||||
Default = new Lazy<RoamingSettings>(() => new RoamingSettings(), LazyThreadSafetyMode.ExecutionAndPublication);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,22 +21,22 @@ namespace NextcloudApp.Services
|
|||
return _client;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(SettingsService.Instance.LocalSettings.ServerAddress) &&
|
||||
!string.IsNullOrEmpty(SettingsService.Instance.LocalSettings.Username))
|
||||
if (!string.IsNullOrEmpty(SettingsService.Default.Value.LocalSettings.ServerAddress) &&
|
||||
!string.IsNullOrEmpty(SettingsService.Default.Value.LocalSettings.Username))
|
||||
{
|
||||
var vault = new PasswordVault();
|
||||
|
||||
IReadOnlyList<PasswordCredential> credentialList = null;
|
||||
try
|
||||
{
|
||||
credentialList = vault.FindAllByResource(SettingsService.Instance.LocalSettings.ServerAddress);
|
||||
credentialList = vault.FindAllByResource(SettingsService.Default.Value.LocalSettings.ServerAddress);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
var credential = credentialList?.FirstOrDefault(item => item.UserName.Equals(SettingsService.Instance.LocalSettings.Username));
|
||||
var credential = credentialList?.FirstOrDefault(item => item.UserName.Equals(SettingsService.Default.Value.LocalSettings.Username));
|
||||
|
||||
if (credential == null)
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ namespace NextcloudApp.Services
|
|||
|
||||
try
|
||||
{
|
||||
var response = await NextcloudClient.NextcloudClient.GetServerStatus(credential.Resource, SettingsService.Instance.LocalSettings.IgnoreServerCertificateErrors);
|
||||
var response = await NextcloudClient.NextcloudClient.GetServerStatus(credential.Resource, SettingsService.Default.Value.LocalSettings.IgnoreServerCertificateErrors);
|
||||
if (response == null)
|
||||
{
|
||||
await ShowServerAddressNotFoundMessage(credential.Resource);
|
||||
|
@ -66,21 +66,21 @@ namespace NextcloudApp.Services
|
|||
credential.Password
|
||||
) {
|
||||
IgnoreServerCertificateErrors =
|
||||
SettingsService.Instance.LocalSettings.IgnoreServerCertificateErrors
|
||||
SettingsService.Default.Value.LocalSettings.IgnoreServerCertificateErrors
|
||||
};
|
||||
}
|
||||
|
||||
SettingsService.Instance.LocalSettings.PropertyChanged += async (sender, args) =>
|
||||
SettingsService.Default.Value.LocalSettings.PropertyChanged += async (sender, args) =>
|
||||
{
|
||||
if (_client != null && args.PropertyName == "IgnoreServerCertificateErrors")
|
||||
{
|
||||
_client.IgnoreServerCertificateErrors =
|
||||
SettingsService.Instance.LocalSettings.IgnoreServerCertificateErrors;
|
||||
SettingsService.Default.Value.LocalSettings.IgnoreServerCertificateErrors;
|
||||
}
|
||||
|
||||
if (
|
||||
string.IsNullOrEmpty(SettingsService.Instance.LocalSettings.ServerAddress) ||
|
||||
string.IsNullOrEmpty(SettingsService.Instance.LocalSettings.Username)
|
||||
string.IsNullOrEmpty(SettingsService.Default.Value.LocalSettings.ServerAddress) ||
|
||||
string.IsNullOrEmpty(SettingsService.Default.Value.LocalSettings.Username)
|
||||
)
|
||||
{
|
||||
_client = null;
|
||||
|
@ -92,14 +92,14 @@ namespace NextcloudApp.Services
|
|||
IReadOnlyList<PasswordCredential> credentialList = null;
|
||||
try
|
||||
{
|
||||
credentialList = vault.FindAllByResource(SettingsService.Instance.LocalSettings.ServerAddress);
|
||||
credentialList = vault.FindAllByResource(SettingsService.Default.Value.LocalSettings.ServerAddress);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
var credential = credentialList?.FirstOrDefault(item => item.UserName.Equals(SettingsService.Instance.LocalSettings.Username));
|
||||
var credential = credentialList?.FirstOrDefault(item => item.UserName.Equals(SettingsService.Default.Value.LocalSettings.Username));
|
||||
|
||||
if (credential == null)
|
||||
{
|
||||
|
@ -111,7 +111,7 @@ namespace NextcloudApp.Services
|
|||
|
||||
try
|
||||
{
|
||||
var response = await NextcloudClient.NextcloudClient.GetServerStatus(credential.Resource, SettingsService.Instance.LocalSettings.IgnoreServerCertificateErrors);
|
||||
var response = await NextcloudClient.NextcloudClient.GetServerStatus(credential.Resource, SettingsService.Default.Value.LocalSettings.IgnoreServerCertificateErrors);
|
||||
if (response == null)
|
||||
{
|
||||
_client = null;
|
||||
|
@ -132,7 +132,7 @@ namespace NextcloudApp.Services
|
|||
credential.Password
|
||||
) {
|
||||
IgnoreServerCertificateErrors =
|
||||
SettingsService.Instance.LocalSettings.IgnoreServerCertificateErrors
|
||||
SettingsService.Default.Value.LocalSettings.IgnoreServerCertificateErrors
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -162,7 +162,7 @@ namespace NextcloudApp.Services
|
|||
PrimaryButtonText = resourceLoader.GetString("OK")
|
||||
};
|
||||
await dialogService.ShowAsync(dialog);
|
||||
SettingsService.Instance.Reset();
|
||||
SettingsService.Default.Value.Reset();
|
||||
navigationService.Navigate(PageToken.Login.ToString(), null);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace NextcloudApp.Services
|
|||
|
||||
private void SortList()
|
||||
{
|
||||
switch (SettingsService.Instance.LocalSettings.GroupMode)
|
||||
switch (SettingsService.Default.Value.LocalSettings.GroupMode)
|
||||
{
|
||||
case GroupMode.GroupByNameAscending:
|
||||
GroupByNameAscending();
|
||||
|
@ -104,7 +104,7 @@ namespace NextcloudApp.Services
|
|||
_groupedFolders.ArrangeItems(new NameSorter(SortSequence.Asc), x => x.Name.First().ToString().ToUpper());
|
||||
FirePropertyChangedFilesAndFolders();
|
||||
IsSorting = false;
|
||||
SettingsService.Instance.LocalSettings.GroupMode = GroupMode.GroupByNameAscending;
|
||||
SettingsService.Default.Value.LocalSettings.GroupMode = GroupMode.GroupByNameAscending;
|
||||
}
|
||||
|
||||
public void GroupByNameDescending()
|
||||
|
@ -114,7 +114,7 @@ namespace NextcloudApp.Services
|
|||
_groupedFolders.ArrangeItems(new NameSorter(SortSequence.Desc), x => x.Name.First().ToString().ToUpper());
|
||||
FirePropertyChangedFilesAndFolders();
|
||||
IsSorting = false;
|
||||
SettingsService.Instance.LocalSettings.GroupMode = GroupMode.GroupByNameDescending;
|
||||
SettingsService.Default.Value.LocalSettings.GroupMode = GroupMode.GroupByNameDescending;
|
||||
}
|
||||
|
||||
public void GroupByDateAscending()
|
||||
|
@ -124,7 +124,7 @@ namespace NextcloudApp.Services
|
|||
_groupedFolders.ArrangeItems(new DateSorter(SortSequence.Asc), x => x.LastModified.ToString(CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern));
|
||||
FirePropertyChangedFilesAndFolders();
|
||||
IsSorting = false;
|
||||
SettingsService.Instance.LocalSettings.GroupMode = GroupMode.GroupByDateAscending;
|
||||
SettingsService.Default.Value.LocalSettings.GroupMode = GroupMode.GroupByDateAscending;
|
||||
}
|
||||
|
||||
public void GroupByDateDescending()
|
||||
|
@ -134,7 +134,7 @@ namespace NextcloudApp.Services
|
|||
_groupedFolders.ArrangeItems(new DateSorter(SortSequence.Desc), x => x.LastModified.ToString(CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern));
|
||||
FirePropertyChangedFilesAndFolders();
|
||||
IsSorting = false;
|
||||
SettingsService.Instance.LocalSettings.GroupMode = GroupMode.GroupByDateDescending;
|
||||
SettingsService.Default.Value.LocalSettings.GroupMode = GroupMode.GroupByDateDescending;
|
||||
}
|
||||
|
||||
public void GroupBySizeAscending()
|
||||
|
@ -144,7 +144,7 @@ namespace NextcloudApp.Services
|
|||
_groupedFolders.ArrangeItems(new SizeSorter(SortSequence.Asc), GetSizeHeader);
|
||||
FirePropertyChangedFilesAndFolders();
|
||||
IsSorting = false;
|
||||
SettingsService.Instance.LocalSettings.GroupMode = GroupMode.GroupBySizeAscending;
|
||||
SettingsService.Default.Value.LocalSettings.GroupMode = GroupMode.GroupBySizeAscending;
|
||||
}
|
||||
|
||||
public void GroupBySizeDescending()
|
||||
|
@ -154,7 +154,7 @@ namespace NextcloudApp.Services
|
|||
_groupedFolders.ArrangeItems(new SizeSorter(SortSequence.Desc), GetSizeHeader);
|
||||
FirePropertyChangedFilesAndFolders();
|
||||
IsSorting = false;
|
||||
SettingsService.Instance.LocalSettings.GroupMode = GroupMode.GroupBySizeDescending;
|
||||
SettingsService.Default.Value.LocalSettings.GroupMode = GroupMode.GroupBySizeDescending;
|
||||
}
|
||||
|
||||
public void GroupByTypeAscending()
|
||||
|
@ -164,7 +164,7 @@ namespace NextcloudApp.Services
|
|||
_groupedFolders.ArrangeItems(new NameSorter(SortSequence.Asc), x => x.ContentType);
|
||||
FirePropertyChangedFilesAndFolders();
|
||||
IsSorting = false;
|
||||
SettingsService.Instance.LocalSettings.GroupMode = GroupMode.GroupByTypeAscending;
|
||||
SettingsService.Default.Value.LocalSettings.GroupMode = GroupMode.GroupByTypeAscending;
|
||||
}
|
||||
|
||||
public void GroupByTypeDescending()
|
||||
|
@ -174,7 +174,7 @@ namespace NextcloudApp.Services
|
|||
_groupedFolders.ArrangeItems(new NameSorter(SortSequence.Desc), x => x.ContentType);
|
||||
FirePropertyChangedFilesAndFolders();
|
||||
IsSorting = false;
|
||||
SettingsService.Instance.LocalSettings.GroupMode = GroupMode.GroupByTypeDescending;
|
||||
SettingsService.Default.Value.LocalSettings.GroupMode = GroupMode.GroupByTypeDescending;
|
||||
}
|
||||
|
||||
public void ToggleSelectionMode()
|
||||
|
@ -299,7 +299,7 @@ namespace NextcloudApp.Services
|
|||
}
|
||||
}
|
||||
|
||||
switch (SettingsService.Instance.LocalSettings.PreviewImageDownloadMode)
|
||||
switch (SettingsService.Default.Value.LocalSettings.PreviewImageDownloadMode)
|
||||
{
|
||||
case PreviewImageDownloadMode.Always:
|
||||
DownloadPreviewImages();
|
||||
|
|
|
@ -97,11 +97,11 @@ namespace NextcloudApp.Services
|
|||
}
|
||||
|
||||
stringBuilder.AppendFormat("[AppTotalRuns]:[{0}]",
|
||||
SettingsService.Instance.LocalSettings.AppTotalRuns);
|
||||
SettingsService.Default.Value.LocalSettings.AppTotalRuns);
|
||||
stringBuilder.AppendLine();
|
||||
|
||||
stringBuilder.AppendFormat("[AppRunsAfterLastUpdate]:[{0}]",
|
||||
SettingsService.Instance.LocalSettings.AppRunsAfterLastUpdate);
|
||||
SettingsService.Default.Value.LocalSettings.AppRunsAfterLastUpdate);
|
||||
stringBuilder.AppendLine();
|
||||
|
||||
stringBuilder.Append(
|
||||
|
|
|
@ -22,8 +22,8 @@ namespace NextcloudApp.Services
|
|||
}
|
||||
var vault = new PasswordVault();
|
||||
vault.Add(new PasswordCredential(
|
||||
SettingsService.Instance.LocalSettings.ServerAddress,
|
||||
SettingsService.Instance.LocalSettings.Username,
|
||||
SettingsService.Default.Value.LocalSettings.ServerAddress,
|
||||
SettingsService.Default.Value.LocalSettings.Username,
|
||||
(string)localSettings.Values["Password"]
|
||||
));
|
||||
localSettings.Values.Remove("Password");
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using NextcloudApp.Models;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using NextcloudApp.Models;
|
||||
using Windows.Security.Credentials;
|
||||
|
||||
namespace NextcloudApp.Services
|
||||
|
@ -8,25 +10,17 @@ namespace NextcloudApp.Services
|
|||
/// </summary>
|
||||
public class SettingsService
|
||||
{
|
||||
private static SettingsService _instance;
|
||||
|
||||
public static SettingsService Instance => _instance ?? (_instance = new SettingsService());
|
||||
public static Lazy<SettingsService> Default = new Lazy<SettingsService>(() => new SettingsService(), LazyThreadSafetyMode.ExecutionAndPublication);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the settings which are stored on the local device only.
|
||||
/// </summary>
|
||||
public LocalSettings LocalSettings
|
||||
{
|
||||
get;
|
||||
} = new LocalSettings();
|
||||
public LocalSettings LocalSettings => LocalSettings.Default.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the settings which are stored in the roaming profile and are synchronized between devices.
|
||||
/// </summary>
|
||||
public RoamingSettings RoamingSettings
|
||||
{
|
||||
get;
|
||||
} = new RoamingSettings();
|
||||
public RoamingSettings RoamingSettings => RoamingSettings.Default.Value;
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
|
@ -44,5 +38,18 @@ namespace NextcloudApp.Services
|
|||
// afiedler: We should ask the user if he also wants to reset the roaming settings
|
||||
//TODO
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposeds this instance.
|
||||
/// </summary>
|
||||
public void Disposed()
|
||||
{
|
||||
LocalSettings.Dispose();
|
||||
RoamingSettings.Dispose();
|
||||
if (Default.IsValueCreated)
|
||||
{
|
||||
Default = new Lazy<SettingsService>(() => new SettingsService(), LazyThreadSafetyMode.ExecutionAndPublication);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace NextcloudApp.Services
|
|||
}
|
||||
var statusBar = StatusBar.GetForCurrentView();
|
||||
statusBar.BackgroundOpacity = 1;
|
||||
var theme = SettingsService.Instance.RoamingSettings.Theme;
|
||||
var theme = SettingsService.Default.Value.RoamingSettings.Theme;
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Dark:
|
||||
|
@ -33,7 +33,7 @@ namespace NextcloudApp.Services
|
|||
break;
|
||||
}
|
||||
|
||||
SettingsService.Instance.RoamingSettings.PropertyChanged += RoamingSettingsOnPropertyChanged;
|
||||
SettingsService.Default.Value.RoamingSettings.PropertyChanged += RoamingSettingsOnPropertyChanged;
|
||||
}
|
||||
|
||||
private void RoamingSettingsOnPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
|
@ -44,7 +44,7 @@ namespace NextcloudApp.Services
|
|||
}
|
||||
var statusBar = StatusBar.GetForCurrentView();
|
||||
statusBar.BackgroundOpacity = 1;
|
||||
var theme = SettingsService.Instance.RoamingSettings.Theme;
|
||||
var theme = SettingsService.Default.Value.RoamingSettings.Theme;
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Dark:
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace NextcloudApp.Services
|
|||
/// </summary>
|
||||
public static void NotifyUser(Grid updateDialogContainer, ContentControl updateDialogTitle, TextBlock updateDialogContent, Button updateDialogButton1, Button updateDialogButton2)
|
||||
{
|
||||
SettingsService.Instance.LocalSettings.ShowUpdateMessage = false;
|
||||
SettingsService.Default.Value.LocalSettings.ShowUpdateMessage = false;
|
||||
|
||||
var app = Application.Current as App;
|
||||
if (app == null)
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace NextcloudApp.ViewModels
|
|||
/**
|
||||
* Contains the User Settings ie. Server-Address and Username
|
||||
*/
|
||||
Settings = SettingsService.Instance.LocalSettings;
|
||||
Settings = SettingsService.Default.Value.LocalSettings;
|
||||
|
||||
GroupByNameAscendingCommand = new DelegateCommand(() =>
|
||||
{
|
||||
|
|
|
@ -121,7 +121,7 @@ namespace NextcloudApp.ViewModels
|
|||
return;
|
||||
}
|
||||
|
||||
switch (SettingsService.Instance.LocalSettings.PreviewImageDownloadMode)
|
||||
switch (SettingsService.Default.Value.LocalSettings.PreviewImageDownloadMode)
|
||||
{
|
||||
case PreviewImageDownloadMode.Always:
|
||||
break;
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace NextcloudApp.ViewModels
|
|||
// _navigationService = navigationService;
|
||||
// _resourceLoader = resourceLoader;
|
||||
// _dialogService = dialogService;
|
||||
// Settings = SettingsService.Instance.LocalSettings;
|
||||
// Settings = SettingsService.Default.Value.LocalSettings;
|
||||
// GroupByNameAscendingCommand = new DelegateCommand(() =>
|
||||
// {
|
||||
// Directory.GroupByNameAscending();
|
||||
|
|
|
@ -193,8 +193,8 @@ namespace NextcloudApp.ViewModels
|
|||
return;
|
||||
}
|
||||
|
||||
SettingsService.Instance.LocalSettings.ServerAddress = ServerAddress;
|
||||
SettingsService.Instance.LocalSettings.Username = Username;
|
||||
SettingsService.Default.Value.LocalSettings.ServerAddress = ServerAddress;
|
||||
SettingsService.Default.Value.LocalSettings.Username = Username;
|
||||
|
||||
var vault = new PasswordVault();
|
||||
vault.Add(new PasswordCredential(ServerAddress, Username, Password));
|
||||
|
@ -257,7 +257,7 @@ namespace NextcloudApp.ViewModels
|
|||
return false;
|
||||
}
|
||||
|
||||
if (SettingsService.Instance.LocalSettings.IgnoreServerCertificateErrors)
|
||||
if (SettingsService.Default.Value.LocalSettings.IgnoreServerCertificateErrors)
|
||||
{
|
||||
var response = await NextcloudClient.NextcloudClient.GetServerStatus(ServerAddress, true);
|
||||
if (response == null)
|
||||
|
@ -289,7 +289,7 @@ namespace NextcloudApp.ViewModels
|
|||
|
||||
private void IgnoreServerCertificateErrors()
|
||||
{
|
||||
SettingsService.Instance.LocalSettings.IgnoreServerCertificateErrors = true;
|
||||
SettingsService.Default.Value.LocalSettings.IgnoreServerCertificateErrors = true;
|
||||
}
|
||||
|
||||
private async Task ShowServerAddressNotFoundMessage()
|
||||
|
@ -328,7 +328,7 @@ namespace NextcloudApp.ViewModels
|
|||
{
|
||||
try
|
||||
{
|
||||
var status = await NextcloudClient.NextcloudClient.GetServerStatus(ServerAddress, SettingsService.Instance.LocalSettings.IgnoreServerCertificateErrors);
|
||||
var status = await NextcloudClient.NextcloudClient.GetServerStatus(ServerAddress, SettingsService.Default.Value.LocalSettings.IgnoreServerCertificateErrors);
|
||||
if (status == null)
|
||||
{
|
||||
await ShowServerAddressNotFoundMessage();
|
||||
|
@ -379,7 +379,7 @@ namespace NextcloudApp.ViewModels
|
|||
{
|
||||
try
|
||||
{
|
||||
return await NextcloudClient.NextcloudClient.CheckUserLogin(ServerAddress, Username, Password, SettingsService.Instance.LocalSettings.IgnoreServerCertificateErrors);
|
||||
return await NextcloudClient.NextcloudClient.CheckUserLogin(ServerAddress, Username, Password, SettingsService.Default.Value.LocalSettings.IgnoreServerCertificateErrors);
|
||||
}
|
||||
catch (ResponseError)
|
||||
{
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace NextcloudApp.ViewModels
|
|||
},
|
||||
};
|
||||
|
||||
SettingsService.Instance.LocalSettings.PropertyChanged += (sender, args) =>
|
||||
SettingsService.Default.Value.LocalSettings.PropertyChanged += (sender, args) =>
|
||||
{
|
||||
GetUserInformation();
|
||||
};
|
||||
|
@ -142,7 +142,7 @@ namespace NextcloudApp.ViewModels
|
|||
return;
|
||||
}
|
||||
|
||||
var username = SettingsService.Instance.LocalSettings.Username;
|
||||
var username = SettingsService.Default.Value.LocalSettings.Username;
|
||||
|
||||
if (string.IsNullOrEmpty(username))
|
||||
return;
|
||||
|
@ -157,7 +157,7 @@ namespace NextcloudApp.ViewModels
|
|||
converter.Convert(User.Quota.Total, typeof(string), null, CultureInfo.CurrentCulture.ToString())
|
||||
);
|
||||
|
||||
switch (SettingsService.Instance.LocalSettings.PreviewImageDownloadMode)
|
||||
switch (SettingsService.Default.Value.LocalSettings.PreviewImageDownloadMode)
|
||||
{
|
||||
case PreviewImageDownloadMode.Always:
|
||||
UserAvatarUrl = await client.GetUserAvatarUrl(username, 120);
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace NextcloudApp.ViewModels
|
|||
_navigationService = navigationService;
|
||||
_resourceLoader = resourceLoader;
|
||||
_dialogService = dialogService;
|
||||
Settings = SettingsService.Instance.LocalSettings;
|
||||
Settings = SettingsService.Default.Value.LocalSettings;
|
||||
|
||||
GroupByNameAscendingCommand = new DelegateCommand(() =>
|
||||
{
|
||||
|
|
|
@ -36,8 +36,8 @@ namespace NextcloudApp.ViewModels
|
|||
_navigationService = navigationService;
|
||||
_resourceLoader = resourceLoader;
|
||||
_dialogService = dialogService;
|
||||
SettingsLocal = SettingsService.Instance.LocalSettings;
|
||||
SettingsRoaming = SettingsService.Instance.RoamingSettings;
|
||||
SettingsLocal = SettingsService.Default.Value.LocalSettings;
|
||||
SettingsRoaming = SettingsService.Default.Value.RoamingSettings;
|
||||
|
||||
UseWindowsHello = SettingsLocal.UseWindowsHello;
|
||||
IgnoreServerCertificateErrors = SettingsLocal.IgnoreServerCertificateErrors;
|
||||
|
@ -55,7 +55,7 @@ namespace NextcloudApp.ViewModels
|
|||
|
||||
private async void GetServerVersion()
|
||||
{
|
||||
var status = await NextcloudClient.NextcloudClient.GetServerStatus(SettingsLocal.ServerAddress, SettingsService.Instance.LocalSettings.IgnoreServerCertificateErrors);
|
||||
var status = await NextcloudClient.NextcloudClient.GetServerStatus(SettingsLocal.ServerAddress, SettingsService.Default.Value.LocalSettings.IgnoreServerCertificateErrors);
|
||||
|
||||
if (!string.IsNullOrEmpty(status.VersionString))
|
||||
{
|
||||
|
@ -193,7 +193,7 @@ namespace NextcloudApp.ViewModels
|
|||
return;
|
||||
}
|
||||
|
||||
SettingsService.Instance.Reset();
|
||||
SettingsService.Default.Value.Reset();
|
||||
SyncDbUtils.Reset();
|
||||
_navigationService.Navigate(PageToken.Login.ToString(), null);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace NextcloudApp.ViewModels
|
|||
_navigationService = navigationService;
|
||||
_resourceLoader = resourceLoader;
|
||||
_dialogService = dialogService;
|
||||
Settings = SettingsService.Instance.LocalSettings;
|
||||
Settings = SettingsService.Default.Value.LocalSettings;
|
||||
GroupByNameAscendingCommand = new DelegateCommand(() =>
|
||||
{
|
||||
Directory.GroupByNameAscending();
|
||||
|
|
Загрузка…
Ссылка в новой задаче