Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remaining 1.4.1 Tasks #566

Merged
merged 7 commits into from
May 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 1.4.1.7

New:

* Consolidated the colors used inside the app to reduce number of shades of a color used
* Animate the alarm add button like sleep sounds to make it consistent
* Overriding the User-Agent header to something that is standard between Android and iOS

Fixes:

* Fixed the added delay after releasing the touch event from the sensor history graph

## 1.4.1.6

New:
Expand Down
2 changes: 1 addition & 1 deletion SenseWidget/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>1.4.1.6</string>
<string>1.4.1.7</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionMainStoryboard</key>
Expand Down
57 changes: 29 additions & 28 deletions SleepModel/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions SleepModel/HEMAccountPresenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ - (void)bindWithTableView:(UITableView*)tableView {
[tableView setTableFooterView:footerView];
[tableView setBackgroundColor:[UIColor clearColor]];
[tableView setBackgroundView:nil];
[tableView setSeparatorColor:[UIColor separatorColor]];
[tableView setDelegate:self];
[tableView setDataSource:self];
[tableView setSectionFooterHeight:0.0f];
Expand Down Expand Up @@ -231,7 +230,7 @@ - (NSAttributedString*)enhancedAudioNote {
if (!_enhancedAudioNote) {
NSString* note = NSLocalizedString(@"settings.enhanced-audio.desc", nil);
NSDictionary* attributes = @{NSFontAttributeName : [UIFont settingsHelpFont],
NSForegroundColorAttributeName : [UIColor settingsCellTitleTextColor]};
NSForegroundColorAttributeName : [UIColor textColor]};
_enhancedAudioNote = [[NSAttributedString alloc] initWithString:note attributes:attributes];
}
return _enhancedAudioNote;
Expand Down Expand Up @@ -378,9 +377,9 @@ - (void)tableView:(UITableView *)tableView
willDisplayCell:(UITableViewCell *)cell
forRowAtIndexPath:(NSIndexPath *)indexPath {
[[cell textLabel] setFont:[UIFont settingsTableCellFont]];
[[cell textLabel] setTextColor:[UIColor settingsCellTitleTextColor]];
[[cell textLabel] setTextColor:[UIColor textColor]];

[[cell detailTextLabel] setTextColor:[UIColor settingsValueTextColor]];
[[cell detailTextLabel] setTextColor:[UIColor detailTextColor]];
[[cell detailTextLabel] setFont:[UIFont settingsTableCellDetailFont]];
[[cell detailTextLabel] setText:nil];

Expand Down
2 changes: 1 addition & 1 deletion SleepModel/HEMActionButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ - (void)setDefaults {
self.layer.cornerRadius = 3;
self.backgroundColor = [UIColor tintColor];
[self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[self setTitleColor:[UIColor actionButtonTextColor]
[self setTitleColor:[UIColor whiteColor]
forState:UIControlStateDisabled];
[self.titleLabel setFont:[UIFont primaryButtonFont]];
[self setTitleEdgeInsets:UIEdgeInsetsMake(kHEMActionTitleTopOffset, 0.0f, 0.0f, 0.0f)];
Expand Down
2 changes: 1 addition & 1 deletion SleepModel/HEMActionSheetOptionCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ - (void)setOptionTitle:(NSString*)title

- (void)configureSelectedBackground {
UIView* view = [[UIView alloc] initWithFrame:[[self contentView] bounds]];
[view setBackgroundColor:[UIColor actionSheetSelectedColor]];
[view setBackgroundColor:[UIColor lightBackgroundColor]];
[view setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
[self setSelectedBackgroundView:view];
}
Expand Down
2 changes: 1 addition & 1 deletion SleepModel/HEMActionSheetTitleView.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ - (void)configureContentWithTitle:(NSString*)title andDescription:(NSString*)des
}

- (void)drawRect:(CGRect)rect {
UIColor* lineColor = [UIColor actionSheetSeparatorColor];
UIColor* lineColor = [UIColor separatorColor];

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
Expand Down
4 changes: 2 additions & 2 deletions SleepModel/HEMActionSheetViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
-(void)setDefaults {
[self setModalPresentationStyle:UIModalPresentationOverCurrentContext];
[self setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[[self optionTableView] setSeparatorColor:[UIColor actionSheetSeparatorColor]];
[[self optionTableView] setSeparatorColor:[UIColor separatorColor]];
[[self optionTableView] setTableFooterView:[[UIView alloc] init]];
}

Expand Down Expand Up @@ -245,7 +245,7 @@ - (void)configureShadedOverlay {
self.shadedOverlayView.isAccessibilityElement = YES;
self.shadedOverlayView.accessibilityTraits = UIAccessibilityTraitButton;
self.shadedOverlayView.accessibilityValue = NSLocalizedString(@"actions.cancel", nil);
self.shadedOverlayView.backgroundColor = [UIColor alertBackgroundColor];
self.shadedOverlayView.backgroundColor = [UIColor seeThroughBackgroundColor];
}

- (void)configureTableViewHeader {
Expand Down
6 changes: 3 additions & 3 deletions SleepModel/HEMActionView.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ - (CGRect)titleFrame {
- (void)addTitleLabelWithText:(NSString*)title {
UILabel* label = [[UILabel alloc] initWithFrame:[self titleFrame]];
[label setBackgroundColor:[UIColor clearColor]];
[label setTextColor:[UIColor actionViewTitleTextColor]];
[label setTextColor:[UIColor grey4]];
[label setFont:[UIFont actionViewTitleFont]];
[label setTextAlignment:NSTextAlignmentCenter];
[label setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
Expand Down Expand Up @@ -170,7 +170,7 @@ - (void)addActionButtons {
[container setTranslatesAutoresizingMaskIntoConstraints:YES];

NSString* cancelText = [NSLocalizedString(@"actions.skip", nil) uppercaseString];
UIColor * cancelColor = [UIColor actionViewCancelButtonTextColor];
UIColor * cancelColor = [UIColor grey4];
UIButton* cancelButton = [self actionButtonWithText:cancelText color:cancelColor andXOrigin:0.0f];
[container addSubview:cancelButton];

Expand Down Expand Up @@ -207,7 +207,7 @@ - (void)drawRect:(CGRect)rect {
if (![[self okButton] isHidden]) {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextSetStrokeColorWithColor(context, [[UIColor buttonDividerColor] CGColor]);
CGContextSetStrokeColorWithColor(context, [[UIColor separatorColor] CGColor]);
CGContextSetLineWidth(context, HEMActionButtonDividerWidth);

// add a line at the middle of the view, at the bottom where the button container is
Expand Down
2 changes: 1 addition & 1 deletion SleepModel/HEMActivityCoverView.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ - (void)setup {
- (void)addLabel {
[self setActivityLabel:[[UILabel alloc] init]];
[[self activityLabel] setFont:[UIFont onboardingActivityFontLarge]];
[[self activityLabel] setTextColor:[UIColor onboardingGrayColor]];
[[self activityLabel] setTextColor:[UIColor grey6]];
[[self activityLabel] setTextAlignment:NSTextAlignmentCenter];
[[self activityLabel] setNumberOfLines:0];

Expand Down
74 changes: 69 additions & 5 deletions SleepModel/HEMAlarmListViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
EmptyStateRowCount = 1,
};

static CGFloat const HEMAlarmLoadAnimeDuration = 0.5f;

@interface HEMAlarmListViewController () <UICollectionViewDataSource, UICollectionViewDelegate,
UICollectionViewDelegateFlowLayout, HEMAlarmControllerDelegate>

Expand All @@ -47,6 +49,9 @@ @interface HEMAlarmListViewController () <UICollectionViewDataSource, UICollecti
@property (nonatomic, strong) NSAttributedString* attributedNoAlarmText;
@property (nonatomic, assign) BOOL launchNewAlarmOnLoad;
@property (nonatomic, strong) HEMAlarmService* alarmService;
@property (nonatomic, assign) CGFloat origAddButtonBottomValue;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *addButtonBottomConstraint;
@property (strong, nonatomic) HEMActivityIndicatorView* addButtonIndicator;
@end

@implementation HEMAlarmListViewController
Expand Down Expand Up @@ -113,6 +118,13 @@ - (void)viewDidBecomeActive {
[self refreshData];
}

- (void)didMoveToParentViewController:(UIViewController *)parent {
[super didMoveToParentViewController:parent];
if (!parent) {
[self hideAddButton];
}
}

- (void)didReceiveMemoryWarning {
if (![self isViewLoaded] || !self.view.window) {
self.alarms = nil;
Expand All @@ -121,10 +133,19 @@ - (void)didReceiveMemoryWarning {
}

- (void)configureAddButton {
CGFloat origConstant = [[self addButtonBottomConstraint] constant];
[self setOrigAddButtonBottomValue:origConstant];

[self.addButton setEnabled:YES];
[[self addButton] setTitle:@"" forState:UIControlStateDisabled];
[self.addButton addTarget:self action:@selector(touchDownAddAlarmButton:) forControlEvents:UIControlEventTouchDown];
[self.addButton addTarget:self
action:@selector(touchUpOutsideAddAlarmButton:)
forControlEvents:UIControlEventTouchUpOutside];

// hide the button initially
[self hideAddButton];
[self setAddButtonIndicator:[self activityIndicator]];
}

- (void)configureDateFormatters {
Expand All @@ -136,13 +157,25 @@ - (void)configureDateFormatters {
self.meridiemFormatter.dateFormat = @"a";
}

- (HEMActivityIndicatorView*)activityIndicator {
CGSize buttonSize = [[self addButton] bounds].size;
UIImage* indicatorImage = [UIImage imageNamed:@"loaderWhite"];
CGRect indicatorFrame = CGRectZero;
indicatorFrame.size = indicatorImage.size;
indicatorFrame.origin.x = (buttonSize.width - indicatorImage.size.width) / 2.f;
indicatorFrame.origin.y = (buttonSize.height - indicatorImage.size.height) / 2.f;
return [[HEMActivityIndicatorView alloc] initWithImage:indicatorImage
andFrame:indicatorFrame];
}

- (void)refreshData {
if ([self isLoading])
return;

self.addButton.enabled = NO;

self.loading = !self.alarms; // only show indicator if there's no alarms at all

[self showAddButtonAsLoading:YES];

__weak typeof(self) weakSelf = self;
[HEMAlarmUtils refreshAlarmsFromPresentingController:self completion:^(NSError *error) {
__strong typeof(weakSelf) strongSelf = weakSelf;
Expand All @@ -153,7 +186,6 @@ - (void)refreshData {
[strongSelf displayLoadingError];
[strongSelf setLaunchNewAlarmOnLoad:NO];
} else {
[[strongSelf addButton] setEnabled:YES];
[strongSelf reloadData];
if ([strongSelf launchNewAlarmOnLoad]) {
[strongSelf addNewAlarm:nil];
Expand All @@ -163,14 +195,45 @@ - (void)refreshData {
}];
}

- (void)hideAddButton {
CGFloat height = CGRectGetHeight([[self addButton] bounds]);
CGFloat hiddenBottom = absCGFloat([self origAddButtonBottomValue]) + height;
[[self addButtonBottomConstraint] setConstant:hiddenBottom];
}

- (void)showAddButton {
[self showAddButtonAsLoading:NO];

if ([[self addButtonBottomConstraint] constant] != [self origAddButtonBottomValue]) {
[UIView animateWithDuration:HEMAlarmLoadAnimeDuration animations:^{
[[self addButtonBottomConstraint] setConstant:[self origAddButtonBottomValue]];
[[self addButton] layoutIfNeeded];
}];
}
}

- (void)showAddButtonAsLoading:(BOOL)loading {
if (loading) {
[[self addButton] setEnabled:NO];
[[self addButton] addSubview:[self addButtonIndicator]];
[[self addButtonIndicator] start];
} else {
[[self addButton] setEnabled:YES];
[[self addButtonIndicator] stop];
[[self addButtonIndicator] removeFromSuperview];
}
}

- (void)displayLoadingError {
[self setLoadingFailed:YES];
[[self addButton] setEnabled:NO];
[self hideAddButton];
[self setAlarms:nil];
[[self collectionView] reloadData];
}

- (void)reloadData {
[self showAddButton];

NSArray *cachedAlarms = [self sortedCachedAlarms];
if ([self.alarms isEqualToArray:cachedAlarms]) {
if ([self isLoading]) {
Expand All @@ -182,7 +245,7 @@ - (void)reloadData {

self.loading = NO;
self.alarms = cachedAlarms;
self.addButton.hidden = self.alarms.count == 0;
[[self addButton] setHidden:[[self alarms] count] == 0];
[self.collectionView reloadData];
}

Expand Down Expand Up @@ -346,6 +409,7 @@ - (void)configureCollectionView {
sectionInsets.bottom = CGRectGetHeight(bounds) - CGRectGetMinY(self.addButton.frame);
layout.sectionInset = sectionInsets;
self.collectionView.hidden = YES;
self.collectionView.backgroundColor = [UIColor backgroundColor];
}

#pragma mark UICollectionViewDatasource
Expand Down
4 changes: 2 additions & 2 deletions SleepModel/HEMAlarmPresenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ - (void)reloadWithAlarmSoundMetadata {

- (void)bindWithClockPickerView:(HEMClockPickerView*)clockPicker {
[clockPicker setDelegate:self];
[clockPicker setBackgroundColor:[UIColor alarmClockViewBackgroundColor]];
[clockPicker setBackgroundColor:[UIColor lightBackgroundColor]];
[self setClockPicker:clockPicker];
}

Expand Down Expand Up @@ -190,7 +190,7 @@ - (UIView*)artificialBorderInView:(UIView*)view {
borderFrame.size.width = width;
borderFrame.size.height = HEMStyleButtonContainerBorderWidth;
UIView* border = [[UIView alloc] initWithFrame:borderFrame];
[border setBackgroundColor:[UIColor borderColor]];
[border setBackgroundColor:[UIColor separatorColor]];
return border;
}

Expand Down
2 changes: 1 addition & 1 deletion SleepModel/HEMAlertView.m
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ - (UIButton *)buttonWithTitle:(NSString *)title style:(HEMAlertViewButtonStyle)s
button.titleLabel.font = [UIFont alertBoldButtonFont];
break;
case HEMAlertViewButtonStyleGrayText:
[button setTitleColor:[UIColor alertBooleanSecondaryColor] forState:UIControlStateNormal];
[button setTitleColor:[UIColor grey4] forState:UIControlStateNormal];
button.titleLabel.font = [UIFont alertLightButtonFont];
break;
case HEMAlertViewButtonStyleBlueText:
Expand Down
4 changes: 2 additions & 2 deletions SleepModel/HEMAlertViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ - (void)addBackgroundView {
UIImageView* imageView = [[UIImageView alloc] initWithFrame:[[self view] bounds]];
imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
imageView.translatesAutoresizingMaskIntoConstraints = YES;
imageView.image = [[self viewToShowThrough] snapshotWithTint:[UIColor alertBackgroundColor]];
imageView.image = [[self viewToShowThrough] snapshotWithTint:[UIColor seeThroughBackgroundColor]];
[[self view] insertSubview:imageView atIndex:0];
} else {
[[self view] setBackgroundColor:[UIColor alertBackgroundColor]];
[[self view] setBackgroundColor:[UIColor seeThroughBackgroundColor]];
}
}

Expand Down
13 changes: 12 additions & 1 deletion SleepModel/HEMAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ @implementation HEMAppDelegate

static NSString* const HEMAppFirstLaunch = @"HEMAppFirstLaunch";
static NSString* const HEMApiXVersionHeader = @"X-Client-Version";
static NSString* const HEMApiUserAgentFormat = @"%@/%@ Platform/iOS OS/%@";

static NSString* const HEMShortcutTypeAddAlarm = @"is.hello.sense.shortcut.addalarm";
static NSString* const HEMShortcutTypeEditAlarms = @"is.hello.sense.shortcut.editalarms";
Expand Down Expand Up @@ -157,10 +158,18 @@ - (void)syncHealthKit {
}

- (void)configureAPI {
// User-Agent should be in the format: Sense/<App version> Platform/<iOS> OS/<Version>
UIDevice* device = [UIDevice currentDevice];
NSBundle* bundle = [NSBundle mainBundle];
NSString* appName = [bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
NSString* version = [bundle objectForInfoDictionaryKey:@"CFBundleVersion"];
NSString* osVersion = [device systemVersion];
NSString* userAgent = [NSString stringWithFormat:HEMApiUserAgentFormat, appName, version, osVersion];
NSString* path = [HEMConfig stringForConfig:HEMConfAPIURL];
NSString* clientID = [HEMConfig stringForConfig:HEMConfClientId];
NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];

[SENAPIClient setBaseURLFromPath:path];
[SENAPIClient setValue:userAgent forHTTPHeaderField:@"User-Agent"];
[SENAPIClient setValue:version forHTTPHeaderField:HEMApiXVersionHeader];
[SENAuthorizationService setClientAppID:clientID];
[SENAuthorizationService authorizeRequestsFromKeychain];
Expand Down Expand Up @@ -235,6 +244,8 @@ - (void)configureAppearance {
NSFontAttributeName : [UIFont navButtonTitleFont],
NSForegroundColorAttributeName : [UIColor tintColor]
} forState:UIControlStateNormal];

[UIColor applyDefaultColorAppearances];
}

- (void)createAndShowWindow {
Expand Down
10 changes: 7 additions & 3 deletions SleepModel/HEMAudioButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ - (instancetype)initWithFrame:(CGRect)frame {
- (void)configureDefaults {
[self setContentEdgeInsets:UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, HEMAudioButtonImageRightInset)];
[[self titleLabel] setFont:[UIFont audioPreviewButtonTitleFont]];
[self setTitleColor:[UIColor audioPreviewButtonTitleColor] forState:UIControlStateNormal];
[self setTitleColor:[UIColor lowImportanceTextColor] forState:UIControlStateNormal];
[self setTitleEdgeInsets:UIEdgeInsetsMake(0.0f, HEMAudioButtonTitleLeftInset, 0.0f, 0.0f)];
[self putIconToTheRightOfTitle];
}
Expand Down Expand Up @@ -133,9 +133,13 @@ - (void)fadeLabel:(CGFloat)alpha {
}

- (void)adjustSize {
[self sizeToFit];
CGRect frame = [self frame];
frame.size.width += HEMAudioButtonTitleLeftInset;

CGSize sizeConstraint = CGSizeMake(MAXFLOAT, CGRectGetHeight(frame));
CGFloat sizedWidth = [self sizeThatFits:sizeConstraint].width;

frame.size.width = sizedWidth + HEMAudioButtonTitleLeftInset;

[self setFrame:frame];
}

Expand Down
Loading