Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…troller

# By Clement T
# Via Clement T
* 'master' of https://github.com/chiunam/CTAssetsPickerController:
  Update CocoaPods Spec
  Update README.md
  Update RELEASE-NOTES.md
  Resize screenshot
  Update Screenshot to iPhone 6
  1and2papa#56 Move the localisable string to separated string table
  1and2papa#57 Make the picker's toolbar to conform UIApperance so that it can be overridden
  Update CocoaPods Spec
  Update RELEASE-NOTES.md
  1and2papa#55 Fix: Pictures disappear until you do scrolling gesture when you take screenshot
  Rectify documentation

Conflicts:
	CTAssetsPickerDemo.xcodeproj/project.pbxproj
  • Loading branch information
kentran committed Nov 10, 2014
2 parents fb2eb7b + a608919 commit 98e64ce
Show file tree
Hide file tree
Showing 20 changed files with 227 additions and 102 deletions.
4 changes: 2 additions & 2 deletions CTAssetsPickerController.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "CTAssetsPickerController"
s.version = "2.6.0"
s.version = "2.7.0"
s.summary = "iOS control that allows picking multiple photos and videos from user's photo library."

s.description = <<-DESC
Expand All @@ -15,7 +15,7 @@ Pod::Spec.new do |s|
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { "Clement T" => "chiunam@gmail.com" }
s.platform = :ios, '7.0'
s.source = { :git => "https://github.com/chiunam/CTAssetsPickerController.git", :tag => "v2.6.0" }
s.source = { :git => "https://github.com/chiunam/CTAssetsPickerController.git", :tag => "v2.7.0" }
s.source_files = "CTAssetsPickerController/*.{h,m}"
s.resource = "CTAssetsPickerController/CTAssetsPicker.xcassets/*/*.png"
s.frameworks = "AssetsLibrary", "MediaPlayer"
Expand Down
10 changes: 5 additions & 5 deletions CTAssetsPickerController/ALAsset+accessibilityLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ - (NSString *)accessibilityLabel
[accessibilityLabels addObject:[self dateAccessibilityLabel]];

if (!self.defaultRepresentation)
[accessibilityLabels addObject:NSLocalizedString(@"Not available", nil)];
[accessibilityLabels addObject:NSLocalizedStringFromTable(@"Not available", @"CTAssetsPickerController", nil)];

return [accessibilityLabels componentsJoinedByString:@", "];
}
Expand All @@ -55,10 +55,10 @@ - (NSString *)accessibilityLabel
- (NSString *)typeAccessibilityLabel
{
if ([self isVideo]) {
return NSLocalizedString(@"Video", nil);
return NSLocalizedStringFromTable(@"Video", @"CTAssetsPickerController", nil);
}

return NSLocalizedString(@"Photo", nil);
return NSLocalizedStringFromTable(@"Photo", @"CTAssetsPickerController", nil);
}

- (NSString *)durationAccessibilityLabel
Expand All @@ -73,10 +73,10 @@ - (NSString *)orientationAccessibilityLabel
CGSize dimension = self.defaultRepresentation.dimensions;

if (dimension.height >= dimension.width) {
return NSLocalizedString(@"Portrait", nil);
return NSLocalizedStringFromTable(@"Portrait", @"CTAssetsPickerController", nil);
}

return NSLocalizedString(@"Landscape", nil);
return NSLocalizedStringFromTable(@"Landscape", @"CTAssetsPickerController", nil);
}

- (NSString *)dateAccessibilityLabel
Expand Down
2 changes: 1 addition & 1 deletion CTAssetsPickerController/CTAssetScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ - (void)addVideoPlayButton
[button setImage:image forState:UIControlStateNormal];
[button addTarget:self action:@selector(playVideo:) forControlEvents:UIControlEventTouchUpInside];

button.accessibilityLabel = NSLocalizedString(@"Play" , nil);
button.accessibilityLabel = NSLocalizedStringFromTable(@"Play", @"CTAssetsPickerController", nil);
button.translatesAutoresizingMaskIntoConstraints = NO;

