Skip to content

Commit

Permalink
rebased feature/reduce-mem-footprint
Browse files Browse the repository at this point in the history
  • Loading branch information
hosy committed Sep 12, 2024
1 parent e31eba8 commit 86f97a6
Show file tree
Hide file tree
Showing 169 changed files with 1,313 additions and 5,361 deletions.
2 changes: 2 additions & 0 deletions ownCloud Action Extension/InfoPlist.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"sourceLanguage" : "en",
"strings" : {
"CFBundleDisplayName" : {
"comment" : "Bundle display name",
"extractionState" : "extracted_with_value",
"localizations" : {
"de" : {
"stringUnit" : {
Expand Down
2 changes: 1 addition & 1 deletion ownCloud File Provider UI/CancelLabelViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CancelLabelViewController: UIViewController {
label.apply(css: collection.css, properties: [.stroke])

self.label.text = message
self.button.setTitle(buttonLabel ?? "Cancel".localized, for: .normal)
self.button.setTitle(buttonLabel ?? OCLocalizedString("Cancel", nil), for: .normal)
}

@IBAction func cancelScreen() {
Expand Down
20 changes: 10 additions & 10 deletions ownCloud File Provider UI/DocumentActionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ class DocumentActionViewController: FPUIActionExtensionViewController {

prepareNavigationController()

showMessage(with: "Connecting…".localized)
showMessage(with: OCLocalizedString("Connecting…", nil))

var actionTypeLabel = ""
var actionExtensionType : ActionExtensionType = .undefined
if actionIdentifier == "com.owncloud.FileProviderUI.Share" {
actionExtensionType = .sharing
actionTypeLabel = "Share".localized
actionTypeLabel = OCLocalizedString("Share", nil)
}

OCCoreManager.shared.requestCoreForBookmarkWithItem(withLocalID: identifier.rawValue, setup: nil) { [weak self] (error, core, databaseItem) in
Expand All @@ -139,7 +139,7 @@ class DocumentActionViewController: FPUIActionExtensionViewController {

OnMainThread {
if actionExtensionType == .sharing, core.connection.capabilities?.sharingAPIEnabled == false || item.isShareable == false {
self.showMessage(with: String(format: "%@ is not available for this item.".localized, actionTypeLabel))
self.showMessage(with: String(format: OCLocalizedString("%@ is not available for this item.", nil), actionTypeLabel))
} else if core.connectionStatus == .online {
self.coreConnectionStatusObservation?.invalidate()
self.coreConnectionStatusObservation = nil
Expand All @@ -157,18 +157,18 @@ class DocumentActionViewController: FPUIActionExtensionViewController {
}
} else if core.connectionStatus == .connecting {
triedConnecting = true
self.showMessage(with: "Connecting…".localized)
self.showMessage(with: OCLocalizedString("Connecting…", nil))
} else if core.connectionStatus == .offline || core.connectionStatus == .unavailable {
// Display error if `.connecting` isn't reached within 2 seconds
OnMainThread(after: 2) {
if !triedConnecting {
self.showMessage(with: String(format: "%@ is not available, when this account is offline. Please open the app and log into your account before you can do this action.".localized, actionTypeLabel))
self.showMessage(with: String(format: OCLocalizedString("%@ is not available, when this account is offline. Please open the app and log into your account before you can do this action.", nil), actionTypeLabel))
}
}

// Display error if `.connecting` has already been reached
if triedConnecting {
self.showMessage(with: String(format: "%@ is not available, when this account is offline. Please open the app and log into your account before you can do this action.".localized, actionTypeLabel))
self.showMessage(with: String(format: OCLocalizedString("%@ is not available, when this account is offline. Please open the app and log into your account before you can do this action.", nil), actionTypeLabel))
}
}
}
Expand All @@ -180,13 +180,13 @@ class DocumentActionViewController: FPUIActionExtensionViewController {
override func prepare(forError error: Error) {
if !OCFileProviderSettings.browseable {
prepareNavigationController()
showMessage(with: "File Provider access has been disabled by the administrator.\n\nPlease use the app to access your files.".localized)
showMessage(with: OCLocalizedString("File Provider access has been disabled by the administrator.\n\nPlease use the app to access your files.", nil))
return
}

if OCBookmarkManager.shared.bookmarks.count == 0 {
prepareNavigationController()
showMessage(with: "No account has been set up in the {{app.name}} app yet.".localized, buttonLabel: "Open app".localized, action: { [weak self] in
showMessage(with: OCLocalizedString("No account has been set up in the {{app.name}} app yet.", nil), buttonLabel: OCLocalizedString("Open app", nil), action: { [weak self] in
if let appURLScheme = OCAppIdentity.shared.appURLSchemes?.first {
self?.extensionContext.open(URL(string: "\(appURLScheme)://fp-no-account")!)
}
Expand All @@ -197,7 +197,7 @@ class DocumentActionViewController: FPUIActionExtensionViewController {

if AppLockManager.supportedOnDevice {
AppLockManager.shared.passwordViewHostViewController = self
AppLockManager.shared.biometricCancelLabel = "Cancel".localized
AppLockManager.shared.biometricCancelLabel = OCLocalizedString("Cancel", nil)
AppLockManager.shared.cancelAction = { [weak self] in
self?.complete(cancelWith: NSError(domain: FPUIErrorDomain, code: Int(FPUIExtensionErrorCode.userCancelled.rawValue), userInfo: nil))
}
Expand All @@ -208,7 +208,7 @@ class DocumentActionViewController: FPUIActionExtensionViewController {
AppLockManager.shared.showLockscreenIfNeeded()
} else {
prepareNavigationController()
showMessage(with: "Passcode protection is not supported on this device.\nPlease disable passcode lock in the app settings.".localized)
showMessage(with: OCLocalizedString("Passcode protection is not supported on this device.\nPlease disable passcode lock in the app settings.", nil))
}
}

Expand Down
1 change: 1 addition & 0 deletions ownCloud File Provider/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
}
},
"Log into your account in the app for more details." : {
"extractionState" : "stale",
"localizations" : {
"en" : {
"stringUnit" : {
Expand Down
2 changes: 2 additions & 0 deletions ownCloud Share Extension/InfoPlist.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"sourceLanguage" : "en",
"strings" : {
"CFBundleDisplayName" : {
"comment" : "Bundle display name",
"extractionState" : "extracted_with_value",
"localizations" : {
"ar" : {
"stringUnit" : {
Expand Down
32 changes: 16 additions & 16 deletions ownCloud Share Extension/ShareExtensionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class ShareExtensionViewController: EmbeddingViewController, Themeable {
}

func showLocationPicker() {
let locationPicker = ClientLocationPicker(location: .accounts, selectButtonTitle: "Save here".localized, avoidConflictsWith: nil, choiceHandler: { [weak self] folderItem, folderLocation, _, cancelled in
let locationPicker = ClientLocationPicker(location: .accounts, selectButtonTitle: OCLocalizedString("Save here", nil), avoidConflictsWith: nil, choiceHandler: { [weak self] folderItem, folderLocation, _, cancelled in
if cancelled {
self?.cancel()
return
Expand All @@ -103,7 +103,7 @@ class ShareExtensionViewController: EmbeddingViewController, Themeable {
if let targetFolder = selectedFolder, let bookmarkUUID = targetFolder.bookmarkUUID ?? location?.bookmarkUUID?.uuidString {
if let bookmark = OCBookmarkManager.shared.bookmark(forUUIDString: bookmarkUUID) {
OnMainThread {
self.progressViewController = ProgressIndicatorViewController(initialProgressLabel: "Preparing…".localized, progress: nil, cancelHandler: { [weak self] in
self.progressViewController = ProgressIndicatorViewController(initialProgressLabel: OCLocalizedString("Preparing…", nil), progress: nil, cancelHandler: { [weak self] in
self?.uploadCoreProgress?.cancel() // Cancel transfers (!) via Progress instances provided by upload methods
self?.cancel()
})
Expand Down Expand Up @@ -172,15 +172,15 @@ class ShareExtensionViewController: EmbeddingViewController, Themeable {

OnMainThread {
importProgress.completedUnitCount = importedItems
totalProgress.localizedDescription = NSString(format: "Importing item %ld of %ld".localized as NSString, importedItems, totalItems) as String
totalProgress.localizedDescription = NSString(format: OCLocalizedString("Importing item %ld of %ld", nil) as NSString, importedItems, totalItems) as String
// self.progressViewController?.update(text: NSString(format: "Importing item %ld of %ld".localized as NSString, importedItems, totalItems) as String)
}
}

let updateUploadMessage = {
OnMainThread {
if importedItems == totalItems {
totalProgress.localizedDescription = "Uploading {{remainingFileCount}} files…".localized(["remainingFileCount" : "\(totalItems - uploadedItems)"])
totalProgress.localizedDescription = OCLocalizedFormat("Uploading {{remainingFileCount}} files…", ["remainingFileCount" : "\(totalItems - uploadedItems)"])
}
}
}
Expand Down Expand Up @@ -217,7 +217,7 @@ class ShareExtensionViewController: EmbeddingViewController, Themeable {
type = "public.file-url"
}

let suggestedTextFileName = attachment.suggestedName ?? "Text".localized
let suggestedTextFileName = attachment.suggestedName ?? OCLocalizedString("Text", nil)

attachment.loadItem(forTypeIdentifier: type, options: nil, completionHandler: { (item, error) -> Void in
if error == nil {
Expand Down Expand Up @@ -262,7 +262,7 @@ class ShareExtensionViewController: EmbeddingViewController, Themeable {
} else if let error {
Log.error("Error loading item: \(String(describing: error))")

self.showAlert(title: "Error loading item".localized, error: error, decisionHandler: { [weak self] (doContinue) in
self.showAlert(title: OCLocalizedString("Error loading item", nil), error: error, decisionHandler: { [weak self] (doContinue) in
if !doContinue {
self?.cancel()
}
Expand Down Expand Up @@ -294,7 +294,7 @@ class ShareExtensionViewController: EmbeddingViewController, Themeable {
} else if let error {
Log.error("Error loading item: \(String(describing: error))")

self.showAlert(title: "Error loading item".localized, error: error, decisionHandler: { [weak self] (doContinue) in
self.showAlert(title: OCLocalizedString("Error loading item", nil), error: error, decisionHandler: { [weak self] (doContinue) in
if !doContinue {
self?.cancel()
}
Expand All @@ -318,8 +318,8 @@ class ShareExtensionViewController: EmbeddingViewController, Themeable {
}

uploadWaitGroup.notify(queue: .main, execute: {
self.finish(with: ((self.progressViewController?.cancelled ?? false) ? NSError(ocError: .cancelled) : uploadError))
jobDone()
self.finish(with: ((self.progressViewController?.cancelled ?? false) ? NSError(ocError: .cancelled) : uploadError))
jobDone()
})
})
}
Expand All @@ -337,7 +337,7 @@ class ShareExtensionViewController: EmbeddingViewController, Themeable {
if let error {
Log.error("Error importing item at \(sourceURL) through share extension: \(String(describing: error))")

self?.showAlert(title: NSString(format: "Error importing %@".localized as NSString, sourceURL.lastPathComponent) as String, error: error, decisionHandler: { [weak self] (doContinue) in
self?.showAlert(title: NSString(format: OCLocalizedString("Error importing %@", nil) as NSString, sourceURL.lastPathComponent) as String, error: error, decisionHandler: { [weak self] (doContinue) in
if !doContinue {
completionHandler(error)
self?.progressViewController?.cancel()
Expand Down Expand Up @@ -381,19 +381,19 @@ class ShareExtensionViewController: EmbeddingViewController, Themeable {
// Check for show stoppers
if !Branding.shared.isImportMethodAllowed(.shareExtension) {
// Share extension disabled, alert user
showErrorMessage(title: "Share Extension disabled".localized, message: "Importing files through the Share Extension is not allowed on this device.".localized)
showErrorMessage(title: OCLocalizedString("Share Extension disabled", nil), message: OCLocalizedString("Importing files through the Share Extension is not allowed on this device.", nil))
return
}

if !OCVault.hostHasFileProvider {
// No file provider -> share extension unavailable
showErrorMessage(title: "Share Extension unavailable".localized, message: "The {{app.name}} share extension is not available on this system.".localized)
showErrorMessage(title: OCLocalizedString("Share Extension unavailable", nil), message: OCLocalizedString("The {{app.name}} share extension is not available on this system.", nil))
return
}

if OCBookmarkManager.shared.bookmarks.count == 0 {
// No account configured
showErrorMessage(title: "No account configured".localized, message: "Setup a new account in the app to save to.".localized)
showErrorMessage(title: OCLocalizedString("No account configured", nil), message: OCLocalizedString("Setup a new account in the app to save to.", nil))
return
}

Expand Down Expand Up @@ -438,7 +438,7 @@ class ShareExtensionViewController: EmbeddingViewController, Themeable {
.spacing(5),
.subtitle(message, alignment: .centered),
.spacing(15),
.button("OK".localized, action: UIAction(handler: { [weak self] action in
.button(OCLocalizedString("OK", nil), action: UIAction(handler: { [weak self] action in
self?.cancel()
}))
])
Expand All @@ -452,14 +452,14 @@ class ShareExtensionViewController: EmbeddingViewController, Themeable {
let message = message ?? ((error != nil) ? error?.localizedDescription : nil)
let alert = ThemedAlertController(title: title, message: message, preferredStyle: .alert)

alert.addAction(UIAlertAction(title: "Cancel".localized, style: .cancel, handler: { (_) in
alert.addAction(UIAlertAction(title: OCLocalizedString("Cancel", nil), style: .cancel, handler: { (_) in
decisionHandler(false)
}))

if let nsError = error as NSError?, nsError.domain == NSCocoaErrorDomain, nsError.code == NSXPCConnectionInvalid || nsError.code == NSXPCConnectionInterrupted {
Log.error("XPC connection error: \(String(describing: error))")
} else {
alert.addAction(UIAlertAction(title: "Continue".localized, style: .default, handler: { (_) in
alert.addAction(UIAlertAction(title: OCLocalizedString("Continue", nil), style: .default, handler: { (_) in
decisionHandler(true)
}))
}
Expand Down
Loading

0 comments on commit 86f97a6

Please sign in to comment.