Skip to content

Commit

Permalink
Merge pull request #28 from ANGOmarcello/RebootPersist_FETCHONLY
Browse files Browse the repository at this point in the history
Reboot persistence (fetch only)
  • Loading branch information
thomasfinch committed Oct 14, 2015
2 parents bcd6b98 + e141605 commit 31029c3
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion GammaTest.xcodeproj/project.pbxproj
Expand Up @@ -241,7 +241,7 @@
TargetAttributes = {
B9E536451B38D90D0097BF90 = {
CreatedOnToolsVersion = 7.0;
DevelopmentTeam = 45BADQ7L9R;
DevelopmentTeam = WV4RMF773Y;
SystemCapabilities = {
com.apple.BackgroundModes = {
enabled = 1;
Expand Down
20 changes: 11 additions & 9 deletions GammaTest/AppDelegate.m
Expand Up @@ -59,21 +59,23 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[application setMinimumBackgroundFetchInterval:900]; //Wake up every 15 minutes at minimum

[[NSUserDefaults standardUserDefaults] registerDefaults:@{
@"enabled": @NO,
@"maxOrange": [NSNumber numberWithFloat:0.7],
@"colorChangingEnabled": @YES,
@"lastAutoChangeDate": [NSDate distantPast],
@"autoStartHour": @19,
@"autoStartMinute": @0,
@"autoEndHour": @7,
@"autoEndMinute": @0,
}];
@"enabled": @NO,
@"maxOrange": [NSNumber numberWithFloat:0.7],
@"colorChangingEnabled": @YES,
@"lastAutoChangeDate": [NSDate distantPast],
@"autoStartHour": @19,
@"autoStartMinute": @0,
@"autoEndHour": @7,
@"autoEndMinute": @0,
}];

if ([application respondsToSelector:@selector(shortcutItems)] &&
!application.shortcutItems.count) {
[self updateShortCutItem];
}

[GammaController autoChangeOrangenessIfNeeded];

return YES;
}

Expand Down
4 changes: 4 additions & 0 deletions GammaTest/GammaController.m
Expand Up @@ -198,6 +198,10 @@ + (void)wakeUpScreenIfNeeded {
+ (void)autoChangeOrangenessIfNeeded {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

if ([defaults boolForKey:@"enabled"]){
[self enableOrangeness];
}

if (![defaults boolForKey:@"colorChangingEnabled"]) {
return;
}
Expand Down
2 changes: 2 additions & 0 deletions GammaTest/Info.plist
Expand Up @@ -46,6 +46,8 @@
<array>
<string>armv7</string>
</array>
<key>CFBundleDisplayName</key>
<string>Gamma Thingy</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand Down
6 changes: 5 additions & 1 deletion GammaTest/MainViewController.m
Expand Up @@ -43,6 +43,7 @@ - (void)viewDidLoad {

timePicker = [[UIDatePicker alloc] init];
timePicker.datePickerMode = UIDatePickerModeTime;
timePicker.minuteInterval = 15;
timePicker.backgroundColor = [UIColor whiteColor];
[timePicker addTarget:self action:@selector(timePickerValueChanged:) forControlEvents:UIControlEventValueChanged];

Expand Down Expand Up @@ -81,6 +82,8 @@ - (void)updateUI {
}

- (IBAction)enabledSwitchChanged:(UISwitch *)sender {
NSLog(@"enabled: %lu",(unsigned long)sender.on);

if (sender.on)
[GammaController setGammaWithOrangeness:[[NSUserDefaults standardUserDefaults] floatForKey:@"maxOrange"]];
else
Expand All @@ -90,14 +93,15 @@ - (IBAction)enabledSwitchChanged:(UISwitch *)sender {
}

- (IBAction)maxOrangeSliderChanged:(UISlider *)sender {
NSLog(@"maxOrange: %f",sender.value);
[[NSUserDefaults standardUserDefaults] setFloat:sender.value forKey:@"maxOrange"];

if (enabledSwitch.on)
[GammaController setGammaWithOrangeness:sender.value];
}

- (IBAction)colorChangingEnabledSwitchChanged:(UISwitch *)sender {
NSLog(@"color changing switch changed");
NSLog(@"colorChangingEnabled: %lu",(unsigned long)sender.on);
[[NSUserDefaults standardUserDefaults] setBool:sender.on forKey:@"colorChangingEnabled"];
[[NSUserDefaults standardUserDefaults] setObject:[NSDate distantPast] forKey:@"lastAutoChangeDate"];
[GammaController autoChangeOrangenessIfNeeded];
Expand Down
6 changes: 3 additions & 3 deletions GammaTest/Storyboard.storyboard
Expand Up @@ -39,7 +39,7 @@
<rect key="frame" x="0.0" y="99" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Zs9-8L-hUf" id="snd-z7-AzZ">
<rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="NcL-B3-6n9">
Expand Down Expand Up @@ -78,7 +78,7 @@
<rect key="frame" x="0.0" y="193" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="7VE-VY-qs7" id="8Wt-5u-Fxf">
<rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.5" minValue="0.0" maxValue="1" translatesAutoresizingMaskIntoConstraints="NO" id="5MF-0c-fvX">
Expand Down Expand Up @@ -107,7 +107,7 @@
<rect key="frame" x="0.0" y="287" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="99n-2q-Sjq" id="yoE-IK-jwS">
<rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="Of2-4s-WYp">
Expand Down

0 comments on commit 31029c3

Please sign in to comment.