show indeterminate download, if we don't know the file size. better naming of download command
This commit is contained in:
Родитель
084120e339
Коммит
4e6c2d4ae9
|
@ -365,4 +365,10 @@ Would you like to inform the application developers and submit the prepared erro
|
|||
<data name="ServerWithGivenAddressIsNotReachable" xml:space="preserve">
|
||||
<value>The server with the address {0} is not reachable.</value>
|
||||
</data>
|
||||
<data name="DownloadAsZip.Text" xml:space="preserve">
|
||||
<value>Download as ZIP file</value>
|
||||
</data>
|
||||
<data name="DownloadingFileProgressIndeterminate" xml:space="preserve">
|
||||
<value>{0} downloaded</value>
|
||||
</data>
|
||||
</root>
|
|
@ -32,6 +32,7 @@ namespace NextcloudApp.ViewModels
|
|||
private ResourceInfo _resourceInfo;
|
||||
private string _downloadingFileProgressText;
|
||||
private StorageFile _currentFile;
|
||||
private bool _isIndeterminate;
|
||||
|
||||
public SingleFileDownloadPageViewModel(INavigationService navigationService, IResourceLoader resourceLoader)
|
||||
{
|
||||
|
@ -146,6 +147,12 @@ namespace NextcloudApp.ViewModels
|
|||
BytesDownloaded = (int)progressInfo.BytesReceived;
|
||||
});
|
||||
}
|
||||
|
||||
public bool IsIndeterminate
|
||||
{
|
||||
get { return _isIndeterminate; }
|
||||
private set { SetProperty(ref _isIndeterminate, value); }
|
||||
}
|
||||
|
||||
public int PercentageDownloaded
|
||||
{
|
||||
|
@ -191,15 +198,24 @@ namespace NextcloudApp.ViewModels
|
|||
|
||||
private void Update()
|
||||
{
|
||||
if (BytesTotal == 0)
|
||||
{
|
||||
IsIndeterminate = true;
|
||||
DownloadingFileProgressText = string.Format(
|
||||
_resourceLoader.GetString("DownloadingFileProgressIndeterminate"),
|
||||
_converter.Convert((long)BytesDownloaded, typeof(string), null, CultureInfo.CurrentCulture.ToString())
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
var percentage = (double)BytesDownloaded / BytesTotal;
|
||||
PercentageDownloaded = (int)(percentage * 100);
|
||||
|
||||
IsIndeterminate = false;
|
||||
DownloadingFileProgressText = string.Format(
|
||||
_resourceLoader.GetString("DownloadingFileProgress"),
|
||||
_converter.Convert((long)BytesDownloaded, typeof(string), null,
|
||||
CultureInfo.CurrentCulture.ToString()),
|
||||
_converter.Convert(BytesTotal, typeof(string), null,
|
||||
CultureInfo.CurrentCulture.ToString())
|
||||
_resourceLoader.GetString("DownloadingFileProgress"),
|
||||
_converter.Convert((long)BytesDownloaded, typeof(string), null, CultureInfo.CurrentCulture.ToString()),
|
||||
_converter.Convert(BytesTotal, typeof(string), null, CultureInfo.CurrentCulture.ToString())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -266,8 +266,8 @@
|
|||
Style="{StaticResource MenuFlyoutIconItemStyle}"/>
|
||||
<MenuFlyoutItem
|
||||
Tag="Download"
|
||||
x:Uid="Download"
|
||||
Text="Download"
|
||||
x:Uid="DownloadAsZip"
|
||||
Text="Download as ZIP file"
|
||||
Command="{Binding DataContext.DownloadResourceCommand, ElementName=Page}"
|
||||
CommandParameter="{Binding}"
|
||||
Style="{StaticResource MenuFlyoutIconItemStyle}"/>
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
<ProgressBar
|
||||
Minimum="0"
|
||||
Value="{Binding PercentageDownloaded}"
|
||||
Maximum="100"/>
|
||||
Maximum="100"
|
||||
IsIndeterminate="{Binding IsIndeterminate}"/>
|
||||
<TextBlock
|
||||
Text="{Binding DownloadingFileProgressText}"
|
||||
HorizontalAlignment="Right"
|
||||
|
|
Загрузка…
Ссылка в новой задаче