Skip to content

Commit

Permalink
A bit of UI polish, some bugfixes about grade update notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan Seifert committed Feb 26, 2014
1 parent 3ff9e26 commit 4744785
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 12 deletions.
4 changes: 2 additions & 2 deletions QuickHAC/QuickHAC.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "E3EEA7E0-939E-45CA-AD8D-3574C38B6E35";
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = 1;
WRAPPER_EXTENSION = app;
};
name = Debug;
Expand Down Expand Up @@ -1317,7 +1317,7 @@
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "E3EEA7E0-939E-45CA-AD8D-3574C38B6E35";
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = 1;
WRAPPER_EXTENSION = app;
};
name = Release;
Expand Down
4 changes: 2 additions & 2 deletions QuickHAC/QuickHAC/QuickHAC-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.1</string>
<string>1.0.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2122</string>
<string>2130</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIBackgroundModes</key>
Expand Down
12 changes: 12 additions & 0 deletions QuickHAC/QuickHAC/SQUClassDetailHeaderCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "SQUColourScheme.h"
#import "SQUCoreData.h"
#import "SQUAppDelegate.h"
#import "SQUGradeOverviewTableViewCell.h"
#import "SQUClassDetailHeaderCell.h"

Expand Down Expand Up @@ -73,6 +74,17 @@ - (void) setCourse:(SQUCourse *) course {
_average.string = [_cycle.average stringValue];

_average.foregroundColor = [SQUGradeOverviewTableViewCell gradeChangeColour:_cycle].CGColor;

if(_cycle.changedSinceLastFetch.boolValue) {
// Reset fetch status
_cycle.changedSinceLastFetch = @(NO);
// Save to DB
NSError *err = nil;
if(![[SQUAppDelegate sharedDelegate].managedObjectContext save:&err]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Database Error", nil) message:err.localizedDescription delegate:nil cancelButtonTitle:NSLocalizedString(@"Dismiss", nil) otherButtonTitles:nil];
[alert show];
}
}
}
}

Expand Down
8 changes: 5 additions & 3 deletions QuickHAC/QuickHAC/SQUGradeManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,11 @@ - (void) updateCycle:(SQUCycle *) cycle withCycleInfo:(NSDictionary *) dict {
* change by either a) viewing the cycle, or b) tapping the notification in
* the notifications drawer.
*/
if(cycle.average.floatValue != [dict[@"average"] floatValue]) {
cycle.changedSinceLastFetch = @(YES);
cycle.preChangeGrade = cycle.average;
if(cycle.average.floatValue != 0) { // prevent notifications for all grades on first launch
if(cycle.average.floatValue != [dict[@"average"] floatValue]) {
cycle.changedSinceLastFetch = @(YES);
cycle.preChangeGrade = cycle.average;
}
}

cycle.last_updated = [NSDate new];
Expand Down
10 changes: 7 additions & 3 deletions QuickHAC/QuickHAC/SQUGradeOverviewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ - (id) initWithStyle:(UITableViewStyle) style {
action:@selector(openSidebar:)];
self.navigationItem.leftBarButtonItem = showSidebar;

UIBarButtonItem *showNotifications = [[UIBarButtonItem alloc]
/* UIBarButtonItem *showNotifications = [[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:@"notificationsIcon"]
style:UIBarButtonItemStyleBordered
target:self
action:@selector(showNotifications:)];
self.navigationItem.rightBarButtonItem = showNotifications;
self.navigationItem.rightBarButtonItem = showNotifications;*/

// Set up the title view container and title text
_navbarTitle = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 44)];
Expand Down Expand Up @@ -195,7 +195,7 @@ - (void) showNotifications:(id) sender {
- (void) reloadData:(SQURelativeRefreshControl *) control {
if([SQUDistrictManager sharedInstance].reachabilityManager.isReachable) {
[[SQUGradeManager sharedInstance] fetchNewClassGradesFromServerWithDoneCallback:^(NSError *error){
[[NSNotificationCenter defaultCenter] postNotificationName:SQUGradesDataUpdatedNotification object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:SQUGradesDataUpdatedNotification object:nil userInfo:@{}];

if(error) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error Updating Grades", nil) message:error.localizedDescription delegate:nil cancelButtonTitle:NSLocalizedString(@"Dismiss", nil) otherButtonTitles:nil];
Expand Down Expand Up @@ -224,6 +224,10 @@ - (void) updateTableNotification:(NSNotification *) notif {
((SQURelativeRefreshControl *) self.refreshControl).date =
[SQUGradeManager sharedInstance].student.lastAveragesUpdate;

if(!notif.userInfo) {
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
}

// Update GPA display
[self updateGPA];
}
Expand Down
4 changes: 2 additions & 2 deletions QuickHAC/QuickHAC/SQUGradeOverviewTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
_backgroundLayer.borderWidth = 0.0;
_backgroundLayer.shadowColor = [UIColor blackColor].CGColor;
_backgroundLayer.shadowOpacity = 0.0625;
_backgroundLayer.shadowRadius = 2.0;
_backgroundLayer.shadowOffset = CGSizeMake(-8.0, -8.0);
_backgroundLayer.shadowRadius = 4.0;
_backgroundLayer.shadowOffset = CGSizeMake(-10.0, -10.0);
_backgroundLayer.cornerRadius = 1.0;
_backgroundLayer.contentsScale = [UIScreen mainScreen].scale;
_backgroundLayer.masksToBounds = NO;
Expand Down

0 comments on commit 4744785

Please sign in to comment.