Skip to content

Commit

Permalink
Merge pull request #440 from Piwigo/v2.6
Browse files Browse the repository at this point in the history
v2.6
  • Loading branch information
EddyLB authored Mar 3, 2021
2 parents 392872e + de6c94c commit 9f3b9dc
Show file tree
Hide file tree
Showing 115 changed files with 6,824 additions and 3,049 deletions.
146 changes: 104 additions & 42 deletions piwigo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions piwigo.xcodeproj/xcshareddata/xcschemes/piwigo.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,16 @@
savedToolIdentifier = "/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/Resources/templates/Leaks.tracetemplate"
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D82B8CBA1A67820A000E47CA"
BuildableName = "piwigo.app"
BlueprintName = "piwigo"
ReferencedContainer = "container:piwigo.xcodeproj">
</BuildableReference>
</MacroExpansion>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
5 changes: 5 additions & 0 deletions piwigo/Albums/AlbumImagesViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ FOUNDATION_EXPORT NSString * const kPiwigoNotificationUploadedImage;
FOUNDATION_EXPORT NSString * const kPiwigoNotificationDeletedImage;
FOUNDATION_EXPORT NSString * const kPiwigoNotificationChangedAlbumData;

FOUNDATION_EXPORT NSString * const kPiwigoNotificationDidShareImage;
FOUNDATION_EXPORT NSString * const kPiwigoNotificationCancelDownloadImage;
FOUNDATION_EXPORT NSString * const kPiwigoNotificationDidShareVideo;
FOUNDATION_EXPORT NSString * const kPiwigoNotificationCancelDownloadVideo;

@interface AlbumImagesViewController : UIViewController

@property (nonatomic, assign) NSInteger categoryId;
Expand Down
67 changes: 46 additions & 21 deletions piwigo/Albums/AlbumImagesViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#import "AlbumData.h"
#import "AlbumImagesViewController.h"
#import "AlbumService.h"
#import "AsyncImageActivityItemProvider.h"
#import "AsyncVideoActivityItemProvider.h"
#import "AppDelegate.h"
#import "CategoriesData.h"
#import "CategoryCollectionViewCell.h"
Expand Down Expand Up @@ -45,7 +43,12 @@
NSString * const kPiwigoNotificationDeletedImage = @"kPiwigoNotificationDeletedImage";
NSString * const kPiwigoNotificationChangedAlbumData = @"kPiwigoNotificationChangedAlbumData";

@interface AlbumImagesViewController () <UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UIGestureRecognizerDelegate, UIToolbarDelegate, UISearchControllerDelegate, UISearchResultsUpdating, UISearchBarDelegate, UITextFieldDelegate, ImageDetailDelegate, EditImageParamsDelegate, MoveImagesDelegate, CategorySortDelegate, CategoryCollectionViewCellDelegate, AsyncImageActivityItemProviderDelegate, TagSelectorViewDelegate, ChangedSettingsDelegate>
NSString * const kPiwigoNotificationDidShareImage = @"kPiwigoNotificationDidShareImage";
NSString * const kPiwigoNotificationCancelDownloadImage = @"kPiwigoNotificationCancelDownloadImage";
NSString * const kPiwigoNotificationDidShareVideo = @"kPiwigoNotificationDidShareVideo";
NSString * const kPiwigoNotificationCancelDownloadVideo = @"kPiwigoNotificationCancelDownloadVideo";

@interface AlbumImagesViewController () <UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UIGestureRecognizerDelegate, UIToolbarDelegate, UISearchControllerDelegate, UISearchResultsUpdating, UISearchBarDelegate, UITextFieldDelegate, ImageDetailDelegate, EditImageParamsDelegate, MoveImagesDelegate, CategorySortDelegate, CategoryCollectionViewCellDelegate, ShareImageActivityItemProviderDelegate, TagSelectorViewDelegate, ChangedSettingsDelegate>

@property (nonatomic, strong) UICollectionView *imagesCollection;
@property (nonatomic, strong) AlbumData *albumData;
Expand Down Expand Up @@ -328,7 +331,7 @@ -(void)applyColorPalette
self.nberOfUploadsLabel.textColor = [UIColor piwigoColorBackground];
self.progressLayer.strokeColor = [[UIColor piwigoColorBackground] CGColor];

[self.homeAlbumButton.layer setShadowColor:[UIColor piwigoColorLeftLabel].CGColor];
[self.homeAlbumButton.layer setShadowColor:[UIColor piwigoColorShadow].CGColor];
self.homeAlbumButton.backgroundColor = [UIColor piwigoColorRightLabel];
self.homeAlbumButton.tintColor = [UIColor piwigoColorBackground];

