Merge remote-tracking branch 'nextcloud/master'

This commit is contained in:
SunboX 2017-05-31 23:44:37 +02:00
Родитель 6c917f6f4e 9512b6b93c
Коммит 1c62df5d94
11 изменённых файлов: 144 добавлений и 100 удалений

Просмотреть файл

@ -226,17 +226,6 @@ namespace NextcloudApp
ActivatedEventArgs = args;
await base.OnActivateApplicationAsync(args);
var theme = SettingsService.Instance.RoamingSettings.Theme;
switch (theme)
{
case Theme.Dark:
RequestedTheme = ApplicationTheme.Dark;
break;
case Theme.Light:
RequestedTheme = ApplicationTheme.Light;
break;
}
// Remove unnecessary notifications whenever the app is used.
ToastNotificationManager.History.RemoveGroup(ToastNotificationService.SYNCACTION);

Просмотреть файл

@ -1,10 +1,11 @@
<Page
<controls:ThemeablePage
x:Class="NextcloudApp.AppShell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="using:NextcloudApp.Views"
xmlns:controls="using:NextcloudApp.Controls"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
@ -51,4 +52,5 @@
Style="{StaticResource SplitViewTogglePaneButtonStyle}"
TabIndex="1" />
</Grid>
</Page>
</controls:ThemeablePage>

Просмотреть файл

