diff --git a/src/Catty/Defines/LanguageTranslationDefines.h b/src/Catty/Defines/LanguageTranslationDefines.h
index 9a97274b4b..041a22e779 100644
--- a/src/Catty/Defines/LanguageTranslationDefines.h
+++ b/src/Catty/Defines/LanguageTranslationDefines.h
@@ -306,6 +306,7 @@
#define kLocalizedRemovedKnownBluetoothDevices NSLocalizedString(@"All known Bluetooth devices successfully removed", nil)
#define kLocalizedArduinoBricksDescription NSLocalizedString(@"Allow the app to control Arduino boards", nil)
#define kLocalizedEmbroideryBricksDescription NSLocalizedString(@"Create patterns for stiching machines", nil)
+#define kLocalizedAllowAccessToPhotos NSLocalizedString(@"Allow access to your photos", nil)
//************************************************************************************************************
//********************************** LONG DESCRIPTIONS ********************************************
@@ -343,6 +344,7 @@
#define kLocalizedNoAccesToMicrophoneCheckSettingsDescription NSLocalizedString(@"Pocket Code has no access to your microphone. To permit access, tap settings and activate microphone.", nil)
#define kLocalizedUnsupportedElementsDescription NSLocalizedString(@"Following features used in this project are not compatible with this version of Pocket Code:", nil)
#define kLocalizedAlwaysAllowWebRequestDescription NSLocalizedString(@"Be very careful before allowing access, since the link may expose your personal information, such as your precise geographical location or any text you have entered to malicious other persons or to the public. See our wiki for more information why this can be extremely dangerous. By always allowing access, you will not be asked again to confirm web addresses from this domain. If you want to revoke this permission later, you can remove the domain from the list of trusted domains in the settings of this app.", nil)
+#define kLocalizedAllowAccessToPhotosDescription NSLocalizedString(@"Pocket Code has no access to this images. To permit access, tap settings and activate images.", nil)
//************************************************************************************************************
//******************************* BRICK TITLE TRANSLATIONS ****************************************
diff --git a/src/Catty/Defines/LanguageTranslationDefinesSwift.swift b/src/Catty/Defines/LanguageTranslationDefinesSwift.swift
index a2cb9affd6..6ad26d2ccf 100644
--- a/src/Catty/Defines/LanguageTranslationDefinesSwift.swift
+++ b/src/Catty/Defines/LanguageTranslationDefinesSwift.swift
@@ -306,6 +306,7 @@ let kLocalizedDisconnectBluetoothDevices = NSLocalizedString("All Bluetooth devi
let kLocalizedRemovedKnownBluetoothDevices = NSLocalizedString("All known Bluetooth devices successfully removed", comment: "")
let kLocalizedArduinoBricksDescription = NSLocalizedString("Allow the app to control Arduino boards", comment: "")
let kLocalizedEmbroideryBricksDescription = NSLocalizedString("Create patterns for stiching machines", comment: "")
+let kLocalizedAllowAccessToPhotos = NSLocalizedString("Allow access to your photos", comment: "")
//************************************************************************************************************
//********************************** LONG DESCRIPTIONS ********************************************
@@ -343,6 +344,7 @@ let kLocalizedNoAccesToCameraCheckSettingsDescription = NSLocalizedString("Pocke
let kLocalizedNoAccesToMicrophoneCheckSettingsDescription = NSLocalizedString("Pocket Code has no access to your microphone. To permit access, tap settings and activate microphone.", comment: "")
let kLocalizedUnsupportedElementsDescription = NSLocalizedString("Following features used in this project are not compatible with this version of Pocket Code:", comment: "")
let kLocalizedAlwaysAllowWebRequestDescription = NSLocalizedString("Be very careful before allowing access, since the link may expose your personal information, such as your precise geographical location or any text you have entered to malicious other persons or to the public. See our wiki for more information why this can be extremely dangerous. By always allowing access, you will not be asked again to confirm web addresses from this domain. If you want to revoke this permission later, you can remove the domain from the list of trusted domains in the settings of this app.", comment: "")
+let kLocalizedAllowAccessToPhotosDescription = NSLocalizedString("Pocket Code has no access to this images. To permit access, tap settings and activate images.", comment: "")
//************************************************************************************************************
//******************************* BRICK TITLE TRANSLATIONS ****************************************
diff --git a/src/Catty/Resources/Localization/en.lproj/Localizable.strings b/src/Catty/Resources/Localization/en.lproj/Localizable.strings
index b20bfb5d8c..65697846dc 100644
--- a/src/Catty/Resources/Localization/en.lproj/Localizable.strings
+++ b/src/Catty/Resources/Localization/en.lproj/Localizable.strings
@@ -70,6 +70,9 @@
/* No comment provided by engineer. */
"All known Bluetooth devices successfully removed" = "All known Bluetooth devices successfully removed";
+/* No comment provided by engineer. */
+"Allow access to your photos" = "Allow access to your photos";
+
/* No comment provided by engineer. */
"Allow the app to control Arduino boards" = "Allow the app to control Arduino boards";
@@ -286,6 +289,9 @@
/* No comment provided by engineer. */
"Change color " = "Change color ";
+/* No comment provided by engineer. */
+"Change Settings to allow Pocket Code full access to this photo." = "Change Settings to allow Pocket Code full access to this photo.";
+
/* No comment provided by engineer. */
"Change size by" = "Change size by";
@@ -1465,6 +1471,9 @@
/* No comment provided by engineer. */
"Open" = "Open";
+/* No comment provided by engineer. */
+"Open Settings" = "Open Settings";
+
/* No comment provided by engineer. */
"or" = "or";
diff --git a/src/Catty/Supporting Files/App-Info.plist b/src/Catty/Supporting Files/App-Info.plist
index 65f9914185..89c8f49140 100755
--- a/src/Catty/Supporting Files/App-Info.plist
+++ b/src/Catty/Supporting Files/App-Info.plist
@@ -79,6 +79,8 @@
Record your own sounds or use the microphone for screen recording.
NSPhotoLibraryUsageDescription
Import pictures from your Photo Library to use as Look or Background.
+ PHPhotoLibraryPreventAutomaticLimitedAccessAlert
+
UIFileSharingEnabled
UILaunchStoryboardName
diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController+MediaLibrary.swift b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController+MediaLibrary.swift
index c693e93e72..019f7cee50 100644
--- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController+MediaLibrary.swift
+++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController+MediaLibrary.swift
@@ -19,6 +19,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
+import PhotosUI
extension LooksTableViewController {
@@ -47,6 +48,37 @@ extension LooksTableViewController {
}
}
+extension LooksTableViewController {
+
+ @available(iOS 14, *)
+ @objc
+ func checkAndUpdateLimitedPhotosAccess() {
+ let accessLevel: PHAccessLevel = .readWrite
+ let status = PHPhotoLibrary.authorizationStatus(for: accessLevel)
+
+ if status == .limited {
+ AlertControllerBuilder.alert(title: kLocalizedAllowAccessToPhotos, message: kLocalizedAllowAccessToPhotosDescription)
+ .addDefaultAction(title: kLocalizedSettings) {
+ self.gotoAppPrivacySettings()
+ }
+ .addCancelAction(title: kLocalizedCancel, handler: {
+ })
+ .build()
+ .showWithController(self)
+ }
+ }
+
+ func gotoAppPrivacySettings() {
+ guard let url = URL(string: UIApplication.openSettingsURLString),
+ UIApplication.shared.canOpenURL(url) else {
+ assertionFailure("Not able to open App privacy settings")
+ return
+ }
+
+ UIApplication.shared.open(url, options: [:], completionHandler: nil)
+ }
+}
+
extension LooksTableViewController: MediaLibraryViewControllerImportDelegate {
func mediaLibraryViewController(_ mediaLibraryViewController: MediaLibraryViewController, didPickItemsForImport items: [MediaItem]) {
for item in items {
diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m
index 7d6e67b3fd..0c5d90931e 100644
--- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m
+++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m
@@ -536,6 +536,11 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking
[self saveImageData:imageData withFileName:@"" andImageFileNameExtension:@""];
}
}];
+ } else {
+ // if asset cannot be found and iOS Version > 14 the access to the image might be limited and need to be checked
+ if (@available(iOS 14, *)) {
+ [self checkAndUpdateLimitedPhotosAccess];
+ }
}
} else if(picker.sourceType == UIImagePickerControllerSourceTypeCamera){
NSData *imageData = UIImagePNGRepresentation(image);
diff --git a/src/CattyUITests/Defines/LanguageTranslationDefinesUI.swift b/src/CattyUITests/Defines/LanguageTranslationDefinesUI.swift
index 46bdb6121a..59422c9b01 100644
--- a/src/CattyUITests/Defines/LanguageTranslationDefinesUI.swift
+++ b/src/CattyUITests/Defines/LanguageTranslationDefinesUI.swift
@@ -283,6 +283,7 @@ let kLocalizedAboutUs = NSLocalizedString("About Us", bundle: Bundle(for: Langua
let kLocalizedCatrobatWebsite = NSLocalizedString("Catrobat website", bundle: Bundle(for: LanguageTranslation.self), comment: "")
let kLocalizedViewTermsOfUse = NSLocalizedString("View Terms of Use and Service", bundle: Bundle(for: LanguageTranslation.self), comment: "")
let kLocalizedTrustedDomains = NSLocalizedString("Trusted domains", bundle: Bundle(for: LanguageTranslation.self), comment: "")
+let kLocalizedOpenSettings = NSLocalizedString("Open Settings", bundle: Bundle(for: LanguageTranslation.self), comment: "")
//************************************************************************************************************
//********************************** SHORT DESCRIPTIONS *******************************************
@@ -306,6 +307,7 @@ let kLocalizedDisconnectBluetoothDevices = NSLocalizedString("All Bluetooth devi
let kLocalizedRemovedKnownBluetoothDevices = NSLocalizedString("All known Bluetooth devices successfully removed", bundle: Bundle(for: LanguageTranslation.self), comment: "")
let kLocalizedArduinoBricksDescription = NSLocalizedString("Allow the app to control Arduino boards", bundle: Bundle(for: LanguageTranslation.self), comment: "")
let kLocalizedEmbroideryBricksDescription = NSLocalizedString("Create patterns for stiching machines", bundle: Bundle(for: LanguageTranslation.self), comment: "")
+let kLocalizedAllowAccessToPhotos = NSLocalizedString("Allow access to your photos", bundle: Bundle(for: LanguageTranslation.self), comment: "")
//************************************************************************************************************
//********************************** LONG DESCRIPTIONS ********************************************
@@ -343,6 +345,7 @@ let kLocalizedNoAccesToCameraCheckSettingsDescription = NSLocalizedString("Pocke
let kLocalizedNoAccesToMicrophoneCheckSettingsDescription = NSLocalizedString("Pocket Code has no access to your microphone. To permit access, tap settings and activate microphone.", bundle: Bundle(for: LanguageTranslation.self), comment: "")
let kLocalizedUnsupportedElementsDescription = NSLocalizedString("Following features used in this project are not compatible with this version of Pocket Code:", bundle: Bundle(for: LanguageTranslation.self), comment: "")
let kLocalizedAlwaysAllowWebRequestDescription = NSLocalizedString("Be very careful before allowing access, since the link may expose your personal information, such as your precise geographical location or any text you have entered to malicious other persons or to the public. See our wiki for more information why this can be extremely dangerous. By always allowing access, you will not be asked again to confirm web addresses from this domain. If you want to revoke this permission later, you can remove the domain from the list of trusted domains in the settings of this app.", bundle: Bundle(for: LanguageTranslation.self), comment: "")
+let kLocalizedAllowAccessToPhotosDescription = NSLocalizedString("Change Settings to allow Pocket Code full access to this photo.", bundle: Bundle(for: LanguageTranslation.self), comment: "")
//************************************************************************************************************
//******************************* BRICK TITLE TRANSLATIONS ****************************************