self.playButton = button;
Expand Down
2 changes: 1 addition & 1 deletion CTAssetsPickerController/CTAssetsGroupViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ - (NSString *)accessibilityLabel
{
NSString *label = [self.assetsGroup valueForProperty:ALAssetsGroupPropertyName];

return [label stringByAppendingFormat:NSLocalizedString(@"%ld Photos", nil), (long)self.assetsGroup.numberOfAssets];
return [label stringByAppendingFormat:NSLocalizedStringFromTable(@"%ld Photos", @"CTAssetsPickerController", nil), (long)self.assetsGroup.numberOfAssets];
}

@end
6 changes: 3 additions & 3 deletions CTAssetsPickerController/CTAssetsGroupViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ - (void)setupButtons
if (self.picker.showsCancelButton)
{
self.navigationItem.leftBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Cancel", nil)
[[UIBarButtonItem alloc] initWithTitle:NSLocalizedStringFromTable(@"Cancel", @"CTAssetsPickerController", nil)
style:UIBarButtonItemStylePlain
target:self.picker
action:@selector(dismiss:)];
}

self.navigationItem.rightBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Done", nil)
[[UIBarButtonItem alloc] initWithTitle:NSLocalizedStringFromTable(@"Done", @"CTAssetsPickerController", nil)
style:UIBarButtonItemStyleDone
target:self.picker
action:@selector(finishPickingAssets:)];
Expand All @@ -144,7 +144,7 @@ - (void)setupToolbar
- (void)localize
{
if (!self.picker.title)
self.title = NSLocalizedString(@"Photos", nil);
self.title = NSLocalizedStringFromTable(@"Photos", @"CTAssetsPickerController", nil);
else
self.title = self.picker.title;
}
Expand Down
2 changes: 1 addition & 1 deletion CTAssetsPickerController/CTAssetsPageViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ - (BOOL)prefersStatusBarHidden
- (void)setTitleIndex:(NSInteger)index
{
NSInteger count = self.assets.count;
self.title = [NSString stringWithFormat:NSLocalizedString(@"%ld of %ld", nil), index, count];
self.title = [NSString stringWithFormat:NSLocalizedStringFromTable(@"%ld of %ld", @"CTAssetsPickerController", nil), index, count];
}


Expand Down
16 changes: 8 additions & 8 deletions CTAssetsPickerController/CTAssetsPickerController.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@
/**
* Tells the delegate that the asset was selected.
*
* @param picker The controller object managing the assets picker interface.
* @param indexPath The asset that was selected.
* @param picker The controller object managing the assets picker interface.
* @param asset The asset that was selected.
*
* @see assetsPickerController:didDeselectAsset:
*/
Expand All @@ -263,8 +263,8 @@
/**
* Tells the delegate that the item at the specified path was deselected.
*
* @param picker The controller object managing the assets picker interface.
* @param indexPath The asset that was deselected.
* @param picker The controller object managing the assets picker interface.
* @param asset The asset that was deselected.
*
* @see assetsPickerController:didSelectAsset:
*/
Expand All @@ -289,8 +289,8 @@
/**
* Tells the delegate that asset was highlighted.
*
* @param picker The controller object managing the assets picker interface.
* @param indexPath The asset that was highlighted.
* @param picker The controller object managing the assets picker interface.
* @param asset The asset that was highlighted.
*
* @see assetsPickerController:didUnhighlightAsset:
*/
Expand All @@ -300,8 +300,8 @@
/**
* Tells the delegate that the highlight was removed from the asset.
*
* @param picker The controller object managing the assets picker interface.
* @param indexPath The asset that had its highlight removed.
* @param picker The controller object managing the assets picker interface.
* @param asset The asset that had its highlight removed.
*
* @see assetsPickerController:didHighlightAsset:
*/
Expand Down
41 changes: 27 additions & 14 deletions CTAssetsPickerController/CTAssetsPickerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
self.preferredContentSize = CTAssetPickerPopoverContentSize;

[self setupNavigationController];
[self setupToolbarApperance];
[self addKeyValueObserver];
}

Expand Down Expand Up @@ -87,9 +88,10 @@ - (UINavigationController *)createChildNavigationController
return [UINavigationController alloc];
}

#pragma mark - UINavigationControllerDelegate


#pragma mark - UINavigationControllerDelegate

- (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
animationControllerForOperation:(UINavigationControllerOperation)operation
fromViewController:(UIViewController *)fromVC
Expand All @@ -111,6 +113,17 @@ - (UINavigationController *)createChildNavigationController



#pragma mark - Toolbar Appearance

- (void)setupToolbarApperance
{
NSDictionary *attributes = @{NSForegroundColorAttributeName : [UIColor blackColor]};
UIBarButtonItem *barButtonItem = [UIBarButtonItem appearanceWhenContainedIn:[UIToolbar class], [CTAssetsPickerController class], nil];
[barButtonItem setTitleTextAttributes:attributes forState:UIControlStateNormal];
}



#pragma mark - ALAssetsLibrary

+ (ALAssetsLibrary *)defaultAssetsLibrary
Expand Down Expand Up @@ -264,9 +277,9 @@ - (NSString *)noAssetsMessage
NSString *format;

if ([self isCameraDeviceAvailable])
format = NSLocalizedString(@"You can take photos and videos using the camera, or sync photos and videos onto your %@\nusing iTunes.", nil);
format = NSLocalizedStringFromTable(@"You can take photos and videos using the camera, or sync photos and videos onto your %@\nusing iTunes.", @"CTAssetsPickerController", nil);
else
format = NSLocalizedString(@"You can sync photos and videos onto your %@ using iTunes.", nil);
format = NSLocalizedStringFromTable(@"You can sync photos and videos onto your %@ using iTunes.", @"CTAssetsPickerController", nil);

return [NSString stringWithFormat:format, self.deviceModel];
}
Expand Down Expand Up @@ -351,11 +364,11 @@ - (UIView *)notAllowedView
UILabel *title =
[self auxiliaryLabelWithFont:[UIFont boldSystemFontOfSize:17.0]
color:[UIColor colorWithRed:129.0/255.0 green:136.0/255.0 blue:148.0/255.0 alpha:1]
text:NSLocalizedString(@"This app does not have access to your photos or videos.", nil)];
text:NSLocalizedStringFromTable(@"This app does not have access to your photos or videos.", @"CTAssetsPickerController", nil)];
UILabel *message =
[self auxiliaryLabelWithFont:[UIFont systemFontOfSize:14.0]
color:[UIColor colorWithRed:129.0/255.0 green:136.0/255.0 blue:148.0/255.0 alpha:1]
text:NSLocalizedString(@"You can enable access in Privacy Settings.", nil)];
text:NSLocalizedStringFromTable(@"You can enable access in Privacy Settings.", @"CTAssetsPickerController", nil)];

UIView *centerView = [self centerViewWithViews:@[padlock, title, message]];

Expand All @@ -370,7 +383,7 @@ - (UIView *)noAssetsView
UILabel *title =
[self auxiliaryLabelWithFont:[UIFont systemFontOfSize:26.0]
color:[UIColor colorWithRed:153.0/255.0 green:153.0/255.0 blue:153.0/255.0 alpha:1]
text:NSLocalizedString(@"No Photos or Videos", nil)];
text:NSLocalizedStringFromTable(@"No Photos or Videos", @"CTAssetsPickerController", nil)];