@ -4,7 +4,7 @@ using NextcloudApp.Services;
namespace NextcloudApp
{
public sealed partial class AppShell : Page
public sealed partial class AppShell
{
public AppShell()
{

Просмотреть файл

@ -0,0 +1,44 @@
using System.ComponentModel;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using NextcloudApp.Services;
using NextcloudApp.Utils;
namespace NextcloudApp.Controls
{
public class ThemeablePage : Page
{
public ThemeablePage()
{
var theme = SettingsService.Instance.RoamingSettings.Theme;
switch (theme)
{
case Theme.Dark:
RequestedTheme = ElementTheme.Dark;
break;
case Theme.Light:
RequestedTheme = ElementTheme.Light;
break;
}
SettingsService.Instance.RoamingSettings.PropertyChanged += RoamingSettingsOnPropertyChanged;
}
private void RoamingSettingsOnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName.Equals("Theme"))
{
var theme = SettingsService.Instance.RoamingSettings.Theme;
switch (theme)
{
case Theme.Dark:
RequestedTheme = ElementTheme.Dark;
break;
case Theme.Light:
RequestedTheme = ElementTheme.Light;
break;
}
}
}
}
}

Просмотреть файл

@ -8,17 +8,8 @@ namespace NextcloudApp.Models
/// Class for storing roaming settings which should be synchronized between devices.
/// </summary>
public class RoamingSettings : ObservableSettings
{
private static RoamingSettings settings = new RoamingSettings();
private const string DefaultValueEmptyString = "";
public static RoamingSettings Default
{
get
{
return settings;
}
}
{
public static RoamingSettings Default { get; } = new RoamingSettings();
public RoamingSettings()
: base(ApplicationData.Current.RoamingSettings)
@ -33,10 +24,7 @@ namespace NextcloudApp.Models
{
var strVal = Get<string>();
if (string.IsNullOrEmpty(strVal))
return Theme.System;
else
return JsonConvert.DeserializeObject<Theme>(strVal);
return string.IsNullOrEmpty(strVal) ? Theme.System : JsonConvert.DeserializeObject<Theme>(strVal);
}
set
{

Просмотреть файл

@ -134,6 +134,7 @@
<Compile Include="Actions\OpenMenuFlyoutAction.cs" />
<Compile Include="Behaviors\ScrollListBoxToEndBehavior.cs" />
<Compile Include="Constants\ResourceConstants.cs" />
<Compile Include="Controls\ThemeablePage.cs" />
<Compile Include="Converter\ConflictTypeToForegroundConverter.cs" />
<Compile Include="Converter\ConflictTypeToStringConverter.cs" />
<Compile Include="Converter\DateTimeToVisibilityConverter.cs" />
@ -401,7 +402,6 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Controls\" />
<Folder Include="SampleData\" />
<Folder Include="Strings\bg-BG\" />
<Folder Include="Strings\ru\" />

Просмотреть файл

@ -1,6 +1,9 @@
using System;
using System.ComponentModel;
using Windows.Foundation.Metadata;
using Windows.UI;
using Windows.UI.ViewManagement;
using NextcloudApp.Utils;
namespace NextcloudApp.Services
{
@ -9,7 +12,49 @@ namespace NextcloudApp.Services
private static StatusBarService _instance;
private int _waitCounter;
private StatusBarService() { }
private StatusBarService()
{
if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
{
var statusBar = StatusBar.GetForCurrentView();
statusBar.BackgroundOpacity = 1;
var theme = SettingsService.Instance.RoamingSettings.Theme;
switch (theme)
{
case Theme.Dark:
statusBar.BackgroundColor = Colors.Black;
statusBar.ForegroundColor = Colors.White;
break;
case Theme.Light:
statusBar.BackgroundColor = Colors.White;
statusBar.ForegroundColor = Colors.Black;
break;
}
SettingsService.Instance.RoamingSettings.PropertyChanged += RoamingSettingsOnPropertyChanged;
}
}
private void RoamingSettingsOnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName.Equals("Theme"))
{
var statusBar = StatusBar.GetForCurrentView();
statusBar.BackgroundOpacity = 1;
var theme = SettingsService.Instance.RoamingSettings.Theme;
switch (theme)
{
case Theme.Dark:
statusBar.BackgroundColor = Colors.Black;
statusBar.ForegroundColor = Colors.White;
break;
case Theme.Light:
statusBar.BackgroundColor = Colors.White;
statusBar.ForegroundColor = Colors.Black;
break;
}
}
}
public static StatusBarService Instance => _instance ?? (_instance = new StatusBarService());

Просмотреть файл

@ -132,20 +132,20 @@ namespace NextcloudApp.ViewModels
public string ServerVersion
{
get { return _serverVersion; }
private set { SetProperty(ref _serverVersion, value); }
get => _serverVersion;
private set => SetProperty(ref _serverVersion, value);
}
public LocalSettings SettingsLocal
{
get { return _settingsLocal; }
private set { SetProperty(ref _settingsLocal, value); }
get => _settingsLocal;
private set => SetProperty(ref _settingsLocal, value);
}
public RoamingSettings SettingsRoaming
{
get { return _settingsRoaming; }
private set { SetProperty(ref _settingsRoaming, value); }
get => _settingsRoaming;
private set => SetProperty(ref _settingsRoaming, value);
}
public List<PreviewImageDownloadModeItem> PreviewImageDownloadModes { get; } = new List<PreviewImageDownloadModeItem>();
@ -155,7 +155,7 @@ namespace NextcloudApp.ViewModels
public int PreviewImageDownloadModesSelectedIndex
{
get { return _previewImageDownloadModesSelectedIndex; }
get => _previewImageDownloadModesSelectedIndex;
set
{
if (!SetProperty(ref _previewImageDownloadModesSelectedIndex, value))
@ -180,7 +180,7 @@ namespace NextcloudApp.ViewModels
public int ThemeModeSelectedIndex
{
get { return _themeModesSelectedIndex; }
get => _themeModesSelectedIndex;
set
{
if (!SetProperty(ref _themeModesSelectedIndex, value))
@ -205,7 +205,7 @@ namespace NextcloudApp.ViewModels
public bool IgnoreServerCertificateErrors
{
get { return _ignoreServerCertificateErrors; }
get => _ignoreServerCertificateErrors;
set
{
if (!SetProperty(ref _ignoreServerCertificateErrors, value))
@ -235,29 +235,9 @@ namespace NextcloudApp.ViewModels
PrismUnityApplication.Current.Exit();
}
public async void ThemeChanged()
{
ClientService.Reset();
var dialog = new ContentDialog
{
Title = _resourceLoader.GetString("Hint"),
Content = new TextBlock
{
Text = _resourceLoader.GetString("AppMustBeRestarted"),
TextWrapping = TextWrapping.WrapWholeWords,
Margin = new Thickness(0, 20, 0, 0)
},
PrimaryButtonText = _resourceLoader.GetString("OK")
};
await _dialogService.ShowAsync(dialog);
PrismUnityApplication.Current.Exit();
}
public bool ExpertMode
{
get { return _expertMode; }
get => _expertMode;
set
{
if (!SetProperty(ref _expertMode, value))
@ -269,7 +249,7 @@ namespace NextcloudApp.ViewModels
public bool UseWindowsHello
{
get { return _useWindowsHello; }
get => _useWindowsHello;
set
{
if (!SetProperty(ref _useWindowsHello, value))
@ -281,28 +261,30 @@ namespace NextcloudApp.ViewModels
public async void UseWindowsHelloToggled()
{
if (UseWindowsHello)
if (!UseWindowsHello)
{
var available = await VerificationService.CheckAvailabilityAsync();
if (!available)
{
var dialog = new ContentDialog
{
Title = _resourceLoader.GetString(ResourceConstants.DialogTitle_GeneralNextCloudApp),
Content = new TextBlock
{
Text = _resourceLoader.GetString(ResourceConstants.WindowsHelloNotAvailable),
TextWrapping = TextWrapping.WrapWholeWords,
Margin = new Thickness(0, 20, 0, 0)
},
PrimaryButtonText = _resourceLoader.GetString("OK")
};
await _dialogService.ShowAsync(dialog);
UseWindowsHello = false;
}
return;
}
var available = await VerificationService.CheckAvailabilityAsync();
if (available)
{
return;
}
var dialog = new ContentDialog
{
Title = _resourceLoader.GetString(ResourceConstants.DialogTitle_GeneralNextCloudApp),
Content = new TextBlock
{
Text = _resourceLoader.GetString(ResourceConstants.WindowsHelloNotAvailable),
TextWrapping = TextWrapping.WrapWholeWords,
Margin = new Thickness(0, 20, 0, 0)
},
PrimaryButtonText = _resourceLoader.GetString("OK")
};
await _dialogService.ShowAsync(dialog);
UseWindowsHello = false;
}
public string AppVersion

Просмотреть файл

@ -506,3 +506,4 @@
</Grid>
</prismMvvm:SessionStateAwarePage>

Просмотреть файл

@ -1,8 +1,8 @@
using Prism.Windows.Mvvm;
using NextcloudApp.Controls;
namespace NextcloudApp.Views
{
public sealed partial class DirectoryListPage : SessionStateAwarePage
public sealed partial class DirectoryListPage
{
public DirectoryListPage()
{

Просмотреть файл

@ -1,17 +1,10 @@
using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
using Prism.Windows.Mvvm;
namespace NextcloudApp.Views
{
public sealed partial class SettingsPage : SessionStateAwarePage
{
public SettingsPage()
{
InitializeComponent();
namespace NextcloudApp.Views
{
public sealed partial class SettingsPage
{
public SettingsPage()
{
InitializeComponent();
}
}
}
}
}