Improve handling of mandatory flag

- Fix mandatory flag is set but newer version is installed, then the mandatory dialog will still appear (if compareVersionType is set to HockeyComparisonResultDifferent)
- Show mandatory alert if any newer version than the installed one is set to mandatory, and not only the latest one
This commit is contained in:
Andreas Linde 2012-03-08 21:20:00 +01:00
parent 810ecb84b8
commit b9efccfbc6
2 changed files with 21 additions and 4 deletions

View File

@ -229,6 +229,9 @@ typedef enum {
- (NSArray *)apps;
// check if there is any newer version mandatory
- (BOOL)hasNewerMandatoryVersion;
@end
///////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -539,7 +539,7 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
if (isAppStoreEnvironment_) return;
if (!updateAlertShowing_) {
if ([self.app.mandatory boolValue] ) {
if ([self hasNewerMandatoryVersion]) {
UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:BWHockeyLocalize(@"HockeyUpdateAvailable")
message:[NSString stringWithFormat:BWHockeyLocalize(@"HockeyUpdateAlertMandatoryTextWithAppVersion"), [self.app nameAndVersionString]]
delegate:self
@ -805,9 +805,8 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
- (void)checkForUpdate {
if (!updateURL_) return;
if (self.requireAuthorization) return;
if (self.isUpdateAvailable && [self.app.mandatory boolValue]) {
if (self.isUpdateAvailable && [self hasNewerMandatoryVersion]) {
[self showCheckForUpdateAlert_];
return;
}
[self checkForUpdateShowFeedback:NO];
}
@ -1054,7 +1053,7 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
[alert release];
}
if (self.isUpdateAvailable && (self.alwaysShowUpdateReminder || newVersionDiffersFromCachedVersion || [self.app.mandatory boolValue])) {
if (self.isUpdateAvailable && (self.alwaysShowUpdateReminder || newVersionDiffersFromCachedVersion || [self hasNewerMandatoryVersion])) {
if (updateAvailable_ && !currentHockeyViewController_) {
[self showCheckForUpdateAlert_];
}
@ -1067,6 +1066,21 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
}
}
- (BOOL)hasNewerMandatoryVersion {
BOOL result = NO;
for (BWApp *app in self.apps) {
if ([app.version isEqualToString:self.currentAppVersion]) {
break;
}
if ([app.mandatory boolValue]) {
result = YES;
}
}
return result;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark -