Import downloaded resources into provider cache
Show message in HUD while extracting files
This commit is contained in:
parent
35605ba89f
commit
8203bc99f8
|
@ -40,12 +40,13 @@ import MBProgressHUD
|
|||
class HUD {
|
||||
private let backend: MBProgressHUD
|
||||
|
||||
init() {
|
||||
init(label: String? = nil) {
|
||||
guard let window = UIApplication.shared.windows.first else {
|
||||
fatalError("Could not locate front window?")
|
||||
}
|
||||
|
||||
backend = MBProgressHUD.showAdded(to: window, animated: true)
|
||||
backend.label.text = label
|
||||
backend.backgroundView.backgroundColor = UIColor(white: 0.0, alpha: 0.6)
|
||||
backend.mode = .indeterminate
|
||||
backend.removeFromSuperViewOnHide = true
|
||||
|
|
|
@ -468,7 +468,25 @@ class ServiceViewController: UIViewController, TableModelHost {
|
|||
|
||||
private func confirmDownload(_ url: URL) {
|
||||
_ = Downloader.shared.download(url: url, in: view) { (url, error) in
|
||||
// FIXME: handle downloaded resource into current infrastructure
|
||||
self.handleDownloadedProviderResources(url: url, error: error)
|
||||
}
|
||||
}
|
||||
|
||||
private func handleDownloadedProviderResources(url: URL?, error: Error?) {
|
||||
guard let url = url else {
|
||||
let alert = Macros.alert(
|
||||
L10n.Service.Alerts.Download.title,
|
||||
L10n.Service.Alerts.Download.failed(error?.localizedDescription ?? "")
|
||||
)
|
||||
alert.addCancelAction(L10n.Global.ok)
|
||||
present(alert, animated: true, completion: nil)
|
||||
return
|
||||
}
|
||||
|
||||
let hud = HUD(label: L10n.Service.Alerts.Download.Hud.extracting)
|
||||
hud.show()
|
||||
uncheckedProviderProfile.name.importExternalResources(from: url) {
|
||||
hud.hide()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -134,6 +134,8 @@
|
|||
"service.alerts.buttons.reconnect" = "Reconnect";
|
||||
"service.alerts.download.title" = "Download required";
|
||||
"service.alerts.download.message" = "%@ requires the download of additional configuration files.\n\nConfirm to start the download.";
|
||||
"service.alerts.download.failed" = "Failed to download configuration files. %@";
|
||||
"service.alerts.download.hud.extracting" = "Extracting files, please be patient...";
|
||||
|
||||
"account.sections.credentials.header" = "Credentials";
|
||||
"account.sections.guidance.footer.infrastructure.mullvad" = "Use your %@ website account number and password \"m\".";
|
||||
|
|
|
@ -594,12 +594,20 @@ public enum L10n {
|
|||
}
|
||||
}
|
||||
public enum Download {
|
||||
/// Failed to download configuration files. %@
|
||||
public static func failed(_ p1: String) -> String {
|
||||
return L10n.tr("Localizable", "service.alerts.download.failed", p1)
|
||||
}
|
||||
/// %@ requires the download of additional configuration files.\n\nConfirm to start the download.
|
||||
public static func message(_ p1: String) -> String {
|
||||
return L10n.tr("Localizable", "service.alerts.download.message", p1)
|
||||
}
|
||||
/// Download required
|
||||
public static let title = L10n.tr("Localizable", "service.alerts.download.title")
|
||||
public enum Hud {
|
||||
/// Extracting files, please be patient...
|
||||
public static let extracting = L10n.tr("Localizable", "service.alerts.download.hud.extracting")
|
||||
}
|
||||
}
|
||||
public enum MasksPrivateData {
|
||||
public enum Messages {
|
||||
|
|
Loading…
Reference in New Issue