Expand Down Expand Up @@ -585,6 +588,32 @@ -(void)viewDidAppear:(BOOL)animated
}
}

// Determine which help pages should be presented
NSMutableArray *displayHelpPagesWithIndex = [[NSMutableArray alloc] initWithCapacity:2];
if ((self.categoryId != 0) && ([self.albumData.images count] > 2) &&
(([Model sharedInstance].didWatchHelpViews & 0b0000000000000001) == 0)) {
[displayHelpPagesWithIndex addObject:@0]; // i.e. multiple selection of images
}
NSInteger numberOfAlbums = [[CategoriesData sharedInstance] getCategoriesForParentCategory:self.categoryId].count;
if ((self.categoryId != 0) && (numberOfAlbums > 2) && [Model sharedInstance].hasAdminRights &&
(([Model sharedInstance].didWatchHelpViews & 0b0000000000000100) == 0)) {
[displayHelpPagesWithIndex addObject:@2]; // i.e. management of albums
}
if (displayHelpPagesWithIndex.count > 0) {
// Present unseen upload management help views
UIStoryboard *helpSB = [UIStoryboard storyboardWithName:@"HelpViewController" bundle:nil];
HelpViewController *helpVC = [helpSB instantiateViewControllerWithIdentifier:@"HelpViewController"];
helpVC.displayHelpPagesWithIndex = displayHelpPagesWithIndex;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
helpVC.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionUp;
[self presentViewController:helpVC animated:YES completion:nil];
} else {
helpVC.modalPresentationStyle = UIModalPresentationFormSheet;
helpVC.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:helpVC animated:YES completion:nil];
}
}

// Replace iRate as from v2.1.5 (75) — See https://github.com/nicklockwood/iRate
// Tells StoreKit to ask the user to rate or review the app, if appropriate.
//#if !defined(DEBUG)
Expand Down Expand Up @@ -630,18 +659,6 @@ -(void)viewDidAppear:(BOOL)animated
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(categoriesUpdated) name:kPiwigoNotificationCategoryDataUpdated object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addImageToCategory:) name:kPiwigoNotificationUploadedImage object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(removeImageFromCategory:) name:kPiwigoNotificationDeletedImage object:nil];

// Present What's New views i.e. Help views if needed
// [Model sharedInstance].didWatchHelpViews = 0b0000000000000000; // Lines for testing
if (([Model sharedInstance].didWatchHelpViews < 0b0000000000111111) &&
![Model sharedInstance].didPresentHelpViewsInCurrentSession ){
UIStoryboard *helpSB = [UIStoryboard storyboardWithName:@"HelpViewController" bundle:nil];
HelpViewController *helpVC = [helpSB instantiateViewControllerWithIdentifier:@"HelpViewController"];
helpVC.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
helpVC.modalPresentationStyle = UIModalPresentationFormSheet;
helpVC.onlyWhatsNew = YES;
[self presentViewController:helpVC animated:YES completion:nil];
}
}

