private string GenerateSettingKey(ConnectionType connectionType, DownloadContentType downloadContentType) { var res = ""; switch (connectionType) { case ConnectionType.Mobile: res += "Mobile"; break; case ConnectionType.Wlan: res += "Wlan"; break; case ConnectionType.None: res += "None"; break; } switch (downloadContentType) { case DownloadContentType.Any: res += "Any"; break; case DownloadContentType.Article: res += "Article"; break; case DownloadContentType.Feed: res += "Feed"; break; case DownloadContentType.Image: res += "Image"; break; } return res; }
private async Task <bool> CanDownloadAsync(DownloadContentType type) { if (_downloadBlocked) { _lastResult = false; } else if (_lastTimeRequested - DateTime.Now > TimeSpan.FromSeconds(10)) { return(_lastResult); } else { var conntype = _platformCodeService.GetConnectionType(); if (conntype == ConnectionType.None) { _lastResult = false; } else if (conntype == ConnectionType.Mobile) { if (!(bool)_platformCodeService.GetLocalSetting(AskedAtMobileConnectionKey, false)) { _platformCodeService.SetLocalSetting(AskedAtMobileConnectionKey, true); await _dialogService.ShowMessage( "Sie sind über das Mobilfunktnetz online, der Download wurde daher automatisch angehalten. Sie können diese Option in den Einstellungen wieder deaktivieren", "Datenverbindung"); } if ( !(bool) _platformCodeService.GetLocalSetting(GenerateSettingKey(conntype, DownloadContentType.Any), false)) { _lastResult = false; } _lastResult = (bool)_platformCodeService.GetLocalSetting(GenerateSettingKey(conntype, type), false); } else if (conntype == ConnectionType.Wlan) { if ( !(bool) _platformCodeService.GetLocalSetting(GenerateSettingKey(conntype, DownloadContentType.Any), true)) { _lastResult = false; } _lastResult = (bool)_platformCodeService.GetLocalSetting(GenerateSettingKey(conntype, type), true); } else { _lastResult = false; } } _lastTimeRequested = DateTime.Now; return(_lastResult); }
private string getContentType(DownloadContentType arg) { switch (arg) { case DownloadContentType.MicrosoftWord: return("application/x-msword"); case DownloadContentType.MicrosoftExcel: return("application/x-msexcel"); case DownloadContentType.PlainText: return("text/plain"); default: return("application/octet-stream"); } }
private async Task<bool> CanDownloadAsync(DownloadContentType type) { if (_downloadBlocked) _lastResult = false; else if (_lastTimeRequested - DateTime.Now > TimeSpan.FromSeconds(10)) return _lastResult; else { var conntype = _platformCodeService.GetConnectionType(); if (conntype == ConnectionType.None) _lastResult = false; else if (conntype == ConnectionType.Mobile) { if (!(bool) _platformCodeService.GetLocalSetting(AskedAtMobileConnectionKey, false)) { _platformCodeService.SetLocalSetting(AskedAtMobileConnectionKey, true); await _dialogService.ShowMessage( "Sie sind über das Mobilfunktnetz online, der Download wurde daher automatisch angehalten. Sie können diese Option in den Einstellungen wieder deaktivieren", "Datenverbindung"); } if ( !(bool) _platformCodeService.GetLocalSetting(GenerateSettingKey(conntype, DownloadContentType.Any), false)) _lastResult = false; _lastResult = (bool) _platformCodeService.GetLocalSetting(GenerateSettingKey(conntype, type), false); } else if (conntype == ConnectionType.Wlan) { if ( !(bool) _platformCodeService.GetLocalSetting(GenerateSettingKey(conntype, DownloadContentType.Any), true)) _lastResult = false; _lastResult = (bool) _platformCodeService.GetLocalSetting(GenerateSettingKey(conntype, type), true); } else { _lastResult = false; } } _lastTimeRequested = DateTime.Now; return _lastResult; }
private string GenerateSettingKey(ConnectionType connectionType, DownloadContentType downloadContentType) { var res = ""; switch (connectionType) { case ConnectionType.Mobile: res += "Mobile"; break; case ConnectionType.Wlan: res += "Wlan"; break; case ConnectionType.None: res += "None"; break; } switch (downloadContentType) { case DownloadContentType.Any: res += "Any"; break; case DownloadContentType.Article: res += "Article"; break; case DownloadContentType.Feed: res += "Feed"; break; case DownloadContentType.Image: res += "Image"; break; } return(res); }
public bool GetPermission(ConnectionType conntype, DownloadContentType type, bool fallback) { return true; }
public void SetPermission(ConnectionType conntype, DownloadContentType type, bool val) { }
public bool GetPermission(ConnectionType conntype, DownloadContentType type, bool fallback) { return(true); }
public void SetContentType(DownloadContentType argContentType) { this.contenttype = getContentType(argContentType); }
public bool GetPermission(ConnectionType conntype, DownloadContentType type, bool fallback) { return((bool)_platformCodeService.GetLocalSetting(GenerateSettingKey(conntype, type), fallback)); }
public void SetPermission(ConnectionType conntype, DownloadContentType type, bool val) { _platformCodeService.SetLocalSetting(GenerateSettingKey(conntype, type), val); PermissionsChanged?.Invoke(this, EventArgs.Empty); _lastTimeRequested = DateTime.MinValue; }
public bool GetPermission(ConnectionType conntype, DownloadContentType type, bool fallback) { return (bool)_platformCodeService.GetLocalSetting(GenerateSettingKey(conntype, type), fallback); }