Skip to content

Commit

Permalink
- add action.allow-image-interactions. To disable Image Interactions,…
Browse files Browse the repository at this point in the history
… set action.allow-image-interactions = false
  • Loading branch information
felix-schwarz authored and hosy committed Dec 7, 2023
1 parent 2bf4398 commit e092190
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ownCloud.xcodeproj/xcshareddata/xcschemes/ownCloud.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,11 @@
value = "string:https://www.owncloud.com/"
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
key = "oc:action.allow-image-interactions"
value = "false"
isEnabled = "NO">
</EnvironmentVariable>
</EnvironmentVariables>
<AdditionalOptions>
<AdditionalOption
Expand Down
32 changes: 30 additions & 2 deletions ownCloud/UI Elements/ImageScrollView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@

import UIKit
import VisionKit
import ownCloudSDK
import ownCloudAppShared

class ImageScrollView: UIScrollView {

// MARK: - Constants
private let MAXIMUM_ZOOM_SCALE: CGFloat = 6.0

Expand Down Expand Up @@ -117,7 +118,9 @@ extension ImageScrollView {
addSubview(imageView)
updateScaleForRotation(size: inSize)

analyzeImage(image: image)
if imageInteractionsAllowed {
analyzeImage(image: image)
}
}

var hasActiveImageAnalysisSelection: Bool {
Expand Down Expand Up @@ -171,3 +174,28 @@ extension ImageScrollView: UIScrollViewDelegate {
}

}

// MARK: - Class Settings
public extension OCClassSettingsKey {
static let allowImageInteractions = OCClassSettingsKey("allow-image-interactions")
}

extension ImageScrollView {
static func registerImageInteractionsSettings() {
Action.registerOCClassSettingsDefaults([
.allowImageInteractions : true
], metadata: [
.allowImageInteractions : [
.type : OCClassSettingsMetadataType.boolean,
.label : "Allow Image Interactions",
.description : "Allow (true) or disallow (false) text/selection/OCR interactions with images.",
.status : OCClassSettingsKeyStatus.advanced,
.category : "Actions"
]
])
}

var imageInteractionsAllowed: Bool {
return Action.classSetting(forOCClassSettingsKey: .allowImageInteractions) as? Bool ?? true
}
}

0 comments on commit e092190

Please sign in to comment.