Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CATTY-587 Choose image from selected photos #1810

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Catty/Defines/LanguageTranslationDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ********************************************
Expand Down Expand Up @@ -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 ****************************************
Expand Down
2 changes: 2 additions & 0 deletions src/Catty/Defines/LanguageTranslationDefinesSwift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 ********************************************
Expand Down Expand Up @@ -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 ****************************************
Expand Down
9 changes: 9 additions & 0 deletions src/Catty/Resources/Localization/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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";

Expand Down Expand Up @@ -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";

Expand Down
2 changes: 2 additions & 0 deletions src/Catty/Supporting Files/App-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
<string>Record your own sounds or use the microphone for screen recording.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Import pictures from your Photo Library to use as Look or Background.</string>
<key>PHPhotoLibraryPreventAutomaticLimitedAccessAlert</key>
<true/>
<key>UIFileSharingEnabled</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/CattyUITests/Defines/LanguageTranslationDefinesUI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 *******************************************
Expand All @@ -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 ********************************************
Expand Down Expand Up @@ -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 ****************************************
Expand Down