Update Update view presentation

This commit is contained in:
Andreas Linde 2012-10-30 17:42:23 +01:00
parent d8f61f363a
commit 90f4b017af
6 changed files with 42 additions and 55 deletions

View File

@ -34,7 +34,6 @@
@interface BITAppStoreHeader : UIView
@property (nonatomic, copy) NSString *headerLabel;
@property (nonatomic, copy) NSString *middleHeaderLabel;
@property (nonatomic, copy) NSString *subHeaderLabel;
@property (nonatomic, strong) UIImage *iconImage;

View File

@ -61,7 +61,6 @@
- (void)drawRect:(CGRect)rect {
CGRect bounds = self.bounds;
CGFloat globalWidth = self.frame.size.width;
CGContextRef context = UIGraphicsGetCurrentContext();
// draw the gradient
@ -72,26 +71,38 @@
CGContextDrawLinearGradient(context, gradient, top, bottom, 0);
CGGradientRelease(gradient);
// icon
[_iconImage drawAtPoint:CGPointMake(kImageLeftMargin, kImageTopMargin)];
}
- (void)layoutSubviews {
[super layoutSubviews];
CGFloat globalWidth = self.frame.size.width;
// draw header name
UIColor *mainTextColor = BIT_RGBCOLOR(61, 61, 61);
UIColor *secondaryTextColor = BIT_RGBCOLOR(100, 100, 100);
UIFont *mainFont = [UIFont boldSystemFontOfSize:15];
UIFont *secondaryFont = [UIFont systemFontOfSize:10];
// icon
[_iconImage drawAtPoint:CGPointMake(kImageLeftMargin, kImageTopMargin)];
[mainTextColor set];
[_headerLabel drawInRect:CGRectMake(kTextRow, kImageTopMargin, globalWidth-kTextRow, 20) withFont:mainFont lineBreakMode:UILineBreakModeTailTruncation];
UILabel *headerLabelView = [[UILabel alloc] init];
[headerLabelView setFont:mainFont];
[headerLabelView setFrame:CGRectMake(kTextRow, kImageTopMargin, globalWidth-kTextRow, 20)];
[headerLabelView setTextColor:mainTextColor];
[headerLabelView setBackgroundColor:[UIColor clearColor]];
[headerLabelView setText:_headerLabel];
[self addSubview:headerLabelView];
// middle
[secondaryTextColor set];
[_middleHeaderLabel drawInRect:CGRectMake(kTextRow, kImageTopMargin + 17, globalWidth-kTextRow, 20) withFont:secondaryFont lineBreakMode:UILineBreakModeTailTruncation];
// CGContextSetShadowWithColor(context, CGSizeZero, 0, nil);
// sub
[secondaryTextColor set];
[_subHeaderLabel drawAtPoint:CGPointMake(kTextRow, kImageTopMargin + 29) forWidth:globalWidth-kTextRow withFont:secondaryFont lineBreakMode:UILineBreakModeTailTruncation];
UILabel *middleLabelView = [[UILabel alloc] init];
[middleLabelView setFont:secondaryFont];
[middleLabelView setFrame:CGRectMake(kTextRow, kImageTopMargin + 17, globalWidth-kTextRow, 20)];
[middleLabelView setTextColor:secondaryTextColor];
[middleLabelView setBackgroundColor:[UIColor clearColor]];
[middleLabelView setText:_subHeaderLabel];
[self addSubview:middleLabelView];
}
@ -104,13 +115,6 @@
}
}
- (void)setMiddleHeaderLabel:(NSString *)aMiddleHeaderLabel {
if (_middleHeaderLabel != aMiddleHeaderLabel) {
_middleHeaderLabel = [aMiddleHeaderLabel copy];
[self setNeedsDisplay];
}
}
- (void)setSubHeaderLabel:(NSString *)aSubHeaderLabel {
if (_subHeaderLabel != aSubHeaderLabel) {
_subHeaderLabel = [aSubHeaderLabel copy];

View File

@ -40,18 +40,6 @@
#import "BITAppVersionMetaInfo.h"
// API defines - do not change
#define BETA_DOWNLOAD_TYPE_PROFILE @"profile"
#define BETA_UPDATE_RESULT @"result"
#define BETA_UPDATE_TITLE @"title"
#define BETA_UPDATE_SUBTITLE @"subtitle"
#define BETA_UPDATE_NOTES @"notes"
#define BETA_UPDATE_VERSION @"version"
#define BETA_UPDATE_TIMESTAMP @"timestamp"
#define BETA_UPDATE_APPSIZE @"appsize"
@implementation BITUpdateManager {
NSString *_currentAppVersion;
@ -256,6 +244,8 @@
}
- (void)loadAppCache {
_companyName = [[NSUserDefaults standardUserDefaults] objectForKey:kBITUpdateCurrentCompanyName];
NSData *savedHockeyData = [[NSUserDefaults standardUserDefaults] objectForKey:kBITUpdateArrayOfLastCheck];
NSArray *savedHockeyCheck = nil;
if (savedHockeyData) {
@ -270,6 +260,8 @@
}
- (void)saveAppCache {
if (_companyName)
[[NSUserDefaults standardUserDefaults] setObject:_companyName forKey:kBITUpdateCurrentCompanyName];
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:self.appVersions];
[[NSUserDefaults standardUserDefaults] setObject:data forKey:kBITUpdateArrayOfLastCheck];
[[NSUserDefaults standardUserDefaults] synchronize];
@ -319,6 +311,7 @@
_disableUpdateManager = NO;
_checkForTracker = NO;
_didSetupDidBecomeActiveNotifications = NO;
_companyName = nil;
// set defaults
self.showDirectInstallOption = NO;
@ -610,7 +603,7 @@
return;
}
NSMutableString *parameter = [NSMutableString stringWithFormat:@"api/2/apps/%@?format=json&udid=%@&sdk=%@&sdk_version=%@&uuid=%@",
NSMutableString *parameter = [NSMutableString stringWithFormat:@"api/2/apps/%@?format=json&extended=true&udid=%@&sdk=%@&sdk_version=%@&uuid=%@",
bit_URLEncodedString([self encodedAppIdentifier]),
([self isAppStoreEnvironment] ? @"appstore" : bit_URLEncodedString([self deviceIdentifier])),
BITHOCKEY_NAME,
@ -795,6 +788,7 @@
NSDictionary *json = (NSDictionary *)[NSJSONSerialization JSONObjectWithData:[responseString dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:&error];
self.trackerConfig = (([self checkForTracker] && [[json valueForKey:@"tracker"] isKindOfClass:[NSDictionary class]]) ? [json valueForKey:@"tracker"] : nil);
self.companyName = (([[json valueForKey:@"company"] isKindOfClass:[NSString class]]) ? [json valueForKey:@"company"] : nil);
if (![self isAppStoreEnvironment]) {
NSArray *feedArray = (NSArray *)([self checkForTracker] ? [json valueForKey:@"versions"] : json);

View File

@ -54,6 +54,8 @@
@property (nonatomic, strong) UIView *blockingView;
@property (nonatomic, strong) NSString *companyName;
// if YES, the API will return an existing JMC config
// if NO, the API will return only version information
@property (nonatomic, assign) BOOL checkForTracker;

View File

@ -76,20 +76,7 @@
- (void)updateAppStoreHeader {
BITAppVersionMetaInfo *appVersion = _updateManager.newestAppVersion;
_appStoreHeader.headerLabel = appVersion.name;
// _appStoreHeader.middleHeaderLabel = appVersion versionString];
// NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
// [formatter setDateStyle:NSDateFormatterMediumStyle];
// NSMutableString *subHeaderString = [NSMutableString string];
// if (appVersion.date) {
// [subHeaderString appendString:[formatter stringFromDate:appVersion.date]];
// }
// if (appVersion.size) {
// if ([subHeaderString length]) {
// [subHeaderString appendString:@" - "];
// }
// [subHeaderString appendString:appVersion.sizeInMB];
// }
// _appStoreHeader.subHeaderLabel = subHeaderString;
_appStoreHeader.subHeaderLabel = _updateManager.companyName;
}
- (void)appDidBecomeActive {

View File

@ -41,13 +41,14 @@
#define BITHOCKEY_FEEDBACK_SETTINGS @"BITFeedbackManager.plist"
#define kBITUpdateArrayOfLastCheck @"BITUpdateArrayOfLastCheck"
#define kBITUpdateDateOfLastCheck @"BITUpdateDateOfLastCheck"
#define kBITUpdateDateOfVersionInstallation @"BITUpdateDateOfVersionInstallation"
#define kBITUpdateUsageTimeOfCurrentVersion @"BITUpdateUsageTimeOfCurrentVersion"
#define kBITUpdateUsageTimeForVersionString @"BITUpdateUsageTimeForVersionString"
#define kBITUpdateAuthorizedVersion @"BITUpdateAuthorizedVersion"
#define kBITUpdateAuthorizedToken @"BITUpdateAuthorizedToken"
#define kBITUpdateCurrentCompanyName @"BITUpdateCurrentCompanyName"
#define kBITUpdateArrayOfLastCheck @"BITUpdateArrayOfLastCheck"
#define kBITUpdateDateOfLastCheck @"BITUpdateDateOfLastCheck"
#define kBITUpdateDateOfVersionInstallation @"BITUpdateDateOfVersionInstallation"
#define kBITUpdateUsageTimeOfCurrentVersion @"BITUpdateUsageTimeOfCurrentVersion"
#define kBITUpdateUsageTimeForVersionString @"BITUpdateUsageTimeForVersionString"
#define kBITUpdateAuthorizedVersion @"BITUpdateAuthorizedVersion"
#define kBITUpdateAuthorizedToken @"BITUpdateAuthorizedToken"
#define BITHOCKEYSDK_BUNDLE @"HockeySDKResources.bundle"
#define BITHOCKEYSDK_URL @"https://sdk.hockeyapp.net/"