UILabel *message =
[self auxiliaryLabelWithFont:[UIFont systemFontOfSize:18.0]
Expand Down Expand Up @@ -409,13 +422,17 @@ - (NSString *)toolbarTitle
NSString *format;

if (photoSelected && videoSelected)
format = NSLocalizedString(@"%ld Items Selected", nil);
format = NSLocalizedStringFromTable(@"%ld Items Selected", @"CTAssetsPickerController", nil);

else if (photoSelected)
format = (self.selectedAssets.count > 1) ? NSLocalizedString(@"%ld Photos Selected", nil) : NSLocalizedString(@"%ld Photo Selected", nil);
format = (self.selectedAssets.count > 1) ?
NSLocalizedStringFromTable(@"%ld Photos Selected", @"CTAssetsPickerController", nil) :
NSLocalizedStringFromTable(@"%ld Photo Selected", @"CTAssetsPickerController", nil);

else if (videoSelected)
format = (self.selectedAssets.count > 1) ? NSLocalizedString(@"%ld Videos Selected", nil) : NSLocalizedString(@"%ld Video Selected", nil);
format = (self.selectedAssets.count > 1) ?
NSLocalizedStringFromTable(@"%ld Videos Selected", @"CTAssetsPickerController", nil) :
NSLocalizedStringFromTable(@"%ld Video Selected", @"CTAssetsPickerController", nil);

return [NSString stringWithFormat:format, (long)self.selectedAssets.count];
}
Expand All @@ -430,11 +447,7 @@ - (UIBarButtonItem *)titleButtonItem
style:UIBarButtonItemStylePlain
target:nil
action:nil];

NSDictionary *attributes = @{NSForegroundColorAttributeName : [UIColor blackColor]};

[title setTitleTextAttributes:attributes forState:UIControlStateNormal];
[title setTitleTextAttributes:attributes forState:UIControlStateDisabled];

[title setEnabled:NO];

return title;
Expand Down
6 changes: 3 additions & 3 deletions CTAssetsPickerController/CTAssetsSupplementaryView.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ - (void)bind:(NSArray *)assets
NSInteger numberOfPhotos = [assets filteredArrayUsingPredicate:[self predicateOfAssetType:ALAssetTypePhoto]].count;

if (numberOfVideos == 0)
self.label.text = [NSString stringWithFormat:NSLocalizedString(@"%ld Photos", nil), (long)numberOfPhotos];
self.label.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"%ld Photos", @"CTAssetsPickerController", nil), (long)numberOfPhotos];
else if (numberOfPhotos == 0)
self.label.text = [NSString stringWithFormat:NSLocalizedString(@"%ld Videos", nil), (long)numberOfVideos];
self.label.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"%ld Videos", @"CTAssetsPickerController", nil), (long)numberOfVideos];
else
self.label.text = [NSString stringWithFormat:NSLocalizedString(@"%ld Photos, %ld Videos", nil), (long)numberOfPhotos, (long)numberOfVideos];
self.label.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"%ld Photos, %ld Videos", @"CTAssetsPickerController", nil), (long)numberOfPhotos, (long)numberOfVideos];
}

- (NSPredicate *)predicateOfAssetType:(NSString *)type
Expand Down
12 changes: 7 additions & 5 deletions CTAssetsPickerController/CTAssetsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ - (void)setupViews
- (void)setupButtons
{
self.navigationItem.rightBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Done", nil)
[[UIBarButtonItem alloc] initWithTitle:NSLocalizedStringFromTable(@"Done", @"CTAssetsPickerController", nil)
style:UIBarButtonItemStyleDone
target:self.picker
action:@selector(finishPickingAssets:)];
Expand Down Expand Up @@ -348,7 +348,9 @@ - (void)reloadData
if (self.assets.count > 0)
{
[self.collectionView reloadData];
[self.collectionView setContentOffset:CGPointMake(0, self.collectionViewLayout.collectionViewContentSize.height)];

if (self.collectionView.contentOffset.y <= 0)
[self.collectionView setContentOffset:CGPointMake(0, self.collectionViewLayout.collectionViewContentSize.height)];
}
else
{
Expand Down Expand Up @@ -466,7 +468,7 @@ - (void)layoutTakePhotoOverlay
- (void)takePhoto
{
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
imagePickerController.modalPresentationStyle = UIModalPresentationFullScreen;
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.mediaTypes = @[(NSString *)kUTTypeImage];
imagePickerController.delegate = self;
Expand All @@ -489,9 +491,9 @@ - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error context
* in case we are trying to dismiss the picker after taking a photo
*/
if ([self.picker.delegate respondsToSelector:@selector(assetsPickerController:didFinishTakingPhoto:)])
[self.picker.delegate assetsPickerController:self.picker didFinishTakingPhoto:[self.assets firstObject]];
[self.picker.delegate assetsPickerController:self.picker didFinishTakingPhoto:[self.assets lastObject]];
}];
// self.imageCaptured = YES;
self.imageCaptured = YES;
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
Expand Down
12 changes: 9 additions & 3 deletions CTAssetsPickerController/NSDateFormatter+timeIntervalFormatter.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,23 @@ - (NSString *)spellOutStringFromTimeInterval:(NSTimeInterval)timeInterval
if (components.hour > 0)
string = [string stringByAppendingFormat:@"%ld %@",
(long)components.hour,
(components.hour > 1) ? NSLocalizedString(@"hours", nil) : NSLocalizedString(@"hour", nil)];
(components.hour > 1) ?
NSLocalizedStringFromTable(@"hours", @"CTAssetsPickerController", nil) :
NSLocalizedStringFromTable(@"hour", @"CTAssetsPickerController", nil)];

