Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Commit

Permalink
Merge branch 'release/3.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
DerAndereAndi committed Sep 26, 2014
2 parents 3072c15 + 476a4de commit 8bf7729
Show file tree
Hide file tree
Showing 157 changed files with 5,059 additions and 1,542 deletions.
33 changes: 33 additions & 0 deletions Classes/BITActivityIndicatorButton.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2012-2014 HockeyApp, Bit Stadium GmbH.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

#import <UIKit/UIKit.h>

@interface BITActivityIndicatorButton : UIButton

- (void)setShowsActivityIndicator:(BOOL)showsIndicator;

@end
76 changes: 76 additions & 0 deletions Classes/BITActivityIndicatorButton.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright (c) 2012-2014 HockeyApp, Bit Stadium GmbH.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

#import "BITActivityIndicatorButton.h"

@interface BITActivityIndicatorButton()

@property (nonatomic, strong) UIActivityIndicatorView *indicator;
@property (nonatomic) BOOL indicatorVisible;

@end

@implementation BITActivityIndicatorButton

- (void)setShowsActivityIndicator:(BOOL)showsIndicator {
if (self.indicatorVisible == showsIndicator){
return;
}

if (!self.indicator){
self.indicator = [[UIActivityIndicatorView alloc] initWithFrame:self.bounds];
[self addSubview:self.indicator];
[self.indicator setColor:[UIColor blackColor]];
}

self.indicatorVisible = showsIndicator;

if (showsIndicator){
[self.indicator startAnimating];
self.indicator.alpha = 1;
self.layer.borderWidth = 1;
self.layer.borderColor = [UIColor lightGrayColor].CGColor;
self.layer.cornerRadius = 5;
self.imageView.image = nil;
} else {
[self.indicator stopAnimating];
self.layer.cornerRadius = 0;
self.indicator.alpha = 0;
self.layer.borderWidth = 0;

}

}

- (void)layoutSubviews {
[super layoutSubviews];

[self.indicator setFrame:self.bounds];

}