-(void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
Expand Down Expand Up @@ -2574,23 +2591,29 @@ -(void)checkPhotoLibraryAccessBeforeShare

-(void)presentShareImageViewControllerWithCameraRollAccess:(BOOL)hasCameraRollAccess
{
// To exclude some activity types
NSMutableSet *excludedActivityTypes = [NSMutableSet new];

// Create new activity provider items to pass to the activity view controller
self.totalNumberOfImages = self.selectedImagesToShare.count;
NSMutableArray *itemsToShare = [NSMutableArray new];
for (PiwigoImageData *imageData in self.selectedImagesToShare) {
if (imageData.isVideo) {
// Case of a video
AsyncVideoActivityItemProvider *videoItemProvider = [[AsyncVideoActivityItemProvider alloc] initWithPlaceholderImage:imageData];
ShareVideoActivityItemProvider *videoItemProvider = [[ShareVideoActivityItemProvider alloc] initWithPlaceholderImage:imageData];

// Use delegation to monitor the progress of the item method
videoItemProvider.delegate = self;

// Add to list of items to share
[itemsToShare addObject:videoItemProvider];

// Exclude "assign to contact" activity
[excludedActivityTypes addObject:UIActivityTypeAssignToContact];
}
else {
// Case of an image
AsyncImageActivityItemProvider *imageItemProvider = [[AsyncImageActivityItemProvider alloc] initWithPlaceholderImage:imageData];
ShareImageActivityItemProvider *imageItemProvider = [[ShareImageActivityItemProvider alloc] initWithPlaceholderImage:imageData];

// Use delegation to monitor the progress of the item method
imageItemProvider.delegate = self;
Expand All @@ -2601,16 +2624,18 @@ -(void)presentShareImageViewControllerWithCameraRollAccess:(BOOL)hasCameraRollAc
}

// Create an activity view controller with the activity provider item.
// AsyncImageActivityItemProvider's superclass conforms to the UIActivityItemSource protocol
// ShareImageActivityItemProvider's superclass conforms to the UIActivityItemSource protocol
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];

// Set HUD view controller for displaying progress
self.hudViewController = activityViewController;

// Exclude camera roll activity if needed
if (!hasCameraRollAccess) {
activityViewController.excludedActivityTypes = @[UIActivityTypeSaveToCameraRoll];
// Exclude "camera roll" activity when the Photo Library is not accessible
[excludedActivityTypes addObject:UIActivityTypeSaveToCameraRoll];
}
activityViewController.excludedActivityTypes = [excludedActivityTypes allObjects];

// Delete image/video files and remove observers after dismissing activity view controller
[activityViewController setCompletionWithItemsHandler:^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError){
Expand Down Expand Up @@ -3439,7 +3464,7 @@ -(void)pushView:(UIViewController *)viewController
}


#pragma mark - AsyncImageActivityItemProviderDelegate
#pragma mark - ShareImageActivityItemProviderDelegate

-(void)imageActivityItemProviderPreprocessingDidBegin:(UIActivityItemProvider *)imageActivityItemProvider withTitle:(NSString *)title
{
Expand Down
24 changes: 15 additions & 9 deletions piwigo/Albums/Discover/DiscoverImagesViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#import "AlbumData.h"
#import "AlbumService.h"
#import "AppDelegate.h"
#import "AsyncImageActivityItemProvider.h"
#import "AsyncVideoActivityItemProvider.h"
#import "CategoriesData.h"
#import "DiscoverImagesViewController.h"
#import "EditImageParamsViewController.h"
Expand All @@ -22,7 +20,7 @@
#import "Model.h"
#import "MoveImageViewController.h"

@interface DiscoverImagesViewController () <UICollectionViewDelegate, UICollectionViewDataSource, UIGestureRecognizerDelegate, ImageDetailDelegate, EditImageParamsDelegate, AsyncImageActivityItemProviderDelegate, MoveImagesDelegate>
@interface DiscoverImagesViewController () <UICollectionViewDelegate, UICollectionViewDataSource, UIGestureRecognizerDelegate, ImageDetailDelegate, EditImageParamsDelegate, ShareImageActivityItemProviderDelegate, MoveImagesDelegate>

@property (nonatomic, strong) UICollectionView *imagesCollection;
@property (nonatomic, assign) NSInteger categoryId;
Expand Down Expand Up @@ -72,9 +70,17 @@ -(instancetype)initWithCategoryId:(NSInteger)categoryId
self.imageOfInterest = [NSIndexPath indexPathForItem:0 inSection:0];

self.albumData = [[AlbumData alloc] initWithCategoryId:categoryId andQuery:@""];
self.currentSortCategory = [Model sharedInstance].defaultSort;
self.displayImageTitles = [Model sharedInstance].displayImageTitles;

if (categoryId == kPiwigoVisitsCategoryId) {
self.currentSortCategory = kPiwigoSortVisitsDescending;
} else if (categoryId == kPiwigoBestCategoryId) {
self.currentSortCategory = kPiwigoSortRatingScoreDescending;
} else if (categoryId == kPiwigoRecentCategoryId) {
self.currentSortCategory = kPiwigoSortDatePostedDescending;
} else {
self.currentSortCategory = [Model sharedInstance].defaultSort;
}

// Initialise selection mode
self.isSelect = NO;
self.touchedImageIds = [NSMutableArray new];
Expand Down Expand Up @@ -1371,7 +1377,7 @@ -(void)presentShareImageViewControllerWithCameraRollAccess:(BOOL)hasCameraRollAc
for (PiwigoImageData *imageData in self.selectedImagesToShare) {
if (imageData.isVideo) {
// Case of a video
AsyncVideoActivityItemProvider *videoItemProvider = [[AsyncVideoActivityItemProvider alloc] initWithPlaceholderImage:imageData];
ShareVideoActivityItemProvider *videoItemProvider = [[ShareVideoActivityItemProvider alloc] initWithPlaceholderImage:imageData];

// Use delegation to monitor the progress of the item method
videoItemProvider.delegate = self;
Expand All @@ -1381,7 +1387,7 @@ -(void)presentShareImageViewControllerWithCameraRollAccess:(BOOL)hasCameraRollAc
}
else {
// Case of an image
AsyncImageActivityItemProvider *imageItemProvider = [[AsyncImageActivityItemProvider alloc] initWithPlaceholderImage:imageData];
ShareImageActivityItemProvider *imageItemProvider = [[ShareImageActivityItemProvider alloc] initWithPlaceholderImage:imageData];

// Use delegation to monitor the progress of the item method
imageItemProvider.delegate = self;
Expand All @@ -1392,7 +1398,7 @@ -(void)presentShareImageViewControllerWithCameraRollAccess:(BOOL)hasCameraRollAc
}

// Create an activity view controller with the activity provider item.
// AsyncImageActivityItemProvider's superclass conforms to the UIActivityItemSource protocol
// ShareImageActivityItemProvider's superclass conforms to the UIActivityItemSource protocol
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];

// Set HUD view controller for displaying progress
Expand Down Expand Up @@ -1561,7 +1567,7 @@ -(void)deselectImages
}


#pragma mark - AsyncImageActivityItemProviderDelegate
#pragma mark - ShareImageActivityItemProviderDelegate

-(void)imageActivityItemProviderPreprocessingDidBegin:(UIActivityItemProvider *)imageActivityItemProvider withTitle:(NSString *)title
{
Expand Down
12 changes: 5 additions & 7 deletions piwigo/Albums/Discover/FavoritesImagesViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#import "AlbumData.h"
#import "AlbumService.h"
#import "AppDelegate.h"
#import "AsyncImageActivityItemProvider.h"
#import "AsyncVideoActivityItemProvider.h"
#import "CategoriesData.h"
#import "EditImageParamsViewController.h"
#import "FavoritesImagesViewController.h"
Expand All @@ -22,7 +20,7 @@
#import "Model.h"
#import "MoveImageViewController.h"

@interface FavoritesImagesViewController () <UICollectionViewDelegate, UICollectionViewDataSource, UIGestureRecognizerDelegate, ImageDetailDelegate, EditImageParamsDelegate, AsyncImageActivityItemProviderDelegate, MoveImagesDelegate>
@interface FavoritesImagesViewController () <UICollectionViewDelegate, UICollectionViewDataSource, UIGestureRecognizerDelegate, ImageDetailDelegate, EditImageParamsDelegate, ShareImageActivityItemProviderDelegate, MoveImagesDelegate>

@property (nonatomic, strong) UICollectionView *imagesCollection;
@property (nonatomic, assign) NSInteger categoryId;
Expand Down Expand Up @@ -1306,7 +1304,7 @@ -(void)presentShareImageViewControllerWithCameraRollAccess:(BOOL)hasCameraRollAc
for (PiwigoImageData *imageData in self.selectedImagesToShare) {
if (imageData.isVideo) {
// Case of a video
AsyncVideoActivityItemProvider *videoItemProvider = [[AsyncVideoActivityItemProvider alloc] initWithPlaceholderImage:imageData];
ShareVideoActivityItemProvider *videoItemProvider = [[ShareVideoActivityItemProvider alloc] initWithPlaceholderImage:imageData];

// Use delegation to monitor the progress of the item method
videoItemProvider.delegate = self;
Expand All @@ -1316,7 +1314,7 @@ -(void)presentShareImageViewControllerWithCameraRollAccess:(BOOL)hasCameraRollAc
}
else {
// Case of an image
AsyncImageActivityItemProvider *imageItemProvider = [[AsyncImageActivityItemProvider alloc] initWithPlaceholderImage:imageData];
ShareImageActivityItemProvider *imageItemProvider = [[ShareImageActivityItemProvider alloc] initWithPlaceholderImage:imageData];

// Use delegation to monitor the progress of the item method
imageItemProvider.delegate = self;
Expand All @@ -1327,7 +1325,7 @@ -(void)presentShareImageViewControllerWithCameraRollAccess:(BOOL)hasCameraRollAc
}

// Create an activity view controller with the activity provider item.
// AsyncImageActivityItemProvider's superclass conforms to the UIActivityItemSource protocol
// ShareImageActivityItemProvider's superclass conforms to the UIActivityItemSource protocol
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];

// Set HUD view controller for displaying progress
Expand Down Expand Up @@ -1496,7 +1494,7 @@ -(void)deselectImages
}


#pragma mark - AsyncImageActivityItemProviderDelegate
#pragma mark - ShareImageActivityItemProviderDelegate

-(void)imageActivityItemProviderPreprocessingDidBegin:(UIActivityItemProvider *)imageActivityItemProvider withTitle:(NSString *)title
{
Expand Down
Loading

0 comments on commit 9f3b9dc

Please sign in to comment.