if (components.minute > 0)
string = [string stringByAppendingFormat:@"%ld %@",
(long)components.minute,
(components.minute > 1) ? NSLocalizedString(@"minutes", nil) : NSLocalizedString(@"minute", nil)];
(components.minute > 1) ?
NSLocalizedStringFromTable(@"minutes", @"CTAssetsPickerController", nil) :
NSLocalizedStringFromTable(@"minute", @"CTAssetsPickerController", nil)];

if (components.second > 0)
string = [string stringByAppendingFormat:@"%ld %@",
(long)components.second,
(components.second > 1) ? NSLocalizedString(@"seconds", nil) : NSLocalizedString(@"second", nil)];
(components.second > 1) ?
NSLocalizedStringFromTable(@"seconds", @"CTAssetsPickerController", nil) :
NSLocalizedStringFromTable(@"second", @"CTAssetsPickerController", nil)];

return string;
}
Expand Down
48 changes: 48 additions & 0 deletions CTAssetsPickerController/en.lproj/CTAssetsPickerController.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* Navigation bar buttons */
"Cancel" = "Cancel";
"Done" = "Done";

/* Default title */
"Photos" = "Photos";

/* No. of selected */
"%ld Photo Selected" = "%ld Photo Selected";
"%ld Photos Selected" = "%ld Photos Selected";
"%ld Video Selected" = "%ld Video Selected";
"%ld Videos Selected" = "%ld Videos Selected";
"%ld Items Selected" = "%ld Items Selected";

/* Album's footer */
"%ld Photos" = "%ld Photos";
"%ld Videos" = "%ld Videos";
"%ld Photos, %ld Videos" = "%1$ld Photos, %2$ld Videos";

/* Assets index */
"%ld of %ld" = "%1$ld of %2$ld";

/* Messages if privacy is not granted */
"This app does not have access to your photos or videos." = "This app does not have access to your photos or videos.";
"You can enable access in Privacy Settings." = "You can enable access in Privacy Settings.";

/* Messages if no assets */
"No Photos or Videos" = "No Photos or Videos";

/* The parameter will be replaced by the device model name */
"You can take photos and videos using the camera, or sync photos and videos onto your %@\nusing iTunes." = "You can take photos and videos using the camera, or sync photos and videos onto your %@\nusing iTunes.";
"You can sync photos and videos onto your iPhone using iTunes." = "You can sync photos and videos onto your iPhone using iTunes.";

/* Accessibility labels */
"Photo" = "Photo";
"Video" = "Video";
"Portrait" = "Portrait";
"Landscape" = "Landscape";
"Play" = "Play";
"Not available" = "Not available";

/* Video duration spell out */
"hours" = "hours";
"hour" = "hour";
"minutes" = "minutes";
"minute" = "minute";
"seconds" = "seconds";
"second" = "second";
Loading

0 comments on commit 98e64ce

Please sign in to comment.