Browse files

Externals.

  • Loading branch information...
1 parent 2fb29e6 commit 635ec61e57a6bd7ad6d16dc7c2e7e28dd8c9adc7 @arturgrigor committed Feb 14, 2012
View
BIN Externals/SVProgressHUD/.DS_Store
Binary file not shown.
View
BIN Externals/SVProgressHUD/SVProgressHUD.bundle/error.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN Externals/SVProgressHUD/SVProgressHUD.bundle/error@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN Externals/SVProgressHUD/SVProgressHUD.bundle/success.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN Externals/SVProgressHUD/SVProgressHUD.bundle/success@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
51 Externals/SVProgressHUD/SVProgressHUD.h
@@ -0,0 +1,51 @@
+//
+// SVProgressHUD.h
+//
+// Created by Sam Vermette on 27.03.11.
+// Copyright 2011 Sam Vermette. All rights reserved.
+//
+// https://github.com/samvermette/SVProgressHUD
+//
+
+#import <UIKit/UIKit.h>
+#import <AvailabilityMacros.h>
+
+// To disable SVProgressHUD's control of the network activity indicator by default,
+// add -DSVPROGRESSHUD_DISABLE_NETWORK_INDICATOR to CFLAGS in build settings.
+
+enum {
+ SVProgressHUDMaskTypeNone = 1, // allow user interactions while HUD is displayed
+ SVProgressHUDMaskTypeClear, // don't allow
+ SVProgressHUDMaskTypeBlack, // don't allow and dim the UI in the back of the HUD
+ SVProgressHUDMaskTypeGradient // don't allow and dim the UI with a a-la-alert-view bg gradient
+};
+
+typedef NSUInteger SVProgressHUDMaskType;
+
+@interface SVProgressHUD : UIWindow
+
++ (void)show;
++ (void)showWithStatus:(NSString*)status;
++ (void)showWithStatus:(NSString*)status networkIndicator:(BOOL)show;
++ (void)showWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType;
++ (void)showWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType networkIndicator:(BOOL)show;
++ (void)showWithMaskType:(SVProgressHUDMaskType)maskType;
++ (void)showWithMaskType:(SVProgressHUDMaskType)maskType networkIndicator:(BOOL)show;
+
++ (void)showSuccessWithStatus:(NSString*)string;
++ (void)setStatus:(NSString*)string; // change the HUD loading status while it's showing
+
++ (void)dismiss; // simply dismiss the HUD with a fade+scale out animation
++ (void)dismissWithSuccess:(NSString*)successString; // also displays the success icon image
++ (void)dismissWithSuccess:(NSString*)successString afterDelay:(NSTimeInterval)seconds;
++ (void)dismissWithError:(NSString*)errorString; // also displays the error icon image
++ (void)dismissWithError:(NSString*)errorString afterDelay:(NSTimeInterval)seconds;
+
+// deprecated Show methods: view and posY params will be ignored
++ (void)showInView:(UIView*)view DEPRECATED_ATTRIBUTE;
++ (void)showInView:(UIView*)view status:(NSString*)string DEPRECATED_ATTRIBUTE;
++ (void)showInView:(UIView*)view status:(NSString*)string networkIndicator:(BOOL)show DEPRECATED_ATTRIBUTE;
++ (void)showInView:(UIView*)view status:(NSString*)string networkIndicator:(BOOL)show posY:(CGFloat)posY DEPRECATED_ATTRIBUTE;
++ (void)showInView:(UIView*)view status:(NSString*)string networkIndicator:(BOOL)show posY:(CGFloat)posY maskType:(SVProgressHUDMaskType)maskType DEPRECATED_ATTRIBUTE;
+
+@end
View
573 Externals/SVProgressHUD/SVProgressHUD.m
@@ -0,0 +1,573 @@
+//
+// SVProgressHUD.m
+//
+// Created by Sam Vermette on 27.03.11.
+// Copyright 2011 Sam Vermette. All rights reserved.
+//
+// https://github.com/samvermette/SVProgressHUD
+//
+
+#import "SVProgressHUD.h"
+#import <QuartzCore/QuartzCore.h>
+
+#ifdef SVPROGRESSHUD_DISABLE_NETWORK_INDICATOR
+#define SVProgressHUDShowNetworkIndicator 0
+#else
+#define SVProgressHUDShowNetworkIndicator 1
+#endif
+
+@interface SVProgressHUD ()
+
+@property (nonatomic, readwrite) SVProgressHUDMaskType maskType;
+@property (nonatomic, readwrite) BOOL showNetworkIndicator;
+@property (nonatomic, retain) NSTimer *fadeOutTimer;
+@property (nonatomic, readonly) UIView *hudView;
+@property (nonatomic, readonly) UILabel *stringLabel;
+@property (nonatomic, readonly) UIImageView *imageView;
+@property (nonatomic, readonly) UIActivityIndicatorView *spinnerView;
+@property (nonatomic, assign) UIWindow *previousKeyWindow;
+@property (nonatomic, readonly) CGFloat visibleKeyboardHeight;
+
+- (void)showWithStatus:(NSString*)string maskType:(SVProgressHUDMaskType)hudMaskType networkIndicator:(BOOL)show;
+- (void)setStatus:(NSString*)string;
+- (void)registerNotifications;
+- (void)moveToPoint:(CGPoint)newCenter rotateAngle:(CGFloat)angle;
+- (void)positionHUD:(NSNotification*)notification;
+
+- (void)dismiss;
+- (void)dismissWithStatus:(NSString*)string error:(BOOL)error;
+- (void)dismissWithStatus:(NSString*)string error:(BOOL)error afterDelay:(NSTimeInterval)seconds;
+
+- (void)memoryWarning:(NSNotification*)notification;
+
+@end
+
+
+@implementation SVProgressHUD
+
+@synthesize hudView, maskType, showNetworkIndicator, fadeOutTimer, stringLabel, imageView, spinnerView, previousKeyWindow, visibleKeyboardHeight;
+
+static SVProgressHUD *sharedView = nil;
+
+- (void)dealloc {
+
+ if(fadeOutTimer != nil)
+ [fadeOutTimer invalidate], [fadeOutTimer release], fadeOutTimer = nil;
+
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+
+ [hudView release];
+ [stringLabel release];
+ [imageView release];
+ [spinnerView release];
+
+ [super dealloc];
+}
+
+- (void)memoryWarning:(NSNotification *)notification {
+
+ if(sharedView.superview == nil) {
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+ [sharedView release], sharedView = nil;
+ [hudView release], hudView = nil;
+ [stringLabel release], stringLabel = nil;
+ [imageView release], imageView = nil;
+ [spinnerView release], spinnerView = nil;
+ }
+}
+
+
++ (SVProgressHUD*)sharedView {
+
+ if(sharedView == nil)
+ sharedView = [[SVProgressHUD alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+
+ return sharedView;
+}
+
+
++ (void)setStatus:(NSString *)string {
+ [[SVProgressHUD sharedView] setStatus:string];
+}
+
+#pragma mark - Show Methods
+
++ (void)show {
+ [SVProgressHUD showWithStatus:nil networkIndicator:SVProgressHUDShowNetworkIndicator];
+}
+
++ (void)showWithStatus:(NSString *)status {
+ [SVProgressHUD showWithStatus:status networkIndicator:SVProgressHUDShowNetworkIndicator];
+}
+
++ (void)showWithMaskType:(SVProgressHUDMaskType)maskType {
+ [SVProgressHUD showWithStatus:nil maskType:maskType networkIndicator:SVProgressHUDShowNetworkIndicator];
+}
+
++ (void)showWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType {
+ [SVProgressHUD showWithStatus:status maskType:maskType networkIndicator:SVProgressHUDShowNetworkIndicator];
+}
+
++ (void)showWithStatus:(NSString *)status networkIndicator:(BOOL)show {
+ [SVProgressHUD showWithStatus:status maskType:SVProgressHUDMaskTypeNone networkIndicator:show];
+}
+
++ (void)showWithMaskType:(SVProgressHUDMaskType)maskType networkIndicator:(BOOL)show {
+ [SVProgressHUD showWithStatus:nil maskType:maskType networkIndicator:show];
+}
+
++ (void)showWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType networkIndicator:(BOOL)show {
+ [[SVProgressHUD sharedView] showWithStatus:status maskType:maskType networkIndicator:show];
+}
+
++ (void)showSuccessWithStatus:(NSString *)string {
+ [SVProgressHUD show];
+ [SVProgressHUD dismissWithSuccess:string afterDelay:1];
+}
+
+
+#pragma mark - Deprecated show methods
+
++ (void)showInView:(UIView*)view {
+ [SVProgressHUD showWithStatus:nil maskType:SVProgressHUDMaskTypeNone networkIndicator:SVProgressHUDShowNetworkIndicator];
+}
+
++ (void)showInView:(UIView*)view status:(NSString*)string {
+ [SVProgressHUD showWithStatus:string maskType:SVProgressHUDMaskTypeNone networkIndicator:SVProgressHUDShowNetworkIndicator];
+}
+
++ (void)showInView:(UIView*)view status:(NSString*)string networkIndicator:(BOOL)show {
+ [SVProgressHUD showWithStatus:string maskType:SVProgressHUDMaskTypeNone networkIndicator:show];
+}
+
++ (void)showInView:(UIView*)view status:(NSString*)string networkIndicator:(BOOL)show posY:(CGFloat)posY {
+ [SVProgressHUD showWithStatus:string maskType:SVProgressHUDMaskTypeNone networkIndicator:show];
+}
+
++ (void)showInView:(UIView*)view status:(NSString*)string networkIndicator:(BOOL)show posY:(CGFloat)posY maskType:(SVProgressHUDMaskType)hudMaskType {
+ [SVProgressHUD showWithStatus:string maskType:hudMaskType networkIndicator:show];
+}
+
+#pragma mark - Dismiss Methods
+
++ (void)dismiss {
+ [[SVProgressHUD sharedView] dismiss];
+}
+
++ (void)dismissWithSuccess:(NSString*)successString {
+ [[SVProgressHUD sharedView] dismissWithStatus:successString error:NO];
+}
+
++ (void)dismissWithSuccess:(NSString *)successString afterDelay:(NSTimeInterval)seconds {
+ [[SVProgressHUD sharedView] dismissWithStatus:successString error:NO afterDelay:seconds];
+}
+
++ (void)dismissWithError:(NSString*)errorString {
+ [[SVProgressHUD sharedView] dismissWithStatus:errorString error:YES];
+}
+
++ (void)dismissWithError:(NSString *)errorString afterDelay:(NSTimeInterval)seconds {
+ [[SVProgressHUD sharedView] dismissWithStatus:errorString error:YES afterDelay:seconds];
+}
+
+
+#pragma mark - Instance Methods
+
+- (id)initWithFrame:(CGRect)frame {
+
+ if ((self = [super initWithFrame:frame])) {
+ self.userInteractionEnabled = NO;
+ self.backgroundColor = [UIColor clearColor];
+ self.alpha = 0;
+ self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+ }
+
+ return self;
+}
+
+- (void)drawRect:(CGRect)rect {
+
+ CGContextRef context = UIGraphicsGetCurrentContext();
+
+ switch (self.maskType) {
+
+ case SVProgressHUDMaskTypeBlack: {
+ [[UIColor colorWithWhite:0 alpha:0.5] set];
+ CGContextFillRect(context, self.bounds);
+ break;
+ }
+
+ case SVProgressHUDMaskTypeGradient: {
+
+ size_t locationsCount = 2;
+ CGFloat locations[2] = {0.0f, 1.0f};
+ CGFloat colors[8] = {0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.75f};
+ CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+ CGGradientRef gradient = CGGradientCreateWithColorComponents(colorSpace, colors, locations, locationsCount);
+ CGColorSpaceRelease(colorSpace);
+
+ CGPoint center = CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2);
+ float radius = MIN(self.bounds.size.width , self.bounds.size.height) ;
+ CGContextDrawRadialGradient (context, gradient, center, 0, center, radius, kCGGradientDrawsAfterEndLocation);
+ CGGradientRelease(gradient);
+
+ break;
+ }
+ }
+}
+
+- (void)setStatus:(NSString *)string {
+
+ CGFloat hudWidth = 100;
+ CGFloat hudHeight = 100;
+ CGFloat stringWidth = 0;
+ CGFloat stringHeight = 0;
+ CGRect labelRect = CGRectZero;
+
+ if(string) {
+ CGSize stringSize = [string sizeWithFont:self.stringLabel.font constrainedToSize:CGSizeMake(200, 300)];
+ stringWidth = stringSize.width;
+ stringHeight = stringSize.height;
+ hudHeight = 80+stringHeight;
+
+ if(stringWidth > hudWidth)
+ hudWidth = ceil(stringWidth/2)*2;
+
+ if(hudHeight > 100) {
+ labelRect = CGRectMake(12, 66, hudWidth, stringHeight);
+ hudWidth+=24;
+ } else {
+ hudWidth+=24;
+ labelRect = CGRectMake(0, 66, hudWidth, stringHeight);
+ }
+ }
+
+ self.hudView.bounds = CGRectMake(0, 0, hudWidth, hudHeight);
+
+ self.imageView.center = CGPointMake(CGRectGetWidth(self.hudView.bounds)/2, 36);
+
+ self.stringLabel.hidden = NO;
+ self.stringLabel.text = string;
+ self.stringLabel.frame = labelRect;
+
+ if(string)
+ self.spinnerView.center = CGPointMake(ceil(CGRectGetWidth(self.hudView.bounds)/2)+0.5, 40.5);
+ else
+ self.spinnerView.center = CGPointMake(ceil(CGRectGetWidth(self.hudView.bounds)/2)+0.5, ceil(self.hudView.bounds.size.height/2)+0.5);
+}
+
+
+- (void)showWithStatus:(NSString*)string maskType:(SVProgressHUDMaskType)hudMaskType networkIndicator:(BOOL)show {
+
+ if(fadeOutTimer != nil)
+ [fadeOutTimer invalidate], [fadeOutTimer release], fadeOutTimer = nil;
+
+ self.showNetworkIndicator = show;
+
+ if(self.showNetworkIndicator)
+ [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
+
+ self.imageView.hidden = YES;
+ self.maskType = hudMaskType;
+
+ [self setStatus:string];
+ [self.spinnerView startAnimating];
+
+ if(self.maskType != SVProgressHUDMaskTypeNone)
+ self.userInteractionEnabled = YES;
+ else
+ self.userInteractionEnabled = NO;
+
+ if(![self isKeyWindow]) {
+
+ [[UIApplication sharedApplication].windows enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
+ UIWindow *window = (UIWindow*)obj;
+ if(window.windowLevel == UIWindowLevelNormal && ![[window class] isEqual:[SVProgressHUD class]]) {
+ self.previousKeyWindow = window;
+ *stop = YES;
+ }
+ }];
+
+ [self makeKeyAndVisible];
+ }
+
+ [self positionHUD:nil];
+
+ if(self.alpha != 1) {
+ [self registerNotifications];
+ self.hudView.transform = CGAffineTransformScale(self.hudView.transform, 1.3, 1.3);
+
+ [UIView animateWithDuration:0.15
+ delay:0
+ options:UIViewAnimationOptionAllowUserInteraction | UIViewAnimationCurveEaseOut | UIViewAnimationOptionBeginFromCurrentState
+ animations:^{
+ self.hudView.transform = CGAffineTransformScale(self.hudView.transform, 1/1.3, 1/1.3);
+ self.alpha = 1;
+ }
+ completion:NULL];
+ }
+
+ [self setNeedsDisplay];
+}
+
+
+- (void)registerNotifications {
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(positionHUD:)
+ name:UIApplicationDidChangeStatusBarOrientationNotification
+ object:nil];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(memoryWarning:)
+ name:UIApplicationDidReceiveMemoryWarningNotification
+ object:nil];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(positionHUD:)
+ name:UIKeyboardWillHideNotification
+ object:nil];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(positionHUD:)
+ name:UIKeyboardDidHideNotification
+ object:nil];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(positionHUD:)
+ name:UIKeyboardWillShowNotification
+ object:nil];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(positionHUD:)
+ name:UIKeyboardDidShowNotification
+ object:nil];
+}
+
+
+- (void)positionHUD:(NSNotification*)notification {
+
+ CGFloat keyboardHeight;
+ double animationDuration;
+
+ if(notification) {
+ NSDictionary* keyboardInfo = [notification userInfo];
+ CGRect keyboardFrame = [[keyboardInfo valueForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue];
+ animationDuration = [[keyboardInfo valueForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
+
+ if(notification.name == UIKeyboardWillShowNotification)
+ keyboardHeight = keyboardFrame.size.height;
+ else
+ keyboardHeight = 0;
+ } else {
+ keyboardHeight = self.visibleKeyboardHeight;
+ }
+
+ UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
+ CGRect orientationFrame = [UIScreen mainScreen].bounds;
+
+ if(UIInterfaceOrientationIsLandscape(orientation)) {
+ float temp = orientationFrame.size.width;
+ orientationFrame.size.width = orientationFrame.size.height;
+ orientationFrame.size.height = temp;
+ }
+
+ CGFloat activeHeight = orientationFrame.size.height;
+
+ if(keyboardHeight > 0)
+ activeHeight += [UIApplication sharedApplication].statusBarFrame.size.height*2;
+
+ activeHeight -= keyboardHeight;
+ CGFloat posY = floor(activeHeight*0.45);
+ CGFloat posX = orientationFrame.size.width/2;
+
+ CGPoint newCenter;
+ CGFloat rotateAngle;
+
+ switch (orientation) {
+ case UIInterfaceOrientationPortraitUpsideDown:
+ rotateAngle = M_PI;
+ newCenter = CGPointMake(posX, orientationFrame.size.height-posY);
+ break;
+ case UIInterfaceOrientationLandscapeLeft:
+ rotateAngle = -M_PI/2.0f;
+ newCenter = CGPointMake(posY, posX);
+ break;
+ case UIInterfaceOrientationLandscapeRight:
+ rotateAngle = M_PI/2.0f;
+ newCenter = CGPointMake(orientationFrame.size.height-posY, posX);
+ break;
+ default: // as UIInterfaceOrientationPortrait
+ rotateAngle = 0.0;
+ newCenter = CGPointMake(posX, posY);
+ break;
+ }
+
+ if(notification) {
+ [UIView animateWithDuration:animationDuration
+ delay:0
+ options:UIViewAnimationOptionAllowUserInteraction
+ animations:^{
+ [self moveToPoint:newCenter rotateAngle:rotateAngle];
+ } completion:NULL];
+ }
+
+ else {
+ [self moveToPoint:newCenter rotateAngle:rotateAngle];
+ }
+
+}
+
+- (void)moveToPoint:(CGPoint)newCenter rotateAngle:(CGFloat)angle {
+ self.hudView.transform = CGAffineTransformMakeRotation(angle);
+ self.hudView.center = newCenter;
+}
+
+
+- (void)dismissWithStatus:(NSString*)string error:(BOOL)error {
+ [self dismissWithStatus:string error:error afterDelay:0.9];
+}
+
+
+- (void)dismissWithStatus:(NSString *)string error:(BOOL)error afterDelay:(NSTimeInterval)seconds {
+
+ if(self.alpha != 1)
+ return;
+
+ if(self.showNetworkIndicator)
+ [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
+
+ if(error)
+ self.imageView.image = [UIImage imageNamed:@"SVProgressHUD.bundle/error.png"];
+ else
+ self.imageView.image = [UIImage imageNamed:@"SVProgressHUD.bundle/success.png"];
+
+ self.imageView.hidden = NO;
+
+ [self setStatus:string];
+
+ [self.spinnerView stopAnimating];
+
+ if(fadeOutTimer != nil)
+ [fadeOutTimer invalidate], [fadeOutTimer release], fadeOutTimer = nil;
+
+ fadeOutTimer = [[NSTimer scheduledTimerWithTimeInterval:seconds target:self selector:@selector(dismiss) userInfo:nil repeats:NO] retain];
+}
+
+- (void)dismiss {
+
+ if(self.showNetworkIndicator)
+ [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
+
+ [UIView animateWithDuration:0.15
+ delay:0
+ options:UIViewAnimationCurveEaseIn | UIViewAnimationOptionAllowUserInteraction
+ animations:^{
+ sharedView.hudView.transform = CGAffineTransformScale(sharedView.hudView.transform, 0.8, 0.8);
+ sharedView.alpha = 0;
+ }
+ completion:^(BOOL finished){
+ if(sharedView.alpha == 0) {
+ [[NSNotificationCenter defaultCenter] removeObserver:sharedView];
+ [sharedView.previousKeyWindow makeKeyWindow];
+ [sharedView release], sharedView = nil;
+
+ // uncomment to make sure UIWindow is gone from app.windows
+ //NSLog(@"%@", [UIApplication sharedApplication].windows);
+ }
+ }];
+}
+
+#pragma mark - Getters
+
+- (UIView *)hudView {
+
+ if(!hudView) {
+ hudView = [[UIView alloc] initWithFrame:CGRectZero];
+ hudView.layer.cornerRadius = 10;
+ hudView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.8];
+ hudView.autoresizingMask = (UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin |
+ UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin);
+
+ [self addSubview:hudView];
+ }
+
+ return hudView;
+}
+
+- (UILabel *)stringLabel {
+
+ if (stringLabel == nil) {
+ stringLabel = [[UILabel alloc] initWithFrame:CGRectZero];
+ stringLabel.textColor = [UIColor whiteColor];
+ stringLabel.backgroundColor = [UIColor clearColor];
+ stringLabel.adjustsFontSizeToFitWidth = YES;
+ stringLabel.textAlignment = UITextAlignmentCenter;
+ stringLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters;
+ stringLabel.font = [UIFont boldSystemFontOfSize:16];
+ stringLabel.shadowColor = [UIColor blackColor];
+ stringLabel.shadowOffset = CGSizeMake(0, -1);
+ stringLabel.numberOfLines = 0;
+ [self.hudView addSubview:stringLabel];
+ }
+
+ return stringLabel;
+}
+
+- (UIImageView *)imageView {
+
+ if (imageView == nil) {
+ imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 28, 28)];
+ [self.hudView addSubview:imageView];
+ }
+
+ return imageView;
+}
+
+- (UIActivityIndicatorView *)spinnerView {
+
+ if (spinnerView == nil) {
+ spinnerView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
+ spinnerView.hidesWhenStopped = YES;
+ spinnerView.bounds = CGRectMake(0, 0, 37, 37);
+ [self.hudView addSubview:spinnerView];
+ }
+
+ return spinnerView;
+}
+
+- (CGFloat)visibleKeyboardHeight {
+
+ NSAutoreleasePool *autoreleasePool = [[NSAutoreleasePool alloc] init];
+
+ UIWindow *keyboardWindow = nil;
+ for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
+ if(![[testWindow class] isEqual:[UIWindow class]] && ![[testWindow class] isEqual:[SVProgressHUD class]]) {
+ keyboardWindow = testWindow;
+ break;
+ }
+ }
+
+ // Locate UIKeyboard.
+ UIView *foundKeyboard = nil;
+ for (UIView *possibleKeyboard in [keyboardWindow subviews]) {
+
+ // iOS 4 sticks the UIKeyboard inside a UIPeripheralHostView.
+ if ([[possibleKeyboard description] hasPrefix:@"<UIPeripheralHostView"]) {
+ possibleKeyboard = [[possibleKeyboard subviews] objectAtIndex:0];
+ }
+
+ if ([[possibleKeyboard description] hasPrefix:@"<UIKeyboard"]) {
+ foundKeyboard = possibleKeyboard;
+ break;
+ }
+ }
+
+ [autoreleasePool release];
+
+ if(foundKeyboard && foundKeyboard.bounds.size.height > 100)
+ return foundKeyboard.bounds.size.height;
+
+ return 0;
+}
+
+@end
View
52 Photo Importer.xcodeproj/project.pbxproj
@@ -8,6 +8,8 @@
/* Begin PBXBuildFile section */
FE04924814E97AFF007587C2 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = FE04924714E97AFF007587C2 /* README.md */; };
+ FE4E239814EA72E500CB333E /* SVProgressHUD.bundle in Resources */ = {isa = PBXBuildFile; fileRef = FE4E239514EA72E500CB333E /* SVProgressHUD.bundle */; };
+ FE4E239914EA72E500CB333E /* SVProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = FE4E239714EA72E500CB333E /* SVProgressHUD.m */; };
FED912B514E95326005C7E12 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FED912B414E95326005C7E12 /* UIKit.framework */; };
FED912B714E95326005C7E12 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FED912B614E95326005C7E12 /* Foundation.framework */; };
FED912B914E95326005C7E12 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FED912B814E95326005C7E12 /* CoreGraphics.framework */; };
@@ -19,12 +21,13 @@
FED912CE14E95326005C7E12 /* AGViewController_iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = FED912CC14E95326005C7E12 /* AGViewController_iPad.xib */; };
FED912D514E95352005C7E12 /* icon.png in Resources */ = {isa = PBXBuildFile; fileRef = FED912D414E95352005C7E12 /* icon.png */; };
FED912D714E95354005C7E12 /* icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FED912D614E95354005C7E12 /* icon@2x.png */; };
- FED912E414E955CD005C7E12 /* SVProgressHUD.bundle in Resources */ = {isa = PBXBuildFile; fileRef = FED912E114E955CD005C7E12 /* SVProgressHUD.bundle */; };
- FED912E514E955CD005C7E12 /* SVProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = FED912E314E955CD005C7E12 /* SVProgressHUD.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
FE04924714E97AFF007587C2 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.md; sourceTree = SOURCE_ROOT; };
+ FE4E239514EA72E500CB333E /* SVProgressHUD.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = SVProgressHUD.bundle; sourceTree = "<group>"; };
+ FE4E239614EA72E500CB333E /* SVProgressHUD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVProgressHUD.h; sourceTree = "<group>"; };
+ FE4E239714EA72E500CB333E /* SVProgressHUD.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVProgressHUD.m; sourceTree = "<group>"; };
FED912B014E95326005C7E12 /* Photo Importer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Photo Importer.app"; sourceTree = BUILT_PRODUCTS_DIR; };
FED912B414E95326005C7E12 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
FED912B614E95326005C7E12 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@@ -41,9 +44,6 @@
FED912CD14E95326005C7E12 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/AGViewController_iPad.xib; sourceTree = "<group>"; };
FED912D414E95352005C7E12 /* icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = icon.png; path = ../icon.png; sourceTree = "<group>"; };
FED912D614E95354005C7E12 /* icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "icon@2x.png"; path = "../icon@2x.png"; sourceTree = "<group>"; };
- FED912E114E955CD005C7E12 /* SVProgressHUD.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = SVProgressHUD.bundle; sourceTree = "<group>"; };
- FED912E214E955CD005C7E12 /* SVProgressHUD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVProgressHUD.h; sourceTree = "<group>"; };
- FED912E314E955CD005C7E12 /* SVProgressHUD.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVProgressHUD.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -60,10 +60,28 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
+ FE4E239314EA72E500CB333E /* Externals */ = {
+ isa = PBXGroup;
+ children = (
+ FE4E239414EA72E500CB333E /* SVProgressHUD */,
+ );
+ path = Externals;
+ sourceTree = "<group>";
+ };
+ FE4E239414EA72E500CB333E /* SVProgressHUD */ = {
+ isa = PBXGroup;
+ children = (
+ FE4E239514EA72E500CB333E /* SVProgressHUD.bundle */,
+ FE4E239614EA72E500CB333E /* SVProgressHUD.h */,
+ FE4E239714EA72E500CB333E /* SVProgressHUD.m */,
+ );
+ path = SVProgressHUD;
+ sourceTree = "<group>";
+ };
FED912A514E95326005C7E12 = {
isa = PBXGroup;
children = (
- FED912DF14E955CD005C7E12 /* Externals */,
+ FE4E239314EA72E500CB333E /* Externals */,
FED912BA14E95326005C7E12 /* Photo Importer */,
FED912B314E95326005C7E12 /* Frameworks */,
FED912B114E95326005C7E12 /* Products */,
@@ -116,24 +134,6 @@
name = "Supporting Files";
sourceTree = "<group>";
};
- FED912DF14E955CD005C7E12 /* Externals */ = {
- isa = PBXGroup;
- children = (
- FED912E014E955CD005C7E12 /* SVProgressHUD */,
- );
- path = Externals;
- sourceTree = "<group>";
- };
- FED912E014E955CD005C7E12 /* SVProgressHUD */ = {
- isa = PBXGroup;
- children = (
- FED912E114E955CD005C7E12 /* SVProgressHUD.bundle */,
- FED912E214E955CD005C7E12 /* SVProgressHUD.h */,
- FED912E314E955CD005C7E12 /* SVProgressHUD.m */,
- );
- path = SVProgressHUD;
- sourceTree = "<group>";
- };
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -190,8 +190,8 @@
FED912CE14E95326005C7E12 /* AGViewController_iPad.xib in Resources */,
FED912D514E95352005C7E12 /* icon.png in Resources */,
FED912D714E95354005C7E12 /* icon@2x.png in Resources */,
- FED912E414E955CD005C7E12 /* SVProgressHUD.bundle in Resources */,
FE04924814E97AFF007587C2 /* README.md in Resources */,
+ FE4E239814EA72E500CB333E /* SVProgressHUD.bundle in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -205,7 +205,7 @@
FED912C114E95326005C7E12 /* main.m in Sources */,
FED912C514E95326005C7E12 /* AGAppDelegate.m in Sources */,
FED912C814E95326005C7E12 /* AGViewController.m in Sources */,
- FED912E514E955CD005C7E12 /* SVProgressHUD.m in Sources */,
+ FE4E239914EA72E500CB333E /* SVProgressHUD.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

0 comments on commit 635ec61

Please sign in to comment.