@end
2 changes: 1 addition & 1 deletion Classes/BITAppStoreHeader.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ @implementation BITAppStoreHeader {

#pragma mark - NSObject

- (id)initWithFrame:(CGRect)frame {
- (instancetype)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
self.backgroundColor = kWhiteBackgroundColorDefault;
Expand Down
2 changes: 1 addition & 1 deletion Classes/BITAppVersionMetaInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ - (void)encodeWithCoder:(NSCoder *)encoder {
[encoder encodeObject:self.uuids forKey:@"uuids"];
}

- (id)initWithCoder:(NSCoder *)decoder {
- (instancetype)initWithCoder:(NSCoder *)decoder {
if ((self = [super init])) {
self.name = [decoder decodeObjectForKey:@"name"];
self.version = [decoder decodeObjectForKey:@"version"];
Expand Down
33 changes: 33 additions & 0 deletions Classes/BITArrowImageAnnotation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Author: Moritz Haarmann <[email protected]>
*
* Copyright (c) 2012-2014 HockeyApp, Bit Stadium GmbH.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

#import "BITImageAnnotation.h"

@interface BITArrowImageAnnotation : BITImageAnnotation

@end
204 changes: 204 additions & 0 deletions Classes/BITArrowImageAnnotation.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
/*
* Author: Moritz Haarmann <[email protected]>
*
* Copyright (c) 2012-2014 HockeyApp, Bit Stadium GmbH.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

#import "BITArrowImageAnnotation.h"

#define kArrowPointCount 7


@interface BITArrowImageAnnotation()

@property (nonatomic, strong) CAShapeLayer *shapeLayer;
@property (nonatomic, strong) CAShapeLayer *strokeLayer;

@end

@implementation BITArrowImageAnnotation

- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.shapeLayer = [CAShapeLayer layer];
self.shapeLayer.strokeColor = [UIColor whiteColor].CGColor;
self.shapeLayer.lineWidth = 5;
self.shapeLayer.fillColor = [UIColor redColor].CGColor;

self.strokeLayer = [CAShapeLayer layer];
self.strokeLayer.strokeColor = [UIColor redColor].CGColor;
self.strokeLayer.lineWidth = 10;
self.strokeLayer.fillColor = [UIColor clearColor].CGColor;
[self.layer addSublayer:self.strokeLayer];

[self.layer addSublayer:self.shapeLayer];


}
return self;
}

- (void)buildShape {
CGFloat baseWidth = MAX(self.frame.size.width, self.frame.size.height);
CGFloat topHeight = MAX(baseWidth / 3.0f,10);


CGFloat lineWidth = MAX(baseWidth / 10.0f,3);
CGFloat startX, startY, endX, endY;

CGRect boundRect = CGRectInset(self.bounds, 0, 0);
CGFloat arrowLength= sqrt(pow(CGRectGetWidth(boundRect), 2) + pow(CGRectGetHeight(boundRect), 2));
if (arrowLength < 30){

CGFloat factor = 30.f/arrowLength;

boundRect = CGRectApplyAffineTransform(boundRect, CGAffineTransformMakeScale(factor,factor));
}

if ( self.movedDelta.width < 0){
startX = CGRectGetMinX(boundRect);
endX = CGRectGetMaxX(boundRect);
} else {
startX = CGRectGetMaxX(boundRect);
endX = CGRectGetMinX(boundRect);

}

if ( self.movedDelta.height < 0){
startY = CGRectGetMinY(boundRect);
endY = CGRectGetMaxY(boundRect);
} else {
startY = CGRectGetMaxY(boundRect);
endY = CGRectGetMinY(boundRect);

}


if (abs(CGRectGetWidth(boundRect)) < 30 || abs(CGRectGetHeight(boundRect)) < 30){
CGFloat smallerOne = MIN(abs(CGRectGetHeight(boundRect)), abs(CGRectGetWidth(boundRect)));

CGFloat factor = smallerOne/30.f;

CGRectApplyAffineTransform(boundRect, CGAffineTransformMakeScale(factor,factor));
}

UIBezierPath *path = [self bezierPathWithArrowFromPoint:CGPointMake(endX, endY) toPoint:CGPointMake(startX, startY) tailWidth:lineWidth headWidth:topHeight headLength:topHeight];

self.shapeLayer.path = path.CGPath;
self.strokeLayer.path = path.CGPath;
[CATransaction begin];
[CATransaction setAnimationDuration:0];
self.strokeLayer.lineWidth = lineWidth/1.5f;
self.shapeLayer.lineWidth = lineWidth / 3.0f;

[CATransaction commit];

}


- (UIBezierPath *)bezierPathWithArrowFromPoint:(CGPoint)startPoint
toPoint:(CGPoint)endPoint
tailWidth:(CGFloat)tailWidth
headWidth:(CGFloat)headWidth
headLength:(CGFloat)headLength {
CGFloat length = hypotf(endPoint.x - startPoint.x, endPoint.y - startPoint.y);

CGPoint points[kArrowPointCount];
[self getAxisAlignedArrowPoints:points
forLength:length
tailWidth:tailWidth
headWidth:headWidth
headLength:headLength];

CGAffineTransform transform = [self transformForStartPoint:startPoint
endPoint:endPoint
length:length];

CGMutablePathRef cgPath = CGPathCreateMutable();
CGPathAddLines(cgPath, &transform, points, sizeof points / sizeof *points);
CGPathCloseSubpath(cgPath);

UIBezierPath *uiPath = [UIBezierPath bezierPathWithCGPath:cgPath];
CGPathRelease(cgPath);
return uiPath;
}

- (void)getAxisAlignedArrowPoints:(CGPoint[kArrowPointCount])points
forLength:(CGFloat)length
tailWidth:(CGFloat)tailWidth
headWidth:(CGFloat)headWidth
headLength:(CGFloat)headLength {
CGFloat tailLength = length - headLength;
points[0] = CGPointMake(0, tailWidth / 2);
points[1] = CGPointMake(tailLength, tailWidth / 2);
points[2] = CGPointMake(tailLength, headWidth / 2);
points[3] = CGPointMake(length, 0);
points[4] = CGPointMake(tailLength, -headWidth / 2);
points[5] = CGPointMake(tailLength, -tailWidth / 2);
points[6] = CGPointMake(0, -tailWidth / 2);
}

+ (CGAffineTransform)dqd_transformForStartPoint:(CGPoint)startPoint
endPoint:(CGPoint)endPoint
length:(CGFloat)length {
CGFloat cosine = (endPoint.x - startPoint.x) / length;
CGFloat sine = (endPoint.y - startPoint.y) / length;
return (CGAffineTransform){ cosine, sine, -sine, cosine, startPoint.x, startPoint.y };
}

- (CGAffineTransform)transformForStartPoint:(CGPoint)startPoint
endPoint:(CGPoint)endPoint
length:(CGFloat)length {
CGFloat cosine = (endPoint.x - startPoint.x) / length;
CGFloat sine = (endPoint.y - startPoint.y) / length;
return (CGAffineTransform){ cosine, sine, -sine, cosine, startPoint.x, startPoint.y };
}

#pragma mark - UIView

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {

CGPathRef strokePath = CGPathCreateCopyByStrokingPath(self.shapeLayer.path, NULL, fmaxf(90.0f, self.shapeLayer.lineWidth), kCGLineCapRound,kCGLineJoinMiter,0);

BOOL containsPoint = CGPathContainsPoint(strokePath, NULL, point, NO);

CGPathRelease(strokePath);

if (containsPoint){
return self;
} else {
return nil;
}

}

- (void)layoutSubviews{
[super layoutSubviews];

[self buildShape];
}

@end
Empty file modified Classes/BITAttributedLabel.h
100755 → 100644
Empty file.
4 changes: 2 additions & 2 deletions Classes/BITAttributedLabel.m
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ @implementation BITAttributedLabel {
@synthesize verticalAlignment = _verticalAlignment;
@synthesize activeLink = _activeLink;

- (id)initWithFrame:(CGRect)frame {
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (!self) {
return nil;
Expand All @@ -251,7 +251,7 @@ - (id)initWithFrame:(CGRect)frame {
return self;
}

- (id)initWithCoder:(NSCoder *)coder {
- (instancetype)initWithCoder:(NSCoder *)coder {
self = [super initWithCoder:coder];
if (!self) {
return nil;
Expand Down
Loading

0 comments on commit 8bf7729

Please sign in to comment.