mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-21 11:39:43 +00:00
Merge pull request #405 from erychagov/delete/support-ios-6
Remove all dependences iOS 6
This commit is contained in:
@@ -35,26 +35,10 @@
|
||||
#define __IPHONE_6_1 60100
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Header style depending on the iOS version
|
||||
*/
|
||||
typedef NS_ENUM(NSUInteger, BITAppStoreHeaderStyle) {
|
||||
/**
|
||||
* Default is iOS 6 style
|
||||
*/
|
||||
BITAppStoreHeaderStyleDefault = 0,
|
||||
/**
|
||||
* Draw header in the iOS 7 style
|
||||
*/
|
||||
BITAppStoreHeaderStyleOS7 = 1
|
||||
};
|
||||
|
||||
@interface BITAppStoreHeader : UIView
|
||||
|
||||
@property (nonatomic, copy) NSString *headerText;
|
||||
@property (nonatomic, copy) NSString *subHeaderText;
|
||||
@property (nonatomic, strong) UIImage *iconImage;
|
||||
@property (nonatomic, assign) BITAppStoreHeaderStyle style;
|
||||
|
||||
@end
|
||||
|
||||
@@ -60,7 +60,6 @@
|
||||
if ((self = [super initWithFrame:frame])) {
|
||||
self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
self.backgroundColor = kWhiteBackgroundColorDefault;
|
||||
self.style = BITAppStoreHeaderStyleDefault;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -70,25 +69,14 @@
|
||||
|
||||
- (void)drawRect:(CGRect)rect {
|
||||
CGRect bounds = self.bounds;
|
||||
CGContextRef context = UIGraphicsGetCurrentContext();
|
||||
|
||||
if (self.style == BITAppStoreHeaderStyleDefault) {
|
||||
// draw the gradient
|
||||
NSArray *colors = [NSArray arrayWithObjects:(id)kDarkGrayColor.CGColor, (id)kLightGrayColor.CGColor, nil];
|
||||
CGGradientRef gradient = CGGradientCreateWithColors(CGColorGetColorSpace((__bridge CGColorRef)[colors objectAtIndex:0]), (__bridge CFArrayRef)colors, (CGFloat[2]){0, 1});
|
||||
CGPoint top = CGPointMake(CGRectGetMidX(bounds), bounds.size.height - 3);
|
||||
CGPoint bottom = CGPointMake(CGRectGetMidX(bounds), CGRectGetMaxY(bounds));
|
||||
CGContextDrawLinearGradient(context, gradient, top, bottom, 0);
|
||||
CGGradientRelease(gradient);
|
||||
} else {
|
||||
// draw the line
|
||||
CGContextRef ctx = UIGraphicsGetCurrentContext();
|
||||
CGContextSetLineWidth(ctx, 1.0);
|
||||
CGContextSetStrokeColorWithColor(ctx, kDarkGrayColor.CGColor);
|
||||
CGContextMoveToPoint(ctx, 0, CGRectGetMaxY(bounds));
|
||||
CGContextAddLineToPoint( ctx, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds));
|
||||
CGContextStrokePath(ctx);
|
||||
}
|
||||
|
||||
// draw the line
|
||||
CGContextRef ctx = UIGraphicsGetCurrentContext();
|
||||
CGContextSetLineWidth(ctx, 1.0);
|
||||
CGContextSetStrokeColorWithColor(ctx, kDarkGrayColor.CGColor);
|
||||
CGContextMoveToPoint(ctx, 0, CGRectGetMaxY(bounds));
|
||||
CGContextAddLineToPoint( ctx, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds));
|
||||
CGContextStrokePath(ctx);
|
||||
|
||||
// icon
|
||||
[_iconImage drawAtPoint:CGPointMake(kImageLeftMargin, kImageTopMargin)];
|
||||
@@ -98,8 +86,7 @@
|
||||
|
||||
|
||||
- (void)layoutSubviews {
|
||||
if (self.style == BITAppStoreHeaderStyleOS7)
|
||||
self.backgroundColor = kWhiteBackgroundColorOS7;
|
||||
self.backgroundColor = kWhiteBackgroundColorOS7;
|
||||
|
||||
[super layoutSubviews];
|
||||
|
||||
@@ -151,10 +138,7 @@
|
||||
|
||||
// scale, make borders and reflection
|
||||
_iconImage = bit_imageToFitSize(anIconImage, CGSizeMake(kImageHeight, kImageHeight), YES);
|
||||
CGFloat radius = kImageBorderRadius;
|
||||
if (self.style == BITAppStoreHeaderStyleOS7)
|
||||
radius = kImageBorderRadiusiOS7;
|
||||
_iconImage = bit_roundedCornerImage(_iconImage, radius, 0.0);
|
||||
_iconImage = bit_roundedCornerImage(_iconImage, kImageBorderRadiusiOS7, 0.0);
|
||||
|
||||
[self setNeedsDisplay];
|
||||
}
|
||||
|
||||
@@ -39,21 +39,6 @@
|
||||
|
||||
@end
|
||||
|
||||
|
||||
/**
|
||||
* Cell style depending on the iOS version
|
||||
*/
|
||||
typedef NS_ENUM(NSUInteger, BITFeedbackListViewCellPresentationStyle) {
|
||||
/**
|
||||
* Default is iOS 6 style
|
||||
*/
|
||||
BITFeedbackListViewCellPresentationStyleDefault = 0,
|
||||
/**
|
||||
* Draw cells in the iOS 7 style
|
||||
*/
|
||||
BITFeedbackListViewCellPresentationStyleOS7 = 1
|
||||
};
|
||||
|
||||
/**
|
||||
* Cell background style
|
||||
*/
|
||||
@@ -73,8 +58,6 @@ typedef NS_ENUM(NSUInteger, BITFeedbackListViewCellBackgroundStyle) {
|
||||
|
||||
@property (nonatomic, strong) BITFeedbackMessage *message;
|
||||
|
||||
@property (nonatomic) BITFeedbackListViewCellPresentationStyle style;
|
||||
|
||||
@property (nonatomic) BITFeedbackListViewCellBackgroundStyle backgroundStyle;
|
||||
|
||||
@property (nonatomic, strong) BITAttributedLabel *labelText;
|
||||
|
||||
@@ -88,7 +88,6 @@
|
||||
if (self) {
|
||||
// Initialization code
|
||||
_backgroundStyle = BITFeedbackListViewCellBackgroundStyleNormal;
|
||||
_style = BITFeedbackListViewCellPresentationStyleDefault;
|
||||
|
||||
_message = nil;
|
||||
|
||||
@@ -164,17 +163,9 @@
|
||||
- (UIColor *)backgroundColor {
|
||||
|
||||
if (self.backgroundStyle == BITFeedbackListViewCellBackgroundStyleNormal) {
|
||||
if (self.style == BITFeedbackListViewCellPresentationStyleDefault) {
|
||||
return BACKGROUNDCOLOR_DEFAULT;
|
||||
} else {
|
||||
return BACKGROUNDCOLOR_DEFAULT_OS7;
|
||||
}
|
||||
return BACKGROUNDCOLOR_DEFAULT_OS7;
|
||||
} else {
|
||||
if (self.style == BITFeedbackListViewCellPresentationStyleDefault) {
|
||||
return BACKGROUNDCOLOR_ALTERNATE;
|
||||
} else {
|
||||
return BACKGROUNDCOLOR_ALTERNATE_OS7;
|
||||
}
|
||||
return BACKGROUNDCOLOR_ALTERNATE_OS7;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,9 +265,7 @@
|
||||
self.accessoryBackgroundView.backgroundColor = [self backgroundColor];
|
||||
}
|
||||
|
||||
if (self.style == BITFeedbackListViewCellPresentationStyleDefault) {
|
||||
[self addSubview:self.accessoryBackgroundView];
|
||||
} else if (self.accessoryBackgroundView.superview){
|
||||
if (self.accessoryBackgroundView.superview){
|
||||
[self.accessoryBackgroundView removeFromSuperview];
|
||||
}
|
||||
self.contentView.backgroundColor = [self backgroundColor];
|
||||
|
||||
@@ -138,19 +138,7 @@
|
||||
self.tableView.dataSource = self;
|
||||
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
[self.tableView setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth];
|
||||
if ([self.manager isPreiOS7Environment]) {
|
||||
[self.tableView setBackgroundColor:[UIColor colorWithRed:0.82 green:0.84 blue:0.84 alpha:1]];
|
||||
[self.tableView setSeparatorColor:[UIColor colorWithRed:0.79 green:0.79 blue:0.79 alpha:1]];
|
||||
} else {
|
||||
// [self.tableView setBackgroundColor:[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]];
|
||||
}
|
||||
|
||||
if ([self.manager isPreiOS7Environment]) {
|
||||
self.view.backgroundColor = DEFAULT_BACKGROUNDCOLOR;
|
||||
} else {
|
||||
// self.view.backgroundColor = DEFAULT_BACKGROUNDCOLOR_OS7;
|
||||
}
|
||||
|
||||
|
||||
if ([UIRefreshControl class]) {
|
||||
self.refreshControl = [[UIRefreshControl alloc] init];
|
||||
[self.refreshControl addTarget:self action:@selector(reloadList) forControlEvents:UIControlEventValueChanged];
|
||||
@@ -488,17 +476,14 @@
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
|
||||
if (![self.manager isPreiOS7Environment]) {
|
||||
if (section == 0) {
|
||||
return 30;
|
||||
}
|
||||
if (section == 0) {
|
||||
return 30;
|
||||
}
|
||||
|
||||
return [super tableView:tableView heightForHeaderInSection:section];
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
|
||||
if (![self.manager isPreiOS7Environment] && section == 0) {
|
||||
if (section == 0) {
|
||||
UIView *containerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 30.0f)];
|
||||
UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(16.0f, 5.0f, self.view.frame.size.width - 32.0f, 25.0f)];
|
||||
textLabel.text = [NSString stringWithFormat:BITHockeyLocalizedString(@"HockeyFeedbackListLastUpdated"),
|
||||
@@ -520,7 +505,7 @@
|
||||
static NSString *ButtonBottomIdentifier = @"ButtonBottomCell";
|
||||
static NSString *ButtonDeleteIdentifier = @"ButtonDeleteCell";
|
||||
|
||||
if (indexPath.section == 0 && indexPath.row == 1 && ![self.manager isPreiOS7Environment]) {
|
||||
if (indexPath.section == 0 && indexPath.row == 1) {
|
||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:LastUpdateIdentifier];
|
||||
|
||||
if (!cell) {
|
||||
@@ -537,8 +522,6 @@
|
||||
|
||||
return cell;
|
||||
} else if (indexPath.section == 0 || indexPath.section >= 2) {
|
||||
CGFloat topGap = 0.0f;
|
||||
|
||||
UITableViewCell *cell = nil;
|
||||
|
||||
NSString *identifier = nil;
|
||||
@@ -559,49 +542,24 @@
|
||||
cell.textLabel.font = [UIFont systemFontOfSize:14];
|
||||
cell.textLabel.numberOfLines = 0;
|
||||
cell.accessoryType = UITableViewCellAccessoryNone;
|
||||
|
||||
if ([self.manager isPreiOS7Environment]) {
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
} else {
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleGray;
|
||||
}
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleGray;
|
||||
}
|
||||
|
||||
// button
|
||||
NSString *titleString = nil;
|
||||
SEL actionSelector = nil;
|
||||
|
||||
UIColor *titleColor = BIT_RGBCOLOR(35, 111, 251);
|
||||
if ([self.view respondsToSelector:@selector(tintColor)]){
|
||||
titleColor = self.view.tintColor;
|
||||
}
|
||||
|
||||
UIButton *button = nil;
|
||||
if ([self.manager isPreiOS7Environment]) {
|
||||
button = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
button.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
UIImage *stretchableButton = [bit_imageNamed(@"buttonRoundedRegular.png", BITHOCKEYSDK_BUNDLE) stretchableImageWithLeftCapWidth:10 topCapHeight:0];
|
||||
UIImage *stretchableHighlightedButton = [bit_imageNamed(@"buttonRoundedRegularHighlighted.png", BITHOCKEYSDK_BUNDLE) stretchableImageWithLeftCapWidth:10 topCapHeight:0];
|
||||
[button setBackgroundImage:stretchableButton forState:UIControlStateNormal];
|
||||
[button setBackgroundImage:stretchableHighlightedButton forState:UIControlStateHighlighted];
|
||||
|
||||
[[button titleLabel] setShadowOffset:CGSizeMake(0, 1)];
|
||||
[[button titleLabel] setFont:[UIFont boldSystemFontOfSize:14.0]];
|
||||
|
||||
[button setTitleColor:BUTTON_TEXTCOLOR forState:UIControlStateNormal];
|
||||
[button setTitleShadowColor:BUTTON_TEXTCOLOR_SHADOW forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
|
||||
if (indexPath.section == 0) {
|
||||
topGap = 22;
|
||||
if ([self.manager numberOfMessages] == 0) {
|
||||
titleString = BITHockeyLocalizedString(@"HockeyFeedbackListButtonWriteFeedback");
|
||||
} else {
|
||||
titleString = BITHockeyLocalizedString(@"HockeyFeedbackListButtonWriteResponse");
|
||||
}
|
||||
actionSelector = @selector(newFeedbackAction:);
|
||||
} else if (indexPath.section == _userButtonSection) {
|
||||
topGap = 6.0f;
|
||||
if ([self.manager requireUserName] == BITFeedbackUserDataElementRequired ||
|
||||
([self.manager requireUserName] == BITFeedbackUserDataElementOptional && [self.manager userName] != nil)
|
||||
) {
|
||||
@@ -615,65 +573,14 @@
|
||||
} else {
|
||||
titleString = BITHockeyLocalizedString(@"HockeyFeedbackListButtonUserDataSetEmail");
|
||||
}
|
||||
actionSelector = @selector(setUserDataAction:);
|
||||
} else {
|
||||
topGap = 0.0f;
|
||||
if ([self.manager isPreiOS7Environment]) {
|
||||
[[button titleLabel] setShadowOffset:CGSizeMake(0, -1)];
|
||||
UIImage *stretchableDeleteButton = [bit_imageNamed(@"buttonRoundedDelete.png", BITHOCKEYSDK_BUNDLE) stretchableImageWithLeftCapWidth:10 topCapHeight:0];
|
||||
UIImage *stretchableDeleteHighlightedButton = [bit_imageNamed(@"buttonRoundedDeleteHighlighted.png", BITHOCKEYSDK_BUNDLE) stretchableImageWithLeftCapWidth:10 topCapHeight:0];
|
||||
[button setBackgroundImage:stretchableDeleteButton forState:UIControlStateNormal];
|
||||
[button setBackgroundImage:stretchableDeleteHighlightedButton forState:UIControlStateHighlighted];
|
||||
|
||||
[button setTitleColor:BUTTON_DELETE_TEXTCOLOR forState:UIControlStateNormal];
|
||||
[button setTitleShadowColor:BUTTON_DELETE_TEXTCOLOR_SHADOW forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
titleString = BITHockeyLocalizedString(@"HockeyFeedbackListButtonDeleteAllMessages");
|
||||
titleColor = BIT_RGBCOLOR(251, 35, 35);
|
||||
actionSelector = @selector(deleteAllMessagesAction:);
|
||||
}
|
||||
|
||||
if ([self.manager isPreiOS7Environment]) {
|
||||
if (titleString)
|
||||
[button setTitle:titleString forState:UIControlStateNormal];
|
||||
if (actionSelector)
|
||||
[button addTarget:self action:actionSelector forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
[button setFrame: CGRectMake( 10.0f, topGap + 12.0f, cell.frame.size.width - 20.0f, 42.0f)];
|
||||
[cell addSubview:button];
|
||||
} else {
|
||||
cell.textLabel.text = titleString;
|
||||
cell.textLabel.textColor = titleColor;
|
||||
}
|
||||
|
||||
if ([self.manager isPreiOS7Environment]) {
|
||||
// status label or shadow lines
|
||||
if (indexPath.section == 0) {
|
||||
UILabel *statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 6, cell.frame.size.width, 28)];
|
||||
|
||||
statusLabel.font = [UIFont systemFontOfSize:10];
|
||||
statusLabel.textColor = DEFAULT_TEXTCOLOR;
|
||||
statusLabel.textAlignment = NSTextAlignmentCenter;
|
||||
if ([self.manager isPreiOS7Environment]) {
|
||||
statusLabel.backgroundColor = DEFAULT_BACKGROUNDCOLOR;
|
||||
} else {
|
||||
statusLabel.backgroundColor = DEFAULT_BACKGROUNDCOLOR_OS7;
|
||||
}
|
||||
statusLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
|
||||
statusLabel.text = [NSString stringWithFormat:BITHockeyLocalizedString(@"HockeyFeedbackListLastUpdated"),
|
||||
[self.manager lastCheck] ? [self.lastUpdateDateFormatter stringFromDate:[self.manager lastCheck]] : BITHockeyLocalizedString(@"HockeyFeedbackListNeverUpdated")];
|
||||
|
||||
[cell addSubview:statusLabel];
|
||||
} else if (indexPath.section == 2) {
|
||||
UIView *lineView1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, cell.frame.size.width, 1)];
|
||||
lineView1.backgroundColor = BORDER_COLOR;
|
||||
lineView1.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
[cell addSubview:lineView1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cell.textLabel.text = titleString;
|
||||
cell.textLabel.textColor = titleColor;
|
||||
|
||||
return cell;
|
||||
} else {
|
||||
BITFeedbackListViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
|
||||
@@ -689,13 +596,7 @@
|
||||
} else {
|
||||
cell.backgroundStyle = BITFeedbackListViewCellBackgroundStyleNormal;
|
||||
}
|
||||
|
||||
if ([self.manager isPreiOS7Environment]) {
|
||||
cell.style = BITFeedbackListViewCellPresentationStyleDefault;
|
||||
} else {
|
||||
cell.style = BITFeedbackListViewCellPresentationStyleOS7;
|
||||
}
|
||||
|
||||
|
||||
BITFeedbackMessage *message = [self.manager messageAtIndex:indexPath.row];
|
||||
cell.message = message;
|
||||
cell.labelText.delegate = self;
|
||||
@@ -733,10 +634,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
[self.manager isPreiOS7Environment] ||
|
||||
(![self.manager isPreiOS7Environment] && indexPath.row != 0)
|
||||
) {
|
||||
if (indexPath.row != 0) {
|
||||
UIView *lineView1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, cell.frame.size.width, 1)];
|
||||
lineView1.backgroundColor = BORDER_COLOR;
|
||||
lineView1.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
@@ -790,16 +688,10 @@
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (indexPath.section == 0 ) {
|
||||
if ([self.manager isPreiOS7Environment])
|
||||
return 87;
|
||||
else
|
||||
return 44;
|
||||
return 44;
|
||||
}
|
||||
if (indexPath.section >= 2) {
|
||||
if ([self.manager isPreiOS7Environment])
|
||||
return 65;
|
||||
else
|
||||
return 44;
|
||||
return 44;
|
||||
}
|
||||
|
||||
BITFeedbackMessage *message = [self.manager messageAtIndex:indexPath.row];
|
||||
@@ -809,14 +701,12 @@
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (![self.manager isPreiOS7Environment]) {
|
||||
if (indexPath.section == 0) {
|
||||
[self newFeedbackAction:self];
|
||||
} else if (indexPath.section == _userButtonSection) {
|
||||
[self setUserDataAction:self];
|
||||
} else if (indexPath.section == _deleteButtonSection) {
|
||||
[self deleteAllMessagesAction:self];
|
||||
}
|
||||
if (indexPath.section == 0) {
|
||||
[self newFeedbackAction:self];
|
||||
} else if (indexPath.section == _userButtonSection) {
|
||||
[self setUserDataAction:self];
|
||||
} else if (indexPath.section == _deleteButtonSection) {
|
||||
[self deleteAllMessagesAction:self];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -209,11 +209,7 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
}
|
||||
|
||||
- (BITFeedbackListViewController *)feedbackListViewController:(BOOL)modal {
|
||||
if ([self isPreiOS7Environment]) {
|
||||
return [[BITFeedbackListViewController alloc] initWithModalStyle:modal];
|
||||
} else {
|
||||
return [[BITFeedbackListViewController alloc] initWithStyle:UITableViewStyleGrouped modal:modal];
|
||||
}
|
||||
return [[BITFeedbackListViewController alloc] initWithStyle:UITableViewStyleGrouped modal:modal];
|
||||
}
|
||||
|
||||
- (void)showFeedbackListView {
|
||||
@@ -1218,19 +1214,13 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage
|
||||
}
|
||||
|
||||
- (void)setObservationModeOnScreenshotEnabled:(BOOL)observationModeOnScreenshotEnabled {
|
||||
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) {
|
||||
// Enable/disable screenshot notification
|
||||
if (observationModeOnScreenshotEnabled) {
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenshotNotificationReceived:) name:UIApplicationUserDidTakeScreenshotNotification object:nil];
|
||||
BITHockeyLogVerbose(@"Added observer for UIApplocationUserDidTakeScreenshotNotification.");
|
||||
} else {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationUserDidTakeScreenshotNotification object:nil];
|
||||
BITHockeyLogVerbose(@"Removed observer for UIApplocationUserDidTakeScreenshotNotification.");
|
||||
}
|
||||
// Enable/disable screenshot notification
|
||||
if (observationModeOnScreenshotEnabled) {
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenshotNotificationReceived:) name:UIApplicationUserDidTakeScreenshotNotification object:nil];
|
||||
BITHockeyLogVerbose(@"Added observer for UIApplocationUserDidTakeScreenshotNotification.");
|
||||
} else {
|
||||
if (observationModeOnScreenshotEnabled) {
|
||||
BITHockeyLogWarning(@"BITFeedbackObservationModeOnScreenshot requires iOS 7 or later.");
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationUserDidTakeScreenshotNotification object:nil];
|
||||
BITHockeyLogVerbose(@"Removed observer for UIApplocationUserDidTakeScreenshotNotification.");
|
||||
}
|
||||
|
||||
_observationModeOnScreenshotEnabled = observationModeOnScreenshotEnabled;
|
||||
|
||||
@@ -57,13 +57,7 @@
|
||||
- (instancetype)init {
|
||||
if ((self = [super init])) {
|
||||
_serverURL = BITHOCKEYSDK_URL;
|
||||
|
||||
if ([self isPreiOS7Environment]) {
|
||||
_barStyle = UIBarStyleBlackOpaque;
|
||||
self.navigationBarTintColor = BIT_RGBCOLOR(25, 25, 25);
|
||||
} else {
|
||||
_barStyle = UIBarStyleDefault;
|
||||
}
|
||||
_barStyle = UIBarStyleDefault;
|
||||
_modalPresentationStyle = UIModalPresentationFormSheet;
|
||||
|
||||
NSLocale *enUSPOSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
|
||||
@@ -94,10 +88,6 @@
|
||||
return bit_encodeAppIdentifier(_appIdentifier);
|
||||
}
|
||||
|
||||
- (BOOL)isPreiOS7Environment {
|
||||
return bit_isPreiOS7Environment();
|
||||
}
|
||||
|
||||
- (NSString *)getDevicePlatform {
|
||||
size_t size;
|
||||
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
|
||||
@@ -184,10 +174,8 @@
|
||||
navController.navigationBar.tintColor = self.navigationBarTintColor;
|
||||
} else {
|
||||
// in case of iOS 7 we overwrite the tint color on the navigation bar
|
||||
if (![self isPreiOS7Environment]) {
|
||||
if ([UIWindow instancesRespondToSelector:NSSelectorFromString(@"tintColor")]) {
|
||||
[navController.navigationBar setTintColor:BIT_RGBCOLOR(0, 122, 255)];
|
||||
}
|
||||
if ([UIWindow instancesRespondToSelector:NSSelectorFromString(@"tintColor")]) {
|
||||
[navController.navigationBar setTintColor:BIT_RGBCOLOR(0, 122, 255)];
|
||||
}
|
||||
}
|
||||
navController.modalPresentationStyle = modalPresentationStyle;
|
||||
|
||||
@@ -43,9 +43,6 @@
|
||||
|
||||
- (void)startManager;
|
||||
|
||||
/** Check if the device is running an iOS version previous to iOS 7 */
|
||||
- (BOOL)isPreiOS7Environment;
|
||||
|
||||
/**
|
||||
* by default, just logs the message
|
||||
*
|
||||
|
||||
@@ -57,10 +57,8 @@ NSString *bit_mainBundleIdentifier(void);
|
||||
NSString *bit_encodeAppIdentifier(NSString *inputString);
|
||||
NSString *bit_appIdentifierToGuid(NSString *appIdentifier);
|
||||
NSString *bit_appName(NSString *placeHolderString);
|
||||
NSString *bit_UUIDPreiOS6(void);
|
||||
NSString *bit_UUID(void);
|
||||
NSString *bit_appAnonID(BOOL forceNewAnonID);
|
||||
BOOL bit_isPreiOS7Environment(void);
|
||||
BOOL bit_isPreiOS8Environment(void);
|
||||
BOOL bit_isPreiOS10Environment(void);
|
||||
BOOL bit_isAppStoreReceiptSandbox(void);
|
||||
|
||||
@@ -210,27 +210,8 @@ NSString *bit_appName(NSString *placeHolderString) {
|
||||
return appName;
|
||||
}
|
||||
|
||||
NSString *bit_UUIDPreiOS6(void) {
|
||||
// Create a new UUID
|
||||
CFUUIDRef uuidObj = CFUUIDCreate(nil);
|
||||
|
||||
// Get the string representation of the UUID
|
||||
NSString *resultUUID = (NSString*)CFBridgingRelease(CFUUIDCreateString(nil, uuidObj));
|
||||
CFRelease(uuidObj);
|
||||
|
||||
return resultUUID;
|
||||
}
|
||||
|
||||
NSString *bit_UUID(void) {
|
||||
NSString *resultUUID = nil;
|
||||
|
||||
if ([NSUUID class]) {
|
||||
resultUUID = [[NSUUID UUID] UUIDString];
|
||||
} else {
|
||||
resultUUID = bit_UUIDPreiOS6();
|
||||
}
|
||||
|
||||
return resultUUID;
|
||||
return [[NSUUID UUID] UUIDString];
|
||||
}
|
||||
|
||||
NSString *bit_appAnonID(BOOL forceNewAnonID) {
|
||||
@@ -283,26 +264,6 @@ NSString *bit_appAnonID(BOOL forceNewAnonID) {
|
||||
|
||||
#pragma mark Environment detection
|
||||
|
||||
BOOL bit_isPreiOS7Environment(void) {
|
||||
static BOOL isPreiOS7Environment = YES;
|
||||
static dispatch_once_t checkOS;
|
||||
|
||||
dispatch_once(&checkOS, ^{
|
||||
// NSFoundationVersionNumber_iOS_6_1 = 993.00
|
||||
// We hardcode this, so compiling with iOS 6 is possible while still being able to detect the correct environment
|
||||
|
||||
// runtime check according to
|
||||
// https://developer.apple.com/library/prerelease/ios/documentation/UserExperience/Conceptual/TransitionGuide/SupportingEarlieriOS.html
|
||||
if (floor(NSFoundationVersionNumber) <= 993.00) {
|
||||
isPreiOS7Environment = YES;
|
||||
} else {
|
||||
isPreiOS7Environment = NO;
|
||||
}
|
||||
});
|
||||
|
||||
return isPreiOS7Environment;
|
||||
}
|
||||
|
||||
BOOL bit_isPreiOS8Environment(void) {
|
||||
static BOOL isPreiOS8Environment = YES;
|
||||
static dispatch_once_t checkOS8;
|
||||
@@ -374,11 +335,6 @@ BITEnvironment bit_currentAppEnvironment(void) {
|
||||
return BITEnvironmentOther;
|
||||
}
|
||||
|
||||
// TestFlight is only supported from iOS 8 onwards, so at this point we have to be in the AppStore
|
||||
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
|
||||
return BITEnvironmentAppStore;
|
||||
}
|
||||
|
||||
if (bit_isAppStoreReceiptSandbox()) {
|
||||
return BITEnvironmentTestFlight;
|
||||
}
|
||||
@@ -462,26 +418,7 @@ NSString *bit_base64String(NSData * data, unsigned long length) {
|
||||
// Return ISO 8601 string representation of the date
|
||||
NSString *bit_utcDateString(NSDate *date){
|
||||
static NSDateFormatter *dateFormatter;
|
||||
|
||||
// NSDateFormatter is not thread-safe prior to iOS 7
|
||||
if (bit_isPreiOS7Environment()) {
|
||||
NSMutableDictionary *threadDictionary = [NSThread currentThread].threadDictionary;
|
||||
dateFormatter = threadDictionary[kBITUtcDateFormatter];
|
||||
|
||||
if (!dateFormatter) {
|
||||
dateFormatter = [NSDateFormatter new];
|
||||
NSLocale *enUSPOSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
|
||||
dateFormatter.locale = enUSPOSIXLocale;
|
||||
dateFormatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
|
||||
dateFormatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
|
||||
threadDictionary[kBITUtcDateFormatter] = dateFormatter;
|
||||
}
|
||||
|
||||
NSString *dateString = [dateFormatter stringFromDate:date];
|
||||
|
||||
return dateString;
|
||||
}
|
||||
|
||||
|
||||
static dispatch_once_t dateFormatterToken;
|
||||
dispatch_once(&dateFormatterToken, ^{
|
||||
NSLocale *enUSPOSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
|
||||
@@ -623,13 +560,9 @@ NSString *bit_validAppIconStringFromIcons(NSBundle *resourceBundle, NSArray *ico
|
||||
NSString *currentBestMatch = nil;
|
||||
float currentBestMatchHeight = 0;
|
||||
float bestMatchHeight = 0;
|
||||
|
||||
if (bit_isPreiOS7Environment()) {
|
||||
bestMatchHeight = useiPadIcon ? (useHighResIcon ? 144 : 72) : (useHighResIcon ? 114 : 57);
|
||||
} else {
|
||||
bestMatchHeight = useiPadIcon ? (useHighResIcon ? 152 : 76) : 120;
|
||||
}
|
||||
|
||||
|
||||
bestMatchHeight = useiPadIcon ? (useHighResIcon ? 152 : 76) : 120;
|
||||
|
||||
for(NSString *icon in icons) {
|
||||
// Don't use imageNamed, otherwise unit tests won't find the fixture icon
|
||||
// and using imageWithContentsOfFile doesn't load @2x files with absolut paths (required in tests)
|
||||
|
||||
@@ -356,12 +356,7 @@ typedef NS_ENUM(NSInteger, BITImageAnnotationViewControllerInteractionMode) {
|
||||
if (self.navigationController.navigationBar.alpha == 0 || self.navigationController.navigationBarHidden ){
|
||||
|
||||
[UIView animateWithDuration:0.35f animations:^{
|
||||
|
||||
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) {
|
||||
[self.navigationController setNavigationBarHidden:NO animated:NO];
|
||||
} else {
|
||||
self.navigationController.navigationBar.alpha = 1.0;
|
||||
}
|
||||
[self.navigationController setNavigationBarHidden:NO animated:NO];
|
||||
|
||||
if ([self respondsToSelector:@selector(prefersStatusBarHidden)]) {
|
||||
[self setNeedsStatusBarAppearanceUpdate];
|
||||
@@ -378,12 +373,7 @@ typedef NS_ENUM(NSInteger, BITImageAnnotationViewControllerInteractionMode) {
|
||||
}];
|
||||
} else {
|
||||
[UIView animateWithDuration:0.35f animations:^{
|
||||
|
||||
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) {
|
||||
[self.navigationController setNavigationBarHidden:YES animated:NO];
|
||||
} else {
|
||||
self.navigationController.navigationBar.alpha = 0.0;
|
||||
}
|
||||
[self.navigationController setNavigationBarHidden:YES animated:NO];
|
||||
|
||||
if ([self respondsToSelector:@selector(prefersStatusBarHidden)]) {
|
||||
[self setNeedsStatusBarAppearanceUpdate];
|
||||
|
||||
@@ -56,14 +56,10 @@
|
||||
* Button style depending on the iOS version
|
||||
*/
|
||||
typedef NS_ENUM(NSUInteger, BITStoreButtonStyle) {
|
||||
/**
|
||||
* Default is iOS 6 style
|
||||
*/
|
||||
BITStoreButtonStyleDefault = 0,
|
||||
/**
|
||||
* Draw buttons in the iOS 7 style
|
||||
*/
|
||||
BITStoreButtonStyleOS7 = 1
|
||||
BITStoreButtonStyleOS7 = 0
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -96,13 +96,9 @@
|
||||
|
||||
// show white or gray text, depending on the state
|
||||
if (self.buttonData.isEnabled) {
|
||||
if (self.style == BITStoreButtonStyleDefault) {
|
||||
[self setTitleColor:BIT_RGBCOLOR(106, 106, 106) forState:UIControlStateNormal];
|
||||
} else {
|
||||
[self setTitleColor:BIT_RGBCOLOR(35, 111, 251) forState:UIControlStateNormal];
|
||||
[_defaultBorderLayer setHidden:NO];
|
||||
[_inActiveBorderLayer setHidden:YES];
|
||||
}
|
||||
[self setTitleColor:BIT_RGBCOLOR(35, 111, 251) forState:UIControlStateNormal];
|
||||
[_defaultBorderLayer setHidden:NO];
|
||||
[_inActiveBorderLayer setHidden:YES];
|
||||
} else {
|
||||
[self setTitleColor:BIT_RGBCOLOR(148, 150, 151) forState:UIControlStateNormal];
|
||||
if (self.style == BITStoreButtonStyleOS7) {
|
||||
@@ -176,24 +172,9 @@
|
||||
_customPadding = padding;
|
||||
_style = style;
|
||||
|
||||
if (style == BITStoreButtonStyleDefault) {
|
||||
// main gradient layer
|
||||
CAGradientLayer *gradient = [CAGradientLayer layer];
|
||||
gradient.colors = @[(id)BIT_RGBCOLOR(243, 243, 243).CGColor, (id)BIT_RGBCOLOR(222, 222, 222).CGColor];
|
||||
gradient.locations = @[[NSNumber numberWithFloat:0.0], [NSNumber numberWithFloat:1.0]];
|
||||
gradient.frame = CGRectMake(0.0, 0.0, CGRectGetWidth(frame), CGRectGetHeight(frame));
|
||||
gradient.cornerRadius = 2.5;
|
||||
gradient.needsDisplayOnBoundsChange = YES;
|
||||
[self.layer addSublayer:gradient];
|
||||
}
|
||||
|
||||
// border layers for more sex!
|
||||
_defaultBorderLayer = [CALayer layer];
|
||||
if (style == BITStoreButtonStyleDefault) {
|
||||
_defaultBorderLayer.borderColor = [BIT_RGBCOLOR(191, 191, 191) CGColor];
|
||||
} else {
|
||||
_defaultBorderLayer.borderColor = [BIT_RGBCOLOR(35, 111, 251) CGColor];
|
||||
}
|
||||
_defaultBorderLayer.borderWidth = 1.0;
|
||||
_defaultBorderLayer.frame = CGRectMake(0.0, 0.0, CGRectGetWidth(frame), CGRectGetHeight(frame));
|
||||
_defaultBorderLayer.cornerRadius = 2.5;
|
||||
|
||||
@@ -535,10 +535,7 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
|
||||
BITHockeyLogDebug(@"INFO: Update view already visible, aborting");
|
||||
return;
|
||||
}
|
||||
|
||||
if ([self isPreiOS7Environment])
|
||||
self.barStyle = UIBarStyleBlack;
|
||||
|
||||
|
||||
BITUpdateViewController *updateViewController = [self hockeyViewController:YES];
|
||||
if ([self hasNewerMandatoryVersion] || [self expiryDateReached]) {
|
||||
[updateViewController setMandatoryUpdate: YES];
|
||||
|
||||
@@ -66,11 +66,7 @@
|
||||
#pragma mark - Private
|
||||
|
||||
- (UIColor *)backgroundColor {
|
||||
if ([self.updateManager isPreiOS7Environment]) {
|
||||
return BIT_RGBCOLOR(235, 235, 235);
|
||||
} else {
|
||||
return BIT_RGBCOLOR(255, 255, 255);
|
||||
}
|
||||
return BIT_RGBCOLOR(255, 255, 255);
|
||||
}
|
||||
|
||||
- (void)restoreStoreButtonStateAnimated:(BOOL)animated {
|
||||
@@ -119,10 +115,8 @@
|
||||
tableViewContentHeight += [self tableView:self.tableView heightForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
|
||||
}
|
||||
tableViewContentHeight += self.tableView.tableHeaderView.frame.size.height;
|
||||
if (![self.updateManager isPreiOS7Environment]) {
|
||||
tableViewContentHeight += self.navigationController.navigationBar.frame.size.height;
|
||||
tableViewContentHeight += [UIApplication sharedApplication].statusBarFrame.size.height;
|
||||
}
|
||||
tableViewContentHeight += self.navigationController.navigationBar.frame.size.height;
|
||||
tableViewContentHeight += [UIApplication sharedApplication].statusBarFrame.size.height;
|
||||
|
||||
NSUInteger footerViewSize = kMinPreviousVersionButtonHeight;
|
||||
NSUInteger frameHeight = self.view.frame.size.height;
|
||||
@@ -235,11 +229,7 @@
|
||||
if ([appVersion.notes length] > 0) {
|
||||
cell.webViewContent = [NSString stringWithFormat:@"<p><b>%@</b>%@<br/><small>%@</small></p><p>%@</p>", [appVersion versionString], installed, dateAndSizeString, appVersion.notes];
|
||||
} else {
|
||||
if ([self.updateManager isPreiOS7Environment]) {
|
||||
cell.webViewContent = [NSString stringWithFormat:@"<div style=\"min-height:200px;vertical-align:middle;text-align:center;\">%@</div>", BITHockeyLocalizedString(@"UpdateNoReleaseNotesAvailable")];
|
||||
} else {
|
||||
cell.webViewContent = [NSString stringWithFormat:@"<div style=\"min-height:130px;vertical-align:middle;text-align:center;\">%@</div>", BITHockeyLocalizedString(@"UpdateNoReleaseNotesAvailable")];
|
||||
}
|
||||
cell.webViewContent = [NSString stringWithFormat:@"<div style=\"min-height:130px;vertical-align:middle;text-align:center;\">%@</div>", BITHockeyLocalizedString(@"UpdateNoReleaseNotesAvailable")];
|
||||
}
|
||||
} else {
|
||||
cell.webViewContent = [NSString stringWithFormat:@"<p><b>%@</b>%@<br/><small>%@</small></p><p>%@</p>", [appVersion versionString], installed, dateAndSizeString, [appVersion notesOrEmptyString]];
|
||||
@@ -312,35 +302,16 @@
|
||||
[self.tableView addSubview:topView];
|
||||
|
||||
_appStoreHeader = [[BITAppStoreHeader alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, kAppStoreViewHeight)];
|
||||
if ([self.updateManager isPreiOS7Environment]) {
|
||||
_appStoreHeader.style = BITAppStoreHeaderStyleDefault;
|
||||
} else {
|
||||
_appStoreHeader.style = BITAppStoreHeaderStyleOS7;
|
||||
}
|
||||
[self updateAppStoreHeader];
|
||||
|
||||
NSString *iconFilename = bit_validAppIconFilename([NSBundle mainBundle], [NSBundle mainBundle]);
|
||||
if (iconFilename) {
|
||||
BOOL addGloss = YES;
|
||||
NSNumber *prerendered = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIPrerenderedIcon"];
|
||||
if (prerendered) {
|
||||
addGloss = ![prerendered boolValue];
|
||||
}
|
||||
|
||||
if (addGloss && [self.updateManager isPreiOS7Environment]) {
|
||||
_appStoreHeader.iconImage = [self addGlossToImage:[UIImage imageNamed:iconFilename]];
|
||||
} else {
|
||||
_appStoreHeader.iconImage = [UIImage imageNamed:iconFilename];
|
||||
}
|
||||
_appStoreHeader.iconImage = [UIImage imageNamed:iconFilename];
|
||||
}
|
||||
|
||||
self.tableView.tableHeaderView = _appStoreHeader;
|
||||
|
||||
BITStoreButtonStyle buttonStyle = BITStoreButtonStyleDefault;
|
||||
if (![self.updateManager isPreiOS7Environment]) {
|
||||
buttonStyle = BITStoreButtonStyleOS7;
|
||||
}
|
||||
BITStoreButton *storeButton = [[BITStoreButton alloc] initWithPadding:CGPointMake(5, 58) style:buttonStyle];
|
||||
BITStoreButton *storeButton = [[BITStoreButton alloc] initWithPadding:CGPointMake(5, 58) style:BITStoreButtonStyleOS7];
|
||||
storeButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
|
||||
storeButton.buttonDelegate = self;
|
||||
[self.tableView.tableHeaderView addSubview:storeButton];
|
||||
|
||||
@@ -73,12 +73,6 @@
|
||||
assertThatBool([resultString isEqualToString:@"Placeholder"], isTrue());
|
||||
}
|
||||
|
||||
- (void)testUUIDPreiOS6 {
|
||||
NSString *resultString = bit_UUIDPreiOS6();
|
||||
assertThat(resultString, notNilValue());
|
||||
assertThatInteger([resultString length], equalToInteger(36));
|
||||
}
|
||||
|
||||
- (void)testUUID {
|
||||
NSString *resultString = bit_UUID();
|
||||
assertThat(resultString, notNilValue());
|
||||
|
||||
Reference in New Issue
Block a user