Skip to content

Commit

Permalink
More minor UI polish, work on making the DB backend more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan Seifert committed Jan 21, 2014
1 parent 9c7b960 commit 2c5c7d4
Show file tree
Hide file tree
Showing 25 changed files with 67 additions and 56 deletions.
Binary file added QuickHAC/App Store Assets/Screenshots/3.5_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QuickHAC/App Store Assets/Screenshots/3.5_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QuickHAC/App Store Assets/Screenshots/4_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QuickHAC/App Store Assets/Screenshots/4_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions QuickHAC/QuickHAC.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,7 @@
CODE_SIGN_ENTITLEMENTS = QuickHAC/QuickHAC.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
EXCLUDED_SOURCE_FILE_NAMES = "";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "QuickHAC/QuickHAC-Prefix.pch";
GCC_WARN_UNDECLARED_SELECTOR = NO;
Expand Down Expand Up @@ -1357,6 +1358,7 @@
CODE_SIGN_ENTITLEMENTS = QuickHAC/QuickHAC.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
EXCLUDED_SOURCE_FILE_NAMES = libTestFlight.a;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "QuickHAC/QuickHAC-Prefix.pch";
GCC_WARN_UNDECLARED_SELECTOR = NO;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions QuickHAC/QuickHAC/Images.xcassets/LoginIcon.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"images" : [
{
"idiom" : "iphone",
"scale" : "1x",
"filename" : "login_icon.png"
},
{
"idiom" : "iphone",
"scale" : "2x",
"filename" : "login_icon@2x.png"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
6 changes: 5 additions & 1 deletion QuickHAC/QuickHAC/QuickHAC-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>755</string>
<string>762</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIBackgroundModes</key>
Expand All @@ -32,6 +32,10 @@
<array>
<string>armv7</string>
</array>
<key>UIStatusBarHidden</key>
<false/>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleBlackTranslucent</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand Down
21 changes: 20 additions & 1 deletion QuickHAC/QuickHAC/SQUAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,25 @@ - (BOOL) application:(UIApplication *) application didFinishLaunchingWithOptions
NSAssert(defaultPreferences, @"Default preferences could not be loaded from URL %@", defaultPreferencesURL);
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultPreferences];

// See if the user updated the app
NSString *appVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleShortVersionString"];
NSString *lastVersion = [[NSUserDefaults standardUserDefaults] stringForKey:@"lastAppVersion"];

if(lastVersion) {
if([lastVersion isEqualToString:appVersion]) {
// not updated since last launch
} else {
NSLog(@"User updated from %@ to %@", lastVersion, appVersion);
[[NSUserDefaults standardUserDefaults] setObject:appVersion forKey:@"lastAppVersion"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
} else {
NSLog(@"User is running %@ for first time", appVersion);

[[NSUserDefaults standardUserDefaults] setObject:appVersion forKey:@"lastAppVersion"];
[[NSUserDefaults standardUserDefaults] synchronize];
}

// Used for the entire singleton thing
sharedDelegate = self;

Expand Down Expand Up @@ -84,7 +103,7 @@ - (BOOL) application:(UIApplication *) application didFinishLaunchingWithOptions
[[UINavigationBar appearance] setBackgroundColor:UIColorFromRGB(kSQUColourNavbarBG)];
[[UINavigationBar appearance] setTitleTextAttributes:@{
NSForegroundColorAttributeName: UIColorFromRGB(kSQUColourTitle),
NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue-Light" size:0.0],
NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue-Medium" size:0.0],
}];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navbar_bg"] forBarMetrics:UIBarMetricsDefault];

Expand Down
9 changes: 5 additions & 4 deletions QuickHAC/QuickHAC/SQUClassDetailController.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ - (id) initWithCourse:(SQUCourse *) course {
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

self.tableView.backgroundView = [[UIView alloc] initWithFrame:self.tableView.frame];
self.tableView.backgroundView.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0];
[self.tableView.backgroundView applyNoiseWithOpacity:0.15f];
self.tableView.backgroundView.backgroundColor = UIColorFromRGB(kSQUColourTableBackground);
// [self.tableView.backgroundView applyNoiseWithOpacity:0.15f];

_course = course;
self.title = course.title;
Expand Down Expand Up @@ -98,7 +98,7 @@ - (void) viewWillAppear:(BOOL) animated {

_titleLayer = [CATextLayer new];
_titleLayer.frame = CGRectMake(0, 4, 200, 28);
_titleLayer.font = (__bridge CFTypeRef)([UIFont fontWithName:@"HelveticaNeue-Light" size:26.0]);
_titleLayer.font = (__bridge CFTypeRef)([UIFont fontWithName:@"HelveticaNeue-Medium" size:26.0]);
_titleLayer.fontSize = 17.0f;
_titleLayer.contentsScale = [UIScreen mainScreen].scale;
_titleLayer.foregroundColor = UIColorFromRGB(kSQUColourTitle).CGColor;
Expand Down Expand Up @@ -179,6 +179,7 @@ - (void) updateCycle {
*/
- (void) changeNoDataDisplay {
if(_currentCycle.categories.count == 0) {
[self.tableView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];
[self showEmptyView];
} else {
[self hideEmptyView];
Expand Down Expand Up @@ -344,7 +345,7 @@ - (void) showEmptyView {

[self.refreshControl endRefreshing];
if(_currentCycle.categories.count != 0) {
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
[self.tableView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];
}

[self.view addSubview:_emptyView];
Expand Down
1 change: 1 addition & 0 deletions QuickHAC/QuickHAC/SQUColourScheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
#define kSQUColourNavbarBG kSQUColourBelizeHole
#define kSQUColourTitle kSQUColourClouds
#define kSQUColourSubtitle 0xe3e8e9
#define kSQUColourTableBackground kSQUColourClouds

#endif
6 changes: 3 additions & 3 deletions QuickHAC/QuickHAC/SQUGradeOverviewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ - (id) initWithStyle:(UITableViewStyle) style {
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

self.tableView.backgroundView = [[UIView alloc] initWithFrame:self.tableView.frame];
self.tableView.backgroundView.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0];
[self.tableView.backgroundView applyNoiseWithOpacity:0.15f];
self.tableView.backgroundView.backgroundColor = UIColorFromRGB(kSQUColourTableBackground);
// [self.tableView.backgroundView applyNoiseWithOpacity:0.15f];

self.title = NSLocalizedString(@"Overview", nil);

Expand All @@ -57,7 +57,7 @@ - (id) initWithStyle:(UITableViewStyle) style {

_titleLayer = [CATextLayer new];
_titleLayer.frame = CGRectMake(0, 4, 200, 28);
_titleLayer.font = (__bridge CFTypeRef)([UIFont fontWithName:@"HelveticaNeue-Light" size:26.0]);
_titleLayer.font = (__bridge CFTypeRef)([UIFont fontWithName:@"HelveticaNeue-Medium" size:26.0]);
_titleLayer.fontSize = 17.0f;
_titleLayer.contentsScale = [UIScreen mainScreen].scale;
_titleLayer.foregroundColor = UIColorFromRGB(kSQUColourTitle).CGColor;
Expand Down
1 change: 0 additions & 1 deletion QuickHAC/QuickHAC/SQUGradeOverviewTableViewCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

- (void) updateUI;

+ (UIColor *) colourizeGrade:(float) grade;
+ (UIColor *) colourForLetterGrade:(NSString *) grade;
+ (CGFloat) cellHeightForCourse:(SQUCourse *) course;

Expand Down
39 changes: 4 additions & 35 deletions QuickHAC/QuickHAC/SQUGradeOverviewTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import "SQUGradeOverviewTableViewCell.h"
#import "SQUCoreData.h"
#import "SQUDistrictManager.h"
#import "SQUUIHelpers.h"
#import "SQUGradeManager.h"
#import "UIColor+SQUColourUtilities.h"

Expand Down Expand Up @@ -325,7 +326,7 @@ - (void) drawCells {

if(cycle.average.unsignedIntegerValue != 0) {
average.string = [NSString stringWithFormat:NSLocalizedString(@"%u", nil), cycle.average.unsignedIntegerValue];
bg.backgroundColor = [SQUGradeOverviewTableViewCell colourizeGrade:cycle.average.floatValue].CGColor;
bg.backgroundColor = [SQUUIHelpers colourizeGrade:cycle.average.floatValue withAsianness:[[NSUserDefaults standardUserDefaults] floatForKey:@"asianness"] andHue:[[NSUserDefaults standardUserDefaults] floatForKey:@"gradesHue"] / 360.0].CGColor;
} else {
average.string = NSLocalizedString(@"-", nil);
bg.backgroundColor = UIColorFromRGB(0xe0e0e0).CGColor;
Expand All @@ -342,15 +343,15 @@ - (void) drawCells {
bg.backgroundColor = UIColorFromRGB(0xe0e0e0).CGColor;
} else {
average.string = [NSString stringWithFormat:NSLocalizedString(@"%u", nil), sem.examGrade.unsignedIntegerValue];
bg.backgroundColor = [SQUGradeOverviewTableViewCell colourizeGrade:sem.examGrade.floatValue].CGColor;
bg.backgroundColor = [SQUUIHelpers colourizeGrade:sem.examGrade.floatValue withAsianness:[[NSUserDefaults standardUserDefaults] floatForKey:@"asianness"] andHue:[[NSUserDefaults standardUserDefaults] floatForKey:@"gradesHue"] / 360.0].CGColor;
}
} else if(offset == 1) { // semester average
if(sem.average.integerValue == -1) {
average.string = NSLocalizedString(@"-", nil);
bg.backgroundColor = UIColorFromRGB(0xe0e0e0).CGColor;
} else {
average.string = [NSString stringWithFormat:NSLocalizedString(@"%u", nil), sem.average.unsignedIntegerValue];
bg.backgroundColor = [SQUGradeOverviewTableViewCell colourizeGrade:sem.average.floatValue].CGColor;
bg.backgroundColor = [SQUUIHelpers colourizeGrade:sem.average.floatValue withAsianness:[[NSUserDefaults standardUserDefaults] floatForKey:@"asianness"] andHue:[[NSUserDefaults standardUserDefaults] floatForKey:@"gradesHue"] / 360.0].CGColor;
}
}
}
Expand Down Expand Up @@ -458,38 +459,6 @@ - (void) updateUI {
[_backgroundLayer addSublayer:_noGradesAvailable];
}

+ (UIColor *) colourizeGrade:(float) grade {
// Makes sure asianness cannot be negative
float asianness = MAX([[NSUserDefaults standardUserDefaults] floatForKey:@"asianness"], 0);

// interpolate a hue gradient and convert to rgb
float h, s, v;

// determine color. ***MAGIC DO NOT TOUCH UNDER ANY CIRCUMSTANCES***
if (grade > 100) {
h = 0.13055;
s = 0;
v = 1;
} else if (grade < 0) {
h = 0;
s = 1;
v = 0.86945;
} else {
h = MIN(0.25 * pow(grade / 100, asianness), 0.13056);
s = 1 - pow(grade / 100, asianness * 2);
v = 0.86945 + h;
}

// Hue must be between 0 and 1.0 for this code
float hue = [[NSUserDefaults standardUserDefaults] floatForKey:@"gradesHue"] / 360.0;

h += hue;
// h %= 1;
if (h < 0) h += 1;

return [UIColor colorWithHue:h saturation:s brightness:v alpha:1.0];
}

+ (UIColor *) colourForLetterGrade:(NSString *) grade {
NSString *letter = [grade substringToIndex:1];
NSDictionary *colours = @{
Expand Down
8 changes: 4 additions & 4 deletions QuickHAC/QuickHAC/SQULoginViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ - (void) viewDidLoad {
_tableMovedAlready = NO;

// Background
_background = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"blurry_bg.jpg"]];
/* _background = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"blurry_bg.jpg"]];
_background.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
_background.alpha = 0.75;
_background.opaque = YES;
Expand Down Expand Up @@ -111,7 +111,7 @@ - (void) viewDidLoad {
group.motionEffects = @[horizontalMotionEffect, verticalMotionEffect];
// Add both effects to your view
[_background addMotionEffect:group];
[_background addMotionEffect:group];*/

self.view.backgroundColor = UIColorFromRGB(kSQUColourConcrete);

Expand Down Expand Up @@ -549,11 +549,11 @@ - (void) studentPickerDidSelect:(SQULoginStudentPicker *) picker withStudent:(SQ

selectedStudent = [students indexOfObject:student];

// Make sure the student is in the DB
if(selectedStudent != NSNotFound) {
// Only update selection if there's no other students in the database
if(students.count == _students.count) {
[[NSUserDefaults standardUserDefaults] setInteger:selectedStudent forKey:@"selectedStudent"];
[[NSUserDefaults standardUserDefaults] synchronize];
[[SQUGradeManager sharedInstance] changeSelectedStudent:student];
}
} else {
NSLog(@"student %@ is fucked man", student);
Expand Down
5 changes: 2 additions & 3 deletions QuickHAC/QuickHAC/SQUSettingsStudents.m
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ - (void) tableView:(UITableView *) tableView commitEditingStyle:(UITableViewCell
if (editingStyle == UITableViewCellEditingStyleDelete) {
NSInteger selectedStudent = [_students indexOfObject:[[SQUGradeManager sharedInstance] getSelectedStudent]];

// Delete object from DB
[[SQUAppDelegate sharedDelegate].managedObjectContext deleteObject:_students[indexPath.row]];
[_students removeObjectAtIndex:indexPath.row];

if(indexPath.row == selectedStudent) {
Expand All @@ -161,9 +163,6 @@ - (void) tableView:(UITableView *) tableView commitEditingStyle:(UITableViewCell
}
}

// Delete object from DB
[[SQUAppDelegate sharedDelegate].managedObjectContext deleteObject:_students[indexPath.row]];

// Do animate-y thing
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];

Expand Down
7 changes: 3 additions & 4 deletions QuickHAC/QuickHAC/SQUUIHelpers.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ @implementation SQUUIHelpers
*/
+ (UIColor *) colourizeGrade:(float) grade withAsianness:(float) asianness andHue:(float) hue {
// Makes sure asianness cannot be negative
NSUInteger asianness_limited = MAX(2, 0);
NSUInteger asianness_limited = MAX(asianness, 0);

// interpolate a hue gradient and convert to rgb
float h, s, v;
Expand All @@ -40,9 +40,8 @@ + (UIColor *) colourizeGrade:(float) grade withAsianness:(float) asianness andHu
}

// apply hue transformation
// h += hue;
// h %= 1;
// if (h < 0) h += 1;
h += hue;
if (h < 0) h += 1;

return [UIColor colorWithHue:h saturation:s brightness:v alpha:1.0];
}
Expand Down
Binary file modified QuickHAC/QuickHAC/en.lproj/Localizable.strings
Binary file not shown.
Binary file modified QuickHAC/assets/miscellaneous/launch_image-568h@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified QuickHAC/assets/miscellaneous/launch_image@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2c5c7d4

Please sign in to comment.