Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: facebookarchive/three20
...
head fork: jcbertin/three20
compare: master
Checking mergeability… Don't worry, you can still create the pull request.
  • 7 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jul 21, 2009
Jean-Charles BERTIN Added french translation.
Signed-off-by: Jean-Charles BERTIN <jc@fusion.nuknuk.land>
d15d792
Jean-Charles BERTIN Optimized -layoutSubviews method.
Signed-off-by: Jean-Charles BERTIN <jc@fusion.nuknuk.land>
a50f068
Jean-Charles BERTIN Optimized files cache reading by adding option property.
Signed-off-by: Jean-Charles BERTIN <jc@fusion.nuknuk.land>
d09238f
Jean-Charles BERTIN Added option for auto hiding bars. Fixed navigation bar hide/show app…
…earance.

Signed-off-by: Jean-Charles BERTIN <jc@fusion.nuknuk.land>
00833c3
@jcbertin jcbertin Fixed bad merge. 8be2836
Commits on Aug 13, 2009
@jcbertin jcbertin Pulled from joehewitt/master branch. 7db6ff2
@jcbertin jcbertin Fixed bad merge (again). a9fb706
View
65 src/TTPhotoViewController.m
@@ -10,6 +10,8 @@
static const NSTimeInterval kPhotoLoadLongDelay = 0.5;
static const NSTimeInterval kPhotoLoadShortDelay = 0.25;
+static const NSTimeInterval kPhotoHideBarsDelay = 5.0;
+
static const NSTimeInterval kSlideshowInterval = 2;
static const NSInteger kActivityLabelTag = 96;
@@ -18,7 +20,8 @@
@implementation TTPhotoViewController
@synthesize photoSource = _photoSource, centerPhoto = _centerPhoto,
- centerPhotoIndex = _centerPhotoIndex, defaultImage = _defaultImage, captionStyle = _captionStyle;
+ centerPhotoIndex = _centerPhotoIndex, defaultImage = _defaultImage, captionStyle = _captionStyle,
+ autoHideBars = _autoHideBars;
///////////////////////////////////////////////////////////////////////////////////////////////////
// private
@@ -27,6 +30,26 @@ - (TTPhotoView*)centerPhotoView {
return (TTPhotoView*)_scrollView.centerPage;
}
+- (void)hideBars {
+ if (_autoHideBars)
+ [self showBars:NO animated:YES];
+}
+
+- (void)startHideBarsTimer:(NSTimeInterval)delay {
+ if (_hideBarsTimerRunning)
+ [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(hideBars) object:nil];
+
+ _hideBarsTimerRunning = YES;
+ [self performSelector:@selector(hideBars) withObject:nil afterDelay:delay];
+}
+
+- (void)cancelHideBarsTimer {
+ if (_hideBarsTimerRunning) {
+ _hideBarsTimerRunning = NO;
+ [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(hideBars) object:nil];
+ }
+}
+
- (void)loadImageDelayed {
_loadTimer = nil;
[self.centerPhotoView loadImage];
@@ -201,7 +224,9 @@ - (void)showThumbnails {
_thumbsController.photoSource = _photoSource;
}
}
-
+
+ [self cancelHideBarsTimer];
+
if (URL) {
TTOpenURL(URL);
} else {
@@ -249,6 +274,7 @@ - (void)nextAction {
if (_centerPhotoIndex < _photoSource.numberOfPhotos-1) {
_scrollView.centerPageIndex = _centerPhotoIndex+1;
}
+ [self startHideBarsTimer:kPhotoHideBarsDelay];
}
- (void)previousAction {
@@ -256,14 +282,15 @@ - (void)previousAction {
if (_centerPhotoIndex > 0) {
_scrollView.centerPageIndex = _centerPhotoIndex-1;
}
+ [self startHideBarsTimer:kPhotoHideBarsDelay];
}
- (void)showBarsAnimationDidStop {
- self.navigationController.navigationBarHidden = NO;
+ [self.navigationController setNavigationBarHidden:NO animated:NO];
}
- (void)hideBarsAnimationDidStop {
- self.navigationController.navigationBarHidden = YES;
+ [self.navigationController setNavigationBarHidden:YES animated:NO];
}
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -300,6 +327,8 @@ - (id)init {
_slideshowTimer = nil;
_loadTimer = nil;
_delayLoad = NO;
+ _hideBarsTimerRunning = NO;
+ _autoHideBars = NO;
self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:
TTLocalizedString(@"Photo", @"Title for back button that returns to photo browser")
@@ -384,9 +413,16 @@ - (void)viewDidUnload {
TT_RELEASE_SAFELY(_toolbar);
}
+- (void)viewDidAppear:(BOOL)animated {
+ [super viewDidAppear:animated];
+
+ [self startHideBarsTimer:kPhotoHideBarsDelay];
+}
+
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
+ [self cancelHideBarsTimer];
[_scrollView cancelTouches];
[self pauseAction];
if (self.nextViewController) {
@@ -403,14 +439,15 @@ - (void)showBars:(BOOL)show animated:(BOOL)animated {
CGFloat alpha = show ? 1 : 0;
if (alpha == _toolbar.alpha)
return;
+
+ if (show)
+ [self showBarsAnimationDidStop];
if (animated) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:TT_TRANSITION_DURATION];
- [UIView setAnimationDelegate:self];
- if (show) {
- [UIView setAnimationDidStopSelector:@selector(showBarsAnimationDidStop)];
- } else {
+ if (!show) {
+ [UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(hideBarsAnimationDidStop)];
}
} else {
@@ -428,6 +465,14 @@ - (void)showBars:(BOOL)show animated:(BOOL)animated {
if (animated) {
[UIView commitAnimations];
}
+
+ if (show) {
+ if (self.nextViewController == nil)
+ [self startHideBarsTimer:kPhotoHideBarsDelay];
+ else
+ [self cancelHideBarsTimer];
+ } else
+ [self cancelHideBarsTimer];
}
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -574,10 +619,12 @@ - (void)scrollViewDidEndZooming:(TTScrollView*)scrollView {
}
- (void)scrollView:(TTScrollView*)scrollView tapped:(UITouch*)touch {
+ [self cancelHideBarsTimer];
+
if ([self isShowingChrome]) {
[self showBars:NO animated:YES];
} else {
- [self showBars:YES animated:NO];
+ [self showBars:YES animated:YES];
}
}
View
12 src/TTURLCache.m
@@ -15,7 +15,8 @@
@implementation TTURLCache
@synthesize disableDiskCache = _disableDiskCache, disableImageCache = _disableImageCache,
- cachePath = _cachePath, maxPixelCount = _maxPixelCount, invalidationAge = _invalidationAge;
+ cachePath = _cachePath, maxPixelCount = _maxPixelCount, invalidationAge = _invalidationAge,
+ fileReadOptions = _fileReadOptions;
//////////////////////////////////////////////////////////////////////////////////////////////////
// class public
@@ -91,13 +92,15 @@ - (void)storeImage:(UIImage*)image forURL:(NSString*)URL force:(BOOL)force {
- (UIImage*)loadImageFromBundle:(NSString*)URL {
NSString* path = TTPathForBundleResource([URL substringFromIndex:9]);
- NSData* data = [NSData dataWithContentsOfFile:path];
+ // Bundles shouldn't change during NSData object existence.
+ // So we could safely use mapped version here.
+ NSData* data = [NSData dataWithContentsOfMappedFile:path];
return [UIImage imageWithData:data];
}
- (UIImage*)loadImageFromDocuments:(NSString*)URL {
NSString* path = TTPathForDocumentsResource([URL substringFromIndex:12]);
- NSData* data = [NSData dataWithContentsOfFile:path];
+ NSData* data = [NSData dataWithContentsOfFile:path options:_fileReadOptions error:nil];
return [UIImage imageWithData:data];
}
@@ -120,6 +123,7 @@ - (id)init {
_invalidationAge = TT_DEFAULT_CACHE_INVALIDATION_AGE;
_maxPixelCount = 0;
_totalPixelCount = 0;
+ _fileReadOptions = 0;
// XXXjoe Disabling the built-in cache may save memory but it also makes UIWebView slow
// NSURLCache* sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0
@@ -207,7 +211,7 @@ - (NSData*)dataForKey:(NSString*)key expires:(NSTimeInterval)expirationAge
*timestamp = modified;
}
- return [NSData dataWithContentsOfFile:filePath];
+ return [NSData dataWithContentsOfFile:filePath options:_fileReadOptions error:nil];
}
return nil;
View
6 src/TTURLRequestQueue.m
@@ -317,7 +317,9 @@ - (NSData*)loadFromBundle:(NSString*)URL error:(NSError**)error {
NSString* path = TTPathForBundleResource([URL substringFromIndex:9]);
NSFileManager* fm = [NSFileManager defaultManager];
if ([fm fileExistsAtPath:path]) {
- return [NSData dataWithContentsOfFile:path];
+ // Bundles shouldn't change during NSData object existence.
+ // So we could safely use mapped version here.
+ return [NSData dataWithContentsOfMappedFile:path];
} else if (error) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain
code:NSFileReadNoSuchFileError userInfo:nil];
@@ -329,7 +331,7 @@ - (NSData*)loadFromDocuments:(NSString*)URL error:(NSError**)error {
NSString* path = TTPathForDocumentsResource([URL substringFromIndex:12]);
NSFileManager* fm = [NSFileManager defaultManager];
if ([fm fileExistsAtPath:path]) {
- return [NSData dataWithContentsOfFile:path];
+ return [NSData dataWithContentsOfFile:path options:[[TTURLCache sharedCache] fileReadOptions] error:nil];
} else if (error) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain
code:NSFileReadNoSuchFileError userInfo:nil];
View
BIN  src/Three20.bundle/fr.lproj/Localizable.strings
Binary file not shown
View
7 src/Three20/TTPhotoViewController.h
@@ -23,6 +23,8 @@
NSTimer* _slideshowTimer;
NSTimer* _loadTimer;
BOOL _delayLoad;
+ BOOL _hideBarsTimerRunning;
+ BOOL _autoHideBars;
}
/**
@@ -51,6 +53,11 @@
@property(nonatomic,retain) UIImage* defaultImage;
/**
+ * Auto hide bars after delay without user interaction.
+ */
+@property(nonatomic,assign) BOOL autoHideBars;
+
+/**
* The style to use for the caption label.
*/
@property(nonatomic,retain) TTStyle* captionStyle;
View
8 src/Three20/TTURLCache.h
@@ -8,6 +8,7 @@
NSMutableArray* _imageSortedList;
NSUInteger _totalPixelCount;
NSUInteger _maxPixelCount;
+ NSUInteger _fileReadOptions;
NSInteger _totalLoading;
NSTimeInterval _invalidationAge;
BOOL _disableDiskCache;
@@ -43,6 +44,13 @@
@property(nonatomic) NSTimeInterval invalidationAge;
/**
+ * Options for data files reading.
+ *
+ * See "Options for NSData Reading Methods" in documention. Default is zero.
+ */
+@property(nonatomic) NSUInteger fileReadOptions;
+
+/**
* Gets the shared cache singleton used across the application.
*/
+ (TTURLCache*)sharedCache;

No commit comments for this range

Something went wrong with that request. Please try again.