Skip to content

Commit

Permalink
* Helper function to check if keyboard is visible
Browse files Browse the repository at this point in the history
* Method to show an activity label over photo viewer, for async photo operations
* Fixed: diffstrings.py ignores focus argument for merge command
  • Loading branch information
joehewitt committed Aug 10, 2009
1 parent 2b0f392 commit dd27ba5
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 14 deletions.
25 changes: 13 additions & 12 deletions diffstrings.py
Expand Up @@ -66,20 +66,21 @@ def mergeProjects(projects, sourceLocaleName, focusedLocaleName=None, verbose=Fa
sourceStrings = project.condenseStringSourceFiles()

for localeName, localizedStrings in project.locales.iteritems():
if localizedStrings.name in translations:
translation = translations[localizedStrings.name]
else:
translation = Translation(localizedStrings.name)
translation.open(".", "2")
translations[localizedStrings.name] = translation
if not focusedLocaleName or focusedLocaleName == localeName:
if localizedStrings.name in translations:
translation = translations[localizedStrings.name]
else:
translation = Translation(localizedStrings.name)
translation.open(".", "2")
translations[localizedStrings.name] = translation

if translation.strings:
if verbose:
localizedStrings.mergeReport(sourceStrings, translation)
if translation.strings:
if verbose:
localizedStrings.mergeReport(sourceStrings, translation)

localizedStrings.mergeTranslation(sourceStrings, translation)
if not dryRun:
localizedStrings.save()
localizedStrings.mergeTranslation(sourceStrings, translation)
if not dryRun:
localizedStrings.save()

###################################################################################################

Expand Down
5 changes: 5 additions & 0 deletions src/TTGlobal.m
Expand Up @@ -37,6 +37,11 @@ BOOL TTIsEmptyString(id object) {
return [object isKindOfClass:[NSString class]] && ![(NSString*)object length];
}

BOOL TTIsKeyboardVisible() {
UIWindow* window = [UIApplication sharedApplication].keyWindow;
return !![window performSelector:@selector(firstResponder)];
}

UIInterfaceOrientation TTDeviceOrientation() {
UIInterfaceOrientation orient = [UIDevice currentDevice].orientation;
if (!orient) {
Expand Down
22 changes: 22 additions & 0 deletions src/TTPhotoViewController.m
Expand Up @@ -2,6 +2,7 @@
#import "Three20/TTURLCache.h"
#import "Three20/TTURLRequest.h"
#import "Three20/TTPhotoView.h"
#import "Three20/TTActivityLabel.h"
#import "Three20/TTNavigator.h"

///////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -10,6 +11,7 @@
static const NSTimeInterval kPhotoLoadLongDelay = 0.5;
static const NSTimeInterval kPhotoLoadShortDelay = 0.25;
static const NSTimeInterval kSlideshowInterval = 2;
static const NSInteger kActivityLabelTag = 96;

///////////////////////////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -523,6 +525,7 @@ - (void)model:(id<TTModel>)model didInsertObject:(id)object atIndexPath:(NSIndex

- (void)model:(id<TTModel>)model didDeleteObject:(id)object atIndexPath:(NSIndexPath*)indexPath {
if (object == self.centerPhoto) {
[self showActivity:nil];
[self moveToNextValidPhoto];
[_scrollView reloadData];
[self refresh];
Expand Down Expand Up @@ -658,4 +661,23 @@ - (TTThumbsViewController*)createThumbsViewController {
- (void)didMoveToPhoto:(id<TTPhoto>)photo fromPhoto:(id<TTPhoto>)fromPhoto {
}

- (void)showActivity:(NSString*)title {
if (title) {
TTActivityLabel* label = [[TTActivityLabel alloc] initWithStyle:TTActivityLabelStyleBlackBezel];
label.tag = kActivityLabelTag;
label.text = title;
label.frame = _scrollView.frame;
[_innerView addSubview:label];

_scrollView.scrollEnabled = NO;
} else {
UIView* label = [_innerView viewWithTag:kActivityLabelTag];
if (label) {
[label removeFromSuperview];
}

_scrollView.scrollEnabled = YES;
}
}

@end
4 changes: 2 additions & 2 deletions src/TTURLCache.m
Expand Up @@ -293,10 +293,10 @@ - (void)moveDataForURL:(NSString*)oldURL toURL:(NSString*)newURL {
[_imageSortedList addObject:newKey];
[_imageCache setObject:image forKey:newKey];
}
NSString* oldPath = [self cachePathForURL:oldKey];
NSString* oldPath = [self cachePathForKey:oldKey];
NSFileManager* fm = [NSFileManager defaultManager];
if ([fm fileExistsAtPath:oldPath]) {
NSString* newPath = [self cachePathForURL:newKey];
NSString* newPath = [self cachePathForKey:newKey];
[fm moveItemAtPath:oldPath toPath:newPath error:nil];
}
}
Expand Down
Binary file modified src/Three20.bundle/de.lproj/Localizable.strings
Binary file not shown.
Binary file modified src/Three20.bundle/it.lproj/Localizable.strings
Binary file not shown.
Binary file modified src/Three20.bundle/ja.lproj/Localizable.strings
Binary file not shown.
6 changes: 6 additions & 0 deletions src/Three20/TTGlobal.h
Expand Up @@ -164,6 +164,12 @@ BOOL TTIsEmptyArray(id object);
* Tests if an object is a string which is empty.
*/
BOOL TTIsEmptyString(id object);

/**
* Tests if the keyboard is visible.
*/
BOOL TTIsKeyboardVisible();

/**
* Gets the current device orientation.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/Three20/TTPhotoViewController.h
Expand Up @@ -77,4 +77,9 @@
*/
- (void)didMoveToPhoto:(id<TTPhoto>)photo fromPhoto:(id<TTPhoto>)fromPhoto;

/**
* Shows or hides an activity label on top of the photo.
*/
- (void)showActivity:(NSString*)title;

@end

0 comments on commit dd27ba5

Please sign in to comment.